setup.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. #ifndef __SETUP_H
  2. #define __SETUP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2004, Daniel Stenberg, <daniel@haxx.se>, 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: setup.h,v 1.59 2004/03/17 12:46:46 bagder Exp $
  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 VMS
  46. /* hand-modified VMS config.h! */
  47. #include "config-vms.h"
  48. #endif
  49. #ifdef NETWARE
  50. /* hand-modified NetWare config.h! */
  51. #include "config-netware.h"
  52. #endif
  53. #ifdef macintosh
  54. /* hand-modified MacOS config.h! */
  55. #include "config-mac.h"
  56. #endif
  57. #ifdef AMIGA
  58. /* hand-modified AmigaOS config.h! */
  59. #include "amigaos.h"
  60. #endif
  61. #ifndef TRUE
  62. #define TRUE 1
  63. #endif
  64. #ifndef FALSE
  65. #define FALSE 0
  66. #endif
  67. #if !defined(__cplusplus) && !defined(__BEOS__)
  68. typedef unsigned char bool;
  69. #define typedef_bool
  70. #endif
  71. #ifdef HAVE_LONGLONG
  72. #define LONG_LONG long long
  73. #define ENABLE_64BIT
  74. #else
  75. #ifdef _MSC_VER
  76. #define LONG_LONG __int64
  77. #define ENABLE_64BIT
  78. #endif
  79. #endif /* HAVE_LONGLONG */
  80. #ifndef SIZEOF_CURL_OFF_T
  81. /* If we don't know the size here, we assume a conservative size: 4. When
  82. building libcurl, the actual size of this variable should be define in the
  83. config*.h file. */
  84. #define SIZEOF_CURL_OFF_T 4
  85. #endif
  86. /* We set up our internal prefered (CURL_)FORMAT_OFF_T here */
  87. #if SIZEOF_CURL_OFF_T > 4
  88. #define FORMAT_OFF_T "lld"
  89. #else
  90. #define FORMAT_OFF_T "ld"
  91. #endif
  92. #ifdef NEED_REENTRANT
  93. /* Solaris machines needs _REENTRANT set for a few function prototypes and
  94. things to appear in the #include files. We need to #define it before all
  95. #include files */
  96. #define _REENTRANT
  97. #endif
  98. #include <stdio.h>
  99. #ifdef HAVE_ASSERT_H
  100. #include <assert.h>
  101. #endif
  102. #include <errno.h>
  103. #ifdef __TANDEM /* for nsr-tandem-nsk systems */
  104. #include <floss.h>
  105. #endif
  106. #if defined(HAVE_X509_H) && defined(HAVE_SSL_H) && defined(HAVE_RSA_H) && \
  107. defined(HAVE_PEM_H) && defined(HAVE_ERR_H) && defined(HAVE_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. #endif
  113. #if defined(HAVE_OPENSSL_X509_H) && defined(HAVE_OPENSSL_SSL_H) && \
  114. defined(HAVE_OPENSSL_RSA_H) && defined(HAVE_OPENSSL_PEM_H) && \
  115. defined(HAVE_OPENSSL_ERR_H) && defined(HAVE_OPENSSL_CRYPTO_H) && \
  116. defined(HAVE_LIBSSL) && defined(HAVE_LIBCRYPTO)
  117. /* the six important includes files all exist and so do both libs,
  118. defined SSLeay usage */
  119. #define USE_SSLEAY 1
  120. #define USE_OPENSSL 1
  121. #endif
  122. #ifndef STDC_HEADERS /* no standard C headers! */
  123. #ifdef VMS
  124. #include "../include/curl/stdcheaders.h"
  125. #else
  126. #include <curl/stdcheaders.h>
  127. #endif
  128. #endif
  129. #if defined(CURLDEBUG) && defined(HAVE_ASSERT_H)
  130. #define NDEBUG
  131. #define curlassert(x) assert(x)
  132. #else
  133. /* does nothing without CURLDEBUG defined */
  134. #define curlassert(x)
  135. #endif
  136. #ifdef MSG_NOSIGNAL
  137. /* If we have the MSG_NOSIGNAL define, we make sure to use that in the forth
  138. argument to send() and recv() */
  139. #define SEND_4TH_ARG MSG_NOSIGNAL
  140. #define HAVE_MSG_NOSIGNAL 1 /* we have MSG_NOSIGNAL */
  141. #else
  142. #define SEND_4TH_ARG 0
  143. #endif
  144. /* Below we define four functions. They should
  145. 1. close a socket
  146. 2. read from a socket
  147. 3. write to a socket
  148. 4. set the SIGALRM signal timeout
  149. 5. set dir/file naming defines
  150. */
  151. #ifdef WIN32
  152. #ifndef WIN32_LEAN_AND_MEAN
  153. #define WIN32_LEAN_AND_MEAN /* Prevent including <winsock*.h> in <windows.h> */
  154. #endif
  155. #include <winsock2.h> /* required by telnet.c */
  156. #if defined(ENABLE_IPV6) || defined(USE_SSLEAY)
  157. #include <ws2tcpip.h>
  158. #endif
  159. #if !defined(__GNUC__) || defined(__MINGW32__)
  160. #define sclose(x) closesocket(x)
  161. #define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG)
  162. #define swrite(x,y,z) (size_t)send(x,y,z, SEND_4TH_ARG)
  163. #undef HAVE_ALARM
  164. #else
  165. /* gcc-for-win is still good :) */
  166. #define sclose(x) close(x)
  167. #define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG)
  168. #define swrite(x,y,z) send(x,y,z, SEND_4TH_ARG)
  169. #define HAVE_ALARM
  170. #endif
  171. #define DIR_CHAR "\\"
  172. #define DOT_CHAR "_"
  173. #else
  174. #ifdef DJGPP
  175. #define sclose(x) close_s(x)
  176. #define sread(x,y,z) read_s(x,y,z)
  177. #define swrite(x,y,z) write_s(x,y,z)
  178. #define select(n,r,w,x,t) select_s(n,r,w,x,t)
  179. #define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
  180. #define IOCTL_3_ARGS
  181. #include <tcp.h>
  182. #ifdef word
  183. #undef word
  184. #endif
  185. #else
  186. #ifdef __BEOS__
  187. #define sclose(x) closesocket(x)
  188. #define sread(x,y,z) (ssize_t)recv(x,y,z, SEND_4TH_ARG)
  189. #define swrite(x,y,z) (ssize_t)send(x,y,z, SEND_4TH_ARG)
  190. #else
  191. #define sclose(x) close(x)
  192. #define sread(x,y,z) recv(x,y,z, SEND_4TH_ARG)
  193. #define swrite(x,y,z) send(x,y,z, SEND_4TH_ARG)
  194. #endif
  195. #define HAVE_ALARM
  196. #endif
  197. #ifdef _AMIGASF
  198. #undef HAVE_ALARM
  199. #undef sclose
  200. #define sclose(x) CloseSocket(x)
  201. #endif
  202. #define DIR_CHAR "/"
  203. #define DOT_CHAR "."
  204. #ifdef DJGPP
  205. #undef DOT_CHAR
  206. #define DOT_CHAR "_"
  207. #endif
  208. #ifndef fileno /* sunos 4 have this as a macro! */
  209. int fileno( FILE *stream);
  210. #endif
  211. #endif
  212. /* now typedef our socket type */
  213. #ifdef WIN32
  214. typedef SOCKET curl_socket_t;
  215. #define CURL_SOCKET_BAD INVALID_SOCKET
  216. #else
  217. typedef int curl_socket_t;
  218. #define CURL_SOCKET_BAD -1
  219. #endif
  220. #if defined(ENABLE_IPV6) && defined(USE_ARES)
  221. #error "ares does not yet support IPv6. Disable IPv6 or ares and rebuild"
  222. #endif
  223. #if defined(WIN32) && !defined(__CYGWIN32__) && !defined(USE_ARES) && !defined(ENABLE_IPV6)
  224. #define USE_THREADING_GETHOSTBYNAME /* Cygwin uses alarm() function */
  225. #endif
  226. /*
  227. * Curl_addrinfo MUST be used for name resolving information.
  228. * Information regarding a single IP witin a Curl_addrinfo MUST be stored in
  229. * a Curl_ipconnect struct.
  230. */
  231. #ifdef ENABLE_IPV6
  232. typedef struct addrinfo Curl_addrinfo;
  233. typedef struct addrinfo Curl_ipconnect;
  234. #else
  235. typedef struct hostent Curl_addrinfo;
  236. typedef struct in_addr Curl_ipconnect;
  237. #endif
  238. #ifdef VMS
  239. #define IOCTL_3_ARGS
  240. #endif
  241. #ifdef mpeix
  242. #define IOCTL_3_ARGS
  243. #endif
  244. #ifndef ECONNRESET
  245. #ifdef WSAECONNRESET
  246. #define ECONNRESET WSAECONNRESET
  247. #else
  248. /* This will effectively prevent the code from working in this particular
  249. aspect, but it still compile fine! */
  250. #define ECONNRESET 10000
  251. #endif
  252. #endif
  253. #ifdef NETWARE
  254. #undef HAVE_ALARM
  255. #endif
  256. #endif /* __CONFIG_H */