*o_Result = output.ToNewCString();
*o_Result = ToNewCString(output);
nsresult writeoutto(const char* i_pURL, char** o_Result, PRBool bUseStd = PR_TRUE){    if (!o_Result || !i_pURL)        return NS_ERROR_FAILURE;    *o_Result = 0;    nsCOMPtr<nsIURI> pURL;    nsresult result = NS_OK;    if (bUseStd)     {        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((char*)i_pURL);    }    else     {        nsCOMPtr<nsIIOService> pService =                  do_GetService(kIOServiceCID, &result);        if (NS_FAILED(result))         {            cout << "Service failed!" << endl;            return NS_ERROR_FAILURE;        }           result = pService->NewURI(i_pURL, nsnull, getter_AddRefs(pURL));    }    nsCString output;    if (NS_SUCCEEDED(result))    {        nsCOMPtr<nsIURL> tURL = do_QueryInterface(pURL);        nsXPIDLCString temp;        PRInt32 port;        tURL->GetScheme(getter_Copies(temp));        output += temp ? (const char*)temp : "";        output += ',';        tURL->GetUsername(getter_Copies(temp));        output += temp ? (const char*)temp : "";        output += ',';        tURL->GetPassword(getter_Copies(temp));        output += temp ? (const char*)temp : "";        output += ',';        tURL->GetHost(getter_Copies(temp));        output += temp ? (const char*)temp : "";        output += ',';        tURL->GetPort(&port);        output.AppendInt(port);        output += ',';        tURL->GetDirectory(getter_Copies(temp));        output += temp ? (const char*)temp : "";        output += ',';        tURL->GetFileBaseName(getter_Copies(temp));        output += temp ? (const char*)temp : "";        output += ',';        tURL->GetFileExtension(getter_Copies(temp));        output += temp ? (const char*)temp : "";        output += ',';        tURL->GetParam(getter_Copies(temp));        output += temp ? (const char*)temp : "";        output += ',';        tURL->GetQuery(getter_Copies(temp));        output += temp ? (const char*)temp : "";        output += ',';        tURL->GetRef(getter_Copies(temp));        output += temp ? (const char*)temp : "";        output += ',';        tURL->GetSpec(getter_Copies(temp));        output += temp ? (const char*)temp : "";        *o_Result = output.ToNewCString();    } else {        output = "Can not create URL";        *o_Result = output.ToNewCString();    }    return NS_OK;}