|
|
@ -117,9 +117,10 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
|
|
|
|
int oldpriority;
|
|
|
|
int oldpriority;
|
|
|
|
char pc[80], depthc[12];
|
|
|
|
char pc[80], depthc[12];
|
|
|
|
char oldcontext[AST_MAX_CONTEXT] = "";
|
|
|
|
char oldcontext[AST_MAX_CONTEXT] = "";
|
|
|
|
|
|
|
|
const char *inhangupc;
|
|
|
|
int offset, depth = 0, maxdepth = 7;
|
|
|
|
int offset, depth = 0, maxdepth = 7;
|
|
|
|
int setmacrocontext=0;
|
|
|
|
int setmacrocontext=0;
|
|
|
|
int autoloopflag, dead = 0;
|
|
|
|
int autoloopflag, dead = 0, inhangup = 0;
|
|
|
|
|
|
|
|
|
|
|
|
char *save_macro_exten;
|
|
|
|
char *save_macro_exten;
|
|
|
|
char *save_macro_context;
|
|
|
|
char *save_macro_context;
|
|
|
@ -143,6 +144,13 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
|
|
|
|
s = pbx_builtin_getvar_helper(chan, "MACRO_DEPTH");
|
|
|
|
s = pbx_builtin_getvar_helper(chan, "MACRO_DEPTH");
|
|
|
|
if (s)
|
|
|
|
if (s)
|
|
|
|
sscanf(s, "%d", &depth);
|
|
|
|
sscanf(s, "%d", &depth);
|
|
|
|
|
|
|
|
/* Used for detecting whether to return when a Macro is called from another Macro after hangup */
|
|
|
|
|
|
|
|
if (strcmp(chan->exten, "h") == 0)
|
|
|
|
|
|
|
|
pbx_builtin_setvar_helper(chan, "MACRO_IN_HANGUP", "1");
|
|
|
|
|
|
|
|
inhangupc = pbx_builtin_getvar_helper(chan, "MACRO_IN_HANGUP");
|
|
|
|
|
|
|
|
if (!ast_strlen_zero(inhangupc))
|
|
|
|
|
|
|
|
sscanf(inhangupc, "%d", &inhangup);
|
|
|
|
|
|
|
|
|
|
|
|
if (depth >= maxdepth) {
|
|
|
|
if (depth >= maxdepth) {
|
|
|
|
ast_log(LOG_ERROR, "Macro(): possible infinite loop detected. Returning early.\n");
|
|
|
|
ast_log(LOG_ERROR, "Macro(): possible infinite loop detected. Returning early.\n");
|
|
|
|
ast_module_user_remove(u);
|
|
|
|
ast_module_user_remove(u);
|
|
|
@ -267,7 +275,7 @@ static int _macro_exec(struct ast_channel *chan, void *data, int exclusive)
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* don't stop executing extensions when we're in "h" */
|
|
|
|
/* don't stop executing extensions when we're in "h" */
|
|
|
|
if (chan->_softhangup && strcasecmp(oldexten,"h") && strcasecmp(chan->macroexten,"h")) {
|
|
|
|
if (chan->_softhangup && !inhangup) {
|
|
|
|
if (option_debug)
|
|
|
|
if (option_debug)
|
|
|
|
ast_log(LOG_DEBUG, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n",
|
|
|
|
ast_log(LOG_DEBUG, "Extension %s, macroexten %s, priority %d returned normally even though call was hung up\n",
|
|
|
|
chan->exten, chan->macroexten, chan->priority);
|
|
|
|
chan->exten, chan->macroexten, chan->priority);
|
|
|
|