diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-04-29 15:04:26 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-04-29 15:04:26 +0000 |
commit | 1cbba5607c36e87977b265e84afa60db41560ce1 (patch) | |
tree | 30e8ea21857bedceb044494a0aeefd2d343f8bc3 /apps | |
parent | 044d2218ba972a4a4ef2d2aa9a9f80f3fad9a6b9 (diff) |
make 'goto' APIs aware of auto-processing loops, so they know exactly when to set the requested priority or one priority lower
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5529 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rwxr-xr-x | apps/app_dial.c | 23 | ||||
-rwxr-xr-x | apps/app_macro.c | 4 |
2 files changed, 13 insertions, 14 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c index 2b90e9c38..d5b46dfd1 100755 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -201,24 +201,19 @@ static void hanguptree(struct localuser *outgoing, struct ast_channel *exception } while (0) -static int ast_onedigit_goto(struct ast_channel *chan, char *context, char exten, int pri, char *cid) +static int onedigit_goto(struct ast_channel *chan, char *context, char exten, int pri) { - char rexten[2]; - snprintf(rexten, 2, "%c", exten); + char rexten[2] = { exten, '\0' }; + if (context) { - if (ast_exists_extension(chan, context, rexten, pri, cid)) { - ast_explicit_goto(chan, context, rexten, pri-1); + if (ast_goto_if_exists(chan, context, rexten, pri)) return 1; - } } else { - if (ast_exists_extension(chan, chan->context, rexten, pri, cid)) { - ast_explicit_goto(chan, chan->context, rexten, pri-1); + if (ast_goto_if_exists(chan, chan->context, rexten, pri)) return 1; - } else if (!ast_strlen_zero(chan->macrocontext)) { - if (ast_exists_extension(chan, chan->macrocontext, rexten, pri, cid)) { - ast_explicit_goto(chan, chan->macrocontext, rexten, pri-1); + else if (!ast_strlen_zero(chan->macrocontext)) { + if (ast_goto_if_exists(chan, chan->macrocontext, rexten, pri)) return 1; - } } } return 0; @@ -552,7 +547,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in, struct localu if (f && (f->frametype == AST_FRAME_DTMF)) { if (ast_test_flag(peerflags, DIAL_HALT_ON_DTMF)) { context = pbx_builtin_getvar_helper(in, "EXITCONTEXT"); - if (ast_onedigit_goto(in, context, (char) f->subclass, 1, in->cid.cid_num)) { + if (onedigit_goto(in, context, (char) f->subclass, 1)) { if (option_verbose > 3) ast_verbose(VERBOSE_PREFIX_3 "User hit %c to disconnect call.\n", f->subclass); *to=0; @@ -1448,7 +1443,7 @@ static int retrydial_exec(struct ast_channel *chan, void *data) if (res < 0) break; else if (res > 0) { /* Trying to send the call elsewhere (1 digit ext) */ - if (ast_onedigit_goto(chan, context, (char) res, 1, chan->cid.cid_num)) { + if (onedigit_goto(chan, context, (char) res, 1)) { res = 0; break; } diff --git a/apps/app_macro.c b/apps/app_macro.c index f0b37aed3..43ad36836 100755 --- a/apps/app_macro.c +++ b/apps/app_macro.c @@ -88,6 +88,7 @@ static int macro_exec(struct ast_channel *chan, void *data) char *offsets; int offset; int setmacrocontext=0; + int autoloopflag; char *save_macro_exten; char *save_macro_context; @@ -166,6 +167,8 @@ static int macro_exec(struct ast_channel *chan, void *data) pbx_builtin_setvar_helper(chan, varname, cur); argc++; } + autoloopflag = ast_test_flag(chan, AST_FLAG_IN_AUTOLOOP); + ast_set_flag(chan, AST_FLAG_IN_AUTOLOOP); while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) { if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num))) { /* Something bad happened, or a hangup has been requested. */ @@ -208,6 +211,7 @@ static int macro_exec(struct ast_channel *chan, void *data) chan->priority++; } out: + ast_set2_flag(chan, autoloopflag, AST_FLAG_IN_AUTOLOOP); for (x=1; x<argc; x++) { /* Restore old arguments and delete ours */ snprintf(varname, sizeof(varname), "ARG%d", x); |