diff -U 8 -prN /home/agomes/Desktop/consulting/getwellnetwork/M1.0/mozilla/xulrunner/stub/Makefile.in mozilla/xulrunner/stub/Makefile.in --- /home/agomes/Desktop/consulting/getwellnetwork/M1.0/mozilla/xulrunner/stub/Makefile.in 2008-03-11 19:32:26.000000000 -0400 +++ mozilla/xulrunner/stub/Makefile.in 2009-03-22 17:00:18.000000000 -0400 @@ -59,16 +59,17 @@ USE_STATIC_LIBS = 1 PROGRAM = $(XULRUNNER_STUB_NAME)$(BIN_SUFFIX) LOCAL_INCLUDES = -I$(topsrcdir)/xpcom/build DEFINES += -DXPCOM_GLUE LIBS = \ $(XPCOM_STANDALONE_GLUE_LDOPTS) \ + $(NSPR_LIBS) \ $(NULL) # Need to link with CoreFoundation on Mac ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT))) LIBS += \ $(TK_LIBS) \ $(NULL) endif diff -U 8 -prN /home/agomes/Desktop/consulting/getwellnetwork/M1.0/mozilla/xulrunner/stub/nsXULStub.cpp mozilla/xulrunner/stub/nsXULStub.cpp --- /home/agomes/Desktop/consulting/getwellnetwork/M1.0/mozilla/xulrunner/stub/nsXULStub.cpp 2008-04-09 02:49:41.000000000 -0400 +++ mozilla/xulrunner/stub/nsXULStub.cpp 2009-03-22 20:39:07.000000000 -0400 @@ -33,16 +33,19 @@ * the provisions above, a recipient may use your version of this file under * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ #include "nsXPCOMGlue.h" #include "nsINIParser.h" #include "prtypes.h" +#include "prenv.h" +#include "plstr.h" +#include "prprf.h" #include "nsXPCOMPrivate.h" // for XP MAXPATHLEN #include "nsMemory.h" // for NS_ARRAY_LENGTH #include "nsXULAppAPI.h" #include "nsILocalFile.h" #include #ifdef XP_WIN @@ -100,16 +103,36 @@ static void Output(PRBool isError, const MessageBox(NULL, msg, "XULRunner", flags); #else vfprintf(stderr, fmt, ap); #endif va_end(ap); } +/** + * Return true if |arg| matches the given argument name. + */ +static PRBool IsArg(const char* arg, const char* s) +{ + if (*arg == '-') + { + if (*++arg == '-') + ++arg; + return !PL_strcasecmp(arg, s); + } + +#if defined(XP_WIN) || defined(XP_OS2) + if (*arg == '/') + return !PL_strcasecmp(++arg, s); +#endif + + return PR_FALSE; +} + class AutoAppData { public: AutoAppData(nsILocalFile* aINIFile) : mAppData(nsnull) { nsresult rv = XRE_CreateAppData(aINIFile, &mAppData); if (NS_FAILED(rv)) mAppData = nsnull; } @@ -135,36 +158,64 @@ main(int argc, char **argv) nsresult rv; char *lastSlash; char iniPath[MAXPATHLEN]; char tmpPath[MAXPATHLEN]; char greDir[MAXPATHLEN]; PRBool greFound = PR_FALSE; + const char *appDataFile = PR_GetEnv("XUL_APP_FILE"); + if (!(appDataFile && *appDataFile)) { + if (argc > 1 && IsArg(argv[1], "app")) { + if (argc == 2) { + Output(PR_FALSE, "specify APP-FILE (optional)\n"); + return 1; + } + argv[1] = argv[0]; + ++argv; + --argc; + + appDataFile = argv[1]; + argv[1] = argv[0]; + ++argv; + --argc; + + static char kAppEnv[MAXPATHLEN]; + PR_snprintf(kAppEnv, MAXPATHLEN, "XUL_APP_FILE=%s", appDataFile); + PR_SetEnv(kAppEnv); + } + } + #if defined(XP_MACOSX) CFBundleRef appBundle = CFBundleGetMainBundle(); if (!appBundle) return 1; CFURLRef resourcesURL = CFBundleCopyResourcesDirectoryURL(appBundle); if (!resourcesURL) return 1; CFURLRef absResourcesURL = CFURLCopyAbsoluteURL(resourcesURL); CFRelease(resourcesURL); if (!absResourcesURL) return 1; + CFStringRef appDataFileStr; + appDataFileStr = (appDataFile && *appDataFile) ? + CFStringCreateWithCString(NULL, appDataFile, kCFStringEncodingUTF8) : + CFSTR("application.ini"); + CFURLRef iniFileURL = CFURLCreateCopyAppendingPathComponent(kCFAllocatorDefault, absResourcesURL, - CFSTR("application.ini"), + appDataFileStr, false); CFRelease(absResourcesURL); + CFRelease(appDataFileStr); if (!iniFileURL) return 1; CFStringRef iniPathStr = CFURLCopyFileSystemPath(iniFileURL, kCFURLPOSIXPathStyle); CFRelease(iniFileURL); if (!iniPathStr) return 1; @@ -203,39 +254,41 @@ main(int argc, char **argv) // multiple applications, we will try a series of techniques: // // 1) use realpath() on argv[0], which works unless we're loaded from the // PATH // 2) manually walk through the PATH and look for ourself // 3) give up struct stat fileStat; - - if (!realpath(argv[0], iniPath) || stat(iniPath, &fileStat)) { - const char *path = getenv("PATH"); - if (!path) - return 1; - - char *pathdup = strdup(path); - if (!pathdup) - return 1; - - PRBool found = PR_FALSE; - char *token = strtok(pathdup, ":"); - while (token) { - sprintf(tmpPath, "%s/%s", token, argv[0]); - if (realpath(tmpPath, iniPath) && stat(iniPath, &fileStat) == 0) { - found = PR_TRUE; - break; + + if (!realpath(appDataFile, iniPath) || stat(iniPath, &fileStat)) { + if (!realpath(argv[0], iniPath) || stat(iniPath, &fileStat)) { + const char *path = getenv("PATH"); + if (!path) + return 1; + + char *pathdup = strdup(path); + if (!pathdup) + return 1; + + PRBool found = PR_FALSE; + char *token = strtok(pathdup, ":"); + while (token) { + sprintf(tmpPath, "%s/%s", token, argv[0]); + if (realpath(tmpPath, iniPath) && stat(iniPath, &fileStat) == 0) { + found = PR_TRUE; + break; + } + token = strtok(NULL, ":"); } - token = strtok(NULL, ":"); + free (pathdup); + if (!found) + return 1; } - free (pathdup); - if (!found) - return 1; } #endif lastSlash = strrchr(iniPath, PATH_SEPARATOR_CHAR); if (!lastSlash) return 1; *(++lastSlash) = '\0';