diff --git a/etlist/etparser.cpp b/etlist/etparser.cpp index 771467f..87caa01 100644 --- a/etlist/etparser.cpp +++ b/etlist/etparser.cpp @@ -34,8 +34,7 @@ ETParser::ETParser(std::vector packets) std::map ::iterator it; for (it = response_variables_.begin(); it != response_variables_.end(); ++it) { - std::cout << std::setw(22) << it->first << ": " << it->second << - std::endl; + std::cout << it->first << ": " << it->second << std::endl; } } @@ -69,8 +68,7 @@ void ETParser::ParseResponse(std::string rsp_to_parse) /* * The following code was adapted from the Wetsi project */ - static int servernr = 1; - int i = rsp_to_parse.find('\\') + 1; // skip to the first item + int i = rsp_to_parse.find('\\') + 1; // skip to the first item if (i >= rsp_to_parse.npos) { @@ -78,12 +76,6 @@ void ETParser::ParseResponse(std::string rsp_to_parse) return; } - struct - { - std::string address; - unsigned short port; - } server; - while (i < rsp_to_parse.npos) { // 'EOT' found, abort successfully @@ -100,21 +92,14 @@ void ETParser::ParseResponse(std::string rsp_to_parse) } // parse out ip - std::stringstream ss; - ss << (int)(unsigned char)rsp_to_parse[i++] << "." - << (int)(unsigned char)rsp_to_parse[i++] << "." - << (int)(unsigned char)rsp_to_parse[i++] << "." - << (int)(unsigned char)rsp_to_parse[i++]; - server.address = ss.str(); + std::stringstream server_addr; + server_addr << (int)(unsigned char)rsp_to_parse[i++] << "." + << (int)(unsigned char)rsp_to_parse[i++] << "." + << (int)(unsigned char)rsp_to_parse[i++] << "." + << (int)(unsigned char)rsp_to_parse[i++] << ":" + << (unsigned short)((rsp_to_parse[i++] << 8) + rsp_to_parse[i++]); - // parse out port - server.port = rsp_to_parse[i++] << 8; - server.port += rsp_to_parse[i++]; - - std::cout << "|" << servernr << "| " - << server.address << ":" << server.port << std::endl; - - servernr++; + add_variable("server", server_addr.str()); // should never happen if (rsp_to_parse[i++] != '\\') diff --git a/etlist/etparser.h b/etlist/etparser.h index cd87feb..7a9f41e 100644 --- a/etlist/etparser.h +++ b/etlist/etparser.h @@ -24,7 +24,6 @@ #include #include #include -#include // using 'setw' #include #include