rpcrt4/tests: Fix a few more broken tests on NT4.
[wine.git] / dlls / msxml3 / saxreader.c
blob90600eb5a080a4185e8132dcf9c2ef32d0b3c2bd
1 /*
2 * SAX Reader implementation
4 * Copyright 2008 Alistair Leslie-Hughes
5 * Copyright 2008 Piotr Caban
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define COBJMACROS
23 #include "config.h"
25 #include <stdarg.h>
26 #include <assert.h>
27 #include "windef.h"
28 #include "winbase.h"
29 #include "winuser.h"
30 #include "winnls.h"
31 #include "ole2.h"
32 #include "msxml2.h"
33 #include "wininet.h"
34 #include "urlmon.h"
35 #include "winreg.h"
36 #include "shlwapi.h"
38 #include "wine/debug.h"
40 #include "msxml_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
44 #ifdef HAVE_LIBXML2
46 #include <libxml/SAX2.h>
47 #include <libxml/parserInternals.h>
49 typedef struct _saxreader
51 const struct IVBSAXXMLReaderVtbl *lpVBSAXXMLReaderVtbl;
52 const struct ISAXXMLReaderVtbl *lpSAXXMLReaderVtbl;
53 LONG ref;
54 struct ISAXContentHandler *contentHandler;
55 struct IVBSAXContentHandler *vbcontentHandler;
56 struct ISAXErrorHandler *errorHandler;
57 struct IVBSAXErrorHandler *vberrorHandler;
58 struct ISAXLexicalHandler *lexicalHandler;
59 struct IVBSAXLexicalHandler *vblexicalHandler;
60 struct ISAXDeclHandler *declHandler;
61 struct IVBSAXDeclHandler *vbdeclHandler;
62 xmlSAXHandler sax;
63 BOOL isParsing;
64 } saxreader;
66 typedef struct _saxlocator
68 const struct IVBSAXLocatorVtbl *lpVBSAXLocatorVtbl;
69 const struct ISAXLocatorVtbl *lpSAXLocatorVtbl;
70 LONG ref;
71 saxreader *saxreader;
72 HRESULT ret;
73 xmlParserCtxtPtr pParserCtxt;
74 WCHAR *publicId;
75 WCHAR *systemId;
76 xmlChar *lastCur;
77 int line;
78 int realLine;
79 int column;
80 int realColumn;
81 BOOL vbInterface;
82 int nsStackSize;
83 int nsStackLast;
84 int *nsStack;
85 } saxlocator;
87 typedef struct _saxattributes
89 const struct IVBSAXAttributesVtbl *lpVBSAXAttributesVtbl;
90 const struct ISAXAttributesVtbl *lpSAXAttributesVtbl;
91 LONG ref;
92 int nb_attributes;
93 BSTR *szLocalname;
94 BSTR *szURI;
95 BSTR *szValue;
96 BSTR *szQName;
97 } saxattributes;
99 static inline saxreader *impl_from_IVBSAXXMLReader( IVBSAXXMLReader *iface )
101 return (saxreader *)((char*)iface - FIELD_OFFSET(saxreader, lpVBSAXXMLReaderVtbl));
104 static inline saxreader *impl_from_ISAXXMLReader( ISAXXMLReader *iface )
106 return (saxreader *)((char*)iface - FIELD_OFFSET(saxreader, lpSAXXMLReaderVtbl));
109 static inline saxlocator *impl_from_IVBSAXLocator( IVBSAXLocator *iface )
111 return (saxlocator *)((char*)iface - FIELD_OFFSET(saxlocator, lpVBSAXLocatorVtbl));
114 static inline saxlocator *impl_from_ISAXLocator( ISAXLocator *iface )
116 return (saxlocator *)((char*)iface - FIELD_OFFSET(saxlocator, lpSAXLocatorVtbl));
119 static inline saxattributes *impl_from_IVBSAXAttributes( IVBSAXAttributes *iface )
121 return (saxattributes *)((char*)iface - FIELD_OFFSET(saxattributes, lpVBSAXAttributesVtbl));
124 static inline saxattributes *impl_from_ISAXAttributes( ISAXAttributes *iface )
126 return (saxattributes *)((char*)iface - FIELD_OFFSET(saxattributes, lpSAXAttributesVtbl));
130 static HRESULT namespacePush(saxlocator *locator, int ns)
132 if(locator->nsStackLast>=locator->nsStackSize)
134 int *new_stack;
136 new_stack = HeapReAlloc(GetProcessHeap(), 0,
137 locator->nsStack, locator->nsStackSize*2);
138 if(!new_stack) return E_OUTOFMEMORY;
139 locator->nsStack = new_stack;
140 locator->nsStackSize *= 2;
142 locator->nsStack[locator->nsStackLast++] = ns;
144 return S_OK;
147 static int namespacePop(saxlocator *locator)
149 if(locator->nsStackLast == 0) return 0;
150 return locator->nsStack[--locator->nsStackLast];
153 static BSTR bstr_from_xmlCharN(const xmlChar *buf, int len)
155 DWORD dLen;
156 LPWSTR str;
157 BSTR bstr;
159 if (!buf)
160 return NULL;
162 dLen = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, NULL, 0);
163 if(len != -1) dLen++;
164 str = HeapAlloc(GetProcessHeap(), 0, dLen * sizeof (WCHAR));
165 if (!str)
166 return NULL;
167 MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)buf, len, str, dLen);
168 if(len != -1) str[dLen-1] = '\0';
169 bstr = SysAllocString(str);
170 HeapFree(GetProcessHeap(), 0, str);
172 return bstr;
175 static BSTR QName_from_xmlChar(const xmlChar *prefix, const xmlChar *name)
177 DWORD dLen, dLast;
178 LPWSTR str;
179 BSTR bstr;
181 if(!name) return NULL;
183 if(!prefix || *prefix=='\0')
184 return bstr_from_xmlChar(name);
186 dLen = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)prefix, -1, NULL, 0)
187 + MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)name, -1, NULL, 0);
188 str = HeapAlloc(GetProcessHeap(), 0, dLen * sizeof(WCHAR));
189 if(!str)
190 return NULL;
192 dLast = MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)prefix, -1, str, dLen);
193 str[dLast-1] = ':';
194 MultiByteToWideChar(CP_UTF8, 0, (LPCSTR)name, -1, &str[dLast], dLen-dLast);
195 bstr = SysAllocString(str);
197 HeapFree(GetProcessHeap(), 0, str);
199 return bstr;
202 static void format_error_message_from_id(saxlocator *This, HRESULT hr)
204 xmlStopParser(This->pParserCtxt);
205 This->ret = hr;
207 if((This->vbInterface && This->saxreader->vberrorHandler)
208 || (!This->vbInterface && This->saxreader->errorHandler))
210 WCHAR msg[1024];
211 if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM,
212 NULL, hr, 0, msg, sizeof(msg), NULL))
214 FIXME("MSXML errors not yet supported.\n");
215 msg[0] = '\0';
218 if(This->vbInterface)
220 BSTR bstrMsg = SysAllocString(msg);
221 IVBSAXErrorHandler_fatalError(This->saxreader->vberrorHandler,
222 (IVBSAXLocator*)&This->lpVBSAXLocatorVtbl, &bstrMsg, hr);
224 else
225 ISAXErrorHandler_fatalError(This->saxreader->errorHandler,
226 (ISAXLocator*)&This->lpSAXLocatorVtbl, msg, hr);
230 static void update_position(saxlocator *This, xmlChar *end)
232 if(This->lastCur == NULL)
234 This->lastCur = (xmlChar*)This->pParserCtxt->input->base;
235 This->realLine = 1;
236 This->realColumn = 1;
238 else if(This->lastCur < This->pParserCtxt->input->base)
240 This->lastCur = (xmlChar*)This->pParserCtxt->input->base;
241 This->realLine = 1;
242 This->realColumn = 1;
245 if(This->pParserCtxt->input->cur<This->lastCur)
247 This->lastCur = (xmlChar*)This->pParserCtxt->input->base;
248 This->realLine -= 1;
249 This->realColumn = 1;
252 if(!end) end = (xmlChar*)This->pParserCtxt->input->cur;
254 while(This->lastCur < end)
256 if(*(This->lastCur) == '\n')
258 This->realLine++;
259 This->realColumn = 1;
261 else if(*(This->lastCur) == '\r' &&
262 (This->lastCur==This->pParserCtxt->input->end ||
263 *(This->lastCur+1)!='\n'))
265 This->realLine++;
266 This->realColumn = 1;
268 else This->realColumn++;
270 This->lastCur++;
272 /* Count multibyte UTF8 encoded characters once */
273 while((*(This->lastCur)&0xC0) == 0x80) This->lastCur++;
276 This->line = This->realLine;
277 This->column = This->realColumn;
280 /*** IVBSAXAttributes interface ***/
281 /*** IUnknown methods ***/
282 static HRESULT WINAPI ivbsaxattributes_QueryInterface(
283 IVBSAXAttributes* iface,
284 REFIID riid,
285 void **ppvObject)
287 saxattributes *This = impl_from_IVBSAXAttributes(iface);
289 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
291 *ppvObject = NULL;
293 if (IsEqualGUID(riid, &IID_IUnknown) ||
294 IsEqualGUID(riid, &IID_IDispatch) ||
295 IsEqualGUID(riid, &IID_IVBSAXAttributes))
297 *ppvObject = iface;
299 else
301 FIXME("interface %s not implemented\n", debugstr_guid(riid));
302 return E_NOINTERFACE;
305 IVBSAXAttributes_AddRef(iface);
307 return S_OK;
310 static ULONG WINAPI ivbsaxattributes_AddRef(IVBSAXAttributes* iface)
312 saxattributes *This = impl_from_IVBSAXAttributes(iface);
313 return ISAXAttributes_AddRef((ISAXAttributes*)&This->lpSAXAttributesVtbl);
316 static ULONG WINAPI ivbsaxattributes_Release(IVBSAXAttributes* iface)
318 saxattributes *This = impl_from_IVBSAXAttributes(iface);
319 return ISAXAttributes_Release((ISAXAttributes*)&This->lpSAXAttributesVtbl);
322 /*** IDispatch methods ***/
323 static HRESULT WINAPI ivbsaxattributes_GetTypeInfoCount( IVBSAXAttributes *iface, UINT* pctinfo )
325 saxattributes *This = impl_from_IVBSAXAttributes( iface );
327 TRACE("(%p)->(%p)\n", This, pctinfo);
329 *pctinfo = 1;
331 return S_OK;
334 static HRESULT WINAPI ivbsaxattributes_GetTypeInfo(
335 IVBSAXAttributes *iface,
336 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
338 saxattributes *This = impl_from_IVBSAXAttributes( iface );
339 HRESULT hr;
341 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
343 hr = get_typeinfo(IVBSAXAttributes_tid, ppTInfo);
345 return hr;
348 static HRESULT WINAPI ivbsaxattributes_GetIDsOfNames(
349 IVBSAXAttributes *iface,
350 REFIID riid,
351 LPOLESTR* rgszNames,
352 UINT cNames,
353 LCID lcid,
354 DISPID* rgDispId)
356 saxattributes *This = impl_from_IVBSAXAttributes( iface );
357 ITypeInfo *typeinfo;
358 HRESULT hr;
360 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
361 lcid, rgDispId);
363 if(!rgszNames || cNames == 0 || !rgDispId)
364 return E_INVALIDARG;
366 hr = get_typeinfo(IVBSAXAttributes_tid, &typeinfo);
367 if(SUCCEEDED(hr))
369 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
370 ITypeInfo_Release(typeinfo);
373 return hr;
376 static HRESULT WINAPI ivbsaxattributes_Invoke(
377 IVBSAXAttributes *iface,
378 DISPID dispIdMember,
379 REFIID riid,
380 LCID lcid,
381 WORD wFlags,
382 DISPPARAMS* pDispParams,
383 VARIANT* pVarResult,
384 EXCEPINFO* pExcepInfo,
385 UINT* puArgErr)
387 saxattributes *This = impl_from_IVBSAXAttributes( iface );
388 ITypeInfo *typeinfo;
389 HRESULT hr;
391 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
392 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
394 hr = get_typeinfo(IVBSAXAttributes_tid, &typeinfo);
395 if(SUCCEEDED(hr))
397 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVBSAXAttributesVtbl), dispIdMember, wFlags, pDispParams,
398 pVarResult, pExcepInfo, puArgErr);
399 ITypeInfo_Release(typeinfo);
402 return hr;
405 /*** IVBSAXAttributes methods ***/
406 static HRESULT WINAPI ivbsaxattributes_get_length(
407 IVBSAXAttributes* iface,
408 int *nLength)
410 saxattributes *This = impl_from_IVBSAXAttributes( iface );
411 return ISAXAttributes_getLength(
412 (ISAXAttributes*)&This->lpSAXAttributesVtbl,
413 nLength);
416 static HRESULT WINAPI ivbsaxattributes_getURI(
417 IVBSAXAttributes* iface,
418 int nIndex,
419 BSTR *uri)
421 int len;
422 saxattributes *This = impl_from_IVBSAXAttributes( iface );
423 return ISAXAttributes_getURI(
424 (ISAXAttributes*)&This->lpSAXAttributesVtbl,
425 nIndex, (const WCHAR**)uri, &len);
428 static HRESULT WINAPI ivbsaxattributes_getLocalName(
429 IVBSAXAttributes* iface,
430 int nIndex,
431 BSTR *localName)
433 int len;
434 saxattributes *This = impl_from_IVBSAXAttributes( iface );
435 return ISAXAttributes_getLocalName(
436 (ISAXAttributes*)&This->lpSAXAttributesVtbl,
437 nIndex, (const WCHAR**)localName, &len);
440 static HRESULT WINAPI ivbsaxattributes_getQName(
441 IVBSAXAttributes* iface,
442 int nIndex,
443 BSTR *QName)
445 int len;
446 saxattributes *This = impl_from_IVBSAXAttributes( iface );
447 return ISAXAttributes_getQName(
448 (ISAXAttributes*)&This->lpSAXAttributesVtbl,
449 nIndex, (const WCHAR**)QName, &len);
452 static HRESULT WINAPI ivbsaxattributes_getIndexFromName(
453 IVBSAXAttributes* iface,
454 BSTR uri,
455 BSTR localName,
456 int *index)
458 saxattributes *This = impl_from_IVBSAXAttributes( iface );
459 return ISAXAttributes_getIndexFromName(
460 (ISAXAttributes*)&This->lpSAXAttributesVtbl, uri, SysStringLen(uri),
461 localName, SysStringLen(localName), index);
464 static HRESULT WINAPI ivbsaxattributes_getIndexFromQName(
465 IVBSAXAttributes* iface,
466 BSTR QName,
467 int *index)
469 saxattributes *This = impl_from_IVBSAXAttributes( iface );
470 return ISAXAttributes_getIndexFromQName(
471 (ISAXAttributes*)&This->lpSAXAttributesVtbl, QName,
472 SysStringLen(QName), index);
475 static HRESULT WINAPI ivbsaxattributes_getType(
476 IVBSAXAttributes* iface,
477 int nIndex,
478 BSTR *type)
480 int len;
481 saxattributes *This = impl_from_IVBSAXAttributes( iface );
482 return ISAXAttributes_getType(
483 (ISAXAttributes*)&This->lpSAXAttributesVtbl,
484 nIndex, (const WCHAR**)type, &len);
487 static HRESULT WINAPI ivbsaxattributes_getTypeFromName(
488 IVBSAXAttributes* iface,
489 BSTR uri,
490 BSTR localName,
491 BSTR *type)
493 int len;
494 saxattributes *This = impl_from_IVBSAXAttributes( iface );
495 return ISAXAttributes_getTypeFromName(
496 (ISAXAttributes*)&This->lpSAXAttributesVtbl, uri, SysStringLen(uri),
497 localName, SysStringLen(localName), (const WCHAR**)type, &len);
500 static HRESULT WINAPI ivbsaxattributes_getTypeFromQName(
501 IVBSAXAttributes* iface,
502 BSTR QName,
503 BSTR *type)
505 int len;
506 saxattributes *This = impl_from_IVBSAXAttributes( iface );
507 return ISAXAttributes_getTypeFromQName(
508 (ISAXAttributes*)&This->lpSAXAttributesVtbl, QName,
509 SysStringLen(QName), (const WCHAR**)type, &len);
512 static HRESULT WINAPI ivbsaxattributes_getValue(
513 IVBSAXAttributes* iface,
514 int nIndex,
515 BSTR *value)
517 int len;
518 saxattributes *This = impl_from_IVBSAXAttributes( iface );
519 return ISAXAttributes_getValue(
520 (ISAXAttributes*)&This->lpSAXAttributesVtbl,
521 nIndex, (const WCHAR**)value, &len);
524 static HRESULT WINAPI ivbsaxattributes_getValueFromName(
525 IVBSAXAttributes* iface,
526 BSTR uri,
527 BSTR localName,
528 BSTR *value)
530 int len;
531 saxattributes *This = impl_from_IVBSAXAttributes( iface );
532 return ISAXAttributes_getValueFromName(
533 (ISAXAttributes*)&This->lpSAXAttributesVtbl, uri, SysStringLen(uri),
534 localName, SysStringLen(localName), (const WCHAR**)value, &len);
537 static HRESULT WINAPI ivbsaxattributes_getValueFromQName(
538 IVBSAXAttributes* iface,
539 BSTR QName,
540 BSTR *value)
542 int len;
543 saxattributes *This = impl_from_IVBSAXAttributes( iface );
544 return ISAXAttributes_getValueFromQName(
545 (ISAXAttributes*)&This->lpSAXAttributesVtbl, QName,
546 SysStringLen(QName), (const WCHAR**)value, &len);
549 static const struct IVBSAXAttributesVtbl ivbsaxattributes_vtbl =
551 ivbsaxattributes_QueryInterface,
552 ivbsaxattributes_AddRef,
553 ivbsaxattributes_Release,
554 ivbsaxattributes_GetTypeInfoCount,
555 ivbsaxattributes_GetTypeInfo,
556 ivbsaxattributes_GetIDsOfNames,
557 ivbsaxattributes_Invoke,
558 ivbsaxattributes_get_length,
559 ivbsaxattributes_getURI,
560 ivbsaxattributes_getLocalName,
561 ivbsaxattributes_getQName,
562 ivbsaxattributes_getIndexFromName,
563 ivbsaxattributes_getIndexFromQName,
564 ivbsaxattributes_getType,
565 ivbsaxattributes_getTypeFromName,
566 ivbsaxattributes_getTypeFromQName,
567 ivbsaxattributes_getValue,
568 ivbsaxattributes_getValueFromName,
569 ivbsaxattributes_getValueFromQName
572 /*** ISAXAttributes interface ***/
573 /*** IUnknown methods ***/
574 static HRESULT WINAPI isaxattributes_QueryInterface(
575 ISAXAttributes* iface,
576 REFIID riid,
577 void **ppvObject)
579 saxattributes *This = impl_from_ISAXAttributes(iface);
581 TRACE("%p %s %p\n", This, debugstr_guid(riid), ppvObject);
583 *ppvObject = NULL;
585 if (IsEqualGUID(riid, &IID_IUnknown) ||
586 IsEqualGUID(riid, &IID_ISAXAttributes))
588 *ppvObject = iface;
590 else
592 FIXME("interface %s not implemented\n", debugstr_guid(riid));
593 return E_NOINTERFACE;
596 ISAXAttributes_AddRef(iface);
598 return S_OK;
601 static ULONG WINAPI isaxattributes_AddRef(ISAXAttributes* iface)
603 saxattributes *This = impl_from_ISAXAttributes(iface);
604 TRACE("%p\n", This);
605 return InterlockedIncrement(&This->ref);
608 static ULONG WINAPI isaxattributes_Release(ISAXAttributes* iface)
610 saxattributes *This = impl_from_ISAXAttributes(iface);
611 LONG ref;
613 TRACE("%p\n", This);
615 ref = InterlockedDecrement(&This->ref);
616 if (ref==0)
618 int index;
619 for(index=0; index<This->nb_attributes; index++)
621 SysFreeString(This->szLocalname[index]);
622 SysFreeString(This->szURI[index]);
623 SysFreeString(This->szValue[index]);
624 SysFreeString(This->szQName[index]);
627 HeapFree(GetProcessHeap(), 0, This->szLocalname);
628 HeapFree(GetProcessHeap(), 0, This->szURI);
629 HeapFree(GetProcessHeap(), 0, This->szValue);
630 HeapFree(GetProcessHeap(), 0, This->szQName);
632 HeapFree(GetProcessHeap(), 0, This);
635 return ref;
638 /*** ISAXAttributes methods ***/
639 static HRESULT WINAPI isaxattributes_getLength(
640 ISAXAttributes* iface,
641 int *length)
643 saxattributes *This = impl_from_ISAXAttributes( iface );
645 *length = This->nb_attributes;
646 TRACE("Length set to %d\n", *length);
647 return S_OK;
650 static HRESULT WINAPI isaxattributes_getURI(
651 ISAXAttributes* iface,
652 int nIndex,
653 const WCHAR **pUrl,
654 int *pUriSize)
656 saxattributes *This = impl_from_ISAXAttributes( iface );
657 TRACE("(%p)->(%d)\n", This, nIndex);
659 if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
660 if(!pUrl || !pUriSize) return E_POINTER;
662 *pUriSize = SysStringLen(This->szURI[nIndex]);
663 *pUrl = This->szURI[nIndex];
665 return S_OK;
668 static HRESULT WINAPI isaxattributes_getLocalName(
669 ISAXAttributes* iface,
670 int nIndex,
671 const WCHAR **pLocalName,
672 int *pLocalNameLength)
674 saxattributes *This = impl_from_ISAXAttributes( iface );
675 TRACE("(%p)->(%d)\n", This, nIndex);
677 if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
678 if(!pLocalName || !pLocalNameLength) return E_POINTER;
680 *pLocalNameLength = SysStringLen(This->szLocalname[nIndex]);
681 *pLocalName = This->szLocalname[nIndex];
683 return S_OK;
686 static HRESULT WINAPI isaxattributes_getQName(
687 ISAXAttributes* iface,
688 int nIndex,
689 const WCHAR **pQName,
690 int *pQNameLength)
692 saxattributes *This = impl_from_ISAXAttributes( iface );
693 TRACE("(%p)->(%d)\n", This, nIndex);
695 if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
696 if(!pQName || !pQNameLength) return E_POINTER;
698 *pQNameLength = SysStringLen(This->szQName[nIndex]);
699 *pQName = This->szQName[nIndex];
701 return S_OK;
704 static HRESULT WINAPI isaxattributes_getName(
705 ISAXAttributes* iface,
706 int nIndex,
707 const WCHAR **pUri,
708 int *pUriLength,
709 const WCHAR **pLocalName,
710 int *pLocalNameSize,
711 const WCHAR **pQName,
712 int *pQNameLength)
714 saxattributes *This = impl_from_ISAXAttributes( iface );
715 TRACE("(%p)->(%d)\n", This, nIndex);
717 if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
718 if(!pUri || !pUriLength || !pLocalName || !pLocalNameSize
719 || !pQName || !pQNameLength) return E_POINTER;
721 *pUriLength = SysStringLen(This->szURI[nIndex]);
722 *pUri = This->szURI[nIndex];
723 *pLocalNameSize = SysStringLen(This->szLocalname[nIndex]);
724 *pLocalName = This->szLocalname[nIndex];
725 *pQNameLength = SysStringLen(This->szQName[nIndex]);
726 *pQName = This->szQName[nIndex];
728 return S_OK;
731 static HRESULT WINAPI isaxattributes_getIndexFromName(
732 ISAXAttributes* iface,
733 const WCHAR *pUri,
734 int cUriLength,
735 const WCHAR *pLocalName,
736 int cocalNameLength,
737 int *index)
739 saxattributes *This = impl_from_ISAXAttributes( iface );
740 int i;
741 TRACE("(%p)->(%s, %d, %s, %d)\n", This, debugstr_w(pUri), cUriLength,
742 debugstr_w(pLocalName), cocalNameLength);
744 if(!pUri || !pLocalName || !index) return E_POINTER;
746 for(i=0; i<This->nb_attributes; i++)
748 if(cUriLength!=SysStringLen(This->szURI[i])
749 || cocalNameLength!=SysStringLen(This->szLocalname[i]))
750 continue;
751 if(cUriLength && memcmp(pUri, This->szURI[i],
752 sizeof(WCHAR)*cUriLength))
753 continue;
754 if(cocalNameLength && memcmp(pLocalName, This->szLocalname[i],
755 sizeof(WCHAR)*cocalNameLength))
756 continue;
758 *index = i;
759 return S_OK;
762 return E_INVALIDARG;
765 static HRESULT WINAPI isaxattributes_getIndexFromQName(
766 ISAXAttributes* iface,
767 const WCHAR *pQName,
768 int nQNameLength,
769 int *index)
771 saxattributes *This = impl_from_ISAXAttributes( iface );
772 int i;
773 TRACE("(%p)->(%s, %d)\n", This, debugstr_w(pQName), nQNameLength);
775 if(!pQName || !index) return E_POINTER;
776 if(!nQNameLength) return E_INVALIDARG;
778 for(i=0; i<This->nb_attributes; i++)
780 if(nQNameLength!=SysStringLen(This->szQName[i])) continue;
781 if(memcmp(pQName, This->szQName, sizeof(WCHAR)*nQNameLength)) continue;
783 *index = i;
784 return S_OK;
787 return E_INVALIDARG;
790 static HRESULT WINAPI isaxattributes_getType(
791 ISAXAttributes* iface,
792 int nIndex,
793 const WCHAR **pType,
794 int *pTypeLength)
796 saxattributes *This = impl_from_ISAXAttributes( iface );
798 FIXME("(%p)->(%d) stub\n", This, nIndex);
799 return E_NOTIMPL;
802 static HRESULT WINAPI isaxattributes_getTypeFromName(
803 ISAXAttributes* iface,
804 const WCHAR *pUri,
805 int nUri,
806 const WCHAR *pLocalName,
807 int nLocalName,
808 const WCHAR **pType,
809 int *nType)
811 saxattributes *This = impl_from_ISAXAttributes( iface );
813 FIXME("(%p)->(%s, %d, %s, %d) stub\n", This, debugstr_w(pUri), nUri,
814 debugstr_w(pLocalName), nLocalName);
815 return E_NOTIMPL;
818 static HRESULT WINAPI isaxattributes_getTypeFromQName(
819 ISAXAttributes* iface,
820 const WCHAR *pQName,
821 int nQName,
822 const WCHAR **pType,
823 int *nType)
825 saxattributes *This = impl_from_ISAXAttributes( iface );
827 FIXME("(%p)->(%s, %d) stub\n", This, debugstr_w(pQName), nQName);
828 return E_NOTIMPL;
831 static HRESULT WINAPI isaxattributes_getValue(
832 ISAXAttributes* iface,
833 int nIndex,
834 const WCHAR **pValue,
835 int *nValue)
837 saxattributes *This = impl_from_ISAXAttributes( iface );
838 TRACE("(%p)->(%d)\n", This, nIndex);
840 if(nIndex>=This->nb_attributes || nIndex<0) return E_INVALIDARG;
841 if(!pValue || !nValue) return E_POINTER;
843 *nValue = SysStringLen(This->szValue[nIndex]);
844 *pValue = This->szValue[nIndex];
846 return S_OK;
849 static HRESULT WINAPI isaxattributes_getValueFromName(
850 ISAXAttributes* iface,
851 const WCHAR *pUri,
852 int nUri,
853 const WCHAR *pLocalName,
854 int nLocalName,
855 const WCHAR **pValue,
856 int *nValue)
858 HRESULT hr;
859 int index;
860 saxattributes *This = impl_from_ISAXAttributes( iface );
861 TRACE("(%p)->(%s, %d, %s, %d)\n", This, debugstr_w(pUri), nUri,
862 debugstr_w(pLocalName), nLocalName);
864 hr = ISAXAttributes_getIndexFromName(iface,
865 pUri, nUri, pLocalName, nLocalName, &index);
866 if(hr==S_OK) hr = ISAXAttributes_getValue(iface, index, pValue, nValue);
868 return hr;
871 static HRESULT WINAPI isaxattributes_getValueFromQName(
872 ISAXAttributes* iface,
873 const WCHAR *pQName,
874 int nQName,
875 const WCHAR **pValue,
876 int *nValue)
878 HRESULT hr;
879 int index;
880 saxattributes *This = impl_from_ISAXAttributes( iface );
881 TRACE("(%p)->(%s, %d)\n", This, debugstr_w(pQName), nQName);
883 hr = ISAXAttributes_getIndexFromQName(iface, pQName, nQName, &index);
884 if(hr==S_OK) hr = ISAXAttributes_getValue(iface, index, pValue, nValue);
886 return hr;
889 static const struct ISAXAttributesVtbl isaxattributes_vtbl =
891 isaxattributes_QueryInterface,
892 isaxattributes_AddRef,
893 isaxattributes_Release,
894 isaxattributes_getLength,
895 isaxattributes_getURI,
896 isaxattributes_getLocalName,
897 isaxattributes_getQName,
898 isaxattributes_getName,
899 isaxattributes_getIndexFromName,
900 isaxattributes_getIndexFromQName,
901 isaxattributes_getType,
902 isaxattributes_getTypeFromName,
903 isaxattributes_getTypeFromQName,
904 isaxattributes_getValue,
905 isaxattributes_getValueFromName,
906 isaxattributes_getValueFromQName
909 static HRESULT SAXAttributes_create(saxattributes **attr,
910 int nb_namespaces, const xmlChar **xmlNamespaces,
911 int nb_attributes, const xmlChar **xmlAttributes)
913 saxattributes *attributes;
914 int index;
915 static const xmlChar xmlns[] = "xmlns";
917 attributes = HeapAlloc(GetProcessHeap(), 0, sizeof(*attributes));
918 if(!attributes)
919 return E_OUTOFMEMORY;
921 attributes->lpVBSAXAttributesVtbl = &ivbsaxattributes_vtbl;
922 attributes->lpSAXAttributesVtbl = &isaxattributes_vtbl;
923 attributes->ref = 1;
925 attributes->nb_attributes = nb_namespaces+nb_attributes;
927 attributes->szLocalname =
928 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR)*attributes->nb_attributes);
929 attributes->szURI =
930 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR)*attributes->nb_attributes);
931 attributes->szValue =
932 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR)*attributes->nb_attributes);
933 attributes->szQName =
934 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR)*attributes->nb_attributes);
936 if(!attributes->szLocalname || !attributes->szURI
937 || !attributes->szValue || !attributes->szQName)
939 HeapFree(GetProcessHeap(), 0, attributes->szLocalname);
940 HeapFree(GetProcessHeap(), 0, attributes->szURI);
941 HeapFree(GetProcessHeap(), 0, attributes->szValue);
942 HeapFree(GetProcessHeap(), 0, attributes->szQName);
943 HeapFree(GetProcessHeap(), 0, attributes);
944 return E_FAIL;
947 for(index=0; index<nb_namespaces; index++)
949 attributes->szLocalname[index] = SysAllocStringLen(NULL, 0);
950 attributes->szURI[index] = SysAllocStringLen(NULL, 0);
951 attributes->szValue[index] = bstr_from_xmlChar(xmlNamespaces[2*index+1]);
952 attributes->szQName[index] = QName_from_xmlChar(xmlns, xmlNamespaces[2*index]);
955 for(index=0; index<nb_attributes; index++)
957 attributes->szLocalname[nb_namespaces+index] =
958 bstr_from_xmlChar(xmlAttributes[index*5]);
959 attributes->szURI[nb_namespaces+index] =
960 bstr_from_xmlChar(xmlAttributes[index*5+2]);
961 attributes->szValue[nb_namespaces+index] =
962 bstr_from_xmlCharN(xmlAttributes[index*5+3],
963 xmlAttributes[index*5+4]-xmlAttributes[index*5+3]);
964 attributes->szQName[nb_namespaces+index] =
965 QName_from_xmlChar(xmlAttributes[index*5+1], xmlAttributes[index*5]);
968 *attr = attributes;
970 TRACE("returning %p\n", *attr);
972 return S_OK;
975 /*** LibXML callbacks ***/
976 static void libxmlStartDocument(void *ctx)
978 saxlocator *This = ctx;
979 HRESULT hr;
981 if((This->vbInterface && This->saxreader->vbcontentHandler)
982 || (!This->vbInterface && This->saxreader->contentHandler))
984 if(This->vbInterface)
985 hr = IVBSAXContentHandler_startDocument(This->saxreader->vbcontentHandler);
986 else
987 hr = ISAXContentHandler_startDocument(This->saxreader->contentHandler);
989 if(hr != S_OK)
990 format_error_message_from_id(This, hr);
993 update_position(This, NULL);
996 static void libxmlEndDocument(void *ctx)
998 saxlocator *This = ctx;
999 HRESULT hr;
1001 This->column = 0;
1002 This->line = 0;
1004 if(This->ret != S_OK) return;
1006 if((This->vbInterface && This->saxreader->vbcontentHandler)
1007 || (!This->vbInterface && This->saxreader->contentHandler))
1009 if(This->vbInterface)
1010 hr = IVBSAXContentHandler_endDocument(This->saxreader->vbcontentHandler);
1011 else
1012 hr = ISAXContentHandler_endDocument(This->saxreader->contentHandler);
1014 if(hr != S_OK)
1015 format_error_message_from_id(This, hr);
1019 static void libxmlStartElementNS(
1020 void *ctx,
1021 const xmlChar *localname,
1022 const xmlChar *prefix,
1023 const xmlChar *URI,
1024 int nb_namespaces,
1025 const xmlChar **namespaces,
1026 int nb_attributes,
1027 int nb_defaulted,
1028 const xmlChar **attributes)
1030 BSTR NamespaceUri, LocalName, QName, Prefix, Uri;
1031 saxlocator *This = ctx;
1032 HRESULT hr;
1033 saxattributes *attr;
1034 int index;
1036 if(*(This->pParserCtxt->input->cur) == '/')
1037 update_position(This, (xmlChar*)This->pParserCtxt->input->cur+2);
1038 else
1039 update_position(This, (xmlChar*)This->pParserCtxt->input->cur+1);
1041 hr = namespacePush(This, nb_namespaces);
1042 if(hr==S_OK && ((This->vbInterface && This->saxreader->vbcontentHandler)
1043 || (!This->vbInterface && This->saxreader->contentHandler)))
1045 for(index=0; index<nb_namespaces; index++)
1047 Prefix = bstr_from_xmlChar(namespaces[2*index]);
1048 Uri = bstr_from_xmlChar(namespaces[2*index+1]);
1050 if(This->vbInterface)
1051 hr = IVBSAXContentHandler_startPrefixMapping(
1052 This->saxreader->vbcontentHandler,
1053 &Prefix, &Uri);
1054 else
1055 hr = ISAXContentHandler_startPrefixMapping(
1056 This->saxreader->contentHandler,
1057 Prefix, SysStringLen(Prefix),
1058 Uri, SysStringLen(Uri));
1060 SysFreeString(Prefix);
1061 SysFreeString(Uri);
1063 if(hr != S_OK)
1065 format_error_message_from_id(This, hr);
1066 return;
1070 NamespaceUri = bstr_from_xmlChar(URI);
1071 LocalName = bstr_from_xmlChar(localname);
1072 QName = QName_from_xmlChar(prefix, localname);
1074 hr = SAXAttributes_create(&attr, nb_namespaces, namespaces, nb_attributes, attributes);
1075 if(hr == S_OK)
1077 if(This->vbInterface)
1078 hr = IVBSAXContentHandler_startElement(
1079 This->saxreader->vbcontentHandler,
1080 &NamespaceUri, &LocalName, &QName,
1081 (IVBSAXAttributes*)&attr->lpVBSAXAttributesVtbl);
1082 else
1083 hr = ISAXContentHandler_startElement(
1084 This->saxreader->contentHandler,
1085 NamespaceUri, SysStringLen(NamespaceUri),
1086 LocalName, SysStringLen(LocalName),
1087 QName, SysStringLen(QName),
1088 (ISAXAttributes*)&attr->lpSAXAttributesVtbl);
1090 ISAXAttributes_Release((ISAXAttributes*)&attr->lpSAXAttributesVtbl);
1093 SysFreeString(NamespaceUri);
1094 SysFreeString(LocalName);
1095 SysFreeString(QName);
1098 if(hr != S_OK)
1099 format_error_message_from_id(This, hr);
1102 static void libxmlEndElementNS(
1103 void *ctx,
1104 const xmlChar *localname,
1105 const xmlChar *prefix,
1106 const xmlChar *URI)
1108 BSTR NamespaceUri, LocalName, QName, Prefix;
1109 saxlocator *This = ctx;
1110 HRESULT hr;
1111 xmlChar *end;
1112 int nsNr, index;
1114 end = (xmlChar*)This->pParserCtxt->input->cur;
1115 if(*(end-1) != '>' || *(end-2) != '/')
1116 while(*(end-2)!='<' && *(end-1)!='/') end--;
1118 update_position(This, end);
1120 nsNr = namespacePop(This);
1122 if((This->vbInterface && This->saxreader->vbcontentHandler)
1123 || (!This->vbInterface && This->saxreader->contentHandler))
1125 NamespaceUri = bstr_from_xmlChar(URI);
1126 LocalName = bstr_from_xmlChar(localname);
1127 QName = QName_from_xmlChar(prefix, localname);
1129 if(This->vbInterface)
1130 hr = IVBSAXContentHandler_endElement(
1131 This->saxreader->vbcontentHandler,
1132 &NamespaceUri, &LocalName, &QName);
1133 else
1134 hr = ISAXContentHandler_endElement(
1135 This->saxreader->contentHandler,
1136 NamespaceUri, SysStringLen(NamespaceUri),
1137 LocalName, SysStringLen(LocalName),
1138 QName, SysStringLen(QName));
1140 SysFreeString(NamespaceUri);
1141 SysFreeString(LocalName);
1142 SysFreeString(QName);
1144 if(hr != S_OK)
1146 format_error_message_from_id(This, hr);
1147 return;
1150 for(index=This->pParserCtxt->nsNr-2;
1151 index>=This->pParserCtxt->nsNr-nsNr*2; index-=2)
1153 Prefix = bstr_from_xmlChar(This->pParserCtxt->nsTab[index]);
1155 if(This->vbInterface)
1156 hr = IVBSAXContentHandler_endPrefixMapping(
1157 This->saxreader->vbcontentHandler, &Prefix);
1158 else
1159 hr = ISAXContentHandler_endPrefixMapping(
1160 This->saxreader->contentHandler,
1161 Prefix, SysStringLen(Prefix));
1163 SysFreeString(Prefix);
1165 if(hr != S_OK)
1167 format_error_message_from_id(This, hr);
1168 return;
1174 update_position(This, NULL);
1177 static void libxmlCharacters(
1178 void *ctx,
1179 const xmlChar *ch,
1180 int len)
1182 saxlocator *This = ctx;
1183 BSTR Chars;
1184 HRESULT hr;
1185 xmlChar *cur;
1186 xmlChar *end;
1187 BOOL lastEvent = FALSE;
1189 if((This->vbInterface && !This->saxreader->vbcontentHandler)
1190 || (!This->vbInterface && !This->saxreader->contentHandler))
1191 return;
1193 cur = (xmlChar*)ch;
1194 if(*(ch-1)=='\r') cur--;
1195 end = cur;
1197 if(ch<This->pParserCtxt->input->base || ch>This->pParserCtxt->input->end)
1198 This->column++;
1200 while(1)
1202 while(end-ch<len && *end!='\r') end++;
1203 if(end-ch==len)
1205 end--;
1206 lastEvent = TRUE;
1209 if(!lastEvent) *end = '\n';
1211 Chars = bstr_from_xmlCharN(cur, end-cur+1);
1212 if(This->vbInterface)
1213 hr = IVBSAXContentHandler_characters(
1214 This->saxreader->vbcontentHandler, &Chars);
1215 else
1216 hr = ISAXContentHandler_characters(
1217 This->saxreader->contentHandler,
1218 Chars, SysStringLen(Chars));
1219 SysFreeString(Chars);
1221 if(hr != S_OK)
1223 format_error_message_from_id(This, hr);
1224 return;
1227 This->column += end-cur+1;
1229 if(lastEvent)
1230 break;
1232 *end = '\r';
1233 end++;
1234 if(*end == '\n')
1236 end++;
1237 This->column++;
1239 cur = end;
1241 if(end-ch == len) break;
1244 if(ch<This->pParserCtxt->input->base || ch>This->pParserCtxt->input->end)
1245 This->column = This->realColumn
1246 +This->pParserCtxt->input->cur-This->lastCur;
1249 static void libxmlSetDocumentLocator(
1250 void *ctx,
1251 xmlSAXLocatorPtr loc)
1253 saxlocator *This = ctx;
1254 HRESULT hr;
1256 if(This->vbInterface)
1257 hr = IVBSAXContentHandler_putref_documentLocator(
1258 This->saxreader->vbcontentHandler,
1259 (IVBSAXLocator*)&This->lpVBSAXLocatorVtbl);
1260 else
1261 hr = ISAXContentHandler_putDocumentLocator(
1262 This->saxreader->contentHandler,
1263 (ISAXLocator*)&This->lpSAXLocatorVtbl);
1265 if(FAILED(hr))
1266 format_error_message_from_id(This, hr);
1269 static void libxmlComment(void *ctx, const xmlChar *value)
1271 saxlocator *This = ctx;
1272 BSTR bValue;
1273 HRESULT hr;
1274 xmlChar *beg = (xmlChar*)This->pParserCtxt->input->cur;
1276 while(memcmp(beg-4, "<!--", sizeof(char[4]))) beg--;
1277 update_position(This, beg);
1279 if(!This->vbInterface && !This->saxreader->lexicalHandler) return;
1280 if(This->vbInterface && !This->saxreader->vblexicalHandler) return;
1282 bValue = bstr_from_xmlChar(value);
1284 if(This->vbInterface)
1285 hr = IVBSAXLexicalHandler_comment(
1286 This->saxreader->vblexicalHandler, &bValue);
1287 else
1288 hr = ISAXLexicalHandler_comment(
1289 This->saxreader->lexicalHandler,
1290 bValue, SysStringLen(bValue));
1292 SysFreeString(bValue);
1294 if(FAILED(hr))
1295 format_error_message_from_id(This, hr);
1297 update_position(This, NULL);
1300 static void libxmlFatalError(void *ctx, const char *msg, ...)
1302 saxlocator *This = ctx;
1303 char message[1024];
1304 WCHAR *wszError;
1305 DWORD len;
1306 va_list args;
1308 if((This->vbInterface && !This->saxreader->vberrorHandler)
1309 || (!This->vbInterface && !This->saxreader->errorHandler))
1311 xmlStopParser(This->pParserCtxt);
1312 This->ret = E_FAIL;
1313 return;
1316 FIXME("Error handling is not compatible.\n");
1318 va_start(args, msg);
1319 vsprintf(message, msg, args);
1320 va_end(args);
1322 len = MultiByteToWideChar(CP_UNIXCP, 0, message, -1, NULL, 0);
1323 wszError = HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR)*len);
1324 if(wszError)
1325 MultiByteToWideChar(CP_UNIXCP, 0, message, -1, wszError, len);
1327 if(This->vbInterface)
1329 BSTR bstrError = SysAllocString(wszError);
1330 IVBSAXErrorHandler_fatalError(This->saxreader->vberrorHandler,
1331 (IVBSAXLocator*)&This->lpVBSAXLocatorVtbl, &bstrError, E_FAIL);
1333 else
1334 ISAXErrorHandler_fatalError(This->saxreader->errorHandler,
1335 (ISAXLocator*)&This->lpSAXLocatorVtbl, wszError, E_FAIL);
1337 HeapFree(GetProcessHeap(), 0, wszError);
1339 xmlStopParser(This->pParserCtxt);
1340 This->ret = E_FAIL;
1343 static void libxmlCDataBlock(void *ctx, const xmlChar *value, int len)
1345 saxlocator *This = ctx;
1346 HRESULT hr = S_OK;
1347 xmlChar *beg = (xmlChar*)This->pParserCtxt->input->cur-len;
1348 xmlChar *cur, *end;
1349 int realLen;
1350 BSTR Chars;
1351 BOOL lastEvent = FALSE, change;
1353 while(memcmp(beg-9, "<![CDATA[", sizeof(char[9]))) beg--;
1354 update_position(This, beg);
1356 if(This->vbInterface && This->saxreader->vblexicalHandler)
1357 hr = IVBSAXLexicalHandler_startCDATA(This->saxreader->vblexicalHandler);
1358 if(!This->vbInterface && This->saxreader->lexicalHandler)
1359 hr = ISAXLexicalHandler_startCDATA(This->saxreader->lexicalHandler);
1361 if(FAILED(hr))
1363 format_error_message_from_id(This, hr);
1364 return;
1367 realLen = This->pParserCtxt->input->cur-beg-3;
1368 cur = beg;
1369 end = beg;
1371 while(1)
1373 while(end-beg<realLen && *end!='\r') end++;
1374 if(end-beg==realLen)
1376 end--;
1377 lastEvent = TRUE;
1379 else if(end-beg==realLen-1 && *end=='\r' && *(end+1)=='\n')
1380 lastEvent = TRUE;
1382 if(*end == '\r') change = TRUE;
1383 else change = FALSE;
1385 if(change) *end = '\n';
1387 if((This->vbInterface && This->saxreader->vbcontentHandler) ||
1388 (!This->vbInterface && This->saxreader->contentHandler))
1390 Chars = bstr_from_xmlCharN(cur, end-cur+1);
1391 if(This->vbInterface)
1392 hr = IVBSAXContentHandler_characters(
1393 This->saxreader->vbcontentHandler, &Chars);
1394 else
1395 hr = ISAXContentHandler_characters(
1396 This->saxreader->contentHandler,
1397 Chars, SysStringLen(Chars));
1398 SysFreeString(Chars);
1401 if(change) *end = '\r';
1403 if(lastEvent)
1404 break;
1406 This->column += end-cur+2;
1407 end += 2;
1408 cur = end;
1411 if(This->vbInterface && This->saxreader->vblexicalHandler)
1412 hr = IVBSAXLexicalHandler_endCDATA(This->saxreader->vblexicalHandler);
1413 if(!This->vbInterface && This->saxreader->lexicalHandler)
1414 hr = ISAXLexicalHandler_endCDATA(This->saxreader->lexicalHandler);
1416 if(FAILED(hr))
1417 format_error_message_from_id(This, hr);
1419 This->column += 4+end-cur;
1422 /*** IVBSAXLocator interface ***/
1423 /*** IUnknown methods ***/
1424 static HRESULT WINAPI ivbsaxlocator_QueryInterface(IVBSAXLocator* iface, REFIID riid, void **ppvObject)
1426 saxlocator *This = impl_from_IVBSAXLocator( iface );
1428 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject);
1430 *ppvObject = NULL;
1432 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
1433 IsEqualGUID( riid, &IID_IDispatch) ||
1434 IsEqualGUID( riid, &IID_IVBSAXLocator ))
1436 *ppvObject = iface;
1438 else
1440 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1441 return E_NOINTERFACE;
1444 IVBSAXLocator_AddRef( iface );
1446 return S_OK;
1449 static ULONG WINAPI ivbsaxlocator_AddRef(IVBSAXLocator* iface)
1451 saxlocator *This = impl_from_IVBSAXLocator( iface );
1452 TRACE("%p\n", This );
1453 return InterlockedIncrement( &This->ref );
1456 static ULONG WINAPI ivbsaxlocator_Release(
1457 IVBSAXLocator* iface)
1459 saxlocator *This = impl_from_IVBSAXLocator( iface );
1460 return ISAXLocator_Release((ISAXLocator*)&This->lpVBSAXLocatorVtbl);
1463 /*** IDispatch methods ***/
1464 static HRESULT WINAPI ivbsaxlocator_GetTypeInfoCount( IVBSAXLocator *iface, UINT* pctinfo )
1466 saxlocator *This = impl_from_IVBSAXLocator( iface );
1468 TRACE("(%p)->(%p)\n", This, pctinfo);
1470 *pctinfo = 1;
1472 return S_OK;
1475 static HRESULT WINAPI ivbsaxlocator_GetTypeInfo(
1476 IVBSAXLocator *iface,
1477 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
1479 saxlocator *This = impl_from_IVBSAXLocator( iface );
1480 HRESULT hr;
1482 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1484 hr = get_typeinfo(IVBSAXLocator_tid, ppTInfo);
1486 return hr;
1489 static HRESULT WINAPI ivbsaxlocator_GetIDsOfNames(
1490 IVBSAXLocator *iface,
1491 REFIID riid,
1492 LPOLESTR* rgszNames,
1493 UINT cNames,
1494 LCID lcid,
1495 DISPID* rgDispId)
1497 saxlocator *This = impl_from_IVBSAXLocator( iface );
1498 ITypeInfo *typeinfo;
1499 HRESULT hr;
1501 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1502 lcid, rgDispId);
1504 if(!rgszNames || cNames == 0 || !rgDispId)
1505 return E_INVALIDARG;
1507 hr = get_typeinfo(IVBSAXLocator_tid, &typeinfo);
1508 if(SUCCEEDED(hr))
1510 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
1511 ITypeInfo_Release(typeinfo);
1514 return hr;
1517 static HRESULT WINAPI ivbsaxlocator_Invoke(
1518 IVBSAXLocator *iface,
1519 DISPID dispIdMember,
1520 REFIID riid,
1521 LCID lcid,
1522 WORD wFlags,
1523 DISPPARAMS* pDispParams,
1524 VARIANT* pVarResult,
1525 EXCEPINFO* pExcepInfo,
1526 UINT* puArgErr)
1528 saxlocator *This = impl_from_IVBSAXLocator( iface );
1529 ITypeInfo *typeinfo;
1530 HRESULT hr;
1532 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1533 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1535 hr = get_typeinfo(IVBSAXLocator_tid, &typeinfo);
1536 if(SUCCEEDED(hr))
1538 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVBSAXLocatorVtbl), dispIdMember, wFlags, pDispParams,
1539 pVarResult, pExcepInfo, puArgErr);
1540 ITypeInfo_Release(typeinfo);
1543 return hr;
1546 /*** IVBSAXLocator methods ***/
1547 static HRESULT WINAPI ivbsaxlocator_get_columnNumber(
1548 IVBSAXLocator* iface,
1549 int *pnColumn)
1551 saxlocator *This = impl_from_IVBSAXLocator( iface );
1552 return ISAXLocator_getColumnNumber(
1553 (ISAXLocator*)&This->lpVBSAXLocatorVtbl,
1554 pnColumn);
1557 static HRESULT WINAPI ivbsaxlocator_get_lineNumber(
1558 IVBSAXLocator* iface,
1559 int *pnLine)
1561 saxlocator *This = impl_from_IVBSAXLocator( iface );
1562 return ISAXLocator_getLineNumber(
1563 (ISAXLocator*)&This->lpVBSAXLocatorVtbl,
1564 pnLine);
1567 static HRESULT WINAPI ivbsaxlocator_get_publicId(
1568 IVBSAXLocator* iface,
1569 BSTR* publicId)
1571 saxlocator *This = impl_from_IVBSAXLocator( iface );
1572 return ISAXLocator_getPublicId(
1573 (ISAXLocator*)&This->lpVBSAXLocatorVtbl,
1574 (const WCHAR**)publicId);
1577 static HRESULT WINAPI ivbsaxlocator_get_systemId(
1578 IVBSAXLocator* iface,
1579 BSTR* systemId)
1581 saxlocator *This = impl_from_IVBSAXLocator( iface );
1582 return ISAXLocator_getSystemId(
1583 (ISAXLocator*)&This->lpVBSAXLocatorVtbl,
1584 (const WCHAR**)systemId);
1587 static const struct IVBSAXLocatorVtbl ivbsaxlocator_vtbl =
1589 ivbsaxlocator_QueryInterface,
1590 ivbsaxlocator_AddRef,
1591 ivbsaxlocator_Release,
1592 ivbsaxlocator_GetTypeInfoCount,
1593 ivbsaxlocator_GetTypeInfo,
1594 ivbsaxlocator_GetIDsOfNames,
1595 ivbsaxlocator_Invoke,
1596 ivbsaxlocator_get_columnNumber,
1597 ivbsaxlocator_get_lineNumber,
1598 ivbsaxlocator_get_publicId,
1599 ivbsaxlocator_get_systemId
1602 /*** ISAXLocator interface ***/
1603 /*** IUnknown methods ***/
1604 static HRESULT WINAPI isaxlocator_QueryInterface(ISAXLocator* iface, REFIID riid, void **ppvObject)
1606 saxlocator *This = impl_from_ISAXLocator( iface );
1608 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
1610 *ppvObject = NULL;
1612 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
1613 IsEqualGUID( riid, &IID_ISAXLocator ))
1615 *ppvObject = iface;
1617 else
1619 FIXME("interface %s not implemented\n", debugstr_guid(riid));
1620 return E_NOINTERFACE;
1623 ISAXLocator_AddRef( iface );
1625 return S_OK;
1628 static ULONG WINAPI isaxlocator_AddRef(ISAXLocator* iface)
1630 saxlocator *This = impl_from_ISAXLocator( iface );
1631 TRACE("%p\n", This );
1632 return InterlockedIncrement( &This->ref );
1635 static ULONG WINAPI isaxlocator_Release(
1636 ISAXLocator* iface)
1638 saxlocator *This = impl_from_ISAXLocator( iface );
1639 LONG ref;
1641 TRACE("%p\n", This );
1643 ref = InterlockedDecrement( &This->ref );
1644 if ( ref == 0 )
1646 SysFreeString(This->publicId);
1647 SysFreeString(This->systemId);
1648 HeapFree(GetProcessHeap(), 0, This->nsStack);
1650 ISAXXMLReader_Release((ISAXXMLReader*)&This->saxreader->lpSAXXMLReaderVtbl);
1651 HeapFree( GetProcessHeap(), 0, This );
1654 return ref;
1657 /*** ISAXLocator methods ***/
1658 static HRESULT WINAPI isaxlocator_getColumnNumber(
1659 ISAXLocator* iface,
1660 int *pnColumn)
1662 saxlocator *This = impl_from_ISAXLocator( iface );
1664 *pnColumn = This->column;
1665 return S_OK;
1668 static HRESULT WINAPI isaxlocator_getLineNumber(
1669 ISAXLocator* iface,
1670 int *pnLine)
1672 saxlocator *This = impl_from_ISAXLocator( iface );
1674 *pnLine = This->line;
1675 return S_OK;
1678 static HRESULT WINAPI isaxlocator_getPublicId(
1679 ISAXLocator* iface,
1680 const WCHAR ** ppwchPublicId)
1682 BSTR publicId;
1683 saxlocator *This = impl_from_ISAXLocator( iface );
1685 SysFreeString(This->publicId);
1687 publicId = bstr_from_xmlChar(xmlSAX2GetPublicId(This->pParserCtxt));
1688 if(SysStringLen(publicId))
1689 This->publicId = (WCHAR*)&publicId;
1690 else
1692 SysFreeString(publicId);
1693 This->publicId = NULL;
1696 *ppwchPublicId = This->publicId;
1697 return S_OK;
1700 static HRESULT WINAPI isaxlocator_getSystemId(
1701 ISAXLocator* iface,
1702 const WCHAR ** ppwchSystemId)
1704 BSTR systemId;
1705 saxlocator *This = impl_from_ISAXLocator( iface );
1707 SysFreeString(This->systemId);
1709 systemId = bstr_from_xmlChar(xmlSAX2GetSystemId(This->pParserCtxt));
1710 if(SysStringLen(systemId))
1711 This->systemId = (WCHAR*)&systemId;
1712 else
1714 SysFreeString(systemId);
1715 This->systemId = NULL;
1718 *ppwchSystemId = This->systemId;
1719 return S_OK;
1722 static const struct ISAXLocatorVtbl isaxlocator_vtbl =
1724 isaxlocator_QueryInterface,
1725 isaxlocator_AddRef,
1726 isaxlocator_Release,
1727 isaxlocator_getColumnNumber,
1728 isaxlocator_getLineNumber,
1729 isaxlocator_getPublicId,
1730 isaxlocator_getSystemId
1733 static HRESULT SAXLocator_create(saxreader *reader, saxlocator **ppsaxlocator, BOOL vbInterface)
1735 saxlocator *locator;
1737 locator = HeapAlloc( GetProcessHeap(), 0, sizeof (*locator) );
1738 if( !locator )
1739 return E_OUTOFMEMORY;
1741 locator->lpVBSAXLocatorVtbl = &ivbsaxlocator_vtbl;
1742 locator->lpSAXLocatorVtbl = &isaxlocator_vtbl;
1743 locator->ref = 1;
1744 locator->vbInterface = vbInterface;
1746 locator->saxreader = reader;
1747 ISAXXMLReader_AddRef((ISAXXMLReader*)&reader->lpSAXXMLReaderVtbl);
1749 locator->pParserCtxt = NULL;
1750 locator->publicId = NULL;
1751 locator->systemId = NULL;
1752 locator->lastCur = NULL;
1753 locator->line = 0;
1754 locator->column = 0;
1755 locator->ret = S_OK;
1756 locator->nsStackSize = 8;
1757 locator->nsStackLast = 0;
1758 locator->nsStack = HeapAlloc(GetProcessHeap(), 0, locator->nsStackSize);
1759 if(!locator->nsStack)
1761 ISAXXMLReader_Release((ISAXXMLReader*)&reader->lpSAXXMLReaderVtbl);
1762 HeapFree(GetProcessHeap(), 0, locator);
1763 return E_OUTOFMEMORY;
1766 *ppsaxlocator = locator;
1768 TRACE("returning %p\n", *ppsaxlocator);
1770 return S_OK;
1773 /*** SAXXMLReader internal functions ***/
1774 static HRESULT internal_parseBuffer(saxreader *This, const char *buffer, int size, BOOL vbInterface)
1776 saxlocator *locator;
1777 HRESULT hr;
1779 hr = SAXLocator_create(This, &locator, vbInterface);
1780 if(FAILED(hr))
1781 return hr;
1783 locator->pParserCtxt = xmlCreateMemoryParserCtxt(buffer, size);
1784 if(!locator->pParserCtxt)
1786 ISAXLocator_Release((ISAXLocator*)&locator->lpSAXLocatorVtbl);
1787 return E_FAIL;
1790 locator->pParserCtxt->sax = &locator->saxreader->sax;
1791 locator->pParserCtxt->userData = locator;
1793 This->isParsing = TRUE;
1794 if(xmlParseDocument(locator->pParserCtxt)) hr = E_FAIL;
1795 else hr = locator->ret;
1796 This->isParsing = FALSE;
1798 if(locator->pParserCtxt)
1800 locator->pParserCtxt->sax = NULL;
1801 xmlFreeParserCtxt(locator->pParserCtxt);
1802 locator->pParserCtxt = NULL;
1805 ISAXLocator_Release((ISAXLocator*)&locator->lpSAXLocatorVtbl);
1806 return hr;
1809 static HRESULT internal_parseStream(saxreader *This, IStream *stream, BOOL vbInterface)
1811 saxlocator *locator;
1812 HRESULT hr;
1813 ULONG dataRead;
1814 char data[1024];
1816 hr = IStream_Read(stream, data, sizeof(data), &dataRead);
1817 if(hr != S_OK)
1818 return hr;
1820 hr = SAXLocator_create(This, &locator, vbInterface);
1821 if(FAILED(hr))
1822 return hr;
1824 locator->pParserCtxt = xmlCreatePushParserCtxt(
1825 &locator->saxreader->sax, locator,
1826 data, dataRead, NULL);
1827 if(!locator->pParserCtxt)
1829 ISAXLocator_Release((ISAXLocator*)&locator->lpSAXLocatorVtbl);
1830 return E_FAIL;
1833 This->isParsing = TRUE;
1834 while(1)
1836 hr = IStream_Read(stream, data, sizeof(data), &dataRead);
1837 if(hr != S_OK)
1838 break;
1840 if(xmlParseChunk(locator->pParserCtxt, data, dataRead, 0)) hr = E_FAIL;
1841 else hr = locator->ret;
1843 if(hr != S_OK) break;
1845 if(dataRead != sizeof(data))
1847 if(xmlParseChunk(locator->pParserCtxt, data, 0, 1)) hr = E_FAIL;
1848 else hr = locator->ret;
1850 break;
1853 This->isParsing = FALSE;
1855 locator->pParserCtxt->sax = NULL;
1856 xmlFreeParserCtxt(locator->pParserCtxt);
1857 locator->pParserCtxt = NULL;
1858 ISAXLocator_Release((ISAXLocator*)&locator->lpSAXLocatorVtbl);
1859 return hr;
1862 static HRESULT internal_getEntityResolver(
1863 saxreader *This,
1864 void *pEntityResolver,
1865 BOOL vbInterface)
1867 FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
1868 return E_NOTIMPL;
1871 static HRESULT internal_putEntityResolver(
1872 saxreader *This,
1873 void *pEntityResolver,
1874 BOOL vbInterface)
1876 FIXME("(%p)->(%p) stub\n", This, pEntityResolver);
1877 return E_NOTIMPL;
1880 static HRESULT internal_getContentHandler(
1881 saxreader* This,
1882 void *pContentHandler,
1883 BOOL vbInterface)
1885 TRACE("(%p)->(%p)\n", This, pContentHandler);
1886 if(pContentHandler == NULL)
1887 return E_POINTER;
1888 if((vbInterface && This->vbcontentHandler)
1889 || (!vbInterface && This->contentHandler))
1891 if(vbInterface)
1892 IVBSAXContentHandler_AddRef(This->vbcontentHandler);
1893 else
1894 ISAXContentHandler_AddRef(This->contentHandler);
1896 if(vbInterface) *(IVBSAXContentHandler**)pContentHandler =
1897 This->vbcontentHandler;
1898 else *(ISAXContentHandler**)pContentHandler = This->contentHandler;
1900 return S_OK;
1903 static HRESULT internal_putContentHandler(
1904 saxreader* This,
1905 void *contentHandler,
1906 BOOL vbInterface)
1908 TRACE("(%p)->(%p)\n", This, contentHandler);
1909 if(contentHandler)
1911 if(vbInterface)
1912 IVBSAXContentHandler_AddRef((IVBSAXContentHandler*)contentHandler);
1913 else
1914 ISAXContentHandler_AddRef((ISAXContentHandler*)contentHandler);
1916 if((vbInterface && This->vbcontentHandler)
1917 || (!vbInterface && This->contentHandler))
1919 if(vbInterface)
1920 IVBSAXContentHandler_Release(This->vbcontentHandler);
1921 else
1922 ISAXContentHandler_Release(This->contentHandler);
1924 if(vbInterface)
1925 This->vbcontentHandler = contentHandler;
1926 else
1927 This->contentHandler = contentHandler;
1929 return S_OK;
1932 static HRESULT internal_getDTDHandler(
1933 saxreader* This,
1934 void *pDTDHandler,
1935 BOOL vbInterface)
1937 FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
1938 return E_NOTIMPL;
1941 static HRESULT internal_putDTDHandler(
1942 saxreader* This,
1943 void *pDTDHandler,
1944 BOOL vbInterface)
1946 FIXME("(%p)->(%p) stub\n", This, pDTDHandler);
1947 return E_NOTIMPL;
1950 static HRESULT internal_getErrorHandler(
1951 saxreader* This,
1952 void *pErrorHandler,
1953 BOOL vbInterface)
1955 TRACE("(%p)->(%p)\n", This, pErrorHandler);
1956 if(pErrorHandler == NULL)
1957 return E_POINTER;
1959 if(vbInterface && This->vberrorHandler)
1960 IVBSAXErrorHandler_AddRef(This->vberrorHandler);
1961 else if(!vbInterface && This->errorHandler)
1962 ISAXErrorHandler_AddRef(This->errorHandler);
1964 if(vbInterface)
1965 *(IVBSAXErrorHandler**)pErrorHandler = This->vberrorHandler;
1966 else
1967 *(ISAXErrorHandler**)pErrorHandler = This->errorHandler;
1969 return S_OK;
1973 static HRESULT internal_putErrorHandler(
1974 saxreader* This,
1975 void *errorHandler,
1976 BOOL vbInterface)
1978 TRACE("(%p)->(%p)\n", This, errorHandler);
1979 if(errorHandler)
1981 if(vbInterface)
1982 IVBSAXErrorHandler_AddRef((IVBSAXErrorHandler*)errorHandler);
1983 else
1984 ISAXErrorHandler_AddRef((ISAXErrorHandler*)errorHandler);
1987 if(vbInterface && This->vberrorHandler)
1988 IVBSAXErrorHandler_Release(This->vberrorHandler);
1989 else if(!vbInterface && This->errorHandler)
1990 ISAXErrorHandler_Release(This->errorHandler);
1992 if(vbInterface)
1993 This->vberrorHandler = errorHandler;
1994 else
1995 This->errorHandler = errorHandler;
1997 return S_OK;
2001 static HRESULT internal_parse(
2002 saxreader* This,
2003 VARIANT varInput,
2004 BOOL vbInterface)
2006 HRESULT hr;
2008 TRACE("(%p)\n", This);
2010 hr = S_OK;
2011 switch(V_VT(&varInput))
2013 case VT_BSTR:
2014 hr = internal_parseBuffer(This, (const char*)V_BSTR(&varInput),
2015 SysStringByteLen(V_BSTR(&varInput)), vbInterface);
2016 break;
2017 case VT_ARRAY|VT_UI1: {
2018 void *pSAData;
2019 LONG lBound, uBound;
2020 ULONG dataRead;
2022 hr = SafeArrayGetLBound(V_ARRAY(&varInput), 1, &lBound);
2023 if(hr != S_OK) break;
2024 hr = SafeArrayGetUBound(V_ARRAY(&varInput), 1, &uBound);
2025 if(hr != S_OK) break;
2026 dataRead = (uBound-lBound)*SafeArrayGetElemsize(V_ARRAY(&varInput));
2027 hr = SafeArrayAccessData(V_ARRAY(&varInput), &pSAData);
2028 if(hr != S_OK) break;
2029 hr = internal_parseBuffer(This, pSAData, dataRead, vbInterface);
2030 SafeArrayUnaccessData(V_ARRAY(&varInput));
2031 break;
2033 case VT_UNKNOWN:
2034 case VT_DISPATCH: {
2035 IPersistStream *persistStream;
2036 IStream *stream = NULL;
2037 IXMLDOMDocument *xmlDoc;
2039 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput),
2040 &IID_IXMLDOMDocument, (void**)&xmlDoc) == S_OK)
2042 BSTR bstrData;
2044 IXMLDOMDocument_get_xml(xmlDoc, &bstrData);
2045 hr = internal_parseBuffer(This, (const char*)bstrData,
2046 SysStringByteLen(bstrData), vbInterface);
2047 IXMLDOMDocument_Release(xmlDoc);
2048 break;
2050 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput),
2051 &IID_IPersistStream, (void**)&persistStream) == S_OK)
2053 hr = IPersistStream_Save(persistStream, stream, TRUE);
2054 IPersistStream_Release(persistStream);
2055 if(hr != S_OK) break;
2057 if(stream || IUnknown_QueryInterface(V_UNKNOWN(&varInput),
2058 &IID_IStream, (void**)&stream) == S_OK)
2060 hr = internal_parseStream(This, stream, vbInterface);
2061 IStream_Release(stream);
2062 break;
2065 default:
2066 WARN("vt %d not implemented\n", V_VT(&varInput));
2067 hr = E_INVALIDARG;
2070 return hr;
2073 static HRESULT internal_vbonDataAvailable(void *obj, char *ptr, DWORD len)
2075 saxreader *This = obj;
2077 return internal_parseBuffer(This, ptr, len, TRUE);
2080 static HRESULT internal_onDataAvailable(void *obj, char *ptr, DWORD len)
2082 saxreader *This = obj;
2084 return internal_parseBuffer(This, ptr, len, FALSE);
2087 static HRESULT internal_parseURL(
2088 saxreader* This,
2089 const WCHAR *url,
2090 BOOL vbInterface)
2092 bsc_t *bsc;
2093 HRESULT hr;
2095 TRACE("(%p)->(%s)\n", This, debugstr_w(url));
2097 if(vbInterface) hr = bind_url(url, internal_vbonDataAvailable, This, &bsc);
2098 else hr = bind_url(url, internal_onDataAvailable, This, &bsc);
2100 if(FAILED(hr))
2101 return hr;
2103 detach_bsc(bsc);
2105 return S_OK;
2108 static HRESULT internal_putProperty(
2109 saxreader* This,
2110 const WCHAR *pProp,
2111 VARIANT value,
2112 BOOL vbInterface)
2114 static const WCHAR wszCharset[] = {
2115 'c','h','a','r','s','e','t',0
2117 static const WCHAR wszDeclarationHandler[] = {
2118 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
2119 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
2120 'd','e','c','l','a','r','a','t','i','o','n',
2121 '-','h','a','n','d','l','e','r',0
2123 static const WCHAR wszDomNode[] = {
2124 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
2125 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
2126 'd','o','m','-','n','o','d','e',0
2128 static const WCHAR wszInputSource[] = {
2129 'i','n','p','u','t','-','s','o','u','r','c','e',0
2131 static const WCHAR wszLexicalHandler[] = {
2132 'h','t','t','p',':','/','/','x','m','l','.','o','r','g','/',
2133 's','a','x','/','p','r','o','p','e','r','t','i','e','s','/',
2134 'l','e','x','i','c','a','l','-','h','a','n','d','l','e','r',0
2136 static const WCHAR wszMaxElementDepth[] = {
2137 'm','a','x','-','e','l','e','m','e','n','t','-','d','e','p','t','h',0
2139 static const WCHAR wszMaxXMLSize[] = {
2140 'm','a','x','-','x','m','l','-','s','i','z','e',0
2142 static const WCHAR wszSchemaDeclarationHandler[] = {
2143 's','c','h','e','m','a','-',
2144 'd','e','c','l','a','r','a','t','i','o','n','-',
2145 'h','a','n','d','l','e','r',0
2147 static const WCHAR wszXMLDeclEncoding[] = {
2148 'x','m','l','d','e','c','l','-','e','n','c','o','d','i','n','g',0
2150 static const WCHAR wszXMLDeclStandalone[] = {
2151 'x','m','l','d','e','c','l',
2152 '-','s','t','a','n','d','a','l','o','n','e',0
2154 static const WCHAR wszXMLDeclVersion[] = {
2155 'x','m','l','d','e','c','l','-','v','e','r','s','i','o','n',0
2158 FIXME("(%p)->(%s): semi-stub\n", This, debugstr_w(pProp));
2160 if(!memcmp(pProp, wszCharset, sizeof(wszCharset)))
2161 return E_NOTIMPL;
2163 if(!memcmp(pProp, wszDeclarationHandler, sizeof(wszDeclarationHandler)))
2165 if(This->isParsing) return E_FAIL;
2167 if(V_UNKNOWN(&value))
2169 if(vbInterface)
2170 IVBSAXDeclHandler_AddRef((IVBSAXDeclHandler*)V_UNKNOWN(&value));
2171 else
2172 ISAXDeclHandler_AddRef((ISAXDeclHandler*)V_UNKNOWN(&value));
2174 if((vbInterface && This->vbdeclHandler)
2175 || (!vbInterface && This->declHandler))
2177 if(vbInterface)
2178 IVBSAXDeclHandler_Release(This->vbdeclHandler);
2179 else
2180 ISAXDeclHandler_Release(This->declHandler);
2182 if(vbInterface)
2183 This->vbdeclHandler = (IVBSAXDeclHandler*)V_UNKNOWN(&value);
2184 else
2185 This->declHandler = (ISAXDeclHandler*)V_UNKNOWN(&value);
2186 return S_OK;
2189 if(!memcmp(pProp, wszDomNode, sizeof(wszDomNode)))
2190 return E_FAIL;
2192 if(!memcmp(pProp, wszInputSource, sizeof(wszInputSource)))
2193 return E_NOTIMPL;
2195 if(!memcmp(pProp, wszLexicalHandler, sizeof(wszLexicalHandler)))
2197 if(This->isParsing) return E_FAIL;
2199 if(V_UNKNOWN(&value))
2201 if(vbInterface)
2202 IVBSAXLexicalHandler_AddRef(
2203 (IVBSAXLexicalHandler*)V_UNKNOWN(&value));
2204 else
2205 ISAXLexicalHandler_AddRef(
2206 (ISAXLexicalHandler*)V_UNKNOWN(&value));
2208 if((vbInterface && This->vblexicalHandler)
2209 || (!vbInterface && This->lexicalHandler))
2211 if(vbInterface)
2212 IVBSAXLexicalHandler_Release(This->vblexicalHandler);
2213 else
2214 ISAXLexicalHandler_Release(This->lexicalHandler);
2216 if(vbInterface)
2217 This->vblexicalHandler = (IVBSAXLexicalHandler*)V_UNKNOWN(&value);
2218 else
2219 This->lexicalHandler = (ISAXLexicalHandler*)V_UNKNOWN(&value);
2220 return S_OK;
2223 if(!memcmp(pProp, wszMaxElementDepth, sizeof(wszMaxElementDepth)))
2224 return E_NOTIMPL;
2226 if(!memcmp(pProp, wszMaxXMLSize, sizeof(wszMaxXMLSize)))
2227 return E_NOTIMPL;
2229 if(!memcmp(pProp, wszSchemaDeclarationHandler,
2230 sizeof(wszSchemaDeclarationHandler)))
2231 return E_NOTIMPL;
2233 if(!memcmp(pProp, wszXMLDeclEncoding, sizeof(wszXMLDeclEncoding)))
2234 return E_FAIL;
2236 if(!memcmp(pProp, wszXMLDeclStandalone, sizeof(wszXMLDeclStandalone)))
2237 return E_FAIL;
2239 if(!memcmp(pProp, wszXMLDeclVersion, sizeof(wszXMLDeclVersion)))
2240 return E_FAIL;
2242 return E_INVALIDARG;
2245 /*** IVBSAXXMLReader interface ***/
2246 /*** IUnknown methods ***/
2247 static HRESULT WINAPI saxxmlreader_QueryInterface(IVBSAXXMLReader* iface, REFIID riid, void **ppvObject)
2249 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2251 TRACE("%p %s %p\n", This, debugstr_guid( riid ), ppvObject );
2253 *ppvObject = NULL;
2255 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
2256 IsEqualGUID( riid, &IID_IDispatch ) ||
2257 IsEqualGUID( riid, &IID_IVBSAXXMLReader ))
2259 *ppvObject = iface;
2261 else if( IsEqualGUID( riid, &IID_ISAXXMLReader ))
2263 *ppvObject = &This->lpSAXXMLReaderVtbl;
2265 else
2267 FIXME("interface %s not implemented\n", debugstr_guid(riid));
2268 return E_NOINTERFACE;
2271 IVBSAXXMLReader_AddRef( iface );
2273 return S_OK;
2276 static ULONG WINAPI saxxmlreader_AddRef(IVBSAXXMLReader* iface)
2278 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2279 TRACE("%p\n", This );
2280 return InterlockedIncrement( &This->ref );
2283 static ULONG WINAPI saxxmlreader_Release(
2284 IVBSAXXMLReader* iface)
2286 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2287 LONG ref;
2289 TRACE("%p\n", This );
2291 ref = InterlockedDecrement( &This->ref );
2292 if ( ref == 0 )
2294 if(This->contentHandler)
2295 ISAXContentHandler_Release(This->contentHandler);
2297 if(This->vbcontentHandler)
2298 IVBSAXContentHandler_Release(This->vbcontentHandler);
2300 if(This->errorHandler)
2301 ISAXErrorHandler_Release(This->errorHandler);
2303 if(This->vberrorHandler)
2304 IVBSAXErrorHandler_Release(This->vberrorHandler);
2306 if(This->lexicalHandler)
2307 ISAXLexicalHandler_Release(This->lexicalHandler);
2309 if(This->vblexicalHandler)
2310 IVBSAXLexicalHandler_Release(This->vblexicalHandler);
2312 if(This->declHandler)
2313 ISAXDeclHandler_Release(This->declHandler);
2315 if(This->vbdeclHandler)
2316 IVBSAXDeclHandler_Release(This->vbdeclHandler);
2318 HeapFree( GetProcessHeap(), 0, This );
2321 return ref;
2323 /*** IDispatch ***/
2324 static HRESULT WINAPI saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader *iface, UINT* pctinfo )
2326 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2328 TRACE("(%p)->(%p)\n", This, pctinfo);
2330 *pctinfo = 1;
2332 return S_OK;
2335 static HRESULT WINAPI saxxmlreader_GetTypeInfo(
2336 IVBSAXXMLReader *iface,
2337 UINT iTInfo, LCID lcid, ITypeInfo** ppTInfo )
2339 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2340 HRESULT hr;
2342 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
2344 hr = get_typeinfo(IVBSAXXMLReader_tid, ppTInfo);
2346 return hr;
2349 static HRESULT WINAPI saxxmlreader_GetIDsOfNames(
2350 IVBSAXXMLReader *iface,
2351 REFIID riid,
2352 LPOLESTR* rgszNames,
2353 UINT cNames,
2354 LCID lcid,
2355 DISPID* rgDispId)
2357 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2358 ITypeInfo *typeinfo;
2359 HRESULT hr;
2361 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
2362 lcid, rgDispId);
2364 if(!rgszNames || cNames == 0 || !rgDispId)
2365 return E_INVALIDARG;
2367 hr = get_typeinfo(IVBSAXXMLReader_tid, &typeinfo);
2368 if(SUCCEEDED(hr))
2370 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
2371 ITypeInfo_Release(typeinfo);
2374 return hr;
2377 static HRESULT WINAPI saxxmlreader_Invoke(
2378 IVBSAXXMLReader *iface,
2379 DISPID dispIdMember,
2380 REFIID riid,
2381 LCID lcid,
2382 WORD wFlags,
2383 DISPPARAMS* pDispParams,
2384 VARIANT* pVarResult,
2385 EXCEPINFO* pExcepInfo,
2386 UINT* puArgErr)
2388 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2389 ITypeInfo *typeinfo;
2390 HRESULT hr;
2392 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
2393 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2395 hr = get_typeinfo(IVBSAXXMLReader_tid, &typeinfo);
2396 if(SUCCEEDED(hr))
2398 hr = ITypeInfo_Invoke(typeinfo, &(This->lpVBSAXXMLReaderVtbl), dispIdMember, wFlags, pDispParams,
2399 pVarResult, pExcepInfo, puArgErr);
2400 ITypeInfo_Release(typeinfo);
2403 return hr;
2406 /*** IVBSAXXMLReader methods ***/
2407 static HRESULT WINAPI saxxmlreader_getFeature(
2408 IVBSAXXMLReader* iface,
2409 const WCHAR *pFeature,
2410 VARIANT_BOOL *pValue)
2412 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2414 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pFeature), pValue);
2415 return E_NOTIMPL;
2418 static HRESULT WINAPI saxxmlreader_putFeature(
2419 IVBSAXXMLReader* iface,
2420 const WCHAR *pFeature,
2421 VARIANT_BOOL vfValue)
2423 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2425 FIXME("(%p)->(%s %x) stub\n", This, debugstr_w(pFeature), vfValue);
2426 return E_NOTIMPL;
2429 static HRESULT WINAPI saxxmlreader_getProperty(
2430 IVBSAXXMLReader* iface,
2431 const WCHAR *pProp,
2432 VARIANT *pValue)
2434 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2436 FIXME("(%p)->(%s %p) stub\n", This, debugstr_w(pProp), pValue);
2437 return E_NOTIMPL;
2440 static HRESULT WINAPI saxxmlreader_putProperty(
2441 IVBSAXXMLReader* iface,
2442 const WCHAR *pProp,
2443 VARIANT value)
2445 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2446 return internal_putProperty(This, pProp, value, TRUE);
2449 static HRESULT WINAPI saxxmlreader_get_entityResolver(
2450 IVBSAXXMLReader* iface,
2451 IVBSAXEntityResolver **pEntityResolver)
2453 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2454 return internal_getEntityResolver(This, pEntityResolver, TRUE);
2457 static HRESULT WINAPI saxxmlreader_put_entityResolver(
2458 IVBSAXXMLReader* iface,
2459 IVBSAXEntityResolver *pEntityResolver)
2461 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2462 return internal_putEntityResolver(This, pEntityResolver, TRUE);
2465 static HRESULT WINAPI saxxmlreader_get_contentHandler(
2466 IVBSAXXMLReader* iface,
2467 IVBSAXContentHandler **ppContentHandler)
2469 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2470 return internal_getContentHandler(This, ppContentHandler, TRUE);
2473 static HRESULT WINAPI saxxmlreader_put_contentHandler(
2474 IVBSAXXMLReader* iface,
2475 IVBSAXContentHandler *contentHandler)
2477 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2478 return internal_putContentHandler(This, contentHandler, TRUE);
2481 static HRESULT WINAPI saxxmlreader_get_dtdHandler(
2482 IVBSAXXMLReader* iface,
2483 IVBSAXDTDHandler **pDTDHandler)
2485 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2486 return internal_getDTDHandler(This, pDTDHandler, TRUE);
2489 static HRESULT WINAPI saxxmlreader_put_dtdHandler(
2490 IVBSAXXMLReader* iface,
2491 IVBSAXDTDHandler *pDTDHandler)
2493 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2494 return internal_putDTDHandler(This, pDTDHandler, TRUE);
2497 static HRESULT WINAPI saxxmlreader_get_errorHandler(
2498 IVBSAXXMLReader* iface,
2499 IVBSAXErrorHandler **pErrorHandler)
2501 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2502 return internal_getErrorHandler(This, pErrorHandler, TRUE);
2505 static HRESULT WINAPI saxxmlreader_put_errorHandler(
2506 IVBSAXXMLReader* iface,
2507 IVBSAXErrorHandler *errorHandler)
2509 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2510 return internal_putErrorHandler(This, errorHandler, TRUE);
2513 static HRESULT WINAPI saxxmlreader_get_baseURL(
2514 IVBSAXXMLReader* iface,
2515 const WCHAR **pBaseUrl)
2517 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2519 FIXME("(%p)->(%p) stub\n", This, pBaseUrl);
2520 return E_NOTIMPL;
2523 static HRESULT WINAPI saxxmlreader_put_baseURL(
2524 IVBSAXXMLReader* iface,
2525 const WCHAR *pBaseUrl)
2527 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2529 FIXME("(%p)->(%s) stub\n", This, debugstr_w(pBaseUrl));
2530 return E_NOTIMPL;
2533 static HRESULT WINAPI saxxmlreader_get_secureBaseURL(
2534 IVBSAXXMLReader* iface,
2535 const WCHAR **pSecureBaseUrl)
2537 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2539 FIXME("(%p)->(%p) stub\n", This, pSecureBaseUrl);
2540 return E_NOTIMPL;
2544 static HRESULT WINAPI saxxmlreader_put_secureBaseURL(
2545 IVBSAXXMLReader* iface,
2546 const WCHAR *secureBaseUrl)
2548 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2550 FIXME("(%p)->(%s) stub\n", This, debugstr_w(secureBaseUrl));
2551 return E_NOTIMPL;
2554 static HRESULT WINAPI saxxmlreader_parse(
2555 IVBSAXXMLReader* iface,
2556 VARIANT varInput)
2558 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2559 return internal_parse(This, varInput, TRUE);
2562 static HRESULT WINAPI saxxmlreader_parseURL(
2563 IVBSAXXMLReader* iface,
2564 const WCHAR *url)
2566 saxreader *This = impl_from_IVBSAXXMLReader( iface );
2567 return internal_parseURL(This, url, TRUE);
2570 static const struct IVBSAXXMLReaderVtbl saxreader_vtbl =
2572 saxxmlreader_QueryInterface,
2573 saxxmlreader_AddRef,
2574 saxxmlreader_Release,
2575 saxxmlreader_GetTypeInfoCount,
2576 saxxmlreader_GetTypeInfo,
2577 saxxmlreader_GetIDsOfNames,
2578 saxxmlreader_Invoke,
2579 saxxmlreader_getFeature,
2580 saxxmlreader_putFeature,
2581 saxxmlreader_getProperty,
2582 saxxmlreader_putProperty,
2583 saxxmlreader_get_entityResolver,
2584 saxxmlreader_put_entityResolver,
2585 saxxmlreader_get_contentHandler,
2586 saxxmlreader_put_contentHandler,
2587 saxxmlreader_get_dtdHandler,
2588 saxxmlreader_put_dtdHandler,
2589 saxxmlreader_get_errorHandler,
2590 saxxmlreader_put_errorHandler,
2591 saxxmlreader_get_baseURL,
2592 saxxmlreader_put_baseURL,
2593 saxxmlreader_get_secureBaseURL,
2594 saxxmlreader_put_secureBaseURL,
2595 saxxmlreader_parse,
2596 saxxmlreader_parseURL
2599 /*** ISAXXMLReader interface ***/
2600 /*** IUnknown methods ***/
2601 static HRESULT WINAPI isaxxmlreader_QueryInterface(ISAXXMLReader* iface, REFIID riid, void **ppvObject)
2603 saxreader *This = impl_from_ISAXXMLReader( iface );
2604 return saxxmlreader_QueryInterface((IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl, riid, ppvObject);
2607 static ULONG WINAPI isaxxmlreader_AddRef(ISAXXMLReader* iface)
2609 saxreader *This = impl_from_ISAXXMLReader( iface );
2610 return saxxmlreader_AddRef((IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl);
2613 static ULONG WINAPI isaxxmlreader_Release(ISAXXMLReader* iface)
2615 saxreader *This = impl_from_ISAXXMLReader( iface );
2616 return saxxmlreader_Release((IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl);
2619 /*** ISAXXMLReader methods ***/
2620 static HRESULT WINAPI isaxxmlreader_getFeature(
2621 ISAXXMLReader* iface,
2622 const WCHAR *pFeature,
2623 VARIANT_BOOL *pValue)
2625 saxreader *This = impl_from_ISAXXMLReader( iface );
2626 return IVBSAXXMLReader_getFeature(
2627 (IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
2628 pFeature, pValue);
2631 static HRESULT WINAPI isaxxmlreader_putFeature(
2632 ISAXXMLReader* iface,
2633 const WCHAR *pFeature,
2634 VARIANT_BOOL vfValue)
2636 saxreader *This = impl_from_ISAXXMLReader( iface );
2637 return IVBSAXXMLReader_putFeature(
2638 (IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
2639 pFeature, vfValue);
2642 static HRESULT WINAPI isaxxmlreader_getProperty(
2643 ISAXXMLReader* iface,
2644 const WCHAR *pProp,
2645 VARIANT *pValue)
2647 saxreader *This = impl_from_ISAXXMLReader( iface );
2648 return IVBSAXXMLReader_getProperty(
2649 (IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
2650 pProp, pValue);
2653 static HRESULT WINAPI isaxxmlreader_putProperty(
2654 ISAXXMLReader* iface,
2655 const WCHAR *pProp,
2656 VARIANT value)
2658 saxreader *This = impl_from_ISAXXMLReader( iface );
2659 return internal_putProperty(This, pProp, value, FALSE);
2662 static HRESULT WINAPI isaxxmlreader_getEntityResolver(
2663 ISAXXMLReader* iface,
2664 ISAXEntityResolver **ppEntityResolver)
2666 saxreader *This = impl_from_ISAXXMLReader( iface );
2667 return internal_getEntityResolver(This, ppEntityResolver, FALSE);
2670 static HRESULT WINAPI isaxxmlreader_putEntityResolver(
2671 ISAXXMLReader* iface,
2672 ISAXEntityResolver *pEntityResolver)
2674 saxreader *This = impl_from_ISAXXMLReader( iface );
2675 return internal_putEntityResolver(This, pEntityResolver, FALSE);
2678 static HRESULT WINAPI isaxxmlreader_getContentHandler(
2679 ISAXXMLReader* iface,
2680 ISAXContentHandler **pContentHandler)
2682 saxreader *This = impl_from_ISAXXMLReader( iface );
2683 return internal_getContentHandler(This, pContentHandler, FALSE);
2686 static HRESULT WINAPI isaxxmlreader_putContentHandler(
2687 ISAXXMLReader* iface,
2688 ISAXContentHandler *contentHandler)
2690 saxreader *This = impl_from_ISAXXMLReader( iface );
2691 return internal_putContentHandler(This, contentHandler, FALSE);
2694 static HRESULT WINAPI isaxxmlreader_getDTDHandler(
2695 ISAXXMLReader* iface,
2696 ISAXDTDHandler **pDTDHandler)
2698 saxreader *This = impl_from_ISAXXMLReader( iface );
2699 return internal_getDTDHandler(This, pDTDHandler, FALSE);
2702 static HRESULT WINAPI isaxxmlreader_putDTDHandler(
2703 ISAXXMLReader* iface,
2704 ISAXDTDHandler *pDTDHandler)
2706 saxreader *This = impl_from_ISAXXMLReader( iface );
2707 return internal_putDTDHandler(This, pDTDHandler, FALSE);
2710 static HRESULT WINAPI isaxxmlreader_getErrorHandler(
2711 ISAXXMLReader* iface,
2712 ISAXErrorHandler **pErrorHandler)
2714 saxreader *This = impl_from_ISAXXMLReader( iface );
2715 return internal_getErrorHandler(This, pErrorHandler, FALSE);
2718 static HRESULT WINAPI isaxxmlreader_putErrorHandler(
2719 ISAXXMLReader* iface,
2720 ISAXErrorHandler *errorHandler)
2722 saxreader *This = impl_from_ISAXXMLReader( iface );
2723 return internal_putErrorHandler(This, errorHandler, FALSE);
2726 static HRESULT WINAPI isaxxmlreader_getBaseURL(
2727 ISAXXMLReader* iface,
2728 const WCHAR **pBaseUrl)
2730 saxreader *This = impl_from_ISAXXMLReader( iface );
2731 return IVBSAXXMLReader_get_baseURL(
2732 (IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
2733 pBaseUrl);
2736 static HRESULT WINAPI isaxxmlreader_putBaseURL(
2737 ISAXXMLReader* iface,
2738 const WCHAR *pBaseUrl)
2740 saxreader *This = impl_from_ISAXXMLReader( iface );
2741 return IVBSAXXMLReader_put_baseURL(
2742 (IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
2743 pBaseUrl);
2746 static HRESULT WINAPI isaxxmlreader_getSecureBaseURL(
2747 ISAXXMLReader* iface,
2748 const WCHAR **pSecureBaseUrl)
2750 saxreader *This = impl_from_ISAXXMLReader( iface );
2751 return IVBSAXXMLReader_get_secureBaseURL(
2752 (IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
2753 pSecureBaseUrl);
2756 static HRESULT WINAPI isaxxmlreader_putSecureBaseURL(
2757 ISAXXMLReader* iface,
2758 const WCHAR *secureBaseUrl)
2760 saxreader *This = impl_from_ISAXXMLReader( iface );
2761 return IVBSAXXMLReader_put_secureBaseURL(
2762 (IVBSAXXMLReader*)&This->lpVBSAXXMLReaderVtbl,
2763 secureBaseUrl);
2766 static HRESULT WINAPI isaxxmlreader_parse(
2767 ISAXXMLReader* iface,
2768 VARIANT varInput)
2770 saxreader *This = impl_from_ISAXXMLReader( iface );
2771 return internal_parse(This, varInput, FALSE);
2774 static HRESULT WINAPI isaxxmlreader_parseURL(
2775 ISAXXMLReader* iface,
2776 const WCHAR *url)
2778 saxreader *This = impl_from_ISAXXMLReader( iface );
2779 return internal_parseURL(This, url, FALSE);
2782 static const struct ISAXXMLReaderVtbl isaxreader_vtbl =
2784 isaxxmlreader_QueryInterface,
2785 isaxxmlreader_AddRef,
2786 isaxxmlreader_Release,
2787 isaxxmlreader_getFeature,
2788 isaxxmlreader_putFeature,
2789 isaxxmlreader_getProperty,
2790 isaxxmlreader_putProperty,
2791 isaxxmlreader_getEntityResolver,
2792 isaxxmlreader_putEntityResolver,
2793 isaxxmlreader_getContentHandler,
2794 isaxxmlreader_putContentHandler,
2795 isaxxmlreader_getDTDHandler,
2796 isaxxmlreader_putDTDHandler,
2797 isaxxmlreader_getErrorHandler,
2798 isaxxmlreader_putErrorHandler,
2799 isaxxmlreader_getBaseURL,
2800 isaxxmlreader_putBaseURL,
2801 isaxxmlreader_getSecureBaseURL,
2802 isaxxmlreader_putSecureBaseURL,
2803 isaxxmlreader_parse,
2804 isaxxmlreader_parseURL
2807 HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
2809 saxreader *reader;
2811 TRACE("(%p,%p)\n", pUnkOuter, ppObj);
2813 reader = HeapAlloc( GetProcessHeap(), 0, sizeof (*reader) );
2814 if( !reader )
2815 return E_OUTOFMEMORY;
2817 reader->lpVBSAXXMLReaderVtbl = &saxreader_vtbl;
2818 reader->lpSAXXMLReaderVtbl = &isaxreader_vtbl;
2819 reader->ref = 1;
2820 reader->contentHandler = NULL;
2821 reader->vbcontentHandler = NULL;
2822 reader->errorHandler = NULL;
2823 reader->vberrorHandler = NULL;
2824 reader->lexicalHandler = NULL;
2825 reader->vblexicalHandler = NULL;
2826 reader->declHandler = NULL;
2827 reader->vbdeclHandler = NULL;
2828 reader->isParsing = FALSE;
2830 memset(&reader->sax, 0, sizeof(xmlSAXHandler));
2831 reader->sax.initialized = XML_SAX2_MAGIC;
2832 reader->sax.startDocument = libxmlStartDocument;
2833 reader->sax.endDocument = libxmlEndDocument;
2834 reader->sax.startElementNs = libxmlStartElementNS;
2835 reader->sax.endElementNs = libxmlEndElementNS;
2836 reader->sax.characters = libxmlCharacters;
2837 reader->sax.setDocumentLocator = libxmlSetDocumentLocator;
2838 reader->sax.comment = libxmlComment;
2839 reader->sax.error = libxmlFatalError;
2840 reader->sax.fatalError = libxmlFatalError;
2841 reader->sax.cdataBlock = libxmlCDataBlock;
2843 *ppObj = &reader->lpVBSAXXMLReaderVtbl;
2845 TRACE("returning iface %p\n", *ppObj);
2847 return S_OK;
2850 #else
2852 HRESULT SAXXMLReader_create(IUnknown *pUnkOuter, LPVOID *ppObj)
2854 MESSAGE("This program tried to use a SAX XML Reader object, but\n"
2855 "libxml2 support was not present at compile time.\n");
2856 return E_NOTIMPL;
2859 #endif