mbdriver/src/guidriver.cxx
// ===========================================================================
// After listening is established and before accepting connections,
// start the Java GUI process and the thread which tracks it.
//
After listening is established and before accepting connections,
start the Java GUI process and the thread which tracks it.
After listening is established and before accepting connections start the Java GUI process and the thread which tracks it .
void ServerToGUI::ready(Listener &listener)
{
    if (!autoStartGui) {
	guiListener = &listener;
	return;
    }
    string javacmd;
    {
	string rover_java;
	bool have_rover_java = false;
	bool rover_java_exists = false;
	if (psethome().length() > 0) {
	    have_rover_java = true;
	    rover_java = psethome();
#ifdef _WIN32
	    rover_java.append("\\jre\\bin\\java.exe");
	    struct stat s;
	    int ret = stat(rover_java.c_str(), &s);
	    if (ret == 0 && (s.st_mode & _S_IFMT) != 0) {
		rover_java_exists = true;
	    }
#else
	    rover_java.append("/jre/bin/java");
	    struct stat s;
	    int ret = stat(rover_java.c_str(), &s);
	    if (ret == 0 && (s.st_mode & S_IXUSR) != 0) {
		rover_java_exists = true;
	    }
#endif 
	}
	if (rover_java_exists) {
	    javacmd = rover_java;
	}
	else if (have_rover_java) {
	    javacmd = rover_java;
	}
    }
    string classpath = psethome();
    classpath.append("/lib/ModelBuildGUI.jar");
    string home = psethome();
    string lmode;
#ifdef ISO_CPP_HEADERS
    stringstream lmodestr;
#else
    strstream lmodestr;
#endif
    lmodestr << get_license_mode();
#ifndef ISO_CPP_HEADERS
    lmodestr << ends;
#endif
    lmode = lmodestr.str();
    static char *argv[] = {
	"-jar",									
	NULL, 
	"-service",                             
	NULL,                                   
	"-home",                                
	NULL,                                   
	"-lmode",								
	NULL,									
	"-projectFile",                         
	NULL, 
	NULL };                                 
    argv[1] = (char *)classpath.c_str();
    argv[3] = (char *)guiservice();
    argv[5] = (char *)home.c_str();
    argv[7] = (char *)lmode.c_str();
    if (projectFile == NULL) {
	argv[8] = NULL;
    }
    else {
	argv[9] = (char *)projectFile;
    }
    guiPid = start_process(javacmd.c_str(), argv, 0);
    if (guiPid == null_pid) {
	cerr << javacmd.c_str() 
	    << " " << argv[0] 
	    << " " << argv[1]
	    << " " << argv[2]
	    << " " << argv[3]
	    << " " << argv[4]
	    << " " << argv[5]
	    << " " << argv[6]
	    << " " << argv[7];
	if (argv[8] != NULL) {
	    cerr << " " << argv[8] << " " << argv[9];
	}
	cerr << endl;
	cerr << "Failed to start the GUI." << endl;
        listener.shut();
    }
    else {
	guiListener = &listener;
	Procedure *guiProcedure = new GUIThread(guiPid, listener, mutex);
	guiThread.start(*guiProcedure);
    }
}
void ServerToGUI :: ready ( Listener & listener ) { if ( ! autoStartGui ) { guiListener = & listener ; return ; } string javacmd ; { string rover_java ; bool have_rover_java = false ; bool rover_java_exists = false ; if ( psethome ( ) . length ( ) > 0 ) { have_rover_java = true ; rover_java = psethome ( ) ; #ifdef _WIN32 rover_java . append ( " \\ \\ \\ " ) ; struct stat s ; int ret = stat ( rover_java . c_str ( ) , & s ) ; if ( ret == 0 && ( s . st_mode & _S_IFMT ) != 0 ) { rover_java_exists = true ; } #else rover_java . append ( " " ) ; struct stat s ; int ret = stat ( rover_java . c_str ( ) , & s ) ; if ( ret == 0 && ( s . st_mode & S_IXUSR ) != 0 ) { rover_java_exists = true ; } #endif } if ( rover_java_exists ) { javacmd = rover_java ; } else if ( have_rover_java ) { javacmd = rover_java ; } } string classpath = psethome ( ) ; classpath . append ( " " ) ; string home = psethome ( ) ; string lmode ; #ifdef ISO_CPP_HEADERS stringstream lmodestr ; #else strstream lmodestr ; #endif lmodestr << get_license_mode ( ) ; #ifndef ISO_CPP_HEADERS lmodestr << ends ; #endif lmode = lmodestr . str ( ) ; static char * argv [ ] = { " " , NULL , " " , NULL , " " , NULL , " " , NULL , " " , NULL , NULL } ; argv [ 1 ] = ( char * ) classpath . c_str ( ) ; argv [ 3 ] = ( char * ) guiservice ( ) ; argv [ 5 ] = ( char * ) home . c_str ( ) ; argv [ 7 ] = ( char * ) lmode . c_str ( ) ; if ( projectFile == NULL ) { argv [ 8 ] = NULL ; } else { argv [ 9 ] = ( char * ) projectFile ; } guiPid = start_process ( javacmd . c_str ( ) , argv , 0 ) ; if ( guiPid == null_pid ) { cerr << javacmd . c_str ( ) << " " << argv [ 0 ] << " " << argv [ 1 ] << " " << argv [ 2 ] << " " << argv [ 3 ] << " " << argv [ 4 ] << " " << argv [ 5 ] << " " << argv [ 6 ] << " " << argv [ 7 ] ; if ( argv [ 8 ] != NULL ) { cerr << " " << argv [ 8 ] << " " << argv [ 9 ] ; } cerr << endl ; cerr << " " << endl ; listener . shut ( ) ; } else { guiListener = & listener ; Procedure * guiProcedure = new GUIThread ( guiPid , listener , mutex ) ; guiThread . start ( * guiProcedure ) ; } }
After listening is established and before accepting connections,
start the Java GUI process and the thread which tracks it.
After listening is established and before accepting connections start the Java GUI process and the thread which tracks it .
// The Gui has been started manually. // Form the process filename and args. // Look up CodeRover home directory. // Determine whether that name refers to an extant file. // Determine whether that name refers to an extant file. // _WIN32 // If doesn't exist, attempt to set the string anyway, for the diagnostic. // 0 // CLASSPATH string               // 1 // 2 // 3 // 4 // 5 // 6 // 7 // 8 // "d:/parsercmd/parsercmd.dsp",  // 9 // 10