[asterisk-commits] bkruse: branch group/appdocsxml r128598 - in /team/group/appdocsxml: ./ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jul 7 09:03:37 CDT 2008


Author: bkruse
Date: Mon Jul  7 09:03:36 2008
New Revision: 128598

URL: http://svn.digium.com/view/asterisk?view=rev&rev=128598
Log:
Yay!

It totally works now with the multi-language
support. I feel really stupid going about this
when the app/func register functions are NULL
safe for description and synopsis, instead of
allocating space for a (None) String and passing
it back. Well, it works now!

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

Modified: team/group/appdocsxml/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/Makefile?view=diff&rev=128598&r1=128597&r2=128598
==============================================================================
--- team/group/appdocsxml/Makefile (original)
+++ team/group/appdocsxml/Makefile Mon Jul  7 09:03:36 2008
@@ -669,7 +669,7 @@
 		echo "astrundir => $(ASTVARRUNDIR)" ; \
 		echo "astlogdir => $(ASTLOGDIR)" ; \
 		echo "" ; \
-		echo ";[options]" ; \
+		echo "[options]" ; \
 		echo ";verbose = 3" ; \
 		echo ";debug = 3" ; \
 		echo ";alwaysfork = yes ; same as -F at startup" ; \

Modified: team/group/appdocsxml/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/main/pbx.c?view=diff&rev=128598&r1=128597&r2=128598
==============================================================================
--- team/group/appdocsxml/main/pbx.c (original)
+++ team/group/appdocsxml/main/pbx.c Mon Jul  7 09:03:36 2008
@@ -439,6 +439,24 @@
 static int totalcalls;
 
 static AST_RWLIST_HEAD_STATIC(acf_root, ast_custom_function);
+
+/*** DOCUMENTATION
+	<application name="Answer" language="en">
+		<synopsis>
+			Answer a channel if ringing.
+		</synopsis>
+		<description>
+			  Answer([delay]): If the call has not been answered, this application will
+			answer it. Otherwise, it has no effect on the call. If a delay is specified,
+			Asterisk will wait this number of milliseconds before returning to
+			the dialplan after answering the call.
+		</description>
+		<option name="delay" required="false">
+			Delay that Asterisk will wait in milliseconds before returning to the dialplan after answering the call.
+		</option>
+	</application>
+
+ ***/
 
 /*** DOCUMENTATION
 	<application name="Answer" language="en">
@@ -2603,6 +2621,14 @@
 	if (!acf)
 		return -1;
 
+	/* Let's try to find it in the Documentation XML */
+	/*
+	if (!acf->desc && !acf->synopsis) {
+		acf->synopsis =  syn->child->value.opaque;
+		acf->desc = desc->child->value.opaque;
+	}
+	*/
+
 	AST_RWLIST_WRLOCK(&acf_root);
 	if ((cur = AST_RWLIST_REMOVE(&acf_root, acf, acflist)))
 		ast_verb(2, "Unregistered custom function %s\n", cur->name);
@@ -2611,53 +2637,41 @@
 	return cur ? 0 : -1;
 }
 
-/* XXX Really not sure if I did this memory allocation correctly... */
 static char *ast_mxml_get_field(const char *type, const char *name, const char *var) {
 	
-	char *fail = malloc(6);
 	mxml_node_t *node, *lang_node, *ret;
 
-	node = lang_node = ret = NULL;
-
-	sprintf(fail, "%s", "(None)");	
+	lang_node = NULL;
 
 	if(ast_strlen_zero(type) || ast_strlen_zero(name)) {
 		ast_log(LOG_WARNING, "Tried to look in XML tree with faulty values.\n");
-		return fail;
+		return NULL;
 	}
 
 	/* not fully initted yet */
-	if(documentation_tree == NULL || docs == NULL) {
+	if(documentation_tree == NULL) {
 		ast_log(LOG_DEBUG, "Parsing XML Tree Error\n");
-		return fail; 
-	}
-
-	ast_log(LOG_WARNING, "Searching For: name:'%s' type:'%s' var:'%s'\n", name, type, var);
-	//ret = mxmlFindElement(docs, docs, type, "name", name, MXML_DESCEND);
-	//ret = mxmlFindElement(documentation_tree, documentation_tree, "application", "name", "Dial", MXML_DESCEND);
-
-	if (!ret) {
-		ast_log(LOG_WARNING, "Cannot find Documentation name:'%s' type:'%s' var:'%s'\n", name, type, var);
-		return fail;
-	}
-
-//	lang_node = mxmlFindElement(node, documentation_tree, type, "language", documentation_language, MXML_DESCEND);	
-	
+		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(node, documentation_tree, var, NULL, NULL, MXML_NO_DESCEND);
-//	} else {
-//		ret = mxmlFindElement(lang_node, documentation_tree, var, NULL, NULL, MXML_NO_DESCEND);
-//	}
+	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);
+	}
+
+	ast_log(LOG_ERROR, "Ok, documentation_language is '%s' and lang_node is %s null\n", documentation_language, (lang_node) ? "NOT":"");
 
 	if (!ret || !ret->child) {
 		ast_log(LOG_WARNING, "Cannot find varible '%s' in tree '%s'\n", name, var);
-		return fail;
-	}
-
-	ast_log(LOG_ERROR, "a) '%s' b) '%s' type: '%s', name:'%s', var:'%s'\n", ret->value.opaque, ret->child->value.opaque, type, name, var);
-	/* Dont need fail anymore */
-	free(fail);
+		return NULL;
+	}
+
 	return ret->child->value.opaque;
 }
 
@@ -2674,8 +2688,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");
 
 	}
 
@@ -4422,6 +4436,8 @@
 static int ast_load_documentation(void) {
 
 	FILE *xmldoc;
+	//const char *test;
+	//mxml_node_t *node, *tmp;
 
 	/* For now, I just throw away cdata */
 	xmldoc = fopen(FILE_XML_DOC, "r");
@@ -4443,13 +4459,6 @@
 	}
 
 	fclose(xmldoc);
-
-	docs = mxmlFindElement(documentation_tree, documentation_tree, "docs", NULL, NULL, MXML_DESCEND);
-
-	if(!docs || !docs->child) {
-		ast_log(LOG_ERROR, "Could not find the docs element in the XML documentation.\n");
-		return 1;
-	}
 
 	return 0;
 }




More information about the asterisk-commits mailing list