mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-26 21:24:16 +00:00
add origination_nested_vars=true to allow vars within vars in originate strings e.g. [originate {origination_nested_vars=true,TEST=,var=,recur=W00t}user/1004 3000] will end up as w00t
This commit is contained in:
1 parent
febb9cc07e
commit
385a92cec7
4 files changed
+54
-25
No files matched your search
+33
-20
@@ -1457,7 +1457,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
|
||||
switch_event_t *e = *event;
|
||||
char *var_array[1024] = { 0 };
|
||||
int var_count = 0;
|
||||
char *next;
|
||||
char *next = NULL, *vnext = NULL;
|
||||
|
||||
if (dup) {
|
||||
vdatap = strdup(data);
|
||||
@@ -1479,6 +1479,7 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
|
||||
if (check_a) end = check_a;
|
||||
|
||||
if (end) {
|
||||
next = end;
|
||||
vdata++;
|
||||
*end++ = '\0';
|
||||
} else {
|
||||
@@ -1494,13 +1495,17 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
|
||||
|
||||
|
||||
for (;;) {
|
||||
if ((next = strchr(vdata, b))) {
|
||||
if (next) {
|
||||
char *pnext;
|
||||
|
||||
*next++ = '\0';
|
||||
|
||||
if ((pnext = switch_strchr_strict(next, a, " "))) {
|
||||
next = pnext + 1;
|
||||
}
|
||||
|
||||
vnext = switch_find_end_paren(next, a, b);
|
||||
next = NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1519,14 +1524,14 @@ SWITCH_DECLARE(switch_status_t) switch_event_create_brackets(char *data, char a,
|
||||
|
||||
if ((inner_var_count = switch_separate_string(var_array[x], '=',
|
||||
inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0])))) == 2) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Parsing variable [%s]=[%s]\n", inner_var_array[0], inner_var_array[1]);
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Parsing variable [%s]=[%s]\n", inner_var_array[0], inner_var_array[1]);
|
||||
switch_event_add_header_string(e, SWITCH_STACK_BOTTOM, inner_var_array[0], inner_var_array[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (next) {
|
||||
vdata = next;
|
||||
if (vnext) {
|
||||
vdata = vnext;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -1993,7 +1998,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
|
||||
char *data, *indup, *endof_indup;
|
||||
size_t sp = 0, len = 0, olen = 0, vtype = 0, br = 0, cpos, block = 128;
|
||||
const char *sub_val = NULL;
|
||||
char *cloned_sub_val = NULL;
|
||||
char *cloned_sub_val = NULL, *expanded_sub_val = NULL;
|
||||
char *func_val = NULL;
|
||||
int nv = 0;
|
||||
char *gvar = NULL, *sb = NULL;
|
||||
@@ -2156,23 +2161,30 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
|
||||
sub_val = "INVALID";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (offset || ooffset) {
|
||||
cloned_sub_val = strdup(sub_val);
|
||||
switch_assert(cloned_sub_val);
|
||||
sub_val = cloned_sub_val;
|
||||
}
|
||||
if ((expanded_sub_val = switch_event_expand_headers(event, sub_val)) == sub_val) {
|
||||
expanded_sub_val = NULL;
|
||||
} else {
|
||||
sub_val = expanded_sub_val;
|
||||
}
|
||||
|
||||
|
||||
if (offset >= 0) {
|
||||
sub_val += offset;
|
||||
} else if ((size_t) abs(offset) <= strlen(sub_val)) {
|
||||
sub_val = cloned_sub_val + (strlen(cloned_sub_val) + offset);
|
||||
}
|
||||
if (offset || ooffset) {
|
||||
cloned_sub_val = strdup(sub_val);
|
||||
switch_assert(cloned_sub_val);
|
||||
sub_val = cloned_sub_val;
|
||||
}
|
||||
|
||||
if (offset >= 0) {
|
||||
sub_val += offset;
|
||||
} else if ((size_t) abs(offset) <= strlen(sub_val)) {
|
||||
sub_val = cloned_sub_val + (strlen(cloned_sub_val) + offset);
|
||||
}
|
||||
|
||||
if (ooffset > 0 && (size_t) ooffset < strlen(sub_val)) {
|
||||
if ((ptr = (char *) sub_val + ooffset)) {
|
||||
*ptr = '\0';
|
||||
if (ooffset > 0 && (size_t) ooffset < strlen(sub_val)) {
|
||||
if ((ptr = (char *) sub_val + ooffset)) {
|
||||
*ptr = '\0';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2232,6 +2244,7 @@ SWITCH_DECLARE(char *) switch_event_expand_headers_check(switch_event_t *event,
|
||||
|
||||
switch_safe_free(func_val);
|
||||
switch_safe_free(cloned_sub_val);
|
||||
switch_safe_free(expanded_sub_val);
|
||||
sub_val = NULL;
|
||||
vname = NULL;
|
||||
vtype = 0;
|
||||
|
||||
Reference in new issue
Block a user