add list support for which vars/api to expand in httapi

This commit is contained in:
Anthony Minessale committed 2012-01-09 12:47:47 -06:00
1 parent 1ee46a3615
commit 755be33022
7 files changed
+270 -44

No files matched your search

+24 -9
View File
@@ -151,6 +151,9 @@ struct switch_channel {
opaque_channel_flag_t opaque_flags;
switch_originator_type_t last_profile_type;
switch_caller_extension_t *queued_extension;
switch_event_t *app_list;
switch_event_t *api_list;
switch_event_t *var_list;
};
@@ -578,6 +581,9 @@ SWITCH_DECLARE(void) switch_channel_uninit(switch_channel_t *channel)
}
switch_mutex_lock(channel->profile_mutex);
switch_event_destroy(&channel->variables);
switch_event_destroy(&channel->api_list);
switch_event_destroy(&channel->var_list);
switch_event_destroy(&channel->app_list);
switch_mutex_unlock(channel->profile_mutex);
}
@@ -3287,7 +3293,7 @@ SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *
memset(c, 0, olen - cpos);\
}} \
SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel, const char *in)
SWITCH_DECLARE(char *) switch_channel_expand_variables_check(switch_channel_t *channel, const char *in, switch_event_t *var_list, switch_event_t *api_list)
{
char *p, *c = NULL;
char *data, *indup, *endof_indup;
@@ -3425,7 +3431,7 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
char *ptr;
int idx = -1;
if ((expanded = switch_channel_expand_variables(channel, (char *) vname)) == vname) {
if ((expanded = switch_channel_expand_variables_check(channel, (char *) vname, var_list, api_list)) == vname) {
expanded = NULL;
} else {
vname = expanded;
@@ -3446,6 +3452,10 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
}
if ((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";
}
if (offset || ooffset) {
cloned_sub_val = strdup(sub_val);
switch_assert(cloned_sub_val);
@@ -3478,24 +3488,29 @@ SWITCH_DECLARE(char *) switch_channel_expand_variables(switch_channel_t *channel
if (stream.data) {
char *expanded_vname = NULL;
if ((expanded_vname = switch_channel_expand_variables(channel, (char *) vname)) == vname) {
if ((expanded_vname = switch_channel_expand_variables_check(channel, (char *) vname, var_list, api_list)) == vname) {
expanded_vname = NULL;
} else {
vname = expanded_vname;
}
if ((expanded = switch_channel_expand_variables(channel, vval)) == vval) {
if ((expanded = switch_channel_expand_variables_check(channel, vval, var_list, api_list)) == vval) {
expanded = NULL;
} else {
vval = expanded;
}
if (switch_api_execute(vname, vval, channel->session, &stream) == SWITCH_STATUS_SUCCESS) {
func_val = stream.data;
sub_val = func_val;
if (api_list && !switch_event_check_permission_list(api_list, vname)) {
func_val = "INVALID";
sub_val = "INVALID";
} else {
free(stream.data);
if (switch_api_execute(vname, vval, channel->session, &stream) == SWITCH_STATUS_SUCCESS) {
func_val = stream.data;
sub_val = func_val;
} else {
free(stream.data);
}
}
switch_safe_free(expanded);