Avoid potential negative array index access to cached text.
[LibreOffice.git] / external / iODBC / inc / odbc / sqltypes.h
blobcf824d6e0ae5bf94908e2678e918f0d9d3964368
1 /*
2 * sqltypes.h
4 * $Id$
6 * ODBC typedefs
8 * The iODBC driver manager.
10 * Copyright (C) 1995 Ke Jin <kejin@empress.com>
11 * Copyright (C) 1996-2021 OpenLink Software <iodbc@openlinksw.com>
12 * All Rights Reserved.
14 * This software is released under the terms of either of the following
15 * licenses:
17 * - GNU Library General Public License (see LICENSE.LGPL)
18 * - The BSD License (see LICENSE.BSD).
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.
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:
29 * http://www.iodbc.org
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.
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.
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
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:
55 * 1. Redistributions of source code must retain the above copyright
56 * 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.
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.
78 #ifndef _SQLTYPES_H
79 #define _SQLTYPES_H
82 * Set default specification to ODBC 3.51
84 #ifndef ODBCVER
85 #define ODBCVER 0x0351
86 #endif
89 * Include Windows style defines and typedefs on Unix
91 #ifndef _IODBCUNIX_H
92 #include "iodbcunix.h"
93 #endif
95 #ifdef __cplusplus
96 extern "C" {
97 #endif
101 * Environment specific definitions
103 #ifndef EXPORT
104 #define EXPORT
105 #endif
107 #ifdef WIN32
108 #define SQL_API __stdcall
109 #else
110 #define SQL_API
111 #endif
115 * API declaration data types
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;
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 */
144 * New Win64 datatypes
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
162 * Backward compatibility with older platform sdks
164 typedef SQLULEN SQLROWCOUNT;
165 typedef SQLULEN SQLROWSETSIZE;
166 typedef SQLULEN SQLTRANSID;
167 typedef SQLLEN SQLROWOFFSET;
171 * Generic pointer types
173 typedef void * PTR;
174 typedef void * SQLHANDLE;
178 * Handles
180 typedef void * HENV;
181 typedef void * HDBC;
182 typedef void * HSTMT;
184 typedef SQLHANDLE SQLHENV;
185 typedef SQLHANDLE SQLHDBC;
186 typedef SQLHANDLE SQLHSTMT;
187 #if (ODBCVER >= 0x0300)
188 typedef SQLHANDLE SQLHDESC;
189 #endif /* ODBCVER >= 0x0300 */
193 * Window Handle
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
208 * SQL portable types for C
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;
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;
227 * Return type for functions
229 typedef signed short RETCODE;
230 typedef SQLSMALLINT SQLRETURN;
234 * SQL portable types for C - DATA, TIME, TIMESTAMP, and BOOKMARK
236 typedef SQLULEN BOOKMARK;
239 typedef struct tagDATE_STRUCT
241 SQLSMALLINT year;
242 SQLUSMALLINT month;
243 SQLUSMALLINT day;
245 DATE_STRUCT;
247 #if (ODBCVER >= 0x0300)
248 typedef DATE_STRUCT SQL_DATE_STRUCT;
249 #endif /* ODBCVER >= 0x0300 */
252 typedef struct tagTIME_STRUCT
254 SQLUSMALLINT hour;
255 SQLUSMALLINT minute;
256 SQLUSMALLINT second;
258 TIME_STRUCT;
260 #if (ODBCVER >= 0x0300)
261 typedef TIME_STRUCT SQL_TIME_STRUCT;
262 #endif /* ODBCVER >= 0x0300 */
265 typedef struct tagTIMESTAMP_STRUCT
267 SQLSMALLINT year;
268 SQLUSMALLINT month;
269 SQLUSMALLINT day;
270 SQLUSMALLINT hour;
271 SQLUSMALLINT minute;
272 SQLUSMALLINT second;
273 SQLUINTEGER fraction;
275 TIMESTAMP_STRUCT;
277 #if (ODBCVER >= 0x0300)
278 typedef TIMESTAMP_STRUCT SQL_TIMESTAMP_STRUCT;
279 #endif /* ODBCVER >= 0x0300 */
283 * Enumeration for DATETIME_INTERVAL_SUBCODE values for interval data types
285 * These values are from SQL-92
287 #if (ODBCVER >= 0x0300)
288 typedef enum
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
304 SQLINTERVAL;
307 typedef struct tagSQL_YEAR_MONTH
309 SQLUINTEGER year;
310 SQLUINTEGER month;
312 SQL_YEAR_MONTH_STRUCT;
315 typedef struct tagSQL_DAY_SECOND
317 SQLUINTEGER day;
318 SQLUINTEGER hour;
319 SQLUINTEGER minute;
320 SQLUINTEGER second;
321 SQLUINTEGER fraction;
323 SQL_DAY_SECOND_STRUCT;
326 typedef struct tagSQL_INTERVAL_STRUCT
328 SQLINTERVAL interval_type;
329 SQLSMALLINT interval_sign;
330 union
332 SQL_YEAR_MONTH_STRUCT year_month;
333 SQL_DAY_SECOND_STRUCT day_second;
335 intval;
337 SQL_INTERVAL_STRUCT;
338 #endif /* ODBCVER >= 0x0300 */
342 * The ODBC C types for SQL_C_SBIGINT and SQL_C_UBIGINT
344 #if (ODBCVER >= 0x0300)
346 #if defined(_MSC_VER) && (_MSC_VER >= 900)
347 # define ODBCINT64 __int64
348 #endif
350 #ifndef ODBCINT64
351 # if (SIZEOF_LONG == 8)
352 # define ODBCINT64 long
353 # else
354 # define ODBCINT64 long long
355 # endif
356 #endif /* ODBCINT64 */
358 #if defined (ODBCINT64)
359 typedef signed ODBCINT64 SQLBIGINT;
360 typedef unsigned ODBCINT64 SQLUBIGINT;
361 #endif /* ODBCINT64 */
363 #endif /* ODBCVER >= 0x0300 */
367 * The internal representation of the numeric data type
369 #if (ODBCVER >= 0x0300)
370 #define SQL_MAX_NUMERIC_LEN 16
371 typedef struct tagSQL_NUMERIC_STRUCT
373 SQLCHAR precision;
374 SQLSCHAR scale;
375 SQLCHAR sign; /* 0 for negative, 1 for positive */
376 SQLCHAR val[SQL_MAX_NUMERIC_LEN];
378 SQL_NUMERIC_STRUCT;
379 #endif /* ODBCVER >= 0x0300 */
382 #if (ODBCVER >= 0x0350)
383 #ifdef GUID_DEFINED
384 typedef GUID SQLGUID;
385 #else
386 typedef struct tagSQLGUID
388 unsigned int Data1;
389 unsigned short Data2;
390 unsigned short Data3;
391 unsigned char Data4[8]; /* BYTE */
393 SQLGUID;
394 #endif /* GUID_DEFINED */
395 #endif /* ODBCVER >= 0x0350 */
398 #if defined(WIN32)
399 typedef unsigned short SQLWCHAR;
400 #else
401 # include <stdlib.h>
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 */
419 #ifdef UNICODE
420 typedef SQLWCHAR SQLTCHAR;
421 #else
422 typedef SQLCHAR SQLTCHAR;
423 #endif /* UNICODE */
425 #ifdef __cplusplus
427 #endif
429 #endif /* _SQLTYPES_H */