-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.cpp
More file actions
69 lines (64 loc) · 2.14 KB
/
main.cpp
File metadata and controls
69 lines (64 loc) · 2.14 KB
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
62
63
64
65
66
67
68
69
//main.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <string>
#include <iostream>
#include "GetOpt.h"
using namespace std;
int main(int argc, char* argv[])
{
char opt = -1;
string aPath;
string aLogFileName;
int levelVerbose = 0;
bool daemon = false;
bool kill = false;
GetOpt getopt( argc, argv, "p:l:v::dkh" );
while ( ( opt = getopt() ) != EOF )
{
switch ( opt )
{
case 'p':
aPath = getopt.get() ;
break;
case 'l':
aLogFileName = getopt.get() ;
break;
case 'v':
if ( !getopt.get().empty() )
{
levelVerbose = std::stoi( getopt.get() ) ;
}
else
{
levelVerbose = 1;
}
break;
case 'd':
daemon = true;
break;
case 'k':
kill = true;
break;
case '?':
case ':':
std::cout << getopt.error();
case 'h':
default:
cout << "usage: " << argv[0] << "[-p path][-l logfile][-v level][-h][-k][-d]\n";
cout << " -p path assume the home directory to be path.\n";
cout << " -l logfile sets the directory to write logfiles\n";
cout << " -v activates verbose level. Level is optional.\n";
cout << " -d start as a daemon\n";
cout << " -k shut down / kill\n";
cout << " -h shows this help message\n";
break;
}
}
cout << "homepath is set to " << aPath << '\n';
cout << "Name of the log file is set to " << aLogFileName << '\n';
cout << "Verbose level is set to " << levelVerbose << '\n';
cout << "Action daemon is set to " << daemon << '\n';
cout << "Action kill is set to " << kill << '\n';
return 0;
}