VirtualBox

source: vbox/trunk/src/libs/curl-7.83.1/lib/curl_setup_once.h@ 97138

最後變更 在這個檔案從97138是 95312,由 vboxsync 提交於 3 年 前

libs/{curl,libxml2}: OSE export fixes, bugref:8515

  • 屬性 svn:eol-style 設為 native
檔案大小: 12.8 KB
 
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 - 2021, 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 ***************************************************************************/
24
25
26/*
27 * Inclusion of common header files.
28 */
29
30#ifdef VBOX
31# include <iprt/types.h>
32#endif
33#include <stdio.h>
34#include <stdlib.h>
35#include <string.h>
36#include <stdarg.h>
37#include <ctype.h>
38#include <time.h>
39
40#ifdef HAVE_ERRNO_H
41#include <errno.h>
42#endif
43
44#ifdef HAVE_SYS_TYPES_H
45#include <sys/types.h>
46#endif
47
48#ifdef NEED_MALLOC_H
49#include <malloc.h>
50#endif
51
52#ifdef NEED_MEMORY_H
53#include <memory.h>
54#endif
55
56#ifdef HAVE_SYS_STAT_H
57#include <sys/stat.h>
58#endif
59
60#ifdef HAVE_SYS_TIME_H
61#include <sys/time.h>
62#endif
63
64#ifdef WIN32
65#include <io.h>
66#include <fcntl.h>
67#endif
68
69#if defined(HAVE_STDBOOL_H) && defined(HAVE_BOOL_T)
70#include <stdbool.h>
71#endif
72
73#ifdef HAVE_UNISTD_H
74#include <unistd.h>
75#endif
76
77#ifdef __hpux
78# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
79# ifdef _APP32_64BIT_OFF_T
80# define OLD_APP32_64BIT_OFF_T _APP32_64BIT_OFF_T
81# undef _APP32_64BIT_OFF_T
82# else
83# undef OLD_APP32_64BIT_OFF_T
84# endif
85# endif
86#endif
87
88#ifdef HAVE_SYS_SOCKET_H
89#include <sys/socket.h>
90#endif
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#if !defined(RECV_TYPE_ARG1) || \
155 !defined(RECV_TYPE_ARG2) || \
156 !defined(RECV_TYPE_ARG3) || \
157 !defined(RECV_TYPE_ARG4) || \
158 !defined(RECV_TYPE_RETV)
159 /* */
160 Error Missing_definition_of_return_and_arguments_types_of_recv
161 /* */
162#else
163#define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \
164 (RECV_TYPE_ARG2)(y), \
165 (RECV_TYPE_ARG3)(z), \
166 (RECV_TYPE_ARG4)(0))
167#endif
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#if !defined(SEND_TYPE_ARG1) || \
185 !defined(SEND_QUAL_ARG2) || \
186 !defined(SEND_TYPE_ARG2) || \
187 !defined(SEND_TYPE_ARG3) || \
188 !defined(SEND_TYPE_ARG4) || \
189 !defined(SEND_TYPE_RETV)
190 /* */
191 Error Missing_definition_of_return_and_arguments_types_of_send
192 /* */
193#else
194#define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
195 (SEND_QUAL_ARG2 SEND_TYPE_ARG2)(y), \
196 (SEND_TYPE_ARG3)(z), \
197 (SEND_TYPE_ARG4)(SEND_4TH_ARG))
198#endif
199#else /* HAVE_SEND */
200#ifndef swrite
201 /* */
202 Error Missing_definition_of_macro_swrite
203 /* */
204#endif
205#endif /* HAVE_SEND */
206
207
208#if 0
209#if defined(HAVE_RECVFROM)
210/*
211 * Currently recvfrom is only used on udp sockets.
212 */
213#if !defined(RECVFROM_TYPE_ARG1) || \
214 !defined(RECVFROM_TYPE_ARG2) || \
215 !defined(RECVFROM_TYPE_ARG3) || \
216 !defined(RECVFROM_TYPE_ARG4) || \
217 !defined(RECVFROM_TYPE_ARG5) || \
218 !defined(RECVFROM_TYPE_ARG6) || \
219 !defined(RECVFROM_TYPE_RETV)
220 /* */
221 Error Missing_definition_of_return_and_arguments_types_of_recvfrom
222 /* */
223#else
224#define sreadfrom(s,b,bl,f,fl) (ssize_t)recvfrom((RECVFROM_TYPE_ARG1) (s), \
225 (RECVFROM_TYPE_ARG2 *)(b), \
226 (RECVFROM_TYPE_ARG3) (bl), \
227 (RECVFROM_TYPE_ARG4) (0), \
228 (RECVFROM_TYPE_ARG5 *)(f), \
229 (RECVFROM_TYPE_ARG6 *)(fl))
230#endif
231#else /* HAVE_RECVFROM */
232#ifndef sreadfrom
233 /* */
234 Error Missing_definition_of_macro_sreadfrom
235 /* */
236#endif
237#endif /* HAVE_RECVFROM */
238
239
240#ifdef RECVFROM_TYPE_ARG6_IS_VOID
241# define RECVFROM_ARG6_T int
242#else
243# define RECVFROM_ARG6_T RECVFROM_TYPE_ARG6
244#endif
245#endif /* if 0 */
246
247
248/*
249 * Function-like macro definition used to close a socket.
250 */
251
252#if defined(HAVE_CLOSESOCKET)
253# define sclose(x) closesocket((x))
254#elif defined(HAVE_CLOSESOCKET_CAMEL)
255# define sclose(x) CloseSocket((x))
256#elif defined(HAVE_CLOSE_S)
257# define sclose(x) close_s((x))
258#elif defined(USE_LWIPSOCK)
259# define sclose(x) lwip_close((x))
260#else
261# define sclose(x) close((x))
262#endif
263
264/*
265 * Stack-independent version of fcntl() on sockets:
266 */
267#if defined(USE_LWIPSOCK)
268# define sfcntl lwip_fcntl
269#else
270# define sfcntl fcntl
271#endif
272
273#define TOLOWER(x) (tolower((int) ((unsigned char)x)))
274
275
276/*
277 * 'bool' stuff compatible with HP-UX headers.
278 */
279
280#if defined(__hpux) && !defined(HAVE_BOOL_T)
281 typedef int bool;
282# define false 0
283# define true 1
284# define HAVE_BOOL_T
285#endif
286
287
288/*
289 * 'bool' exists on platforms with <stdbool.h>, i.e. C99 platforms.
290 * On non-C99 platforms there's no bool, so define an enum for that.
291 * On C99 platforms 'false' and 'true' also exist. Enum uses a
292 * global namespace though, so use bool_false and bool_true.
293 */
294
295#ifndef VBOX /* VirtualBox */
296#ifndef HAVE_BOOL_T
297 typedef enum {
298 bool_false = 0,
299 bool_true = 1
300 } bool;
301
302/*
303 * Use a define to let 'true' and 'false' use those enums. There
304 * are currently no use of true and false in libcurl proper, but
305 * there are some in the examples. This will cater for any later
306 * code happening to use true and false.
307 */
308# define false bool_false
309# define true bool_true
310# define HAVE_BOOL_T
311#endif
312#endif
313
314
315/*
316 * Redefine TRUE and FALSE too, to catch current use. With this
317 * change, 'bool found = 1' will give a warning on MIPSPro, but
318 * 'bool found = TRUE' will not. Change tested on IRIX/MIPSPro,
319 * AIX 5.1/Xlc, Tru64 5.1/cc, w/make test too.
320 */
321
322#ifndef TRUE
323#define TRUE true
324#endif
325#ifndef FALSE
326#define FALSE false
327#endif
328
329#include "curl_ctype.h"
330
331
332/*
333 * Macro used to include code only in debug builds.
334 */
335
336#ifdef DEBUGBUILD
337#define DEBUGF(x) x
338#else
339#define DEBUGF(x) do { } while(0)
340#endif
341
342
343/*
344 * Macro used to include assertion code only in debug builds.
345 */
346
347#undef DEBUGASSERT
348#if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H)
349#define DEBUGASSERT(x) assert(x)
350#else
351#define DEBUGASSERT(x) do { } while(0)
352#endif
353
354
355/*
356 * Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno
357 * (or equivalent) on this platform to hide platform details to code using it.
358 */
359
360#ifdef USE_WINSOCK
361#define SOCKERRNO ((int)WSAGetLastError())
362#define SET_SOCKERRNO(x) (WSASetLastError((int)(x)))
363#else
364#define SOCKERRNO (errno)
365#define SET_SOCKERRNO(x) (errno = (x))
366#endif
367
368
369/*
370 * Portable error number symbolic names defined to Winsock error codes.
371 */
372
373#ifdef USE_WINSOCK
374#undef EBADF /* override definition in errno.h */
375#define EBADF WSAEBADF
376#undef EINTR /* override definition in errno.h */
377#define EINTR WSAEINTR
378#undef EINVAL /* override definition in errno.h */
379#define EINVAL WSAEINVAL
380#undef EWOULDBLOCK /* override definition in errno.h */
381#define EWOULDBLOCK WSAEWOULDBLOCK
382#undef EINPROGRESS /* override definition in errno.h */
383#define EINPROGRESS WSAEINPROGRESS
384#undef EALREADY /* override definition in errno.h */
385#define EALREADY WSAEALREADY
386#undef ENOTSOCK /* override definition in errno.h */
387#define ENOTSOCK WSAENOTSOCK
388#undef EDESTADDRREQ /* override definition in errno.h */
389#define EDESTADDRREQ WSAEDESTADDRREQ
390#undef EMSGSIZE /* override definition in errno.h */
391#define EMSGSIZE WSAEMSGSIZE
392#undef EPROTOTYPE /* override definition in errno.h */
393#define EPROTOTYPE WSAEPROTOTYPE
394#undef ENOPROTOOPT /* override definition in errno.h */
395#define ENOPROTOOPT WSAENOPROTOOPT
396#undef EPROTONOSUPPORT /* override definition in errno.h */
397#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
398#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
399#undef EOPNOTSUPP /* override definition in errno.h */
400#define EOPNOTSUPP WSAEOPNOTSUPP
401#define EPFNOSUPPORT WSAEPFNOSUPPORT
402#undef EAFNOSUPPORT /* override definition in errno.h */
403#define EAFNOSUPPORT WSAEAFNOSUPPORT
404#undef EADDRINUSE /* override definition in errno.h */
405#define EADDRINUSE WSAEADDRINUSE
406#undef EADDRNOTAVAIL /* override definition in errno.h */
407#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
408#undef ENETDOWN /* override definition in errno.h */
409#define ENETDOWN WSAENETDOWN
410#undef ENETUNREACH /* override definition in errno.h */
411#define ENETUNREACH WSAENETUNREACH
412#undef ENETRESET /* override definition in errno.h */
413#define ENETRESET WSAENETRESET
414#undef ECONNABORTED /* override definition in errno.h */
415#define ECONNABORTED WSAECONNABORTED
416#undef ECONNRESET /* override definition in errno.h */
417#define ECONNRESET WSAECONNRESET
418#undef ENOBUFS /* override definition in errno.h */
419#define ENOBUFS WSAENOBUFS
420#undef EISCONN /* override definition in errno.h */
421#define EISCONN WSAEISCONN
422#undef ENOTCONN /* override definition in errno.h */
423#define ENOTCONN WSAENOTCONN
424#define ESHUTDOWN WSAESHUTDOWN
425#define ETOOMANYREFS WSAETOOMANYREFS
426#undef ETIMEDOUT /* override definition in errno.h */
427#define ETIMEDOUT WSAETIMEDOUT
428#undef ECONNREFUSED /* override definition in errno.h */
429#define ECONNREFUSED WSAECONNREFUSED
430#undef ELOOP /* override definition in errno.h */
431#define ELOOP WSAELOOP
432#ifndef ENAMETOOLONG /* possible previous definition in errno.h */
433#define ENAMETOOLONG WSAENAMETOOLONG
434#endif
435#define EHOSTDOWN WSAEHOSTDOWN
436#undef EHOSTUNREACH /* override definition in errno.h */
437#define EHOSTUNREACH WSAEHOSTUNREACH
438#ifndef ENOTEMPTY /* possible previous definition in errno.h */
439#define ENOTEMPTY WSAENOTEMPTY
440#endif
441#define EPROCLIM WSAEPROCLIM
442#define EUSERS WSAEUSERS
443#define EDQUOT WSAEDQUOT
444#define ESTALE WSAESTALE
445#define EREMOTE WSAEREMOTE
446#endif
447
448/*
449 * Macro argv_item_t hides platform details to code using it.
450 */
451
452#ifdef __VMS
453#define argv_item_t __char_ptr32
454#elif defined(_UNICODE)
455#define argv_item_t wchar_t *
456#else
457#define argv_item_t char *
458#endif
459
460
461/*
462 * We use this ZERO_NULL to avoid picky compiler warnings,
463 * when assigning a NULL pointer to a function pointer var.
464 */
465
466#define ZERO_NULL 0
467
468
469#endif /* HEADER_CURL_SETUP_ONCE_H */
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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