[asterisk-commits] eliel: branch group/appdocsxml r151415 - in /team/group/appdocsxml: include/a...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Oct 21 14:40:17 CDT 2008


Author: eliel
Date: Tue Oct 21 14:40:15 2008
New Revision: 151415

URL: http://svn.digium.com/view/asterisk?view=rev&rev=151415
Log:
Implement syntax,synopsis,description,arguments and seealso as stringfields inside struct ast_app.

Modified:
    team/group/appdocsxml/include/asterisk/extconf.h
    team/group/appdocsxml/main/pbx.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=151415&r1=151414&r2=151415
==============================================================================
--- team/group/appdocsxml/include/asterisk/extconf.h (original)
+++ team/group/appdocsxml/include/asterisk/extconf.h Tue Oct 21 14:40:15 2008
@@ -82,11 +82,13 @@
 /*! \brief A registered application */
 struct ast_app {
 	int (*execute)(struct ast_channel *chan, void *data);
-	char *synopsis;				/*!< Synopsis text for 'show applications' */
-	char *description;			/*!< Description (help text) for 'show application &lt;name&gt;' */
-	char *syntax;				/*!< Syntax text for 'core show applications' */
-	char *arguments;			/*!< Arguments description */
-	char *seealso;				/*!< See also */
+	AST_DECLARE_STRING_FIELDS(
+		AST_STRING_FIELD(synopsis);     /*!< Synopsis text for 'show applications' */
+		AST_STRING_FIELD(description);  /*!< Description (help text) for 'show application &lt;name&gt;' */
+		AST_STRING_FIELD(syntax);       /*!< Syntax text for 'core show applications' */
+		AST_STRING_FIELD(arguments);    /*!< Arguments description */
+		AST_STRING_FIELD(seealso);      /*!< See also */
+	);
 	enum doc_src docsrc;			/*!< Where the documentation come from. */
 	AST_RWLIST_ENTRY(ast_app) list;		/*!< Next app in list */
 	void *module;			/*!< Module this app belongs to */

Modified: team/group/appdocsxml/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/main/pbx.c?view=diff&rev=151415&r1=151414&r2=151415
==============================================================================
--- team/group/appdocsxml/main/pbx.c (original)
+++ team/group/appdocsxml/main/pbx.c Tue Oct 21 14:40:15 2008
@@ -762,11 +762,13 @@
 /*! \brief ast_app: A registered application */
 struct ast_app {
 	int (*execute)(struct ast_channel *chan, void *data);
-	char *synopsis;				/*!< Synopsis text for 'show applications' */
-	char *description;			/*!< Description (help text) for 'show application &lt;name&gt;' */
-	char *syntax;				/*!< Syntax text for 'core show applications' */
-	char *arguments;			/*!< Arguments description */
-	char *seealso;				/*!< See also */
+	AST_DECLARE_STRING_FIELDS(
+		AST_STRING_FIELD(synopsis);	/*!< Synopsis text for 'show applications' */
+		AST_STRING_FIELD(description);	/*!< Description (help text) for 'show application &lt;name&gt;' */
+		AST_STRING_FIELD(syntax);	/*!< Syntax text for 'core show applications' */
+		AST_STRING_FIELD(arguments);	/*!< Arguments description */
+		AST_STRING_FIELD(seealso);	/*!< See also */
+	);
 	enum doc_src docsrc;			/*!< Where the documentation come from. */
 	AST_RWLIST_ENTRY(ast_app) list;		/*!< Next app in list */
 	struct ast_module *module;		/*!< Module this app belongs to */
@@ -6198,6 +6200,9 @@
 	struct ast_app *tmp, *cur = NULL;
 	char tmps[80];
 	int length, res;
+#ifdef XML_DOCUMENTATION
+	char *tmpxml;
+#endif
 
 	AST_RWLIST_WRLOCK(&apps);
 	AST_RWLIST_TRAVERSE(&apps, tmp, list) {
@@ -6216,19 +6221,43 @@
 		return -1;
 	}
 
+	if (ast_string_field_init(tmp, 128)) {
+		ast_free(tmp);
+		return -1;
+	}
+
 #ifdef XML_DOCUMENTATION
 	/* Try to lookup the docs in our XML documentation database */
 	if (ast_strlen_zero(synopsis) && ast_strlen_zero(description)) {
-		tmp->synopsis = xmldoc_get_field("application", app, "synopsis", 1);
-		tmp->description = xmldoc_get_field("application", app, "description", 0);
-		tmp->syntax = xmldoc_get_syntax("application", app);
-		tmp->arguments = xmldoc_build_arguments("application", app);
-		tmp->seealso = xmldoc_parse_seealso("application", app);
+		/* load synopsis */
+		tmpxml = xmldoc_get_field("application", app, "synopsis", 1);
+		ast_string_field_set(tmp, synopsis, tmpxml);
+		ast_free(tmpxml);
+		
+		/* load description */
+		tmpxml = xmldoc_get_field("application", app, "description", 0);
+		ast_string_field_set(tmp, description, tmpxml);
+		ast_free(tmpxml);
+
+		/* load syntax */
+		tmpxml = xmldoc_get_syntax("application", app);
+		ast_string_field_set(tmp, syntax, tmpxml);
+		ast_free(tmpxml);
+
+		/* load arguments */
+		tmpxml = xmldoc_build_arguments("application", app);
+		ast_string_field_set(tmp, arguments, tmpxml);
+		ast_free(tmpxml);	
+	
+		/* load seealso */
+		tmpxml = xmldoc_parse_seealso("application", app);
+		ast_string_field_set(tmp, seealso, tmpxml);
+		ast_free(tmpxml);
 		tmp->docsrc = AST_XML_DOC;
 	} else {
 #endif
-		tmp->synopsis = (char *)synopsis;
-		tmp->description = (char *)description;
+		ast_string_field_set(tmp, synopsis, synopsis);
+		ast_string_field_set(tmp, description, description);
 		tmp->docsrc = AST_STATIC_DOC;
 #ifdef XML_DOCUMENTATION
 	}
@@ -6436,31 +6465,31 @@
 
 				no_registered_app = 0;
 #ifndef XML_DOCUMENTATION
-				if (aa->synopsis)
+				if (!ast_strlen_zero(aa->synopsis))
 					synopsis_size = strlen(aa->synopsis) + 23;
 				else
 					synopsis_size = strlen("Not available") + 23;
 				synopsis = ast_malloc(synopsis_size);
 
-				if (aa->description)
+				if (!ast_strlen_zero(aa->description))
 					description_size = strlen(aa->description) + 23;
 				else
 					description_size = strlen("Not available") + 23;
 				description = ast_malloc(description_size);
 
-				if (aa->arguments)
+				if (!ast_strlen_zero(aa->arguments))
 					arguments_size = strlen(aa->arguments) + 23;
 				else
 					arguments_size = strlen("Not available") + 23;
 				arguments = ast_malloc(arguments_size);
 
-				if (aa->seealso)
+				if (!ast_strlen_zero(aa->seealso))
 					seealso_size = strlen(aa->seealso) + 23;
 				else
 					seealso_size = strlen("Not available") + 23;
 				seealso = ast_malloc(seealso_size);
 #endif
-				if (aa->syntax)
+				if (!ast_strlen_zero(aa->syntax))
 					syntax_size = strlen(aa->syntax) + 23;
 				else
 					syntax_size = strlen("Not available") + 23;
@@ -7617,15 +7646,7 @@
 			ast_verb(2, "Unregistered application '%s'\n", tmp->name);
 #ifdef XML_DOCUMENTATION
 			if (tmp->docsrc == AST_XML_DOC) {
-				if (tmp->description) {
-					ast_free(tmp->description);
-				}
-				if (tmp->synopsis) {
-					ast_free(tmp->synopsis);
-				}
-				if (tmp->syntax) {
-					ast_free(tmp->syntax);
-				}
+				ast_string_field_free_memory(tmp);
 			}
 #endif
 			ast_free(tmp);




More information about the asterisk-commits mailing list