1/*	$FreeBSD$	*/
2
3/* Copyright 1993,1994 by Paul Vixie
4 * All rights reserved
5 *
6 * Distribute freely, except: don't remove my name from the source or
7 * documentation (don't take credit for my work), mark your changes (don't
8 * get me blamed for your possible bugs), don't alter or remove this
9 * notice.  May be sold if buildable source is provided to buyer.  No
10 * warrantee of any kind, express or implied, is included with this
11 * software; use at your own risk, responsibility for damages (if any) to
12 * anyone resulting from the use of this software rests entirely with the
13 * user.
14 *
15 * Send bug reports, bug fixes, enhancements, requests, flames, etc., and
16 * I'll try to keep a version up to date.  I can be reached as follows:
17 * Paul Vixie          <paul@vix.com>          uunet!decwrl!vixie!paul
18 */
19
20#if defined(POSIX) || defined(ATT)
21# include <stdlib.h>
22# include <unistd.h>
23# include <string.h>
24# include <dirent.h>
25# define DIR_T	struct dirent
26# define WAIT_T	int
27# define WAIT_IS_INT 1
28extern char *tzname[2];
29# define TZONE(tm) tzname[(tm).tm_isdst]
30#endif
31
32#if defined(UNIXPC)
33# undef WAIT_T
34# undef WAIT_IS_INT
35# define WAIT_T	union wait
36#endif
37
38#if defined(POSIX)
39# define SIG_T	sig_t
40# define TIME_T	time_t
41# define PID_T pid_t
42#endif
43
44#if defined(ATT)
45# define SIG_T	void
46# define TIME_T	long
47# define PID_T int
48#endif
49
50#if !defined(POSIX) && !defined(ATT)
51/* classic BSD */
52extern	time_t		time();
53extern	unsigned	sleep();
54extern	struct tm	*localtime();
55extern	struct passwd	*getpwnam();
56extern	int		errno;
57extern	void		perror(), exit(), free();
58extern	char		*getenv(), *strcpy(), *strchr(), *strtok();
59extern	void		*malloc(), *realloc();
60# define SIG_T	void
61# define TIME_T	long
62# define PID_T int
63# define WAIT_T	union wait
64# define DIR_T	struct direct
65# include <sys/dir.h>
66# define TZONE(tm) (tm).tm_zone
67#endif
68
69/* getopt() isn't part of POSIX.  some systems define it in <stdlib.h> anyway.
70 * of those that do, some complain that our definition is different and some
71 * do not.  to add to the misery and confusion, some systems define getopt()
72 * in ways that we cannot predict or comprehend, yet do not define the adjunct
73 * external variables needed for the interface.
74 */
75#if (!defined(BSD) || (BSD < 198911)) && !defined(ATT) && !defined(UNICOS)
76int	getopt(int, char * const *, const char *);
77#endif
78
79#if (!defined(BSD) || (BSD < 199103))
80extern	char *optarg;
81extern	int optind, opterr, optopt;
82#endif
83
84#if WAIT_IS_INT
85# ifndef WEXITSTATUS
86#  define WEXITSTATUS(x) (((x) >> 8) & 0xff)
87# endif
88# ifndef WTERMSIG
89#  define WTERMSIG(x)	((x) & 0x7f)
90# endif
91# ifndef WCOREDUMP
92#  define WCOREDUMP(x)	((x) & 0x80)
93# endif
94#else /*WAIT_IS_INT*/
95# ifndef WEXITSTATUS
96#  define WEXITSTATUS(x) ((x).w_retcode)
97# endif
98# ifndef WTERMSIG
99#  define WTERMSIG(x)	((x).w_termsig)
100# endif
101# ifndef WCOREDUMP
102#  define WCOREDUMP(x)	((x).w_coredump)
103# endif
104#endif /*WAIT_IS_INT*/
105
106#ifndef WIFSIGNALED
107#define WIFSIGNALED(x)	(WTERMSIG(x) != 0)
108#endif
109#ifndef WIFEXITED
110#define WIFEXITED(x)	(WTERMSIG(x) == 0)
111#endif
112
113#ifdef NEED_STRCASECMP
114extern	int		strcasecmp(char *, char *);
115#endif
116
117#ifdef NEED_STRDUP
118extern	char		*strdup(char *);
119#endif
120
121#ifdef NEED_STRERROR
122extern	char		*strerror(int);
123#endif
124
125#ifdef NEED_FLOCK
126extern	int		flock(int, int);
127# define LOCK_SH 1
128# define LOCK_EX 2
129# define LOCK_NB 4
130# define LOCK_UN 8
131#endif
132
133#ifdef NEED_SETSID
134extern	int		setsid(void);
135#endif
136
137#ifdef NEED_GETDTABLESIZE
138extern	int		getdtablesize(void);
139#endif
140
141#ifdef NEED_SETENV
142extern	int		setenv(char *, char *, int);
143#endif
144
145#ifdef NEED_VFORK
146extern	PID_T		vfork(void);
147#endif
148