os/ossrv/ssl/include/e_os.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200 (2014-06-10)
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
sl@0
     1
/* e_os.h */
sl@0
     2
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
sl@0
     3
 * All rights reserved.
sl@0
     4
 *
sl@0
     5
 * This package is an SSL implementation written
sl@0
     6
 * by Eric Young (eay@cryptsoft.com).
sl@0
     7
 * The implementation was written so as to conform with Netscapes SSL.
sl@0
     8
 * 
sl@0
     9
 * This library is free for commercial and non-commercial use as long as
sl@0
    10
 * the following conditions are aheared to.  The following conditions
sl@0
    11
 * apply to all code found in this distribution, be it the RC4, RSA,
sl@0
    12
 * lhash, DES, etc., code; not just the SSL code.  The SSL documentation
sl@0
    13
 * included with this distribution is covered by the same copyright terms
sl@0
    14
 * except that the holder is Tim Hudson (tjh@cryptsoft.com).
sl@0
    15
 * 
sl@0
    16
 * Copyright remains Eric Young's, and as such any Copyright notices in
sl@0
    17
 * the code are not to be removed.
sl@0
    18
 * If this package is used in a product, Eric Young should be given attribution
sl@0
    19
 * as the author of the parts of the library used.
sl@0
    20
 * This can be in the form of a textual message at program startup or
sl@0
    21
 * in documentation (online or textual) provided with the package.
sl@0
    22
 * 
sl@0
    23
 * Redistribution and use in source and binary forms, with or without
sl@0
    24
 * modification, are permitted provided that the following conditions
sl@0
    25
 * are met:
sl@0
    26
 * 1. Redistributions of source code must retain the copyright
sl@0
    27
 *    notice, this list of conditions and the following disclaimer.
sl@0
    28
 * 2. Redistributions in binary form must reproduce the above copyright
sl@0
    29
 *    notice, this list of conditions and the following disclaimer in the
sl@0
    30
 *    documentation and/or other materials provided with the distribution.
sl@0
    31
 * 3. All advertising materials mentioning features or use of this software
sl@0
    32
 *    must display the following acknowledgement:
sl@0
    33
 *    "This product includes cryptographic software written by
sl@0
    34
 *     Eric Young (eay@cryptsoft.com)"
sl@0
    35
 *    The word 'cryptographic' can be left out if the rouines from the library
sl@0
    36
 *    being used are not cryptographic related :-).
sl@0
    37
 * 4. If you include any Windows specific code (or a derivative thereof) from 
sl@0
    38
 *    the apps directory (application code) you must include an acknowledgement:
sl@0
    39
 *    "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
sl@0
    40
 * 
sl@0
    41
 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
sl@0
    42
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
sl@0
    43
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
sl@0
    44
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
sl@0
    45
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
sl@0
    46
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
sl@0
    47
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
sl@0
    48
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
sl@0
    49
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
sl@0
    50
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
sl@0
    51
 * SUCH DAMAGE.
sl@0
    52
 * 
sl@0
    53
 * The licence and distribution terms for any publically available version or
sl@0
    54
 * derivative of this code cannot be changed.  i.e. this code cannot simply be
sl@0
    55
 * copied and put under another distribution licence
sl@0
    56
 * [including the GNU Public Licence.]
sl@0
    57
 */
sl@0
    58
sl@0
    59
#ifndef HEADER_E_OS_H
sl@0
    60
#define HEADER_E_OS_H
sl@0
    61
sl@0
    62
#include <openssl/opensslconf.h>
sl@0
    63
sl@0
    64
#include <openssl/e_os2.h>
sl@0
    65
/* <openssl/e_os2.h> contains what we can justify to make visible
sl@0
    66
 * to the outside; this file e_os.h is not part of the exported
sl@0
    67
 * interface. */
sl@0
    68
sl@0
    69
#ifdef  __cplusplus
sl@0
    70
extern "C" {
sl@0
    71
#endif
sl@0
    72
sl@0
    73
/* Used to checking reference counts, most while doing perl5 stuff :-) */
sl@0
    74
#ifdef REF_PRINT
sl@0
    75
#undef REF_PRINT
sl@0
    76
#define REF_PRINT(a,b)	fprintf(stderr,"%08X:%4d:%s\n",(int)b,b->references,a)
sl@0
    77
#endif
sl@0
    78
sl@0
    79
#ifndef DEVRANDOM
sl@0
    80
/* set this to a comma-separated list of 'random' device files to try out.
sl@0
    81
 * My default, we will try to read at least one of these files */
sl@0
    82
#define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom"
sl@0
    83
#endif
sl@0
    84
#ifndef DEVRANDOM_EGD
sl@0
    85
/* set this to a comma-seperated list of 'egd' sockets to try out. These
sl@0
    86
 * sockets will be tried in the order listed in case accessing the device files
sl@0
    87
 * listed in DEVRANDOM did not return enough entropy. */
sl@0
    88
#define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"
sl@0
    89
#endif
sl@0
    90
sl@0
    91
#if defined(OPENSSL_SYS_VXWORKS)
sl@0
    92
#  define NO_SYS_PARAM_H
sl@0
    93
#  define NO_CHMOD
sl@0
    94
#  define NO_SYSLOG
sl@0
    95
#endif
sl@0
    96
  
sl@0
    97
#if defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
sl@0
    98
# if macintosh==1
sl@0
    99
#  ifndef MAC_OS_GUSI_SOURCE
sl@0
   100
#    define MAC_OS_pre_X
sl@0
   101
#    define NO_SYS_TYPES_H
sl@0
   102
     typedef long ssize_t;
sl@0
   103
#  endif
sl@0
   104
#  define NO_SYS_PARAM_H
sl@0
   105
#  define NO_CHMOD
sl@0
   106
#  define NO_SYSLOG
sl@0
   107
#  undef  DEVRANDOM
sl@0
   108
#  define GETPID_IS_MEANINGLESS
sl@0
   109
# endif
sl@0
   110
#endif
sl@0
   111
sl@0
   112
/********************************************************************
sl@0
   113
 The Microsoft section
sl@0
   114
 ********************************************************************/
sl@0
   115
/* The following is used becaue of the small stack in some
sl@0
   116
 * Microsoft operating systems */
sl@0
   117
#if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYSNAME_WIN32)&&!defined(SYMBIAN)
sl@0
   118
#  define MS_STATIC	static
sl@0
   119
#else
sl@0
   120
#  define MS_STATIC
sl@0
   121
#endif
sl@0
   122
sl@0
   123
#if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
sl@0
   124
#  define WIN32
sl@0
   125
#endif
sl@0
   126
#if defined(OPENSSL_SYS_WIN16) && !defined(WIN16)
sl@0
   127
#  definess WIN16
sl@0
   128
#endif
sl@0
   129
#if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
sl@0
   130
#  define WINDOWS
sl@0
   131
#endif
sl@0
   132
#if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
sl@0
   133
#  define MSDOS
sl@0
   134
#endif
sl@0
   135
sl@0
   136
#if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)&&!defined(SYMBIAN)
sl@0
   137
#  define GETPID_IS_MEANINGLESS
sl@0
   138
#endif
sl@0
   139
sl@0
   140
#if defined(WIN32)&&!defined(SYMBIAN)
sl@0
   141
#define get_last_sys_error()	GetLastError()
sl@0
   142
#define clear_sys_error()	SetLastError(0)
sl@0
   143
#if !defined(WINNT)
sl@0
   144
#define WIN_CONSOLE_BUG
sl@0
   145
#endif
sl@0
   146
#else
sl@0
   147
#define get_last_sys_error()	errno
sl@0
   148
#define clear_sys_error()	errno=0
sl@0
   149
#endif
sl@0
   150
sl@0
   151
#if defined(WINDOWS)&&!defined(SYMBIAN)
sl@0
   152
#define get_last_socket_error()	WSAGetLastError()
sl@0
   153
#define clear_socket_error()	WSASetLastError(0)
sl@0
   154
#define readsocket(s,b,n)	recv((s),(b),(n),0)
sl@0
   155
#define writesocket(s,b,n)	send((s),(b),(n),0)
sl@0
   156
#define EADDRINUSE		WSAEADDRINUSE
sl@0
   157
#elif defined(__DJGPP__)
sl@0
   158
#define WATT32
sl@0
   159
#define get_last_socket_error()	errno
sl@0
   160
#define clear_socket_error()	errno=0
sl@0
   161
#define closesocket(s)		close_s(s)
sl@0
   162
#define readsocket(s,b,n)	read_s(s,b,n)
sl@0
   163
#define writesocket(s,b,n)	send(s,b,n,0)
sl@0
   164
#elif defined(MAC_OS_pre_X)
sl@0
   165
#define get_last_socket_error()	errno
sl@0
   166
#define clear_socket_error()	errno=0
sl@0
   167
#define closesocket(s)		MacSocket_close(s)
sl@0
   168
#define readsocket(s,b,n)	MacSocket_recv((s),(b),(n),true)
sl@0
   169
#define writesocket(s,b,n)	MacSocket_send((s),(b),(n))
sl@0
   170
#elif defined(OPENSSL_SYS_VMS)
sl@0
   171
#define get_last_socket_error() errno
sl@0
   172
#define clear_socket_error()    errno=0
sl@0
   173
#define ioctlsocket(a,b,c)      ioctl(a,b,c)
sl@0
   174
#define closesocket(s)          close(s)
sl@0
   175
#define readsocket(s,b,n)       recv((s),(b),(n),0)
sl@0
   176
#define writesocket(s,b,n)      send((s),(b),(n),0)
sl@0
   177
#elif defined(OPENSSL_SYS_VXWORKS)
sl@0
   178
#define get_last_socket_error()	errno
sl@0
   179
#define clear_socket_error()	errno=0
sl@0
   180
#define ioctlsocket(a,b,c)	    ioctl((a),(b),(int)(c))
sl@0
   181
#define closesocket(s)		    close(s)
sl@0
   182
#define readsocket(s,b,n)	    read((s),(b),(n))
sl@0
   183
#define writesocket(s,b,n)	    write((s),(char *)(b),(n))
sl@0
   184
#elif defined(OPENSSL_SYS_NETWARE)
sl@0
   185
#if defined(NETWARE_BSDSOCK)
sl@0
   186
#define get_last_socket_error() errno
sl@0
   187
#define clear_socket_error()    errno=0
sl@0
   188
#define closesocket(s)          close(s)
sl@0
   189
#define readsocket(s,b,n)       recv((s),(b),(n),0)
sl@0
   190
#define writesocket(s,b,n)      send((s),(b),(n),0)
sl@0
   191
#else
sl@0
   192
#define get_last_socket_error()	WSAGetLastError()
sl@0
   193
#define clear_socket_error()	WSASetLastError(0)
sl@0
   194
#define readsocket(s,b,n)		recv((s),(b),(n),0)
sl@0
   195
#define writesocket(s,b,n)		send((s),(b),(n),0)
sl@0
   196
#endif
sl@0
   197
#else
sl@0
   198
#define get_last_socket_error()	errno
sl@0
   199
#define clear_socket_error()	errno=0
sl@0
   200
#define ioctlsocket(a,b,c)	ioctl(a,b,c)
sl@0
   201
#define closesocket(s)		close(s)
sl@0
   202
#define readsocket(s,b,n)	read((s),(b),(n))
sl@0
   203
#define writesocket(s,b,n)	write((s),(b),(n))
sl@0
   204
#endif
sl@0
   205
sl@0
   206
#if defined(WIN16)&&!defined(SYMBIAN)
sl@0
   207
#  define MS_CALLBACK	_far _loadds
sl@0
   208
#  define MS_FAR	_far
sl@0
   209
#else
sl@0
   210
#  define MS_CALLBACK
sl@0
   211
#  define MS_FAR
sl@0
   212
#endif
sl@0
   213
sl@0
   214
#ifdef OPENSSL_NO_STDIO
sl@0
   215
#  undef OPENSSL_NO_FP_API
sl@0
   216
#  define OPENSSL_NO_FP_API
sl@0
   217
#endif
sl@0
   218
sl@0
   219
#if (defined(WINDOWS) || defined(MSDOS) && !defined(SYMBIAN))
sl@0
   220
sl@0
   221
#  ifdef __DJGPP__
sl@0
   222
#    include <unistd.h>
sl@0
   223
#    include <sys/stat.h>
sl@0
   224
#    include <sys/socket.h>
sl@0
   225
#    include <tcp.h>
sl@0
   226
#    include <netdb.h>
sl@0
   227
#    define _setmode setmode
sl@0
   228
#    define _O_TEXT O_TEXT
sl@0
   229
#    define _O_BINARY O_BINARY
sl@0
   230
#    undef DEVRANDOM
sl@0
   231
#    define DEVRANDOM "/dev/urandom\x24"
sl@0
   232
#  endif /* __DJGPP__ */
sl@0
   233
sl@0
   234
#  ifndef S_IFDIR
sl@0
   235
#    define S_IFDIR	_S_IFDIR
sl@0
   236
#  endif
sl@0
   237
sl@0
   238
#  ifndef S_IFMT
sl@0
   239
#    define S_IFMT	_S_IFMT
sl@0
   240
#  endif
sl@0
   241
sl@0
   242
#  if !defined(WINNT) && !defined(__DJGPP__)
sl@0
   243
#    define NO_SYSLOG
sl@0
   244
#  endif
sl@0
   245
#  define NO_DIRENT
sl@0
   246
sl@0
   247
#  ifdef WINDOWS
sl@0
   248
#    if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
sl@0
   249
       /*
sl@0
   250
	* Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
sl@0
   251
	* Most notably we ought to check for availability of each specific
sl@0
   252
	* routine with GetProcAddress() and/or quard NT-specific calls with
sl@0
   253
	* GetVersion() < 0x80000000. One can argue that in latter "or" case
sl@0
   254
	* we ought to /DELAYLOAD some .DLLs in order to protect ourselves
sl@0
   255
	* against run-time link errors. This doesn't seem to be necessary,
sl@0
   256
	* because it turned out that already Windows 95, first non-NT Win32
sl@0
   257
	* implementation, is equipped with at least NT 3.51 stubs, dummy
sl@0
   258
	* routines with same name, but which do nothing. Meaning that it's
sl@0
   259
	* apparently appropriate to guard generic NT calls with GetVersion
sl@0
   260
	* alone, while NT 4.0 and above calls ought to be additionally
sl@0
   261
	* checked upon with GetProcAddress.
sl@0
   262
	*/
sl@0
   263
#      define _WIN32_WINNT 0x0400
sl@0
   264
#    endif
sl@0
   265
#    include <windows.h>
sl@0
   266
#    include <stddef.h>
sl@0
   267
#    include <errno.h>
sl@0
   268
#    include <string.h>
sl@0
   269
#    ifdef _WIN64
sl@0
   270
#      define strlen(s) _strlen31(s)
sl@0
   271
/* cut strings to 2GB */
sl@0
   272
static unsigned int _strlen31(const char *str)
sl@0
   273
	{
sl@0
   274
	unsigned int len=0;
sl@0
   275
	while (*str && len<0x80000000U) str++, len++;
sl@0
   276
	return len&0x7FFFFFFF;
sl@0
   277
	}
sl@0
   278
#    endif
sl@0
   279
#    include <malloc.h>
sl@0
   280
#  endif
sl@0
   281
#  include <io.h>
sl@0
   282
#  include <fcntl.h>
sl@0
   283
sl@0
   284
#  ifdef OPENSSL_SYS_WINCE
sl@0
   285
#    include <winsock_extras.h>
sl@0
   286
#  endif
sl@0
   287
sl@0
   288
#  define ssize_t long
sl@0
   289
sl@0
   290
#  if defined (__BORLANDC__)
sl@0
   291
#    define _setmode setmode
sl@0
   292
#    define _O_TEXT O_TEXT
sl@0
   293
#    define _O_BINARY O_BINARY
sl@0
   294
#    define _int64 __int64
sl@0
   295
#    define _kbhit kbhit
sl@0
   296
#  endif
sl@0
   297
sl@0
   298
#  if defined(WIN16) && defined(SSLEAY) && defined(_WINEXITNOPERSIST)
sl@0
   299
#    define EXIT(n) _wsetexit(_WINEXITNOPERSIST)
sl@0
   300
#    define OPENSSL_EXIT(n) do { if (n == 0) EXIT(n); return(n); } while(0)
sl@0
   301
#  else
sl@0
   302
#    define EXIT(n) exit(n)
sl@0
   303
#  endif
sl@0
   304
#  define LIST_SEPARATOR_CHAR ';'
sl@0
   305
#  ifndef X_OK
sl@0
   306
#    define X_OK	0
sl@0
   307
#  endif
sl@0
   308
#  ifndef W_OK
sl@0
   309
#    define W_OK	2
sl@0
   310
#  endif
sl@0
   311
#  ifndef R_OK
sl@0
   312
#    define R_OK	4
sl@0
   313
#  endif
sl@0
   314
#  define OPENSSL_CONF	"openssl.cnf"
sl@0
   315
#  define SSLEAY_CONF	OPENSSL_CONF
sl@0
   316
#  define NUL_DEV	"nul"
sl@0
   317
#  define RFILE		".rnd"
sl@0
   318
#  ifdef OPENSSL_SYS_WINCE
sl@0
   319
#    define DEFAULT_HOME  ""
sl@0
   320
#  else
sl@0
   321
#    define DEFAULT_HOME  "C:"
sl@0
   322
#  endif
sl@0
   323
sl@0
   324
#else /* The non-microsoft world world */
sl@0
   325
sl@0
   326
#  ifdef OPENSSL_SYS_VMS
sl@0
   327
#    define VMS 1
sl@0
   328
  /* some programs don't include stdlib, so exit() and others give implicit 
sl@0
   329
     function warnings */
sl@0
   330
#    include <stdlib.h>
sl@0
   331
#    if defined(__DECC)
sl@0
   332
#      include <unistd.h>
sl@0
   333
#    else
sl@0
   334
#      include <unixlib.h>
sl@0
   335
#    endif
sl@0
   336
#    define OPENSSL_CONF	"openssl.cnf"
sl@0
   337
#    define SSLEAY_CONF		OPENSSL_CONF
sl@0
   338
#    define RFILE		".rnd"
sl@0
   339
#    define LIST_SEPARATOR_CHAR ','
sl@0
   340
#    define NUL_DEV		"NLA0:"
sl@0
   341
  /* We don't have any well-defined random devices on VMS, yet... */
sl@0
   342
#    undef DEVRANDOM
sl@0
   343
  /* We need to do this since VMS has the following coding on status codes:
sl@0
   344
sl@0
   345
     Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
sl@0
   346
               The important thing to know is that odd numbers are considered
sl@0
   347
	       good, while even ones are considered errors.
sl@0
   348
     Bits 3-15: actual status number
sl@0
   349
     Bits 16-27: facility number.  0 is considered "unknown"
sl@0
   350
     Bits 28-31: control bits.  If bit 28 is set, the shell won't try to
sl@0
   351
                 output the message (which, for random codes, just looks ugly)
sl@0
   352
sl@0
   353
     So, what we do here is to change 0 to 1 to get the default success status,
sl@0
   354
     and everything else is shifted up to fit into the status number field, and
sl@0
   355
     the status is tagged as an error, which I believe is what is wanted here.
sl@0
   356
     -- Richard Levitte
sl@0
   357
  */
sl@0
   358
#    define EXIT(n)		do { int __VMS_EXIT = n; \
sl@0
   359
                                     if (__VMS_EXIT == 0) \
sl@0
   360
				       __VMS_EXIT = 1; \
sl@0
   361
				     else \
sl@0
   362
				       __VMS_EXIT = (n << 3) | 2; \
sl@0
   363
                                     __VMS_EXIT |= 0x10000000; \
sl@0
   364
				     exit(__VMS_EXIT); } while(0)
sl@0
   365
#    define NO_SYS_PARAM_H
sl@0
   366
sl@0
   367
#  elif defined(OPENSSL_SYS_NETWARE)
sl@0
   368
#    include <fcntl.h>
sl@0
   369
#    include <unistd.h>
sl@0
   370
#    define NO_SYS_TYPES_H
sl@0
   371
#    undef  DEVRANDOM
sl@0
   372
#    ifdef NETWARE_CLIB
sl@0
   373
#      define getpid GetThreadID
sl@0
   374
#    endif
sl@0
   375
#    define NO_SYSLOG
sl@0
   376
#    define _setmode setmode
sl@0
   377
#    define _kbhit kbhit
sl@0
   378
#    define _O_TEXT O_TEXT
sl@0
   379
#    define _O_BINARY O_BINARY
sl@0
   380
#    define OPENSSL_CONF   "openssl.cnf"
sl@0
   381
#    define SSLEAY_CONF    OPENSSL_CONF
sl@0
   382
#    define RFILE    ".rnd"
sl@0
   383
#    define LIST_SEPARATOR_CHAR ';'
sl@0
   384
#    define EXIT(n)  { if (n) printf("ERROR: %d\n", (int)n); exit(n); }
sl@0
   385
sl@0
   386
#  else
sl@0
   387
    /* !defined VMS */
sl@0
   388
#    ifdef OPENSSL_SYS_MPE
sl@0
   389
#      define NO_SYS_PARAM_H
sl@0
   390
#    endif
sl@0
   391
#    ifdef OPENSSL_UNISTD
sl@0
   392
#      include OPENSSL_UNISTD
sl@0
   393
#    else
sl@0
   394
#      include <unistd.h>
sl@0
   395
#    endif
sl@0
   396
#    ifndef NO_SYS_TYPES_H
sl@0
   397
#      include <sys/types.h>
sl@0
   398
#    endif
sl@0
   399
#    if defined(NeXT) || defined(OPENSSL_SYS_NEWS4)
sl@0
   400
#      define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP
sl@0
   401
                         * (unless when compiling with -D_POSIX_SOURCE,
sl@0
   402
                         * which doesn't work for us) */
sl@0
   403
#    endif
sl@0
   404
#    if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)
sl@0
   405
#      define ssize_t int /* ditto */
sl@0
   406
#    endif
sl@0
   407
#    ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */
sl@0
   408
#      define setvbuf(a, b, c, d) setbuffer((a), (b), (d))
sl@0
   409
       typedef unsigned long clock_t;
sl@0
   410
#    endif
sl@0
   411
sl@0
   412
#    define OPENSSL_CONF	"openssl.cnf"
sl@0
   413
#    define SSLEAY_CONF		OPENSSL_CONF
sl@0
   414
#    define RFILE		".rnd"
sl@0
   415
#    define LIST_SEPARATOR_CHAR ':'
sl@0
   416
#    define NUL_DEV		"/dev/null"
sl@0
   417
#    define EXIT(n)		exit(n)
sl@0
   418
#  endif
sl@0
   419
sl@0
   420
#  define SSLeay_getpid()	getpid()
sl@0
   421
sl@0
   422
#endif
sl@0
   423
sl@0
   424
sl@0
   425
/*************/
sl@0
   426
sl@0
   427
#ifdef USE_SOCKETS
sl@0
   428
#  if defined(WINDOWS) || defined(MSDOS) && !defined(SYMBIAN)
sl@0
   429
      /* windows world */
sl@0
   430
sl@0
   431
#    ifdef OPENSSL_NO_SOCK
sl@0
   432
#      define SSLeay_Write(a,b,c)	(-1)
sl@0
   433
#      define SSLeay_Read(a,b,c)	(-1)
sl@0
   434
#      define SHUTDOWN(fd)		close(fd)
sl@0
   435
#      define SHUTDOWN2(fd)		close(fd)
sl@0
   436
#    elif !defined(__DJGPP__)
sl@0
   437
#      include <winsock.h>
sl@0
   438
extern HINSTANCE _hInstance;
sl@0
   439
#      ifdef _WIN64
sl@0
   440
/*
sl@0
   441
 * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
sl@0
   442
 * the value constitutes an index in per-process table of limited size
sl@0
   443
 * and not a real pointer.
sl@0
   444
 */
sl@0
   445
#        define socket(d,t,p)	((int)socket(d,t,p))
sl@0
   446
#        define accept(s,f,l)	((int)accept(s,f,l))
sl@0
   447
#      endif
sl@0
   448
#      define SSLeay_Write(a,b,c)	send((a),(b),(c),0)
sl@0
   449
#      define SSLeay_Read(a,b,c)	recv((a),(b),(c),0)
sl@0
   450
#      define SHUTDOWN(fd)		{ shutdown((fd),0); closesocket(fd); }
sl@0
   451
#      define SHUTDOWN2(fd)		{ shutdown((fd),2); closesocket(fd); }
sl@0
   452
#    else
sl@0
   453
#      define SSLeay_Write(a,b,c)	write_s(a,b,c,0)
sl@0
   454
#      define SSLeay_Read(a,b,c)	read_s(a,b,c)
sl@0
   455
#      define SHUTDOWN(fd)		close_s(fd)
sl@0
   456
#      define SHUTDOWN2(fd)		close_s(fd)
sl@0
   457
#    endif
sl@0
   458
sl@0
   459
#  elif defined(MAC_OS_pre_X)
sl@0
   460
sl@0
   461
#    include "MacSocket.h"
sl@0
   462
#    define SSLeay_Write(a,b,c)		MacSocket_send((a),(b),(c))
sl@0
   463
#    define SSLeay_Read(a,b,c)		MacSocket_recv((a),(b),(c),true)
sl@0
   464
#    define SHUTDOWN(fd)		MacSocket_close(fd)
sl@0
   465
#    define SHUTDOWN2(fd)		MacSocket_close(fd)
sl@0
   466
sl@0
   467
#  elif defined(OPENSSL_SYS_NETWARE)
sl@0
   468
         /* NetWare uses the WinSock2 interfaces by default, but can be configured for BSD
sl@0
   469
         */
sl@0
   470
#      if defined(NETWARE_BSDSOCK)
sl@0
   471
#        include <sys/socket.h>
sl@0
   472
#        include <netinet/in.h>
sl@0
   473
#        include <sys/time.h>
sl@0
   474
#        include <sys/select.h>
sl@0
   475
#        define INVALID_SOCKET (int)(~0)
sl@0
   476
#      else
sl@0
   477
#        include <novsock2.h>
sl@0
   478
#      endif
sl@0
   479
#      define SSLeay_Write(a,b,c)   send((a),(b),(c),0)
sl@0
   480
#      define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
sl@0
   481
#      define SHUTDOWN(fd)    { shutdown((fd),0); closesocket(fd); }
sl@0
   482
#      define SHUTDOWN2(fd)      { shutdown((fd),2); closesocket(fd); }
sl@0
   483
sl@0
   484
#  else
sl@0
   485
#    ifndef NO_SYS_PARAM_H
sl@0
   486
#      include <sys/param.h>
sl@0
   487
#    endif
sl@0
   488
#    ifdef OPENSSL_SYS_VXWORKS
sl@0
   489
#      include <time.h> 
sl@0
   490
#    elif !defined(OPENSSL_SYS_MPE)
sl@0
   491
#      include <sys/time.h> /* Needed under linux for FD_XXX */
sl@0
   492
#    endif
sl@0
   493
sl@0
   494
#    include <netdb.h>
sl@0
   495
#    if defined(OPENSSL_SYS_VMS_NODECC)
sl@0
   496
#      include <socket.h>
sl@0
   497
#      include <in.h>
sl@0
   498
#      include <inet.h>
sl@0
   499
#    else
sl@0
   500
#      include <sys/socket.h>
sl@0
   501
#      ifdef FILIO_H
sl@0
   502
#        include <sys/filio.h> /* Added for FIONBIO under unixware */
sl@0
   503
#      endif
sl@0
   504
#      include <netinet/in.h>
sl@0
   505
#      include <arpa/inet.h>
sl@0
   506
#    endif
sl@0
   507
sl@0
   508
#    if defined(NeXT) || defined(_NEXT_SOURCE)
sl@0
   509
#      include <sys/fcntl.h>
sl@0
   510
#      include <sys/types.h>
sl@0
   511
#    endif
sl@0
   512
sl@0
   513
#    ifdef OPENSSL_SYS_AIX
sl@0
   514
#      include <sys/select.h>
sl@0
   515
#    endif
sl@0
   516
sl@0
   517
#    ifdef __QNX__
sl@0
   518
#      include <sys/select.h>
sl@0
   519
#    endif
sl@0
   520
sl@0
   521
#    if defined(sun)
sl@0
   522
#      include <sys/filio.h>
sl@0
   523
#    else
sl@0
   524
#      ifndef VMS
sl@0
   525
#        include <sys/ioctl.h>
sl@0
   526
#      else
sl@0
   527
	 /* ioctl is only in VMS > 7.0 and when socketshr is not used */
sl@0
   528
#        if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
sl@0
   529
#          include <sys/ioctl.h>
sl@0
   530
#        endif
sl@0
   531
#      endif
sl@0
   532
#    endif
sl@0
   533
sl@0
   534
#    ifdef VMS
sl@0
   535
#      include <unixio.h>
sl@0
   536
#      if defined(TCPIP_TYPE_SOCKETSHR)
sl@0
   537
#        include <socketshr.h>
sl@0
   538
#      endif
sl@0
   539
#    endif
sl@0
   540
sl@0
   541
#    define SSLeay_Read(a,b,c)     read((a),(b),(c))
sl@0
   542
#    define SSLeay_Write(a,b,c)    write((a),(b),(c))
sl@0
   543
#    define SHUTDOWN(fd)    { shutdown((fd),0); closesocket((fd)); }
sl@0
   544
#    define SHUTDOWN2(fd)   { shutdown((fd),2); closesocket((fd)); }
sl@0
   545
#    ifndef INVALID_SOCKET
sl@0
   546
#    define INVALID_SOCKET	(-1)
sl@0
   547
#    endif /* INVALID_SOCKET */
sl@0
   548
#  endif
sl@0
   549
#endif
sl@0
   550
sl@0
   551
#if defined(__ultrix)
sl@0
   552
#  ifndef ssize_t
sl@0
   553
#    define ssize_t int 
sl@0
   554
#  endif
sl@0
   555
#endif
sl@0
   556
sl@0
   557
#if defined(sun) && !defined(__svr4__) && !defined(__SVR4)
sl@0
   558
  /* include headers first, so our defines don't break it */
sl@0
   559
#include <stdlib.h>
sl@0
   560
#include <string.h>
sl@0
   561
  /* bcopy can handle overlapping moves according to SunOS 4.1.4 manpage */
sl@0
   562
# define memmove(s1,s2,n) bcopy((s2),(s1),(n))
sl@0
   563
# define strtoul(s,e,b) ((unsigned long int)strtol((s),(e),(b)))
sl@0
   564
extern char *sys_errlist[]; extern int sys_nerr;
sl@0
   565
# define strerror(errnum) \
sl@0
   566
	(((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum])
sl@0
   567
  /* Being signed SunOS 4.x memcpy breaks ASN1_OBJECT table lookup */
sl@0
   568
#include "crypto/o_str.h"
sl@0
   569
# define memcmp OPENSSL_memcmp
sl@0
   570
#endif
sl@0
   571
sl@0
   572
#ifndef OPENSSL_EXIT
sl@0
   573
# if defined(MONOLITH) && !defined(OPENSSL_C)
sl@0
   574
#  define OPENSSL_EXIT(n) return(n)
sl@0
   575
# else
sl@0
   576
#  define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
sl@0
   577
# endif
sl@0
   578
#endif
sl@0
   579
sl@0
   580
/***********************************************/
sl@0
   581
sl@0
   582
/* do we need to do this for getenv.
sl@0
   583
 * Just define getenv for use under windows */
sl@0
   584
sl@0
   585
#if defined(WIN16) && !defined(SYMBIAN)
sl@0
   586
/* How to do this needs to be thought out a bit more.... */
sl@0
   587
/*char *GETENV(char *);
sl@0
   588
#define Getenv	GETENV*/
sl@0
   589
#define Getenv	getenv
sl@0
   590
#else
sl@0
   591
#define Getenv getenv
sl@0
   592
#endif
sl@0
   593
sl@0
   594
#define DG_GCC_BUG	/* gcc < 2.6.3 on DGUX */
sl@0
   595
sl@0
   596
#ifdef sgi
sl@0
   597
#define IRIX_CC_BUG	/* all version of IRIX I've tested (4.* 5.*) */
sl@0
   598
#endif
sl@0
   599
#ifdef OPENSSL_SYS_SNI
sl@0
   600
#define IRIX_CC_BUG	/* CDS++ up to V2.0Bsomething suffered from the same bug.*/
sl@0
   601
#endif
sl@0
   602
sl@0
   603
#if defined(OPENSSL_SYS_WINDOWS)
sl@0
   604
#  define strcasecmp _stricmp
sl@0
   605
#  define strncasecmp _strnicmp
sl@0
   606
#elif defined(OPENSSL_SYS_VMS)
sl@0
   607
/* VMS below version 7.0 doesn't have strcasecmp() */
sl@0
   608
#  include "o_str.h"
sl@0
   609
#  define strcasecmp OPENSSL_strcasecmp
sl@0
   610
#  define strncasecmp OPENSSL_strncasecmp
sl@0
   611
#  define OPENSSL_IMPLEMENTS_strncasecmp
sl@0
   612
#elif defined(OPENSSL_SYS_OS2) && defined(__EMX__)
sl@0
   613
#  define strcasecmp stricmp
sl@0
   614
#  define strncasecmp strnicmp
sl@0
   615
#elif defined(OPENSSL_SYS_NETWARE) && defined(NETWARE_CLIB)
sl@0
   616
#  define strcasecmp stricmp
sl@0
   617
#  define strncasecmp strnicmp
sl@0
   618
#else
sl@0
   619
#  ifdef NO_STRINGS_H
sl@0
   620
    int	strcasecmp();
sl@0
   621
    int	strncasecmp();
sl@0
   622
#  else
sl@0
   623
#    include <strings.h>
sl@0
   624
#  endif /* NO_STRINGS_H */
sl@0
   625
#endif
sl@0
   626
sl@0
   627
#if defined(OPENSSL_SYS_OS2) && defined(__EMX__)
sl@0
   628
# include <io.h>
sl@0
   629
# include <fcntl.h>
sl@0
   630
# define NO_SYSLOG
sl@0
   631
#endif
sl@0
   632
sl@0
   633
/* vxworks */
sl@0
   634
#if defined(OPENSSL_SYS_VXWORKS)
sl@0
   635
#include <ioLib.h>
sl@0
   636
#include <tickLib.h>
sl@0
   637
#include <sysLib.h>
sl@0
   638
sl@0
   639
#define TTY_STRUCT int
sl@0
   640
sl@0
   641
#define sleep(a) taskDelay((a) * sysClkRateGet())
sl@0
   642
sl@0
   643
#include <vxWorks.h>
sl@0
   644
#include <sockLib.h>
sl@0
   645
#include <taskLib.h>
sl@0
   646
sl@0
   647
#define getpid taskIdSelf
sl@0
   648
sl@0
   649
/* NOTE: these are implemented by helpers in database app!
sl@0
   650
 * if the database is not linked, we need to implement them
sl@0
   651
 * elswhere */
sl@0
   652
struct hostent *gethostbyname(const char *name);
sl@0
   653
struct hostent *gethostbyaddr(const char *addr, int length, int type);
sl@0
   654
struct servent *getservbyname(const char *name, const char *proto);
sl@0
   655
sl@0
   656
#endif
sl@0
   657
/* end vxworks */
sl@0
   658
sl@0
   659
#ifdef  __cplusplus
sl@0
   660
}
sl@0
   661
#endif
sl@0
   662
sl@0
   663
#endif
sl@0
   664