Changeset 45a38a5


Ignore:
Timestamp:
Apr 4, 2013 10:15:21 PM (9 years ago)
Author:
str4d <str4d@…>
Branches:
master
Children:
8857fe5
Parents:
7f471910
Message:

Only use original argc/v if there are arguments, otherwise use launch.properties or defaults

File:
1 edited

Legend:

Unmodified
Added
Removed
  • installer/c/i2pExe/i2p.c

    r7f471910 r45a38a5  
    3333main(int argc, char** argv) {
    3434
    35         //int read_options_size;
    36         //char** read_options;
     35        int read_options_size;
     36        char** read_options;
    3737        int ret = 0;
    3838        //int current_argc = 0;
    39         //int new_argc;
    40         //char** new_argv;
    41         //int i;
     39        int new_argc;
     40        char** new_argv;
     41        int i;
    4242#ifdef _WIN32
    4343        char currentDirectory[MAX_PATH+1];
     
    4949#endif
    5050
    51         // Read in options from disk (launch.properties)
    52         // or the default ones (if no launch.properties existed)
    53         //readOptions(&read_options, &read_options_size);
    54 
    55         // Construct a new argc & argv to pass to launchJVM
    56         //new_argc = read_options_size + argc;
    57         //new_argv = (char**)MemAlloc(sizeof(char*) * (new_argc+1));
    58 
    59         // copy process name
    60         //new_argv[0] = argv[0];
    61         // copy arguments from properties file
    62         //for(i = 1; i <= read_options_size; i++)
    63         //      new_argv[i] = read_options[i-1];
    64         // copy argv arguments as arguments after the properties file
    65         // (generally used as arguments for I2P)
    66         //for(current_argc = 1; current_argc < argc; current_argc++)
    67         //      new_argv[i++] = argv[current_argc];
    68 
    69         //new_argv[i] = NULL;
    70 
    71         // options are no longer necessary -- free them up.
    72         //if(read_options != 0)
    73         //      free(read_options);
    74 
    75     //ret = launchJVM(new_argc, new_argv);
    76         //free(new_argv);
    77         ret = launchJVM(argc, argv);
     51        // If there are command-line arguments, just use them
     52        if(argc > 1) {
     53                ret = launchJVM(argc, argv);
     54        } else {
     55                // Read in options from disk (launch.properties)
     56                // or the default ones (if no launch.properties existed)
     57                readOptions(&read_options, &read_options_size);
     58
     59                // Construct a new argc & argv to pass to launchJVM
     60                new_argc = read_options_size;
     61                new_argv = (char**)MemAlloc(sizeof(char*) * (new_argc+1));
     62
     63                // copy process name
     64                new_argv[0] = argv[0];
     65                // copy arguments from properties file
     66                for(i = 1; i <= read_options_size; i++)
     67                        new_argv[i] = read_options[i-1];
     68                // copy argv arguments as arguments after the properties file
     69                // (generally used as arguments for I2P)
     70                //for(current_argc = 1; current_argc < argc; current_argc++)
     71                //      new_argv[i++] = argv[current_argc];
     72
     73                new_argv[i] = NULL;
     74
     75                // options are no longer necessary -- free them up.
     76                if(read_options != 0)
     77                        free(read_options);
     78
     79                ret = launchJVM(new_argc, new_argv);
     80                free(new_argv);
     81        }
    7882        switch(ret) {
    7983        case ERROR_COULDNT_FIND_JVM:
Note: See TracChangeset for help on using the changeset viewer.