mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-24 05:02:10 +00:00
add scoped channel variables (%[var=val,var2=val2] blocks valid in any app data field and will only last for that one app execution)
This commit is contained in:
@@ -1979,7 +1979,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
|
||||
char *expanded = NULL;
|
||||
const char *app;
|
||||
switch_core_session_message_t msg = { 0 };
|
||||
|
||||
char delim = ',';
|
||||
|
||||
switch_assert(application_interface);
|
||||
|
||||
app = application_interface->interface_name;
|
||||
@@ -1988,6 +1989,30 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
|
||||
expanded = switch_channel_expand_variables(session->channel, arg);
|
||||
}
|
||||
|
||||
if (expanded && *expanded == '%' && (*(expanded+1) == '[' || *(expanded+2) == '[')) {
|
||||
char *p, *dup;
|
||||
switch_event_t *ovars = NULL;
|
||||
|
||||
p = expanded + 1;
|
||||
|
||||
if (*p != '[') {
|
||||
delim = *p;
|
||||
p++;
|
||||
}
|
||||
|
||||
dup = strdup(p);
|
||||
|
||||
if (expanded != arg) {
|
||||
switch_safe_free(expanded);
|
||||
}
|
||||
|
||||
switch_event_create_brackets(dup, '[', ']', delim, &ovars, &expanded, SWITCH_TRUE);
|
||||
free(dup);
|
||||
|
||||
switch_channel_set_scope_variables(session->channel, &ovars);
|
||||
}
|
||||
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG_CLEAN(session), SWITCH_LOG_DEBUG, "EXECUTE %s %s(%s)\n",
|
||||
switch_channel_get_name(session->channel), app, switch_str_nil(expanded));
|
||||
|
||||
@@ -2066,6 +2091,8 @@ SWITCH_DECLARE(switch_status_t) switch_core_session_exec(switch_core_session_t *
|
||||
switch_safe_free(expanded);
|
||||
}
|
||||
|
||||
switch_channel_set_scope_variables(session->channel, NULL);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user