rv = gEventQ->WaitForEvent(&gEvent); rv = gEventQ->HandleEvent(gEvent); #endif  #endif
gEventQ->WaitForEvent(&gEvent); gEventQ->HandleEvent(gEvent);
main(int argc, char* argv[]){    nsresult rv= (nsresult)-1;    if (argc < 2) {        printf("usage: %s [-verbose] [-file <name>] <url> <url> ... \n", argv[0]);        return -1;    }#if defined(PR_LOGGING)        gTestLog = PR_NewLogModule("Test");#endif    /*       The following code only deals with XPCOM registration stuff. and setting      up the event queues. Copied from TestSocketIO.cpp    */    rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);    if (NS_FAILED(rv)) return rv;    {        // Create the Event Queue for this thread...        nsCOMPtr<nsIEventQueueService> eventQService =                 do_GetService(kEventQueueServiceCID, &rv);        if (NS_FAILED(rv)) return rv;        eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);        int i;        LOG(("Trying to load:\n"));        for (i=1; i<argc; i++) {            // Turn on verbose printing...            if (PL_strcasecmp(argv[i], "-verbose") == 0) {                gVerbose = PR_TRUE;                continue;            }            // Turn on netlib tracing...            if (PL_strcasecmp(argv[i], "-file") == 0) {                LoadURLsFromFile(argv[++i]);                continue;            }            if (PL_strcasecmp(argv[i], "-console") == 0) {                gAskUserForInput = PR_TRUE;                continue;            }            if (PL_strcasecmp(argv[i], "-resume") == 0) {                gResume = PR_TRUE;                gStartAt = atoi(argv[++i]);                continue;            }            LOG(("\t%s\n", argv[i]));            rv = StartLoadingURL(argv[i]);        }      // Enter the message pump to allow the URL load to proceed.        while ( gKeepRunning ) {#ifdef WIN32            MSG msg;            if (GetMessage(&msg, NULL, 0, 0)) {                TranslateMessage(&msg);                DispatchMessage(&msg);            } else {                gKeepRunning = 0;            }#else#ifdef XP_MAC            /* Mac stuff is missing here! */#else            PLEvent *gEvent;            rv = gEventQ->WaitForEvent(&gEvent);            rv = gEventQ->HandleEvent(gEvent);#endif /* XP_UNIX */#endif /* !WIN32 */        }    } // this scopes the nsCOMPtrs    // no nsCOMPtrs are allowed to be alive when you call NS_ShutdownXPCOM    NS_ShutdownXPCOM(nsnull);    return rv;}