VirtualBox

source: vbox/trunk/src/libs/curl-8.7.1/lib/curl_setup_once.h@ 105945

Last change on this file since 105945 was 104083, checked in by vboxsync, 8 months ago

curl-8.7.1: Applied and adjusted our curl changes to 8.4.0. bugref:10639

  • Property svn:eol-style set to native
File size: 11.4 KB
Line 
1#ifndef HEADER_CURL_SETUP_ONCE_H
2#define HEADER_CURL_SETUP_ONCE_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
28/*
29 * Inclusion of common header files.
30 */
31
32#ifdef VBOX
33# include <iprt/types.h>
34#endif
35#include <stdio.h>
36#include <stdlib.h>
37#include <string.h>
38#include <stdarg.h>
39#include <time.h>
40#include <errno.h>
41
42#ifdef HAVE_SYS_TYPES_H
43#include <sys/types.h>
44#endif
45
46#ifdef NEED_MALLOC_H
47#include <malloc.h>
48#endif
49
50#ifdef NEED_MEMORY_H
51#include <memory.h>
52#endif
53
54#ifdef HAVE_SYS_STAT_H
55#include <sys/stat.h>
56#endif
57
58#ifdef HAVE_SYS_TIME_H
59#include <sys/time.h>
60#endif
61
62#ifdef _WIN32
63#include <io.h>
64#include <fcntl.h>
65#endif
66
67#if defined(HAVE_STDBOOL_H) && defined(HAVE_BOOL_T)
68#include <stdbool.h>
69#endif
70
71#ifdef HAVE_UNISTD_H
72#include <unistd.h>
73#endif
74
75#ifdef USE_WOLFSSL
76#include <stdint.h>
77#endif
78
79#ifdef USE_SCHANNEL
80/* Must set this before <schannel.h> is included directly or indirectly by
81 another Windows header. */
82# define SCHANNEL_USE_BLACKLISTS 1
83#endif
84
85#ifdef __hpux
86# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
87# ifdef _APP32_64BIT_OFF_T
88# define OLD_APP32_64BIT_OFF_T _APP32_64BIT_OFF_T
89# undef _APP32_64BIT_OFF_T
90# else
91# undef OLD_APP32_64BIT_OFF_T
92# endif
93# endif
94#endif
95
96#ifdef HAVE_SYS_SOCKET_H
97#include <sys/socket.h>
98#endif
99
100#include "functypes.h"
101
102#ifdef __hpux
103# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
104# ifdef OLD_APP32_64BIT_OFF_T
105# define _APP32_64BIT_OFF_T OLD_APP32_64BIT_OFF_T
106# undef OLD_APP32_64BIT_OFF_T
107# endif
108# endif
109#endif
110
111/*
112 * Definition of timeval struct for platforms that don't have it.
113 */
114
115#ifndef HAVE_STRUCT_TIMEVAL
116struct timeval {
117 long tv_sec;
118 long tv_usec;
119};
120#endif
121
122
123/*
124 * If we have the MSG_NOSIGNAL define, make sure we use
125 * it as the fourth argument of function send()
126 */
127
128#ifdef HAVE_MSG_NOSIGNAL
129#define SEND_4TH_ARG MSG_NOSIGNAL
130#else
131#define SEND_4TH_ARG 0
132#endif
133
134
135#if defined(__minix)
136/* Minix doesn't support recv on TCP sockets */
137#define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \
138 (RECV_TYPE_ARG2)(y), \
139 (RECV_TYPE_ARG3)(z))
140
141#elif defined(HAVE_RECV)
142/*
143 * The definitions for the return type and arguments types
144 * of functions recv() and send() belong and come from the
145 * configuration file. Do not define them in any other place.
146 *
147 * HAVE_RECV is defined if you have a function named recv()
148 * which is used to read incoming data from sockets. If your
149 * function has another name then don't define HAVE_RECV.
150 *
151 * If HAVE_RECV is defined then RECV_TYPE_ARG1, RECV_TYPE_ARG2,
152 * RECV_TYPE_ARG3, RECV_TYPE_ARG4 and RECV_TYPE_RETV must also
153 * be defined.
154 *
155 * HAVE_SEND is defined if you have a function named send()
156 * which is used to write outgoing data on a connected socket.
157 * If yours has another name then don't define HAVE_SEND.
158 *
159 * If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_QUAL_ARG2,
160 * SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and
161 * SEND_TYPE_RETV must also be defined.
162 */
163
164#define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \
165 (RECV_TYPE_ARG2)(y), \
166 (RECV_TYPE_ARG3)(z), \
167 (RECV_TYPE_ARG4)(0))
168#else /* HAVE_RECV */
169#ifndef sread
170 /* */
171 Error Missing_definition_of_macro_sread
172 /* */
173#endif
174#endif /* HAVE_RECV */
175
176
177#if defined(__minix)
178/* Minix doesn't support send on TCP sockets */
179#define swrite(x,y,z) (ssize_t)write((SEND_TYPE_ARG1)(x), \
180 (SEND_TYPE_ARG2)(y), \
181 (SEND_TYPE_ARG3)(z))
182
183#elif defined(HAVE_SEND)
184#define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
185 (SEND_QUAL_ARG2 SEND_TYPE_ARG2)(y), \
186 (SEND_TYPE_ARG3)(z), \
187 (SEND_TYPE_ARG4)(SEND_4TH_ARG))
188#else /* HAVE_SEND */
189#ifndef swrite
190 /* */
191 Error Missing_definition_of_macro_swrite
192 /* */
193#endif
194#endif /* HAVE_SEND */
195
196
197/*
198 * Function-like macro definition used to close a socket.
199 */
200
201#if defined(HAVE_CLOSESOCKET)
202# define sclose(x) closesocket((x))
203#elif defined(HAVE_CLOSESOCKET_CAMEL)
204# define sclose(x) CloseSocket((x))
205#elif defined(HAVE_CLOSE_S)
206# define sclose(x) close_s((x))
207#elif defined(USE_LWIPSOCK)
208# define sclose(x) lwip_close((x))
209#else
210# define sclose(x) close((x))
211#endif
212
213/*
214 * Stack-independent version of fcntl() on sockets:
215 */
216#if defined(USE_LWIPSOCK)
217# define sfcntl lwip_fcntl
218#else
219# define sfcntl fcntl
220#endif
221
222/*
223 * 'bool' stuff compatible with HP-UX headers.
224 */
225
226#if defined(__hpux) && !defined(HAVE_BOOL_T)
227 typedef int bool;
228# define false 0
229# define true 1
230# define HAVE_BOOL_T
231#endif
232
233
234/*
235 * 'bool' exists on platforms with <stdbool.h>, i.e. C99 platforms.
236 * On non-C99 platforms there's no bool, so define an enum for that.
237 * On C99 platforms 'false' and 'true' also exist. Enum uses a
238 * global namespace though, so use bool_false and bool_true.
239 */
240
241#ifndef VBOX /* VirtualBox */
242#ifndef HAVE_BOOL_T
243 typedef enum {
244 bool_false = 0,
245 bool_true = 1
246 } bool;
247
248/*
249 * Use a define to let 'true' and 'false' use those enums. There
250 * are currently no use of true and false in libcurl proper, but
251 * there are some in the examples. This will cater for any later
252 * code happening to use true and false.
253 */
254# define false bool_false
255# define true bool_true
256# define HAVE_BOOL_T
257#endif
258#endif
259
260/* the type we use for storing a single boolean bit */
261#ifdef _MSC_VER
262typedef bool bit;
263#define BIT(x) bool x
264#else
265typedef unsigned int bit;
266#define BIT(x) bit x:1
267#endif
268
269/*
270 * Redefine TRUE and FALSE too, to catch current use. With this
271 * change, 'bool found = 1' will give a warning on MIPSPro, but
272 * 'bool found = TRUE' will not. Change tested on IRIX/MIPSPro,
273 * AIX 5.1/Xlc, Tru64 5.1/cc, w/make test too.
274 */
275
276#ifndef TRUE
277#define TRUE true
278#endif
279#ifndef FALSE
280#define FALSE false
281#endif
282
283#include "curl_ctype.h"
284
285
286/*
287 * Macro used to include code only in debug builds.
288 */
289
290#ifdef DEBUGBUILD
291#define DEBUGF(x) x
292#else
293#define DEBUGF(x) do { } while(0)
294#endif
295
296
297/*
298 * Macro used to include assertion code only in debug builds.
299 */
300
301#undef DEBUGASSERT
302#if defined(DEBUGBUILD)
303#define DEBUGASSERT(x) assert(x)
304#else
305#define DEBUGASSERT(x) do { } while(0)
306#endif
307
308
309/*
310 * Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno
311 * (or equivalent) on this platform to hide platform details to code using it.
312 */
313
314#ifdef USE_WINSOCK
315#define SOCKERRNO ((int)WSAGetLastError())
316#define SET_SOCKERRNO(x) (WSASetLastError((int)(x)))
317#else
318#define SOCKERRNO (errno)
319#define SET_SOCKERRNO(x) (errno = (x))
320#endif
321
322
323/*
324 * Portable error number symbolic names defined to Winsock error codes.
325 */
326
327#ifdef USE_WINSOCK
328#undef EBADF /* override definition in errno.h */
329#define EBADF WSAEBADF
330#undef EINTR /* override definition in errno.h */
331#define EINTR WSAEINTR
332#undef EINVAL /* override definition in errno.h */
333#define EINVAL WSAEINVAL
334#undef EWOULDBLOCK /* override definition in errno.h */
335#define EWOULDBLOCK WSAEWOULDBLOCK
336#undef EINPROGRESS /* override definition in errno.h */
337#define EINPROGRESS WSAEINPROGRESS
338#undef EALREADY /* override definition in errno.h */
339#define EALREADY WSAEALREADY
340#undef ENOTSOCK /* override definition in errno.h */
341#define ENOTSOCK WSAENOTSOCK
342#undef EDESTADDRREQ /* override definition in errno.h */
343#define EDESTADDRREQ WSAEDESTADDRREQ
344#undef EMSGSIZE /* override definition in errno.h */
345#define EMSGSIZE WSAEMSGSIZE
346#undef EPROTOTYPE /* override definition in errno.h */
347#define EPROTOTYPE WSAEPROTOTYPE
348#undef ENOPROTOOPT /* override definition in errno.h */
349#define ENOPROTOOPT WSAENOPROTOOPT
350#undef EPROTONOSUPPORT /* override definition in errno.h */
351#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
352#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
353#undef EOPNOTSUPP /* override definition in errno.h */
354#define EOPNOTSUPP WSAEOPNOTSUPP
355#define EPFNOSUPPORT WSAEPFNOSUPPORT
356#undef EAFNOSUPPORT /* override definition in errno.h */
357#define EAFNOSUPPORT WSAEAFNOSUPPORT
358#undef EADDRINUSE /* override definition in errno.h */
359#define EADDRINUSE WSAEADDRINUSE
360#undef EADDRNOTAVAIL /* override definition in errno.h */
361#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
362#undef ENETDOWN /* override definition in errno.h */
363#define ENETDOWN WSAENETDOWN
364#undef ENETUNREACH /* override definition in errno.h */
365#define ENETUNREACH WSAENETUNREACH
366#undef ENETRESET /* override definition in errno.h */
367#define ENETRESET WSAENETRESET
368#undef ECONNABORTED /* override definition in errno.h */
369#define ECONNABORTED WSAECONNABORTED
370#undef ECONNRESET /* override definition in errno.h */
371#define ECONNRESET WSAECONNRESET
372#undef ENOBUFS /* override definition in errno.h */
373#define ENOBUFS WSAENOBUFS
374#undef EISCONN /* override definition in errno.h */
375#define EISCONN WSAEISCONN
376#undef ENOTCONN /* override definition in errno.h */
377#define ENOTCONN WSAENOTCONN
378#define ESHUTDOWN WSAESHUTDOWN
379#define ETOOMANYREFS WSAETOOMANYREFS
380#undef ETIMEDOUT /* override definition in errno.h */
381#define ETIMEDOUT WSAETIMEDOUT
382#undef ECONNREFUSED /* override definition in errno.h */
383#define ECONNREFUSED WSAECONNREFUSED
384#undef ELOOP /* override definition in errno.h */
385#define ELOOP WSAELOOP
386#ifndef ENAMETOOLONG /* possible previous definition in errno.h */
387#define ENAMETOOLONG WSAENAMETOOLONG
388#endif
389#define EHOSTDOWN WSAEHOSTDOWN
390#undef EHOSTUNREACH /* override definition in errno.h */
391#define EHOSTUNREACH WSAEHOSTUNREACH
392#ifndef ENOTEMPTY /* possible previous definition in errno.h */
393#define ENOTEMPTY WSAENOTEMPTY
394#endif
395#define EPROCLIM WSAEPROCLIM
396#define EUSERS WSAEUSERS
397#define EDQUOT WSAEDQUOT
398#define ESTALE WSAESTALE
399#define EREMOTE WSAEREMOTE
400#endif
401
402/*
403 * Macro argv_item_t hides platform details to code using it.
404 */
405
406#ifdef __VMS
407#define argv_item_t __char_ptr32
408#elif defined(_UNICODE)
409#define argv_item_t wchar_t *
410#else
411#define argv_item_t char *
412#endif
413
414
415/*
416 * We use this ZERO_NULL to avoid picky compiler warnings,
417 * when assigning a NULL pointer to a function pointer var.
418 */
419
420#define ZERO_NULL 0
421
422
423#endif /* HEADER_CURL_SETUP_ONCE_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette