2 * SAX Reader implementation
4 * Copyright 2008 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
37 #include "wine/debug.h"
39 #include "msxml_private.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
45 #include <libxml/SAX2.h>
47 typedef struct _saxreader
49 const struct IVBSAXXMLReaderVtbl *lpVtbl;
50 const struct ISAXXMLReaderVtbl *lpSAXXMLReaderVtbl;
52 struct ISAXContentHandler *contentHandler;
53 struct ISAXErrorHandler *errorHandler;
57 static inline saxreader *impl_from_IVBSAXXMLReader( IVBSAXXMLReader *iface )
59 return (saxreader *)((char*)iface - FIELD_OFFSET(saxreader, lpVtbl));
62 static inline saxreader *impl_from_ISAXXMLReader( ISAXXMLReader *iface )
64 return (saxreader *)((char*)iface - FIELD_OFFSET(saxreader, lpSAXXMLReaderVtbl));
67 /*** IVBSAXXMLReader interface ***/
68 /*** IUnknown methods ***/
69 static HRESULT WINAPI saxxmlreader_QueryInterface(IVBSAXXMLReader* iface, REFIID riid, void **ppvObject)
71 saxreader *This = impl_from_IVBSAXXMLReader( iface );
73 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
77 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
78 IsEqualGUID( riid, &IID_IDispatch ) ||
79 IsEqualGUID( riid, &IID_IVBSAXXMLReader ))
83 else if( IsEqualGUID( riid, &IID_ISAXXMLReader ))
85 *ppvObject = (ISAXXMLReader*)&This->lpSAXXMLReaderVtbl;
89 FIXME("interface %s not implemented\n", debugstr_guid(riid));
93 IVBSAXXMLReader_AddRef( iface );
98 static ULONG WINAPI saxxmlreader_AddRef(IVBSAXXMLReader* iface)
100 saxreader *This = impl_from_IVBSAXXMLReader( iface );
101 TRACE("%p\n", This );
102 return InterlockedIncrement( &This->ref );
105 static ULONG WINAPI saxxmlreader_Release(
106 IVBSAXXMLReader* iface)
108 saxreader *This = impl_from_IVBSAXXMLReader( iface );
111 TRACE("%p\n", This );
113 ref = InterlockedDecrement( &This->ref );
116 if(This->contentHandler)
117 ISAXContentHandler_Release(This->contentHandler);
119 if(This->errorHandler)
120 ISAXErrorHandler_Release(This->errorHandler);
122 HeapFree( GetProcessHeap(), 0, This );
128 static HRESULT WINAPI saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader *iface, UINT* pctinfo )
130 saxreader *This = impl_from_IVBSAXXMLReader( iface );
132 TRACE("(%p)->(%p)\n", This, pctinfo);
139 static HRESULT WINAPI saxxmlreader_GetTypeInfo(
140 IVBSAXXMLReader *iface,
141 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
143 saxreader *This = impl_from_IVBSAXXMLReader( iface );
146 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
148 hr = get_typeinfo(IVBSAXXMLReader_tid, ppTInfo);
153 static HRESULT WINAPI saxxmlreader_GetIDsOfNames(
154 IVBSAXXMLReader *iface,
161 saxreader *This = impl_from_IVBSAXXMLReader( iface );
165 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
168 if(!rgszNames || cNames == 0 || !rgDispId)
171 hr = get_typeinfo(IVBSAXXMLReader_tid, &typeinfo);
174 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
175 ITypeInfo_Release(typeinfo);
181 static HRESULT WINAPI saxxmlreader_Invoke(
182 IVBSAXXMLReader *iface,
187 DISPPARAMS* pDispParams,
189 EXCEPINFO* pExcepInfo,
192 saxreader *This = impl_from_IVBSAXXMLReader( iface );
196 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
197 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
199 hr = get_typeinfo(IVBSAXXMLReader_tid, &typeinfo);
202 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVtbl), dispIdMember, wFlags, pDispParams,
203 pVarResult, pExcepInfo, puArgErr);
204 ITypeInfo_Release(typeinfo);
210 /*** IVBSAXXMLReader methods ***/
211 static HRESULT WINAPI saxxmlreader_getFeature(
212 IVBSAXXMLReader* iface,
213 const WCHAR *pFeature,
214 VARIANT_BOOL *pValue)
216 saxreader *This = impl_from_IVBSAXXMLReader( iface );
218 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pFeature), pValue);
222 static HRESULT WINAPI saxxmlreader_putFeature(
223 IVBSAXXMLReader* iface,
224 const WCHAR *pFeature,
225 VARIANT_BOOL vfValue)
227 saxreader *This = impl_from_IVBSAXXMLReader( iface );
229 FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(pFeature), vfValue);
233 static HRESULT WINAPI saxxmlreader_getProperty(
234 IVBSAXXMLReader* iface,
238 saxreader *This = impl_from_IVBSAXXMLReader( iface );
240 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pProp), pValue);
244 static HRESULT WINAPI saxxmlreader_putProperty(
245 IVBSAXXMLReader* iface,
249 saxreader *This = impl_from_IVBSAXXMLReader( iface );
251 FIXME("(%p)->(%s) stub\n", This, debugstr_w(pProp));
255 static HRESULT WINAPI saxxmlreader_getEntityResolver(
256 IVBSAXXMLReader* iface,
257 IVBSAXEntityResolver **pEntityResolver)
259 saxreader *This = impl_from_IVBSAXXMLReader( iface );
261 FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
265 static HRESULT WINAPI saxxmlreader_putEntityResolver(
266 IVBSAXXMLReader* iface,
267 IVBSAXEntityResolver *pEntityResolver)
269 saxreader *This = impl_from_IVBSAXXMLReader( iface );
271 FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
275 static HRESULT WINAPI saxxmlreader_getContentHandler(
276 IVBSAXXMLReader* iface,
277 IVBSAXContentHandler **ppContentHandler)
279 saxreader *This = impl_from_IVBSAXXMLReader( iface );
281 FIXME("(%p)->(%p) stub\n", This, ppContentHandler);
285 static HRESULT WINAPI saxxmlreader_putContentHandler(
286 IVBSAXXMLReader* iface,
287 IVBSAXContentHandler *contentHandler)
289 saxreader *This = impl_from_IVBSAXXMLReader( iface );
291 FIXME("(%p)->(%p) stub\n", This, contentHandler);
295 static HRESULT WINAPI saxxmlreader_getDTDHandler(
296 IVBSAXXMLReader* iface,
297 IVBSAXDTDHandler **pDTDHandler)
299 saxreader *This = impl_from_IVBSAXXMLReader( iface );
301 FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
305 static HRESULT WINAPI saxxmlreader_putDTDHandler(
306 IVBSAXXMLReader* iface,
307 IVBSAXDTDHandler *pDTDHandler)
309 saxreader *This = impl_from_IVBSAXXMLReader( iface );
311 FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
315 static HRESULT WINAPI saxxmlreader_getErrorHandler(
316 IVBSAXXMLReader* iface,
317 IVBSAXErrorHandler **pErrorHandler)
319 saxreader *This = impl_from_IVBSAXXMLReader( iface );
321 FIXME("(%p)->(%p) stub\n", This, pErrorHandler);
325 static HRESULT WINAPI saxxmlreader_putErrorHandler(
326 IVBSAXXMLReader* iface,
327 IVBSAXErrorHandler *errorHandler)
329 saxreader *This = impl_from_IVBSAXXMLReader( iface );
331 FIXME("(%p)->(%p) stub\n", This, errorHandler);
335 static HRESULT WINAPI saxxmlreader_getBaseURL(
336 IVBSAXXMLReader* iface,
337 const WCHAR **pBaseUrl)
339 saxreader *This = impl_from_IVBSAXXMLReader( iface );
341 FIXME("(%p)->(%p) stub\n", This, pBaseUrl);
345 static HRESULT WINAPI saxxmlreader_putBaseURL(
346 IVBSAXXMLReader* iface,
347 const WCHAR *pBaseUrl)
349 saxreader *This = impl_from_IVBSAXXMLReader( iface );
351 FIXME("(%p)->(%s) stub\n", This, debugstr_w(pBaseUrl));
355 static HRESULT WINAPI saxxmlreader_getSecureBaseURL(
356 IVBSAXXMLReader* iface,
357 const WCHAR **pSecureBaseUrl)
359 saxreader *This = impl_from_IVBSAXXMLReader( iface );
361 FIXME("(%p)->(%p) stub\n", This, pSecureBaseUrl);
366 static HRESULT WINAPI saxxmlreader_putSecureBaseURL(
367 IVBSAXXMLReader* iface,
368 const WCHAR *secureBaseUrl)
370 saxreader *This = impl_from_IVBSAXXMLReader( iface );
372 FIXME("(%p)->(%s) stub\n", This, debugstr_w(secureBaseUrl));
376 static HRESULT WINAPI saxxmlreader_parse(
377 IVBSAXXMLReader* iface,
380 saxreader *This = impl_from_IVBSAXXMLReader( iface );
382 FIXME("(%p) stub\n", This);
386 static HRESULT WINAPI saxxmlreader_parseURL(
387 IVBSAXXMLReader* iface,
390 saxreader *This = impl_from_IVBSAXXMLReader( iface );
392 FIXME("(%p)->(%s) stub\n", This, debugstr_w(url));
396 static const struct IVBSAXXMLReaderVtbl saxreader_vtbl =
398 saxxmlreader_QueryInterface,
400 saxxmlreader_Release,
401 saxxmlreader_GetTypeInfoCount,
402 saxxmlreader_GetTypeInfo,
403 saxxmlreader_GetIDsOfNames,
405 saxxmlreader_getFeature,
406 saxxmlreader_putFeature,
407 saxxmlreader_getProperty,
408 saxxmlreader_putProperty,
409 saxxmlreader_getEntityResolver,
410 saxxmlreader_putEntityResolver,
411 saxxmlreader_getContentHandler,
412 saxxmlreader_putContentHandler,
413 saxxmlreader_getDTDHandler,
414 saxxmlreader_putDTDHandler,
415 saxxmlreader_getErrorHandler,
416 saxxmlreader_putErrorHandler,
417 saxxmlreader_getBaseURL,
418 saxxmlreader_putBaseURL,
419 saxxmlreader_getSecureBaseURL,
420 saxxmlreader_putSecureBaseURL,
422 saxxmlreader_parseURL
425 /*** ISAXXMLReader interface ***/
426 /*** IUnknown methods ***/
427 static HRESULT WINAPI isaxxmlreader_QueryInterface(ISAXXMLReader* iface, REFIID riid, void **ppvObject)
429 saxreader *This = impl_from_ISAXXMLReader( iface );
430 return saxxmlreader_QueryInterface((IVBSAXXMLReader*)&This->lpVtbl, riid, ppvObject);
433 static ULONG WINAPI isaxxmlreader_AddRef(ISAXXMLReader* iface)
435 saxreader *This = impl_from_ISAXXMLReader( iface );
436 return saxxmlreader_AddRef((IVBSAXXMLReader*)&This->lpVtbl);
439 static ULONG WINAPI isaxxmlreader_Release(ISAXXMLReader* iface)
441 saxreader *This = impl_from_ISAXXMLReader( iface );
442 return saxxmlreader_Release((IVBSAXXMLReader*)&This->lpVtbl);
445 /*** ISAXXMLReader methods ***/
446 static HRESULT WINAPI isaxxmlreader_getFeature(
447 ISAXXMLReader* iface,
448 const WCHAR *pFeature,
449 VARIANT_BOOL *pValue)
451 saxreader *This = impl_from_ISAXXMLReader( iface );
453 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pFeature), pValue);
457 static HRESULT WINAPI isaxxmlreader_putFeature(
458 ISAXXMLReader* iface,
459 const WCHAR *pFeature,
460 VARIANT_BOOL vfValue)
462 saxreader *This = impl_from_ISAXXMLReader( iface );
464 FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(pFeature), vfValue);
468 static HRESULT WINAPI isaxxmlreader_getProperty(
469 ISAXXMLReader* iface,
473 saxreader *This = impl_from_ISAXXMLReader( iface );
475 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pProp), pValue);
479 static HRESULT WINAPI isaxxmlreader_putProperty(
480 ISAXXMLReader* iface,
484 saxreader *This = impl_from_ISAXXMLReader( iface );
486 FIXME("(%p)->(%s) stub\n", This, debugstr_w(pProp));
490 static HRESULT WINAPI isaxxmlreader_getEntityResolver(
491 ISAXXMLReader* iface,
492 ISAXEntityResolver **ppEntityResolver)
494 saxreader *This = impl_from_ISAXXMLReader( iface );
496 FIXME("(%p)->(%p) stub\n", This, ppEntityResolver);
500 static HRESULT WINAPI isaxxmlreader_putEntityResolver(
501 ISAXXMLReader* iface,
502 ISAXEntityResolver *pEntityResolver)
504 saxreader *This = impl_from_ISAXXMLReader( iface );
506 FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
510 static HRESULT WINAPI isaxxmlreader_getContentHandler(
511 ISAXXMLReader* iface,
512 ISAXContentHandler **pContentHandler)
514 saxreader *This = impl_from_ISAXXMLReader( iface );
516 TRACE("(%p)->(%p)\n", This, pContentHandler);
517 if(pContentHandler == NULL)
519 if(This->contentHandler)
520 ISAXContentHandler_AddRef(This->contentHandler);
521 *pContentHandler = This->contentHandler;
526 static HRESULT WINAPI isaxxmlreader_putContentHandler(
527 ISAXXMLReader* iface,
528 ISAXContentHandler *contentHandler)
530 saxreader *This = impl_from_ISAXXMLReader( iface );
532 TRACE("(%p)->(%p)\n", This, contentHandler);
534 ISAXContentHandler_AddRef(contentHandler);
535 if(This->contentHandler)
536 ISAXContentHandler_Release(This->contentHandler);
537 This->contentHandler = contentHandler;
542 static HRESULT WINAPI isaxxmlreader_getDTDHandler(
543 ISAXXMLReader* iface,
544 ISAXDTDHandler **pDTDHandler)
546 saxreader *This = impl_from_ISAXXMLReader( iface );
548 FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
552 static HRESULT WINAPI isaxxmlreader_putDTDHandler(
553 ISAXXMLReader* iface,
554 ISAXDTDHandler *pDTDHandler)
556 saxreader *This = impl_from_ISAXXMLReader( iface );
558 FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
562 static HRESULT WINAPI isaxxmlreader_getErrorHandler(
563 ISAXXMLReader* iface,
564 ISAXErrorHandler **pErrorHandler)
566 saxreader *This = impl_from_ISAXXMLReader( iface );
568 TRACE("(%p)->(%p)\n", This, pErrorHandler);
569 if(pErrorHandler == NULL)
571 if(This->errorHandler)
572 ISAXErrorHandler_AddRef(This->errorHandler);
573 *pErrorHandler = This->errorHandler;
578 static HRESULT WINAPI isaxxmlreader_putErrorHandler(
579 ISAXXMLReader* iface,
580 ISAXErrorHandler *errorHandler)
582 saxreader *This = impl_from_ISAXXMLReader( iface );
584 TRACE("(%p)->(%p)\n", This, errorHandler);
586 ISAXErrorHandler_AddRef(errorHandler);
587 if(This->errorHandler)
588 ISAXErrorHandler_Release(This->errorHandler);
589 This->errorHandler = errorHandler;
594 static HRESULT WINAPI isaxxmlreader_getBaseURL(
595 ISAXXMLReader* iface,
596 const WCHAR **pBaseUrl)
598 saxreader *This = impl_from_ISAXXMLReader( iface );
600 FIXME("(%p)->(%p) stub\n", This, pBaseUrl);
604 static HRESULT WINAPI isaxxmlreader_putBaseURL(
605 ISAXXMLReader* iface,
606 const WCHAR *pBaseUrl)
608 saxreader *This = impl_from_ISAXXMLReader( iface );
610 FIXME("(%p)->(%s) stub\n", This, debugstr_w(pBaseUrl));
614 static HRESULT WINAPI isaxxmlreader_getSecureBaseURL(
615 ISAXXMLReader* iface,
616 const WCHAR **pSecureBaseUrl)
618 saxreader *This = impl_from_ISAXXMLReader( iface );
620 FIXME("(%p)->(%p) stub\n", This, pSecureBaseUrl);
624 static HRESULT WINAPI isaxxmlreader_putSecureBaseURL(
625 ISAXXMLReader* iface,
626 const WCHAR *secureBaseUrl)
628 saxreader *This = impl_from_ISAXXMLReader( iface );
630 FIXME("(%p)->(%s) stub\n", This, debugstr_w(secureBaseUrl));
634 static HRESULT WINAPI isaxxmlreader_parse(
635 ISAXXMLReader* iface,
638 saxreader *This = impl_from_ISAXXMLReader( iface );
640 FIXME("(%p) stub\n", This);
644 static HRESULT WINAPI isaxxmlreader_parseURL(
645 ISAXXMLReader* iface,
648 saxreader *This = impl_from_ISAXXMLReader( iface );
650 FIXME("(%p)->(%s) stub\n", This, debugstr_w(url));
654 static const struct ISAXXMLReaderVtbl isaxreader_vtbl =
656 isaxxmlreader_QueryInterface,
657 isaxxmlreader_AddRef,
658 isaxxmlreader_Release,
659 isaxxmlreader_getFeature,
660 isaxxmlreader_putFeature,
661 isaxxmlreader_getProperty,
662 isaxxmlreader_putProperty,
663 isaxxmlreader_getEntityResolver,
664 isaxxmlreader_putEntityResolver,
665 isaxxmlreader_getContentHandler,
666 isaxxmlreader_putContentHandler,
667 isaxxmlreader_getDTDHandler,
668 isaxxmlreader_putDTDHandler,
669 isaxxmlreader_getErrorHandler,
670 isaxxmlreader_putErrorHandler,
671 isaxxmlreader_getBaseURL,
672 isaxxmlreader_putBaseURL,
673 isaxxmlreader_getSecureBaseURL,
674 isaxxmlreader_putSecureBaseURL,
676 isaxxmlreader_parseURL
679 HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
683 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
685 reader = HeapAlloc( GetProcessHeap(), 0, sizeof (*reader) );
687 return E_OUTOFMEMORY;
689 reader->lpVtbl = &saxreader_vtbl;
690 reader->lpSAXXMLReaderVtbl = &isaxreader_vtbl;
692 reader->contentHandler = NULL;
693 reader->errorHandler = NULL;
695 *ppObj = &reader->lpVtbl;
697 TRACE("returning iface %p\n", *ppObj);
704 HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
706 MESSAGE("This program tried to use a SAX XML Reader object, but\n"
707 "libxml2 support was not present at compile time.\n");