1 | /* |
2 | * PROGRAM: Firebird RDBMS definitions |
3 | * MODULE: fb_types.h |
4 | * DESCRIPTION: Firebird's platform independent data types header |
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 Mike Nordell and Mark O'Donohue |
18 | * for the Firebird Open Source RDBMS project. |
19 | * |
20 | * Copyright (c) 2001 |
21 | * Mike Nordel <tamlin@algonet.se> |
22 | * Mark O'Donohue <mark.odonohue@ludwig.edu.au> |
23 | * and all contributors signed below. |
24 | * |
25 | * All Rights Reserved. |
26 | * Contributor(s): ______________________________________. |
27 | * |
28 | * 2002.02.15 Sean Leyne - Code Cleanup, removed obsolete "OS/2" port |
29 | * |
30 | */ |
31 | |
32 | #ifndef INCLUDE_FB_TYPES_H |
33 | #define INCLUDE_FB_TYPES_H |
34 | |
35 | #include <limits.h> |
36 | |
37 | #if SIZEOF_LONG == 8 |
38 | /* EKU: Firebird requires (S)LONG to be 32 bit */ |
39 | typedef int SLONG; |
40 | typedef unsigned int ULONG; |
41 | const SLONG SLONG_MIN = INT_MIN; |
42 | const SLONG SLONG_MAX = INT_MAX; |
43 | #elif SIZEOF_LONG == 4 |
44 | typedef long SLONG; |
45 | typedef unsigned long ULONG; |
46 | const SLONG SLONG_MIN = LONG_MIN; |
47 | const SLONG SLONG_MAX = LONG_MAX; |
48 | #else |
49 | #error compile_time_failure: SIZEOF_LONG not specified |
50 | #endif |
51 | |
52 | /* Basic data types */ |
53 | |
54 | /* typedef signed char SCHAR; |
55 | * TMN: TODO It seems SCHAR is used just about *everywhere* where a plain |
56 | * "char" is really intended. This currently forces us to this bad definition. |
57 | */ |
58 | typedef char SCHAR; |
59 | |
60 | typedef unsigned char UCHAR; |
61 | typedef short SSHORT; |
62 | typedef unsigned short USHORT; |
63 | |
64 | #ifdef WIN_NT |
65 | typedef __int64 SINT64; |
66 | typedef unsigned __int64 FB_UINT64; |
67 | #else |
68 | typedef long long int SINT64; |
69 | typedef unsigned long long int FB_UINT64; |
70 | #endif |
71 | |
72 | /* Substitution of API data types */ |
73 | |
74 | typedef SCHAR ISC_SCHAR; |
75 | typedef UCHAR ISC_UCHAR; |
76 | typedef SSHORT ISC_SHORT; |
77 | typedef USHORT ISC_USHORT; |
78 | typedef SLONG ISC_LONG; |
79 | typedef ULONG ISC_ULONG; |
80 | typedef SINT64 ISC_INT64; |
81 | typedef FB_UINT64 ISC_UINT64; |
82 | |
83 | #include "types_pub.h" |
84 | |
85 | typedef ISC_QUAD SQUAD; |
86 | |
87 | /* |
88 | * TMN: some misc data types from all over the place |
89 | */ |
90 | struct vary |
91 | { |
92 | USHORT vary_length; |
93 | char vary_string[1]; /* CVC: The original declaration used UCHAR. */ |
94 | }; |
95 | |
96 | struct lstring |
97 | { |
98 | ULONG lstr_length; |
99 | ULONG lstr_allocated; |
100 | UCHAR* lstr_address; |
101 | }; |
102 | |
103 | typedef unsigned char BOOLEAN; |
104 | typedef char TEXT; /* To be expunged over time */ |
105 | typedef unsigned char BYTE; /* Unsigned byte - common */ |
106 | typedef intptr_t IPTR; |
107 | typedef uintptr_t U_IPTR; |
108 | |
109 | typedef void (*FPTR_VOID) (); |
110 | typedef void (*FPTR_VOID_PTR) (void*); |
111 | typedef int (*FPTR_INT) (); |
112 | typedef int (*FPTR_INT_VOID_PTR) (void*); |
113 | typedef void (*FPTR_PRINT_CALLBACK) (void*, SSHORT, const char*); |
114 | /* Used for isc_version */ |
115 | typedef void (*FPTR_VERSION_CALLBACK)(void*, const char*); |
116 | /* Used for isc_que_events and internal functions */ |
117 | typedef void (*FPTR_EVENT_CALLBACK)(void*, USHORT, const UCHAR*); |
118 | |
119 | /* The type of JRD's ERR_post, DSQL's ERRD_post & post_error, |
120 | * REMOTE's move_error & GPRE's post_error. |
121 | */ |
122 | namespace Firebird { |
123 | namespace Arg { |
124 | class StatusVector; |
125 | } |
126 | } |
127 | typedef void (*ErrorFunction) (const Firebird::Arg::StatusVector& v); |
128 | // kept for backward compatibility with old private API (CVT_move()) |
129 | typedef void (*FPTR_ERROR) (ISC_STATUS, ...); |
130 | |
131 | typedef ULONG RCRD_OFFSET; |
132 | typedef USHORT FLD_LENGTH; |
133 | /* CVC: internal usage. I suspect the only reason to return int is that |
134 | vmslock.cpp:LOCK_convert() calls VMS' sys$enq that may require this signature, |
135 | but our code never uses the return value. */ |
136 | typedef int (*lock_ast_t)(void*); |
137 | |
138 | /* Number of elements in an array */ |
139 | #define FB_NELEM(x) ((int)(sizeof(x) / sizeof(x[0]))) |
140 | |
141 | // Intl types |
142 | typedef SSHORT CHARSET_ID; |
143 | typedef SSHORT COLLATE_ID; |
144 | typedef USHORT TTYPE_ID; |
145 | |
146 | // Stream type, had to move it from dsql/Nodes.h due to circular dependencies. |
147 | typedef ULONG StreamType; |
148 | |
149 | // The type of Jrd's transaction. |
150 | typedef ULONG TraNumber; |
151 | |
152 | #endif /* INCLUDE_FB_TYPES_H */ |
153 | |