]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
config: Create ast_variable_find_in_list()
authorGeorge Joseph <george.joseph@fairview5.com>
Tue, 2 Dec 2014 00:35:10 +0000 (00:35 +0000)
committerGeorge Joseph <george.joseph@fairview5.com>
Tue, 2 Dec 2014 00:35:10 +0000 (00:35 +0000)
Add
const char *ast_variable_find_in_list(const struct ast_variable *list,
   const char *variable);

ast_variable_find() requires a config category to search whereas
ast_variable_find_in_list() just needs the root list element which is
useful if you don't have a category.

Tested-by: George Joseph
Review: https://reviewboard.asterisk.org/r/4217/

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@428733 65c4cc65-6c06-0410-ace0-fbb531ad65f3

include/asterisk/config.h
main/config.c

index 2f604e0be35572b15fafca7ad6ff3577f18fb706..7f0434d888702cd5e4c49b6b39b7f05ad7b7a829 100644 (file)
@@ -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
  *
index 86485502a69f42030a790b8b24e1071b39aa2ddc..e59bbd24d1d0344155ae06adc41b4e8b60535a61 100644 (file)
@@ -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);
+}
+
+const char *ast_variable_find_in_list(const struct ast_variable *list, const char *variable)
+{
+       const struct ast_variable *v;
 
-       for (v = category->root; v; v = v->next) {
+       for (v = list; v; v = v->next) {
                if (!strcasecmp(variable, v->name)) {
                        return v->value;
                }