2
0

curl_setup.h 23 KB

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