curl_setup.h 23 KB

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