VirtualBox

source: vbox/trunk/src/libs/curl-8.11.1/lib/curl_setup_once.h@ 108257

Last change on this file since 108257 was 108048, checked in by vboxsync, 3 months ago

curl-8.11.1: Applied and adjusted our curl changes to 8.7.1. jiraref:VBP-1535

  • 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, <[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#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 do not 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 does not 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 do not 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 do not 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#error "Missing definition of macro sread!"
171#endif
172#endif /* HAVE_RECV */
173
174
175#if defined(__minix)
176/* Minix does not 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#error "Missing definition of macro swrite!"
189#endif
190#endif /* HAVE_SEND */
191
192
193/*
194 * Function-like macro definition used to close a socket.
195 */
196
197#if defined(HAVE_CLOSESOCKET)
198# define sclose(x) closesocket((x))
199#elif defined(HAVE_CLOSESOCKET_CAMEL)
200# define sclose(x) CloseSocket((x))
201#elif defined(HAVE_CLOSE_S)
202# define sclose(x) close_s((x))
203#elif defined(USE_LWIPSOCK)
204# define sclose(x) lwip_close((x))
205#else
206# define sclose(x) close((x))
207#endif
208
209/*
210 * Stack-independent version of fcntl() on sockets:
211 */
212#if defined(USE_LWIPSOCK)
213# define sfcntl lwip_fcntl
214#else
215# define sfcntl fcntl
216#endif
217
218/*
219 * 'bool' stuff compatible with HP-UX headers.
220 */
221
222#if defined(__hpux) && !defined(HAVE_BOOL_T)
223 typedef int bool;
224# define false 0
225# define true 1
226# define HAVE_BOOL_T
227#endif
228
229
230/*
231 * 'bool' exists on platforms with <stdbool.h>, i.e. C99 platforms.
232 * On non-C99 platforms there is no bool, so define an enum for that.
233 * On C99 platforms 'false' and 'true' also exist. Enum uses a
234 * global namespace though, so use bool_false and bool_true.
235 */
236
237#ifndef VBOX /* VirtualBox */
238#ifndef HAVE_BOOL_T
239 typedef enum {
240 bool_false = 0,
241 bool_true = 1
242 } bool;
243
244/*
245 * Use a define to let 'true' and 'false' use those enums. There
246 * are currently no use of true and false in libcurl proper, but
247 * there are some in the examples. This will cater for any later
248 * code happening to use true and false.
249 */
250# define false bool_false
251# define true bool_true
252# define HAVE_BOOL_T
253#endif
254#endif
255
256/* the type we use for storing a single boolean bit */
257#ifdef _MSC_VER
258typedef bool bit;
259#define BIT(x) bool x
260#else
261typedef unsigned int bit;
262#define BIT(x) bit x:1
263#endif
264
265/*
266 * Redefine TRUE and FALSE too, to catch current use. With this
267 * change, 'bool found = 1' will give a warning on MIPSPro, but
268 * 'bool found = TRUE' will not. Change tested on IRIX/MIPSPro,
269 * AIX 5.1/Xlc, Tru64 5.1/cc, w/make test too.
270 */
271
272#ifndef TRUE
273#define TRUE true
274#endif
275#ifndef FALSE
276#define FALSE false
277#endif
278
279#include "curl_ctype.h"
280
281
282/*
283 * Macro used to include code only in debug builds.
284 */
285
286#ifdef DEBUGBUILD
287#define DEBUGF(x) x
288#else
289#define DEBUGF(x) do { } while(0)
290#endif
291
292
293/*
294 * Macro used to include assertion code only in debug builds.
295 */
296
297#undef DEBUGASSERT
298#if defined(DEBUGBUILD)
299#define DEBUGASSERT(x) assert(x)
300#else
301#define DEBUGASSERT(x) do { } while(0)
302#endif
303
304
305/*
306 * Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno
307 * (or equivalent) on this platform to hide platform details to code using it.
308 */
309
310#ifdef USE_WINSOCK
311#define SOCKERRNO ((int)WSAGetLastError())
312#define SET_SOCKERRNO(x) (WSASetLastError((int)(x)))
313#else
314#define SOCKERRNO (errno)
315#define SET_SOCKERRNO(x) (errno = (x))
316#endif
317
318
319/*
320 * Portable error number symbolic names defined to Winsock error codes.
321 */
322
323#ifdef USE_WINSOCK
324#undef EBADF /* override definition in errno.h */
325#define EBADF WSAEBADF
326#undef EINTR /* override definition in errno.h */
327#define EINTR WSAEINTR
328#undef EINVAL /* override definition in errno.h */
329#define EINVAL WSAEINVAL
330#undef EWOULDBLOCK /* override definition in errno.h */
331#define EWOULDBLOCK WSAEWOULDBLOCK
332#undef EINPROGRESS /* override definition in errno.h */
333#define EINPROGRESS WSAEINPROGRESS
334#undef EALREADY /* override definition in errno.h */
335#define EALREADY WSAEALREADY
336#undef ENOTSOCK /* override definition in errno.h */
337#define ENOTSOCK WSAENOTSOCK
338#undef EDESTADDRREQ /* override definition in errno.h */
339#define EDESTADDRREQ WSAEDESTADDRREQ
340#undef EMSGSIZE /* override definition in errno.h */
341#define EMSGSIZE WSAEMSGSIZE
342#undef EPROTOTYPE /* override definition in errno.h */
343#define EPROTOTYPE WSAEPROTOTYPE
344#undef ENOPROTOOPT /* override definition in errno.h */
345#define ENOPROTOOPT WSAENOPROTOOPT
346#undef EPROTONOSUPPORT /* override definition in errno.h */
347#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
348#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
349#undef EOPNOTSUPP /* override definition in errno.h */
350#define EOPNOTSUPP WSAEOPNOTSUPP
351#define EPFNOSUPPORT WSAEPFNOSUPPORT
352#undef EAFNOSUPPORT /* override definition in errno.h */
353#define EAFNOSUPPORT WSAEAFNOSUPPORT
354#undef EADDRINUSE /* override definition in errno.h */
355#define EADDRINUSE WSAEADDRINUSE
356#undef EADDRNOTAVAIL /* override definition in errno.h */
357#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
358#undef ENETDOWN /* override definition in errno.h */
359#define ENETDOWN WSAENETDOWN
360#undef ENETUNREACH /* override definition in errno.h */
361#define ENETUNREACH WSAENETUNREACH
362#undef ENETRESET /* override definition in errno.h */
363#define ENETRESET WSAENETRESET
364#undef ECONNABORTED /* override definition in errno.h */
365#define ECONNABORTED WSAECONNABORTED
366#undef ECONNRESET /* override definition in errno.h */
367#define ECONNRESET WSAECONNRESET
368#undef ENOBUFS /* override definition in errno.h */
369#define ENOBUFS WSAENOBUFS
370#undef EISCONN /* override definition in errno.h */
371#define EISCONN WSAEISCONN
372#undef ENOTCONN /* override definition in errno.h */
373#define ENOTCONN WSAENOTCONN
374#define ESHUTDOWN WSAESHUTDOWN
375#define ETOOMANYREFS WSAETOOMANYREFS
376#undef ETIMEDOUT /* override definition in errno.h */
377#define ETIMEDOUT WSAETIMEDOUT
378#undef ECONNREFUSED /* override definition in errno.h */
379#define ECONNREFUSED WSAECONNREFUSED
380#undef ELOOP /* override definition in errno.h */
381#define ELOOP WSAELOOP
382#ifndef ENAMETOOLONG /* possible previous definition in errno.h */
383#define ENAMETOOLONG WSAENAMETOOLONG
384#endif
385#define EHOSTDOWN WSAEHOSTDOWN
386#undef EHOSTUNREACH /* override definition in errno.h */
387#define EHOSTUNREACH WSAEHOSTUNREACH
388#ifndef ENOTEMPTY /* possible previous definition in errno.h */
389#define ENOTEMPTY WSAENOTEMPTY
390#endif
391#define EPROCLIM WSAEPROCLIM
392#define EUSERS WSAEUSERS
393#define EDQUOT WSAEDQUOT
394#define ESTALE WSAESTALE
395#define EREMOTE WSAEREMOTE
396#endif
397
398/*
399 * Macro argv_item_t hides platform details to code using it.
400 */
401
402#ifdef __VMS
403#define argv_item_t __char_ptr32
404#elif defined(_UNICODE)
405#define argv_item_t wchar_t *
406#else
407#define argv_item_t char *
408#endif
409
410
411/*
412 * We use this ZERO_NULL to avoid picky compiler warnings,
413 * when assigning a NULL pointer to a function pointer var.
414 */
415
416#define ZERO_NULL 0
417
418
419#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