From f33018188bf5bdf6f6b8af0d646e3f8c519d9d71 Mon Sep 17 00:00:00 2001 From: mwturvey Date: Thu, 23 Mar 2017 12:13:44 -0700 Subject: Added support for empty string in config.json & other cleanup. --- src/survive_config.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/survive_config.c') diff --git a/src/survive_config.c b/src/survive_config.c index 0810280..005cfaf 100644 --- a/src/survive_config.c +++ b/src/survive_config.c @@ -175,7 +175,13 @@ const char* config_set_str(config_group *cg, const char *tag, const char* value) if (cv == NULL) cv = next_unused_entry(cg); sstrcpy(&(cv->tag), tag); - sstrcpy(&(cv->data), value); + + if (NULL != value){ + sstrcpy(&(cv->data), value); + } + else { + sstrcpy(&(cv->data), ""); + } cv->type = CONFIG_STRING; return value; @@ -357,9 +363,11 @@ void handle_tag_value(char* tag, char** values, uint8_t count) { print_json_value(tag,values,count); config_group* cg = cg_stack[cg_stack_head]; + if (NULL != *values){ if (parse_uint32(tag,values,count) > 0) return; //parse integers first, stricter rules if (parse_floats(tag,values,count) > 0) return; + } //should probably also handle string arrays config_set_str(cg,tag,values[0]); -- cgit v1.2.3 From ffe28a0d0079f56191e82eb6590c59442357983a Mon Sep 17 00:00:00 2001 From: cnlohr Date: Fri, 7 Apr 2017 00:53:50 -0400 Subject: Remove feature printing out all config items at start. --- src/survive_config.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/survive_config.c') diff --git a/src/survive_config.c b/src/survive_config.c index 005cfaf..3a83902 100644 --- a/src/survive_config.c +++ b/src/survive_config.c @@ -360,7 +360,10 @@ int parse_uint32(char* tag, char** values, uint16_t count) { } void handle_tag_value(char* tag, char** values, uint8_t count) { - print_json_value(tag,values,count); + + //Uncomment for more debugging of input configuration. + //print_json_value(tag,values,count); + config_group* cg = cg_stack[cg_stack_head]; if (NULL != *values){ -- cgit v1.2.3