curl_setup.h 20 KB

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