Main Page | Class List | Directories | File List | Class Members | File Members

e_os.h

Go to the documentation of this file.
00001 /* e_os.h */
00002 /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
00003  * All rights reserved.
00004  *
00005  * This package is an SSL implementation written
00006  * by Eric Young (eay@cryptsoft.com).
00007  * The implementation was written so as to conform with Netscapes SSL.
00008  * 
00009  * This library is free for commercial and non-commercial use as long as
00010  * the following conditions are aheared to.  The following conditions
00011  * apply to all code found in this distribution, be it the RC4, RSA,
00012  * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
00013  * included with this distribution is covered by the same copyright terms
00014  * except that the holder is Tim Hudson (tjh@cryptsoft.com).
00015  * 
00016  * Copyright remains Eric Young's, and as such any Copyright notices in
00017  * the code are not to be removed.
00018  * If this package is used in a product, Eric Young should be given attribution
00019  * as the author of the parts of the library used.
00020  * This can be in the form of a textual message at program startup or
00021  * in documentation (online or textual) provided with the package.
00022  * 
00023  * Redistribution and use in source and binary forms, with or without
00024  * modification, are permitted provided that the following conditions
00025  * are met:
00026  * 1. Redistributions of source code must retain the copyright
00027  *    notice, this list of conditions and the following disclaimer.
00028  * 2. Redistributions in binary form must reproduce the above copyright
00029  *    notice, this list of conditions and the following disclaimer in the
00030  *    documentation and/or other materials provided with the distribution.
00031  * 3. All advertising materials mentioning features or use of this software
00032  *    must display the following acknowledgement:
00033  *    "This product includes cryptographic software written by
00034  *     Eric Young (eay@cryptsoft.com)"
00035  *    The word 'cryptographic' can be left out if the rouines from the library
00036  *    being used are not cryptographic related :-).
00037  * 4. If you include any Windows specific code (or a derivative thereof) from 
00038  *    the apps directory (application code) you must include an acknowledgement:
00039  *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
00040  * 
00041  * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
00042  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00043  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00044  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
00045  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
00046  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
00047  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00048  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00049  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
00050  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
00051  * SUCH DAMAGE.
00052  * 
00053  * The licence and distribution terms for any publically available version or
00054  * derivative of this code cannot be changed.  i.e. this code cannot simply be
00055  * copied and put under another distribution licence
00056  * [including the GNU Public Licence.]
00057  */
00058 
00059 #ifndef HEADER_E_OS_H
00060 #define HEADER_E_OS_H
00061 
00062 #include <openssl/opensslconf.h>
00063 
00064 #include <openssl/e_os2.h>
00065 /* <openssl/e_os2.h> contains what we can justify to make visible
00066  * to the outside; this file e_os.h is not part of the exported
00067  * interface. */
00068 
00069 #ifdef  __cplusplus
00070 extern "C" {
00071 #endif
00072 
00073 /* Used to checking reference counts, most while doing perl5 stuff :-) */
00074 #ifdef REF_PRINT
00075 #undef REF_PRINT
00076 #define REF_PRINT(a,b)  fprintf(stderr,"%08X:%4d:%s\n",(int)b,b->references,a)
00077 #endif
00078 
00079 #ifndef DEVRANDOM
00080 /* set this to a comma-separated list of 'random' device files to try out.
00081  * My default, we will try to read at least one of these files */
00082 #define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom"
00083 #endif
00084 #ifndef DEVRANDOM_EGD
00085 /* set this to a comma-seperated list of 'egd' sockets to try out. These
00086  * sockets will be tried in the order listed in case accessing the device files
00087  * listed in DEVRANDOM did not return enough entropy. */
00088 #define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"
00089 #endif
00090 
00091 #if defined(OPENSSL_SYS_VXWORKS)
00092 #  define NO_SYS_PARAM_H
00093 #  define NO_CHMOD
00094 #  define NO_SYSLOG
00095 #endif
00096   
00097 #if defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
00098 # if macintosh==1
00099 #  ifndef MAC_OS_GUSI_SOURCE
00100 #    define MAC_OS_pre_X
00101 #    define NO_SYS_TYPES_H
00102      typedef long ssize_t;
00103 #  endif
00104 #  define NO_SYS_PARAM_H
00105 #  define NO_CHMOD
00106 #  define NO_SYSLOG
00107 #  undef  DEVRANDOM
00108 #  define GETPID_IS_MEANINGLESS
00109 # endif
00110 #endif
00111 
00112 /********************************************************************
00113  The Microsoft section
00114  ********************************************************************/
00115 /* The following is used becaue of the small stack in some
00116  * Microsoft operating systems */
00117 #if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYSNAME_WIN32)
00118 #  define MS_STATIC     static
00119 #else
00120 #  define MS_STATIC
00121 #endif
00122 
00123 #if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
00124 #  define WIN32
00125 #endif
00126 #if defined(OPENSSL_SYS_WIN16) && !defined(WIN16)
00127 #  define WIN16
00128 #endif
00129 #if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
00130 #  define WINDOWS
00131 #endif
00132 #if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
00133 #  define MSDOS
00134 #endif
00135 
00136 #if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
00137 #  define GETPID_IS_MEANINGLESS
00138 #endif
00139 
00140 #ifdef WIN32
00141 #define get_last_sys_error()    GetLastError()
00142 #define clear_sys_error()       SetLastError(0)
00143 #if !defined(WINNT)
00144 #define WIN_CONSOLE_BUG
00145 #endif
00146 #else
00147 #define get_last_sys_error()    errno
00148 #define clear_sys_error()       errno=0
00149 #endif
00150 
00151 #if defined(WINDOWS)
00152 #define get_last_socket_error() WSAGetLastError()
00153 #define clear_socket_error()    WSASetLastError(0)
00154 #define readsocket(s,b,n)       recv((s),(b),(n),0)
00155 #define writesocket(s,b,n)      send((s),(b),(n),0)
00156 #define EADDRINUSE              WSAEADDRINUSE
00157 #elif defined(__DJGPP__)
00158 #define WATT32
00159 #define get_last_socket_error() errno
00160 #define clear_socket_error()    errno=0
00161 #define closesocket(s)          close_s(s)
00162 #define readsocket(s,b,n)       read_s(s,b,n)
00163 #define writesocket(s,b,n)      send(s,b,n,0)
00164 #elif defined(MAC_OS_pre_X)
00165 #define get_last_socket_error() errno
00166 #define clear_socket_error()    errno=0
00167 #define closesocket(s)          MacSocket_close(s)
00168 #define readsocket(s,b,n)       MacSocket_recv((s),(b),(n),true)
00169 #define writesocket(s,b,n)      MacSocket_send((s),(b),(n))
00170 #elif defined(OPENSSL_SYS_VMS)
00171 #define get_last_socket_error() errno
00172 #define clear_socket_error()    errno=0
00173 #define ioctlsocket(a,b,c)      ioctl(a,b,c)
00174 #define closesocket(s)          close(s)
00175 #define readsocket(s,b,n)       recv((s),(b),(n),0)
00176 #define writesocket(s,b,n)      send((s),(b),(n),0)
00177 #elif defined(OPENSSL_SYS_VXWORKS)
00178 #define get_last_socket_error() errno
00179 #define clear_socket_error()    errno=0
00180 #define ioctlsocket(a,b,c)          ioctl((a),(b),(int)(c))
00181 #define closesocket(s)              close(s)
00182 #define readsocket(s,b,n)           read((s),(b),(n))
00183 #define writesocket(s,b,n)          write((s),(char *)(b),(n))
00184 #elif defined(OPENSSL_SYS_NETWARE)
00185 #if defined(NETWARE_BSDSOCK)
00186 #define get_last_socket_error() errno
00187 #define clear_socket_error()    errno=0
00188 #define closesocket(s)          close(s)
00189 #define readsocket(s,b,n)       recv((s),(b),(n),0)
00190 #define writesocket(s,b,n)      send((s),(b),(n),0)
00191 #else
00192 #define get_last_socket_error() WSAGetLastError()
00193 #define clear_socket_error()    WSASetLastError(0)
00194 #define readsocket(s,b,n)               recv((s),(b),(n),0)
00195 #define writesocket(s,b,n)              send((s),(b),(n),0)
00196 #endif
00197 #else
00198 #define get_last_socket_error() errno
00199 #define clear_socket_error()    errno=0
00200 #define ioctlsocket(a,b,c)      ioctl(a,b,c)
00201 #define closesocket(s)          close(s)
00202 #define readsocket(s,b,n)       read((s),(b),(n))
00203 #define writesocket(s,b,n)      write((s),(b),(n))
00204 #endif
00205 
00206 #ifdef WIN16
00207 #  define MS_CALLBACK   _far _loadds
00208 #  define MS_FAR        _far
00209 #else
00210 #  define MS_CALLBACK
00211 #  define MS_FAR
00212 #endif
00213 
00214 #ifdef OPENSSL_NO_STDIO
00215 #  undef OPENSSL_NO_FP_API
00216 #  define OPENSSL_NO_FP_API
00217 #endif
00218 
00219 #if (defined(WINDOWS) || defined(MSDOS))
00220 
00221 #  ifdef __DJGPP__
00222 #    include <unistd.h>
00223 #    include <sys/stat.h>
00224 #    include <sys/socket.h>
00225 #    include <tcp.h>
00226 #    include <netdb.h>
00227 #    define _setmode setmode
00228 #    define _O_TEXT O_TEXT
00229 #    define _O_BINARY O_BINARY
00230 #    undef DEVRANDOM
00231 #    define DEVRANDOM "/dev/urandom\x24"
00232 #  endif /* __DJGPP__ */
00233 
00234 #  ifndef S_IFDIR
00235 #    define S_IFDIR     _S_IFDIR
00236 #  endif
00237 
00238 #  ifndef S_IFMT
00239 #    define S_IFMT      _S_IFMT
00240 #  endif
00241 
00242 #  if !defined(WINNT) && !defined(__DJGPP__)
00243 #    define NO_SYSLOG
00244 #  endif
00245 #  define NO_DIRENT
00246 
00247 #  ifdef WINDOWS
00248 #    if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
00249        /*
00250         * Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
00251         * Most notably we ought to check for availability of each specific
00252         * routine with GetProcAddress() and/or quard NT-specific calls with
00253         * GetVersion() < 0x80000000. One can argue that in latter "or" case
00254         * we ought to /DELAYLOAD some .DLLs in order to protect ourselves
00255         * against run-time link errors. This doesn't seem to be necessary,
00256         * because it turned out that already Windows 95, first non-NT Win32
00257         * implementation, is equipped with at least NT 3.51 stubs, dummy
00258         * routines with same name, but which do nothing. Meaning that it's
00259         * apparently appropriate to guard generic NT calls with GetVersion
00260         * alone, while NT 4.0 and above calls ought to be additionally
00261         * checked upon with GetProcAddress.
00262         */
00263 #      define _WIN32_WINNT 0x0400
00264 #    endif
00265 #    include <windows.h>
00266 #    include <stddef.h>
00267 #    include <errno.h>
00268 #    include <string.h>
00269 #    ifdef _WIN64
00270 #      define strlen(s) _strlen31(s)
00271 /* cut strings to 2GB */
00272 static unsigned int _strlen31(const char *str)
00273         {
00274         unsigned int len=0;
00275         while (*str && len<0x80000000U) str++, len++;
00276         return len&0x7FFFFFFF;
00277         }
00278 #    endif
00279 #    include <malloc.h>
00280 #  endif
00281 #  include <io.h>
00282 #  include <fcntl.h>
00283 
00284 #  ifdef OPENSSL_SYS_WINCE
00285 #    include <winsock_extras.h>
00286 #  endif
00287 
00288 #  define ssize_t long
00289 
00290 #  if defined (__BORLANDC__)
00291 #    define _setmode setmode
00292 #    define _O_TEXT O_TEXT
00293 #    define _O_BINARY O_BINARY
00294 #    define _int64 __int64
00295 #    define _kbhit kbhit
00296 #  endif
00297 
00298 #  if defined(WIN16) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
00299 #    define EXIT(n) _wsetexit(_WINEXITNOPERSIST)
00300 #    define OPENSSL_EXIT(n) do { if (n == 0) EXIT(n); return(n); } while(0)
00301 #  else
00302 #    define EXIT(n) exit(n)
00303 #  endif
00304 #  define LIST_SEPARATOR_CHAR ';'
00305 #  ifndef X_OK
00306 #    define X_OK        0
00307 #  endif
00308 #  ifndef W_OK
00309 #    define W_OK        2
00310 #  endif
00311 #  ifndef R_OK
00312 #    define R_OK        4
00313 #  endif
00314 #  define OPENSSL_CONF  "openssl.cnf"
00315 #  define SSLEAY_CONF   OPENSSL_CONF
00316 #  define NUL_DEV       "nul"
00317 #  define RFILE         ".rnd"
00318 #  ifdef OPENSSL_SYS_WINCE
00319 #    define DEFAULT_HOME  ""
00320 #  else
00321 #    define DEFAULT_HOME  "C:"
00322 #  endif
00323 
00324 #else /* The non-microsoft world world */
00325 
00326 #  ifdef OPENSSL_SYS_VMS
00327 #    define VMS 1
00328   /* some programs don't include stdlib, so exit() and others give implicit 
00329      function warnings */
00330 #    include <stdlib.h>
00331 #    if defined(__DECC)
00332 #      include <unistd.h>
00333 #    else
00334 #      include <unixlib.h>
00335 #    endif
00336 #    define OPENSSL_CONF        "openssl.cnf"
00337 #    define SSLEAY_CONF         OPENSSL_CONF
00338 #    define RFILE               ".rnd"
00339 #    define LIST_SEPARATOR_CHAR ','
00340 #    define NUL_DEV             "NLA0:"
00341   /* We don't have any well-defined random devices on VMS, yet... */
00342 #    undef DEVRANDOM
00343   /* We need to do this since VMS has the following coding on status codes:
00344 
00345      Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
00346                The important thing to know is that odd numbers are considered
00347                good, while even ones are considered errors.
00348      Bits 3-15: actual status number
00349      Bits 16-27: facility number.  0 is considered "unknown"
00350      Bits 28-31: control bits.  If bit 28 is set, the shell won't try to
00351                  output the message (which, for random codes, just looks ugly)
00352 
00353      So, what we do here is to change 0 to 1 to get the default success status,
00354      and everything else is shifted up to fit into the status number field, and
00355      the status is tagged as an error, which I believe is what is wanted here.
00356      -- Richard Levitte
00357   */
00358 #    define EXIT(n)             do { int __VMS_EXIT = n; \
00359                                      if (__VMS_EXIT == 0) \
00360                                        __VMS_EXIT = 1; \
00361                                      else \
00362                                        __VMS_EXIT = (n << 3) | 2; \
00363                                      __VMS_EXIT |= 0x10000000; \
00364                                      exit(__VMS_EXIT); } while(0)
00365 #    define NO_SYS_PARAM_H
00366 
00367 #  elif defined(OPENSSL_SYS_NETWARE)
00368 #    include <fcntl.h>
00369 #    include <unistd.h>
00370 #    define NO_SYS_TYPES_H
00371 #    undef  DEVRANDOM
00372 #    ifdef NETWARE_CLIB
00373 #      define getpid GetThreadID
00374 #    endif
00375 #    define NO_SYSLOG
00376 #    define _setmode setmode
00377 #    define _kbhit kbhit
00378 #    define _O_TEXT O_TEXT
00379 #    define _O_BINARY O_BINARY
00380 #    define OPENSSL_CONF   "openssl.cnf"
00381 #    define SSLEAY_CONF    OPENSSL_CONF
00382 #    define RFILE    ".rnd"
00383 #    define LIST_SEPARATOR_CHAR ';'
00384 #    define EXIT(n)  { if (n) printf("ERROR: %d\n", (int)n); exit(n); }
00385 
00386 #  else
00387      /* !defined VMS */
00388 #    ifdef OPENSSL_SYS_MPE
00389 #      define NO_SYS_PARAM_H
00390 #    endif
00391 #    ifdef OPENSSL_UNISTD
00392 #      include OPENSSL_UNISTD
00393 #    else
00394 #      include <unistd.h>
00395 #    endif
00396 #    ifndef NO_SYS_TYPES_H
00397 #      include <sys/types.h>
00398 #    endif
00399 #    if defined(NeXT) || defined(OPENSSL_SYS_NEWS4)
00400 #      define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP
00401                          * (unless when compiling with -D_POSIX_SOURCE,
00402                          * which doesn't work for us) */
00403 #    endif
00404 #    if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)
00405 #      define ssize_t int /* ditto */
00406 #    endif
00407 #    ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */
00408 #      define setvbuf(a, b, c, d) setbuffer((a), (b), (d))
00409        typedef unsigned long clock_t;
00410 #    endif
00411 
00412 #    define OPENSSL_CONF        "openssl.cnf"
00413 #    define SSLEAY_CONF         OPENSSL_CONF
00414 #    define RFILE               ".rnd"
00415 #    define LIST_SEPARATOR_CHAR ':'
00416 #    define NUL_DEV             "/dev/null"
00417 #    define EXIT(n)             exit(n)
00418 #  endif
00419 
00420 #  define SSLeay_getpid()       getpid()
00421 
00422 #endif
00423 
00424 
00425 /*************/
00426 
00427 #ifdef USE_SOCKETS
00428 #  if defined(WINDOWS) || defined(MSDOS)
00429       /* windows world */
00430 
00431 #    ifdef OPENSSL_NO_SOCK
00432 #      define SSLeay_Write(a,b,c)       (-1)
00433 #      define SSLeay_Read(a,b,c)        (-1)
00434 #      define SHUTDOWN(fd)              close(fd)
00435 #      define SHUTDOWN2(fd)             close(fd)
00436 #    elif !defined(__DJGPP__)
00437 #      include <winsock.h>
00438 extern HINSTANCE _hInstance;
00439 #      ifdef _WIN64
00440 /*
00441  * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
00442  * the value constitutes an index in per-process table of limited size
00443  * and not a real pointer.
00444  */
00445 #        define socket(d,t,p)   ((int)socket(d,t,p))
00446 #        define accept(s,f,l)   ((int)accept(s,f,l))
00447 #      endif
00448 #      define SSLeay_Write(a,b,c)       send((a),(b),(c),0)
00449 #      define SSLeay_Read(a,b,c)        recv((a),(b),(c),0)
00450 #      define SHUTDOWN(fd)              { shutdown((fd),0); closesocket(fd); }
00451 #      define SHUTDOWN2(fd)             { shutdown((fd),2); closesocket(fd); }
00452 #    else
00453 #      define SSLeay_Write(a,b,c)       write_s(a,b,c,0)
00454 #      define SSLeay_Read(a,b,c)        read_s(a,b,c)
00455 #      define SHUTDOWN(fd)              close_s(fd)
00456 #      define SHUTDOWN2(fd)             close_s(fd)
00457 #    endif
00458 
00459 #  elif defined(MAC_OS_pre_X)
00460 
00461 #    include "MacSocket.h"
00462 #    define SSLeay_Write(a,b,c)         MacSocket_send((a),(b),(c))
00463 #    define SSLeay_Read(a,b,c)          MacSocket_recv((a),(b),(c),true)
00464 #    define SHUTDOWN(fd)                MacSocket_close(fd)
00465 #    define SHUTDOWN2(fd)               MacSocket_close(fd)
00466 
00467 #  elif defined(OPENSSL_SYS_NETWARE)
00468          /* NetWare uses the WinSock2 interfaces by default, but can be configured for BSD
00469          */
00470 #      if defined(NETWARE_BSDSOCK)
00471 #        include <sys/socket.h>
00472 #        include <netinet/in.h>
00473 #        include <sys/time.h>
00474 #        include <sys/select.h>
00475 #        define INVALID_SOCKET (int)(~0)
00476 #      else
00477 #        include <novsock2.h>
00478 #      endif
00479 #      define SSLeay_Write(a,b,c)   send((a),(b),(c),0)
00480 #      define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
00481 #      define SHUTDOWN(fd)    { shutdown((fd),0); closesocket(fd); }
00482 #      define SHUTDOWN2(fd)      { shutdown((fd),2); closesocket(fd); }
00483 
00484 #  else
00485 
00486 #    ifndef NO_SYS_PARAM_H
00487 #      include <sys/param.h>
00488 #    endif
00489 #    ifdef OPENSSL_SYS_VXWORKS
00490 #      include <time.h> 
00491 #    elif !defined(OPENSSL_SYS_MPE)
00492 #      include <sys/time.h> /* Needed under linux for FD_XXX */
00493 #    endif
00494 
00495 #    include <netdb.h>
00496 #    if defined(OPENSSL_SYS_VMS_NODECC)
00497 #      include <socket.h>
00498 #      include <in.h>
00499 #      include <inet.h>
00500 #    else
00501 #      include <sys/socket.h>
00502 #      ifdef FILIO_H
00503 #        include <sys/filio.h> /* Added for FIONBIO under unixware */
00504 #      endif
00505 #      include <netinet/in.h>
00506 #      include <arpa/inet.h>
00507 #    endif
00508 
00509 #    if defined(NeXT) || defined(_NEXT_SOURCE)
00510 #      include <sys/fcntl.h>
00511 #      include <sys/types.h>
00512 #    endif
00513 
00514 #    ifdef OPENSSL_SYS_AIX
00515 #      include <sys/select.h>
00516 #    endif
00517 
00518 #    ifdef __QNX__
00519 #      include <sys/select.h>
00520 #    endif
00521 
00522 #    if defined(sun)
00523 #      include <sys/filio.h>
00524 #    else
00525 #      ifndef VMS
00526 #        include <sys/ioctl.h>
00527 #      else
00528          /* ioctl is only in VMS > 7.0 and when socketshr is not used */
00529 #        if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
00530 #          include <sys/ioctl.h>
00531 #        endif
00532 #      endif
00533 #    endif
00534 
00535 #    ifdef VMS
00536 #      include <unixio.h>
00537 #      if defined(TCPIP_TYPE_SOCKETSHR)
00538 #        include <socketshr.h>
00539 #      endif
00540 #    endif
00541 
00542 #    define SSLeay_Read(a,b,c)     read((a),(b),(c))
00543 #    define SSLeay_Write(a,b,c)    write((a),(b),(c))
00544 #    define SHUTDOWN(fd)    { shutdown((fd),0); closesocket((fd)); }
00545 #    define SHUTDOWN2(fd)   { shutdown((fd),2); closesocket((fd)); }
00546 #    ifndef INVALID_SOCKET
00547 #    define INVALID_SOCKET      (-1)
00548 #    endif /* INVALID_SOCKET */
00549 #  endif
00550 #endif
00551 
00552 #if defined(__ultrix)
00553 #  ifndef ssize_t
00554 #    define ssize_t int 
00555 #  endif
00556 #endif
00557 
00558 #if defined(sun) && !defined(__svr4__) && !defined(__SVR4)
00559   /* include headers first, so our defines don't break it */
00560 #include <stdlib.h>
00561 #include <string.h>
00562   /* bcopy can handle overlapping moves according to SunOS 4.1.4 manpage */
00563 # define memmove(s1,s2,n) bcopy((s2),(s1),(n))
00564 # define strtoul(s,e,b) ((unsigned long int)strtol((s),(e),(b)))
00565 extern char *sys_errlist[]; extern int sys_nerr;
00566 # define strerror(errnum) \
00567         (((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum])
00568   /* Being signed SunOS 4.x memcpy breaks ASN1_OBJECT table lookup */
00569 #include "crypto/o_str.h"
00570 # define memcmp OPENSSL_memcmp
00571 #endif
00572 
00573 #ifndef OPENSSL_EXIT
00574 # if defined(MONOLITH) && !defined(OPENSSL_C)
00575 #  define OPENSSL_EXIT(n) return(n)
00576 # else
00577 #  define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
00578 # endif
00579 #endif
00580 
00581 /***********************************************/
00582 
00583 /* do we need to do this for getenv.
00584  * Just define getenv for use under windows */
00585 
00586 #ifdef WIN16
00587 /* How to do this needs to be thought out a bit more.... */
00588 /*char *GETENV(char *);
00589 #define Getenv  GETENV*/
00590 #define Getenv  getenv
00591 #else
00592 #define Getenv getenv
00593 #endif
00594 
00595 #define DG_GCC_BUG      /* gcc < 2.6.3 on DGUX */
00596 
00597 #ifdef sgi
00598 #define IRIX_CC_BUG     /* all version of IRIX I've tested (4.* 5.*) */
00599 #endif
00600 #ifdef OPENSSL_SYS_SNI
00601 #define IRIX_CC_BUG     /* CDS++ up to V2.0Bsomething suffered from the same bug.*/
00602 #endif
00603 
00604 #if defined(OPENSSL_SYS_WINDOWS)
00605 #  define strcasecmp _stricmp
00606 #  define strncasecmp _strnicmp
00607 #elif defined(OPENSSL_SYS_VMS)
00608 /* VMS below version 7.0 doesn't have strcasecmp() */
00609 #  include "o_str.h"
00610 #  define strcasecmp OPENSSL_strcasecmp
00611 #  define strncasecmp OPENSSL_strncasecmp
00612 #  define OPENSSL_IMPLEMENTS_strncasecmp
00613 #elif defined(OPENSSL_SYS_OS2) && defined(__EMX__)
00614 #  define strcasecmp stricmp
00615 #  define strncasecmp strnicmp
00616 #elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
00617 #  define strcasecmp stricmp
00618 #  define strncasecmp strnicmp
00619 #else
00620 #  ifdef NO_STRINGS_H
00621     int strcasecmp();
00622     int strncasecmp();
00623 #  else
00624 #    include <strings.h>
00625 #  endif /* NO_STRINGS_H */
00626 #endif
00627 
00628 #if defined(OPENSSL_SYS_OS2) && defined(__EMX__)
00629 # include <io.h>
00630 # include <fcntl.h>
00631 # define NO_SYSLOG
00632 #endif
00633 
00634 /* vxworks */
00635 #if defined(OPENSSL_SYS_VXWORKS)
00636 #include <ioLib.h>
00637 #include <tickLib.h>
00638 #include <sysLib.h>
00639 
00640 #define TTY_STRUCT int
00641 
00642 #define sleep(a) taskDelay((a) * sysClkRateGet())
00643 
00644 #include <vxWorks.h>
00645 #include <sockLib.h>
00646 #include <taskLib.h>
00647 
00648 #define getpid taskIdSelf
00649 
00650 /* NOTE: these are implemented by helpers in database app!
00651  * if the database is not linked, we need to implement them
00652  * elswhere */
00653 struct hostent *gethostbyname(const char *name);
00654 struct hostent *gethostbyaddr(const char *addr, int length, int type);
00655 struct servent *getservbyname(const char *name, const char *proto);
00656 
00657 #endif
00658 /* end vxworks */
00659 
00660 #ifdef  __cplusplus
00661 }
00662 #endif
00663 
00664 #endif
00665 

© sourcejam.com 2005-2008