ReactOS 0.4.16-dev-2206-gc56950d
xmlparser.c
Go to the documentation of this file.
1/*
2 * XML Parser implementation
3 *
4 * Copyright 2011 Alistair Leslie-Hughes
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 */
20#define COBJMACROS
21
22#include <stdarg.h>
23
24#include "ole2.h"
25
26#include "initguid.h"
27#include "xmlparser.h"
28
29#include "wine/debug.h"
30
32
33typedef struct _xmlparser
34{
35 IXMLParser IXMLParser_iface;
36 IXMLNodeFactory *nodefactory;
39
40 int flags;
43
44static inline xmlparser *impl_from_IXMLParser( IXMLParser *iface )
45{
46 return CONTAINING_RECORD(iface, xmlparser, IXMLParser_iface);
47}
48
49/*** IUnknown methods ***/
50static HRESULT WINAPI xmlparser_QueryInterface(IXMLParser* iface, REFIID riid, void **ppvObject)
51{
53 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
54
55 if ( IsEqualGUID( riid, &IID_IXMLParser ) ||
56 IsEqualGUID( riid, &IID_IXMLNodeSource ) ||
58 {
59 *ppvObject = iface;
60 }
61 else
62 {
63 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
64 *ppvObject = NULL;
65 return E_NOINTERFACE;
66 }
67
68 IXMLParser_AddRef(iface);
69 return S_OK;
70}
71
72static ULONG WINAPI xmlparser_AddRef(IXMLParser* iface)
73{
76 TRACE("%p, refcount %lu.\n", iface, ref);
77 return ref;
78}
79
80static ULONG WINAPI xmlparser_Release(IXMLParser* iface)
81{
84
85 TRACE("%p, refcount %lu.\n", iface, ref);
86 if ( ref == 0 )
87 {
88 if(This->input)
89 IUnknown_Release(This->input);
90
91 if(This->nodefactory)
92 IXMLNodeFactory_Release(This->nodefactory);
93
94 free(This);
95 }
96
97 return ref;
98}
99
100/*** IXMLNodeSource methods ***/
101static HRESULT WINAPI xmlparser_SetFactory(IXMLParser *iface, IXMLNodeFactory *pNodeFactory)
102{
104
105 TRACE("(%p %p)\n", This, pNodeFactory);
106
107 if(This->nodefactory)
108 IXMLNodeFactory_Release(This->nodefactory);
109
110 This->nodefactory = pNodeFactory;
111 if(This->nodefactory)
112 IXMLNodeFactory_AddRef(This->nodefactory);
113
114 return S_OK;
115}
116
117static HRESULT WINAPI xmlparser_GetFactory(IXMLParser *iface, IXMLNodeFactory **ppNodeFactory)
118{
120
121 TRACE("(%p, %p)\n", This, ppNodeFactory);
122
123 if(!ppNodeFactory)
124 return E_INVALIDARG;
125
126 *ppNodeFactory = This->nodefactory;
127
128 if(*ppNodeFactory)
129 IXMLNodeFactory_AddRef(*ppNodeFactory);
130
131 return S_OK;
132}
133
134static HRESULT WINAPI xmlparser_Abort(IXMLParser *iface, BSTR bstrErrorInfo)
135{
137
138 FIXME("(%p, %s)\n", This, debugstr_w(bstrErrorInfo));
139
140 return E_NOTIMPL;
141}
142
143static ULONG WINAPI xmlparser_GetLineNumber(IXMLParser *iface)
144{
146
147 FIXME("(%p)\n", This);
148
149 return 0;
150}
151
152static ULONG WINAPI xmlparser_GetLinePosition(IXMLParser *iface)
153{
155
156 FIXME("(%p)\n", This);
157
158 return 0;
159}
160
162{
164
165 FIXME("(%p)\n", This);
166
167 return 0;
168}
169
170static HRESULT WINAPI xmlparser_GetLineBuffer(IXMLParser *iface, const WCHAR **ppBuf,
171 ULONG *len, ULONG *startPos)
172{
174
175 FIXME("(%p %p %p %p)\n", This, ppBuf, len, startPos);
176
177 return 0;
178}
179
180static HRESULT WINAPI xmlparser_GetLastError(IXMLParser *iface)
181{
183
184 FIXME("(%p)\n", This);
185
186 return E_NOTIMPL;
187}
188
189static HRESULT WINAPI xmlparser_GetErrorInfo(IXMLParser *iface, BSTR *pErrorInfo)
190{
192
193 FIXME("(%p %p)\n", This, pErrorInfo);
194
195 return E_NOTIMPL;
196}
197
198static ULONG WINAPI xmlparser_GetFlags(IXMLParser *iface)
199{
201
202 TRACE("(%p)\n", This);
203
204 return This->flags;
205}
206
207static HRESULT WINAPI xmlparser_GetURL(IXMLParser *iface, const WCHAR **ppBuf)
208{
210
211 FIXME("(%p %p)\n", This, ppBuf);
212
213 return E_NOTIMPL;
214}
215
216/*** IXMLParser methods ***/
217static HRESULT WINAPI xmlparser_SetURL(IXMLParser *iface,const WCHAR *pszBaseUrl,
218 const WCHAR *relativeUrl, BOOL async)
219{
221
222 FIXME("(%p %s %s %d)\n", This, debugstr_w(pszBaseUrl), debugstr_w(relativeUrl), async);
223
224 return E_NOTIMPL;
225}
226
227static HRESULT WINAPI xmlparser_Load(IXMLParser *iface, BOOL bFullyAvailable,
228 IMoniker *pMon, LPBC pBC, DWORD dwMode)
229{
230 FIXME("%p, %d, %p, %p, %ld.\n", iface, bFullyAvailable, pMon, pBC, dwMode);
231
232 return E_NOTIMPL;
233}
234
235static HRESULT WINAPI xmlparser_SetInput(IXMLParser *iface, IUnknown *pStm)
236{
238
239 TRACE("(%p %p)\n", This, pStm);
240
241 if(!pStm)
242 return E_INVALIDARG;
243
244 if(This->input)
245 IUnknown_Release(This->input);
246
247 This->input = pStm;
248 IUnknown_AddRef(This->input);
249
250 return S_OK;
251}
252
253static HRESULT WINAPI xmlparser_PushData(IXMLParser *iface, const char *pData,
254 ULONG nChars, BOOL fLastBuffer)
255{
256 FIXME("%p, %s, %lu, %d.\n", iface, debugstr_a(pData), nChars, fLastBuffer);
257
258 return E_NOTIMPL;
259}
260
261static HRESULT WINAPI xmlparser_LoadDTD(IXMLParser *iface, const WCHAR *baseUrl,
262 const WCHAR *relativeUrl)
263{
265
266 FIXME("(%p %s %s)\n", This, debugstr_w(baseUrl), debugstr_w(relativeUrl));
267
268 return E_NOTIMPL;
269}
270
271static HRESULT WINAPI xmlparser_LoadEntity(IXMLParser *iface, const WCHAR *baseUrl,
272 const WCHAR *relativeUrl, BOOL fpe)
273{
275
276 FIXME("(%p %s %s %d)\n", This, debugstr_w(baseUrl), debugstr_w(relativeUrl), fpe);
277
278 return E_NOTIMPL;
279}
280
281static HRESULT WINAPI xmlparser_ParseEntity(IXMLParser *iface, const WCHAR *text,
282 ULONG len, BOOL fpe)
283{
284 FIXME("%p, %s, %lu, %d.\n", iface, debugstr_w(text), len, fpe);
285
286 return E_NOTIMPL;
287}
288
289static HRESULT WINAPI xmlparser_ExpandEntity(IXMLParser *iface, const WCHAR *text,
290 ULONG len)
291{
292 FIXME("%p, %s, %ld.\n", iface, debugstr_w(text), len);
293
294 return E_NOTIMPL;
295}
296
297static HRESULT WINAPI xmlparser_SetRoot(IXMLParser *iface, PVOID pRoot)
298{
300
301 FIXME("(%p %p)\n", This, pRoot);
302
303 return E_NOTIMPL;
304}
305
306static HRESULT WINAPI xmlparser_GetRoot( IXMLParser *iface, PVOID *ppRoot)
307{
309
310 FIXME("(%p %p)\n", This, ppRoot);
311
312 return E_NOTIMPL;
313}
314
315static HRESULT WINAPI xmlparser_Run(IXMLParser *iface, LONG chars)
316{
317 FIXME("%p, %ld.\n", iface, chars);
318
319 return E_NOTIMPL;
320}
321
322static HRESULT WINAPI xmlparser_GetParserState(IXMLParser *iface)
323{
325
326 TRACE("(%p)\n", This);
327
328 return This->state;
329}
330
331static HRESULT WINAPI xmlparser_Suspend(IXMLParser *iface)
332{
334
335 FIXME("(%p)\n", This);
336
337 return E_NOTIMPL;
338}
339
340static HRESULT WINAPI xmlparser_Reset(IXMLParser *iface)
341{
343
344 FIXME("(%p)\n", This);
345
346 return E_NOTIMPL;
347}
348
349static HRESULT WINAPI xmlparser_SetFlags(IXMLParser *iface, ULONG flags)
350{
352
353 TRACE("%p, %lx.\n", iface, flags);
354
355 This->flags = flags;
356
357 return S_OK;
358}
359
360static HRESULT WINAPI xmlparser_SetSecureBaseURL(IXMLParser *iface, const WCHAR *baseUrl)
361{
363
364 FIXME("(%p %s)\n", This, debugstr_w(baseUrl));
365
366 return E_NOTIMPL;
367}
368
369static HRESULT WINAPI xmlparser_GetSecureBaseURL( IXMLParser *iface, const WCHAR **ppBuf)
370{
372
373 FIXME("(%p %p)\n", This, ppBuf);
374
375 return E_NOTIMPL;
376}
377
378
379static const struct IXMLParserVtbl xmlparser_vtbl =
380{
412};
413
415{
417
418 TRACE("(%p)\n", ppObj);
419
420 This = malloc(sizeof(xmlparser));
421 if(!This)
422 return E_OUTOFMEMORY;
423
424 This->IXMLParser_iface.lpVtbl = &xmlparser_vtbl;
425 This->nodefactory = NULL;
426 This->input = NULL;
427 This->flags = 0;
428 This->state = XMLPARSER_IDLE;
429 This->ref = 1;
430
431 *ppObj = &This->IXMLParser_iface;
432
433 TRACE("returning iface %p\n", *ppObj);
434
435 return S_OK;
436}
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
const GUID IID_IUnknown
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
OLECHAR * BSTR
Definition: compat.h:2293
const WCHAR * text
Definition: package.c:1794
static HRESULT WINAPI xmlparser_GetParserState(IXMLParser *iface)
Definition: xmlparser.c:322
static HRESULT WINAPI xmlparser_GetLastError(IXMLParser *iface)
Definition: xmlparser.c:180
static HRESULT WINAPI xmlparser_SetURL(IXMLParser *iface, const WCHAR *pszBaseUrl, const WCHAR *relativeUrl, BOOL async)
Definition: xmlparser.c:217
static HRESULT WINAPI xmlparser_GetURL(IXMLParser *iface, const WCHAR **ppBuf)
Definition: xmlparser.c:207
static HRESULT WINAPI xmlparser_SetRoot(IXMLParser *iface, PVOID pRoot)
Definition: xmlparser.c:297
static HRESULT WINAPI xmlparser_GetLineBuffer(IXMLParser *iface, const WCHAR **ppBuf, ULONG *len, ULONG *startPos)
Definition: xmlparser.c:170
static HRESULT WINAPI xmlparser_GetRoot(IXMLParser *iface, PVOID *ppRoot)
Definition: xmlparser.c:306
static HRESULT WINAPI xmlparser_Run(IXMLParser *iface, LONG chars)
Definition: xmlparser.c:315
static const struct IXMLParserVtbl xmlparser_vtbl
Definition: xmlparser.c:379
static HRESULT WINAPI xmlparser_GetErrorInfo(IXMLParser *iface, BSTR *pErrorInfo)
Definition: xmlparser.c:189
static HRESULT WINAPI xmlparser_GetFactory(IXMLParser *iface, IXMLNodeFactory **ppNodeFactory)
Definition: xmlparser.c:117
static ULONG WINAPI xmlparser_Release(IXMLParser *iface)
Definition: xmlparser.c:80
static HRESULT WINAPI xmlparser_SetFlags(IXMLParser *iface, ULONG flags)
Definition: xmlparser.c:349
static HRESULT WINAPI xmlparser_SetSecureBaseURL(IXMLParser *iface, const WCHAR *baseUrl)
Definition: xmlparser.c:360
static HRESULT WINAPI xmlparser_Suspend(IXMLParser *iface)
Definition: xmlparser.c:331
static HRESULT WINAPI xmlparser_QueryInterface(IXMLParser *iface, REFIID riid, void **ppvObject)
Definition: xmlparser.c:50
static HRESULT WINAPI xmlparser_SetInput(IXMLParser *iface, IUnknown *pStm)
Definition: xmlparser.c:235
static HRESULT WINAPI xmlparser_Reset(IXMLParser *iface)
Definition: xmlparser.c:340
static ULONG WINAPI xmlparser_GetAbsolutePosition(IXMLParser *iface)
Definition: xmlparser.c:161
static HRESULT WINAPI xmlparser_LoadDTD(IXMLParser *iface, const WCHAR *baseUrl, const WCHAR *relativeUrl)
Definition: xmlparser.c:261
static HRESULT WINAPI xmlparser_LoadEntity(IXMLParser *iface, const WCHAR *baseUrl, const WCHAR *relativeUrl, BOOL fpe)
Definition: xmlparser.c:271
static HRESULT WINAPI xmlparser_ParseEntity(IXMLParser *iface, const WCHAR *text, ULONG len, BOOL fpe)
Definition: xmlparser.c:281
static HRESULT WINAPI xmlparser_Load(IXMLParser *iface, BOOL bFullyAvailable, IMoniker *pMon, LPBC pBC, DWORD dwMode)
Definition: xmlparser.c:227
static HRESULT WINAPI xmlparser_Abort(IXMLParser *iface, BSTR bstrErrorInfo)
Definition: xmlparser.c:134
static ULONG WINAPI xmlparser_GetFlags(IXMLParser *iface)
Definition: xmlparser.c:198
static ULONG WINAPI xmlparser_AddRef(IXMLParser *iface)
Definition: xmlparser.c:72
static HRESULT WINAPI xmlparser_PushData(IXMLParser *iface, const char *pData, ULONG nChars, BOOL fLastBuffer)
Definition: xmlparser.c:253
static HRESULT WINAPI xmlparser_SetFactory(IXMLParser *iface, IXMLNodeFactory *pNodeFactory)
Definition: xmlparser.c:101
static HRESULT WINAPI xmlparser_GetSecureBaseURL(IXMLParser *iface, const WCHAR **ppBuf)
Definition: xmlparser.c:369
static ULONG WINAPI xmlparser_GetLineNumber(IXMLParser *iface)
Definition: xmlparser.c:143
static ULONG WINAPI xmlparser_GetLinePosition(IXMLParser *iface)
Definition: xmlparser.c:152
struct _xmlparser xmlparser
static HRESULT WINAPI xmlparser_ExpandEntity(IXMLParser *iface, const WCHAR *text, ULONG len)
Definition: xmlparser.c:289
static xmlparser * impl_from_IXMLParser(IXMLParser *iface)
Definition: xmlparser.c:44
HRESULT XMLParser_create(void **ppObj)
Definition: xmlparser.c:414
XML_PARSER_STATE
Definition: xmlparser.idl:194
@ XMLPARSER_IDLE
Definition: xmlparser.idl:195
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
GLenum GLsizei len
Definition: glext.h:6722
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
#define debugstr_guid
Definition: kernel32.h:35
#define debugstr_a
Definition: kernel32.h:31
#define debugstr_w
Definition: kernel32.h:32
interface IBindCtx * LPBC
Definition: objfwd.h:18
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
#define TRACE(s)
Definition: solgame.cpp:4
IXMLParser IXMLParser_iface
Definition: xmlparser.c:35
IXMLNodeFactory * nodefactory
Definition: xmlparser.c:36
LONG ref
Definition: xmlparser.c:38
XML_PARSER_STATE state
Definition: xmlparser.c:41
int flags
Definition: xmlparser.c:40
IUnknown * input
Definition: xmlparser.c:37
Definition: send.c:48
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:3479
__wchar_t WCHAR
Definition: xmlstorage.h:180