From: Anthony Minessale Date: Wed, 1 Jul 2015 17:54:51 +0000 (-0500) Subject: FS-7750 #resolve X-Git-Tag: v1.4.21~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=39d0797abebc2cddcc6acfa4441329712f1b9519;p=thirdparty%2Ffreeswitch.git FS-7750 #resolve --- diff --git a/src/mod/applications/mod_commands/mod_commands.c b/src/mod/applications/mod_commands/mod_commands.c index 15ceb23ee7..1b5ff683a7 100644 --- a/src/mod/applications/mod_commands/mod_commands.c +++ b/src/mod/applications/mod_commands/mod_commands.c @@ -5430,7 +5430,7 @@ SWITCH_STANDARD_API(uuid_setvar_function) switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); stream->write_function(stream, "-ERR No variable specified\n"); } else { - switch_channel_set_variable(channel, var_name, var_value); + switch_channel_add_variable_var_check(channel, var_name, var_value, SWITCH_FALSE, SWITCH_STACK_BOTTOM); stream->write_function(stream, "+OK\n"); } @@ -5539,7 +5539,24 @@ SWITCH_STANDARD_API(uuid_getvar_function) stream->write_function(stream, "-ERR No variable name specified!\n"); switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(session), SWITCH_LOG_ERROR, "No variable name specified.\n"); } else { - var_value = switch_channel_get_variable(channel, var_name); + if (strchr(var_name, '[')) { + char *ptr = NULL; + int idx = -1; + char *vname = strdup(var_name); + + if ((ptr = strchr(vname, '[')) && strchr(ptr, ']')) { + *ptr++ = '\0'; + idx = atoi(ptr); + var_value = switch_channel_get_variable_dup(channel, vname, SWITCH_TRUE, idx); + } + + free(vname); + } + + if (!var_value) { + var_value = switch_channel_get_variable(channel, var_name); + } + if (var_value != NULL) { stream->write_function(stream, "%s", var_value); } else {