e_os.h 23 KB

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