nsAutoString rdfName = uri;
nsAutoString rdfName(uri); PRInt32 pos = rdfName.Find(':'); if (pos < 0) { NS_WARNING("bad URI for data source, missing ':'"); return NS_ERROR_FAILURE; }
ServiceImpl::GetDataSource(const char* uri, nsIRDFDataSource** aDataSource){    nsIRDFDataSource* ds =        NS_STATIC_CAST(nsIRDFDataSource*, PL_HashTableLookup(mNamedDataSources, uri));    if (ds) {        NS_ADDREF(ds);        *aDataSource = ds;        return NS_OK;    }    nsresult rv;	nsAutoString rdfName = uri;    nsAutoString dataSourceName;    PRInt32 pos = rdfName.Find(':');    if (pos < 0) return NS_ERROR_FAILURE;       // bad URI    rdfName.Right(dataSourceName, rdfName.Length() - (pos + 1));    char* name = dataSourceName.ToNewCString();    if (name == nsnull)        return NS_ERROR_OUT_OF_MEMORY;    char* progID = PR_smprintf(NS_RDF_DATASOURCE_PROGID_PREFIX "%s",                               name);    delete[] name;    if (progID == nsnull)        return NS_ERROR_OUT_OF_MEMORY;#if HACK_DONT_USE_LIBREG    nsIServiceManager* servMgr;    nsServiceManager::GetGlobalServiceManager(&servMgr);    nsIFactory* fact;    nsCID cid;    if (dataSourceName.Equals("bookmarks"))        cid = kRDFBookmarkDataSourceCID;    else if (dataSourceName.Equals("composite-datasource"))        cid = kRDFCompositeDataSourceCID;    else if (dataSourceName.Equals("in-memory-datasource"))        cid = kRDFInMemoryDataSourceCID;    else if (dataSourceName.Equals("xml-datasource"))        cid = kRDFXMLDataSourceCID;    else if (dataSourceName.Equals("xul-datasource"))        cid = kXULDataSourceCID;    else        PR_ASSERT(0);    rv = NSGetFactory(servMgr, cid,                      "", progID, &fact);    if (rv == NS_OK) {        rv = fact->CreateInstance(nsnull, nsIRDFDataSource::IID(),                                  (void**)aDataSource);        NS_RELEASE(fact);    }#else    rv = nsRepository::CreateInstance(progID, nsnull,                                      nsIRDFDataSource::IID(),                                      (void**)aDataSource);#endif    PR_smprintf_free(progID);    if (NS_FAILED(rv)) return rv;    rv = (*aDataSource)->Init(uri);    if (NS_FAILED(rv)) return rv;    return NS_OK;}