rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL); if (NS_FAILED(rv)) return -1;
nsCOMPtr<nsIServiceManager> servMan; NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull); nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan); NS_ASSERTION(registrar, "Null nsIComponentRegistrar"); registrar->AutoRegister(nsnull);
main(int argc, char **argv){    nsresult rv;    PRBool sync;    if (argc < 3) {        print_usage();        return -1;    }    if (PL_strcasecmp(argv[1], "-sync") == 0)        sync = PR_TRUE;    else if (PL_strcasecmp(argv[1], "-async") == 0)        sync = PR_FALSE;    else {        print_usage();        return -1;    }    rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup, NULL);    if (NS_FAILED(rv)) return -1;    // cache the io service    {        nsCOMPtr<nsIIOService> ioserv( do_GetIOService() );        NS_ADDREF(gIOService = ioserv);    }    nsCOMPtr<nsISupportsArray> urls;    rv = NS_NewISupportsArray(getter_AddRefs(urls));    if (NS_FAILED(rv)) return -1;    rv = read_file(argv[2], urls);    if (NS_FAILED(rv)) {        printf("failed reading file-of-urls\n");        return -1;    }    PRUint32 urlCount;    urls->Count(&urlCount);    PRIntervalTime start = PR_IntervalNow();    if (sync)        rv = load_sync(urls);    else        rv = load_async(urls);    if (NS_FAILED(rv)) {        printf("load failed\n");        return -1;    }    PRIntervalTime end = PR_IntervalNow();    fprintf(stderr, "read: %u urls; total time: %u milliseconds\n",            urlCount,            PR_IntervalToMilliseconds(end - start));    NS_RELEASE(gIOService);    return 0;}