[svn-commits] eliel: branch group/appdocsxml r151510 - in /team/group/appdocsxml: include/a...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Oct 22 09:55:59 CDT 2008


Author: eliel
Date: Wed Oct 22 09:55:58 2008
New Revision: 151510

URL: http://svn.digium.com/view/asterisk?view=rev&rev=151510
Log:
Many minor fixes pointed by russellb in the reviewboard.
- Move code according to coding guidelines.
- Try to avoid indententation when checking for null values, etc.
- node->AST_XML_NAME should be caster to (const char *) instead of (char *).
- Remove mxml from the Makefile.
- Use sizeof() instead of counting again for the array size.
- Remove trailing spaces.
- Change the return value of ast_xml_get_text() to 'const char *'.

Modified:
    team/group/appdocsxml/include/asterisk/extconf.h
    team/group/appdocsxml/include/asterisk/strings.h
    team/group/appdocsxml/include/asterisk/xml.h
    team/group/appdocsxml/main/Makefile
    team/group/appdocsxml/main/pbx.c
    team/group/appdocsxml/main/xml.c

Modified: team/group/appdocsxml/include/asterisk/extconf.h
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/include/asterisk/extconf.h?view=diff&rev=151510&r1=151509&r2=151510
==============================================================================
--- team/group/appdocsxml/include/asterisk/extconf.h (original)
+++ team/group/appdocsxml/include/asterisk/extconf.h Wed Oct 22 09:55:58 2008
@@ -72,12 +72,6 @@
 };
 
 /* ================== above: the config world; below, the dialplan world */
-
-/*! \brief From where the documentation come from */
-enum doc_src {
-	AST_XML_DOC,		/*!< From XML documentation */
-	AST_STATIC_DOC		/*!< From application/function registration */
-};
 
 /*! \brief A registered application */
 struct ast_app {

Modified: team/group/appdocsxml/include/asterisk/strings.h
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/include/asterisk/strings.h?view=diff&rev=151510&r1=151509&r2=151510
==============================================================================
--- team/group/appdocsxml/include/asterisk/strings.h (original)
+++ team/group/appdocsxml/include/asterisk/strings.h Wed Oct 22 09:55:58 2008
@@ -393,10 +393,11 @@
 AST_INLINE_API(
 void ast_str_trim_blanks(struct ast_str *buf),
 {
-	if (buf) {
-		while (buf->used && buf->str[buf->used - 1] < 33) {
-			buf->str[--(buf->used)] = '\0';
-		}
+	if (!buf) {
+		return;
+	}
+	while (buf->used && buf->str[buf->used - 1] < 33) {
+		buf->str[--(buf->used)] = '\0';
 	}
 }
 )

Modified: team/group/appdocsxml/include/asterisk/xml.h
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/include/asterisk/xml.h?view=diff&rev=151510&r1=151509&r2=151510
==============================================================================
--- team/group/appdocsxml/include/asterisk/xml.h (original)
+++ team/group/appdocsxml/include/asterisk/xml.h Wed Oct 22 09:55:58 2008
@@ -33,7 +33,7 @@
 typedef xmlNode ast_xml_node;
 typedef xmlDoc ast_xml_doc;
 typedef char ast_xml_attr;
-typedef char ast_xml_text;
+typedef const char ast_xml_text;
 
 /* Node member mapping, not always the child node is called 'children' */
 #define AST_XML_CHILD	children
@@ -120,7 +120,7 @@
  *  \retval NULL on error.
  *  \retval The text content of node.
  */
-char *ast_xml_get_text(ast_xml_node *node);
+const char *ast_xml_get_text(ast_xml_node *node);
 
 /* Features using ast_xml_ */
 #define XML_DOCUMENTATION

Modified: team/group/appdocsxml/main/Makefile
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/main/Makefile?view=diff&rev=151510&r1=151509&r2=151510
==============================================================================
--- team/group/appdocsxml/main/Makefile (original)
+++ team/group/appdocsxml/main/Makefile Wed Oct 22 09:55:58 2008
@@ -41,7 +41,6 @@
 
 AST_LIBS += $(SSL_LIB)
 AST_LIBS += $(BKTR_LIB)
-AST_LIBS += -lmxml -L../menuselect/mxml
 AST_LIBS += $(LIBXML2_LIB) 
 
 ifeq ($(POLL_AVAILABLE),)

Modified: team/group/appdocsxml/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/main/pbx.c?view=diff&rev=151510&r1=151509&r2=151510
==============================================================================
--- team/group/appdocsxml/main/pbx.c (original)
+++ team/group/appdocsxml/main/pbx.c Wed Oct 22 09:55:58 2008
@@ -3007,22 +3007,28 @@
 		return ret;
 	}
 
-	if (a->argc < 4)
+	if (a->argc < 4) {
 		return CLI_SHOWUSAGE;
+	}
 
 	if (!(acf = ast_custom_function_find(a->argv[3]))) {
 		ast_cli(a->fd, "No function by that name registered.\n");
 		return CLI_FAILURE;
 	}
 
-	if (!ast_strlen_zero(acf->syntax))
+	if (!ast_strlen_zero(acf->syntax)) {
 		syntax_size = strlen(acf->syntax) + 23;
-	else
+	} else {
 		syntax_size = strlen("Not available") + 23;
+	}
 	syntax = ast_malloc(syntax_size);
-
-	snprintf(info, 64 + AST_MAX_APP, "\n  -= Info about function '%s' =- \n\n", acf->name);
-	term_color(infotitle, info, COLOR_MAGENTA, 0, 64 + AST_MAX_APP + 22);
+	if (!syntax) {
+		ast_cli(a->fd, "Memory allocation failure!\n");
+		return CLI_FAILURE;
+	}
+
+	snprintf(info, sizeof(info), "\n  -= Info about function '%s' =- \n\n", acf->name);
+	term_color(infotitle, info, COLOR_MAGENTA, 0, sizeof(infotitle));
 	term_color(stxtitle, "[Syntax]\n", COLOR_MAGENTA, 0, 40);
 	term_color(argtitle, "[Arguments]\n", COLOR_MAGENTA, 0, 40);
 	term_color(syntitle, "[Synopsis]\n", COLOR_MAGENTA, 0, 40);
@@ -3035,30 +3041,45 @@
 	description = xmldoc_colorization(S_OR(acf->desc, "Not available"), COLOR_CYAN, COLOR_BLACK);
 	seealso = xmldoc_colorization(S_OR(acf->seealso, "Not available"), COLOR_CYAN, COLOR_BLACK);
 #else
-	if (!ast_strlen_zero(acf->synopsis))
+	if (!ast_strlen_zero(acf->synopsis)) {
 		synopsis_size = strlen(acf->synopsis) + 23;
-	else
+	} else {
 		synopsis_size = strlen("Not available") + 23;
+	}
 	synopsis = ast_malloc(synopsis_size);
 
-	if (!ast_strlen_zero(acf->desc))
+	if (!ast_strlen_zero(acf->desc)) {
 		description_size = strlen(acf->desc) + 23;
-	else
+	} else {
 		description_size = strlen("Not available") + 23;
+	}
 	description = ast_malloc(description_size);
 
-	if (!ast_strlen_zero(acf->arguments))
+	if (!ast_strlen_zero(acf->arguments)) {
 		arguments_size = strlen(acf->arguments) + 23;
-	else
+	} else {
 		arguments_size = strlen("Not available") + 23;
+	}
 	arguments = ast_malloc(arguments_size);
 
-	if (!ast_strlen_zero(acf->seealso))
+	if (!ast_strlen_zero(acf->seealso)) {
 		seealso_size = strlen(acf->seealso) + 23;
-	else
+	} else {
 		seealso_size = strlen("Not available") + 23;
+	}
 	seealso = ast_malloc(seealso_size);
 
+	/* check allocated memory. */
+	if (!synopsis || !description || !arguments || !seealso) {
+		ast_cli(a->fd, "Memory allocation failure!\n");
+		ast_free(synopsis);
+		ast_free(description);
+		ast_free(arguments);
+		ast_free(seealso);
+		ast_free(syntax);
+		return CLI_FAILURE;
+	}
+	
 	term_color(arguments, S_OR(acf->arguments, "Not available"), COLOR_CYAN, 0, arguments_size);
 	term_color(synopsis, S_OR(acf->synopsis, "Not available"), COLOR_CYAN, 0, synopsis_size);
 	term_color(description, S_OR(acf->desc, "Not available"), COLOR_CYAN, 0, description_size);
@@ -3157,14 +3178,15 @@
 	int postbrreallen = 0, i;
 	size_t postbrlen;
 
-	if (postbr) {
-		postbrlen = strlen(postbr);
-		for (i = 0; i < postbrlen; i++) {
-			if (postbr[i] == '\t') {
-				postbrreallen += 8 - (postbrreallen % 8);
-			} else {
-				postbrreallen++;
-			}
+	if (!postbr) {
+		return 0;
+	}
+	postbrlen = strlen(postbr);
+	for (i = 0; i < postbrlen; i++) {
+		if (postbr[i] == '\t') {
+			postbrreallen += 8 - (postbrreallen % 8);
+		} else {
+			postbrreallen++;
 		}
 	}
 	return postbrreallen;
@@ -3371,27 +3393,29 @@
 			if (!strncasecmp(bwinput + i, colorized_tags[c].inittag, strlen(colorized_tags[c].inittag))) {
 				tmp = strcasestr(bwinput + i + strlen(colorized_tags[c].inittag), colorized_tags[c].endtag);
 
-				if (tmp) {
-					len = tmp - (bwinput + i + strlen(colorized_tags[c].inittag));
-					/* Setup color */
-					term_color_code(colorized + strlen(colorized), colorized_tags[c].colorfg, colorized_tags[c].colorbg, 23);
-
-					/* copy initial string replace */
-					ast_copy_string(colorized + strlen(colorized), colorized_tags[c].init, strlen(colorized_tags[c].init) + 1);
-
-					ast_copy_string(colorized + strlen(colorized), bwinput + i + strlen(colorized_tags[c].inittag), len + 1);
-
-					/* copy the ending string replace */
-					ast_copy_string(colorized + strlen(colorized), colorized_tags[c].end, strlen(colorized_tags[c].end) + 1);
-
-					/* Continue with the last color. */
-					term_color_code(colorized + strlen(colorized), base_fg, base_bg, 23);
-
-					i += len + strlen(colorized_tags[c].endtag) + strlen(colorized_tags[c].inittag) - 1;
-					actual_len = strlen(colorized);
-					colorsection = 1;
-					break;
+				if (!tmp) {
+					continue;
 				}
+
+				len = tmp - (bwinput + i + strlen(colorized_tags[c].inittag));
+
+				/* Setup color */
+				term_color_code(colorized + strlen(colorized), colorized_tags[c].colorfg, colorized_tags[c].colorbg, 23);
+
+				/* copy initial string replace */
+				ast_copy_string(colorized + strlen(colorized), colorized_tags[c].init, strlen(colorized_tags[c].init) + 1);
+				ast_copy_string(colorized + strlen(colorized), bwinput + i + strlen(colorized_tags[c].inittag), len + 1);
+
+				/* copy the ending string replace */
+				ast_copy_string(colorized + strlen(colorized), colorized_tags[c].end, strlen(colorized_tags[c].end) + 1);
+
+				/* Continue with the last color. */
+				term_color_code(colorized + strlen(colorized), base_fg, base_bg, 23);
+
+				i += len + strlen(colorized_tags[c].endtag) + strlen(colorized_tags[c].inittag) - 1;
+				actual_len = strlen(colorized);
+				colorsection = 1;
+				break;
 			}
 		}
 		if (!colorsection) {
@@ -3561,7 +3585,7 @@
 	ast_xml_node *node = fixnode;
 
 	for (node = fixnode->AST_XML_CHILD; node; node = node->AST_XML_NEXT) {
-		if (!strcasecmp((char *)node->AST_XML_NAME, "argument")) {
+		if (!strcasecmp((const char *)node->AST_XML_NAME, "argument")) {
 			return 1;
 		}
 	}
@@ -3612,7 +3636,7 @@
 
 	/* Get order of evaluation. */
 	for (node = rootnode->AST_XML_CHILD; node; node = node->AST_XML_NEXT) {
-		if (strcasecmp((char *)node->AST_XML_NAME, childname)) {
+		if (strcasecmp((const char *)node->AST_XML_NAME, childname)) {
 			continue;
 		}
 		required = 0;
@@ -3643,7 +3667,7 @@
 	if (reqfinode && reqlanode) {
 		/* check midnode */
 		for (node = rootnode->AST_XML_CHILD; node; node = node->AST_XML_NEXT) {
-			if (strcasecmp((char *)node->AST_XML_NAME, childname)) {
+			if (strcasecmp((const char *)node->AST_XML_NAME, childname)) {
 				continue;
 			}
 			if (node != firstparam && node != lastparam) {
@@ -3674,7 +3698,7 @@
 	}
 
 	for (; node; node = GOTONEXT(reverse, node)) {
-		if (strcasecmp((char *)node->AST_XML_NAME, childname)) {
+		if (strcasecmp((const char *)node->AST_XML_NAME, childname)) {
 			continue;
 		}
 
@@ -3699,7 +3723,7 @@
 		/* Defaults to 'false'. */
 		multiple = 0;
 		if ((multipletype = ast_xml_get_attribute(node, "multiple"))) {
-			if (ast_true((char *)multipletype)) {
+			if (ast_true(multipletype)) {
 				multiple = 1;
 			}
 			ast_xml_free_attr(multipletype);
@@ -3707,7 +3731,7 @@
 
 		required = 0;	/* Defaults to 'false'. */
 		if ((paramtype = ast_xml_get_attribute(node, "required"))) {
-			if (ast_true((char *)paramtype)) {
+			if (ast_true(paramtype)) {
 				required = 1;
 			}
 			ast_xml_free_attr(paramtype);
@@ -3801,7 +3825,7 @@
 	}
 
 	for (node = node->AST_XML_CHILD; node; node = node->AST_XML_NEXT) {
-		if (!strcasecmp((char *)node->AST_XML_NAME, "syntax")) {
+		if (!strcasecmp((const char *)node->AST_XML_NAME, "syntax")) {
 			break;
 		}
 	}
@@ -3835,7 +3859,7 @@
 		return ret;
 	}
 
-	if (strcasecmp((char *)node->AST_XML_NAME, "para")) {
+	if (strcasecmp((const char *)node->AST_XML_NAME, "para")) {
 		return ret;
 	}
 
@@ -3851,7 +3875,7 @@
 			xmldoc_string_cleanup(tmptext, &tmpstr, 0);
 			ast_xml_free_text(tmptext);
 			if (tmpstr) {
-				if (strcasecmp((char *)tmp->AST_XML_NAME, "text")) {
+				if (strcasecmp((const char *)tmp->AST_XML_NAME, "text")) {
 					ast_str_append(buffer, 0, "<%s>%s</%s>", tmp->AST_XML_NAME, tmpstr->str, tmp->AST_XML_NAME);
 				} else {
 					ast_str_append(buffer, 0, "%s", tmpstr->str);
@@ -3887,7 +3911,7 @@
 	}
 
 	for (i = 0; i < ARRAY_LEN(special_tags); i++) {
-		if (!strcasecmp((char *)node->AST_XML_NAME, special_tags[i].tagname)) {
+		if (!strcasecmp((const char *)node->AST_XML_NAME, special_tags[i].tagname)) {
 			ret = 1;
 			/* This is a special tag. */
 
@@ -3982,7 +4006,7 @@
 			continue;
 		}
 
-		if (!strcasecmp((char *)tmp->AST_XML_NAME, "value")) {
+		if (!strcasecmp((const char *)tmp->AST_XML_NAME, "value")) {
 			if (!printedpara) {
 				ast_str_append(buffer, 0, "\n");
 				printedpara = 1;
@@ -4034,7 +4058,7 @@
 		return ret;
 	}
 
-	if (strcasecmp((char *)node->AST_XML_NAME, "variablelist")) {
+	if (strcasecmp((const char *)node->AST_XML_NAME, "variablelist")) {
 		return ret;
 	}
 
@@ -4053,7 +4077,7 @@
 			continue;
 		}
 
-		if (!strcasecmp((char *)tmp->AST_XML_NAME, "variable")) {
+		if (!strcasecmp((const char *)tmp->AST_XML_NAME, "variable")) {
 			/* Store the variable name in buffer. */
 			varname = ast_xml_get_attribute(tmp, "name");
 			if (varname) {
@@ -4081,9 +4105,10 @@
 static char *xmldoc_parse_seealso(const char *type, const char *name)
 {
 	struct ast_str *outputstr;
-	char *output, *content;
+	char *output;
 	ast_xml_node *node;
 	ast_xml_attr *typename;
+	ast_xml_text *content;
 
 	if (ast_strlen_zero(type) || ast_strlen_zero(name)) {
 		return NULL;
@@ -4097,7 +4122,7 @@
 
 	/* Find the <see-also> node. */
 	for (node = node->AST_XML_CHILD; node; node = node->AST_XML_NEXT) {
-		if (!strcasecmp((char *)node->AST_XML_NAME, "see-also")) {
+		if (!strcasecmp((const char *)node->AST_XML_NAME, "see-also")) {
 			break;
 		}
 	}
@@ -4115,29 +4140,31 @@
 
 	/* get into the <see-also> node. */
 	for (node = node->AST_XML_CHILD; node; node = node->AST_XML_NEXT) {
-		if (strcasecmp((char *)node->AST_XML_NAME, "ref")) {
+		if (strcasecmp((const char *)node->AST_XML_NAME, "ref")) {
 			continue;
 		}
 
 		/* parse the <ref> node. 'type' attribute is required. */
 		typename = ast_xml_get_attribute(node, "type");
-		if (typename) {
-			content = ast_xml_get_text(node);
-			if (content) {
-				if (!strcasecmp(typename, "application") || !strcasecmp(typename, "function")) {
-					ast_str_append(&outputstr, 0, "%s: Type <astcli>core show %s %s</astcli> for more info.\n",
-						content, typename, content);
-				} else if (!strcasecmp(typename, "astcli")) {
-					ast_str_append(&outputstr, 0, "%s: Type <astcli>help %s</astcli> for more info.\n", content, content);
-				} else if (!strcasecmp(typename, "link")) {
-					ast_str_append(&outputstr, 0, "%s\n", content);
-				} else if (!strcasecmp(typename, "manpage")) {
-					ast_str_append(&outputstr, 0, "ManPage: %s\n", content);
-				}
-				ast_xml_free_text(content);
-			}
+		if (!typename) {
+			continue;
+		}
+		content = ast_xml_get_text(node);
+		if (!content) {
 			ast_xml_free_attr(typename);
-		}
+			continue;
+		}
+		if (!strcasecmp(typename, "application") || !strcasecmp(typename, "function")) {
+			ast_str_append(&outputstr, 0, "%s: Type <astcli>core show %s %s</astcli> for more info.\n",
+				content, typename, content);
+		} else if (!strcasecmp(typename, "astcli")) {
+			ast_str_append(&outputstr, 0, "%s: Type <astcli>help %s</astcli> for more info.\n", content, content);
+		} else if (!strcasecmp(typename, "link")) {
+			ast_str_append(&outputstr, 0, "%s\n", content);
+		} else if (!strcasecmp(typename, "manpage")) {
+			ast_str_append(&outputstr, 0, "ManPage: %s\n", content);
+		}
+		ast_xml_free_text(content);
 	}
 
 	output = ast_strdup(outputstr->str);
@@ -4182,7 +4209,7 @@
 	int ret = 0;
 
 	for (node = node->AST_XML_CHILD; node; node = node->AST_XML_NEXT) {
-		if (strcasecmp((char *)node->AST_XML_NAME, "enum")) {
+		if (strcasecmp((const char *)node->AST_XML_NAME, "enum")) {
 			continue;
 		}
 
@@ -4222,7 +4249,7 @@
 		return ret;
 	}
 	for (node = fixnode->AST_XML_CHILD; node; node = node->AST_XML_NEXT) {
-		if (!strcasecmp((char *)node->AST_XML_NAME, "argument")) {
+		if (!strcasecmp((const char *)node->AST_XML_NAME, "argument")) {
 			/* if this is the first data appended to buffer, print a \n*/
 			if (!ret && node->AST_XML_CHILD) {
 				/* print \n */
@@ -4264,7 +4291,7 @@
 
 	for (node = fixnode->AST_XML_CHILD; node; node = node->AST_XML_NEXT) {
 		/* Start appending every option tag. */
-		if (strcasecmp((char *)node->AST_XML_NAME, "option")) {
+		if (strcasecmp((const char *)node->AST_XML_NAME, "option")) {
 			continue;
 		}
 
@@ -4301,7 +4328,7 @@
 	int hasarguments, printed = 0;
 	char *internaltabs;
 
-	if (strcasecmp((char *)node->AST_XML_NAME, "parameter")) {
+	if (strcasecmp((const char *)node->AST_XML_NAME, "parameter")) {
 		return;
 	}
 
@@ -4323,13 +4350,13 @@
 	}
 
 	for (node = node->AST_XML_CHILD; node; node = node->AST_XML_NEXT) {
-		if (!strcasecmp((char *)node->AST_XML_NAME, "optionlist")) {
+		if (!strcasecmp((const char *)node->AST_XML_NAME, "optionlist")) {
 			xmldoc_parse_optionlist(node, internaltabs, buffer);
-		} else if (!strcasecmp((char *)node->AST_XML_NAME, "enumlist")) {
+		} else if (!strcasecmp((const char *)node->AST_XML_NAME, "enumlist")) {
 			xmldoc_parse_enumlist(node, internaltabs, buffer);
-		} else if (!strcasecmp((char *)node->AST_XML_NAME, "argument")) {
+		} else if (!strcasecmp((const char *)node->AST_XML_NAME, "argument")) {
 			xmldoc_parse_argument(node, 1, internaltabs, (!hasarguments ? "        " : ""), buffer);
-		} else if (!strcasecmp((char *)node->AST_XML_NAME, "para")) {
+		} else if (!strcasecmp((const char *)node->AST_XML_NAME, "para")) {
 			if (!printed) {
 				ast_str_append(buffer, 0, "%s\n", paramname);
 				ast_xml_free_attr(paramname);
@@ -4370,7 +4397,7 @@
 
 	/* Find the syntax field. */
 	for (node = node->AST_XML_CHILD; node; node = node->AST_XML_NEXT) {
-		if (!strcasecmp((char *)node->AST_XML_NAME, "syntax")) {
+		if (!strcasecmp((const char *)node->AST_XML_NAME, "syntax")) {
 			break;
 		}
 	}
@@ -4409,8 +4436,8 @@
 static struct ast_str *xmldoc_get_formatted(ast_xml_node *node, int raw_output, int raw_wrap)
 {
 	ast_xml_node *tmp;
+	ast_xml_text *notcleanret, *tmpstr;
 	struct ast_str *ret = ast_str_create(128);
-	char *notcleanret, *tmpstr;
 
 	if (raw_output) {
 		notcleanret = ast_xml_get_text(node);
@@ -4503,7 +4530,7 @@
 			return -1;
 		}
 
-		/* load synopsis */			
+		/* load synopsis */
 		tmpxml = xmldoc_get_field("function", acf->name, "synopsis", 1);
 		ast_string_field_set(acf, synopsis, tmpxml);
 		ast_free(tmpxml);
@@ -6367,7 +6394,7 @@
 			continue;
 		}
 		/* Check root node name for malformed xmls. */
-		if (strcmp((char *)root_node->AST_XML_NAME, "docs")) {
+		if (strcmp((const char *)root_node->AST_XML_NAME, "docs")) {
 			ast_log(LOG_ERROR, "Documentation file is not well formed!\n");
 			ast_xml_close(tmpdoc);
 			continue;
@@ -6461,8 +6488,9 @@
 		return ret;
 	}
 
-	if (a->argc < 4)
+	if (a->argc < 4) {
 		return CLI_SHOWUSAGE;
+	}
 
 	/* ... go through all applications ... */
 	AST_RWLIST_RDLOCK(&apps);
@@ -6483,34 +6511,39 @@
 
 				no_registered_app = 0;
 #ifndef XML_DOCUMENTATION
-				if (!ast_strlen_zero(aa->synopsis))
+				if (!ast_strlen_zero(aa->synopsis)) {
 					synopsis_size = strlen(aa->synopsis) + 23;
-				else
+				} else {
 					synopsis_size = strlen("Not available") + 23;
+				}
 				synopsis = ast_malloc(synopsis_size);
 
-				if (!ast_strlen_zero(aa->description))
+				if (!ast_strlen_zero(aa->description)) {
 					description_size = strlen(aa->description) + 23;
-				else
+				} else {
 					description_size = strlen("Not available") + 23;
+				}
 				description = ast_malloc(description_size);
 
-				if (!ast_strlen_zero(aa->arguments))
+				if (!ast_strlen_zero(aa->arguments)) {
 					arguments_size = strlen(aa->arguments) + 23;
-				else
+				} else {
 					arguments_size = strlen("Not available") + 23;
+				}
 				arguments = ast_malloc(arguments_size);
 
-				if (!ast_strlen_zero(aa->seealso))
+				if (!ast_strlen_zero(aa->seealso)) {
 					seealso_size = strlen(aa->seealso) + 23;
-				else
+				} else {
 					seealso_size = strlen("Not available") + 23;
+				}
 				seealso = ast_malloc(seealso_size);
 #endif
-				if (!ast_strlen_zero(aa->syntax))
+				if (!ast_strlen_zero(aa->syntax)) {
 					syntax_size = strlen(aa->syntax) + 23;
-				else
+				} else {
 					syntax_size = strlen("Not available") + 23;
+				}
 				syntax = ast_malloc(syntax_size);
 
 #ifdef XML_DOCUMENTATION
@@ -6518,8 +6551,8 @@
 #else
 				if (syntax && description && arguments && synopsis) {
 #endif
-					snprintf(info, 64 + AST_MAX_APP, "\n  -= Info about application '%s' =- \n\n", aa->name);
-					term_color(infotitle, info, COLOR_MAGENTA, 0, 64 + AST_MAX_APP + 22);
+					snprintf(info, sizeof(info), "\n  -= Info about application '%s' =- \n\n", aa->name);
+					term_color(infotitle, info, COLOR_MAGENTA, 0, sizeof(infotitle));
 					term_color(stxtitle, "[Syntax]\n", COLOR_MAGENTA, 0, 40);
 					term_color(argtitle, "[Arguments]\n", COLOR_MAGENTA, 0, 40);
 					term_color(syntitle, "[Synopsis]\n", COLOR_MAGENTA, 0, 40);

Modified: team/group/appdocsxml/main/xml.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/main/xml.c?view=diff&rev=151510&r1=151509&r2=151510
==============================================================================
--- team/group/appdocsxml/main/xml.c (original)
+++ team/group/appdocsxml/main/xml.c Wed Oct 22 09:55:58 2008
@@ -103,7 +103,7 @@
 void ast_xml_free_text(ast_xml_text *text)
 {
 	if (text) {
-		xmlFree(text);
+		xmlFree((char *)text);
 	}
 }
 
@@ -133,9 +133,7 @@
 		return NULL;
 	}
 
-	cur = root_node;
-
-	while (cur) {
+	for (cur = root_node; cur; cur = cur->next) {
 		/* Check if the name matchs */
 		if (!strcmp((char *)cur->name, name)) {
 			/* We need to check for a specific attribute name? */
@@ -153,19 +151,18 @@
 				return cur;
 			}
 		}
-		cur = cur->next;
 	}
 
 	return NULL;
 }
 
-char *ast_xml_get_text(ast_xml_node *node)
+const char *ast_xml_get_text(ast_xml_node *node)
 {
 	if (!node) {
 		return NULL;
 	}
 
-	return (char *)xmlNodeGetContent(node);
+	return (const char *)xmlNodeGetContent(node);
 }
 
 #endif /* defined(HAVE_LIBXML2) && !defined(AST_XML_IMPLEMENTATION) */




More information about the svn-commits mailing list