Get a simple I2P.exe working

This commit is contained in:
str4d
2013-04-03 01:55:02 +00:00
parent 51f072cc72
commit f6190dd82d

View File

@@ -27,13 +27,13 @@ extern int launchJVM(int, char**);
int int
main(int argc, char** argv) { main(int argc, char** argv) {
int read_options_size; //int read_options_size;
char** read_options; //char** read_options;
int ret = 0; int ret = 0;
int current_argc = 0; //int current_argc = 0;
int new_argc; //int new_argc;
char** new_argv; //char** new_argv;
int i; //int i;
char currentDirectory[MAX_PATH+1]; char currentDirectory[MAX_PATH+1];
// Set/get the correct working directory. // Set/get the correct working directory.
@@ -41,30 +41,31 @@ main(int argc, char** argv) {
// Read in options from disk (launch.properties) // Read in options from disk (launch.properties)
// or the default ones (if no launch.properties existed) // or the default ones (if no launch.properties existed)
readOptions(&read_options, &read_options_size); //readOptions(&read_options, &read_options_size);
// Construct a new argc & argv to pass to launchJVM // Construct a new argc & argv to pass to launchJVM
new_argc = read_options_size + argc; //new_argc = read_options_size + argc;
new_argv = (char**)MemAlloc(sizeof(char*) * (new_argc+1)); //new_argv = (char**)MemAlloc(sizeof(char*) * (new_argc+1));
// copy process name // copy process name
new_argv[0] = argv[0]; //new_argv[0] = argv[0];
// copy arguments from properties file // copy arguments from properties file
for(i = 1; i <= read_options_size; i++) //for(i = 1; i <= read_options_size; i++)
new_argv[i] = read_options[i-1]; // new_argv[i] = read_options[i-1];
// copy argv arguments as arguments after the properties file // copy argv arguments as arguments after the properties file
// (generally used as arguments for I2P) // (generally used as arguments for I2P)
for(current_argc = 1; current_argc < argc; current_argc++) //for(current_argc = 1; current_argc < argc; current_argc++)
new_argv[i++] = argv[current_argc]; // new_argv[i++] = argv[current_argc];
new_argv[i] = NULL; //new_argv[i] = NULL;
// options are no longer necessary -- free them up. // options are no longer necessary -- free them up.
if(read_options != 0) //if(read_options != 0)
free(read_options); // free(read_options);
ret = launchJVM(new_argc, new_argv); //ret = launchJVM(new_argc, new_argv);
free(new_argv); //free(new_argv);
ret = launchJVM(argc, argv);
switch(ret) { switch(ret) {
case ERROR_COULDNT_FIND_JVM: case ERROR_COULDNT_FIND_JVM:
case ERROR_COULDNT_INITIALIZE_JVM: case ERROR_COULDNT_INITIALIZE_JVM: