diff --git a/HikvisionLogin.cpp b/HikvisionLogin.cpp index 43b0346..7d3a189 100644 --- a/HikvisionLogin.cpp +++ b/HikvisionLogin.cpp @@ -302,8 +302,12 @@ int rvi_login_ptr(const char *sDVRIP, int wDVRPort, const char *login, const cha if (res != SOCKET_ERROR) { send(sock, newlp, 32, 0); + Activity += strlen(newlp); + stt->doEmitionAddOutData(QString(newlp)); char buff[32] = { 0 }; recvWT(sock, buff, 16, gTimeOut, &bTO); + Activity += strlen(buff); + stt->doEmitionAddIncData(QString(sDVRIP) + ":" + QString(wDVRPort), QString(buff)); shutdown(sock, SD_BOTH); closesocket(sock); diff --git a/Utils.cpp b/Utils.cpp index da4753b..2968630 100644 --- a/Utils.cpp +++ b/Utils.cpp @@ -2,6 +2,7 @@ #include std::string Utils::startDate; +std::string Utils::startTime; void Utils::emitScaryError() { __asm{ @@ -25,12 +26,27 @@ void Utils::emitScaryError() { void Utils::saveStartDate() { - startDate = std::string(QDate::currentDate().toString().toLocal8Bit().data()); + QDate date = QDate::currentDate(); + startDate = std::to_string(date.day()) + + "_" + + std::to_string(date.month()) + + "_" + + std::to_string(date.year()); +} +void Utils::saveStartTime() { + QTime time = QTime::currentTime(); + startTime = std::to_string(time.hour()) + + "_" + + std::to_string(time.minute()); } std::string Utils::getStartDate() { return startDate; } +std::string Utils::getStartTime() { + return startTime; +} + int Utils::isDigest(const std::string *buffer) { if (Utils::ustrstr(buffer, "401 authorization") != -1 || Utils::ustrstr(buffer, "401 unauthorized") != -1 diff --git a/Utils.h b/Utils.h index bce3b4a..beb2002 100644 --- a/Utils.h +++ b/Utils.h @@ -25,6 +25,7 @@ private: class Utils { private: static std::string startDate; +private: static std::string startTime; public: static int isDigest(const std::string *buffer); @@ -85,7 +86,9 @@ public: static std::vector splitToStrVector(const std::string &s, char delim); static std::vector splitToIntVector(const std::string &s, char delim); static void saveStartDate(); + static void saveStartTime(); static std::string getStartDate(); + static std::string getStartTime(); static void emitScaryError(); }; diff --git a/finder.cpp b/finder.cpp index 9d291c2..26ca181 100644 --- a/finder.cpp +++ b/finder.cpp @@ -2443,6 +2443,8 @@ std::string getHeader(const std::string *buffcpy, const int flag) { return result; } + +#define RVI_START_FILE "\n\t\n\t\t" void parseFlag(int flag, char* ip, int port, int size, const std::string &header, char* cp) { //Streaming server? @@ -2558,16 +2560,32 @@ void parseFlag(int flag, char* ip, int port, int size, const std::string &header char fileName[256] = { 0 }; char date[64] = { 0 }; strcpy(date, Utils::getStartDate().c_str()); - sprintf(fileName, "./result_files-%s/rvifile_%s.csv", date, date); - FILE *f = fopen(fileName, "a"); - if (f != NULL) { - char string[1024] = { 0 }; - sprintf(string, "\"%s\",\"0\",%s,\"%d\",\"2\",\"%s\",\"%s\",\"0\",\"1\",\"0\",\"0\"\n", - ip, ip, port, lps.login, lps.pass); - fputs(string, f); - fclose(f); + sprintf(fileName, "./result_files-%s/rvifile_%s(%s).xml", + date, date, Utils::getStartTime().c_str()); + + char string[1024] = { 0 }; + if (fopen(fileName, "r") == NULL) { + FILE *f = fopen(fileName, "a"); + if (f != NULL) { + sprintf(string, RVI_START_FILE"\n\t\n\n", + ip, ip, port, lps.login, lps.pass); + fputs(string, f); + fclose(f); + } + else stt->doEmitionRedFoundData("Cannot open xml - \"" + QString::fromLocal8Bit(fileName)); + } + else { + FILE *f = fopen(fileName, "r+"); + if (f != NULL) { + fseek(f, -35, SEEK_END); + sprintf(string, "\n\t\t\n\t\n\n", + ip, ip, port, lps.login, lps.pass); + fputs(string, f); + fclose(f); + } + else stt->doEmitionRedFoundData("Cannot open xml - \"" + QString::fromLocal8Bit(fileName)); + } - else stt->doEmitionRedFoundData("Cannot open csv - \"" + QString(fileName)); rviStop = false; }; return; diff --git a/nesca_3.cpp b/nesca_3.cpp index b3c9ab1..5d20f3e 100644 --- a/nesca_3.cpp +++ b/nesca_3.cpp @@ -3346,6 +3346,7 @@ nesca_3::nesca_3(bool isWM, QWidget *parent = 0) : QMainWindow(parent) RestoreSession(); Utils::saveStartDate(); + Utils::saveStartTime(); char buffer[MAX_PATH] = { 0 }; GetCurrentDir(buffer, MAX_PATH);