]>
Commit | Line | Data |
---|---|---|
d02b48c6 | 1 | /* e_os.h */ |
58964a49 | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
d02b48c6 RE |
3 | * All rights reserved. |
4 | * | |
5 | * This package is an SSL implementation written | |
6 | * by Eric Young (eay@cryptsoft.com). | |
7 | * The implementation was written so as to conform with Netscapes SSL. | |
8 | * | |
9 | * This library is free for commercial and non-commercial use as long as | |
10 | * the following conditions are aheared to. The following conditions | |
11 | * apply to all code found in this distribution, be it the RC4, RSA, | |
12 | * lhash, DES, etc., code; not just the SSL code. The SSL documentation | |
13 | * included with this distribution is covered by the same copyright terms | |
14 | * except that the holder is Tim Hudson (tjh@cryptsoft.com). | |
15 | * | |
16 | * Copyright remains Eric Young's, and as such any Copyright notices in | |
17 | * the code are not to be removed. | |
18 | * If this package is used in a product, Eric Young should be given attribution | |
19 | * as the author of the parts of the library used. | |
20 | * This can be in the form of a textual message at program startup or | |
21 | * in documentation (online or textual) provided with the package. | |
22 | * | |
23 | * Redistribution and use in source and binary forms, with or without | |
24 | * modification, are permitted provided that the following conditions | |
25 | * are met: | |
26 | * 1. Redistributions of source code must retain the copyright | |
27 | * notice, this list of conditions and the following disclaimer. | |
28 | * 2. Redistributions in binary form must reproduce the above copyright | |
29 | * notice, this list of conditions and the following disclaimer in the | |
30 | * documentation and/or other materials provided with the distribution. | |
31 | * 3. All advertising materials mentioning features or use of this software | |
32 | * must display the following acknowledgement: | |
33 | * "This product includes cryptographic software written by | |
34 | * Eric Young (eay@cryptsoft.com)" | |
35 | * The word 'cryptographic' can be left out if the rouines from the library | |
36 | * being used are not cryptographic related :-). | |
37 | * 4. If you include any Windows specific code (or a derivative thereof) from | |
38 | * the apps directory (application code) you must include an acknowledgement: | |
39 | * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" | |
40 | * | |
41 | * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND | |
42 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | |
43 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
44 | * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE | |
45 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | |
46 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | |
47 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
48 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | |
49 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | |
50 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |
51 | * SUCH DAMAGE. | |
52 | * | |
53 | * The licence and distribution terms for any publically available version or | |
54 | * derivative of this code cannot be changed. i.e. this code cannot simply be | |
55 | * copied and put under another distribution licence | |
56 | * [including the GNU Public Licence.] | |
57 | */ | |
58 | ||
59 | #ifndef HEADER_E_OS_H | |
60 | #define HEADER_E_OS_H | |
61 | ||
fa470a84 BM |
62 | #include <openssl/e_os2.h> |
63 | /* <openssl/e_os2.h> contains what we can justify to make visible | |
17e3dd1c BM |
64 | * to the outside; this file e_os.h is not part of the exported |
65 | * interface. */ | |
fa470a84 | 66 | |
d02b48c6 RE |
67 | #ifdef __cplusplus |
68 | extern "C" { | |
69 | #endif | |
70 | ||
58964a49 RE |
71 | /* Used to checking reference counts, most while doing perl5 stuff :-) */ |
72 | #ifdef REF_PRINT | |
73 | #undef REF_PRINT | |
74 | #define REF_PRINT(a,b) fprintf(stderr,"%08X:%4d:%s\n",(int)b,b->references,a) | |
75 | #endif | |
76 | ||
d02b48c6 | 77 | #ifndef DEVRANDOM |
58964a49 RE |
78 | /* set this to your 'random' device if you have one. |
79 | * My default, we will try to read this file */ | |
80 | #define DEVRANDOM "/dev/urandom" | |
d02b48c6 RE |
81 | #endif |
82 | ||
d02b48c6 RE |
83 | /******************************************************************** |
84 | The Microsoft section | |
85 | ********************************************************************/ | |
86 | /* The following is used becaue of the small stack in some | |
87 | * Microsoft operating systems */ | |
88 | #if defined(WIN16) || defined(MSDOS) | |
89 | # define MS_STATIC static | |
90 | #else | |
91 | # define MS_STATIC | |
92 | #endif | |
93 | ||
94 | #if defined(WIN32) || defined(WIN16) | |
95 | # ifndef WINDOWS | |
96 | # define WINDOWS | |
97 | # endif | |
98 | # ifndef MSDOS | |
99 | # define MSDOS | |
100 | # endif | |
101 | #endif | |
102 | ||
58964a49 RE |
103 | #ifdef WIN32 |
104 | #define get_last_sys_error() GetLastError() | |
105 | #define clear_sys_error() SetLastError(0) | |
6e064240 DSH |
106 | #if !defined(WINNT) |
107 | #define WIN_CONSOLE_BUG | |
108 | #endif | |
58964a49 RE |
109 | #else |
110 | #define get_last_sys_error() errno | |
111 | #define clear_sys_error() errno=0 | |
112 | #endif | |
113 | ||
114 | #ifdef WINDOWS | |
115 | #define get_last_socket_error() WSAGetLastError() | |
116 | #define clear_socket_error() WSASetLastError(0) | |
dfeab068 RE |
117 | #define readsocket(s,b,n) recv((s),(b),(n),0) |
118 | #define writesocket(s,b,n) send((s),(b),(n),0) | |
119 | #define EADDRINUSE WSAEADDRINUSE | |
58964a49 RE |
120 | #else |
121 | #define get_last_socket_error() errno | |
122 | #define clear_socket_error() errno=0 | |
123 | #define ioctlsocket(a,b,c) ioctl(a,b,c) | |
dfeab068 RE |
124 | #define closesocket(s) close(s) |
125 | #define readsocket(s,b,n) read((s),(b),(n)) | |
126 | #define writesocket(s,b,n) write((s),(b),(n)) | |
58964a49 RE |
127 | #endif |
128 | ||
d02b48c6 | 129 | #ifdef WIN16 |
58964a49 | 130 | # define NO_FP_API |
d02b48c6 RE |
131 | # define MS_CALLBACK _far _loadds |
132 | # define MS_FAR _far | |
133 | #else | |
134 | # define MS_CALLBACK | |
135 | # define MS_FAR | |
136 | #endif | |
137 | ||
58964a49 RE |
138 | #ifdef NO_STDIO |
139 | # define NO_FP_API | |
140 | #endif | |
141 | ||
d02b48c6 RE |
142 | #if defined(WINDOWS) || defined(MSDOS) |
143 | ||
144 | #ifndef S_IFDIR | |
145 | #define S_IFDIR _S_IFDIR | |
146 | #endif | |
147 | ||
148 | #ifndef S_IFMT | |
149 | #define S_IFMT _S_IFMT | |
6e064240 DSH |
150 | |
151 | #if !defined(WINNT) | |
152 | #define NO_SYSLOG | |
6e064240 | 153 | #endif |
0cc39579 | 154 | #define NO_DIRENT |
6e064240 | 155 | |
d02b48c6 RE |
156 | #endif |
157 | ||
d02b48c6 RE |
158 | # ifdef WINDOWS |
159 | # include <windows.h> | |
160 | # include <stddef.h> | |
161 | # include <errno.h> | |
162 | # include <string.h> | |
163 | # include <malloc.h> | |
164 | # endif | |
165 | # include <io.h> | |
166 | # include <fcntl.h> | |
167 | ||
31a674d8 UM |
168 | #if defined (__BORLANDC__) |
169 | #define _setmode setmode | |
170 | #define _O_TEXT O_TEXT | |
171 | #define _O_BINARY O_BINARY | |
172 | #define _int64 __int64 | |
173 | #endif | |
174 | ||
58964a49 RE |
175 | #if defined(WIN16) && !defined(MONOLITH) && defined(SSLEAY) && defined(_WINEXITNOPERSIST) |
176 | # define EXIT(n) { if (n == 0) _wsetexit(_WINEXITNOPERSIST); return(n); } | |
d02b48c6 RE |
177 | #else |
178 | # define EXIT(n) return(n); | |
179 | #endif | |
180 | # define LIST_SEPARATOR_CHAR ';' | |
181 | #ifndef X_OK | |
182 | # define X_OK 0 | |
183 | #endif | |
184 | #ifndef W_OK | |
185 | # define W_OK 2 | |
186 | #endif | |
187 | #ifndef R_OK | |
188 | # define R_OK 4 | |
189 | #endif | |
06d5b162 RE |
190 | # define OPENSSL_CONF "openssl.cnf" |
191 | # define SSLEAY_CONF OPENSSL_CONF | |
58964a49 | 192 | # define NUL_DEV "nul" |
d02b48c6 RE |
193 | # define RFILE ".rnd" |
194 | ||
195 | #else /* The non-microsoft world world */ | |
196 | ||
7d7d2cbc UM |
197 | # if defined(__VMS) && !defined(VMS) |
198 | # define VMS 1 | |
199 | # endif | |
200 | ||
d02b48c6 | 201 | # ifdef VMS |
7d7d2cbc UM |
202 | /* some programs don't include stdlib, so exit() and others give implicit |
203 | function warnings */ | |
204 | # include <stdlib.h> | |
205 | # if defined(__DECC) | |
206 | # include <unistd.h> | |
207 | # else | |
208 | # include <unixlib.h> | |
209 | # endif | |
210 | # define OPENSSL_CONF "openssl.cnf" | |
211 | # define SSLEAY_CONF OPENSSL_CONF | |
212 | # define RFILE ".rnd" | |
213 | # define LIST_SEPARATOR_CHAR ',' | |
214 | # define NUL_DEV "NLA0:" | |
215 | /* We need to do this, because DEC C converts exit code 0 to 1, but not 1 | |
216 | to 0. We will convert 1 to 3! Also, add the inhibit message bit... */ | |
217 | # ifndef MONOLITH | |
218 | # define EXIT(n) do { int __VMS_EXIT = n; \ | |
219 | if (__VMS_EXIT == 1) __VMS_EXIT = 3; \ | |
220 | __VMS_EXIT |= 0x10000000; \ | |
221 | exit(n); return(n); } while(0) | |
222 | # else | |
223 | # define EXIT(n) do { int __VMS_EXIT = n; \ | |
224 | if (__VMS_EXIT == 1) __VMS_EXIT = 3; \ | |
225 | __VMS_EXIT |= 0x10000000; \ | |
226 | return(n); } while(0) | |
227 | # endif | |
d02b48c6 RE |
228 | # else |
229 | # include <unistd.h> | |
d02b48c6 | 230 | |
7d7d2cbc UM |
231 | # define OPENSSL_CONF "openssl.cnf" |
232 | # define SSLEAY_CONF OPENSSL_CONF | |
233 | # define RFILE ".rnd" | |
234 | # define LIST_SEPARATOR_CHAR ':' | |
235 | # define NUL_DEV "/dev/null" | |
236 | # ifndef MONOLITH | |
237 | # define EXIT(n) exit(n); return(n) | |
238 | # else | |
239 | # define EXIT(n) return(n) | |
240 | # endif | |
d02b48c6 | 241 | # endif |
d02b48c6 RE |
242 | |
243 | # define SSLeay_getpid() getpid() | |
244 | ||
245 | #endif | |
246 | ||
7d7d2cbc | 247 | |
d02b48c6 RE |
248 | /*************/ |
249 | ||
250 | #ifdef USE_SOCKETS | |
251 | # if defined(WINDOWS) || defined(MSDOS) | |
252 | /* windows world */ | |
253 | ||
254 | # ifdef NO_SOCK | |
255 | # define SSLeay_Write(a,b,c) (-1) | |
256 | # define SSLeay_Read(a,b,c) (-1) | |
257 | # define SHUTDOWN(fd) close(fd) | |
258 | # define SHUTDOWN2(fd) close(fd) | |
259 | # else | |
260 | # include <winsock.h> | |
261 | extern HINSTANCE _hInstance; | |
262 | # define SSLeay_Write(a,b,c) send((a),(b),(c),0) | |
263 | # define SSLeay_Read(a,b,c) recv((a),(b),(c),0) | |
264 | # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); } | |
265 | # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); } | |
266 | # endif | |
267 | ||
268 | ||
269 | # else | |
270 | ||
7d7d2cbc | 271 | # include <sys/types.h> |
d02b48c6 | 272 | # ifndef VMS |
7d7d2cbc UM |
273 | # include <sys/param.h> |
274 | # endif | |
275 | # include <sys/time.h> /* Needed under linux for FD_XXX */ | |
276 | ||
277 | # include <netdb.h> | |
278 | # if defined(VMS) && !defined(__DECC) | |
279 | # include <socket.h> | |
280 | # include <in.h> | |
281 | # else | |
d02b48c6 | 282 | # include <sys/socket.h> |
58964a49 RE |
283 | # ifdef FILIO_H |
284 | # include <sys/filio.h> /* Added for FIONBIO under unixware */ | |
285 | # endif | |
d02b48c6 RE |
286 | # include <netinet/in.h> |
287 | # endif | |
288 | ||
289 | # if defined(NeXT) || defined(_NEXT_SOURCE) | |
290 | # include <sys/fcntl.h> | |
291 | # include <sys/types.h> | |
292 | # endif | |
293 | ||
294 | # ifdef AIX | |
295 | # include <sys/select.h> | |
296 | # endif | |
297 | ||
298 | # if defined(sun) | |
299 | # include <sys/filio.h> | |
300 | # else | |
7d7d2cbc UM |
301 | # ifndef VMS |
302 | # include <sys/ioctl.h> | |
303 | # else | |
304 | /* ioctl is only in VMS > 7.0 and when socketshr is not used */ | |
305 | # if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000) | |
306 | # include <sys/ioctl.h> | |
307 | # endif | |
308 | # endif | |
d02b48c6 RE |
309 | # endif |
310 | ||
311 | # ifdef VMS | |
312 | # include <unixio.h> | |
7d7d2cbc UM |
313 | # if defined(TCPIP_TYPE_SOCKETSHR) |
314 | # include <socketshr.h> | |
315 | # endif | |
d02b48c6 RE |
316 | # endif |
317 | ||
318 | # define SSLeay_Read(a,b,c) read((a),(b),(c)) | |
319 | # define SSLeay_Write(a,b,c) write((a),(b),(c)) | |
320 | # define SHUTDOWN(fd) { shutdown((fd),0); close((fd)); } | |
321 | # define SHUTDOWN2(fd) { shutdown((fd),2); close((fd)); } | |
dfeab068 | 322 | # define INVALID_SOCKET (-1) |
d02b48c6 RE |
323 | # endif |
324 | #endif | |
325 | ||
326 | #if defined(THREADS) || defined(sun) | |
327 | #ifndef _REENTRANT | |
328 | #define _REENTRANT | |
329 | #endif | |
330 | #endif | |
331 | ||
332 | /***********************************************/ | |
333 | ||
d02b48c6 RE |
334 | /* do we need to do this for getenv. |
335 | * Just define getenv for use under windows */ | |
336 | ||
337 | #ifdef WIN16 | |
338 | /* How to do this needs to be thought out a bit more.... */ | |
339 | /*char *GETENV(char *); | |
340 | #define Getenv GETENV*/ | |
341 | #define Getenv getenv | |
342 | #else | |
343 | #define Getenv getenv | |
344 | #endif | |
345 | ||
346 | #define DG_GCC_BUG /* gcc < 2.6.3 on DGUX */ | |
347 | ||
348 | #ifdef sgi | |
349 | #define IRIX_CC_BUG /* all version of IRIX I've tested (4.* 5.*) */ | |
350 | #endif | |
95f9968e BM |
351 | #ifdef SNI |
352 | #define IRIX_CC_BUG /* CDS++ up to V2.0Bsomething suffered from the same bug.*/ | |
353 | #endif | |
d02b48c6 RE |
354 | |
355 | #ifdef NO_MD2 | |
356 | #define MD2_Init MD2Init | |
357 | #define MD2_Update MD2Update | |
358 | #define MD2_Final MD2Final | |
359 | #define MD2_DIGEST_LENGTH 16 | |
360 | #endif | |
361 | #ifdef NO_MD5 | |
362 | #define MD5_Init MD5Init | |
363 | #define MD5_Update MD5Update | |
364 | #define MD5_Final MD5Final | |
365 | #define MD5_DIGEST_LENGTH 16 | |
366 | #endif | |
367 | ||
368 | #ifdef __cplusplus | |
369 | } | |
370 | #endif | |
371 | ||
372 | #endif | |
373 |