curl_setup.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763
  1. #ifndef HEADER_CURL_SETUP_H
  2. #define HEADER_CURL_SETUP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2017, 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 https://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. ***************************************************************************/
  24. #if defined(BUILDING_LIBCURL) && !defined(CURL_NO_OLDIES)
  25. #define CURL_NO_OLDIES
  26. #endif
  27. /*
  28. * Define WIN32 when build target is Win32 API
  29. */
  30. #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) && \
  31. !defined(__SYMBIAN32__)
  32. #define WIN32
  33. #endif
  34. #ifdef WIN32
  35. /*
  36. * Don't include unneeded stuff in Windows headers to avoid compiler
  37. * warnings and macro clashes.
  38. * Make sure to define this macro before including any Windows headers.
  39. */
  40. # ifndef WIN32_LEAN_AND_MEAN
  41. # define WIN32_LEAN_AND_MEAN
  42. # endif
  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 "curl_config.h"
  50. #else /* HAVE_CONFIG_H */
  51. #ifdef _WIN32_WCE
  52. # include "config-win32ce.h"
  53. #else
  54. # ifdef WIN32
  55. # include "config-win32.h"
  56. # endif
  57. #endif
  58. #if defined(macintosh) && defined(__MRC__)
  59. # include "config-mac.h"
  60. #endif
  61. #ifdef __riscos__
  62. # include "config-riscos.h"
  63. #endif
  64. #ifdef __AMIGA__
  65. # include "config-amigaos.h"
  66. #endif
  67. #ifdef __SYMBIAN32__
  68. # include "config-symbian.h"
  69. #endif
  70. #ifdef __OS400__
  71. # include "config-os400.h"
  72. #endif
  73. #ifdef TPF
  74. # include "config-tpf.h"
  75. #endif
  76. #ifdef __VXWORKS__
  77. # include "config-vxworks.h"
  78. #endif
  79. #endif /* HAVE_CONFIG_H */
  80. /* ================================================================ */
  81. /* Definition of preprocessor macros/symbols which modify compiler */
  82. /* behavior or generated code characteristics must be done here, */
  83. /* as appropriate, before any system header file is included. It is */
  84. /* also possible to have them defined in the config file included */
  85. /* before this point. As a result of all this we frown inclusion of */
  86. /* system header files in our config files, avoid this at any cost. */
  87. /* ================================================================ */
  88. /*
  89. * AIX 4.3 and newer needs _THREAD_SAFE defined to build
  90. * proper reentrant code. Others may also need it.
  91. */
  92. #ifdef NEED_THREAD_SAFE
  93. # ifndef _THREAD_SAFE
  94. # define _THREAD_SAFE
  95. # endif
  96. #endif
  97. /*
  98. * Tru64 needs _REENTRANT set for a few function prototypes and
  99. * things to appear in the system header files. Unixware needs it
  100. * to build proper reentrant code. Others may also need it.
  101. */
  102. #ifdef NEED_REENTRANT
  103. # ifndef _REENTRANT
  104. # define _REENTRANT
  105. # endif
  106. #endif
  107. /* Solaris needs this to get a POSIX-conformant getpwuid_r */
  108. #if defined(sun) || defined(__sun)
  109. # ifndef _POSIX_PTHREAD_SEMANTICS
  110. # define _POSIX_PTHREAD_SEMANTICS 1
  111. # endif
  112. #endif
  113. /* ================================================================ */
  114. /* If you need to include a system header file for your platform, */
  115. /* please, do it beyond the point further indicated in this file. */
  116. /* ================================================================ */
  117. #include <curl/curl.h>
  118. #define CURL_SIZEOF_CURL_OFF_T SIZEOF_CURL_OFF_T
  119. /*
  120. * Disable other protocols when http is the only one desired.
  121. */
  122. #ifdef HTTP_ONLY
  123. # ifndef CURL_DISABLE_TFTP
  124. # define CURL_DISABLE_TFTP
  125. # endif
  126. # ifndef CURL_DISABLE_FTP
  127. # define CURL_DISABLE_FTP
  128. # endif
  129. # ifndef CURL_DISABLE_LDAP
  130. # define CURL_DISABLE_LDAP
  131. # endif
  132. # ifndef CURL_DISABLE_TELNET
  133. # define CURL_DISABLE_TELNET
  134. # endif
  135. # ifndef CURL_DISABLE_DICT
  136. # define CURL_DISABLE_DICT
  137. # endif
  138. # ifndef CURL_DISABLE_FILE
  139. # define CURL_DISABLE_FILE
  140. # endif
  141. # ifndef CURL_DISABLE_RTSP
  142. # define CURL_DISABLE_RTSP
  143. # endif
  144. # ifndef CURL_DISABLE_POP3
  145. # define CURL_DISABLE_POP3
  146. # endif
  147. # ifndef CURL_DISABLE_IMAP
  148. # define CURL_DISABLE_IMAP
  149. # endif
  150. # ifndef CURL_DISABLE_SMTP
  151. # define CURL_DISABLE_SMTP
  152. # endif
  153. # ifndef CURL_DISABLE_GOPHER
  154. # define CURL_DISABLE_GOPHER
  155. # endif
  156. # ifndef CURL_DISABLE_SMB
  157. # define CURL_DISABLE_SMB
  158. # endif
  159. #endif
  160. /*
  161. * When http is disabled rtsp is not supported.
  162. */
  163. #if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP)
  164. # define CURL_DISABLE_RTSP
  165. #endif
  166. /* ================================================================ */
  167. /* No system header file shall be included in this file before this */
  168. /* point. The only allowed ones are those included from curl/system.h */
  169. /* ================================================================ */
  170. /*
  171. * OS/400 setup file includes some system headers.
  172. */
  173. #ifdef __OS400__
  174. # include "setup-os400.h"
  175. #endif
  176. /*
  177. * VMS setup file includes some system headers.
  178. */
  179. #ifdef __VMS
  180. # include "setup-vms.h"
  181. #endif
  182. /*
  183. * Use getaddrinfo to resolve the IPv4 address literal. If the current network
  184. * interface doesn’t support IPv4, but supports IPv6, NAT64, and DNS64,
  185. * performing this task will result in a synthesized IPv6 address.
  186. */
  187. #ifdef __APPLE__
  188. #define USE_RESOLVE_ON_IPS 1
  189. #endif
  190. /*
  191. * Include header files for windows builds before redefining anything.
  192. * Use this preprocessor block only to include or exclude windows.h,
  193. * winsock2.h, ws2tcpip.h or winsock.h. Any other windows thing belongs
  194. * to any other further and independent block. Under Cygwin things work
  195. * just as under linux (e.g. <sys/socket.h>) and the winsock headers should
  196. * never be included when __CYGWIN__ is defined. configure script takes
  197. * care of this, not defining HAVE_WINDOWS_H, HAVE_WINSOCK_H, HAVE_WINSOCK2_H,
  198. * neither HAVE_WS2TCPIP_H when __CYGWIN__ is defined.
  199. */
  200. #ifdef HAVE_WINDOWS_H
  201. # if defined(UNICODE) && !defined(_UNICODE)
  202. # define _UNICODE
  203. # endif
  204. # if defined(_UNICODE) && !defined(UNICODE)
  205. # define UNICODE
  206. # endif
  207. # include <windows.h>
  208. # ifdef HAVE_WINSOCK2_H
  209. # include <winsock2.h>
  210. # ifdef HAVE_WS2TCPIP_H
  211. # include <ws2tcpip.h>
  212. # endif
  213. # else
  214. # ifdef HAVE_WINSOCK_H
  215. # include <winsock.h>
  216. # endif
  217. # endif
  218. # include <tchar.h>
  219. # ifdef UNICODE
  220. typedef wchar_t *(*curl_wcsdup_callback)(const wchar_t *str);
  221. # endif
  222. #endif
  223. /*
  224. * Define USE_WINSOCK to 2 if we have and use WINSOCK2 API, else
  225. * define USE_WINSOCK to 1 if we have and use WINSOCK API, else
  226. * undefine USE_WINSOCK.
  227. */
  228. #undef USE_WINSOCK
  229. #ifdef HAVE_WINSOCK2_H
  230. # define USE_WINSOCK 2
  231. #else
  232. # ifdef HAVE_WINSOCK_H
  233. # define USE_WINSOCK 1
  234. # endif
  235. #endif
  236. #ifdef USE_LWIPSOCK
  237. # include <lwip/init.h>
  238. # include <lwip/sockets.h>
  239. # include <lwip/netdb.h>
  240. #endif
  241. #ifdef HAVE_EXTRA_STRICMP_H
  242. # include <extra/stricmp.h>
  243. #endif
  244. #ifdef HAVE_EXTRA_STRDUP_H
  245. # include <extra/strdup.h>
  246. #endif
  247. #ifdef TPF
  248. # include <strings.h> /* for bzero, strcasecmp, and strncasecmp */
  249. # include <string.h> /* for strcpy and strlen */
  250. # include <stdlib.h> /* for rand and srand */
  251. # include <sys/socket.h> /* for select and ioctl*/
  252. # include <netdb.h> /* for in_addr_t definition */
  253. # include <tpf/sysapi.h> /* for tpf_process_signals */
  254. /* change which select is used for libcurl */
  255. # define select(a,b,c,d,e) tpf_select_libcurl(a,b,c,d,e)
  256. #endif
  257. #ifdef __VXWORKS__
  258. # include <sockLib.h> /* for generic BSD socket functions */
  259. # include <ioLib.h> /* for basic I/O interface functions */
  260. #endif
  261. #ifdef __AMIGA__
  262. # ifndef __ixemul__
  263. # include <exec/types.h>
  264. # include <exec/execbase.h>
  265. # include <proto/exec.h>
  266. # include <proto/dos.h>
  267. # define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
  268. # endif
  269. #endif
  270. #include <stdio.h>
  271. #ifdef HAVE_ASSERT_H
  272. #include <assert.h>
  273. #endif
  274. #ifdef __TANDEM /* for nsr-tandem-nsk systems */
  275. #include <floss.h>
  276. #endif
  277. #ifndef STDC_HEADERS /* no standard C headers! */
  278. #include <curl/stdcheaders.h>
  279. #endif
  280. #ifdef __POCC__
  281. # include <sys/types.h>
  282. # include <unistd.h>
  283. # define sys_nerr EILSEQ
  284. #endif
  285. /*
  286. * Salford-C kludge section (mostly borrowed from wxWidgets).
  287. */
  288. #ifdef __SALFORDC__
  289. #pragma suppress 353 /* Possible nested comments */
  290. #pragma suppress 593 /* Define not used */
  291. #pragma suppress 61 /* enum has no name */
  292. #pragma suppress 106 /* unnamed, unused parameter */
  293. #include <clib.h>
  294. #endif
  295. /*
  296. * Large file (>2Gb) support using WIN32 functions.
  297. */
  298. #ifdef USE_WIN32_LARGE_FILES
  299. # include <io.h>
  300. # include <sys/types.h>
  301. # include <sys/stat.h>
  302. # undef lseek
  303. # define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence)
  304. # undef fstat
  305. # define fstat(fdes,stp) _fstati64(fdes, stp)
  306. # undef stat
  307. # define stat(fname,stp) _stati64(fname, stp)
  308. # define struct_stat struct _stati64
  309. # define LSEEK_ERROR (__int64)-1
  310. #endif
  311. /*
  312. * Small file (<2Gb) support using WIN32 functions.
  313. */
  314. #ifdef USE_WIN32_SMALL_FILES
  315. # include <io.h>
  316. # include <sys/types.h>
  317. # include <sys/stat.h>
  318. # ifndef _WIN32_WCE
  319. # undef lseek
  320. # define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence)
  321. # define fstat(fdes,stp) _fstat(fdes, stp)
  322. # define stat(fname,stp) _stat(fname, stp)
  323. # define struct_stat struct _stat
  324. # endif
  325. # define LSEEK_ERROR (long)-1
  326. #endif
  327. #ifndef struct_stat
  328. # define struct_stat struct stat
  329. #endif
  330. #ifndef LSEEK_ERROR
  331. # define LSEEK_ERROR (off_t)-1
  332. #endif
  333. /*
  334. * Default sizeof(off_t) in case it hasn't been defined in config file.
  335. */
  336. #ifndef SIZEOF_OFF_T
  337. # if defined(__VMS) && !defined(__VAX)
  338. # if defined(_LARGEFILE)
  339. # define SIZEOF_OFF_T 8
  340. # endif
  341. # elif defined(__OS400__) && defined(__ILEC400__)
  342. # if defined(_LARGE_FILES)
  343. # define SIZEOF_OFF_T 8
  344. # endif
  345. # elif defined(__MVS__) && defined(__IBMC__)
  346. # if defined(_LP64) || defined(_LARGE_FILES)
  347. # define SIZEOF_OFF_T 8
  348. # endif
  349. # elif defined(__370__) && defined(__IBMC__)
  350. # if defined(_LP64) || defined(_LARGE_FILES)
  351. # define SIZEOF_OFF_T 8
  352. # endif
  353. # endif
  354. # ifndef SIZEOF_OFF_T
  355. # define SIZEOF_OFF_T 4
  356. # endif
  357. #endif
  358. /*
  359. * Arg 2 type for gethostname in case it hasn't been defined in config file.
  360. */
  361. #ifndef GETHOSTNAME_TYPE_ARG2
  362. # ifdef USE_WINSOCK
  363. # define GETHOSTNAME_TYPE_ARG2 int
  364. # else
  365. # define GETHOSTNAME_TYPE_ARG2 size_t
  366. # endif
  367. #endif
  368. /* Below we define some functions. They should
  369. 4. set the SIGALRM signal timeout
  370. 5. set dir/file naming defines
  371. */
  372. #ifdef WIN32
  373. # define DIR_CHAR "\\"
  374. # define DOT_CHAR "_"
  375. #else /* WIN32 */
  376. # ifdef MSDOS /* Watt-32 */
  377. # include <sys/ioctl.h>
  378. # define select(n,r,w,x,t) select_s(n,r,w,x,t)
  379. # define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
  380. # include <tcp.h>
  381. # ifdef word
  382. # undef word
  383. # endif
  384. # ifdef byte
  385. # undef byte
  386. # endif
  387. # endif /* MSDOS */
  388. # ifdef __minix
  389. /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
  390. extern char *strtok_r(char *s, const char *delim, char **last);
  391. extern struct tm *gmtime_r(const time_t * const timep, struct tm *tmp);
  392. # endif
  393. # define DIR_CHAR "/"
  394. # ifndef DOT_CHAR
  395. # define DOT_CHAR "."
  396. # endif
  397. # ifdef MSDOS
  398. # undef DOT_CHAR
  399. # define DOT_CHAR "_"
  400. # endif
  401. # ifndef fileno /* sunos 4 have this as a macro! */
  402. int fileno(FILE *stream);
  403. # endif
  404. #endif /* WIN32 */
  405. /*
  406. * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
  407. * defined in ws2tcpip.h as well as to provide IPv6 support.
  408. * Does not apply if lwIP is used.
  409. */
  410. #if defined(_MSC_VER) && !defined(__POCC__) && !defined(USE_LWIPSOCK)
  411. # if !defined(HAVE_WS2TCPIP_H) || \
  412. ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN))
  413. # undef HAVE_GETADDRINFO_THREADSAFE
  414. # undef HAVE_FREEADDRINFO
  415. # undef HAVE_GETADDRINFO
  416. # undef HAVE_GETNAMEINFO
  417. # undef ENABLE_IPV6
  418. # endif
  419. #endif
  420. /* ---------------------------------------------------------------- */
  421. /* resolver specialty compile-time defines */
  422. /* CURLRES_* defines to use in the host*.c sources */
  423. /* ---------------------------------------------------------------- */
  424. /*
  425. * lcc-win32 doesn't have _beginthreadex(), lacks threads support.
  426. */
  427. #if defined(__LCC__) && defined(WIN32)
  428. # undef USE_THREADS_POSIX
  429. # undef USE_THREADS_WIN32
  430. #endif
  431. /*
  432. * MSVC threads support requires a multi-threaded runtime library.
  433. * _beginthreadex() is not available in single-threaded ones.
  434. */
  435. #if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT)
  436. # undef USE_THREADS_POSIX
  437. # undef USE_THREADS_WIN32
  438. #endif
  439. /*
  440. * Mutually exclusive CURLRES_* definitions.
  441. */
  442. #ifdef USE_ARES
  443. # define CURLRES_ASYNCH
  444. # define CURLRES_ARES
  445. /* now undef the stock libc functions just to avoid them being used */
  446. # undef HAVE_GETADDRINFO
  447. # undef HAVE_FREEADDRINFO
  448. # undef HAVE_GETHOSTBYNAME
  449. #elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
  450. # define CURLRES_ASYNCH
  451. # define CURLRES_THREADED
  452. #else
  453. # define CURLRES_SYNCH
  454. #endif
  455. #ifdef ENABLE_IPV6
  456. # define CURLRES_IPV6
  457. #else
  458. # define CURLRES_IPV4
  459. #endif
  460. /* ---------------------------------------------------------------- */
  461. /*
  462. * When using WINSOCK, TELNET protocol requires WINSOCK2 API.
  463. */
  464. #if defined(USE_WINSOCK) && (USE_WINSOCK != 2)
  465. # define CURL_DISABLE_TELNET 1
  466. #endif
  467. /*
  468. * msvc 6.0 does not have struct sockaddr_storage and
  469. * does not define IPPROTO_ESP in winsock2.h. But both
  470. * are available if PSDK is properly installed.
  471. */
  472. #if defined(_MSC_VER) && !defined(__POCC__)
  473. # if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP))
  474. # undef HAVE_STRUCT_SOCKADDR_STORAGE
  475. # endif
  476. #endif
  477. /*
  478. * Intentionally fail to build when using msvc 6.0 without PSDK installed.
  479. * The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK
  480. * in lib/config-win32.h although absolutely discouraged and unsupported.
  481. */
  482. #if defined(_MSC_VER) && !defined(__POCC__)
  483. # if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_))
  484. # if !defined(ALLOW_MSVC6_WITHOUT_PSDK)
  485. # error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. \
  486. "Windows Server 2003 PSDK"
  487. # else
  488. # define CURL_DISABLE_LDAP 1
  489. # endif
  490. # endif
  491. #endif
  492. #ifdef NETWARE
  493. int netware_init(void);
  494. #ifndef __NOVELL_LIBC__
  495. #include <sys/bsdskt.h>
  496. #include <sys/timeval.h>
  497. #endif
  498. #endif
  499. #if defined(HAVE_LIBIDN2) && defined(HAVE_IDN2_H) && !defined(USE_WIN32_IDN)
  500. /* The lib and header are present */
  501. #define USE_LIBIDN2
  502. #endif
  503. #if defined(USE_LIBIDN2) && defined(USE_WIN32_IDN)
  504. #error "Both libidn2 and WinIDN are enabled, choose one."
  505. #endif
  506. #ifndef SIZEOF_TIME_T
  507. /* assume default size of time_t to be 32 bit */
  508. #define SIZEOF_TIME_T 4
  509. #endif
  510. #define LIBIDN_REQUIRED_VERSION "0.4.1"
  511. #if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_NSS) || \
  512. defined(USE_POLARSSL) || defined(USE_AXTLS) || defined(USE_MBEDTLS) || \
  513. defined(USE_CYASSL) || defined(USE_SCHANNEL) || \
  514. defined(USE_DARWINSSL) || defined(USE_GSKIT)
  515. #define USE_SSL /* SSL support has been enabled */
  516. #endif
  517. /* Single point where USE_SPNEGO definition might be defined */
  518. #if !defined(CURL_DISABLE_CRYPTO_AUTH) && \
  519. (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI))
  520. #define USE_SPNEGO
  521. #endif
  522. /* Single point where USE_KERBEROS5 definition might be defined */
  523. #if !defined(CURL_DISABLE_CRYPTO_AUTH) && \
  524. (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI))
  525. #define USE_KERBEROS5
  526. #endif
  527. /* Single point where USE_NTLM definition might be defined */
  528. #if !defined(CURL_DISABLE_NTLM) && !defined(CURL_DISABLE_CRYPTO_AUTH)
  529. #if defined(USE_OPENSSL) || defined(USE_WINDOWS_SSPI) || \
  530. defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_DARWINSSL) || \
  531. defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \
  532. defined(USE_MBEDTLS)
  533. #define USE_NTLM
  534. # if defined(USE_MBEDTLS)
  535. /* Get definition of MBEDTLS_MD4_C */
  536. # include <mbedtls/md4.h>
  537. # endif
  538. #endif
  539. #endif
  540. #ifdef CURL_WANTS_CA_BUNDLE_ENV
  541. #error "No longer supported. Set CURLOPT_CAINFO at runtime instead."
  542. #endif
  543. /*
  544. * Provide a mechanism to silence picky compilers, such as gcc 4.6+.
  545. * Parameters should of course normally not be unused, but for example when
  546. * we have multiple implementations of the same interface it may happen.
  547. */
  548. #if defined(__GNUC__) && ((__GNUC__ >= 3) || \
  549. ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7)))
  550. # define UNUSED_PARAM __attribute__((__unused__))
  551. # define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  552. #else
  553. # define UNUSED_PARAM /*NOTHING*/
  554. # define WARN_UNUSED_RESULT
  555. #endif
  556. /*
  557. * Include macros and defines that should only be processed once.
  558. */
  559. #ifndef HEADER_CURL_SETUP_ONCE_H
  560. #include "curl_setup_once.h"
  561. #endif
  562. /*
  563. * Definition of our NOP statement Object-like macro
  564. */
  565. #ifndef Curl_nop_stmt
  566. # define Curl_nop_stmt do { } WHILE_FALSE
  567. #endif
  568. /*
  569. * Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
  570. */
  571. #if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H)
  572. # if defined(SOCKET) || \
  573. defined(USE_WINSOCK) || \
  574. defined(HAVE_WINSOCK_H) || \
  575. defined(HAVE_WINSOCK2_H) || \
  576. defined(HAVE_WS2TCPIP_H)
  577. # error "Winsock and lwIP TCP/IP stack definitions shall not coexist!"
  578. # endif
  579. #endif
  580. /*
  581. * Portable symbolic names for Winsock shutdown() mode flags.
  582. */
  583. #ifdef USE_WINSOCK
  584. # define SHUT_RD 0x00
  585. # define SHUT_WR 0x01
  586. # define SHUT_RDWR 0x02
  587. #endif
  588. /* Define S_ISREG if not defined by system headers, f.e. MSVC */
  589. #if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
  590. #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  591. #endif
  592. /* Define S_ISDIR if not defined by system headers, f.e. MSVC */
  593. #if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
  594. #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  595. #endif
  596. /* In Windows the default file mode is text but an application can override it.
  597. Therefore we specify it explicitly. https://github.com/curl/curl/pull/258
  598. */
  599. #if defined(WIN32) || defined(MSDOS)
  600. #define FOPEN_READTEXT "rt"
  601. #define FOPEN_WRITETEXT "wt"
  602. #define FOPEN_APPENDTEXT "at"
  603. #elif defined(__CYGWIN__)
  604. /* Cygwin has specific behavior we need to address when WIN32 is not defined.
  605. https://cygwin.com/cygwin-ug-net/using-textbinary.html
  606. For write we want our output to have line endings of LF and be compatible with
  607. other Cygwin utilities. For read we want to handle input that may have line
  608. endings either CRLF or LF so 't' is appropriate.
  609. */
  610. #define FOPEN_READTEXT "rt"
  611. #define FOPEN_WRITETEXT "w"
  612. #define FOPEN_APPENDTEXT "a"
  613. #else
  614. #define FOPEN_READTEXT "r"
  615. #define FOPEN_WRITETEXT "w"
  616. #define FOPEN_APPENDTEXT "a"
  617. #endif
  618. /* WinSock destroys recv() buffer when send() failed.
  619. * Enabled automatically for Windows and for Cygwin as Cygwin sockets are
  620. * wrappers for WinSock sockets. https://github.com/curl/curl/issues/657
  621. * Define DONT_USE_RECV_BEFORE_SEND_WORKAROUND to force disable workaround.
  622. */
  623. #if !defined(DONT_USE_RECV_BEFORE_SEND_WORKAROUND)
  624. # if defined(WIN32) || defined(__CYGWIN__)
  625. # define USE_RECV_BEFORE_SEND_WORKAROUND
  626. # endif
  627. #else /* DONT_USE_RECV_BEFORE_SEND_WORKAROUNDS */
  628. # ifdef USE_RECV_BEFORE_SEND_WORKAROUND
  629. # undef USE_RECV_BEFORE_SEND_WORKAROUND
  630. # endif
  631. #endif /* DONT_USE_RECV_BEFORE_SEND_WORKAROUNDS */
  632. /* Detect Windows App environment which has a restricted access
  633. * to the Win32 APIs. */
  634. # if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \
  635. defined(WINAPI_FAMILY)
  636. # include <winapifamily.h>
  637. # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
  638. !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  639. # define CURL_WINDOWS_APP
  640. # endif
  641. # endif
  642. #endif /* HEADER_CURL_SETUP_H */