Make macro preserve context

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@807 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Mark Spencer
2003-04-09 23:46:49 +00:00
parent b0bb0ed079
commit 45eb2c1c9d

View File

@@ -115,7 +115,10 @@ static int macro_exec(struct ast_channel *chan, void *data)
/* Setup environment for new run */ /* Setup environment for new run */
strcpy(chan->exten, "s"); strcpy(chan->exten, "s");
#if 0
/* Don't overwrite it because sometimes we have to know the real context */
strncpy(chan->context, fullmacro, sizeof(chan->context)); strncpy(chan->context, fullmacro, sizeof(chan->context));
#endif
chan->priority = 1; chan->priority = 1;
while((cur = strsep(&rest, "|")) && (argc < MAX_ARGS)) { while((cur = strsep(&rest, "|")) && (argc < MAX_ARGS)) {
@@ -128,8 +131,8 @@ static int macro_exec(struct ast_channel *chan, void *data)
pbx_builtin_setvar_helper(chan, varname, cur); pbx_builtin_setvar_helper(chan, varname, cur);
argc++; argc++;
} }
while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid)) { while(ast_exists_extension(chan, fullmacro, chan->exten, chan->priority, chan->callerid)) {
if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid))) { if ((res = ast_spawn_extension(chan, fullmacro, chan->exten, chan->priority, chan->callerid))) {
/* Something bad happened, or a hangup has been requested. */ /* Something bad happened, or a hangup has been requested. */
if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F'))) { if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F'))) {
/* Just return result as to the previous application as if it had been dialed */ /* Just return result as to the previous application as if it had been dialed */
@@ -152,7 +155,7 @@ static int macro_exec(struct ast_channel *chan, void *data)
goto out; goto out;
} }
} }
if (strcasecmp(chan->context, fullmacro)) { if (strcmp(chan->context, oldcontext) || strcmp(chan->exten, "s")) {
if (option_verbose > 1) if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Channel '%s' jumping out of macro '%s'\n", chan->name, macro); ast_verbose(VERBOSE_PREFIX_2 "Channel '%s' jumping out of macro '%s'\n", chan->name, macro);
break; break;