VirtualBox

source: vbox/trunk/src/libs/curl-8.4.0/lib/curl_setup_once.h@ 101930

Last change on this file since 101930 was 101409, checked in by vboxsync, 16 months ago

curl-8.4.0: Applied and adjusted our curl changes to 8.3.0. bugref:10533

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