e_os.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747
  1. /* e_os.h */
  2. /* Copyright (C) 1995-1998 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. #ifndef HEADER_E_OS_H
  59. #define HEADER_E_OS_H
  60. #include <openssl/opensslconf.h>
  61. #include <openssl/e_os2.h>
  62. /* <openssl/e_os2.h> contains what we can justify to make visible
  63. * to the outside; this file e_os.h is not part of the exported
  64. * interface. */
  65. #ifdef __cplusplus
  66. extern "C" {
  67. #endif
  68. /* Used to checking reference counts, most while doing perl5 stuff :-) */
  69. #ifdef REF_PRINT
  70. #undef REF_PRINT
  71. #define REF_PRINT(a,b) fprintf(stderr,"%08X:%4d:%s\n",(int)b,b->references,a)
  72. #endif
  73. #ifndef DEVRANDOM
  74. /* set this to a comma-separated list of 'random' device files to try out.
  75. * My default, we will try to read at least one of these files */
  76. #define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom"
  77. #endif
  78. #ifndef DEVRANDOM_EGD
  79. /* set this to a comma-seperated list of 'egd' sockets to try out. These
  80. * sockets will be tried in the order listed in case accessing the device files
  81. * listed in DEVRANDOM did not return enough entropy. */
  82. #define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"
  83. #endif
  84. #if defined(OPENSSL_SYS_VXWORKS)
  85. # define NO_SYS_PARAM_H
  86. # define NO_CHMOD
  87. # define NO_SYSLOG
  88. #endif
  89. #if defined(OPENSSL_SYS_MACINTOSH_CLASSIC)
  90. # if macintosh==1
  91. # ifndef MAC_OS_GUSI_SOURCE
  92. # define MAC_OS_pre_X
  93. # define NO_SYS_TYPES_H
  94. typedef long ssize_t;
  95. # endif
  96. # define NO_SYS_PARAM_H
  97. # define NO_CHMOD
  98. # define NO_SYSLOG
  99. # undef DEVRANDOM
  100. # define GETPID_IS_MEANINGLESS
  101. # endif
  102. #endif
  103. /********************************************************************
  104. The Microsoft section
  105. ********************************************************************/
  106. /* The following is used because of the small stack in some
  107. * Microsoft operating systems */
  108. #if defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYSNAME_WIN32)
  109. # define MS_STATIC static
  110. #else
  111. # define MS_STATIC
  112. #endif
  113. #if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
  114. # define WIN32
  115. #endif
  116. #if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
  117. # define WINDOWS
  118. #endif
  119. #if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
  120. # define MSDOS
  121. #endif
  122. #if defined(MSDOS) && !defined(GETPID_IS_MEANINGLESS)
  123. # define GETPID_IS_MEANINGLESS
  124. #endif
  125. #ifdef WIN32
  126. #define get_last_sys_error() GetLastError()
  127. #define clear_sys_error() SetLastError(0)
  128. #if !defined(WINNT)
  129. #define WIN_CONSOLE_BUG
  130. #endif
  131. #else
  132. #define get_last_sys_error() errno
  133. #define clear_sys_error() errno=0
  134. #endif
  135. #if defined(WINDOWS)
  136. #define get_last_socket_error() WSAGetLastError()
  137. #define clear_socket_error() WSASetLastError(0)
  138. #define readsocket(s,b,n) recv((s),(b),(n),0)
  139. #define writesocket(s,b,n) send((s),(b),(n),0)
  140. #define EADDRINUSE WSAEADDRINUSE
  141. #elif defined(__DJGPP__)
  142. #define WATT32
  143. #define get_last_socket_error() errno
  144. #define clear_socket_error() errno=0
  145. #define closesocket(s) close_s(s)
  146. #define readsocket(s,b,n) read_s(s,b,n)
  147. #define writesocket(s,b,n) send(s,b,n,0)
  148. #elif defined(MAC_OS_pre_X)
  149. #define get_last_socket_error() errno
  150. #define clear_socket_error() errno=0
  151. #define closesocket(s) MacSocket_close(s)
  152. #define readsocket(s,b,n) MacSocket_recv((s),(b),(n),true)
  153. #define writesocket(s,b,n) MacSocket_send((s),(b),(n))
  154. #elif defined(OPENSSL_SYS_VMS)
  155. #define get_last_socket_error() errno
  156. #define clear_socket_error() errno=0
  157. #define ioctlsocket(a,b,c) ioctl(a,b,c)
  158. #define closesocket(s) close(s)
  159. #define readsocket(s,b,n) recv((s),(b),(n),0)
  160. #define writesocket(s,b,n) send((s),(b),(n),0)
  161. #elif defined(OPENSSL_SYS_VXWORKS)
  162. #define get_last_socket_error() errno
  163. #define clear_socket_error() errno=0
  164. #define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
  165. #define closesocket(s) close(s)
  166. #define readsocket(s,b,n) read((s),(b),(n))
  167. #define writesocket(s,b,n) write((s),(char *)(b),(n))
  168. #elif defined(OPENSSL_SYS_BEOS_R5)
  169. #define get_last_socket_error() errno
  170. #define clear_socket_error() errno=0
  171. #define FIONBIO SO_NONBLOCK
  172. #define ioctlsocket(a,b,c) setsockopt((a),SOL_SOCKET,(b),(c),sizeof(*(c)))
  173. #define readsocket(s,b,n) recv((s),(b),(n),0)
  174. #define writesocket(s,b,n) send((s),(b),(n),0)
  175. #elif defined(OPENSSL_SYS_NETWARE)
  176. #if defined(NETWARE_BSDSOCK)
  177. #define get_last_socket_error() errno
  178. #define clear_socket_error() errno=0
  179. #define closesocket(s) close(s)
  180. #define ioctlsocket(a,b,c) ioctl(a,b,c)
  181. #if defined(NETWARE_LIBC)
  182. #define readsocket(s,b,n) recv((s),(b),(n),0)
  183. #define writesocket(s,b,n) send((s),(b),(n),0)
  184. #else
  185. #define readsocket(s,b,n) recv((s),(char*)(b),(n),0)
  186. #define writesocket(s,b,n) send((s),(char*)(b),(n),0)
  187. #endif
  188. #else
  189. #define get_last_socket_error() WSAGetLastError()
  190. #define clear_socket_error() WSASetLastError(0)
  191. #define readsocket(s,b,n) recv((s),(b),(n),0)
  192. #define writesocket(s,b,n) send((s),(b),(n),0)
  193. #endif
  194. #else
  195. #define get_last_socket_error() errno
  196. #define clear_socket_error() errno=0
  197. #define ioctlsocket(a,b,c) ioctl(a,b,c)
  198. #define closesocket(s) close(s)
  199. #define readsocket(s,b,n) read((s),(b),(n))
  200. #define writesocket(s,b,n) write((s),(b),(n))
  201. #endif
  202. #ifdef WIN16 /* never the case */
  203. # define MS_CALLBACK _far _loadds
  204. # define MS_FAR _far
  205. #else
  206. # define MS_CALLBACK
  207. # define MS_FAR
  208. #endif
  209. #ifdef OPENSSL_NO_STDIO
  210. # undef OPENSSL_NO_FP_API
  211. # define OPENSSL_NO_FP_API
  212. #endif
  213. #if (defined(WINDOWS) || defined(MSDOS))
  214. # ifdef __DJGPP__
  215. # include <unistd.h>
  216. # include <sys/stat.h>
  217. # include <sys/socket.h>
  218. # include <tcp.h>
  219. # include <netdb.h>
  220. # define _setmode setmode
  221. # define _O_TEXT O_TEXT
  222. # define _O_BINARY O_BINARY
  223. # undef DEVRANDOM
  224. # define DEVRANDOM "/dev/urandom\x24"
  225. # endif /* __DJGPP__ */
  226. # ifndef S_IFDIR
  227. # define S_IFDIR _S_IFDIR
  228. # endif
  229. # ifndef S_IFMT
  230. # define S_IFMT _S_IFMT
  231. # endif
  232. # if !defined(WINNT) && !defined(__DJGPP__)
  233. # define NO_SYSLOG
  234. # endif
  235. # define NO_DIRENT
  236. # ifdef WINDOWS
  237. # if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
  238. /*
  239. * Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
  240. * Most notably we ought to check for availability of each specific
  241. * routine with GetProcAddress() and/or guard NT-specific calls with
  242. * GetVersion() < 0x80000000. One can argue that in latter "or" case
  243. * we ought to /DELAYLOAD some .DLLs in order to protect ourselves
  244. * against run-time link errors. This doesn't seem to be necessary,
  245. * because it turned out that already Windows 95, first non-NT Win32
  246. * implementation, is equipped with at least NT 3.51 stubs, dummy
  247. * routines with same name, but which do nothing. Meaning that it's
  248. * apparently sufficient to guard "vanilla" NT calls with GetVersion
  249. * alone, while NT 4.0 and above interfaces ought to be linked with
  250. * GetProcAddress at run-time.
  251. */
  252. # define _WIN32_WINNT 0x0400
  253. # endif
  254. # if !defined(OPENSSL_NO_SOCK) && defined(_WIN32_WINNT)
  255. /*
  256. * Just like defining _WIN32_WINNT including winsock2.h implies
  257. * certain "discipline" for maintaining [broad] binary compatibility.
  258. * As long as structures are invariant among Winsock versions,
  259. * it's sufficient to check for specific Winsock2 API availability
  260. * at run-time [DSO_global_lookup is recommended]...
  261. */
  262. # include <winsock2.h>
  263. # include <ws2tcpip.h>
  264. /* yes, they have to be #included prior to <windows.h> */
  265. # endif
  266. # include <windows.h>
  267. # include <stdio.h>
  268. # include <stddef.h>
  269. # include <errno.h>
  270. # include <string.h>
  271. # ifdef _WIN64
  272. # define strlen(s) _strlen31(s)
  273. /* cut strings to 2GB */
  274. static unsigned int _strlen31(const char *str)
  275. {
  276. unsigned int len=0;
  277. while (*str && len<0x80000000U) str++, len++;
  278. return len&0x7FFFFFFF;
  279. }
  280. # endif
  281. # include <malloc.h>
  282. # if defined(_MSC_VER) && _MSC_VER<=1200 && defined(_MT) && defined(isspace)
  283. /* compensate for bug in VC6 ctype.h */
  284. # undef isspace
  285. # undef isdigit
  286. # undef isalnum
  287. # undef isupper
  288. # undef isxdigit
  289. # endif
  290. # if defined(_MSC_VER) && !defined(_DLL) && defined(stdin)
  291. # if _MSC_VER>=1300
  292. # undef stdin
  293. # undef stdout
  294. # undef stderr
  295. FILE *__iob_func();
  296. # define stdin (&__iob_func()[0])
  297. # define stdout (&__iob_func()[1])
  298. # define stderr (&__iob_func()[2])
  299. # elif defined(I_CAN_LIVE_WITH_LNK4049)
  300. # undef stdin
  301. # undef stdout
  302. # undef stderr
  303. /* pre-1300 has __p__iob(), but it's available only in msvcrt.lib,
  304. * or in other words with /MD. Declaring implicit import, i.e.
  305. * with _imp_ prefix, works correctly with all compiler options,
  306. * but without /MD results in LINK warning LNK4049:
  307. * 'locally defined symbol "__iob" imported'.
  308. */
  309. extern FILE *_imp___iob;
  310. # define stdin (&_imp___iob[0])
  311. # define stdout (&_imp___iob[1])
  312. # define stderr (&_imp___iob[2])
  313. # endif
  314. # endif
  315. # endif
  316. # include <io.h>
  317. # include <fcntl.h>
  318. # ifdef OPENSSL_SYS_WINCE
  319. # define OPENSSL_NO_POSIX_IO
  320. # endif
  321. # define ssize_t long
  322. # if defined (__BORLANDC__)
  323. # define _setmode setmode
  324. # define _O_TEXT O_TEXT
  325. # define _O_BINARY O_BINARY
  326. # define _int64 __int64
  327. # define _kbhit kbhit
  328. # endif
  329. # define EXIT(n) exit(n)
  330. # define LIST_SEPARATOR_CHAR ';'
  331. # ifndef X_OK
  332. # define X_OK 0
  333. # endif
  334. # ifndef W_OK
  335. # define W_OK 2
  336. # endif
  337. # ifndef R_OK
  338. # define R_OK 4
  339. # endif
  340. # define OPENSSL_CONF "openssl.cnf"
  341. # define SSLEAY_CONF OPENSSL_CONF
  342. # define NUL_DEV "nul"
  343. # define RFILE ".rnd"
  344. # ifdef OPENSSL_SYS_WINCE
  345. # define DEFAULT_HOME ""
  346. # else
  347. # define DEFAULT_HOME "C:"
  348. # endif
  349. #else /* The non-microsoft world */
  350. # ifdef OPENSSL_SYS_VMS
  351. # define VMS 1
  352. /* some programs don't include stdlib, so exit() and others give implicit
  353. function warnings */
  354. # include <stdlib.h>
  355. # if defined(__DECC)
  356. # include <unistd.h>
  357. # else
  358. # include <unixlib.h>
  359. # endif
  360. # define OPENSSL_CONF "openssl.cnf"
  361. # define SSLEAY_CONF OPENSSL_CONF
  362. # define RFILE ".rnd"
  363. # define LIST_SEPARATOR_CHAR ','
  364. # define NUL_DEV "NLA0:"
  365. /* We don't have any well-defined random devices on VMS, yet... */
  366. # undef DEVRANDOM
  367. /* We need to do this since VMS has the following coding on status codes:
  368. Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
  369. The important thing to know is that odd numbers are considered
  370. good, while even ones are considered errors.
  371. Bits 3-15: actual status number
  372. Bits 16-27: facility number. 0 is considered "unknown"
  373. Bits 28-31: control bits. If bit 28 is set, the shell won't try to
  374. output the message (which, for random codes, just looks ugly)
  375. So, what we do here is to change 0 to 1 to get the default success status,
  376. and everything else is shifted up to fit into the status number field, and
  377. the status is tagged as an error, which I believe is what is wanted here.
  378. -- Richard Levitte
  379. */
  380. # define EXIT(n) do { int __VMS_EXIT = n; \
  381. if (__VMS_EXIT == 0) \
  382. __VMS_EXIT = 1; \
  383. else \
  384. __VMS_EXIT = (n << 3) | 2; \
  385. __VMS_EXIT |= 0x10000000; \
  386. exit(__VMS_EXIT); } while(0)
  387. # define NO_SYS_PARAM_H
  388. # elif defined(OPENSSL_SYS_NETWARE)
  389. # include <fcntl.h>
  390. # include <unistd.h>
  391. # define NO_SYS_TYPES_H
  392. # undef DEVRANDOM
  393. # ifdef NETWARE_CLIB
  394. # define getpid GetThreadID
  395. extern int GetThreadID(void);
  396. /* # include <conio.h> */
  397. extern int kbhit(void);
  398. # else
  399. # include <screen.h>
  400. # endif
  401. # define NO_SYSLOG
  402. # define _setmode setmode
  403. # define _kbhit kbhit
  404. # define _O_TEXT O_TEXT
  405. # define _O_BINARY O_BINARY
  406. # define OPENSSL_CONF "openssl.cnf"
  407. # define SSLEAY_CONF OPENSSL_CONF
  408. # define RFILE ".rnd"
  409. # define LIST_SEPARATOR_CHAR ';'
  410. # define EXIT(n) { if (n) printf("ERROR: %d\n", (int)n); exit(n); }
  411. # else
  412. /* !defined VMS */
  413. # ifdef OPENSSL_SYS_MPE
  414. # define NO_SYS_PARAM_H
  415. # endif
  416. # ifdef OPENSSL_UNISTD
  417. # include OPENSSL_UNISTD
  418. # else
  419. # include <unistd.h>
  420. # endif
  421. # ifndef NO_SYS_TYPES_H
  422. # include <sys/types.h>
  423. # endif
  424. # if defined(NeXT) || defined(OPENSSL_SYS_NEWS4)
  425. # define pid_t int /* pid_t is missing on NEXTSTEP/OPENSTEP
  426. * (unless when compiling with -D_POSIX_SOURCE,
  427. * which doesn't work for us) */
  428. # endif
  429. # if defined(NeXT) || defined(OPENSSL_SYS_NEWS4) || defined(OPENSSL_SYS_SUNOS)
  430. # define ssize_t int /* ditto */
  431. # endif
  432. # ifdef OPENSSL_SYS_NEWS4 /* setvbuf is missing on mips-sony-bsd */
  433. # define setvbuf(a, b, c, d) setbuffer((a), (b), (d))
  434. typedef unsigned long clock_t;
  435. # endif
  436. # ifdef OPENSSL_SYS_WIN32_CYGWIN
  437. # include <io.h>
  438. # include <fcntl.h>
  439. # endif
  440. # define OPENSSL_CONF "openssl.cnf"
  441. # define SSLEAY_CONF OPENSSL_CONF
  442. # define RFILE ".rnd"
  443. # define LIST_SEPARATOR_CHAR ':'
  444. # define NUL_DEV "/dev/null"
  445. # define EXIT(n) exit(n)
  446. # endif
  447. # define SSLeay_getpid() getpid()
  448. #endif
  449. /*************/
  450. #ifdef USE_SOCKETS
  451. # if defined(WINDOWS) || defined(MSDOS)
  452. /* windows world */
  453. # ifdef OPENSSL_NO_SOCK
  454. # define SSLeay_Write(a,b,c) (-1)
  455. # define SSLeay_Read(a,b,c) (-1)
  456. # define SHUTDOWN(fd) close(fd)
  457. # define SHUTDOWN2(fd) close(fd)
  458. # elif !defined(__DJGPP__)
  459. # if defined(_WIN32_WCE) && _WIN32_WCE<410
  460. # define getservbyname _masked_declaration_getservbyname
  461. # endif
  462. # if !defined(IPPROTO_IP)
  463. /* winsock[2].h was included already? */
  464. # include <winsock.h>
  465. # endif
  466. # ifdef getservbyname
  467. # undef getservbyname
  468. /* this is used to be wcecompat/include/winsock_extras.h */
  469. struct servent* PASCAL getservbyname(const char*,const char*);
  470. # endif
  471. # ifdef _WIN64
  472. /*
  473. * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
  474. * the value constitutes an index in per-process table of limited size
  475. * and not a real pointer.
  476. */
  477. # define socket(d,t,p) ((int)socket(d,t,p))
  478. # define accept(s,f,l) ((int)accept(s,f,l))
  479. # endif
  480. # define SSLeay_Write(a,b,c) send((a),(b),(c),0)
  481. # define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
  482. # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
  483. # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
  484. # else
  485. # define SSLeay_Write(a,b,c) write_s(a,b,c,0)
  486. # define SSLeay_Read(a,b,c) read_s(a,b,c)
  487. # define SHUTDOWN(fd) close_s(fd)
  488. # define SHUTDOWN2(fd) close_s(fd)
  489. # endif
  490. # elif defined(MAC_OS_pre_X)
  491. # include "MacSocket.h"
  492. # define SSLeay_Write(a,b,c) MacSocket_send((a),(b),(c))
  493. # define SSLeay_Read(a,b,c) MacSocket_recv((a),(b),(c),true)
  494. # define SHUTDOWN(fd) MacSocket_close(fd)
  495. # define SHUTDOWN2(fd) MacSocket_close(fd)
  496. # elif defined(OPENSSL_SYS_NETWARE)
  497. /* NetWare uses the WinSock2 interfaces by default, but can be configured for BSD
  498. */
  499. # if defined(NETWARE_BSDSOCK)
  500. # include <sys/socket.h>
  501. # include <netinet/in.h>
  502. # include <sys/time.h>
  503. # if defined(NETWARE_CLIB)
  504. # include <sys/bsdskt.h>
  505. # else
  506. # include <sys/select.h>
  507. # endif
  508. # define INVALID_SOCKET (int)(~0)
  509. # else
  510. # include <novsock2.h>
  511. # endif
  512. # define SSLeay_Write(a,b,c) send((a),(b),(c),0)
  513. # define SSLeay_Read(a,b,c) recv((a),(b),(c),0)
  514. # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
  515. # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
  516. # else
  517. # ifndef NO_SYS_PARAM_H
  518. # include <sys/param.h>
  519. # endif
  520. # ifdef OPENSSL_SYS_VXWORKS
  521. # include <time.h>
  522. # elif !defined(OPENSSL_SYS_MPE)
  523. # include <sys/time.h> /* Needed under linux for FD_XXX */
  524. # endif
  525. # include <netdb.h>
  526. # if defined(OPENSSL_SYS_VMS_NODECC)
  527. # include <socket.h>
  528. # include <in.h>
  529. # include <inet.h>
  530. # else
  531. # include <sys/socket.h>
  532. # ifdef FILIO_H
  533. # include <sys/filio.h> /* Added for FIONBIO under unixware */
  534. # endif
  535. # include <netinet/in.h>
  536. # if !defined(OPENSSL_SYS_BEOS_R5)
  537. # include <arpa/inet.h>
  538. # endif
  539. # endif
  540. # if defined(NeXT) || defined(_NEXT_SOURCE)
  541. # include <sys/fcntl.h>
  542. # include <sys/types.h>
  543. # endif
  544. # ifdef OPENSSL_SYS_AIX
  545. # include <sys/select.h>
  546. # endif
  547. # ifdef __QNX__
  548. # include <sys/select.h>
  549. # endif
  550. # if defined(sun)
  551. # include <sys/filio.h>
  552. # else
  553. # ifndef VMS
  554. # include <sys/ioctl.h>
  555. # else
  556. /* ioctl is only in VMS > 7.0 and when socketshr is not used */
  557. # if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
  558. # include <sys/ioctl.h>
  559. # endif
  560. # endif
  561. # endif
  562. # ifdef VMS
  563. # include <unixio.h>
  564. # if defined(TCPIP_TYPE_SOCKETSHR)
  565. # include <socketshr.h>
  566. # endif
  567. # endif
  568. # define SSLeay_Read(a,b,c) read((a),(b),(c))
  569. # define SSLeay_Write(a,b,c) write((a),(b),(c))
  570. # define SHUTDOWN(fd) { shutdown((fd),0); closesocket((fd)); }
  571. # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket((fd)); }
  572. # ifndef INVALID_SOCKET
  573. # define INVALID_SOCKET (-1)
  574. # endif /* INVALID_SOCKET */
  575. # endif
  576. /* Some IPv6 implementations are broken, disable them in known bad
  577. * versions.
  578. */
  579. # if !defined(OPENSSL_USE_IPV6)
  580. # if defined(AF_INET6) && !defined(OPENSSL_SYS_BEOS_BONE) && !defined(NETWARE_CLIB)
  581. # define OPENSSL_USE_IPV6 1
  582. # else
  583. # define OPENSSL_USE_IPV6 0
  584. # endif
  585. # endif
  586. #endif
  587. #if defined(__ultrix)
  588. # ifndef ssize_t
  589. # define ssize_t int
  590. # endif
  591. #endif
  592. #if defined(sun) && !defined(__svr4__) && !defined(__SVR4)
  593. /* include headers first, so our defines don't break it */
  594. #include <stdlib.h>
  595. #include <string.h>
  596. /* bcopy can handle overlapping moves according to SunOS 4.1.4 manpage */
  597. # define memmove(s1,s2,n) bcopy((s2),(s1),(n))
  598. # define strtoul(s,e,b) ((unsigned long int)strtol((s),(e),(b)))
  599. extern char *sys_errlist[]; extern int sys_nerr;
  600. # define strerror(errnum) \
  601. (((errnum)<0 || (errnum)>=sys_nerr) ? NULL : sys_errlist[errnum])
  602. /* Being signed SunOS 4.x memcpy breaks ASN1_OBJECT table lookup */
  603. #include "crypto/o_str.h"
  604. # define memcmp OPENSSL_memcmp
  605. #endif
  606. #ifndef OPENSSL_EXIT
  607. # if defined(MONOLITH) && !defined(OPENSSL_C)
  608. # define OPENSSL_EXIT(n) return(n)
  609. # else
  610. # define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
  611. # endif
  612. #endif
  613. /***********************************************/
  614. #define DG_GCC_BUG /* gcc < 2.6.3 on DGUX */
  615. #ifdef sgi
  616. #define IRIX_CC_BUG /* all version of IRIX I've tested (4.* 5.*) */
  617. #endif
  618. #ifdef OPENSSL_SYS_SNI
  619. #define IRIX_CC_BUG /* CDS++ up to V2.0Bsomething suffered from the same bug.*/
  620. #endif
  621. #if defined(OPENSSL_SYS_WINDOWS)
  622. # define strcasecmp _stricmp
  623. # define strncasecmp _strnicmp
  624. #elif defined(OPENSSL_SYS_VMS)
  625. /* VMS below version 7.0 doesn't have strcasecmp() */
  626. # include "o_str.h"
  627. # define strcasecmp OPENSSL_strcasecmp
  628. # define strncasecmp OPENSSL_strncasecmp
  629. # define OPENSSL_IMPLEMENTS_strncasecmp
  630. #elif defined(OPENSSL_SYS_OS2) && defined(__EMX__)
  631. # define strcasecmp stricmp
  632. # define strncasecmp strnicmp
  633. #elif defined(OPENSSL_SYS_NETWARE)
  634. # include <string.h>
  635. # if defined(NETWARE_CLIB)
  636. # define strcasecmp stricmp
  637. # define strncasecmp strnicmp
  638. # endif /* NETWARE_CLIB */
  639. #endif
  640. #if defined(OPENSSL_SYS_OS2) && defined(__EMX__)
  641. # include <io.h>
  642. # include <fcntl.h>
  643. # define NO_SYSLOG
  644. #endif
  645. /* vxworks */
  646. #if defined(OPENSSL_SYS_VXWORKS)
  647. #include <ioLib.h>
  648. #include <tickLib.h>
  649. #include <sysLib.h>
  650. #define TTY_STRUCT int
  651. #define sleep(a) taskDelay((a) * sysClkRateGet())
  652. #include <vxWorks.h>
  653. #include <sockLib.h>
  654. #include <taskLib.h>
  655. #define getpid taskIdSelf
  656. /* NOTE: these are implemented by helpers in database app!
  657. * if the database is not linked, we need to implement them
  658. * elswhere */
  659. struct hostent *gethostbyname(const char *name);
  660. struct hostent *gethostbyaddr(const char *addr, int length, int type);
  661. struct servent *getservbyname(const char *name, const char *proto);
  662. #endif
  663. /* end vxworks */
  664. /* beos */
  665. #if defined(OPENSSL_SYS_BEOS_R5)
  666. #define SO_ERROR 0
  667. #define NO_SYS_UN
  668. #define IPPROTO_IP 0
  669. #include <OS.h>
  670. #endif
  671. #ifdef __cplusplus
  672. }
  673. #endif
  674. #endif