1 /* 2 * sqltypes.h 3 * 4 * $Id$ 5 * 6 * ODBC typedefs 7 * 8 * The iODBC driver manager. 9 * 10 * Copyright (C) 1995 Ke Jin <kejin@empress.com> 11 * Copyright (C) 1996-2021 OpenLink Software <iodbc@openlinksw.com> 12 * All Rights Reserved. 13 * 14 * This software is released under the terms of either of the following 15 * licenses: 16 * 17 * - GNU Library General Public License (see LICENSE.LGPL) 18 * - The BSD License (see LICENSE.BSD). 19 * 20 * Note that the only valid version of the LGPL license as far as this 21 * project is concerned is the original GNU Library General Public License 22 * Version 2, dated June 1991. 23 * 24 * While not mandated by the BSD license, any patches you make to the 25 * iODBC source code may be contributed back into the iODBC project 26 * at your discretion. Contributions will benefit the Open Source and 27 * Data Access community as a whole. Submissions may be made at: 28 * 29 * http://www.iodbc.org 30 * 31 * 32 * GNU Library Generic Public License Version 2 33 * ============================================ 34 * This library is free software; you can redistribute it and/or 35 * modify it under the terms of the GNU Library General Public 36 * License as published by the Free Software Foundation; only 37 * Version 2 of the License dated June 1991. 38 * 39 * This library is distributed in the hope that it will be useful, 40 * but WITHOUT ANY WARRANTY; without even the implied warranty of 41 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 42 * Library General Public License for more details. 43 * 44 * You should have received a copy of the GNU Library General Public 45 * License along with this library; if not, write to the Free 46 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 47 * 48 * 49 * The BSD License 50 * =============== 51 * Redistribution and use in source and binary forms, with or without 52 * modification, are permitted provided that the following conditions 53 * are met: 54 * 55 * 1. Redistributions of source code must retain the above copyright contentsOptionData::InitialCmdEntry56 * notice, this list of conditions and the following disclaimer. 57 * 2. Redistributions in binary form must reproduce the above copyright 58 * notice, this list of conditions and the following disclaimer in 59 * the documentation and/or other materials provided with the 60 * distribution. 61 * 3. Neither the name of OpenLink Software Inc. nor the names of its 62 * contributors may be used to endorse or promote products derived 63 * from this software without specific prior written permission. 64 * 65 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 66 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 67 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 68 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL OPENLINK OR 69 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 70 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 71 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 72 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 73 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 74 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 75 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 76 */ 77 78 #ifndef _SQLTYPES_H 79 #define _SQLTYPES_H 80 81 /* 82 * Set default specification to ODBC 3.51 83 */ 84 #ifndef ODBCVER 85 #define ODBCVER 0x0351 86 #endif 87 88 /* 89 * Include Windows style defines and typedefs on Unix 90 */ 91 #ifndef _IODBCUNIX_H 92 #include <iodbcunix.h> 93 #endif 94 95 #ifdef __cplusplus 96 extern "C" { 97 #endif 98 99 100 /* 101 * Environment specific definitions 102 */ 103 #ifndef EXPORT 104 #define EXPORT 105 #endif 106 107 #ifdef WIN32 108 #define SQL_API __stdcall 109 #else 110 #define SQL_API 111 #endif 112 113 114 /* 115 * API declaration data types 116 */ 117 typedef unsigned char SQLCHAR; 118 typedef signed short SQLSMALLINT; 119 typedef unsigned short SQLUSMALLINT; 120 #if (SIZEOF_LONG == 8) 121 typedef signed int SQLINTEGER; 122 typedef unsigned int SQLUINTEGER; 123 #else 124 typedef signed long SQLINTEGER; 125 typedef unsigned long SQLUINTEGER; 126 #endif 127 typedef void * SQLPOINTER; 128 129 #if (ODBCVER >= 0x0300) 130 typedef signed char SQLSCHAR; 131 typedef unsigned char SQLDATE; 132 typedef unsigned char SQLDECIMAL; 133 typedef unsigned char SQLNUMERIC; 134 typedef double SQLDOUBLE; 135 typedef double SQLFLOAT; 136 typedef float SQLREAL; 137 typedef unsigned char SQLTIME; 138 typedef unsigned char SQLTIMESTAMP; 139 typedef unsigned char SQLVARCHAR; 140 #endif /* ODBCVER >= 0x0300 */ 141 142 143 /* 144 * New Win64 datatypes 145 */ 146 #ifdef _WIN64 147 typedef INT64 SQLLEN; 148 typedef UINT64 SQLULEN; 149 typedef UINT64 SQLSETPOSIROW; 150 #elif defined(STRICT_ODBC_TYPES) 151 typedef long SQLLEN; 152 typedef unsigned long SQLULEN; 153 typedef unsigned short SQLSETPOSIROW; 154 #else 155 #define SQLLEN long 156 #define SQLULEN unsigned long 157 #define SQLSETPOSIROW unsigned short 158 #endif 159 160 161 /* 162 * Backward compatibility with older platform sdks 163 */ 164 typedef SQLULEN SQLROWCOUNT; 165 typedef SQLULEN SQLROWSETSIZE; 166 typedef SQLULEN SQLTRANSID; 167 typedef SQLLEN SQLROWOFFSET; 168 169 170 /* 171 * Generic pointer types 172 */ 173 typedef void * PTR; 174 typedef void * SQLHANDLE; 175 176 177 /* 178 * Handles 179 */ 180 typedef void * HENV; 181 typedef void * HDBC; 182 typedef void * HSTMT; 183 184 typedef SQLHANDLE SQLHENV; 185 typedef SQLHANDLE SQLHDBC; 186 typedef SQLHANDLE SQLHSTMT; 187 #if (ODBCVER >= 0x0300) 188 typedef SQLHANDLE SQLHDESC; 189 #endif /* ODBCVER >= 0x0300 */ 190 191 192 /* 193 * Window Handle 194 */ 195 #if defined(WIN32) || defined (_WIN64) || defined(OS2) 196 typedef HWND SQLHWND; 197 #elif defined(macintosh) 198 #include <Dialogs.h> 199 typedef WindowPtr HWND; 200 typedef HWND SQLHWND; 201 #else 202 typedef SQLPOINTER HWND; 203 typedef SQLPOINTER SQLHWND; 204 #endif 205 206 207 /* 208 * SQL portable types for C 209 */ 210 typedef unsigned char UCHAR; 211 typedef signed char SCHAR; 212 typedef short int SWORD; 213 typedef unsigned short int UWORD; 214 typedef long int SDWORD; 215 typedef unsigned long int UDWORD; 216 217 typedef signed short SSHORT; 218 typedef unsigned short USHORT; 219 typedef signed long SLONG; 220 typedef unsigned long ULONG; 221 typedef float SFLOAT; 222 typedef double SDOUBLE; 223 typedef double LDOUBLE; 224 225 226 /* 227 * Return type for functions 228 */ 229 typedef signed short RETCODE; 230 typedef SQLSMALLINT SQLRETURN; 231 232 233 /* 234 * SQL portable types for C - DATA, TIME, TIMESTAMP, and BOOKMARK 235 */ 236 typedef SQLULEN BOOKMARK; 237 238 239 typedef struct tagDATE_STRUCT 240 { 241 SQLSMALLINT year; 242 SQLUSMALLINT month; 243 SQLUSMALLINT day; 244 } 245 DATE_STRUCT; 246 247 #if (ODBCVER >= 0x0300) 248 typedef DATE_STRUCT SQL_DATE_STRUCT; 249 #endif /* ODBCVER >= 0x0300 */ 250 251 252 typedef struct tagTIME_STRUCT 253 { 254 SQLUSMALLINT hour; 255 SQLUSMALLINT minute; 256 SQLUSMALLINT second; 257 } 258 TIME_STRUCT; 259 260 #if (ODBCVER >= 0x0300) 261 typedef TIME_STRUCT SQL_TIME_STRUCT; 262 #endif /* ODBCVER >= 0x0300 */ 263 264 265 typedef struct tagTIMESTAMP_STRUCT 266 { 267 SQLSMALLINT year; 268 SQLUSMALLINT month; 269 SQLUSMALLINT day; 270 SQLUSMALLINT hour; 271 SQLUSMALLINT minute; 272 SQLUSMALLINT second; 273 SQLUINTEGER fraction; 274 } 275 TIMESTAMP_STRUCT; 276 277 #if (ODBCVER >= 0x0300) 278 typedef TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT; 279 #endif /* ODBCVER >= 0x0300 */ 280 281 282 /* 283 * Enumeration for DATETIME_INTERVAL_SUBCODE values for interval data types 284 * 285 * These values are from SQL-92 286 */ 287 #if (ODBCVER >= 0x0300) 288 typedef enum 289 { 290 SQL_IS_YEAR = 1, 291 SQL_IS_MONTH = 2, 292 SQL_IS_DAY = 3, 293 SQL_IS_HOUR = 4, 294 SQL_IS_MINUTE = 5, 295 SQL_IS_SECOND = 6, 296 SQL_IS_YEAR_TO_MONTH = 7, 297 SQL_IS_DAY_TO_HOUR = 8, 298 SQL_IS_DAY_TO_MINUTE = 9, 299 SQL_IS_DAY_TO_SECOND = 10, 300 SQL_IS_HOUR_TO_MINUTE = 11, 301 SQL_IS_HOUR_TO_SECOND = 12, 302 SQL_IS_MINUTE_TO_SECOND = 13 303 } 304 SQLINTERVAL; 305 306 307 typedef struct tagSQL_YEAR_MONTH 308 { 309 SQLUINTEGER year; 310 SQLUINTEGER month; 311 } 312 SQL_YEAR_MONTH_STRUCT; 313 314 315 typedef struct tagSQL_DAY_SECOND 316 { 317 SQLUINTEGER day; 318 SQLUINTEGER hour; 319 SQLUINTEGER minute; 320 SQLUINTEGER second; 321 SQLUINTEGER fraction; 322 } 323 SQL_DAY_SECOND_STRUCT; 324 325 326 typedef struct tagSQL_INTERVAL_STRUCT 327 { 328 SQLINTERVAL interval_type; 329 SQLSMALLINT interval_sign; 330 union 331 { 332 SQL_YEAR_MONTH_STRUCT year_month; 333 SQL_DAY_SECOND_STRUCT day_second; 334 } 335 intval; 336 } 337 SQL_INTERVAL_STRUCT; 338 #endif /* ODBCVER >= 0x0300 */ 339 340 341 /* 342 * The ODBC C types for SQL_C_SBIGINT and SQL_C_UBIGINT 343 */ 344 #if (ODBCVER >= 0x0300) 345 346 #if defined(_MSC_VER) && (_MSC_VER >= 900) 347 # define ODBCINT64 __int64 348 #endif 349 350 #ifndef ODBCINT64 351 # if (SIZEOF_LONG == 8) 352 # define ODBCINT64 long 353 # else 354 # define ODBCINT64 long long 355 # endif 356 #endif /* ODBCINT64 */ 357 358 #if defined (ODBCINT64) 359 typedef signed ODBCINT64 SQLBIGINT; 360 typedef unsigned ODBCINT64 SQLUBIGINT; 361 #endif /* ODBCINT64 */ 362 363 #endif /* ODBCVER >= 0x0300 */ 364 365 366 /* 367 * The internal representation of the numeric data type 368 */ 369 #if (ODBCVER >= 0x0300) 370 #define SQL_MAX_NUMERIC_LEN 16 371 typedef struct tagSQL_NUMERIC_STRUCT 372 { 373 SQLCHAR precision; 374 SQLSCHAR scale; 375 SQLCHAR sign; /* 0 for negative, 1 for positive */ 376 SQLCHAR val[SQL_MAX_NUMERIC_LEN]; 377 } 378 SQL_NUMERIC_STRUCT; 379 #endif /* ODBCVER >= 0x0300 */ 380 381 382 #if (ODBCVER >= 0x0350) 383 #ifdef GUID_DEFINED 384 typedef GUID SQLGUID; 385 #else 386 typedef struct tagSQLGUID 387 { 388 unsigned int Data1; 389 unsigned short Data2; 390 unsigned short Data3; 391 unsigned char Data4[8]; /* BYTE */ 392 } 393 SQLGUID; 394 #endif /* GUID_DEFINED */ 395 #endif /* ODBCVER >= 0x0350 */ 396 397 398 #if defined(WIN32) 399 typedef unsigned short SQLWCHAR; 400 #else 401 # include <stdlib.h> 402 403 # if defined(__cplusplus) || \ 404 defined(_WCHAR_T) || \ 405 defined(_WCHAR_T_DEFINED) || \ 406 defined(_WCHAR_T_DEFINED_) || \ 407 defined(_WCHAR_T_DECLARED) || \ 408 defined(_BSD_WCHAR_T_DEFINED_) || \ 409 defined(_BSD_WCHAR_T_) || \ 410 defined(_BSD_CT_RUNE_T_) || \ 411 defined(__DEFINED_wchar_t) 412 typedef wchar_t SQLWCHAR; 413 # else 414 # error Please make sure your system supports the wchar_t type 415 # endif 416 #endif /* WIN32 */ 417 418 419 #ifdef UNICODE 420 typedef SQLWCHAR SQLTCHAR; 421 #else 422 typedef SQLCHAR SQLTCHAR; 423 #endif /* UNICODE */ 424 425 #ifdef __cplusplus 426 } 427 #endif 428 429 #endif /* _SQLTYPES_H */ 430