curl_setup_once.h
Go to the documentation of this file.
00001 #ifndef HEADER_CURL_SETUP_ONCE_H
00002 #define HEADER_CURL_SETUP_ONCE_H
00003 /***************************************************************************
00004  *                                  _   _ ____  _
00005  *  Project                     ___| | | |  _ \| |
00006  *                             / __| | | | |_) | |
00007  *                            | (__| |_| |  _ <| |___
00008  *                             \___|\___/|_| \_\_____|
00009  *
00010  * Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
00011  *
00012  * This software is licensed as described in the file COPYING, which
00013  * you should have received as part of this distribution. The terms
00014  * are also available at https://curl.haxx.se/docs/copyright.html.
00015  *
00016  * You may opt to use, copy, modify, merge, publish, distribute and/or sell
00017  * copies of the Software, and permit persons to whom the Software is
00018  * furnished to do so, under the terms of the COPYING file.
00019  *
00020  * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
00021  * KIND, either express or implied.
00022  *
00023  ***************************************************************************/
00024 
00025 
00026 /*
00027  * Inclusion of common header files.
00028  */
00029 
00030 #include <stdio.h>
00031 #include <stdlib.h>
00032 #include <string.h>
00033 #include <stdarg.h>
00034 #include <ctype.h>
00035 
00036 #ifdef HAVE_ERRNO_H
00037 #include <errno.h>
00038 #endif
00039 
00040 #ifdef HAVE_SYS_TYPES_H
00041 #include <sys/types.h>
00042 #endif
00043 
00044 #ifdef NEED_MALLOC_H
00045 #include <malloc.h>
00046 #endif
00047 
00048 #ifdef NEED_MEMORY_H
00049 #include <memory.h>
00050 #endif
00051 
00052 #ifdef HAVE_SYS_STAT_H
00053 #include <sys/stat.h>
00054 #endif
00055 
00056 #ifdef HAVE_SYS_TIME_H
00057 #include <sys/time.h>
00058 #ifdef TIME_WITH_SYS_TIME
00059 #include <time.h>
00060 #endif
00061 #else
00062 #ifdef HAVE_TIME_H
00063 #include <time.h>
00064 #endif
00065 #endif
00066 
00067 #ifdef WIN32
00068 #include <io.h>
00069 #include <fcntl.h>
00070 #endif
00071 
00072 #if defined(HAVE_STDBOOL_H) && defined(HAVE_BOOL_T)
00073 #include <stdbool.h>
00074 #endif
00075 
00076 #ifdef HAVE_UNISTD_H
00077 #include <unistd.h>
00078 #endif
00079 
00080 #ifdef __hpux
00081 #  if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
00082 #    ifdef _APP32_64BIT_OFF_T
00083 #      define OLD_APP32_64BIT_OFF_T _APP32_64BIT_OFF_T
00084 #      undef _APP32_64BIT_OFF_T
00085 #    else
00086 #      undef OLD_APP32_64BIT_OFF_T
00087 #    endif
00088 #  endif
00089 #endif
00090 
00091 #ifdef HAVE_SYS_SOCKET_H
00092 #include <sys/socket.h>
00093 #endif
00094 
00095 #ifdef __hpux
00096 #  if !defined(_XOPEN_SOURCE_EXTENDED) || defined(_KERNEL)
00097 #    ifdef OLD_APP32_64BIT_OFF_T
00098 #      define _APP32_64BIT_OFF_T OLD_APP32_64BIT_OFF_T
00099 #      undef OLD_APP32_64BIT_OFF_T
00100 #    endif
00101 #  endif
00102 #endif
00103 
00104 
00105 /*
00106  * Definition of timeval struct for platforms that don't have it.
00107  */
00108 
00109 #ifndef HAVE_STRUCT_TIMEVAL
00110 struct timeval {
00111  long tv_sec;
00112  long tv_usec;
00113 };
00114 #endif
00115 
00116 
00117 /*
00118  * If we have the MSG_NOSIGNAL define, make sure we use
00119  * it as the fourth argument of function send()
00120  */
00121 
00122 #ifdef HAVE_MSG_NOSIGNAL
00123 #define SEND_4TH_ARG MSG_NOSIGNAL
00124 #else
00125 #define SEND_4TH_ARG 0
00126 #endif
00127 
00128 
00129 #if defined(__minix)
00130 /* Minix doesn't support recv on TCP sockets */
00131 #define sread(x,y,z) (ssize_t)read((RECV_TYPE_ARG1)(x), \
00132                                    (RECV_TYPE_ARG2)(y), \
00133                                    (RECV_TYPE_ARG3)(z))
00134 
00135 #elif defined(HAVE_RECV)
00136 /*
00137  * The definitions for the return type and arguments types
00138  * of functions recv() and send() belong and come from the
00139  * configuration file. Do not define them in any other place.
00140  *
00141  * HAVE_RECV is defined if you have a function named recv()
00142  * which is used to read incoming data from sockets. If your
00143  * function has another name then don't define HAVE_RECV.
00144  *
00145  * If HAVE_RECV is defined then RECV_TYPE_ARG1, RECV_TYPE_ARG2,
00146  * RECV_TYPE_ARG3, RECV_TYPE_ARG4 and RECV_TYPE_RETV must also
00147  * be defined.
00148  *
00149  * HAVE_SEND is defined if you have a function named send()
00150  * which is used to write outgoing data on a connected socket.
00151  * If yours has another name then don't define HAVE_SEND.
00152  *
00153  * If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_QUAL_ARG2,
00154  * SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and
00155  * SEND_TYPE_RETV must also be defined.
00156  */
00157 
00158 #if !defined(RECV_TYPE_ARG1) || \
00159     !defined(RECV_TYPE_ARG2) || \
00160     !defined(RECV_TYPE_ARG3) || \
00161     !defined(RECV_TYPE_ARG4) || \
00162     !defined(RECV_TYPE_RETV)
00163   /* */
00164   Error Missing_definition_of_return_and_arguments_types_of_recv
00165   /* */
00166 #else
00167 #define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \
00168                                    (RECV_TYPE_ARG2)(y), \
00169                                    (RECV_TYPE_ARG3)(z), \
00170                                    (RECV_TYPE_ARG4)(0))
00171 #endif
00172 #else /* HAVE_RECV */
00173 #ifndef sread
00174   /* */
00175   Error Missing_definition_of_macro_sread
00176   /* */
00177 #endif
00178 #endif /* HAVE_RECV */
00179 
00180 
00181 #if defined(__minix)
00182 /* Minix doesn't support send on TCP sockets */
00183 #define swrite(x,y,z) (ssize_t)write((SEND_TYPE_ARG1)(x), \
00184                                     (SEND_TYPE_ARG2)(y), \
00185                                     (SEND_TYPE_ARG3)(z))
00186 
00187 #elif defined(HAVE_SEND)
00188 #if !defined(SEND_TYPE_ARG1) || \
00189     !defined(SEND_QUAL_ARG2) || \
00190     !defined(SEND_TYPE_ARG2) || \
00191     !defined(SEND_TYPE_ARG3) || \
00192     !defined(SEND_TYPE_ARG4) || \
00193     !defined(SEND_TYPE_RETV)
00194   /* */
00195   Error Missing_definition_of_return_and_arguments_types_of_send
00196   /* */
00197 #else
00198 #define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
00199                                     (SEND_TYPE_ARG2)(y), \
00200                                     (SEND_TYPE_ARG3)(z), \
00201                                     (SEND_TYPE_ARG4)(SEND_4TH_ARG))
00202 #endif
00203 #else /* HAVE_SEND */
00204 #ifndef swrite
00205   /* */
00206   Error Missing_definition_of_macro_swrite
00207   /* */
00208 #endif
00209 #endif /* HAVE_SEND */
00210 
00211 
00212 #if 0
00213 #if defined(HAVE_RECVFROM)
00214 /*
00215  * Currently recvfrom is only used on udp sockets.
00216  */
00217 #if !defined(RECVFROM_TYPE_ARG1) || \
00218     !defined(RECVFROM_TYPE_ARG2) || \
00219     !defined(RECVFROM_TYPE_ARG3) || \
00220     !defined(RECVFROM_TYPE_ARG4) || \
00221     !defined(RECVFROM_TYPE_ARG5) || \
00222     !defined(RECVFROM_TYPE_ARG6) || \
00223     !defined(RECVFROM_TYPE_RETV)
00224   /* */
00225   Error Missing_definition_of_return_and_arguments_types_of_recvfrom
00226   /* */
00227 #else
00228 #define sreadfrom(s,b,bl,f,fl) (ssize_t)recvfrom((RECVFROM_TYPE_ARG1)  (s),  \
00229                                                  (RECVFROM_TYPE_ARG2 *)(b),  \
00230                                                  (RECVFROM_TYPE_ARG3)  (bl), \
00231                                                  (RECVFROM_TYPE_ARG4)  (0),  \
00232                                                  (RECVFROM_TYPE_ARG5 *)(f),  \
00233                                                  (RECVFROM_TYPE_ARG6 *)(fl))
00234 #endif
00235 #else /* HAVE_RECVFROM */
00236 #ifndef sreadfrom
00237   /* */
00238   Error Missing_definition_of_macro_sreadfrom
00239   /* */
00240 #endif
00241 #endif /* HAVE_RECVFROM */
00242 
00243 
00244 #ifdef RECVFROM_TYPE_ARG6_IS_VOID
00245 #  define RECVFROM_ARG6_T int
00246 #else
00247 #  define RECVFROM_ARG6_T RECVFROM_TYPE_ARG6
00248 #endif
00249 #endif /* if 0 */
00250 
00251 
00252 /*
00253  * Function-like macro definition used to close a socket.
00254  */
00255 
00256 #if defined(HAVE_CLOSESOCKET)
00257 #  define sclose(x)  closesocket((x))
00258 #elif defined(HAVE_CLOSESOCKET_CAMEL)
00259 #  define sclose(x)  CloseSocket((x))
00260 #elif defined(HAVE_CLOSE_S)
00261 #  define sclose(x)  close_s((x))
00262 #elif defined(USE_LWIPSOCK)
00263 #  define sclose(x)  lwip_close((x))
00264 #else
00265 #  define sclose(x)  close((x))
00266 #endif
00267 
00268 /*
00269  * Stack-independent version of fcntl() on sockets:
00270  */
00271 #if defined(USE_LWIPSOCK)
00272 #  define sfcntl  lwip_fcntl
00273 #else
00274 #  define sfcntl  fcntl
00275 #endif
00276 
00277 /*
00278  * Uppercase macro versions of ANSI/ISO is*() functions/macros which
00279  * avoid negative number inputs with argument byte codes > 127.
00280  */
00281 
00282 #define ISSPACE(x)  (isspace((int)  ((unsigned char)x)))
00283 #define ISDIGIT(x)  (isdigit((int)  ((unsigned char)x)))
00284 #define ISALNUM(x)  (isalnum((int)  ((unsigned char)x)))
00285 #define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
00286 #define ISGRAPH(x)  (isgraph((int)  ((unsigned char)x)))
00287 #define ISALPHA(x)  (isalpha((int)  ((unsigned char)x)))
00288 #define ISPRINT(x)  (isprint((int)  ((unsigned char)x)))
00289 #define ISUPPER(x)  (isupper((int)  ((unsigned char)x)))
00290 #define ISLOWER(x)  (islower((int)  ((unsigned char)x)))
00291 #define ISASCII(x)  (isascii((int)  ((unsigned char)x)))
00292 
00293 #define ISBLANK(x)  (int)((((unsigned char)x) == ' ') || \
00294                           (((unsigned char)x) == '\t'))
00295 
00296 #define TOLOWER(x)  (tolower((int)  ((unsigned char)x)))
00297 
00298 
00299 /*
00300  * 'bool' stuff compatible with HP-UX headers.
00301  */
00302 
00303 #if defined(__hpux) && !defined(HAVE_BOOL_T)
00304    typedef int bool;
00305 #  define false 0
00306 #  define true 1
00307 #  define HAVE_BOOL_T
00308 #endif
00309 
00310 
00311 /*
00312  * 'bool' exists on platforms with <stdbool.h>, i.e. C99 platforms.
00313  * On non-C99 platforms there's no bool, so define an enum for that.
00314  * On C99 platforms 'false' and 'true' also exist. Enum uses a
00315  * global namespace though, so use bool_false and bool_true.
00316  */
00317 
00318 #ifndef HAVE_BOOL_T
00319   typedef enum {
00320       bool_false = 0,
00321       bool_true  = 1
00322   } bool;
00323 
00324 /*
00325  * Use a define to let 'true' and 'false' use those enums.  There
00326  * are currently no use of true and false in libcurl proper, but
00327  * there are some in the examples. This will cater for any later
00328  * code happening to use true and false.
00329  */
00330 #  define false bool_false
00331 #  define true  bool_true
00332 #  define HAVE_BOOL_T
00333 #endif
00334 
00335 
00336 /*
00337  * Redefine TRUE and FALSE too, to catch current use. With this
00338  * change, 'bool found = 1' will give a warning on MIPSPro, but
00339  * 'bool found = TRUE' will not. Change tested on IRIX/MIPSPro,
00340  * AIX 5.1/Xlc, Tru64 5.1/cc, w/make test too.
00341  */
00342 
00343 #ifndef TRUE
00344 #define TRUE true
00345 #endif
00346 #ifndef FALSE
00347 #define FALSE false
00348 #endif
00349 
00350 
00351 /*
00352  * Macro WHILE_FALSE may be used to build single-iteration do-while loops,
00353  * avoiding compiler warnings. Mostly intended for other macro definitions.
00354  */
00355 
00356 #define WHILE_FALSE  while(0)
00357 
00358 #if defined(_MSC_VER) && !defined(__POCC__)
00359 #  undef WHILE_FALSE
00360 #  if (_MSC_VER < 1500)
00361 #    define WHILE_FALSE  while(1, 0)
00362 #  else
00363 #    define WHILE_FALSE \
00364 __pragma(warning(push)) \
00365 __pragma(warning(disable:4127)) \
00366 while(0) \
00367 __pragma(warning(pop))
00368 #  endif
00369 #endif
00370 
00371 
00372 /*
00373  * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type.
00374  */
00375 
00376 #ifndef HAVE_SIG_ATOMIC_T
00377 typedef int sig_atomic_t;
00378 #define HAVE_SIG_ATOMIC_T
00379 #endif
00380 
00381 
00382 /*
00383  * Convenience SIG_ATOMIC_T definition
00384  */
00385 
00386 #ifdef HAVE_SIG_ATOMIC_T_VOLATILE
00387 #define SIG_ATOMIC_T static sig_atomic_t
00388 #else
00389 #define SIG_ATOMIC_T static volatile sig_atomic_t
00390 #endif
00391 
00392 
00393 /*
00394  * Default return type for signal handlers.
00395  */
00396 
00397 #ifndef RETSIGTYPE
00398 #define RETSIGTYPE void
00399 #endif
00400 
00401 
00402 /*
00403  * Macro used to include code only in debug builds.
00404  */
00405 
00406 #ifdef DEBUGBUILD
00407 #define DEBUGF(x) x
00408 #else
00409 #define DEBUGF(x) do { } WHILE_FALSE
00410 #endif
00411 
00412 
00413 /*
00414  * Macro used to include assertion code only in debug builds.
00415  */
00416 
00417 #if defined(DEBUGBUILD) && defined(HAVE_ASSERT_H)
00418 #define DEBUGASSERT(x) assert(x)
00419 #else
00420 #define DEBUGASSERT(x) do { } WHILE_FALSE
00421 #endif
00422 
00423 
00424 /*
00425  * Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno
00426  * (or equivalent) on this platform to hide platform details to code using it.
00427  */
00428 
00429 #ifdef USE_WINSOCK
00430 #define SOCKERRNO         ((int)WSAGetLastError())
00431 #define SET_SOCKERRNO(x)  (WSASetLastError((int)(x)))
00432 #else
00433 #define SOCKERRNO         (errno)
00434 #define SET_SOCKERRNO(x)  (errno = (x))
00435 #endif
00436 
00437 
00438 /*
00439  * Macro ERRNO / SET_ERRNO() returns / sets the NOT *socket-related* errno
00440  * (or equivalent) on this platform to hide platform details to code using it.
00441  */
00442 
00443 #if defined(WIN32) && !defined(USE_LWIPSOCK)
00444 #define ERRNO         ((int)GetLastError())
00445 #define SET_ERRNO(x)  (SetLastError((DWORD)(x)))
00446 #else
00447 #define ERRNO         (errno)
00448 #define SET_ERRNO(x)  (errno = (x))
00449 #endif
00450 
00451 
00452 /*
00453  * Portable error number symbolic names defined to Winsock error codes.
00454  */
00455 
00456 #ifdef USE_WINSOCK
00457 #undef  EBADF            /* override definition in errno.h */
00458 #define EBADF            WSAEBADF
00459 #undef  EINTR            /* override definition in errno.h */
00460 #define EINTR            WSAEINTR
00461 #undef  EINVAL           /* override definition in errno.h */
00462 #define EINVAL           WSAEINVAL
00463 #undef  EWOULDBLOCK      /* override definition in errno.h */
00464 #define EWOULDBLOCK      WSAEWOULDBLOCK
00465 #undef  EINPROGRESS      /* override definition in errno.h */
00466 #define EINPROGRESS      WSAEINPROGRESS
00467 #undef  EALREADY         /* override definition in errno.h */
00468 #define EALREADY         WSAEALREADY
00469 #undef  ENOTSOCK         /* override definition in errno.h */
00470 #define ENOTSOCK         WSAENOTSOCK
00471 #undef  EDESTADDRREQ     /* override definition in errno.h */
00472 #define EDESTADDRREQ     WSAEDESTADDRREQ
00473 #undef  EMSGSIZE         /* override definition in errno.h */
00474 #define EMSGSIZE         WSAEMSGSIZE
00475 #undef  EPROTOTYPE       /* override definition in errno.h */
00476 #define EPROTOTYPE       WSAEPROTOTYPE
00477 #undef  ENOPROTOOPT      /* override definition in errno.h */
00478 #define ENOPROTOOPT      WSAENOPROTOOPT
00479 #undef  EPROTONOSUPPORT  /* override definition in errno.h */
00480 #define EPROTONOSUPPORT  WSAEPROTONOSUPPORT
00481 #define ESOCKTNOSUPPORT  WSAESOCKTNOSUPPORT
00482 #undef  EOPNOTSUPP       /* override definition in errno.h */
00483 #define EOPNOTSUPP       WSAEOPNOTSUPP
00484 #define EPFNOSUPPORT     WSAEPFNOSUPPORT
00485 #undef  EAFNOSUPPORT     /* override definition in errno.h */
00486 #define EAFNOSUPPORT     WSAEAFNOSUPPORT
00487 #undef  EADDRINUSE       /* override definition in errno.h */
00488 #define EADDRINUSE       WSAEADDRINUSE
00489 #undef  EADDRNOTAVAIL    /* override definition in errno.h */
00490 #define EADDRNOTAVAIL    WSAEADDRNOTAVAIL
00491 #undef  ENETDOWN         /* override definition in errno.h */
00492 #define ENETDOWN         WSAENETDOWN
00493 #undef  ENETUNREACH      /* override definition in errno.h */
00494 #define ENETUNREACH      WSAENETUNREACH
00495 #undef  ENETRESET        /* override definition in errno.h */
00496 #define ENETRESET        WSAENETRESET
00497 #undef  ECONNABORTED     /* override definition in errno.h */
00498 #define ECONNABORTED     WSAECONNABORTED
00499 #undef  ECONNRESET       /* override definition in errno.h */
00500 #define ECONNRESET       WSAECONNRESET
00501 #undef  ENOBUFS          /* override definition in errno.h */
00502 #define ENOBUFS          WSAENOBUFS
00503 #undef  EISCONN          /* override definition in errno.h */
00504 #define EISCONN          WSAEISCONN
00505 #undef  ENOTCONN         /* override definition in errno.h */
00506 #define ENOTCONN         WSAENOTCONN
00507 #define ESHUTDOWN        WSAESHUTDOWN
00508 #define ETOOMANYREFS     WSAETOOMANYREFS
00509 #undef  ETIMEDOUT        /* override definition in errno.h */
00510 #define ETIMEDOUT        WSAETIMEDOUT
00511 #undef  ECONNREFUSED     /* override definition in errno.h */
00512 #define ECONNREFUSED     WSAECONNREFUSED
00513 #undef  ELOOP            /* override definition in errno.h */
00514 #define ELOOP            WSAELOOP
00515 #ifndef ENAMETOOLONG     /* possible previous definition in errno.h */
00516 #define ENAMETOOLONG     WSAENAMETOOLONG
00517 #endif
00518 #define EHOSTDOWN        WSAEHOSTDOWN
00519 #undef  EHOSTUNREACH     /* override definition in errno.h */
00520 #define EHOSTUNREACH     WSAEHOSTUNREACH
00521 #ifndef ENOTEMPTY        /* possible previous definition in errno.h */
00522 #define ENOTEMPTY        WSAENOTEMPTY
00523 #endif
00524 #define EPROCLIM         WSAEPROCLIM
00525 #define EUSERS           WSAEUSERS
00526 #define EDQUOT           WSAEDQUOT
00527 #define ESTALE           WSAESTALE
00528 #define EREMOTE          WSAEREMOTE
00529 #endif
00530 
00531 /*
00532  * Macro argv_item_t hides platform details to code using it.
00533  */
00534 
00535 #ifdef __VMS
00536 #define argv_item_t  __char_ptr32
00537 #else
00538 #define argv_item_t  char *
00539 #endif
00540 
00541 
00542 /*
00543  * We use this ZERO_NULL to avoid picky compiler warnings,
00544  * when assigning a NULL pointer to a function pointer var.
00545  */
00546 
00547 #define ZERO_NULL 0
00548 
00549 
00550 #endif /* HEADER_CURL_SETUP_ONCE_H */
00551 


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:02