wined3d: Force stream info update on vertex shader change.
[wine.git] / dlls / odbccp32 / odbccp32.c
blob0483f1ef3786fdf885704b30ba0d3f1df2077247
1 /*
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 #include <assert.h>
24 #include <stdarg.h>
26 #define COBJMACROS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winreg.h"
31 #include "winnls.h"
32 #include "wine/debug.h"
34 #include "odbcinst.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};
41 /* This config mode is known to be process-wide.
42 * MSDN documentation suggests that the value is hidden somewhere in the registry but I haven't found it yet.
43 * Although both the registry and the ODBC.ini files appear to be maintained together they are not maintained automatically through the registry's IniFileMapping.
45 static UWORD config_mode = ODBC_BOTH_DSN;
47 /* MSDN documentation suggests that the error subsystem handles errors 1 to 8
48 * only and experimentation (Windows 2000) shows that the errors are process-
49 * wide so go for the simple solution; static arrays.
51 static int num_errors;
52 static int error_code[8];
53 static const WCHAR *error_msg[8];
54 static const WCHAR odbc_error_general_err[] = {'G','e','n','e','r','a','l',' ','e','r','r','o','r',0};
55 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};
56 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};
57 static const WCHAR odbc_error_out_of_mem[] = {'O','u','t',' ','o','f',' ','m','e','m','o','r','y',0};
58 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 /* Push an error onto the error stack, taking care of ranges etc. */
61 static void push_error(int code, LPCWSTR msg)
63 if (num_errors < sizeof error_code/sizeof error_code[0])
65 error_code[num_errors] = code;
66 error_msg[num_errors] = msg;
67 num_errors++;
71 /* Clear the error stack */
72 static void clear_errors(void)
74 num_errors = 0;
77 BOOL WINAPI ODBCCPlApplet( LONG i, LONG j, LONG * p1, LONG * p2)
79 clear_errors();
80 FIXME( "( %d %d %p %p) : stub!\n", i, j, p1, p2);
81 return FALSE;
84 static LPWSTR SQLInstall_strdup_multi(LPCSTR str)
86 LPCSTR p;
87 LPWSTR ret = NULL;
88 DWORD len;
90 if (!str)
91 return ret;
93 for (p = str; *p; p += lstrlenA(p) + 1)
96 len = MultiByteToWideChar(CP_ACP, 0, str, p - str, NULL, 0 );
97 ret = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
98 MultiByteToWideChar(CP_ACP, 0, str, p - str, ret, len );
99 ret[len] = 0;
101 return ret;
104 static LPWSTR SQLInstall_strdup(LPCSTR str)
106 DWORD len;
107 LPWSTR ret = NULL;
109 if (!str)
110 return ret;
112 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0 );
113 ret = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
114 MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len );
116 return ret;
119 /* Convert the wide string or zero-length-terminated list of wide strings to a
120 * narrow string or zero-length-terminated list of narrow strings.
121 * Do not try to emulate windows undocumented excesses (e.g. adding a third \0
122 * to a list)
123 * Arguments
124 * mode Indicates the sort of string.
125 * 1 denotes that the buffers contain strings terminated by a single nul
126 * character
127 * 2 denotes that the buffers contain zero-length-terminated lists
128 * (frequently erroneously referred to as double-null-terminated)
129 * buffer The narrow-character buffer into which to place the result. This
130 * must be a non-null pointer to the first element of a buffer whose
131 * length is passed in buffer_length.
132 * str The wide-character buffer containing the string or list of strings to
133 * be converted. str_length defines how many wide characters in the
134 * buffer are to be converted, including all desired terminating nul
135 * characters.
136 * str_length Effective length of str
137 * buffer_length Length of buffer
138 * returned_length A pointer to a variable that will receive the number of
139 * narrow characters placed into the buffer. This pointer
140 * may be NULL.
142 static BOOL SQLInstall_narrow(int mode, LPSTR buffer, LPCWSTR str, WORD str_length, WORD buffer_length, WORD *returned_length)
144 LPSTR pbuf; /* allows us to allocate a temporary buffer only if needed */
145 int len; /* Length of the converted list */
146 BOOL success = FALSE;
147 assert(mode == 1 || mode == 2);
148 assert(buffer_length);
149 len = WideCharToMultiByte(CP_ACP, 0, str, str_length, 0, 0, NULL, NULL);
150 if (len > 0)
152 if (len > buffer_length)
154 pbuf = HeapAlloc(GetProcessHeap(), 0, len);
156 else
158 pbuf = buffer;
160 len = WideCharToMultiByte(CP_ACP, 0, str, str_length, pbuf, len, NULL, NULL);
161 if (len > 0)
163 if (pbuf != buffer)
165 if (buffer_length > (mode - 1))
167 memcpy (buffer, pbuf, buffer_length-mode);
168 *(buffer+buffer_length-mode) = '\0';
170 *(buffer+buffer_length-1) = '\0';
172 if (returned_length)
174 *returned_length = pbuf == buffer ? len : buffer_length;
176 success = TRUE;
178 else
180 ERR("transferring wide to narrow\n");
182 if (pbuf != buffer)
184 HeapFree(GetProcessHeap(), 0, pbuf);
187 else
189 ERR("measuring wide to narrow\n");
191 return success;
194 BOOL WINAPI SQLConfigDataSourceW(HWND hwndParent, WORD fRequest,
195 LPCWSTR lpszDriver, LPCWSTR lpszAttributes)
197 LPCWSTR p;
199 clear_errors();
200 FIXME("%p %d %s %s\n", hwndParent, fRequest, debugstr_w(lpszDriver),
201 debugstr_w(lpszAttributes));
203 for (p = lpszAttributes; *p; p += lstrlenW(p) + 1)
204 FIXME("%s\n", debugstr_w(p));
206 return TRUE;
209 BOOL WINAPI SQLConfigDataSource(HWND hwndParent, WORD fRequest,
210 LPCSTR lpszDriver, LPCSTR lpszAttributes)
212 FIXME("%p %d %s %s\n", hwndParent, fRequest, debugstr_a(lpszDriver),
213 debugstr_a(lpszAttributes));
214 clear_errors();
215 return TRUE;
218 BOOL WINAPI SQLConfigDriverW(HWND hwndParent, WORD fRequest, LPCWSTR lpszDriver,
219 LPCWSTR lpszArgs, LPWSTR lpszMsg, WORD cbMsgMax, WORD *pcbMsgOut)
221 clear_errors();
222 FIXME("(%p %d %s %s %p %d %p)\n", hwndParent, fRequest, debugstr_w(lpszDriver),
223 debugstr_w(lpszArgs), lpszMsg, cbMsgMax, pcbMsgOut);
224 return TRUE;
227 BOOL WINAPI SQLConfigDriver(HWND hwndParent, WORD fRequest, LPCSTR lpszDriver,
228 LPCSTR lpszArgs, LPSTR lpszMsg, WORD cbMsgMax, WORD *pcbMsgOut)
230 clear_errors();
231 FIXME("(%p %d %s %s %p %d %p)\n", hwndParent, fRequest, debugstr_a(lpszDriver),
232 debugstr_a(lpszArgs), lpszMsg, cbMsgMax, pcbMsgOut);
233 return TRUE;
236 BOOL WINAPI SQLCreateDataSourceW(HWND hwnd, LPCWSTR lpszDS)
238 clear_errors();
239 FIXME("\n");
240 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
241 return FALSE;
244 BOOL WINAPI SQLCreateDataSource(HWND hwnd, LPCSTR lpszDS)
246 clear_errors();
247 FIXME("\n");
248 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
249 return FALSE;
252 BOOL WINAPI SQLGetAvailableDriversW(LPCWSTR lpszInfFile, LPWSTR lpszBuf,
253 WORD cbBufMax, WORD *pcbBufOut)
255 clear_errors();
256 FIXME("\n");
257 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
258 return FALSE;
261 BOOL WINAPI SQLGetAvailableDrivers(LPCSTR lpszInfFile, LPSTR lpszBuf,
262 WORD cbBufMax, WORD *pcbBufOut)
264 clear_errors();
265 FIXME("\n");
266 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
267 return FALSE;
270 BOOL WINAPI SQLGetConfigMode(UWORD *pwConfigMode)
272 clear_errors();
273 if (pwConfigMode)
274 *pwConfigMode = config_mode;
275 return TRUE;
278 /* This is implemented sensibly rather than according to exact conformance to Microsoft's buggy implementations
279 * e.g. The Microsoft one occasionally actually adds a third nul character (possibly beyond the buffer).
280 * 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.
282 BOOL WINAPI SQLGetInstalledDriversW(LPWSTR lpszBuf, WORD cbBufMax,
283 WORD *pcbBufOut)
285 HKEY hDrivers; /* Registry handle to the Drivers key */
286 LONG reg_ret; /* Return code from registry functions */
287 BOOL success = FALSE; /* The value we will return */
289 clear_errors();
290 if (!lpszBuf || cbBufMax == 0)
292 push_error(ODBC_ERROR_INVALID_BUFF_LEN, odbc_error_invalid_buff_len);
294 else if ((reg_ret = RegOpenKeyExW (HKEY_LOCAL_MACHINE /* The drivers does not depend on the config mode */,
295 drivers_key, 0, KEY_READ /* Maybe overkill */,
296 &hDrivers)) == ERROR_SUCCESS)
298 DWORD index = 0;
299 cbBufMax--;
300 success = TRUE;
301 while (cbBufMax > 0)
303 DWORD size_name;
304 size_name = cbBufMax;
305 if ((reg_ret = RegEnumValueW(hDrivers, index, lpszBuf, &size_name, NULL, NULL, NULL, NULL)) == ERROR_SUCCESS)
307 index++;
308 assert (size_name < cbBufMax && *(lpszBuf + size_name) == 0);
309 size_name++;
310 cbBufMax-= size_name;
311 lpszBuf+=size_name;
313 else
315 if (reg_ret != ERROR_NO_MORE_ITEMS)
317 success = FALSE;
318 push_error(ODBC_ERROR_GENERAL_ERR, odbc_error_general_err);
320 break;
323 *lpszBuf = 0;
324 if ((reg_ret = RegCloseKey (hDrivers)) != ERROR_SUCCESS)
325 TRACE ("Error %d closing ODBC Drivers key\n", reg_ret);
327 else
329 /* MSDN states that it returns failure with COMPONENT_NOT_FOUND in this case.
330 * Version 3.525.1117.0 (Windows 2000) does not; it actually returns success.
331 * I doubt if it will actually be an issue.
333 push_error(ODBC_ERROR_COMPONENT_NOT_FOUND, odbc_error_component_not_found);
335 return success;
338 BOOL WINAPI SQLGetInstalledDrivers(LPSTR lpszBuf, WORD cbBufMax,
339 WORD *pcbBufOut)
341 BOOL ret;
342 int size_wbuf = cbBufMax;
343 LPWSTR wbuf;
344 WORD size_used;
345 wbuf = HeapAlloc(GetProcessHeap(), 0, size_wbuf*sizeof(WCHAR));
346 if (wbuf)
348 ret = SQLGetInstalledDriversW(wbuf, size_wbuf, &size_used);
349 if (ret)
351 if (!(ret = SQLInstall_narrow(2, lpszBuf, wbuf, size_used, cbBufMax, pcbBufOut)))
353 push_error(ODBC_ERROR_GENERAL_ERR, odbc_error_general_err);
356 HeapFree(GetProcessHeap(), 0, wbuf);
357 /* ignore failure; we have achieved the aim */
359 else
361 push_error(ODBC_ERROR_OUT_OF_MEM, odbc_error_out_of_mem);
362 ret = FALSE;
364 return ret;
367 int WINAPI SQLGetPrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry,
368 LPCWSTR lpszDefault, LPCWSTR RetBuffer, int cbRetBuffer,
369 LPCWSTR lpszFilename)
371 clear_errors();
372 FIXME("\n");
373 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
374 return FALSE;
377 int WINAPI SQLGetPrivateProfileString(LPCSTR lpszSection, LPCSTR lpszEntry,
378 LPCSTR lpszDefault, LPCSTR RetBuffer, int cbRetBuffer,
379 LPCSTR lpszFilename)
381 clear_errors();
382 FIXME("\n");
383 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
384 return FALSE;
387 BOOL WINAPI SQLGetTranslatorW(HWND hwndParent, LPWSTR lpszName, WORD cbNameMax,
388 WORD *pcbNameOut, LPWSTR lpszPath, WORD cbPathMax,
389 WORD *pcbPathOut, DWORD *pvOption)
391 clear_errors();
392 FIXME("\n");
393 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
394 return FALSE;
397 BOOL WINAPI SQLGetTranslator(HWND hwndParent, LPSTR lpszName, WORD cbNameMax,
398 WORD *pcbNameOut, LPSTR lpszPath, WORD cbPathMax,
399 WORD *pcbPathOut, DWORD *pvOption)
401 clear_errors();
402 FIXME("\n");
403 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
404 return FALSE;
407 BOOL WINAPI SQLInstallDriverW(LPCWSTR lpszInfFile, LPCWSTR lpszDriver,
408 LPWSTR lpszPath, WORD cbPathMax, WORD * pcbPathOut)
410 DWORD usage;
412 clear_errors();
413 TRACE("%s %s %p %d %p\n", debugstr_w(lpszInfFile),
414 debugstr_w(lpszDriver), lpszPath, cbPathMax, pcbPathOut);
416 if (lpszInfFile)
417 return FALSE;
419 return SQLInstallDriverExW(lpszDriver, NULL, lpszPath, cbPathMax,
420 pcbPathOut, ODBC_INSTALL_COMPLETE, &usage);
423 BOOL WINAPI SQLInstallDriver(LPCSTR lpszInfFile, LPCSTR lpszDriver,
424 LPSTR lpszPath, WORD cbPathMax, WORD * pcbPathOut)
426 DWORD usage;
428 clear_errors();
429 TRACE("%s %s %p %d %p\n", debugstr_a(lpszInfFile),
430 debugstr_a(lpszDriver), lpszPath, cbPathMax, pcbPathOut);
432 if (lpszInfFile)
433 return FALSE;
435 return SQLInstallDriverEx(lpszDriver, NULL, lpszPath, cbPathMax,
436 pcbPathOut, ODBC_INSTALL_COMPLETE, &usage);
439 BOOL WINAPI SQLInstallDriverExW(LPCWSTR lpszDriver, LPCWSTR lpszPathIn,
440 LPWSTR lpszPathOut, WORD cbPathOutMax, WORD *pcbPathOut,
441 WORD fRequest, LPDWORD lpdwUsageCount)
443 UINT len;
444 LPCWSTR p;
445 WCHAR path[MAX_PATH];
447 clear_errors();
448 TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszDriver),
449 debugstr_w(lpszPathIn), lpszPathOut, cbPathOutMax, pcbPathOut,
450 fRequest, lpdwUsageCount);
452 for (p = lpszDriver; *p; p += lstrlenW(p) + 1)
453 TRACE("%s\n", debugstr_w(p));
455 len = GetSystemDirectoryW(path, MAX_PATH);
457 if (pcbPathOut)
458 *pcbPathOut = len;
460 len = GetSystemDirectoryW(path, MAX_PATH);
462 if (lpszPathOut && cbPathOutMax > len)
464 lstrcpyW(lpszPathOut, path);
465 return TRUE;
467 return FALSE;
470 BOOL WINAPI SQLInstallDriverEx(LPCSTR lpszDriver, LPCSTR lpszPathIn,
471 LPSTR lpszPathOut, WORD cbPathOutMax, WORD *pcbPathOut,
472 WORD fRequest, LPDWORD lpdwUsageCount)
474 LPCSTR p;
475 LPWSTR driver, pathin;
476 WCHAR pathout[MAX_PATH];
477 BOOL ret;
478 WORD cbOut = 0;
480 clear_errors();
481 TRACE("%s %s %p %d %p %d %p\n", debugstr_a(lpszDriver),
482 debugstr_a(lpszPathIn), lpszPathOut, cbPathOutMax, pcbPathOut,
483 fRequest, lpdwUsageCount);
485 for (p = lpszDriver; *p; p += lstrlenA(p) + 1)
486 TRACE("%s\n", debugstr_a(p));
488 driver = SQLInstall_strdup_multi(lpszDriver);
489 pathin = SQLInstall_strdup(lpszPathIn);
491 ret = SQLInstallDriverExW(driver, pathin, pathout, MAX_PATH, &cbOut,
492 fRequest, lpdwUsageCount);
493 if (ret)
495 int len = WideCharToMultiByte(CP_ACP, 0, pathout, -1, lpszPathOut,
496 0, NULL, NULL);
497 if (len)
499 if (pcbPathOut)
500 *pcbPathOut = len - 1;
502 if (!lpszPathOut || cbPathOutMax < len)
504 ret = FALSE;
505 goto out;
507 len = WideCharToMultiByte(CP_ACP, 0, pathout, -1, lpszPathOut,
508 cbPathOutMax, NULL, NULL);
512 out:
513 HeapFree(GetProcessHeap(), 0, driver);
514 HeapFree(GetProcessHeap(), 0, pathin);
515 return ret;
518 BOOL WINAPI SQLInstallDriverManagerW(LPWSTR lpszPath, WORD cbPathMax,
519 WORD *pcbPathOut)
521 UINT len;
522 WCHAR path[MAX_PATH];
524 TRACE("(%p %d %p)\n", lpszPath, cbPathMax, pcbPathOut);
526 if (cbPathMax < MAX_PATH)
527 return FALSE;
529 clear_errors();
531 len = GetSystemDirectoryW(path, MAX_PATH);
533 if (pcbPathOut)
534 *pcbPathOut = len;
536 if (lpszPath && cbPathMax > len)
538 lstrcpyW(lpszPath, path);
539 return TRUE;
541 return FALSE;
544 BOOL WINAPI SQLInstallDriverManager(LPSTR lpszPath, WORD cbPathMax,
545 WORD *pcbPathOut)
547 BOOL ret;
548 WORD len, cbOut = 0;
549 WCHAR path[MAX_PATH];
551 TRACE("(%p %d %p)\n", lpszPath, cbPathMax, pcbPathOut);
553 if (cbPathMax < MAX_PATH)
554 return FALSE;
556 clear_errors();
558 ret = SQLInstallDriverManagerW(path, MAX_PATH, &cbOut);
559 if (ret)
561 len = WideCharToMultiByte(CP_ACP, 0, path, -1, lpszPath, 0,
562 NULL, NULL);
563 if (len)
565 if (pcbPathOut)
566 *pcbPathOut = len - 1;
568 if (!lpszPath || cbPathMax < len)
569 return FALSE;
571 len = WideCharToMultiByte(CP_ACP, 0, path, -1, lpszPath,
572 cbPathMax, NULL, NULL);
575 return ret;
578 BOOL WINAPI SQLInstallODBCW(HWND hwndParent, LPCWSTR lpszInfFile,
579 LPCWSTR lpszSrcPath, LPCWSTR lpszDrivers)
581 clear_errors();
582 FIXME("\n");
583 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
584 return FALSE;
587 BOOL WINAPI SQLInstallODBC(HWND hwndParent, LPCSTR lpszInfFile,
588 LPCSTR lpszSrcPath, LPCSTR lpszDrivers)
590 clear_errors();
591 FIXME("\n");
592 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
593 return FALSE;
596 SQLRETURN WINAPI SQLInstallerErrorW(WORD iError, DWORD *pfErrorCode,
597 LPWSTR lpszErrorMsg, WORD cbErrorMsgMax, WORD *pcbErrorMsg)
599 TRACE("%d %p %p %d %p\n", iError, pfErrorCode, lpszErrorMsg,
600 cbErrorMsgMax, pcbErrorMsg);
602 if (iError == 0)
604 return SQL_ERROR;
606 else if (iError <= num_errors)
608 BOOL truncated = FALSE;
609 WORD len;
610 LPCWSTR msg;
611 iError--;
612 if (pfErrorCode)
613 *pfErrorCode = error_code[iError];
614 msg = error_msg[iError];
615 len = msg ? lstrlenW(msg) : 0;
616 if (pcbErrorMsg)
617 *pcbErrorMsg = len;
618 len++;
619 if (cbErrorMsgMax < len)
621 len = cbErrorMsgMax;
622 truncated = TRUE;
624 if (lpszErrorMsg && len)
626 if (msg)
628 memcpy (lpszErrorMsg, msg, len * sizeof(WCHAR));
630 else
632 assert(len==1);
633 *lpszErrorMsg = 0;
636 else
638 /* Yes. If you pass a null pointer and a large length it is not an error! */
639 truncated = TRUE;
642 return truncated ? SQL_SUCCESS_WITH_INFO : SQL_SUCCESS;
645 /* 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 */
646 if (pcbErrorMsg)
647 *pcbErrorMsg = 0;
649 if (lpszErrorMsg && cbErrorMsgMax > 0)
650 *lpszErrorMsg = '\0';
652 return SQL_NO_DATA;
655 SQLRETURN WINAPI SQLInstallerError(WORD iError, DWORD *pfErrorCode,
656 LPSTR lpszErrorMsg, WORD cbErrorMsgMax, WORD *pcbErrorMsg)
658 SQLRETURN ret;
659 LPWSTR wbuf;
660 WORD cbwbuf;
661 TRACE("%d %p %p %d %p\n", iError, pfErrorCode, lpszErrorMsg,
662 cbErrorMsgMax, pcbErrorMsg);
664 wbuf = 0;
665 if (lpszErrorMsg && cbErrorMsgMax)
667 wbuf = HeapAlloc(GetProcessHeap(), 0, cbErrorMsgMax*sizeof(WCHAR));
668 if (!wbuf)
669 return SQL_ERROR;
671 ret = SQLInstallerErrorW(iError, pfErrorCode, wbuf, cbErrorMsgMax, &cbwbuf);
672 if (wbuf)
674 WORD cbBuf = 0;
675 SQLInstall_narrow(1, lpszErrorMsg, wbuf, cbwbuf+1, cbErrorMsgMax, &cbBuf);
676 HeapFree(GetProcessHeap(), 0, wbuf);
677 if (pcbErrorMsg)
678 *pcbErrorMsg = cbBuf-1;
680 return ret;
683 BOOL WINAPI SQLInstallTranslatorExW(LPCWSTR lpszTranslator, LPCWSTR lpszPathIn,
684 LPWSTR lpszPathOut, WORD cbPathOutMax, WORD *pcbPathOut,
685 WORD fRequest, LPDWORD lpdwUsageCount)
687 UINT len;
688 LPCWSTR p;
689 WCHAR path[MAX_PATH];
691 clear_errors();
692 TRACE("%s %s %p %d %p %d %p\n", debugstr_w(lpszTranslator),
693 debugstr_w(lpszPathIn), lpszPathOut, cbPathOutMax, pcbPathOut,
694 fRequest, lpdwUsageCount);
696 for (p = lpszTranslator; *p; p += lstrlenW(p) + 1)
697 TRACE("%s\n", debugstr_w(p));
699 len = GetSystemDirectoryW(path, MAX_PATH);
701 if (pcbPathOut)
702 *pcbPathOut = len;
704 if (lpszPathOut && cbPathOutMax > len)
706 lstrcpyW(lpszPathOut, path);
707 return TRUE;
709 return FALSE;
712 BOOL WINAPI SQLInstallTranslatorEx(LPCSTR lpszTranslator, LPCSTR lpszPathIn,
713 LPSTR lpszPathOut, WORD cbPathOutMax, WORD *pcbPathOut,
714 WORD fRequest, LPDWORD lpdwUsageCount)
716 LPCSTR p;
717 LPWSTR translator, pathin;
718 WCHAR pathout[MAX_PATH];
719 BOOL ret;
720 WORD cbOut = 0;
722 clear_errors();
723 TRACE("%s %s %p %d %p %d %p\n", debugstr_a(lpszTranslator),
724 debugstr_a(lpszPathIn), lpszPathOut, cbPathOutMax, pcbPathOut,
725 fRequest, lpdwUsageCount);
727 for (p = lpszTranslator; *p; p += lstrlenA(p) + 1)
728 TRACE("%s\n", debugstr_a(p));
730 translator = SQLInstall_strdup_multi(lpszTranslator);
731 pathin = SQLInstall_strdup(lpszPathIn);
733 ret = SQLInstallTranslatorExW(translator, pathin, pathout, MAX_PATH,
734 &cbOut, fRequest, lpdwUsageCount);
735 if (ret)
737 int len = WideCharToMultiByte(CP_ACP, 0, pathout, -1, lpszPathOut,
738 0, NULL, NULL);
739 if (len)
741 if (pcbPathOut)
742 *pcbPathOut = len - 1;
744 if (!lpszPathOut || cbPathOutMax < len)
746 ret = FALSE;
747 goto out;
749 len = WideCharToMultiByte(CP_ACP, 0, pathout, -1, lpszPathOut,
750 cbPathOutMax, NULL, NULL);
754 out:
755 HeapFree(GetProcessHeap(), 0, translator);
756 HeapFree(GetProcessHeap(), 0, pathin);
757 return ret;
760 BOOL WINAPI SQLInstallTranslator(LPCSTR lpszInfFile, LPCSTR lpszTranslator,
761 LPCSTR lpszPathIn, LPSTR lpszPathOut, WORD cbPathOutMax,
762 WORD *pcbPathOut, WORD fRequest, LPDWORD lpdwUsageCount)
764 clear_errors();
765 TRACE("%s %s %s %p %d %p %d %p\n", debugstr_a(lpszInfFile),
766 debugstr_a(lpszTranslator), debugstr_a(lpszPathIn), lpszPathOut,
767 cbPathOutMax, pcbPathOut, fRequest, lpdwUsageCount);
769 if (lpszInfFile)
770 return FALSE;
772 return SQLInstallTranslatorEx(lpszTranslator, lpszPathIn, lpszPathOut,
773 cbPathOutMax, pcbPathOut, fRequest, lpdwUsageCount);
776 BOOL WINAPI SQLInstallTranslatorW(LPCWSTR lpszInfFile, LPCWSTR lpszTranslator,
777 LPCWSTR lpszPathIn, LPWSTR lpszPathOut, WORD cbPathOutMax,
778 WORD *pcbPathOut, WORD fRequest, LPDWORD lpdwUsageCount)
780 clear_errors();
781 TRACE("%s %s %s %p %d %p %d %p\n", debugstr_w(lpszInfFile),
782 debugstr_w(lpszTranslator), debugstr_w(lpszPathIn), lpszPathOut,
783 cbPathOutMax, pcbPathOut, fRequest, lpdwUsageCount);
785 if (lpszInfFile)
786 return FALSE;
788 return SQLInstallTranslatorExW(lpszTranslator, lpszPathIn, lpszPathOut,
789 cbPathOutMax, pcbPathOut, fRequest, lpdwUsageCount);
792 BOOL WINAPI SQLManageDataSources(HWND hwnd)
794 clear_errors();
795 FIXME("\n");
796 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
797 return FALSE;
800 SQLRETURN WINAPI SQLPostInstallerErrorW(DWORD fErrorCode, LPCWSTR szErrorMsg)
802 FIXME("\n");
803 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
804 return FALSE;
807 SQLRETURN WINAPI SQLPostInstallerError(DWORD fErrorCode, LPCSTR szErrorMsg)
809 FIXME("\n");
810 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
811 return FALSE;
814 BOOL WINAPI SQLReadFileDSNW(LPCWSTR lpszFileName, LPCWSTR lpszAppName,
815 LPCWSTR lpszKeyName, LPWSTR lpszString, WORD cbString,
816 WORD *pcbString)
818 clear_errors();
819 FIXME("\n");
820 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
821 return FALSE;
824 BOOL WINAPI SQLReadFileDSN(LPCSTR lpszFileName, LPCSTR lpszAppName,
825 LPCSTR lpszKeyName, LPSTR lpszString, WORD cbString,
826 WORD *pcbString)
828 clear_errors();
829 FIXME("\n");
830 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
831 return FALSE;
834 BOOL WINAPI SQLRemoveDefaultDataSource(void)
836 clear_errors();
837 FIXME("\n");
838 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
839 return FALSE;
842 BOOL WINAPI SQLRemoveDriverW(LPCWSTR lpszDriver, BOOL fRemoveDSN,
843 LPDWORD lpdwUsageCount)
845 clear_errors();
846 FIXME("stub\n");
847 if (lpdwUsageCount) *lpdwUsageCount = 1;
848 return TRUE;
851 BOOL WINAPI SQLRemoveDriver(LPCSTR lpszDriver, BOOL fRemoveDSN,
852 LPDWORD lpdwUsageCount)
854 clear_errors();
855 FIXME("stub\n");
856 if (lpdwUsageCount) *lpdwUsageCount = 1;
857 return TRUE;
860 BOOL WINAPI SQLRemoveDriverManager(LPDWORD pdwUsageCount)
862 clear_errors();
863 FIXME("stub\n");
864 if (pdwUsageCount) *pdwUsageCount = 1;
865 return TRUE;
868 BOOL WINAPI SQLRemoveDSNFromIniW(LPCWSTR lpszDSN)
870 clear_errors();
871 FIXME("\n");
872 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
873 return FALSE;
876 BOOL WINAPI SQLRemoveDSNFromIni(LPCSTR lpszDSN)
878 clear_errors();
879 FIXME("\n");
880 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
881 return FALSE;
884 BOOL WINAPI SQLRemoveTranslatorW(LPCWSTR lpszTranslator, LPDWORD lpdwUsageCount)
886 clear_errors();
887 FIXME("\n");
888 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
889 return FALSE;
892 BOOL WINAPI SQLRemoveTranslator(LPCSTR lpszTranslator, LPDWORD lpdwUsageCount)
894 clear_errors();
895 FIXME("\n");
896 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
897 return FALSE;
900 BOOL WINAPI SQLSetConfigMode(UWORD wConfigMode)
902 clear_errors();
903 if (wConfigMode > ODBC_SYSTEM_DSN)
905 push_error(ODBC_ERROR_INVALID_PARAM_SEQUENCE, odbc_error_invalid_param_sequence);
906 return FALSE;
908 else
910 config_mode = wConfigMode;
911 return TRUE;
915 BOOL WINAPI SQLValidDSNW(LPCWSTR lpszDSN)
917 clear_errors();
918 FIXME("\n");
919 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
920 return FALSE;
923 BOOL WINAPI SQLValidDSN(LPCSTR lpszDSN)
925 clear_errors();
926 FIXME("\n");
927 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
928 return FALSE;
931 BOOL WINAPI SQLWriteDSNToIniW(LPCWSTR lpszDSN, LPCWSTR lpszDriver)
933 clear_errors();
934 FIXME("\n");
935 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
936 return FALSE;
939 BOOL WINAPI SQLWriteDSNToIni(LPCSTR lpszDSN, LPCSTR lpszDriver)
941 clear_errors();
942 FIXME("\n");
943 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
944 return FALSE;
947 BOOL WINAPI SQLWriteFileDSNW(LPCWSTR lpszFileName, LPCWSTR lpszAppName,
948 LPCWSTR lpszKeyName, LPCWSTR lpszString)
950 clear_errors();
951 FIXME("\n");
952 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
953 return FALSE;
956 BOOL WINAPI SQLWriteFileDSN(LPCSTR lpszFileName, LPCSTR lpszAppName,
957 LPCSTR lpszKeyName, LPCSTR lpszString)
959 clear_errors();
960 FIXME("\n");
961 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
962 return FALSE;
965 BOOL WINAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection, LPCWSTR lpszEntry,
966 LPCWSTR lpszString, LPCWSTR lpszFilename)
968 clear_errors();
969 FIXME("\n");
970 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
971 return FALSE;
974 BOOL WINAPI SQLWritePrivateProfileString(LPCSTR lpszSection, LPCSTR lpszEntry,
975 LPCSTR lpszString, LPCSTR lpszFilename)
977 clear_errors();
978 FIXME("\n");
979 SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
980 return FALSE;