diff options
author | Costa Tsaousis <costa@tsaousis.gr> | 2016-01-25 22:43:54 +0200 |
---|---|---|
committer | Costa Tsaousis <costa@tsaousis.gr> | 2016-01-25 22:43:54 +0200 |
commit | d158156710b921416b2484abd4ff8e79cdbe68b4 (patch) | |
tree | c879425d604f0494d1b9847523df2fd96b5a88bd /src/appconfig.c | |
parent | e3416e1df3188415d8816ddd78e7760247e1202f (diff) |
fix to update tc (QoS) names if they are updated
Diffstat (limited to 'src/appconfig.c')
-rwxr-xr-x | src/appconfig.c | 38 |
1 files changed, 34 insertions, 4 deletions
diff --git a/src/appconfig.c b/src/appconfig.c index 7cbb053b45..49eca90f0b 100755 --- a/src/appconfig.c +++ b/src/appconfig.c @@ -340,6 +340,34 @@ int config_get_boolean_ondemand(const char *section, const char *name, int value return value; } +const char *config_set_default(const char *section, const char *name, const char *value) +{ + struct config_value *cv; + + debug(D_CONFIG, "request to set config in section '%s', name '%s', value '%s'", section, name, value); + + struct config *co = config_find_section(section); + if(!co) return config_set(section, name, value); + + cv = config_value_index_find(co, name, 0); + if(!cv) return config_set(section, name, value); + + cv->flags |= CONFIG_VALUE_USED; + + if(cv->flags & CONFIG_VALUE_LOADED) + return cv->value; + + if(strcmp(cv->value, value) != 0) { + cv->flags |= CONFIG_VALUE_CHANGED; + + free(cv->value); + cv->value = strdup(value); + if(!cv->value) fatal("Cannot allocate config.value"); + } + + return cv->value; +} + const char *config_set(const char *section, const char *name, const char *value) { struct config_value *cv; @@ -353,11 +381,13 @@ const char *config_set(const char *section, const char *name, const char *value) if(!cv) cv = config_value_create(co, name, value); cv->flags |= CONFIG_VALUE_USED; - if(strcmp(cv->value, value) != 0) cv->flags |= CONFIG_VALUE_CHANGED; + if(strcmp(cv->value, value) != 0) { + cv->flags |= CONFIG_VALUE_CHANGED; - free(cv->value); - cv->value = strdup(value); - if(!cv->value) fatal("Cannot allocate config.value"); + free(cv->value); + cv->value = strdup(value); + if(!cv->value) fatal("Cannot allocate config.value"); + } return value; } |