netstat: Initial implementation.
[wine] / dlls / msxml3 / xmlparser.c
1 /*
2  * XML Parser implementation
3  *
4  * Copyright 2011 Alistair Leslie-Hughes
5  *
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.
10  *
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.
15  *
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
19  */
20 #define COBJMACROS
21
22 #include "config.h"
23
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
30
31 #include "windef.h"
32 #include "winbase.h"
33 #include "winuser.h"
34 #include "ole2.h"
35 #include "msxml6.h"
36
37 #include "msxml_private.h"
38
39 #include "initguid.h"
40 #include "xmlparser.h"
41
42 #include "wine/debug.h"
43
44 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
45
46 typedef struct _xmlparser
47 {
48     IXMLParser IXMLParser_iface;
49     LONG ref;
50
51     int flags;
52 } xmlparser;
53
54 static inline xmlparser *impl_from_IXMLParser( IXMLParser *iface )
55 {
56     return CONTAINING_RECORD(iface, xmlparser, IXMLParser_iface);
57 }
58
59 /*** IUnknown methods ***/
60 static HRESULT WINAPI xmlparser_QueryInterface(IXMLParser* iface, REFIID riid, void **ppvObject)
61 {
62     xmlparser *This = impl_from_IXMLParser( iface );
63     TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
64
65     if ( IsEqualGUID( riid, &IID_IXMLParser ) ||
66          IsEqualGUID( riid, &IID_IXMLNodeSource ) ||
67          IsEqualGUID( riid, &IID_IUnknown ) )
68     {
69         *ppvObject = iface;
70     }
71     else
72     {
73         TRACE("Unsupported interface %s\n", debugstr_guid(riid));
74         *ppvObject = NULL;
75         return E_NOINTERFACE;
76     }
77
78     IXMLParser_AddRef(iface);
79     return S_OK;
80 }
81
82 static ULONG WINAPI xmlparser_AddRef(IXMLParser* iface)
83 {
84     xmlparser *This = impl_from_IXMLParser( iface );
85     ULONG ref = InterlockedIncrement( &This->ref );
86     TRACE("(%p)->(%d)\n", This, ref);
87     return ref;
88 }
89
90 static ULONG WINAPI xmlparser_Release(IXMLParser* iface)
91 {
92     xmlparser *This = impl_from_IXMLParser( iface );
93     ULONG ref = InterlockedDecrement( &This->ref );
94
95     TRACE("(%p)->(%d)\n", This, ref);
96     if ( ref == 0 )
97     {
98         heap_free( This );
99     }
100
101     return ref;
102 }
103
104 /*** IXMLNodeSource methods ***/
105 static HRESULT WINAPI xmlparser_SetFactory(IXMLParser *iface, IXMLNodeFactory *pNodeFactory)
106 {
107     xmlparser *This = impl_from_IXMLParser( iface );
108
109     FIXME("(%p %p)\n", This, pNodeFactory);
110
111     return E_NOTIMPL;
112 }
113
114 static HRESULT WINAPI xmlparser_GetFactory(IXMLParser *iface, IXMLNodeFactory **ppNodeFactory)
115 {
116     xmlparser *This = impl_from_IXMLParser( iface );
117
118     FIXME("(%p, %p)\n", This, ppNodeFactory);
119
120     return E_NOTIMPL;
121 }
122
123 static HRESULT WINAPI xmlparser_Abort(IXMLParser *iface, BSTR bstrErrorInfo)
124 {
125     xmlparser *This = impl_from_IXMLParser( iface );
126
127     FIXME("(%p, %s)\n", This, debugstr_w(bstrErrorInfo));
128
129     return E_NOTIMPL;
130 }
131
132 static ULONG WINAPI xmlparser_GetLineNumber(IXMLParser *iface)
133 {
134     xmlparser *This = impl_from_IXMLParser( iface );
135
136     FIXME("(%p)\n", This);
137
138     return 0;
139 }
140
141 static ULONG WINAPI xmlparser_GetLinePosition(IXMLParser *iface)
142 {
143     xmlparser *This = impl_from_IXMLParser( iface );
144
145     FIXME("(%p)\n", This);
146
147     return 0;
148 }
149
150 static ULONG WINAPI xmlparser_GetAbsolutePosition(IXMLParser *iface)
151 {
152     xmlparser *This = impl_from_IXMLParser( iface );
153
154     FIXME("(%p)\n", This);
155
156     return 0;
157 }
158
159 static HRESULT WINAPI xmlparser_GetLineBuffer(IXMLParser *iface, const WCHAR **ppBuf,
160                 ULONG *len, ULONG *startPos)
161 {
162     xmlparser *This = impl_from_IXMLParser( iface );
163
164     FIXME("(%p %p %p %p)\n", This, ppBuf, len, startPos);
165
166     return 0;
167 }
168
169 static HRESULT WINAPI xmlparser_GetLastError(IXMLParser *iface)
170 {
171     xmlparser *This = impl_from_IXMLParser( iface );
172
173     FIXME("(%p)\n", This);
174
175     return E_NOTIMPL;
176 }
177
178 static HRESULT WINAPI xmlparser_GetErrorInfo(IXMLParser *iface, BSTR *pErrorInfo)
179 {
180     xmlparser *This = impl_from_IXMLParser( iface );
181
182     FIXME("(%p %p)\n", This, pErrorInfo);
183
184     return E_NOTIMPL;
185 }
186
187 static ULONG WINAPI xmlparser_GetFlags(IXMLParser *iface)
188 {
189     xmlparser *This = impl_from_IXMLParser( iface );
190
191     TRACE("(%p)\n", This);
192
193     return This->flags;
194 }
195
196 static HRESULT WINAPI xmlparser_GetURL(IXMLParser *iface, const WCHAR **ppBuf)
197 {
198     xmlparser *This = impl_from_IXMLParser( iface );
199
200     FIXME("(%p %p)\n", This, ppBuf);
201
202     return E_NOTIMPL;
203 }
204
205 /*** IXMLParser methods ***/
206 static HRESULT WINAPI xmlparser_SetURL(IXMLParser *iface,const WCHAR *pszBaseUrl,
207                 const WCHAR *relativeUrl, BOOL async)
208 {
209     xmlparser *This = impl_from_IXMLParser( iface );
210
211     FIXME("(%p %s %s %d)\n", This, debugstr_w(pszBaseUrl), debugstr_w(relativeUrl), async);
212
213     return E_NOTIMPL;
214 }
215
216 static HRESULT WINAPI xmlparser_Load(IXMLParser *iface, BOOL bFullyAvailable,
217                 IMoniker *pMon, LPBC pBC, DWORD dwMode)
218 {
219     xmlparser *This = impl_from_IXMLParser( iface );
220
221     FIXME("(%p %d %p %p %d)\n", This, bFullyAvailable, pMon, pBC, dwMode);
222
223     return E_NOTIMPL;
224 }
225
226 static HRESULT WINAPI xmlparser_SetInput(IXMLParser *iface, IUnknown *pStm)
227 {
228     xmlparser *This = impl_from_IXMLParser( iface );
229
230     FIXME("(%p %p)\n", This, pStm);
231
232     return E_NOTIMPL;
233 }
234
235 static HRESULT WINAPI xmlparser_PushData(IXMLParser *iface, const char *pData,
236                 ULONG nChars, BOOL fLastBuffer)
237 {
238     xmlparser *This = impl_from_IXMLParser( iface );
239
240     FIXME("(%p %s %d %d)\n", This, debugstr_a(pData), nChars, fLastBuffer);
241
242     return E_NOTIMPL;
243 }
244
245 static HRESULT WINAPI xmlparser_LoadDTD(IXMLParser *iface, const WCHAR *baseUrl,
246                 const WCHAR *relativeUrl)
247 {
248     xmlparser *This = impl_from_IXMLParser( iface );
249
250     FIXME("(%p %s %s)\n", This, debugstr_w(baseUrl), debugstr_w(relativeUrl));
251
252     return E_NOTIMPL;
253 }
254
255 static HRESULT WINAPI xmlparser_LoadEntity(IXMLParser *iface, const WCHAR *baseUrl,
256                 const WCHAR *relativeUrl, BOOL fpe)
257 {
258     xmlparser *This = impl_from_IXMLParser( iface );
259
260     FIXME("(%p %s %s %d)\n", This, debugstr_w(baseUrl), debugstr_w(relativeUrl), fpe);
261
262     return E_NOTIMPL;
263 }
264
265 static HRESULT WINAPI xmlparser_ParseEntity(IXMLParser *iface, const WCHAR *text,
266                 ULONG len, BOOL fpe)
267 {
268     xmlparser *This = impl_from_IXMLParser( iface );
269
270     FIXME("(%p %s %d %d)\n", This, debugstr_w(text), len, fpe);
271
272     return E_NOTIMPL;
273 }
274
275 static HRESULT WINAPI xmlparser_ExpandEntity(IXMLParser *iface, const WCHAR *text,
276                 ULONG len)
277 {
278     xmlparser *This = impl_from_IXMLParser( iface );
279
280     FIXME("(%p %s %d)\n", This, debugstr_w(text), len);
281
282     return E_NOTIMPL;
283 }
284
285 static HRESULT WINAPI xmlparser_SetRoot(IXMLParser *iface, PVOID pRoot)
286 {
287     xmlparser *This = impl_from_IXMLParser( iface );
288
289     FIXME("(%p %p)\n", This, pRoot);
290
291     return E_NOTIMPL;
292 }
293
294 static HRESULT WINAPI xmlparser_GetRoot( IXMLParser *iface, PVOID *ppRoot)
295 {
296     xmlparser *This = impl_from_IXMLParser( iface );
297
298     FIXME("(%p %p)\n", This, ppRoot);
299
300     return E_NOTIMPL;
301 }
302
303 static HRESULT WINAPI xmlparser_Run(IXMLParser *iface, LONG chars)
304 {
305     xmlparser *This = impl_from_IXMLParser( iface );
306
307     FIXME("(%p %d)\n", This, chars);
308
309     return E_NOTIMPL;
310 }
311
312 static HRESULT WINAPI xmlparser_GetParserState(IXMLParser *iface)
313 {
314     xmlparser *This = impl_from_IXMLParser( iface );
315
316     FIXME("(%p)\n", This);
317
318     return E_NOTIMPL;
319 }
320
321 static HRESULT WINAPI xmlparser_Suspend(IXMLParser *iface)
322 {
323     xmlparser *This = impl_from_IXMLParser( iface );
324
325     FIXME("(%p)\n", This);
326
327     return E_NOTIMPL;
328 }
329
330 static HRESULT WINAPI xmlparser_Reset(IXMLParser *iface)
331 {
332     xmlparser *This = impl_from_IXMLParser( iface );
333
334     FIXME("(%p)\n", This);
335
336     return E_NOTIMPL;
337 }
338
339 static HRESULT WINAPI xmlparser_SetFlags(IXMLParser *iface, ULONG flags)
340 {
341     xmlparser *This = impl_from_IXMLParser( iface );
342
343     TRACE("(%p %d)\n", This, flags);
344
345     This->flags = flags;
346
347     return S_OK;
348 }
349
350 static HRESULT WINAPI xmlparser_SetSecureBaseURL(IXMLParser *iface, const WCHAR *baseUrl)
351 {
352     xmlparser *This = impl_from_IXMLParser( iface );
353
354     FIXME("(%p %s)\n", This, debugstr_w(baseUrl));
355
356     return E_NOTIMPL;
357 }
358
359 static HRESULT WINAPI xmlparser_GetSecureBaseURL( IXMLParser *iface, const WCHAR **ppBuf)
360 {
361     xmlparser *This = impl_from_IXMLParser( iface );
362
363     FIXME("(%p %p)\n", This, ppBuf);
364
365     return E_NOTIMPL;
366 }
367
368
369 static const struct IXMLParserVtbl xmlparser_vtbl =
370 {
371     xmlparser_QueryInterface,
372     xmlparser_AddRef,
373     xmlparser_Release,
374     xmlparser_SetFactory,
375     xmlparser_GetFactory,
376     xmlparser_Abort,
377     xmlparser_GetLineNumber,
378     xmlparser_GetLinePosition,
379     xmlparser_GetAbsolutePosition,
380     xmlparser_GetLineBuffer,
381     xmlparser_GetLastError,
382     xmlparser_GetErrorInfo,
383     xmlparser_GetFlags,
384     xmlparser_GetURL,
385     xmlparser_SetURL,
386     xmlparser_Load,
387     xmlparser_SetInput,
388     xmlparser_PushData,
389     xmlparser_LoadDTD,
390     xmlparser_LoadEntity,
391     xmlparser_ParseEntity,
392     xmlparser_ExpandEntity,
393     xmlparser_SetRoot,
394     xmlparser_GetRoot,
395     xmlparser_Run,
396     xmlparser_GetParserState,
397     xmlparser_Suspend,
398     xmlparser_Reset,
399     xmlparser_SetFlags,
400     xmlparser_SetSecureBaseURL,
401     xmlparser_GetSecureBaseURL
402 };
403
404 HRESULT XMLParser_create(IUnknown* pUnkOuter, void**ppObj)
405 {
406     xmlparser *This;
407
408     TRACE("(%p,%p)\n", pUnkOuter, ppObj);
409
410     if (pUnkOuter)
411         FIXME("support aggregation, outer\n");
412
413     This = heap_alloc( sizeof(xmlparser) );
414     if(!This)
415         return E_OUTOFMEMORY;
416
417     This->IXMLParser_iface.lpVtbl = &xmlparser_vtbl;
418     This->flags = 0;
419     This->ref = 1;
420
421     *ppObj = &This->IXMLParser_iface;
422
423     TRACE("returning iface %p\n", *ppObj);
424
425     return S_OK;
426 }