result = NS_AutoregisterComponents(); if (NS_FAILED(result)) return result;
nsCOMPtr<nsIServiceManager> servMan; NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull); nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan); NS_ASSERTION(registrar, "Null nsIComponentRegistrar"); registrar->AutoRegister(nsnull);
int main(int argc, char **argv){    int rv = -1;    nsresult result = NS_OK;    if (argc < 2) {        printusage();        return NS_OK;    }    result = NS_AutoregisterComponents();    if (NS_FAILED(result)) return result;    // end of all messages from register components...    cout << "------------------" << endl << endl;     PRInt32 urlFactory = URL_FACTORY_DEFAULT;    PRBool bMakeAbs= PR_FALSE;    char* relativePath = 0;    char* url = 0;    for (int i=1; i<argc; i++) {        if (PL_strcasecmp(argv[i], "-std") == 0)         {            urlFactory = URL_FACTORY_STDURL;            if (i+1 >= argc)            {                printusage();                return NS_OK;            }        }        else if (PL_strcasecmp(argv[i], "-abs") == 0)        {            if (!gFileIO)             {                relativePath = argv[i+1];                 i++;            }            bMakeAbs = PR_TRUE;        }        else if (PL_strcasecmp(argv[i], "-file") == 0)        {            if (i+1 >= argc)            {                printusage();                return NS_OK;            }            gFileIO = argv[i+1];            i++;        }        else        {            url = argv[i];        }    }    PRTime startTime = PR_Now();    if (bMakeAbs)    {        rv = (url && relativePath) ?  doMakeAbsTest(url, relativePath) :             doMakeAbsTest();    }    else    {        rv = gFileIO ? testURL(0, urlFactory) : testURL(url, urlFactory);    }    if (gFileIO)    {        PRTime endTime = PR_Now();        printf("Elapsed time: %d micros.\n", (PRInt32)             (endTime - startTime));    }    return rv;}