X-Git-Url: https://git.teslayout.com/public/public/public/?p=anna.git;a=blobdiff_plain;f=example%2Fdiameter%2Flauncher%2FLauncher.cpp;h=60a9cb0cfb7a0fec3dcc13f668d50713fc9af26c;hp=bb28699ec9bf76837e9048055dd8c867830ecc3c;hb=415985b3f67878c2e3cee785a0b1cb36f4eff901;hpb=227446df961ead723c8f2b04ea53d99c770a438f diff --git a/example/diameter/launcher/Launcher.cpp b/example/diameter/launcher/Launcher.cpp index bb28699..60a9cb0 100644 --- a/example/diameter/launcher/Launcher.cpp +++ b/example/diameter/launcher/Launcher.cpp @@ -833,21 +833,6 @@ bool Launcher::getDataBlockFromHexFile(const std::string &pathfile, anna::DataBl return false; } -bool Launcher::getContentFromFile(const std::string &pathfile, std::string &content) const throw(anna::RuntimeException) { - - std::ifstream inFile(pathfile.c_str(), std::ifstream::in); - if(!inFile.good()) { - throw RuntimeException(anna::functions::asString("Unable to open file '%s'", pathfile.c_str()), ANNA_FILE_LOCATION); - } - - std::stringstream strStream; - strStream << inFile.rdbuf(); //read the file - content = strStream.str(); // holds the content of the file - inFile.close(); - - return true; -} - void Launcher::resetStatistics() throw() { if (a_workingNode) { a_workingNode->getCommEngine()->resetStatistics(); @@ -1777,49 +1762,42 @@ bool Launcher::eventOperation(const std::string &operation, std::string &respons throw anna::RuntimeException("Wrong body content format on HTTP Request. Check 'HELP.md' for more information.", ANNA_FILE_LOCATION); if(param3 == "") throw anna::RuntimeException(anna::functions::asString("Missing xml file for '%s' command in test id operation", param2.c_str()), ANNA_FILE_LOCATION); - // Get xml content from file: - std::string regexp; - if(!getContentFromFile(param3, regexp)) - throw anna::RuntimeException("Error reading xml content from file provided", ANNA_FILE_LOCATION); + codecMsg.loadXMLFile(param3); + std::string regexp = codecMsg.asXMLString(true /* normalization */); + + // Now we must insert regular expressions in hop-by-hop, end-to-end and Origin-State-Id: // optional 'full': if(param4 != "strict") { - - // TODO: use this from gcc4.9.0: http://stackoverflow.com/questions/8060025/is-this-c11-regex-error-me-or-the-compiler -/* - std::string s_from = "hop-by-hop-id=\"[0-9]+\" end-to-end-id=\"[0-9]+\""; - std::string s_to = s_from; - std::string s_from2 = "avp name=\"Origin-State-Id\" data=\"[0-9]+\""; - std::string s_to2 = s_from2; - - try { - regexp = std::regex_replace (regexp, std::regex(s_from), s_to); - regexp = std::regex_replace (regexp, std::regex(s_from2), s_to2); - } - catch (const std::regex_error& e) { - throw anna::RuntimeException(e.what(), ANNA_FILE_LOCATION); - } - -*/ std::string::size_type pos, pos_1, pos_2; - pos = regexp.find("hop-by-hop-id=", 0u); + pos = regexp.find("end-to-end-id=", 0u); pos = regexp.find("\"", pos); pos_1 = pos; pos = regexp.find("\"", pos+1); pos_2 = pos; regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+"); - pos = regexp.find("end-to-end-id=", 0u); + pos = regexp.find("hop-by-hop-id=", 0u); pos = regexp.find("\"", pos); pos_1 = pos; pos = regexp.find("\"", pos+1); pos_2 = pos; regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+"); + // For this representation: + //pos = regexp.find("Origin-State-Id", 0u); + //pos = regexp.find("\"", pos); + //pos = regexp.find("\"", pos+1); + //pos_1 = pos; + //pos = regexp.find("\"", pos+1); + //pos_2 = pos; + //regexp.replace(pos_1 + 1, pos_2 - pos_1 - 1, "[0-9]+"); + // But we have this one: pos = regexp.find("Origin-State-Id", 0u); - pos = regexp.find("\"", pos); - pos = regexp.find("\"", pos+1); + pos = regexp.rfind("\"", pos); + pos = regexp.rfind("\"", pos-1); + pos = regexp.rfind("\"", pos-1); pos_1 = pos; pos = regexp.find("\"", pos+1); pos_2 = pos;