ntdll: Make sure we don't try to attach the main exe a second time.
[wine/zf.git] / dlls / msxml3 / parseerror.c
blob2ca0885708d53d4c6ccf6b6d7bf32d42b32fc708
1 /*
2 * ParseError implementation
4 * Copyright 2005 Huw Davies
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
22 #define COBJMACROS
24 #include "config.h"
26 #include <stdarg.h>
27 #ifdef HAVE_LIBXML2
28 # include <libxml/parser.h>
29 # include <libxml/xmlerror.h>
30 #endif
32 #include "windef.h"
33 #include "winbase.h"
34 #include "winerror.h"
35 #include "winuser.h"
36 #include "ole2.h"
37 #include "msxml6.h"
39 #include "msxml_private.h"
41 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
45 typedef struct
47 DispatchEx dispex;
48 IXMLDOMParseError2 IXMLDOMParseError2_iface;
49 LONG ref;
50 LONG code, line, linepos, filepos;
51 BSTR url, reason, srcText;
52 } parse_error_t;
54 static inline parse_error_t *impl_from_IXMLDOMParseError2( IXMLDOMParseError2 *iface )
56 return CONTAINING_RECORD(iface, parse_error_t, IXMLDOMParseError2_iface);
59 static HRESULT WINAPI parseError_QueryInterface(
60 IXMLDOMParseError2 *iface,
61 REFIID riid,
62 void** ppvObject )
64 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
66 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
68 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
69 IsEqualGUID( riid, &IID_IDispatch ) ||
70 IsEqualGUID( riid, &IID_IXMLDOMParseError ) ||
71 IsEqualGUID( riid, &IID_IXMLDOMParseError2 ) )
73 *ppvObject = iface;
75 else if (dispex_query_interface(&This->dispex, riid, ppvObject))
77 return *ppvObject ? S_OK : E_NOINTERFACE;
79 else
81 FIXME("interface %s not implemented\n", debugstr_guid(riid));
82 *ppvObject = NULL;
83 return E_NOINTERFACE;
86 IXMLDOMParseError2_AddRef( iface );
88 return S_OK;
91 static ULONG WINAPI parseError_AddRef(
92 IXMLDOMParseError2 *iface )
94 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
95 ULONG ref = InterlockedIncrement( &This->ref );
96 TRACE("(%p)->(%d)\n", This, ref);
97 return ref;
100 static ULONG WINAPI parseError_Release(
101 IXMLDOMParseError2 *iface )
103 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
104 ULONG ref = InterlockedDecrement( &This->ref );
106 TRACE("(%p)->(%d)\n", This, ref);
107 if ( ref == 0 )
109 SysFreeString(This->url);
110 SysFreeString(This->reason);
111 SysFreeString(This->srcText);
112 heap_free( This );
115 return ref;
118 static HRESULT WINAPI parseError_GetTypeInfoCount(
119 IXMLDOMParseError2 *iface,
120 UINT* pctinfo )
122 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
123 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
126 static HRESULT WINAPI parseError_GetTypeInfo(
127 IXMLDOMParseError2 *iface,
128 UINT iTInfo,
129 LCID lcid,
130 ITypeInfo** ppTInfo )
132 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
133 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface,
134 iTInfo, lcid, ppTInfo);
137 static HRESULT WINAPI parseError_GetIDsOfNames(
138 IXMLDOMParseError2 *iface,
139 REFIID riid,
140 LPOLESTR* rgszNames,
141 UINT cNames,
142 LCID lcid,
143 DISPID* rgDispId )
145 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
146 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface,
147 riid, rgszNames, cNames, lcid, rgDispId);
150 static HRESULT WINAPI parseError_Invoke(
151 IXMLDOMParseError2 *iface,
152 DISPID dispIdMember,
153 REFIID riid,
154 LCID lcid,
155 WORD wFlags,
156 DISPPARAMS* pDispParams,
157 VARIANT* pVarResult,
158 EXCEPINFO* pExcepInfo,
159 UINT* puArgErr )
161 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
162 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface,
163 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
166 static HRESULT WINAPI parseError_get_errorCode(
167 IXMLDOMParseError2 *iface,
168 LONG *code )
170 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
171 TRACE("(%p)->(%p)\n", This, code);
173 *code = This->code;
175 if(This->code == 0)
176 return S_FALSE;
178 return S_OK;
181 static HRESULT WINAPI parseError_get_url(
182 IXMLDOMParseError2 *iface,
183 BSTR *url )
185 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
186 FIXME("(%p)->(%p)\n", This, url);
187 return E_NOTIMPL;
190 static HRESULT WINAPI parseError_get_reason(
191 IXMLDOMParseError2 *iface,
192 BSTR *reason )
194 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
195 TRACE("(%p)->(%p)\n", This, reason);
197 if(!This->reason)
199 *reason = NULL;
200 return S_FALSE;
202 *reason = SysAllocString(This->reason);
203 return S_OK;
206 static HRESULT WINAPI parseError_get_srcText(
207 IXMLDOMParseError2 *iface,
208 BSTR *srcText )
210 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
212 TRACE("(%p)->(%p)\n", This, srcText);
214 if (!srcText) return E_INVALIDARG;
216 *srcText = SysAllocString(This->srcText);
218 return S_OK;
221 static HRESULT WINAPI parseError_get_line(
222 IXMLDOMParseError2 *iface,
223 LONG *line )
225 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
227 TRACE("%p, %p.\n", This, line);
229 if (!line) return E_INVALIDARG;
231 *line = This->line;
232 return S_OK;
235 static HRESULT WINAPI parseError_get_linepos(
236 IXMLDOMParseError2 *iface,
237 LONG *linepos )
239 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
241 TRACE("(%p)->(%p)\n", This, linepos);
243 if (!linepos) return E_INVALIDARG;
245 *linepos = This->linepos;
246 return S_OK;
249 static HRESULT WINAPI parseError_get_filepos(
250 IXMLDOMParseError2 *iface,
251 LONG *filepos )
253 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
254 FIXME("(%p)->(%p)\n", This, filepos);
255 return E_NOTIMPL;
258 static HRESULT WINAPI parseError_get_errorXPath(
259 IXMLDOMParseError2 *iface,
260 BSTR *xpathexpr)
262 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
263 FIXME("(%p)->(%p)\n", This, xpathexpr);
264 return E_NOTIMPL;
267 static HRESULT WINAPI parseError_get_AllErrors(
268 IXMLDOMParseError2 *iface,
269 IXMLDOMParseErrorCollection **allErrors)
271 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
272 FIXME("(%p)->(%p)\n", This, allErrors);
273 return E_NOTIMPL;
276 static HRESULT WINAPI parseError_errorParameters(
277 IXMLDOMParseError2 *iface,
278 LONG index,
279 BSTR *param)
281 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
282 FIXME("(%p)->(%p)\n", This, param);
283 return E_NOTIMPL;
286 static HRESULT WINAPI parseError_get_errorParametersCount(
287 IXMLDOMParseError2 *iface,
288 LONG *count)
290 parse_error_t *This = impl_from_IXMLDOMParseError2( iface );
291 FIXME("(%p)->(%p)\n", This, count);
292 return E_NOTIMPL;
295 static const struct IXMLDOMParseError2Vtbl XMLDOMParseError2Vtbl =
297 parseError_QueryInterface,
298 parseError_AddRef,
299 parseError_Release,
300 parseError_GetTypeInfoCount,
301 parseError_GetTypeInfo,
302 parseError_GetIDsOfNames,
303 parseError_Invoke,
304 parseError_get_errorCode,
305 parseError_get_url,
306 parseError_get_reason,
307 parseError_get_srcText,
308 parseError_get_line,
309 parseError_get_linepos,
310 parseError_get_filepos,
311 parseError_get_errorXPath,
312 parseError_get_AllErrors,
313 parseError_errorParameters,
314 parseError_get_errorParametersCount
317 static const tid_t parseError_iface_tids[] = {
318 IXMLDOMParseError2_tid,
322 static dispex_static_data_t parseError_dispex = {
323 NULL,
324 IXMLDOMParseError2_tid,
325 NULL,
326 parseError_iface_tids
329 IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
330 LONG line, LONG linepos, LONG filepos )
332 parse_error_t *This;
334 This = heap_alloc( sizeof(*This) );
335 if ( !This )
336 return NULL;
338 This->IXMLDOMParseError2_iface.lpVtbl = &XMLDOMParseError2Vtbl;
339 This->ref = 1;
341 This->code = code;
342 This->url = url;
343 This->reason = reason;
344 This->srcText = srcText;
345 This->line = line;
346 This->linepos = linepos;
347 This->filepos = filepos;
349 init_dispex(&This->dispex, (IUnknown*)&This->IXMLDOMParseError2_iface, &parseError_dispex);
351 return (IXMLDOMParseError*)&This->IXMLDOMParseError2_iface;