Clarification.
[openssl.git] / e_os.h
diff --git a/e_os.h b/e_os.h
index eb5c7bf696e4b30309e38b963feec2a0b4dfdaeb..1e06e0a2fe50eec3b6c39ca952ac6e9920c21993 100644 (file)
--- a/e_os.h
+++ b/e_os.h
 #ifndef HEADER_E_OS_H
 #define HEADER_E_OS_H
 
+#include <openssl/opensslconf.h>
+
+#include <openssl/e_os2.h>
+/* <openssl/e_os2.h> contains what we can justify to make visible
+ * to the outside; this file e_os.h is not part of the exported
+ * interface. */
+
 #ifdef  __cplusplus
 extern "C" {
 #endif
@@ -75,8 +82,18 @@ extern "C" {
 #define DEVRANDOM "/dev/urandom"
 #endif
 
-#if defined(NOCONST)
-#define const
+#if defined(__MWERKS__) && defined(macintosh)
+# if macintosh==1
+#  ifndef MAC_OS_GUSI_SOURCE
+#    define MAC_OS_pre_X
+#    define NO_SYS_TYPES_H
+#  endif
+#  define NO_SYS_PARAM_H
+#  define NO_CHMOD
+#  define NO_SYSLOG
+#  undef  DEVRANDOM
+#  define GETPID_IS_MEANINGLESS
+# endif
 #endif
 
 /********************************************************************
@@ -90,6 +107,10 @@ extern "C" {
 #  define MS_STATIC
 #endif
 
+#if defined(_WIN32) && !defined(WIN32)
+#  define WIN32
+#endif
+
 #if defined(WIN32) || defined(WIN16)
 #  ifndef WINDOWS
 #    define WINDOWS
@@ -99,6 +120,10 @@ extern "C" {
 #  endif
 #endif
 
+#if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
+#  define GETPID_IS_MEANINGLESS
+#endif
+
 #ifdef WIN32
 #define get_last_sys_error()   GetLastError()
 #define clear_sys_error()      SetLastError(0)
@@ -116,6 +141,12 @@ extern "C" {
 #define readsocket(s,b,n)      recv((s),(b),(n),0)
 #define writesocket(s,b,n)     send((s),(b),(n),0)
 #define EADDRINUSE             WSAEADDRINUSE
+#elif defined(MAC_OS_pre_X)
+#define get_last_socket_error()        errno
+#define clear_socket_error()   errno=0
+#define closesocket(s)         MacSocket_close(s)
+#define readsocket(s,b,n)      MacSocket_recv((s),(b),(n),true)
+#define writesocket(s,b,n)     MacSocket_send((s),(b),(n))
 #else
 #define get_last_socket_error()        errno
 #define clear_socket_error()   errno=0
@@ -140,21 +171,18 @@ extern "C" {
 
 #if defined(WINDOWS) || defined(MSDOS)
 
-#ifndef S_IFDIR
-#define S_IFDIR        _S_IFDIR
-#endif
-
-#ifndef S_IFMT
-#define S_IFMT _S_IFMT
-
-#if !defined(WINNT)
-#define NO_SYSLOG
-#endif
-#define NO_DIRENT
+#  ifndef S_IFDIR
+#    define S_IFDIR    _S_IFDIR
+#  endif
 
-#endif
+#  ifndef S_IFMT
+#    define S_IFMT     _S_IFMT
+#  endif
 
-#define strncasecmp(a,b,c)     strnicmp((a),(b),(c))
+#  if !defined(WINNT)
+#    define NO_SYSLOG
+#  endif
+#  define NO_DIRENT
 
 #  ifdef WINDOWS
 #    include <windows.h>
@@ -166,21 +194,29 @@ extern "C" {
 #  include <io.h>
 #  include <fcntl.h>
 
-#if defined(WIN16) && !defined(MONOLITH) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
-#  define EXIT(n) { if (n == 0) _wsetexit(_WINEXITNOPERSIST); return(n); }
-#else
-#  define EXIT(n)              return(n);
-#endif
+#  if defined (__BORLANDC__)
+#    define _setmode setmode
+#    define _O_TEXT O_TEXT
+#    define _O_BINARY O_BINARY
+#    define _int64 __int64
+#    define _kbhit kbhit
+#  endif
+
+#  if defined(WIN16) && !defined(MONOLITH) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
+#    define EXIT(n) { if (n == 0) _wsetexit(_WINEXITNOPERSIST); return(n); }
+#  else
+#    define EXIT(n)            return(n);
+#  endif
 #  define LIST_SEPARATOR_CHAR ';'
-#ifndef X_OK
-#  define X_OK 0
-#endif
-#ifndef W_OK
-#  define W_OK 2
-#endif
-#ifndef R_OK
-#  define R_OK 4
-#endif
+#  ifndef X_OK
+#    define X_OK       0
+#  endif
+#  ifndef W_OK
+#    define W_OK       2
+#  endif
+#  ifndef R_OK
+#    define R_OK       4
+#  endif
 #  define OPENSSL_CONF "openssl.cnf"
 #  define SSLEAY_CONF  OPENSSL_CONF
 #  define NUL_DEV      "nul"
@@ -188,27 +224,69 @@ extern "C" {
 
 #else /* The non-microsoft world world */
 
-#  ifdef VMS
-#    include <unixlib.h>
-#  else
-#    include <unistd.h>
+#  if defined(__VMS) && !defined(VMS)
+#  define VMS 1
 #  endif
 
-#  define OPENSSL_CONF "openssl.cnf"
-#  define SSLEAY_CONF  OPENSSL_CONF
-#  define RFILE                ".rnd"
-#  define LIST_SEPARATOR_CHAR ':'
-#  ifndef MONOLITH
-#    define EXIT(n)            exit(n); return(n)
+#  ifdef VMS
+  /* some programs don't include stdlib, so exit() and others give implicit 
+     function warnings */
+#    include <stdlib.h>
+#    if defined(__DECC)
+#      include <unistd.h>
+#    else
+#      include <unixlib.h>
+#    endif
+#    define OPENSSL_CONF       "openssl.cnf"
+#    define SSLEAY_CONF                OPENSSL_CONF
+#    define RFILE              ".rnd"
+#    define LIST_SEPARATOR_CHAR ','
+#    define NUL_DEV            "NLA0:"
+  /* We need to do this, because DEC C converts exit code 0 to 1, but not 1
+     to 0.  We will convert 1 to 3!  Also, add the inhibit message bit... */
+#    ifndef MONOLITH
+#      define EXIT(n)          do { int __VMS_EXIT = n; \
+                                     if (__VMS_EXIT == 1) __VMS_EXIT = 3; \
+                                     __VMS_EXIT |= 0x10000000; \
+                                    exit(n); return(n); } while(0)
+#    else
+#      define EXIT(n)          do { int __VMS_EXIT = n; \
+                                     if (__VMS_EXIT == 1) __VMS_EXIT = 3; \
+                                     __VMS_EXIT |= 0x10000000; \
+                                    return(n); } while(0)
+#    endif
+#    define NO_SYS_PARAM_H
 #  else
-#    define EXIT(n)            return(n)
+     /* !defined VMS */
+#    ifdef OPENSSL_UNISTD
+#      include OPENSSL_UNISTD
+#    else
+#      include <unistd.h>
+#    endif
+#    ifndef NO_SYS_TYPES_H
+#      include <sys/types.h>
+#    endif
+#    ifdef NeXT
+#      define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP */
+#    endif
+
+#    define OPENSSL_CONF       "openssl.cnf"
+#    define SSLEAY_CONF                OPENSSL_CONF
+#    define RFILE              ".rnd"
+#    define LIST_SEPARATOR_CHAR ':'
+#    define NUL_DEV            "/dev/null"
+#    ifndef MONOLITH
+#      define EXIT(n)          exit(n); return(n)
+#    else
+#      define EXIT(n)          return(n)
+#    endif
 #  endif
-#  define NUL_DEV              "/dev/null"
 
 #  define SSLeay_getpid()      getpid()
 
 #endif
 
+
 /*************/
 
 #ifdef USE_SOCKETS
@@ -229,19 +307,30 @@ extern HINSTANCE _hInstance;
 #      define SHUTDOWN2(fd)            { shutdown((fd),2); closesocket(fd); }
 #    endif
 
+#  elif defined(MAC_OS_pre_X)
+
+#    include "MacSocket.h"
+#    define SSLeay_Write(a,b,c)                MacSocket_send((a),(b),(c))
+#    define SSLeay_Read(a,b,c)         MacSocket_recv((a),(b),(c),true)
+#    define SHUTDOWN(fd)               MacSocket_close(fd)
+#    define SHUTDOWN2(fd)              MacSocket_close(fd)
 
 #  else
 
-#    ifndef VMS
-      /* unix world */
-#      include <netdb.h>
-#      include <sys/types.h>
+#    ifndef NO_SYS_PARAM_H
+#      include <sys/param.h>
+#    endif
+#    include <sys/time.h> /* Needed under linux for FD_XXX */
+
+#    include <netdb.h>
+#    if defined(VMS) && !defined(__DECC)
+#      include <socket.h>
+#      include <in.h>
+#    else
 #      include <sys/socket.h>
 #      ifdef FILIO_H
 #        include <sys/filio.h> /* Added for FIONBIO under unixware */
 #      endif
-#      include <sys/param.h>
-#      include <sys/time.h> /* Needed under linux for FD_XXX */
 #      include <netinet/in.h>
 #    endif
 
@@ -257,17 +346,27 @@ extern HINSTANCE _hInstance;
 #    if defined(sun)
 #      include <sys/filio.h>
 #    else
-#      include <sys/ioctl.h>
+#      ifndef VMS
+#        include <sys/ioctl.h>
+#      else
+        /* ioctl is only in VMS > 7.0 and when socketshr is not used */
+#        if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
+#          include <sys/ioctl.h>
+#        endif
+#      endif
 #    endif
 
 #    ifdef VMS
 #      include <unixio.h>
+#      if defined(TCPIP_TYPE_SOCKETSHR)
+#        include <socketshr.h>
+#      endif
 #    endif
 
 #    define SSLeay_Read(a,b,c)     read((a),(b),(c))
 #    define SSLeay_Write(a,b,c)    write((a),(b),(c))
-#    define SHUTDOWN(fd)    { shutdown((fd),0); close((fd)); }
-#    define SHUTDOWN2(fd)   { shutdown((fd),2); close((fd)); }
+#    define SHUTDOWN(fd)    { shutdown((fd),0); closesocket((fd)); }
+#    define SHUTDOWN2(fd)   { shutdown((fd),2); closesocket((fd)); }
 #    define INVALID_SOCKET     (-1)
 #  endif
 #endif
@@ -280,26 +379,6 @@ extern HINSTANCE _hInstance;
 
 /***********************************************/
 
-#ifndef NOPROTO
-#define P_CC_CC        const void *,const void *
-#define P_I_I          int,int 
-#define P_I_I_P                int,int,char *
-#define P_I_I_P_I      int,int,char *,int
-#define P_IP_I_I_P_I   int *,int,int,char *,int
-#define P_V            void 
-#else
-#define P_CC_CC
-#define P_I_I
-#define P_I_I_P
-#define P_IP_I_I_P_I
-#define P_I_I_P_I
-#define P_V
-#endif
-
-/* not used yet */
-#define        CS_BEGIN
-#define CS_END
-
 /* do we need to do this for getenv.
  * Just define getenv for use under windows */
 
@@ -317,6 +396,9 @@ extern HINSTANCE _hInstance;
 #ifdef sgi
 #define IRIX_CC_BUG    /* all version of IRIX I've tested (4.* 5.*) */
 #endif
+#ifdef SNI
+#define IRIX_CC_BUG    /* CDS++ up to V2.0Bsomething suffered from the same bug.*/
+#endif
 
 #ifdef NO_MD2
 #define MD2_Init MD2Init