| 5612 | } |
| 5613 | |
| 5614 | call::T_ActionResult call::executeAction(const char* msg, message* curmsg) |
| 5615 | { |
| 5616 | CActions* actions; |
| 5617 | CAction* currentAction; |
| 5618 | int rc = 0; |
| 5619 | |
| 5620 | actions = curmsg->M_actions; |
| 5621 | // looking for action to do on this message |
| 5622 | if (actions == nullptr) { |
| 5623 | return(call::E_AR_NO_ERROR); |
| 5624 | } |
| 5625 | |
| 5626 | for (int i = 0; i < actions->getActionSize(); i++) { |
| 5627 | currentAction = actions->getAction(i); |
| 5628 | if(currentAction == nullptr) { |
| 5629 | continue; |
| 5630 | } |
| 5631 | |
| 5632 | if(currentAction->getActionType() == CAction::E_AT_ASSIGN_FROM_REGEXP) { |
| 5633 | char msgPart[MAX_SUB_MESSAGE_LENGTH]; |
| 5634 | |
| 5635 | /* Where to look. */ |
| 5636 | const char* haystack = nullptr; |
| 5637 | |
| 5638 | if(currentAction->getLookingPlace() == CAction::E_LP_HDR) { |
| 5639 | extractSubMessage (msg, |
| 5640 | currentAction->getLookingChar(), |
| 5641 | msgPart, |
| 5642 | currentAction->getCaseIndep(), |
| 5643 | currentAction->getOccurrence(), |
| 5644 | currentAction->getHeadersOnly()); |
| 5645 | if(currentAction->getCheckIt() == true && (strlen(msgPart) == 0)) { |
| 5646 | // the sub message is not found and the checking action say it |
| 5647 | // MUST match --> Call will be marked as failed but will go on |
| 5648 | WARNING("Failed regexp match: header %s not found in message\n%s\n", currentAction->getLookingChar(), msg); |
| 5649 | return(call::E_AR_HDR_NOT_FOUND); |
| 5650 | } |
| 5651 | haystack = msgPart; |
| 5652 | } else if(currentAction->getLookingPlace() == CAction::E_LP_BODY) { |
| 5653 | haystack = strstr(msg, "\r\n\r\n"); |
| 5654 | if (!haystack) { |
| 5655 | if (currentAction->getCheckIt() == true) { |
| 5656 | WARNING("Failed regexp match: body not found in message\n%s\n", msg); |
| 5657 | return(call::E_AR_HDR_NOT_FOUND); |
| 5658 | } |
| 5659 | msgPart[0] = '\0'; |
| 5660 | haystack = msgPart; |
| 5661 | } |
| 5662 | haystack += strlen("\r\n\r\n"); |
| 5663 | } else if(currentAction->getLookingPlace() == CAction::E_LP_MSG) { |
| 5664 | haystack = msg; |
| 5665 | } else if(currentAction->getLookingPlace() == CAction::E_LP_VAR) { |
| 5666 | /* Get the input variable. */ |
| 5667 | haystack = M_callVariableTable->getVar(currentAction->getVarInId())->getString(); |
| 5668 | if (!haystack) { |
| 5669 | if (currentAction->getCheckIt() == true) { |
| 5670 | WARNING("Failed regexp match: variable $%d not set", currentAction->getVarInId()); |
| 5671 | return(call::E_AR_HDR_NOT_FOUND); |
nothing calls this directly
no test coverage detected