diff --git a/apps/dsm/DSMCoreModule.cpp b/apps/dsm/DSMCoreModule.cpp index c7d38acf..866cad6d 100644 --- a/apps/dsm/DSMCoreModule.cpp +++ b/apps/dsm/DSMCoreModule.cpp @@ -75,6 +75,7 @@ DSMAction* DSMCoreModule::getAction(const string& from_str) { DEF_CMD("set", SCSetAction); DEF_CMD("append", SCAppendAction); + DEF_CMD("inc", SCIncAction); DEF_CMD("log", SCLogAction); DEF_CMD("clear", SCClearAction); DEF_CMD("logVars", SCLogVarsAction); @@ -350,6 +351,17 @@ EXEC_ACTION_START(SCAppendAction) { var_name.c_str(), sc_sess->var[var_name].c_str()); } EXEC_ACTION_END; +EXEC_ACTION_START(SCIncAction) { + string var_name = (arg.length() && arg[0] == '$')? + arg.substr(1) : arg; + unsigned int val = 0; + str2i(sc_sess->var[var_name], val); + sc_sess->var[var_name] = int2str(val+1); + + DBG("inc: $%s now '%s'\n", + var_name.c_str(), sc_sess->var[var_name].c_str()); +} EXEC_ACTION_END; + CONST_ACTION_2P(SCSetTimerAction,',', false); EXEC_ACTION_START(SCSetTimerAction) { diff --git a/apps/dsm/DSMCoreModule.h b/apps/dsm/DSMCoreModule.h index e9eac671..fce60437 100644 --- a/apps/dsm/DSMCoreModule.h +++ b/apps/dsm/DSMCoreModule.h @@ -76,6 +76,7 @@ DEF_SCModSEStrArgAction(SCReturnFSMAction); DEF_ACTION_2P(SCSetAction); DEF_ACTION_2P(SCAppendAction); +DEF_ACTION_1P(SCIncAction); DEF_ACTION_1P(SCClearAction); DEF_ACTION_2P(SCSetTimerAction); DEF_ACTION_2P(SCLogAction); diff --git a/apps/dsm/doc/dsm_syntax.txt b/apps/dsm/doc/dsm_syntax.txt index 6c39e3e3..03385580 100644 --- a/apps/dsm/doc/dsm_syntax.txt +++ b/apps/dsm/doc/dsm_syntax.txt @@ -76,6 +76,7 @@ actions: append($var, value) e.g. append($var, "text"); append($var, #key); append($var, @select); append($var, $var2); + inc($var) clear($var) log(level, text)