[asterisk-commits] eliel: branch group/appdocsxml r137286 - /team/group/appdocsxml/main/pbx.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Aug 12 10:44:43 CDT 2008


Author: eliel
Date: Tue Aug 12 10:44:43 2008
New Revision: 137286

URL: http://svn.digium.com/view/asterisk?view=rev&rev=137286
Log:
Simplify function naming. It is not recommended to call it ast_ when they are static functions.
Join 'xml_doc' into 'xmldoc' (Hey I have reduced it one char!).
Make documentation_language and documentation_tree static.


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=137286&r1=137285&r2=137286
==============================================================================
--- team/group/appdocsxml/main/pbx.c (original)
+++ team/group/appdocsxml/main/pbx.c Tue Aug 12 10:44:43 2008
@@ -287,8 +287,8 @@
 
 #ifdef XML_DOCUMENTATION
 #define DEFAULT_DOCUMENTATION_LANGUAGE "en_US"
-char documentation_language[80];
-ast_xml_doc *documentation_tree = NULL;
+static char documentation_language[80];
+static ast_xml_doc *documentation_tree = NULL;
 #endif
 
 static int pbx_builtin_answer(struct ast_channel *, void *);
@@ -2802,7 +2802,7 @@
  *  \retval NULL on error.
  *  \retval A node of type ast_xml_node.
  */
-static ast_xml_node *ast_xml_doc_get_node(ast_xml_doc *doc, const char *type, const char *name, const char *language)
+static ast_xml_node *xmldoc_get_node(ast_xml_doc *doc, const char *type, const char *name, const char *language)
 {
 	ast_xml_node *node;
 	char *lang;
@@ -2848,7 +2848,7 @@
  *  \param fmtrev A format string that will be used in a sprintf call when reverse=1, it must always have a %s
  *         inside it, event if not used.
  */
-static void ast_xml_doc_reverse_helper(int reverse, int *len, char **syntax, const char *paramname, char *fmt, char *fmtrev)
+static void xmldoc_reverse_helper(int reverse, int *len, char **syntax, const char *paramname, char *fmt, char *fmtrev)
 {
 	int fmtlen = (reverse ? strlen(fmtrev) : strlen(fmt));
 	int i;
@@ -2886,7 +2886,7 @@
  *  \param name Name of the application or function to build the syntax.
  *  \retval NULL on error.
  *  \retval A ast_malloc'ed string with the syntax generated. */
-static char *ast_xml_doc_build_syntax(const char *type, const char *name) 
+static char *xmldoc_build_syntax(const char *type, const char *name) 
 {
 #define GOTONEXT(__rev, __a) (__rev ? __a->AST_XML_PREV : __a->AST_XML_NEXT)
 #define ISLAST(__rev, __a)  (__rev == 1 ? (__a->AST_XML_PREV ? 0 : 1) : (__a->AST_XML_NEXT ? 0 : 1))
@@ -2900,7 +2900,7 @@
 		return NULL;
 	}
 
-	node = ast_xml_doc_get_node(documentation_tree, type, name, documentation_language);
+	node = xmldoc_get_node(documentation_tree, type, name, documentation_language);
 	if (!node || !node->AST_XML_CHILD) {
 		return NULL;
 	}
@@ -2987,9 +2987,9 @@
 
 	/* init syntax string. */
 	if (!reverse) {
-		ast_xml_doc_reverse_helper(reverse, &len, &syntax, name, "%s(", "");
+		xmldoc_reverse_helper(reverse, &len, &syntax, name, "%s(", "");
 	} else {
-		ast_xml_doc_reverse_helper(reverse, &len, &syntax, "", "", "%s)");
+		xmldoc_reverse_helper(reverse, &len, &syntax, "", "", "%s)");
 	}
 
 	while (node) {
@@ -3025,23 +3025,23 @@
 		if (required) {
 			/* First parameter */
 			if (!paramcount) {
-				ast_xml_doc_reverse_helper(reverse, &len, &syntax, (const char *)paramname, "%s", "%s");
+				xmldoc_reverse_helper(reverse, &len, &syntax, (const char *)paramname, "%s", "%s");
 			} else {
 				while (openbrackets > 0) {
-					ast_xml_doc_reverse_helper(reverse, &len, &syntax, "", "%s]", "[%s");
+					xmldoc_reverse_helper(reverse, &len, &syntax, "", "%s]", "[%s");
 					openbrackets--;
 				}
-				ast_xml_doc_reverse_helper(reverse, &len, &syntax, (const char *)paramname, ",%s", "%s,");
+				xmldoc_reverse_helper(reverse, &len, &syntax, (const char *)paramname, ",%s", "%s,");
 			}
 		} else {
 			/* First parameter */
 			if (!paramcount) {
-				ast_xml_doc_reverse_helper(reverse, &len, &syntax, (const char *)paramname, "[%s]", "[%s]");
+				xmldoc_reverse_helper(reverse, &len, &syntax, (const char *)paramname, "[%s]", "[%s]");
 			} else {
 				if (ISLAST(reverse, node)) {
-					ast_xml_doc_reverse_helper(reverse, &len, &syntax, (const char *)paramname, ",[%s]", "[%s],");
+					xmldoc_reverse_helper(reverse, &len, &syntax, (const char *)paramname, ",[%s]", "[%s],");
 				} else {
-					ast_xml_doc_reverse_helper(reverse, &len, &syntax, (const char *)paramname, "[,%s", "%s,]");
+					xmldoc_reverse_helper(reverse, &len, &syntax, (const char *)paramname, "[,%s", "%s,]");
 					openbrackets++;
 				}
 			}
@@ -3054,15 +3054,15 @@
 	}
 
 	while (openbrackets > 0) {
-		ast_xml_doc_reverse_helper(reverse, &len, &syntax, "", "%s]", "%s[");
+		xmldoc_reverse_helper(reverse, &len, &syntax, "", "%s]", "%s[");
 		openbrackets--;
 	}
 
 	/* close syntax string. */
 	if (!reverse) {	
-		ast_xml_doc_reverse_helper(reverse, &len, &syntax, "", "%s)", "");
+		xmldoc_reverse_helper(reverse, &len, &syntax, "", "%s)", "");
 	} else {
-		ast_xml_doc_reverse_helper(reverse, &len, &syntax, name, "", "%s(");
+		xmldoc_reverse_helper(reverse, &len, &syntax, name, "", "%s(");
 	}
 
 	return syntax;
@@ -3080,7 +3080,7 @@
  *  \retval 1 on succes.
  *  \retval 0 on error.
  */
-static int ast_xml_doc_parse_para(ast_xml_node *node, const char *tabs, const char *posttabs, int *len, char **buffer)
+static int xmldoc_parse_para(ast_xml_node *node, const char *tabs, const char *posttabs, int *len, char **buffer)
 {
 	ast_xml_text *tmptext;
 
@@ -3112,7 +3112,7 @@
  *  	   to store the result (if already has something it will be appended to the current
  *  	   string).
  */
-static void ast_xml_doc_parse_variable(ast_xml_node *node, const char *tabs, int *len, char **buffer)
+static void xmldoc_parse_variable(ast_xml_node *node, const char *tabs, int *len, char **buffer)
 {
 	ast_xml_node *tmp;
 	ast_xml_attr *valname;
@@ -3125,7 +3125,7 @@
 	tmp = node->AST_XML_CHILD;
 	while (tmp) {
 		/* XXX: increment by one tab the tabs? */
-		if (ast_xml_doc_parse_para(tmp, tabs, "\n", len, buffer)) {
+		if (xmldoc_parse_para(tmp, tabs, "\n", len, buffer)) {
 			tmp = tmp->AST_XML_NEXT;
 			continue;
 		}
@@ -3165,7 +3165,7 @@
  *  \retval 1 If a <variablelist> element is parsed.
  *  \retval 0 On error.
  */
-static int ast_xml_doc_parse_variablelist(ast_xml_node *node, const char *tabs, int *len, char **buffer)
+static int xmldoc_parse_variablelist(ast_xml_node *node, const char *tabs, int *len, char **buffer)
 {
 	ast_xml_node *tmp;
 	ast_xml_attr *varname;
@@ -3181,7 +3181,7 @@
 	tmp = node->AST_XML_CHILD;
 	while (tmp) {
 		/* We can have a <para> element inside the variable list ?? */
-		if ((ast_xml_doc_parse_para(tmp, "", "", len, buffer))) {
+		if ((xmldoc_parse_para(tmp, "", "", len, buffer))) {
 			tmp = tmp->AST_XML_NEXT;
 			continue;
 		}
@@ -3195,7 +3195,7 @@
 				ast_xml_free_attr(varname);
 			}
 			/* Parse the <variable> possible values. */
-			ast_xml_doc_parse_variable(tmp, "\t\t", len, buffer);
+			xmldoc_parse_variable(tmp, "\t\t", len, buffer);
 		}
 		tmp = tmp->AST_XML_NEXT;
 	}
@@ -3208,7 +3208,7 @@
  *  \retval NULL on error
  *  \retval Node content on success.
  */
-static char *ast_xml_doc_get_formatted(ast_xml_node *node)
+static char *xmldoc_get_formatted(ast_xml_node *node)
 {
 	ast_xml_node *tmp;
 	char *ret = NULL;
@@ -3224,12 +3224,12 @@
 		tmp = node->AST_XML_CHILD;
 		while (tmp) {
 			/* if found, parse a <para> element. */
-			if (ast_xml_doc_parse_para(tmp, "", "\n", &len, &ret)) {
+			if (xmldoc_parse_para(tmp, "", "\n", &len, &ret)) {
 				tmp = tmp->AST_XML_NEXT;
 				continue;
 			}
 			/* if found, parse a <variablelist> element. */
-			ast_xml_doc_parse_variablelist(tmp, "\n", &len, &ret);
+			xmldoc_parse_variablelist(tmp, "\n", &len, &ret);
 			
 			tmp = tmp->AST_XML_NEXT;
 		}
@@ -3244,7 +3244,7 @@
  *  \retval NULL On error.
  *  \retval Field text content on success.
  */
-static char *ast_xml_doc_get_field(const char *type, const char *name, const char *var)
+static char *xmldoc_get_field(const char *type, const char *name, const char *var)
 {
 	ast_xml_node *node;
 
@@ -3259,7 +3259,7 @@
 		return NULL; 
 	}
 
-	node = ast_xml_doc_get_node(documentation_tree, type, name, documentation_language);
+	node = xmldoc_get_node(documentation_tree, type, name, documentation_language);
 		
 	if (!node) {
 		ast_log(LOG_ERROR, "Counldn't find %s %s in XML documentation\n", type, name);
@@ -3273,7 +3273,7 @@
 		return NULL;
 	}
 
-	return ast_xml_doc_get_formatted(node);
+	return xmldoc_get_formatted(node);
 }
 #endif /* XML_DOCUMENTATION */
 
@@ -3291,9 +3291,9 @@
 #ifdef XML_DOCUMENTATION
 	/* Let's try to find it in the Documentation XML */
 	if (ast_strlen_zero(acf->desc) && ast_strlen_zero(acf->synopsis)) {
-		acf->synopsis = ast_xml_doc_get_field("function", acf->name, "synopsis");
-		acf->desc = ast_xml_doc_get_field("function", acf->name, "description");
-		acf->syntax = ast_xml_doc_build_syntax("application", acf->name);
+		acf->synopsis = xmldoc_get_field("function", acf->name, "synopsis");
+		acf->desc = xmldoc_get_field("function", acf->name, "description");
+		acf->syntax = xmldoc_build_syntax("application", acf->name);
 		acf->docsrc = AST_XML_DOC;
 	}
 #endif
@@ -5003,9 +5003,9 @@
 #ifdef XML_DOCUMENTATION
 	/* Try to lookup the docs in our XML documentation database */
 	if (ast_strlen_zero(synopsis) && ast_strlen_zero(description)) {
-		tmp->synopsis = ast_xml_doc_get_field("application", app, "synopsis");
-		tmp->description = ast_xml_doc_get_field("application", app, "description");
-		tmp->syntax = ast_xml_doc_build_syntax("application", app);
+		tmp->synopsis = xmldoc_get_field("application", app, "synopsis");
+		tmp->description = xmldoc_get_field("application", app, "description");
+		tmp->syntax = xmldoc_build_syntax("application", app);
 		tmp->docsrc = AST_XML_DOC;
 	} else {
 #endif




More information about the asterisk-commits mailing list