ReactOS 0.4.17-dev-970-gcf0f1a6
odbcinst.h File Reference
#include <sql.h>
Include dependency graph for odbcinst.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ODBCVER   0x0351
 
#define INSTAPI   __stdcall
 
#define ODBC_ADD_DSN   1
 
#define ODBC_CONFIG_DSN   2
 
#define ODBC_REMOVE_DSN   3
 
#define ODBC_ADD_SYS_DSN   4
 
#define ODBC_CONFIG_SYS_DSN   5
 
#define ODBC_REMOVE_SYS_DSN   6
 
#define ODBC_INSTALL_INQUIRY   1
 
#define ODBC_INSTALL_COMPLETE   2
 
#define ODBC_INSTALL_DRIVER   1
 
#define ODBC_REMOVE_DRIVER   2
 
#define ODBC_CONFIG_DRIVER   3
 
#define ODBC_CONFIG_DRIVER_MAX   100
 
#define ODBC_REMOVE_DEFAULT_DSN   7
 
#define ODBC_BOTH_DSN   0
 
#define ODBC_USER_DSN   1
 
#define ODBC_SYSTEM_DSN   2
 
#define ODBC_ERROR_GENERAL_ERR   1
 
#define ODBC_ERROR_INVALID_BUFF_LEN   2
 
#define ODBC_ERROR_INVALID_HWND   3
 
#define ODBC_ERROR_INVALID_STR   4
 
#define ODBC_ERROR_INVALID_REQUEST_TYPE   5
 
#define ODBC_ERROR_COMPONENT_NOT_FOUND   6
 
#define ODBC_ERROR_INVALID_NAME   7
 
#define ODBC_ERROR_INVALID_KEYWORD_VALUE   8
 
#define ODBC_ERROR_INVALID_DSN   9
 
#define ODBC_ERROR_INVALID_INF   10
 
#define ODBC_ERROR_REQUEST_FAILED   11
 
#define ODBC_ERROR_INVALID_PATH   12
 
#define ODBC_ERROR_LOAD_LIB_FAILED   13
 
#define ODBC_ERROR_INVALID_PARAM_SEQUENCE   14
 
#define ODBC_ERROR_INVALID_LOG_FILE   15
 
#define ODBC_ERROR_USER_CANCELED   16
 
#define ODBC_ERROR_USAGE_UPDATE_FAILED   17
 
#define ODBC_ERROR_CREATE_DSN_FAILED   18
 
#define ODBC_ERROR_WRITING_SYSINFO_FAILED   19
 
#define ODBC_ERROR_REMOVE_DSN_FAILED   20
 
#define ODBC_ERROR_OUT_OF_MEM   21
 
#define ODBC_ERROR_OUTPUT_STRING_TRUNCATED   22
 

Functions

BOOL INSTAPI ConfigDSN (HWND, WORD, LPCSTR, LPCSTR)
 
BOOL INSTAPI ConfigDSNW (HWND, WORD, LPCWSTR, LPCWSTR)
 
BOOL INSTAPI ConfigTranslator (HWND, DWORD *)
 
BOOL INSTAPI SQLConfigDataSource (HWND, WORD, LPCSTR, LPCSTR)
 
BOOL INSTAPI SQLConfigDataSourceW (HWND, WORD, LPCWSTR, LPCWSTR)
 
BOOL INSTAPI SQLCreateDataSource (HWND, LPCSTR)
 
BOOL INSTAPI SQLCreateDataSourceW (HWND, LPCWSTR)
 
BOOL INSTAPI SQLGetAvailableDrivers (LPCSTR, LPSTR, WORD, WORD *)
 
BOOL INSTAPI SQLGetAvailableDriversW (LPCWSTR, LPWSTR, WORD, WORD *)
 
BOOL INSTAPI SQLGetInstalledDrivers (LPSTR, WORD, WORD *)
 
BOOL INSTAPI SQLGetInstalledDriversW (LPWSTR, WORD, WORD *)
 
int INSTAPI SQLGetPrivateProfileString (LPCSTR, LPCSTR, LPCSTR, LPSTR, int, LPCSTR)
 
int INSTAPI SQLGetPrivateProfileStringW (LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, int, LPCWSTR)
 
BOOL INSTAPI SQLGetTranslator (HWND, LPSTR, WORD, WORD *, LPSTR, WORD, WORD *, DWORD *)
 
BOOL INSTAPI SQLGetTranslatorW (HWND, LPWSTR, WORD, WORD *, LPWSTR, WORD, WORD *, DWORD *)
 
BOOL INSTAPI SQLInstallDriver (LPCSTR, LPCSTR, LPSTR, WORD, WORD *)
 
BOOL INSTAPI SQLInstallDriverManager (LPSTR, WORD, WORD *)
 
BOOL INSTAPI SQLInstallDriverManagerW (LPWSTR, WORD, WORD *)
 
BOOL INSTAPI SQLInstallDriverW (LPCWSTR, LPCWSTR, LPWSTR, WORD, WORD *)
 
BOOL INSTAPI SQLInstallODBC (HWND, LPCSTR, LPCSTR, LPCSTR)
 
BOOL INSTAPI SQLInstallODBCW (HWND, LPCWSTR, LPCWSTR, LPCWSTR)
 
BOOL INSTAPI SQLManageDataSources (HWND)
 
BOOL INSTAPI SQLRemoveDefaultDataSource (void)
 
BOOL INSTAPI SQLRemoveDSNFromIni (LPCSTR)
 
BOOL INSTAPI SQLRemoveDSNFromIniW (LPCWSTR)
 
BOOL INSTAPI SQLValidDSN (LPCSTR)
 
BOOL INSTAPI SQLValidDSNW (LPCWSTR)
 
BOOL INSTAPI SQLWriteDSNToIni (LPCSTR, LPCSTR)
 
BOOL INSTAPI SQLWriteDSNToIniW (LPCWSTR, LPCWSTR)
 
BOOL INSTAPI SQLWritePrivateProfileString (LPCSTR, LPCSTR, LPCSTR, LPCSTR)
 
BOOL INSTAPI SQLWritePrivateProfileStringW (LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR)
 
BOOL INSTAPI ConfigDriver (HWND, WORD, LPCSTR, LPCSTR, LPSTR, WORD, WORD *)
 
BOOL INSTAPI ConfigDriverW (HWND, WORD, LPCWSTR, LPCWSTR, LPWSTR, WORD, WORD *)
 
BOOL INSTAPI SQLConfigDriver (HWND, WORD, LPCSTR, LPCSTR, LPSTR, WORD, WORD *)
 
BOOL INSTAPI SQLConfigDriverW (HWND, WORD, LPCWSTR, LPCWSTR, LPWSTR, WORD, WORD *)
 
BOOL INSTAPI SQLInstallTranslator (LPCSTR, LPCSTR, LPCSTR, LPSTR, WORD, WORD *, WORD, LPDWORD)
 
BOOL INSTAPI SQLInstallTranslatorW (LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, WORD, WORD *, WORD, LPDWORD)
 
BOOL INSTAPI SQLRemoveDriver (LPCSTR, BOOL, LPDWORD)
 
BOOL INSTAPI SQLRemoveDriverManager (LPDWORD)
 
BOOL INSTAPI SQLRemoveDriverW (LPCWSTR, BOOL, LPDWORD)
 
BOOL INSTAPI SQLRemoveTranslator (LPCSTR, LPDWORD)
 
BOOL INSTAPI SQLRemoveTranslatorW (LPCWSTR, LPDWORD)
 
BOOL INSTAPI SQLGetConfigMode (UWORD *)
 
BOOL INSTAPI SQLInstallDriverEx (LPCSTR, LPCSTR, LPSTR, WORD, WORD *, WORD, LPDWORD)
 
BOOL INSTAPI SQLInstallDriverExW (LPCWSTR, LPCWSTR, LPWSTR, WORD, WORD *, WORD, LPDWORD)
 
SQLRETURN INSTAPI SQLInstallerError (WORD, DWORD *, LPSTR, WORD, WORD *)
 
SQLRETURN INSTAPI SQLInstallerErrorW (WORD, DWORD *, LPWSTR, WORD, WORD *)
 
BOOL INSTAPI SQLInstallTranslatorEx (LPCSTR, LPCSTR, LPSTR, WORD, WORD *, WORD, LPDWORD)
 
BOOL INSTAPI SQLInstallTranslatorExW (LPCWSTR, LPCWSTR, LPWSTR, WORD, WORD *, WORD, LPDWORD)
 
SQLRETURN INSTAPI SQLPostInstallerError (DWORD, LPCSTR)
 
SQLRETURN INSTAPI SQLPostInstallerErrorW (DWORD, LPCWSTR)
 
BOOL INSTAPI SQLReadFileDSN (LPCSTR, LPCSTR, LPCSTR, LPSTR, WORD, WORD *)
 
BOOL INSTAPI SQLReadFileDSNW (LPCWSTR, LPCWSTR, LPCWSTR, LPWSTR, WORD, WORD *)
 
BOOL INSTAPI SQLSetConfigMode (UWORD)
 
BOOL INSTAPI SQLWriteFileDSN (LPCSTR, LPCSTR, LPCSTR, LPCSTR)
 
BOOL INSTAPI SQLWriteFileDSNW (LPCWSTR, LPCWSTR, LPCWSTR, LPCWSTR)
 

Macro Definition Documentation

◆ INSTAPI

#define INSTAPI   __stdcall

Definition at line 11 of file odbcinst.h.

◆ ODBC_ADD_DSN

#define ODBC_ADD_DSN   1

Definition at line 12 of file odbcinst.h.

◆ ODBC_ADD_SYS_DSN

#define ODBC_ADD_SYS_DSN   4

Definition at line 16 of file odbcinst.h.

◆ ODBC_BOTH_DSN

#define ODBC_BOTH_DSN   0

Definition at line 28 of file odbcinst.h.

◆ ODBC_CONFIG_DRIVER

#define ODBC_CONFIG_DRIVER   3

Definition at line 23 of file odbcinst.h.

◆ ODBC_CONFIG_DRIVER_MAX

#define ODBC_CONFIG_DRIVER_MAX   100

Definition at line 24 of file odbcinst.h.

◆ ODBC_CONFIG_DSN

#define ODBC_CONFIG_DSN   2

Definition at line 13 of file odbcinst.h.

◆ ODBC_CONFIG_SYS_DSN

#define ODBC_CONFIG_SYS_DSN   5

Definition at line 17 of file odbcinst.h.

◆ ODBC_ERROR_COMPONENT_NOT_FOUND

#define ODBC_ERROR_COMPONENT_NOT_FOUND   6

Definition at line 36 of file odbcinst.h.

◆ ODBC_ERROR_CREATE_DSN_FAILED

#define ODBC_ERROR_CREATE_DSN_FAILED   18

Definition at line 48 of file odbcinst.h.

◆ ODBC_ERROR_GENERAL_ERR

#define ODBC_ERROR_GENERAL_ERR   1

Definition at line 31 of file odbcinst.h.

◆ ODBC_ERROR_INVALID_BUFF_LEN

#define ODBC_ERROR_INVALID_BUFF_LEN   2

Definition at line 32 of file odbcinst.h.

◆ ODBC_ERROR_INVALID_DSN

#define ODBC_ERROR_INVALID_DSN   9

Definition at line 39 of file odbcinst.h.

◆ ODBC_ERROR_INVALID_HWND

#define ODBC_ERROR_INVALID_HWND   3

Definition at line 33 of file odbcinst.h.

◆ ODBC_ERROR_INVALID_INF

#define ODBC_ERROR_INVALID_INF   10

Definition at line 40 of file odbcinst.h.

◆ ODBC_ERROR_INVALID_KEYWORD_VALUE

#define ODBC_ERROR_INVALID_KEYWORD_VALUE   8

Definition at line 38 of file odbcinst.h.

◆ ODBC_ERROR_INVALID_LOG_FILE

#define ODBC_ERROR_INVALID_LOG_FILE   15

Definition at line 45 of file odbcinst.h.

◆ ODBC_ERROR_INVALID_NAME

#define ODBC_ERROR_INVALID_NAME   7

Definition at line 37 of file odbcinst.h.

◆ ODBC_ERROR_INVALID_PARAM_SEQUENCE

#define ODBC_ERROR_INVALID_PARAM_SEQUENCE   14

Definition at line 44 of file odbcinst.h.

◆ ODBC_ERROR_INVALID_PATH

#define ODBC_ERROR_INVALID_PATH   12

Definition at line 42 of file odbcinst.h.

◆ ODBC_ERROR_INVALID_REQUEST_TYPE

#define ODBC_ERROR_INVALID_REQUEST_TYPE   5

Definition at line 35 of file odbcinst.h.

◆ ODBC_ERROR_INVALID_STR

#define ODBC_ERROR_INVALID_STR   4

Definition at line 34 of file odbcinst.h.

◆ ODBC_ERROR_LOAD_LIB_FAILED

#define ODBC_ERROR_LOAD_LIB_FAILED   13

Definition at line 43 of file odbcinst.h.

◆ ODBC_ERROR_OUT_OF_MEM

#define ODBC_ERROR_OUT_OF_MEM   21

Definition at line 51 of file odbcinst.h.

◆ ODBC_ERROR_OUTPUT_STRING_TRUNCATED

#define ODBC_ERROR_OUTPUT_STRING_TRUNCATED   22

Definition at line 52 of file odbcinst.h.

◆ ODBC_ERROR_REMOVE_DSN_FAILED

#define ODBC_ERROR_REMOVE_DSN_FAILED   20

Definition at line 50 of file odbcinst.h.

◆ ODBC_ERROR_REQUEST_FAILED

#define ODBC_ERROR_REQUEST_FAILED   11

Definition at line 41 of file odbcinst.h.

◆ ODBC_ERROR_USAGE_UPDATE_FAILED

#define ODBC_ERROR_USAGE_UPDATE_FAILED   17

Definition at line 47 of file odbcinst.h.

◆ ODBC_ERROR_USER_CANCELED

#define ODBC_ERROR_USER_CANCELED   16

Definition at line 46 of file odbcinst.h.

◆ ODBC_ERROR_WRITING_SYSINFO_FAILED

#define ODBC_ERROR_WRITING_SYSINFO_FAILED   19

Definition at line 49 of file odbcinst.h.

◆ ODBC_INSTALL_COMPLETE

#define ODBC_INSTALL_COMPLETE   2

Definition at line 20 of file odbcinst.h.

◆ ODBC_INSTALL_DRIVER

#define ODBC_INSTALL_DRIVER   1

Definition at line 21 of file odbcinst.h.

◆ ODBC_INSTALL_INQUIRY

#define ODBC_INSTALL_INQUIRY   1

Definition at line 19 of file odbcinst.h.

◆ ODBC_REMOVE_DEFAULT_DSN

#define ODBC_REMOVE_DEFAULT_DSN   7

Definition at line 27 of file odbcinst.h.

◆ ODBC_REMOVE_DRIVER

#define ODBC_REMOVE_DRIVER   2

Definition at line 22 of file odbcinst.h.

◆ ODBC_REMOVE_DSN

#define ODBC_REMOVE_DSN   3

Definition at line 14 of file odbcinst.h.

◆ ODBC_REMOVE_SYS_DSN

#define ODBC_REMOVE_SYS_DSN   6

Definition at line 18 of file odbcinst.h.

◆ ODBC_SYSTEM_DSN

#define ODBC_SYSTEM_DSN   2

Definition at line 30 of file odbcinst.h.

◆ ODBC_USER_DSN

#define ODBC_USER_DSN   1

Definition at line 29 of file odbcinst.h.

◆ ODBCVER

#define ODBCVER   0x0351

Definition at line 9 of file odbcinst.h.

Function Documentation

◆ ConfigDriver()

BOOL INSTAPI ConfigDriver ( HWND  ,
WORD  ,
LPCSTR  ,
LPCSTR  ,
LPSTR  ,
WORD  ,
WORD *   
)

◆ ConfigDriverW()

BOOL INSTAPI ConfigDriverW ( HWND  ,
WORD  ,
LPCWSTR  ,
LPCWSTR  ,
LPWSTR  ,
WORD  ,
WORD *   
)

◆ ConfigDSN()

BOOL INSTAPI ConfigDSN ( HWND  ,
WORD  ,
LPCSTR  ,
LPCSTR   
)

◆ ConfigDSNW()

BOOL INSTAPI ConfigDSNW ( HWND  ,
WORD  ,
LPCWSTR  ,
LPCWSTR   
)

◆ ConfigTranslator()

BOOL INSTAPI ConfigTranslator ( HWND  ,
DWORD *   
)

◆ SQLConfigDataSource()

BOOL INSTAPI SQLConfigDataSource ( HWND  hwnd,
WORD  request,
LPCSTR  driver,
LPCSTR  attributes 
)

Definition at line 442 of file odbccp32.c.

443{
444 HMODULE mod;
445 BOOL ret = FALSE;
446 WCHAR *driverW;
447 UWORD config_mode_prev = config_mode;
448 WORD mapped_request;
449
450 TRACE("%p, %d, %s, %s\n", hwnd, request, debugstr_a(driver), debugstr_a(attributes));
451
452 if (TRACE_ON(odbc) && attributes)
453 {
454 const char *p;
455 for (p = attributes; *p; p += lstrlenA(p) + 1)
456 TRACE("%s\n", debugstr_a(p));
457 }
458
459 clear_errors();
460
461 mapped_request = map_request(request);
462 if (!mapped_request)
463 return FALSE;
464
466 if (!driverW)
467 {
468 push_error(ODBC_ERROR_OUT_OF_MEM, L"Out of memory");
469 return FALSE;
470 }
471
473 if (!mod)
474 {
475 free(driverW);
476 return FALSE;
477 }
478
480
481 pConfigDSN = (void*)GetProcAddress(mod, "ConfigDSN");
482 if (pConfigDSN)
483 {
484 TRACE("Calling ConfigDSN\n");
485 ret = pConfigDSN(hwnd, mapped_request, driver, attributes);
486 }
487 else
488 {
489 pConfigDSNW = (void*)GetProcAddress(mod, "ConfigDSNW");
490 if (pConfigDSNW)
491 {
492 WCHAR *attr = NULL;
493 TRACE("Calling ConfigDSNW\n");
494
496 if(attr)
497 ret = pConfigDSNW(hwnd, mapped_request, driverW, attr);
498 free(attr);
499 }
500 }
501
502 config_mode = config_mode_prev;
503
504 if (!ret)
505 push_error(ODBC_ERROR_REQUEST_FAILED, L"Request Failed");
506
507 free(driverW);
509
510 return ret;
511}
std::map< E_MODULE, HMODULE > mod
Definition: LocaleTests.cpp:68
#define free
Definition: debug_ros.c:5
#define NULL
Definition: types.h:112
#define FALSE
Definition: types.h:117
#define GetProcAddress(x, y)
Definition: compat.h:753
#define FreeLibrary(x)
Definition: compat.h:748
#define TRACE_ON(x)
Definition: compat.h:75
return ret
Definition: mutex.c:147
#define L(x)
Definition: resources.c:13
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
GLfloat GLfloat p
Definition: glext.h:8902
unsigned short UWORD
Definition: lzx.c:49
#define debugstr_a
Definition: kernel32.h:31
int WINAPI lstrlenA(LPCSTR lpString)
Definition: lstring.c:145
#define ODBC_ERROR_REQUEST_FAILED
Definition: odbcinst.h:41
#define ODBC_ERROR_OUT_OF_MEM
Definition: odbcinst.h:51
static HANDLE ACCESS_MASK ULONG attributes
Definition: om.c:94
short WCHAR
Definition: pedump.c:58
static const WCHAR driverW[]
#define TRACE(s)
Definition: solgame.cpp:4
Definition: cookie.c:202
Definition: tftpd.h:86
static void clear_errors(void)
Definition: odbccp32.c:71
static void push_error(int code, LPCWSTR msg)
Definition: odbccp32.c:60
static WORD const char * driver
Definition: odbccp32.c:56
static WCHAR * strdupAtoW(const char *str)
Definition: odbccp32.c:76
static HMODULE load_config_driver(const WCHAR *driver)
Definition: odbccp32.c:242
static WORD map_request(WORD request)
Definition: odbccp32.c:357
static UWORD get_config_mode(WORD request)
Definition: odbccp32.c:379
static LPWSTR SQLInstall_strdup_multi(LPCSTR str)
Definition: odbccp32.c:100
static UWORD config_mode
Definition: odbccp32.c:46
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023

Referenced by test_SQLConfigDataSource().

◆ SQLConfigDataSourceW()

BOOL INSTAPI SQLConfigDataSourceW ( HWND  hwnd,
WORD  request,
LPCWSTR  driver,
LPCWSTR  attributes 
)

Definition at line 385 of file odbccp32.c.

386{
387 HMODULE mod;
388 BOOL ret = FALSE;
389 UWORD config_mode_prev = config_mode;
390 WORD mapped_request;
391
392 TRACE("%p, %d, %s, %s\n", hwnd, request, debugstr_w(driver), debugstr_w(attributes));
393 if (TRACE_ON(odbc) && attributes)
394 {
395 const WCHAR *p;
396 for (p = attributes; *p; p += lstrlenW(p) + 1)
397 TRACE("%s\n", debugstr_w(p));
398 }
399
400 clear_errors();
401
402 mapped_request = map_request(request);
403 if (!mapped_request)
404 return FALSE;
405
407 if (!mod)
408 return FALSE;
409
411
412 pConfigDSNW = (void*)GetProcAddress(mod, "ConfigDSNW");
413 if(pConfigDSNW)
414 ret = pConfigDSNW(hwnd, mapped_request, driver, attributes);
415 else
416 {
417 pConfigDSN = (void*)GetProcAddress(mod, "ConfigDSN");
418 if (pConfigDSN)
419 {
421 char *driverA = strdupWtoA(driver);
422 TRACE("Calling ConfigDSN\n");
423
424 ret = pConfigDSN(hwnd, mapped_request, driverA, attr);
425 free(attr);
426 free(driverA);
427 }
428 else
429 ERR("Failed to find ConfigDSN/W\n");
430 }
431
432 config_mode = config_mode_prev;
433
434 if (!ret)
435 push_error(ODBC_ERROR_REQUEST_FAILED, L"Request Failed");
436
438
439 return ret;
440}
#define ERR(fmt,...)
Definition: precomp.h:57
#define lstrlenW
Definition: compat.h:750
#define debugstr_w
Definition: kernel32.h:32
char * LPSTR
Definition: typedefs.h:51
static LPSTR SQLInstall_strdup_multiWtoA(LPCWSTR str)
Definition: odbccp32.c:120
static char * strdupWtoA(const WCHAR *str)
Definition: odbccp32.c:140

Referenced by ITERATE_InstallODBCDataSource(), and ITERATE_RemoveODBCDataSource().

◆ SQLConfigDriver()

BOOL INSTAPI SQLConfigDriver ( HWND  hwnd,
WORD  request,
LPCSTR  driver,
LPCSTR  args,
LPSTR  msg,
WORD  msgmax,
WORD *  msgout 
)

Definition at line 545 of file odbccp32.c.

547{
548 BOOL (WINAPI *pConfigDriverA)(HWND hwnd, WORD request, const char *driver, const char *args, const char *msg, WORD msgmax, WORD *msgout);
550 WCHAR *driverW;
551 BOOL funcret = FALSE;
552
553 clear_errors();
554 TRACE("(%p %d %s %s %p %d %p)\n", hwnd, request, debugstr_a(driver),
555 debugstr_a(args), msg, msgmax, msgout);
556
558 if(!driverW)
559 {
560 push_error(ODBC_ERROR_OUT_OF_MEM, L"Out of memory");
561 return FALSE;
562 }
564 {
565 BOOL ret = FALSE;
566 WCHAR *argsW = strdupAtoW(args);
567 if(argsW)
568 {
570 free(argsW);
571 }
572 else
573 {
574 push_error(ODBC_ERROR_OUT_OF_MEM, L"Out of memory");
575 }
576
577 free(driverW);
578
579 return ret;
580 }
581
583 free(driverW);
584 if(!hmod)
585 return FALSE;
586
587 pConfigDriverA = (void*)GetProcAddress(hmod, "ConfigDriver");
588 if(pConfigDriverA)
589 funcret = pConfigDriverA(hwnd, request, driver, args, msg, msgmax, msgout);
590
591 if(!funcret)
592 push_error(ODBC_ERROR_REQUEST_FAILED, L"Request Failed");
593
595
596 return funcret;
597}
#define msg(x)
Definition: auth_time.c:54
static NTSTATUS *static PWSTR CURDIR *static HMODULE hmod
Definition: security.c:104
#define BOOL
Definition: nt_native.h:43
#define ODBC_CONFIG_DRIVER
Definition: odbcinst.h:23
#define args
Definition: format.c:66
Definition: match.c:390
static WORD request
Definition: odbccp32.c:56
static BOOL write_config_value(const WCHAR *driver, const WCHAR *args)
Definition: odbccp32.c:299
#define WINAPI
Definition: msvc.h:6

Referenced by test_SQLInstallDriverEx().

◆ SQLConfigDriverW()

BOOL INSTAPI SQLConfigDriverW ( HWND  hwnd,
WORD  request,
LPCWSTR  driver,
LPCWSTR  args,
LPWSTR  msg,
WORD  msgmax,
WORD *  msgout 
)

Definition at line 513 of file odbccp32.c.

515{
516 BOOL (WINAPI *pConfigDriverW)(HWND hwnd, WORD request, const WCHAR *driver, const WCHAR *args, const WCHAR *msg, WORD msgmax, WORD *msgout);
518 BOOL funcret = FALSE;
519
520 clear_errors();
521 TRACE("(%p %d %s %s %p %d %p)\n", hwnd, request, debugstr_w(driver),
522 debugstr_w(args), msg, msgmax, msgout);
523
525 {
527 }
528
530 if(!hmod)
531 return FALSE;
532
533 pConfigDriverW = (void*)GetProcAddress(hmod, "ConfigDriverW");
534 if(pConfigDriverW)
535 funcret = pConfigDriverW(hwnd, request, driver, args, msg, msgmax, msgout);
536
537 if(!funcret)
538 push_error(ODBC_ERROR_REQUEST_FAILED, L"Request Failed");
539
541
542 return funcret;
543}

◆ SQLCreateDataSource()

BOOL INSTAPI SQLCreateDataSource ( HWND  hwnd,
LPCSTR  lpszDS 
)

Definition at line 607 of file odbccp32.c.

608{
609 clear_errors();
610 FIXME("%p %s\n", hwnd, debugstr_a(lpszDS));
612 return FALSE;
613}
#define FIXME(fmt,...)
Definition: precomp.h:53
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define SetLastError(x)
Definition: compat.h:752

◆ SQLCreateDataSourceW()

BOOL INSTAPI SQLCreateDataSourceW ( HWND  hwnd,
LPCWSTR  lpszDS 
)

Definition at line 599 of file odbccp32.c.

600{
601 clear_errors();
602 FIXME("%p %s\n", hwnd, debugstr_w(lpszDS));
604 return FALSE;
605}

◆ SQLGetAvailableDrivers()

BOOL INSTAPI SQLGetAvailableDrivers ( LPCSTR  lpszInfFile,
LPSTR  lpszBuf,
WORD  cbBufMax,
WORD *  pcbBufOut 
)

Definition at line 624 of file odbccp32.c.

626{
627 clear_errors();
628 FIXME("%s %p %d %p\n", debugstr_a(lpszInfFile), lpszBuf, cbBufMax, pcbBufOut);
630 return FALSE;
631}

◆ SQLGetAvailableDriversW()

BOOL INSTAPI SQLGetAvailableDriversW ( LPCWSTR  lpszInfFile,
LPWSTR  lpszBuf,
WORD  cbBufMax,
WORD *  pcbBufOut 
)

Definition at line 615 of file odbccp32.c.

617{
618 clear_errors();
619 FIXME("%s %p %d %p\n", debugstr_w(lpszInfFile), lpszBuf, cbBufMax, pcbBufOut);
621 return FALSE;
622}

◆ SQLGetConfigMode()

BOOL INSTAPI SQLGetConfigMode ( UWORD *  pwConfigMode)

Definition at line 633 of file odbccp32.c.

634{
635 clear_errors();
636 TRACE("%p\n", pwConfigMode);
637 if (pwConfigMode)
638 *pwConfigMode = config_mode;
639 return TRUE;
640}
#define TRUE
Definition: types.h:120

Referenced by test_SQLConfigMode(), and test_SQLGetPrivateProfileStringW().

◆ SQLGetInstalledDrivers()

BOOL INSTAPI SQLGetInstalledDrivers ( LPSTR  ,
WORD  ,
WORD *   
)

◆ SQLGetInstalledDriversW()

BOOL INSTAPI SQLGetInstalledDriversW ( LPWSTR  ,
WORD  ,
WORD *   
)

◆ SQLGetPrivateProfileString()

int INSTAPI SQLGetPrivateProfileString ( LPCSTR  section,
LPCSTR  entry,
LPCSTR  defvalue,
LPSTR  buff,
int  buff_len,
LPCSTR  filename 
)

Definition at line 847 of file odbccp32.c.

849{
850 WCHAR *sectionW, *filenameW;
851 BOOL usedefault = TRUE;
852 HKEY sectionkey;
853 LONG ret = 0;
854
855 TRACE("%s %s %s %p %d %s\n", debugstr_a(section), debugstr_a(entry),
857
858 clear_errors();
859
860 if (buff_len <= 0)
861 return 0;
862
863 if (buff)
864 buff[0] = 0;
865
866 if (!section || !defvalue || !buff)
867 return 0;
868
869 if (!(sectionW = strdupAtoW(section))) return 0;
870 if (!(filenameW = strdupAtoW(filename)))
871 {
872 free(sectionW);
873 return 0;
874 }
875
878 else if (config_mode == ODBC_SYSTEM_DSN)
880 else
881 {
883 if (!sectionkey) sectionkey = get_privateprofile_sectionkey(HKEY_LOCAL_MACHINE, sectionW, filenameW);
884 }
885
886 free(sectionW);
888
889 if (sectionkey)
890 {
891 DWORD type, size;
892
893 if (entry)
894 {
895 size = buff_len * sizeof(*buff);
896 if (RegGetValueA(sectionkey, NULL, entry, RRF_RT_REG_SZ, &type, buff, &size) == ERROR_SUCCESS)
897 {
898 usedefault = FALSE;
899 ret = (size / sizeof(*buff)) - 1;
900 }
901 }
902 else
903 {
904 char name[MAX_PATH] = {0};
905 DWORD index = 0;
907
908 usedefault = FALSE;
909
910 memset(buff, 0, buff_len);
911
912 namelen = sizeof(name);
913 while (RegEnumValueA(sectionkey, index, name, &namelen, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
914 {
915 if ((ret + namelen+1) > buff_len)
916 break;
917
919
920 ret += namelen+1;
921 namelen = sizeof(name);
922 index++;
923 }
924 }
925
926 RegCloseKey(sectionkey);
927 }
928 else
929 usedefault = entry != NULL;
930
931 if (usedefault)
932 {
933 lstrcpynA(buff, defvalue, buff_len);
934 ret = strlen(buff);
935 }
936
937 return ret;
938}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegEnumValueA(_In_ HKEY hKey, _In_ DWORD dwIndex, _Out_ LPSTR lpName, _Inout_ LPDWORD lpcbName, _Reserved_ LPDWORD lpdwReserved, _Out_opt_ LPDWORD lpdwType, _Out_opt_ LPBYTE lpData, _Inout_opt_ LPDWORD lpcbData)
Definition: reg.c:2668
LSTATUS WINAPI RegGetValueA(HKEY hKey, LPCSTR pszSubKey, LPCSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:2037
#define lstrcpynA
Definition: compat.h:751
#define MAX_PATH
Definition: compat.h:34
_ACRTIMP size_t __cdecl strlen(const char *)
Definition: string.c:1597
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizeiptr size
Definition: glext.h:5919
GLint namelen
Definition: glext.h:7232
GLuint index
Definition: glext.h:6031
const char * filename
Definition: ioapi.h:137
uint32_t entry
Definition: isohybrid.c:63
LPSTR WINAPI lstrcpyA(LPSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:100
static const WCHAR filenameW[]
Definition: resource.c:27
#define ODBC_SYSTEM_DSN
Definition: odbcinst.h:30
#define ODBC_USER_DSN
Definition: odbcinst.h:29
long LONG
Definition: pedump.c:60
#define memset(x, y, z)
Definition: compat.h:39
static const char *static const char const char DWORD void DWORD *static const char const char DWORD void DWORD *static const char DWORD DWORD void DWORD * buff_len
Definition: shcore.c:41
static const char *static const char const char DWORD void DWORD *static const char const char DWORD void DWORD *static const char DWORD DWORD void * buff
Definition: shcore.c:41
Definition: name.c:39
Definition: parser.c:56
static HKEY get_privateprofile_sectionkey(HKEY root, const WCHAR *section, const WCHAR *filename)
Definition: odbccp32.c:746
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RRF_RT_REG_SZ
Definition: winreg.h:58

Referenced by test_SQLGetPrivateProfileString().

◆ SQLGetPrivateProfileStringW()

int INSTAPI SQLGetPrivateProfileStringW ( LPCWSTR  section,
LPCWSTR  entry,
LPCWSTR  defvalue,
LPWSTR  buff,
int  buff_len,
LPCWSTR  filename 
)

Definition at line 765 of file odbccp32.c.

767{
768 BOOL usedefault = TRUE;
769 HKEY sectionkey;
770 LONG ret = 0;
771
772 TRACE("%s %s %s %p %d %s\n", debugstr_w(section), debugstr_w(entry),
774
775 clear_errors();
776
777 if (buff_len <= 0 || !section)
778 return 0;
779
780 if(buff)
781 buff[0] = 0;
782
783 if (!defvalue || !buff)
784 return 0;
785
786 /* odbcinit.ini is only for drivers, so default to local Machine */
787 if (!wcsicmp(filename, L"ODBCINST.INI") || config_mode == ODBC_SYSTEM_DSN)
789 else if (config_mode == ODBC_USER_DSN)
791 else
792 {
794 if (!sectionkey) sectionkey = get_privateprofile_sectionkey(HKEY_LOCAL_MACHINE, section, filename);
795 }
796
797 if (sectionkey)
798 {
799 DWORD type, size;
800
801 if (entry)
802 {
803 size = buff_len * sizeof(*buff);
804 if (RegGetValueW(sectionkey, NULL, entry, RRF_RT_REG_SZ, &type, buff, &size) == ERROR_SUCCESS)
805 {
806 usedefault = FALSE;
807 ret = (size / sizeof(*buff)) - 1;
808 }
809 }
810 else
811 {
813 DWORD index = 0;
815
816 usedefault = FALSE;
817
818 memset(buff, 0, buff_len);
819
820 namelen = sizeof(name);
821 while (RegEnumValueW(sectionkey, index, name, &namelen, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
822 {
823 if ((ret + namelen+1) > buff_len)
824 break;
825
827 ret += namelen+1;
828 namelen = sizeof(name);
829 index++;
830 }
831 }
832
833 RegCloseKey(sectionkey);
834 }
835 else
836 usedefault = entry != NULL;
837
838 if (usedefault)
839 {
840 lstrcpynW(buff, defvalue, buff_len);
841 ret = lstrlenW(buff);
842 }
843
844 return ret;
845}
LSTATUS WINAPI RegGetValueW(HKEY hKey, LPCWSTR pszSubKey, LPCWSTR pszValue, DWORD dwFlags, LPDWORD pdwType, PVOID pvData, LPDWORD pcbData)
Definition: reg.c:1931
LONG WINAPI RegEnumValueW(_In_ HKEY hKey, _In_ DWORD index, _Out_ LPWSTR value, _Inout_ PDWORD val_count, _Reserved_ PDWORD reserved, _Out_opt_ PDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ PDWORD count)
Definition: reg.c:2830
#define lstrcpyW
Definition: compat.h:749
#define wcsicmp
Definition: compat.h:15
#define lstrcpynW
Definition: compat.h:738

Referenced by test_SQLGetPrivateProfileStringW().

◆ SQLGetTranslator()

BOOL INSTAPI SQLGetTranslator ( HWND  hwndParent,
LPSTR  lpszName,
WORD  cbNameMax,
WORD *  pcbNameOut,
LPSTR  lpszPath,
WORD  cbPathMax,
WORD *  pcbPathOut,
DWORD *  pvOption 
)

Definition at line 951 of file odbccp32.c.

954{
955 clear_errors();
956 FIXME("%p %s %d %p %p %d %p %p\n", hwndParent, debugstr_a(lpszName), cbNameMax,
957 pcbNameOut, lpszPath, cbPathMax, pcbPathOut, pvOption);
959 return FALSE;
960}
static HWND hwndParent
Definition: cryptui.c:299

◆ SQLGetTranslatorW()

BOOL INSTAPI SQLGetTranslatorW ( HWND  hwndParent,
LPWSTR  lpszName,
WORD  cbNameMax,
WORD *  pcbNameOut,
LPWSTR  lpszPath,
WORD  cbPathMax,
WORD *  pcbPathOut,
DWORD *  pvOption 
)

Definition at line 940 of file odbccp32.c.

943{
944 clear_errors();
945 FIXME("%p %s %d %p %p %d %p %p\n", hwndParent, debugstr_w(lpszName), cbNameMax,
946 pcbNameOut, lpszPath, cbPathMax, pcbPathOut, pvOption);
948 return FALSE;
949}

◆ SQLInstallDriver()

BOOL INSTAPI SQLInstallDriver ( LPCSTR  lpszInfFile,
LPCSTR  lpszDriver,
LPSTR  lpszPath,
WORD  cbPathMax,
WORD *  pcbPathOut 
)

Definition at line 978 of file odbccp32.c.

980{
981 DWORD usage;
982
983 clear_errors();
984 TRACE("%s %s %p %d %p\n", debugstr_a(lpszInfFile),
985 debugstr_a(lpszDriver), lpszPath, cbPathMax, pcbPathOut);
986
987 if (lpszInfFile)
988 return FALSE;
989
990 return SQLInstallDriverEx(lpszDriver, NULL, lpszPath, cbPathMax,
991 pcbPathOut, ODBC_INSTALL_COMPLETE, &usage);
992}
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
#define ODBC_INSTALL_COMPLETE
Definition: odbcinst.h:20
BOOL WINAPI SQLInstallDriverEx(LPCSTR lpszDriver, LPCSTR lpszPathIn, LPSTR lpszPathOut, WORD cbPathOutMax, WORD *pcbPathOut, WORD fRequest, LPDWORD lpdwUsageCount)
Definition: odbccp32.c:1138

◆ SQLInstallDriverEx()

BOOL INSTAPI SQLInstallDriverEx ( LPCSTR  lpszDriver,
LPCSTR  lpszPathIn,
LPSTR  lpszPathOut,
WORD  cbPathOutMax,
WORD *  pcbPathOut,
WORD  fRequest,
LPDWORD  lpdwUsageCount 
)

Definition at line 1138 of file odbccp32.c.

1141{
1142 LPWSTR driver, pathin;
1143 WCHAR pathout[MAX_PATH];
1144 BOOL ret;
1145 WORD cbOut = 0;
1146
1147 clear_errors();
1148 TRACE("%s %s %p %d %p %d %p\n", debugstr_a(lpszDriver),
1149 debugstr_a(lpszPathIn), lpszPathOut, cbPathOutMax, pcbPathOut,
1150 fRequest, lpdwUsageCount);
1151
1152 driver = SQLInstall_strdup_multi(lpszDriver);
1153 pathin = SQLInstall_strdup(lpszPathIn);
1154
1155 ret = SQLInstallDriverExW(driver, pathin, pathout, MAX_PATH, &cbOut,
1156 fRequest, lpdwUsageCount);
1157 if (ret)
1158 {
1159 int len = WideCharToMultiByte(CP_ACP, 0, pathout, -1, lpszPathOut,
1160 0, NULL, NULL);
1161 if (len)
1162 {
1163 if (pcbPathOut)
1164 *pcbPathOut = len - 1;
1165
1166 if (!lpszPathOut || cbPathOutMax < len)
1167 {
1168 ret = FALSE;
1169 goto out;
1170 }
1171 len = WideCharToMultiByte(CP_ACP, 0, pathout, -1, lpszPathOut,
1172 cbPathOutMax, NULL, NULL);
1173 }
1174 }
1175
1176out:
1177 free(driver);
1178 free(pathin);
1179 return ret;
1180}
#define CP_ACP
Definition: compat.h:109
#define WideCharToMultiByte
Definition: compat.h:111
GLenum GLsizei len
Definition: glext.h:6722
uint16_t * LPWSTR
Definition: typedefs.h:56
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
BOOL WINAPI SQLInstallDriverExW(LPCWSTR lpszDriver, LPCWSTR lpszPathIn, LPWSTR lpszPathOut, WORD cbPathOutMax, WORD *pcbPathOut, WORD fRequest, LPDWORD lpdwUsageCount)
Definition: odbccp32.c:1111
static LPWSTR SQLInstall_strdup(LPCSTR str)
Definition: odbccp32.c:152

Referenced by SQLInstallDriver(), test_SQLGetInstalledDrivers(), and test_SQLInstallDriverEx().

◆ SQLInstallDriverExW()

BOOL INSTAPI SQLInstallDriverExW ( LPCWSTR  lpszDriver,
LPCWSTR  lpszPathIn,
LPWSTR  lpszPathOut,
WORD  cbPathOutMax,
WORD *  pcbPathOut,
WORD  fRequest,
LPDWORD  lpdwUsageCount 
)

Definition at line 1111 of file odbccp32.c.

1114{
1115 UINT len;
1117
1118 clear_errors();
1119 TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszDriver),
1120 debugstr_w(lpszPathIn), lpszPathOut, cbPathOutMax, pcbPathOut,
1121 fRequest, lpdwUsageCount);
1122
1123 write_registry_values(L"ODBC Drivers", lpszDriver, lpszPathIn, path, lpdwUsageCount);
1124
1125 len = lstrlenW(path);
1126
1127 if (pcbPathOut)
1128 *pcbPathOut = len;
1129
1130 if (lpszPathOut && cbPathOutMax > len)
1131 {
1132 lstrcpyW(lpszPathOut, path);
1133 return TRUE;
1134 }
1135 return FALSE;
1136}
unsigned int UINT
Definition: sysinfo.c:13
static void write_registry_values(const WCHAR *regkey, const WCHAR *driver, const WCHAR *path_in, WCHAR *path, DWORD *usage_count)
Definition: odbccp32.c:994

Referenced by ITERATE_InstallODBCDriver(), SQLInstallDriverEx(), and SQLInstallDriverW().

◆ SQLInstallDriverManager()

BOOL INSTAPI SQLInstallDriverManager ( LPSTR  lpszPath,
WORD  cbPathMax,
WORD *  pcbPathOut 
)

Definition at line 1208 of file odbccp32.c.

1210{
1211 BOOL ret;
1212 WORD len, cbOut = 0;
1214
1215 TRACE("(%p %d %p)\n", lpszPath, cbPathMax, pcbPathOut);
1216
1217 if (cbPathMax < MAX_PATH)
1218 return FALSE;
1219
1220 clear_errors();
1221
1223 if (ret)
1224 {
1225 len = WideCharToMultiByte(CP_ACP, 0, path, -1, lpszPath, 0,
1226 NULL, NULL);
1227 if (len)
1228 {
1229 if (pcbPathOut)
1230 *pcbPathOut = len - 1;
1231
1232 if (!lpszPath || cbPathMax < len)
1233 return FALSE;
1234
1235 len = WideCharToMultiByte(CP_ACP, 0, path, -1, lpszPath,
1236 cbPathMax, NULL, NULL);
1237 }
1238 }
1239 return ret;
1240}
BOOL WINAPI SQLInstallDriverManagerW(LPWSTR lpszPath, WORD cbPathMax, WORD *pcbPathOut)
Definition: odbccp32.c:1182

Referenced by test_SQLInstallDriverManager().

◆ SQLInstallDriverManagerW()

BOOL INSTAPI SQLInstallDriverManagerW ( LPWSTR  lpszPath,
WORD  cbPathMax,
WORD *  pcbPathOut 
)

Definition at line 1182 of file odbccp32.c.

1184{
1185 UINT len;
1187
1188 TRACE("(%p %d %p)\n", lpszPath, cbPathMax, pcbPathOut);
1189
1190 if (cbPathMax < MAX_PATH)
1191 return FALSE;
1192
1193 clear_errors();
1194
1196
1197 if (pcbPathOut)
1198 *pcbPathOut = len;
1199
1200 if (lpszPath && cbPathMax > len)
1201 {
1202 lstrcpyW(lpszPath, path);
1203 return TRUE;
1204 }
1205 return FALSE;
1206}
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2331

Referenced by SQLInstallDriverManager().

◆ SQLInstallDriverW()

BOOL INSTAPI SQLInstallDriverW ( LPCWSTR  lpszInfFile,
LPCWSTR  lpszDriver,
LPWSTR  lpszPath,
WORD  cbPathMax,
WORD *  pcbPathOut 
)

Definition at line 962 of file odbccp32.c.

964{
965 DWORD usage;
966
967 clear_errors();
968 TRACE("%s %s %p %d %p\n", debugstr_w(lpszInfFile),
969 debugstr_w(lpszDriver), lpszPath, cbPathMax, pcbPathOut);
970
971 if (lpszInfFile)
972 return FALSE;
973
974 return SQLInstallDriverExW(lpszDriver, NULL, lpszPath, cbPathMax,
975 pcbPathOut, ODBC_INSTALL_COMPLETE, &usage);
976}

◆ SQLInstallerError()

SQLRETURN INSTAPI SQLInstallerError ( WORD  iError,
DWORD *  pfErrorCode,
LPSTR  lpszErrorMsg,
WORD  cbErrorMsgMax,
WORD *  pcbErrorMsg 
)

Definition at line 1321 of file odbccp32.c.

1323{
1324 SQLRETURN ret;
1325 LPWSTR wbuf;
1326 WORD cbwbuf;
1327 TRACE("%d %p %p %d %p\n", iError, pfErrorCode, lpszErrorMsg,
1328 cbErrorMsgMax, pcbErrorMsg);
1329
1330 wbuf = 0;
1331 if (lpszErrorMsg && cbErrorMsgMax)
1332 {
1333 wbuf = malloc(cbErrorMsgMax * sizeof(WCHAR));
1334 if (!wbuf)
1335 return SQL_ERROR;
1336 }
1337 ret = SQLInstallerErrorW(iError, pfErrorCode, wbuf, cbErrorMsgMax, &cbwbuf);
1338 if (wbuf)
1339 {
1340 WORD cbBuf = 0;
1341 SQLInstall_narrow(1, lpszErrorMsg, wbuf, cbwbuf+1, cbErrorMsgMax, &cbBuf);
1342 free(wbuf);
1343 if (pcbErrorMsg)
1344 *pcbErrorMsg = cbBuf-1;
1345 }
1346 return ret;
1347}
#define malloc
Definition: debug_ros.c:4
#define SQL_ERROR
Definition: sql.h:68
SQLSMALLINT SQLRETURN
Definition: sqltypes.h:38
static BOOL SQLInstall_narrow(int mode, LPSTR buffer, LPCWSTR str, WORD str_length, WORD buffer_length, WORD *returned_length)
Definition: odbccp32.c:190
SQLRETURN WINAPI SQLInstallerErrorW(WORD iError, DWORD *pfErrorCode, LPWSTR lpszErrorMsg, WORD cbErrorMsgMax, WORD *pcbErrorMsg)
Definition: odbccp32.c:1262

Referenced by check_error_(), test_SQLConfigDataSource(), and test_SQLInstallerError().

◆ SQLInstallerErrorW()

SQLRETURN INSTAPI SQLInstallerErrorW ( WORD  iError,
DWORD *  pfErrorCode,
LPWSTR  lpszErrorMsg,
WORD  cbErrorMsgMax,
WORD *  pcbErrorMsg 
)

Definition at line 1262 of file odbccp32.c.

1264{
1265 TRACE("%d %p %p %d %p\n", iError, pfErrorCode, lpszErrorMsg,
1266 cbErrorMsgMax, pcbErrorMsg);
1267
1268 if (iError == 0)
1269 {
1270 return SQL_ERROR;
1271 }
1272 else if (iError <= num_errors)
1273 {
1274 BOOL truncated = FALSE;
1275 WORD len;
1276 LPCWSTR msg;
1277 iError--;
1278 if (pfErrorCode)
1279 *pfErrorCode = error_code[iError];
1280 msg = error_msg[iError];
1281 len = msg ? lstrlenW(msg) : 0;
1282 if (pcbErrorMsg)
1283 *pcbErrorMsg = len;
1284 len++;
1285 if (cbErrorMsgMax < len)
1286 {
1287 len = cbErrorMsgMax;
1288 truncated = TRUE;
1289 }
1290 if (lpszErrorMsg && len)
1291 {
1292 if (msg)
1293 {
1294 memcpy (lpszErrorMsg, msg, len * sizeof(WCHAR));
1295 }
1296 else
1297 {
1298 assert(len==1);
1299 *lpszErrorMsg = 0;
1300 }
1301 }
1302 else
1303 {
1304 /* Yes. If you pass a null pointer and a large length it is not an error! */
1305 truncated = TRUE;
1306 }
1307
1308 return truncated ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS;
1309 }
1310
1311 /* At least on Windows 2000 , the buffers are not altered in this case. However that is a little too dangerous a test for just now */
1312 if (pcbErrorMsg)
1313 *pcbErrorMsg = 0;
1314
1315 if (lpszErrorMsg && cbErrorMsgMax > 0)
1316 *lpszErrorMsg = '\0';
1317
1318 return SQL_NO_DATA;
1319}
#define assert(_expr)
Definition: assert.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define SQL_SUCCESS
Definition: sql.h:163
#define SQL_SUCCESS_WITH_INFO
Definition: sql.h:164
#define SQL_NO_DATA
Definition: sql.h:315
const uint16_t * LPCWSTR
Definition: typedefs.h:57
static int error_code[8]
Definition: odbccp32.c:53
static const WCHAR * error_msg[8]
Definition: odbccp32.c:54
static int num_errors
Definition: odbccp32.c:52

Referenced by SQLInstallerError(), test_SQLConfigMode(), test_SQLGetInstalledDrivers(), test_SQLGetPrivateProfileStringW(), test_SQLInstallDriverEx(), test_SQLInstallDriverManager(), test_SQLInstallTranslatorEx(), and test_SQLWritePrivateProfileString().

◆ SQLInstallODBC()

BOOL INSTAPI SQLInstallODBC ( HWND  hwndParent,
LPCSTR  lpszInfFile,
LPCSTR  lpszSrcPath,
LPCSTR  lpszDrivers 
)

Definition at line 1252 of file odbccp32.c.

1254{
1255 clear_errors();
1256 FIXME("%p %s %s %s\n", hwndParent, debugstr_a(lpszInfFile),
1257 debugstr_a(lpszSrcPath), debugstr_a(lpszDrivers));
1259 return FALSE;
1260}

◆ SQLInstallODBCW()

BOOL INSTAPI SQLInstallODBCW ( HWND  hwndParent,
LPCWSTR  lpszInfFile,
LPCWSTR  lpszSrcPath,
LPCWSTR  lpszDrivers 
)

Definition at line 1242 of file odbccp32.c.

1244{
1245 clear_errors();
1246 FIXME("%p %s %s %s\n", hwndParent, debugstr_w(lpszInfFile),
1247 debugstr_w(lpszSrcPath), debugstr_w(lpszDrivers));
1249 return FALSE;
1250}

◆ SQLInstallTranslator()

BOOL INSTAPI SQLInstallTranslator ( LPCSTR  lpszInfFile,
LPCSTR  lpszTranslator,
LPCSTR  lpszPathIn,
LPSTR  lpszPathOut,
WORD  cbPathOutMax,
WORD *  pcbPathOut,
WORD  fRequest,
LPDWORD  lpdwUsageCount 
)

Definition at line 1424 of file odbccp32.c.

1427{
1428 clear_errors();
1429 TRACE("%s %s %s %p %d %p %d %p\n", debugstr_a(lpszInfFile),
1430 debugstr_a(lpszTranslator), debugstr_a(lpszPathIn), lpszPathOut,
1431 cbPathOutMax, pcbPathOut, fRequest, lpdwUsageCount);
1432
1433 if (lpszInfFile)
1434 return FALSE;
1435
1436 return SQLInstallTranslatorEx(lpszTranslator, lpszPathIn, lpszPathOut,
1437 cbPathOutMax, pcbPathOut, fRequest, lpdwUsageCount);
1438}
BOOL WINAPI SQLInstallTranslatorEx(LPCSTR lpszTranslator, LPCSTR lpszPathIn, LPSTR lpszPathOut, WORD cbPathOutMax, WORD *pcbPathOut, WORD fRequest, LPDWORD lpdwUsageCount)
Definition: odbccp32.c:1376

◆ SQLInstallTranslatorEx()

BOOL INSTAPI SQLInstallTranslatorEx ( LPCSTR  lpszTranslator,
LPCSTR  lpszPathIn,
LPSTR  lpszPathOut,
WORD  cbPathOutMax,
WORD *  pcbPathOut,
WORD  fRequest,
LPDWORD  lpdwUsageCount 
)

Definition at line 1376 of file odbccp32.c.

1379{
1380 LPCSTR p;
1381 LPWSTR translator, pathin;
1382 WCHAR pathout[MAX_PATH];
1383 BOOL ret;
1384 WORD cbOut = 0;
1385
1386 clear_errors();
1387 TRACE("%s %s %p %d %p %d %p\n", debugstr_a(lpszTranslator),
1388 debugstr_a(lpszPathIn), lpszPathOut, cbPathOutMax, pcbPathOut,
1389 fRequest, lpdwUsageCount);
1390
1391 for (p = lpszTranslator; *p; p += lstrlenA(p) + 1)
1392 TRACE("%s\n", debugstr_a(p));
1393
1394 translator = SQLInstall_strdup_multi(lpszTranslator);
1395 pathin = SQLInstall_strdup(lpszPathIn);
1396
1397 ret = SQLInstallTranslatorExW(translator, pathin, pathout, MAX_PATH,
1398 &cbOut, fRequest, lpdwUsageCount);
1399 if (ret)
1400 {
1401 int len = WideCharToMultiByte(CP_ACP, 0, pathout, -1, lpszPathOut,
1402 0, NULL, NULL);
1403 if (len)
1404 {
1405 if (pcbPathOut)
1406 *pcbPathOut = len - 1;
1407
1408 if (!lpszPathOut || cbPathOutMax < len)
1409 {
1410 ret = FALSE;
1411 goto out;
1412 }
1413 len = WideCharToMultiByte(CP_ACP, 0, pathout, -1, lpszPathOut,
1414 cbPathOutMax, NULL, NULL);
1415 }
1416 }
1417
1418out:
1419 free(translator);
1420 free(pathin);
1421 return ret;
1422}
const char * LPCSTR
Definition: typedefs.h:52
BOOL WINAPI SQLInstallTranslatorExW(LPCWSTR lpszTranslator, LPCWSTR lpszPathIn, LPWSTR lpszPathOut, WORD cbPathOutMax, WORD *pcbPathOut, WORD fRequest, LPDWORD lpdwUsageCount)
Definition: odbccp32.c:1349

Referenced by SQLInstallTranslator(), and test_SQLInstallTranslatorEx().

◆ SQLInstallTranslatorExW()

BOOL INSTAPI SQLInstallTranslatorExW ( LPCWSTR  lpszTranslator,
LPCWSTR  lpszPathIn,
LPWSTR  lpszPathOut,
WORD  cbPathOutMax,
WORD *  pcbPathOut,
WORD  fRequest,
LPDWORD  lpdwUsageCount 
)

Definition at line 1349 of file odbccp32.c.

1352{
1353 UINT len;
1355
1356 clear_errors();
1357 TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszTranslator),
1358 debugstr_w(lpszPathIn), lpszPathOut, cbPathOutMax, pcbPathOut,
1359 fRequest, lpdwUsageCount);
1360
1361 write_registry_values(L"ODBC Translators", lpszTranslator, lpszPathIn, path, lpdwUsageCount);
1362
1363 len = lstrlenW(path);
1364
1365 if (pcbPathOut)
1366 *pcbPathOut = len;
1367
1368 if (lpszPathOut && cbPathOutMax > len)
1369 {
1370 lstrcpyW(lpszPathOut, path);
1371 return TRUE;
1372 }
1373 return FALSE;
1374}

Referenced by ITERATE_InstallODBCTranslator(), SQLInstallTranslatorEx(), and SQLInstallTranslatorW().

◆ SQLInstallTranslatorW()

BOOL INSTAPI SQLInstallTranslatorW ( LPCWSTR  lpszInfFile,
LPCWSTR  lpszTranslator,
LPCWSTR  lpszPathIn,
LPWSTR  lpszPathOut,
WORD  cbPathOutMax,
WORD *  pcbPathOut,
WORD  fRequest,
LPDWORD  lpdwUsageCount 
)

Definition at line 1440 of file odbccp32.c.

1443{
1444 clear_errors();
1445 TRACE("%s %s %s %p %d %p %d %p\n", debugstr_w(lpszInfFile),
1446 debugstr_w(lpszTranslator), debugstr_w(lpszPathIn), lpszPathOut,
1447 cbPathOutMax, pcbPathOut, fRequest, lpdwUsageCount);
1448
1449 if (lpszInfFile)
1450 return FALSE;
1451
1452 return SQLInstallTranslatorExW(lpszTranslator, lpszPathIn, lpszPathOut,
1453 cbPathOutMax, pcbPathOut, fRequest, lpdwUsageCount);
1454}

◆ SQLManageDataSources()

BOOL INSTAPI SQLManageDataSources ( HWND  hwnd)

Definition at line 1456 of file odbccp32.c.

1457{
1458 clear_errors();
1459 FIXME("%p\n", hwnd);
1461 return FALSE;
1462}

◆ SQLPostInstallerError()

SQLRETURN INSTAPI SQLPostInstallerError ( DWORD  fErrorCode,
LPCSTR  szErrorMsg 
)

Definition at line 1471 of file odbccp32.c.

1472{
1473 FIXME("%lu %s\n", fErrorCode, debugstr_a(szErrorMsg));
1475 return FALSE;
1476}

◆ SQLPostInstallerErrorW()

SQLRETURN INSTAPI SQLPostInstallerErrorW ( DWORD  fErrorCode,
LPCWSTR  szErrorMsg 
)

Definition at line 1464 of file odbccp32.c.

1465{
1466 FIXME("%lu %s\n", fErrorCode, debugstr_w(szErrorMsg));
1468 return FALSE;
1469}

◆ SQLReadFileDSN()

BOOL INSTAPI SQLReadFileDSN ( LPCSTR  lpszFileName,
LPCSTR  lpszAppName,
LPCSTR  lpszKeyName,
LPSTR  lpszString,
WORD  cbString,
WORD *  pcbString 
)

Definition at line 1489 of file odbccp32.c.

1492{
1493 clear_errors();
1494 FIXME("%s %s %s %s %d %p\n", debugstr_a(lpszFileName), debugstr_a(lpszAppName),
1495 debugstr_a(lpszKeyName), debugstr_a(lpszString), cbString, pcbString);
1497 return FALSE;
1498}

◆ SQLReadFileDSNW()

BOOL INSTAPI SQLReadFileDSNW ( LPCWSTR  lpszFileName,
LPCWSTR  lpszAppName,
LPCWSTR  lpszKeyName,
LPWSTR  lpszString,
WORD  cbString,
WORD *  pcbString 
)

Definition at line 1478 of file odbccp32.c.

1481{
1482 clear_errors();
1483 FIXME("%s %s %s %s %d %p\n", debugstr_w(lpszFileName), debugstr_w(lpszAppName),
1484 debugstr_w(lpszKeyName), debugstr_w(lpszString), cbString, pcbString);
1486 return FALSE;
1487}

◆ SQLRemoveDefaultDataSource()

BOOL INSTAPI SQLRemoveDefaultDataSource ( void  )

Definition at line 1500 of file odbccp32.c.

1501{
1502 clear_errors();
1503 FIXME("\n");
1505 return FALSE;
1506}

◆ SQLRemoveDriver()

BOOL INSTAPI SQLRemoveDriver ( LPCSTR  lpszDriver,
BOOL  fRemoveDSN,
LPDWORD  lpdwUsageCount 
)

Definition at line 1563 of file odbccp32.c.

1565{
1566 WCHAR *driver;
1567 BOOL ret;
1568
1569 clear_errors();
1570 TRACE("%s %d %p\n", debugstr_a(lpszDriver), fRemoveDSN, lpdwUsageCount);
1571
1572 driver = SQLInstall_strdup(lpszDriver);
1573
1574 ret = SQLRemoveDriverW(driver, fRemoveDSN, lpdwUsageCount);
1575
1576 free(driver);
1577 return ret;
1578}
BOOL WINAPI SQLRemoveDriverW(LPCWSTR drivername, BOOL remove_dsn, LPDWORD usage_count)
Definition: odbccp32.c:1508

Referenced by test_SQLGetInstalledDrivers(), and test_SQLInstallDriverEx().

◆ SQLRemoveDriverManager()

BOOL INSTAPI SQLRemoveDriverManager ( LPDWORD  pdwUsageCount)

Definition at line 1580 of file odbccp32.c.

1581{
1582 clear_errors();
1583 FIXME("%p\n", pdwUsageCount);
1584 if (pdwUsageCount) *pdwUsageCount = 1;
1585 return TRUE;
1586}

◆ SQLRemoveDriverW()

BOOL INSTAPI SQLRemoveDriverW ( LPCWSTR  drivername,
BOOL  remove_dsn,
LPDWORD  usage_count 
)

Definition at line 1508 of file odbccp32.c.

1509{
1510 HKEY hkey;
1511 DWORD usagecount = 1;
1512
1513 clear_errors();
1514 TRACE("%s %d %p\n", debugstr_w(drivername), remove_dsn, usage_count);
1515
1516 if (RegOpenKeyW(HKEY_LOCAL_MACHINE, L"Software\\ODBC\\ODBCINST.INI\\", &hkey) == ERROR_SUCCESS)
1517 {
1518 HKEY hkeydriver;
1519
1520 if (RegOpenKeyW(hkey, drivername, &hkeydriver) == ERROR_SUCCESS)
1521 {
1522 DWORD size, type;
1523 DWORD count;
1524
1525 size = sizeof(usagecount);
1526 RegGetValueA(hkeydriver, NULL, "UsageCount", RRF_RT_DWORD, &type, &usagecount, &size);
1527 TRACE("Usage count %ld\n", usagecount);
1528 count = usagecount - 1;
1529 if (count)
1530 {
1531 if (RegSetValueExA(hkeydriver, "UsageCount", 0, REG_DWORD, (BYTE*)&count, sizeof(count)) != ERROR_SUCCESS)
1532 ERR("Failed to write registry UsageCount key\n");
1533 }
1534
1535 RegCloseKey(hkeydriver);
1536 }
1537
1538 if (usagecount)
1539 usagecount--;
1540
1541 if (!usagecount)
1542 {
1543 if (RegDeleteKeyW(hkey, drivername) != ERROR_SUCCESS)
1544 ERR("Failed to delete registry key: %s\n", debugstr_w(drivername));
1545
1546 if (RegOpenKeyW(hkey, L"ODBC Drivers", &hkeydriver) == ERROR_SUCCESS)
1547 {
1548 if(RegDeleteValueW(hkeydriver, drivername) != ERROR_SUCCESS)
1549 ERR("Failed to delete registry value: %s\n", debugstr_w(drivername));
1550 RegCloseKey(hkeydriver);
1551 }
1552 }
1553
1554 RegCloseKey(hkey);
1555 }
1556
1557 if (usage_count)
1558 *usage_count = usagecount;
1559
1560 return TRUE;
1561}
LONG WINAPI RegSetValueExA(HKEY hKey, LPCSTR lpValueName, DWORD Reserved, DWORD dwType, CONST BYTE *lpData, DWORD cbData)
Definition: reg.c:4799
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
LONG WINAPI RegDeleteKeyW(_In_ HKEY hKey, _In_ LPCWSTR lpSubKey)
Definition: reg.c:1239
LONG WINAPI RegDeleteValueW(HKEY hKey, LPCWSTR lpValueName)
Definition: reg.c:2330
GLuint GLuint GLsizei count
Definition: gl.h:1545
#define REG_DWORD
Definition: sdbapi.c:615
#define RRF_RT_DWORD
Definition: winreg.h:64
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ITERATE_RemoveODBCDriver(), and SQLRemoveDriver().

◆ SQLRemoveDSNFromIni()

BOOL INSTAPI SQLRemoveDSNFromIni ( LPCSTR  lpszDSN)

Definition at line 1640 of file odbccp32.c.

1641{
1642 BOOL ret = FALSE;
1643 WCHAR *dsn;
1644
1645 TRACE("%s\n", debugstr_a(lpszDSN));
1646
1647 clear_errors();
1648
1649 dsn = SQLInstall_strdup(lpszDSN);
1650 if (dsn)
1652 else
1653 push_error(ODBC_ERROR_OUT_OF_MEM, L"Out of memory");
1654
1655 free(dsn);
1656
1657 return ret;
1658}
BOOL WINAPI SQLRemoveDSNFromIniW(LPCWSTR lpszDSN)
Definition: odbccp32.c:1588

Referenced by test_SQLWriteDSNToIni().

◆ SQLRemoveDSNFromIniW()

BOOL INSTAPI SQLRemoveDSNFromIniW ( LPCWSTR  lpszDSN)

Definition at line 1588 of file odbccp32.c.

1589{
1590 HKEY hkey, hkeyroot = HKEY_CURRENT_USER;
1591
1592 TRACE("%s\n", debugstr_w(lpszDSN));
1593
1594 if (!SQLValidDSNW(lpszDSN))
1595 {
1596 push_error(ODBC_ERROR_INVALID_DSN, L"Invalid DSN");
1597 return FALSE;
1598 }
1599
1600 clear_errors();
1601
1603 hkeyroot = HKEY_LOCAL_MACHINE;
1604 else if (config_mode == ODBC_BOTH_DSN)
1605 {
1606 WCHAR *regpath = malloc( (wcslen(L"Software\\ODBC\\ODBC.INI\\") + wcslen(lpszDSN) + 1) * sizeof(WCHAR) );
1607 if (!regpath)
1608 {
1609 push_error(ODBC_ERROR_OUT_OF_MEM, L"Out of memory");
1610 return FALSE;
1611 }
1612 wcscpy(regpath, L"Software\\ODBC\\ODBC.INI\\");
1613 wcscat(regpath, lpszDSN);
1614
1615 /* ONLY removes one DSN, USER or SYSTEM */
1616 if (RegOpenKeyW(HKEY_CURRENT_USER, regpath, &hkey) == ERROR_SUCCESS)
1617 hkeyroot = HKEY_CURRENT_USER;
1618 else
1619 hkeyroot = HKEY_LOCAL_MACHINE;
1620
1621 RegCloseKey(hkey);
1622 free(regpath);
1623 }
1624
1625 if (RegOpenKeyW(hkeyroot, L"Software\\ODBC\\ODBC.INI\\ODBC Data Sources", &hkey) == ERROR_SUCCESS)
1626 {
1627 RegDeleteValueW(hkey, lpszDSN);
1628 RegCloseKey(hkey);
1629 }
1630
1631 if (RegOpenKeyW(hkeyroot, L"Software\\ODBC\\ODBC.INI", &hkey) == ERROR_SUCCESS)
1632 {
1633 RegDeleteTreeW(hkey, lpszDSN);
1634 RegCloseKey(hkey);
1635 }
1636
1637 return TRUE;
1638}
LSTATUS WINAPI RegDeleteTreeW(_In_ HKEY, _In_opt_ LPCWSTR)
_ACRTIMP size_t __cdecl wcslen(const wchar_t *)
Definition: wcs.c:2988
#define ODBC_ERROR_INVALID_DSN
Definition: odbcinst.h:39
#define ODBC_BOTH_DSN
Definition: odbcinst.h:28
wcscat
wcscpy
BOOL WINAPI SQLValidDSNW(LPCWSTR lpszDSN)
Definition: odbccp32.c:1757

Referenced by SQLRemoveDSNFromIni(), and test_SQLWriteDSNToIni().

◆ SQLRemoveTranslator()

BOOL INSTAPI SQLRemoveTranslator ( LPCSTR  lpszTranslator,
LPDWORD  lpdwUsageCount 
)

Definition at line 1725 of file odbccp32.c.

1726{
1727 WCHAR *translator;
1728 BOOL ret;
1729
1730 clear_errors();
1731 TRACE("%s %p\n", debugstr_a(lpszTranslator), lpdwUsageCount);
1732
1733 translator = SQLInstall_strdup(lpszTranslator);
1734 ret = SQLRemoveTranslatorW(translator, lpdwUsageCount);
1735
1736 free(translator);
1737 return ret;
1738}
BOOL WINAPI SQLRemoveTranslatorW(const WCHAR *translator, DWORD *usage_count)
Definition: odbccp32.c:1660

Referenced by test_SQLInstallTranslatorEx().

◆ SQLRemoveTranslatorW()

BOOL INSTAPI SQLRemoveTranslatorW ( LPCWSTR  ,
LPDWORD   
)

◆ SQLSetConfigMode()

BOOL INSTAPI SQLSetConfigMode ( UWORD  wConfigMode)

Definition at line 1740 of file odbccp32.c.

1741{
1742 clear_errors();
1743 TRACE("%u\n", wConfigMode);
1744
1745 if (wConfigMode > ODBC_SYSTEM_DSN)
1746 {
1747 push_error(ODBC_ERROR_INVALID_PARAM_SEQUENCE, L"Invalid parameter sequence");
1748 return FALSE;
1749 }
1750 else
1751 {
1752 config_mode = wConfigMode;
1753 return TRUE;
1754 }
1755}
#define ODBC_ERROR_INVALID_PARAM_SEQUENCE
Definition: odbcinst.h:44

Referenced by test_SQLConfigMode(), test_SQLGetPrivateProfileStringW(), and test_SQLWriteDSNToIni().

◆ SQLValidDSN()

BOOL INSTAPI SQLValidDSN ( LPCSTR  lpszDSN)

Definition at line 1770 of file odbccp32.c.

1771{
1772 static const char *invalid = "[]{}(),;?*=!@\\";
1773 clear_errors();
1774 TRACE("%s\n", debugstr_a(lpszDSN));
1775
1776 if (!lpszDSN || !*lpszDSN || strlen(lpszDSN) > SQL_MAX_DSN_LENGTH || strpbrk(lpszDSN, invalid))
1777 {
1778 return FALSE;
1779 }
1780
1781 return TRUE;
1782}
_ACRTIMP char *__cdecl strpbrk(const char *, const char *)
Definition: string.c:3530
#define SQL_MAX_DSN_LENGTH
Definition: sqlext.h:320

Referenced by test_SQLValidDSN().

◆ SQLValidDSNW()

BOOL INSTAPI SQLValidDSNW ( LPCWSTR  lpszDSN)

Definition at line 1757 of file odbccp32.c.

1758{
1759 clear_errors();
1760 TRACE("%s\n", debugstr_w(lpszDSN));
1761
1762 if (!lpszDSN || !*lpszDSN || lstrlenW(lpszDSN) > SQL_MAX_DSN_LENGTH || wcspbrk(lpszDSN, L"[]{}(),;?*=!@\\"))
1763 {
1764 return FALSE;
1765 }
1766
1767 return TRUE;
1768}
_ACRTIMP wchar_t *__cdecl wcspbrk(const wchar_t *, const wchar_t *)
Definition: wcs.c:2021

Referenced by SQLRemoveDSNFromIniW(), SQLWriteDSNToIniW(), and test_SQLValidDSNW().

◆ SQLWriteDSNToIni()

BOOL INSTAPI SQLWriteDSNToIni ( LPCSTR  lpszDSN,
LPCSTR  lpszDriver 
)

Definition at line 1863 of file odbccp32.c.

1864{
1865 BOOL ret = FALSE;
1866 WCHAR *dsn, *driver;
1867
1868 TRACE("%s %s\n", debugstr_a(lpszDSN), debugstr_a(lpszDriver));
1869
1870 dsn = SQLInstall_strdup(lpszDSN);
1871 driver = SQLInstall_strdup(lpszDriver);
1872 if (dsn && driver)
1874 else
1875 push_error(ODBC_ERROR_OUT_OF_MEM, L"Out of memory");
1876
1877 free(dsn);
1878 free(driver);
1879
1880 return ret;
1881}
BOOL WINAPI SQLWriteDSNToIniW(LPCWSTR lpszDSN, LPCWSTR lpszDriver)
Definition: odbccp32.c:1784

Referenced by test_SQLWriteDSNToIni().

◆ SQLWriteDSNToIniW()

BOOL INSTAPI SQLWriteDSNToIniW ( LPCWSTR  lpszDSN,
LPCWSTR  lpszDriver 
)

Definition at line 1784 of file odbccp32.c.

1785{
1786 DWORD ret;
1787 HKEY hkey, hkeydriver, hkeyroot = HKEY_CURRENT_USER;
1789
1790 TRACE("%s %s\n", debugstr_w(lpszDSN), debugstr_w(lpszDriver));
1791
1792 clear_errors();
1793
1794 if (!SQLValidDSNW(lpszDSN))
1795 {
1796 push_error(ODBC_ERROR_INVALID_DSN, L"Invalid DSN");
1797 return FALSE;
1798 }
1799
1800 /* It doesn't matter if we cannot find the driver, windows just writes a blank value. */
1801 filename[0] = 0;
1802 if (RegOpenKeyW(HKEY_LOCAL_MACHINE, L"Software\\ODBC\\ODBCINST.INI\\", &hkey) == ERROR_SUCCESS)
1803 {
1804 HKEY hkeydriver;
1805
1806 if (RegOpenKeyW(hkey, lpszDriver, &hkeydriver) == ERROR_SUCCESS)
1807 {
1808 DWORD size = MAX_PATH * sizeof(WCHAR);
1809 RegGetValueW(hkeydriver, NULL, L"driver", RRF_RT_REG_SZ, NULL, filename, &size);
1810 RegCloseKey(hkeydriver);
1811 }
1812 RegCloseKey(hkey);
1813 }
1814
1816 hkeyroot = HKEY_LOCAL_MACHINE;
1817 else if (config_mode == ODBC_BOTH_DSN)
1818 {
1819 WCHAR *regpath = malloc( (wcslen(L"Software\\ODBC\\ODBC.INI\\") + wcslen(lpszDSN) + 1) * sizeof(WCHAR) );
1820 if (!regpath)
1821 {
1822 push_error(ODBC_ERROR_OUT_OF_MEM, L"Out of memory");
1823 return FALSE;
1824 }
1825 wcscpy(regpath, L"Software\\ODBC\\ODBC.INI\\");
1826 wcscat(regpath, lpszDSN);
1827
1828 /* Check for existing entry */
1829 if (RegOpenKeyW(HKEY_LOCAL_MACHINE, regpath, &hkey) == ERROR_SUCCESS)
1830 hkeyroot = HKEY_LOCAL_MACHINE;
1831 else
1832 hkeyroot = HKEY_CURRENT_USER;
1833
1834 RegCloseKey(hkey);
1835 free(regpath);
1836 }
1837
1838 if ((ret = RegCreateKeyW(hkeyroot, L"SOFTWARE\\ODBC\\ODBC.INI", &hkey)) == ERROR_SUCCESS)
1839 {
1840 HKEY sources;
1841
1842 if ((ret = RegCreateKeyW(hkey, L"ODBC Data Sources", &sources)) == ERROR_SUCCESS)
1843 {
1844 RegSetValueExW(sources, lpszDSN, 0, REG_SZ, (BYTE*)lpszDriver, (lstrlenW(lpszDriver)+1)*sizeof(WCHAR));
1846
1847 RegDeleteTreeW(hkey, lpszDSN);
1848 if ((ret = RegCreateKeyW(hkey, lpszDSN, &hkeydriver)) == ERROR_SUCCESS)
1849 {
1850 RegSetValueExW(sources, L"driver", 0, REG_SZ, (BYTE*)filename, (lstrlenW(filename)+1)*sizeof(WCHAR));
1851 RegCloseKey(hkeydriver);
1852 }
1853 }
1854 RegCloseKey(hkey);
1855 }
1856
1857 if (ret != ERROR_SUCCESS)
1858 push_error(ODBC_ERROR_REQUEST_FAILED, L"Request Failed");
1859
1860 return ret == ERROR_SUCCESS;
1861}
#define REG_SZ
Definition: layer.c:22
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1201
GLsizei GLenum * sources
Definition: glext.h:7753

Referenced by SQLWriteDSNToIni().

◆ SQLWriteFileDSN()

BOOL INSTAPI SQLWriteFileDSN ( LPCSTR  lpszFileName,
LPCSTR  lpszAppName,
LPCSTR  lpszKeyName,
LPCSTR  lpszString 
)

Definition at line 1893 of file odbccp32.c.

1895{
1896 clear_errors();
1897 FIXME("%s %s %s %s\n", debugstr_a(lpszFileName), debugstr_a(lpszAppName),
1898 debugstr_a(lpszKeyName), debugstr_a(lpszString));
1900 return FALSE;
1901}

◆ SQLWriteFileDSNW()

BOOL INSTAPI SQLWriteFileDSNW ( LPCWSTR  lpszFileName,
LPCWSTR  lpszAppName,
LPCWSTR  lpszKeyName,
LPCWSTR  lpszString 
)

Definition at line 1883 of file odbccp32.c.

1885{
1886 clear_errors();
1887 FIXME("%s %s %s %s\n", debugstr_w(lpszFileName), debugstr_w(lpszAppName),
1888 debugstr_w(lpszKeyName), debugstr_w(lpszString));
1890 return FALSE;
1891}

◆ SQLWritePrivateProfileString()

BOOL INSTAPI SQLWritePrivateProfileString ( LPCSTR  lpszSection,
LPCSTR  lpszEntry,
LPCSTR  lpszString,
LPCSTR  lpszFilename 
)

Definition at line 1961 of file odbccp32.c.

1963{
1964 BOOL ret;
1965 WCHAR *sect, *entry, *string, *file;
1966 clear_errors();
1967 TRACE("%s %s %s %s\n", lpszSection, lpszEntry, lpszString, lpszFilename);
1968
1969 sect = strdupAtoW(lpszSection);
1970 entry = strdupAtoW(lpszEntry);
1971 string = strdupAtoW(lpszString);
1972 file = strdupAtoW(lpszFilename);
1973
1974 ret = SQLWritePrivateProfileStringW(sect, entry, string, file);
1975
1976 free(sect);
1977 free(entry);
1978 free(string);
1979 free(file);
1980
1981 return ret;
1982}
char string[160]
Definition: util.h:11
Definition: fci.c:123
BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry, LPCWSTR lpszString, LPCWSTR lpszFilename)
Definition: odbccp32.c:1903

Referenced by test_SQLGetPrivateProfileString(), test_SQLGetPrivateProfileStringW(), and test_SQLWritePrivateProfileString().

◆ SQLWritePrivateProfileStringW()

BOOL INSTAPI SQLWritePrivateProfileStringW ( LPCWSTR  lpszSection,
LPCWSTR  lpszEntry,
LPCWSTR  lpszString,
LPCWSTR  lpszFilename 
)

Definition at line 1903 of file odbccp32.c.

1905{
1906 LONG ret;
1907 HKEY hkey;
1908 WCHAR *regpath;
1909
1910 clear_errors();
1911 TRACE("%s %s %s %s\n", debugstr_w(lpszSection), debugstr_w(lpszEntry),
1912 debugstr_w(lpszString), debugstr_w(lpszFilename));
1913
1914 if(!lpszFilename || !*lpszFilename)
1915 {
1916 push_error(ODBC_ERROR_INVALID_STR, L"Invalid parameter string");
1917 return FALSE;
1918 }
1919
1920 regpath = malloc ( (wcslen(L"Software\\ODBC\\") + wcslen(lpszFilename) + wcslen(L"\\")
1921 + wcslen(lpszSection) + 1) * sizeof(WCHAR));
1922 if (!regpath)
1923 {
1924 push_error(ODBC_ERROR_OUT_OF_MEM, L"Out of memory");
1925 return FALSE;
1926 }
1927 wcscpy(regpath, L"Software\\ODBC\\");
1928 wcscat(regpath, lpszFilename);
1929 wcscat(regpath, L"\\");
1930 wcscat(regpath, lpszSection);
1931
1932 /* odbcinit.ini is only for drivers, so default to local Machine */
1933 if (!wcsicmp(lpszFilename, L"ODBCINST.INI") || config_mode == ODBC_SYSTEM_DSN)
1934 ret = RegCreateKeyW(HKEY_LOCAL_MACHINE, regpath, &hkey);
1935 else if (config_mode == ODBC_USER_DSN)
1936 ret = RegCreateKeyW(HKEY_CURRENT_USER, regpath, &hkey);
1937 else
1938 {
1939 /* Check existing keys first */
1940 if ((ret = RegOpenKeyW(HKEY_CURRENT_USER, regpath, &hkey)) != ERROR_SUCCESS)
1941 ret = RegOpenKeyW(HKEY_LOCAL_MACHINE, regpath, &hkey);
1942
1943 if (ret != ERROR_SUCCESS)
1944 ret = RegCreateKeyW(HKEY_CURRENT_USER, regpath, &hkey);
1945 }
1946
1947 free(regpath);
1948
1949 if (ret == ERROR_SUCCESS)
1950 {
1951 if(lpszString)
1952 ret = RegSetValueExW(hkey, lpszEntry, 0, REG_SZ, (BYTE*)lpszString, (lstrlenW(lpszString)+1)*sizeof(WCHAR));
1953 else
1954 ret = RegSetValueExW(hkey, lpszEntry, 0, REG_SZ, (BYTE*)L"", sizeof(L""));
1955 RegCloseKey(hkey);
1956 }
1957
1958 return ret == ERROR_SUCCESS;
1959}
#define ODBC_ERROR_INVALID_STR
Definition: odbcinst.h:34

Referenced by SQLWritePrivateProfileString(), and test_SQLGetPrivateProfileStringW().