support stacked [] pairs in origiante

This commit is contained in:
Anthony Minessale 2010-06-30 20:09:06 -05:00
parent 09bd04734c
commit 9c7fb0d4ca

View File

@ -2223,7 +2223,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
}
if (cid_name_override) {
if (!cid_tmp) {
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_caller_id_name", cid_name_override);
}
} else {
cid_name_override = switch_event_get_header(var_event, "origination_caller_id_name");
}
@ -2233,7 +2235,9 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
}
if (cid_num_override) {
if (!cid_tmp) {
switch_event_add_header_string(var_event, SWITCH_STACK_BOTTOM, "origination_caller_id_number", cid_num_override);
}
} else {
cid_num_override = switch_event_get_header(var_event, "origination_caller_id_number");
}
@ -2309,7 +2313,7 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
}
if (p == end) {
end = NULL;
end = strchr(p, '[');
}
p++;
@ -2327,8 +2331,10 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
const char *current_variable;
char variable_buffer[512] = "";
switch_event_t *local_var_event = NULL, *originate_var_event = NULL, *event = NULL;
char *check_a = NULL, *check_b = NULL;
end = NULL;
chan_type = peer_names[i];
while (chan_type && *chan_type && *chan_type == ' ') {
@ -2338,6 +2344,16 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
vdata = chan_type;
end = switch_find_end_paren(vdata, '[', ']');
check_a = end;
while (check_a && (check_b = strchr(check_a, '['))) {
if ((check_b = switch_find_end_paren(check_b, '[', ']'))) {
check_a = check_b;
}
}
if (check_a) end = check_a;
if (end) {
vdata++;
*end++ = '\0';
@ -2525,21 +2541,45 @@ SWITCH_DECLARE(switch_status_t) switch_ivr_originate(switch_core_session_t *sess
if (vdata) {
char *var_array[1024] = { 0 };
int var_count = 0;
char *next;
switch_event_create_plain(&local_var_event, SWITCH_EVENT_CHANNEL_DATA);
for (;;) {
if ((next = strchr(vdata, ']'))) {
char *pnext;
*next++ = '\0';
if ((pnext = strchr(next, '['))) {
next = pnext + 1;
}
}
if ((var_count = switch_separate_string(vdata, '|', var_array, (sizeof(var_array) / sizeof(var_array[0]))))) {
int x = 0;
for (x = 0; x < var_count; x++) {
char *inner_var_array[2] = { 0 };
int inner_var_count;
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_DEBUG, "local variable string %d = [%s]\n",
x, var_array[x]);
if ((inner_var_count =
switch_separate_string(var_array[x], '=',
inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0])))) == 2) {
switch_event_add_header_string(local_var_event, SWITCH_STACK_BOTTOM, inner_var_array[0], inner_var_array[1]);
}
}
}
if (next) {
vdata = next;
} else {
break;
}
}
}
/* make a special var event with mixture of the {} and the [] vars to pass down as global vars to the outgoing channel