wine-staging/patches/odbc-remove-unixodbc/0005-odbc32-Implement-SQLAllocConnect.patch
2023-02-17 13:38:41 +11:00

82 lines
2.2 KiB
Diff

From 8d5b34c895f776ed4944fa5aeed0df3ddc847015 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Fri, 3 Feb 2023 14:40:03 +1100
Subject: [PATCH 05/42] odbc32: Implement SQLAllocConnect
---
dlls/odbc32/proxyodbc.c | 41 +++++++++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 6 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 1330c4c33fe..b3680b7759d 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -49,17 +49,35 @@ struct SQLHENV_data
SQLUINTEGER pooling;
};
+struct SQLHDBC_data
+{
+ int type;
+ struct SQLHENV_data *environment;
+};
/*************************************************************************
* SQLAllocConnect [ODBC32.001]
*/
SQLRETURN WINAPI SQLAllocConnect(SQLHENV EnvironmentHandle, SQLHDBC *ConnectionHandle)
{
- SQLRETURN ret = SQL_ERROR;
+ struct SQLHDBC_data *hdbc;
+
+ TRACE("(EnvironmentHandle %p, ConnectionHandle %p)\n", EnvironmentHandle, ConnectionHandle);
- FIXME("(EnvironmentHandle %p, ConnectionHandle %p)\n", EnvironmentHandle, ConnectionHandle);
+ if(!ConnectionHandle)
+ return SQL_ERROR;
*ConnectionHandle = SQL_NULL_HDBC;
- return ret;
+
+ hdbc = calloc(1, sizeof(*hdbc));
+ if (!hdbc)
+ return SQL_ERROR;
+
+ hdbc->type = SQL_HANDLE_DBC;
+ hdbc->environment = EnvironmentHandle;
+
+ *ConnectionHandle = hdbc;
+
+ return SQL_SUCCESS;
}
/*************************************************************************
@@ -404,11 +422,22 @@ SQLRETURN WINAPI SQLFetchScroll(SQLHSTMT StatementHandle, SQLSMALLINT FetchOrien
*/
SQLRETURN WINAPI SQLFreeConnect(SQLHDBC ConnectionHandle)
{
- SQLRETURN ret = SQL_ERROR;
+ struct SQLHDBC_data *hdbc = ConnectionHandle;
- FIXME("(ConnectionHandle %p)\n", ConnectionHandle);
+ TRACE("(ConnectionHandle %p)\n", ConnectionHandle);
- return ret;
+ if (!hdbc)
+ return SQL_ERROR;
+
+ if (hdbc->type != SQL_HANDLE_DBC)
+ {
+ WARN("Wrong handle type %d\n", hdbc->type);
+ return SQL_ERROR;
+ }
+
+ free(hdbc);
+
+ return SQL_SUCCESS;
}
/*************************************************************************
--
2.39.1