Files
wine-staging/patches/odbc32-fixes/0009-odbc32-SQLDriverConnectW-fallback-to-SQLDriverConnec.patch
Alistair Leslie-Hughes 3714d05e91 Updated odbc32-fixes patchset
2025-09-08 09:54:01 +10:00

65 lines
2.4 KiB
Diff

From e6c3fae4360c375015e75165fc9a3c16af79ec4a Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Sat, 26 Apr 2025 12:33:23 +1000
Subject: [PATCH] odbc32: SQLDriverConnectW fallback to SQLDriverConnect when
required.
---
dlls/odbc32/proxyodbc.c | 37 +++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/dlls/odbc32/proxyodbc.c b/dlls/odbc32/proxyodbc.c
index 0893537aef9..6685b4306f5 100644
--- a/dlls/odbc32/proxyodbc.c
+++ b/dlls/odbc32/proxyodbc.c
@@ -6937,11 +6937,44 @@ static SQLRETURN driver_connect_win32_w( struct connection *con, SQLHWND window,
SQLSMALLINT len, SQLWCHAR *out_conn_str, SQLSMALLINT buflen, SQLSMALLINT *len2,
SQLUSMALLINT completion )
{
+ SQLRETURN ret = SQL_ERROR;
+
if (con->hdr.win32_funcs->SQLDriverConnectW)
return con->hdr.win32_funcs->SQLDriverConnectW( con->hdr.win32_handle, window, in_conn_str, len, out_conn_str,
buflen, len2, completion );
- if (con->hdr.win32_funcs->SQLDriverConnect) FIXME( "Unicode to ANSI conversion not handled\n" );
- return SQL_ERROR;
+ if (con->hdr.win32_funcs->SQLDriverConnect)
+ {
+ SQLCHAR *in = NULL, *out = NULL;
+ SQLSMALLINT in_len = 0, out_len = 0;
+
+ in_len = WideCharToMultiByte(CP_ACP, 0, in_conn_str, len, NULL, 0, NULL, NULL);
+ if (!(in = malloc(in_len + 1))) return SQL_ERROR;
+
+ WideCharToMultiByte(CP_ACP, 0, in_conn_str, len, (char *)in, in_len, NULL, NULL);
+ in[in_len] = 0;
+
+ if (out_conn_str && buflen > 0)
+ {
+ if (!(out = malloc(buflen)))
+ {
+ free(in);
+ return SQL_ERROR;
+ }
+ }
+
+ ret = con->hdr.win32_funcs->SQLDriverConnect( con->hdr.win32_handle, window, in, in_len, out, buflen, &out_len, completion );
+
+ if (SQL_SUCCEEDED(ret) && out_conn_str && out)
+ {
+ MultiByteToWideChar(CP_ACP, 0, (char *)out, out_len, out_conn_str, buflen);
+ if (len2) *len2 = out_len;
+ }
+
+ free(in);
+ free(out);
+ }
+
+ return ret;
}
static SQLRETURN driver_connect_unix_w( struct connection *con, SQLHWND window, SQLWCHAR *in_conn_str, SQLSMALLINT len,
--
2.50.1