39 #include "nsXULAppAPI.h"
53 #include "nsILocalFile.h"
54 #include "nsStringGlue.h"
58 #define XRE_WANT_DLL_BLOCKLIST
60 #include "nsWindowsWMain.cpp"
63 static void Output(
const char *fmt, ... )
68 #if defined(XP_WIN) && !MOZ_WINCONSOLE
70 _vsnwprintf(msg,
sizeof(msg)/
sizeof(msg[0]), NS_ConvertUTF8toUTF16(fmt).
get(), ap);
71 MessageBoxW(NULL, msg, L
"XULRunner", MB_OK | MB_ICONERROR);
73 vfprintf(stderr, fmt, ap);
82 static PRBool
IsArg(
const char* arg,
const char* s)
88 return !PL_strcasecmp(arg, s);
91 #if defined(XP_WIN) || defined(XP_OS2)
93 return !PL_strcasecmp(++arg, s);
109 int main(
int argc,
char* argv[])
113 nsCOMPtr<nsILocalFile> appini;
114 nsresult rv = XRE_GetBinaryPath(argv[0], getter_AddRefs(appini));
116 Output(
"Couldn't calculate the application directory.");
119 appini->SetNativeLeafName(NS_LITERAL_CSTRING(
"application.ini"));
123 char *appEnv = nsnull;
124 const char *appDataFile = PR_GetEnv(
"XUL_APP_FILE");
125 if (appDataFile && *appDataFile) {
126 rv = XRE_GetFileFromPath(appDataFile, getter_AddRefs(appini));
128 Output(
"Invalid path found: '%s'", appDataFile);
132 else if (argc > 1 &&
IsArg(argv[1],
"app")) {
134 Output(
"Incorrect number of arguments passed to -app");
138 rv = XRE_GetFileFromPath(argv[2], getter_AddRefs(appini));
140 Output(
"application.ini path not recognized: '%s'", argv[2]);
144 appEnv = PR_smprintf(
"XUL_APP_FILE=%s", argv[2]);
151 nsXREAppData *appData;
152 rv = XRE_CreateAppData(appini, &appData);
154 Output(
"Couldn't read application.ini");
158 int result = XRE_main(argc, argv, appData);
159 XRE_FreeAppData(appData);
161 PR_smprintf_free(appEnv);
static PRBool IsArg(const char *arg, const char *s)
int main(int argc, char *argv[])
static void Output(const char *fmt,...)