curl_setup.h 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833
  1. #ifndef HEADER_CURL_SETUP_H
  2. #define HEADER_CURL_SETUP_H
  3. /***************************************************************************
  4. * _ _ ____ _
  5. * Project ___| | | | _ \| |
  6. * / __| | | | |_) | |
  7. * | (__| |_| | _ <| |___
  8. * \___|\___/|_| \_\_____|
  9. *
  10. * Copyright (C) 1998 - 2022, 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.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. * Disable Visual Studio warnings:
  29. * 4127 "conditional expression is constant"
  30. */
  31. #ifdef _MSC_VER
  32. #pragma warning(disable:4127)
  33. #endif
  34. /*
  35. * Define WIN32 when build target is Win32 API
  36. */
  37. #if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32)
  38. #define WIN32
  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. # include "config-win32ce.h"
  72. #else
  73. # ifdef WIN32
  74. # include "config-win32.h"
  75. # endif
  76. #endif
  77. #if defined(macintosh) && defined(__MRC__)
  78. # include "config-mac.h"
  79. #endif
  80. #ifdef __riscos__
  81. # include "config-riscos.h"
  82. #endif
  83. #ifdef __AMIGA__
  84. # include "config-amigaos.h"
  85. #endif
  86. #ifdef __OS400__
  87. # include "config-os400.h"
  88. #endif
  89. #ifdef __PLAN9__
  90. # include "config-plan9.h"
  91. #endif
  92. #endif /* HAVE_CONFIG_H */
  93. #if defined(_MSC_VER)
  94. # pragma warning(push,1)
  95. #endif
  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. #include <curl/curl.h>
  134. /*
  135. * Disable other protocols when http is the only one desired.
  136. */
  137. #ifdef HTTP_ONLY
  138. # ifndef CURL_DISABLE_DICT
  139. # define CURL_DISABLE_DICT
  140. # endif
  141. # ifndef CURL_DISABLE_FILE
  142. # define CURL_DISABLE_FILE
  143. # endif
  144. # ifndef CURL_DISABLE_FTP
  145. # define CURL_DISABLE_FTP
  146. # endif
  147. # ifndef CURL_DISABLE_GOPHER
  148. # define CURL_DISABLE_GOPHER
  149. # endif
  150. # ifndef CURL_DISABLE_IMAP
  151. # define CURL_DISABLE_IMAP
  152. # endif
  153. # ifndef CURL_DISABLE_LDAP
  154. # define CURL_DISABLE_LDAP
  155. # endif
  156. # ifndef CURL_DISABLE_LDAPS
  157. # define CURL_DISABLE_LDAPS
  158. # endif
  159. # ifndef CURL_DISABLE_MQTT
  160. # define CURL_DISABLE_MQTT
  161. # endif
  162. # ifndef CURL_DISABLE_POP3
  163. # define CURL_DISABLE_POP3
  164. # endif
  165. # ifndef CURL_DISABLE_RTSP
  166. # define CURL_DISABLE_RTSP
  167. # endif
  168. # ifndef CURL_DISABLE_SMB
  169. # define CURL_DISABLE_SMB
  170. # endif
  171. # ifndef CURL_DISABLE_SMTP
  172. # define CURL_DISABLE_SMTP
  173. # endif
  174. # ifndef CURL_DISABLE_TELNET
  175. # define CURL_DISABLE_TELNET
  176. # endif
  177. # ifndef CURL_DISABLE_TFTP
  178. # define CURL_DISABLE_TFTP
  179. # endif
  180. #endif
  181. /*
  182. * When http is disabled rtsp is not supported.
  183. */
  184. #if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP)
  185. # define CURL_DISABLE_RTSP
  186. #endif
  187. /* ================================================================ */
  188. /* No system header file shall be included in this file before this */
  189. /* point. The only allowed ones are those included from curl/system.h */
  190. /* ================================================================ */
  191. /*
  192. * OS/400 setup file includes some system headers.
  193. */
  194. #ifdef __OS400__
  195. # include "setup-os400.h"
  196. #endif
  197. /*
  198. * VMS setup file includes some system headers.
  199. */
  200. #ifdef __VMS
  201. # include "setup-vms.h"
  202. #endif
  203. /*
  204. * Windows setup file includes some system headers.
  205. */
  206. #ifdef HAVE_WINDOWS_H
  207. # include "setup-win32.h"
  208. #endif
  209. /*
  210. * Use getaddrinfo to resolve the IPv4 address literal. If the current network
  211. * interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64,
  212. * performing this task will result in a synthesized IPv6 address.
  213. */
  214. #if defined(__APPLE__) && !defined(USE_ARES)
  215. #include <TargetConditionals.h>
  216. #define USE_RESOLVE_ON_IPS 1
  217. # if defined(TARGET_OS_OSX) && TARGET_OS_OSX
  218. # define CURL_OSX_CALL_COPYPROXIES 1
  219. # endif
  220. #endif
  221. #ifdef USE_LWIPSOCK
  222. # include <lwip/init.h>
  223. # include <lwip/sockets.h>
  224. # include <lwip/netdb.h>
  225. #endif
  226. #ifdef HAVE_EXTRA_STRICMP_H
  227. # include <extra/stricmp.h>
  228. #endif
  229. #ifdef HAVE_EXTRA_STRDUP_H
  230. # include <extra/strdup.h>
  231. #endif
  232. #ifdef __AMIGA__
  233. # include <exec/types.h>
  234. # include <exec/execbase.h>
  235. # include <proto/exec.h>
  236. # include <proto/dos.h>
  237. # include <unistd.h>
  238. # ifdef HAVE_PROTO_BSDSOCKET_H
  239. # include <proto/bsdsocket.h> /* ensure bsdsocket.library use */
  240. # define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0)
  241. # endif
  242. /*
  243. * In clib2 arpa/inet.h warns that some prototypes may clash
  244. * with bsdsocket.library. This avoids the definition of those.
  245. */
  246. # define __NO_NET_API
  247. #endif
  248. #include <stdio.h>
  249. #ifdef HAVE_ASSERT_H
  250. #include <assert.h>
  251. #endif
  252. #ifdef __TANDEM /* for nsr-tandem-nsk systems */
  253. #include <floss.h>
  254. #endif
  255. #ifndef STDC_HEADERS /* no standard C headers! */
  256. #include <curl/stdcheaders.h>
  257. #endif
  258. #ifdef __POCC__
  259. # include <sys/types.h>
  260. # include <unistd.h>
  261. # define sys_nerr EILSEQ
  262. #endif
  263. /*
  264. * Salford-C kludge section (mostly borrowed from wxWidgets).
  265. */
  266. #ifdef __SALFORDC__
  267. #pragma suppress 353 /* Possible nested comments */
  268. #pragma suppress 593 /* Define not used */
  269. #pragma suppress 61 /* enum has no name */
  270. #pragma suppress 106 /* unnamed, unused parameter */
  271. #include <clib.h>
  272. #endif
  273. /* Default Windows file API selection. */
  274. #ifdef _WIN32
  275. # if defined(_MSC_VER) && (_INTEGRAL_MAX_BITS >= 64)
  276. # define USE_WIN32_LARGE_FILES
  277. # elif defined(__MINGW32__)
  278. # define USE_WIN32_LARGE_FILES
  279. # else
  280. # define USE_WIN32_SMALL_FILES
  281. # endif
  282. #endif
  283. /*
  284. * Large file (>2Gb) support using WIN32 functions.
  285. */
  286. #ifdef USE_WIN32_LARGE_FILES
  287. # include <io.h>
  288. # include <sys/types.h>
  289. # include <sys/stat.h>
  290. # undef lseek
  291. # define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence)
  292. # undef fstat
  293. # define fstat(fdes,stp) _fstati64(fdes, stp)
  294. # undef stat
  295. # define stat(fname,stp) curlx_win32_stat(fname, stp)
  296. # define struct_stat struct _stati64
  297. # define LSEEK_ERROR (__int64)-1
  298. # define open curlx_win32_open
  299. # define fopen(fname,mode) curlx_win32_fopen(fname, mode)
  300. # define access(fname,mode) curlx_win32_access(fname, mode)
  301. int curlx_win32_open(const char *filename, int oflag, ...);
  302. int curlx_win32_stat(const char *path, struct_stat *buffer);
  303. FILE *curlx_win32_fopen(const char *filename, const char *mode);
  304. int curlx_win32_access(const char *path, int mode);
  305. #endif
  306. /*
  307. * Small file (<2Gb) support using WIN32 functions.
  308. */
  309. #ifdef USE_WIN32_SMALL_FILES
  310. # include <io.h>
  311. # include <sys/types.h>
  312. # include <sys/stat.h>
  313. # ifndef _WIN32_WCE
  314. # undef lseek
  315. # define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence)
  316. # define fstat(fdes,stp) _fstat(fdes, stp)
  317. # define stat(fname,stp) curlx_win32_stat(fname, stp)
  318. # define struct_stat struct _stat
  319. # define open curlx_win32_open
  320. # define fopen(fname,mode) curlx_win32_fopen(fname, mode)
  321. # define access(fname,mode) curlx_win32_access(fname, mode)
  322. int curlx_win32_stat(const char *path, struct_stat *buffer);
  323. int curlx_win32_open(const char *filename, int oflag, ...);
  324. FILE *curlx_win32_fopen(const char *filename, const char *mode);
  325. int curlx_win32_access(const char *path, int mode);
  326. # endif
  327. # define LSEEK_ERROR (long)-1
  328. #endif
  329. #ifndef struct_stat
  330. # define struct_stat struct stat
  331. #endif
  332. #ifndef LSEEK_ERROR
  333. # define LSEEK_ERROR (off_t)-1
  334. #endif
  335. #ifndef SIZEOF_TIME_T
  336. /* assume default size of time_t to be 32 bit */
  337. #define SIZEOF_TIME_T 4
  338. #endif
  339. /*
  340. * Default sizeof(off_t) in case it hasn't been defined in config file.
  341. */
  342. #ifndef SIZEOF_OFF_T
  343. # if defined(__VMS) && !defined(__VAX)
  344. # if defined(_LARGEFILE)
  345. # define SIZEOF_OFF_T 8
  346. # endif
  347. # elif defined(__OS400__) && defined(__ILEC400__)
  348. # if defined(_LARGE_FILES)
  349. # define SIZEOF_OFF_T 8
  350. # endif
  351. # elif defined(__MVS__) && defined(__IBMC__)
  352. # if defined(_LP64) || defined(_LARGE_FILES)
  353. # define SIZEOF_OFF_T 8
  354. # endif
  355. # elif defined(__370__) && defined(__IBMC__)
  356. # if defined(_LP64) || defined(_LARGE_FILES)
  357. # define SIZEOF_OFF_T 8
  358. # endif
  359. # endif
  360. # ifndef SIZEOF_OFF_T
  361. # define SIZEOF_OFF_T 4
  362. # endif
  363. #endif
  364. #if (SIZEOF_CURL_OFF_T == 4)
  365. # define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFF)
  366. #else
  367. /* assume SIZEOF_CURL_OFF_T == 8 */
  368. # define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF)
  369. #endif
  370. #define CURL_OFF_T_MIN (-CURL_OFF_T_MAX - CURL_OFF_T_C(1))
  371. #if (SIZEOF_TIME_T == 4)
  372. # ifdef HAVE_TIME_T_UNSIGNED
  373. # define TIME_T_MAX UINT_MAX
  374. # define TIME_T_MIN 0
  375. # else
  376. # define TIME_T_MAX INT_MAX
  377. # define TIME_T_MIN INT_MIN
  378. # endif
  379. #else
  380. # ifdef HAVE_TIME_T_UNSIGNED
  381. # define TIME_T_MAX 0xFFFFFFFFFFFFFFFF
  382. # define TIME_T_MIN 0
  383. # else
  384. # define TIME_T_MAX 0x7FFFFFFFFFFFFFFF
  385. # define TIME_T_MIN (-TIME_T_MAX - 1)
  386. # endif
  387. #endif
  388. #ifndef SIZE_T_MAX
  389. /* some limits.h headers have this defined, some don't */
  390. #if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
  391. #define SIZE_T_MAX 18446744073709551615U
  392. #else
  393. #define SIZE_T_MAX 4294967295U
  394. #endif
  395. #endif
  396. #ifndef SSIZE_T_MAX
  397. /* some limits.h headers have this defined, some don't */
  398. #if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
  399. #define SSIZE_T_MAX 9223372036854775807
  400. #else
  401. #define SSIZE_T_MAX 2147483647
  402. #endif
  403. #endif
  404. /*
  405. * Arg 2 type for gethostname in case it hasn't been defined in config file.
  406. */
  407. #ifndef GETHOSTNAME_TYPE_ARG2
  408. # ifdef USE_WINSOCK
  409. # define GETHOSTNAME_TYPE_ARG2 int
  410. # else
  411. # define GETHOSTNAME_TYPE_ARG2 size_t
  412. # endif
  413. #endif
  414. /* Below we define some functions. They should
  415. 4. set the SIGALRM signal timeout
  416. 5. set dir/file naming defines
  417. */
  418. #ifdef WIN32
  419. # define DIR_CHAR "\\"
  420. #else /* WIN32 */
  421. # ifdef MSDOS /* Watt-32 */
  422. # include <sys/ioctl.h>
  423. # define select(n,r,w,x,t) select_s(n,r,w,x,t)
  424. # define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z))
  425. # include <tcp.h>
  426. # ifdef word
  427. # undef word
  428. # endif
  429. # ifdef byte
  430. # undef byte
  431. # endif
  432. # endif /* MSDOS */
  433. # ifdef __minix
  434. /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
  435. extern char *strtok_r(char *s, const char *delim, char **last);
  436. extern struct tm *gmtime_r(const time_t * const timep, struct tm *tmp);
  437. # endif
  438. # define DIR_CHAR "/"
  439. # ifndef fileno /* sunos 4 have this as a macro! */
  440. int fileno(FILE *stream);
  441. # endif
  442. #endif /* WIN32 */
  443. /*
  444. * msvc 6.0 requires PSDK in order to have INET6_ADDRSTRLEN
  445. * defined in ws2tcpip.h as well as to provide IPv6 support.
  446. * Does not apply if lwIP is used.
  447. */
  448. #if defined(_MSC_VER) && !defined(__POCC__) && !defined(USE_LWIPSOCK)
  449. # if !defined(HAVE_WS2TCPIP_H) || \
  450. ((_MSC_VER < 1300) && !defined(INET6_ADDRSTRLEN))
  451. # undef HAVE_GETADDRINFO_THREADSAFE
  452. # undef HAVE_FREEADDRINFO
  453. # undef HAVE_GETADDRINFO
  454. # undef ENABLE_IPV6
  455. # endif
  456. #endif
  457. /* ---------------------------------------------------------------- */
  458. /* resolver specialty compile-time defines */
  459. /* CURLRES_* defines to use in the host*.c sources */
  460. /* ---------------------------------------------------------------- */
  461. /*
  462. * lcc-win32 doesn't have _beginthreadex(), lacks threads support.
  463. */
  464. #if defined(__LCC__) && defined(WIN32)
  465. # undef USE_THREADS_POSIX
  466. # undef USE_THREADS_WIN32
  467. #endif
  468. /*
  469. * MSVC threads support requires a multi-threaded runtime library.
  470. * _beginthreadex() is not available in single-threaded ones.
  471. */
  472. #if defined(_MSC_VER) && !defined(__POCC__) && !defined(_MT)
  473. # undef USE_THREADS_POSIX
  474. # undef USE_THREADS_WIN32
  475. #endif
  476. /*
  477. * Mutually exclusive CURLRES_* definitions.
  478. */
  479. #if defined(ENABLE_IPV6) && defined(HAVE_GETADDRINFO)
  480. # define CURLRES_IPV6
  481. #else
  482. # define CURLRES_IPV4
  483. #endif
  484. #ifdef USE_ARES
  485. # define CURLRES_ASYNCH
  486. # define CURLRES_ARES
  487. /* now undef the stock libc functions just to avoid them being used */
  488. # undef HAVE_GETADDRINFO
  489. # undef HAVE_FREEADDRINFO
  490. # undef HAVE_GETHOSTBYNAME
  491. #elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
  492. # define CURLRES_ASYNCH
  493. # define CURLRES_THREADED
  494. #else
  495. # define CURLRES_SYNCH
  496. #endif
  497. /* ---------------------------------------------------------------- */
  498. /*
  499. * msvc 6.0 does not have struct sockaddr_storage and
  500. * does not define IPPROTO_ESP in winsock2.h. But both
  501. * are available if PSDK is properly installed.
  502. */
  503. #if defined(_MSC_VER) && !defined(__POCC__)
  504. # if !defined(HAVE_WINSOCK2_H) || ((_MSC_VER < 1300) && !defined(IPPROTO_ESP))
  505. # undef HAVE_STRUCT_SOCKADDR_STORAGE
  506. # endif
  507. #endif
  508. /*
  509. * Intentionally fail to build when using msvc 6.0 without PSDK installed.
  510. * The brave of heart can circumvent this, defining ALLOW_MSVC6_WITHOUT_PSDK
  511. * in lib/config-win32.h although absolutely discouraged and unsupported.
  512. */
  513. #if defined(_MSC_VER) && !defined(__POCC__)
  514. # if !defined(HAVE_WINDOWS_H) || ((_MSC_VER < 1300) && !defined(_FILETIME_))
  515. # if !defined(ALLOW_MSVC6_WITHOUT_PSDK)
  516. # error MSVC 6.0 requires "February 2003 Platform SDK" a.k.a. \
  517. "Windows Server 2003 PSDK"
  518. # else
  519. # define CURL_DISABLE_LDAP 1
  520. # endif
  521. # endif
  522. #endif
  523. #if defined(HAVE_LIBIDN2) && defined(HAVE_IDN2_H) && !defined(USE_WIN32_IDN)
  524. /* The lib and header are present */
  525. #define USE_LIBIDN2
  526. #endif
  527. #if defined(USE_LIBIDN2) && defined(USE_WIN32_IDN)
  528. #error "Both libidn2 and WinIDN are enabled, choose one."
  529. #endif
  530. #define LIBIDN_REQUIRED_VERSION "0.4.1"
  531. #if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_NSS) || \
  532. defined(USE_MBEDTLS) || \
  533. defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || \
  534. defined(USE_SECTRANSP) || defined(USE_GSKIT) || \
  535. defined(USE_BEARSSL) || defined(USE_RUSTLS)
  536. #define USE_SSL /* SSL support has been enabled */
  537. #endif
  538. /* Single point where USE_SPNEGO definition might be defined */
  539. #if !defined(CURL_DISABLE_CRYPTO_AUTH) && \
  540. (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI))
  541. #define USE_SPNEGO
  542. #endif
  543. /* Single point where USE_KERBEROS5 definition might be defined */
  544. #if !defined(CURL_DISABLE_CRYPTO_AUTH) && \
  545. (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI))
  546. #define USE_KERBEROS5
  547. #endif
  548. /* Single point where USE_NTLM definition might be defined */
  549. #if !defined(CURL_DISABLE_CRYPTO_AUTH) && !defined(CURL_DISABLE_NTLM)
  550. # if defined(USE_OPENSSL) || defined(USE_MBEDTLS) || \
  551. defined(USE_GNUTLS) || defined(USE_NSS) || defined(USE_SECTRANSP) || \
  552. defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \
  553. (defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT))
  554. # define USE_CURL_NTLM_CORE
  555. # endif
  556. # if defined(USE_CURL_NTLM_CORE) || defined(USE_WINDOWS_SSPI)
  557. # define USE_NTLM
  558. # endif
  559. #endif
  560. #ifdef CURL_WANTS_CA_BUNDLE_ENV
  561. #error "No longer supported. Set CURLOPT_CAINFO at runtime instead."
  562. #endif
  563. #if defined(USE_LIBSSH2) || defined(USE_LIBSSH) || defined(USE_WOLFSSH)
  564. #define USE_SSH
  565. #endif
  566. /*
  567. * Provide a mechanism to silence picky compilers, such as gcc 4.6+.
  568. * Parameters should of course normally not be unused, but for example when
  569. * we have multiple implementations of the same interface it may happen.
  570. */
  571. #if defined(__GNUC__) && ((__GNUC__ >= 3) || \
  572. ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7)))
  573. # define UNUSED_PARAM __attribute__((__unused__))
  574. # define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
  575. #else
  576. # define UNUSED_PARAM /*NOTHING*/
  577. # define WARN_UNUSED_RESULT
  578. #endif
  579. /*
  580. * Include macros and defines that should only be processed once.
  581. */
  582. #ifndef HEADER_CURL_SETUP_ONCE_H
  583. #include "curl_setup_once.h"
  584. #endif
  585. /*
  586. * Definition of our NOP statement Object-like macro
  587. */
  588. #ifndef Curl_nop_stmt
  589. # define Curl_nop_stmt do { } while(0)
  590. #endif
  591. /*
  592. * Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
  593. */
  594. #if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H)
  595. # if defined(SOCKET) || \
  596. defined(USE_WINSOCK) || \
  597. defined(HAVE_WINSOCK2_H) || \
  598. defined(HAVE_WS2TCPIP_H)
  599. # error "WinSock and lwIP TCP/IP stack definitions shall not coexist!"
  600. # endif
  601. #endif
  602. /*
  603. * shutdown() flags for systems that don't define them
  604. */
  605. #ifndef SHUT_RD
  606. #define SHUT_RD 0x00
  607. #endif
  608. #ifndef SHUT_WR
  609. #define SHUT_WR 0x01
  610. #endif
  611. #ifndef SHUT_RDWR
  612. #define SHUT_RDWR 0x02
  613. #endif
  614. /* Define S_ISREG if not defined by system headers, f.e. MSVC */
  615. #if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
  616. #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
  617. #endif
  618. /* Define S_ISDIR if not defined by system headers, f.e. MSVC */
  619. #if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
  620. #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
  621. #endif
  622. /* In Windows the default file mode is text but an application can override it.
  623. Therefore we specify it explicitly. https://github.com/curl/curl/pull/258
  624. */
  625. #if defined(WIN32) || defined(MSDOS)
  626. #define FOPEN_READTEXT "rt"
  627. #define FOPEN_WRITETEXT "wt"
  628. #define FOPEN_APPENDTEXT "at"
  629. #elif defined(__CYGWIN__)
  630. /* Cygwin has specific behavior we need to address when WIN32 is not defined.
  631. https://cygwin.com/cygwin-ug-net/using-textbinary.html
  632. For write we want our output to have line endings of LF and be compatible with
  633. other Cygwin utilities. For read we want to handle input that may have line
  634. endings either CRLF or LF so 't' is appropriate.
  635. */
  636. #define FOPEN_READTEXT "rt"
  637. #define FOPEN_WRITETEXT "w"
  638. #define FOPEN_APPENDTEXT "a"
  639. #else
  640. #define FOPEN_READTEXT "r"
  641. #define FOPEN_WRITETEXT "w"
  642. #define FOPEN_APPENDTEXT "a"
  643. #endif
  644. /* WinSock destroys recv() buffer when send() failed.
  645. * Enabled automatically for Windows and for Cygwin as Cygwin sockets are
  646. * wrappers for WinSock sockets. https://github.com/curl/curl/issues/657
  647. * Define DONT_USE_RECV_BEFORE_SEND_WORKAROUND to force disable workaround.
  648. */
  649. #if !defined(DONT_USE_RECV_BEFORE_SEND_WORKAROUND)
  650. # if defined(WIN32) || defined(__CYGWIN__)
  651. # define USE_RECV_BEFORE_SEND_WORKAROUND
  652. # endif
  653. #else /* DONT_USE_RECV_BEFORE_SEND_WORKAROUND */
  654. # ifdef USE_RECV_BEFORE_SEND_WORKAROUND
  655. # undef USE_RECV_BEFORE_SEND_WORKAROUND
  656. # endif
  657. #endif /* DONT_USE_RECV_BEFORE_SEND_WORKAROUND */
  658. /* for systems that don't detect this in configure */
  659. #ifndef CURL_SA_FAMILY_T
  660. # if defined(HAVE_SA_FAMILY_T)
  661. # define CURL_SA_FAMILY_T sa_family_t
  662. # elif defined(HAVE_ADDRESS_FAMILY)
  663. # define CURL_SA_FAMILY_T ADDRESS_FAMILY
  664. # else
  665. /* use a sensible default */
  666. # define CURL_SA_FAMILY_T unsigned short
  667. # endif
  668. #endif
  669. /* Some convenience macros to get the larger/smaller value out of two given.
  670. We prefix with CURL to prevent name collisions. */
  671. #define CURLMAX(x,y) ((x)>(y)?(x):(y))
  672. #define CURLMIN(x,y) ((x)<(y)?(x):(y))
  673. /* A convenience macro to provide both the string literal and the length of
  674. the string literal in one go, useful for functions that take "string,len"
  675. as their argument */
  676. #define STRCONST(x) x,sizeof(x)-1
  677. /* Some versions of the Android SDK is missing the declaration */
  678. #if defined(HAVE_GETPWUID_R) && defined(HAVE_DECL_GETPWUID_R_MISSING)
  679. struct passwd;
  680. int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
  681. size_t buflen, struct passwd **result);
  682. #endif
  683. #ifdef DEBUGBUILD
  684. #define UNITTEST
  685. #else
  686. #define UNITTEST static
  687. #endif
  688. #if defined(USE_NGHTTP2) || defined(USE_HYPER)
  689. #define USE_HTTP2
  690. #endif
  691. #if defined(USE_NGTCP2) || defined(USE_QUICHE) || defined(USE_MSH3)
  692. #define ENABLE_QUIC
  693. #endif
  694. #if defined(USE_UNIX_SOCKETS) && defined(WIN32)
  695. # if defined(__MINGW32__) && !defined(LUP_SECURE)
  696. typedef u_short ADDRESS_FAMILY; /* Classic mingw, 11y+ old mingw-w64 */
  697. # endif
  698. # if !defined(UNIX_PATH_MAX)
  699. /* Replicating logic present in afunix.h
  700. (distributed with newer Windows 10 SDK versions only) */
  701. # define UNIX_PATH_MAX 108
  702. /* !checksrc! disable TYPEDEFSTRUCT 1 */
  703. typedef struct sockaddr_un {
  704. ADDRESS_FAMILY sun_family;
  705. char sun_path[UNIX_PATH_MAX];
  706. } SOCKADDR_UN, *PSOCKADDR_UN;
  707. # define WIN32_SOCKADDR_UN
  708. # endif
  709. #endif
  710. #endif /* HEADER_CURL_SETUP_H */