[asterisk-commits] eliel: branch group/appdocsxml r146014 - in /team/group/appdocsxml: funcs/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Oct 3 09:19:43 CDT 2008


Author: eliel
Date: Fri Oct  3 09:19:42 2008
New Revision: 146014

URL: http://svn.digium.com/view/asterisk?view=rev&rev=146014
Log:
Introduce ODBC_FETCH(), SQL_ESC() functions and ODBCFinish() application XML documentation,
the work was done by snuff-home, with minor changes I made.
Thanks snuff!
Fix an issue if no document root is found to prevent a crash.

Modified:
    team/group/appdocsxml/funcs/func_odbc.c
    team/group/appdocsxml/main/pbx.c

Modified: team/group/appdocsxml/funcs/func_odbc.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/funcs/func_odbc.c?view=diff&rev=146014&r1=146013&r2=146014
==============================================================================
--- team/group/appdocsxml/funcs/func_odbc.c (original)
+++ team/group/appdocsxml/funcs/func_odbc.c Fri Oct  3 09:19:42 2008
@@ -43,6 +43,58 @@
 #include "asterisk/config.h"
 #include "asterisk/res_odbc.h"
 #include "asterisk/app.h"
+
+/*** DOCUMENTATION
+	<function name="ODBC_FETCH" language="en_US">
+		<synopsis>
+			Fetch a row from a multirow query.
+		</synopsis>
+		<syntax>
+			<parameter name="result-id" required="true" />
+		</syntax>
+		<description>
+			<para>For queries which are marked as mode=multirow, the original 
+			query returns a <replaceable>result-id</replaceable> from which results 
+			may be fetched.  This function implements the actual fetch of the results.</para>
+			<para>This also sets <variable>ODBC_FETCH_STATUS</variable>.</para>
+			<variablelist>
+				<variable name="ODBC_FETCH_STATUS">
+					<value name="SUCESS">
+						If rows are available.
+					</value>
+					<value name="FAILURE">
+						If no rows are available.
+					</value>
+				</variable>
+			</variablelist>
+		</description>
+	</function>
+	<application name="ODBCFinish" language="en_US">
+		<synopsis>
+			Clear the resultset of a sucessful multirow query.
+		</synopsis>
+		<syntax>
+			<parameter name="result-id" required="true" />
+		</syntax>
+		<description>
+			<para>For queries which are marked as mode=multirow, this will clear 
+			any remaining rows of the specified resultset.</para>
+		</description>
+	</application>
+	<function name="SQL_ESC" language="en_US">
+		<synopsis>
+			Escapes single ticks for use in SQL statements.
+		</synopsis>
+		<syntax>
+			<parameter name="string" required="true" />
+		</syntax>
+		<description>
+			<para>Used in SQL templates to escape data which may contain single ticks 
+			<literal>'</literal> which are otherwise used to delimit data.</para>
+		  	<para>Example: SELECT foo FROM bar WHERE baz='${SQL_ESC(${ARG1})}'</para>
+		</description>
+	</function>
+ ***/
 
 static char *config = "func_odbc.conf";
 
@@ -547,12 +599,6 @@
 
 static struct ast_custom_function escape_function = {
 	.name = "SQL_ESC",
-	.synopsis = "Escapes single ticks for use in SQL statements",
-	.syntax = "SQL_ESC(<string>)",
-	.desc =
-"Used in SQL templates to escape data which may contain single ticks (') which\n"
-"are otherwise used to delimit data.  For example:\n"
-"SELECT foo FROM bar WHERE baz='${SQL_ESC(${ARG1})}'\n",
 	.read = acf_escape,
 	.write = NULL,
 };
@@ -587,24 +633,11 @@
 
 static struct ast_custom_function fetch_function = {
 	.name = "ODBC_FETCH",
-	.synopsis = "Fetch a row from a multirow query",
-	.syntax = "ODBC_FETCH(<result-id>)",
-	.desc =
-"For queries which are marked as mode=multirow, the original query returns a\n"
-"result-id from which results may be fetched.  This function implements the\n"
-"actual fetch of the results.\n"
-"This function also sets ODBC_FETCH_STATUS to one of \"SUCCESS\" or \"FAILURE\",\n"
-"depending upon whether there were rows available or not.\n",
 	.read = acf_fetch,
 	.write = NULL,
 };
 
 static char *app_odbcfinish = "ODBCFinish";
-static char *syn_odbcfinish = "Clear the resultset of a successful multirow query";
-static char *desc_odbcfinish =
-"ODBCFinish(<result-id>)\n"
-"  Clears any remaining rows of the specified resultset\n";
-
 
 static int exec_odbcfinish(struct ast_channel *chan, void *data)
 {
@@ -835,7 +868,7 @@
 	struct ast_flags config_flags = { 0 };
 
 	res |= ast_custom_function_register(&fetch_function);
-	res |= ast_register_application(app_odbcfinish, exec_odbcfinish, syn_odbcfinish, desc_odbcfinish);
+	res |= ast_register_application_xml(app_odbcfinish, exec_odbcfinish);
 	AST_RWLIST_WRLOCK(&queries);
 
 	cfg = ast_config_load(config, config_flags);

Modified: team/group/appdocsxml/main/pbx.c
URL: http://svn.digium.com/view/asterisk/team/group/appdocsxml/main/pbx.c?view=diff&rev=146014&r1=146013&r2=146014
==============================================================================
--- team/group/appdocsxml/main/pbx.c (original)
+++ team/group/appdocsxml/main/pbx.c Fri Oct  3 09:19:42 2008
@@ -3163,6 +3163,10 @@
 	char *lang;
 
 	node = ast_xml_get_root(doc);
+	if (!node) {
+		ast_log(LOG_ERROR, "No XML root node found while reading %s %s documentation\n", name, type);
+		return NULL;
+	}
 	node = node->AST_XML_CHILD;
 	while (node) {
 		node = ast_xml_find_element(node, type, "name", name);




More information about the asterisk-commits mailing list