-
Notifications
You must be signed in to change notification settings - Fork 0
/
tool.cpp
65 lines (50 loc) · 1.66 KB
/
tool.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
62
63
64
//////////////////////////////////////////////////////////////////////
// main.cpp
//////////////////////////////////////////////////////////////////////
#include <string>
#include <vector>
#include "common.h"
#include "data.h"
#include "jvm.h"
//////////////////////////////////////////////////////////////////////
using std::cout;
using std::endl;
using std::string;
using std::vector;
namespace JB = Jarbinger;
//////////////////////////////////////////////////////////////////////
class Usage : public JB::Usage {
public:
Usage(string binName) : _binName(binName) { /* nothing */ }
virtual void output() {
cout << "usage: " << _binName << " ..." << endl;
}
private:
string _binName;
};
//////////////////////////////////////////////////////////////////////
int main(int argc, char** argv) {
int status= 0;
int argNo= 0;
string binName= argv[argNo++];
Usage usage(binName);
try {
//TODO: command line options for debug and cleanup (e.g. -jb-clean)
// and pass remaining args onto tool
string toolName(TOOL);
string dataPath= JB::unArchive(toolName, &_binary_data_file_start,
(JB::U64) &_binary_data_file_size);
string mainJarFilename(dataPath +"/"+ JAR_FILENAME);
string mainClassName(MAIN_CLASS_NAME);
vector<string> vArgs;
for (int i= argNo; i < argc; i++) {
string arg(argv[i]);
vArgs.push_back(arg);
}
JB::startJVM(mainJarFilename, mainClassName, vArgs);
} catch (JB::Exception e) {
e.reportAndExit();
}
return status;
}
//////////////////////////////////////////////////////////////////////