curl_setup.h 23 KB

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