summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorTilghman Lesher <tilghman@meg.abyt.es>2006-10-02 22:02:45 +0000
committerTilghman Lesher <tilghman@meg.abyt.es>2006-10-02 22:02:45 +0000
commitd3033c319b21b7a42f0712478ff9ced582f55a08 (patch)
tree85b1697c133387be76a84b5536b2c8c5c10b34ac /apps
parent8ff3dd273a3c75cce15d7f1a6541a53c69c13a0f (diff)
Use the standard parsing routines
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@44231 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r--apps/app_stack.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/apps/app_stack.c b/apps/app_stack.c
index 434055e0d..7cdf80151 100644
--- a/apps/app_stack.c
+++ b/apps/app_stack.c
@@ -182,27 +182,39 @@ static int gosub_exec(struct ast_channel *chan, void *data)
static int gosubif_exec(struct ast_channel *chan, void *data)
{
struct ast_module_user *u;
- char *condition = "", *label1, *label2, *args;
+ char *args;
int res=0;
+ AST_DECLARE_APP_ARGS(cond,
+ AST_APP_ARG(ition);
+ AST_APP_ARG(labels);
+ );
+ AST_DECLARE_APP_ARGS(label,
+ AST_APP_ARG(iftrue);
+ AST_APP_ARG(iffalse);
+ );
if (ast_strlen_zero(data)) {
ast_log(LOG_WARNING, "GosubIf requires an argument: GosubIf(cond?label1(args):label2(args)\n");
return 0;
}
- args = ast_strdupa(data);
-
u = ast_module_user_add(chan);
- condition = strsep(&args, "?");
- label1 = strsep(&args, ":");
- label2 = args;
+ args = ast_strdupa(data);
+ AST_NONSTANDARD_APP_ARGS(cond, args, '?');
+ if (cond.argc != 2) {
+ ast_log(LOG_WARNING, "GosubIf requires an argument: GosubIf(cond?label1(args):label2(args)\n");
+ ast_module_user_remove(u);
+ return 0;
+ }
+
+ AST_NONSTANDARD_APP_ARGS(label, cond.labels, ':');
- if (pbx_checkcondition(condition)) {
- if (label1)
- res = gosub_exec(chan, label1);
- } else if (label2) {
- res = gosub_exec(chan, label2);
+ if (pbx_checkcondition(cond.ition)) {
+ if (!ast_strlen_zero(label.iftrue))
+ res = gosub_exec(chan, label.iftrue);
+ } else if (!ast_strlen_zero(label.iffalse)) {
+ res = gosub_exec(chan, label.iffalse);
}
ast_module_user_remove(u);