[asterisk-commits] gtjoseph: trunk r428735 - in /trunk: ./ include/asterisk/config.h main/config.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 1 18:38:59 CST 2014


Author: gtjoseph
Date: Mon Dec  1 18:38:56 2014
New Revision: 428735

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=428735
Log:
config: Create ast_variable_find_in_list()

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/
........

Merged revisions 428733 from http://svn.asterisk.org/svn/asterisk/branches/12
........

Merged revisions 428734 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/include/asterisk/config.h
    trunk/main/config.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/include/asterisk/config.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/config.h?view=diff&rev=428735&r1=428734&r2=428735
==============================================================================
--- trunk/include/asterisk/config.h (original)
+++ trunk/include/asterisk/config.h Mon Dec  1 18:38:56 2014
@@ -310,6 +310,20 @@
  * \retval NULL if unable to find it.
  */
 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

Modified: trunk/main/config.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/config.c?view=diff&rev=428735&r1=428734&r2=428735
==============================================================================
--- trunk/main/config.c (original)
+++ trunk/main/config.c Mon Dec  1 18:38:56 2014
@@ -720,9 +720,14 @@
 
 const char *ast_variable_find(const struct ast_category *category, const char *variable)
 {
-	struct ast_variable *v;
-
-	for (v = category->root; v; v = v->next) {
+	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 = list; v; v = v->next) {
 		if (!strcasecmp(variable, v->name)) {
 			return v->value;
 		}




More information about the asterisk-commits mailing list