git repos / oastat

commit c7f56721

sago007 · 2019-03-23 11:42
c7f567215bca9342575d080c4286613f44f8fd76 patch · browse files
parent c817f17fbe97231afe894dc15b803c5d088161a7

Move source code around to allow multiple binaries

Changed files

A .vscode/settings.json
M CMakeLists.txt before
M README.md before
A src/common/common.cpp
A src/common/local.h
A src/common/oastatstruct.cpp
A src/common/oastatstruct.h
M src/db/database.hpp before
D src/local.h before
D src/mxe-build.sh before
M src/oastat.cpp before
D src/oastatstruct.cpp before
D src/oastatstruct.h before
M src/oss2db/Accuracy2Db.hpp before
M src/oss2db/Award2Db.h before
M src/oss2db/Challenge2Db.hpp before
M src/oss2db/Ctf1f2Db.hpp before
M src/oss2db/Ctf2Db.hpp before
M src/oss2db/CtfElimination2Db.hpp before
M src/oss2db/Disconnect2Db.h before
M src/oss2db/Elimination2Db.hpp before
M src/oss2db/Harvester2Db.hpp before
M src/oss2db/Point2Db.hpp before
M src/oss2db/Warmup2Db.hpp before
M src/oss2db/init2db.h before
M src/oss2db/kill2db.h before
M src/oss2db/shutdown2db.h before
M src/oss2db/struct2db.h before
M src/oss2db/userinfo2db.h before
diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c87d914 --- /dev/null +++ b/.vscode/settings.json
@@ -0,0 +1,11 @@
+{
+ "editor.insertSpaces": false,
+ "files.exclude": {
+ "**/*.db3": true,
+ "**/*.o": true,
+ "**/*~": true,
+ "*/*.tgz": true,
+ "Makefile": true,
+ "nbproject": true
+ }
+}
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt index a029055..2de5ab4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -4,8 +4,12 @@ find_package(Boost COMPONENTS program_options REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -std=c++11 -DUSECPPDB=1")
-file(GLOB SOURCES "src/*.cpp" "src/*/*.cpp")
+file(GLOB SOURCES "src/*/*.cpp")
-add_executable(oastat ${SOURCES})
+add_executable(oastat src/oastat.cpp ${SOURCES})
TARGET_LINK_LIBRARIES( oastat ${Boost_LIBRARIES} )
target_link_libraries( oastat cppdb gcrypt gpg-error)
+
+add_executable(oastat_delete_games src/oastat_delete_games.cpp ${SOURCES})
+TARGET_LINK_LIBRARIES( oastat_delete_games ${Boost_LIBRARIES} )
+target_link_libraries( oastat_delete_games cppdb gcrypt gpg-error)
\ No newline at end of file
diff --git a/README.md b/README.md index 992ef87..e9ea7fc 100644 --- a/README.md +++ b/README.md
@@ -12,7 +12,7 @@ Homepage: <https://github.com/sago007/oastat/>
* libgcrypt
* boost_program_options
-On Ubuntu (15.04 or later) all requirements can be installed with: sudo apt-get install build-essential libboost-program-options-dev libcppdb-dev libgcrypt20-dev cmake
+On Ubuntu (16.04 or later) all requirements can be installed with: sudo apt-get install build-essential libboost-program-options-dev libcppdb-dev libgcrypt20-dev cmake
On earlier versions CppDb must be installed manually.
To compile:
diff --git a/src/common/common.cpp b/src/common/common.cpp new file mode 100644 index 0000000..c5127d1 --- /dev/null +++ b/src/common/common.cpp
@@ -0,0 +1,53 @@
+/*
+===========================================================================
+oastat - a program for parsing log files and write the result to a database
+Copyright (C) 2012 Poul Sander
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see http://www.gnu.org/licenses/
+
+Source information and contacts persons can be found at
+https://github.com/sago007/oastat/
+===========================================================================
+*/
+
+#include <string>
+#include <vector>
+#include <gcrypt.h>
+
+std::vector<std::string> clientIdMap;
+
+/**
+ * Hashes the user id so they cannot be recovered from the db.
+ *
+ * @param unhashedID - The unhashed id
+ * @return the hashed id
+ */
+std::string getHashedId(const std::string& unhashedID)
+{
+ int msg_len = unhashedID.length();
+ int hash_len = gcry_md_get_algo_dlen( GCRY_MD_SHA1 );
+ std::vector<unsigned char> hash_binary(hash_len);
+ std::vector<char> hash_hex(hash_len*2+1);
+ char *out = &hash_hex.at(0);
+ char *p = out;
+
+ gcry_md_hash_buffer( GCRY_MD_SHA1, &hash_binary[0], unhashedID.c_str(), msg_len );
+ for ( int i = 0; i < hash_len; i++, p += 2 ) {
+ snprintf ( p, 3, "%02x", hash_binary[i] );
+ }
+
+ std::string hashedID = &hash_hex.at(0);
+
+ return hashedID; //Replace with md5 at some point
+}
\ No newline at end of file
diff --git a/src/common/local.h b/src/common/local.h new file mode 100644 index 0000000..4a915ac --- /dev/null +++ b/src/common/local.h
@@ -0,0 +1,38 @@
+/*
+===========================================================================
+oastat - a program for parsing log files and write the result to a database
+Copyright (C) 2012 Poul Sander
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see http://www.gnu.org/licenses/
+
+Source information and contacts persons can be found at
+https://github.com/sago007/oastat/
+===========================================================================
+*/
+
+#ifndef _LOCAL_H
+#define _LOCAL_H
+
+#define MAX_ID 128
+
+#include "oastatstruct.h"
+
+/* This array contains all the guid hashes of the players in a game */
+extern std::vector<std::string> clientIdMap;
+
+/* returns the SHA-1 code of the parameter */
+std::string getHashedId(const std::string& unhashedID);
+
+#endif /* _LOCAL_H */
+
diff --git a/src/common/oastatstruct.cpp b/src/common/oastatstruct.cpp new file mode 100644 index 0000000..c835816 --- /dev/null +++ b/src/common/oastatstruct.cpp
@@ -0,0 +1,169 @@
+/*
+===========================================================================
+oastat - a program for parsing log files and write the result to a database
+Copyright (C) 2012 Poul Sander
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see http://www.gnu.org/licenses/
+
+Source information and contacts persons can be found at
+https://github.com/sago007/oastat/
+===========================================================================
+*/
+
+#include "oastatstruct.h"
+#include <stdlib.h>
+#include <sstream>
+#include <iostream>
+#include <iomanip>
+
+static void makeLower(std::string &x)
+{
+ for (size_t i=0; i<x.length(); ++i) {
+ if (x[i] >= 'A' && x[i] <= 'X') {
+ x[i] = x[i]-'A'+'a';
+ }
+ }
+}
+
+
+void OaStatStruct::clear()
+{
+ second=0;
+ command = "";
+ parameters.clear();
+ restOfLine = "";
+}
+
+void OaStatStruct::parseLine(const std::string& orgLine)
+{
+ //Parse time
+ std::string tempTimeString = orgLine.substr(0,7);
+ int posColon = tempTimeString.find(":");
+ int minute = atoi(tempTimeString.substr(0,posColon).c_str());
+ second = atoi(tempTimeString.substr(posColon+1,7).c_str());
+ second+=minute*60;
+ std::string line = orgLine.substr(7, orgLine.length()); //Cut the first part of the string.
+
+ //Parse command name:
+ posColon = line.find(":");
+ command = line.substr(0,posColon);
+ try {
+ line = line.substr(posColon+2,line.length()); //Also remove the colon and the first space after it (+2)
+
+ posColon = line.find_first_not_of(" -0123456789"); //First non-number or space
+ std::stringstream ss;
+ ss << line.substr(0,posColon);
+ int counter = 0; //to ensure that we don't go on forever
+ while (ss && counter++<10) {
+ int value;
+ ss >> value;
+ parameters.push_back(value);
+ }
+
+
+ if (line.at(posColon) == ':') {
+ posColon++; //There is some inconsistensy about then there is a colon here
+ if(line.at(posColon) == ' ') {
+ posColon++; //If there is a colon there is likely a space
+ }
+ }
+ line = line.substr(posColon,line.length());
+ } catch (std::exception &e) {
+ //The last part does not always exist... ignore it
+ restOfLine = "";
+ return;
+ }
+
+
+ restOfLine = line;
+}
+
+
+std::map<std::string,std::string> OaStatStruct::GetInfostring(const std::string& restOfLine) const
+{
+ std::map<std::string,std::string> list;
+ size_t lastPos = 0;
+ bool iskey = true;
+ std::string key;
+ if (restOfLine[0] == '\\') {
+ lastPos++;
+ }
+ while (lastPos<restOfLine.length()) {
+ int curPos = restOfLine.find_first_of("\\", lastPos);
+ if (curPos<0) {
+ curPos = restOfLine.length();
+ }
+ if (iskey) {
+ key = restOfLine.substr(lastPos,curPos-lastPos);
+ } else {
+ const std::string& value = restOfLine.substr(lastPos,curPos-lastPos);
+ makeLower(key);
+ if (key.length()>0) {
+ list[key] = value;
+ }
+ }
+ iskey = !iskey;
+ lastPos = curPos+1;
+ }
+ return list;
+}
+
+std::map<std::string,std::string> OaStatStruct::GetInfostring() const
+{
+ return GetInfostring(restOfLine);
+}
+
+const tm OaStatStruct::getDateTime() const
+{
+ return _datetime;
+}
+
+std::string ZeroPadNumber(int num, int size = 2)
+{
+ std::ostringstream ss;
+ ss.clear();
+ ss << std::setw( size ) << std::setfill( '0' ) << num;
+ return ss.str();
+}
+
+std::string OaStatStruct::getTimeStamp() const
+{
+ std::string s = "TIMESTAMP \'" + ZeroPadNumber(_datetime.tm_year+1900,4) + "-" + ZeroPadNumber(_datetime.tm_mon+1) + "-"
+ + ZeroPadNumber(_datetime.tm_mday) + " " + ZeroPadNumber(_datetime.tm_hour) + ":"
+ + ZeroPadNumber(_datetime.tm_min) + ":" + ZeroPadNumber(_datetime.tm_sec) + "\'";
+ return s;
+}
+
+void OaStatStruct::setTimeStamp(const std::string &timestring)
+{
+ if (timestring.empty()) {
+ std::time_t t = std::time(0);
+ _datetime = *std::gmtime(&t);
+ return;
+ }
+ std::stringstream ss(timestring);
+ std::string tmp;
+ getline(ss,tmp,'-');
+ _datetime.tm_year = atoi(tmp.c_str())-1900;
+ getline(ss,tmp,'-');
+ _datetime.tm_mon = atoi(tmp.c_str())-1;
+ getline(ss,tmp,' ');
+ _datetime.tm_mday = atoi(tmp.c_str());
+ getline(ss,tmp,':');
+ _datetime.tm_hour = atoi(tmp.c_str());
+ getline(ss,tmp,':');
+ _datetime.tm_min = atoi(tmp.c_str());
+ getline(ss,tmp);
+ _datetime.tm_sec = atoi(tmp.c_str());
+}
diff --git a/src/common/oastatstruct.h b/src/common/oastatstruct.h new file mode 100644 index 0000000..758b5fe --- /dev/null +++ b/src/common/oastatstruct.h
@@ -0,0 +1,83 @@
+/*
+===========================================================================
+oastat - a program for parsing log files and write the result to a database
+Copyright (C) 2012 Poul Sander
+
+This program is free software: you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation, either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program. If not, see http://www.gnu.org/licenses/
+
+Source information and contacts persons can be found at
+https://github.com/sago007/oastat/
+===========================================================================
+*/
+
+#ifndef _OASTATSTRUCT_H
+#define _OASTATSTRUCT_H
+
+#include <vector>
+#include <string>
+#include <map>
+#include <time.h>
+
+
+/*
+ * This is the most important class in oastat. This takes a line and stores all
+ * information from that line in easy to process parts.
+ */
+class OaStatStruct
+{
+public:
+ OaStatStruct() = default;
+ OaStatStruct(const OaStatStruct& orig) = default;
+ virtual ~OaStatStruct() = default;
+
+ OaStatStruct& operator=(const OaStatStruct& orig) = default;
+
+ //There are no reason to make any variables private.
+ int second = 0; //number of seconds
+ std::string command; //Like 'ClientConnect', 'Award' and 'Kill'
+ std::vector<int> parameters; //The parameters for the command.
+ std::string restOfLine;
+ const tm getDateTime() const;
+
+ void parseLine(const std::string& line);
+ void clear();
+
+ /*
+ *Parses the rest of the line to an info string
+ */
+ std::map<std::string,std::string> GetInfostring(const std::string& restOfLine) const;
+
+ /*
+ *Same but uses this.restOfLine
+ */
+ std::map<std::string,std::string> GetInfostring() const;
+
+ /*
+ Returns a string with the time in the format:
+ * TIMESTAMP 'YYYY-MM-
+ */
+ std::string getTimeStamp() const;
+
+ /*
+ Sets _datetime. Requires input in the format: "YYYY-MM-DD HH:MM:SS"
+ * If input is blank the timestamp will be set to current UTC time.
+ * For any other input the behavior is unspecified.
+ */
+ void setTimeStamp(const std::string &timestring);
+private:
+ tm _datetime = {};
+};
+
+#endif /* _OASTATSTRUCT_H */
+
diff --git a/src/db/database.hpp b/src/db/database.hpp index 7b2b7f4..ee8f8d2 100644 --- a/src/db/database.hpp +++ b/src/db/database.hpp
@@ -26,7 +26,7 @@ https://github.com/sago007/oastat/
#include <string>
#include <iostream>
-#include "../oastatstruct.h"
+#include "../common/oastatstruct.h"
/*
This is the class that all database connections need to inherit to be able to recieve data from the program
diff --git a/src/local.h b/src/local.h deleted file mode 100644 index 4a915ac..0000000 --- a/src/local.h +++ /dev/null
@@ -1,38 +0,0 @@
-/*
-===========================================================================
-oastat - a program for parsing log files and write the result to a database
-Copyright (C) 2012 Poul Sander
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/
-
-Source information and contacts persons can be found at
-https://github.com/sago007/oastat/
-===========================================================================
-*/
-
-#ifndef _LOCAL_H
-#define _LOCAL_H
-
-#define MAX_ID 128
-
-#include "oastatstruct.h"
-
-/* This array contains all the guid hashes of the players in a game */
-extern std::vector<std::string> clientIdMap;
-
-/* returns the SHA-1 code of the parameter */
-std::string getHashedId(const std::string& unhashedID);
-
-#endif /* _LOCAL_H */
-
diff --git a/src/mxe-build.sh b/src/mxe-build.sh deleted file mode 100755 index a76dd0b..0000000 --- a/src/mxe-build.sh +++ /dev/null
@@ -1,2 +0,0 @@
-#! /bin/bash
-make USEDBIXX=0 CROSS=i686-pc-mingw32- PROGRAMNAME=oastat.exe
diff --git a/src/oastat.cpp b/src/oastat.cpp index 1b974f8..45275b1 100644 --- a/src/oastat.cpp +++ b/src/oastat.cpp
@@ -26,22 +26,18 @@ https://github.com/sago007/oastat/
#include <iostream>
#include <fstream>
#include <vector>
-#include <gcrypt.h>
#include <stdio.h>
#include <deque>
#include <boost/format.hpp>
#include <boost/program_options.hpp>
#include "db/database.hpp"
-#ifdef USECPPDB
#include "db/Db2CppDb.hpp"
-#endif
-
#include "db/Db2Xml.hpp"
-#include "oastatstruct.h"
+#include "common/oastatstruct.h"
#include "oss2db/struct2db.h"
-#include "local.h"
+#include "common/local.h"
#include "oss2db/kill2db.h"
#include "oss2db/init2db.h"
#include "oss2db/shutdown2db.h"
@@ -58,7 +54,7 @@ https://github.com/sago007/oastat/
#include "oss2db/Challenge2Db.hpp"
#include "oss2db/Warmup2Db.hpp"
-std::vector<std::string> clientIdMap;
+
static int processStdIn(std::istream &in_p,std::vector<std::shared_ptr<Struct2Db> > &commands);
@@ -151,30 +147,6 @@ static int processStdIn(std::istream &in_p, std::vector<std::shared_ptr<Struct2D
return 0;
}
-/**
- * Hashes the user id so they cannot be recovered from the db.
- *
- * @param unhashedID - The unhashed id
- * @return the hashed id
- */
-std::string getHashedId(const std::string& unhashedID)
-{
- int msg_len = unhashedID.length();
- int hash_len = gcry_md_get_algo_dlen( GCRY_MD_SHA1 );
- std::vector<unsigned char> hash_binary(hash_len);
- std::vector<char> hash_hex(hash_len*2+1);
- char *out = &hash_hex.at(0);
- char *p = out;
-
- gcry_md_hash_buffer( GCRY_MD_SHA1, &hash_binary[0], unhashedID.c_str(), msg_len );
- for ( int i = 0; i < hash_len; i++, p += 2 ) {
- snprintf ( p, 3, "%02x", hash_binary[i] );
- }
-
- std::string hashedID = &hash_hex.at(0);
-
- return hashedID; //Replace with md5 at some point
-}
int main (int argc, const char* argv[])
{
@@ -237,7 +209,6 @@ int main (int argc, const char* argv[])
}
std::shared_ptr<Database> db;
-#if USECPPDB
if (backend == "CppDb") {
std::cout << "Using CppDb\n";
if (dbargs.length()<1) {
@@ -246,7 +217,6 @@ int main (int argc, const char* argv[])
db = std::shared_ptr<Database>(new Db2CppDb(dbargs) );
}
}
-#endif
if (backend == "Xml") {
std::cout << "Using XML\n";
if (dbargs.length()<1) {
diff --git a/src/oastatstruct.cpp b/src/oastatstruct.cpp deleted file mode 100644 index c835816..0000000 --- a/src/oastatstruct.cpp +++ /dev/null
@@ -1,169 +0,0 @@
-/*
-===========================================================================
-oastat - a program for parsing log files and write the result to a database
-Copyright (C) 2012 Poul Sander
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/
-
-Source information and contacts persons can be found at
-https://github.com/sago007/oastat/
-===========================================================================
-*/
-
-#include "oastatstruct.h"
-#include <stdlib.h>
-#include <sstream>
-#include <iostream>
-#include <iomanip>
-
-static void makeLower(std::string &x)
-{
- for (size_t i=0; i<x.length(); ++i) {
- if (x[i] >= 'A' && x[i] <= 'X') {
- x[i] = x[i]-'A'+'a';
- }
- }
-}
-
-
-void OaStatStruct::clear()
-{
- second=0;
- command = "";
- parameters.clear();
- restOfLine = "";
-}
-
-void OaStatStruct::parseLine(const std::string& orgLine)
-{
- //Parse time
- std::string tempTimeString = orgLine.substr(0,7);
- int posColon = tempTimeString.find(":");
- int minute = atoi(tempTimeString.substr(0,posColon).c_str());
- second = atoi(tempTimeString.substr(posColon+1,7).c_str());
- second+=minute*60;
- std::string line = orgLine.substr(7, orgLine.length()); //Cut the first part of the string.
-
- //Parse command name:
- posColon = line.find(":");
- command = line.substr(0,posColon);
- try {
- line = line.substr(posColon+2,line.length()); //Also remove the colon and the first space after it (+2)
-
- posColon = line.find_first_not_of(" -0123456789"); //First non-number or space
- std::stringstream ss;
- ss << line.substr(0,posColon);
- int counter = 0; //to ensure that we don't go on forever
- while (ss && counter++<10) {
- int value;
- ss >> value;
- parameters.push_back(value);
- }
-
-
- if (line.at(posColon) == ':') {
- posColon++; //There is some inconsistensy about then there is a colon here
- if(line.at(posColon) == ' ') {
- posColon++; //If there is a colon there is likely a space
- }
- }
- line = line.substr(posColon,line.length());
- } catch (std::exception &e) {
- //The last part does not always exist... ignore it
- restOfLine = "";
- return;
- }
-
-
- restOfLine = line;
-}
-
-
-std::map<std::string,std::string> OaStatStruct::GetInfostring(const std::string& restOfLine) const
-{
- std::map<std::string,std::string> list;
- size_t lastPos = 0;
- bool iskey = true;
- std::string key;
- if (restOfLine[0] == '\\') {
- lastPos++;
- }
- while (lastPos<restOfLine.length()) {
- int curPos = restOfLine.find_first_of("\\", lastPos);
- if (curPos<0) {
- curPos = restOfLine.length();
- }
- if (iskey) {
- key = restOfLine.substr(lastPos,curPos-lastPos);
- } else {
- const std::string& value = restOfLine.substr(lastPos,curPos-lastPos);
- makeLower(key);
- if (key.length()>0) {
- list[key] = value;
- }
- }
- iskey = !iskey;
- lastPos = curPos+1;
- }
- return list;
-}
-
-std::map<std::string,std::string> OaStatStruct::GetInfostring() const
-{
- return GetInfostring(restOfLine);
-}
-
-const tm OaStatStruct::getDateTime() const
-{
- return _datetime;
-}
-
-std::string ZeroPadNumber(int num, int size = 2)
-{
- std::ostringstream ss;
- ss.clear();
- ss << std::setw( size ) << std::setfill( '0' ) << num;
- return ss.str();
-}
-
-std::string OaStatStruct::getTimeStamp() const
-{
- std::string s = "TIMESTAMP \'" + ZeroPadNumber(_datetime.tm_year+1900,4) + "-" + ZeroPadNumber(_datetime.tm_mon+1) + "-"
- + ZeroPadNumber(_datetime.tm_mday) + " " + ZeroPadNumber(_datetime.tm_hour) + ":"
- + ZeroPadNumber(_datetime.tm_min) + ":" + ZeroPadNumber(_datetime.tm_sec) + "\'";
- return s;
-}
-
-void OaStatStruct::setTimeStamp(const std::string &timestring)
-{
- if (timestring.empty()) {
- std::time_t t = std::time(0);
- _datetime = *std::gmtime(&t);
- return;
- }
- std::stringstream ss(timestring);
- std::string tmp;
- getline(ss,tmp,'-');
- _datetime.tm_year = atoi(tmp.c_str())-1900;
- getline(ss,tmp,'-');
- _datetime.tm_mon = atoi(tmp.c_str())-1;
- getline(ss,tmp,' ');
- _datetime.tm_mday = atoi(tmp.c_str());
- getline(ss,tmp,':');
- _datetime.tm_hour = atoi(tmp.c_str());
- getline(ss,tmp,':');
- _datetime.tm_min = atoi(tmp.c_str());
- getline(ss,tmp);
- _datetime.tm_sec = atoi(tmp.c_str());
-}
diff --git a/src/oastatstruct.h b/src/oastatstruct.h deleted file mode 100644 index 758b5fe..0000000 --- a/src/oastatstruct.h +++ /dev/null
@@ -1,83 +0,0 @@
-/*
-===========================================================================
-oastat - a program for parsing log files and write the result to a database
-Copyright (C) 2012 Poul Sander
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see http://www.gnu.org/licenses/
-
-Source information and contacts persons can be found at
-https://github.com/sago007/oastat/
-===========================================================================
-*/
-
-#ifndef _OASTATSTRUCT_H
-#define _OASTATSTRUCT_H
-
-#include <vector>
-#include <string>
-#include <map>
-#include <time.h>
-
-
-/*
- * This is the most important class in oastat. This takes a line and stores all
- * information from that line in easy to process parts.
- */
-class OaStatStruct
-{
-public:
- OaStatStruct() = default;
- OaStatStruct(const OaStatStruct& orig) = default;
- virtual ~OaStatStruct() = default;
-
- OaStatStruct& operator=(const OaStatStruct& orig) = default;
-
- //There are no reason to make any variables private.
- int second = 0; //number of seconds
- std::string command; //Like 'ClientConnect', 'Award' and 'Kill'
- std::vector<int> parameters; //The parameters for the command.
- std::string restOfLine;
- const tm getDateTime() const;
-
- void parseLine(const std::string& line);
- void clear();
-
- /*
- *Parses the rest of the line to an info string
- */
- std::map<std::string,std::string> GetInfostring(const std::string& restOfLine) const;
-
- /*
- *Same but uses this.restOfLine
- */
- std::map<std::string,std::string> GetInfostring() const;
-
- /*
- Returns a string with the time in the format:
- * TIMESTAMP 'YYYY-MM-
- */
- std::string getTimeStamp() const;
-
- /*
- Sets _datetime. Requires input in the format: "YYYY-MM-DD HH:MM:SS"
- * If input is blank the timestamp will be set to current UTC time.
- * For any other input the behavior is unspecified.
- */
- void setTimeStamp(const std::string &timestring);
-private:
- tm _datetime = {};
-};
-
-#endif /* _OASTATSTRUCT_H */
-
diff --git a/src/oss2db/Accuracy2Db.hpp b/src/oss2db/Accuracy2Db.hpp index f7ad133..dd8d71f 100644 --- a/src/oss2db/Accuracy2Db.hpp +++ b/src/oss2db/Accuracy2Db.hpp
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define ACCURACY2DB_HPP
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Accuracy2Db : public Struct2Db {
public:
diff --git a/src/oss2db/Award2Db.h b/src/oss2db/Award2Db.h index b595da5..2eb6171 100644 --- a/src/oss2db/Award2Db.h +++ b/src/oss2db/Award2Db.h
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define _AWARD2DB_H
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Award2Db : public Struct2Db
{
diff --git a/src/oss2db/Challenge2Db.hpp b/src/oss2db/Challenge2Db.hpp index 2993417..35de9b5 100644 --- a/src/oss2db/Challenge2Db.hpp +++ b/src/oss2db/Challenge2Db.hpp
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define CHALLENGE2DB_HPP
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Challenge2Db : public Struct2Db
{
diff --git a/src/oss2db/Ctf1f2Db.hpp b/src/oss2db/Ctf1f2Db.hpp index ec6c138..3dc0a15 100644 --- a/src/oss2db/Ctf1f2Db.hpp +++ b/src/oss2db/Ctf1f2Db.hpp
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define _CTF1F2DB_HPP
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Ctf1f2Db : public Struct2Db
{
diff --git a/src/oss2db/Ctf2Db.hpp b/src/oss2db/Ctf2Db.hpp index 27bf95b..e83afed 100644 --- a/src/oss2db/Ctf2Db.hpp +++ b/src/oss2db/Ctf2Db.hpp
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define _CTF2DB_HPP
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Ctf2Db : public Struct2Db
{
diff --git a/src/oss2db/CtfElimination2Db.hpp b/src/oss2db/CtfElimination2Db.hpp index b4408f4..dbe7a38 100644 --- a/src/oss2db/CtfElimination2Db.hpp +++ b/src/oss2db/CtfElimination2Db.hpp
@@ -26,7 +26,7 @@ https://github.com/sago007/oastat/
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class CtfElimination2Db : public Struct2Db
{
diff --git a/src/oss2db/Disconnect2Db.h b/src/oss2db/Disconnect2Db.h index 8740722..a3b9cbb 100644 --- a/src/oss2db/Disconnect2Db.h +++ b/src/oss2db/Disconnect2Db.h
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define _DISCONNECT2DB_H
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Disconnect2Db : public Struct2Db
{
diff --git a/src/oss2db/Elimination2Db.hpp b/src/oss2db/Elimination2Db.hpp index 3e72622..86bb253 100644 --- a/src/oss2db/Elimination2Db.hpp +++ b/src/oss2db/Elimination2Db.hpp
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define _ELIMINATION2DB_HPP
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Elimination2Db : public Struct2Db
{
diff --git a/src/oss2db/Harvester2Db.hpp b/src/oss2db/Harvester2Db.hpp index 89625fe..c0ec62a 100644 --- a/src/oss2db/Harvester2Db.hpp +++ b/src/oss2db/Harvester2Db.hpp
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define _HARVESTER2DB_HPP
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Harvester2Db : public Struct2Db
{
diff --git a/src/oss2db/Point2Db.hpp b/src/oss2db/Point2Db.hpp index c6ba4a6..90fcf60 100644 --- a/src/oss2db/Point2Db.hpp +++ b/src/oss2db/Point2Db.hpp
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define _POINT2DB_HPP
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Point2Db : public Struct2Db
{
diff --git a/src/oss2db/Warmup2Db.hpp b/src/oss2db/Warmup2Db.hpp index d6a9787..6882017 100644 --- a/src/oss2db/Warmup2Db.hpp +++ b/src/oss2db/Warmup2Db.hpp
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define WARMUP2DB_HPP
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Warmup2Db : public Struct2Db
{
diff --git a/src/oss2db/init2db.h b/src/oss2db/init2db.h index 0eb3afb..7780c1c 100644 --- a/src/oss2db/init2db.h +++ b/src/oss2db/init2db.h
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define _INIT2DB_H
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Init2Db : public Struct2Db
{
diff --git a/src/oss2db/kill2db.h b/src/oss2db/kill2db.h index e17ba44..fc9e92f 100644 --- a/src/oss2db/kill2db.h +++ b/src/oss2db/kill2db.h
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define _KILL2DB_H
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Kill2Db : public Struct2Db
{
diff --git a/src/oss2db/shutdown2db.h b/src/oss2db/shutdown2db.h index 8d6aa8f..782f5a5 100644 --- a/src/oss2db/shutdown2db.h +++ b/src/oss2db/shutdown2db.h
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define _SHUTDOWN2DB_H
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Shutdown2Db : public Struct2Db
{
diff --git a/src/oss2db/struct2db.h b/src/oss2db/struct2db.h index 0b8c343..056c33f 100644 --- a/src/oss2db/struct2db.h +++ b/src/oss2db/struct2db.h
@@ -24,7 +24,7 @@ https://github.com/sago007/oastat/
#ifndef _STRUCT2DB_H
#define _STRUCT2DB_H
-#include "../oastatstruct.h"
+#include "../common/oastatstruct.h"
#include "../db/database.hpp"
#include <string>
#include <boost/shared_ptr.hpp>
diff --git a/src/oss2db/userinfo2db.h b/src/oss2db/userinfo2db.h index fd19855..a821b16 100644 --- a/src/oss2db/userinfo2db.h +++ b/src/oss2db/userinfo2db.h
@@ -25,7 +25,7 @@ https://github.com/sago007/oastat/
#define _USERINFO2DB_H
#include "struct2db.h"
-#include "../local.h"
+#include "../common/local.h"
class Userinfo2Db : public Struct2Db
{