reverting back the changes. causes core dump
[csql.git] / include / sqltypes.h
blob1e681790a520f3e22aede8c40ee21c0143b38fcb
3 /*************************************************************
4 * sqltypes.h
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
10 * packages).
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 *************************************************************/
21 #ifndef __SQLTYPES_H
22 #define __SQLTYPES_H
24 /****************************
25 * default to the 3.51 definitions. should define ODBCVER before here if you want an older set of defines
26 ***************************/
27 #ifndef ODBCVER
28 #define ODBCVER 0x0351
29 #endif
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
36 /*
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.
41 #include <wchar.h>
42 #endif
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
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
52 /*PRABA-START
53 #ifndef SIZEOF_LONG_INT
54 #include <unixodbc_conf.h>
55 #endif
57 #ifndef SIZEOF_LONG_INT
58 #error "Needs to know how big a long int is to continue!!!"
59 #endif
60 PRABA-END */
62 /****************************
63 * These make up for having no windows.h
64 ***************************/
65 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
67 #define FAR
68 #define CALLBACK
69 #ifdef __OS2__
70 #define SQL_API _System
71 #else
72 #define SQL_API
73 #endif
74 #define BOOL int
75 typedef void* HWND;
76 typedef char CHAR;
77 #ifdef UNICODE
79 /*
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;
87 #else
88 typedef signed short TCHAR;
89 #endif
91 #else
92 typedef char TCHAR;
93 #endif
95 #ifndef DONT_TD_VOID
96 typedef void VOID;
97 #endif
99 typedef unsigned short WORD;
100 #if (SIZEOF_LONG_INT == 4)
101 typedef unsigned long DWORD;
102 #else
103 typedef unsigned int DWORD;
104 #endif
105 typedef unsigned char BYTE;
107 #ifdef SQL_WCHART_CONVERT
108 typedef wchar_t WCHAR;
109 #else
110 typedef unsigned short WCHAR;
111 #endif
113 typedef WCHAR* LPWSTR;
114 typedef const char* LPCSTR;
115 typedef const WCHAR* LPCWSTR;
116 typedef TCHAR* LPTSTR;
117 typedef char* LPSTR;
118 typedef DWORD* LPDWORD;
120 typedef void* HINSTANCE;
122 #endif
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;
135 #endif
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;
169 #else
170 typedef int SQLINTEGER;
171 typedef unsigned int SQLUINTEGER;
172 typedef long SQLLEN;
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;
182 #endif
183 #else
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;
193 #endif
195 #if (ODBCVER >= 0x0300)
196 typedef unsigned char SQLNUMERIC;
197 #endif
199 typedef void * SQLPOINTER;
201 #if (ODBCVER >= 0x0300)
202 typedef float SQLREAL;
203 #endif
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;
212 #endif
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;
222 #else
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;
230 #endif
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;
243 #else
244 typedef void * HENV;
245 typedef void * HDBC;
246 typedef void * HSTMT;
247 #endif
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;
261 #else
262 typedef int SDWORD;
263 typedef unsigned int UDWORD;
264 #endif
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;
275 typedef void* PTR;
276 #endif
277 typedef signed char SQLSCHAR;
278 typedef void* SQLHWND;
279 typedef signed short RETCODE;
281 /****************************
282 * standard structs for working with date/times
283 ***************************/
284 #ifndef __SQLDATE
285 #define __SQLDATE
286 typedef struct tagDATE_STRUCT
288 SQLSMALLINT year;
289 SQLUSMALLINT month;
290 SQLUSMALLINT day;
291 } DATE_STRUCT;
293 #if (ODBCVER >= 0x0300)
294 typedef DATE_STRUCT SQL_DATE_STRUCT;
295 #endif
297 typedef struct tagTIME_STRUCT
299 SQLUSMALLINT hour;
300 SQLUSMALLINT minute;
301 SQLUSMALLINT second;
302 } TIME_STRUCT;
304 #if (ODBCVER >= 0x0300)
305 typedef TIME_STRUCT SQL_TIME_STRUCT;
306 #endif
308 typedef struct tagTIMESTAMP_STRUCT
310 SQLSMALLINT year;
311 SQLUSMALLINT month;
312 SQLUSMALLINT day;
313 SQLUSMALLINT hour;
314 SQLUSMALLINT minute;
315 SQLUSMALLINT second;
316 SQLUINTEGER fraction;
317 } TIMESTAMP_STRUCT;
319 #if (ODBCVER >= 0x0300)
320 typedef TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT;
321 #endif
324 #if (ODBCVER >= 0x0300)
325 typedef enum
327 SQL_IS_YEAR = 1,
328 SQL_IS_MONTH = 2,
329 SQL_IS_DAY = 3,
330 SQL_IS_HOUR = 4,
331 SQL_IS_MINUTE = 5,
332 SQL_IS_SECOND = 6,
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
340 } SQLINTERVAL;
342 #endif
344 #if (ODBCVER >= 0x0300)
345 typedef struct tagSQL_YEAR_MONTH
347 SQLUINTEGER year;
348 SQLUINTEGER month;
349 } SQL_YEAR_MONTH_STRUCT;
351 typedef struct tagSQL_DAY_SECOND
353 SQLUINTEGER day;
354 SQLUINTEGER hour;
355 SQLUINTEGER minute;
356 SQLUINTEGER second;
357 SQLUINTEGER fraction;
358 } SQL_DAY_SECOND_STRUCT;
360 typedef struct tagSQL_INTERVAL_STRUCT
362 SQLINTERVAL interval_type;
363 SQLSMALLINT interval_sign;
364 union {
365 SQL_YEAR_MONTH_STRUCT year_month;
366 SQL_DAY_SECOND_STRUCT day_second;
367 } intval;
369 } SQL_INTERVAL_STRUCT;
371 #endif
373 #endif
375 /****************************
377 ***************************/
378 #if (ODBCVER >= 0x0300)
379 #if (SIZEOF_LONG_INT == 8)
380 # define ODBCINT64 long
381 # define UODBCINT64 unsigned long
382 #else
383 # ifdef HAVE_LONG_LONG
384 # define ODBCINT64 long long
385 # define UODBCINT64 unsigned long long
386 # else
388 * may fail in some cases, but what else can we do ?
390 struct __bigint_struct
392 int hiword;
393 unsigned int loword;
395 struct __bigint_struct_u
397 unsigned int hiword;
398 unsigned int loword;
400 # define ODBCINT64 struct __bigint_struct
401 # define UODBCINT64 struct __bigint_struct_u
402 # endif
403 #endif
404 #ifdef ODBCINT64
405 typedef ODBCINT64 SQLBIGINT;
406 #endif
407 #ifdef UODBCINT64
408 typedef UODBCINT64 SQLUBIGINT;
409 #endif
410 #endif
413 /****************************
414 * cursor and bookmark
415 ***************************/
416 #if (ODBCVER >= 0x0300)
417 #define SQL_MAX_NUMERIC_LEN 16
418 typedef struct tagSQL_NUMERIC_STRUCT
420 SQLCHAR precision;
421 SQLSCHAR scale;
422 SQLCHAR sign; /* 1=pos 0=neg */
423 SQLCHAR val[SQL_MAX_NUMERIC_LEN];
424 } SQL_NUMERIC_STRUCT;
425 #endif
427 #if (ODBCVER >= 0x0350)
428 #ifdef GUID_DEFINED
429 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
430 typedef GUID SQLGUID;
431 #else
432 typedef struct tagSQLGUID
434 DWORD Data1;
435 WORD Data2;
436 WORD Data3;
437 BYTE Data4[ 8 ];
438 } SQLGUID;
439 #endif
440 #else
441 typedef struct tagSQLGUID
443 DWORD Data1;
444 WORD Data2;
445 WORD Data3;
446 BYTE Data4[ 8 ];
447 } SQLGUID;
448 #endif
449 #endif
451 typedef SQLULEN BOOKMARK;
453 typedef WCHAR SQLWCHAR;
455 #ifdef UNICODE
456 typedef SQLWCHAR SQLTCHAR;
457 #else
458 typedef SQLCHAR SQLTCHAR;
459 #endif
461 #ifdef __cplusplus
463 #endif
465 #endif