int oldpriority;
char pc[80], depthc[12];
char oldcontext[AST_MAX_CONTEXT] = "";
- char *offsets;
- int offset, depth;
+ char *offsets, *s;
+ int offset, depth = 0, maxdepth = 7;
int setmacrocontext=0;
int autoloopflag, dead = 0;
LOCAL_USER_ADD(u);
+ /* does the user want a deeper rabbit hole? */
+ s = pbx_builtin_getvar_helper(chan, "MACRO_RECURSION");
+ if (s)
+ sscanf(s, "%d", &maxdepth);
+
/* Count how many levels deep the rabbit hole goes */
tmp = pbx_builtin_getvar_helper(chan, "MACRO_DEPTH");
if (tmp) {
depth = 0;
}
- if (depth >= 20) {
+ if (depth >= maxdepth) {
ast_log(LOG_ERROR, "Macro(): possible infinite loop detected. Returning early.\n");
LOCAL_USER_REMOVE(u);
return 0;
chan->_state = state;
ast_device_state_changed_literal(chan->name);
- manager_event(EVENT_FLAG_CALL, "Newstate",
+ manager_event(EVENT_FLAG_CALL,
+ (oldstate == AST_STATE_DOWN) ? "Newchannel" : "Newstate",
"Channel: %s\r\n"
"State: %s\r\n"
"CallerID: %s\r\n"
int argc;
char *argv[2];
int recursive = 0;
+ struct ast_cdr *cdr = chan->cdr;
if (ast_strlen_zero(data))
return NULL;
- if (!chan->cdr)
+ if (!cdr)
return NULL;
mydata = ast_strdupa(data);
recursive = 1;
}
- ast_cdr_getvar(chan->cdr, argv[0], &ret, buf, len, recursive);
+ /* Find last entry */
+ while (cdr->next)
+ cdr = cdr->next;
+
+ ast_cdr_getvar(cdr, argv[0], &ret, buf, len, recursive);
return ret;
}