setup.h 8.8 KB

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