r=pedemont, sr=blizzard (platform specific), a=mkaply
OS/2 only - fully qualify turbo daemon before trying to launch
This commit is contained in:
mkaply%us.ibm.com 2004-06-14 16:45:03 +00:00
parent 3fea0ab34d
commit e11fb1858e

View File

@ -375,7 +375,7 @@ public:
// console.
// On OS/2, we use the return from CheckConsole to determine
// whether or not to use the OS/2 specific turbo mode
nsresult CheckConsole();
PRBool CheckConsole();
private:
static HDDEDATA APIENTRY HandleDDENotification( ULONG idInst,
@ -658,9 +658,14 @@ void ThreadProc(void *splashScreen) {
PRBool gAbortServer = PR_FALSE;
nsresult
PRBool
nsNativeAppSupportOS2::CheckConsole() {
nsresult rv = NS_OK;
CHAR pszAppPath[CCHMAXPATH];
PPIB ppib;
PTIB ptib;
DosGetInfoBlocks(&ptib, &ppib);
DosQueryModuleName(ppib->pib_hmte, CCHMAXPATH, pszAppPath);
*strrchr(pszAppPath, '\\') = '\0'; // XXX DBCS misery
for ( int i = 1; i < __argc; i++ ) {
if ( strcmp( "-console", __argv[i] ) == 0
@ -674,27 +679,30 @@ nsNativeAppSupportOS2::CheckConsole() {
strcmp( "-server", __argv[i] ) == 0
||
strcmp( "/server", __argv[i] ) == 0 ) {
struct stat st;
int statrv = stat(TURBOD, &st);
CHAR pszTurboPath[CCHMAXPATH];
strcpy(pszTurboPath, pszAppPath);
strcat(pszTurboPath, "\\");
strcat(pszTurboPath, TURBOD);
int statrv = stat(pszTurboPath, &st);
/* If we can't find the turbo EXE, use the Mozilla turbo */
if (statrv == 0) {
RESULTCODES rcodes;
APIRET rc;
CHAR pszArgString[CCHMAXPATH];
strcpy(pszArgString, TURBOD);
strcpy(pszArgString, pszTurboPath);
strcat(pszArgString, " -l -p ");
strcat(pszArgString, __argv[0]);
char *pchar = strrchr(pszArgString, '\\');
pchar++;
*pchar = '\0';
pszArgString[strlen(TURBOD)] = '\0';
strcat(pszArgString, pszAppPath);
pszArgString[strlen(pszTurboPath)] = '\0';
rc = DosExecPgm(NULL,0,EXEC_BACKGROUND,
pszArgString,
0, &rcodes,
TURBOD);
rv = NS_ERROR_FAILURE;
DosExecPgm(NULL,0,EXEC_BACKGROUND,
pszArgString,
0, &rcodes,
pszTurboPath);
return PR_FALSE; /* Don't start the app */
} else {
// Start in server mode (and suppress splash screen).
mServerMode = PR_TRUE;
@ -708,23 +716,29 @@ nsNativeAppSupportOS2::CheckConsole() {
for ( int j = 1; j < __argc; j++ ) {
if (strcmp("-killAll", __argv[j]) == 0 || strcmp("/killAll", __argv[j]) == 0 ||
strcmp("-kill", __argv[j]) == 0 || strcmp("/kill", __argv[j]) == 0) {
struct stat st;
int statrv = stat(TURBOD, &st);
CHAR pszTurboPath[CCHMAXPATH];
strcpy(pszTurboPath, pszAppPath);
strcat(pszTurboPath, "\\");
strcat(pszTurboPath, TURBOD);
int statrv = stat(pszTurboPath, &st);
/* If we can't find the turbo EXE, use the Mozilla turbo */
if (statrv == 0) {
RESULTCODES rcodes;
APIRET rc;
CHAR pszArgString[CCHMAXPATH];
strcpy(pszArgString, TURBOD);
strcpy(pszArgString, pszTurboPath);
strcat(pszArgString, " -u");
pszArgString[strlen(TURBOD)] = '\0';
pszArgString[strlen(pszTurboPath)] = '\0';
rc = DosExecPgm(NULL,0,EXEC_BACKGROUND,
pszArgString,
0, &rcodes,
TURBOD);
rv = NS_ERROR_FAILURE;
DosExecPgm(NULL,0,EXEC_BACKGROUND,
pszArgString,
0, &rcodes,
pszTurboPath);
return PR_FALSE; /* Don't start the app */
} else {
gAbortServer = PR_TRUE;
}
@ -732,7 +746,7 @@ nsNativeAppSupportOS2::CheckConsole() {
}
}
return rv;
return PR_TRUE; /* Start the app */
}
@ -743,7 +757,9 @@ NS_CreateNativeAppSupport( nsINativeAppSupport **aResult ) {
nsNativeAppSupportOS2 *pNative = new nsNativeAppSupportOS2;
if ( pNative ) {
// Check for dynamic console creation request.
if NS_FAILED(pNative->CheckConsole()) {
// If CheckConsole returns PR_FALSE, we should
// start the turbo daemon and close the app.
if (pNative->CheckConsole() == PR_FALSE) {
delete pNative;
return NS_ERROR_FAILURE;
}