sync with lib/setup_once.h
[platform/upstream/c-ares.git] / setup_once.h
1 #ifndef __SETUP_ONCE_H
2 #define __SETUP_ONCE_H
3
4 /* $Id$ */
5
6 /* Copyright (C) 2004 - 2007 by Daniel Stenberg et al
7  *
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.
17  */
18
19
20 /********************************************************************
21  *                              NOTICE                              *
22  *                             ========                             *
23  *                                                                  *
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.  *
26  *                                                                  *
27  ********************************************************************/
28
29
30 /*
31  * If we have the MSG_NOSIGNAL define, make sure we use
32  * it as the fourth argument of function send()
33  */
34
35 #ifdef HAVE_MSG_NOSIGNAL
36 #define SEND_4TH_ARG MSG_NOSIGNAL
37 #else
38 #define SEND_4TH_ARG 0
39 #endif 
40
41
42 /*
43  * The definitions for the return type and arguments types
44  * of functions recv() and send() belong and come from the
45  * configuration file. Do not define them in any other place.
46  *
47  * HAVE_RECV is defined if you have a function named recv()
48  * which is used to read incoming data from sockets. If your
49  * function has another name then don't define HAVE_RECV.
50  *
51  * If HAVE_RECV is defined then RECV_TYPE_ARG1, RECV_TYPE_ARG2,
52  * RECV_TYPE_ARG3, RECV_TYPE_ARG4 and RECV_TYPE_RETV must also
53  * be defined.
54  *
55  * HAVE_SEND is defined if you have a function named send()
56  * which is used to write outgoing data on a connected socket.
57  * If yours has another name then don't define HAVE_SEND.
58  *
59  * If HAVE_SEND is defined then SEND_TYPE_ARG1, SEND_QUAL_ARG2,
60  * SEND_TYPE_ARG2, SEND_TYPE_ARG3, SEND_TYPE_ARG4 and
61  * SEND_TYPE_RETV must also be defined.
62  */
63
64 #ifdef HAVE_RECV
65 #if !defined(RECV_TYPE_ARG1) || \
66     !defined(RECV_TYPE_ARG2) || \
67     !defined(RECV_TYPE_ARG3) || \
68     !defined(RECV_TYPE_ARG4) || \
69     !defined(RECV_TYPE_RETV)
70   /* */
71   Error Missing_definition_of_return_and_arguments_types_of_recv
72   /* */
73 #else
74 #define sread(x,y,z) (ssize_t)recv((RECV_TYPE_ARG1)(x), \
75                                    (RECV_TYPE_ARG2)(y), \
76                                    (RECV_TYPE_ARG3)(z), \
77                                    (RECV_TYPE_ARG4)(0))
78 #endif
79 #else /* HAVE_RECV */
80 #ifndef sread
81   /* */
82   Error Missing_definition_of_macro_sread
83   /* */
84 #endif
85 #endif /* HAVE_RECV */
86
87 #ifdef HAVE_SEND
88 #if !defined(SEND_TYPE_ARG1) || \
89     !defined(SEND_QUAL_ARG2) || \
90     !defined(SEND_TYPE_ARG2) || \
91     !defined(SEND_TYPE_ARG3) || \
92     !defined(SEND_TYPE_ARG4) || \
93     !defined(SEND_TYPE_RETV)
94   /* */
95   Error Missing_definition_of_return_and_arguments_types_of_send
96   /* */
97 #else
98 #define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
99                                     (SEND_TYPE_ARG2)(y), \
100                                     (SEND_TYPE_ARG3)(z), \
101                                     (SEND_TYPE_ARG4)(SEND_4TH_ARG))
102 #endif
103 #else /* HAVE_SEND */
104 #ifndef swrite
105   /* */
106   Error Missing_definition_of_macro_swrite
107   /* */
108 #endif
109 #endif /* HAVE_SEND */
110
111
112 /*
113  * Uppercase macro versions of ANSI/ISO is*() functions/macros which 
114  * avoid negative number inputs with argument byte codes > 127.
115  */
116
117 #define ISSPACE(x)  (isspace((int)  ((unsigned char)x)))
118 #define ISDIGIT(x)  (isdigit((int)  ((unsigned char)x)))
119 #define ISALNUM(x)  (isalnum((int)  ((unsigned char)x)))
120 #define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
121 #define ISGRAPH(x)  (isgraph((int)  ((unsigned char)x)))
122 #define ISALPHA(x)  (isalpha((int)  ((unsigned char)x)))
123 #define ISPRINT(x)  (isprint((int)  ((unsigned char)x)))
124
125
126 /*
127  * Typedef to 'int' if sig_atomic_t is not an available 'typedefed' type.
128  */
129
130 #ifndef HAVE_SIG_ATOMIC_T
131 typedef int sig_atomic_t;
132 #define HAVE_SIG_ATOMIC_T
133 #endif
134
135
136 /*
137  * Default return type for signal handlers.
138  */
139
140 #ifndef RETSIGTYPE
141 #define RETSIGTYPE void
142 #endif
143
144
145 #endif /* __SETUP_ONCE_H */
146