curl_setup.h 21 KB

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