setup.h 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390
  1. #ifndef __LIB_CURL_SETUP_H
  2. #define __LIB_CURL_SETUP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2007, 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_TFTP
  27. #define CURL_DISABLE_FTP
  28. #define CURL_DISABLE_LDAP
  29. #define CURL_DISABLE_TELNET
  30. #define CURL_DISABLE_DICT
  31. #define CURL_DISABLE_FILE
  32. #endif /* HTTP_ONLY */
  33. #if !defined(WIN32) && defined(__WIN32__)
  34. /* Borland fix */
  35. #define WIN32
  36. #endif
  37. #if !defined(WIN32) && defined(_WIN32)
  38. /* VS2005 on x64 fix */
  39. #define WIN32
  40. #endif
  41. #if defined(__clang__)
  42. # pragma clang diagnostic ignored "-Wcast-align"
  43. #endif
  44. /*
  45. * Include configuration script results or hand-crafted
  46. * configuration file for platforms which lack config tool.
  47. */
  48. #ifdef HAVE_CONFIG_H
  49. #include "config.h"
  50. #else
  51. /*
  52. #ifdef _WIN32_WCE
  53. #include "config-win32ce.h"
  54. #else
  55. #ifdef WIN32
  56. #include "config-win32.h"
  57. #endif
  58. #endif
  59. */
  60. #ifdef macintosh
  61. #include "config-mac.h"
  62. #endif
  63. #ifdef AMIGA
  64. #include "amigaos.h"
  65. #endif
  66. #ifdef TPF
  67. #include "config-tpf.h" /* hand-modified TPF config.h */
  68. /* change which select is used for libcurl */
  69. #define select(a,b,c,d,e) tpf_select_libcurl(a,b,c,d,e)
  70. #endif
  71. #endif /* HAVE_CONFIG_H */
  72. /*
  73. * Include header files for windows builds before redefining anything.
  74. * Use this preproessor block only to include or exclude windows.h,
  75. * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
  76. * to any other further and independant block. Under Cygwin things work
  77. * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
  78. * never be included when __CYGWIN__ is defined. configure script takes
  79. * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
  80. * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
  81. */
  82. #ifdef HAVE_WINDOWS_H
  83. # ifndef WIN32_LEAN_AND_MEAN
  84. # define WIN32_LEAN_AND_MEAN
  85. # endif
  86. # include <windows.h>
  87. # ifdef HAVE_WINSOCK2_H
  88. # include <winsock2.h>
  89. # ifdef HAVE_WS2TCPIP_H
  90. # include <ws2tcpip.h>
  91. # endif
  92. # else
  93. # ifdef HAVE_WINSOCK_H
  94. # include <winsock.h>
  95. # endif
  96. # endif
  97. #endif
  98. /*
  99. * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
  100. * define USE_WINSOCK to 1 if we have and use WINSOCK API, else
  101. * undefine USE_WINSOCK.
  102. */
  103. #undef USE_WINSOCK
  104. #ifdef HAVE_WINSOCK2_H
  105. # define USE_WINSOCK 2
  106. #else
  107. # ifdef HAVE_WINSOCK_H
  108. # define USE_WINSOCK 1
  109. # endif
  110. #endif
  111. #ifndef TRUE
  112. #define TRUE 1
  113. #endif
  114. #ifndef FALSE
  115. #define FALSE 0
  116. #endif
  117. #if !defined(__cplusplus) && !defined(__BEOS__) && !defined(__ECOS) && !defined(typedef_bool)
  118. typedef unsigned char bool;
  119. #define typedef_bool
  120. #endif
  121. #ifdef HAVE_LONGLONG
  122. #define LONG_LONG long long
  123. #define ENABLE_64BIT
  124. #else
  125. #ifdef _MSC_VER
  126. #define LONG_LONG __int64
  127. #define ENABLE_64BIT
  128. #endif /* _MSC_VER */
  129. #endif /* HAVE_LONGLONG */
  130. #ifndef SIZEOF_CURL_OFF_T
  131. /* If we don't know the size here, we assume a conservative size: 4. When
  132. building libcurl, the actual size of this variable should be define in the
  133. config*.h file. */
  134. #define SIZEOF_CURL_OFF_T 4
  135. #endif
  136. /* We set up our internal prefered (CURL_)FORMAT_OFF_T here */
  137. #if SIZEOF_CURL_OFF_T > 4
  138. #define FORMAT_OFF_T "lld"
  139. #else
  140. #define FORMAT_OFF_T "ld"
  141. #endif /* SIZEOF_CURL_OFF_T */
  142. #ifndef _REENTRANT
  143. /* Solaris needs _REENTRANT set for a few function prototypes and things to
  144. appear in the #include files. We need to #define it before all #include
  145. files. Unixware needs it to build proper reentrant code. Others may also
  146. need it. */
  147. #define _REENTRANT
  148. #endif
  149. #include <stdio.h>
  150. #ifdef HAVE_ASSERT_H
  151. #include <assert.h>
  152. #endif
  153. #include <errno.h>
  154. #ifdef __TANDEM /* for nsr-tandem-nsk systems */
  155. #include <floss.h>
  156. #endif
  157. #ifndef STDC_HEADERS /* no standard C headers! */
  158. #include <curl/stdcheaders.h>
  159. #endif
  160. /*
  161. * PellesC cludge section (yikes);
  162. * - It has 'ssize_t', but it is in <unistd.h>. The way the headers
  163. * on Win32 are included, forces me to include this header here.
  164. * - sys_nerr, EINTR is missing in v4.0 or older.
  165. */
  166. #ifdef __POCC__
  167. #include <sys/types.h>
  168. #include <unistd.h>
  169. #if (__POCC__ <= 400)
  170. #define sys_nerr EILSEQ /* for strerror.c */
  171. #define EINTR -1 /* for select.c */
  172. #endif
  173. #endif
  174. /*
  175. * Salford-C cludge section (mostly borrowed from wxWidgets).
  176. */
  177. #ifdef __SALFORDC__
  178. #pragma suppress 353 /* Possible nested comments */
  179. #pragma suppress 593 /* Define not used */
  180. #pragma suppress 61 /* enum has no name */
  181. #pragma suppress 106 /* unnamed, unused parameter */
  182. #include <clib.h>
  183. #endif
  184. #if defined(CURLDEBUG) && defined(HAVE_ASSERT_H)
  185. #define curlassert(x) assert(x)
  186. #else
  187. /* does nothing without CURLDEBUG defined */
  188. #define curlassert(x)
  189. #endif
  190. /* To make large file support transparent even on Windows */
  191. #if defined(WIN32) && (SIZEOF_CURL_OFF_T > 4)
  192. #include <sys/stat.h> /* must come first before we redefine stat() */
  193. #include <io.h>
  194. #define lseek(x,y,z) _lseeki64(x, y, z)
  195. #define struct_stat struct _stati64
  196. #define stat(file,st) _stati64(file,st)
  197. #define fstat(fd,st) _fstati64(fd,st)
  198. #else
  199. #define struct_stat struct stat
  200. #endif /* Win32 with large file support */
  201. /* Below we define some functions. They should
  202. 1. close a socket
  203. 4. set the SIGALRM signal timeout
  204. 5. set dir/file naming defines
  205. */
  206. #ifdef WIN32
  207. #if !defined(__CYGWIN__)
  208. #define sclose(x) closesocket(x)
  209. #undef HAVE_ALARM
  210. #else
  211. /* gcc-for-win is still good :) */
  212. #define sclose(x) close(x)
  213. #define HAVE_ALARM
  214. #endif /* !GNU or mingw */
  215. #define DIR_CHAR "\\"
  216. #define DOT_CHAR "_"
  217. #else /* WIN32 */
  218. #ifdef MSDOS /* Watt-32 */
  219. #include <sys/ioctl.h>
  220. #define sclose(x) close_s(x)
  221. #define select(n,r,w,x,t) select_s(n,r,w,x,t)
  222. #define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
  223. #define IOCTL_3_ARGS
  224. #include <tcp.h>
  225. #ifdef word
  226. #undef word
  227. #endif
  228. #else /* MSDOS */
  229. #ifdef __VMS
  230. #define IOCTL_3_ARGS 1
  231. #endif
  232. #ifdef __BEOS__
  233. #define sclose(x) closesocket(x)
  234. #else /* __BEOS__ */
  235. #define sclose(x) close(x)
  236. #endif /* __BEOS__ */
  237. #define HAVE_ALARM
  238. #endif /* MSDOS */
  239. #ifdef _AMIGASF
  240. #undef HAVE_ALARM
  241. #undef sclose
  242. #define sclose(x) CloseSocket(x)
  243. #endif
  244. #define DIR_CHAR "/"
  245. #ifndef DOT_CHAR
  246. #define DOT_CHAR "."
  247. #endif
  248. #ifdef MSDOS
  249. #undef DOT_CHAR
  250. #define DOT_CHAR "_"
  251. #endif
  252. #ifndef fileno /* sunos 4 have this as a macro! */
  253. int fileno( FILE *stream);
  254. #endif
  255. #endif /* WIN32 */
  256. #if defined(WIN32) && !defined(__CYGWIN__) && !defined(USE_ARES) && \
  257. !defined(__LCC__) /* lcc-win32 doesn't have _beginthreadex() */
  258. #ifdef ENABLE_IPV6
  259. #define USE_THREADING_GETADDRINFO
  260. #else
  261. #define USE_THREADING_GETHOSTBYNAME /* Cygwin uses alarm() function */
  262. #endif
  263. #endif
  264. /* "cl -ML" or "cl -MLd" implies a single-threaded runtime library where
  265. _beginthreadex() is not available */
  266. #if (defined(_MSC_VER) && !defined(__POCC__)) && !defined(_MT) && !defined(USE_ARES)
  267. #undef USE_THREADING_GETADDRINFO
  268. #undef USE_THREADING_GETHOSTBYNAME
  269. #define CURL_NO__BEGINTHREADEX
  270. #endif
  271. /*
  272. * msvc 6.0 does not have struct sockaddr_storage and
  273. * does not define IPPROTO_ESP in winsock2.h. But both
  274. * are available if PSDK is properly installed.
  275. */
  276. #ifdef _MSC_VER
  277. #if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP))
  278. #undef HAVE_STRUCT_SOCKADDR_STORAGE
  279. #endif
  280. #endif
  281. #ifdef mpeix
  282. #define IOCTL_3_ARGS
  283. #endif
  284. #ifdef NETWARE
  285. #undef HAVE_ALARM
  286. #endif
  287. #if defined(HAVE_LIBIDN) && defined(HAVE_TLD_H)
  288. /* The lib was present and the tld.h header (which is missing in libidn 0.3.X
  289. but we only work with libidn 0.4.1 or later) */
  290. #define USE_LIBIDN
  291. #endif
  292. #ifndef SIZEOF_TIME_T
  293. /* assume default size of time_t to be 32 bit */
  294. #define SIZEOF_TIME_T 4
  295. #endif
  296. #define LIBIDN_REQUIRED_VERSION "0.4.1"
  297. #ifdef __UCLIBC__
  298. #define HAVE_INET_NTOA_R_2_ARGS 1
  299. #endif
  300. #if defined(USE_GNUTLS) || defined(USE_SSLEAY)
  301. #define USE_SSL /* Either OpenSSL || GnuTLS */
  302. #endif
  303. #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM)
  304. #if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI)
  305. #define USE_NTLM
  306. #endif
  307. #endif
  308. #ifdef CURLDEBUG
  309. #define DEBUGF(x) x
  310. #else
  311. #define DEBUGF(x)
  312. #endif
  313. /* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */
  314. #if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE)
  315. #define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE")
  316. #endif
  317. /*
  318. * Include macros and defines that should only be processed once.
  319. */
  320. #ifndef __SETUP_ONCE_H
  321. #include "setup_once.h"
  322. #endif
  323. #endif /* __LIB_CURL_SETUP_H */