14bd3cce6SAxel Dörfler/*
24bd3cce6SAxel Dörfler * Copyright (C) 2004-2008  Internet Systems Consortium, Inc. ("ISC")
34bd3cce6SAxel Dörfler * Copyright (C) 2001-2003  Internet Software Consortium.
44bd3cce6SAxel Dörfler *
54bd3cce6SAxel Dörfler * Permission to use, copy, modify, and/or distribute this software for any
64bd3cce6SAxel Dörfler * purpose with or without fee is hereby granted, provided that the above
74bd3cce6SAxel Dörfler * copyright notice and this permission notice appear in all copies.
84bd3cce6SAxel Dörfler *
94bd3cce6SAxel Dörfler * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
104bd3cce6SAxel Dörfler * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
114bd3cce6SAxel Dörfler * AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
124bd3cce6SAxel Dörfler * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
134bd3cce6SAxel Dörfler * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
144bd3cce6SAxel Dörfler * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
154bd3cce6SAxel Dörfler * PERFORMANCE OF THIS SOFTWARE.
164bd3cce6SAxel Dörfler */
174bd3cce6SAxel Dörfler
184bd3cce6SAxel Dörfler/* $Id: port_after.h.in,v 1.60 2008/02/28 05:34:17 marka Exp $ */
194bd3cce6SAxel Dörfler
205d7cf21bSWaldemar Kornewald#ifndef port_after_h
215d7cf21bSWaldemar Kornewald#define port_after_h
225d7cf21bSWaldemar Kornewald
233aeed660SJérôme Duval#ifdef __HAIKU__
243aeed660SJérôme Duval	#ifdef _STRING_H_
253aeed660SJérôme Duval		#include <strings.h>
263aeed660SJérôme Duval	#endif
273aeed660SJérôme Duval#endif
284bd3cce6SAxel Dörfler#include <stdio.h>
295d7cf21bSWaldemar Kornewald#include <sys/types.h>
304bd3cce6SAxel Dörfler#include <sys/socket.h>
315d7cf21bSWaldemar Kornewald#include <sys/param.h>
324bd3cce6SAxel Dörfler#include <sys/time.h>
334bd3cce6SAxel Dörfler#if (!defined(BSD)) || (BSD < 199306)
344bd3cce6SAxel Dörfler#include <sys/bitypes.h>
355d7cf21bSWaldemar Kornewald#endif
364bd3cce6SAxel Dörfler#ifdef HAVE_INTTYPES_H
374bd3cce6SAxel Dörfler#include <inttypes.h>
384bd3cce6SAxel Dörfler#endif
394bd3cce6SAxel Dörfler#ifdef HAVE_SYS_SELECT_H
404bd3cce6SAxel Dörfler#include <sys/select.h>
414bd3cce6SAxel Dörfler#endif /* HAVE_SYS_SELECT_H */
425d7cf21bSWaldemar Kornewald
434bd3cce6SAxel Dörfler#ifdef REENABLE_SEND
444bd3cce6SAxel Dörfler#undef send
454bd3cce6SAxel Dörfler#endif
465d7cf21bSWaldemar Kornewald
474bd3cce6SAxel Dörfler#undef NEED_PSELECT
485d7cf21bSWaldemar Kornewald#define HAVE_SA_LEN 1
495d7cf21bSWaldemar Kornewald#undef HAVE_MINIMUM_IFREQ
504bd3cce6SAxel Dörfler#undef NEED_DAEMON
514bd3cce6SAxel Dörfler	/* manual Haiku change */
525d7cf21bSWaldemar Kornewald#define NEED_STRSEP 1
535d7cf21bSWaldemar Kornewald#undef NEED_STRERROR
544bd3cce6SAxel Dörfler#ifdef NEED_STRERROR
554bd3cce6SAxel Dörflerconst char *isc_strerror(int);
564bd3cce6SAxel Dörfler#define strerror isc_strerror
574bd3cce6SAxel Dörfler#endif
584bd3cce6SAxel Dörfler#define HAS_INET6_STRUCTS 1
595d7cf21bSWaldemar Kornewald#define HAVE_SIN6_SCOPE_ID 1
60e054bfbfSAxel Dörfler#undef NEED_IN6ADDR_ANY
61e054bfbfSAxel Dörfler#define HAS_IN_ADDR6
624bd3cce6SAxel Dörfler#define HAVE_SOCKADDR_STORAGE 1
635d7cf21bSWaldemar Kornewald#undef NEED_GETTIMEOFDAY
644bd3cce6SAxel Dörfler#define HAVE_STRNDUP 1
655d7cf21bSWaldemar Kornewald#undef USE_FIONBIO_IOCTL
665d7cf21bSWaldemar Kornewald#undef INNETGR_ARGS
675d7cf21bSWaldemar Kornewald#undef SETNETGRENT_ARGS
685d7cf21bSWaldemar Kornewald#undef USE_IFNAMELINKID
695d7cf21bSWaldemar Kornewald#define PORT_NONBLOCK O_NONBLOCK
705d7cf21bSWaldemar Kornewald
714bd3cce6SAxel Dörfler#ifndef _POSIX_PATH_MAX
724bd3cce6SAxel Dörfler#define _POSIX_PATH_MAX 255
734bd3cce6SAxel Dörfler#endif
744bd3cce6SAxel Dörfler#ifndef PATH_MAX
754bd3cce6SAxel Dörfler#define PATH_MAX _POSIX_PATH_MAX
764bd3cce6SAxel Dörfler#endif
774bd3cce6SAxel Dörfler
785d7cf21bSWaldemar Kornewald/*
795d7cf21bSWaldemar Kornewald * We need to know the IPv6 address family number even on IPv4-only systems.
805d7cf21bSWaldemar Kornewald * Note that this is NOT a protocol constant, and that if the system has its
815d7cf21bSWaldemar Kornewald * own AF_INET6, different from ours below, all of BIND's libraries and
825d7cf21bSWaldemar Kornewald * executables will need to be recompiled after the system <sys/socket.h>
835d7cf21bSWaldemar Kornewald * has had this type added.  The type number below is correct on most BSD-
845d7cf21bSWaldemar Kornewald * derived systems for which AF_INET6 is defined.
855d7cf21bSWaldemar Kornewald */
865d7cf21bSWaldemar Kornewald#ifndef AF_INET6
875d7cf21bSWaldemar Kornewald#define AF_INET6        24
885d7cf21bSWaldemar Kornewald#endif
895d7cf21bSWaldemar Kornewald
905d7cf21bSWaldemar Kornewald#ifndef PF_INET6
915d7cf21bSWaldemar Kornewald#define PF_INET6        AF_INET6
925d7cf21bSWaldemar Kornewald#endif
935d7cf21bSWaldemar Kornewald
945d7cf21bSWaldemar Kornewald#ifndef HAS_INET6_STRUCTS
954bd3cce6SAxel Dörfler/* Replace with structure from later rev of O/S if known. */
964bd3cce6SAxel Dörflerstruct in6_addr {
974bd3cce6SAxel Dörfler	u_int8_t        s6_addr[16];
984bd3cce6SAxel Dörfler};
995d7cf21bSWaldemar Kornewald
1005d7cf21bSWaldemar Kornewald#define IN6ADDR_ANY_INIT \
1015d7cf21bSWaldemar Kornewald	{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
1025d7cf21bSWaldemar Kornewald	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
1035d7cf21bSWaldemar Kornewald
1045d7cf21bSWaldemar Kornewald#define IN6ADDR_LOOPBACK_INIT \
1055d7cf21bSWaldemar Kornewald	{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
1065d7cf21bSWaldemar Kornewald	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
1075d7cf21bSWaldemar Kornewald
1084bd3cce6SAxel Dörfler/* Replace with structure from later rev of O/S if known. */
1094bd3cce6SAxel Dörflerstruct sockaddr_in6 {
1104bd3cce6SAxel Dörfler#ifdef  HAVE_SA_LEN
1114bd3cce6SAxel Dörfler	u_int8_t        sin6_len;       /* length of this struct */
1124bd3cce6SAxel Dörfler	u_int8_t        sin6_family;    /* AF_INET6 */
1134bd3cce6SAxel Dörfler#else
1144bd3cce6SAxel Dörfler	u_int16_t       sin6_family;    /* AF_INET6 */
1154bd3cce6SAxel Dörfler#endif
1164bd3cce6SAxel Dörfler	u_int16_t       sin6_port;      /* transport layer port # */
1174bd3cce6SAxel Dörfler	u_int32_t       sin6_flowinfo;  /* IPv6 flow information */
1184bd3cce6SAxel Dörfler	struct in6_addr sin6_addr;      /* IPv6 address */
1194bd3cce6SAxel Dörfler	u_int32_t       sin6_scope_id;  /* set of interfaces for a scope */
1204bd3cce6SAxel Dörfler};
1215d7cf21bSWaldemar Kornewald#endif  /* HAS_INET6_STRUCTS */
1225d7cf21bSWaldemar Kornewald
1235d7cf21bSWaldemar Kornewald#ifdef BROKEN_IN6ADDR_INIT_MACROS
1245d7cf21bSWaldemar Kornewald#undef IN6ADDR_ANY_INIT
1255d7cf21bSWaldemar Kornewald#undef IN6ADDR_LOOPBACK_INIT
1265d7cf21bSWaldemar Kornewald#endif
1275d7cf21bSWaldemar Kornewald
1285d7cf21bSWaldemar Kornewald#ifdef _AIX
1295d7cf21bSWaldemar Kornewald#ifndef IN6ADDR_ANY_INIT
1305d7cf21bSWaldemar Kornewald#define IN6ADDR_ANY_INIT {{{ 0, 0, 0, 0 }}}
1315d7cf21bSWaldemar Kornewald#endif
1325d7cf21bSWaldemar Kornewald#ifndef IN6ADDR_LOOPBACK_INIT
1335d7cf21bSWaldemar Kornewald#if BYTE_ORDER == BIG_ENDIAN
1345d7cf21bSWaldemar Kornewald#define IN6ADDR_LOOPBACK_INIT {{{ 0, 0, 0, 1 }}}
1355d7cf21bSWaldemar Kornewald#else
1365d7cf21bSWaldemar Kornewald#define IN6ADDR_LOOPBACK_INIT {{{0, 0, 0, 0x01000000}}}
1375d7cf21bSWaldemar Kornewald#endif
1385d7cf21bSWaldemar Kornewald#endif
1395d7cf21bSWaldemar Kornewald#endif
1405d7cf21bSWaldemar Kornewald
141e054bfbfSAxel Dörfler#ifdef __HAIKU__
142e054bfbfSAxel Dörfler#define isc_in6addr_any in6addr_any
143e054bfbfSAxel Dörfler#define isc_in6addr_loopback in6addr_loopback
144e054bfbfSAxel Dörfler#endif
145e054bfbfSAxel Dörfler
1465d7cf21bSWaldemar Kornewald#ifndef IN6ADDR_ANY_INIT
1475d7cf21bSWaldemar Kornewald#ifdef s6_addr
1485d7cf21bSWaldemar Kornewald#define IN6ADDR_ANY_INIT \
1495d7cf21bSWaldemar Kornewald	{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
1505d7cf21bSWaldemar Kornewald	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
1515d7cf21bSWaldemar Kornewald#else
1525d7cf21bSWaldemar Kornewald#define IN6ADDR_ANY_INIT \
1535d7cf21bSWaldemar Kornewald	{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
1545d7cf21bSWaldemar Kornewald	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}
1555d7cf21bSWaldemar Kornewald#endif
1565d7cf21bSWaldemar Kornewald
1575d7cf21bSWaldemar Kornewald#endif
1585d7cf21bSWaldemar Kornewald#ifndef IN6ADDR_LOOPBACK_INIT
1595d7cf21bSWaldemar Kornewald#ifdef s6_addr
1605d7cf21bSWaldemar Kornewald#define IN6ADDR_LOOPBACK_INIT \
1615d7cf21bSWaldemar Kornewald	{{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
1625d7cf21bSWaldemar Kornewald	    0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}}
1635d7cf21bSWaldemar Kornewald#else
1645d7cf21bSWaldemar Kornewald#define IN6ADDR_LOOPBACK_INIT \
1655d7cf21bSWaldemar Kornewald	{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
1665d7cf21bSWaldemar Kornewald	   0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 }}
1675d7cf21bSWaldemar Kornewald#endif
1685d7cf21bSWaldemar Kornewald#endif
1695d7cf21bSWaldemar Kornewald
1705d7cf21bSWaldemar Kornewald#ifndef HAVE_SOCKADDR_STORAGE
1714bd3cce6SAxel Dörfler#define __SS_MAXSIZE 128
1724bd3cce6SAxel Dörfler#define __SS_ALLIGSIZE (sizeof (long))
1735d7cf21bSWaldemar Kornewald
1745d7cf21bSWaldemar Kornewaldstruct sockaddr_storage {
1755d7cf21bSWaldemar Kornewald#ifdef  HAVE_SA_LEN
1764bd3cce6SAxel Dörfler	u_int8_t        ss_len;       /* address length */
1774bd3cce6SAxel Dörfler	u_int8_t        ss_family;    /* address family */
1784bd3cce6SAxel Dörfler	char            __ss_pad1[__SS_ALLIGSIZE - 2 * sizeof(u_int8_t)];
1794bd3cce6SAxel Dörfler	long            __ss_align;
1804bd3cce6SAxel Dörfler	char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
1814bd3cce6SAxel Dörfler#else
1824bd3cce6SAxel Dörfler	u_int16_t       ss_family;    /* address family */
1834bd3cce6SAxel Dörfler	char            __ss_pad1[__SS_ALLIGSIZE - sizeof(u_int16_t)];
1844bd3cce6SAxel Dörfler	long            __ss_align;
1854bd3cce6SAxel Dörfler	char            __ss_pad2[__SS_MAXSIZE - 2 * __SS_ALLIGSIZE];
1865d7cf21bSWaldemar Kornewald#endif
1875d7cf21bSWaldemar Kornewald};
1885d7cf21bSWaldemar Kornewald#endif
1895d7cf21bSWaldemar Kornewald
1905d7cf21bSWaldemar Kornewald
1915d7cf21bSWaldemar Kornewald#if !defined(HAS_INET6_STRUCTS) || defined(NEED_IN6ADDR_ANY)
1925d7cf21bSWaldemar Kornewald#define in6addr_any isc_in6addr_any
1935d7cf21bSWaldemar Kornewaldextern const struct in6_addr in6addr_any;
1945d7cf21bSWaldemar Kornewald#endif
1955d7cf21bSWaldemar Kornewald
1965d7cf21bSWaldemar Kornewald/*
1975d7cf21bSWaldemar Kornewald * IN6_ARE_ADDR_EQUAL, IN6_IS_ADDR_UNSPECIFIED, IN6_IS_ADDR_V4COMPAT and
1985d7cf21bSWaldemar Kornewald * IN6_IS_ADDR_V4MAPPED are broken in glibc 2.1.
1995d7cf21bSWaldemar Kornewald */
2005d7cf21bSWaldemar Kornewald#ifdef __GLIBC__
2015d7cf21bSWaldemar Kornewald#if __GLIBC__ < 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ < 2)
2025d7cf21bSWaldemar Kornewald#undef IN6_ARE_ADDR_EQUAL
2035d7cf21bSWaldemar Kornewald#undef IN6_IS_ADDR_UNSPECIFIED
2045d7cf21bSWaldemar Kornewald#undef IN6_IS_ADDR_V4COMPAT
2055d7cf21bSWaldemar Kornewald#undef IN6_IS_ADDR_V4MAPPED
2065d7cf21bSWaldemar Kornewald#endif
2075d7cf21bSWaldemar Kornewald#endif
2085d7cf21bSWaldemar Kornewald
2095d7cf21bSWaldemar Kornewald#ifndef IN6_ARE_ADDR_EQUAL
2105d7cf21bSWaldemar Kornewald#define IN6_ARE_ADDR_EQUAL(a,b) \
2115d7cf21bSWaldemar Kornewald   (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
2125d7cf21bSWaldemar Kornewald#endif
2135d7cf21bSWaldemar Kornewald
2145d7cf21bSWaldemar Kornewald#ifndef IN6_IS_ADDR_UNSPECIFIED
2155d7cf21bSWaldemar Kornewald#define IN6_IS_ADDR_UNSPECIFIED(a)      \
2165d7cf21bSWaldemar Kornewald	IN6_ARE_ADDR_EQUAL(a, &in6addr_any)
2175d7cf21bSWaldemar Kornewald#endif
2185d7cf21bSWaldemar Kornewald
2195d7cf21bSWaldemar Kornewald#ifndef IN6_IS_ADDR_LOOPBACK
2205d7cf21bSWaldemar Kornewaldextern const struct in6_addr isc_in6addr_loopback;
2215d7cf21bSWaldemar Kornewald#define IN6_IS_ADDR_LOOPBACK(a) \
2225d7cf21bSWaldemar Kornewald	IN6_ARE_ADDR_EQUAL(a, &isc_in6addr_loopback)
2235d7cf21bSWaldemar Kornewald#endif
2245d7cf21bSWaldemar Kornewald
2255d7cf21bSWaldemar Kornewald#ifndef IN6_IS_ADDR_V4MAPPED
2265d7cf21bSWaldemar Kornewald#define IN6_IS_ADDR_V4MAPPED(a)	\
2275d7cf21bSWaldemar Kornewald	((a)->s6_addr[0] == 0x00 && (a)->s6_addr[1] == 0x00 && \
2285d7cf21bSWaldemar Kornewald	(a)->s6_addr[2] == 0x00 && (a)->s6_addr[3] == 0x00 && \
2295d7cf21bSWaldemar Kornewald	(a)->s6_addr[4] == 0x00 && (a)->s6_addr[5] == 0x00 && \
2305d7cf21bSWaldemar Kornewald	(a)->s6_addr[6] == 0x00 && (a)->s6_addr[9] == 0x00 && \
2315d7cf21bSWaldemar Kornewald	(a)->s6_addr[8] == 0x00 && (a)->s6_addr[9] == 0x00 && \
2325d7cf21bSWaldemar Kornewald	(a)->s6_addr[10] == 0xff && (a)->s6_addr[11] == 0xff)
2335d7cf21bSWaldemar Kornewald#endif
2345d7cf21bSWaldemar Kornewald
2355d7cf21bSWaldemar Kornewald#ifndef IN6_IS_ADDR_SITELOCAL
2365d7cf21bSWaldemar Kornewald#define IN6_IS_ADDR_SITELOCAL(a)        \
2375d7cf21bSWaldemar Kornewald	(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
2385d7cf21bSWaldemar Kornewald#endif
2395d7cf21bSWaldemar Kornewald
2405d7cf21bSWaldemar Kornewald#ifndef IN6_IS_ADDR_LINKLOCAL
2415d7cf21bSWaldemar Kornewald#define IN6_IS_ADDR_LINKLOCAL(a)        \
2425d7cf21bSWaldemar Kornewald	(((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
2435d7cf21bSWaldemar Kornewald#endif
2445d7cf21bSWaldemar Kornewald
2455d7cf21bSWaldemar Kornewald#ifndef IN6_IS_ADDR_MULTICAST
2465d7cf21bSWaldemar Kornewald#define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
2475d7cf21bSWaldemar Kornewald#endif
2485d7cf21bSWaldemar Kornewald
2495d7cf21bSWaldemar Kornewald#ifndef __IPV6_ADDR_MC_SCOPE
2505d7cf21bSWaldemar Kornewald#define __IPV6_ADDR_MC_SCOPE(a)         ((a)->s6_addr[1] & 0x0f)
2515d7cf21bSWaldemar Kornewald#endif
2525d7cf21bSWaldemar Kornewald
2535d7cf21bSWaldemar Kornewald#ifndef __IPV6_ADDR_SCOPE_SITELOCAL
2545d7cf21bSWaldemar Kornewald#define __IPV6_ADDR_SCOPE_SITELOCAL 0x05
2555d7cf21bSWaldemar Kornewald#endif
2565d7cf21bSWaldemar Kornewald#ifndef __IPV6_ADDR_SCOPE_ORGLOCAL
2575d7cf21bSWaldemar Kornewald#define __IPV6_ADDR_SCOPE_ORGLOCAL  0x08
2585d7cf21bSWaldemar Kornewald#endif
2595d7cf21bSWaldemar Kornewald
2605d7cf21bSWaldemar Kornewald#ifndef IN6_IS_ADDR_MC_SITELOCAL
2615d7cf21bSWaldemar Kornewald#define IN6_IS_ADDR_MC_SITELOCAL(a)     \
2625d7cf21bSWaldemar Kornewald	(IN6_IS_ADDR_MULTICAST(a) &&    \
2635d7cf21bSWaldemar Kornewald	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_SITELOCAL))
2645d7cf21bSWaldemar Kornewald#endif
2655d7cf21bSWaldemar Kornewald
2665d7cf21bSWaldemar Kornewald#ifndef IN6_IS_ADDR_MC_ORGLOCAL
2675d7cf21bSWaldemar Kornewald#define IN6_IS_ADDR_MC_ORGLOCAL(a)      \
2685d7cf21bSWaldemar Kornewald	(IN6_IS_ADDR_MULTICAST(a) &&    \
2695d7cf21bSWaldemar Kornewald	 (__IPV6_ADDR_MC_SCOPE(a) == __IPV6_ADDR_SCOPE_ORGLOCAL))
2705d7cf21bSWaldemar Kornewald#endif
2715d7cf21bSWaldemar Kornewald
2725d7cf21bSWaldemar Kornewald#ifndef INADDR_NONE
2735d7cf21bSWaldemar Kornewald#define INADDR_NONE 0xffffffff
2745d7cf21bSWaldemar Kornewald#endif
2755d7cf21bSWaldemar Kornewald
2765d7cf21bSWaldemar Kornewald#ifndef MAXHOSTNAMELEN
2775d7cf21bSWaldemar Kornewald#define MAXHOSTNAMELEN 256
2785d7cf21bSWaldemar Kornewald#endif
2795d7cf21bSWaldemar Kornewald
2805d7cf21bSWaldemar Kornewald#ifndef INET6_ADDRSTRLEN
2815d7cf21bSWaldemar Kornewald/* sizeof("aaaa:bbbb:cccc:dddd:eeee:ffff:123.123.123.123") */
2825d7cf21bSWaldemar Kornewald#define INET6_ADDRSTRLEN 46
2835d7cf21bSWaldemar Kornewald#endif
2845d7cf21bSWaldemar Kornewald
2855d7cf21bSWaldemar Kornewald#ifndef MIN
2865d7cf21bSWaldemar Kornewald#define MIN(x,y) (((x) <= (y)) ? (x) : (y))
2875d7cf21bSWaldemar Kornewald#endif
2885d7cf21bSWaldemar Kornewald
2895d7cf21bSWaldemar Kornewald#ifndef MAX
2905d7cf21bSWaldemar Kornewald#define MAX(x,y) (((x) >= (y)) ? (x) : (y))
2915d7cf21bSWaldemar Kornewald#endif
2925d7cf21bSWaldemar Kornewald
2935d7cf21bSWaldemar Kornewald#ifdef NEED_DAEMON
2945d7cf21bSWaldemar Kornewaldint daemon(int nochdir, int noclose);
2955d7cf21bSWaldemar Kornewald#endif
2964bd3cce6SAxel Dörfler
2975d7cf21bSWaldemar Kornewald#ifdef NEED_STRSEP
2985d7cf21bSWaldemar Kornewaldchar * strsep(char **stringp, const char *delim);
2995d7cf21bSWaldemar Kornewald#endif
3005d7cf21bSWaldemar Kornewald
3015d7cf21bSWaldemar Kornewald#ifndef ALIGN
3024bd3cce6SAxel Dörfler#define ALIGN(p) (((uintptr_t)(p) + (sizeof(long) - 1)) & ~(sizeof(long) - 1))
3035d7cf21bSWaldemar Kornewald#endif
3045d7cf21bSWaldemar Kornewald
3055d7cf21bSWaldemar Kornewald#ifdef NEED_SETGROUPENT
3065d7cf21bSWaldemar Kornewaldint setgroupent(int stayopen);
3075d7cf21bSWaldemar Kornewald#endif
3085d7cf21bSWaldemar Kornewald
3095d7cf21bSWaldemar Kornewald#ifdef NEED_GETGROUPLIST
3105d7cf21bSWaldemar Kornewaldint getgrouplist(GETGROUPLIST_ARGS);
3115d7cf21bSWaldemar Kornewald#endif
3125d7cf21bSWaldemar Kornewald
3135d7cf21bSWaldemar Kornewald#ifdef POSIX_GETGRNAM_R
3145d7cf21bSWaldemar Kornewaldint
3155d7cf21bSWaldemar Kornewald__posix_getgrnam_r(const char *, struct group *, char *, int, struct group **);
3165d7cf21bSWaldemar Kornewald#endif
3175d7cf21bSWaldemar Kornewald
3185d7cf21bSWaldemar Kornewald#ifdef NEED_GETGRNAM_R
3195d7cf21bSWaldemar Kornewaldint
3205d7cf21bSWaldemar Kornewaldgetgrnam_r(const char *,  struct group *, char *, size_t, struct group **);
3215d7cf21bSWaldemar Kornewald#endif
3225d7cf21bSWaldemar Kornewald
3235d7cf21bSWaldemar Kornewald#ifdef POSIX_GETGRGID_R
3245d7cf21bSWaldemar Kornewaldint
3255d7cf21bSWaldemar Kornewald__posix_getgrgid_r(gid_t, struct group *, char *, int, struct group **) ;
3265d7cf21bSWaldemar Kornewald#endif
3275d7cf21bSWaldemar Kornewald
3285d7cf21bSWaldemar Kornewald#ifdef NEED_GETGRGID_R
3295d7cf21bSWaldemar Kornewaldint
3305d7cf21bSWaldemar Kornewaldgetgrgid_r(gid_t, struct group *, char *, size_t, struct group **);
3315d7cf21bSWaldemar Kornewald#endif
3325d7cf21bSWaldemar Kornewald
3335d7cf21bSWaldemar Kornewald#ifdef NEED_GETGRENT_R
3345d7cf21bSWaldemar KornewaldGROUP_R_RETURN getgrent_r(struct group *gptr, GROUP_R_ARGS);
3355d7cf21bSWaldemar Kornewald#endif
3365d7cf21bSWaldemar Kornewald
3375d7cf21bSWaldemar Kornewald#ifdef NEED_SETGRENT_R
3385d7cf21bSWaldemar KornewaldGROUP_R_SET_RETURN setgrent_r(GROUP_R_ENT_ARGS);
3395d7cf21bSWaldemar Kornewald#endif
3405d7cf21bSWaldemar Kornewald
3415d7cf21bSWaldemar Kornewald#ifdef NEED_ENDGRENT_R
3425d7cf21bSWaldemar KornewaldGROUP_R_END_RETURN endgrent_r(GROUP_R_ENT_ARGS);
3435d7cf21bSWaldemar Kornewald#endif
3445d7cf21bSWaldemar Kornewald
3454bd3cce6SAxel Dörfler#if defined(NEED_INNETGR_R) && defined(NGR_R_RETURN)
3465d7cf21bSWaldemar KornewaldNGR_R_RETURN
3475d7cf21bSWaldemar Kornewaldinnetgr_r(const char *, const char *, const char *, const char *);
3485d7cf21bSWaldemar Kornewald#endif
3495d7cf21bSWaldemar Kornewald
3505d7cf21bSWaldemar Kornewald#ifdef NEED_SETNETGRENT_R
3514bd3cce6SAxel Dörfler#ifdef NGR_R_SET_ARGS
3524bd3cce6SAxel DörflerNGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
3535d7cf21bSWaldemar Kornewald#else
3544bd3cce6SAxel DörflerNGR_R_SET_RETURN setnetgrent_r(NGR_R_SET_CONST char *netgroup);
3555d7cf21bSWaldemar Kornewald#endif
3565d7cf21bSWaldemar Kornewald#endif
3575d7cf21bSWaldemar Kornewald
3585d7cf21bSWaldemar Kornewald#ifdef NEED_ENDNETGRENT_R
3594bd3cce6SAxel Dörfler#ifdef NGR_R_END_ARGS
3604bd3cce6SAxel DörflerNGR_R_END_RETURN endnetgrent_r(NGR_R_END_ARGS);
3615d7cf21bSWaldemar Kornewald#else
3625d7cf21bSWaldemar KornewaldNGR_R_END_RETURN endnetgrent_r(void);
3635d7cf21bSWaldemar Kornewald#endif
3645d7cf21bSWaldemar Kornewald#endif
3655d7cf21bSWaldemar Kornewald
3665d7cf21bSWaldemar Kornewald#ifdef POSIX_GETPWNAM_R
3675d7cf21bSWaldemar Kornewaldint
3685d7cf21bSWaldemar Kornewald__posix_getpwnam_r(const char *login,  struct passwd *pwptr,
3694bd3cce6SAxel Dörfler		char *buf, size_t buflen, struct passwd **result);
3705d7cf21bSWaldemar Kornewald#endif
3715d7cf21bSWaldemar Kornewald
3725d7cf21bSWaldemar Kornewald#ifdef NEED_GETPWNAM_R
3735d7cf21bSWaldemar Kornewaldint
3745d7cf21bSWaldemar Kornewaldgetpwnam_r(const char *login,  struct passwd *pwptr,
3754bd3cce6SAxel Dörfler		char *buf, size_t buflen, struct passwd **result);
3765d7cf21bSWaldemar Kornewald#endif
3775d7cf21bSWaldemar Kornewald
3785d7cf21bSWaldemar Kornewald#ifdef POSIX_GETPWUID_R
3795d7cf21bSWaldemar Kornewaldint
3805d7cf21bSWaldemar Kornewald__posix_getpwuid_r(uid_t uid, struct passwd *pwptr,
3814bd3cce6SAxel Dörfler		char *buf, int buflen, struct passwd **result);
3825d7cf21bSWaldemar Kornewald#endif
3835d7cf21bSWaldemar Kornewald
3845d7cf21bSWaldemar Kornewald#ifdef NEED_GETPWUID_R
3855d7cf21bSWaldemar Kornewaldint
3865d7cf21bSWaldemar Kornewaldgetpwuid_r(uid_t uid, struct passwd *pwptr,
3874bd3cce6SAxel Dörfler		char *buf, size_t buflen, struct passwd **result);
3885d7cf21bSWaldemar Kornewald#endif
3895d7cf21bSWaldemar Kornewald
3905d7cf21bSWaldemar Kornewald#ifdef NEED_SETPWENT_R
3915d7cf21bSWaldemar Kornewald#ifdef PASS_R_ENT_ARGS
3925d7cf21bSWaldemar KornewaldPASS_R_SET_RETURN setpwent_r(PASS_R_ENT_ARGS);
3935d7cf21bSWaldemar Kornewald#else
3945d7cf21bSWaldemar KornewaldPASS_R_SET_RETURN setpwent_r(void);
3955d7cf21bSWaldemar Kornewald#endif
3965d7cf21bSWaldemar Kornewald
3975d7cf21bSWaldemar Kornewald#endif
3985d7cf21bSWaldemar Kornewald
3995d7cf21bSWaldemar Kornewald#ifdef NEED_SETPASSENT_R
4005d7cf21bSWaldemar Kornewald#ifdef PASS_R_ENT_ARGS
4015d7cf21bSWaldemar KornewaldPASS_R_SET_RETURN setpassent_r(int stayopen, PASS_R_ENT_ARGS);
4025d7cf21bSWaldemar Kornewald#else
4035d7cf21bSWaldemar KornewaldPASS_R_SET_RETURN setpassent_r(int stayopen);
4045d7cf21bSWaldemar Kornewald#endif
4055d7cf21bSWaldemar Kornewald#endif
4065d7cf21bSWaldemar Kornewald
4075d7cf21bSWaldemar Kornewald#ifdef NEED_GETPWENT_R
4085d7cf21bSWaldemar KornewaldPASS_R_RETURN getpwent_r(struct passwd *pwptr, PASS_R_ARGS);
4095d7cf21bSWaldemar Kornewald#endif
4105d7cf21bSWaldemar Kornewald
4115d7cf21bSWaldemar Kornewald#ifdef NEED_ENDPWENT_R
4125d7cf21bSWaldemar Kornewaldvoid endpwent_r(void);
4135d7cf21bSWaldemar Kornewald#endif
4145d7cf21bSWaldemar Kornewald
4155d7cf21bSWaldemar Kornewald#ifdef NEED_SETPASSENT
4165d7cf21bSWaldemar Kornewaldint setpassent(int stayopen);
4175d7cf21bSWaldemar Kornewald#endif
4185d7cf21bSWaldemar Kornewald
4194bd3cce6SAxel Dörfler#ifndef __HAIKU__
4204bd3cce6SAxel Dörfler#define gettimeofday isc__gettimeofday
4214bd3cce6SAxel Dörfler#ifdef NEED_GETTIMEOFDAY
4224bd3cce6SAxel Dörflerint isc__gettimeofday(struct timeval *tvp, struct _TIMEZONE *tzp);
4234bd3cce6SAxel Dörfler#else
4244bd3cce6SAxel Dörflerint isc__gettimeofday(struct timeval *tp, struct timezone *tzp);
4254bd3cce6SAxel Dörfler#endif
4264bd3cce6SAxel Dörfler#endif
4274bd3cce6SAxel Dörfler
4284bd3cce6SAxel Dörflerint getnetgrent(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
4294bd3cce6SAxel Dörfler		NGR_R_CONST char **domainp);
4305d7cf21bSWaldemar Kornewald
4314bd3cce6SAxel Dörfler#ifdef NGR_R_ARGS
4324bd3cce6SAxel Dörflerint getnetgrent_r(NGR_R_CONST char **machinep, NGR_R_CONST char **userp,
4334bd3cce6SAxel Dörfler		  NGR_R_CONST char **domainp, NGR_R_ARGS);
4344bd3cce6SAxel Dörfler#endif
4355d7cf21bSWaldemar Kornewald
4365d7cf21bSWaldemar Kornewald#ifdef SETNETGRENT_ARGS
4375d7cf21bSWaldemar Kornewaldvoid setnetgrent(SETNETGRENT_ARGS);
4385d7cf21bSWaldemar Kornewald#else
4395d7cf21bSWaldemar Kornewaldvoid setnetgrent(const char *netgroup);
4405d7cf21bSWaldemar Kornewald#endif
4415d7cf21bSWaldemar Kornewald
4425d7cf21bSWaldemar Kornewaldvoid endnetgrent(void);
4435d7cf21bSWaldemar Kornewald
4445d7cf21bSWaldemar Kornewald#ifdef INNETGR_ARGS
4455d7cf21bSWaldemar Kornewaldint innetgr(INNETGR_ARGS);
4465d7cf21bSWaldemar Kornewald#else
4475d7cf21bSWaldemar Kornewaldint innetgr(const char *netgroup, const char *machine,
4485d7cf21bSWaldemar Kornewald	    const char *user, const char *domain);
4495d7cf21bSWaldemar Kornewald#endif
4505d7cf21bSWaldemar Kornewald
4514bd3cce6SAxel Dörfler#ifdef NGR_R_SET_ARGS
4525d7cf21bSWaldemar KornewaldNGR_R_SET_RETURN
4534bd3cce6SAxel Dörflersetnetgrent_r(NGR_R_SET_CONST char *netgroup, NGR_R_SET_ARGS);
4545d7cf21bSWaldemar Kornewald#else
4555d7cf21bSWaldemar KornewaldNGR_R_SET_RETURN
4564bd3cce6SAxel Dörflersetnetgrent_r(NGR_R_SET_CONST char *netgroup);
4574bd3cce6SAxel Dörfler#endif
4584bd3cce6SAxel Dörfler
4594bd3cce6SAxel Dörfler#ifdef NEED_STRTOUL
4604bd3cce6SAxel Dörflerunsigned long strtoul(const char *, char **, int);
4614bd3cce6SAxel Dörfler#endif
4624bd3cce6SAxel Dörfler
4634bd3cce6SAxel Dörfler#ifdef NEED_SUN4PROTOS
4644bd3cce6SAxel Dörfler#include <stdarg.h>
4654bd3cce6SAxel Dörfler#ifndef __SIZE_TYPE__
4664bd3cce6SAxel Dörfler#define __SIZE_TYPE__ int
4674bd3cce6SAxel Dörfler#endif
4684bd3cce6SAxel Dörflerstruct sockaddr;
4694bd3cce6SAxel Dörflerstruct iovec;
4704bd3cce6SAxel Dörflerstruct timeval;
4714bd3cce6SAxel Dörflerstruct timezone;
4724bd3cce6SAxel Dörflerint fprintf(FILE *, const char *, ...);
4734bd3cce6SAxel Dörflerint getsockname(int, struct sockaddr *, int *);
4744bd3cce6SAxel Dörflerint getpeername(int, struct sockaddr *, int *);
4754bd3cce6SAxel Dörflerint socket(int, int, int);
4764bd3cce6SAxel Dörflerint connect(int, const struct sockaddr *, int);
4774bd3cce6SAxel Dörflerint writev(int, struct iovec *, int);
4784bd3cce6SAxel Dörflerint readv(int, struct iovec *, int);
4794bd3cce6SAxel Dörflerint send(int, const char *, int, int);
4804bd3cce6SAxel Dörflervoid bzero(char *, int);
4814bd3cce6SAxel Dörflerint recvfrom(int, char *, int, int, struct sockaddr *, int *);
4824bd3cce6SAxel Dörflerint syslog(int, const char *, ... );
4834bd3cce6SAxel Dörflerint printf(const char *, ...);
4844bd3cce6SAxel Dörfler__SIZE_TYPE__ fread(void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
4854bd3cce6SAxel Dörfler__SIZE_TYPE__ fwrite(const void *, __SIZE_TYPE__, __SIZE_TYPE__, FILE *);
4864bd3cce6SAxel Dörflerint fclose(FILE *);
4874bd3cce6SAxel Dörflerint ungetc(int, FILE *);
4884bd3cce6SAxel Dörflerint scanf(const char *, ...);
4894bd3cce6SAxel Dörflerint sscanf(const char *, const char *, ... );
4904bd3cce6SAxel Dörflerint tolower(int);
4914bd3cce6SAxel Dörflerint toupper(int);
4924bd3cce6SAxel Dörflerint strcasecmp(const char *, const char *);
4934bd3cce6SAxel Dörflerint strncasecmp(const char *, const char *, int);
4944bd3cce6SAxel Dörflerint select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
4954bd3cce6SAxel Dörfler#ifdef gettimeofday
4964bd3cce6SAxel Dörfler#undef gettimeofday
4974bd3cce6SAxel Dörflerint gettimeofday(struct timeval *, struct timezone *);
4984bd3cce6SAxel Dörfler#define gettimeofday isc__gettimeofday
4994bd3cce6SAxel Dörfler#else
5004bd3cce6SAxel Dörflerint gettimeofday(struct timeval *, struct timezone *);
5014bd3cce6SAxel Dörfler#endif
5024bd3cce6SAxel Dörflerlong strtol(const char*, char **, int);
5034bd3cce6SAxel Dörflerint fseek(FILE *, long, int);
5044bd3cce6SAxel Dörflerint setsockopt(int, int, int, const char *, int);
5054bd3cce6SAxel Dörflerint bind(int, const struct sockaddr *, int);
5064bd3cce6SAxel Dörflervoid bcopy(char *, char *, int);
5074bd3cce6SAxel Dörflerint fputc(char, FILE *);
5084bd3cce6SAxel Dörflerint listen(int, int);
5094bd3cce6SAxel Dörflerint accept(int, struct sockaddr *, int *);
5104bd3cce6SAxel Dörflerint getsockopt(int, int, int, char *, int *);
5114bd3cce6SAxel Dörflerint vfprintf(FILE *, const char *, va_list);
5124bd3cce6SAxel Dörflerint fflush(FILE *);
5134bd3cce6SAxel Dörflerint fgetc(FILE *);
5144bd3cce6SAxel Dörflerint fputs(const char *, FILE *);
5154bd3cce6SAxel Dörflerint fchown(int, int, int);
5164bd3cce6SAxel Dörflervoid setbuf(FILE *, char *);
5174bd3cce6SAxel Dörflerint gethostname(char *, int);
5184bd3cce6SAxel Dörflerint rename(const char *, const char *);
5194bd3cce6SAxel Dörflertime_t time(time_t *);
5204bd3cce6SAxel Dörflerint fscanf(FILE *, const char *, ...);
5214bd3cce6SAxel Dörflerint sscanf(const char *, const char *, ...);
5224bd3cce6SAxel Dörflerint ioctl(int, int, caddr_t);
5234bd3cce6SAxel Dörflervoid perror(const char *);
5244bd3cce6SAxel Dörfler
5254bd3cce6SAxel Dörfler#if !defined(__USE_FIXED_PROTOTYPES__) && !defined(__cplusplus) && !defined(__STRICT_ANSI__)
5264bd3cce6SAxel Dörfler/*
5274bd3cce6SAxel Dörfler * 'gcc -ansi' changes the prototype for vsprintf().
5284bd3cce6SAxel Dörfler * Use this prototype when 'gcc -ansi' is not in effect.
5294bd3cce6SAxel Dörfler */
5304bd3cce6SAxel Dörflerchar *vsprintf(char *, const char *, va_list);
5315d7cf21bSWaldemar Kornewald#endif
5325d7cf21bSWaldemar Kornewald#endif
5334bd3cce6SAxel Dörfler
5344bd3cce6SAxel Dörfler#endif
535