setup.h 9.0 KB

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