Changeset 15103 for release-kits/shared/search4j/search4j.cpp
- Timestamp:
- 2008-03-20T17:09:16+13:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
release-kits/shared/search4j/search4j.cpp
r15093 r15103 7 7 #include <iostream> 8 8 #include <fstream> 9 #include <string> 9 10 #include <sstream> 10 #include <string> 11 12 using namespace std; 13 14 #ifdef WINDOWS 11 15 #include <windows.h> 12 using namespace std;13 14 16 15 17 //minimal launch4j stuff … … 20 22 char foundJavaVer[128] = {0}; 21 23 24 //windows functions 25 #define popen _popen 26 #define strcmp _stricmp 27 #endif /* WINDOWS */ 28 22 29 23 30 //global variables … … 50 57 int process( string command, string &output ) { 51 58 52 FILE 59 FILE *pPipe; 53 60 54 61 /* Run command so that it writes its output to a pipe. Open this … … 57 64 char cmd[1024]; strcpy(cmd, command.c_str()); 58 65 //if ( verbose ) cout << "process(): running '" << command << "'" << endl; 59 if( (pPipe = _popen( cmd, "rt" )) == NULL ) { 66 #ifdef WINDOWS 67 if( (pPipe = popen( cmd, "rt" )) == NULL ) { 60 68 if ( verbose ) cout << "could not start process" << endl; 61 _pclose( pPipe );69 pclose( pPipe ); 62 70 return -1; 63 71 } 72 #endif 73 #ifndef WINDOWS 74 if( (pPipe = popen( cmd, "r" )) == NULL ) { 75 if ( verbose ) cout << "could not start process" << endl; 76 pclose( pPipe ); 77 return -1; 78 } 79 #endif 80 64 81 //if ( verbose ) cout << "started process" << endl; 65 82 … … 80 97 81 98 /* Close pipe and return return value of pPipe. */ 82 int code = _pclose( pPipe );99 int code = pclose( pPipe ); 83 100 return code; 84 101 } … … 116 133 string exec = ""; 117 134 exec.append( javaHome ); 135 136 #ifdef WINDOWS 118 137 exec.append( "\\bin\\java.exe" ); 138 #endif 139 140 #ifndef WINDOWS 141 exec.append( "/bin/java" ); 142 #endif 143 119 144 return exec; 120 145 } … … 181 206 command.append( "\"" ); 182 207 command.append(" -version 2>&1"); 208 //cout << "(command: " << command << ")"; 183 209 int result = process( command, output ); 210 //cout << "(output: " << output << ")"; 184 211 if ( result == 0 ) { 185 if ( _stricmp( output.substr( 0, 12 ).c_str() , "java version" ) == 0 || true ) {212 if ( strcmp( output.substr( 0, 12 ).c_str() , "java version" ) == 0 || true ) { 186 213 era = atoi( output.substr(14,1).c_str() ); 187 214 major = atoi( output.substr(16,1).c_str() ); … … 265 292 Jvm minimum; 266 293 267 294 #ifdef WINDOWS 268 295 void regSearch(HKEY hKey, const char* keyName, int searchType) { 269 296 DWORD x = 0; … … 285 312 } 286 313 } 287 314 #endif 288 315 289 316 /* … … 303 330 javaHome = getenv( "JAVA_HOME" ); 304 331 if ( javaHome != NULL ) { 332 if ( verbose ) cout << "(" << javaHome << ")"; 305 333 jvm.setJavaHome( javaHome ); 306 334 if ( jvm.check() ) { … … 322 350 javaHome = getenv( "JRE_HOME" ); 323 351 if ( javaHome != NULL ) { 352 if ( verbose ) cout << "(" << javaHome << ")"; 324 353 jvm.setJavaHome( javaHome ); 325 354 if ( jvm.check() ) { … … 335 364 if ( verbose ) { if( jvmFound ) cout << "yes" << endl; else cout << "no" << endl; } 336 365 } 337 366 367 #ifdef WINDOWS 338 368 if ( !jvmFound ) { 339 369 //try the registry - this code based on launch4j code … … 391 421 if ( verbose ) { if( jvmFound ) cout << "yes" << endl; else cout << "no" << endl; } 392 422 } 423 #endif 393 424 394 425 return jvmFound; … … 409 440 //parse commandline arguments 410 441 for (int i=1; i<argc; i++) { 411 if ( _stricmp(argv[i], "--verbose") == 0 ) {442 if ( strcmp(argv[i], "--verbose") == 0 ) { 412 443 verbose = true; 413 } else if ( _stricmp(argv[i], "--help") == 0 || _stricmp(argv[i], "--usage") == 0 ) {444 } else if ( strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "--usage") == 0 ) { 414 445 usage(); 415 446 return 0; 416 } else if ( _stricmp(argv[i], "-v") == 0 ) {447 } else if ( strcmp(argv[i], "-v") == 0 ) { 417 448 jvmProperty = Version; 418 } else if ( _stricmp(argv[i], "-e") == 0 ) {449 } else if ( strcmp(argv[i], "-e") == 0 ) { 419 450 jvmProperty = Executable; 420 } else if ( _stricmp(argv[i], "-c") == 0 ) {451 } else if ( strcmp(argv[i], "-c") == 0 ) { 421 452 action = Compare; 422 453 if ( i == argc-1 ) { … … 427 458 } 428 459 429 } else if ( _stricmp(argv[i], "-m") == 0 ) {460 } else if ( strcmp(argv[i], "-m") == 0 ) { 430 461 if ( i == argc-1 ) { 431 462 usage(); … … 439 470 } 440 471 441 } else if ( _stricmp(argv[i], "-l") == 0 ) {472 } else if ( strcmp(argv[i], "-l") == 0 ) { 442 473 action = Launch; 443 474 arg1 = argv[++i]; … … 521 552 return 0; 522 553 } 554
Note:
See TracChangeset
for help on using the changeset viewer.