1656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* e_os.h */
2656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
3656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * All rights reserved.
4656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
5656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * This package is an SSL implementation written
6656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * by Eric Young (eay@cryptsoft.com).
7656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * The implementation was written so as to conform with Netscapes SSL.
8656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
9656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * This library is free for commercial and non-commercial use as long as
10656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * the following conditions are aheared to.  The following conditions
11656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * apply to all code found in this distribution, be it the RC4, RSA,
12656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
13656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * included with this distribution is covered by the same copyright terms
14656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * except that the holder is Tim Hudson (tjh@cryptsoft.com).
15656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
16656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Copyright remains Eric Young's, and as such any Copyright notices in
17656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * the code are not to be removed.
18656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * If this package is used in a product, Eric Young should be given attribution
19656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * as the author of the parts of the library used.
20656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * This can be in the form of a textual message at program startup or
21656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * in documentation (online or textual) provided with the package.
22656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
23656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Redistribution and use in source and binary forms, with or without
24656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * modification, are permitted provided that the following conditions
25656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * are met:
26656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 1. Redistributions of source code must retain the copyright
27656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    notice, this list of conditions and the following disclaimer.
28656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 2. Redistributions in binary form must reproduce the above copyright
29656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    notice, this list of conditions and the following disclaimer in the
30656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    documentation and/or other materials provided with the distribution.
31656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 3. All advertising materials mentioning features or use of this software
32656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    must display the following acknowledgement:
33656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    "This product includes cryptographic software written by
34656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *     Eric Young (eay@cryptsoft.com)"
35656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    The word 'cryptographic' can be left out if the rouines from the library
36656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    being used are not cryptographic related :-).
37656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * 4. If you include any Windows specific code (or a derivative thereof) from
38656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    the apps directory (application code) you must include an acknowledgement:
39656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
40656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
41656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
42656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
43656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
44656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
45656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
46656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
47656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
48656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
49656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
50656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * SUCH DAMAGE.
52656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project *
53656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * The licence and distribution terms for any publically available version or
54656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * derivative of this code cannot be changed.  i.e. this code cannot simply be
55656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * copied and put under another distribution licence
56656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * [including the GNU Public Licence.]
57656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project */
58656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
59656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef HEADER_E_OS_H
60656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define HEADER_E_OS_H
61656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
62656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <openssl/opensslconf.h>
63656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
64656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <openssl/e_os2.h>
65656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* <openssl/e_os2.h> contains what we can justify to make visible
66656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * to the outside; this file e_os.h is not part of the exported
67656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * interface. */
68656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
69656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef  __cplusplus
70656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectextern "C" {
71656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
72656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
73656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* Used to checking reference counts, most while doing perl5 stuff :-) */
74656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef REF_PRINT
75656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#undef REF_PRINT
76656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define REF_PRINT(a,b)	fprintf(stderr,"%08X:%4d:%s\n",(int)b,b->references,a)
77656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
78656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
79656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef DEVRANDOM
80656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* set this to a comma-separated list of 'random' device files to try out.
81656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * My default, we will try to read at least one of these files */
82656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom"
83656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
84656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef DEVRANDOM_EGD
85656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* set this to a comma-seperated list of 'egd' sockets to try out. These
86656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * sockets will be tried in the order listed in case accessing the device files
87656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * listed in DEVRANDOM did not return enough entropy. */
88656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"
89656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
90656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
91656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(OPENSSL_SYS_VXWORKS)
92656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define NO_SYS_PARAM_H
93656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define NO_CHMOD
94656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define NO_SYSLOG
95656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
96656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
97656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
98656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# if macintosh==1
99656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  ifndef MAC_OS_GUSI_SOURCE
100656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define MAC_OS_pre_X
101656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define NO_SYS_TYPES_H
102656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
103656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define NO_SYS_PARAM_H
104656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define NO_CHMOD
105656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define NO_SYSLOG
106656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  undef  DEVRANDOM
107656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define GETPID_IS_MEANINGLESS
108656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# endif
109656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
110656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
111656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/********************************************************************
112656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project The Microsoft section
113656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project ********************************************************************/
114221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/* The following is used because of the small stack in some
115656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Microsoft operating systems */
116656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYSNAME_WIN32)
117656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define MS_STATIC	static
118656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#else
119656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define MS_STATIC
120656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
121656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
122656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
123656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define WIN32
124656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
125656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
126656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define WINDOWS
127656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
128656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
129656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define MSDOS
130656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
131656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
132656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
133656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define GETPID_IS_MEANINGLESS
134656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
135656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
136656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef WIN32
137656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define get_last_sys_error()	GetLastError()
138656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define clear_sys_error()	SetLastError(0)
139656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if !defined(WINNT)
140656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define WIN_CONSOLE_BUG
141656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
142656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#else
143656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define get_last_sys_error()	errno
144656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define clear_sys_error()	errno=0
145656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
146656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
147656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(WINDOWS)
148656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define get_last_socket_error()	WSAGetLastError()
149656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define clear_socket_error()	WSASetLastError(0)
150656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define readsocket(s,b,n)	recv((s),(b),(n),0)
151656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define writesocket(s,b,n)	send((s),(b),(n),0)
152656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#elif defined(__DJGPP__)
153656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define WATT32
154656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define get_last_socket_error()	errno
155656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define clear_socket_error()	errno=0
156656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define closesocket(s)		close_s(s)
157656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define readsocket(s,b,n)	read_s(s,b,n)
158656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define writesocket(s,b,n)	send(s,b,n,0)
159656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#elif defined(MAC_OS_pre_X)
160656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define get_last_socket_error()	errno
161656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define clear_socket_error()	errno=0
162656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define closesocket(s)		MacSocket_close(s)
163656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define readsocket(s,b,n)	MacSocket_recv((s),(b),(n),true)
164656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define writesocket(s,b,n)	MacSocket_send((s),(b),(n))
165656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#elif defined(OPENSSL_SYS_VMS)
166656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define get_last_socket_error() errno
167656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define clear_socket_error()    errno=0
168656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define ioctlsocket(a,b,c)      ioctl(a,b,c)
169656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define closesocket(s)          close(s)
170656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define readsocket(s,b,n)       recv((s),(b),(n),0)
171656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define writesocket(s,b,n)      send((s),(b),(n),0)
172656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#elif defined(OPENSSL_SYS_VXWORKS)
173656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define get_last_socket_error()	errno
174656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define clear_socket_error()	errno=0
175656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define ioctlsocket(a,b,c)	    ioctl((a),(b),(int)(c))
176656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define closesocket(s)		    close(s)
177656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define readsocket(s,b,n)	    read((s),(b),(n))
178656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define writesocket(s,b,n)	    write((s),(char *)(b),(n))
179221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#elif defined(OPENSSL_SYS_BEOS_R5)
180221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define get_last_socket_error() errno
181221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define clear_socket_error()    errno=0
182221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define FIONBIO SO_NONBLOCK
183221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define ioctlsocket(a,b,c)		  setsockopt((a),SOL_SOCKET,(b),(c),sizeof(*(c)))
184221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define readsocket(s,b,n)       recv((s),(b),(n),0)
185221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#define writesocket(s,b,n)      send((s),(b),(n),0)
186656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#elif defined(OPENSSL_SYS_NETWARE)
187656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(NETWARE_BSDSOCK)
188656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define get_last_socket_error() errno
189656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define clear_socket_error()    errno=0
190656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define closesocket(s)          close(s)
191656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define ioctlsocket(a,b,c)      ioctl(a,b,c)
192656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(NETWARE_LIBC)
193656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define readsocket(s,b,n)       recv((s),(b),(n),0)
194656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define writesocket(s,b,n)      send((s),(b),(n),0)
195656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#else
196656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define readsocket(s,b,n)       recv((s),(char*)(b),(n),0)
197656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define writesocket(s,b,n)      send((s),(char*)(b),(n),0)
198656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
199656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#else
200656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define get_last_socket_error()	WSAGetLastError()
201656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define clear_socket_error()	WSASetLastError(0)
202656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define readsocket(s,b,n)		recv((s),(b),(n),0)
203656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define writesocket(s,b,n)		send((s),(b),(n),0)
204656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
205656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#else
206656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define get_last_socket_error()	errno
207656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define clear_socket_error()	errno=0
208656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define ioctlsocket(a,b,c)	ioctl(a,b,c)
209656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define closesocket(s)		close(s)
210656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define readsocket(s,b,n)	read((s),(b),(n))
211656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define writesocket(s,b,n)	write((s),(b),(n))
212656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
213656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
214221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#ifdef WIN16 /* never the case */
215656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define MS_CALLBACK	_far _loadds
216656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define MS_FAR	_far
217656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#else
218656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define MS_CALLBACK
219656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define MS_FAR
220656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
221656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
222656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef OPENSSL_NO_STDIO
223656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  undef OPENSSL_NO_FP_API
224656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define OPENSSL_NO_FP_API
225656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
226656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
227656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if (defined(WINDOWS) || defined(MSDOS))
228656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
229656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  ifdef __DJGPP__
230656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <unistd.h>
231656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <sys/stat.h>
232656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <sys/socket.h>
233656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <tcp.h>
234656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <netdb.h>
235656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define _setmode setmode
236656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define _O_TEXT O_TEXT
237656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define _O_BINARY O_BINARY
238656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    undef DEVRANDOM
239656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define DEVRANDOM "/dev/urandom\x24"
240656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif /* __DJGPP__ */
241656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
242656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  ifndef S_IFDIR
243656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define S_IFDIR	_S_IFDIR
244656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
245656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
246656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  ifndef S_IFMT
247656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define S_IFMT	_S_IFMT
248656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
249656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
250656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  if !defined(WINNT) && !defined(__DJGPP__)
251656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define NO_SYSLOG
252656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
253656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define NO_DIRENT
254656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
255656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  ifdef WINDOWS
256656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
257656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project       /*
258656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	* Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
259656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	* Most notably we ought to check for availability of each specific
260221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	* routine with GetProcAddress() and/or guard NT-specific calls with
261656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	* GetVersion() < 0x80000000. One can argue that in latter "or" case
262656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	* we ought to /DELAYLOAD some .DLLs in order to protect ourselves
263656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	* against run-time link errors. This doesn't seem to be necessary,
264656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	* because it turned out that already Windows 95, first non-NT Win32
265656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	* implementation, is equipped with at least NT 3.51 stubs, dummy
266656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	* routines with same name, but which do nothing. Meaning that it's
267221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	* apparently sufficient to guard "vanilla" NT calls with GetVersion
268221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	* alone, while NT 4.0 and above interfaces ought to be linked with
269221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	* GetProcAddress at run-time.
270656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	*/
271656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define _WIN32_WINNT 0x0400
272656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
273221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#    if !defined(OPENSSL_NO_SOCK) && defined(_WIN32_WINNT)
274221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom       /*
275221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom        * Just like defining _WIN32_WINNT including winsock2.h implies
276221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom        * certain "discipline" for maintaining [broad] binary compatibility.
277221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom        * As long as structures are invariant among Winsock versions,
278221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom        * it's sufficient to check for specific Winsock2 API availability
279221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom        * at run-time [DSO_global_lookup is recommended]...
280221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom        */
281221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      include <winsock2.h>
282221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      include <ws2tcpip.h>
283221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom       /* yes, they have to be #included prior to <windows.h> */
284221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#    endif
285656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <windows.h>
286e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#    include <stdio.h>
287656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <stddef.h>
288656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <errno.h>
289656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <string.h>
290656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifdef _WIN64
291656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define strlen(s) _strlen31(s)
292656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* cut strings to 2GB */
293656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectstatic unsigned int _strlen31(const char *str)
294656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	{
295656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	unsigned int len=0;
296656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	while (*str && len<0x80000000U) str++, len++;
297656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	return len&0x7FFFFFFF;
298656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	}
299656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
300656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <malloc.h>
301656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    if defined(_MSC_VER) && _MSC_VER<=1200 && defined(_MT) && defined(isspace)
302e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu       /* compensate for bug in VC6 ctype.h */
303656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      undef isspace
304656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      undef isdigit
305656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      undef isalnum
306656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      undef isupper
307656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      undef isxdigit
308656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
309e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#    if defined(_MSC_VER) && !defined(_DLL) && defined(stdin)
310e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#      if _MSC_VER>=1300
311e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#        undef stdin
312e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#        undef stdout
313e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#        undef stderr
314e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu         FILE *__iob_func();
315e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#        define stdin  (&__iob_func()[0])
316e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#        define stdout (&__iob_func()[1])
317e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#        define stderr (&__iob_func()[2])
318e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#      elif defined(I_CAN_LIVE_WITH_LNK4049)
319e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#        undef stdin
320e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#        undef stdout
321e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#        undef stderr
322e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu         /* pre-1300 has __p__iob(), but it's available only in msvcrt.lib,
323e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu          * or in other words with /MD. Declaring implicit import, i.e.
324e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu          * with _imp_ prefix, works correctly with all compiler options,
325221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	  * but without /MD results in LINK warning LNK4049:
326221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom	  * 'locally defined symbol "__iob" imported'.
327e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu          */
328e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu         extern FILE *_imp___iob;
329e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#        define stdin  (&_imp___iob[0])
330e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#        define stdout (&_imp___iob[1])
331e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#        define stderr (&_imp___iob[2])
332e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#      endif
333e45f106cb6b47af1f21efe76e933bdea2f5dd1caNagendra Modadugu#    endif
334656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
335656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  include <io.h>
336656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  include <fcntl.h>
337656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
338656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  ifdef OPENSSL_SYS_WINCE
339221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#    define OPENSSL_NO_POSIX_IO
340656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
341656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
342656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  if defined (__BORLANDC__)
343656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define _setmode setmode
344656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define _O_TEXT O_TEXT
345656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define _O_BINARY O_BINARY
346656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define _int64 __int64
347656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define _kbhit kbhit
348656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
349656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
350221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#  define EXIT(n) exit(n)
351656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define LIST_SEPARATOR_CHAR ';'
352656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  ifndef X_OK
353656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define X_OK	0
354656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
355656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  ifndef W_OK
356656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define W_OK	2
357656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
358656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  ifndef R_OK
359656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define R_OK	4
360656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
361656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define OPENSSL_CONF	"openssl.cnf"
362656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define SSLEAY_CONF	OPENSSL_CONF
363656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define NUL_DEV	"nul"
364656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define RFILE		".rnd"
365656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  ifdef OPENSSL_SYS_WINCE
366656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define DEFAULT_HOME  ""
367656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  else
368656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define DEFAULT_HOME  "C:"
369656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
370656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
3717f7ea2d72f2e316ba518e82f06513e3477840c15Kenny Root/* Avoid Windows 8 SDK GetVersion deprecated problems */
3727f7ea2d72f2e316ba518e82f06513e3477840c15Kenny Root#if defined(_MSC_VER) && _MSC_VER>=1800
3737f7ea2d72f2e316ba518e82f06513e3477840c15Kenny Root#  define check_winnt() (1)
3747f7ea2d72f2e316ba518e82f06513e3477840c15Kenny Root#else
3757f7ea2d72f2e316ba518e82f06513e3477840c15Kenny Root#  define check_winnt() (GetVersion() < 0x80000000)
376c64f6fe2be99cb3fa8e491b5bede9a217de87a4cKenny Root#endif
377c64f6fe2be99cb3fa8e491b5bede9a217de87a4cKenny Root
378c64f6fe2be99cb3fa8e491b5bede9a217de87a4cKenny Root/*
379c64f6fe2be99cb3fa8e491b5bede9a217de87a4cKenny Root * Visual Studio: inline is available in C++ only, however
380c64f6fe2be99cb3fa8e491b5bede9a217de87a4cKenny Root * __inline is available for C, see
381c64f6fe2be99cb3fa8e491b5bede9a217de87a4cKenny Root * http://msdn.microsoft.com/en-us/library/z8y1yy88.aspx
382c64f6fe2be99cb3fa8e491b5bede9a217de87a4cKenny Root */
383c64f6fe2be99cb3fa8e491b5bede9a217de87a4cKenny Root#if defined(_MSC_VER) && !defined(__cplusplus) && !defined(inline)
384c64f6fe2be99cb3fa8e491b5bede9a217de87a4cKenny Root#  define inline __inline
385c64f6fe2be99cb3fa8e491b5bede9a217de87a4cKenny Root#endif
3867f7ea2d72f2e316ba518e82f06513e3477840c15Kenny Root
387221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#else /* The non-microsoft world */
388656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
389656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  ifdef OPENSSL_SYS_VMS
390656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define VMS 1
391656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project  /* some programs don't include stdlib, so exit() and others give implicit
392656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project     function warnings */
393656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <stdlib.h>
394656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    if defined(__DECC)
395656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <unistd.h>
396656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    else
397656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <unixlib.h>
398656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
399656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define OPENSSL_CONF	"openssl.cnf"
400656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define SSLEAY_CONF		OPENSSL_CONF
401656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define RFILE		".rnd"
402656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define LIST_SEPARATOR_CHAR ','
403656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define NUL_DEV		"NLA0:"
404656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project  /* We don't have any well-defined random devices on VMS, yet... */
405656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    undef DEVRANDOM
406656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project  /* We need to do this since VMS has the following coding on status codes:
407656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
408656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project     Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
409656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project               The important thing to know is that odd numbers are considered
410656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	       good, while even ones are considered errors.
411656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project     Bits 3-15: actual status number
412656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project     Bits 16-27: facility number.  0 is considered "unknown"
413656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project     Bits 28-31: control bits.  If bit 28 is set, the shell won't try to
414656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project                 output the message (which, for random codes, just looks ugly)
415656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
416656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project     So, what we do here is to change 0 to 1 to get the default success status,
417656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project     and everything else is shifted up to fit into the status number field, and
418656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project     the status is tagged as an error, which I believe is what is wanted here.
419656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project     -- Richard Levitte
420656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project  */
421656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define EXIT(n)		do { int __VMS_EXIT = n; \
422656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project                                     if (__VMS_EXIT == 0) \
423656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project				       __VMS_EXIT = 1; \
424656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project				     else \
425656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project				       __VMS_EXIT = (n << 3) | 2; \
426656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project                                     __VMS_EXIT |= 0x10000000; \
427656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project				     exit(__VMS_EXIT); } while(0)
428656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define NO_SYS_PARAM_H
429656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
430656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  elif defined(OPENSSL_SYS_NETWARE)
431656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <fcntl.h>
432656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <unistd.h>
433656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define NO_SYS_TYPES_H
434656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    undef  DEVRANDOM
435656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifdef NETWARE_CLIB
436656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define getpid GetThreadID
437656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project       extern int GetThreadID(void);
438656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* #      include <conio.h> */
439656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project       extern int kbhit(void);
440656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    else
441656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <screen.h>
442656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
443656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define NO_SYSLOG
444656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define _setmode setmode
445656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define _kbhit kbhit
446656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define _O_TEXT O_TEXT
447656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define _O_BINARY O_BINARY
448656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define OPENSSL_CONF   "openssl.cnf"
449656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define SSLEAY_CONF    OPENSSL_CONF
450656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define RFILE    ".rnd"
451656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define LIST_SEPARATOR_CHAR ';'
452656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define EXIT(n)  { if (n) printf("ERROR: %d\n", (int)n); exit(n); }
453656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
454656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  else
455656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project     /* !defined VMS */
456656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifdef OPENSSL_SYS_MPE
457656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define NO_SYS_PARAM_H
458656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
459656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifdef OPENSSL_UNISTD
460656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include OPENSSL_UNISTD
461656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    else
462656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <unistd.h>
463656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
464656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifndef NO_SYS_TYPES_H
465656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <sys/types.h>
466656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
467656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    if defined(NeXT) || defined(OPENSSL_SYS_NEWS4)
468656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP
469656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project                         * (unless when compiling with -D_POSIX_SOURCE,
470656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project                         * which doesn't work for us) */
471656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
472656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */
473656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define setvbuf(a, b, c, d) setbuffer((a), (b), (d))
474656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project       typedef unsigned long clock_t;
475656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
476221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#    ifdef OPENSSL_SYS_WIN32_CYGWIN
477221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      include <io.h>
478221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      include <fcntl.h>
479221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#    endif
480656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
481656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define OPENSSL_CONF	"openssl.cnf"
482656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define SSLEAY_CONF		OPENSSL_CONF
483656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define RFILE		".rnd"
484656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define LIST_SEPARATOR_CHAR ':'
485656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define NUL_DEV		"/dev/null"
486656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define EXIT(n)		exit(n)
487656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
488656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
489656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define SSLeay_getpid()	getpid()
490656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
491656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
492656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
493656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
494656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/*************/
495656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
496656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef USE_SOCKETS
497656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  if defined(WINDOWS) || defined(MSDOS)
498656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project      /* windows world */
499656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
500656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifdef OPENSSL_NO_SOCK
501656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SSLeay_Write(a,b,c)	(-1)
502656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SSLeay_Read(a,b,c)	(-1)
503656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SHUTDOWN(fd)		close(fd)
504656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SHUTDOWN2(fd)		close(fd)
505656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    elif !defined(__DJGPP__)
506221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      if defined(_WIN32_WCE) && _WIN32_WCE<410
507221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#        define getservbyname _masked_declaration_getservbyname
508221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      endif
509221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      if !defined(IPPROTO_IP)
510221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom         /* winsock[2].h was included already? */
511221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#        include <winsock.h>
512221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      endif
513221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      ifdef getservbyname
514221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#        undef getservbyname
515221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom         /* this is used to be wcecompat/include/winsock_extras.h */
516221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom         struct servent* PASCAL getservbyname(const char*,const char*);
517221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      endif
518221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
519656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      ifdef _WIN64
520656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/*
521656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
522656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * the value constitutes an index in per-process table of limited size
523656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * and not a real pointer.
524656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project */
525656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        define socket(d,t,p)	((int)socket(d,t,p))
526656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        define accept(s,f,l)	((int)accept(s,f,l))
527656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      endif
528656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SSLeay_Write(a,b,c)	send((a),(b),(c),0)
529656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SSLeay_Read(a,b,c)	recv((a),(b),(c),0)
530656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SHUTDOWN(fd)		{ shutdown((fd),0); closesocket(fd); }
531656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SHUTDOWN2(fd)		{ shutdown((fd),2); closesocket(fd); }
532656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    else
533656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SSLeay_Write(a,b,c)	write_s(a,b,c,0)
534656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SSLeay_Read(a,b,c)	read_s(a,b,c)
535656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SHUTDOWN(fd)		close_s(fd)
536656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SHUTDOWN2(fd)		close_s(fd)
537656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
538656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
539656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  elif defined(MAC_OS_pre_X)
540656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
541656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include "MacSocket.h"
542656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define SSLeay_Write(a,b,c)		MacSocket_send((a),(b),(c))
543656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define SSLeay_Read(a,b,c)		MacSocket_recv((a),(b),(c),true)
544656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define SHUTDOWN(fd)		MacSocket_close(fd)
545656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define SHUTDOWN2(fd)		MacSocket_close(fd)
546656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
547656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  elif defined(OPENSSL_SYS_NETWARE)
548656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project         /* NetWare uses the WinSock2 interfaces by default, but can be configured for BSD
549656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project         */
550656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      if defined(NETWARE_BSDSOCK)
551656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        include <sys/socket.h>
552656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        include <netinet/in.h>
553656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        include <sys/time.h>
554656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        if defined(NETWARE_CLIB)
555656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#          include <sys/bsdskt.h>
556656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        else
557656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#          include <sys/select.h>
558656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        endif
559656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        define INVALID_SOCKET (int)(~0)
560656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      else
561656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        include <novsock2.h>
562656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      endif
563656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SSLeay_Write(a,b,c)   send((a),(b),(c),0)
564656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
565656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SHUTDOWN(fd)    { shutdown((fd),0); closesocket(fd); }
566656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      define SHUTDOWN2(fd)      { shutdown((fd),2); closesocket(fd); }
567656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
568656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  else
569656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
570656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifndef NO_SYS_PARAM_H
571656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <sys/param.h>
572656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
573656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifdef OPENSSL_SYS_VXWORKS
574656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <time.h>
575656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    elif !defined(OPENSSL_SYS_MPE)
576656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <sys/time.h> /* Needed under linux for FD_XXX */
577656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
578656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
579656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    include <netdb.h>
580656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    if defined(OPENSSL_SYS_VMS_NODECC)
581656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <socket.h>
582656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <in.h>
583656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <inet.h>
584656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    else
585656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <sys/socket.h>
586656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      ifdef FILIO_H
587656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        include <sys/filio.h> /* Added for FIONBIO under unixware */
588656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      endif
589656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <netinet/in.h>
590221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      if !defined(OPENSSL_SYS_BEOS_R5)
591656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <arpa/inet.h>
592656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
593221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#    endif
594656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
595656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    if defined(NeXT) || defined(_NEXT_SOURCE)
596656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <sys/fcntl.h>
597656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <sys/types.h>
598656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
599656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
600656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifdef OPENSSL_SYS_AIX
601656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <sys/select.h>
602656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
603656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
604656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifdef __QNX__
605656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <sys/select.h>
606656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
607656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
608656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    if defined(sun)
609656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <sys/filio.h>
610656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    else
611656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      ifndef VMS
612656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        include <sys/ioctl.h>
613656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      else
614656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	 /* ioctl is only in VMS > 7.0 and when socketshr is not used */
615656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
616656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#          include <sys/ioctl.h>
617656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        endif
618656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      endif
619656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
620656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
621656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifdef VMS
622656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      include <unixio.h>
623656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      if defined(TCPIP_TYPE_SOCKETSHR)
624656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#        include <socketshr.h>
625656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#      endif
626656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif
627656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
628656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define SSLeay_Read(a,b,c)     read((a),(b),(c))
629656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define SSLeay_Write(a,b,c)    write((a),(b),(c))
630656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define SHUTDOWN(fd)    { shutdown((fd),0); closesocket((fd)); }
631656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define SHUTDOWN2(fd)   { shutdown((fd),2); closesocket((fd)); }
632656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    ifndef INVALID_SOCKET
633656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define INVALID_SOCKET	(-1)
634656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    endif /* INVALID_SOCKET */
635656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif
636221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
637221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom/* Some IPv6 implementations are broken, disable them in known bad
638221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom * versions.
639221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom */
640221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#  if !defined(OPENSSL_USE_IPV6)
641221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#    if defined(AF_INET6) && !defined(OPENSSL_SYS_BEOS_BONE) && !defined(NETWARE_CLIB)
642221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      define OPENSSL_USE_IPV6 1
643221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#    else
644221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#      define OPENSSL_USE_IPV6 0
645221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#    endif
646221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom#  endif
647221304ee937bc0910948a8be1320cb8cc4eb6d36Brian Carlstrom
648656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
649656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
650656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(sun) && !defined(__svr4__) && !defined(__SVR4)
651656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project  /* include headers first, so our defines don't break it */
652656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <stdlib.h>
653656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <string.h>
654656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project  /* bcopy can handle overlapping moves according to SunOS 4.1.4 manpage */
655656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# define memmove(s1,s2,n) bcopy((s2),(s1),(n))
656656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# define strtoul(s,e,b) ((unsigned long int)strtol((s),(e),(b)))
657656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectextern char *sys_errlist[]; extern int sys_nerr;
658656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# define strerror(errnum) \
659656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project	(((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum])
660656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project  /* Being signed SunOS 4.x memcpy breaks ASN1_OBJECT table lookup */
661656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include "crypto/o_str.h"
662656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# define memcmp OPENSSL_memcmp
663656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
664656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
665656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifndef OPENSSL_EXIT
666656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# if defined(MONOLITH) && !defined(OPENSSL_C)
667656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define OPENSSL_EXIT(n) return(n)
668656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# else
669656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
670656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# endif
671656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
672656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
673656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/***********************************************/
674656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
675656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define DG_GCC_BUG	/* gcc < 2.6.3 on DGUX */
676656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
677656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef sgi
678656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define IRIX_CC_BUG	/* all version of IRIX I've tested (4.* 5.*) */
679656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
680656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#ifdef OPENSSL_SYS_SNI
681656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define IRIX_CC_BUG	/* CDS++ up to V2.0Bsomething suffered from the same bug.*/
682656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
683656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
684656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(OPENSSL_SYS_WINDOWS)
685656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define strcasecmp _stricmp
686656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define strncasecmp _strnicmp
687656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#elif defined(OPENSSL_SYS_VMS)
688656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* VMS below version 7.0 doesn't have strcasecmp() */
689656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  include "o_str.h"
690656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define strcasecmp OPENSSL_strcasecmp
691656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define strncasecmp OPENSSL_strncasecmp
692656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define OPENSSL_IMPLEMENTS_strncasecmp
693656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#elif defined(OPENSSL_SYS_OS2) && defined(__EMX__)
694656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define strcasecmp stricmp
695656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  define strncasecmp strnicmp
696656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#elif defined(OPENSSL_SYS_NETWARE)
697656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  include <string.h>
698656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  if defined(NETWARE_CLIB)
699656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define strcasecmp stricmp
700656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#    define strncasecmp strnicmp
701656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#  endif /* NETWARE_CLIB */
702656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
703656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
704656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(OPENSSL_SYS_OS2) && defined(__EMX__)
705656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# include <io.h>
706656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# include <fcntl.h>
707656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project# define NO_SYSLOG
708656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
709656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
710656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* vxworks */
711656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#if defined(OPENSSL_SYS_VXWORKS)
712656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <ioLib.h>
713656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <tickLib.h>
714656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <sysLib.h>
715656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
716656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define TTY_STRUCT int
717656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
718656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define sleep(a) taskDelay((a) * sysClkRateGet())
719656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
720656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <vxWorks.h>
721656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <sockLib.h>
722656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#include <taskLib.h>
723656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
724656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#define getpid taskIdSelf
725656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
726656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* NOTE: these are implemented by helpers in database app!
727656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * if the database is not linked, we need to implement them
728656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project * elswhere */
729656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectstruct hostent *gethostbyname(const char *name);
730656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectstruct hostent *gethostbyaddr(const char *addr, int length, int type);
731656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Projectstruct servent *getservbyname(const char *name, const char *proto);
732656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
733656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project#endif
734656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project/* end vxworks */
735656d9c7f52f88b3a3daccafa7655dec086c4756eThe Android Open Source Project
736