setup.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. #ifndef __SETUP_H
  2. #define __SETUP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2004, Daniel Stenberg, <[email protected]>, et al.
  11. *
  12. * This software is licensed as described in the file COPYING, which
  13. * you should have received as part of this distribution. The terms
  14. * are also available at http://curl.haxx.se/docs/copyright.html.
  15. *
  16. * You may opt to use, copy, modify, merge, publish, distribute and/or sell
  17. * copies of the Software, and permit persons to whom the Software is
  18. * furnished to do so, under the terms of the COPYING file.
  19. *
  20. * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  21. * KIND, either express or implied.
  22. *
  23. * $Id$
  24. ***************************************************************************/
  25. #ifdef HTTP_ONLY
  26. #define CURL_DISABLE_FTP
  27. #define CURL_DISABLE_LDAP
  28. #define CURL_DISABLE_TELNET
  29. #define CURL_DISABLE_DICT
  30. #define CURL_DISABLE_FILE
  31. #define CURL_DISABLE_GOPHER
  32. #endif
  33. #if !defined(WIN32) && defined(__WIN32__)
  34. /* This should be a good Borland fix. Alexander J. Oss told us! */
  35. #define WIN32
  36. #endif
  37. #ifdef HAVE_CONFIG_H
  38. #include "config.h" /* the configure script results */
  39. #else
  40. #ifdef WIN32
  41. /* hand-modified win32 config.h! */
  42. #include "config-win32.h"
  43. #endif
  44. #endif
  45. #ifdef macintosh
  46. /* hand-modified MacOS config.h! */
  47. #include "config-mac.h"
  48. #endif
  49. #ifdef AMIGA
  50. /* hand-modified AmigaOS config.h! */
  51. #include "amigaos.h"
  52. #endif
  53. #ifndef TRUE
  54. #define TRUE 1
  55. #endif
  56. #ifndef FALSE
  57. #define FALSE 0
  58. #endif
  59. #if !defined(__cplusplus) && !defined(__BEOS__)
  60. typedef unsigned char bool;
  61. #define typedef_bool
  62. #endif
  63. #ifdef HAVE_LONGLONG
  64. #define LONG_LONG long long
  65. #define ENABLE_64BIT
  66. #else
  67. #ifdef _MSC_VER
  68. #define LONG_LONG __int64
  69. #define ENABLE_64BIT
  70. #endif
  71. #endif /* HAVE_LONGLONG */
  72. #ifndef SIZEOF_CURL_OFF_T
  73. /* If we don't know the size here, we assume a conservative size: 4. When
  74. building libcurl, the actual size of this variable should be define in the
  75. config*.h file. */
  76. #define SIZEOF_CURL_OFF_T 4
  77. #endif
  78. /* We set up our internal prefered (CURL_)FORMAT_OFF_T here */
  79. #if SIZEOF_CURL_OFF_T > 4
  80. #define FORMAT_OFF_T "lld"
  81. #else
  82. #define FORMAT_OFF_T "ld"
  83. #endif
  84. #ifdef NEED_REENTRANT
  85. /* Solaris machines needs _REENTRANT set for a few function prototypes and
  86. things to appear in the #include files. We need to #define it before all
  87. #include files */
  88. #define _REENTRANT
  89. #endif
  90. #include <stdio.h>
  91. #ifdef HAVE_ASSERT_H
  92. #include <assert.h>
  93. #endif
  94. #include <errno.h>
  95. #ifdef __TANDEM /* for nsr-tandem-nsk systems */
  96. #include <floss.h>
  97. #endif
  98. #if defined(HAVE_X509_H) && defined(HAVE_SSL_H) && defined(HAVE_RSA_H) && \
  99. defined(HAVE_PEM_H) && defined(HAVE_ERR_H) && defined(HAVE_CRYPTO_H) && \
  100. defined(HAVE_LIBSSL) && defined(HAVE_LIBCRYPTO)
  101. /* the six important includes files all exist and so do both libs,
  102. defined SSLeay usage */
  103. #define USE_SSLEAY 1
  104. #endif
  105. #if defined(HAVE_OPENSSL_X509_H) && defined(HAVE_OPENSSL_SSL_H) && \
  106. defined(HAVE_OPENSSL_RSA_H) && defined(HAVE_OPENSSL_PEM_H) && \
  107. defined(HAVE_OPENSSL_ERR_H) && defined(HAVE_OPENSSL_CRYPTO_H) && \
  108. defined(HAVE_LIBSSL) && defined(HAVE_LIBCRYPTO)
  109. /* the six important includes files all exist and so do both libs,
  110. defined SSLeay usage */
  111. #define USE_SSLEAY 1
  112. #define USE_OPENSSL 1
  113. #endif
  114. #ifndef STDC_HEADERS /* no standard C headers! */
  115. #include <curl/stdcheaders.h>
  116. #endif
  117. #if defined(CURLDEBUG) && defined(HAVE_ASSERT_H)
  118. #define curlassert(x) assert(x)
  119. #else
  120. /* does nothing without CURLDEBUG defined */
  121. #define curlassert(x)
  122. #endif
  123. #ifdef MSG_NOSIGNAL
  124. /* If we have the MSG_NOSIGNAL define, we make sure to use that in the forth
  125. argument to send() and recv() */
  126. #define SEND_4TH_ARG MSG_NOSIGNAL
  127. #define HAVE_MSG_NOSIGNAL 1 /* we have MSG_NOSIGNAL */
  128. #else
  129. #define SEND_4TH_ARG 0
  130. #endif
  131. /* Below we define four functions. They should
  132. 1. close a socket
  133. 2. read from a socket
  134. 3. write to a socket
  135. 4. set the SIGALRM signal timeout
  136. 5. set dir/file naming defines
  137. */
  138. #ifdef WIN32
  139. #ifndef WIN32_LEAN_AND_MEAN
  140. #define WIN32_LEAN_AND_MEAN /* Prevent including <winsock*.h> in <windows.h> */
  141. #endif
  142. #if (defined(ENABLE_IPV6) || defined(CURLDEBUG)) && defined(_MSC_VER) && \
  143. (!defined(_WIN32_WINNT) || _WIN32_WINNT < 0x0500)
  144. /*
  145. * Needed to pull in the real getaddrinfo() and not the inline version
  146. * in <wspiAPI.H> which doesn't support IPv6 (IPv4 only). <wspiAPI.H> is
  147. * included from <ws2tcpip.h> for <= 0x0500 SDKs.
  148. */
  149. #undef _WIN32_WINNT
  150. #define _WIN32_WINNT 0x0501
  151. #endif
  152. #include <winsock2.h> /* required by telnet.c */
  153. #if defined(ENABLE_IPV6) || defined(USE_SSLEAY)
  154. #include <ws2tcpip.h>
  155. #endif
  156. #if !defined(__GNUC__) || defined(__MINGW32__)
  157. #define sclose(x) closesocket(x)
  158. #define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG)
  159. #define swrite(x,y,z) (size_t)send(x,y,z, SEND_4TH_ARG)
  160. #undef HAVE_ALARM
  161. #else
  162. /* gcc-for-win is still good :) */
  163. #define sclose(x) close(x)
  164. #define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG)
  165. #define swrite(x,y,z) send(x,y,z, SEND_4TH_ARG)
  166. #define HAVE_ALARM
  167. #endif
  168. #define DIR_CHAR "\\"
  169. #define DOT_CHAR "_"
  170. #else
  171. #ifdef DJGPP
  172. #define sclose(x) close_s(x)
  173. #define sread(x,y,z) read_s(x,y,z)
  174. #define swrite(x,y,z) write_s(x,y,z)
  175. #define select(n,r,w,x,t) select_s(n,r,w,x,t)
  176. #define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
  177. #define IOCTL_3_ARGS
  178. #include <tcp.h>
  179. #ifdef word
  180. #undef word
  181. #endif
  182. #else
  183. #ifdef __BEOS__
  184. #define sclose(x) closesocket(x)
  185. #define sread(x,y,z) (ssize_t)recv(x,y,z, SEND_4TH_ARG)
  186. #define swrite(x,y,z) (ssize_t)send(x,y,z, SEND_4TH_ARG)
  187. #else
  188. #define sclose(x) close(x)
  189. #define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG)
  190. #define swrite(x,y,z) send(x,y,z, SEND_4TH_ARG)
  191. #endif
  192. #define HAVE_ALARM
  193. #endif
  194. #ifdef _AMIGASF
  195. #undef HAVE_ALARM
  196. #undef sclose
  197. #define sclose(x) CloseSocket(x)
  198. #endif
  199. #define DIR_CHAR "/"
  200. #define DOT_CHAR "."
  201. #ifdef DJGPP
  202. #undef DOT_CHAR
  203. #define DOT_CHAR "_"
  204. #endif
  205. #ifndef fileno /* sunos 4 have this as a macro! */
  206. int fileno( FILE *stream);
  207. #endif
  208. #endif
  209. /* now typedef our socket type */
  210. #ifdef WIN32
  211. typedef SOCKET curl_socket_t;
  212. #define CURL_SOCKET_BAD INVALID_SOCKET
  213. #else
  214. typedef int curl_socket_t;
  215. #define CURL_SOCKET_BAD -1
  216. #endif
  217. #if defined(ENABLE_IPV6) && defined(USE_ARES)
  218. #error "ares does not yet support IPv6. Disable IPv6 or ares and rebuild"
  219. #endif
  220. #if defined(WIN32) && !defined(__CYGWIN__) && !defined(USE_ARES) && \
  221. !defined(__LCC__) /* lcc-win32 doesn't have _beginthreadex() */
  222. #ifdef ENABLE_IPV6
  223. #define USE_THREADING_GETADDRINFO
  224. #else
  225. #define USE_THREADING_GETHOSTBYNAME /* Cygwin uses alarm() function */
  226. #endif
  227. #endif
  228. #ifdef mpeix
  229. #define IOCTL_3_ARGS
  230. #endif
  231. #ifndef ECONNRESET
  232. #ifdef WSAECONNRESET
  233. #define ECONNRESET WSAECONNRESET
  234. #else
  235. /* This will effectively prevent the code from working in this particular
  236. aspect, but it still compile fine! */
  237. #define ECONNRESET 10000
  238. #endif
  239. #endif
  240. #ifdef NETWARE
  241. #undef HAVE_ALARM
  242. #endif
  243. #ifdef HAVE_LIBIDN
  244. /* This could benefit from additional checks that some of the used/important
  245. header files are present as well before we define the USE_* define. */
  246. #define USE_LIBIDN
  247. #define LIBIDN_REQUIRED_VERSION "0.4.1"
  248. #endif
  249. #endif /* __CONFIG_H */