From 0f67768bd11cc1c58d9ad84640260e2ea66ea8ff Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Fri, 3 Feb 2023 14:40:03 +1100 Subject: [PATCH] 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 89b8663d888..8cc89f2c7ba 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.43.0