xmllite: Store DTD processing mode in reader
Nikolay Sivov
nsivov at codeweavers.com
Mon Aug 27 06:19:32 CDT 2012
Store DTD processing mode in reader
-------------- next part --------------
>From 43807d8232eb1bed2545e49db7b0541d90f90a50 Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Mon, 27 Aug 2012 15:18:43 +0400
Subject: [PATCH 5/5] Store DTD processing mode in reader
---
dlls/xmllite/reader.c | 27 +++++++++++++++++++++++----
dlls/xmllite/tests/reader.c | 28 ++++++++++++++++++++++------
include/xmllite.idl | 17 +++++++++++++++++
3 files changed, 62 insertions(+), 10 deletions(-)
diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c
index 1eb462e..f4c0e94 100644
--- a/dlls/xmllite/reader.c
+++ b/dlls/xmllite/reader.c
@@ -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;
diff --git a/dlls/xmllite/tests/reader.c b/dlls/xmllite/tests/reader.c
index 1f1b2ec..8560cd6 100644
--- a/dlls/xmllite/tests/reader.c
+++ b/dlls/xmllite/tests/reader.c
@@ -33,6 +33,9 @@
DEFINE_GUID(IID_IXmlReaderInput, 0x0b3ccc9b, 0x9214, 0x428b, 0xa2, 0xae, 0xef, 0x3a, 0xa8, 0x71, 0xaf, 0xda);
+#define EXPECT_HR(hr,hr_exp) \
+ ok(hr == hr_exp, "got 0x%08x, expected 0x%08x\n", hr, hr_exp)
+
static HRESULT (WINAPI *pCreateXmlReader)(REFIID riid, void **ppvObject, IMalloc *pMalloc);
static HRESULT (WINAPI *pCreateXmlReaderInputWithEncodingName)(IUnknown *stream,
IMalloc *pMalloc,
@@ -350,34 +353,47 @@ 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);
- ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ hr = pCreateXmlReader(&IID_IXmlReader, (void**)&reader, NULL);
+ EXPECT_HR(hr, S_OK);
test_read_state(reader, XmlReadState_Closed, -1, FALSE);
+ dtd = 2;
+ hr = IXmlReader_GetProperty(reader, XmlReaderProperty_DtdProcessing, (LONG_PTR*)&dtd);
+ EXPECT_HR(hr, S_OK);
+ ok(dtd == DtdProcessing_Prohibit, "got %d\n", dtd);
+
+ dtd = 2;
+ hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing, dtd);
+ EXPECT_HR(hr, E_INVALIDARG);
+
+ hr = IXmlReader_SetProperty(reader, XmlReaderProperty_DtdProcessing, -1);
+ EXPECT_HR(hr, E_INVALIDARG);
+
/* Null input pointer, releases previous input */
hr = IXmlReader_SetInput(reader, NULL);
- ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ EXPECT_HR(hr, S_OK);
test_read_state(reader, XmlReadState_Initial, XmlReadState_Closed, FALSE);
/* test input interface selection sequence */
hr = testinput_createinstance((void**)&input);
- ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
+ EXPECT_HR(hr, S_OK);
if (hr == S_OK)
{
input_iids.count = 0;
hr = IXmlReader_SetInput(reader, input);
- ok(hr == E_NOINTERFACE, "Expected E_NOINTERFACE, got %08x\n", hr);
+ EXPECT_HR(hr, E_NOINTERFACE);
ok_iids(&input_iids, setinput_full, setinput_full_old, FALSE);
IUnknown_Release(input);
}
diff --git a/include/xmllite.idl b/include/xmllite.idl
index d416d21..9bf406c 100644
--- a/include/xmllite.idl
+++ b/include/xmllite.idl
@@ -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("{")
--
1.5.6.5
More information about the wine-patches
mailing list