Remove warnings
[anna.git] / example / diameter / launcher / Launcher.cpp
index 0fcfd52..871fcb3 100644 (file)
@@ -12,7 +12,8 @@
 #include <math.h> // ceil
 #include <climits>
 #include <unistd.h> // chdir
-#include <regex>
+//#include <regex> TODO: use this from gcc4.9.0: http://stackoverflow.com/questions/8060025/is-this-c11-regex-error-me-or-the-compiler
+#include <stdio.h>
 
 // Project
 #include <anna/timex/Engine.hpp>
@@ -613,7 +614,7 @@ void Launcher::run()
 throw(anna::RuntimeException) {
   LOGMETHOD(anna::TraceMethod tm("Launcher", "run", ANNA_FILE_LOCATION));
   CommandLine& cl(anna::CommandLine::instantiate());
-  anna::diameter::stack::Engine &stackEngine = anna::diameter::stack::Engine::instantiate();
+  anna::diameter::stack::Engine::instantiate();
 
   // Start time:
   a_start_time.setNow();
@@ -1271,7 +1272,8 @@ std::string Launcher::help() const throw() {
   result += "\n                                                          source file (xml representation). Fix mode must be enabled to avoid";
   result += "\n                                                          unexpected matching behaviour. If you need a strict matching you";
   result += "\n                                                          must add parameter 'strict', if not, regexp is built ignoring sequence";
-  result += "\n                                                          information (hop-by-hop-id=\"[0-9]+\" end-to-end-id=\"[0-9]+\").";
+  result += "\n                                                          information (hop-by-hop-id=\"[0-9]+\" end-to-end-id=\"[0-9]+\") and";
+  result += "\n                                                          Origin-State-Id value.";
   result += "\n                                                          All LF codes will be internally removed when comparison is executed";
   result += "\n                                                          in order to ease xml content configuration.";
   result += "\n";
@@ -2283,9 +2285,47 @@ void Launcher::eventOperation(const std::string &operation, std::string &respons
 
         // 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;
-          regexp = std::regex_replace (regexp, std::regex(s_from), s_to);
+          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("\"", 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("\"", 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("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]+");
+
           //regexp.insert(0, "^");
           //regexp += "$";
         }