Alistair Leslie-Hughes : msdasql: Implement IDBCreateCommand CreateCommand.

Alexandre Julliard julliard at winehq.org
Fri Oct 29 16:29:08 CDT 2021


Module: wine
Branch: master
Commit: 067c0e91e3a2b60f1e3139a76b4cee521c476aa1
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=067c0e91e3a2b60f1e3139a76b4cee521c476aa1

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Fri Oct 29 17:32:44 2021 +1100

msdasql: Implement IDBCreateCommand CreateCommand.

Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/msdasql/session.c | 123 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 121 insertions(+), 2 deletions(-)

diff --git a/dlls/msdasql/session.c b/dlls/msdasql/session.c
index e01dcf7ab7e..afdbccb5a03 100644
--- a/dlls/msdasql/session.c
+++ b/dlls/msdasql/session.c
@@ -275,13 +275,132 @@ static ULONG WINAPI createcommand_Release(IDBCreateCommand *iface)
     return IUnknown_Release(&session->session_iface);
 }
 
+struct command
+{
+    ICommandText ICommandText_iface;
+    LONG refs;
+};
+
+static inline struct command *impl_from_ICommandText( ICommandText *iface )
+{
+    return CONTAINING_RECORD( iface, struct command, ICommandText_iface );
+}
+
+static HRESULT WINAPI command_QueryInterface(ICommandText *iface, REFIID riid, void **ppv)
+{
+    struct command *command = impl_from_ICommandText( iface );
+
+    TRACE( "%p, %s, %p\n", command, debugstr_guid(riid), ppv );
+    *ppv = NULL;
+
+    if(IsEqualGUID(&IID_IUnknown, riid) ||
+       IsEqualGUID(&IID_ICommand, riid) ||
+       IsEqualGUID(&IID_ICommandText, riid))
+    {
+        *ppv = &command->ICommandText_iface;
+    }
+
+    if(*ppv)
+    {
+        IUnknown_AddRef((IUnknown*)*ppv);
+        return S_OK;
+    }
+
+    FIXME("(%p)->(%s %p)\n", iface, debugstr_guid(riid), ppv);
+    return E_NOINTERFACE;
+}
+
+static ULONG WINAPI command_AddRef(ICommandText *iface)
+{
+    struct command *command = impl_from_ICommandText( iface );
+    LONG refs = InterlockedIncrement( &command->refs );
+    TRACE( "%p new refcount %d\n", command, refs );
+    return refs;
+}
+
+static ULONG WINAPI command_Release(ICommandText *iface)
+{
+    struct command *command = impl_from_ICommandText( iface );
+    LONG refs = InterlockedDecrement( &command->refs );
+    TRACE( "%p new refcount %d\n", command, refs );
+    if (!refs)
+    {
+        TRACE( "destroying %p\n", command );
+        heap_free( command );
+    }
+    return refs;
+}
+
+static HRESULT WINAPI command_Cancel(ICommandText *iface)
+{
+    struct command *command = impl_from_ICommandText( iface );
+    FIXME("%p\n", command);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI command_Execute(ICommandText *iface, IUnknown *outer, REFIID riid,
+        DBPARAMS *params, DBROWCOUNT *affected, IUnknown **rowset)
+{
+    struct command *command = impl_from_ICommandText( iface );
+    FIXME("%p, %p, %s, %p %p %p\n", command, outer, debugstr_guid(riid), params, affected, rowset);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI command_GetDBSession(ICommandText *iface, REFIID riid, IUnknown **session)
+{
+    struct command *command = impl_from_ICommandText( iface );
+    FIXME("%p, %s, %p\n", command, debugstr_guid(riid), session);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI command_GetCommandText(ICommandText *iface, GUID *dialect, LPOLESTR *commandstr)
+{
+    struct command *command = impl_from_ICommandText( iface );
+    FIXME("%p, %p, %p\n", command, dialect, commandstr);
+    return E_NOTIMPL;
+}
+
+static HRESULT WINAPI command_SetCommandText(ICommandText *iface, REFGUID dialect, LPCOLESTR commandstr)
+{
+    struct command *command = impl_from_ICommandText( iface );
+    FIXME("%p, %s, %s\n", command, debugstr_guid(dialect), debugstr_w(commandstr));
+    return S_OK;
+}
+
+static const ICommandTextVtbl commandVtbl =
+{
+    command_QueryInterface,
+    command_AddRef,
+    command_Release,
+    command_Cancel,
+    command_Execute,
+    command_GetDBSession,
+    command_GetCommandText,
+    command_SetCommandText
+};
+
 static HRESULT WINAPI createcommand_CreateCommand(IDBCreateCommand *iface, IUnknown *outer, REFIID riid,
                                             IUnknown **out)
 {
     struct msdasql_session *session = impl_from_IDBCreateCommand( iface );
-    FIXME("%p, %p, %s, %p\n", session, outer, debugstr_guid(riid), out);
+    struct command *command;
+    HRESULT hr;
 
-    return E_NOTIMPL;
+    TRACE("%p, %p, %s, %p\n", session, outer, debugstr_guid(riid), out);
+
+    if (outer)
+        FIXME("Outer not currently supported\n");
+
+    command = heap_alloc(sizeof(*command));
+    if (!command)
+        return E_OUTOFMEMORY;
+
+    command->ICommandText_iface.lpVtbl = &commandVtbl;
+    command->refs = 1;
+
+    hr = ICommandText_QueryInterface(&command->ICommandText_iface, riid, (void**)out);
+    ICommandText_Release(&command->ICommandText_iface);
+    return hr;
 }
 
 static const IDBCreateCommandVtbl createcommandVtbl =




More information about the wine-cvs mailing list