3 /*************************************************************
6 * This is the lowest level include in unixODBC. It defines
7 * the basic types required by unixODBC and is heavily based
8 * upon the MS include of the same name (it has to be for
9 * binary compatability between drivers developed under different
12 * You can include this file directly but it is almost always
13 * included indirectly, by including.. for example sqlext.h
15 * This include makes no effort to be usefull on any platforms other
16 * than Linux (with some exceptions for UNIX in general).
18 * !!!DO NOT CONTAMINATE THIS FILE WITH NON-Linux CODE!!!
20 *************************************************************/
24 /****************************
25 * default to the 3.51 definitions. should define ODBCVER before here if you want an older set of defines
26 ***************************/
28 #define ODBCVER 0x0351
32 * if thi sis set, then use a 4 byte unicode definition, insteead of the 2 bye that MS use
35 #ifdef SQL_WCHART_CONVERT
37 * Use this if you want to use the C/C++ portable definition of a wide char, wchar_t
38 * Microsoft hardcoded a definition of unsigned short which may not be compatible with
39 * your platform specific wide char definition.
49 * this is defined by configure, but will not be on a normal application build
50 * the install creates a unixodbc_conf.h file that contains the current build settings
53 #ifndef SIZEOF_LONG_INT
54 #include <unixodbc_conf.h>
57 #ifndef SIZEOF_LONG_INT
58 #error "Needs to know how big a long int is to continue!!!"
62 /****************************
63 * These make up for having no windows.h
64 ***************************/
65 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
70 #define SQL_API _System
80 * NOTE: The Microsoft unicode define is only for apps that want to use TCHARs and
81 * be able to compile for both unicode and non-unicode with the same source.
82 * This is not recommanded for linux applications and is not supported
83 * by the standard linux string header files.
85 #ifdef SQL_WCHART_CONVERT
86 typedef wchar_t TCHAR
;
88 typedef signed short TCHAR
;
99 typedef unsigned short WORD
;
100 #if (SIZEOF_LONG_INT == 4)
101 typedef unsigned long DWORD
;
103 typedef unsigned int DWORD
;
105 typedef unsigned char BYTE
;
107 #ifdef SQL_WCHART_CONVERT
108 typedef wchar_t WCHAR
;
110 typedef unsigned short WCHAR
;
113 typedef WCHAR
* LPWSTR
;
114 typedef const char* LPCSTR
;
115 typedef const WCHAR
* LPCWSTR
;
116 typedef TCHAR
* LPTSTR
;
118 typedef DWORD
* LPDWORD
;
120 typedef void* HINSTANCE
;
125 /****************************
126 * standard SQL* data types. use these as much as possible when using ODBC calls/vars
127 ***************************/
128 typedef unsigned char SQLCHAR
;
130 #if (ODBCVER >= 0x0300)
131 typedef unsigned char SQLDATE
;
132 typedef unsigned char SQLDECIMAL
;
133 typedef double SQLDOUBLE
;
134 typedef double SQLFLOAT
;
138 * can't use a long it fails on 64 platforms
142 * I (Nick) have made these changes, to cope with the new 3.52 MS
143 * changes for 64 bit ODBC, but looking at MS's spec they havn't
144 * finished it themself. For example, SQLBindCol now expects the
145 * indicator variable to be a SQLLEN which then is a pointer to
146 * a 64 bit value. However the online book that comes with the
147 * headers, then goes on to describe the indicator_ptr in the
148 * descriptor record (which is set by SQLBindCol) as a pointer
149 * to a SQLINTEGER (32 bit). So I don't think its ready for the
150 * big time yet. Thats not to mention all the ODBC apps on 64 bit
151 * platforms that this would break...
154 * Hopefully by now it should be safe to assume most drivers know about SQLLEN now
158 #if (SIZEOF_LONG_INT == 8)
159 #ifdef BUILD_LEGACY_64_BIT_MODE
160 typedef int SQLINTEGER
;
161 typedef unsigned int SQLUINTEGER
;
162 #define SQLLEN SQLINTEGER
163 #define SQLULEN SQLUINTEGER
164 #define SQLSETPOSIROW SQLUSMALLINT
165 typedef SQLULEN SQLROWCOUNT
;
166 typedef SQLULEN SQLROWSETSIZE
;
167 typedef SQLULEN SQLTRANSID
;
168 typedef SQLLEN SQLROWOFFSET
;
170 typedef int SQLINTEGER
;
171 typedef unsigned int SQLUINTEGER
;
173 typedef unsigned long SQLULEN
;
174 typedef unsigned long SQLSETPOSIROW
;
176 * These are not supprted on 64bit ODBC according to MS
177 * typedef SQLULEN SQLTRANSID;
179 typedef SQLULEN SQLROWCOUNT
;
180 typedef SQLUINTEGER SQLROWSETSIZE
;
181 typedef SQLLEN SQLROWOFFSET
;
184 typedef long SQLINTEGER
;
185 typedef unsigned long SQLUINTEGER
;
186 #define SQLLEN SQLINTEGER
187 #define SQLULEN SQLUINTEGER
188 #define SQLSETPOSIROW SQLUSMALLINT
189 typedef SQLULEN SQLROWCOUNT
;
190 typedef SQLULEN SQLROWSETSIZE
;
191 typedef SQLULEN SQLTRANSID
;
192 typedef SQLLEN SQLROWOFFSET
;
195 #if (ODBCVER >= 0x0300)
196 typedef unsigned char SQLNUMERIC
;
199 typedef void * SQLPOINTER
;
201 #if (ODBCVER >= 0x0300)
202 typedef float SQLREAL
;
205 typedef signed short int SQLSMALLINT
;
206 typedef unsigned short SQLUSMALLINT
;
208 #if (ODBCVER >= 0x0300)
209 typedef unsigned char SQLTIME
;
210 typedef unsigned char SQLTIMESTAMP
;
211 typedef unsigned char SQLVARCHAR
;
214 typedef SQLSMALLINT SQLRETURN
;
216 #if (ODBCVER >= 0x0300)
217 typedef void * SQLHANDLE
;
218 typedef SQLHANDLE SQLHENV
;
219 typedef SQLHANDLE SQLHDBC
;
220 typedef SQLHANDLE SQLHSTMT
;
221 typedef SQLHANDLE SQLHDESC
;
223 typedef void * SQLHENV
;
224 typedef void * SQLHDBC
;
225 typedef void * SQLHSTMT
;
227 * some things like PHP won't build without this
229 typedef void * SQLHANDLE
;
232 /****************************
233 * These are cast into the actual struct that is being passed around. The
234 * DriverManager knows what its structs look like and the Driver knows about its
235 * structs... the app knows nothing about them... just void*
236 * These are deprecated in favour of SQLHENV, SQLHDBC, SQLHSTMT
237 ***************************/
239 #if (ODBCVER >= 0x0300)
240 typedef SQLHANDLE HENV
;
241 typedef SQLHANDLE HDBC
;
242 typedef SQLHANDLE HSTMT
;
246 typedef void * HSTMT
;
250 /****************************
251 * more basic data types to augment what windows.h provides
252 ***************************/
253 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
255 typedef unsigned char UCHAR
;
256 typedef signed char SCHAR
;
257 typedef SCHAR SQLSCHAR
;
258 #if (SIZEOF_LONG_INT == 4)
259 typedef long int SDWORD
;
260 typedef unsigned long int UDWORD
;
263 typedef unsigned int UDWORD
;
265 typedef signed short int SWORD
;
266 typedef unsigned short int UWORD
;
267 typedef unsigned int UINT
;
268 typedef signed long SLONG
;
269 typedef signed short SSHORT
;
270 typedef unsigned long ULONG
;
271 typedef unsigned short USHORT
;
272 typedef double SDOUBLE
;
273 typedef double LDOUBLE
;
274 typedef float SFLOAT
;
276 typedef signed short RETCODE
;
277 typedef void* SQLHWND
;
281 /****************************
282 * standard structs for working with date/times
283 ***************************/
286 typedef struct tagDATE_STRUCT
293 #if (ODBCVER >= 0x0300)
294 typedef DATE_STRUCT SQL_DATE_STRUCT
;
297 typedef struct tagTIME_STRUCT
304 #if (ODBCVER >= 0x0300)
305 typedef TIME_STRUCT SQL_TIME_STRUCT
;
308 typedef struct tagTIMESTAMP_STRUCT
316 SQLUINTEGER fraction
;
319 #if (ODBCVER >= 0x0300)
320 typedef TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT
;
324 #if (ODBCVER >= 0x0300)
333 SQL_IS_YEAR_TO_MONTH
= 7,
334 SQL_IS_DAY_TO_HOUR
= 8,
335 SQL_IS_DAY_TO_MINUTE
= 9,
336 SQL_IS_DAY_TO_SECOND
= 10,
337 SQL_IS_HOUR_TO_MINUTE
= 11,
338 SQL_IS_HOUR_TO_SECOND
= 12,
339 SQL_IS_MINUTE_TO_SECOND
= 13
344 #if (ODBCVER >= 0x0300)
345 typedef struct tagSQL_YEAR_MONTH
349 } SQL_YEAR_MONTH_STRUCT
;
351 typedef struct tagSQL_DAY_SECOND
357 SQLUINTEGER fraction
;
358 } SQL_DAY_SECOND_STRUCT
;
360 typedef struct tagSQL_INTERVAL_STRUCT
362 SQLINTERVAL interval_type
;
363 SQLSMALLINT interval_sign
;
365 SQL_YEAR_MONTH_STRUCT year_month
;
366 SQL_DAY_SECOND_STRUCT day_second
;
369 } SQL_INTERVAL_STRUCT
;
375 /****************************
377 ***************************/
378 #if (ODBCVER >= 0x0300)
379 #if (SIZEOF_LONG_INT == 8)
380 # define ODBCINT64 long
381 # define UODBCINT64 unsigned long
383 # ifdef HAVE_LONG_LONG
384 # define ODBCINT64 long long
385 # define UODBCINT64 unsigned long long
388 * may fail in some cases, but what else can we do ?
390 struct __bigint_struct
395 struct __bigint_struct_u
400 # define ODBCINT64 struct __bigint_struct
401 # define UODBCINT64 struct __bigint_struct_u
405 typedef ODBCINT64 SQLBIGINT
;
408 typedef UODBCINT64 SQLUBIGINT
;
413 /****************************
414 * cursor and bookmark
415 ***************************/
416 #if (ODBCVER >= 0x0300)
417 #define SQL_MAX_NUMERIC_LEN 16
418 typedef struct tagSQL_NUMERIC_STRUCT
422 SQLCHAR sign
; /* 1=pos 0=neg */
423 SQLCHAR val
[SQL_MAX_NUMERIC_LEN
];
424 } SQL_NUMERIC_STRUCT
;
427 #if (ODBCVER >= 0x0350)
429 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
430 typedef GUID SQLGUID
;
432 typedef struct tagSQLGUID
441 typedef struct tagSQLGUID
451 typedef SQLULEN BOOKMARK
;
453 typedef WCHAR SQLWCHAR
;
456 typedef SQLWCHAR SQLTCHAR
;
458 typedef SQLCHAR SQLTCHAR
;