Update ooo320-m1
[ooovba.git] / unixODBC / inc / sqltypes.h
blob130de90086ee52c61ee402e16a47c4f4ca2d7946
1 /*************************************************************
2 * sqltypes.h
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
8 * packages).
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 *************************************************************/
19 #ifndef __SQLTYPES_H
20 #define __SQLTYPES_H
22 /****************************
23 * default to the 3.51 definitions. should define ODBCVER before here if you want an older set of defines
24 ***************************/
25 #ifndef ODBCVER
26 #define ODBCVER 0x0351
27 #endif
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
34 /*
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.
39 #include <wchar.h>
40 #endif
42 #include <sal/types.h>
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
48 #ifndef SIZEOF_LONG_INT
49 # define SIZEOF_LONG_INT SAL_TYPES_SIZEOFLONG
50 #endif
51 #ifndef ODBCINT64
52 # define ODBCINT64 sal_Int64
53 #endif
54 #ifndef UODBCINT64
55 # define UODBCINT64 sal_uInt64
56 #endif
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>
65 #endif
67 #ifndef SIZEOF_LONG_INT
68 #error "Needs to know how big a long int is to continue!!!"
69 #endif
71 /****************************
72 * These make up for having no windows.h
73 ***************************/
74 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
76 #define FAR
77 #define CALLBACK
78 #ifdef __OS2__
79 #define SQL_API _System
80 #else
81 #define SQL_API
82 #endif
83 #define BOOL int
84 typedef void* HWND;
85 typedef char CHAR;
86 #ifdef UNICODE
88 /*
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;
96 #else
97 typedef signed short TCHAR;
98 #endif
100 #else
101 typedef char TCHAR;
102 #endif
104 #ifndef DONT_TD_VOID
105 typedef void VOID;
106 #endif
108 typedef unsigned short WORD;
109 #if (SIZEOF_LONG_INT == 4)
110 typedef unsigned long DWORD;
111 #else
112 typedef unsigned int DWORD;
113 #endif
114 typedef unsigned char BYTE;
116 #ifdef SQL_WCHART_CONVERT
117 typedef wchar_t WCHAR;
118 #else
119 typedef unsigned short WCHAR;
120 #endif
122 typedef WCHAR* LPWSTR;
123 typedef const char* LPCSTR;
124 typedef const WCHAR* LPCWSTR;
125 typedef TCHAR* LPTSTR;
126 typedef char* LPSTR;
127 typedef DWORD* LPDWORD;
129 typedef void* HINSTANCE;
131 #endif
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;
144 #endif
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;
171 #else
172 typedef int SQLINTEGER;
173 typedef unsigned int SQLUINTEGER;
174 typedef long SQLLEN;
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;
189 #endif
190 #else
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;
200 #endif
202 #if (ODBCVER >= 0x0300)
203 typedef unsigned char SQLNUMERIC;
204 #endif
206 typedef void * SQLPOINTER;
208 #if (ODBCVER >= 0x0300)
209 typedef float SQLREAL;
210 #endif
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;
219 #endif
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;
229 #else
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;
237 #endif
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;
250 #else
251 typedef void * HENV;
252 typedef void * HDBC;
253 typedef void * HSTMT;
254 #endif
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;
268 #else
269 typedef int SDWORD;
270 typedef unsigned int UDWORD;
271 #endif
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;
282 typedef void* PTR;
283 typedef signed short RETCODE;
284 typedef void* SQLHWND;
286 #endif
288 /****************************
289 * standard structs for working with date/times
290 ***************************/
291 #ifndef __SQLDATE
292 #define __SQLDATE
293 typedef struct tagDATE_STRUCT
295 SQLSMALLINT year;
296 SQLUSMALLINT month;
297 SQLUSMALLINT day;
298 } DATE_STRUCT;
300 #if (ODBCVER >= 0x0300)
301 typedef DATE_STRUCT SQL_DATE_STRUCT;
302 #endif
304 typedef struct tagTIME_STRUCT
306 SQLUSMALLINT hour;
307 SQLUSMALLINT minute;
308 SQLUSMALLINT second;
309 } TIME_STRUCT;
311 #if (ODBCVER >= 0x0300)
312 typedef TIME_STRUCT SQL_TIME_STRUCT;
313 #endif
315 typedef struct tagTIMESTAMP_STRUCT
317 SQLSMALLINT year;
318 SQLUSMALLINT month;
319 SQLUSMALLINT day;
320 SQLUSMALLINT hour;
321 SQLUSMALLINT minute;
322 SQLUSMALLINT second;
323 SQLUINTEGER fraction;
324 } TIMESTAMP_STRUCT;
326 #if (ODBCVER >= 0x0300)
327 typedef TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT;
328 #endif
331 #if (ODBCVER >= 0x0300)
332 typedef enum
334 SQL_IS_YEAR = 1,
335 SQL_IS_MONTH = 2,
336 SQL_IS_DAY = 3,
337 SQL_IS_HOUR = 4,
338 SQL_IS_MINUTE = 5,
339 SQL_IS_SECOND = 6,
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
347 } SQLINTERVAL;
349 #endif
351 #if (ODBCVER >= 0x0300)
352 typedef struct tagSQL_YEAR_MONTH
354 SQLUINTEGER year;
355 SQLUINTEGER month;
356 } SQL_YEAR_MONTH_STRUCT;
358 typedef struct tagSQL_DAY_SECOND
360 SQLUINTEGER day;
361 SQLUINTEGER hour;
362 SQLUINTEGER minute;
363 SQLUINTEGER second;
364 SQLUINTEGER fraction;
365 } SQL_DAY_SECOND_STRUCT;
367 typedef struct tagSQL_INTERVAL_STRUCT
369 SQLINTERVAL interval_type;
370 SQLSMALLINT interval_sign;
371 union {
372 SQL_YEAR_MONTH_STRUCT year_month;
373 SQL_DAY_SECOND_STRUCT day_second;
374 } intval;
376 } SQL_INTERVAL_STRUCT;
378 #endif
380 #endif
382 /****************************
384 ***************************/
385 #ifndef ODBCINT64
386 # if (ODBCVER >= 0x0300)
387 # if (SIZEOF_LONG_INT == 8)
388 # define ODBCINT64 long
389 # define UODBCINT64 unsigned long
390 # else
391 # ifdef HAVE_LONG_LONG
392 # define ODBCINT64 long long
393 # define UODBCINT64 unsigned long long
394 # else
396 * may fail in some cases, but what else can we do ?
398 struct __bigint_struct
400 int hiword;
401 unsigned int loword;
403 struct __bigint_struct_u
405 unsigned int hiword;
406 unsigned int loword;
408 # define ODBCINT64 struct __bigint_struct
409 # define UODBCINT64 struct __bigint_struct_u
410 # endif
411 # endif
412 #endif
413 #endif
415 #ifdef ODBCINT64
416 typedef ODBCINT64 SQLBIGINT;
417 #endif
418 #ifdef UODBCINT64
419 typedef UODBCINT64 SQLUBIGINT;
420 #endif
423 /****************************
424 * cursor and bookmark
425 ***************************/
426 #if (ODBCVER >= 0x0300)
427 #define SQL_MAX_NUMERIC_LEN 16
428 typedef struct tagSQL_NUMERIC_STRUCT
430 SQLCHAR precision;
431 SQLSCHAR scale;
432 SQLCHAR sign; /* 1=pos 0=neg */
433 SQLCHAR val[SQL_MAX_NUMERIC_LEN];
434 } SQL_NUMERIC_STRUCT;
435 #endif
437 #if (ODBCVER >= 0x0350)
438 #ifdef GUID_DEFINED
439 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
440 typedef GUID SQLGUID;
441 #else
442 typedef struct tagSQLGUID
444 DWORD Data1;
445 WORD Data2;
446 WORD Data3;
447 BYTE Data4[ 8 ];
448 } SQLGUID;
449 #endif
450 #else
451 typedef struct tagSQLGUID
453 DWORD Data1;
454 WORD Data2;
455 WORD Data3;
456 BYTE Data4[ 8 ];
457 } SQLGUID;
458 #endif
459 #endif
461 typedef SQLULEN BOOKMARK;
463 typedef WCHAR SQLWCHAR;
465 #ifdef UNICODE
466 typedef SQLWCHAR SQLTCHAR;
467 #else
468 typedef SQLCHAR SQLTCHAR;
469 #endif
471 #ifdef __cplusplus
473 #endif
475 #endif