if ( rv != NS_OK )
if ( NS_SUCEEDED(NS_OK) )
main(){    nsresult rv;    char buf[80];    // Initialize XPCOM    rv = NS_InitXPCOM(nsnull, nsnull);    if (NS_FAILED(rv))    {        printf("ERROR: XPCOM intialization error [%x].\n", rv);        return -1;    }    // Do Autoreg to make sure our component is registered. The real way of    // doing this is running the xpcom registraion tool, regxpcom, at install    // time to get components registered and not make this call everytime.    // Ignore return value.    //    // Here we use the global component manager. Note that this will cause    // linkage dependency to XPCOM library. We feel that linkage dependency    // to XPCOM is inevitable and this is simpler to code.    // To break free from such dependencies, we can GetService() the component    // manager from the service manager that is returned from NS_InitXPCOM().    // We feel that linkage dependency to XPCOM library is inevitable.    (void) nsComponentManager::AutoRegister(nsIComponentManager::NS_Startup, nsnull);    // Create an instance of our component    nsCOMPtr<oeIICal> mysample = do_CreateInstance(OE_ICAL_CONTRACTID, &rv);    if (NS_FAILED(rv))    {        printf("ERROR: Cannot create instance of component " OE_ICAL_CONTRACTID " [%x].\n"               "Debugging hint:\n"               "\tsetenv NSPR_LOG_MODULES nsComponentManager:5\n"               "\tsetenv NSPR_LOG_FILE xpcom.log\n"               "\t./TestICal\n"               "\t<check the contents for xpcom.log for possible cause of error>.\n",               rv);        return -2;    }    mysample->SetServer( "/tmp/.oecalendar" );    rv = mysample->Test();    if ( rv != NS_OK )    {        printf("ERROR: Calling oeIICal::Test()\n");        return 0;    }    printf("Test finished\n");    // Shutdown XPCOM    NS_ShutdownXPCOM(nsnull);    return 0;}