"Fossies" - the Fresh Open Source Software Archive 
Member "zsync-0.6.2/getaddrinfo.h" (16 Sep 2010, 5108 Bytes) of package /linux/privat/old/zsync-0.6.2.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
For more information about "getaddrinfo.h" see the
Fossies "Dox" file reference documentation.
1 /*
2 * Copyright (c) 2001, 02 Motoyuki Kasahara
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * 3. Neither the name of the project nor the names of its contributors
13 * may be used to endorse or promote products derived from this software
14 * without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29 #ifndef GETADDRINFO_H
30 #define GETADDRINFO_H
31
32 #include <sys/types.h>
33 #include <sys/socket.h>
34 #include <netdb.h>
35
36 /********************************************************************/
37 /*
38 * Undefine all the macros.
39 * <netdb.h> might defines some of them.
40 */
41 #ifdef EAI_ADDRFAMILY
42 #undef EAI_ADDRFAMILY
43 #endif
44 #ifdef EAI_AGAIN
45 #undef EAI_AGAIN
46 #endif
47 #ifdef EAI_BADFLAGS
48 #undef EAI_BADFLAGS
49 #endif
50 #ifdef EAI_FAIL
51 #undef EAI_FAIL
52 #endif
53 #ifdef EAI_FAMILY
54 #undef EAI_FAMILY
55 #endif
56 #ifdef EAI_MEMORY
57 #undef EAI_MEMORY
58 #endif
59 #ifdef EAI_NONAME
60 #undef EAI_NONAME
61 #endif
62 #ifdef EAI_OVERFLOW
63 #undef EAI_OVERFLOW
64 #endif
65 #ifdef EAI_SERVICE
66 #undef EAI_SERVICE
67 #endif
68 #ifdef EAI_SOCKTYPE
69 #undef EAI_SOCKTYPE
70 #endif
71 #ifdef EAI_SYSTEM
72 #undef EAI_SYSTEM
73 #endif
74
75 #ifdef AI_PASSIVE
76 #undef AI_PASSIVE
77 #endif
78 #ifdef AI_CANONNAME
79 #undef AI_CANONNAME
80 #endif
81 #ifdef AI_NUMERICHOST
82 #undef AI_NUMERICHOST
83 #endif
84 #ifdef AI_NUMERICSERV
85 #undef AI_NUMERICSERV
86 #endif
87 #ifdef AI_V4MAPPED
88 #undef AI_V4MAPPED
89 #endif
90 #ifdef AI_ALL
91 #undef AI_ALL
92 #endif
93 #ifdef AI_ADDRCONFIG
94 #undef AI_ADDRCONFIG
95 #endif
96 #ifdef AI_DEFAULT
97 #undef AI_DEFAULT
98 #endif
99
100 #ifdef NI_NOFQDN
101 #undef NI_NOFQDN
102 #endif
103 #ifdef NI_NUMERICHOST
104 #undef NI_NUMERICHOST
105 #endif
106 #ifdef NI_NAMEREQD
107 #undef NI_NAMEREQD
108 #endif
109 #ifdef NI_NUMERICSERV
110 #undef NI_NUMERICSERV
111 #endif
112 #ifdef NI_NUMERICSCOPE
113 #undef NI_NUMERICSCOPE
114 #endif
115
116 #ifdef NI_DGRAM
117 #undef NI_DGRAM
118 #endif
119 #ifdef NI_MAXHOST
120 #undef NI_MAXHOST
121 #endif
122 #ifdef NI_MAXSERV
123 #undef NI_MAXSERV
124 #endif
125
126 /*
127 * Fake struct and function names.
128 * <netdb.h> might declares all or some of them.
129 */
130 #if defined(HAVE_GETADDRINFO) || defined(HAVE_GETNAMEINFO)
131 #define addrinfo my_addrinfo
132 #define gai_strerror my_gai_strerror
133 #define freeaddrinfo my_freeaddrinfo
134 #define getaddrinfo my_getaddrinfo
135 #define getnameinfo my_getnameinfo
136 #endif
137
138 /********************************************************************/
139 /*
140 * Error codes.
141 */
142 #define EAI_ADDRFAMILY 1
143 #define EAI_AGAIN 2
144 #define EAI_BADFLAGS 3
145 #define EAI_FAIL 4
146 #define EAI_FAMILY 5
147 #define EAI_MEMORY 6
148 #define EAI_NONAME 7
149 #define EAI_OVERFLOW 8
150 #define EAI_SERVICE 9
151 #define EAI_SOCKTYPE 10
152 #define EAI_SYSTEM 11
153
154 /*
155 * Flags for getaddrinfo().
156 */
157 #define AI_ADDRCONFIG 0x0001
158 #define AI_ALL 0x0002
159 #define AI_CANONNAME 0x0004
160 #define AI_NUMERICHOST 0x0008
161 #define AI_NUMERICSERV 0x0010
162 #define AI_PASSIVE 0x0020
163 #define AI_V4MAPPED 0x0040
164 #define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG)
165
166 /*
167 * Flags for getnameinfo().
168 */
169 #define NI_DGRAM 0x0001
170 #define NI_NAMEREQD 0x0002
171 #define NI_NOFQDN 0x0004
172 #define NI_NUMERICHOST 0x0008
173 #define NI_NUMERICSCOPE 0x0010
174 #define NI_NUMERICSERV 0x0020
175
176 /*
177 * Maximum length of FQDN and servie name for getnameinfo().
178 */
179 #define NI_MAXHOST 1025
180 #define NI_MAXSERV 32
181
182 /*
183 * Address families and Protocol families.
184 */
185 #ifndef AF_UNSPEC
186 #define AF_UNSPEC AF_INET
187 #endif
188 #ifndef PF_UNSPEC
189 #define PF_UNSPEC PF_INET
190 #endif
191
192 /*
193 * struct addrinfo.
194 */
195 struct addrinfo {
196 int ai_flags;
197 int ai_family;
198 int ai_socktype;
199 int ai_protocol;
200 socklen_t ai_addrlen;
201 char *ai_canonname;
202 struct sockaddr *ai_addr;
203 struct addrinfo *ai_next;
204 };
205
206 /*
207 * Functions.
208 */
209 #ifdef __STDC__
210 const char *gai_strerror(int);
211 void freeaddrinfo(struct addrinfo *);
212 int getaddrinfo(const char *, const char *, const struct addrinfo *,
213 struct addrinfo **);
214 int getnameinfo(const struct sockaddr *, socklen_t, char *,
215 socklen_t, char *, socklen_t, int);
216 #else
217 const char *gai_strerror();
218 void freeaddrinfo();
219 int getaddrinfo();
220 int getnameinfo();
221 #endif
222
223 #endif /* not GETADDRINFO_H */