Added headless mode to DTSC analyser, will for example analyse MstConf files now

This commit is contained in:
Thulinma 2018-11-01 21:25:45 +01:00
parent ba34b3b1f7
commit 9a2544cc9b
2 changed files with 17 additions and 0 deletions

View file

@ -4,14 +4,30 @@
void AnalyserDTSC::init(Util::Config &conf){ void AnalyserDTSC::init(Util::Config &conf){
Analyser::init(conf); Analyser::init(conf);
JSON::Value opt;
opt["long"] = "headless";
opt["short"] = "H";
opt["help"] = "Parse entire file or streams as a single headless DTSC packet";
conf.addOption("headless", opt);
opt.null();
} }
AnalyserDTSC::AnalyserDTSC(Util::Config &conf) : Analyser(conf){ AnalyserDTSC::AnalyserDTSC(Util::Config &conf) : Analyser(conf){
conn = Socket::Connection(0, fileno(stdin)); conn = Socket::Connection(0, fileno(stdin));
totalBytes = 0; totalBytes = 0;
headLess = conf.getBool("headless");
} }
bool AnalyserDTSC::parsePacket(){ bool AnalyserDTSC::parsePacket(){
if (headLess){
while (conn){
if (!conn.spool()){Util::sleep(50);}
}
std::string dataBuf = conn.Received().remove(conn.Received().bytes(0xFFFFFFFFul));
DTSC::Scan S((char*)dataBuf.data(), dataBuf.size());
std::cout << S.toPrettyString() << std::endl;
return false;
}
P.reInit(conn); P.reInit(conn);
if (conn && !P){ if (conn && !P){
FAIL_MSG("Invalid DTSC packet @ byte %llu", totalBytes) FAIL_MSG("Invalid DTSC packet @ byte %llu", totalBytes)

View file

@ -8,6 +8,7 @@ public:
static void init(Util::Config &conf); static void init(Util::Config &conf);
private: private:
bool headLess;
DTSC::Packet P; DTSC::Packet P;
Socket::Connection conn; Socket::Connection conn;
uint64_t totalBytes; uint64_t totalBytes;