curl_setup.h 22 KB

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