Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Niefer2007-02-02 16:54:33 +0000
committerAndrew Niefer2007-02-02 16:54:33 +0000
commit282b63f3254acb68da64167211f59657e421830f (patch)
tree99c4c793d304eb3f073b5772b1de59a541da5cf1
parent8d8cf89e3a82e26a1ccf3b3000f8741b0cad101c (diff)
downloadrt.equinox.framework-282b63f3254acb68da64167211f59657e421830f.tar.gz
rt.equinox.framework-282b63f3254acb68da64167211f59657e421830f.tar.xz
rt.equinox.framework-282b63f3254acb68da64167211f59657e421830f.zip
bug 170334, bug 172684, bug 172685
-rw-r--r--bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbonMain.c84
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipse.c105
-rw-r--r--bundles/org.eclipse.equinox.executable/library/eclipseMain.c25
3 files changed, 119 insertions, 95 deletions
diff --git a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbonMain.c b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbonMain.c
index 57a91e037..e08491975 100644
--- a/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbonMain.c
+++ b/bundles/org.eclipse.equinox.executable/library/carbon/eclipseCarbonMain.c
@@ -59,56 +59,56 @@ int main( int argc, char* argv[] ) {
fgPid= getpid();
dumpArgs("start", argc, argv);
-
- /* find path to application bundle (ignoring case) */
- char *pos= my_strcasestr(argv[0], APP_PACKAGE_PATTERN);
- if (pos != NULL) {
- int l= pos-argv[0] + 4; // reserve space for ".app"
- fgAppPackagePath= malloc(l+1);
- strncpy(fgAppPackagePath, argv[0], l);
- fgAppPackagePath[l]= '\0'; // terminate result
- }
-
- /* Get the main bundle for the app */
- CFBundleRef mainBundle= CFBundleGetMainBundle();
- if (mainBundle != NULL) {
-
- /* Get an instance of the info plist.*/
- CFDictionaryRef bundleInfoDict= CFBundleGetInfoDictionary(mainBundle);
-
- /* If we succeeded, look for our property. */
- if (bundleInfoDict != NULL) {
- CFArrayRef ar= CFDictionaryGetValue(bundleInfoDict, CFSTR("Eclipse"));
- if (ar) {
- CFIndex size= CFArrayGetCount(ar);
- if (size > 0) {
- int i;
- char **old_argv= argv;
- argv= (char**) calloc(size+2, sizeof(char*));
- argc= 0;
- argv[argc++]= old_argv[0];
- for (i= 0; i < size; i++) {
- CFStringRef sr= (CFStringRef) CFArrayGetValueAtIndex (ar, i);
- CFIndex argStringSize= CFStringGetMaximumSizeForEncoding(CFStringGetLength(sr), kCFStringEncodingUTF8);
- char *s= malloc(argStringSize);
- if (CFStringGetCString(sr, s, argStringSize, kCFStringEncodingUTF8)) {
- argv[argc++]= expandShell(s, fgAppPackagePath, NULL);
- } else {
- fprintf(fgConsoleLog, "can't extract bytes\n");
+ if ( (argc > 1 && strncmp(argv[1], "-psn_", 5) == 0) || argc == 1) {
+ /* find path to application bundle (ignoring case) */
+ char *pos= my_strcasestr(argv[0], APP_PACKAGE_PATTERN);
+ if (pos != NULL) {
+ int l= pos-argv[0] + 4; // reserve space for ".app"
+ fgAppPackagePath= malloc(l+1);
+ strncpy(fgAppPackagePath, argv[0], l);
+ fgAppPackagePath[l]= '\0'; // terminate result
+ }
+
+ /* Get the main bundle for the app */
+ CFBundleRef mainBundle= CFBundleGetMainBundle();
+ if (mainBundle != NULL) {
+
+ /* Get an instance of the info plist.*/
+ CFDictionaryRef bundleInfoDict= CFBundleGetInfoDictionary(mainBundle);
+
+ /* If we succeeded, look for our property. */
+ if (bundleInfoDict != NULL) {
+ CFArrayRef ar= CFDictionaryGetValue(bundleInfoDict, CFSTR("Eclipse"));
+ if (ar) {
+ CFIndex size= CFArrayGetCount(ar);
+ if (size > 0) {
+ int i;
+ char **old_argv= argv;
+ argv= (char**) calloc(size+2, sizeof(char*));
+ argc= 0;
+ argv[argc++]= old_argv[0];
+ for (i= 0; i < size; i++) {
+ CFStringRef sr= (CFStringRef) CFArrayGetValueAtIndex (ar, i);
+ CFIndex argStringSize= CFStringGetMaximumSizeForEncoding(CFStringGetLength(sr), kCFStringEncodingUTF8);
+ char *s= malloc(argStringSize);
+ if (CFStringGetCString(sr, s, argStringSize, kCFStringEncodingUTF8)) {
+ argv[argc++]= expandShell(s, fgAppPackagePath, NULL);
+ } else {
+ fprintf(fgConsoleLog, "can't extract bytes\n");
+ }
+ //free(s);
}
- //free(s);
}
+ } else {
+ fprintf(fgConsoleLog, "no Eclipse dict found\n");
}
} else {
- fprintf(fgConsoleLog, "no Eclipse dict found\n");
+ fprintf(fgConsoleLog, "no bundle dict found\n");
}
} else {
- fprintf(fgConsoleLog, "no bundle dict found\n");
+ fprintf(fgConsoleLog, "no bundle found\n");
}
- } else {
- fprintf(fgConsoleLog, "no bundle found\n");
}
-
int exitcode= original_main(argc, argv);
debug("<<<< exit(%d)\n", exitcode);
fclose(fgConsoleLog);
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipse.c b/bundles/org.eclipse.equinox.executable/library/eclipse.c
index d09b14c22..884825732 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipse.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipse.c
@@ -270,6 +270,7 @@ companion startup.jar file (in the same directory as the executable).");
#define CP _T_ECLIPSE("-cp")
#define CLASSPATH _T_ECLIPSE("-classpath")
#define JAR _T_ECLIPSE("-jar")
+#define NOERROR _T_ECLIPSE("-suppressErrors")
/* constants for ee options file */
#define EE_EXECUTABLE _T_ECLIPSE("-Dee.executable=")
@@ -281,6 +282,7 @@ companion startup.jar file (in the same directory as the executable).");
static int needConsole = 0; /* True: user wants a console */
static int debug = 0; /* True: output debugging info */
static int noSplash = 0; /* True: do not show splash win */
+static int suppressErrors = 0; /* True: do not display errors dialogs */
static _TCHAR* showSplashArg = NULL; /* showsplash data (main launcher window) */
static _TCHAR * startupArg = NULL; /* path of the startup.jar the user wants to run relative to the program path */
@@ -307,6 +309,7 @@ static Option options[] = {
{ CONSOLELOG, NULL, &needConsole, 0 },
{ DEBUG, NULL, &debug, 0 },
{ NOSPLASH, NULL, &noSplash, 1 },
+ { NOERROR, NULL, &suppressErrors, 1},
{ LIBRARY, NULL, NULL, 2 }, /* library was parsed by exe, just remove it */
{ OS, &osArg, NULL, 2 },
{ OSARCH, &osArchArg, NULL, 2 },
@@ -386,20 +389,24 @@ JNIEXPORT int run(int argc, _TCHAR* argv[], _TCHAR* vmArgs[])
programDir = getProgramDir();
if (programDir == NULL)
{
- errorMsg = malloc( (_tcslen(homeMsg) + _tcslen(officialName) + 10) * sizeof(_TCHAR) );
- _stprintf( errorMsg, homeMsg, officialName );
- displayMessage( officialName, errorMsg );
- free( errorMsg );
+ if (!suppressErrors) {
+ errorMsg = malloc( (_tcslen(homeMsg) + _tcslen(officialName) + 10) * sizeof(_TCHAR) );
+ _stprintf( errorMsg, homeMsg, officialName );
+ displayMessage( officialName, errorMsg );
+ free( errorMsg );
+ }
exit( 1 );
}
launchMode = determineVM(&msg);
if (launchMode == -1) {
/* problem */
- errorMsg = malloc((_tcslen(noVMMsg) + _tcslen(officialName) + _tcslen(msg) + 1) * sizeof(_TCHAR));
- _stprintf( errorMsg, noVMMsg, officialName, msg );
- displayMessage( officialName, errorMsg );
- free( errorMsg );
+ if (!suppressErrors) {
+ errorMsg = malloc((_tcslen(noVMMsg) + _tcslen(officialName) + _tcslen(msg) + 1) * sizeof(_TCHAR));
+ _stprintf( errorMsg, noVMMsg, officialName, msg );
+ displayMessage( officialName, errorMsg );
+ free( errorMsg );
+ }
free( msg );
exit(1);
}
@@ -407,10 +414,12 @@ JNIEXPORT int run(int argc, _TCHAR* argv[], _TCHAR* vmArgs[])
/* Find the startup.jar */
jarFile = findStartupJar();
if(jarFile == NULL) {
- errorMsg = malloc( (_tcslen(startupMsg) + _tcslen(officialName) + 10) * sizeof(_TCHAR) );
- _stprintf( errorMsg, startupMsg, officialName );
- displayMessage( officialName, errorMsg );
- free( errorMsg );
+ if (!suppressErrors) {
+ errorMsg = malloc( (_tcslen(startupMsg) + _tcslen(officialName) + 10) * sizeof(_TCHAR) );
+ _stprintf( errorMsg, startupMsg, officialName );
+ displayMessage( officialName, errorMsg );
+ free( errorMsg );
+ }
exit( 1 );
}
@@ -428,8 +437,8 @@ JNIEXPORT int run(int argc, _TCHAR* argv[], _TCHAR* vmArgs[])
/* not using JNI launching, need some shared data */
if (launchMode == LAUNCH_EXE && createSharedData( &sharedID, MAX_SHARED_LENGTH )) {
- if (debug) {
- if (debug) displayMessage( officialName, shareMsg );
+ if (debug && !suppressErrors) {
+ displayMessage( officialName, shareMsg );
}
}
@@ -493,46 +502,48 @@ JNIEXPORT int run(int argc, _TCHAR* argv[], _TCHAR* vmArgs[])
running = 0;
}
} else {
- if (debug) displayMessage( officialName, shareMsg );
+ if (debug && !suppressErrors) displayMessage( officialName, shareMsg );
}
break;
default: {
_TCHAR *title = _tcsdup(officialName);
running = 0;
- errorMsg = NULL;
- if (launchMode == LAUNCH_EXE) {
- if (exitData != NULL) free(exitData);
- getSharedData( sharedID, &exitData );
- }
- if (exitData != 0) {
- errorMsg = exitData;
- if (_tcslen( errorMsg ) == 0) {
- free( errorMsg );
- errorMsg = NULL;
- } else {
- _TCHAR *str;
- if (_tcsncmp(errorMsg, _T_ECLIPSE("<title>"), _tcslen(_T_ECLIPSE("<title>"))) == 0) {
- str = _tcsstr(errorMsg, _T_ECLIPSE("</title>"));
- if (str != NULL) {
- free( title );
- str[0] = _T_ECLIPSE('\0');
- title = _tcsdup( errorMsg + _tcslen(_T_ECLIPSE("<title>")) );
- str = _tcsdup( str + _tcslen(_T_ECLIPSE("</title>")) );
- free( errorMsg );
- errorMsg = str;
- }
- }
- }
- } else {
- if (debug) displayMessage( title, shareMsg );
- }
- if (errorMsg == NULL) {
- errorMsg = malloc( (_tcslen(exitMsg) + _tcslen(msg) + 10) * sizeof(_TCHAR) );
- _stprintf( errorMsg, exitMsg, exitCode, msg );
+ if(!suppressErrors) {
+ errorMsg = NULL;
+ if (launchMode == LAUNCH_EXE) {
+ if (exitData != NULL) free(exitData);
+ getSharedData( sharedID, &exitData );
+ }
+ if (exitData != 0) {
+ errorMsg = exitData;
+ if (_tcslen( errorMsg ) == 0) {
+ free( errorMsg );
+ errorMsg = NULL;
+ } else {
+ _TCHAR *str;
+ if (_tcsncmp(errorMsg, _T_ECLIPSE("<title>"), _tcslen(_T_ECLIPSE("<title>"))) == 0) {
+ str = _tcsstr(errorMsg, _T_ECLIPSE("</title>"));
+ if (str != NULL) {
+ free( title );
+ str[0] = _T_ECLIPSE('\0');
+ title = _tcsdup( errorMsg + _tcslen(_T_ECLIPSE("<title>")) );
+ str = _tcsdup( str + _tcslen(_T_ECLIPSE("</title>")) );
+ free( errorMsg );
+ errorMsg = str;
+ }
+ }
+ }
+ } else {
+ if (debug) displayMessage( title, shareMsg );
+ }
+ if (errorMsg == NULL) {
+ errorMsg = malloc( (_tcslen(exitMsg) + _tcslen(msg) + 10) * sizeof(_TCHAR) );
+ _stprintf( errorMsg, exitMsg, exitCode, msg );
+ }
+ displayMessage( title, errorMsg );
+ free( errorMsg );
}
- displayMessage( title, errorMsg );
free( title );
- free( errorMsg );
break;
}
}
diff --git a/bundles/org.eclipse.equinox.executable/library/eclipseMain.c b/bundles/org.eclipse.equinox.executable/library/eclipseMain.c
index 24de17988..5a22d539a 100644
--- a/bundles/org.eclipse.equinox.executable/library/eclipseMain.c
+++ b/bundles/org.eclipse.equinox.executable/library/eclipseMain.c
@@ -17,6 +17,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
+#include <ctype.h>
#include <locale.h>
#include <sys/stat.h>
@@ -30,6 +31,7 @@ finding the entry point.");
#define NAME _T_ECLIPSE("-name")
#define LIBRARY _T_ECLIPSE("-library")
+#define NOERROR _T_ECLIPSE("-suppressErrors")
#define VMARGS _T_ECLIPSE("-vmargs") /* special option processing required */
/* this typedef must match the run method in eclipse.c */
@@ -41,6 +43,7 @@ static _TCHAR** userVMarg = NULL; /* user specific args for the Java V
static _TCHAR* programDir = NULL; /* directory where program resides */
static _TCHAR* library = NULL; /* pathname of the eclipse shared library */
static _TCHAR* officialName = NULL;
+static int suppressErrors = 0; /* supress error dialogs */
static int createUserArgs(int configArgc, _TCHAR **configArgv, int *argc, _TCHAR ***argv);
static void parseArgs( int* argc, _TCHAR* argv[] );
@@ -118,6 +121,9 @@ int main( int argc, _TCHAR* argv[] )
/* Determine the full pathname of this program. */
program = findCommand( argv[0] );
+ if (_tcscmp(argv[0], program) != 0) {
+ argv[0] = program;
+ }
if (program == NULL)
{
#ifdef _WIN32
@@ -160,10 +166,12 @@ int main( int argc, _TCHAR* argv[] )
if(library != NULL)
handle = loadLibrary(library);
if(handle == NULL) {
- errorMsg = malloc( (_tcslen(libraryMsg) + _tcslen(officialName) + 10) * sizeof(_TCHAR) );
- _stprintf( errorMsg, libraryMsg, officialName );
- displayMessage( officialName, errorMsg );
- free( errorMsg );
+ if (!suppressErrors) {
+ errorMsg = malloc( (_tcslen(libraryMsg) + _tcslen(officialName) + 10) * sizeof(_TCHAR) );
+ _stprintf( errorMsg, libraryMsg, officialName );
+ displayMessage( officialName, errorMsg );
+ free( errorMsg );
+ }
exit( 1 );
}
@@ -171,7 +179,8 @@ int main( int argc, _TCHAR* argv[] )
if(setArgs != NULL)
setArgs(initialArgc, initialArgv, library);
else {
- displayMessage(officialName, entryMsg);
+ if(!suppressErrors)
+ displayMessage(officialName, entryMsg);
exit(1);
}
@@ -179,13 +188,15 @@ int main( int argc, _TCHAR* argv[] )
if(runMethod != NULL)
exitCode = runMethod(argc, argv, userVMarg);
else {
- displayMessage(officialName, entryMsg);
+ if(!suppressErrors)
+ displayMessage(officialName, entryMsg);
exit(1);
}
unloadLibrary(handle);
free( library );
free( programDir );
+ free( program );
free( officialName );
return exitCode;
@@ -211,6 +222,8 @@ static void parseArgs( int* pArgc, _TCHAR* argv[] )
name = argv[++index];
} else if(_tcsicmp(argv[index], LIBRARY) == 0) {
library = argv[++index];
+ } else if(_tcsicmp(argv[index], NOERROR) == 0) {
+ suppressErrors = 1;
}
}
}

Back to the top