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
23 #define WIN32_NO_STATUS
29 #define NONAMELESSUNION
35 #include <wine/debug.h>
39 WINE_DEFAULT_DEBUG_CHANNEL(odbc
);
41 /* Registry key names */
42 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};
44 /* This config mode is known to be process-wide.
45 * MSDN documentation suggests that the value is hidden somewhere in the registry but I haven't found it yet.
46 * Although both the registry and the ODBC.ini files appear to be maintained together they are not maintained automatically through the registry's IniFileMapping.
48 static UWORD config_mode
= ODBC_BOTH_DSN
;
50 /* MSDN documentation suggests that the error subsystem handles errors 1 to 8
51 * only and experimentation (Windows 2000) shows that the errors are process-
52 * wide so go for the simple solution; static arrays.
54 static int num_errors
;
55 static int error_code
[8];
56 static const WCHAR
*error_msg
[8];
57 static const WCHAR odbc_error_general_err
[] = {'G','e','n','e','r','a','l',' ','e','r','r','o','r',0};
58 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};
59 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};
60 static const WCHAR odbc_error_out_of_mem
[] = {'O','u','t',' ','o','f',' ','m','e','m','o','r','y',0};
61 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};
62 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};
64 /* Push an error onto the error stack, taking care of ranges etc. */
65 static void push_error(int code
, LPCWSTR msg
)
67 if (num_errors
< sizeof error_code
/sizeof error_code
[0])
69 error_code
[num_errors
] = code
;
70 error_msg
[num_errors
] = msg
;
75 /* Clear the error stack */
76 static void clear_errors(void)
81 static inline void * heap_alloc(size_t len
)
83 return HeapAlloc(GetProcessHeap(), 0, len
);
86 static inline BOOL
heap_free(void *mem
)
88 return HeapFree(GetProcessHeap(), 0, mem
);
91 static inline WCHAR
*heap_strdupAtoW(const char *str
)
98 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0);
99 ret
= heap_alloc(len
*sizeof(WCHAR
));
101 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
108 BOOL WINAPI
ODBCCPlApplet( LONG i
, LONG j
, LONG
* p1
, LONG
* p2
)
111 FIXME( "( %d %d %p %p) : stub!\n", i
, j
, p1
, p2
);
115 static LPWSTR
SQLInstall_strdup_multi(LPCSTR str
)
124 for (p
= str
; *p
; p
+= lstrlenA(p
) + 1)
127 len
= MultiByteToWideChar(CP_ACP
, 0, str
, p
- str
, NULL
, 0 );
128 ret
= HeapAlloc(GetProcessHeap(), 0, (len
+1)*sizeof(WCHAR
));
129 MultiByteToWideChar(CP_ACP
, 0, str
, p
- str
, ret
, len
);
135 static LPWSTR
SQLInstall_strdup(LPCSTR str
)
143 len
= MultiByteToWideChar(CP_ACP
, 0, str
, -1, NULL
, 0 );
144 ret
= HeapAlloc(GetProcessHeap(), 0, len
*sizeof(WCHAR
));
145 MultiByteToWideChar(CP_ACP
, 0, str
, -1, ret
, len
);
150 /* Convert the wide string or zero-length-terminated list of wide strings to a
151 * narrow string or zero-length-terminated list of narrow strings.
152 * Do not try to emulate windows undocumented excesses (e.g. adding a third \0
155 * mode Indicates the sort of string.
156 * 1 denotes that the buffers contain strings terminated by a single nul
158 * 2 denotes that the buffers contain zero-length-terminated lists
159 * (frequently erroneously referred to as double-null-terminated)
160 * buffer The narrow-character buffer into which to place the result. This
161 * must be a non-null pointer to the first element of a buffer whose
162 * length is passed in buffer_length.
163 * str The wide-character buffer containing the string or list of strings to
164 * be converted. str_length defines how many wide characters in the
165 * buffer are to be converted, including all desired terminating nul
167 * str_length Effective length of str
168 * buffer_length Length of buffer
169 * returned_length A pointer to a variable that will receive the number of
170 * narrow characters placed into the buffer. This pointer
173 static BOOL
SQLInstall_narrow(int mode
, LPSTR buffer
, LPCWSTR str
, WORD str_length
, WORD buffer_length
, WORD
*returned_length
)
175 LPSTR pbuf
; /* allows us to allocate a temporary buffer only if needed */
176 int len
; /* Length of the converted list */
177 BOOL success
= FALSE
;
178 assert(mode
== 1 || mode
== 2);
179 assert(buffer_length
);
180 len
= WideCharToMultiByte(CP_ACP
, 0, str
, str_length
, 0, 0, NULL
, NULL
);
183 if (len
> buffer_length
)
185 pbuf
= HeapAlloc(GetProcessHeap(), 0, len
);
191 len
= WideCharToMultiByte(CP_ACP
, 0, str
, str_length
, pbuf
, len
, NULL
, NULL
);
196 if (buffer_length
> (mode
- 1))
198 memcpy (buffer
, pbuf
, buffer_length
-mode
);
199 *(buffer
+buffer_length
-mode
) = '\0';
201 *(buffer
+buffer_length
-1) = '\0';
205 *returned_length
= pbuf
== buffer
? len
: buffer_length
;
211 ERR("transferring wide to narrow\n");
215 HeapFree(GetProcessHeap(), 0, pbuf
);
220 ERR("measuring wide to narrow\n");
225 BOOL WINAPI
SQLConfigDataSourceW(HWND hwndParent
, WORD fRequest
,
226 LPCWSTR lpszDriver
, LPCWSTR lpszAttributes
)
231 FIXME("%p %d %s %s\n", hwndParent
, fRequest
, debugstr_w(lpszDriver
),
232 debugstr_w(lpszAttributes
));
234 for (p
= lpszAttributes
; *p
; p
+= lstrlenW(p
) + 1)
235 FIXME("%s\n", debugstr_w(p
));
240 BOOL WINAPI
SQLConfigDataSource(HWND hwndParent
, WORD fRequest
,
241 LPCSTR lpszDriver
, LPCSTR lpszAttributes
)
243 FIXME("%p %d %s %s\n", hwndParent
, fRequest
, debugstr_a(lpszDriver
),
244 debugstr_a(lpszAttributes
));
249 BOOL WINAPI
SQLConfigDriverW(HWND hwndParent
, WORD fRequest
, LPCWSTR lpszDriver
,
250 LPCWSTR lpszArgs
, LPWSTR lpszMsg
, WORD cbMsgMax
, WORD
*pcbMsgOut
)
253 FIXME("(%p %d %s %s %p %d %p)\n", hwndParent
, fRequest
, debugstr_w(lpszDriver
),
254 debugstr_w(lpszArgs
), lpszMsg
, cbMsgMax
, pcbMsgOut
);
258 BOOL WINAPI
SQLConfigDriver(HWND hwndParent
, WORD fRequest
, LPCSTR lpszDriver
,
259 LPCSTR lpszArgs
, LPSTR lpszMsg
, WORD cbMsgMax
, WORD
*pcbMsgOut
)
262 FIXME("(%p %d %s %s %p %d %p)\n", hwndParent
, fRequest
, debugstr_a(lpszDriver
),
263 debugstr_a(lpszArgs
), lpszMsg
, cbMsgMax
, pcbMsgOut
);
267 BOOL WINAPI
SQLCreateDataSourceW(HWND hwnd
, LPCWSTR lpszDS
)
270 FIXME("%p %s\n", hwnd
, debugstr_w(lpszDS
));
271 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
275 BOOL WINAPI
SQLCreateDataSource(HWND hwnd
, LPCSTR lpszDS
)
278 FIXME("%p %s\n", hwnd
, debugstr_a(lpszDS
));
279 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
283 BOOL WINAPI
SQLGetAvailableDriversW(LPCWSTR lpszInfFile
, LPWSTR lpszBuf
,
284 WORD cbBufMax
, WORD
*pcbBufOut
)
287 FIXME("%s %p %d %p\n", debugstr_w(lpszInfFile
), lpszBuf
, cbBufMax
, pcbBufOut
);
288 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
292 BOOL WINAPI
SQLGetAvailableDrivers(LPCSTR lpszInfFile
, LPSTR lpszBuf
,
293 WORD cbBufMax
, WORD
*pcbBufOut
)
296 FIXME("%s %p %d %p\n", debugstr_a(lpszInfFile
), lpszBuf
, cbBufMax
, pcbBufOut
);
297 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
301 BOOL WINAPI
SQLGetConfigMode(UWORD
*pwConfigMode
)
304 TRACE("%p\n", pwConfigMode
);
306 *pwConfigMode
= config_mode
;
310 /* This is implemented sensibly rather than according to exact conformance to Microsoft's buggy implementations
311 * e.g. The Microsoft one occasionally actually adds a third nul character (possibly beyond the buffer).
312 * 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.
314 BOOL WINAPI
SQLGetInstalledDriversW(LPWSTR lpszBuf
, WORD cbBufMax
,
317 HKEY hDrivers
; /* Registry handle to the Drivers key */
318 LONG reg_ret
; /* Return code from registry functions */
319 BOOL success
= FALSE
; /* The value we will return */
323 TRACE("%p %d %p\n", lpszBuf
, cbBufMax
, pcbBufOut
);
325 if (!lpszBuf
|| cbBufMax
== 0)
327 push_error(ODBC_ERROR_INVALID_BUFF_LEN
, odbc_error_invalid_buff_len
);
329 else if ((reg_ret
= RegOpenKeyExW (HKEY_LOCAL_MACHINE
/* The drivers does not depend on the config mode */,
330 drivers_key
, 0, KEY_READ
/* Maybe overkill */,
331 &hDrivers
)) == ERROR_SUCCESS
)
339 size_name
= cbBufMax
;
340 if ((reg_ret
= RegEnumValueW(hDrivers
, index
, lpszBuf
, &size_name
, NULL
, NULL
, NULL
, NULL
)) == ERROR_SUCCESS
)
343 assert (size_name
< cbBufMax
&& *(lpszBuf
+ size_name
) == 0);
345 cbBufMax
-= size_name
;
350 if (reg_ret
!= ERROR_NO_MORE_ITEMS
)
353 push_error(ODBC_ERROR_GENERAL_ERR
, odbc_error_general_err
);
359 if ((reg_ret
= RegCloseKey (hDrivers
)) != ERROR_SUCCESS
)
360 TRACE ("Error %d closing ODBC Drivers key\n", reg_ret
);
364 /* MSDN states that it returns failure with COMPONENT_NOT_FOUND in this case.
365 * Version 3.525.1117.0 (Windows 2000) does not; it actually returns success.
366 * I doubt if it will actually be an issue.
368 push_error(ODBC_ERROR_COMPONENT_NOT_FOUND
, odbc_error_component_not_found
);
373 BOOL WINAPI
SQLGetInstalledDrivers(LPSTR lpszBuf
, WORD cbBufMax
,
377 int size_wbuf
= cbBufMax
;
381 TRACE("%p %d %p\n", lpszBuf
, cbBufMax
, pcbBufOut
);
383 wbuf
= HeapAlloc(GetProcessHeap(), 0, size_wbuf
*sizeof(WCHAR
));
386 ret
= SQLGetInstalledDriversW(wbuf
, size_wbuf
, &size_used
);
389 if (!(ret
= SQLInstall_narrow(2, lpszBuf
, wbuf
, size_used
, cbBufMax
, pcbBufOut
)))
391 push_error(ODBC_ERROR_GENERAL_ERR
, odbc_error_general_err
);
394 HeapFree(GetProcessHeap(), 0, wbuf
);
395 /* ignore failure; we have achieved the aim */
399 push_error(ODBC_ERROR_OUT_OF_MEM
, odbc_error_out_of_mem
);
405 int WINAPI
SQLGetPrivateProfileStringW(LPCWSTR lpszSection
, LPCWSTR lpszEntry
,
406 LPCWSTR lpszDefault
, LPCWSTR RetBuffer
, int cbRetBuffer
,
407 LPCWSTR lpszFilename
)
410 FIXME("%s %s %s %p %d %s\n", debugstr_w(lpszSection
), debugstr_w(lpszEntry
),
411 debugstr_w(lpszDefault
), RetBuffer
, cbRetBuffer
,
412 debugstr_w(lpszFilename
));
413 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
417 int WINAPI
SQLGetPrivateProfileString(LPCSTR lpszSection
, LPCSTR lpszEntry
,
418 LPCSTR lpszDefault
, LPCSTR RetBuffer
, int cbRetBuffer
,
422 FIXME("%s %s %s %p %d %s\n", debugstr_a(lpszSection
), debugstr_a(lpszEntry
),
423 debugstr_a(lpszDefault
), RetBuffer
, cbRetBuffer
,
424 debugstr_a(lpszFilename
));
425 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
429 BOOL WINAPI
SQLGetTranslatorW(HWND hwndParent
, LPWSTR lpszName
, WORD cbNameMax
,
430 WORD
*pcbNameOut
, LPWSTR lpszPath
, WORD cbPathMax
,
431 WORD
*pcbPathOut
, DWORD
*pvOption
)
434 FIXME("%p %s %d %p %p %d %p %p\n", hwndParent
, debugstr_w(lpszName
), cbNameMax
,
435 pcbNameOut
, lpszPath
, cbPathMax
, pcbPathOut
, pvOption
);
436 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
440 BOOL WINAPI
SQLGetTranslator(HWND hwndParent
, LPSTR lpszName
, WORD cbNameMax
,
441 WORD
*pcbNameOut
, LPSTR lpszPath
, WORD cbPathMax
,
442 WORD
*pcbPathOut
, DWORD
*pvOption
)
445 FIXME("%p %s %d %p %p %d %p %p\n", hwndParent
, debugstr_a(lpszName
), cbNameMax
,
446 pcbNameOut
, lpszPath
, cbPathMax
, pcbPathOut
, pvOption
);
447 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
451 BOOL WINAPI
SQLInstallDriverW(LPCWSTR lpszInfFile
, LPCWSTR lpszDriver
,
452 LPWSTR lpszPath
, WORD cbPathMax
, WORD
* pcbPathOut
)
457 TRACE("%s %s %p %d %p\n", debugstr_w(lpszInfFile
),
458 debugstr_w(lpszDriver
), lpszPath
, cbPathMax
, pcbPathOut
);
463 return SQLInstallDriverExW(lpszDriver
, NULL
, lpszPath
, cbPathMax
,
464 pcbPathOut
, ODBC_INSTALL_COMPLETE
, &usage
);
467 BOOL WINAPI
SQLInstallDriver(LPCSTR lpszInfFile
, LPCSTR lpszDriver
,
468 LPSTR lpszPath
, WORD cbPathMax
, WORD
* pcbPathOut
)
473 TRACE("%s %s %p %d %p\n", debugstr_a(lpszInfFile
),
474 debugstr_a(lpszDriver
), lpszPath
, cbPathMax
, pcbPathOut
);
479 return SQLInstallDriverEx(lpszDriver
, NULL
, lpszPath
, cbPathMax
,
480 pcbPathOut
, ODBC_INSTALL_COMPLETE
, &usage
);
483 BOOL WINAPI
SQLInstallDriverExW(LPCWSTR lpszDriver
, LPCWSTR lpszPathIn
,
484 LPWSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
485 WORD fRequest
, LPDWORD lpdwUsageCount
)
489 WCHAR path
[MAX_PATH
];
492 TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszDriver
),
493 debugstr_w(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
494 fRequest
, lpdwUsageCount
);
496 for (p
= lpszDriver
; *p
; p
+= lstrlenW(p
) + 1)
497 TRACE("%s\n", debugstr_w(p
));
499 len
= GetSystemDirectoryW(path
, MAX_PATH
);
504 len
= GetSystemDirectoryW(path
, MAX_PATH
);
506 if (lpszPathOut
&& cbPathOutMax
> len
)
508 lstrcpyW(lpszPathOut
, path
);
514 BOOL WINAPI
SQLInstallDriverEx(LPCSTR lpszDriver
, LPCSTR lpszPathIn
,
515 LPSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
516 WORD fRequest
, LPDWORD lpdwUsageCount
)
519 LPWSTR driver
, pathin
;
520 WCHAR pathout
[MAX_PATH
];
525 TRACE("%s %s %p %d %p %d %p\n", debugstr_a(lpszDriver
),
526 debugstr_a(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
527 fRequest
, lpdwUsageCount
);
529 for (p
= lpszDriver
; *p
; p
+= lstrlenA(p
) + 1)
530 TRACE("%s\n", debugstr_a(p
));
532 driver
= SQLInstall_strdup_multi(lpszDriver
);
533 pathin
= SQLInstall_strdup(lpszPathIn
);
535 ret
= SQLInstallDriverExW(driver
, pathin
, pathout
, MAX_PATH
, &cbOut
,
536 fRequest
, lpdwUsageCount
);
539 int len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
544 *pcbPathOut
= len
- 1;
546 if (!lpszPathOut
|| cbPathOutMax
< len
)
551 len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
552 cbPathOutMax
, NULL
, NULL
);
557 HeapFree(GetProcessHeap(), 0, driver
);
558 HeapFree(GetProcessHeap(), 0, pathin
);
562 BOOL WINAPI
SQLInstallDriverManagerW(LPWSTR lpszPath
, WORD cbPathMax
,
566 WCHAR path
[MAX_PATH
];
568 TRACE("(%p %d %p)\n", lpszPath
, cbPathMax
, pcbPathOut
);
570 if (cbPathMax
< MAX_PATH
)
575 len
= GetSystemDirectoryW(path
, MAX_PATH
);
580 if (lpszPath
&& cbPathMax
> len
)
582 lstrcpyW(lpszPath
, path
);
588 BOOL WINAPI
SQLInstallDriverManager(LPSTR lpszPath
, WORD cbPathMax
,
593 WCHAR path
[MAX_PATH
];
595 TRACE("(%p %d %p)\n", lpszPath
, cbPathMax
, pcbPathOut
);
597 if (cbPathMax
< MAX_PATH
)
602 ret
= SQLInstallDriverManagerW(path
, MAX_PATH
, &cbOut
);
605 len
= WideCharToMultiByte(CP_ACP
, 0, path
, -1, lpszPath
, 0,
610 *pcbPathOut
= len
- 1;
612 if (!lpszPath
|| cbPathMax
< len
)
615 len
= WideCharToMultiByte(CP_ACP
, 0, path
, -1, lpszPath
,
616 cbPathMax
, NULL
, NULL
);
622 BOOL WINAPI
SQLInstallODBCW(HWND hwndParent
, LPCWSTR lpszInfFile
,
623 LPCWSTR lpszSrcPath
, LPCWSTR lpszDrivers
)
626 FIXME("%p %s %s %s\n", hwndParent
, debugstr_w(lpszInfFile
),
627 debugstr_w(lpszSrcPath
), debugstr_w(lpszDrivers
));
628 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
632 BOOL WINAPI
SQLInstallODBC(HWND hwndParent
, LPCSTR lpszInfFile
,
633 LPCSTR lpszSrcPath
, LPCSTR lpszDrivers
)
636 FIXME("%p %s %s %s\n", hwndParent
, debugstr_a(lpszInfFile
),
637 debugstr_a(lpszSrcPath
), debugstr_a(lpszDrivers
));
638 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
642 SQLRETURN WINAPI
SQLInstallerErrorW(WORD iError
, DWORD
*pfErrorCode
,
643 LPWSTR lpszErrorMsg
, WORD cbErrorMsgMax
, WORD
*pcbErrorMsg
)
645 TRACE("%d %p %p %d %p\n", iError
, pfErrorCode
, lpszErrorMsg
,
646 cbErrorMsgMax
, pcbErrorMsg
);
652 else if (iError
<= num_errors
)
654 BOOL truncated
= FALSE
;
659 *pfErrorCode
= error_code
[iError
];
660 msg
= error_msg
[iError
];
661 len
= msg
? lstrlenW(msg
) : 0;
665 if (cbErrorMsgMax
< len
)
670 if (lpszErrorMsg
&& len
)
674 memcpy (lpszErrorMsg
, msg
, len
* sizeof(WCHAR
));
684 /* Yes. If you pass a null pointer and a large length it is not an error! */
688 return truncated
? SQL_SUCCESS_WITH_INFO
: SQL_SUCCESS
;
691 /* 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 */
695 if (lpszErrorMsg
&& cbErrorMsgMax
> 0)
696 *lpszErrorMsg
= '\0';
701 SQLRETURN WINAPI
SQLInstallerError(WORD iError
, DWORD
*pfErrorCode
,
702 LPSTR lpszErrorMsg
, WORD cbErrorMsgMax
, WORD
*pcbErrorMsg
)
707 TRACE("%d %p %p %d %p\n", iError
, pfErrorCode
, lpszErrorMsg
,
708 cbErrorMsgMax
, pcbErrorMsg
);
711 if (lpszErrorMsg
&& cbErrorMsgMax
)
713 wbuf
= HeapAlloc(GetProcessHeap(), 0, cbErrorMsgMax
*sizeof(WCHAR
));
717 ret
= SQLInstallerErrorW(iError
, pfErrorCode
, wbuf
, cbErrorMsgMax
, &cbwbuf
);
721 SQLInstall_narrow(1, lpszErrorMsg
, wbuf
, cbwbuf
+1, cbErrorMsgMax
, &cbBuf
);
722 HeapFree(GetProcessHeap(), 0, wbuf
);
724 *pcbErrorMsg
= cbBuf
-1;
729 BOOL WINAPI
SQLInstallTranslatorExW(LPCWSTR lpszTranslator
, LPCWSTR lpszPathIn
,
730 LPWSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
731 WORD fRequest
, LPDWORD lpdwUsageCount
)
735 WCHAR path
[MAX_PATH
];
738 TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszTranslator
),
739 debugstr_w(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
740 fRequest
, lpdwUsageCount
);
742 for (p
= lpszTranslator
; *p
; p
+= lstrlenW(p
) + 1)
743 TRACE("%s\n", debugstr_w(p
));
745 len
= GetSystemDirectoryW(path
, MAX_PATH
);
750 if (lpszPathOut
&& cbPathOutMax
> len
)
752 lstrcpyW(lpszPathOut
, path
);
758 BOOL WINAPI
SQLInstallTranslatorEx(LPCSTR lpszTranslator
, LPCSTR lpszPathIn
,
759 LPSTR lpszPathOut
, WORD cbPathOutMax
, WORD
*pcbPathOut
,
760 WORD fRequest
, LPDWORD lpdwUsageCount
)
763 LPWSTR translator
, pathin
;
764 WCHAR pathout
[MAX_PATH
];
769 TRACE("%s %s %p %d %p %d %p\n", debugstr_a(lpszTranslator
),
770 debugstr_a(lpszPathIn
), lpszPathOut
, cbPathOutMax
, pcbPathOut
,
771 fRequest
, lpdwUsageCount
);
773 for (p
= lpszTranslator
; *p
; p
+= lstrlenA(p
) + 1)
774 TRACE("%s\n", debugstr_a(p
));
776 translator
= SQLInstall_strdup_multi(lpszTranslator
);
777 pathin
= SQLInstall_strdup(lpszPathIn
);
779 ret
= SQLInstallTranslatorExW(translator
, pathin
, pathout
, MAX_PATH
,
780 &cbOut
, fRequest
, lpdwUsageCount
);
783 int len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
788 *pcbPathOut
= len
- 1;
790 if (!lpszPathOut
|| cbPathOutMax
< len
)
795 len
= WideCharToMultiByte(CP_ACP
, 0, pathout
, -1, lpszPathOut
,
796 cbPathOutMax
, NULL
, NULL
);
801 HeapFree(GetProcessHeap(), 0, translator
);
802 HeapFree(GetProcessHeap(), 0, pathin
);
806 BOOL WINAPI
SQLInstallTranslator(LPCSTR lpszInfFile
, LPCSTR lpszTranslator
,
807 LPCSTR lpszPathIn
, LPSTR lpszPathOut
, WORD cbPathOutMax
,
808 WORD
*pcbPathOut
, WORD fRequest
, LPDWORD lpdwUsageCount
)
811 TRACE("%s %s %s %p %d %p %d %p\n", debugstr_a(lpszInfFile
),
812 debugstr_a(lpszTranslator
), debugstr_a(lpszPathIn
), lpszPathOut
,
813 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
818 return SQLInstallTranslatorEx(lpszTranslator
, lpszPathIn
, lpszPathOut
,
819 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
822 BOOL WINAPI
SQLInstallTranslatorW(LPCWSTR lpszInfFile
, LPCWSTR lpszTranslator
,
823 LPCWSTR lpszPathIn
, LPWSTR lpszPathOut
, WORD cbPathOutMax
,
824 WORD
*pcbPathOut
, WORD fRequest
, LPDWORD lpdwUsageCount
)
827 TRACE("%s %s %s %p %d %p %d %p\n", debugstr_w(lpszInfFile
),
828 debugstr_w(lpszTranslator
), debugstr_w(lpszPathIn
), lpszPathOut
,
829 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
834 return SQLInstallTranslatorExW(lpszTranslator
, lpszPathIn
, lpszPathOut
,
835 cbPathOutMax
, pcbPathOut
, fRequest
, lpdwUsageCount
);
838 BOOL WINAPI
SQLManageDataSources(HWND hwnd
)
842 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
846 SQLRETURN WINAPI
SQLPostInstallerErrorW(DWORD fErrorCode
, LPCWSTR szErrorMsg
)
848 FIXME("%u %s\n", fErrorCode
, debugstr_w(szErrorMsg
));
849 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
853 SQLRETURN WINAPI
SQLPostInstallerError(DWORD fErrorCode
, LPCSTR szErrorMsg
)
855 FIXME("%u %s\n", fErrorCode
, debugstr_a(szErrorMsg
));
856 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
860 BOOL WINAPI
SQLReadFileDSNW(LPCWSTR lpszFileName
, LPCWSTR lpszAppName
,
861 LPCWSTR lpszKeyName
, LPWSTR lpszString
, WORD cbString
,
865 FIXME("%s %s %s %s %d %p\n", debugstr_w(lpszFileName
), debugstr_w(lpszAppName
),
866 debugstr_w(lpszKeyName
), debugstr_w(lpszString
), cbString
, pcbString
);
867 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
871 BOOL WINAPI
SQLReadFileDSN(LPCSTR lpszFileName
, LPCSTR lpszAppName
,
872 LPCSTR lpszKeyName
, LPSTR lpszString
, WORD cbString
,
876 FIXME("%s %s %s %s %d %p\n", debugstr_a(lpszFileName
), debugstr_a(lpszAppName
),
877 debugstr_a(lpszKeyName
), debugstr_a(lpszString
), cbString
, pcbString
);
878 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
882 BOOL WINAPI
SQLRemoveDefaultDataSource(void)
886 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
890 BOOL WINAPI
SQLRemoveDriverW(LPCWSTR lpszDriver
, BOOL fRemoveDSN
,
891 LPDWORD lpdwUsageCount
)
894 FIXME("%s %d %p\n", debugstr_w(lpszDriver
), fRemoveDSN
, lpdwUsageCount
);
895 if (lpdwUsageCount
) *lpdwUsageCount
= 1;
899 BOOL WINAPI
SQLRemoveDriver(LPCSTR lpszDriver
, BOOL fRemoveDSN
,
900 LPDWORD lpdwUsageCount
)
903 FIXME("%s %d %p\n", debugstr_a(lpszDriver
), fRemoveDSN
, lpdwUsageCount
);
904 if (lpdwUsageCount
) *lpdwUsageCount
= 1;
908 BOOL WINAPI
SQLRemoveDriverManager(LPDWORD pdwUsageCount
)
911 FIXME("%p\n", pdwUsageCount
);
912 if (pdwUsageCount
) *pdwUsageCount
= 1;
916 BOOL WINAPI
SQLRemoveDSNFromIniW(LPCWSTR lpszDSN
)
919 FIXME("%s\n", debugstr_w(lpszDSN
));
920 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
924 BOOL WINAPI
SQLRemoveDSNFromIni(LPCSTR lpszDSN
)
927 FIXME("%s\n", debugstr_a(lpszDSN
));
928 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
932 BOOL WINAPI
SQLRemoveTranslatorW(LPCWSTR lpszTranslator
, LPDWORD lpdwUsageCount
)
935 FIXME("%s %p\n", debugstr_w(lpszTranslator
), lpdwUsageCount
);
936 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
940 BOOL WINAPI
SQLRemoveTranslator(LPCSTR lpszTranslator
, LPDWORD lpdwUsageCount
)
943 FIXME("%s %p\n", debugstr_a(lpszTranslator
), lpdwUsageCount
);
944 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
948 BOOL WINAPI
SQLSetConfigMode(UWORD wConfigMode
)
951 TRACE("%u\n", wConfigMode
);
953 if (wConfigMode
> ODBC_SYSTEM_DSN
)
955 push_error(ODBC_ERROR_INVALID_PARAM_SEQUENCE
, odbc_error_invalid_param_sequence
);
960 config_mode
= wConfigMode
;
965 BOOL WINAPI
SQLValidDSNW(LPCWSTR lpszDSN
)
968 FIXME("%s\n", debugstr_w(lpszDSN
));
969 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
973 BOOL WINAPI
SQLValidDSN(LPCSTR lpszDSN
)
976 FIXME("%s\n", debugstr_a(lpszDSN
));
977 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
981 BOOL WINAPI
SQLWriteDSNToIniW(LPCWSTR lpszDSN
, LPCWSTR lpszDriver
)
984 FIXME("%s %s\n", debugstr_w(lpszDSN
), debugstr_w(lpszDriver
));
985 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
989 BOOL WINAPI
SQLWriteDSNToIni(LPCSTR lpszDSN
, LPCSTR lpszDriver
)
992 FIXME("%s %s\n", debugstr_a(lpszDSN
), debugstr_a(lpszDriver
));
993 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
997 BOOL WINAPI
SQLWriteFileDSNW(LPCWSTR lpszFileName
, LPCWSTR lpszAppName
,
998 LPCWSTR lpszKeyName
, LPCWSTR lpszString
)
1001 FIXME("%s %s %s %s\n", debugstr_w(lpszFileName
), debugstr_w(lpszAppName
),
1002 debugstr_w(lpszKeyName
), debugstr_w(lpszString
));
1003 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1007 BOOL WINAPI
SQLWriteFileDSN(LPCSTR lpszFileName
, LPCSTR lpszAppName
,
1008 LPCSTR lpszKeyName
, LPCSTR lpszString
)
1011 FIXME("%s %s %s %s\n", debugstr_a(lpszFileName
), debugstr_a(lpszAppName
),
1012 debugstr_a(lpszKeyName
), debugstr_a(lpszString
));
1013 SetLastError(ERROR_CALL_NOT_IMPLEMENTED
);
1017 BOOL WINAPI
SQLWritePrivateProfileStringW(LPCWSTR lpszSection
, LPCWSTR lpszEntry
,
1018 LPCWSTR lpszString
, LPCWSTR lpszFilename
)
1022 WCHAR softwareodbc
[] = {'S','o','f','t','w','a','r','e','\\','O','D','B','C',0};
1025 TRACE("%s %s %s %s\n", debugstr_w(lpszSection
), debugstr_w(lpszEntry
),
1026 debugstr_w(lpszString
), debugstr_w(lpszFilename
));
1028 if(!lpszFilename
|| !*lpszFilename
)
1030 push_error(ODBC_ERROR_INVALID_STR
, odbc_error_invalid_param_string
);
1034 if ((ret
= RegCreateKeyW(HKEY_CURRENT_USER
, softwareodbc
, &hkey
)) == ERROR_SUCCESS
)
1038 if ((ret
= RegCreateKeyW(hkey
, lpszFilename
, &hkeyfilename
)) == ERROR_SUCCESS
)
1042 if ((ret
= RegCreateKeyW(hkeyfilename
, lpszSection
, &hkey_section
)) == ERROR_SUCCESS
)
1044 ret
= RegSetValueExW(hkey_section
, lpszEntry
, 0, REG_SZ
, (BYTE
*)lpszString
, (lstrlenW(lpszString
)+1)*sizeof(WCHAR
));
1045 RegCloseKey(hkey_section
);
1048 RegCloseKey(hkeyfilename
);
1054 return ret
== ERROR_SUCCESS
;
1057 BOOL WINAPI
SQLWritePrivateProfileString(LPCSTR lpszSection
, LPCSTR lpszEntry
,
1058 LPCSTR lpszString
, LPCSTR lpszFilename
)
1061 WCHAR
*sect
, *entry
, *string
, *file
;
1063 TRACE("%s %s %s %s\n", lpszSection
, lpszEntry
, lpszString
, lpszFilename
);
1065 sect
= heap_strdupAtoW(lpszSection
);
1066 entry
= heap_strdupAtoW(lpszEntry
);
1067 string
= heap_strdupAtoW(lpszString
);
1068 file
= heap_strdupAtoW(lpszFilename
);
1070 ret
= SQLWritePrivateProfileStringW(sect
, entry
, string
, file
);