2 * XML Parser implementation
4 * Copyright 2011 Alistair Leslie-Hughes
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
26 # include <libxml/parser.h>
27 # include <libxml/xmlerror.h>
28 # include <libxml/HTMLtree.h>
37 #include "msxml_private.h"
40 #include "xmlparser.h"
42 #include "wine/debug.h"
44 WINE_DEFAULT_DEBUG_CHANNEL(msxml
);
46 typedef struct _xmlparser
48 IXMLParser IXMLParser_iface
;
49 IXMLNodeFactory
*nodefactory
;
54 XML_PARSER_STATE state
;
57 static inline xmlparser
*impl_from_IXMLParser( IXMLParser
*iface
)
59 return CONTAINING_RECORD(iface
, xmlparser
, IXMLParser_iface
);
62 /*** IUnknown methods ***/
63 static HRESULT WINAPI
xmlparser_QueryInterface(IXMLParser
* iface
, REFIID riid
, void **ppvObject
)
65 xmlparser
*This
= impl_from_IXMLParser( iface
);
66 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
68 if ( IsEqualGUID( riid
, &IID_IXMLParser
) ||
69 IsEqualGUID( riid
, &IID_IXMLNodeSource
) ||
70 IsEqualGUID( riid
, &IID_IUnknown
) )
76 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
81 IXMLParser_AddRef(iface
);
85 static ULONG WINAPI
xmlparser_AddRef(IXMLParser
* iface
)
87 xmlparser
*This
= impl_from_IXMLParser( iface
);
88 ULONG ref
= InterlockedIncrement( &This
->ref
);
89 TRACE("(%p)->(%d)\n", This
, ref
);
93 static ULONG WINAPI
xmlparser_Release(IXMLParser
* iface
)
95 xmlparser
*This
= impl_from_IXMLParser( iface
);
96 ULONG ref
= InterlockedDecrement( &This
->ref
);
98 TRACE("(%p)->(%d)\n", This
, ref
);
102 IUnknown_Release(This
->input
);
104 if(This
->nodefactory
)
105 IXMLNodeFactory_Release(This
->nodefactory
);
113 /*** IXMLNodeSource methods ***/
114 static HRESULT WINAPI
xmlparser_SetFactory(IXMLParser
*iface
, IXMLNodeFactory
*pNodeFactory
)
116 xmlparser
*This
= impl_from_IXMLParser( iface
);
118 TRACE("(%p %p)\n", This
, pNodeFactory
);
120 if(This
->nodefactory
)
121 IXMLNodeFactory_Release(This
->nodefactory
);
123 This
->nodefactory
= pNodeFactory
;
124 if(This
->nodefactory
)
125 IXMLNodeFactory_AddRef(This
->nodefactory
);
130 static HRESULT WINAPI
xmlparser_GetFactory(IXMLParser
*iface
, IXMLNodeFactory
**ppNodeFactory
)
132 xmlparser
*This
= impl_from_IXMLParser( iface
);
134 TRACE("(%p, %p)\n", This
, ppNodeFactory
);
139 *ppNodeFactory
= This
->nodefactory
;
142 IXMLNodeFactory_AddRef(*ppNodeFactory
);
147 static HRESULT WINAPI
xmlparser_Abort(IXMLParser
*iface
, BSTR bstrErrorInfo
)
149 xmlparser
*This
= impl_from_IXMLParser( iface
);
151 FIXME("(%p, %s)\n", This
, debugstr_w(bstrErrorInfo
));
156 static ULONG WINAPI
xmlparser_GetLineNumber(IXMLParser
*iface
)
158 xmlparser
*This
= impl_from_IXMLParser( iface
);
160 FIXME("(%p)\n", This
);
165 static ULONG WINAPI
xmlparser_GetLinePosition(IXMLParser
*iface
)
167 xmlparser
*This
= impl_from_IXMLParser( iface
);
169 FIXME("(%p)\n", This
);
174 static ULONG WINAPI
xmlparser_GetAbsolutePosition(IXMLParser
*iface
)
176 xmlparser
*This
= impl_from_IXMLParser( iface
);
178 FIXME("(%p)\n", This
);
183 static HRESULT WINAPI
xmlparser_GetLineBuffer(IXMLParser
*iface
, const WCHAR
**ppBuf
,
184 ULONG
*len
, ULONG
*startPos
)
186 xmlparser
*This
= impl_from_IXMLParser( iface
);
188 FIXME("(%p %p %p %p)\n", This
, ppBuf
, len
, startPos
);
193 static HRESULT WINAPI
xmlparser_GetLastError(IXMLParser
*iface
)
195 xmlparser
*This
= impl_from_IXMLParser( iface
);
197 FIXME("(%p)\n", This
);
202 static HRESULT WINAPI
xmlparser_GetErrorInfo(IXMLParser
*iface
, BSTR
*pErrorInfo
)
204 xmlparser
*This
= impl_from_IXMLParser( iface
);
206 FIXME("(%p %p)\n", This
, pErrorInfo
);
211 static ULONG WINAPI
xmlparser_GetFlags(IXMLParser
*iface
)
213 xmlparser
*This
= impl_from_IXMLParser( iface
);
215 TRACE("(%p)\n", This
);
220 static HRESULT WINAPI
xmlparser_GetURL(IXMLParser
*iface
, const WCHAR
**ppBuf
)
222 xmlparser
*This
= impl_from_IXMLParser( iface
);
224 FIXME("(%p %p)\n", This
, ppBuf
);
229 /*** IXMLParser methods ***/
230 static HRESULT WINAPI
xmlparser_SetURL(IXMLParser
*iface
,const WCHAR
*pszBaseUrl
,
231 const WCHAR
*relativeUrl
, BOOL async
)
233 xmlparser
*This
= impl_from_IXMLParser( iface
);
235 FIXME("(%p %s %s %d)\n", This
, debugstr_w(pszBaseUrl
), debugstr_w(relativeUrl
), async
);
240 static HRESULT WINAPI
xmlparser_Load(IXMLParser
*iface
, BOOL bFullyAvailable
,
241 IMoniker
*pMon
, LPBC pBC
, DWORD dwMode
)
243 xmlparser
*This
= impl_from_IXMLParser( iface
);
245 FIXME("(%p %d %p %p %d)\n", This
, bFullyAvailable
, pMon
, pBC
, dwMode
);
250 static HRESULT WINAPI
xmlparser_SetInput(IXMLParser
*iface
, IUnknown
*pStm
)
252 xmlparser
*This
= impl_from_IXMLParser( iface
);
254 TRACE("(%p %p)\n", This
, pStm
);
260 IUnknown_Release(This
->input
);
263 IUnknown_AddRef(This
->input
);
268 static HRESULT WINAPI
xmlparser_PushData(IXMLParser
*iface
, const char *pData
,
269 ULONG nChars
, BOOL fLastBuffer
)
271 xmlparser
*This
= impl_from_IXMLParser( iface
);
273 FIXME("(%p %s %d %d)\n", This
, debugstr_a(pData
), nChars
, fLastBuffer
);
278 static HRESULT WINAPI
xmlparser_LoadDTD(IXMLParser
*iface
, const WCHAR
*baseUrl
,
279 const WCHAR
*relativeUrl
)
281 xmlparser
*This
= impl_from_IXMLParser( iface
);
283 FIXME("(%p %s %s)\n", This
, debugstr_w(baseUrl
), debugstr_w(relativeUrl
));
288 static HRESULT WINAPI
xmlparser_LoadEntity(IXMLParser
*iface
, const WCHAR
*baseUrl
,
289 const WCHAR
*relativeUrl
, BOOL fpe
)
291 xmlparser
*This
= impl_from_IXMLParser( iface
);
293 FIXME("(%p %s %s %d)\n", This
, debugstr_w(baseUrl
), debugstr_w(relativeUrl
), fpe
);
298 static HRESULT WINAPI
xmlparser_ParseEntity(IXMLParser
*iface
, const WCHAR
*text
,
301 xmlparser
*This
= impl_from_IXMLParser( iface
);
303 FIXME("(%p %s %d %d)\n", This
, debugstr_w(text
), len
, fpe
);
308 static HRESULT WINAPI
xmlparser_ExpandEntity(IXMLParser
*iface
, const WCHAR
*text
,
311 xmlparser
*This
= impl_from_IXMLParser( iface
);
313 FIXME("(%p %s %d)\n", This
, debugstr_w(text
), len
);
318 static HRESULT WINAPI
xmlparser_SetRoot(IXMLParser
*iface
, PVOID pRoot
)
320 xmlparser
*This
= impl_from_IXMLParser( iface
);
322 FIXME("(%p %p)\n", This
, pRoot
);
327 static HRESULT WINAPI
xmlparser_GetRoot( IXMLParser
*iface
, PVOID
*ppRoot
)
329 xmlparser
*This
= impl_from_IXMLParser( iface
);
331 FIXME("(%p %p)\n", This
, ppRoot
);
336 static HRESULT WINAPI
xmlparser_Run(IXMLParser
*iface
, LONG chars
)
338 xmlparser
*This
= impl_from_IXMLParser( iface
);
340 FIXME("(%p %d)\n", This
, chars
);
345 static HRESULT WINAPI
xmlparser_GetParserState(IXMLParser
*iface
)
347 xmlparser
*This
= impl_from_IXMLParser( iface
);
349 TRACE("(%p)\n", This
);
354 static HRESULT WINAPI
xmlparser_Suspend(IXMLParser
*iface
)
356 xmlparser
*This
= impl_from_IXMLParser( iface
);
358 FIXME("(%p)\n", This
);
363 static HRESULT WINAPI
xmlparser_Reset(IXMLParser
*iface
)
365 xmlparser
*This
= impl_from_IXMLParser( iface
);
367 FIXME("(%p)\n", This
);
372 static HRESULT WINAPI
xmlparser_SetFlags(IXMLParser
*iface
, ULONG flags
)
374 xmlparser
*This
= impl_from_IXMLParser( iface
);
376 TRACE("(%p %d)\n", This
, flags
);
383 static HRESULT WINAPI
xmlparser_SetSecureBaseURL(IXMLParser
*iface
, const WCHAR
*baseUrl
)
385 xmlparser
*This
= impl_from_IXMLParser( iface
);
387 FIXME("(%p %s)\n", This
, debugstr_w(baseUrl
));
392 static HRESULT WINAPI
xmlparser_GetSecureBaseURL( IXMLParser
*iface
, const WCHAR
**ppBuf
)
394 xmlparser
*This
= impl_from_IXMLParser( iface
);
396 FIXME("(%p %p)\n", This
, ppBuf
);
402 static const struct IXMLParserVtbl xmlparser_vtbl
=
404 xmlparser_QueryInterface
,
407 xmlparser_SetFactory
,
408 xmlparser_GetFactory
,
410 xmlparser_GetLineNumber
,
411 xmlparser_GetLinePosition
,
412 xmlparser_GetAbsolutePosition
,
413 xmlparser_GetLineBuffer
,
414 xmlparser_GetLastError
,
415 xmlparser_GetErrorInfo
,
423 xmlparser_LoadEntity
,
424 xmlparser_ParseEntity
,
425 xmlparser_ExpandEntity
,
429 xmlparser_GetParserState
,
433 xmlparser_SetSecureBaseURL
,
434 xmlparser_GetSecureBaseURL
437 HRESULT
XMLParser_create(void **ppObj
)
441 TRACE("(%p)\n", ppObj
);
443 This
= heap_alloc( sizeof(xmlparser
) );
445 return E_OUTOFMEMORY
;
447 This
->IXMLParser_iface
.lpVtbl
= &xmlparser_vtbl
;
448 This
->nodefactory
= NULL
;
451 This
->state
= XMLPARSER_IDLE
;
454 *ppObj
= &This
->IXMLParser_iface
;
456 TRACE("returning iface %p\n", *ppObj
);