]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
add support for variable expander to recognize 717 vars as specificly globals
authorAnthony Minessale <anthm@freeswitch.org>
Thu, 24 May 2012 18:07:26 +0000 (13:07 -0500)
committerAnthony Minessale <anthm@freeswitch.org>
Thu, 24 May 2012 18:07:26 +0000 (13:07 -0500)
src/switch_channel.c
src/switch_event.c

index 7afe342103ba228cae5bab314d9b23a5cdbac618..e06706cbc37f1fe3f9a6a55a7920d838c7e60e7e 100644 (file)
@@ -3411,12 +3411,16 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables_check(switch_channel_t *c
                memset(data, 0, olen);
                c = data;
                for (p = indup; p && p < endof_indup && *p; p++) {
+                       int global = 0;
                        vtype = 0;
 
                        if (*p == '\\') {
                                if (*(p + 1) == '$') {
                                        nv = 1;
                                        p++;
+                                       if (*(p + 1) == '$') {
+                                               p++;
+                                       }
                                } else if (*(p + 1) == '\'') {
                                        p++;
                                        continue;
@@ -3428,9 +3432,15 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables_check(switch_channel_t *c
                        }
 
                        if (*p == '$' && !nv) {
+
+                               if (*(p + 1) == '$') {
+                                       p++;
+                                       global++;
+                               }
+
                                if (*(p + 1)) {
                                        if (*(p + 1) == '{') {
-                                               vtype = 1;
+                                               vtype = global ? 3 : 1;
                                        } else {
                                                nv = 1;
                                        }
@@ -3452,7 +3462,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables_check(switch_channel_t *c
 
                                s++;
 
-                               if (vtype == 1 && *s == '{') {
+                               if ((vtype == 1 || vtype == 3) && *s == '{') {
                                        br = 1;
                                        s++;
                                }
@@ -3513,7 +3523,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables_check(switch_channel_t *c
                                        vtype = 2;
                                }
 
-                               if (vtype == 1) {
+                               if (vtype == 1 || vtype == 3) {
                                        char *expanded = NULL;
                                        int offset = 0;
                                        int ooffset = 0;
@@ -3540,7 +3550,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables_check(switch_channel_t *c
                                                idx = atoi(ptr);
                                        }
                                        
-                                       if ((sub_val = (char *) switch_channel_get_variable_dup(channel, vname, SWITCH_TRUE, idx))) {
+                                       if (vtype == 3 || (sub_val = (char *) switch_channel_get_variable_dup(channel, vname, SWITCH_TRUE, idx))) {
                                                if (var_list && !switch_event_check_permission_list(var_list, vname)) {
                                                        sub_val = "INVALID";
                                                }
index 9a0776efd1c7b829716b0400e05eb86d329d80e1..defae3586c370d04ca0654d38de4da8379631ae2 100644 (file)
@@ -1957,12 +1957,16 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
                memset(data, 0, olen);
                c = data;
                for (p = indup; p && p < endof_indup && *p; p++) {
+                       int global = 0;
                        vtype = 0;
 
                        if (*p == '\\') {
                                if (*(p + 1) == '$') {
                                        nv = 1;
                                        p++;
+                                       if (*(p + 1) == '$') {
+                                               p++;
+                                       }
                                } else if (*(p + 1) == '\'') {
                                        p++;
                                        continue;
@@ -1974,9 +1978,14 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
                        }
 
                        if (*p == '$' && !nv) {
+                               if (*(p + 1) == '$') {
+                                       p++;
+                                       global++;
+                               }
+
                                if (*(p + 1)) {
                                        if (*(p + 1) == '{') {
-                                               vtype = 1;
+                                               vtype = global ? 3 : 1;
                                        } else {
                                                nv = 1;
                                        }
@@ -1998,7 +2007,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
 
                                s++;
 
-                               if (vtype == 1 && *s == '{') {
+                               if ((vtype == 1 || vtype == 3) && *s == '{') {
                                        br = 1;
                                        s++;
                                }
@@ -2060,7 +2069,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
                                        vtype = 2;
                                }
 
-                               if (vtype == 1) {
+                               if (vtype == 1 || vtype == 3) {
                                        char *expanded = NULL;
                                        int offset = 0;
                                        int ooffset = 0;
@@ -2086,7 +2095,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
                                                idx = atoi(ptr);
                                        }
 
-                                       if (!(sub_val = switch_event_get_header_idx(event, vname, idx))) {
+                                       if (vtype == 3 || !(sub_val = switch_event_get_header_idx(event, vname, idx))) {
                                                switch_safe_free(gvar);
                                                if ((gvar = switch_core_get_variable_dup(vname))) {
                                                        sub_val = gvar;