[svn-commits] eliel: branch group/appdocsxml r139193 - /team/group/appdocsxml/main/pbx.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Aug 20 15:31:39 CDT 2008


Author: eliel
Date: Wed Aug 20 15:31:38 2008
New Revision: 139193

URL: http://svn.digium.com/view/asterisk?view=rev&rev=139193
Log:
Implement argument parsing.

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=139193&r1=139192&r2=139193
==============================================================================
--- team/group/appdocsxml/main/pbx.c (original)
+++ team/group/appdocsxml/main/pbx.c Wed Aug 20 15:31:38 2008
@@ -3333,8 +3333,16 @@
  *  is appended into buffer.
  *  \param node Pointer to the optionlist xml node.
  */
-static void xmldoc_parse_optionlist(char **buffer, int *len, ast_xml_node *node)
-{
+static void xmldoc_parse_optionlist(char **buffer, int *len, ast_xml_node *fixnode)
+{
+	ast_xml_node *node = fixnode;
+
+	if (!node || !node->AST_XML_CHILD) {
+		return;
+	}
+
+	
+
 	return;
 }
 
@@ -3344,9 +3352,33 @@
  *  \param len Output buffer length (will be modified if data is appended to buffer).
  *  \param node Pointer to the 'argument' xml node.
  */
-static void xmldoc_parse_argument(char **buffer, int *len, ast_xml_node *node)
-{
-	return;
+static void xmldoc_parse_argument(char **buffer, int *len, ast_xml_node *fixnode)
+{
+	ast_xml_node *node = fixnode;
+	ast_xml_attr *argname;
+
+	if (!node || !node->AST_XML_CHILD) {
+		return;
+	}
+
+	/* Print the argument names */	
+	argname = ast_xml_get_attribute(node, "name");
+	if (argname) {
+		*buffer = ast_realloc(*buffer, *len + strlen(argname) + 3);
+		*len += sprintf(*buffer + *len, "\t%s\n", argname);
+		ast_xml_free_attr(argname);
+
+		node = node->AST_XML_CHILD;
+		while (node) {
+			xmldoc_parse_para(node, "\t\t", "\n", len, buffer);
+			node = node->AST_XML_NEXT;
+		}
+
+	} else {
+		/* Argument without name, huh? */
+		return;
+	}
+
 }
 
 /*! \internal
@@ -3355,9 +3387,10 @@
  *  \param len Buffer length (will be modified if data is appended to buffer).
  *  \param node A pointer to the 'parameter' xml node.
  */
-static void xmldoc_parse_parameter(char **buffer, int *len, ast_xml_node *node)
+static void xmldoc_parse_parameter(char **buffer, int *len, ast_xml_node *fixnode)
 {
 	ast_xml_attr *paramname;
+	ast_xml_node *node = fixnode;
 
 	if (!node || !node->AST_XML_CHILD || strcasecmp((char *)node->AST_XML_NAME, "parameter")) {
 		return;
@@ -3375,20 +3408,13 @@
 		return;
 	}
 
-	return;
 	node = node->AST_XML_CHILD;
 	while (node) {
 		if (!strcasecmp((char *)node->AST_XML_NAME, "optionlist")) {
 			xmldoc_parse_optionlist(buffer, len, node);
-			node = node->AST_XML_NEXT;
-			continue;
-		}
-		if (!strcasecmp((char *)node->AST_XML_NAME, "argument")) {
+		} else if (!strcasecmp((char *)node->AST_XML_NAME, "argument")) {
 			xmldoc_parse_argument(buffer, len, node);
-			node = node->AST_XML_NEXT;
-			continue;
-		}
-		if ((xmldoc_parse_para(node, "", "", len, buffer))) {
+		} else if ((xmldoc_parse_para(node, "\t", "\n", len, buffer))) {
 			node = node->AST_XML_NEXT;
 			continue;
 		}
@@ -3410,7 +3436,7 @@
 static char *xmldoc_build_arguments(const char *type, const char *name)
 {
 	ast_xml_node *node;
-	char *ret = NULL;
+	char *retnotwrapped = NULL, *ret = NULL;
 	int len = 0;
 	
 	if (ast_strlen_zero(type) || ast_strlen_zero(name)) {
@@ -3439,8 +3465,13 @@
 
 	node = node->AST_XML_CHILD;
 	while (node) {
-		xmldoc_parse_parameter(&ret, &len, node);
+		xmldoc_parse_parameter(&retnotwrapped, &len, node);
 		node = node->AST_XML_NEXT;
+	}
+
+	if (retnotwrapped) {
+		ret = xmldoc_string_wrap(retnotwrapped, XMLDOC_TEXT_COLUMNS, XMLDOC_MAX_DIFF);
+		ast_free(retnotwrapped);
 	}
 
 	return ret;




More information about the svn-commits mailing list