00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
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
00066
00067
00068
00069 #ifdef __cplusplus
00070 extern "C" {
00071 #endif
00072
00073
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
00081
00082 #define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom"
00083 #endif
00084 #ifndef DEVRANDOM_EGD
00085
00086
00087
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
00114
00115
00116
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_WINDOWS) && !defined(WINDOWS)
00127 # define WINDOWS
00128 #endif
00129 #if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
00130 # define MSDOS
00131 #endif
00132
00133 #if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
00134 # define GETPID_IS_MEANINGLESS
00135 #endif
00136
00137 #ifdef WIN32
00138 #define get_last_sys_error() GetLastError()
00139 #define clear_sys_error() SetLastError(0)
00140 #if !defined(WINNT)
00141 #define WIN_CONSOLE_BUG
00142 #endif
00143 #else
00144 #define get_last_sys_error() errno
00145 #define clear_sys_error() errno=0
00146 #endif
00147
00148 #if defined(WINDOWS)
00149 #define get_last_socket_error() WSAGetLastError()
00150 #define clear_socket_error() WSASetLastError(0)
00151 #define readsocket(s,b,n) recv((s),(b),(n),0)
00152 #define writesocket(s,b,n) send((s),(b),(n),0)
00153 #elif defined(__DJGPP__)
00154 #define WATT32
00155 #define get_last_socket_error() errno
00156 #define clear_socket_error() errno=0
00157 #define closesocket(s) close_s(s)
00158 #define readsocket(s,b,n) read_s(s,b,n)
00159 #define writesocket(s,b,n) send(s,b,n,0)
00160 #elif defined(MAC_OS_pre_X)
00161 #define get_last_socket_error() errno
00162 #define clear_socket_error() errno=0
00163 #define closesocket(s) MacSocket_close(s)
00164 #define readsocket(s,b,n) MacSocket_recv((s),(b),(n),true)
00165 #define writesocket(s,b,n) MacSocket_send((s),(b),(n))
00166 #elif defined(OPENSSL_SYS_VMS)
00167 #define get_last_socket_error() errno
00168 #define clear_socket_error() errno=0
00169 #define ioctlsocket(a,b,c) ioctl(a,b,c)
00170 #define closesocket(s) close(s)
00171 #define readsocket(s,b,n) recv((s),(b),(n),0)
00172 #define writesocket(s,b,n) send((s),(b),(n),0)
00173 #elif defined(OPENSSL_SYS_VXWORKS)
00174 #define get_last_socket_error() errno
00175 #define clear_socket_error() errno=0
00176 #define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
00177 #define closesocket(s) close(s)
00178 #define readsocket(s,b,n) read((s),(b),(n))
00179 #define writesocket(s,b,n) write((s),(char *)(b),(n))
00180 #elif defined(OPENSSL_SYS_BEOS_R5)
00181 #define get_last_socket_error() errno
00182 #define clear_socket_error() errno=0
00183 #define FIONBIO SO_NONBLOCK
00184 #define ioctlsocket(a,b,c) setsockopt((a),SOL_SOCKET,(b),(c),sizeof(*(c)))
00185 #define readsocket(s,b,n) recv((s),(b),(n),0)
00186 #define writesocket(s,b,n) send((s),(b),(n),0)
00187 #elif defined(OPENSSL_SYS_NETWARE)
00188 #if defined(NETWARE_BSDSOCK)
00189 #define get_last_socket_error() errno
00190 #define clear_socket_error() errno=0
00191 #define closesocket(s) close(s)
00192 #define ioctlsocket(a,b,c) ioctl(a,b,c)
00193 #if defined(NETWARE_LIBC)
00194 #define readsocket(s,b,n) recv((s),(b),(n),0)
00195 #define writesocket(s,b,n) send((s),(b),(n),0)
00196 #else
00197 #define readsocket(s,b,n) recv((s),(char*)(b),(n),0)
00198 #define writesocket(s,b,n) send((s),(char*)(b),(n),0)
00199 #endif
00200 #else
00201 #define get_last_socket_error() WSAGetLastError()
00202 #define clear_socket_error() WSASetLastError(0)
00203 #define readsocket(s,b,n) recv((s),(b),(n),0)
00204 #define writesocket(s,b,n) send((s),(b),(n),0)
00205 #endif
00206 #else
00207 #define get_last_socket_error() errno
00208 #define clear_socket_error() errno=0
00209 #define ioctlsocket(a,b,c) ioctl(a,b,c)
00210 #define closesocket(s) close(s)
00211 #define readsocket(s,b,n) read((s),(b),(n))
00212 #define writesocket(s,b,n) write((s),(b),(n))
00213 #endif
00214
00215 #ifdef WIN16
00216 # define MS_CALLBACK _far _loadds
00217 # define MS_FAR _far
00218 #else
00219 # define MS_CALLBACK
00220 # define MS_FAR
00221 #endif
00222
00223 #ifdef OPENSSL_NO_STDIO
00224 # undef OPENSSL_NO_FP_API
00225 # define OPENSSL_NO_FP_API
00226 #endif
00227
00228 #if (defined(WINDOWS) || defined(MSDOS))
00229
00230 # ifdef __DJGPP__
00231 # include <unistd.h>
00232 # include <sys/stat.h>
00233 # include <sys/socket.h>
00234 # include <tcp.h>
00235 # include <netdb.h>
00236 # define _setmode setmode
00237 # define _O_TEXT O_TEXT
00238 # define _O_BINARY O_BINARY
00239 # undef DEVRANDOM
00240 # define DEVRANDOM "/dev/urandom\x24"
00241 # endif
00242
00243 # ifndef S_IFDIR
00244 # define S_IFDIR _S_IFDIR
00245 # endif
00246
00247 # ifndef S_IFMT
00248 # define S_IFMT _S_IFMT
00249 # endif
00250
00251 # if !defined(WINNT) && !defined(__DJGPP__)
00252 # define NO_SYSLOG
00253 # endif
00254 # define NO_DIRENT
00255
00256 # ifdef WINDOWS
00257 # if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272 # define _WIN32_WINNT 0x0400
00273 # endif
00274 # if !defined(OPENSSL_NO_SOCK) && defined(_WIN32_WINNT)
00275
00276
00277
00278
00279
00280
00281
00282 # include <winsock2.h>
00283 # include <ws2tcpip.h>
00284
00285 # endif
00286 # include <windows.h>
00287 # include <stdio.h>
00288 # include <stddef.h>
00289 # include <errno.h>
00290 # include <string.h>
00291 # ifdef _WIN64
00292 # define strlen(s) _strlen31(s)
00293
00294 static unsigned int _strlen31(const char *str)
00295 {
00296 unsigned int len=0;
00297 while (*str && len<0x80000000U) str++, len++;
00298 return len&0x7FFFFFFF;
00299 }
00300 # endif
00301 # include <malloc.h>
00302 # if defined(_MSC_VER) && _MSC_VER<=1200 && defined(_MT) && defined(isspace)
00303
00304 # undef isspace
00305 # undef isdigit
00306 # undef isalnum
00307 # undef isupper
00308 # undef isxdigit
00309 # endif
00310 # if defined(_MSC_VER) && !defined(_DLL) && defined(stdin)
00311 # if _MSC_VER>=1300
00312 # undef stdin
00313 # undef stdout
00314 # undef stderr
00315 FILE *__iob_func();
00316 # define stdin (&__iob_func()[0])
00317 # define stdout (&__iob_func()[1])
00318 # define stderr (&__iob_func()[2])
00319 # elif defined(I_CAN_LIVE_WITH_LNK4049)
00320 # undef stdin
00321 # undef stdout
00322 # undef stderr
00323
00324
00325
00326
00327
00328
00329 extern FILE *_imp___iob;
00330 # define stdin (&_imp___iob[0])
00331 # define stdout (&_imp___iob[1])
00332 # define stderr (&_imp___iob[2])
00333 # endif
00334 # endif
00335 # endif
00336 # include <io.h>
00337 # include <fcntl.h>
00338
00339 # ifdef OPENSSL_SYS_WINCE
00340 # define OPENSSL_NO_POSIX_IO
00341 # endif
00342
00343 # define ssize_t long
00344
00345 # if defined (__BORLANDC__)
00346 # define _setmode setmode
00347 # define _O_TEXT O_TEXT
00348 # define _O_BINARY O_BINARY
00349 # define _int64 __int64
00350 # define _kbhit kbhit
00351 # endif
00352
00353 # define EXIT(n) exit(n)
00354 # define LIST_SEPARATOR_CHAR ';'
00355 # ifndef X_OK
00356 # define X_OK 0
00357 # endif
00358 # ifndef W_OK
00359 # define W_OK 2
00360 # endif
00361 # ifndef R_OK
00362 # define R_OK 4
00363 # endif
00364 # define OPENSSL_CONF "openssl.cnf"
00365 # define SSLEAY_CONF OPENSSL_CONF
00366 # define NUL_DEV "nul"
00367 # define RFILE ".rnd"
00368 # ifdef OPENSSL_SYS_WINCE
00369 # define DEFAULT_HOME ""
00370 # else
00371 # define DEFAULT_HOME "C:"
00372 # endif
00373
00374 #else
00375
00376 # ifdef OPENSSL_SYS_VMS
00377 # define VMS 1
00378
00379
00380 # include <stdlib.h>
00381 # if defined(__DECC)
00382 # include <unistd.h>
00383 # else
00384 # include <unixlib.h>
00385 # endif
00386 # define OPENSSL_CONF "openssl.cnf"
00387 # define SSLEAY_CONF OPENSSL_CONF
00388 # define RFILE ".rnd"
00389 # define LIST_SEPARATOR_CHAR ','
00390 # define NUL_DEV "NLA0:"
00391
00392 # undef DEVRANDOM
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408 # define EXIT(n) do { int __VMS_EXIT = n; \
00409 if (__VMS_EXIT == 0) \
00410 __VMS_EXIT = 1; \
00411 else \
00412 __VMS_EXIT = (n << 3) | 2; \
00413 __VMS_EXIT |= 0x10000000; \
00414 exit(__VMS_EXIT); } while(0)
00415 # define NO_SYS_PARAM_H
00416
00417 # elif defined(OPENSSL_SYS_NETWARE)
00418 # include <fcntl.h>
00419 # include <unistd.h>
00420 # define NO_SYS_TYPES_H
00421 # undef DEVRANDOM
00422 # ifdef NETWARE_CLIB
00423 # define getpid GetThreadID
00424 extern int GetThreadID(void);
00425
00426 extern int kbhit(void);
00427 # else
00428 # include <screen.h>
00429 # endif
00430 # define NO_SYSLOG
00431 # define _setmode setmode
00432 # define _kbhit kbhit
00433 # define _O_TEXT O_TEXT
00434 # define _O_BINARY O_BINARY
00435 # define OPENSSL_CONF "openssl.cnf"
00436 # define SSLEAY_CONF OPENSSL_CONF
00437 # define RFILE ".rnd"
00438 # define LIST_SEPARATOR_CHAR ';'
00439 # define EXIT(n) { if (n) printf("ERROR: %d\n", (int)n); exit(n); }
00440
00441 # else
00442
00443 # ifdef OPENSSL_SYS_MPE
00444 # define NO_SYS_PARAM_H
00445 # endif
00446 # ifdef OPENSSL_UNISTD
00447 # include OPENSSL_UNISTD
00448 # else
00449 # include <unistd.h>
00450 # endif
00451 # ifndef NO_SYS_TYPES_H
00452 # include <sys/types.h>
00453 # endif
00454 # if defined(NeXT) || defined(OPENSSL_SYS_NEWS4)
00455 # define pid_t int
00456
00457
00458 # endif
00459 # if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)
00460 # define ssize_t int
00461 # endif
00462 # ifdef OPENSSL_SYS_NEWS4
00463 # define setvbuf(a, b, c, d) setbuffer((a), (b), (d))
00464 typedef unsigned long clock_t;
00465 # endif
00466 # ifdef OPENSSL_SYS_WIN32_CYGWIN
00467 # include <io.h>
00468 # include <fcntl.h>
00469 # endif
00470
00471 # define OPENSSL_CONF "openssl.cnf"
00472 # define SSLEAY_CONF OPENSSL_CONF
00473 # define RFILE ".rnd"
00474 # define LIST_SEPARATOR_CHAR ':'
00475 # define NUL_DEV "/dev/null"
00476 # define EXIT(n) exit(n)
00477 # endif
00478
00479 # define SSLeay_getpid() getpid()
00480
00481 #endif
00482
00483
00484
00485
00486 #ifdef USE_SOCKETS
00487 # if defined(WINDOWS) || defined(MSDOS)
00488
00489
00490 # ifdef OPENSSL_NO_SOCK
00491 # define SSLeay_Write(a,b,c) (-1)
00492 # define SSLeay_Read(a,b,c) (-1)
00493 # define SHUTDOWN(fd) close(fd)
00494 # define SHUTDOWN2(fd) close(fd)
00495 # elif !defined(__DJGPP__)
00496 # if defined(_WIN32_WCE) && _WIN32_WCE<410
00497 # define getservbyname _masked_declaration_getservbyname
00498 # endif
00499 # if !defined(IPPROTO_IP)
00500
00501 # include <winsock.h>
00502 # endif
00503 # ifdef getservbyname
00504 # undef getservbyname
00505
00506 struct servent* PASCAL getservbyname(const char*,const char*);
00507 # endif
00508
00509 # ifdef _WIN64
00510
00511
00512
00513
00514
00515 # define socket(d,t,p) ((int)socket(d,t,p))
00516 # define accept(s,f,l) ((int)accept(s,f,l))
00517 # endif
00518 # define SSLeay_Write(a,b,c) send((a),(b),(c),0)
00519 # define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
00520 # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
00521 # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
00522 # else
00523 # define SSLeay_Write(a,b,c) write_s(a,b,c,0)
00524 # define SSLeay_Read(a,b,c) read_s(a,b,c)
00525 # define SHUTDOWN(fd) close_s(fd)
00526 # define SHUTDOWN2(fd) close_s(fd)
00527 # endif
00528
00529 # elif defined(MAC_OS_pre_X)
00530
00531 # include "MacSocket.h"
00532 # define SSLeay_Write(a,b,c) MacSocket_send((a),(b),(c))
00533 # define SSLeay_Read(a,b,c) MacSocket_recv((a),(b),(c),true)
00534 # define SHUTDOWN(fd) MacSocket_close(fd)
00535 # define SHUTDOWN2(fd) MacSocket_close(fd)
00536
00537 # elif defined(OPENSSL_SYS_NETWARE)
00538
00539
00540 # if defined(NETWARE_BSDSOCK)
00541 # include <sys/socket.h>
00542 # include <netinet/in.h>
00543 # include <sys/time.h>
00544 # if defined(NETWARE_CLIB)
00545 # include <sys/bsdskt.h>
00546 # else
00547 # include <sys/select.h>
00548 # endif
00549 # define INVALID_SOCKET (int)(~0)
00550 # else
00551 # include <novsock2.h>
00552 # endif
00553 # define SSLeay_Write(a,b,c) send((a),(b),(c),0)
00554 # define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
00555 # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
00556 # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
00557
00558 # else
00559
00560 # ifndef NO_SYS_PARAM_H
00561 # include <sys/param.h>
00562 # endif
00563 # ifdef OPENSSL_SYS_VXWORKS
00564 # include <time.h>
00565 # elif !defined(OPENSSL_SYS_MPE)
00566 # include <sys/time.h>
00567 # endif
00568
00569 # include <netdb.h>
00570 # if defined(OPENSSL_SYS_VMS_NODECC)
00571 # include <socket.h>
00572 # include <in.h>
00573 # include <inet.h>
00574 # else
00575 # include <sys/socket.h>
00576 # ifdef FILIO_H
00577 # include <sys/filio.h>
00578 # endif
00579 # include <netinet/in.h>
00580 # if !defined(OPENSSL_SYS_BEOS_R5)
00581 # include <arpa/inet.h>
00582 # endif
00583 # endif
00584
00585 # if defined(NeXT) || defined(_NEXT_SOURCE)
00586 # include <sys/fcntl.h>
00587 # include <sys/types.h>
00588 # endif
00589
00590 # ifdef OPENSSL_SYS_AIX
00591 # include <sys/select.h>
00592 # endif
00593
00594 # ifdef __QNX__
00595 # include <sys/select.h>
00596 # endif
00597
00598 # if defined(sun)
00599 # include <sys/filio.h>
00600 # else
00601 # ifndef VMS
00602 # include <sys/ioctl.h>
00603 # else
00604
00605 # if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
00606 # include <sys/ioctl.h>
00607 # endif
00608 # endif
00609 # endif
00610
00611 # ifdef VMS
00612 # include <unixio.h>
00613 # if defined(TCPIP_TYPE_SOCKETSHR)
00614 # include <socketshr.h>
00615 # endif
00616 # endif
00617
00618 # define SSLeay_Read(a,b,c) read((a),(b),(c))
00619 # define SSLeay_Write(a,b,c) write((a),(b),(c))
00620 # define SHUTDOWN(fd) { shutdown((fd),0); closesocket((fd)); }
00621 # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket((fd)); }
00622 # ifndef INVALID_SOCKET
00623 # define INVALID_SOCKET (-1)
00624 # endif
00625 # endif
00626
00627
00628
00629
00630 # if !defined(OPENSSL_USE_IPV6)
00631 # if defined(AF_INET6) && !defined(OPENSSL_SYS_BEOS_BONE) && !defined(NETWARE_CLIB)
00632 # define OPENSSL_USE_IPV6 1
00633 # else
00634 # define OPENSSL_USE_IPV6 0
00635 # endif
00636 # endif
00637
00638 #endif
00639
00640 #if defined(__ultrix)
00641 # ifndef ssize_t
00642 # define ssize_t int
00643 # endif
00644 #endif
00645
00646 #if defined(sun) && !defined(__svr4__) && !defined(__SVR4)
00647
00648 #include <stdlib.h>
00649 #include <string.h>
00650
00651 # define memmove(s1,s2,n) bcopy((s2),(s1),(n))
00652 # define strtoul(s,e,b) ((unsigned long int)strtol((s),(e),(b)))
00653 extern char *sys_errlist[]; extern int sys_nerr;
00654 # define strerror(errnum) \
00655 (((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum])
00656
00657 #include "crypto/o_str.h"
00658 # define memcmp OPENSSL_memcmp
00659 #endif
00660
00661 #ifndef OPENSSL_EXIT
00662 # if defined(MONOLITH) && !defined(OPENSSL_C)
00663 # define OPENSSL_EXIT(n) return(n)
00664 # else
00665 # define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
00666 # endif
00667 #endif
00668
00669
00670
00671 #define DG_GCC_BUG
00672
00673 #ifdef sgi
00674 #define IRIX_CC_BUG
00675 #endif
00676 #ifdef OPENSSL_SYS_SNI
00677 #define IRIX_CC_BUG
00678 #endif
00679
00680 #if defined(OPENSSL_SYS_WINDOWS)
00681 # define strcasecmp _stricmp
00682 # define strncasecmp _strnicmp
00683 #elif defined(OPENSSL_SYS_VMS)
00684
00685 # include "o_str.h"
00686 # define strcasecmp OPENSSL_strcasecmp
00687 # define strncasecmp OPENSSL_strncasecmp
00688 # define OPENSSL_IMPLEMENTS_strncasecmp
00689 #elif defined(OPENSSL_SYS_OS2) && defined(__EMX__)
00690 # define strcasecmp stricmp
00691 # define strncasecmp strnicmp
00692 #elif defined(OPENSSL_SYS_NETWARE)
00693 # include <string.h>
00694 # if defined(NETWARE_CLIB)
00695 # define strcasecmp stricmp
00696 # define strncasecmp strnicmp
00697 # endif
00698 #endif
00699
00700 #if defined(OPENSSL_SYS_OS2) && defined(__EMX__)
00701 # include <io.h>
00702 # include <fcntl.h>
00703 # define NO_SYSLOG
00704 #endif
00705
00706
00707 #if defined(OPENSSL_SYS_VXWORKS)
00708 #include <ioLib.h>
00709 #include <tickLib.h>
00710 #include <sysLib.h>
00711
00712 #define TTY_STRUCT int
00713
00714 #define sleep(a) taskDelay((a) * sysClkRateGet())
00715
00716 #include <vxWorks.h>
00717 #include <sockLib.h>
00718 #include <taskLib.h>
00719
00720 #define getpid taskIdSelf
00721
00722
00723
00724
00725 struct hostent *gethostbyname(const char *name);
00726 struct hostent *gethostbyaddr(const char *addr, int length, int type);
00727 struct servent *getservbyname(const char *name, const char *proto);
00728
00729 #endif
00730
00731
00732
00733 #if defined(OPENSSL_SYS_BEOS_R5)
00734 #define SO_ERROR 0
00735 #define NO_SYS_UN
00736 #define IPPROTO_IP 0
00737 #include <OS.h>
00738 #endif
00739
00740
00741 #ifdef __cplusplus
00742 }
00743 #endif
00744
00745 #endif
00746