X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Ftestclient%2Fmain.cpp;h=f2f2bf3e0a9678338fc8b347b38d6afc853b0006;hb=b9187cc6999276ce37a5c9852655fd558ea76b8e;hp=90158edbec031ac5fb0ef0dc4fefe28d9b27e4eb;hpb=88c5a743d71c6655bfc08c2bd7a82828775cc828;p=deb_libcec.git diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index 90158ed..f2f2bf3 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -31,19 +31,60 @@ */ #include "../../include/CECExports.h" -#include "../lib/util/threads.h" -#include "../lib/util/misc.h" +#include "../lib/platform/threads.h" #include "../lib/util/StdString.h" #include #include #include #include +#include using namespace CEC; using namespace std; #define CEC_TEST_CLIENT_VERSION 3 + +inline bool HexStrToInt(const std::string& data, int& value) +{ + return sscanf(data.c_str(), "%x", &value) == 1; +} + + +//get the first word (separated by whitespace) from string data and place that in word +//then remove that word from string data +bool GetWord(string& data, string& word) +{ + stringstream datastream(data); + string end; + + datastream >> word; + if (datastream.fail()) + { + data.clear(); + return false; + } + + size_t pos = data.find(word) + word.length(); + + if (pos >= data.length()) + { + data.clear(); + return true; + } + + data = data.substr(pos); + + datastream.clear(); + datastream.str(data); + + datastream >> end; + if (datastream.fail()) + data.clear(); + + return true; +} + void flush_log(ICECAdapter *cecParser) { cec_log_message message;