setup.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. #ifndef HEADER_CURL_LIB_SETUP_H
  2. #define HEADER_CURL_LIB_SETUP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2010, 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. /*
  26. * Define WIN32 when build target is Win32 API
  27. */
  28. #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && !defined(__SYMBIAN32__)
  29. #define WIN32
  30. #endif
  31. /*
  32. * Include configuration script results or hand-crafted
  33. * configuration file for platforms which lack config tool.
  34. */
  35. #ifdef HAVE_CONFIG_H
  36. #include "curl_config.h"
  37. #else /* HAVE_CONFIG_H */
  38. #ifdef _WIN32_WCE
  39. # include "config-win32ce.h"
  40. #else
  41. # ifdef WIN32
  42. # include "config-win32.h"
  43. # endif
  44. #endif
  45. #if defined(macintosh) && defined(__MRC__)
  46. # include "config-mac.h"
  47. #endif
  48. #ifdef __AMIGA__
  49. # include "amigaos.h"
  50. #endif
  51. #ifdef __SYMBIAN32__
  52. # include "config-symbian.h"
  53. #endif
  54. #ifdef __OS400__
  55. # include "config-os400.h"
  56. #endif
  57. #ifdef TPF
  58. # include "config-tpf.h"
  59. #endif
  60. #ifdef __VXWORKS__
  61. # include "config-vxworks.h"
  62. #endif
  63. #endif /* HAVE_CONFIG_H */
  64. /* ================================================================ */
  65. /* Definition of preprocessor macros/symbols which modify compiler */
  66. /* behavior or generated code characteristics must be done here, */
  67. /* as appropriate, before any system header file is included. It is */
  68. /* also possible to have them defined in the config file included */
  69. /* before this point. As a result of all this we frown inclusion of */
  70. /* system header files in our config files, avoid this at any cost. */
  71. /* ================================================================ */
  72. /*
  73. * AIX 4.3 and newer needs _THREAD_SAFE defined to build
  74. * proper reentrant code. Others may also need it.
  75. */
  76. #ifdef NEED_THREAD_SAFE
  77. # ifndef _THREAD_SAFE
  78. # define _THREAD_SAFE
  79. # endif
  80. #endif
  81. /*
  82. * Tru64 needs _REENTRANT set for a few function prototypes and
  83. * things to appear in the system header files. Unixware needs it
  84. * to build proper reentrant code. Others may also need it.
  85. */
  86. #ifdef NEED_REENTRANT
  87. # ifndef _REENTRANT
  88. # define _REENTRANT
  89. # endif
  90. #endif
  91. /* ================================================================ */
  92. /* If you need to include a system header file for your platform, */
  93. /* please, do it beyond the point further indicated in this file. */
  94. /* ================================================================ */
  95. /*
  96. * libcurl's external interface definitions are also used internally,
  97. * and might also include required system header files to define them.
  98. */
  99. #include <curl/curlbuild.h>
  100. /*
  101. * Compile time sanity checks must also be done when building the library.
  102. */
  103. #include <curl/curlrules.h>
  104. /*
  105. * Ensure that no one is using the old SIZEOF_CURL_OFF_T macro
  106. */
  107. #ifdef SIZEOF_CURL_OFF_T
  108. # error "SIZEOF_CURL_OFF_T shall not be defined!"
  109. Error Compilation_aborted_SIZEOF_CURL_OFF_T_shall_not_be_defined
  110. #endif
  111. /*
  112. * Set up internal curl_off_t formatting string directives for
  113. * exclusive use with libcurl's internal *printf functions.
  114. */
  115. #ifdef FORMAT_OFF_T
  116. # error "FORMAT_OFF_T shall not be defined before this point!"
  117. Error Compilation_aborted_FORMAT_OFF_T_already_defined
  118. #endif
  119. #ifdef FORMAT_OFF_TU
  120. # error "FORMAT_OFF_TU shall not be defined before this point!"
  121. Error Compilation_aborted_FORMAT_OFF_TU_already_defined
  122. #endif
  123. #if (CURL_SIZEOF_CURL_OFF_T > CURL_SIZEOF_LONG)
  124. # define FORMAT_OFF_T "lld"
  125. # define FORMAT_OFF_TU "llu"
  126. #else
  127. # define FORMAT_OFF_T "ld"
  128. # define FORMAT_OFF_TU "lu"
  129. #endif
  130. /*
  131. * Disable other protocols when http is the only one desired.
  132. */
  133. #ifdef HTTP_ONLY
  134. # define CURL_DISABLE_TFTP
  135. # define CURL_DISABLE_FTP
  136. # define CURL_DISABLE_LDAP
  137. # define CURL_DISABLE_TELNET
  138. # define CURL_DISABLE_DICT
  139. # define CURL_DISABLE_FILE
  140. # define CURL_DISABLE_RTSP
  141. #endif
  142. /*
  143. * When http is disabled rtsp is not supported.
  144. */
  145. #if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP)
  146. # define CURL_DISABLE_RTSP
  147. #endif
  148. /* ================================================================ */
  149. /* No system header file shall be included in this file before this */
  150. /* point. The only allowed ones are those included from curlbuild.h */
  151. /* ================================================================ */
  152. /*
  153. * OS/400 setup file includes some system headers.
  154. */
  155. #ifdef __OS400__
  156. # include "setup-os400.h"
  157. #endif
  158. /*
  159. * Include header files for windows builds before redefining anything.
  160. * Use this preprocessor block only to include or exclude windows.h,
  161. * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
  162. * to any other further and independent block. Under Cygwin things work
  163. * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
  164. * never be included when __CYGWIN__ is defined. configure script takes
  165. * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
  166. * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
  167. */
  168. #ifdef HAVE_WINDOWS_H
  169. # ifndef WIN32_LEAN_AND_MEAN
  170. # define WIN32_LEAN_AND_MEAN
  171. # endif
  172. # include <windows.h>
  173. # ifdef HAVE_WINSOCK2_H
  174. # include <winsock2.h>
  175. # ifdef HAVE_WS2TCPIP_H
  176. # include <ws2tcpip.h>
  177. # endif
  178. # else
  179. # ifdef HAVE_WINSOCK_H
  180. # include <winsock.h>
  181. # endif
  182. # endif
  183. #endif
  184. /*
  185. * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
  186. * define USE_WINSOCK to 1 if we have and use WINSOCK API, else
  187. * undefine USE_WINSOCK.
  188. */
  189. #undef USE_WINSOCK
  190. #ifdef HAVE_WINSOCK2_H
  191. # define USE_WINSOCK 2
  192. #else
  193. # ifdef HAVE_WINSOCK_H
  194. # define USE_WINSOCK 1
  195. # endif
  196. #endif
  197. #ifdef HAVE_EXTRA_STRICMP_H
  198. # include <extra/stricmp.h>
  199. #endif
  200. #ifdef HAVE_EXTRA_STRDUP_H
  201. # include <extra/strdup.h>
  202. #endif
  203. #ifdef TPF
  204. # include <strings.h> /* for bzero, strcasecmp, and strncasecmp */
  205. # include <string.h> /* for strcpy and strlen */
  206. # include <stdlib.h> /* for rand and srand */
  207. # include <sys/socket.h> /* for select and ioctl*/
  208. # include <netdb.h> /* for in_addr_t definition */
  209. # include <tpf/sysapi.h> /* for tpf_process_signals */
  210. /* change which select is used for libcurl */
  211. # define select(a,b,c,d,e) tpf_select_libcurl(a,b,c,d,e)
  212. #endif
  213. #ifdef __VXWORKS__
  214. # include <sockLib.h> /* for generic BSD socket functions */
  215. # include <ioLib.h> /* for basic I/O interface functions */
  216. #endif
  217. #include <stdio.h>
  218. #ifdef HAVE_ASSERT_H
  219. #include <assert.h>
  220. #endif
  221. #include <errno.h>
  222. #ifdef __TANDEM /* for nsr-tandem-nsk systems */
  223. #include <floss.h>
  224. #endif
  225. #ifndef STDC_HEADERS /* no standard C headers! */
  226. #include <curl/stdcheaders.h>
  227. #endif
  228. #ifdef __POCC__
  229. # include <sys/types.h>
  230. # include <unistd.h>
  231. # define sys_nerr EILSEQ
  232. #endif
  233. /*
  234. * Salford-C kludge section (mostly borrowed from wxWidgets).
  235. */
  236. #ifdef __SALFORDC__
  237. #pragma suppress 353 /* Possible nested comments */
  238. #pragma suppress 593 /* Define not used */
  239. #pragma suppress 61 /* enum has no name */
  240. #pragma suppress 106 /* unnamed, unused parameter */
  241. #include <clib.h>
  242. #endif
  243. /*
  244. * Large file (>2Gb) support using WIN32 functions.
  245. */
  246. #ifdef USE_WIN32_LARGE_FILES
  247. # include <io.h>
  248. # include <sys/types.h>
  249. # include <sys/stat.h>
  250. # define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence)
  251. # define fstat(fdes,stp) _fstati64(fdes, stp)
  252. # define stat(fname,stp) _stati64(fname, stp)
  253. # define struct_stat struct _stati64
  254. # define LSEEK_ERROR (__int64)-1
  255. #endif
  256. /*
  257. * Small file (<2Gb) support using WIN32 functions.
  258. */
  259. #ifdef USE_WIN32_SMALL_FILES
  260. # include <io.h>
  261. # include <sys/types.h>
  262. # include <sys/stat.h>
  263. # define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence)
  264. # define fstat(fdes,stp) _fstat(fdes, stp)
  265. # define stat(fname,stp) _stat(fname, stp)
  266. # define struct_stat struct _stat
  267. # define LSEEK_ERROR (long)-1
  268. #endif
  269. #ifndef struct_stat
  270. # define struct_stat struct stat
  271. #endif
  272. #ifndef LSEEK_ERROR
  273. # define LSEEK_ERROR (off_t)-1
  274. #endif
  275. /*
  276. * Default sizeof(off_t) in case it hasn't been defined in config file.
  277. */
  278. #ifndef SIZEOF_OFF_T
  279. # if defined(__VMS) && !defined(__VAX)
  280. # if defined(_LARGEFILE)
  281. # define SIZEOF_OFF_T 8
  282. # endif
  283. # elif defined(__OS400__) && defined(__ILEC400__)
  284. # if defined(_LARGE_FILES)
  285. # define SIZEOF_OFF_T 8
  286. # endif
  287. # elif defined(__MVS__) && defined(__IBMC__)
  288. # if defined(_LP64) || defined(_LARGE_FILES)
  289. # define SIZEOF_OFF_T 8
  290. # endif
  291. # elif defined(__370__) && defined(__IBMC__)
  292. # if defined(_LP64) || defined(_LARGE_FILES)
  293. # define SIZEOF_OFF_T 8
  294. # endif
  295. # endif
  296. # ifndef SIZEOF_OFF_T
  297. # define SIZEOF_OFF_T 4
  298. # endif
  299. #endif
  300. /* Below we define some functions. They should
  301. 4. set the SIGALRM signal timeout
  302. 5. set dir/file naming defines
  303. */
  304. #ifdef WIN32
  305. # define DIR_CHAR "\\"
  306. # define DOT_CHAR "_"
  307. #else /* WIN32 */
  308. # ifdef MSDOS /* Watt-32 */
  309. # include <sys/ioctl.h>
  310. # define select(n,r,w,x,t) select_s(n,r,w,x,t)
  311. # define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
  312. # include <tcp.h>
  313. # ifdef word
  314. # undef word
  315. # endif
  316. # ifdef byte
  317. # undef byte
  318. # endif
  319. # endif /* MSDOS */
  320. # ifdef __minix
  321. /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
  322. extern char * strtok_r(char *s, const char *delim, char **last);
  323. extern struct tm * gmtime_r(const time_t * const timep, struct tm *tmp);
  324. # endif
  325. # define DIR_CHAR "/"
  326. # ifndef DOT_CHAR
  327. # define DOT_CHAR "."
  328. # endif
  329. # ifdef MSDOS
  330. # undef DOT_CHAR
  331. # define DOT_CHAR "_"
  332. # endif
  333. # ifndef fileno /* sunos 4 have this as a macro! */
  334. int fileno( FILE *stream);
  335. # endif
  336. #endif /* WIN32 */
  337. /*
  338. * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
  339. * defined in ws2tcpip.h as well as to provide IPv6 support.
  340. */
  341. #if defined(_MSC_VER) && !defined(__POCC__)
  342. # if !defined(HAVE_WS2TCPIP_H) || \
  343. ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN))
  344. # undef HAVE_GETADDRINFO_THREADSAFE
  345. # undef HAVE_FREEADDRINFO
  346. # undef HAVE_GETADDRINFO
  347. # undef HAVE_GETNAMEINFO
  348. # undef ENABLE_IPV6
  349. # endif
  350. #endif
  351. /* ---------------------------------------------------------------- */
  352. /* resolver specialty compile-time defines */
  353. /* CURLRES_* defines to use in the host*.c sources */
  354. /* ---------------------------------------------------------------- */
  355. /*
  356. * lcc-win32 doesn't have _beginthreadex(), lacks threads support.
  357. */
  358. #if defined(__LCC__) && defined(WIN32)
  359. # undef USE_THREADS_POSIX
  360. # undef USE_THREADS_WIN32
  361. #endif
  362. /*
  363. * MSVC threads support requires a multi-threaded runtime library.
  364. * _beginthreadex() is not available in single-threaded ones.
  365. */
  366. #if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT)
  367. # undef USE_THREADS_POSIX
  368. # undef USE_THREADS_WIN32
  369. #endif
  370. /*
  371. * Mutually exclusive CURLRES_* definitions.
  372. */
  373. #ifdef USE_ARES
  374. # define CURLRES_ASYNCH
  375. # define CURLRES_ARES
  376. #elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
  377. # define CURLRES_ASYNCH
  378. # define CURLRES_THREADED
  379. #else
  380. # define CURLRES_SYNCH
  381. #endif
  382. #ifdef ENABLE_IPV6
  383. # define CURLRES_IPV6
  384. #else
  385. # define CURLRES_IPV4
  386. #endif
  387. /* ---------------------------------------------------------------- */
  388. /*
  389. * When using WINSOCK, TELNET protocol requires WINSOCK2 API.
  390. */
  391. #if defined(USE_WINSOCK) && (USE_WINSOCK != 2)
  392. # define CURL_DISABLE_TELNET 1
  393. #endif
  394. /*
  395. * msvc 6.0 does not have struct sockaddr_storage and
  396. * does not define IPPROTO_ESP in winsock2.h. But both
  397. * are available if PSDK is properly installed.
  398. */
  399. #if defined(_MSC_VER) && !defined(__POCC__)
  400. # if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP))
  401. # undef HAVE_STRUCT_SOCKADDR_STORAGE
  402. # endif
  403. #endif
  404. /*
  405. * Intentionally fail to build when using msvc 6.0 without PSDK installed.
  406. * The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK
  407. * in lib/config-win32.h although absolutely discouraged and unsupported.
  408. */
  409. #if defined(_MSC_VER) && !defined(__POCC__)
  410. # if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_))
  411. # if !defined(ALLOW_MSVC6_WITHOUT_PSDK)
  412. # error MSVC 6.0 requires 'February 2003 Platform SDK' a.k.a. 'Windows Server 2003 PSDK'
  413. # else
  414. # define CURL_DISABLE_LDAP 1
  415. # endif
  416. # endif
  417. #endif
  418. #ifdef NETWARE
  419. int netware_init(void);
  420. #ifndef __NOVELL_LIBC__
  421. #include <sys/bsdskt.h>
  422. #include <sys/timeval.h>
  423. #endif
  424. #endif
  425. #if defined(HAVE_LIBIDN) && defined(HAVE_TLD_H)
  426. /* The lib was present and the tld.h header (which is missing in libidn 0.3.X
  427. but we only work with libidn 0.4.1 or later) */
  428. #define USE_LIBIDN
  429. #endif
  430. #ifndef SIZEOF_TIME_T
  431. /* assume default size of time_t to be 32 bit */
  432. #define SIZEOF_TIME_T 4
  433. #endif
  434. #define LIBIDN_REQUIRED_VERSION "0.4.1"
  435. #if defined(USE_GNUTLS) || defined(USE_SSLEAY) || defined(USE_NSS) || defined(USE_QSOSSL)
  436. #define USE_SSL /* SSL support has been enabled */
  437. #endif
  438. #if !defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_NTLM)
  439. #if defined(USE_SSLEAY) || defined(USE_WINDOWS_SSPI) || defined(USE_GNUTLS)
  440. #define USE_NTLM
  441. #endif
  442. #endif
  443. /* non-configure builds may define CURL_WANTS_CA_BUNDLE_ENV */
  444. #if defined(CURL_WANTS_CA_BUNDLE_ENV) && !defined(CURL_CA_BUNDLE)
  445. #define CURL_CA_BUNDLE getenv("CURL_CA_BUNDLE")
  446. #endif
  447. /*
  448. * Include macros and defines that should only be processed once.
  449. */
  450. #ifndef __SETUP_ONCE_H
  451. #include "setup_once.h"
  452. #endif
  453. #endif /* HEADER_CURL_LIB_SETUP_H */