curl_setup.h 20 KB

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