const char		*sourceURI = nsnull;
char			*sourceURI = nsnull;
InternetSearchDataSource::BeginSearchRequest(nsIRDFResource *source, PRBool doNetworkRequest){        nsresult		rv = NS_OK;	const char		*sourceURI = nsnull;	if (NS_FAILED(rv = source->GetValueConst(&sourceURI)))		return(rv);	nsAutoString		uri;	uri.AssignWithConversion(sourceURI);	if (uri.Find("internetsearch:") != 0)		return(NS_ERROR_FAILURE);	// forget about any previous search results	ClearResults(PR_TRUE);	// forget about any previous search sites	ClearResultSearchSites();	// remember the last search query	const PRUnichar	*uriUni = uri.get();	nsCOMPtr<nsIRDFLiteral>	uriLiteral;	if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(uriUni, getter_AddRefs(uriLiteral))))	{		rv = mInner->Assert(kNC_LastSearchRoot, kNC_Ref, uriLiteral, PR_TRUE);	}	uri.Cut(0, strlen("internetsearch:"));	nsVoidArray	*engineArray = new nsVoidArray;	if (!engineArray)		return(NS_ERROR_FAILURE);	nsAutoString	text;	// parse up attributes	while(!uri.IsEmpty())	{		nsAutoString	item;		PRInt32 andOffset = uri.Find("&");		if (andOffset >= 0)		{			uri.Left(item, andOffset);			uri.Cut(0, andOffset + 1);		}		else		{			item = uri;			uri.Truncate();		}		PRInt32 equalOffset = item.Find("=");		if (equalOffset < 0)	break;				nsAutoString	attrib, value;		item.Left(attrib, equalOffset);		value = item;		value.Cut(0, equalOffset + 1);				if (!attrib.IsEmpty() && !value.IsEmpty())		{			if (attrib.LowerCaseEqualsLiteral("engine"))			{				if ((value.Find(kEngineProtocol) == 0) ||					(value.Find(kURINC_SearchCategoryEnginePrefix) == 0))				{					char	*val = ToNewCString(value);					if (val)					{						engineArray->AppendElement(val);					}				}			}			else if (attrib.LowerCaseEqualsLiteral("text"))			{				text = value;			}		}	}	mInner->Assert(source, kNC_loading, kTrueLiteral, PR_TRUE);	PRBool	requestInitiated = PR_FALSE;	// loop over specified search engines	while (engineArray->Count() > 0)	{		char *baseFilename = (char *)(engineArray->ElementAt(0));		engineArray->RemoveElementAt(0);		if (!baseFilename)	continue;#ifdef	DEBUG_SEARCH_OUTPUT		printf("Search engine to query: '%s'\n", baseFilename);#endif		nsCOMPtr<nsIRDFResource>	engine;		gRDFService->GetResource(nsDependentCString(baseFilename), getter_AddRefs(engine));		nsCRT::free(baseFilename);		baseFilename = nsnull;		if (!engine)	continue;		// if its a engine from a search category, then get its "#Name",		// and map from that back to the real engine reference; if an		// error occurs, finish processing the rest of the engines,		// don't just break/return out		if (isSearchCategoryEngineURI(engine))		{			nsCOMPtr<nsIRDFResource>	trueEngine;			rv = resolveSearchCategoryEngineURI(engine, getter_AddRefs(trueEngine));			if (NS_FAILED(rv) || (rv == NS_RDF_NO_VALUE))	return(rv);			if (!trueEngine)	continue;			engine = trueEngine;		}		// mark this as a search site		if (mInner)		{			mInner->Assert(kNC_SearchResultsSitesRoot, kNC_Child, engine, PR_TRUE);		}    if (doNetworkRequest)		{			DoSearch(source, engine, EmptyString(), text);			requestInitiated = PR_TRUE;		}	}		delete engineArray;	engineArray = nsnull;  if (!requestInitiated)	{		Stop();	}	return(rv);}