[PATCH 2/2] odbccp32: Handle ODBC_CONFIG_DRIVER request in SQLConfigDriver/W
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Sun Apr 9 23:00:26 CDT 2017
When SQLInstallerErrorW returns SQL_NO_DATA, the error code isn't
updated when the previous call successed.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
---
dlls/odbccp32/odbccp32.c | 49 ++++++++++++++++++++++++++++++++++++++++++++++
dlls/odbccp32/tests/misc.c | 26 +++++++++++++++++++++---
2 files changed, 72 insertions(+), 3 deletions(-)
diff --git a/dlls/odbccp32/odbccp32.c b/dlls/odbccp32/odbccp32.c
index f28d464..2f415c7 100644
--- a/dlls/odbccp32/odbccp32.c
+++ b/dlls/odbccp32/odbccp32.c
@@ -303,6 +303,41 @@ static HMODULE load_config_driver(const WCHAR *driver)
return hmod;
}
+static BOOL write_timeout_value(const WCHAR *driver, const WCHAR *args)
+{
+ static WCHAR cptimeout[] = {'C','P','T','i','m','e','o','u','t',0};
+ long ret;
+ HKEY hkey;
+ WCHAR *position;
+
+ if ( !(position = strstrW(args, cptimeout)))
+ return FALSE;
+
+ if ((ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, odbcini, &hkey)) == ERROR_SUCCESS)
+ {
+ HKEY hkeydriver;
+
+ if ((ret = RegOpenKeyW(hkey, driver, &hkeydriver)) == ERROR_SUCCESS)
+ {
+ const WCHAR *value = &args[sizeof(cptimeout) / sizeof(WCHAR)];
+
+ TRACE("CPTimeout value %s\n", debugstr_w(value));
+ if(RegSetValueExW(hkeydriver, cptimeout, 0, REG_SZ, (BYTE*)value,
+ strlenW(value) * sizeof(WCHAR)) != ERROR_SUCCESS)
+ ERR("Failed to write registry installed key\n");
+
+ RegCloseKey(hkeydriver);
+ }
+
+ RegCloseKey(hkey);
+ }
+
+ if(ret != ERROR_SUCCESS)
+ push_error(ODBC_ERROR_COMPONENT_NOT_FOUND, odbc_error_component_not_found);
+
+ return ret == ERROR_SUCCESS;
+}
+
BOOL WINAPI SQLConfigDriverW(HWND hwnd, WORD request, LPCWSTR driver,
LPCWSTR args, LPWSTR msg, WORD msgmax, WORD *msgout)
{
@@ -314,6 +349,11 @@ BOOL WINAPI SQLConfigDriverW(HWND hwnd, WORD request, LPCWSTR driver,
TRACE("(%p %d %s %s %p %d %p)\n", hwnd, request, debugstr_w(driver),
debugstr_w(args), msg, msgmax, msgout);
+ if(request == ODBC_CONFIG_DRIVER)
+ {
+ return write_timeout_value(driver, args);;
+ }
+
hmod = load_config_driver(driver);
if(!hmod)
return FALSE;
@@ -343,6 +383,15 @@ BOOL WINAPI SQLConfigDriver(HWND hwnd, WORD request, LPCSTR driver,
debugstr_a(args), msg, msgmax, msgout);
driverW = heap_strdupAtoW(driver);
+ if(request == ODBC_CONFIG_DRIVER)
+ {
+ WCHAR *argsW = heap_strdupAtoW(args);
+ BOOL ret = write_timeout_value(driverW, argsW);
+ HeapFree(GetProcessHeap(), 0, driverW);
+ HeapFree(GetProcessHeap(), 0, argsW);
+ return ret;
+ }
+
hmod = load_config_driver(driverW);
HeapFree(GetProcessHeap(), 0, driverW);
if(!hmod)
diff --git a/dlls/odbccp32/tests/misc.c b/dlls/odbccp32/tests/misc.c
index ed8e6f1..7c027b3 100644
--- a/dlls/odbccp32/tests/misc.c
+++ b/dlls/odbccp32/tests/misc.c
@@ -421,22 +421,36 @@ static void test_SQLInstallDriverEx(void)
DWORD cnt, error_code = 0;
HKEY hkey;
LONG res;
+ char error[1000];
GetSystemDirectoryA(syspath, MAX_PATH);
- SQLInstallDriverEx("WINE ODBC Driver\0Driver=sample.dll\0Setup=sample.dll\0\0", NULL, path, MAX_PATH, &size, ODBC_INSTALL_COMPLETE, NULL);
+ ret = SQLConfigDriver(NULL, ODBC_CONFIG_DRIVER, "WINE ODBC Driver", "CPTimeout=59", error, sizeof(error), NULL);
+ ok(!ret, "SQLConfigDriver returned %d\n", ret);
+ sql_ret = SQLConfigDriver(1, &error_code, NULL, 0, NULL);
+ ok(sql_ret && error_code == ODBC_ERROR_COMPONENT_NOT_FOUND, "SQLConfigDriver returned %d, %u\n", sql_ret, error_code);
+
+ ret = SQLInstallDriverEx("WINE ODBC Driver\0Driver=sample.dll\0Setup=sample.dll\0\0", NULL,
+ path, MAX_PATH, &size, ODBC_INSTALL_COMPLETE, NULL);
+ ok(ret, "SQLInstallDriverEx failed\n");
sql_ret = SQLInstallerErrorW(1, &error_code, NULL, 0, NULL);
if (sql_ret && error_code == ODBC_ERROR_WRITING_SYSINFO_FAILED)
{
win_skip("not enough privileges\n");
return;
}
- ok(sql_ret && error_code == SQL_SUCCESS, "SQLInstallDriverEx failed %d, %u\n", sql_ret, error_code);
+ ok(sql_ret == SQL_NO_DATA || (sql_ret && error_code == SQL_SUCCESS), "SQLInstallDriverEx failed %d, %u\n", sql_ret, error_code);
ok(!strcmp(path, syspath), "invalid path %s\n", path);
+ ret = SQLConfigDriver(NULL, ODBC_CONFIG_DRIVER, "WINE ODBC Driver", "CPTimeout=59", error, sizeof(error), NULL);
+ ok(ret, "SQLConfigDriver failed\n");
+ sql_ret = SQLInstallerErrorW(1, &error_code, NULL, 0, NULL);
+ ok(sql_ret == SQL_NO_DATA || (sql_ret && error_code == SQL_SUCCESS), "SQLConfigDriver failed %d, %u\n", sql_ret, error_code);
+
ret = SQLInstallDriverEx("WINE ODBC Driver Path\0Driver=sample.dll\0Setup=sample.dll\0\0", "c:\\temp", path, MAX_PATH, &size, ODBC_INSTALL_COMPLETE, NULL);
+ ok(ret, "SQLInstallDriverEx failed\n");
sql_ret = SQLInstallerErrorW(1, &error_code, NULL, 0, NULL);
- ok(sql_ret && error_code == SQL_SUCCESS, "SQLInstallDriverEx failed %d, %u\n", sql_ret, error_code);
+ ok(sql_ret == SQL_NO_DATA || (sql_ret && error_code == SQL_SUCCESS), "SQLInstallDriverEx failed %d, %u\n", sql_ret, error_code);
ok(!strcmp(path, "c:\\temp"), "invalid path %s\n", path);
if (ret)
@@ -458,6 +472,12 @@ static void test_SQLInstallDriverEx(void)
ok(size == strlen(driverpath) + 1, "got %u\n", size);
ok(!strcmp(path, driverpath), "invalid path %s\n", path);
+ res = RegQueryValueExA(hkey, "CPTimeout", NULL, &type, (BYTE *)&path, &size);
+ ok(res == ERROR_SUCCESS, "got %d\n", res);
+ ok(type == REG_SZ, "got %u\n", type);
+ ok(size == strlen("59") + 1, "got %u\n", size);
+ ok(!strcmp(path, "59"), "invalid value %s\n", path);
+
RegCloseKey(hkey);
}
}
--
1.9.1
More information about the wine-patches
mailing list