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