rv = NS_AutoregisterComponents(); if (NS_FAILED(rv)) return rv;
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;#if defined(PR_LOGGING)    gTestFileTransportLog = PR_NewLogModule("TestFileTransport");#endif    if (argc < 2) {        printf("usage: %s <file-to-read>\n", argv[0]);        return -1;    }    char* fileName = argv[1];    rv = NS_AutoregisterComponents();    if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsIEventQueueService> eventQService =              do_GetService(kEventQueueServiceCID, &rv);    if (NS_FAILED(rv)) return rv;    rv = eventQService->CreateThreadEventQueue();    if (NS_FAILED(rv)) return rv;    rv = eventQService->GetThreadEventQueue(NS_CURRENT_THREAD, &gEventQ);    if (NS_FAILED(rv)) return rv;    rv = TestAsyncRead(fileName, 0, -1);    NS_ASSERTION(NS_SUCCEEDED(rv), "TestAsyncRead failed");    rv = TestAsyncWrite(fileName, 0, -1);    NS_ASSERTION(NS_SUCCEEDED(rv), "TestAsyncWrite failed");    rv = TestAsyncRead(fileName, 10, 100);    NS_ASSERTION(NS_SUCCEEDED(rv), "TestAsyncRead failed");    NS_RELEASE(gEventQ);    return NS_OK;}