ReactOS 0.4.15-dev-7681-g776c3a3
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 "config.h"
23
24#include <stdarg.h>
25#ifdef HAVE_LIBXML2
26# include <libxml/parser.h>
27# include <libxml/xmlerror.h>
28# include <libxml/HTMLtree.h>
29#endif
30
31#include "windef.h"
32#include "winbase.h"
33#include "winuser.h"
34#include "ole2.h"
35#include "msxml6.h"
36
37#include "msxml_private.h"
38
39#include "initguid.h"
40#include "xmlparser.h"
41
42#include "wine/debug.h"
43
45
46typedef struct _xmlparser
47{
48 IXMLParser IXMLParser_iface;
49 IXMLNodeFactory *nodefactory;
52
53 int flags;
56
57static inline xmlparser *impl_from_IXMLParser( IXMLParser *iface )
58{
59 return CONTAINING_RECORD(iface, xmlparser, IXMLParser_iface);
60}
61
62/*** IUnknown methods ***/
63static HRESULT WINAPI xmlparser_QueryInterface(IXMLParser* iface, REFIID riid, void **ppvObject)
64{
66 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
67
68 if ( IsEqualGUID( riid, &IID_IXMLParser ) ||
69 IsEqualGUID( riid, &IID_IXMLNodeSource ) ||
71 {
72 *ppvObject = iface;
73 }
74 else
75 {
76 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
77 *ppvObject = NULL;
78 return E_NOINTERFACE;
79 }
80
81 IXMLParser_AddRef(iface);
82 return S_OK;
83}
84
85static ULONG WINAPI xmlparser_AddRef(IXMLParser* iface)
86{
89 TRACE("(%p)->(%d)\n", This, ref);
90 return ref;
91}
92
93static ULONG WINAPI xmlparser_Release(IXMLParser* iface)
94{
97
98 TRACE("(%p)->(%d)\n", This, ref);
99 if ( ref == 0 )
100 {
101 if(This->input)
102 IUnknown_Release(This->input);
103
104 if(This->nodefactory)
105 IXMLNodeFactory_Release(This->nodefactory);
106
107 heap_free( This );
108 }
109
110 return ref;
111}
112
113/*** IXMLNodeSource methods ***/
114static HRESULT WINAPI xmlparser_SetFactory(IXMLParser *iface, IXMLNodeFactory *pNodeFactory)
115{
117
118 TRACE("(%p %p)\n", This, pNodeFactory);
119
120 if(This->nodefactory)
121 IXMLNodeFactory_Release(This->nodefactory);
122
123 This->nodefactory = pNodeFactory;
124 if(This->nodefactory)
125 IXMLNodeFactory_AddRef(This->nodefactory);
126
127 return S_OK;
128}
129
130static HRESULT WINAPI xmlparser_GetFactory(IXMLParser *iface, IXMLNodeFactory **ppNodeFactory)
131{
133
134 TRACE("(%p, %p)\n", This, ppNodeFactory);
135
136 if(!ppNodeFactory)
137 return E_INVALIDARG;
138
139 *ppNodeFactory = This->nodefactory;
140
141 if(*ppNodeFactory)
142 IXMLNodeFactory_AddRef(*ppNodeFactory);
143
144 return S_OK;
145}
146
147static HRESULT WINAPI xmlparser_Abort(IXMLParser *iface, BSTR bstrErrorInfo)
148{
150
151 FIXME("(%p, %s)\n", This, debugstr_w(bstrErrorInfo));
152
153 return E_NOTIMPL;
154}
155
156static ULONG WINAPI xmlparser_GetLineNumber(IXMLParser *iface)
157{
159
160 FIXME("(%p)\n", This);
161
162 return 0;
163}
164
165static ULONG WINAPI xmlparser_GetLinePosition(IXMLParser *iface)
166{
168
169 FIXME("(%p)\n", This);
170
171 return 0;
172}
173
175{
177
178 FIXME("(%p)\n", This);
179
180 return 0;
181}
182
183static HRESULT WINAPI xmlparser_GetLineBuffer(IXMLParser *iface, const WCHAR **ppBuf,
184 ULONG *len, ULONG *startPos)
185{
187
188 FIXME("(%p %p %p %p)\n", This, ppBuf, len, startPos);
189
190 return 0;
191}
192
193static HRESULT WINAPI xmlparser_GetLastError(IXMLParser *iface)
194{
196
197 FIXME("(%p)\n", This);
198
199 return E_NOTIMPL;
200}
201
202static HRESULT WINAPI xmlparser_GetErrorInfo(IXMLParser *iface, BSTR *pErrorInfo)
203{
205
206 FIXME("(%p %p)\n", This, pErrorInfo);
207
208 return E_NOTIMPL;
209}
210
211static ULONG WINAPI xmlparser_GetFlags(IXMLParser *iface)
212{
214
215 TRACE("(%p)\n", This);
216
217 return This->flags;
218}
219
220static HRESULT WINAPI xmlparser_GetURL(IXMLParser *iface, const WCHAR **ppBuf)
221{
223
224 FIXME("(%p %p)\n", This, ppBuf);
225
226 return E_NOTIMPL;
227}
228
229/*** IXMLParser methods ***/
230static HRESULT WINAPI xmlparser_SetURL(IXMLParser *iface,const WCHAR *pszBaseUrl,
231 const WCHAR *relativeUrl, BOOL async)
232{
234
235 FIXME("(%p %s %s %d)\n", This, debugstr_w(pszBaseUrl), debugstr_w(relativeUrl), async);
236
237 return E_NOTIMPL;
238}
239
240static HRESULT WINAPI xmlparser_Load(IXMLParser *iface, BOOL bFullyAvailable,
241 IMoniker *pMon, LPBC pBC, DWORD dwMode)
242{
244
245 FIXME("(%p %d %p %p %d)\n", This, bFullyAvailable, pMon, pBC, dwMode);
246
247 return E_NOTIMPL;
248}
249
250static HRESULT WINAPI xmlparser_SetInput(IXMLParser *iface, IUnknown *pStm)
251{
253
254 TRACE("(%p %p)\n", This, pStm);
255
256 if(!pStm)
257 return E_INVALIDARG;
258
259 if(This->input)
260 IUnknown_Release(This->input);
261
262 This->input = pStm;
263 IUnknown_AddRef(This->input);
264
265 return S_OK;
266}
267
268static HRESULT WINAPI xmlparser_PushData(IXMLParser *iface, const char *pData,
269 ULONG nChars, BOOL fLastBuffer)
270{
272
273 FIXME("(%p %s %d %d)\n", This, debugstr_a(pData), nChars, fLastBuffer);
274
275 return E_NOTIMPL;
276}
277
278static HRESULT WINAPI xmlparser_LoadDTD(IXMLParser *iface, const WCHAR *baseUrl,
279 const WCHAR *relativeUrl)
280{
282
283 FIXME("(%p %s %s)\n", This, debugstr_w(baseUrl), debugstr_w(relativeUrl));
284
285 return E_NOTIMPL;
286}
287
288static HRESULT WINAPI xmlparser_LoadEntity(IXMLParser *iface, const WCHAR *baseUrl,
289 const WCHAR *relativeUrl, BOOL fpe)
290{
292
293 FIXME("(%p %s %s %d)\n", This, debugstr_w(baseUrl), debugstr_w(relativeUrl), fpe);
294
295 return E_NOTIMPL;
296}
297
298static HRESULT WINAPI xmlparser_ParseEntity(IXMLParser *iface, const WCHAR *text,
299 ULONG len, BOOL fpe)
300{
302
303 FIXME("(%p %s %d %d)\n", This, debugstr_w(text), len, fpe);
304
305 return E_NOTIMPL;
306}
307
308static HRESULT WINAPI xmlparser_ExpandEntity(IXMLParser *iface, const WCHAR *text,
309 ULONG len)
310{
312
313 FIXME("(%p %s %d)\n", This, debugstr_w(text), len);
314
315 return E_NOTIMPL;
316}
317
318static HRESULT WINAPI xmlparser_SetRoot(IXMLParser *iface, PVOID pRoot)
319{
321
322 FIXME("(%p %p)\n", This, pRoot);
323
324 return E_NOTIMPL;
325}
326
327static HRESULT WINAPI xmlparser_GetRoot( IXMLParser *iface, PVOID *ppRoot)
328{
330
331 FIXME("(%p %p)\n", This, ppRoot);
332
333 return E_NOTIMPL;
334}
335
336static HRESULT WINAPI xmlparser_Run(IXMLParser *iface, LONG chars)
337{
339
340 FIXME("(%p %d)\n", This, chars);
341
342 return E_NOTIMPL;
343}
344
345static HRESULT WINAPI xmlparser_GetParserState(IXMLParser *iface)
346{
348
349 TRACE("(%p)\n", This);
350
351 return This->state;
352}
353
354static HRESULT WINAPI xmlparser_Suspend(IXMLParser *iface)
355{
357
358 FIXME("(%p)\n", This);
359
360 return E_NOTIMPL;
361}
362
363static HRESULT WINAPI xmlparser_Reset(IXMLParser *iface)
364{
366
367 FIXME("(%p)\n", This);
368
369 return E_NOTIMPL;
370}
371
372static HRESULT WINAPI xmlparser_SetFlags(IXMLParser *iface, ULONG flags)
373{
375
376 TRACE("(%p %d)\n", This, flags);
377
378 This->flags = flags;
379
380 return S_OK;
381}
382
383static HRESULT WINAPI xmlparser_SetSecureBaseURL(IXMLParser *iface, const WCHAR *baseUrl)
384{
386
387 FIXME("(%p %s)\n", This, debugstr_w(baseUrl));
388
389 return E_NOTIMPL;
390}
391
392static HRESULT WINAPI xmlparser_GetSecureBaseURL( IXMLParser *iface, const WCHAR **ppBuf)
393{
395
396 FIXME("(%p %p)\n", This, ppBuf);
397
398 return E_NOTIMPL;
399}
400
401
402static const struct IXMLParserVtbl xmlparser_vtbl =
403{
435};
436
438{
440
441 TRACE("(%p)\n", ppObj);
442
443 This = heap_alloc( sizeof(xmlparser) );
444 if(!This)
445 return E_OUTOFMEMORY;
446
447 This->IXMLParser_iface.lpVtbl = &xmlparser_vtbl;
448 This->nodefactory = NULL;
449 This->input = NULL;
450 This->flags = 0;
451 This->state = XMLPARSER_IDLE;
452 This->ref = 1;
453
454 *ppObj = &This->IXMLParser_iface;
455
456 TRACE("returning iface %p\n", *ppObj);
457
458 return S_OK;
459}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
const GUID IID_IUnknown
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
OLECHAR * BSTR
Definition: compat.h:2293
const WCHAR * text
Definition: package.c:1799
static HRESULT WINAPI xmlparser_GetParserState(IXMLParser *iface)
Definition: xmlparser.c:345
static HRESULT WINAPI xmlparser_GetLastError(IXMLParser *iface)
Definition: xmlparser.c:193
static HRESULT WINAPI xmlparser_SetURL(IXMLParser *iface, const WCHAR *pszBaseUrl, const WCHAR *relativeUrl, BOOL async)
Definition: xmlparser.c:230
static HRESULT WINAPI xmlparser_GetURL(IXMLParser *iface, const WCHAR **ppBuf)
Definition: xmlparser.c:220
static HRESULT WINAPI xmlparser_SetRoot(IXMLParser *iface, PVOID pRoot)
Definition: xmlparser.c:318
static HRESULT WINAPI xmlparser_GetLineBuffer(IXMLParser *iface, const WCHAR **ppBuf, ULONG *len, ULONG *startPos)
Definition: xmlparser.c:183
static HRESULT WINAPI xmlparser_GetRoot(IXMLParser *iface, PVOID *ppRoot)
Definition: xmlparser.c:327
static HRESULT WINAPI xmlparser_Run(IXMLParser *iface, LONG chars)
Definition: xmlparser.c:336
static const struct IXMLParserVtbl xmlparser_vtbl
Definition: xmlparser.c:402
static HRESULT WINAPI xmlparser_GetErrorInfo(IXMLParser *iface, BSTR *pErrorInfo)
Definition: xmlparser.c:202
static HRESULT WINAPI xmlparser_GetFactory(IXMLParser *iface, IXMLNodeFactory **ppNodeFactory)
Definition: xmlparser.c:130
static ULONG WINAPI xmlparser_Release(IXMLParser *iface)
Definition: xmlparser.c:93
static HRESULT WINAPI xmlparser_SetFlags(IXMLParser *iface, ULONG flags)
Definition: xmlparser.c:372
static HRESULT WINAPI xmlparser_SetSecureBaseURL(IXMLParser *iface, const WCHAR *baseUrl)
Definition: xmlparser.c:383
static HRESULT WINAPI xmlparser_Suspend(IXMLParser *iface)
Definition: xmlparser.c:354
static HRESULT WINAPI xmlparser_QueryInterface(IXMLParser *iface, REFIID riid, void **ppvObject)
Definition: xmlparser.c:63
static HRESULT WINAPI xmlparser_SetInput(IXMLParser *iface, IUnknown *pStm)
Definition: xmlparser.c:250
static HRESULT WINAPI xmlparser_Reset(IXMLParser *iface)
Definition: xmlparser.c:363
static ULONG WINAPI xmlparser_GetAbsolutePosition(IXMLParser *iface)
Definition: xmlparser.c:174
static HRESULT WINAPI xmlparser_LoadDTD(IXMLParser *iface, const WCHAR *baseUrl, const WCHAR *relativeUrl)
Definition: xmlparser.c:278
static HRESULT WINAPI xmlparser_LoadEntity(IXMLParser *iface, const WCHAR *baseUrl, const WCHAR *relativeUrl, BOOL fpe)
Definition: xmlparser.c:288
static HRESULT WINAPI xmlparser_ParseEntity(IXMLParser *iface, const WCHAR *text, ULONG len, BOOL fpe)
Definition: xmlparser.c:298
static HRESULT WINAPI xmlparser_Load(IXMLParser *iface, BOOL bFullyAvailable, IMoniker *pMon, LPBC pBC, DWORD dwMode)
Definition: xmlparser.c:240
static HRESULT WINAPI xmlparser_Abort(IXMLParser *iface, BSTR bstrErrorInfo)
Definition: xmlparser.c:147
static ULONG WINAPI xmlparser_GetFlags(IXMLParser *iface)
Definition: xmlparser.c:211
static ULONG WINAPI xmlparser_AddRef(IXMLParser *iface)
Definition: xmlparser.c:85
static HRESULT WINAPI xmlparser_PushData(IXMLParser *iface, const char *pData, ULONG nChars, BOOL fLastBuffer)
Definition: xmlparser.c:268
static HRESULT WINAPI xmlparser_SetFactory(IXMLParser *iface, IXMLNodeFactory *pNodeFactory)
Definition: xmlparser.c:114
static HRESULT WINAPI xmlparser_GetSecureBaseURL(IXMLParser *iface, const WCHAR **ppBuf)
Definition: xmlparser.c:392
static ULONG WINAPI xmlparser_GetLineNumber(IXMLParser *iface)
Definition: xmlparser.c:156
static ULONG WINAPI xmlparser_GetLinePosition(IXMLParser *iface)
Definition: xmlparser.c:165
struct _xmlparser xmlparser
static HRESULT WINAPI xmlparser_ExpandEntity(IXMLParser *iface, const WCHAR *text, ULONG len)
Definition: xmlparser.c:308
static xmlparser * impl_from_IXMLParser(IXMLParser *iface)
Definition: xmlparser.c:57
HRESULT XMLParser_create(void **ppObj)
Definition: xmlparser.c:437
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:48
IXMLNodeFactory * nodefactory
Definition: xmlparser.c:49
LONG ref
Definition: xmlparser.c:51
XML_PARSER_STATE state
Definition: xmlparser.c:54
int flags
Definition: xmlparser.c:53
IUnknown * input
Definition: xmlparser.c:50
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
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define WINAPI
Definition: msvc.h:6
#define E_NOINTERFACE
Definition: winerror.h:2364
__wchar_t WCHAR
Definition: xmlstorage.h:180