local_clobber true|false (default false)
whether or not to allow (per-leg) local variables inside [] to take precedence over originate global variables in {}
{foo=value1,local_clobber=false}sofia/internal/100@test.com,[foo=value2]sofia/internal/101@test.com
foo will be value1 on both legs
{foo=value1,local_clobber=true}sofia/internal/100@test.com,[foo=value2]sofia/internal/101@test.com
foo will be value1 on all legs except the 101 who set it to value2
Hi,
Would somebody enlighten me on this trunk of code in the mentioned file at line 2273:
if (local_clobber) {
if (var_event) {
switch_event_t *event;
switch_event_header_t *header;
/* install the vars from the {} params */
for (header = var_event->headers; header; header = header->next) {
switch_channel_set_variable(originate_status[i].peer_channel, header->name, header->value);
}
switch_event_create(&event, SWITCH_EVENT_CHANNEL_ORIGINATE);
switch_assert(event);
switch_channel_event_set_data(originate_status[i].peer_channel, event);
switch_event_fire(&event);
}
}
if (vdata) {
char *var_array[1024] = { 0 };
int var_count = 0;
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;
if ((inner_var_count =
switch_separate_string(var_array[x], '=',
inner_var_array, (sizeof(inner_var_array) / sizeof(inner_var_array[0])))) == 2) {
switch_channel_set_variable(originate_status[i].peer_channel, inner_var_array[0], inner_var_array[1]);
}
}
}
}
if (!local_clobber) {
if (var_event) {
switch_event_t *event;
switch_event_header_t *header;
/* install the vars from the {} params */
for (header = var_event->headers; header; header = header->next) {
switch_channel_set_variable(originate_status[i].peer_channel, header->name, header->value);
}
switch_event_create(&event, SWITCH_EVENT_CHANNEL_ORIGINATE);
switch_assert(event);
switch_channel_event_set_data(originate_status[i].peer_channel, event);
switch_event_fire(&event);
}
}
The code block inside if (local_clobber) and if (!local_clobber) does exactly the same thing. May I know is it by design and how does it actually work ? I am not sure what does it mean by localClobber so if someone can spare sometime explaining, I would really appreciate it.
Thank you
Best Regards
Alex To
_______________________________________________
FreeSWITCH-dev mailing list
FreeSWITCH-dev@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-dev
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-dev
http://www.freeswitch.org