char	*basename = engineStr.ToNewCString(); if (!basename)
char	*baseFilename = engineStr.ToNewCString(); if (!baseFilename)
SearchDataSource::DoSearch(nsIRDFResource *source, nsIRDFResource *engine, nsString text){	nsresult	rv;	if (!source)		return(NS_ERROR_NULL_POINTER);	if (!engine)		return(NS_ERROR_NULL_POINTER);	if (!mInner)	{		return(NS_RDF_NO_VALUE);	}	// get data	nsAutoString		data("");	nsCOMPtr<nsIRDFNode>	dataTarget = nsnull;	if (NS_SUCCEEDED((rv = mInner->GetTarget(engine, kNC_Data, PR_TRUE, getter_AddRefs(dataTarget)))) && (dataTarget))	{		nsCOMPtr<nsIRDFLiteral>	dataLiteral = do_QueryInterface(dataTarget);		if (!dataLiteral)			return(rv);		PRUnichar	*dataUni;		if (NS_FAILED(rv = dataLiteral->GetValue(&dataUni)))			return(rv);		data = dataUni;	}	else	{		nsXPIDLCString	engineURI;		if (NS_FAILED(rv = engine->GetValue(getter_Copies(engineURI))))			return(rv);		nsAutoString	engineStr(engineURI);		if (engineStr.Find(kEngineProtocol) != 0)			return(rv);		engineStr.Cut(0, sizeof(kEngineProtocol) - 1);		char	*basename = engineStr.ToNewCString();		if (!basename)			return(rv);		basename = nsUnescape(basename);		if (!basename)			return(rv);		rv = ReadFileContents(basename, data);		delete [] basename;		basename = nsnull;		if (NS_FAILED(rv))		{			return(rv);		}		// save file contents		nsCOMPtr<nsIRDFLiteral>	dataLiteral;		if (NS_SUCCEEDED(rv = gRDFService->GetLiteral(data.GetUnicode(), getter_AddRefs(dataLiteral))))		{			if (mInner)			{				mInner->Assert(engine, kNC_Data, dataLiteral, PR_TRUE);			}		}	}	if (data.Length() < 1)		return(NS_RDF_NO_VALUE);		nsAutoString	action, method, input;	if (NS_FAILED(rv = GetData(data, "search", "action", action)))		return(rv);	if (NS_FAILED(rv = GetData(data, "search", "method", method)))		return(rv);	if (NS_FAILED(rv = GetInputs(data, text, input)))		return(rv);#ifdef	DEBUG	char *cAction = action.ToNewCString();	char *cMethod = method.ToNewCString();	char *cInput = input.ToNewCString();	printf("Search Action: '%s'\n", cAction);	printf("Search Method: '%s'\n", cMethod);	printf(" Search Input: '%s'\n\n", cInput);	if (cAction)	{		delete [] cAction;		cAction = nsnull;	}	if (cMethod)	{		delete [] cMethod;		cMethod = nsnull;	}	if (cInput)	{		delete [] cInput;		cInput = nsnull;	}#endif	if (input.Length() < 1)		return(NS_ERROR_UNEXPECTED);	if (method.EqualsIgnoreCase("get"))	{		// HTTP Get method support		action += "?";		action += input;	}	char	*searchURL = action.ToNewCString();	if (searchURL)	{		nsIURI		*url = nsnull;#ifndef NECKO        rv = NS_NewURL(&url, (const char*) searchURL);#else        rv = NS_NewURI(&url, (const char*) searchURL);#endif // NECKO		if (NS_SUCCEEDED(rv))		{			if (method.EqualsIgnoreCase("post"))			{				// HTTP Post method support			        nsCOMPtr<nsIPostToServer>	pts = do_QueryInterface(url);				if (pts)			        {			        	// construct post data to send			        	nsAutoString	postStr(POSTHEADER_PREFIX);			        	postStr.Append(input.Length(), 10);			        	postStr += POSTHEADER_SUFFIX;			        	postStr += input;					char	*postData = postStr.ToNewCString();					if (postData)					{						rv = pts->SendData(postData, (PRUint32)strlen(postData));						delete []postData;						postData = nsnull;					}			        }			}			SearchDataSourceCallback *callback = new SearchDataSourceCallback(mInner, source, engine);			if (nsnull != callback)			{#ifdef NECKO				rv = NS_OpenURI(NS_STATIC_CAST(nsIStreamListener *, callback), url);#else				rv = NS_OpenURL(url, NS_STATIC_CAST(nsIStreamListener *, callback));#endif			}		}		delete [] searchURL;		searchURL = nsnull;	}	return(NS_OK);}