1 /* e_os.h */ 2 /* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com) 3 * All rights reserved. 4 * 5 * This package is an SSL implementation written 6 * by Eric Young (eay@cryptsoft.com). 7 * The implementation was written so as to conform with Netscapes SSL. 8 * 9 * This library is free for commercial and non-commercial use as long as 10 * the following conditions are aheared to. The following conditions 11 * apply to all code found in this distribution, be it the RC4, RSA, 12 * lhash, DES, etc., code; not just the SSL code. The SSL documentation 13 * included with this distribution is covered by the same copyright terms 14 * except that the holder is Tim Hudson (tjh@cryptsoft.com). 15 * 16 * Copyright remains Eric Young's, and as such any Copyright notices in 17 * the code are not to be removed. 18 * If this package is used in a product, Eric Young should be given attribution 19 * as the author of the parts of the library used. 20 * This can be in the form of a textual message at program startup or 21 * in documentation (online or textual) provided with the package. 22 * 23 * Redistribution and use in source and binary forms, with or without 24 * modification, are permitted provided that the following conditions 25 * are met: 26 * 1. Redistributions of source code must retain the copyright 27 * notice, this list of conditions and the following disclaimer. 28 * 2. Redistributions in binary form must reproduce the above copyright 29 * notice, this list of conditions and the following disclaimer in the 30 * documentation and/or other materials provided with the distribution. 31 * 3. All advertising materials mentioning features or use of this software 32 * must display the following acknowledgement: 33 * "This product includes cryptographic software written by 34 * Eric Young (eay@cryptsoft.com)" 35 * The word 'cryptographic' can be left out if the rouines from the library 36 * being used are not cryptographic related :-). 37 * 4. If you include any Windows specific code (or a derivative thereof) from 38 * the apps directory (application code) you must include an acknowledgement: 39 * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)" 40 * 41 * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND 42 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 43 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 44 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 45 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 46 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 47 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 48 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 49 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 50 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 51 * SUCH DAMAGE. 52 * 53 * The licence and distribution terms for any publically available version or 54 * derivative of this code cannot be changed. i.e. this code cannot simply be 55 * copied and put under another distribution licence 56 * [including the GNU Public Licence.] 57 */ 58 59 #ifndef HEADER_E_OS_H 60 #define HEADER_E_OS_H 61 62 #ifdef __cplusplus 63 extern "C" { 64 #endif 65 66 #ifndef DEVRANDOM 67 #undef DEVRANDOM /* set this to your 'random' device if you have one */ 68 #endif 69 70 #if defined(NOCONST) 71 #define const 72 #endif 73 74 /******************************************************************** 75 The Microsoft section 76 ********************************************************************/ 77 /* The following is used becaue of the small stack in some 78 * Microsoft operating systems */ 79 #if defined(WIN16) || defined(MSDOS) 80 # define MS_STATIC static 81 #else 82 # define MS_STATIC 83 #endif 84 85 #if defined(WIN32) || defined(WIN16) 86 # ifndef WINDOWS 87 # define WINDOWS 88 # endif 89 # ifndef MSDOS 90 # define MSDOS 91 # endif 92 #endif 93 94 #ifdef WIN16 95 # define MS_CALLBACK _far _loadds 96 # define MS_FAR _far 97 #else 98 # define MS_CALLBACK 99 # define MS_FAR 100 #endif 101 102 #if defined(WINDOWS) || defined(MSDOS) 103 104 #ifndef S_IFDIR 105 #define S_IFDIR _S_IFDIR 106 #endif 107 108 #ifndef S_IFMT 109 #define S_IFMT _S_IFMT 110 #endif 111 112 #define strncasecmp(a,b,c) strnicmp((a),(b),(c)) 113 114 # ifdef WINDOWS 115 # include <windows.h> 116 # include <stddef.h> 117 # include <errno.h> 118 # include <string.h> 119 # include <malloc.h> 120 # endif 121 # include <io.h> 122 # include <fcntl.h> 123 124 #if defined(WIN16) && (!defined(MONOLITH) || defined(SSLEAY)) && defined(_WINEXITNOPERSIST) 125 # define EXIT(n) { if (n == 0) _wsetexit(_WINEXITNOPERSIST); \ 126 return(n); } 127 #else 128 # define EXIT(n) return(n); 129 #endif 130 # define LIST_SEPARATOR_CHAR ';' 131 #ifndef X_OK 132 # define X_OK 0 133 #endif 134 #ifndef W_OK 135 # define W_OK 2 136 #endif 137 #ifndef R_OK 138 # define R_OK 4 139 #endif 140 # define SSLEAY_CONF "ssleay.cnf" 141 # define NUL_DEV "nul" 142 # define RFILE ".rnd" 143 144 #else /* The non-microsoft world world */ 145 146 # ifdef VMS 147 # include <unixlib.h> 148 # else 149 # include <unistd.h> 150 # endif 151 152 # define SSLEAY_CONF "ssleay.cnf" 153 # define RFILE ".rnd" 154 # define LIST_SEPARATOR_CHAR ':' 155 # ifndef MONOLITH 156 # define EXIT(n) exit(n); return(n) 157 # else 158 # define EXIT(n) return(n) 159 # endif 160 # define NUL_DEV "/dev/null" 161 162 # define SSLeay_getpid() getpid() 163 164 #endif 165 166 /*************/ 167 168 #ifdef USE_SOCKETS 169 # if defined(WINDOWS) || defined(MSDOS) 170 /* windows world */ 171 172 # ifdef NO_SOCK 173 # define SSLeay_Write(a,b,c) (-1) 174 # define SSLeay_Read(a,b,c) (-1) 175 # define SHUTDOWN(fd) close(fd) 176 # define SHUTDOWN2(fd) close(fd) 177 # else 178 # include <winsock.h> 179 extern HINSTANCE _hInstance; 180 # define SSLeay_Write(a,b,c) send((a),(b),(c),0) 181 # define SSLeay_Read(a,b,c) recv((a),(b),(c),0) 182 # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); } 183 # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); } 184 # endif 185 186 187 # else 188 189 # ifndef VMS 190 /* unix world */ 191 # include <netdb.h> 192 # include <sys/types.h> 193 # include <sys/socket.h> 194 # include <sys/param.h> 195 # include <sys/time.h> /* Needed under linux for FD_XXX */ 196 # include <netinet/in.h> 197 # endif 198 199 # if defined(NeXT) || defined(_NEXT_SOURCE) 200 # include <sys/fcntl.h> 201 # include <sys/types.h> 202 # endif 203 204 # ifdef AIX 205 # include <sys/select.h> 206 # endif 207 208 # if defined(sun) 209 # include <sys/filio.h> 210 # else 211 # include <sys/ioctl.h> 212 # endif 213 214 # ifdef VMS 215 # include <unixio.h> 216 # endif 217 218 # define SSLeay_Read(a,b,c) read((a),(b),(c)) 219 # define SSLeay_Write(a,b,c) write((a),(b),(c)) 220 # define SHUTDOWN(fd) { shutdown((fd),0); close((fd)); } 221 # define SHUTDOWN2(fd) { shutdown((fd),2); close((fd)); } 222 # define INVALID_SOCKET -1 223 # endif 224 #endif 225 226 #if defined(THREADS) || defined(sun) 227 #ifndef _REENTRANT 228 #define _REENTRANT 229 #endif 230 #endif 231 232 /***********************************************/ 233 234 #ifndef NOPROTO 235 #define P_CC_CC const void *,const void * 236 #define P_I_I int,int 237 #define P_I_I_P_I int,int,char *,int 238 #define P_IP_I_I_P_I int *,int,int,char *,int 239 #define P_V void 240 #else 241 #define P_CC_CC 242 #define P_I_I 243 #define P_IP_I_I_P_I 244 #define P_I_I_P_I 245 #define P_V 246 #endif 247 248 /* not used yet */ 249 #define CS_BEGIN 250 #define CS_END 251 252 /* do we need to do this for getenv. 253 * Just define getenv for use under windows */ 254 255 #ifdef WIN16 256 /* How to do this needs to be thought out a bit more.... */ 257 /*char *GETENV(char *); 258 #define Getenv GETENV*/ 259 #define Getenv getenv 260 #else 261 #define Getenv getenv 262 #endif 263 264 #define DG_GCC_BUG /* gcc < 2.6.3 on DGUX */ 265 266 #ifdef sgi 267 #define IRIX_CC_BUG /* all version of IRIX I've tested (4.* 5.*) */ 268 #endif 269 270 #ifdef NO_MD2 271 #define MD2_Init MD2Init 272 #define MD2_Update MD2Update 273 #define MD2_Final MD2Final 274 #define MD2_DIGEST_LENGTH 16 275 #endif 276 #ifdef NO_MD5 277 #define MD5_Init MD5Init 278 #define MD5_Update MD5Update 279 #define MD5_Final MD5Final 280 #define MD5_DIGEST_LENGTH 16 281 #endif 282 283 #ifdef __cplusplus 284 } 285 #endif 286 287 #endif 288 289