VirtualBox

source: vbox/trunk/src/libs/curl-8.0.1/lib/curl_setup_once.h@ 100347

Last change on this file since 100347 was 99344, checked in by vboxsync, 2 years ago

curl-8.0.1: Applied and adjusted our curl changes to 7.87.0 bugref:10417

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

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