netprofm: Add stubbed IConnectionPoint interface.
[wine.git] / dlls / msxml3 / xmlparser.c
blobca40b22e0e01c88817004b6c99c628ac83b32d04
1 /*
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
20 #define COBJMACROS
22 #include "config.h"
24 #include <stdarg.h>
25 #ifdef HAVE_LIBXML2
26 # include <libxml/parser.h>
27 # include <libxml/xmlerror.h>
28 # include <libxml/HTMLtree.h>
29 #endif
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "ole2.h"
35 #include "msxml6.h"
37 #include "msxml_private.h"
39 #include "initguid.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;
50 IUnknown *input;
51 LONG ref;
53 int flags;
54 } xmlparser;
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 ) )
71 *ppvObject = iface;
73 else
75 TRACE("Unsupported interface %s\n", debugstr_guid(riid));
76 *ppvObject = NULL;
77 return E_NOINTERFACE;
80 IXMLParser_AddRef(iface);
81 return S_OK;
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);
89 return 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);
98 if ( ref == 0 )
100 if(This->input)
101 IUnknown_Release(This->input);
103 if(This->nodefactory)
104 IXMLNodeFactory_Release(This->nodefactory);
106 heap_free( This );
109 return ref;
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);
126 return S_OK;
129 static HRESULT WINAPI xmlparser_GetFactory(IXMLParser *iface, IXMLNodeFactory **ppNodeFactory)
131 xmlparser *This = impl_from_IXMLParser( iface );
133 TRACE("(%p, %p)\n", This, ppNodeFactory);
135 if(!ppNodeFactory)
136 return E_INVALIDARG;
138 *ppNodeFactory = This->nodefactory;
140 if(*ppNodeFactory)
141 IXMLNodeFactory_AddRef(*ppNodeFactory);
143 return S_OK;
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));
152 return E_NOTIMPL;
155 static ULONG WINAPI xmlparser_GetLineNumber(IXMLParser *iface)
157 xmlparser *This = impl_from_IXMLParser( iface );
159 FIXME("(%p)\n", This);
161 return 0;
164 static ULONG WINAPI xmlparser_GetLinePosition(IXMLParser *iface)
166 xmlparser *This = impl_from_IXMLParser( iface );
168 FIXME("(%p)\n", This);
170 return 0;
173 static ULONG WINAPI xmlparser_GetAbsolutePosition(IXMLParser *iface)
175 xmlparser *This = impl_from_IXMLParser( iface );
177 FIXME("(%p)\n", This);
179 return 0;
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);
189 return 0;
192 static HRESULT WINAPI xmlparser_GetLastError(IXMLParser *iface)
194 xmlparser *This = impl_from_IXMLParser( iface );
196 FIXME("(%p)\n", This);
198 return E_NOTIMPL;
201 static HRESULT WINAPI xmlparser_GetErrorInfo(IXMLParser *iface, BSTR *pErrorInfo)
203 xmlparser *This = impl_from_IXMLParser( iface );
205 FIXME("(%p %p)\n", This, pErrorInfo);
207 return E_NOTIMPL;
210 static ULONG WINAPI xmlparser_GetFlags(IXMLParser *iface)
212 xmlparser *This = impl_from_IXMLParser( iface );
214 TRACE("(%p)\n", This);
216 return This->flags;
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);
225 return E_NOTIMPL;
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);
236 return E_NOTIMPL;
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);
246 return E_NOTIMPL;
249 static HRESULT WINAPI xmlparser_SetInput(IXMLParser *iface, IUnknown *pStm)
251 xmlparser *This = impl_from_IXMLParser( iface );
253 TRACE("(%p %p)\n", This, pStm);
255 if(!pStm)
256 return E_INVALIDARG;
258 if(This->input)
259 IUnknown_Release(This->input);
261 This->input = pStm;
262 IUnknown_AddRef(This->input);
264 return S_OK;
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);
274 return E_NOTIMPL;
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));
284 return E_NOTIMPL;
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);
294 return E_NOTIMPL;
297 static HRESULT WINAPI xmlparser_ParseEntity(IXMLParser *iface, const WCHAR *text,
298 ULONG len, BOOL fpe)
300 xmlparser *This = impl_from_IXMLParser( iface );
302 FIXME("(%p %s %d %d)\n", This, debugstr_w(text), len, fpe);
304 return E_NOTIMPL;
307 static HRESULT WINAPI xmlparser_ExpandEntity(IXMLParser *iface, const WCHAR *text,
308 ULONG len)
310 xmlparser *This = impl_from_IXMLParser( iface );
312 FIXME("(%p %s %d)\n", This, debugstr_w(text), len);
314 return E_NOTIMPL;
317 static HRESULT WINAPI xmlparser_SetRoot(IXMLParser *iface, PVOID pRoot)
319 xmlparser *This = impl_from_IXMLParser( iface );
321 FIXME("(%p %p)\n", This, pRoot);
323 return E_NOTIMPL;
326 static HRESULT WINAPI xmlparser_GetRoot( IXMLParser *iface, PVOID *ppRoot)
328 xmlparser *This = impl_from_IXMLParser( iface );
330 FIXME("(%p %p)\n", This, ppRoot);
332 return E_NOTIMPL;
335 static HRESULT WINAPI xmlparser_Run(IXMLParser *iface, LONG chars)
337 xmlparser *This = impl_from_IXMLParser( iface );
339 FIXME("(%p %d)\n", This, chars);
341 return E_NOTIMPL;
344 static HRESULT WINAPI xmlparser_GetParserState(IXMLParser *iface)
346 xmlparser *This = impl_from_IXMLParser( iface );
348 FIXME("(%p)\n", This);
350 return E_NOTIMPL;
353 static HRESULT WINAPI xmlparser_Suspend(IXMLParser *iface)
355 xmlparser *This = impl_from_IXMLParser( iface );
357 FIXME("(%p)\n", This);
359 return E_NOTIMPL;
362 static HRESULT WINAPI xmlparser_Reset(IXMLParser *iface)
364 xmlparser *This = impl_from_IXMLParser( iface );
366 FIXME("(%p)\n", This);
368 return E_NOTIMPL;
371 static HRESULT WINAPI xmlparser_SetFlags(IXMLParser *iface, ULONG flags)
373 xmlparser *This = impl_from_IXMLParser( iface );
375 TRACE("(%p %d)\n", This, flags);
377 This->flags = flags;
379 return S_OK;
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));
388 return E_NOTIMPL;
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);
397 return E_NOTIMPL;
401 static const struct IXMLParserVtbl xmlparser_vtbl =
403 xmlparser_QueryInterface,
404 xmlparser_AddRef,
405 xmlparser_Release,
406 xmlparser_SetFactory,
407 xmlparser_GetFactory,
408 xmlparser_Abort,
409 xmlparser_GetLineNumber,
410 xmlparser_GetLinePosition,
411 xmlparser_GetAbsolutePosition,
412 xmlparser_GetLineBuffer,
413 xmlparser_GetLastError,
414 xmlparser_GetErrorInfo,
415 xmlparser_GetFlags,
416 xmlparser_GetURL,
417 xmlparser_SetURL,
418 xmlparser_Load,
419 xmlparser_SetInput,
420 xmlparser_PushData,
421 xmlparser_LoadDTD,
422 xmlparser_LoadEntity,
423 xmlparser_ParseEntity,
424 xmlparser_ExpandEntity,
425 xmlparser_SetRoot,
426 xmlparser_GetRoot,
427 xmlparser_Run,
428 xmlparser_GetParserState,
429 xmlparser_Suspend,
430 xmlparser_Reset,
431 xmlparser_SetFlags,
432 xmlparser_SetSecureBaseURL,
433 xmlparser_GetSecureBaseURL
436 HRESULT XMLParser_create(void **ppObj)
438 xmlparser *This;
440 TRACE("(%p)\n", ppObj);
442 This = heap_alloc( sizeof(xmlparser) );
443 if(!This)
444 return E_OUTOFMEMORY;
446 This->IXMLParser_iface.lpVtbl = &xmlparser_vtbl;
447 This->nodefactory = NULL;
448 This->input = NULL;
449 This->flags = 0;
450 This->ref = 1;
452 *ppObj = &This->IXMLParser_iface;
454 TRACE("returning iface %p\n", *ppObj);
456 return S_OK;