os/ossrv/ssl/tsrc/BC/include/e_os.h
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/ossrv/ssl/tsrc/BC/include/e_os.h	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,664 @@
     1.4 +/* e_os.h */
     1.5 +/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
     1.6 + * All rights reserved.
     1.7 + *
     1.8 + * This package is an SSL implementation written
     1.9 + * by Eric Young (eay@cryptsoft.com).
    1.10 + * The implementation was written so as to conform with Netscapes SSL.
    1.11 + * 
    1.12 + * This library is free for commercial and non-commercial use as long as
    1.13 + * the following conditions are aheared to.  The following conditions
    1.14 + * apply to all code found in this distribution, be it the RC4, RSA,
    1.15 + * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
    1.16 + * included with this distribution is covered by the same copyright terms
    1.17 + * except that the holder is Tim Hudson (tjh@cryptsoft.com).
    1.18 + * 
    1.19 + * Copyright remains Eric Young's, and as such any Copyright notices in
    1.20 + * the code are not to be removed.
    1.21 + * If this package is used in a product, Eric Young should be given attribution
    1.22 + * as the author of the parts of the library used.
    1.23 + * This can be in the form of a textual message at program startup or
    1.24 + * in documentation (online or textual) provided with the package.
    1.25 + * 
    1.26 + * Redistribution and use in source and binary forms, with or without
    1.27 + * modification, are permitted provided that the following conditions
    1.28 + * are met:
    1.29 + * 1. Redistributions of source code must retain the copyright
    1.30 + *    notice, this list of conditions and the following disclaimer.
    1.31 + * 2. Redistributions in binary form must reproduce the above copyright
    1.32 + *    notice, this list of conditions and the following disclaimer in the
    1.33 + *    documentation and/or other materials provided with the distribution.
    1.34 + * 3. All advertising materials mentioning features or use of this software
    1.35 + *    must display the following acknowledgement:
    1.36 + *    "This product includes cryptographic software written by
    1.37 + *     Eric Young (eay@cryptsoft.com)"
    1.38 + *    The word 'cryptographic' can be left out if the rouines from the library
    1.39 + *    being used are not cryptographic related :-).
    1.40 + * 4. If you include any Windows specific code (or a derivative thereof) from 
    1.41 + *    the apps directory (application code) you must include an acknowledgement:
    1.42 + *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
    1.43 + * 
    1.44 + * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
    1.45 + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    1.46 + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
    1.47 + * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
    1.48 + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
    1.49 + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
    1.50 + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
    1.51 + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
    1.52 + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
    1.53 + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
    1.54 + * SUCH DAMAGE.
    1.55 + * 
    1.56 + * The licence and distribution terms for any publically available version or
    1.57 + * derivative of this code cannot be changed.  i.e. this code cannot simply be
    1.58 + * copied and put under another distribution licence
    1.59 + * [including the GNU Public Licence.]
    1.60 + */
    1.61 +
    1.62 +#ifndef HEADER_E_OS_H
    1.63 +#define HEADER_E_OS_H
    1.64 +
    1.65 +#include <openssl/opensslconf.h>
    1.66 +
    1.67 +#include <openssl/e_os2.h>
    1.68 +/* <openssl/e_os2.h> contains what we can justify to make visible
    1.69 + * to the outside; this file e_os.h is not part of the exported
    1.70 + * interface. */
    1.71 +
    1.72 +#ifdef  __cplusplus
    1.73 +extern "C" {
    1.74 +#endif
    1.75 +
    1.76 +/* Used to checking reference counts, most while doing perl5 stuff :-) */
    1.77 +#ifdef REF_PRINT
    1.78 +#undef REF_PRINT
    1.79 +#define REF_PRINT(a,b)	fprintf(stderr,"%08X:%4d:%s\n",(int)b,b->references,a)
    1.80 +#endif
    1.81 +
    1.82 +#ifndef DEVRANDOM
    1.83 +/* set this to a comma-separated list of 'random' device files to try out.
    1.84 + * My default, we will try to read at least one of these files */
    1.85 +#define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom"
    1.86 +#endif
    1.87 +#ifndef DEVRANDOM_EGD
    1.88 +/* set this to a comma-seperated list of 'egd' sockets to try out. These
    1.89 + * sockets will be tried in the order listed in case accessing the device files
    1.90 + * listed in DEVRANDOM did not return enough entropy. */
    1.91 +#define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"
    1.92 +#endif
    1.93 +
    1.94 +#if defined(OPENSSL_SYS_VXWORKS)
    1.95 +#  define NO_SYS_PARAM_H
    1.96 +#  define NO_CHMOD
    1.97 +#  define NO_SYSLOG
    1.98 +#endif
    1.99 +  
   1.100 +#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
   1.101 +# if macintosh==1
   1.102 +#  ifndef MAC_OS_GUSI_SOURCE
   1.103 +#    define MAC_OS_pre_X
   1.104 +#    define NO_SYS_TYPES_H
   1.105 +     typedef long ssize_t;
   1.106 +#  endif
   1.107 +#  define NO_SYS_PARAM_H
   1.108 +#  define NO_CHMOD
   1.109 +#  define NO_SYSLOG
   1.110 +#  undef  DEVRANDOM
   1.111 +#  define GETPID_IS_MEANINGLESS
   1.112 +# endif
   1.113 +#endif
   1.114 +
   1.115 +/********************************************************************
   1.116 + The Microsoft section
   1.117 + ********************************************************************/
   1.118 +/* The following is used becaue of the small stack in some
   1.119 + * Microsoft operating systems */
   1.120 +#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYSNAME_WIN32)&&!defined(SYMBIAN)
   1.121 +#  define MS_STATIC	static
   1.122 +#else
   1.123 +#  define MS_STATIC
   1.124 +#endif
   1.125 +
   1.126 +#if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
   1.127 +#  define WIN32
   1.128 +#endif
   1.129 +#if defined(OPENSSL_SYS_WIN16) && !defined(WIN16)
   1.130 +#  definess WIN16
   1.131 +#endif
   1.132 +#if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
   1.133 +#  define WINDOWS
   1.134 +#endif
   1.135 +#if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
   1.136 +#  define MSDOS
   1.137 +#endif
   1.138 +
   1.139 +#if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)&&!defined(SYMBIAN)
   1.140 +#  define GETPID_IS_MEANINGLESS
   1.141 +#endif
   1.142 +
   1.143 +#if defined(WIN32)&&!defined(SYMBIAN)
   1.144 +#define get_last_sys_error()	GetLastError()
   1.145 +#define clear_sys_error()	SetLastError(0)
   1.146 +#if !defined(WINNT)
   1.147 +#define WIN_CONSOLE_BUG
   1.148 +#endif
   1.149 +#else
   1.150 +#define get_last_sys_error()	errno
   1.151 +#define clear_sys_error()	errno=0
   1.152 +#endif
   1.153 +
   1.154 +#if defined(WINDOWS)&&!defined(SYMBIAN)
   1.155 +#define get_last_socket_error()	WSAGetLastError()
   1.156 +#define clear_socket_error()	WSASetLastError(0)
   1.157 +#define readsocket(s,b,n)	recv((s),(b),(n),0)
   1.158 +#define writesocket(s,b,n)	send((s),(b),(n),0)
   1.159 +#define EADDRINUSE		WSAEADDRINUSE
   1.160 +#elif defined(__DJGPP__)
   1.161 +#define WATT32
   1.162 +#define get_last_socket_error()	errno
   1.163 +#define clear_socket_error()	errno=0
   1.164 +#define closesocket(s)		close_s(s)
   1.165 +#define readsocket(s,b,n)	read_s(s,b,n)
   1.166 +#define writesocket(s,b,n)	send(s,b,n,0)
   1.167 +#elif defined(MAC_OS_pre_X)
   1.168 +#define get_last_socket_error()	errno
   1.169 +#define clear_socket_error()	errno=0
   1.170 +#define closesocket(s)		MacSocket_close(s)
   1.171 +#define readsocket(s,b,n)	MacSocket_recv((s),(b),(n),true)
   1.172 +#define writesocket(s,b,n)	MacSocket_send((s),(b),(n))
   1.173 +#elif defined(OPENSSL_SYS_VMS)
   1.174 +#define get_last_socket_error() errno
   1.175 +#define clear_socket_error()    errno=0
   1.176 +#define ioctlsocket(a,b,c)      ioctl(a,b,c)
   1.177 +#define closesocket(s)          close(s)
   1.178 +#define readsocket(s,b,n)       recv((s),(b),(n),0)
   1.179 +#define writesocket(s,b,n)      send((s),(b),(n),0)
   1.180 +#elif defined(OPENSSL_SYS_VXWORKS)
   1.181 +#define get_last_socket_error()	errno
   1.182 +#define clear_socket_error()	errno=0
   1.183 +#define ioctlsocket(a,b,c)	    ioctl((a),(b),(int)(c))
   1.184 +#define closesocket(s)		    close(s)
   1.185 +#define readsocket(s,b,n)	    read((s),(b),(n))
   1.186 +#define writesocket(s,b,n)	    write((s),(char *)(b),(n))
   1.187 +#elif defined(OPENSSL_SYS_NETWARE)
   1.188 +#if defined(NETWARE_BSDSOCK)
   1.189 +#define get_last_socket_error() errno
   1.190 +#define clear_socket_error()    errno=0
   1.191 +#define closesocket(s)          close(s)
   1.192 +#define readsocket(s,b,n)       recv((s),(b),(n),0)
   1.193 +#define writesocket(s,b,n)      send((s),(b),(n),0)
   1.194 +#else
   1.195 +#define get_last_socket_error()	WSAGetLastError()
   1.196 +#define clear_socket_error()	WSASetLastError(0)
   1.197 +#define readsocket(s,b,n)		recv((s),(b),(n),0)
   1.198 +#define writesocket(s,b,n)		send((s),(b),(n),0)
   1.199 +#endif
   1.200 +#else
   1.201 +#define get_last_socket_error()	errno
   1.202 +#define clear_socket_error()	errno=0
   1.203 +#define ioctlsocket(a,b,c)	ioctl(a,b,c)
   1.204 +#define closesocket(s)		close(s)
   1.205 +#define readsocket(s,b,n)	read((s),(b),(n))
   1.206 +#define writesocket(s,b,n)	write((s),(b),(n))
   1.207 +#endif
   1.208 +
   1.209 +#if defined(WIN16)&&!defined(SYMBIAN)
   1.210 +#  define MS_CALLBACK	_far _loadds
   1.211 +#  define MS_FAR	_far
   1.212 +#else
   1.213 +#  define MS_CALLBACK
   1.214 +#  define MS_FAR
   1.215 +#endif
   1.216 +
   1.217 +#ifdef OPENSSL_NO_STDIO
   1.218 +#  undef OPENSSL_NO_FP_API
   1.219 +#  define OPENSSL_NO_FP_API
   1.220 +#endif
   1.221 +
   1.222 +#if (defined(WINDOWS) || defined(MSDOS) && !defined(SYMBIAN))
   1.223 +
   1.224 +#  ifdef __DJGPP__
   1.225 +#    include <unistd.h>
   1.226 +#    include <sys/stat.h>
   1.227 +#    include <sys/socket.h>
   1.228 +#    include <tcp.h>
   1.229 +#    include <netdb.h>
   1.230 +#    define _setmode setmode
   1.231 +#    define _O_TEXT O_TEXT
   1.232 +#    define _O_BINARY O_BINARY
   1.233 +#    undef DEVRANDOM
   1.234 +#    define DEVRANDOM "/dev/urandom\x24"
   1.235 +#  endif /* __DJGPP__ */
   1.236 +
   1.237 +#  ifndef S_IFDIR
   1.238 +#    define S_IFDIR	_S_IFDIR
   1.239 +#  endif
   1.240 +
   1.241 +#  ifndef S_IFMT
   1.242 +#    define S_IFMT	_S_IFMT
   1.243 +#  endif
   1.244 +
   1.245 +#  if !defined(WINNT) && !defined(__DJGPP__)
   1.246 +#    define NO_SYSLOG
   1.247 +#  endif
   1.248 +#  define NO_DIRENT
   1.249 +
   1.250 +#  ifdef WINDOWS
   1.251 +#    if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
   1.252 +       /*
   1.253 +	* Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
   1.254 +	* Most notably we ought to check for availability of each specific
   1.255 +	* routine with GetProcAddress() and/or quard NT-specific calls with
   1.256 +	* GetVersion() < 0x80000000. One can argue that in latter "or" case
   1.257 +	* we ought to /DELAYLOAD some .DLLs in order to protect ourselves
   1.258 +	* against run-time link errors. This doesn't seem to be necessary,
   1.259 +	* because it turned out that already Windows 95, first non-NT Win32
   1.260 +	* implementation, is equipped with at least NT 3.51 stubs, dummy
   1.261 +	* routines with same name, but which do nothing. Meaning that it's
   1.262 +	* apparently appropriate to guard generic NT calls with GetVersion
   1.263 +	* alone, while NT 4.0 and above calls ought to be additionally
   1.264 +	* checked upon with GetProcAddress.
   1.265 +	*/
   1.266 +#      define _WIN32_WINNT 0x0400
   1.267 +#    endif
   1.268 +#    include <windows.h>
   1.269 +#    include <stddef.h>
   1.270 +#    include <errno.h>
   1.271 +#    include <string.h>
   1.272 +#    ifdef _WIN64
   1.273 +#      define strlen(s) _strlen31(s)
   1.274 +/* cut strings to 2GB */
   1.275 +static unsigned int _strlen31(const char *str)
   1.276 +	{
   1.277 +	unsigned int len=0;
   1.278 +	while (*str && len<0x80000000U) str++, len++;
   1.279 +	return len&0x7FFFFFFF;
   1.280 +	}
   1.281 +#    endif
   1.282 +#    include <malloc.h>
   1.283 +#  endif
   1.284 +#  include <io.h>
   1.285 +#  include <fcntl.h>
   1.286 +
   1.287 +#  ifdef OPENSSL_SYS_WINCE
   1.288 +#    include <winsock_extras.h>
   1.289 +#  endif
   1.290 +
   1.291 +#  define ssize_t long
   1.292 +
   1.293 +#  if defined (__BORLANDC__)
   1.294 +#    define _setmode setmode
   1.295 +#    define _O_TEXT O_TEXT
   1.296 +#    define _O_BINARY O_BINARY
   1.297 +#    define _int64 __int64
   1.298 +#    define _kbhit kbhit
   1.299 +#  endif
   1.300 +
   1.301 +#  if defined(WIN16) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
   1.302 +#    define EXIT(n) _wsetexit(_WINEXITNOPERSIST)
   1.303 +#    define OPENSSL_EXIT(n) do { if (n == 0) EXIT(n); return(n); } while(0)
   1.304 +#  else
   1.305 +#    define EXIT(n) exit(n)
   1.306 +#  endif
   1.307 +#  define LIST_SEPARATOR_CHAR ';'
   1.308 +#  ifndef X_OK
   1.309 +#    define X_OK	0
   1.310 +#  endif
   1.311 +#  ifndef W_OK
   1.312 +#    define W_OK	2
   1.313 +#  endif
   1.314 +#  ifndef R_OK
   1.315 +#    define R_OK	4
   1.316 +#  endif
   1.317 +#  define OPENSSL_CONF	"openssl.cnf"
   1.318 +#  define SSLEAY_CONF	OPENSSL_CONF
   1.319 +#  define NUL_DEV	"nul"
   1.320 +#  define RFILE		".rnd"
   1.321 +#  ifdef OPENSSL_SYS_WINCE
   1.322 +#    define DEFAULT_HOME  ""
   1.323 +#  else
   1.324 +#    define DEFAULT_HOME  "C:"
   1.325 +#  endif
   1.326 +
   1.327 +#else /* The non-microsoft world world */
   1.328 +
   1.329 +#  ifdef OPENSSL_SYS_VMS
   1.330 +#    define VMS 1
   1.331 +  /* some programs don't include stdlib, so exit() and others give implicit 
   1.332 +     function warnings */
   1.333 +#    include <stdlib.h>
   1.334 +#    if defined(__DECC)
   1.335 +#      include <unistd.h>
   1.336 +#    else
   1.337 +#      include <unixlib.h>
   1.338 +#    endif
   1.339 +#    define OPENSSL_CONF	"openssl.cnf"
   1.340 +#    define SSLEAY_CONF		OPENSSL_CONF
   1.341 +#    define RFILE		".rnd"
   1.342 +#    define LIST_SEPARATOR_CHAR ','
   1.343 +#    define NUL_DEV		"NLA0:"
   1.344 +  /* We don't have any well-defined random devices on VMS, yet... */
   1.345 +#    undef DEVRANDOM
   1.346 +  /* We need to do this since VMS has the following coding on status codes:
   1.347 +
   1.348 +     Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
   1.349 +               The important thing to know is that odd numbers are considered
   1.350 +	       good, while even ones are considered errors.
   1.351 +     Bits 3-15: actual status number
   1.352 +     Bits 16-27: facility number.  0 is considered "unknown"
   1.353 +     Bits 28-31: control bits.  If bit 28 is set, the shell won't try to
   1.354 +                 output the message (which, for random codes, just looks ugly)
   1.355 +
   1.356 +     So, what we do here is to change 0 to 1 to get the default success status,
   1.357 +     and everything else is shifted up to fit into the status number field, and
   1.358 +     the status is tagged as an error, which I believe is what is wanted here.
   1.359 +     -- Richard Levitte
   1.360 +  */
   1.361 +#    define EXIT(n)		do { int __VMS_EXIT = n; \
   1.362 +                                     if (__VMS_EXIT == 0) \
   1.363 +				       __VMS_EXIT = 1; \
   1.364 +				     else \
   1.365 +				       __VMS_EXIT = (n << 3) | 2; \
   1.366 +                                     __VMS_EXIT |= 0x10000000; \
   1.367 +				     exit(__VMS_EXIT); } while(0)
   1.368 +#    define NO_SYS_PARAM_H
   1.369 +
   1.370 +#  elif defined(OPENSSL_SYS_NETWARE)
   1.371 +#    include <fcntl.h>
   1.372 +#    include <unistd.h>
   1.373 +#    define NO_SYS_TYPES_H
   1.374 +#    undef  DEVRANDOM
   1.375 +#    ifdef NETWARE_CLIB
   1.376 +#      define getpid GetThreadID
   1.377 +#    endif
   1.378 +#    define NO_SYSLOG
   1.379 +#    define _setmode setmode
   1.380 +#    define _kbhit kbhit
   1.381 +#    define _O_TEXT O_TEXT
   1.382 +#    define _O_BINARY O_BINARY
   1.383 +#    define OPENSSL_CONF   "openssl.cnf"
   1.384 +#    define SSLEAY_CONF    OPENSSL_CONF
   1.385 +#    define RFILE    ".rnd"
   1.386 +#    define LIST_SEPARATOR_CHAR ';'
   1.387 +#    define EXIT(n)  { if (n) printf("ERROR: %d\n", (int)n); exit(n); }
   1.388 +
   1.389 +#  else
   1.390 +    /* !defined VMS */
   1.391 +#    ifdef OPENSSL_SYS_MPE
   1.392 +#      define NO_SYS_PARAM_H
   1.393 +#    endif
   1.394 +#    ifdef OPENSSL_UNISTD
   1.395 +#      include OPENSSL_UNISTD
   1.396 +#    else
   1.397 +#      include <unistd.h>
   1.398 +#    endif
   1.399 +#    ifndef NO_SYS_TYPES_H
   1.400 +#      include <sys/types.h>
   1.401 +#    endif
   1.402 +#    if defined(NeXT) || defined(OPENSSL_SYS_NEWS4)
   1.403 +#      define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP
   1.404 +                         * (unless when compiling with -D_POSIX_SOURCE,
   1.405 +                         * which doesn't work for us) */
   1.406 +#    endif
   1.407 +#    if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)
   1.408 +#      define ssize_t int /* ditto */
   1.409 +#    endif
   1.410 +#    ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */
   1.411 +#      define setvbuf(a, b, c, d) setbuffer((a), (b), (d))
   1.412 +       typedef unsigned long clock_t;
   1.413 +#    endif
   1.414 +
   1.415 +#    define OPENSSL_CONF	"openssl.cnf"
   1.416 +#    define SSLEAY_CONF		OPENSSL_CONF
   1.417 +#    define RFILE		".rnd"
   1.418 +#    define LIST_SEPARATOR_CHAR ':'
   1.419 +#    define NUL_DEV		"/dev/null"
   1.420 +#    define EXIT(n)		exit(n)
   1.421 +#  endif
   1.422 +
   1.423 +#  define SSLeay_getpid()	getpid()
   1.424 +
   1.425 +#endif
   1.426 +
   1.427 +
   1.428 +/*************/
   1.429 +
   1.430 +#ifdef USE_SOCKETS
   1.431 +#  if defined(WINDOWS) || defined(MSDOS) && !defined(SYMBIAN)
   1.432 +      /* windows world */
   1.433 +
   1.434 +#    ifdef OPENSSL_NO_SOCK
   1.435 +#      define SSLeay_Write(a,b,c)	(-1)
   1.436 +#      define SSLeay_Read(a,b,c)	(-1)
   1.437 +#      define SHUTDOWN(fd)		close(fd)
   1.438 +#      define SHUTDOWN2(fd)		close(fd)
   1.439 +#    elif !defined(__DJGPP__)
   1.440 +#      include <winsock.h>
   1.441 +extern HINSTANCE _hInstance;
   1.442 +#      ifdef _WIN64
   1.443 +/*
   1.444 + * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
   1.445 + * the value constitutes an index in per-process table of limited size
   1.446 + * and not a real pointer.
   1.447 + */
   1.448 +#        define socket(d,t,p)	((int)socket(d,t,p))
   1.449 +#        define accept(s,f,l)	((int)accept(s,f,l))
   1.450 +#      endif
   1.451 +#      define SSLeay_Write(a,b,c)	send((a),(b),(c),0)
   1.452 +#      define SSLeay_Read(a,b,c)	recv((a),(b),(c),0)
   1.453 +#      define SHUTDOWN(fd)		{ shutdown((fd),0); closesocket(fd); }
   1.454 +#      define SHUTDOWN2(fd)		{ shutdown((fd),2); closesocket(fd); }
   1.455 +#    else
   1.456 +#      define SSLeay_Write(a,b,c)	write_s(a,b,c,0)
   1.457 +#      define SSLeay_Read(a,b,c)	read_s(a,b,c)
   1.458 +#      define SHUTDOWN(fd)		close_s(fd)
   1.459 +#      define SHUTDOWN2(fd)		close_s(fd)
   1.460 +#    endif
   1.461 +
   1.462 +#  elif defined(MAC_OS_pre_X)
   1.463 +
   1.464 +#    include "MacSocket.h"
   1.465 +#    define SSLeay_Write(a,b,c)		MacSocket_send((a),(b),(c))
   1.466 +#    define SSLeay_Read(a,b,c)		MacSocket_recv((a),(b),(c),true)
   1.467 +#    define SHUTDOWN(fd)		MacSocket_close(fd)
   1.468 +#    define SHUTDOWN2(fd)		MacSocket_close(fd)
   1.469 +
   1.470 +#  elif defined(OPENSSL_SYS_NETWARE)
   1.471 +         /* NetWare uses the WinSock2 interfaces by default, but can be configured for BSD
   1.472 +         */
   1.473 +#      if defined(NETWARE_BSDSOCK)
   1.474 +#        include <sys/socket.h>
   1.475 +#        include <netinet/in.h>
   1.476 +#        include <sys/time.h>
   1.477 +#        include <sys/select.h>
   1.478 +#        define INVALID_SOCKET (int)(~0)
   1.479 +#      else
   1.480 +#        include <novsock2.h>
   1.481 +#      endif
   1.482 +#      define SSLeay_Write(a,b,c)   send((a),(b),(c),0)
   1.483 +#      define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
   1.484 +#      define SHUTDOWN(fd)    { shutdown((fd),0); closesocket(fd); }
   1.485 +#      define SHUTDOWN2(fd)      { shutdown((fd),2); closesocket(fd); }
   1.486 +
   1.487 +#  else
   1.488 +#    ifndef NO_SYS_PARAM_H
   1.489 +#      include <sys/param.h>
   1.490 +#    endif
   1.491 +#    ifdef OPENSSL_SYS_VXWORKS
   1.492 +#      include <time.h> 
   1.493 +#    elif !defined(OPENSSL_SYS_MPE)
   1.494 +#      include <sys/time.h> /* Needed under linux for FD_XXX */
   1.495 +#    endif
   1.496 +
   1.497 +#    include <netdb.h>
   1.498 +#    if defined(OPENSSL_SYS_VMS_NODECC)
   1.499 +#      include <socket.h>
   1.500 +#      include <in.h>
   1.501 +#      include <inet.h>
   1.502 +#    else
   1.503 +#      include <sys/socket.h>
   1.504 +#      ifdef FILIO_H
   1.505 +#        include <sys/filio.h> /* Added for FIONBIO under unixware */
   1.506 +#      endif
   1.507 +#      include <netinet/in.h>
   1.508 +#      include <arpa/inet.h>
   1.509 +#    endif
   1.510 +
   1.511 +#    if defined(NeXT) || defined(_NEXT_SOURCE)
   1.512 +#      include <sys/fcntl.h>
   1.513 +#      include <sys/types.h>
   1.514 +#    endif
   1.515 +
   1.516 +#    ifdef OPENSSL_SYS_AIX
   1.517 +#      include <sys/select.h>
   1.518 +#    endif
   1.519 +
   1.520 +#    ifdef __QNX__
   1.521 +#      include <sys/select.h>
   1.522 +#    endif
   1.523 +
   1.524 +#    if defined(sun)
   1.525 +#      include <sys/filio.h>
   1.526 +#    else
   1.527 +#      ifndef VMS
   1.528 +#        include <sys/ioctl.h>
   1.529 +#      else
   1.530 +	 /* ioctl is only in VMS > 7.0 and when socketshr is not used */
   1.531 +#        if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
   1.532 +#          include <sys/ioctl.h>
   1.533 +#        endif
   1.534 +#      endif
   1.535 +#    endif
   1.536 +
   1.537 +#    ifdef VMS
   1.538 +#      include <unixio.h>
   1.539 +#      if defined(TCPIP_TYPE_SOCKETSHR)
   1.540 +#        include <socketshr.h>
   1.541 +#      endif
   1.542 +#    endif
   1.543 +
   1.544 +#    define SSLeay_Read(a,b,c)     read((a),(b),(c))
   1.545 +#    define SSLeay_Write(a,b,c)    write((a),(b),(c))
   1.546 +#    define SHUTDOWN(fd)    { shutdown((fd),0); closesocket((fd)); }
   1.547 +#    define SHUTDOWN2(fd)   { shutdown((fd),2); closesocket((fd)); }
   1.548 +#    ifndef INVALID_SOCKET
   1.549 +#    define INVALID_SOCKET	(-1)
   1.550 +#    endif /* INVALID_SOCKET */
   1.551 +#  endif
   1.552 +#endif
   1.553 +
   1.554 +#if defined(__ultrix)
   1.555 +#  ifndef ssize_t
   1.556 +#    define ssize_t int 
   1.557 +#  endif
   1.558 +#endif
   1.559 +
   1.560 +#if defined(sun) && !defined(__svr4__) && !defined(__SVR4)
   1.561 +  /* include headers first, so our defines don't break it */
   1.562 +#include <stdlib.h>
   1.563 +#include <string.h>
   1.564 +  /* bcopy can handle overlapping moves according to SunOS 4.1.4 manpage */
   1.565 +# define memmove(s1,s2,n) bcopy((s2),(s1),(n))
   1.566 +# define strtoul(s,e,b) ((unsigned long int)strtol((s),(e),(b)))
   1.567 +extern char *sys_errlist[]; extern int sys_nerr;
   1.568 +# define strerror(errnum) \
   1.569 +	(((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum])
   1.570 +  /* Being signed SunOS 4.x memcpy breaks ASN1_OBJECT table lookup */
   1.571 +#include "crypto/o_str.h"
   1.572 +# define memcmp OPENSSL_memcmp
   1.573 +#endif
   1.574 +
   1.575 +#ifndef OPENSSL_EXIT
   1.576 +# if defined(MONOLITH) && !defined(OPENSSL_C)
   1.577 +#  define OPENSSL_EXIT(n) return(n)
   1.578 +# else
   1.579 +#  define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
   1.580 +# endif
   1.581 +#endif
   1.582 +
   1.583 +/***********************************************/
   1.584 +
   1.585 +/* do we need to do this for getenv.
   1.586 + * Just define getenv for use under windows */
   1.587 +
   1.588 +#if defined(WIN16) && !defined(SYMBIAN)
   1.589 +/* How to do this needs to be thought out a bit more.... */
   1.590 +/*char *GETENV(char *);
   1.591 +#define Getenv	GETENV*/
   1.592 +#define Getenv	getenv
   1.593 +#else
   1.594 +#define Getenv getenv
   1.595 +#endif
   1.596 +
   1.597 +#define DG_GCC_BUG	/* gcc < 2.6.3 on DGUX */
   1.598 +
   1.599 +#ifdef sgi
   1.600 +#define IRIX_CC_BUG	/* all version of IRIX I've tested (4.* 5.*) */
   1.601 +#endif
   1.602 +#ifdef OPENSSL_SYS_SNI
   1.603 +#define IRIX_CC_BUG	/* CDS++ up to V2.0Bsomething suffered from the same bug.*/
   1.604 +#endif
   1.605 +
   1.606 +#if defined(OPENSSL_SYS_WINDOWS)
   1.607 +#  define strcasecmp _stricmp
   1.608 +#  define strncasecmp _strnicmp
   1.609 +#elif defined(OPENSSL_SYS_VMS)
   1.610 +/* VMS below version 7.0 doesn't have strcasecmp() */
   1.611 +#  include "o_str.h"
   1.612 +#  define strcasecmp OPENSSL_strcasecmp
   1.613 +#  define strncasecmp OPENSSL_strncasecmp
   1.614 +#  define OPENSSL_IMPLEMENTS_strncasecmp
   1.615 +#elif defined(OPENSSL_SYS_OS2) && defined(__EMX__)
   1.616 +#  define strcasecmp stricmp
   1.617 +#  define strncasecmp strnicmp
   1.618 +#elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
   1.619 +#  define strcasecmp stricmp
   1.620 +#  define strncasecmp strnicmp
   1.621 +#else
   1.622 +#  ifdef NO_STRINGS_H
   1.623 +    int	strcasecmp();
   1.624 +    int	strncasecmp();
   1.625 +#  else
   1.626 +#    include <strings.h>
   1.627 +#  endif /* NO_STRINGS_H */
   1.628 +#endif
   1.629 +
   1.630 +#if defined(OPENSSL_SYS_OS2) && defined(__EMX__)
   1.631 +# include <io.h>
   1.632 +# include <fcntl.h>
   1.633 +# define NO_SYSLOG
   1.634 +#endif
   1.635 +
   1.636 +/* vxworks */
   1.637 +#if defined(OPENSSL_SYS_VXWORKS)
   1.638 +#include <ioLib.h>
   1.639 +#include <tickLib.h>
   1.640 +#include <sysLib.h>
   1.641 +
   1.642 +#define TTY_STRUCT int
   1.643 +
   1.644 +#define sleep(a) taskDelay((a) * sysClkRateGet())
   1.645 +
   1.646 +#include <vxWorks.h>
   1.647 +#include <sockLib.h>
   1.648 +#include <taskLib.h>
   1.649 +
   1.650 +#define getpid taskIdSelf
   1.651 +
   1.652 +/* NOTE: these are implemented by helpers in database app!
   1.653 + * if the database is not linked, we need to implement them
   1.654 + * elswhere */
   1.655 +struct hostent *gethostbyname(const char *name);
   1.656 +struct hostent *gethostbyaddr(const char *addr, int length, int type);
   1.657 +struct servent *getservbyname(const char *name, const char *proto);
   1.658 +
   1.659 +#endif
   1.660 +/* end vxworks */
   1.661 +
   1.662 +#ifdef  __cplusplus
   1.663 +}
   1.664 +#endif
   1.665 +
   1.666 +#endif
   1.667 +