VirtualBox

source: vbox/trunk/src/libs/curl-7.64.0/lib/curl_setup_once.h@ 86643

Last change on this file since 86643 was 85671, checked in by vboxsync, 4 years ago

Export out internal curl copy to make it a lot simpler to build VBox (OSE) on Windows. bugref:9814

  • Property svn:eol-style set to native
File size: 14.3 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 - 2018, 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.haxx.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#include <iprt/types.h> /* VirtualBox */
31#include <stdio.h>
32#include <stdlib.h>
33#include <string.h>
34#include <stdarg.h>
35#include <ctype.h>
36
37#ifdef HAVE_ERRNO_H
38#include <errno.h>
39#endif
40
41#ifdef HAVE_SYS_TYPES_H
42#include <sys/types.h>
43#endif
44
45#ifdef NEED_MALLOC_H
46#include <malloc.h>
47#endif
48
49#ifdef NEED_MEMORY_H
50#include <memory.h>
51#endif
52
53#ifdef HAVE_SYS_STAT_H
54#include <sys/stat.h>
55#endif
56
57#ifdef HAVE_SYS_TIME_H
58#include <sys/time.h>
59#ifdef TIME_WITH_SYS_TIME
60#include <time.h>
61#endif
62#else
63#ifdef HAVE_TIME_H
64#include <time.h>
65#endif
66#endif
67
68#ifdef WIN32
69#include <io.h>
70#include <fcntl.h>
71#endif
72
73#if defined(HAVE_STDBOOL_H) && defined(HAVE_BOOL_T)
74#include <stdbool.h>
75#endif
76
77#ifdef HAVE_UNISTD_H
78#include <unistd.h>
79#endif
80
81#ifdef __hpux
82# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
83# ifdef _APP32_64BIT_OFF_T
84# define OLD_APP32_64BIT_OFF_T _APP32_64BIT_OFF_T
85# undef _APP32_64BIT_OFF_T
86# else
87# undef OLD_APP32_64BIT_OFF_T
88# endif
89# endif
90#endif
91
92#ifdef HAVE_SYS_SOCKET_H
93#include <sys/socket.h>
94#endif
95
96#ifdef __hpux
97# if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
98# ifdef OLD_APP32_64BIT_OFF_T
99# define _APP32_64BIT_OFF_T OLD_APP32_64BIT_OFF_T
100# undef OLD_APP32_64BIT_OFF_T
101# endif
102# endif
103#endif
104
105/*
106 * Definition of timeval struct for platforms that don't have it.
107 */
108
109#ifndef HAVE_STRUCT_TIMEVAL
110struct timeval {
111 long tv_sec;
112 long tv_usec;
113};
114#endif
115
116
117/*
118 * If we have the MSG_NOSIGNAL define, make sure we use
119 * it as the fourth argument of function send()
120 */
121
122#ifdef HAVE_MSG_NOSIGNAL
123#define SEND_4TH_ARG MSG_NOSIGNAL
124#else
125#define SEND_4TH_ARG 0
126#endif
127
128
129#if defined(__minix)
130/* Minix doesn't support recv on TCP sockets */
131#define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \
132 (RECV_TYPE_ARG2)(y), \
133 (RECV_TYPE_ARG3)(z))
134
135#elif defined(HAVE_RECV)
136/*
137 * The definitions for the return type and arguments types
138 * of functions recv() and send() belong and come from the
139 * configuration file. Do not define them in any other place.
140 *
141 * HAVE_RECV is defined if you have a function named recv()
142 * which is used to read incoming data from sockets. If your
143 * function has another name then don't define HAVE_RECV.
144 *
145 * If HAVE_RECV is defined then RECV_TYPE_ARG1, RECV_TYPE_ARG2,
146 * RECV_TYPE_ARG3, RECV_TYPE_ARG4 and RECV_TYPE_RETV must also
147 * be defined.
148 *
149 * HAVE_SEND is defined if you have a function named send()
150 * which is used to write outgoing data on a connected socket.
151 * If yours has another name then don't define HAVE_SEND.
152 *
153 * If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_QUAL_ARG2,
154 * SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and
155 * SEND_TYPE_RETV must also be defined.
156 */
157
158#if !defined(RECV_TYPE_ARG1) || \
159 !defined(RECV_TYPE_ARG2) || \
160 !defined(RECV_TYPE_ARG3) || \
161 !defined(RECV_TYPE_ARG4) || \
162 !defined(RECV_TYPE_RETV)
163 /* */
164 Error Missing_definition_of_return_and_arguments_types_of_recv
165 /* */
166#else
167#define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \
168 (RECV_TYPE_ARG2)(y), \
169 (RECV_TYPE_ARG3)(z), \
170 (RECV_TYPE_ARG4)(0))
171#endif
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#if !defined(SEND_TYPE_ARG1) || \
189 !defined(SEND_QUAL_ARG2) || \
190 !defined(SEND_TYPE_ARG2) || \
191 !defined(SEND_TYPE_ARG3) || \
192 !defined(SEND_TYPE_ARG4) || \
193 !defined(SEND_TYPE_RETV)
194 /* */
195 Error Missing_definition_of_return_and_arguments_types_of_send
196 /* */
197#else
198#define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
199 (SEND_QUAL_ARG2 SEND_TYPE_ARG2)(y), \
200 (SEND_TYPE_ARG3)(z), \
201 (SEND_TYPE_ARG4)(SEND_4TH_ARG))
202#endif
203#else /* HAVE_SEND */
204#ifndef swrite
205 /* */
206 Error Missing_definition_of_macro_swrite
207 /* */
208#endif
209#endif /* HAVE_SEND */
210
211
212#if 0
213#if defined(HAVE_RECVFROM)
214/*
215 * Currently recvfrom is only used on udp sockets.
216 */
217#if !defined(RECVFROM_TYPE_ARG1) || \
218 !defined(RECVFROM_TYPE_ARG2) || \
219 !defined(RECVFROM_TYPE_ARG3) || \
220 !defined(RECVFROM_TYPE_ARG4) || \
221 !defined(RECVFROM_TYPE_ARG5) || \
222 !defined(RECVFROM_TYPE_ARG6) || \
223 !defined(RECVFROM_TYPE_RETV)
224 /* */
225 Error Missing_definition_of_return_and_arguments_types_of_recvfrom
226 /* */
227#else
228#define sreadfrom(s,b,bl,f,fl) (ssize_t)recvfrom((RECVFROM_TYPE_ARG1) (s), \
229 (RECVFROM_TYPE_ARG2 *)(b), \
230 (RECVFROM_TYPE_ARG3) (bl), \
231 (RECVFROM_TYPE_ARG4) (0), \
232 (RECVFROM_TYPE_ARG5 *)(f), \
233 (RECVFROM_TYPE_ARG6 *)(fl))
234#endif
235#else /* HAVE_RECVFROM */
236#ifndef sreadfrom
237 /* */
238 Error Missing_definition_of_macro_sreadfrom
239 /* */
240#endif
241#endif /* HAVE_RECVFROM */
242
243
244#ifdef RECVFROM_TYPE_ARG6_IS_VOID
245# define RECVFROM_ARG6_T int
246#else
247# define RECVFROM_ARG6_T RECVFROM_TYPE_ARG6
248#endif
249#endif /* if 0 */
250
251
252/*
253 * Function-like macro definition used to close a socket.
254 */
255
256#if defined(HAVE_CLOSESOCKET)
257# define sclose(x) closesocket((x))
258#elif defined(HAVE_CLOSESOCKET_CAMEL)
259# define sclose(x) CloseSocket((x))
260#elif defined(HAVE_CLOSE_S)
261# define sclose(x) close_s((x))
262#elif defined(USE_LWIPSOCK)
263# define sclose(x) lwip_close((x))
264#else
265# define sclose(x) close((x))
266#endif
267
268/*
269 * Stack-independent version of fcntl() on sockets:
270 */
271#if defined(USE_LWIPSOCK)
272# define sfcntl lwip_fcntl
273#else
274# define sfcntl fcntl
275#endif
276
277#define TOLOWER(x) (tolower((int) ((unsigned char)x)))
278
279
280/*
281 * 'bool' stuff compatible with HP-UX headers.
282 */
283
284#if defined(__hpux) && !defined(HAVE_BOOL_T)
285 typedef int bool;
286# define false 0
287# define true 1
288# define HAVE_BOOL_T
289#endif
290
291
292/*
293 * 'bool' exists on platforms with <stdbool.h>, i.e. C99 platforms.
294 * On non-C99 platforms there's no bool, so define an enum for that.
295 * On C99 platforms 'false' and 'true' also exist. Enum uses a
296 * global namespace though, so use bool_false and bool_true.
297 */
298
299#ifndef VBOX /* VirtualBox */
300#ifndef HAVE_BOOL_T
301 typedef enum {
302 bool_false = 0,
303 bool_true = 1
304 } bool;
305
306/*
307 * Use a define to let 'true' and 'false' use those enums. There
308 * are currently no use of true and false in libcurl proper, but
309 * there are some in the examples. This will cater for any later
310 * code happening to use true and false.
311 */
312# define false bool_false
313# define true bool_true
314# define HAVE_BOOL_T
315#endif
316#endif
317
318
319/*
320 * Redefine TRUE and FALSE too, to catch current use. With this
321 * change, 'bool found = 1' will give a warning on MIPSPro, but
322 * 'bool found = TRUE' will not. Change tested on IRIX/MIPSPro,
323 * AIX 5.1/Xlc, Tru64 5.1/cc, w/make test too.
324 */
325
326#ifndef TRUE
327#define TRUE true
328#endif
329#ifndef FALSE
330#define FALSE false
331#endif
332
333#include "curl_ctype.h"
334
335/*
336 * Macro WHILE_FALSE may be used to build single-iteration do-while loops,
337 * avoiding compiler warnings. Mostly intended for other macro definitions.
338 */
339
340#define WHILE_FALSE while(0)
341
342#if defined(_MSC_VER) && !defined(__POCC__)
343# undef WHILE_FALSE
344# if (_MSC_VER < 1500)
345# define WHILE_FALSE while(1, 0)
346# else
347# define WHILE_FALSE \
348__pragma(warning(push)) \
349__pragma(warning(disable:4127)) \
350while(0) \
351__pragma(warning(pop))
352# endif
353#endif
354
355
356/*
357 * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type.
358 */
359
360#ifndef HAVE_SIG_ATOMIC_T
361typedef int sig_atomic_t;
362#define HAVE_SIG_ATOMIC_T
363#endif
364
365
366/*
367 * Convenience SIG_ATOMIC_T definition
368 */
369
370#ifdef HAVE_SIG_ATOMIC_T_VOLATILE
371#define SIG_ATOMIC_T static sig_atomic_t
372#else
373#define SIG_ATOMIC_T static volatile sig_atomic_t
374#endif
375
376
377/*
378 * Default return type for signal handlers.
379 */
380
381#ifndef RETSIGTYPE
382#define RETSIGTYPE void
383#endif
384
385
386/*
387 * Macro used to include code only in debug builds.
388 */
389
390#ifdef DEBUGBUILD
391#define DEBUGF(x) x
392#else
393#define DEBUGF(x) do { } WHILE_FALSE
394#endif
395
396
397/*
398 * Macro used to include assertion code only in debug builds.
399 */
400
401#if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H)
402#define DEBUGASSERT(x) assert(x)
403#else
404#define DEBUGASSERT(x) do { } WHILE_FALSE
405#endif
406
407
408/*
409 * Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno
410 * (or equivalent) on this platform to hide platform details to code using it.
411 */
412
413#ifdef USE_WINSOCK
414#define SOCKERRNO ((int)WSAGetLastError())
415#define SET_SOCKERRNO(x) (WSASetLastError((int)(x)))
416#else
417#define SOCKERRNO (errno)
418#define SET_SOCKERRNO(x) (errno = (x))
419#endif
420
421
422/*
423 * Portable error number symbolic names defined to Winsock error codes.
424 */
425
426#ifdef USE_WINSOCK
427
428# if defined(_MSC_VER) && _MSC_VER >= 1600 /* VirtualBox bird */
429# include <errno.h>
430# undef ELOOP
431# undef EWOULDBLOCK
432# undef EHOSTUNREACH
433# undef EINPROGRESS
434# undef EALREADY
435# undef ENOTSOCK
436# undef EDESTADDRREQ
437# undef EMSGSIZE
438# undef EPROTOTYPE
439# undef ENOPROTOOPT
440# undef EPROTONOSUPPORT
441# undef EOPNOTSUPP
442# undef EAFNOSUPPORT
443# undef EADDRINUSE
444# undef EADDRNOTAVAIL
445# undef ENETDOWN
446# undef ENETUNREACH
447# undef ENETRESET
448# undef ECONNABORTED
449# undef ECONNRESET
450# undef ENOBUFS
451# undef EISCONN
452# undef ENOTCONN
453# undef ETIMEDOUT
454# undef ECONNREFUSED
455# endif
456
457#undef EBADF /* override definition in errno.h */
458#define EBADF WSAEBADF
459#undef EINTR /* override definition in errno.h */
460#define EINTR WSAEINTR
461#undef EINVAL /* override definition in errno.h */
462#define EINVAL WSAEINVAL
463#undef EWOULDBLOCK /* override definition in errno.h */
464#define EWOULDBLOCK WSAEWOULDBLOCK
465#undef EINPROGRESS /* override definition in errno.h */
466#define EINPROGRESS WSAEINPROGRESS
467#undef EALREADY /* override definition in errno.h */
468#define EALREADY WSAEALREADY
469#undef ENOTSOCK /* override definition in errno.h */
470#define ENOTSOCK WSAENOTSOCK
471#undef EDESTADDRREQ /* override definition in errno.h */
472#define EDESTADDRREQ WSAEDESTADDRREQ
473#undef EMSGSIZE /* override definition in errno.h */
474#define EMSGSIZE WSAEMSGSIZE
475#undef EPROTOTYPE /* override definition in errno.h */
476#define EPROTOTYPE WSAEPROTOTYPE
477#undef ENOPROTOOPT /* override definition in errno.h */
478#define ENOPROTOOPT WSAENOPROTOOPT
479#undef EPROTONOSUPPORT /* override definition in errno.h */
480#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
481#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
482#undef EOPNOTSUPP /* override definition in errno.h */
483#define EOPNOTSUPP WSAEOPNOTSUPP
484#define EPFNOSUPPORT WSAEPFNOSUPPORT
485#undef EAFNOSUPPORT /* override definition in errno.h */
486#define EAFNOSUPPORT WSAEAFNOSUPPORT
487#undef EADDRINUSE /* override definition in errno.h */
488#define EADDRINUSE WSAEADDRINUSE
489#undef EADDRNOTAVAIL /* override definition in errno.h */
490#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
491#undef ENETDOWN /* override definition in errno.h */
492#define ENETDOWN WSAENETDOWN
493#undef ENETUNREACH /* override definition in errno.h */
494#define ENETUNREACH WSAENETUNREACH
495#undef ENETRESET /* override definition in errno.h */
496#define ENETRESET WSAENETRESET
497#undef ECONNABORTED /* override definition in errno.h */
498#define ECONNABORTED WSAECONNABORTED
499#undef ECONNRESET /* override definition in errno.h */
500#define ECONNRESET WSAECONNRESET
501#undef ENOBUFS /* override definition in errno.h */
502#define ENOBUFS WSAENOBUFS
503#undef EISCONN /* override definition in errno.h */
504#define EISCONN WSAEISCONN
505#undef ENOTCONN /* override definition in errno.h */
506#define ENOTCONN WSAENOTCONN
507#define ESHUTDOWN WSAESHUTDOWN
508#define ETOOMANYREFS WSAETOOMANYREFS
509#undef ETIMEDOUT /* override definition in errno.h */
510#define ETIMEDOUT WSAETIMEDOUT
511#undef ECONNREFUSED /* override definition in errno.h */
512#define ECONNREFUSED WSAECONNREFUSED
513#undef ELOOP /* override definition in errno.h */
514#define ELOOP WSAELOOP
515#ifndef ENAMETOOLONG /* possible previous definition in errno.h */
516#define ENAMETOOLONG WSAENAMETOOLONG
517#endif
518#define EHOSTDOWN WSAEHOSTDOWN
519#undef EHOSTUNREACH /* override definition in errno.h */
520#define EHOSTUNREACH WSAEHOSTUNREACH
521#ifndef ENOTEMPTY /* possible previous definition in errno.h */
522#define ENOTEMPTY WSAENOTEMPTY
523#endif
524#define EPROCLIM WSAEPROCLIM
525#define EUSERS WSAEUSERS
526#define EDQUOT WSAEDQUOT
527#define ESTALE WSAESTALE
528#define EREMOTE WSAEREMOTE
529#endif
530
531/*
532 * Macro argv_item_t hides platform details to code using it.
533 */
534
535#ifdef __VMS
536#define argv_item_t __char_ptr32
537#else
538#define argv_item_t char *
539#endif
540
541
542/*
543 * We use this ZERO_NULL to avoid picky compiler warnings,
544 * when assigning a NULL pointer to a function pointer var.
545 */
546
547#define ZERO_NULL 0
548
549
550#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