mirror of
https://github.com/ChronosX88/nesca.git
synced 2024-12-24 00:31:46 +00:00
RVI import-list generator.
This commit is contained in:
parent
d39de296e7
commit
6827862988
@ -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);
|
||||
|
18
Utils.cpp
18
Utils.cpp
@ -2,6 +2,7 @@
|
||||
#include <sstream>
|
||||
|
||||
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
|
||||
|
3
Utils.h
3
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<std::string> splitToStrVector(const std::string &s, char delim);
|
||||
static std::vector<int> splitToIntVector(const std::string &s, char delim);
|
||||
static void saveStartDate();
|
||||
static void saveStartTime();
|
||||
static std::string getStartDate();
|
||||
static std::string getStartTime();
|
||||
static void emitScaryError();
|
||||
};
|
||||
|
||||
|
36
finder.cpp
36
finder.cpp
@ -2443,6 +2443,8 @@ std::string getHeader(const std::string *buffcpy, const int flag) {
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
#define RVI_START_FILE "<Organization>\n\t<Department name=\"root\">\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"<Device title=\"%s\" ip=\"%s\" port=\"%d\" user=\"%s\" password=\"%s\"/>\n\t</Department>\n</Organization>\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<Device title=\"%s\" ip=\"%s\" port=\"%d\" user=\"%s\" password=\"%s\"/>\n\t</Department>\n</Organization>\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;
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user