[asterisk-commits] tilghman: trunk r145846 - in /trunk: ./ configs/ funcs/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Oct 2 12:16:54 CDT 2008


Author: tilghman
Date: Thu Oct  2 12:16:54 2008
New Revision: 145846

URL: http://svn.digium.com/view/asterisk?view=rev&rev=145846
Log:
Permit the syntax and synopsis fields to be set (for func_odbc).

Modified:
    trunk/CHANGES
    trunk/configs/func_odbc.conf.sample
    trunk/funcs/func_odbc.c

Modified: trunk/CHANGES
URL: http://svn.digium.com/view/asterisk/trunk/CHANGES?view=diff&rev=145846&r1=145845&r2=145846
==============================================================================
--- trunk/CHANGES (original)
+++ trunk/CHANGES Thu Oct  2 12:16:54 2008
@@ -13,6 +13,8 @@
  * Added a new dialplan function, CURLOPT, which permits setting various
    options that may be useful with the CURL dialplan function, such as
    cookies, proxies, connection timeouts, passwords, etc.
+ * Permit the syntax and synopsis fields of the corresponding dialplan
+   functions to be individually set from func_odbc.conf.
 
 Miscellaneous
 -------------

Modified: trunk/configs/func_odbc.conf.sample
URL: http://svn.digium.com/view/asterisk/trunk/configs/func_odbc.conf.sample?view=diff&rev=145846&r1=145845&r2=145846
==============================================================================
--- trunk/configs/func_odbc.conf.sample (original)
+++ trunk/configs/func_odbc.conf.sample Thu Oct  2 12:16:54 2008
@@ -57,6 +57,8 @@
                     ; "writehandle", if it is important to separate reads and
                     ; writes to different databases.
 readsql=SELECT COUNT(*) FROM exgirlfriends WHERE callerid='${SQL_ESC(${ARG1})}'
+syntax=<callerid>
+synopsis=Check if a specified callerid is contained in the ex-gf database
 
 ; ODBC_PRESENCE - Retrieve and update presence
 [PRESENCE]

Modified: trunk/funcs/func_odbc.c
URL: http://svn.digium.com/view/asterisk/trunk/funcs/func_odbc.c?view=diff&rev=145846&r1=145845&r2=145846
==============================================================================
--- trunk/funcs/func_odbc.c (original)
+++ trunk/funcs/func_odbc.c Thu Oct  2 12:16:54 2008
@@ -564,6 +564,7 @@
 	struct odbc_datastore_row *row;
 	store = ast_channel_datastore_find(chan, &odbc_info, data);
 	if (!store) {
+		pbx_builtin_setvar_helper(chan, "ODBC_FETCH_STATUS", "FAILURE");
 		return -1;
 	}
 	resultset = store->data;
@@ -574,11 +575,13 @@
 		/* Cleanup datastore */
 		ast_channel_datastore_remove(chan, store);
 		ast_datastore_free(store);
+		pbx_builtin_setvar_helper(chan, "ODBC_FETCH_STATUS", "FAILURE");
 		return -1;
 	}
 	pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", resultset->names);
 	ast_copy_string(buf, row->data, len);
 	ast_free(row);
+	pbx_builtin_setvar_helper(chan, "ODBC_FETCH_STATUS", "SUCCESS");
 	return 0;
 }
 
@@ -589,7 +592,9 @@
 	.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",
+"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,
 };
@@ -716,7 +721,11 @@
 		return ENOMEM;
 	}
 
-	asprintf((char **)&((*query)->acf->syntax), "%s(<arg1>[...[,<argN>]])", (*query)->acf->name);
+	if ((tmp = ast_variable_retrieve(cfg, catg, "syntax")) && !ast_strlen_zero(tmp)) {
+		asprintf((char **)&((*query)->acf->syntax), "%s(%s)", (*query)->acf->name, tmp);
+	} else {
+		asprintf((char **)&((*query)->acf->syntax), "%s(<arg1>[...[,<argN>]])", (*query)->acf->name);
+	}
 
 	if (!((*query)->acf->syntax)) {
 		ast_free((char *)(*query)->acf->name);
@@ -726,7 +735,21 @@
 		return ENOMEM;
 	}
 
-	(*query)->acf->synopsis = "Runs the referenced query with the specified arguments";
+	if ((tmp = ast_variable_retrieve(cfg, catg, "synopsis")) && !ast_strlen_zero(tmp)) {
+		(*query)->acf->synopsis = ast_strdup(tmp);
+	} else {
+		(*query)->acf->synopsis = ast_strdup("Runs the referenced query with the specified arguments");
+	}
+
+	if (!((*query)->acf->synopsis)) {
+		ast_free((char *)(*query)->acf->name);
+		ast_free((char *)(*query)->acf->syntax);
+		ast_free((*query)->acf);
+		ast_free(*query);
+		*query = NULL;
+		return ENOMEM;
+	}
+
 	if (!ast_strlen_zero((*query)->sql_read) && !ast_strlen_zero((*query)->sql_write)) {
 		asprintf((char **)&((*query)->acf->desc),
 					"Runs the following query, as defined in func_odbc.conf, performing\n"
@@ -751,6 +774,7 @@
 					"This function may only be set.\nSQL:\n%s\n",
 					(*query)->sql_write);
 	} else {
+		ast_free((char *)(*query)->acf->synopsis);
 		ast_free((char *)(*query)->acf->syntax);
 		ast_free((char *)(*query)->acf->name);
 		ast_free((*query)->acf);
@@ -760,6 +784,7 @@
 	}
 
 	if (! ((*query)->acf->desc)) {
+		ast_free((char *)(*query)->acf->synopsis);
 		ast_free((char *)(*query)->acf->syntax);
 		ast_free((char *)(*query)->acf->name);
 		ast_free((*query)->acf);
@@ -791,6 +816,8 @@
 				ast_free((char *)query->acf->name);
 			if (query->acf->syntax)
 				ast_free((char *)query->acf->syntax);
+			if (query->acf->synopsis)
+				ast_free((char *)query->acf->synopsis);
 			if (query->acf->desc)
 				ast_free((char *)query->acf->desc);
 			ast_free(query->acf);




More information about the asterisk-commits mailing list