-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
101 lines (91 loc) · 1.76 KB
/
main.cpp
File metadata and controls
101 lines (91 loc) · 1.76 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#include <windows.h>
#include "common.h"
#include "tool_functions.h"
#include "tool_dispatch.h"
extern "C" {
#ifdef EXPERIMENT
#ifdef DEBUG
#define WaterMarkString "DebugBuild,ExperimentOn";
#else
#error AS a preference, release build and EXPERIMENT flag not supported.
#define WaterMarkString "WARNINGReleaseBuild,ExperimentOn";
#endif
#else
#ifdef DEBUG
#define WaterMarkString "DebugBuild,ExperimentOff";
#else
#define WaterMarkString "ReleaseBuild,ExperimentOff";
#endif
#endif
}
extern "C" __declspec(dllexport) const char WaterMark[] = WaterMarkString;
#undef WaterMarkString
int main(int argc, const char* argv[])
{
if (argc < 2)
{
return -1;
}
// first check for the help flag;
bool HelpWanted = false;
for (int i = 1; i < argc; i++)
{
if (lstrcmpiA(argv[i], "-help") == 0)
{
HelpWanted = true;
break;
}
}
for (int i = 1; i < argc; i++)
{
const char* current = argv[i];
if (HelpWanted)
{
if (lstrcmpiA(argv[i], "-help") != 0)
{
const char* help_text = GetFunctionHelp(current);
if (help_text != nullptr)
{
WriteStdout(help_text);
}
else
{
WriteStderr(Message_UnknownCommandLineFlag);
}
}
continue;
}
else
{
ToolFunction function = (ToolFunction)GetFunctionPointer(current);
if (function != 0)
{
int result = 0;
const char* message_result = nullptr;
bool res = function(&result, &message_result, argv, argc);
if (res)
{
if (message_result != nullptr)
{
WriteStdout(message_result);
}
return result;
}
else
{
if (message_result != nullptr)
{
WriteStderr(message_result);
}
return result;
}
}
else
{
WriteStderr(Message_UnknownCommandLineFlag);
return -1;
}
}
break;
}
}