1 /*************************************************************
4 * This is the lowest level include in unixODBC. It defines
5 * the basic types required by unixODBC and is heavily based
6 * upon the MS include of the same name (it has to be for
7 * binary compatability between drivers developed under different
10 * You can include this file directly but it is almost always
11 * included indirectly, by including.. for example sqlext.h
13 * This include makes no effort to be usefull on any platforms other
14 * than Linux (with some exceptions for UNIX in general).
16 * !!!DO NOT CONTAMINATE THIS FILE WITH NON-Linux CODE!!!
18 *************************************************************/
22 /****************************
23 * default to the 3.51 definitions. should define ODBCVER before here if you want an older set of defines
24 ***************************/
26 #define ODBCVER 0x0351
30 * if thi sis set, then use a 4 byte unicode definition, insteead of the 2 bye that MS use
33 #ifdef SQL_WCHART_CONVERT
35 * Use this if you want to use the C/C++ portable definition of a wide char, wchar_t
36 * Microsoft hardcoded a definition of unsigned short which may not be compatible with
37 * your platform specific wide char definition.
42 #include <sal/types.h>
48 #ifndef SIZEOF_LONG_INT
49 # define SIZEOF_LONG_INT SAL_TYPES_SIZEOFLONG
52 # define ODBCINT64 sal_Int64
55 # define UODBCINT64 sal_uInt64
59 * this is defined by configure, but will not be on a normal application build
60 * the install creates a unixodbc_conf.h file that contains the current build settings
63 #ifndef SIZEOF_LONG_INT
64 #include <unixodbc_conf.h>
67 #ifndef SIZEOF_LONG_INT
68 #error "Needs to know how big a long int is to continue!!!"
71 /****************************
72 * These make up for having no windows.h
73 ***************************/
74 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
79 #define SQL_API _System
89 * NOTE: The Microsoft unicode define is only for apps that want to use TCHARs and
90 * be able to compile for both unicode and non-unicode with the same source.
91 * This is not recommanded for linux applications and is not supported
92 * by the standard linux string header files.
94 #ifdef SQL_WCHART_CONVERT
95 typedef wchar_t TCHAR
;
97 typedef signed short TCHAR
;
108 typedef unsigned short WORD
;
109 #if (SIZEOF_LONG_INT == 4)
110 typedef unsigned long DWORD
;
112 typedef unsigned int DWORD
;
114 typedef unsigned char BYTE
;
116 #ifdef SQL_WCHART_CONVERT
117 typedef wchar_t WCHAR
;
119 typedef unsigned short WCHAR
;
122 typedef WCHAR
* LPWSTR
;
123 typedef const char* LPCSTR
;
124 typedef const WCHAR
* LPCWSTR
;
125 typedef TCHAR
* LPTSTR
;
127 typedef DWORD
* LPDWORD
;
129 typedef void* HINSTANCE
;
134 /****************************
135 * standard SQL* data types. use these as much as possible when using ODBC calls/vars
136 ***************************/
137 typedef unsigned char SQLCHAR
;
139 #if (ODBCVER >= 0x0300)
140 typedef unsigned char SQLDATE
;
141 typedef unsigned char SQLDECIMAL
;
142 typedef double SQLDOUBLE
;
143 typedef double SQLFLOAT
;
147 * can't use a long it fails on 64 platforms
151 * Hopefully by now it should be safe to assume most drivers know about SQLLEN now
152 * and the defaukt is now sizeof( SQLLEN ) = 8 on 64 bit platforms
156 #if (SIZEOF_LONG_INT == 8)
157 #ifdef BUILD_LEGACY_64_BIT_MODE
158 typedef int SQLINTEGER
;
159 typedef unsigned int SQLUINTEGER
;
160 #define SQLLEN SQLINTEGER
161 #define SQLULEN SQLUINTEGER
162 #define SQLSETPOSIROW SQLUSMALLINT
164 * These are not supprted on 64bit ODBC according to MS, removed, so use at your peril
166 typedef SQLULEN SQLROWCOUNT;
167 typedef SQLULEN SQLROWSETSIZE;
168 typedef SQLULEN SQLTRANSID;
169 typedef SQLLEN SQLROWOFFSET;
172 typedef int SQLINTEGER
;
173 typedef unsigned int SQLUINTEGER
;
175 typedef unsigned long SQLULEN
;
176 typedef unsigned long SQLSETPOSIROW
;
178 * These are not supprted on 64bit ODBC according to MS, removed, so use at your peril
180 typedef SQLULEN SQLTRANSID;
181 typedef SQLULEN SQLROWCOUNT;
182 typedef SQLUINTEGER SQLROWSETSIZE;
183 typedef SQLLEN SQLROWOFFSET;
185 typedef SQLULEN SQLROWCOUNT
;
186 typedef SQLULEN SQLROWSETSIZE
;
187 typedef SQLULEN SQLTRANSID
;
188 typedef SQLLEN SQLROWOFFSET
;
191 typedef long SQLINTEGER
;
192 typedef unsigned long SQLUINTEGER
;
193 #define SQLLEN SQLINTEGER
194 #define SQLULEN SQLUINTEGER
195 #define SQLSETPOSIROW SQLUSMALLINT
196 typedef SQLULEN SQLROWCOUNT
;
197 typedef SQLULEN SQLROWSETSIZE
;
198 typedef SQLULEN SQLTRANSID
;
199 typedef SQLLEN SQLROWOFFSET
;
202 #if (ODBCVER >= 0x0300)
203 typedef unsigned char SQLNUMERIC
;
206 typedef void * SQLPOINTER
;
208 #if (ODBCVER >= 0x0300)
209 typedef float SQLREAL
;
212 typedef signed short int SQLSMALLINT
;
213 typedef unsigned short SQLUSMALLINT
;
215 #if (ODBCVER >= 0x0300)
216 typedef unsigned char SQLTIME
;
217 typedef unsigned char SQLTIMESTAMP
;
218 typedef unsigned char SQLVARCHAR
;
221 typedef SQLSMALLINT SQLRETURN
;
223 #if (ODBCVER >= 0x0300)
224 typedef void * SQLHANDLE
;
225 typedef SQLHANDLE SQLHENV
;
226 typedef SQLHANDLE SQLHDBC
;
227 typedef SQLHANDLE SQLHSTMT
;
228 typedef SQLHANDLE SQLHDESC
;
230 typedef void * SQLHENV
;
231 typedef void * SQLHDBC
;
232 typedef void * SQLHSTMT
;
234 * some things like PHP won't build without this
236 typedef void * SQLHANDLE
;
239 /****************************
240 * These are cast into the actual struct that is being passed around. The
241 * DriverManager knows what its structs look like and the Driver knows about its
242 * structs... the app knows nothing about them... just void*
243 * These are deprecated in favour of SQLHENV, SQLHDBC, SQLHSTMT
244 ***************************/
246 #if (ODBCVER >= 0x0300)
247 typedef SQLHANDLE HENV
;
248 typedef SQLHANDLE HDBC
;
249 typedef SQLHANDLE HSTMT
;
253 typedef void * HSTMT
;
257 /****************************
258 * more basic data types to augment what windows.h provides
259 ***************************/
260 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
262 typedef unsigned char UCHAR
;
263 typedef signed char SCHAR
;
264 typedef SCHAR SQLSCHAR
;
265 #if (SIZEOF_LONG_INT == 4)
266 typedef long int SDWORD
;
267 typedef unsigned long int UDWORD
;
270 typedef unsigned int UDWORD
;
272 typedef signed short int SWORD
;
273 typedef unsigned short int UWORD
;
274 typedef unsigned int UINT
;
275 typedef signed long SLONG
;
276 typedef signed short SSHORT
;
277 typedef unsigned long ULONG
;
278 typedef unsigned short USHORT
;
279 typedef double SDOUBLE
;
280 typedef double LDOUBLE
;
281 typedef float SFLOAT
;
283 typedef signed short RETCODE
;
284 typedef void* SQLHWND
;
288 /****************************
289 * standard structs for working with date/times
290 ***************************/
293 typedef struct tagDATE_STRUCT
300 #if (ODBCVER >= 0x0300)
301 typedef DATE_STRUCT SQL_DATE_STRUCT
;
304 typedef struct tagTIME_STRUCT
311 #if (ODBCVER >= 0x0300)
312 typedef TIME_STRUCT SQL_TIME_STRUCT
;
315 typedef struct tagTIMESTAMP_STRUCT
323 SQLUINTEGER fraction
;
326 #if (ODBCVER >= 0x0300)
327 typedef TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT
;
331 #if (ODBCVER >= 0x0300)
340 SQL_IS_YEAR_TO_MONTH
= 7,
341 SQL_IS_DAY_TO_HOUR
= 8,
342 SQL_IS_DAY_TO_MINUTE
= 9,
343 SQL_IS_DAY_TO_SECOND
= 10,
344 SQL_IS_HOUR_TO_MINUTE
= 11,
345 SQL_IS_HOUR_TO_SECOND
= 12,
346 SQL_IS_MINUTE_TO_SECOND
= 13
351 #if (ODBCVER >= 0x0300)
352 typedef struct tagSQL_YEAR_MONTH
356 } SQL_YEAR_MONTH_STRUCT
;
358 typedef struct tagSQL_DAY_SECOND
364 SQLUINTEGER fraction
;
365 } SQL_DAY_SECOND_STRUCT
;
367 typedef struct tagSQL_INTERVAL_STRUCT
369 SQLINTERVAL interval_type
;
370 SQLSMALLINT interval_sign
;
372 SQL_YEAR_MONTH_STRUCT year_month
;
373 SQL_DAY_SECOND_STRUCT day_second
;
376 } SQL_INTERVAL_STRUCT
;
382 /****************************
384 ***************************/
386 # if (ODBCVER >= 0x0300)
387 # if (SIZEOF_LONG_INT == 8)
388 # define ODBCINT64 long
389 # define UODBCINT64 unsigned long
391 # ifdef HAVE_LONG_LONG
392 # define ODBCINT64 long long
393 # define UODBCINT64 unsigned long long
396 * may fail in some cases, but what else can we do ?
398 struct __bigint_struct
403 struct __bigint_struct_u
408 # define ODBCINT64 struct __bigint_struct
409 # define UODBCINT64 struct __bigint_struct_u
416 typedef ODBCINT64 SQLBIGINT
;
419 typedef UODBCINT64 SQLUBIGINT
;
423 /****************************
424 * cursor and bookmark
425 ***************************/
426 #if (ODBCVER >= 0x0300)
427 #define SQL_MAX_NUMERIC_LEN 16
428 typedef struct tagSQL_NUMERIC_STRUCT
432 SQLCHAR sign
; /* 1=pos 0=neg */
433 SQLCHAR val
[SQL_MAX_NUMERIC_LEN
];
434 } SQL_NUMERIC_STRUCT
;
437 #if (ODBCVER >= 0x0350)
439 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
440 typedef GUID SQLGUID
;
442 typedef struct tagSQLGUID
451 typedef struct tagSQLGUID
461 typedef SQLULEN BOOKMARK
;
463 typedef WCHAR SQLWCHAR
;
466 typedef SQLWCHAR SQLTCHAR
;
468 typedef SQLCHAR SQLTCHAR
;