From d23b74e66a779a3135e2eb59e28a48f1f4aa1ce2 Mon Sep 17 00:00:00 2001 From: Anthony Minessale Date: Mon, 6 Aug 2012 23:50:39 -0500 Subject: [PATCH] FS-4352 --resolve alternate implementation as multiset to avoid regressions on set --- .../applications/mod_dptools/mod_dptools.c | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/mod/applications/mod_dptools/mod_dptools.c b/src/mod/applications/mod_dptools/mod_dptools.c index 5ca719e8d2..92eba0f568 100755 --- a/src/mod/applications/mod_dptools/mod_dptools.c +++ b/src/mod/applications/mod_dptools/mod_dptools.c @@ -1326,6 +1326,33 @@ static void base_set (switch_core_session_t *session, const char *data, switch_s } } +SWITCH_STANDARD_APP(multiset_function) +{ + char delim = ' '; + char *arg = (char *) data; + + if (!zstr(arg) && *arg == '^' && *(arg+1) == '^') { + arg += 2; + delim = *arg++; + } + + if (arg) { + char *array[256] = {0}; + int i, argc; + + arg = switch_core_session_strdup(session, arg); + argc = switch_split(arg, delim, array); + + for(i = 0; i < argc; i++) { + base_set(session, array[i], SWITCH_STACK_BOTTOM); + } + + + } else { + base_set(session, data, SWITCH_STACK_BOTTOM); + } +} + SWITCH_STANDARD_APP(set_function) { base_set(session, data, SWITCH_STACK_BOTTOM); @@ -4672,6 +4699,9 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_dptools_load) SWITCH_ADD_APP(app_interface, "set", "Set a channel variable", SET_LONG_DESC, set_function, "=", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC); + SWITCH_ADD_APP(app_interface, "multiset", "Set many channel variables", SET_LONG_DESC, multiset_function, "[^^]= =", + SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC); + SWITCH_ADD_APP(app_interface, "push", "Set a channel variable", SET_LONG_DESC, push_function, "=", SAF_SUPPORT_NOMEDIA | SAF_ROUTING_EXEC | SAF_ZOMBIE_EXEC);