Coverage Report

Created: 2025-12-14 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/curl/lib/curl_setup.h
Line
Count
Source
1
#ifndef HEADER_CURL_SETUP_H
2
#define HEADER_CURL_SETUP_H
3
/***************************************************************************
4
 *                                  _   _ ____  _
5
 *  Project                     ___| | | |  _ \| |
6
 *                             / __| | | | |_) | |
7
 *                            | (__| |_| |  _ <| |___
8
 *                             \___|\___/|_| \_\_____|
9
 *
10
 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
11
 *
12
 * This software is licensed as described in the file COPYING, which
13
 * you should have received as part of this distribution. The terms
14
 * are also available at https://curl.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
 * SPDX-License-Identifier: curl
24
 *
25
 ***************************************************************************/
26
27
#if defined(BUILDING_LIBCURL) && !defined(CURL_NO_OLDIES)
28
#define CURL_NO_OLDIES
29
#endif
30
31
/* Set default _WIN32_WINNT */
32
#ifdef __MINGW32__
33
#include <_mingw.h>
34
#endif
35
36
/* Workaround for Homebrew gcc 12.4.0, 13.3.0, 14.1.0, 14.2.0 (initial build)
37
   that started advertising the `availability` attribute, which then gets used
38
   by Apple SDK, but, in a way incompatible with gcc, resulting in misc errors
39
   inside SDK headers, e.g.:
40
     error: attributes should be specified before the declarator in a function
41
            definition
42
     error: expected ',' or '}' before
43
   Followed by missing declarations.
44
   Work it around by overriding the built-in feature-check macro used by the
45
   headers to enable the problematic attributes. This makes the feature check
46
   fail. Fixed in 14.2.0_1. Disable the workaround if the fix is detected. */
47
#if defined(__APPLE__) && !defined(__clang__) && defined(__GNUC__) && \
48
  defined(__has_attribute)
49
#  if !defined(__has_feature)  /* Keep this PP check separate from others */
50
#    define availability curl_pp_attribute_disabled
51
#  elif !__has_feature(attribute_availability)
52
#    define availability curl_pp_attribute_disabled
53
#  endif
54
#endif
55
56
#ifdef __APPLE__
57
#include <sys/types.h>
58
#include <TargetConditionals.h>
59
/* Fixup faulty target macro initialization in macOS SDK since v14.4 (as of
60
   15.0 beta). The SDK target detection in `TargetConditionals.h` correctly
61
   detects macOS, but fails to set the macro's old name `TARGET_OS_OSX`, then
62
   continues to set it to a default value of 0. Other parts of the SDK still
63
   rely on the old name, and with this inconsistency our builds fail due to
64
   missing declarations. It happens when using mainline llvm older than v18.
65
   Later versions fixed it by predefining these target macros, avoiding the
66
   faulty dynamic detection. gcc is not affected (for now) because it lacks
67
   the necessary dynamic detection features, so the SDK falls back to
68
   a codepath that sets both the old and new macro to 1. */
69
#if defined(TARGET_OS_MAC) && TARGET_OS_MAC && \
70
  defined(TARGET_OS_OSX) && !TARGET_OS_OSX && \
71
  (!defined(TARGET_OS_IPHONE) || !TARGET_OS_IPHONE) && \
72
  (!defined(TARGET_OS_SIMULATOR) || !TARGET_OS_SIMULATOR)
73
#undef TARGET_OS_OSX
74
#define TARGET_OS_OSX TARGET_OS_MAC
75
#endif
76
#endif
77
78
#if defined(__MINGW32__) && \
79
  (!defined(__MINGW64_VERSION_MAJOR) || (__MINGW64_VERSION_MAJOR < 3))
80
#error "Building curl requires mingw-w64 3.0 or later"
81
#endif
82
83
/* Visual Studio 2010 is the minimum Visual Studio version we support.
84
   Workarounds for older versions of Visual Studio have been removed. */
85
#if defined(_MSC_VER) && (_MSC_VER < 1600)
86
#error "Ancient versions of Visual Studio are no longer supported due to bugs."
87
#endif
88
89
#ifdef _MSC_VER
90
/* Disable Visual Studio warnings: 4127 "conditional expression is constant" */
91
#pragma warning(disable:4127)
92
/* Avoid VS2005 and upper complaining about portable C functions. */
93
#ifndef _CRT_NONSTDC_NO_DEPRECATE  /* mingw-w64 v2+. MS SDK ~10+/~VS2017+. */
94
#define _CRT_NONSTDC_NO_DEPRECATE  /* for close(), fileno(), unlink(), etc. */
95
#endif
96
#ifndef _CRT_SECURE_NO_WARNINGS
97
#define _CRT_SECURE_NO_WARNINGS  /* for getenv(), gmtime(), strcpy(),
98
                                    in tests: localtime(), sscanf() */
99
#endif
100
#endif /* _MSC_VER */
101
102
#ifdef _WIN32
103
/*
104
 * Do not include unneeded stuff in Windows headers to avoid compiler
105
 * warnings and macro clashes.
106
 * Make sure to define this macro before including any Windows headers.
107
 */
108
#  ifndef WIN32_LEAN_AND_MEAN
109
#  define WIN32_LEAN_AND_MEAN
110
#  endif
111
#  ifndef NOGDI
112
#  define NOGDI
113
#  endif
114
/* Detect Windows App environment which has a restricted access
115
 * to the Win32 APIs. */
116
#  if (defined(_WIN32_WINNT) && (_WIN32_WINNT >= 0x0602)) || \
117
     defined(WINAPI_FAMILY)
118
#    include <winapifamily.h>
119
#    if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) &&  \
120
       !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
121
#      define CURL_WINDOWS_UWP
122
#    endif
123
#  endif
124
#endif
125
126
/* Compatibility */
127
#ifdef ENABLE_IPV6
128
#define USE_IPV6 1
129
#endif
130
131
/*
132
 * Include configuration script results or hand-crafted
133
 * configuration file for platforms which lack config tool.
134
 */
135
136
#ifdef HAVE_CONFIG_H
137
138
#include "curl_config.h"
139
140
#else /* HAVE_CONFIG_H */
141
142
#ifdef _WIN32
143
#  include "config-win32.h"
144
#endif
145
146
#ifdef macintosh
147
#  include "config-mac.h"
148
#endif
149
150
#ifdef __riscos__
151
#  include "config-riscos.h"
152
#endif
153
154
#ifdef __OS400__
155
#  include "config-os400.h"
156
#endif
157
158
#ifdef __PLAN9__
159
#  include "config-plan9.h"
160
#endif
161
162
#endif /* HAVE_CONFIG_H */
163
164
/* ================================================================ */
165
/* Definition of preprocessor macros/symbols which modify compiler  */
166
/* behavior or generated code characteristics must be done here,   */
167
/* as appropriate, before any system header file is included. It is */
168
/* also possible to have them defined in the config file included   */
169
/* before this point. As a result of all this we frown inclusion of */
170
/* system header files in our config files, avoid this at any cost. */
171
/* ================================================================ */
172
173
#ifdef HAVE_LIBZ
174
#  ifndef ZLIB_CONST
175
#  define ZLIB_CONST  /* Use z_const. Supported by v1.2.5.2 and upper. */
176
#  endif
177
#endif
178
179
/*
180
 * AIX 4.3 and newer needs _THREAD_SAFE defined to build
181
 * proper reentrant code. Others may also need it.
182
 */
183
#ifdef NEED_THREAD_SAFE
184
#  ifndef _THREAD_SAFE
185
#  define _THREAD_SAFE
186
#  endif
187
#endif
188
189
/*
190
 * Tru64 needs _REENTRANT set for a few function prototypes and
191
 * things to appear in the system header files. Unixware needs it
192
 * to build proper reentrant code. Others may also need it.
193
 */
194
#ifdef NEED_REENTRANT
195
#  ifndef _REENTRANT
196
#  define _REENTRANT
197
#  endif
198
#endif
199
200
/* Solaris needs this to get a POSIX-conformant getpwuid_r */
201
#if defined(sun) || defined(__sun)
202
#  ifndef _POSIX_PTHREAD_SEMANTICS
203
#  define _POSIX_PTHREAD_SEMANTICS 1
204
#  endif
205
#endif
206
207
/* ================================================================ */
208
/*  If you need to include a system header file for your platform,  */
209
/*  please, do it beyond the point further indicated in this file.  */
210
/* ================================================================ */
211
212
/* Give calloc a chance to be dragging in early, so we do not redefine */
213
#if defined(USE_THREADS_POSIX) && defined(HAVE_PTHREAD_H)
214
#  include <pthread.h>
215
#endif
216
217
/*
218
 * Disable other protocols when http is the only one desired.
219
 */
220
#ifdef HTTP_ONLY
221
#  ifndef CURL_DISABLE_DICT
222
#  define CURL_DISABLE_DICT
223
#  endif
224
#  ifndef CURL_DISABLE_FILE
225
#  define CURL_DISABLE_FILE
226
#  endif
227
#  ifndef CURL_DISABLE_FTP
228
#  define CURL_DISABLE_FTP
229
#  endif
230
#  ifndef CURL_DISABLE_GOPHER
231
#  define CURL_DISABLE_GOPHER
232
#  endif
233
#  ifndef CURL_DISABLE_IMAP
234
#  define CURL_DISABLE_IMAP
235
#  endif
236
#  ifndef CURL_DISABLE_LDAP
237
#  define CURL_DISABLE_LDAP
238
#  endif
239
#  ifndef CURL_DISABLE_LDAPS
240
#  define CURL_DISABLE_LDAPS
241
#  endif
242
#  ifndef CURL_DISABLE_MQTT
243
#  define CURL_DISABLE_MQTT
244
#  endif
245
#  ifndef CURL_DISABLE_POP3
246
#  define CURL_DISABLE_POP3
247
#  endif
248
#  ifndef CURL_DISABLE_RTSP
249
#  define CURL_DISABLE_RTSP
250
#  endif
251
#  ifndef CURL_DISABLE_SMB
252
#  define CURL_DISABLE_SMB
253
#  endif
254
#  ifndef CURL_DISABLE_SMTP
255
#  define CURL_DISABLE_SMTP
256
#  endif
257
#  ifndef CURL_DISABLE_TELNET
258
#  define CURL_DISABLE_TELNET
259
#  endif
260
#  ifndef CURL_DISABLE_TFTP
261
#  define CURL_DISABLE_TFTP
262
#  endif
263
#endif
264
265
/*
266
 * When http is disabled rtsp is not supported.
267
 */
268
#if defined(CURL_DISABLE_HTTP) && !defined(CURL_DISABLE_RTSP)
269
#  define CURL_DISABLE_RTSP
270
#endif
271
272
/*
273
 * When HTTP is disabled, disable HTTP-only features
274
 */
275
#ifdef CURL_DISABLE_HTTP
276
#  define CURL_DISABLE_ALTSVC 1
277
#  define CURL_DISABLE_COOKIES 1
278
#  define CURL_DISABLE_BASIC_AUTH 1
279
#  define CURL_DISABLE_BEARER_AUTH 1
280
#  define CURL_DISABLE_AWS 1
281
#  define CURL_DISABLE_DOH 1
282
#  define CURL_DISABLE_FORM_API 1
283
#  define CURL_DISABLE_HEADERS_API 1
284
#  define CURL_DISABLE_HSTS 1
285
#  define CURL_DISABLE_HTTP_AUTH 1
286
#endif
287
288
/* ================================================================ */
289
/* No system header file shall be included in this file before this */
290
/* point.                                                           */
291
/* ================================================================ */
292
293
/*
294
 * OS/400 setup file includes some system headers.
295
 */
296
#ifdef __OS400__
297
#  include "setup-os400.h"
298
#endif
299
300
/*
301
 * VMS setup file includes some system headers.
302
 */
303
#ifdef __VMS
304
#  include "setup-vms.h"
305
#endif
306
307
/*
308
 * Windows setup file includes some system headers.
309
 */
310
#ifdef _WIN32
311
#  include "setup-win32.h"
312
#endif
313
314
#include <curl/system.h>
315
316
/* Helper macro to expand and concatenate two macros.
317
 * Direct macros concatenation does not work because macros
318
 * are not expanded before direct concatenation.
319
 */
320
#define CURL_CONC_MACROS_(A, B) A ## B
321
#define CURL_CONC_MACROS(A, B) CURL_CONC_MACROS_(A, B)
322
323
/* curl uses its own printf() function internally. It understands the GNU
324
 * format. Use this format, so that it matches the GNU format attribute we
325
 * use with the MinGW compiler, allowing it to verify them at compile-time.
326
 */
327
#ifdef __MINGW32__
328
#  undef CURL_FORMAT_CURL_OFF_T
329
#  undef CURL_FORMAT_CURL_OFF_TU
330
#  define CURL_FORMAT_CURL_OFF_T   "lld"
331
#  define CURL_FORMAT_CURL_OFF_TU  "llu"
332
#endif
333
334
/* based on logic in "curl/mprintf.h" */
335
#if (defined(__GNUC__) || defined(__clang__) ||                         \
336
  defined(__IAR_SYSTEMS_ICC__)) &&                                      \
337
  defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) &&         \
338
  !defined(CURL_NO_FMT_CHECKS)
339
#if defined(__MINGW32__) && !defined(__clang__)
340
#define CURL_PRINTF(fmt, arg) \
341
  __attribute__((format(gnu_printf, fmt, arg)))
342
#else
343
#define CURL_PRINTF(fmt, arg) \
344
  __attribute__((format(__printf__, fmt, arg)))
345
#endif
346
#else
347
#define CURL_PRINTF(fmt, arg)
348
#endif
349
350
/* Override default printf mask check rules in "curl/mprintf.h" */
351
#define CURL_TEMP_PRINTF CURL_PRINTF
352
353
/* Workaround for mainline llvm v16 and earlier missing a built-in macro
354
   expected by macOS SDK v14 / Xcode v15 (2023) and newer.
355
   gcc (as of v14) is also missing it. */
356
#if defined(__APPLE__) &&                                   \
357
  ((!defined(__apple_build_version__) &&                    \
358
    defined(__clang__) && __clang_major__ < 17) ||          \
359
   (defined(__GNUC__) && __GNUC__ <= 14)) &&                \
360
  defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) && \
361
  !defined(__ENVIRONMENT_OS_VERSION_MIN_REQUIRED__)
362
#define __ENVIRONMENT_OS_VERSION_MIN_REQUIRED__             \
363
  __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
364
#endif
365
366
/*
367
 * Use getaddrinfo to resolve the IPv4 address literal. If the current network
368
 * interface does not support IPv4, but supports IPv6, NAT64, and DNS64,
369
 * performing this task will result in a synthesized IPv6 address.
370
 */
371
#if defined(__APPLE__) && !defined(USE_ARES)
372
#  define USE_RESOLVE_ON_IPS 1
373
#  if TARGET_OS_MAC && !(defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE) && \
374
     defined(USE_IPV6)
375
#    define CURL_MACOS_CALL_COPYPROXIES 1
376
#  endif
377
#endif
378
379
#ifdef USE_ARES
380
#  ifndef CARES_NO_DEPRECATED
381
#  define CARES_NO_DEPRECATED  /* for ares_getsock() */
382
#  endif
383
#  if defined(CURL_STATICLIB) && !defined(CARES_STATICLIB) && defined(_WIN32)
384
#    define CARES_STATICLIB  /* define it before including ares.h */
385
#  endif
386
#endif
387
388
#ifdef USE_LWIPSOCK
389
#  include <lwip/init.h>
390
#  include <lwip/sockets.h>
391
#  include <lwip/netdb.h>
392
#endif
393
394
#ifdef macintosh
395
#  include <extra/stricmp.h>
396
#  include <extra/strdup.h>
397
#endif
398
399
#ifdef __AMIGA__
400
#  ifdef __amigaos4__
401
#    define __USE_INLINE__
402
     /* use our own resolver which uses runtime feature detection */
403
#    define CURLRES_AMIGA
404
     /* getaddrinfo() currently crashes bsdsocket.library, so disable */
405
#    undef HAVE_GETADDRINFO
406
#    if !(defined(__NEWLIB__) || \
407
          (defined(__CLIB2__) && defined(__THREAD_SAFE)))
408
       /* disable threaded resolver with clib2 - requires newlib or clib-ts */
409
#      undef USE_THREADS_POSIX
410
#    endif
411
#  endif
412
#  include <exec/types.h>
413
#  include <exec/execbase.h>
414
#  include <proto/exec.h>
415
#  include <proto/dos.h>
416
#  include <unistd.h>
417
#  if defined(HAVE_PROTO_BSDSOCKET_H) && \
418
    (!defined(__amigaos4__) || defined(USE_AMISSL))
419
     /* use bsdsocket.library directly, instead of libc networking functions */
420
#    define _SYS_MBUF_H /* m_len define clashes with curl */
421
#    include <proto/bsdsocket.h>
422
#    ifdef __amigaos4__
423
       int Curl_amiga_select(int nfds, fd_set *readfds, fd_set *writefds,
424
                             fd_set *errorfds, struct timeval *timeout);
425
#      define select(a, b, c, d, e) Curl_amiga_select(a, b, c, d, e)
426
#    else
427
#      define select(a, b, c, d, e) WaitSelect(a, b, c, d, e, 0)
428
#    endif
429
     /* must not use libc's fcntl() on bsdsocket.library sockfds! */
430
#    undef HAVE_FCNTL
431
#    undef HAVE_FCNTL_O_NONBLOCK
432
#  else
433
     /* use libc networking and hence close() and fnctl() */
434
#    undef HAVE_CLOSESOCKET_CAMEL
435
#    undef HAVE_IOCTLSOCKET_CAMEL
436
#  endif
437
/*
438
 * In clib2 arpa/inet.h warns that some prototypes may clash
439
 * with bsdsocket.library. This avoids the definition of those.
440
 */
441
#  define __NO_NET_API
442
#endif
443
444
/* Whether to use eventfd() */
445
#if defined(HAVE_EVENTFD) && defined(HAVE_SYS_EVENTFD_H)
446
#define USE_EVENTFD
447
#endif
448
449
#include <stdio.h>
450
#include <assert.h>
451
452
#ifdef __TANDEM /* for ns*-tandem-nsk systems */
453
#  if ! defined __LP64
454
#    include <floss.h> /* FLOSS is only used for 32-bit builds. */
455
#  endif
456
#endif
457
458
#ifndef STDC_HEADERS /* no standard C headers! */
459
#include <curl/stdcheaders.h>
460
#endif
461
462
#if defined(HAVE_STDINT_H) || defined(USE_WOLFSSL)
463
#include <stdint.h>
464
#endif
465
466
#include <limits.h>
467
468
#ifdef _WIN32
469
#  ifdef HAVE_IO_H
470
#  include <io.h>
471
#  endif
472
#  include <sys/types.h>
473
#  include <sys/stat.h>
474
   /* Large file (>2Gb) support using Win32 functions. */
475
#  undef  lseek
476
#  define lseek(fdes, offset, whence)  _lseeki64(fdes, offset, whence)
477
#  undef  fstat
478
#  define fstat(fdes, stp)             _fstati64(fdes, stp)
479
#  define struct_stat                  struct _stati64
480
#  define LSEEK_ERROR                  (__int64)-1
481
#elif defined(__DJGPP__)
482
   /* Requires DJGPP 2.04 */
483
#  include <unistd.h>
484
#  undef  lseek
485
#  define lseek(fdes, offset, whence)  llseek(fdes, offset, whence)
486
#  define LSEEK_ERROR                  (offset_t)-1
487
#endif
488
489
#ifndef struct_stat
490
7.85k
#define struct_stat struct stat
491
#endif
492
493
#ifndef LSEEK_ERROR
494
#define LSEEK_ERROR (off_t)-1
495
#endif
496
497
#ifndef SIZEOF_TIME_T
498
/* assume default size of time_t to be 32 bits */
499
#define SIZEOF_TIME_T 4
500
#endif
501
502
#ifndef SIZEOF_CURL_SOCKET_T
503
/* configure and cmake check and set the define */
504
#  ifdef _WIN64
505
#    define SIZEOF_CURL_SOCKET_T 8
506
#  else
507
/* default guess */
508
#    define SIZEOF_CURL_SOCKET_T 4
509
#  endif
510
#endif
511
512
#if SIZEOF_CURL_SOCKET_T < 8
513
#ifdef _WIN32
514
#  define FMT_SOCKET_T "u"
515
#else
516
#  define FMT_SOCKET_T "d"
517
#endif
518
#elif defined(_WIN32)
519
#  define FMT_SOCKET_T "zu"
520
#else
521
#  define FMT_SOCKET_T "qd"
522
#endif
523
524
/*
525
 * Default sizeof(off_t) in case it has not been defined in config file.
526
 */
527
528
#ifndef SIZEOF_OFF_T
529
#  if defined(__VMS) && !defined(__VAX)
530
#    ifdef _LARGEFILE
531
#      define SIZEOF_OFF_T 8
532
#    endif
533
#  elif defined(__OS400__) && defined(__ILEC400__)
534
#    ifdef _LARGE_FILES
535
#      define SIZEOF_OFF_T 8
536
#    endif
537
#  elif defined(__MVS__) && defined(__IBMC__)
538
#    if defined(_LP64) || defined(_LARGE_FILES)
539
#      define SIZEOF_OFF_T 8
540
#    endif
541
#  elif defined(__370__) && defined(__IBMC__)
542
#    if defined(_LP64) || defined(_LARGE_FILES)
543
#      define SIZEOF_OFF_T 8
544
#    endif
545
#  endif
546
#  ifndef SIZEOF_OFF_T
547
#  define SIZEOF_OFF_T 4
548
#  endif
549
#endif
550
551
#if (SIZEOF_CURL_OFF_T < 8)
552
#error "too small curl_off_t"
553
#else
554
   /* assume SIZEOF_CURL_OFF_T == 8 */
555
11.4k
#  define CURL_OFF_T_MAX 0x7FFFFFFFFFFFFFFF
556
#endif
557
0
#define CURL_OFF_T_MIN (-CURL_OFF_T_MAX - 1)
558
559
0
#define FMT_OFF_T  CURL_FORMAT_CURL_OFF_T
560
#define FMT_OFF_TU CURL_FORMAT_CURL_OFF_TU
561
562
#if (SIZEOF_TIME_T == 4)
563
#  ifdef HAVE_TIME_T_UNSIGNED
564
#  define TIME_T_MAX UINT_MAX
565
#  define TIME_T_MIN 0
566
#  else
567
#  define TIME_T_MAX INT_MAX
568
#  define TIME_T_MIN INT_MIN
569
#  endif
570
#else
571
#  ifdef HAVE_TIME_T_UNSIGNED
572
#  define TIME_T_MAX 0xFFFFFFFFFFFFFFFF
573
#  define TIME_T_MIN 0
574
#  else
575
281
#  define TIME_T_MAX 0x7FFFFFFFFFFFFFFF
576
#  define TIME_T_MIN (-TIME_T_MAX - 1)
577
#  endif
578
#endif
579
580
#ifndef SIZE_MAX
581
/* some limits.h headers have this defined, some do not */
582
#if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
583
#define SIZE_MAX 18446744073709551615U
584
#else
585
#define SIZE_MAX 4294967295U
586
#endif
587
#endif
588
589
#ifndef SSIZE_MAX
590
/* some limits.h headers have this defined, some do not */
591
#if defined(SIZEOF_SIZE_T) && (SIZEOF_SIZE_T > 4)
592
#define SSIZE_MAX 9223372036854775807
593
#else
594
#define SSIZE_MAX 2147483647
595
#endif
596
#endif
597
598
#if SIZEOF_LONG > SIZEOF_SIZE_T
599
#error "unexpected: 'long' is larger than 'size_t'"
600
#endif
601
602
/*
603
 * Arg 2 type for gethostname in case it has not been defined in config file.
604
 */
605
#ifndef GETHOSTNAME_TYPE_ARG2
606
#  ifdef USE_WINSOCK
607
#    define GETHOSTNAME_TYPE_ARG2 int
608
#  else
609
#    define GETHOSTNAME_TYPE_ARG2 size_t
610
#  endif
611
#endif
612
613
/* Below we define some functions. They should
614
   4. set the SIGALRM signal timeout
615
   5. set dir/file naming defines
616
 */
617
618
#ifdef _WIN32
619
620
#  define DIR_CHAR      "\\"
621
622
#else /* _WIN32 */
623
624
#  ifdef MSDOS  /* Watt-32 */
625
626
#    include <sys/ioctl.h>
627
#    define select(n, r, w, x, t)  select_s(n, r, w, x, t)
628
#    define ioctl(x, y, z)         ioctlsocket(x, y, (char *)(z))
629
#    include <tcp.h>
630
#    undef word
631
#    undef byte
632
633
#  endif /* MSDOS */
634
635
#  ifdef __minix
636
     /* Minix 3 versions up to at least 3.1.3 are missing these prototypes */
637
     extern struct tm *gmtime_r(const time_t * const timep, struct tm *tmp);
638
#  endif
639
640
0
#  define DIR_CHAR      "/"
641
642
#endif /* _WIN32 */
643
644
/* ---------------------------------------------------------------- */
645
/*             resolver specialty compile-time defines              */
646
/*         CURLRES_* defines to use in the host*.c sources          */
647
/* ---------------------------------------------------------------- */
648
649
/*
650
 * Mutually exclusive CURLRES_* definitions.
651
 */
652
#if defined(USE_IPV6) && defined(HAVE_GETADDRINFO)
653
#  define CURLRES_IPV6
654
#elif defined(USE_IPV6) && (defined(_WIN32) || defined(__CYGWIN__))
655
/* assume on Windows that IPv6 without getaddrinfo is a broken build */
656
#  error "Unexpected build: IPv6 is enabled but getaddrinfo was not found."
657
#else
658
#  define CURLRES_IPV4
659
#endif
660
661
#if defined(USE_THREADS_POSIX) || defined(USE_THREADS_WIN32)
662
#  define CURLRES_ASYNCH
663
#  define CURLRES_THREADED
664
#elif defined(USE_ARES)
665
#  define CURLRES_ASYNCH
666
#  define CURLRES_ARES
667
/* now undef the stock libc functions just to avoid them being used */
668
#  undef HAVE_GETADDRINFO
669
#  undef HAVE_FREEADDRINFO
670
#else
671
#  define CURLRES_SYNCH
672
#endif
673
674
/* ---------------------------------------------------------------- */
675
676
#if defined(HAVE_LIBIDN2) && defined(HAVE_IDN2_H) && \
677
  !defined(USE_WIN32_IDN) && !defined(USE_APPLE_IDN)
678
/* The lib and header are present */
679
#define USE_LIBIDN2
680
#endif
681
682
#if defined(USE_LIBIDN2) && (defined(USE_WIN32_IDN) || defined(USE_APPLE_IDN))
683
#error "libidn2 cannot be enabled with WinIDN or AppleIDN, choose one."
684
#endif
685
686
#if defined(USE_GNUTLS) || defined(USE_OPENSSL) || defined(USE_MBEDTLS) || \
687
  defined(USE_WOLFSSL) || defined(USE_SCHANNEL) || \
688
  defined(USE_RUSTLS)
689
#define USE_SSL    /* SSL support has been enabled */
690
#endif
691
692
#if defined(USE_OPENSSL) && defined(USE_WOLFSSL)
693
#  include <wolfssl/version.h>
694
#  if LIBWOLFSSL_VERSION_HEX >= 0x05007006
695
#    ifndef OPENSSL_COEXIST
696
#    define OPENSSL_COEXIST
697
#    endif
698
#  else
699
#    error "OpenSSL can only coexist with wolfSSL v5.7.6 or upper"
700
#  endif
701
#endif
702
703
#if defined(USE_WOLFSSL) && defined(USE_GNUTLS)
704
/* Avoid defining unprefixed wolfSSL SHA macros colliding with nettle ones */
705
#define NO_OLD_WC_NAMES
706
#endif
707
708
/* Single point where USE_SPNEGO definition might be defined */
709
#if !defined(CURL_DISABLE_NEGOTIATE_AUTH) && \
710
    (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI))
711
#define USE_SPNEGO
712
#endif
713
714
/* Single point where USE_KERBEROS5 definition might be defined */
715
#if !defined(CURL_DISABLE_KERBEROS_AUTH) && \
716
    (defined(HAVE_GSSAPI) || defined(USE_WINDOWS_SSPI))
717
#define USE_KERBEROS5
718
#endif
719
720
/* Single point where USE_NTLM definition might be defined */
721
#ifndef CURL_DISABLE_NTLM
722
#  if (defined(USE_OPENSSL) && defined(HAVE_DES_ECB_ENCRYPT)) ||        \
723
  defined(USE_GNUTLS) ||                                                \
724
  (defined(USE_MBEDTLS) && defined(HAVE_MBEDTLS_DES_CRYPT_ECB)) ||      \
725
  defined(USE_OS400CRYPTO) || defined(USE_WIN32_CRYPTO) ||              \
726
  (defined(USE_WOLFSSL) && defined(HAVE_WOLFSSL_DES_ECB_ENCRYPT))
727
#    define USE_CURL_NTLM_CORE
728
#  endif
729
#  if defined(USE_CURL_NTLM_CORE) || defined(USE_WINDOWS_SSPI)
730
#    define USE_NTLM
731
#  endif
732
#endif
733
734
#if defined(USE_LIBSSH2) || defined(USE_LIBSSH)
735
#define USE_SSH
736
#endif
737
738
/*
739
 * Provide a mechanism to silence picky compilers, such as gcc 4.6+.
740
 * Parameters should of course normally not be unused, but for example when
741
 * we have multiple implementations of the same interface it may happen.
742
 */
743
#if defined(__GNUC__) && ((__GNUC__ >= 3) || \
744
  ((__GNUC__ == 2) && defined(__GNUC_MINOR__) && (__GNUC_MINOR__ >= 7)))
745
#  define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
746
#elif defined(__IAR_SYSTEMS_ICC__) && (__VER__ >= 9040001)
747
#  define WARN_UNUSED_RESULT __attribute__((warn_unused_result))
748
#else
749
#  define WARN_UNUSED_RESULT
750
#endif
751
752
/* noreturn attribute */
753
754
#ifndef CURL_NORETURN
755
#if (defined(__GNUC__) && (__GNUC__ >= 3)) || defined(__clang__) || \
756
  defined(__IAR_SYSTEMS_ICC__)
757
#  define CURL_NORETURN  __attribute__((__noreturn__))
758
#elif defined(_MSC_VER)
759
#  define CURL_NORETURN  __declspec(noreturn)
760
#else
761
#  define CURL_NORETURN
762
#endif
763
#endif
764
765
/* fallthrough attribute */
766
767
#ifndef FALLTHROUGH
768
#if (defined(__GNUC__) && __GNUC__ >= 7) || \
769
    (defined(__clang__) && __clang_major__ >= 10)
770
412
#  define FALLTHROUGH()  __attribute__((fallthrough))
771
#else
772
#  define FALLTHROUGH()  do {} while (0)
773
#endif
774
#endif
775
776
/*
777
 * Include macros and defines that should only be processed once.
778
 */
779
#ifndef HEADER_CURL_SETUP_ONCE_H
780
#include "curl_setup_once.h"
781
#endif
782
783
/*
784
 * Definition of our NOP statement Object-like macro
785
 */
786
#ifndef Curl_nop_stmt
787
0
#define Curl_nop_stmt do { } while(0)
788
#endif
789
790
/*
791
 * Ensure that Winsock and lwIP TCP/IP stacks are not mixed.
792
 */
793
#if defined(__LWIP_OPT_H__) || defined(LWIP_HDR_OPT_H)
794
#  if defined(SOCKET) || defined(USE_WINSOCK)
795
#    error "Winsock and lwIP TCP/IP stack definitions shall not coexist!"
796
#  endif
797
#endif
798
799
/*
800
 * shutdown() flags for systems that do not define them
801
 */
802
#ifndef SHUT_RD
803
#define SHUT_RD 0x00
804
#endif
805
806
#ifndef SHUT_WR
807
#define SHUT_WR 0x01
808
#endif
809
810
#ifndef SHUT_RDWR
811
#define SHUT_RDWR 0x02
812
#endif
813
814
/* Define S_ISREG if not defined by system headers, e.g. MSVC */
815
#if !defined(S_ISREG) && defined(S_IFMT) && defined(S_IFREG)
816
#define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
817
#endif
818
819
/* Define S_ISDIR if not defined by system headers, e.g. MSVC */
820
#if !defined(S_ISDIR) && defined(S_IFMT) && defined(S_IFDIR)
821
#define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
822
#endif
823
824
/* For MSVC (all versions as of VS2022) */
825
#ifndef STDIN_FILENO
826
#define STDIN_FILENO  fileno(stdin)
827
#endif
828
#ifndef STDOUT_FILENO
829
#define STDOUT_FILENO  fileno(stdout)
830
#endif
831
#ifndef STDERR_FILENO
832
#define STDERR_FILENO  fileno(stderr)
833
#endif
834
835
/* Since O_BINARY is used in bitmasks, setting it to zero makes it usable in
836
   source code but yet it does not ruin anything */
837
#ifdef O_BINARY
838
#define CURL_O_BINARY O_BINARY
839
#else
840
0
#define CURL_O_BINARY 0
841
#endif
842
843
/* In Windows the default file mode is text but an application can override it.
844
Therefore we specify it explicitly. https://github.com/curl/curl/pull/258
845
*/
846
#if defined(_WIN32) || defined(MSDOS)
847
#define FOPEN_READTEXT "rt"
848
#define FOPEN_WRITETEXT "wt"
849
#define FOPEN_APPENDTEXT "at"
850
#elif defined(__CYGWIN__)
851
/* Cygwin has specific behavior we need to address when _WIN32 is not defined.
852
https://cygwin.com/cygwin-ug-net/using-textbinary.html
853
For write we want our output to have line endings of LF and be compatible with
854
other Cygwin utilities. For read we want to handle input that may have line
855
endings either CRLF or LF so 't' is appropriate.
856
*/
857
#define FOPEN_READTEXT "rt"
858
#define FOPEN_WRITETEXT "w"
859
#define FOPEN_APPENDTEXT "a"
860
#else
861
#define FOPEN_READTEXT "r"
862
0
#define FOPEN_WRITETEXT "w"
863
#define FOPEN_APPENDTEXT "a"
864
#endif
865
866
/* for systems that do not detect this in configure */
867
#ifndef CURL_SA_FAMILY_T
868
#  ifdef _WIN32
869
#    define CURL_SA_FAMILY_T ADDRESS_FAMILY
870
#  elif defined(HAVE_SA_FAMILY_T)
871
0
#    define CURL_SA_FAMILY_T sa_family_t
872
#  elif defined(__AMIGA__)
873
#    define CURL_SA_FAMILY_T unsigned char
874
#  else
875
/* use a sensible default */
876
#    define CURL_SA_FAMILY_T unsigned short
877
#  endif
878
#endif
879
880
/* Some convenience macros to get the larger/smaller value out of two given.
881
   We prefix with CURL to prevent name collisions. */
882
0
#define CURLMAX(x, y) ((x) > (y) ? (x) : (y))
883
66
#define CURLMIN(x, y) ((x) < (y) ? (x) : (y))
884
885
/* A convenience macro to provide both the string literal and the length of
886
   the string literal in one go, useful for functions that take "string,len"
887
   as their argument */
888
1.87k
#define STRCONST(x) x, sizeof(x) - 1
889
890
335k
#define CURL_ARRAYSIZE(A) (sizeof(A) / sizeof((A)[0]))
891
892
/* Buffer size for error messages retrieved via
893
   curlx_strerror() and Curl_sspi_strerror() */
894
#define STRERROR_LEN 256
895
896
#ifndef CURL_DID_MEMORY_FUNC_TYPEDEFS /* only if not already done */
897
/*
898
 * The following memory function replacement typedef's are COPIED from
899
 * curl/curl.h and MUST match the originals. We copy them to avoid having to
900
 * include curl/curl.h here. We avoid that include since it includes stdio.h
901
 * and other headers that may get messed up with defines done here.
902
 */
903
typedef void *(*curl_malloc_callback)(size_t size);
904
typedef void (*curl_free_callback)(void *ptr);
905
typedef void *(*curl_realloc_callback)(void *ptr, size_t size);
906
typedef char *(*curl_strdup_callback)(const char *str);
907
typedef void *(*curl_calloc_callback)(size_t nmemb, size_t size);
908
#define CURL_DID_MEMORY_FUNC_TYPEDEFS
909
#endif
910
911
extern curl_malloc_callback Curl_cmalloc;
912
extern curl_free_callback Curl_cfree;
913
extern curl_realloc_callback Curl_crealloc;
914
extern curl_strdup_callback Curl_cstrdup;
915
extern curl_calloc_callback Curl_ccalloc;
916
917
/*
918
 * Curl_safefree defined as a macro to allow MemoryTracking feature
919
 * to log free() calls at same location where Curl_safefree is used.
920
 * This macro also assigns NULL to given pointer when free'd.
921
 */
922
#define Curl_safefree(ptr) \
923
811k
  do { curlx_free(ptr); (ptr) = NULL;} while(0)
924
925
#include <curl/curl.h> /* for CURL_EXTERN, mprintf.h */
926
927
#ifdef CURLDEBUG
928
#ifdef __clang__
929
#  define ALLOC_FUNC         __attribute__((__malloc__))
930
#  if __clang_major__ >= 4
931
#  define ALLOC_SIZE(s)      __attribute__((__alloc_size__(s)))
932
#  define ALLOC_SIZE2(n, s)  __attribute__((__alloc_size__(n, s)))
933
#  else
934
#  define ALLOC_SIZE(s)
935
#  define ALLOC_SIZE2(n, s)
936
#  endif
937
#elif defined(__GNUC__) && __GNUC__ >= 3
938
#  define ALLOC_FUNC         __attribute__((__malloc__))
939
#  define ALLOC_SIZE(s)      __attribute__((__alloc_size__(s)))
940
#  define ALLOC_SIZE2(n, s)  __attribute__((__alloc_size__(n, s)))
941
#elif defined(_MSC_VER)
942
#  define ALLOC_FUNC         __declspec(restrict)
943
#  define ALLOC_SIZE(s)
944
#  define ALLOC_SIZE2(n, s)
945
#else
946
#  define ALLOC_FUNC
947
#  define ALLOC_SIZE(s)
948
#  define ALLOC_SIZE2(n, s)
949
#endif
950
951
extern FILE *curl_dbg_logfile;
952
953
/* memory functions */
954
CURL_EXTERN void curl_dbg_free(void *ptr, int line, const char *source);
955
CURL_EXTERN ALLOC_FUNC ALLOC_SIZE(1)
956
  void *curl_dbg_malloc(size_t size, int line, const char *source);
957
CURL_EXTERN ALLOC_FUNC ALLOC_SIZE2(1, 2)
958
  void *curl_dbg_calloc(size_t n, size_t size, int line, const char *source);
959
CURL_EXTERN ALLOC_SIZE(2)
960
  void *curl_dbg_realloc(void *ptr, size_t size, int line, const char *source);
961
CURL_EXTERN ALLOC_FUNC
962
  char *curl_dbg_strdup(const char *str, int line, const char *src);
963
#if defined(_WIN32) && defined(UNICODE)
964
CURL_EXTERN ALLOC_FUNC
965
  wchar_t *curl_dbg_wcsdup(const wchar_t *str, int line, const char *source);
966
#endif
967
968
CURL_EXTERN void curl_dbg_memdebug(const char *logname);
969
CURL_EXTERN void curl_dbg_memlimit(long limit);
970
CURL_EXTERN void curl_dbg_log(const char *format, ...) CURL_PRINTF(1, 2);
971
972
/* file descriptor manipulators */
973
CURL_EXTERN curl_socket_t curl_dbg_socket(int domain, int type, int protocol,
974
                                          int line, const char *source);
975
CURL_EXTERN void curl_dbg_mark_sclose(curl_socket_t sockfd,
976
                                      int line, const char *source);
977
CURL_EXTERN int curl_dbg_sclose(curl_socket_t sockfd,
978
                                int line, const char *source);
979
CURL_EXTERN curl_socket_t curl_dbg_accept(curl_socket_t s, void *a, void *alen,
980
                                          int line, const char *source);
981
#ifdef HAVE_ACCEPT4
982
CURL_EXTERN curl_socket_t curl_dbg_accept4(curl_socket_t s, void *saddr,
983
                                           void *saddrlen, int flags,
984
                                           int line, const char *source);
985
#endif
986
#ifdef HAVE_SOCKETPAIR
987
CURL_EXTERN int curl_dbg_socketpair(int domain, int type, int protocol,
988
                                    curl_socket_t socket_vector[2],
989
                                    int line, const char *source);
990
#endif
991
992
/* send/receive sockets */
993
CURL_EXTERN SEND_TYPE_RETV curl_dbg_send(SEND_TYPE_ARG1 sockfd,
994
                                         SEND_QUAL_ARG2 SEND_TYPE_ARG2 buf,
995
                                         SEND_TYPE_ARG3 len,
996
                                         SEND_TYPE_ARG4 flags, int line,
997
                                         const char *source);
998
CURL_EXTERN RECV_TYPE_RETV curl_dbg_recv(RECV_TYPE_ARG1 sockfd,
999
                                         RECV_TYPE_ARG2 buf,
1000
                                         RECV_TYPE_ARG3 len,
1001
                                         RECV_TYPE_ARG4 flags, int line,
1002
                                         const char *source);
1003
1004
/* FILE functions */
1005
CURL_EXTERN int curl_dbg_fclose(FILE *file, int line, const char *source);
1006
CURL_EXTERN ALLOC_FUNC
1007
  FILE *curl_dbg_fopen(const char *file, const char *mode,
1008
                       int line, const char *source);
1009
CURL_EXTERN ALLOC_FUNC
1010
  FILE *curl_dbg_freopen(const char *file, const char *mode, FILE *fh,
1011
                         int line, const char *source);
1012
CURL_EXTERN ALLOC_FUNC
1013
  FILE *curl_dbg_fdopen(int filedes, const char *mode,
1014
                        int line, const char *source);
1015
1016
0
#define sclose(sockfd) curl_dbg_sclose(sockfd, __LINE__, __FILE__)
1017
#define fake_sclose(sockfd) curl_dbg_mark_sclose(sockfd, __LINE__, __FILE__)
1018
1019
#define CURL_GETADDRINFO(host, serv, hint, res) \
1020
0
  curl_dbg_getaddrinfo(host, serv, hint, res, __LINE__, __FILE__)
1021
#define CURL_FREEADDRINFO(data) \
1022
0
  curl_dbg_freeaddrinfo(data, __LINE__, __FILE__)
1023
#define CURL_SOCKET(domain, type, protocol) \
1024
0
  curl_dbg_socket((int)domain, type, protocol, __LINE__, __FILE__)
1025
#ifdef HAVE_SOCKETPAIR
1026
#define CURL_SOCKETPAIR(domain, type, protocol, socket_vector) \
1027
  curl_dbg_socketpair((int)domain, type, protocol, socket_vector, \
1028
                      __LINE__, __FILE__)
1029
#endif
1030
#define CURL_ACCEPT(sock, addr, len) \
1031
  curl_dbg_accept(sock, addr, len, __LINE__, __FILE__)
1032
#ifdef HAVE_ACCEPT4
1033
#define CURL_ACCEPT4(sock, addr, len, flags) \
1034
0
  curl_dbg_accept4(sock, addr, len, flags, __LINE__, __FILE__)
1035
#endif
1036
#define CURL_SEND(a, b, c, d) curl_dbg_send(a, b, c, d, __LINE__, __FILE__)
1037
#define CURL_RECV(a, b, c, d) curl_dbg_recv(a, b, c, d, __LINE__, __FILE__)
1038
1039
#else /* !CURLDEBUG */
1040
1041
#define sclose(x) CURL_SCLOSE(x)
1042
#define fake_sclose(x) Curl_nop_stmt
1043
1044
#define CURL_GETADDRINFO getaddrinfo
1045
#define CURL_FREEADDRINFO freeaddrinfo
1046
#define CURL_SOCKET socket
1047
#ifdef HAVE_SOCKETPAIR
1048
#define CURL_SOCKETPAIR socketpair
1049
#endif
1050
#define CURL_ACCEPT accept
1051
#ifdef HAVE_ACCEPT4
1052
#define CURL_ACCEPT4 accept4
1053
#endif
1054
#define CURL_SEND send
1055
#define CURL_RECV recv
1056
1057
#endif /* CURLDEBUG */
1058
1059
/* Allocator macros */
1060
1061
#ifdef CURLDEBUG
1062
1063
40.9k
#define curlx_strdup(ptr)         curl_dbg_strdup(ptr, __LINE__, __FILE__)
1064
26.5k
#define curlx_malloc(size)        curl_dbg_malloc(size, __LINE__, __FILE__)
1065
#define curlx_calloc(nbelem,size) \
1066
17.5k
                              curl_dbg_calloc(nbelem, size, __LINE__, __FILE__)
1067
#define curlx_realloc(ptr,size)   \
1068
4.16k
                              curl_dbg_realloc(ptr, size, __LINE__, __FILE__)
1069
890k
#define curlx_free(ptr)           curl_dbg_free(ptr, __LINE__, __FILE__)
1070
1071
#ifdef _WIN32
1072
#ifdef UNICODE
1073
#define curlx_tcsdup(ptr)         curl_dbg_wcsdup(ptr, __LINE__, __FILE__)
1074
#else
1075
#define curlx_tcsdup(ptr)         curlx_strdup(ptr)
1076
#endif
1077
#endif /* _WIN32 */
1078
1079
#else /* !CURLDEBUG */
1080
1081
#ifdef BUILDING_LIBCURL
1082
#define curlx_strdup(ptr)         Curl_cstrdup(ptr)
1083
#define curlx_malloc(size)        Curl_cmalloc(size)
1084
#define curlx_calloc(nbelem,size) Curl_ccalloc(nbelem, size)
1085
#define curlx_realloc(ptr,size)   Curl_crealloc(ptr, size)
1086
#define curlx_free(ptr)           Curl_cfree(ptr)
1087
#else /* !BUILDING_LIBCURL */
1088
#ifdef _WIN32
1089
#define curlx_strdup(ptr)         _strdup(ptr)
1090
#else
1091
#define curlx_strdup(ptr)         strdup(ptr)
1092
#endif
1093
#define curlx_malloc(size)        malloc(size)
1094
#define curlx_calloc(nbelem,size) calloc(nbelem, size)
1095
#define curlx_realloc(ptr,size)   realloc(ptr, size)
1096
#define curlx_free(ptr)           free(ptr)
1097
#endif /* BUILDING_LIBCURL */
1098
1099
#ifdef _WIN32
1100
#ifdef UNICODE
1101
#define curlx_tcsdup(ptr)         Curl_wcsdup(ptr)
1102
#else
1103
#define curlx_tcsdup(ptr)         curlx_strdup(ptr)
1104
#endif
1105
#endif /* _WIN32 */
1106
1107
#endif /* CURLDEBUG */
1108
1109
/* Some versions of the Android NDK is missing the declaration */
1110
#if defined(HAVE_GETPWUID_R) && \
1111
  defined(__ANDROID_API__) && (__ANDROID_API__ < 21)
1112
struct passwd;
1113
int getpwuid_r(uid_t uid, struct passwd *pwd, char *buf,
1114
               size_t buflen, struct passwd **result);
1115
#endif
1116
1117
#ifdef UNITTESTS
1118
#define UNITTEST
1119
#else
1120
#define UNITTEST static
1121
#endif
1122
1123
#ifdef USE_NGHTTP2
1124
#define USE_HTTP2
1125
#endif
1126
1127
#if (defined(USE_NGTCP2) && defined(USE_NGHTTP3)) || \
1128
    (defined(USE_OPENSSL_QUIC) && defined(USE_NGHTTP3)) || \
1129
    defined(USE_QUICHE)
1130
1131
#ifdef CURL_WITH_MULTI_SSL
1132
#error "MultiSSL combined with QUIC is not supported"
1133
#endif
1134
1135
#define USE_HTTP3
1136
#endif
1137
1138
/* WebAssembly builds have TCP_NODELAY, but runtime support is missing. */
1139
#ifndef __EMSCRIPTEN__
1140
#define CURL_TCP_NODELAY_SUPPORTED
1141
#endif
1142
1143
/* Certain Windows implementations are not aligned with what curl expects,
1144
   so always use the local one on this platform. E.g. the mingw-w64
1145
   implementation can return wrong results for non-ASCII inputs. */
1146
#if defined(HAVE_BASENAME) && defined(_WIN32)
1147
#undef HAVE_BASENAME
1148
#endif
1149
1150
#if defined(USE_UNIX_SOCKETS) && defined(_WIN32)
1151
#  ifndef UNIX_PATH_MAX
1152
     /* Replicating logic present in afunix.h
1153
        (distributed with newer Windows 10 SDK versions only) */
1154
#    define UNIX_PATH_MAX 108
1155
     /* !checksrc! disable TYPEDEFSTRUCT 1 */
1156
     typedef struct sockaddr_un {
1157
       CURL_SA_FAMILY_T sun_family;
1158
       char sun_path[UNIX_PATH_MAX];
1159
     } SOCKADDR_UN, *PSOCKADDR_UN;
1160
#    define WIN32_SOCKADDR_UN
1161
#  endif
1162
#endif
1163
1164
#ifdef USE_OPENSSL
1165
/* OpenSSLv3 marks DES, MD5 and ENGINE functions deprecated but we have no
1166
   replacements (yet) so tell the compiler to not warn for them. */
1167
#  define OPENSSL_SUPPRESS_DEPRECATED
1168
#  ifdef _WIN32
1169
/* Silence LibreSSL warnings about wincrypt.h collision. Works in 3.8.2+ */
1170
#    ifndef LIBRESSL_DISABLE_OVERRIDE_WINCRYPT_DEFINES_WARNING
1171
#    define LIBRESSL_DISABLE_OVERRIDE_WINCRYPT_DEFINES_WARNING
1172
#    endif
1173
#  endif
1174
#endif
1175
1176
#ifdef CURL_INLINE
1177
/* 'CURL_INLINE' defined, use as-is */
1178
#elif defined(inline)
1179
#  define CURL_INLINE inline /* 'inline' defined, assumed correct */
1180
#elif defined(__cplusplus)
1181
/* The code is compiled with C++ compiler.
1182
   C++ always supports 'inline'. */
1183
#  define CURL_INLINE inline /* 'inline' keyword supported */
1184
#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901
1185
/* C99 (and later) supports 'inline' keyword */
1186
#  define CURL_INLINE inline /* 'inline' keyword supported */
1187
#elif defined(__GNUC__) && __GNUC__ >= 3
1188
/* GCC supports '__inline__' as an extension */
1189
#  define CURL_INLINE __inline__
1190
#elif defined(_MSC_VER)
1191
#  define CURL_INLINE __inline
1192
#else
1193
/* Probably 'inline' is not supported by compiler.
1194
   Define to the empty string to be on the safe side. */
1195
#  define CURL_INLINE /* empty */
1196
#endif
1197
1198
#endif /* HEADER_CURL_SETUP_H */