Module: sems Branch: master Commit: 4155f83bec4e70ad75bb21256c0cd987612301e5 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=4155f83bec4e70ad75bb21256c0cd987612301e5
Author: Stefan Sayer <[email protected]> Committer: Stefan Sayer <[email protected]> Date: Mon Jul 12 16:37:38 2010 +0200 DSM: clearArray action --- apps/dsm/DSMCoreModule.cpp | 20 ++++++++++++++++++++ apps/dsm/DSMCoreModule.h | 1 + doc/dsm/dsm_syntax.txt | 2 ++ 3 files changed, 23 insertions(+), 0 deletions(-) diff --git a/apps/dsm/DSMCoreModule.cpp b/apps/dsm/DSMCoreModule.cpp index a5db2a4..20b85f4 100644 --- a/apps/dsm/DSMCoreModule.cpp +++ b/apps/dsm/DSMCoreModule.cpp @@ -84,6 +84,7 @@ DSMAction* DSMCoreModule::getAction(const string& from_str) { DEF_CMD("inc", SCIncAction); DEF_CMD("log", SCLogAction); DEF_CMD("clear", SCClearAction); + DEF_CMD("clearArray", SCClearArrayAction); DEF_CMD("logVars", SCLogVarsAction); DEF_CMD("logParams", SCLogParamsAction); DEF_CMD("logSelects", SCLogSelectsAction); @@ -634,6 +635,25 @@ EXEC_ACTION_START(SCClearAction) { sc_sess->var.erase(var_name); } EXEC_ACTION_END; +EXEC_ACTION_START(SCClearArrayAction) { + string varprefix = (arg.length() && arg[0] == '$')? + arg.substr(1) : arg; + DBG("clear variable array '%s.*'\n", varprefix.c_str()); + + varprefix+="."; + + map<string, string>::iterator lb = sc_sess->var.lower_bound(varprefix); + while (lb != sc_sess->var.end()) { + if ((lb->first.length() < varprefix.length()) || + strncmp(lb->first.c_str(), varprefix.c_str(),varprefix.length())) + break; + map<string, string>::iterator lb_d = lb; + lb++; + sc_sess->var.erase(lb_d); + } + +} EXEC_ACTION_END; + CONST_ACTION_2P(SCAppendAction,',', false); EXEC_ACTION_START(SCAppendAction) { diff --git a/apps/dsm/DSMCoreModule.h b/apps/dsm/DSMCoreModule.h index bd55f08..5a939b7 100644 --- a/apps/dsm/DSMCoreModule.h +++ b/apps/dsm/DSMCoreModule.h @@ -83,6 +83,7 @@ DEF_ACTION_2P(SCAppendAction); DEF_ACTION_2P(SCSubStrAction); DEF_ACTION_1P(SCIncAction); DEF_ACTION_1P(SCClearAction); +DEF_ACTION_1P(SCClearArrayAction); DEF_ACTION_2P(SCSetTimerAction); DEF_ACTION_1P(SCRemoveTimerAction); DEF_ACTION_1P(SCRemoveTimersAction); diff --git a/doc/dsm/dsm_syntax.txt b/doc/dsm/dsm_syntax.txt index d21e0d7..e3ba30a 100644 --- a/doc/dsm/dsm_syntax.txt +++ b/doc/dsm/dsm_syntax.txt @@ -144,6 +144,8 @@ sendDTMFSequence(sequence [, duration_ms]) inc($var) clear($var) + clearArray($var) + clears all var.* variables log(level, text) e.g. log(1, $var1) _______________________________________________ Semsdev mailing list [email protected] http://lists.iptel.org/mailman/listinfo/semsdev
