VirtualBox

source: vbox/trunk/src/libs/curl-7.87.0/lib/curl_setup_once.h@ 98326

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

curl-7.87.0: Applied and adjusted our curl changes to 7.83.1. bugref:10356

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