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
;
55 static inline xmlparser
*impl_from_IXMLParser( IXMLParser
*iface
)
57 return CONTAINING_RECORD(iface
, xmlparser
, IXMLParser_iface
);
60 /*** IUnknown methods ***/
61 static HRESULT WINAPI
xmlparser_QueryInterface(IXMLParser
* iface
, REFIID riid
, void **ppvObject
)
63 xmlparser
*This
= impl_from_IXMLParser( iface
);
64 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
66 if ( IsEqualGUID( riid
, &IID_IXMLParser
) ||
67 IsEqualGUID( riid
, &IID_IXMLNodeSource
) ||
68 IsEqualGUID( riid
, &IID_IUnknown
) )
74 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
79 IXMLParser_AddRef(iface
);
83 static ULONG WINAPI
xmlparser_AddRef(IXMLParser
* iface
)
85 xmlparser
*This
= impl_from_IXMLParser( iface
);
86 ULONG ref
= InterlockedIncrement( &This
->ref
);
87 TRACE("(%p)->(%d)\n", This
, ref
);
91 static ULONG WINAPI
xmlparser_Release(IXMLParser
* iface
)
93 xmlparser
*This
= impl_from_IXMLParser( iface
);
94 ULONG ref
= InterlockedDecrement( &This
->ref
);
96 TRACE("(%p)->(%d)\n", This
, ref
);
100 IXMLNodeFactory_Release(This
->nodefactory
);
108 /*** IXMLNodeSource methods ***/
109 static HRESULT WINAPI
xmlparser_SetFactory(IXMLParser
*iface
, IXMLNodeFactory
*pNodeFactory
)
111 xmlparser
*This
= impl_from_IXMLParser( iface
);
113 TRACE("(%p %p)\n", This
, pNodeFactory
);
115 if(This
->nodefactory
)
116 IXMLNodeFactory_Release(This
->nodefactory
);
118 This
->nodefactory
= pNodeFactory
;
119 if(This
->nodefactory
)
120 IXMLNodeFactory_AddRef(This
->nodefactory
);
125 static HRESULT WINAPI
xmlparser_GetFactory(IXMLParser
*iface
, IXMLNodeFactory
**ppNodeFactory
)
127 xmlparser
*This
= impl_from_IXMLParser( iface
);
129 TRACE("(%p, %p)\n", This
, ppNodeFactory
);
134 *ppNodeFactory
= This
->nodefactory
;
137 IXMLNodeFactory_AddRef(*ppNodeFactory
);
142 static HRESULT WINAPI
xmlparser_Abort(IXMLParser
*iface
, BSTR bstrErrorInfo
)
144 xmlparser
*This
= impl_from_IXMLParser( iface
);
146 FIXME("(%p, %s)\n", This
, debugstr_w(bstrErrorInfo
));
151 static ULONG WINAPI
xmlparser_GetLineNumber(IXMLParser
*iface
)
153 xmlparser
*This
= impl_from_IXMLParser( iface
);
155 FIXME("(%p)\n", This
);
160 static ULONG WINAPI
xmlparser_GetLinePosition(IXMLParser
*iface
)
162 xmlparser
*This
= impl_from_IXMLParser( iface
);
164 FIXME("(%p)\n", This
);
169 static ULONG WINAPI
xmlparser_GetAbsolutePosition(IXMLParser
*iface
)
171 xmlparser
*This
= impl_from_IXMLParser( iface
);
173 FIXME("(%p)\n", This
);
178 static HRESULT WINAPI
xmlparser_GetLineBuffer(IXMLParser
*iface
, const WCHAR
**ppBuf
,
179 ULONG
*len
, ULONG
*startPos
)
181 xmlparser
*This
= impl_from_IXMLParser( iface
);
183 FIXME("(%p %p %p %p)\n", This
, ppBuf
, len
, startPos
);
188 static HRESULT WINAPI
xmlparser_GetLastError(IXMLParser
*iface
)
190 xmlparser
*This
= impl_from_IXMLParser( iface
);
192 FIXME("(%p)\n", This
);
197 static HRESULT WINAPI
xmlparser_GetErrorInfo(IXMLParser
*iface
, BSTR
*pErrorInfo
)
199 xmlparser
*This
= impl_from_IXMLParser( iface
);
201 FIXME("(%p %p)\n", This
, pErrorInfo
);
206 static ULONG WINAPI
xmlparser_GetFlags(IXMLParser
*iface
)
208 xmlparser
*This
= impl_from_IXMLParser( iface
);
210 TRACE("(%p)\n", This
);
215 static HRESULT WINAPI
xmlparser_GetURL(IXMLParser
*iface
, const WCHAR
**ppBuf
)
217 xmlparser
*This
= impl_from_IXMLParser( iface
);
219 FIXME("(%p %p)\n", This
, ppBuf
);
224 /*** IXMLParser methods ***/
225 static HRESULT WINAPI
xmlparser_SetURL(IXMLParser
*iface
,const WCHAR
*pszBaseUrl
,
226 const WCHAR
*relativeUrl
, BOOL async
)
228 xmlparser
*This
= impl_from_IXMLParser( iface
);
230 FIXME("(%p %s %s %d)\n", This
, debugstr_w(pszBaseUrl
), debugstr_w(relativeUrl
), async
);
235 static HRESULT WINAPI
xmlparser_Load(IXMLParser
*iface
, BOOL bFullyAvailable
,
236 IMoniker
*pMon
, LPBC pBC
, DWORD dwMode
)
238 xmlparser
*This
= impl_from_IXMLParser( iface
);
240 FIXME("(%p %d %p %p %d)\n", This
, bFullyAvailable
, pMon
, pBC
, dwMode
);
245 static HRESULT WINAPI
xmlparser_SetInput(IXMLParser
*iface
, IUnknown
*pStm
)
247 xmlparser
*This
= impl_from_IXMLParser( iface
);
249 FIXME("(%p %p)\n", This
, pStm
);
254 static HRESULT WINAPI
xmlparser_PushData(IXMLParser
*iface
, const char *pData
,
255 ULONG nChars
, BOOL fLastBuffer
)
257 xmlparser
*This
= impl_from_IXMLParser( iface
);
259 FIXME("(%p %s %d %d)\n", This
, debugstr_a(pData
), nChars
, fLastBuffer
);
264 static HRESULT WINAPI
xmlparser_LoadDTD(IXMLParser
*iface
, const WCHAR
*baseUrl
,
265 const WCHAR
*relativeUrl
)
267 xmlparser
*This
= impl_from_IXMLParser( iface
);
269 FIXME("(%p %s %s)\n", This
, debugstr_w(baseUrl
), debugstr_w(relativeUrl
));
274 static HRESULT WINAPI
xmlparser_LoadEntity(IXMLParser
*iface
, const WCHAR
*baseUrl
,
275 const WCHAR
*relativeUrl
, BOOL fpe
)
277 xmlparser
*This
= impl_from_IXMLParser( iface
);
279 FIXME("(%p %s %s %d)\n", This
, debugstr_w(baseUrl
), debugstr_w(relativeUrl
), fpe
);
284 static HRESULT WINAPI
xmlparser_ParseEntity(IXMLParser
*iface
, const WCHAR
*text
,
287 xmlparser
*This
= impl_from_IXMLParser( iface
);
289 FIXME("(%p %s %d %d)\n", This
, debugstr_w(text
), len
, fpe
);
294 static HRESULT WINAPI
xmlparser_ExpandEntity(IXMLParser
*iface
, const WCHAR
*text
,
297 xmlparser
*This
= impl_from_IXMLParser( iface
);
299 FIXME("(%p %s %d)\n", This
, debugstr_w(text
), len
);
304 static HRESULT WINAPI
xmlparser_SetRoot(IXMLParser
*iface
, PVOID pRoot
)
306 xmlparser
*This
= impl_from_IXMLParser( iface
);
308 FIXME("(%p %p)\n", This
, pRoot
);
313 static HRESULT WINAPI
xmlparser_GetRoot( IXMLParser
*iface
, PVOID
*ppRoot
)
315 xmlparser
*This
= impl_from_IXMLParser( iface
);
317 FIXME("(%p %p)\n", This
, ppRoot
);
322 static HRESULT WINAPI
xmlparser_Run(IXMLParser
*iface
, LONG chars
)
324 xmlparser
*This
= impl_from_IXMLParser( iface
);
326 FIXME("(%p %d)\n", This
, chars
);
331 static HRESULT WINAPI
xmlparser_GetParserState(IXMLParser
*iface
)
333 xmlparser
*This
= impl_from_IXMLParser( iface
);
335 FIXME("(%p)\n", This
);
340 static HRESULT WINAPI
xmlparser_Suspend(IXMLParser
*iface
)
342 xmlparser
*This
= impl_from_IXMLParser( iface
);
344 FIXME("(%p)\n", This
);
349 static HRESULT WINAPI
xmlparser_Reset(IXMLParser
*iface
)
351 xmlparser
*This
= impl_from_IXMLParser( iface
);
353 FIXME("(%p)\n", This
);
358 static HRESULT WINAPI
xmlparser_SetFlags(IXMLParser
*iface
, ULONG flags
)
360 xmlparser
*This
= impl_from_IXMLParser( iface
);
362 TRACE("(%p %d)\n", This
, flags
);
369 static HRESULT WINAPI
xmlparser_SetSecureBaseURL(IXMLParser
*iface
, const WCHAR
*baseUrl
)
371 xmlparser
*This
= impl_from_IXMLParser( iface
);
373 FIXME("(%p %s)\n", This
, debugstr_w(baseUrl
));
378 static HRESULT WINAPI
xmlparser_GetSecureBaseURL( IXMLParser
*iface
, const WCHAR
**ppBuf
)
380 xmlparser
*This
= impl_from_IXMLParser( iface
);
382 FIXME("(%p %p)\n", This
, ppBuf
);
388 static const struct IXMLParserVtbl xmlparser_vtbl
=
390 xmlparser_QueryInterface
,
393 xmlparser_SetFactory
,
394 xmlparser_GetFactory
,
396 xmlparser_GetLineNumber
,
397 xmlparser_GetLinePosition
,
398 xmlparser_GetAbsolutePosition
,
399 xmlparser_GetLineBuffer
,
400 xmlparser_GetLastError
,
401 xmlparser_GetErrorInfo
,
409 xmlparser_LoadEntity
,
410 xmlparser_ParseEntity
,
411 xmlparser_ExpandEntity
,
415 xmlparser_GetParserState
,
419 xmlparser_SetSecureBaseURL
,
420 xmlparser_GetSecureBaseURL
423 HRESULT
XMLParser_create(IUnknown
* pUnkOuter
, void**ppObj
)
427 TRACE("(%p,%p)\n", pUnkOuter
, ppObj
);
430 FIXME("support aggregation, outer\n");
432 This
= heap_alloc( sizeof(xmlparser
) );
434 return E_OUTOFMEMORY
;
436 This
->IXMLParser_iface
.lpVtbl
= &xmlparser_vtbl
;
437 This
->nodefactory
= NULL
;
441 *ppObj
= &This
->IXMLParser_iface
;
443 TRACE("returning iface %p\n", *ppObj
);