Coverage Report

Created: 2025-11-11 06:17

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