Unconstify members of the lconv structure to make it conform to the C89 and
[dragonfly/port-amd64.git] / lib / libbind / port_after.h
blob7cce3b9992942019b6f7c26987a41b180a9fa5c8
1 /* $DragonFly: src/lib/libbind/port_after.h,v 1.2 2006/09/20 21:48:39 victor Exp $ */
2 #ifndef port_after_h
3 #define port_after_h
5 #include <stdio.h>
6 #include <sys/types.h>
7 #include <sys/socket.h>
8 #include <sys/param.h>
9 #if (!defined(BSD)) || (BSD < 199306)
10 #include <sys/bitypes.h>
11 #endif
12 #ifdef HAVE_INTTYPES_H
13 #include <inttypes.h>
14 #endif
16 #define NEED_PSELECT
17 #define HAVE_SA_LEN 1
18 #define HAVE_MINIMUM_IFREQ 1
19 #undef NEED_DAEMON
20 #undef NEED_STRSEP
21 #undef NEED_STRERROR
22 #define HAS_INET6_STRUCTS 1
23 #define HAVE_SIN6_SCOPE_ID 1
24 #undef NEED_IN6ADDR_ANY
25 #undef HAS_IN_ADDR6
26 #define HAVE_SOCKADDR_STORAGE 1
27 #undef NEED_GETTIMEOFDAY
28 #undef HAVE_STRNDUP
29 #undef USE_FIONBIO_IOCTL
30 #undef USE_SYSERROR_LIST
31 #undef INNETGR_ARGS
32 #undef SETNETGRENT_ARGS
33 #define USE_IFNAMELINKID 1
34 #define PORT_NONBLOCK O_NONBLOCK
37 * We need to know the IPv6 address family number even on IPv4-only systems.
38 * Note that this is NOT a protocol constant, and that if the system has its
39 * own AF_INET6, different from ours below, all of BIND's libraries and
40 * executables will need to be recompiled after the system <sys/socket.h>
41 * has had this type added. The type number below is correct on most BSD-
42 * derived systems for which AF_INET6 is defined.
44 #ifndef AF_INET6
45 #define AF_INET6 24
46 #endif
48 #ifndef PF_INET6
49 #define PF_INET6 AF_INET6
50 #endif
52 #ifdef HAS_IN_ADDR6
53 /* Map to pre-RFC structure. */
54 #define in6_addr in_addr6
55 #endif
57 #ifndef HAS_INET6_STRUCTS
58 /* Replace with structure from later rev of O/S if known. */
59 struct in6_addr {
60 u_int8_t s6_addr[16];
63 #define IN6ADDR_ANY_INIT \
64 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
65 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
67 #define IN6ADDR_LOOPBACK_INIT \
68 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
69 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
71 /* Replace with structure from later rev of O/S if known. */
72 struct sockaddr_in6 {
73 #ifdef HAVE_SA_LEN
74 u_int8_t sin6_len; /* length of this struct */
75 u_int8_t sin6_family; /* AF_INET6 */
76 #else
77 u_int16_t sin6_family; /* AF_INET6 */
78 #endif
79 u_int16_t sin6_port; /* transport layer port # */
80 u_int32_t sin6_flowinfo; /* IPv6 flow information */
81 struct in6_addr sin6_addr; /* IPv6 address */
82 u_int32_t sin6_scope_id; /* set of interfaces for a scope */
84 #endif /* HAS_INET6_STRUCTS */
86 #ifdef BROKEN_IN6ADDR_INIT_MACROS
87 #undef IN6ADDR_ANY_INIT
88 #undef IN6ADDR_LOOPBACK_INIT
89 #endif
91 #ifdef _AIX
92 #ifndef IN6ADDR_ANY_INIT
93 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
94 #endif
95 #ifndef IN6ADDR_LOOPBACK_INIT
96 #if BYTE_ORDER == BIG_ENDIAN
97 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
98 #else
99 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
100 #endif
101 #endif
102 #endif
104 #ifndef IN6ADDR_ANY_INIT
105 #ifdef s6_addr
106 #define IN6ADDR_ANY_INIT \
107 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
108 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
109 #else
110 #define IN6ADDR_ANY_INIT \
111 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
112 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
113 #endif
115 #endif
116 #ifndef IN6ADDR_LOOPBACK_INIT
117 #ifdef s6_addr
118 #define IN6ADDR_LOOPBACK_INIT \
119 {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
120 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
121 #else
122 #define IN6ADDR_LOOPBACK_INIT \
123 {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
124 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
125 #endif
126 #endif
128 #ifndef HAVE_SOCKADDR_STORAGE
129 #define __SS_MAXSIZE 128
130 #define __SS_ALLIGSIZE (sizeof (long))
132 struct sockaddr_storage {
133 #ifdef HAVE_SA_LEN
134 u_int8_t ss_len; /* address length */
135 u_int8_t ss_family; /* address family */
136 char __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
137 long __ss_align;
138 char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
139 #else
140 u_int16_t ss_family; /* address family */
141 char __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
142 long __ss_align;
143 char __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
144 #endif
146 #endif
149 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
150 #define in6addr_any isc_in6addr_any
151 extern const struct in6_addr in6addr_any;
152 #endif
155 * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
156 * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
158 #ifdef __GLIBC__
159 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
160 #undef IN6_ARE_ADDR_EQUAL
161 #undef IN6_IS_ADDR_UNSPECIFIED
162 #undef IN6_IS_ADDR_V4COMPAT
163 #undef IN6_IS_ADDR_V4MAPPED
164 #endif
165 #endif
167 #ifndef IN6_ARE_ADDR_EQUAL
168 #define IN6_ARE_ADDR_EQUAL(a,b) \
169 (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
170 #endif
172 #ifndef IN6_IS_ADDR_UNSPECIFIED
173 #define IN6_IS_ADDR_UNSPECIFIED(a) \
174 IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
175 #endif
177 #ifndef IN6_IS_ADDR_LOOPBACK
178 extern const struct in6_addr isc_in6addr_loopback;
179 #define IN6_IS_ADDR_LOOPBACK(a) \
180 IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
181 #endif
183 #ifndef IN6_IS_ADDR_V4MAPPED
184 #define IN6_IS_ADDR_V4MAPPED(a) \
185 ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
186 (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
187 (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
188 (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
189 (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
190 (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
191 #endif
193 #ifndef IN6_IS_ADDR_SITELOCAL
194 #define IN6_IS_ADDR_SITELOCAL(a) \
195 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
196 #endif
198 #ifndef IN6_IS_ADDR_LINKLOCAL
199 #define IN6_IS_ADDR_LINKLOCAL(a) \
200 (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
201 #endif
203 #ifndef IN6_IS_ADDR_MULTICAST
204 #define IN6_IS_ADDR_MULTICAST(a) ((a)->s6_addr[0] == 0xff)
205 #endif
207 #ifndef __IPV6_ADDR_MC_SCOPE
208 #define __IPV6_ADDR_MC_SCOPE(a) ((a)->s6_addr[1] & 0x0f)
209 #endif
211 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
212 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
213 #endif
214 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
215 #define __IPV6_ADDR_SCOPE_ORGLOCAL 0x08
216 #endif
218 #ifndef IN6_IS_ADDR_MC_SITELOCAL
219 #define IN6_IS_ADDR_MC_SITELOCAL(a) \
220 (IN6_IS_ADDR_MULTICAST(a) && \
221 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
222 #endif
224 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
225 #define IN6_IS_ADDR_MC_ORGLOCAL(a) \
226 (IN6_IS_ADDR_MULTICAST(a) && \
227 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
228 #endif
230 #ifndef INADDR_NONE
231 #define INADDR_NONE 0xffffffff
232 #endif
234 #ifndef MAXHOSTNAMELEN
235 #define MAXHOSTNAMELEN 256
236 #endif
238 #ifndef INET6_ADDRSTRLEN
239 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
240 #define INET6_ADDRSTRLEN 46
241 #endif
243 #ifndef MIN
244 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
245 #endif
247 #ifndef MAX
248 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
249 #endif
251 #ifdef NEED_DAEMON
252 int daemon(int nochdir, int noclose);
253 #endif
255 #ifdef NEED_STRSEP
256 char * strsep(char **stringp, const char *delim);
257 #endif
259 #ifndef ALIGN
260 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
261 #endif
263 #ifdef NEED_SETGROUPENT
264 int setgroupent(int stayopen);
265 #endif
267 #ifdef NEED_GETGROUPLIST
268 int getgrouplist(GETGROUPLIST_ARGS);
269 #endif
271 #ifdef POSIX_GETGRNAM_R
273 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
274 #endif
276 #ifdef NEED_GETGRNAM_R
278 getgrnam_r(const char *, struct group *, char *, size_t, struct group **);
279 #endif
281 #ifdef POSIX_GETGRGID_R
283 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
284 #endif
286 #ifdef NEED_GETGRGID_R
288 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
289 #endif
291 #ifdef NEED_GETGRENT_R
292 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
293 #endif
295 #ifdef NEED_SETGRENT_R
296 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
297 #endif
299 #ifdef NEED_ENDGRENT_R
300 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
301 #endif
303 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
304 NGR_R_RETURN
305 innetgr_r(const char *, const char *, const char *, const char *);
306 #endif
308 #ifdef NEED_SETNETGRENT_R
309 #ifdef NGR_R_ENT_ARGS
310 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
311 #else
312 NGR_R_SET_RETURN setnetgrent_r(const char *netgroup);
313 #endif
314 #endif
316 #ifdef NEED_ENDNETGRENT_R
317 #ifdef NGR_R_ENT_ARGS
318 NGR_R_END_RETURN endnetgrent_r(NGR_R_ENT_ARGS);
319 #else
320 NGR_R_END_RETURN endnetgrent_r(void);
321 #endif
322 #endif
324 #ifdef POSIX_GETPWNAM_R
326 __posix_getpwnam_r(const char *login, struct passwd *pwptr,
327 char *buf, size_t buflen, struct passwd **result);
328 #endif
330 #ifdef NEED_GETPWNAM_R
332 getpwnam_r(const char *login, struct passwd *pwptr,
333 char *buf, size_t buflen, struct passwd **result);
334 #endif
336 #ifdef POSIX_GETPWUID_R
338 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
339 char *buf, int buflen, struct passwd **result);
340 #endif
342 #ifdef NEED_GETPWUID_R
344 getpwuid_r(uid_t uid, struct passwd *pwptr,
345 char *buf, size_t buflen, struct passwd **result);
346 #endif
348 #ifdef NEED_SETPWENT_R
349 #ifdef PASS_R_ENT_ARGS
350 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
351 #else
352 PASS_R_SET_RETURN setpwent_r(void);
353 #endif
355 #endif
357 #ifdef NEED_SETPASSENT_R
358 #ifdef PASS_R_ENT_ARGS
359 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
360 #else
361 PASS_R_SET_RETURN setpassent_r(int stayopen);
362 #endif
363 #endif
365 #ifdef NEED_GETPWENT_R
366 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
367 #endif
369 #ifdef NEED_ENDPWENT_R
370 void endpwent_r(void);
371 #endif
373 #ifdef NEED_SETPASSENT
374 int setpassent(int stayopen);
375 #endif
377 #define gettimeofday isc__gettimeofday
378 #ifdef NEED_GETTIMEOFDAY
379 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
380 #else
381 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
382 #endif
384 int getnetgrent(char **machinep, char **userp, char **domainp);
386 #ifdef NGR_R_ARGS
387 int getnetgrent_r(char **machinep, char **userp, char **domainp, NGR_R_ARGS);
388 #endif
390 #ifdef SETNETGRENT_ARGS
391 void setnetgrent(SETNETGRENT_ARGS);
392 #else
393 void setnetgrent(const char *netgroup);
394 #endif
396 void endnetgrent(void);
398 #ifdef INNETGR_ARGS
399 int innetgr(INNETGR_ARGS);
400 #else
401 int innetgr(const char *netgroup, const char *machine,
402 const char *user, const char *domain);
403 #endif
405 #ifdef NGR_R_ENT_ARGS
406 NGR_R_SET_RETURN
407 setnetgrent_r(const char *netgroup, NGR_R_ENT_ARGS);
408 #else
409 NGR_R_SET_RETURN
410 setnetgrent_r(const char *netgroup);
411 #endif
412 #endif