curl_setup.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802
  1. #ifndef HEADER_CURL_SETUP_H
  2. #define HEADER_CURL_SETUP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 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.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. * SPDX-License-Identifier: curl
  24. *
  25. ***************************************************************************/
  26. #if defined(BUILDING_LIBCURL) && !defined(CURL_NO_OLDIES)
  27. #define CURL_NO_OLDIES
  28. #endif
  29. /* Set default _WIN32_WINNT */
  30. #ifdef __MINGW32__
  31. #include <_mingw.h>
  32. #endif
  33. /*
  34. * Disable Visual Studio warnings:
  35. * 4127 "conditional expression is constant"
  36. */
  37. #ifdef _MSC_VER
  38. #pragma warning(disable:4127)
  39. #endif
  40. #ifdef _WIN32
  41. /*
  42. * Don't include unneeded stuff in Windows headers to avoid compiler
  43. * warnings and macro clashes.
  44. * Make sure to define this macro before including any Windows headers.
  45. */
  46. # ifndef WIN32_LEAN_AND_MEAN
  47. # define WIN32_LEAN_AND_MEAN
  48. # endif
  49. # ifndef NOGDI
  50. # define NOGDI
  51. # endif
  52. /* Detect Windows App environment which has a restricted access
  53. * to the Win32 APIs. */
  54. # if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \
  55. defined(WINAPI_FAMILY)
  56. # include <winapifamily.h>
  57. # if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
  58. !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
  59. # define CURL_WINDOWS_APP
  60. # endif
  61. # endif
  62. #endif
  63. /*
  64. * Include configuration script results or hand-crafted
  65. * configuration file for platforms which lack config tool.
  66. */
  67. #ifdef HAVE_CONFIG_H
  68. #include "curl_config.h"
  69. #else /* HAVE_CONFIG_H */
  70. #ifdef _WIN32_WCE
  71. # error #include "config-win32ce.h"
  72. #else
  73. # ifdef _WIN32
  74. # error #include "config-win32.h"
  75. # endif
  76. #endif
  77. #ifdef macintosh
  78. # error #include "config-mac.h"
  79. #endif
  80. #ifdef __riscos__
  81. # error #include "config-riscos.h"
  82. #endif
  83. #ifdef __AMIGA__
  84. # error #include "config-amigaos.h"
  85. #endif
  86. #ifdef __OS400__
  87. # error #include "config-os400.h"
  88. #endif
  89. #ifdef __PLAN9__
  90. # error #include "config-plan9.h"
  91. #endif
  92. #ifdef MSDOS
  93. # error #include "config-dos.h"
  94. #endif
  95. #endif /* HAVE_CONFIG_H */
  96. /* ================================================================ */
  97. /* Definition of preprocessor macros/symbols which modify compiler */
  98. /* behavior or generated code characteristics must be done here, */
  99. /* as appropriate, before any system header file is included. It is */
  100. /* also possible to have them defined in the config file included */
  101. /* before this point. As a result of all this we frown inclusion of */
  102. /* system header files in our config files, avoid this at any cost. */
  103. /* ================================================================ */
  104. /*
  105. * AIX 4.3 and newer needs _THREAD_SAFE defined to build
  106. * proper reentrant code. Others may also need it.
  107. */
  108. #ifdef NEED_THREAD_SAFE
  109. # ifndef _THREAD_SAFE
  110. # define _THREAD_SAFE
  111. # endif
  112. #endif
  113. /*
  114. * Tru64 needs _REENTRANT set for a few function prototypes and
  115. * things to appear in the system header files. Unixware needs it
  116. * to build proper reentrant code. Others may also need it.
  117. */
  118. #ifdef NEED_REENTRANT
  119. # ifndef _REENTRANT
  120. # define _REENTRANT
  121. # endif
  122. #endif
  123. /* Solaris needs this to get a POSIX-conformant getpwuid_r */
  124. #if defined(sun) || defined(__sun)
  125. # ifndef _POSIX_PTHREAD_SEMANTICS
  126. # define _POSIX_PTHREAD_SEMANTICS 1
  127. # endif
  128. #endif
  129. /* ================================================================ */
  130. /* If you need to include a system header file for your platform, */
  131. /* please, do it beyond the point further indicated in this file. */
  132. /* ================================================================ */
  133. /*
  134. * Disable other protocols when http is the only one desired.
  135. */
  136. #ifdef HTTP_ONLY
  137. # ifndef CURL_DISABLE_DICT
  138. # define CURL_DISABLE_DICT
  139. # endif
  140. # ifndef CURL_DISABLE_FILE
  141. # define CURL_DISABLE_FILE
  142. # endif
  143. # ifndef CURL_DISABLE_FTP
  144. # define CURL_DISABLE_FTP
  145. # endif
  146. # ifndef CURL_DISABLE_GOPHER
  147. # define CURL_DISABLE_GOPHER
  148. # endif
  149. # ifndef CURL_DISABLE_IMAP
  150. # define CURL_DISABLE_IMAP
  151. # endif
  152. # ifndef CURL_DISABLE_LDAP
  153. # define CURL_DISABLE_LDAP
  154. # endif
  155. # ifndef CURL_DISABLE_LDAPS
  156. # define CURL_DISABLE_LDAPS
  157. # endif
  158. # ifndef CURL_DISABLE_MQTT
  159. # define CURL_DISABLE_MQTT
  160. # endif
  161. # ifndef CURL_DISABLE_POP3
  162. # define CURL_DISABLE_POP3
  163. # endif
  164. # ifndef CURL_DISABLE_RTSP
  165. # define CURL_DISABLE_RTSP
  166. # endif
  167. # ifndef CURL_DISABLE_SMB
  168. # define CURL_DISABLE_SMB
  169. # endif
  170. # ifndef CURL_DISABLE_SMTP
  171. # define CURL_DISABLE_SMTP
  172. # endif
  173. # ifndef CURL_DISABLE_TELNET
  174. # define CURL_DISABLE_TELNET
  175. # endif
  176. # ifndef CURL_DISABLE_TFTP
  177. # define CURL_DISABLE_TFTP
  178. # endif
  179. #endif
  180. /*
  181. * When http is disabled rtsp is not supported.
  182. */
  183. #if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP)
  184. # define CURL_DISABLE_RTSP
  185. #endif
  186. /*
  187. * When HTTP is disabled, disable HTTP-only features
  188. */
  189. #if defined(CURL_DISABLE_HTTP)
  190. # define CURL_DISABLE_ALTSVC 1
  191. # define CURL_DISABLE_COOKIES 1
  192. # define CURL_DISABLE_BASIC_AUTH 1
  193. # define CURL_DISABLE_BEARER_AUTH 1
  194. # define CURL_DISABLE_AWS 1
  195. # define CURL_DISABLE_DOH 1
  196. # define CURL_DISABLE_FORM_API 1
  197. # define CURL_DISABLE_HEADERS_API 1
  198. # define CURL_DISABLE_HSTS 1
  199. # define CURL_DISABLE_HTTP_AUTH 1
  200. #endif
  201. /* ================================================================ */
  202. /* No system header file shall be included in this file before this */
  203. /* point. */
  204. /* ================================================================ */
  205. /*
  206. * OS/400 setup file includes some system headers.
  207. */
  208. #ifdef __OS400__
  209. # error #include "setup-os400.h"
  210. #endif
  211. /*
  212. * VMS setup file includes some system headers.
  213. */
  214. #ifdef __VMS
  215. # error #include "setup-vms.h"
  216. #endif
  217. /*
  218. * Windows setup file includes some system headers.
  219. */
  220. #ifdef HAVE_WINDOWS_H
  221. # include "setup-win32.h"
  222. #endif
  223. #include <curl/system.h>
  224. /*
  225. * Use getaddrinfo to resolve the IPv4 address literal. If the current network
  226. * interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64,
  227. * performing this task will result in a synthesized IPv6 address.
  228. */
  229. #if defined(__APPLE__) && !defined(USE_ARES)
  230. #include <TargetConditionals.h>
  231. #define USE_RESOLVE_ON_IPS 1
  232. # if TARGET_OS_MAC && !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && \
  233. defined(ENABLE_IPV6)
  234. # define CURL_MACOS_CALL_COPYPROXIES 1
  235. # endif
  236. #endif
  237. #ifdef USE_LWIPSOCK
  238. # error #include <lwip/init.h>
  239. # error #include <lwip/sockets.h>
  240. # error #include <lwip/netdb.h>
  241. #endif
  242. #ifdef HAVE_EXTRA_STRICMP_H
  243. # error #include <extra/stricmp.h>
  244. #endif
  245. #ifdef HAVE_EXTRA_STRDUP_H
  246. # error #include <extra/strdup.h>
  247. #endif
  248. #ifdef __AMIGA__
  249. # ifdef __amigaos4__
  250. # define __USE_INLINE__
  251. /* use our own resolver which uses runtime feature detection */
  252. # define CURLRES_AMIGA
  253. /* getaddrinfo() currently crashes bsdsocket.library, so disable */
  254. # undef HAVE_GETADDRINFO
  255. # if !(defined(__NEWLIB__) || \
  256. (defined(__CLIB2__) && defined(__THREAD_SAFE)))
  257. /* disable threaded resolver with clib2 - requires newlib or clib-ts */
  258. # undef USE_THREADS_POSIX
  259. # endif
  260. # endif
  261. # error #include <exec/types.h>
  262. # error #include <exec/execbase.h>
  263. # error #include <proto/exec.h>
  264. # error #include <proto/dos.h>
  265. # include <unistd.h>
  266. # if defined(HAVE_PROTO_BSDSOCKET_H) && \
  267. (!defined(__amigaos4__) || defined(USE_AMISSL))
  268. /* use bsdsocket.library directly, instead of libc networking functions */
  269. # define _SYS_MBUF_H /* m_len define clashes with curl */
  270. # error #include <proto/bsdsocket.h>
  271. # ifdef __amigaos4__
  272. int Curl_amiga_select(int nfds, fd_set *readfds, fd_set *writefds,
  273. fd_set *errorfds, struct timeval *timeout);
  274. # define select(a,b,c,d,e) Curl_amiga_select(a,b,c,d,e)
  275. # else
  276. # define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
  277. # endif
  278. /* must not use libc's fcntl() on bsdsocket.library sockfds! */
  279. # undef HAVE_FCNTL
  280. # undef HAVE_FCNTL_O_NONBLOCK
  281. # else
  282. /* use libc networking and hence close() and fnctl() */
  283. # undef HAVE_CLOSESOCKET_CAMEL
  284. # undef HAVE_IOCTLSOCKET_CAMEL
  285. # endif
  286. /*
  287. * In clib2 arpa/inet.h warns that some prototypes may clash
  288. * with bsdsocket.library. This avoids the definition of those.
  289. */
  290. # define __NO_NET_API
  291. #endif
  292. #include <stdio.h>
  293. #include <assert.h>
  294. #ifdef __TANDEM /* for ns*-tandem-nsk systems */
  295. # if ! defined __LP64
  296. # error #include <floss.h> /* FLOSS is only used for 32-bit builds. */
  297. # endif
  298. #endif
  299. #ifndef STDC_HEADERS /* no standard C headers! */
  300. #include <curl/stdcheaders.h>
  301. #endif
  302. /*
  303. * Large file (>2Gb) support using WIN32 functions.
  304. */
  305. #ifdef USE_WIN32_LARGE_FILES
  306. # include <io.h>
  307. # include <sys/types.h>
  308. # include <sys/stat.h>
  309. # undef lseek
  310. # define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence)
  311. # undef fstat
  312. # define fstat(fdes,stp) _fstati64(fdes, stp)
  313. # undef stat
  314. # define stat(fname,stp) curlx_win32_stat(fname, stp)
  315. # define struct_stat struct _stati64
  316. # define LSEEK_ERROR (__int64)-1
  317. # define open curlx_win32_open
  318. # define fopen(fname,mode) curlx_win32_fopen(fname, mode)
  319. # define access(fname,mode) curlx_win32_access(fname, mode)
  320. int curlx_win32_open(const char *filename, int oflag, ...);
  321. int curlx_win32_stat(const char *path, struct_stat *buffer);
  322. FILE *curlx_win32_fopen(const char *filename, const char *mode);
  323. int curlx_win32_access(const char *path, int mode);
  324. #endif
  325. /*
  326. * Small file (<2Gb) support using WIN32 functions.
  327. */
  328. #ifdef USE_WIN32_SMALL_FILES
  329. # include <io.h>
  330. # include <sys/types.h>
  331. # include <sys/stat.h>
  332. # ifndef _WIN32_WCE
  333. # undef lseek
  334. # define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence)
  335. # define fstat(fdes,stp) _fstat(fdes, stp)
  336. # define stat(fname,stp) curlx_win32_stat(fname, stp)
  337. # define struct_stat struct _stat
  338. # define open curlx_win32_open
  339. # define fopen(fname,mode) curlx_win32_fopen(fname, mode)
  340. # define access(fname,mode) curlx_win32_access(fname, mode)
  341. int curlx_win32_stat(const char *path, struct_stat *buffer);
  342. int curlx_win32_open(const char *filename, int oflag, ...);
  343. FILE *curlx_win32_fopen(const char *filename, const char *mode);
  344. int curlx_win32_access(const char *path, int mode);
  345. # endif
  346. # define LSEEK_ERROR (long)-1
  347. #endif
  348. #ifndef struct_stat
  349. # define struct_stat struct stat
  350. #endif
  351. #ifndef LSEEK_ERROR
  352. # define LSEEK_ERROR (off_t)-1
  353. #endif
  354. #ifndef SIZEOF_TIME_T
  355. /* assume default size of time_t to be 32 bit */
  356. #define SIZEOF_TIME_T 4
  357. #endif
  358. /*
  359. * Default sizeof(off_t) in case it hasn't been defined in config file.
  360. */
  361. #ifndef SIZEOF_OFF_T
  362. # if defined(__VMS) && !defined(__VAX)
  363. # if defined(_LARGEFILE)
  364. # define SIZEOF_OFF_T 8
  365. # endif
  366. # elif defined(__OS400__) && defined(__ILEC400__)
  367. # if defined(_LARGE_FILES)
  368. # define SIZEOF_OFF_T 8
  369. # endif
  370. # elif defined(__MVS__) && defined(__IBMC__)
  371. # if defined(_LP64) || defined(_LARGE_FILES)
  372. # define SIZEOF_OFF_T 8
  373. # endif
  374. # elif defined(__370__) && defined(__IBMC__)
  375. # if defined(_LP64) || defined(_LARGE_FILES)
  376. # define SIZEOF_OFF_T 8
  377. # endif
  378. # endif
  379. # ifndef SIZEOF_OFF_T
  380. # define SIZEOF_OFF_T 4
  381. # endif
  382. #endif
  383. #if (SIZEOF_CURL_OFF_T < 8)
  384. #error "too small curl_off_t"
  385. #else
  386. /* assume SIZEOF_CURL_OFF_T == 8 */
  387. # define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
  388. #endif
  389. #define CURL_OFF_T_MIN (-CURL_OFF_T_MAX - CURL_OFF_T_C(1))
  390. #if (SIZEOF_TIME_T == 4)
  391. # ifdef HAVE_TIME_T_UNSIGNED
  392. # define TIME_T_MAX UINT_MAX
  393. # define TIME_T_MIN 0
  394. # else
  395. # define TIME_T_MAX INT_MAX
  396. # define TIME_T_MIN INT_MIN
  397. # endif
  398. #else
  399. # ifdef HAVE_TIME_T_UNSIGNED
  400. # define TIME_T_MAX 0xFFFFFFFFFFFFFFFF
  401. # define TIME_T_MIN 0
  402. # else
  403. # define TIME_T_MAX 0x7FFFFFFFFFFFFFFF
  404. # define TIME_T_MIN (-TIME_T_MAX - 1)
  405. # endif
  406. #endif
  407. #ifndef SIZE_T_MAX
  408. /* some limits.h headers have this defined, some don't */
  409. #if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
  410. #define SIZE_T_MAX 18446744073709551615U
  411. #else
  412. #define SIZE_T_MAX 4294967295U
  413. #endif
  414. #endif
  415. #ifndef SSIZE_T_MAX
  416. /* some limits.h headers have this defined, some don't */
  417. #if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
  418. #define SSIZE_T_MAX 9223372036854775807
  419. #else
  420. #define SSIZE_T_MAX 2147483647
  421. #endif
  422. #endif
  423. /*
  424. * Arg 2 type for gethostname in case it hasn't been defined in config file.
  425. */
  426. #ifndef GETHOSTNAME_TYPE_ARG2
  427. # ifdef USE_WINSOCK
  428. # define GETHOSTNAME_TYPE_ARG2 int
  429. # else
  430. # define GETHOSTNAME_TYPE_ARG2 size_t
  431. # endif
  432. #endif
  433. /* Below we define some functions. They should
  434. 4. set the SIGALRM signal timeout
  435. 5. set dir/file naming defines
  436. */
  437. #ifdef _WIN32
  438. # define DIR_CHAR "\\"
  439. #else /* _WIN32 */
  440. # ifdef MSDOS /* Watt-32 */
  441. # include <sys/ioctl.h>
  442. # define select(n,r,w,x,t) select_s(n,r,w,x,t)
  443. # define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
  444. # include <tcp.h>
  445. # ifdef word
  446. # undef word
  447. # endif
  448. # ifdef byte
  449. # undef byte
  450. # endif
  451. # endif /* MSDOS */
  452. # ifdef __minix
  453. /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
  454. extern char *strtok_r(char *s, const char *delim, char **last);
  455. extern struct tm *gmtime_r(const time_t * const timep, struct tm *tmp);
  456. # endif
  457. # define DIR_CHAR "/"
  458. #endif /* _WIN32 */
  459. /* ---------------------------------------------------------------- */
  460. /* resolver specialty compile-time defines */
  461. /* CURLRES_* defines to use in the host*.c sources */
  462. /* ---------------------------------------------------------------- */
  463. /*
  464. * MSVC threads support requires a multi-threaded runtime library.
  465. * _beginthreadex() is not available in single-threaded ones.
  466. */
  467. #if defined(_MSC_VER) && !defined(_MT)
  468. # undef USE_THREADS_POSIX
  469. # undef USE_THREADS_WIN32
  470. #endif
  471. /*
  472. * Mutually exclusive CURLRES_* definitions.
  473. */
  474. #if defined(ENABLE_IPV6) && defined(HAVE_GETADDRINFO)
  475. # define CURLRES_IPV6
  476. #elif defined(ENABLE_IPV6) && (defined(_WIN32) || defined(__CYGWIN__))
  477. /* assume on Windows that IPv6 without getaddrinfo is a broken build */
  478. # error "Unexpected build: IPv6 is enabled but getaddrinfo was not found."
  479. #else
  480. # define CURLRES_IPV4
  481. #endif
  482. #ifdef USE_ARES
  483. # define CURLRES_ASYNCH
  484. # define CURLRES_ARES
  485. /* now undef the stock libc functions just to avoid them being used */
  486. # undef HAVE_GETADDRINFO
  487. # undef HAVE_FREEADDRINFO
  488. #elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
  489. # define CURLRES_ASYNCH
  490. # define CURLRES_THREADED
  491. #else
  492. # define CURLRES_SYNCH
  493. #endif
  494. /* ---------------------------------------------------------------- */
  495. #if defined(HAVE_LIBIDN2) && defined(HAVE_IDN2_H) && !defined(USE_WIN32_IDN)
  496. /* The lib and header are present */
  497. #define USE_LIBIDN2
  498. #endif
  499. #if defined(USE_LIBIDN2) && defined(USE_WIN32_IDN)
  500. #error "Both libidn2 and WinIDN are enabled, choose one."
  501. #endif
  502. #define LIBIDN_REQUIRED_VERSION "0.4.1"
  503. #if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_MBEDTLS) || \
  504. defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || defined(USE_SECTRANSP) || \
  505. defined(USE_BEARSSL) || defined(USE_RUSTLS)
  506. #define USE_SSL /* SSL support has been enabled */
  507. #endif
  508. /* Single point where USE_SPNEGO definition might be defined */
  509. #if !defined(CURL_DISABLE_NEGOTIATE_AUTH) && \
  510. (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI))
  511. #define USE_SPNEGO
  512. #endif
  513. /* Single point where USE_KERBEROS5 definition might be defined */
  514. #if !defined(CURL_DISABLE_KERBEROS_AUTH) && \
  515. (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI))
  516. #define USE_KERBEROS5
  517. #endif
  518. /* Single point where USE_NTLM definition might be defined */
  519. #if !defined(CURL_DISABLE_NTLM)
  520. # if defined(USE_OPENSSL) || defined(USE_MBEDTLS) || \
  521. defined(USE_GNUTLS) || defined(USE_SECTRANSP) || \
  522. defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \
  523. (defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT))
  524. # define USE_CURL_NTLM_CORE
  525. # endif
  526. # if defined(USE_CURL_NTLM_CORE) || defined(USE_WINDOWS_SSPI)
  527. # define USE_NTLM
  528. # endif
  529. #endif
  530. #ifdef CURL_WANTS_CA_BUNDLE_ENV
  531. #error "No longer supported. Set CURLOPT_CAINFO at runtime instead."
  532. #endif
  533. #if defined(USE_LIBSSH2) || defined(USE_LIBSSH) || defined(USE_WOLFSSH)
  534. #define USE_SSH
  535. #endif
  536. /*
  537. * Provide a mechanism to silence picky compilers, such as gcc 4.6+.
  538. * Parameters should of course normally not be unused, but for example when
  539. * we have multiple implementations of the same interface it may happen.
  540. */
  541. #if defined(__GNUC__) && ((__GNUC__ >= 3) || \
  542. ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7)))
  543. # define UNUSED_PARAM __attribute__((__unused__))
  544. # define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  545. #else
  546. # define UNUSED_PARAM /* NOTHING */
  547. # define WARN_UNUSED_RESULT
  548. #endif
  549. /* noreturn attribute */
  550. #if !defined(CURL_NORETURN)
  551. #if (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__clang__)
  552. # define CURL_NORETURN __attribute__((__noreturn__))
  553. #elif defined(_MSC_VER) && (_MSC_VER >= 1200)
  554. # define CURL_NORETURN __declspec(noreturn)
  555. #else
  556. # define CURL_NORETURN
  557. #endif
  558. #endif
  559. /*
  560. * Include macros and defines that should only be processed once.
  561. */
  562. #ifndef HEADER_CURL_SETUP_ONCE_H
  563. #include "curl_setup_once.h"
  564. #endif
  565. /*
  566. * Definition of our NOP statement Object-like macro
  567. */
  568. #ifndef Curl_nop_stmt
  569. # define Curl_nop_stmt do { } while(0)
  570. #endif
  571. /*
  572. * Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
  573. */
  574. #if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H)
  575. # if defined(SOCKET) || \
  576. defined(USE_WINSOCK) || \
  577. defined(HAVE_WINSOCK2_H) || \
  578. defined(HAVE_WS2TCPIP_H)
  579. # error "WinSock and lwIP TCP/IP stack definitions shall not coexist!"
  580. # endif
  581. #endif
  582. /*
  583. * shutdown() flags for systems that don't define them
  584. */
  585. #ifndef SHUT_RD
  586. #define SHUT_RD 0x00
  587. #endif
  588. #ifndef SHUT_WR
  589. #define SHUT_WR 0x01
  590. #endif
  591. #ifndef SHUT_RDWR
  592. #define SHUT_RDWR 0x02
  593. #endif
  594. /* Define S_ISREG if not defined by system headers, e.g. MSVC */
  595. #if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
  596. #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  597. #endif
  598. /* Define S_ISDIR if not defined by system headers, e.g. MSVC */
  599. #if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
  600. #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  601. #endif
  602. /* In Windows the default file mode is text but an application can override it.
  603. Therefore we specify it explicitly. https://github.com/curl/curl/pull/258
  604. */
  605. #if defined(_WIN32) || defined(MSDOS)
  606. #define FOPEN_READTEXT "rt"
  607. #define FOPEN_WRITETEXT "wt"
  608. #define FOPEN_APPENDTEXT "at"
  609. #elif defined(__CYGWIN__)
  610. /* Cygwin has specific behavior we need to address when WIN32 is not defined.
  611. https://cygwin.com/cygwin-ug-net/using-textbinary.html
  612. For write we want our output to have line endings of LF and be compatible with
  613. other Cygwin utilities. For read we want to handle input that may have line
  614. endings either CRLF or LF so 't' is appropriate.
  615. */
  616. #define FOPEN_READTEXT "rt"
  617. #define FOPEN_WRITETEXT "w"
  618. #define FOPEN_APPENDTEXT "a"
  619. #else
  620. #define FOPEN_READTEXT "r"
  621. #define FOPEN_WRITETEXT "w"
  622. #define FOPEN_APPENDTEXT "a"
  623. #endif
  624. /* for systems that don't detect this in configure */
  625. #ifndef CURL_SA_FAMILY_T
  626. # if defined(HAVE_SA_FAMILY_T)
  627. # define CURL_SA_FAMILY_T sa_family_t
  628. # elif defined(HAVE_ADDRESS_FAMILY)
  629. # define CURL_SA_FAMILY_T ADDRESS_FAMILY
  630. # else
  631. /* use a sensible default */
  632. # define CURL_SA_FAMILY_T unsigned short
  633. # endif
  634. #endif
  635. /* Some convenience macros to get the larger/smaller value out of two given.
  636. We prefix with CURL to prevent name collisions. */
  637. #define CURLMAX(x,y) ((x)>(y)?(x):(y))
  638. #define CURLMIN(x,y) ((x)<(y)?(x):(y))
  639. /* A convenience macro to provide both the string literal and the length of
  640. the string literal in one go, useful for functions that take "string,len"
  641. as their argument */
  642. #define STRCONST(x) x,sizeof(x)-1
  643. /* Some versions of the Android SDK is missing the declaration */
  644. #if defined(HAVE_GETPWUID_R) && defined(HAVE_DECL_GETPWUID_R_MISSING)
  645. struct passwd;
  646. int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
  647. size_t buflen, struct passwd **result);
  648. #endif
  649. #ifdef DEBUGBUILD
  650. #define UNITTEST
  651. #else
  652. #define UNITTEST static
  653. #endif
  654. /* Hyper supports HTTP2 also, but Curl's integration with Hyper does not */
  655. #if defined(USE_NGHTTP2)
  656. #define USE_HTTP2
  657. #endif
  658. #if (defined(USE_NGTCP2) && defined(USE_NGHTTP3)) || \
  659. defined(USE_QUICHE) || defined(USE_MSH3)
  660. #define ENABLE_QUIC
  661. #define USE_HTTP3
  662. #endif
  663. /* Certain Windows implementations are not aligned with what curl expects,
  664. so always use the local one on this platform. E.g. the mingw-w64
  665. implementation can return wrong results for non-ASCII inputs. */
  666. #if defined(HAVE_BASENAME) && defined(_WIN32)
  667. #undef HAVE_BASENAME
  668. #endif
  669. #if defined(USE_UNIX_SOCKETS) && defined(_WIN32)
  670. # if !defined(UNIX_PATH_MAX)
  671. /* Replicating logic present in afunix.h
  672. (distributed with newer Windows 10 SDK versions only) */
  673. # define UNIX_PATH_MAX 108
  674. /* !checksrc! disable TYPEDEFSTRUCT 1 */
  675. typedef struct sockaddr_un {
  676. ADDRESS_FAMILY sun_family;
  677. char sun_path[UNIX_PATH_MAX];
  678. } SOCKADDR_UN, *PSOCKADDR_UN;
  679. # define WIN32_SOCKADDR_UN
  680. # endif
  681. #endif
  682. /* OpenSSLv3 marks DES, MD5 and ENGINE functions deprecated but we have no
  683. replacements (yet) so tell the compiler to not warn for them. */
  684. #ifdef USE_OPENSSL
  685. #define OPENSSL_SUPPRESS_DEPRECATED
  686. #endif
  687. #endif /* HEADER_CURL_SETUP_H */