Move definition of IS*() macros to 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 - 2006 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 send() and recv()
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)(SEND_4TH_ARG))
78 #endif
79 #else /* HAVE_RECV */
80 #ifdef MSDOS
81 #define sread(x,y,z) (ssize_t)read_s((int)(x), (char *)(y), (int)(z))
82 #endif
83 #ifndef sread
84   /* */
85   Error Missing_definition_of_macro_sread
86   /* */
87 #endif
88 #endif /* HAVE_RECV */
89
90 #ifdef HAVE_SEND
91 #if !defined(SEND_TYPE_ARG1) || \
92     !defined(SEND_QUAL_ARG2) || \
93     !defined(SEND_TYPE_ARG2) || \
94     !defined(SEND_TYPE_ARG3) || \
95     !defined(SEND_TYPE_ARG4) || \
96     !defined(SEND_TYPE_RETV)
97   /* */
98   Error Missing_definition_of_return_and_arguments_types_of_send
99   /* */
100 #else
101 #define swrite(x,y,z) (ssize_t)send((SEND_TYPE_ARG1)(x), \
102                                     (SEND_TYPE_ARG2)(y), \
103                                     (SEND_TYPE_ARG3)(z), \
104                                     (SEND_TYPE_ARG4)(SEND_4TH_ARG))
105 #endif
106 #else /* HAVE_SEND */
107 #ifdef MSDOS
108 #define swrite(x,y,z) (ssize_t)write_s((int)(x), (char *)(y), (int)(z))
109 #endif
110 #ifndef swrite
111   /* */
112   Error Missing_definition_of_macro_swrite
113   /* */
114 #endif
115 #endif /* HAVE_SEND */
116
117
118 /*
119  * Uppercase macro versions of ANSI/ISO is*() functions/macros which 
120  * avoid negative number inputs whith argument byte codes > 127.
121  */
122
123 #define ISSPACE(x)  (isspace((int)  ((unsigned char)x)))
124 #define ISDIGIT(x)  (isdigit((int)  ((unsigned char)x)))
125 #define ISALNUM(x)  (isalnum((int)  ((unsigned char)x)))
126 #define ISXDIGIT(x) (isxdigit((int) ((unsigned char)x)))
127 #define ISGRAPH(x)  (isgraph((int)  ((unsigned char)x)))
128 #define ISALPHA(x)  (isalpha((int)  ((unsigned char)x)))
129
130
131 #endif /* __SETUP_ONCE_H */
132