-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
48 lines (39 loc) · 977 Bytes
/
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
#include <algorithm>
#include <string>
#include <iostream>
#include <thread>
#include "ParseInput.h"
#include "ReportThread.h"
using namespace std;
char* getOption(char ** begin, char ** end, const std::string & option)
{
char ** itr = std::find(begin, end, option);
if (itr != end && ++itr != end)
{
return *itr;
}
return NULL;
}
int main(int argc, char ** argv) {
std::string reportPath;
int interval=1;
char *file = getOption(argv, argv + argc, "-o");
if(file != NULL) {
reportPath.append(std::string(file));
}
char *intervalString = getOption(argv, argv + argc, "-i");
if(intervalString != NULL) {
try {
interval = std::stoi(intervalString);
} catch(std::exception const &e) {
cerr << "Wrong interval argument.\n";
return 1;
}
}
ParseInput parseInput;
ReportThread reportThread(&parseInput.httpKeysMap);
std::thread t = reportThread.report(reportPath, interval);
parseInput.parse();
t.join();
return 0;
}