sl@0: /* e_os.h */
sl@0: /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
sl@0:  * All rights reserved.
sl@0:  *
sl@0:  * This package is an SSL implementation written
sl@0:  * by Eric Young (eay@cryptsoft.com).
sl@0:  * The implementation was written so as to conform with Netscapes SSL.
sl@0:  * 
sl@0:  * This library is free for commercial and non-commercial use as long as
sl@0:  * the following conditions are aheared to.  The following conditions
sl@0:  * apply to all code found in this distribution, be it the RC4, RSA,
sl@0:  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
sl@0:  * included with this distribution is covered by the same copyright terms
sl@0:  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
sl@0:  * 
sl@0:  * Copyright remains Eric Young's, and as such any Copyright notices in
sl@0:  * the code are not to be removed.
sl@0:  * If this package is used in a product, Eric Young should be given attribution
sl@0:  * as the author of the parts of the library used.
sl@0:  * This can be in the form of a textual message at program startup or
sl@0:  * in documentation (online or textual) provided with the package.
sl@0:  * 
sl@0:  * Redistribution and use in source and binary forms, with or without
sl@0:  * modification, are permitted provided that the following conditions
sl@0:  * are met:
sl@0:  * 1. Redistributions of source code must retain the copyright
sl@0:  *    notice, this list of conditions and the following disclaimer.
sl@0:  * 2. Redistributions in binary form must reproduce the above copyright
sl@0:  *    notice, this list of conditions and the following disclaimer in the
sl@0:  *    documentation and/or other materials provided with the distribution.
sl@0:  * 3. All advertising materials mentioning features or use of this software
sl@0:  *    must display the following acknowledgement:
sl@0:  *    "This product includes cryptographic software written by
sl@0:  *     Eric Young (eay@cryptsoft.com)"
sl@0:  *    The word 'cryptographic' can be left out if the rouines from the library
sl@0:  *    being used are not cryptographic related :-).
sl@0:  * 4. If you include any Windows specific code (or a derivative thereof) from 
sl@0:  *    the apps directory (application code) you must include an acknowledgement:
sl@0:  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
sl@0:  * 
sl@0:  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
sl@0:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
sl@0:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0:  * SUCH DAMAGE.
sl@0:  * 
sl@0:  * The licence and distribution terms for any publically available version or
sl@0:  * derivative of this code cannot be changed.  i.e. this code cannot simply be
sl@0:  * copied and put under another distribution licence
sl@0:  * [including the GNU Public Licence.]
sl@0:  */
sl@0: 
sl@0: #ifndef HEADER_E_OS_H
sl@0: #define HEADER_E_OS_H
sl@0: 
sl@0: #include <openssl/opensslconf.h>
sl@0: 
sl@0: #include <openssl/e_os2.h>
sl@0: /* <openssl/e_os2.h> contains what we can justify to make visible
sl@0:  * to the outside; this file e_os.h is not part of the exported
sl@0:  * interface. */
sl@0: 
sl@0: #ifdef  __cplusplus
sl@0: extern "C" {
sl@0: #endif
sl@0: 
sl@0: /* Used to checking reference counts, most while doing perl5 stuff :-) */
sl@0: #ifdef REF_PRINT
sl@0: #undef REF_PRINT
sl@0: #define REF_PRINT(a,b)	fprintf(stderr,"%08X:%4d:%s\n",(int)b,b->references,a)
sl@0: #endif
sl@0: 
sl@0: #ifndef DEVRANDOM
sl@0: /* set this to a comma-separated list of 'random' device files to try out.
sl@0:  * My default, we will try to read at least one of these files */
sl@0: #define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom"
sl@0: #endif
sl@0: #ifndef DEVRANDOM_EGD
sl@0: /* set this to a comma-seperated list of 'egd' sockets to try out. These
sl@0:  * sockets will be tried in the order listed in case accessing the device files
sl@0:  * listed in DEVRANDOM did not return enough entropy. */
sl@0: #define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"
sl@0: #endif
sl@0: 
sl@0: #if defined(OPENSSL_SYS_VXWORKS)
sl@0: #  define NO_SYS_PARAM_H
sl@0: #  define NO_CHMOD
sl@0: #  define NO_SYSLOG
sl@0: #endif
sl@0:   
sl@0: #if defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
sl@0: # if macintosh==1
sl@0: #  ifndef MAC_OS_GUSI_SOURCE
sl@0: #    define MAC_OS_pre_X
sl@0: #    define NO_SYS_TYPES_H
sl@0:      typedef long ssize_t;
sl@0: #  endif
sl@0: #  define NO_SYS_PARAM_H
sl@0: #  define NO_CHMOD
sl@0: #  define NO_SYSLOG
sl@0: #  undef  DEVRANDOM
sl@0: #  define GETPID_IS_MEANINGLESS
sl@0: # endif
sl@0: #endif
sl@0: 
sl@0: /********************************************************************
sl@0:  The Microsoft section
sl@0:  ********************************************************************/
sl@0: /* The following is used becaue of the small stack in some
sl@0:  * Microsoft operating systems */
sl@0: #if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYSNAME_WIN32)&&!defined(SYMBIAN)
sl@0: #  define MS_STATIC	static
sl@0: #else
sl@0: #  define MS_STATIC
sl@0: #endif
sl@0: 
sl@0: #if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
sl@0: #  define WIN32
sl@0: #endif
sl@0: #if defined(OPENSSL_SYS_WIN16) && !defined(WIN16)
sl@0: #  definess WIN16
sl@0: #endif
sl@0: #if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
sl@0: #  define WINDOWS
sl@0: #endif
sl@0: #if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
sl@0: #  define MSDOS
sl@0: #endif
sl@0: 
sl@0: #if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)&&!defined(SYMBIAN)
sl@0: #  define GETPID_IS_MEANINGLESS
sl@0: #endif
sl@0: 
sl@0: #if defined(WIN32)&&!defined(SYMBIAN)
sl@0: #define get_last_sys_error()	GetLastError()
sl@0: #define clear_sys_error()	SetLastError(0)
sl@0: #if !defined(WINNT)
sl@0: #define WIN_CONSOLE_BUG
sl@0: #endif
sl@0: #else
sl@0: #define get_last_sys_error()	errno
sl@0: #define clear_sys_error()	errno=0
sl@0: #endif
sl@0: 
sl@0: #if defined(WINDOWS)&&!defined(SYMBIAN)
sl@0: #define get_last_socket_error()	WSAGetLastError()
sl@0: #define clear_socket_error()	WSASetLastError(0)
sl@0: #define readsocket(s,b,n)	recv((s),(b),(n),0)
sl@0: #define writesocket(s,b,n)	send((s),(b),(n),0)
sl@0: #define EADDRINUSE		WSAEADDRINUSE
sl@0: #elif defined(__DJGPP__)
sl@0: #define WATT32
sl@0: #define get_last_socket_error()	errno
sl@0: #define clear_socket_error()	errno=0
sl@0: #define closesocket(s)		close_s(s)
sl@0: #define readsocket(s,b,n)	read_s(s,b,n)
sl@0: #define writesocket(s,b,n)	send(s,b,n,0)
sl@0: #elif defined(MAC_OS_pre_X)
sl@0: #define get_last_socket_error()	errno
sl@0: #define clear_socket_error()	errno=0
sl@0: #define closesocket(s)		MacSocket_close(s)
sl@0: #define readsocket(s,b,n)	MacSocket_recv((s),(b),(n),true)
sl@0: #define writesocket(s,b,n)	MacSocket_send((s),(b),(n))
sl@0: #elif defined(OPENSSL_SYS_VMS)
sl@0: #define get_last_socket_error() errno
sl@0: #define clear_socket_error()    errno=0
sl@0: #define ioctlsocket(a,b,c)      ioctl(a,b,c)
sl@0: #define closesocket(s)          close(s)
sl@0: #define readsocket(s,b,n)       recv((s),(b),(n),0)
sl@0: #define writesocket(s,b,n)      send((s),(b),(n),0)
sl@0: #elif defined(OPENSSL_SYS_VXWORKS)
sl@0: #define get_last_socket_error()	errno
sl@0: #define clear_socket_error()	errno=0
sl@0: #define ioctlsocket(a,b,c)	    ioctl((a),(b),(int)(c))
sl@0: #define closesocket(s)		    close(s)
sl@0: #define readsocket(s,b,n)	    read((s),(b),(n))
sl@0: #define writesocket(s,b,n)	    write((s),(char *)(b),(n))
sl@0: #elif defined(OPENSSL_SYS_NETWARE)
sl@0: #if defined(NETWARE_BSDSOCK)
sl@0: #define get_last_socket_error() errno
sl@0: #define clear_socket_error()    errno=0
sl@0: #define closesocket(s)          close(s)
sl@0: #define readsocket(s,b,n)       recv((s),(b),(n),0)
sl@0: #define writesocket(s,b,n)      send((s),(b),(n),0)
sl@0: #else
sl@0: #define get_last_socket_error()	WSAGetLastError()
sl@0: #define clear_socket_error()	WSASetLastError(0)
sl@0: #define readsocket(s,b,n)		recv((s),(b),(n),0)
sl@0: #define writesocket(s,b,n)		send((s),(b),(n),0)
sl@0: #endif
sl@0: #else
sl@0: #define get_last_socket_error()	errno
sl@0: #define clear_socket_error()	errno=0
sl@0: #define ioctlsocket(a,b,c)	ioctl(a,b,c)
sl@0: #define closesocket(s)		close(s)
sl@0: #define readsocket(s,b,n)	read((s),(b),(n))
sl@0: #define writesocket(s,b,n)	write((s),(b),(n))
sl@0: #endif
sl@0: 
sl@0: #if defined(WIN16)&&!defined(SYMBIAN)
sl@0: #  define MS_CALLBACK	_far _loadds
sl@0: #  define MS_FAR	_far
sl@0: #else
sl@0: #  define MS_CALLBACK
sl@0: #  define MS_FAR
sl@0: #endif
sl@0: 
sl@0: #ifdef OPENSSL_NO_STDIO
sl@0: #  undef OPENSSL_NO_FP_API
sl@0: #  define OPENSSL_NO_FP_API
sl@0: #endif
sl@0: 
sl@0: #if (defined(WINDOWS) || defined(MSDOS) && !defined(SYMBIAN))
sl@0: 
sl@0: #  ifdef __DJGPP__
sl@0: #    include <unistd.h>
sl@0: #    include <sys/stat.h>
sl@0: #    include <sys/socket.h>
sl@0: #    include <tcp.h>
sl@0: #    include <netdb.h>
sl@0: #    define _setmode setmode
sl@0: #    define _O_TEXT O_TEXT
sl@0: #    define _O_BINARY O_BINARY
sl@0: #    undef DEVRANDOM
sl@0: #    define DEVRANDOM "/dev/urandom\x24"
sl@0: #  endif /* __DJGPP__ */
sl@0: 
sl@0: #  ifndef S_IFDIR
sl@0: #    define S_IFDIR	_S_IFDIR
sl@0: #  endif
sl@0: 
sl@0: #  ifndef S_IFMT
sl@0: #    define S_IFMT	_S_IFMT
sl@0: #  endif
sl@0: 
sl@0: #  if !defined(WINNT) && !defined(__DJGPP__)
sl@0: #    define NO_SYSLOG
sl@0: #  endif
sl@0: #  define NO_DIRENT
sl@0: 
sl@0: #  ifdef WINDOWS
sl@0: #    if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
sl@0:        /*
sl@0: 	* Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
sl@0: 	* Most notably we ought to check for availability of each specific
sl@0: 	* routine with GetProcAddress() and/or quard NT-specific calls with
sl@0: 	* GetVersion() < 0x80000000. One can argue that in latter "or" case
sl@0: 	* we ought to /DELAYLOAD some .DLLs in order to protect ourselves
sl@0: 	* against run-time link errors. This doesn't seem to be necessary,
sl@0: 	* because it turned out that already Windows 95, first non-NT Win32
sl@0: 	* implementation, is equipped with at least NT 3.51 stubs, dummy
sl@0: 	* routines with same name, but which do nothing. Meaning that it's
sl@0: 	* apparently appropriate to guard generic NT calls with GetVersion
sl@0: 	* alone, while NT 4.0 and above calls ought to be additionally
sl@0: 	* checked upon with GetProcAddress.
sl@0: 	*/
sl@0: #      define _WIN32_WINNT 0x0400
sl@0: #    endif
sl@0: #    include <windows.h>
sl@0: #    include <stddef.h>
sl@0: #    include <errno.h>
sl@0: #    include <string.h>
sl@0: #    ifdef _WIN64
sl@0: #      define strlen(s) _strlen31(s)
sl@0: /* cut strings to 2GB */
sl@0: static unsigned int _strlen31(const char *str)
sl@0: 	{
sl@0: 	unsigned int len=0;
sl@0: 	while (*str && len<0x80000000U) str++, len++;
sl@0: 	return len&0x7FFFFFFF;
sl@0: 	}
sl@0: #    endif
sl@0: #    include <malloc.h>
sl@0: #  endif
sl@0: #  include <io.h>
sl@0: #  include <fcntl.h>
sl@0: 
sl@0: #  ifdef OPENSSL_SYS_WINCE
sl@0: #    include <winsock_extras.h>
sl@0: #  endif
sl@0: 
sl@0: #  define ssize_t long
sl@0: 
sl@0: #  if defined (__BORLANDC__)
sl@0: #    define _setmode setmode
sl@0: #    define _O_TEXT O_TEXT
sl@0: #    define _O_BINARY O_BINARY
sl@0: #    define _int64 __int64
sl@0: #    define _kbhit kbhit
sl@0: #  endif
sl@0: 
sl@0: #  if defined(WIN16) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
sl@0: #    define EXIT(n) _wsetexit(_WINEXITNOPERSIST)
sl@0: #    define OPENSSL_EXIT(n) do { if (n == 0) EXIT(n); return(n); } while(0)
sl@0: #  else
sl@0: #    define EXIT(n) exit(n)
sl@0: #  endif
sl@0: #  define LIST_SEPARATOR_CHAR ';'
sl@0: #  ifndef X_OK
sl@0: #    define X_OK	0
sl@0: #  endif
sl@0: #  ifndef W_OK
sl@0: #    define W_OK	2
sl@0: #  endif
sl@0: #  ifndef R_OK
sl@0: #    define R_OK	4
sl@0: #  endif
sl@0: #  define OPENSSL_CONF	"openssl.cnf"
sl@0: #  define SSLEAY_CONF	OPENSSL_CONF
sl@0: #  define NUL_DEV	"nul"
sl@0: #  define RFILE		".rnd"
sl@0: #  ifdef OPENSSL_SYS_WINCE
sl@0: #    define DEFAULT_HOME  ""
sl@0: #  else
sl@0: #    define DEFAULT_HOME  "C:"
sl@0: #  endif
sl@0: 
sl@0: #else /* The non-microsoft world world */
sl@0: 
sl@0: #  ifdef OPENSSL_SYS_VMS
sl@0: #    define VMS 1
sl@0:   /* some programs don't include stdlib, so exit() and others give implicit 
sl@0:      function warnings */
sl@0: #    include <stdlib.h>
sl@0: #    if defined(__DECC)
sl@0: #      include <unistd.h>
sl@0: #    else
sl@0: #      include <unixlib.h>
sl@0: #    endif
sl@0: #    define OPENSSL_CONF	"openssl.cnf"
sl@0: #    define SSLEAY_CONF		OPENSSL_CONF
sl@0: #    define RFILE		".rnd"
sl@0: #    define LIST_SEPARATOR_CHAR ','
sl@0: #    define NUL_DEV		"NLA0:"
sl@0:   /* We don't have any well-defined random devices on VMS, yet... */
sl@0: #    undef DEVRANDOM
sl@0:   /* We need to do this since VMS has the following coding on status codes:
sl@0: 
sl@0:      Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
sl@0:                The important thing to know is that odd numbers are considered
sl@0: 	       good, while even ones are considered errors.
sl@0:      Bits 3-15: actual status number
sl@0:      Bits 16-27: facility number.  0 is considered "unknown"
sl@0:      Bits 28-31: control bits.  If bit 28 is set, the shell won't try to
sl@0:                  output the message (which, for random codes, just looks ugly)
sl@0: 
sl@0:      So, what we do here is to change 0 to 1 to get the default success status,
sl@0:      and everything else is shifted up to fit into the status number field, and
sl@0:      the status is tagged as an error, which I believe is what is wanted here.
sl@0:      -- Richard Levitte
sl@0:   */
sl@0: #    define EXIT(n)		do { int __VMS_EXIT = n; \
sl@0:                                      if (__VMS_EXIT == 0) \
sl@0: 				       __VMS_EXIT = 1; \
sl@0: 				     else \
sl@0: 				       __VMS_EXIT = (n << 3) | 2; \
sl@0:                                      __VMS_EXIT |= 0x10000000; \
sl@0: 				     exit(__VMS_EXIT); } while(0)
sl@0: #    define NO_SYS_PARAM_H
sl@0: 
sl@0: #  elif defined(OPENSSL_SYS_NETWARE)
sl@0: #    include <fcntl.h>
sl@0: #    include <unistd.h>
sl@0: #    define NO_SYS_TYPES_H
sl@0: #    undef  DEVRANDOM
sl@0: #    ifdef NETWARE_CLIB
sl@0: #      define getpid GetThreadID
sl@0: #    endif
sl@0: #    define NO_SYSLOG
sl@0: #    define _setmode setmode
sl@0: #    define _kbhit kbhit
sl@0: #    define _O_TEXT O_TEXT
sl@0: #    define _O_BINARY O_BINARY
sl@0: #    define OPENSSL_CONF   "openssl.cnf"
sl@0: #    define SSLEAY_CONF    OPENSSL_CONF
sl@0: #    define RFILE    ".rnd"
sl@0: #    define LIST_SEPARATOR_CHAR ';'
sl@0: #    define EXIT(n)  { if (n) printf("ERROR: %d\n", (int)n); exit(n); }
sl@0: 
sl@0: #  else
sl@0:     /* !defined VMS */
sl@0: #    ifdef OPENSSL_SYS_MPE
sl@0: #      define NO_SYS_PARAM_H
sl@0: #    endif
sl@0: #    ifdef OPENSSL_UNISTD
sl@0: #      include OPENSSL_UNISTD
sl@0: #    else
sl@0: #      include <unistd.h>
sl@0: #    endif
sl@0: #    ifndef NO_SYS_TYPES_H
sl@0: #      include <sys/types.h>
sl@0: #    endif
sl@0: #    if defined(NeXT) || defined(OPENSSL_SYS_NEWS4)
sl@0: #      define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP
sl@0:                          * (unless when compiling with -D_POSIX_SOURCE,
sl@0:                          * which doesn't work for us) */
sl@0: #    endif
sl@0: #    if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)
sl@0: #      define ssize_t int /* ditto */
sl@0: #    endif
sl@0: #    ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */
sl@0: #      define setvbuf(a, b, c, d) setbuffer((a), (b), (d))
sl@0:        typedef unsigned long clock_t;
sl@0: #    endif
sl@0: 
sl@0: #    define OPENSSL_CONF	"openssl.cnf"
sl@0: #    define SSLEAY_CONF		OPENSSL_CONF
sl@0: #    define RFILE		".rnd"
sl@0: #    define LIST_SEPARATOR_CHAR ':'
sl@0: #    define NUL_DEV		"/dev/null"
sl@0: #    define EXIT(n)		exit(n)
sl@0: #  endif
sl@0: 
sl@0: #  define SSLeay_getpid()	getpid()
sl@0: 
sl@0: #endif
sl@0: 
sl@0: 
sl@0: /*************/
sl@0: 
sl@0: #ifdef USE_SOCKETS
sl@0: #  if defined(WINDOWS) || defined(MSDOS) && !defined(SYMBIAN)
sl@0:       /* windows world */
sl@0: 
sl@0: #    ifdef OPENSSL_NO_SOCK
sl@0: #      define SSLeay_Write(a,b,c)	(-1)
sl@0: #      define SSLeay_Read(a,b,c)	(-1)
sl@0: #      define SHUTDOWN(fd)		close(fd)
sl@0: #      define SHUTDOWN2(fd)		close(fd)
sl@0: #    elif !defined(__DJGPP__)
sl@0: #      include <winsock.h>
sl@0: extern HINSTANCE _hInstance;
sl@0: #      ifdef _WIN64
sl@0: /*
sl@0:  * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
sl@0:  * the value constitutes an index in per-process table of limited size
sl@0:  * and not a real pointer.
sl@0:  */
sl@0: #        define socket(d,t,p)	((int)socket(d,t,p))
sl@0: #        define accept(s,f,l)	((int)accept(s,f,l))
sl@0: #      endif
sl@0: #      define SSLeay_Write(a,b,c)	send((a),(b),(c),0)
sl@0: #      define SSLeay_Read(a,b,c)	recv((a),(b),(c),0)
sl@0: #      define SHUTDOWN(fd)		{ shutdown((fd),0); closesocket(fd); }
sl@0: #      define SHUTDOWN2(fd)		{ shutdown((fd),2); closesocket(fd); }
sl@0: #    else
sl@0: #      define SSLeay_Write(a,b,c)	write_s(a,b,c,0)
sl@0: #      define SSLeay_Read(a,b,c)	read_s(a,b,c)
sl@0: #      define SHUTDOWN(fd)		close_s(fd)
sl@0: #      define SHUTDOWN2(fd)		close_s(fd)
sl@0: #    endif
sl@0: 
sl@0: #  elif defined(MAC_OS_pre_X)
sl@0: 
sl@0: #    include "MacSocket.h"
sl@0: #    define SSLeay_Write(a,b,c)		MacSocket_send((a),(b),(c))
sl@0: #    define SSLeay_Read(a,b,c)		MacSocket_recv((a),(b),(c),true)
sl@0: #    define SHUTDOWN(fd)		MacSocket_close(fd)
sl@0: #    define SHUTDOWN2(fd)		MacSocket_close(fd)
sl@0: 
sl@0: #  elif defined(OPENSSL_SYS_NETWARE)
sl@0:          /* NetWare uses the WinSock2 interfaces by default, but can be configured for BSD
sl@0:          */
sl@0: #      if defined(NETWARE_BSDSOCK)
sl@0: #        include <sys/socket.h>
sl@0: #        include <netinet/in.h>
sl@0: #        include <sys/time.h>
sl@0: #        include <sys/select.h>
sl@0: #        define INVALID_SOCKET (int)(~0)
sl@0: #      else
sl@0: #        include <novsock2.h>
sl@0: #      endif
sl@0: #      define SSLeay_Write(a,b,c)   send((a),(b),(c),0)
sl@0: #      define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
sl@0: #      define SHUTDOWN(fd)    { shutdown((fd),0); closesocket(fd); }
sl@0: #      define SHUTDOWN2(fd)      { shutdown((fd),2); closesocket(fd); }
sl@0: 
sl@0: #  else
sl@0: #    ifndef NO_SYS_PARAM_H
sl@0: #      include <sys/param.h>
sl@0: #    endif
sl@0: #    ifdef OPENSSL_SYS_VXWORKS
sl@0: #      include <time.h> 
sl@0: #    elif !defined(OPENSSL_SYS_MPE)
sl@0: #      include <sys/time.h> /* Needed under linux for FD_XXX */
sl@0: #    endif
sl@0: 
sl@0: #    include <netdb.h>
sl@0: #    if defined(OPENSSL_SYS_VMS_NODECC)
sl@0: #      include <socket.h>
sl@0: #      include <in.h>
sl@0: #      include <inet.h>
sl@0: #    else
sl@0: #      include <sys/socket.h>
sl@0: #      ifdef FILIO_H
sl@0: #        include <sys/filio.h> /* Added for FIONBIO under unixware */
sl@0: #      endif
sl@0: #      include <netinet/in.h>
sl@0: #      include <arpa/inet.h>
sl@0: #    endif
sl@0: 
sl@0: #    if defined(NeXT) || defined(_NEXT_SOURCE)
sl@0: #      include <sys/fcntl.h>
sl@0: #      include <sys/types.h>
sl@0: #    endif
sl@0: 
sl@0: #    ifdef OPENSSL_SYS_AIX
sl@0: #      include <sys/select.h>
sl@0: #    endif
sl@0: 
sl@0: #    ifdef __QNX__
sl@0: #      include <sys/select.h>
sl@0: #    endif
sl@0: 
sl@0: #    if defined(sun)
sl@0: #      include <sys/filio.h>
sl@0: #    else
sl@0: #      ifndef VMS
sl@0: #        include <sys/ioctl.h>
sl@0: #      else
sl@0: 	 /* ioctl is only in VMS > 7.0 and when socketshr is not used */
sl@0: #        if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
sl@0: #          include <sys/ioctl.h>
sl@0: #        endif
sl@0: #      endif
sl@0: #    endif
sl@0: 
sl@0: #    ifdef VMS
sl@0: #      include <unixio.h>
sl@0: #      if defined(TCPIP_TYPE_SOCKETSHR)
sl@0: #        include <socketshr.h>
sl@0: #      endif
sl@0: #    endif
sl@0: 
sl@0: #    define SSLeay_Read(a,b,c)     read((a),(b),(c))
sl@0: #    define SSLeay_Write(a,b,c)    write((a),(b),(c))
sl@0: #    define SHUTDOWN(fd)    { shutdown((fd),0); closesocket((fd)); }
sl@0: #    define SHUTDOWN2(fd)   { shutdown((fd),2); closesocket((fd)); }
sl@0: #    ifndef INVALID_SOCKET
sl@0: #    define INVALID_SOCKET	(-1)
sl@0: #    endif /* INVALID_SOCKET */
sl@0: #  endif
sl@0: #endif
sl@0: 
sl@0: #if defined(__ultrix)
sl@0: #  ifndef ssize_t
sl@0: #    define ssize_t int 
sl@0: #  endif
sl@0: #endif
sl@0: 
sl@0: #if defined(sun) && !defined(__svr4__) && !defined(__SVR4)
sl@0:   /* include headers first, so our defines don't break it */
sl@0: #include <stdlib.h>
sl@0: #include <string.h>
sl@0:   /* bcopy can handle overlapping moves according to SunOS 4.1.4 manpage */
sl@0: # define memmove(s1,s2,n) bcopy((s2),(s1),(n))
sl@0: # define strtoul(s,e,b) ((unsigned long int)strtol((s),(e),(b)))
sl@0: extern char *sys_errlist[]; extern int sys_nerr;
sl@0: # define strerror(errnum) \
sl@0: 	(((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum])
sl@0:   /* Being signed SunOS 4.x memcpy breaks ASN1_OBJECT table lookup */
sl@0: #include "crypto/o_str.h"
sl@0: # define memcmp OPENSSL_memcmp
sl@0: #endif
sl@0: 
sl@0: #ifndef OPENSSL_EXIT
sl@0: # if defined(MONOLITH) && !defined(OPENSSL_C)
sl@0: #  define OPENSSL_EXIT(n) return(n)
sl@0: # else
sl@0: #  define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
sl@0: # endif
sl@0: #endif
sl@0: 
sl@0: /***********************************************/
sl@0: 
sl@0: /* do we need to do this for getenv.
sl@0:  * Just define getenv for use under windows */
sl@0: 
sl@0: #if defined(WIN16) && !defined(SYMBIAN)
sl@0: /* How to do this needs to be thought out a bit more.... */
sl@0: /*char *GETENV(char *);
sl@0: #define Getenv	GETENV*/
sl@0: #define Getenv	getenv
sl@0: #else
sl@0: #define Getenv getenv
sl@0: #endif
sl@0: 
sl@0: #define DG_GCC_BUG	/* gcc < 2.6.3 on DGUX */
sl@0: 
sl@0: #ifdef sgi
sl@0: #define IRIX_CC_BUG	/* all version of IRIX I've tested (4.* 5.*) */
sl@0: #endif
sl@0: #ifdef OPENSSL_SYS_SNI
sl@0: #define IRIX_CC_BUG	/* CDS++ up to V2.0Bsomething suffered from the same bug.*/
sl@0: #endif
sl@0: 
sl@0: #if defined(OPENSSL_SYS_WINDOWS)
sl@0: #  define strcasecmp _stricmp
sl@0: #  define strncasecmp _strnicmp
sl@0: #elif defined(OPENSSL_SYS_VMS)
sl@0: /* VMS below version 7.0 doesn't have strcasecmp() */
sl@0: #  include "o_str.h"
sl@0: #  define strcasecmp OPENSSL_strcasecmp
sl@0: #  define strncasecmp OPENSSL_strncasecmp
sl@0: #  define OPENSSL_IMPLEMENTS_strncasecmp
sl@0: #elif defined(OPENSSL_SYS_OS2) && defined(__EMX__)
sl@0: #  define strcasecmp stricmp
sl@0: #  define strncasecmp strnicmp
sl@0: #elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
sl@0: #  define strcasecmp stricmp
sl@0: #  define strncasecmp strnicmp
sl@0: #else
sl@0: #  ifdef NO_STRINGS_H
sl@0:     int	strcasecmp();
sl@0:     int	strncasecmp();
sl@0: #  else
sl@0: #    include <strings.h>
sl@0: #  endif /* NO_STRINGS_H */
sl@0: #endif
sl@0: 
sl@0: #if defined(OPENSSL_SYS_OS2) && defined(__EMX__)
sl@0: # include <io.h>
sl@0: # include <fcntl.h>
sl@0: # define NO_SYSLOG
sl@0: #endif
sl@0: 
sl@0: /* vxworks */
sl@0: #if defined(OPENSSL_SYS_VXWORKS)
sl@0: #include <ioLib.h>
sl@0: #include <tickLib.h>
sl@0: #include <sysLib.h>
sl@0: 
sl@0: #define TTY_STRUCT int
sl@0: 
sl@0: #define sleep(a) taskDelay((a) * sysClkRateGet())
sl@0: 
sl@0: #include <vxWorks.h>
sl@0: #include <sockLib.h>
sl@0: #include <taskLib.h>
sl@0: 
sl@0: #define getpid taskIdSelf
sl@0: 
sl@0: /* NOTE: these are implemented by helpers in database app!
sl@0:  * if the database is not linked, we need to implement them
sl@0:  * elswhere */
sl@0: struct hostent *gethostbyname(const char *name);
sl@0: struct hostent *gethostbyaddr(const char *addr, int length, int type);
sl@0: struct servent *getservbyname(const char *name, const char *proto);
sl@0: 
sl@0: #endif
sl@0: /* end vxworks */
sl@0: 
sl@0: #ifdef  __cplusplus
sl@0: }
sl@0: #endif
sl@0: 
sl@0: #endif
sl@0: