[asterisk-commits] russell: branch russell/dundi_results r62093 -
/team/russell/dundi_results/pbx/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Apr 26 15:33:41 MST 2007
Author: russell
Date: Thu Apr 26 17:33:41 2007
New Revision: 62093
URL: http://svn.digium.com/view/asterisk?view=rev&rev=62093
Log:
Instead of specifying a result number of 0 to get the number of available
results, make it be "getnum". Updated example usage ...
exten => s,1,Set(ID=${DUNDIQUERY(1234)})
exten => s,n,Set(NUMRESULTS=${DUNDIRESULT(${ID}|getnum)})
exten => s,n,Set(X=1)
exten => s,n,While($[${X} <= ${NUMRESULTS}])
exten => s,n,NoOp(Result ${X} is ${DUNDIRESULT(${ID}|${X})})
exten => s,n,Set(X=$[${X} + 1])
exten => s,n,EndWhile
Modified:
team/russell/dundi_results/pbx/pbx_dundi.c
Modified: team/russell/dundi_results/pbx/pbx_dundi.c
URL: http://svn.digium.com/view/asterisk/team/russell/dundi_results/pbx/pbx_dundi.c?view=diff&rev=62093&r1=62092&r2=62093
==============================================================================
--- team/russell/dundi_results/pbx/pbx_dundi.c (original)
+++ team/russell/dundi_results/pbx/pbx_dundi.c Thu Apr 26 17:33:41 2007
@@ -3967,19 +3967,18 @@
unsigned int num;
struct dundi_result_datastore *drds;
struct ast_datastore *datastore;
+ int res = -1;
u = ast_module_user_add(chan);
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "DUNDIRESULT requires an argument (id and resultnum)\n");
- ast_module_user_remove(u);
- return -1;
+ goto finish;
}
if (!chan) {
ast_log(LOG_ERROR, "DUNDRESULT can not be used without a channel!\n");
- ast_module_user_remove(u);
- return -1;
+ goto finish;
}
parse = ast_strdupa(data);
@@ -3988,34 +3987,37 @@
if (ast_strlen_zero(args.resultnum)) {
ast_log(LOG_ERROR, "A result number must be given to DUNDIRESULT!\n");
- ast_module_user_remove(u);
- return -1;
+ goto finish;
+ }
+
+ if (!(datastore = ast_channel_datastore_find(chan, &dundi_result_datastore_info, args.id))) {
+ ast_log(LOG_WARNING, "No DUNDi results found for query ID '%s'\n", args.id);
+ goto finish;
+ }
+ drds = datastore->data;
+
+ if (!strcasecmp(args.resultnum, "getnum")) {
+ snprintf(buf, len, "%u", drds->num_results);
+ res = 0;
+ goto finish;
}
if (sscanf(args.resultnum, "%u", &num) != 1) {
ast_log(LOG_ERROR, "Invalid value '%s' for resultnum to DUNDIRESULT!\n",
args.resultnum);
- ast_module_user_remove(u);
- return -1;
- }
-
- if (!(datastore = ast_channel_datastore_find(chan, &dundi_result_datastore_info, args.id))) {
- ast_log(LOG_WARNING, "No DUNDi results found for query ID '%s'\n", args.id);
- ast_module_user_remove(u);
- return -1;
- }
- drds = datastore->data;
-
- if (!num)
- snprintf(buf, len, "%u", drds->num_results);
- else if (num <= drds->num_results)
+ goto finish;
+ }
+
+ if (num && num <= drds->num_results) {
snprintf(buf, len, "%s/%s", drds->results[num - 1].tech, drds->results[num - 1].dest);
- else
+ res = 0;
+ } else
ast_log(LOG_WARNING, "Result number %u is not valid for DUNDi query results for ID %s!\n", num, args.id);
+finish:
ast_module_user_remove(u);
- return 0;
+ return res;
}
static struct ast_custom_function dundi_result_function = {
@@ -4026,8 +4028,8 @@
"of the DUNDIQUERY function.\n"
" id - This argument is the identifier returned by the DUNDIQUERY function.\n"
" resultnum - This is the number of the result that you want to retrieve.\n"
- " Results start at 1. If this argument is specified as 0, then it will\n"
- " return the total number of results that are available.\n",
+ " Results start at 1. If this argument is specified as \"getnum\",\n"
+ " then it will return the total number of results that are available.\n",
.read = dundi_result_read,
};
More information about the asterisk-commits
mailing list