cout << "CreateInstance failed" << endl;
printf("CreateInstance failed\n");
nsresult writeoutto(const char* i_pURL, char** o_Result, PRInt32 urlFactory = URL_FACTORY_DEFAULT){    if (!o_Result || !i_pURL)        return NS_ERROR_FAILURE;    *o_Result = 0;    nsCOMPtr<nsIURI> pURL;    nsresult result = NS_OK;    switch (urlFactory) {        case URL_FACTORY_STDURL: {            nsIURI* url;            result = nsComponentManager::CreateInstance(kStdURLCID, nsnull,                     NS_GET_IID(nsIURI), (void**)&url);            if (NS_FAILED(result))            {                cout << "CreateInstance failed" << endl;                return NS_ERROR_FAILURE;            }            pURL = url;            pURL->SetSpec(nsDependentCString(i_pURL));            break;        }        case URL_FACTORY_DEFAULT: {            nsCOMPtr<nsIIOService> pService =                      do_GetService(kIOServiceCID, &result);            if (NS_FAILED(result))             {                cout << "Service failed!" << endl;                return NS_ERROR_FAILURE;            }               result = pService->NewURI(nsDependentCString(i_pURL), nsnull, nsnull, getter_AddRefs(pURL));        }    }    nsCString output;    if (NS_SUCCEEDED(result))    {        nsCOMPtr<nsIURL> tURL = do_QueryInterface(pURL);        nsCAutoString temp;        PRInt32 port;        nsresult rv;#define RESULT() NS_SUCCEEDED(rv) ? temp.get() : ""        rv = tURL->GetScheme(temp);        output += RESULT();        output += ',';        rv = tURL->GetUsername(temp);        output += RESULT();        output += ',';        rv = tURL->GetPassword(temp);        output += RESULT();        output += ',';        rv = tURL->GetHost(temp);        output += RESULT();        output += ',';        rv = tURL->GetPort(&port);        output.AppendInt(port);        output += ',';        rv = tURL->GetDirectory(temp);        output += RESULT();        output += ',';        rv = tURL->GetFileBaseName(temp);        output += RESULT();        output += ',';        rv = tURL->GetFileExtension(temp);        output += RESULT();        output += ',';        rv = tURL->GetParam(temp);        output += RESULT();        output += ',';        rv = tURL->GetQuery(temp);        output += RESULT();        output += ',';        rv = tURL->GetRef(temp);        output += RESULT();        output += ',';        rv = tURL->GetSpec(temp);        output += RESULT();        *o_Result = ToNewCString(output);    } else {        output = "Can not create URL";        *o_Result = ToNewCString(output);    }    return NS_OK;}