include/sqltypes.h

Go to the documentation of this file.
00001 
00002 
00003 /*************************************************************
00004  * sqltypes.h
00005  *
00006  * This is the lowest level include in unixODBC. It defines
00007  * the basic types required by unixODBC and is heavily based
00008  * upon the MS include of the same name (it has to be for
00009  * binary compatability between drivers developed under different
00010  * packages).
00011  *
00012  * You can include this file directly but it is almost always
00013  * included indirectly, by including.. for example sqlext.h
00014  *
00015  * This include makes no effort to be usefull on any platforms other
00016  * than Linux (with some exceptions for UNIX in general).
00017  *
00018  * !!!DO NOT CONTAMINATE THIS FILE WITH NON-Linux CODE!!!
00019  *
00020  *************************************************************/
00021 #ifndef __SQLTYPES_H
00022 #define __SQLTYPES_H
00023 
00024 /****************************
00025  * default to the 3.51 definitions. should define ODBCVER before here if you want an older set of defines
00026  ***************************/
00027 #ifndef ODBCVER
00028 #define ODBCVER 0x0351
00029 #endif
00030 
00031 /*
00032  * if thi sis set, then use a 4 byte unicode definition, insteead of the 2 bye that MS use
00033  */
00034 
00035 #ifdef SQL_WCHART_CONVERT  
00036 /* 
00037  * Use this if you want to use the C/C++ portable definition of  a wide char, wchar_t
00038  *  Microsoft hardcoded a definition of  unsigned short which may not be compatible with
00039  *  your platform specific wide char definition.
00040  */
00041 #include <wchar.h>
00042 #endif
00043 
00044 #ifdef __cplusplus
00045 extern "C" {
00046 #endif
00047 
00048 /*
00049  * this is defined by configure, but will not be on a normal application build
00050  * the install creates a unixodbc_conf.h file that contains the current build settings
00051  */
00052 /*PRABA-START
00053 #ifndef SIZEOF_LONG_INT
00054 #include <unixodbc_conf.h>
00055 #endif
00056 
00057 #ifndef SIZEOF_LONG_INT
00058 #error "Needs to know how big a long int is to continue!!!"
00059 #endif
00060 PRABA-END */
00061 
00062 /****************************
00063  * These make up for having no windows.h
00064  ***************************/
00065 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
00066 
00067 #define FAR
00068 #define CALLBACK
00069 #ifdef __OS2__
00070 #define SQL_API _System
00071 #else
00072 #define SQL_API
00073 #endif
00074 #define BOOL                            int
00075 typedef void*                           HWND;
00076 typedef char                            CHAR;
00077 #ifdef UNICODE
00078 
00079 /* 
00080  * NOTE: The Microsoft unicode define is only for apps that want to use TCHARs and 
00081  *  be able to compile for both unicode and non-unicode with the same source.
00082  *  This is not recommanded for linux applications and is not supported
00083  *      by the standard linux string header files.
00084  */
00085 #ifdef SQL_WCHART_CONVERT
00086 typedef wchar_t             TCHAR;
00087 #else
00088 typedef signed short        TCHAR;
00089 #endif
00090 
00091 #else
00092 typedef char                            TCHAR;
00093 #endif
00094 
00095 #ifndef DONT_TD_VOID
00096 typedef void                            VOID;
00097 #endif
00098 
00099 typedef unsigned short          WORD;
00100 #if (SIZEOF_LONG_INT == 4)
00101 typedef unsigned long           DWORD;
00102 #else
00103 typedef unsigned int            DWORD;
00104 #endif
00105 typedef unsigned char           BYTE;
00106 
00107 #ifdef SQL_WCHART_CONVERT
00108 typedef wchar_t             WCHAR;
00109 #else
00110 typedef unsigned short          WCHAR;
00111 #endif
00112 
00113 typedef WCHAR*              LPWSTR;
00114 typedef const char*         LPCSTR;
00115 typedef const WCHAR*        LPCWSTR;
00116 typedef TCHAR*              LPTSTR;
00117 typedef char*               LPSTR;
00118 typedef DWORD*                  LPDWORD;
00119 
00120 typedef void*               HINSTANCE;
00121 
00122 #endif
00123 
00124 
00125 /****************************
00126  * standard SQL* data types. use these as much as possible when using ODBC calls/vars
00127  ***************************/
00128 typedef unsigned char   SQLCHAR;
00129 
00130 #if (ODBCVER >= 0x0300)
00131 typedef unsigned char   SQLDATE;
00132 typedef unsigned char   SQLDECIMAL;
00133 typedef double          SQLDOUBLE;
00134 typedef double          SQLFLOAT;
00135 #endif
00136 
00137 /*
00138  * can't use a long it fails on 64 platforms
00139  */
00140 
00141 /*
00142  * I (Nick) have made these changes, to cope with the new 3.52 MS
00143  * changes for 64 bit ODBC, but looking at MS's spec they havn't
00144  * finished it themself. For example, SQLBindCol now expects the
00145  * indicator variable to be a SQLLEN which then is a pointer to 
00146  * a 64 bit value. However the online book that comes with the 
00147  * headers, then goes on to describe the indicator_ptr in the 
00148  * descriptor record (which is set by SQLBindCol) as a pointer
00149  * to a SQLINTEGER (32 bit). So I don't think its ready for the
00150  * big time yet. Thats not to mention all the ODBC apps on 64 bit
00151  * platforms that this would break...
00152  *
00153  *
00154  * Hopefully by now it should be safe to assume most drivers know about SQLLEN now
00155  * 
00156  */
00157 
00158 #if (SIZEOF_LONG_INT == 8)
00159 #ifdef BUILD_LEGACY_64_BIT_MODE
00160 typedef int             SQLINTEGER;
00161 typedef unsigned int    SQLUINTEGER;
00162 #define SQLLEN          SQLINTEGER
00163 #define SQLULEN         SQLUINTEGER
00164 #define SQLSETPOSIROW   SQLUSMALLINT
00165 typedef SQLULEN         SQLROWCOUNT;
00166 typedef SQLULEN         SQLROWSETSIZE;
00167 typedef SQLULEN         SQLTRANSID;
00168 typedef SQLLEN          SQLROWOFFSET;
00169 #else
00170 typedef int             SQLINTEGER;
00171 typedef unsigned int    SQLUINTEGER;
00172 typedef long            SQLLEN;
00173 typedef unsigned long   SQLULEN;
00174 typedef unsigned long   SQLSETPOSIROW;
00175 /* 
00176  * These are not supprted on 64bit ODBC according to MS 
00177  * typedef SQLULEN SQLTRANSID;
00178  */
00179 typedef SQLULEN SQLROWCOUNT;
00180 typedef SQLUINTEGER SQLROWSETSIZE;
00181 typedef SQLLEN SQLROWOFFSET;
00182 #endif
00183 #else
00184 typedef long            SQLINTEGER;
00185 typedef unsigned long   SQLUINTEGER;
00186 #define SQLLEN          SQLINTEGER
00187 #define SQLULEN         SQLUINTEGER
00188 #define SQLSETPOSIROW   SQLUSMALLINT
00189 typedef SQLULEN         SQLROWCOUNT;
00190 typedef SQLULEN         SQLROWSETSIZE;
00191 typedef SQLULEN         SQLTRANSID;
00192 typedef SQLLEN          SQLROWOFFSET;
00193 #endif
00194 
00195 #if (ODBCVER >= 0x0300)
00196 typedef unsigned char   SQLNUMERIC;
00197 #endif
00198 
00199 typedef void *          SQLPOINTER;
00200 
00201 #if (ODBCVER >= 0x0300)
00202 typedef float           SQLREAL;
00203 #endif
00204 
00205 typedef signed short int   SQLSMALLINT;
00206 typedef unsigned short  SQLUSMALLINT;
00207 
00208 #if (ODBCVER >= 0x0300)
00209 typedef unsigned char   SQLTIME;
00210 typedef unsigned char   SQLTIMESTAMP;
00211 typedef unsigned char   SQLVARCHAR;
00212 #endif
00213 
00214 typedef SQLSMALLINT     SQLRETURN;
00215 
00216 #if (ODBCVER >= 0x0300)
00217 typedef void *                          SQLHANDLE; 
00218 typedef SQLHANDLE               SQLHENV;
00219 typedef SQLHANDLE               SQLHDBC;
00220 typedef SQLHANDLE               SQLHSTMT;
00221 typedef SQLHANDLE               SQLHDESC;
00222 #else
00223 typedef void *                  SQLHENV;
00224 typedef void *                  SQLHDBC;
00225 typedef void *                  SQLHSTMT;
00226 /*
00227  * some things like PHP won't build without this
00228  */
00229 typedef void *                          SQLHANDLE; 
00230 #endif
00231 
00232 /****************************
00233  * These are cast into the actual struct that is being passed around. The
00234  * DriverManager knows what its structs look like and the Driver knows about its
00235  * structs... the app knows nothing about them... just void*
00236  * These are deprecated in favour of SQLHENV, SQLHDBC, SQLHSTMT
00237  ***************************/
00238 
00239 #if (ODBCVER >= 0x0300)
00240 typedef SQLHANDLE                       HENV;
00241 typedef SQLHANDLE                       HDBC;
00242 typedef SQLHANDLE                       HSTMT;
00243 #else
00244 typedef void *                      HENV;
00245 typedef void *                      HDBC;
00246 typedef void *                      HSTMT;
00247 #endif
00248 
00249 
00250 /****************************
00251  * more basic data types to augment what windows.h provides
00252  ***************************/
00253 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
00254 
00255 typedef unsigned char           UCHAR;
00256 typedef signed char             SCHAR;
00257 typedef SCHAR                   SQLSCHAR;
00258 #if (SIZEOF_LONG_INT == 4)
00259 typedef long int                SDWORD;
00260 typedef unsigned long int       UDWORD;
00261 #else
00262 typedef int                     SDWORD;
00263 typedef unsigned int            UDWORD;
00264 #endif
00265 typedef signed short int        SWORD;
00266 typedef unsigned short int      UWORD;
00267 typedef unsigned int            UINT;
00268 typedef signed long             SLONG;
00269 typedef signed short            SSHORT;
00270 typedef unsigned long           ULONG;
00271 typedef unsigned short          USHORT;
00272 typedef double                  SDOUBLE;
00273 typedef double                          LDOUBLE;
00274 typedef float                   SFLOAT;
00275 typedef void*                           PTR;
00276 typedef signed short            RETCODE;
00277 typedef void*                   SQLHWND;
00278 
00279 #endif
00280 
00281 /****************************
00282  * standard structs for working with date/times
00283  ***************************/
00284 #ifndef __SQLDATE
00285 #define __SQLDATE
00286 typedef struct tagDATE_STRUCT
00287 {
00288         SQLSMALLINT    year;
00289         SQLUSMALLINT   month;
00290         SQLUSMALLINT   day;
00291 } DATE_STRUCT;
00292 
00293 #if (ODBCVER >= 0x0300)
00294 typedef DATE_STRUCT     SQL_DATE_STRUCT;
00295 #endif
00296 
00297 typedef struct tagTIME_STRUCT
00298 {
00299         SQLUSMALLINT   hour;
00300         SQLUSMALLINT   minute;
00301         SQLUSMALLINT   second;
00302 } TIME_STRUCT;
00303 
00304 #if (ODBCVER >= 0x0300)
00305 typedef TIME_STRUCT     SQL_TIME_STRUCT;
00306 #endif
00307 
00308 typedef struct tagTIMESTAMP_STRUCT
00309 {
00310         SQLSMALLINT    year;
00311         SQLUSMALLINT   month;
00312         SQLUSMALLINT   day;
00313         SQLUSMALLINT   hour;
00314         SQLUSMALLINT   minute;
00315         SQLUSMALLINT   second;
00316         SQLUINTEGER    fraction;
00317 } TIMESTAMP_STRUCT;
00318 
00319 #if (ODBCVER >= 0x0300)
00320 typedef TIMESTAMP_STRUCT        SQL_TIMESTAMP_STRUCT;
00321 #endif
00322 
00323 
00324 #if (ODBCVER >= 0x0300)
00325 typedef enum
00326 {
00327         SQL_IS_YEAR                                             = 1,
00328         SQL_IS_MONTH                                    = 2,
00329         SQL_IS_DAY                                              = 3,
00330         SQL_IS_HOUR                                             = 4,
00331         SQL_IS_MINUTE                                   = 5,
00332         SQL_IS_SECOND                                   = 6,
00333         SQL_IS_YEAR_TO_MONTH                    = 7,
00334         SQL_IS_DAY_TO_HOUR                              = 8,
00335         SQL_IS_DAY_TO_MINUTE                    = 9,
00336         SQL_IS_DAY_TO_SECOND                    = 10,
00337         SQL_IS_HOUR_TO_MINUTE                   = 11,
00338         SQL_IS_HOUR_TO_SECOND                   = 12,
00339         SQL_IS_MINUTE_TO_SECOND                 = 13
00340 } SQLINTERVAL;
00341 
00342 #endif
00343 
00344 #if (ODBCVER >= 0x0300)
00345 typedef struct tagSQL_YEAR_MONTH
00346 {
00347                 SQLUINTEGER             year;
00348                 SQLUINTEGER             month;
00349 } SQL_YEAR_MONTH_STRUCT;
00350 
00351 typedef struct tagSQL_DAY_SECOND
00352 {
00353                 SQLUINTEGER             day;
00354                 SQLUINTEGER             hour;
00355                 SQLUINTEGER             minute;
00356                 SQLUINTEGER             second;
00357                 SQLUINTEGER             fraction;
00358 } SQL_DAY_SECOND_STRUCT;
00359 
00360 typedef struct tagSQL_INTERVAL_STRUCT
00361 {
00362         SQLINTERVAL             interval_type;
00363         SQLSMALLINT             interval_sign;
00364         union {
00365                 SQL_YEAR_MONTH_STRUCT           year_month;
00366                 SQL_DAY_SECOND_STRUCT           day_second;
00367         } intval;
00368 
00369 } SQL_INTERVAL_STRUCT;
00370 
00371 #endif
00372 
00373 #endif
00374 
00375 /****************************
00376  *
00377  ***************************/
00378 #if (ODBCVER >= 0x0300)
00379 #if (SIZEOF_LONG_INT == 8)
00380 #  define ODBCINT64         long
00381 #  define UODBCINT64    unsigned long
00382 #else
00383 # ifdef HAVE_LONG_LONG
00384 #  define ODBCINT64         long long
00385 #  define UODBCINT64    unsigned long long
00386 # else
00387 /*
00388  * may fail in some cases, but what else can we do ?
00389  */
00390 struct __bigint_struct
00391 {
00392     int             hiword;
00393     unsigned int    loword;
00394 };
00395 struct __bigint_struct_u
00396 {
00397     unsigned int    hiword;
00398     unsigned int    loword;
00399 };
00400 #  define ODBCINT64         struct __bigint_struct
00401 #  define UODBCINT64    struct __bigint_struct_u
00402 # endif
00403 #endif
00404 #ifdef ODBCINT64
00405 typedef ODBCINT64       SQLBIGINT;
00406 #endif
00407 #ifdef UODBCINT64
00408 typedef UODBCINT64      SQLUBIGINT;
00409 #endif
00410 #endif
00411 
00412 
00413 /****************************
00414  * cursor and bookmark
00415  ***************************/
00416 #if (ODBCVER >= 0x0300)
00417 #define SQL_MAX_NUMERIC_LEN             16
00418 typedef struct tagSQL_NUMERIC_STRUCT
00419 {
00420         SQLCHAR         precision;
00421         SQLSCHAR        scale;
00422         SQLCHAR         sign;   /* 1=pos 0=neg */
00423         SQLCHAR         val[SQL_MAX_NUMERIC_LEN];
00424 } SQL_NUMERIC_STRUCT;
00425 #endif
00426 
00427 #if (ODBCVER >= 0x0350)
00428 #ifdef GUID_DEFINED
00429 #ifndef ALLREADY_HAVE_WINDOWS_TYPE
00430 typedef GUID    SQLGUID;
00431 #else
00432 typedef struct  tagSQLGUID
00433 {
00434     DWORD Data1;
00435     WORD Data2;
00436     WORD Data3;
00437     BYTE Data4[ 8 ];
00438 } SQLGUID;
00439 #endif
00440 #else
00441 typedef struct  tagSQLGUID
00442 {
00443     DWORD Data1;
00444     WORD Data2;
00445     WORD Data3;
00446     BYTE Data4[ 8 ];
00447 } SQLGUID;
00448 #endif
00449 #endif
00450 
00451 typedef SQLULEN         BOOKMARK;
00452 
00453 typedef  WCHAR         SQLWCHAR;
00454 
00455 #ifdef UNICODE
00456 typedef SQLWCHAR        SQLTCHAR;
00457 #else
00458 typedef SQLCHAR         SQLTCHAR;
00459 #endif
00460 
00461 #ifdef __cplusplus
00462 }
00463 #endif
00464 
00465 #endif
00466 
00467 
00468 
00469 

Generated on Mon Jun 9 22:37:14 2008 for csql by  doxygen 1.4.7