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

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Aug 8 10:16:57 CDT 2008


Author: eliel
Date: Fri Aug  8 10:16:56 2008
New Revision: 136783

URL: http://svn.digium.com/view/asterisk?view=rev&rev=136783
Log:
- NOTICE: We added a casting while passing parameters from ast_register_application to ast_register_application2, we must remove this when all the descriptions and synopsis are converted to 'char *' instead of 'const char *'.

- Added a 'docsrc' member in 'struct ast_custom_function' and in 'struct ast_app' to know where the documentation come from and if we need to free allocated memory, free it! (when unregistering an application or function).
  Right now only two sources are defined:
       AST_XML_DOC    (From XML documentation).
       AST_STATIC_DOC (From register functions).

- Added a 'syntax' member inside ast_app (To persist the read XML documentation there).

- Remove ast_xml_doc_get_field() and ast_xml_doc_build_syntax() declarations from the begining of pbx.c (They are not needed, because the order of the implementation is correct).

- Implement function ast_xml_doc_get_node(), this will be used when trying to get an application/function node, and check the language, or get the first one if the passed language is not found (At least it will be used in ast_xml_doc_get_field() and in ast_xml_doc_build_syntax()).

- Remove old code inside ast_xml_doc_build_syntax(), we need to redo all the function.

- Make ast_xml_doc_get_field() use ast_xml_doc_get_node().

- Set the current docsrc for each application/function documentation when registering them.

- Remove CLI command 'core show syntax'. And added the Syntax item in 'core show application'.
  'core show function' already has [Syntax].

Modified:
    team/group/appdocsxml/include/asterisk/extconf.h
    team/group/appdocsxml/include/asterisk/module.h
    team/group/appdocsxml/include/asterisk/pbx.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=136783&r1=136782&r2=136783
==============================================================================
--- team/group/appdocsxml/include/asterisk/extconf.h (original)
+++ team/group/appdocsxml/include/asterisk/extconf.h Fri Aug  8 10:16:56 2008
@@ -73,11 +73,19 @@
 
 /* ================== 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 {
 	int (*execute)(struct ast_channel *chan, void *data);
-	const char *synopsis;			/*!< Synopsis text for 'show applications' */
-	const char *description;		/*!< Description (help text) for 'show application &lt;name&gt;' */
+	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' */
+	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 */
 	char name[0];				/*!< Name of the application */

Modified: team/group/appdocsxml/include/asterisk/module.h
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/include/asterisk/module.h?view=diff&rev=136783&r1=136782&r2=136783
==============================================================================
--- team/group/appdocsxml/include/asterisk/module.h (original)
+++ team/group/appdocsxml/include/asterisk/module.h Fri Aug  8 10:16:56 2008
@@ -378,7 +378,8 @@
  * \retval 0 success 
  * \retval -1 failure.
  */
-#define ast_register_application(app, execute, synopsis, description) ast_register_application2(app, execute, synopsis, description, ast_module_info->self)
+/* XXX: Remove this when finish changing every description/synopsis to 'char *' type. */
+#define ast_register_application(app, execute, synopsis, description) ast_register_application2(app, execute, (char *)synopsis, (char *)description, ast_module_info->self)
 
 /*! 
  * \brief Register an application using XML documentation.
@@ -416,7 +417,7 @@
  * \retval -1 failure.
  */
 int ast_register_application2(const char *app, int (*execute)(struct ast_channel *, void *),
-				     const char *synopsis, const char *description, void *mod);
+				     char *synopsis, char *description, void *mod);
 
 /*! 
  * \brief Unregister an application

Modified: team/group/appdocsxml/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/include/asterisk/pbx.h?view=diff&rev=136783&r1=136782&r2=136783
==============================================================================
--- team/group/appdocsxml/include/asterisk/pbx.h (original)
+++ team/group/appdocsxml/include/asterisk/pbx.h Fri Aug  8 10:16:56 2008
@@ -72,12 +72,19 @@
 /*! \brief Typedef for devicestate and hint callbacks */
 typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data);
 
+/*! \brief From where the documentation come from */
+enum doc_src {
+	AST_XML_DOC,            /*!< From XML documentation */
+	AST_STATIC_DOC          /*!< From application/function registration */
+};
+
 /*! \brief Data structure associated with a custom dialplan function */
 struct ast_custom_function {
 	const char *name;		/*!< Name */
-	const char *synopsis;		/*!< Short description for "show functions" */
-	const char *desc;		/*!< Help text that explains it all */
-	const char *syntax;		/*!< Syntax description */
+	char *synopsis;		/*!< Short description for "show functions" */
+	char *desc;		/*!< Help text that explains it all */
+	char *syntax;		/*!< Syntax description */
+	enum doc_src docsrc;		/*!< Where the documentation come from */
 	int (*read)(struct ast_channel *, const char *, char *, char *, size_t);	/*!< Read function, if read is supported */
 	int (*write)(struct ast_channel *, const char *, char *, const char *);		/*!< Write function, if write is supported */
 	struct ast_module *mod;         /*!< Module this custom function 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=136783&r1=136782&r2=136783
==============================================================================
--- team/group/appdocsxml/main/pbx.c (original)
+++ team/group/appdocsxml/main/pbx.c Fri Aug  8 10:16:56 2008
@@ -223,12 +223,13 @@
 	char name[0];				/*!< Name of the context */
 };
 
-
 /*! \brief ast_app: A registered application */
 struct ast_app {
 	int (*execute)(struct ast_channel *chan, void *data);
-	const char *synopsis;			/*!< Synopsis text for 'show applications' */
-	const char *description;		/*!< Description (help text) for 'show application &lt;name&gt;' */
+	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' */
+	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 */
 	char name[0];				/*!< Name of the application */
@@ -287,6 +288,7 @@
 #ifdef XML_DOCUMENTATION
 #define DEFAULT_DOCUMENTATION_LANGUAGE "en_US"
 char documentation_language[80];
+ast_xml_doc *documentation_tree = NULL;
 #endif
 
 static int pbx_builtin_answer(struct ast_channel *, void *);
@@ -334,11 +336,6 @@
 static unsigned int hashtab_hash_priority(const void *obj);
 static unsigned int hashtab_hash_labels(const void *obj);
 static void __ast_internal_context_destroy( struct ast_context *con);
-#ifdef XML_DOCUMENTATION
-ast_xml_doc *documentation_tree = NULL;
-static char *ast_xml_doc_get_field(const char *type, const char *name, const char *var); 
-//static char *ast_xml_doc_build_syntax(const char *type, const char *name);
-#endif
 
 /* a func for qsort to use to sort a char array */
 static int compare_char(const void *a, const void *b)
@@ -2773,8 +2770,22 @@
 		return -1;
 
 	AST_RWLIST_WRLOCK(&acf_root);
-	if ((cur = AST_RWLIST_REMOVE(&acf_root, acf, acflist)))
+	if ((cur = AST_RWLIST_REMOVE(&acf_root, acf, acflist))) {
+#ifdef XML_DOCUMENTATION
+		if (cur->docsrc == AST_XML_DOC) {
+			if (cur->desc) {
+				ast_free(cur->desc);
+			}
+			if (cur->synopsis) {
+				ast_free(cur->synopsis);
+			}
+			if (cur->syntax) {
+				ast_free(cur->syntax);
+			}
+		}
+#endif
 		ast_verb(2, "Unregistered custom function %s\n", cur->name);
+	}
 	AST_RWLIST_UNLOCK(&acf_root);
 
 	return cur ? 0 : -1;
@@ -2782,81 +2793,52 @@
 
 #ifdef XML_DOCUMENTATION
 
-#if 0
-/*! \brief Get the application node for 'name' application with language 'language'
- *         if we don't find any, get the first application no matter which language with
- *         this name.
- *  \param type 'application' or 'function'?
+/*! \brief Get the application/function node for 'name' application/function with language 'language'
+ *         if we don't find any, get the first application with 'name' no matter which language with.
+ *  \param doc XML documentation tree structure.
+ *  \param type 'application', 'function', ...
  *  \param name Application or Function name.
  *  \param language Try to get this language (if not found try with en_US)
- *  \return A node of type ast_xml_node.
+ *  \retval NULL on error.
+ *  \retval A node of type ast_xml_node.
  */
-static ast_xml_node *ast_xml_doc_get_application(const char *type, const char *name, const char *language) {
-	/* XXX: We should implement this search function, to avoid repeating this code. */	
-	return NULL;
-}
-#endif
-
-#if 0
+static ast_xml_node *ast_xml_doc_get_node(ast_xml_doc *doc, const char *type, const char *name, const char *language)
+{
+	ast_xml_node *node;
+	char *lang;
+
+	node = ast_xml_get_root(doc);
+	node = node->AST_XML_CHILD;
+	while (node) {
+		node = ast_xml_find_element(node, type, "name", name);
+		if (node) {
+			/* Check language */
+			lang = ast_xml_get_attribute(node, "language");
+			if (!strcmp(lang, language)) {
+				ast_xml_free_attr(lang);
+				break;
+			}
+			ast_xml_free_attr(lang);
+			node = node->AST_XML_NEXT;
+		}
+	}
+
+	if (!node && !node->AST_XML_CHILD) {
+		/* We didn't find the application documentation for the specified language,
+		so, try to load documentation for any language */
+		node = ast_xml_get_root(documentation_tree);
+		if (node && node->AST_XML_CHILD) {
+			node = ast_xml_find_element(node->AST_XML_CHILD, type, "name", name);
+		}
+	}
+
+	return node;
+}
+
 static char *ast_xml_doc_build_syntax(const char *type, const char *name) 
 {	
-	const char *tmp = NULL;
-	int req_found = 1; 
-	ast_xml_node *node = NULL, *ret = NULL, *req, *root;
-
-	if (ast_strlen_zero(type) || ast_strlen_zero(name)) {
-		ast_log(LOG_WARNING, "Tried to look in XML tree with faulty values.\n");
-		return NULL;
-	}
-
-	/* not fully initted yet */
-	if (!documentation_tree) {
-		ast_log(LOG_DEBUG, "Parsing XML Tree Error\n");
-		return NULL; 
-	}
-	
-	root = ast_xml_get_root(documentation_tree);
-	if (!root) {
-		ast_log(LOG_DEBUG, "Error getting documentation root node\n");
-		return NULL;
-	}
-
-	node = ast_xml_find_element(root->AST_XML_CHILD, type, "name", name);
-	while (node && node->AST_XML_CHILD) {
-		tmp = mxmlElementGetAttr(node, "language");
-		if (!strcmp(tmp, documentation_language)) {
-			ret = mxmlFindElement(node, documentation_tree, NULL, NULL, NULL, MXML_DESCEND_FIRST);
-			break;
-		}
-		node = mxmlFindElement(node, documentation_tree, type, "name", name, MXML_DESCEND);
-	}
-
-	/* If we still could not find the language, chose the first one found (english) */
-	if (!ret) {
-		node = mxmlFindElement(documentation_tree, documentation_tree, type, "name", name, MXML_DESCEND);
-	}
-
-	ret = mxmlFindElement(node, documentation_tree, "option", NULL, NULL, MXML_DESCEND);
-	while (ret) {
-		if (!req_found) {
-			tmp = mxmlElementGetAttr(ret, "required");
-			if (tmp && !ast_strlen_zero(tmp)) {
-				/* We found the "required=true" node. Set the req pointer to ret (current node) */
-				req = ret;
-				req_found = 0;		
-			}
-		}
-		ret = mxmlFindElement(ret, documentation_tree, "option", NULL, NULL, MXML_DESCEND);
-	} 
-
-	if (!ret || !ret->AST_XML_CHILD) {
-		ast_log(LOG_WARNING, "Cannot find option variables in tree '%s'\n", name);
-		return NULL;
-	}
-
-	return ret->AST_XML_CHILD->value.opaque;
-}
-#endif /* if 0 */
+	return NULL;
+}
 
 /* \brief Return the string within a node formatted with <para> elements. 
  * \param node Parent node where content resides.
@@ -2898,8 +2880,7 @@
  */
 static char *ast_xml_doc_get_field(const char *type, const char *name, const char *var)
 {
-	ast_xml_node *node, *ret = NULL;
-	ast_xml_attr *lang;
+	ast_xml_node *node;
 
 	if (ast_strlen_zero(type) || ast_strlen_zero(name)) {
 		ast_log(LOG_WARNING, "Tried to look in XML tree with faulty values.\n");
@@ -2912,42 +2893,21 @@
 		return NULL; 
 	}
 
-	node = ast_xml_get_root(documentation_tree);
-	node = node->AST_XML_CHILD;
-	while (node) {
-		node = ast_xml_find_element(node, type, "name", name);
-		if (node) {
-			/* Check language */
-			lang = ast_xml_get_attribute(node, "language");
-			if (!strcmp(lang, documentation_language)) {
-				ast_xml_free_attr(lang);
-				break;
-			}
-			ast_xml_free_attr(lang);
-			node = node->AST_XML_NEXT;
-		}
-	}
-	
-	if (node && node->AST_XML_CHILD) {
-		ret = ast_xml_find_element(node->AST_XML_CHILD, var, NULL, NULL);
-	} else {
-		/* We didn't find the application documentation for the specified language,
-		   so, try to load documentation for any language */
-		node = ast_xml_get_root(documentation_tree);
-		if (node && node->AST_XML_CHILD) {
-			node = ast_xml_find_element(node->AST_XML_CHILD, type, "name", name);
-			if (node && node->AST_XML_CHILD) {
-				ret = ast_xml_find_element(node->AST_XML_CHILD, var, NULL, NULL);
-			}
-		}
-	}
-
-	if (!ret || !ret->AST_XML_CHILD) {
+	node = ast_xml_doc_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);
+		return NULL;
+	}
+
+	node = ast_xml_find_element(node->AST_XML_CHILD, var, NULL, NULL);
+
+	if (!node || !node->AST_XML_CHILD) {
 		ast_log(LOG_DEBUG, "Cannot find varible '%s' in tree '%s'\n", name, var);
 		return NULL;
 	}
 
-	return ast_xml_doc_get_formatted(ret);
+	return ast_xml_doc_get_formatted(node);
 }
 #endif /* XML_DOCUMENTATION */
 
@@ -2960,12 +2920,15 @@
 		return -1;
 
 	acf->mod = mod;
+	acf->docsrc = AST_STATIC_DOC;
 
 #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->docsrc = AST_XML_DOC;
 	}
 #endif
 
@@ -4648,7 +4611,7 @@
 }
 
 /*! \brief Dynamically register a new dial plan application */
-int ast_register_application2(const char *app, int (*execute)(struct ast_channel *, void *), const char *synopsis, const char *description, void *mod)
+int ast_register_application2(const char *app, int (*execute)(struct ast_channel *, void *), char *synopsis, char *description, void *mod)
 {
 	struct ast_app *tmp, *cur = NULL;
 	char tmps[80];
@@ -4676,9 +4639,14 @@
 	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->docsrc = AST_XML_DOC;
 	} else {
+#endif
 		tmp->synopsis = synopsis;
 		tmp->description = description;
+		tmp->docsrc = AST_STATIC_DOC;
+#ifdef XML_DOCUMENTATION
 	}
 #endif
 
@@ -4842,9 +4810,9 @@
 		for (app = 3; app < a->argc; app++) {
 			if (!strcasecmp(aa->name, a->argv[app])) {
 				/* Maximum number of characters added by terminal coloring is 22 */
-				char infotitle[64 + AST_MAX_APP + 22], syntitle[40], destitle[40];
-				char info[64 + AST_MAX_APP], *synopsis = NULL, *description = NULL;
-				int synopsis_size, description_size;
+				char infotitle[64 + AST_MAX_APP + 22], syntitle[40], destitle[40], stxtitle[40];
+				char info[64 + AST_MAX_APP], *synopsis = NULL, *description = NULL, *syntax = NULL;
+				int synopsis_size, description_size, syntax_size;
 
 				no_registered_app = 0;
 
@@ -4860,9 +4828,16 @@
 					description_size = strlen("Not available") + 23;
 				description = alloca(description_size);
 
+				if (aa->syntax)
+					syntax_size = strlen(aa->syntax) + 23;
+				else
+					syntax_size = strlen("Not available") + 23;
+				syntax = alloca(syntax_size);
+
 				if (synopsis && description) {
 					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);
+					term_color(stxtitle, "[Syntax]\n", COLOR_MAGENTA, 0, 40);
 					term_color(syntitle, "[Synopsis]\n", COLOR_MAGENTA, 0, 40);
 					term_color(destitle, "[Description]\n", COLOR_MAGENTA, 0, 40);
 					term_color(synopsis,
@@ -4871,14 +4846,19 @@
 					term_color(description,
 									aa->description ? aa->description : "Not available",
 									COLOR_CYAN, 0, description_size);
-
-					ast_cli(a->fd,"%s%s%s\n\n%s%s\n", infotitle, syntitle, synopsis, destitle, description);
+					term_color(syntax,
+									aa->syntax ? aa->syntax : "Not available",
+									COLOR_CYAN, 0, syntax_size);
+
+					ast_cli(a->fd,"%s%s%s\n\n%s%s\n\n%s%s\n", infotitle, stxtitle, syntax, syntitle, synopsis, destitle, description);
 				} else {
 					/* ... one of our applications, show info ...*/
 					ast_cli(a->fd,"\n  -= Info about application '%s' =- \n\n"
+						"[Syntax]\n  %s\n\n"
 						"[Synopsis]\n  %s\n\n"
 						"[Description]\n%s\n",
 						aa->name,
+						aa->syntax ? aa->syntax : "Not available",
 						aa->synopsis ? aa->synopsis : "Not available",
 						aa->description ? aa->description : "Not available");
 				}
@@ -4895,122 +4875,6 @@
 
 	return CLI_SUCCESS;
 }
-
-#ifdef XML_DOCUMENTATION
-/*
- * Help for CLI commands ...
- */
-
-/* XXX This can eventually just be added to handle_show_application */
-
-/*
- * \brief 'show syntax' CLI command implementation function...
- */
-static char *handle_show_syntax(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
-	struct ast_app *aa;
-	int app, no_registered_app = 1;
-	char *ret = NULL;
-	int which = 0;
-	int wordlen;
-
-	switch (cmd) {
-	case CLI_INIT:	
-		e->command = "core show syntax";
-		e->usage = 
-			"Usage: core show syntax <application>\n"
-			"       Dumps out a syntactical respresentation of the Application.\n";
-		return NULL;
-	case CLI_GENERATE:
-		/* return the n-th [partial] matching entry */
-		wordlen = strlen(a->word);
-		AST_RWLIST_RDLOCK(&apps);
-		AST_RWLIST_TRAVERSE(&apps, aa, list) {
-			if (!strncasecmp(a->word, aa->name, wordlen) && ++which > a->n) {
-				ret = ast_strdup(aa->name);
-				break;
-			}
-		}
-		AST_RWLIST_UNLOCK(&apps);
-
-		return ret;
-	}
-
-	if (a->argc < 4)
-		return CLI_SHOWUSAGE;
-
-	/* ... go through all applications ... */
-	AST_RWLIST_RDLOCK(&apps);
-	AST_RWLIST_TRAVERSE(&apps, aa, list) {
-		/* ... compare this application name with all arguments given
-		 * to 'show application' command ... */
-		for (app = 3; app < a->argc; app++) {
-			if (!strcasecmp(aa->name, a->argv[app])) {
-				/* Maximum number of characters added by terminal coloring is 22 */
-				char infotitle[64 + AST_MAX_APP + 22], syntitle[40], destitle[40], taxtitle[40];
-				char info[64 + AST_MAX_APP], *synopsis = NULL, *description = NULL, *syntax = NULL, *syn_handle;
-				int synopsis_size, description_size, syntax_size;
-
-				no_registered_app = 0;
-
-				if (aa->synopsis)
-					synopsis_size = strlen(aa->synopsis) + 23;
-				else
-					synopsis_size = strlen("Not available") + 23;
-				synopsis = alloca(synopsis_size);
-
-				if (aa->description)
-					description_size = strlen(aa->description) + 23;
-				else
-					description_size = strlen("Not available") + 23;
-				description = alloca(description_size);
-
-				/* XXX Figure out how much space we REALLY need */
-				syntax_size = (4096 + 23); 
-				syntax = alloca(syntax_size);
-				syn_handle = NULL; //ast_mxml_build_syntax("application", aa->name);
-
-				if (synopsis && description) {
-					snprintf(info, 64 + AST_MAX_APP, "\n  -= Syntax representation of App: '%s' =- \n\n", aa->name);
-					term_color(infotitle, info, COLOR_MAGENTA, 0, 64 + AST_MAX_APP + 22);
-					term_color(syntitle, "[Synopsis]\n", COLOR_MAGENTA, 0, 40);
-					term_color(destitle, "[Description]\n", COLOR_MAGENTA, 0, 40);
-					term_color(taxtitle, "[Syntax]\n", COLOR_MAGENTA, 0, 40);
-					term_color(synopsis,
-									aa->synopsis ? aa->synopsis : "Not available",
-									COLOR_CYAN, 0, synopsis_size);
-					term_color(description,
-									aa->description ? aa->description : "Not available",
-									COLOR_CYAN, 0, description_size);
-					term_color(syntax,
-									syn_handle ? syn_handle : "Not available",
-									COLOR_CYAN, 0, syntax_size);
-
-					
-					ast_cli(a->fd,"%s%s%s\n%s%s\n\n%s%s\n", infotitle, syntitle, synopsis, taxtitle, syntax, destitle, description);
-				} else {
-					/* ... one of our applications, show info ...*/
-					ast_cli(a->fd,"\n  -= Info about application '%s' =- \n\n"
-						"[Synopsis]\n  %s\n\n"
-						"[Description]\n%s\n",
-						aa->name,
-						aa->synopsis ? aa->synopsis : "Not available",
-						aa->description ? aa->description : "Not available");
-				}
-			}
-		}
-	}
-	AST_RWLIST_UNLOCK(&apps);
-
-	/* we found at least one app? no? */
-	if (no_registered_app) {
-		ast_cli(a->fd, "Your application(s) is (are) not registered\n");
-		return CLI_FAILURE;
-	}
-
-	return CLI_SUCCESS;
-}
-#endif /* XML_DOCUMENTATION */
 
 /*! \brief  handle_show_hints: CLI support for listing registered dial plan hints */
 static char *handle_show_hints(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@@ -5968,9 +5832,6 @@
 	AST_CLI_DEFINE(handle_show_chanvar, "Show channel variables"),
 	AST_CLI_DEFINE(handle_show_function, "Describe a specific dialplan function"),
 	AST_CLI_DEFINE(handle_show_application, "Describe a specific dialplan application"),
-#ifdef XML_DOCUMENTATION
-	AST_CLI_DEFINE(handle_show_syntax, "Show syntax"),
-#endif
 	AST_CLI_DEFINE(handle_set_global, "Set global dialplan variable", .deprecate_cmd = &cli_set_global_deprecated),
 	AST_CLI_DEFINE(handle_set_chanvar, "Set a channel variable", .deprecate_cmd = &cli_set_chanvar_deprecated),
 	AST_CLI_DEFINE(handle_show_dialplan, "Show dialplan"),
@@ -6007,6 +5868,19 @@
 			unreference_cached_app(tmp);
 			AST_RWLIST_REMOVE_CURRENT(list);
 			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);
+				}
+			}
+#endif
 			ast_free(tmp);
 			break;
 		}




More information about the asterisk-commits mailing list