1/**************************************************
2 * odbcinst.h
3 *
4 **************************************************
5 * This code was created by Peter Harvey @ CodeByDesign.
6 * Released under LGPL 28.JAN.99
7 *
8 * Contributions from...
9 * -----------------------------------------------
10 * Peter Harvey - pharvey@codebydesign.com
11 **************************************************/
12#ifndef __ODBCINST_H
13#define __ODBCINST_H
14
15#include <stdio.h>
16
17#ifndef BOOL
18#define BOOL int
19#endif
20
21#ifndef __SQL
22#include "sql.h"
23#endif
24
25
26/*!
27 * \brief Our generic window handle.
28 *
29 * This is used wherever a HWND is needed. The caller inits this according
30 * to which UI the caller has (or simply desires). This may be a; console, xlib, qt3, qt4,
31 * gtk, mono, carbon, etc.
32 *
33 * SQLCreateDataSource
34 * (maps to ODBCCreateDataSource entry point in UI plugin)
35 *
36 * This function requires a HWND (and it must NOT be NULL as per ODBC spec.). So
37 * the caller should *always* init an ODBCINSTWND and cast it to HWND as it is passed to
38 * SQLCreateDataSource.
39 *
40 * SQLManageDataSources
41 * (maps to ODBCManageDataSources entry point in UI plugin)
42 *
43 * This function requires a HWND (and it must NOT be NULL as per ODBC spec.). So
44 * the caller should *always* init an ODBCINSTWND and cast it to HWND as it is passed to
45 * SQLManageDataSources. However; it may make sense to have a NULL hWnd... this is what
46 * an ODBC Administrator program would typically do.
47 *
48 * Plugin Selection
49 *
50 * 1. Passing a NULL to a function instead of a valid HODBCINSTWND may result in an error
51 * (this is the case with SQLCreateDataSource). In anycase; passing a NULL in this way
52 * negates the use of any UI plugin.
53 *
54 * 2. szUI has a value and it is the file name (no path and no extension) of the UI
55 * plugin. The plugin is loaded and the appropriate function is called with hWnd. The
56 * caller must have init hWnd in a manner which is appropriate for the UI plugin.
57 *
58 * 3. Passing an empty szUI indicates that the UI plugin should be determined by other
59 * means (see 4). In such a case it is dangerous to use hWnd because it may not match
60 * the type expected by the plugin. hWnd will be ignored and a NULL will be passed to the UI
61 * plugin.
62 *
63 * 4. The fallback logic for determining the UI plugin is as follows;
64 * - use the ODBCINSTUI environment variable to get the UI plugin file name
65 * - use the ODBCINSTUI value in odbcinst.ini to get the UI plugin file name
66 *
67 * NOTE: In the future we may want to consider making HWND of this type instead of having
68 * two different types and having to cast HODBCINSTWND into a HWND.
69 */
70typedef struct tODBCINSTWND
71{
72 char szUI[FILENAME_MAX]; /*!< Plugin file name (no path and no extension) ie "odbcinstQ4". */
73 HWND hWnd; /*!< this is passed to the UI plugin - caller must know what the plugin is expecting */
74
75} ODBCINSTWND, *HODBCINSTWND;
76
77
78#ifdef __cplusplus
79extern "C" {
80#endif
81
82#ifndef ODBCVER
83#define ODBCVER 0x0351
84#endif
85
86#ifndef WINVER
87#define WINVER 0x0400
88#endif
89
90/* SQLConfigDataSource request flags */
91#define ODBC_ADD_DSN 1
92#define ODBC_CONFIG_DSN 2
93#define ODBC_REMOVE_DSN 3
94
95#if (ODBCVER >= 0x0250)
96#define ODBC_ADD_SYS_DSN 4
97#define ODBC_CONFIG_SYS_DSN 5
98#define ODBC_REMOVE_SYS_DSN 6
99#if (ODBCVER >= 0x0300)
100#define ODBC_REMOVE_DEFAULT_DSN 7
101#endif /* ODBCVER >= 0x0300 */
102
103/* install request flags */
104#define ODBC_INSTALL_INQUIRY 1
105#define ODBC_INSTALL_COMPLETE 2
106
107/* config driver flags */
108#define ODBC_INSTALL_DRIVER 1
109#define ODBC_REMOVE_DRIVER 2
110#define ODBC_CONFIG_DRIVER 3
111#define ODBC_CONFIG_DRIVER_MAX 100
112#endif
113
114/* SQLGetConfigMode and SQLSetConfigMode flags */
115#if (ODBCVER >= 0x0300)
116#define ODBC_BOTH_DSN 0
117#define ODBC_USER_DSN 1
118#define ODBC_SYSTEM_DSN 2
119#endif /* ODBCVER >= 0x0300 */
120
121/* SQLInstallerError code */
122#if (ODBCVER >= 0x0300)
123#define ODBC_ERROR_GENERAL_ERR 1
124#define ODBC_ERROR_INVALID_BUFF_LEN 2
125#define ODBC_ERROR_INVALID_HWND 3
126#define ODBC_ERROR_INVALID_STR 4
127#define ODBC_ERROR_INVALID_REQUEST_TYPE 5
128#define ODBC_ERROR_COMPONENT_NOT_FOUND 6
129#define ODBC_ERROR_INVALID_NAME 7
130#define ODBC_ERROR_INVALID_KEYWORD_VALUE 8
131#define ODBC_ERROR_INVALID_DSN 9
132#define ODBC_ERROR_INVALID_INF 10
133#define ODBC_ERROR_REQUEST_FAILED 11
134#define ODBC_ERROR_INVALID_PATH 12
135#define ODBC_ERROR_LOAD_LIB_FAILED 13
136#define ODBC_ERROR_INVALID_PARAM_SEQUENCE 14
137#define ODBC_ERROR_INVALID_LOG_FILE 15
138#define ODBC_ERROR_USER_CANCELED 16
139#define ODBC_ERROR_USAGE_UPDATE_FAILED 17
140#define ODBC_ERROR_CREATE_DSN_FAILED 18
141#define ODBC_ERROR_WRITING_SYSINFO_FAILED 19
142#define ODBC_ERROR_REMOVE_DSN_FAILED 20
143#define ODBC_ERROR_OUT_OF_MEM 21
144#define ODBC_ERROR_OUTPUT_STRING_TRUNCATED 22
145#endif /* ODBCVER >= 0x0300 */
146
147#ifndef EXPORT
148#define EXPORT
149#endif
150
151#ifdef __OS2__
152#define INSTAPI _System
153#else
154#define INSTAPI
155#endif
156
157/* HIGH LEVEL CALLS */
158BOOL INSTAPI SQLInstallODBC (HWND hwndParent,
159 LPCSTR lpszInfFile,
160 LPCSTR lpszSrcPath,
161 LPCSTR lpszDrivers);
162BOOL INSTAPI SQLManageDataSources (HWND hwndParent);
163BOOL INSTAPI SQLCreateDataSource (HWND hwndParent,
164 LPCSTR lpszDSN);
165BOOL INSTAPI SQLGetTranslator (HWND hwnd,
166 LPSTR lpszName,
167 WORD cbNameMax,
168 WORD *pcbNameOut,
169 LPSTR lpszPath,
170 WORD cbPathMax,
171 WORD *pcbPathOut,
172 DWORD *pvOption);
173
174/* LOW LEVEL CALLS */
175BOOL INSTAPI SQLInstallDriver (LPCSTR lpszInfFile,
176 LPCSTR lpszDriver,
177 LPSTR lpszPath,
178 WORD cbPathMax,
179 WORD * pcbPathOut);
180BOOL INSTAPI SQLInstallDriverManager (LPSTR lpszPath,
181 WORD cbPathMax,
182 WORD * pcbPathOut);
183BOOL INSTAPI SQLGetInstalledDrivers (LPSTR lpszBuf,
184 WORD cbBufMax,
185 WORD * pcbBufOut);
186BOOL INSTAPI SQLGetAvailableDrivers (LPCSTR lpszInfFile,
187 LPSTR lpszBuf,
188 WORD cbBufMax,
189 WORD * pcbBufOut);
190BOOL INSTAPI SQLConfigDataSource (HWND hwndParent,
191 WORD fRequest,
192 LPCSTR lpszDriver,
193 LPCSTR lpszAttributes);
194BOOL INSTAPI SQLRemoveDefaultDataSource(void);
195BOOL INSTAPI SQLWriteDSNToIni (LPCSTR lpszDSN,
196 LPCSTR lpszDriver);
197BOOL INSTAPI SQLRemoveDSNFromIni (LPCSTR lpszDSN);
198BOOL INSTAPI SQLValidDSN (LPCSTR lpszDSN);
199
200BOOL INSTAPI SQLWritePrivateProfileString(LPCSTR lpszSection,
201 LPCSTR lpszEntry,
202 LPCSTR lpszString,
203 LPCSTR lpszFilename);
204
205int INSTAPI SQLGetPrivateProfileString( LPCSTR lpszSection,
206 LPCSTR lpszEntry,
207 LPCSTR lpszDefault,
208 LPSTR lpszRetBuffer,
209 int cbRetBuffer,
210 LPCSTR lpszFilename);
211
212#if (ODBCVER >= 0x0250)
213BOOL INSTAPI SQLRemoveDriverManager(LPDWORD lpdwUsageCount);
214BOOL INSTAPI SQLInstallTranslator(LPCSTR lpszInfFile,
215 LPCSTR lpszTranslator,
216 LPCSTR lpszPathIn,
217 LPSTR lpszPathOut,
218 WORD cbPathOutMax,
219 WORD *pcbPathOut,
220 WORD fRequest,
221 LPDWORD lpdwUsageCount);
222BOOL INSTAPI SQLRemoveTranslator(LPCSTR lpszTranslator,
223 LPDWORD lpdwUsageCount);
224BOOL INSTAPI SQLRemoveDriver(LPCSTR lpszDriver,
225 BOOL fRemoveDSN,
226 LPDWORD lpdwUsageCount);
227BOOL INSTAPI SQLConfigDriver(HWND hwndParent,
228 WORD fRequest,
229 LPCSTR lpszDriver,
230 LPCSTR lpszArgs,
231 LPSTR lpszMsg,
232 WORD cbMsgMax,
233 WORD *pcbMsgOut);
234#endif
235
236#if (ODBCVER >= 0x0300)
237SQLRETURN INSTAPI SQLInstallerError(WORD iError,
238 DWORD *pfErrorCode,
239 LPSTR lpszErrorMsg,
240 WORD cbErrorMsgMax,
241 WORD *pcbErrorMsg);
242SQLRETURN INSTAPI SQLPostInstallerError(DWORD dwErrorCode, LPCSTR lpszErrMsg);
243
244BOOL INSTAPI SQLWriteFileDSN(LPCSTR lpszFileName,
245 LPCSTR lpszAppName,
246 LPCSTR lpszKeyName,
247 LPCSTR lpszString);
248
249BOOL INSTAPI SQLReadFileDSN(LPCSTR lpszFileName,
250 LPCSTR lpszAppName,
251 LPCSTR lpszKeyName,
252 LPSTR lpszString,
253 WORD cbString,
254 WORD *pcbString);
255BOOL INSTAPI SQLInstallDriverEx(LPCSTR lpszDriver,
256 LPCSTR lpszPathIn,
257 LPSTR lpszPathOut,
258 WORD cbPathOutMax,
259 WORD *pcbPathOut,
260 WORD fRequest,
261 LPDWORD lpdwUsageCount);
262BOOL INSTAPI SQLInstallTranslatorEx(LPCSTR lpszTranslator,
263 LPCSTR lpszPathIn,
264 LPSTR lpszPathOut,
265 WORD cbPathOutMax,
266 WORD *pcbPathOut,
267 WORD fRequest,
268 LPDWORD lpdwUsageCount);
269BOOL INSTAPI SQLGetConfigMode(UWORD *pwConfigMode);
270BOOL INSTAPI SQLSetConfigMode(UWORD wConfigMode);
271#endif /* ODBCVER >= 0x0300 */
272
273/* Driver specific Setup APIs called by installer */
274BOOL INSTAPI ConfigDSN (HWND hwndParent,
275 WORD fRequest,
276 LPCSTR lpszDriver,
277 LPCSTR lpszAttributes);
278
279BOOL INSTAPI ConfigTranslator ( HWND hwndParent,
280 DWORD *pvOption);
281
282#if (ODBCVER >= 0x0250)
283BOOL INSTAPI ConfigDriver(HWND hwndParent,
284 WORD fRequest,
285 LPCSTR lpszDriver,
286 LPCSTR lpszArgs,
287 LPSTR lpszMsg,
288 WORD cbMsgMax,
289 WORD *pcbMsgOut);
290#endif
291
292/*
293 * UNICODE APIs
294 */
295
296BOOL INSTAPI SQLInstallODBCW (HWND hwndParent,
297 LPCWSTR lpszInfFile,
298 LPCWSTR lpszSrcPath,
299 LPCWSTR lpszDrivers);
300BOOL INSTAPI SQLCreateDataSourceW (HWND hwndParent,
301 LPCWSTR lpszDSN);
302
303BOOL INSTAPI SQLGetTranslatorW (HWND hwnd,
304 LPWSTR lpszName,
305 WORD cbNameMax,
306 WORD *pcbNameOut,
307 LPWSTR lpszPath,
308 WORD cbPathMax,
309 WORD *pcbPathOut,
310 DWORD *pvOption);
311BOOL INSTAPI SQLInstallDriverW (LPCWSTR lpszInfFile,
312 LPCWSTR lpszDriver,
313 LPWSTR lpszPath,
314 WORD cbPathMax,
315 WORD * pcbPathOut);
316BOOL INSTAPI SQLInstallDriverManagerW (LPWSTR lpszPath,
317 WORD cbPathMax,
318 WORD * pcbPathOut);
319BOOL INSTAPI SQLGetInstalledDriversW (LPWSTR lpszBuf,
320 WORD cbBufMax,
321 WORD * pcbBufOut);
322BOOL INSTAPI SQLGetAvailableDriversW (LPCWSTR lpszInfFile,
323 LPWSTR lpszBuf,
324 WORD cbBufMax,
325 WORD * pcbBufOut);
326BOOL INSTAPI SQLConfigDataSourceW (HWND hwndParent,
327 WORD fRequest,
328 LPCWSTR lpszDriver,
329 LPCWSTR lpszAttributes);
330BOOL INSTAPI SQLWriteDSNToIniW (LPCWSTR lpszDSN,
331 LPCWSTR lpszDriver);
332BOOL INSTAPI SQLRemoveDSNFromIniW (LPCWSTR lpszDSN);
333BOOL INSTAPI SQLValidDSNW (LPCWSTR lpszDSN);
334
335BOOL INSTAPI SQLWritePrivateProfileStringW(LPCWSTR lpszSection,
336 LPCWSTR lpszEntry,
337 LPCWSTR lpszString,
338 LPCWSTR lpszFilename);
339
340int INSTAPI SQLGetPrivateProfileStringW( LPCWSTR lpszSection,
341 LPCWSTR lpszEntry,
342 LPCWSTR lpszDefault,
343 LPWSTR lpszRetBuffer,
344 int cbRetBuffer,
345 LPCWSTR lpszFilename);
346
347#if (ODBCVER >= 0x0250)
348BOOL INSTAPI SQLInstallTranslatorW(LPCWSTR lpszInfFile,
349 LPCWSTR lpszTranslator,
350 LPCWSTR lpszPathIn,
351 LPWSTR lpszPathOut,
352 WORD cbPathOutMax,
353 WORD *pcbPathOut,
354 WORD fRequest,
355 LPDWORD lpdwUsageCount);
356BOOL INSTAPI SQLRemoveTranslatorW(LPCWSTR lpszTranslator,
357 LPDWORD lpdwUsageCount);
358BOOL INSTAPI SQLRemoveDriverW(LPCWSTR lpszDriver,
359 BOOL fRemoveDSN,
360 LPDWORD lpdwUsageCount);
361BOOL INSTAPI SQLConfigDriverW(HWND hwndParent,
362 WORD fRequest,
363 LPCWSTR lpszDriver,
364 LPCWSTR lpszArgs,
365 LPWSTR lpszMsg,
366 WORD cbMsgMax,
367 WORD *pcbMsgOut);
368#endif
369
370#if (ODBCVER >= 0x0300)
371SQLRETURN INSTAPI SQLInstallerErrorW(WORD iError,
372 DWORD *pfErrorCode,
373 LPWSTR lpszErrorMsg,
374 WORD cbErrorMsgMax,
375 WORD *pcbErrorMsg);
376SQLRETURN INSTAPI SQLPostInstallerErrorW(DWORD dwErrorCode,
377 LPCWSTR lpszErrorMsg);
378
379BOOL INSTAPI SQLWriteFileDSNW(LPCWSTR lpszFileName,
380 LPCWSTR lpszAppName,
381 LPCWSTR lpszKeyName,
382 LPCWSTR lpszString);
383
384BOOL INSTAPI SQLReadFileDSNW(LPCWSTR lpszFileName,
385 LPCWSTR lpszAppName,
386 LPCWSTR lpszKeyName,
387 LPWSTR lpszString,
388 WORD cbString,
389 WORD *pcbString);
390BOOL INSTAPI SQLInstallDriverExW(LPCWSTR lpszDriver,
391 LPCWSTR lpszPathIn,
392 LPWSTR lpszPathOut,
393 WORD cbPathOutMax,
394 WORD *pcbPathOut,
395 WORD fRequest,
396 LPDWORD lpdwUsageCount);
397BOOL INSTAPI SQLInstallTranslatorExW(LPCWSTR lpszTranslator,
398 LPCWSTR lpszPathIn,
399 LPWSTR lpszPathOut,
400 WORD cbPathOutMax,
401 WORD *pcbPathOut,
402 WORD fRequest,
403 LPDWORD lpdwUsageCount);
404#endif /* ODBCVER >= 0x0300 */
405
406/* Driver specific Setup APIs called by installer */
407
408BOOL INSTAPI ConfigDSNW (HWND hwndParent,
409 WORD fRequest,
410 LPCWSTR lpszDriver,
411 LPCWSTR lpszAttributes);
412
413
414#if (ODBCVER >= 0x0250)
415BOOL INSTAPI ConfigDriverW(HWND hwndParent,
416 WORD fRequest,
417 LPCWSTR lpszDriver,
418 LPCWSTR lpszArgs,
419 LPWSTR lpszMsg,
420 WORD cbMsgMax,
421 WORD *pcbMsgOut);
422#endif
423
424#ifndef SQL_NOUNICODEMAP /* define this to disable the mapping */
425#ifdef UNICODE
426
427#define SQLInstallODBC SQLInstallODBCW
428#define SQLCreateDataSource SQLCreateDataSourceW
429#define SQLGetTranslator SQLGetTranslatorW
430#define SQLInstallDriver SQLInstallDriverW
431#define SQLInstallDriverManager SQLInstallDriverManagerW
432#define SQLGetInstalledDrivers SQLGetInstalledDriversW
433#define SQLGetAvailableDrivers SQLGetAvailableDriversW
434#define SQLConfigDataSource SQLConfigDataSourceW
435#define SQLWriteDSNToIni SQLWriteDSNToIniW
436#define SQLRemoveDSNFromIni SQLRemoveDSNFromIniW
437#define SQLValidDSN SQLValidDSNW
438#define SQLWritePrivateProfileString SQLWritePrivateProfileStringW
439#define SQLGetPrivateProfileString SQLGetPrivateProfileStringW
440#define SQLInstallTranslator SQLInstallTranslatorW
441#define SQLRemoveTranslator SQLRemoveTranslatorW
442#define SQLRemoveDriver SQLRemoveDriverW
443#define SQLConfigDriver SQLConfigDriverW
444#define SQLInstallerError SQLInstallerErrorW
445#define SQLPostInstallerError SQLPostInstallerErrorW
446#define SQLReadFileDSN SQLReadFileDSNW
447#define SQLWriteFileDSN SQLWriteFileDSNW
448#define SQLInstallDriverEx SQLInstallDriverExW
449#define SQLInstallTranslatorEx SQLInstallTranslatorExW
450
451#endif
452#endif
453
454#ifdef __cplusplus
455}
456#endif
457
458#endif
459