aboutsummaryrefslogtreecommitdiffstats
path: root/main/config.c
diff options
context:
space:
mode:
authormurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-19 15:41:13 +0000
committermurf <murf@f38db490-d61c-443f-a65b-d21fe96a405b>2008-03-19 15:41:13 +0000
commit4d7555f78e5a7df29a6fcb489c512f84750808c1 (patch)
tree5b3d13f01ec6278724711aeeef2ed97801812a7c /main/config.c
parent37035e351808cc81c40d54e688661d5dd5b1131e (diff)
(closes issue #11442)
Reported by: tzafrir Patches: 11442.patch uploaded by murf (license 17) Tested by: murf I didn't give tzafrir very much time to test this, but if he does still have remaining issues, he is welcome to re-open this bug, and we'll do what is called for. I reproduced the problem, and tested the fix, so I hope I am not jumping by just going ahead and committing the fix. The problem was with what file_save does with templates; firstly, it tended to print out multiple options: [my_category](!)(templateref) instead of [my_category](!,templateref) which is fixed by this patch. Nextly, the code to suppress output of duplicate declarations that would occur because the reader copies inherited declarations down the hierarchy, was not working. Thus: [master-template](!) mastervar = bar [template](!,master-template) tvar = value [cat](template) catvar = val would be rewritten as: ;! ;! Automatically generated configuration file ;! Filename: experiment.conf (/etc/asterisk/experiment.conf) ;! Generator: Manager ;! Creation Date: Tue Mar 18 23:17:46 2008 ;! [master-template](!) mastervar = bar [template](!,master-template) mastervar = bar tvar = value [cat](template) mastervar = bar tvar = value catvar = val This has been fixed. Since the config reader 'explodes' inherited vars into the category, users may, in certain circumstances, see output different from what they originally entered, but it should be both correct and equivalent. git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@109908 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'main/config.c')
-rw-r--r--main/config.c31
1 files changed, 21 insertions, 10 deletions
diff --git a/main/config.c b/main/config.c
index 2740640a5..00cc0d836 100644
--- a/main/config.c
+++ b/main/config.c
@@ -1042,15 +1042,21 @@ int config_text_file_save(const char *configfile, const struct ast_config *cfg,
if (!cat->precomments)
fprintf(f,"\n");
fprintf(f, "[%s]", cat->name);
- if (cat->ignored)
- fprintf(f, "(!)");
- if (!AST_LIST_EMPTY(&cat->template_instances)) {
- struct ast_category_template_instance *x;
+ if (cat->ignored || !AST_LIST_EMPTY(&cat->template_instances)) {
fprintf(f, "(");
- AST_LIST_TRAVERSE(&cat->template_instances, x, next) {
- fprintf(f,"%s",x->name);
- if (x != AST_LIST_LAST(&cat->template_instances))
- fprintf(f,",");
+ if (cat->ignored) {
+ fprintf(f, "!");
+ }
+ if (cat->ignored && !AST_LIST_EMPTY(&cat->template_instances)) {
+ fprintf(f, ",");
+ }
+ if (!AST_LIST_EMPTY(&cat->template_instances)) {
+ struct ast_category_template_instance *x;
+ AST_LIST_TRAVERSE(&cat->template_instances, x, next) {
+ fprintf(f,"%s",x->name);
+ if (x != AST_LIST_LAST(&cat->template_instances))
+ fprintf(f,",");
+ }
}
fprintf(f, ")");
}
@@ -1063,10 +1069,15 @@ int config_text_file_save(const char *configfile, const struct ast_config *cfg,
var = cat->root;
while(var) {
struct ast_category_template_instance *x;
+ struct ast_variable *v2;
int found = 0;
AST_LIST_TRAVERSE(&cat->template_instances, x, next) {
- const char *pvalue = ast_variable_retrieve(cfg, x->name, var->name);
- if (pvalue && !strcmp(pvalue, var->value)) {
+
+ for (v2 = x->inst->root; v2; v2 = v2->next) {
+ if (!strcasecmp(var->name, v2->name))
+ break;
+ }
+ if (v2 && v2->value && !strcmp(v2->value, var->value)) {
found = 1;
break;
}