winhttp/tests: Initialize a variant with a known value.
[wine/multimedia.git] / dlls / msxml3 / parseerror.c
blob3f5c59f45ee6b0b6ceefd9d77df38f1ffc7161b9
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 IXMLDOMParseError IXMLDOMParseError_iface;
48 LONG ref;
49 LONG code, line, linepos, filepos;
50 BSTR url, reason, srcText;
51 } parse_error_t;
53 static inline parse_error_t *impl_from_IXMLDOMParseError( IXMLDOMParseError *iface )
55 return CONTAINING_RECORD(iface, parse_error_t, IXMLDOMParseError_iface);
58 static HRESULT WINAPI parseError_QueryInterface(
59 IXMLDOMParseError *iface,
60 REFIID riid,
61 void** ppvObject )
63 TRACE("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppvObject);
65 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
66 IsEqualGUID( riid, &IID_IDispatch ) ||
67 IsEqualGUID( riid, &IID_IXMLDOMParseError ) )
69 *ppvObject = iface;
71 else
73 FIXME("interface %s not implemented\n", debugstr_guid(riid));
74 *ppvObject = NULL;
75 return E_NOINTERFACE;
78 IXMLDOMParseError_AddRef( iface );
80 return S_OK;
83 static ULONG WINAPI parseError_AddRef(
84 IXMLDOMParseError *iface )
86 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
87 ULONG ref = InterlockedIncrement( &This->ref );
88 TRACE("(%p) ref now %d\n", This, ref);
89 return ref;
92 static ULONG WINAPI parseError_Release(
93 IXMLDOMParseError *iface )
95 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
96 ULONG ref;
98 ref = InterlockedDecrement( &This->ref );
99 TRACE("(%p) ref now %d\n", This, ref);
100 if ( ref == 0 )
102 SysFreeString(This->url);
103 SysFreeString(This->reason);
104 SysFreeString(This->srcText);
105 heap_free( This );
108 return ref;
111 static HRESULT WINAPI parseError_GetTypeInfoCount(
112 IXMLDOMParseError *iface,
113 UINT* pctinfo )
115 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
117 TRACE("(%p)->(%p)\n", This, pctinfo);
119 *pctinfo = 1;
121 return S_OK;
124 static HRESULT WINAPI parseError_GetTypeInfo(
125 IXMLDOMParseError *iface,
126 UINT iTInfo,
127 LCID lcid,
128 ITypeInfo** ppTInfo )
130 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
131 HRESULT hr;
133 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
135 hr = get_typeinfo(IXMLDOMParseError_tid, ppTInfo);
137 return hr;
140 static HRESULT WINAPI parseError_GetIDsOfNames(
141 IXMLDOMParseError *iface,
142 REFIID riid,
143 LPOLESTR* rgszNames,
144 UINT cNames,
145 LCID lcid,
146 DISPID* rgDispId )
148 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
149 ITypeInfo *typeinfo;
150 HRESULT hr;
152 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
153 lcid, rgDispId);
155 if(!rgszNames || cNames == 0 || !rgDispId)
156 return E_INVALIDARG;
158 hr = get_typeinfo(IXMLDOMParseError_tid, &typeinfo);
159 if(SUCCEEDED(hr))
161 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
162 ITypeInfo_Release(typeinfo);
165 return hr;
168 static HRESULT WINAPI parseError_Invoke(
169 IXMLDOMParseError *iface,
170 DISPID dispIdMember,
171 REFIID riid,
172 LCID lcid,
173 WORD wFlags,
174 DISPPARAMS* pDispParams,
175 VARIANT* pVarResult,
176 EXCEPINFO* pExcepInfo,
177 UINT* puArgErr )
179 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
180 ITypeInfo *typeinfo;
181 HRESULT hr;
183 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
184 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
186 hr = get_typeinfo(IXMLDOMParseError_tid, &typeinfo);
187 if(SUCCEEDED(hr))
189 hr = ITypeInfo_Invoke(typeinfo, &This->IXMLDOMParseError_iface, dispIdMember, wFlags,
190 pDispParams, pVarResult, pExcepInfo, puArgErr);
191 ITypeInfo_Release(typeinfo);
194 return hr;
197 static HRESULT WINAPI parseError_get_errorCode(
198 IXMLDOMParseError *iface,
199 LONG *code )
201 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
202 TRACE("(%p)->(%p)\n", This, code);
204 *code = This->code;
206 if(This->code == 0)
207 return S_FALSE;
209 return S_OK;
212 static HRESULT WINAPI parseError_get_url(
213 IXMLDOMParseError *iface,
214 BSTR *url )
216 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
217 FIXME("(%p)->(%p)\n", This, url);
218 return E_NOTIMPL;
221 static HRESULT WINAPI parseError_get_reason(
222 IXMLDOMParseError *iface,
223 BSTR *reason )
225 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
226 TRACE("(%p)->(%p)\n", This, reason);
228 if(!This->reason)
230 *reason = NULL;
231 return S_FALSE;
233 *reason = SysAllocString(This->reason);
234 return S_OK;
237 static HRESULT WINAPI parseError_get_srcText(
238 IXMLDOMParseError *iface,
239 BSTR *srcText )
241 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
242 FIXME("(%p)->(%p)\n", This, srcText);
243 return E_NOTIMPL;
246 static HRESULT WINAPI parseError_get_line(
247 IXMLDOMParseError *iface,
248 LONG *line )
250 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
251 FIXME("(%p)->(%p)\n", This, line);
252 return E_NOTIMPL;
255 static HRESULT WINAPI parseError_get_linepos(
256 IXMLDOMParseError *iface,
257 LONG *linepos )
259 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
260 FIXME("(%p)->(%p)\n", This, linepos);
261 return E_NOTIMPL;
264 static HRESULT WINAPI parseError_get_filepos(
265 IXMLDOMParseError *iface,
266 LONG *filepos )
268 parse_error_t *This = impl_from_IXMLDOMParseError( iface );
269 FIXME("(%p)->(%p)\n", This, filepos);
270 return E_NOTIMPL;
273 static const struct IXMLDOMParseErrorVtbl parseError_vtbl =
275 parseError_QueryInterface,
276 parseError_AddRef,
277 parseError_Release,
278 parseError_GetTypeInfoCount,
279 parseError_GetTypeInfo,
280 parseError_GetIDsOfNames,
281 parseError_Invoke,
282 parseError_get_errorCode,
283 parseError_get_url,
284 parseError_get_reason,
285 parseError_get_srcText,
286 parseError_get_line,
287 parseError_get_linepos,
288 parseError_get_filepos
291 IXMLDOMParseError *create_parseError( LONG code, BSTR url, BSTR reason, BSTR srcText,
292 LONG line, LONG linepos, LONG filepos )
294 parse_error_t *This;
296 This = heap_alloc( sizeof(*This) );
297 if ( !This )
298 return NULL;
300 This->IXMLDOMParseError_iface.lpVtbl = &parseError_vtbl;
301 This->ref = 1;
303 This->code = code;
304 This->url = url;
305 This->reason = reason;
306 This->srcText = srcText;
307 This->line = line;
308 This->linepos = linepos;
309 This->filepos = filepos;
311 return &This->IXMLDOMParseError_iface;