Commit b15345d4 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

msxml3: Added ISAXXMLReader_parseURL implementation.

parent 6b2e7a18
...@@ -1098,17 +1098,11 @@ static HRESULT WINAPI isaxxmlreader_putSecureBaseURL( ...@@ -1098,17 +1098,11 @@ static HRESULT WINAPI isaxxmlreader_putSecureBaseURL(
return E_NOTIMPL; return E_NOTIMPL;
} }
static HRESULT WINAPI isaxxmlreader_parse( static HRESULT parse_buffer(saxreader *This, xmlChar *buffer)
ISAXXMLReader* iface,
VARIANT varInput)
{ {
saxreader *This = impl_from_ISAXXMLReader( iface );
saxlocator *locator; saxlocator *locator;
xmlChar *data = NULL;
HRESULT hr; HRESULT hr;
TRACE("(%p)\n", This);
hr = SAXLocator_create(This, &locator); hr = SAXLocator_create(This, &locator);
if(FAILED(hr)) if(FAILED(hr))
return E_FAIL; return E_FAIL;
...@@ -1123,12 +1117,38 @@ static HRESULT WINAPI isaxxmlreader_parse( ...@@ -1123,12 +1117,38 @@ static HRESULT WINAPI isaxxmlreader_parse(
locator->pParserCtxt->sax = &locator->saxreader->sax; locator->pParserCtxt->sax = &locator->saxreader->sax;
locator->pParserCtxt->userData = locator; locator->pParserCtxt->userData = locator;
xmlSetupParserForBuffer(locator->pParserCtxt, buffer, NULL);
if(xmlParseDocument(locator->pParserCtxt)) hr = E_FAIL;
else hr = locator->ret;
if(locator->pParserCtxt)
{
locator->pParserCtxt->sax = NULL;
xmlFreeParserCtxt(locator->pParserCtxt);
locator->pParserCtxt = NULL;
}
ISAXLocator_Release((ISAXLocator*)&locator->lpSAXLocatorVtbl);
return S_OK;
}
static HRESULT WINAPI isaxxmlreader_parse(
ISAXXMLReader* iface,
VARIANT varInput)
{
saxreader *This = impl_from_ISAXXMLReader( iface );
xmlChar *data = NULL;
HRESULT hr;
TRACE("(%p)\n", This);
hr = S_OK; hr = S_OK;
switch(V_VT(&varInput)) switch(V_VT(&varInput))
{ {
case VT_BSTR: case VT_BSTR:
data = xmlChar_from_wchar(V_BSTR(&varInput)); data = xmlChar_from_wchar(V_BSTR(&varInput));
xmlSetupParserForBuffer(locator->pParserCtxt, data, NULL); hr = parse_buffer(This, data);
break; break;
case VT_ARRAY|VT_UI1: { case VT_ARRAY|VT_UI1: {
void *pSAData; void *pSAData;
...@@ -1146,7 +1166,7 @@ static HRESULT WINAPI isaxxmlreader_parse( ...@@ -1146,7 +1166,7 @@ static HRESULT WINAPI isaxxmlreader_parse(
if(hr != S_OK) break; if(hr != S_OK) break;
memcpy(data, pSAData, dataRead); memcpy(data, pSAData, dataRead);
data[dataRead] = '\0'; data[dataRead] = '\0';
xmlSetupParserForBuffer(locator->pParserCtxt, data, NULL); hr = parse_buffer(This, data);
SafeArrayUnaccessData(V_ARRAY(&varInput)); SafeArrayUnaccessData(V_ARRAY(&varInput));
break; break;
} }
...@@ -1185,7 +1205,7 @@ static HRESULT WINAPI isaxxmlreader_parse( ...@@ -1185,7 +1205,7 @@ static HRESULT WINAPI isaxxmlreader_parse(
break; break;
} }
data[dataInfo.cbSize.QuadPart] = '\0'; data[dataInfo.cbSize.QuadPart] = '\0';
xmlSetupParserForBuffer(locator->pParserCtxt, data, NULL); hr = parse_buffer(This, data);
IStream_Release(stream); IStream_Release(stream);
break; break;
} }
...@@ -1196,7 +1216,7 @@ static HRESULT WINAPI isaxxmlreader_parse( ...@@ -1196,7 +1216,7 @@ static HRESULT WINAPI isaxxmlreader_parse(
IXMLDOMDocument_get_xml(xmlDoc, &bstrData); IXMLDOMDocument_get_xml(xmlDoc, &bstrData);
data = xmlChar_from_wchar(bstrData); data = xmlChar_from_wchar(bstrData);
xmlSetupParserForBuffer(locator->pParserCtxt, data, NULL); hr = parse_buffer(This, data);
IXMLDOMDocument_Release(xmlDoc); IXMLDOMDocument_Release(xmlDoc);
hr = E_NOTIMPL; hr = E_NOTIMPL;
break; break;
...@@ -1207,20 +1227,23 @@ static HRESULT WINAPI isaxxmlreader_parse( ...@@ -1207,20 +1227,23 @@ static HRESULT WINAPI isaxxmlreader_parse(
hr = E_INVALIDARG; hr = E_INVALIDARG;
} }
if(hr == S_OK) HeapFree(GetProcessHeap(), 0, data);
{ return hr;
if(xmlParseDocument(locator->pParserCtxt)) hr = E_FAIL; }
else hr = locator->ret;
} static HRESULT saxreader_onDataAvailable(void *obj, char *ptr, DWORD len)
{
saxreader *This = obj;
xmlChar *data;
HRESULT hr;
data = HeapAlloc(GetProcessHeap(), 0, len+1);
memcpy(data, ptr, len);
data[len] = 0;
hr = parse_buffer(This, data);
if(locator->pParserCtxt)
{
locator->pParserCtxt->sax = NULL;
xmlFreeParserCtxt(locator->pParserCtxt);
locator->pParserCtxt = NULL;
}
HeapFree(GetProcessHeap(), 0, data); HeapFree(GetProcessHeap(), 0, data);
ISAXLocator_Release((ISAXLocator*)&locator->lpSAXLocatorVtbl);
return hr; return hr;
} }
...@@ -1229,9 +1252,18 @@ static HRESULT WINAPI isaxxmlreader_parseURL( ...@@ -1229,9 +1252,18 @@ static HRESULT WINAPI isaxxmlreader_parseURL(
const WCHAR *url) const WCHAR *url)
{ {
saxreader *This = impl_from_ISAXXMLReader( iface ); saxreader *This = impl_from_ISAXXMLReader( iface );
bsc_t *bsc;
HRESULT hr;
FIXME("(%p)->(%s) stub\n", This, debugstr_w(url)); TRACE("(%p)->(%s) stub\n", This, debugstr_w(url));
return E_NOTIMPL;
hr = bind_url(url, saxreader_onDataAvailable, This, &bsc);
if(FAILED(hr))
return hr;
detach_bsc(bsc);
return S_OK;
} }
static const struct ISAXXMLReaderVtbl isaxreader_vtbl = static const struct ISAXXMLReaderVtbl isaxreader_vtbl =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment