xref: /reactos/dll/win32/msxml3/parseerror.c (revision bab6b90f)
1c2c66affSColin Finck /*
2c2c66affSColin Finck  *    ParseError implementation
3c2c66affSColin Finck  *
4c2c66affSColin Finck  * Copyright 2005 Huw Davies
5c2c66affSColin Finck  *
6c2c66affSColin Finck  * This library is free software; you can redistribute it and/or
7c2c66affSColin Finck  * modify it under the terms of the GNU Lesser General Public
8c2c66affSColin Finck  * License as published by the Free Software Foundation; either
9c2c66affSColin Finck  * version 2.1 of the License, or (at your option) any later version.
10c2c66affSColin Finck  *
11c2c66affSColin Finck  * This library is distributed in the hope that it will be useful,
12c2c66affSColin Finck  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13c2c66affSColin Finck  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14c2c66affSColin Finck  * Lesser General Public License for more details.
15c2c66affSColin Finck  *
16c2c66affSColin Finck  * You should have received a copy of the GNU Lesser General Public
17c2c66affSColin Finck  * License along with this library; if not, write to the Free Software
18c2c66affSColin Finck  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19c2c66affSColin Finck  */
20c2c66affSColin Finck 
21*bab6b90fSAmine Khaldi 
22*bab6b90fSAmine Khaldi #define COBJMACROS
23*bab6b90fSAmine Khaldi 
24*bab6b90fSAmine Khaldi #include "config.h"
25*bab6b90fSAmine Khaldi 
26*bab6b90fSAmine Khaldi #include <stdarg.h>
27*bab6b90fSAmine Khaldi #ifdef HAVE_LIBXML2
28*bab6b90fSAmine Khaldi # include <libxml/parser.h>
29*bab6b90fSAmine Khaldi # include <libxml/xmlerror.h>
30*bab6b90fSAmine Khaldi #endif
31*bab6b90fSAmine Khaldi 
32*bab6b90fSAmine Khaldi #include "windef.h"
33*bab6b90fSAmine Khaldi #include "winbase.h"
34*bab6b90fSAmine Khaldi #include "winerror.h"
35*bab6b90fSAmine Khaldi #include "winuser.h"
36*bab6b90fSAmine Khaldi #include "ole2.h"
37*bab6b90fSAmine Khaldi #include "msxml6.h"
38*bab6b90fSAmine Khaldi 
39*bab6b90fSAmine Khaldi #include "msxml_private.h"
40*bab6b90fSAmine Khaldi 
41*bab6b90fSAmine Khaldi #include "wine/debug.h"
42*bab6b90fSAmine Khaldi 
43*bab6b90fSAmine Khaldi WINE_DEFAULT_DEBUG_CHANNEL(msxml);
44c2c66affSColin Finck 
45c2c66affSColin Finck typedef struct
46c2c66affSColin Finck {
47c2c66affSColin Finck     DispatchEx dispex;
48c2c66affSColin Finck     IXMLDOMParseError2 IXMLDOMParseError2_iface;
49c2c66affSColin Finck     LONG ref;
50c2c66affSColin Finck     LONG code, line, linepos, filepos;
51c2c66affSColin Finck     BSTR url, reason, srcText;
52c2c66affSColin Finck } parse_error_t;
53c2c66affSColin Finck 
impl_from_IXMLDOMParseError2(IXMLDOMParseError2 * iface)54c2c66affSColin Finck static inline parse_error_t *impl_from_IXMLDOMParseError2( IXMLDOMParseError2 *iface )
55c2c66affSColin Finck {
56c2c66affSColin Finck     return CONTAINING_RECORD(iface, parse_error_t, IXMLDOMParseError2_iface);
57c2c66affSColin Finck }
58c2c66affSColin Finck 
parseError_QueryInterface(IXMLDOMParseError2 * iface,REFIID riid,void ** ppvObject)59c2c66affSColin Finck static HRESULT WINAPI parseError_QueryInterface(
60c2c66affSColin Finck     IXMLDOMParseError2 *iface,
61c2c66affSColin Finck     REFIID riid,
62c2c66affSColin Finck     void** ppvObject )
63c2c66affSColin Finck {
64c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
65c2c66affSColin Finck 
66c2c66affSColin Finck     TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
67c2c66affSColin Finck 
68c2c66affSColin Finck     if ( IsEqualGUID( riid, &IID_IUnknown ) ||
69c2c66affSColin Finck          IsEqualGUID( riid, &IID_IDispatch ) ||
70c2c66affSColin Finck          IsEqualGUID( riid, &IID_IXMLDOMParseError ) ||
71c2c66affSColin Finck          IsEqualGUID( riid, &IID_IXMLDOMParseError2 ) )
72c2c66affSColin Finck     {
73c2c66affSColin Finck         *ppvObject = iface;
74c2c66affSColin Finck     }
75c2c66affSColin Finck     else if (dispex_query_interface(&This->dispex, riid, ppvObject))
76c2c66affSColin Finck     {
77c2c66affSColin Finck         return *ppvObject ? S_OK : E_NOINTERFACE;
78c2c66affSColin Finck     }
79c2c66affSColin Finck     else
80c2c66affSColin Finck     {
81c2c66affSColin Finck         FIXME("interface %s not implemented\n", debugstr_guid(riid));
82c2c66affSColin Finck         *ppvObject = NULL;
83c2c66affSColin Finck         return E_NOINTERFACE;
84c2c66affSColin Finck     }
85c2c66affSColin Finck 
86c2c66affSColin Finck     IXMLDOMParseError2_AddRef( iface );
87c2c66affSColin Finck 
88c2c66affSColin Finck     return S_OK;
89c2c66affSColin Finck }
90c2c66affSColin Finck 
parseError_AddRef(IXMLDOMParseError2 * iface)91c2c66affSColin Finck static ULONG WINAPI parseError_AddRef(
92c2c66affSColin Finck     IXMLDOMParseError2 *iface )
93c2c66affSColin Finck {
94c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
95c2c66affSColin Finck     ULONG ref = InterlockedIncrement( &This->ref );
96c2c66affSColin Finck     TRACE("(%p)->(%d)\n", This, ref);
97c2c66affSColin Finck     return ref;
98c2c66affSColin Finck }
99c2c66affSColin Finck 
parseError_Release(IXMLDOMParseError2 * iface)100c2c66affSColin Finck static ULONG WINAPI parseError_Release(
101c2c66affSColin Finck     IXMLDOMParseError2 *iface )
102c2c66affSColin Finck {
103c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
104c2c66affSColin Finck     ULONG ref = InterlockedDecrement( &This->ref );
105c2c66affSColin Finck 
106c2c66affSColin Finck     TRACE("(%p)->(%d)\n", This, ref);
107c2c66affSColin Finck     if ( ref == 0 )
108c2c66affSColin Finck     {
109c2c66affSColin Finck         SysFreeString(This->url);
110c2c66affSColin Finck         SysFreeString(This->reason);
111c2c66affSColin Finck         SysFreeString(This->srcText);
112c2c66affSColin Finck         heap_free( This );
113c2c66affSColin Finck     }
114c2c66affSColin Finck 
115c2c66affSColin Finck     return ref;
116c2c66affSColin Finck }
117c2c66affSColin Finck 
parseError_GetTypeInfoCount(IXMLDOMParseError2 * iface,UINT * pctinfo)118c2c66affSColin Finck static HRESULT WINAPI parseError_GetTypeInfoCount(
119c2c66affSColin Finck     IXMLDOMParseError2 *iface,
120c2c66affSColin Finck     UINT* pctinfo )
121c2c66affSColin Finck {
122c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
123c2c66affSColin Finck     return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
124c2c66affSColin Finck }
125c2c66affSColin Finck 
parseError_GetTypeInfo(IXMLDOMParseError2 * iface,UINT iTInfo,LCID lcid,ITypeInfo ** ppTInfo)126c2c66affSColin Finck static HRESULT WINAPI parseError_GetTypeInfo(
127c2c66affSColin Finck     IXMLDOMParseError2 *iface,
128c2c66affSColin Finck     UINT iTInfo,
129c2c66affSColin Finck     LCID lcid,
130c2c66affSColin Finck     ITypeInfo** ppTInfo )
131c2c66affSColin Finck {
132c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
133c2c66affSColin Finck     return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface,
134c2c66affSColin Finck         iTInfo, lcid, ppTInfo);
135c2c66affSColin Finck }
136c2c66affSColin Finck 
parseError_GetIDsOfNames(IXMLDOMParseError2 * iface,REFIID riid,LPOLESTR * rgszNames,UINT cNames,LCID lcid,DISPID * rgDispId)137c2c66affSColin Finck static HRESULT WINAPI parseError_GetIDsOfNames(
138c2c66affSColin Finck     IXMLDOMParseError2 *iface,
139c2c66affSColin Finck     REFIID riid,
140c2c66affSColin Finck     LPOLESTR* rgszNames,
141c2c66affSColin Finck     UINT cNames,
142c2c66affSColin Finck     LCID lcid,
143c2c66affSColin Finck     DISPID* rgDispId )
144c2c66affSColin Finck {
145c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
146c2c66affSColin Finck     return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface,
147c2c66affSColin Finck         riid, rgszNames, cNames, lcid, rgDispId);
148c2c66affSColin Finck }
149c2c66affSColin Finck 
parseError_Invoke(IXMLDOMParseError2 * iface,DISPID dispIdMember,REFIID riid,LCID lcid,WORD wFlags,DISPPARAMS * pDispParams,VARIANT * pVarResult,EXCEPINFO * pExcepInfo,UINT * puArgErr)150c2c66affSColin Finck static HRESULT WINAPI parseError_Invoke(
151c2c66affSColin Finck     IXMLDOMParseError2 *iface,
152c2c66affSColin Finck     DISPID dispIdMember,
153c2c66affSColin Finck     REFIID riid,
154c2c66affSColin Finck     LCID lcid,
155c2c66affSColin Finck     WORD wFlags,
156c2c66affSColin Finck     DISPPARAMS* pDispParams,
157c2c66affSColin Finck     VARIANT* pVarResult,
158c2c66affSColin Finck     EXCEPINFO* pExcepInfo,
159c2c66affSColin Finck     UINT* puArgErr )
160c2c66affSColin Finck {
161c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
162c2c66affSColin Finck     return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface,
163c2c66affSColin Finck         dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
164c2c66affSColin Finck }
165c2c66affSColin Finck 
parseError_get_errorCode(IXMLDOMParseError2 * iface,LONG * code)166c2c66affSColin Finck static HRESULT WINAPI parseError_get_errorCode(
167c2c66affSColin Finck     IXMLDOMParseError2 *iface,
168c2c66affSColin Finck     LONG *code )
169c2c66affSColin Finck {
170c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
171c2c66affSColin Finck     TRACE("(%p)->(%p)\n", This, code);
172c2c66affSColin Finck 
173c2c66affSColin Finck     *code = This->code;
174c2c66affSColin Finck 
175c2c66affSColin Finck     if(This->code == 0)
176c2c66affSColin Finck         return S_FALSE;
177c2c66affSColin Finck 
178c2c66affSColin Finck     return S_OK;
179c2c66affSColin Finck }
180c2c66affSColin Finck 
parseError_get_url(IXMLDOMParseError2 * iface,BSTR * url)181c2c66affSColin Finck static HRESULT WINAPI parseError_get_url(
182c2c66affSColin Finck     IXMLDOMParseError2 *iface,
183c2c66affSColin Finck     BSTR *url )
184c2c66affSColin Finck {
185c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
186c2c66affSColin Finck     FIXME("(%p)->(%p)\n", This, url);
187c2c66affSColin Finck     return E_NOTIMPL;
188c2c66affSColin Finck }
189c2c66affSColin Finck 
parseError_get_reason(IXMLDOMParseError2 * iface,BSTR * reason)190c2c66affSColin Finck static HRESULT WINAPI parseError_get_reason(
191c2c66affSColin Finck     IXMLDOMParseError2 *iface,
192c2c66affSColin Finck     BSTR *reason )
193c2c66affSColin Finck {
194c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
195c2c66affSColin Finck     TRACE("(%p)->(%p)\n", This, reason);
196c2c66affSColin Finck 
197c2c66affSColin Finck     if(!This->reason)
198c2c66affSColin Finck     {
199c2c66affSColin Finck         *reason = NULL;
200c2c66affSColin Finck         return S_FALSE;
201c2c66affSColin Finck     }
202c2c66affSColin Finck     *reason = SysAllocString(This->reason);
203c2c66affSColin Finck     return S_OK;
204c2c66affSColin Finck }
205c2c66affSColin Finck 
parseError_get_srcText(IXMLDOMParseError2 * iface,BSTR * srcText)206c2c66affSColin Finck static HRESULT WINAPI parseError_get_srcText(
207c2c66affSColin Finck     IXMLDOMParseError2 *iface,
208c2c66affSColin Finck     BSTR *srcText )
209c2c66affSColin Finck {
210c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
211c2c66affSColin Finck 
212c2c66affSColin Finck     TRACE("(%p)->(%p)\n", This, srcText);
213c2c66affSColin Finck 
214c2c66affSColin Finck     if (!srcText) return E_INVALIDARG;
215c2c66affSColin Finck 
216c2c66affSColin Finck     *srcText = SysAllocString(This->srcText);
217c2c66affSColin Finck 
218c2c66affSColin Finck     return S_OK;
219c2c66affSColin Finck }
220c2c66affSColin Finck 
parseError_get_line(IXMLDOMParseError2 * iface,LONG * line)221c2c66affSColin Finck static HRESULT WINAPI parseError_get_line(
222c2c66affSColin Finck     IXMLDOMParseError2 *iface,
223c2c66affSColin Finck     LONG *line )
224c2c66affSColin Finck {
225c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
226c2c66affSColin Finck 
227c2c66affSColin Finck     TRACE("(%p)->(%p): stub\n", This, line);
228c2c66affSColin Finck 
229c2c66affSColin Finck     if (!line) return E_INVALIDARG;
230c2c66affSColin Finck 
231c2c66affSColin Finck     *line = This->line;
232c2c66affSColin Finck     return S_OK;
233c2c66affSColin Finck }
234c2c66affSColin Finck 
parseError_get_linepos(IXMLDOMParseError2 * iface,LONG * linepos)235c2c66affSColin Finck static HRESULT WINAPI parseError_get_linepos(
236c2c66affSColin Finck     IXMLDOMParseError2 *iface,
237c2c66affSColin Finck     LONG *linepos )
238c2c66affSColin Finck {
239c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
240c2c66affSColin Finck 
241c2c66affSColin Finck     TRACE("(%p)->(%p)\n", This, linepos);
242c2c66affSColin Finck 
243c2c66affSColin Finck     if (!linepos) return E_INVALIDARG;
244c2c66affSColin Finck 
245c2c66affSColin Finck     *linepos = This->linepos;
246c2c66affSColin Finck     return S_OK;
247c2c66affSColin Finck }
248c2c66affSColin Finck 
parseError_get_filepos(IXMLDOMParseError2 * iface,LONG * filepos)249c2c66affSColin Finck static HRESULT WINAPI parseError_get_filepos(
250c2c66affSColin Finck     IXMLDOMParseError2 *iface,
251c2c66affSColin Finck     LONG *filepos )
252c2c66affSColin Finck {
253c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
254c2c66affSColin Finck     FIXME("(%p)->(%p)\n", This, filepos);
255c2c66affSColin Finck     return E_NOTIMPL;
256c2c66affSColin Finck }
257c2c66affSColin Finck 
parseError_get_errorXPath(IXMLDOMParseError2 * iface,BSTR * xpathexpr)258c2c66affSColin Finck static HRESULT WINAPI parseError_get_errorXPath(
259c2c66affSColin Finck     IXMLDOMParseError2 *iface,
260c2c66affSColin Finck     BSTR *xpathexpr)
261c2c66affSColin Finck {
262c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
263c2c66affSColin Finck     FIXME("(%p)->(%p)\n", This, xpathexpr);
264c2c66affSColin Finck     return E_NOTIMPL;
265c2c66affSColin Finck }
266c2c66affSColin Finck 
parseError_get_AllErrors(IXMLDOMParseError2 * iface,IXMLDOMParseErrorCollection ** allErrors)267c2c66affSColin Finck static HRESULT WINAPI parseError_get_AllErrors(
268c2c66affSColin Finck     IXMLDOMParseError2 *iface,
269c2c66affSColin Finck     IXMLDOMParseErrorCollection **allErrors)
270c2c66affSColin Finck {
271c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
272c2c66affSColin Finck     FIXME("(%p)->(%p)\n", This, allErrors);
273c2c66affSColin Finck     return E_NOTIMPL;
274c2c66affSColin Finck }
275c2c66affSColin Finck 
parseError_errorParameters(IXMLDOMParseError2 * iface,LONG index,BSTR * param)276c2c66affSColin Finck static HRESULT WINAPI parseError_errorParameters(
277c2c66affSColin Finck     IXMLDOMParseError2 *iface,
278c2c66affSColin Finck     LONG index,
279c2c66affSColin Finck     BSTR *param)
280c2c66affSColin Finck {
281c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
282c2c66affSColin Finck     FIXME("(%p)->(%p)\n", This, param);
283c2c66affSColin Finck     return E_NOTIMPL;
284c2c66affSColin Finck }
285c2c66affSColin Finck 
parseError_get_errorParametersCount(IXMLDOMParseError2 * iface,LONG * count)286c2c66affSColin Finck static HRESULT WINAPI parseError_get_errorParametersCount(
287c2c66affSColin Finck     IXMLDOMParseError2 *iface,
288c2c66affSColin Finck     LONG *count)
289c2c66affSColin Finck {
290c2c66affSColin Finck     parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
291c2c66affSColin Finck     FIXME("(%p)->(%p)\n", This, count);
292c2c66affSColin Finck     return E_NOTIMPL;
293c2c66affSColin Finck }
294c2c66affSColin Finck 
295c2c66affSColin Finck static const struct IXMLDOMParseError2Vtbl XMLDOMParseError2Vtbl =
296c2c66affSColin Finck {
297c2c66affSColin Finck     parseError_QueryInterface,
298c2c66affSColin Finck     parseError_AddRef,
299c2c66affSColin Finck     parseError_Release,
300c2c66affSColin Finck     parseError_GetTypeInfoCount,
301c2c66affSColin Finck     parseError_GetTypeInfo,
302c2c66affSColin Finck     parseError_GetIDsOfNames,
303c2c66affSColin Finck     parseError_Invoke,
304c2c66affSColin Finck     parseError_get_errorCode,
305c2c66affSColin Finck     parseError_get_url,
306c2c66affSColin Finck     parseError_get_reason,
307c2c66affSColin Finck     parseError_get_srcText,
308c2c66affSColin Finck     parseError_get_line,
309c2c66affSColin Finck     parseError_get_linepos,
310c2c66affSColin Finck     parseError_get_filepos,
311c2c66affSColin Finck     parseError_get_errorXPath,
312c2c66affSColin Finck     parseError_get_AllErrors,
313c2c66affSColin Finck     parseError_errorParameters,
314c2c66affSColin Finck     parseError_get_errorParametersCount
315c2c66affSColin Finck };
316c2c66affSColin Finck 
317c2c66affSColin Finck static const tid_t parseError_iface_tids[] = {
318c2c66affSColin Finck     IXMLDOMParseError2_tid,
319c2c66affSColin Finck     0
320c2c66affSColin Finck };
321c2c66affSColin Finck 
322c2c66affSColin Finck static dispex_static_data_t parseError_dispex = {
323c2c66affSColin Finck     NULL,
324c2c66affSColin Finck     IXMLDOMParseError2_tid,
325c2c66affSColin Finck     NULL,
326c2c66affSColin Finck     parseError_iface_tids
327c2c66affSColin Finck };
328c2c66affSColin Finck 
create_parseError(LONG code,BSTR url,BSTR reason,BSTR srcText,LONG line,LONG linepos,LONG filepos)329c2c66affSColin Finck IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
330c2c66affSColin Finck                                       LONG line, LONG linepos, LONG filepos )
331c2c66affSColin Finck {
332c2c66affSColin Finck     parse_error_t *This;
333c2c66affSColin Finck 
334c2c66affSColin Finck     This = heap_alloc( sizeof(*This) );
335c2c66affSColin Finck     if ( !This )
336c2c66affSColin Finck         return NULL;
337c2c66affSColin Finck 
338c2c66affSColin Finck     This->IXMLDOMParseError2_iface.lpVtbl = &XMLDOMParseError2Vtbl;
339c2c66affSColin Finck     This->ref = 1;
340c2c66affSColin Finck 
341c2c66affSColin Finck     This->code = code;
342c2c66affSColin Finck     This->url = url;
343c2c66affSColin Finck     This->reason = reason;
344c2c66affSColin Finck     This->srcText = srcText;
345c2c66affSColin Finck     This->line = line;
346c2c66affSColin Finck     This->linepos = linepos;
347c2c66affSColin Finck     This->filepos = filepos;
348c2c66affSColin Finck 
349c2c66affSColin Finck     init_dispex(&This->dispex, (IUnknown*)&This->IXMLDOMParseError2_iface, &parseError_dispex);
350c2c66affSColin Finck 
351c2c66affSColin Finck     return (IXMLDOMParseError*)&This->IXMLDOMParseError2_iface;
352c2c66affSColin Finck }
353