Commit 990f08dc authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

odbccp32: Implement SQLValidDSN/W.

parent 04413abc
......@@ -29,6 +29,7 @@
#include "winbase.h"
#include "winreg.h"
#include "winnls.h"
#include "sqlext.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "wine/heap.h"
......@@ -1514,18 +1515,30 @@ BOOL WINAPI SQLSetConfigMode(UWORD wConfigMode)
BOOL WINAPI SQLValidDSNW(LPCWSTR lpszDSN)
{
static const WCHAR invalid[] = {'[',']','{','}','(',')',',',';','?','*','=','!','@','\\',0};
clear_errors();
FIXME("%s\n", debugstr_w(lpszDSN));
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
TRACE("%s\n", debugstr_w(lpszDSN));
if(strlenW(lpszDSN) > SQL_MAX_DSN_LENGTH || strpbrkW(lpszDSN, invalid) != NULL)
{
return FALSE;
}
return TRUE;
}
BOOL WINAPI SQLValidDSN(LPCSTR lpszDSN)
{
static const char *invalid = "[]{}(),;?*=!@\\";
clear_errors();
FIXME("%s\n", debugstr_a(lpszDSN));
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
TRACE("%s\n", debugstr_a(lpszDSN));
if(strlen(lpszDSN) > SQL_MAX_DSN_LENGTH || strpbrk(lpszDSN, invalid) != NULL)
{
return FALSE;
}
return TRUE;
}
BOOL WINAPI SQLWriteDSNToIniW(LPCWSTR lpszDSN, LPCWSTR lpszDriver)
......
......@@ -682,6 +682,65 @@ static void test_SQLGetInstalledDrivers(void)
SQLRemoveDriver("Wine test", TRUE, NULL);
}
static void test_SQLValidDSN(void)
{
static const char *invalid = "[]{}(),;?*=!@\\";
char str[10];
int i;
BOOL ret;
strcpy(str, "wine10");
for(i = 0; i < strlen(invalid); i++)
{
str[4] = invalid[i];
ret = SQLValidDSN(str);
ok(!ret, "got %d\n", ret);
}
/* Too large */
ret = SQLValidDSN("Wine123456789012345678901234567890");
ok(!ret, "got %d\n", ret);
/* Valid with a space */
ret = SQLValidDSN("Wine Vinegar");
ok(ret, "got %d\n", ret);
/* Max DSN name value */
ret = SQLValidDSN("12345678901234567890123456789012");
ok(ret, "got %d\n", ret);
}
static void test_SQLValidDSNW(void)
{
static const WCHAR invalid[] = {'[',']','{','}','(',')',',',';','?','*','=','!','@','\\',0};
static const WCHAR value[] = { 'w','i','n','e','1','0',0};
static const WCHAR too_large[] = { 'W','i','n','e','1','2','3','4','5','6','7','8','9','0','1','2','3','4','5',
'6','7','8','9','0','1','2','3','4','5','6','7','8','9','0', 0};
static const WCHAR with_space[] = { 'W','i','n','e',' ','V','i','n','e','g','a','r', 0};
static const WCHAR max_dsn[] = { '1','2','3','4','5','6','7','8','9','0','1','2','3','4','5','6','7','8','9','0',
'1','2','3','4','5','6','7','8','9','0','1','2', 0};
WCHAR str[10];
int i;
BOOL ret;
lstrcpyW(str, value);
for(i = 0; i < lstrlenW(invalid); i++)
{
str[4] = invalid[i];
ret = SQLValidDSNW(str);
ok(!ret, "got %d\n", ret);
}
ret = SQLValidDSNW(too_large);
ok(!ret, "got %d\n", ret);
ret = SQLValidDSNW(with_space);
ok(ret, "got %d\n", ret);
ret = SQLValidDSNW(max_dsn);
ok(ret, "got %d\n", ret);
}
START_TEST(misc)
{
test_SQLConfigMode();
......@@ -693,4 +752,6 @@ START_TEST(misc)
test_SQLInstallDriverEx();
test_SQLInstallTranslatorEx();
test_SQLGetInstalledDrivers();
test_SQLValidDSN();
test_SQLValidDSNW();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment