From 0ebe84be5824202aecfd87ac58005afa76b36be9 Mon Sep 17 00:00:00 2001 From: Joshua Allen Date: Mon, 6 Mar 2017 22:05:02 -0500 Subject: Load strings from config files. I need to finish the loading of numeric values and arrays. --- src/survive_config.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'src/survive_config.c') diff --git a/src/survive_config.c b/src/survive_config.c index c46e300..d91596f 100644 --- a/src/survive_config.c +++ b/src/survive_config.c @@ -109,6 +109,14 @@ FLT config_read_float(config_group *cg, const char *tag, const FLT def) { config_entry* next_unused_entry(config_group *cg) { config_entry *cv = cg->config_entries + cg->used_entries; assert(cg->used_entries < cg->max_entries); + +/* + if (cg->used_entries >= cg->max_entries) { + cg->max_entries+=10; + cg->config_entries = realloc(cg->config_entries, sizeof(config_entry)*cg->max_entries); + } +*/ + cg->used_entries++; return cv; } @@ -213,3 +221,52 @@ void config_save(const char* path) { fclose(f); } +void print_json_value(char* tag, char** values, uint16_t count) { + uint16_t i = 0; + for (i=0;i1) config_set_str +} + +void config_read(const char* path) { + json_begin_object = handle_config_group; + json_end_object = pop_config_group; + json_tag_value = handle_tag_value; + + cg_stack[0] = &global_config_values; + + json_load_file(path); + + json_begin_object = NULL; + json_end_object = NULL; + json_tag_value = NULL; +} + -- cgit v1.2.3