extern "C" void * mozilla_register_error_listener (GObject *dialog) { ErrorViewerConsoleListener *listener; nsCOMPtr<nsIConsoleService> consoleService (do_GetService (NS_CONSOLESERVICE_CONTRACTID)); NS_ENSURE_TRUE (consoleService, NULL); listener = new ErrorViewerConsoleListener (); consoleService->RegisterListener (listener); listener->mDialog = dialog; return (void *) listener; }
int main (int argn, char **argv) { program_name = argv[0]; int runas = MYSERVER_RUNAS_CONSOLE; struct argp_input input; #ifndef WIN32 pid_t pid; pid_t sid; #endif string mainConf, mimeConf, vhostConf, externPath; registerSignals (); setlocale (LC_ALL, ""); setlocale (LC_TIME, "POSIX"); bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); try { Server::createInstance (); } catch (exception & e) { cerr << e.what () << endl; return 1; } catch (...) { return 1; }; /* Move to a different working directory, if necessary. */ updateWorkingDirectory (argv[0]); /* Call the parser. */ argp_parse (&myserverArgp, argn, argv, 0, 0, &input); runas = input.runas; if (input.logFileName && Server::getInstance ()->setLogLocation (input.logFileName)) { cerr << "Error setting the location for the MyServer's main log" << endl; return 1; } /* If the version flag is up, show the version and exit. */ if (input.version) { cout << "GNU MyServer " << MYSERVER_VERSION << endl << "Copyright (C) 2002-2010 Free Software Foundation, Inc." << endl << "License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>." << endl << "This is free software: you are free to change and redistribute it." << endl << "There is NO WARRANTY, to the extent permitted by law." << endl << endl << "http://www.gnu.org/software/myserver" << endl; return 0; } if (input.useForkServer) { FilesUtility::resetTmpPath (); Process::getForkServer ()->startForkServer (); } if (input.plugins) { PluginsManager *pluginsManager = Server::getInstance ()->getPluginsManager (); if (pluginsManager->quickLoad (Server::getInstance (), input.plugins)) { cerr << _("Cannot load specified plugins") << endl; return 1; } } /* Start here the MyServer execution. */ try { const char *confFileDir; #ifdef WIN32 confFileDir = "."; #else confFileDir = input.confFilesLocation; #endif if (loadConfFilesLocation (mainConf, mimeConf, vhostConf, externPath, confFileDir)) { cerr << _("Cannot find the configuration files, be sure they exist") << endl; return 1; } switch (runas) { case MYSERVER_RUNAS_SERVICE: #ifdef WIN32 runService (); #else /* Run the daemon. pid is the process ID for the forked process. Fork the process. */ pid = fork (); /* An error happened, return with errors. */ if (pid < 0) return 1; if (pid) { if (input.pidFileName) writePidfile (input.pidFileName); else writePidfile (); return 0; } /* Create a SID for the new process. */ sid = setsid (); if (sid < 0) return 1; #endif case MYSERVER_RUNAS_CONSOLE: consoleService (mainConf, mimeConf, vhostConf, externPath, genMainConf); } } catch (...) { if (input.useForkServer) Process::getForkServer ()->killServer (); return 1; }; if (input.useForkServer) Process::getForkServer ()->killServer (); return 0; }