1 | /* |
2 | * PROGRAM: Client/Server Common Code |
3 | * MODULE: types_pub.h |
4 | * DESCRIPTION: Types that are used both internally and externally |
5 | * |
6 | * The contents of this file are subject to the Initial |
7 | * Developer's Public License Version 1.0 (the "License"); |
8 | * you may not use this file except in compliance with the |
9 | * License. You may obtain a copy of the License at |
10 | * http://www.ibphoenix.com/main.nfs?a=ibphoenix&page=ibp_idpl. |
11 | * |
12 | * Software distributed under the License is distributed AS IS, |
13 | * WITHOUT WARRANTY OF ANY KIND, either express or implied. |
14 | * See the License for the specific language governing rights |
15 | * and limitations under the License. |
16 | * |
17 | * The Original Code was created by Dmitry Yemanov |
18 | * for the Firebird Open Source RDBMS project. |
19 | * |
20 | * Copyright (c) 2004 Dmitry Yemanov <dimitr@users.sf.net> |
21 | * and all contributors signed below. |
22 | * |
23 | * All Rights Reserved. |
24 | * Contributor(s): ______________________________________. |
25 | */ |
26 | |
27 | #ifndef INCLUDE_TYPES_PUB_H |
28 | #define INCLUDE_TYPES_PUB_H |
29 | |
30 | #include <stddef.h> |
31 | |
32 | #if defined(__GNUC__) || defined (__HP_cc) || defined (__HP_aCC) |
33 | #include <inttypes.h> |
34 | #else |
35 | |
36 | #if !defined(_INTPTR_T_DEFINED) |
37 | #if defined(_WIN64) |
38 | typedef __int64 intptr_t; |
39 | typedef unsigned __int64 uintptr_t; |
40 | #else |
41 | typedef long intptr_t; |
42 | typedef unsigned long uintptr_t; |
43 | #endif |
44 | #endif |
45 | |
46 | #endif |
47 | |
48 | #define FB_ALIGN(n, b) ((n + b - 1) & ~(b - 1)) |
49 | |
50 | /******************************************************************/ |
51 | /* API handles */ |
52 | /******************************************************************/ |
53 | |
54 | #if defined(_LP64) || defined(__LP64__) || defined(__arch64__) || defined(_WIN64) |
55 | typedef unsigned int FB_API_HANDLE; |
56 | #else |
57 | typedef void* FB_API_HANDLE; |
58 | #endif |
59 | |
60 | /******************************************************************/ |
61 | /* Status vector */ |
62 | /******************************************************************/ |
63 | |
64 | typedef intptr_t ISC_STATUS; |
65 | |
66 | #define ISC_STATUS_LENGTH 20 |
67 | typedef ISC_STATUS ISC_STATUS_ARRAY[ISC_STATUS_LENGTH]; |
68 | |
69 | /* SQL State as defined in the SQL Standard. */ |
70 | #define FB_SQLSTATE_LENGTH 5 |
71 | #define FB_SQLSTATE_SIZE (FB_SQLSTATE_LENGTH + 1) |
72 | typedef char FB_SQLSTATE_STRING[FB_SQLSTATE_SIZE]; |
73 | |
74 | /******************************************************************/ |
75 | /* Define type, export and other stuff based on c/c++ and Windows */ |
76 | /******************************************************************/ |
77 | #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) |
78 | #define ISC_EXPORT __stdcall |
79 | #define ISC_EXPORT_VARARG __cdecl |
80 | #else |
81 | #define ISC_EXPORT |
82 | #define ISC_EXPORT_VARARG |
83 | #endif |
84 | |
85 | /* |
86 | * It is difficult to detect 64-bit long from the redistributable header |
87 | * we do not care of 16-bit platforms anymore thus we may use plain "int" |
88 | * which is 32-bit on all platforms we support |
89 | * |
90 | * We'll move to this definition in future API releases. |
91 | * |
92 | */ |
93 | |
94 | #if defined(_LP64) || defined(__LP64__) || defined(__arch64__) |
95 | typedef int ISC_LONG; |
96 | typedef unsigned int ISC_ULONG; |
97 | #else |
98 | typedef signed long ISC_LONG; |
99 | typedef unsigned long ISC_ULONG; |
100 | #endif |
101 | |
102 | typedef signed short ISC_SHORT; |
103 | typedef unsigned short ISC_USHORT; |
104 | |
105 | typedef unsigned char ISC_UCHAR; |
106 | typedef char ISC_SCHAR; |
107 | |
108 | typedef ISC_UCHAR FB_BOOLEAN; |
109 | #define FB_FALSE '\0' |
110 | #define FB_TRUE '\1' |
111 | |
112 | /*******************************************************************/ |
113 | /* 64 bit Integers */ |
114 | /*******************************************************************/ |
115 | |
116 | #if (defined(WIN32) || defined(_WIN32) || defined(__WIN32__)) && !defined(__GNUC__) |
117 | typedef __int64 ISC_INT64; |
118 | typedef unsigned __int64 ISC_UINT64; |
119 | #else |
120 | typedef long long int ISC_INT64; |
121 | typedef unsigned long long int ISC_UINT64; |
122 | #endif |
123 | |
124 | /*******************************************************************/ |
125 | /* Time & Date support */ |
126 | /*******************************************************************/ |
127 | |
128 | #ifndef ISC_TIMESTAMP_DEFINED |
129 | typedef int ISC_DATE; |
130 | typedef unsigned int ISC_TIME; |
131 | typedef struct |
132 | { |
133 | ISC_DATE timestamp_date; |
134 | ISC_TIME timestamp_time; |
135 | } ISC_TIMESTAMP; |
136 | #define ISC_TIMESTAMP_DEFINED |
137 | #endif /* ISC_TIMESTAMP_DEFINED */ |
138 | |
139 | /*******************************************************************/ |
140 | /* Blob Id support */ |
141 | /*******************************************************************/ |
142 | |
143 | struct GDS_QUAD_t { |
144 | ISC_LONG gds_quad_high; |
145 | ISC_ULONG gds_quad_low; |
146 | }; |
147 | |
148 | typedef struct GDS_QUAD_t GDS_QUAD; |
149 | typedef struct GDS_QUAD_t ISC_QUAD; |
150 | |
151 | #define isc_quad_high gds_quad_high |
152 | #define isc_quad_low gds_quad_low |
153 | |
154 | typedef int (*FB_SHUTDOWN_CALLBACK)(const int reason, const int mask, void* arg); |
155 | |
156 | #endif /* INCLUDE_TYPES_PUB_H */ |
157 | |