Changeset b3c169e6 in mainline
- Timestamp:
- 2020-07-05T22:01:59Z (4 years ago)
- Parents:
- 6efe1b78
- git-author:
- Matthieu Riolo <matthieu.riolo@…> (2020-03-14 15:32:12)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2020-07-05 22:01:59)
- Location:
- uspace/lib/conf
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/conf/include/conf/configuration.h
r6efe1b78 rb3c169e6 38 38 /** Value name */ 39 39 const char *name; 40 40 41 41 /** Parse and store given string 42 42 * -
uspace/lib/conf/include/conf/ini.h
r6efe1b78 rb3c169e6 103 103 } ini_item_iterator_t; 104 104 105 106 105 extern void ini_configuration_init(ini_configuration_t *); 107 106 extern void ini_configuration_deinit(ini_configuration_t *); … … 123 122 extern size_t ini_item_iterator_lineno(ini_item_iterator_t *); 124 123 125 126 127 124 #endif -
uspace/lib/conf/include/conf/text_parse.h
r6efe1b78 rb3c169e6 53 53 } text_parse_error_t; 54 54 55 56 55 extern void text_parse_init(text_parse_t *); 57 56 extern void text_parse_deinit(text_parse_t *); -
uspace/lib/conf/src/ini.c
r6efe1b78 rb3c169e6 110 110 } 111 111 112 113 112 static size_t ini_item_ht_hash(const ht_link_t *item) 114 113 { … … 142 141 ini_item_destroy(&ini_item); 143 142 } 144 145 143 146 144 static hash_table_ops_t configuration_ht_ops = { … … 235 233 continue; 236 234 } 237 235 238 236 /* Start new section */ 239 237 if (line[0] == '[') { … … 256 254 *close_bracket = '\0'; 257 255 cur_section->name = str_dup(line + 1); 258 256 259 257 if (!hash_table_insert_unique(&conf->sections, 260 258 &cur_section->ht_link)) { … … 329 327 } 330 328 331 332 333 329 /* 334 330 * Actual INI functions … … 355 351 } 356 352 357 static ini_section_t *ini_section_create(void)353 static ini_section_t *ini_section_create(void) 358 354 { 359 355 ini_section_t *section = malloc(sizeof(ini_section_t)); … … 403 399 } 404 400 405 406 401 /** Parse file contents to INI structure 407 402 * … … 447 442 } 448 443 449 450 444 /** Get a section from configuration 451 445 * … … 476 470 */ 477 471 ini_item_iterator_t ini_section_get_iterator(ini_section_t *section, 478 const char *key)472 const char *key) 479 473 { 480 474 ini_item_iterator_t result; -
uspace/lib/conf/src/text_parse.c
r6efe1b78 rb3c169e6 63 63 */ 64 64 void text_parse_raise_error(text_parse_t *parse, size_t lineno, 65 int parse_errno) { 65 int parse_errno) 66 { 66 67 assert(parse); 67 68 -
uspace/lib/conf/test/ini.c
r6efe1b78 rb3c169e6 39 39 static text_parse_t parse; 40 40 41 PCUT_TEST_BEFORE { 41 PCUT_TEST_BEFORE 42 { 42 43 ini_configuration_init(&ini_conf); 43 44 text_parse_init(&parse); 44 45 } 45 46 46 PCUT_TEST_AFTER { 47 PCUT_TEST_AFTER 48 { 47 49 text_parse_deinit(&parse); 48 50 ini_configuration_deinit(&ini_conf); 49 51 } 50 52 51 PCUT_TEST(simple_parsing) { 53 PCUT_TEST(simple_parsing) 54 { 52 55 const char *data = 53 56 "[Section]\n" … … 68 71 } 69 72 70 PCUT_TEST(default_section) { 73 PCUT_TEST(default_section) 74 { 71 75 const char *data = 72 76 "key = value\n" … … 86 90 } 87 91 88 PCUT_TEST(multikey) { 92 PCUT_TEST(multikey) 93 { 89 94 const char *data = 90 95 "key = value\n" … … 114 119 } 115 120 116 PCUT_TEST(dup_section) { 121 PCUT_TEST(dup_section) 122 { 117 123 const char *data = 118 124 "[Section]\n" … … 133 139 } 134 140 135 PCUT_TEST(empty_section) { 141 PCUT_TEST(empty_section) 142 { 136 143 const char *data = 137 144 "[Section1]\n" -
uspace/lib/conf/test/main.c
r6efe1b78 rb3c169e6 33 33 PCUT_IMPORT(ini); 34 34 35 PCUT_MAIN() 35 PCUT_MAIN();
Note:
See TracChangeset
for help on using the changeset viewer.