e_os.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665
  1. /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  2. * All rights reserved.
  3. *
  4. * This package is an SSL implementation written
  5. * by Eric Young (eay@cryptsoft.com).
  6. * The implementation was written so as to conform with Netscapes SSL.
  7. *
  8. * This library is free for commercial and non-commercial use as long as
  9. * the following conditions are aheared to. The following conditions
  10. * apply to all code found in this distribution, be it the RC4, RSA,
  11. * lhash, DES, etc., code; not just the SSL code. The SSL documentation
  12. * included with this distribution is covered by the same copyright terms
  13. * except that the holder is Tim Hudson (tjh@cryptsoft.com).
  14. *
  15. * Copyright remains Eric Young's, and as such any Copyright notices in
  16. * the code are not to be removed.
  17. * If this package is used in a product, Eric Young should be given attribution
  18. * as the author of the parts of the library used.
  19. * This can be in the form of a textual message at program startup or
  20. * in documentation (online or textual) provided with the package.
  21. *
  22. * Redistribution and use in source and binary forms, with or without
  23. * modification, are permitted provided that the following conditions
  24. * are met:
  25. * 1. Redistributions of source code must retain the copyright
  26. * notice, this list of conditions and the following disclaimer.
  27. * 2. Redistributions in binary form must reproduce the above copyright
  28. * notice, this list of conditions and the following disclaimer in the
  29. * documentation and/or other materials provided with the distribution.
  30. * 3. All advertising materials mentioning features or use of this software
  31. * must display the following acknowledgement:
  32. * "This product includes cryptographic software written by
  33. * Eric Young (eay@cryptsoft.com)"
  34. * The word 'cryptographic' can be left out if the rouines from the library
  35. * being used are not cryptographic related :-).
  36. * 4. If you include any Windows specific code (or a derivative thereof) from
  37. * the apps directory (application code) you must include an acknowledgement:
  38. * "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
  39. *
  40. * THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
  41. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  42. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  43. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  44. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  45. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  46. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  47. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  48. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  49. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  50. * SUCH DAMAGE.
  51. *
  52. * The licence and distribution terms for any publically available version or
  53. * derivative of this code cannot be changed. i.e. this code cannot simply be
  54. * copied and put under another distribution licence
  55. * [including the GNU Public Licence.]
  56. */
  57. #ifndef HEADER_E_OS_H
  58. # define HEADER_E_OS_H
  59. # include <openssl/opensslconf.h>
  60. # include <openssl/e_os2.h>
  61. /*
  62. * <openssl/e_os2.h> contains what we can justify to make visible to the
  63. * outside; this file e_os.h is not part of the exported interface.
  64. */
  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. # if defined(OPENSSL_NO_STDIO) && defined(REF_CHECK)
  74. # error "Cannot have REF_CHECK with no-stdio"
  75. # endif
  76. # if defined(OPENSSL_NO_STDIO) && defined(REF_PRINT)
  77. # error "Cannot have REF_PRINT with no-stdio"
  78. # endif
  79. # ifndef DEVRANDOM
  80. /*
  81. * set this to a comma-separated list of 'random' device files to try out. My
  82. * default, we will try to read at least one of these files
  83. */
  84. # define DEVRANDOM "/dev/urandom","/dev/random","/dev/srandom"
  85. # endif
  86. # if !defined(OPENSSL_NO_EGD) && !defined(DEVRANDOM_EGD)
  87. /*
  88. * set this to a comma-separated list of 'egd' sockets to try out. These
  89. * sockets will be tried in the order listed in case accessing the device
  90. * files listed in DEVRANDOM did not return enough entropy.
  91. */
  92. # define DEVRANDOM_EGD "/var/run/egd-pool","/dev/egd-pool","/etc/egd-pool","/etc/entropy"
  93. # endif
  94. # if defined(OPENSSL_SYS_VXWORKS)
  95. # define NO_SYS_PARAM_H
  96. # define NO_CHMOD
  97. # define NO_SYSLOG
  98. # endif
  99. /********************************************************************
  100. The Microsoft section
  101. ********************************************************************/
  102. # if defined(OPENSSL_SYS_WIN32) && !defined(WIN32)
  103. # define WIN32
  104. # endif
  105. # if defined(OPENSSL_SYS_WINDOWS) && !defined(WINDOWS)
  106. # define WINDOWS
  107. # endif
  108. # if defined(OPENSSL_SYS_MSDOS) && !defined(MSDOS)
  109. # define MSDOS
  110. # endif
  111. # if (defined(MSDOS) || defined(OPENSSL_SYS_UEFI)) && !defined(GETPID_IS_MEANINGLESS)
  112. # define GETPID_IS_MEANINGLESS
  113. # endif
  114. # ifdef WIN32
  115. # define NO_SYS_UN_H
  116. # define get_last_sys_error() GetLastError()
  117. # define clear_sys_error() SetLastError(0)
  118. # if !defined(WINNT)
  119. # define WIN_CONSOLE_BUG
  120. # endif
  121. # else
  122. # define get_last_sys_error() errno
  123. # define clear_sys_error() errno=0
  124. # endif
  125. # if defined(WINDOWS)
  126. # define get_last_socket_error() WSAGetLastError()
  127. # define clear_socket_error() WSASetLastError(0)
  128. # define readsocket(s,b,n) recv((s),(b),(n),0)
  129. # define writesocket(s,b,n) send((s),(b),(n),0)
  130. # elif defined(__DJGPP__)
  131. # define WATT32
  132. # define get_last_socket_error() errno
  133. # define clear_socket_error() errno=0
  134. # define closesocket(s) close_s(s)
  135. # define readsocket(s,b,n) read_s(s,b,n)
  136. # define writesocket(s,b,n) send(s,b,n,0)
  137. # elif defined(OPENSSL_SYS_VMS)
  138. # define get_last_socket_error() errno
  139. # define clear_socket_error() errno=0
  140. # define ioctlsocket(a,b,c) ioctl(a,b,c)
  141. # define closesocket(s) close(s)
  142. # define readsocket(s,b,n) recv((s),(b),(n),0)
  143. # define writesocket(s,b,n) send((s),(b),(n),0)
  144. # elif defined(OPENSSL_SYS_VXWORKS)
  145. # define get_last_socket_error() errno
  146. # define clear_socket_error() errno=0
  147. # define ioctlsocket(a,b,c) ioctl((a),(b),(int)(c))
  148. # define closesocket(s) close(s)
  149. # define readsocket(s,b,n) read((s),(b),(n))
  150. # define writesocket(s,b,n) write((s),(char *)(b),(n))
  151. # elif defined(OPENSSL_SYS_NETWARE)
  152. # if defined(NETWARE_BSDSOCK)
  153. # define get_last_socket_error() errno
  154. # define clear_socket_error() errno=0
  155. # define closesocket(s) close(s)
  156. # define ioctlsocket(a,b,c) ioctl(a,b,c)
  157. # if defined(NETWARE_LIBC)
  158. # define readsocket(s,b,n) recv((s),(b),(n),0)
  159. # define writesocket(s,b,n) send((s),(b),(n),0)
  160. # else
  161. # define readsocket(s,b,n) recv((s),(char*)(b),(n),0)
  162. # define writesocket(s,b,n) send((s),(char*)(b),(n),0)
  163. # endif
  164. # else
  165. # define get_last_socket_error() WSAGetLastError()
  166. # define clear_socket_error() WSASetLastError(0)
  167. # define readsocket(s,b,n) recv((s),(b),(n),0)
  168. # define writesocket(s,b,n) send((s),(b),(n),0)
  169. # endif
  170. # else
  171. # define get_last_socket_error() errno
  172. # define clear_socket_error() errno=0
  173. # define ioctlsocket(a,b,c) ioctl(a,b,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),(b),(n))
  177. # endif
  178. # if (defined(WINDOWS) || defined(MSDOS))
  179. # ifdef __DJGPP__
  180. # include <unistd.h>
  181. # include <sys/stat.h>
  182. # include <sys/socket.h>
  183. # include <tcp.h>
  184. # include <netdb.h>
  185. # define _setmode setmode
  186. # define _O_TEXT O_TEXT
  187. # define _O_BINARY O_BINARY
  188. # undef DEVRANDOM
  189. # define DEVRANDOM "/dev/urandom\x24"
  190. # endif /* __DJGPP__ */
  191. # ifndef S_IFDIR
  192. # define S_IFDIR _S_IFDIR
  193. # endif
  194. # ifndef S_IFMT
  195. # define S_IFMT _S_IFMT
  196. # endif
  197. # if !defined(WINNT) && !defined(__DJGPP__)
  198. # define NO_SYSLOG
  199. # endif
  200. # define NO_DIRENT
  201. # ifdef WINDOWS
  202. # if !defined(_WIN32_WCE) && !defined(_WIN32_WINNT)
  203. /*
  204. * Defining _WIN32_WINNT here in e_os.h implies certain "discipline."
  205. * Most notably we ought to check for availability of each specific
  206. * routine that was introduced after denoted _WIN32_WINNT with
  207. * GetProcAddress(). Normally newer functions are masked with higher
  208. * _WIN32_WINNT in SDK headers. So that if you wish to use them in
  209. * some module, you'd need to override _WIN32_WINNT definition in
  210. * the target module in order to "reach for" prototypes, but replace
  211. * calls to new functions with indirect calls. Alternatively it
  212. * might be possible to achieve the goal by /DELAYLOAD-ing .DLLs
  213. * and check for current OS version instead.
  214. */
  215. # define _WIN32_WINNT 0x0501
  216. # endif
  217. # if !defined(OPENSSL_NO_SOCK) && (defined(_WIN32_WINNT) || defined(_WIN32_WCE))
  218. /*
  219. * Just like defining _WIN32_WINNT including winsock2.h implies
  220. * certain "discipline" for maintaining [broad] binary compatibility.
  221. * As long as structures are invariant among Winsock versions,
  222. * it's sufficient to check for specific Winsock2 API availability
  223. * at run-time [DSO_global_lookup is recommended]...
  224. */
  225. # include <winsock2.h>
  226. # include <ws2tcpip.h>
  227. /* yes, they have to be #included prior to <windows.h> */
  228. # endif
  229. # include <windows.h>
  230. # include <stdio.h>
  231. # include <stddef.h>
  232. # include <errno.h>
  233. # if defined(_WIN32_WCE) && !defined(EACCES)
  234. # define EACCES 13
  235. # endif
  236. # include <string.h>
  237. # ifdef _WIN64
  238. # define strlen(s) _strlen31(s)
  239. /* cut strings to 2GB */
  240. static __inline unsigned int _strlen31(const char *str)
  241. {
  242. unsigned int len = 0;
  243. while (*str && len < 0x80000000U)
  244. str++, len++;
  245. return len & 0x7FFFFFFF;
  246. }
  247. # endif
  248. # include <malloc.h>
  249. # if defined(_MSC_VER) && _MSC_VER<=1200 && defined(_MT) && defined(isspace)
  250. /* compensate for bug in VC6 ctype.h */
  251. # undef isspace
  252. # undef isdigit
  253. # undef isalnum
  254. # undef isupper
  255. # undef isxdigit
  256. # endif
  257. # if defined(_MSC_VER) && !defined(_WIN32_WCE) && !defined(_DLL) && defined(stdin)
  258. # if _MSC_VER>=1300 && _MSC_VER<1600
  259. # undef stdin
  260. # undef stdout
  261. # undef stderr
  262. FILE *__iob_func();
  263. # define stdin (&__iob_func()[0])
  264. # define stdout (&__iob_func()[1])
  265. # define stderr (&__iob_func()[2])
  266. # elif _MSC_VER<1300 && defined(I_CAN_LIVE_WITH_LNK4049)
  267. # undef stdin
  268. # undef stdout
  269. # undef stderr
  270. /*
  271. * pre-1300 has __p__iob(), but it's available only in msvcrt.lib,
  272. * or in other words with /MD. Declaring implicit import, i.e. with
  273. * _imp_ prefix, works correctly with all compiler options, but
  274. * without /MD results in LINK warning LNK4049: 'locally defined
  275. * symbol "__iob" imported'.
  276. */
  277. extern FILE *_imp___iob;
  278. # define stdin (&_imp___iob[0])
  279. # define stdout (&_imp___iob[1])
  280. # define stderr (&_imp___iob[2])
  281. # endif
  282. # endif
  283. # endif
  284. # include <io.h>
  285. # include <fcntl.h>
  286. # ifdef OPENSSL_SYS_WINCE
  287. # define OPENSSL_NO_POSIX_IO
  288. # endif
  289. # if defined (__BORLANDC__)
  290. # define _setmode setmode
  291. # define _O_TEXT O_TEXT
  292. # define _O_BINARY O_BINARY
  293. # define _int64 __int64
  294. # define _kbhit kbhit
  295. # endif
  296. # define EXIT(n) exit(n)
  297. # define LIST_SEPARATOR_CHAR ';'
  298. # ifndef X_OK
  299. # define X_OK 0
  300. # endif
  301. # ifndef W_OK
  302. # define W_OK 2
  303. # endif
  304. # ifndef R_OK
  305. # define R_OK 4
  306. # endif
  307. # define OPENSSL_CONF "openssl.cnf"
  308. # define NUL_DEV "nul"
  309. # define RFILE ".rnd"
  310. # ifdef OPENSSL_SYS_WINCE
  311. # define DEFAULT_HOME ""
  312. # else
  313. # define DEFAULT_HOME "C:"
  314. # endif
  315. /* Avoid Visual Studio 13 GetVersion deprecated problems */
  316. # if defined(_MSC_VER) && _MSC_VER>=1800
  317. # define check_winnt() (1)
  318. # define check_win_minplat(x) (1)
  319. # else
  320. # define check_winnt() (GetVersion() < 0x80000000)
  321. # define check_win_minplat(x) (LOBYTE(LOWORD(GetVersion())) >= (x))
  322. # endif
  323. # else /* The non-microsoft world */
  324. # ifdef OPENSSL_SYS_VMS
  325. # define VMS 1
  326. /*
  327. * some programs don't include stdlib, so exit() and others give implicit
  328. * function warnings
  329. */
  330. # include <stdlib.h>
  331. # if defined(__DECC)
  332. # include <unistd.h>
  333. # else
  334. # include <unixlib.h>
  335. # endif
  336. # define OPENSSL_CONF "openssl.cnf"
  337. # define RFILE ".rnd"
  338. # define LIST_SEPARATOR_CHAR ','
  339. # define NUL_DEV "NLA0:"
  340. /* We don't have any well-defined random devices on VMS, yet... */
  341. # undef DEVRANDOM
  342. /*-
  343. We need to do this since VMS has the following coding on status codes:
  344. Bits 0-2: status type: 0 = warning, 1 = success, 2 = error, 3 = info ...
  345. The important thing to know is that odd numbers are considered
  346. good, while even ones are considered errors.
  347. Bits 3-15: actual status number
  348. Bits 16-27: facility number. 0 is considered "unknown"
  349. Bits 28-31: control bits. If bit 28 is set, the shell won't try to
  350. output the message (which, for random codes, just looks ugly)
  351. So, what we do here is to change 0 to 1 to get the default success status,
  352. and everything else is shifted up to fit into the status number field, and
  353. the status is tagged as an error, which is what is wanted here.
  354. Finally, we add the VMS C facility code 0x35a000, because there are some
  355. programs, such as Perl, that will reinterpret the code back to something
  356. POSIXly. 'man perlvms' explains it further.
  357. NOTE: the perlvms manual wants to turn all codes 2 to 255 into success
  358. codes (status type = 1). I couldn't disagree more. Fortunately, the
  359. status type doesn't seem to bother Perl.
  360. -- Richard Levitte
  361. */
  362. # define EXIT(n) exit((n) ? (((n) << 3) | 2 | 0x10000000 | 0x35a000) : 1)
  363. # define NO_SYS_PARAM_H
  364. # define NO_SYS_UN_H
  365. # elif defined(OPENSSL_SYS_NETWARE)
  366. # include <fcntl.h>
  367. # include <unistd.h>
  368. # define NO_SYS_TYPES_H
  369. # undef DEVRANDOM
  370. # ifdef NETWARE_CLIB
  371. # define getpid GetThreadID
  372. extern int GetThreadID(void);
  373. /* # include <conio.h> */
  374. extern int kbhit(void);
  375. # else
  376. # include <screen.h>
  377. # endif
  378. # define NO_SYSLOG
  379. # define _setmode setmode
  380. # define _kbhit kbhit
  381. # define _O_TEXT O_TEXT
  382. # define _O_BINARY O_BINARY
  383. # define OPENSSL_CONF "openssl.cnf"
  384. # define RFILE ".rnd"
  385. # define LIST_SEPARATOR_CHAR ';'
  386. # define EXIT(n) { if (n) printf("ERROR: %d\n", (int)n); exit(n); }
  387. # else
  388. /* !defined VMS */
  389. # ifdef OPENSSL_UNISTD
  390. # include OPENSSL_UNISTD
  391. # else
  392. # include <unistd.h>
  393. # endif
  394. # ifndef NO_SYS_TYPES_H
  395. # include <sys/types.h>
  396. # endif
  397. # ifdef OPENSSL_SYS_WIN32_CYGWIN
  398. # include <io.h>
  399. # include <fcntl.h>
  400. # endif
  401. # define OPENSSL_CONF "openssl.cnf"
  402. # define RFILE ".rnd"
  403. # define LIST_SEPARATOR_CHAR ':'
  404. # define NUL_DEV "/dev/null"
  405. # define EXIT(n) exit(n)
  406. # endif
  407. # define OpenSSL_getpid() getpid()
  408. # endif
  409. /*************/
  410. # if defined(OPENSSL_NO_SOCK) && !defined(OPENSSL_NO_DGRAM)
  411. # define OPENSSL_NO_DGRAM
  412. # endif
  413. # ifdef USE_SOCKETS
  414. # if defined(WINDOWS) || defined(MSDOS)
  415. /* windows world */
  416. # ifdef OPENSSL_NO_SOCK
  417. # define OpenSSL_Write(a,b,c) (-1)
  418. # define OpenSSL_Read(a,b,c) (-1)
  419. # define SHUTDOWN(fd) close(fd)
  420. # define SHUTDOWN2(fd) close(fd)
  421. # elif !defined(__DJGPP__)
  422. # if defined(_WIN32_WCE) && _WIN32_WCE<410
  423. # define getservbyname _masked_declaration_getservbyname
  424. # endif
  425. # if !defined(IPPROTO_IP)
  426. /* winsock[2].h was included already? */
  427. # include <winsock.h>
  428. # endif
  429. # ifdef getservbyname
  430. # undef getservbyname
  431. /* this is used to be wcecompat/include/winsock_extras.h */
  432. struct servent *PASCAL getservbyname(const char *, const char *);
  433. # endif
  434. # ifdef _WIN64
  435. /*
  436. * Even though sizeof(SOCKET) is 8, it's safe to cast it to int, because
  437. * the value constitutes an index in per-process table of limited size
  438. * and not a real pointer. And we also depend on fact that all processors
  439. * Windows run on happen to be two's-complement, which allows to
  440. * interchange INVALID_SOCKET and -1.
  441. */
  442. # define socket(d,t,p) ((int)socket(d,t,p))
  443. # define accept(s,f,l) ((int)accept(s,f,l))
  444. # endif
  445. # define OpenSSL_Write(a,b,c) send((a),(b),(c),0)
  446. # define OpenSSL_Read(a,b,c) recv((a),(b),(c),0)
  447. # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
  448. # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
  449. # else
  450. # define OpenSSL_Write(a,b,c) write_s(a,b,c,0)
  451. # define OpenSSL_Read(a,b,c) read_s(a,b,c)
  452. # define SHUTDOWN(fd) close_s(fd)
  453. # define SHUTDOWN2(fd) close_s(fd)
  454. # endif
  455. # elif defined(OPENSSL_SYS_NETWARE)
  456. /*
  457. * NetWare uses the WinSock2 interfaces by default, but can be
  458. * configured for BSD
  459. */
  460. # if defined(NETWARE_BSDSOCK)
  461. # include <sys/socket.h>
  462. # include <netinet/in.h>
  463. # include <sys/time.h>
  464. # if defined(NETWARE_CLIB)
  465. # include <sys/bsdskt.h>
  466. # else
  467. # include <sys/select.h>
  468. # endif
  469. # define INVALID_SOCKET (int)(~0)
  470. # else
  471. # include <novsock2.h>
  472. # endif
  473. # define OpenSSL_Write(a,b,c) send((a),(b),(c),0)
  474. # define OpenSSL_Read(a,b,c) recv((a),(b),(c),0)
  475. # define SHUTDOWN(fd) { shutdown((fd),0); closesocket(fd); }
  476. # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket(fd); }
  477. # else
  478. # ifndef NO_SYS_PARAM_H
  479. # include <sys/param.h>
  480. # endif
  481. # ifdef OPENSSL_SYS_VXWORKS
  482. # include <time.h>
  483. # endif
  484. # include <netdb.h>
  485. # if defined(OPENSSL_SYS_VMS_NODECC)
  486. # include <socket.h>
  487. # include <in.h>
  488. # include <inet.h>
  489. # else
  490. # include <sys/socket.h>
  491. # ifndef NO_SYS_UN_H
  492. # ifdef OPENSSL_SYS_VXWORKS
  493. # include <streams/un.h>
  494. # else
  495. # include <sys/un.h>
  496. # endif
  497. # ifndef UNIX_PATH_MAX
  498. # define UNIX_PATH_MAX sizeof(((struct sockaddr_un *)NULL)->sun_path)
  499. # endif
  500. # endif
  501. # ifdef FILIO_H
  502. # include <sys/filio.h> /* FIONBIO in some SVR4, e.g. unixware, solaris */
  503. # endif
  504. # include <netinet/in.h>
  505. # include <arpa/inet.h>
  506. # endif
  507. # ifdef OPENSSL_SYS_AIX
  508. # include <sys/select.h>
  509. # endif
  510. # ifdef __QNX__
  511. # include <sys/select.h>
  512. # endif
  513. # ifndef VMS
  514. # include <sys/ioctl.h>
  515. # else
  516. /* ioctl is only in VMS > 7.0 and when socketshr is not used */
  517. # if !defined(TCPIP_TYPE_SOCKETSHR) && defined(__VMS_VER) && (__VMS_VER > 70000000)
  518. # include <sys/ioctl.h>
  519. # endif
  520. # endif
  521. # ifdef VMS
  522. # include <unixio.h>
  523. # if defined(TCPIP_TYPE_SOCKETSHR)
  524. # include <socketshr.h>
  525. # endif
  526. # endif
  527. # define OpenSSL_Read(a,b,c) read((a),(b),(c))
  528. # define OpenSSL_Write(a,b,c) write((a),(b),(c))
  529. # define SHUTDOWN(fd) { shutdown((fd),0); closesocket((fd)); }
  530. # define SHUTDOWN2(fd) { shutdown((fd),2); closesocket((fd)); }
  531. # ifndef INVALID_SOCKET
  532. # define INVALID_SOCKET (-1)
  533. # endif /* INVALID_SOCKET */
  534. # endif
  535. /*
  536. * Some IPv6 implementations are broken, disable them in known bad versions.
  537. */
  538. # if !defined(OPENSSL_USE_IPV6)
  539. # if defined(AF_INET6) && !defined(NETWARE_CLIB)
  540. # define OPENSSL_USE_IPV6 1
  541. # else
  542. # define OPENSSL_USE_IPV6 0
  543. # endif
  544. # endif
  545. # endif
  546. # ifndef OPENSSL_EXIT
  547. # if defined(MONOLITH) && !defined(OPENSSL_C)
  548. # define OPENSSL_EXIT(n) return(n)
  549. # else
  550. # define OPENSSL_EXIT(n) do { EXIT(n); return(n); } while(0)
  551. # endif
  552. # endif
  553. /***********************************************/
  554. # if defined(OPENSSL_SYS_WINDOWS)
  555. # define strcasecmp _stricmp
  556. # define strncasecmp _strnicmp
  557. # elif defined(OPENSSL_SYS_VMS)
  558. /* VMS below version 7.0 doesn't have strcasecmp() */
  559. # include "internal/o_str.h"
  560. # define strcasecmp OPENSSL_strcasecmp
  561. # define strncasecmp OPENSSL_strncasecmp
  562. # define OPENSSL_IMPLEMENTS_strncasecmp
  563. # elif defined(OPENSSL_SYS_OS2) && defined(__EMX__)
  564. # define strcasecmp stricmp
  565. # define strncasecmp strnicmp
  566. # elif defined(OPENSSL_SYS_NETWARE)
  567. # include <string.h>
  568. # if defined(NETWARE_CLIB)
  569. # define strcasecmp stricmp
  570. # define strncasecmp strnicmp
  571. # endif /* NETWARE_CLIB */
  572. # endif
  573. # if defined(OPENSSL_SYS_OS2) && defined(__EMX__)
  574. # include <io.h>
  575. # include <fcntl.h>
  576. # define NO_SYSLOG
  577. # endif
  578. /* vxworks */
  579. # if defined(OPENSSL_SYS_VXWORKS)
  580. # include <ioLib.h>
  581. # include <tickLib.h>
  582. # include <sysLib.h>
  583. # define TTY_STRUCT int
  584. # define sleep(a) taskDelay((a) * sysClkRateGet())
  585. # include <vxWorks.h>
  586. # include <sockLib.h>
  587. # include <taskLib.h>
  588. # define getpid taskIdSelf
  589. /*
  590. * NOTE: these are implemented by helpers in database app! if the database is
  591. * not linked, we need to implement them elswhere
  592. */
  593. struct hostent *gethostbyname(const char *name);
  594. struct hostent *gethostbyaddr(const char *addr, int length, int type);
  595. struct servent *getservbyname(const char *name, const char *proto);
  596. # endif
  597. /* end vxworks */
  598. #define OSSL_NELEM(x) (sizeof(x)/sizeof(x[0]))
  599. #ifdef __cplusplus
  600. }
  601. #endif
  602. #endif