6 /* Copyright (C) 2004 - 2007 by Daniel Stenberg et al
8 * Permission to use, copy, modify, and distribute this software and its
9 * documentation for any purpose and without fee is hereby granted, provided
10 * that the above copyright notice appear in all copies and that both that
11 * copyright notice and this permission notice appear in supporting
12 * documentation, and that the name of M.I.T. not be used in advertising or
13 * publicity pertaining to distribution of the software without specific,
14 * written prior permission. M.I.T. makes no representations about the
15 * suitability of this software for any purpose. It is provided "as is"
16 * without express or implied warranty.
20 /********************************************************************
24 * Content of header files lib/setup_once.h and ares/setup_once.h *
25 * must be kept in sync. Modify the other one if you change this. *
27 ********************************************************************/
31 * Inclusion of common header files.
38 * If we have the MSG_NOSIGNAL define, make sure we use
39 * it as the fourth argument of function send()
42 #ifdef HAVE_MSG_NOSIGNAL
43 #define SEND_4TH_ARG MSG_NOSIGNAL
45 #define SEND_4TH_ARG 0
50 * The definitions for the return type and arguments types
51 * of functions recv() and send() belong and come from the
52 * configuration file. Do not define them in any other place.
54 * HAVE_RECV is defined if you have a function named recv()
55 * which is used to read incoming data from sockets. If your
56 * function has another name then don't define HAVE_RECV.
58 * If HAVE_RECV is defined then RECV_TYPE_ARG1, RECV_TYPE_ARG2,
59 * RECV_TYPE_ARG3, RECV_TYPE_ARG4 and RECV_TYPE_RETV must also
62 * HAVE_SEND is defined if you have a function named send()
63 * which is used to write outgoing data on a connected socket.
64 * If yours has another name then don't define HAVE_SEND.
66 * If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_QUAL_ARG2,
67 * SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and
68 * SEND_TYPE_RETV must also be defined.
72 #if !defined(RECV_TYPE_ARG1) || \
73 !defined(RECV_TYPE_ARG2) || \
74 !defined(RECV_TYPE_ARG3) || \
75 !defined(RECV_TYPE_ARG4) || \
76 !defined(RECV_TYPE_RETV)
78 Error Missing_definition_of_return_and_arguments_types_of_recv
81 #define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \
82 (RECV_TYPE_ARG2)(y), \
83 (RECV_TYPE_ARG3)(z), \
89 Error Missing_definition_of_macro_sread
92 #endif /* HAVE_RECV */
95 #if !defined(SEND_TYPE_ARG1) || \
96 !defined(SEND_QUAL_ARG2) || \
97 !defined(SEND_TYPE_ARG2) || \
98 !defined(SEND_TYPE_ARG3) || \
99 !defined(SEND_TYPE_ARG4) || \
100 !defined(SEND_TYPE_RETV)
102 Error Missing_definition_of_return_and_arguments_types_of_send
105 #define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
106 (SEND_TYPE_ARG2)(y), \
107 (SEND_TYPE_ARG3)(z), \
108 (SEND_TYPE_ARG4)(SEND_4TH_ARG))
110 #else /* HAVE_SEND */
113 Error Missing_definition_of_macro_swrite
116 #endif /* HAVE_SEND */
120 * Uppercase macro versions of ANSI/ISO is*() functions/macros which
121 * avoid negative number inputs with argument byte codes > 127.
124 #define ISSPACE(x) (isspace((int) ((unsigned char)x)))
125 #define ISDIGIT(x) (isdigit((int) ((unsigned char)x)))
126 #define ISALNUM(x) (isalnum((int) ((unsigned char)x)))
127 #define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
128 #define ISGRAPH(x) (isgraph((int) ((unsigned char)x)))
129 #define ISALPHA(x) (isalpha((int) ((unsigned char)x)))
130 #define ISPRINT(x) (isprint((int) ((unsigned char)x)))
131 #define ISUPPER(x) (isupper((int) ((unsigned char)x)))
132 #define ISLOWER(x) (islower((int) ((unsigned char)x)))
134 #define ISBLANK(x) (int)((((unsigned char)x) == ' ') || \
135 (((unsigned char)x) == '\t'))
139 * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type.
142 #ifndef HAVE_SIG_ATOMIC_T
143 typedef int sig_atomic_t;
144 #define HAVE_SIG_ATOMIC_T
149 * Default return type for signal handlers.
153 #define RETSIGTYPE void
158 * Macro used to include code only in debug builds.
164 #define DEBUGF(X) do { } while (0)
169 * Macro SOCKERRNO / SET_SOCKERRNO() returns / sets the *socket-related* errno
170 * (or equivalent) on this platform to hide platform details to code using it.
174 #define SOCKERRNO ((int)WSAGetLastError())
175 #define SET_SOCKERRNO(x) (WSASetLastError((int)(x)))
177 #define SOCKERRNO (errno)
178 #define SET_SOCKERRNO(x) (errno = (x))
183 * Macro ERRNO / SET_ERRNO() returns / sets the NOT *socket-related* errno
184 * (or equivalent) on this platform to hide platform details to code using it.
188 #define ERRNO ((int)GetLastError())
189 #define SET_ERRNO(x) (SetLastError((DWORD)(x)))
191 #define ERRNO (errno)
192 #define SET_ERRNO(x) (errno = (x))
197 * Portable error number symbolic names defined to Winsock error codes.
201 #define EWOULDBLOCK WSAEWOULDBLOCK
202 #define EINPROGRESS WSAEINPROGRESS
203 #define EALREADY WSAEALREADY
204 #define ENOTSOCK WSAENOTSOCK
205 #define EDESTADDRREQ WSAEDESTADDRREQ
206 #define EMSGSIZE WSAEMSGSIZE
207 #define EPROTOTYPE WSAEPROTOTYPE
208 #define ENOPROTOOPT WSAENOPROTOOPT
209 #define EPROTONOSUPPORT WSAEPROTONOSUPPORT
210 #define ESOCKTNOSUPPORT WSAESOCKTNOSUPPORT
211 #define EOPNOTSUPP WSAEOPNOTSUPP
212 #define EPFNOSUPPORT WSAEPFNOSUPPORT
213 #define EAFNOSUPPORT WSAEAFNOSUPPORT
214 #define EADDRINUSE WSAEADDRINUSE
215 #define EADDRNOTAVAIL WSAEADDRNOTAVAIL
216 #define ENETDOWN WSAENETDOWN
217 #define ENETUNREACH WSAENETUNREACH
218 #define ENETRESET WSAENETRESET
219 #define ECONNABORTED WSAECONNABORTED
220 #define ECONNRESET WSAECONNRESET
221 #define ENOBUFS WSAENOBUFS
222 #define EISCONN WSAEISCONN
223 #define ENOTCONN WSAENOTCONN
224 #define ESHUTDOWN WSAESHUTDOWN
225 #define ETOOMANYREFS WSAETOOMANYREFS
226 #define ETIMEDOUT WSAETIMEDOUT
227 #define ECONNREFUSED WSAECONNREFUSED
228 #define ELOOP WSAELOOP
229 #ifndef ENAMETOOLONG /* possible previous definition in errno.h */
230 #define ENAMETOOLONG WSAENAMETOOLONG
232 #define EHOSTDOWN WSAEHOSTDOWN
233 #define EHOSTUNREACH WSAEHOSTUNREACH
234 #ifndef ENOTEMPTY /* possible previous definition in errno.h */
235 #define ENOTEMPTY WSAENOTEMPTY
237 #define EPROCLIM WSAEPROCLIM
238 #define EUSERS WSAEUSERS
239 #define EDQUOT WSAEDQUOT
240 #define ESTALE WSAESTALE
241 #define EREMOTE WSAEREMOTE
245 #endif /* __SETUP_ONCE_H */