argv2 = (char **) malloc(sizeof(char*) * (argc + 2)); argv2[0] = argv[0]; argv2[1] = "-app"; for (int i=1; i<argc; ++i) argv2[i+1] = argv[i]; argv2[argc+1] = NULL; argv = argv2; argc++;
argv[1] = argv[0]; ++argv; --argc;  static char kAppEnv[MAXPATHLEN]; PR_snprintf(kAppEnv, MAXPATHLEN, "XUL_APP_FILE=%s", appDataFile); PR_SetEnv(kAppEnv);
int main(int argc, char* argv[]){  if (argc == 1 || IsArg(argv[1], "h")                || IsArg(argv[1], "help")                || IsArg(argv[1], "?"))  {    // display additional information (XXX make localizable?)    Output(PR_FALSE,           "Mozilla XULRunner " MOZILLA_VERSION " %d\n\n"           "Usage: " XULRUNNER_PROGNAME            " [OPTIONS] [APP-FILE [APP-OPTIONS...]]\n"           "\n"           "OPTIONS\n"           "      --app        specify APP-FILE (optional)\n"           "  -h, --help       show this message\n"           "  -v, --version    show version\n"           "\n"           "APP-FILE\n"           "  Application initialization file.\n"           "\n"           "APP-OPTIONS\n"           "  Application specific options.\n",           BUILD_ID);    return 0;  }  if (argc == 2 && (IsArg(argv[1], "v") || IsArg(argv[1], "version")))  {    Output(PR_FALSE, "Mozilla XULRunner " MOZILLA_VERSION " %d\n",           BUILD_ID);    return 0;  }  geckoVersion = ParseVersion(GRE_BUILD_ID);  const char *appDataFile;  char **argv2;  if (IsArg(argv[1], "app"))  {    if (argc == 2)    {      Output(PR_TRUE, "Error: APP-FILE must be specified!\n");      return 1;    }    appDataFile = argv[2];    argv2 = NULL;  }  else  {    appDataFile = argv[1];    //    // Fix-up argv to start with -app.    //     // This is done so that we preserve our command line whenever XRE_main    // needs to restart our process.  We also don't want the supplied path to    // our application data file to be treated as a URL to load by the    // application.    //    // XXX this probably means that we need to implement a command line handler    // to consume the parameter before it is seen as a parameter by the    // application.    // XXX a better approach would be to use an evnvar.    //    argv2 = (char **) malloc(sizeof(char*) * (argc + 2));    argv2[0] = argv[0];    argv2[1] = "-app";    for (int i=1; i<argc; ++i)      argv2[i+1] = argv[i];    argv2[argc+1] = NULL;    argv = argv2;    argc++;  }  nsXREAppData appData = { sizeof(nsXREAppData), 0 };  int rv = LoadAppData(appDataFile, &appData);  if (!rv)    rv = XRE_main(argc, argv, &appData);  NS_IF_RELEASE(appData.directory);  if (argv2)    free(argv2);  return rv;}