Commit ae0b830c authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite: Store DTD processing mode in reader.

parent 5cb75c52
......@@ -44,6 +44,7 @@ typedef struct _xmlreader
ISequentialStream *stream;/* stored as sequential stream, cause currently
optimizations possible with IStream aren't implemented */
XmlReadState state;
DtdProcessing dtdmode;
UINT line, pos; /* reader position in XML stream */
} xmlreader;
......@@ -104,7 +105,7 @@ static ULONG WINAPI xmlreader_Release(IXmlReader *iface)
if (ref == 0)
{
if (This->input) IUnknown_Release(This->input);
if (This->stream) IUnknown_Release(This->stream);
if (This->stream) ISequentialStream_Release(This->stream);
HeapFree(GetProcessHeap(), 0, This);
}
......@@ -126,7 +127,7 @@ static HRESULT WINAPI xmlreader_SetInput(IXmlReader* iface, IUnknown *input)
if (This->stream)
{
IUnknown_Release(This->stream);
ISequentialStream_Release(This->stream);
This->stream = NULL;
}
......@@ -167,6 +168,9 @@ static HRESULT WINAPI xmlreader_GetProperty(IXmlReader* iface, UINT property, LO
switch (property)
{
case XmlReaderProperty_DtdProcessing:
*value = This->dtdmode;
break;
case XmlReaderProperty_ReadState:
*value = This->state;
break;
......@@ -180,8 +184,22 @@ static HRESULT WINAPI xmlreader_GetProperty(IXmlReader* iface, UINT property, LO
static HRESULT WINAPI xmlreader_SetProperty(IXmlReader* iface, UINT property, LONG_PTR value)
{
FIXME("(%p %u %lu): stub\n", iface, property, value);
return E_NOTIMPL;
xmlreader *This = impl_from_IXmlReader(iface);
TRACE("(%p %u %lu)\n", iface, property, value);
switch (property)
{
case XmlReaderProperty_DtdProcessing:
if (value < 0 || value > _DtdProcessing_Last) return E_INVALIDARG;
This->dtdmode = value;
break;
default:
FIXME("Unimplemented property (%u)\n", property);
return E_NOTIMPL;
}
return S_OK;
}
static HRESULT WINAPI xmlreader_Read(IXmlReader* iface, XmlNodeType *node_type)
......@@ -455,6 +473,7 @@ HRESULT WINAPI CreateXmlReader(REFIID riid, void **pObject, IMalloc *pMalloc)
reader->stream = NULL;
reader->input = NULL;
reader->state = XmlReadState_Closed;
reader->dtdmode = DtdProcessing_Prohibit;
reader->line = reader->pos = 0;
*pObject = &reader->IXmlReader_iface;
......
......@@ -350,19 +350,32 @@ static void test_reader_create(void)
HRESULT hr;
IXmlReader *reader;
IUnknown *input;
DtdProcessing dtd;
/* crashes native */
if (0)
{
pCreateXmlReader(&IID_IXmlReader, NULL, NULL);
pCreateXmlReader(NULL, (LPVOID*)&reader, NULL);
pCreateXmlReader(NULL, (void**)&reader, NULL);
}
hr = pCreateXmlReader(&IID_IXmlReader, (LPVOID*)&reader, NULL);
hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_read_state(reader, XmlReadState_Closed, -1, FALSE);
dtd = 2;
hr = IXmlReader_GetProperty(reader, XmlReaderProperty_DtdProcessing, (LONG_PTR*)&dtd);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
ok(dtd == DtdProcessing_Prohibit, "got %d\n", dtd);
dtd = 2;
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing, dtd);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing, -1);
ok(hr == E_INVALIDARG, "Expected E_INVALIDARG, got %08x\n", hr);
/* Null input pointer, releases previous input */
hr = IXmlReader_SetInput(reader, NULL);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
......
......@@ -88,6 +88,23 @@ cpp_quote(" XmlReadState_EndOfFile = 3,")
cpp_quote(" XmlReadState_Closed = 4")
cpp_quote("} XmlReadState;")
/* conformance levels */
cpp_quote("typedef enum XmlConformanceLevel")
cpp_quote("{")
cpp_quote(" XmlConformanceLevel_Auto = 0,")
cpp_quote(" XmlConformanceLevel_Fragment = 1,")
cpp_quote(" XmlConformanceLevel_Document = 2,")
cpp_quote(" _XmlConformanceLevel_Last = 2")
cpp_quote("} XmlConformanceLevel;")
/* DTD processing mode */
cpp_quote("typedef enum DtdProcessing")
cpp_quote("{")
cpp_quote(" DtdProcessing_Prohibit = 0,")
cpp_quote(" DtdProcessing_Parse = DtdProcessing_Prohibit + 1,")
cpp_quote(" _DtdProcessing_Last = DtdProcessing_Parse")
cpp_quote("} DtdProcessing;")
/* IXmlReader properties */
cpp_quote("typedef enum XmlReaderProperty")
cpp_quote("{")
......
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