ReactOS 0.4.15-dev-7942-gd23573b
parseerror.c
Go to the documentation of this file.
1/*
2 * ParseError implementation
3 *
4 * Copyright 2005 Huw Davies
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
21
22#define COBJMACROS
23
24#include "config.h"
25
26#include <stdarg.h>
27#ifdef HAVE_LIBXML2
28# include <libxml/parser.h>
29# include <libxml/xmlerror.h>
30#endif
31
32#include "windef.h"
33#include "winbase.h"
34#include "winerror.h"
35#include "winuser.h"
36#include "ole2.h"
37#include "msxml6.h"
38
39#include "msxml_private.h"
40
41#include "wine/debug.h"
42
44
45typedef struct
46{
48 IXMLDOMParseError2 IXMLDOMParseError2_iface;
50 LONG code, line, linepos, filepos;
51 BSTR url, reason, srcText;
53
54static inline parse_error_t *impl_from_IXMLDOMParseError2( IXMLDOMParseError2 *iface )
55{
56 return CONTAINING_RECORD(iface, parse_error_t, IXMLDOMParseError2_iface);
57}
58
60 IXMLDOMParseError2 *iface,
62 void** ppvObject )
63{
65
66 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppvObject);
67
68 if ( IsEqualGUID( riid, &IID_IUnknown ) ||
70 IsEqualGUID( riid, &IID_IXMLDOMParseError ) ||
71 IsEqualGUID( riid, &IID_IXMLDOMParseError2 ) )
72 {
73 *ppvObject = iface;
74 }
75 else if (dispex_query_interface(&This->dispex, riid, ppvObject))
76 {
77 return *ppvObject ? S_OK : E_NOINTERFACE;
78 }
79 else
80 {
81 FIXME("interface %s not implemented\n", debugstr_guid(riid));
82 *ppvObject = NULL;
83 return E_NOINTERFACE;
84 }
85
86 IXMLDOMParseError2_AddRef( iface );
87
88 return S_OK;
89}
90
92 IXMLDOMParseError2 *iface )
93{
96 TRACE("(%p)->(%d)\n", This, ref);
97 return ref;
98}
99
101 IXMLDOMParseError2 *iface )
102{
105
106 TRACE("(%p)->(%d)\n", This, ref);
107 if ( ref == 0 )
108 {
109 SysFreeString(This->url);
110 SysFreeString(This->reason);
111 SysFreeString(This->srcText);
112 heap_free( This );
113 }
114
115 return ref;
116}
117
119 IXMLDOMParseError2 *iface,
120 UINT* pctinfo )
121{
123 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
124}
125
127 IXMLDOMParseError2 *iface,
128 UINT iTInfo,
129 LCID lcid,
130 ITypeInfo** ppTInfo )
131{
133 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface,
134 iTInfo, lcid, ppTInfo);
135}
136
138 IXMLDOMParseError2 *iface,
139 REFIID riid,
140 LPOLESTR* rgszNames,
141 UINT cNames,
142 LCID lcid,
143 DISPID* rgDispId )
144{
146 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface,
147 riid, rgszNames, cNames, lcid, rgDispId);
148}
149
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 )
160{
162 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface,
163 dispIdMember, riid, lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
164}
165
167 IXMLDOMParseError2 *iface,
168 LONG *code )
169{
171 TRACE("(%p)->(%p)\n", This, code);
172
173 *code = This->code;
174
175 if(This->code == 0)
176 return S_FALSE;
177
178 return S_OK;
179}
180
182 IXMLDOMParseError2 *iface,
183 BSTR *url )
184{
186 FIXME("(%p)->(%p)\n", This, url);
187 return E_NOTIMPL;
188}
189
191 IXMLDOMParseError2 *iface,
192 BSTR *reason )
193{
195 TRACE("(%p)->(%p)\n", This, reason);
196
197 if(!This->reason)
198 {
199 *reason = NULL;
200 return S_FALSE;
201 }
202 *reason = SysAllocString(This->reason);
203 return S_OK;
204}
205
207 IXMLDOMParseError2 *iface,
208 BSTR *srcText )
209{
211
212 TRACE("(%p)->(%p)\n", This, srcText);
213
214 if (!srcText) return E_INVALIDARG;
215
216 *srcText = SysAllocString(This->srcText);
217
218 return S_OK;
219}
220
222 IXMLDOMParseError2 *iface,
223 LONG *line )
224{
226
227 TRACE("(%p)->(%p): stub\n", This, line);
228
229 if (!line) return E_INVALIDARG;
230
231 *line = This->line;
232 return S_OK;
233}
234
236 IXMLDOMParseError2 *iface,
237 LONG *linepos )
238{
240
241 TRACE("(%p)->(%p)\n", This, linepos);
242
243 if (!linepos) return E_INVALIDARG;
244
245 *linepos = This->linepos;
246 return S_OK;
247}
248
250 IXMLDOMParseError2 *iface,
251 LONG *filepos )
252{
254 FIXME("(%p)->(%p)\n", This, filepos);
255 return E_NOTIMPL;
256}
257
259 IXMLDOMParseError2 *iface,
260 BSTR *xpathexpr)
261{
263 FIXME("(%p)->(%p)\n", This, xpathexpr);
264 return E_NOTIMPL;
265}
266
268 IXMLDOMParseError2 *iface,
269 IXMLDOMParseErrorCollection **allErrors)
270{
272 FIXME("(%p)->(%p)\n", This, allErrors);
273 return E_NOTIMPL;
274}
275
277 IXMLDOMParseError2 *iface,
278 LONG index,
279 BSTR *param)
280{
282 FIXME("(%p)->(%p)\n", This, param);
283 return E_NOTIMPL;
284}
285
287 IXMLDOMParseError2 *iface,
288 LONG *count)
289{
291 FIXME("(%p)->(%p)\n", This, count);
292 return E_NOTIMPL;
293}
294
295static const struct IXMLDOMParseError2Vtbl XMLDOMParseError2Vtbl =
296{
315};
316
317static const tid_t parseError_iface_tids[] = {
319 0
320};
321
323 NULL,
325 NULL,
327};
328
330 LONG line, LONG linepos, LONG filepos )
331{
333
334 This = heap_alloc( sizeof(*This) );
335 if ( !This )
336 return NULL;
337
338 This->IXMLDOMParseError2_iface.lpVtbl = &XMLDOMParseError2Vtbl;
339 This->ref = 1;
340
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;
348
349 init_dispex(&This->dispex, (IUnknown*)&This->IXMLDOMParseError2_iface, &parseError_dispex);
350
351 return (IXMLDOMParseError*)&This->IXMLDOMParseError2_iface;
352}
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define InterlockedIncrement
Definition: armddk.h:53
#define InterlockedDecrement
Definition: armddk.h:52
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
const GUID IID_IUnknown
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_INVALIDARG
Definition: ddrawi.h:101
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112
static WCHAR reason[MAX_STRING_RESOURCE_LEN]
Definition: object.c:1904
OLECHAR * BSTR
Definition: compat.h:2293
unsigned short WORD
Definition: ntddk_ex.h:93
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint index
Definition: glext.h:6031
GLfloat param
Definition: glext.h:5796
tid_t
Definition: ieframe.h:311
REFIID riid
Definition: atlbase.h:39
#define S_OK
Definition: intsafe.h:52
HRESULT init_dispex(jsdisp_t *dispex, script_ctx_t *ctx, const builtin_info_t *builtin_info, jsdisp_t *prototype)
Definition: dispex.c:919
#define debugstr_guid
Definition: kernel32.h:35
static const WCHAR url[]
Definition: encode.c:1432
static LPOLESTR
Definition: stg_prop.c:27
static VARIANTARG static DISPID
Definition: ordinal.c:52
BOOL dispex_query_interface(DispatchEx *This, REFIID riid, void **ppv)
Definition: dispex.c:1656
@ IXMLDOMParseError2_tid
Definition: msxml_private.h:60
unsigned int UINT
Definition: ndis.h:50
BSTR WINAPI SysAllocString(LPCOLESTR str)
Definition: oleaut.c:238
void WINAPI DECLSPEC_HOTPATCH SysFreeString(BSTR str)
Definition: oleaut.c:271
const GUID IID_IDispatch
static dispex_static_data_t parseError_dispex
Definition: parseerror.c:322
static HRESULT WINAPI parseError_errorParameters(IXMLDOMParseError2 *iface, LONG index, BSTR *param)
Definition: parseerror.c:276
static HRESULT WINAPI parseError_get_errorCode(IXMLDOMParseError2 *iface, LONG *code)
Definition: parseerror.c:166
static HRESULT WINAPI parseError_get_errorXPath(IXMLDOMParseError2 *iface, BSTR *xpathexpr)
Definition: parseerror.c:258
static HRESULT WINAPI parseError_get_linepos(IXMLDOMParseError2 *iface, LONG *linepos)
Definition: parseerror.c:235
static parse_error_t * impl_from_IXMLDOMParseError2(IXMLDOMParseError2 *iface)
Definition: parseerror.c:54
static HRESULT WINAPI parseError_get_reason(IXMLDOMParseError2 *iface, BSTR *reason)
Definition: parseerror.c:190
static HRESULT WINAPI parseError_get_errorParametersCount(IXMLDOMParseError2 *iface, LONG *count)
Definition: parseerror.c:286
static ULONG WINAPI parseError_Release(IXMLDOMParseError2 *iface)
Definition: parseerror.c:100
static HRESULT WINAPI parseError_GetIDsOfNames(IXMLDOMParseError2 *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
Definition: parseerror.c:137
IXMLDOMParseError * create_parseError(LONG code, BSTR url, BSTR reason, BSTR srcText, LONG line, LONG linepos, LONG filepos)
Definition: parseerror.c:329
static HRESULT WINAPI parseError_Invoke(IXMLDOMParseError2 *iface, DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
Definition: parseerror.c:150
static HRESULT WINAPI parseError_GetTypeInfoCount(IXMLDOMParseError2 *iface, UINT *pctinfo)
Definition: parseerror.c:118
static HRESULT WINAPI parseError_get_filepos(IXMLDOMParseError2 *iface, LONG *filepos)
Definition: parseerror.c:249
static HRESULT WINAPI parseError_get_srcText(IXMLDOMParseError2 *iface, BSTR *srcText)
Definition: parseerror.c:206
static HRESULT WINAPI parseError_GetTypeInfo(IXMLDOMParseError2 *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
Definition: parseerror.c:126
static HRESULT WINAPI parseError_get_url(IXMLDOMParseError2 *iface, BSTR *url)
Definition: parseerror.c:181
static HRESULT WINAPI parseError_QueryInterface(IXMLDOMParseError2 *iface, REFIID riid, void **ppvObject)
Definition: parseerror.c:59
static ULONG WINAPI parseError_AddRef(IXMLDOMParseError2 *iface)
Definition: parseerror.c:91
static HRESULT WINAPI parseError_get_AllErrors(IXMLDOMParseError2 *iface, IXMLDOMParseErrorCollection **allErrors)
Definition: parseerror.c:267
static HRESULT WINAPI parseError_get_line(IXMLDOMParseError2 *iface, LONG *line)
Definition: parseerror.c:221
static const struct IXMLDOMParseError2Vtbl XMLDOMParseError2Vtbl
Definition: parseerror.c:295
static const tid_t parseError_iface_tids[]
Definition: parseerror.c:317
long LONG
Definition: pedump.c:60
#define IsEqualGUID(rguid1, rguid2)
Definition: guiddef.h:147
#define REFIID
Definition: guiddef.h:118
DWORD LCID
Definition: nls.h:13
#define TRACE(s)
Definition: solgame.cpp:4
Definition: inflate.c:139
Definition: parser.c:49
DispatchEx dispex
Definition: parseerror.c:47
IXMLDOMParseError2 IXMLDOMParseError2_iface
Definition: parseerror.c:48
Definition: send.c:48
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
_In_ DWORD _Out_ _In_ WORD wFlags
Definition: wincon.h:531
_In_ void _In_ PCCERT_CONTEXT _In_opt_ LPFILETIME _In_ DWORD _In_ DWORD _Outptr_opt_ void ** ppvObject
Definition: wincrypt.h:6082
#define WINAPI
Definition: msvc.h:6
#define S_FALSE
Definition: winerror.h:2357
#define E_NOINTERFACE
Definition: winerror.h:2364