rv = gEventQ->GetEvent(&gEvent);
rv = gEventQ->WaitForEvent(&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;    }    /*       The following code only deals with XPCOM registration stuff. and setting      up the event queues. Copied from TestSocketIO.cpp    */    rv = NS_InitXPCOM(nsnull, nsnull);    if (NS_FAILED(rv)) return rv;        // Create the Event Queue for this thread...    NS_WITH_SERVICE(nsIEventQueueService, eventQService, kEventQueueServiceCID, &rv);    if (NS_FAILED(rv)) return rv;    rv = eventQService->CreateThreadEventQueue();    if (NS_FAILED(rv)) return rv;    eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);#if 0 // Jud sez     // 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, nsCookieServiceCID, &rv);    if (NS_FAILED(rv)) return rv;#endif // NECKO    int i;    printf("\nTrying 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;        }         printf("\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->GetEvent(&gEvent);    rv = gEventQ->HandleEvent(gEvent);#endif /* XP_UNIX */#endif /* !WIN32 */    }    NS_ShutdownXPCOM(nsnull);    return rv;}