[comp.lang.c] My error-handling library and ANSI prototypes

bet@dukeac.UUCP (Bennett Todd) (02/04/89)

I am about to post, in two shell archives, my error-handling library of
wrappers around system calls and library routines (sections 2 and 3 UPM). This
package includes (wrapped in the second shell archive) a header file which in
turn includes /usr/include/*, more-or-less, and then has ANSI function
prototypes for most all of them. I say most, because there are a couple of
exceptions and strangenesses. Frst I created the thing using the 4.3BSD
manual, including prototypes for everything (except I didn't get around to
doing the big packages like curses, dbm, lib3248, and so forth; you can grep
for TBD to see what I deliberately skipped). Then I tried to use it on the
Sun, and made a few changes under "#ifdef sun" to make it useable. I have
since added a few routines not in 4.3BSD's man pages, but I have made no
attempt to cover all of Sun's additional routines.

Here's an inane example of using the library:

#include <bent.h>
/*
 * cat [file ...]
 *
 * Copy file(s) (stdin default) to stdout.
 * Gratuitously balks if it thinks it sees a "-" option.
 * Cat shouldn't take any options.
 */

/* This here is all that is required to provide the "syntax()" subroutine */
char syntax_args[] = "[file ...]";

#define BLEN 65536

static void cat(FILE *);

int main(int argc, char **argv) {
	/* "progname" is used by the library routines for error messages */
	progname = argv[0];
	argc--, argv++;

	if (argc > 0 && **argv == '-')
		syntax();

	if (argc > 0) {
		while (argc-- > 0)
			cat(efopen(*argv++, "r"));
	} else {
		cat(stdin);
	}
}

static void cat(FILE *fp) {
	static char *buffer = NULL;
	int n;

	if (buffer == NULL)
		buffer = emalloc(BLEN);

	while (n = fread(buffer, 1, BLEN, fp))
		efwrite(buffer, 1, n, stdout);

	efclose(fp);
	return;
}

That is how I am writing programs these days; it doesn't take me any extra
time, they can (once they are debugged) be compiled using gcc with all
warnings turned on and not generate any, and run-time error returns from the
system are systematically checked and uniformly reported.

I like it. I am posting it because I've gotten many requests for it; I am
posting it to this group because mail between here and the moderator of
comp.sources.misc seems to be hosed (I've tried mailing this to him a couple
of times; nary a bounce or confirmation or whatever. I am sure it is my
fault).

-Bennett
bet@orion.mc.duke.edu

bet@dukeac.UUCP (Bennett Todd) (02/04/89)

: This is a sharchive -- extract the files by running through sh.
echo x - README
sed 's/^X//' <<\Shar_Eof >README
XThis is the first release of the Bent utility library. See intro(3b) for
Xinformation on the functions provided. As distributed this package installs
Xand runs on my Sun 3 systems running SunOS 3.5. I expect that everything
Xexcept maybe a few details in bent-stdio.h will work with few changes in any
XBSD 4.2 or greater system; the guts of it should be extremely portable.
XOutside of BSD the getdtablesize() call might have to be replaced with some
Xdefine out of a header file to identify the number of available file
Xdescriptors; if they aren't guaranteed to be low integers from [0..MAX] for
Xsome compile-time-fixed MAX then some more sophisticated associative scheme
Xwill be necessary to maintain the _bentio_filename_table. I haven't checked
Xthe #else clauses in the #ifdef __STDC__ definitions for a while; it is
Xpossible some have drifted (I use gcc; I am expecting to rip out the sop for
Xobsolete compilers in the future).
X
XI am well aware that some folks won't like the bent-stdio.h approach of
X#including everything in the universe; that could be done away with. I
Xprefer not having to bother with keeping track of which things need to be
Xincluded for various system functions.
X
XI have added e* routines as I have needed them; in principle I expect to end
Xup with e* wrappers around the majority of section 2 and section 3 routines.
XAs I find other generally-useful-to-me routines I expect to add them in.
XThis is basically the collection of oddments that I like to have on hand
Xbecause I don't like to have to keep rewriting them, and I want them in one
Xplace so that I don't have to go find all the copies of the source when I
Xfix a bug.
X
XNote that I edit with tabstops every 4 columns, so except for tabular stuff
Xin man pages all the alignment will be off if you look at it with default
Xtabstops every 8 columns.
X
XPorting to systems that haven't got >14 character long filenames, that don't
Xtake long C identifiers, that don't have the UNIX complement of text
Xprocessing tools (egrep and sed and like that), or are otherwise more
Xsubstantially different from BSD UNIX will probably take some little effort.
XI don't program in such environments myself or I would have done this
Xalready; if anyone does anything to fix bugs or improve portability of this
Xlibrary I would appreciate it if they sent me the fixes, and I will attempt
Xto incorporate them into future releases.
X
XAs for installation, if you are on a Sun you can adjust the directory names
Xfor installation in Makefile and run make, followed by make install (you
Xmight want to run make -n install first to ensure that you like the approach
XI take to installing the files). If not, best of luck. The only really
Xtricky thing I have is the mkprototypes script, which uses egrep and sed to
Xsynthesize function prototypes for a file, and more sed abuse to turn them
Xinto declarations. Note that these scripts are extremely sensitive to
Xtypographical layout of function declarations! I have included a "bent.h" in
Xthe distribution that matches the functions as they currently are defined;
Xif mkprototypes doesn't work on your system then you can start with that
Xbent.h and manually adjust it to match whenever you add or change a routine.
X
X-Bennett (bet@orion.mc.duke.edu)
Shar_Eof
echo x - Makefile
sed 's/^X//' <<\Shar_Eof >Makefile
X# If you have a repository for local stuff (on our system /usr/local) which
X# contains .../lib for /usr/lib type stuff, .../include for header files, and
X# .../man for man pages (on Suns and 4.3 BSD systems you can have a local
X# heirarchy by setting the MANPATH environment variable) then you can set ROOT
X# to that location and all the target directories will be fixed.  Otherwise set
X# LIBDIR, INCDIR, and MANDIR properly. Note that *.3b will be installed in
X# $(MANDIR)/man3, and "catman -M $(MANDIR)" will be invoked.
X
XROOT=/usr/local
XLIBDIR=$(ROOT)/lib
XINCDIR=$(ROOT)/include
XMANDIR=$(ROOT)/man
X
X# The following are how Bennett approaches the task of compiling C programs
XCC=gcc
XCFLAGS=-O -g -Wall -Wwrite-strings -msoft-float -fstrength-reduce -finline-functions -I.
X
XSRC=eclose.c efclose.c efdopen.c efflush.c efgets.c efopen.c efprintf.c \
X	efread.c efree.c efseek.c efwrite.c emalloc.c emkstemp.c eopen.c \
X	eprintf.c eputchar.c erealloc.c error.c etruncate.c eunlink.c ewrite.c \
X	getline.c max.c min.c progname.c putline.c readfile.c standrand.c \
X	strdup.c syntax.c
X
XOBJ=eclose.o efclose.o efdopen.o efflush.o efgets.o efopen.o efprintf.o \
X	efread.o efree.o efseek.o efwrite.o emalloc.o emkstemp.o eopen.o \
X	eprintf.o eputchar.o erealloc.o error.o etruncate.o eunlink.o ewrite.o \
X	getline.o max.o min.o progname.o putline.o readfile.o standrand.o \
X	strdup.o syntax.o \
X	filename_tab.o
X
XSHAR1=README Makefile VERSION bent.header eclose.c efclose.c efdopen.c \
X	  efflush.c efgets.c efopen.c efprintf.c efread.c efree.c efseek.c \
X	  efwrite.c emalloc.c emkstemp.c eopen.c eprintf.c eputchar.c erealloc.c \
X	  error.3b error.c etruncate.c eunlink.c ewrite.c getdtablesize.c \
X	  getline.3b getline.c intro.3b max.3b max.c min.c mkprototypes \
X	  progname.c putline.c readfile.3b readfile.c standrand.3b standrand.c \
X	  strdup.3b strdup.c syntax.3b syntax.c
X
XSHAR2=bent-stdio.h
X
XMAN=error.3b getline.3b intro.3b max.3b readfile.3b standrand.3b strdup.3b \
X	syntax.3b
X
Xlibbent.a : $(OBJ)
X	ar r libbent.a $(OBJ)
X	ranlib libbent.a
X
X$(OBJ) : bent.h
X
Xbent.h : bent.header $(SRC)
X	cat bent.header					 >bent.h.tmp
X	echo '#ifdef __STDC__'			>>bent.h.tmp
X	./mkprototypes $(SRC)           >>bent.h.tmp
X	echo '#else /* __STDC__ */'		>>bent.h.tmp
X	./mkprototypes $(SRC) | sed 's/(.*);/();/' >>bent.h.tmp
X	echo '#endif /* __STDC__ */'	>>bent.h.tmp
X	cmp -s bent.h bent.h.tmp || mv bent.h.tmp bent.h
X	rm -f bent.h.tmp
X
Xfilename_tab.o: /vmunix getdtablesize
X	$(CC) $(CFLAGS) getdtablesize.c -o getdtablesize
X	echo 'const char *_bentio_filename_table['`./getdtablesize`']={"stdin","stdout","stderr",};'>filename_tab.c
X	$(CC) $(CFLAGS) -c filename_tab.c
X	rm filename_tab.c
X
Xinstall : $(LIBDIR)/libbent.a $(INCDIR)/bent.h $(INCDIR)/bent-stdio.h $(MANDIR)/man3/intro.3b
X
X$(LIBDIR)/libbent.a : libbent.a
X	cp libbent.a $(LIBDIR)
X	ranlib -t $(LIBDIR)/libbent.a
X
X$(INCDIR)/bent.h : bent.h
X	cp bent.h $(INCDIR)
X
X$(INCDIR)/bent-stdio.h : bent-stdio.h
X	cp bent-stdio.h $(INCDIR)
X
X$(MANDIR)/man3/intro.3b : $(MAN)
X	for f in $(MAN);do \
X		cmp -s $$f $(MANDIR)/man3/$$f || cp $$f $(MANDIR)/man3; \
X	done
X	catman -M $(MANDIR)
X
Xclean :
X	rm -f $(OBJ) getdtablesize
X
Xrealclean : clean
X	rm -f libbent.a bent.h
X
Xshar : libbent.shar.1 libbent.shar.2
X
Xlibbent.shar.1 : $(SHAR1)
X	shar $(SHAR1) >libbent.shar.1
X
Xlibbent.shar.2 : $(SHAR2)
X	shar $(SHAR2) >libbent.shar.2
Shar_Eof
echo x - VERSION
sed 's/^X//' <<\Shar_Eof >VERSION
XVersion 1.0, Fri Dec  2 13:07:34 EST 1988
Shar_Eof
echo x - bent.header
sed 's/^X//' <<\Shar_Eof >bent.header
X#include <bent-stdio.h>
Xextern char *progname;
Xextern char syntax_args[];
X
Xtypedef struct {
X	long magic;	/* MAXIMUM ALIGNMENT TYPE! */
X	unsigned len;
X} _BENT_MALLOC_HEADER;
X
X#define _BENT_MALLOC_MAGIC 0x13713713
X
Xlong stand_rand_seed;
X
Xextern const char *_bentio_filename_table[];
X
X#define _FD2FN(fd) (_bentio_filename_table[(fd)] ? _bentio_filename_table[(fd)] : "(unknown file)")
Shar_Eof
echo x - eclose.c
sed 's/^X//' <<\Shar_Eof >eclose.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid eclose(int fd) {
X#else /* __STDC__ */
Xvoid eclose(fd)
Xint fd;
X{
X#endif /* __STDC__ */
X	if (close(fd) != 0)
X		error("eclose(%d: %s) failed: %s", fd, _FD2FN(fd), BENT_ERRMSG);
X	if (fd > 2 && _bentio_filename_table[fd]) {
X		efree((char *)_bentio_filename_table[fd]);
X		_bentio_filename_table[fd] = 0;
X	}
X}
Shar_Eof
echo x - efclose.c
sed 's/^X//' <<\Shar_Eof >efclose.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid efclose(FILE *fp) {
X#else /* __STDC__ */
Xvoid efclose(fp)
XFILE *fd;
X{
X#endif /* __STDC__ */
X	if (fclose(fp) != 0)
X		error("efclose(%s) failed: %s", _FD2FN(fileno(fp)), BENT_ERRMSG);
X	if (fileno(fp) > 2 && _bentio_filename_table[fileno(fp)]) {
X		efree((char *)_bentio_filename_table[fileno(fp)]);
X		_bentio_filename_table[fileno(fp)] = 0;
X	}
X}
Shar_Eof
echo x - efdopen.c
sed 's/^X//' <<\Shar_Eof >efdopen.c
X#include <bent.h>
X
X#ifdef __STDC__
XFILE *efdopen(int fd, const char *mode) {
X#else /* __STDC__ */
XFILE *efdopen(fd, mode)
Xint fd;
Xchar *mode;
X{
X#endif /* __STDC__ */
X	FILE *fp;
X	char *filename;
X
X	if ((fp = fdopen(fd, mode)) == NULL)
X		error("fdopen(%d) failed: %s\n", fd, BENT_ERRMSG);
X
X	filename = emalloc(20);
X	(void) sprintf(filename, "(fdopen %d)", fd);
X	_bentio_filename_table[fd] = filename;
X
X	return(fp);
X}
Shar_Eof
echo x - efflush.c
sed 's/^X//' <<\Shar_Eof >efflush.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid efflush(FILE *fp) {
X#else /* __STDC__ */
Xvoid efflush(fp)
XFILE *fp;
X{
X#endif /* __STDC__ */
X	if (fflush(fp) != NULL)
X		error("fflush(%s) failed: %s", _FD2FN(fileno(fp)), BENT_ERRMSG);
X}
Shar_Eof
echo x - efgets.c
sed 's/^X//' <<\Shar_Eof >efgets.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid efgets(char *buff, int n, FILE *fp) {
X#else /* __STDC__ */
Xvoid efgets(buff, n, fp)
Xchar *buff;
Xint n;
XFILE *fp;
X{
X#endif /* __STDC__ */
X	if (fgets(buff, n, fp) == NULL)
X		error("fgets(0x%lx, int n, %s) failed: %s", buff, n, _FD2FN(fileno(fp)), BENT_ERRMSG);
X}
Shar_Eof
echo x - efopen.c
sed 's/^X//' <<\Shar_Eof >efopen.c
X#include <bent.h>
X
X#ifdef __STDC__
XFILE *efopen(const char *name, const char *mode) {
X#else /* __STDC__ */
XFILE *efopen(name, mode)
Xchar *name, *mode;
X{
X#endif /* __STDC__ */
X	FILE *fp;
X
X	if ((fp = fopen(name, mode)) == NULL)
X		error("fopen(%s, %s) failed: %s", name, mode, BENT_ERRMSG);
X	_bentio_filename_table[fileno(fp)] = strdup(name);
X	return(fp);
X}
Shar_Eof
echo x - efprintf.c
sed 's/^X//' <<\Shar_Eof >efprintf.c
X#include <bent.h>
X
X#ifdef __STDC__
X#include <stdarg.h>
Xvoid efprintf(FILE *fp, const char *fmt, ...) {
X	va_list ap;
X
X	va_start(ap, fmt);
X	if (vfprintf(fp, fmt, ap) == EOF)
X		error("efprintf(0x%lx, \"%s\", ...) failed: %s", fp, fmt, BENT_ERRMSG);
X	va_end(ap);
X}
X#else /* __STDC__ */
X#include <varargs.h>
Xvoid efprintf(va_list)
Xva_dcl
X{
X	va_list ap;
X	FILE *fp;
X	char *fmt;
X
X	va_start(ap);
X	fp = va_arg(ap, FILE *);
X	fmt = va_arg(ap, char *);
X	if (vfprintf(fp, fmt, ap) == EOF)
X		error("efprintf(0x%lx, "%s", ...) failed: %s", fp, fmt, BENT_ERRMSG);
X	va_end(ap);
X}
X#endif /* __STDC__ */
Shar_Eof
echo x - efread.c
sed 's/^X//' <<\Shar_Eof >efread.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid efread(char *buff, int len, int count, FILE *fp) {
X#else /* __STDC__ */
Xvoid efread(buff, len, count, fp)
Xchar *buff;
Xint len, count;
XFILE *fp;
X{
X#endif /* __STDC__ */
X	if (fread(buff, len, count, fp) != count)
X		error("fread(0x%lx, %d, %d, %s) failed: %s", buff, len, count, _FD2FN(fileno(fp)), BENT_ERRMSG);
X}
Shar_Eof
echo x - efree.c
sed 's/^X//' <<\Shar_Eof >efree.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid efree(char *ptr) {
X#else /* __STDC__ */
Xvoid efree(char *ptr)
Xchar *ptr;
X{
X#endif /* __STDC__ */
X	_BENT_MALLOC_HEADER *header, *trailer;
X
X	header = (_BENT_MALLOC_HEADER *) (ptr - sizeof(_BENT_MALLOC_HEADER));
X	if (header->magic != _BENT_MALLOC_MAGIC) {
X		(void) fprintf(stderr, "%s: warning: bogus call to efree(0x%lx)", progname, ptr);
X		if (header->magic == _BENT_MALLOC_MAGIC - 1)
X			(void) fprintf(stderr, " -- possible double free\n");
X		else
X			(void) fprintf(stderr, "\n");
X		return;
X	}
X	header->magic = _BENT_MALLOC_MAGIC - 1;
X	trailer = (_BENT_MALLOC_HEADER *) (ptr + header->len);
X	if (trailer->magic != _BENT_MALLOC_MAGIC || trailer->len != header->len) {
X		(void) fprintf(stderr, "%s: warning: bogus call to efree(0x%lx) -- possible pointer overruns treading on malloc arena\n", progname, ptr);
X		return;
X	}
X	free((char *)header);
X}
Shar_Eof
echo x - efseek.c
sed 's/^X//' <<\Shar_Eof >efseek.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid efseek(FILE *fp, long offset, int whence) {
X#else /* __STDC__ */
Xvoid efseek(fp, offset, whence)
XFILE *fp;
Xlong offset;
Xint whence;
X{
X#endif /* __STDC__ */
X	if (fseek(fp, offset, whence) != NULL)
X		error("fseek(%s, %ld, %d) failed: %s", _FD2FN(fileno(fp)), offset, whence, BENT_ERRMSG);
X}
Shar_Eof
echo x - efwrite.c
sed 's/^X//' <<\Shar_Eof >efwrite.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid efwrite(const char *buff, int len, int count, FILE *fp) {
X#else /* __STDC__ */
Xvoid efwrite(buff, len, count, fp)
Xchar *buff;
Xint len, count;
XFILE *fp;
X{
X#endif /* __STDC__ */
X	if (fwrite(buff, len, count, fp) != count)
X		error("fwrite(0x%lx, %d, %d, %s) failed: %s", buff, len, count, _FD2FN(fileno(fp)), BENT_ERRMSG);
X}
Shar_Eof
echo x - emalloc.c
sed 's/^X//' <<\Shar_Eof >emalloc.c
X#include <bent.h>
X
X#ifdef __STDC__
Xchar *emalloc(unsigned n) {
X#else /* __STDC__ */
Xchar *emalloc(n)
Xunsigned n;
X{
X#endif /* __STDC__ */
X	char *ptr;
X	_BENT_MALLOC_HEADER *tmp;
X
X	if ((ptr = malloc(n + 2*sizeof(_BENT_MALLOC_HEADER))) == NULL)
X		error("malloc(%d) failed: %s", n, BENT_ERRMSG);
X
X	tmp = (_BENT_MALLOC_HEADER *) ptr;
X	tmp->magic = _BENT_MALLOC_MAGIC;
X	tmp->len = n;
X
X	tmp = (_BENT_MALLOC_HEADER *) (ptr + sizeof(_BENT_MALLOC_HEADER) + n);
X	tmp->magic = _BENT_MALLOC_MAGIC;
X	tmp->len = n;
X
X	return(ptr + sizeof(_BENT_MALLOC_HEADER));
X}
Shar_Eof
echo x - emkstemp.c
sed 's/^X//' <<\Shar_Eof >emkstemp.c
X#include <bent.h>
X
X#ifdef __STDC__
Xint emkstemp(char *ptr) {
X#else /* __STDC__ */
Xint emkstemp(ptr)
Xchar *ptr;
X{
X#endif /* __STDC__ */
X	int fd;
X
X	if ((fd = mkstemp(ptr)) < 0)
X		error("mkstemp(%s) failed: %s", ptr, BENT_ERRMSG);
X
X	return(fd);
X}
Shar_Eof
echo x - eopen.c
sed 's/^X//' <<\Shar_Eof >eopen.c
X#include <bent.h>
X
X#ifdef __STDC__
Xint eopen(const char *name, int flags, int mode) {
X#else /* __STDC__ */
Xint eopen(name, flags, mode)
Xchar *name;
Xint flags, mode;
X{
X#endif /* __STDC__ */
X	int fd;
X
X	if ((fd = open(name, flags, mode)) < 0)
X		error("open(%s, %d, %d) failed: %s", name, flags, mode, BENT_ERRMSG);
X	_bentio_filename_table[fd] = strdup(name);
X	return(fd);
X}
Shar_Eof
echo x - eprintf.c
sed 's/^X//' <<\Shar_Eof >eprintf.c
X#include <bent.h>
X
X#ifdef __STDC__
X#include <stdarg.h>
Xvoid eprintf(const char *fmt, ...) {
X	va_list ap;
X
X	va_start(ap, fmt);
X	if (vprintf(fmt, ap) == EOF)
X		error("eprintf(\"%s\", ...) failed: %s", fmt, BENT_ERRMSG);
X	va_end(ap);
X}
X#else /* __STDC__ */
X#include <varargs.h>
Xvoid eprintf(va_list)
Xva_dcl
X{
X	va_list ap;
X	char *fmt;
X
X	va_start(ap);
X	fmt = va_arg(ap, char *);
X	if (vprintf(fmt, ap) == EOF)
X		error("eprintf("%s", ...) failed: %s", fmt, BENT_ERRMSG);
X	va_end(ap);
X}
X#endif /* __STDC__ */
Shar_Eof
echo x - eputchar.c
sed 's/^X//' <<\Shar_Eof >eputchar.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid eputchar(int c) {
X#else /* __STDC__ */
Xvoid eputchar(c)
Xint c;
X{
X#endif /* __STDC__ */
X	if (putchar(c) == EOF)
X		error("eputchar('%c') failed: %s", c, BENT_ERRMSG);
X}
Shar_Eof
echo x - erealloc.c
sed 's/^X//' <<\Shar_Eof >erealloc.c
X#include <bent.h>
X
X#ifdef __STDC__
Xchar *erealloc(char *ptr, unsigned n) {
X#else /* __STDC__ */
Xchar *erealloc(ptr, n)
Xchar *ptr;
Xunsigned n;
X{
X#endif /* __STDC__ */
X	_BENT_MALLOC_HEADER *header, *trailer;
X
X	header = (_BENT_MALLOC_HEADER *) (ptr - sizeof(_BENT_MALLOC_HEADER));
X	if (header->magic != _BENT_MALLOC_MAGIC) {
X		(void) fprintf(stderr, "%s: warning: bogus call to erealloc(0x%lx, %u)", progname, ptr, n);
X		if (header->magic == _BENT_MALLOC_MAGIC - 1) {
X			(void) fprintf(stderr, " -- possible double free\n");
X		} else {
X			(void) fprintf(stderr, "\n");
X			return(realloc(ptr, n));
X		}
X	}
X
X	trailer = (_BENT_MALLOC_HEADER *) (ptr + header->len);
X	if (trailer->magic != _BENT_MALLOC_MAGIC || trailer->len != header->len)
X		(void) fprintf(stderr, "%s: warning: bogus call to erealloc(0x%lx) -- possible pointer overruns treading on malloc arena\n", progname, ptr);
X
X	header = (_BENT_MALLOC_HEADER *) realloc((char *)header, n+2*sizeof(_BENT_MALLOC_HEADER));
X	if (header == NULL)
X		error("erealloc(%lx, %u) failed: %s", ptr, n, BENT_ERRMSG);
X
X	header->len = n;
X	ptr = ((char *) header) + sizeof(_BENT_MALLOC_HEADER);
X	trailer = (_BENT_MALLOC_HEADER *) (ptr + header->len);
X	trailer->magic = _BENT_MALLOC_MAGIC;
X	trailer->len = header->len;
X
X	return(ptr);
X}
Shar_Eof
echo x - error.3b
sed 's/^X//' <<\Shar_Eof >error.3b
X.TH ERROR 3B "18 November 1988"
X.SH NAME
Xerror \- error handling library routines
X.SH SYNOPSIS
X#include <bent.h>
X.br
Xextern char *progname;
X.br
X.SH DESCRIPTION
X.PP
XThe \fImain()\fR procedure should initialize \fIprogname\fR to argv[0], as
Xthat is used in generating error messages. These routines behave exactly
Xlike the system calls and library routines they are wrapped around, except
Xthat they don't return if the call failed. Instead they print a suitable
Xerror message to stderr and exit with status 1. The routine \fIerror\fR
Xhas syntax identical to printf(3S), but prepends the message with
X\fIprogname\fR, and exits with status 1.
X.SH "LIST OF FUNCTIONS"
X.sp 2
X.nf
X\fIName\fP		\fIDescription\fP
Xeclose	wrapper around close(2)
Xefclose	wrapper around fclose(3S)
Xefdopen	wrapper around fdopen(3S)
Xefflush	wrapper around fflush(3S)
Xefgets	wrapper around fgets(3S)
Xefopen	wrapper around fopen(3S)
Xefprintf	wrapper around fprintf(3S)
Xefread	wrapper around fread(3S)
Xefree	wrapper around free(3S)
Xefseek	wrapper around fseek(3S)
Xefwrite	wrapper around fwrite(3S)
Xemalloc	wrapper around malloc(3S)
Xemkstemp	wrapper around mkstemp(3S)
Xeopen	wrapper around open(2)
Xeprintf	wrapper around printf(3S)
Xeputchar	wrapper around putchar(3S)
Xerealloc	wrapper around realloc(3S)
Xerror	print message and exit
Xetruncate	wrapper around truncate(2)
Xeunlink	wrapper around unlink(2)
Xewrite	wrapper around write(2)
X.fi
X.SH "SEE ALSO"
Xintro(3B), perror(3S), printf(3S), intro(2), intro(3)
Shar_Eof
echo x - error.c
sed 's/^X//' <<\Shar_Eof >error.c
X#include <bent.h>
X
X#ifdef __STDC__
X#include <stdarg.h>
Xvoid error(const char *fmt, ...) {
X	va_list ap;
X
X	(void) fprintf(stderr, "%s: ", progname);
X	va_start(ap, fmt);
X	(void) vfprintf(stderr, fmt, ap);
X	va_end(ap);
X	(void) fprintf(stderr, "\n");
X	exit(1);
X}
X#else /* __STDC__ */
X#include <varargs.h>
Xvoid error(va_list)
Xva_dcl
X{
X	va_list ap;
X	char *fmt;
X
X	(void) fprintf(stderr, "%s: ", progname);
X	va_start(ap);
X	fmt = va_arg(ap, char *);
X	(void) vfprintf(stderr, fmt, ap);
X	va_end(ap);
X	(void) fprintf(stderr, "\n");
X	exit(1);
X}
X#endif /* __STDC__ */
Shar_Eof
echo x - etruncate.c
sed 's/^X//' <<\Shar_Eof >etruncate.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid etruncate(const char *name, unsigned long len) {
X#else /* __STDC__ */
Xvoid etruncate(name, len)
Xchar *name;
Xunsigned long len;
X{
X#endif /* __STDC__ */
X	if (truncate(name, len) < 0)
X		error("etruncate(%s, %ul) failed: %s", name, len, BENT_ERRMSG);
X}
Shar_Eof
echo x - eunlink.c
sed 's/^X//' <<\Shar_Eof >eunlink.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid eunlink(const char *name) {
X#else /* __STDC__ */
Xvoid eunlink(name)
Xchar *name;
X{
X#endif /* __STDC__ */
X	if (unlink(name) != NULL)
X		error("unlink(%s) failed: %s", name, BENT_ERRMSG);
X}
Shar_Eof
echo x - ewrite.c
sed 's/^X//' <<\Shar_Eof >ewrite.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid ewrite(int fd, const char *buff, int count) {
X#else /* __STDC__ */
Xvoid ewrite(fd, buff, count)
Xint fd;
Xchar *buff;
Xint count;
X{
X#endif /* __STDC__ */
X	if (write(fd, buff, count) != count)
X		error("write(%s, 0x%lx, %d) failed: %s", _FD2FN(fd), buff, count, BENT_ERRMSG);
X}
Shar_Eof
echo x - getdtablesize.c
sed 's/^X//' <<\Shar_Eof >getdtablesize.c
X#include <bent-stdio.h>
X
X#ifdef __STDC__
Xint main(int argc, char **argv) {
X#else /* __STDC__ */
Xint main(argc, argv)
Xint argc;
Xchar **argv;
X{
X#endif /* __STDC__ */
X	return(printf("%d\n", getdtablesize()) < 0);
X}
Shar_Eof
echo x - getline.3b
sed 's/^X//' <<\Shar_Eof >getline.3b
X.TH GETLINE 3B  "18 November 1988"
X.SH NAME
Xgetline, putline \- read and write arbitrarily long text lines
X.SH SYNOPSIS
X.B #include <bent.h>
X.PP
X.B char *getline(buff, stream)
X.br
X.B char *buff;
X.br
X.B FILE *stream;
X.PP
X.B void putline(buff, stream)
X.br
X.B char *buff;
X.br
X.SM
X.B FILE
X.B *stream;
X.SH DESCRIPTION
X\fIgetline\fR reads characters from \fIstream\fR until newline or EOF is
Xreached.  It reads them into \fIbuff\fR, growing it as necessary. \fIbuff\fR
XMUST be a buffer created by \fIgetline\fR. If \fIbuff\fR is "(char *)NULL"
X\fIgetline\fR will allocate a new buffer. \fIgetline\fR returns the pointer
Xto the filled buffer, or NULL on EOF (in which case it de-allocates
X\fIbuff\fR).
X.PP
X\fIputline\fR writes a buffer created by \fIgetline\fR to \fIstream\fR.
X.SH "SEE ALSO"
Xintro(3B), gets(3S), puts(3S)
Shar_Eof
echo x - getline.c
sed 's/^X//' <<\Shar_Eof >getline.c
X#include <bent.h>
X
X#define _GETLINE_INIT_SIZE 7	/* 2**N == 128 bytes initial */
X
X#ifdef __STDC__
Xchar *getline(char *buff, FILE *fp) {
X#else /* __STDC__ */
Xchar *getline(buff, fp)
Xchar *buff;
XFILE *fp;
X{
X#endif /* __STDC__ */
X	char *curch, *stop;
X	int c;
X
X	if (feof(fp)) {
X		if (buff)
X			efree(buff-1);
X		return(0);
X	}
X
X	if (buff == NULL) {
X		buff = emalloc(1<<_GETLINE_INIT_SIZE);
X		*buff++ = _GETLINE_INIT_SIZE;
X	}
X
X	curch = buff;
X	stop = buff + (1<<buff[-1]) - 2;
X	while ((c = getc(fp)) != EOF && c != '\n') {
X		if (curch >= stop) {
X			buff = erealloc(buff, 1<<(buff[-1]+1)) + 1;
X			curch = buff + (1<<buff[-1]) - 2;
X			buff[-1]++;
X			stop = buff + (1<<buff[-1]) - 2;
X		}
X		if (c == '\0')
X			*curch++ = '\n';
X		else
X			*curch++ = c;
X	}
X	*curch = 0;
X
X	if (feof(fp)) {
X		if (strlen(buff) == 0) {
X			efree(buff-1);
X			return(0);
X		} else {
X			clearerr(fp);
X		}
X	}
X
X	return(buff);
X}
Shar_Eof
echo x - intro.3b
sed 's/^X//' <<\Shar_Eof >intro.3b
X.TH INTRO 3B "18 November 1988"
X.SH NAME
Xintro \- introduction to Bennett's library of handy routines
X.SH SYNOPSIS
X#include <bent.h>
X.br
Xextern char *progname;
X.br
Xextern char syntax_args[];
X.SH DESCRIPTION
XThe include file <bent.h> contains declarations of all the functions in the
X\fIbent\fR library \fIlibbent\fR (described in Section 3B).
X.PP
XThe routines are divided into two catagories: first there are wrappers around
Xmany standard system calls found in section 2 of the Unix Programmer's
XManual (UPM) and library routines (section 3 of the UPM) which check for
Xerror conditions and only return on success. On failure they will exit with
Xan errorlevel of 1 after printing \fIprogname\fR (should be initialized to
Xargv[0] at the beginning of main), the name of the routine that failed, and
Xsys_errlist[errno] (these will be printed to stderr). All these routines are
Xthe same name as the routines they are built upon, preceded by "e". Thus
X\fIemalloc()\fR, \fIefopen()\fR, etc. See error(3B).  The second catagory is
Xauxiliary helpful support routines.
X.PP
X\fIBent.h\fR includes support declarations and function prototypes (under
X#ifdef __STDC __; old-style declarations are also provided for older
Xcompilers). It also includes \fIbent-stdio.h\fR which in turn includes all
Xthe relevant support files for all the calls in sections 2 and 3 of the UPM,
Xand function prototypes for them all.
X.PP
XThe link editor searches this library under the \*(lq\-lbent\*(rq option.
X.SH "LIST OF FUNCTIONS"
X.sp 2
X.nf
X\fIName\fP		\fIAppears on Page\fP	\fIDescription\fP
Xeclose	error(3B)			wrapper around close(2)
Xefclose	error(3B)			wrapper around fclose(3S)
Xefdopen	error(3B)			wrapper around fdopen(3S)
Xefflush	error(3B)			wrapper around fflush(3S)
Xefgets	error(3B)			wrapper around fgets(3S)
Xefopen	error(3B)			wrapper around fopen(3S)
Xefprintf	error(3B)			wrapper around fprintf(3S)
Xefread	error(3B)			wrapper around fread(3S)
Xefree	error(3B)			wrapper around free(3S)
Xefseek	error(3B)			wrapper around fseek(3S)
Xefwrite	error(3B)			wrapper around fwrite(3S)
Xemalloc	error(3B)			wrapper around malloc(3S)
Xemkstemp	error(3B)			wrapper around mkstemp(3S)
Xeopen	error(3B)			wrapper around open(2)
Xeprintf	error(3B)			wrapper around printf(3S)
Xeputchar	error(3B)			wrapper around putchar(3S)
Xerealloc	error(3B)			wrapper around realloc(3S)
Xerror	error(3B)			print message and exit
Xetruncate	error(3B)			wrapper around truncate(2)
Xeunlink	error(3B)			wrapper around unlink(2)
Xewrite	error(3B)			wrapper around write(2)
Xgetline	getline(3B)			read arbitrarily long text line
Xmax		max(3B)				maximum of two integers
Xmin		max(3B)				minimum of two integers
Xputline	getline(3B)			write line read by getline(3B)
Xreadfile	readfile(3B)			read a whole file into a buffer
Xstandrand	standrand(3B)			standard pseudo-random number generator
Xstrdup	strdup(3B)			return a duplicate of a string
Xsyntax	syntax(3B)			print a syntax error message and exit
X.fi
X.SH "SEE ALSO"
Xerror(3B), perror(3), getline(3B), max(3B), readfile(3B), standrand(3B),
Xstrdup(3B), syntax(3B)
Shar_Eof
echo x - max.3b
sed 's/^X//' <<\Shar_Eof >max.3b
X.TH MAX 3B  "5 December 1988"
X.SH NAME
Xmax, min \- maximum or minimum of two integers
X.SH SYNOPSIS
X.B int max(x, y)
X.br
X.B int x, y;
X.PP
X.B int min(x, y)
X.br
X.B int x, y;
X.SH DESCRIPTION
XReally staggeringly obvious.
Shar_Eof
echo x - max.c
sed 's/^X//' <<\Shar_Eof >max.c
X#ifdef __STDC__
Xint max(int x, int y) {
X#else /* __STDC__ */
Xint max(x, y)
Xint x, y;
X{
X#endif /* __STDC__ */
X	return(x>y ? x : y);
X}
Shar_Eof
echo x - min.c
sed 's/^X//' <<\Shar_Eof >min.c
X#ifdef __STDC__
Xint min(int x, int y) {
X#else /* __STDC__ */
Xint min(x, y)
Xint x, y;
X{
X#endif /* __STDC__ */
X	return(x<y ? x : y);
X}
Shar_Eof
echo x - mkprototypes
sed 's/^X//' <<\Shar_Eof >mkprototypes
Xegrep '^[a-zA-Z_].*{$' $* | sed -e 's/[ 	]*[a-z_0-9]*,/,/g' \
X								-e 's/[ 	]*[a-z_0-9]*)/)/g' \
X								-e 's/[ 	]*{$/;/' \
X								-e 's/();/(void);/' \
X								-e 's/^.*\.c://'
Shar_Eof
echo x - progname.c
sed 's/^X//' <<\Shar_Eof >progname.c
Xstatic char progname_initializer[] = "[UNINITIALIZED]";
Xchar *progname = progname_initializer;
Shar_Eof
echo x - putline.c
sed 's/^X//' <<\Shar_Eof >putline.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid putline(char *buff, FILE *fp) {
X#else /* __STDC__ */
Xvoid putline(buff, fp)
Xchar *buff;
XFILE *fp;
X{
X#endif /* __STDC__ */
X	char *ptr, *stop;
X
X	ptr = buff;
X	stop = buff + (1<<buff[-1]) - 2;
X	while ((ptr = index(ptr, '\n')) && ptr < stop)
X		*ptr++ = '\0';
X	while (*ptr++)
X		/* NULL BODY */;
X	*ptr++ = '\n';
X	efwrite(buff, 1, ptr-buff, fp);
X}
Shar_Eof
echo x - readfile.3b
sed 's/^X//' <<\Shar_Eof >readfile.3b
X.TH READFILE 3B  "5 December 1988"
X.SH NAME
Xreadfile \- read a whole file into a buffer
X.SH SYNOPSIS
X.B #include <bent.h>
X.PP
X.B char *readfile(fp, len)
X.br
X.B FILE *fp;
X.br
X.B int *len;
X.SH DESCRIPTION
X\fIreadfile\fR reads the entire contents of the file pointed to by \fIfp\fR
Xinto a dynamically allocated buffer, adjusting the size as necessary. It
Xreturns a pointer to the buffer, with the actual length stored in the int
Xpointed to by \fIlen\fR. \fIfp\fR is closed.
Shar_Eof
echo x - readfile.c
sed 's/^X//' <<\Shar_Eof >readfile.c
X#include <bent.h>
X
X#ifdef __STDC__
Xchar *readfile(FILE *fp, int *len) {
X#else /* __STDC__ */
Xchar *readfile(fp, len)
XFILE *fp;
Xint *len;
X{
X#endif /* __STDC__ */
X	char *buff, *ptr;
X	int allocated, n;
X
X	allocated = 65536;
X	*len = 0;
X	ptr = buff = emalloc(allocated);
X	while (n = fread(ptr, 1, allocated - *len, fp)) {
X		*len += n;
X		ptr += n;
X		if (*len == allocated) {
X			allocated *= 2;
X			buff = erealloc(buff, allocated);
X			ptr = buff + *len;
X		}
X	}
X	efclose(fp);
X	return(erealloc(buff, *len));
X}
Shar_Eof
echo x - standrand.3b
sed 's/^X//' <<\Shar_Eof >standrand.3b
X.TH STANDRAND 3B  "18 November 1988"
X.SH NAME
Xstandrand \- standard pseudo-random number generator
X.SH SYNOPSIS
X.B #include <bent.h>
X.PP
X.B
Xstand_rand_seed = /* some good integer */;
X.PP
X.B double stand_rand();
X.SH DESCRIPTION
X\fIstand_rand\fR implements a pseudo-random number generator as described in
XCACM V31N10 (10/88). It returns a double uniformly distributed on [0,1). It
Xhas a period of 2**31 - 2.
Shar_Eof
echo x - standrand.c
sed 's/^X//' <<\Shar_Eof >standrand.c
X#include <bent.h>
X/* seed[i+1] == A*seed[i] % M */
X#define A 16807
X#define M 2147483647
X#define Q 127773		/* M div A */
X#define R 2836			/* M mod A */
X
X#ifdef __STDC__
Xdouble stand_rand(void) {
X#else /* __STDC__ */
Xdouble stand_rand()
X{
X#endif /* __STDC__ */
X	int lo, hi;
X
X	hi = stand_rand_seed / Q;
X	lo = stand_rand_seed % Q;
X	stand_rand_seed = A*lo - R*hi;
X	if (stand_rand_seed <= 0)
X		stand_rand_seed += M;
X	return(((double)stand_rand_seed-1.0) / ((double)M-1.0));
X}
Shar_Eof
echo x - strdup.3b
sed 's/^X//' <<\Shar_Eof >strdup.3b
X.TH STRDUP 3B  "18 November 1988"
X.SH NAME
Xstrdup \- make a copy of a string
X.SH SYNOPSIS
X.B #include <bent.h>
X.PP
X.B char *strdup(s)
X.br
X.B char *s;
X.SH DESCRIPTION
X\fIstrdup\fR returns a copy of the string pointed to by \fIs\fR. It can be
Xdestroyed later by passing it to \fIefree(3B)\fR.
Shar_Eof
echo x - strdup.c
sed 's/^X//' <<\Shar_Eof >strdup.c
X#include <bent.h>
X
X#ifdef __STDC__
Xchar *strdup(const char *s) {
X#else /* __STDC__ */
Xchar *strdup(s)
Xchar *s;
X{
X#endif /* __STDC__ */
X	return(strcpy(emalloc(strlen(s)+1), s));
X}
Shar_Eof
echo x - syntax.3b
sed 's/^X//' <<\Shar_Eof >syntax.3b
X.TH SYNTAX 3B "18 November 1988"
X.SH NAME
Xsyntax \- print syntax message and exit
X.SH SYNOPSIS
X#include <bent.h>
X.br
Xchar *progname;
X.br
Xchar syntax_args[] = "(optional flags and arguments)"
X.PP
Xvoid syntax();
X.SH DESCRIPTION
X\fIsyntax\fR prints a syntax message using \fIprogname\fR (which should be
Xinitialized by \fImain()\fR to argv[0]), then exits.
X.SH "SEE ALSO"
Xintro(3B), error(3B)
Shar_Eof
echo x - syntax.c
sed 's/^X//' <<\Shar_Eof >syntax.c
X#include <bent.h>
X
X#ifdef __STDC__
Xvoid syntax(void) {
X#else /* __STDC__ */
Xvoid syntax()
X{
X#endif /* __STDC__ */
X	(void) fprintf(stderr, "syntax: %s %s\n", progname, syntax_args);
X	exit(1);
X}
Shar_Eof
exit 0

-Bennett
bet@orion.mc.duke.edu

bet@dukeac.UUCP (Bennett Todd) (02/04/89)

: This is a sharchive -- extract the files by running through sh.
echo x - bent-stdio.h
sed 's/^X//' <<\Shar_Eof >bent-stdio.h
X/********************************\
X*                                *
X* Forms for Sections 2 and 3 UPM *
X*                                *
X* Based on the 4.3BSD UPM        *
X* ifdef-ed for (and only tested  *
X* on) SunOS.                     *
X*                                *
X\********************************/
X
X/* Includes for section 2 */
X#include <sys/errno.h>
X#include <sys/types.h>
X#include <sys/socket.h>
X#include <sys/file.h>
X#include <sys/time.h>
X#ifndef sun
X#include <sys/inode.h>
X#else
X#include <sys/vnode.h>
X#include <ufs/inode.h>
X#endif
X#include <fcntl.h>
X#include <sys/param.h>
X#include <sys/resource.h>
X#include <sys/ioctl.h>
X#include <sys/signal.h>
X#include <sys/ptrace.h>
X#ifndef sun
X#include <sys/quota.h>
X#else
X#include <ufs/quota.h>
X#endif
X#include <sys/uio.h>
X#include <sys/reboot.h>
X#include <signal.h>
X#include <sys/stat.h>
X#include <syscall.h>
X#include <sys/wait.h>
X
X/* Includes for section 3 */
X#include <math.h>
X#include <assert.h>
X#include <netinet/in.h>
X#include <ctype.h>
X#include <sys/dir.h>
X#include <stdio.h>
X#include <disktab.h>
X#include <fstab.h>
X#include <grp.h>
X#include <netdb.h>
X#include <pwd.h>
X#ifndef sun
X#include <ttyent.h>
X#endif
X#include <arpa/inet.h>
X#include <nlist.h>
X#ifndef sun
X#include <netns/ns.h>
X#endif
X#ifdef __STDC__
X#include <stdarg.h>
X#else
X#include <varargs.h>
X#endif
X#include <arpa/nameser.h>
X#ifndef sun
X#include <resolv.h>
X#else
X#include <arpa/resolv.h>
X#endif
X#include <setjmp.h>
X#if 0
X#include <strings.h>	/* triggers a gratuitous type incompatibility */
X#endif
X#include <sgtty.h>
X#include <syslog.h>
X#include <sys/timeb.h>
X#include <sys/times.h>
X#include <sys/vlimit.h>
X#include <sys/vtimes.h>
X
X#ifdef __STDC__
X
X/* accept(2) -- accept a connection on a socket */
Xint accept(int, struct sockaddr *, int *);
X
X/* access(2) -- determine accessibility of file */
Xint access(const char *, int);
X
X/* acct(2) -- turn accounting on or off */
Xint acct(const char *);
X
X/* adjtime(2) -- correct the time to allow synchronization of the system clock */
Xint adjtime(struct timeval *, struct timeval *);
X
X/* bind(2) -- bind a name to a socket */
Xint bind(int, struct sockaddr *, int);
X
X/* brk(2), sbrk(2) -- change data segment size */
Xchar *brk(char *);
Xchar *sbrk(int);
X
X/* chdir(2) -- change working directory */
Xint chdir(const char *);
X
X/* chmod(2) -- change mode of file */
Xint chmod(const char *, int);
Xint fchmod(int, int);
X
X/* chown(2) -- change owner and group of a file */
Xint chown(const char *, int, int);
Xint fchown(int, int, int);
X
X/* chroot(2) -- change root directory */
Xint chroot(const char *);
X
X/* close(2) -- delete a descriptor */
Xint close(int);
X
X/* connect(2) -- initiate a connection on a socket */
Xint connect(int, struct sockaddr *, int);
X
X/* creat(2) -- create a new file */
Xint creat(const char *, int);
X
X/* dup(2), dup2(2) -- duplicate a descriptor */
Xint dup(int);
Xint dup2(int, int);
X
X/* execve(2) -- execute a file */
Xint execve(const char *, const char *[], const char *[]);
X
X/* _exit(2) -- terminate a process */
Xvoid _exit(int);
X
X/* fcntl(2) -- file control */
Xint fcntl(int, int, int);
X
X/* flock(2) -- apply or remove an advisory lock on an open file */
Xint flock(int, int);
X
X/* fork(2) -- create a new process */
Xint fork(void);
X
X/* fsync(2) -- synchronize a file's in-core state with that on disk */
Xint fsync(int);
X
X/* getdtablesize(2) -- get descriptor table size */
Xint getdtablesize(void);
X
X/* getgid(2), getegid(2) -- get group identity */
X#ifdef sun
Xtypedef int gid_t;
X#endif
Xgid_t getgid(void);
Xgid_t getegid(void);
X
X/* getgroups(2) -- get group access list */
Xint getgroups(int, int *);
X
X/* gethostid(2), sethostid(2) -- get/set unique identifier of current host */
Xlong gethostid(void);
Xint sethostid(long);
X
X/* gethostname(2), sethostname(2) -- get/set name of current host */
Xint gethostname(const char *, int);
Xint sethostname(const char *, int);
X
X/* getitimer(2), setitimer(2) -- get/set value of interval timer */
Xint getitimer(int, struct itimerval *);
Xint setitimer(int, struct itimerval *, struct itimerval *);
X
X/* getpagesize(2) -- get system page size */
Xint getpagesize(void);
X
X/* getpeername(2) -- get name of connected peer */
Xint getpeername(int, struct sockaddr *, int *);
X
X/* getpgrp(2) -- get process group */
Xint getpgrp(int);
X
X/* getpid(2), getppid(2) -- get proces identification */
Xint getpid(void);
Xint getppid(void);
X
X/* getpriority(2), setpriority(2) -- get/set program scheduling priority */
Xint getpriority(int, int);
Xint setpriority(int, int, int);
X
X/* getrlimit(2), setrlimit(2) -- control maximum system resource consumption */
Xint getrlimit(int, struct rlimit *);
Xint setrlimit(int, struct rlimit *);
X
X/* getrusage(2) -- get information about resource utilization */
Xint getrusage(int, struct rusage *);
X
X/* getsockname(2) -- get socket name */
Xint getsockname(int, struct sockaddr *, int *);
X
X/* getsockopt(2), setsockopt(2) -- get and set options on sockets */
Xint getsockopt(int, int, int, char *, int *);
Xint setsockopt(int, int, int, char *, int *);
X
X/* gettimeofday(2), settimeofday(2) -- get/set date and time */
Xint gettimeofday(struct timeval *, struct timezone *);
Xint settimeofday(struct timeval *, struct timezone *);
X
X/* getuid(2), geteuid(2) -- get user identity */
X#ifdef sun
Xtypedef int uid_t;
X#endif
Xuid_t getuid(void);
Xuid_t geteuid(void);
X
X/* ioctl(2) -- control device */
Xint ioctl(int, unsigned long, char *);
X
X/* kill(2) -- send signal to process */
Xint kill(int, int);
X
X/* killpg(2) -- send signal to process group */
Xint killpg(int, int);
X
X/* link(2) -- make a hard link to a file */
Xint link(const char *, const char *);
X
X/* listen(2) -- listen for connections on a socket */
Xint listen(int, int);
X
X/* lseek(2) -- move read/write pointer */
Xoff_t lseek(int, off_t, int);
X
X/* mkdir(2) -- make a directory file */
Xint mkdir(const char *, int);
X
X/* mknod(2) -- make a special file */
Xint mknod(const char *, int, int);
X
X/* mount(2), umount(2) -- mount or remove file system */
Xint mount(const char *, const char *, int);
Xint umount(const char *);
X
X/* open(2) -- open a file for reading or writing, or create a new file */
Xint open(const char *, int, int);
X
X/* pipe(2) -- create an interprocess communication channel */
Xint pipe(int [2]);
X
X/* profil(2) -- execution time profile */
Xint profil(const char *, int, int, int);
X
X/* ptrace(2) -- process trace */
Xint ptrace(int, int, int *, int);
X
X/* quota(2) -- manipulate disk quotas */
Xint quota(int, int, int, char *);
X
X/* read(2), readv(2) -- read input */
Xint read(int, char *, int);
Xint readv(int, struct iovec *, int);
X
X/* readlink(2) -- read value of a symbolic link */
Xint readlink(const char *, char *, int);
X
X/* reboot(2) -- reboot system or halt processor */
Xint reboot(int);
X
X/* recv(2), recvfrom(2), recvmsg(2) -- receive a message from a socket */
Xint recv(int, char *, int, int);
Xint recvfrom(int, char *, int, int, struct sockaddr *, int *);
Xint recvmsg(int, struct msghdr [], int);
X
X/* rename(2) -- change the name of a file */
Xint rename(const char *, const char *);
X
X/* rmdir(2) -- remove a directory file */
Xint rmdir(const char *);
X
X/* select(2) -- synchronous I/O multiplexing */
Xint select(int, fd_set *, fd_set *, fd_set *, struct timeval *);
X
X/* send(2), sendto(2), sendmsg(2) -- send a message from a socket */
Xint send(int, char *, int, int);
Xint sendto(int, char *, int, int, struct sockaddr *, int);
Xint sendmsg(int, struct msghdr [], int);
X
X/* setgroups(2) -- set group access list */
Xint setgroups(int, int*);
X
X/* setpgrp(2) -- set process group */
Xint setpgrp(int, int);
X
X/* setquota(2) -- enable/disable quotas on a file system */
Xint setquota(char *, char *);
X
X/* setregid(2) -- set real and effective group ID */
Xint setregid(int, int);
X
X/* setreuid(2) -- set real and effective user ID's */
Xint setreuid(int, int);
X
X/* shutdown(2) -- shut down part of a full-duplex connection */
Xint shutdown(int, int);
X
X/* sigblock(2) -- block signals */
Xint sigblock(int);
X
X/* sigpause(2) -- atomically release blocked signals and wait for interrupt */
Xint sigpause(int);
X
X/* sigreturn(2) -- return from a signal (4.3BSD only) */
Xint sigreturn(struct sigcontext *);
X
X/* sigsetmask(2) -- set current signal mask */
Xint sigsetmask(int);
X
X/* sigstack(2) -- set and/or get signal stack context */
Xint sigstack(struct sigstack *, struct sigstack *);
X
X/* sigvec(2) -- software signal facilities */
Xint sigvec(int, struct sigvec *, struct sigvec *);
X
X/* socket(2) -- create an endpoint ffor communication */
Xint socket(int, int, int);
X
X/* socketpair(2) -- create a pair of connected sockets */
Xint socketpair(int, int, int, int [2]);
X
X/* stat(2), lstat(2), fstat(2) -- get file status */
Xint stat(const char *, struct stat *);
Xint lstat(const char *, struct stat *);
Xint fstat(int, struct stat *);
X
X/* swapon(2) -- add a swap device for interleaved paging/swapping */
Xint swapon(const char *);
X
X/* symlink(2) -- make a symbolic link to a file */
Xint symlink(const char *, const char *);
X
X/* sync(2) -- update super-block */
Xint sync(void);
X
X/* syscall(2) -- indirect system call */
Xint syscall(int, ...);
X
X/* truncate(2) -- truncate a file to a specified length */
Xint truncate(const char *, off_t);
Xint ftruncate(int, off_t);
X
X/* umask(2) -- set file creation mode mask */
Xint umask(int);
X
X/* unlink(2) -- remove directory entry */
Xint unlink(const char *);
X
X/* utimes(2) -- set file times */
Xint utimes(const char *, struct timeval [2]);
X
X/* vfork(2) -- spawn new process in a virtual memory efficient way */
Xint vfork(void);
X
X/* vhangup(2) -- virtually "hangup" the current control terminal */
Xint vhangup(void);
X
X/* wait(2), wait3(2) -- wait for process to terminate */
Xint wait(union wait *);
Xint wait3(union wait *, int, struct rusage *);
X
X/* write(2), writev(2) -- write output */
Xint write(int, const char *, int);
Xint writev(int, struct iovec *, int);
X
X/* abort(3) -- generate a fault */
Xint abort(void);
X
X/* abs(3) -- integer absolute value */
Xint abs(int);
X
X/* alarm(3C) -- schedule signal after specified time */
Xint alarm(unsigned);
X
X/* asinh(3M), acosh(3M), atanh(3M) -- inverse hyperbolic functions */
Xdouble asinh(double);
Xdouble acosh(double);
Xdouble atanh(double);
X
X/* assert(3) -- program verification */
X#ifndef assert
Xvoid assert(int);
X#endif
X
X/* atof(3), atoi(3), atol(3) -- convert ASCII to numbers */
Xdouble atof(const char *);
Xint atoi(const char *);
Xlong atol(const char *);
X
X/* bcopy(3), bcmp(3), bzero(3), ffs(3) -- bit and byte string operations */
Xvoid bcopy(const char *, char *, int);
Xint bcmp(const char *, const char *, int);
Xvoid bzero(char *, int);
Xint ffs(int);
X
X/* htonl(3N), htons(3N), ntonl(3N), ntohs(3N) -- convert values between host and network byte order */
X#ifndef htonl
Xu_long htonl(u_long);
Xu_short htons(u_short);
Xu_long ntohl(u_long);
Xu_short ntohs(u_short);
X#endif
X
X/* crypt(3), setkey(3), encrypt(3) -- DES encryption */
Xchar *crypt(char *, char *);
Xvoid setkey(char *);
Xvoid encrypt(char *, int);
X
X/* ctime(3), localtime(3), gmtime(3), asctime(3), timezone(3) -- convert date and time to ASCII */
Xchar *ctime(long *);
Xstruct tm *localtime(long *);
Xstruct tm *gmtime(long *);
Xchar *asctime(struct tm *);
Xchar *timezone(int, int);
X
X/* isalpha(3), isupper(3), islower(3), isdigit(3), isxdigit(3), isalnum(3), isspace(3), ispunct(3), isprint(3), isgraph(3), iscntrl(3), isascii(3), toupper(3), tolower(3), toascii(3) -- character classification macros */
X#ifndef isalpha
Xint isalpha(int);
Xint isupper(int);
Xint islower(int);
Xint isdigit(int);
Xint isxdigit(int);
Xint isalnum(int);
Xint isspace(int);
Xint ispunct(int);
Xint isprint(int);
Xint isgraph(int);
Xint iscntrl(int);
Xint isascii(int);
Xint toupper(int);
Xint tolower(int);
Xint toascii(int);
X#endif
X
X/* curses(3X) -- TBD */
X
X/* dbm(3X) -- TBD */
X
X/* opendir(3), readdir(3), telldir(3), seekdir(3), rewinddir(3), closedir(3) -- directory operations */
XDIR *opendir(const char *);
Xstruct direct *readdir(DIR *);
Xlong telldir(DIR *);
Xvoid seekdir(DIR *, long);
X#ifndef rewinddir
Xvoid rewinddir(DIR *);
X#endif
Xvoid closedir(DIR *);
X
X/* ecvf(3), fcvt(3), gcvt(3) -- output conversion */
Xchar *ecvt(double, int, int *, int *);
Xchar *fcvt(double, int, int *, int *);
Xchar *gcvf(double, int, char *);
X
X/* end(3), etext(3), edata(3) -- last locations in program */
Xextern int end;
Xextern int etext;
Xextern int edata;
X
X/* erf(3M), erfc(3M) -- error functions */
Xdouble erf(double);
Xdouble erfc(double);
X
X/* execl(3), execv(3), execle(3), execlp(3), execvp(3), exect(3), environ(3) -- execute a file */
Xint execl(const char *, ...);
Xint execv(const char *, const char *[]);
Xint execle(const char *, ...);
Xint execlp(const char *, ...);
Xint execvp(const char *, const char *[]);
Xint exect(const char *, const char *[], const char *[]);
Xextern char **environ;
X
X/* exit(3) -- terminate a process after flushing any pending output */
Xvoid exit(int);
X
X/* exp(3M), expm1(3M), log(3M), log10(3M), log1p(3M), pow(3M) -- exponential, logarithm, power */
Xdouble exp(double);
Xdouble expm1(double);
Xdouble log(double);
Xdouble log10(double);
Xdouble log1p(double);
Xdouble pow(double, double);
X
X/* fclose(3S), fflush(3S) -- close or flush a stream */
Xint fclose(FILE *);
Xint fflush(FILE *);
X
X/* ferror(3S), feof(3S), clearerr(3S), fileno(3S) -- stream status inquiries */
X#ifndef fileno
Xint feof(FILE *);
Xint ferror(FILE *);
Xvoid clearerr(FILE *);
Xint fileno(FILE *);
X#endif
X
X/* fabs(3M), floor(3M), ceil(3M), rint(3M) -- absolute value, floor, ceiling, and round-to-nearest functions */
Xdouble fabs(double);
Xdouble floor(double);
Xdouble ceil(double);
Xdouble rint(double);
X
X/* _filbuf(3U), _flsbuf(3U) -- visible underpinnings of stdio */
Xint _filbuf(FILE *);
Xint _flsbuf(unsigned char, FILE *);
X
X/* fopen(3S), freopen(3S), fdopen(3S) -- open a stream */
XFILE *fopen(const char *, const char *);
XFILE *freopen(const char *, const char *, FILE *);
XFILE *fdopen(int, const char *);
X
X/* fread(3S), fwrite(3S) -- buffered binary input/output */
Xint fread(char *, int, int, FILE *);
Xint fwrite(const char *, int, int, FILE *);
X
X/* frexp(3), ldexp(3), modf(3) -- split into mantissa and exponent */
Xdouble frexp(double, int *);
Xdouble ldexp(double, int);
Xdouble modf(double, double *);
X
X/* fseek(3S), ftell(3S), rewind(3S) -- reposition a stream */
Xint fseek(FILE *, long, int);
Xlong ftell(FILE *);
Xint rewind(FILE *);
X
X/* getc(3S), getchar(3S), fgetc(3S), getw(3S) -- get character or word from stream */
X#ifndef getc
Xint getc(FILE *);
Xint getchar(void);
X#endif
Xint fgetc(FILE *);
Xint getw(FILE *);
X
X/* getdiskbyname(3) -- get disk description by its name */
Xstruct disktab *getdiskbyname(const char *);
X
X/* getenv(3) -- value for environment name */
Xchar *getenv(const char *);
X
X/* getfsent(3), getfsspec(3), getfsfile(3), getfstype(3), setfsent(3), endfsent(3) -- get file system descriptor file entry */
Xstruct fstab *getfsent(void);
Xstruct fstab *getfsspec(char *);
Xstruct fstab *getfsfile(char *);
Xstruct fstab *getfstype(char *);
Xint setfsent(void);
Xint endfsent(void);
X
X/* getgrent(3), getgrgid(3), getgrnam(3), setgrent(3), endgrent(3) -- get group file entry */
Xstruct group *getgrent(void);
Xstruct group *getgrgid(int);
Xstruct group *getgrname(char *);
Xvoid setgrent(void);
Xvoid endgrent(void);
X
X/* gethostbyname(3N), gethostbyaddr(3N), gethostent(3N), sethostent(3N), endhostent(3N) -- get network host entry */
Xextern int h_errno;
Xstruct hostent *gethostbyname(char *);
Xstruct hostent *gethostbyaddr(char *, int, int);
Xstruct hostent *gethostent(void);
Xint sethostent(int);
Xvoid endhostent(void);
X
X/* getlogin(3) -- get login name */
Xchar *getlogin(void);
X
X/* getnetent(3N), getnetbyaddr(3N), getnetbyname(3N), setnetent(3N), endnetent(3N) -- get network entry */
Xstruct netent *getnetent(void);
Xstruct netent *getnetbyaddr(long, int);
Xstruct netent *getnetbyname(char *);
Xint setnetent(int);
Xvoid endnetent(void);
X
X/* getopt(3) -- get option letter from argv */
Xint getopt(int, char **, char *);
Xextern char *optarg;
Xextern int optind;
X
X/* getpass(3) -- read a password */
Xchar *getpass(char *);
X
X/* getprotoent(3N), getprotobynumber(3N), getprotobyname(3N), setprotoent(3N), endprotoent(3N) -- get protocol entry */
Xstruct protoent *getprotoent(void);
Xstruct protoent *getprotobynumber(int);
Xstruct protoent *getprotobyname(char *);
Xint setprotoent(int);
Xvoid endprotoent(void);
X
X/* getpw(3C) -- get name from uid */
Xint getpw(int, char *);
X
X/* getpwent(3), getpwuid(3), getpwnam(3), setpwent(3), endpwent(3), setpwfile(3) -- get password file entry */
Xstruct passwd *getpwuid(int);
Xstruct passwd *getpwnam(char *);
Xstruct passwd *getpwent(void);
Xint setpwent(void);
Xvoid endpwent(void);
Xint setpwfile(char *);
X
X/* gets(3S), fgets(3S) -- get a string from a stream */
Xchar *gets(char *);
Xchar *fgets(char *, int, FILE *);
X
X/* getservent(3N), getservbyport(3N), getservbyname(3N), setservent(3N), endservent(3N) -- get service entry */
Xstruct servent *getservent(void);
Xstruct servent *getservbyport(int, char *);
Xstruct servent *getservbyname(char *, char *);
Xint setservent(int);
Xvoid endservent(void);
X
X#ifndef sun
X/* getttyent(3), getttynam(3), setttyent(3), endttyent(3) -- get ttys file entry */
Xstruct ttyent *getttyent(void);
Xstruct ttyent *getttynam(char *);
Xint setttyent(void);
Xvoid endttyent(void);
X#endif
X
X/* getusershell(3), setusershell(3), endusershell(3) -- get legal user shells */
Xchar *getusershell(void);
Xint setusershell(void);
Xvoid endusershell(void);
X
X/* getwd(3) -- get current working directory pathname */
Xchar *getwd(char *);
X
X/* hypot(3M), cabs(3M) -- Euclidean distance, complex absolute value */
Xdouble hypot(double, double);
Xdouble cabs(struct {double x, y;});
X
X/* copysign(3M), drem(3M), finite(3M), logb(3M), scalb(3M) -- copysign, remainder, exponent manipulations */
Xdouble copysign(double, double);
Xdouble drem(double, double);
Xint finite(double);
Xdouble logb(double);
Xdouble scalb(double, int);
X
X/* inet_addr(3N), inet_network(3N), inet_ntoa(3N), inet_makeaddr(3N), inet_lnaof(3N), inet_netof(3N) -- Internet address manipulation routines */
Xunsigned long inet_addr(char *);
Xunsigned long inet_network(char *);
Xchar *inet_ntoa(struct in_addr);
Xstruct in_addr inet_makeaddr(int, int);
Xint inet_lnaof(struct in_addr);
Xint inet_netof(struct in_addr);
X
X/* infnan(3M) -- signals invalid floating-point operations on a VAX (temporary) */
X#ifdef vax
Xdouble infnan(int);
X#endif
X
X/* initgroups(3) -- initialize group access list */
Xint initgroups(char *, int);
X
X/* insque(3), remque(3) -- insert/remove element from a queue */
Xstruct qelem {
X	struct qelem *q_forw;
X	struct qelem *q_back;
X	char q_data[0];
X};
Xvoid insque(struct qelem *, struct qelem *);
Xvoid remque(struct qelem *);
X
X/* j0(3M), j1(3M), jn(3M), y0(3M), y1(3M), yn(3M) -- bessel functions */
Xdouble j0(double);
Xdouble j1(double);
Xdouble jn(int, double);
Xdouble y0(double);
Xdouble y1(double);
Xdouble yn(int, double);
X
X/* lgamma(3M) -- log gamma function */
Xextern int signgam;
Xdouble lgamma(double);
X
X/* lib2648(3X) -- TBD (roight) */
X
X/* malloc(3), free(3), realloc(3), calloc(3), alloc(3) -- memory allocator */
Xchar *malloc(unsigned);
Xvoid free(char *);
Xchar *realloc(char *, unsigned);
Xchar *calloc(unsigned, unsigned);
Xchar *alloca(int);
X
X/* mktemp(3), mkstemp(3) -- make a unique file name */
Xchar *mktemp(char *);
Xint mkstemp(char *);
X
X/* monitor(3), monstartup(3), moncontrol(3) -- prepare execution profile */
Xvoid monitor(int (*)(), int (*)(), short [], int);
Xvoid monstartup(int (*)(), int (*)());
Xvoid moncontrol(int);
X
X/* mp(3X) -- TBD */
X
X/* ndbm(3) -- TBD */
X
X/* nice(3C) -- set program priority */
Xvoid nice(int);
X
X/* nlist(3) -- get entries from name list */
Xint nlist(const char *, struct nlist []);
X
X#ifndef sun
X/* ns_addr(3N), ns_ntoa(3N) -- Xerox NS(tm) address conversion routines */
Xstruct ns_addr ns_addr(char *);
Xchar *ns_toa(struct ns_addr);
X#endif
X
X/* pause(3C) -- stop until signal */
Xint pause(void);
X
X/* perror(3), sys_errlist(3), sys_nerr(3) -- system error messages */
Xvoid perror(const char *);
Xextern int errno, sys_nerr;
Xextern char *sys_errlist[];
X
X#define BENT_ERRMSG \
X	((errno == 0) ? "No error!?" : \
X			((errno < sys_nerr) ? sys_errlist[errno] : \
X					      "Unknown error" \
X			) \
X	)
X
X/* plot(3X) -- TBD */
X
X/* popen(3), pclose(3) -- initiate I/O to/from a process */
XFILE *popen(const char *, const char *);
Xint pclose(FILE *);
X
X/* printf(3S), fprintf(3S), sprintf(3S) -- formatted output conversions */
Xint printf(const char *, ...);
Xint fprintf(FILE *, const char *, ...);
Xint sprintf(char *, const char *, ...);
Xint _doprnt(const char *, va_list *, FILE *);
X
X/* psignal(3), sys_siglist(3) -- system signal messages */
Xvoid psignal(unsigned, char *);
Xextern char *sys_siglist[];
X
X/* putc(3S), putchar(3S), fputc(3S), putw(3S) -- put character on word on a stream */
X#ifndef putc
Xint putc(char, FILE *);
X#endif
X#ifndef putchar
Xint putchar(int);
X#endif
Xint fputc(int, FILE *);
Xint putw(int, FILE *);
X
X/* puts(3S), fputs(3S) -- put a string on a stream */
Xvoid puts(const char *);
Xvoid fputs(const char *, FILE *);
X
X/* qsort(3) -- quicker sort */
Xvoid qsort(char *, int, int, int (*)());
X
X/* rand(3C) -- random number generator */
Xint srand(int);
Xint rand(void);
X
X/* random(3), srandom(3), initstate(3), setstate(3) -- better random number generator; routines for changing generators */
Xlong random(void);
Xvoid srandom(int);
Xchar *initstate(unsigned, char *, int);
Xchar *setstate(char *);
X
X/* rcmd(3), rresvport(3), ruserok(3) -- routines for returning a stream to a remote command */
Xint rcmd(char **, int, char *, char *, char *, int *);
Xint rresvport(int *);
Xint ruserok(char *, int, char *, char *);
X
X/* re_comp(3), re_exec(3) -- regular expression handler */
Xchar *re_comp(const char *);
Xint re_exec(const char *);
X
X/* res_mkquery(3), res_send(3), res_init(3), dn_comp(3), dn_expand(3) -- resolver routines */
Xint res_mkquery(int, char *, int, int, char *, int, struct rrec *, char *, int);
Xint res_send(char *, int, char *, int);
Xvoid res_init(void);
Xint dn_comp(char *, char *, int, char **, char **);
Xint dn_expand(char *, char *, char *, char *, int);
X
X/* rexec(3) -- return stream to a remote command */
Xint rexec(char **, int, char *, char *, char *, int *);
X
X/* scandir(3), alphasort(3) -- scan a directory */
Xint scandir(const char *, struct direct ***, int (*)(), int (*)());
Xint alphasort(struct direct **, struct direct **);
X
X/* scanf(3S), fscanf(3S), sscanf(3S) -- formatted input conversion */
Xint scanf(const char *, ...);
Xint fscanf(FILE *, const char *, ...);
Xint sscanf(char *, const char *, ...);
X
X/* setbuf(3S), setbuffer(3S), setlinebuf(3S) -- assign buffering to a stream */
Xvoid setbuf(FILE *, char *);
Xvoid setbuffer(FILE *, char *, int);
Xvoid setlinebuf(FILE *);
X
X/* setjmp(3), longjmp(3) -- non-local goto */
Xint setjmp(jmp_buf);
Xvoid longjmp(jmp_buf, int);
Xint _setjmp(jmp_buf);
Xvoid _longjmp(jmp_buf, int);
X
X/* setuid(3), seteuid(3), setruid(3), setgid(3), setegid(3), setrgid(3) -- set user and group ID */
Xint setuid(uid_t);
Xint seteuid(uid_t);
Xint setruid(uid_t);
Xint setgid(gid_t);
Xint setegid(gid_t);
Xint setrgid(gid_t);
X
X/* siginterrupt(3) -- allow signals to interrupt system calls */
Xint siginterrupt(int, int);
X
X/* signal(3C) -- simplified software signal facilities */
Xint (*signal(int, int (*)()))();
X
X/* sin(3M), cos(3M), tan(3M), asin(3M), acos(3M), atan(3M), atan2(3M) -- trigonometric ffunctions and their inverses */
Xdouble sin(double);
Xdouble cos(double);
Xdouble tan(double);
Xdouble asin(double);
Xdouble acos(double);
Xdouble atan(double);
Xdouble atan2(double, double);
X
X/* sinh(3M), cosh(3M), tanh(3M) -- hyperbolic functions */
Xdouble sinh(double);
Xdouble cosh(double);
Xdouble tanh(double);
X
X/* sleep(3) -- suspend execution for interval */
Xvoid sleep(unsigned);
X
X/* cbrt(3M), sqrt(3M) -- cube root, square root */
Xdouble cbrt(double);
Xdouble sqrt(double);
X
X/* strcat(3), strncat(3), strcmp(3), strncmp(3), strcpy(3), strncpy(3), strlen(3), index(3), rindex(3) -- string operations */
Xchar *strcat(char *, const char *);
Xchar *strncat(char *, const char *, int);
Xint strcmp(const char *, const char *);
Xint strncmp(const char *, const char *, int);
Xchar *strcpy(char *, const char *);
Xchar *strncpy(char *, const char *, int);
Xint strlen(const char *);
Xchar *index(const char *, char);
Xchar *rindex(const char *, char);
X#ifdef sun
Xchar *strchr(char *, int);
Xchar *strrchr(char *, int);
Xchar *strpbrk(const char *, const char *);
Xint strspn(const char *, const char *);
Xint strcspn(const char *, const char *);
Xchar *strtok(char *, const char *);
X#endif
X
X/* stty(3C), gtty(3C) -- set and get terminal state (defunct) */
Xint stty(int, struct sgttyb *);
Xint gtty(int, struct sgttyb *);
X
X/* swab(3) -- swap bytes */
Xvoid swab(const char *, char *, int);
X
X/* syslog(3), openlog(3), closelog(3), setlogmask(3) -- control system log */
Xvoid syslog(int, char *, ...);
Xvoid openlog(char *, int, int);
Xvoid closelog(void);
Xvoid setlogmask(int);
X
X/* system(3) -- issue a shell command */
Xint system(const char *);
X
X/* termcap(3X) -- TBD */
X
X/* time(3C), ftime(3C) -- get date and time */
Xlong time(long *);
Xvoid ftime(struct timeb *);
X
X/* times(3C) -- get process times */
Xvoid times(struct tms *);
X
X/* ttyname(3), isatty(3), ttyslot(3) -- find name of a terminal */
Xchar *ttyname(int);
Xint isatty(int);
Xint ttyslot(void);
X
X/* ualarm(3) -- schedule signal after specified time */
Xunsigned ualarm(unsigned, unsigned);
X
X/* ungetc(3S) -- push a character back into input stream */
Xint ungetc(int, FILE *);
X
X/* usleep(3) -- suspend execution for interval */
Xvoid usleep(unsigned);
X
X/* utime(3C) -- set file times */
Xvoid utime(char *, time_t []);
X
X/* valloc(3C) -- aligned memory allocator */
Xchar *valloc(unsigned);
X
X/* vlimit(3C) -- control maximum system resource consumption */
Xint vlimit(int, int);
X
X/* vprintf(3S), vfprintf(3S), vsprintf(3S) -- print formatted output of a varargs argument list */
Xint vprintf(const char *, va_list);
Xint vfprintf(FILE *, const char *, va_list);
Xchar *vsprintf(char *, const char *, va_list);
X
X/* vtimes(3C) -- get information about resource utilization */
Xvoid vtimes(struct vtimes *, struct vtimes *);
X
X/* The End. */
X
X#else /* __STDC__ */
X
X/* accept(2) -- accept a connection on a socket */
Xint accept();
X
X/* access(2) -- determine accessibility of file */
Xint access();
X
X/* acct(2) -- turn accounting on or off */
Xint acct();
X
X/* adjtime(2) -- correct the time to allow synchronization of the system clock */
Xint adjtime();
X
X/* bind(2) -- bind a name to a socket */
Xint bind();
X
X/* brk(2), sbrk(2) -- change data segment size */
Xchar *brk();
Xchar *sbrk();
X
X/* chdir(2) -- change working directory */
Xint chdir();
X
X/* chmod(2) -- change mode of file */
Xint chmod();
Xint fchmod();
X
X/* chown(2) -- change owner and group of a file */
Xint chown();
Xint fchown();
X
X/* chroot(2) -- change root directory */
Xint chroot();
X
X/* close(2) -- delete a descriptor */
Xint close();
X
X/* connect(2) -- initiate a connection on a socket */
Xint connect();
X
X/* creat(2) -- create a new file */
Xint creat();
X
X/* dup(2), dup2(2) -- duplicate a descriptor */
Xint dup();
Xint dup2();
X
X/* execve(2) -- execute a file */
Xint execve();
X
X/* _exit(2) -- terminate a process */
Xvoid _exit();
X
X/* fcntl(2) -- file control */
Xint fcntl();
X
X/* flock(2) -- apply or remove an advisory lock on an open file */
Xint flock();
X
X/* fork(2) -- create a new process */
Xint fork();
X
X/* fsync(2) -- synchronize a file's in-core state with that on disk */
Xint fsync();
X
X/* getdtablesize(2) -- get descriptor table size */
Xint getdtablesize();
X
X/* getgid(2), getegid(2) -- get group identity */
X#ifdef sun
Xtypedef int gid_t;
X#endif
Xgid_t getgid();
Xgid_t getegid();
X
X/* getgroups(2) -- get group access list */
Xint getgroups();
X
X/* gethostid(2), sethostid(2) -- get/set unique identifier of current host */
Xlong gethostid();
Xint sethostid();
X
X/* gethostname(2), sethostname(2) -- get/set name of current host */
Xint gethostname();
Xint sethostname();
X
X/* getitimer(2), setitimer(2) -- get/set value of interval timer */
Xint getitimer();
Xint setitimer();
X
X/* getpagesize(2) -- get system page size */
Xint getpagesize();
X
X/* getpeername(2) -- get name of connected peer */
Xint getpeername();
X
X/* getpgrp(2) -- get process group */
Xint getpgrp();
X
X/* getpid(2), getppid(2) -- get proces identification */
Xint getpid();
Xint getppid();
X
X/* getpriority(2), setpriority(2) -- get/set program scheduling priority */
Xint getpriority();
Xint setpriority();
X
X/* getrlimit(2), setrlimit(2) -- control maximum system resource consumption */
Xint getrlimit();
Xint setrlimit();
X
X/* getrusage(2) -- get information about resource utilization */
Xint getrusage();
X
X/* getsockname(2) -- get socket name */
Xint getsockname();
X
X/* getsockopt(2), setsockopt(2) -- get and set options on sockets */
Xint getsockopt();
Xint setsockopt();
X
X/* gettimeofday(2), settimeofday(2) -- get/set date and time */
Xint gettimeofday();
Xint settimeofday();
X
X/* getuid(2), geteuid(2) -- get user identity */
X#ifdef sun
Xtypedef int uid_t;
X#endif
Xuid_t getuid();
Xuid_t geteuid();
X
X/* ioctl(2) -- control device */
Xint ioctl();
X
X/* kill(2) -- send signal to process */
Xint kill();
X
X/* killpg(2) -- send signal to process group */
Xint killpg();
X
X/* link(2) -- make a hard link to a file */
Xint link();
X
X/* listen(2) -- listen for connections on a socket */
Xint listen();
X
X/* lseek(2) -- move read/write pointer */
Xoff_t lseek();
X
X/* mkdir(2) -- make a directory file */
Xint mkdir();
X
X/* mknod(2) -- make a special file */
Xint mknod();
X
X/* mount(2), umount(2) -- mount or remove file system */
Xint mount();
Xint umount();
X
X/* open(2) -- open a file for reading or writing, or create a new file */
Xint open();
X
X/* pipe(2) -- create an interprocess communication channel */
Xint pipe();
X
X/* profil(2) -- execution time profile */
Xint profil();
X
X/* ptrace(2) -- process trace */
Xint ptrace();
X
X/* quota(2) -- manipulate disk quotas */
Xint quota();
X
X/* read(2), readv(2) -- read input */
Xint read();
Xint readv();
X
X/* readlink(2) -- read value of a symbolic link */
Xint readlink();
X
X/* reboot(2) -- reboot system or halt processor */
Xint reboot();
X
X/* recv(2), recvfrom(2), recvmsg(2) -- receive a message from a socket */
Xint recv();
Xint recvfrom();
Xint recvmsg();
X
X/* rename(2) -- change the name of a file */
Xint rename();
X
X/* rmdir(2) -- remove a directory file */
Xint rmdir();
X
X/* select(2) -- synchronous I/O multiplexing */
Xint select();
X
X/* send(2), sendto(2), sendmsg(2) -- send a message from a socket */
Xint send();
Xint sendto();
Xint sendmsg();
X
X/* setgroups(2) -- set group access list */
Xint setgroups();
X
X/* setpgrp(2) -- set process group */
Xint setpgrp();
X
X/* setquota(2) -- enable/disable quotas on a file system */
Xint setquota();
X
X/* setregid(2) -- set real and effective group ID */
Xint setregid();
X
X/* setreuid(2) -- set real and effective user ID's */
Xint setreuid();
X
X/* shutdown(2) -- shut down part of a full-duplex connection */
Xint shutdown();
X
X/* sigblock(2) -- block signals */
Xint sigblock();
X
X/* sigpause(2) -- atomically release blocked signals and wait for interrupt */
Xint sigpause();
X
X/* sigreturn(2) -- return from a signal (4.3BSD only) */
Xint sigreturn();
X
X/* sigsetmask(2) -- set current signal mask */
Xint sigsetmask();
X
X/* sigstack(2) -- set and/or get signal stack context */
Xint sigstack();
X
X/* sigvec(2) -- software signal facilities */
Xint sigvec();
X
X/* socket(2) -- create an endpoint ffor communication */
Xint socket();
X
X/* socketpair(2) -- create a pair of connected sockets */
Xint socketpair();
X
X/* stat(2), lstat(2), fstat(2) -- get file status */
Xint stat();
Xint lstat();
Xint fstat();
X
X/* swapon(2) -- add a swap device for interleaved paging/swapping */
Xint swapon();
X
X/* symlink(2) -- make a symbolic link to a file */
Xint symlink();
X
X/* sync(2) -- update super-block */
Xint sync();
X
X/* syscall(2) -- indirect system call */
Xint syscall();
X
X/* truncate(2) -- truncate a file to a specified length */
Xint truncate();
Xint ftruncate();
X
X/* umask(2) -- set file creation mode mask */
Xint umask();
X
X/* unlink(2) -- remove directory entry */
Xint unlink();
X
X/* utimes(2) -- set file times */
Xint utimes();
X
X/* vfork(2) -- spawn new process in a virtual memory efficient way */
Xint vfork();
X
X/* vhangup(2) -- virtually "hangup" the current control terminal */
Xint vhangup();
X
X/* wait(2), wait3(2) -- wait for process to terminate */
Xint wait();
Xint wait3();
X
X/* write(2), writev(2) -- write output */
Xint write();
Xint writev();
X
X/* abort(3) -- generate a fault */
Xint abort();
X
X/* abs(3) -- integer absolute value */
Xint abs();
X
X/* alarm(3C) -- schedule signal after specified time */
Xint alarm();
X
X/* asinh(3M), acosh(3M), atanh(3M) -- inverse hyperbolic functions */
Xdouble asinh();
Xdouble acosh();
Xdouble atanh();
X
X/* assert(3) -- program verification */
X#ifndef assert
Xvoid assert();
X#endif
X
X/* atof(3), atoi(3), atol(3) -- convert ASCII to numbers */
Xdouble atof();
Xint atoi();
Xlong atol();
X
X/* bcopy(3), bcmp(3), bzero(3), ffs(3) -- bit and byte string operations */
Xvoid bcopy();
Xint bcmp();
Xvoid bzero();
Xint ffs();
X
X/* htonl(3N), htons(3N), ntonl(3N), ntohs(3N) -- convert values between host and network byte order */
X#ifndef htonl
Xu_long htonl();
Xu_short htons();
Xu_long ntohl();
Xu_short ntohs();
X#endif
X
X/* crypt(3), setkey(3), encrypt(3) -- DES encryption */
Xchar *crypt();
Xvoid setkey();
Xvoid encrypt();
X
X/* ctime(3), localtime(3), gmtime(3), asctime(3), timezone(3) -- convert date and time to ASCII */
Xchar *ctime();
Xstruct tm *localtime();
Xstruct tm *gmtime();
Xchar *asctime();
Xchar *timezone();
X
X/* isalpha(3), isupper(3), islower(3), isdigit(3), isxdigit(3), isalnum(3), isspace(3), ispunct(3), isprint(3), isgraph(3), iscntrl(3), isascii(3), toupper(3), tolower(3), toascii(3) -- character classification macros */
X#ifndef isalpha
Xint isalpha();
Xint isupper();
Xint islower();
Xint isdigit();
Xint isxdigit();
Xint isalnum();
Xint isspace();
Xint ispunct();
Xint isprint();
Xint isgraph();
Xint iscntrl();
Xint isascii();
Xint toupper();
Xint tolower();
Xint toascii();
X#endif
X
X/* curses(3X) -- TBD */
X
X/* dbm(3X) -- TBD */
X
X/* opendir(3), readdir(3), telldir(3), seekdir(3), rewinddir(3), closedir(3) -- directory operations */
XDIR *opendir();
Xstruct direct *readdir();
Xlong telldir();
Xvoid seekdir();
X#ifndef rewinddir
Xvoid rewinddir();
X#endif
Xvoid closedir();
X
X/* ecvf(3), fcvt(3), gcvt(3) -- output conversion */
Xchar *ecvt();
Xchar *fcvt();
Xchar *gcvf();
X
X/* end(3), etext(3), edata(3) -- last locations in program */
Xextern int end;
Xextern int etext;
Xextern int edata;
X
X/* erf(3M), erfc(3M) -- error functions */
Xdouble erf();
Xdouble erfc();
X
X/* execl(3), execv(3), execle(3), execlp(3), execvp(3), exect(3), environ(3) -- execute a file */
Xint execl();
Xint execv();
Xint execle();
Xint execlp();
Xint execvp();
Xint exect();
Xextern char **environ;
X
X/* exit(3) -- terminate a process after flushing any pending output */
Xvoid exit();
X
X/* exp(3M), expm1(3M), log(3M), log10(3M), log1p(3M), pow(3M) -- exponential, logarithm, power */
Xdouble exp();
Xdouble expm1();
Xdouble log();
Xdouble log10();
Xdouble log1p();
Xdouble pow();
X
X/* fclose(3S), fflush(3S) -- close or flush a stream */
Xint fclose();
Xint fflush();
X
X/* ferror(3S), feof(3S), clearerr(3S), fileno(3S) -- stream status inquiries */
X#ifndef fileno
Xint feof();
Xint ferror();
Xvoid clearerr();
Xint fileno();
X#endif
X
X/* fabs(3M), floor(3M), ceil(3M), rint(3M) -- absolute value, floor, ceiling, and round-to-nearest functions */
Xdouble fabs();
Xdouble floor();
Xdouble ceil();
Xdouble rint();
X
X/* _filbuf(3U) -- visible underpinnings of stdio */
Xint _filbuf();
X
X/* fopen(3S), freopen(3S), fdopen(3S) -- open a stream */
XFILE *fopen();
XFILE *freopen();
XFILE *fdopen();
X
X/* fread(3S), fwrite(3S) -- buffered binary input/output */
Xint fread();
Xint fwrite();
X
X/* frexp(3), ldexp(3), modf(3) -- split into mantissa and exponent */
Xdouble frexp();
Xdouble ldexp();
Xdouble modf();
X
X/* fseek(3S), ftell(3S), rewind(3S) -- reposition a stream */
Xint fseek();
Xlong ftell();
Xint rewind();
X
X/* getc(3S), getchar(3S), fgetc(3S), getw(3S) -- get character or word from stream */
X#ifndef getc
Xint getc();
Xint getchar();
X#endif
Xint fgetc();
Xint getw();
X
X/* getdiskbyname(3) -- get disk description by its name */
Xstruct disktab *getdiskbyname();
X
X/* getenv(3) -- value for environment name */
Xchar *getenv();
X
X/* getfsent(3), getfsspec(3), getfsfile(3), getfstype(3), setfsent(3), endfsent(3) -- get file system descriptor file entry */
Xstruct fstab *getfsent();
Xstruct fstab *getfsspec();
Xstruct fstab *getfsfile();
Xstruct fstab *getfstype();
Xint setfsent();
Xint endfsent();
X
X/* getgrent(3), getgrgid(3), getgrnam(3), setgrent(3), endgrent(3) -- get group file entry */
Xstruct group *getgrent();
Xstruct group *getgrgid();
Xstruct group *getgrname();
Xvoid setgrent();
Xvoid endgrent();
X
X/* gethostbyname(3N), gethostbyaddr(3N), gethostent(3N), sethostent(3N), endhostent(3N) -- get network host entry */
Xextern int h_errno;
Xstruct hostent *gethostbyname();
Xstruct hostent *gethostbyaddr();
Xstruct hostent *gethostent();
Xint sethostent();
Xvoid endhostent();
X
X/* getlogin(3) -- get login name */
Xchar *getlogin();
X
X/* getnetent(3N), getnetbyaddr(3N), getnetbyname(3N), setnetent(3N), endnetent(3N) -- get network entry */
Xstruct netent *getnetent();
Xstruct netent *getnetbyaddr();
Xstruct netent *getnetbyname();
Xint setnetent();
Xvoid endnetent();
X
X/* getopt(3) -- get option letter from argv */
Xint getopt();
Xextern char *optarg;
Xextern int optind;
X
X/* getpass(3) -- read a password */
Xchar *getpass();
X
X/* getprotoent(3N), getprotobynumber(3N), getprotobyname(3N), setprotoent(3N), endprotoent(3N) -- get protocol entry */
Xstruct protoent *getprotoent();
Xstruct protoent *getprotobynumber();
Xstruct protoent *getprotobyname();
Xint setprotoent();
Xvoid endprotoent();
X
X/* getpw(3C) -- get name from uid */
Xint getpw();
X
X/* getpwent(3), getpwuid(3), getpwnam(3), setpwent(3), endpwent(3), setpwfile(3) -- get password file entry */
Xstruct passwd *getpwuid();
Xstruct passwd *getpwnam();
Xstruct passwd *getpwent();
Xint setpwent();
Xvoid endpwent();
Xint setpwfile();
X
X/* gets(3S), fgets(3S) -- get a string from a stream */
Xchar *gets();
Xchar *fgets();
X
X/* getservent(3N), getservbyport(3N), getservbyname(3N), setservent(3N), endservent(3N) -- get service entry */
Xstruct servent *getservent();
Xstruct servent *getservbyport();
Xstruct servent *getservbyname();
Xint setservent();
Xvoid endservent();
X
X#ifndef sun
X/* getttyent(3), getttynam(3), setttyent(3), endttyent(3) -- get ttys file entry */
Xstruct ttyent *getttyent();
Xstruct ttyent *getttynam();
Xint setttyent();
Xvoid endttyent();
X#endif
X
X/* getusershell(3), setusershell(3), endusershell(3) -- get legal user shells */
Xchar *getusershell();
Xint setusershell();
Xvoid endusershell();
X
X/* getwd(3) -- get current working directory pathname */
Xchar *getwd();
X
X/* hypot(3M), cabs(3M) -- Euclidean distance, complex absolute value */
Xdouble hypot();
Xdouble cabs();
X
X/* copysign(3M), drem(3M), finite(3M), logb(3M), scalb(3M) -- copysign, remainder, exponent manipulations */
Xdouble copysign();
Xdouble drem();
Xint finite();
Xdouble logb();
Xdouble scalb();
X
X/* inet_addr(3N), inet_network(3N), inet_ntoa(3N), inet_makeaddr(3N), inet_lnaof(3N), inet_netof(3N) -- Internet address manipulation routines */
Xunsigned long inet_addr();
Xunsigned long inet_network();
Xchar *inet_ntoa();
Xstruct in_addr inet_makeaddr();
Xint inet_lnaof();
Xint inet_netof();
X
X/* infnan(3M) -- signals invalid floating-point operations on a VAX (temporary) */
X#ifdef vax
Xdouble infnan();
X#endif
X
X/* initgroups(3) -- initialize group access list */
Xint initgroups();
X
X/* insque(3), remque(3) -- insert/remove element from a queue */
Xvoid insque();
Xvoid remque();
X
X/* j0(3M), j1(3M), jn(3M), y0(3M), y1(3M), yn(3M) -- bessel functions */
Xdouble j0();
Xdouble j1();
Xdouble jn();
Xdouble y0();
Xdouble y1();
Xdouble yn();
X
X/* lgamma(3M) -- log gamma function */
Xextern int signgam;
Xdouble lgamma();
X
X/* lib2648(3X) -- TBD (roight) */
X
X/* malloc(3), free(3), realloc(3), calloc(3), alloc(3) -- memory allocator */
Xchar *malloc();
Xvoid free();
Xchar *realloc();
Xchar *calloc();
Xchar *alloca();
X
X/* mktemp(3), mkstemp(3) -- make a unique file name */
Xchar *mktemp();
Xint mkstemp();
X
X/* monitor(3), monstartup(3), moncontrol(3) -- prepare execution profile */
Xvoid monitor();
Xvoid monstartup();
Xvoid moncontrol();
X
X/* mp(3X) -- TBD */
X
X/* ndbm(3) -- TBD */
X
X/* nice(3C) -- set program priority */
Xvoid nice();
X
X/* nlist(3) -- get entries from name list */
Xint nlist();
X
X#ifndef sun
X/* ns_addr(3N), ns_ntoa(3N) -- Xerox NS(tm) address conversion routines */
Xstruct ns_addr ns_addr();
Xchar *ns_toa();
X#endif
X
X/* pause(2C) -- stop until signal */
Xint pause();
X
X/* perror(3), sys_errlist(3), sys_nerr(3) -- system error messages */
Xvoid perror();
Xextern int errno, sys_nerr;
Xextern char *sys_errlist[];
X
X#define BENT_ERRMSG \
X	((errno == 0) ? "No error!?" : \
X			((errno < sys_nerr) ? sys_errlist[errno] : \
X					      "Unknown error" \
X			) \
X	)
X
X/* plot(3X) -- TBD */
X
X/* popen(3), pclose(3) -- initiate I/O to/from a process */
XFILE *popen();
Xint pclose();
X
X/* printf(3S), fprintf(3S), sprintf(3S) -- formatted output conversions */
Xint printf();
Xint fprintf();
Xint sprintf();
Xint _doprnt();
X
X/* psignal(3), sys_siglist(3) -- system signal messages */
Xvoid psignal();
Xextern char *sys_siglist[];
X
X/* putc(3S), putchar(3S), fputc(3S), putw(3S) -- put character on word on a stream */
X#ifndef putc
Xint putc();
X#endif
X#ifndef putchar
Xint putchar();
X#endif
Xint fputc();
Xint putw();
X
X/* puts(3S), fputs(3S) -- put a string on a stream */
Xvoid puts();
Xvoid fputs();
X
X/* qsort(3) -- quicker sort */
Xvoid qsort();
X
X/* rand(3C) -- random number generator */
Xint srand();
Xint rand();
X
X/* random(3), srandom(3), initstate(3), setstate(3) -- better random number generator; routines for changing generators */
Xlong random();
Xvoid srandom();
Xchar *initstate();
Xchar *setstate();
X
X/* rcmd(3), rresvport(3), ruserok(3) -- routines for returning a stream to a remote command */
Xint rcmd();
Xint rresvport();
Xint ruserok();
X
X/* re_comp(3), re_exec(3) -- regular expression handler */
Xchar *re_comp();
Xint re_exec();
X
X/* res_mkquery(3), res_send(3), res_init(3), dn_comp(3), dn_expand(3) -- resolver routines */
Xint res_mkquery();
Xint res_send();
Xvoid res_init();
Xint dn_comp();
Xint dn_expand();
X
X/* rexec(3) -- return stream to a remote command */
Xint rexec();
X
X/* scandir(3), alphasort(3) -- scan a directory */
Xint scandir();
Xint alphasort();
X
X/* scanf(3S), fscanf(3S), sscanf(3S) -- formatted input conversion */
Xint scanf();
Xint fscanf();
Xint sscanf();
X
X/* setbuf(3S), setbuffer(3S), setlinebuf(3S) -- assign buffering to a stream */
Xvoid setbuf();
Xvoid setbuffer();
Xvoid setlinebuf();
X
X/* setjmp(3), longjmp(3) -- non-local goto */
Xint setjmp();
Xvoid longjmp();
Xint _setjmp();
Xvoid _longjmp();
X
X/* setuid(3), seteuid(3), setruid(3), setgid(3), setegid(3), setrgid(3) -- set user and group ID */
Xint setuid();
Xint seteuid();
Xint setruid();
Xint setgid();
Xint setegid();
Xint setrgid();
X
X/* siginterrupt(3) -- allow signals to interrupt system calls */
Xint siginterrupt();
X
X/* signal(3C) -- simplified software signal facilities */
Xint (*signal())();
X
X/* sin(3M), cos(3M), tan(3M), asin(3M), acos(3M), atan(3M), atan2(3M) -- trigonometric ffunctions and their inverses */
Xdouble sin();
Xdouble cos();
Xdouble tan();
Xdouble asin();
Xdouble acos();
Xdouble atan();
Xdouble atan2();
X
X/* sinh(3M), cosh(3M), tanh(3M) -- hyperbolic functions */
Xdouble sinh();
Xdouble cosh();
Xdouble tanh();
X
X/* sleep(3) -- suspend execution for interval */
Xvoid sleep();
X
X/* cbrt(3M), sqrt(3M) -- cube root, square root */
Xdouble cbrt();
Xdouble sqrt();
X
X/* strcat(3), strncat(3), strcmp(3), strncmp(3), strcpy(3), strncpy(3), strlen(3), index(3), rindex(3) -- string operations */
Xchar *strcat();
Xchar *strncat();
Xint strcmp();
Xint strncmp();
Xchar *strcpy();
Xchar *strncpy();
Xint strlen();
Xchar *index();
Xchar *rindex();
X#ifdef sun
Xchar *strchr();
Xchar *strrchr();
Xchar *strpbrk();
Xint strspn();
Xint strcspn();
Xchar *strtok();
X#endif
X
X/* stty(3C), gtty(3C) -- set and get terminal state (defunct) */
Xint stty();
Xint gtty();
X
X/* swab(3) -- swap bytes */
Xvoid swab();
X
X/* syslog(3), openlog(3), closelog(3), setlogmask(3) -- control system log */
Xvoid syslog();
Xvoid openlog();
Xvoid closelog();
Xvoid setlogmask();
X
X/* system(3) -- issue a shell command */
Xint system();
X
X/* termcap(3X) -- TBD */
X
X/* time(3C), ftime(3C) -- get date and time */
Xlong time();
Xvoid ftime();
X
X/* times(3C) -- get process times */
Xvoid times();
X
X/* ttyname(3), isatty(3), ttyslot(3) -- find name of a terminal */
Xchar *ttyname();
Xint isatty();
Xint ttyslot();
X
X/* ualarm(3) -- schedule signal after specified time */
Xunsigned ualarm();
X
X/* ungetc(3S) -- push a character back into input stream */
Xint ungetc();
X
X/* usleep(3) -- suspend execution for interval */
Xvoid usleep();
X
X/* utime(3C) -- set file times */
Xvoid utime();
X
X/* valloc(3C) -- aligned memory allocator */
Xchar *valloc();
X
X/* vlimit(3C) -- control maximum system resource consumption */
Xint vlimit();
X
X/* vprintf(3S), vfprintf(3S), vsprintf(3S) -- print formatted output of a varargs argument list */
Xint vprintf();
Xint vfprintf();
Xchar *vsprintf();
X
X/* vtimes(3C) -- get information about resource utilization */
Xvoid vtimes();
X
X/* The End. */
X
X#endif /* __STDC__ */
Shar_Eof
exit 0

-Bennett
bet@orion.mc.duke.edu

bet@dukeac.UUCP (Bennett Todd) (02/08/89)

Drat. So close.... Two glitches so far in posting. First, my (admittedly
primitive) shar doesn't preserve mode bits, so you have to manually

	chmod +x mkprototypes

Second, despite saying that I would include it, I forgot to include a bent.h
in case you can't rebuild it. Here's one:

: This is a sharchive -- extract the files by running through sh.
echo x - bent.h
sed 's/^X//' <<\Shar_Eof >bent.h
X#include <bent-stdio.h>
Xextern char *progname;
Xextern char syntax_args[];
X
Xtypedef struct {
X	long magic;	/* MAXIMUM ALIGNMENT TYPE! */
X	unsigned len;
X} _BENT_MALLOC_HEADER;
X
X#define _BENT_MALLOC_MAGIC 0x13713713
X
Xlong stand_rand_seed;
X
Xextern const char *_bentio_filename_table[];
X
X#define _FD2FN(fd) (_bentio_filename_table[(fd)] ? _bentio_filename_table[(fd)] : "(unknown file)")
X#ifdef __STDC__
Xvoid eclose(int);
Xvoid efclose(FILE *);
XFILE *efdopen(int, const char *);
Xvoid efflush(FILE *);
Xvoid efgets(char *, int, FILE *);
XFILE *efopen(const char *, const char *);
Xvoid efprintf(FILE *, const char *, ...);
Xvoid efread(char *, int, int, FILE *);
Xvoid efree(char *);
Xvoid efseek(FILE *, long, int);
Xvoid efwrite(const char *, int, int, FILE *);
Xchar *emalloc(unsigned);
Xint emkstemp(char *);
Xint eopen(const char *, int, int);
Xvoid eprintf(const char *, ...);
Xvoid eputchar(int);
Xchar *erealloc(char *, unsigned);
Xvoid error(const char *, ...);
Xvoid etruncate(const char *, unsigned long);
Xvoid eunlink(const char *);
Xvoid ewrite(int, const char *, int);
Xchar *getline(char *, FILE *);
Xint max(int, int);
Xint min(int, int);
Xvoid putline(char *, FILE *);
Xchar *readfile(FILE *, int *);
Xdouble stand_rand(void);
Xchar *strdup(const char *);
Xvoid syntax(void);
X#else /* __STDC__ */
Xvoid eclose();
Xvoid efclose();
XFILE *efdopen();
Xvoid efflush();
Xvoid efgets();
XFILE *efopen();
Xvoid efprintf();
Xvoid efread();
Xvoid efree();
Xvoid efseek();
Xvoid efwrite();
Xchar *emalloc();
Xint emkstemp();
Xint eopen();
Xvoid eprintf();
Xvoid eputchar();
Xchar *erealloc();
Xvoid error();
Xvoid etruncate();
Xvoid eunlink();
Xvoid ewrite();
Xchar *getline();
Xint max();
Xint min();
Xvoid putline();
Xchar *readfile();
Xdouble stand_rand();
Xchar *strdup();
Xvoid syntax();
X#endif /* __STDC__ */
Shar_Eof
exit 0

-Bennett
bet@orion.mc.duke.edu