/*
 * Domhan_Samhlaigh - Constructor for Domhan_Samhlaigh class
 * 
 * parameter argc - int &
 * parameter argv - char **&
 * parameter appDefaults - char **&
 */
Domhan_Samhlaigh::Domhan_Samhlaigh(int & argc, char **& argv, char **& appDefaults) :
	Vrui::Application(argc, argv, appDefaults), heightMapPrefix(0), mainMenu(NULL), minimumLevel(0), numberOfHorizontalPatches(0),
			numberOfVerticalPatches(0), scaleToEnvironment(true), scene(NULL), texturePrefix(0) {
	try {
		processCommandLineArguments(argc, argv);
	} catch (std::runtime_error e) {
		std::cerr << "Error: Exception " << e.what() << "!" << std::endl;
	}
	initialize();
}
FiberApplication::FiberApplication(int& argc,char**& argv,char**& appDefaults)
    :Vrui::Application(argc,argv,appDefaults),
     mainMenu(0),
     propertiesDialog(0),
     m_showSelectionBox(true),
     m_fiberFileName(""),
     m_anatomyFileName(""),
     m_showVolume(false),
     mIsoSurface(NULL)
{
    //TODO create tool at launch if possible

    processCommandLineArguments(argc,argv);

    if(m_anatomyFileName != "")
    {
        mAnatomy.load(m_anatomyFileName);
        mIsoSurface = new IsoSurface(&mAnatomy,false);
        mIsoSurface->GenerateSurface(0.2f);
    }

    if(m_fiberFileName != "")
    {
        mFibers.load(m_fiberFileName);
    }

    //Create the user interface:
    mainMenu=createMainMenu();

    //create Popup Window
    //propertiesDialog = createPropertiesDialog();

    //Install the main menu:
    Vrui::setMainMenu(mainMenu);

    if(mFibers.getBBMax()[X_AXIS] + mFibers.getBBMax()[Y_AXIS] + mFibers.getBBMax()[Z_AXIS] >
        mAnatomy.getBBMax()[X_AXIS] + mAnatomy.getBBMax()[Y_AXIS] + mAnatomy.getBBMax()[Z_AXIS])
    {
        m_BBMax = mFibers.getBBMax();
    }
    else
    {
        m_BBMax = mAnatomy.getBBMax();
    }

    //Set the navigation transformation:
    resetNavigationCallback(0);

    //Tell Vrui to run in a continuous frame sequence:
    Vrui::updateContinuously();
}
Exemple #3
0
void Config::process(int argc, char* argv[])
{
    processCommandLineArguments(argc-1, argv+1);
    if (isSet("config")) {
        string path;
        get("config", path);

        ifstream f(path.c_str());
        if (!f) {
            cerr << "Failed to open config file " << path << endl;
            return;
        }

        while (f) {
            string str;
            getline(f, str);
            boost::trim(str);
            if (str[0] == '#') continue;
            if (str.empty()) continue;
            processArgument(str.c_str());
        }
    }
    processEnvArguments();
}
Exemple #4
0
/**
 * Parse command line arguments to find those arguments that
 *   1) affect the starting of the VM,
 *   2) can be handled without starting the VM, or
 *   3) contain quotes
 * then call createVM().
 */
int main(int argc, const char **argv)
{
  int vbufret, j, ret;
  JavaVMInitArgs initArgs;
  JavaVM *mainJavaVM;
  JNIEnv *mainJNIEnv;

  /* Make standard streams unbuffered so that we can use them
     for low level-debugging */
  vbufret = setvbuf(stdout, NULL, _IONBF, 0);
  if (vbufret != 0) {
    printf("Error making stdout unbuffered: %d\n", vbufret);
  }
  vbufret = setvbuf(stderr, NULL, _IONBF, 0);
  if (vbufret != 0) {
    printf("Error making stderr unbuffered: %d\n", vbufret);
  }
  SysErrorFile = stderr;
  SysTraceFile = stdout;
  Me = strrchr(*argv, '/');
  if (Me == NULL) {
    Me = "RVM";
  } else {
    Me++;
  }

  ++argv, --argc;
  initialHeapSize = heap_default_initial_size;
  maximumHeapSize = heap_default_maximum_size;

  // Determine page size information early because
  // it's needed to parse command line options
  pageSize = (Extent) determinePageSize();
  if (pageSize <= 0) {
    ERROR_PRINTF("RunBootImage.main(): invalid page size %u", pageSize);
    exit(EXIT_STATUS_IMPOSSIBLE_LIBRARY_FUNCTION_ERROR);
  }

  /*
   * Debugging: print out command line arguments.
   */
  if (TRACE) {
    TRACE_PRINTF("RunBootImage.main(): process %d command line arguments\n",argc);
    for (j = 0; j < argc; j++) {
      TRACE_PRINTF("\targv[%d] is \"%s\"\n",j, argv[j]);
     }
  }

  /* Initialize JavaArgc, JavaArgs and initArg */
  initArgs.version = JNI_VERSION_1_4;
  initArgs.ignoreUnrecognized = JNI_TRUE;
  JavaArgs = (char **)processCommandLineArguments(&initArgs, argv, argc);

  if (TRACE) {
    TRACE_PRINTF("RunBootImage.main(): after processCommandLineArguments: %d command line arguments\n", JavaArgc);
    for (j = 0; j < JavaArgc; j++) {
      TRACE_PRINTF("\tJavaArgs[%d] is \"%s\"\n", j, JavaArgs[j]);
    }
  }

  /* Verify heap sizes for sanity. */
  if (initialHeapSize == heap_default_initial_size &&
      maximumHeapSize != heap_default_maximum_size &&
      initialHeapSize > maximumHeapSize) {
    initialHeapSize = maximumHeapSize;
  }

  if (maximumHeapSize == heap_default_maximum_size &&
      initialHeapSize != heap_default_initial_size &&
      initialHeapSize > maximumHeapSize) {
    maximumHeapSize = initialHeapSize;
  }

  if (maximumHeapSize < initialHeapSize) {
    CONSOLE_PRINTF( "%s: maximum heap size %lu MiB is less than initial heap size %lu MiB\n",
                    Me, (unsigned long) maximumHeapSize/(1024*1024),
                    (unsigned long) initialHeapSize/(1024*1024));
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  TRACE_PRINTF("\nRunBootImage.main(): VM variable settings\n");
  TRACE_PRINTF("initialHeapSize %lu\nmaxHeapSize %lu\n"
           "bootCodeFileName \"%s\"\nbootDataFileName \"%s\"\n"
           "bootRmapFileName \"%s\"\n"
           "verbose %d\n",
           (unsigned long) initialHeapSize,
           (unsigned long) maximumHeapSize,
           bootCodeFilename, bootDataFilename, bootRMapFilename,
           verbose);

  if (!bootCodeFilename) {
    CONSOLE_PRINTF( "%s: please specify name of boot image code file using \"-X:ic=<filename>\"\n", Me);
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  if (!bootDataFilename) {
    CONSOLE_PRINTF( "%s: please specify name of boot image data file using \"-X:id=<filename>\"\n", Me);
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  if (!bootRMapFilename) {
    CONSOLE_PRINTF( "%s: please specify name of boot image ref map file using \"-X:ir=<filename>\"\n", Me);
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  ret = JNI_CreateJavaVM(&mainJavaVM, &mainJNIEnv, &initArgs);
  if (ret < 0) {
    ERROR_PRINTF("%s: Could not create the virtual machine; goodbye\n", Me);
    exit(EXIT_STATUS_MISC_TROUBLE);
  }
  return 0;
}
int main (int argc, char *argv[])
{
  SquareMaze *maze;

  bool showVisualization=false;
  bool showSolutionMode=false;
  double visualizationPauseInSec=0.1;

  // 221 STUDENTS: you may safely ignore (or even delete) the function
  // call to processCommandLineArguments.  We will test your program
  // with no command-line arguments.  (You are free to leave the call
  // here and, e.g., use the visualization for your debugging,
  // however!)
  processCommandLineArguments(argc, argv, 
			      showVisualization, 
			      showSolutionMode, 
			      visualizationPauseInSec);
	   

  // 221 STUDENTS: This reads a square maze from standard input.  You
  // can use this as is.  
  maze = new SquareMaze(cin);


  // 221 STUDENTS: You may safely ignore (or even delete) the
  // visualization code below.  Even if you would like to use it, it
  // should work with no changes on your part.

  // Set up the visualizer, if it has been requested.  If solution
  // visualization has been requested, then the input should include
  // solutions to the maze, and showing the solutions is all this
  // program will do.  (It will not also try to solve the maze.)
  //
  // WARNING: this code does not work on Windows
  VisualizeSquareMazeRunner *visualizer=NULL;
#ifndef WIN32
  if (showVisualization) {
    visualizer=new VisualizeSquareMazeRunner(maze);
    visualizer->setPauseTime(visualizationPauseInSec);
	  
    if (showSolutionMode) {
      while (!cin.eof()) {
	char solutionAlg[256];
	cin.getline(solutionAlg,256);
	if (cin.eof()) {
	  break;
	}
	cout << " Printing solution done by " << solutionAlg << " algorithm\n";
	int x,y;
	visualizer->startSolutionPath();
	while (SquareMaze::SquareMazeNode::readXY(cin,&x,&y)) {
	  visualizer->addNextInSolutionPath(x,y);
	  //cout << "(" << x << "," << y << ")\n";
	}
	visualizer->doneSolutionPath();

	cout << "Click mouse in solution display window to continue...\n";
	cout << flush;
	visualizer->waitForMouseClick();

      }
      return 0;
    }
  }
#endif


  MazeRunner *mazeRunner;

// 221 STUDENTS: You'll want to use your own maze runner rather than
// a RandomMazeRunner.  (Just change the constructor called on the
// right side of the assignment statement.)  You'll also want to run
// two mazerunners (which you can do by copying similar code below).



// cout<< "random"<< endl;
// mazeRunner = new RandomMazeRunner();
// mazeRunner->solveMaze(maze,cout);
// delete mazeRunner;
//

  // Clean up the maze, in case we need to run another maze runner
  maze->reinitializeMaze();

  mazeRunner = new DFSMazeRunner();
  mazeRunner->solveMaze(maze,cout);
  delete mazeRunner;

  // Clean up the maze, in case we need to run another maze runner
  maze->reinitializeMaze();

  mazeRunner = new BFSMazeRunner();
  mazeRunner->solveMaze(maze,cout);
  delete mazeRunner;

  // Clean up the maze, in case we need to run another maze runner
  maze->reinitializeMaze();


  // Clean up and return.
  if (visualizer != NULL)
    delete visualizer;

  delete maze;

  return 0;
}
Exemple #6
0
/*
 * Parse command line arguments to find those arguments that
 *   1) affect the starting of the VM,
 *   2) can be handled without starting the VM, or
 *   3) contain quotes
 * then call createVM().
 */
int
main(int argc, const char **argv)
{
    Me            = strrchr(*argv, '/') + 1;
    ++argv, --argc;
    initialHeapSize = heap_default_initial_size;
    maximumHeapSize = heap_default_maximum_size;

    /*
     * Debugging: print out command line arguments.
     */
    if (DEBUG) {
        printf("RunBootImage.main(): process %d command line arguments\n",argc);
        for (int j=0; j<argc; j++) {
            printf("\targv[%d] is \"%s\"\n",j, argv[j]);
        }
    }

    // call processCommandLineArguments().
    bool fastBreak = false;
    // Sets JavaArgc
    JavaArgs = processCommandLineArguments(argv, argc, &fastBreak);
    if (fastBreak) {
        exit(EXIT_STATUS_BOGUS_COMMAND_LINE_ARG);
    }

    if (DEBUG) {
        printf("RunBootImage.main(): after processCommandLineArguments: %d command line arguments\n", JavaArgc);
        for (int j = 0; j < JavaArgc; j++) {
            printf("\tJavaArgs[%d] is \"%s\"\n", j, JavaArgs[j]);
        }
    }


    /* Verify heap sizes for sanity. */
    if (initialHeapSize == heap_default_initial_size &&
        maximumHeapSize != heap_default_maximum_size &&
        initialHeapSize > maximumHeapSize) {
        initialHeapSize = maximumHeapSize;
    }

    if (maximumHeapSize == heap_default_maximum_size &&
        initialHeapSize != heap_default_initial_size &&
        initialHeapSize > maximumHeapSize) {
        maximumHeapSize = initialHeapSize;
    }

    if (maximumHeapSize < initialHeapSize) {
        fprintf(SysTraceFile, "%s: maximum heap size %lu MiB is less than initial heap size %lu MiB\n",
                Me, (unsigned long) maximumHeapSize/(1024*1024),
                (unsigned long) initialHeapSize/(1024*1024));
        return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
    }

    if (DEBUG){
        printf("\nRunBootImage.main(): VM variable settings\n");
        printf("initialHeapSize %lu\nmaxHeapSize %lu\n"
               "bootCodeFileName |%s|\nbootDataFileName |%s|\n"
               "bootRmapFileName |%s|\n"
               "lib_verbose %d\n",
               (unsigned long) initialHeapSize,
               (unsigned long) maximumHeapSize,
               bootCodeFilename, bootDataFilename, bootRMapFilename,
               lib_verbose);
    }

    if (!bootCodeFilename) {
        fprintf(SysTraceFile, "%s: please specify name of boot image code file using \"-X:ic=<filename>\"\n", Me);
        return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
    }

    if (!bootDataFilename) {
        fprintf(SysTraceFile, "%s: please specify name of boot image data file using \"-X:id=<filename>\"\n", Me);
        return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
    }

    if (!bootRMapFilename) {
        fprintf(SysTraceFile, "%s: please specify name of boot image ref map file using \"-X:ir=<filename>\"\n", Me);
        return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
    }

#ifdef __MACH__
    // Initialize timer information on OS/X
    (void) mach_timebase_info(&timebaseInfo);
#endif

    int ret = createVM(0);
    assert(ret == 1);           // must be 1 (error status for this func.)

    fprintf(SysErrorFile, "%s: Could not create the virtual machine; goodbye\n", Me);
    exit(EXIT_STATUS_MISC_TROUBLE);
}
Exemple #7
0
/*
 * Parse command line arguments to find those arguments that 
 *   1) affect the starting of the VM, 
 *   2) can be handled without starting the VM, or
 *   3) contain quotes
 * then call createVM().
 */
int
main(int argc, const char **argv)
{
    Me            = strrchr(*argv, '/') + 1;
    ++argv, --argc;
    initialHeapSize = heap_default_initial_size;
    maximumHeapSize = heap_default_maximum_size;

#ifdef RVM_WITH_FLEXIBLE_STACK_SIZES
    const unsigned stack_minimum_size         = 
        VM_Constants_STACK_SIZE_MIN;
    const unsigned stack_default_initial_size = 
        VM_Constants_STACK_SIZE_NORMAL_DEFAULT;
    const unsigned stack_grow_minimum_increment = 
        VM_Constants_STACK_SIZE_GROW_MIN;
    const unsigned stack_default_grow_increment = 
        VM_Constants_STACK_SIZE_GROW_DEFAULT;
    const unsigned stack_default_maximum_size = 
        VM_Constants_STACK_SIZE_MAX_DEFAULT;
    
    initialStackSize = stack_default_initial_size;
    stackGrowIncrement = stack_default_grow_increment;
    maximumStackSize = stack_default_maximum_size;
#endif // RVM_WITH_FLEXIBLE_STACK_SIZES
  
    /*
     * Debugging: print out command line arguments.
     */
    if (DEBUG) {
        printf("RunBootImage.main(): process %d command line arguments\n",argc);
        for (int j=0; j<argc; j++) {
            printf("\targv[%d] is \"%s\"\n",j, argv[j]);
        }
    }
  
    // call processCommandLineArguments().
    bool fastBreak = false;
    // Sets JavaArgc
    JavaArgs = processCommandLineArguments(argv, argc, &fastBreak);
    if (fastBreak) {
        exit(EXIT_STATUS_BOGUS_COMMAND_LINE_ARG);
    }

    if (DEBUG) {
        printf("RunBootImage.main(): after processCommandLineArguments: %d command line arguments\n", JavaArgc);
        for (int j = 0; j < JavaArgc; j++) {
            printf("\tJavaArgs[%d] is \"%s\"\n", j, JavaArgs[j]);
        }
    }
  
            
#ifdef RVM_FOR_LINUX
    if (rvm_singleVirtualProcessor <= -2) {
        if (running_Debian())
            rvm_singleVirtualProcessor = -1;
        else
            rvm_singleVirtualProcessor = 0;
    }
    

    if (rvm_singleVirtualProcessor < 0) // Debian.
        rvm_singleVirtualProcessor = singleVirtualProcessor_for_Debian();
#else
    /* Turn it off for all non-Linux systems.  We could print a diagnostic
     * message here, but that seems like too much work to implement. */
    if (rvm_singleVirtualProcessor < 0)
        rvm_singleVirtualProcessor = 0; 
#endif

    /* Verify heap sizes for sanity. */
    if (initialHeapSize == heap_default_initial_size &&
        maximumHeapSize != heap_default_maximum_size &&
        initialHeapSize > maximumHeapSize) {
        initialHeapSize = maximumHeapSize;
    }

    if (maximumHeapSize == heap_default_maximum_size &&
        initialHeapSize != heap_default_initial_size &&
        initialHeapSize > maximumHeapSize) {
        maximumHeapSize = initialHeapSize;
    }

    if (maximumHeapSize < initialHeapSize) {
        fprintf(SysTraceFile, "%s: maximum heap size %lu MiB is less than initial heap size %lu MiB\n", 
                Me, (unsigned long) maximumHeapSize/(1024*1024), 
                (unsigned long) initialHeapSize/(1024*1024));
        return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
    }

#ifdef RVM_WITH_FLEXIBLE_STACK_SIZES
    /* Verify stack sizes for sanity. */
    if (initialStackSize == stack_default_initial_size &&
        maximumStackSize != stack_default_maximum_size &&
        initialStackSize > maximumStackSize) {
        initialStackSize = maximumStackSize;
    }

    if (maximumStackSize == stack_default_maximum_size &&
        initialStackSize != stack_default_initial_size &&
        initialStackSize > maximumStackSize) {
        maximumStackSize = initialStackSize;
    }

    if (maximumStackSize < initialStackSize) {
        fprintf(SysTraceFile, "%s: maximum stack size %lu KiB is less than initial stack size %lu KiB\n", 
                Me, (unsigned long) maximumStackSize/1024, 
                (unsigned long) initialStackSize/1024);
        return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
    }

    if (initialStackSize < stack_minimum_size) {
        fprintf(SysTraceFile, "%s: initial stack size %lu KiB is less than minimum stack size %lu KiB\n", 
                Me, (unsigned long) initialStackSize/1024, 
                (unsigned long) stack_minimum_size/1024);
        return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
    }

    if (stackGrowIncrement < stack_grow_minimum_increment) {
        fprintf(SysTraceFile, "%s: stack growth increment %lu KiB is less than minimum growth increment %lu KiB\n", 
                Me, (unsigned long) stackGrowIncrement/1024, 
                (unsigned long) stack_grow_minimum_increment/1024);
        return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
    }
#endif // RVM_WITH_FLEXIBLE_STACK_SIZES

    if (DEBUG){
        printf("\nRunBootImage.main(): VM variable settings\n");
        printf("initialHeapSize %lu\nmaxHeapSize %lu\n"
#ifdef RVM_WITH_FLEXIBLE_STACK_SIZES
               "initialStackSize %lu\n"
               "stackGrowIncrement %lu\n"
               "maxStackSize %lu\n"
#endif // RVM_WITH_FLEXIBLE_STACK_SIZES
               "rvm_singleVirtualProcessor %d\n"
               "bootFileName |%s|\nlib_verbose %d\n",
               (unsigned long) initialHeapSize, 
               (unsigned long) maximumHeapSize, 
#ifdef RVM_WITH_FLEXIBLE_STACK_SIZES
               (unsigned long) initialStackSize, 
               (unsigned long) stackGrowIncrement,
               (unsigned long) maximumStackSize,
#endif // RVM_WITH_FLEXIBLE_STACK_SIZES
               rvm_singleVirtualProcessor,
               bootFilename, lib_verbose);
    }

    if (!bootFilename) {
#define STRINGIZE(x) #x
#ifdef RVM_BOOTIMAGE
        bootFilename = STRINGIZE(RVM_BOOTIMAGE);
#endif
    }

    if (!bootFilename) {
        fprintf(SysTraceFile, "%s: please specify name of boot image file using \"-i<filename>\"\n", Me);
        return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
    }

    int ret = createVM(0);
    assert(ret == 1);           // must be 1 (error status for this func.)
    
    fprintf(SysErrorFile, "%s: Could not create the virtual machine; goodbye\n", Me);
    exit(EXIT_STATUS_MISC_TROUBLE);
}
Exemple #8
0
/**
 * Parse command line arguments to find those arguments that
 *   1) affect the starting of the VM,
 *   2) can be handled without starting the VM, or
 *   3) contain quotes
 * then call createVM().
 */
int main(int argc, const char **argv)
{
  int j, ret;
  JavaVMInitArgs initArgs;
  JavaVM *mainJavaVM;
  JNIEnv *mainJNIEnv;
  SYS_START();
#ifndef RVM_FOR_HARMONY
  SysErrorFile = stderr;
  SysTraceFile = stdout;
  setbuf (SysErrorFile, NULL);
  setbuf (SysTraceFile, NULL);
  setvbuf(stdout,NULL,_IONBF,0);
  setvbuf(stderr,NULL,_IONBF,0);
#endif
#ifndef RVM_FOR_WINDOWS
  Me = strrchr(*argv, '/');
#else
  Me = strrchr(*argv, '\\');
#endif
  if (Me == NULL) {
    Me = "RVM";
  } else {
    Me++;
  }
  ++argv, --argc;
  initialHeapSize = heap_default_initial_size;
  maximumHeapSize = heap_default_maximum_size;

  /* Initialize system call routines and side data structures */
  sysInitialize();

  /*
   * Debugging: print out command line arguments.
   */
  if (TRACE) {
    TRACE_PRINTF("RunBootImage.main(): process %d command line arguments\n",argc);
    for (j=0; j<argc; j++) {
      TRACE_PRINTF("\targv[%d] is \"%s\"\n",j, argv[j]);
    }
  }

  /* Initialize JavaArgc, JavaArgs and initArg */
  initArgs.version = JNI_VERSION_1_4;
  initArgs.ignoreUnrecognized = JNI_TRUE;
  JavaArgs = (char **)processCommandLineArguments(&initArgs, argv, argc);

  if (TRACE) {
    TRACE_PRINTF("RunBootImage.main(): after processCommandLineArguments: %d command line arguments\n", JavaArgc);
    for (j = 0; j < JavaArgc; j++) {
      TRACE_PRINTF("\tJavaArgs[%d] is \"%s\"\n", j, JavaArgs[j]);
    }
  }


  /* Verify heap sizes for sanity. */
  if (initialHeapSize == heap_default_initial_size &&
      maximumHeapSize != heap_default_maximum_size &&
      initialHeapSize > maximumHeapSize) {
    initialHeapSize = maximumHeapSize;
  }

  if (maximumHeapSize == heap_default_maximum_size &&
      initialHeapSize != heap_default_initial_size &&
      initialHeapSize > maximumHeapSize) {
    maximumHeapSize = initialHeapSize;
  }

  if (maximumHeapSize < initialHeapSize) {
    CONSOLE_PRINTF( "%s: maximum heap size %lu MiB is less than initial heap size %lu MiB\n",
                    Me, (unsigned long) maximumHeapSize/(1024*1024),
                    (unsigned long) initialHeapSize/(1024*1024));
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }


  TRACE_PRINTF("\nRunBootImage.main(): VM variable settings\n");
  TRACE_PRINTF("initialHeapSize %lu\nmaxHeapSize %lu\n"
               "bootCodeFileName \"%s\"\nbootDataFileName \"%s\"\n"
               "bootRmapFileName \"%s\"\n"
               "verbose %d\n",
               (unsigned long) initialHeapSize,
               (unsigned long) maximumHeapSize,
               bootCodeFilename, bootDataFilename, bootRMapFilename,
               verbose);

  if (!bootCodeFilename) {
    CONSOLE_PRINTF( "%s: please specify name of boot image code file using \"-X:ic=<filename>\"\n", Me);
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  if (!bootDataFilename) {
    CONSOLE_PRINTF( "%s: please specify name of boot image data file using \"-X:id=<filename>\"\n", Me);
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  if (!bootRMapFilename) {
    CONSOLE_PRINTF( "%s: please specify name of boot image ref map file using \"-X:ir=<filename>\"\n", Me);
    return EXIT_STATUS_BOGUS_COMMAND_LINE_ARG;
  }

  ret = JNI_CreateJavaVM(&mainJavaVM, &mainJNIEnv, &initArgs);

  if (ret < 0) {
    ERROR_PRINTF("%s: Could not create the virtual machine; goodbye\n", Me);
    sysExit(EXIT_STATUS_MISC_TROUBLE);
  }
  return 0;
}
Exemple #9
0
int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) {
#else
int main(int argc, char* argv[]) {
#endif

    // Do all the standard CEF setup stuff.
    //-------------------------------------

  void * sandbox_info = nullptr;

#ifdef _WIN32
    // Enable High-DPI support on Windows 7 or newer.
  CefEnableHighDPISupport();

  // Read command line arguments.
  CefMainArgs main_args(hInstance);
#else
    // Read command line arguments.
  CefMainArgs main_args(argc, argv);
#endif

    // Create the process reference.
  CefRefPtr<loot::LootApp> app(new loot::LootApp);

  // Run the process.
  int exit_code = CefExecuteProcess(main_args, app.get(), nullptr);
  if (exit_code >= 0) {
      // The sub-process has completed so return here.
    return exit_code;
  }

#ifdef _WIN32
    // Check if LOOT is already running
    //---------------------------------

  HANDLE hMutex = ::OpenMutex(MUTEX_ALL_ACCESS, FALSE, L"LOOT.Shell.Instance");
  if (hMutex != NULL) {
      // An instance of LOOT is already running, so focus its window then quit.
    HWND hWnd = ::FindWindow(NULL, L"LOOT");
    ::SetForegroundWindow(hWnd);
    return 0;
  } else {
      //Create the mutex so that future instances will not run.
    hMutex = ::CreateMutex(NULL, FALSE, L"LOOT.Shell.Instance");
  }
#endif

  // Handle command line args (not CEF args)
  //----------------------------------------

  processCommandLineArguments(app);

  // Back to CEF
  //------------

  // Initialise CEF settings.
  CefSettings cef_settings = GetCefSettings();

#ifndef _WIN32
    // Install xlib error handlers so that the application won't be terminated
    // on non-fatal errors.
  XSetErrorHandler(XErrorHandlerImpl);
  XSetIOErrorHandler(XIOErrorHandlerImpl);
#endif

    // Initialize CEF.
  CefInitialize(main_args, cef_settings, app.get(), sandbox_info);

  // Run the CEF message loop. This will block until CefQuitMessageLoop() is called.
  CefRunMessageLoop();

  // Shut down CEF.
  CefShutdown();

#ifdef _WIN32
    // Release the program instance mutex.
  if (hMutex != NULL)
    ReleaseMutex(hMutex);
#endif

  return 0;
}