From: <cha...@us...> - 2007-07-06 20:20:27
|
Revision: 278 http://sipp.svn.sourceforge.net/sipp/?rev=278&view=rev Author: charlespwright Date: 2007-07-06 13:20:24 -0700 (Fri, 06 Jul 2007) Log Message: ----------- Enh: Add strcmp action for string comparison. Modified Paths: -------------- sipp/trunk/actions.cpp sipp/trunk/actions.hpp sipp/trunk/call.cpp sipp/trunk/scenario.cpp Modified: sipp/trunk/actions.cpp =================================================================== --- sipp/trunk/actions.cpp 2007-07-06 17:43:26 UTC (rev 277) +++ sipp/trunk/actions.cpp 2007-07-06 20:20:24 UTC (rev 278) @@ -154,6 +154,7 @@ char* CAction::getCmdLine() { return(M_cmdLine); } CSample* CAction::getDistribution() { return(M_distribution); } double CAction::getDoubleValue() { return(M_doubleValue); } +char* CAction::getStringValue() { return(M_stringValue); } #ifdef PCAPPLAY pcap_pkts * CAction::getPcapPkts() { return(M_pcapArgs); } #endif @@ -186,6 +187,9 @@ void CAction::setDoubleValue (double P_value) { M_doubleValue = P_value; } +/* strcmp specific function. */ +void CAction::setStringValue (char *P_value) +{ M_stringValue = P_value; } void CAction::setSubVarId (int P_value) { if ( M_nbSubVarId < M_maxNbSubVarId ) { @@ -350,6 +354,7 @@ M_cmdLine = NULL; M_IntCmd = E_INTCMD_INVALID; M_doubleValue = 0; + M_stringValue = NULL; M_distribution = NULL; #ifdef PCAPPLAY M_pcapArgs = NULL; @@ -378,6 +383,11 @@ delete [] M_subVarId; M_subVarId = NULL; } + if(M_stringValue != NULL) + { + delete [] M_stringValue; + M_stringValue = NULL; + } #ifdef PCAPPLAY if (M_pcapArgs != NULL) { free(M_pcapArgs); Modified: sipp/trunk/actions.hpp =================================================================== --- sipp/trunk/actions.hpp 2007-07-06 17:43:26 UTC (rev 277) +++ sipp/trunk/actions.hpp 2007-07-06 20:20:24 UTC (rev 278) @@ -50,6 +50,7 @@ E_AT_VAR_DIVIDE, E_AT_VAR_TEST, E_AT_VAR_TO_DOUBLE, + E_AT_VAR_STRCMP, #ifdef PCAPPLAY E_AT_PLAY_PCAP_AUDIO, E_AT_PLAY_PCAP_VIDEO, @@ -125,6 +126,7 @@ void setIntCmd (T_IntCmdType P_type ); /* exec specific function */ void setDistribution (CSample * P_value); /* sample specific function */ void setDoubleValue (double P_value); /* assign value specific function */ + void setStringValue (char * P_value); /* strcmp value specific function */ #ifdef PCAPPLAY void setPcapArgs (char * P_value); /* send_packets specific function */ void setPcapArgs (pcap_pkts * P_value); /* send_packets specific function */ @@ -137,6 +139,7 @@ int* getSubVarId() ; CSample *getDistribution (); /* sample specific function */ double getDoubleValue (); /* assign value specific function */ + char * getStringValue (); /* strcmp specific function */ CAction(); ~CAction(); @@ -165,6 +168,8 @@ CSample *M_distribution; /* assign value specific member. */ double M_doubleValue; + /* strcmp specific member. */ + char * M_stringValue; #ifdef PCAPPLAY /* pcap specific member */ pcap_pkts * M_pcapArgs; Modified: sipp/trunk/call.cpp =================================================================== --- sipp/trunk/call.cpp 2007-07-06 17:43:26 UTC (rev 277) +++ sipp/trunk/call.cpp 2007-07-06 20:20:24 UTC (rev 278) @@ -3138,6 +3138,11 @@ } else if (currentAction->getActionType() == CAction::E_AT_VAR_TEST) { double value = currentAction->compare(M_callVariableTable); M_callVariableTable[currentAction->getVarId()]->setBool(value); + } else if (currentAction->getActionType() == CAction::E_AT_VAR_STRCMP) { + char *rhs = M_callVariableTable[currentAction->getVarInId()]->getString(); + char *lhs = currentAction->getStringValue(); + int value = strcmp(rhs, lhs); + M_callVariableTable[currentAction->getVarId()]->setDouble((double)value); } else if (currentAction->getActionType() == CAction::E_AT_VAR_TO_DOUBLE) { double value; Modified: sipp/trunk/scenario.cpp =================================================================== --- sipp/trunk/scenario.cpp 2007-07-06 17:43:26 UTC (rev 277) +++ sipp/trunk/scenario.cpp 2007-07-06 20:20:24 UTC (rev 278) @@ -220,6 +220,16 @@ return ret; } +char * xp_get_string(const char *name, const char *what) { + char *ptr; + + if (!(ptr = xp_get_value(name))) { + ERROR_P2("%s is missing the required '%s' parameter.", what, name); + } + + return strdup(ptr); +} + double xp_get_double(const char *name, const char *what) { char *ptr; char *helptext; @@ -1400,6 +1410,11 @@ } else { ERROR_P1("Invalid 'compare' parameter: %s", ptr); } + } else if(!strcmp(actionElem, "strcmp")) { + tmpAction->setVarId(xp_get_var("assign_to", "strcmp")); + tmpAction->setVarInId(xp_get_var("variable", "test")); + tmpAction->setStringValue(xp_get_string("value", "test")); + tmpAction->setActionType(CAction::E_AT_VAR_STRCMP); } else if(!strcmp(actionElem, "exec")) { if(ptr = xp_get_value((char *)"command")) { tmpAction->setActionType(CAction::E_AT_EXECUTE_CMD); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |