Changeset a81a950d in mainline
- Timestamp:
- 2020-07-05T21:00:33Z (4 years ago)
- Children:
- 0c01270
- Parents:
- a58727c
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-05-07 11:47:29)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2020-07-05 21:00:33)
- Location:
- uspace/lib/conf
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/conf/include/conf/configuration.h
ra58727c ra81a950d 65 65 /** Code of configuration processing error */ 66 66 typedef enum { 67 CONFIGURATION_EMISSING_ITEM = -1 67 CONFIGURATION_EMISSING_ITEM = -1, 68 CONFIGURATION_EINVAL_BOOL = -2 68 69 } config_error_t; 69 70 … … 74 75 75 76 extern bool config_parse_string(const char *, void *, text_parse_t *, size_t); 77 extern bool config_parse_bool(const char *, void *, text_parse_t *, size_t); 76 78 77 79 #endif -
uspace/lib/conf/src/configuration.c
ra58727c ra81a950d 126 126 return true; 127 127 } 128 129 /** Parse boolean value 130 * 131 * @param[out] dst pointer to bool 132 * 133 * @return true on success 134 * @return false on parse error 135 */ 136 bool config_parse_bool(const char *string, void *dst, text_parse_t *parse, 137 size_t lineno) 138 { 139 bool value; 140 if (stricmp(string, "true") == 0 || 141 stricmp(string, "yes") == 0 || 142 stricmp(string, "1") == 0) { 143 value = true; 144 } else if (stricmp(string, "false") == 0 || 145 stricmp(string, "no") == 0 || 146 stricmp(string, "0") == 0) { 147 value = false; 148 } else { 149 text_parse_raise_error(parse, lineno, 150 CONFIGURATION_EINVAL_BOOL); 151 return false; 152 } 153 154 bool *bool_dst = dst; 155 *bool_dst = value; 156 return true; 157 }
Note:
See TracChangeset
for help on using the changeset viewer.