113498266Sopenharmony_ci#ifndef HEADER_CURL_SETUP_H 213498266Sopenharmony_ci#define HEADER_CURL_SETUP_H 313498266Sopenharmony_ci/*************************************************************************** 413498266Sopenharmony_ci * _ _ ____ _ 513498266Sopenharmony_ci * Project ___| | | | _ \| | 613498266Sopenharmony_ci * / __| | | | |_) | | 713498266Sopenharmony_ci * | (__| |_| | _ <| |___ 813498266Sopenharmony_ci * \___|\___/|_| \_\_____| 913498266Sopenharmony_ci * 1013498266Sopenharmony_ci * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al. 1113498266Sopenharmony_ci * 1213498266Sopenharmony_ci * This software is licensed as described in the file COPYING, which 1313498266Sopenharmony_ci * you should have received as part of this distribution. The terms 1413498266Sopenharmony_ci * are also available at https://curl.se/docs/copyright.html. 1513498266Sopenharmony_ci * 1613498266Sopenharmony_ci * You may opt to use, copy, modify, merge, publish, distribute and/or sell 1713498266Sopenharmony_ci * copies of the Software, and permit persons to whom the Software is 1813498266Sopenharmony_ci * furnished to do so, under the terms of the COPYING file. 1913498266Sopenharmony_ci * 2013498266Sopenharmony_ci * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY 2113498266Sopenharmony_ci * KIND, either express or implied. 2213498266Sopenharmony_ci * 2313498266Sopenharmony_ci * SPDX-License-Identifier: curl 2413498266Sopenharmony_ci * 2513498266Sopenharmony_ci ***************************************************************************/ 2613498266Sopenharmony_ci 2713498266Sopenharmony_ci#if defined(BUILDING_LIBCURL) && !defined(CURL_NO_OLDIES) 2813498266Sopenharmony_ci#define CURL_NO_OLDIES 2913498266Sopenharmony_ci#endif 3013498266Sopenharmony_ci 3113498266Sopenharmony_ci/* FIXME: Delete this once the warnings have been fixed. */ 3213498266Sopenharmony_ci#if !defined(CURL_WARN_SIGN_CONVERSION) 3313498266Sopenharmony_ci#ifdef __GNUC__ 3413498266Sopenharmony_ci#pragma GCC diagnostic ignored "-Wsign-conversion" 3513498266Sopenharmony_ci#endif 3613498266Sopenharmony_ci#endif 3713498266Sopenharmony_ci 3813498266Sopenharmony_ci/* Set default _WIN32_WINNT */ 3913498266Sopenharmony_ci#ifdef __MINGW32__ 4013498266Sopenharmony_ci#include <_mingw.h> 4113498266Sopenharmony_ci#endif 4213498266Sopenharmony_ci 4313498266Sopenharmony_ci/* 4413498266Sopenharmony_ci * Disable Visual Studio warnings: 4513498266Sopenharmony_ci * 4127 "conditional expression is constant" 4613498266Sopenharmony_ci */ 4713498266Sopenharmony_ci#ifdef _MSC_VER 4813498266Sopenharmony_ci#pragma warning(disable:4127) 4913498266Sopenharmony_ci#endif 5013498266Sopenharmony_ci 5113498266Sopenharmony_ci#ifdef _WIN32 5213498266Sopenharmony_ci/* 5313498266Sopenharmony_ci * Don't include unneeded stuff in Windows headers to avoid compiler 5413498266Sopenharmony_ci * warnings and macro clashes. 5513498266Sopenharmony_ci * Make sure to define this macro before including any Windows headers. 5613498266Sopenharmony_ci */ 5713498266Sopenharmony_ci# ifndef WIN32_LEAN_AND_MEAN 5813498266Sopenharmony_ci# define WIN32_LEAN_AND_MEAN 5913498266Sopenharmony_ci# endif 6013498266Sopenharmony_ci# ifndef NOGDI 6113498266Sopenharmony_ci# define NOGDI 6213498266Sopenharmony_ci# endif 6313498266Sopenharmony_ci/* Detect Windows App environment which has a restricted access 6413498266Sopenharmony_ci * to the Win32 APIs. */ 6513498266Sopenharmony_ci# if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \ 6613498266Sopenharmony_ci defined(WINAPI_FAMILY) 6713498266Sopenharmony_ci# include <winapifamily.h> 6813498266Sopenharmony_ci# if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \ 6913498266Sopenharmony_ci !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) 7013498266Sopenharmony_ci# define CURL_WINDOWS_APP 7113498266Sopenharmony_ci# endif 7213498266Sopenharmony_ci# endif 7313498266Sopenharmony_ci#endif 7413498266Sopenharmony_ci 7513498266Sopenharmony_ci/* 7613498266Sopenharmony_ci * Include configuration script results or hand-crafted 7713498266Sopenharmony_ci * configuration file for platforms which lack config tool. 7813498266Sopenharmony_ci */ 7913498266Sopenharmony_ci 8013498266Sopenharmony_ci#ifdef HAVE_CONFIG_H 8113498266Sopenharmony_ci 8213498266Sopenharmony_ci#include "curl_config.h" 8313498266Sopenharmony_ci 8413498266Sopenharmony_ci#else /* HAVE_CONFIG_H */ 8513498266Sopenharmony_ci 8613498266Sopenharmony_ci#ifdef _WIN32_WCE 8713498266Sopenharmony_ci# include "config-win32ce.h" 8813498266Sopenharmony_ci#else 8913498266Sopenharmony_ci# ifdef _WIN32 9013498266Sopenharmony_ci# include "config-win32.h" 9113498266Sopenharmony_ci# endif 9213498266Sopenharmony_ci#endif 9313498266Sopenharmony_ci 9413498266Sopenharmony_ci#ifdef macintosh 9513498266Sopenharmony_ci# include "config-mac.h" 9613498266Sopenharmony_ci#endif 9713498266Sopenharmony_ci 9813498266Sopenharmony_ci#ifdef __riscos__ 9913498266Sopenharmony_ci# include "config-riscos.h" 10013498266Sopenharmony_ci#endif 10113498266Sopenharmony_ci 10213498266Sopenharmony_ci#ifdef __AMIGA__ 10313498266Sopenharmony_ci# include "config-amigaos.h" 10413498266Sopenharmony_ci#endif 10513498266Sopenharmony_ci 10613498266Sopenharmony_ci#ifdef __OS400__ 10713498266Sopenharmony_ci# include "config-os400.h" 10813498266Sopenharmony_ci#endif 10913498266Sopenharmony_ci 11013498266Sopenharmony_ci#ifdef __PLAN9__ 11113498266Sopenharmony_ci# include "config-plan9.h" 11213498266Sopenharmony_ci#endif 11313498266Sopenharmony_ci 11413498266Sopenharmony_ci#ifdef MSDOS 11513498266Sopenharmony_ci# include "config-dos.h" 11613498266Sopenharmony_ci#endif 11713498266Sopenharmony_ci 11813498266Sopenharmony_ci#endif /* HAVE_CONFIG_H */ 11913498266Sopenharmony_ci 12013498266Sopenharmony_ci/* ================================================================ */ 12113498266Sopenharmony_ci/* Definition of preprocessor macros/symbols which modify compiler */ 12213498266Sopenharmony_ci/* behavior or generated code characteristics must be done here, */ 12313498266Sopenharmony_ci/* as appropriate, before any system header file is included. It is */ 12413498266Sopenharmony_ci/* also possible to have them defined in the config file included */ 12513498266Sopenharmony_ci/* before this point. As a result of all this we frown inclusion of */ 12613498266Sopenharmony_ci/* system header files in our config files, avoid this at any cost. */ 12713498266Sopenharmony_ci/* ================================================================ */ 12813498266Sopenharmony_ci 12913498266Sopenharmony_ci/* 13013498266Sopenharmony_ci * AIX 4.3 and newer needs _THREAD_SAFE defined to build 13113498266Sopenharmony_ci * proper reentrant code. Others may also need it. 13213498266Sopenharmony_ci */ 13313498266Sopenharmony_ci 13413498266Sopenharmony_ci#ifdef NEED_THREAD_SAFE 13513498266Sopenharmony_ci# ifndef _THREAD_SAFE 13613498266Sopenharmony_ci# define _THREAD_SAFE 13713498266Sopenharmony_ci# endif 13813498266Sopenharmony_ci#endif 13913498266Sopenharmony_ci 14013498266Sopenharmony_ci/* 14113498266Sopenharmony_ci * Tru64 needs _REENTRANT set for a few function prototypes and 14213498266Sopenharmony_ci * things to appear in the system header files. Unixware needs it 14313498266Sopenharmony_ci * to build proper reentrant code. Others may also need it. 14413498266Sopenharmony_ci */ 14513498266Sopenharmony_ci 14613498266Sopenharmony_ci#ifdef NEED_REENTRANT 14713498266Sopenharmony_ci# ifndef _REENTRANT 14813498266Sopenharmony_ci# define _REENTRANT 14913498266Sopenharmony_ci# endif 15013498266Sopenharmony_ci#endif 15113498266Sopenharmony_ci 15213498266Sopenharmony_ci/* Solaris needs this to get a POSIX-conformant getpwuid_r */ 15313498266Sopenharmony_ci#if defined(sun) || defined(__sun) 15413498266Sopenharmony_ci# ifndef _POSIX_PTHREAD_SEMANTICS 15513498266Sopenharmony_ci# define _POSIX_PTHREAD_SEMANTICS 1 15613498266Sopenharmony_ci# endif 15713498266Sopenharmony_ci#endif 15813498266Sopenharmony_ci 15913498266Sopenharmony_ci/* ================================================================ */ 16013498266Sopenharmony_ci/* If you need to include a system header file for your platform, */ 16113498266Sopenharmony_ci/* please, do it beyond the point further indicated in this file. */ 16213498266Sopenharmony_ci/* ================================================================ */ 16313498266Sopenharmony_ci 16413498266Sopenharmony_ci/* 16513498266Sopenharmony_ci * Disable other protocols when http is the only one desired. 16613498266Sopenharmony_ci */ 16713498266Sopenharmony_ci 16813498266Sopenharmony_ci#ifdef HTTP_ONLY 16913498266Sopenharmony_ci# ifndef CURL_DISABLE_DICT 17013498266Sopenharmony_ci# define CURL_DISABLE_DICT 17113498266Sopenharmony_ci# endif 17213498266Sopenharmony_ci# ifndef CURL_DISABLE_FILE 17313498266Sopenharmony_ci# define CURL_DISABLE_FILE 17413498266Sopenharmony_ci# endif 17513498266Sopenharmony_ci# ifndef CURL_DISABLE_FTP 17613498266Sopenharmony_ci# define CURL_DISABLE_FTP 17713498266Sopenharmony_ci# endif 17813498266Sopenharmony_ci# ifndef CURL_DISABLE_GOPHER 17913498266Sopenharmony_ci# define CURL_DISABLE_GOPHER 18013498266Sopenharmony_ci# endif 18113498266Sopenharmony_ci# ifndef CURL_DISABLE_IMAP 18213498266Sopenharmony_ci# define CURL_DISABLE_IMAP 18313498266Sopenharmony_ci# endif 18413498266Sopenharmony_ci# ifndef CURL_DISABLE_LDAP 18513498266Sopenharmony_ci# define CURL_DISABLE_LDAP 18613498266Sopenharmony_ci# endif 18713498266Sopenharmony_ci# ifndef CURL_DISABLE_LDAPS 18813498266Sopenharmony_ci# define CURL_DISABLE_LDAPS 18913498266Sopenharmony_ci# endif 19013498266Sopenharmony_ci# ifndef CURL_DISABLE_MQTT 19113498266Sopenharmony_ci# define CURL_DISABLE_MQTT 19213498266Sopenharmony_ci# endif 19313498266Sopenharmony_ci# ifndef CURL_DISABLE_POP3 19413498266Sopenharmony_ci# define CURL_DISABLE_POP3 19513498266Sopenharmony_ci# endif 19613498266Sopenharmony_ci# ifndef CURL_DISABLE_RTSP 19713498266Sopenharmony_ci# define CURL_DISABLE_RTSP 19813498266Sopenharmony_ci# endif 19913498266Sopenharmony_ci# ifndef CURL_DISABLE_SMB 20013498266Sopenharmony_ci# define CURL_DISABLE_SMB 20113498266Sopenharmony_ci# endif 20213498266Sopenharmony_ci# ifndef CURL_DISABLE_SMTP 20313498266Sopenharmony_ci# define CURL_DISABLE_SMTP 20413498266Sopenharmony_ci# endif 20513498266Sopenharmony_ci# ifndef CURL_DISABLE_TELNET 20613498266Sopenharmony_ci# define CURL_DISABLE_TELNET 20713498266Sopenharmony_ci# endif 20813498266Sopenharmony_ci# ifndef CURL_DISABLE_TFTP 20913498266Sopenharmony_ci# define CURL_DISABLE_TFTP 21013498266Sopenharmony_ci# endif 21113498266Sopenharmony_ci#endif 21213498266Sopenharmony_ci 21313498266Sopenharmony_ci/* 21413498266Sopenharmony_ci * When http is disabled rtsp is not supported. 21513498266Sopenharmony_ci */ 21613498266Sopenharmony_ci 21713498266Sopenharmony_ci#if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP) 21813498266Sopenharmony_ci# define CURL_DISABLE_RTSP 21913498266Sopenharmony_ci#endif 22013498266Sopenharmony_ci 22113498266Sopenharmony_ci/* 22213498266Sopenharmony_ci * When HTTP is disabled, disable HTTP-only features 22313498266Sopenharmony_ci */ 22413498266Sopenharmony_ci 22513498266Sopenharmony_ci#if defined(CURL_DISABLE_HTTP) 22613498266Sopenharmony_ci# define CURL_DISABLE_ALTSVC 1 22713498266Sopenharmony_ci# define CURL_DISABLE_COOKIES 1 22813498266Sopenharmony_ci# define CURL_DISABLE_BASIC_AUTH 1 22913498266Sopenharmony_ci# define CURL_DISABLE_BEARER_AUTH 1 23013498266Sopenharmony_ci# define CURL_DISABLE_AWS 1 23113498266Sopenharmony_ci# define CURL_DISABLE_DOH 1 23213498266Sopenharmony_ci# define CURL_DISABLE_FORM_API 1 23313498266Sopenharmony_ci# define CURL_DISABLE_HEADERS_API 1 23413498266Sopenharmony_ci# define CURL_DISABLE_HSTS 1 23513498266Sopenharmony_ci# define CURL_DISABLE_HTTP_AUTH 1 23613498266Sopenharmony_ci#endif 23713498266Sopenharmony_ci 23813498266Sopenharmony_ci/* ================================================================ */ 23913498266Sopenharmony_ci/* No system header file shall be included in this file before this */ 24013498266Sopenharmony_ci/* point. */ 24113498266Sopenharmony_ci/* ================================================================ */ 24213498266Sopenharmony_ci 24313498266Sopenharmony_ci/* 24413498266Sopenharmony_ci * OS/400 setup file includes some system headers. 24513498266Sopenharmony_ci */ 24613498266Sopenharmony_ci 24713498266Sopenharmony_ci#ifdef __OS400__ 24813498266Sopenharmony_ci# include "setup-os400.h" 24913498266Sopenharmony_ci#endif 25013498266Sopenharmony_ci 25113498266Sopenharmony_ci/* 25213498266Sopenharmony_ci * VMS setup file includes some system headers. 25313498266Sopenharmony_ci */ 25413498266Sopenharmony_ci 25513498266Sopenharmony_ci#ifdef __VMS 25613498266Sopenharmony_ci# include "setup-vms.h" 25713498266Sopenharmony_ci#endif 25813498266Sopenharmony_ci 25913498266Sopenharmony_ci/* 26013498266Sopenharmony_ci * Windows setup file includes some system headers. 26113498266Sopenharmony_ci */ 26213498266Sopenharmony_ci 26313498266Sopenharmony_ci#ifdef _WIN32 26413498266Sopenharmony_ci# include "setup-win32.h" 26513498266Sopenharmony_ci#endif 26613498266Sopenharmony_ci 26713498266Sopenharmony_ci#include <curl/system.h> 26813498266Sopenharmony_ci 26913498266Sopenharmony_ci/* curl uses its own printf() function internally. It understands the GNU 27013498266Sopenharmony_ci * format. Use this format, so that is matches the GNU format attribute we 27113498266Sopenharmony_ci * use with the mingw compiler, allowing it to verify them at compile-time. 27213498266Sopenharmony_ci */ 27313498266Sopenharmony_ci#ifdef __MINGW32__ 27413498266Sopenharmony_ci# undef CURL_FORMAT_CURL_OFF_T 27513498266Sopenharmony_ci# undef CURL_FORMAT_CURL_OFF_TU 27613498266Sopenharmony_ci# define CURL_FORMAT_CURL_OFF_T "lld" 27713498266Sopenharmony_ci# define CURL_FORMAT_CURL_OFF_TU "llu" 27813498266Sopenharmony_ci#endif 27913498266Sopenharmony_ci 28013498266Sopenharmony_ci/* based on logic in "curl/mprintf.h" */ 28113498266Sopenharmony_ci 28213498266Sopenharmony_ci#if (defined(__GNUC__) || defined(__clang__)) && \ 28313498266Sopenharmony_ci defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) && \ 28413498266Sopenharmony_ci !defined(CURL_NO_FMT_CHECKS) 28513498266Sopenharmony_ci#if defined(__MINGW32__) && !defined(__clang__) 28613498266Sopenharmony_ci#define CURL_PRINTF(fmt, arg) \ 28713498266Sopenharmony_ci __attribute__((format(gnu_printf, fmt, arg))) 28813498266Sopenharmony_ci#else 28913498266Sopenharmony_ci#define CURL_PRINTF(fmt, arg) \ 29013498266Sopenharmony_ci __attribute__((format(__printf__, fmt, arg))) 29113498266Sopenharmony_ci#endif 29213498266Sopenharmony_ci#else 29313498266Sopenharmony_ci#define CURL_PRINTF(fmt, arg) 29413498266Sopenharmony_ci#endif 29513498266Sopenharmony_ci 29613498266Sopenharmony_ci/* 29713498266Sopenharmony_ci * Use getaddrinfo to resolve the IPv4 address literal. If the current network 29813498266Sopenharmony_ci * interface doesn't support IPv4, but supports IPv6, NAT64, and DNS64, 29913498266Sopenharmony_ci * performing this task will result in a synthesized IPv6 address. 30013498266Sopenharmony_ci */ 30113498266Sopenharmony_ci#if defined(__APPLE__) && !defined(USE_ARES) 30213498266Sopenharmony_ci#include <TargetConditionals.h> 30313498266Sopenharmony_ci#define USE_RESOLVE_ON_IPS 1 30413498266Sopenharmony_ci# if TARGET_OS_MAC && !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && \ 30513498266Sopenharmony_ci defined(ENABLE_IPV6) 30613498266Sopenharmony_ci# define CURL_MACOS_CALL_COPYPROXIES 1 30713498266Sopenharmony_ci# endif 30813498266Sopenharmony_ci#endif 30913498266Sopenharmony_ci 31013498266Sopenharmony_ci#ifdef USE_LWIPSOCK 31113498266Sopenharmony_ci# include <lwip/init.h> 31213498266Sopenharmony_ci# include <lwip/sockets.h> 31313498266Sopenharmony_ci# include <lwip/netdb.h> 31413498266Sopenharmony_ci#endif 31513498266Sopenharmony_ci 31613498266Sopenharmony_ci#ifdef HAVE_EXTRA_STRICMP_H 31713498266Sopenharmony_ci# include <extra/stricmp.h> 31813498266Sopenharmony_ci#endif 31913498266Sopenharmony_ci 32013498266Sopenharmony_ci#ifdef HAVE_EXTRA_STRDUP_H 32113498266Sopenharmony_ci# include <extra/strdup.h> 32213498266Sopenharmony_ci#endif 32313498266Sopenharmony_ci 32413498266Sopenharmony_ci#ifdef __AMIGA__ 32513498266Sopenharmony_ci# ifdef __amigaos4__ 32613498266Sopenharmony_ci# define __USE_INLINE__ 32713498266Sopenharmony_ci /* use our own resolver which uses runtime feature detection */ 32813498266Sopenharmony_ci# define CURLRES_AMIGA 32913498266Sopenharmony_ci /* getaddrinfo() currently crashes bsdsocket.library, so disable */ 33013498266Sopenharmony_ci# undef HAVE_GETADDRINFO 33113498266Sopenharmony_ci# if !(defined(__NEWLIB__) || \ 33213498266Sopenharmony_ci (defined(__CLIB2__) && defined(__THREAD_SAFE))) 33313498266Sopenharmony_ci /* disable threaded resolver with clib2 - requires newlib or clib-ts */ 33413498266Sopenharmony_ci# undef USE_THREADS_POSIX 33513498266Sopenharmony_ci# endif 33613498266Sopenharmony_ci# endif 33713498266Sopenharmony_ci# include <exec/types.h> 33813498266Sopenharmony_ci# include <exec/execbase.h> 33913498266Sopenharmony_ci# include <proto/exec.h> 34013498266Sopenharmony_ci# include <proto/dos.h> 34113498266Sopenharmony_ci# include <unistd.h> 34213498266Sopenharmony_ci# if defined(HAVE_PROTO_BSDSOCKET_H) && \ 34313498266Sopenharmony_ci (!defined(__amigaos4__) || defined(USE_AMISSL)) 34413498266Sopenharmony_ci /* use bsdsocket.library directly, instead of libc networking functions */ 34513498266Sopenharmony_ci# define _SYS_MBUF_H /* m_len define clashes with curl */ 34613498266Sopenharmony_ci# include <proto/bsdsocket.h> 34713498266Sopenharmony_ci# ifdef __amigaos4__ 34813498266Sopenharmony_ci int Curl_amiga_select(int nfds, fd_set *readfds, fd_set *writefds, 34913498266Sopenharmony_ci fd_set *errorfds, struct timeval *timeout); 35013498266Sopenharmony_ci# define select(a,b,c,d,e) Curl_amiga_select(a,b,c,d,e) 35113498266Sopenharmony_ci# else 35213498266Sopenharmony_ci# define select(a,b,c,d,e) WaitSelect(a,b,c,d,e,0) 35313498266Sopenharmony_ci# endif 35413498266Sopenharmony_ci /* must not use libc's fcntl() on bsdsocket.library sockfds! */ 35513498266Sopenharmony_ci# undef HAVE_FCNTL 35613498266Sopenharmony_ci# undef HAVE_FCNTL_O_NONBLOCK 35713498266Sopenharmony_ci# else 35813498266Sopenharmony_ci /* use libc networking and hence close() and fnctl() */ 35913498266Sopenharmony_ci# undef HAVE_CLOSESOCKET_CAMEL 36013498266Sopenharmony_ci# undef HAVE_IOCTLSOCKET_CAMEL 36113498266Sopenharmony_ci# endif 36213498266Sopenharmony_ci/* 36313498266Sopenharmony_ci * In clib2 arpa/inet.h warns that some prototypes may clash 36413498266Sopenharmony_ci * with bsdsocket.library. This avoids the definition of those. 36513498266Sopenharmony_ci */ 36613498266Sopenharmony_ci# define __NO_NET_API 36713498266Sopenharmony_ci#endif 36813498266Sopenharmony_ci 36913498266Sopenharmony_ci#include <stdio.h> 37013498266Sopenharmony_ci#include <assert.h> 37113498266Sopenharmony_ci 37213498266Sopenharmony_ci#ifdef __TANDEM /* for ns*-tandem-nsk systems */ 37313498266Sopenharmony_ci# if ! defined __LP64 37413498266Sopenharmony_ci# include <floss.h> /* FLOSS is only used for 32-bit builds. */ 37513498266Sopenharmony_ci# endif 37613498266Sopenharmony_ci#endif 37713498266Sopenharmony_ci 37813498266Sopenharmony_ci#ifndef STDC_HEADERS /* no standard C headers! */ 37913498266Sopenharmony_ci#include <curl/stdcheaders.h> 38013498266Sopenharmony_ci#endif 38113498266Sopenharmony_ci 38213498266Sopenharmony_ci/* 38313498266Sopenharmony_ci * Large file (>2Gb) support using WIN32 functions. 38413498266Sopenharmony_ci */ 38513498266Sopenharmony_ci 38613498266Sopenharmony_ci#ifdef USE_WIN32_LARGE_FILES 38713498266Sopenharmony_ci# include <io.h> 38813498266Sopenharmony_ci# include <sys/types.h> 38913498266Sopenharmony_ci# include <sys/stat.h> 39013498266Sopenharmony_ci# undef lseek 39113498266Sopenharmony_ci# define lseek(fdes,offset,whence) _lseeki64(fdes, offset, whence) 39213498266Sopenharmony_ci# undef fstat 39313498266Sopenharmony_ci# define fstat(fdes,stp) _fstati64(fdes, stp) 39413498266Sopenharmony_ci# undef stat 39513498266Sopenharmony_ci# define stat(fname,stp) curlx_win32_stat(fname, stp) 39613498266Sopenharmony_ci# define struct_stat struct _stati64 39713498266Sopenharmony_ci# define LSEEK_ERROR (__int64)-1 39813498266Sopenharmony_ci# define open curlx_win32_open 39913498266Sopenharmony_ci# define fopen(fname,mode) curlx_win32_fopen(fname, mode) 40013498266Sopenharmony_ci# define access(fname,mode) curlx_win32_access(fname, mode) 40113498266Sopenharmony_ci int curlx_win32_open(const char *filename, int oflag, ...); 40213498266Sopenharmony_ci int curlx_win32_stat(const char *path, struct_stat *buffer); 40313498266Sopenharmony_ci FILE *curlx_win32_fopen(const char *filename, const char *mode); 40413498266Sopenharmony_ci int curlx_win32_access(const char *path, int mode); 40513498266Sopenharmony_ci#endif 40613498266Sopenharmony_ci 40713498266Sopenharmony_ci/* 40813498266Sopenharmony_ci * Small file (<2Gb) support using WIN32 functions. 40913498266Sopenharmony_ci */ 41013498266Sopenharmony_ci 41113498266Sopenharmony_ci#ifdef USE_WIN32_SMALL_FILES 41213498266Sopenharmony_ci# include <io.h> 41313498266Sopenharmony_ci# include <sys/types.h> 41413498266Sopenharmony_ci# include <sys/stat.h> 41513498266Sopenharmony_ci# ifndef _WIN32_WCE 41613498266Sopenharmony_ci# undef lseek 41713498266Sopenharmony_ci# define lseek(fdes,offset,whence) _lseek(fdes, (long)offset, whence) 41813498266Sopenharmony_ci# define fstat(fdes,stp) _fstat(fdes, stp) 41913498266Sopenharmony_ci# define stat(fname,stp) curlx_win32_stat(fname, stp) 42013498266Sopenharmony_ci# define struct_stat struct _stat 42113498266Sopenharmony_ci# define open curlx_win32_open 42213498266Sopenharmony_ci# define fopen(fname,mode) curlx_win32_fopen(fname, mode) 42313498266Sopenharmony_ci# define access(fname,mode) curlx_win32_access(fname, mode) 42413498266Sopenharmony_ci int curlx_win32_stat(const char *path, struct_stat *buffer); 42513498266Sopenharmony_ci int curlx_win32_open(const char *filename, int oflag, ...); 42613498266Sopenharmony_ci FILE *curlx_win32_fopen(const char *filename, const char *mode); 42713498266Sopenharmony_ci int curlx_win32_access(const char *path, int mode); 42813498266Sopenharmony_ci# endif 42913498266Sopenharmony_ci# define LSEEK_ERROR (long)-1 43013498266Sopenharmony_ci#endif 43113498266Sopenharmony_ci 43213498266Sopenharmony_ci#ifndef struct_stat 43313498266Sopenharmony_ci# define struct_stat struct stat 43413498266Sopenharmony_ci#endif 43513498266Sopenharmony_ci 43613498266Sopenharmony_ci#ifndef LSEEK_ERROR 43713498266Sopenharmony_ci# define LSEEK_ERROR (off_t)-1 43813498266Sopenharmony_ci#endif 43913498266Sopenharmony_ci 44013498266Sopenharmony_ci#ifndef SIZEOF_TIME_T 44113498266Sopenharmony_ci/* assume default size of time_t to be 32 bit */ 44213498266Sopenharmony_ci#define SIZEOF_TIME_T 4 44313498266Sopenharmony_ci#endif 44413498266Sopenharmony_ci 44513498266Sopenharmony_ci#ifndef SIZEOF_CURL_SOCKET_T 44613498266Sopenharmony_ci/* configure and cmake check and set the define */ 44713498266Sopenharmony_ci# ifdef _WIN64 44813498266Sopenharmony_ci# define SIZEOF_CURL_SOCKET_T 8 44913498266Sopenharmony_ci# else 45013498266Sopenharmony_ci/* default guess */ 45113498266Sopenharmony_ci# define SIZEOF_CURL_SOCKET_T 4 45213498266Sopenharmony_ci# endif 45313498266Sopenharmony_ci#endif 45413498266Sopenharmony_ci 45513498266Sopenharmony_ci#if SIZEOF_CURL_SOCKET_T < 8 45613498266Sopenharmony_ci# define CURL_FORMAT_SOCKET_T "d" 45713498266Sopenharmony_ci#elif defined(__MINGW32__) 45813498266Sopenharmony_ci# define CURL_FORMAT_SOCKET_T "zd" 45913498266Sopenharmony_ci#else 46013498266Sopenharmony_ci# define CURL_FORMAT_SOCKET_T "qd" 46113498266Sopenharmony_ci#endif 46213498266Sopenharmony_ci 46313498266Sopenharmony_ci/* 46413498266Sopenharmony_ci * Default sizeof(off_t) in case it hasn't been defined in config file. 46513498266Sopenharmony_ci */ 46613498266Sopenharmony_ci 46713498266Sopenharmony_ci#ifndef SIZEOF_OFF_T 46813498266Sopenharmony_ci# if defined(__VMS) && !defined(__VAX) 46913498266Sopenharmony_ci# if defined(_LARGEFILE) 47013498266Sopenharmony_ci# define SIZEOF_OFF_T 8 47113498266Sopenharmony_ci# endif 47213498266Sopenharmony_ci# elif defined(__OS400__) && defined(__ILEC400__) 47313498266Sopenharmony_ci# if defined(_LARGE_FILES) 47413498266Sopenharmony_ci# define SIZEOF_OFF_T 8 47513498266Sopenharmony_ci# endif 47613498266Sopenharmony_ci# elif defined(__MVS__) && defined(__IBMC__) 47713498266Sopenharmony_ci# if defined(_LP64) || defined(_LARGE_FILES) 47813498266Sopenharmony_ci# define SIZEOF_OFF_T 8 47913498266Sopenharmony_ci# endif 48013498266Sopenharmony_ci# elif defined(__370__) && defined(__IBMC__) 48113498266Sopenharmony_ci# if defined(_LP64) || defined(_LARGE_FILES) 48213498266Sopenharmony_ci# define SIZEOF_OFF_T 8 48313498266Sopenharmony_ci# endif 48413498266Sopenharmony_ci# endif 48513498266Sopenharmony_ci# ifndef SIZEOF_OFF_T 48613498266Sopenharmony_ci# define SIZEOF_OFF_T 4 48713498266Sopenharmony_ci# endif 48813498266Sopenharmony_ci#endif 48913498266Sopenharmony_ci 49013498266Sopenharmony_ci#if (SIZEOF_CURL_OFF_T < 8) 49113498266Sopenharmony_ci#error "too small curl_off_t" 49213498266Sopenharmony_ci#else 49313498266Sopenharmony_ci /* assume SIZEOF_CURL_OFF_T == 8 */ 49413498266Sopenharmony_ci# define CURL_OFF_T_MAX CURL_OFF_T_C(0x7FFFFFFFFFFFFFFF) 49513498266Sopenharmony_ci#endif 49613498266Sopenharmony_ci#define CURL_OFF_T_MIN (-CURL_OFF_T_MAX - CURL_OFF_T_C(1)) 49713498266Sopenharmony_ci 49813498266Sopenharmony_ci#if (SIZEOF_TIME_T == 4) 49913498266Sopenharmony_ci# ifdef HAVE_TIME_T_UNSIGNED 50013498266Sopenharmony_ci# define TIME_T_MAX UINT_MAX 50113498266Sopenharmony_ci# define TIME_T_MIN 0 50213498266Sopenharmony_ci# else 50313498266Sopenharmony_ci# define TIME_T_MAX INT_MAX 50413498266Sopenharmony_ci# define TIME_T_MIN INT_MIN 50513498266Sopenharmony_ci# endif 50613498266Sopenharmony_ci#else 50713498266Sopenharmony_ci# ifdef HAVE_TIME_T_UNSIGNED 50813498266Sopenharmony_ci# define TIME_T_MAX 0xFFFFFFFFFFFFFFFF 50913498266Sopenharmony_ci# define TIME_T_MIN 0 51013498266Sopenharmony_ci# else 51113498266Sopenharmony_ci# define TIME_T_MAX 0x7FFFFFFFFFFFFFFF 51213498266Sopenharmony_ci# define TIME_T_MIN (-TIME_T_MAX - 1) 51313498266Sopenharmony_ci# endif 51413498266Sopenharmony_ci#endif 51513498266Sopenharmony_ci 51613498266Sopenharmony_ci#ifndef SIZE_T_MAX 51713498266Sopenharmony_ci/* some limits.h headers have this defined, some don't */ 51813498266Sopenharmony_ci#if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4) 51913498266Sopenharmony_ci#define SIZE_T_MAX 18446744073709551615U 52013498266Sopenharmony_ci#else 52113498266Sopenharmony_ci#define SIZE_T_MAX 4294967295U 52213498266Sopenharmony_ci#endif 52313498266Sopenharmony_ci#endif 52413498266Sopenharmony_ci 52513498266Sopenharmony_ci#ifndef SSIZE_T_MAX 52613498266Sopenharmony_ci/* some limits.h headers have this defined, some don't */ 52713498266Sopenharmony_ci#if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4) 52813498266Sopenharmony_ci#define SSIZE_T_MAX 9223372036854775807 52913498266Sopenharmony_ci#else 53013498266Sopenharmony_ci#define SSIZE_T_MAX 2147483647 53113498266Sopenharmony_ci#endif 53213498266Sopenharmony_ci#endif 53313498266Sopenharmony_ci 53413498266Sopenharmony_ci/* 53513498266Sopenharmony_ci * Arg 2 type for gethostname in case it hasn't been defined in config file. 53613498266Sopenharmony_ci */ 53713498266Sopenharmony_ci 53813498266Sopenharmony_ci#ifndef GETHOSTNAME_TYPE_ARG2 53913498266Sopenharmony_ci# ifdef USE_WINSOCK 54013498266Sopenharmony_ci# define GETHOSTNAME_TYPE_ARG2 int 54113498266Sopenharmony_ci# else 54213498266Sopenharmony_ci# define GETHOSTNAME_TYPE_ARG2 size_t 54313498266Sopenharmony_ci# endif 54413498266Sopenharmony_ci#endif 54513498266Sopenharmony_ci 54613498266Sopenharmony_ci/* Below we define some functions. They should 54713498266Sopenharmony_ci 54813498266Sopenharmony_ci 4. set the SIGALRM signal timeout 54913498266Sopenharmony_ci 5. set dir/file naming defines 55013498266Sopenharmony_ci */ 55113498266Sopenharmony_ci 55213498266Sopenharmony_ci#ifdef _WIN32 55313498266Sopenharmony_ci 55413498266Sopenharmony_ci# define DIR_CHAR "\\" 55513498266Sopenharmony_ci 55613498266Sopenharmony_ci#else /* _WIN32 */ 55713498266Sopenharmony_ci 55813498266Sopenharmony_ci# ifdef MSDOS /* Watt-32 */ 55913498266Sopenharmony_ci 56013498266Sopenharmony_ci# include <sys/ioctl.h> 56113498266Sopenharmony_ci# define select(n,r,w,x,t) select_s(n,r,w,x,t) 56213498266Sopenharmony_ci# define ioctl(x,y,z) ioctlsocket(x,y,(char *)(z)) 56313498266Sopenharmony_ci# include <tcp.h> 56413498266Sopenharmony_ci# ifdef word 56513498266Sopenharmony_ci# undef word 56613498266Sopenharmony_ci# endif 56713498266Sopenharmony_ci# ifdef byte 56813498266Sopenharmony_ci# undef byte 56913498266Sopenharmony_ci# endif 57013498266Sopenharmony_ci 57113498266Sopenharmony_ci# endif /* MSDOS */ 57213498266Sopenharmony_ci 57313498266Sopenharmony_ci# ifdef __minix 57413498266Sopenharmony_ci /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */ 57513498266Sopenharmony_ci extern char *strtok_r(char *s, const char *delim, char **last); 57613498266Sopenharmony_ci extern struct tm *gmtime_r(const time_t * const timep, struct tm *tmp); 57713498266Sopenharmony_ci# endif 57813498266Sopenharmony_ci 57913498266Sopenharmony_ci# define DIR_CHAR "/" 58013498266Sopenharmony_ci 58113498266Sopenharmony_ci#endif /* _WIN32 */ 58213498266Sopenharmony_ci 58313498266Sopenharmony_ci/* ---------------------------------------------------------------- */ 58413498266Sopenharmony_ci/* resolver specialty compile-time defines */ 58513498266Sopenharmony_ci/* CURLRES_* defines to use in the host*.c sources */ 58613498266Sopenharmony_ci/* ---------------------------------------------------------------- */ 58713498266Sopenharmony_ci 58813498266Sopenharmony_ci/* 58913498266Sopenharmony_ci * MSVC threads support requires a multi-threaded runtime library. 59013498266Sopenharmony_ci * _beginthreadex() is not available in single-threaded ones. 59113498266Sopenharmony_ci */ 59213498266Sopenharmony_ci 59313498266Sopenharmony_ci#if defined(_MSC_VER) && !defined(_MT) 59413498266Sopenharmony_ci# undef USE_THREADS_POSIX 59513498266Sopenharmony_ci# undef USE_THREADS_WIN32 59613498266Sopenharmony_ci#endif 59713498266Sopenharmony_ci 59813498266Sopenharmony_ci/* 59913498266Sopenharmony_ci * Mutually exclusive CURLRES_* definitions. 60013498266Sopenharmony_ci */ 60113498266Sopenharmony_ci 60213498266Sopenharmony_ci#if defined(ENABLE_IPV6) && defined(HAVE_GETADDRINFO) 60313498266Sopenharmony_ci# define CURLRES_IPV6 60413498266Sopenharmony_ci#elif defined(ENABLE_IPV6) && (defined(_WIN32) || defined(__CYGWIN__)) 60513498266Sopenharmony_ci/* assume on Windows that IPv6 without getaddrinfo is a broken build */ 60613498266Sopenharmony_ci# error "Unexpected build: IPv6 is enabled but getaddrinfo was not found." 60713498266Sopenharmony_ci#else 60813498266Sopenharmony_ci# define CURLRES_IPV4 60913498266Sopenharmony_ci#endif 61013498266Sopenharmony_ci 61113498266Sopenharmony_ci#ifdef USE_ARES 61213498266Sopenharmony_ci# define CURLRES_ASYNCH 61313498266Sopenharmony_ci# define CURLRES_ARES 61413498266Sopenharmony_ci/* now undef the stock libc functions just to avoid them being used */ 61513498266Sopenharmony_ci# undef HAVE_GETADDRINFO 61613498266Sopenharmony_ci# undef HAVE_FREEADDRINFO 61713498266Sopenharmony_ci#elif defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32) 61813498266Sopenharmony_ci# define CURLRES_ASYNCH 61913498266Sopenharmony_ci# define CURLRES_THREADED 62013498266Sopenharmony_ci#else 62113498266Sopenharmony_ci# define CURLRES_SYNCH 62213498266Sopenharmony_ci#endif 62313498266Sopenharmony_ci 62413498266Sopenharmony_ci/* ---------------------------------------------------------------- */ 62513498266Sopenharmony_ci 62613498266Sopenharmony_ci#if defined(HAVE_LIBIDN2) && defined(HAVE_IDN2_H) && !defined(USE_WIN32_IDN) 62713498266Sopenharmony_ci/* The lib and header are present */ 62813498266Sopenharmony_ci#define USE_LIBIDN2 62913498266Sopenharmony_ci#endif 63013498266Sopenharmony_ci 63113498266Sopenharmony_ci#if defined(USE_LIBIDN2) && defined(USE_WIN32_IDN) 63213498266Sopenharmony_ci#error "Both libidn2 and WinIDN are enabled, choose one." 63313498266Sopenharmony_ci#endif 63413498266Sopenharmony_ci 63513498266Sopenharmony_ci#define LIBIDN_REQUIRED_VERSION "0.4.1" 63613498266Sopenharmony_ci 63713498266Sopenharmony_ci#if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_MBEDTLS) || \ 63813498266Sopenharmony_ci defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || defined(USE_SECTRANSP) || \ 63913498266Sopenharmony_ci defined(USE_BEARSSL) || defined(USE_RUSTLS) 64013498266Sopenharmony_ci#define USE_SSL /* SSL support has been enabled */ 64113498266Sopenharmony_ci#endif 64213498266Sopenharmony_ci 64313498266Sopenharmony_ci/* Single point where USE_SPNEGO definition might be defined */ 64413498266Sopenharmony_ci#if !defined(CURL_DISABLE_NEGOTIATE_AUTH) && \ 64513498266Sopenharmony_ci (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) 64613498266Sopenharmony_ci#define USE_SPNEGO 64713498266Sopenharmony_ci#endif 64813498266Sopenharmony_ci 64913498266Sopenharmony_ci/* Single point where USE_KERBEROS5 definition might be defined */ 65013498266Sopenharmony_ci#if !defined(CURL_DISABLE_KERBEROS_AUTH) && \ 65113498266Sopenharmony_ci (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI)) 65213498266Sopenharmony_ci#define USE_KERBEROS5 65313498266Sopenharmony_ci#endif 65413498266Sopenharmony_ci 65513498266Sopenharmony_ci/* Single point where USE_NTLM definition might be defined */ 65613498266Sopenharmony_ci#if !defined(CURL_DISABLE_NTLM) 65713498266Sopenharmony_ci# if defined(USE_OPENSSL) || defined(USE_MBEDTLS) || \ 65813498266Sopenharmony_ci defined(USE_GNUTLS) || defined(USE_SECTRANSP) || \ 65913498266Sopenharmony_ci defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) || \ 66013498266Sopenharmony_ci (defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT)) 66113498266Sopenharmony_ci# define USE_CURL_NTLM_CORE 66213498266Sopenharmony_ci# endif 66313498266Sopenharmony_ci# if defined(USE_CURL_NTLM_CORE) || defined(USE_WINDOWS_SSPI) 66413498266Sopenharmony_ci# define USE_NTLM 66513498266Sopenharmony_ci# endif 66613498266Sopenharmony_ci#endif 66713498266Sopenharmony_ci 66813498266Sopenharmony_ci#ifdef CURL_WANTS_CA_BUNDLE_ENV 66913498266Sopenharmony_ci#error "No longer supported. Set CURLOPT_CAINFO at runtime instead." 67013498266Sopenharmony_ci#endif 67113498266Sopenharmony_ci 67213498266Sopenharmony_ci#if defined(USE_LIBSSH2) || defined(USE_LIBSSH) || defined(USE_WOLFSSH) 67313498266Sopenharmony_ci#define USE_SSH 67413498266Sopenharmony_ci#endif 67513498266Sopenharmony_ci 67613498266Sopenharmony_ci/* 67713498266Sopenharmony_ci * Provide a mechanism to silence picky compilers, such as gcc 4.6+. 67813498266Sopenharmony_ci * Parameters should of course normally not be unused, but for example when 67913498266Sopenharmony_ci * we have multiple implementations of the same interface it may happen. 68013498266Sopenharmony_ci */ 68113498266Sopenharmony_ci 68213498266Sopenharmony_ci#if defined(__GNUC__) && ((__GNUC__ >= 3) || \ 68313498266Sopenharmony_ci ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7))) 68413498266Sopenharmony_ci# define UNUSED_PARAM __attribute__((__unused__)) 68513498266Sopenharmony_ci# define WARN_UNUSED_RESULT __attribute__((warn_unused_result)) 68613498266Sopenharmony_ci#else 68713498266Sopenharmony_ci# define UNUSED_PARAM /* NOTHING */ 68813498266Sopenharmony_ci# define WARN_UNUSED_RESULT 68913498266Sopenharmony_ci#endif 69013498266Sopenharmony_ci 69113498266Sopenharmony_ci/* noreturn attribute */ 69213498266Sopenharmony_ci 69313498266Sopenharmony_ci#if !defined(CURL_NORETURN) 69413498266Sopenharmony_ci#if (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__clang__) 69513498266Sopenharmony_ci# define CURL_NORETURN __attribute__((__noreturn__)) 69613498266Sopenharmony_ci#elif defined(_MSC_VER) && (_MSC_VER >= 1200) 69713498266Sopenharmony_ci# define CURL_NORETURN __declspec(noreturn) 69813498266Sopenharmony_ci#else 69913498266Sopenharmony_ci# define CURL_NORETURN 70013498266Sopenharmony_ci#endif 70113498266Sopenharmony_ci#endif 70213498266Sopenharmony_ci 70313498266Sopenharmony_ci/* fallthrough attribute */ 70413498266Sopenharmony_ci 70513498266Sopenharmony_ci#if !defined(FALLTHROUGH) 70613498266Sopenharmony_ci#if (defined(__GNUC__) && __GNUC__ >= 7) || \ 70713498266Sopenharmony_ci (defined(__clang__) && __clang_major__ >= 10) 70813498266Sopenharmony_ci# define FALLTHROUGH() __attribute__((fallthrough)) 70913498266Sopenharmony_ci#else 71013498266Sopenharmony_ci# define FALLTHROUGH() do {} while (0) 71113498266Sopenharmony_ci#endif 71213498266Sopenharmony_ci#endif 71313498266Sopenharmony_ci 71413498266Sopenharmony_ci/* 71513498266Sopenharmony_ci * Include macros and defines that should only be processed once. 71613498266Sopenharmony_ci */ 71713498266Sopenharmony_ci 71813498266Sopenharmony_ci#ifndef HEADER_CURL_SETUP_ONCE_H 71913498266Sopenharmony_ci#include "curl_setup_once.h" 72013498266Sopenharmony_ci#endif 72113498266Sopenharmony_ci 72213498266Sopenharmony_ci/* 72313498266Sopenharmony_ci * Definition of our NOP statement Object-like macro 72413498266Sopenharmony_ci */ 72513498266Sopenharmony_ci 72613498266Sopenharmony_ci#ifndef Curl_nop_stmt 72713498266Sopenharmony_ci# define Curl_nop_stmt do { } while(0) 72813498266Sopenharmony_ci#endif 72913498266Sopenharmony_ci 73013498266Sopenharmony_ci/* 73113498266Sopenharmony_ci * Ensure that Winsock and lwIP TCP/IP stacks are not mixed. 73213498266Sopenharmony_ci */ 73313498266Sopenharmony_ci 73413498266Sopenharmony_ci#if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H) 73513498266Sopenharmony_ci# if defined(SOCKET) || defined(USE_WINSOCK) 73613498266Sopenharmony_ci# error "WinSock and lwIP TCP/IP stack definitions shall not coexist!" 73713498266Sopenharmony_ci# endif 73813498266Sopenharmony_ci#endif 73913498266Sopenharmony_ci 74013498266Sopenharmony_ci/* 74113498266Sopenharmony_ci * shutdown() flags for systems that don't define them 74213498266Sopenharmony_ci */ 74313498266Sopenharmony_ci 74413498266Sopenharmony_ci#ifndef SHUT_RD 74513498266Sopenharmony_ci#define SHUT_RD 0x00 74613498266Sopenharmony_ci#endif 74713498266Sopenharmony_ci 74813498266Sopenharmony_ci#ifndef SHUT_WR 74913498266Sopenharmony_ci#define SHUT_WR 0x01 75013498266Sopenharmony_ci#endif 75113498266Sopenharmony_ci 75213498266Sopenharmony_ci#ifndef SHUT_RDWR 75313498266Sopenharmony_ci#define SHUT_RDWR 0x02 75413498266Sopenharmony_ci#endif 75513498266Sopenharmony_ci 75613498266Sopenharmony_ci/* Define S_ISREG if not defined by system headers, e.g. MSVC */ 75713498266Sopenharmony_ci#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG) 75813498266Sopenharmony_ci#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG) 75913498266Sopenharmony_ci#endif 76013498266Sopenharmony_ci 76113498266Sopenharmony_ci/* Define S_ISDIR if not defined by system headers, e.g. MSVC */ 76213498266Sopenharmony_ci#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR) 76313498266Sopenharmony_ci#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR) 76413498266Sopenharmony_ci#endif 76513498266Sopenharmony_ci 76613498266Sopenharmony_ci/* In Windows the default file mode is text but an application can override it. 76713498266Sopenharmony_ciTherefore we specify it explicitly. https://github.com/curl/curl/pull/258 76813498266Sopenharmony_ci*/ 76913498266Sopenharmony_ci#if defined(_WIN32) || defined(MSDOS) 77013498266Sopenharmony_ci#define FOPEN_READTEXT "rt" 77113498266Sopenharmony_ci#define FOPEN_WRITETEXT "wt" 77213498266Sopenharmony_ci#define FOPEN_APPENDTEXT "at" 77313498266Sopenharmony_ci#elif defined(__CYGWIN__) 77413498266Sopenharmony_ci/* Cygwin has specific behavior we need to address when WIN32 is not defined. 77513498266Sopenharmony_cihttps://cygwin.com/cygwin-ug-net/using-textbinary.html 77613498266Sopenharmony_ciFor write we want our output to have line endings of LF and be compatible with 77713498266Sopenharmony_ciother Cygwin utilities. For read we want to handle input that may have line 77813498266Sopenharmony_ciendings either CRLF or LF so 't' is appropriate. 77913498266Sopenharmony_ci*/ 78013498266Sopenharmony_ci#define FOPEN_READTEXT "rt" 78113498266Sopenharmony_ci#define FOPEN_WRITETEXT "w" 78213498266Sopenharmony_ci#define FOPEN_APPENDTEXT "a" 78313498266Sopenharmony_ci#else 78413498266Sopenharmony_ci#define FOPEN_READTEXT "r" 78513498266Sopenharmony_ci#define FOPEN_WRITETEXT "w" 78613498266Sopenharmony_ci#define FOPEN_APPENDTEXT "a" 78713498266Sopenharmony_ci#endif 78813498266Sopenharmony_ci 78913498266Sopenharmony_ci/* for systems that don't detect this in configure */ 79013498266Sopenharmony_ci#ifndef CURL_SA_FAMILY_T 79113498266Sopenharmony_ci# if defined(HAVE_SA_FAMILY_T) 79213498266Sopenharmony_ci# define CURL_SA_FAMILY_T sa_family_t 79313498266Sopenharmony_ci# elif defined(HAVE_ADDRESS_FAMILY) 79413498266Sopenharmony_ci# define CURL_SA_FAMILY_T ADDRESS_FAMILY 79513498266Sopenharmony_ci# else 79613498266Sopenharmony_ci/* use a sensible default */ 79713498266Sopenharmony_ci# define CURL_SA_FAMILY_T unsigned short 79813498266Sopenharmony_ci# endif 79913498266Sopenharmony_ci#endif 80013498266Sopenharmony_ci 80113498266Sopenharmony_ci/* Some convenience macros to get the larger/smaller value out of two given. 80213498266Sopenharmony_ci We prefix with CURL to prevent name collisions. */ 80313498266Sopenharmony_ci#define CURLMAX(x,y) ((x)>(y)?(x):(y)) 80413498266Sopenharmony_ci#define CURLMIN(x,y) ((x)<(y)?(x):(y)) 80513498266Sopenharmony_ci 80613498266Sopenharmony_ci/* A convenience macro to provide both the string literal and the length of 80713498266Sopenharmony_ci the string literal in one go, useful for functions that take "string,len" 80813498266Sopenharmony_ci as their argument */ 80913498266Sopenharmony_ci#define STRCONST(x) x,sizeof(x)-1 81013498266Sopenharmony_ci 81113498266Sopenharmony_ci/* Some versions of the Android SDK is missing the declaration */ 81213498266Sopenharmony_ci#if defined(HAVE_GETPWUID_R) && defined(HAVE_DECL_GETPWUID_R_MISSING) 81313498266Sopenharmony_cistruct passwd; 81413498266Sopenharmony_ciint getpwuid_r(uid_t uid, struct passwd *pwd, char *buf, 81513498266Sopenharmony_ci size_t buflen, struct passwd **result); 81613498266Sopenharmony_ci#endif 81713498266Sopenharmony_ci 81813498266Sopenharmony_ci#ifdef DEBUGBUILD 81913498266Sopenharmony_ci#define UNITTEST 82013498266Sopenharmony_ci#else 82113498266Sopenharmony_ci#define UNITTEST static 82213498266Sopenharmony_ci#endif 82313498266Sopenharmony_ci 82413498266Sopenharmony_ci/* Hyper supports HTTP2 also, but Curl's integration with Hyper does not */ 82513498266Sopenharmony_ci#if defined(USE_NGHTTP2) 82613498266Sopenharmony_ci#define USE_HTTP2 82713498266Sopenharmony_ci#endif 82813498266Sopenharmony_ci 82913498266Sopenharmony_ci#if (defined(USE_NGTCP2) && defined(USE_NGHTTP3)) || \ 83013498266Sopenharmony_ci (defined(USE_OPENSSL_QUIC) && defined(USE_NGHTTP3)) || \ 83113498266Sopenharmony_ci defined(USE_QUICHE) || defined(USE_MSH3) 83213498266Sopenharmony_ci 83313498266Sopenharmony_ci#ifdef CURL_WITH_MULTI_SSL 83413498266Sopenharmony_ci#error "Multi-SSL combined with QUIC is not supported" 83513498266Sopenharmony_ci#endif 83613498266Sopenharmony_ci 83713498266Sopenharmony_ci#define ENABLE_QUIC 83813498266Sopenharmony_ci#define USE_HTTP3 83913498266Sopenharmony_ci#endif 84013498266Sopenharmony_ci 84113498266Sopenharmony_ci/* Certain Windows implementations are not aligned with what curl expects, 84213498266Sopenharmony_ci so always use the local one on this platform. E.g. the mingw-w64 84313498266Sopenharmony_ci implementation can return wrong results for non-ASCII inputs. */ 84413498266Sopenharmony_ci#if defined(HAVE_BASENAME) && defined(_WIN32) 84513498266Sopenharmony_ci#undef HAVE_BASENAME 84613498266Sopenharmony_ci#endif 84713498266Sopenharmony_ci 84813498266Sopenharmony_ci#if defined(USE_UNIX_SOCKETS) && defined(_WIN32) 84913498266Sopenharmony_ci# if !defined(UNIX_PATH_MAX) 85013498266Sopenharmony_ci /* Replicating logic present in afunix.h 85113498266Sopenharmony_ci (distributed with newer Windows 10 SDK versions only) */ 85213498266Sopenharmony_ci# define UNIX_PATH_MAX 108 85313498266Sopenharmony_ci /* !checksrc! disable TYPEDEFSTRUCT 1 */ 85413498266Sopenharmony_ci typedef struct sockaddr_un { 85513498266Sopenharmony_ci ADDRESS_FAMILY sun_family; 85613498266Sopenharmony_ci char sun_path[UNIX_PATH_MAX]; 85713498266Sopenharmony_ci } SOCKADDR_UN, *PSOCKADDR_UN; 85813498266Sopenharmony_ci# define WIN32_SOCKADDR_UN 85913498266Sopenharmony_ci# endif 86013498266Sopenharmony_ci#endif 86113498266Sopenharmony_ci 86213498266Sopenharmony_ci/* OpenSSLv3 marks DES, MD5 and ENGINE functions deprecated but we have no 86313498266Sopenharmony_ci replacements (yet) so tell the compiler to not warn for them. */ 86413498266Sopenharmony_ci#ifdef USE_OPENSSL 86513498266Sopenharmony_ci#define OPENSSL_SUPPRESS_DEPRECATED 86613498266Sopenharmony_ci#endif 86713498266Sopenharmony_ci 86813498266Sopenharmony_ci#endif /* HEADER_CURL_SETUP_H */ 869