From 1cfd145c171968bd7b184206e281f773d6feebdf Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Thu, 24 May 2012 13:07:26 -0500 Subject: [PATCH] add support for variable expander to recognize 717 vars as specificly globals --- src/switch_channel.c | 18 ++++++++++++++---- src/switch_event.c | 17 +++++++++++++---- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/src/switch_channel.c b/src/switch_channel.c index 7afe342103..e06706cbc3 100644 --- a/src/switch_channel.c +++ b/src/switch_channel.c @@ -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"; } diff --git a/src/switch_event.c b/src/switch_event.c index 9a0776efd1..defae3586c 100644 --- a/src/switch_event.c +++ b/src/switch_event.c @@ -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;