2 * Implementation of the ODBC driver installer
4 * Copyright 2005 Mike McCormack for CodeWeavers
5 * Copyright 2005 Hans Leidekker
6 * Copyright 2007 Bill Medland
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
32 #include "wine/debug.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(odbc
);
38 /* Registry key names */
39 static const WCHAR drivers_key
[] = {'S','o','f','t','w','a','r','e','\\','O','D','B','C','\\','O','D','B','C','I','N','S','T','.','I','N','I','\\','O','D','B','C',' ','D','r','i','v','e','r','s',0};
40 static const WCHAR odbcW
[] = {'S','o','f','t','w','a','r','e','\\','O','D','B','C',0};
42 /* This config mode is known to be process-wide.
43 * MSDN documentation suggests that the value is hidden somewhere in the registry but I haven't found it yet.
44 * Although both the registry and the ODBC.ini files appear to be maintained together they are not maintained automatically through the registry's IniFileMapping.
46 static UWORD config_mode
= ODBC_BOTH_DSN
;
48 /* MSDN documentation suggests that the error subsystem handles errors 1 to 8
49 * only and experimentation (Windows 2000) shows that the errors are process-
50 * wide so go for the simple solution; static arrays.
52 static int num_errors
;
53 static int error_code
[8];
54 static const WCHAR
*error_msg
[8];
55 static const WCHAR odbc_error_general_err
[] = {'G','e','n','e','r','a','l',' ','e','r','r','o','r',0};
56 static const WCHAR odbc_error_invalid_buff_len
[] = {'I','n','v','a','l','i','d',' ','b','u','f','f','e','r',' ','l','e','n','g','t','h',0};
57 static const WCHAR odbc_error_component_not_found
[] = {'C','o','m','p','o','n','e','n','t',' ','n','o','t',' ','f','o','u','n','d',0};
58 static const WCHAR odbc_error_out_of_mem
[] = {'O','u','t',' ','o','f',' ','m','e','m','o','r','y',0};
59 static const WCHAR odbc_error_invalid_param_sequence
[] = {'I','n','v','a','l','i','d',' ','p','a','r','a','m','e','t','e','r',' ','s','e','q','u','e','n','c','e',0};
60 static const WCHAR odbc_error_invalid_param_string
[] = {'I','n','v','a','l','i','d',' ','p','a','r','a','m','e','t','e','r',' ','s','t','r','i','n','g',0};
62 /* Push an error onto the error stack, taking care of ranges etc. */
63 static void push_error(int code
, LPCWSTR msg
)
65 if (num_errors
< sizeof error_code
/sizeof error_code
[0])
67 error_code
[num_errors
] = code
;
68 error_msg
[num_errors
] = msg
;
73 /* Clear the error stack */
74 static void clear_errors(void)
79 static inline void * heap_alloc(size_t len
)
81 return HeapAlloc(GetProcessHeap(), 0, len
);
84 static inline BOOL
heap_free(void *mem
)
86 return HeapFree(GetProcessHeap(), 0, mem
);
89 static inline WCHAR
*heap_strdupAtoW(const char *str
)
96 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
97 ret
= heap_alloc(len
*sizeof(WCHAR
));
99 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
106 BOOL WINAPI
ODBCCPlApplet( LONG i
, LONG j
, LONG
* p1
, LONG
* p2
)
109 FIXME( "( %d %d %p %p) : stub!\n", i
, j
, p1
, p2
);
113 static LPWSTR
SQLInstall_strdup_multi(LPCSTR str
)
122 for (p
= str
; *p
; p
+= lstrlenA(p
) + 1)
125 len
= MultiByteToWideChar(CP_ACP
, 0, str
, p
- str
, NULL
, 0 );
126 ret
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
127 MultiByteToWideChar(CP_ACP
, 0, str
, p
- str
, ret
, len
);
133 static LPWSTR
SQLInstall_strdup(LPCSTR str
)
141 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0 );
142 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
143 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
148 /* Convert the wide string or zero-length-terminated list of wide strings to a
149 * narrow string or zero-length-terminated list of narrow strings.
150 * Do not try to emulate windows undocumented excesses (e.g. adding a third \0
153 * mode Indicates the sort of string.
154 * 1 denotes that the buffers contain strings terminated by a single nul
156 * 2 denotes that the buffers contain zero-length-terminated lists
157 * (frequently erroneously referred to as double-null-terminated)
158 * buffer The narrow-character buffer into which to place the result. This
159 * must be a non-null pointer to the first element of a buffer whose
160 * length is passed in buffer_length.
161 * str The wide-character buffer containing the string or list of strings to
162 * be converted. str_length defines how many wide characters in the
163 * buffer are to be converted, including all desired terminating nul
165 * str_length Effective length of str
166 * buffer_length Length of buffer
167 * returned_length A pointer to a variable that will receive the number of
168 * narrow characters placed into the buffer. This pointer
171 static BOOL
SQLInstall_narrow(int mode
, LPSTR buffer
, LPCWSTR str
, WORD str_length
, WORD buffer_length
, WORD
*returned_length
)
173 LPSTR pbuf
; /* allows us to allocate a temporary buffer only if needed */
174 int len
; /* Length of the converted list */
175 BOOL success
= FALSE
;
176 assert(mode
== 1 || mode
== 2);
177 assert(buffer_length
);
178 len
= WideCharToMultiByte(CP_ACP
, 0, str
, str_length
, 0, 0, NULL
, NULL
);
181 if (len
> buffer_length
)
183 pbuf
= HeapAlloc(GetProcessHeap(), 0, len
);
189 len
= WideCharToMultiByte(CP_ACP
, 0, str
, str_length
, pbuf
, len
, NULL
, NULL
);
194 if (buffer_length
> (mode
- 1))
196 memcpy (buffer
, pbuf
, buffer_length
-mode
);
197 *(buffer
+buffer_length
-mode
) = '\0';
199 *(buffer
+buffer_length
-1) = '\0';
203 *returned_length
= pbuf
== buffer
? len
: buffer_length
;
209 ERR("transferring wide to narrow\n");
213 HeapFree(GetProcessHeap(), 0, pbuf
);
218 ERR("measuring wide to narrow\n");
223 BOOL WINAPI
SQLConfigDataSourceW(HWND hwndParent
, WORD fRequest
,
224 LPCWSTR lpszDriver
, LPCWSTR lpszAttributes
)
229 FIXME("%p %d %s %s\n", hwndParent
, fRequest
, debugstr_w(lpszDriver
),
230 debugstr_w(lpszAttributes
));
232 for (p
= lpszAttributes
; *p
; p
+= lstrlenW(p
) + 1)
233 FIXME("%s\n", debugstr_w(p
));
238 BOOL WINAPI
SQLConfigDataSource(HWND hwndParent
, WORD fRequest
,
239 LPCSTR lpszDriver
, LPCSTR lpszAttributes
)
241 FIXME("%p %d %s %s\n", hwndParent
, fRequest
, debugstr_a(lpszDriver
),
242 debugstr_a(lpszAttributes
));
247 BOOL WINAPI
SQLConfigDriverW(HWND hwndParent
, WORD fRequest
, LPCWSTR lpszDriver
,
248 LPCWSTR lpszArgs
, LPWSTR lpszMsg
, WORD cbMsgMax
, WORD
*pcbMsgOut
)
251 FIXME("(%p %d %s %s %p %d %p)\n", hwndParent
, fRequest
, debugstr_w(lpszDriver
),
252 debugstr_w(lpszArgs
), lpszMsg
, cbMsgMax
, pcbMsgOut
);
256 BOOL WINAPI
SQLConfigDriver(HWND hwndParent
, WORD fRequest
, LPCSTR lpszDriver
,
257 LPCSTR lpszArgs
, LPSTR lpszMsg
, WORD cbMsgMax
, WORD
*pcbMsgOut
)
260 FIXME("(%p %d %s %s %p %d %p)\n", hwndParent
, fRequest
, debugstr_a(lpszDriver
),
261 debugstr_a(lpszArgs
), lpszMsg
, cbMsgMax
, pcbMsgOut
);
265 BOOL WINAPI
SQLCreateDataSourceW(HWND hwnd
, LPCWSTR lpszDS
)
268 FIXME("%p %s\n", hwnd
, debugstr_w(lpszDS
));
269 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
273 BOOL WINAPI
SQLCreateDataSource(HWND hwnd
, LPCSTR lpszDS
)
276 FIXME("%p %s\n", hwnd
, debugstr_a(lpszDS
));
277 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
281 BOOL WINAPI
SQLGetAvailableDriversW(LPCWSTR lpszInfFile
, LPWSTR lpszBuf
,
282 WORD cbBufMax
, WORD
*pcbBufOut
)
285 FIXME("%s %p %d %p\n", debugstr_w(lpszInfFile
), lpszBuf
, cbBufMax
, pcbBufOut
);
286 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
290 BOOL WINAPI
SQLGetAvailableDrivers(LPCSTR lpszInfFile
, LPSTR lpszBuf
,
291 WORD cbBufMax
, WORD
*pcbBufOut
)
294 FIXME("%s %p %d %p\n", debugstr_a(lpszInfFile
), lpszBuf
, cbBufMax
, pcbBufOut
);
295 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
299 BOOL WINAPI
SQLGetConfigMode(UWORD
*pwConfigMode
)
302 TRACE("%p\n", pwConfigMode
);
304 *pwConfigMode
= config_mode
;
308 /* This is implemented sensibly rather than according to exact conformance to Microsoft's buggy implementations
309 * e.g. The Microsoft one occasionally actually adds a third nul character (possibly beyond the buffer).
310 * e.g. If the key has no drivers then version 3.525.1117.0 does not modify the buffer at all, not even a nul character.
312 BOOL WINAPI
SQLGetInstalledDriversW(LPWSTR lpszBuf
, WORD cbBufMax
,
315 HKEY hDrivers
; /* Registry handle to the Drivers key */
316 LONG reg_ret
; /* Return code from registry functions */
317 BOOL success
= FALSE
; /* The value we will return */
321 TRACE("%p %d %p\n", lpszBuf
, cbBufMax
, pcbBufOut
);
323 if (!lpszBuf
|| cbBufMax
== 0)
325 push_error(ODBC_ERROR_INVALID_BUFF_LEN
, odbc_error_invalid_buff_len
);
327 else if ((reg_ret
= RegOpenKeyExW (HKEY_LOCAL_MACHINE
/* The drivers does not depend on the config mode */,
328 drivers_key
, 0, KEY_READ
/* Maybe overkill */,
329 &hDrivers
)) == ERROR_SUCCESS
)
337 size_name
= cbBufMax
;
338 if ((reg_ret
= RegEnumValueW(hDrivers
, index
, lpszBuf
, &size_name
, NULL
, NULL
, NULL
, NULL
)) == ERROR_SUCCESS
)
341 assert (size_name
< cbBufMax
&& *(lpszBuf
+ size_name
) == 0);
343 cbBufMax
-= size_name
;
348 if (reg_ret
!= ERROR_NO_MORE_ITEMS
)
351 push_error(ODBC_ERROR_GENERAL_ERR
, odbc_error_general_err
);
357 if ((reg_ret
= RegCloseKey (hDrivers
)) != ERROR_SUCCESS
)
358 TRACE ("Error %d closing ODBC Drivers key\n", reg_ret
);
362 /* MSDN states that it returns failure with COMPONENT_NOT_FOUND in this case.
363 * Version 3.525.1117.0 (Windows 2000) does not; it actually returns success.
364 * I doubt if it will actually be an issue.
366 push_error(ODBC_ERROR_COMPONENT_NOT_FOUND
, odbc_error_component_not_found
);
371 BOOL WINAPI
SQLGetInstalledDrivers(LPSTR lpszBuf
, WORD cbBufMax
,
375 int size_wbuf
= cbBufMax
;
379 TRACE("%p %d %p\n", lpszBuf
, cbBufMax
, pcbBufOut
);
381 wbuf
= HeapAlloc(GetProcessHeap(), 0, size_wbuf
*sizeof(WCHAR
));
384 ret
= SQLGetInstalledDriversW(wbuf
, size_wbuf
, &size_used
);
387 if (!(ret
= SQLInstall_narrow(2, lpszBuf
, wbuf
, size_used
, cbBufMax
, pcbBufOut
)))
389 push_error(ODBC_ERROR_GENERAL_ERR
, odbc_error_general_err
);
392 HeapFree(GetProcessHeap(), 0, wbuf
);
393 /* ignore failure; we have achieved the aim */
397 push_error(ODBC_ERROR_OUT_OF_MEM
, odbc_error_out_of_mem
);
403 static HKEY
get_privateprofile_sectionkey(LPCWSTR section
, LPCWSTR filename
)
405 HKEY hkey
, hkeyfilename
, hkeysection
;
408 if (RegOpenKeyW(HKEY_CURRENT_USER
, odbcW
, &hkey
))
411 ret
= RegOpenKeyW(hkey
, filename
, &hkeyfilename
);
416 ret
= RegOpenKeyW(hkeyfilename
, section
, &hkeysection
);
417 RegCloseKey(hkeyfilename
);
419 return ret
? NULL
: hkeysection
;
422 int WINAPI
SQLGetPrivateProfileStringW(LPCWSTR section
, LPCWSTR entry
,
423 LPCWSTR defvalue
, LPWSTR buff
, int buff_len
, LPCWSTR filename
)
425 BOOL usedefault
= TRUE
;
429 TRACE("%s %s %s %p %d %s\n", debugstr_w(section
), debugstr_w(entry
),
430 debugstr_w(defvalue
), buff
, buff_len
, debugstr_w(filename
));
434 if (buff_len
<= 0 || !section
)
440 if (!defvalue
|| !buff
)
443 sectionkey
= get_privateprofile_sectionkey(section
, filename
);
450 size
= buff_len
* sizeof(*buff
);
451 if (RegGetValueW(sectionkey
, NULL
, entry
, RRF_RT_REG_SZ
, &type
, buff
, &size
) == ERROR_SUCCESS
)
454 ret
= (size
/ sizeof(*buff
)) - 1;
459 WCHAR name
[MAX_PATH
];
465 memset(buff
, 0, buff_len
);
467 namelen
= sizeof(name
);
468 while (RegEnumValueW(sectionkey
, index
, name
, &namelen
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
470 if ((ret
+ namelen
+1) > buff_len
)
473 lstrcpyW(buff
+ret
, name
);
475 namelen
= sizeof(name
);
480 RegCloseKey(sectionkey
);
483 usedefault
= entry
!= NULL
;
487 lstrcpynW(buff
, defvalue
, buff_len
);
488 ret
= lstrlenW(buff
);
494 int WINAPI
SQLGetPrivateProfileString(LPCSTR section
, LPCSTR entry
,
495 LPCSTR defvalue
, LPSTR buff
, int buff_len
, LPCSTR filename
)
497 WCHAR
*sectionW
, *filenameW
;
498 BOOL usedefault
= TRUE
;
502 TRACE("%s %s %s %p %d %s\n", debugstr_a(section
), debugstr_a(entry
),
503 debugstr_a(defvalue
), buff
, buff_len
, debugstr_a(filename
));
513 if (!section
|| !defvalue
|| !buff
)
516 sectionW
= heap_strdupAtoW(section
);
517 filenameW
= heap_strdupAtoW(filename
);
519 sectionkey
= get_privateprofile_sectionkey(sectionW
, filenameW
);
522 heap_free(filenameW
);
530 size
= buff_len
* sizeof(*buff
);
531 if (RegGetValueA(sectionkey
, NULL
, entry
, RRF_RT_REG_SZ
, &type
, buff
, &size
) == ERROR_SUCCESS
)
534 ret
= (size
/ sizeof(*buff
)) - 1;
539 char name
[MAX_PATH
] = {0};
545 memset(buff
, 0, buff_len
);
547 namelen
= sizeof(name
);
548 while (RegEnumValueA(sectionkey
, index
, name
, &namelen
, NULL
, NULL
, NULL
, NULL
) == ERROR_SUCCESS
)
550 if ((ret
+ namelen
+1) > buff_len
)
553 lstrcpyA(buff
+ret
, name
);
556 namelen
= sizeof(name
);
561 RegCloseKey(sectionkey
);
564 usedefault
= entry
!= NULL
;
568 lstrcpynA(buff
, defvalue
, buff_len
);
575 BOOL WINAPI
SQLGetTranslatorW(HWND hwndParent
, LPWSTR lpszName
, WORD cbNameMax
,
576 WORD
*pcbNameOut
, LPWSTR lpszPath
, WORD cbPathMax
,
577 WORD
*pcbPathOut
, DWORD
*pvOption
)
580 FIXME("%p %s %d %p %p %d %p %p\n", hwndParent
, debugstr_w(lpszName
), cbNameMax
,
581 pcbNameOut
, lpszPath
, cbPathMax
, pcbPathOut
, pvOption
);
582 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
586 BOOL WINAPI
SQLGetTranslator(HWND hwndParent
, LPSTR lpszName
, WORD cbNameMax
,
587 WORD
*pcbNameOut
, LPSTR lpszPath
, WORD cbPathMax
,
588 WORD
*pcbPathOut
, DWORD
*pvOption
)
591 FIXME("%p %s %d %p %p %d %p %p\n", hwndParent
, debugstr_a(lpszName
), cbNameMax
,
592 pcbNameOut
, lpszPath
, cbPathMax
, pcbPathOut
, pvOption
);
593 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
597 BOOL WINAPI
SQLInstallDriverW(LPCWSTR lpszInfFile
, LPCWSTR lpszDriver
,
598 LPWSTR lpszPath
, WORD cbPathMax
, WORD
* pcbPathOut
)
603 TRACE("%s %s %p %d %p\n", debugstr_w(lpszInfFile
),
604 debugstr_w(lpszDriver
), lpszPath
, cbPathMax
, pcbPathOut
);
609 return SQLInstallDriverExW(lpszDriver
, NULL
, lpszPath
, cbPathMax
,
610 pcbPathOut
, ODBC_INSTALL_COMPLETE
, &usage
);
613 BOOL WINAPI
SQLInstallDriver(LPCSTR lpszInfFile
, LPCSTR lpszDriver
,
614 LPSTR lpszPath
, WORD cbPathMax
, WORD
* pcbPathOut
)
619 TRACE("%s %s %p %d %p\n", debugstr_a(lpszInfFile
),
620 debugstr_a(lpszDriver
), lpszPath
, cbPathMax
, pcbPathOut
);
625 return SQLInstallDriverEx(lpszDriver
, NULL
, lpszPath
, cbPathMax
,
626 pcbPathOut
, ODBC_INSTALL_COMPLETE
, &usage
);
629 BOOL WINAPI
SQLInstallDriverExW(LPCWSTR lpszDriver
, LPCWSTR lpszPathIn
,
630 LPWSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
631 WORD fRequest
, LPDWORD lpdwUsageCount
)
635 WCHAR path
[MAX_PATH
];
638 TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszDriver
),
639 debugstr_w(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
640 fRequest
, lpdwUsageCount
);
642 for (p
= lpszDriver
; *p
; p
+= lstrlenW(p
) + 1)
643 TRACE("%s\n", debugstr_w(p
));
645 len
= GetSystemDirectoryW(path
, MAX_PATH
);
650 len
= GetSystemDirectoryW(path
, MAX_PATH
);
652 if (lpszPathOut
&& cbPathOutMax
> len
)
654 lstrcpyW(lpszPathOut
, path
);
660 BOOL WINAPI
SQLInstallDriverEx(LPCSTR lpszDriver
, LPCSTR lpszPathIn
,
661 LPSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
662 WORD fRequest
, LPDWORD lpdwUsageCount
)
665 LPWSTR driver
, pathin
;
666 WCHAR pathout
[MAX_PATH
];
671 TRACE("%s %s %p %d %p %d %p\n", debugstr_a(lpszDriver
),
672 debugstr_a(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
673 fRequest
, lpdwUsageCount
);
675 for (p
= lpszDriver
; *p
; p
+= lstrlenA(p
) + 1)
676 TRACE("%s\n", debugstr_a(p
));
678 driver
= SQLInstall_strdup_multi(lpszDriver
);
679 pathin
= SQLInstall_strdup(lpszPathIn
);
681 ret
= SQLInstallDriverExW(driver
, pathin
, pathout
, MAX_PATH
, &cbOut
,
682 fRequest
, lpdwUsageCount
);
685 int len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
690 *pcbPathOut
= len
- 1;
692 if (!lpszPathOut
|| cbPathOutMax
< len
)
697 len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
698 cbPathOutMax
, NULL
, NULL
);
703 HeapFree(GetProcessHeap(), 0, driver
);
704 HeapFree(GetProcessHeap(), 0, pathin
);
708 BOOL WINAPI
SQLInstallDriverManagerW(LPWSTR lpszPath
, WORD cbPathMax
,
712 WCHAR path
[MAX_PATH
];
714 TRACE("(%p %d %p)\n", lpszPath
, cbPathMax
, pcbPathOut
);
716 if (cbPathMax
< MAX_PATH
)
721 len
= GetSystemDirectoryW(path
, MAX_PATH
);
726 if (lpszPath
&& cbPathMax
> len
)
728 lstrcpyW(lpszPath
, path
);
734 BOOL WINAPI
SQLInstallDriverManager(LPSTR lpszPath
, WORD cbPathMax
,
739 WCHAR path
[MAX_PATH
];
741 TRACE("(%p %d %p)\n", lpszPath
, cbPathMax
, pcbPathOut
);
743 if (cbPathMax
< MAX_PATH
)
748 ret
= SQLInstallDriverManagerW(path
, MAX_PATH
, &cbOut
);
751 len
= WideCharToMultiByte(CP_ACP
, 0, path
, -1, lpszPath
, 0,
756 *pcbPathOut
= len
- 1;
758 if (!lpszPath
|| cbPathMax
< len
)
761 len
= WideCharToMultiByte(CP_ACP
, 0, path
, -1, lpszPath
,
762 cbPathMax
, NULL
, NULL
);
768 BOOL WINAPI
SQLInstallODBCW(HWND hwndParent
, LPCWSTR lpszInfFile
,
769 LPCWSTR lpszSrcPath
, LPCWSTR lpszDrivers
)
772 FIXME("%p %s %s %s\n", hwndParent
, debugstr_w(lpszInfFile
),
773 debugstr_w(lpszSrcPath
), debugstr_w(lpszDrivers
));
774 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
778 BOOL WINAPI
SQLInstallODBC(HWND hwndParent
, LPCSTR lpszInfFile
,
779 LPCSTR lpszSrcPath
, LPCSTR lpszDrivers
)
782 FIXME("%p %s %s %s\n", hwndParent
, debugstr_a(lpszInfFile
),
783 debugstr_a(lpszSrcPath
), debugstr_a(lpszDrivers
));
784 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
788 SQLRETURN WINAPI
SQLInstallerErrorW(WORD iError
, DWORD
*pfErrorCode
,
789 LPWSTR lpszErrorMsg
, WORD cbErrorMsgMax
, WORD
*pcbErrorMsg
)
791 TRACE("%d %p %p %d %p\n", iError
, pfErrorCode
, lpszErrorMsg
,
792 cbErrorMsgMax
, pcbErrorMsg
);
798 else if (iError
<= num_errors
)
800 BOOL truncated
= FALSE
;
805 *pfErrorCode
= error_code
[iError
];
806 msg
= error_msg
[iError
];
807 len
= msg
? lstrlenW(msg
) : 0;
811 if (cbErrorMsgMax
< len
)
816 if (lpszErrorMsg
&& len
)
820 memcpy (lpszErrorMsg
, msg
, len
* sizeof(WCHAR
));
830 /* Yes. If you pass a null pointer and a large length it is not an error! */
834 return truncated
? SQL_SUCCESS_WITH_INFO
: SQL_SUCCESS
;
837 /* 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 */
841 if (lpszErrorMsg
&& cbErrorMsgMax
> 0)
842 *lpszErrorMsg
= '\0';
847 SQLRETURN WINAPI
SQLInstallerError(WORD iError
, DWORD
*pfErrorCode
,
848 LPSTR lpszErrorMsg
, WORD cbErrorMsgMax
, WORD
*pcbErrorMsg
)
853 TRACE("%d %p %p %d %p\n", iError
, pfErrorCode
, lpszErrorMsg
,
854 cbErrorMsgMax
, pcbErrorMsg
);
857 if (lpszErrorMsg
&& cbErrorMsgMax
)
859 wbuf
= HeapAlloc(GetProcessHeap(), 0, cbErrorMsgMax
*sizeof(WCHAR
));
863 ret
= SQLInstallerErrorW(iError
, pfErrorCode
, wbuf
, cbErrorMsgMax
, &cbwbuf
);
867 SQLInstall_narrow(1, lpszErrorMsg
, wbuf
, cbwbuf
+1, cbErrorMsgMax
, &cbBuf
);
868 HeapFree(GetProcessHeap(), 0, wbuf
);
870 *pcbErrorMsg
= cbBuf
-1;
875 BOOL WINAPI
SQLInstallTranslatorExW(LPCWSTR lpszTranslator
, LPCWSTR lpszPathIn
,
876 LPWSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
877 WORD fRequest
, LPDWORD lpdwUsageCount
)
881 WCHAR path
[MAX_PATH
];
884 TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszTranslator
),
885 debugstr_w(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
886 fRequest
, lpdwUsageCount
);
888 for (p
= lpszTranslator
; *p
; p
+= lstrlenW(p
) + 1)
889 TRACE("%s\n", debugstr_w(p
));
891 len
= GetSystemDirectoryW(path
, MAX_PATH
);
896 if (lpszPathOut
&& cbPathOutMax
> len
)
898 lstrcpyW(lpszPathOut
, path
);
904 BOOL WINAPI
SQLInstallTranslatorEx(LPCSTR lpszTranslator
, LPCSTR lpszPathIn
,
905 LPSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
906 WORD fRequest
, LPDWORD lpdwUsageCount
)
909 LPWSTR translator
, pathin
;
910 WCHAR pathout
[MAX_PATH
];
915 TRACE("%s %s %p %d %p %d %p\n", debugstr_a(lpszTranslator
),
916 debugstr_a(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
917 fRequest
, lpdwUsageCount
);
919 for (p
= lpszTranslator
; *p
; p
+= lstrlenA(p
) + 1)
920 TRACE("%s\n", debugstr_a(p
));
922 translator
= SQLInstall_strdup_multi(lpszTranslator
);
923 pathin
= SQLInstall_strdup(lpszPathIn
);
925 ret
= SQLInstallTranslatorExW(translator
, pathin
, pathout
, MAX_PATH
,
926 &cbOut
, fRequest
, lpdwUsageCount
);
929 int len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
934 *pcbPathOut
= len
- 1;
936 if (!lpszPathOut
|| cbPathOutMax
< len
)
941 len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
942 cbPathOutMax
, NULL
, NULL
);
947 HeapFree(GetProcessHeap(), 0, translator
);
948 HeapFree(GetProcessHeap(), 0, pathin
);
952 BOOL WINAPI
SQLInstallTranslator(LPCSTR lpszInfFile
, LPCSTR lpszTranslator
,
953 LPCSTR lpszPathIn
, LPSTR lpszPathOut
, WORD cbPathOutMax
,
954 WORD
*pcbPathOut
, WORD fRequest
, LPDWORD lpdwUsageCount
)
957 TRACE("%s %s %s %p %d %p %d %p\n", debugstr_a(lpszInfFile
),
958 debugstr_a(lpszTranslator
), debugstr_a(lpszPathIn
), lpszPathOut
,
959 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
964 return SQLInstallTranslatorEx(lpszTranslator
, lpszPathIn
, lpszPathOut
,
965 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
968 BOOL WINAPI
SQLInstallTranslatorW(LPCWSTR lpszInfFile
, LPCWSTR lpszTranslator
,
969 LPCWSTR lpszPathIn
, LPWSTR lpszPathOut
, WORD cbPathOutMax
,
970 WORD
*pcbPathOut
, WORD fRequest
, LPDWORD lpdwUsageCount
)
973 TRACE("%s %s %s %p %d %p %d %p\n", debugstr_w(lpszInfFile
),
974 debugstr_w(lpszTranslator
), debugstr_w(lpszPathIn
), lpszPathOut
,
975 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
980 return SQLInstallTranslatorExW(lpszTranslator
, lpszPathIn
, lpszPathOut
,
981 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
984 BOOL WINAPI
SQLManageDataSources(HWND hwnd
)
988 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
992 SQLRETURN WINAPI
SQLPostInstallerErrorW(DWORD fErrorCode
, LPCWSTR szErrorMsg
)
994 FIXME("%u %s\n", fErrorCode
, debugstr_w(szErrorMsg
));
995 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
999 SQLRETURN WINAPI
SQLPostInstallerError(DWORD fErrorCode
, LPCSTR szErrorMsg
)
1001 FIXME("%u %s\n", fErrorCode
, debugstr_a(szErrorMsg
));
1002 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1006 BOOL WINAPI
SQLReadFileDSNW(LPCWSTR lpszFileName
, LPCWSTR lpszAppName
,
1007 LPCWSTR lpszKeyName
, LPWSTR lpszString
, WORD cbString
,
1011 FIXME("%s %s %s %s %d %p\n", debugstr_w(lpszFileName
), debugstr_w(lpszAppName
),
1012 debugstr_w(lpszKeyName
), debugstr_w(lpszString
), cbString
, pcbString
);
1013 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1017 BOOL WINAPI
SQLReadFileDSN(LPCSTR lpszFileName
, LPCSTR lpszAppName
,
1018 LPCSTR lpszKeyName
, LPSTR lpszString
, WORD cbString
,
1022 FIXME("%s %s %s %s %d %p\n", debugstr_a(lpszFileName
), debugstr_a(lpszAppName
),
1023 debugstr_a(lpszKeyName
), debugstr_a(lpszString
), cbString
, pcbString
);
1024 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1028 BOOL WINAPI
SQLRemoveDefaultDataSource(void)
1032 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1036 BOOL WINAPI
SQLRemoveDriverW(LPCWSTR lpszDriver
, BOOL fRemoveDSN
,
1037 LPDWORD lpdwUsageCount
)
1040 FIXME("%s %d %p\n", debugstr_w(lpszDriver
), fRemoveDSN
, lpdwUsageCount
);
1041 if (lpdwUsageCount
) *lpdwUsageCount
= 1;
1045 BOOL WINAPI
SQLRemoveDriver(LPCSTR lpszDriver
, BOOL fRemoveDSN
,
1046 LPDWORD lpdwUsageCount
)
1049 FIXME("%s %d %p\n", debugstr_a(lpszDriver
), fRemoveDSN
, lpdwUsageCount
);
1050 if (lpdwUsageCount
) *lpdwUsageCount
= 1;
1054 BOOL WINAPI
SQLRemoveDriverManager(LPDWORD pdwUsageCount
)
1057 FIXME("%p\n", pdwUsageCount
);
1058 if (pdwUsageCount
) *pdwUsageCount
= 1;
1062 BOOL WINAPI
SQLRemoveDSNFromIniW(LPCWSTR lpszDSN
)
1065 FIXME("%s\n", debugstr_w(lpszDSN
));
1066 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1070 BOOL WINAPI
SQLRemoveDSNFromIni(LPCSTR lpszDSN
)
1073 FIXME("%s\n", debugstr_a(lpszDSN
));
1074 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1078 BOOL WINAPI
SQLRemoveTranslatorW(LPCWSTR lpszTranslator
, LPDWORD lpdwUsageCount
)
1081 FIXME("%s %p\n", debugstr_w(lpszTranslator
), lpdwUsageCount
);
1082 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1086 BOOL WINAPI
SQLRemoveTranslator(LPCSTR lpszTranslator
, LPDWORD lpdwUsageCount
)
1089 FIXME("%s %p\n", debugstr_a(lpszTranslator
), lpdwUsageCount
);
1090 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1094 BOOL WINAPI
SQLSetConfigMode(UWORD wConfigMode
)
1097 TRACE("%u\n", wConfigMode
);
1099 if (wConfigMode
> ODBC_SYSTEM_DSN
)
1101 push_error(ODBC_ERROR_INVALID_PARAM_SEQUENCE
, odbc_error_invalid_param_sequence
);
1106 config_mode
= wConfigMode
;
1111 BOOL WINAPI
SQLValidDSNW(LPCWSTR lpszDSN
)
1114 FIXME("%s\n", debugstr_w(lpszDSN
));
1115 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1119 BOOL WINAPI
SQLValidDSN(LPCSTR lpszDSN
)
1122 FIXME("%s\n", debugstr_a(lpszDSN
));
1123 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1127 BOOL WINAPI
SQLWriteDSNToIniW(LPCWSTR lpszDSN
, LPCWSTR lpszDriver
)
1130 FIXME("%s %s\n", debugstr_w(lpszDSN
), debugstr_w(lpszDriver
));
1131 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1135 BOOL WINAPI
SQLWriteDSNToIni(LPCSTR lpszDSN
, LPCSTR lpszDriver
)
1138 FIXME("%s %s\n", debugstr_a(lpszDSN
), debugstr_a(lpszDriver
));
1139 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1143 BOOL WINAPI
SQLWriteFileDSNW(LPCWSTR lpszFileName
, LPCWSTR lpszAppName
,
1144 LPCWSTR lpszKeyName
, LPCWSTR lpszString
)
1147 FIXME("%s %s %s %s\n", debugstr_w(lpszFileName
), debugstr_w(lpszAppName
),
1148 debugstr_w(lpszKeyName
), debugstr_w(lpszString
));
1149 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1153 BOOL WINAPI
SQLWriteFileDSN(LPCSTR lpszFileName
, LPCSTR lpszAppName
,
1154 LPCSTR lpszKeyName
, LPCSTR lpszString
)
1157 FIXME("%s %s %s %s\n", debugstr_a(lpszFileName
), debugstr_a(lpszAppName
),
1158 debugstr_a(lpszKeyName
), debugstr_a(lpszString
));
1159 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1163 BOOL WINAPI
SQLWritePrivateProfileStringW(LPCWSTR lpszSection
, LPCWSTR lpszEntry
,
1164 LPCWSTR lpszString
, LPCWSTR lpszFilename
)
1170 TRACE("%s %s %s %s\n", debugstr_w(lpszSection
), debugstr_w(lpszEntry
),
1171 debugstr_w(lpszString
), debugstr_w(lpszFilename
));
1173 if(!lpszFilename
|| !*lpszFilename
)
1175 push_error(ODBC_ERROR_INVALID_STR
, odbc_error_invalid_param_string
);
1179 if ((ret
= RegCreateKeyW(HKEY_CURRENT_USER
, odbcW
, &hkey
)) == ERROR_SUCCESS
)
1183 if ((ret
= RegCreateKeyW(hkey
, lpszFilename
, &hkeyfilename
)) == ERROR_SUCCESS
)
1187 if ((ret
= RegCreateKeyW(hkeyfilename
, lpszSection
, &hkey_section
)) == ERROR_SUCCESS
)
1189 ret
= RegSetValueExW(hkey_section
, lpszEntry
, 0, REG_SZ
, (BYTE
*)lpszString
, (lstrlenW(lpszString
)+1)*sizeof(WCHAR
));
1190 RegCloseKey(hkey_section
);
1193 RegCloseKey(hkeyfilename
);
1199 return ret
== ERROR_SUCCESS
;
1202 BOOL WINAPI
SQLWritePrivateProfileString(LPCSTR lpszSection
, LPCSTR lpszEntry
,
1203 LPCSTR lpszString
, LPCSTR lpszFilename
)
1206 WCHAR
*sect
, *entry
, *string
, *file
;
1208 TRACE("%s %s %s %s\n", lpszSection
, lpszEntry
, lpszString
, lpszFilename
);
1210 sect
= heap_strdupAtoW(lpszSection
);
1211 entry
= heap_strdupAtoW(lpszEntry
);
1212 string
= heap_strdupAtoW(lpszString
);
1213 file
= heap_strdupAtoW(lpszFilename
);
1215 ret
= SQLWritePrivateProfileStringW(sect
, entry
, string
, file
);