curl_setup.h 22 KB

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