NS_WITH_SERVICE(nsIDOMAppCoresManager, appCoresManager, kAppCoresManagerCID, &rv);  if (NS_SUCCEEDED(rv)){ if (appCoresManager->Startup() != NS_OK) { appCoresManager->Shutdown(); nsServiceManager::ReleaseService(kAppCoresManagerCID, appCoresManager); } } #ifdef DEBUG printf("started appcores\n"); #endif
static nsresult main1(int argc, char* argv[]){  nsresult rv;#ifndef XP_MAC  // Unbuffer debug output (necessary for automated QA performance scripts).  setbuf( stdout, 0 );#endif    NS_VERIFY(NS_SUCCEEDED(nsIThread::SetMainThread()), "couldn't set main thread");   InitFullCircle(); #if XP_MAC     stTSMCloser  tsmCloser;    InitializeMacCommandLine( argc, argv); #endif  // XXX: This call will be replaced by a registry initialization...  NS_SetupRegistry_1();  // Start up the core services:  // Initialize the cmd line service  NS_WITH_SERVICE(nsICmdLineService, cmdLineArgs, kCmdLineServiceCID, &rv);   if (NS_FAILED(rv)) {    fprintf(stderr, "Could not obtain CmdLine processing service\n");    return rv;  }   rv = cmdLineArgs->Initialize(argc, argv);  if (rv  == NS_ERROR_INVALID_ARG) {    PrintUsage();    return rv;  }  // Kick off appcores  NS_WITH_SERVICE(nsIDOMAppCoresManager, appCoresManager, kAppCoresManagerCID, &rv);    if (NS_SUCCEEDED(rv)){		if (appCoresManager->Startup() != NS_OK) {		  appCoresManager->Shutdown();      nsServiceManager::ReleaseService(kAppCoresManagerCID, appCoresManager);		}  }#ifdef DEBUG  printf("started appcores\n");#endif    // Create the Application Shell instance...  NS_WITH_SERVICE(nsIAppShellService, appShell, kAppShellServiceCID, &rv);  if (NS_FAILED(rv)) {    return rv;  }  rv = appShell->Initialize( cmdLineArgs );  if ( NS_FAILED(rv) ) return rv; #ifdef DEBUG  printf("initialized appshell\n");#endif  NS_WITH_SERVICE(nsIProfile, profileMgr, kProfileCID, &rv);  if ( NS_FAILED(rv) ) return rv;   rv = profileMgr->StartupWithArgs(cmdLineArgs);  if (NS_FAILED(rv)) {	return rv;  }  // if we get here, and we don't have a current profile, return a failure so we will exit  // this can happen, if the user hits Cancel or Exit in the profile manager dialogs  char *currentProfileStr = nsnull;  rv = profileMgr->GetCurrentProfile(&currentProfileStr);  if (NS_FAILED(rv) || !currentProfileStr || (PL_strlen(currentProfileStr) == 0)) {  	return NS_ERROR_FAILURE;  }  PR_FREEIF(currentProfileStr);     // rjc: now must explicitly call appshell's CreateHiddenWindow() function AFTER profile manager.  //      if the profile manager ever switches to using nsIDOMWindow stuff, this might have to change  appShell->CreateHiddenWindow();  if ( CheckAndRunPrefs(cmdLineArgs) )  	return NS_OK;  // fire up an instance of the cookie manager.  // I'm doing this using the serviceManager for convenience's sake.  // Presumably an application will init it's own cookie service a   // different way (this way works too though).  NS_WITH_SERVICE(nsICookieService, cookieService, kCookieServiceCID, &rv);  // quiet the compiler  (void)cookieService;  	// Enumerate AppShellComponenets	appShell->EnumerateAndInitializeComponents();		// This will go away once Components are handling there own commandlines	// if we have no command line arguments, we need to heed the	// "general.startup.*" prefs	// if we had no command line arguments, argc == 1.	rv = DoCommandLines( cmdLineArgs, (argc == 1) );	if ( NS_FAILED(rv) )    return rv;       // Make sure there exists at least 1 window. 	rv = Ensure1Window( cmdLineArgs );  if (NS_FAILED(rv))    return rv;  // Fire up the walletService  NS_WITH_SERVICE(nsIWalletService, walletService, kWalletServiceCID, &rv);  if ( NS_SUCCEEDED(rv) )      walletService->WALLET_FetchFromNetCenter();  NS_HideSplashScreen();  // Start main event loop  rv = appShell->Run();    /*   * Shut down the Shell instance...  This is done even if the Run(...)   * method returned an error.   */  (void) appShell->Shutdown();  return rv ;}