aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_dial.c
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-23 19:51:41 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-07-23 19:51:41 +0000
commitfd0b69a4e7f57297f9c011c75820432d693e21a5 (patch)
treec9c73917bfd120da30c16650000c7296781fae50 /apps/app_dial.c
parentb5741f9dd4e38302ab7d62f3999c59f5b9011ac5 (diff)
Merge the dialplan_aesthetics branch. Most of this patch simply converts applications
using old methods of parsing arguments to using the standard macros. However, the big change is that the really old way of specifying application and arguments separated by a comma will no longer work (e.g. NoOp,foo|bar). Instead, the way that has been recommended since long before 1.0 will become the only method available (e.g. NoOp(foo,bar). git-svn-id: http://svn.digium.com/svn/asterisk/trunk@76703 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_dial.c')
-rw-r--r--apps/app_dial.c68
1 files changed, 30 insertions, 38 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 29f059a02..0acdc1751 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -66,7 +66,7 @@ static char *app = "Dial";
static char *synopsis = "Place a call and connect to the current channel";
static char *descrip =
-" Dial(Technology/resource[&Tech2/resource2...][|timeout][|options][|URL]):\n"
+" Dial(Technology/resource[&Tech2/resource2...][,timeout][,options][,URL]):\n"
"This application will place calls to one or more specified channels. As soon\n"
"as one of the requested channels answers, the originating channel will be\n"
"answered, if it has not already been answered. These two channels will then\n"
@@ -215,7 +215,7 @@ static char *descrip =
static char *rapp = "RetryDial";
static char *rsynopsis = "Place a call, retrying on failure allowing optional exit extension.";
static char *rdescrip =
-" RetryDial(announce|sleep|retries|dialargs): This application will attempt to\n"
+" RetryDial(announce,sleep,retries,dialargs): This application will attempt to\n"
"place a call using the normal Dial application. If no channel can be reached,\n"
"the 'announce' file will be played. Then, it will wait 'sleep' number of\n"
"seconds before retying the call. After 'retires' number of attempts, the\n"
@@ -840,7 +840,7 @@ static void replace_macro_delimiter(char *s)
{
for (; *s; s++)
if (*s == '^')
- *s = '|';
+ *s = ',';
}
@@ -1856,41 +1856,33 @@ static int dial_exec(struct ast_channel *chan, void *data)
static int retrydial_exec(struct ast_channel *chan, void *data)
{
- char *announce = NULL, *dialdata = NULL;
+ char *parse;
const char *context = NULL;
int sleep = 0, loops = 0, res = -1;
- struct ast_flags64 peerflags;
-
+ struct ast_flags64 peerflags = { 0, };
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(announce);
+ AST_APP_ARG(sleep);
+ AST_APP_ARG(retries);
+ AST_APP_ARG(dialdata);
+ );
+
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "RetryDial requires an argument!\n");
return -1;
}
- announce = ast_strdupa(data);
-
- memset(&peerflags, 0, sizeof(peerflags));
+ parse = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, parse);
- if ((dialdata = strchr(announce, '|'))) {
- *dialdata++ = '\0';
- if (sscanf(dialdata, "%d", &sleep) == 1) {
- sleep *= 1000;
- } else {
- ast_log(LOG_ERROR, "%s requires the numerical argument <sleep>\n",rapp);
- goto done;
- }
- if ((dialdata = strchr(dialdata, '|'))) {
- *dialdata++ = '\0';
- if (sscanf(dialdata, "%d", &loops) != 1) {
- ast_log(LOG_ERROR, "%s requires the numerical argument <loops>\n",rapp);
- goto done;
- }
- }
+ if ((sleep = atoi(args.sleep))) {
+ sleep *= 1000;
}
-
- if ((dialdata = strchr(dialdata, '|'))) {
- *dialdata++ = '\0';
- } else {
- ast_log(LOG_ERROR, "%s requires more arguments\n",rapp);
+
+ loops = atoi(args.retries);
+
+ if (!args.dialdata) {
+ ast_log(LOG_ERROR, "%s requires a 4th argument (dialdata)\n", rapp);
goto done;
}
@@ -1910,18 +1902,18 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
if (ast_test_flag(chan, AST_FLAG_MOH))
ast_moh_stop(chan);
- res = dial_exec_full(chan, dialdata, &peerflags, &continue_exec);
+ res = dial_exec_full(chan, args.dialdata, &peerflags, &continue_exec);
if (continue_exec)
break;
if (res == 0) {
if (ast_test_flag64(&peerflags, OPT_DTMF_EXIT)) {
- if (!ast_strlen_zero(announce)) {
- if (ast_fileexists(announce, NULL, chan->language) > 0) {
- if(!(res = ast_streamfile(chan, announce, chan->language)))
+ if (!ast_strlen_zero(args.announce)) {
+ if (ast_fileexists(args.announce, NULL, chan->language) > 0) {
+ if(!(res = ast_streamfile(chan, args.announce, chan->language)))
ast_waitstream(chan, AST_DIGIT_ANY);
} else
- ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", announce);
+ ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce);
}
if (!res && sleep) {
if (!ast_test_flag(chan, AST_FLAG_MOH))
@@ -1929,12 +1921,12 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
res = ast_waitfordigit(chan, sleep);
}
} else {
- if (!ast_strlen_zero(announce)) {
- if (ast_fileexists(announce, NULL, chan->language) > 0) {
- if (!(res = ast_streamfile(chan, announce, chan->language)))
+ if (!ast_strlen_zero(args.announce)) {
+ if (ast_fileexists(args.announce, NULL, chan->language) > 0) {
+ if (!(res = ast_streamfile(chan, args.announce, chan->language)))
res = ast_waitstream(chan, "");
} else
- ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", announce);
+ ast_log(LOG_WARNING, "Announce file \"%s\" specified in Retrydial does not exist\n", args.announce);
}
if (sleep) {
if (!ast_test_flag(chan, AST_FLAG_MOH))