#include <string.h>
#include <sys/types.h>
#include <sys/param.h>
#ifndef TIME_H_INCLUDED
# include <sys/time.h>
# define TIME_H_INCLUDED
#endif
#ifdef ISC
# ifndef _POSIX_SOURCE
# define _POSIX_SOURCE
# endif
# define SYSV
# define SVR3
# define _SYSV3
# define NEED_STRTOUL
# define NEED_FTRUNCATE
# define USE_POSIX
# include <sys/bsdtypes.h>
# include <sys/sioctl.h>
# include <sys/stream.h>
# include <net/errno.h>
#endif
#if defined(__convex__)
# if !defined(_POSIX_SOURCE)
# define _POSIX_SOURCE
# endif
# define USE_UTIME
# define NEED_PUTENV
#endif
#if defined(_CRAY)
# if !defined(_POSIX_SOURCE)
# define _POSIX_SOURCE
# endif
# define writev(a,b,c) __writev(a,b,c)
# define setitimer(a,b,c) __setitimer(a,b,c)
#endif
#if defined(ISC)
# define ftruncate(a,b) __ftruncate(a,b)
# define USE_MEMCPY
# define USE_UTIME
# define HAVE_FCHMOD 0
#endif
#if defined(M_UNIX)
# undef POSIX_SOURCE
# define POSIX_SIGNALS
# define HAVE_FCHMOD 0
# define writev(a,b,c) __writev(a,b,c)
# define ftruncate(a,b) __ftruncate(a,b)
#endif
#if defined(__APPLE__) && BSD < 199506
# define NEED_PUTENV
# define NEED_SETENV
#endif
#if defined(__sgi)
# define BSD 43
# define vfork fork
#endif
#if defined(SUNOS4)
# define BSD 43
#endif
#if defined(_AUX_SOURCE)
# define vfork fork
# define NEED_STRERROR
# define NEED_STRTOUL
# define SIG_FN void
# define USE_MEMCPY
#endif
#if defined(SVR4) && !defined(SYSV)
# define SYSV
#endif
#if defined(_POSIX_SOURCE) || defined(__sgi) || defined(__ultrix) || \
defined(__hpux) || (defined(BSD) && (BSD >= 199103)) || \
(defined(sun) && defined(SYSV))
# define USE_POSIX
#endif
#if defined(__ultrix) && !defined(BSD)
# define BSD 42
#endif
#if defined(host_mips) && defined(SYSTYPE_BSD43)
# define RISCOS_BSD
#endif
#if defined(SYSV) || defined(__ultrix) || defined(__osf__) \
|| (defined(BSD) && BSD >= 199306) || defined(linux)
# define USE_UTIME
# define HAVE_SETVBUF
#endif
#if defined(SYSV) && !defined(SVR4)
# define vfork fork
#endif
#if defined(sun) || defined(SVR4)
# define NETREAD_BROKEN
#endif
#if defined(BSD) && BSD >= 199006 && !defined(i386) && !defined(RISCOS_BSD)
# define HAVE_DAEMON
#endif
#if !defined(BSD) || (BSD <= 199006)
# if !defined(__APPLE__)
# define NEED_INETADDR
# endif
# define NEED_INETATON
#endif
#if defined(__hpux)
# if defined(__STDC__)
# define select(a,b,c,d,e) select(a, (int *)b, (int *)c, (int *)d, e)
# define ctime(x) ctime((const time_t *)x)
# endif
# if !defined(SYSV)
# define USE_UTIME
# define setlinebuf(x) setvbuf(x, NULL, _IOLBF, BUFSIZ)
# if !defined(SIGWINCH)
# define SIGWINCH SIGWINDOW
# endif
# endif
# if 0
struct linger {
int l_onoff;
int l_linger;
};
# endif
#endif
#if defined(_SEQUENT_)
# include <netinet/in_systm.h>
# define USE_UTIME
# define USE_POSIX
# define NEED_GETTIMEOFDAY
# define _TIMEZONE timezoneBSD
struct timezoneBSD {
int tz_minuteswest;
int tz_dsttime;
};
#endif
#ifndef __P
# if defined(__STDC__) || defined(__GNUC__)
# define __P(x) x
# else
# define __P(x) ()
# endif
#endif
#ifndef _TIMEZONE
# define _TIMEZONE timezone
#endif
#if defined(USE_POSIX)
# include <stdlib.h>
# include <unistd.h>
# include <limits.h>
#else
# define NEED_STRTOUL
# define STDIN_FILENO 0
# define STDOUT_FILENO 1
# define STDERR_FILENO 2
# ifndef __APPLE__
extern char *getenv __P((char *));
# else
extern char *getenv __P((const char *));
# endif
extern int errno;
# if !defined(DMALLOC) && !defined(__APPLE__)
extern char *malloc(), *realloc(), *calloc();
# if defined(sun)
extern int free();
# else
extern void free();
# endif
# endif
extern int getdtablesize __P((void));
# ifdef SHORT_FNAMES
extern long pathconf __P((const char *path, int name));
# endif
#endif
#ifndef UINT_MAX
# ifdef __STDC__
# define UINT_MAX 4294967295u
# else
# define UINT_MAX ((unsigned)4294967295)
# endif
# define ULONG_MAX UINT_MAX
#endif
#ifndef INT_MAX
# define INT_MAX 2147483647
#endif
#ifndef RAND_MAX
# define RAND_MAX 0x7fffffff
#endif
#ifndef IN_LOOPBACKNET
# define IN_LOOPBACKNET 127
#endif
#ifndef INADDR_NONE
# define INADDR_NONE 0xffffffff
#endif
#if defined(apollo)
#undef IP_OPTIONS
#endif
#if !defined(__STDC__) && !defined(const)
# define const
#endif
#if !defined(__convex__) && (!defined(BSD) || (BSD < 199103))
int strcasecmp __P((const char *, const char *));
#endif
#if (!defined(BSD) || (BSD <= 43)) && \
!defined(NeXT) && \
!defined(__convex__) && \
!defined(USE_POSIX)
# if !defined(NCR)
extern void syslog();
# endif
extern char *ctime __P((const time_t *clock));
extern int close(), setitimer(), recv(), sendto(), sigsetmask(),
atoi(), getpid(), fork(), read(), ioctl(),
setsockopt(), socket(), bind();
#endif
#if !defined(bcopy)
# if defined(USE_POSIX) || \
(defined(__STDC__) && !defined(sun) && !defined(sequent))
#if defined(USE_MEMCPY)
# define bcopy(a,b,c) memcpy(b,a,c)
#else
# define bcopy(a,b,c) memmove(b,a,c)
#endif
# define bzero(a,b) memset(a,0,b)
# define bcmp(a,b,c) memcmp(a,b,c)
# else
extern void bcopy();
extern void bzero();
extern int bcmp();
# endif
#endif
#if (!defined(BSD) || (BSD < 43) || defined(RISCOS_BSD)) \
&& !defined(USE_POSIX) && !defined(apollo) && !defined(sequent) \
&& !defined(M_UNIX)
# define NEED_STRERROR
#if !defined(ultrix) && !defined(NCR)
# define NEED_PUTENV
#endif
#endif
#if defined(SUNOS4)
# define NEED_STRERROR
# if defined(sun386)
# define pid_t int
# define NEED_STRCASECMP
# endif
#endif
#if (!defined(BSD) || (BSD < 43))
# define NEED_MKSTEMP
# if !defined(__ultrix) && !defined(apollo)
# define NEED_STRCASECMP
# define NEED_MKTEMP
# if !defined(SVR4)
# define NEED_STRPBRK
# endif
# endif
#endif
#if defined(USE_POSIX)
# define POSIX_SIGNALS
#endif
#ifndef SIG_FN
# ifdef BSD
# if (BSD >= 199006) || defined(__APPLE__) || defined(__osf__) || defined(sun) \
|| defined(__ultrix) || defined(apollo) || defined(POSIX_SIGNALS)
# define SIG_FN void
# else
# define SIG_FN int
# endif
# else
# define SIG_FN void
# endif
#endif
#if !defined(ntohl) && !defined(htonl) && defined(BSD) && (BSD <= 43)
extern u_short htons(), ntohs();
extern u_long htonl(), ntohl();
#endif
#if defined(USE_POSIX) && !defined(sun) && !defined(__sgi) \
&& !defined(__convex__) && !defined(__ultrix) && !defined(_AUX_SOURCE)
# define PORT_NONBLOCK O_NONBLOCK
# define PORT_WOULDBLK EAGAIN
#else
# define PORT_NONBLOCK O_NDELAY
# define PORT_WOULDBLK EWOULDBLOCK
#endif
#if defined(USE_POSIX)
# define USE_SETSID
#endif
#if defined(USE_POSIX) || !defined(SYSV)
#define USE_WAITPID
#endif
#if !defined(USE_POSIX)
#define waitpid(x,y,z) (wait3(y,z,(struct rusage *)NULL))
#endif
#if defined(__APPLE__) || defined(_AIX) || defined(sun386)
# undef WIFEXITED
# undef WEXITSTATUS
# undef WIFSIGNALED
# undef WTERMSIG
#endif
#if defined(sequent)
#define WEXITSTATUS(x) ((x).w_retcode)
#define WTERMSIG(x) ((x).w_termsig)
#endif
#if !defined(WIFEXITED)
# define WIFEXITED(x) (!(x & 0177))
#endif
#if !defined(WEXITSTATUS)
# define WEXITSTATUS(x) (x >> 8)
#endif
#if !defined(WIFSIGNALED)
# define WIFSIGNALED(x) ((x & 0177) && ((x & 0377) != 0177))
#endif
#if !defined(WTERMSIG)
# define WTERMSIG(x) (x & 0177)
#endif
#ifndef S_ISDIR
# ifndef S_IFMT
# define S_IFMT 0170000
# endif
# ifndef S_IFDIR
# define S_IFDIR 0040000
# endif
# define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
#endif
#ifndef S_ISREG
# ifndef S_IFMT
# define S_IFMT 0170000
# endif
# ifndef S_IFREG
# define S_IFREG 0100000
# endif
# define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
#endif
#ifndef S_ISFIFO
# ifndef S_IFMT
# define S_IFMT 0170000
# endif
# ifndef S_IFIFO
# define S_IFIFO 0010000
# endif
# define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
#endif
#if defined(NEED_STRTOUL) && \
(defined(__ultrix) || defined(__osf__) || defined(NeXT))
# undef NEED_STRTOUL
#endif
#if defined(__ultrix) || defined(__osf__)
# define MAYBE_HESIOD
#endif
#ifndef FD_SET
#define NFDBITS 32
#define FD_SETSIZE 32
#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
#endif
#ifndef MIN
# define MIN(x, y) ((x > y) ?y :x)
#endif
#ifndef MAX
# define MAX(x, y) ((x > y) ?x :y)
#endif
#if !defined(PATH_MAX)
# if defined(_POSIX_PATH_MAX)
# define PATH_MAX _POSIX_PATH_MAX
# else
# if defined(MAXPATHLEN)
# define PATH_MAX MAXPATHLEN
# endif
# endif
#endif
#if defined(BSD) || defined(__osf__) || defined(__convex__)
# define HAVE_GETRUSAGE
#endif
#if defined(HAVE_GETRUSAGE)
# include <sys/resource.h>
#endif
#if defined(__convex__) && !defined(feof)
# define feof(p) ((p)->_flag&_IOEOF)
#endif
#if defined(M_UNIX) || defined(linux)
# define SPURIOUS_ECONNREFUSED
#endif
#if !defined(HAVE_FCHMOD)
# define HAVE_FCHMOD 1
#endif
#ifdef NEED_PUTENV
extern int putenv __P((char *));
#endif
#ifdef NEED_GETTIMEOFDAY
extern int gettimeofday __P((struct timeval *, struct _TIMEZONE *));
#endif