1 /* e_os.h */
2 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
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 /*
60 * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
61 * Use is subject to license terms.
62 */
63
64 #pragma ident "%Z%%M% %I% %E% SMI"
65
66 #ifndef HEADER_E_OS_H
67 #define HEADER_E_OS_H
68
69 #include <openssl/opensslconf.h>
70
71 #include <openssl/e_os2.h>
72 /* <openssl/e_os2.h> contains what we can justify to make visible
73 * to the outside; this file e_os.h is not part of the exported
74 * interface. */
75
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79
80 /* Used to checking reference counts, most while doing perl5 stuff :-) */
81 #ifdef REF_PRINT
82 #undef REF_PRINT
83 #define REF_PRINT(a,b) fprintf(stderr,"%08X:%4d:%s\n",(int)b,b->references,a)
84 #endif
85
86 #ifndef DEVRANDOM
87 /* set this to a comma-separated list of 'random' device files to try out.
88 * My default, we will try to read at least one of these files */
89 #define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom"
90 #endif
91 #ifndef DEVRANDOM_EGD
92 /* set this to a comma-seperated list of 'egd' sockets to try out. These
93 * sockets will be tried in the order listed in case accessing the device files
94 * listed in DEVRANDOM did not return enough entropy. */
95 #define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"
96 #endif
97
98 #if defined(OPENSSL_SYS_VXWORKS)
99 # define NO_SYS_PARAM_H
100 # define NO_CHMOD
101 # define NO_SYSLOG
102 #endif
103
104 #if defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
105 # if macintosh==1
106 # ifndef MAC_OS_GUSI_SOURCE
107 # define MAC_OS_pre_X
108 # define NO_SYS_TYPES_H
109 typedef long ssize_t;
110 # endif
111 # define NO_SYS_PARAM_H
112 # define NO_CHMOD
113 # define NO_SYSLOG
114 # undef DEVRANDOM
115 # define GETPID_IS_MEANINGLESS
116 # endif
117 #endif
118
119 /********************************************************************
120 The Microsoft section
121 ********************************************************************/
122 /* The following is used becaue of the small stack in some
123 * Microsoft operating systems */
124 #if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYSNAME_WIN32)
125 # define MS_STATIC static
126 #else
127 # define MS_STATIC
128 #endif
129
130 #if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
131 # define WIN32
132 #endif
133 #if defined(OPENSSL_SYS_WIN16) && !defined(WIN16)
134 # define WIN16
135 #endif
136 #if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
137 # define WINDOWS
138 #endif
139 #if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
140 # define MSDOS
141 #endif
142
143 #if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
144 # define GETPID_IS_MEANINGLESS
145 #endif
146
147 #ifdef WIN32
148 #define get_last_sys_error() GetLastError()
149 #define clear_sys_error() SetLastError(0)
150 #if !defined(WINNT)
151 #define WIN_CONSOLE_BUG
152 #endif
153 #else
154 #define get_last_sys_error() errno
155 #define clear_sys_error() errno=0
156 #endif
157
158 #if defined(WINDOWS)
159 #define get_last_socket_error() WSAGetLastError()
160 #define clear_socket_error() WSASetLastError(0)
161 #define readsocket(s,b,n) recv((s),(b),(n),0)
162 #define writesocket(s,b,n) send((s),(b),(n),0)
163 #define EADDRINUSE WSAEADDRINUSE
164 #elif defined(__DJGPP__)
165 #define WATT32
166 #define get_last_socket_error() errno
167 #define clear_socket_error() errno=0
168 #define closesocket(s) close_s(s)
169 #define readsocket(s,b,n) read_s(s,b,n)
170 #define writesocket(s,b,n) send(s,b,n,0)
171 #elif defined(MAC_OS_pre_X)
172 #define get_last_socket_error() errno
173 #define clear_socket_error() errno=0
174 #define closesocket(s) MacSocket_close(s)
175 #define readsocket(s,b,n) MacSocket_recv((s),(b),(n),true)
176 #define writesocket(s,b,n) MacSocket_send((s),(b),(n))
177 #elif defined(OPENSSL_SYS_VMS)
178 #define get_last_socket_error() errno
179 #define clear_socket_error() errno=0
180 #define ioctlsocket(a,b,c) ioctl(a,b,c)
181 #define closesocket(s) close(s)
182 #define readsocket(s,b,n) recv((s),(b),(n),0)
183 #define writesocket(s,b,n) send((s),(b),(n),0)
184 #elif defined(OPENSSL_SYS_VXWORKS)
185 #define get_last_socket_error() errno
186 #define clear_socket_error() errno=0
187 #define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
188 #define closesocket(s) close(s)
189 #define readsocket(s,b,n) read((s),(b),(n))
190 #define writesocket(s,b,n) write((s),(char *)(b),(n))
191 #elif defined(OPENSSL_SYS_NETWARE)
192 #if defined(NETWARE_BSDSOCK)
193 #define get_last_socket_error() errno
194 #define clear_socket_error() errno=0
195 #define closesocket(s) close(s)
196 #define readsocket(s,b,n) recv((s),(b),(n),0)
197 #define writesocket(s,b,n) send((s),(b),(n),0)
198 #else
199 #define get_last_socket_error() WSAGetLastError()
200 #define clear_socket_error() WSASetLastError(0)
201 #define readsocket(s,b,n) recv((s),(b),(n),0)
202 #define writesocket(s,b,n) send((s),(b),(n),0)
203 #endif
204 #else
205 #define get_last_socket_error() errno
206 #define clear_socket_error() errno=0
207 #define ioctlsocket(a,b,c) ioctl(a,b,c)
208 #ifdef _BOOT
209 #include <socket_inet.h>
210 /*
211 * Due to a maze of nested #includes triggered by the above #include,
212 * _SC_CLK_TCK gets #defined, which the openssl code uses as a check
213 * to see if sysconf(_SC_CLK_TCK) should be used to determine the HZ
214 * of the machine. Since sysconf() is of course not available in the
215 * standalone environment, we #undef it. This sucks.
216 */
217 #undef _SC_CLK_TCK
218 #define closesocket(s) socket_close(s)
219 #define readsocket(s,b,n) socket_read((s),(b),(n), 200)
220 #define writesocket(s,b,n) send((s),(b),(n), 0)
221 #else /* !_BOOT */
222 #define closesocket(s) close(s)
223 #define readsocket(s,b,n) read((s),(b),(n))
224 #define writesocket(s,b,n) write((s),(b),(n))
225 #endif
226 #endif
227
228 #ifdef WIN16
229 # define MS_CALLBACK _far _loadds
230 # define MS_FAR _far
231 #else
232 # define MS_CALLBACK
233 # define MS_FAR
234 #endif
235
236 #ifdef OPENSSL_NO_STDIO
237 # undef OPENSSL_NO_FP_API
238 # define OPENSSL_NO_FP_API
239 #endif
240
241 #if (defined(WINDOWS) || defined(MSDOS))
242
243 # ifdef __DJGPP__
244 # include <unistd.h>
245 # include <sys/stat.h>
246 # include <sys/socket.h>
247 # include <tcp.h>
248 # include <netdb.h>
249 # define _setmode setmode
250 # define _O_TEXT O_TEXT
251 # define _O_BINARY O_BINARY
252 # undef DEVRANDOM
253 # define DEVRANDOM "/dev/urandom\x24"
254 # endif /* __DJGPP__ */
255
256 # ifndef S_IFDIR
257 # define S_IFDIR _S_IFDIR
258 # endif
259
260 # ifndef S_IFMT
261 # define S_IFMT _S_IFMT
262 # endif
263
264 # if !defined(WINNT) && !defined(__DJGPP__)
265 # define NO_SYSLOG
266 # endif
267 # define NO_DIRENT
268
269 # ifdef WINDOWS
270 # if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
271 /*
272 * Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
273 * Most notably we ought to check for availability of each specific
274 * routine with GetProcAddress() and/or quard NT-specific calls with
275 * GetVersion() < 0x80000000. One can argue that in latter "or" case
276 * we ought to /DELAYLOAD some .DLLs in order to protect ourselves
277 * against run-time link errors. This doesn't seem to be necessary,
278 * because it turned out that already Windows 95, first non-NT Win32
279 * implementation, is equipped with at least NT 3.51 stubs, dummy
280 * routines with same name, but which do nothing. Meaning that it's
281 * apparently appropriate to guard generic NT calls with GetVersion
282 * alone, while NT 4.0 and above calls ought to be additionally
283 * checked upon with GetProcAddress.
284 */
285 # define _WIN32_WINNT 0x0400
286 # endif
287 # include <windows.h>
288 # include <stddef.h>
289 # include <errno.h>
290 # include <string.h>
291 # ifdef _WIN64
292 # define strlen(s) _strlen31(s)
293 /* cut strings to 2GB */
_strlen31(const char * str)294 static unsigned int _strlen31(const char *str)
295 {
296 unsigned int len=0;
297 while (*str && len<0x80000000U) str++, len++;
298 return len&0x7FFFFFFF;
299 }
300 # endif
301 # include <malloc.h>
302 # endif
303 # include <io.h>
304 # include <fcntl.h>
305
306 # ifdef OPENSSL_SYS_WINCE
307 # include <winsock_extras.h>
308 # endif
309
310 # define ssize_t long
311
312 # if defined (__BORLANDC__)
313 # define _setmode setmode
314 # define _O_TEXT O_TEXT
315 # define _O_BINARY O_BINARY
316 # define _int64 __int64
317 # define _kbhit kbhit
318 # endif
319
320 # if defined(WIN16) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
321 # define EXIT(n) _wsetexit(_WINEXITNOPERSIST)
322 # define OPENSSL_EXIT(n) do { if (n == 0) EXIT(n); return(n); } while(0)
323 # else
324 # define EXIT(n) exit(n)
325 # endif
326 # define LIST_SEPARATOR_CHAR ';'
327 # ifndef X_OK
328 # define X_OK 0
329 # endif
330 # ifndef W_OK
331 # define W_OK 2
332 # endif
333 # ifndef R_OK
334 # define R_OK 4
335 # endif
336 # define OPENSSL_CONF "openssl.cnf"
337 # define SSLEAY_CONF OPENSSL_CONF
338 # define NUL_DEV "nul"
339 # define RFILE ".rnd"
340 # ifdef OPENSSL_SYS_WINCE
341 # define DEFAULT_HOME ""
342 # else
343 # define DEFAULT_HOME "C:"
344 # endif
345
346 #else /* The non-microsoft world world */
347
348 # ifdef OPENSSL_SYS_VMS
349 # define VMS 1
350 /* some programs don't include stdlib, so exit() and others give implicit
351 function warnings */
352 # include <stdlib.h>
353 # if defined(__DECC)
354 # include <unistd.h>
355 # else
356 # include <unixlib.h>
357 # endif
358 # define OPENSSL_CONF "openssl.cnf"
359 # define SSLEAY_CONF OPENSSL_CONF
360 # define RFILE ".rnd"
361 # define LIST_SEPARATOR_CHAR ','
362 # define NUL_DEV "NLA0:"
363 /* We don't have any well-defined random devices on VMS, yet... */
364 # undef DEVRANDOM
365 /* We need to do this since VMS has the following coding on status codes:
366
367 Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
368 The important thing to know is that odd numbers are considered
369 good, while even ones are considered errors.
370 Bits 3-15: actual status number
371 Bits 16-27: facility number. 0 is considered "unknown"
372 Bits 28-31: control bits. If bit 28 is set, the shell won't try to
373 output the message (which, for random codes, just looks ugly)
374
375 So, what we do here is to change 0 to 1 to get the default success status,
376 and everything else is shifted up to fit into the status number field, and
377 the status is tagged as an error, which I believe is what is wanted here.
378 -- Richard Levitte
379 */
380 # define EXIT(n) do { int __VMS_EXIT = n; \
381 if (__VMS_EXIT == 0) \
382 __VMS_EXIT = 1; \
383 else \
384 __VMS_EXIT = (n << 3) | 2; \
385 __VMS_EXIT |= 0x10000000; \
386 exit(__VMS_EXIT); } while(0)
387 # define NO_SYS_PARAM_H
388
389 # elif defined(OPENSSL_SYS_NETWARE)
390 # include <fcntl.h>
391 # include <unistd.h>
392 # define NO_SYS_TYPES_H
393 # undef DEVRANDOM
394 # ifdef NETWARE_CLIB
395 # define getpid GetThreadID
396 # endif
397 # define NO_SYSLOG
398 # define _setmode setmode
399 # define _kbhit kbhit
400 # define _O_TEXT O_TEXT
401 # define _O_BINARY O_BINARY
402 # define OPENSSL_CONF "openssl.cnf"
403 # define SSLEAY_CONF OPENSSL_CONF
404 # define RFILE ".rnd"
405 # define LIST_SEPARATOR_CHAR ';'
406 # define EXIT(n) { if (n) printf("ERROR: %d\n", (int)n); exit(n); }
407
408 # else
409 /* !defined VMS */
410 # ifdef OPENSSL_SYS_MPE
411 # define NO_SYS_PARAM_H
412 # endif
413 # ifdef OPENSSL_UNISTD
414 # include OPENSSL_UNISTD
415 # else
416 # include <unistd.h>
417 # endif
418 # ifndef NO_SYS_TYPES_H
419 # include <sys/types.h>
420 # endif
421 # if defined(NeXT) || defined(OPENSSL_SYS_NEWS4)
422 # define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP
423 * (unless when compiling with -D_POSIX_SOURCE,
424 * which doesn't work for us) */
425 # endif
426 # if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)
427 # define ssize_t int /* ditto */
428 # endif
429 # ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */
430 # define setvbuf(a, b, c, d) setbuffer((a), (b), (d))
431 typedef unsigned long clock_t;
432 # endif
433
434 # define OPENSSL_CONF "openssl.cnf"
435 # define SSLEAY_CONF OPENSSL_CONF
436 # define RFILE ".rnd"
437 # define LIST_SEPARATOR_CHAR ':'
438 # define NUL_DEV "/dev/null"
439 # define EXIT(n) exit(n)
440 # endif
441
442 # define SSLeay_getpid() getpid()
443
444 #endif
445
446
447 /*************/
448
449 #ifdef USE_SOCKETS
450 # if defined(WINDOWS) || defined(MSDOS)
451 /* windows world */
452
453 # ifdef OPENSSL_NO_SOCK
454 # define SSLeay_Write(a,b,c) (-1)
455 # define SSLeay_Read(a,b,c) (-1)
456 # define SHUTDOWN(fd) close(fd)
457 # define SHUTDOWN2(fd) close(fd)
458 # elif !defined(__DJGPP__)
459 # include <winsock.h>
460 extern HINSTANCE _hInstance;
461 # ifdef _WIN64
462 /*
463 * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
464 * the value constitutes an index in per-process table of limited size
465 * and not a real pointer.
466 */
467 # define socket(d,t,p) ((int)socket(d,t,p))
468 # define accept(s,f,l) ((int)accept(s,f,l))
469 # endif
470 # define SSLeay_Write(a,b,c) send((a),(b),(c),0)
471 # define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
472 # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
473 # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
474 # else
475 # define SSLeay_Write(a,b,c) write_s(a,b,c,0)
476 # define SSLeay_Read(a,b,c) read_s(a,b,c)
477 # define SHUTDOWN(fd) close_s(fd)
478 # define SHUTDOWN2(fd) close_s(fd)
479 # endif
480
481 # elif defined(MAC_OS_pre_X)
482
483 # include "MacSocket.h"
484 # define SSLeay_Write(a,b,c) MacSocket_send((a),(b),(c))
485 # define SSLeay_Read(a,b,c) MacSocket_recv((a),(b),(c),true)
486 # define SHUTDOWN(fd) MacSocket_close(fd)
487 # define SHUTDOWN2(fd) MacSocket_close(fd)
488
489 # elif defined(OPENSSL_SYS_NETWARE)
490 /* NetWare uses the WinSock2 interfaces by default, but can be configured for BSD
491 */
492 # if defined(NETWARE_BSDSOCK)
493 # include <sys/socket.h>
494 # include <netinet/in.h>
495 # include <sys/time.h>
496 # include <sys/select.h>
497 # define INVALID_SOCKET (int)(~0)
498 # else
499 # include <novsock2.h>
500 # endif
501 # define SSLeay_Write(a,b,c) send((a),(b),(c),0)
502 # define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
503 # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
504 # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
505
506 # else
507
508 # ifndef NO_SYS_PARAM_H
509 # include <sys/param.h>
510 # endif
511 # ifdef OPENSSL_SYS_VXWORKS
512 # include <time.h>
513 # elif !defined(OPENSSL_SYS_MPE)
514 # include <sys/time.h> /* Needed under linux for FD_XXX */
515 # endif
516
517 # include <netdb.h>
518 # if defined(OPENSSL_SYS_VMS_NODECC)
519 # include <socket.h>
520 # include <in.h>
521 # include <inet.h>
522 # else
523 # include <sys/socket.h>
524 # ifdef FILIO_H
525 # include <sys/filio.h> /* Added for FIONBIO under unixware */
526 # endif
527 # include <netinet/in.h>
528 # include <arpa/inet.h>
529 # endif
530
531 # if defined(NeXT) || defined(_NEXT_SOURCE)
532 # include <sys/fcntl.h>
533 # include <sys/types.h>
534 # endif
535
536 # ifdef OPENSSL_SYS_AIX
537 # include <sys/select.h>
538 # endif
539
540 # ifdef __QNX__
541 # include <sys/select.h>
542 # endif
543
544 # if defined(sun)
545 # include <sys/filio.h>
546 # else
547 # ifndef VMS
548 # include <sys/ioctl.h>
549 # else
550 /* ioctl is only in VMS > 7.0 and when socketshr is not used */
551 # if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
552 # include <sys/ioctl.h>
553 # endif
554 # endif
555 # endif
556
557 # ifdef VMS
558 # include <unixio.h>
559 # if defined(TCPIP_TYPE_SOCKETSHR)
560 # include <socketshr.h>
561 # endif
562 # endif
563
564 # define SSLeay_Read(a,b,c) read((a),(b),(c))
565 # define SSLeay_Write(a,b,c) write((a),(b),(c))
566 # define SHUTDOWN(fd) { shutdown((fd),0); closesocket((fd)); }
567 # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket((fd)); }
568 # ifndef INVALID_SOCKET
569 # define INVALID_SOCKET (-1)
570 # endif /* INVALID_SOCKET */
571 # endif
572 #endif
573
574 #if defined(__ultrix)
575 # ifndef ssize_t
576 # define ssize_t int
577 # endif
578 #endif
579
580 #if defined(sun) && !defined(__svr4__) && !defined(__SVR4)
581 /* include headers first, so our defines don't break it */
582 #include <stdlib.h>
583 #include <string.h>
584 /* bcopy can handle overlapping moves according to SunOS 4.1.4 manpage */
585 # define memmove(s1,s2,n) bcopy((s2),(s1),(n))
586 # define strtoul(s,e,b) ((unsigned long int)strtol((s),(e),(b)))
587 extern char *sys_errlist[]; extern int sys_nerr;
588 # define strerror(errnum) \
589 (((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum])
590 /* Being signed SunOS 4.x memcpy breaks ASN1_OBJECT table lookup */
591 #include "crypto/o_str.h"
592 # define memcmp OPENSSL_memcmp
593 #endif
594
595 #ifndef OPENSSL_EXIT
596 # if defined(MONOLITH) && !defined(OPENSSL_C)
597 # define OPENSSL_EXIT(n) return(n)
598 # else
599 # define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
600 # endif
601 #endif
602
603 /***********************************************/
604
605 /* do we need to do this for getenv.
606 * Just define getenv for use under windows */
607
608 #ifdef WIN16
609 /* How to do this needs to be thought out a bit more.... */
610 /*char *GETENV(char *);
611 #define Getenv GETENV*/
612 #define Getenv getenv
613 #else
614 #define Getenv getenv
615 #endif
616
617 #define DG_GCC_BUG /* gcc < 2.6.3 on DGUX */
618
619 #ifdef sgi
620 #define IRIX_CC_BUG /* all version of IRIX I've tested (4.* 5.*) */
621 #endif
622 #ifdef OPENSSL_SYS_SNI
623 #define IRIX_CC_BUG /* CDS++ up to V2.0Bsomething suffered from the same bug.*/
624 #endif
625
626 #if defined(OPENSSL_SYS_WINDOWS)
627 # define strcasecmp _stricmp
628 # define strncasecmp _strnicmp
629 #elif defined(OPENSSL_SYS_VMS)
630 /* VMS below version 7.0 doesn't have strcasecmp() */
631 # include "o_str.h"
632 # define strcasecmp OPENSSL_strcasecmp
633 # define strncasecmp OPENSSL_strncasecmp
634 # define OPENSSL_IMPLEMENTS_strncasecmp
635 #elif defined(OPENSSL_SYS_OS2) && defined(__EMX__)
636 # define strcasecmp stricmp
637 # define strncasecmp strnicmp
638 #elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
639 # define strcasecmp stricmp
640 # define strncasecmp strnicmp
641 #else
642 # ifdef NO_STRINGS_H
643 int strcasecmp();
644 int strncasecmp();
645 # else
646 # include <strings.h>
647 # endif /* NO_STRINGS_H */
648 #endif
649
650 #if defined(OPENSSL_SYS_OS2) && defined(__EMX__)
651 # include <io.h>
652 # include <fcntl.h>
653 # define NO_SYSLOG
654 #endif
655
656 /* vxworks */
657 #if defined(OPENSSL_SYS_VXWORKS)
658 #include <ioLib.h>
659 #include <tickLib.h>
660 #include <sysLib.h>
661
662 #define TTY_STRUCT int
663
664 #define sleep(a) taskDelay((a) * sysClkRateGet())
665
666 #include <vxWorks.h>
667 #include <sockLib.h>
668 #include <taskLib.h>
669
670 #define getpid taskIdSelf
671
672 /* NOTE: these are implemented by helpers in database app!
673 * if the database is not linked, we need to implement them
674 * elswhere */
675 struct hostent *gethostbyname(const char *name);
676 struct hostent *gethostbyaddr(const char *addr, int length, int type);
677 struct servent *getservbyname(const char *name, const char *proto);
678
679 #endif
680 /* end vxworks */
681
682 #ifdef __cplusplus
683 }
684 #endif
685
686 #endif
687
688