-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
61 lines (50 loc) · 1.65 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//====================================================================
// Filename: main.cpp
// Version: 0.02
// Author: 吴旭 <[email protected]>
// Created at: Mon Mar 12 10:11:25 2012
// Description: main file for log analysis.
//====================================================================
#include <cstring>
#include <memory>
#include "loganalysis.h"
void about();
void usage();
int main(int argc, char *argv[])
{
//LogAnalysis *ans;
if (argc < 1 || argc > 3) { // argument illegall
throw runtime_error("Invaild argument!");
usage();
} else if (argc == 1) { // default config
std::auto_ptr<LogAnalysis> ans(new LogAnalysis());
ans->getin_ip();
ans->getout_rst();
} else if (argc == 2) { // help
if (strncmp(argv[1], "help", 4)) {
throw runtime_error("Invaild argument!");
usage();
} else {
about();
usage();
}
} else if (argc == 3) { // custome config
std::auto_ptr<LogAnalysis> ans(new LogAnalysis(argv[1], argv[2]));
ans->getin_ip();
ans->getout_rst();
}
return 0;
}
void about() {
cout << "about this program" << endl;
cout << "version" << version << endl;
}
void usage() {
cout << "Usage: \n";
cout << "1 ./count\n";
cout << "This use \"ipdata\" as default ipdata file and \"rstdata\" as default result output file\n"
<< endl;
cout << "2 ./count ipdata resultfile\n";
cout << "You MUST specify \"ipdata\" for ip collection and \"resultfile\" for result output file."
<< endl;
}