aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-04-09 23:56:15 +0000
committermarkster <markster@f38db490-d61c-443f-a65b-d21fe96a405b>2003-04-09 23:56:15 +0000
commit40028fe80ea1c36b7eb35e5cda282d5d083336ab (patch)
tree9b9863de3fe260fd81cfcd4e88ab97137001f3c7
parentb5dfede5e4a0a446a83413e3a42ea77e60f08c7f (diff)
Add new "macrocontext" field (yes, you need to "make clean ; make install"
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@808 f38db490-d61c-443f-a65b-d21fe96a405b
-rwxr-xr-xapps/app_macro.c16
-rwxr-xr-xapps/app_voicemail.c4
-rwxr-xr-xinclude/asterisk/channel.h2
3 files changed, 15 insertions, 7 deletions
diff --git a/apps/app_macro.c b/apps/app_macro.c
index 4a84e011d..eec120575 100755
--- a/apps/app_macro.c
+++ b/apps/app_macro.c
@@ -65,6 +65,7 @@ static int macro_exec(struct ast_channel *chan, void *data)
char oldcontext[256] = "";
char *offsets;
int offset;
+ int setmacrocontext=0;
char *save_macro_exten;
char *save_macro_context;
@@ -94,6 +95,10 @@ static int macro_exec(struct ast_channel *chan, void *data)
oldpriority = chan->priority;
strncpy(oldexten, chan->exten, sizeof(oldexten) - 1);
strncpy(oldcontext, chan->context, sizeof(oldcontext) - 1);
+ if (!strlen(chan->macrocontext)) {
+ strncpy(chan->macrocontext, chan->context, sizeof(chan->macrocontext) - 1);
+ setmacrocontext=1;
+ }
argc = 1;
/* Save old macro variables */
save_macro_exten = pbx_builtin_getvar_helper(chan, "MACRO_EXTEN");
@@ -115,10 +120,7 @@ static int macro_exec(struct ast_channel *chan, void *data)
/* Setup environment for new run */
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));
-#endif
chan->priority = 1;
while((cur = strsep(&rest, "|")) && (argc < MAX_ARGS)) {
@@ -131,8 +133,8 @@ static int macro_exec(struct ast_channel *chan, void *data)
pbx_builtin_setvar_helper(chan, varname, cur);
argc++;
}
- while(ast_exists_extension(chan, fullmacro, chan->exten, chan->priority, chan->callerid)) {
- if ((res = ast_spawn_extension(chan, fullmacro, chan->exten, chan->priority, chan->callerid))) {
+ while(ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid)) {
+ if ((res = ast_spawn_extension(chan, chan->context, chan->exten, chan->priority, chan->callerid))) {
/* Something bad happened, or a hangup has been requested. */
if (((res >= '0') && (res <= '9')) || ((res >= 'A') && (res <= 'F'))) {
/* Just return result as to the previous application as if it had been dialed */
@@ -155,7 +157,7 @@ static int macro_exec(struct ast_channel *chan, void *data)
goto out;
}
}
- if (strcmp(chan->context, oldcontext) || strcmp(chan->exten, "s")) {
+ if (strcasecmp(chan->context, fullmacro)) {
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Channel '%s' jumping out of macro '%s'\n", chan->name, macro);
break;
@@ -186,6 +188,8 @@ out:
if (save_macro_context) free(save_macro_context);
pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", save_macro_priority);
if (save_macro_priority) free(save_macro_priority);
+ if (setmacrocontext)
+ strcpy(chan->macrocontext, "");
if (!strcasecmp(chan->context, fullmacro)) {
/* If we're leaving the macro normally, restore original information */
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index d14884931..7f32db009 100755
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -492,7 +492,7 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
make_dir(dir, sizeof(dir), ext, "INBOX");
if (mkdir(dir, 0700) && (errno != EEXIST))
ast_log(LOG_WARNING, "mkdir '%s' failed: %s\n", dir, strerror(errno));
- if (ast_exists_extension(chan, chan->context, "o", 1, chan->callerid))
+ if (ast_exists_extension(chan, strlen(chan->macrocontext) ? chan->macrocontext : chan->context, "o", 1, chan->callerid))
ecodes = "#0";
/* Play the beginning intro if desired */
if (strlen(prefile)) {
@@ -520,6 +520,8 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, int silent, int
}
} else if (silent == '0') {
strncpy(chan->exten, "o", sizeof(chan->exten) - 1);
+ if (strlen(chan->macrocontext))
+ strncpy(chan->context, chan->macrocontext, sizeof(chan->context) - 1);
chan->priority = 0;
ast_softhangup(chan, AST_SOFTHANGUP_ASYNCGOTO);
free(copy);
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 3ab0f647a..73ecc8b29 100755
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -142,6 +142,8 @@ struct ast_channel {
/*! Current extension context */
char context[AST_MAX_EXTENSION];
+ /*! Current non-macro context */
+ char macrocontext[AST_MAX_EXTENSION];
/*! Current extension number */
char exten[AST_MAX_EXTENSION];
/* Current extension priority */