소스 검색

updated to clean namespaces

master
Pete McNeil 4 년 전
부모
커밋
97714b2140
4개의 변경된 파일24개의 추가작업 그리고 24개의 파일을 삭제
  1. 1
    1
      CodeDweller
  2. 20
    20
      GBUDBTool/main.cpp
  3. 1
    1
      SNFMulti
  4. 2
    2
      makefile

+ 1
- 1
CodeDweller

@@ -1 +1 @@
Subproject commit 57459a5d9aea2a42de064a05998d5f48f7614220
Subproject commit 2c3aafcc16cbc2d9ea121b0b9c8851b0337c9168

+ 20
- 20
GBUDBTool/main.cpp 파일 보기

@@ -5,14 +5,14 @@
#include "../CodeDweller/faults.hpp"
#include "../SNFMulti/GBUdb.hpp"
using namespace std;
namespace cd = codedweller;
const string VersionInfo = "V0.1";
const std::string VersionInfo = "V0.1";
const int ErrorResultCode = 1;
const int SuccessResultCode = 0;
struct Configuration {
string GBXFile;
std::string GBXFile;
double Probability;
double Confidence;
bool findBlack;
@@ -25,14 +25,14 @@ struct Configuration {
showDetails(false) {}
} myConfig;
class BadArguments : public RuntimeFault {public: BadArguments(string s):RuntimeFault(s){}};
class BadArguments : public cd::RuntimeFault {public: BadArguments(std::string s):RuntimeFault(s){}};
const BadArguments BadArgumentCount("Wrong number of arguments");
const BadArguments BadSwitch("Bad command line switch");
void setConfiguration(Configuration &conf, int argc, char* argv[]) {
BadArgumentCount(argc > 6 || argc < 1);
for(int i = 1; i < argc; i++) {
string thisArgument(argv[i]);
std::string thisArgument(argv[i]);
if(0 == thisArgument.find("-black")) {
conf.findBlack = true;
@@ -65,27 +65,27 @@ void setConfiguration(Configuration &conf, int argc, char* argv[]) {
}
void displayHelp() {
cerr << "GBUDBTool " << VersionInfo << endl;
cerr << "Use: GBUDBTool [-black | -white] [-p=<value>] [-c=<value>] <gbx file>" << endl;
cerr << " -black prints out blacklist IPs based on p & c" << endl;
cerr << " -white prints out whitelist IPs based on p & c" << endl;
cerr << " -details prints out counts, confidence, and probability" << endl;
cerr << " -c=<value> sets the confidence figure for the list" << endl;
cerr << " -p=<value> sets the probability figure for the list" << endl;
cerr << " <gbx file> is the path to a GBUdb snapshot" << endl;
std::cerr << "GBUDBTool " << VersionInfo << std::endl;
std::cerr << "Use: GBUDBTool [-black | -white] [-p=<value>] [-c=<value>] <gbx file>" << std::endl;
std::cerr << " -black prints out blacklist IPs based on p & c" << std::endl;
std::cerr << " -white prints out whitelist IPs based on p & c" << std::endl;
std::cerr << " -details prints out counts, confidence, and probability" << std::endl;
std::cerr << " -c=<value> sets the confidence figure for the list" << std::endl;
std::cerr << " -p=<value> sets the probability figure for the list" << std::endl;
std::cerr << " <gbx file> is the path to a GBUdb snapshot" << std::endl;
}
class Reporter : public GBUdbOperator {
private:
Configuration myConfig;
string toIP4String(unsigned int IP) {
std::string toIP4String(unsigned int IP) {
int a, b, c, d;
d = IP & 0x000000ff; IP >>= 8;
c = IP & 0x000000ff; IP >>= 8;
b = IP & 0x000000ff; IP >>= 8;
a = IP;
ostringstream S;
std::ostringstream S;
S << a << "." << b << "." << c << "." << d;
return S.str();
}
@@ -100,15 +100,15 @@ class Reporter : public GBUdbOperator {
if(myConfig.findBlack) goodProbability = (myConfig.Probability <= R.Probability());
else goodProbability = (myConfig.Probability <= R.Probability());
if(goodProbability && goodConfidence) {
cout << toIP4String(IP);
std::cout << toIP4String(IP);
if(myConfig.showDetails) {
cout << "\t"
std::cout << "\t"
<< "g=" << R.Good()
<< ", b=" << R.Bad()
<< ", c=" << R.Confidence()
<< ", p=" << R.Probability();
}
cout << endl;
std::cout << std::endl;
}
return R;
}
@@ -123,9 +123,9 @@ int main(int argc, char* argv[]) {
DB.doForAllRecords(R);
}
catch(exception &e) {
catch(const std::exception &e) {
displayHelp();
cerr << endl << "Exception: " << e.what() << endl;
std::cerr << std::endl << "Exception: " << e.what() << std::endl;
return ErrorResultCode;
}

+ 1
- 1
SNFMulti

@@ -1 +1 @@
Subproject commit a81ce5f3e8ea19d300e169517579d63d7567bed9
Subproject commit 869c039bef12a6cdc191781f0c0a76dd7eb00c85

+ 2
- 2
makefile 파일 보기

@@ -6,10 +6,10 @@ CXXFLAGS = -Wall -O3 -pthread -static
gbudbtool: gbudbtool.o GBUdb.o threading.o
$(CXX) $(CXXFLAGS) gbudbtool.o GBUdb.o threading.o -o bin/gbudbtool

gbudbtool.o: GBUDBTool/main.cpp SNFMulti/GBUdb.hpp SNFMulti/GBUdb.inline.hpp CodeDweller/faults.hpp
gbudbtool.o: GBUDBTool/main.cpp SNFMulti/GBUdb.hpp CodeDweller/faults.hpp
$(CXX) $(CXXFLAGS) -c GBUDBTool/main.cpp -o gbudbtool.o

GBUdb.o: SNFMulti/GBUdb.cpp SNFMulti/GBUdb.inline.hpp SNFMulti/GBUdb.cpp
GBUdb.o: SNFMulti/GBUdb.cpp SNFMulti/GBUdb.cpp
$(CXX) $(CXXFLAGS) -c SNFMulti/GBUdb.cpp

threading.o: CodeDweller/threading.cpp CodeDweller/threading.hpp

Loading…
취소
저장