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
;
56 static inline xmlparser
*impl_from_IXMLParser( IXMLParser
*iface
)
58 return CONTAINING_RECORD(iface
, xmlparser
, IXMLParser_iface
);
61 /*** IUnknown methods ***/
62 static HRESULT WINAPI
xmlparser_QueryInterface(IXMLParser
* iface
, REFIID riid
, void **ppvObject
)
64 xmlparser
*This
= impl_from_IXMLParser( iface
);
65 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
67 if ( IsEqualGUID( riid
, &IID_IXMLParser
) ||
68 IsEqualGUID( riid
, &IID_IXMLNodeSource
) ||
69 IsEqualGUID( riid
, &IID_IUnknown
) )
75 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
80 IXMLParser_AddRef(iface
);
84 static ULONG WINAPI
xmlparser_AddRef(IXMLParser
* iface
)
86 xmlparser
*This
= impl_from_IXMLParser( iface
);
87 ULONG ref
= InterlockedIncrement( &This
->ref
);
88 TRACE("(%p)->(%d)\n", This
, ref
);
92 static ULONG WINAPI
xmlparser_Release(IXMLParser
* iface
)
94 xmlparser
*This
= impl_from_IXMLParser( iface
);
95 ULONG ref
= InterlockedDecrement( &This
->ref
);
97 TRACE("(%p)->(%d)\n", This
, ref
);
101 IUnknown_Release(This
->input
);
103 if(This
->nodefactory
)
104 IXMLNodeFactory_Release(This
->nodefactory
);
112 /*** IXMLNodeSource methods ***/
113 static HRESULT WINAPI
xmlparser_SetFactory(IXMLParser
*iface
, IXMLNodeFactory
*pNodeFactory
)
115 xmlparser
*This
= impl_from_IXMLParser( iface
);
117 TRACE("(%p %p)\n", This
, pNodeFactory
);
119 if(This
->nodefactory
)
120 IXMLNodeFactory_Release(This
->nodefactory
);
122 This
->nodefactory
= pNodeFactory
;
123 if(This
->nodefactory
)
124 IXMLNodeFactory_AddRef(This
->nodefactory
);
129 static HRESULT WINAPI
xmlparser_GetFactory(IXMLParser
*iface
, IXMLNodeFactory
**ppNodeFactory
)
131 xmlparser
*This
= impl_from_IXMLParser( iface
);
133 TRACE("(%p, %p)\n", This
, ppNodeFactory
);
138 *ppNodeFactory
= This
->nodefactory
;
141 IXMLNodeFactory_AddRef(*ppNodeFactory
);
146 static HRESULT WINAPI
xmlparser_Abort(IXMLParser
*iface
, BSTR bstrErrorInfo
)
148 xmlparser
*This
= impl_from_IXMLParser( iface
);
150 FIXME("(%p, %s)\n", This
, debugstr_w(bstrErrorInfo
));
155 static ULONG WINAPI
xmlparser_GetLineNumber(IXMLParser
*iface
)
157 xmlparser
*This
= impl_from_IXMLParser( iface
);
159 FIXME("(%p)\n", This
);
164 static ULONG WINAPI
xmlparser_GetLinePosition(IXMLParser
*iface
)
166 xmlparser
*This
= impl_from_IXMLParser( iface
);
168 FIXME("(%p)\n", This
);
173 static ULONG WINAPI
xmlparser_GetAbsolutePosition(IXMLParser
*iface
)
175 xmlparser
*This
= impl_from_IXMLParser( iface
);
177 FIXME("(%p)\n", This
);
182 static HRESULT WINAPI
xmlparser_GetLineBuffer(IXMLParser
*iface
, const WCHAR
**ppBuf
,
183 ULONG
*len
, ULONG
*startPos
)
185 xmlparser
*This
= impl_from_IXMLParser( iface
);
187 FIXME("(%p %p %p %p)\n", This
, ppBuf
, len
, startPos
);
192 static HRESULT WINAPI
xmlparser_GetLastError(IXMLParser
*iface
)
194 xmlparser
*This
= impl_from_IXMLParser( iface
);
196 FIXME("(%p)\n", This
);
201 static HRESULT WINAPI
xmlparser_GetErrorInfo(IXMLParser
*iface
, BSTR
*pErrorInfo
)
203 xmlparser
*This
= impl_from_IXMLParser( iface
);
205 FIXME("(%p %p)\n", This
, pErrorInfo
);
210 static ULONG WINAPI
xmlparser_GetFlags(IXMLParser
*iface
)
212 xmlparser
*This
= impl_from_IXMLParser( iface
);
214 TRACE("(%p)\n", This
);
219 static HRESULT WINAPI
xmlparser_GetURL(IXMLParser
*iface
, const WCHAR
**ppBuf
)
221 xmlparser
*This
= impl_from_IXMLParser( iface
);
223 FIXME("(%p %p)\n", This
, ppBuf
);
228 /*** IXMLParser methods ***/
229 static HRESULT WINAPI
xmlparser_SetURL(IXMLParser
*iface
,const WCHAR
*pszBaseUrl
,
230 const WCHAR
*relativeUrl
, BOOL async
)
232 xmlparser
*This
= impl_from_IXMLParser( iface
);
234 FIXME("(%p %s %s %d)\n", This
, debugstr_w(pszBaseUrl
), debugstr_w(relativeUrl
), async
);
239 static HRESULT WINAPI
xmlparser_Load(IXMLParser
*iface
, BOOL bFullyAvailable
,
240 IMoniker
*pMon
, LPBC pBC
, DWORD dwMode
)
242 xmlparser
*This
= impl_from_IXMLParser( iface
);
244 FIXME("(%p %d %p %p %d)\n", This
, bFullyAvailable
, pMon
, pBC
, dwMode
);
249 static HRESULT WINAPI
xmlparser_SetInput(IXMLParser
*iface
, IUnknown
*pStm
)
251 xmlparser
*This
= impl_from_IXMLParser( iface
);
253 TRACE("(%p %p)\n", This
, pStm
);
259 IUnknown_Release(This
->input
);
262 IUnknown_AddRef(This
->input
);
267 static HRESULT WINAPI
xmlparser_PushData(IXMLParser
*iface
, const char *pData
,
268 ULONG nChars
, BOOL fLastBuffer
)
270 xmlparser
*This
= impl_from_IXMLParser( iface
);
272 FIXME("(%p %s %d %d)\n", This
, debugstr_a(pData
), nChars
, fLastBuffer
);
277 static HRESULT WINAPI
xmlparser_LoadDTD(IXMLParser
*iface
, const WCHAR
*baseUrl
,
278 const WCHAR
*relativeUrl
)
280 xmlparser
*This
= impl_from_IXMLParser( iface
);
282 FIXME("(%p %s %s)\n", This
, debugstr_w(baseUrl
), debugstr_w(relativeUrl
));
287 static HRESULT WINAPI
xmlparser_LoadEntity(IXMLParser
*iface
, const WCHAR
*baseUrl
,
288 const WCHAR
*relativeUrl
, BOOL fpe
)
290 xmlparser
*This
= impl_from_IXMLParser( iface
);
292 FIXME("(%p %s %s %d)\n", This
, debugstr_w(baseUrl
), debugstr_w(relativeUrl
), fpe
);
297 static HRESULT WINAPI
xmlparser_ParseEntity(IXMLParser
*iface
, const WCHAR
*text
,
300 xmlparser
*This
= impl_from_IXMLParser( iface
);
302 FIXME("(%p %s %d %d)\n", This
, debugstr_w(text
), len
, fpe
);
307 static HRESULT WINAPI
xmlparser_ExpandEntity(IXMLParser
*iface
, const WCHAR
*text
,
310 xmlparser
*This
= impl_from_IXMLParser( iface
);
312 FIXME("(%p %s %d)\n", This
, debugstr_w(text
), len
);
317 static HRESULT WINAPI
xmlparser_SetRoot(IXMLParser
*iface
, PVOID pRoot
)
319 xmlparser
*This
= impl_from_IXMLParser( iface
);
321 FIXME("(%p %p)\n", This
, pRoot
);
326 static HRESULT WINAPI
xmlparser_GetRoot( IXMLParser
*iface
, PVOID
*ppRoot
)
328 xmlparser
*This
= impl_from_IXMLParser( iface
);
330 FIXME("(%p %p)\n", This
, ppRoot
);
335 static HRESULT WINAPI
xmlparser_Run(IXMLParser
*iface
, LONG chars
)
337 xmlparser
*This
= impl_from_IXMLParser( iface
);
339 FIXME("(%p %d)\n", This
, chars
);
344 static HRESULT WINAPI
xmlparser_GetParserState(IXMLParser
*iface
)
346 xmlparser
*This
= impl_from_IXMLParser( iface
);
348 FIXME("(%p)\n", This
);
353 static HRESULT WINAPI
xmlparser_Suspend(IXMLParser
*iface
)
355 xmlparser
*This
= impl_from_IXMLParser( iface
);
357 FIXME("(%p)\n", This
);
362 static HRESULT WINAPI
xmlparser_Reset(IXMLParser
*iface
)
364 xmlparser
*This
= impl_from_IXMLParser( iface
);
366 FIXME("(%p)\n", This
);
371 static HRESULT WINAPI
xmlparser_SetFlags(IXMLParser
*iface
, ULONG flags
)
373 xmlparser
*This
= impl_from_IXMLParser( iface
);
375 TRACE("(%p %d)\n", This
, flags
);
382 static HRESULT WINAPI
xmlparser_SetSecureBaseURL(IXMLParser
*iface
, const WCHAR
*baseUrl
)
384 xmlparser
*This
= impl_from_IXMLParser( iface
);
386 FIXME("(%p %s)\n", This
, debugstr_w(baseUrl
));
391 static HRESULT WINAPI
xmlparser_GetSecureBaseURL( IXMLParser
*iface
, const WCHAR
**ppBuf
)
393 xmlparser
*This
= impl_from_IXMLParser( iface
);
395 FIXME("(%p %p)\n", This
, ppBuf
);
401 static const struct IXMLParserVtbl xmlparser_vtbl
=
403 xmlparser_QueryInterface
,
406 xmlparser_SetFactory
,
407 xmlparser_GetFactory
,
409 xmlparser_GetLineNumber
,
410 xmlparser_GetLinePosition
,
411 xmlparser_GetAbsolutePosition
,
412 xmlparser_GetLineBuffer
,
413 xmlparser_GetLastError
,
414 xmlparser_GetErrorInfo
,
422 xmlparser_LoadEntity
,
423 xmlparser_ParseEntity
,
424 xmlparser_ExpandEntity
,
428 xmlparser_GetParserState
,
432 xmlparser_SetSecureBaseURL
,
433 xmlparser_GetSecureBaseURL
436 HRESULT
XMLParser_create(void **ppObj
)
440 TRACE("(%p)\n", ppObj
);
442 This
= heap_alloc( sizeof(xmlparser
) );
444 return E_OUTOFMEMORY
;
446 This
->IXMLParser_iface
.lpVtbl
= &xmlparser_vtbl
;
447 This
->nodefactory
= NULL
;
452 *ppObj
= &This
->IXMLParser_iface
;
454 TRACE("returning iface %p\n", *ppObj
);