diff --git a/include/asterisk/config.h b/include/asterisk/config.h index 2f604e0be3..7f0434d888 100644 --- a/include/asterisk/config.h +++ b/include/asterisk/config.h @@ -311,6 +311,20 @@ const char *ast_variable_retrieve(struct ast_config *config, */ const char *ast_variable_find(const struct ast_category *category, const char *variable); +/*! + * \brief Gets a variable from a variable list + * + * \param list variable list to search + * \param variable which variable you wish to get the data for + * + * \details + * Goes through a given variable list and searches for the given variable + * + * \retval The variable value on success + * \retval NULL if unable to find it. + */ +const char *ast_variable_find_in_list(const struct ast_variable *list, const char *variable); + /*! * \brief Retrieve a category if it exists * diff --git a/main/config.c b/main/config.c index 95f0b696e7..fe3ad3f9a6 100644 --- a/main/config.c +++ b/main/config.c @@ -720,9 +720,14 @@ const char *ast_variable_retrieve_filtered(struct ast_config *config, const char *ast_variable_find(const struct ast_category *category, const char *variable) { - struct ast_variable *v; + return ast_variable_find_in_list(category->root, variable); +} - for (v = category->root; v; v = v->next) { +const char *ast_variable_find_in_list(const struct ast_variable *list, const char *variable) +{ + const struct ast_variable *v; + + for (v = list; v; v = v->next) { if (!strcasecmp(variable, v->name)) { return v->value; }