summaryrefslogtreecommitdiff
path: root/main/config.c
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2015-05-14 17:01:56 -0600
committerGeorge Joseph <george.joseph@fairview5.com>2015-05-15 17:19:49 -0500
commit5d9392817524da02d408f89f78002ea972b0e87c (patch)
tree050d275cf0cf4ab5e4a87c818250daf0b5300b55 /main/config.c
parente7124a30021bbe9ac90c5cb52b9a806fe42db3fc (diff)
res_pjsip_config_wizard/config: Fix template processing
The config wizard was always pulling the first occurrence of a variable from an ast_variable list but this gets the template value from the list instead of any overridden value. This patch creates ast_variable_find_last_in_list() in config.c and updates res_pjsip_config_wizard to use it instead of ast_variable_find_in_list. Now the overridden values, where they exist, are used instead of template variables. Updated test_config to test the new API. ASTERISK-25089 #close Reported-by: George Joseph <george.joseph@fairview5.com> Tested-by: George Joseph <george.joseph@fairview5.com> Change-Id: Ifa7ddefc956a463923ee6839dd1ebe021c299de4
Diffstat (limited to 'main/config.c')
-rw-r--r--main/config.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/main/config.c b/main/config.c
index bc622ccab..d6a077b2d 100644
--- a/main/config.c
+++ b/main/config.c
@@ -735,6 +735,19 @@ const char *ast_variable_find_in_list(const struct ast_variable *list, const cha
return NULL;
}
+const char *ast_variable_find_last_in_list(const struct ast_variable *list, const char *variable)
+{
+ const struct ast_variable *v;
+ const char *found = NULL;
+
+ for (v = list; v; v = v->next) {
+ if (!strcasecmp(variable, v->name)) {
+ found = v->value;
+ }
+ }
+ return found;
+}
+
static struct ast_variable *variable_clone(const struct ast_variable *old)
{
struct ast_variable *new = ast_variable_new(old->name, old->value, old->file);