MCPcopy Create free account
hub / github.com/SIPp/sipp / executeRegExp

Method executeRegExp

src/actions.cpp:464–498  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

462}
463
464int CAction::executeRegExp(const char* P_string, VariableTable *P_callVarTable)
465{
466 regmatch_t pmatch[10];
467 int error;
468 int nbOfMatch = 0;
469 char* result = nullptr ;
470
471 if (!M_regExpSet) {
472 ERROR("Trying to perform regular expression match on action that does not have one!");
473 }
474
475 if (getNbSubVarId() > 9) {
476 ERROR("You can only have nine sub expressions!");
477 }
478
479 memset((void*)pmatch, 0, sizeof(regmatch_t)*10);
480
481 error = regexec(&M_internalRegExp, P_string, 10, pmatch, REGEXEC_PARAMS);
482 if (error == 0) {
483 CCallVariable* L_callVar = P_callVarTable->getVar(getVarId());
484
485 for (int i = 0; i <= getNbSubVarId(); i++) {
486 if (pmatch[i].rm_eo != -1) {
487 setSubString(&result, P_string, pmatch[i].rm_so, pmatch[i].rm_eo);
488 L_callVar->setMatchingValue(result);
489 nbOfMatch++;
490 }
491 if (i == getNbSubVarId()) {
492 break;
493 }
494 L_callVar = P_callVarTable->getVar(getSubVarId(i));
495 }
496 }
497 return(nbOfMatch);
498}
499
500void CAction::setSubString(char** P_target, const char* P_source, int P_start, int P_stop)
501{

Callers 2

TESTFunction · 0.80
executeActionMethod · 0.80

Calls 3

ERRORFunction · 0.85
getVarMethod · 0.80
setMatchingValueMethod · 0.80

Tested by

no test coverage detected