]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
automerge commit
authorAutomerge script <automerge@asterisk.org>
Thu, 17 Aug 2006 17:04:18 +0000 (17:04 +0000)
committerAutomerge script <automerge@asterisk.org>
Thu, 17 Aug 2006 17:04:18 +0000 (17:04 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@40253 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_macro.c
channel.c
funcs/func_cdr.c

index 4fb3360257c4190cb2b8aa15881763f86f24ba26..0ac2d097f67e6324cce51848263624f3ffe6bd74 100644 (file)
@@ -101,8 +101,8 @@ static int macro_exec(struct ast_channel *chan, void *data)
        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;
   
@@ -119,6 +119,11 @@ static int macro_exec(struct ast_channel *chan, void *data)
 
        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) {
@@ -127,7 +132,7 @@ static int macro_exec(struct ast_channel *chan, void *data)
                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;
index 26e5e05ba3ce26054341b21ed57684d17721538e..2f3950195d7a24a3cdc4cbcf31cfd65ac97a6f56 100644 (file)
--- a/channel.c
+++ b/channel.c
@@ -3196,7 +3196,8 @@ int ast_setstate(struct ast_channel *chan, int state)
 
        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"
index 3e4696e18df6fa17c91a8b1d8a50fa3b383883e2..fdd241894b6d6bf8ebef4a6fa911645b376a72a1 100644 (file)
@@ -44,11 +44,12 @@ static char *builtin_function_cdr_read(struct ast_channel *chan, char *cmd, char
        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);
@@ -61,7 +62,11 @@ static char *builtin_function_cdr_read(struct ast_channel *chan, char *cmd, char
                        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;
 }