[asterisk-commits] bkruse: branch group/appdocsxml r128636 - /team/group/appdocsxml/main/pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 7 11:26:15 CDT 2008


Author: bkruse
Date: Mon Jul  7 11:26:13 2008
New Revision: 128636

URL: http://svn.digium.com/view/asterisk?view=rev&rev=128636
Log:
Ok, now it really works :)

Modified:
    team/group/appdocsxml/main/pbx.c

Modified: team/group/appdocsxml/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/main/pbx.c?view=diff&rev=128636&r1=128635&r2=128636
==============================================================================
--- team/group/appdocsxml/main/pbx.c (original)
+++ team/group/appdocsxml/main/pbx.c Mon Jul  7 11:26:13 2008
@@ -337,7 +337,7 @@
 static unsigned int hashtab_hash_labels(const void *obj);
 static void __ast_internal_context_destroy( struct ast_context *con);
 #ifdef XML_DOCUMENTATION
-mxml_node_t *documentation_tree = NULL, *docs = NULL;
+mxml_node_t *documentation_tree = NULL;
 static char *ast_mxml_get_field(const char *type, const char *name, const char *var); 
 void _mxml_error(const char *cb);
 #endif
@@ -2639,9 +2639,10 @@
 
 static char *ast_mxml_get_field(const char *type, const char *name, const char *var) {
 	
-	mxml_node_t *lang_node, *ret;
-
-	lang_node = NULL;
+	const char *tmp = NULL;
+	mxml_node_t *node, *ret;
+
+	node = ret = NULL;
 
 	if(ast_strlen_zero(type) || ast_strlen_zero(name)) {
 		ast_log(LOG_WARNING, "Tried to look in XML tree with faulty values.\n");
@@ -2654,15 +2655,18 @@
 		return NULL; 
 	}
 
-	docs = mxmlFindElement(documentation_tree, documentation_tree, type, "name", name, MXML_DESCEND);
-
-	lang_node = mxmlFindElement(docs, documentation_tree, NULL, "language", documentation_language, MXML_DESCEND);
-
-	/* Could not find language, use the default one without a language */
-	if (!lang_node) {
-		ret = mxmlFindElement(docs, documentation_tree, var, NULL, NULL, MXML_DESCEND);
-	} else {
-		ret = mxmlFindElement(lang_node, documentation_tree, var, NULL, NULL, MXML_DESCEND);
+	for (node = mxmlFindElement(documentation_tree, documentation_tree, type, "name", name, MXML_DESCEND); node != NULL && node->child != NULL; node = mxmlFindElement(node, documentation_tree, type, "name", name, MXML_DESCEND)) {
+		tmp = mxmlElementGetAttr(node, "language");
+		if (!strcmp(tmp, documentation_language)) {
+			ret = mxmlFindElement(node, documentation_tree, var, NULL, NULL, MXML_DESCEND_FIRST);
+			break;
+		}
+	}
+
+	/* If we still could not find the language, chose the first one found (english) */
+	if (!ret) {
+		node = mxmlFindElement(documentation_tree, documentation_tree, type, "name", name, MXML_DESCEND);
+		ret = mxmlFindElement(node, documentation_tree, var, NULL, NULL, MXML_DESCEND);
 	}
 
 	if (!ret || !ret->child) {
@@ -2686,8 +2690,8 @@
 	/* Let's try to find it in the Documentation XML */
 	if (ast_strlen_zero(acf->desc) && ast_strlen_zero(acf->synopsis)) {
 
-		//acf->synopsis = ast_mxml_get_field("function", acf->name, "synopsis");
-		//acf->desc = ast_mxml_get_field("function", acf->name, "description");
+		acf->synopsis = ast_mxml_get_field("function", acf->name, "synopsis");
+		acf->desc = ast_mxml_get_field("function", acf->name, "description");
 
 	}
 




More information about the asterisk-commits mailing list