]>
git.saurik.com Git - apple/security.git/blob - Security/libsecurity_apple_csp/open_ssl/openssl/e_os.h
2 * Copyright (c) 2000-2001,2011,2014 Apple Inc. All Rights Reserved.
4 * The contents of this file constitute Original Code as defined in and are
5 * subject to the Apple Public Source License Version 1.2 (the 'License').
6 * You may not use this file except in compliance with the License. Please obtain
7 * a copy of the License at http://www.apple.com/publicsource and read it before
10 * This Original Code and all software distributed under the License are
11 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS
12 * OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, INCLUDING WITHOUT
13 * LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
14 * PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. Please see the License for the
15 * specific language governing rights and limitations under the License.
20 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
21 * All rights reserved.
23 * This package is an SSL implementation written
24 * by Eric Young (eay@cryptsoft.com).
25 * The implementation was written so as to conform with Netscapes SSL.
27 * This library is free for commercial and non-commercial use as long as
28 * the following conditions are aheared to. The following conditions
29 * apply to all code found in this distribution, be it the RC4, RSA,
30 * lhash, DES, etc., code; not just the SSL code. The SSL documentation
31 * included with this distribution is covered by the same copyright terms
32 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
34 * Copyright remains Eric Young's, and as such any Copyright notices in
35 * the code are not to be removed.
36 * If this package is used in a product, Eric Young should be given attribution
37 * as the author of the parts of the library used.
38 * This can be in the form of a textual message at program startup or
39 * in documentation (online or textual) provided with the package.
41 * Redistribution and use in source and binary forms, with or without
42 * modification, are permitted provided that the following conditions
44 * 1. Redistributions of source code must retain the copyright
45 * notice, this list of conditions and the following disclaimer.
46 * 2. Redistributions in binary form must reproduce the above copyright
47 * notice, this list of conditions and the following disclaimer in the
48 * documentation and/or other materials provided with the distribution.
49 * 3. All advertising materials mentioning features or use of this software
50 * must display the following acknowledgement:
51 * "This product includes cryptographic software written by
52 * Eric Young (eay@cryptsoft.com)"
53 * The word 'cryptographic' can be left out if the rouines from the library
54 * being used are not cryptographic related :-).
55 * 4. If you include any Windows specific code (or a derivative thereof) from
56 * the apps directory (application code) you must include an acknowledgement:
57 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
59 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
60 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
61 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
62 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
63 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
64 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
65 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
66 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
67 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
68 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
71 * The licence and distribution terms for any publically available version or
72 * derivative of this code cannot be changed. i.e. this code cannot simply be
73 * copied and put under another distribution licence
74 * [including the GNU Public Licence.]
80 #include <openssl/opensslconf.h>
82 #include <openssl/e_os2.h>
83 /* <openssl/e_os2.h> contains what we can justify to make visible
84 * to the outside; this file e_os.h is not part of the exported
91 /* Used to checking reference counts, most while doing perl5 stuff :-) */
94 #define REF_PRINT(a,b) fprintf(stderr,"%08X:%4d:%s\n",(int)b,b->references,a)
98 /* set this to your 'random' device if you have one.
99 * My default, we will try to read this file */
100 #define DEVRANDOM "/dev/urandom"
103 #if defined(__MWERKS__) && defined(macintosh)
105 # ifndef MAC_OS_GUSI_SOURCE
106 # define MAC_OS_pre_X
107 # define NO_SYS_TYPES_H
109 # define NO_SYS_PARAM_H
113 # define GETPID_IS_MEANINGLESS
117 /********************************************************************
118 The Microsoft section
119 ********************************************************************/
120 /* The following is used becaue of the small stack in some
121 * Microsoft operating systems */
122 #if defined(WIN16) || defined(MSDOS)
123 # define MS_STATIC static
128 #if defined(_WIN32) && !defined(WIN32)
132 #if defined(WIN32) || defined(WIN16)
141 #if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
142 # define GETPID_IS_MEANINGLESS
146 #define get_last_sys_error() GetLastError()
147 #define clear_sys_error() SetLastError(0)
149 #define WIN_CONSOLE_BUG
152 #define get_last_sys_error() errno
153 #define clear_sys_error() errno=0
157 #define get_last_socket_error() WSAGetLastError()
158 #define clear_socket_error() WSASetLastError(0)
159 #define readsocket(s,b,n) recv((s),(b),(n),0)
160 #define writesocket(s,b,n) send((s),(b),(n),0)
161 #define EADDRINUSE WSAEADDRINUSE
162 #elif defined(MAC_OS_pre_X)
163 #define get_last_socket_error() errno
164 #define clear_socket_error() errno=0
165 #define closesocket(s) MacSocket_close(s)
166 #define readsocket(s,b,n) MacSocket_recv((s),(b),(n),true)
167 #define writesocket(s,b,n) MacSocket_send((s),(b),(n))
169 #define get_last_socket_error() errno
170 #define clear_socket_error() errno=0
171 #define ioctlsocket(a,b,c) ioctl(a,b,c)
172 #define closesocket(s) close(s)
173 #define readsocket(s,b,n) read((s),(b),(n))
174 #define writesocket(s,b,n) write((s),(b),(n))
179 # define MS_CALLBACK _far _loadds
190 #if defined(WINDOWS) || defined(MSDOS)
193 # define S_IFDIR _S_IFDIR
197 # define S_IFMT _S_IFMT
206 # include <windows.h>
215 # define ssize_t long
217 # if defined (__BORLANDC__)
218 # define _setmode setmode
219 # define _O_TEXT O_TEXT
220 # define _O_BINARY O_BINARY
221 # define _int64 __int64
222 # define _kbhit kbhit
225 # if defined(WIN16) && !defined(MONOLITH) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
226 # define EXIT(n) { if (n == 0) _wsetexit(_WINEXITNOPERSIST); return(n); }
228 # define EXIT(n) return(n);
230 # define LIST_SEPARATOR_CHAR ';'
240 # define OPENSSL_CONF "openssl.cnf"
241 # define SSLEAY_CONF OPENSSL_CONF
242 # define NUL_DEV "nul"
243 # define RFILE ".rnd"
245 #else /* The non-microsoft world world */
247 # if defined(__VMS) && !defined(VMS)
252 /* some programs don't include stdlib, so exit() and others give implicit
258 # include <unixlib.h>
260 # define OPENSSL_CONF "openssl.cnf"
261 # define SSLEAY_CONF OPENSSL_CONF
262 # define RFILE ".rnd"
263 # define LIST_SEPARATOR_CHAR ','
264 # define NUL_DEV "NLA0:"
265 /* We need to do this since VMS has the following coding on status codes:
267 Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
268 The important thing to know is that odd numbers are considered
269 good, while even ones are considered errors.
270 Bits 3-15: actual status number
271 Bits 16-27: facility number. 0 is considered "unknown"
272 Bits 28-31: control bits. If bit 28 is set, the shell won't try to
273 output the message (which, for random codes, just looks ugly)
275 So, what we do here is to change 0 to 1 to get the default success status,
276 and everything else is shifted up to fit into the status number field, and
277 the status is tagged as an error, which I believe is what is wanted here.
280 # if !defined(MONOLITH) || defined(OPENSSL_C)
281 # define EXIT(n) do { int __VMS_EXIT = n; \
282 if (__VMS_EXIT == 0) \
285 __VMS_EXIT = (n << 3) | 2; \
286 __VMS_EXIT |= 0x10000000; \
288 return(__VMS_EXIT); } while(0)
290 # define EXIT(n) return(n)
292 # define NO_SYS_PARAM_H
295 # ifdef OPENSSL_UNISTD
296 # include OPENSSL_UNISTD
300 # ifndef NO_SYS_TYPES_H
301 # include <sys/types.h>
304 # define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP
305 * (unless when compiling with -D_POSIX_SOURCE,
306 * which doesn't work for us) */
307 # define ssize_t int /* ditto */
310 # define OPENSSL_CONF "openssl.cnf"
311 # define SSLEAY_CONF OPENSSL_CONF
312 # define RFILE ".rnd"
313 # define LIST_SEPARATOR_CHAR ':'
314 # define NUL_DEV "/dev/null"
316 # define EXIT(n) exit(n); return(n)
318 # define EXIT(n) return(n)
322 # define SSLeay_getpid() getpid()
330 # if defined(WINDOWS) || defined(MSDOS)
334 # define SSLeay_Write(a,b,c) (-1)
335 # define SSLeay_Read(a,b,c) (-1)
336 # define SHUTDOWN(fd) close(fd)
337 # define SHUTDOWN2(fd) close(fd)
339 # include <winsock.h>
340 extern HINSTANCE _hInstance
;
341 # define SSLeay_Write(a,b,c) send((a),(b),(c),0)
342 # define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
343 # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
344 # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
347 # elif defined(MAC_OS_pre_X)
349 # include "MacSocket.h"
350 # define SSLeay_Write(a,b,c) MacSocket_send((a),(b),(c))
351 # define SSLeay_Read(a,b,c) MacSocket_recv((a),(b),(c),true)
352 # define SHUTDOWN(fd) MacSocket_close(fd)
353 # define SHUTDOWN2(fd) MacSocket_close(fd)
357 # ifndef NO_SYS_PARAM_H
358 # include <sys/param.h>
360 # include <sys/time.h> /* Needed under linux for FD_XXX */
363 # if defined(VMS) && !defined(__DECC)
367 # include <sys/socket.h>
369 # include <sys/filio.h> /* Added for FIONBIO under unixware */
371 # include <netinet/in.h>
374 # if defined(NeXT) || defined(_NEXT_SOURCE)
375 # include <sys/fcntl.h>
376 # include <sys/types.h>
380 # include <sys/select.h>
384 # include <sys/filio.h>
387 # include <sys/ioctl.h>
389 /* ioctl is only in VMS > 7.0 and when socketshr is not used */
390 # if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
391 # include <sys/ioctl.h>
398 # if defined(TCPIP_TYPE_SOCKETSHR)
399 # include <socketshr.h>
403 # define SSLeay_Read(a,b,c) read((a),(b),(c))
404 # define SSLeay_Write(a,b,c) write((a),(b),(c))
405 # define SHUTDOWN(fd) { shutdown((fd),0); closesocket((fd)); }
406 # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket((fd)); }
407 # define INVALID_SOCKET (-1)
411 #if defined(__ultrix)
417 #if defined(THREADS) || defined(sun)
423 /***********************************************/
425 /* do we need to do this for getenv.
426 * Just define getenv for use under windows */
429 /* How to do this needs to be thought out a bit more.... */
430 /*char *GETENV(char *);
431 #define Getenv GETENV*/
432 #define Getenv getenv
434 #define Getenv getenv
437 #define DG_GCC_BUG /* gcc < 2.6.3 on DGUX */
440 #define IRIX_CC_BUG /* all version of IRIX I've tested (4.* 5.*) */
443 #define IRIX_CC_BUG /* CDS++ up to V2.0Bsomething suffered from the same bug.*/
447 #define MD2_Init MD2Init
448 #define MD2_Update MD2Update
449 #define MD2_Final MD2Final
450 #define MD2_DIGEST_LENGTH 16
453 #define MD5_Init MD5Init
454 #define MD5_Update MD5Update
455 #define MD5_Final MD5Final
456 #define MD5_DIGEST_LENGTH 16