Lines Matching refs:config
43 static void config_parse(nvs_handle_t fp, config_t *config);
47 static section_t *section_find(const config_t *config, const char *section);
51 static entry_t *entry_find(const config_t *config, const char *section, const char *key);
55 config_t *config = osi_calloc(sizeof(config_t)); in config_new_empty() local
56 if (!config) { in config_new_empty()
61 config->sections = list_new(section_free); in config_new_empty()
62 if (!config->sections) { in config_new_empty()
67 return config; in config_new_empty()
70 config_free(config); in config_new_empty()
78 config_t *config = config_new_empty(); in config_new() local
79 if (!config) { in config_new()
93 config_free(config); in config_new()
97 config_parse(fp, config); in config_new()
99 return config; in config_new()
102 void config_free(config_t *config) in config_free() argument
104 if (!config) { in config_free()
108 list_free(config->sections); in config_free()
109 osi_free(config); in config_free()
112 bool config_has_section(const config_t *config, const char *section) in config_has_section() argument
114 assert(config != NULL); in config_has_section()
117 return (section_find(config, section) != NULL); in config_has_section()
120 bool config_has_key(const config_t *config, const char *section, const char *key) in config_has_key() argument
122 assert(config != NULL); in config_has_key()
126 return (entry_find(config, section, key) != NULL); in config_has_key()
129 bool config_has_key_in_section(config_t *config, const char *key, char *key_value) in config_has_key_in_section() argument
132 …for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); n… in config_has_key_in_section()
148 int config_get_int(const config_t *config, const char *section, const char *key, int def_value) in config_get_int() argument
150 assert(config != NULL); in config_get_int()
154 entry_t *entry = entry_find(config, section, key); in config_get_int()
164 bool config_get_bool(const config_t *config, const char *section, const char *key, bool def_value) in config_get_bool() argument
166 assert(config != NULL); in config_get_bool()
170 entry_t *entry = entry_find(config, section, key); in config_get_bool()
185 const char *config_get_string(const config_t *config, const char *section, const char *key, const c… in config_get_string() argument
187 assert(config != NULL); in config_get_string()
191 entry_t *entry = entry_find(config, section, key); in config_get_string()
199 void config_set_int(config_t *config, const char *section, const char *key, int value) in config_set_int() argument
201 assert(config != NULL); in config_set_int()
207 config_set_string(config, section, key, value_str, false); in config_set_int()
210 void config_set_bool(config_t *config, const char *section, const char *key, bool value) in config_set_bool() argument
212 assert(config != NULL); in config_set_bool()
216 config_set_string(config, section, key, value ? "true" : "false", false); in config_set_bool()
219 void config_set_string(config_t *config, const char *section, const char *key, const char *value, b… in config_set_string() argument
221 section_t *sec = section_find(config, section); in config_set_string()
225 list_append(config->sections, sec); in config_set_string()
227 list_prepend(config->sections, sec); in config_set_string()
244 bool config_remove_section(config_t *config, const char *section) in config_remove_section() argument
246 assert(config != NULL); in config_remove_section()
249 section_t *sec = section_find(config, section); in config_remove_section()
254 return list_remove(config->sections, sec); in config_remove_section()
257 bool config_update_newest_section(config_t *config, const char *section) in config_update_newest_section() argument
259 assert(config != NULL); in config_update_newest_section()
262 list_node_t *first_node = list_begin(config->sections); in config_update_newest_section()
271 …for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); n… in config_update_newest_section()
274 list_delete(config->sections, sec); in config_update_newest_section()
275 list_prepend(config->sections, sec); in config_update_newest_section()
283 bool config_remove_key(config_t *config, const char *section, const char *key) in config_remove_key() argument
285 assert(config != NULL); in config_remove_key()
290 section_t *sec = section_find(config, section); in config_remove_key()
291 entry_t *entry = entry_find(config, section, key); in config_remove_key()
299 ret &= config_remove_section(config, section); in config_remove_key()
304 const config_section_node_t *config_section_begin(const config_t *config) in config_section_begin() argument
306 assert(config != NULL); in config_section_begin()
307 return (const config_section_node_t *)list_begin(config->sections); in config_section_begin()
310 const config_section_node_t *config_section_end(const config_t *config) in config_section_end() argument
312 assert(config != NULL); in config_section_end()
313 return (const config_section_node_t *)list_end(config->sections); in config_section_end()
330 static int get_config_size(const config_t *config) in get_config_size() argument
332 assert(config != NULL); in get_config_size()
336 …for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); n… in get_config_size()
348 if (list_next(node) != list_end(config->sections)) { in get_config_size()
403 bool config_save(const config_t *config, const char *filename) in config_save() argument
405 assert(config != NULL); in config_save()
415 int config_size = get_config_size(config); in config_save()
433 …for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); n… in config_save()
470 if (list_next(node) != list_end(config->sections)) { in config_save()
555 static void config_parse(nvs_handle_t fp, config_t *config) in config_parse() argument
558 assert(config != NULL); in config_parse()
643 config_set_string(config, section, trim(line_ptr), trim(split + 1), true); in config_parse()
689 static section_t *section_find(const config_t *config, const char *section) in section_find() argument
691 …for (const list_node_t *node = list_begin(config->sections); node != list_end(config->sections); n… in section_find()
725 static entry_t *entry_find(const config_t *config, const char *section, const char *key) in entry_find() argument
727 section_t *sec = section_find(config, section); in entry_find()