aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_url.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_url.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_url.c')
-rw-r--r--apps/app_url.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/apps/app_url.c b/apps/app_url.c
index 46db0d37e..e0ec68e44 100644
--- a/apps/app_url.c
+++ b/apps/app_url.c
@@ -42,6 +42,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
#include "asterisk/translate.h"
#include "asterisk/image.h"
#include "asterisk/options.h"
+#include "asterisk/app.h"
static char *app = "SendURL";
@@ -56,22 +57,32 @@ static char *descrip =
" NOLOAD Client failed to load URL (wait enabled)\n"
" UNSUPPORTED Channel does not support URL transport\n"
"\n"
-"If the option 'wait' is specified, execution will wait for an\n"
+"If the option 'w' is specified, execution will wait for an\n"
"acknowledgement that the URL has been loaded before continuing\n"
"\n"
"SendURL continues normally if the URL was sent correctly or if the channel\n"
"does not support HTML transport. Otherwise, the channel is hung up.\n";
+enum {
+ OPTION_WAIT = (1 << 0),
+} option_flags;
+
+AST_APP_OPTIONS(app_opts,{
+ AST_APP_OPTION('w', OPTION_WAIT),
+});
static int sendurl_exec(struct ast_channel *chan, void *data)
{
int res = 0;
char *tmp;
- char *options;
- int local_option_wait=0;
struct ast_frame *f;
- char *stringp=NULL;
char *status = "FAILURE";
+ char *opts[0];
+ struct ast_flags flags;
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(url);
+ AST_APP_ARG(options);
+ );
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "SendURL requires an argument (URL)\n");
@@ -81,24 +92,22 @@ static int sendurl_exec(struct ast_channel *chan, void *data)
tmp = ast_strdupa(data);
- stringp=tmp;
- strsep(&stringp, "|");
- options = strsep(&stringp, "|");
- if (options && !strcasecmp(options, "wait"))
- local_option_wait = 1;
+ AST_STANDARD_APP_ARGS(args, tmp);
+ if (args.argc == 2)
+ ast_app_parse_options(app_opts, &flags, opts, args.options);
if (!ast_channel_supports_html(chan)) {
/* Does not support transport */
pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "UNSUPPORTED");
return 0;
}
- res = ast_channel_sendurl(chan, tmp);
+ res = ast_channel_sendurl(chan, args.url);
if (res == -1) {
pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", "FAILURE");
return res;
}
status = "SUCCESS";
- if (local_option_wait) {
+ if (ast_test_flag(&flags, OPTION_WAIT)) {
for(;;) {
/* Wait for an event */
res = ast_waitfor(chan, -1);
@@ -120,7 +129,7 @@ static int sendurl_exec(struct ast_channel *chan, void *data)
break;
case AST_HTML_NOSUPPORT:
/* Does not support transport */
- status ="UNSUPPORTED";
+ status = "UNSUPPORTED";
res = 0;
ast_frfree(f);
goto out;