msxml3: Implement IXMLParser Get/Set Factory.
[wine/multimedia.git] / dlls / msxml3 / xmlparser.c
blob154e439ad4b92e0d96905adf37cc08846f69bff8
1 /*
2 * XML Parser implementation
4 * Copyright 2011 Alistair Leslie-Hughes
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.
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.
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
20 #define COBJMACROS
22 #include "config.h"
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
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "ole2.h"
35 #include "msxml6.h"
37 #include "msxml_private.h"
39 #include "initguid.h"
40 #include "xmlparser.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
46 typedef struct _xmlparser
48 IXMLParser IXMLParser_iface;
49 IXMLNodeFactory *nodefactory;
50 LONG ref;
52 int flags;
53 } xmlparser;
55 static inline xmlparser *impl_from_IXMLParser( IXMLParser *iface )
57 return CONTAINING_RECORD(iface, xmlparser, IXMLParser_iface);
60 /*** IUnknown methods ***/
61 static HRESULT WINAPI xmlparser_QueryInterface(IXMLParser* iface, REFIID riid, void **ppvObject)
63 xmlparser *This = impl_from_IXMLParser( iface );
64 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
66 if ( IsEqualGUID( riid, &IID_IXMLParser ) ||
67 IsEqualGUID( riid, &IID_IXMLNodeSource ) ||
68 IsEqualGUID( riid, &IID_IUnknown ) )
70 *ppvObject = iface;
72 else
74 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
75 *ppvObject = NULL;
76 return E_NOINTERFACE;
79 IXMLParser_AddRef(iface);
80 return S_OK;
83 static ULONG WINAPI xmlparser_AddRef(IXMLParser* iface)
85 xmlparser *This = impl_from_IXMLParser( iface );
86 ULONG ref = InterlockedIncrement( &This->ref );
87 TRACE("(%p)->(%d)\n", This, ref);
88 return ref;
91 static ULONG WINAPI xmlparser_Release(IXMLParser* iface)
93 xmlparser *This = impl_from_IXMLParser( iface );
94 ULONG ref = InterlockedDecrement( &This->ref );
96 TRACE("(%p)->(%d)\n", This, ref);
97 if ( ref == 0 )
99 if(This->nodefactory)
100 IXMLNodeFactory_Release(This->nodefactory);
102 heap_free( This );
105 return ref;
108 /*** IXMLNodeSource methods ***/
109 static HRESULT WINAPI xmlparser_SetFactory(IXMLParser *iface, IXMLNodeFactory *pNodeFactory)
111 xmlparser *This = impl_from_IXMLParser( iface );
113 TRACE("(%p %p)\n", This, pNodeFactory);
115 if(This->nodefactory)
116 IXMLNodeFactory_Release(This->nodefactory);
118 This->nodefactory = pNodeFactory;
119 if(This->nodefactory)
120 IXMLNodeFactory_AddRef(This->nodefactory);
122 return S_OK;
125 static HRESULT WINAPI xmlparser_GetFactory(IXMLParser *iface, IXMLNodeFactory **ppNodeFactory)
127 xmlparser *This = impl_from_IXMLParser( iface );
129 TRACE("(%p, %p)\n", This, ppNodeFactory);
131 if(!ppNodeFactory)
132 return E_INVALIDARG;
134 *ppNodeFactory = This->nodefactory;
136 if(*ppNodeFactory)
137 IXMLNodeFactory_AddRef(*ppNodeFactory);
139 return S_OK;
142 static HRESULT WINAPI xmlparser_Abort(IXMLParser *iface, BSTR bstrErrorInfo)
144 xmlparser *This = impl_from_IXMLParser( iface );
146 FIXME("(%p, %s)\n", This, debugstr_w(bstrErrorInfo));
148 return E_NOTIMPL;
151 static ULONG WINAPI xmlparser_GetLineNumber(IXMLParser *iface)
153 xmlparser *This = impl_from_IXMLParser( iface );
155 FIXME("(%p)\n", This);
157 return 0;
160 static ULONG WINAPI xmlparser_GetLinePosition(IXMLParser *iface)
162 xmlparser *This = impl_from_IXMLParser( iface );
164 FIXME("(%p)\n", This);
166 return 0;
169 static ULONG WINAPI xmlparser_GetAbsolutePosition(IXMLParser *iface)
171 xmlparser *This = impl_from_IXMLParser( iface );
173 FIXME("(%p)\n", This);
175 return 0;
178 static HRESULT WINAPI xmlparser_GetLineBuffer(IXMLParser *iface, const WCHAR **ppBuf,
179 ULONG *len, ULONG *startPos)
181 xmlparser *This = impl_from_IXMLParser( iface );
183 FIXME("(%p %p %p %p)\n", This, ppBuf, len, startPos);
185 return 0;
188 static HRESULT WINAPI xmlparser_GetLastError(IXMLParser *iface)
190 xmlparser *This = impl_from_IXMLParser( iface );
192 FIXME("(%p)\n", This);
194 return E_NOTIMPL;
197 static HRESULT WINAPI xmlparser_GetErrorInfo(IXMLParser *iface, BSTR *pErrorInfo)
199 xmlparser *This = impl_from_IXMLParser( iface );
201 FIXME("(%p %p)\n", This, pErrorInfo);
203 return E_NOTIMPL;
206 static ULONG WINAPI xmlparser_GetFlags(IXMLParser *iface)
208 xmlparser *This = impl_from_IXMLParser( iface );
210 TRACE("(%p)\n", This);
212 return This->flags;
215 static HRESULT WINAPI xmlparser_GetURL(IXMLParser *iface, const WCHAR **ppBuf)
217 xmlparser *This = impl_from_IXMLParser( iface );
219 FIXME("(%p %p)\n", This, ppBuf);
221 return E_NOTIMPL;
224 /*** IXMLParser methods ***/
225 static HRESULT WINAPI xmlparser_SetURL(IXMLParser *iface,const WCHAR *pszBaseUrl,
226 const WCHAR *relativeUrl, BOOL async)
228 xmlparser *This = impl_from_IXMLParser( iface );
230 FIXME("(%p %s %s %d)\n", This, debugstr_w(pszBaseUrl), debugstr_w(relativeUrl), async);
232 return E_NOTIMPL;
235 static HRESULT WINAPI xmlparser_Load(IXMLParser *iface, BOOL bFullyAvailable,
236 IMoniker *pMon, LPBC pBC, DWORD dwMode)
238 xmlparser *This = impl_from_IXMLParser( iface );
240 FIXME("(%p %d %p %p %d)\n", This, bFullyAvailable, pMon, pBC, dwMode);
242 return E_NOTIMPL;
245 static HRESULT WINAPI xmlparser_SetInput(IXMLParser *iface, IUnknown *pStm)
247 xmlparser *This = impl_from_IXMLParser( iface );
249 FIXME("(%p %p)\n", This, pStm);
251 return E_NOTIMPL;
254 static HRESULT WINAPI xmlparser_PushData(IXMLParser *iface, const char *pData,
255 ULONG nChars, BOOL fLastBuffer)
257 xmlparser *This = impl_from_IXMLParser( iface );
259 FIXME("(%p %s %d %d)\n", This, debugstr_a(pData), nChars, fLastBuffer);
261 return E_NOTIMPL;
264 static HRESULT WINAPI xmlparser_LoadDTD(IXMLParser *iface, const WCHAR *baseUrl,
265 const WCHAR *relativeUrl)
267 xmlparser *This = impl_from_IXMLParser( iface );
269 FIXME("(%p %s %s)\n", This, debugstr_w(baseUrl), debugstr_w(relativeUrl));
271 return E_NOTIMPL;
274 static HRESULT WINAPI xmlparser_LoadEntity(IXMLParser *iface, const WCHAR *baseUrl,
275 const WCHAR *relativeUrl, BOOL fpe)
277 xmlparser *This = impl_from_IXMLParser( iface );
279 FIXME("(%p %s %s %d)\n", This, debugstr_w(baseUrl), debugstr_w(relativeUrl), fpe);
281 return E_NOTIMPL;
284 static HRESULT WINAPI xmlparser_ParseEntity(IXMLParser *iface, const WCHAR *text,
285 ULONG len, BOOL fpe)
287 xmlparser *This = impl_from_IXMLParser( iface );
289 FIXME("(%p %s %d %d)\n", This, debugstr_w(text), len, fpe);
291 return E_NOTIMPL;
294 static HRESULT WINAPI xmlparser_ExpandEntity(IXMLParser *iface, const WCHAR *text,
295 ULONG len)
297 xmlparser *This = impl_from_IXMLParser( iface );
299 FIXME("(%p %s %d)\n", This, debugstr_w(text), len);
301 return E_NOTIMPL;
304 static HRESULT WINAPI xmlparser_SetRoot(IXMLParser *iface, PVOID pRoot)
306 xmlparser *This = impl_from_IXMLParser( iface );
308 FIXME("(%p %p)\n", This, pRoot);
310 return E_NOTIMPL;
313 static HRESULT WINAPI xmlparser_GetRoot( IXMLParser *iface, PVOID *ppRoot)
315 xmlparser *This = impl_from_IXMLParser( iface );
317 FIXME("(%p %p)\n", This, ppRoot);
319 return E_NOTIMPL;
322 static HRESULT WINAPI xmlparser_Run(IXMLParser *iface, LONG chars)
324 xmlparser *This = impl_from_IXMLParser( iface );
326 FIXME("(%p %d)\n", This, chars);
328 return E_NOTIMPL;
331 static HRESULT WINAPI xmlparser_GetParserState(IXMLParser *iface)
333 xmlparser *This = impl_from_IXMLParser( iface );
335 FIXME("(%p)\n", This);
337 return E_NOTIMPL;
340 static HRESULT WINAPI xmlparser_Suspend(IXMLParser *iface)
342 xmlparser *This = impl_from_IXMLParser( iface );
344 FIXME("(%p)\n", This);
346 return E_NOTIMPL;
349 static HRESULT WINAPI xmlparser_Reset(IXMLParser *iface)
351 xmlparser *This = impl_from_IXMLParser( iface );
353 FIXME("(%p)\n", This);
355 return E_NOTIMPL;
358 static HRESULT WINAPI xmlparser_SetFlags(IXMLParser *iface, ULONG flags)
360 xmlparser *This = impl_from_IXMLParser( iface );
362 TRACE("(%p %d)\n", This, flags);
364 This->flags = flags;
366 return S_OK;
369 static HRESULT WINAPI xmlparser_SetSecureBaseURL(IXMLParser *iface, const WCHAR *baseUrl)
371 xmlparser *This = impl_from_IXMLParser( iface );
373 FIXME("(%p %s)\n", This, debugstr_w(baseUrl));
375 return E_NOTIMPL;
378 static HRESULT WINAPI xmlparser_GetSecureBaseURL( IXMLParser *iface, const WCHAR **ppBuf)
380 xmlparser *This = impl_from_IXMLParser( iface );
382 FIXME("(%p %p)\n", This, ppBuf);
384 return E_NOTIMPL;
388 static const struct IXMLParserVtbl xmlparser_vtbl =
390 xmlparser_QueryInterface,
391 xmlparser_AddRef,
392 xmlparser_Release,
393 xmlparser_SetFactory,
394 xmlparser_GetFactory,
395 xmlparser_Abort,
396 xmlparser_GetLineNumber,
397 xmlparser_GetLinePosition,
398 xmlparser_GetAbsolutePosition,
399 xmlparser_GetLineBuffer,
400 xmlparser_GetLastError,
401 xmlparser_GetErrorInfo,
402 xmlparser_GetFlags,
403 xmlparser_GetURL,
404 xmlparser_SetURL,
405 xmlparser_Load,
406 xmlparser_SetInput,
407 xmlparser_PushData,
408 xmlparser_LoadDTD,
409 xmlparser_LoadEntity,
410 xmlparser_ParseEntity,
411 xmlparser_ExpandEntity,
412 xmlparser_SetRoot,
413 xmlparser_GetRoot,
414 xmlparser_Run,
415 xmlparser_GetParserState,
416 xmlparser_Suspend,
417 xmlparser_Reset,
418 xmlparser_SetFlags,
419 xmlparser_SetSecureBaseURL,
420 xmlparser_GetSecureBaseURL
423 HRESULT XMLParser_create(IUnknown* pUnkOuter, void**ppObj)
425 xmlparser *This;
427 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
429 if (pUnkOuter)
430 FIXME("support aggregation, outer\n");
432 This = heap_alloc( sizeof(xmlparser) );
433 if(!This)
434 return E_OUTOFMEMORY;
436 This->IXMLParser_iface.lpVtbl = &xmlparser_vtbl;
437 This->nodefactory = NULL;
438 This->flags = 0;
439 This->ref = 1;
441 *ppObj = &This->IXMLParser_iface;
443 TRACE("returning iface %p\n", *ppObj);
445 return S_OK;