2006-07-28 10:19:02 -04:00
|
|
|
#ifndef __SETUP_ONCE_H
|
|
|
|
#define __SETUP_ONCE_H
|
|
|
|
|
|
|
|
/* $Id$ */
|
|
|
|
|
2007-01-26 20:56:57 -05:00
|
|
|
/* Copyright (C) 2004 - 2007 by Daniel Stenberg et al
|
2006-07-28 10:19:02 -04:00
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software and its
|
|
|
|
* documentation for any purpose and without fee is hereby granted, provided
|
|
|
|
* that the above copyright notice appear in all copies and that both that
|
|
|
|
* copyright notice and this permission notice appear in supporting
|
|
|
|
* documentation, and that the name of M.I.T. not be used in advertising or
|
|
|
|
* publicity pertaining to distribution of the software without specific,
|
|
|
|
* written prior permission. M.I.T. makes no representations about the
|
|
|
|
* suitability of this software for any purpose. It is provided "as is"
|
|
|
|
* without express or implied warranty.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2006-10-17 23:41:19 -04:00
|
|
|
/********************************************************************
|
|
|
|
* NOTICE *
|
|
|
|
* ======== *
|
|
|
|
* *
|
|
|
|
* Content of header files lib/setup_once.h and ares/setup_once.h *
|
|
|
|
* must be kept in sync. Modify the other one if you change this. *
|
|
|
|
* *
|
|
|
|
********************************************************************/
|
|
|
|
|
|
|
|
|
2007-02-17 19:34:37 -05:00
|
|
|
/*
|
|
|
|
* Inclusion of common header files.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
|
|
|
|
2006-07-28 10:19:02 -04:00
|
|
|
/*
|
|
|
|
* If we have the MSG_NOSIGNAL define, make sure we use
|
2007-01-26 20:56:57 -05:00
|
|
|
* it as the fourth argument of function send()
|
2006-07-28 10:19:02 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_MSG_NOSIGNAL
|
|
|
|
#define SEND_4TH_ARG MSG_NOSIGNAL
|
|
|
|
#else
|
|
|
|
#define SEND_4TH_ARG 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The definitions for the return type and arguments types
|
|
|
|
* of functions recv() and send() belong and come from the
|
|
|
|
* configuration file. Do not define them in any other place.
|
|
|
|
*
|
|
|
|
* HAVE_RECV is defined if you have a function named recv()
|
|
|
|
* which is used to read incoming data from sockets. If your
|
|
|
|
* function has another name then don't define HAVE_RECV.
|
|
|
|
*
|
|
|
|
* If HAVE_RECV is defined then RECV_TYPE_ARG1, RECV_TYPE_ARG2,
|
|
|
|
* RECV_TYPE_ARG3, RECV_TYPE_ARG4 and RECV_TYPE_RETV must also
|
|
|
|
* be defined.
|
|
|
|
*
|
|
|
|
* HAVE_SEND is defined if you have a function named send()
|
|
|
|
* which is used to write outgoing data on a connected socket.
|
|
|
|
* If yours has another name then don't define HAVE_SEND.
|
|
|
|
*
|
|
|
|
* If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_QUAL_ARG2,
|
|
|
|
* SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and
|
|
|
|
* SEND_TYPE_RETV must also be defined.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_RECV
|
|
|
|
#if !defined(RECV_TYPE_ARG1) || \
|
|
|
|
!defined(RECV_TYPE_ARG2) || \
|
|
|
|
!defined(RECV_TYPE_ARG3) || \
|
|
|
|
!defined(RECV_TYPE_ARG4) || \
|
|
|
|
!defined(RECV_TYPE_RETV)
|
|
|
|
/* */
|
|
|
|
Error Missing_definition_of_return_and_arguments_types_of_recv
|
|
|
|
/* */
|
|
|
|
#else
|
|
|
|
#define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \
|
|
|
|
(RECV_TYPE_ARG2)(y), \
|
|
|
|
(RECV_TYPE_ARG3)(z), \
|
2007-01-26 20:56:57 -05:00
|
|
|
(RECV_TYPE_ARG4)(0))
|
2006-07-28 10:19:02 -04:00
|
|
|
#endif
|
|
|
|
#else /* HAVE_RECV */
|
2006-07-31 13:12:24 -04:00
|
|
|
#ifndef sread
|
|
|
|
/* */
|
|
|
|
Error Missing_definition_of_macro_sread
|
|
|
|
/* */
|
|
|
|
#endif
|
2006-07-28 10:19:02 -04:00
|
|
|
#endif /* HAVE_RECV */
|
|
|
|
|
|
|
|
#ifdef HAVE_SEND
|
|
|
|
#if !defined(SEND_TYPE_ARG1) || \
|
|
|
|
!defined(SEND_QUAL_ARG2) || \
|
|
|
|
!defined(SEND_TYPE_ARG2) || \
|
|
|
|
!defined(SEND_TYPE_ARG3) || \
|
|
|
|
!defined(SEND_TYPE_ARG4) || \
|
|
|
|
!defined(SEND_TYPE_RETV)
|
|
|
|
/* */
|
|
|
|
Error Missing_definition_of_return_and_arguments_types_of_send
|
|
|
|
/* */
|
|
|
|
#else
|
|
|
|
#define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
|
|
|
|
(SEND_TYPE_ARG2)(y), \
|
|
|
|
(SEND_TYPE_ARG3)(z), \
|
|
|
|
(SEND_TYPE_ARG4)(SEND_4TH_ARG))
|
|
|
|
#endif
|
|
|
|
#else /* HAVE_SEND */
|
2006-07-31 13:12:24 -04:00
|
|
|
#ifndef swrite
|
|
|
|
/* */
|
|
|
|
Error Missing_definition_of_macro_swrite
|
|
|
|
/* */
|
|
|
|
#endif
|
2006-07-28 10:19:02 -04:00
|
|
|
#endif /* HAVE_SEND */
|
|
|
|
|
|
|
|
|
2006-10-17 23:41:19 -04:00
|
|
|
/*
|
|
|
|
* Uppercase macro versions of ANSI/ISO is*() functions/macros which
|
2006-10-18 08:59:02 -04:00
|
|
|
* avoid negative number inputs with argument byte codes > 127.
|
2006-10-17 23:41:19 -04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define ISSPACE(x) (isspace((int) ((unsigned char)x)))
|
|
|
|
#define ISDIGIT(x) (isdigit((int) ((unsigned char)x)))
|
|
|
|
#define ISALNUM(x) (isalnum((int) ((unsigned char)x)))
|
|
|
|
#define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
|
|
|
|
#define ISGRAPH(x) (isgraph((int) ((unsigned char)x)))
|
|
|
|
#define ISALPHA(x) (isalpha((int) ((unsigned char)x)))
|
2006-10-18 17:25:12 -04:00
|
|
|
#define ISPRINT(x) (isprint((int) ((unsigned char)x)))
|
2007-02-13 13:02:20 -05:00
|
|
|
#define ISUPPER(x) (isupper((int) ((unsigned char)x)))
|
|
|
|
#define ISLOWER(x) (islower((int) ((unsigned char)x)))
|
2006-10-17 23:41:19 -04:00
|
|
|
|
2007-02-13 14:01:03 -05:00
|
|
|
#define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \
|
|
|
|
(((unsigned char)x) == '\t'))
|
|
|
|
|
2006-10-17 23:41:19 -04:00
|
|
|
|
2006-11-22 13:41:34 -05:00
|
|
|
/*
|
|
|
|
* Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HAVE_SIG_ATOMIC_T
|
|
|
|
typedef int sig_atomic_t;
|
|
|
|
#define HAVE_SIG_ATOMIC_T
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-11-24 20:02:52 -05:00
|
|
|
/*
|
|
|
|
* Default return type for signal handlers.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RETSIGTYPE
|
|
|
|
#define RETSIGTYPE void
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-02-02 10:31:32 -05:00
|
|
|
/*
|
|
|
|
* Macro used to include code only in debug builds.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CURLDEBUG
|
|
|
|
#define DEBUGF(X) X
|
|
|
|
#else
|
|
|
|
#define DEBUGF(X) do { } while (0)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-02-15 11:23:24 -05:00
|
|
|
/*
|
|
|
|
* Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno
|
|
|
|
* (or equivalent) on this platform to hide platform details to code using it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef USE_WINSOCK
|
|
|
|
#define SOCKERRNO ((int)WSAGetLastError())
|
|
|
|
#define SET_SOCKERRNO(x) (WSASetLastError((int)(x)))
|
|
|
|
#else
|
|
|
|
#define SOCKERRNO (errno)
|
|
|
|
#define SET_SOCKERRNO(x) (errno = (x))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Macro ERRNO / SET_ERRNO() returns / sets the NOT *socket-related* errno
|
|
|
|
* (or equivalent) on this platform to hide platform details to code using it.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef WIN32
|
|
|
|
#define ERRNO ((int)GetLastError())
|
|
|
|
#define SET_ERRNO(x) (SetLastError((DWORD)(x)))
|
|
|
|
#else
|
|
|
|
#define ERRNO (errno)
|
|
|
|
#define SET_ERRNO(x) (errno = (x))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2007-02-17 08:51:24 -05:00
|
|
|
/*
|
|
|
|
* Portable error number symbolic names defined to Winsock error codes.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef USE_WINSOCK
|
|
|
|
#define EWOULDBLOCK WSAEWOULDBLOCK
|
|
|
|
#define EINPROGRESS WSAEINPROGRESS
|
|
|
|
#define EALREADY WSAEALREADY
|
|
|
|
#define ENOTSOCK WSAENOTSOCK
|
|
|
|
#define EDESTADDRREQ WSAEDESTADDRREQ
|
|
|
|
#define EMSGSIZE WSAEMSGSIZE
|
|
|
|
#define EPROTOTYPE WSAEPROTOTYPE
|
|
|
|
#define ENOPROTOOPT WSAENOPROTOOPT
|
|
|
|
#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
|
|
|
|
#define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
|
|
|
|
#define EOPNOTSUPP WSAEOPNOTSUPP
|
|
|
|
#define EPFNOSUPPORT WSAEPFNOSUPPORT
|
|
|
|
#define EAFNOSUPPORT WSAEAFNOSUPPORT
|
|
|
|
#define EADDRINUSE WSAEADDRINUSE
|
|
|
|
#define EADDRNOTAVAIL WSAEADDRNOTAVAIL
|
|
|
|
#define ENETDOWN WSAENETDOWN
|
|
|
|
#define ENETUNREACH WSAENETUNREACH
|
|
|
|
#define ENETRESET WSAENETRESET
|
|
|
|
#define ECONNABORTED WSAECONNABORTED
|
|
|
|
#define ECONNRESET WSAECONNRESET
|
|
|
|
#define ENOBUFS WSAENOBUFS
|
|
|
|
#define EISCONN WSAEISCONN
|
|
|
|
#define ENOTCONN WSAENOTCONN
|
|
|
|
#define ESHUTDOWN WSAESHUTDOWN
|
|
|
|
#define ETOOMANYREFS WSAETOOMANYREFS
|
|
|
|
#define ETIMEDOUT WSAETIMEDOUT
|
|
|
|
#define ECONNREFUSED WSAECONNREFUSED
|
|
|
|
#define ELOOP WSAELOOP
|
2007-02-17 19:34:37 -05:00
|
|
|
#ifndef ENAMETOOLONG /* possible previous definition in errno.h */
|
2007-02-17 08:51:24 -05:00
|
|
|
#define ENAMETOOLONG WSAENAMETOOLONG
|
2007-02-17 19:34:37 -05:00
|
|
|
#endif
|
2007-02-17 08:51:24 -05:00
|
|
|
#define EHOSTDOWN WSAEHOSTDOWN
|
|
|
|
#define EHOSTUNREACH WSAEHOSTUNREACH
|
2007-02-17 19:34:37 -05:00
|
|
|
#ifndef ENOTEMPTY /* possible previous definition in errno.h */
|
2007-02-17 08:51:24 -05:00
|
|
|
#define ENOTEMPTY WSAENOTEMPTY
|
2007-02-17 19:34:37 -05:00
|
|
|
#endif
|
2007-02-17 08:51:24 -05:00
|
|
|
#define EPROCLIM WSAEPROCLIM
|
|
|
|
#define EUSERS WSAEUSERS
|
|
|
|
#define EDQUOT WSAEDQUOT
|
|
|
|
#define ESTALE WSAESTALE
|
|
|
|
#define EREMOTE WSAEREMOTE
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2006-07-28 10:19:02 -04:00
|
|
|
#endif /* __SETUP_ONCE_H */
|
|
|
|
|