]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - contrib/bind9/lib/bind/port_after.h.in
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / contrib / bind9 / lib / bind / port_after.h.in
1 #ifndef port_after_h
2 #define port_after_h
3
4 #include <stdio.h>
5 #include <sys/types.h>
6 #include <sys/socket.h>
7 #include <sys/param.h>
8 #include <sys/time.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
15 #ifdef HAVE_SYS_SELECT_H
16 #include <sys/select.h>
17 #endif /* HAVE_SYS_SELECT_H */
18
19 #ifdef REENABLE_SEND
20 #undef send
21 #endif
22
23 @NEED_PSELECT@
24 @HAVE_SA_LEN@
25 @HAVE_MINIMUM_IFREQ@
26 @NEED_DAEMON@
27 @NEED_STRSEP@
28 @NEED_STRERROR@
29 #ifdef NEED_STRERROR
30 const char *isc_strerror(int);
31 #define strerror isc_strerror
32 #endif
33 @HAS_INET6_STRUCTS@
34 @HAVE_SIN6_SCOPE_ID@
35 @NEED_IN6ADDR_ANY@
36 @HAS_IN_ADDR6@
37 @HAVE_SOCKADDR_STORAGE@
38 @NEED_GETTIMEOFDAY@
39 @HAVE_STRNDUP@
40 @USE_FIONBIO_IOCTL@
41 @INNETGR_ARGS@
42 @SETNETGRENT_ARGS@
43 @USE_IFNAMELINKID@
44 @PORT_NONBLOCK@
45
46 #ifndef _POSIX_PATH_MAX
47 #define _POSIX_PATH_MAX 255
48 #endif
49 #ifndef PATH_MAX
50 #define PATH_MAX _POSIX_PATH_MAX
51 #endif
52
53 /*
54  * We need to know the IPv6 address family number even on IPv4-only systems.
55  * Note that this is NOT a protocol constant, and that if the system has its
56  * own AF_INET6, different from ours below, all of BIND's libraries and
57  * executables will need to be recompiled after the system <sys/socket.h>
58  * has had this type added.  The type number below is correct on most BSD-
59  * derived systems for which AF_INET6 is defined.
60  */
61 #ifndef AF_INET6
62 #define AF_INET6        24
63 #endif
64
65 #ifndef PF_INET6
66 #define PF_INET6        AF_INET6
67 #endif
68
69 #ifdef HAS_IN_ADDR6
70 /* Map to pre-RFC structure. */
71 #define in6_addr in_addr6
72 #endif
73
74 #ifndef HAS_INET6_STRUCTS
75 /* Replace with structure from later rev of O/S if known. */
76 struct in6_addr {
77         u_int8_t        s6_addr[16];
78 };
79
80 #define IN6ADDR_ANY_INIT \
81         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
82            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
83
84 #define IN6ADDR_LOOPBACK_INIT \
85         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
86            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
87
88 /* Replace with structure from later rev of O/S if known. */
89 struct sockaddr_in6 {
90 #ifdef  HAVE_SA_LEN
91         u_int8_t        sin6_len;       /* length of this struct */
92         u_int8_t        sin6_family;    /* AF_INET6 */
93 #else
94         u_int16_t       sin6_family;    /* AF_INET6 */
95 #endif
96         u_int16_t       sin6_port;      /* transport layer port # */
97         u_int32_t       sin6_flowinfo;  /* IPv6 flow information */
98         struct in6_addr sin6_addr;      /* IPv6 address */
99         u_int32_t       sin6_scope_id;  /* set of interfaces for a scope */
100 };
101 #endif  /* HAS_INET6_STRUCTS */
102
103 #ifdef BROKEN_IN6ADDR_INIT_MACROS
104 #undef IN6ADDR_ANY_INIT
105 #undef IN6ADDR_LOOPBACK_INIT
106 #endif
107
108 #ifdef _AIX
109 #ifndef IN6ADDR_ANY_INIT
110 #define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
111 #endif
112 #ifndef IN6ADDR_LOOPBACK_INIT
113 #if BYTE_ORDER == BIG_ENDIAN
114 #define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
115 #else
116 #define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
117 #endif
118 #endif
119 #endif
120
121 #ifndef IN6ADDR_ANY_INIT
122 #ifdef s6_addr
123 #define IN6ADDR_ANY_INIT \
124         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
125             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
126 #else
127 #define IN6ADDR_ANY_INIT \
128         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
129            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
130 #endif
131
132 #endif
133 #ifndef IN6ADDR_LOOPBACK_INIT
134 #ifdef s6_addr
135 #define IN6ADDR_LOOPBACK_INIT \
136         {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
137             0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
138 #else
139 #define IN6ADDR_LOOPBACK_INIT \
140         {{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
141            0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
142 #endif
143 #endif
144
145 #ifndef HAVE_SOCKADDR_STORAGE
146 #define __SS_MAXSIZE 128 
147 #define __SS_ALLIGSIZE (sizeof (long)) 
148
149 struct sockaddr_storage {
150 #ifdef  HAVE_SA_LEN
151         u_int8_t        ss_len;       /* address length */
152         u_int8_t        ss_family;    /* address family */
153         char            __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
154         long            __ss_align;
155         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
156 #else   
157         u_int16_t       ss_family;    /* address family */
158         char            __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
159         long            __ss_align;
160         char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
161 #endif
162 };
163 #endif
164
165
166 #if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
167 #define in6addr_any isc_in6addr_any
168 extern const struct in6_addr in6addr_any;
169 #endif
170
171 /*
172  * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
173  * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
174  */
175 #ifdef __GLIBC__
176 #if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
177 #undef IN6_ARE_ADDR_EQUAL
178 #undef IN6_IS_ADDR_UNSPECIFIED
179 #undef IN6_IS_ADDR_V4COMPAT
180 #undef IN6_IS_ADDR_V4MAPPED
181 #endif
182 #endif
183
184 #ifndef IN6_ARE_ADDR_EQUAL
185 #define IN6_ARE_ADDR_EQUAL(a,b) \
186    (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
187 #endif
188
189 #ifndef IN6_IS_ADDR_UNSPECIFIED
190 #define IN6_IS_ADDR_UNSPECIFIED(a)      \
191         IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
192 #endif
193
194 #ifndef IN6_IS_ADDR_LOOPBACK
195 extern const struct in6_addr isc_in6addr_loopback;
196 #define IN6_IS_ADDR_LOOPBACK(a) \
197         IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
198 #endif
199
200 #ifndef IN6_IS_ADDR_V4MAPPED
201 #define IN6_IS_ADDR_V4MAPPED(a) \
202         ((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
203         (a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
204         (a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
205         (a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
206         (a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
207         (a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
208 #endif
209
210 #ifndef IN6_IS_ADDR_SITELOCAL
211 #define IN6_IS_ADDR_SITELOCAL(a)        \
212         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
213 #endif
214
215 #ifndef IN6_IS_ADDR_LINKLOCAL
216 #define IN6_IS_ADDR_LINKLOCAL(a)        \
217         (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
218 #endif
219
220 #ifndef IN6_IS_ADDR_MULTICAST
221 #define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
222 #endif
223
224 #ifndef __IPV6_ADDR_MC_SCOPE
225 #define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
226 #endif
227
228 #ifndef __IPV6_ADDR_SCOPE_SITELOCAL
229 #define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
230 #endif
231 #ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
232 #define __IPV6_ADDR_SCOPE_ORGLOCAL  0x08
233 #endif
234
235 #ifndef IN6_IS_ADDR_MC_SITELOCAL
236 #define IN6_IS_ADDR_MC_SITELOCAL(a)     \
237         (IN6_IS_ADDR_MULTICAST(a) &&    \
238          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
239 #endif
240
241 #ifndef IN6_IS_ADDR_MC_ORGLOCAL
242 #define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
243         (IN6_IS_ADDR_MULTICAST(a) &&    \
244          (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
245 #endif
246
247 #ifndef INADDR_NONE
248 #define INADDR_NONE 0xffffffff
249 #endif
250
251 #ifndef MAXHOSTNAMELEN
252 #define MAXHOSTNAMELEN 256
253 #endif
254
255 #ifndef INET6_ADDRSTRLEN
256 /* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
257 #define INET6_ADDRSTRLEN 46
258 #endif
259
260 #ifndef MIN
261 #define MIN(x,y) (((x) <= (y)) ? (x) : (y))
262 #endif
263
264 #ifndef MAX
265 #define MAX(x,y) (((x) >= (y)) ? (x) : (y))
266 #endif
267
268 #ifdef NEED_DAEMON
269 int daemon(int nochdir, int noclose);
270 #endif
271   
272 #ifdef NEED_STRSEP
273 char * strsep(char **stringp, const char *delim);
274 #endif
275
276 #ifndef ALIGN
277 #define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
278 #endif
279
280 #ifdef NEED_SETGROUPENT
281 int setgroupent(int stayopen);
282 #endif
283
284 #ifdef NEED_GETGROUPLIST
285 int getgrouplist(GETGROUPLIST_ARGS);
286 #endif
287
288 #ifdef POSIX_GETGRNAM_R
289 int
290 __posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
291 #endif
292
293 #ifdef NEED_GETGRNAM_R
294 int
295 getgrnam_r(const char *,  struct group *, char *, size_t, struct group **);
296 #endif
297
298 #ifdef POSIX_GETGRGID_R
299 int
300 __posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
301 #endif
302
303 #ifdef NEED_GETGRGID_R
304 int
305 getgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
306 #endif
307
308 #ifdef NEED_GETGRENT_R
309 GROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
310 #endif
311
312 #ifdef NEED_SETGRENT_R
313 GROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
314 #endif
315
316 #ifdef NEED_ENDGRENT_R
317 GROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
318 #endif
319
320 #if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
321 NGR_R_RETURN
322 innetgr_r(const char *, const char *, const char *, const char *);
323 #endif
324
325 #ifdef NEED_SETNETGRENT_R
326 #ifdef NGR_R_SET_ARGS
327 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
328 #else
329 NGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup);
330 #endif
331 #endif
332
333 #ifdef NEED_ENDNETGRENT_R
334 #ifdef NGR_R_END_ARGS
335 NGR_R_END_RETURN endnetgrent_r(NGR_R_END_ARGS);
336 #else
337 NGR_R_END_RETURN endnetgrent_r(void);
338 #endif
339 #endif
340
341 #ifdef POSIX_GETPWNAM_R
342 int
343 __posix_getpwnam_r(const char *login,  struct passwd *pwptr,
344                 char *buf, size_t buflen, struct passwd **result);
345 #endif
346
347 #ifdef NEED_GETPWNAM_R
348 int
349 getpwnam_r(const char *login,  struct passwd *pwptr,
350                 char *buf, size_t buflen, struct passwd **result);
351 #endif
352
353 #ifdef POSIX_GETPWUID_R
354 int
355 __posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
356                 char *buf, int buflen, struct passwd **result);
357 #endif
358
359 #ifdef NEED_GETPWUID_R
360 int
361 getpwuid_r(uid_t uid, struct passwd *pwptr,
362                 char *buf, size_t buflen, struct passwd **result);
363 #endif
364
365 #ifdef NEED_SETPWENT_R
366 #ifdef PASS_R_ENT_ARGS
367 PASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
368 #else
369 PASS_R_SET_RETURN setpwent_r(void);
370 #endif
371
372 #endif
373
374 #ifdef NEED_SETPASSENT_R
375 #ifdef PASS_R_ENT_ARGS
376 PASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
377 #else
378 PASS_R_SET_RETURN setpassent_r(int stayopen);
379 #endif
380 #endif
381
382 #ifdef NEED_GETPWENT_R
383 PASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
384 #endif
385
386 #ifdef NEED_ENDPWENT_R
387 void endpwent_r(void);
388 #endif
389
390 #ifdef NEED_SETPASSENT
391 int setpassent(int stayopen);
392 #endif
393
394 #define gettimeofday isc__gettimeofday
395 #ifdef NEED_GETTIMEOFDAY
396 int isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
397 #else
398 int isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
399 #endif
400
401 int getnetgrent(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
402                 NGR_R_CONST char **domainp);
403
404 #ifdef NGR_R_ARGS
405 int getnetgrent_r(NGR_R_CONST char **machinep, NGR_R_CONST char **userp, 
406                   NGR_R_CONST char **domainp, NGR_R_ARGS);
407 #endif
408
409 #ifdef SETNETGRENT_ARGS
410 void setnetgrent(SETNETGRENT_ARGS);
411 #else
412 void setnetgrent(const char *netgroup);
413 #endif
414
415 void endnetgrent(void);
416
417 #ifdef INNETGR_ARGS
418 int innetgr(INNETGR_ARGS);
419 #else
420 int innetgr(const char *netgroup, const char *machine,
421             const char *user, const char *domain);
422 #endif
423
424 #ifdef NGR_R_SET_ARGS
425 NGR_R_SET_RETURN
426 setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
427 #else
428 NGR_R_SET_RETURN
429 setnetgrent_r(NGR_R_SET_CONST char *netgroup);
430 #endif
431
432 #ifdef NEED_STRTOUL
433 unsigned long strtoul(const char *, char **, int);
434 #endif
435
436 #ifdef NEED_SUN4PROTOS
437 #include <stdarg.h>
438 #ifndef __SIZE_TYPE__
439 #define __SIZE_TYPE__ int
440 #endif
441 struct sockaddr;
442 struct iovec;
443 struct timeval;
444 struct timezone;
445 int fprintf(FILE *, const char *, ...);
446 int getsockname(int, struct sockaddr *, int *);
447 int getpeername(int, struct sockaddr *, int *);
448 int socket(int, int, int);
449 int connect(int, const struct sockaddr *, int);
450 int writev(int, struct iovec *, int);
451 int readv(int, struct iovec *, int);
452 int send(int, const char *, int, int);
453 void bzero(char *, int);
454 int recvfrom(int, char *, int, int, struct sockaddr *, int *);
455 int syslog(int, const char *, ... );
456 int printf(const char *, ...);
457 __SIZE_TYPE__ fread(void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
458 __SIZE_TYPE__ fwrite(const void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
459 int fclose(FILE *);
460 int ungetc(int, FILE *);
461 int scanf(const char *, ...);
462 int sscanf(const char *, const char *, ... );
463 int tolower(int);
464 int toupper(int);
465 int strcasecmp(const char *, const char *);
466 int strncasecmp(const char *, const char *, int);
467 int select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
468 #ifdef gettimeofday
469 #undef gettimeofday
470 int gettimeofday(struct timeval *, struct timezone *);
471 #define gettimeofday isc__gettimeofday
472 #else
473 int gettimeofday(struct timeval *, struct timezone *);
474 #endif
475 long strtol(const char*, char **, int);
476 int fseek(FILE *, long, int);
477 int setsockopt(int, int, int, const char *, int);
478 int bind(int, const struct sockaddr *, int);
479 void bcopy(char *, char *, int);
480 int fputc(char, FILE *);
481 int listen(int, int);
482 int accept(int, struct sockaddr *, int *);
483 int getsockopt(int, int, int, char *, int *);
484 int vfprintf(FILE *, const char *, va_list);
485 int fflush(FILE *);
486 int fgetc(FILE *);
487 int fputs(const char *, FILE *);
488 int fchown(int, int, int);
489 void setbuf(FILE *, char *);
490 int gethostname(char *, int);
491 int rename(const char *, const char *);
492 time_t time(time_t *);
493 int fscanf(FILE *, const char *, ...);
494 int sscanf(const char *, const char *, ...);
495 int ioctl(int, int, caddr_t);
496 void perror(const char *);
497
498 #if !defined(__USE_FIXED_PROTOTYPES__) && !defined(__cplusplus) && !defined(__STRICT_ANSI__)
499 /*
500  * 'gcc -ansi' changes the prototype for vsprintf().
501  * Use this prototype when 'gcc -ansi' is not in effect.
502  */
503 char *vsprintf(char *, const char *, va_list);
504 #endif
505 #endif 
506
507 #endif