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
38 #include "wine/debug.h"
40 #include "msxml_private.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
46 #include <libxml/SAX2.h>
47 #include <libxml/parserInternals.h>
49 typedef struct _saxreader
51 const struct IVBSAXXMLReaderVtbl
*lpVBSAXXMLReaderVtbl
;
52 const struct ISAXXMLReaderVtbl
*lpSAXXMLReaderVtbl
;
54 struct ISAXContentHandler
*contentHandler
;
55 struct IVBSAXContentHandler
*vbcontentHandler
;
56 struct ISAXErrorHandler
*errorHandler
;
57 struct IVBSAXErrorHandler
*vberrorHandler
;
61 typedef struct _saxlocator
63 const struct IVBSAXLocatorVtbl
*lpVBSAXLocatorVtbl
;
64 const struct ISAXLocatorVtbl
*lpSAXLocatorVtbl
;
68 xmlParserCtxtPtr pParserCtxt
;
80 typedef struct _saxattributes
82 const struct IVBSAXAttributesVtbl
*lpVBSAXAttributesVtbl
;
83 const struct ISAXAttributesVtbl
*lpSAXAttributesVtbl
;
92 static inline saxreader
*impl_from_IVBSAXXMLReader( IVBSAXXMLReader
*iface
)
94 return (saxreader
*)((char*)iface
- FIELD_OFFSET(saxreader
, lpVBSAXXMLReaderVtbl
));
97 static inline saxreader
*impl_from_ISAXXMLReader( ISAXXMLReader
*iface
)
99 return (saxreader
*)((char*)iface
- FIELD_OFFSET(saxreader
, lpSAXXMLReaderVtbl
));
102 static inline saxlocator
*impl_from_IVBSAXLocator( IVBSAXLocator
*iface
)
104 return (saxlocator
*)((char*)iface
- FIELD_OFFSET(saxlocator
, lpVBSAXLocatorVtbl
));
107 static inline saxlocator
*impl_from_ISAXLocator( ISAXLocator
*iface
)
109 return (saxlocator
*)((char*)iface
- FIELD_OFFSET(saxlocator
, lpSAXLocatorVtbl
));
112 static inline saxattributes
*impl_from_IVBSAXAttributes( IVBSAXAttributes
*iface
)
114 return (saxattributes
*)((char*)iface
- FIELD_OFFSET(saxattributes
, lpVBSAXAttributesVtbl
));
117 static inline saxattributes
*impl_from_ISAXAttributes( ISAXAttributes
*iface
)
119 return (saxattributes
*)((char*)iface
- FIELD_OFFSET(saxattributes
, lpSAXAttributesVtbl
));
123 static HRESULT
namespacePush(saxlocator
*locator
, int ns
)
125 if(locator
->nsStackLast
>=locator
->nsStackSize
)
129 new_stack
= HeapReAlloc(GetProcessHeap(), 0,
130 locator
->nsStack
, locator
->nsStackSize
*2);
131 if(!new_stack
) return E_OUTOFMEMORY
;
132 locator
->nsStack
= new_stack
;
133 locator
->nsStackSize
*= 2;
135 locator
->nsStack
[locator
->nsStackLast
++] = ns
;
140 static int namespacePop(saxlocator
*locator
)
142 if(locator
->nsStackLast
== 0) return 0;
143 return locator
->nsStack
[--locator
->nsStackLast
];
146 static BSTR
bstr_from_xmlCharN(const xmlChar
*buf
, int len
)
155 dLen
= MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)buf
, len
, NULL
, 0);
156 if(len
!= -1) dLen
++;
157 str
= (LPWSTR
)HeapAlloc(GetProcessHeap(), 0, dLen
* sizeof (WCHAR
));
160 MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)buf
, len
, str
, dLen
);
161 if(len
!= -1) str
[dLen
-1] = '\0';
162 bstr
= SysAllocString(str
);
163 HeapFree(GetProcessHeap(), 0, str
);
168 static BSTR
QName_from_xmlChar(const xmlChar
*prefix
, const xmlChar
*name
)
174 if(!name
) return NULL
;
176 if(!prefix
|| *prefix
=='\0')
177 return bstr_from_xmlChar(name
);
179 dLen
= MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)prefix
, -1, NULL
, 0)
180 + MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)name
, -1, NULL
, 0);
181 str
= HeapAlloc(GetProcessHeap(), 0, dLen
* sizeof(WCHAR
));
185 dLast
= MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)prefix
, -1, str
, dLen
);
187 MultiByteToWideChar(CP_UTF8
, 0, (LPCSTR
)name
, -1, &str
[dLast
], dLen
-dLast
);
188 bstr
= SysAllocString(str
);
190 HeapFree(GetProcessHeap(), 0, str
);
195 static void format_error_message_from_id(saxlocator
*This
, HRESULT hr
)
197 xmlStopParser(This
->pParserCtxt
);
200 if((This
->vbInterface
&& This
->saxreader
->vberrorHandler
)
201 || (!This
->vbInterface
&& This
->saxreader
->errorHandler
))
204 if(!FormatMessageW(FORMAT_MESSAGE_FROM_SYSTEM
,
205 NULL
, hr
, 0, msg
, sizeof(msg
), NULL
))
207 FIXME("MSXML errors not yet supported.\n");
211 if(This
->vbInterface
)
213 BSTR bstrMsg
= SysAllocString(msg
);
214 IVBSAXErrorHandler_fatalError(This
->saxreader
->vberrorHandler
,
215 (IVBSAXLocator
*)&This
->lpVBSAXLocatorVtbl
, &bstrMsg
, hr
);
218 ISAXErrorHandler_fatalError(This
->saxreader
->errorHandler
,
219 (ISAXLocator
*)&This
->lpSAXLocatorVtbl
, msg
, hr
);
223 static void update_position(saxlocator
*This
, xmlChar
*end
)
225 if(This
->lastCur
== NULL
)
227 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
231 else if(This
->lastCur
< This
->pParserCtxt
->input
->base
)
233 This
->lastCur
= (xmlChar
*)This
->pParserCtxt
->input
->base
;
238 if(!end
) end
= (xmlChar
*)This
->pParserCtxt
->input
->cur
;
240 while(This
->lastCur
< end
)
242 if(*(This
->lastCur
) == '\n')
247 else if(*(This
->lastCur
) == '\r' && (This
->lastCur
==This
->pParserCtxt
->input
->end
|| *(This
->lastCur
+1)!='\n'))
258 /*** IVBSAXAttributes interface ***/
259 /*** IUnknown methods ***/
260 static HRESULT WINAPI
ivbsaxattributes_QueryInterface(
261 IVBSAXAttributes
* iface
,
265 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
267 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
271 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
272 IsEqualGUID(riid
, &IID_IDispatch
) ||
273 IsEqualGUID(riid
, &IID_IVBSAXAttributes
))
279 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
280 return E_NOINTERFACE
;
283 IVBSAXAttributes_AddRef(iface
);
288 static ULONG WINAPI
ivbsaxattributes_AddRef(IVBSAXAttributes
* iface
)
290 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
291 return ISAXAttributes_AddRef((ISAXAttributes
*)&This
->lpSAXAttributesVtbl
);
294 static ULONG WINAPI
ivbsaxattributes_Release(IVBSAXAttributes
* iface
)
296 saxattributes
*This
= impl_from_IVBSAXAttributes(iface
);
297 return ISAXAttributes_Release((ISAXAttributes
*)&This
->lpSAXAttributesVtbl
);
300 /*** IDispatch methods ***/
301 static HRESULT WINAPI
ivbsaxattributes_GetTypeInfoCount( IVBSAXAttributes
*iface
, UINT
* pctinfo
)
303 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
305 TRACE("(%p)->(%p)\n", This
, pctinfo
);
312 static HRESULT WINAPI
ivbsaxattributes_GetTypeInfo(
313 IVBSAXAttributes
*iface
,
314 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
316 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
319 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
321 hr
= get_typeinfo(IVBSAXAttributes_tid
, ppTInfo
);
326 static HRESULT WINAPI
ivbsaxattributes_GetIDsOfNames(
327 IVBSAXAttributes
*iface
,
334 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
338 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
341 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
344 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
347 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
348 ITypeInfo_Release(typeinfo
);
354 static HRESULT WINAPI
ivbsaxattributes_Invoke(
355 IVBSAXAttributes
*iface
,
360 DISPPARAMS
* pDispParams
,
362 EXCEPINFO
* pExcepInfo
,
365 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
369 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
370 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
372 hr
= get_typeinfo(IVBSAXAttributes_tid
, &typeinfo
);
375 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVBSAXAttributesVtbl
), dispIdMember
, wFlags
, pDispParams
,
376 pVarResult
, pExcepInfo
, puArgErr
);
377 ITypeInfo_Release(typeinfo
);
383 /*** IVBSAXAttributes methods ***/
384 static HRESULT WINAPI
ivbsaxattributes_get_length(
385 IVBSAXAttributes
* iface
,
388 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
389 return ISAXAttributes_getLength(
390 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
394 static HRESULT WINAPI
ivbsaxattributes_getURI(
395 IVBSAXAttributes
* iface
,
400 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
401 return ISAXAttributes_getURI(
402 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
403 nIndex
, (const WCHAR
**)uri
, &len
);
406 static HRESULT WINAPI
ivbsaxattributes_getLocalName(
407 IVBSAXAttributes
* iface
,
412 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
413 return ISAXAttributes_getLocalName(
414 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
415 nIndex
, (const WCHAR
**)localName
, &len
);
418 static HRESULT WINAPI
ivbsaxattributes_getQName(
419 IVBSAXAttributes
* iface
,
424 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
425 return ISAXAttributes_getQName(
426 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
427 nIndex
, (const WCHAR
**)QName
, &len
);
430 static HRESULT WINAPI
ivbsaxattributes_getIndexFromName(
431 IVBSAXAttributes
* iface
,
436 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
437 return ISAXAttributes_getIndexFromName(
438 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
439 (const WCHAR
*)uri
, SysStringLen(uri
),
440 (const WCHAR
*)localName
, SysStringLen(localName
), index
);
443 static HRESULT WINAPI
ivbsaxattributes_getIndexFromQName(
444 IVBSAXAttributes
* iface
,
448 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
449 return ISAXAttributes_getIndexFromQName(
450 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
451 (const WCHAR
*)QName
, SysStringLen(QName
), index
);
454 static HRESULT WINAPI
ivbsaxattributes_getType(
455 IVBSAXAttributes
* iface
,
460 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
461 return ISAXAttributes_getType(
462 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
463 nIndex
, (const WCHAR
**)type
, &len
);
466 static HRESULT WINAPI
ivbsaxattributes_getTypeFromName(
467 IVBSAXAttributes
* iface
,
473 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
474 return ISAXAttributes_getTypeFromName(
475 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
476 (const WCHAR
*)uri
, SysStringLen(uri
),
477 (const WCHAR
*)localName
, SysStringLen(localName
),
478 (const WCHAR
**)type
, &len
);
481 static HRESULT WINAPI
ivbsaxattributes_getTypeFromQName(
482 IVBSAXAttributes
* iface
,
487 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
488 return ISAXAttributes_getTypeFromQName(
489 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
490 (const WCHAR
*)QName
, SysStringLen(QName
),
491 (const WCHAR
**)type
, &len
);
494 static HRESULT WINAPI
ivbsaxattributes_getValue(
495 IVBSAXAttributes
* iface
,
500 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
501 return ISAXAttributes_getValue(
502 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
503 nIndex
, (const WCHAR
**)value
, &len
);
506 static HRESULT WINAPI
ivbsaxattributes_getValueFromName(
507 IVBSAXAttributes
* iface
,
513 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
514 return ISAXAttributes_getValueFromName(
515 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
516 (const WCHAR
*)uri
, SysStringLen(uri
),
517 (const WCHAR
*)localName
, SysStringLen(localName
),
518 (const WCHAR
**)value
, &len
);
521 static HRESULT WINAPI
ivbsaxattributes_getValueFromQName(
522 IVBSAXAttributes
* iface
,
527 saxattributes
*This
= impl_from_IVBSAXAttributes( iface
);
528 return ISAXAttributes_getValueFromQName(
529 (ISAXAttributes
*)&This
->lpSAXAttributesVtbl
,
530 (const WCHAR
*)QName
, SysStringLen(QName
),
531 (const WCHAR
**)value
, &len
);
534 static const struct IVBSAXAttributesVtbl ivbsaxattributes_vtbl
=
536 ivbsaxattributes_QueryInterface
,
537 ivbsaxattributes_AddRef
,
538 ivbsaxattributes_Release
,
539 ivbsaxattributes_GetTypeInfoCount
,
540 ivbsaxattributes_GetTypeInfo
,
541 ivbsaxattributes_GetIDsOfNames
,
542 ivbsaxattributes_Invoke
,
543 ivbsaxattributes_get_length
,
544 ivbsaxattributes_getURI
,
545 ivbsaxattributes_getLocalName
,
546 ivbsaxattributes_getQName
,
547 ivbsaxattributes_getIndexFromName
,
548 ivbsaxattributes_getIndexFromQName
,
549 ivbsaxattributes_getType
,
550 ivbsaxattributes_getTypeFromName
,
551 ivbsaxattributes_getTypeFromQName
,
552 ivbsaxattributes_getValue
,
553 ivbsaxattributes_getValueFromName
,
554 ivbsaxattributes_getValueFromQName
557 /*** ISAXAttributes interface ***/
558 /*** IUnknown methods ***/
559 static HRESULT WINAPI
isaxattributes_QueryInterface(
560 ISAXAttributes
* iface
,
564 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
566 TRACE("%p %s %p\n", This
, debugstr_guid(riid
), ppvObject
);
570 if (IsEqualGUID(riid
, &IID_IUnknown
) ||
571 IsEqualGUID(riid
, &IID_ISAXAttributes
))
577 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
578 return E_NOINTERFACE
;
581 ISAXAttributes_AddRef(iface
);
586 static ULONG WINAPI
isaxattributes_AddRef(ISAXAttributes
* iface
)
588 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
590 return InterlockedIncrement(&This
->ref
);
593 static ULONG WINAPI
isaxattributes_Release(ISAXAttributes
* iface
)
595 saxattributes
*This
= impl_from_ISAXAttributes(iface
);
600 ref
= InterlockedDecrement(&This
->ref
);
604 for(index
=0; index
<This
->nb_attributes
; index
++)
606 SysFreeString(This
->szLocalname
[index
]);
607 SysFreeString(This
->szURI
[index
]);
608 SysFreeString(This
->szValue
[index
]);
609 SysFreeString(This
->szQName
[index
]);
612 HeapFree(GetProcessHeap(), 0, This
->szLocalname
);
613 HeapFree(GetProcessHeap(), 0, This
->szURI
);
614 HeapFree(GetProcessHeap(), 0, This
->szValue
);
615 HeapFree(GetProcessHeap(), 0, This
->szQName
);
617 HeapFree(GetProcessHeap(), 0, This
);
623 /*** ISAXAttributes methods ***/
624 static HRESULT WINAPI
isaxattributes_getLength(
625 ISAXAttributes
* iface
,
628 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
630 *length
= This
->nb_attributes
;
631 TRACE("Length set to %d\n", *length
);
635 static HRESULT WINAPI
isaxattributes_getURI(
636 ISAXAttributes
* iface
,
641 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
642 TRACE("(%p)->(%d)\n", This
, nIndex
);
644 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
645 if(!pUrl
|| !pUriSize
) return E_POINTER
;
647 *pUriSize
= SysStringLen(This
->szURI
[nIndex
]);
648 *pUrl
= This
->szURI
[nIndex
];
653 static HRESULT WINAPI
isaxattributes_getLocalName(
654 ISAXAttributes
* iface
,
656 const WCHAR
**pLocalName
,
657 int *pLocalNameLength
)
659 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
660 TRACE("(%p)->(%d)\n", This
, nIndex
);
662 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
663 if(!pLocalName
|| !pLocalNameLength
) return E_POINTER
;
665 *pLocalNameLength
= SysStringLen(This
->szLocalname
[nIndex
]);
666 *pLocalName
= This
->szLocalname
[nIndex
];
671 static HRESULT WINAPI
isaxattributes_getQName(
672 ISAXAttributes
* iface
,
674 const WCHAR
**pQName
,
677 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
678 TRACE("(%p)->(%d)\n", This
, nIndex
);
680 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
681 if(!pQName
|| !pQNameLength
) return E_POINTER
;
683 *pQNameLength
= SysStringLen(This
->szQName
[nIndex
]);
684 *pQName
= This
->szQName
[nIndex
];
689 static HRESULT WINAPI
isaxattributes_getName(
690 ISAXAttributes
* iface
,
694 const WCHAR
**pLocalName
,
696 const WCHAR
**pQName
,
699 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
700 TRACE("(%p)->(%d)\n", This
, nIndex
);
702 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
703 if(!pUri
|| !pUriLength
|| !pLocalName
|| !pLocalNameSize
704 || !pQName
|| !pQNameLength
) return E_POINTER
;
706 *pUriLength
= SysStringLen(This
->szURI
[nIndex
]);
707 *pUri
= This
->szURI
[nIndex
];
708 *pLocalNameSize
= SysStringLen(This
->szLocalname
[nIndex
]);
709 *pLocalName
= This
->szLocalname
[nIndex
];
710 *pQNameLength
= SysStringLen(This
->szQName
[nIndex
]);
711 *pQName
= This
->szQName
[nIndex
];
716 static HRESULT WINAPI
isaxattributes_getIndexFromName(
717 ISAXAttributes
* iface
,
720 const WCHAR
*pLocalName
,
724 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
726 TRACE("(%p)->(%s, %d, %s, %d)\n", This
, debugstr_w(pUri
), cUriLength
,
727 debugstr_w(pLocalName
), cocalNameLength
);
729 if(!pUri
|| !pLocalName
|| !index
) return E_POINTER
;
731 for(i
=0; i
<This
->nb_attributes
; i
++)
733 if(cUriLength
!=SysStringLen(This
->szURI
[i
])
734 || cocalNameLength
!=SysStringLen(This
->szLocalname
[i
]))
736 if(cUriLength
&& memcmp(pUri
, This
->szURI
[i
],
737 sizeof(WCHAR
)*cUriLength
))
739 if(cocalNameLength
&& memcmp(pLocalName
, This
->szLocalname
[i
],
740 sizeof(WCHAR
)*cocalNameLength
))
750 static HRESULT WINAPI
isaxattributes_getIndexFromQName(
751 ISAXAttributes
* iface
,
756 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
758 TRACE("(%p)->(%s, %d)\n", This
, debugstr_w(pQName
), nQNameLength
);
760 if(!pQName
|| !index
) return E_POINTER
;
761 if(!nQNameLength
) return E_INVALIDARG
;
763 for(i
=0; i
<This
->nb_attributes
; i
++)
765 if(nQNameLength
!=SysStringLen(This
->szQName
[i
])) continue;
766 if(memcmp(pQName
, This
->szQName
, sizeof(WCHAR
)*nQNameLength
)) continue;
775 static HRESULT WINAPI
isaxattributes_getType(
776 ISAXAttributes
* iface
,
781 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
783 FIXME("(%p)->(%d) stub\n", This
, nIndex
);
787 static HRESULT WINAPI
isaxattributes_getTypeFromName(
788 ISAXAttributes
* iface
,
791 const WCHAR
*pLocalName
,
796 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
798 FIXME("(%p)->(%s, %d, %s, %d) stub\n", This
, debugstr_w(pUri
), nUri
,
799 debugstr_w(pLocalName
), nLocalName
);
803 static HRESULT WINAPI
isaxattributes_getTypeFromQName(
804 ISAXAttributes
* iface
,
810 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
812 FIXME("(%p)->(%s, %d) stub\n", This
, debugstr_w(pQName
), nQName
);
816 static HRESULT WINAPI
isaxattributes_getValue(
817 ISAXAttributes
* iface
,
819 const WCHAR
**pValue
,
822 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
823 TRACE("(%p)->(%d)\n", This
, nIndex
);
825 if(nIndex
>=This
->nb_attributes
|| nIndex
<0) return E_INVALIDARG
;
826 if(!pValue
|| !nValue
) return E_POINTER
;
828 *nValue
= SysStringLen(This
->szValue
[nIndex
]);
829 *pValue
= This
->szValue
[nIndex
];
834 static HRESULT WINAPI
isaxattributes_getValueFromName(
835 ISAXAttributes
* iface
,
838 const WCHAR
*pLocalName
,
840 const WCHAR
**pValue
,
845 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
846 TRACE("(%p)->(%s, %d, %s, %d)\n", This
, debugstr_w(pUri
), nUri
,
847 debugstr_w(pLocalName
), nLocalName
);
849 hr
= ISAXAttributes_getIndexFromName(iface
,
850 pUri
, nUri
, pLocalName
, nLocalName
, &index
);
851 if(hr
==S_OK
) hr
= ISAXAttributes_getValue(iface
, index
, pValue
, nValue
);
856 static HRESULT WINAPI
isaxattributes_getValueFromQName(
857 ISAXAttributes
* iface
,
860 const WCHAR
**pValue
,
865 saxattributes
*This
= impl_from_ISAXAttributes( iface
);
866 TRACE("(%p)->(%s, %d)\n", This
, debugstr_w(pQName
), nQName
);
868 hr
= ISAXAttributes_getIndexFromQName(iface
, pQName
, nQName
, &index
);
869 if(hr
==S_OK
) hr
= ISAXAttributes_getValue(iface
, index
, pValue
, nValue
);
874 static const struct ISAXAttributesVtbl isaxattributes_vtbl
=
876 isaxattributes_QueryInterface
,
877 isaxattributes_AddRef
,
878 isaxattributes_Release
,
879 isaxattributes_getLength
,
880 isaxattributes_getURI
,
881 isaxattributes_getLocalName
,
882 isaxattributes_getQName
,
883 isaxattributes_getName
,
884 isaxattributes_getIndexFromName
,
885 isaxattributes_getIndexFromQName
,
886 isaxattributes_getType
,
887 isaxattributes_getTypeFromName
,
888 isaxattributes_getTypeFromQName
,
889 isaxattributes_getValue
,
890 isaxattributes_getValueFromName
,
891 isaxattributes_getValueFromQName
894 static HRESULT
SAXAttributes_create(saxattributes
**attr
,
895 int nb_namespaces
, const xmlChar
**xmlNamespaces
,
896 int nb_attributes
, const xmlChar
**xmlAttributes
)
898 saxattributes
*attributes
;
900 static const xmlChar xmlns
[] = "xmlns";
902 attributes
= HeapAlloc(GetProcessHeap(), 0, sizeof(*attributes
));
904 return E_OUTOFMEMORY
;
906 attributes
->lpVBSAXAttributesVtbl
= &ivbsaxattributes_vtbl
;
907 attributes
->lpSAXAttributesVtbl
= &isaxattributes_vtbl
;
910 attributes
->nb_attributes
= nb_namespaces
+nb_attributes
;
912 attributes
->szLocalname
=
913 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR
)*attributes
->nb_attributes
);
915 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR
)*attributes
->nb_attributes
);
916 attributes
->szValue
=
917 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR
)*attributes
->nb_attributes
);
918 attributes
->szQName
=
919 HeapAlloc(GetProcessHeap(), 0, sizeof(BSTR
)*attributes
->nb_attributes
);
921 if(!attributes
->szLocalname
|| !attributes
->szURI
922 || !attributes
->szValue
|| !attributes
->szQName
)
924 HeapFree(GetProcessHeap(), 0, attributes
->szLocalname
);
925 HeapFree(GetProcessHeap(), 0, attributes
->szURI
);
926 HeapFree(GetProcessHeap(), 0, attributes
->szValue
);
927 HeapFree(GetProcessHeap(), 0, attributes
->szQName
);
928 HeapFree(GetProcessHeap(), 0, attributes
);
932 for(index
=0; index
<nb_namespaces
; index
++)
934 attributes
->szLocalname
[index
] = SysAllocStringLen(NULL
, 0);
935 attributes
->szURI
[index
] = SysAllocStringLen(NULL
, 0);
936 attributes
->szValue
[index
] = bstr_from_xmlChar(xmlNamespaces
[2*index
+1]);
937 attributes
->szQName
[index
] = QName_from_xmlChar(xmlns
, xmlNamespaces
[2*index
]);
940 for(index
=0; index
<nb_attributes
; index
++)
942 attributes
->szLocalname
[nb_namespaces
+index
] =
943 bstr_from_xmlChar(xmlAttributes
[index
*5]);
944 attributes
->szURI
[nb_namespaces
+index
] =
945 bstr_from_xmlChar(xmlAttributes
[index
*5+2]);
946 attributes
->szValue
[nb_namespaces
+index
] =
947 bstr_from_xmlCharN(xmlAttributes
[index
*5+3],
948 xmlAttributes
[index
*5+4]-xmlAttributes
[index
*5+3]);
949 attributes
->szQName
[nb_namespaces
+index
] =
950 QName_from_xmlChar(xmlAttributes
[index
*5+1], xmlAttributes
[index
*5]);
955 TRACE("returning %p\n", *attr
);
960 /*** LibXML callbacks ***/
961 static void libxmlStartDocument(void *ctx
)
963 saxlocator
*This
= ctx
;
966 if((This
->vbInterface
&& This
->saxreader
->vbcontentHandler
)
967 || (!This
->vbInterface
&& This
->saxreader
->contentHandler
))
969 if(This
->vbInterface
)
970 hr
= IVBSAXContentHandler_startDocument(This
->saxreader
->vbcontentHandler
);
972 hr
= ISAXContentHandler_startDocument(This
->saxreader
->contentHandler
);
975 format_error_message_from_id(This
, hr
);
978 update_position(This
, NULL
);
981 static void libxmlEndDocument(void *ctx
)
983 saxlocator
*This
= ctx
;
989 if(This
->ret
!= S_OK
) return;
991 if((This
->vbInterface
&& This
->saxreader
->vbcontentHandler
)
992 || (!This
->vbInterface
&& This
->saxreader
->contentHandler
))
994 if(This
->vbInterface
)
995 hr
= IVBSAXContentHandler_endDocument(This
->saxreader
->vbcontentHandler
);
997 hr
= ISAXContentHandler_endDocument(This
->saxreader
->contentHandler
);
1000 format_error_message_from_id(This
, hr
);
1004 static void libxmlStartElementNS(
1006 const xmlChar
*localname
,
1007 const xmlChar
*prefix
,
1010 const xmlChar
**namespaces
,
1013 const xmlChar
**attributes
)
1015 BSTR NamespaceUri
, LocalName
, QName
, Prefix
, Uri
;
1016 saxlocator
*This
= ctx
;
1018 saxattributes
*attr
;
1021 update_position(This
, (xmlChar
*)This
->pParserCtxt
->input
->cur
+1);
1023 hr
= namespacePush(This
, nb_namespaces
);
1024 if(hr
==S_OK
&& ((This
->vbInterface
&& This
->saxreader
->vbcontentHandler
)
1025 || (!This
->vbInterface
&& This
->saxreader
->contentHandler
)))
1027 for(index
=0; index
<nb_namespaces
; index
++)
1029 Prefix
= bstr_from_xmlChar(namespaces
[2*index
]);
1030 Uri
= bstr_from_xmlChar(namespaces
[2*index
+1]);
1032 if(This
->vbInterface
)
1033 hr
= IVBSAXContentHandler_startPrefixMapping(
1034 This
->saxreader
->vbcontentHandler
,
1037 hr
= ISAXContentHandler_startPrefixMapping(
1038 This
->saxreader
->contentHandler
,
1039 Prefix
, SysStringLen(Prefix
),
1040 Uri
, SysStringLen(Uri
));
1042 SysFreeString(Prefix
);
1047 format_error_message_from_id(This
, hr
);
1052 NamespaceUri
= bstr_from_xmlChar(URI
);
1053 LocalName
= bstr_from_xmlChar(localname
);
1054 QName
= QName_from_xmlChar(prefix
, localname
);
1056 hr
= SAXAttributes_create(&attr
, nb_namespaces
, namespaces
, nb_attributes
, attributes
);
1059 if(This
->vbInterface
)
1060 hr
= IVBSAXContentHandler_startElement(
1061 This
->saxreader
->vbcontentHandler
,
1062 &NamespaceUri
, &LocalName
, &QName
,
1063 (IVBSAXAttributes
*)&attr
->lpVBSAXAttributesVtbl
);
1065 hr
= ISAXContentHandler_startElement(
1066 This
->saxreader
->contentHandler
,
1067 NamespaceUri
, SysStringLen(NamespaceUri
),
1068 LocalName
, SysStringLen(LocalName
),
1069 QName
, SysStringLen(QName
),
1070 (ISAXAttributes
*)&attr
->lpSAXAttributesVtbl
);
1072 ISAXAttributes_Release((ISAXAttributes
*)&attr
->lpSAXAttributesVtbl
);
1075 SysFreeString(NamespaceUri
);
1076 SysFreeString(LocalName
);
1077 SysFreeString(QName
);
1081 format_error_message_from_id(This
, hr
);
1084 static void libxmlEndElementNS(
1086 const xmlChar
*localname
,
1087 const xmlChar
*prefix
,
1090 BSTR NamespaceUri
, LocalName
, QName
, Prefix
;
1091 saxlocator
*This
= ctx
;
1096 end
= This
->lastCur
;
1097 while(*end
!= '<' && *(end
+1) != '/') end
++;
1098 update_position(This
, end
+2);
1100 nsNr
= namespacePop(This
);
1102 if((This
->vbInterface
&& This
->saxreader
->vbcontentHandler
)
1103 || (!This
->vbInterface
&& This
->saxreader
->contentHandler
))
1105 NamespaceUri
= bstr_from_xmlChar(URI
);
1106 LocalName
= bstr_from_xmlChar(localname
);
1107 QName
= QName_from_xmlChar(prefix
, localname
);
1109 if(This
->vbInterface
)
1110 hr
= IVBSAXContentHandler_endElement(
1111 This
->saxreader
->vbcontentHandler
,
1112 &NamespaceUri
, &LocalName
, &QName
);
1114 hr
= ISAXContentHandler_endElement(
1115 This
->saxreader
->contentHandler
,
1116 NamespaceUri
, SysStringLen(NamespaceUri
),
1117 LocalName
, SysStringLen(LocalName
),
1118 QName
, SysStringLen(QName
));
1120 SysFreeString(NamespaceUri
);
1121 SysFreeString(LocalName
);
1122 SysFreeString(QName
);
1126 format_error_message_from_id(This
, hr
);
1130 for(index
=This
->pParserCtxt
->nsNr
-2;
1131 index
>=This
->pParserCtxt
->nsNr
-nsNr
*2; index
-=2)
1133 Prefix
= bstr_from_xmlChar(This
->pParserCtxt
->nsTab
[index
]);
1135 if(This
->vbInterface
)
1136 hr
= IVBSAXContentHandler_endPrefixMapping(
1137 This
->saxreader
->vbcontentHandler
, &Prefix
);
1139 hr
= ISAXContentHandler_endPrefixMapping(
1140 This
->saxreader
->contentHandler
,
1141 Prefix
, SysStringLen(Prefix
));
1143 SysFreeString(Prefix
);
1148 static void libxmlCharacters(
1154 saxlocator
*This
= ctx
;
1157 xmlChar
*lastCurCopy
;
1162 if(*(This
->lastCur
-1) != '>' && *(This
->lastCur
-1) != '/') return;
1164 if(*(This
->lastCur
-1) != '>')
1166 end
= (xmlChar
*)This
->pParserCtxt
->input
->cur
-len
;
1167 while(*(end
-1) != '>') end
--;
1168 update_position(This
, end
);
1171 chEnd
= This
->lastCur
+len
;
1172 while(*chEnd
!= '<') chEnd
++;
1174 Chars
= bstr_from_xmlChar(ch
);
1176 lastCurCopy
= This
->lastCur
;
1177 columnCopy
= This
->column
;
1178 lineCopy
= This
->line
;
1179 end
= This
->lastCur
;
1181 if((This
->vbInterface
&& This
->saxreader
->vbcontentHandler
)
1182 || (!This
->vbInterface
&& This
->saxreader
->contentHandler
))
1184 while(This
->lastCur
< chEnd
)
1186 end
= This
->lastCur
;
1187 while(end
< chEnd
-1)
1189 if(*end
== '\r') break;
1193 Chars
= bstr_from_xmlChar(This
->lastCur
);
1195 if(*end
== '\r' && *(end
+1) == '\n')
1197 memmove((WCHAR
*)Chars
+(end
-This
->lastCur
),
1198 (WCHAR
*)Chars
+(end
-This
->lastCur
)+1,
1199 (SysStringLen(Chars
)-(end
-This
->lastCur
))*sizeof(WCHAR
));
1200 SysReAllocStringLen(&Chars
, Chars
, SysStringLen(Chars
)-1);
1202 else if(*end
== '\r') Chars
[end
-This
->lastCur
] = '\n';
1204 if(This
->vbInterface
)
1205 hr
= IVBSAXContentHandler_characters(
1206 This
->saxreader
->vbcontentHandler
, &Chars
);
1208 hr
= ISAXContentHandler_characters(
1209 This
->saxreader
->contentHandler
,
1210 Chars
, end
-This
->lastCur
+1);
1212 SysFreeString(Chars
);
1215 format_error_message_from_id(This
, hr
);
1219 if(*(end
+1) == '\n') end
++;
1220 if(end
< chEnd
) end
++;
1222 This
->column
+= end
-This
->lastCur
;
1223 This
->lastCur
= end
;
1226 This
->lastCur
= lastCurCopy
;
1227 This
->column
= columnCopy
;
1228 This
->line
= lineCopy
;
1229 update_position(This
, chEnd
);
1233 static void libxmlSetDocumentLocator(
1235 xmlSAXLocatorPtr loc
)
1237 saxlocator
*This
= ctx
;
1240 if(This
->vbInterface
)
1241 hr
= IVBSAXContentHandler_putref_documentLocator(
1242 This
->saxreader
->vbcontentHandler
,
1243 (IVBSAXLocator
*)&This
->lpVBSAXLocatorVtbl
);
1245 hr
= ISAXContentHandler_putDocumentLocator(
1246 This
->saxreader
->contentHandler
,
1247 (ISAXLocator
*)&This
->lpSAXLocatorVtbl
);
1250 format_error_message_from_id(This
, hr
);
1253 void libxmlFatalError(void *ctx
, const char *msg
, ...)
1255 saxlocator
*This
= ctx
;
1261 if((This
->vbInterface
&& !This
->saxreader
->vberrorHandler
)
1262 || (!This
->vbInterface
&& !This
->saxreader
->errorHandler
))
1264 xmlStopParser(This
->pParserCtxt
);
1269 FIXME("Error handling is not compatible.\n");
1271 va_start(args
, msg
);
1272 vsprintf(message
, msg
, args
);
1275 len
= MultiByteToWideChar(CP_ACP
, 0, message
, -1, NULL
, 0);
1276 wszError
= HeapAlloc(GetProcessHeap(), 0, sizeof(WCHAR
)*len
);
1278 MultiByteToWideChar(CP_ACP
, 0, message
, -1, (LPWSTR
)wszError
, len
);
1280 if(This
->vbInterface
)
1282 BSTR bstrError
= SysAllocString(wszError
);
1283 IVBSAXErrorHandler_fatalError(This
->saxreader
->vberrorHandler
,
1284 (IVBSAXLocator
*)&This
->lpVBSAXLocatorVtbl
, &bstrError
, E_FAIL
);
1287 ISAXErrorHandler_fatalError(This
->saxreader
->errorHandler
,
1288 (ISAXLocator
*)&This
->lpSAXLocatorVtbl
, wszError
, E_FAIL
);
1290 HeapFree(GetProcessHeap(), 0, wszError
);
1292 xmlStopParser(This
->pParserCtxt
);
1296 /*** IVBSAXLocator interface ***/
1297 /*** IUnknown methods ***/
1298 static HRESULT WINAPI
ivbsaxlocator_QueryInterface(IVBSAXLocator
* iface
, REFIID riid
, void **ppvObject
)
1300 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1302 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1306 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1307 IsEqualGUID( riid
, &IID_IDispatch
) ||
1308 IsEqualGUID( riid
, &IID_IVBSAXLocator
))
1314 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1315 return E_NOINTERFACE
;
1318 IVBSAXLocator_AddRef( iface
);
1323 static ULONG WINAPI
ivbsaxlocator_AddRef(IVBSAXLocator
* iface
)
1325 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1326 TRACE("%p\n", This
);
1327 return InterlockedIncrement( &This
->ref
);
1330 static ULONG WINAPI
ivbsaxlocator_Release(
1331 IVBSAXLocator
* iface
)
1333 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1334 return ISAXLocator_Release((ISAXLocator
*)&This
->lpVBSAXLocatorVtbl
);
1337 /*** IDispatch methods ***/
1338 static HRESULT WINAPI
ivbsaxlocator_GetTypeInfoCount( IVBSAXLocator
*iface
, UINT
* pctinfo
)
1340 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1342 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1349 static HRESULT WINAPI
ivbsaxlocator_GetTypeInfo(
1350 IVBSAXLocator
*iface
,
1351 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
1353 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1356 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1358 hr
= get_typeinfo(IVBSAXLocator_tid
, ppTInfo
);
1363 static HRESULT WINAPI
ivbsaxlocator_GetIDsOfNames(
1364 IVBSAXLocator
*iface
,
1366 LPOLESTR
* rgszNames
,
1371 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1372 ITypeInfo
*typeinfo
;
1375 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1378 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
1379 return E_INVALIDARG
;
1381 hr
= get_typeinfo(IVBSAXLocator_tid
, &typeinfo
);
1384 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
1385 ITypeInfo_Release(typeinfo
);
1391 static HRESULT WINAPI
ivbsaxlocator_Invoke(
1392 IVBSAXLocator
*iface
,
1393 DISPID dispIdMember
,
1397 DISPPARAMS
* pDispParams
,
1398 VARIANT
* pVarResult
,
1399 EXCEPINFO
* pExcepInfo
,
1402 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1403 ITypeInfo
*typeinfo
;
1406 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1407 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1409 hr
= get_typeinfo(IVBSAXLocator_tid
, &typeinfo
);
1412 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVBSAXLocatorVtbl
), dispIdMember
, wFlags
, pDispParams
,
1413 pVarResult
, pExcepInfo
, puArgErr
);
1414 ITypeInfo_Release(typeinfo
);
1420 /*** IVBSAXLocator methods ***/
1421 static HRESULT WINAPI
ivbsaxlocator_get_columnNumber(
1422 IVBSAXLocator
* iface
,
1425 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1426 return ISAXLocator_getColumnNumber(
1427 (ISAXLocator
*)&This
->lpVBSAXLocatorVtbl
,
1431 static HRESULT WINAPI
ivbsaxlocator_get_lineNumber(
1432 IVBSAXLocator
* iface
,
1435 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1436 return ISAXLocator_getLineNumber(
1437 (ISAXLocator
*)&This
->lpVBSAXLocatorVtbl
,
1441 static HRESULT WINAPI
ivbsaxlocator_get_publicId(
1442 IVBSAXLocator
* iface
,
1445 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1446 return ISAXLocator_getPublicId(
1447 (ISAXLocator
*)&This
->lpVBSAXLocatorVtbl
,
1448 (const WCHAR
**)publicId
);
1451 static HRESULT WINAPI
ivbsaxlocator_get_systemId(
1452 IVBSAXLocator
* iface
,
1455 saxlocator
*This
= impl_from_IVBSAXLocator( iface
);
1456 return ISAXLocator_getSystemId(
1457 (ISAXLocator
*)&This
->lpVBSAXLocatorVtbl
,
1458 (const WCHAR
**)systemId
);
1461 static const struct IVBSAXLocatorVtbl ivbsaxlocator_vtbl
=
1463 ivbsaxlocator_QueryInterface
,
1464 ivbsaxlocator_AddRef
,
1465 ivbsaxlocator_Release
,
1466 ivbsaxlocator_GetTypeInfoCount
,
1467 ivbsaxlocator_GetTypeInfo
,
1468 ivbsaxlocator_GetIDsOfNames
,
1469 ivbsaxlocator_Invoke
,
1470 ivbsaxlocator_get_columnNumber
,
1471 ivbsaxlocator_get_lineNumber
,
1472 ivbsaxlocator_get_publicId
,
1473 ivbsaxlocator_get_systemId
1476 /*** ISAXLocator interface ***/
1477 /*** IUnknown methods ***/
1478 static HRESULT WINAPI
isaxlocator_QueryInterface(ISAXLocator
* iface
, REFIID riid
, void **ppvObject
)
1480 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1482 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1486 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1487 IsEqualGUID( riid
, &IID_ISAXLocator
))
1493 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1494 return E_NOINTERFACE
;
1497 ISAXLocator_AddRef( iface
);
1502 static ULONG WINAPI
isaxlocator_AddRef(ISAXLocator
* iface
)
1504 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1505 TRACE("%p\n", This
);
1506 return InterlockedIncrement( &This
->ref
);
1509 static ULONG WINAPI
isaxlocator_Release(
1512 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1515 TRACE("%p\n", This
);
1517 ref
= InterlockedDecrement( &This
->ref
);
1521 SysFreeString(This
->publicId
);
1523 SysFreeString(This
->systemId
);
1524 HeapFree(GetProcessHeap(), 0, This
->nsStack
);
1526 ISAXXMLReader_Release((ISAXXMLReader
*)&This
->saxreader
->lpSAXXMLReaderVtbl
);
1527 HeapFree( GetProcessHeap(), 0, This
);
1533 /*** ISAXLocator methods ***/
1534 static HRESULT WINAPI
isaxlocator_getColumnNumber(
1538 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1540 *pnColumn
= This
->column
;
1544 static HRESULT WINAPI
isaxlocator_getLineNumber(
1548 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1550 *pnLine
= This
->line
;
1554 static HRESULT WINAPI
isaxlocator_getPublicId(
1556 const WCHAR
** ppwchPublicId
)
1559 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1561 if(This
->publicId
) SysFreeString(This
->publicId
);
1563 publicId
= bstr_from_xmlChar(xmlSAX2GetPublicId(This
->pParserCtxt
));
1564 if(SysStringLen(publicId
))
1565 This
->publicId
= (WCHAR
*)&publicId
;
1568 SysFreeString(publicId
);
1569 This
->publicId
= NULL
;
1572 *ppwchPublicId
= This
->publicId
;
1576 static HRESULT WINAPI
isaxlocator_getSystemId(
1578 const WCHAR
** ppwchSystemId
)
1581 saxlocator
*This
= impl_from_ISAXLocator( iface
);
1583 if(This
->systemId
) SysFreeString(This
->systemId
);
1585 systemId
= bstr_from_xmlChar(xmlSAX2GetSystemId(This
->pParserCtxt
));
1586 if(SysStringLen(systemId
))
1587 This
->systemId
= (WCHAR
*)&systemId
;
1590 SysFreeString(systemId
);
1591 This
->systemId
= NULL
;
1594 *ppwchSystemId
= This
->systemId
;
1598 static const struct ISAXLocatorVtbl isaxlocator_vtbl
=
1600 isaxlocator_QueryInterface
,
1602 isaxlocator_Release
,
1603 isaxlocator_getColumnNumber
,
1604 isaxlocator_getLineNumber
,
1605 isaxlocator_getPublicId
,
1606 isaxlocator_getSystemId
1609 static HRESULT
SAXLocator_create(saxreader
*reader
, saxlocator
**ppsaxlocator
, BOOL vbInterface
)
1611 saxlocator
*locator
;
1613 locator
= HeapAlloc( GetProcessHeap(), 0, sizeof (*locator
) );
1615 return E_OUTOFMEMORY
;
1617 locator
->lpVBSAXLocatorVtbl
= &ivbsaxlocator_vtbl
;
1618 locator
->lpSAXLocatorVtbl
= &isaxlocator_vtbl
;
1620 locator
->vbInterface
= vbInterface
;
1622 locator
->saxreader
= reader
;
1623 ISAXXMLReader_AddRef((ISAXXMLReader
*)&reader
->lpSAXXMLReaderVtbl
);
1625 locator
->pParserCtxt
= NULL
;
1626 locator
->publicId
= NULL
;
1627 locator
->systemId
= NULL
;
1628 locator
->lastCur
= NULL
;
1630 locator
->column
= 0;
1631 locator
->ret
= S_OK
;
1632 locator
->nsStackSize
= 8;
1633 locator
->nsStackLast
= 0;
1634 locator
->nsStack
= HeapAlloc(GetProcessHeap(), 0, locator
->nsStackSize
);
1635 if(!locator
->nsStack
)
1637 ISAXXMLReader_Release((ISAXXMLReader
*)&reader
->lpSAXXMLReaderVtbl
);
1638 HeapFree(GetProcessHeap(), 0, locator
);
1639 return E_OUTOFMEMORY
;
1642 *ppsaxlocator
= locator
;
1644 TRACE("returning %p\n", *ppsaxlocator
);
1649 /*** SAXXMLReader internal functions ***/
1650 static HRESULT
internal_parseBuffer(saxreader
*This
, const char *buffer
, int size
, BOOL vbInterface
)
1652 saxlocator
*locator
;
1655 hr
= SAXLocator_create(This
, &locator
, vbInterface
);
1659 locator
->pParserCtxt
= xmlCreateMemoryParserCtxt(buffer
, size
);
1660 if(!locator
->pParserCtxt
)
1662 ISAXLocator_Release((ISAXLocator
*)&locator
->lpSAXLocatorVtbl
);
1666 locator
->pParserCtxt
->sax
= &locator
->saxreader
->sax
;
1667 locator
->pParserCtxt
->userData
= locator
;
1669 if(xmlParseDocument(locator
->pParserCtxt
)) hr
= E_FAIL
;
1670 else hr
= locator
->ret
;
1672 if(locator
->pParserCtxt
)
1674 locator
->pParserCtxt
->sax
= NULL
;
1675 xmlFreeParserCtxt(locator
->pParserCtxt
);
1676 locator
->pParserCtxt
= NULL
;
1679 ISAXLocator_Release((ISAXLocator
*)&locator
->lpSAXLocatorVtbl
);
1683 static HRESULT WINAPI
internal_getEntityResolver(
1685 void *pEntityResolver
,
1688 FIXME("(%p)->(%p) stub\n", This
, pEntityResolver
);
1692 static HRESULT WINAPI
internal_putEntityResolver(
1694 void *pEntityResolver
,
1697 FIXME("(%p)->(%p) stub\n", This
, pEntityResolver
);
1701 static HRESULT WINAPI
internal_getContentHandler(
1703 void *pContentHandler
,
1706 TRACE("(%p)->(%p)\n", This
, pContentHandler
);
1707 if(pContentHandler
== NULL
)
1709 if((vbInterface
&& This
->vbcontentHandler
)
1710 || (!vbInterface
&& This
->contentHandler
))
1713 IVBSAXContentHandler_AddRef(This
->vbcontentHandler
);
1715 ISAXContentHandler_AddRef(This
->contentHandler
);
1717 if(vbInterface
) *(IVBSAXContentHandler
**)pContentHandler
=
1718 This
->vbcontentHandler
;
1719 else *(ISAXContentHandler
**)pContentHandler
= This
->contentHandler
;
1724 static HRESULT WINAPI
internal_putContentHandler(
1726 void *contentHandler
,
1729 TRACE("(%p)->(%p)\n", This
, contentHandler
);
1733 IVBSAXContentHandler_AddRef((IVBSAXContentHandler
*)contentHandler
);
1735 ISAXContentHandler_AddRef((ISAXContentHandler
*)contentHandler
);
1737 if((vbInterface
&& This
->vbcontentHandler
)
1738 || (!vbInterface
&& This
->contentHandler
))
1741 IVBSAXContentHandler_Release(This
->vbcontentHandler
);
1743 ISAXContentHandler_Release(This
->contentHandler
);
1746 This
->vbcontentHandler
= contentHandler
;
1748 This
->contentHandler
= contentHandler
;
1753 static HRESULT WINAPI
internal_getDTDHandler(
1758 FIXME("(%p)->(%p) stub\n", This
, pDTDHandler
);
1762 static HRESULT WINAPI
internal_putDTDHandler(
1767 FIXME("(%p)->(%p) stub\n", This
, pDTDHandler
);
1771 static HRESULT WINAPI
internal_getErrorHandler(
1773 void *pErrorHandler
,
1776 TRACE("(%p)->(%p)\n", This
, pErrorHandler
);
1777 if(pErrorHandler
== NULL
)
1780 if(vbInterface
&& This
->vberrorHandler
)
1781 IVBSAXErrorHandler_AddRef(This
->vberrorHandler
);
1782 else if(!vbInterface
&& This
->errorHandler
)
1783 ISAXErrorHandler_AddRef(This
->errorHandler
);
1786 *(IVBSAXErrorHandler
**)pErrorHandler
= This
->vberrorHandler
;
1788 *(ISAXErrorHandler
**)pErrorHandler
= This
->errorHandler
;
1794 static HRESULT WINAPI
internal_putErrorHandler(
1799 TRACE("(%p)->(%p)\n", This
, errorHandler
);
1803 IVBSAXErrorHandler_AddRef((IVBSAXErrorHandler
*)errorHandler
);
1805 ISAXErrorHandler_AddRef((ISAXErrorHandler
*)errorHandler
);
1808 if(vbInterface
&& This
->vberrorHandler
)
1809 IVBSAXErrorHandler_Release(This
->vberrorHandler
);
1810 else if(!vbInterface
&& This
->errorHandler
)
1811 ISAXErrorHandler_Release(This
->errorHandler
);
1814 This
->vberrorHandler
= errorHandler
;
1816 This
->errorHandler
= errorHandler
;
1822 static HRESULT WINAPI
internal_parse(
1829 TRACE("(%p)\n", This
);
1832 switch(V_VT(&varInput
))
1835 hr
= internal_parseBuffer(This
, (const char*)V_BSTR(&varInput
),
1836 SysStringByteLen(V_BSTR(&varInput
)), vbInterface
);
1838 case VT_ARRAY
|VT_UI1
: {
1840 LONG lBound
, uBound
;
1843 hr
= SafeArrayGetLBound(V_ARRAY(&varInput
), 1, &lBound
);
1844 if(hr
!= S_OK
) break;
1845 hr
= SafeArrayGetUBound(V_ARRAY(&varInput
), 1, &uBound
);
1846 if(hr
!= S_OK
) break;
1847 dataRead
= (uBound
-lBound
)*SafeArrayGetElemsize(V_ARRAY(&varInput
));
1848 hr
= SafeArrayAccessData(V_ARRAY(&varInput
), (void**)&pSAData
);
1849 if(hr
!= S_OK
) break;
1850 hr
= internal_parseBuffer(This
, pSAData
, dataRead
, vbInterface
);
1851 SafeArrayUnaccessData(V_ARRAY(&varInput
));
1856 IPersistStream
*persistStream
;
1857 IStream
*stream
= NULL
;
1858 IXMLDOMDocument
*xmlDoc
;
1860 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
1861 &IID_IPersistStream
, (void**)&persistStream
) == S_OK
)
1863 hr
= IPersistStream_Save(persistStream
, stream
, TRUE
);
1864 IPersistStream_Release(persistStream
);
1865 if(hr
!= S_OK
) break;
1867 if(stream
|| IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
1868 &IID_IStream
, (void**)&stream
) == S_OK
)
1876 hr
= IStream_Stat(stream
, &dataInfo
, STATFLAG_NONAME
);
1877 if(hr
== E_PENDING
) continue;
1882 IStream_Release(stream
);
1886 data
= HeapAlloc(GetProcessHeap(), 0,
1887 dataInfo
.cbSize
.QuadPart
);
1890 IStream_Release(stream
);
1896 hr
= IStream_Read(stream
, data
,
1897 dataInfo
.cbSize
.QuadPart
, &dataRead
);
1898 if(hr
== E_PENDING
) continue;
1903 HeapFree(GetProcessHeap(), 0, data
);
1904 IStream_Release(stream
);
1908 hr
= internal_parseBuffer(This
, data
,
1909 dataInfo
.cbSize
.QuadPart
, vbInterface
);
1910 HeapFree(GetProcessHeap(), 0, data
);
1911 IStream_Release(stream
);
1914 if(IUnknown_QueryInterface(V_UNKNOWN(&varInput
),
1915 &IID_IXMLDOMDocument
, (void**)&xmlDoc
) == S_OK
)
1919 IXMLDOMDocument_get_xml(xmlDoc
, &bstrData
);
1920 hr
= internal_parseBuffer(This
, (const char*)bstrData
,
1921 SysStringByteLen(bstrData
), vbInterface
);
1922 IXMLDOMDocument_Release(xmlDoc
);
1928 WARN("vt %d not implemented\n", V_VT(&varInput
));
1935 static HRESULT
internal_vbonDataAvailable(void *obj
, char *ptr
, DWORD len
)
1937 saxreader
*This
= obj
;
1939 return internal_parseBuffer(This
, ptr
, len
, TRUE
);
1942 static HRESULT
internal_onDataAvailable(void *obj
, char *ptr
, DWORD len
)
1944 saxreader
*This
= obj
;
1946 return internal_parseBuffer(This
, ptr
, len
, FALSE
);
1949 static HRESULT WINAPI
internal_parseURL(
1957 TRACE("(%p)->(%s)\n", This
, debugstr_w(url
));
1959 if(vbInterface
) hr
= bind_url(url
, internal_vbonDataAvailable
, This
, &bsc
);
1960 else hr
= bind_url(url
, internal_onDataAvailable
, This
, &bsc
);
1970 /*** IVBSAXXMLReader interface ***/
1971 /*** IUnknown methods ***/
1972 static HRESULT WINAPI
saxxmlreader_QueryInterface(IVBSAXXMLReader
* iface
, REFIID riid
, void **ppvObject
)
1974 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
1976 TRACE("%p %s %p\n", This
, debugstr_guid( riid
), ppvObject
);
1980 if ( IsEqualGUID( riid
, &IID_IUnknown
) ||
1981 IsEqualGUID( riid
, &IID_IDispatch
) ||
1982 IsEqualGUID( riid
, &IID_IVBSAXXMLReader
))
1986 else if( IsEqualGUID( riid
, &IID_ISAXXMLReader
))
1988 *ppvObject
= (ISAXXMLReader
*)&This
->lpSAXXMLReaderVtbl
;
1992 FIXME("interface %s not implemented\n", debugstr_guid(riid
));
1993 return E_NOINTERFACE
;
1996 IVBSAXXMLReader_AddRef( iface
);
2001 static ULONG WINAPI
saxxmlreader_AddRef(IVBSAXXMLReader
* iface
)
2003 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2004 TRACE("%p\n", This
);
2005 return InterlockedIncrement( &This
->ref
);
2008 static ULONG WINAPI
saxxmlreader_Release(
2009 IVBSAXXMLReader
* iface
)
2011 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2014 TRACE("%p\n", This
);
2016 ref
= InterlockedDecrement( &This
->ref
);
2019 if(This
->contentHandler
)
2020 ISAXContentHandler_Release(This
->contentHandler
);
2022 if(This
->vbcontentHandler
)
2023 IVBSAXContentHandler_Release(This
->vbcontentHandler
);
2025 if(This
->errorHandler
)
2026 ISAXErrorHandler_Release(This
->errorHandler
);
2028 if(This
->vberrorHandler
)
2029 IVBSAXErrorHandler_Release(This
->vberrorHandler
);
2031 HeapFree( GetProcessHeap(), 0, This
);
2037 static HRESULT WINAPI
saxxmlreader_GetTypeInfoCount( IVBSAXXMLReader
*iface
, UINT
* pctinfo
)
2039 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2041 TRACE("(%p)->(%p)\n", This
, pctinfo
);
2048 static HRESULT WINAPI
saxxmlreader_GetTypeInfo(
2049 IVBSAXXMLReader
*iface
,
2050 UINT iTInfo
, LCID lcid
, ITypeInfo
** ppTInfo
)
2052 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2055 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
2057 hr
= get_typeinfo(IVBSAXXMLReader_tid
, ppTInfo
);
2062 static HRESULT WINAPI
saxxmlreader_GetIDsOfNames(
2063 IVBSAXXMLReader
*iface
,
2065 LPOLESTR
* rgszNames
,
2070 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2071 ITypeInfo
*typeinfo
;
2074 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
2077 if(!rgszNames
|| cNames
== 0 || !rgDispId
)
2078 return E_INVALIDARG
;
2080 hr
= get_typeinfo(IVBSAXXMLReader_tid
, &typeinfo
);
2083 hr
= ITypeInfo_GetIDsOfNames(typeinfo
, rgszNames
, cNames
, rgDispId
);
2084 ITypeInfo_Release(typeinfo
);
2090 static HRESULT WINAPI
saxxmlreader_Invoke(
2091 IVBSAXXMLReader
*iface
,
2092 DISPID dispIdMember
,
2096 DISPPARAMS
* pDispParams
,
2097 VARIANT
* pVarResult
,
2098 EXCEPINFO
* pExcepInfo
,
2101 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2102 ITypeInfo
*typeinfo
;
2105 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
2106 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2108 hr
= get_typeinfo(IVBSAXXMLReader_tid
, &typeinfo
);
2111 hr
= ITypeInfo_Invoke(typeinfo
, &(This
->lpVBSAXXMLReaderVtbl
), dispIdMember
, wFlags
, pDispParams
,
2112 pVarResult
, pExcepInfo
, puArgErr
);
2113 ITypeInfo_Release(typeinfo
);
2119 /*** IVBSAXXMLReader methods ***/
2120 static HRESULT WINAPI
saxxmlreader_getFeature(
2121 IVBSAXXMLReader
* iface
,
2122 const WCHAR
*pFeature
,
2123 VARIANT_BOOL
*pValue
)
2125 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2127 FIXME("(%p)->(%s %p) stub\n", This
, debugstr_w(pFeature
), pValue
);
2131 static HRESULT WINAPI
saxxmlreader_putFeature(
2132 IVBSAXXMLReader
* iface
,
2133 const WCHAR
*pFeature
,
2134 VARIANT_BOOL vfValue
)
2136 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2138 FIXME("(%p)->(%s %x) stub\n", This
, debugstr_w(pFeature
), vfValue
);
2142 static HRESULT WINAPI
saxxmlreader_getProperty(
2143 IVBSAXXMLReader
* iface
,
2147 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2149 FIXME("(%p)->(%s %p) stub\n", This
, debugstr_w(pProp
), pValue
);
2153 static HRESULT WINAPI
saxxmlreader_putProperty(
2154 IVBSAXXMLReader
* iface
,
2158 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2160 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(pProp
));
2164 static HRESULT WINAPI
saxxmlreader_getEntityResolver(
2165 IVBSAXXMLReader
* iface
,
2166 IVBSAXEntityResolver
**pEntityResolver
)
2168 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2169 return internal_getEntityResolver(This
, pEntityResolver
, TRUE
);
2172 static HRESULT WINAPI
saxxmlreader_putEntityResolver(
2173 IVBSAXXMLReader
* iface
,
2174 IVBSAXEntityResolver
*pEntityResolver
)
2176 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2177 return internal_putEntityResolver(This
, pEntityResolver
, TRUE
);
2180 static HRESULT WINAPI
saxxmlreader_getContentHandler(
2181 IVBSAXXMLReader
* iface
,
2182 IVBSAXContentHandler
**ppContentHandler
)
2184 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2185 return internal_getContentHandler(This
, ppContentHandler
, TRUE
);
2188 static HRESULT WINAPI
saxxmlreader_putContentHandler(
2189 IVBSAXXMLReader
* iface
,
2190 IVBSAXContentHandler
*contentHandler
)
2192 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2193 return internal_putContentHandler(This
, contentHandler
, TRUE
);
2196 static HRESULT WINAPI
saxxmlreader_getDTDHandler(
2197 IVBSAXXMLReader
* iface
,
2198 IVBSAXDTDHandler
**pDTDHandler
)
2200 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2201 return internal_getDTDHandler(This
, pDTDHandler
, TRUE
);
2204 static HRESULT WINAPI
saxxmlreader_putDTDHandler(
2205 IVBSAXXMLReader
* iface
,
2206 IVBSAXDTDHandler
*pDTDHandler
)
2208 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2209 return internal_putDTDHandler(This
, pDTDHandler
, TRUE
);
2212 static HRESULT WINAPI
saxxmlreader_getErrorHandler(
2213 IVBSAXXMLReader
* iface
,
2214 IVBSAXErrorHandler
**pErrorHandler
)
2216 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2217 return internal_getErrorHandler(This
, pErrorHandler
, TRUE
);
2220 static HRESULT WINAPI
saxxmlreader_putErrorHandler(
2221 IVBSAXXMLReader
* iface
,
2222 IVBSAXErrorHandler
*errorHandler
)
2224 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2225 return internal_putErrorHandler(This
, errorHandler
, TRUE
);
2228 static HRESULT WINAPI
saxxmlreader_getBaseURL(
2229 IVBSAXXMLReader
* iface
,
2230 const WCHAR
**pBaseUrl
)
2232 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2234 FIXME("(%p)->(%p) stub\n", This
, pBaseUrl
);
2238 static HRESULT WINAPI
saxxmlreader_putBaseURL(
2239 IVBSAXXMLReader
* iface
,
2240 const WCHAR
*pBaseUrl
)
2242 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2244 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(pBaseUrl
));
2248 static HRESULT WINAPI
saxxmlreader_getSecureBaseURL(
2249 IVBSAXXMLReader
* iface
,
2250 const WCHAR
**pSecureBaseUrl
)
2252 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2254 FIXME("(%p)->(%p) stub\n", This
, pSecureBaseUrl
);
2259 static HRESULT WINAPI
saxxmlreader_putSecureBaseURL(
2260 IVBSAXXMLReader
* iface
,
2261 const WCHAR
*secureBaseUrl
)
2263 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2265 FIXME("(%p)->(%s) stub\n", This
, debugstr_w(secureBaseUrl
));
2269 static HRESULT WINAPI
saxxmlreader_parse(
2270 IVBSAXXMLReader
* iface
,
2273 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2274 return internal_parse(This
, varInput
, TRUE
);
2277 static HRESULT WINAPI
saxxmlreader_parseURL(
2278 IVBSAXXMLReader
* iface
,
2281 saxreader
*This
= impl_from_IVBSAXXMLReader( iface
);
2282 return internal_parseURL(This
, url
, TRUE
);
2285 static const struct IVBSAXXMLReaderVtbl saxreader_vtbl
=
2287 saxxmlreader_QueryInterface
,
2288 saxxmlreader_AddRef
,
2289 saxxmlreader_Release
,
2290 saxxmlreader_GetTypeInfoCount
,
2291 saxxmlreader_GetTypeInfo
,
2292 saxxmlreader_GetIDsOfNames
,
2293 saxxmlreader_Invoke
,
2294 saxxmlreader_getFeature
,
2295 saxxmlreader_putFeature
,
2296 saxxmlreader_getProperty
,
2297 saxxmlreader_putProperty
,
2298 saxxmlreader_getEntityResolver
,
2299 saxxmlreader_putEntityResolver
,
2300 saxxmlreader_getContentHandler
,
2301 saxxmlreader_putContentHandler
,
2302 saxxmlreader_getDTDHandler
,
2303 saxxmlreader_putDTDHandler
,
2304 saxxmlreader_getErrorHandler
,
2305 saxxmlreader_putErrorHandler
,
2306 saxxmlreader_getBaseURL
,
2307 saxxmlreader_putBaseURL
,
2308 saxxmlreader_getSecureBaseURL
,
2309 saxxmlreader_putSecureBaseURL
,
2311 saxxmlreader_parseURL
2314 /*** ISAXXMLReader interface ***/
2315 /*** IUnknown methods ***/
2316 static HRESULT WINAPI
isaxxmlreader_QueryInterface(ISAXXMLReader
* iface
, REFIID riid
, void **ppvObject
)
2318 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2319 return saxxmlreader_QueryInterface((IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
, riid
, ppvObject
);
2322 static ULONG WINAPI
isaxxmlreader_AddRef(ISAXXMLReader
* iface
)
2324 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2325 return saxxmlreader_AddRef((IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
);
2328 static ULONG WINAPI
isaxxmlreader_Release(ISAXXMLReader
* iface
)
2330 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2331 return saxxmlreader_Release((IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
);
2334 /*** ISAXXMLReader methods ***/
2335 static HRESULT WINAPI
isaxxmlreader_getFeature(
2336 ISAXXMLReader
* iface
,
2337 const WCHAR
*pFeature
,
2338 VARIANT_BOOL
*pValue
)
2340 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2341 return IVBSAXXMLReader_getFeature(
2342 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2346 static HRESULT WINAPI
isaxxmlreader_putFeature(
2347 ISAXXMLReader
* iface
,
2348 const WCHAR
*pFeature
,
2349 VARIANT_BOOL vfValue
)
2351 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2352 return IVBSAXXMLReader_putFeature(
2353 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2357 static HRESULT WINAPI
isaxxmlreader_getProperty(
2358 ISAXXMLReader
* iface
,
2362 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2363 return IVBSAXXMLReader_getProperty(
2364 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2368 static HRESULT WINAPI
isaxxmlreader_putProperty(
2369 ISAXXMLReader
* iface
,
2373 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2374 return IVBSAXXMLReader_putProperty(
2375 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2379 static HRESULT WINAPI
isaxxmlreader_getEntityResolver(
2380 ISAXXMLReader
* iface
,
2381 ISAXEntityResolver
**ppEntityResolver
)
2383 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2384 return internal_getEntityResolver(This
, ppEntityResolver
, FALSE
);
2387 static HRESULT WINAPI
isaxxmlreader_putEntityResolver(
2388 ISAXXMLReader
* iface
,
2389 ISAXEntityResolver
*pEntityResolver
)
2391 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2392 return internal_putEntityResolver(This
, pEntityResolver
, FALSE
);
2395 static HRESULT WINAPI
isaxxmlreader_getContentHandler(
2396 ISAXXMLReader
* iface
,
2397 ISAXContentHandler
**pContentHandler
)
2399 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2400 return internal_getContentHandler(This
, pContentHandler
, FALSE
);
2403 static HRESULT WINAPI
isaxxmlreader_putContentHandler(
2404 ISAXXMLReader
* iface
,
2405 ISAXContentHandler
*contentHandler
)
2407 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2408 return internal_putContentHandler(This
, contentHandler
, FALSE
);
2411 static HRESULT WINAPI
isaxxmlreader_getDTDHandler(
2412 ISAXXMLReader
* iface
,
2413 ISAXDTDHandler
**pDTDHandler
)
2415 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2416 return internal_getDTDHandler(This
, pDTDHandler
, FALSE
);
2419 static HRESULT WINAPI
isaxxmlreader_putDTDHandler(
2420 ISAXXMLReader
* iface
,
2421 ISAXDTDHandler
*pDTDHandler
)
2423 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2424 return internal_putDTDHandler(This
, pDTDHandler
, FALSE
);
2427 static HRESULT WINAPI
isaxxmlreader_getErrorHandler(
2428 ISAXXMLReader
* iface
,
2429 ISAXErrorHandler
**pErrorHandler
)
2431 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2432 return internal_getErrorHandler(This
, pErrorHandler
, FALSE
);
2435 static HRESULT WINAPI
isaxxmlreader_putErrorHandler(
2436 ISAXXMLReader
* iface
,
2437 ISAXErrorHandler
*errorHandler
)
2439 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2440 return internal_putErrorHandler(This
, errorHandler
, FALSE
);
2443 static HRESULT WINAPI
isaxxmlreader_getBaseURL(
2444 ISAXXMLReader
* iface
,
2445 const WCHAR
**pBaseUrl
)
2447 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2448 return IVBSAXXMLReader_get_getBaseURL(
2449 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2453 static HRESULT WINAPI
isaxxmlreader_putBaseURL(
2454 ISAXXMLReader
* iface
,
2455 const WCHAR
*pBaseUrl
)
2457 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2458 return IVBSAXXMLReader_put_putBaseURL(
2459 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2463 static HRESULT WINAPI
isaxxmlreader_getSecureBaseURL(
2464 ISAXXMLReader
* iface
,
2465 const WCHAR
**pSecureBaseUrl
)
2467 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2468 return IVBSAXXMLReader_get_getSecureBaseURL(
2469 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2473 static HRESULT WINAPI
isaxxmlreader_putSecureBaseURL(
2474 ISAXXMLReader
* iface
,
2475 const WCHAR
*secureBaseUrl
)
2477 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2478 return IVBSAXXMLReader_put_putSecureBaseURL(
2479 (IVBSAXXMLReader
*)&This
->lpVBSAXXMLReaderVtbl
,
2483 static HRESULT WINAPI
isaxxmlreader_parse(
2484 ISAXXMLReader
* iface
,
2487 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2488 return internal_parse(This
, varInput
, FALSE
);
2491 static HRESULT WINAPI
isaxxmlreader_parseURL(
2492 ISAXXMLReader
* iface
,
2495 saxreader
*This
= impl_from_ISAXXMLReader( iface
);
2496 return internal_parseURL(This
, url
, FALSE
);
2499 static const struct ISAXXMLReaderVtbl isaxreader_vtbl
=
2501 isaxxmlreader_QueryInterface
,
2502 isaxxmlreader_AddRef
,
2503 isaxxmlreader_Release
,
2504 isaxxmlreader_getFeature
,
2505 isaxxmlreader_putFeature
,
2506 isaxxmlreader_getProperty
,
2507 isaxxmlreader_putProperty
,
2508 isaxxmlreader_getEntityResolver
,
2509 isaxxmlreader_putEntityResolver
,
2510 isaxxmlreader_getContentHandler
,
2511 isaxxmlreader_putContentHandler
,
2512 isaxxmlreader_getDTDHandler
,
2513 isaxxmlreader_putDTDHandler
,
2514 isaxxmlreader_getErrorHandler
,
2515 isaxxmlreader_putErrorHandler
,
2516 isaxxmlreader_getBaseURL
,
2517 isaxxmlreader_putBaseURL
,
2518 isaxxmlreader_getSecureBaseURL
,
2519 isaxxmlreader_putSecureBaseURL
,
2520 isaxxmlreader_parse
,
2521 isaxxmlreader_parseURL
2524 HRESULT
SAXXMLReader_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
2528 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
2530 reader
= HeapAlloc( GetProcessHeap(), 0, sizeof (*reader
) );
2532 return E_OUTOFMEMORY
;
2534 reader
->lpVBSAXXMLReaderVtbl
= &saxreader_vtbl
;
2535 reader
->lpSAXXMLReaderVtbl
= &isaxreader_vtbl
;
2537 reader
->contentHandler
= NULL
;
2538 reader
->vbcontentHandler
= NULL
;
2539 reader
->errorHandler
= NULL
;
2540 reader
->vberrorHandler
= NULL
;
2542 memset(&reader
->sax
, 0, sizeof(xmlSAXHandler
));
2543 reader
->sax
.initialized
= XML_SAX2_MAGIC
;
2544 reader
->sax
.startDocument
= libxmlStartDocument
;
2545 reader
->sax
.endDocument
= libxmlEndDocument
;
2546 reader
->sax
.startElementNs
= libxmlStartElementNS
;
2547 reader
->sax
.endElementNs
= libxmlEndElementNS
;
2548 reader
->sax
.characters
= libxmlCharacters
;
2549 reader
->sax
.setDocumentLocator
= libxmlSetDocumentLocator
;
2550 reader
->sax
.error
= libxmlFatalError
;
2551 reader
->sax
.fatalError
= libxmlFatalError
;
2553 *ppObj
= &reader
->lpVBSAXXMLReaderVtbl
;
2555 TRACE("returning iface %p\n", *ppObj
);
2562 HRESULT
SAXXMLReader_create(IUnknown
*pUnkOuter
, LPVOID
*ppObj
)
2564 MESSAGE("This program tried to use a SAX XML Reader object, but\n"
2565 "libxml2 support was not present at compile time.\n");