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