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
24 #include "xmlparser.h"
26 typedef struct _xmlparser
28 IXMLParser IXMLParser_iface
;
29 IXMLNodeFactory
*nodefactory
;
34 XML_PARSER_STATE state
;
37 static inline xmlparser
*impl_from_IXMLParser( IXMLParser
*iface
)
39 return CONTAINING_RECORD(iface
, xmlparser
, IXMLParser_iface
);
42 /*** IUnknown methods ***/
43 static HRESULT WINAPI
xmlparser_QueryInterface(IXMLParser
* iface
, REFIID riid
, void **ppvObject
)
45 xmlparser
*This
= impl_from_IXMLParser( iface
);
46 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppvObject
);
48 if ( IsEqualGUID( riid
, &IID_IXMLParser
) ||
49 IsEqualGUID( riid
, &IID_IXMLNodeSource
) ||
50 IsEqualGUID( riid
, &IID_IUnknown
) )
56 TRACE("Unsupported interface %s\n", debugstr_guid(riid
));
61 IXMLParser_AddRef(iface
);
65 static ULONG WINAPI
xmlparser_AddRef(IXMLParser
* iface
)
67 xmlparser
*This
= impl_from_IXMLParser( iface
);
68 ULONG ref
= InterlockedIncrement( &This
->ref
);
69 TRACE("(%p)->(%d)\n", This
, ref
);
73 static ULONG WINAPI
xmlparser_Release(IXMLParser
* iface
)
75 xmlparser
*This
= impl_from_IXMLParser( iface
);
76 ULONG ref
= InterlockedDecrement( &This
->ref
);
78 TRACE("(%p)->(%d)\n", This
, ref
);
82 IUnknown_Release(This
->input
);
85 IXMLNodeFactory_Release(This
->nodefactory
);
93 /*** IXMLNodeSource methods ***/
94 static HRESULT WINAPI
xmlparser_SetFactory(IXMLParser
*iface
, IXMLNodeFactory
*pNodeFactory
)
96 xmlparser
*This
= impl_from_IXMLParser( iface
);
98 TRACE("(%p %p)\n", This
, pNodeFactory
);
100 if(This
->nodefactory
)
101 IXMLNodeFactory_Release(This
->nodefactory
);
103 This
->nodefactory
= pNodeFactory
;
104 if(This
->nodefactory
)
105 IXMLNodeFactory_AddRef(This
->nodefactory
);
110 static HRESULT WINAPI
xmlparser_GetFactory(IXMLParser
*iface
, IXMLNodeFactory
**ppNodeFactory
)
112 xmlparser
*This
= impl_from_IXMLParser( iface
);
114 TRACE("(%p, %p)\n", This
, ppNodeFactory
);
119 *ppNodeFactory
= This
->nodefactory
;
122 IXMLNodeFactory_AddRef(*ppNodeFactory
);
127 static HRESULT WINAPI
xmlparser_Abort(IXMLParser
*iface
, BSTR bstrErrorInfo
)
129 xmlparser
*This
= impl_from_IXMLParser( iface
);
131 FIXME("(%p, %s)\n", This
, debugstr_w(bstrErrorInfo
));
136 static ULONG WINAPI
xmlparser_GetLineNumber(IXMLParser
*iface
)
138 xmlparser
*This
= impl_from_IXMLParser( iface
);
140 FIXME("(%p)\n", This
);
145 static ULONG WINAPI
xmlparser_GetLinePosition(IXMLParser
*iface
)
147 xmlparser
*This
= impl_from_IXMLParser( iface
);
149 FIXME("(%p)\n", This
);
154 static ULONG WINAPI
xmlparser_GetAbsolutePosition(IXMLParser
*iface
)
156 xmlparser
*This
= impl_from_IXMLParser( iface
);
158 FIXME("(%p)\n", This
);
163 static HRESULT WINAPI
xmlparser_GetLineBuffer(IXMLParser
*iface
, const WCHAR
**ppBuf
,
164 ULONG
*len
, ULONG
*startPos
)
166 xmlparser
*This
= impl_from_IXMLParser( iface
);
168 FIXME("(%p %p %p %p)\n", This
, ppBuf
, len
, startPos
);
173 static HRESULT WINAPI
xmlparser_GetLastError(IXMLParser
*iface
)
175 xmlparser
*This
= impl_from_IXMLParser( iface
);
177 FIXME("(%p)\n", This
);
182 static HRESULT WINAPI
xmlparser_GetErrorInfo(IXMLParser
*iface
, BSTR
*pErrorInfo
)
184 xmlparser
*This
= impl_from_IXMLParser( iface
);
186 FIXME("(%p %p)\n", This
, pErrorInfo
);
191 static ULONG WINAPI
xmlparser_GetFlags(IXMLParser
*iface
)
193 xmlparser
*This
= impl_from_IXMLParser( iface
);
195 TRACE("(%p)\n", This
);
200 static HRESULT WINAPI
xmlparser_GetURL(IXMLParser
*iface
, const WCHAR
**ppBuf
)
202 xmlparser
*This
= impl_from_IXMLParser( iface
);
204 FIXME("(%p %p)\n", This
, ppBuf
);
209 /*** IXMLParser methods ***/
210 static HRESULT WINAPI
xmlparser_SetURL(IXMLParser
*iface
,const WCHAR
*pszBaseUrl
,
211 const WCHAR
*relativeUrl
, BOOL async
)
213 xmlparser
*This
= impl_from_IXMLParser( iface
);
215 FIXME("(%p %s %s %d)\n", This
, debugstr_w(pszBaseUrl
), debugstr_w(relativeUrl
), async
);
220 static HRESULT WINAPI
xmlparser_Load(IXMLParser
*iface
, BOOL bFullyAvailable
,
221 IMoniker
*pMon
, LPBC pBC
, DWORD dwMode
)
223 xmlparser
*This
= impl_from_IXMLParser( iface
);
225 FIXME("(%p %d %p %p %d)\n", This
, bFullyAvailable
, pMon
, pBC
, dwMode
);
230 static HRESULT WINAPI
xmlparser_SetInput(IXMLParser
*iface
, IUnknown
*pStm
)
232 xmlparser
*This
= impl_from_IXMLParser( iface
);
234 TRACE("(%p %p)\n", This
, pStm
);
240 IUnknown_Release(This
->input
);
243 IUnknown_AddRef(This
->input
);
248 static HRESULT WINAPI
xmlparser_PushData(IXMLParser
*iface
, const char *pData
,
249 ULONG nChars
, BOOL fLastBuffer
)
251 xmlparser
*This
= impl_from_IXMLParser( iface
);
253 FIXME("(%p %s %d %d)\n", This
, debugstr_a(pData
), nChars
, fLastBuffer
);
258 static HRESULT WINAPI
xmlparser_LoadDTD(IXMLParser
*iface
, const WCHAR
*baseUrl
,
259 const WCHAR
*relativeUrl
)
261 xmlparser
*This
= impl_from_IXMLParser( iface
);
263 FIXME("(%p %s %s)\n", This
, debugstr_w(baseUrl
), debugstr_w(relativeUrl
));
268 static HRESULT WINAPI
xmlparser_LoadEntity(IXMLParser
*iface
, const WCHAR
*baseUrl
,
269 const WCHAR
*relativeUrl
, BOOL fpe
)
271 xmlparser
*This
= impl_from_IXMLParser( iface
);
273 FIXME("(%p %s %s %d)\n", This
, debugstr_w(baseUrl
), debugstr_w(relativeUrl
), fpe
);
278 static HRESULT WINAPI
xmlparser_ParseEntity(IXMLParser
*iface
, const WCHAR
*text
,
281 xmlparser
*This
= impl_from_IXMLParser( iface
);
283 FIXME("(%p %s %d %d)\n", This
, debugstr_w(text
), len
, fpe
);
288 static HRESULT WINAPI
xmlparser_ExpandEntity(IXMLParser
*iface
, const WCHAR
*text
,
291 xmlparser
*This
= impl_from_IXMLParser( iface
);
293 FIXME("(%p %s %d)\n", This
, debugstr_w(text
), len
);
298 static HRESULT WINAPI
xmlparser_SetRoot(IXMLParser
*iface
, PVOID pRoot
)
300 xmlparser
*This
= impl_from_IXMLParser( iface
);
302 FIXME("(%p %p)\n", This
, pRoot
);
307 static HRESULT WINAPI
xmlparser_GetRoot( IXMLParser
*iface
, PVOID
*ppRoot
)
309 xmlparser
*This
= impl_from_IXMLParser( iface
);
311 FIXME("(%p %p)\n", This
, ppRoot
);
316 static HRESULT WINAPI
xmlparser_Run(IXMLParser
*iface
, LONG chars
)
318 xmlparser
*This
= impl_from_IXMLParser( iface
);
320 FIXME("(%p %d)\n", This
, chars
);
325 static HRESULT WINAPI
xmlparser_GetParserState(IXMLParser
*iface
)
327 xmlparser
*This
= impl_from_IXMLParser( iface
);
329 TRACE("(%p)\n", This
);
334 static HRESULT WINAPI
xmlparser_Suspend(IXMLParser
*iface
)
336 xmlparser
*This
= impl_from_IXMLParser( iface
);
338 FIXME("(%p)\n", This
);
343 static HRESULT WINAPI
xmlparser_Reset(IXMLParser
*iface
)
345 xmlparser
*This
= impl_from_IXMLParser( iface
);
347 FIXME("(%p)\n", This
);
352 static HRESULT WINAPI
xmlparser_SetFlags(IXMLParser
*iface
, ULONG flags
)
354 xmlparser
*This
= impl_from_IXMLParser( iface
);
356 TRACE("(%p %d)\n", This
, flags
);
363 static HRESULT WINAPI
xmlparser_SetSecureBaseURL(IXMLParser
*iface
, const WCHAR
*baseUrl
)
365 xmlparser
*This
= impl_from_IXMLParser( iface
);
367 FIXME("(%p %s)\n", This
, debugstr_w(baseUrl
));
372 static HRESULT WINAPI
xmlparser_GetSecureBaseURL( IXMLParser
*iface
, const WCHAR
**ppBuf
)
374 xmlparser
*This
= impl_from_IXMLParser( iface
);
376 FIXME("(%p %p)\n", This
, ppBuf
);
382 static const struct IXMLParserVtbl xmlparser_vtbl
=
384 xmlparser_QueryInterface
,
387 xmlparser_SetFactory
,
388 xmlparser_GetFactory
,
390 xmlparser_GetLineNumber
,
391 xmlparser_GetLinePosition
,
392 xmlparser_GetAbsolutePosition
,
393 xmlparser_GetLineBuffer
,
394 xmlparser_GetLastError
,
395 xmlparser_GetErrorInfo
,
403 xmlparser_LoadEntity
,
404 xmlparser_ParseEntity
,
405 xmlparser_ExpandEntity
,
409 xmlparser_GetParserState
,
413 xmlparser_SetSecureBaseURL
,
414 xmlparser_GetSecureBaseURL
417 HRESULT
XMLParser_create(void **ppObj
)
421 TRACE("(%p)\n", ppObj
);
423 This
= heap_alloc( sizeof(xmlparser
) );
425 return E_OUTOFMEMORY
;
427 This
->IXMLParser_iface
.lpVtbl
= &xmlparser_vtbl
;
428 This
->nodefactory
= NULL
;
431 This
->state
= XMLPARSER_IDLE
;
434 *ppObj
= &This
->IXMLParser_iface
;
436 TRACE("returning iface %p\n", *ppObj
);