ntdll: Implement RtlIsEcCode().
[wine.git] / dlls / msado15 / command.c
blob152528308e0dd7ff3e6c3f678306624e785e5395
1 /*
2 * Copyright 2019 Alistair Leslie-Hughes
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
18 #include <stdarg.h>
19 #include "windef.h"
20 #include "winbase.h"
21 #define COBJMACROS
22 #include "objbase.h"
23 #include "msdasc.h"
24 #include "msado15_backcompat.h"
26 #include "wine/debug.h"
28 #include "msado15_private.h"
30 WINE_DEFAULT_DEBUG_CHANNEL(msado15);
32 struct command
34 _Command Command_iface;
35 LONG ref;
36 CommandTypeEnum type;
37 BSTR text;
38 _Connection *connection;
41 static inline struct command *impl_from_Command( _Command *iface )
43 return CONTAINING_RECORD( iface, struct command, Command_iface );
46 static HRESULT WINAPI command_QueryInterface( _Command *iface, REFIID riid, void **obj )
48 TRACE( "%p, %s, %p\n", iface, debugstr_guid(riid), obj );
50 *obj = NULL;
52 if (IsEqualIID(riid, &IID_IUnknown) ||
53 IsEqualIID(riid, &IID_IDispatch) ||
54 IsEqualIID(riid, &IID__ADO) ||
55 IsEqualIID(riid, &IID_Command15) ||
56 IsEqualIID(riid, &IID_Command25) ||
57 IsEqualIID(riid, &IID__Command))
59 *obj = iface;
61 else
63 FIXME( "interface %s not implemented\n", debugstr_guid(riid) );
64 return E_NOINTERFACE;
67 _Command_AddRef( iface );
68 return S_OK;
71 static ULONG WINAPI command_AddRef( _Command *iface )
73 struct command *command = impl_from_Command( iface );
74 return InterlockedIncrement( &command->ref );
77 static ULONG WINAPI command_Release( _Command *iface )
79 struct command *command = impl_from_Command( iface );
80 LONG ref = InterlockedDecrement( &command->ref );
81 if (!ref)
83 TRACE( "destroying %p\n", command );
84 if (command->connection) _Connection_Release(command->connection);
85 free( command->text );
86 free( command );
88 return ref;
91 static HRESULT WINAPI command_GetTypeInfoCount( _Command *iface, UINT *count )
93 struct command *command = impl_from_Command( iface );
94 TRACE( "%p, %p\n", command, count );
95 *count = 1;
96 return S_OK;
99 static HRESULT WINAPI command_GetTypeInfo( _Command *iface, UINT index, LCID lcid, ITypeInfo **info )
101 struct command *command = impl_from_Command( iface );
102 TRACE( "%p, %u, %lu, %p\n", command, index, lcid, info );
103 return get_typeinfo(Command_tid, info);
106 static HRESULT WINAPI command_GetIDsOfNames( _Command *iface, REFIID riid, LPOLESTR *names, UINT count,
107 LCID lcid, DISPID *dispid )
109 struct command *command = impl_from_Command( iface );
110 HRESULT hr;
111 ITypeInfo *typeinfo;
113 TRACE( "%p, %s, %p, %u, %lu, %p\n", command, debugstr_guid(riid), names, count, lcid, dispid );
115 hr = get_typeinfo(Command_tid, &typeinfo);
116 if(SUCCEEDED(hr))
118 hr = ITypeInfo_GetIDsOfNames(typeinfo, names, count, dispid);
119 ITypeInfo_Release(typeinfo);
122 return hr;
125 static HRESULT WINAPI command_Invoke( _Command *iface, DISPID member, REFIID riid, LCID lcid, WORD flags,
126 DISPPARAMS *params, VARIANT *result, EXCEPINFO *excep_info, UINT *arg_err )
128 struct command *command = impl_from_Command( iface );
129 HRESULT hr;
130 ITypeInfo *typeinfo;
132 TRACE( "%p, %ld, %s, %ld, %d, %p, %p, %p, %p\n", command, member, debugstr_guid(riid), lcid, flags, params,
133 result, excep_info, arg_err );
135 hr = get_typeinfo(Command_tid, &typeinfo);
136 if(SUCCEEDED(hr))
138 hr = ITypeInfo_Invoke(typeinfo, &command->Command_iface, member, flags, params,
139 result, excep_info, arg_err);
140 ITypeInfo_Release(typeinfo);
143 return hr;
146 static HRESULT WINAPI command_get_Properties( _Command *iface, Properties **props )
148 FIXME( "%p, %p\n", iface, props );
149 return E_NOTIMPL;
152 static HRESULT WINAPI command_get_ActiveConnection( _Command *iface, _Connection **connection )
154 struct command *command = impl_from_Command( iface );
155 TRACE( "%p, %p\n", iface, connection );
157 *connection = command->connection;
158 if (command->connection) _Connection_AddRef(command->connection);
159 return S_OK;
162 static HRESULT WINAPI command_putref_ActiveConnection( _Command *iface, _Connection *connection )
164 struct command *command = impl_from_Command( iface );
165 TRACE( "%p, %p\n", iface, connection );
167 if (command->connection) _Connection_Release(command->connection);
168 command->connection = connection;
169 if (command->connection) _Connection_AddRef(command->connection);
170 return S_OK;
173 static HRESULT WINAPI command_put_ActiveConnection( _Command *iface, VARIANT connection )
175 FIXME( "%p, %s\n", iface, debugstr_variant(&connection) );
176 return E_NOTIMPL;
179 static HRESULT WINAPI command_get_CommandText( _Command *iface, BSTR *text )
181 struct command *command = impl_from_Command( iface );
182 BSTR cmd_text = NULL;
184 TRACE( "%p, %p\n", command, text );
186 if (command->text && !(cmd_text = SysAllocString( command->text ))) return E_OUTOFMEMORY;
187 *text = cmd_text;
188 return S_OK;
191 static HRESULT WINAPI command_put_CommandText( _Command *iface, BSTR text )
193 struct command *command = impl_from_Command( iface );
194 WCHAR *source = NULL;
196 TRACE( "%p, %s\n", command, debugstr_w( text ) );
198 if (text && !(source = wcsdup( text ))) return E_OUTOFMEMORY;
199 free( command->text );
200 command->text = source;
201 return S_OK;
204 static HRESULT WINAPI command_get_CommandTimeout( _Command *iface, LONG *timeout )
206 FIXME( "%p, %p\n", iface, timeout );
207 return E_NOTIMPL;
210 static HRESULT WINAPI command_put_CommandTimeout( _Command *iface, LONG timeout )
212 FIXME( "%p, %ld\n", iface, timeout );
213 return E_NOTIMPL;
216 static HRESULT WINAPI command_get_Prepared( _Command *iface, VARIANT_BOOL *prepared )
218 FIXME( "%p, %p\n", iface, prepared );
219 return E_NOTIMPL;
222 static HRESULT WINAPI command_put_Prepared( _Command *iface, VARIANT_BOOL prepared )
224 FIXME( "%p, %d\n", iface, prepared );
225 return E_NOTIMPL;
228 static HRESULT WINAPI command_Execute( _Command *iface, VARIANT *affected, VARIANT *parameters,
229 LONG options, _Recordset **recordset )
231 FIXME( "%p, %p, %p, %ld, %p\n", iface, affected, parameters, options, recordset );
232 return E_NOTIMPL;
235 static HRESULT WINAPI command_CreateParameter( _Command *iface, BSTR name, DataTypeEnum type,
236 ParameterDirectionEnum direction, ADO_LONGPTR size, VARIANT value,
237 _Parameter **parameter )
239 FIXME( "%p, %s, %d, %d, %Id, %p\n", iface, debugstr_w(name), type, direction, size, parameter );
240 return E_NOTIMPL;
243 static HRESULT WINAPI command_get_Parameters( _Command *iface, Parameters **parameters )
245 FIXME( "%p, %p\n", iface, parameters );
246 return E_NOTIMPL;
249 static HRESULT WINAPI command_put_CommandType( _Command *iface, CommandTypeEnum type )
251 struct command *command = impl_from_Command( iface );
253 TRACE( "%p, %d\n", iface, type );
255 switch (type)
257 case adCmdUnspecified:
258 case adCmdUnknown:
259 case adCmdText:
260 case adCmdTable:
261 case adCmdStoredProc:
262 case adCmdFile:
263 case adCmdTableDirect:
264 command->type = type;
265 return S_OK;
268 return MAKE_ADO_HRESULT( adErrInvalidArgument );
271 static HRESULT WINAPI command_get_CommandType( _Command *iface, CommandTypeEnum *type )
273 struct command *command = impl_from_Command( iface );
275 TRACE( "%p, %p\n", iface, type );
277 *type = command->type;
278 return S_OK;
281 static HRESULT WINAPI command_get_Name(_Command *iface, BSTR *name)
283 FIXME( "%p, %p\n", iface, name );
284 return E_NOTIMPL;
287 static HRESULT WINAPI command_put_Name( _Command *iface, BSTR name )
289 FIXME( "%p, %s\n", iface, debugstr_w(name) );
290 return E_NOTIMPL;
293 static HRESULT WINAPI command_get_State( _Command *iface, LONG *state )
295 FIXME( "%p, %p\n", iface, state );
296 return E_NOTIMPL;
299 static HRESULT WINAPI command_Cancel( _Command *iface )
301 FIXME( "%p\n", iface );
302 return E_NOTIMPL;
305 static HRESULT WINAPI command_putref_CommandStream( _Command *iface, IUnknown *stream )
307 FIXME( "%p, %p\n", iface, stream );
308 return E_NOTIMPL;
311 static HRESULT WINAPI command_get_CommandStream( _Command *iface, VARIANT *stream )
313 FIXME( "%p, %p\n", iface, stream );
314 return E_NOTIMPL;
317 static HRESULT WINAPI command_put_Dialect( _Command *iface, BSTR dialect )
319 FIXME( "%p, %s\n", iface, debugstr_w(dialect) );
320 return E_NOTIMPL;
323 static HRESULT WINAPI command_get_Dialect( _Command *iface, BSTR *dialect )
325 FIXME( "%p, %p\n", iface, dialect );
326 return E_NOTIMPL;
329 static HRESULT WINAPI command_put_NamedParameters( _Command *iface, VARIANT_BOOL parameters )
331 FIXME( "%p, %d\n", iface, parameters );
332 return E_NOTIMPL;
335 static HRESULT WINAPI command_get_NamedParameters( _Command *iface, VARIANT_BOOL *parameters )
337 FIXME( "%p, %p\n", iface, parameters );
338 return E_NOTIMPL;
341 static const struct _CommandVtbl command_vtbl =
343 command_QueryInterface,
344 command_AddRef,
345 command_Release,
346 command_GetTypeInfoCount,
347 command_GetTypeInfo,
348 command_GetIDsOfNames,
349 command_Invoke,
350 command_get_Properties,
351 command_get_ActiveConnection,
352 command_putref_ActiveConnection,
353 command_put_ActiveConnection,
354 command_get_CommandText,
355 command_put_CommandText,
356 command_get_CommandTimeout,
357 command_put_CommandTimeout,
358 command_get_Prepared,
359 command_put_Prepared,
360 command_Execute,
361 command_CreateParameter,
362 command_get_Parameters,
363 command_put_CommandType,
364 command_get_CommandType,
365 command_get_Name,
366 command_put_Name,
367 command_get_State,
368 command_Cancel,
369 command_putref_CommandStream,
370 command_get_CommandStream,
371 command_put_Dialect,
372 command_get_Dialect,
373 command_put_NamedParameters,
374 command_get_NamedParameters
377 HRESULT Command_create( void **obj )
379 struct command *command;
381 if (!(command = malloc( sizeof(*command) ))) return E_OUTOFMEMORY;
382 command->Command_iface.lpVtbl = &command_vtbl;
383 command->type = adCmdUnknown;
384 command->text = NULL;
385 command->connection = NULL;
386 command->ref = 1;
388 *obj = &command->Command_iface;
389 TRACE( "returning iface %p\n", *obj );
390 return S_OK;