From 5d9392817524da02d408f89f78002ea972b0e87c Mon Sep 17 00:00:00 2001 From: George Joseph Date: Thu, 14 May 2015 17:01:56 -0600 Subject: 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 Tested-by: George Joseph Change-Id: Ifa7ddefc956a463923ee6839dd1ebe021c299de4 --- include/asterisk/config.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'include') diff --git a/include/asterisk/config.h b/include/asterisk/config.h index 6489344ad..bd268a333 100644 --- a/include/asterisk/config.h +++ b/include/asterisk/config.h @@ -334,6 +334,23 @@ const char *ast_variable_find(const struct ast_category *category, const char *v */ const char *ast_variable_find_in_list(const struct ast_variable *list, const char *variable); +/*! + * \brief Gets the LAST occurrence of a variable from a variable list + * + * \param list The ast_variable list to search + * \param variable The name of the ast_variable you wish to fetch data for + * + * \details + * Iterates over a given ast_variable list to search for the last occurrence of an + * ast_variable entry with a name attribute matching the given name (variable). + * This is useful if the list has duplicate entries (such as in cases where entries + * are created by a template) + * + * \retval The variable value on success + * \retval NULL if unable to find it. + */ +const char *ast_variable_find_last_in_list(const struct ast_variable *list, const char *variable); + /*! * \brief Retrieve a category if it exists * -- cgit v1.2.3