odbccp32: Implement SQLValidDSN/W.
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
04413abcc7
commit
990f08dc73
|
@ -29,6 +29,7 @@
|
||||||
#include "winbase.h"
|
#include "winbase.h"
|
||||||
#include "winreg.h"
|
#include "winreg.h"
|
||||||
#include "winnls.h"
|
#include "winnls.h"
|
||||||
|
#include "sqlext.h"
|
||||||
#include "wine/unicode.h"
|
#include "wine/unicode.h"
|
||||||
#include "wine/debug.h"
|
#include "wine/debug.h"
|
||||||
#include "wine/heap.h"
|
#include "wine/heap.h"
|
||||||
|
@ -1514,18 +1515,30 @@ BOOL WINAPI SQLSetConfigMode(UWORD wConfigMode)
|
||||||
|
|
||||||
BOOL WINAPI SQLValidDSNW(LPCWSTR lpszDSN)
|
BOOL WINAPI SQLValidDSNW(LPCWSTR lpszDSN)
|
||||||
{
|
{
|
||||||
|
static const WCHAR invalid[] = {'[',']','{','}','(',')',',',';','?','*','=','!','@','\\',0};
|
||||||
clear_errors();
|
clear_errors();
|
||||||
FIXME("%s\n", debugstr_w(lpszDSN));
|
TRACE("%s\n", debugstr_w(lpszDSN));
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
||||||
return FALSE;
|
if(strlenW(lpszDSN) > SQL_MAX_DSN_LENGTH || strpbrkW(lpszDSN, invalid) != NULL)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI SQLValidDSN(LPCSTR lpszDSN)
|
BOOL WINAPI SQLValidDSN(LPCSTR lpszDSN)
|
||||||
{
|
{
|
||||||
|
static const char *invalid = "[]{}(),;?*=!@\\";
|
||||||
clear_errors();
|
clear_errors();
|
||||||
FIXME("%s\n", debugstr_a(lpszDSN));
|
TRACE("%s\n", debugstr_a(lpszDSN));
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
||||||
return FALSE;
|
if(strlen(lpszDSN) > SQL_MAX_DSN_LENGTH || strpbrk(lpszDSN, invalid) != NULL)
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL WINAPI SQLWriteDSNToIniW(LPCWSTR lpszDSN, LPCWSTR lpszDriver)
|
BOOL WINAPI SQLWriteDSNToIniW(LPCWSTR lpszDSN, LPCWSTR lpszDriver)
|
||||||
|
|
|
@ -682,6 +682,65 @@ static void test_SQLGetInstalledDrivers(void)
|
||||||
SQLRemoveDriver("Wine test", TRUE, NULL);
|
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)
|
START_TEST(misc)
|
||||||
{
|
{
|
||||||
test_SQLConfigMode();
|
test_SQLConfigMode();
|
||||||
|
@ -693,4 +752,6 @@ START_TEST(misc)
|
||||||
test_SQLInstallDriverEx();
|
test_SQLInstallDriverEx();
|
||||||
test_SQLInstallTranslatorEx();
|
test_SQLInstallTranslatorEx();
|
||||||
test_SQLGetInstalledDrivers();
|
test_SQLGetInstalledDrivers();
|
||||||
|
test_SQLValidDSN();
|
||||||
|
test_SQLValidDSNW();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue