1 /*
2  * Type definitions for libfwnt
3  *
4  * Copyright (C) 2009-2021, Joachim Metz <joachim.metz@gmail.com>
5  *
6  * Refer to AUTHORS for acknowledgements.
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with this program.  If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #if !defined( _LIBFWNT_TYPES_H )
23 #define _LIBFWNT_TYPES_H
24 
25 #include <libfwnt/features.h>
26 
27 /* Integer type definitions
28  */
29 #if ( defined( _MSC_VER ) && ( _MSC_VER < 1600 ) ) || ( defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 ) )
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /* Microsoft Visual Studio C++ before Visual Studio 2010 or earlier versions of the Borland C++ Builder
36  * do not support the (u)int#_t type definitions but have __int# definitions instead
37  */
38 #if !defined( HAVE_INT8_T )
39 #define HAVE_INT8_T
40 typedef __int8 int8_t;
41 #endif
42 
43 #if !defined( HAVE_UINT8_T )
44 #define HAVE_UINT8_T
45 typedef unsigned __int8 uint8_t;
46 #endif
47 
48 #if !defined( HAVE_INT16_T )
49 #define HAVE_INT16_T
50 typedef __int16 int16_t;
51 #endif
52 
53 #if !defined( HAVE_UINT16_T )
54 #define HAVE_UINT16_T
55 typedef unsigned __int16 uint16_t;
56 #endif
57 
58 #if !defined( HAVE_INT32_T )
59 #define HAVE_INT32_T
60 typedef __int32 int32_t;
61 #endif
62 
63 #if !defined( HAVE_UINT32_T )
64 #define HAVE_UINT32_T
65 typedef unsigned __int32 uint32_t;
66 #endif
67 
68 #if !defined( HAVE_INT64_T )
69 #define HAVE_INT64_T
70 typedef __int64 int64_t;
71 #endif
72 
73 #if !defined( HAVE_UINT64_T )
74 #define HAVE_UINT64_T
75 typedef unsigned __int64 uint64_t;
76 #endif
77 
78 #ifdef __cplusplus
79 }
80 #endif
81 
82 #elif defined( _MSC_VER ) || defined( __BORLANDC__ )
83 
84 /* Later versions of Microsoft Visual Studio C++ and Borland C/C++ define the types in <stdint.h>
85  */
86 #include <stdint.h>
87 
88 #else
89 
90 #if 1 || defined( HAVE_SYS_TYPES_H )
91 #include <sys/types.h>
92 
93 #else
94 #error Missing system type definitions (sys/types.h)
95 #endif
96 
97 /* Type definitions for compilers that have access to
98  * <inttypes.h> or <stdint.h>
99  */
100 #if 1 || defined( HAVE_INTTYPES_H )
101 #include <inttypes.h>
102 
103 #elif 1 || defined( HAVE_STDINT_H )
104 #include <stdint.h>
105 
106 #else
107 #error Missing integer type definitions (inttypes.h, stdint.h)
108 #endif
109 
110 #endif
111 
112 #ifdef __cplusplus
113 extern "C" {
114 #endif
115 
116 #if defined( _MSC_VER ) || ( defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 ) )
117 
118 /* Microsoft Visual Studio C++ or earlier versions of the Borland C++ Builder
119  * do not support the ssize_t type definition
120  */
121 #if !defined( HAVE_SSIZE_T )
122 #define HAVE_SSIZE_T
123 
124 #if defined( _WIN64 )
125 typedef __int64 ssize_t;
126 #else
127 typedef __int32 ssize_t;
128 #endif
129 
130 #endif /* !defined( HAVE_SSIZE_T ) */
131 
132 #endif /* defined( _MSC_VER ) || ( defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 ) ) */
133 
134 #if defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 )
135 
136 /* Earlier versions of Borland C++ Builder do not support the intptr_t type definition
137  */
138 #if !defined( HAVE_INTPTR_T )
139 #define HAVE_INTPTR_T
140 
141 #if defined( _WIN64 )
142 typedef __int64	intptr_t;
143 #else
144 typedef __int32	intptr_t;
145 #endif
146 
147 #endif /* !defined( HAVE_INTPTR_T ) */
148 
149 #endif /* defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0560 ) */
150 
151 #if ( !defined( HAVE_SIZE32_T ) && ! 0 ) || HAVE_SIZE32_T == 0
152 #define HAVE_SIZE32_T	1
153 typedef uint32_t size32_t;
154 #endif
155 
156 #if ( !defined( HAVE_SSIZE32_T ) && ! 0 ) || HAVE_SSIZE32_T == 0
157 #define HAVE_SSIZE32_T	1
158 typedef int32_t ssize32_t;
159 #endif
160 
161 #if ( !defined( HAVE_SIZE64_T ) && ! 0 ) || HAVE_SIZE64_T == 0
162 #define HAVE_SIZE64_T	1
163 typedef uint64_t size64_t;
164 #endif
165 
166 #if ( !defined( HAVE_SSIZE64_T ) && ! 0 ) || HAVE_SSIZE64_T == 0
167 #define HAVE_SSIZE64_T	1
168 typedef int64_t ssize64_t;
169 #endif
170 
171 #if ( !defined( HAVE_OFF64_T ) && ! 0 ) || HAVE_OFF64_T == 0
172 #define HAVE_OFF64_T	1
173 typedef int64_t off64_t;
174 #endif
175 
176 /* Wide character definition
177  */
178 #if defined( __BORLANDC__ ) && ( __BORLANDC__ <= 0x0520 )
179 #include <string.h>
180 
181 #elif defined( WINAPI )
182 #include <wchar.h>
183 
184 #elif 1 || defined( HAVE_WCHAR_H )
185 
186 /* __USE_UNIX98 is required to add swprintf definition
187  */
188 #if !defined( __USE_UNIX98 )
189 #define __USE_UNIX98
190 #define LIBFWNT_DEFINITION_UNIX98
191 #endif
192 
193 #include <wchar.h>
194 
195 #if defined( LIBFWNT_DEFINITION_UNIX98 )
196 #undef __USE_UNIX98
197 #undef LIBFWNT_DEFINITION_UNIX98
198 #endif
199 
200 #endif
201 
202 /* The following type definitions hide internal data structures
203  */
204 typedef intptr_t libfwnt_access_control_entry_t;
205 typedef intptr_t libfwnt_access_control_list_t;
206 typedef intptr_t libfwnt_security_descriptor_t;
207 typedef intptr_t libfwnt_security_identifier_t;
208 
209 #ifdef __cplusplus
210 }
211 #endif
212 
213 #endif /* !defined( _LIBFWNT_TYPES_H ) */
214 
215