--- /dev/null
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 4.19 (Berkeley) 3/9/86
+#
+#
+# The system has two monitoring schemes, utilizing either ``prof''
+# or ``gprof''. DFLMON determines the default profiler; mon.o
+# specifies that ``prof'' is the default, gmon.o specifies that
+# ``gprof'' is the default.
+#
+# Machine dependent routines are located in a subtree which parallels
+# the top directories. This subtree is identified by the machine name.
+#
+# Compatibility routines are kept in directories with a prefixing
+# ``compat'' (so they all sort together).
+#
+# The C run-time startup code is always machine dependent and expected
+# to be located in ${MACHINE}/csu
+#
+# All files contain sccsid strings, but these are not compiled into
+# library objects by default, as a space-saving measure. To produce
+# a library that contains these strings in every object except
+# system call stubs, add -DLIBC_SCCS to DEFS below; to put these
+# strings into system call stubs, use -DSYSLIBC_SCCS.
+#
+# There are two possible methods of doing host name look up. They are
+# to use the name server or /etc/hosts. HOSTLOOKUP defines which method
+# is to be compiled into libc :
+#
+# defining HOSTLOOKUP to be "named", compiles the
+# host lookup routines that use the BIND name server.
+#
+# defining HOSTLOOKUP to be "hosttable", compiles
+# the host lookup routines that use /etc/hosts.
+#
+#HOSTLOOKUP= hosttable
+HOSTLOOKUP= named
+#
+DESTDIR=
+INSTALL=install -m 644
+DFLMON= mon.o
+MACHINE=vax
+DEFS=
+COMPAT= compat-4.1 compat-sys5
+ALL= gen inet net ns stdio ${MACHINE} ${COMPAT}
+TAGSFILE=tags
+
+libc.a libc_p.a: ${MACHINE}/csu ${ALL} net/${HOSTLOOKUP}
+ rm -rf t1 tmp
+ -mkdir tmp
+ for i in ${ALL}; do (cd tmp; ar x ../$$i/$${i}lib); done
+ cd tmp; ar x ../net/${HOSTLOOKUP}/hostlib
+ ls tmp/*.o | sort -t/ +1 > t1
+ ar cr libc.a `lorder \`cat t1\` | tsort` ${MACHINE}/csu/${DFLMON}
+ ar ma findiop.o libc.a exit.o
+ ar ma exit.o libc.a fakcu.o
+ rm -f t1 tmp/*
+ for i in ${ALL}; do (cd tmp; ar x ../$$i/$${i}lib_p); done
+ cd tmp; ar x ../net/${HOSTLOOKUP}/hostlib_p
+ ls tmp/*.o | sort -t/ +1 > t1
+ ar cr libc_p.a `lorder \`cat t1\` | tsort` ${MACHINE}/csu/${DFLMON}
+ ar ma findiop.o libc_p.a exit.o
+ ar ma exit.o libc_p.a fakcu.o
+ rm -rf t1 tmp
+
+${MACHINE}/csu ${ALL} net/${HOSTLOOKUP}: FRC
+ cd $@; make ${MFLAGS} DEFS=${DEFS}
+
+FRC:
+
+install:
+ ${INSTALL} libc.a ${DESTDIR}/lib/libc.a
+ ranlib ${DESTDIR}/lib/libc.a
+ ${INSTALL} libc_p.a ${DESTDIR}/usr/lib/libc_p.a
+ ranlib ${DESTDIR}/usr/lib/libc_p.a
+ cd ${MACHINE}/csu; make DESTDIR=${DESTDIR} install
+
+tags:
+ for i in ${ALL}; do \
+ (cd $$i; make ${MFLAGS} TAGSFILE=../${TAGSFILE} tags); \
+ done
+ cd net/${HOSTLOOKUP}; \
+ make ${MFLAGS} TAGSFILE=../../${TAGSFILE} tags
+
+clean:
+ for i in ${MACHINE}/csu ${ALL} net/hosttable net/named; \
+ do (cd $$i; make ${MFLAGS} clean); done
+ rm -f t1 tmp/*.o
+ -rmdir tmp
+
+depend:
+ for i in ${MACHINE}/csu ${ALL} net/hosttable net/named; \
+ do (cd $$i; make ${MFLAGS} DEFS=${DEFS} depend); done
--- /dev/null
+int strncmp(a, b, n) char *a, *b; {
+ abort();
+}
--- /dev/null
+#ifdef poo
+#endif
--- /dev/null
+/* compat-4.1/vtimes.c */
+int vtimes __P((register struct vtimes *par, register struct vtimes *chi));
+/* compat-4.1/gtty.c */
+int gtty __P((int fd, struct sgttyb *ap));
+/* compat-4.1/ftime.c */
+int ftime __P((register struct timeb *tp));
+/* compat-4.1/getpw.c */
+int getpw __P((int uid, char buf[]));
+/* compat-4.1/tell.c */
+long tell __P((int f));
+/* compat-4.1/rand.c */
+int srand __P((unsigned x));
+int rand __P((void));
+/* compat-4.1/reset.c */
+/* compat-4.1/times.c */
+int times __P((register struct tms *tmsp));
+/* compat-4.1/pause.c */
+int pause __P((void));
+/* compat-4.1/utime.c */
+int utime __P((char *name, int otv[]));
+/* compat-4.1/vlimit.c */
+int vlimit __P((int limit, int value));
+/* compat-4.1/nice.c */
+int nice __P((int incr));
+/* compat-4.1/stty.c */
+int stty __P((int fd, struct sgttyb *ap));
--- /dev/null
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 5.4 (Berkeley) 9/5/85
+#
+CFLAGS= -O ${DEFS}
+STDSRCS=ftime.c gtty.c nice.c pause.c rand.c stty.c tell.c \
+ times.c utime.c vlimit.c vtimes.c
+STD= ftime.o gtty.o nice.o pause.o rand.o stty.o tell.o \
+ times.o utime.o vlimit.o vtimes.o
+# these should just be pitched, but in the interest of compatibility...
+TRASHSRC=getpw.c
+TRASH= getpw.o
+SRCS= ${STDSRCS} ${TRASHSRCS}
+OBJS= ${STD} ${TRASH}
+TAGSFILE=tags
+
+.c.o:
+ ${CC} -p ${CFLAGS} -c $*.c
+ -ld -X -r $*.o
+ mv a.out profiled/$*.o
+ ${CC} ${CFLAGS} -c $*.c
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+compat-4.1lib compat-4.1lib_p: ${OBJS}
+ @echo "building profiled compat-4.1lib"
+ @cd profiled; ar cru ../compat-4.1lib_p ${OBJS}
+ @echo "buiding normal compat-4.1lib"
+ @ar cru compat-4.1lib ${OBJS}
+
+tags:
+ cwd=`pwd`; \
+ for i in ${SRCS}; do \
+ ctags -a -f ${TAGSFILE} $$cwd/$$i; \
+ done
+
+clean:
+ rm -f compat-4.1lib compat-4.1lib_p *.o profiled/*.o tags Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ftime.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+/*
+ * Backwards compatible ftime.
+ */
+
+/* from old timeb.h */
+struct timeb {
+ time_t time;
+ u_short millitm;
+ short timezone;
+ short dstflag;
+};
+
+ftime(tp)
+ register struct timeb *tp;
+{
+ struct timeval t;
+ struct timezone tz;
+
+ if (gettimeofday(&t, &tz) < 0)
+ return (-1);
+ tp->time = t.tv_sec;
+ tp->millitm = t.tv_usec / 1000;
+ tp->timezone = tz.tz_minuteswest;
+ tp->dstflag = tz.tz_dsttime;
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getpw.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+getpw(uid, buf)
+int uid;
+char buf[];
+{
+ static FILE *pwf;
+ register n, c;
+ register char *bp;
+
+ if(pwf == 0)
+ pwf = fopen("/etc/passwd", "r");
+ if(pwf == NULL)
+ return(1);
+ rewind(pwf);
+
+ for (;;) {
+ bp = buf;
+ while((c=getc(pwf)) != '\n') {
+ if(c == EOF)
+ return(1);
+ *bp++ = c;
+ }
+ *bp++ = '\0';
+ bp = buf;
+ n = 3;
+ while(--n)
+ while((c = *bp++) != ':')
+ if(c == '\n')
+ return(1);
+ while((c = *bp++) != ':') {
+ if(c<'0' || c>'9')
+ continue;
+ n = n*10+c-'0';
+ }
+ if(n == uid)
+ return(0);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)gtty.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Writearound to old gtty system call.
+ */
+
+#include <sgtty.h>
+
+gtty(fd, ap)
+ struct sgttyb *ap;
+{
+
+ return(ioctl(fd, TIOCGETP, ap));
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)nice.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/time.h>
+#include <sys/resource.h>
+
+/*
+ * Backwards compatible nice.
+ */
+nice(incr)
+ int incr;
+{
+ int prio;
+ extern int errno;
+
+ errno = 0;
+ prio = getpriority(PRIO_PROCESS, 0);
+ if (prio == -1 && errno)
+ return (-1);
+ return (setpriority(PRIO_PROCESS, 0, prio + incr));
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)pause.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Backwards compatible pause.
+ */
+pause()
+{
+
+ sigpause(sigblock(0));
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rand.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+static long randx = 1;
+
+srand(x)
+unsigned x;
+{
+ randx = x;
+}
+
+rand()
+{
+ return((randx = randx * 1103515245 + 12345) & 0x7fffffff);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)stty.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Writearound to old stty system call.
+ */
+
+#include <sgtty.h>
+
+stty(fd, ap)
+ struct sgttyb *ap;
+{
+
+ return(ioctl(fd, TIOCSETP, ap));
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)tell.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * return offset in file.
+ */
+
+long lseek();
+
+long tell(f)
+{
+ return(lseek(f, 0L, 1));
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)times.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/time.h>
+#include <sys/resource.h>
+
+/*
+ * Backwards compatible times.
+ */
+struct tms {
+ int tms_utime; /* user time */
+ int tms_stime; /* system time */
+ int tms_cutime; /* user time, children */
+ int tms_cstime; /* system time, children */
+};
+
+times(tmsp)
+ register struct tms *tmsp;
+{
+ struct rusage ru;
+
+ if (getrusage(RUSAGE_SELF, &ru) < 0)
+ return (-1);
+ tmsp->tms_utime = scale60(&ru.ru_utime);
+ tmsp->tms_stime = scale60(&ru.ru_stime);
+ if (getrusage(RUSAGE_CHILDREN, &ru) < 0)
+ return (-1);
+ tmsp->tms_cutime = scale60(&ru.ru_utime);
+ tmsp->tms_cstime = scale60(&ru.ru_stime);
+ return (0);
+}
+
+static
+scale60(tvp)
+ register struct timeval *tvp;
+{
+
+ return (tvp->tv_sec * 60 + tvp->tv_usec / 16667);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)utime.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/time.h>
+/*
+ * Backwards compatible utime.
+ */
+
+utime(name, otv)
+ char *name;
+ int otv[];
+{
+ struct timeval tv[2];
+
+ tv[0].tv_sec = otv[0]; tv[0].tv_usec = 0;
+ tv[1].tv_sec = otv[1]; tv[1].tv_usec = 0;
+ return (utimes(name, tv));
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)vlimit.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * (Almost) backwards compatible vlimit.
+ */
+#include <sys/time.h>
+#include <sys/resource.h>
+#include <errno.h>
+
+/* LIM_NORAISE is not emulated */
+#define LIM_NORAISE 0 /* if <> 0, can't raise limits */
+#define LIM_CPU 1 /* max secs cpu time */
+#define LIM_FSIZE 2 /* max size of file created */
+#define LIM_DATA 3 /* max growth of data space */
+#define LIM_STACK 4 /* max growth of stack */
+#define LIM_CORE 5 /* max size of ``core'' file */
+#define LIM_MAXRSS 6 /* max desired data+stack core usage */
+
+#define NLIMITS 6
+
+vlimit(limit, value)
+ int limit, value;
+{
+ struct rlimit rlim;
+
+ if (limit <= 0 || limit > NLIMITS)
+ return (EINVAL);
+ if (value == -1) {
+ if (getrlimit(limit - 1, &rlim) < 0)
+ return (-1);
+ return (rlim.rlim_cur);
+ }
+ rlim.rlim_cur = value;
+ rlim.rlim_max = RLIM_INFINITY;
+ return (setrlimit(limit - 1, &rlim));
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)vtimes.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/time.h>
+#include <sys/resource.h>
+
+/*
+ * Backwards compatible vtimes.
+ */
+struct vtimes {
+ int vm_utime; /* user time (60'ths) */
+ int vm_stime; /* system time (60'ths) */
+ /* divide next two by utime+stime to get averages */
+ unsigned vm_idsrss; /* integral of d+s rss */
+ unsigned vm_ixrss; /* integral of text rss */
+ int vm_maxrss; /* maximum rss */
+ int vm_majflt; /* major page faults */
+ int vm_minflt; /* minor page faults */
+ int vm_nswap; /* number of swaps */
+ int vm_inblk; /* block reads */
+ int vm_oublk; /* block writes */
+};
+
+vtimes(par, chi)
+ register struct vtimes *par, *chi;
+{
+ struct rusage ru;
+
+ if (par) {
+ if (getrusage(RUSAGE_SELF, &ru) < 0)
+ return (-1);
+ getvtimes(&ru, par);
+ }
+ if (chi) {
+ if (getrusage(RUSAGE_CHILDREN, &ru) < 0)
+ return (-1);
+ getvtimes(&ru, chi);
+ }
+ return (0);
+}
+
+static
+getvtimes(aru, avt)
+ register struct rusage *aru;
+ register struct vtimes *avt;
+{
+
+ avt->vm_utime = scale60(&aru->ru_utime);
+ avt->vm_stime = scale60(&aru->ru_stime);
+ avt->vm_idsrss = ((aru->ru_idrss+aru->ru_isrss) / 100) * 60;
+ avt->vm_ixrss = aru->ru_ixrss / 100 * 60;
+ avt->vm_maxrss = aru->ru_maxrss;
+ avt->vm_majflt = aru->ru_majflt;
+ avt->vm_minflt = aru->ru_minflt;
+ avt->vm_nswap = aru->ru_nswap;
+ avt->vm_inblk = aru->ru_inblock;
+ avt->vm_oublk = aru->ru_oublock;
+}
+
+static
+scale60(tvp)
+ register struct timeval *tvp;
+{
+
+ return (tvp->tv_sec * 60 + tvp->tv_usec / 16667);
+}
--- /dev/null
+/* compat-sys5/memccpy.c */
+char *memccpy __P((register char *t, register char *f, register c, register n));
+/* compat-sys5/strcmpn.c */
+int strcmpn __P((register char *s1, register char *s2, register n));
+/* compat-sys5/strcatn.c */
+char *strcatn __P((register char *s1, register char *s2, register n));
+/* compat-sys5/getopt.c */
+int getopt __P((int nargc, char **nargv, char *ostr));
+/* compat-sys5/memchr.c */
+char *memchr __P((register char *s, register c, register n));
+/* compat-sys5/memcpy.c */
+char *memcpy __P((register char *t, register char *f, register n));
+/* compat-sys5/strtok.c */
+char *strtok __P((register char *s, register char *sep));
+/* compat-sys5/tmpnam.c */
+char *tmpnam __P((char *s));
+/* compat-sys5/memset.c */
+char *memset __P((register char *s, register c, register n));
+/* compat-sys5/memcmp.c */
+int memcmp __P((register char *s1, register char *s2, register n));
+/* compat-sys5/strchr.c */
+char *strchr __P((register char *sp, int c));
+/* compat-sys5/strcspn.c */
+int strcspn __P((register char *s, register char *set));
+/* compat-sys5/strrchr.c */
+char *strrchr __P((register char *sp, int c));
+/* compat-sys5/strpbrk.c */
+char *strpbrk __P((register char *s, register char *brk));
+/* compat-sys5/strspn.c */
+int strspn __P((register char *s, register char *set));
+/* compat-sys5/strcpyn.c */
+char *strcpyn __P((register char *s1, register char *s2, int n));
--- /dev/null
+# Makefile 1.5 85/09/05
+#
+CFLAGS= -O ${DEFS}
+SRCS= getopt.c memccpy.c memchr.c memcmp.c memcpy.c memset.c \
+ strcatn.c strchr.c strcmpn.c strcpyn.c strcspn.c strpbrk.c \
+ strrchr.c strspn.c strtok.c tmpnam.c
+OBJS= getopt.o memccpy.o memchr.o memcmp.o memcpy.o memset.o \
+ strcatn.o strchr.o strcmpn.o strcpyn.o strcspn.o strpbrk.o \
+ strrchr.o strspn.o strtok.o tmpnam.o
+TAGSFILE=tags
+
+.c.o:
+ ${CC} -p ${CFLAGS} -c $*.c
+ -ld -X -r $*.o
+ mv a.out profiled/$*.o
+ ${CC} ${CFLAGS} -c $*.c
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+compat-sys5lib compat-sys5lib_p: ${OBJS}
+ @echo "building profiled compat-sys5lib"
+ @cd profiled; ar cru ../compat-sys5lib_p ${OBJS}
+ @echo "buiding normal compat-sys5lib"
+ @ar cru compat-sys5lib ${OBJS}
+
+tags:
+ cwd=`pwd`; \
+ for i in ${SRCS}; do \
+ ctags -a -f ${TAGSFILE} $$cwd/$$i; \
+ done
+
+clean:
+ rm -f compat-sys5lib compat-sys5lib_p *.o profiled/*.o Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+getopt.o: getopt.c /usr/include/stdio.h
+memccpy.o: memccpy.c
+memchr.o: memchr.c
+memcmp.o: memcmp.c
+memcpy.o: memcpy.c
+memset.o: memset.c
+strcatn.o: strcatn.c
+strchr.o: strchr.c
+strcmpn.o: strcmpn.c
+strcpyn.o: strcpyn.c
+strcspn.o: strcspn.c
+strpbrk.o: strpbrk.c
+strrchr.o: strrchr.c
+strspn.o: strspn.c
+strtok.o: strtok.c
+tmpnam.o: tmpnam.c
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getopt.c 4.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+/*
+ * get option letter from argument vector
+ */
+int opterr = 1, /* if error message should be printed */
+ optind = 1, /* index into parent argv vector */
+ optopt; /* character checked for validity */
+char *optarg; /* argument associated with option */
+
+#define BADCH (int)'?'
+#define EMSG ""
+#define tell(s) if (opterr) {fputs(*nargv,stderr);fputs(s,stderr); \
+ fputc(optopt,stderr);fputc('\n',stderr);return(BADCH);}
+
+getopt(nargc,nargv,ostr)
+int nargc;
+char **nargv,
+ *ostr;
+{
+ static char *place = EMSG; /* option letter processing */
+ register char *oli; /* option letter list index */
+ char *index();
+
+ if(!*place) { /* update scanning pointer */
+ if(optind >= nargc || *(place = nargv[optind]) != '-' || !*++place) return(EOF);
+ if (*place == '-') { /* found "--" */
+ ++optind;
+ return(EOF);
+ }
+ } /* option letter okay? */
+ if ((optopt = (int)*place++) == (int)':' || !(oli = index(ostr,optopt))) {
+ if(!*place) ++optind;
+ tell(": illegal option -- ");
+ }
+ if (*++oli != ':') { /* don't need argument */
+ optarg = NULL;
+ if (!*place) ++optind;
+ }
+ else { /* need an argument */
+ if (*place) optarg = place; /* no white space */
+ else if (nargc <= ++optind) { /* no arg */
+ place = EMSG;
+ tell(": option requires an argument -- ");
+ }
+ else optarg = nargv[optind]; /* white space */
+ place = EMSG;
+ ++optind;
+ }
+ return(optopt); /* dump back option letter */
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+/*
+ * Sys5 compat routine
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)memccpy.c 5.2 (Berkeley) 86/03/09";
+#endif
+
+char *
+memccpy(t, f, c, n)
+ register char *t, *f;
+ register c, n;
+{
+ while (--n >= 0)
+ if ((*t++ = *f++) == c)
+ return (t);
+ return (0);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+/*
+ * Sys5 compat routine
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)memchr.c 5.2 (Berkeley) 86/03/09";
+#endif
+
+char *
+memchr(s, c, n)
+ register char *s;
+ register c, n;
+{
+ while (--n >= 0)
+ if (*s++ == c)
+ return (--s);
+ return (0);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+/*
+ * Sys5 compat routine
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)memcmp.c 5.2 (Berkeley) 86/03/09";
+#endif
+
+memcmp(s1, s2, n)
+ register char *s1, *s2;
+ register n;
+{
+ while (--n >= 0)
+ if (*s1++ != *s2++)
+ return (*--s1 - *--s2);
+ return (0);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+/*
+ * Sys5 compat routine
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)memcpy.c 5.2 (Berkeley) 86/03/09";
+#endif
+
+char *
+memcpy(t, f, n)
+ register char *t, *f;
+ register n;
+{
+ register char *p = t;
+
+ while (--n >= 0)
+ *t++ = *f++;
+
+ return (p);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+/*
+ * Sys5 compat routine
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)memset.c 5.2 (Berkeley) 86/03/09";
+#endif
+
+char *
+memset(s, c, n)
+ register char *s;
+ register c, n;
+{
+ register char *p = s;
+
+ while (--n >= 0)
+ *s++ = c;
+
+ return (p);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcatn.c 4.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Concatenate s2 on the end of s1. S1's space must be large enough.
+ * At most n characters are moved.
+ * Return s1.
+ */
+
+char *
+strcatn(s1, s2, n)
+register char *s1, *s2;
+register n;
+{
+ register char *os1;
+
+ os1 = s1;
+ while (*s1++)
+ ;
+ --s1;
+ while (*s1++ = *s2++)
+ if (--n < 0) {
+ *--s1 = '\0';
+ break;
+ }
+ return(os1);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strchr.c 5.2 (Berkeley) 86/03/09";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Return the ptr in sp at which the character c appears;
+ * NULL if not found
+ *
+ * this routine is just "index" renamed.
+ */
+
+#define NULL 0
+
+char *
+strchr(sp, c)
+register char *sp, c;
+{
+ do {
+ if (*sp == c)
+ return(sp);
+ } while (*sp++);
+ return(NULL);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcmpn.c 4.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Compare strings (at most n bytes): s1>s2: >0 s1==s2: 0 s1<s2: <0
+ */
+
+strcmpn(s1, s2, n)
+register char *s1, *s2;
+register n;
+{
+
+ while (--n >= 0 && *s1 == *s2++)
+ if (*s1++ == '\0')
+ return(0);
+ return(n<0 ? 0 : *s1 - *--s2);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcpyn.c 4.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Copy s2 to s1, truncating or null-padding to always copy n bytes
+ * return s1
+ */
+
+char *
+strcpyn(s1, s2, n)
+register char *s1, *s2;
+{
+ register i;
+ register char *os1;
+
+ os1 = s1;
+ for (i = 0; i < n; i++)
+ if ((*s1++ = *s2++) == '\0') {
+ while (++i < n)
+ *s1++ = '\0';
+ return(os1);
+ }
+ return(os1);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+/*
+ * Sys5 compat routine
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcspn.c 5.2 (Berkeley) 86/03/09";
+#endif
+
+strcspn(s, set)
+ register char *s, *set;
+{
+ register n = 0;
+ register char *p;
+ register c;
+
+ while (c = *s++) {
+ for (p = set; *p; p++)
+ if (c == *p)
+ break;
+ if (*p)
+ return (n);
+ n++;
+ }
+ return (n);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+/*
+ * Sys 5 compat routine...
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strpbrk.c 5.2 (Berkeley) 86/03/09";
+#endif
+
+char *
+strpbrk(s, brk)
+ register char *s, *brk;
+{
+ register char *p;
+ register c;
+
+ while (c = *s) {
+ for (p = brk; *p; p++)
+ if (c == *p)
+ return (s);
+ s++;
+ }
+ return (0);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strrchr.c 5.2 (berkeley) 86/03/09";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Return the ptr in sp at which the character c last
+ * appears; NULL if not found
+ *
+ * This routine is just "rindex" renamed.
+ */
+
+#define NULL 0
+
+char *
+strrchr(sp, c)
+register char *sp, c;
+{
+ register char *r;
+
+ r = NULL;
+ do {
+ if (*sp == c)
+ r = sp;
+ } while (*sp++);
+ return(r);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+/*
+ * Sys5 compat routine
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strspn.c 5.2 (Berkeley) 86/03/09";
+#endif
+
+strspn(s, set)
+ register char *s, *set;
+{
+ register n = 0;
+ register char *p;
+ register c;
+
+ while (c = *s++) {
+ for (p = set; *p; p++)
+ if (c == *p)
+ break;
+ if (!*p)
+ return (n);
+ n++;
+ }
+ return (n);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+/*
+ * Sys5 compat routine
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strtok.c 5.2 (Berkeley) 86/03/09";
+#endif
+
+char *
+strtok(s, sep)
+ register char *s, *sep;
+{
+ register char *p;
+ register c;
+ static char *lasts;
+
+ if (s == 0)
+ s = lasts;
+ if (s == 0)
+ return (0);
+
+ while (c = *s) {
+ if (!index(sep, c))
+ break;
+ s++;
+ }
+
+ if (c == '\0') {
+ lasts = 0;
+ return (0);
+ }
+
+ for (p = s; c = *++p; )
+ if (index(sep, c))
+ break;
+
+ if (c == '\0')
+ lasts = 0;
+ else {
+ *p++ = '\0';
+ lasts = p;
+ }
+ return (s);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)tmpnam.c 4.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+char *tmpnam(s)
+char *s;
+{
+ static seed;
+
+ sprintf(s, "temp.%d.%d", getpid(), seed++);
+ return(s);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)crt0.c 5.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * C start up routine.
+ * Robert Henry, UCB, 20 Oct 81
+ *
+ * We make the following (true) assumptions:
+ * 1) when the kernel calls start, it does a jump to location 2,
+ * and thus avoids the register save mask. We are NOT called
+ * with a calls! see sys1.c:setregs().
+ * 2) The only register variable that we can trust is sp,
+ * which points to the base of the kernel calling frame.
+ * Do NOT believe the documentation in exec(2) regarding the
+ * values of fp and ap.
+ * 3) We can allocate as many register variables as we want,
+ * and don't have to save them for anybody.
+ * 4) Because of the ways that asm's work, we can't have
+ * any automatic variables allocated on the stack, because
+ * we must catch the value of sp before any automatics are
+ * allocated.
+ */
+
+char **environ = (char **)0;
+static int fd;
+
+asm("#define _start start");
+asm("#define _eprol eprol");
+extern unsigned char etext;
+extern unsigned char eprol;
+start()
+{
+ struct kframe {
+ int kargc;
+ char *kargv[1]; /* size depends on kargc */
+ char kargstr[1]; /* size varies */
+ char kenvstr[1]; /* size varies */
+ };
+ /*
+ * ALL REGISTER VARIABLES!!!
+ */
+ register int r11; /* needed for init */
+ register struct kframe *kfp; /* r10 */
+ register char **targv;
+ register char **argv;
+ extern int errno;
+
+#ifdef lint
+ kfp = 0;
+ initcode = initcode = 0;
+#else not lint
+ asm(" movl sp,r10"); /* catch it quick */
+#endif not lint
+ for (argv = targv = &kfp->kargv[0]; *targv++; /* void */)
+ /* void */ ;
+ if (targv >= (char **)(*argv))
+ --targv;
+ environ = targv;
+asm("eprol:");
+
+#ifdef paranoid
+ /*
+ * The standard I/O library assumes that file descriptors 0, 1, and 2
+ * are open. If one of these descriptors is closed prior to the start
+ * of the process, I/O gets very confused. To avoid this problem, we
+ * insure that the first three file descriptors are open before calling
+ * main(). Normally this is undefined, as it adds two unnecessary
+ * system calls.
+ */
+ do {
+ fd = open("/dev/null", 2);
+ } while (fd >= 0 && fd < 3);
+ close(fd);
+#endif paranoid
+
+#ifdef MCRT0
+ monstartup(&eprol, &etext);
+#endif MCRT0
+ errno = 0;
+ exit(main(kfp->kargc, argv, environ));
+}
+asm("#undef _start");
+asm("#undef _eprol");
+
+#ifdef MCRT0
+/*ARGSUSED*/
+exit(code)
+ register int code; /* r11 */
+{
+ monitor(0);
+ _cleanup();
+ asm(" movl r11,r0");
+ asm(" chmk $1");
+}
+#endif MCRT0
+
+#ifdef CRT0
+/*
+ * null mcount and moncontrol,
+ * just in case some routine is compiled for profiling
+ */
+moncontrol(val)
+ int val;
+{
+
+}
+asm(" .globl mcount");
+asm("mcount: rsb");
+#endif CRT0
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)gmon.c 5.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#ifdef DEBUG
+#include <stdio.h>
+#endif DEBUG
+
+#include "gmon.h"
+
+ /*
+ * froms is actually a bunch of unsigned shorts indexing tos
+ */
+static int profiling = 3;
+static unsigned short *froms;
+static struct tostruct *tos = 0;
+static long tolimit = 0;
+static char *s_lowpc = 0;
+static char *s_highpc = 0;
+static unsigned long s_textsize = 0;
+
+static int ssiz;
+static char *sbuf;
+static int s_scale;
+ /* see profil(2) where this is describe (incorrectly) */
+#define SCALE_1_TO_1 0x10000L
+
+#define MSG "No space for monitor buffer(s)\n"
+
+monstartup(lowpc, highpc)
+ char *lowpc;
+ char *highpc;
+{
+ int monsize;
+ char *buffer;
+ char *sbrk();
+ extern char *minbrk;
+
+ /*
+ * round lowpc and highpc to multiples of the density we're using
+ * so the rest of the scaling (here and in gprof) stays in ints.
+ */
+ lowpc = (char *)
+ ROUNDDOWN((unsigned)lowpc, HISTFRACTION*sizeof(HISTCOUNTER));
+ s_lowpc = lowpc;
+ highpc = (char *)
+ ROUNDUP((unsigned)highpc, HISTFRACTION*sizeof(HISTCOUNTER));
+ s_highpc = highpc;
+ s_textsize = highpc - lowpc;
+ monsize = (s_textsize / HISTFRACTION) + sizeof(struct phdr);
+ buffer = sbrk( monsize );
+ if ( buffer == (char *) -1 ) {
+ write( 2 , MSG , sizeof(MSG) );
+ return;
+ }
+ froms = (unsigned short *) sbrk( s_textsize / HASHFRACTION );
+ if ( froms == (unsigned short *) -1 ) {
+ write( 2 , MSG , sizeof(MSG) );
+ froms = 0;
+ return;
+ }
+ tolimit = s_textsize * ARCDENSITY / 100;
+ if ( tolimit < MINARCS ) {
+ tolimit = MINARCS;
+ } else if ( tolimit > 65534 ) {
+ tolimit = 65534;
+ }
+ tos = (struct tostruct *) sbrk( tolimit * sizeof( struct tostruct ) );
+ if ( tos == (struct tostruct *) -1 ) {
+ write( 2 , MSG , sizeof(MSG) );
+ froms = 0;
+ tos = 0;
+ return;
+ }
+ minbrk = sbrk(0);
+ tos[0].link = 0;
+ monitor( lowpc , highpc , buffer , monsize , tolimit );
+}
+
+_mcleanup()
+{
+ int fd;
+ int fromindex;
+ int endfrom;
+ char *frompc;
+ int toindex;
+ struct rawarc rawarc;
+
+ fd = creat( "gmon.out" , 0666 );
+ if ( fd < 0 ) {
+ perror( "mcount: gmon.out" );
+ return;
+ }
+# ifdef DEBUG
+ fprintf( stderr , "[mcleanup] sbuf 0x%x ssiz %d\n" , sbuf , ssiz );
+# endif DEBUG
+ write( fd , sbuf , ssiz );
+ endfrom = s_textsize / (HASHFRACTION * sizeof(*froms));
+ for ( fromindex = 0 ; fromindex < endfrom ; fromindex++ ) {
+ if ( froms[fromindex] == 0 ) {
+ continue;
+ }
+ frompc = s_lowpc + (fromindex * HASHFRACTION * sizeof(*froms));
+ for (toindex=froms[fromindex]; toindex!=0; toindex=tos[toindex].link) {
+# ifdef DEBUG
+ fprintf( stderr ,
+ "[mcleanup] frompc 0x%x selfpc 0x%x count %d\n" ,
+ frompc , tos[toindex].selfpc , tos[toindex].count );
+# endif DEBUG
+ rawarc.raw_frompc = (unsigned long) frompc;
+ rawarc.raw_selfpc = (unsigned long) tos[toindex].selfpc;
+ rawarc.raw_count = tos[toindex].count;
+ write( fd , &rawarc , sizeof rawarc );
+ }
+ }
+ close( fd );
+}
+
+asm(".text");
+asm(".align 2");
+asm("#the beginning of mcount()");
+asm(".data");
+mcount()
+{
+ register char *selfpc; /* r11 => r5 */
+ register unsigned short *frompcindex; /* r10 => r4 */
+ register struct tostruct *top; /* r9 => r3 */
+ register struct tostruct *prevtop; /* r8 => r2 */
+ register long toindex; /* r7 => r1 */
+
+ /*
+ * find the return address for mcount,
+ * and the return address for mcount's caller.
+ */
+ asm(" .text"); /* make sure we're in text space */
+ asm(" movl (sp), r11"); /* selfpc = ... (jsb frame) */
+ asm(" movl 16(fp), r10"); /* frompcindex = (calls frame) */
+ /*
+ * check that we are profiling
+ * and that we aren't recursively invoked.
+ */
+ if (profiling) {
+ goto out;
+ }
+ profiling++;
+ /*
+ * check that frompcindex is a reasonable pc value.
+ * for example: signal catchers get called from the stack,
+ * not from text space. too bad.
+ */
+ frompcindex = (unsigned short *)((long)frompcindex - (long)s_lowpc);
+ if ((unsigned long)frompcindex > s_textsize) {
+ goto done;
+ }
+ frompcindex =
+ &froms[((long)frompcindex) / (HASHFRACTION * sizeof(*froms))];
+ toindex = *frompcindex;
+ if (toindex == 0) {
+ /*
+ * first time traversing this arc
+ */
+ toindex = ++tos[0].link;
+ if (toindex >= tolimit) {
+ goto overflow;
+ }
+ *frompcindex = toindex;
+ top = &tos[toindex];
+ top->selfpc = selfpc;
+ top->count = 1;
+ top->link = 0;
+ goto done;
+ }
+ top = &tos[toindex];
+ if (top->selfpc == selfpc) {
+ /*
+ * arc at front of chain; usual case.
+ */
+ top->count++;
+ goto done;
+ }
+ /*
+ * have to go looking down chain for it.
+ * top points to what we are looking at,
+ * prevtop points to previous top.
+ * we know it is not at the head of the chain.
+ */
+ for (; /* goto done */; ) {
+ if (top->link == 0) {
+ /*
+ * top is end of the chain and none of the chain
+ * had top->selfpc == selfpc.
+ * so we allocate a new tostruct
+ * and link it to the head of the chain.
+ */
+ toindex = ++tos[0].link;
+ if (toindex >= tolimit) {
+ goto overflow;
+ }
+ top = &tos[toindex];
+ top->selfpc = selfpc;
+ top->count = 1;
+ top->link = *frompcindex;
+ *frompcindex = toindex;
+ goto done;
+ }
+ /*
+ * otherwise, check the next arc on the chain.
+ */
+ prevtop = top;
+ top = &tos[top->link];
+ if (top->selfpc == selfpc) {
+ /*
+ * there it is.
+ * increment its count
+ * move it to the head of the chain.
+ */
+ top->count++;
+ toindex = prevtop->link;
+ prevtop->link = top->link;
+ top->link = *frompcindex;
+ *frompcindex = toindex;
+ goto done;
+ }
+
+ }
+done:
+ profiling--;
+ /* and fall through */
+out:
+ asm(" rsb");
+
+overflow:
+ profiling++; /* halt further profiling */
+# define TOLIMIT "mcount: tos overflow\n"
+ write(2, TOLIMIT, sizeof(TOLIMIT));
+ goto out;
+}
+asm(".text");
+asm("#the end of mcount()");
+asm(".data");
+
+/*VARARGS1*/
+monitor( lowpc , highpc , buf , bufsiz , nfunc )
+ char *lowpc;
+ char *highpc;
+ char *buf; /* declared ``short buffer[]'' in monitor(3) */
+ int bufsiz;
+ int nfunc; /* not used, available for compatability only */
+{
+ register o;
+
+ if ( lowpc == 0 ) {
+ moncontrol(0);
+ _mcleanup();
+ return;
+ }
+ sbuf = buf;
+ ssiz = bufsiz;
+ ( (struct phdr *) buf ) -> lpc = lowpc;
+ ( (struct phdr *) buf ) -> hpc = highpc;
+ ( (struct phdr *) buf ) -> ncnt = ssiz;
+ bufsiz -= sizeof(struct phdr);
+ if ( bufsiz <= 0 )
+ return;
+ o = highpc - lowpc;
+ if( bufsiz < o )
+ s_scale = ( (float) bufsiz / o ) * SCALE_1_TO_1;
+ else
+ s_scale = SCALE_1_TO_1;
+ moncontrol(1);
+}
+
+/*
+ * Control profiling
+ * profiling is what mcount checks to see if
+ * all the data structures are ready.
+ */
+moncontrol(mode)
+ int mode;
+{
+ if (mode) {
+ /* start */
+ profil(sbuf + sizeof(struct phdr), ssiz - sizeof(struct phdr),
+ s_lowpc, s_scale);
+ profiling = 0;
+ } else {
+ /* stop */
+ profil((char *)0, 0, 0, 0);
+ profiling = 3;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)mon.c 5.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#define ARCDENSITY 5 /* density of routines */
+#define MINARCS 50 /* minimum number of counters */
+#define HISTFRACTION 2 /* fraction of text space for histograms */
+
+
+struct phdr {
+ int *lpc;
+ int *hpc;
+ int ncnt;
+};
+
+struct cnt {
+ int *pc;
+ long ncall;
+} *countbase;
+
+static int cntrs = 0;
+static int profiling = 3;
+static char *s_sbuf;
+static int s_bufsiz;
+static int s_scale;
+static char *s_lowpc;
+
+int numctrs;
+
+#define MSG "No space for monitor buffer(s)\n"
+
+monstartup(lowpc, highpc)
+ char *lowpc;
+ char *highpc;
+{
+ int monsize;
+ char *buffer;
+ int cntsiz;
+ extern char *sbrk();
+ extern char *minbrk;
+
+
+ cntsiz = (highpc - lowpc) * ARCDENSITY / 100;
+ if (cntsiz < MINARCS)
+ cntsiz = MINARCS;
+ monsize = (highpc - lowpc + HISTFRACTION - 1) / HISTFRACTION
+ + sizeof(struct phdr) + cntsiz * sizeof(struct cnt);
+ monsize = (monsize + 1) & ~1;
+ buffer = sbrk(monsize);
+ if (buffer == (char *)-1) {
+ write(2, MSG, sizeof(MSG));
+ return;
+ }
+ minbrk = sbrk(0);
+ monitor(lowpc, highpc, buffer, monsize, cntsiz);
+}
+
+/*
+ * This routine is massaged so that it may be jsb'ed to
+ */
+asm(".text");
+asm("#the beginning of mcount()");
+asm(".data");
+mcount()
+{
+ register int *selfpc; /* r11 */
+ register long **cntp; /* r10 */
+
+ /*
+ * find the return address for mcount,
+ * and address of counter pointer
+ */
+ asm(" movl (sp),r11"); /* selfpc = ... (jsb frame) */
+ asm(" movl r0,r10"); /* address of count local */
+ /*
+ * check that we aren't recursively invoked.
+ */
+ if (profiling)
+ goto out;
+ profiling++;
+ /*
+ * check that counter is allocated
+ */
+ if (*cntp == 0) {
+ /*
+ * check that a counter is available
+ */
+ if (cntrs++ == numctrs)
+ goto overflow;
+ countbase->pc = selfpc;
+ *cntp = &countbase->ncall;
+ countbase++;
+ }
+ (**cntp)++;
+ profiling--;
+out:
+ asm( " rsb" );
+
+overflow:
+# define TOLIMIT "mcount: counter overflow\n"
+ write( 2 , TOLIMIT , sizeof( TOLIMIT ) );
+ goto out;
+}
+asm(".text");
+asm("#the end of mcount()");
+asm(".data");
+
+monitor(lowpc, highpc, buf, bufsiz, cntsiz)
+ char *lowpc, *highpc;
+ char *buf;
+ int bufsiz, cntsiz;
+{
+ register int o;
+ struct phdr *php;
+ static int ssiz;
+ static char *sbuf;
+
+ if (lowpc == 0) {
+ moncontrol(0);
+ o = creat("mon.out", 0666);
+ write(o, sbuf, ssiz);
+ close(o);
+ return;
+ }
+ sbuf = buf;
+ ssiz = bufsiz;
+ php = (struct phdr *)&buf[0];
+ php->lpc = (int *)lowpc;
+ php->hpc = (int *)highpc;
+ php->ncnt = cntsiz;
+ numctrs = cntsiz;
+ countbase = (struct cnt *)(buf + sizeof(struct phdr));
+ o = sizeof(struct phdr) + cntsiz * sizeof(struct cnt);
+ buf += o;
+ bufsiz -= o;
+ if (bufsiz <= 0)
+ return;
+ o = (highpc - lowpc);
+ if(bufsiz < o)
+ o = ((float) bufsiz / o) * 65536;
+ else
+ o = 65536;
+ s_scale = o;
+ s_sbuf = buf;
+ s_bufsiz = bufsiz;
+ s_lowpc = lowpc;
+ moncontrol(1);
+}
+
+/*
+ * Control profiling
+ * profiling is what mcount checks to see if
+ * all the data structures are ready.
+ */
+moncontrol(mode)
+ int mode;
+{
+ if (mode) {
+ /* start */
+ profil(s_sbuf, s_bufsiz, s_lowpc, s_scale);
+ profiling = 0;
+ } else {
+ /* stop */
+ profil((char *)0, 0, 0, 0);
+ profiling = 3;
+ }
+}
--- /dev/null
+include/arpa/inet.h:unsigned long inet_addr();
+include/arpa/inet.h:char *inet_ntoa();
+include/arpa/inet.h:struct in_addr inet_makeaddr();
+include/arpa/inet.h:unsigned long inet_network();
+include/arpa/nameser.h:extern u_short getshort();
+include/arpa/nameser.h:extern u_long getlong();
+include/netdb.h:struct hostent *gethostbyname(), *gethostbyaddr(), *gethostent();
+include/netdb.h:struct netent *getnetbyname(), *getnetbyaddr(), *getnetent();
+include/netdb.h:struct servent *getservbyname(), *getservbyport(), *getservent();
+include/netdb.h:struct protoent *getprotobyname(), *getprotobynumber(), *getprotoent();
+include/math.h:extern double asinh(), acosh(), atanh();
+include/math.h:extern double erf(), erfc();
+include/math.h:extern double exp(), expm1(), log(), log10(), log1p(), pow();
+include/math.h:extern double fabs(), floor(), ceil(), rint();
+include/math.h:extern double lgamma();
+include/math.h:extern double hypot(), cabs();
+include/math.h:extern double copysign(), drem(), logb(), scalb();
+include/math.h:extern int finite();
+include/math.h:extern double infnan();
+include/math.h:extern double j0(), j1(), jn(), y0(), y1(), yn();
+include/math.h:extern double sin(), cos(), tan(), asin(), acos(), atan(), atan2();
+include/math.h:extern double sinh(), cosh(), tanh();
+include/math.h:extern double cbrt(), sqrt();
+include/math.h:extern double modf(), ldexp(), frexp(), atof();
+include/netimp/if_imp.h: int (*ic_init)(); /* hardware init routine */
+include/netimp/if_imp.h: int (*ic_start)(); /* hardware start output routine */
+include/netimp/if_imphost.h:struct host *hostlookup();
+include/netimp/if_imphost.h:struct host *hostenter();
+include/netimp/if_imphost.h:struct mbuf *hostdeque();
+include/vaxuba/ubavar.h: int (**uh_vec)(); /* interrupt vector */
+include/vaxuba/ubavar.h: int (**um_intr)(); /* interrupt handler(s) */
+include/vaxuba/ubavar.h: int (**ui_intr)(); /* interrupt handler(s) */
+include/vaxuba/ubavar.h: int (*ud_probe)(); /* see if a driver is really there */
+include/vaxuba/ubavar.h: int (*ud_slave)(); /* see if a slave is there */
+include/vaxuba/ubavar.h: int (*ud_attach)(); /* setup driver for a slave */
+include/vaxuba/ubavar.h: int (*ud_dgo)(); /* fill csr/ba to start transfer */
+include/vaxuba/ubavar.h: int (*ud_ubamem)(); /* see if dedicated memory is present */
+include/vaxuba/ubavar.h:extern int (*UNIvec[])(); /* unibus vec for uba0 */
+include/vaxuba/ubavar.h:extern int (*UNI1vec[])(); /* unibus vec for uba1 */
+include/vaxuba/ubavar.h:extern Xua0int(), Xua1int(), Xua2int(), Xua3int();
+include/vaxuba/npreg.h: int (*intr)(); /* Ptr to routine to call at interrupt time */
+include/vaxuba/pdma.h: int (*p_fcn)();
+include/grp.h:struct group *getgrent(), *getgrgid(), *getgrnam();
+include/memory.h:extern char *memccpy();
+include/memory.h:extern char *memchr();
+include/memory.h:extern int memcmp();
+include/memory.h:extern char *memcpy();
+include/memory.h:extern char *memset();
+include/net/netisr.h:#define schednetisr(anisr) { netisr |= 1<<(anisr); setsoftnet(); }
+include/net/af.h: int (*af_hash)();
+include/net/af.h: int (*af_netmatch)();
+include/net/if.h: int (*if_init)(); /* init routine */
+include/net/if.h: int (*if_output)(); /* output routine */
+include/net/if.h: int (*if_ioctl)(); /* ioctl routine */
+include/net/if.h: int (*if_reset)(); /* bus reset routine */
+include/net/if.h: int (*if_watchdog)(); /* timer routine */
+include/net/if.h:struct ifaddr *ifa_ifwithaddr(), *ifa_ifwithnet();
+include/net/if.h:struct ifaddr *ifa_ifwithdstaddr();
+include/vaxmba/mbavar.h: int (*md_attach)(); /* attach a device */
+include/vaxmba/mbavar.h: int (*md_slave)(); /* attach a slave */
+include/vaxmba/mbavar.h: int (*md_ustart)(); /* unit start routine */
+include/vaxmba/mbavar.h: int (*md_start)(); /* setup a data transfer */
+include/vaxmba/mbavar.h: int (*md_dtint)(); /* data transfer complete */
+include/vaxmba/mbavar.h: int (*md_ndint)(); /* non-data transfer interrupt */
+include/vaxmba/mbavar.h:extern Xmba0int(), Xmba1int(), Xmba2int(), Xmba3int();
+include/vax/scb.h: int (*scb_stray)(); /* reserved */
+include/vax/scb.h: int (*scb_machchk)(); /* machine chack */
+include/vax/scb.h: int (*scb_kspinval)(); /* KSP invalid */
+include/vax/scb.h: int (*scb_powfail)(); /* power fail */
+include/vax/scb.h: int (*scb_resinstr)(); /* reserved instruction */
+include/vax/scb.h: int (*scb_custinst)(); /* XFC instr */
+include/vax/scb.h: int (*scb_resopnd)(); /* reserved operand */
+include/vax/scb.h: int (*scb_resaddr)(); /* reserved addr mode */
+include/vax/scb.h: int (*scb_acv)(); /* access control violation */
+include/vax/scb.h: int (*scb_tnv)(); /* translation not valid */
+include/vax/scb.h: int (*scb_tracep)(); /* trace pending */
+include/vax/scb.h: int (*scb_bpt)(); /* breakpoint instr */
+include/vax/scb.h: int (*scb_compat)(); /* compatibility mode fault */
+include/vax/scb.h: int (*scb_arith)(); /* arithmetic fault */
+include/vax/scb.h: int (*scb_stray2)();
+include/vax/scb.h: int (*scb_stray3)();
+include/vax/scb.h: int (*scb_chmk)(); /* CHMK instr */
+include/vax/scb.h: int (*scb_chme)(); /* CHME instr */
+include/vax/scb.h: int (*scb_chms)(); /* CHMS instr */
+include/vax/scb.h: int (*scb_chmu)(); /* CHMU instr */
+include/vax/scb.h: int (*scb_sbisilo)(); /* SBI silo compare */
+include/vax/scb.h: int (*scb_cmrd)(); /* corrected mem read data */
+include/vax/scb.h: int (*scb_sbialert)(); /* SBI alert */
+include/vax/scb.h: int (*scb_sbiflt)(); /* SBI fault */
+include/vax/scb.h: int (*scb_wtime)(); /* memory write timeout */
+include/vax/scb.h: int (*scb_stray4[8])();
+include/vax/scb.h: int (*scb_soft[15])(); /* software interrupt */
+include/vax/scb.h: int (*scb_timer)(); /* interval timer interrupt */
+include/vax/scb.h: int (*scb_stray5[7])();
+include/vax/scb.h: int (*scb_stray6[4])();
+include/vax/scb.h: int (*scb_csdr)(); /* console storage receive */
+include/vax/scb.h: int (*scb_csdx)(); /* console storage transmit */
+include/vax/scb.h: int (*scb_ctr)(); /* console terminal receive */
+include/vax/scb.h: int (*scb_ctx)(); /* console terminal transmit */
+include/vax/scb.h: int (*scb_ipl14[16])(); /* device interrupts IPL 14 */
+include/vax/scb.h: int (*scb_ipl15[16])(); /* " " IPL 15 */
+include/vax/scb.h: int (*scb_ipl16[16])(); /* " " IPL 16 */
+include/vax/scb.h: int (*scb_ipl17[16])(); /* " " IPL 17 */
+include/vax/scb.h: int (*scb_ubaint[128])(); /* Unibus device intr */
+include/vax/scb.h: int (*scb_uba1int[128])(); /* Unibus 1 device intr */
+include/vax/inline/inline.h:char *newline(), *copyline(), *doreplaceon();
+include/vax/rpb.h: int (*rp_dumprout)(); /* routine to be called */
+include/pwd.h:struct passwd *getpwent(), *getpwuid(), *getpwnam();
+include/string.h:extern char *strcpyn();
+include/string.h:extern char *strcatn();
+include/string.h:extern int strcmpn();
+include/string.h:extern char *strchr();
+include/string.h:extern char *strrchr();
+include/string.h:extern char *strpbrk();
+include/string.h:extern int strspn();
+include/string.h:extern int strcspn();
+include/string.h:extern char *strtok();
+include/ttyent.h:extern struct ttyent *getttyent();
+include/ttyent.h:extern struct ttyent *getttynam();
+include/stdio.h:FILE *fopen();
+include/stdio.h:FILE *fdopen();
+include/stdio.h:FILE *freopen();
+include/stdio.h:FILE *popen();
+include/stdio.h:long ftell();
+include/stdio.h:char *fgets();
+include/stdio.h:char *gets();
+include/stdio.h:char *sprintf(); /* too painful to do right */
+include/resolv.h:extern char *p_cdname(), *p_rr(), *p_type(), *p_class();
+include/netinet/ip_var.h:struct mbuf *ip_srcroute();
+include/netinet/if_ether.h:struct arptab *arptnew();
+include/netinet/if_ether.h:char *ether_sprintf();
+include/netinet/in_pcb.h:struct inpcb *in_pcblookup();
+include/netinet/in.h:u_short ntohs(), htons();
+include/netinet/in.h:u_long ntohl(), htonl();
+include/netinet/in.h:struct in_addr in_makeaddr();
+include/netinet/in.h:u_long in_netof(), in_lnaof();
+include/netinet/in_systm.h:n_time iptime();
+include/netinet/in_var.h:struct in_ifaddr *in_iaonnetof();
+include/netinet/tcp_var.h:struct tcpiphdr *tcp_template();
+include/netinet/tcp_var.h:struct tcpcb *tcp_close(), *tcp_drop();
+include/netinet/tcp_var.h:struct tcpcb *tcp_timers(), *tcp_disconnect(), *tcp_usrclosed();
+include/vaxif/if_uba.h:struct mbuf *if_ubaget();
+include/ndbm.h:DBM *dbm_open();
+include/ndbm.h:void dbm_close();
+include/ndbm.h:datum dbm_fetch();
+include/ndbm.h:datum dbm_firstkey();
+include/ndbm.h:datum dbm_nextkey();
+include/ndbm.h:long dbm_forder();
+include/ndbm.h:int dbm_delete();
+include/ndbm.h:int dbm_store();
+include/stand/saio.h: int (*dv_strategy)();
+include/stand/saio.h: int (*dv_open)();
+include/stand/saio.h: int (*dv_close)();
+include/stand/saio.h: int (*dv_ioctl)();
+include/signal.h:int (*signal())();
+include/signal.h: int (*sv_handler)(); /* signal handler */
+include/sys/proc.h:struct proc *pfind();
+include/sys/tty.h: int (*t_oproc)(); /* device */
+include/sys/buf.h: int (*b_iodone)(); /* function called by iodone */
+include/sys/buf.h:struct buf *alloc();
+include/sys/buf.h:struct buf *realloccg();
+include/sys/buf.h:struct buf *baddr();
+include/sys/buf.h:struct buf *getblk();
+include/sys/buf.h:struct buf *geteblk();
+include/sys/buf.h:struct buf *getnewbuf();
+include/sys/buf.h:struct buf *bread();
+include/sys/buf.h:struct buf *breada();
+include/sys/buf.h:unsigned minphys();
+include/sys/buf.h: int x = splbio(); \
+include/sys/quota.h:struct quota *getquota(), *qfind();
+include/sys/quota.h:struct dquot *discquota(), *inoquota(), *dqalloc(), *dqp();
+include/sys/conf.h: int (*d_open)();
+include/sys/conf.h: int (*d_close)();
+include/sys/conf.h: int (*d_strategy)();
+include/sys/conf.h: int (*d_dump)();
+include/sys/conf.h: int (*d_psize)();
+include/sys/conf.h: int (*d_open)();
+include/sys/conf.h: int (*d_close)();
+include/sys/conf.h: int (*d_read)();
+include/sys/conf.h: int (*d_write)();
+include/sys/conf.h: int (*d_ioctl)();
+include/sys/conf.h: int (*d_stop)();
+include/sys/conf.h: int (*d_reset)();
+include/sys/conf.h: int (*d_select)();
+include/sys/conf.h: int (*d_mmap)();
+include/sys/conf.h: int (*l_open)();
+include/sys/conf.h: int (*l_close)();
+include/sys/conf.h: int (*l_read)();
+include/sys/conf.h: int (*l_write)();
+include/sys/conf.h: int (*l_ioctl)();
+include/sys/conf.h: int (*l_rint)();
+include/sys/conf.h: int (*l_rend)();
+include/sys/conf.h: int (*l_meta)();
+include/sys/conf.h: int (*l_start)();
+include/sys/conf.h: int (*l_modem)();
+include/sys/socketvar.h:struct socket *sonewconn();
+include/sys/user.h: int (*u_signal[NSIG])(); /* disposition of signals */
+include/sys/systm.h:daddr_t bmap();
+include/sys/systm.h:caddr_t calloc();
+include/sys/systm.h:int memall();
+include/sys/systm.h:int vmemall();
+include/sys/systm.h:caddr_t wmemall();
+include/sys/systm.h:swblk_t vtod();
+include/sys/systm.h: int (*sy_call)(); /* handler */
+include/sys/domain.h: int (*dom_init)(); /* initialize domain data structures */
+include/sys/domain.h: int (*dom_externalize)(); /* externalize access rights */
+include/sys/domain.h: int (*dom_dispose)(); /* dispose of internalized rights */
+include/sys/protosw.h: int (*pr_input)(); /* input to protocol (from below) */
+include/sys/protosw.h: int (*pr_output)(); /* output to protocol (from above) */
+include/sys/protosw.h: int (*pr_ctlinput)(); /* control input (from below) */
+include/sys/protosw.h: int (*pr_ctloutput)(); /* control output (from above) */
+include/sys/protosw.h: int (*pr_usrreq)(); /* user request: see list below */
+include/sys/protosw.h: int (*pr_init)(); /* initialization hook */
+include/sys/protosw.h: int (*pr_fasttimo)(); /* fast timeout (200ms) */
+include/sys/protosw.h: int (*pr_slowtimo)(); /* slow timeout (500ms) */
+include/sys/protosw.h: int (*pr_drain)(); /* flush any excess space possible */
+include/sys/protosw.h:extern struct protosw *pffindproto(), *pffindtype();
+include/sys/un.h:int unp_discard();
+include/sys/cmap.h:struct cmap *mfind();
+include/sys/signal.h:int (*signal())();
+include/sys/signal.h: int (*sv_handler)(); /* signal handler */
+include/sys/fs.h:struct fs *getfs();
+include/sys/fs.h:struct fs *mountfs();
+include/sys/callout.h: int (*c_func)(); /* routine */
+include/sys/file.h: int (*fo_rw)();
+include/sys/file.h: int (*fo_ioctl)();
+include/sys/file.h: int (*fo_select)();
+include/sys/file.h: int (*fo_close)();
+include/sys/file.h:struct file *getf();
+include/sys/file.h:struct file *falloc();
+include/sys/kernel.h:long rmalloc();
+include/sys/kernel.h:int realitexpire();
+include/sys/vmmac.h:struct pte *vtopte();
+include/sys/dir.h:extern DIR *opendir();
+include/sys/dir.h:extern struct direct *readdir();
+include/sys/dir.h:extern long telldir();
+include/sys/dir.h:extern void seekdir();
+include/sys/dir.h:extern void closedir();
+include/sys/inode.h: cacheinvalall();
+include/sys/inode.h:struct inode *ialloc();
+include/sys/inode.h:struct inode *iget();
+include/sys/inode.h:struct inode *ifind();
+include/sys/inode.h:struct inode *owner();
+include/sys/inode.h:struct inode *maknode();
+include/sys/inode.h:struct inode *namei();
+include/sys/inode.h:ino_t dirpref();
+include/sys/mbuf.h: { int ms = splimp(); \
+include/sys/mbuf.h: { int ms = splimp(); \
+include/sys/mbuf.h: { int ms = splimp(); \
+include/sys/mbuf.h:struct mbuf *m_get(),*m_getclr(),*m_free(),*m_more(),*m_copy(),*m_pullup();
+include/sys/mbuf.h:caddr_t m_clalloc();
+include/fstab.h:struct fstab *getfsent();
+include/fstab.h:struct fstab *getfsspec();
+include/fstab.h:struct fstab *getfsfile();
+include/fstab.h:struct fstab *getfstype();
+include/fstab.h:int setfsent();
+include/fstab.h:int endfsent();
+include/mp.h:extern MINT *itom();
+include/mp.h:extern short *xalloc();
+include/disktab.h:struct disktab *getdiskbyname();
+include/strings.h:char *strcat();
+include/strings.h:char *strncat();
+include/strings.h:int strcmp();
+include/strings.h:int strncmp();
+include/strings.h:char *strcpy();
+include/strings.h:char *strncpy();
+include/strings.h:int strlen();
+include/strings.h:char *index();
+include/strings.h:char *rindex();
+include/netns/ns.h:u_short ntohs(), htons();
+include/netns/ns.h:u_long ntohl(), htonl();
+include/netns/ns.h:u_short ns_cksum();
+include/netns/ns_if.h:struct ns_ifaddr *ns_iaonnetof();
+include/netns/ns_pcb.h:struct nspcb *ns_pcblookup();
+include/netns/spp_var.h: *spp_usrclosed(), *spp_timers(), *spp_drop();
+include/time.h:extern struct tm *gmtime(), *localtime();
+include/time.h:extern char *asctime(), *ctime();
--- /dev/null
+/* gen/timezone.c */
+char *timezone __P((int zone, int dst));
+/* gen/_setjmp.c */
+/* gen/atof.c */
+double atof __P((char *s));
+/* gen/setegid.c */
+int setegid __P((int egid));
+/* gen/isatty.c */
+int isatty __P((int f));
+/* gen/strncpy.c */
+char *strncpy __P((register char *s1, register char *s2, int n));
+/* gen/errlst.c */
+/* gen/setjmp.c */
+/* gen/nlist.c */
+int nlist __P((char *name, struct nlist *list));
+/* gen/getpwent.c */
+int setpwent __P((void));
+int endpwent __P((void));
+struct passwd *getpwent __P((void));
+int setpwfile __P((char *file));
+/* gen/getenv.c */
+char *getenv __P((register char *name));
+/* gen/getgrgid.c */
+struct group *getgrgid __P((register gid));
+/* gen/signal.c */
+int (*signal __P((int s, int (*a)(void)))) __P((void));
+/* gen/usleep.c */
+int usleep __P((unsigned n));
+/* gen/ttyslot.c */
+int ttyslot __P((void));
+/* gen/setruid.c */
+int setruid __P((int ruid));
+/* gen/seekdir.c */
+void seekdir __P((register DIR *dirp, long loc));
+/* gen/fakcu.c */
+int _cleanup __P((void));
+/* gen/setrgid.c */
+int setrgid __P((int rgid));
+/* gen/random.c */
+int srandom __P((unsigned x));
+char *initstate __P((unsigned seed, char *arg_state, int n));
+char *setstate __P((char *arg_state));
+long random __P((void));
+/* gen/setgid.c */
+int setgid __P((int gid));
+/* gen/swab.c */
+int swab __P((register char *from, register char *to, register int n));
+/* gen/getpwnamuid.c */
+struct passwd *getpwnam __P((char *nam));
+struct passwd *getpwuid __P((int uid));
+/* gen/mktemp.c */
+char *mktemp __P((char *as));
+/* gen/udiv.c */
+/* gen/fabs.c */
+/* gen/index.c */
+char *index __P((register char *sp, int c));
+/* gen/getttyent.c */
+int setttyent __P((void));
+int endttyent __P((void));
+struct ttyent *getttyent __P((void));
+/* gen/ndbm.c */
+DBM *dbm_open __P((char *file, int flags, int mode));
+void dbm_close __P((DBM *db));
+long dbm_forder __P((register DBM *db, datum key));
+datum dbm_fetch __P((register DBM *db, datum key));
+int dbm_delete __P((register DBM *db, datum key));
+int dbm_store __P((register DBM *db, datum key, datum dat, int replace));
+datum dbm_firstkey __P((DBM *db));
+datum dbm_nextkey __P((register DBM *db));
+/* gen/valloc.c */
+char *valloc __P((int i));
+/* gen/frexp.c */
+double frexp __P((double x, int *i));
+/* gen/ecvt.c */
+char *ecvt __P((double arg, int ndigits, int *decpt, int *sign));
+char *fcvt __P((double arg, int ndigits, int *decpt, int *sign));
+/* gen/setjmperr.c */
+int longjmperror __P((void));
+/* gen/scandir.c */
+int scandir __P((char *dirname, struct direct *(*namelist[]), int (*select)(void), int (*dcomp)(void)));
+int alphasort __P((struct direct **d1, struct direct **d2));
+/* gen/psignal.c */
+int psignal __P((unsigned sig, char *s));
+/* gen/system.c */
+int system __P((char *s));
+/* gen/alloca.c */
+/* gen/disktab.c */
+struct disktab *getdiskbyname __P((char *name));
+/* gen/getwd.c */
+char *getwd __P((char *pathname));
+/* gen/bcopy.c */
+int bcopy __P((register char *src, register char *dst, register int length));
+/* gen/seteuid.c */
+int seteuid __P((int euid));
+/* gen/ualarm.c */
+unsigned ualarm __P((register unsigned usecs, register unsigned reload));
+/* gen/calloc.c */
+char *calloc __P((register unsigned num, register unsigned size));
+int cfree __P((char *p, unsigned num, unsigned size));
+/* gen/getlogin.c */
+char *getlogin __P((void));
+/* gen/ctype_.c */
+/* gen/urem.c */
+/* gen/syslog.c */
+int syslog __P((int pri, char *fmt, int p0, int p1, int p2, int p3, int p4));
+int openlog __P((char *ident, int logstat, int logfac));
+int closelog __P((void));
+int setlogmask __P((int pmask));
+/* gen/modf.c */
+double modf __P((double v, double *p));
+/* gen/getttynam.c */
+struct ttyent *getttynam __P((char *tty));
+/* gen/closedir.c */
+void closedir __P((register DIR *dirp));
+/* gen/ctime.c */
+char *ctime __P((time_t *t));
+struct tm *localtime __P((time_t *tim));
+struct tm *gmtime __P((time_t *tim));
+char *asctime __P((struct tm *t));
+int dysize __P((int y));
+/* gen/initgroups.c */
+int initgroups __P((char *uname, int agroup));
+/* gen/siglist.c */
+/* gen/ldexp.c */
+double ldexp __P((double v, int e));
+/* gen/gcvt.c */
+char *gcvt __P((double number, int ndigit, char *buf));
+/* gen/ttyname.c */
+char *ttyname __P((int f));
+/* gen/opendir.c */
+DIR *opendir __P((char *name));
+/* gen/getusershell.c */
+char *getusershell __P((void));
+int endusershell __P((void));
+int setusershell __P((void));
+/* gen/abort.c */
+int abort __P((void));
+/* gen/atoi.c */
+int atoi __P((register char *p));
+/* gen/malloc.c */
+char *malloc __P((unsigned nbytes));
+int morecore __P((int bucket));
+int free __P((char *cp));
+char *realloc __P((char *cp, unsigned nbytes));
+int mstats __P((char *s));
+/* gen/strcmp.c */
+int strcmp __P((register char *s1, register char *s2));
+/* gen/fstab.c */
+int setfsent __P((void));
+int endfsent __P((void));
+struct fstab *getfsent __P((void));
+struct fstab *getfsspec __P((char *name));
+struct fstab *getfsfile __P((char *name));
+struct fstab *getfstype __P((char *type));
+/* gen/ffs.c */
+int ffs __P((register long mask));
+/* gen/getpass.c */
+char *getpass __P((char *prompt));
+/* gen/crypt.c */
+int setkey __P((char *key));
+int encrypt __P((char *block, int edflag));
+char *crypt __P((char *pw, char *salt));
+/* gen/nargs.c */
+/* gen/strcpy.c */
+char *strcpy __P((register char *s1, register char *s2));
+/* gen/bcmp.c */
+int bcmp __P((register char *b1, register char *b2, register int length));
+/* gen/setuid.c */
+int setuid __P((int uid));
+/* gen/strcat.c */
+char *strcat __P((register char *s1, register char *s2));
+/* gen/qsort.c */
+int qsort __P((char *base, int n, int size, int (*compar)(void)));
+/* gen/siginterrupt.c */
+int siginterrupt __P((int sig, int flag));
+/* gen/alarm.c */
+int alarm __P((int secs));
+/* gen/atol.c */
+long atol __P((register char *p));
+/* gen/telldir.c */
+long telldir __P((DIR *dirp));
+/* gen/getgrnam.c */
+struct group *getgrnam __P((register char *name));
+/* gen/getgrent.c */
+int setgrent __P((void));
+int endgrent __P((void));
+struct group *getgrent __P((void));
+/* gen/readdir.c */
+struct direct *readdir __P((register DIR *dirp));
+/* gen/abs.c */
+int abs __P((int i));
+/* gen/rindex.c */
+char *rindex __P((register char *sp, int c));
+/* gen/strlen.c */
+int strlen __P((register char *s));
+/* gen/execvp.c */
+int execlp __P((char *name, char *argv));
+int execvp __P((char *name, char **argv));
+/* gen/popen.c */
+FILE *popen __P((char *cmd, char *mode));
+int pclose __P((FILE *ptr));
+/* gen/strncat.c */
+char *strncat __P((register char *s1, register char *s2, register n));
+/* gen/remque.c */
+int remque __P((register struct vaxque *e));
+/* gen/insque.c */
+int insque __P((register struct vaxque *e, register struct vaxque *prev));
+/* gen/perror.c */
+int perror __P((char *s));
+/* gen/regex.c */
+char *re_comp __P((register char *sp));
+int re_exec __P((register char *p1));
+int backref __P((register int i, register char *lp));
+int cclass __P((register char *set, int c, int af));
+/* gen/mkstemp.c */
+int mkstemp __P((char *as));
+/* gen/sleep.c */
+int sleep __P((unsigned n));
+/* gen/bzero.c */
+int bzero __P((register char *b, register int length));
+/* gen/time.c */
+long time __P((time_t *t));
+/* gen/strncmp.c */
+int strncmp __P((register char *s1, register char *s2, register n));
--- /dev/null
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 5.7 (Berkeley) 3/26/86
+#
+# Several routines have been rewritten in assembly language for the VAX.
+# If you are not running on a VAX, you should use the original C sources
+# which are included in this directory. Regretably we do not have a C
+# version of the bstring(3) routines.
+#
+#ifndef vax
+#SRCS= ${STDSRC} ${VAXSRC}
+#OBJS= ${STDOBJ} ${VAXOBJ}
+#else
+SRCS= ${STDSRC}
+OBJS= ${STDOBJ}
+#endif not vax
+
+CFLAGS= -O ${DEFS}
+STDSRC= abort.c alarm.c atoi.c atol.c calloc.c closedir.c crypt.c \
+ ctime.c ctype_.c errlst.c execvp.c fakcu.c fstab.c gcvt.c getenv.c \
+ getgrent.c getgrgid.c getgrnam.c getlogin.c getpass.c getpwent.c \
+ getpwnamuid.c getttyent.c getttynam.c getusershell.c getwd.c \
+ initgroups.c isatty.c malloc.c mkstemp.c mktemp.c ndbm.c nlist.c \
+ opendir.c perror.c popen.c psignal.c qsort.c random.c readdir.c \
+ regex.c scandir.c seekdir.c setgid.c setegid.c setrgid.c setuid.c \
+ seteuid.c setruid.c siglist.c signal.c siginterrupt.c sleep.c \
+ swab.c syslog.c system.c telldir.c time.c timezone.c ttyname.c \
+ ttyslot.c ualarm.c usleep.c valloc.c
+VAXSRC= index.c rindex.c strcat.c strcmp.c strcpy.c strlen.c \
+ strncat.c strncmp.c strncpy.c
+STDOBJ= abort.o alarm.o atoi.o atol.o calloc.o closedir.o crypt.o \
+ ctime.o ctype_.o errlst.o execvp.o fakcu.o fstab.o gcvt.o getenv.o \
+ getgrent.o getgrgid.o getgrnam.o getlogin.o getpass.o getpwent.o \
+ getpwnamuid.o getttyent.o getttynam.o getusershell.o getwd.o \
+ initgroups.o isatty.o malloc.o mkstemp.o mktemp.o ndbm.o nlist.o \
+ opendir.o perror.o popen.o psignal.o qsort.o random.o readdir.o \
+ regex.o scandir.o seekdir.o setgid.o setegid.o setrgid.o setuid.o \
+ seteuid.o setruid.o siglist.o signal.o siginterrupt.o sleep.o \
+ swab.o syslog.o system.o telldir.o time.o timezone.o ttyname.o \
+ ttyslot.o ualarm.o usleep.o valloc.o
+VAXOBJ= index.o rindex.o strcat.o strcmp.o strcpy.o strlen.o \
+ strncat.o strncmp.o strncpy.o
+TAGSFILE=tags
+
+.c.o:
+ ${CC} -p ${CFLAGS} -c $*.c
+ -ld -X -r $*.o
+ mv a.out profiled/$*.o
+ ${CC} ${CFLAGS} -c $*.c
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+genlib genlib_p: ${OBJS}
+ @echo "building profiled genlib"
+ @cd profiled; ar cru ../genlib_p ${OBJS}
+ @echo "buiding normal genlib"
+ @ar cru genlib ${OBJS}
+
+errlst.o: errlst.c
+ cc -S ${DEFS} errlst.c
+ ed - <:errfix errlst.s
+ as -o errlst.o errlst.s
+ cp errlst.o profiled/errlst.o
+ rm errlst.s
+
+tags:
+ cwd=`pwd`; \
+ for i in ${SRCS}; do \
+ ctags -a -f ${TAGSFILE} $$cwd/$$i; \
+ done
+
+clean:
+ rm -f genlib genlib_p *.o profiled/*.o tags Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+abort.o: abort.c /usr/include/signal.h
+alarm.o: alarm.c /usr/include/sys/time.h /usr/include/time.h
+atoi.o: atoi.c
+atol.o: atol.c
+calloc.o: calloc.c
+closedir.o: closedir.c /usr/include/sys/param.h
+closedir.o: /usr/include/machine/machparam.h /usr/include/signal.h
+closedir.o: /usr/include/sys/types.h /usr/include/sys/dir.h
+crypt.o: crypt.c
+ctime.o: ctime.c /usr/include/sys/time.h /usr/include/time.h
+ctime.o: /usr/include/sys/types.h /usr/include/sys/timeb.h
+ctype_.o: ctype_.c /usr/include/ctype.h
+errlst.o: errlst.c
+execvp.o: execvp.c /usr/include/errno.h
+fakcu.o: fakcu.c
+fstab.o: fstab.c /usr/include/fstab.h /usr/include/stdio.h /usr/include/ctype.h
+gcvt.o: gcvt.c
+getenv.o: getenv.c
+getgrent.o: getgrent.c /usr/include/stdio.h /usr/include/grp.h
+getgrgid.o: getgrgid.c /usr/include/grp.h
+getgrnam.o: getgrnam.c /usr/include/grp.h
+getlogin.o: getlogin.c /usr/include/utmp.h
+getpass.o: getpass.c /usr/include/stdio.h /usr/include/signal.h
+getpass.o: /usr/include/sgtty.h /usr/include/sys/ioctl.h
+getpass.o: /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h
+getpwent.o: getpwent.c /usr/include/stdio.h /usr/include/pwd.h
+getpwent.o: /usr/include/ndbm.h
+getpwnamuid.o: getpwnamuid.c /usr/include/stdio.h /usr/include/pwd.h
+getpwnamuid.o: /usr/include/ndbm.h /usr/include/sys/file.h
+getttyent.o: getttyent.c /usr/include/stdio.h /usr/include/strings.h
+getttyent.o: /usr/include/ttyent.h
+getttynam.o: getttynam.c /usr/include/ttyent.h
+getusershell.o: getusershell.c /usr/include/sys/param.h
+getusershell.o: /usr/include/machine/machparam.h /usr/include/signal.h
+getusershell.o: /usr/include/sys/types.h /usr/include/sys/file.h
+getusershell.o: /usr/include/sys/stat.h /usr/include/ctype.h
+getusershell.o: /usr/include/stdio.h
+getwd.o: getwd.c /usr/include/sys/param.h /usr/include/machine/machparam.h
+getwd.o: /usr/include/signal.h /usr/include/sys/types.h /usr/include/sys/stat.h
+getwd.o: /usr/include/sys/dir.h
+initgroups.o: initgroups.c /usr/include/stdio.h /usr/include/sys/param.h
+initgroups.o: /usr/include/machine/machparam.h /usr/include/signal.h
+initgroups.o: /usr/include/sys/types.h /usr/include/grp.h
+isatty.o: isatty.c /usr/include/sgtty.h /usr/include/sys/ioctl.h
+isatty.o: /usr/include/sys/ttychars.h /usr/include/sys/ttydev.h
+malloc.o: malloc.c /usr/include/sys/types.h
+mkstemp.o: mkstemp.c /usr/include/sys/file.h
+mktemp.o: mktemp.c
+ndbm.o: ndbm.c /usr/include/sys/types.h /usr/include/sys/stat.h
+ndbm.o: /usr/include/sys/file.h /usr/include/stdio.h /usr/include/errno.h
+ndbm.o: /usr/include/ndbm.h
+nlist.o: nlist.c /usr/include/sys/types.h /usr/include/a.out.h
+nlist.o: /usr/include/sys/exec.h /usr/include/stdio.h
+opendir.o: opendir.c /usr/include/sys/param.h /usr/include/machine/machparam.h
+opendir.o: /usr/include/signal.h /usr/include/sys/types.h
+opendir.o: /usr/include/sys/dir.h
+perror.o: perror.c /usr/include/sys/types.h /usr/include/sys/uio.h
+popen.o: popen.c /usr/include/stdio.h /usr/include/signal.h
+psignal.o: psignal.c /usr/include/signal.h
+qsort.o: qsort.c
+random.o: random.c /usr/include/stdio.h
+readdir.o: readdir.c /usr/include/sys/param.h /usr/include/machine/machparam.h
+readdir.o: /usr/include/signal.h /usr/include/sys/types.h
+readdir.o: /usr/include/sys/dir.h
+regex.o: regex.c
+scandir.o: scandir.c /usr/include/sys/types.h /usr/include/sys/stat.h
+scandir.o: /usr/include/sys/dir.h
+seekdir.o: seekdir.c /usr/include/sys/param.h /usr/include/machine/machparam.h
+seekdir.o: /usr/include/signal.h /usr/include/sys/types.h
+seekdir.o: /usr/include/sys/dir.h
+setgid.o: setgid.c
+setegid.o: setegid.c
+setrgid.o: setrgid.c
+setuid.o: setuid.c
+seteuid.o: seteuid.c
+setruid.o: setruid.c
+siglist.o: siglist.c /usr/include/signal.h
+signal.o: signal.c /usr/include/signal.h
+siginterrupt.o: siginterrupt.c /usr/include/signal.h
+sleep.o: sleep.c /usr/include/sys/time.h /usr/include/time.h
+sleep.o: /usr/include/signal.h
+swab.o: swab.c
+syslog.o: syslog.c /usr/include/sys/types.h /usr/include/sys/socket.h
+syslog.o: /usr/include/sys/file.h /usr/include/sys/signal.h
+syslog.o: /usr/include/sys/syslog.h /usr/include/netdb.h /usr/include/strings.h
+system.o: system.c /usr/include/signal.h
+telldir.o: telldir.c /usr/include/sys/param.h /usr/include/machine/machparam.h
+telldir.o: /usr/include/signal.h /usr/include/sys/types.h
+telldir.o: /usr/include/sys/dir.h
+time.o: time.c /usr/include/sys/types.h /usr/include/sys/time.h
+time.o: /usr/include/time.h
+timezone.o: timezone.c
+ttyname.o: ttyname.c /usr/include/sys/param.h /usr/include/machine/machparam.h
+ttyname.o: /usr/include/signal.h /usr/include/sys/types.h
+ttyname.o: /usr/include/sys/dir.h /usr/include/sys/stat.h
+ttyslot.o: ttyslot.c /usr/include/ttyent.h
+ualarm.o: ualarm.c /usr/include/sys/time.h /usr/include/time.h
+usleep.o: usleep.c /usr/include/sys/time.h /usr/include/time.h
+usleep.o: /usr/include/signal.h
+valloc.o: valloc.c
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+#include "gen.h"
+int _setjmp(e) jmp_buf e; {
+ abort();
+}
+void _longjmp(e, v) jmp_buf e; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)abort.c 5.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/* C library -- abort */
+
+#include "signal.h"
+
+abort()
+{
+ sigblock(~0);
+ signal(SIGILL, SIG_DFL);
+ sigsetmask(~sigmask(SIGILL));
+ kill(getpid(), SIGILL);
+}
--- /dev/null
+#include "gen.h"
+int abs(i) int i; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)alarm.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Backwards compatible alarm.
+ */
+#include <sys/time.h>
+
+alarm(secs)
+ int secs;
+{
+ struct itimerval it, oitv;
+ register struct itimerval *itp = ⁢
+
+ timerclear(&itp->it_interval);
+ itp->it_value.tv_sec = secs;
+ itp->it_value.tv_usec = 0;
+ if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
+ return (-1);
+ if (oitv.it_value.tv_usec)
+ oitv.it_value.tv_sec++;
+ return (oitv.it_value.tv_sec);
+}
--- /dev/null
+#include "gen.h"
+double atof(s) char *s; {
+ abort();
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)atoi.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+atoi(p)
+register char *p;
+{
+ register int n;
+ register int f;
+
+ n = 0;
+ f = 0;
+ for(;;p++) {
+ switch(*p) {
+ case ' ':
+ case '\t':
+ continue;
+ case '-':
+ f++;
+ case '+':
+ p++;
+ }
+ break;
+ }
+ while(*p >= '0' && *p <= '9')
+ n = n*10 + *p++ - '0';
+ return(f? -n: n);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)atol.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+long
+atol(p)
+register char *p;
+{
+ long n;
+ register int f;
+
+ n = 0;
+ f = 0;
+ for(;;p++) {
+ switch(*p) {
+ case ' ':
+ case '\t':
+ continue;
+ case '-':
+ f++;
+ case '+':
+ p++;
+ }
+ break;
+ }
+ while(*p >= '0' && *p <= '9')
+ n = n*10 + *p++ - '0';
+ return(f? -n: n);
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bcmp.c 5.1 (Berkeley) 1/27/87";
+#endif LIBC_SCCS and not lint
+
+/*
+ * bcmp -- vax cmpc3 instruction
+ */
+bcmp(b1, b2, length)
+ register char *b1, *b2;
+ register int length;
+{
+
+ if (length == 0)
+ return (0);
+ do
+ if (*b1++ != *b2++)
+ break;
+ while (--length);
+ return(length);
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bcopy.c 5.1 (Berkeley) 1/27/87";
+#endif LIBC_SCCS and not lint
+
+/*
+ * bcopy -- vax movc3 instruction
+ */
+bcopy(src, dst, length)
+ register char *src, *dst;
+ register int length;
+{
+ if (length && src != dst)
+ if ((u_int)dst < (u_int)src)
+ if (((int)src | (int)dst | length) & 3)
+ do /* copy by bytes */
+ *dst++ = *src++;
+ while (--length);
+ else {
+ length >>= 2;
+ do /* copy by longs */
+ *((long *)dst)++ = *((long *)src)++;
+ while (--length);
+ }
+ else { /* copy backwards */
+ src += length;
+ dst += length;
+ if (((int)src | (int)dst | length) & 3)
+ do /* copy by bytes */
+ *--dst = *--src;
+ while (--length);
+ else {
+ length >>= 2;
+ do /* copy by shorts */
+ *--((long *)dst) = *--((long *)src);
+ while (--length);
+ }
+ }
+ return(0);
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bzero.c 5.1 (Berkeley) 1/27/87";
+#endif LIBC_SCCS and not lint
+
+/*
+ * bzero -- vax movc5 instruction
+ */
+bzero(b, length)
+ register char *b;
+ register int length;
+{
+
+ if (length)
+ do
+ *b++ = '\0';
+ while (--length);
+ return(length);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)calloc.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Calloc - allocate and clear memory block
+ */
+char *
+calloc(num, size)
+ register unsigned num, size;
+{
+ extern char *malloc();
+ register char *p;
+
+ size *= num;
+ if (p = malloc(size))
+ bzero(p, size);
+ return (p);
+}
+
+cfree(p, num, size)
+ char *p;
+ unsigned num;
+ unsigned size;
+{
+ free(p);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)closedir.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/param.h>
+#include <sys/dir.h>
+
+/*
+ * close a directory.
+ */
+void
+closedir(dirp)
+ register DIR *dirp;
+{
+ close(dirp->dd_fd);
+ dirp->dd_fd = -1;
+ dirp->dd_loc = 0;
+ free(dirp);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)crypt.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * This program implements the
+ * Proposed Federal Information Processing
+ * Data Encryption Standard.
+ * See Federal Register, March 17, 1975 (40FR12134)
+ */
+
+/*
+ * Initial permutation,
+ */
+static char IP[] = {
+ 58,50,42,34,26,18,10, 2,
+ 60,52,44,36,28,20,12, 4,
+ 62,54,46,38,30,22,14, 6,
+ 64,56,48,40,32,24,16, 8,
+ 57,49,41,33,25,17, 9, 1,
+ 59,51,43,35,27,19,11, 3,
+ 61,53,45,37,29,21,13, 5,
+ 63,55,47,39,31,23,15, 7,
+};
+
+/*
+ * Final permutation, FP = IP^(-1)
+ */
+static char FP[] = {
+ 40, 8,48,16,56,24,64,32,
+ 39, 7,47,15,55,23,63,31,
+ 38, 6,46,14,54,22,62,30,
+ 37, 5,45,13,53,21,61,29,
+ 36, 4,44,12,52,20,60,28,
+ 35, 3,43,11,51,19,59,27,
+ 34, 2,42,10,50,18,58,26,
+ 33, 1,41, 9,49,17,57,25,
+};
+
+/*
+ * Permuted-choice 1 from the key bits
+ * to yield C and D.
+ * Note that bits 8,16... are left out:
+ * They are intended for a parity check.
+ */
+static char PC1_C[] = {
+ 57,49,41,33,25,17, 9,
+ 1,58,50,42,34,26,18,
+ 10, 2,59,51,43,35,27,
+ 19,11, 3,60,52,44,36,
+};
+
+static char PC1_D[] = {
+ 63,55,47,39,31,23,15,
+ 7,62,54,46,38,30,22,
+ 14, 6,61,53,45,37,29,
+ 21,13, 5,28,20,12, 4,
+};
+
+/*
+ * Sequence of shifts used for the key schedule.
+*/
+static char shifts[] = {
+ 1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1,
+};
+
+/*
+ * Permuted-choice 2, to pick out the bits from
+ * the CD array that generate the key schedule.
+ */
+static char PC2_C[] = {
+ 14,17,11,24, 1, 5,
+ 3,28,15, 6,21,10,
+ 23,19,12, 4,26, 8,
+ 16, 7,27,20,13, 2,
+};
+
+static char PC2_D[] = {
+ 41,52,31,37,47,55,
+ 30,40,51,45,33,48,
+ 44,49,39,56,34,53,
+ 46,42,50,36,29,32,
+};
+
+/*
+ * The C and D arrays used to calculate the key schedule.
+ */
+
+static char C[28];
+static char D[28];
+/*
+ * The key schedule.
+ * Generated from the key.
+ */
+static char KS[16][48];
+
+/*
+ * The E bit-selection table.
+ */
+static char E[48];
+static char e[] = {
+ 32, 1, 2, 3, 4, 5,
+ 4, 5, 6, 7, 8, 9,
+ 8, 9,10,11,12,13,
+ 12,13,14,15,16,17,
+ 16,17,18,19,20,21,
+ 20,21,22,23,24,25,
+ 24,25,26,27,28,29,
+ 28,29,30,31,32, 1,
+};
+
+/*
+ * Set up the key schedule from the key.
+ */
+
+setkey(key)
+char *key;
+{
+ register i, j, k;
+ int t;
+
+ /*
+ * First, generate C and D by permuting
+ * the key. The low order bit of each
+ * 8-bit char is not used, so C and D are only 28
+ * bits apiece.
+ */
+ for (i=0; i<28; i++) {
+ C[i] = key[PC1_C[i]-1];
+ D[i] = key[PC1_D[i]-1];
+ }
+ /*
+ * To generate Ki, rotate C and D according
+ * to schedule and pick up a permutation
+ * using PC2.
+ */
+ for (i=0; i<16; i++) {
+ /*
+ * rotate.
+ */
+ for (k=0; k<shifts[i]; k++) {
+ t = C[0];
+ for (j=0; j<28-1; j++)
+ C[j] = C[j+1];
+ C[27] = t;
+ t = D[0];
+ for (j=0; j<28-1; j++)
+ D[j] = D[j+1];
+ D[27] = t;
+ }
+ /*
+ * get Ki. Note C and D are concatenated.
+ */
+ for (j=0; j<24; j++) {
+ KS[i][j] = C[PC2_C[j]-1];
+ KS[i][j+24] = D[PC2_D[j]-28-1];
+ }
+ }
+
+ for(i=0;i<48;i++)
+ E[i] = e[i];
+}
+
+/*
+ * The 8 selection functions.
+ * For some reason, they give a 0-origin
+ * index, unlike everything else.
+ */
+static char S[8][64] = {
+ 14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7,
+ 0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8,
+ 4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0,
+ 15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13,
+
+ 15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10,
+ 3,13, 4, 7,15, 2, 8,14,12, 0, 1,10, 6, 9,11, 5,
+ 0,14, 7,11,10, 4,13, 1, 5, 8,12, 6, 9, 3, 2,15,
+ 13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9,
+
+ 10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8,
+ 13, 7, 0, 9, 3, 4, 6,10, 2, 8, 5,14,12,11,15, 1,
+ 13, 6, 4, 9, 8,15, 3, 0,11, 1, 2,12, 5,10,14, 7,
+ 1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12,
+
+ 7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15,
+ 13, 8,11, 5, 6,15, 0, 3, 4, 7, 2,12, 1,10,14, 9,
+ 10, 6, 9, 0,12,11, 7,13,15, 1, 3,14, 5, 2, 8, 4,
+ 3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14,
+
+ 2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9,
+ 14,11, 2,12, 4, 7,13, 1, 5, 0,15,10, 3, 9, 8, 6,
+ 4, 2, 1,11,10,13, 7, 8,15, 9,12, 5, 6, 3, 0,14,
+ 11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3,
+
+ 12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11,
+ 10,15, 4, 2, 7,12, 9, 5, 6, 1,13,14, 0,11, 3, 8,
+ 9,14,15, 5, 2, 8,12, 3, 7, 0, 4,10, 1,13,11, 6,
+ 4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13,
+
+ 4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1,
+ 13, 0,11, 7, 4, 9, 1,10,14, 3, 5,12, 2,15, 8, 6,
+ 1, 4,11,13,12, 3, 7,14,10,15, 6, 8, 0, 5, 9, 2,
+ 6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12,
+
+ 13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7,
+ 1,15,13, 8,10, 3, 7, 4,12, 5, 6,11, 0,14, 9, 2,
+ 7,11, 4, 1, 9,12,14, 2, 0, 6,10,13,15, 3, 5, 8,
+ 2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11,
+};
+
+/*
+ * P is a permutation on the selected combination
+ * of the current L and key.
+ */
+static char P[] = {
+ 16, 7,20,21,
+ 29,12,28,17,
+ 1,15,23,26,
+ 5,18,31,10,
+ 2, 8,24,14,
+ 32,27, 3, 9,
+ 19,13,30, 6,
+ 22,11, 4,25,
+};
+
+/*
+ * The current block, divided into 2 halves.
+ */
+static char L[32], R[32];
+static char tempL[32];
+static char f[32];
+
+/*
+ * The combination of the key and the input, before selection.
+ */
+static char preS[48];
+
+/*
+ * The payoff: encrypt a block.
+ */
+
+encrypt(block, edflag)
+char *block;
+{
+ int i, ii;
+ register t, j, k;
+
+ /*
+ * First, permute the bits in the input
+ */
+ for (j=0; j<64; j++)
+ L[j] = block[IP[j]-1];
+ /*
+ * Perform an encryption operation 16 times.
+ */
+ for (ii=0; ii<16; ii++) {
+ /*
+ * Set direction
+ */
+ if (edflag)
+ i = 15-ii;
+ else
+ i = ii;
+ /*
+ * Save the R array,
+ * which will be the new L.
+ */
+ for (j=0; j<32; j++)
+ tempL[j] = R[j];
+ /*
+ * Expand R to 48 bits using the E selector;
+ * exclusive-or with the current key bits.
+ */
+ for (j=0; j<48; j++)
+ preS[j] = R[E[j]-1] ^ KS[i][j];
+ /*
+ * The pre-select bits are now considered
+ * in 8 groups of 6 bits each.
+ * The 8 selection functions map these
+ * 6-bit quantities into 4-bit quantities
+ * and the results permuted
+ * to make an f(R, K).
+ * The indexing into the selection functions
+ * is peculiar; it could be simplified by
+ * rewriting the tables.
+ */
+ for (j=0; j<8; j++) {
+ t = 6*j;
+ k = S[j][(preS[t+0]<<5)+
+ (preS[t+1]<<3)+
+ (preS[t+2]<<2)+
+ (preS[t+3]<<1)+
+ (preS[t+4]<<0)+
+ (preS[t+5]<<4)];
+ t = 4*j;
+ f[t+0] = (k>>3)&01;
+ f[t+1] = (k>>2)&01;
+ f[t+2] = (k>>1)&01;
+ f[t+3] = (k>>0)&01;
+ }
+ /*
+ * The new R is L ^ f(R, K).
+ * The f here has to be permuted first, though.
+ */
+ for (j=0; j<32; j++)
+ R[j] = L[j] ^ f[P[j]-1];
+ /*
+ * Finally, the new L (the original R)
+ * is copied back.
+ */
+ for (j=0; j<32; j++)
+ L[j] = tempL[j];
+ }
+ /*
+ * The output L and R are reversed.
+ */
+ for (j=0; j<32; j++) {
+ t = L[j];
+ L[j] = R[j];
+ R[j] = t;
+ }
+ /*
+ * The final output
+ * gets the inverse permutation of the very original.
+ */
+ for (j=0; j<64; j++)
+ block[j] = L[FP[j]-1];
+}
+
+char *
+crypt(pw,salt)
+char *pw;
+char *salt;
+{
+ register i, j, c;
+ int temp;
+ static char block[66], iobuf[16];
+
+ for(i=0; i<66; i++)
+ block[i] = 0;
+ for(i=0; (c= *pw) && i<64; pw++){
+ for(j=0; j<7; j++, i++)
+ block[i] = (c>>(6-j)) & 01;
+ i++;
+ }
+
+ setkey(block);
+
+ for(i=0; i<66; i++)
+ block[i] = 0;
+
+ for(i=0;i<2;i++){
+ c = *salt++;
+ iobuf[i] = c;
+ if(c>'Z') c -= 6;
+ if(c>'9') c -= 7;
+ c -= '.';
+ for(j=0;j<6;j++){
+ if((c>>j) & 01){
+ temp = E[6*i+j];
+ E[6*i+j] = E[6*i+j+24];
+ E[6*i+j+24] = temp;
+ }
+ }
+ }
+
+ for(i=0; i<25; i++)
+ encrypt(block,0);
+
+ for(i=0; i<11; i++){
+ c = 0;
+ for(j=0; j<6; j++){
+ c <<= 1;
+ c |= block[6*i+j];
+ }
+ c += '.';
+ if(c>'9') c += 7;
+ if(c>'Z') c += 6;
+ iobuf[i+2] = c;
+ }
+ iobuf[i+2] = 0;
+ if(iobuf[1]==0)
+ iobuf[1] = iobuf[0];
+ return(iobuf);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ctime.c 5.5 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * This routine converts time as follows.
+ * The epoch is 0000 Jan 1 1970 GMT.
+ * The argument time is in seconds since then.
+ * The localtime(t) entry returns a pointer to an array
+ * containing
+ * seconds (0-59)
+ * minutes (0-59)
+ * hours (0-23)
+ * day of month (1-31)
+ * month (0-11)
+ * year-1970
+ * weekday (0-6, Sun is 0)
+ * day of the year
+ * daylight savings flag
+ *
+ * The routine calls the system to determine the local
+ * timezone and whether Daylight Saving Time is permitted locally.
+ * (DST is then determined by the current local rules)
+ *
+ * The routine does not work
+ * in Saudi Arabia which runs on Solar time.
+ *
+ * asctime(tvec))
+ * where tvec is produced by localtime
+ * returns a ptr to a character string
+ * that has the ascii time in the form
+ * Thu Jan 01 00:00:00 1970\n\0
+ * 0123456789012345678901234 5
+ * 0 1 2
+ *
+ * ctime(t) just calls localtime, then asctime.
+ */
+
+#include <sys/time.h>
+#include <sys/types.h>
+#include <sys/timeb.h>
+
+static char cbuf[26];
+static int dmsize[12] =
+{
+ 31,
+ 28,
+ 31,
+ 30,
+ 31,
+ 30,
+ 31,
+ 31,
+ 30,
+ 31,
+ 30,
+ 31
+};
+
+/*
+ * The following table is used for 1974 and 1975 and
+ * gives the day number of the first day after the Sunday of the
+ * change.
+ */
+struct dstab {
+ int dayyr;
+ int daylb;
+ int dayle;
+};
+
+static struct dstab usdaytab[] = {
+ 1974, 5, 333, /* 1974: Jan 6 - last Sun. in Nov */
+ 1975, 58, 303, /* 1975: Last Sun. in Feb - last Sun in Oct */
+ 0, 119, 303, /* all other years: end Apr - end Oct */
+};
+static struct dstab ausdaytab[] = {
+ 1970, 400, 0, /* 1970: no daylight saving at all */
+ 1971, 303, 0, /* 1971: daylight saving from Oct 31 */
+ 1972, 303, 58, /* 1972: Jan 1 -> Feb 27 & Oct 31 -> dec 31 */
+ 0, 303, 65, /* others: -> Mar 7, Oct 31 -> */
+};
+
+/*
+ * The European tables ... based on hearsay
+ * Believed correct for:
+ * WE: Great Britain, Portugal?
+ * ME: Belgium, Luxembourg, Netherlands, Denmark, Norway,
+ * Austria, Poland, Czechoslovakia, Sweden, Switzerland,
+ * DDR, DBR, France, Spain, Hungary, Italy, Jugoslavia
+ * Finland (EE timezone, but ME dst rules)
+ * Eastern European dst is unknown, we'll make it ME until someone speaks up.
+ * EE: Bulgaria, Greece, Rumania, Turkey, Western Russia
+ *
+ * Ireland is unpredictable. (Years when Easter Sunday just happens ...)
+ * Years before 1983 are suspect.
+ */
+static struct dstab wedaytab[] = {
+ 1983, 89, 296, /* 1983: end March - end Oct */
+ 0, 89, 303, /* others: end March - end Oct */
+};
+
+static struct dstab medaytab[] = {
+ 1983, 89, 296, /* 1983: end March - end Oct */
+ 0, 89, 272, /* others: end March - end Sep */
+};
+
+/*
+ * Canada, same as the US, except no early 70's fluctuations.
+ * Can this really be right ??
+ */
+static struct dstab candaytab[] = {
+ 0, 119, 303, /* all years: end Apr - end Oct */
+};
+
+static struct dayrules {
+ int dst_type; /* number obtained from system */
+ int dst_hrs; /* hours to add when dst on */
+ struct dstab * dst_rules; /* one of the above */
+ enum {STH,NTH} dst_hemi; /* southern, northern hemisphere */
+} dayrules [] = {
+ DST_USA, 1, usdaytab, NTH,
+ DST_AUST, 1, ausdaytab, STH,
+ DST_WET, 1, wedaytab, NTH,
+ DST_MET, 1, medaytab, NTH,
+ DST_EET, 1, medaytab, NTH, /* XXX */
+ DST_CAN, 1, candaytab, NTH,
+ -1,
+};
+
+struct tm *gmtime();
+char *ct_numb();
+struct tm *localtime();
+char *ctime();
+char *ct_num();
+char *asctime();
+
+char *
+ctime(t)
+time_t *t;
+{
+ return(asctime(localtime(t)));
+}
+
+struct tm *
+localtime(tim)
+time_t *tim;
+{
+ register int dayno;
+ register struct tm *ct;
+ register dalybeg, daylend;
+ register struct dayrules *dr;
+ register struct dstab *ds;
+ int year;
+ time_t copyt;
+ struct timeval curtime;
+ static struct timezone zone;
+ static int init = 0;
+
+ if (!init) {
+ gettimeofday(&curtime, &zone);
+ init++;
+ }
+ copyt = *tim - (time_t)zone.tz_minuteswest*60;
+ ct = gmtime(©t);
+ dayno = ct->tm_yday;
+ for (dr = dayrules; dr->dst_type >= 0; dr++)
+ if (dr->dst_type == zone.tz_dsttime)
+ break;
+ if (dr->dst_type >= 0) {
+ year = ct->tm_year + 1900;
+ for (ds = dr->dst_rules; ds->dayyr; ds++)
+ if (ds->dayyr == year)
+ break;
+ dalybeg = ds->daylb; /* first Sun after dst starts */
+ daylend = ds->dayle; /* first Sun after dst ends */
+ dalybeg = sunday(ct, dalybeg);
+ daylend = sunday(ct, daylend);
+ switch (dr->dst_hemi) {
+ case NTH:
+ if (!(
+ (dayno>dalybeg || (dayno==dalybeg && ct->tm_hour>=2)) &&
+ (dayno<daylend || (dayno==daylend && ct->tm_hour<1))
+ ))
+ return(ct);
+ break;
+ case STH:
+ if (!(
+ (dayno>dalybeg || (dayno==dalybeg && ct->tm_hour>=2)) ||
+ (dayno<daylend || (dayno==daylend && ct->tm_hour<2))
+ ))
+ return(ct);
+ break;
+ default:
+ return(ct);
+ }
+ copyt += dr->dst_hrs*60*60;
+ ct = gmtime(©t);
+ ct->tm_isdst++;
+ }
+ return(ct);
+}
+
+/*
+ * The argument is a 0-origin day number.
+ * The value is the day number of the last
+ * Sunday on or before the day.
+ */
+static
+sunday(t, d)
+register struct tm *t;
+register int d;
+{
+ if (d >= 58)
+ d += dysize(t->tm_year) - 365;
+ return(d - (d - t->tm_yday + t->tm_wday + 700) % 7);
+}
+
+struct tm *
+gmtime(tim)
+time_t *tim;
+{
+ register int d0, d1;
+ long hms, day;
+ register int *tp;
+ static struct tm xtime;
+
+ /*
+ * break initial number into days
+ */
+ hms = *tim % 86400;
+ day = *tim / 86400;
+ if (hms<0) {
+ hms += 86400;
+ day -= 1;
+ }
+ tp = (int *)&xtime;
+
+ /*
+ * generate hours:minutes:seconds
+ */
+ *tp++ = hms%60;
+ d1 = hms/60;
+ *tp++ = d1%60;
+ d1 /= 60;
+ *tp++ = d1;
+
+ /*
+ * day is the day number.
+ * generate day of the week.
+ * The addend is 4 mod 7 (1/1/1970 was Thursday)
+ */
+
+ xtime.tm_wday = (day+7340036)%7;
+
+ /*
+ * year number
+ */
+ if (day>=0) for(d1=70; day >= dysize(d1); d1++)
+ day -= dysize(d1);
+ else for (d1=70; day<0; d1--)
+ day += dysize(d1-1);
+ xtime.tm_year = d1;
+ xtime.tm_yday = d0 = day;
+
+ /*
+ * generate month
+ */
+
+ if (dysize(d1)==366)
+ dmsize[1] = 29;
+ for(d1=0; d0 >= dmsize[d1]; d1++)
+ d0 -= dmsize[d1];
+ dmsize[1] = 28;
+ *tp++ = d0+1;
+ *tp++ = d1;
+ xtime.tm_isdst = 0;
+ return(&xtime);
+}
+
+char *
+asctime(t)
+struct tm *t;
+{
+ register char *cp, *ncp;
+ register int *tp;
+
+ cp = cbuf;
+ for (ncp = "Day Mon 00 00:00:00 1900\n"; *cp++ = *ncp++;);
+ ncp = &"SunMonTueWedThuFriSat"[3*t->tm_wday];
+ cp = cbuf;
+ *cp++ = *ncp++;
+ *cp++ = *ncp++;
+ *cp++ = *ncp++;
+ cp++;
+ tp = &t->tm_mon;
+ ncp = &"JanFebMarAprMayJunJulAugSepOctNovDec"[(*tp)*3];
+ *cp++ = *ncp++;
+ *cp++ = *ncp++;
+ *cp++ = *ncp++;
+ cp = ct_numb(cp, *--tp);
+ cp = ct_numb(cp, *--tp+100);
+ cp = ct_numb(cp, *--tp+100);
+ cp = ct_numb(cp, *--tp+100);
+ if (t->tm_year>=100) {
+ cp[1] = '2';
+ cp[2] = '0' + (t->tm_year-100) / 100;
+ }
+ cp += 2;
+ cp = ct_numb(cp, t->tm_year+100);
+ return(cbuf);
+}
+
+dysize(y)
+{
+ if((y%4) == 0)
+ return(366);
+ return(365);
+}
+
+static char *
+ct_numb(cp, n)
+register char *cp;
+{
+ cp++;
+ if (n>=10)
+ *cp++ = (n/10)%10 + '0';
+ else
+ *cp++ = ' ';
+ *cp++ = n%10 + '0';
+ return(cp);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ctype_.c 5.4 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <ctype.h>
+
+char _ctype_[1 + 256] = {
+ 0,
+ _C, _C, _C, _C, _C, _C, _C, _C,
+ _C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C,
+ _C, _C, _C, _C, _C, _C, _C, _C,
+ _C, _C, _C, _C, _C, _C, _C, _C,
+ _S|_B, _P, _P, _P, _P, _P, _P, _P,
+ _P, _P, _P, _P, _P, _P, _P, _P,
+ _N, _N, _N, _N, _N, _N, _N, _N,
+ _N, _N, _P, _P, _P, _P, _P, _P,
+ _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U,
+ _U, _U, _U, _U, _U, _U, _U, _U,
+ _U, _U, _U, _U, _U, _U, _U, _U,
+ _U, _U, _U, _P, _P, _P, _P, _P,
+ _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L,
+ _L, _L, _L, _L, _L, _L, _L, _L,
+ _L, _L, _L, _L, _L, _L, _L, _L,
+ _L, _L, _L, _P, _P, _P, _P, _C
+};
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)disktab.c 5.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <disktab.h>
+#include <stdio.h>
+
+static char *dgetstr();
+
+struct disktab *
+getdiskbyname(name)
+ char *name;
+{
+ static struct disktab disk;
+ static char localbuf[100], *cp = localbuf;
+ register struct disktab *dp = &disk;
+ register struct partition *pp;
+ char p, psize[3], pbsize[3], pfsize[3];
+ char buf[BUFSIZ];
+
+ if (dgetent(buf, name) <= 0)
+ return ((struct disktab *)0);
+ dp->d_name = cp;
+ strcpy(cp, name);
+ cp += strlen(name) + 1;
+ dp->d_type = dgetstr("ty", &cp);
+ dp->d_secsize = dgetnum("se");
+ if (dp->d_secsize < 0)
+ dp->d_secsize = 512;
+ dp->d_ntracks = dgetnum("nt");
+ dp->d_nsectors = dgetnum("ns");
+ dp->d_ncylinders = dgetnum("nc");
+ dp->d_rpm = dgetnum("rm");
+ if (dp->d_rpm < 0)
+ dp->d_rpm = 3600;
+ dp->d_badsectforw = dgetflag("sf");
+ dp->d_sectoffset = dgetflag("so");
+ strcpy(psize, "px");
+ strcpy(pbsize, "bx");
+ strcpy(pfsize, "fx");
+ for (p = 'a'; p < 'i'; p++) {
+ psize[1] = pbsize[1] = pfsize[1] = p;
+ pp = &dp->d_partitions[p - 'a'];
+ pp->p_size = dgetnum(psize);
+ pp->p_bsize = dgetnum(pbsize);
+ pp->p_fsize = dgetnum(pfsize);
+ }
+ return (dp);
+}
+
+#include <ctype.h>
+
+static char *tbuf;
+static char *dskip();
+static char *ddecode();
+
+/*
+ * Get an entry for disk name in buffer bp,
+ * from the diskcap file. Parse is very rudimentary;
+ * we just notice escaped newlines.
+ */
+static
+dgetent(bp, name)
+ char *bp, *name;
+{
+ register char *cp;
+ register int c;
+ register int i = 0, cnt = 0;
+ char ibuf[BUFSIZ];
+ int tf;
+
+ tbuf = bp;
+ tf = open(DISKTAB, 0);
+ if (tf < 0)
+ return (-1);
+ for (;;) {
+ cp = bp;
+ for (;;) {
+ if (i == cnt) {
+ cnt = read(tf, ibuf, BUFSIZ);
+ if (cnt <= 0) {
+ close(tf);
+ return (0);
+ }
+ i = 0;
+ }
+ c = ibuf[i++];
+ if (c == '\n') {
+ if (cp > bp && cp[-1] == '\\'){
+ cp--;
+ continue;
+ }
+ break;
+ }
+ if (cp >= bp+BUFSIZ) {
+ write(2,"Disktab entry too long\n", 23);
+ break;
+ } else
+ *cp++ = c;
+ }
+ *cp = 0;
+
+ /*
+ * The real work for the match.
+ */
+ if (dnamatch(name)) {
+ close(tf);
+ return (1);
+ }
+ }
+}
+
+/*
+ * Dnamatch deals with name matching. The first field of the disktab
+ * entry is a sequence of names separated by |'s, so we compare
+ * against each such name. The normal : terminator after the last
+ * name (before the first field) stops us.
+ */
+static
+dnamatch(np)
+ char *np;
+{
+ register char *Np, *Bp;
+
+ Bp = tbuf;
+ if (*Bp == '#')
+ return (0);
+ for (;;) {
+ for (Np = np; *Np && *Bp == *Np; Bp++, Np++)
+ continue;
+ if (*Np == 0 && (*Bp == '|' || *Bp == ':' || *Bp == 0))
+ return (1);
+ while (*Bp && *Bp != ':' && *Bp != '|')
+ Bp++;
+ if (*Bp == 0 || *Bp == ':')
+ return (0);
+ Bp++;
+ }
+}
+
+/*
+ * Skip to the next field. Notice that this is very dumb, not
+ * knowing about \: escapes or any such. If necessary, :'s can be put
+ * into the diskcap file in octal.
+ */
+static char *
+dskip(bp)
+ register char *bp;
+{
+
+ while (*bp && *bp != ':')
+ bp++;
+ if (*bp == ':')
+ bp++;
+ return (bp);
+}
+
+/*
+ * Return the (numeric) option id.
+ * Numeric options look like
+ * li#80
+ * i.e. the option string is separated from the numeric value by
+ * a # character. If the option is not found we return -1.
+ * Note that we handle octal numbers beginning with 0.
+ */
+static
+dgetnum(id)
+ char *id;
+{
+ register int i, base;
+ register char *bp = tbuf;
+
+ for (;;) {
+ bp = dskip(bp);
+ if (*bp == 0)
+ return (-1);
+ if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1])
+ continue;
+ if (*bp == '@')
+ return (-1);
+ if (*bp != '#')
+ continue;
+ bp++;
+ base = 10;
+ if (*bp == '0')
+ base = 8;
+ i = 0;
+ while (isdigit(*bp))
+ i *= base, i += *bp++ - '0';
+ return (i);
+ }
+}
+
+/*
+ * Handle a flag option.
+ * Flag options are given "naked", i.e. followed by a : or the end
+ * of the buffer. Return 1 if we find the option, or 0 if it is
+ * not given.
+ */
+static
+dgetflag(id)
+ char *id;
+{
+ register char *bp = tbuf;
+
+ for (;;) {
+ bp = dskip(bp);
+ if (!*bp)
+ return (0);
+ if (*bp++ == id[0] && *bp != 0 && *bp++ == id[1]) {
+ if (!*bp || *bp == ':')
+ return (1);
+ else if (*bp == '@')
+ return (0);
+ }
+ }
+}
+
+/*
+ * Get a string valued option.
+ * These are given as
+ * cl=^Z
+ * Much decoding is done on the strings, and the strings are
+ * placed in area, which is a ref parameter which is updated.
+ * No checking on area overflow.
+ */
+static char *
+dgetstr(id, area)
+ char *id, **area;
+{
+ register char *bp = tbuf;
+
+ for (;;) {
+ bp = dskip(bp);
+ if (!*bp)
+ return (0);
+ if (*bp++ != id[0] || *bp == 0 || *bp++ != id[1])
+ continue;
+ if (*bp == '@')
+ return (0);
+ if (*bp != '=')
+ continue;
+ bp++;
+ return (ddecode(bp, area));
+ }
+}
+
+/*
+ * Tdecode does the grung work to decode the
+ * string capability escapes.
+ */
+static char *
+ddecode(str, area)
+ register char *str;
+ char **area;
+{
+ register char *cp;
+ register int c;
+ register char *dp;
+ int i;
+
+ cp = *area;
+ while ((c = *str++) && c != ':') {
+ switch (c) {
+
+ case '^':
+ c = *str++ & 037;
+ break;
+
+ case '\\':
+ dp = "E\033^^\\\\::n\nr\rt\tb\bf\f";
+ c = *str++;
+nextc:
+ if (*dp++ == c) {
+ c = *dp++;
+ break;
+ }
+ dp++;
+ if (*dp)
+ goto nextc;
+ if (isdigit(c)) {
+ c -= '0', i = 2;
+ do
+ c <<= 3, c |= *str++ - '0';
+ while (--i && isdigit(*str));
+ }
+ break;
+ }
+ *cp++ = c;
+ }
+ *cp++ = 0;
+ str = *area;
+ *area = cp;
+ return (str);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ecvt.c 5.1 (Berkeley) 3/15/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * ecvt converts to decimal
+ * the number of digits is specified by ndigit
+ * decpt is set to the position of the decimal point
+ * sign is set to 0 for positive, 1 for negative
+ */
+
+char *cvt();
+
+#define NDIG 80
+char*
+ecvt(arg, ndigits, decpt, sign)
+double arg;
+int ndigits, *decpt, *sign;
+{
+ return(cvt(arg, ndigits, decpt, sign, 1));
+}
+
+char*
+fcvt(arg, ndigits, decpt, sign)
+double arg;
+int ndigits, *decpt, *sign;
+{
+ return(cvt(arg, ndigits, decpt, sign, 0));
+}
+
+static char*
+cvt(arg, ndigits, decpt, sign, eflag)
+double arg;
+int ndigits, *decpt, *sign;
+{
+ register int r2;
+ double fi, fj;
+ register char *p, *p1;
+ static char buf[NDIG];
+ double modf();
+
+ if (ndigits<0)
+ ndigits = 0;
+ if (ndigits>=NDIG-1)
+ ndigits = NDIG-2;
+ r2 = 0;
+ *sign = 0;
+ p = &buf[0];
+ if (arg<0) {
+ *sign = 1;
+ arg = -arg;
+ }
+ arg = modf(arg, &fi);
+ p1 = &buf[NDIG];
+ /*
+ * Do integer part
+ */
+ if (fi != 0) {
+ p1 = &buf[NDIG];
+ while (fi != 0) {
+ fj = modf(fi/10, &fi);
+ *--p1 = (int)((fj+.03)*10) + '0';
+ r2++;
+ }
+ while (p1 < &buf[NDIG])
+ *p++ = *p1++;
+ } else if (arg > 0) {
+ while ((fj = arg*10) < 1) {
+ arg = fj;
+ r2--;
+ }
+ }
+ p1 = &buf[ndigits];
+ if (eflag==0)
+ p1 += r2;
+ *decpt = r2;
+ if (p1 < &buf[0]) {
+ buf[0] = '\0';
+ return(buf);
+ }
+ while (p<=p1 && p<&buf[NDIG]) {
+ arg *= 10;
+ arg = modf(arg, &fj);
+ *p++ = (int)fj + '0';
+ }
+ if (p1 >= &buf[NDIG]) {
+ buf[NDIG-1] = '\0';
+ return(buf);
+ }
+ p = p1;
+ *p1 += 5;
+ while (*p1 > '9') {
+ *p1 = '0';
+ if (p1>buf)
+ ++*--p1;
+ else {
+ *p1 = '1';
+ (*decpt)++;
+ if (eflag==0) {
+ if (p>buf)
+ *p = '0';
+ p++;
+ }
+ }
+ }
+ *p = '\0';
+ return(buf);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)errlst.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+char *sys_errlist[] = {
+ "Error 0",
+ "Not owner", /* 1 - EPERM */
+ "No such file or directory", /* 2 - ENOENT */
+ "No such process", /* 3 - ESRCH */
+ "Interrupted system call", /* 4 - EINTR */
+ "I/O error", /* 5 - EIO */
+ "No such device or address", /* 6 - ENXIO */
+ "Arg list too long", /* 7 - E2BIG */
+ "Exec format error", /* 8 - ENOEXEC */
+ "Bad file number", /* 9 - EBADF */
+ "No children", /* 10 - ECHILD */
+ "No more processes", /* 11 - EAGAIN */
+ "Not enough memory", /* 12 - ENOMEM */
+ "Permission denied", /* 13 - EACCES */
+ "Bad address", /* 14 - EFAULT */
+ "Block device required", /* 15 - ENOTBLK */
+ "Device busy", /* 16 - EBUSY */
+ "File exists", /* 17 - EEXIST */
+ "Cross-device link", /* 18 - EXDEV */
+ "No such device", /* 19 - ENODEV */
+ "Not a directory", /* 20 - ENOTDIR */
+ "Is a directory", /* 21 - EISDIR */
+ "Invalid argument", /* 22 - EINVAL */
+ "File table overflow", /* 23 - ENFILE */
+ "Too many open files", /* 24 - EMFILE */
+ "Inappropriate ioctl for device", /* 25 - ENOTTY */
+ "Text file busy", /* 26 - ETXTBSY */
+ "File too large", /* 27 - EFBIG */
+ "No space left on device", /* 28 - ENOSPC */
+ "Illegal seek", /* 29 - ESPIPE */
+ "Read-only file system", /* 30 - EROFS */
+ "Too many links", /* 31 - EMLINK */
+ "Broken pipe", /* 32 - EPIPE */
+
+/* math software */
+ "Argument too large", /* 33 - EDOM */
+ "Result too large", /* 34 - ERANGE */
+
+/* non-blocking and interrupt i/o */
+ "Operation would block", /* 35 - EWOULDBLOCK */
+ "Operation now in progress", /* 36 - EINPROGRESS */
+ "Operation already in progress", /* 37 - EALREADY */
+
+/* ipc/network software */
+
+ /* argument errors */
+ "Socket operation on non-socket", /* 38 - ENOTSOCK */
+ "Destination address required", /* 39 - EDESTADDRREQ */
+ "Message too long", /* 40 - EMSGSIZE */
+ "Protocol wrong type for socket", /* 41 - EPROTOTYPE */
+ "Option not supported by protocol", /* 42 - ENOPROTOOPT */
+ "Protocol not supported", /* 43 - EPROTONOSUPPORT */
+ "Socket type not supported", /* 44 - ESOCKTNOSUPPORT */
+ "Operation not supported on socket", /* 45 - EOPNOTSUPP */
+ "Protocol family not supported", /* 46 - EPFNOSUPPORT */
+ "Address family not supported by protocol family",
+ /* 47 - EAFNOSUPPORT */
+ "Address already in use", /* 48 - EADDRINUSE */
+ "Can't assign requested address", /* 49 - EADDRNOTAVAIL */
+
+ /* operational errors */
+ "Network is down", /* 50 - ENETDOWN */
+ "Network is unreachable", /* 51 - ENETUNREACH */
+ "Network dropped connection on reset", /* 52 - ENETRESET */
+ "Software caused connection abort", /* 53 - ECONNABORTED */
+ "Connection reset by peer", /* 54 - ECONNRESET */
+ "No buffer space available", /* 55 - ENOBUFS */
+ "Socket is already connected", /* 56 - EISCONN */
+ "Socket is not connected", /* 57 - ENOTCONN */
+ "Can't send after socket shutdown", /* 58 - ESHUTDOWN */
+ "Too many references: can't splice", /* 59 - ETOOMANYREFS */
+ "Connection timed out", /* 60 - ETIMEDOUT */
+ "Connection refused", /* 61 - EREFUSED */
+ "Too many levels of symbolic links", /* 62 - ELOOP */
+ "File name too long", /* 63 - ENAMETOOLONG */
+ "Host is down", /* 64 - EHOSTDOWN */
+ "Host is unreachable", /* 65 - EHOSTUNREACH */
+ "Directory not empty", /* 66 - ENOTEMPTY */
+ "Too many processes", /* 67 - EPROCLIM */
+ "Too many users", /* 68 - EUSERS */
+ "Disc quota exceeded", /* 69 - EDQUOT */
+};
+int sys_nerr = { sizeof sys_errlist/sizeof sys_errlist[0] };
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)execvp.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * execlp(name, arg,...,0) (like execl, but does path search)
+ * execvp(name, argv) (like execv, but does path search)
+ */
+#include <errno.h>
+#define NULL 0
+
+static char shell[] = "/bin/sh";
+char *execat(), *getenv();
+extern errno;
+
+execlp(name, argv)
+char *name, *argv;
+{
+ return(execvp(name, &argv));
+}
+
+execvp(name, argv)
+char *name, **argv;
+{
+ char *pathstr;
+ register char *cp;
+ char fname[128];
+ char *newargs[256];
+ int i;
+ register unsigned etxtbsy = 1;
+ register eacces = 0;
+
+ if ((pathstr = getenv("PATH")) == NULL)
+ pathstr = ":/bin:/usr/bin";
+ cp = index(name, '/')? "": pathstr;
+
+ do {
+ cp = execat(cp, name, fname);
+ retry:
+ execv(fname, argv);
+ switch(errno) {
+ case ENOEXEC:
+ newargs[0] = "sh";
+ newargs[1] = fname;
+ for (i=1; newargs[i+1]=argv[i]; i++) {
+ if (i>=254) {
+ errno = E2BIG;
+ return(-1);
+ }
+ }
+ execv(shell, newargs);
+ return(-1);
+ case ETXTBSY:
+ if (++etxtbsy > 5)
+ return(-1);
+ sleep(etxtbsy);
+ goto retry;
+ case EACCES:
+ eacces++;
+ break;
+ case ENOMEM:
+ case E2BIG:
+ return(-1);
+ }
+ } while (cp);
+ if (eacces)
+ errno = EACCES;
+ return(-1);
+}
+
+static char *
+execat(s1, s2, si)
+register char *s1, *s2;
+char *si;
+{
+ register char *s;
+
+ s = si;
+ while (*s1 && *s1 != ':')
+ *s++ = *s1++;
+ if (si != s)
+ *s++ = '/';
+ while (*s2)
+ *s++ = *s2++;
+ *s = '\0';
+ return(*s1? ++s1: 0);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fakcu.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Null cleanup routine to resolve reference in exit()
+ * if not using stdio.
+ */
+_cleanup()
+{
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ffs.c 5.2 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * ffs -- vax ffs instruction
+ */
+ffs(mask)
+ register long mask;
+{
+ register int cnt;
+
+ if (mask == 0)
+ return(0);
+ for (cnt = 1; !(mask & 1); cnt++)
+ mask >>= 1;
+ return(cnt);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)frexp.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * the call
+ * x = frexp(arg,&exp);
+ * must return a double fp quantity x which is <1.0
+ * and the corresponding binary exponent "exp".
+ * such that
+ * arg = x*2^exp
+ * if the argument is 0.0, return 0.0 mantissa and 0 exponent.
+ */
+
+double
+frexp(x,i)
+double x;
+int *i;
+{
+ int neg;
+ int j;
+ j = 0;
+ neg = 0;
+ if(x<0){
+ x = -x;
+ neg = 1;
+ }
+ if(x>=1.0)
+ while(x>=1.0){
+ j = j+1;
+ x = x/2;
+ }
+ else if(x<0.5 && x != 0.0)
+ while(x<0.5){
+ j = j-1;
+ x = 2*x;
+ }
+ *i = j;
+ if(neg) x = -x;
+ return(x);
+ }
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fstab.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <fstab.h>
+#include <stdio.h>
+#include <ctype.h>
+
+static struct fstab fs;
+static char line[BUFSIZ+1];
+static FILE *fs_file = 0;
+
+static char *
+fsskip(p)
+ register char *p;
+{
+
+ while (*p && *p != ':')
+ ++p;
+ if (*p)
+ *p++ = 0;
+ return (p);
+}
+
+static char *
+fsdigit(backp, string, end)
+ int *backp;
+ char *string, end;
+{
+ register int value = 0;
+ register char *cp;
+
+ for (cp = string; *cp && isdigit(*cp); cp++) {
+ value *= 10;
+ value += *cp - '0';
+ }
+ if (*cp == '\0')
+ return ((char *)0);
+ *backp = value;
+ while (*cp && *cp != end)
+ cp++;
+ if (*cp == '\0')
+ return ((char *)0);
+ return (cp+1);
+}
+
+static
+fstabscan(fs)
+ struct fstab *fs;
+{
+ register char *cp;
+
+ cp = fgets(line, 256, fs_file);
+ if (cp == NULL)
+ return (EOF);
+ fs->fs_spec = cp;
+ cp = fsskip(cp);
+ fs->fs_file = cp;
+ cp = fsskip(cp);
+ fs->fs_type = cp;
+ cp = fsskip(cp);
+ cp = fsdigit(&fs->fs_freq, cp, ':');
+ if (cp == 0)
+ return (3);
+ cp = fsdigit(&fs->fs_passno, cp, '\n');
+ if (cp == 0)
+ return (4);
+ return (5);
+}
+
+setfsent()
+{
+
+ if (fs_file)
+ endfsent();
+ if ((fs_file = fopen(FSTAB, "r")) == NULL) {
+ fs_file = 0;
+ return (0);
+ }
+ return (1);
+}
+
+endfsent()
+{
+
+ if (fs_file) {
+ fclose(fs_file);
+ fs_file = 0;
+ }
+ return (1);
+}
+
+struct fstab *
+getfsent()
+{
+ int nfields;
+
+ if ((fs_file == 0) && (setfsent() == 0))
+ return ((struct fstab *)0);
+ nfields = fstabscan(&fs);
+ if (nfields == EOF || nfields != 5)
+ return ((struct fstab *)0);
+ return (&fs);
+}
+
+struct fstab *
+getfsspec(name)
+ char *name;
+{
+ register struct fstab *fsp;
+
+ if (setfsent() == 0) /* start from the beginning */
+ return ((struct fstab *)0);
+ while((fsp = getfsent()) != 0)
+ if (strcmp(fsp->fs_spec, name) == 0)
+ return (fsp);
+ return ((struct fstab *)0);
+}
+
+struct fstab *
+getfsfile(name)
+ char *name;
+{
+ register struct fstab *fsp;
+
+ if (setfsent() == 0) /* start from the beginning */
+ return ((struct fstab *)0);
+ while ((fsp = getfsent()) != 0)
+ if (strcmp(fsp->fs_file, name) == 0)
+ return (fsp);
+ return ((struct fstab *)0);
+}
+
+struct fstab *
+getfstype(type)
+ char *type;
+{
+ register struct fstab *fs;
+
+ if (setfsent() == 0)
+ return ((struct fstab *)0);
+ while ((fs = getfsent()) != 0)
+ if (strcmp(fs->fs_type, type) == 0)
+ return (fs);
+ return ((struct fstab *)0);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)gcvt.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * gcvt - Floating output conversion to
+ * minimal length string
+ */
+
+char *ecvt();
+
+char *
+gcvt(number, ndigit, buf)
+double number;
+char *buf;
+{
+ int sign, decpt;
+ register char *p1, *p2;
+ register i;
+
+ p1 = ecvt(number, ndigit, &decpt, &sign);
+ p2 = buf;
+ if (sign)
+ *p2++ = '-';
+ for (i=ndigit-1; i>0 && p1[i]=='0'; i--)
+ ndigit--;
+ if (decpt >= 0 && decpt-ndigit > 4
+ || decpt < 0 && decpt < -3) { /* use E-style */
+ decpt--;
+ *p2++ = *p1++;
+ *p2++ = '.';
+ for (i=1; i<ndigit; i++)
+ *p2++ = *p1++;
+ *p2++ = 'e';
+ if (decpt<0) {
+ decpt = -decpt;
+ *p2++ = '-';
+ } else
+ *p2++ = '+';
+ *p2++ = decpt/10 + '0';
+ *p2++ = decpt%10 + '0';
+ } else {
+ if (decpt<=0) {
+ if (*p1!='0')
+ *p2++ = '.';
+ while (decpt<0) {
+ decpt++;
+ *p2++ = '0';
+ }
+ }
+ for (i=1; i<=ndigit; i++) {
+ *p2++ = *p1++;
+ if (i==decpt)
+ *p2++ = '.';
+ }
+ if (ndigit<decpt) {
+ while (ndigit++<decpt)
+ *p2++ = '0';
+ *p2++ = '.';
+ }
+ }
+ if (p2[-1]=='.')
+ p2--;
+ *p2 = '\0';
+ return(buf);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getenv.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * getenv(name)
+ * returns ptr to value associated with name, if any, else NULL
+ */
+#define NULL 0
+extern char **environ;
+char *nvmatch();
+
+char *
+getenv(name)
+register char *name;
+{
+ register char **p = environ;
+ register char *v;
+
+ while (*p != NULL)
+ if ((v = nvmatch(name, *p++)) != NULL)
+ return(v);
+ return(NULL);
+}
+
+/*
+ * s1 is either name, or name=value
+ * s2 is name=value
+ * if names match, return value of s2, else NULL
+ * used for environment searching: see getenv
+ */
+
+static char *
+nvmatch(s1, s2)
+register char *s1, *s2;
+{
+
+ while (*s1 == *s2++)
+ if (*s1++ == '=')
+ return(s2);
+ if (*s1 == '\0' && *(s2-1) == '=')
+ return(s2);
+ return(NULL);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getgrent.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <grp.h>
+
+#define MAXGRP 200
+
+static char GROUP[] = "/etc/group";
+static FILE *grf = NULL;
+static char line[BUFSIZ+1];
+static struct group group;
+static char *gr_mem[MAXGRP];
+
+setgrent()
+{
+ if( !grf )
+ grf = fopen( GROUP, "r" );
+ else
+ rewind( grf );
+}
+
+endgrent()
+{
+ if( grf ){
+ fclose( grf );
+ grf = NULL;
+ }
+}
+
+static char *
+grskip(p,c)
+register char *p;
+register c;
+{
+ while( *p && *p != c ) ++p;
+ if( *p ) *p++ = 0;
+ return( p );
+}
+
+struct group *
+getgrent()
+{
+ register char *p, **q;
+
+ if( !grf && !(grf = fopen( GROUP, "r" )) )
+ return(NULL);
+ if( !(p = fgets( line, BUFSIZ, grf )) )
+ return(NULL);
+ group.gr_name = p;
+ group.gr_passwd = p = grskip(p,':');
+ group.gr_gid = atoi( p = grskip(p,':') );
+ group.gr_mem = gr_mem;
+ p = grskip(p,':');
+ grskip(p,'\n');
+ q = gr_mem;
+ while( *p ){
+ if (q < &gr_mem[MAXGRP-1])
+ *q++ = p;
+ p = grskip(p,',');
+ }
+ *q = NULL;
+ return( &group );
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getgrgid.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <grp.h>
+
+struct group *
+getgrgid(gid)
+register gid;
+{
+ register struct group *p;
+ struct group *getgrent();
+
+ setgrent();
+ while( (p = getgrent()) && p->gr_gid != gid );
+ endgrent();
+ return(p);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getgrnam.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <grp.h>
+
+struct group *
+getgrnam(name)
+register char *name;
+{
+ register struct group *p;
+ struct group *getgrent();
+
+ setgrent();
+ while( (p = getgrent()) && strcmp(p->gr_name,name) );
+ endgrent();
+ return(p);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getlogin.c 5.3 (Berkeley) 5/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <utmp.h>
+
+static char UTMP[] = "/etc/utmp";
+static struct utmp ubuf;
+
+char *
+getlogin()
+{
+ register int me, uf;
+ register char *cp;
+
+ if (!(me = ttyslot()))
+ return(0);
+ if ((uf = open(UTMP, 0)) < 0)
+ return (0);
+ lseek (uf, (long)(me*sizeof(ubuf)), 0);
+ if (read(uf, (char *)&ubuf, sizeof (ubuf)) != sizeof (ubuf)) {
+ close(uf);
+ return (0);
+ }
+ close(uf);
+ if (ubuf.ut_name[0] == '\0')
+ return (0);
+ ubuf.ut_name[sizeof (ubuf.ut_name)] = ' ';
+ for (cp = ubuf.ut_name; *cp++ != ' '; )
+ ;
+ *--cp = '\0';
+ return (ubuf.ut_name);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getpass.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <signal.h>
+#include <sgtty.h>
+
+char *
+getpass(prompt)
+char *prompt;
+{
+ struct sgttyb ttyb;
+ int flags;
+ register char *p;
+ register c;
+ FILE *fi;
+ static char pbuf[9];
+ int (*signal())();
+ int (*sig)();
+
+ if ((fi = fdopen(open("/dev/tty", 2), "r")) == NULL)
+ fi = stdin;
+ else
+ setbuf(fi, (char *)NULL);
+ sig = signal(SIGINT, SIG_IGN);
+ ioctl(fileno(fi), TIOCGETP, &ttyb);
+ flags = ttyb.sg_flags;
+ ttyb.sg_flags &= ~ECHO;
+ ioctl(fileno(fi), TIOCSETP, &ttyb);
+ fprintf(stderr, "%s", prompt); fflush(stderr);
+ for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) {
+ if (p < &pbuf[8])
+ *p++ = c;
+ }
+ *p = '\0';
+ fprintf(stderr, "\n"); fflush(stderr);
+ ttyb.sg_flags = flags;
+ ioctl(fileno(fi), TIOCSETP, &ttyb);
+ signal(SIGINT, sig);
+ if (fi != stdin)
+ fclose(fi);
+ return(pbuf);
+}
--- /dev/null
+/*
+ * Copyright (c) 1984 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getpwent.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <pwd.h>
+#include <ndbm.h>
+
+static char EMPTY[] = "";
+static FILE *pwf = NULL;
+static char line[BUFSIZ+1];
+static struct passwd passwd;
+
+/*
+ * The following are shared with getpwnamuid.c
+ */
+char *_pw_file = "/etc/passwd";
+DBM *_pw_db;
+int _pw_stayopen;
+
+setpwent()
+{
+ if (pwf == NULL)
+ pwf = fopen(_pw_file, "r");
+ else
+ rewind(pwf);
+}
+
+endpwent()
+{
+ if (pwf != NULL) {
+ fclose(pwf);
+ pwf = NULL;
+ }
+ if (_pw_db != (DBM *)0) {
+ dbm_close(_pw_db);
+ _pw_db = (DBM *)0;
+ _pw_stayopen = 0;
+ }
+}
+
+static char *
+pwskip(p)
+register char *p;
+{
+ while (*p && *p != ':' && *p != '\n')
+ ++p;
+ if (*p)
+ *p++ = 0;
+ return(p);
+}
+
+struct passwd *
+getpwent()
+{
+ register char *p;
+
+ if (pwf == NULL) {
+ if ((pwf = fopen( _pw_file, "r" )) == NULL)
+ return(0);
+ }
+ p = fgets(line, BUFSIZ, pwf);
+ if (p == NULL)
+ return(0);
+ passwd.pw_name = p;
+ p = pwskip(p);
+ passwd.pw_passwd = p;
+ p = pwskip(p);
+ passwd.pw_uid = atoi(p);
+ p = pwskip(p);
+ passwd.pw_gid = atoi(p);
+ passwd.pw_quota = 0;
+ passwd.pw_comment = EMPTY;
+ p = pwskip(p);
+ passwd.pw_gecos = p;
+ p = pwskip(p);
+ passwd.pw_dir = p;
+ p = pwskip(p);
+ passwd.pw_shell = p;
+ while (*p && *p != '\n')
+ p++;
+ *p = '\0';
+ return(&passwd);
+}
+
+setpwfile(file)
+ char *file;
+{
+ _pw_file = file;
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getpwnamuid.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <pwd.h>
+#include <ndbm.h>
+
+#include <sys/file.h>
+
+static char line[BUFSIZ+1];
+static struct passwd passwd;
+
+/*
+ * The following are shared with getpwent.c
+ */
+extern char *_pw_file;
+DBM *_pw_db;
+int _pw_stayopen;
+
+static struct passwd *
+fetchpw(key)
+ datum key;
+{
+ register char *cp, *tp;
+
+ if (key.dptr == 0)
+ return ((struct passwd *)NULL);
+ key = dbm_fetch(_pw_db, key);
+ if (key.dptr == 0)
+ return ((struct passwd *)NULL);
+ cp = key.dptr;
+ tp = line;
+
+#define EXPAND(e) passwd.pw_/**/e = tp; while (*tp++ = *cp++);
+ EXPAND(name);
+ EXPAND(passwd);
+ bcopy(cp, (char *)&passwd.pw_uid, sizeof (int));
+ cp += sizeof (int);
+ bcopy(cp, (char *)&passwd.pw_gid, sizeof (int));
+ cp += sizeof (int);
+ bcopy(cp, (char *)&passwd.pw_quota, sizeof (int));
+ cp += sizeof (int);
+ EXPAND(comment);
+ EXPAND(gecos);
+ EXPAND(dir);
+ EXPAND(shell);
+ return (&passwd);
+}
+
+struct passwd *
+getpwnam(nam)
+ char *nam;
+{
+ datum key;
+ register struct passwd *pw;
+
+ if (_pw_db == (DBM *)0 &&
+ (_pw_db = dbm_open(_pw_file, O_RDONLY)) == (DBM *)0) {
+ oldcode:
+ setpwent();
+ while ((pw = getpwent()) && strcmp(nam, pw->pw_name))
+ ;
+ if (!_pw_stayopen)
+ endpwent();
+ return (pw);
+ }
+ if (flock(dbm_dirfno(_pw_db), LOCK_SH) < 0) {
+ dbm_close(_pw_db);
+ _pw_db = (DBM *)0;
+ goto oldcode;
+ }
+ key.dptr = nam;
+ key.dsize = strlen(nam);
+ pw = fetchpw(key);
+ (void) flock(dbm_dirfno(_pw_db), LOCK_UN);
+ if (!_pw_stayopen) {
+ dbm_close(_pw_db);
+ _pw_db = (DBM *)0;
+ }
+ return (pw);
+}
+
+struct passwd *
+getpwuid(uid)
+ int uid;
+{
+ datum key;
+ register struct passwd *pw;
+
+ if (_pw_db == (DBM *)0 &&
+ (_pw_db = dbm_open(_pw_file, O_RDONLY)) == (DBM *)0) {
+ oldcode:
+ setpwent();
+ while ((pw = getpwent()) && pw->pw_uid != uid)
+ ;
+ if (!_pw_stayopen)
+ endpwent();
+ return (pw);
+ }
+ if (flock(dbm_dirfno(_pw_db), LOCK_SH) < 0) {
+ dbm_close(_pw_db);
+ _pw_db = (DBM *)0;
+ goto oldcode;
+ }
+ key.dptr = (char *) &uid;
+ key.dsize = sizeof uid;
+ pw = fetchpw(key);
+ (void) flock(dbm_dirfno(_pw_db), LOCK_UN);
+ if (!_pw_stayopen) {
+ dbm_close(_pw_db);
+ _pw_db = (DBM *)0;
+ }
+ return (pw);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getttyent.c 5.4 (Berkeley) 5/19/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <strings.h>
+#include <ttyent.h>
+
+static char TTYFILE[] = "/etc/ttys";
+static char zapchar;
+static FILE *tf = NULL;
+#define LINE 256
+static char line[LINE];
+static struct ttyent tty;
+
+setttyent()
+{
+ if (tf == NULL)
+ tf = fopen(TTYFILE, "r");
+ else
+ rewind(tf);
+}
+
+endttyent()
+{
+ if (tf != NULL) {
+ (void) fclose(tf);
+ tf = NULL;
+ }
+}
+
+#define QUOTED 1
+
+/*
+ * Skip over the current field, removing quotes,
+ * and return a pointer to the next field.
+ */
+static char *
+skip(p)
+ register char *p;
+{
+ register char *t = p;
+ register int c;
+ register int q = 0;
+
+ for (; (c = *p) != '\0'; p++) {
+ if (c == '"') {
+ q ^= QUOTED; /* obscure, but nice */
+ continue;
+ }
+ if (q == QUOTED && *p == '\\' && *(p+1) == '"')
+ p++;
+ *t++ = *p;
+ if (q == QUOTED)
+ continue;
+ if (c == '#') {
+ zapchar = c;
+ *p = 0;
+ break;
+ }
+ if (c == '\t' || c == ' ' || c == '\n') {
+ zapchar = c;
+ *p++ = 0;
+ while ((c = *p) == '\t' || c == ' ' || c == '\n')
+ p++;
+ break;
+ }
+ }
+ *--t = '\0';
+ return (p);
+}
+
+static char *
+value(p)
+ register char *p;
+{
+ if ((p = index(p,'=')) == 0)
+ return(NULL);
+ p++; /* get past the = sign */
+ return(p);
+}
+
+struct ttyent *
+getttyent()
+{
+ register char *p;
+ register int c;
+
+ if (tf == NULL) {
+ if ((tf = fopen(TTYFILE, "r")) == NULL)
+ return (NULL);
+ }
+ do {
+ p = fgets(line, LINE, tf);
+ if (p == NULL)
+ return (NULL);
+ while ((c = *p) == '\t' || c == ' ' || c == '\n')
+ p++;
+ } while (c == '\0' || c == '#');
+ zapchar = 0;
+ tty.ty_name = p;
+ p = skip(p);
+ tty.ty_getty = p;
+ p = skip(p);
+ tty.ty_type = p;
+ p = skip(p);
+ tty.ty_status = 0;
+ tty.ty_window = NULL;
+ for (; *p; p = skip(p)) {
+#define space(x) ((c = p[x]) == ' ' || c == '\t' || c == '\n')
+ if (strncmp(p, "on", 2) == 0 && space(2))
+ tty.ty_status |= TTY_ON;
+ else if (strncmp(p, "off", 3) == 0 && space(3))
+ tty.ty_status &= ~TTY_ON;
+ else if (strncmp(p, "secure", 6) == 0 && space(6))
+ tty.ty_status |= TTY_SECURE;
+ else if (strncmp(p, "window=", 7) == 0)
+ tty.ty_window = value(p);
+ else
+ break;
+ }
+ if (zapchar == '#' || *p == '#')
+ while ((c = *++p) == ' ' || c == '\t')
+ ;
+ tty.ty_comment = p;
+ if (*p == 0)
+ tty.ty_comment = 0;
+ if (p = index(p, '\n'))
+ *p = '\0';
+ return(&tty);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getttynam.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <ttyent.h>
+
+struct ttyent *
+getttynam(tty)
+ char *tty;
+{
+ register struct ttyent *t;
+
+ setttyent();
+ while (t = getttyent()) {
+ if (strcmp(tty, t->ty_name) == 0)
+ break;
+ }
+ endttyent();
+ return (t);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getusershell.c 5.4 (Berkeley) 7/25/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/stat.h>
+#include <ctype.h>
+#include <stdio.h>
+
+#define SHELLS "/etc/shells"
+
+/*
+ * Do not add local shells here. They should be added in /etc/shells
+ */
+static char *okshells[] =
+ { "/bin/sh", "/bin/csh", 0 };
+
+static char **shells, *strings;
+static char **curshell = NULL;
+extern char **initshells();
+
+/*
+ * Get a list of shells from SHELLS, if it exists.
+ */
+char *
+getusershell()
+{
+ char *ret;
+
+ if (curshell == NULL)
+ curshell = initshells();
+ ret = *curshell;
+ if (ret != NULL)
+ curshell++;
+ return (ret);
+}
+
+endusershell()
+{
+
+ if (shells != NULL)
+ free((char *)shells);
+ shells = NULL;
+ if (strings != NULL)
+ free(strings);
+ strings = NULL;
+ curshell = NULL;
+}
+
+setusershell()
+{
+
+ curshell = initshells();
+}
+
+static char **
+initshells()
+{
+ register char **sp, *cp;
+ register FILE *fp;
+ struct stat statb;
+ extern char *malloc(), *calloc();
+
+ if (shells != NULL)
+ free((char *)shells);
+ shells = NULL;
+ if (strings != NULL)
+ free(strings);
+ strings = NULL;
+ if ((fp = fopen(SHELLS, "r")) == (FILE *)0)
+ return(okshells);
+ if (fstat(fileno(fp), &statb) == -1) {
+ (void)fclose(fp);
+ return(okshells);
+ }
+ if ((strings = malloc((unsigned)statb.st_size)) == NULL) {
+ (void)fclose(fp);
+ return(okshells);
+ }
+ shells = (char **)calloc((unsigned)statb.st_size / 3, sizeof (char *));
+ if (shells == NULL) {
+ (void)fclose(fp);
+ free(strings);
+ strings = NULL;
+ return(okshells);
+ }
+ sp = shells;
+ cp = strings;
+ while (fgets(cp, MAXPATHLEN + 1, fp) != NULL) {
+ while (*cp != '#' && *cp != '/' && *cp != '\0')
+ cp++;
+ if (*cp == '#' || *cp == '\0')
+ continue;
+ *sp++ = cp;
+ while (!isspace(*cp) && *cp != '#' && *cp != '\0')
+ cp++;
+ *cp++ = '\0';
+ }
+ *sp = (char *)0;
+ (void)fclose(fp);
+ return (shells);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getwd.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * getwd() returns the pathname of the current working directory. On error
+ * an error message is copied to pathname and null pointer is returned.
+ */
+#include <sys/param.h>
+#include <sys/stat.h>
+#include <sys/dir.h>
+
+#define GETWDERR(s) strcpy(pathname, (s));
+
+char *strcpy();
+static int pathsize; /* pathname length */
+
+char *
+getwd(pathname)
+ char *pathname;
+{
+ char pathbuf[MAXPATHLEN]; /* temporary pathname buffer */
+ char *pnptr = &pathbuf[(sizeof pathbuf)-1]; /* pathname pointer */
+ char curdir[MAXPATHLEN]; /* current directory buffer */
+ char *dptr = curdir; /* directory pointer */
+ char *prepend(); /* prepend dirname to pathname */
+ dev_t cdev, rdev; /* current & root device number */
+ ino_t cino, rino; /* current & root inode number */
+ DIR *dirp; /* directory stream */
+ struct direct *dir; /* directory entry struct */
+ struct stat d, dd; /* file status struct */
+
+ pathsize = 0;
+ *pnptr = '\0';
+ if (stat("/", &d) < 0) {
+ GETWDERR("getwd: can't stat /");
+ return (NULL);
+ }
+ rdev = d.st_dev;
+ rino = d.st_ino;
+ strcpy(dptr, "./");
+ dptr += 2;
+ if (stat(curdir, &d) < 0) {
+ GETWDERR("getwd: can't stat .");
+ return (NULL);
+ }
+ for (;;) {
+ if (d.st_ino == rino && d.st_dev == rdev)
+ break; /* reached root directory */
+ cino = d.st_ino;
+ cdev = d.st_dev;
+ strcpy(dptr, "../");
+ dptr += 3;
+ if ((dirp = opendir(curdir)) == NULL) {
+ GETWDERR("getwd: can't open ..");
+ return (NULL);
+ }
+ fstat(dirp->dd_fd, &d);
+ if (cdev == d.st_dev) {
+ if (cino == d.st_ino) {
+ /* reached root directory */
+ closedir(dirp);
+ break;
+ }
+ do {
+ if ((dir = readdir(dirp)) == NULL) {
+ closedir(dirp);
+ GETWDERR("getwd: read error in ..");
+ return (NULL);
+ }
+ } while (dir->d_ino != cino);
+ } else
+ do {
+ if ((dir = readdir(dirp)) == NULL) {
+ closedir(dirp);
+ GETWDERR("getwd: read error in ..");
+ return (NULL);
+ }
+ strcpy(dptr, dir->d_name);
+ lstat(curdir, &dd);
+ } while(dd.st_ino != cino || dd.st_dev != cdev);
+ closedir(dirp);
+ pnptr = prepend("/", prepend(dir->d_name, pnptr));
+ }
+ if (*pnptr == '\0') /* current dir == root dir */
+ strcpy(pathname, "/");
+ else
+ strcpy(pathname, pnptr);
+ return (pathname);
+}
+
+/*
+ * prepend() tacks a directory name onto the front of a pathname.
+ */
+static char *
+prepend(dirname, pathname)
+ register char *dirname;
+ register char *pathname;
+{
+ register int i; /* directory name size counter */
+
+ for (i = 0; *dirname != '\0'; i++, dirname++)
+ continue;
+ if ((pathsize += i) < MAXPATHLEN)
+ while (i-- > 0)
+ *--pathname = *--dirname;
+ return (pathname);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)index.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Return the ptr in sp at which the character c appears;
+ * NULL if not found
+ */
+
+#define NULL 0
+
+char *
+index(sp, c)
+register char *sp, c;
+{
+ do {
+ if (*sp == c)
+ return(sp);
+ } while (*sp++);
+ return(NULL);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)initgroups.c 5.3 (Berkeley) 4/27/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * initgroups
+ */
+#include <stdio.h>
+#include <sys/param.h>
+#include <grp.h>
+
+struct group *getgrent();
+
+initgroups(uname, agroup)
+ char *uname;
+ int agroup;
+{
+ int groups[NGROUPS], ngroups = 0;
+ register struct group *grp;
+ register int i;
+
+ if (agroup >= 0)
+ groups[ngroups++] = agroup;
+ setgrent();
+ while (grp = getgrent()) {
+ if (grp->gr_gid == agroup)
+ continue;
+ for (i = 0; grp->gr_mem[i]; i++)
+ if (!strcmp(grp->gr_mem[i], uname)) {
+ if (ngroups == NGROUPS) {
+fprintf(stderr, "initgroups: %s is in too many groups\n", uname);
+ goto toomany;
+ }
+ groups[ngroups++] = grp->gr_gid;
+ }
+ }
+toomany:
+ endgrent();
+ if (setgroups(ngroups, groups) < 0) {
+ perror("setgroups");
+ return (-1);
+ }
+ return (0);
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)insque.c 5.1 (Berkeley) 1/27/87";
+#endif LIBC_SCCS and not lint
+
+/*
+ * insque -- vax insque instruction
+ *
+ * NOTE: this implementation is non-atomic!!
+ */
+
+struct vaxque { /* queue format expected by VAX queue instructions */
+ struct vaxque *vq_next;
+ struct vaxque *vq_prev;
+};
+
+insque(e, prev)
+ register struct vaxque *e, *prev;
+{
+ e->vq_prev = prev;
+ e->vq_next = prev->vq_next;
+ prev->vq_next->vq_prev = e;
+ prev->vq_next = e;
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)isatty.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Returns 1 iff file is a tty
+ */
+
+#include <sgtty.h>
+
+isatty(f)
+{
+ struct sgttyb ttyb;
+
+ if (ioctl(f, TIOCGETP, &ttyb) < 0)
+ return(0);
+ return(1);
+}
--- /dev/null
+#include "gen.h"
+double ldexp(v, e) double v; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)malloc.c 5.6 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * malloc.c (Caltech) 2/21/82
+ * Chris Kingsley, kingsley@cit-20.
+ *
+ * This is a very fast storage allocator. It allocates blocks of a small
+ * number of different sizes, and keeps free lists of each size. Blocks that
+ * don't exactly fit are passed up to the next larger size. In this
+ * implementation, the available sizes are 2^n-4 (or 2^n-10) bytes long.
+ * This is designed for use in a virtual memory environment.
+ */
+
+#include <sys/types.h>
+
+#define NULL 0
+
+/*
+ * The overhead on a block is at least 4 bytes. When free, this space
+ * contains a pointer to the next free block, and the bottom two bits must
+ * be zero. When in use, the first byte is set to MAGIC, and the second
+ * byte is the size index. The remaining bytes are for alignment.
+ * If range checking is enabled then a second word holds the size of the
+ * requested block, less 1, rounded up to a multiple of sizeof(RMAGIC).
+ * The order of elements is critical: ov_magic must overlay the low order
+ * bits of ov_next, and ov_magic can not be a valid ov_next bit pattern.
+ */
+union overhead {
+ union overhead *ov_next; /* when free */
+ struct {
+ u_char ovu_magic; /* magic number */
+ u_char ovu_index; /* bucket # */
+#ifdef RCHECK
+ u_short ovu_rmagic; /* range magic number */
+ u_int ovu_size; /* actual block size */
+#endif
+ } ovu;
+#define ov_magic ovu.ovu_magic
+#define ov_index ovu.ovu_index
+#define ov_rmagic ovu.ovu_rmagic
+#define ov_size ovu.ovu_size
+};
+
+#define MAGIC 0xef /* magic # on accounting info */
+#define RMAGIC 0x5555 /* magic # on range info */
+
+#ifdef RCHECK
+#define RSLOP sizeof (u_short)
+#else
+#define RSLOP 0
+#endif
+
+/*
+ * nextf[i] is the pointer to the next free block of size 2^(i+3). The
+ * smallest allocatable block is 8 bytes. The overhead information
+ * precedes the data area returned to the user.
+ */
+#define NBUCKETS 30
+static union overhead *nextf[NBUCKETS];
+extern char *sbrk();
+
+static int pagesz; /* page size */
+static int pagebucket; /* page size bucket */
+
+#ifdef MSTATS
+/*
+ * nmalloc[i] is the difference between the number of mallocs and frees
+ * for a given block size.
+ */
+static u_int nmalloc[NBUCKETS];
+#include <stdio.h>
+#endif
+
+#if defined(DEBUG) || defined(RCHECK)
+#define ASSERT(p) if (!(p)) botch("p")
+#include <stdio.h>
+static
+botch(s)
+ char *s;
+{
+ fprintf(stderr, "\r\nassertion botched: %s\r\n", s);
+ (void) fflush(stderr); /* just in case user buffered it */
+ abort();
+}
+#else
+#define ASSERT(p)
+#endif
+
+char *
+malloc(nbytes)
+ unsigned nbytes;
+{
+ register union overhead *op;
+ register int bucket;
+ register unsigned amt, n;
+
+ /*
+ * First time malloc is called, setup page size and
+ * align break pointer so all data will be page aligned.
+ */
+ if (pagesz == 0) {
+ pagesz = n = getpagesize();
+ op = (union overhead *)sbrk(0);
+ n = n - sizeof (*op) - ((int)op & (n - 1));
+ if (n < 0)
+ n += pagesz;
+ if (n) {
+ if (sbrk(n) == (char *)-1)
+ return (NULL);
+ }
+ bucket = 0;
+ amt = 8;
+ while (pagesz > amt) {
+ amt <<= 1;
+ bucket++;
+ }
+ pagebucket = bucket;
+ }
+ /*
+ * Convert amount of memory requested into closest block size
+ * stored in hash buckets which satisfies request.
+ * Account for space used per block for accounting.
+ */
+ if (nbytes <= (n = pagesz - sizeof (*op) - RSLOP)) {
+#ifndef RCHECK
+ amt = 8; /* size of first bucket */
+ bucket = 0;
+#else
+ amt = 16; /* size of first bucket */
+ bucket = 1;
+#endif
+ n = -(sizeof (*op) + RSLOP);
+ } else {
+ amt = pagesz;
+ bucket = pagebucket;
+ }
+ while (nbytes > amt + n) {
+ amt <<= 1;
+ if (amt == 0)
+ return (NULL);
+ bucket++;
+ }
+ /*
+ * If nothing in hash bucket right now,
+ * request more memory from the system.
+ */
+ if ((op = nextf[bucket]) == NULL) {
+ morecore(bucket);
+ if ((op = nextf[bucket]) == NULL)
+ return (NULL);
+ }
+ /* remove from linked list */
+ nextf[bucket] = op->ov_next;
+ op->ov_magic = MAGIC;
+ op->ov_index = bucket;
+#ifdef MSTATS
+ nmalloc[bucket]++;
+#endif
+#ifdef RCHECK
+ /*
+ * Record allocated size of block and
+ * bound space with magic numbers.
+ */
+ op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1);
+ op->ov_rmagic = RMAGIC;
+ *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC;
+#endif
+ return ((char *)(op + 1));
+}
+
+/*
+ * Allocate more memory to the indicated bucket.
+ */
+morecore(bucket)
+ int bucket;
+{
+ register union overhead *op;
+ register int sz; /* size of desired block */
+ int amt; /* amount to allocate */
+ int nblks; /* how many blocks we get */
+
+ /*
+ * sbrk_size <= 0 only for big, FLUFFY, requests (about
+ * 2^30 bytes on a VAX, I think) or for a negative arg.
+ */
+ sz = 1 << (bucket + 3);
+#ifdef DEBUG
+ ASSERT(sz > 0);
+#else
+ if (sz <= 0)
+ return;
+#endif
+ if (sz < pagesz) {
+ amt = pagesz;
+ nblks = amt / sz;
+ } else {
+ amt = sz + pagesz;
+ nblks = 1;
+ }
+ op = (union overhead *)sbrk(amt);
+ /* no more room! */
+ if ((int)op == -1)
+ return;
+ /*
+ * Add new memory allocated to that on
+ * free list for this hash bucket.
+ */
+ nextf[bucket] = op;
+ while (--nblks > 0) {
+ op->ov_next = (union overhead *)((caddr_t)op + sz);
+ op = (union overhead *)((caddr_t)op + sz);
+ }
+}
+
+free(cp)
+ char *cp;
+{
+ register int size;
+ register union overhead *op;
+
+ if (cp == NULL)
+ return;
+ op = (union overhead *)((caddr_t)cp - sizeof (union overhead));
+#ifdef DEBUG
+ ASSERT(op->ov_magic == MAGIC); /* make sure it was in use */
+#else
+ if (op->ov_magic != MAGIC)
+ return; /* sanity */
+#endif
+#ifdef RCHECK
+ ASSERT(op->ov_rmagic == RMAGIC);
+ ASSERT(*(u_short *)((caddr_t)(op + 1) + op->ov_size) == RMAGIC);
+#endif
+ size = op->ov_index;
+ ASSERT(size < NBUCKETS);
+ op->ov_next = nextf[size]; /* also clobbers ov_magic */
+ nextf[size] = op;
+#ifdef MSTATS
+ nmalloc[size]--;
+#endif
+}
+
+/*
+ * When a program attempts "storage compaction" as mentioned in the
+ * old malloc man page, it realloc's an already freed block. Usually
+ * this is the last block it freed; occasionally it might be farther
+ * back. We have to search all the free lists for the block in order
+ * to determine its bucket: 1st we make one pass thru the lists
+ * checking only the first block in each; if that fails we search
+ * ``realloc_srchlen'' blocks in each list for a match (the variable
+ * is extern so the caller can modify it). If that fails we just copy
+ * however many bytes was given to realloc() and hope it's not huge.
+ */
+int realloc_srchlen = 4; /* 4 should be plenty, -1 =>'s whole list */
+
+char *
+realloc(cp, nbytes)
+ char *cp;
+ unsigned nbytes;
+{
+ register u_int onb, i;
+ union overhead *op;
+ char *res;
+ int was_alloced = 0;
+
+ if (cp == NULL)
+ return (malloc(nbytes));
+ op = (union overhead *)((caddr_t)cp - sizeof (union overhead));
+ if (op->ov_magic == MAGIC) {
+ was_alloced++;
+ i = op->ov_index;
+ } else {
+ /*
+ * Already free, doing "compaction".
+ *
+ * Search for the old block of memory on the
+ * free list. First, check the most common
+ * case (last element free'd), then (this failing)
+ * the last ``realloc_srchlen'' items free'd.
+ * If all lookups fail, then assume the size of
+ * the memory block being realloc'd is the
+ * largest possible (so that all "nbytes" of new
+ * memory are copied into). Note that this could cause
+ * a memory fault if the old area was tiny, and the moon
+ * is gibbous. However, that is very unlikely.
+ */
+ if ((i = findbucket(op, 1)) < 0 &&
+ (i = findbucket(op, realloc_srchlen)) < 0)
+ i = NBUCKETS;
+ }
+ onb = 1 << (i + 3);
+ if (onb < pagesz)
+ onb -= sizeof (*op) + RSLOP;
+ else
+ onb += pagesz - sizeof (*op) - RSLOP;
+ /* avoid the copy if same size block */
+ if (was_alloced) {
+ if (i) {
+ i = 1 << (i + 2);
+ if (i < pagesz)
+ i -= sizeof (*op) + RSLOP;
+ else
+ i += pagesz - sizeof (*op) - RSLOP;
+ }
+ if (nbytes <= onb && nbytes > i) {
+#ifdef RCHECK
+ op->ov_size = (nbytes + RSLOP - 1) & ~(RSLOP - 1);
+ *(u_short *)((caddr_t)(op + 1) + op->ov_size) = RMAGIC;
+#endif
+ return(cp);
+ } else
+ free(cp);
+ }
+ if ((res = malloc(nbytes)) == NULL)
+ return (NULL);
+ if (cp != res) /* common optimization if "compacting" */
+ bcopy(cp, res, (nbytes < onb) ? nbytes : onb);
+ return (res);
+}
+
+/*
+ * Search ``srchlen'' elements of each free list for a block whose
+ * header starts at ``freep''. If srchlen is -1 search the whole list.
+ * Return bucket number, or -1 if not found.
+ */
+static
+findbucket(freep, srchlen)
+ union overhead *freep;
+ int srchlen;
+{
+ register union overhead *p;
+ register int i, j;
+
+ for (i = 0; i < NBUCKETS; i++) {
+ j = 0;
+ for (p = nextf[i]; p && j != srchlen; p = p->ov_next) {
+ if (p == freep)
+ return (i);
+ j++;
+ }
+ }
+ return (-1);
+}
+
+#ifdef MSTATS
+/*
+ * mstats - print out statistics about malloc
+ *
+ * Prints two lines of numbers, one showing the length of the free list
+ * for each size category, the second showing the number of mallocs -
+ * frees for each size category.
+ */
+mstats(s)
+ char *s;
+{
+ register int i, j;
+ register union overhead *p;
+ int totfree = 0,
+ totused = 0;
+
+ fprintf(stderr, "Memory allocation statistics %s\nfree:\t", s);
+ for (i = 0; i < NBUCKETS; i++) {
+ for (j = 0, p = nextf[i]; p; p = p->ov_next, j++)
+ ;
+ fprintf(stderr, " %d", j);
+ totfree += j * (1 << (i + 3));
+ }
+ fprintf(stderr, "\nused:\t");
+ for (i = 0; i < NBUCKETS; i++) {
+ fprintf(stderr, " %d", nmalloc[i]);
+ totused += nmalloc[i] * (1 << (i + 3));
+ }
+ fprintf(stderr, "\n\tTotal in use: %d, total free: %d\n",
+ totused, totfree);
+}
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)mkstemp.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/file.h>
+
+mkstemp(as)
+ char *as;
+{
+ register char *s;
+ register unsigned int pid;
+ register int fd, i;
+
+ pid = getpid();
+ s = as;
+ while (*s++)
+ /* void */;
+ s--;
+ while (*--s == 'X') {
+ *s = (pid % 10) + '0';
+ pid /= 10;
+ }
+ s++;
+ i = 'a';
+ while ((fd = open(as, O_CREAT|O_EXCL|O_RDWR, 0600)) == -1) {
+ if (i == 'z')
+ return(-1);
+ *s = i++;
+ }
+ return(fd);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)mktemp.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+char *
+mktemp(as)
+char *as;
+{
+ register char *s;
+ register unsigned pid;
+ register i;
+
+ pid = getpid();
+ s = as;
+ while (*s++)
+ ;
+ s--;
+ while (*--s == 'X') {
+ *s = (pid%10) + '0';
+ pid /= 10;
+ }
+ s++;
+ i = 'a';
+ while (access(as, 0) != -1) {
+ if (i=='z')
+ return("/");
+ *s = i++;
+ }
+ return(as);
+}
--- /dev/null
+#include "gen.h"
+double modf(v, p) double v, *p; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ndbm.c 5.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/file.h>
+#include <stdio.h>
+#include <errno.h>
+#include <ndbm.h>
+
+#define BYTESIZ 8
+#undef setbit
+
+static datum makdatum();
+static long hashinc();
+static long dcalchash();
+extern int errno;
+
+DBM *
+dbm_open(file, flags, mode)
+ char *file;
+ int flags, mode;
+{
+ struct stat statb;
+ register DBM *db;
+
+ if ((db = (DBM *)malloc(sizeof *db)) == 0) {
+ errno = ENOMEM;
+ return ((DBM *)0);
+ }
+ db->dbm_flags = (flags & 03) == O_RDONLY ? _DBM_RDONLY : 0;
+ if ((flags & 03) == O_WRONLY)
+ flags = (flags & ~03) | O_RDWR;
+ strcpy(db->dbm_pagbuf, file);
+ strcat(db->dbm_pagbuf, ".pag");
+ db->dbm_pagf = open(db->dbm_pagbuf, flags, mode);
+ if (db->dbm_pagf < 0)
+ goto bad;
+ strcpy(db->dbm_pagbuf, file);
+ strcat(db->dbm_pagbuf, ".dir");
+ db->dbm_dirf = open(db->dbm_pagbuf, flags, mode);
+ if (db->dbm_dirf < 0)
+ goto bad1;
+ fstat(db->dbm_dirf, &statb);
+ db->dbm_maxbno = statb.st_size*BYTESIZ-1;
+ db->dbm_pagbno = db->dbm_dirbno = -1;
+ return (db);
+bad1:
+ (void) close(db->dbm_pagf);
+bad:
+ free((char *)db);
+ return ((DBM *)0);
+}
+
+void
+dbm_close(db)
+ DBM *db;
+{
+
+ (void) close(db->dbm_dirf);
+ (void) close(db->dbm_pagf);
+ free((char *)db);
+}
+
+long
+dbm_forder(db, key)
+ register DBM *db;
+ datum key;
+{
+ long hash;
+
+ hash = dcalchash(key);
+ for (db->dbm_hmask=0;; db->dbm_hmask=(db->dbm_hmask<<1)+1) {
+ db->dbm_blkno = hash & db->dbm_hmask;
+ db->dbm_bitno = db->dbm_blkno + db->dbm_hmask;
+ if (getbit(db) == 0)
+ break;
+ }
+ return (db->dbm_blkno);
+}
+
+datum
+dbm_fetch(db, key)
+ register DBM *db;
+ datum key;
+{
+ register i;
+ datum item;
+
+ if (dbm_error(db))
+ goto err;
+ dbm_access(db, dcalchash(key));
+ if ((i = finddatum(db->dbm_pagbuf, key)) >= 0) {
+ item = makdatum(db->dbm_pagbuf, i+1);
+ if (item.dptr != NULL)
+ return (item);
+ }
+err:
+ item.dptr = NULL;
+ item.dsize = 0;
+ return (item);
+}
+
+dbm_delete(db, key)
+ register DBM *db;
+ datum key;
+{
+ register i;
+ datum item;
+
+ if (dbm_error(db))
+ return (-1);
+ if (dbm_rdonly(db)) {
+ errno = EPERM;
+ return (-1);
+ }
+ dbm_access(db, dcalchash(key));
+ if ((i = finddatum(db->dbm_pagbuf, key)) < 0)
+ return (-1);
+ if (!delitem(db->dbm_pagbuf, i))
+ goto err;
+ db->dbm_pagbno = db->dbm_blkno;
+ (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, L_SET);
+ if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
+ err:
+ db->dbm_flags |= _DBM_IOERR;
+ return (-1);
+ }
+ return (0);
+}
+
+dbm_store(db, key, dat, replace)
+ register DBM *db;
+ datum key, dat;
+ int replace;
+{
+ register i;
+ datum item, item1;
+ char ovfbuf[PBLKSIZ];
+
+ if (dbm_error(db))
+ return (-1);
+ if (dbm_rdonly(db)) {
+ errno = EPERM;
+ return (-1);
+ }
+loop:
+ dbm_access(db, dcalchash(key));
+ if ((i = finddatum(db->dbm_pagbuf, key)) >= 0) {
+ if (!replace)
+ return (1);
+ if (!delitem(db->dbm_pagbuf, i)) {
+ db->dbm_flags |= _DBM_IOERR;
+ return (-1);
+ }
+ }
+ if (!additem(db->dbm_pagbuf, key, dat))
+ goto split;
+ db->dbm_pagbno = db->dbm_blkno;
+ (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, L_SET);
+ if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
+ db->dbm_flags |= _DBM_IOERR;
+ return (-1);
+ }
+ return (0);
+
+split:
+ if (key.dsize+dat.dsize+3*sizeof(short) >= PBLKSIZ) {
+ db->dbm_flags |= _DBM_IOERR;
+ errno = ENOSPC;
+ return (-1);
+ }
+ bzero(ovfbuf, PBLKSIZ);
+ for (i=0;;) {
+ item = makdatum(db->dbm_pagbuf, i);
+ if (item.dptr == NULL)
+ break;
+ if (dcalchash(item) & (db->dbm_hmask+1)) {
+ item1 = makdatum(db->dbm_pagbuf, i+1);
+ if (item1.dptr == NULL) {
+ fprintf(stderr, "ndbm: split not paired\n");
+ db->dbm_flags |= _DBM_IOERR;
+ break;
+ }
+ if (!additem(ovfbuf, item, item1) ||
+ !delitem(db->dbm_pagbuf, i)) {
+ db->dbm_flags |= _DBM_IOERR;
+ return (-1);
+ }
+ continue;
+ }
+ i += 2;
+ }
+ db->dbm_pagbno = db->dbm_blkno;
+ (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, L_SET);
+ if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
+ db->dbm_flags |= _DBM_IOERR;
+ return (-1);
+ }
+ (void) lseek(db->dbm_pagf, (db->dbm_blkno+db->dbm_hmask+1)*PBLKSIZ, L_SET);
+ if (write(db->dbm_pagf, ovfbuf, PBLKSIZ) != PBLKSIZ) {
+ db->dbm_flags |= _DBM_IOERR;
+ return (-1);
+ }
+ setbit(db);
+ goto loop;
+}
+
+datum
+dbm_firstkey(db)
+ DBM *db;
+{
+
+ db->dbm_blkptr = 0L;
+ db->dbm_keyptr = 0;
+ return (dbm_nextkey(db));
+}
+
+datum
+dbm_nextkey(db)
+ register DBM *db;
+{
+ struct stat statb;
+ datum item;
+
+ if (dbm_error(db) || fstat(db->dbm_pagf, &statb) < 0)
+ goto err;
+ statb.st_size /= PBLKSIZ;
+ for (;;) {
+ if (db->dbm_blkptr != db->dbm_pagbno) {
+ db->dbm_pagbno = db->dbm_blkptr;
+ (void) lseek(db->dbm_pagf, db->dbm_blkptr*PBLKSIZ, L_SET);
+ if (read(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ)
+ bzero(db->dbm_pagbuf, PBLKSIZ);
+#ifdef DEBUG
+ else if (chkblk(db->dbm_pagbuf) < 0)
+ db->dbm_flags |= _DBM_IOERR;
+#endif
+ }
+ if (((short *)db->dbm_pagbuf)[0] != 0) {
+ item = makdatum(db->dbm_pagbuf, db->dbm_keyptr);
+ if (item.dptr != NULL) {
+ db->dbm_keyptr += 2;
+ return (item);
+ }
+ db->dbm_keyptr = 0;
+ }
+ if (++db->dbm_blkptr >= statb.st_size)
+ break;
+ }
+err:
+ item.dptr = NULL;
+ item.dsize = 0;
+ return (item);
+}
+
+static
+dbm_access(db, hash)
+ register DBM *db;
+ long hash;
+{
+
+ for (db->dbm_hmask=0;; db->dbm_hmask=(db->dbm_hmask<<1)+1) {
+ db->dbm_blkno = hash & db->dbm_hmask;
+ db->dbm_bitno = db->dbm_blkno + db->dbm_hmask;
+ if (getbit(db) == 0)
+ break;
+ }
+ if (db->dbm_blkno != db->dbm_pagbno) {
+ db->dbm_pagbno = db->dbm_blkno;
+ (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, L_SET);
+ if (read(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ)
+ bzero(db->dbm_pagbuf, PBLKSIZ);
+#ifdef DEBUG
+ else if (chkblk(db->dbm_pagbuf) < 0)
+ db->dbm_flags |= _DBM_IOERR;
+#endif
+ }
+}
+
+static
+getbit(db)
+ register DBM *db;
+{
+ long bn;
+ register b, i, n;
+
+
+ if (db->dbm_bitno > db->dbm_maxbno)
+ return (0);
+ n = db->dbm_bitno % BYTESIZ;
+ bn = db->dbm_bitno / BYTESIZ;
+ i = bn % DBLKSIZ;
+ b = bn / DBLKSIZ;
+ if (b != db->dbm_dirbno) {
+ db->dbm_dirbno = b;
+ (void) lseek(db->dbm_dirf, (long)b*DBLKSIZ, L_SET);
+ if (read(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ)
+ bzero(db->dbm_dirbuf, DBLKSIZ);
+ }
+ return (db->dbm_dirbuf[i] & (1<<n));
+}
+
+static
+setbit(db)
+ register DBM *db;
+{
+ long bn;
+ register i, n, b;
+
+ if (db->dbm_bitno > db->dbm_maxbno)
+ db->dbm_maxbno = db->dbm_bitno;
+ n = db->dbm_bitno % BYTESIZ;
+ bn = db->dbm_bitno / BYTESIZ;
+ i = bn % DBLKSIZ;
+ b = bn / DBLKSIZ;
+ if (b != db->dbm_dirbno) {
+ db->dbm_dirbno = b;
+ (void) lseek(db->dbm_dirf, (long)b*DBLKSIZ, L_SET);
+ if (read(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ)
+ bzero(db->dbm_dirbuf, DBLKSIZ);
+ }
+ db->dbm_dirbuf[i] |= 1<<n;
+ db->dbm_dirbno = b;
+ (void) lseek(db->dbm_dirf, (long)b*DBLKSIZ, L_SET);
+ if (write(db->dbm_dirf, db->dbm_dirbuf, DBLKSIZ) != DBLKSIZ)
+ db->dbm_flags |= _DBM_IOERR;
+}
+
+static datum
+makdatum(buf, n)
+ char buf[PBLKSIZ];
+{
+ register short *sp;
+ register t;
+ datum item;
+
+ sp = (short *)buf;
+ if ((unsigned)n >= sp[0]) {
+ item.dptr = NULL;
+ item.dsize = 0;
+ return (item);
+ }
+ t = PBLKSIZ;
+ if (n > 0)
+ t = sp[n];
+ item.dptr = buf+sp[n+1];
+ item.dsize = t - sp[n+1];
+ return (item);
+}
+
+static
+finddatum(buf, item)
+ char buf[PBLKSIZ];
+ datum item;
+{
+ register short *sp;
+ register int i, n, j;
+
+ sp = (short *)buf;
+ n = PBLKSIZ;
+ for (i=0, j=sp[0]; i<j; i+=2, n = sp[i]) {
+ n -= sp[i+1];
+ if (n != item.dsize)
+ continue;
+ if (n == 0 || bcmp(&buf[sp[i+1]], item.dptr, n) == 0)
+ return (i);
+ }
+ return (-1);
+}
+
+static int hitab[16]
+/* ken's
+{
+ 055,043,036,054,063,014,004,005,
+ 010,064,077,000,035,027,025,071,
+};
+*/
+ = { 61, 57, 53, 49, 45, 41, 37, 33,
+ 29, 25, 21, 17, 13, 9, 5, 1,
+};
+static long hltab[64]
+ = {
+ 06100151277L,06106161736L,06452611562L,05001724107L,
+ 02614772546L,04120731531L,04665262210L,07347467531L,
+ 06735253126L,06042345173L,03072226605L,01464164730L,
+ 03247435524L,07652510057L,01546775256L,05714532133L,
+ 06173260402L,07517101630L,02431460343L,01743245566L,
+ 00261675137L,02433103631L,03421772437L,04447707466L,
+ 04435620103L,03757017115L,03641531772L,06767633246L,
+ 02673230344L,00260612216L,04133454451L,00615531516L,
+ 06137717526L,02574116560L,02304023373L,07061702261L,
+ 05153031405L,05322056705L,07401116734L,06552375715L,
+ 06165233473L,05311063631L,01212221723L,01052267235L,
+ 06000615237L,01075222665L,06330216006L,04402355630L,
+ 01451177262L,02000133436L,06025467062L,07121076461L,
+ 03123433522L,01010635225L,01716177066L,05161746527L,
+ 01736635071L,06243505026L,03637211610L,01756474365L,
+ 04723077174L,03642763134L,05750130273L,03655541561L,
+};
+
+static long
+hashinc(db, hash)
+ register DBM *db;
+ long hash;
+{
+ long bit;
+
+ hash &= db->dbm_hmask;
+ bit = db->dbm_hmask+1;
+ for (;;) {
+ bit >>= 1;
+ if (bit == 0)
+ return (0L);
+ if ((hash & bit) == 0)
+ return (hash | bit);
+ hash &= ~bit;
+ }
+}
+
+static long
+dcalchash(item)
+ datum item;
+{
+ register int s, c, j;
+ register char *cp;
+ register long hashl;
+ register int hashi;
+
+ hashl = 0;
+ hashi = 0;
+ for (cp = item.dptr, s=item.dsize; --s >= 0; ) {
+ c = *cp++;
+ for (j=0; j<BYTESIZ; j+=4) {
+ hashi += hitab[c&017];
+ hashl += hltab[hashi&63];
+ c >>= 4;
+ }
+ }
+ return (hashl);
+}
+
+/*
+ * Delete pairs of items (n & n+1).
+ */
+static
+delitem(buf, n)
+ char buf[PBLKSIZ];
+{
+ register short *sp, *sp1;
+ register i1, i2;
+
+ sp = (short *)buf;
+ i2 = sp[0];
+ if ((unsigned)n >= i2 || (n & 1))
+ return (0);
+ if (n == i2-2) {
+ sp[0] -= 2;
+ return (1);
+ }
+ i1 = PBLKSIZ;
+ if (n > 0)
+ i1 = sp[n];
+ i1 -= sp[n+2];
+ if (i1 > 0) {
+ i2 = sp[i2];
+ bcopy(&buf[i2], &buf[i2 + i1], sp[n+2] - i2);
+ }
+ sp[0] -= 2;
+ for (sp1 = sp + sp[0], sp += n+1; sp <= sp1; sp++)
+ sp[0] = sp[2] + i1;
+ return (1);
+}
+
+/*
+ * Add pairs of items (item & item1).
+ */
+static
+additem(buf, item, item1)
+ char buf[PBLKSIZ];
+ datum item, item1;
+{
+ register short *sp;
+ register i1, i2;
+
+ sp = (short *)buf;
+ i1 = PBLKSIZ;
+ i2 = sp[0];
+ if (i2 > 0)
+ i1 = sp[i2];
+ i1 -= item.dsize + item1.dsize;
+ if (i1 <= (i2+3) * sizeof(short))
+ return (0);
+ sp[0] += 2;
+ sp[++i2] = i1 + item1.dsize;
+ bcopy(item.dptr, &buf[i1 + item1.dsize], item.dsize);
+ sp[++i2] = i1;
+ bcopy(item1.dptr, &buf[i1], item1.dsize);
+ return (1);
+}
+
+#ifdef DEBUG
+static
+chkblk(buf)
+ char buf[PBLKSIZ];
+{
+ register short *sp;
+ register t, i;
+
+ sp = (short *)buf;
+ t = PBLKSIZ;
+ for (i=0; i<sp[0]; i++) {
+ if (sp[i+1] > t)
+ return (-1);
+ t = sp[i+1];
+ }
+ if (t < (sp[0]+1)*sizeof(short))
+ return (-1);
+ return (0);
+}
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)nlist.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <a.out.h>
+#include <stdio.h>
+
+/*
+ * nlist - retreive attributes from name list (string table version)
+ */
+nlist(name, list)
+ char *name;
+ struct nlist *list;
+{
+ register struct nlist *p, *q;
+ register char *s1, *s2;
+ register n, m;
+ int maxlen, nreq;
+ FILE *f;
+ FILE *sf;
+ off_t sa; /* symbol address */
+ off_t ss; /* start of strings */
+ struct exec buf;
+ struct nlist space[BUFSIZ/sizeof (struct nlist)];
+
+ maxlen = 0;
+ for (q = list, nreq = 0; q->n_un.n_name && q->n_un.n_name[0]; q++, nreq++) {
+ q->n_type = 0;
+ q->n_value = 0;
+ q->n_desc = 0;
+ q->n_other = 0;
+ n = strlen(q->n_un.n_name);
+ if (n > maxlen)
+ maxlen = n;
+ }
+ f = fopen(name, "r");
+ if (f == NULL)
+ return (-1);
+ fread((char *)&buf, sizeof buf, 1, f);
+ if (N_BADMAG(buf)) {
+ fclose(f);
+ return (-1);
+ }
+ sf = fopen(name, "r");
+ if (sf == NULL) {
+ /* ??? */
+ fclose(f);
+ return(-1);
+ }
+ sa = N_SYMOFF(buf);
+ ss = sa + buf.a_syms;
+ n = buf.a_syms;
+ fseek(f, sa, 0);
+ while (n) {
+ m = sizeof (space);
+ if (n < m)
+ m = n;
+ if (fread((char *)space, m, 1, f) != 1)
+ break;
+ n -= m;
+ for (q = space; (m -= sizeof(struct nlist)) >= 0; q++) {
+ char nambuf[BUFSIZ];
+
+ if (q->n_un.n_strx == 0 || q->n_type & N_STAB)
+ continue;
+ fseek(sf, ss+q->n_un.n_strx, 0);
+ fread(nambuf, maxlen+1, 1, sf);
+ for (p = list; p->n_un.n_name && p->n_un.n_name[0]; p++) {
+ s1 = p->n_un.n_name;
+ s2 = nambuf;
+ while (*s1) {
+ if (*s1++ != *s2++)
+ goto cont;
+ }
+ if (*s2)
+ goto cont;
+ p->n_value = q->n_value;
+ p->n_type = q->n_type;
+ p->n_desc = q->n_desc;
+ p->n_other = q->n_other;
+ if (--nreq == 0)
+ goto alldone;
+ break;
+ cont: ;
+ }
+ }
+ }
+alldone:
+ fclose(f);
+ fclose(sf);
+ return (nreq);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)opendir.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/param.h>
+#include <sys/dir.h>
+
+/*
+ * open a directory.
+ */
+DIR *
+opendir(name)
+ char *name;
+{
+ register DIR *dirp;
+ register int fd;
+
+ if ((fd = open(name, 0)) == -1)
+ return NULL;
+ if ((dirp = (DIR *)malloc(sizeof(DIR))) == NULL) {
+ close (fd);
+ return NULL;
+ }
+ dirp->dd_fd = fd;
+ dirp->dd_loc = 0;
+ return dirp;
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)perror.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Print the error indicated
+ * in the cerror cell.
+ */
+#include <sys/types.h>
+#include <sys/uio.h>
+
+int errno;
+int sys_nerr;
+char *sys_errlist[];
+perror(s)
+ char *s;
+{
+ struct iovec iov[4];
+ register struct iovec *v = iov;
+
+ if (s && *s) {
+ v->iov_base = s;
+ v->iov_len = strlen(s);
+ v++;
+ v->iov_base = ": ";
+ v->iov_len = 2;
+ v++;
+ }
+ v->iov_base = errno < sys_nerr ? sys_errlist[errno] : "Unknown error";
+ v->iov_len = strlen(v->iov_base);
+ v++;
+ v->iov_base = "\n";
+ v->iov_len = 1;
+ writev(2, iov, (v - iov) + 1);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)popen.c 5.4 (Berkeley) 3/26/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <signal.h>
+
+#define tst(a,b) (*mode == 'r'? (b) : (a))
+#define RDR 0
+#define WTR 1
+
+extern char *malloc();
+
+static int *popen_pid;
+static int nfiles;
+
+FILE *
+popen(cmd,mode)
+ char *cmd;
+ char *mode;
+{
+ int p[2];
+ int myside, hisside, pid;
+
+ if (nfiles <= 0)
+ nfiles = getdtablesize();
+ if (popen_pid == NULL) {
+ popen_pid = (int *)malloc(nfiles * sizeof *popen_pid);
+ if (popen_pid == NULL)
+ return (NULL);
+ for (pid = 0; pid < nfiles; pid++)
+ popen_pid[pid] = -1;
+ }
+ if (pipe(p) < 0)
+ return (NULL);
+ myside = tst(p[WTR], p[RDR]);
+ hisside = tst(p[RDR], p[WTR]);
+ if ((pid = vfork()) == 0) {
+ /* myside and hisside reverse roles in child */
+ close(myside);
+ if (hisside != tst(0, 1)) {
+ dup2(hisside, tst(0, 1));
+ close(hisside);
+ }
+ execl("/bin/sh", "sh", "-c", cmd, (char *)NULL);
+ _exit(127);
+ }
+ if (pid == -1) {
+ close(myside);
+ close(hisside);
+ return (NULL);
+ }
+ popen_pid[myside] = pid;
+ close(hisside);
+ return (fdopen(myside, mode));
+}
+
+pclose(ptr)
+ FILE *ptr;
+{
+ int child, pid, status, omask;
+
+ child = popen_pid[fileno(ptr)];
+ popen_pid[fileno(ptr)] = -1;
+ fclose(ptr);
+ if (child == -1)
+ return (-1);
+ omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT)|sigmask(SIGHUP));
+ while ((pid = wait(&status)) != child && pid != -1)
+ ;
+ (void) sigsetmask(omask);
+ return (pid == -1 ? -1 : status);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)psignal.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Print the name of the signal indicated
+ * along with the supplied message.
+ */
+#include <signal.h>
+
+extern char *sys_siglist[];
+
+psignal(sig, s)
+ unsigned sig;
+ char *s;
+{
+ register char *c;
+ register n;
+
+ c = "Unknown signal";
+ if (sig < NSIG)
+ c = sys_siglist[sig];
+ n = strlen(s);
+ if (n) {
+ write(2, s, n);
+ write(2, ": ", 2);
+ }
+ write(2, c, strlen(c));
+ write(2, "\n", 1);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)qsort.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * qsort.c:
+ * Our own version of the system qsort routine which is faster by an average
+ * of 25%, with lows and highs of 10% and 50%.
+ * The THRESHold below is the insertion sort threshold, and has been adjusted
+ * for records of size 48 bytes.
+ * The MTHREShold is where we stop finding a better median.
+ */
+
+#define THRESH 4 /* threshold for insertion */
+#define MTHRESH 6 /* threshold for median */
+
+static int (*qcmp)(); /* the comparison routine */
+static int qsz; /* size of each record */
+static int thresh; /* THRESHold in chars */
+static int mthresh; /* MTHRESHold in chars */
+
+/*
+ * qsort:
+ * First, set up some global parameters for qst to share. Then, quicksort
+ * with qst(), and then a cleanup insertion sort ourselves. Sound simple?
+ * It's not...
+ */
+
+qsort(base, n, size, compar)
+ char *base;
+ int n;
+ int size;
+ int (*compar)();
+{
+ register char c, *i, *j, *lo, *hi;
+ char *min, *max;
+
+ if (n <= 1)
+ return;
+ qsz = size;
+ qcmp = compar;
+ thresh = qsz * THRESH;
+ mthresh = qsz * MTHRESH;
+ max = base + n * qsz;
+ if (n >= THRESH) {
+ qst(base, max);
+ hi = base + thresh;
+ } else {
+ hi = max;
+ }
+ /*
+ * First put smallest element, which must be in the first THRESH, in
+ * the first position as a sentinel. This is done just by searching
+ * the first THRESH elements (or the first n if n < THRESH), finding
+ * the min, and swapping it into the first position.
+ */
+ for (j = lo = base; (lo += qsz) < hi; )
+ if (qcmp(j, lo) > 0)
+ j = lo;
+ if (j != base) {
+ /* swap j into place */
+ for (i = base, hi = base + qsz; i < hi; ) {
+ c = *j;
+ *j++ = *i;
+ *i++ = c;
+ }
+ }
+ /*
+ * With our sentinel in place, we now run the following hyper-fast
+ * insertion sort. For each remaining element, min, from [1] to [n-1],
+ * set hi to the index of the element AFTER which this one goes.
+ * Then, do the standard insertion sort shift on a character at a time
+ * basis for each element in the frob.
+ */
+ for (min = base; (hi = min += qsz) < max; ) {
+ while (qcmp(hi -= qsz, min) > 0)
+ /* void */;
+ if ((hi += qsz) != min) {
+ for (lo = min + qsz; --lo >= min; ) {
+ c = *lo;
+ for (i = j = lo; (j -= qsz) >= hi; i = j)
+ *i = *j;
+ *i = c;
+ }
+ }
+ }
+}
+
+/*
+ * qst:
+ * Do a quicksort
+ * First, find the median element, and put that one in the first place as the
+ * discriminator. (This "median" is just the median of the first, last and
+ * middle elements). (Using this median instead of the first element is a big
+ * win). Then, the usual partitioning/swapping, followed by moving the
+ * discriminator into the right place. Then, figure out the sizes of the two
+ * partions, do the smaller one recursively and the larger one via a repeat of
+ * this code. Stopping when there are less than THRESH elements in a partition
+ * and cleaning up with an insertion sort (in our caller) is a huge win.
+ * All data swaps are done in-line, which is space-losing but time-saving.
+ * (And there are only three places where this is done).
+ */
+
+static
+qst(base, max)
+ char *base, *max;
+{
+ register char c, *i, *j, *jj;
+ register int ii;
+ char *mid, *tmp;
+ int lo, hi;
+
+ /*
+ * At the top here, lo is the number of characters of elements in the
+ * current partition. (Which should be max - base).
+ * Find the median of the first, last, and middle element and make
+ * that the middle element. Set j to largest of first and middle.
+ * If max is larger than that guy, then it's that guy, else compare
+ * max with loser of first and take larger. Things are set up to
+ * prefer the middle, then the first in case of ties.
+ */
+ lo = max - base; /* number of elements as chars */
+ do {
+ mid = i = base + qsz * ((lo / qsz) >> 1);
+ if (lo >= mthresh) {
+ j = (qcmp((jj = base), i) > 0 ? jj : i);
+ if (qcmp(j, (tmp = max - qsz)) > 0) {
+ /* switch to first loser */
+ j = (j == jj ? i : jj);
+ if (qcmp(j, tmp) < 0)
+ j = tmp;
+ }
+ if (j != i) {
+ ii = qsz;
+ do {
+ c = *i;
+ *i++ = *j;
+ *j++ = c;
+ } while (--ii);
+ }
+ }
+ /*
+ * Semi-standard quicksort partitioning/swapping
+ */
+ for (i = base, j = max - qsz; ; ) {
+ while (i < mid && qcmp(i, mid) <= 0)
+ i += qsz;
+ while (j > mid) {
+ if (qcmp(mid, j) <= 0) {
+ j -= qsz;
+ continue;
+ }
+ tmp = i + qsz; /* value of i after swap */
+ if (i == mid) {
+ /* j <-> mid, new mid is j */
+ mid = jj = j;
+ } else {
+ /* i <-> j */
+ jj = j;
+ j -= qsz;
+ }
+ goto swap;
+ }
+ if (i == mid) {
+ break;
+ } else {
+ /* i <-> mid, new mid is i */
+ jj = mid;
+ tmp = mid = i; /* value of i after swap */
+ j -= qsz;
+ }
+ swap:
+ ii = qsz;
+ do {
+ c = *i;
+ *i++ = *jj;
+ *jj++ = c;
+ } while (--ii);
+ i = tmp;
+ }
+ /*
+ * Look at sizes of the two partitions, do the smaller
+ * one first by recursion, then do the larger one by
+ * making sure lo is its size, base and max are update
+ * correctly, and branching back. But only repeat
+ * (recursively or by branching) if the partition is
+ * of at least size THRESH.
+ */
+ i = (j = mid) + qsz;
+ if ((lo = j - base) <= (hi = max - i)) {
+ if (lo >= thresh)
+ qst(base, j);
+ base = i;
+ lo = hi;
+ } else {
+ if (hi >= thresh)
+ qst(i, max);
+ max = j;
+ }
+ } while (lo >= thresh);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)random.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+/*
+ * random.c:
+ * An improved random number generation package. In addition to the standard
+ * rand()/srand() like interface, this package also has a special state info
+ * interface. The initstate() routine is called with a seed, an array of
+ * bytes, and a count of how many bytes are being passed in; this array is then
+ * initialized to contain information for random number generation with that
+ * much state information. Good sizes for the amount of state information are
+ * 32, 64, 128, and 256 bytes. The state can be switched by calling the
+ * setstate() routine with the same array as was initiallized with initstate().
+ * By default, the package runs with 128 bytes of state information and
+ * generates far better random numbers than a linear congruential generator.
+ * If the amount of state information is less than 32 bytes, a simple linear
+ * congruential R.N.G. is used.
+ * Internally, the state information is treated as an array of longs; the
+ * zeroeth element of the array is the type of R.N.G. being used (small
+ * integer); the remainder of the array is the state information for the
+ * R.N.G. Thus, 32 bytes of state information will give 7 longs worth of
+ * state information, which will allow a degree seven polynomial. (Note: the
+ * zeroeth word of state information also has some other information stored
+ * in it -- see setstate() for details).
+ * The random number generation technique is a linear feedback shift register
+ * approach, employing trinomials (since there are fewer terms to sum up that
+ * way). In this approach, the least significant bit of all the numbers in
+ * the state table will act as a linear feedback shift register, and will have
+ * period 2^deg - 1 (where deg is the degree of the polynomial being used,
+ * assuming that the polynomial is irreducible and primitive). The higher
+ * order bits will have longer periods, since their values are also influenced
+ * by pseudo-random carries out of the lower bits. The total period of the
+ * generator is approximately deg*(2**deg - 1); thus doubling the amount of
+ * state information has a vast influence on the period of the generator.
+ * Note: the deg*(2**deg - 1) is an approximation only good for large deg,
+ * when the period of the shift register is the dominant factor. With deg
+ * equal to seven, the period is actually much longer than the 7*(2**7 - 1)
+ * predicted by this formula.
+ */
+
+
+
+/*
+ * For each of the currently supported random number generators, we have a
+ * break value on the amount of state information (you need at least this
+ * many bytes of state info to support this random number generator), a degree
+ * for the polynomial (actually a trinomial) that the R.N.G. is based on, and
+ * the separation between the two lower order coefficients of the trinomial.
+ */
+
+#define TYPE_0 0 /* linear congruential */
+#define BREAK_0 8
+#define DEG_0 0
+#define SEP_0 0
+
+#define TYPE_1 1 /* x**7 + x**3 + 1 */
+#define BREAK_1 32
+#define DEG_1 7
+#define SEP_1 3
+
+#define TYPE_2 2 /* x**15 + x + 1 */
+#define BREAK_2 64
+#define DEG_2 15
+#define SEP_2 1
+
+#define TYPE_3 3 /* x**31 + x**3 + 1 */
+#define BREAK_3 128
+#define DEG_3 31
+#define SEP_3 3
+
+#define TYPE_4 4 /* x**63 + x + 1 */
+#define BREAK_4 256
+#define DEG_4 63
+#define SEP_4 1
+
+
+/*
+ * Array versions of the above information to make code run faster -- relies
+ * on fact that TYPE_i == i.
+ */
+
+#define MAX_TYPES 5 /* max number of types above */
+
+static int degrees[ MAX_TYPES ] = { DEG_0, DEG_1, DEG_2,
+ DEG_3, DEG_4 };
+
+static int seps[ MAX_TYPES ] = { SEP_0, SEP_1, SEP_2,
+ SEP_3, SEP_4 };
+
+
+
+/*
+ * Initially, everything is set up as if from :
+ * initstate( 1, &randtbl, 128 );
+ * Note that this initialization takes advantage of the fact that srandom()
+ * advances the front and rear pointers 10*rand_deg times, and hence the
+ * rear pointer which starts at 0 will also end up at zero; thus the zeroeth
+ * element of the state information, which contains info about the current
+ * position of the rear pointer is just
+ * MAX_TYPES*(rptr - state) + TYPE_3 == TYPE_3.
+ */
+
+static long randtbl[ DEG_3 + 1 ] = { TYPE_3,
+ 0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342,
+ 0xde3b81e0, 0xdf0a6fb5, 0xf103bc02, 0x48f340fb,
+ 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd,
+ 0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86,
+ 0xda672e2a, 0x1588ca88, 0xe369735d, 0x904f35f7,
+ 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc,
+ 0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b,
+ 0xf5ad9d0e, 0x8999220b, 0x27fb47b9 };
+
+/*
+ * fptr and rptr are two pointers into the state info, a front and a rear
+ * pointer. These two pointers are always rand_sep places aparts, as they cycle
+ * cyclically through the state information. (Yes, this does mean we could get
+ * away with just one pointer, but the code for random() is more efficient this
+ * way). The pointers are left positioned as they would be from the call
+ * initstate( 1, randtbl, 128 )
+ * (The position of the rear pointer, rptr, is really 0 (as explained above
+ * in the initialization of randtbl) because the state table pointer is set
+ * to point to randtbl[1] (as explained below).
+ */
+
+static long *fptr = &randtbl[ SEP_3 + 1 ];
+static long *rptr = &randtbl[ 1 ];
+
+
+
+/*
+ * The following things are the pointer to the state information table,
+ * the type of the current generator, the degree of the current polynomial
+ * being used, and the separation between the two pointers.
+ * Note that for efficiency of random(), we remember the first location of
+ * the state information, not the zeroeth. Hence it is valid to access
+ * state[-1], which is used to store the type of the R.N.G.
+ * Also, we remember the last location, since this is more efficient than
+ * indexing every time to find the address of the last element to see if
+ * the front and rear pointers have wrapped.
+ */
+
+static long *state = &randtbl[ 1 ];
+
+static int rand_type = TYPE_3;
+static int rand_deg = DEG_3;
+static int rand_sep = SEP_3;
+
+static long *end_ptr = &randtbl[ DEG_3 + 1 ];
+
+
+
+/*
+ * srandom:
+ * Initialize the random number generator based on the given seed. If the
+ * type is the trivial no-state-information type, just remember the seed.
+ * Otherwise, initializes state[] based on the given "seed" via a linear
+ * congruential generator. Then, the pointers are set to known locations
+ * that are exactly rand_sep places apart. Lastly, it cycles the state
+ * information a given number of times to get rid of any initial dependencies
+ * introduced by the L.C.R.N.G.
+ * Note that the initialization of randtbl[] for default usage relies on
+ * values produced by this routine.
+ */
+
+srandom( x )
+
+ unsigned x;
+{
+ register int i, j;
+
+ if( rand_type == TYPE_0 ) {
+ state[ 0 ] = x;
+ }
+ else {
+ j = 1;
+ state[ 0 ] = x;
+ for( i = 1; i < rand_deg; i++ ) {
+ state[i] = 1103515245*state[i - 1] + 12345;
+ }
+ fptr = &state[ rand_sep ];
+ rptr = &state[ 0 ];
+ for( i = 0; i < 10*rand_deg; i++ ) random();
+ }
+}
+
+
+
+/*
+ * initstate:
+ * Initialize the state information in the given array of n bytes for
+ * future random number generation. Based on the number of bytes we
+ * are given, and the break values for the different R.N.G.'s, we choose
+ * the best (largest) one we can and set things up for it. srandom() is
+ * then called to initialize the state information.
+ * Note that on return from srandom(), we set state[-1] to be the type
+ * multiplexed with the current value of the rear pointer; this is so
+ * successive calls to initstate() won't lose this information and will
+ * be able to restart with setstate().
+ * Note: the first thing we do is save the current state, if any, just like
+ * setstate() so that it doesn't matter when initstate is called.
+ * Returns a pointer to the old state.
+ */
+
+char *
+initstate( seed, arg_state, n )
+
+ unsigned seed; /* seed for R. N. G. */
+ char *arg_state; /* pointer to state array */
+ int n; /* # bytes of state info */
+{
+ register char *ostate = (char *)( &state[ -1 ] );
+
+ if( rand_type == TYPE_0 ) state[ -1 ] = rand_type;
+ else state[ -1 ] = MAX_TYPES*(rptr - state) + rand_type;
+ if( n < BREAK_1 ) {
+ if( n < BREAK_0 ) {
+ fprintf( stderr, "initstate: not enough state (%d bytes) with which to do jack; ignored.\n" );
+ return;
+ }
+ rand_type = TYPE_0;
+ rand_deg = DEG_0;
+ rand_sep = SEP_0;
+ }
+ else {
+ if( n < BREAK_2 ) {
+ rand_type = TYPE_1;
+ rand_deg = DEG_1;
+ rand_sep = SEP_1;
+ }
+ else {
+ if( n < BREAK_3 ) {
+ rand_type = TYPE_2;
+ rand_deg = DEG_2;
+ rand_sep = SEP_2;
+ }
+ else {
+ if( n < BREAK_4 ) {
+ rand_type = TYPE_3;
+ rand_deg = DEG_3;
+ rand_sep = SEP_3;
+ }
+ else {
+ rand_type = TYPE_4;
+ rand_deg = DEG_4;
+ rand_sep = SEP_4;
+ }
+ }
+ }
+ }
+ state = &( ( (long *)arg_state )[1] ); /* first location */
+ end_ptr = &state[ rand_deg ]; /* must set end_ptr before srandom */
+ srandom( seed );
+ if( rand_type == TYPE_0 ) state[ -1 ] = rand_type;
+ else state[ -1 ] = MAX_TYPES*(rptr - state) + rand_type;
+ return( ostate );
+}
+
+
+
+/*
+ * setstate:
+ * Restore the state from the given state array.
+ * Note: it is important that we also remember the locations of the pointers
+ * in the current state information, and restore the locations of the pointers
+ * from the old state information. This is done by multiplexing the pointer
+ * location into the zeroeth word of the state information.
+ * Note that due to the order in which things are done, it is OK to call
+ * setstate() with the same state as the current state.
+ * Returns a pointer to the old state information.
+ */
+
+char *
+setstate( arg_state )
+
+ char *arg_state;
+{
+ register long *new_state = (long *)arg_state;
+ register int type = new_state[0]%MAX_TYPES;
+ register int rear = new_state[0]/MAX_TYPES;
+ char *ostate = (char *)( &state[ -1 ] );
+
+ if( rand_type == TYPE_0 ) state[ -1 ] = rand_type;
+ else state[ -1 ] = MAX_TYPES*(rptr - state) + rand_type;
+ switch( type ) {
+ case TYPE_0:
+ case TYPE_1:
+ case TYPE_2:
+ case TYPE_3:
+ case TYPE_4:
+ rand_type = type;
+ rand_deg = degrees[ type ];
+ rand_sep = seps[ type ];
+ break;
+
+ default:
+ fprintf( stderr, "setstate: state info has been munged; not changed.\n" );
+ }
+ state = &new_state[ 1 ];
+ if( rand_type != TYPE_0 ) {
+ rptr = &state[ rear ];
+ fptr = &state[ (rear + rand_sep)%rand_deg ];
+ }
+ end_ptr = &state[ rand_deg ]; /* set end_ptr too */
+ return( ostate );
+}
+
+
+
+/*
+ * random:
+ * If we are using the trivial TYPE_0 R.N.G., just do the old linear
+ * congruential bit. Otherwise, we do our fancy trinomial stuff, which is the
+ * same in all ther other cases due to all the global variables that have been
+ * set up. The basic operation is to add the number at the rear pointer into
+ * the one at the front pointer. Then both pointers are advanced to the next
+ * location cyclically in the table. The value returned is the sum generated,
+ * reduced to 31 bits by throwing away the "least random" low bit.
+ * Note: the code takes advantage of the fact that both the front and
+ * rear pointers can't wrap on the same call by not testing the rear
+ * pointer if the front one has wrapped.
+ * Returns a 31-bit random number.
+ */
+
+long
+random()
+{
+ long i;
+
+ if( rand_type == TYPE_0 ) {
+ i = state[0] = ( state[0]*1103515245 + 12345 )&0x7fffffff;
+ }
+ else {
+ *fptr += *rptr;
+ i = (*fptr >> 1)&0x7fffffff; /* chucking least random bit */
+ if( ++fptr >= end_ptr ) {
+ fptr = state;
+ ++rptr;
+ }
+ else {
+ if( ++rptr >= end_ptr ) rptr = state;
+ }
+ }
+ return( i );
+}
+
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)readdir.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/param.h>
+#include <sys/dir.h>
+
+/*
+ * get next entry in a directory.
+ */
+struct direct *
+readdir(dirp)
+ register DIR *dirp;
+{
+ register struct direct *dp;
+
+ for (;;) {
+ if (dirp->dd_loc == 0) {
+ dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf,
+ DIRBLKSIZ);
+ if (dirp->dd_size <= 0)
+ return NULL;
+ }
+ if (dirp->dd_loc >= dirp->dd_size) {
+ dirp->dd_loc = 0;
+ continue;
+ }
+ dp = (struct direct *)(dirp->dd_buf + dirp->dd_loc);
+ if (dp->d_reclen <= 0 ||
+ dp->d_reclen > DIRBLKSIZ + 1 - dirp->dd_loc)
+ return NULL;
+ dirp->dd_loc += dp->d_reclen;
+ if (dp->d_ino == 0)
+ continue;
+ return (dp);
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)regex.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#
+
+/*
+ * routines to do regular expression matching
+ *
+ * Entry points:
+ *
+ * re_comp(s)
+ * char *s;
+ * ... returns 0 if the string s was compiled successfully,
+ * a pointer to an error message otherwise.
+ * If passed 0 or a null string returns without changing
+ * the currently compiled re (see note 11 below).
+ *
+ * re_exec(s)
+ * char *s;
+ * ... returns 1 if the string s matches the last compiled regular
+ * expression,
+ * 0 if the string s failed to match the last compiled
+ * regular expression, and
+ * -1 if the compiled regular expression was invalid
+ * (indicating an internal error).
+ *
+ * The strings passed to both re_comp and re_exec may have trailing or
+ * embedded newline characters; they are terminated by nulls.
+ *
+ * The identity of the author of these routines is lost in antiquity;
+ * this is essentially the same as the re code in the original V6 ed.
+ *
+ * The regular expressions recognized are described below. This description
+ * is essentially the same as that for ed.
+ *
+ * A regular expression specifies a set of strings of characters.
+ * A member of this set of strings is said to be matched by
+ * the regular expression. In the following specification for
+ * regular expressions the word `character' means any character but NUL.
+ *
+ * 1. Any character except a special character matches itself.
+ * Special characters are the regular expression delimiter plus
+ * \ [ . and sometimes ^ * $.
+ * 2. A . matches any character.
+ * 3. A \ followed by any character except a digit or ( )
+ * matches that character.
+ * 4. A nonempty string s bracketed [s] (or [^s]) matches any
+ * character in (or not in) s. In s, \ has no special meaning,
+ * and ] may only appear as the first letter. A substring
+ * a-b, with a and b in ascending ASCII order, stands for
+ * the inclusive range of ASCII characters.
+ * 5. A regular expression of form 1-4 followed by * matches a
+ * sequence of 0 or more matches of the regular expression.
+ * 6. A regular expression, x, of form 1-8, bracketed \(x\)
+ * matches what x matches.
+ * 7. A \ followed by a digit n matches a copy of the string that the
+ * bracketed regular expression beginning with the nth \( matched.
+ * 8. A regular expression of form 1-8, x, followed by a regular
+ * expression of form 1-7, y matches a match for x followed by
+ * a match for y, with the x match being as long as possible
+ * while still permitting a y match.
+ * 9. A regular expression of form 1-8 preceded by ^ (or followed
+ * by $), is constrained to matches that begin at the left
+ * (or end at the right) end of a line.
+ * 10. A regular expression of form 1-9 picks out the longest among
+ * the leftmost matches in a line.
+ * 11. An empty regular expression stands for a copy of the last
+ * regular expression encountered.
+ */
+
+/*
+ * constants for re's
+ */
+#define CBRA 1
+#define CCHR 2
+#define CDOT 4
+#define CCL 6
+#define NCCL 8
+#define CDOL 10
+#define CEOF 11
+#define CKET 12
+#define CBACK 18
+
+#define CSTAR 01
+
+#define ESIZE 512
+#define NBRA 9
+
+static char expbuf[ESIZE], *braslist[NBRA], *braelist[NBRA];
+static char circf;
+
+/*
+ * compile the regular expression argument into a dfa
+ */
+char *
+re_comp(sp)
+ register char *sp;
+{
+ register int c;
+ register char *ep = expbuf;
+ int cclcnt, numbra = 0;
+ char *lastep = 0;
+ char bracket[NBRA];
+ char *bracketp = &bracket[0];
+ static char *retoolong = "Regular expression too long";
+
+#define comerr(msg) {expbuf[0] = 0; numbra = 0; return(msg); }
+
+ if (sp == 0 || *sp == '\0') {
+ if (*ep == 0)
+ return("No previous regular expression");
+ return(0);
+ }
+ if (*sp == '^') {
+ circf = 1;
+ sp++;
+ }
+ else
+ circf = 0;
+ for (;;) {
+ if (ep >= &expbuf[ESIZE])
+ comerr(retoolong);
+ if ((c = *sp++) == '\0') {
+ if (bracketp != bracket)
+ comerr("unmatched \\(");
+ *ep++ = CEOF;
+ *ep++ = 0;
+ return(0);
+ }
+ if (c != '*')
+ lastep = ep;
+ switch (c) {
+
+ case '.':
+ *ep++ = CDOT;
+ continue;
+
+ case '*':
+ if (lastep == 0 || *lastep == CBRA || *lastep == CKET)
+ goto defchar;
+ *lastep |= CSTAR;
+ continue;
+
+ case '$':
+ if (*sp != '\0')
+ goto defchar;
+ *ep++ = CDOL;
+ continue;
+
+ case '[':
+ *ep++ = CCL;
+ *ep++ = 0;
+ cclcnt = 1;
+ if ((c = *sp++) == '^') {
+ c = *sp++;
+ ep[-2] = NCCL;
+ }
+ do {
+ if (c == '\0')
+ comerr("missing ]");
+ if (c == '-' && ep [-1] != 0) {
+ if ((c = *sp++) == ']') {
+ *ep++ = '-';
+ cclcnt++;
+ break;
+ }
+ while (ep[-1] < c) {
+ *ep = ep[-1] + 1;
+ ep++;
+ cclcnt++;
+ if (ep >= &expbuf[ESIZE])
+ comerr(retoolong);
+ }
+ }
+ *ep++ = c;
+ cclcnt++;
+ if (ep >= &expbuf[ESIZE])
+ comerr(retoolong);
+ } while ((c = *sp++) != ']');
+ lastep[1] = cclcnt;
+ continue;
+
+ case '\\':
+ if ((c = *sp++) == '(') {
+ if (numbra >= NBRA)
+ comerr("too many \\(\\) pairs");
+ *bracketp++ = numbra;
+ *ep++ = CBRA;
+ *ep++ = numbra++;
+ continue;
+ }
+ if (c == ')') {
+ if (bracketp <= bracket)
+ comerr("unmatched \\)");
+ *ep++ = CKET;
+ *ep++ = *--bracketp;
+ continue;
+ }
+ if (c >= '1' && c < ('1' + NBRA)) {
+ *ep++ = CBACK;
+ *ep++ = c - '1';
+ continue;
+ }
+ *ep++ = CCHR;
+ *ep++ = c;
+ continue;
+
+ defchar:
+ default:
+ *ep++ = CCHR;
+ *ep++ = c;
+ }
+ }
+}
+
+/*
+ * match the argument string against the compiled re
+ */
+int
+re_exec(p1)
+ register char *p1;
+{
+ register char *p2 = expbuf;
+ register int c;
+ int rv;
+
+ for (c = 0; c < NBRA; c++) {
+ braslist[c] = 0;
+ braelist[c] = 0;
+ }
+ if (circf)
+ return((advance(p1, p2)));
+ /*
+ * fast check for first character
+ */
+ if (*p2 == CCHR) {
+ c = p2[1];
+ do {
+ if (*p1 != c)
+ continue;
+ if (rv = advance(p1, p2))
+ return(rv);
+ } while (*p1++);
+ return(0);
+ }
+ /*
+ * regular algorithm
+ */
+ do
+ if (rv = advance(p1, p2))
+ return(rv);
+ while (*p1++);
+ return(0);
+}
+
+/*
+ * try to match the next thing in the dfa
+ */
+static int
+advance(lp, ep)
+ register char *lp, *ep;
+{
+ register char *curlp;
+ int ct, i;
+ int rv;
+
+ for (;;)
+ switch (*ep++) {
+
+ case CCHR:
+ if (*ep++ == *lp++)
+ continue;
+ return(0);
+
+ case CDOT:
+ if (*lp++)
+ continue;
+ return(0);
+
+ case CDOL:
+ if (*lp == '\0')
+ continue;
+ return(0);
+
+ case CEOF:
+ return(1);
+
+ case CCL:
+ if (cclass(ep, *lp++, 1)) {
+ ep += *ep;
+ continue;
+ }
+ return(0);
+
+ case NCCL:
+ if (cclass(ep, *lp++, 0)) {
+ ep += *ep;
+ continue;
+ }
+ return(0);
+
+ case CBRA:
+ braslist[*ep++] = lp;
+ continue;
+
+ case CKET:
+ braelist[*ep++] = lp;
+ continue;
+
+ case CBACK:
+ if (braelist[i = *ep++] == 0)
+ return(-1);
+ if (backref(i, lp)) {
+ lp += braelist[i] - braslist[i];
+ continue;
+ }
+ return(0);
+
+ case CBACK|CSTAR:
+ if (braelist[i = *ep++] == 0)
+ return(-1);
+ curlp = lp;
+ ct = braelist[i] - braslist[i];
+ while (backref(i, lp))
+ lp += ct;
+ while (lp >= curlp) {
+ if (rv = advance(lp, ep))
+ return(rv);
+ lp -= ct;
+ }
+ continue;
+
+ case CDOT|CSTAR:
+ curlp = lp;
+ while (*lp++)
+ ;
+ goto star;
+
+ case CCHR|CSTAR:
+ curlp = lp;
+ while (*lp++ == *ep)
+ ;
+ ep++;
+ goto star;
+
+ case CCL|CSTAR:
+ case NCCL|CSTAR:
+ curlp = lp;
+ while (cclass(ep, *lp++, ep[-1] == (CCL|CSTAR)))
+ ;
+ ep += *ep;
+ goto star;
+
+ star:
+ do {
+ lp--;
+ if (rv = advance(lp, ep))
+ return(rv);
+ } while (lp > curlp);
+ return(0);
+
+ default:
+ return(-1);
+ }
+}
+
+backref(i, lp)
+ register int i;
+ register char *lp;
+{
+ register char *bp;
+
+ bp = braslist[i];
+ while (*bp++ == *lp++)
+ if (bp >= braelist[i])
+ return(1);
+ return(0);
+}
+
+int
+cclass(set, c, af)
+ register char *set, c;
+ int af;
+{
+ register int n;
+
+ if (c == 0)
+ return(0);
+ n = *set++;
+ while (--n)
+ if (*set++ == c)
+ return(af);
+ return(! af);
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)remque.c 5.1 (Berkeley) 1/27/87";
+#endif LIBC_SCCS and not lint
+
+/*
+ * remque -- vax remque instruction
+ *
+ * NOTE: this implementation is non-atomic!!
+ */
+
+struct vaxque { /* queue format expected by VAX queue instructions */
+ struct vaxque *vq_next;
+ struct vaxque *vq_prev;
+};
+
+remque(e)
+ register struct vaxque *e;
+{
+ e->vq_prev->vq_next = e->vq_next;
+ e->vq_next->vq_prev = e->vq_prev;
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rindex.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Return the ptr in sp at which the character c last
+ * appears; NULL if not found
+ */
+
+#define NULL 0
+
+char *
+rindex(sp, c)
+register char *sp, c;
+{
+ register char *r;
+
+ r = NULL;
+ do {
+ if (*sp == c)
+ r = sp;
+ } while (*sp++);
+ return(r);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)scandir.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Scan the directory dirname calling select to make a list of selected
+ * directory entries then sort using qsort and compare routine dcomp.
+ * Returns the number of entries and a pointer to a list of pointers to
+ * struct direct (through namelist). Returns -1 if there were any errors.
+ */
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/dir.h>
+
+scandir(dirname, namelist, select, dcomp)
+ char *dirname;
+ struct direct *(*namelist[]);
+ int (*select)(), (*dcomp)();
+{
+ register struct direct *d, *p, **names;
+ register int nitems;
+ register char *cp1, *cp2;
+ struct stat stb;
+ long arraysz;
+ DIR *dirp;
+
+ if ((dirp = opendir(dirname)) == NULL)
+ return(-1);
+ if (fstat(dirp->dd_fd, &stb) < 0)
+ return(-1);
+
+ /*
+ * estimate the array size by taking the size of the directory file
+ * and dividing it by a multiple of the minimum size entry.
+ */
+ arraysz = (stb.st_size / 24);
+ names = (struct direct **)malloc(arraysz * sizeof(struct direct *));
+ if (names == NULL)
+ return(-1);
+
+ nitems = 0;
+ while ((d = readdir(dirp)) != NULL) {
+ if (select != NULL && !(*select)(d))
+ continue; /* just selected names */
+ /*
+ * Make a minimum size copy of the data
+ */
+ p = (struct direct *)malloc(DIRSIZ(d));
+ if (p == NULL)
+ return(-1);
+ p->d_ino = d->d_ino;
+ p->d_reclen = d->d_reclen;
+ p->d_namlen = d->d_namlen;
+ for (cp1 = p->d_name, cp2 = d->d_name; *cp1++ = *cp2++; );
+ /*
+ * Check to make sure the array has space left and
+ * realloc the maximum size.
+ */
+ if (++nitems >= arraysz) {
+ if (fstat(dirp->dd_fd, &stb) < 0)
+ return(-1); /* just might have grown */
+ arraysz = stb.st_size / 12;
+ names = (struct direct **)realloc((char *)names,
+ arraysz * sizeof(struct direct *));
+ if (names == NULL)
+ return(-1);
+ }
+ names[nitems-1] = p;
+ }
+ closedir(dirp);
+ if (nitems && dcomp != NULL)
+ qsort(names, nitems, sizeof(struct direct *), dcomp);
+ *namelist = names;
+ return(nitems);
+}
+
+/*
+ * Alphabetic order comparison routine for those who want it.
+ */
+alphasort(d1, d2)
+ struct direct **d1, **d2;
+{
+ return(strcmp((*d1)->d_name, (*d2)->d_name));
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)seekdir.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/param.h>
+#include <sys/dir.h>
+
+/*
+ * seek to an entry in a directory.
+ * Only values returned by "telldir" should be passed to seekdir.
+ */
+void
+seekdir(dirp, loc)
+ register DIR *dirp;
+ long loc;
+{
+ long curloc, base, offset;
+ struct direct *dp;
+ extern long lseek();
+
+ curloc = telldir(dirp);
+ if (loc == curloc)
+ return;
+ base = loc & ~(DIRBLKSIZ - 1);
+ offset = loc & (DIRBLKSIZ - 1);
+ (void) lseek(dirp->dd_fd, base, 0);
+ dirp->dd_loc = 0;
+ while (dirp->dd_loc < offset) {
+ dp = readdir(dirp);
+ if (dp == NULL)
+ return;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)setegid.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+setegid(egid)
+ int egid;
+{
+
+ return (setregid(-1, egid));
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)seteuid.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+seteuid(euid)
+ int euid;
+{
+
+ return (setreuid(-1, euid));
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)setgid.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Backwards compatible setgid.
+ */
+setgid(gid)
+ int gid;
+{
+
+ return (setregid(gid, gid));
+}
--- /dev/null
+#include "gen.h"
+int setjmp(e) jmp_buf e; {
+ abort();
+}
+void longjmp(e, v) jmp_buf e; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)setjmperr.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#define ERRMSG "longjmp botch\n"
+
+/*
+ * This routine is called from longjmp() when an error occurs.
+ * Programs that wish to exit gracefully from this error may
+ * write their own versions.
+ * If this routine returns, the program is aborted.
+ */
+longjmperror()
+{
+
+ write(2, ERRMSG, sizeof(ERRMSG));
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)setrgid.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+setrgid(rgid)
+ int rgid;
+{
+
+ return (setregid(rgid, -1));
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)setruid.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+setruid(ruid)
+ int ruid;
+{
+
+ return (setreuid(ruid, -1));
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)setuid.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Backwards compatible setuid.
+ */
+setuid(uid)
+ int uid;
+{
+
+ return (setreuid(uid, uid));
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)siginterrupt.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <signal.h>
+
+/*
+ * Set signal state to prevent restart of system calls
+ * after an instance of the indicated signal.
+ */
+siginterrupt(sig, flag)
+ int sig, flag;
+{
+ struct sigvec sv;
+ int ret;
+
+ if ((ret = sigvec(sig, 0, &sv)) < 0)
+ return (ret);
+ if (flag)
+ sv.sv_flags |= SV_INTERRUPT;
+ else
+ sv.sv_flags &= ~SV_INTERRUPT;
+ return (sigvec(sig, &sv, 0));
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)siglist.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <signal.h>
+
+char *sys_siglist[NSIG] = {
+ "Signal 0",
+ "Hangup", /* SIGHUP */
+ "Interrupt", /* SIGINT */
+ "Quit", /* SIGQUIT */
+ "Illegal instruction", /* SIGILL */
+ "Trace/BPT trap", /* SIGTRAP */
+ "IOT trap", /* SIGIOT */
+ "EMT trap", /* SIGEMT */
+ "Floating point exception", /* SIGFPE */
+ "Killed", /* SIGKILL */
+ "Bus error", /* SIGBUS */
+ "Segmentation fault", /* SIGSEGV */
+ "Bad system call", /* SIGSYS */
+ "Broken pipe", /* SIGPIPE */
+ "Alarm clock", /* SIGALRM */
+ "Terminated", /* SIGTERM */
+ "Urgent I/O condition", /* SIGURG */
+ "Stopped (signal)", /* SIGSTOP */
+ "Stopped", /* SIGTSTP */
+ "Continued", /* SIGCONT */
+ "Child exited", /* SIGCHLD */
+ "Stopped (tty input)", /* SIGTTIN */
+ "Stopped (tty output)", /* SIGTTOU */
+ "I/O possible", /* SIGIO */
+ "Cputime limit exceeded", /* SIGXCPU */
+ "Filesize limit exceeded", /* SIGXFSZ */
+ "Virtual timer expired", /* SIGVTALRM */
+ "Profiling timer expired", /* SIGPROF */
+ "Window size changes", /* SIGWINCH */
+ "Signal 29",
+ "User defined signal 1", /* SIGUSR1 */
+ "User defined signal 2" /* SIGUSR2 */
+};
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)signal.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Almost backwards compatible signal.
+ */
+#include <signal.h>
+
+int (*
+signal(s, a))()
+ int s, (*a)();
+{
+ struct sigvec osv, sv;
+ static int mask[NSIG];
+ static int flags[NSIG];
+
+ sv.sv_handler = a;
+ sv.sv_mask = mask[s];
+ sv.sv_flags = flags[s];
+ if (sigvec(s, &sv, &osv) < 0)
+ return (BADSIG);
+ if (sv.sv_mask != osv.sv_mask || sv.sv_flags != osv.sv_flags) {
+ mask[s] = sv.sv_mask = osv.sv_mask;
+ flags[s] = sv.sv_flags = osv.sv_flags;
+ if (sigvec(s, &sv, 0) < 0)
+ return (BADSIG);
+ }
+ return (osv.sv_handler);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)sleep.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/time.h>
+#include <signal.h>
+
+#define setvec(vec, a) \
+ vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0
+
+static int ringring;
+
+sleep(n)
+ unsigned n;
+{
+ int sleepx(), omask;
+ struct itimerval itv, oitv;
+ register struct itimerval *itp = &itv;
+ struct sigvec vec, ovec;
+
+ if (n == 0)
+ return;
+ timerclear(&itp->it_interval);
+ timerclear(&itp->it_value);
+ if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
+ return;
+ itp->it_value.tv_sec = n;
+ if (timerisset(&oitv.it_value)) {
+ if (timercmp(&oitv.it_value, &itp->it_value, >))
+ oitv.it_value.tv_sec -= itp->it_value.tv_sec;
+ else {
+ itp->it_value = oitv.it_value;
+ /*
+ * This is a hack, but we must have time to
+ * return from the setitimer after the alarm
+ * or else it'll be restarted. And, anyway,
+ * sleep never did anything more than this before.
+ */
+ oitv.it_value.tv_sec = 1;
+ oitv.it_value.tv_usec = 0;
+ }
+ }
+ setvec(vec, sleepx);
+ (void) sigvec(SIGALRM, &vec, &ovec);
+ omask = sigblock(sigmask(SIGALRM));
+ ringring = 0;
+ (void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0);
+ while (!ringring)
+ sigpause(omask &~ sigmask(SIGALRM));
+ (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0);
+ (void) sigsetmask(omask);
+ (void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0);
+}
+
+static
+sleepx()
+{
+
+ ringring = 1;
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcat.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Concatenate s2 on the end of s1. S1's space must be large enough.
+ * Return s1.
+ */
+
+char *
+strcat(s1, s2)
+register char *s1, *s2;
+{
+ register char *os1;
+
+ os1 = s1;
+ while (*s1++)
+ ;
+ --s1;
+ while (*s1++ = *s2++)
+ ;
+ return(os1);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcmp.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Compare strings: s1>s2: >0 s1==s2: 0 s1<s2: <0
+ */
+
+strcmp(s1, s2)
+register char *s1, *s2;
+{
+
+ while (*s1 == *s2++)
+ if (*s1++=='\0')
+ return(0);
+ return(*s1 - *--s2);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcpy.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Copy string s2 to s1. s1 must be large enough.
+ * return s1
+ */
+
+char *
+strcpy(s1, s2)
+register char *s1, *s2;
+{
+ register char *os1;
+
+ os1 = s1;
+ while (*s1++ = *s2++)
+ ;
+ return(os1);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strlen.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Returns the number of
+ * non-NULL bytes in string argument.
+ */
+
+strlen(s)
+register char *s;
+{
+ register n;
+
+ n = 0;
+ while (*s++)
+ n++;
+ return(n);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strncat.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Concatenate s2 on the end of s1. S1's space must be large enough.
+ * At most n characters are moved.
+ * Return s1.
+ */
+
+char *
+strncat(s1, s2, n)
+register char *s1, *s2;
+register n;
+{
+ register char *os1;
+
+ os1 = s1;
+ while (*s1++)
+ ;
+ --s1;
+ while (*s1++ = *s2++)
+ if (--n < 0) {
+ *--s1 = '\0';
+ break;
+ }
+ return(os1);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strncmp.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Compare strings (at most n bytes): s1>s2: >0 s1==s2: 0 s1<s2: <0
+ */
+
+strncmp(s1, s2, n)
+register char *s1, *s2;
+register n;
+{
+
+ while (--n >= 0 && *s1 == *s2++)
+ if (*s1++ == '\0')
+ return(0);
+ return(n<0 ? 0 : *s1 - *--s2);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strncpy.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Copy s2 to s1, truncating or null-padding to always copy n bytes
+ * return s1
+ */
+
+char *
+strncpy(s1, s2, n)
+register char *s1, *s2;
+{
+ register i;
+ register char *os1;
+
+ os1 = s1;
+ for (i = 0; i < n; i++)
+ if ((*s1++ = *s2++) == '\0') {
+ while (++i < n)
+ *s1++ = '\0';
+ return(os1);
+ }
+ return(os1);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)swab.c 5.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Swab bytes
+ * Jeffrey Mogul, Stanford
+ */
+
+swab(from, to, n)
+ register char *from, *to;
+ register int n;
+{
+ register unsigned long temp;
+
+ n >>= 1; n++;
+#define STEP temp = *from++,*to++ = *from++,*to++ = temp
+ /* round to multiple of 8 */
+ while ((--n) & 07)
+ STEP;
+ n >>= 3;
+ while (--n >= 0) {
+ STEP; STEP; STEP; STEP;
+ STEP; STEP; STEP; STEP;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)syslog.c 5.9 (Berkeley) 5/7/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * SYSLOG -- print message on log file
+ *
+ * This routine looks a lot like printf, except that it
+ * outputs to the log file instead of the standard output.
+ * Also:
+ * adds a timestamp,
+ * prints the module name in front of the message,
+ * has some other formatting types (or will sometime),
+ * adds a newline on the end of the message.
+ *
+ * The output of this routine is intended to be read by /etc/syslogd.
+ *
+ * Author: Eric Allman
+ * Modified to use UNIX domain IPC by Ralph Campbell
+ */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/file.h>
+#include <sys/signal.h>
+#include <sys/syslog.h>
+#include <netdb.h>
+#include <strings.h>
+
+#define MAXLINE 1024 /* max message size */
+#define NULL 0 /* manifest */
+
+#define PRIMASK(p) (1 << ((p) & LOG_PRIMASK))
+#define PRIFAC(p) (((p) & LOG_FACMASK) >> 3)
+#define IMPORTANT LOG_ERR
+
+static char logname[] = "/dev/log";
+static char ctty[] = "/dev/console";
+
+static int LogFile = -1; /* fd for log */
+static int LogStat = 0; /* status bits, set by openlog() */
+static char *LogTag = "syslog"; /* string to tag the entry with */
+static int LogMask = 0xff; /* mask of priorities to be logged */
+static int LogFacility = LOG_USER; /* default facility code */
+
+static struct sockaddr SyslogAddr; /* AF_UNIX address of local logger */
+
+extern int errno, sys_nerr;
+extern char *sys_errlist[];
+
+syslog(pri, fmt, p0, p1, p2, p3, p4)
+ int pri;
+ char *fmt;
+{
+ char buf[MAXLINE + 1], outline[MAXLINE + 1];
+ register char *b, *f, *o;
+ register int c;
+ long now;
+ int pid, olderrno = errno;
+
+ /* see if we should just throw out this message */
+ if (pri <= 0 || PRIFAC(pri) >= LOG_NFACILITIES || (PRIMASK(pri) & LogMask) == 0)
+ return;
+ if (LogFile < 0)
+ openlog(LogTag, LogStat | LOG_NDELAY, 0);
+
+ /* set default facility if none specified */
+ if ((pri & LOG_FACMASK) == 0)
+ pri |= LogFacility;
+
+ /* build the message */
+ o = outline;
+ sprintf(o, "<%d>", pri);
+ o += strlen(o);
+ time(&now);
+ sprintf(o, "%.15s ", ctime(&now) + 4);
+ o += strlen(o);
+ if (LogTag) {
+ strcpy(o, LogTag);
+ o += strlen(o);
+ }
+ if (LogStat & LOG_PID) {
+ sprintf(o, "[%d]", getpid());
+ o += strlen(o);
+ }
+ if (LogTag) {
+ strcpy(o, ": ");
+ o += 2;
+ }
+
+ b = buf;
+ f = fmt;
+ while ((c = *f++) != '\0' && c != '\n' && b < &buf[MAXLINE]) {
+ if (c != '%') {
+ *b++ = c;
+ continue;
+ }
+ if ((c = *f++) != 'm') {
+ *b++ = '%';
+ *b++ = c;
+ continue;
+ }
+ if ((unsigned)olderrno > sys_nerr)
+ sprintf(b, "error %d", olderrno);
+ else
+ strcpy(b, sys_errlist[olderrno]);
+ b += strlen(b);
+ }
+ *b++ = '\n';
+ *b = '\0';
+ sprintf(o, buf, p0, p1, p2, p3, p4);
+ c = strlen(outline);
+ if (c > MAXLINE)
+ c = MAXLINE;
+
+ /* output the message to the local logger */
+ if (sendto(LogFile, outline, c, 0, &SyslogAddr, sizeof SyslogAddr) >= 0)
+ return;
+ if (!(LogStat & LOG_CONS))
+ return;
+
+ /* output the message to the console */
+ pid = vfork();
+ if (pid == -1)
+ return;
+ if (pid == 0) {
+ int fd;
+
+ signal(SIGALRM, SIG_DFL);
+ sigsetmask(sigblock(0) & ~sigmask(SIGALRM));
+ alarm(5);
+ fd = open(ctty, O_WRONLY);
+ alarm(0);
+ strcat(o, "\r");
+ o = index(outline, '>') + 1;
+ write(fd, o, c + 1 - (o - outline));
+ close(fd);
+ _exit(0);
+ }
+ if (!(LogStat & LOG_NOWAIT))
+ while ((c = wait((int *)0)) > 0 && c != pid)
+ ;
+}
+
+/*
+ * OPENLOG -- open system log
+ */
+
+openlog(ident, logstat, logfac)
+ char *ident;
+ int logstat, logfac;
+{
+ if (ident != NULL)
+ LogTag = ident;
+ LogStat = logstat;
+ if (logfac != 0)
+ LogFacility = logfac & LOG_FACMASK;
+ if (LogFile >= 0)
+ return;
+ SyslogAddr.sa_family = AF_UNIX;
+ strncpy(SyslogAddr.sa_data, logname, sizeof SyslogAddr.sa_data);
+ if (LogStat & LOG_NDELAY) {
+ LogFile = socket(AF_UNIX, SOCK_DGRAM, 0);
+ fcntl(LogFile, F_SETFD, 1);
+ }
+}
+
+/*
+ * CLOSELOG -- close the system log
+ */
+
+closelog()
+{
+
+ (void) close(LogFile);
+ LogFile = -1;
+}
+
+/*
+ * SETLOGMASK -- set the log mask level
+ */
+setlogmask(pmask)
+ int pmask;
+{
+ int omask;
+
+ omask = LogMask;
+ if (pmask != 0)
+ LogMask = pmask;
+ return (omask);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)system.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <signal.h>
+
+system(s)
+char *s;
+{
+ int status, pid, w;
+ register int (*istat)(), (*qstat)();
+
+ if ((pid = vfork()) == 0) {
+ execl("/bin/sh", "sh", "-c", s, 0);
+ _exit(127);
+ }
+ istat = signal(SIGINT, SIG_IGN);
+ qstat = signal(SIGQUIT, SIG_IGN);
+ while ((w = wait(&status)) != pid && w != -1)
+ ;
+ if (w == -1)
+ status = -1;
+ signal(SIGINT, istat);
+ signal(SIGQUIT, qstat);
+ return(status);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)telldir.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/param.h>
+#include <sys/dir.h>
+
+/*
+ * return a pointer into a directory
+ */
+long
+telldir(dirp)
+ DIR *dirp;
+{
+ extern long lseek();
+
+ return (lseek(dirp->dd_fd, 0L, 1) - dirp->dd_size + dirp->dd_loc);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)time.c 5.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Backwards compatible time call.
+ */
+#include <sys/types.h>
+#include <sys/time.h>
+
+long
+time(t)
+ time_t *t;
+{
+ struct timeval tt;
+
+ if (gettimeofday(&tt, (struct timezone *)0) < 0)
+ return (-1);
+ if (t)
+ *t = tt.tv_sec;
+ return (tt.tv_sec);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)timezone.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * The arguments are the number of minutes of time
+ * you are westward from Greenwich and whether DST is in effect.
+ * It returns a string
+ * giving the name of the local timezone.
+ *
+ * Sorry, I don't know all the names.
+ */
+
+static struct zone {
+ int offset;
+ char *stdzone;
+ char *dlzone;
+} zonetab[] = {
+ -1*60, "MET", "MET DST", /* Middle European */
+ -2*60, "EET", "EET DST", /* Eastern European */
+ 4*60, "AST", "ADT", /* Atlantic */
+ 5*60, "EST", "EDT", /* Eastern */
+ 6*60, "CST", "CDT", /* Central */
+ 7*60, "MST", "MDT", /* Mountain */
+ 8*60, "PST", "PDT", /* Pacific */
+#ifdef notdef
+ /* there's no way to distinguish this from WET */
+ 0, "GMT", 0, /* Greenwich */
+#endif
+ 0*60, "WET", "WET DST", /* Western European */
+ -10*60, "EST", "EST", /* Aust: Eastern */
+ -10*60+30, "CST", "CST", /* Aust: Central */
+ -8*60, "WST", 0, /* Aust: Western */
+ -1
+};
+
+char *timezone(zone, dst)
+{
+ register struct zone *zp;
+ static char czone[10];
+ char *sign;
+ register char *p, *q;
+ char *getenv(), *index();
+
+ if (p = getenv("TZNAME")) {
+ if (q = index(p, ',')) {
+ if (dst)
+ return(++q);
+ else {
+ *q = '\0';
+ strncpy(czone, p, sizeof(czone)-1);
+ czone[sizeof(czone)-1] = '\0';
+ *q = ',';
+ return (czone);
+ }
+ }
+ return(p);
+ }
+ for (zp=zonetab; zp->offset!=-1; zp++)
+ if (zp->offset==zone) {
+ if (dst && zp->dlzone)
+ return(zp->dlzone);
+ if (!dst && zp->stdzone)
+ return(zp->stdzone);
+ }
+ if (zone<0) {
+ zone = -zone;
+ sign = "+";
+ } else
+ sign = "-";
+ sprintf(czone, "GMT%s%d:%02d", sign, zone/60, zone%60);
+ return(czone);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ttyname.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * ttyname(f): return "/dev/ttyXX" which the the name of the
+ * tty belonging to file f.
+ * NULL if it is not a tty
+ */
+
+#define NULL 0
+#include <sys/param.h>
+#include <sys/dir.h>
+#include <sys/stat.h>
+
+static char dev[] = "/dev/";
+char *strcpy();
+char *strcat();
+
+char *
+ttyname(f)
+{
+ struct stat fsb;
+ struct stat tsb;
+ register struct direct *db;
+ register DIR *df;
+ static char rbuf[32];
+
+ if (isatty(f)==0)
+ return(NULL);
+ if (fstat(f, &fsb) < 0)
+ return(NULL);
+ if ((fsb.st_mode&S_IFMT) != S_IFCHR)
+ return(NULL);
+ if ((df = opendir(dev)) == NULL)
+ return(NULL);
+ while ((db = readdir(df)) != NULL) {
+ if (db->d_ino != fsb.st_ino)
+ continue;
+ strcpy(rbuf, dev);
+ strcat(rbuf, db->d_name);
+ if (stat(rbuf, &tsb) < 0)
+ continue;
+ if (tsb.st_dev == fsb.st_dev && tsb.st_ino == fsb.st_ino) {
+ closedir(df);
+ return(rbuf);
+ }
+ }
+ closedir(df);
+ return(NULL);
+}
--- /dev/null
+/*
+ * Copyright (c) 1984 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ttyslot.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Return the number of the slot in the utmp file
+ * corresponding to the current user: try for file 0, 1, 2.
+ * Definition is the line number in the /etc/ttys file.
+ */
+#include <ttyent.h>
+
+char *ttyname();
+char *rindex();
+
+#define NULL 0
+
+ttyslot()
+{
+ register struct ttyent *ty;
+ register char *tp, *p;
+ register s;
+
+ if ((tp = ttyname(0)) == NULL &&
+ (tp = ttyname(1)) == NULL &&
+ (tp = ttyname(2)) == NULL)
+ return(0);
+ if ((p = rindex(tp, '/')) == NULL)
+ p = tp;
+ else
+ p++;
+ setttyent();
+ s = 0;
+ while ((ty = getttyent()) != NULL) {
+ s++;
+ if (strcmp(ty->ty_name, p) == 0) {
+ endttyent();
+ return (s);
+ }
+ }
+ endttyent();
+ return (0);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ualarm.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/time.h>
+
+#define USPS 1000000 /* # of microseconds in a second */
+
+/*
+ * Generate a SIGALRM signal in ``usecs'' microseconds.
+ * If ``reload'' is non-zero, keep generating SIGALRM
+ * every ``reload'' microseconds after the first signal.
+ */
+unsigned
+ualarm(usecs, reload)
+ register unsigned usecs;
+ register unsigned reload;
+{
+ struct itimerval new, old;
+
+ new.it_interval.tv_usec = reload % USPS;
+ new.it_interval.tv_sec = reload / USPS;
+
+ new.it_value.tv_usec = usecs % USPS;
+ new.it_value.tv_sec = usecs / USPS;
+
+ if (setitimer(ITIMER_REAL, &new, &old) == 0)
+ return (old.it_value.tv_sec * USPS + old.it_value.tv_usec);
+ /* else */
+ return (-1);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)usleep.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/time.h>
+#include <signal.h>
+
+#define USPS 1000000 /* number of microseconds in a second */
+#define TICK 10000 /* system clock resolution in microseconds */
+
+#define setvec(vec, a) \
+ vec.sv_handler = a; vec.sv_mask = vec.sv_onstack = 0
+
+static int ringring;
+
+usleep(n)
+ unsigned n;
+{
+ int sleepx(), omask;
+ struct itimerval itv, oitv;
+ register struct itimerval *itp = &itv;
+ struct sigvec vec, ovec;
+
+ if (n == 0)
+ return;
+ timerclear(&itp->it_interval);
+ timerclear(&itp->it_value);
+ if (setitimer(ITIMER_REAL, itp, &oitv) < 0)
+ return;
+ itp->it_value.tv_sec = n / USPS;
+ itp->it_value.tv_usec = n % USPS;
+ if (timerisset(&oitv.it_value)) {
+ if (timercmp(&oitv.it_value, &itp->it_value, >)) {
+ oitv.it_value.tv_sec -= itp->it_value.tv_sec;
+ oitv.it_value.tv_usec -= itp->it_value.tv_usec;
+ if (oitv.it_value.tv_usec < 0) {
+ oitv.it_value.tv_usec += USPS;
+ oitv.it_value.tv_sec--;
+ }
+ } else {
+ itp->it_value = oitv.it_value;
+ oitv.it_value.tv_sec = 0;
+ oitv.it_value.tv_usec = 2 * TICK;
+ }
+ }
+ setvec(vec, sleepx);
+ (void) sigvec(SIGALRM, &vec, &ovec);
+ omask = sigblock(sigmask(SIGALRM));
+ ringring = 0;
+ (void) setitimer(ITIMER_REAL, itp, (struct itimerval *)0);
+ while (!ringring)
+ sigpause(omask &~ sigmask(SIGALRM));
+ (void) sigvec(SIGALRM, &ovec, (struct sigvec *)0);
+ (void) sigsetmask(omask);
+ (void) setitimer(ITIMER_REAL, &oitv, (struct itimerval *)0);
+}
+
+static
+sleepx()
+{
+
+ ringring = 1;
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)valloc.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+char *malloc();
+
+char *
+valloc(i)
+ int i;
+{
+ int valsiz = getpagesize(), j;
+ char *cp = malloc(i + (valsiz-1));
+
+ j = ((int)cp + (valsiz-1)) &~ (valsiz-1);
+ return ((char *)j);
+}
--- /dev/null
+diff --git a/include/stdio.h b/include/stdio.h
+index 2001be8..ca9648c 100644
+--- a/include/stdio.h
++++ b/include/stdio.h
+@@ -59,7 +59,7 @@ FILE *popen();
+ long ftell();
+ char *fgets();
+ char *gets();
+-#ifdef vax
++#if 0 /*def vax*/
+ char *sprintf(); /* too painful to do right */
+ #endif
+ # endif
--- /dev/null
+include/vaxuba/rxreg.h:#include <sys/ioctl.h>
+include/vaxuba/rxreg.h:#include "ioctl.h"
+include/net/if.h:#include <net/if_arp.h>
+include/net/if.h:#include "../net/if_arp.h"
+include/protocols/talkd.h:#include <sys/types.h>
+include/protocols/talkd.h:#include <sys/socket.h>
+include/a.out.h:#include <sys/exec.h>
+include/sgtty.h:#include <sys/ioctl.h>
+include/string.h:#include <strings.h>
+include/sys/tty.h:#include <sys/ttychars.h>
+include/sys/tty.h:#include <sys/ttydev.h>
+include/sys/tty.h:#include "ttychars.h"
+include/sys/tty.h:#include "ttydev.h"
+include/sys/ioctl.h:#include <sys/ttychars.h>
+include/sys/ioctl.h:#include <sys/ttydev.h>
+include/sys/ioctl.h:#include "ttychars.h"
+include/sys/ioctl.h:#include "ttydev.h"
+include/sys/vmparam.h:#include <machine/vmparam.h>
+include/sys/vmparam.h:#include "../machine/vmparam.h"
+include/sys/param.h:#include <machine/machparam.h>
+include/sys/param.h:#include <signal.h>
+include/sys/param.h:#include <sys/types.h>
+include/sys/param.h:#include "../machine/machparam.h"
+include/sys/param.h:#include "signal.h"
+include/sys/param.h:#include "types.h"
+include/sys/vm.h:#include <sys/vmparam.h>
+include/sys/vm.h:#include <sys/vmmac.h>
+include/sys/vm.h:#include <sys/vmmeter.h>
+include/sys/vm.h:#include <sys/vmsystm.h>
+include/sys/vm.h:#include "vmparam.h"
+include/sys/vm.h:#include "vmmac.h"
+include/sys/vm.h:#include "vmmeter.h"
+include/sys/vm.h:#include "vmsystm.h"
+include/sys/namei.h:#include <sys/uio.h>
+include/sys/namei.h:#include "uio.h"
+include/sys/user.h:#include <machine/pcb.h>
+include/sys/user.h:#include <sys/dmap.h>
+include/sys/user.h:#include <sys/time.h>
+include/sys/user.h:#include <sys/resource.h>
+include/sys/user.h:#include <sys/namei.h>
+include/sys/user.h:#include <errno.h>
+include/sys/user.h:#include "../machine/pcb.h"
+include/sys/user.h:#include "dmap.h"
+include/sys/user.h:#include "time.h"
+include/sys/user.h:#include "resource.h"
+include/sys/user.h:#include "namei.h"
+include/sys/user.h:#include "errno.h"
+include/sys/vcmd.h:#include <sys/ioctl.h>
+include/sys/vcmd.h:#include "ioctl.h"
+include/sys/tablet.h:#include <sys/ioctl.h>
+include/sys/tablet.h:#include "../h/ioctl.h"
+include/sys/time.h:#include <time.h>
+include/mp.h:#include <stdio.h>
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)a.out.h 5.1 (Berkeley) 5/30/85
+ */
+
+/*
+ * Definitions of the a.out header
+ * and magic numbers are shared with
+ * the kernel.
+ */
+/*#include <sys/exec.h>*/
+
+/*
+ * Macros which take exec structures as arguments and tell whether
+ * the file has a reasonable magic number or offsets to text|symbols|strings.
+ */
+#define N_BADMAG(x) \
+ (((x).a_magic)!=OMAGIC && ((x).a_magic)!=NMAGIC && ((x).a_magic)!=ZMAGIC)
+
+#define N_TXTOFF(x) \
+ ((x).a_magic==ZMAGIC ? 1024 : sizeof (struct exec))
+#define N_SYMOFF(x) \
+ (N_TXTOFF(x) + (x).a_text+(x).a_data + (x).a_trsize+(x).a_drsize)
+#define N_STROFF(x) \
+ (N_SYMOFF(x) + (x).a_syms)
+
+/*
+ * Format of a relocation datum.
+ */
+struct relocation_info {
+ int r_address; /* address which is relocated */
+unsigned int r_symbolnum:24, /* local symbol ordinal */
+ r_pcrel:1, /* was relocated pc relative already */
+ r_length:2, /* 0=byte, 1=word, 2=long */
+ r_extern:1, /* does not include value of sym referenced */
+ :4; /* nothing, yet */
+};
+
+/*
+ * Format of a symbol table entry; this file is included by <a.out.h>
+ * and should be used if you aren't interested the a.out header
+ * or relocation information.
+ */
+struct nlist {
+ union {
+ char *n_name; /* for use when in-core */
+ long n_strx; /* index into file string table */
+ } n_un;
+unsigned char n_type; /* type flag, i.e. N_TEXT etc; see below */
+ char n_other; /* unused */
+ short n_desc; /* see <stab.h> */
+unsigned long n_value; /* value of this symbol (or sdb offset) */
+};
+#define n_hash n_desc /* used internally by ld */
+
+/*
+ * Simple values for n_type.
+ */
+#define N_UNDF 0x0 /* undefined */
+#define N_ABS 0x2 /* absolute */
+#define N_TEXT 0x4 /* text */
+#define N_DATA 0x6 /* data */
+#define N_BSS 0x8 /* bss */
+#define N_COMM 0x12 /* common (internal to ld) */
+#define N_FN 0x1f /* file name symbol */
+
+#define N_EXT 01 /* external bit, or'ed in */
+#define N_TYPE 0x1e /* mask for all the type bits */
+
+/*
+ * Sdb entries have some of the N_STAB bits set.
+ * These are given in <stab.h>
+ */
+#define N_STAB 0xe0 /* if any of these bits set, a SDB entry */
+
+/*
+ * Format for namelist values.
+ */
+#define N_FORMAT "%08x"
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ar.h 5.1 (Berkeley) 5/30/85
+ */
+
+#define ARMAG "!<arch>\n"
+#define SARMAG 8
+
+#define ARFMAG "`\n"
+
+struct ar_hdr {
+ char ar_name[16];
+ char ar_date[12];
+ char ar_uid[6];
+ char ar_gid[6];
+ char ar_mode[8];
+ char ar_size[10];
+ char ar_fmag[2];
+};
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ftp.h 5.2 (Berkeley) 5/30/85
+ */
+
+/*
+ * Definitions for FTP
+ * See RFC-765
+ */
+
+/*
+ * Reply codes.
+ */
+#define PRELIM 1 /* positive preliminary */
+#define COMPLETE 2 /* positive completion */
+#define CONTINUE 3 /* positive intermediate */
+#define TRANSIENT 4 /* transient negative completion */
+#define ERROR 5 /* permanent negative completion */
+
+/*
+ * Type codes
+ */
+#define TYPE_A 1 /* ASCII */
+#define TYPE_E 2 /* EBCDIC */
+#define TYPE_I 3 /* image */
+#define TYPE_L 4 /* local byte size */
+
+/*
+ * Form codes
+ */
+#define FORM_N 1 /* non-print */
+#define FORM_T 2 /* telnet format effectors */
+#define FORM_C 3 /* carriage control (ASA) */
+
+/*
+ * Structure codes
+ */
+#define STRU_F 1 /* file (no record structure) */
+#define STRU_R 2 /* record structure */
+#define STRU_P 3 /* page structure */
+
+/*
+ * Mode types
+ */
+#define MODE_S 1 /* stream */
+#define MODE_B 2 /* block */
+#define MODE_C 3 /* compressed */
+
+/*
+ * Record Tokens
+ */
+#define REC_ESC '\377' /* Record-mode Escape */
+#define REC_EOR '\001' /* Record-mode End-of-Record */
+#define REC_EOF '\002' /* Record-mode End-of-File */
+
+/*
+ * Block Header
+ */
+#define BLK_EOR 0x80 /* Block is End-of-Record */
+#define BLK_EOF 0x40 /* Block is End-of-File */
+#define BLK_ERRORS 0x20 /* Block is suspected of containing errors */
+#define BLK_RESTART 0x10 /* Block is Restart Marker */
+
+#define BLK_BYTECOUNT 2 /* Bytes in this block */
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)inet.h 5.1 (Berkeley) 5/30/85
+ */
+
+/*
+ * External definitions for
+ * functions in inet(3N)
+ */
+/*unsigned long inet_addr();*/
+/*char *inet_ntoa();*/
+/*struct in_addr inet_makeaddr();*/
+/*unsigned long inet_network();*/
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)nameser.h 5.11 (Berkeley) 2/14/86
+ */
+
+/*
+ * Define constants based on rfc883
+ */
+#define PACKETSZ 512 /* maximum packet size */
+#define MAXDNAME 256 /* maximum domain name */
+#define MAXCDNAME 255 /* maximum compressed domain name */
+#define MAXLABEL 63 /* maximum length of domain label */
+ /* Number of bytes of fixed size data in query structure */
+#define QFIXEDSZ 4
+ /* number of bytes of fixed size data in resource record */
+#define RRFIXEDSZ 10
+
+/*
+ * Internet nameserver port number
+ */
+#define NAMESERVER_PORT 53
+
+/*
+ * Currently defined opcodes
+ */
+#define QUERY 0 /* standard query */
+#define IQUERY 1 /* inverse query */
+#define CQUERYM 2 /* completion query (multiple) */
+#define CQUERYU 3 /* completion query (unique) */
+ /* non standard */
+#define UPDATEA 100 /* add resource record */
+#define UPDATED 101 /* delete resource record */
+#define UPDATEM 102 /* modify resource record */
+#define ZONEINIT 103 /* initial zone transfer */
+#define ZONEREF 104 /* incremental zone referesh */
+
+/*
+ * Currently defined response codes
+ */
+#define NOERROR 0 /* no error */
+#define FORMERR 1 /* format error */
+#define SERVFAIL 2 /* server failure */
+#define NXDOMAIN 3 /* non existent domain */
+#define NOTIMP 4 /* not implemented */
+#define REFUSED 5 /* query refused */
+ /* non standard */
+#define NOCHANGE 100 /* update failed to change db */
+
+/*
+ * Type values for resources and queries
+ */
+#define T_A 1 /* host address */
+#define T_NS 2 /* authoritative server */
+#define T_MD 3 /* mail destination */
+#define T_MF 4 /* mail forwarder */
+#define T_CNAME 5 /* connonical name */
+#define T_SOA 6 /* start of authority zone */
+#define T_MB 7 /* mailbox domain name */
+#define T_MG 8 /* mail group member */
+#define T_MR 9 /* mail rename name */
+#define T_NULL 10 /* null resource record */
+#define T_WKS 11 /* well known service */
+#define T_PTR 12 /* domain name pointer */
+#define T_HINFO 13 /* host information */
+#define T_MINFO 14 /* mailbox information */
+#define T_MX 15 /* mail routing information */
+ /* non standard */
+#define T_UINFO 100 /* user (finger) information */
+#define T_UID 101 /* user ID */
+#define T_GID 102 /* group ID */
+ /* Query type values which do not appear in resource records */
+#define T_AXFR 252 /* transfer zone of authority */
+#define T_MAILB 253 /* transfer mailbox records */
+#define T_MAILA 254 /* transfer mail agent records */
+#define T_ANY 255 /* wildcard match */
+
+/*
+ * Values for class field
+ */
+
+#define C_IN 1 /* the arpa internet */
+#define C_CHAOS 3 /* for chaos net at MIT */
+ /* Query class values which do not appear in resource records */
+#define C_ANY 255 /* wildcard match */
+
+/*
+ * Structure for query header, the order of the fields is machine and
+ * compiler dependent, in our case, the bits within a byte are assignd
+ * least significant first, while the order of transmition is most
+ * significant first. This requires a somewhat confusing rearrangement.
+ */
+
+typedef struct {
+ u_short id; /* query identification number */
+#if defined (sun) || defined (sel) || defined (pyr) || defined (is68k) \
+|| defined (tahoe) || defined (BIT_ZERO_ON_LEFT)
+ /* Bit zero on left: Gould and similar architectures */
+ /* fields in third byte */
+ u_char qr:1; /* response flag */
+ u_char opcode:4; /* purpose of message */
+ u_char aa:1; /* authoritive answer */
+ u_char tc:1; /* truncated message */
+ u_char rd:1; /* recursion desired */
+ /* fields in fourth byte */
+ u_char ra:1; /* recursion available */
+ u_char pr:1; /* primary server required (non standard) */
+ u_char unused:2; /* unused bits */
+ u_char rcode:4; /* response code */
+#else
+#if defined (vax) || defined (BIT_ZERO_ON_RIGHT)
+ /* Bit zero on right: VAX */
+ /* fields in third byte */
+ u_char rd:1; /* recursion desired */
+ u_char tc:1; /* truncated message */
+ u_char aa:1; /* authoritive answer */
+ u_char opcode:4; /* purpose of message */
+ u_char qr:1; /* response flag */
+ /* fields in fourth byte */
+ u_char rcode:4; /* response code */
+ u_char unused:2; /* unused bits */
+ u_char pr:1; /* primary server required (non standard) */
+ u_char ra:1; /* recursion available */
+#else
+ /* you must determine what the correct bit order is for your compiler */
+ UNDEFINED_BIT_ORDER;
+#endif
+#endif
+ /* remaining bytes */
+ u_short qdcount; /* number of question entries */
+ u_short ancount; /* number of answer entries */
+ u_short nscount; /* number of authority entries */
+ u_short arcount; /* number of resource entries */
+} HEADER;
+
+/*
+ * Defines for handling compressed domain names
+ */
+#define INDIR_MASK 0xc0
+
+/*
+ * Structure for passing resource records around.
+ */
+struct rrec {
+ short r_zone; /* zone number */
+ short r_class; /* class number */
+ short r_type; /* type number */
+ u_long r_ttl; /* time to live */
+ int r_size; /* size of data area */
+ char *r_data; /* pointer to data */
+};
+
+/*extern u_short getshort();*/
+/*extern u_long getlong();*/
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)telnet.h 5.1 (Berkeley) 5/30/85
+ */
+
+/*
+ * Definitions for the TELNET protocol.
+ */
+#define IAC 255 /* interpret as command: */
+#define DONT 254 /* you are not to use option */
+#define DO 253 /* please, you use option */
+#define WONT 252 /* I won't use option */
+#define WILL 251 /* I will use option */
+#define SB 250 /* interpret as subnegotiation */
+#define GA 249 /* you may reverse the line */
+#define EL 248 /* erase the current line */
+#define EC 247 /* erase the current character */
+#define AYT 246 /* are you there */
+#define AO 245 /* abort output--but let prog finish */
+#define IP 244 /* interrupt process--permanently */
+#define BREAK 243 /* break */
+#define DM 242 /* data mark--for connect. cleaning */
+#define NOP 241 /* nop */
+#define SE 240 /* end sub negotiation */
+#define EOR 239 /* end of record (transparent mode) */
+
+#define SYNCH 242 /* for telfunc calls */
+
+#ifdef TELCMDS
+char *telcmds[] = {
+ "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC",
+ "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC",
+};
+#endif
+
+/* telnet options */
+#define TELOPT_BINARY 0 /* 8-bit data path */
+#define TELOPT_ECHO 1 /* echo */
+#define TELOPT_RCP 2 /* prepare to reconnect */
+#define TELOPT_SGA 3 /* suppress go ahead */
+#define TELOPT_NAMS 4 /* approximate message size */
+#define TELOPT_STATUS 5 /* give status */
+#define TELOPT_TM 6 /* timing mark */
+#define TELOPT_RCTE 7 /* remote controlled transmission and echo */
+#define TELOPT_NAOL 8 /* negotiate about output line width */
+#define TELOPT_NAOP 9 /* negotiate about output page size */
+#define TELOPT_NAOCRD 10 /* negotiate about CR disposition */
+#define TELOPT_NAOHTS 11 /* negotiate about horizontal tabstops */
+#define TELOPT_NAOHTD 12 /* negotiate about horizontal tab disposition */
+#define TELOPT_NAOFFD 13 /* negotiate about formfeed disposition */
+#define TELOPT_NAOVTS 14 /* negotiate about vertical tab stops */
+#define TELOPT_NAOVTD 15 /* negotiate about vertical tab disposition */
+#define TELOPT_NAOLFD 16 /* negotiate about output LF disposition */
+#define TELOPT_XASCII 17 /* extended ascic character set */
+#define TELOPT_LOGOUT 18 /* force logout */
+#define TELOPT_BM 19 /* byte macro */
+#define TELOPT_DET 20 /* data entry terminal */
+#define TELOPT_SUPDUP 21 /* supdup protocol */
+#define TELOPT_SUPDUPOUTPUT 22 /* supdup output */
+#define TELOPT_SNDLOC 23 /* send location */
+#define TELOPT_TTYPE 24 /* terminal type */
+#define TELOPT_EOR 25 /* end or record */
+#define TELOPT_EXOPL 255 /* extended-options-list */
+
+#ifdef TELOPTS
+#define NTELOPTS (1+TELOPT_EOR)
+char *telopts[NTELOPTS] = {
+ "BINARY", "ECHO", "RCP", "SUPPRESS GO AHEAD", "NAME",
+ "STATUS", "TIMING MARK", "RCTE", "NAOL", "NAOP",
+ "NAOCRD", "NAOHTS", "NAOHTD", "NAOFFD", "NAOVTS",
+ "NAOVTD", "NAOLFD", "EXTEND ASCII", "LOGOUT", "BYTE MACRO",
+ "DATA ENTRY TERMINAL", "SUPDUP", "SUPDUP OUTPUT",
+ "SEND LOCATION", "TERMINAL TYPE", "END OF RECORD",
+};
+#endif
+
+/* sub-option qualifiers */
+#define TELQUAL_IS 0 /* option is... */
+#define TELQUAL_SEND 1 /* send option */
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tftp.h 5.1 (Berkeley) 5/30/85
+ */
+
+/*
+ * Trivial File Transfer Protocol (IEN-133)
+ */
+#define SEGSIZE 512 /* data segment size */
+
+/*
+ * Packet types.
+ */
+#define RRQ 01 /* read request */
+#define WRQ 02 /* write request */
+#define DATA 03 /* data packet */
+#define ACK 04 /* acknowledgement */
+#define ERROR 05 /* error code */
+
+struct tftphdr {
+ short th_opcode; /* packet type */
+ union {
+ short tu_block; /* block # */
+ short tu_code; /* error code */
+ char tu_stuff[1]; /* request packet stuff */
+ } th_u;
+ char th_data[1]; /* data or error string */
+};
+
+#define th_block th_u.tu_block
+#define th_code th_u.tu_code
+#define th_stuff th_u.tu_stuff
+#define th_msg th_data
+
+/*
+ * Error codes.
+ */
+#define EUNDEF 0 /* not defined */
+#define ENOTFOUND 1 /* file not found */
+#define EACCESS 2 /* access violation */
+#define ENOSPACE 3 /* disk full or allocation exceeded */
+#define EBADOP 4 /* illegal TFTP operation */
+#define EBADID 5 /* unknown transfer ID */
+#define EEXISTS 6 /* file already exists */
+#define ENOUSER 7 /* no such user */
--- /dev/null
+/* assert.h 4.2 85/01/21 */
+
+/*# ifndef NDEBUG*/
+# define _assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file \"%s\", line %d\n", __FILE__, __LINE__);exit(1);}}
+# define assert(ex) _assert(ex)
+# else
+# define _assert(ex)
+# define assert(ex)
+/*# endif*/
--- /dev/null
+/* ctype.h 4.2 85/09/04 */
+
+#define _U 01
+#define _L 02
+#define _N 04
+#define _S 010
+#define _P 020
+#define _C 040
+#define _X 0100
+#define _B 0200
+
+extern char _ctype_[];
+
+#define isalpha(c) ((_ctype_+1)[c]&(_U|_L))
+#define isupper(c) ((_ctype_+1)[c]&_U)
+#define islower(c) ((_ctype_+1)[c]&_L)
+#define isdigit(c) ((_ctype_+1)[c]&_N)
+#define isxdigit(c) ((_ctype_+1)[c]&(_N|_X))
+#define isspace(c) ((_ctype_+1)[c]&_S)
+#define ispunct(c) ((_ctype_+1)[c]&_P)
+#define isalnum(c) ((_ctype_+1)[c]&(_U|_L|_N))
+#define isprint(c) ((_ctype_+1)[c]&(_P|_U|_L|_N|_B))
+#define isgraph(c) ((_ctype_+1)[c]&(_P|_U|_L|_N))
+#define iscntrl(c) ((_ctype_+1)[c]&_C)
+#define isascii(c) ((unsigned)(c)<=0177)
+#define toupper(c) ((c)-'a'+'A')
+#define tolower(c) ((c)-'A'+'a')
+#define toascii(c) ((c)&0177)
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)disktab.h 5.2 (Berkeley) 10/1/85
+ */
+
+/*
+ * Disk description table, see disktab(5)
+ */
+#define DISKTAB "/etc/disktab"
+
+struct disktab {
+ char *d_name; /* drive name */
+ char *d_type; /* drive type */
+ int d_secsize; /* sector size in bytes */
+ int d_ntracks; /* # tracks/cylinder */
+ int d_nsectors; /* # sectors/track */
+ int d_ncylinders; /* # cylinders */
+ int d_rpm; /* revolutions/minute */
+ int d_badsectforw; /* supports DEC bad144 std */
+ int d_sectoffset; /* use sect rather than cyl offsets */
+ struct partition {
+ int p_size; /* #sectors in partition */
+ short p_bsize; /* block size in bytes */
+ short p_fsize; /* frag size in bytes */
+ } d_partitions[8];
+};
+
+/*struct disktab *getdiskbyname();*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)errno.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Error codes
+ */
+
+#define EPERM 1 /* Not owner */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* I/O error */
+#define ENXIO 6 /* No such device or address */
+#define E2BIG 7 /* Arg list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file number */
+#define ECHILD 10 /* No children */
+#define EAGAIN 11 /* No more processes */
+#define ENOMEM 12 /* Not enough core */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Mount device busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* No such device */
+#define ENOTDIR 20 /* Not a directory*/
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* File table overflow */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Not a typewriter */
+#define ETXTBSY 26 /* Text file busy */
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+
+/* math software */
+#define EDOM 33 /* Argument too large */
+#define ERANGE 34 /* Result too large */
+
+/* non-blocking and interrupt i/o */
+#define EWOULDBLOCK 35 /* Operation would block */
+#define EDEADLK EWOULDBLOCK /* ditto */
+#define EINPROGRESS 36 /* Operation now in progress */
+#define EALREADY 37 /* Operation already in progress */
+
+/* ipc/network software */
+
+ /* argument errors */
+#define ENOTSOCK 38 /* Socket operation on non-socket */
+#define EDESTADDRREQ 39 /* Destination address required */
+#define EMSGSIZE 40 /* Message too long */
+#define EPROTOTYPE 41 /* Protocol wrong type for socket */
+#define ENOPROTOOPT 42 /* Protocol not available */
+#define EPROTONOSUPPORT 43 /* Protocol not supported */
+#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
+#define EOPNOTSUPP 45 /* Operation not supported on socket */
+#define EPFNOSUPPORT 46 /* Protocol family not supported */
+#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
+#define EADDRINUSE 48 /* Address already in use */
+#define EADDRNOTAVAIL 49 /* Can't assign requested address */
+
+ /* operational errors */
+#define ENETDOWN 50 /* Network is down */
+#define ENETUNREACH 51 /* Network is unreachable */
+#define ENETRESET 52 /* Network dropped connection on reset */
+#define ECONNABORTED 53 /* Software caused connection abort */
+#define ECONNRESET 54 /* Connection reset by peer */
+#define ENOBUFS 55 /* No buffer space available */
+#define EISCONN 56 /* Socket is already connected */
+#define ENOTCONN 57 /* Socket is not connected */
+#define ESHUTDOWN 58 /* Can't send after socket shutdown */
+#define ETOOMANYREFS 59 /* Too many references: can't splice */
+#define ETIMEDOUT 60 /* Connection timed out */
+#define ECONNREFUSED 61 /* Connection refused */
+
+ /* */
+#define ELOOP 62 /* Too many levels of symbolic links */
+#define ENAMETOOLONG 63 /* File name too long */
+
+/* should be rearranged */
+#define EHOSTDOWN 64 /* Host is down */
+#define EHOSTUNREACH 65 /* No route to host */
+#define ENOTEMPTY 66 /* Directory not empty */
+
+/* quotas & mush */
+#define EPROCLIM 67 /* Too many processes */
+#define EUSERS 68 /* Too many users */
+#define EDQUOT 69 /* Disc quota exceeded */
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)fcntl.h 5.2 (Berkeley) 1/8/86
+ */
+
+/*
+ * Flag values accessible to open(2) and fcntl(2)-- copied from
+ * <sys/file.h>. (The first three can only be set by open.)
+ */
+#define O_RDONLY 000 /* open for reading */
+#define O_WRONLY 001 /* open for writing */
+#define O_RDWR 002 /* open for read & write */
+#define O_NDELAY FNDELAY /* non-blocking open */
+ /* really non-blocking I/O for fcntl */
+#define O_APPEND FAPPEND /* append on each write */
+#define O_CREAT FCREAT /* open with file create */
+#define O_TRUNC FTRUNC /* open with truncation */
+#define O_EXCL FEXCL /* error on create if file exists */
+
+#ifndef F_DUPFD
+/* fcntl(2) requests */
+#define F_DUPFD 0 /* Duplicate fildes */
+#define F_GETFD 1 /* Get fildes flags */
+#define F_SETFD 2 /* Set fildes flags */
+#define F_GETFL 3 /* Get file flags */
+#define F_SETFL 4 /* Set file flags */
+#define F_GETOWN 5 /* Get owner */
+#define F_SETOWN 6 /* Set owner */
+
+/* flags for F_GETFL, F_SETFL-- copied from <sys/file.h> */
+#define FNDELAY 00004 /* non-blocking reads */
+#define FAPPEND 00010 /* append on each write */
+#define FASYNC 00100 /* signal pgrp when data ready */
+#define FCREAT 01000 /* create if nonexistant */
+#define FTRUNC 02000 /* truncate to zero length */
+#define FEXCL 04000 /* error if already created */
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)frame.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Definition of the vax calls/callg frame.
+ */
+struct frame {
+ int fr_handler;
+ u_int fr_psw:16, /* saved psw */
+ fr_mask:12, /* register save mask */
+ :1,
+ fr_s:1, /* call was a calls, not callg */
+ fr_spa:2; /* stack pointer alignment */
+ int fr_savap; /* saved arg pointer */
+ int fr_savfp; /* saved frame pointer */
+ int fr_savpc; /* saved program counter */
+};
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)fstab.h 5.1 (Berkeley) 5/30/85
+ */
+
+/*
+ * File system table, see fstab (5)
+ *
+ * Used by dump, mount, umount, swapon, fsck, df, ...
+ *
+ * The fs_spec field is the block special name. Programs
+ * that want to use the character special name must create
+ * that name by prepending a 'r' after the right most slash.
+ * Quota files are always named "quotas", so if type is "rq",
+ * then use concatenation of fs_file and "quotas" to locate
+ * quota file.
+ */
+#define FSTAB "/etc/fstab"
+
+#define FSTAB_RW "rw" /* read/write device */
+#define FSTAB_RQ "rq" /* read/write with quotas */
+#define FSTAB_RO "ro" /* read-only device */
+#define FSTAB_SW "sw" /* swap device */
+#define FSTAB_XX "xx" /* ignore totally */
+
+struct fstab{
+ char *fs_spec; /* block special device name */
+ char *fs_file; /* file system path prefix */
+ char *fs_type; /* FSTAB_* */
+ int fs_freq; /* dump frequency, in days */
+ int fs_passno; /* pass number on parallel dump */
+};
+
+/*struct fstab *getfsent();*/
+/*struct fstab *getfsspec();*/
+/*struct fstab *getfsfile();*/
+/*struct fstab *getfstype();*/
+/*int setfsent();*/
+/*int endfsent();*/
--- /dev/null
+/* grp.h 4.1 83/05/03 */
+
+struct group { /* see getgrent(3) */
+ char *gr_name;
+ char *gr_passwd;
+ int gr_gid;
+ char **gr_mem;
+};
+
+/*struct group *getgrent(), *getgrgid(), *getgrnam();*/
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)lastlog.h 5.1 (Berkeley) 5/30/85
+ */
+
+struct lastlog {
+ time_t ll_time;
+ char ll_line[8];
+ char ll_host[16]; /* same as in utmp */
+};
--- /dev/null
+vax
\ No newline at end of file
--- /dev/null
+/* math.h 4.6 9/11/85 */
+
+/*extern double asinh(), acosh(), atanh();*/
+/*extern double erf(), erfc();*/
+/*extern double exp(), expm1(), log(), log10(), log1p(), pow();*/
+/*extern double fabs(), floor(), ceil(), rint();*/
+/*extern double lgamma();*/
+/*extern double hypot(), cabs();*/
+/*extern double copysign(), drem(), logb(), scalb();*/
+/*extern int finite();*/
+#ifdef vax
+/*extern double infnan();*/
+#endif
+/*extern double j0(), j1(), jn(), y0(), y1(), yn();*/
+/*extern double sin(), cos(), tan(), asin(), acos(), atan(), atan2();*/
+/*extern double sinh(), cosh(), tanh();*/
+/*extern double cbrt(), sqrt();*/
+/*extern double modf(), ldexp(), frexp(), atof();*/
+
+#define HUGE 1.701411733192644270e38
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)memory.h 5.1 (Berkeley) 85/08/05
+ */
+
+/*
+ * Definitions of the Sys5 compat memory manipulation routines
+ */
+
+/*extern char *memccpy();*/
+/*extern char *memchr();*/
+/*extern int memcmp();*/
+/*extern char *memcpy();*/
+/*extern char *memset();*/
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)mp.h 5.1 (Berkeley) 5/30/85
+ */
+
+#define MINT struct mint
+MINT
+{ int len;
+ short *val;
+};
+#define FREE(x) {if(x.len!=0) {free((char *)x.val); x.len=0;}}
+#ifndef DBG
+#define shfree(u) free((char *)u)
+#else
+/*#include <stdio.h>*/
+#define shfree(u) { if(dbg) fprintf(stderr, "free %o\n", u); free((char *)u);}
+extern int dbg;
+#endif
+#ifndef vax
+struct half
+{ short high;
+ short low;
+};
+#else
+struct half
+{ short low;
+ short high;
+};
+#endif
+/*extern MINT *itom();*/
+/*extern short *xalloc();*/
+
+#ifdef lint
+extern xv_oid;
+#define VOID xv_oid =
+#else
+#define VOID
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)mtab.h 5.1 (Berkeley) 5/30/85
+ */
+
+/*
+ * Mounted device accounting file.
+ */
+struct mtab {
+ char m_path[32]; /* mounted on pathname */
+ char m_dname[32]; /* block device pathname */
+ char m_type[4]; /* read-only, quotas */
+};
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ndbm.h 5.1 (Berkeley) 5/30/85
+ */
+
+/*
+ * Hashed key data base library.
+ */
+#define PBLKSIZ 1024
+#define DBLKSIZ 4096
+
+typedef struct {
+ int dbm_dirf; /* open directory file */
+ int dbm_pagf; /* open page file */
+ int dbm_flags; /* flags, see below */
+ long dbm_maxbno; /* last ``bit'' in dir file */
+ long dbm_bitno; /* current bit number */
+ long dbm_hmask; /* hash mask */
+ long dbm_blkptr; /* current block for dbm_nextkey */
+ int dbm_keyptr; /* current key for dbm_nextkey */
+ long dbm_blkno; /* current page to read/write */
+ long dbm_pagbno; /* current page in pagbuf */
+ char dbm_pagbuf[PBLKSIZ]; /* page file block buffer */
+ long dbm_dirbno; /* current block in dirbuf */
+ char dbm_dirbuf[DBLKSIZ]; /* directory file block buffer */
+} DBM;
+
+#define _DBM_RDONLY 0x1 /* data base open read-only */
+#define _DBM_IOERR 0x2 /* data base I/O error */
+
+#define dbm_rdonly(db) ((db)->dbm_flags & _DBM_RDONLY)
+
+#define dbm_error(db) ((db)->dbm_flags & _DBM_IOERR)
+ /* use this one at your own risk! */
+#define dbm_clearerr(db) ((db)->dbm_flags &= ~_DBM_IOERR)
+
+/* for flock(2) and fstat(2) */
+#define dbm_dirfno(db) ((db)->dbm_dirf)
+#define dbm_pagfno(db) ((db)->dbm_pagf)
+
+typedef struct {
+ char *dptr;
+ int dsize;
+} datum;
+
+/*
+ * flags to dbm_store()
+ */
+#define DBM_INSERT 0
+#define DBM_REPLACE 1
+
+/*DBM *dbm_open();*/
+/*void dbm_close();*/
+/*datum dbm_fetch();*/
+/*datum dbm_firstkey();*/
+/*datum dbm_nextkey();*/
+/*long dbm_forder();*/
+/*int dbm_delete();*/
+/*int dbm_store();*/
--- /dev/null
+/*
+ * Copyright (c) 1980, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)af.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Address family routines,
+ * used in handling generic sockaddr structures.
+ *
+ * Hash routine is called
+ * af_hash(addr, h);
+ * struct sockaddr *addr; struct afhash *h;
+ * producing an afhash structure for addr.
+ *
+ * Netmatch routine is called
+ * af_netmatch(addr1, addr2);
+ * where addr1 and addr2 are sockaddr *. Returns 1 if network
+ * values match, 0 otherwise.
+ */
+struct afswitch {
+/* int (*af_hash)();*/
+/* int (*af_netmatch)();*/
+};
+
+struct afhash {
+ u_int afh_hosthash;
+ u_int afh_nethash;
+};
+
+#ifdef KERNEL
+struct afswitch afswitch[];
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Structures defining a network interface, providing a packet
+ * transport mechanism (ala level 0 of the PUP protocols).
+ *
+ * Each interface accepts output datagrams of a specified maximum
+ * length, and provides higher level routines with input datagrams
+ * received from its medium.
+ *
+ * Output occurs when the routine if_output is called, with three parameters:
+ * (*ifp->if_output)(ifp, m, dst)
+ * Here m is the mbuf chain to be sent and dst is the destination address.
+ * The output routine encapsulates the supplied datagram if necessary,
+ * and then transmits it on its medium.
+ *
+ * On input, each interface unwraps the data received by it, and either
+ * places it on the input queue of a internetwork datagram routine
+ * and posts the associated software interrupt, or passes the datagram to a raw
+ * packet input routine.
+ *
+ * Routines exist for locating interfaces by their addresses
+ * or for locating a interface on a certain network, as well as more general
+ * routing and gateway routines maintaining information used to locate
+ * interfaces. These routines live in the files if.c and route.c
+ */
+
+/*
+ * Structure defining a queue for a network interface.
+ *
+ * (Would like to call this struct ``if'', but C isn't PL/1.)
+ */
+struct ifnet {
+ char *if_name; /* name, e.g. ``en'' or ``lo'' */
+ short if_unit; /* sub-unit for lower level driver */
+ short if_mtu; /* maximum transmission unit */
+ short if_flags; /* up/down, broadcast, etc. */
+ short if_timer; /* time 'til if_watchdog called */
+ int if_metric; /* routing metric (external only) */
+ struct ifaddr *if_addrlist; /* linked list of addresses per if */
+ struct ifqueue {
+ struct mbuf *ifq_head;
+ struct mbuf *ifq_tail;
+ int ifq_len;
+ int ifq_maxlen;
+ int ifq_drops;
+ } if_snd; /* output queue */
+/* procedure handles */
+/* int (*if_init)();*/ /* init routine */
+/* int (*if_output)();*/ /* output routine */
+/* int (*if_ioctl)();*/ /* ioctl routine */
+/* int (*if_reset)();*/ /* bus reset routine */
+/* int (*if_watchdog)();*/ /* timer routine */
+/* generic interface statistics */
+ int if_ipackets; /* packets received on interface */
+ int if_ierrors; /* input errors on interface */
+ int if_opackets; /* packets sent on interface */
+ int if_oerrors; /* output errors on interface */
+ int if_collisions; /* collisions on csma interfaces */
+/* end statistics */
+ struct ifnet *if_next;
+};
+
+#define IFF_UP 0x1 /* interface is up */
+#define IFF_BROADCAST 0x2 /* broadcast address valid */
+#define IFF_DEBUG 0x4 /* turn on debugging */
+#define IFF_LOOPBACK 0x8 /* is a loopback net */
+#define IFF_POINTOPOINT 0x10 /* interface is point-to-point link */
+#define IFF_NOTRAILERS 0x20 /* avoid use of trailers */
+#define IFF_RUNNING 0x40 /* resources allocated */
+#define IFF_NOARP 0x80 /* no address resolution protocol */
+/* next two not supported now, but reserved: */
+#define IFF_PROMISC 0x100 /* receive all packets */
+#define IFF_ALLMULTI 0x200 /* receive all multicast packets */
+/* flags set internally only: */
+#define IFF_CANTCHANGE (IFF_BROADCAST | IFF_POINTOPOINT | IFF_RUNNING)
+
+/*
+ * Output queues (ifp->if_snd) and internetwork datagram level (pup level 1)
+ * input routines have queues of messages stored on ifqueue structures
+ * (defined above). Entries are added to and deleted from these structures
+ * by these macros, which should be called with ipl raised to splimp().
+ */
+#define IF_QFULL(ifq) ((ifq)->ifq_len >= (ifq)->ifq_maxlen)
+#define IF_DROP(ifq) ((ifq)->ifq_drops++)
+#define IF_ENQUEUE(ifq, m) { \
+ (m)->m_act = 0; \
+ if ((ifq)->ifq_tail == 0) \
+ (ifq)->ifq_head = m; \
+ else \
+ (ifq)->ifq_tail->m_act = m; \
+ (ifq)->ifq_tail = m; \
+ (ifq)->ifq_len++; \
+}
+#define IF_PREPEND(ifq, m) { \
+ (m)->m_act = (ifq)->ifq_head; \
+ if ((ifq)->ifq_tail == 0) \
+ (ifq)->ifq_tail = (m); \
+ (ifq)->ifq_head = (m); \
+ (ifq)->ifq_len++; \
+}
+/*
+ * Packets destined for level-1 protocol input routines
+ * have a pointer to the receiving interface prepended to the data.
+ * IF_DEQUEUEIF extracts and returns this pointer when dequeueing the packet.
+ * IF_ADJ should be used otherwise to adjust for its presence.
+ */
+#define IF_ADJ(m) { \
+ (m)->m_off += sizeof(struct ifnet *); \
+ (m)->m_len -= sizeof(struct ifnet *); \
+ if ((m)->m_len == 0) { \
+ struct mbuf *n; \
+ MFREE((m), n); \
+ (m) = n; \
+ } \
+}
+#define IF_DEQUEUEIF(ifq, m, ifp) { \
+ (m) = (ifq)->ifq_head; \
+ if (m) { \
+ if (((ifq)->ifq_head = (m)->m_act) == 0) \
+ (ifq)->ifq_tail = 0; \
+ (m)->m_act = 0; \
+ (ifq)->ifq_len--; \
+ (ifp) = *(mtod((m), struct ifnet **)); \
+ IF_ADJ(m); \
+ } \
+}
+#define IF_DEQUEUE(ifq, m) { \
+ (m) = (ifq)->ifq_head; \
+ if (m) { \
+ if (((ifq)->ifq_head = (m)->m_act) == 0) \
+ (ifq)->ifq_tail = 0; \
+ (m)->m_act = 0; \
+ (ifq)->ifq_len--; \
+ } \
+}
+
+#define IFQ_MAXLEN 50
+#define IFNET_SLOWHZ 1 /* granularity is 1 second */
+
+/*
+ * The ifaddr structure contains information about one address
+ * of an interface. They are maintained by the different address families,
+ * are allocated and attached when an address is set, and are linked
+ * together so all addresses for an interface can be located.
+ */
+struct ifaddr {
+ struct sockaddr ifa_addr; /* address of interface */
+ union {
+ struct sockaddr ifu_broadaddr;
+ struct sockaddr ifu_dstaddr;
+ } ifa_ifu;
+#define ifa_broadaddr ifa_ifu.ifu_broadaddr /* broadcast address */
+#define ifa_dstaddr ifa_ifu.ifu_dstaddr /* other end of p-to-p link */
+ struct ifnet *ifa_ifp; /* back-pointer to interface */
+ struct ifaddr *ifa_next; /* next address for interface */
+};
+
+/*
+ * Interface request structure used for socket
+ * ioctl's. All interface ioctl's must have parameter
+ * definitions which begin with ifr_name. The
+ * remainder may be interface specific.
+ */
+struct ifreq {
+#define IFNAMSIZ 16
+ char ifr_name[IFNAMSIZ]; /* if name, e.g. "en0" */
+ union {
+ struct sockaddr ifru_addr;
+ struct sockaddr ifru_dstaddr;
+ struct sockaddr ifru_broadaddr;
+ short ifru_flags;
+ int ifru_metric;
+ caddr_t ifru_data;
+ } ifr_ifru;
+#define ifr_addr ifr_ifru.ifru_addr /* address */
+#define ifr_dstaddr ifr_ifru.ifru_dstaddr /* other end of p-to-p link */
+#define ifr_broadaddr ifr_ifru.ifru_broadaddr /* broadcast address */
+#define ifr_flags ifr_ifru.ifru_flags /* flags */
+#define ifr_metric ifr_ifru.ifru_metric /* metric */
+#define ifr_data ifr_ifru.ifru_data /* for use by interface */
+};
+
+/*
+ * Structure used in SIOCGIFCONF request.
+ * Used to retrieve interface configuration
+ * for machine (useful for programs which
+ * must know all networks accessible).
+ */
+struct ifconf {
+ int ifc_len; /* size of associated buffer */
+ union {
+ caddr_t ifcu_buf;
+ struct ifreq *ifcu_req;
+ } ifc_ifcu;
+#define ifc_buf ifc_ifcu.ifcu_buf /* buffer address */
+#define ifc_req ifc_ifcu.ifcu_req /* array of structures returned */
+};
+
+#ifdef KERNEL
+/*#include "../net/if_arp.h"*/
+struct ifqueue rawintrq; /* raw packet input queue */
+struct ifnet *ifnet;
+/*struct ifaddr *ifa_ifwithaddr(), *ifa_ifwithnet();*/
+/*struct ifaddr *ifa_ifwithdstaddr();*/
+#else KERNEL
+/*#include <net/if_arp.h>*/
+#endif KERNEL
--- /dev/null
+/*
+ * Copyright (c) 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_arp.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Address Resolution Protocol.
+ *
+ * See RFC 826 for protocol description. ARP packets are variable
+ * in size; the arphdr structure defines the fixed-length portion.
+ * Protocol type values are the same as those for 10 Mb/s Ethernet.
+ * It is followed by the variable-sized fields ar_sha, arp_spa,
+ * arp_tha and arp_tpa in that order, according to the lengths
+ * specified. Field names used correspond to RFC 826.
+ */
+struct arphdr {
+ u_short ar_hrd; /* format of hardware address */
+#define ARPHRD_ETHER 1 /* ethernet hardware address */
+ u_short ar_pro; /* format of protocol address */
+ u_char ar_hln; /* length of hardware address */
+ u_char ar_pln; /* length of protocol address */
+ u_short ar_op; /* one of: */
+#define ARPOP_REQUEST 1 /* request to resolve address */
+#define ARPOP_REPLY 2 /* response to previous request */
+/*
+ * The remaining fields are variable in size,
+ * according to the sizes above.
+ */
+/* u_char ar_sha[]; /* sender hardware address */
+/* u_char ar_spa[]; /* sender protocol address */
+/* u_char ar_tha[]; /* target hardware address */
+/* u_char ar_tpa[]; /* target protocol address */
+};
+
+/*
+ * ARP ioctl request
+ */
+struct arpreq {
+ struct sockaddr arp_pa; /* protocol address */
+ struct sockaddr arp_ha; /* hardware address */
+ int arp_flags; /* flags */
+};
+/* arp_flags and at_flags field values */
+#define ATF_INUSE 0x01 /* entry in use */
+#define ATF_COM 0x02 /* completed entry (enaddr valid) */
+#define ATF_PERM 0x04 /* permanent entry */
+#define ATF_PUBL 0x08 /* publish entry (respond for other host) */
+#define ATF_USETRAILERS 0x10 /* has requested trailers */
--- /dev/null
+/*
+ * Copyright (c) 1980, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)netisr.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * The networking code runs off software interrupts.
+ *
+ * You can switch into the network by doing splnet() and return by splx().
+ * The software interrupt level for the network is higher than the software
+ * level for the clock (so you can enter the network in routines called
+ * at timeout time).
+ */
+#ifdef vax
+#define setsoftnet() mtpr(SIRR, 12)
+#endif
+
+/*
+ * Each ``pup-level-1'' input queue has a bit in a ``netisr'' status
+ * word which is used to de-multiplex a single software
+ * interrupt used for scheduling the network code to calls
+ * on the lowest level routine of each protocol.
+ */
+#define NETISR_RAW 0 /* same as AF_UNSPEC */
+#define NETISR_IP 2 /* same as AF_INET */
+#define NETISR_IMP 3 /* same as AF_IMPLINK */
+#define NETISR_NS 6 /* same as AF_NS */
+
+/*#define schednetisr(anisr) { netisr |= 1<<(anisr); setsoftnet();*/ }
+
+#ifndef LOCORE
+#ifdef KERNEL
+int netisr; /* scheduling bits for network */
+#endif
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1980, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)raw_cb.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Raw protocol interface control block. Used
+ * to tie a socket to the generic raw interface.
+ */
+struct rawcb {
+ struct rawcb *rcb_next; /* doubly linked list */
+ struct rawcb *rcb_prev;
+ struct socket *rcb_socket; /* back pointer to socket */
+ struct sockaddr rcb_faddr; /* destination address */
+ struct sockaddr rcb_laddr; /* socket's address */
+ struct sockproto rcb_proto; /* protocol family, protocol */
+ caddr_t rcb_pcb; /* protocol specific stuff */
+ struct mbuf *rcb_options; /* protocol specific options */
+ struct route rcb_route; /* routing information */
+ short rcb_flags;
+};
+
+/*
+ * Since we can't interpret canonical addresses,
+ * we mark an address present in the flags field.
+ */
+#define RAW_LADDR 01
+#define RAW_FADDR 02
+#define RAW_DONTROUTE 04 /* no routing, default */
+
+#define sotorawcb(so) ((struct rawcb *)(so)->so_pcb)
+
+/*
+ * Nominal space allocated to a raw socket.
+ */
+#define RAWSNDQ 2048
+#define RAWRCVQ 2048
+
+/*
+ * Format of raw interface header prepended by
+ * raw_input after call from protocol specific
+ * input routine.
+ */
+struct raw_header {
+ struct sockproto raw_proto; /* format of packet */
+ struct sockaddr raw_dst; /* dst address for rawintr */
+ struct sockaddr raw_src; /* src address for sbappendaddr */
+};
+
+#ifdef KERNEL
+struct rawcb rawcb; /* head of list */
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1980, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)route.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Kernel resident routing tables.
+ *
+ * The routing tables are initialized when interface addresses
+ * are set by making entries for all directly connected interfaces.
+ */
+
+/*
+ * A route consists of a destination address and a reference
+ * to a routing entry. These are often held by protocols
+ * in their control blocks, e.g. inpcb.
+ */
+struct route {
+ struct rtentry *ro_rt;
+ struct sockaddr ro_dst;
+};
+
+/*
+ * We distinguish between routes to hosts and routes to networks,
+ * preferring the former if available. For each route we infer
+ * the interface to use from the gateway address supplied when
+ * the route was entered. Routes that forward packets through
+ * gateways are marked so that the output routines know to address the
+ * gateway rather than the ultimate destination.
+ */
+struct rtentry {
+ u_long rt_hash; /* to speed lookups */
+ struct sockaddr rt_dst; /* key */
+ struct sockaddr rt_gateway; /* value */
+ short rt_flags; /* up/down?, host/net */
+ short rt_refcnt; /* # held references */
+ u_long rt_use; /* raw # packets forwarded */
+ struct ifnet *rt_ifp; /* the answer: interface to use */
+};
+
+#define RTF_UP 0x1 /* route useable */
+#define RTF_GATEWAY 0x2 /* destination is a gateway */
+#define RTF_HOST 0x4 /* host entry (net otherwise) */
+#define RTF_DYNAMIC 0x10 /* created dynamically (by redirect) */
+
+/*
+ * Routing statistics.
+ */
+struct rtstat {
+ short rts_badredirect; /* bogus redirect calls */
+ short rts_dynamic; /* routes created by redirects */
+ short rts_newgateway; /* routes modified by redirects */
+ short rts_unreach; /* lookups which failed */
+ short rts_wildcard; /* lookups satisfied by a wildcard */
+};
+
+#ifdef KERNEL
+#define RTFREE(rt) \
+ if ((rt)->rt_refcnt == 1) \
+ rtfree(rt); \
+ else \
+ (rt)->rt_refcnt--;
+
+#ifdef GATEWAY
+#define RTHASHSIZ 64
+#else
+#define RTHASHSIZ 8
+#endif
+#if (RTHASHSIZ & (RTHASHSIZ - 1)) == 0
+#define RTHASHMOD(h) ((h) & (RTHASHSIZ - 1))
+#else
+#define RTHASHMOD(h) ((h) % RTHASHSIZ)
+#endif
+struct mbuf *rthost[RTHASHSIZ];
+struct mbuf *rtnet[RTHASHSIZ];
+struct rtstat rtstat;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)netdb.h 5.7 (Berkeley) 5/12/86
+ */
+
+/*
+ * Structures returned by network
+ * data base library. All addresses
+ * are supplied in host order, and
+ * returned in network order (suitable
+ * for use in system calls).
+ */
+struct hostent {
+ char *h_name; /* official name of host */
+ char **h_aliases; /* alias list */
+ int h_addrtype; /* host address type */
+ int h_length; /* length of address */
+ char **h_addr_list; /* list of addresses from name server */
+#define h_addr h_addr_list[0] /* address, for backward compatiblity */
+};
+
+/*
+ * Assumption here is that a network number
+ * fits in 32 bits -- probably a poor one.
+ */
+struct netent {
+ char *n_name; /* official name of net */
+ char **n_aliases; /* alias list */
+ int n_addrtype; /* net address type */
+ unsigned long n_net; /* network # */
+};
+
+struct servent {
+ char *s_name; /* official service name */
+ char **s_aliases; /* alias list */
+ int s_port; /* port # */
+ char *s_proto; /* protocol to use */
+};
+
+struct protoent {
+ char *p_name; /* official protocol name */
+ char **p_aliases; /* alias list */
+ int p_proto; /* protocol # */
+};
+
+/*struct hostent *gethostbyname(), *gethostbyaddr(), *gethostent();*/
+/*struct netent *getnetbyname(), *getnetbyaddr(), *getnetent();*/
+/*struct servent *getservbyname(), *getservbyport(), *getservent();*/
+/*struct protoent *getprotobyname(), *getprotobynumber(), *getprotoent();*/
+
+/*
+ * Error return codes from gethostbyname() and gethostbyaddr()
+ */
+
+extern int h_errno;
+
+#define HOST_NOT_FOUND 1 /* Authoritive Answer Host not found */
+#define TRY_AGAIN 2 /* Non-Authoritive Host not found, or SERVERFAIL */
+#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
+#define NO_ADDRESS 4 /* Valid host name, no address, look for MX record */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_imp.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Structure of IMP 1822 long leader.
+ */
+struct control_leader {
+ u_char dl_format; /* leader format */
+ u_char dl_network; /* src/dest network */
+ u_char dl_flags; /* leader flags */
+ u_char dl_mtype; /* message type */
+ u_char dl_htype; /* handling type */
+ u_char dl_host; /* host number */
+ u_short dl_imp; /* imp field */
+ u_char dl_link; /* link number */
+ u_char dl_subtype; /* message subtype */
+};
+
+struct imp_leader {
+ struct control_leader il_dl;
+#define il_format il_dl.dl_format
+#define il_network il_dl.dl_network
+#define il_flags il_dl.dl_flags
+#define il_mtype il_dl.dl_mtype
+#define il_htype il_dl.dl_htype
+#define il_host il_dl.dl_host
+#define il_imp il_dl.dl_imp
+#define il_link il_dl.dl_link
+#define il_subtype il_dl.dl_subtype
+ u_short il_length; /* message length */
+};
+
+#define IMP_DROPCNT 2 /* # of noops from imp to ignore */
+/* insure things are even... */
+#define IMPMTU ((8159 / NBBY) & ~01)
+
+/*
+ * IMP-host flags
+ */
+#define IMP_NFF 0xf /* 96-bit (new) format */
+#define IMP_TRACE 0x8 /* trace message route */
+
+#define IMP_DMASK 0x3 /* host going down mask */
+
+/*
+ * IMP-host message types.
+ */
+#define IMPTYPE_DATA 0 /* data for protocol */
+#define IMPTYPE_BADLEADER 1 /* leader error */
+#define IMPTYPE_DOWN 2 /* imp going down */
+#define IMPTYPE_NOOP 4 /* noop seen during initialization */
+#define IMPTYPE_RFNM 5 /* request for new messages */
+#define IMPTYPE_HOSTDEAD 6 /* host doesn't respond */
+#define IMPTYPE_HOSTUNREACH 7 /* host unreachable */
+#define IMPTYPE_BADDATA 8 /* data error */
+#define IMPTYPE_INCOMPLETE 9 /* incomplete message, send rest */
+#define IMPTYPE_RESET 10 /* reset complete */
+/* non-blocking IMP interface */
+#define IMPTYPE_RETRY 11 /* IMP refused, try again */
+#define IMPTYPE_NOTIFY 12 /* IMP refused, will notify */
+#define IMPTYPE_TRYING 13 /* IMP refused, still rexmt'ng */
+#define IMPTYPE_READY 14 /* ready for next message */
+
+/*
+ * IMPTYPE_DOWN subtypes.
+ */
+#define IMPDOWN_GOING 0 /* 30 secs */
+#define IMPDOWN_PM 1 /* hardware PM */
+#define IMPDOWN_RELOAD 2 /* software reload */
+#define IMPDOWN_RESTART 3 /* emergency restart */
+
+/*
+ * IMPTYPE_BADLEADER subtypes.
+ */
+#define IMPLEADER_ERR 0 /* error flip-flop set */
+#define IMPLEADER_SHORT 1 /* leader < 80 bits */
+#define IMPLEADER_TYPE 2 /* illegal type field */
+#define IMPLEADER_OPPOSITE 3 /* opposite leader type */
+
+/*
+ * IMPTYPE_HOSTDEAD subtypes.
+ */
+#define IMPHOST_NORDY 1 /* ready-line negated */
+#define IMPHOST_TARDY 2 /* tardy receiving mesgs */
+#define IMPHOST_NOEXIST 3 /* NCC doesn't know host */
+#define IMPHOST_IMPSOFT 4 /* IMP software won't allow mesgs */
+#define IMPHOST_PM 5 /* host down for scheduled PM */
+#define IMPHOST_HARDSCHED 6 /* " " " " hardware work */
+#define IMPHOST_SOFTSCHED 7 /* " " " " software work */
+#define IMPHOST_RESTART 8 /* host down for emergency restart */
+#define IMPHOST_POWER 9 /* down because of power outage */
+#define IMPHOST_BREAKPOINT 10 /* host stopped at a breakpoint */
+#define IMPHOST_HARDWARE 11 /* hardware failure */
+#define IMPHOST_NOTUP 12 /* host not scheduled to be up */
+/* 13-14 currently unused */
+#define IMPHOST_COMINGUP 15 /* host in process of coming up */
+
+/*
+ * IMPTYPE_HOSTUNREACH subtypes.
+ */
+#define IMPREACH_IMP 0 /* destination IMP can't be reached */
+#define IMPREACH_HOSTUP 1 /* destination host isn't up */
+#define IMPREACH_LEADER 2 /* host doesn't support long leader */
+#define IMPREACH_PROHIBITED 3 /* communication is prohibited */
+
+/*
+ * IMPTYPE_INCOMPLETE subtypes.
+ */
+#define IMPCOMPLETE_SLOW 0 /* host didn't take data fast enough */
+#define IMPCOMPLETE_TOOLONG 1 /* message was too long */
+#define IMPCOMPLETE_TIMEOUT 2 /* mesg transmission time > 15 sec. */
+#define IMPCOMPLETE_FAILURE 3 /* IMP/circuit failure */
+#define IMPCOMPLETE_NOSPACE 4 /* no resources within 15 sec. */
+#define IMPCOMPLETE_IMPIO 5 /* src IMP I/O failure during receipt */
+
+/*
+ * IMPTYPE_RETRY subtypes.
+ */
+#define IMPRETRY_BUFFER 0 /* IMP buffer wasn't available */
+#define IMPRETRY_BLOCK 1 /* connection block unavailable */
+
+/*
+ * Data structure shared between IMP protocol module and hardware
+ * interface driver. Used to allow layering of IMP routines on top
+ * of varying device drivers. NOTE: there's a possible problem
+ * with ambiguity in the ``unit'' definition which is implicitly
+ * shared by the both IMP and device code. If we have two IMPs,
+ * with each on top of a device of the same unit, things won't work.
+ * The assumption is if you've got multiple IMPs, then they all run
+ * on top of the same type of device, or they must have different units.
+ */
+struct impcb {
+ char ic_oactive; /* output in progress */
+/* int (*ic_init)();*/ /* hardware init routine */
+/* int (*ic_start)();*/ /* hardware start output routine */
+};
+
+/*
+ * State of an IMP.
+ */
+#define IMPS_DOWN 0 /* unavailable, don't use */
+#define IMPS_GOINGDOWN 1 /* been told we go down soon */
+#define IMPS_INIT 2 /* coming up */
+#define IMPS_UP 3 /* ready to go */
+#define IMPS_RESET 4 /* reset in progress */
+
+#define IMPTV_DOWN (30*60) /* going down timer 30 secs */
+
+#ifdef IMPLEADERS
+char *impleaders[IMPTYPE_READY+1] = {
+ "DATA", "BADLEADER", "DOWN", "bad", "NOOP", "RFNM", "HOSTDEAD",
+ "HOSTUNREACH", "BADDATA", "INCOMPLETE", "RESET", "RETRY",
+ "NOTIFY", "TRYING", "READY"
+};
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_imphost.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Host structure used with IMP's.
+ * Used to hold outgoing packets which
+ * would exceed allowed RFNM count.
+ *
+ * These structures are packed into
+ * mbuf's and kept as small as possible.
+ */
+struct host {
+ struct mbuf *h_q; /* holding queue */
+ struct in_addr h_addr; /* host's address */
+ u_char h_qcnt; /* size of holding q */
+ u_char h_timer; /* used to stay off deletion */
+ u_char h_rfnm; /* # outstanding rfnm's */
+ u_char h_flags; /* see below */
+};
+
+/*
+ * A host structure is kept around (even when there are no
+ * references to it) for a spell to avoid constant reallocation
+ * and also to reflect IMP status back to sites which aren't
+ * directly connected to the IMP. When structures are marked
+ * free, a timer is started; when the timer expires the structure
+ * is scavenged.
+ */
+#define HF_INUSE 0x1
+#define HF_DEAD (1<<IMPTYPE_HOSTDEAD)
+#define HF_UNREACH (1<<IMPTYPE_HOSTUNREACH)
+
+#define HOSTTIMER 128 /* keep structure around awhile */
+
+/*
+ * Host structures, as seen inside an mbuf.
+ * Hashing on the host address is used to
+ * select an index into the first mbuf. Collisions
+ * are then resolved by searching successive
+ * mbuf's at the same index. Reclamation is done
+ * automatically at the time a structure is free'd.
+ */
+#define HPMBUF ((MLEN - sizeof(int)) / sizeof(struct host))
+#if vax
+#define HOSTHASH(a) ((((a).s_addr>>24)+(a).s_addr) % HPMBUF)
+#endif
+
+/*
+ * In-line expansions for queuing operations on
+ * host message holding queue. Queue is maintained
+ * as circular list with the head pointing to the
+ * last message in the queue.
+ */
+#define HOST_ENQUE(hp, m) { \
+ register struct mbuf *n; \
+ (hp)->h_qcnt++; \
+ if ((n = (hp)->h_q) == 0) \
+ (hp)->h_q = (m)->m_act = (m); \
+ else { \
+ (m)->m_act = n->m_act; \
+ (hp)->h_q = n->m_act = (m); \
+ } \
+}
+#define HOST_DEQUE(hp, m) { \
+ if ((m) = (hp)->h_q) { \
+ if ((m)->m_act == (m)) \
+ (hp)->h_q = 0; \
+ else { \
+ (m) = (m)->m_act; \
+ (hp)->h_q->m_act = (m)->m_act; \
+ } \
+ (hp)->h_qcnt--; \
+ (m)->m_act = 0; \
+ } \
+}
+
+struct hmbuf {
+ int hm_count; /* # of struct's in use */
+ struct host hm_hosts[HPMBUF]; /* data structures proper */
+};
+
+#ifdef KERNEL
+/*struct host *hostlookup();*/
+/*struct host *hostenter();*/
+/*struct mbuf *hostdeque();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)icmp_var.h 7.2 (Berkeley) 1/13/87
+ */
+
+/*
+ * Variables related to this implementation
+ * of the internet control message protocol.
+ */
+struct icmpstat {
+/* statistics related to icmp packets generated */
+ int icps_error; /* # of calls to icmp_error */
+ int icps_oldshort; /* no error 'cuz old ip too short */
+ int icps_oldicmp; /* no error 'cuz old was icmp */
+ int icps_outhist[ICMP_MAXTYPE + 1];
+/* statistics related to input messages processed */
+ int icps_badcode; /* icmp_code out of range */
+ int icps_tooshort; /* packet < ICMP_MINLEN */
+ int icps_checksum; /* bad checksum */
+ int icps_badlen; /* calculated bound mismatch */
+ int icps_reflect; /* number of responses */
+ int icps_inhist[ICMP_MAXTYPE + 1];
+};
+
+#ifdef KERNEL
+struct icmpstat icmpstat;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_ether.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Structure of a 10Mb/s Ethernet header.
+ */
+struct ether_header {
+ u_char ether_dhost[6];
+ u_char ether_shost[6];
+ u_short ether_type;
+};
+
+#define ETHERTYPE_PUP 0x0200 /* PUP protocol */
+#define ETHERTYPE_IP 0x0800 /* IP protocol */
+#define ETHERTYPE_ARP 0x0806 /* Addr. resolution protocol */
+
+/*
+ * The ETHERTYPE_NTRAILER packet types starting at ETHERTYPE_TRAIL have
+ * (type-ETHERTYPE_TRAIL)*512 bytes of data followed
+ * by an ETHER type (as given above) and then the (variable-length) header.
+ */
+#define ETHERTYPE_TRAIL 0x1000 /* Trailer packet */
+#define ETHERTYPE_NTRAILER 16
+
+#define ETHERMTU 1500
+#define ETHERMIN (60-14)
+
+/*
+ * Ethernet Address Resolution Protocol.
+ *
+ * See RFC 826 for protocol description. Structure below is adapted
+ * to resolving internet addresses. Field names used correspond to
+ * RFC 826.
+ */
+struct ether_arp {
+ struct arphdr ea_hdr; /* fixed-size header */
+ u_char arp_sha[6]; /* sender hardware address */
+ u_char arp_spa[4]; /* sender protocol address */
+ u_char arp_tha[6]; /* target hardware address */
+ u_char arp_tpa[4]; /* target protocol address */
+};
+#define arp_hrd ea_hdr.ar_hrd
+#define arp_pro ea_hdr.ar_pro
+#define arp_hln ea_hdr.ar_hln
+#define arp_pln ea_hdr.ar_pln
+#define arp_op ea_hdr.ar_op
+
+
+/*
+ * Structure shared between the ethernet driver modules and
+ * the address resolution code. For example, each ec_softc or il_softc
+ * begins with this structure.
+ */
+struct arpcom {
+ struct ifnet ac_if; /* network-visible interface */
+ u_char ac_enaddr[6]; /* ethernet hardware address */
+ struct in_addr ac_ipaddr; /* copy of ip address- XXX */
+};
+
+/*
+ * Internet to ethernet address resolution table.
+ */
+struct arptab {
+ struct in_addr at_iaddr; /* internet address */
+ u_char at_enaddr[6]; /* ethernet address */
+ u_char at_timer; /* minutes since last reference */
+ u_char at_flags; /* flags */
+ struct mbuf *at_hold; /* last packet until resolved/timeout */
+};
+
+#ifdef KERNEL
+u_char etherbroadcastaddr[6];
+/*struct arptab *arptnew();*/
+/*char *ether_sprintf();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)in.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Constants and structures defined by the internet system,
+ * Per RFC 790, September 1981.
+ */
+
+/*
+ * Protocols
+ */
+#define IPPROTO_IP 0 /* dummy for IP */
+#define IPPROTO_ICMP 1 /* control message protocol */
+#define IPPROTO_GGP 2 /* gateway^2 (deprecated) */
+#define IPPROTO_TCP 6 /* tcp */
+#define IPPROTO_EGP 8 /* exterior gateway protocol */
+#define IPPROTO_PUP 12 /* pup */
+#define IPPROTO_UDP 17 /* user datagram protocol */
+#define IPPROTO_IDP 22 /* xns idp */
+
+#define IPPROTO_RAW 255 /* raw IP packet */
+#define IPPROTO_MAX 256
+
+
+/*
+ * Ports < IPPORT_RESERVED are reserved for
+ * privileged processes (e.g. root).
+ * Ports > IPPORT_USERRESERVED are reserved
+ * for servers, not necessarily privileged.
+ */
+#define IPPORT_RESERVED 1024
+#define IPPORT_USERRESERVED 5000
+
+/*
+ * Link numbers
+ */
+#define IMPLINK_IP 155
+#define IMPLINK_LOWEXPER 156
+#define IMPLINK_HIGHEXPER 158
+
+/*
+ * Internet address (a structure for historical reasons)
+ */
+struct in_addr {
+ u_long s_addr;
+};
+
+/*
+ * Definitions of bits in internet address integers.
+ * On subnets, the decomposition of addresses to host and net parts
+ * is done according to subnet mask, not the masks here.
+ */
+#define IN_CLASSA(i) (((long)(i) & 0x80000000) == 0)
+#define IN_CLASSA_NET 0xff000000
+#define IN_CLASSA_NSHIFT 24
+#define IN_CLASSA_HOST 0x00ffffff
+#define IN_CLASSA_MAX 128
+
+#define IN_CLASSB(i) (((long)(i) & 0xc0000000) == 0x80000000)
+#define IN_CLASSB_NET 0xffff0000
+#define IN_CLASSB_NSHIFT 16
+#define IN_CLASSB_HOST 0x0000ffff
+#define IN_CLASSB_MAX 65536
+
+#define IN_CLASSC(i) (((long)(i) & 0xc0000000) == 0xc0000000)
+#define IN_CLASSC_NET 0xffffff00
+#define IN_CLASSC_NSHIFT 8
+#define IN_CLASSC_HOST 0x000000ff
+
+#define INADDR_ANY (u_long)0x00000000
+#define INADDR_BROADCAST (u_long)0xffffffff /* must be masked */
+
+/*
+ * Socket address, internet style.
+ */
+struct sockaddr_in {
+ short sin_family;
+ u_short sin_port;
+ struct in_addr sin_addr;
+ char sin_zero[8];
+};
+
+/*
+ * Options for use with [gs]etsockopt at the IP level.
+ */
+#define IP_OPTIONS 1 /* set/get IP per-packet options */
+
+#if !defined(vax) && !defined(ntohl) && !defined(lint)
+/*
+ * Macros for number representation conversion.
+ */
+#define ntohl(x) (x)
+#define ntohs(x) (x)
+#define htonl(x) (x)
+#define htons(x) (x)
+#endif
+
+#if !defined(ntohl) && (defined(vax) || defined(lint))
+/*u_short ntohs(), htons();*/
+/*u_long ntohl(), htonl();*/
+#endif
+
+#ifdef KERNEL
+extern struct domain inetdomain;
+extern struct protosw inetsw[];
+/*struct in_addr in_makeaddr();*/
+/*u_long in_netof(), in_lnaof();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)in_pcb.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Common structure pcb for internet protocol implementation.
+ * Here are stored pointers to local and foreign host table
+ * entries, local and foreign socket numbers, and pointers
+ * up (to a socket structure) and down (to a protocol-specific)
+ * control block.
+ */
+struct inpcb {
+ struct inpcb *inp_next,*inp_prev;
+ /* pointers to other pcb's */
+ struct inpcb *inp_head; /* pointer back to chain of inpcb's
+ for this protocol */
+ struct in_addr inp_faddr; /* foreign host table entry */
+ u_short inp_fport; /* foreign port */
+ struct in_addr inp_laddr; /* local host table entry */
+ u_short inp_lport; /* local port */
+ struct socket *inp_socket; /* back pointer to socket */
+ caddr_t inp_ppcb; /* pointer to per-protocol pcb */
+ struct route inp_route; /* placeholder for routing entry */
+ struct mbuf *inp_options; /* IP options */
+};
+
+#define INPLOOKUP_WILDCARD 1
+#define INPLOOKUP_SETLOCAL 2
+
+#define sotoinpcb(so) ((struct inpcb *)(so)->so_pcb)
+
+#ifdef KERNEL
+/*struct inpcb *in_pcblookup();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)in_systm.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Miscellaneous internetwork
+ * definitions for kernel.
+ */
+
+/*
+ * Network types.
+ *
+ * Internally the system keeps counters in the headers with the bytes
+ * swapped so that VAX instructions will work on them. It reverses
+ * the bytes before transmission at each protocol level. The n_ types
+ * represent the types with the bytes in ``high-ender'' order.
+ */
+typedef u_short n_short; /* short as received from the net */
+typedef u_long n_long; /* long as received from the net */
+
+typedef u_long n_time; /* ms since 00:00 GMT, byte rev */
+
+#ifdef KERNEL
+/*n_time iptime();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1985, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)in_var.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Interface address, Internet version. One of these structures
+ * is allocated for each interface with an Internet address.
+ * The ifaddr structure contains the protocol-independent part
+ * of the structure and is assumed to be first.
+ */
+struct in_ifaddr {
+ struct ifaddr ia_ifa; /* protocol-independent info */
+#define ia_addr ia_ifa.ifa_addr
+#define ia_broadaddr ia_ifa.ifa_broadaddr
+#define ia_dstaddr ia_ifa.ifa_dstaddr
+#define ia_ifp ia_ifa.ifa_ifp
+ u_long ia_net; /* network number of interface */
+ u_long ia_netmask; /* mask of net part */
+ u_long ia_subnet; /* subnet number, including net */
+ u_long ia_subnetmask; /* mask of net + subnet */
+ struct in_addr ia_netbroadcast; /* broadcast addr for (logical) net */
+ int ia_flags;
+ struct in_ifaddr *ia_next; /* next in list of internet addresses */
+};
+/*
+ * Given a pointer to an in_ifaddr (ifaddr),
+ * return a pointer to the addr as a sockadd_in.
+ */
+#define IA_SIN(ia) ((struct sockaddr_in *)(&((struct in_ifaddr *)ia)->ia_addr))
+/*
+ * ia_flags
+ */
+#define IFA_ROUTE 0x01 /* routing entry installed */
+
+#ifdef KERNEL
+struct in_ifaddr *in_ifaddr;
+/*struct in_ifaddr *in_iaonnetof();*/
+struct ifqueue ipintrq; /* ip packet input queue */
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ip.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Definitions for internet protocol version 4.
+ * Per RFC 791, September 1981.
+ */
+#define IPVERSION 4
+
+/*
+ * Structure of an internet header, naked of options.
+ *
+ * We declare ip_len and ip_off to be short, rather than u_short
+ * pragmatically since otherwise unsigned comparisons can result
+ * against negative integers quite easily, and fail in subtle ways.
+ */
+struct ip {
+#ifdef vax
+ u_char ip_hl:4, /* header length */
+ ip_v:4; /* version */
+#endif
+ u_char ip_tos; /* type of service */
+ short ip_len; /* total length */
+ u_short ip_id; /* identification */
+ short ip_off; /* fragment offset field */
+#define IP_DF 0x4000 /* dont fragment flag */
+#define IP_MF 0x2000 /* more fragments flag */
+ u_char ip_ttl; /* time to live */
+ u_char ip_p; /* protocol */
+ u_short ip_sum; /* checksum */
+ struct in_addr ip_src,ip_dst; /* source and dest address */
+};
+
+/*
+ * Definitions for options.
+ */
+#define IPOPT_COPIED(o) ((o)&0x80)
+#define IPOPT_CLASS(o) ((o)&0x60)
+#define IPOPT_NUMBER(o) ((o)&0x1f)
+
+#define IPOPT_CONTROL 0x00
+#define IPOPT_RESERVED1 0x20
+#define IPOPT_DEBMEAS 0x40
+#define IPOPT_RESERVED2 0x60
+
+#define IPOPT_EOL 0 /* end of option list */
+#define IPOPT_NOP 1 /* no operation */
+
+#define IPOPT_RR 7 /* record packet route */
+#define IPOPT_TS 68 /* timestamp */
+#define IPOPT_SECURITY 130 /* provide s,c,h,tcc */
+#define IPOPT_LSRR 131 /* loose source route */
+#define IPOPT_SATID 136 /* satnet id */
+#define IPOPT_SSRR 137 /* strict source route */
+
+/*
+ * Offsets to fields in options other than EOL and NOP.
+ */
+#define IPOPT_OPTVAL 0 /* option ID */
+#define IPOPT_OLEN 1 /* option length */
+#define IPOPT_OFFSET 2 /* offset within option */
+#define IPOPT_MINOFF 4 /* min value of above */
+
+/*
+ * Time stamp option structure.
+ */
+struct ip_timestamp {
+ u_char ipt_code; /* IPOPT_TS */
+ u_char ipt_len; /* size of structure (variable) */
+ u_char ipt_ptr; /* index of current entry */
+ u_char ipt_flg:4, /* flags, see below */
+ ipt_oflw:4; /* overflow counter */
+ union {
+ n_long ipt_time[1];
+ struct ipt_ta {
+ struct in_addr ipt_addr;
+ n_long ipt_time;
+ } ipt_ta[1];
+ }
+};
+
+/* flag bits for ipt_flg */
+#define IPOPT_TS_TSONLY 0 /* timestamps only */
+#define IPOPT_TS_TSANDADDR 1 /* timestamps and addresses */
+#define IPOPT_TS_PRESPEC 2 /* specified modules only */
+
+/* bits for security (not byte swapped) */
+#define IPOPT_SECUR_UNCLASS 0x0000
+#define IPOPT_SECUR_CONFID 0xf135
+#define IPOPT_SECUR_EFTO 0x789a
+#define IPOPT_SECUR_MMMM 0xbc4d
+#define IPOPT_SECUR_RESTR 0xaf13
+#define IPOPT_SECUR_SECRET 0xd788
+#define IPOPT_SECUR_TOPSECRET 0x6bc5
+
+/*
+ * Internet implementation parameters.
+ */
+#define MAXTTL 255 /* maximum time to live (seconds) */
+#define IPFRAGTTL 15 /* time to live for frag chains */
+#define IPTTLDEC 1 /* subtracted when forwarding */
+
+#define IP_MSS 576 /* default maximum segment size */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ip_icmp.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Interface Control Message Protocol Definitions.
+ * Per RFC 792, September 1981.
+ */
+
+/*
+ * Structure of an icmp header.
+ */
+struct icmp {
+ u_char icmp_type; /* type of message, see below */
+ u_char icmp_code; /* type sub code */
+ u_short icmp_cksum; /* ones complement cksum of struct */
+ union {
+ u_char ih_pptr; /* ICMP_PARAMPROB */
+ struct in_addr ih_gwaddr; /* ICMP_REDIRECT */
+ struct ih_idseq {
+ n_short icd_id;
+ n_short icd_seq;
+ } ih_idseq;
+ int ih_void;
+ } icmp_hun;
+#define icmp_pptr icmp_hun.ih_pptr
+#define icmp_gwaddr icmp_hun.ih_gwaddr
+#define icmp_id icmp_hun.ih_idseq.icd_id
+#define icmp_seq icmp_hun.ih_idseq.icd_seq
+#define icmp_void icmp_hun.ih_void
+ union {
+ struct id_ts {
+ n_time its_otime;
+ n_time its_rtime;
+ n_time its_ttime;
+ } id_ts;
+ struct id_ip {
+ struct ip idi_ip;
+ /* options and then 64 bits of data */
+ } id_ip;
+ u_long id_mask;
+ char id_data[1];
+ } icmp_dun;
+#define icmp_otime icmp_dun.id_ts.its_otime
+#define icmp_rtime icmp_dun.id_ts.its_rtime
+#define icmp_ttime icmp_dun.id_ts.its_ttime
+#define icmp_ip icmp_dun.id_ip.idi_ip
+#define icmp_mask icmp_dun.id_mask
+#define icmp_data icmp_dun.id_data
+};
+
+/*
+ * Lower bounds on packet lengths for various types.
+ * For the error advice packets must first insure that the
+ * packet is large enought to contain the returned ip header.
+ * Only then can we do the check to see if 64 bits of packet
+ * data have been returned, since we need to check the returned
+ * ip header length.
+ */
+#define ICMP_MINLEN 8 /* abs minimum */
+#define ICMP_TSLEN (8 + 3 * sizeof (n_time)) /* timestamp */
+#define ICMP_MASKLEN 12 /* address mask */
+#define ICMP_ADVLENMIN (8 + sizeof (struct ip) + 8) /* min */
+#define ICMP_ADVLEN(p) (8 + ((p)->icmp_ip.ip_hl << 2) + 8)
+ /* N.B.: must separately check that ip_hl >= 5 */
+
+/*
+ * Definition of type and code field values.
+ */
+#define ICMP_ECHOREPLY 0 /* echo reply */
+#define ICMP_UNREACH 3 /* dest unreachable, codes: */
+#define ICMP_UNREACH_NET 0 /* bad net */
+#define ICMP_UNREACH_HOST 1 /* bad host */
+#define ICMP_UNREACH_PROTOCOL 2 /* bad protocol */
+#define ICMP_UNREACH_PORT 3 /* bad port */
+#define ICMP_UNREACH_NEEDFRAG 4 /* IP_DF caused drop */
+#define ICMP_UNREACH_SRCFAIL 5 /* src route failed */
+#define ICMP_SOURCEQUENCH 4 /* packet lost, slow down */
+#define ICMP_REDIRECT 5 /* shorter route, codes: */
+#define ICMP_REDIRECT_NET 0 /* for network */
+#define ICMP_REDIRECT_HOST 1 /* for host */
+#define ICMP_REDIRECT_TOSNET 2 /* for tos and net */
+#define ICMP_REDIRECT_TOSHOST 3 /* for tos and host */
+#define ICMP_ECHO 8 /* echo service */
+#define ICMP_TIMXCEED 11 /* time exceeded, code: */
+#define ICMP_TIMXCEED_INTRANS 0 /* ttl==0 in transit */
+#define ICMP_TIMXCEED_REASS 1 /* ttl==0 in reass */
+#define ICMP_PARAMPROB 12 /* ip header bad */
+#define ICMP_TSTAMP 13 /* timestamp request */
+#define ICMP_TSTAMPREPLY 14 /* timestamp reply */
+#define ICMP_IREQ 15 /* information request */
+#define ICMP_IREQREPLY 16 /* information reply */
+#define ICMP_MASKREQ 17 /* address mask request */
+#define ICMP_MASKREPLY 18 /* address mask reply */
+
+#define ICMP_MAXTYPE 18
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ip_var.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Overlay for ip header used by other protocols (tcp, udp).
+ */
+struct ipovly {
+ caddr_t ih_next, ih_prev; /* for protocol sequence q's */
+ u_char ih_x1; /* (unused) */
+ u_char ih_pr; /* protocol */
+ short ih_len; /* protocol length */
+ struct in_addr ih_src; /* source internet address */
+ struct in_addr ih_dst; /* destination internet address */
+};
+
+/*
+ * Ip reassembly queue structure. Each fragment
+ * being reassembled is attached to one of these structures.
+ * They are timed out after ipq_ttl drops to 0, and may also
+ * be reclaimed if memory becomes tight.
+ */
+struct ipq {
+ struct ipq *next,*prev; /* to other reass headers */
+ u_char ipq_ttl; /* time for reass q to live */
+ u_char ipq_p; /* protocol of this fragment */
+ u_short ipq_id; /* sequence id for reassembly */
+ struct ipasfrag *ipq_next,*ipq_prev;
+ /* to ip headers of fragments */
+ struct in_addr ipq_src,ipq_dst;
+};
+
+/*
+ * Ip header, when holding a fragment.
+ *
+ * Note: ipf_next must be at same offset as ipq_next above
+ */
+struct ipasfrag {
+#ifdef vax
+ u_char ip_hl:4,
+ ip_v:4;
+#endif
+ u_char ipf_mff; /* copied from (ip_off&IP_MF) */
+ short ip_len;
+ u_short ip_id;
+ short ip_off;
+ u_char ip_ttl;
+ u_char ip_p;
+ u_short ip_sum;
+ struct ipasfrag *ipf_next; /* next fragment */
+ struct ipasfrag *ipf_prev; /* previous fragment */
+};
+
+/*
+ * Structure stored in mbuf in inpcb.ip_options
+ * and passed to ip_output when ip options are in use.
+ * The actual length of the options (including ipopt_dst)
+ * is in m_len.
+ */
+#define MAX_IPOPTLEN 40
+
+struct ipoption {
+ struct in_addr ipopt_dst; /* first-hop dst if source routed */
+ char ipopt_list[MAX_IPOPTLEN]; /* options proper */
+};
+
+struct ipstat {
+ long ips_total; /* total packets received */
+ long ips_badsum; /* checksum bad */
+ long ips_tooshort; /* packet too short */
+ long ips_toosmall; /* not enough data */
+ long ips_badhlen; /* ip header length < data size */
+ long ips_badlen; /* ip length < ip header length */
+ long ips_fragments; /* fragments received */
+ long ips_fragdropped; /* frags dropped (dups, out of space) */
+ long ips_fragtimeout; /* fragments timed out */
+ long ips_forward; /* packets forwarded */
+ long ips_cantforward; /* packets rcvd for unreachable dest */
+ long ips_redirectsent; /* packets forwarded on same net */
+};
+
+#ifdef KERNEL
+/* flags passed to ip_output as last parameter */
+#define IP_FORWARDING 0x1 /* most of ip header exists */
+#define IP_ROUTETOIF SO_DONTROUTE /* bypass routing tables */
+#define IP_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
+
+struct ipstat ipstat;
+struct ipq ipq; /* ip reass. queue */
+u_short ip_id; /* ip packet ctr, for ids */
+
+/*struct mbuf *ip_srcroute();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tcp.h 7.1 (Berkeley) 6/5/86
+ */
+
+typedef u_long tcp_seq;
+/*
+ * TCP header.
+ * Per RFC 793, September, 1981.
+ */
+struct tcphdr {
+ u_short th_sport; /* source port */
+ u_short th_dport; /* destination port */
+ tcp_seq th_seq; /* sequence number */
+ tcp_seq th_ack; /* acknowledgement number */
+#ifdef vax
+ u_char th_x2:4, /* (unused) */
+ th_off:4; /* data offset */
+#endif
+ u_char th_flags;
+#define TH_FIN 0x01
+#define TH_SYN 0x02
+#define TH_RST 0x04
+#define TH_PUSH 0x08
+#define TH_ACK 0x10
+#define TH_URG 0x20
+ u_short th_win; /* window */
+ u_short th_sum; /* checksum */
+ u_short th_urp; /* urgent pointer */
+};
+
+#define TCPOPT_EOL 0
+#define TCPOPT_NOP 1
+#define TCPOPT_MAXSEG 2
+
+/*
+ * Default maximum segment size for TCP.
+ * With an IP MSS of 576, this is 536,
+ * but 512 is probably more convenient.
+ */
+#ifdef lint
+#define TCP_MSS 536
+#else
+#define TCP_MSS MIN(512, IP_MSS - sizeof (struct tcpiphdr))
+#endif
+
+/*
+ * User-settable options (used with setsockopt).
+ */
+#define TCP_NODELAY 0x01 /* don't delay send to coalesce packets */
+#define TCP_MAXSEG 0x02 /* set maximum segment size */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tcp_debug.h 7.1 (Berkeley) 6/5/86
+ */
+
+struct tcp_debug {
+ n_time td_time;
+ short td_act;
+ short td_ostate;
+ caddr_t td_tcb;
+ struct tcpiphdr td_ti;
+ short td_req;
+ struct tcpcb td_cb;
+};
+
+#define TA_INPUT 0
+#define TA_OUTPUT 1
+#define TA_USER 2
+#define TA_RESPOND 3
+#define TA_DROP 4
+
+#ifdef TANAMES
+char *tanames[] =
+ { "input", "output", "user", "respond", "drop" };
+#endif
+
+#define TCP_NDEBUG 100
+struct tcp_debug tcp_debug[TCP_NDEBUG];
+int tcp_debx;
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tcp_fsm.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * TCP FSM state definitions.
+ * Per RFC793, September, 1981.
+ */
+
+#define TCP_NSTATES 11
+
+#define TCPS_CLOSED 0 /* closed */
+#define TCPS_LISTEN 1 /* listening for connection */
+#define TCPS_SYN_SENT 2 /* active, have sent syn */
+#define TCPS_SYN_RECEIVED 3 /* have send and received syn */
+/* states < TCPS_ESTABLISHED are those where connections not established */
+#define TCPS_ESTABLISHED 4 /* established */
+#define TCPS_CLOSE_WAIT 5 /* rcvd fin, waiting for close */
+/* states > TCPS_CLOSE_WAIT are those where user has closed */
+#define TCPS_FIN_WAIT_1 6 /* have closed, sent fin */
+#define TCPS_CLOSING 7 /* closed xchd FIN; await FIN ACK */
+#define TCPS_LAST_ACK 8 /* had fin and close; await FIN ACK */
+/* states > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN */
+#define TCPS_FIN_WAIT_2 9 /* have closed, fin is acked */
+#define TCPS_TIME_WAIT 10 /* in 2*msl quiet wait after close */
+
+#define TCPS_HAVERCVDSYN(s) ((s) >= TCPS_SYN_RECEIVED)
+#define TCPS_HAVERCVDFIN(s) ((s) >= TCPS_TIME_WAIT)
+
+#ifdef TCPOUTFLAGS
+/*
+ * Flags used when sending segments in tcp_output.
+ * Basic flags (TH_RST,TH_ACK,TH_SYN,TH_FIN) are totally
+ * determined by state, with the proviso that TH_FIN is sent only
+ * if all data queued for output is included in the segment.
+ */
+u_char tcp_outflags[TCP_NSTATES] = {
+ TH_RST|TH_ACK, 0, TH_SYN, TH_SYN|TH_ACK,
+ TH_ACK, TH_ACK,
+ TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_FIN|TH_ACK, TH_ACK, TH_ACK,
+};
+#endif
+
+#ifdef KPROF
+int tcp_acounts[TCP_NSTATES][PRU_NREQ];
+#endif
+
+#ifdef TCPSTATES
+char *tcpstates[] = {
+ "CLOSED", "LISTEN", "SYN_SENT", "SYN_RCVD",
+ "ESTABLISHED", "CLOSE_WAIT", "FIN_WAIT_1", "CLOSING",
+ "LAST_ACK", "FIN_WAIT_2", "TIME_WAIT",
+};
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tcp_seq.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * TCP sequence numbers are 32 bit integers operated
+ * on with modular arithmetic. These macros can be
+ * used to compare such integers.
+ */
+#define SEQ_LT(a,b) ((int)((a)-(b)) < 0)
+#define SEQ_LEQ(a,b) ((int)((a)-(b)) <= 0)
+#define SEQ_GT(a,b) ((int)((a)-(b)) > 0)
+#define SEQ_GEQ(a,b) ((int)((a)-(b)) >= 0)
+
+/*
+ * Macros to initialize tcp sequence numbers for
+ * send and receive from initial send and receive
+ * sequence numbers.
+ */
+#define tcp_rcvseqinit(tp) \
+ (tp)->rcv_adv = (tp)->rcv_nxt = (tp)->irs + 1
+
+#define tcp_sendseqinit(tp) \
+ (tp)->snd_una = (tp)->snd_nxt = (tp)->snd_max = (tp)->snd_up = \
+ (tp)->iss
+
+#define TCP_ISSINCR (125*1024) /* increment for tcp_iss each second */
+
+#ifdef KERNEL
+tcp_seq tcp_iss; /* tcp initial send seq # */
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tcp_timer.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Definitions of the TCP timers. These timers are counted
+ * down PR_SLOWHZ times a second.
+ */
+#define TCPT_NTIMERS 4
+
+#define TCPT_REXMT 0 /* retransmit */
+#define TCPT_PERSIST 1 /* retransmit persistance */
+#define TCPT_KEEP 2 /* keep alive */
+#define TCPT_2MSL 3 /* 2*msl quiet time timer */
+
+/*
+ * The TCPT_REXMT timer is used to force retransmissions.
+ * The TCP has the TCPT_REXMT timer set whenever segments
+ * have been sent for which ACKs are expected but not yet
+ * received. If an ACK is received which advances tp->snd_una,
+ * then the retransmit timer is cleared (if there are no more
+ * outstanding segments) or reset to the base value (if there
+ * are more ACKs expected). Whenever the retransmit timer goes off,
+ * we retransmit one unacknowledged segment, and do a backoff
+ * on the retransmit timer.
+ *
+ * The TCPT_PERSIST timer is used to keep window size information
+ * flowing even if the window goes shut. If all previous transmissions
+ * have been acknowledged (so that there are no retransmissions in progress),
+ * and the window is too small to bother sending anything, then we start
+ * the TCPT_PERSIST timer. When it expires, if the window is nonzero,
+ * we go to transmit state. Otherwise, at intervals send a single byte
+ * into the peer's window to force him to update our window information.
+ * We do this at most as often as TCPT_PERSMIN time intervals,
+ * but no more frequently than the current estimate of round-trip
+ * packet time. The TCPT_PERSIST timer is cleared whenever we receive
+ * a window update from the peer.
+ *
+ * The TCPT_KEEP timer is used to keep connections alive. If an
+ * connection is idle (no segments received) for TCPTV_KEEP amount of time,
+ * but not yet established, then we drop the connection. If the connection
+ * is established, then we force the peer to send us a segment by sending:
+ * <SEQ=SND.UNA-1><ACK=RCV.NXT><CTL=ACK>
+ * This segment is (deliberately) outside the window, and should elicit
+ * an ack segment in response from the peer. If, despite the TCPT_KEEP
+ * initiated segments we cannot elicit a response from a peer in TCPT_MAXIDLE
+ * amount of time, then we drop the connection.
+ */
+
+#define TCP_TTL 30 /* time to live for TCP segs */
+/*
+ * Time constants.
+ */
+#define TCPTV_MSL ( 15*PR_SLOWHZ) /* max seg lifetime */
+#define TCPTV_SRTTBASE 0 /* base roundtrip time;
+ if 0, no idea yet */
+#define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */
+
+#define TCPTV_KEEP ( 45*PR_SLOWHZ) /* keep alive - 45 secs */
+#define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */
+
+#define TCPTV_MAXIDLE ( 8*TCPTV_KEEP) /* maximum allowable idle
+ time before drop conn */
+
+#define TCPTV_MIN ( 1*PR_SLOWHZ) /* minimum allowable value */
+#define TCPTV_MAX ( 30*PR_SLOWHZ) /* maximum allowable value */
+
+#define TCP_LINGERTIME 120 /* linger at most 2 minutes */
+
+#define TCP_MAXRXTSHIFT 12 /* maximum retransmits */
+
+#ifdef TCPTIMERS
+char *tcptimers[] =
+ { "REXMT", "PERSIST", "KEEP", "2MSL" };
+#endif
+
+/*
+ * Retransmission smoothing constants.
+ * Smoothed round trip time is updated by
+ * tp->t_srtt = (tcp_alpha * tp->t_srtt) + ((1 - tcp_alpha) * tp->t_rtt)
+ * each time a new value of tp->t_rtt is available. The initial
+ * retransmit timeout is then based on
+ * tp->t_timer[TCPT_REXMT] = tcp_beta * tp->t_srtt;
+ * limited, however to be at least TCPTV_MIN and at most TCPTV_MAX.
+ */
+float tcp_alpha, tcp_beta;
+
+/*
+ * Initial values of tcp_alpha and tcp_beta.
+ * These are conservative: averaging over a long
+ * period of time, and allowing for large individual deviations from
+ * tp->t_srtt.
+ */
+#define TCP_ALPHA 0.9
+#define TCP_BETA 2.0
+
+/*
+ * Force a time value to be in a certain range.
+ */
+#define TCPT_RANGESET(tv, value, tvmin, tvmax) { \
+ (tv) = (value); \
+ if ((tv) < (tvmin)) \
+ (tv) = (tvmin); \
+ if ((tv) > (tvmax)) \
+ (tv) = (tvmax); \
+}
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tcp_var.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Kernel variables for tcp.
+ */
+
+/*
+ * Tcp control block, one per tcp; fields:
+ */
+struct tcpcb {
+ struct tcpiphdr *seg_next; /* sequencing queue */
+ struct tcpiphdr *seg_prev;
+ short t_state; /* state of this connection */
+ short t_timer[TCPT_NTIMERS]; /* tcp timers */
+ short t_rxtshift; /* log(2) of rexmt exp. backoff */
+ struct mbuf *t_tcpopt; /* tcp options */
+ u_short t_maxseg; /* maximum segment size */
+ char t_force; /* 1 if forcing out a byte */
+ u_char t_flags;
+#define TF_ACKNOW 0x01 /* ack peer immediately */
+#define TF_DELACK 0x02 /* ack, but try to delay it */
+#define TF_NODELAY 0x04 /* don't delay packets to coalesce */
+#define TF_NOOPT 0x08 /* don't use tcp options */
+#define TF_SENTFIN 0x10 /* have sent FIN */
+ struct tcpiphdr *t_template; /* skeletal packet for transmit */
+ struct inpcb *t_inpcb; /* back pointer to internet pcb */
+/*
+ * The following fields are used as in the protocol specification.
+ * See RFC783, Dec. 1981, page 21.
+ */
+/* send sequence variables */
+ tcp_seq snd_una; /* send unacknowledged */
+ tcp_seq snd_nxt; /* send next */
+ tcp_seq snd_up; /* send urgent pointer */
+ tcp_seq snd_wl1; /* window update seg seq number */
+ tcp_seq snd_wl2; /* window update seg ack number */
+ tcp_seq iss; /* initial send sequence number */
+ u_short snd_wnd; /* send window */
+/* receive sequence variables */
+ u_short rcv_wnd; /* receive window */
+ tcp_seq rcv_nxt; /* receive next */
+ tcp_seq rcv_up; /* receive urgent pointer */
+ tcp_seq irs; /* initial receive sequence number */
+/*
+ * Additional variables for this implementation.
+ */
+/* receive variables */
+ tcp_seq rcv_adv; /* advertised window */
+/* retransmit variables */
+ tcp_seq snd_max; /* highest sequence number sent
+ * used to recognize retransmits
+ */
+/* congestion control (for source quench) */
+ u_short snd_cwnd; /* congestion-controlled window */
+/* transmit timing stuff */
+ short t_idle; /* inactivity time */
+ short t_rtt; /* round trip time */
+ u_short max_rcvd; /* most peer has sent into window */
+ tcp_seq t_rtseq; /* sequence number being timed */
+ float t_srtt; /* smoothed round-trip time */
+ u_short max_sndwnd; /* largest window peer has offered */
+/* out-of-band data */
+ char t_oobflags; /* have some */
+ char t_iobc; /* input character */
+#define TCPOOB_HAVEDATA 0x01
+#define TCPOOB_HADDATA 0x02
+};
+
+#define intotcpcb(ip) ((struct tcpcb *)(ip)->inp_ppcb)
+#define sototcpcb(so) (intotcpcb(sotoinpcb(so)))
+
+struct tcpstat {
+ int tcps_badsum;
+ int tcps_badoff;
+ int tcps_hdrops;
+ int tcps_badsegs;
+ int tcps_unack;
+};
+
+#ifdef KERNEL
+struct inpcb tcb; /* head of queue of active tcpcb's */
+struct tcpstat tcpstat; /* tcp statistics */
+/*struct tcpiphdr *tcp_template();*/
+/*struct tcpcb *tcp_close(), *tcp_drop();*/
+/*struct tcpcb *tcp_timers(), *tcp_disconnect(), *tcp_usrclosed();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tcpip.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Tcp+ip header, after ip options removed.
+ */
+struct tcpiphdr {
+ struct ipovly ti_i; /* overlaid ip structure */
+ struct tcphdr ti_t; /* tcp header */
+};
+#define ti_next ti_i.ih_next
+#define ti_prev ti_i.ih_prev
+#define ti_x1 ti_i.ih_x1
+#define ti_pr ti_i.ih_pr
+#define ti_len ti_i.ih_len
+#define ti_src ti_i.ih_src
+#define ti_dst ti_i.ih_dst
+#define ti_sport ti_t.th_sport
+#define ti_dport ti_t.th_dport
+#define ti_seq ti_t.th_seq
+#define ti_ack ti_t.th_ack
+#define ti_x2 ti_t.th_x2
+#define ti_off ti_t.th_off
+#define ti_flags ti_t.th_flags
+#define ti_win ti_t.th_win
+#define ti_sum ti_t.th_sum
+#define ti_urp ti_t.th_urp
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)udp.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Udp protocol header.
+ * Per RFC 768, September, 1981.
+ */
+struct udphdr {
+ u_short uh_sport; /* source port */
+ u_short uh_dport; /* destination port */
+ short uh_ulen; /* udp length */
+ u_short uh_sum; /* udp checksum */
+};
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)udp_var.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * UDP kernel structures and variables.
+ */
+struct udpiphdr {
+ struct ipovly ui_i; /* overlaid ip structure */
+ struct udphdr ui_u; /* udp header */
+};
+#define ui_next ui_i.ih_next
+#define ui_prev ui_i.ih_prev
+#define ui_x1 ui_i.ih_x1
+#define ui_pr ui_i.ih_pr
+#define ui_len ui_i.ih_len
+#define ui_src ui_i.ih_src
+#define ui_dst ui_i.ih_dst
+#define ui_sport ui_u.uh_sport
+#define ui_dport ui_u.uh_dport
+#define ui_ulen ui_u.uh_ulen
+#define ui_sum ui_u.uh_sum
+
+struct udpstat {
+ int udps_hdrops;
+ int udps_badsum;
+ int udps_badlen;
+};
+
+#define UDP_TTL 30 /* time to live for UDP packets */
+
+#ifdef KERNEL
+struct inpcb udb;
+struct udpstat udpstat;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1984, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)idp.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Definitions for NS(tm) Internet Datagram Protocol
+ */
+struct idp {
+ u_short idp_sum; /* Checksum */
+ u_short idp_len; /* Length, in bytes, including header */
+ u_char idp_tc; /* Transport Crontrol (i.e. hop count) */
+ u_char idp_pt; /* Packet Type (i.e. level 2 protocol) */
+ struct ns_addr idp_dna; /* Destination Network Address */
+ struct ns_addr idp_sna; /* Source Network Address */
+};
--- /dev/null
+/*
+ * Copyright (c) 1984, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)idp_var.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * IDP Kernel Structures and Variables
+ */
+struct idpstat {
+ int idps_badsum; /* checksum bad */
+ int idps_tooshort; /* packet too short */
+ int idps_toosmall; /* not enough data */
+ int idps_badhlen; /* ip header length < data size */
+ int idps_badlen; /* ip length < ip header length */
+};
+
+#ifdef KERNEL
+struct idpstat idpstat;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1984, 1985, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ns.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Constants and Structures defined by the Xerox Network Software
+ * per "Internet Transport Protocols", XSIS 028112, December 1981
+ */
+
+/*
+ * Protocols
+ */
+#define NSPROTO_RI 1 /* Routing Information */
+#define NSPROTO_ECHO 2 /* Echo Protocol */
+#define NSPROTO_ERROR 3 /* Error Protocol */
+#define NSPROTO_PE 4 /* Packet Exchange */
+#define NSPROTO_SPP 5 /* Sequenced Packet */
+#define NSPROTO_RAW 255 /* Placemarker*/
+#define NSPROTO_MAX 256 /* Placemarker*/
+
+
+/*
+ * Port/Socket numbers: network standard functions
+ */
+
+#define NSPORT_RI 1 /* Routing Information */
+#define NSPORT_ECHO 2 /* Echo */
+#define NSPORT_RE 3 /* Router Error */
+
+/*
+ * Ports < NSPORT_RESERVED are reserved for priveleged
+ * processes (e.g. root).
+ */
+#define NSPORT_RESERVED 3000
+
+/* flags passed to ns_output as last parameter */
+
+#define NS_FORWARDING 0x1 /* most of idp header exists */
+#define NS_ROUTETOIF 0x10 /* same as SO_DONTROUTE */
+#define NS_ALLOWBROADCAST SO_BROADCAST /* can send broadcast packets */
+
+#define NS_MAXHOPS 15
+
+/* flags passed to get/set socket option */
+#define SO_HEADERS_ON_INPUT 1
+#define SO_HEADERS_ON_OUTPUT 2
+#define SO_DEFAULT_HEADERS 3
+#define SO_LAST_HEADER 4
+#define SO_NSIP_ROUTE 5
+#define SO_SEQNO 6
+#define SO_ALL_PACKETS 7
+#define SO_MTU 8
+
+
+/*
+ * NS addressing
+ */
+union ns_host {
+ u_char c_host[6];
+ u_short s_host[3];
+};
+
+union ns_net {
+ u_char c_net[4];
+ u_short s_net[2];
+};
+
+union ns_net_u {
+ union ns_net net_e;
+ u_long long_e;
+};
+
+struct ns_addr {
+ union ns_net x_net;
+ union ns_host x_host;
+ u_short x_port;
+};
+
+/*
+ * Socket address, Xerox style
+ */
+struct sockaddr_ns {
+ u_short sns_family;
+ struct ns_addr sns_addr;
+ char sns_zero[2];
+};
+#define sns_port sns_addr.x_port
+
+#ifdef vax
+#define ns_netof(a) (*(long *) & ((a).x_net)) /* XXX - not needed */
+#endif
+#define ns_neteqnn(a,b) (((a).s_net[0]==(b).s_net[0]) && \
+ ((a).s_net[1]==(b).s_net[1]))
+#define ns_neteq(a,b) ns_neteqnn((a).x_net, (b).x_net)
+#define satons_addr(sa) (((struct sockaddr_ns *)&(sa))->sns_addr)
+#define ns_hosteqnh(s,t) ((s).s_host[0] == (t).s_host[0] && \
+ (s).s_host[1] == (t).s_host[1] && (s).s_host[2] == (t).s_host[2])
+#define ns_hosteq(s,t) (ns_hosteqnh((s).x_host,(t).x_host))
+#define ns_nullhost(x) (((x).x_host.s_host[0]==0) && \
+ ((x).x_host.s_host[1]==0) && ((x).x_host.s_host[2]==0))
+
+#if !defined(vax) && !defined(ntohl) && !defined(lint)
+/*
+ * Macros for number representation conversion.
+ */
+#define ntohl(x) (x)
+#define ntohs(x) (x)
+#define htonl(x) (x)
+#define htons(x) (x)
+#endif
+
+#if !defined(ntohl) && (defined(vax) || defined(lint))
+/*u_short ntohs(), htons();*/
+/*u_long ntohl(), htonl();*/
+#endif
+
+#ifdef KERNEL
+extern struct domain nsdomain;
+union ns_host ns_thishost;
+union ns_host ns_zerohost;
+union ns_host ns_broadhost;
+union ns_net ns_zeronet;
+union ns_net ns_broadnet;
+/*u_short ns_cksum();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1984, 1985, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ns_error.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Xerox NS error messages
+ */
+
+struct ns_errp {
+ u_short ns_err_num; /* Error Number */
+ u_short ns_err_param; /* Error Parameter */
+ struct idp ns_err_idp; /* Initial segment of offending
+ packet */
+ u_char ns_err_lev2[12]; /* at least this much higher
+ level protocol */
+};
+struct ns_epidp {
+ struct idp ns_ep_idp;
+ struct ns_errp ns_ep_errp;
+};
+
+#define NS_ERR_UNSPEC 0 /* Unspecified Error detected at dest. */
+#define NS_ERR_BADSUM 1 /* Bad Checksum detected at dest */
+#define NS_ERR_NOSOCK 2 /* Specified socket does not exist at dest*/
+#define NS_ERR_FULLUP 3 /* Dest. refuses packet due to resource lim.*/
+#define NS_ERR_UNSPEC_T 0x200 /* Unspec. Error occured before reaching dest*/
+#define NS_ERR_BADSUM_T 0x201 /* Bad Checksum detected in transit */
+#define NS_ERR_UNREACH_HOST 0x202 /* Dest cannot be reached from here*/
+#define NS_ERR_TOO_OLD 0x203 /* Packet x'd 15 routers without delivery*/
+#define NS_ERR_TOO_BIG 0x204 /* Packet too large to be forwarded through
+ some intermediate gateway. The error
+ parameter field contains the max packet
+ size that can be accommodated */
+#define NS_ERR_ATHOST 4
+#define NS_ERR_ENROUTE 5
+#define NS_ERR_MAX (NS_ERR_ATHOST + NS_ERR_ENROUTE + 1)
+#define ns_err_x(c) (((c)&0x200) ? ((c) - 0x200 + NS_ERR_ATHOST) : c )
+
+/*
+ * Variables related to this implementation
+ * of the network systems error message protocol.
+ */
+struct ns_errstat {
+/* statistics related to ns_err packets generated */
+ int ns_es_error; /* # of calls to ns_error */
+ int ns_es_oldshort; /* no error 'cuz old ip too short */
+ int ns_es_oldns_err; /* no error 'cuz old was ns_err */
+ int ns_es_outhist[NS_ERR_MAX];
+/* statistics related to input messages processed */
+ int ns_es_badcode; /* ns_err_code out of range */
+ int ns_es_tooshort; /* packet < IDP_MINLEN */
+ int ns_es_checksum; /* bad checksum */
+ int ns_es_badlen; /* calculated bound mismatch */
+ int ns_es_reflect; /* number of responses */
+ int ns_es_inhist[NS_ERR_MAX];
+};
+
+#ifdef KERNEL
+struct ns_errstat ns_errstat;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1985, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ns_if.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Interface address, xerox version. One of these structures
+ * is allocated for each interface with an internet address.
+ * The ifaddr structure contains the protocol-independent part
+ * of the structure and is assumed to be first.
+ */
+
+struct ns_ifaddr {
+ struct ifaddr ia_ifa; /* protocol-independent info */
+#define ia_addr ia_ifa.ifa_addr
+#define ia_broadaddr ia_ifa.ifa_broadaddr
+#define ia_dstaddr ia_ifa.ifa_dstaddr
+#define ia_ifp ia_ifa.ifa_ifp
+ union ns_net ia_net; /* network number of interface */
+ int ia_flags;
+ struct ns_ifaddr *ia_next; /* next in list of internet addresses */
+};
+
+/*
+ * Given a pointer to an ns_ifaddr (ifaddr),
+ * return a pointer to the addr as a sockadd_ns.
+ */
+
+#define IA_SNS(ia) ((struct sockaddr_ns *)(&((struct ns_ifaddr *)ia)->ia_addr))
+/*
+ * ia_flags
+ */
+#define IFA_ROUTE 0x01 /* routing entry installed */
+
+/* This is not the right place for this but where is? */
+#define ETHERTYPE_NS 0x0600
+
+#ifdef NSIP
+struct nsip_req {
+ struct sockaddr rq_ns; /* must be ns format destination */
+ struct sockaddr rq_ip; /* must be ip format gateway */
+ short rq_flags;
+};
+#endif
+
+#ifdef KERNEL
+struct ns_ifaddr *ns_ifaddr;
+/*struct ns_ifaddr *ns_iaonnetof();*/
+struct ifqueue nsintrq; /* XNS input packet queue */
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1984, 1985, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ns_pcb.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Ns protocol interface control block.
+ */
+struct nspcb {
+ struct nspcb *nsp_next; /* doubly linked list */
+ struct nspcb *nsp_prev;
+ struct nspcb *nsp_head;
+ struct socket *nsp_socket; /* back pointer to socket */
+ struct ns_addr nsp_faddr; /* destination address */
+ struct ns_addr nsp_laddr; /* socket's address */
+ caddr_t nsp_pcb; /* protocol specific stuff */
+ struct route nsp_route; /* routing information */
+ struct ns_addr nsp_lastdst; /* validate cached route for dg socks*/
+ long nsp_notify_param; /* extra info passed via ns_pcbnotify*/
+ short nsp_flags;
+ u_char nsp_dpt; /* default packet type for idp_output*/
+ u_char nsp_rpt; /* last received packet type by
+ idp_input() */
+};
+
+/* possible flags */
+
+#define NSP_IN_ABORT 0x1 /* calling abort through socket */
+#define NSP_RAWIN 0x2 /* show headers on input */
+#define NSP_RAWOUT 0x4 /* show header on output */
+#define NSP_ALL_PACKETS 0x8 /* Turn off higher proto processing */
+
+#define NS_WILDCARD 1
+
+#define nsp_lport nsp_laddr.x_port
+#define nsp_fport nsp_faddr.x_port
+
+#define sotonspcb(so) ((struct nspcb *)((so)->so_pcb))
+
+/*
+ * Nominal space allocated to a ns socket.
+ */
+#define NSSNDQ 2048
+#define NSRCVQ 2048
+
+
+#ifdef KERNEL
+struct nspcb nspcb; /* head of list */
+/*struct nspcb *ns_pcblookup();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1984, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)sp.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Definitions for Xerox NS style sequenced packet protocol
+ */
+
+struct sphdr {
+ u_char sp_cc; /* connection control */
+ u_char sp_dt; /* datastream type */
+#define SP_SP 0x80 /* system packet */
+#define SP_SA 0x40 /* send acknowledgement */
+#define SP_OB 0x20 /* attention (out of band data) */
+#define SP_EM 0x10 /* end of message */
+ u_short sp_sid; /* source connection identifier */
+ u_short sp_did; /* destination connection identifier */
+ u_short sp_seq; /* sequence number */
+ u_short sp_ack; /* acknowledge number */
+ u_short sp_alo; /* allocation number */
+};
--- /dev/null
+/*
+ * Copyright (c) 1984, 1985, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)spidp.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Definitions for NS(tm) Internet Datagram Protocol
+ * containing a Sequenced Packet Protocol packet.
+ */
+struct spidp {
+ struct idp si_i;
+ struct sphdr si_s;
+};
+struct spidp_q {
+ struct spidp_q *si_next;
+ struct spidp_q *si_prev;
+};
+#define SI(x) ((struct spidp *)x)
+#define si_sum si_i.idp_sum
+#define si_len si_i.idp_len
+#define si_tc si_i.idp_tc
+#define si_pt si_i.idp_pt
+#define si_dna si_i.idp_dna
+#define si_sna si_i.idp_sna
+#define si_sport si_i.idp_sna.x_port
+#define si_cc si_s.sp_cc
+#define si_dt si_s.sp_dt
+#define si_sid si_s.sp_sid
+#define si_did si_s.sp_did
+#define si_seq si_s.sp_seq
+#define si_ack si_s.sp_ack
+#define si_alo si_s.sp_alo
--- /dev/null
+/*
+ * Copyright (c) 1984, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)spp_debug.h 7.1 (Berkeley) 6/5/86
+ */
+
+struct spp_debug {
+ u_long sd_time;
+ short sd_act;
+ short sd_ostate;
+ caddr_t sd_cb;
+ short sd_req;
+ struct spidp sd_si;
+ struct sppcb sd_sp;
+};
+
+#define SA_INPUT 0
+#define SA_OUTPUT 1
+#define SA_USER 2
+#define SA_RESPOND 3
+#define SA_DROP 4
+
+#ifdef SANAMES
+char *sanames[] =
+ { "input", "output", "user", "respond", "drop" };
+#endif
+
+#define SPP_NDEBUG 100
+struct spp_debug spp_debug[SPP_NDEBUG];
+int spp_debx;
--- /dev/null
+/*
+ * Copyright (c) 1984, 1985, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)spp_var.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Sp control block, one per connection
+ */
+struct sppcb {
+ struct spidp_q s_q; /* queue for out-of-order receipt */
+ struct nspcb *s_nspcb; /* backpointer to internet pcb */
+ u_char s_state;
+ u_char s_flags;
+#define SF_AK 0x01 /* Acknowledgement requested */
+#define SF_DELACK 0x02 /* Ak, waiting to see if we xmit*/
+#define SF_HI 0x04 /* Show headers on input */
+#define SF_HO 0x08 /* Show headers on output */
+#define SF_PI 0x10 /* Packet (datagram) interface */
+ u_short s_mtu; /* Max packet size for this stream */
+/* use sequence fields in headers to store sequence numbers for this
+ connection */
+ struct spidp s_shdr; /* prototype header to transmit */
+#define s_cc s_shdr.si_cc /* connection control (for EM bit) */
+#define s_dt s_shdr.si_dt /* datastream type */
+#define s_sid s_shdr.si_sid /* source connection identifier */
+#define s_did s_shdr.si_did /* destination connection identifier */
+#define s_seq s_shdr.si_seq /* sequence number */
+#define s_ack s_shdr.si_ack /* acknowledge number */
+#define s_alo s_shdr.si_alo /* allocation number */
+#define s_dport s_shdr.si_dna.x_port /* where we are sending */
+ struct sphdr s_rhdr; /* last received header (in effect!)*/
+ u_short s_rack; /* their acknowledge number */
+ u_short s_ralo; /* their allocation number */
+ u_short s_snt; /* highest packet # we have sent */
+
+/* timeout stuff */
+ short s_idle; /* time idle */
+ short s_timer[TCPT_NTIMERS]; /* timers */
+ short s_rxtshift; /* log(2) of rexmt exp. backoff */
+ u_short s_rtseq; /* packet being timed */
+ short s_rtt; /* timer for round trips */
+ short s_srtt; /* averaged timer */
+ char s_force; /* which timer expired */
+
+/* out of band data */
+ char s_oobflags;
+#define SF_SOOB 0x08 /* sending out of band data */
+#define SF_IOOB 0x10 /* receiving out of band data */
+ char s_iobc; /* input characters */
+/* debug stuff */
+ u_short s_want; /* Last candidate for sending */
+};
+
+#define nstosppcb(np) ((struct sppcb *)(np)->nsp_pcb)
+#define sotosppcb(so) (nstosppcb(sotonspcb(so)))
+
+struct spp_istat {
+ short hdrops;
+ short badsum;
+ short badlen;
+ short slotim;
+ short fastim;
+ short nonucn;
+ short noconn;
+ short notme;
+ short wrncon;
+ short bdreas;
+ short gonawy;
+ short notyet;
+ short lstdup;
+};
+
+#ifdef KERNEL
+struct spp_istat spp_istat;
+u_short spp_iss;
+extern struct sppcb *spp_close(), *spp_disconnect(),
+/* *spp_usrclosed(), *spp_timers(), *spp_drop();*/
+#endif
+
+#define SPP_ISSINCR 128
+/*
+ * SPP sequence numbers are 16 bit integers operated
+ * on with modular arithmetic. These macros can be
+ * used to compare such integers.
+ */
+#define SSEQ_LT(a,b) (((short)((a)-(b))) < 0)
+#define SSEQ_LEQ(a,b) (((short)((a)-(b))) <= 0)
+#define SSEQ_GT(a,b) (((short)((a)-(b))) > 0)
+#define SSEQ_GEQ(a,b) (((short)((a)-(b))) >= 0)
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)nlist.h 5.1 (Berkeley) 5/30/85
+ */
+
+/*
+ * Format of a symbol table entry; this file is included by <a.out.h>
+ * and should be used if you aren't interested the a.out header
+ * or relocation information.
+ */
+struct nlist {
+ char *n_name; /* for use when in-core */
+ unsigned char n_type; /* type flag, i.e. N_TEXT etc; see below */
+ char n_other; /* unused */
+ short n_desc; /* see <stab.h> */
+ unsigned long n_value; /* value of this symbol (or sdb offset) */
+};
+#define n_hash n_desc /* used internally by ld */
+
+/*
+ * Simple values for n_type.
+ */
+#define N_UNDF 0x0 /* undefined */
+#define N_ABS 0x2 /* absolute */
+#define N_TEXT 0x4 /* text */
+#define N_DATA 0x6 /* data */
+#define N_BSS 0x8 /* bss */
+#define N_COMM 0x12 /* common (internal to ld) */
+#define N_FN 0x1f /* file name symbol */
+
+#define N_EXT 01 /* external bit, or'ed in */
+#define N_TYPE 0x1e /* mask for all the type bits */
+
+/*
+ * Sdb entries have some of the N_STAB bits set.
+ * These are given in <stab.h>
+ */
+#define N_STAB 0xe0 /* if any of these bits set, a SDB entry */
+
+/*
+ * Format for namelist values.
+ */
+#define N_FORMAT "%08x"
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)pcc.h 5.1 (Berkeley) 5/30/85
+ */
+
+/*
+ * This file contains definitions for all the constants and structures
+ * needed to use the intermediate code files generated and read by
+ * the Portable C Compiler and related compilers.
+ *
+ * Rules for changing this code:
+ * 1) All op values must be integer constants -- this permits us to run
+ * a 'sed' script on this file to create %term declarations for yacc.
+ * 2) Because the PCC uses fancy ASG and UNARY macros, assignment
+ * operators must have values 1 greater than corresponding normal
+ * operators, and unary operators must have values 2 greater ditto.
+ * 3) Ops used only by f1 must have values >= 150 (PCCF_FORTOPS).
+ * 4) Other language-dependent ops must have values >= 200.
+ */
+
+# ifndef PCC_TOKENS
+
+# define PCC_TOKENS 0
+
+# define PCC_ERROR 1 /* an error node */
+# define PCC_FREE 2 /* an unused node */
+
+/*
+ * Constants.
+ */
+# define PCC_STRING 3 /* a string constant */
+# define PCC_ICON 4 /* an integer constant */
+# define PCC_FCON 5 /* a floating point constant */
+# define PCC_DCON 6 /* a double precision f.p. constant */
+
+/*
+ * Leaf types.
+ */
+# define PCC_NAME 7 /* an identifier */
+# define PCC_REG 8 /* a register */
+# define PCC_OREG 9 /* register and offset */
+# define PCC_CCODES 10 /* condition codes */
+# define PCC_FLD 11 /* a bit field */
+
+/*
+ * Arithmetic operators.
+ */
+# define PCC_PLUS 12 /* + */
+# define PCC_PLUSEQ 13 /* += */
+# define PCC_UPLUS 14 /* unary + (for completeness) */
+# define PCC_MINUS 15 /* - */
+# define PCC_MINUSEQ 16 /* -= */
+# define PCC_UMINUS 17 /* unary - */
+# define PCC_MUL 18 /* * */
+# define PCC_MULEQ 19 /* *= */
+/* Reserve a slot for 'unary *', which is PCC jargon for PCC_DEREF (yech) */
+# define PCC_DIV 21 /* / */
+# define PCC_DIVEQ 22 /* /= */
+# define PCC_MOD 23 /* % */
+# define PCC_MODEQ 24 /* %= */
+# define PCC_INCR 25 /* ++ */
+# define PCC_DECR 26 /* -- */
+# define PCC_ASSIGN 27 /* = (these last 3 are stretching it) */
+
+/*
+ * Bit operators.
+ */
+# define PCC_AND 28 /* & */
+# define PCC_ANDEQ 29 /* &= */
+/* Reserve a slot for 'unary &', jargon for PCC_ADDROF */
+# define PCC_OR 31 /* | */
+# define PCC_OREQ 32 /* |= */
+# define PCC_ER 33 /* ^ */
+# define PCC_EREQ 34 /* ^= */
+# define PCC_LS 35 /* << */
+# define PCC_LSEQ 36 /* <<= */
+# define PCC_RS 37 /* >> */
+# define PCC_RSEQ 38 /* >>= */
+# define PCC_COMPL 39 /* ~ */
+
+/*
+ * Booleans.
+ */
+# define PCC_EQ 40 /* == */
+# define PCC_NE 41 /* != */
+# define PCC_LE 42 /* <= */
+# define PCC_LT 43 /* < */
+# define PCC_GE 44 /* >= */
+# define PCC_GT 45 /* > */
+# define PCC_ULE 46 /* unsigned <= */
+# define PCC_ULT 47 /* unsigned < */
+# define PCC_UGE 48 /* unsigned >= */
+# define PCC_UGT 49 /* unsigned > */
+# define PCC_QUEST 50 /* ? (for conditional expressions) */
+# define PCC_COLON 51 /* : (for conditional expressions) */
+# define PCC_ANDAND 52 /* && */
+# define PCC_OROR 53 /* || */
+# define PCC_NOT 54 /* ! */
+
+/*
+ * Function calls.
+ */
+# define PCC_CALL 55 /* call by value */
+/* no ASG */
+# define PCC_UCALL 57 /* call with no arguments */
+# define PCC_FORTCALL 58 /* call by reference? */
+/* no ASG */
+# define PCC_UFORTCALL 60 /* ??? */
+# ifdef INLINE
+# define PCC_INLINE 61 /* inline function */
+/* no ASG */
+# define PCC_UINLINE 63 /* inline with no arguments */
+# endif INLINE
+
+/*
+ * Referencing and dereferencing.
+ */
+# define PCC_DEREF 20 /* * */
+# define PCC_ADDROF 30 /* & */
+
+/*
+ * Special structure operators.
+ */
+# define PCC_DOT 64 /* . */
+# define PCC_STREF 65 /* -> */
+# define PCC_STASG 66 /* structure assignment */
+# define PCC_STARG 67 /* an argument of type structure */
+# define PCC_STCALL 68 /* a function of type structure */
+/* no ASG */
+# define PCC_USTCALL 70 /* unary structure function */
+
+/*
+ * Conversions.
+ */
+# define PCC_SCONV 71 /* scalar conversion */
+# define PCC_PCONV 72 /* pointer conversion */
+# define PCC_PMCONV 73 /* pointer multiply conversion */
+# define PCC_PVCONV 74 /* pointer divide conversion */
+# define PCC_CAST 75 /* redundant? */
+
+/*
+ * Bracket types.
+ */
+# define PCC_LB 76 /* [ */
+# define PCC_RB 77 /* ] */
+
+/*
+ * Comma nodes.
+ */
+# define PCC_COMOP 78 /* , (in expressions) */
+# define PCC_CM 79 /* , (in argument lists) */
+
+/*
+ * Miscellaneous.
+ */
+# define PCC_FORCE 80 /* result of last expression goes in r0 */
+# define PCC_GOTO 81 /* unconditional goto */
+# define PCC_CBRANCH 82 /* goto label if !test */
+# define PCC_RETURN 83 /* return from function */
+# define PCC_INIT 84 /* initialized data */
+# define PCC_TYPE 85 /* a type */
+# define PCC_CLASS 86 /* a storage class */
+
+# define PCC_MAXOP 86 /* highest numbered PCC op */
+
+/*
+ * Special codes for interfacing to /lib/f1.
+ */
+# define PCCF_FORTOPS 150
+# define PCCF_FTEXT 150 /* pass literal assembler text */
+# define PCCF_FEXPR 151 /* a statement */
+# define PCCF_FSWITCH 152 /* not implemented */
+# define PCCF_FLBRAC 153 /* beginning of subroutine */
+# define PCCF_FRBRAC 154 /* end of subroutine */
+# define PCCF_FEOF 155 /* end of file */
+# define PCCF_FARIF 156 /* not implemented */
+# define PCCF_FLABEL 157 /* an f77 label */
+
+# endif PCC_TOKENS
+
+
+/*
+ * Types, as encoded in intermediate file cookies.
+ */
+# define PCCT_UNDEF 0
+# define PCCT_FARG 1 /* function argument */
+# define PCCT_CHAR 2
+# define PCCT_SHORT 3
+# define PCCT_INT 4
+# define PCCT_LONG 5
+# define PCCT_FLOAT 6
+# define PCCT_DOUBLE 7
+# define PCCT_STRTY 8
+# define PCCT_UNIONTY 9
+# define PCCT_ENUMTY 10
+# define PCCT_MOETY 11 /* member of enum */
+# define PCCT_UCHAR 12
+# define PCCT_USHORT 13
+# define PCCT_UNSIGNED 14
+# define PCCT_ULONG 15
+
+/*
+ * Type modifiers.
+ */
+# define PCCTM_PTR 020
+# define PCCTM_FTN 040
+# define PCCTM_ARY 060
+# define PCCTM_BASETYPE 017
+# define PCCTM_TYPESHIFT 2
+
+
+/*
+ * Useful macros. 'PCCOM' macros apply to ops.
+ */
+# define PCCOM_ASG 1+
+# define PCCOM_UNARY 2+
+# define PCCOM_NOASG (-1)+
+# define PCCOM_NOUNARY (-2)+
+
+# define PCCM_TRIPLE(op, var, type) \
+ ((op) | ((var) << 8) | (long) (type) << 16)
+# define PCCM_TEXT(s) \
+ PCCM_TRIPLE(PCCF_FTEXT, (strlen(s) + 3) / 4, 0)
+# define PCCM_ADDTYPE(t, m) \
+ ((((t) &~ PCCTM_BASETYPE) << PCCTM_TYPESHIFT) | \
+ (m) | ((t) & PCCTM_BASETYPE))
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dumprestore.h 5.1 (Berkeley) 6/5/85
+ */
+
+/*
+ * TP_BSIZE is the size of file blocks on the dump tapes.
+ * Note that TP_BSIZE must be a multiple of DEV_BSIZE.
+ *
+ * NTREC is the number of TP_BSIZE blocks that are written
+ * in each tape record. HIGHDENSITYTREC is the number of
+ * TP_BSIZE blocks that are written in each tape record on
+ * 6250 BPI or higher density tapes.
+ *
+ * TP_NINDIR is the number of indirect pointers in a TS_INODE
+ * or TS_ADDR record. Note that it must be a power of two.
+ */
+#define TP_BSIZE 1024
+#define NTREC 10
+#define HIGHDENSITYTREC 32
+#define TP_NINDIR (TP_BSIZE/2)
+
+#define TS_TAPE 1
+#define TS_INODE 2
+#define TS_BITS 3
+#define TS_ADDR 4
+#define TS_END 5
+#define TS_CLRI 6
+#define OFS_MAGIC (int)60011
+#define NFS_MAGIC (int)60012
+#define CHECKSUM (int)84446
+
+union u_spcl {
+ char dummy[TP_BSIZE];
+ struct s_spcl {
+ int c_type;
+ time_t c_date;
+ time_t c_ddate;
+ int c_volume;
+ daddr_t c_tapea;
+ ino_t c_inumber;
+ int c_magic;
+ int c_checksum;
+ struct dinode c_dinode;
+ int c_count;
+ char c_addr[TP_NINDIR];
+ } s_spcl;
+} u_spcl;
+
+#define spcl u_spcl.s_spcl
+
+#define DUMPOUTFMT "%-16s %c %s" /* for printf */
+ /* name, incno, ctime(date) */
+#define DUMPINFMT "%16s %c %[^\n]\n" /* inverse for scanf */
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)protocol.h 5.1 (Berkeley) 6/4/85
+ */
+
+/*
+ * Routing Information Protocol
+ *
+ * Derived from Xerox NS Routing Information Protocol
+ * by changing 32-bit net numbers to sockaddr's and
+ * padding stuff to 32-bit boundaries.
+ */
+#define RIPVERSION 1
+
+struct netinfo {
+ struct sockaddr rip_dst; /* destination net/host */
+ int rip_metric; /* cost of route */
+};
+
+struct rip {
+ u_char rip_cmd; /* request/response */
+ u_char rip_vers; /* protocol version # */
+ u_char rip_res1[2]; /* pad to 32-bit boundary */
+ union {
+ struct netinfo ru_nets[1]; /* variable length... */
+ char ru_tracefile[1]; /* ditto ... */
+ } ripun;
+#define rip_nets ripun.ru_nets
+#define rip_tracefile ripun.ru_tracefile
+};
+
+/*
+ * Packet types.
+ */
+#define RIPCMD_REQUEST 1 /* want info */
+#define RIPCMD_RESPONSE 2 /* responding to request */
+#define RIPCMD_TRACEON 3 /* turn tracing on */
+#define RIPCMD_TRACEOFF 4 /* turn it off */
+
+#define RIPCMD_MAX 5
+#ifdef RIPCMDS
+char *ripcmds[RIPCMD_MAX] =
+ { "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" };
+#endif
+
+#define HOPCNT_INFINITY 16 /* per Xerox NS */
+#define MAXPACKETSIZE 512 /* max broadcast size */
+
+/*
+ * Timer values used in managing the routing table.
+ * Every update forces an entry's timer to be reset. After
+ * EXPIRE_TIME without updates, the entry is marked invalid,
+ * but held onto until GARBAGE_TIME so that others may
+ * see it "be deleted".
+ */
+#define TIMER_RATE 30 /* alarm clocks every 30 seconds */
+
+#define SUPPLY_INTERVAL 30 /* time to supply tables */
+
+#define EXPIRE_TIME 180 /* time to mark entry invalid */
+#define GARBAGE_TIME 240 /* time to garbage collect */
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)rwhod.h 5.1 (Berkeley) 5/28/85
+ */
+
+/*
+ * rwho protocol packet format.
+ */
+struct outmp {
+ char out_line[8]; /* tty name */
+ char out_name[8]; /* user id */
+ long out_time; /* time on */
+};
+
+struct whod {
+ char wd_vers; /* protocol version # */
+ char wd_type; /* packet type, see below */
+ char wd_pad[2];
+ int wd_sendtime; /* time stamp by sender */
+ int wd_recvtime; /* time stamp applied by receiver */
+ char wd_hostname[32]; /* hosts's name */
+ int wd_loadav[3]; /* load average as in uptime */
+ int wd_boottime; /* time system booted */
+ struct whoent {
+ struct outmp we_utmp; /* active tty info */
+ int we_idle; /* tty idle time */
+ } wd_we[1024 / sizeof (struct whoent)];
+};
+
+#define WHODVERSION 1
+#define WHODTYPE_STATUS 1 /* host status */
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)talkd.h 5.2 (Berkeley) 3/13/86
+ */
+
+/*#include <sys/types.h>*/
+/*#include <sys/socket.h>*/
+/*
+ * This describes the protocol used by the talk server and clients.
+ *
+ * The talk server acts a repository of invitations, responding to
+ * requests by clients wishing to rendezvous for the purpose of
+ * holding a conversation. In normal operation, a client, the caller,
+ * initiates a rendezvous by sending a CTL_MSG to the server of
+ * type LOOK_UP. This causes the server to search its invitation
+ * tables to check if an invitation currently exists for the caller
+ * (to speak to the callee specified in the message). If the lookup
+ * fails, the caller then sends an ANNOUNCE message causing the server
+ * to broadcast an announcement on the callee's login ports requesting
+ * contact. When the callee responds, the local server uses the
+ * recorded invitation to respond with the appropriate rendezvous
+ * address and the caller and callee client programs establish a
+ * stream connection through which the conversation takes place.
+ */
+
+/*
+ * Client->server request message format.
+ */
+typedef struct {
+ u_char vers; /* protocol version */
+ u_char type; /* request type, see below */
+ u_char answer; /* not used */
+ u_char pad;
+ u_long id_num; /* message id */
+ struct sockaddr addr;
+ struct sockaddr ctl_addr;
+ long pid; /* caller's process id */
+#define NAME_SIZE 12
+ char l_name[NAME_SIZE];/* caller's name */
+ char r_name[NAME_SIZE];/* callee's name */
+#define TTY_SIZE 16
+ char r_tty[TTY_SIZE];/* callee's tty name */
+} CTL_MSG;
+
+/*
+ * Server->client response message format.
+ */
+typedef struct {
+ u_char vers; /* protocol version */
+ u_char type; /* type of request message, see below */
+ u_char answer; /* respose to request message, see below */
+ u_char pad;
+ u_long id_num; /* message id */
+ struct sockaddr addr; /* address for establishing conversation */
+} CTL_RESPONSE;
+
+#define TALK_VERSION 1 /* protocol version */
+
+/* message type values */
+#define LEAVE_INVITE 0 /* leave invitation with server */
+#define LOOK_UP 1 /* check for invitation by callee */
+#define DELETE 2 /* delete invitation by caller */
+#define ANNOUNCE 3 /* announce invitation by caller */
+
+/* answer values */
+#define SUCCESS 0 /* operation completed properly */
+#define NOT_HERE 1 /* callee not logged in */
+#define FAILED 2 /* operation failed for unexplained reason */
+#define MACHINE_UNKNOWN 3 /* caller's machine name unknown */
+#define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */
+#define UNKNOWN_REQUEST 5 /* request has invalid type value */
+#define BADVERSION 6 /* request has invalid protocol version */
+#define BADADDR 7 /* request has invalid addr value */
+#define BADCTLADDR 8 /* request has invalid ctl_addr value */
+
+/*
+ * Operational parameters.
+ */
+#define MAX_LIFE 60 /* max time daemon saves invitations */
+/* RING_WAIT should be 10's of seconds less than MAX_LIFE */
+#define RING_WAIT 30 /* time to wait before resending invitation */
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+/* @(#)timed.h 1.6 (Berkeley) 5/28/86 */
+
+/*
+ * Time Synchronization Protocol
+ */
+
+#define TSPVERSION 1
+#define ANYADDR NULL
+
+struct tsp {
+ u_char tsp_type;
+ u_char tsp_vers;
+ u_short tsp_seq;
+ union {
+ struct timeval tspu_time;
+ char tspu_hopcnt;
+ } tsp_u;
+ char tsp_name[MAXHOSTNAMELEN];
+};
+
+#define tsp_time tsp_u.tspu_time
+#define tsp_hopcnt tsp_u.tspu_hopcnt
+
+/*
+ * Command types.
+ */
+#define TSP_ANY 0 /* match any types */
+#define TSP_ADJTIME 1 /* send adjtime */
+#define TSP_ACK 2 /* generic acknowledgement */
+#define TSP_MASTERREQ 3 /* ask for master's name */
+#define TSP_MASTERACK 4 /* acknowledge master request */
+#define TSP_SETTIME 5 /* send network time */
+#define TSP_MASTERUP 6 /* inform slaves that master is up */
+#define TSP_SLAVEUP 7 /* slave is up but not polled */
+#define TSP_ELECTION 8 /* advance candidature for master */
+#define TSP_ACCEPT 9 /* support candidature of master */
+#define TSP_REFUSE 10 /* reject candidature of master */
+#define TSP_CONFLICT 11 /* two or more masters present */
+#define TSP_RESOLVE 12 /* masters' conflict resolution */
+#define TSP_QUIT 13 /* reject candidature if master is up */
+#define TSP_DATE 14 /* reset the time (date command) */
+#define TSP_DATEREQ 15 /* remote request to reset the time */
+#define TSP_DATEACK 16 /* acknowledge time setting */
+#define TSP_TRACEON 17 /* turn tracing on */
+#define TSP_TRACEOFF 18 /* turn tracing off */
+#define TSP_MSITE 19 /* find out master's site */
+#define TSP_MSITEREQ 20 /* remote master's site request */
+#define TSP_TEST 21 /* for testing election algo */
+#define TSP_SETDATE 22 /* New from date command */
+#define TSP_SETDATEREQ 23 /* New remote for above */
+#define TSP_LOOP 24 /* loop detection packet */
+
+#define TSPTYPENUMBER 25
+
+#ifdef TSPTYPES
+char *tsptype[TSPTYPENUMBER] =
+ { "ANY", "ADJTIME", "ACK", "MASTERREQ", "MASTERACK", "SETTIME", "MASTERUP",
+ "SLAVEUP", "ELECTION", "ACCEPT", "REFUSE", "CONFLICT", "RESOLVE", "QUIT",
+ "DATE", "DATEREQ", "DATEACK", "TRACEON", "TRACEOFF", "MSITE", "MSITEREQ",
+ "TEST", "SETDATE", "SETDATEREQ", "LOOP" };
+#endif
--- /dev/null
+/* pwd.h 4.1 83/05/03 */
+
+struct passwd { /* see getpwent(3) */
+ char *pw_name;
+ char *pw_passwd;
+ int pw_uid;
+ int pw_gid;
+ int pw_quota;
+ char *pw_comment;
+ char *pw_gecos;
+ char *pw_dir;
+ char *pw_shell;
+};
+
+/*struct passwd *getpwent(), *getpwuid(), *getpwnam();*/
--- /dev/null
+/* ranlib.h 4.1 83/05/03 */
+
+/*
+ * Structure of the __.SYMDEF table of contents for an archive.
+ * __.SYMDEF begins with a word giving the number of ranlib structures
+ * which immediately follow, and then continues with a string
+ * table consisting of a word giving the number of bytes of strings
+ * which follow and then the strings themselves.
+ * The ran_strx fields index the string table whose first byte is numbered 0.
+ */
+struct ranlib {
+ union {
+ off_t ran_strx; /* string table index of */
+ char *ran_name; /* symbol defined by */
+ } ran_un;
+ off_t ran_off; /* library member at this offset */
+};
--- /dev/null
+
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)resolv.h 5.4 (Berkeley) 2/22/86
+ */
+
+/*
+ * Global defines and variables for resolver stub.
+ */
+
+
+#define MAXNS 3 /* max # name servers we'll track */
+
+
+struct state {
+ int retrans; /* retransmition time interval */
+ int retry; /* number of times to retransmit */
+ long options; /* option flags - see below. */
+ int nscount; /* number of name servers */
+ struct sockaddr_in nsaddr_list[MAXNS]; /* address of name server */
+#define nsaddr nsaddr_list[0] /* for backward compatibility */
+ u_short id; /* current packet id */
+ char defdname[MAXDNAME]; /* default domain */
+};
+
+/*
+ * Resolver options
+ */
+#define RES_INIT 0x0001 /* address initialized */
+#define RES_DEBUG 0x0002 /* print debug messages */
+#define RES_AAONLY 0x0004 /* authoritative answers only */
+#define RES_USEVC 0x0008 /* use virtual circuit */
+#define RES_PRIMARY 0x0010 /* query primary server only */
+#define RES_IGNTC 0x0020 /* ignore trucation errors */
+#define RES_RECURSE 0x0040 /* recursion desired */
+#define RES_DEFNAMES 0x0080 /* use default domain name */
+#define RES_STAYOPEN 0x0100 /* Keep TCP socket open */
+
+extern struct state _res;
+/*extern char *p_cdname(), *p_rr(), *p_type(), *p_class();*/
--- /dev/null
+/* setjmp.h 4.1 83/05/03 */
+
+typedef int jmp_buf[10];
--- /dev/null
+/* sgtty.h 4.2 85/01/03 */
+
+/*#ifndef _IOCTL_*/
+/*#include <sys/ioctl.h>*/
+/*#endif*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)signal.h 7.1 (Berkeley) 6/4/86
+ */
+
+#ifndef NSIG
+#define NSIG 32
+
+#define SIGHUP 1 /* hangup */
+#define SIGINT 2 /* interrupt */
+#define SIGQUIT 3 /* quit */
+#define SIGILL 4 /* illegal instruction (not reset when caught) */
+#define ILL_RESAD_FAULT 0x0 /* reserved addressing fault */
+#define ILL_PRIVIN_FAULT 0x1 /* privileged instruction fault */
+#define ILL_RESOP_FAULT 0x2 /* reserved operand fault */
+/* CHME, CHMS, CHMU are not yet given back to users reasonably */
+#define SIGTRAP 5 /* trace trap (not reset when caught) */
+#define SIGIOT 6 /* IOT instruction */
+#define SIGABRT SIGIOT /* compatibility */
+#define SIGEMT 7 /* EMT instruction */
+#define SIGFPE 8 /* floating point exception */
+#define FPE_INTOVF_TRAP 0x1 /* integer overflow */
+#define FPE_INTDIV_TRAP 0x2 /* integer divide by zero */
+#define FPE_FLTOVF_TRAP 0x3 /* floating overflow */
+#define FPE_FLTDIV_TRAP 0x4 /* floating/decimal divide by zero */
+#define FPE_FLTUND_TRAP 0x5 /* floating underflow */
+#define FPE_DECOVF_TRAP 0x6 /* decimal overflow */
+#define FPE_SUBRNG_TRAP 0x7 /* subscript out of range */
+#define FPE_FLTOVF_FAULT 0x8 /* floating overflow fault */
+#define FPE_FLTDIV_FAULT 0x9 /* divide by zero floating fault */
+#define FPE_FLTUND_FAULT 0xa /* floating underflow fault */
+#define SIGKILL 9 /* kill (cannot be caught or ignored) */
+#define SIGBUS 10 /* bus error */
+#define SIGSEGV 11 /* segmentation violation */
+#define SIGSYS 12 /* bad argument to system call */
+#define SIGPIPE 13 /* write on a pipe with no one to read it */
+#define SIGALRM 14 /* alarm clock */
+#define SIGTERM 15 /* software termination signal from kill */
+#define SIGURG 16 /* urgent condition on IO channel */
+#define SIGSTOP 17 /* sendable stop signal not from tty */
+#define SIGTSTP 18 /* stop signal from tty */
+#define SIGCONT 19 /* continue a stopped process */
+#define SIGCHLD 20 /* to parent on child stop or exit */
+#define SIGCLD SIGCHLD /* compatibility */
+#define SIGTTIN 21 /* to readers pgrp upon background tty read */
+#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
+#define SIGIO 23 /* input/output possible signal */
+#define SIGXCPU 24 /* exceeded CPU time limit */
+#define SIGXFSZ 25 /* exceeded file size limit */
+#define SIGVTALRM 26 /* virtual time alarm */
+#define SIGPROF 27 /* profiling time alarm */
+#define SIGWINCH 28 /* window size changes */
+#define SIGUSR1 30 /* user defined signal 1 */
+#define SIGUSR2 31 /* user defined signal 2 */
+
+#ifndef KERNEL
+/*int (*signal())();*/
+#endif
+
+/*
+ * Signal vector "template" used in sigvec call.
+ */
+struct sigvec {
+/* int (*sv_handler)();*/ /* signal handler */
+ int sv_mask; /* signal mask to apply */
+ int sv_flags; /* see signal options below */
+};
+#define SV_ONSTACK 0x0001 /* take signal on signal stack */
+#define SV_INTERRUPT 0x0002 /* do not restart system on signal return */
+#define sv_onstack sv_flags /* isn't compatibility wonderful! */
+
+/*
+ * Structure used in sigstack call.
+ */
+struct sigstack {
+ char *ss_sp; /* signal stack pointer */
+ int ss_onstack; /* current status */
+};
+
+/*
+ * Information pushed on stack when a signal is delivered.
+ * This is used by the kernel to restore state following
+ * execution of the signal handler. It is also made available
+ * to the handler to allow it to properly restore state if
+ * a non-standard exit is performed.
+ */
+struct sigcontext {
+ int sc_onstack; /* sigstack state to restore */
+ int sc_mask; /* signal mask to restore */
+ int sc_sp; /* sp to restore */
+ int sc_fp; /* fp to restore */
+ int sc_ap; /* ap to restore */
+ int sc_pc; /* pc to restore */
+ int sc_ps; /* psl to restore */
+};
+
+#define BADSIG (int (*)())-1
+#define SIG_DFL (int (*)())0
+#define SIG_IGN (int (*)())1
+
+#ifdef KERNEL
+#define SIG_CATCH (int (*)())2
+#define SIG_HOLD (int (*)())3
+#endif
+#endif
+
+/*
+ * Macro for converting signal number to a mask suitable for
+ * sigblock().
+ */
+#define sigmask(m) (1 << ((m)-1))
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)stab.h 5.1 (Berkeley) 5/30/85
+ */
+
+/* IF YOU ADD DEFINITIONS, ADD THEM TO nm.c as well */
+/*
+ * This file gives definitions supplementing <a.out.h>
+ * for permanent symbol table entries.
+ * These must have one of the N_STAB bits on,
+ * and are subject to relocation according to the masks in <a.out.h>.
+ */
+/*
+ * for symbolic debugger, sdb(1):
+ */
+#define N_GSYM 0x20 /* global symbol: name,,0,type,0 */
+#define N_FNAME 0x22 /* procedure name (f77 kludge): name,,0 */
+#define N_FUN 0x24 /* procedure: name,,0,linenumber,address */
+#define N_STSYM 0x26 /* static symbol: name,,0,type,address */
+#define N_LCSYM 0x28 /* .lcomm symbol: name,,0,type,address */
+#define N_RSYM 0x40 /* register sym: name,,0,type,register */
+#define N_SLINE 0x44 /* src line: 0,,0,linenumber,address */
+#define N_SSYM 0x60 /* structure elt: name,,0,type,struct_offset */
+#define N_SO 0x64 /* source file name: name,,0,0,address */
+#define N_LSYM 0x80 /* local sym: name,,0,type,offset */
+#define N_SOL 0x84 /* #included file name: name,,0,0,address */
+#define N_PSYM 0xa0 /* parameter: name,,0,type,offset */
+#define N_ENTRY 0xa4 /* alternate entry: name,linenumber,address */
+#define N_LBRAC 0xc0 /* left bracket: 0,,0,nesting level,address */
+#define N_RBRAC 0xe0 /* right bracket: 0,,0,nesting level,address */
+#define N_BCOMM 0xe2 /* begin common: name,, */
+#define N_ECOMM 0xe4 /* end common: name,, */
+#define N_ECOML 0xe8 /* end common (local name): ,,address */
+#define N_LENG 0xfe /* second stab entry with length information */
+
+/*
+ * for the berkeley pascal compiler, pc(1):
+ */
+#define N_PC 0x30 /* global pascal symbol: name,,0,subtype,line */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)saio.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Header file for standalone package
+ */
+
+/*
+ * Io block: includes an
+ * inode, cells for the use of seek, etc,
+ * and a buffer.
+ */
+struct iob {
+ int i_flgs; /* see F_ below */
+ struct inode i_ino; /* inode, if file */
+ int i_unit; /* pseudo device unit */
+ daddr_t i_boff; /* block offset on device */
+ daddr_t i_cyloff; /* cylinder offset on device */
+ off_t i_offset; /* seek offset in file */
+ daddr_t i_bn; /* 1st block # of next read */
+ char *i_ma; /* memory address of i/o buffer */
+ int i_cc; /* character count of transfer */
+ int i_error; /* error # return */
+ int i_errcnt; /* error count for driver retries */
+ int i_errblk; /* block # in error for error reporting */
+ char i_buf[MAXBSIZE];/* i/o buffer */
+ union {
+ struct fs ui_fs; /* file system super block info */
+ char dummy[SBSIZE];
+ } i_un;
+};
+#define i_fs i_un.ui_fs
+#define NULL 0
+
+#define F_READ 0x1 /* file opened for reading */
+#define F_WRITE 0x2 /* file opened for writing */
+#define F_ALLOC 0x4 /* buffer allocated */
+#define F_FILE 0x8 /* file instead of device */
+#define F_NBSF 0x10 /* no bad sector forwarding */
+#define F_SSI 0x40 /* set skip sector inhibit */
+/* io types */
+#define F_RDDATA 0x0100 /* read data */
+#define F_WRDATA 0x0200 /* write data */
+#define F_HDR 0x0400 /* include header on next i/o */
+#define F_CHECK 0x0800 /* perform check of data read/write */
+#define F_HCHECK 0x1000 /* perform check of header and data */
+
+#define F_TYPEMASK 0xff00
+
+/*
+ * Device switch.
+ */
+struct devsw {
+ char *dv_name;
+/* int (*dv_strategy)();*/
+/* int (*dv_open)();*/
+/* int (*dv_close)();*/
+/* int (*dv_ioctl)();*/
+};
+
+struct devsw devsw[];
+
+/*
+ * Drive description table.
+ * Returned from SAIODEVDATA call.
+ */
+struct st {
+ short nsect; /* # sectors/track */
+ short ntrak; /* # tracks/surfaces/heads */
+ short nspc; /* # sectors/cylinder */
+ short ncyl; /* # cylinders */
+ short *off; /* partition offset table (cylinders) */
+};
+
+/*
+ * Request codes. Must be the same a F_XXX above
+ */
+#define READ 1
+#define WRITE 2
+
+#define NBUFS 4
+
+char b[NBUFS][MAXBSIZE];
+daddr_t blknos[NBUFS];
+
+#define NFILES 4
+struct iob iob[NFILES];
+
+extern int errno; /* just like unix */
+
+/* error codes */
+#define EBADF 1 /* bad file descriptor */
+#define EOFFSET 2 /* relative seek not supported */
+#define EDEV 3 /* improper device specification on open */
+#define ENXIO 4 /* unknown device specified */
+#define EUNIT 5 /* improper unit specification */
+#define ESRCH 6 /* directory search for file failed */
+#define EIO 7 /* generic error */
+#define ECMD 10 /* undefined driver command */
+#define EBSE 11 /* bad sector error */
+#define EWCK 12 /* write check error */
+#define EECC 13 /* uncorrectable ecc error */
+#define EHER 14 /* hard error */
+
+/* ioctl's -- for disks just now */
+#define SAIOHDR (('d'<<8)|1) /* next i/o includes header */
+#define SAIOCHECK (('d'<<8)|2) /* next i/o checks data */
+#define SAIOHCHECK (('d'<<8)|3) /* next i/o checks header & data */
+#define SAIONOBAD (('d'<<8)|4) /* inhibit bad sector forwarding */
+#define SAIODOBAD (('d'<<8)|5) /* enable bad sector forwarding */
+#define SAIOECCLIM (('d'<<8)|6) /* set limit to ecc correction, bits */
+#define SAIORETRIES (('d'<<8)|7) /* set retry count for unit */
+#define SAIODEVDATA (('d'<<8)|8) /* get device data */
+#define SAIOSSI (('d'<<8)|9) /* set skip sector inhibit */
+#define SAIONOSSI (('d'<<8)|10) /* inhibit skip sector handling */
+#define SAIOSSDEV (('d'<<8)|11) /* is device skip sector type? */
+#define SAIODEBUG (('d'<<8)|12) /* enable/disable debugging */
+#define SAIOGBADINFO (('d'<<8)|13) /* get bad-sector table */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)savax.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Standalone definitions peculiar to vaxen
+ * The mba devices in the standalone system are addressed as
+ * xx(unit,section)
+ * where unit is
+ * 8*mbanum+drive
+ * The mbadrv macro gives the address of the device registers
+ * for the specified unit; the mbamba macro gives the address of the
+ * mba registers themselves.
+ *
+ * The uba devices are also addressed by giving, as unit,
+ * 8*ubanum+drive
+ * The ubamem macro converts a specified unibus address (ala pdp-11)
+ * into a unibus memory address space address.
+ */
+
+int cpu; /* see <sys/cpu.h> */
+
+#define MAXNMBA 4
+#define MAXNUBA 4
+struct mba_regs **mbaddr;
+int mbaact;
+caddr_t *umaddr;
+struct uba_regs **ubaddr;
+
+#define UNITTOMBA(unit) ((unit)>>3)
+#define UNITTODRIVE(unit) ((unit)&07)
+
+#define mbamba(unit) (mbaddr[UNITTOMBA(unit)])
+#define mbadrv(unit) (&mbamba(unit)->mba_drv[UNITTODRIVE(unit)])
+
+#define UNITTOUBA(unit) ((unit)>>3)
+#define ubauba(unit) (ubaddr[UNITTOUBA(unit)])
+#define ubamem(unit, off) ((umaddr[UNITTOUBA(unit)]+ubdevreg(off)))
+
+#define PHYSUBA0 0x20006000
+#define PHYSMBA0 0x20010000
+#define PHYSMBA1 0x20012000
+#define PHYSUMEM 0x2013e000
+
+/*
+ * RM03/5 (4-byte header plus CRC) format information:
+ * codes for sector header word 1
+ */
+#define HDR1_FMT22 0x1000 /* standard 16 bit format */
+#define HDR1_OKSCT 0xc000 /* sector ok */
+#define HDR1_SSF 0x2000 /* skip sector flag */
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)stdio.h 5.3 (Berkeley) 3/15/86
+ */
+
+/*# ifndef FILE*/
+#define BUFSIZ 1024
+extern struct _iobuf {
+ int _cnt;
+ char *_ptr; /* should be unsigned char */
+ char *_base; /* ditto */
+ int _bufsiz;
+ short _flag;
+ char _file; /* should be short */
+} _iob[];
+
+#define _IOREAD 01
+#define _IOWRT 02
+#define _IONBF 04
+#define _IOMYBUF 010
+#define _IOEOF 020
+#define _IOERR 040
+#define _IOSTRG 0100
+#define _IOLBF 0200
+#define _IORW 0400
+#define NULL 0
+#define FILE struct _iobuf
+#define EOF (-1)
+
+#define stdin (&_iob[0])
+#define stdout (&_iob[1])
+#define stderr (&_iob[2])
+#ifndef lint
+#define getc(p) (--(p)->_cnt>=0? (int)(*(unsigned char *)(p)->_ptr++):_filbuf(p))
+#endif not lint
+#define getchar() getc(stdin)
+#ifndef lint
+#define putc(x, p) (--(p)->_cnt >= 0 ?\
+ (int)(*(unsigned char *)(p)->_ptr++ = (x)) :\
+ (((p)->_flag & _IOLBF) && -(p)->_cnt < (p)->_bufsiz ?\
+ ((*(p)->_ptr = (x)) != '\n' ?\
+ (int)(*(unsigned char *)(p)->_ptr++) :\
+ _flsbuf(*(unsigned char *)(p)->_ptr, p)) :\
+ _flsbuf((unsigned char)(x), p)))
+#endif not lint
+#define putchar(x) putc(x,stdout)
+#define feof(p) (((p)->_flag&_IOEOF)!=0)
+#define ferror(p) (((p)->_flag&_IOERR)!=0)
+#define fileno(p) ((p)->_file)
+#define clearerr(p) ((p)->_flag &= ~(_IOERR|_IOEOF))
+
+/*FILE *fopen();*/
+/*FILE *fdopen();*/
+/*FILE *freopen();*/
+/*FILE *popen();*/
+/*long ftell();*/
+/*char *fgets();*/
+/*char *gets();*/
+#if 0 /*def vax*/
+/*char *sprintf();*/ /* too painful to do right */
+#endif
+/*# endif*/
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)string.h 5.1 (Berkeley) 85/08/05
+ */
+
+/*#include <strings.h>*/
+
+/*
+ * these next few are obsolete trash
+ */
+
+/*extern char *strcpyn();*/
+/*extern char *strcatn();*/
+/*extern int strcmpn();*/
+
+/*
+ * and the rest are Sys5 functions supported just so
+ * Sys5 progs will compile easily.
+ */
+
+/*extern char *strchr();*/
+/*extern char *strrchr();*/
+/*extern char *strpbrk();*/
+/*extern int strspn();*/
+/*extern int strcspn();*/
+/*extern char *strtok();*/
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)strings.h 5.1 (Berkeley) 5/30/85
+ */
+
+/*
+ * External function definitions
+ * for routines described in string(3).
+ */
+/*char *strcat();*/
+/*char *strncat();*/
+/*int strcmp();*/
+/*int strncmp();*/
+/*char *strcpy();*/
+/*char *strncpy();*/
+/*int strlen();*/
+/*char *index();*/
+/*char *rindex();*/
--- /dev/null
+/* struct.h 4.1 83/05/03 */
+
+/*
+ * access to information relating to the fields of a structure
+ */
+
+#define fldoff(str, fld) ((int)&(((struct str *)0)->fld))
+#define fldsiz(str, fld) (sizeof(((struct str *)0)->fld))
+#define strbase(str, ptr, fld) ((struct str *)((char *)(ptr)-fldoff(str, fld)))
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)acct.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Accounting structures;
+ * these use a comp_t type which is a 3 bits base 8
+ * exponent, 13 bit fraction ``floating point'' number.
+ * Units are 1/AHZ seconds.
+ */
+typedef u_short comp_t;
+
+struct acct
+{
+ char ac_comm[10]; /* Accounting command name */
+ comp_t ac_utime; /* Accounting user time */
+ comp_t ac_stime; /* Accounting system time */
+ comp_t ac_etime; /* Accounting elapsed time */
+ time_t ac_btime; /* Beginning time */
+ uid_t ac_uid; /* Accounting user ID */
+ gid_t ac_gid; /* Accounting group ID */
+ short ac_mem; /* average memory usage */
+ comp_t ac_io; /* number of disk IO blocks */
+ dev_t ac_tty; /* control typewriter */
+ char ac_flag; /* Accounting flag */
+};
+
+#define AFORK 0001 /* has executed fork, but no exec */
+#define ASU 0002 /* used super-user privileges */
+#define ACOMPAT 0004 /* used compatibility mode */
+#define ACORE 0010 /* dumped core */
+#define AXSIG 0020 /* killed by a signal */
+
+/*
+ * 1/AHZ is the granularity of the data encoded in the various
+ * comp_t fields. This is not necessarily equal to hz.
+ */
+#define AHZ 64
+
+#ifdef KERNEL
+struct acct acctbuf;
+struct inode *acctp;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)bkmac.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Macro definition of bk.c/netinput().
+ * This is used to replace a call to
+ * (*linesw[tp->t_line].l_rint)(c,tp);
+ * with
+ *
+ * if (tp->t_line == NETLDISC)
+ * BKINPUT(c, tp);
+ * else
+ * (*linesw[tp->t_line].l_rint)(c,tp);
+ */
+#define BKINPUT(c, tp) { \
+ if ((tp)->t_rec == 0) { \
+ *(tp)->t_cp++ = c; \
+ if (++(tp)->t_inbuf == 1024 || (c) == '\n') { \
+ (tp)->t_rec = 1; \
+ wakeup((caddr_t)&(tp)->t_rawq); \
+ } \
+ } \
+}
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)buf.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * The header for buffers in the buffer pool and otherwise used
+ * to describe a block i/o request is given here. The routines
+ * which manipulate these things are given in bio.c.
+ *
+ * Each buffer in the pool is usually doubly linked into 2 lists:
+ * hashed into a chain by <dev,blkno> so it can be located in the cache,
+ * and (usually) on (one of several) queues. These lists are circular and
+ * doubly linked for easy removal.
+ *
+ * There are currently three queues for buffers:
+ * one for buffers which must be kept permanently (super blocks)
+ * one for buffers containing ``useful'' information (the cache)
+ * one for buffers containing ``non-useful'' information
+ * (and empty buffers, pushed onto the front)
+ * The latter two queues contain the buffers which are available for
+ * reallocation, are kept in lru order. When not on one of these queues,
+ * the buffers are ``checked out'' to drivers which use the available list
+ * pointers to keep track of them in their i/o active queues.
+ */
+
+/*
+ * Bufhd structures used at the head of the hashed buffer queues.
+ * We only need three words for these, so this abbreviated
+ * definition saves some space.
+ */
+struct bufhd
+{
+ long b_flags; /* see defines below */
+ struct buf *b_forw, *b_back; /* fwd/bkwd pointer in chain */
+};
+struct buf
+{
+ long b_flags; /* too much goes here to describe */
+ struct buf *b_forw, *b_back; /* hash chain (2 way street) */
+ struct buf *av_forw, *av_back; /* position on free list if not BUSY */
+#define b_actf av_forw /* alternate names for driver queue */
+#define b_actl av_back /* head - isn't history wonderful */
+ long b_bcount; /* transfer count */
+ long b_bufsize; /* size of allocated buffer */
+#define b_active b_bcount /* driver queue head: drive active */
+ short b_error; /* returned after I/O */
+ dev_t b_dev; /* major+minor device name */
+ union {
+ caddr_t b_addr; /* low order core address */
+ int *b_words; /* words for clearing */
+ struct fs *b_fs; /* superblocks */
+ struct csum *b_cs; /* superblock summary information */
+ struct cg *b_cg; /* cylinder group block */
+ struct dinode *b_dino; /* ilist */
+ daddr_t *b_daddr; /* indirect block */
+ } b_un;
+ daddr_t b_blkno; /* block # on device */
+ long b_resid; /* words not transferred after error */
+#define b_errcnt b_resid /* while i/o in progress: # retries */
+ struct proc *b_proc; /* proc doing physical or swap I/O */
+/* int (*b_iodone)();*/ /* function called by iodone */
+ int b_pfcent; /* center page when swapping cluster */
+};
+
+#define BQUEUES 4 /* number of free buffer queues */
+
+#define BQ_LOCKED 0 /* super-blocks &c */
+#define BQ_LRU 1 /* lru, useful buffers */
+#define BQ_AGE 2 /* rubbish */
+#define BQ_EMPTY 3 /* buffer headers with no memory */
+
+#ifdef KERNEL
+#define BUFHSZ 512
+#define RND (MAXBSIZE/DEV_BSIZE)
+#if ((BUFHSZ&(BUFHSZ-1)) == 0)
+#define BUFHASH(dev, dblkno) \
+ ((struct buf *)&bufhash[((int)(dev)+(((int)(dblkno))/RND))&(BUFHSZ-1)])
+#else
+#define BUFHASH(dev, dblkno) \
+ ((struct buf *)&bufhash[((int)(dev)+(((int)(dblkno))/RND)) % BUFHSZ])
+#endif
+
+struct buf *buf; /* the buffer pool itself */
+char *buffers;
+int nbuf; /* number of buffer headers */
+int bufpages; /* number of memory pages in the buffer pool */
+struct buf *swbuf; /* swap I/O headers */
+int nswbuf;
+struct bufhd bufhash[BUFHSZ]; /* heads of hash lists */
+struct buf bfreelist[BQUEUES]; /* heads of available lists */
+struct buf bswlist; /* head of free swap header list */
+struct buf *bclnlist; /* head of cleaned page list */
+
+/*struct buf *alloc();*/
+/*struct buf *realloccg();*/
+/*struct buf *baddr();*/
+/*struct buf *getblk();*/
+/*struct buf *geteblk();*/
+/*struct buf *getnewbuf();*/
+/*struct buf *bread();*/
+/*struct buf *breada();*/
+
+/*unsigned minphys();*/
+#endif
+
+/*
+ * These flags are kept in b_flags.
+ */
+#define B_WRITE 0x000000 /* non-read pseudo-flag */
+#define B_READ 0x000001 /* read when I/O occurs */
+#define B_DONE 0x000002 /* transaction finished */
+#define B_ERROR 0x000004 /* transaction aborted */
+#define B_BUSY 0x000008 /* not on av_forw/back list */
+#define B_PHYS 0x000010 /* physical IO */
+#define B_XXX 0x000020 /* was B_MAP, alloc UNIBUS on pdp-11 */
+#define B_WANTED 0x000040 /* issue wakeup when BUSY goes off */
+#define B_AGE 0x000080 /* delayed write for correct aging */
+#define B_ASYNC 0x000100 /* don't wait for I/O completion */
+#define B_DELWRI 0x000200 /* write at exit of avail list */
+#define B_TAPE 0x000400 /* this is a magtape (no bdwrite) */
+#define B_UAREA 0x000800 /* add u-area to a swap operation */
+#define B_PAGET 0x001000 /* page in/out of page table space */
+#define B_DIRTY 0x002000 /* dirty page to be pushed out async */
+#define B_PGIN 0x004000 /* pagein op, so swap() can count it */
+#define B_CACHE 0x008000 /* did bread find us in the cache ? */
+#define B_INVAL 0x010000 /* does not contain valid info */
+#define B_LOCKED 0x020000 /* locked in core (not reusable) */
+#define B_HEAD 0x040000 /* a buffer header, not a buffer */
+#define B_BAD 0x100000 /* bad block revectoring in progress */
+#define B_CALL 0x200000 /* call b_iodone from iodone */
+
+/*
+ * Insq/Remq for the buffer hash lists.
+ */
+#define bremhash(bp) { \
+ (bp)->b_back->b_forw = (bp)->b_forw; \
+ (bp)->b_forw->b_back = (bp)->b_back; \
+}
+#define binshash(bp, dp) { \
+ (bp)->b_forw = (dp)->b_forw; \
+ (bp)->b_back = (dp); \
+ (dp)->b_forw->b_back = (bp); \
+ (dp)->b_forw = (bp); \
+}
+
+/*
+ * Insq/Remq for the buffer free lists.
+ */
+#define bremfree(bp) { \
+ (bp)->av_back->av_forw = (bp)->av_forw; \
+ (bp)->av_forw->av_back = (bp)->av_back; \
+}
+#define binsheadfree(bp, dp) { \
+ (dp)->av_forw->av_back = (bp); \
+ (bp)->av_forw = (dp)->av_forw; \
+ (dp)->av_forw = (bp); \
+ (bp)->av_back = (dp); \
+}
+#define binstailfree(bp, dp) { \
+ (dp)->av_back->av_forw = (bp); \
+ (bp)->av_back = (dp)->av_back; \
+ (dp)->av_back = (bp); \
+ (bp)->av_forw = (dp); \
+}
+
+/*
+ * Take a buffer off the free list it's on and
+ * mark it as being use (B_BUSY) by a device.
+ */
+#define notavail(bp) { \
+/* int x = splbio();*/ \
+ bremfree(bp); \
+ (bp)->b_flags |= B_BUSY; \
+ splx(x); \
+}
+
+#define iodone biodone
+#define iowait biowait
+
+/*
+ * Zero out a buffer's data portion.
+ */
+#define clrbuf(bp) { \
+ blkclr((bp)->b_un.b_addr, (unsigned)(bp)->b_bcount); \
+ (bp)->b_resid = 0; \
+}
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)callout.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * The callout structure is for
+ * a routine arranging
+ * to be called by the clock interrupt
+ * (clock.c) with a specified argument,
+ * in a specified amount of time.
+ * Used, for example, to time tab
+ * delays on typewriters.
+ */
+
+struct callout {
+ int c_time; /* incremental time */
+ caddr_t c_arg; /* argument to routine */
+/* int (*c_func)();*/ /* routine */
+ struct callout *c_next;
+};
+#ifdef KERNEL
+struct callout *callfree, *callout, calltodo;
+int ncallout;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)clist.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Raw structures for the character list routines.
+ */
+struct cblock {
+ struct cblock *c_next;
+ char c_info[CBSIZE];
+};
+#ifdef KERNEL
+struct cblock *cfree;
+int nclist;
+struct cblock *cfreelist;
+int cfreecount;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)cmap.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * core map entry
+ *
+ * Limits imposed by this structure:
+ *
+ * limit cur. size fields
+ * Physical memory* 64 Mb c_next, c_prev, c_hlink
+ * Mounted filesystems 255 c_mdev
+ * size of a process segment 1 Gb c_page
+ * filesystem size 8 Gb c_blkno
+ * proc, text table size 64K c_ndx
+ *
+ * * memory can be expanded by converting first three entries
+ * to bit fields of larger than 16 bits, shrinking c_ndx accordingly,
+ * and increasing MAXMEM below. Also, the type of cmhash
+ * (below) must be changed to long.
+ */
+/*#ifndef LOCORE*/
+struct cmap
+{
+unsigned short c_next, /* index of next free list entry */
+ c_prev, /* index of previous free list entry */
+ c_hlink; /* hash link for <blkno,mdev> */
+unsigned short c_ndx; /* index of owner proc or text */
+unsigned int c_page:21, /* virtual page number in segment */
+ c_lock:1, /* locked for raw i/o or pagein */
+ c_want:1, /* wanted */
+ c_intrans:1, /* intransit bit */
+ c_free:1, /* on the free list */
+ c_gone:1, /* associated page has been released */
+ c_type:2, /* type CSYS or CTEXT or CSTACK or CDATA */
+ :4, /* to longword boundary */
+ c_blkno:24, /* disk block this is a copy of */
+ c_mdev:8; /* which mounted dev this is from */
+};
+#else LOCORE
+/*
+ * bit offsets of elements in cmap
+ */
+#define C_INTRANS 87
+#define C_FREE 88
+#define SZ_CMAP 16 /* sizeof(struct cmap) */
+
+#define MAXMEM 64*1024 /* maximum memory, in Kbytes */
+#endif LOCORE
+
+#define CMHEAD 0
+
+/*
+ * Shared text pages are not totally abandoned when a process
+ * exits, but are remembered while in the free list hashed by <mdev,blkno>
+ * off the cmhash structure so that they can be reattached
+ * if another instance of the program runs again soon.
+ */
+#define CMHSIZ 2048 /* SHOULD BE DYNAMIC */
+#define CMHASH(bn) ((bn)&(CMHSIZ-1))
+
+#ifndef LOCORE
+#ifdef KERNEL
+struct cmap *cmap;
+struct cmap *ecmap;
+int ncmap;
+/*struct cmap *mfind();*/
+int firstfree, maxfree;
+int ecmx; /* cmap index of ecmap */
+u_short cmhash[CMHSIZ];
+#endif
+
+/* bits defined in c_type */
+
+#define CSYS 0 /* none of below */
+#define CTEXT 1 /* belongs to shared text segment */
+#define CDATA 2 /* belongs to data segment */
+#define CSTACK 3 /* belongs to stack segment */
+
+#define pgtocm(x) (((int) ((x)-firstfree) / CLSIZE) + 1)
+#define cmtopg(x) ((((x)-1) * CLSIZE) + firstfree)
+/*#endif*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)conf.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Declaration of block device
+ * switch. Each entry (row) is
+ * the only link between the
+ * main unix code and the driver.
+ * The initialization of the
+ * device switches is in the
+ * file conf.c.
+ */
+struct bdevsw
+{
+/* int (*d_open)();*/
+/* int (*d_close)();*/
+/* int (*d_strategy)();*/
+/* int (*d_dump)();*/
+/* int (*d_psize)();*/
+ int d_flags;
+};
+#ifdef KERNEL
+struct bdevsw bdevsw[];
+#endif
+
+/*
+ * Character device switch.
+ */
+struct cdevsw
+{
+/* int (*d_open)();*/
+/* int (*d_close)();*/
+/* int (*d_read)();*/
+/* int (*d_write)();*/
+/* int (*d_ioctl)();*/
+/* int (*d_stop)();*/
+/* int (*d_reset)();*/
+ struct tty *d_ttys;
+/* int (*d_select)();*/
+/* int (*d_mmap)();*/
+};
+#ifdef KERNEL
+struct cdevsw cdevsw[];
+#endif
+
+/*
+ * tty line control switch.
+ */
+struct linesw
+{
+/* int (*l_open)();*/
+/* int (*l_close)();*/
+/* int (*l_read)();*/
+/* int (*l_write)();*/
+/* int (*l_ioctl)();*/
+/* int (*l_rint)();*/
+/* int (*l_rend)();*/
+/* int (*l_meta)();*/
+/* int (*l_start)();*/
+/* int (*l_modem)();*/
+};
+#ifdef KERNEL
+struct linesw linesw[];
+#endif
+
+/*
+ * Swap device information
+ */
+struct swdevt
+{
+ dev_t sw_dev;
+ int sw_freed;
+ int sw_nblks;
+};
+#ifdef KERNEL
+struct swdevt swdevt[];
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dir.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * A directory consists of some number of blocks of DIRBLKSIZ
+ * bytes, where DIRBLKSIZ is chosen such that it can be transferred
+ * to disk in a single atomic operation (e.g. 512 bytes on most machines).
+ *
+ * Each DIRBLKSIZ byte block contains some number of directory entry
+ * structures, which are of variable length. Each directory entry has
+ * a struct direct at the front of it, containing its inode number,
+ * the length of the entry, and the length of the name contained in
+ * the entry. These are followed by the name padded to a 4 byte boundary
+ * with null bytes. All names are guaranteed null terminated.
+ * The maximum length of a name in a directory is MAXNAMLEN.
+ *
+ * The macro DIRSIZ(dp) gives the amount of space required to represent
+ * a directory entry. Free space in a directory is represented by
+ * entries which have dp->d_reclen > DIRSIZ(dp). All DIRBLKSIZ bytes
+ * in a directory block are claimed by the directory entries. This
+ * usually results in the last entry in a directory having a large
+ * dp->d_reclen. When entries are deleted from a directory, the
+ * space is returned to the previous entry in the same directory
+ * block by increasing its dp->d_reclen. If the first entry of
+ * a directory block is free, then its dp->d_ino is set to 0.
+ * Entries other than the first in a directory do not normally have
+ * dp->d_ino set to 0.
+ */
+/* so user programs can just include dir.h */
+#if !defined(KERNEL) && !defined(DEV_BSIZE)
+#define DEV_BSIZE 512
+#endif
+#define DIRBLKSIZ DEV_BSIZE
+#define MAXNAMLEN 255
+
+struct direct {
+ u_long d_ino; /* inode number of entry */
+ u_short d_reclen; /* length of this record */
+ u_short d_namlen; /* length of string in d_name */
+ char d_name[MAXNAMLEN + 1]; /* name must be no longer than this */
+};
+
+/*
+ * The DIRSIZ macro gives the minimum record length which will hold
+ * the directory entry. This requires the amount of space in struct direct
+ * without the d_name field, plus enough space for the name with a terminating
+ * null byte (dp->d_namlen+1), rounded up to a 4 byte boundary.
+ */
+#undef DIRSIZ
+#define DIRSIZ(dp) \
+ ((sizeof (struct direct) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
+
+#ifndef KERNEL
+/*
+ * Definitions for library routines operating on directories.
+ */
+typedef struct _dirdesc {
+ int dd_fd;
+ long dd_loc;
+ long dd_size;
+ char dd_buf[DIRBLKSIZ];
+} DIR;
+#ifndef NULL
+#define NULL 0
+#endif
+/*extern DIR *opendir();*/
+/*extern struct direct *readdir();*/
+/*extern long telldir();*/
+/*extern void seekdir();*/
+#define rewinddir(dirp) seekdir((dirp), (long)0)
+/*extern void closedir();*/
+#endif
+
+#ifdef KERNEL
+/*
+ * Template for manipulating directories.
+ * Should use struct direct's, but the name field
+ * is MAXNAMLEN - 1, and this just won't do.
+ */
+struct dirtemplate {
+ u_long dot_ino;
+ short dot_reclen;
+ short dot_namlen;
+ char dot_name[4]; /* must be multiple of 4 */
+ u_long dotdot_ino;
+ short dotdot_reclen;
+ short dotdot_namlen;
+ char dotdot_name[4]; /* ditto */
+};
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dk.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Instrumentation
+ */
+#define CPUSTATES 4
+
+#define CP_USER 0
+#define CP_NICE 1
+#define CP_SYS 2
+#define CP_IDLE 3
+
+#define DK_NDRIVE 4
+
+#ifdef KERNEL
+long cp_time[CPUSTATES];
+int dk_ndrive;
+int dk_busy;
+long dk_time[DK_NDRIVE];
+long dk_seek[DK_NDRIVE];
+long dk_xfer[DK_NDRIVE];
+long dk_wds[DK_NDRIVE];
+float dk_mspw[DK_NDRIVE];
+
+long tk_nin;
+long tk_nout;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dkbad.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Definitions needed to perform bad sector
+ * revectoring ala DEC STD 144.
+ *
+ * The bad sector information is located in the
+ * first 5 even numbered sectors of the last
+ * track of the disk pack. There are five
+ * identical copies of the information, described
+ * by the dkbad structure.
+ *
+ * Replacement sectors are allocated starting with
+ * the first sector before the bad sector information
+ * and working backwards towards the beginning of
+ * the disk. A maximum of 126 bad sectors are supported.
+ * The position of the bad sector in the bad sector table
+ * determines which replacement sector it corresponds to.
+ *
+ * The bad sector information and replacement sectors
+ * are conventionally only accessible through the
+ * 'c' file system partition of the disk. If that
+ * partition is used for a file system, the user is
+ * responsible for making sure that it does not overlap
+ * the bad sector information or any replacement sector.s
+ */
+
+struct dkbad {
+ long bt_csn; /* cartridge serial number */
+ u_short bt_mbz; /* unused; should be 0 */
+ u_short bt_flag; /* -1 => alignment cartridge */
+ struct bt_bad {
+ u_short bt_cyl; /* cylinder number of bad sector */
+ u_short bt_trksec; /* track and sector number */
+ } bt_bad[126];
+};
+
+#define ECC 0
+#define SSE 1
+#define BSE 2
+#define CONT 3
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dmap.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Definitions for the mapping of vitual swap
+ * space to the physical swap area - the disk map.
+ */
+
+#define NDMAP 38 /* size of the swap area map */
+
+struct dmap
+{
+ swblk_t dm_size; /* current size used by process */
+ swblk_t dm_alloc; /* amount of physical swap space allocated */
+ swblk_t dm_map[NDMAP]; /* first disk block number in each chunk */
+};
+#ifdef KERNEL
+struct dmap zdmap;
+int dmmin, dmmax, dmtext;
+#endif
+
+/*
+ * The following structure is that ``returned''
+ * from a call to vstodb().
+ */
+struct dblock
+{
+ swblk_t db_base; /* base of physical contig drum block */
+ swblk_t db_size; /* size of block */
+};
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)domain.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Structure per communications domain.
+ */
+struct domain {
+ int dom_family; /* AF_xxx */
+ char *dom_name;
+/* int (*dom_init)();*/ /* initialize domain data structures */
+/* int (*dom_externalize)();*/ /* externalize access rights */
+/* int (*dom_dispose)();*/ /* dispose of internalized rights */
+ struct protosw *dom_protosw, *dom_protoswNPROTOSW;
+ struct domain *dom_next;
+};
+
+#ifdef KERNEL
+struct domain *domains;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)errno.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Error codes
+ */
+
+#define EPERM 1 /* Not owner */
+#define ENOENT 2 /* No such file or directory */
+#define ESRCH 3 /* No such process */
+#define EINTR 4 /* Interrupted system call */
+#define EIO 5 /* I/O error */
+#define ENXIO 6 /* No such device or address */
+#define E2BIG 7 /* Arg list too long */
+#define ENOEXEC 8 /* Exec format error */
+#define EBADF 9 /* Bad file number */
+#define ECHILD 10 /* No children */
+#define EAGAIN 11 /* No more processes */
+#define ENOMEM 12 /* Not enough core */
+#define EACCES 13 /* Permission denied */
+#define EFAULT 14 /* Bad address */
+#define ENOTBLK 15 /* Block device required */
+#define EBUSY 16 /* Mount device busy */
+#define EEXIST 17 /* File exists */
+#define EXDEV 18 /* Cross-device link */
+#define ENODEV 19 /* No such device */
+#define ENOTDIR 20 /* Not a directory*/
+#define EISDIR 21 /* Is a directory */
+#define EINVAL 22 /* Invalid argument */
+#define ENFILE 23 /* File table overflow */
+#define EMFILE 24 /* Too many open files */
+#define ENOTTY 25 /* Not a typewriter */
+#define ETXTBSY 26 /* Text file busy */
+#define EFBIG 27 /* File too large */
+#define ENOSPC 28 /* No space left on device */
+#define ESPIPE 29 /* Illegal seek */
+#define EROFS 30 /* Read-only file system */
+#define EMLINK 31 /* Too many links */
+#define EPIPE 32 /* Broken pipe */
+
+/* math software */
+#define EDOM 33 /* Argument too large */
+#define ERANGE 34 /* Result too large */
+
+/* non-blocking and interrupt i/o */
+#define EWOULDBLOCK 35 /* Operation would block */
+#define EDEADLK EWOULDBLOCK /* ditto */
+#define EINPROGRESS 36 /* Operation now in progress */
+#define EALREADY 37 /* Operation already in progress */
+
+/* ipc/network software */
+
+ /* argument errors */
+#define ENOTSOCK 38 /* Socket operation on non-socket */
+#define EDESTADDRREQ 39 /* Destination address required */
+#define EMSGSIZE 40 /* Message too long */
+#define EPROTOTYPE 41 /* Protocol wrong type for socket */
+#define ENOPROTOOPT 42 /* Protocol not available */
+#define EPROTONOSUPPORT 43 /* Protocol not supported */
+#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
+#define EOPNOTSUPP 45 /* Operation not supported on socket */
+#define EPFNOSUPPORT 46 /* Protocol family not supported */
+#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
+#define EADDRINUSE 48 /* Address already in use */
+#define EADDRNOTAVAIL 49 /* Can't assign requested address */
+
+ /* operational errors */
+#define ENETDOWN 50 /* Network is down */
+#define ENETUNREACH 51 /* Network is unreachable */
+#define ENETRESET 52 /* Network dropped connection on reset */
+#define ECONNABORTED 53 /* Software caused connection abort */
+#define ECONNRESET 54 /* Connection reset by peer */
+#define ENOBUFS 55 /* No buffer space available */
+#define EISCONN 56 /* Socket is already connected */
+#define ENOTCONN 57 /* Socket is not connected */
+#define ESHUTDOWN 58 /* Can't send after socket shutdown */
+#define ETOOMANYREFS 59 /* Too many references: can't splice */
+#define ETIMEDOUT 60 /* Connection timed out */
+#define ECONNREFUSED 61 /* Connection refused */
+
+ /* */
+#define ELOOP 62 /* Too many levels of symbolic links */
+#define ENAMETOOLONG 63 /* File name too long */
+
+/* should be rearranged */
+#define EHOSTDOWN 64 /* Host is down */
+#define EHOSTUNREACH 65 /* No route to host */
+#define ENOTEMPTY 66 /* Directory not empty */
+
+/* quotas & mush */
+#define EPROCLIM 67 /* Too many processes */
+#define EUSERS 68 /* Too many users */
+#define EDQUOT 69 /* Disc quota exceeded */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)exec.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Header prepended to each a.out file.
+ */
+struct exec {
+ long a_magic; /* magic number */
+unsigned long a_text; /* size of text segment */
+unsigned long a_data; /* size of initialized data */
+unsigned long a_bss; /* size of uninitialized data */
+unsigned long a_syms; /* size of symbol table */
+unsigned long a_entry; /* entry point */
+unsigned long a_trsize; /* size of text relocation */
+unsigned long a_drsize; /* size of data relocation */
+};
+
+#define OMAGIC 0407 /* old impure format */
+#define NMAGIC 0410 /* read-only text */
+#define ZMAGIC 0413 /* demand load format */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)file.h 7.1 (Berkeley) 6/4/86
+ */
+
+#ifdef KERNEL
+/*
+ * Descriptor table entry.
+ * One for each kernel object.
+ */
+struct file {
+ int f_flag; /* see below */
+ short f_type; /* descriptor type */
+ short f_count; /* reference count */
+ short f_msgcount; /* references from message queue */
+ struct fileops {
+/* int (*fo_rw)();*/
+/* int (*fo_ioctl)();*/
+/* int (*fo_select)();*/
+/* int (*fo_close)();*/
+ } *f_ops;
+ caddr_t f_data; /* inode */
+ off_t f_offset;
+};
+
+struct file *file, *fileNFILE;
+int nfile;
+/*struct file *getf();*/
+/*struct file *falloc();*/
+#endif
+
+/*
+ * flags- also for fcntl call.
+ */
+#define FOPEN (-1)
+#define FREAD 00001 /* descriptor read/receive'able */
+#define FWRITE 00002 /* descriptor write/send'able */
+#ifndef F_DUPFD
+#define FNDELAY 00004 /* no delay */
+#define FAPPEND 00010 /* append on each write */
+#endif
+#define FMARK 00020 /* mark during gc() */
+#define FDEFER 00040 /* defer for next gc pass */
+#ifndef F_DUPFD
+#define FASYNC 00100 /* signal pgrp when data ready */
+#endif
+#define FSHLOCK 00200 /* shared lock present */
+#define FEXLOCK 00400 /* exclusive lock present */
+
+/* bits to save after open */
+#define FMASK 00113
+#define FCNTLCANT (FREAD|FWRITE|FMARK|FDEFER|FSHLOCK|FEXLOCK)
+
+/* open only modes */
+#define FCREAT 01000 /* create if nonexistant */
+#define FTRUNC 02000 /* truncate to zero length */
+#define FEXCL 04000 /* error if already created */
+
+#ifndef F_DUPFD
+/* fcntl(2) requests--from <fcntl.h> */
+#define F_DUPFD 0 /* Duplicate fildes */
+#define F_GETFD 1 /* Get fildes flags */
+#define F_SETFD 2 /* Set fildes flags */
+#define F_GETFL 3 /* Get file flags */
+#define F_SETFL 4 /* Set file flags */
+#define F_GETOWN 5 /* Get owner */
+#define F_SETOWN 6 /* Set owner */
+#endif
+
+/*
+ * User definitions.
+ */
+
+/*
+ * Open call.
+ */
+#define O_RDONLY 000 /* open for reading */
+#define O_WRONLY 001 /* open for writing */
+#define O_RDWR 002 /* open for read & write */
+#define O_NDELAY FNDELAY /* non-blocking open */
+#define O_APPEND FAPPEND /* append on each write */
+#define O_CREAT FCREAT /* open with file create */
+#define O_TRUNC FTRUNC /* open with truncation */
+#define O_EXCL FEXCL /* error on create if file exists */
+
+/*
+ * Flock call.
+ */
+#define LOCK_SH 1 /* shared lock */
+#define LOCK_EX 2 /* exclusive lock */
+#define LOCK_NB 4 /* don't block when locking */
+#define LOCK_UN 8 /* unlock */
+
+/*
+ * Access call.
+ */
+#define F_OK 0 /* does file exist */
+#define X_OK 1 /* is it executable by caller */
+#define W_OK 2 /* writable by caller */
+#define R_OK 4 /* readable by caller */
+
+/*
+ * Lseek call.
+ */
+#define L_SET 0 /* absolute offset */
+#define L_INCR 1 /* relative to current offset */
+#define L_XTND 2 /* relative to end of file */
+
+#ifdef KERNEL
+#define GETF(fp, fd) { \
+ if ((unsigned)(fd) >= NOFILE || ((fp) = u.u_ofile[fd]) == NULL) { \
+ u.u_error = EBADF; \
+ return; \
+ } \
+}
+#define DTYPE_INODE 1 /* file */
+#define DTYPE_SOCKET 2 /* communications endpoint */
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)fs.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Each disk drive contains some number of file systems.
+ * A file system consists of a number of cylinder groups.
+ * Each cylinder group has inodes and data.
+ *
+ * A file system is described by its super-block, which in turn
+ * describes the cylinder groups. The super-block is critical
+ * data and is replicated in each cylinder group to protect against
+ * catastrophic loss. This is done at mkfs time and the critical
+ * super-block data does not change, so the copies need not be
+ * referenced further unless disaster strikes.
+ *
+ * For file system fs, the offsets of the various blocks of interest
+ * are given in the super block as:
+ * [fs->fs_sblkno] Super-block
+ * [fs->fs_cblkno] Cylinder group block
+ * [fs->fs_iblkno] Inode blocks
+ * [fs->fs_dblkno] Data blocks
+ * The beginning of cylinder group cg in fs, is given by
+ * the ``cgbase(fs, cg)'' macro.
+ *
+ * The first boot and super blocks are given in absolute disk addresses.
+ */
+#define BBSIZE 8192
+#define SBSIZE 8192
+#define BBLOCK ((daddr_t)(0))
+#define SBLOCK ((daddr_t)(BBLOCK + BBSIZE / DEV_BSIZE))
+
+/*
+ * Addresses stored in inodes are capable of addressing fragments
+ * of `blocks'. File system blocks of at most size MAXBSIZE can
+ * be optionally broken into 2, 4, or 8 pieces, each of which is
+ * addressible; these pieces may be DEV_BSIZE, or some multiple of
+ * a DEV_BSIZE unit.
+ *
+ * Large files consist of exclusively large data blocks. To avoid
+ * undue wasted disk space, the last data block of a small file may be
+ * allocated as only as many fragments of a large block as are
+ * necessary. The file system format retains only a single pointer
+ * to such a fragment, which is a piece of a single large block that
+ * has been divided. The size of such a fragment is determinable from
+ * information in the inode, using the ``blksize(fs, ip, lbn)'' macro.
+ *
+ * The file system records space availability at the fragment level;
+ * to determine block availability, aligned fragments are examined.
+ *
+ * The root inode is the root of the file system.
+ * Inode 0 can't be used for normal purposes and
+ * historically bad blocks were linked to inode 1,
+ * thus the root inode is 2. (inode 1 is no longer used for
+ * this purpose, however numerous dump tapes make this
+ * assumption, so we are stuck with it)
+ * The lost+found directory is given the next available
+ * inode when it is created by ``mkfs''.
+ */
+#define ROOTINO ((ino_t)2) /* i number of all roots */
+#define LOSTFOUNDINO (ROOTINO + 1)
+
+/*
+ * Cylinder group related limits.
+ *
+ * For each cylinder we keep track of the availability of blocks at different
+ * rotational positions, so that we can lay out the data to be picked
+ * up with minimum rotational latency. NRPOS is the number of rotational
+ * positions which we distinguish. With NRPOS 8 the resolution of our
+ * summary information is 2ms for a typical 3600 rpm drive.
+ */
+#define NRPOS 8 /* number distinct rotational positions */
+
+/*
+ * MAXIPG bounds the number of inodes per cylinder group, and
+ * is needed only to keep the structure simpler by having the
+ * only a single variable size element (the free bit map).
+ *
+ * N.B.: MAXIPG must be a multiple of INOPB(fs).
+ */
+#define MAXIPG 2048 /* max number inodes/cyl group */
+
+/*
+ * MINBSIZE is the smallest allowable block size.
+ * In order to insure that it is possible to create files of size
+ * 2^32 with only two levels of indirection, MINBSIZE is set to 4096.
+ * MINBSIZE must be big enough to hold a cylinder group block,
+ * thus changes to (struct cg) must keep its size within MINBSIZE.
+ * MAXCPG is limited only to dimension an array in (struct cg);
+ * it can be made larger as long as that structures size remains
+ * within the bounds dictated by MINBSIZE.
+ * Note that super blocks are always of size SBSIZE,
+ * and that both SBSIZE and MAXBSIZE must be >= MINBSIZE.
+ */
+#define MINBSIZE 4096
+#define MAXCPG 32 /* maximum fs_cpg */
+
+/*
+ * The path name on which the file system is mounted is maintained
+ * in fs_fsmnt. MAXMNTLEN defines the amount of space allocated in
+ * the super block for this name.
+ * The limit on the amount of summary information per file system
+ * is defined by MAXCSBUFS. It is currently parameterized for a
+ * maximum of two million cylinders.
+ */
+#define MAXMNTLEN 512
+#define MAXCSBUFS 32
+
+/*
+ * Per cylinder group information; summarized in blocks allocated
+ * from first cylinder group data blocks. These blocks have to be
+ * read in from fs_csaddr (size fs_cssize) in addition to the
+ * super block.
+ *
+ * N.B. sizeof(struct csum) must be a power of two in order for
+ * the ``fs_cs'' macro to work (see below).
+ */
+struct csum {
+ long cs_ndir; /* number of directories */
+ long cs_nbfree; /* number of free blocks */
+ long cs_nifree; /* number of free inodes */
+ long cs_nffree; /* number of free frags */
+};
+
+/*
+ * Super block for a file system.
+ */
+#define FS_MAGIC 0x011954
+struct fs
+{
+ struct fs *fs_link; /* linked list of file systems */
+ struct fs *fs_rlink; /* used for incore super blocks */
+ daddr_t fs_sblkno; /* addr of super-block in filesys */
+ daddr_t fs_cblkno; /* offset of cyl-block in filesys */
+ daddr_t fs_iblkno; /* offset of inode-blocks in filesys */
+ daddr_t fs_dblkno; /* offset of first data after cg */
+ long fs_cgoffset; /* cylinder group offset in cylinder */
+ long fs_cgmask; /* used to calc mod fs_ntrak */
+ time_t fs_time; /* last time written */
+ long fs_size; /* number of blocks in fs */
+ long fs_dsize; /* number of data blocks in fs */
+ long fs_ncg; /* number of cylinder groups */
+ long fs_bsize; /* size of basic blocks in fs */
+ long fs_fsize; /* size of frag blocks in fs */
+ long fs_frag; /* number of frags in a block in fs */
+/* these are configuration parameters */
+ long fs_minfree; /* minimum percentage of free blocks */
+ long fs_rotdelay; /* num of ms for optimal next block */
+ long fs_rps; /* disk revolutions per second */
+/* these fields can be computed from the others */
+ long fs_bmask; /* ``blkoff'' calc of blk offsets */
+ long fs_fmask; /* ``fragoff'' calc of frag offsets */
+ long fs_bshift; /* ``lblkno'' calc of logical blkno */
+ long fs_fshift; /* ``numfrags'' calc number of frags */
+/* these are configuration parameters */
+ long fs_maxcontig; /* max number of contiguous blks */
+ long fs_maxbpg; /* max number of blks per cyl group */
+/* these fields can be computed from the others */
+ long fs_fragshift; /* block to frag shift */
+ long fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
+ long fs_sbsize; /* actual size of super block */
+ long fs_csmask; /* csum block offset */
+ long fs_csshift; /* csum block number */
+ long fs_nindir; /* value of NINDIR */
+ long fs_inopb; /* value of INOPB */
+ long fs_nspf; /* value of NSPF */
+ long fs_optim; /* optimization preference, see below */
+ long fs_sparecon[5]; /* reserved for future constants */
+/* sizes determined by number of cylinder groups and their sizes */
+ daddr_t fs_csaddr; /* blk addr of cyl grp summary area */
+ long fs_cssize; /* size of cyl grp summary area */
+ long fs_cgsize; /* cylinder group size */
+/* these fields should be derived from the hardware */
+ long fs_ntrak; /* tracks per cylinder */
+ long fs_nsect; /* sectors per track */
+ long fs_spc; /* sectors per cylinder */
+/* this comes from the disk driver partitioning */
+ long fs_ncyl; /* cylinders in file system */
+/* these fields can be computed from the others */
+ long fs_cpg; /* cylinders per group */
+ long fs_ipg; /* inodes per group */
+ long fs_fpg; /* blocks per group * fs_frag */
+/* this data must be re-computed after crashes */
+ struct csum fs_cstotal; /* cylinder summary information */
+/* these fields are cleared at mount time */
+ char fs_fmod; /* super block modified flag */
+ char fs_clean; /* file system is clean flag */
+ char fs_ronly; /* mounted read-only flag */
+ char fs_flags; /* currently unused flag */
+ char fs_fsmnt[MAXMNTLEN]; /* name mounted on */
+/* these fields retain the current block allocation info */
+ long fs_cgrotor; /* last cg searched */
+ struct csum *fs_csp[MAXCSBUFS];/* list of fs_cs info buffers */
+ long fs_cpc; /* cyl per cycle in postbl */
+ short fs_postbl[MAXCPG][NRPOS];/* head of blocks for each rotation */
+ long fs_magic; /* magic number */
+ u_char fs_rotbl[1]; /* list of blocks for each rotation */
+/* actually longer */
+};
+/*
+ * Preference for optimization.
+ */
+#define FS_OPTTIME 0 /* minimize allocation time */
+#define FS_OPTSPACE 1 /* minimize disk fragmentation */
+
+/*
+ * Convert cylinder group to base address of its global summary info.
+ *
+ * N.B. This macro assumes that sizeof(struct csum) is a power of two.
+ */
+#define fs_cs(fs, indx) \
+ fs_csp[(indx) >> (fs)->fs_csshift][(indx) & ~(fs)->fs_csmask]
+
+/*
+ * MAXBPC bounds the size of the rotational layout tables and
+ * is limited by the fact that the super block is of size SBSIZE.
+ * The size of these tables is INVERSELY proportional to the block
+ * size of the file system. It is aggravated by sector sizes that
+ * are not powers of two, as this increases the number of cylinders
+ * included before the rotational pattern repeats (fs_cpc).
+ * Its size is derived from the number of bytes remaining in (struct fs)
+ */
+#define MAXBPC (SBSIZE - sizeof (struct fs))
+
+/*
+ * Cylinder group block for a file system.
+ */
+#define CG_MAGIC 0x090255
+struct cg {
+ struct cg *cg_link; /* linked list of cyl groups */
+ struct cg *cg_rlink; /* used for incore cyl groups */
+ time_t cg_time; /* time last written */
+ long cg_cgx; /* we are the cgx'th cylinder group */
+ short cg_ncyl; /* number of cyl's this cg */
+ short cg_niblk; /* number of inode blocks this cg */
+ long cg_ndblk; /* number of data blocks this cg */
+ struct csum cg_cs; /* cylinder summary information */
+ long cg_rotor; /* position of last used block */
+ long cg_frotor; /* position of last used frag */
+ long cg_irotor; /* position of last used inode */
+ long cg_frsum[MAXFRAG]; /* counts of available frags */
+ long cg_btot[MAXCPG]; /* block totals per cylinder */
+ short cg_b[MAXCPG][NRPOS]; /* positions of free blocks */
+ char cg_iused[MAXIPG/NBBY]; /* used inode map */
+ long cg_magic; /* magic number */
+ u_char cg_free[1]; /* free block map */
+/* actually longer */
+};
+
+/*
+ * MAXBPG bounds the number of blocks of data per cylinder group,
+ * and is limited by the fact that cylinder groups are at most one block.
+ * Its size is derived from the size of blocks and the (struct cg) size,
+ * by the number of remaining bits.
+ */
+#define MAXBPG(fs) \
+ (fragstoblks((fs), (NBBY * ((fs)->fs_bsize - (sizeof (struct cg))))))
+
+/*
+ * Turn file system block numbers into disk block addresses.
+ * This maps file system blocks to device size blocks.
+ */
+#define fsbtodb(fs, b) ((b) << (fs)->fs_fsbtodb)
+#define dbtofsb(fs, b) ((b) >> (fs)->fs_fsbtodb)
+
+/*
+ * Cylinder group macros to locate things in cylinder groups.
+ * They calc file system addresses of cylinder group data structures.
+ */
+#define cgbase(fs, c) ((daddr_t)((fs)->fs_fpg * (c)))
+#define cgstart(fs, c) \
+ (cgbase(fs, c) + (fs)->fs_cgoffset * ((c) & ~((fs)->fs_cgmask)))
+#define cgsblock(fs, c) (cgstart(fs, c) + (fs)->fs_sblkno) /* super blk */
+#define cgtod(fs, c) (cgstart(fs, c) + (fs)->fs_cblkno) /* cg block */
+#define cgimin(fs, c) (cgstart(fs, c) + (fs)->fs_iblkno) /* inode blk */
+#define cgdmin(fs, c) (cgstart(fs, c) + (fs)->fs_dblkno) /* 1st data */
+
+/*
+ * Macros for handling inode numbers:
+ * inode number to file system block offset.
+ * inode number to cylinder group number.
+ * inode number to file system block address.
+ */
+#define itoo(fs, x) ((x) % INOPB(fs))
+#define itog(fs, x) ((x) / (fs)->fs_ipg)
+#define itod(fs, x) \
+ ((daddr_t)(cgimin(fs, itog(fs, x)) + \
+ (blkstofrags((fs), (((x) % (fs)->fs_ipg) / INOPB(fs))))))
+
+/*
+ * Give cylinder group number for a file system block.
+ * Give cylinder group block number for a file system block.
+ */
+#define dtog(fs, d) ((d) / (fs)->fs_fpg)
+#define dtogd(fs, d) ((d) % (fs)->fs_fpg)
+
+/*
+ * Extract the bits for a block from a map.
+ * Compute the cylinder and rotational position of a cyl block addr.
+ */
+#define blkmap(fs, map, loc) \
+ (((map)[(loc) / NBBY] >> ((loc) % NBBY)) & (0xff >> (NBBY - (fs)->fs_frag)))
+#define cbtocylno(fs, bno) \
+ ((bno) * NSPF(fs) / (fs)->fs_spc)
+#define cbtorpos(fs, bno) \
+ ((bno) * NSPF(fs) % (fs)->fs_spc % (fs)->fs_nsect * NRPOS / (fs)->fs_nsect)
+
+/*
+ * The following macros optimize certain frequently calculated
+ * quantities by using shifts and masks in place of divisions
+ * modulos and multiplications.
+ */
+#define blkoff(fs, loc) /* calculates (loc % fs->fs_bsize) */ \
+ ((loc) & ~(fs)->fs_bmask)
+#define fragoff(fs, loc) /* calculates (loc % fs->fs_fsize) */ \
+ ((loc) & ~(fs)->fs_fmask)
+#define lblkno(fs, loc) /* calculates (loc / fs->fs_bsize) */ \
+ ((loc) >> (fs)->fs_bshift)
+#define numfrags(fs, loc) /* calculates (loc / fs->fs_fsize) */ \
+ ((loc) >> (fs)->fs_fshift)
+#define blkroundup(fs, size) /* calculates roundup(size, fs->fs_bsize) */ \
+ (((size) + (fs)->fs_bsize - 1) & (fs)->fs_bmask)
+#define fragroundup(fs, size) /* calculates roundup(size, fs->fs_fsize) */ \
+ (((size) + (fs)->fs_fsize - 1) & (fs)->fs_fmask)
+#define fragstoblks(fs, frags) /* calculates (frags / fs->fs_frag) */ \
+ ((frags) >> (fs)->fs_fragshift)
+#define blkstofrags(fs, blks) /* calculates (blks * fs->fs_frag) */ \
+ ((blks) << (fs)->fs_fragshift)
+#define fragnum(fs, fsb) /* calculates (fsb % fs->fs_frag) */ \
+ ((fsb) & ((fs)->fs_frag - 1))
+#define blknum(fs, fsb) /* calculates rounddown(fsb, fs->fs_frag) */ \
+ ((fsb) &~ ((fs)->fs_frag - 1))
+
+/*
+ * Determine the number of available frags given a
+ * percentage to hold in reserve
+ */
+#define freespace(fs, percentreserved) \
+ (blkstofrags((fs), (fs)->fs_cstotal.cs_nbfree) + \
+ (fs)->fs_cstotal.cs_nffree - ((fs)->fs_dsize * (percentreserved) / 100))
+
+/*
+ * Determining the size of a file block in the file system.
+ */
+#define blksize(fs, ip, lbn) \
+ (((lbn) >= NDADDR || (ip)->i_size >= ((lbn) + 1) << (fs)->fs_bshift) \
+ ? (fs)->fs_bsize \
+ : (fragroundup(fs, blkoff(fs, (ip)->i_size))))
+#define dblksize(fs, dip, lbn) \
+ (((lbn) >= NDADDR || (dip)->di_size >= ((lbn) + 1) << (fs)->fs_bshift) \
+ ? (fs)->fs_bsize \
+ : (fragroundup(fs, blkoff(fs, (dip)->di_size))))
+
+/*
+ * Number of disk sectors per block; assumes DEV_BSIZE byte sector size.
+ */
+#define NSPB(fs) ((fs)->fs_nspf << (fs)->fs_fragshift)
+#define NSPF(fs) ((fs)->fs_nspf)
+
+/*
+ * INOPB is the number of inodes in a secondary storage block.
+ */
+#define INOPB(fs) ((fs)->fs_inopb)
+#define INOPF(fs) ((fs)->fs_inopb >> (fs)->fs_fragshift)
+
+/*
+ * NINDIR is the number of indirects in a file system block.
+ */
+#define NINDIR(fs) ((fs)->fs_nindir)
+
+#ifdef KERNEL
+/*struct fs *getfs();*/
+/*struct fs *mountfs();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)gprof.h 7.1 (Berkeley) 6/4/86
+ */
+
+struct phdr {
+ char *lpc;
+ char *hpc;
+ int ncnt;
+};
+
+ /*
+ * histogram counters are unsigned shorts (according to the kernel).
+ */
+#define HISTCOUNTER unsigned short
+
+ /*
+ * fraction of text space to allocate for histogram counters
+ * here, 1/2
+ */
+#define HISTFRACTION 2
+
+ /*
+ * Fraction of text space to allocate for from hash buckets.
+ * The value of HASHFRACTION is based on the minimum number of bytes
+ * of separation between two subroutine call points in the object code.
+ * Given MIN_SUBR_SEPARATION bytes of separation the value of
+ * HASHFRACTION is calculated as:
+ *
+ * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1);
+ *
+ * For the VAX, the shortest two call sequence is:
+ *
+ * calls $0,(r0)
+ * calls $0,(r0)
+ *
+ * which is separated by only three bytes, thus HASHFRACTION is
+ * calculated as:
+ *
+ * HASHFRACTION = 3 / (2 * 2 - 1) = 1
+ *
+ * Note that the division above rounds down, thus if MIN_SUBR_FRACTION
+ * is less than three, this algorithm will not work!
+ *
+ * NB: for the kernel we assert that the shortest two call sequence is:
+ *
+ * calls $0,_name
+ * calls $0,_name
+ *
+ * which is separated by seven bytes, thus HASHFRACTION is calculated as:
+ *
+ * HASHFRACTION = 7 / (2 * 2 - 1) = 2
+ */
+#define HASHFRACTION 2
+
+ /*
+ * percent of text space to allocate for tostructs
+ * with a minimum.
+ */
+#define ARCDENSITY 2
+#define MINARCS 50
+
+struct tostruct {
+ char *selfpc;
+ long count;
+ unsigned short link;
+};
+
+ /*
+ * a raw arc,
+ * with pointers to the calling site and the called site
+ * and a count.
+ */
+struct rawarc {
+ unsigned long raw_frompc;
+ unsigned long raw_selfpc;
+ long raw_count;
+};
+
+ /*
+ * general rounding functions.
+ */
+#define ROUNDDOWN(x,y) (((x)/(y))*(y))
+#define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y))
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)inode.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * The I node is the focus of all file activity in UNIX.
+ * There is a unique inode allocated for each active file,
+ * each current directory, each mounted-on file, text file, and the root.
+ * An inode is 'named' by its dev/inumber pair. (iget/iget.c)
+ * Data in icommon is read in from permanent inode on volume.
+ */
+
+#define NDADDR 12 /* direct addresses in inode */
+#define NIADDR 3 /* indirect addresses in inode */
+
+struct inode {
+ struct inode *i_chain[2]; /* must be first */
+ u_short i_flag;
+ u_short i_count; /* reference count */
+ dev_t i_dev; /* device where inode resides */
+ u_short i_shlockc; /* count of shared locks on inode */
+ u_short i_exlockc; /* count of exclusive locks on inode */
+ ino_t i_number; /* i number, 1-to-1 with device address */
+ long i_id; /* unique identifier */
+ struct fs *i_fs; /* file sys associated with this inode */
+ struct dquot *i_dquot; /* quota structure controlling this file */
+ struct text *i_text; /* text entry, if any (should be region) */
+ union {
+ daddr_t if_lastr; /* last read (read-ahead) */
+ struct socket *is_socket;
+ struct {
+ struct inode *if_freef; /* free list forward */
+ struct inode **if_freeb; /* free list back */
+ } i_fr;
+ } i_un;
+ struct icommon
+ {
+ u_short ic_mode; /* 0: mode and type of file */
+ short ic_nlink; /* 2: number of links to file */
+ uid_t ic_uid; /* 4: owner's user id */
+ gid_t ic_gid; /* 6: owner's group id */
+ quad ic_size; /* 8: number of bytes in file */
+ time_t ic_atime; /* 16: time last accessed */
+ long ic_atspare;
+ time_t ic_mtime; /* 24: time last modified */
+ long ic_mtspare;
+ time_t ic_ctime; /* 32: last time inode changed */
+ long ic_ctspare;
+ daddr_t ic_db[NDADDR]; /* 40: disk block addresses */
+ daddr_t ic_ib[NIADDR]; /* 88: indirect blocks */
+ long ic_flags; /* 100: status, currently unused */
+ long ic_blocks; /* 104: blocks actually held */
+ long ic_spare[5]; /* 108: reserved, currently unused */
+ } i_ic;
+};
+
+struct dinode {
+ union {
+ struct icommon di_icom;
+ char di_size[128];
+ } di_un;
+};
+
+#define i_mode i_ic.ic_mode
+#define i_nlink i_ic.ic_nlink
+#define i_uid i_ic.ic_uid
+#define i_gid i_ic.ic_gid
+/* ugh! -- must be fixed */
+#ifdef vax
+#define i_size i_ic.ic_size.val[0]
+#endif
+#define i_db i_ic.ic_db
+#define i_ib i_ic.ic_ib
+#define i_atime i_ic.ic_atime
+#define i_mtime i_ic.ic_mtime
+#define i_ctime i_ic.ic_ctime
+#define i_blocks i_ic.ic_blocks
+#define i_rdev i_ic.ic_db[0]
+#define i_lastr i_un.if_lastr
+#define i_socket i_un.is_socket
+#define i_forw i_chain[0]
+#define i_back i_chain[1]
+#define i_freef i_un.i_fr.if_freef
+#define i_freeb i_un.i_fr.if_freeb
+
+#define di_ic di_un.di_icom
+#define di_mode di_ic.ic_mode
+#define di_nlink di_ic.ic_nlink
+#define di_uid di_ic.ic_uid
+#define di_gid di_ic.ic_gid
+#ifdef vax
+#define di_size di_ic.ic_size.val[0]
+#endif
+#define di_db di_ic.ic_db
+#define di_ib di_ic.ic_ib
+#define di_atime di_ic.ic_atime
+#define di_mtime di_ic.ic_mtime
+#define di_ctime di_ic.ic_ctime
+#define di_rdev di_ic.ic_db[0]
+#define di_blocks di_ic.ic_blocks
+
+#ifdef KERNEL
+/*
+ * Invalidate an inode. Used by the namei cache to detect stale
+ * information. At an absurd rate of 100 calls/second, the inode
+ * table invalidation should only occur once every 16 months.
+ */
+#define cacheinval(ip) \
+ (ip)->i_id = ++nextinodeid; \
+ if (nextinodeid == 0) \
+/* cacheinvalall();*/
+
+struct inode *inode; /* the inode table itself */
+struct inode *inodeNINODE; /* the end of the inode table */
+int ninode; /* number of slots in the table */
+long nextinodeid; /* unique id generator */
+
+struct inode *rootdir; /* pointer to inode of root directory */
+
+/*struct inode *ialloc();*/
+/*struct inode *iget();*/
+#ifdef notdef
+/*struct inode *ifind();*/
+#endif
+/*struct inode *owner();*/
+/*struct inode *maknode();*/
+/*struct inode *namei();*/
+
+/*ino_t dirpref();*/
+#endif
+
+/* flags */
+#define ILOCKED 0x1 /* inode is locked */
+#define IUPD 0x2 /* file has been modified */
+#define IACC 0x4 /* inode access time to be updated */
+#define IMOUNT 0x8 /* inode is mounted on */
+#define IWANT 0x10 /* some process waiting on lock */
+#define ITEXT 0x20 /* inode is pure text prototype */
+#define ICHG 0x40 /* inode has been changed */
+#define ISHLOCK 0x80 /* file has shared lock */
+#define IEXLOCK 0x100 /* file has exclusive lock */
+#define ILWAIT 0x200 /* someone waiting on file lock */
+#define IMOD 0x400 /* inode has been modified */
+#define IRENAME 0x800 /* inode is being renamed */
+
+/* modes */
+#define IFMT 0170000 /* type of file */
+#define IFCHR 0020000 /* character special */
+#define IFDIR 0040000 /* directory */
+#define IFBLK 0060000 /* block special */
+#define IFREG 0100000 /* regular */
+#define IFLNK 0120000 /* symbolic link */
+#define IFSOCK 0140000 /* socket */
+
+#define ISUID 04000 /* set user id on execution */
+#define ISGID 02000 /* set group id on execution */
+#define ISVTX 01000 /* save swapped text even after use */
+#define IREAD 0400 /* read, write, execute permissions */
+#define IWRITE 0200
+#define IEXEC 0100
+
+#define ILOCK(ip) { \
+ while ((ip)->i_flag & ILOCKED) { \
+ (ip)->i_flag |= IWANT; \
+ sleep((caddr_t)(ip), PINOD); \
+ } \
+ (ip)->i_flag |= ILOCKED; \
+}
+
+#define IUNLOCK(ip) { \
+ (ip)->i_flag &= ~ILOCKED; \
+ if ((ip)->i_flag&IWANT) { \
+ (ip)->i_flag &= ~IWANT; \
+ wakeup((caddr_t)(ip)); \
+ } \
+}
+
+#define IUPDAT(ip, t1, t2, waitfor) { \
+ if (ip->i_flag&(IUPD|IACC|ICHG|IMOD)) \
+ iupdat(ip, t1, t2, waitfor); \
+}
+
+#define ITIMES(ip, t1, t2) { \
+ if ((ip)->i_flag&(IUPD|IACC|ICHG)) { \
+ (ip)->i_flag |= IMOD; \
+ if ((ip)->i_flag&IACC) \
+ (ip)->i_atime = (t1)->tv_sec; \
+ if ((ip)->i_flag&IUPD) \
+ (ip)->i_mtime = (t2)->tv_sec; \
+ if ((ip)->i_flag&ICHG) \
+ (ip)->i_ctime = time.tv_sec; \
+ (ip)->i_flag &= ~(IACC|IUPD|ICHG); \
+ } \
+}
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ioctl.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Ioctl definitions
+ */
+/*#ifndef _IOCTL_*/
+/*#define _IOCTL_*/
+#ifdef KERNEL
+/*#include "ttychars.h"*/
+/*#include "ttydev.h"*/
+#else
+/*#include <sys/ttychars.h>*/
+/*#include <sys/ttydev.h>*/
+#endif
+
+struct tchars {
+ char t_intrc; /* interrupt */
+ char t_quitc; /* quit */
+ char t_startc; /* start output */
+ char t_stopc; /* stop output */
+ char t_eofc; /* end-of-file */
+ char t_brkc; /* input delimiter (like nl) */
+};
+struct ltchars {
+ char t_suspc; /* stop process signal */
+ char t_dsuspc; /* delayed stop process signal */
+ char t_rprntc; /* reprint line */
+ char t_flushc; /* flush output (toggles) */
+ char t_werasc; /* word erase */
+ char t_lnextc; /* literal next character */
+};
+
+/*
+ * Structure for TIOCGETP and TIOCSETP ioctls.
+ */
+
+#ifndef _SGTTYB_
+#define _SGTTYB_
+struct sgttyb {
+ char sg_ispeed; /* input speed */
+ char sg_ospeed; /* output speed */
+ char sg_erase; /* erase character */
+ char sg_kill; /* kill character */
+ short sg_flags; /* mode flags */
+};
+#endif
+
+/*
+ * Window/terminal size structure.
+ * This information is stored by the kernel
+ * in order to provide a consistent interface,
+ * but is not used by the kernel.
+ *
+ * Type must be "unsigned short" so that types.h not required.
+ */
+struct winsize {
+ unsigned short ws_row; /* rows, in characters */
+ unsigned short ws_col; /* columns, in characters */
+ unsigned short ws_xpixel; /* horizontal size, pixels */
+ unsigned short ws_ypixel; /* vertical size, pixels */
+};
+
+/*
+ * Pun for SUN.
+ */
+struct ttysize {
+ unsigned short ts_lines;
+ unsigned short ts_cols;
+ unsigned short ts_xxx;
+ unsigned short ts_yyy;
+};
+#define TIOCGSIZE TIOCGWINSZ
+#define TIOCSSIZE TIOCSWINSZ
+
+#ifndef _IO
+/*
+ * Ioctl's have the command encoded in the lower word,
+ * and the size of any in or out parameters in the upper
+ * word. The high 2 bits of the upper word are used
+ * to encode the in/out status of the parameter; for now
+ * we restrict parameters to at most 128 bytes.
+ */
+#define IOCPARM_MASK 0x7f /* parameters must be < 128 bytes */
+#define IOC_VOID 0x20000000 /* no parameters */
+#define IOC_OUT 0x40000000 /* copy out parameters */
+#define IOC_IN 0x80000000 /* copy in parameters */
+#define IOC_INOUT (IOC_IN|IOC_OUT)
+/* the 0x20000000 is so we can distinguish new ioctl's from old */
+#define _IO(x,y) (IOC_VOID|('x'<<8)|y)
+#define _IOR(x,y,t) (IOC_OUT|((sizeof(t)&IOCPARM_MASK)<<16)|('x'<<8)|y)
+#define _IOW(x,y,t) (IOC_IN|((sizeof(t)&IOCPARM_MASK)<<16)|('x'<<8)|y)
+/* this should be _IORW, but stdio got there first */
+#define _IOWR(x,y,t) (IOC_INOUT|((sizeof(t)&IOCPARM_MASK)<<16)|('x'<<8)|y)
+#endif
+
+/*
+ * tty ioctl commands
+ */
+#define TIOCGETD _IOR(t, 0, int) /* get line discipline */
+#define TIOCSETD _IOW(t, 1, int) /* set line discipline */
+#define TIOCHPCL _IO(t, 2) /* hang up on last close */
+#define TIOCMODG _IOR(t, 3, int) /* get modem control state */
+#define TIOCMODS _IOW(t, 4, int) /* set modem control state */
+#define TIOCM_LE 0001 /* line enable */
+#define TIOCM_DTR 0002 /* data terminal ready */
+#define TIOCM_RTS 0004 /* request to send */
+#define TIOCM_ST 0010 /* secondary transmit */
+#define TIOCM_SR 0020 /* secondary receive */
+#define TIOCM_CTS 0040 /* clear to send */
+#define TIOCM_CAR 0100 /* carrier detect */
+#define TIOCM_CD TIOCM_CAR
+#define TIOCM_RNG 0200 /* ring */
+#define TIOCM_RI TIOCM_RNG
+#define TIOCM_DSR 0400 /* data set ready */
+#define TIOCGETP _IOR(t, 8,struct sgttyb)/* get parameters -- gtty */
+#define TIOCSETP _IOW(t, 9,struct sgttyb)/* set parameters -- stty */
+#define TIOCSETN _IOW(t,10,struct sgttyb)/* as above, but no flushtty */
+#define TIOCEXCL _IO(t, 13) /* set exclusive use of tty */
+#define TIOCNXCL _IO(t, 14) /* reset exclusive use of tty */
+#define TIOCFLUSH _IOW(t, 16, int) /* flush buffers */
+#define TIOCSETC _IOW(t,17,struct tchars)/* set special characters */
+#define TIOCGETC _IOR(t,18,struct tchars)/* get special characters */
+#define TANDEM 0x00000001 /* send stopc on out q full */
+#define CBREAK 0x00000002 /* half-cooked mode */
+#define LCASE 0x00000004 /* simulate lower case */
+#define ECHO 0x00000008 /* echo input */
+#define CRMOD 0x00000010 /* map \r to \r\n on output */
+#define RAW 0x00000020 /* no i/o processing */
+#define ODDP 0x00000040 /* get/send odd parity */
+#define EVENP 0x00000080 /* get/send even parity */
+#define ANYP 0x000000c0 /* get any parity/send none */
+#define NLDELAY 0x00000300 /* \n delay */
+#define NL0 0x00000000
+#define NL1 0x00000100 /* tty 37 */
+#define NL2 0x00000200 /* vt05 */
+#define NL3 0x00000300
+#define TBDELAY 0x00000c00 /* horizontal tab delay */
+#define TAB0 0x00000000
+#define TAB1 0x00000400 /* tty 37 */
+#define TAB2 0x00000800
+#define XTABS 0x00000c00 /* expand tabs on output */
+#define CRDELAY 0x00003000 /* \r delay */
+#define CR0 0x00000000
+#define CR1 0x00001000 /* tn 300 */
+#define CR2 0x00002000 /* tty 37 */
+#define CR3 0x00003000 /* concept 100 */
+#define VTDELAY 0x00004000 /* vertical tab delay */
+#define FF0 0x00000000
+#define FF1 0x00004000 /* tty 37 */
+#define BSDELAY 0x00008000 /* \b delay */
+#define BS0 0x00000000
+#define BS1 0x00008000
+#define ALLDELAY (NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)
+#define CRTBS 0x00010000 /* do backspacing for crt */
+#define PRTERA 0x00020000 /* \ ... / erase */
+#define CRTERA 0x00040000 /* " \b " to wipe out char */
+#define TILDE 0x00080000 /* hazeltine tilde kludge */
+#define MDMBUF 0x00100000 /* start/stop output on carrier intr */
+#define LITOUT 0x00200000 /* literal output */
+#define TOSTOP 0x00400000 /* SIGSTOP on background output */
+#define FLUSHO 0x00800000 /* flush output to terminal */
+#define NOHANG 0x01000000 /* no SIGHUP on carrier drop */
+#define L001000 0x02000000
+#define CRTKIL 0x04000000 /* kill line with " \b " */
+#define PASS8 0x08000000
+#define CTLECH 0x10000000 /* echo control chars as ^X */
+#define PENDIN 0x20000000 /* tp->t_rawq needs reread */
+#define DECCTQ 0x40000000 /* only ^Q starts after ^S */
+#define NOFLSH 0x80000000 /* no output flush on signal */
+/* locals, from 127 down */
+#define TIOCLBIS _IOW(t, 127, int) /* bis local mode bits */
+#define TIOCLBIC _IOW(t, 126, int) /* bic local mode bits */
+#define TIOCLSET _IOW(t, 125, int) /* set entire local mode word */
+#define TIOCLGET _IOR(t, 124, int) /* get local modes */
+#define LCRTBS (CRTBS>>16)
+#define LPRTERA (PRTERA>>16)
+#define LCRTERA (CRTERA>>16)
+#define LTILDE (TILDE>>16)
+#define LMDMBUF (MDMBUF>>16)
+#define LLITOUT (LITOUT>>16)
+#define LTOSTOP (TOSTOP>>16)
+#define LFLUSHO (FLUSHO>>16)
+#define LNOHANG (NOHANG>>16)
+#define LCRTKIL (CRTKIL>>16)
+#define LPASS8 (PASS8>>16)
+#define LCTLECH (CTLECH>>16)
+#define LPENDIN (PENDIN>>16)
+#define LDECCTQ (DECCTQ>>16)
+#define LNOFLSH (NOFLSH>>16)
+#define TIOCSBRK _IO(t, 123) /* set break bit */
+#define TIOCCBRK _IO(t, 122) /* clear break bit */
+#define TIOCSDTR _IO(t, 121) /* set data terminal ready */
+#define TIOCCDTR _IO(t, 120) /* clear data terminal ready */
+#define TIOCGPGRP _IOR(t, 119, int) /* get pgrp of tty */
+#define TIOCSPGRP _IOW(t, 118, int) /* set pgrp of tty */
+#define TIOCSLTC _IOW(t,117,struct ltchars)/* set local special chars */
+#define TIOCGLTC _IOR(t,116,struct ltchars)/* get local special chars */
+#define TIOCOUTQ _IOR(t, 115, int) /* output queue size */
+#define TIOCSTI _IOW(t, 114, char) /* simulate terminal input */
+#define TIOCNOTTY _IO(t, 113) /* void tty association */
+#define TIOCPKT _IOW(t, 112, int) /* pty: set/clear packet mode */
+#define TIOCPKT_DATA 0x00 /* data packet */
+#define TIOCPKT_FLUSHREAD 0x01 /* flush packet */
+#define TIOCPKT_FLUSHWRITE 0x02 /* flush packet */
+#define TIOCPKT_STOP 0x04 /* stop output */
+#define TIOCPKT_START 0x08 /* start output */
+#define TIOCPKT_NOSTOP 0x10 /* no more ^S, ^Q */
+#define TIOCPKT_DOSTOP 0x20 /* now do ^S ^Q */
+#define TIOCSTOP _IO(t, 111) /* stop output, like ^S */
+#define TIOCSTART _IO(t, 110) /* start output, like ^Q */
+#define TIOCMSET _IOW(t, 109, int) /* set all modem bits */
+#define TIOCMBIS _IOW(t, 108, int) /* bis modem bits */
+#define TIOCMBIC _IOW(t, 107, int) /* bic modem bits */
+#define TIOCMGET _IOR(t, 106, int) /* get all modem bits */
+#define TIOCREMOTE _IOW(t, 105, int) /* remote input editing */
+#define TIOCGWINSZ _IOR(t, 104, struct winsize) /* get window size */
+#define TIOCSWINSZ _IOW(t, 103, struct winsize) /* set window size */
+#define TIOCUCNTL _IOW(t, 102, int) /* pty: set/clr usr cntl mode */
+#define UIOCCMD(n) _IO(u, n) /* usr cntl op "n" */
+
+#define OTTYDISC 0 /* old, v7 std tty driver */
+#define NETLDISC 1 /* line discip for berk net */
+#define NTTYDISC 2 /* new tty discipline */
+#define TABLDISC 3 /* tablet discipline */
+#define SLIPDISC 4 /* serial IP discipline */
+
+#define FIOCLEX _IO(f, 1) /* set exclusive use on fd */
+#define FIONCLEX _IO(f, 2) /* remove exclusive use */
+/* another local */
+#define FIONREAD _IOR(f, 127, int) /* get # bytes to read */
+#define FIONBIO _IOW(f, 126, int) /* set/clear non-blocking i/o */
+#define FIOASYNC _IOW(f, 125, int) /* set/clear async i/o */
+#define FIOSETOWN _IOW(f, 124, int) /* set owner */
+#define FIOGETOWN _IOR(f, 123, int) /* get owner */
+
+/* socket i/o controls */
+#define SIOCSHIWAT _IOW(s, 0, int) /* set high watermark */
+#define SIOCGHIWAT _IOR(s, 1, int) /* get high watermark */
+#define SIOCSLOWAT _IOW(s, 2, int) /* set low watermark */
+#define SIOCGLOWAT _IOR(s, 3, int) /* get low watermark */
+#define SIOCATMARK _IOR(s, 7, int) /* at oob mark? */
+#define SIOCSPGRP _IOW(s, 8, int) /* set process group */
+#define SIOCGPGRP _IOR(s, 9, int) /* get process group */
+
+#define SIOCADDRT _IOW(r, 10, struct rtentry) /* add route */
+#define SIOCDELRT _IOW(r, 11, struct rtentry) /* delete route */
+
+#define SIOCSIFADDR _IOW(i, 12, struct ifreq) /* set ifnet address */
+#define SIOCGIFADDR _IOWR(i,13, struct ifreq) /* get ifnet address */
+#define SIOCSIFDSTADDR _IOW(i, 14, struct ifreq) /* set p-p address */
+#define SIOCGIFDSTADDR _IOWR(i,15, struct ifreq) /* get p-p address */
+#define SIOCSIFFLAGS _IOW(i, 16, struct ifreq) /* set ifnet flags */
+#define SIOCGIFFLAGS _IOWR(i,17, struct ifreq) /* get ifnet flags */
+#define SIOCGIFBRDADDR _IOWR(i,18, struct ifreq) /* get broadcast addr */
+#define SIOCSIFBRDADDR _IOW(i,19, struct ifreq) /* set broadcast addr */
+#define SIOCGIFCONF _IOWR(i,20, struct ifconf) /* get ifnet list */
+#define SIOCGIFNETMASK _IOWR(i,21, struct ifreq) /* get net addr mask */
+#define SIOCSIFNETMASK _IOW(i,22, struct ifreq) /* set net addr mask */
+#define SIOCGIFMETRIC _IOWR(i,23, struct ifreq) /* get IF metric */
+#define SIOCSIFMETRIC _IOW(i,24, struct ifreq) /* set IF metric */
+
+#define SIOCSARP _IOW(i, 30, struct arpreq) /* set arp entry */
+#define SIOCGARP _IOWR(i,31, struct arpreq) /* get arp entry */
+#define SIOCDARP _IOW(i, 32, struct arpreq) /* delete arp entry */
+
+/*#endif*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)kernel.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Global variables for the kernel
+ */
+
+/*long rmalloc();*/
+
+/* 1.1 */
+long hostid;
+char hostname[MAXHOSTNAMELEN];
+int hostnamelen;
+
+/* 1.2 */
+struct timeval boottime;
+struct timeval time;
+struct timezone tz; /* XXX */
+int hz;
+int phz; /* alternate clock's frequency */
+int tick;
+int lbolt; /* awoken once a second */
+/*int realitexpire();*/
+
+double avenrun[3];
+
+#ifdef GPROF
+extern int profiling;
+extern char *s_lowpc;
+extern u_long s_textsize;
+extern u_short *kcount;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)map.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Resource Allocation Maps.
+ *
+ * Associated routines manage sub-allocation of an address space using
+ * an array of segment descriptors. The first element of this array
+ * is a map structure, describing the arrays extent and the name
+ * of the controlled object. Each additional structure represents
+ * a free segment of the address space.
+ *
+ * A call to rminit initializes a resource map and may also be used
+ * to free some address space for the map. Subsequent calls to rmalloc
+ * and rmfree allocate and free space in the resource map. If the resource
+ * map becomes too fragmented to be described in the available space,
+ * then some of the resource is discarded. This may lead to critical
+ * shortages, but is better than not checking (as the previous versions
+ * of these routines did) or giving up and calling panic(). The routines
+ * could use linked lists and call a memory allocator when they run
+ * out of space, but that would not solve the out of space problem when
+ * called at interrupt time.
+ *
+ * N.B.: The address 0 in the resource address space is not available
+ * as it is used internally by the resource map routines.
+ */
+struct map {
+ struct mapent *m_limit; /* address of last slot in map */
+ char *m_name; /* name of resource */
+/* we use m_name when the map overflows, in warning messages */
+};
+struct mapent
+{
+ int m_size; /* size of this segment of the map */
+ int m_addr; /* resource-space addr of start of segment */
+};
+
+#ifdef KERNEL
+struct map *swapmap;
+int nswapmap;
+struct map *argmap;
+#define ARGMAPSIZE 16
+struct map *kernelmap;
+struct map *mbmap;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)mbuf.h 7.3 (Berkeley) 9/11/86
+ */
+
+/*
+ * Constants related to memory allocator.
+ */
+#define MSIZE 128 /* size of an mbuf */
+
+#define MMINOFF 12 /* mbuf header length */
+#define MTAIL 4
+#define MMAXOFF (MSIZE-MTAIL) /* offset where data ends */
+#define MLEN (MSIZE-MMINOFF-MTAIL) /* mbuf data length */
+#define NMBCLUSTERS 256
+#define NMBPCL (CLBYTES/MSIZE) /* # mbufs per cluster */
+
+/*
+ * Macros for type conversion
+ */
+
+/* network cluster number to virtual address, and back */
+#define cltom(x) ((struct mbuf *)((int)mbutl + ((x) << CLSHIFT)))
+#define mtocl(x) (((int)x - (int)mbutl) >> CLSHIFT)
+
+/* address in mbuf to mbuf head */
+#define dtom(x) ((struct mbuf *)((int)x & ~(MSIZE-1)))
+
+/* mbuf head, to typed data */
+#define mtod(x,t) ((t)((int)(x) + (x)->m_off))
+
+struct mbuf {
+ struct mbuf *m_next; /* next buffer in chain */
+ u_long m_off; /* offset of data */
+ short m_len; /* amount of data in this mbuf */
+ short m_type; /* mbuf type (0 == free) */
+ u_char m_dat[MLEN]; /* data storage */
+ struct mbuf *m_act; /* link in higher-level mbuf list */
+};
+
+/* mbuf types */
+#define MT_FREE 0 /* should be on free list */
+#define MT_DATA 1 /* dynamic (data) allocation */
+#define MT_HEADER 2 /* packet header */
+#define MT_SOCKET 3 /* socket structure */
+#define MT_PCB 4 /* protocol control block */
+#define MT_RTABLE 5 /* routing tables */
+#define MT_HTABLE 6 /* IMP host tables */
+#define MT_ATABLE 7 /* address resolution tables */
+#define MT_SONAME 8 /* socket name */
+#define MT_ZOMBIE 9 /* zombie proc status */
+#define MT_SOOPTS 10 /* socket options */
+#define MT_FTABLE 11 /* fragment reassembly header */
+#define MT_RIGHTS 12 /* access rights */
+#define MT_IFADDR 13 /* interface address */
+
+/* flags to m_get */
+#define M_DONTWAIT 0
+#define M_WAIT 1
+
+/* flags to m_pgalloc */
+#define MPG_MBUFS 0 /* put new mbufs on free list */
+#define MPG_CLUSTERS 1 /* put new clusters on free list */
+#define MPG_SPACE 2 /* don't free; caller wants space */
+
+/* length to m_copy to copy all */
+#define M_COPYALL 1000000000
+
+/*
+ * m_pullup will pull up additional length if convenient;
+ * should be enough to hold headers of second-level and higher protocols.
+ */
+#define MPULL_EXTRA 32
+
+#define MGET(m, i, t) \
+/* { int ms = splimp();*/ \
+ if ((m)=mfree) \
+ { if ((m)->m_type != MT_FREE) panic("mget"); (m)->m_type = t; \
+ mbstat.m_mtypes[MT_FREE]--; mbstat.m_mtypes[t]++; \
+ mfree = (m)->m_next; (m)->m_next = 0; \
+ (m)->m_off = MMINOFF; } \
+ else \
+ (m) = m_more(i, t); \
+ splx(ms); }
+/*
+ * Mbuf page cluster macros.
+ * MCLALLOC allocates mbuf page clusters.
+ * Note that it works only with a count of 1 at the moment.
+ * MCLGET adds such clusters to a normal mbuf.
+ * m->m_len is set to CLBYTES upon success.
+ * MCLFREE frees clusters allocated by MCLALLOC.
+ */
+#define MCLALLOC(m, i) \
+/* { int ms = splimp();*/ \
+ if (mclfree == 0) \
+ (void)m_clalloc((i), MPG_CLUSTERS, M_DONTWAIT); \
+ if ((m)=mclfree) \
+ {++mclrefcnt[mtocl(m)];mbstat.m_clfree--;mclfree = (m)->m_next;} \
+ splx(ms); }
+#define M_HASCL(m) ((m)->m_off >= MSIZE)
+#define MTOCL(m) ((struct mbuf *)(mtod((m), int)&~CLOFSET))
+
+#define MCLGET(m) \
+ { struct mbuf *p; \
+ MCLALLOC(p, 1); \
+ if (p) { \
+ (m)->m_off = (int)p - (int)(m); \
+ (m)->m_len = CLBYTES; \
+ } \
+ }
+#define MCLFREE(m) { \
+ if (--mclrefcnt[mtocl(m)] == 0) \
+ { (m)->m_next = mclfree;mclfree = (m);mbstat.m_clfree++;} \
+ }
+#define MFREE(m, n) \
+/* { int ms = splimp();*/ \
+ if ((m)->m_type == MT_FREE) panic("mfree"); \
+ mbstat.m_mtypes[(m)->m_type]--; mbstat.m_mtypes[MT_FREE]++; \
+ (m)->m_type = MT_FREE; \
+ if (M_HASCL(m)) { \
+ (n) = MTOCL(m); \
+ MCLFREE(n); \
+ } \
+ (n) = (m)->m_next; (m)->m_next = mfree; \
+ (m)->m_off = 0; (m)->m_act = 0; mfree = (m); \
+ splx(ms); \
+ if (m_want) { \
+ m_want = 0; \
+ wakeup((caddr_t)&mfree); \
+ } \
+ }
+
+/*
+ * Mbuf statistics.
+ */
+struct mbstat {
+ short m_mbufs; /* mbufs obtained from page pool */
+ short m_clusters; /* clusters obtained from page pool */
+ short m_clfree; /* free clusters */
+ short m_drops; /* times failed to find space */
+ short m_mtypes[256]; /* type specific mbuf allocations */
+};
+
+#ifdef KERNEL
+extern struct mbuf mbutl[]; /* virtual address of net free mem */
+extern struct pte Mbmap[]; /* page tables to map Netutl */
+struct mbstat mbstat;
+int nmbclusters;
+struct mbuf *mfree, *mclfree;
+char mclrefcnt[NMBCLUSTERS + 1];
+int m_want;
+/*struct mbuf *m_get(),*m_getclr(),*m_free(),*m_more(),*m_copy(),*m_pullup();*/
+/*caddr_t m_clalloc();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)mman.h 7.1 (Berkeley) 6/4/86
+ */
+
+/* protections are chosen from these bits, or-ed together */
+#define PROT_READ 0x1 /* pages can be read */
+#define PROT_WRITE 0x2 /* pages can be written */
+#define PROT_EXEC 0x4 /* pages can be executed */
+
+/* sharing types: choose either SHARED or PRIVATE */
+#define MAP_SHARED 1 /* share changes */
+#define MAP_PRIVATE 2 /* changes are private */
+
+/* advice to madvise */
+#define MADV_NORMAL 0 /* no further special treatment */
+#define MADV_RANDOM 1 /* expect random page references */
+#define MADV_SEQUENTIAL 2 /* expect sequential page references */
+#define MADV_WILLNEED 3 /* will need these pages */
+#define MADV_DONTNEED 4 /* dont need these pages */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)mount.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Mount structure.
+ * One allocated on every mount.
+ * Used to find the super block.
+ */
+struct mount
+{
+ dev_t m_dev; /* device mounted */
+ struct buf *m_bufp; /* pointer to superblock */
+ struct inode *m_inodp; /* pointer to mounted on inode */
+ struct inode *m_qinod; /* QUOTA: pointer to quota file */
+};
+#ifdef KERNEL
+struct mount mount[NMOUNT];
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)msgbuf.h 7.1 (Berkeley) 6/4/86
+ */
+
+#define MSG_MAGIC 0x063061
+#define MSG_BSIZE (4096 - 3 * sizeof (long))
+struct msgbuf {
+ long msg_magic;
+ long msg_bufx;
+ long msg_bufr;
+ char msg_bufc[MSG_BSIZE];
+};
+#ifdef KERNEL
+struct msgbuf msgbuf;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)mtio.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Structures and definitions for mag tape io control commands
+ */
+
+/* structure for MTIOCTOP - mag tape op command */
+struct mtop {
+ short mt_op; /* operations defined below */
+ daddr_t mt_count; /* how many of them */
+};
+
+/* operations */
+#define MTWEOF 0 /* write an end-of-file record */
+#define MTFSF 1 /* forward space file */
+#define MTBSF 2 /* backward space file */
+#define MTFSR 3 /* forward space record */
+#define MTBSR 4 /* backward space record */
+#define MTREW 5 /* rewind */
+#define MTOFFL 6 /* rewind and put the drive offline */
+#define MTNOP 7 /* no operation, sets status only */
+#define MTCACHE 8 /* enable controller cache */
+#define MTNOCACHE 9 /* disable controller cache */
+
+/* structure for MTIOCGET - mag tape get status command */
+
+struct mtget {
+ short mt_type; /* type of magtape device */
+/* the following two registers are grossly device dependent */
+ short mt_dsreg; /* ``drive status'' register */
+ short mt_erreg; /* ``error'' register */
+/* end device-dependent registers */
+ short mt_resid; /* residual count */
+/* the following two are not yet implemented */
+ daddr_t mt_fileno; /* file number of current position */
+ daddr_t mt_blkno; /* block number of current position */
+/* end not yet implemented */
+};
+
+/*
+ * Constants for mt_type byte. These are the same
+ * for controllers compatible with the types listed.
+ */
+#define MT_ISTS 0x01 /* TS-11 */
+#define MT_ISHT 0x02 /* TM03 Massbus: TE16, TU45, TU77 */
+#define MT_ISTM 0x03 /* TM11/TE10 Unibus */
+#define MT_ISMT 0x04 /* TM78/TU78 Massbus */
+#define MT_ISUT 0x05 /* SI TU-45 emulation on Unibus */
+#define MT_ISCPC 0x06 /* SUN */
+#define MT_ISAR 0x07 /* SUN */
+#define MT_ISTMSCP 0x08 /* DEC TMSCP protocol (TU81, TK50) */
+
+/* mag tape io control commands */
+#define MTIOCTOP _IOW(m, 1, struct mtop) /* do a mag tape op */
+#define MTIOCGET _IOR(m, 2, struct mtget) /* get tape status */
+#define MTIOCIEOT _IO(m, 3) /* ignore EOT error */
+#define MTIOCEEOT _IO(m, 4) /* enable EOT error */
+
+#ifndef KERNEL
+#define DEFTAPE "/dev/rmt12"
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)namei.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*#ifndef _NAMEI_*/
+/*#define _NAMEI_*/
+
+#ifdef KERNEL
+/*#include "uio.h"*/
+#else
+/*#include <sys/uio.h>*/
+#endif
+
+/*
+ * Encapsulation of namei parameters.
+ * One of these is located in the u. area to
+ * minimize space allocated on the kernel stack.
+ */
+struct nameidata {
+ caddr_t ni_dirp; /* pathname pointer */
+ short ni_nameiop; /* see below */
+ short ni_error; /* error return if any */
+ off_t ni_endoff; /* end of useful stuff in directory */
+ struct inode *ni_pdir; /* inode of parent directory of dirp */
+ struct iovec ni_iovec; /* MUST be pointed to by ni_iov */
+ struct uio ni_uio; /* directory I/O parameters */
+ struct direct ni_dent; /* current directory entry */
+};
+
+#define ni_base ni_iovec.iov_base
+#define ni_count ni_iovec.iov_len
+#define ni_iov ni_uio.uio_iov
+#define ni_iovcnt ni_uio.uio_iovcnt
+#define ni_offset ni_uio.uio_offset
+#define ni_segflg ni_uio.uio_segflg
+#define ni_resid ni_uio.uio_resid
+
+/*
+ * namei operations and modifiers
+ */
+#define LOOKUP 0 /* perform name lookup only */
+#define CREATE 1 /* setup for file creation */
+#define DELETE 2 /* setup for file deletion */
+#define LOCKPARENT 0x10 /* see the top of namei */
+#define NOCACHE 0x20 /* name must not be left in cache */
+#define FOLLOW 0x40 /* follow symbolic links */
+#define NOFOLLOW 0x0 /* don't follow symbolic links (pseudo) */
+
+/*
+ * This structure describes the elements in the cache of recent
+ * names looked up by namei.
+ */
+struct namecache {
+ struct namecache *nc_forw; /* hash chain, MUST BE FIRST */
+ struct namecache *nc_back; /* hash chain, MUST BE FIRST */
+ struct namecache *nc_nxt; /* LRU chain */
+ struct namecache **nc_prev; /* LRU chain */
+ struct inode *nc_ip; /* inode the name refers to */
+ ino_t nc_ino; /* ino of parent of name */
+ dev_t nc_dev; /* dev of parent of name */
+ dev_t nc_idev; /* dev of the name ref'd */
+ long nc_id; /* referenced inode's id */
+ char nc_nlen; /* length of name */
+#define NCHNAMLEN 15 /* maximum name segment length we bother with */
+ char nc_name[NCHNAMLEN]; /* segment name */
+};
+#ifdef KERNEL
+struct namecache *namecache;
+int nchsize;
+#endif
+
+/*
+ * Stats on usefulness of namei caches.
+ */
+struct nchstats {
+ long ncs_goodhits; /* hits that we can reall use */
+ long ncs_badhits; /* hits we must drop */
+ long ncs_falsehits; /* hits with id mismatch */
+ long ncs_miss; /* misses */
+ long ncs_long; /* long names that ignore cache */
+ long ncs_pass2; /* names found with passes == 2 */
+ long ncs_2passes; /* number of times we attempt it */
+};
+/*#endif*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)param.h 7.1 (Berkeley) 6/4/86
+ */
+
+#define BSD 43 /* 4.3 * 10, as cpp doesn't do floats */
+#define BSD4_3 1
+
+/*
+ * Machine type dependent parameters.
+ */
+#ifdef KERNEL
+/*#include "../machine/machparam.h"*/
+#else
+/*#include <machine/machparam.h>*/
+#endif
+
+#define NPTEPG (NBPG/(sizeof (struct pte)))
+
+/*
+ * Machine-independent constants
+ */
+#define NMOUNT 20 /* number of mountable file systems */
+/* NMOUNT must be <= 255 unless c_mdev (cmap.h) is expanded */
+#define MSWAPX NMOUNT /* pseudo mount table index for swapdev */
+#define MAXUPRC 40 /* max processes per user */
+#define NOFILE 64 /* max open files per process */
+#define CANBSIZ 256 /* max size of typewriter line */
+#define NCARGS 20480 /* # characters in exec arglist */
+#define NGROUPS 16 /* max number groups */
+
+#define NOGROUP 65535 /* marker for empty group set member */
+
+/*
+ * Priorities
+ */
+#define PSWP 0
+#define PINOD 10
+#define PRIBIO 20
+#define PRIUBA 24
+#define PZERO 25
+#define PPIPE 26
+#define PWAIT 30
+#define PLOCK 35
+#define PSLEP 40
+#define PUSER 50
+
+#define NZERO 0
+
+/*
+ * Signals
+ */
+#ifdef KERNEL
+/*#include "signal.h"*/
+#else
+/*#include <signal.h>*/
+#endif
+
+#define ISSIG(p) \
+ ((p)->p_sig && ((p)->p_flag&STRC || \
+ ((p)->p_sig &~ ((p)->p_sigignore | (p)->p_sigmask))) && issig())
+
+#define NBPW sizeof(int) /* number of bytes in an integer */
+
+#define NULL 0
+#define CMASK 022 /* default mask for file creation */
+#define NODEV (dev_t)(-1)
+
+/*
+ * Clustering of hardware pages on machines with ridiculously small
+ * page sizes is done here. The paging subsystem deals with units of
+ * CLSIZE pte's describing NBPG (from vm.h) pages each.
+ *
+ * NOTE: SSIZE, SINCR and UPAGES must be multiples of CLSIZE
+ */
+#define CLBYTES (CLSIZE*NBPG)
+#define CLOFSET (CLSIZE*NBPG-1) /* for clusters, like PGOFSET */
+#define claligned(x) ((((int)(x))&CLOFSET)==0)
+#define CLOFF CLOFSET
+#define CLSHIFT (PGSHIFT+CLSIZELOG2)
+
+#if CLSIZE==1
+#define clbase(i) (i)
+#define clrnd(i) (i)
+#else
+/* give the base virtual address (first of CLSIZE) */
+#define clbase(i) ((i) &~ (CLSIZE-1))
+/* round a number of clicks up to a whole cluster */
+#define clrnd(i) (((i) + (CLSIZE-1)) &~ (CLSIZE-1))
+#endif
+
+/* CBLOCK is the size of a clist block, must be power of 2 */
+#define CBLOCK 64
+#define CBSIZE (CBLOCK - sizeof(struct cblock *)) /* data chars/clist */
+#define CROUND (CBLOCK - 1) /* clist rounding */
+
+#ifndef KERNEL
+/*#include <sys/types.h>*/
+#else
+#ifndef LOCORE
+/*#include "types.h"*/
+#endif
+#endif
+
+/*
+ * File system parameters and macros.
+ *
+ * The file system is made out of blocks of at most MAXBSIZE units,
+ * with smaller units (fragments) only in the last direct block.
+ * MAXBSIZE primarily determines the size of buffers in the buffer
+ * pool. It may be made larger without any effect on existing
+ * file systems; however making it smaller make make some file
+ * systems unmountable.
+ *
+ * Note that the blocked devices are assumed to have DEV_BSIZE
+ * "sectors" and that fragments must be some multiple of this size.
+ * Block devices are read in BLKDEV_IOSIZE units. This number must
+ * be a power of two and in the range of
+ * DEV_BSIZE <= BLKDEV_IOSIZE <= MAXBSIZE
+ * This size has no effect upon the file system, but is usually set
+ * to the block size of the root file system, so as to maximize the
+ * speed of ``fsck''.
+ */
+#define MAXBSIZE 8192
+#define DEV_BSIZE 512
+#define DEV_BSHIFT 9 /* log2(DEV_BSIZE) */
+#define BLKDEV_IOSIZE 2048
+#define MAXFRAG 8
+
+#define btodb(bytes) /* calculates (bytes / DEV_BSIZE) */ \
+ ((unsigned)(bytes) >> DEV_BSHIFT)
+#define dbtob(db) /* calculates (db * DEV_BSIZE) */ \
+ ((unsigned)(db) << DEV_BSHIFT)
+
+/*
+ * Map a ``block device block'' to a file system block.
+ * This should be device dependent, and will be after we
+ * add an entry to cdevsw for that purpose. For now though
+ * just use DEV_BSIZE.
+ */
+#define bdbtofsb(bn) ((bn) / (BLKDEV_IOSIZE/DEV_BSIZE))
+
+/*
+ * MAXPATHLEN defines the longest permissable path length
+ * after expanding symbolic links. It is used to allocate
+ * a temporary buffer from the buffer pool in which to do the
+ * name expansion, hence should be a power of two, and must
+ * be less than or equal to MAXBSIZE.
+ * MAXSYMLINKS defines the maximum number of symbolic links
+ * that may be expanded in a path name. It should be set high
+ * enough to allow all legitimate uses, but halt infinite loops
+ * reasonably quickly.
+ */
+#define MAXPATHLEN 1024
+#define MAXSYMLINKS 8
+
+/*
+ * bit map related macros
+ */
+#define setbit(a,i) ((a)[(i)/NBBY] |= 1<<((i)%NBBY))
+#define clrbit(a,i) ((a)[(i)/NBBY] &= ~(1<<((i)%NBBY)))
+#define isset(a,i) ((a)[(i)/NBBY] & (1<<((i)%NBBY)))
+#define isclr(a,i) (((a)[(i)/NBBY] & (1<<((i)%NBBY))) == 0)
+
+/*
+ * Macros for fast min/max.
+ */
+#define MIN(a,b) (((a)<(b))?(a):(b))
+#define MAX(a,b) (((a)>(b))?(a):(b))
+
+/*
+ * Macros for counting and rounding.
+ */
+#ifndef howmany
+#define howmany(x, y) (((x)+((y)-1))/(y))
+#endif
+#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
+
+/*
+ * Maximum size of hostname recognized and stored in the kernel.
+ */
+#define MAXHOSTNAMELEN 64
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)proc.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * One structure allocated per active
+ * process. It contains all data needed
+ * about the process while the
+ * process may be swapped out.
+ * Other per process data (user.h)
+ * is swapped with the process.
+ */
+struct proc {
+ struct proc *p_link; /* linked list of running processes */
+ struct proc *p_rlink;
+ struct proc *p_nxt; /* linked list of allocated proc slots */
+ struct proc **p_prev; /* also zombies, and free proc's */
+ struct pte *p_addr; /* u-area kernel map address */
+ char p_usrpri; /* user-priority based on p_cpu and p_nice */
+ char p_pri; /* priority, negative is high */
+ char p_cpu; /* cpu usage for scheduling */
+ char p_stat;
+ char p_time; /* resident time for scheduling */
+ char p_nice; /* nice for cpu usage */
+ char p_slptime; /* time since last block */
+ char p_cursig;
+ int p_sig; /* signals pending to this process */
+ int p_sigmask; /* current signal mask */
+ int p_sigignore; /* signals being ignored */
+ int p_sigcatch; /* signals being caught by user */
+ int p_flag;
+ uid_t p_uid; /* user id, used to direct tty signals */
+ short p_pgrp; /* name of process group leader */
+ short p_pid; /* unique process id */
+ short p_ppid; /* process id of parent */
+ u_short p_xstat; /* Exit status for wait */
+ struct rusage *p_ru; /* mbuf holding exit information */
+ short p_poip; /* page outs in progress */
+ short p_szpt; /* copy of page table size */
+ size_t p_tsize; /* size of text (clicks) */
+ size_t p_dsize; /* size of data space (clicks) */
+ size_t p_ssize; /* copy of stack size (clicks) */
+ size_t p_rssize; /* current resident set size in clicks */
+ size_t p_maxrss; /* copy of u.u_limit[MAXRSS] */
+ size_t p_swrss; /* resident set size before last swap */
+ swblk_t p_swaddr; /* disk address of u area when swapped */
+ caddr_t p_wchan; /* event process is awaiting */
+ struct text *p_textp; /* pointer to text structure */
+ struct pte *p_p0br; /* page table base P0BR */
+ struct proc *p_xlink; /* linked list of procs sharing same text */
+ short p_cpticks; /* ticks of cpu time */
+ float p_pctcpu; /* %cpu for this process during p_time */
+ short p_ndx; /* proc index for memall (because of vfork) */
+ short p_idhash; /* hashed based on p_pid for kill+exit+... */
+ struct proc *p_pptr; /* pointer to process structure of parent */
+ struct proc *p_cptr; /* pointer to youngest living child */
+ struct proc *p_osptr; /* pointer to older sibling processes */
+ struct proc *p_ysptr; /* pointer to younger siblings */
+ struct itimerval p_realtimer;
+ struct quota *p_quota; /* quotas for this process */
+};
+
+#define PIDHSZ 64
+#define PIDHASH(pid) ((pid) & (PIDHSZ - 1))
+
+#ifdef KERNEL
+short pidhash[PIDHSZ];
+/*struct proc *pfind();*/
+struct proc *proc, *procNPROC; /* the proc table itself */
+struct proc *freeproc, *zombproc, *allproc;
+ /* lists of procs in various states */
+int nproc;
+
+#define NQS 32 /* 32 run queues */
+struct prochd {
+ struct proc *ph_link; /* linked list of running processes */
+ struct proc *ph_rlink;
+} qs[NQS];
+int whichqs; /* bit mask summarizing non-empty qs's */
+#endif
+
+/* stat codes */
+#define SSLEEP 1 /* awaiting an event */
+#define SWAIT 2 /* (abandoned state) */
+#define SRUN 3 /* running */
+#define SIDL 4 /* intermediate state in process creation */
+#define SZOMB 5 /* intermediate state in process termination */
+#define SSTOP 6 /* process being traced */
+
+/* flag codes */
+#define SLOAD 0x0000001 /* in core */
+#define SSYS 0x0000002 /* swapper or pager process */
+#define SLOCK 0x0000004 /* process being swapped out */
+#define SSWAP 0x0000008 /* save area flag */
+#define STRC 0x0000010 /* process is being traced */
+#define SWTED 0x0000020 /* another tracing flag */
+#define SULOCK 0x0000040 /* user settable lock in core */
+#define SPAGE 0x0000080 /* process in page wait state */
+#define SKEEP 0x0000100 /* another flag to prevent swap out */
+#define SOMASK 0x0000200 /* restore old mask after taking signal */
+#define SWEXIT 0x0000400 /* working on exiting */
+#define SPHYSIO 0x0000800 /* doing physical i/o (bio.c) */
+#define SVFORK 0x0001000 /* process resulted from vfork() */
+#define SVFDONE 0x0002000 /* another vfork flag */
+#define SNOVM 0x0004000 /* no vm, parent in a vfork() */
+#define SPAGI 0x0008000 /* init data space on demand, from inode */
+#define SSEQL 0x0010000 /* user warned of sequential vm behavior */
+#define SUANOM 0x0020000 /* user warned of random vm behavior */
+#define STIMO 0x0040000 /* timing out during sleep */
+/* was SDETACH */
+#define SOUSIG 0x0100000 /* using old signal mechanism */
+#define SOWEUPC 0x0200000 /* owe process an addupc() call at next ast */
+#define SSEL 0x0400000 /* selecting; wakeup/waiting danger */
+#define SLOGIN 0x0800000 /* a login process (legit child of init) */
+#define SPTECHG 0x1000000 /* pte's for process have changed */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)protosw.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Protocol switch table.
+ *
+ * Each protocol has a handle initializing one of these structures,
+ * which is used for protocol-protocol and system-protocol communication.
+ *
+ * A protocol is called through the pr_init entry before any other.
+ * Thereafter it is called every 200ms through the pr_fasttimo entry and
+ * every 500ms through the pr_slowtimo for timer based actions.
+ * The system will call the pr_drain entry if it is low on space and
+ * this should throw away any non-critical data.
+ *
+ * Protocols pass data between themselves as chains of mbufs using
+ * the pr_input and pr_output hooks. Pr_input passes data up (towards
+ * UNIX) and pr_output passes it down (towards the imps); control
+ * information passes up and down on pr_ctlinput and pr_ctloutput.
+ * The protocol is responsible for the space occupied by any the
+ * arguments to these entries and must dispose it.
+ *
+ * The userreq routine interfaces protocols to the system and is
+ * described below.
+ */
+struct protosw {
+ short pr_type; /* socket type used for */
+ struct domain *pr_domain; /* domain protocol a member of */
+ short pr_protocol; /* protocol number */
+ short pr_flags; /* see below */
+/* protocol-protocol hooks */
+/* int (*pr_input)();*/ /* input to protocol (from below) */
+/* int (*pr_output)();*/ /* output to protocol (from above) */
+/* int (*pr_ctlinput)();*/ /* control input (from below) */
+/* int (*pr_ctloutput)();*/ /* control output (from above) */
+/* user-protocol hook */
+/* int (*pr_usrreq)();*/ /* user request: see list below */
+/* utility hooks */
+/* int (*pr_init)();*/ /* initialization hook */
+/* int (*pr_fasttimo)();*/ /* fast timeout (200ms) */
+/* int (*pr_slowtimo)();*/ /* slow timeout (500ms) */
+/* int (*pr_drain)();*/ /* flush any excess space possible */
+};
+
+#define PR_SLOWHZ 2 /* 2 slow timeouts per second */
+#define PR_FASTHZ 5 /* 5 fast timeouts per second */
+
+/*
+ * Values for pr_flags
+ */
+#define PR_ATOMIC 0x01 /* exchange atomic messages only */
+#define PR_ADDR 0x02 /* addresses given with messages */
+/* in the current implementation, PR_ADDR needs PR_ATOMIC to work */
+#define PR_CONNREQUIRED 0x04 /* connection required by protocol */
+#define PR_WANTRCVD 0x08 /* want PRU_RCVD calls */
+#define PR_RIGHTS 0x10 /* passes capabilities */
+
+/*
+ * The arguments to usrreq are:
+ * (*protosw[].pr_usrreq)(up, req, m, nam, opt);
+ * where up is a (struct socket *), req is one of these requests,
+ * m is a optional mbuf chain containing a message,
+ * nam is an optional mbuf chain containing an address,
+ * and opt is a pointer to a socketopt structure or nil.
+ * The protocol is responsible for disposal of the mbuf chain m,
+ * the caller is responsible for any space held by nam and opt.
+ * A non-zero return from usrreq gives an
+ * UNIX error number which should be passed to higher level software.
+ */
+#define PRU_ATTACH 0 /* attach protocol to up */
+#define PRU_DETACH 1 /* detach protocol from up */
+#define PRU_BIND 2 /* bind socket to address */
+#define PRU_LISTEN 3 /* listen for connection */
+#define PRU_CONNECT 4 /* establish connection to peer */
+#define PRU_ACCEPT 5 /* accept connection from peer */
+#define PRU_DISCONNECT 6 /* disconnect from peer */
+#define PRU_SHUTDOWN 7 /* won't send any more data */
+#define PRU_RCVD 8 /* have taken data; more room now */
+#define PRU_SEND 9 /* send this data */
+#define PRU_ABORT 10 /* abort (fast DISCONNECT, DETATCH) */
+#define PRU_CONTROL 11 /* control operations on protocol */
+#define PRU_SENSE 12 /* return status into m */
+#define PRU_RCVOOB 13 /* retrieve out of band data */
+#define PRU_SENDOOB 14 /* send out of band data */
+#define PRU_SOCKADDR 15 /* fetch socket's address */
+#define PRU_PEERADDR 16 /* fetch peer's address */
+#define PRU_CONNECT2 17 /* connect two sockets */
+/* begin for protocols internal use */
+#define PRU_FASTTIMO 18 /* 200ms timeout */
+#define PRU_SLOWTIMO 19 /* 500ms timeout */
+#define PRU_PROTORCV 20 /* receive from below */
+#define PRU_PROTOSEND 21 /* send to below */
+
+#define PRU_NREQ 21
+
+#ifdef PRUREQUESTS
+char *prurequests[] = {
+ "ATTACH", "DETACH", "BIND", "LISTEN",
+ "CONNECT", "ACCEPT", "DISCONNECT", "SHUTDOWN",
+ "RCVD", "SEND", "ABORT", "CONTROL",
+ "SENSE", "RCVOOB", "SENDOOB", "SOCKADDR",
+ "PEERADDR", "CONNECT2", "FASTTIMO", "SLOWTIMO",
+ "PROTORCV", "PROTOSEND",
+};
+#endif
+
+/*
+ * The arguments to the ctlinput routine are
+ * (*protosw[].pr_ctlinput)(cmd, arg);
+ * where cmd is one of the commands below, and arg is
+ * an optional argument (caddr_t).
+ *
+ * N.B. The IMP code, in particular, pressumes the values
+ * of some of the commands; change with extreme care.
+ * TODO:
+ * spread out codes so new ICMP codes can be
+ * accomodated more easily
+ */
+#define PRC_IFDOWN 0 /* interface transition */
+#define PRC_ROUTEDEAD 1 /* select new route if possible */
+#define PRC_QUENCH 4 /* some said to slow down */
+#define PRC_MSGSIZE 5 /* message size forced drop */
+#define PRC_HOSTDEAD 6 /* normally from IMP */
+#define PRC_HOSTUNREACH 7 /* ditto */
+#define PRC_UNREACH_NET 8 /* no route to network */
+#define PRC_UNREACH_HOST 9 /* no route to host */
+#define PRC_UNREACH_PROTOCOL 10 /* dst says bad protocol */
+#define PRC_UNREACH_PORT 11 /* bad port # */
+#define PRC_UNREACH_NEEDFRAG 12 /* IP_DF caused drop */
+#define PRC_UNREACH_SRCFAIL 13 /* source route failed */
+#define PRC_REDIRECT_NET 14 /* net routing redirect */
+#define PRC_REDIRECT_HOST 15 /* host routing redirect */
+#define PRC_REDIRECT_TOSNET 16 /* redirect for type of service & net */
+#define PRC_REDIRECT_TOSHOST 17 /* redirect for tos & host */
+#define PRC_TIMXCEED_INTRANS 18 /* packet lifetime expired in transit */
+#define PRC_TIMXCEED_REASS 19 /* lifetime expired on reass q */
+#define PRC_PARAMPROB 20 /* header incorrect */
+
+#define PRC_NCMDS 21
+
+#ifdef PRCREQUESTS
+char *prcrequests[] = {
+ "IFDOWN", "ROUTEDEAD", "#2", "#3",
+ "QUENCH", "MSGSIZE", "HOSTDEAD", "HOSTUNREACH",
+ "NET-UNREACH", "HOST-UNREACH", "PROTO-UNREACH", "PORT-UNREACH",
+ "FRAG-UNREACH", "SRCFAIL-UNREACH", "NET-REDIRECT", "HOST-REDIRECT",
+ "TOSNET-REDIRECT", "TOSHOST-REDIRECT", "TX-INTRANS", "TX-REASS",
+ "PARAMPROB"
+};
+#endif
+
+/*
+ * The arguments to ctloutput are:
+ * (*protosw[].pr_ctloutput)(req, so, level, optname, optval);
+ * req is one of the actions listed below, so is a (struct socket *),
+ * level is an indication of which protocol layer the option is intended.
+ * optname is a protocol dependent socket option request,
+ * optval is a pointer to a mbuf-chain pointer, for value-return results.
+ * The protocol is responsible for disposal of the mbuf chain *optval
+ * if supplied,
+ * the caller is responsible for any space held by *optval, when returned.
+ * A non-zero return from usrreq gives an
+ * UNIX error number which should be passed to higher level software.
+ */
+#define PRCO_GETOPT 0
+#define PRCO_SETOPT 1
+
+#define PRCO_NCMDS 2
+
+#ifdef PRCOREQUESTS
+char *prcorequests[] = {
+ "GETOPT", "SETOPT",
+};
+#endif
+
+#ifdef KERNEL
+/*extern struct protosw *pffindproto(), *pffindtype();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1980, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ptrace.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*#ifndef _PTRACE_*/
+/*#define _PTRACE_*/
+
+#define PT_TRACE_ME 0 /* child declares it's being traced */
+#define PT_READ_I 1 /* read word in child's I space */
+#define PT_READ_D 2 /* read word in child's D space */
+#define PT_READ_U 3 /* read word in child's user structure */
+#define PT_WRITE_I 4 /* write word in child's I space */
+#define PT_WRITE_D 5 /* write word in child's D space */
+#define PT_WRITE_U 6 /* write word in child's user structure */
+#define PT_CONTINUE 7 /* continue the child */
+#define PT_KILL 8 /* kill the child process */
+#define PT_STEP 9 /* single step the child */
+
+/*#endif*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)quota.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * MELBOURNE DISC QUOTAS
+ *
+ * Various junk to do with various quotas (etc) imposed upon
+ * the average user (big brother finally hits UNIX).
+ *
+ * The following structure exists in core for each logged on user.
+ * It contains global junk relevant to that user's quotas.
+ *
+ * The u_quota field of each user struct contains a pointer to
+ * the quota struct relevant to the current process, this is changed
+ * by 'setuid' sys call, &/or by the Q_SETUID quota() call.
+ */
+struct quota {
+ struct quota *q_forw, *q_back; /* hash chain, MUST be first */
+ short q_cnt; /* ref count (# processes) */
+ uid_t q_uid; /* real uid of owner */
+ int q_flags; /* struct management flags */
+#define Q_LOCK 0x01 /* quota struct locked (for disc i/o) */
+#define Q_WANT 0x02 /* issue a wakeup when lock goes off */
+#define Q_NEW 0x04 /* new quota - no proc1 msg sent yet */
+#define Q_NDQ 0x08 /* account has NO disc quota */
+ struct quota *q_freef, **q_freeb;
+ struct dquot *q_dq[NMOUNT]; /* disc quotas for mounted filesys's */
+};
+
+#define NOQUOTA ((struct quota *) 0)
+
+#if defined(KERNEL) && defined(QUOTA)
+struct quota *quota, *quotaNQUOTA;
+int nquota;
+/*struct quota *getquota(), *qfind();*/
+#endif
+
+/*
+ * The following structure defines the format of the disc quota file
+ * (as it appears on disc) - the file is an array of these structures
+ * indexed by user number. The setquota sys call establishes the inode
+ * for each quota file (a pointer is retained in the mount structure).
+ *
+ * The following constants define the number of warnings given a user
+ * before the soft limits are treated as hard limits (usually resulting
+ * in an allocation failure). The warnings are normally manipulated
+ * each time a user logs in through the Q_DOWARN quota call. If
+ * the user logs in and is under the soft limit the warning count
+ * is reset to MAX_*_WARN, otherwise a message is printed and the
+ * warning count is decremented. This makes MAX_*_WARN equivalent to
+ * the number of logins before soft limits are treated as hard limits.
+ */
+#define MAX_IQ_WARN 3
+#define MAX_DQ_WARN 3
+
+struct dqblk {
+ u_long dqb_bhardlimit; /* absolute limit on disc blks alloc */
+ u_long dqb_bsoftlimit; /* preferred limit on disc blks */
+ u_long dqb_curblocks; /* current block count */
+ u_short dqb_ihardlimit; /* maximum # allocated inodes + 1 */
+ u_short dqb_isoftlimit; /* preferred inode limit */
+ u_short dqb_curinodes; /* current # allocated inodes */
+ u_char dqb_bwarn; /* # warnings left about excessive disc use */
+ u_char dqb_iwarn; /* # warnings left about excessive inodes */
+};
+
+/*
+ * The following structure records disc usage for a user on a filesystem.
+ * There is one allocated for each quota that exists on any filesystem
+ * for the current user. A cache is kept of other recently used entries.
+ */
+struct dquot {
+ struct dquot *dq_forw, *dq_back;/* MUST be first entry */
+ union {
+ struct quota *Dq_own; /* the quota that points to this */
+ struct { /* free list */
+ struct dquot *Dq_freef, **Dq_freeb;
+ } dq_f;
+ } dq_u;
+ short dq_flags;
+#define DQ_LOCK 0x01 /* this quota locked (no MODS) */
+#define DQ_WANT 0x02 /* wakeup on unlock */
+#define DQ_MOD 0x04 /* this quota modified since read */
+#define DQ_FAKE 0x08 /* no limits here, just usage */
+#define DQ_BLKS 0x10 /* has been warned about blk limit */
+#define DQ_INODS 0x20 /* has been warned about inode limit */
+ short dq_cnt; /* count of active references */
+ uid_t dq_uid; /* user this applies to */
+ dev_t dq_dev; /* filesystem this relates to */
+ struct dqblk dq_dqb; /* actual usage & quotas */
+};
+
+#define dq_own dq_u.Dq_own
+#define dq_freef dq_u.dq_f.Dq_freef
+#define dq_freeb dq_u.dq_f.Dq_freeb
+#define dq_bhardlimit dq_dqb.dqb_bhardlimit
+#define dq_bsoftlimit dq_dqb.dqb_bsoftlimit
+#define dq_curblocks dq_dqb.dqb_curblocks
+#define dq_ihardlimit dq_dqb.dqb_ihardlimit
+#define dq_isoftlimit dq_dqb.dqb_isoftlimit
+#define dq_curinodes dq_dqb.dqb_curinodes
+#define dq_bwarn dq_dqb.dqb_bwarn
+#define dq_iwarn dq_dqb.dqb_iwarn
+
+#define NODQUOT ((struct dquot *) 0)
+#define LOSTDQUOT ((struct dquot *) 1)
+
+#if defined(KERNEL) && defined(QUOTA)
+struct dquot *dquot, *dquotNDQUOT;
+int ndquot;
+/*struct dquot *discquota(), *inoquota(), *dqalloc(), *dqp();*/
+#endif
+
+/*
+ * Definitions for the 'quota' system call.
+ */
+#define Q_SETDLIM 1 /* set disc limits & usage */
+#define Q_GETDLIM 2 /* get disc limits & usage */
+#define Q_SETDUSE 3 /* set disc usage only */
+#define Q_SYNC 4 /* update disc copy of quota usages */
+#define Q_SETUID 16 /* change proc to use quotas for uid */
+#define Q_SETWARN 25 /* alter inode/block warning counts */
+#define Q_DOWARN 26 /* warn user about excessive space/inodes */
+
+/*
+ * Used in Q_SETDUSE.
+ */
+struct dqusage {
+ u_short du_curinodes;
+ u_long du_curblocks;
+};
+
+/*
+ * Used in Q_SETWARN.
+ */
+struct dqwarn {
+ u_char dw_bwarn;
+ u_char dw_iwarn;
+};
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)reboot.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Arguments to reboot system call.
+ * These are passed to boot program in r11,
+ * and on to init.
+ */
+#define RB_AUTOBOOT 0 /* flags for system auto-booting itself */
+
+#define RB_ASKNAME 0x01 /* ask for file name to reboot from */
+#define RB_SINGLE 0x02 /* reboot to single user only */
+#define RB_NOSYNC 0x04 /* dont sync before reboot */
+#define RB_HALT 0x08 /* don't reboot, just halt */
+#define RB_INITNAME 0x10 /* name given for /etc/init */
+#define RB_DFLTROOT 0x20 /* use compiled-in rootdev */
+
+#define RB_PANIC 0 /* reboot due to panic */
+#define RB_BOOT 1 /* reboot due to boot() */
+
+/*
+ * Constants for converting boot-style device number to type,
+ * adaptor (uba, mba, etc), unit number and partition number.
+ * Type (== major device number) is in the low byte
+ * for backward compatibility. Except for that of the "magic
+ * number", each mask applies to the shifted value.
+ */
+#define B_ADAPTORSHIFT 24
+#define B_ADAPTORMASK 0x0f
+#define B_UNITSHIFT 16
+#define B_UNITMASK 0xff
+#define B_PARTITIONSHIFT 8
+#define B_PARTITIONMASK 0xff
+#define B_TYPESHIFT 0
+#define B_TYPEMASK 0xff
+#define B_MAGICMASK 0xf0000000
+#define B_DEVMAGIC 0xa0000000
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)resource.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Process priority specifications to get/setpriority.
+ */
+#define PRIO_MIN -20
+#define PRIO_MAX 20
+
+#define PRIO_PROCESS 0
+#define PRIO_PGRP 1
+#define PRIO_USER 2
+
+/*
+ * Resource utilization information.
+ */
+
+#define RUSAGE_SELF 0
+#define RUSAGE_CHILDREN -1
+
+struct rusage {
+ struct timeval ru_utime; /* user time used */
+ struct timeval ru_stime; /* system time used */
+ long ru_maxrss;
+#define ru_first ru_ixrss
+ long ru_ixrss; /* integral shared memory size */
+ long ru_idrss; /* integral unshared data " */
+ long ru_isrss; /* integral unshared stack " */
+ long ru_minflt; /* page reclaims */
+ long ru_majflt; /* page faults */
+ long ru_nswap; /* swaps */
+ long ru_inblock; /* block input operations */
+ long ru_oublock; /* block output operations */
+ long ru_msgsnd; /* messages sent */
+ long ru_msgrcv; /* messages received */
+ long ru_nsignals; /* signals received */
+ long ru_nvcsw; /* voluntary context switches */
+ long ru_nivcsw; /* involuntary " */
+#define ru_last ru_nivcsw
+};
+
+/*
+ * Resource limits
+ */
+#define RLIMIT_CPU 0 /* cpu time in milliseconds */
+#define RLIMIT_FSIZE 1 /* maximum file size */
+#define RLIMIT_DATA 2 /* data size */
+#define RLIMIT_STACK 3 /* stack size */
+#define RLIMIT_CORE 4 /* core file size */
+#define RLIMIT_RSS 5 /* resident set size */
+
+#define RLIM_NLIMITS 6 /* number of resource limits */
+
+#define RLIM_INFINITY 0x7fffffff
+
+struct rlimit {
+ int rlim_cur; /* current (soft) limit */
+ int rlim_max; /* maximum value for rlim_cur */
+};
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)seg.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Mapper addresses and bits
+ */
+
+#define RO PG_URKR /* access abilities */
+#define RW PG_UW
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)signal.h 7.1 (Berkeley) 6/4/86
+ */
+
+#ifndef NSIG
+#define NSIG 32
+
+#define SIGHUP 1 /* hangup */
+#define SIGINT 2 /* interrupt */
+#define SIGQUIT 3 /* quit */
+#define SIGILL 4 /* illegal instruction (not reset when caught) */
+#define ILL_RESAD_FAULT 0x0 /* reserved addressing fault */
+#define ILL_PRIVIN_FAULT 0x1 /* privileged instruction fault */
+#define ILL_RESOP_FAULT 0x2 /* reserved operand fault */
+/* CHME, CHMS, CHMU are not yet given back to users reasonably */
+#define SIGTRAP 5 /* trace trap (not reset when caught) */
+#define SIGIOT 6 /* IOT instruction */
+#define SIGABRT SIGIOT /* compatibility */
+#define SIGEMT 7 /* EMT instruction */
+#define SIGFPE 8 /* floating point exception */
+#define FPE_INTOVF_TRAP 0x1 /* integer overflow */
+#define FPE_INTDIV_TRAP 0x2 /* integer divide by zero */
+#define FPE_FLTOVF_TRAP 0x3 /* floating overflow */
+#define FPE_FLTDIV_TRAP 0x4 /* floating/decimal divide by zero */
+#define FPE_FLTUND_TRAP 0x5 /* floating underflow */
+#define FPE_DECOVF_TRAP 0x6 /* decimal overflow */
+#define FPE_SUBRNG_TRAP 0x7 /* subscript out of range */
+#define FPE_FLTOVF_FAULT 0x8 /* floating overflow fault */
+#define FPE_FLTDIV_FAULT 0x9 /* divide by zero floating fault */
+#define FPE_FLTUND_FAULT 0xa /* floating underflow fault */
+#define SIGKILL 9 /* kill (cannot be caught or ignored) */
+#define SIGBUS 10 /* bus error */
+#define SIGSEGV 11 /* segmentation violation */
+#define SIGSYS 12 /* bad argument to system call */
+#define SIGPIPE 13 /* write on a pipe with no one to read it */
+#define SIGALRM 14 /* alarm clock */
+#define SIGTERM 15 /* software termination signal from kill */
+#define SIGURG 16 /* urgent condition on IO channel */
+#define SIGSTOP 17 /* sendable stop signal not from tty */
+#define SIGTSTP 18 /* stop signal from tty */
+#define SIGCONT 19 /* continue a stopped process */
+#define SIGCHLD 20 /* to parent on child stop or exit */
+#define SIGCLD SIGCHLD /* compatibility */
+#define SIGTTIN 21 /* to readers pgrp upon background tty read */
+#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
+#define SIGIO 23 /* input/output possible signal */
+#define SIGXCPU 24 /* exceeded CPU time limit */
+#define SIGXFSZ 25 /* exceeded file size limit */
+#define SIGVTALRM 26 /* virtual time alarm */
+#define SIGPROF 27 /* profiling time alarm */
+#define SIGWINCH 28 /* window size changes */
+#define SIGUSR1 30 /* user defined signal 1 */
+#define SIGUSR2 31 /* user defined signal 2 */
+
+#ifndef KERNEL
+/*int (*signal())();*/
+#endif
+
+/*
+ * Signal vector "template" used in sigvec call.
+ */
+struct sigvec {
+/* int (*sv_handler)();*/ /* signal handler */
+ int sv_mask; /* signal mask to apply */
+ int sv_flags; /* see signal options below */
+};
+#define SV_ONSTACK 0x0001 /* take signal on signal stack */
+#define SV_INTERRUPT 0x0002 /* do not restart system on signal return */
+#define sv_onstack sv_flags /* isn't compatibility wonderful! */
+
+/*
+ * Structure used in sigstack call.
+ */
+struct sigstack {
+ char *ss_sp; /* signal stack pointer */
+ int ss_onstack; /* current status */
+};
+
+/*
+ * Information pushed on stack when a signal is delivered.
+ * This is used by the kernel to restore state following
+ * execution of the signal handler. It is also made available
+ * to the handler to allow it to properly restore state if
+ * a non-standard exit is performed.
+ */
+struct sigcontext {
+ int sc_onstack; /* sigstack state to restore */
+ int sc_mask; /* signal mask to restore */
+ int sc_sp; /* sp to restore */
+ int sc_fp; /* fp to restore */
+ int sc_ap; /* ap to restore */
+ int sc_pc; /* pc to restore */
+ int sc_ps; /* psl to restore */
+};
+
+#define BADSIG (int (*)())-1
+#define SIG_DFL (int (*)())0
+#define SIG_IGN (int (*)())1
+
+#ifdef KERNEL
+#define SIG_CATCH (int (*)())2
+#define SIG_HOLD (int (*)())3
+#endif
+#endif
+
+/*
+ * Macro for converting signal number to a mask suitable for
+ * sigblock().
+ */
+#define sigmask(m) (1 << ((m)-1))
--- /dev/null
+/*
+ * Copyright (c) 1982,1985, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)socket.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Definitions related to sockets: types, address families, options.
+ */
+
+/*
+ * Types
+ */
+#define SOCK_STREAM 1 /* stream socket */
+#define SOCK_DGRAM 2 /* datagram socket */
+#define SOCK_RAW 3 /* raw-protocol interface */
+#define SOCK_RDM 4 /* reliably-delivered message */
+#define SOCK_SEQPACKET 5 /* sequenced packet stream */
+
+/*
+ * Option flags per-socket.
+ */
+#define SO_DEBUG 0x0001 /* turn on debugging info recording */
+#define SO_ACCEPTCONN 0x0002 /* socket has had listen() */
+#define SO_REUSEADDR 0x0004 /* allow local address reuse */
+#define SO_KEEPALIVE 0x0008 /* keep connections alive */
+#define SO_DONTROUTE 0x0010 /* just use interface addresses */
+#define SO_BROADCAST 0x0020 /* permit sending of broadcast msgs */
+#define SO_USELOOPBACK 0x0040 /* bypass hardware when possible */
+#define SO_LINGER 0x0080 /* linger on close if data present */
+#define SO_OOBINLINE 0x0100 /* leave received OOB data in line */
+
+/*
+ * Additional options, not kept in so_options.
+ */
+#define SO_SNDBUF 0x1001 /* send buffer size */
+#define SO_RCVBUF 0x1002 /* receive buffer size */
+#define SO_SNDLOWAT 0x1003 /* send low-water mark */
+#define SO_RCVLOWAT 0x1004 /* receive low-water mark */
+#define SO_SNDTIMEO 0x1005 /* send timeout */
+#define SO_RCVTIMEO 0x1006 /* receive timeout */
+#define SO_ERROR 0x1007 /* get error status and clear */
+#define SO_TYPE 0x1008 /* get socket type */
+
+/*
+ * Structure used for manipulating linger option.
+ */
+struct linger {
+ int l_onoff; /* option on/off */
+ int l_linger; /* linger time */
+};
+
+/*
+ * Level number for (get/set)sockopt() to apply to socket itself.
+ */
+#define SOL_SOCKET 0xffff /* options for socket level */
+
+/*
+ * Address families.
+ */
+#define AF_UNSPEC 0 /* unspecified */
+#define AF_UNIX 1 /* local to host (pipes, portals) */
+#define AF_INET 2 /* internetwork: UDP, TCP, etc. */
+#define AF_IMPLINK 3 /* arpanet imp addresses */
+#define AF_PUP 4 /* pup protocols: e.g. BSP */
+#define AF_CHAOS 5 /* mit CHAOS protocols */
+#define AF_NS 6 /* XEROX NS protocols */
+#define AF_NBS 7 /* nbs protocols */
+#define AF_ECMA 8 /* european computer manufacturers */
+#define AF_DATAKIT 9 /* datakit protocols */
+#define AF_CCITT 10 /* CCITT protocols, X.25 etc */
+#define AF_SNA 11 /* IBM SNA */
+#define AF_DECnet 12 /* DECnet */
+#define AF_DLI 13 /* Direct data link interface */
+#define AF_LAT 14 /* LAT */
+#define AF_HYLINK 15 /* NSC Hyperchannel */
+#define AF_APPLETALK 16 /* Apple Talk */
+
+#define AF_MAX 17
+
+/*
+ * Structure used by kernel to store most
+ * addresses.
+ */
+struct sockaddr {
+ u_short sa_family; /* address family */
+ char sa_data[14]; /* up to 14 bytes of direct address */
+};
+
+/*
+ * Structure used by kernel to pass protocol
+ * information in raw sockets.
+ */
+struct sockproto {
+ u_short sp_family; /* address family */
+ u_short sp_protocol; /* protocol */
+};
+
+/*
+ * Protocol families, same as address families for now.
+ */
+#define PF_UNSPEC AF_UNSPEC
+#define PF_UNIX AF_UNIX
+#define PF_INET AF_INET
+#define PF_IMPLINK AF_IMPLINK
+#define PF_PUP AF_PUP
+#define PF_CHAOS AF_CHAOS
+#define PF_NS AF_NS
+#define PF_NBS AF_NBS
+#define PF_ECMA AF_ECMA
+#define PF_DATAKIT AF_DATAKIT
+#define PF_CCITT AF_CCITT
+#define PF_SNA AF_SNA
+#define PF_DECnet AF_DECnet
+#define PF_DLI AF_DLI
+#define PF_LAT AF_LAT
+#define PF_HYLINK AF_HYLINK
+#define PF_APPLETALK AF_APPLETALK
+
+#define PF_MAX AF_MAX
+
+/*
+ * Maximum queue length specifiable by listen.
+ */
+#define SOMAXCONN 5
+
+/*
+ * Message header for recvmsg and sendmsg calls.
+ */
+struct msghdr {
+ caddr_t msg_name; /* optional address */
+ int msg_namelen; /* size of address */
+ struct iovec *msg_iov; /* scatter/gather array */
+ int msg_iovlen; /* # elements in msg_iov */
+ caddr_t msg_accrights; /* access rights sent/received */
+ int msg_accrightslen;
+};
+
+#define MSG_OOB 0x1 /* process out-of-band data */
+#define MSG_PEEK 0x2 /* peek at incoming message */
+#define MSG_DONTROUTE 0x4 /* send without using routing tables */
+
+#define MSG_MAXIOVLEN 16
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)socketvar.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Kernel structure per socket.
+ * Contains send and receive buffer queues,
+ * handle on protocol and pointer to protocol
+ * private data and error information.
+ */
+struct socket {
+ short so_type; /* generic type, see socket.h */
+ short so_options; /* from socket call, see socket.h */
+ short so_linger; /* time to linger while closing */
+ short so_state; /* internal state flags SS_*, below */
+ caddr_t so_pcb; /* protocol control block */
+ struct protosw *so_proto; /* protocol handle */
+/*
+ * Variables for connection queueing.
+ * Socket where accepts occur is so_head in all subsidiary sockets.
+ * If so_head is 0, socket is not related to an accept.
+ * For head socket so_q0 queues partially completed connections,
+ * while so_q is a queue of connections ready to be accepted.
+ * If a connection is aborted and it has so_head set, then
+ * it has to be pulled out of either so_q0 or so_q.
+ * We allow connections to queue up based on current queue lengths
+ * and limit on number of queued connections for this socket.
+ */
+ struct socket *so_head; /* back pointer to accept socket */
+ struct socket *so_q0; /* queue of partial connections */
+ short so_q0len; /* partials on so_q0 */
+ struct socket *so_q; /* queue of incoming connections */
+ short so_qlen; /* number of connections on so_q */
+ short so_qlimit; /* max number queued connections */
+/*
+ * Variables for socket buffering.
+ */
+ struct sockbuf {
+ u_short sb_cc; /* actual chars in buffer */
+ u_short sb_hiwat; /* max actual char count */
+ u_short sb_mbcnt; /* chars of mbufs used */
+ u_short sb_mbmax; /* max chars of mbufs to use */
+ u_short sb_lowat; /* low water mark (not used yet) */
+ short sb_timeo; /* timeout (not used yet) */
+ struct mbuf *sb_mb; /* the mbuf chain */
+ struct proc *sb_sel; /* process selecting read/write */
+ short sb_flags; /* flags, see below */
+ } so_rcv, so_snd;
+#define SB_MAX 65535 /* max chars in sockbuf */
+#define SB_LOCK 0x01 /* lock on data queue (so_rcv only) */
+#define SB_WANT 0x02 /* someone is waiting to lock */
+#define SB_WAIT 0x04 /* someone is waiting for data/space */
+#define SB_SEL 0x08 /* buffer is selected */
+#define SB_COLL 0x10 /* collision selecting */
+ short so_timeo; /* connection timeout */
+ u_short so_error; /* error affecting connection */
+ u_short so_oobmark; /* chars to oob mark */
+ short so_pgrp; /* pgrp for signals */
+};
+
+/*
+ * Socket state bits.
+ */
+#define SS_NOFDREF 0x001 /* no file table ref any more */
+#define SS_ISCONNECTED 0x002 /* socket connected to a peer */
+#define SS_ISCONNECTING 0x004 /* in process of connecting to peer */
+#define SS_ISDISCONNECTING 0x008 /* in process of disconnecting */
+#define SS_CANTSENDMORE 0x010 /* can't send more data to peer */
+#define SS_CANTRCVMORE 0x020 /* can't receive more data from peer */
+#define SS_RCVATMARK 0x040 /* at mark on input */
+
+#define SS_PRIV 0x080 /* privileged for broadcast, raw... */
+#define SS_NBIO 0x100 /* non-blocking ops */
+#define SS_ASYNC 0x200 /* async i/o notify */
+
+
+/*
+ * Macros for sockets and socket buffering.
+ */
+
+/* how much space is there in a socket buffer (so->so_snd or so->so_rcv) */
+#define sbspace(sb) \
+ (MIN((int)((sb)->sb_hiwat - (sb)->sb_cc),\
+ (int)((sb)->sb_mbmax - (sb)->sb_mbcnt)))
+
+/* do we have to send all at once on a socket? */
+#define sosendallatonce(so) \
+ ((so)->so_proto->pr_flags & PR_ATOMIC)
+
+/* can we read something from so? */
+#define soreadable(so) \
+ ((so)->so_rcv.sb_cc || ((so)->so_state & SS_CANTRCVMORE) || \
+ (so)->so_qlen || (so)->so_error)
+
+/* can we write something to so? */
+#define sowriteable(so) \
+ (sbspace(&(so)->so_snd) > 0 && \
+ (((so)->so_state&SS_ISCONNECTED) || \
+ ((so)->so_proto->pr_flags&PR_CONNREQUIRED)==0) || \
+ ((so)->so_state & SS_CANTSENDMORE) || \
+ (so)->so_error)
+
+/* adjust counters in sb reflecting allocation of m */
+#define sballoc(sb, m) { \
+ (sb)->sb_cc += (m)->m_len; \
+ (sb)->sb_mbcnt += MSIZE; \
+ if ((m)->m_off > MMAXOFF) \
+ (sb)->sb_mbcnt += CLBYTES; \
+}
+
+/* adjust counters in sb reflecting freeing of m */
+#define sbfree(sb, m) { \
+ (sb)->sb_cc -= (m)->m_len; \
+ (sb)->sb_mbcnt -= MSIZE; \
+ if ((m)->m_off > MMAXOFF) \
+ (sb)->sb_mbcnt -= CLBYTES; \
+}
+
+/* set lock on sockbuf sb */
+#define sblock(sb) { \
+ while ((sb)->sb_flags & SB_LOCK) { \
+ (sb)->sb_flags |= SB_WANT; \
+ sleep((caddr_t)&(sb)->sb_flags, PZERO+1); \
+ } \
+ (sb)->sb_flags |= SB_LOCK; \
+}
+
+/* release lock on sockbuf sb */
+#define sbunlock(sb) { \
+ (sb)->sb_flags &= ~SB_LOCK; \
+ if ((sb)->sb_flags & SB_WANT) { \
+ (sb)->sb_flags &= ~SB_WANT; \
+ wakeup((caddr_t)&(sb)->sb_flags); \
+ } \
+}
+
+#define sorwakeup(so) sowakeup((so), &(so)->so_rcv)
+#define sowwakeup(so) sowakeup((so), &(so)->so_snd)
+
+#ifdef KERNEL
+/*struct socket *sonewconn();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)stat.h 7.1 (Berkeley) 6/4/86
+ */
+
+struct stat
+{
+ dev_t st_dev;
+ ino_t st_ino;
+ unsigned short st_mode;
+ short st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ off_t st_size;
+ time_t st_atime;
+ int st_spare1;
+ time_t st_mtime;
+ int st_spare2;
+ time_t st_ctime;
+ int st_spare3;
+ long st_blksize;
+ long st_blocks;
+ long st_spare4[2];
+};
+
+#define S_IFMT 0170000 /* type of file */
+#define S_IFDIR 0040000 /* directory */
+#define S_IFCHR 0020000 /* character special */
+#define S_IFBLK 0060000 /* block special */
+#define S_IFREG 0100000 /* regular */
+#define S_IFLNK 0120000 /* symbolic link */
+#define S_IFSOCK 0140000/* socket */
+#define S_ISUID 0004000 /* set user id on execution */
+#define S_ISGID 0002000 /* set group id on execution */
+#define S_ISVTX 0001000 /* save swapped text even after use */
+#define S_IREAD 0000400 /* read permission, owner */
+#define S_IWRITE 0000200 /* write permission, owner */
+#define S_IEXEC 0000100 /* execute/search permission, owner */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)syslog.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Facility codes
+ */
+
+#define LOG_KERN (0<<3) /* kernel messages */
+#define LOG_USER (1<<3) /* random user-level messages */
+#define LOG_MAIL (2<<3) /* mail system */
+#define LOG_DAEMON (3<<3) /* system daemons */
+#define LOG_AUTH (4<<3) /* security/authorization messages */
+#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
+#define LOG_LPR (6<<3) /* line printer subsystem */
+ /* other codes through 15 reserved for system use */
+#define LOG_LOCAL0 (16<<3) /* reserved for local use */
+#define LOG_LOCAL1 (17<<3) /* reserved for local use */
+#define LOG_LOCAL2 (18<<3) /* reserved for local use */
+#define LOG_LOCAL3 (19<<3) /* reserved for local use */
+#define LOG_LOCAL4 (20<<3) /* reserved for local use */
+#define LOG_LOCAL5 (21<<3) /* reserved for local use */
+#define LOG_LOCAL6 (22<<3) /* reserved for local use */
+#define LOG_LOCAL7 (23<<3) /* reserved for local use */
+
+#define LOG_NFACILITIES 24 /* maximum number of facilities */
+#define LOG_FACMASK 0x03f8 /* mask to extract facility part */
+
+/*
+ * Priorities (these are ordered)
+ */
+
+#define LOG_EMERG 0 /* system is unusable */
+#define LOG_ALERT 1 /* action must be taken immediately */
+#define LOG_CRIT 2 /* critical conditions */
+#define LOG_ERR 3 /* error conditions */
+#define LOG_WARNING 4 /* warning conditions */
+#define LOG_NOTICE 5 /* normal but signification condition */
+#define LOG_INFO 6 /* informational */
+#define LOG_DEBUG 7 /* debug-level messages */
+
+#define LOG_PRIMASK 0x0007 /* mask to extract priority part (internal) */
+
+/*
+ * arguments to setlogmask.
+ */
+#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
+#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
+
+/*
+ * Option flags for openlog.
+ *
+ * LOG_ODELAY no longer does anything; LOG_NDELAY is the
+ * inverse of what it used to be.
+ */
+#define LOG_PID 0x01 /* log the pid with each message */
+#define LOG_CONS 0x02 /* log on the console if errors in sending */
+#define LOG_ODELAY 0x04 /* delay open until syslog() is called */
+#define LOG_NDELAY 0x08 /* don't delay open */
+#define LOG_NOWAIT 0x10 /* if forking to log on console, don't wait() */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)systm.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Random set of variables
+ * used by more than one
+ * routine.
+ */
+extern char version[]; /* system version */
+
+/*
+ * Nblkdev is the number of entries
+ * (rows) in the block switch. It is
+ * set in binit/bio.c by making
+ * a pass over the switch.
+ * Used in bounds checking on major
+ * device numbers.
+ */
+int nblkdev;
+
+/*
+ * Number of character switch entries.
+ * Set by cinit/prim.c
+ */
+int nchrdev;
+
+int nswdev; /* number of swap devices */
+int mpid; /* generic for unique process id's */
+char runin; /* scheduling flag */
+char runout; /* scheduling flag */
+int runrun; /* scheduling flag */
+char kmapwnt; /* kernel map want flag */
+char curpri; /* more scheduling */
+
+int maxmem; /* actual max memory per process */
+int physmem; /* physical memory on this CPU */
+
+int nswap; /* size of swap space */
+int updlock; /* lock for sync */
+daddr_t rablock; /* block to be read ahead */
+int rasize; /* size of block in rablock */
+extern int intstack[]; /* stack for interrupts */
+dev_t rootdev; /* device of the root */
+dev_t dumpdev; /* device to take dumps on */
+long dumplo; /* offset into dumpdev */
+dev_t swapdev; /* swapping device */
+dev_t argdev; /* device for argument lists */
+
+#ifdef vax
+extern int icode[]; /* user init code */
+extern int szicode; /* its size */
+#endif
+
+/*daddr_t bmap();*/
+/*caddr_t calloc();*/
+/*int memall();*/
+/*int vmemall();*/
+/*caddr_t wmemall();*/
+/*swblk_t vtod();*/
+
+/*
+ * Structure of the system-entry table
+ */
+extern struct sysent
+{
+ int sy_narg; /* total number of arguments */
+/* int (*sy_call)();*/ /* handler */
+} sysent[];
+
+int noproc; /* no one is running just now */
+char *panicstr;
+int wantin;
+int boothowto; /* reboot flags, from console subsystem */
+int selwait;
+
+extern char vmmap[]; /* poor name! */
+
+/* casts to keep lint happy */
+#define insque(q,p) _insque((caddr_t)q,(caddr_t)p)
+#define remque(q) _remque((caddr_t)q)
--- /dev/null
+/*
+ * Copyright (c) 1985, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tablet.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*#ifndef _TABLET_*/
+/*
+ * Tablet line discipline.
+ */
+#ifdef KERNEL
+/*#include "../h/ioctl.h"*/
+#else
+/*#include <sys/ioctl.h>*/
+#endif
+
+/*
+ * Reads on the tablet return one of the following
+ * structures, depending on the underlying tablet type.
+ * The first two are defined such that a read of
+ * sizeof (gtcopos) on a non-gtco tablet will return
+ * meaningful info. The in-proximity bit is simulated
+ * where the tablet does not directly provide the information.
+ */
+struct tbpos {
+ int xpos, ypos; /* raw x-y coordinates */
+ short status; /* buttons/pen down */
+#define TBINPROX 0100000 /* pen in proximity of tablet */
+ short scount; /* sample count */
+};
+
+struct gtcopos {
+ int xpos, ypos; /* raw x-y coordinates */
+ short status; /* as above */
+ short scount; /* sample count */
+ short xtilt, ytilt; /* raw tilt */
+ short pressure;
+ short pad; /* pad to longword boundary */
+};
+
+struct polpos {
+ short p_x, p_y, p_z; /* raw 3-space coordinates */
+ short p_azi, p_pit, p_rol; /* azimuth, pitch, and roll */
+ short p_stat; /* status, as above */
+ char p_key; /* calculator input keyboard */
+};
+
+#define BIOSMODE _IOW(b, 1, int) /* set mode bit(s) */
+#define BIOGMODE _IOR(b, 2, int) /* get mode bit(s) */
+#define TBMODE 0xfff0 /* mode bits: */
+#define TBPOINT 0x0010 /* single point */
+#define TBRUN 0x0000 /* runs contin. */
+#define TBSTOP 0x0020 /* shut-up */
+#define TBGO 0x0000 /* ~TBSTOP */
+#define TBTYPE 0x000f /* tablet type: */
+#define TBUNUSED 0x0000
+#define TBHITACHI 0x0001 /* hitachi tablet */
+#define TBTIGER 0x0002 /* hitachi tiger */
+#define TBGTCO 0x0003 /* gtco */
+#define TBPOL 0x0004 /* polhemus 3space */
+#define TBHDG 0x0005 /* hdg-1111b, low res */
+#define TBHDGHIRES 0x0006 /* hdg-1111b, high res */
+#define BIOSTYPE _IOW(b, 3, int) /* set tablet type */
+#define BIOGTYPE _IOR(b, 4, int) /* get tablet type*/
+/*#endif*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)text.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Text structure.
+ * One allocated per pure
+ * procedure on swap device.
+ * Manipulated by text.c
+ */
+#define NXDAD 12 /* param.h:MAXTSIZ / vmparam.h:DMTEXT */
+
+struct text
+{
+ struct text *x_forw; /* forward link in free list */
+ struct text **x_back; /* backward link in free list */
+ swblk_t x_daddr[NXDAD]; /* disk addresses of dmtext-page segments */
+ swblk_t x_ptdaddr; /* disk address of page table */
+ size_t x_size; /* size (clicks) */
+ struct proc *x_caddr; /* ptr to linked proc, if loaded */
+ struct inode *x_iptr; /* inode of prototype */
+ short x_rssize;
+ short x_swrss;
+ short x_count; /* reference count */
+ short x_ccount; /* number of loaded references */
+ char x_flag; /* traced, written flags */
+ char x_slptime;
+ short x_poip; /* page out in progress count */
+};
+
+#ifdef KERNEL
+struct text *text, *textNTEXT;
+int ntext;
+#endif
+
+#define XTRC 0x01 /* Text may be written, exclusive use */
+#define XWRIT 0x02 /* Text written into, must swap out */
+#define XLOAD 0x04 /* Currently being read from file */
+#define XLOCK 0x08 /* Being swapped in or out */
+#define XWANT 0x10 /* Wanted for swapping */
+#define XPAGI 0x20 /* Page in on demand from inode */
+#define XUNUSED 0x40 /* unused since swapped out for cache */
+
+/*
+ * Text table statistics
+ */
+struct xstats {
+ u_long alloc; /* calls to xalloc */
+ u_long alloc_inuse; /* found in use/sticky */
+ u_long alloc_cachehit; /* found in cache */
+ u_long alloc_cacheflush; /* flushed cached text */
+ u_long alloc_unused; /* flushed unused cached text */
+ u_long free; /* calls to xfree */
+ u_long free_inuse; /* still in use/sticky */
+ u_long free_cache; /* placed in cache */
+ u_long free_cacheswap; /* swapped out to place in cache */
+};
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)time.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Structure returned by gettimeofday(2) system call,
+ * and used in other calls.
+ */
+struct timeval {
+ long tv_sec; /* seconds */
+ long tv_usec; /* and microseconds */
+};
+
+struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+#define DST_NONE 0 /* not on dst */
+#define DST_USA 1 /* USA style dst */
+#define DST_AUST 2 /* Australian style dst */
+#define DST_WET 3 /* Western European dst */
+#define DST_MET 4 /* Middle European dst */
+#define DST_EET 5 /* Eastern European dst */
+#define DST_CAN 6 /* Canada */
+
+/*
+ * Operations on timevals.
+ *
+ * NB: timercmp does not work for >= or <=.
+ */
+#define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec)
+#define timercmp(tvp, uvp, cmp) \
+ ((tvp)->tv_sec cmp (uvp)->tv_sec || \
+ (tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec)
+#define timerclear(tvp) (tvp)->tv_sec = (tvp)->tv_usec = 0
+
+/*
+ * Names of the interval timers, and structure
+ * defining a timer setting.
+ */
+#define ITIMER_REAL 0
+#define ITIMER_VIRTUAL 1
+#define ITIMER_PROF 2
+
+struct itimerval {
+ struct timeval it_interval; /* timer interval */
+ struct timeval it_value; /* current value */
+};
+
+#ifndef KERNEL
+/*#include <time.h>*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)timeb.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Structure returned by ftime system call
+ */
+struct timeb
+{
+ time_t time;
+ unsigned short millitm;
+ short timezone;
+ short dstflag;
+};
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)times.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Structure returned by times()
+ */
+struct tms {
+ time_t tms_utime; /* user time */
+ time_t tms_stime; /* system time */
+ time_t tms_cutime; /* user time, children */
+ time_t tms_cstime; /* system time, children */
+};
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)trace.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * File system buffer tracing points; all trace <pack(dev, size), bn>
+ */
+#define TR_BREADHIT 0 /* buffer read found in cache */
+#define TR_BREADMISS 1 /* buffer read not in cache */
+#define TR_BWRITE 2 /* buffer written */
+#define TR_BREADHITRA 3 /* buffer read-ahead found in cache */
+#define TR_BREADMISSRA 4 /* buffer read-ahead not in cache */
+#define TR_XFODMISS 5 /* exe fod read */
+#define TR_XFODHIT 6 /* exe fod read */
+#define TR_BRELSE 7 /* brelse */
+#define TR_BREALLOC 8 /* expand/contract a buffer */
+
+/*
+ * Memory allocator trace points; all trace the amount of memory involved
+ */
+#define TR_MALL 10 /* memory allocated */
+
+/*
+ * Paging trace points: all are <vaddr, pid>
+ */
+#define TR_INTRANS 20 /* page intransit block */
+#define TR_EINTRANS 21 /* page intransit wait done */
+#define TR_FRECLAIM 22 /* reclaim from free list */
+#define TR_RECLAIM 23 /* reclaim from loop */
+#define TR_XSFREC 24 /* reclaim from free list instead of drum */
+#define TR_XIFREC 25 /* reclaim from free list instead of fsys */
+#define TR_WAITMEM 26 /* wait for memory in pagein */
+#define TR_EWAITMEM 27 /* end memory wait in pagein */
+#define TR_ZFOD 28 /* zfod page fault */
+#define TR_EXFOD 29 /* exec fod page fault */
+#define TR_VRFOD 30 /* vread fod page fault */
+#define TR_CACHEFOD 31 /* fod in file system cache */
+#define TR_SWAPIN 32 /* drum page fault */
+#define TR_PGINDONE 33 /* page in done */
+#define TR_SWAPIO 34 /* swap i/o request arrives */
+
+/*
+ * System call trace points.
+ */
+#define TR_VADVISE 40 /* vadvise occurred with <arg, pid> */
+
+/*
+ * Miscellaneous
+ */
+#define TR_STAMP 45 /* user said vtrace(VTR_STAMP, value); */
+
+/*
+ * This defines the size of the trace flags array.
+ */
+#define TR_NFLAGS 100 /* generous */
+
+#define TRCSIZ 4096
+
+/*
+ * Specifications of the vtrace() system call, which takes one argument.
+ */
+#define VTRACE 64+51
+
+#define VTR_DISABLE 0 /* set a trace flag to 0 */
+#define VTR_ENABLE 1 /* set a trace flag to 1 */
+#define VTR_VALUE 2 /* return value of a trace flag */
+#define VTR_UALARM 3 /* set alarm to go off (sig 16) */
+ /* in specified number of hz */
+#define VTR_STAMP 4 /* user specified stamp */
+#ifdef KERNEL
+#ifdef TRACE
+char traceflags[TR_NFLAGS];
+struct proc *traceproc;
+int tracebuf[TRCSIZ];
+unsigned tracex;
+int tracewhich;
+#define pack(a,b) ((a)<<16)|(b)
+#define trace(a,b,c) if (traceflags[a]) trace1(a,b,c)
+#else
+#define trace(a,b,b) ;
+#endif
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tty.h 7.1 (Berkeley) 6/4/86
+ */
+
+#ifdef KERNEL
+/*#include "ttychars.h"*/
+/*#include "ttydev.h"*/
+#else
+/*#include <sys/ttychars.h>*/
+/*#include <sys/ttydev.h>*/
+#endif
+
+/*
+ * A clist structure is the head of a linked list queue
+ * of characters. The characters are stored in blocks
+ * containing a link and CBSIZE (param.h) characters.
+ * The routines in tty_subr.c manipulate these structures.
+ */
+struct clist {
+ int c_cc; /* character count */
+ char *c_cf; /* pointer to first char */
+ char *c_cl; /* pointer to last char */
+};
+
+/*
+ * Per-tty structure.
+ *
+ * Should be split in two, into device and tty drivers.
+ * Glue could be masks of what to echo and circular buffer
+ * (low, high, timeout).
+ */
+struct tty {
+ union {
+ struct {
+ struct clist T_rawq;
+ struct clist T_canq;
+ } t_t;
+#define t_rawq t_nu.t_t.T_rawq /* raw characters or partial line */
+#define t_canq t_nu.t_t.T_canq /* raw characters or partial line */
+ struct {
+ struct buf *T_bufp;
+ char *T_cp;
+ int T_inbuf;
+ int T_rec;
+ } t_n;
+#define t_bufp t_nu.t_n.T_bufp /* buffer allocated to protocol */
+#define t_cp t_nu.t_n.T_cp /* pointer into the ripped off buffer */
+#define t_inbuf t_nu.t_n.T_inbuf /* number chars in the buffer */
+#define t_rec t_nu.t_n.T_rec /* have a complete record */
+ } t_nu;
+ struct clist t_outq; /* device */
+/* int (*t_oproc)();*/ /* device */
+ struct proc *t_rsel; /* tty */
+ struct proc *t_wsel;
+ caddr_t T_LINEP; /* ### */
+ caddr_t t_addr; /* ??? */
+ dev_t t_dev; /* device */
+ int t_flags; /* some of both */
+ int t_state; /* some of both */
+ short t_pgrp; /* tty */
+ char t_delct; /* tty */
+ char t_line; /* glue */
+ char t_col; /* tty */
+ char t_ispeed, t_ospeed; /* device */
+ char t_rocount, t_rocol; /* tty */
+ struct ttychars t_chars; /* tty */
+ struct winsize t_winsize; /* window size */
+/* be careful of tchars & co. */
+#define t_erase t_chars.tc_erase
+#define t_kill t_chars.tc_kill
+#define t_intrc t_chars.tc_intrc
+#define t_quitc t_chars.tc_quitc
+#define t_startc t_chars.tc_startc
+#define t_stopc t_chars.tc_stopc
+#define t_eofc t_chars.tc_eofc
+#define t_brkc t_chars.tc_brkc
+#define t_suspc t_chars.tc_suspc
+#define t_dsuspc t_chars.tc_dsuspc
+#define t_rprntc t_chars.tc_rprntc
+#define t_flushc t_chars.tc_flushc
+#define t_werasc t_chars.tc_werasc
+#define t_lnextc t_chars.tc_lnextc
+};
+
+#define TTIPRI 28
+#define TTOPRI 29
+
+/* limits */
+#define NSPEEDS 16
+#define TTMASK 15
+#define OBUFSIZ 100
+#define TTYHOG 255
+#ifdef KERNEL
+short tthiwat[NSPEEDS], ttlowat[NSPEEDS];
+#define TTHIWAT(tp) tthiwat[(tp)->t_ospeed&TTMASK]
+#define TTLOWAT(tp) ttlowat[(tp)->t_ospeed&TTMASK]
+extern struct ttychars ttydefaults;
+#endif
+
+/* internal state bits */
+#define TS_TIMEOUT 0x000001 /* delay timeout in progress */
+#define TS_WOPEN 0x000002 /* waiting for open to complete */
+#define TS_ISOPEN 0x000004 /* device is open */
+#define TS_FLUSH 0x000008 /* outq has been flushed during DMA */
+#define TS_CARR_ON 0x000010 /* software copy of carrier-present */
+#define TS_BUSY 0x000020 /* output in progress */
+#define TS_ASLEEP 0x000040 /* wakeup when output done */
+#define TS_XCLUDE 0x000080 /* exclusive-use flag against open */
+#define TS_TTSTOP 0x000100 /* output stopped by ctl-s */
+#define TS_HUPCLS 0x000200 /* hang up upon last close */
+#define TS_TBLOCK 0x000400 /* tandem queue blocked */
+#define TS_RCOLL 0x000800 /* collision in read select */
+#define TS_WCOLL 0x001000 /* collision in write select */
+#define TS_NBIO 0x002000 /* tty in non-blocking mode */
+#define TS_ASYNC 0x004000 /* tty in async i/o mode */
+/* state for intra-line fancy editing work */
+#define TS_BKSL 0x010000 /* state for lowercase \ work */
+#define TS_QUOT 0x020000 /* last character input was \ */
+#define TS_ERASE 0x040000 /* within a \.../ for PRTRUB */
+#define TS_LNCH 0x080000 /* next character is literal */
+#define TS_TYPEN 0x100000 /* retyping suspended input (PENDIN) */
+#define TS_CNTTB 0x200000 /* counting tab width; leave FLUSHO alone */
+
+#define TS_LOCAL (TS_BKSL|TS_QUOT|TS_ERASE|TS_LNCH|TS_TYPEN|TS_CNTTB)
+
+/* define partab character types */
+#define ORDINARY 0
+#define CONTROL 1
+#define BACKSPACE 2
+#define NEWLINE 3
+#define TAB 4
+#define VTAB 5
+#define RETURN 6
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ttychars.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * User visible structures and constants
+ * related to terminal handling.
+ */
+/*#ifndef _TTYCHARS_*/
+/*#define _TTYCHARS_*/
+struct ttychars {
+ char tc_erase; /* erase last character */
+ char tc_kill; /* erase entire line */
+ char tc_intrc; /* interrupt */
+ char tc_quitc; /* quit */
+ char tc_startc; /* start output */
+ char tc_stopc; /* stop output */
+ char tc_eofc; /* end-of-file */
+ char tc_brkc; /* input delimiter (like nl) */
+ char tc_suspc; /* stop process signal */
+ char tc_dsuspc; /* delayed stop process signal */
+ char tc_rprntc; /* reprint line */
+ char tc_flushc; /* flush output (toggles) */
+ char tc_werasc; /* word erase */
+ char tc_lnextc; /* literal next character */
+};
+
+#define CTRL(c) ('c'&037)
+
+/* default special characters */
+#define CERASE 0177
+#define CKILL CTRL(u)
+#define CINTR CTRL(c)
+#define CQUIT 034 /* FS, ^\ */
+#define CSTART CTRL(q)
+#define CSTOP CTRL(s)
+#define CEOF CTRL(d)
+#define CEOT CEOF
+#define CBRK 0377
+#define CSUSP CTRL(z)
+#define CDSUSP CTRL(y)
+#define CRPRNT CTRL(r)
+#define CFLUSH CTRL(o)
+#define CWERASE CTRL(w)
+#define CLNEXT CTRL(v)
+/*#endif*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ttydev.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Terminal definitions related to underlying hardware.
+ */
+/*#ifndef _TTYDEV_*/
+/*#define _TTYDEV_*/
+
+/*
+ * Speeds
+ */
+#define B0 0
+#define B50 1
+#define B75 2
+#define B110 3
+#define B134 4
+#define B150 5
+#define B200 6
+#define B300 7
+#define B600 8
+#define B1200 9
+#define B1800 10
+#define B2400 11
+#define B4800 12
+#define B9600 13
+#define EXTA 14
+#define EXTB 15
+
+#ifdef KERNEL
+/*
+ * Hardware bits.
+ * SHOULD NOT BE HERE.
+ */
+#define DONE 0200
+#define IENABLE 0100
+
+/*
+ * Modem control commands.
+ */
+#define DMSET 0
+#define DMBIS 1
+#define DMBIC 2
+#define DMGET 3
+#endif
+/*#endif*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)types.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*#ifndef _TYPES_*/
+/*#define _TYPES_*/
+/*
+ * Basic system types and major/minor device constructing/busting macros.
+ */
+
+/* major part of a device */
+#define major(x) ((int)(((unsigned)(x)>>8)&0377))
+
+/* minor part of a device */
+#define minor(x) ((int)((x)&0377))
+
+/* make a device number */
+#define makedev(x,y) ((dev_t)(((x)<<8) | (y)))
+
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned int u_int;
+typedef unsigned long u_long;
+typedef unsigned short ushort; /* sys III compat */
+
+#ifdef vax
+typedef struct _physadr { int r[1]; } *physadr;
+typedef struct label_t {
+ int val[14];
+} label_t;
+#endif
+typedef struct _quad { long val[2]; } quad;
+typedef long daddr_t;
+typedef char * caddr_t;
+typedef u_long ino_t;
+typedef long swblk_t;
+typedef long size_t;
+typedef long time_t;
+typedef short dev_t;
+typedef long off_t;
+typedef u_short uid_t;
+typedef u_short gid_t;
+
+#define NBBY 8 /* number of bits in a byte */
+/*
+ * Select uses bit masks of file descriptors in longs.
+ * These macros manipulate such bit fields (the filesystem macros use chars).
+ * FD_SETSIZE may be defined by the user, but the default here
+ * should be >= NOFILE (param.h).
+ */
+#ifndef FD_SETSIZE
+#define FD_SETSIZE 256
+#endif
+
+typedef long fd_mask;
+#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */
+#ifndef howmany
+#define howmany(x, y) (((x)+((y)-1))/(y))
+#endif
+
+typedef struct fd_set {
+ fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)];
+} fd_set;
+
+#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*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)uio.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*#ifndef _UIO_*/
+/*#define _UIO_*/
+
+struct iovec {
+ caddr_t iov_base;
+ int iov_len;
+};
+
+struct uio {
+ struct iovec *uio_iov;
+ int uio_iovcnt;
+ off_t uio_offset;
+ int uio_segflg;
+ int uio_resid;
+};
+
+enum uio_rw { UIO_READ, UIO_WRITE };
+
+/*
+ * Segment flag values (should be enum).
+ */
+#define UIO_USERSPACE 0 /* from user data space */
+#define UIO_SYSSPACE 1 /* from system space */
+#define UIO_USERISPACE 2 /* from user I space */
+/*#endif*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)un.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Definitions for UNIX IPC domain.
+ */
+struct sockaddr_un {
+ short sun_family; /* AF_UNIX */
+ char sun_path[108]; /* path name (gag) */
+};
+
+#ifdef KERNEL
+/*int unp_discard();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)unpcb.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Protocol control block for an active
+ * instance of a UNIX internal protocol.
+ *
+ * A socket may be associated with an inode in the
+ * file system. If so, the unp_inode pointer holds
+ * a reference count to this inode, which should be irele'd
+ * when the socket goes away.
+ *
+ * A socket may be connected to another socket, in which
+ * case the control block of the socket to which it is connected
+ * is given by unp_conn.
+ *
+ * A socket may be referenced by a number of sockets (e.g. several
+ * sockets may be connected to a datagram socket.) These sockets
+ * are in a linked list starting with unp_refs, linked through
+ * unp_nextref and null-terminated. Note that a socket may be referenced
+ * by a number of other sockets and may also reference a socket (not
+ * necessarily one which is referencing it). This generates
+ * the need for unp_refs and unp_nextref to be separate fields.
+ *
+ * Stream sockets keep copies of receive sockbuf sb_cc and sb_mbcnt
+ * so that changes in the sockbuf may be computed to modify
+ * back pressure on the sender accordingly.
+ */
+struct unpcb {
+ struct socket *unp_socket; /* pointer back to socket */
+ struct inode *unp_inode; /* if associated with file */
+ ino_t unp_ino; /* fake inode number */
+ struct unpcb *unp_conn; /* control block of connected socket */
+ struct unpcb *unp_refs; /* referencing socket linked list */
+ struct unpcb *unp_nextref; /* link in unp_refs list */
+ struct mbuf *unp_addr; /* bound address of socket */
+ int unp_cc; /* copy of rcv.sb_cc */
+ int unp_mbcnt; /* copy of rcv.sb_mbcnt */
+};
+
+#define sotounpcb(so) ((struct unpcb *)((so)->so_pcb))
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)user.h 7.1 (Berkeley) 6/4/86
+ */
+
+#ifdef KERNEL
+/*#include "../machine/pcb.h"*/
+/*#include "dmap.h"*/
+/*#include "time.h"*/
+/*#include "resource.h"*/
+/*#include "namei.h"*/
+#else
+/*#include <machine/pcb.h>*/
+/*#include <sys/dmap.h>*/
+/*#include <sys/time.h>*/
+/*#include <sys/resource.h>*/
+/*#include <sys/namei.h>*/
+#endif
+
+/*
+ * Per process structure containing data that
+ * isn't needed in core when the process is swapped out.
+ */
+
+#define MAXCOMLEN 16 /* <= MAXNAMLEN, >= sizeof(ac_comm) */
+
+struct user {
+ struct pcb u_pcb;
+ struct proc *u_procp; /* pointer to proc structure */
+ int *u_ar0; /* address of users saved R0 */
+ char u_comm[MAXCOMLEN + 1];
+
+/* syscall parameters, results and catches */
+ int u_arg[8]; /* arguments to current system call */
+ int *u_ap; /* pointer to arglist */
+ label_t u_qsave; /* for non-local gotos on interrupts */
+ union { /* syscall return values */
+ struct {
+ int R_val1;
+ int R_val2;
+ } u_rv;
+#define r_val1 u_rv.R_val1
+#define r_val2 u_rv.R_val2
+ off_t r_off;
+ time_t r_time;
+ } u_r;
+ char u_error; /* return error code */
+ char u_eosys; /* special action on end of syscall */
+
+/* 1.1 - processes and protection */
+ uid_t u_uid; /* effective user id */
+ uid_t u_ruid; /* real user id */
+ gid_t u_gid; /* effective group id */
+ gid_t u_rgid; /* real group id */
+ gid_t u_groups[NGROUPS]; /* groups, 0 terminated */
+
+/* 1.2 - memory management */
+ size_t u_tsize; /* text size (clicks) */
+ size_t u_dsize; /* data size (clicks) */
+ size_t u_ssize; /* stack size (clicks) */
+ struct dmap u_dmap; /* disk map for data segment */
+ struct dmap u_smap; /* disk map for stack segment */
+ struct dmap u_cdmap, u_csmap; /* shadows of u_dmap, u_smap, for
+ use of parent during fork */
+ label_t u_ssave; /* label variable for swapping */
+ size_t u_odsize, u_ossize; /* for (clumsy) expansion swaps */
+ time_t u_outime; /* user time at last sample */
+
+/* 1.3 - signal management */
+/* int (*u_signal[NSIG])();*/ /* disposition of signals */
+ int u_sigmask[NSIG]; /* signals to be blocked */
+ int u_sigonstack; /* signals to take on sigstack */
+ int u_sigintr; /* signals that interrupt syscalls */
+ int u_oldmask; /* saved mask from before sigpause */
+ int u_code; /* ``code'' to trap */
+ struct sigstack u_sigstack; /* sp & on stack state variable */
+#define u_onstack u_sigstack.ss_onstack
+#define u_sigsp u_sigstack.ss_sp
+
+/* 1.4 - descriptor management */
+ struct file *u_ofile[NOFILE]; /* file structures for open files */
+ char u_pofile[NOFILE]; /* per-process flags of open files */
+ int u_lastfile; /* high-water mark of u_ofile */
+#define UF_EXCLOSE 0x1 /* auto-close on exec */
+#define UF_MAPPED 0x2 /* mapped from device */
+ struct inode *u_cdir; /* current directory */
+ struct inode *u_rdir; /* root directory of current process */
+ struct tty *u_ttyp; /* controlling tty pointer */
+ dev_t u_ttyd; /* controlling tty dev */
+ short u_cmask; /* mask for file creation */
+
+/* 1.5 - timing and statistics */
+ struct rusage u_ru; /* stats for this proc */
+ struct rusage u_cru; /* sum of stats for reaped children */
+ struct itimerval u_timer[3];
+ int u_XXX[3];
+ struct timeval u_start;
+ short u_acflag;
+
+ struct uprof { /* profile arguments */
+ short *pr_base; /* buffer base */
+ unsigned pr_size; /* buffer size */
+ unsigned pr_off; /* pc offset */
+ unsigned pr_scale; /* pc scaling */
+ } u_prof;
+
+/* 1.6 - resource controls */
+ struct rlimit u_rlimit[RLIM_NLIMITS];
+ struct quota *u_quota; /* user's quota structure */
+ int u_qflags; /* per process quota flags */
+
+/* namei & co. */
+ struct nameicache { /* last successful directory search */
+ int nc_prevoffset; /* offset at which last entry found */
+ ino_t nc_inumber; /* inum of cached directory */
+ dev_t nc_dev; /* dev of cached directory */
+ time_t nc_time; /* time stamp for cache entry */
+ } u_ncache;
+ struct nameidata u_nd;
+
+ int u_stack[1];
+};
+
+/* u_eosys values */
+#define JUSTRETURN 1
+#define RESTARTSYS 2
+#define NORMALRETURN 3
+
+/* u_error codes */
+#ifdef KERNEL
+/*#include "errno.h"*/
+#else
+/*#include <errno.h>*/
+#endif
+
+#ifdef KERNEL
+extern struct user u;
+extern struct user swaputl;
+extern struct user forkutl;
+extern struct user xswaputl;
+extern struct user xswap2utl;
+extern struct user pushutl;
+extern struct user vfutl;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)vadvise.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Parameters to vadvise() to tell system of particular paging
+ * behaviour:
+ * VA_NORM Normal strategy
+ * VA_ANOM Sampling page behaviour is not a win, don't bother
+ * Suitable during GCs in LISP, or sequential or random
+ * page referencing.
+ * VA_SEQL Sequential behaviour expected.
+ * VA_FLUSH Invalidate all page table entries.
+ */
+#define VA_NORM 0
+#define VA_ANOM 1
+#define VA_SEQL 2
+#define VA_FLUSH 3
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)vcmd.h 7.1 (Berkeley) 6/4/86
+ */
+
+#ifndef _IOCTL_
+#ifdef KERNEL
+/*#include "ioctl.h"*/
+#else
+/*#include <sys/ioctl.h>*/
+#endif
+#endif
+
+#define VPRINT 0100
+#define VPLOT 0200
+#define VPRINTPLOT 0400
+
+#define VGETSTATE _IOR(v, 0, int)
+#define VSETSTATE _IOW(v, 1, int)
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)vlimit.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Limits for u.u_limit[i], per process, inherited.
+ */
+#define LIM_NORAISE 0 /* if <> 0, can't raise limits */
+#define LIM_CPU 1 /* max secs cpu time */
+#define LIM_FSIZE 2 /* max size of file created */
+#define LIM_DATA 3 /* max growth of data space */
+#define LIM_STACK 4 /* max growth of stack */
+#define LIM_CORE 5 /* max size of ``core'' file */
+#define LIM_MAXRSS 6 /* max desired data+stack core usage */
+
+#define NLIMITS 6
+
+#define INFINITY 0x7fffffff
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)vm.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * #include "../h/vm.h"
+ * or #include <vm.h> in a user program
+ * is a quick way to include all the vm header files.
+ */
+#ifdef KERNEL
+/*#include "vmparam.h"*/
+/*#include "vmmac.h"*/
+/*#include "vmmeter.h"*/
+/*#include "vmsystm.h"*/
+#else
+/*#include <sys/vmparam.h>*/
+/*#include <sys/vmmac.h>*/
+/*#include <sys/vmmeter.h>*/
+/*#include <sys/vmsystm.h>*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)vmmac.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Virtual memory related conversion macros
+ */
+
+/* Core clicks to number of pages of page tables needed to map that much */
+#define ctopt(x) (((x)+NPTEPG-1)/NPTEPG)
+
+#ifdef vax
+/* Virtual page numbers to text|data|stack segment page numbers and back */
+#define vtotp(p, v) ((int)(v))
+#define vtodp(p, v) ((int)((v) - stoc(ctos((p)->p_tsize))))
+#define vtosp(p, v) ((int)(BTOPUSRSTACK - 1 - (v)))
+#define tptov(p, i) ((unsigned)(i))
+#define dptov(p, i) ((unsigned)(stoc(ctos((p)->p_tsize)) + (i)))
+#define sptov(p, i) ((unsigned)(BTOPUSRSTACK - 1 - (i)))
+
+/* Tell whether virtual page numbers are in text|data|stack segment */
+#define isassv(p, v) ((v) >= BTOPUSRSTACK - (p)->p_ssize)
+#define isatsv(p, v) ((v) < (p)->p_tsize)
+#define isadsv(p, v) ((v) >= stoc(ctos((p)->p_tsize)) && \
+ (v) < (p)->p_tsize + (p)->p_dsize)
+#else
+/* Virtual page numbers to text|data|stack segment page numbers and back */
+#define vtotp(p, v) ((int)(v)-LOWPAGES)
+#define vtodp(p, v) ((int)((v) - stoc(ctos((p)->p_tsize)) - LOWPAGES))
+#define vtosp(p, v) ((int)(BTOPUSRSTACK - 1 - (v)))
+#define tptov(p, i) ((unsigned)(i) + LOWPAGES)
+#define dptov(p, i) ((unsigned)(stoc(ctos((p)->p_tsize)) + (i) + LOWPAGES))
+#define sptov(p, i) ((unsigned)(BTOPUSRSTACK - 1 - (i)))
+
+/* Tell whether virtual page numbers are in text|data|stack segment */
+#define isassv(p, v) ((v) >= BTOPUSRSTACK - (p)->p_ssize)
+#define isatsv(p, v) (((v) - LOWPAGES) < (p)->p_tsize)
+#define isadsv(p, v) (((v) - LOWPAGES) >= stoc(ctos((p)->p_tsize)) && \
+ !isassv(p, v))
+#endif
+
+/* Tell whether pte's are text|data|stack */
+#define isaspte(p, pte) ((pte) > sptopte(p, (p)->p_ssize))
+#define isatpte(p, pte) ((pte) < dptopte(p, 0))
+#define isadpte(p, pte) (!isaspte(p, pte) && !isatpte(p, pte))
+
+/* Text|data|stack pte's to segment page numbers and back */
+#define ptetotp(p, pte) ((pte) - (p)->p_p0br)
+#define ptetodp(p, pte) (((pte) - (p)->p_p0br) - (p)->p_tsize)
+#define ptetosp(p, pte) (((p)->p_addr - (pte)) - 1)
+
+#define tptopte(p, i) ((p)->p_p0br + (i))
+#define dptopte(p, i) ((p)->p_p0br + ((p)->p_tsize + (i)))
+#define sptopte(p, i) ((p)->p_addr - (1 + (i)))
+
+/* Convert a virtual page number to a pte address. */
+#define vtopte(p, v) \
+ (((v) < (p)->p_tsize + (p)->p_dsize) ? ((p)->p_p0br + (v)) : \
+ ((p)->p_addr - (BTOPUSRSTACK - (v))))
+#ifdef notdef
+/*struct pte *vtopte();*/
+#endif
+
+/* Bytes to pages without rounding, and back */
+#define btop(x) (((unsigned)(x)) >> PGSHIFT)
+#define ptob(x) ((caddr_t)((x) << PGSHIFT))
+
+/* Turn virtual addresses into kernel map indices */
+#define kmxtob(a) (usrpt + (a) * NPTEPG)
+#define btokmx(b) (((b) - usrpt) / NPTEPG)
+
+/* User area address and pcb bases */
+#define uaddr(p) (&((p)->p_p0br[(p)->p_szpt * NPTEPG - UPAGES]))
+#ifdef vax
+#define pcbb(p) ((p)->p_addr[0].pg_pfnum)
+#endif
+
+/* Average new into old with aging factor time */
+#define ave(smooth, cnt, time) \
+ smooth = ((time - 1) * (smooth) + (cnt)) / (time)
+
+/* Abstract machine dependent operations */
+#ifdef vax
+#define setp0br(x) (u.u_pcb.pcb_p0br = (x), mtpr(P0BR, x))
+#define setp0lr(x) (u.u_pcb.pcb_p0lr = \
+ (x) | (u.u_pcb.pcb_p0lr & AST_CLR), \
+ mtpr(P0LR, x))
+#define setp1br(x) (u.u_pcb.pcb_p1br = (x), mtpr(P1BR, x))
+#define setp1lr(x) (u.u_pcb.pcb_p1lr = (x), mtpr(P1LR, x))
+#define initp1br(x) ((x) - P1PAGES)
+#endif
+
+#define outofmem() wakeup((caddr_t)&proc[2]);
+
+/*
+ * Page clustering macros.
+ *
+ * dirtycl(pte) is the page cluster dirty?
+ * anycl(pte,fld) does any pte in the cluster has fld set?
+ * zapcl(pte,fld) = val set all fields fld in the cluster to val
+ * distcl(pte) distribute high bits to cluster; note that
+ * distcl copies everything but pg_pfnum,
+ * INCLUDING pg_m!!!
+ *
+ * In all cases, pte must be the low pte in the cluster, even if
+ * the segment grows backwards (e.g. the stack).
+ */
+#define H(pte) ((struct hpte *)(pte))
+
+#if CLSIZE==1
+#define dirtycl(pte) dirty(pte)
+#define anycl(pte,fld) ((pte)->fld)
+#define zapcl(pte,fld) (pte)->fld
+#define distcl(pte)
+#endif
+
+#if CLSIZE==2
+#define dirtycl(pte) (dirty(pte) || dirty((pte)+1))
+#define anycl(pte,fld) ((pte)->fld || (((pte)+1)->fld))
+#define zapcl(pte,fld) (pte)[1].fld = (pte)[0].fld
+#endif
+
+#if CLSIZE==4
+#define dirtycl(pte) \
+ (dirty(pte) || dirty((pte)+1) || dirty((pte)+2) || dirty((pte)+3))
+#define anycl(pte,fld) \
+ ((pte)->fld || (((pte)+1)->fld) || (((pte)+2)->fld) || (((pte)+3)->fld))
+#define zapcl(pte,fld) \
+ (pte)[3].fld = (pte)[2].fld = (pte)[1].fld = (pte)[0].fld
+#endif
+
+#ifndef distcl
+#define distcl(pte) zapcl(H(pte),pg_high)
+#endif
+
+/*
+ * Lock a page frame.
+ */
+#define MLOCK(c) { \
+ while ((c)->c_lock) { \
+ (c)->c_want = 1; \
+ sleep((caddr_t)(c), PSWP+1); \
+ } \
+ (c)->c_lock = 1; \
+}
+/*
+ * Unlock a page frame.
+ */
+#define MUNLOCK(c) { \
+ if (c->c_want) { \
+ wakeup((caddr_t)c); \
+ c->c_want = 0; \
+ } \
+ c->c_lock = 0; \
+}
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)vmmeter.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Virtual memory related instrumentation
+ */
+struct vmmeter
+{
+#define v_first v_swtch
+ unsigned v_swtch; /* context switches */
+ unsigned v_trap; /* calls to trap */
+ unsigned v_syscall; /* calls to syscall() */
+ unsigned v_intr; /* device interrupts */
+ unsigned v_soft; /* software interrupts */
+ unsigned v_pdma; /* pseudo-dma interrupts */
+ unsigned v_pswpin; /* pages swapped in */
+ unsigned v_pswpout; /* pages swapped out */
+ unsigned v_pgin; /* pageins */
+ unsigned v_pgout; /* pageouts */
+ unsigned v_pgpgin; /* pages paged in */
+ unsigned v_pgpgout; /* pages paged out */
+ unsigned v_intrans; /* intransit blocking page faults */
+ unsigned v_pgrec; /* total page reclaims */
+ unsigned v_xsfrec; /* found in free list rather than on swapdev */
+ unsigned v_xifrec; /* found in free list rather than in filsys */
+ unsigned v_exfod; /* pages filled on demand from executables */
+ unsigned v_zfod; /* pages zero filled on demand */
+ unsigned v_vrfod; /* fills of pages mapped by vread() */
+ unsigned v_nexfod; /* number of exfod's created */
+ unsigned v_nzfod; /* number of zfod's created */
+ unsigned v_nvrfod; /* number of vrfod's created */
+ unsigned v_pgfrec; /* page reclaims from free list */
+ unsigned v_faults; /* total faults taken */
+ unsigned v_scan; /* scans in page out daemon */
+ unsigned v_rev; /* revolutions of the hand */
+ unsigned v_seqfree; /* pages taken from sequential programs */
+ unsigned v_dfree; /* pages freed by daemon */
+ unsigned v_fastpgrec; /* fast reclaims in locore */
+#define v_last v_fastpgrec
+ unsigned v_swpin; /* swapins */
+ unsigned v_swpout; /* swapouts */
+};
+#ifdef KERNEL
+struct vmmeter cnt, rate, sum;
+#endif
+
+/* systemwide totals computed every five seconds */
+struct vmtotal
+{
+ short t_rq; /* length of the run queue */
+ short t_dw; /* jobs in ``disk wait'' (neg priority) */
+ short t_pw; /* jobs in page wait */
+ short t_sl; /* jobs sleeping in core */
+ short t_sw; /* swapped out runnable/short block jobs */
+ long t_vm; /* total virtual memory */
+ long t_avm; /* active virtual memory */
+ long t_rm; /* total real memory in use */
+ long t_arm; /* active real memory */
+ long t_vmtxt; /* virtual memory used by text */
+ long t_avmtxt; /* active virtual memory used by text */
+ long t_rmtxt; /* real memory used by text */
+ long t_armtxt; /* active real memory used by text */
+ long t_free; /* free memory pages */
+};
+#ifdef KERNEL
+struct vmtotal total;
+#endif
+
+/*
+ * Optional instrumentation.
+ */
+#ifdef PGINPROF
+
+#define NDMON 128
+#define NSMON 128
+
+#define DRES 20
+#define SRES 5
+
+#define PMONMIN 20
+#define PRES 50
+#define NPMON 64
+
+#define RMONMIN 130
+#define RRES 5
+#define NRMON 64
+
+/* data and stack size distribution counters */
+unsigned int dmon[NDMON+1];
+unsigned int smon[NSMON+1];
+
+/* page in time distribution counters */
+unsigned int pmon[NPMON+2];
+
+/* reclaim time distribution counters */
+unsigned int rmon[NRMON+2];
+
+int pmonmin;
+int pres;
+int rmonmin;
+int rres;
+
+unsigned rectime; /* accumulator for reclaim times */
+unsigned pgintime; /* accumulator for page in times */
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)vmparam.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Machine dependent constants
+ */
+#ifdef KERNEL
+/*#include "../machine/vmparam.h"*/
+#else
+/*#include <machine/vmparam.h>*/
+#endif
+
+#if defined(KERNEL) && !defined(LOCORE)
+int klseql;
+int klsdist;
+int klin;
+int kltxt;
+int klout;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)vmsystm.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Miscellaneous virtual memory subsystem variables and structures.
+ */
+
+#ifdef KERNEL
+int freemem; /* remaining blocks of free memory */
+int avefree; /* moving average of remaining free blocks */
+int avefree30; /* 30 sec (avefree is 5 sec) moving average */
+int deficit; /* estimate of needs of new swapped in procs */
+int nscan; /* number of scans in last second */
+int multprog; /* current multiprogramming degree */
+int desscan; /* desired pages scanned per second */
+
+/* writable copies of tunables */
+int maxpgio; /* max paging i/o per sec before start swaps */
+int maxslp; /* max sleep time before very swappable */
+int lotsfree; /* max free before clock freezes */
+int minfree; /* minimum free pages before swapping begins */
+int desfree; /* no of pages to try to keep free via daemon */
+int saferss; /* no pages not to steal; decays with slptime */
+int slowscan; /* slowest scan rate, clusters/second */
+int fastscan; /* fastest scan rate, clusters/second */
+#endif
+
+/*
+ * Fork/vfork accounting.
+ */
+struct forkstat
+{
+ int cntfork;
+ int cntvfork;
+ int sizfork;
+ int sizvfork;
+};
+#ifdef KERNEL
+struct forkstat forkstat;
+#endif
+
+/*
+ * Swap kind accounting.
+ */
+struct swptstat
+{
+ int pteasy; /* easy pt swaps */
+ int ptexpand; /* pt expansion swaps */
+ int ptshrink; /* pt shrinking swaps */
+ int ptpack; /* pt swaps involving spte copying */
+};
+#ifdef KERNEL
+struct swptstat swptstat;
+#endif
--- /dev/null
+/* @(#)vsio.h 7.1 (MIT) 6/4/86 */
+ /****************************************************************************
+ * *
+ * Copyright (c) 1983, 1984 by *
+ * DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts. *
+ * All rights reserved. *
+ * *
+ * This software is furnished on an as-is basis and may be used and copied *
+ * only with inclusion of the above copyright notice. This software or any *
+ * other copies thereof may be provided or otherwise made available to *
+ * others only for non-commercial purposes. No title to or ownership of *
+ * the software is hereby transferred. *
+ * *
+ * The information in this software is subject to change without notice *
+ * and should not be construed as a commitment by DIGITAL EQUIPMENT *
+ * CORPORATION. *
+ * *
+ * DIGITAL assumes no responsibility for the use or reliability of its *
+ * software on equipment which is not supplied by DIGITAL. *
+ * *
+ * *
+ ****************************************************************************/
+/*
+ * vsio.h - VS100 I/O command definitions
+ *
+ * Author: Christopher A. Kent
+ * Digital Equipment Corporation
+ * Western Research Lab
+ * Date: Tue Jun 21 1983
+ */
+
+/*
+ * Possible ioctl calls
+ */
+
+#define VSIOINIT _IO(V, 0) /* init the device */
+#define VSIOSTART _IOW(V, 1, int) /* start microcode */
+#define VSIOABORT _IO(V, 2) /* abort a command chain */
+#define VSIOPWRUP _IO(V, 3) /* power-up reset */
+#define VSIOGETVER _IOR(V, 4, int) /* get rom version */
+#define VSIOSYNC _IO(V, 6) /* synch with device */
+#define VSIOBBACTL _IOW(V, 8, int) /* control the BBA */
+#define VSIOFIBCTL _IOW(V, 9, int) /* lamp on/off */
+#define VSIOFIBRETRY _IOW(V,10, int) /* fiber retries */
+#define VSIOGETSTATS _IOR(V,11, vsStats) /* get statistics */
+#define VSIOGETIOA _IOR(V,13, vsIoAddrAddr)/* get ioreg address */
+#define VSIOUSERWAIT _IO(V, 15) /* wait for user I/O completion */
+#define VSIOWAITGO _IOW(V, 16, caddr_t) /* wait then go */
+
+
+#define VSIO_OFF 0 /* option off */
+#define VSIO_ON 1 /* option on */
+
+#define VS_FIB_FINITE 1 /* finite retries */
+#define VS_FIB_INFINITE 2 /* infinite retries */
+
+/*
+ * Event queue entries
+ */
+
+typedef struct _vs_event{
+ u_short vse_x; /* x position */
+ u_short vse_y; /* y position */
+ u_short vse_time; /* 10 millisecond units (button only) */
+ char vse_type; /* button or motion? */
+ u_char vse_key; /* the key (button only) */
+ char vse_direction; /* which direction (button only) */
+ char vse_device; /* which device (button only) */
+}vsEvent;
+
+#define VSE_BUTTON 0 /* button moved */
+#define VSE_MMOTION 1 /* mouse moved */
+#define VSE_TMOTION 2 /* tablet moved */
+
+#define VSE_KBTUP 0 /* up */
+#define VSE_KBTDOWN 1 /* down */
+
+#define VSE_MOUSE 1 /* mouse */
+#define VSE_DKB 2 /* main keyboard */
+#define VSE_TABLET 3 /* graphics tablet */
+#define VSE_AUX 4 /* auxiliary */
+#define VSE_CONSOLE 5 /* console */
+
+typedef struct _vsStats{
+ int errors; /* count errors */
+ int unsolIntr; /* count unsolicited interrupts */
+ int overruns; /* event queue overruns */
+ int flashes; /* flashes on fiber link */
+ int ignites; /* times turned on */
+ int douses; /* times turned off */
+ int linkErrors; /* link errors */
+}vsStats;
+
+typedef struct _vs_cursor{
+ short x;
+ short y;
+}vsCursor;
+
+typedef struct _vs_box {
+ short bottom;
+ short right;
+ short left;
+ short top;
+}vsBox;
+
+typedef struct _vsIoAddr {
+ short *ioreg;
+ short status;
+ caddr_t obuff;
+ int obufflen;
+ int reloc;
+ vsEvent *ibuff;
+ int iqsize; /* may assume power of 2 */
+ int ihead; /* atomic write */
+ int itail; /* atomic read */
+ vsCursor mouse; /* atomic read/write */
+ vsBox mbox; /* atomic read/write */
+} vsIoAddr;
+typedef vsIoAddr *vsIoAddrAddr;
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)vtimes.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Structure returned by vtimes() and in vwait().
+ * In vtimes() two of these are returned, one for the process itself
+ * and one for all its children. In vwait() these are combined
+ * by adding componentwise (except for maxrss, which is max'ed).
+ */
+struct vtimes {
+ int vm_utime; /* user time (60'ths) */
+ int vm_stime; /* system time (60'ths) */
+ /* divide next two by utime+stime to get averages */
+ unsigned vm_idsrss; /* integral of d+s rss */
+ unsigned vm_ixrss; /* integral of text rss */
+ int vm_maxrss; /* maximum rss */
+ int vm_majflt; /* major page faults */
+ int vm_minflt; /* minor page faults */
+ int vm_nswap; /* number of swaps */
+ int vm_inblk; /* block reads */
+ int vm_oublk; /* block writes */
+};
+
+#ifdef KERNEL
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)wait.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * This file holds definitions relevent to the wait system call.
+ * Some of the options here are available only through the ``wait3''
+ * entry point; the old entry point with one argument has more fixed
+ * semantics, never returning status of unstopped children, hanging until
+ * a process terminates if any are outstanding, and never returns
+ * detailed information about process resource utilization (<vtimes.h>).
+ */
+
+/*
+ * Structure of the information in the first word returned by both
+ * wait and wait3. If w_stopval==WSTOPPED, then the second structure
+ * describes the information returned, else the first. See WUNTRACED below.
+ */
+union wait {
+ int w_status; /* used in syscall */
+ /*
+ * Terminated process status.
+ */
+ struct {
+ unsigned short w_Termsig:7; /* termination signal */
+ unsigned short w_Coredump:1; /* core dump indicator */
+ unsigned short w_Retcode:8; /* exit code if w_termsig==0 */
+ } w_T;
+ /*
+ * Stopped process status. Returned
+ * only for traced children unless requested
+ * with the WUNTRACED option bit.
+ */
+ struct {
+ unsigned short w_Stopval:8; /* == W_STOPPED if stopped */
+ unsigned short w_Stopsig:8; /* signal that stopped us */
+ } w_S;
+};
+#define w_termsig w_T.w_Termsig
+#define w_coredump w_T.w_Coredump
+#define w_retcode w_T.w_Retcode
+#define w_stopval w_S.w_Stopval
+#define w_stopsig w_S.w_Stopsig
+
+
+#define WSTOPPED 0177 /* value of s.stopval if process is stopped */
+
+/*
+ * Option bits for the second argument of wait3. WNOHANG causes the
+ * wait to not hang if there are no stopped or terminated processes, rather
+ * returning an error indication in this case (pid==0). WUNTRACED
+ * indicates that the caller should receive status about untraced children
+ * which stop due to signals. If children are stopped and a wait without
+ * this option is done, it is as though they were still running... nothing
+ * about them is returned.
+ */
+#define WNOHANG 1 /* dont hang in wait */
+#define WUNTRACED 2 /* tell about stopped, untraced children */
+
+#define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED)
+#define WIFSIGNALED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig != 0)
+#define WIFEXITED(x) ((x).w_stopval != WSTOPPED && (x).w_termsig == 0)
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)syscall.h 5.4 (Berkeley) 4/3/86
+ */
+
+#define SYS_exit 1
+#define SYS_fork 2
+#define SYS_read 3
+#define SYS_write 4
+#define SYS_open 5
+#define SYS_close 6
+ /* 7 is old: wait */
+#define SYS_creat 8
+#define SYS_link 9
+#define SYS_unlink 10
+#define SYS_execv 11
+#define SYS_chdir 12
+ /* 13 is old: time */
+#define SYS_mknod 14
+#define SYS_chmod 15
+#define SYS_chown 16
+ /* 17 is old: sbreak */
+ /* 18 is old: stat */
+#define SYS_lseek 19
+#define SYS_getpid 20
+#define SYS_mount 21
+#define SYS_umount 22
+ /* 23 is old: setuid */
+#define SYS_getuid 24
+ /* 25 is old: stime */
+#define SYS_ptrace 26
+ /* 27 is old: alarm */
+ /* 28 is old: fstat */
+ /* 29 is old: pause */
+ /* 30 is old: utime */
+ /* 31 is old: stty */
+ /* 32 is old: gtty */
+#define SYS_access 33
+ /* 34 is old: nice */
+ /* 35 is old: ftime */
+#define SYS_sync 36
+#define SYS_kill 37
+#define SYS_stat 38
+ /* 39 is old: setpgrp */
+#define SYS_lstat 40
+#define SYS_dup 41
+#define SYS_pipe 42
+ /* 43 is old: times */
+#define SYS_profil 44
+ /* 45 is unused */
+ /* 46 is old: setgid */
+#define SYS_getgid 47
+ /* 48 is old: sigsys */
+ /* 49 is unused */
+ /* 50 is unused */
+#define SYS_acct 51
+ /* 52 is old: phys */
+ /* 53 is old: syslock */
+#define SYS_ioctl 54
+#define SYS_reboot 55
+ /* 56 is old: mpxchan */
+#define SYS_symlink 57
+#define SYS_readlink 58
+#define SYS_execve 59
+#define SYS_umask 60
+#define SYS_chroot 61
+#define SYS_fstat 62
+ /* 63 is unused */
+#define SYS_getpagesize 64
+#define SYS_mremap 65
+ /* 66 is old: vfork */
+ /* 67 is old: vread */
+ /* 68 is old: vwrite */
+#define SYS_sbrk 69
+#define SYS_sstk 70
+#define SYS_mmap 71
+ /* 72 is old: vadvise */
+#define SYS_munmap 73
+#define SYS_mprotect 74
+#define SYS_madvise 75
+#define SYS_vhangup 76
+ /* 77 is old: vlimit */
+#define SYS_mincore 78
+#define SYS_getgroups 79
+#define SYS_setgroups 80
+#define SYS_getpgrp 81
+#define SYS_setpgrp 82
+#define SYS_setitimer 83
+#define SYS_wait 84
+#define SYS_swapon 85
+#define SYS_getitimer 86
+#define SYS_gethostname 87
+#define SYS_sethostname 88
+#define SYS_getdtablesize 89
+#define SYS_dup2 90
+#define SYS_getdopt 91
+#define SYS_fcntl 92
+#define SYS_select 93
+#define SYS_setdopt 94
+#define SYS_fsync 95
+#define SYS_setpriority 96
+#define SYS_socket 97
+#define SYS_connect 98
+#define SYS_accept 99
+#define SYS_getpriority 100
+#define SYS_send 101
+#define SYS_recv 102
+#define SYS_sigreturn 103
+#define SYS_bind 104
+#define SYS_setsockopt 105
+#define SYS_listen 106
+ /* 107 was vtimes */
+#define SYS_sigvec 108
+#define SYS_sigblock 109
+#define SYS_sigsetmask 110
+#define SYS_sigpause 111
+#define SYS_sigstack 112
+#define SYS_recvmsg 113
+#define SYS_sendmsg 114
+ /* 115 is old vtrace */
+#define SYS_gettimeofday 116
+#define SYS_getrusage 117
+#define SYS_getsockopt 118
+ /* 119 is old resuba */
+#define SYS_readv 120
+#define SYS_writev 121
+#define SYS_settimeofday 122
+#define SYS_fchown 123
+#define SYS_fchmod 124
+#define SYS_recvfrom 125
+#define SYS_setreuid 126
+#define SYS_setregid 127
+#define SYS_rename 128
+#define SYS_truncate 129
+#define SYS_ftruncate 130
+#define SYS_flock 131
+ /* 132 is unused */
+#define SYS_sendto 133
+#define SYS_shutdown 134
+#define SYS_socketpair 135
+#define SYS_mkdir 136
+#define SYS_rmdir 137
+#define SYS_utimes 138
+ /* 139 is unused */
+#define SYS_adjtime 140
+#define SYS_getpeername 141
+#define SYS_gethostid 142
+#define SYS_sethostid 143
+#define SYS_getrlimit 144
+#define SYS_setrlimit 145
+#define SYS_killpg 146
+ /* 147 is unused */
+#define SYS_setquota 148
+#define SYS_quota 149
+#define SYS_getsockname 150
--- /dev/null
+/*
+** SYSEXITS.H -- Exit status codes for system programs.
+**
+** This include file attempts to categorize possible error
+** exit statuses for system programs, notably delivermail
+** and the Berkeley network.
+**
+** Error numbers begin at EX__BASE to reduce the possibility of
+** clashing with other exit statuses that random programs may
+** already return. The meaning of the codes is approximately
+** as follows:
+**
+** EX_USAGE -- The command was used incorrectly, e.g., with
+** the wrong number of arguments, a bad flag, a bad
+** syntax in a parameter, or whatever.
+** EX_DATAERR -- The input data was incorrect in some way.
+** This should only be used for user's data & not
+** system files.
+** EX_NOINPUT -- An input file (not a system file) did not
+** exist or was not readable. This could also include
+** errors like "No message" to a mailer (if it cared
+** to catch it).
+** EX_NOUSER -- The user specified did not exist. This might
+** be used for mail addresses or remote logins.
+** EX_NOHOST -- The host specified did not exist. This is used
+** in mail addresses or network requests.
+** EX_UNAVAILABLE -- A service is unavailable. This can occur
+** if a support program or file does not exist. This
+** can also be used as a catchall message when something
+** you wanted to do doesn't work, but you don't know
+** why.
+** EX_SOFTWARE -- An internal software error has been detected.
+** This should be limited to non-operating system related
+** errors as possible.
+** EX_OSERR -- An operating system error has been detected.
+** This is intended to be used for such things as "cannot
+** fork", "cannot create pipe", or the like. It includes
+** things like getuid returning a user that does not
+** exist in the passwd file.
+** EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp,
+** etc.) does not exist, cannot be opened, or has some
+** sort of error (e.g., syntax error).
+** EX_CANTCREAT -- A (user specified) output file cannot be
+** created.
+** EX_IOERR -- An error occurred while doing I/O on some file.
+** EX_TEMPFAIL -- temporary failure, indicating something that
+** is not really an error. In sendmail, this means
+** that a mailer (e.g.) could not create a connection,
+** and the request should be reattempted later.
+** EX_PROTOCOL -- the remote system returned something that
+** was "not possible" during a protocol exchange.
+** EX_NOPERM -- You did not have sufficient permission to
+** perform the operation. This is not intended for
+** file system problems, which should use NOINPUT or
+** CANTCREAT, but rather for higher level permissions.
+** For example, kre uses this to restrict who students
+** can send mail to.
+**
+** Maintained by Eric Allman (eric@berkeley, ucbvax!eric) --
+** please mail changes to me.
+**
+** @(#)sysexits.h 4.2 7/31/83
+*/
+
+# define EX_OK 0 /* successful termination */
+
+# define EX__BASE 64 /* base value for error messages */
+
+# define EX_USAGE 64 /* command line usage error */
+# define EX_DATAERR 65 /* data format error */
+# define EX_NOINPUT 66 /* cannot open input */
+# define EX_NOUSER 67 /* addressee unknown */
+# define EX_NOHOST 68 /* host name unknown */
+# define EX_UNAVAILABLE 69 /* service unavailable */
+# define EX_SOFTWARE 70 /* internal software error */
+# define EX_OSERR 71 /* system error (e.g., can't fork) */
+# define EX_OSFILE 72 /* critical OS file missing */
+# define EX_CANTCREAT 73 /* can't create (user) output file */
+# define EX_IOERR 74 /* input/output error */
+# define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
+# define EX_PROTOCOL 76 /* remote error in protocol */
+# define EX_NOPERM 77 /* permission denied */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)syslog.h 7.1 (Berkeley) 6/4/86
+ */
+
+/*
+ * Facility codes
+ */
+
+#define LOG_KERN (0<<3) /* kernel messages */
+#define LOG_USER (1<<3) /* random user-level messages */
+#define LOG_MAIL (2<<3) /* mail system */
+#define LOG_DAEMON (3<<3) /* system daemons */
+#define LOG_AUTH (4<<3) /* security/authorization messages */
+#define LOG_SYSLOG (5<<3) /* messages generated internally by syslogd */
+#define LOG_LPR (6<<3) /* line printer subsystem */
+ /* other codes through 15 reserved for system use */
+#define LOG_LOCAL0 (16<<3) /* reserved for local use */
+#define LOG_LOCAL1 (17<<3) /* reserved for local use */
+#define LOG_LOCAL2 (18<<3) /* reserved for local use */
+#define LOG_LOCAL3 (19<<3) /* reserved for local use */
+#define LOG_LOCAL4 (20<<3) /* reserved for local use */
+#define LOG_LOCAL5 (21<<3) /* reserved for local use */
+#define LOG_LOCAL6 (22<<3) /* reserved for local use */
+#define LOG_LOCAL7 (23<<3) /* reserved for local use */
+
+#define LOG_NFACILITIES 24 /* maximum number of facilities */
+#define LOG_FACMASK 0x03f8 /* mask to extract facility part */
+
+/*
+ * Priorities (these are ordered)
+ */
+
+#define LOG_EMERG 0 /* system is unusable */
+#define LOG_ALERT 1 /* action must be taken immediately */
+#define LOG_CRIT 2 /* critical conditions */
+#define LOG_ERR 3 /* error conditions */
+#define LOG_WARNING 4 /* warning conditions */
+#define LOG_NOTICE 5 /* normal but signification condition */
+#define LOG_INFO 6 /* informational */
+#define LOG_DEBUG 7 /* debug-level messages */
+
+#define LOG_PRIMASK 0x0007 /* mask to extract priority part (internal) */
+
+/*
+ * arguments to setlogmask.
+ */
+#define LOG_MASK(pri) (1 << (pri)) /* mask for one priority */
+#define LOG_UPTO(pri) ((1 << ((pri)+1)) - 1) /* all priorities through pri */
+
+/*
+ * Option flags for openlog.
+ *
+ * LOG_ODELAY no longer does anything; LOG_NDELAY is the
+ * inverse of what it used to be.
+ */
+#define LOG_PID 0x01 /* log the pid with each message */
+#define LOG_CONS 0x02 /* log on the console if errors in sending */
+#define LOG_ODELAY 0x04 /* delay open until syslog() is called */
+#define LOG_NDELAY 0x08 /* don't delay open */
+#define LOG_NOWAIT 0x10 /* if forking to log on console, don't wait() */
--- /dev/null
+/* time.h 1.1 85/03/13 */
+
+/*
+ * Structure returned by gmtime and localtime calls (see ctime(3)).
+ */
+struct tm {
+ int tm_sec;
+ int tm_min;
+ int tm_hour;
+ int tm_mday;
+ int tm_mon;
+ int tm_year;
+ int tm_wday;
+ int tm_yday;
+ int tm_isdst;
+};
+
+/*extern struct tm *gmtime(), *localtime();*/
+/*extern char *asctime(), *ctime();*/
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ttyent.h 5.1 (Berkeley) 5/30/85
+ */
+
+struct ttyent { /* see getttyent(3) */
+ char *ty_name; /* terminal device name */
+ char *ty_getty; /* command to execute, usually getty */
+ char *ty_type; /* terminal type for termcap (3X) */
+ int ty_status; /* status flags (see below for defines) */
+ char *ty_window; /* command to start up window manager */
+ char *ty_comment; /* usually the location of the terminal */
+};
+
+#define TTY_ON 0x1 /* enable logins (startup getty) */
+#define TTY_SECURE 0x2 /* allow root to login */
+
+/*extern struct ttyent *getttyent();*/
+/*extern struct ttyent *getttynam();*/
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)utmp.h 5.1 (Berkeley) 5/30/85
+ */
+
+/*
+ * Structure of utmp and wtmp files.
+ *
+ * Assuming the number 8 is unwise.
+ */
+struct utmp {
+ char ut_line[8]; /* tty name */
+ char ut_name[8]; /* user id */
+ char ut_host[16]; /* host name, if remote */
+ long ut_time; /* time on */
+};
--- /dev/null
+/* varargs.h 4.1 83/05/03 */
+
+typedef char *va_list;
+# define va_dcl int va_alist;
+# define va_start(list) list = (char *) &va_alist
+# define va_end(list)
+# define va_arg(list,mode) ((mode *)(list += sizeof(mode)))[-1]
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)clock.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * VAX clock registers
+ */
+
+#define ICCS_RUN 0x00000001
+#define ICCS_TRANS 0x00000010
+#define ICCS_SS 0x00000020
+#define ICCS_IE 0x00000040
+#define ICCS_INT 0x00000080
+#define ICCS_ERR 0x80000000
+
+#define SECDAY ((unsigned)(24*60*60)) /* seconds per day */
+#define SECYR ((unsigned)(365*SECDAY)) /* per common year */
+/*
+ * TODRZERO is the what the TODR should contain when the ``year'' begins.
+ * The TODR should always contain a number between 0 and SECYR+SECDAY.
+ */
+#define TODRZERO ((unsigned)(1<<28))
+
+#define YRREF 1970
+#define LEAPYEAR(year) ((year)%4==0) /* good till time becomes negative */
+
+/*
+ * Has the time-of-day clock wrapped around?
+ */
+#define clkwrap() (((unsigned)mfpr(TODR) - TODRZERO)/100 > SECYR+SECDAY)
+
+/*
+ * Software clock is software interrupt level 8,
+ * implemented as mtpr(SIRR, 0x8) in asm.sed.
+ */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)cons.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * VAX console interface registers
+ */
+
+#define RXCS_IE 0x00000040 /* receiver interrupt enable */
+#define RXCS_DONE 0x00000080 /* receiver done */
+
+#define RXDB_DATA 0x000000ff /* received character */
+#define RXDB_ID 0x00000f00 /* channel id */
+#define RXDB_ERR 0x80000000 /* receiver error */
+
+#define TXCS_IE 0x00000040 /* transmitter interrupt enable */
+#define TXCS_RDY 0x00000080 /* transmitter ready for next char */
+#if VAX8600
+#define TXCS_ID 0x00000300 /* interrupt ID field */
+#define TXCS_WMASK 0x00008000 /* enable mask write */
+#define TXCS_TXMASK 0x00ff0000 /* transmit enable channel mask: */
+#define TXCS_CTERM 0x00010000 /* console terminal */
+#define TXCS_RTERM 0x00020000 /* remote diagnostic port */
+#define TXCS_EMM 0x00040000 /* Environmental Monitor Module */
+#define TXCS_LCONS 0x00080000 /* Logical console */
+#endif
+
+#define TXDB_DATA 0x000000ff /* transmitter byte */
+#define TXDB_ID 0x00000f00 /* channel id- not on 8600 */
+#define TXDB_CONS 0x00000f00 /* channel id for console subsystem */
+
+#define TXDB_DONE 0x01 /* software done */
+#define TXDB_BOOT 0x02 /* reboot */
+#define TXDB_CWSI 0x03 /* clear warm start inhibit */
+#define TXDB_CCSI 0x04 /* clear cold-start inhibit */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)cpu.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*#ifndef LOCORE*/
+/*
+ * Cpu identification, from SID register.
+ */
+union cpusid {
+ int cpusid;
+ struct cpuany {
+ u_int :24,
+ cp_type:8;
+ } cpuany;
+ struct cpu8600 {
+ u_int cp_sno:12, /* serial number */
+ cp_plant:4, /* plant number */
+ cp_eco:8, /* eco level */
+ cp_type:8; /* VAX_8600 */
+ } cpu8600;
+ struct cpu780 {
+ u_int cp_sno:12, /* serial number */
+ cp_plant:3, /* plant number */
+ cp_eco:9, /* eco level */
+ cp_type:8; /* VAX_780 */
+ } cpu780;
+ struct cpu750 {
+ u_int cp_hrev:8, /* hardware rev level */
+ cp_urev:8, /* ucode rev level */
+ :8,
+ cp_type:8; /* VAX_750 */
+ } cpu750;
+ struct cpu730 {
+ u_int :8, /* reserved */
+ cp_urev:8, /* ucode rev level */
+ :8, /* reserved */
+ cp_type:8; /* VAX_730 */
+ } cpu730;
+ struct cpu630 {
+ u_int :24, /* reserved */
+ cp_type:8; /* VAX_630 */
+ } cpu630;
+};
+#endif
+/*
+ * Vax CPU types.
+ * Similar types are grouped with their earliest example.
+ */
+#define VAX_780 1
+#define VAX_750 2
+#define VAX_730 3
+#define VAX_8600 4
+#define VAX_630 8
+
+#define VAX_MAX 8
+
+/*
+ * Main IO backplane types.
+ * This gives us a handle on how to do autoconfiguration.
+ */
+#define IO_SBI780 1
+#define IO_CMI750 2
+#define IO_XXX730 3
+#define IO_ABUS 4
+#define IO_QBUS 5
+
+#ifndef LOCORE
+/*
+ * Per-cpu information for system.
+ */
+struct percpu {
+ short pc_cputype; /* cpu type code */
+ short pc_cpuspeed; /* relative speed of cpu */
+ short pc_nioa; /* number of IO adaptors/nexus blocks */
+ struct iobus *pc_io; /* descriptions of IO adaptors */
+};
+
+struct iobus {
+ int io_type; /* io adaptor types */
+ caddr_t io_addr; /* phys address of IO adaptor */
+ int io_size; /* size of an IO space */
+ caddr_t io_details; /* specific to adaptor types */
+};
+
+/*
+ * Description of a main bus that maps "nexi", ala the 780 SBI.
+ */
+struct nexusconnect {
+ short psb_nnexus; /* number of nexus slots */
+ struct nexus *psb_nexbase; /* base of nexus space */
+/* we should be able to have just one address for the unibus memories */
+/* and calculate successive addresses by adding to the base, but the 750 */
+/* doesn't obey the sensible rule: uba1 has a lower address than uba0! */
+ caddr_t *psb_umaddr; /* unibus memory addresses */
+ short psb_nubabdp; /* number of bdp's per uba */
+ short psb_haveubasr; /* have uba status register */
+/* the 750 has some slots which don't promise to tell you their types */
+/* if this pointer is non-zero, then you get the type from this array */
+/* rather than from the (much more sensible) low byte of the config register */
+ short *psb_nextype; /* botch */
+};
+
+#ifdef KERNEL
+int cpu;
+struct percpu percpu[];
+#endif
+/*#endif*/
--- /dev/null
+/*
+ * @(#)crl.h 7.1 (Berkeley) 6/5/86
+ */
+
+/****************************************************************
+ * *
+ * Licensed from Digital Equipment Corporation *
+ * Copyright (c) *
+ * Digital Equipment Corporation *
+ * Maynard, Massachusetts *
+ * 1985, 1986 *
+ * All rights reserved. *
+ * *
+ * The Information in this software is subject to change *
+ * without notice and should not be construed as a commitment *
+ * by Digital Equipment Corporation. Digital makes no *
+ * representations about the suitability of this software for *
+ * any purpose. It is supplied "As Is" without expressed or *
+ * implied warranty. *
+ * *
+ * If the Regents of the University of California or its *
+ * licensees modify the software in a manner creating *
+ * diriviative copyright rights, appropriate copyright *
+ * legends may be placed on the drivative work in addition *
+ * to that set forth above. *
+ ****************************************************************/
+
+#if VAX8600
+/*
+ * Console RL02 status of current transfer (read only)
+ */
+#define CRL_S_XCMPLT 1 /* transaction complete */
+#define CRL_S_XCONT 2 /* continue transaction */
+#define CRL_S_ABORT 3 /* transation abort */
+#define CRL_S_RETSTS 4 /* return device status */
+#define CRL_S_HNDSHK 0x80 /* handshake err during transaction */
+#define CRL_S_HWERR 0x81 /* hardware err during transaction */
+
+/*
+ * Console RL02 function codes
+ */
+#define CRL_F_NOOP 0 /* No operation */
+#define CRL_F_RSTSTS 2 /* reset and return device status */
+#define CRL_F_ABORT 3 /* abort transfer */
+#define CRL_F_RETSTS 4 /* read device status */
+#define CRL_F_WRITE 5 /* write block data */
+#define CRL_F_READ 6 /* read block data */
+
+/*
+ * Console sectoring information.
+ * The console understands the rl02 as having 512 byte sectors.
+ */
+#define CRLBYSEC 512 /* bytes/sector */
+#define MAXSEC 20480 /* sectors/rl02 */
+
+/*
+ * STXCS bit definitions
+ */
+#define STXCS_RDY 0x00000080 /* ready bit */
+#define STXCS_IE 0x00000040 /* interrupt enable */
+
+#define CRLERRS 5 /* number of retries before quitting */
+
+/*
+ * The state byte is used to retain exclusivity,
+ * and contains the busy flag.
+ */
+#define CRL_IDLE 0
+#define CRL_OPEN 1
+#define CRL_BUSY 2
+
+
+#define CRLDS_BITS \
+"\20\20WDE\17CHE\16WL\15SKTO\14SPE\13WGE\12VC\11DSE\
+\10DT\7HS\6CO\5HO\4BH\3STC\2STB\1STA"
+
+#define CRLCS_BITS \
+"\20\20CE\17DE\16NXM\15DLT\14DCRC\13OPI\1DRDY"
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dkio.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Structures and definitions for disk io control commands
+ *
+ * THIS WHOLE AREA NEEDS MORE THOUGHT. FOR NOW JUST IMPLEMENT
+ * ENOUGH TO READ AND WRITE HEADERS ON MASSBUS DISKS. EVENTUALLY
+ * SHOULD BE ABLE TO DETERMINE DRIVE TYPE AND DO OTHER GOOD STUFF.
+ */
+
+/* disk io control commands */
+#define DKIOCHDR _IO(d, 1) /* next I/O will read/write header */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)flp.h 7.1 (Berkeley) 6/5/86
+ */
+
+#if VAX780
+/*
+ * Console floppy command/status and sectoring information.
+ */
+#define FL_FFC 0x200 /* floppy function complete */
+#define FL_ERR 0x80 /* error bit in floppy status byte */
+#define FL_PERR 0x905 /* floppy protocol error */
+#define FL_DATA 0x100 /* floppy data select code */
+#define FL_RS 0x900 /* floppy read sector command */
+#define FL_WS 0x901 /* floppy write sector command*/
+#define FL_STAT 0x902 /* floppy get status command*/
+#define FL_CANCEL 0x904 /* cancel floppy function */
+
+#define RXFTRK 77 /* tracks/floppy */
+#define RXSTRK 26 /* sectors/track */
+#define RXBYSEC 128 /* bytes/sector */
+#define MAXSEC (RXFTRK*RXSTRK) /* sectors/floppy */
+
+/*
+ * In the floppy driver routines, the device active byte is used
+ * not as a boolean, but as an indicator of the state we are in.
+ * That is, it contains what to do on the next interrupt.
+ */
+
+#define FL_IDLE 0 /* floppy idle */
+#define FL_MAND 1 /* about to send read/write command */
+#define FL_SEC 2 /* about to send sector # to LSI */
+#define FL_TRACK 3 /* about to send track # to LSI */
+#define FL_DAX 4 /* transmitting data */
+#define FL_DAR 5 /* receiving data */
+#define FL_COM 6 /* completing transmission */
+#define FL_CAN 7 /* give cancel order - we had an error,
+ and are to restart */
+
+#define FLERRS 5 /* number of retries before quitting */
+
+/*
+ * The state byte is used to retain exclusivity,
+ * and contains the busy flag.
+ */
+#define FL_OPEN 1
+#define FL_BUSY 2
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)frame.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Definition of the vax calls/callg frame.
+ */
+struct frame {
+ int fr_handler;
+ u_int fr_psw:16, /* saved psw */
+ fr_mask:12, /* register save mask */
+ :1,
+ fr_s:1, /* call was a calls, not callg */
+ fr_spa:2; /* stack pointer alignment */
+ int fr_savap; /* saved arg pointer */
+ int fr_savfp; /* saved frame pointer */
+ int fr_savpc; /* saved program counter */
+};
--- /dev/null
+/*
+ * Copyright (c) 1984, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)inline.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * COMMENTCHAR is the character delimiting comments in the assembler.
+ * LABELCHAR is the character that separates labels from instructions.
+ * ARGSEPCHAR is the character that separates arguments in instructions.
+ */
+#define COMMENTCHAR '#'
+#define LABELCHAR ':'
+#define ARGSEPCHAR ','
+
+/*
+ * Expansion parameters:
+ * QUEUESIZE is the number of instructions to be considered for
+ * integration of argument pushes and pops
+ * MAXLINELEN is the longest expected input line
+ * MAXARGS is the maximum number of arguments in an assembly instruction
+ */
+#define QUEUESIZE 16
+#define MAXLINELEN 1024
+#define MAXARGS 10
+
+/*
+ * The following global variables are used to manipulate the queue of
+ * recently seen instructions.
+ * line - The queue of instructions.
+ * bufhead - Pointer to next availble queue slot. It is not
+ * considered part of te instruction stream until
+ * bufhead is advanced.
+ * buftail - Pointer to last instruction in queue.
+ * Note that bufhead == buftail implies that the queue is empty.
+ */
+int bufhead, buftail;
+char line[QUEUESIZE][MAXLINELEN];
+
+#define SUCC(qindex) ((qindex) + 1 == QUEUESIZE ? 0 : (qindex) + 1)
+#define PRED(qindex) ((qindex) - 1 < 0 ? QUEUESIZE - 1 : (qindex) - 1)
+
+/*
+ * Hash table headers should be twice as big as the number of patterns.
+ * They must be a power of two.
+ */
+#define HSHSIZ 128
+
+/*
+ * These tables specify the substitutions that are to be done.
+ */
+struct pats {
+ int args;
+ char *name;
+ char *replace;
+ struct pats *next;
+ int size;
+};
+struct pats *patshdr[HSHSIZ];
+extern struct pats language_ptab[], libc_ptab[], machine_ptab[];
+extern struct pats vax_libc_ptab[], vaxsubset_libc_ptab[];
+extern struct pats vax_ptab[], vaxsubset_ptab[];
+
+/*
+ * This table defines the set of instructions that demark the
+ * end of a basic block.
+ */
+struct inststoptbl {
+ char *name;
+ struct inststoptbl *next;
+ int size;
+};
+struct inststoptbl *inststoptblhdr[HSHSIZ];
+extern struct inststoptbl inststoptable[];
+
+/*
+ * Miscellaneous functions.
+ */
+/*char *newline(), *copyline(), *doreplaceon();*/
--- /dev/null
+/*
+ * @(#)ioa.h 7.1 (Berkeley) 6/5/86
+ */
+
+/****************************************************************
+ * *
+ * Licensed from Digital Equipment Corporation *
+ * Copyright (c) *
+ * Digital Equipment Corporation *
+ * Maynard, Massachusetts *
+ * 1985, 1986 *
+ * All rights reserved. *
+ * *
+ * The Information in this software is subject to change *
+ * without notice and should not be construed as a commitment *
+ * by Digital Equipment Corporation. Digital makes no *
+ * representations about the suitability of this software for *
+ * any purpose. It is supplied "As Is" without expressed or *
+ * implied warranty. *
+ * *
+ * If the Regents of the University of California or its *
+ * licensees modify the software in a manner creating *
+ * diriviative copyright rights, appropriate copyright *
+ * legends may be placed on the drivative work in addition *
+ * to that set forth above. *
+ * *
+ ****************************************************************/
+
+#define MAXNIOA 4
+#define NIOA8600 2
+#define IOASIZE 0x2000000
+#define IOAMAPSIZ 512 /* Map one page to get at SBIA regs */
+#define IOA8600(i) ((caddr_t)(0x20080000+IOASIZE*i))
+
+#ifndef LOCORE
+struct sbia_regs
+{
+ int sbi_cfg;
+ int sbi_csr;
+ int sbi_errsum;
+ int sbi_dctl;
+ int sbi_dmaica;
+ int sbi_dmaiid;
+ int sbi_dmaaca;
+ int sbi_dmaaid;
+ int sbi_dmabcs;
+ int sbi_dmabid;
+ int sbi_dmaccs;
+ int sbi_dmacid;
+ int sbi_silo;
+ int sbi_error;
+ int sbi_timo;
+ int sbi_fltsts;
+ int sbi_silcmp;
+ int sbi_maint;
+ int sbi_unjam;
+ int sbi_qclr;
+ int sbi_unused[12];
+ int sbi_iv10;
+ int sbi_iv11;
+ int sbi_iv12;
+ int sbi_iv13;
+ int sbi_iv14;
+ int sbi_iv15;
+ int sbi_iv16;
+ int sbi_iv17;
+ int sbi_iv18;
+ int sbi_iv19;
+ int sbi_iv1a;
+ int sbi_iv1b;
+ int sbi_iv1c;
+ int sbi_iv1d;
+ int sbi_iv1e;
+};
+struct ioa {
+ union ioacsr {
+ long ioa_csr;
+ u_char ioa_type;
+ } ioacsr;
+ long ioa_pad[IOAMAPSIZ / sizeof (long) - 1];
+};
+#ifdef KERNEL
+struct ioa ioa[MAXNIOA];
+#endif KERNEL
+#endif LOCORE
+
+#define IOA_TYPMSK 0xf0
+#define IOA_SBIA 0x10
--- /dev/null
+/*
+ * @(#)ka630.h 7.1 (Berkeley) 6/5/86
+ *
+ * Definitions specific to the ka630 uvax2 cpu card. Includes the tod
+ * clock chip and the cpu registers.
+ */
+#ifdef VAX630
+/* Bdr register bits */
+#define KA630BDR_PWROK 0x8000
+#define KA630BDR_HLTENB 0x4000
+#define KA630BDR_CPU 0x0c00
+#define KA630BDR_BDG 0x0300
+#define KA630BDR_DSPL 0x000f
+
+/* Memory system err reg. */
+#define KA630MSER_CD 0x00000300
+#define KA630MSER_NXM 0x00000080
+#define KA630MSER_LPE 0x00000040
+#define KA630MSER_QPE 0x00000020
+#define KA630MSER_MERR 0x000000f0
+#define KA630MSER_CPUER 0x00000060
+#define KA630MSER_DQPE 0x00000010
+#define KA630MSER_LEB 0x00000008
+#define KA630MSER_WRWP 0x00000002
+#define KA630MSER_PAREN 0x00000001
+
+/* Mem. error address regs. */
+#define KA630CEAR_PG 0x00007fff
+#define KA630DEAR_PG 0x00007fff
+
+/* Clock registers and constants */
+#define MINSEC 60
+#define HRSEC 3600
+
+#define KA630CLK_VRT 0200
+#define KA630CLK_UIP 0200
+#define KA630CLK_RATE 040
+#define KA630CLK_ENABLE 06
+#define KA630CLK_SET 0206
+/* cpmbx bits */
+#define KA630CLK_HLTACT 03
+/* halt action values */
+#define KA630CLK_RESTRT 01
+#define KA630CLK_REBOOT 02
+#define KA630CLK_HALT 03
+/* in progress flags */
+#define KA630CLK_BOOT 04
+#define KA630CLK_RSTRT 010
+#define KA630CLK_LANG 0360
+
+#ifndef LOCORE
+struct cldevice {
+ u_short sec;
+ u_short secalrm;
+ u_short min;
+ u_short minalrm;
+ u_short hr;
+ u_short hralrm;
+ u_short dayofwk;
+ u_short day;
+ u_short mon;
+ u_short yr;
+ u_short csr0;
+ u_short csr1;
+ u_short csr2;
+ u_short csr3;
+ u_short cpmbx; /* CPMBX is used by the boot rom. see ka630-ug-3.3.3 */
+};
+
+struct ka630cpu {
+ u_short ka630_bdr;
+ u_short ka630_xxx;
+ u_long ka630_mser;
+ u_long ka630_cear;
+ u_long ka630_dear;
+};
+#endif
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)machparam.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Machine dependent constants for vax.
+ */
+#define NBPG 512 /* bytes/page */
+#define PGOFSET (NBPG-1) /* byte offset into page */
+#define PGSHIFT 9 /* LOG2(NBPG) */
+
+#define CLSIZE 2
+#define CLSIZELOG2 1
+
+#define SSIZE 4 /* initial stack size/NBPG */
+#define SINCR 4 /* increment of stack/NBPG */
+
+#define UPAGES 10 /* pages of u-area */
+
+/*
+ * Some macros for units conversion
+ */
+/* Core clicks (512 bytes) to segments and vice versa */
+#define ctos(x) (x)
+#define stoc(x) (x)
+
+/* Core clicks (512 bytes) to disk blocks */
+#define ctod(x) (x)
+#define dtoc(x) (x)
+#define dtob(x) ((x)<<9)
+
+/* clicks to bytes */
+#define ctob(x) ((x)<<9)
+
+/* bytes to clicks */
+#define btoc(x) ((((unsigned)(x)+511)>>9))
+
+/*
+ * Macros to decode processor status word.
+ */
+#define USERMODE(ps) (((ps) & PSL_CURMOD) == PSL_CURMOD)
+#define BASEPRI(ps) (((ps) & PSL_IPL) == 0)
+
+#ifdef KERNEL
+#ifndef LOCORE
+int cpuspeed;
+#endif
+#define DELAY(n) { register int N = cpuspeed * (n); while (--N > 0); }
+
+#else KERNEL
+#define DELAY(n) { register int N = (n); while (--N > 0); }
+#endif KERNEL
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)mem.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Memory controller registers
+ *
+ * The way in which the data is stored in these registers varies
+ * per controller and cpu, so we define macros here to mask that.
+ */
+struct mcr {
+ int mc_reg[6];
+};
+
+/*
+ * Compute maximum possible number of memory controllers,
+ * for sizing of the mcraddr array.
+ */
+#if VAX780
+#define MAXNMCR 4
+#else
+#define MAXNMCR 1
+#endif
+
+/*
+ * For each controller type we define 5 macros:
+ * M???_INH(mcr) inhibits further crd interrupts from mcr
+ * M???_ENA(mcr) enables another crd interrupt from mcr
+ * M???_ERR(mcr) tells whether an error is waiting
+ * M???_SYN(mcr) gives the syndrome bits of the error
+ * M???_ADDR(mcr) gives the address of the error
+ */
+
+#if VAX8600
+/*
+ * 8600 register bit definitions
+ */
+#define M8600_ICRD 0x400 /* inhibit crd interrupts */
+#define M8600_TB_ERR 0xf00 /* translation buffer error mask */
+/*
+ * MDECC register
+ */
+#define M8600_ADDR_PE 0x080000 /* address parity error */
+#define M8600_DBL_ERR 0x100000 /* data double bit error */
+#define M8600_SNG_ERR 0x200000 /* data single bit error */
+#define M8600_BDT_ERR 0x400000 /* bad data error */
+
+/*
+ * ESPA register is used to address scratch pad registers in the Ebox.
+ * To access a register in the scratch pad, write the ESPA with the address
+ * and then read the ESPD register.
+ *
+ * NOTE: In assmebly code, the the mfpr instruction that reads the ESPD
+ * register must immedately follow the mtpr instruction that setup
+ * the ESPA register -- per the VENUS processor register spec.
+ *
+ * The scratchpad registers that are supplied for a single bit ECC
+ * error are:
+ */
+#define SPAD_MSTAT1 0x25 /* scratch pad mstat1 register */
+#define SPAD_MSTAT2 0x26 /* scratch pad mstat2 register */
+#define SPAD_MDECC 0x27 /* scratch pad mdecc register */
+#define SPAD_MEAR 0x2a /* scratch pad mear register */
+
+#define M8600_MEMERR(mdecc) ((mdecc) & 0x780000)
+#define M8600_HRDERR(mdecc) ((mdecc) & 0x580000)
+#define M8600_ENA (mtpr(MERG, (mfpr(MERG) & ~M8600_ICRD)))
+#define M8600_INH (mtpr(EHSR, 0), mtpr(MERG, (mfpr(MERG) | M8600_ICRD)))
+#define M8600_SYN(mdecc) (((mdecc) >> 9) & 0x3f)
+#define M8600_ADDR(mear) ((mear) & 0x3ffffffc)
+#define M8600_ARRAY(mear) (((mear) >> 22) & 0x0f)
+
+#define M8600_MDECC_BITS "\20\27BAD_DT_ERR\26SNG_BIT_ERR\25DBL_BIT_ERR\
+\24ADDR_PE"
+#define M8600_MSTAT1_BITS "\20\30CPR_PE_A\27CPR_PE_B\26ABUS_DT_PE\
+\25ABUS_CTL_MSK_PE\24ABUS_ADR_PE\23ABUS_C/A_CYCLE\22ABUS_ADP_1\21ABUS_ADP_0\
+\20TB_MISS\17BLK_HIT\16C0_TAG_MISS\15CHE_MISS\14TB_VAL_ERR\13TB_PTE_B_PE\
+\12TB_PTE_A_PE\11TB_TAG_PE\10WR_DT_PE_B3\7WR_DT_PE_B2\6WR_DT_PE_B1\
+\5WR_DT_PE_B0\4CHE_RD_DT_PE\3CHE_SEL\2ANY_REFL\1CP_BW_CHE_DT_PE"
+#define M8600_MSTAT2_BITS "\20\20CP_BYT_WR\17ABUS_BD_DT_CODE\10MULT_ERR\
+\7CHE_TAG_PE\6CHE_TAG_W_PE\5CHE_WRTN_BIT\4NXM\3CP-IO_BUF_ERR\2MBOX_LOCK"
+#endif VAX8600
+
+#if VAX780
+#define M780_ICRD 0x40000000 /* inhibit crd interrupts, in [2] */
+#define M780_HIER 0x20000000 /* high error rate, in reg[2] */
+#define M780_ERLOG 0x10000000 /* error log request, in reg[2] */
+/* on a 780, memory crd's occur only when bit 15 is set in the SBIER */
+/* register; bit 14 there is an error bit which we also clear */
+/* these bits are in the back of the ``red book'' (or in the VMS code) */
+
+#define M780C_INH(mcr) \
+ (((mcr)->mc_reg[2] = (M780_ICRD|M780_HIER|M780_ERLOG)), mtpr(SBIER, 0))
+#define M780C_ENA(mcr) \
+ (((mcr)->mc_reg[2] = (M780_HIER|M780_ERLOG)), mtpr(SBIER, 3<<14))
+#define M780C_ERR(mcr) \
+ ((mcr)->mc_reg[2] & (M780_ERLOG))
+
+#define M780C_SYN(mcr) ((mcr)->mc_reg[2] & 0xff)
+#define M780C_ADDR(mcr) (((mcr)->mc_reg[2] >> 8) & 0xfffff)
+
+#define M780EL_INH(mcr) \
+ (((mcr)->mc_reg[2] = (M780_ICRD|M780_HIER|M780_ERLOG)), mtpr(SBIER, 0))
+#define M780EL_ENA(mcr) \
+ (((mcr)->mc_reg[2] = (M780_HIER|M780_ERLOG)), mtpr(SBIER, 3<<14))
+#define M780EL_ERR(mcr) \
+ ((mcr)->mc_reg[2] & (M780_ERLOG))
+
+#define M780EL_SYN(mcr) ((mcr)->mc_reg[2] & 0x7f)
+#define M780EL_ADDR(mcr) (((mcr)->mc_reg[2] >> 11) & 0x1ffff)
+
+#define M780EU_INH(mcr) \
+ (((mcr)->mc_reg[3] = (M780_ICRD|M780_HIER|M780_ERLOG)), mtpr(SBIER, 0))
+#define M780EU_ENA(mcr) \
+ (((mcr)->mc_reg[3] = (M780_HIER|M780_ERLOG)), mtpr(SBIER, 3<<14))
+#define M780EU_ERR(mcr) \
+ ((mcr)->mc_reg[3] & (M780_ERLOG))
+
+#define M780EU_SYN(mcr) ((mcr)->mc_reg[3] & 0x7f)
+#define M780EU_ADDR(mcr) (((mcr)->mc_reg[3] >> 11) & 0x1ffff)
+#endif
+
+#if VAX750
+#define M750_ICRD 0x10000000 /* inhibit crd interrupts, in [1] */
+#define M750_UNCORR 0xc0000000 /* uncorrectable error, in [0] */
+#define M750_CORERR 0x20000000 /* correctable error, in [0] */
+
+#define M750_INH(mcr) ((mcr)->mc_reg[1] = 0)
+#define M750_ENA(mcr) ((mcr)->mc_reg[0] = (M750_UNCORR|M750_CORERR), \
+ (mcr)->mc_reg[1] = M750_ICRD)
+#define M750_ERR(mcr) ((mcr)->mc_reg[0] & (M750_UNCORR|M750_CORERR))
+
+#define M750_SYN(mcr) ((mcr)->mc_reg[0] & 0x7f)
+#define M750_ADDR(mcr) (((mcr)->mc_reg[0] >> 9) & 0x7fff)
+#endif
+
+#if VAX730
+#define M730_UNCORR 0x80000000 /* rds, uncorrectable error, in [1] */
+#define M730_CRD 0x40000000 /* crd, in [1] */
+#define M730_FTBPE 0x20000000 /* force tbuf parity error, in [1] */
+#define M730_ENACRD 0x10000000 /* enable crd interrupt, in [1] */
+#define M730_MME 0x08000000 /* mem-man enable (ala ipr), in [1] */
+#define M730_DM 0x04000000 /* diagnostic mode, in [1] */
+#define M730_DISECC 0x02000000 /* disable ecc, in [1] */
+
+#define M730_INH(mcr) ((mcr)->mc_reg[1] = M730_MME)
+#define M730_ENA(mcr) ((mcr)->mc_reg[1] = (M730_MME|M730_ENACRD))
+#define M730_ERR(mcr) ((mcr)->mc_reg[1] & (M730_UNCORR|M730_CRD))
+#define M730_SYN(mcr) ((mcr)->mc_reg[0] & 0x7f)
+#define M730_ADDR(mcr) (((mcr)->mc_reg[0] >> 8) & 0x7fff)
+#endif
+
+/* controller types */
+#define M780C 1
+#define M780EL 2
+#define M780EU 3
+#define M750 4
+#define M730 5
+
+#define MEMINTVL (60*10) /* 10 minutes */
+
+#ifdef KERNEL
+int nmcr;
+struct mcr *mcraddr[MAXNMCR];
+int mcrtype[MAXNMCR];
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)mscp.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Definitions for the Mass Storage Control Protocol
+ */
+
+
+/*
+ * Control message opcodes
+ */
+#define M_OP_ABORT 0001 /* Abort command */
+#define M_OP_GTCMD 0002 /* Get command status command */
+#define M_OP_GTUNT 0003 /* Get unit status command */
+#define M_OP_STCON 0004 /* Set controller characteristics command */
+#define M_OP_SEREX 0007 /* Serious exception end message */
+#define M_OP_AVAIL 0010 /* Available command */
+#define M_OP_ONLIN 0011 /* Online command */
+#define M_OP_STUNT 0012 /* Set unit characteristics command */
+#define M_OP_DTACP 0013 /* Determine access paths command */
+#define M_OP_ACCES 0020 /* Access command */
+#define M_OP_CMPCD 0021 /* Compare controller data command */
+#define M_OP_ERASE 0022 /* Erase command */
+#define M_OP_FLUSH 0023 /* Flush command */
+#define M_OP_REPLC 0024 /* Replace command */
+#define M_OP_COMP 0040 /* Compare host data command */
+#define M_OP_READ 0041 /* Read command */
+#define M_OP_WRITE 0042 /* Write command */
+#define M_OP_AVATN 0100 /* Available attention message */
+#define M_OP_DUPUN 0101 /* Duplicate unit number attention message */
+#define M_OP_ACPTH 0102 /* Access path attention message */
+#define M_OP_END 0200 /* End message flag */
+
+
+/*
+ * Generic command modifiers
+ */
+#define M_MD_EXPRS 0100000 /* Express request */
+#define M_MD_COMP 0040000 /* Compare */
+#define M_MD_CLSEX 0020000 /* Clear serious exception */
+#define M_MD_ERROR 0010000 /* Force error */
+#define M_MD_SCCHH 0004000 /* Suppress caching (high speed) */
+#define M_MD_SCCHL 0002000 /* Suppress caching (low speed) */
+#define M_MD_SECOR 0001000 /* Suppress error correction */
+#define M_MD_SEREC 0000400 /* Suppress error recovery */
+#define M_MD_SSHDW 0000200 /* Suppress shadowing */
+#define M_MD_WBKNV 0000100 /* Write back (non-volatile) */
+#define M_MD_WBKVL 0000040 /* Write back (volatile) */
+#define M_MD_WRSEQ 0000020 /* Write shadow set one unit at a time */
+
+/*
+ * AVAILABLE command modifiers
+ */
+#define M_MD_ALLCD 0000002 /* All class drivers */
+#define M_MD_SPNDW 0000001 /* Spin down */
+
+/*
+ * FLUSH command modifiers
+ */
+#define M_MD_FLENU 0000001 /* Flush entire unit */
+#define M_MD_VOLTL 0000002 /* Volatile only */
+
+/*
+ * GET UNIT STATUS command modifiers
+ */
+#define M_MD_NXUNT 0000001 /* Next unit */
+
+/*
+ * ONLINE command modifiers
+ */
+#define M_MD_RIP 0000001 /* Allow self destruction */
+#define M_MD_IGNMF 0000002 /* Ignore media format error */
+
+/*
+ * ONLINE and SET UNIT CHARACTERISTICS command modifiers
+ */
+#define M_MD_ALTHI 0000040 /* Alter host identifier */
+#define M_MD_SHDSP 0000020 /* Shadow unit specified */
+#define M_MD_CLWBL 0000010 /* Clear write-back data lost */
+#define M_MD_STWRP 0000004 /* Set write protect */
+
+/*
+ * REPLACE command modifiers
+ */
+#define M_MD_PRIMR 0000001 /* Primary replacement block */
+
+
+/*
+ * End message flags
+ */
+#define M_EF_BBLKR 0200 /* Bad block reported */
+#define M_EF_BBLKU 0100 /* Bad block unreported */
+#define M_EF_ERLOG 0040 /* Error log generated */
+#define M_EF_SEREX 0020 /* Serious exception */
+
+
+/*
+ * Controller flags
+ */
+#define M_CF_ATTN 0200 /* Enable attention messages */
+#define M_CF_MISC 0100 /* Enable miscellaneous error log messages */
+#define M_CF_OTHER 0040 /* Enable other host's error log messages */
+#define M_CF_THIS 0020 /* Enable this host's error log messages */
+#define M_CF_MLTHS 0004 /* Multi-host */
+#define M_CF_SHADW 0002 /* Shadowing */
+#define M_CF_576 0001 /* 576 byte sectors */
+
+
+/*
+ * Unit flags
+ */
+#define M_UF_REPLC 0100000 /* Controller initiated bad block replacement */
+#define M_UF_INACT 0040000 /* Inactive shadow set unit */
+#define M_UF_WRTPH 0020000 /* Write protect (hardware) */
+#define M_UF_WRTPS 0010000 /* Write protect (software or volume) */
+#define M_UF_SCCHH 0004000 /* Suppress caching (high speed) */
+#define M_UF_SCCHL 0002000 /* Suppress caching (low speed) */
+#define M_UF_RMVBL 0000200 /* Removable media */
+#define M_UF_WBKNV 0000100 /* Write back (non-volatile) */
+#define M_UF_576 0000004 /* 576 byte sectors */
+#define M_UF_CMPWR 0000002 /* Compare writes */
+#define M_UF_CMPRD 0000001 /* Compare reads */
+
+
+/*
+ * Status codes
+ */
+#define M_ST_MASK 037 /* Status code mask */
+#define M_ST_SUCC 000 /* Success */
+#define M_ST_ICMD 001 /* Invalid command */
+#define M_ST_ABRTD 002 /* Command aborted */
+#define M_ST_OFFLN 003 /* Unit offline */
+#define M_ST_AVLBL 004 /* Unit available */
+#define M_ST_MFMTE 005 /* Media format error */
+#define M_ST_WRTPR 006 /* Write protected */
+#define M_ST_COMP 007 /* Compare error */
+#define M_ST_DATA 010 /* Data error */
+#define M_ST_HSTBF 011 /* Host buffer access error */
+#define M_ST_CNTLR 012 /* Controller error */
+#define M_ST_DRIVE 013 /* Drive error */
+#define M_ST_DIAG 037 /* Message from an internal diagnostic */
+
+/*
+ * An MSCP packet
+ */
+
+struct mscp {
+ struct mscp_header mscp_header;/* device specific header */
+ long mscp_cmdref; /* command reference number */
+ short mscp_unit; /* unit number */
+ short mscp_xxx1; /* unused */
+ u_char mscp_opcode; /* opcode */
+ u_char mscp_flags; /* end message flags */
+ short mscp_modifier; /* modifiers */
+ union {
+ struct {
+ long Mscp_bytecnt; /* byte count */
+ long Mscp_buffer; /* buffer descriptor */
+ long Mscp_xxx2[2]; /* unused */
+ long Mscp_lbn; /* logical block number */
+ long Mscp_xxx4; /* unused */
+ long *Mscp_dscptr; /* pointer to descriptor (software) */
+ long Mscp_sftwds[4]; /* software words, padding */
+ } mscp_generic;
+ struct {
+ short Mscp_version; /* MSCP version */
+ short Mscp_cntflgs; /* controller flags */
+ short Mscp_hsttmo; /* host timeout */
+ short Mscp_usefrac; /* use fraction */
+ long Mscp_time; /* time and date */
+ } mscp_setcntchar;
+ struct {
+ short Mscp_multunt; /* multi-unit code */
+ short Mscp_unitflgs; /* unit flags */
+ long Mscp_hostid; /* host identifier */
+ quad Mscp_unitid; /* unit identifier */
+ long Mscp_mediaid; /* media type identifier */
+ short Mscp_shdwunt; /* shadow unit */
+ short Mscp_shdwsts; /* shadow status */
+ short Mscp_track; /* track size */
+ short Mscp_group; /* group size */
+ short Mscp_cylinder; /* cylinder size */
+ short Mscp_xxx3; /* reserved */
+ short Mscp_rctsize; /* RCT table size */
+ char Mscp_rbns; /* RBNs / track */
+ char Mscp_rctcpys; /* RCT copies */
+ } mscp_getunitsts;
+ } mscp_un;
+ short mscp_fil1;
+ short mscp_fil2;
+ short mscp_fil3;
+};
+
+#define mscp_msglen (sizeof (struct mscp) - sizeof(struct mscp_header))
+
+/*
+ * generic packet
+ */
+
+#define mscp_bytecnt mscp_un.mscp_generic.Mscp_bytecnt
+#define mscp_buffer mscp_un.mscp_generic.Mscp_buffer
+#define mscp_lbn mscp_un.mscp_generic.Mscp_lbn
+#define mscp_dscptr mscp_un.mscp_generic.Mscp_dscptr
+#define mscp_sftwds mscp_un.mscp_generic.Mscp_sftwds
+#define mscp_status mscp_modifier
+
+/*
+ * Abort / Get Command Status packet
+ */
+
+#define mscp_outref mscp_bytecnt
+
+/*
+ * Online / Set Unit Characteristics packet
+ */
+
+#define mscp_errlgfl mscp_lbn
+#define mscp_copyspd mscp_shdwsts
+
+/*
+ * Replace packet
+ */
+
+#define mscp_rbn mscp_bytecnt
+
+/*
+ * Set Controller Characteristics packet
+ */
+
+#define mscp_version mscp_un.mscp_setcntchar.Mscp_version
+#define mscp_cntflgs mscp_un.mscp_setcntchar.Mscp_cntflgs
+#define mscp_hsttmo mscp_un.mscp_setcntchar.Mscp_hsttmo
+#define mscp_usefrac mscp_un.mscp_setcntchar.Mscp_usefrac
+#define mscp_time mscp_un.mscp_setcntchar.Mscp_time
+
+/*
+ * Get Unit Status end packet
+ */
+
+#define mscp_multunt mscp_un.mscp_getunitsts.Mscp_multunt
+#define mscp_unitflgs mscp_un.mscp_getunitsts.Mscp_unitflgs
+#define mscp_hostid mscp_un.mscp_getunitsts.Mscp_hostid
+#define mscp_unitid mscp_un.mscp_getunitsts.Mscp_unitid
+#define mscp_mediaid mscp_un.mscp_getunitsts.Mscp_mediaid
+#define mscp_shdwunt mscp_un.mscp_getunitsts.Mscp_shdwunt
+#define mscp_shdwsts mscp_un.mscp_getunitsts.Mscp_shdwsts
+#define mscp_track mscp_un.mscp_getunitsts.Mscp_track
+#define mscp_group mscp_un.mscp_getunitsts.Mscp_group
+#define mscp_cylinder mscp_un.mscp_getunitsts.Mscp_cylinder
+#define mscp_rctsize mscp_un.mscp_getunitsts.Mscp_rctsize
+#define mscp_rbns mscp_un.mscp_getunitsts.Mscp_rbns
+#define mscp_rctcpys mscp_un.mscp_getunitsts.Mscp_rctcpys
+
+/*
+ * Online / Set Unit Characteristics end packet
+ */
+
+#define mscp_untsize mscp_dscptr
+#define mscp_volser mscp_sftwds[0]
+
+/*
+ * Set Controller Characteristics end packet
+ */
+
+#define mscp_cnttmo mscp_hsttmo
+#define mscp_cntcmdl mscp_usefrac
+#define mscp_cntid mscp_unitid
+
+
+/*
+ * Error Log message format codes
+ */
+#define M_FM_CNTERR 0 /* Controller error */
+#define M_FM_BUSADDR 1 /* Host memory access error */
+#define M_FM_DISKTRN 2 /* Disk transfer error */
+#define M_FM_SDI 3 /* SDI error */
+#define M_FM_SMLDSK 4 /* Small disk error */
+
+/*
+ * Error Log message flags
+ */
+#define M_LF_SUCC 0200 /* Operation successful */
+#define M_LF_CONT 0100 /* Operation continuing */
+#define M_LF_SQNRS 0001 /* Sequence number reset */
+
+/*
+ * MSCP Error Log packet
+ *
+ * NOTE: MSCP packet must be padded to this size.
+ */
+
+struct mslg {
+ struct mscp_header mslg_header;/* device specific header */
+ long mslg_cmdref; /* command reference number */
+ short mslg_unit; /* unit number */
+ short mslg_seqnum; /* sequence number */
+ u_char mslg_format; /* format */
+ u_char mslg_flags; /* error log message flags */
+ short mslg_event; /* event code */
+ quad mslg_cntid; /* controller id */
+ u_char mslg_cntsvr; /* controller software version */
+ u_char mslg_cnthvr; /* controller hardware version */
+ short mslg_multunt; /* multi-unit code */
+ quad mslg_unitid; /* unit id */
+ u_char mslg_unitsvr; /* unit software version */
+ u_char mslg_unithvr; /* unit hardware version */
+ short mslg_group; /* group; retry + level */
+ long mslg_volser; /* volume serial number */
+ long mslg_hdr; /* header */
+ char mslg_sdistat[12]; /* SDI status information */
+};
+
+#define mslg_busaddr mslg_unitid.val[0]
+#define mslg_sdecyl mslg_group
+
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)mtpr.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * VAX processor register numbers
+ */
+
+#define KSP 0x0 /* kernel stack pointer */
+#define ESP 0x1 /* exec stack pointer */
+#define SSP 0x2 /* supervisor stack pointer */
+#define USP 0x3 /* user stack pointer */
+#define ISP 0x4 /* interrupt stack pointer */
+#define P0BR 0x8 /* p0 base register */
+#define P0LR 0x9 /* p0 length register */
+#define P1BR 0xa /* p1 base register */
+#define P1LR 0xb /* p1 length register */
+#define SBR 0xc /* system segment base register */
+#define SLR 0xd /* system segment length register */
+#define PCBB 0x10 /* process control block base */
+#define SCBB 0x11 /* system control block base */
+#define IPL 0x12 /* interrupt priority level */
+#define ASTLVL 0x13 /* async. system trap level */
+#define SIRR 0x14 /* software interrupt request */
+#define SISR 0x15 /* software interrupt summary */
+#define ICCS 0x18 /* interval clock control */
+#define NICR 0x19 /* next interval count */
+#define ICR 0x1a /* interval count */
+#define TODR 0x1b /* time of year (day) */
+#define RXCS 0x20 /* console receiver control and status */
+#define RXDB 0x21 /* console receiver data buffer */
+#define TXCS 0x22 /* console transmitter control and status */
+#define TXDB 0x23 /* console transmitter data buffer */
+#define MAPEN 0x38 /* memory management enable */
+#define TBIA 0x39 /* translation buffer invalidate all */
+#define TBIS 0x3a /* translation buffer invalidate single */
+#define PMR 0x3d /* performance monitor enable */
+#define SID 0x3e /* system identification */
+
+#if defined(VAX780) || defined(VAX8600)
+#define ACCS 0x28 /* accelerator control and status */
+#endif
+
+#if defined(VAX8600)
+#define TBCHK 0x3f /* Translation Buffer Check */
+#define PAMACC 0x40 /* PAMM access */
+#define PAMLOC 0x41 /* PAMM location */
+#define CSWP 0x42 /* Cache sweep */
+#define MDECC 0x43 /* MBOX data ecc register */
+#define MENA 0x44 /* MBOX error enable register */
+#define MDCTL 0x45 /* MBOX data control register */
+#define MCCTL 0x46 /* MBOX mcc control register */
+#define MERG 0x47 /* MBOX error generator register */
+#define CRBT 0x48 /* Console reboot */
+#define DFI 0x49 /* Diag fault insertion register */
+#define EHSR 0x4a /* Error handling status register */
+#define STXCS 0x4c /* Console block storage C/S */
+#define STXDB 0x4d /* Console block storage D/B */
+#define ESPA 0x4e /* EBOX scratchpad address */
+#define ESPD 0x4f /* EBOX sratchpad data */
+#endif
+
+#if defined(VAX780)
+#define ACCR 0x29 /* accelerator maintenance */
+#define WCSA 0x2c /* WCS address */
+#define WCSD 0x2d /* WCS data */
+#define SBIFS 0x30 /* SBI fault and status */
+#define SBIS 0x31 /* SBI silo */
+#define SBISC 0x32 /* SBI silo comparator */
+#define SBIMT 0x33 /* SBI maintenance */
+#define SBIER 0x34 /* SBI error register */
+#define SBITA 0x35 /* SBI timeout address */
+#define SBIQC 0x36 /* SBI quadword clear */
+#define MBRK 0x3c /* micro-program breakpoint */
+#endif
+
+#if defined(VAX750) || defined(VAX730)
+#define MCSR 0x17 /* machine check status register */
+#define CSRS 0x1c /* console storage receive status register */
+#define CSRD 0x1d /* console storage receive data register */
+#define CSTS 0x1e /* console storage transmit status register */
+#define CSTD 0x1f /* console storage transmit data register */
+#define TBDR 0x24 /* translation buffer disable register */
+#define CADR 0x25 /* cache disable register */
+#define MCESR 0x26 /* machine check error summary register */
+#define CAER 0x27 /* cache error */
+#define IUR 0x37 /* init unibus register */
+#define TB 0x3b /* translation buffer */
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)nexus.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Information about nexus's.
+ *
+ * Each machine has an address of backplane slots (nexi).
+ * Each nexus is some type of adapter, whose code is the low
+ * byte of the first word of the adapter address space.
+ * At boot time the system looks through the array of available
+ * slots and finds the interconnects for the machine.
+ */
+#define NNEXSBI 16
+#if VAX8600
+#define NNEX8600 NNEXSBI
+#define NEXA8600 ((struct nexus *)(0x20000000))
+#define NEXB8600 ((struct nexus *)(0x22000000))
+#endif
+#if VAX780
+#define NNEX780 NNEXSBI
+#define NEX780 ((struct nexus *)0x20000000)
+#endif
+#if VAX750
+#define NNEX750 NNEXSBI
+#define NEX750 ((struct nexus *)0xf20000)
+#endif
+#if VAX730
+#define NNEX730 NNEXSBI
+#define NEX730 ((struct nexus *)0xf20000)
+#endif
+#if VAX630
+#define NNEX630 1
+#define NEX630 ((struct nexus *)0x20088000)
+#endif
+#define NEXSIZE 0x2000
+
+#if VAX8600
+#define MAXNNEXUS (2 * NNEXSBI)
+#else
+#define MAXNNEXUS NNEXSBI
+#endif
+
+#ifndef LOCORE
+struct nexus {
+ union nexcsr {
+ long nex_csr;
+ u_char nex_type;
+ } nexcsr;
+ long nex_pad[NEXSIZE / sizeof (long) - 1];
+};
+#ifdef KERNEL
+struct nexus nexus[MAXNNEXUS];
+#endif
+#endif
+
+/*
+ * Bits in high word of nexus's.
+ */
+#define SBI_PARFLT (1<<31) /* sbi parity fault */
+#define SBI_WSQFLT (1<<30) /* write sequence fault */
+#define SBI_URDFLT (1<<29) /* unexpected read data fault */
+#define SBI_ISQFLT (1<<28) /* interlock sequence fault */
+#define SBI_MXTFLT (1<<27) /* multiple transmitter fault */
+#define SBI_XMTFLT (1<<26) /* transmit fault */
+
+#define NEX_CFGFLT (0xfc000000)
+
+#ifndef LOCORE
+#if defined(VAX780) || defined(VAX8600)
+#define NEXFLT_BITS \
+"\20\40PARFLT\37WSQFLT\36URDFLT\35ISQFLT\34MXTFLT\33XMTFLT"
+#endif
+#endif
+
+#define NEX_APD (1<<23) /* adaptor power down */
+#define NEX_APU (1<<22) /* adaptor power up */
+
+#define MBA_OT (1<<21) /* overtemperature */
+
+#define UBA_UBINIT (1<<18) /* unibus init */
+#define UBA_UBPDN (1<<17) /* unibus power down */
+#define UBA_UBIC (1<<16) /* unibus initialization complete */
+
+/*
+ * Types for nex_type.
+ */
+#define NEX_ANY 0 /* pseudo for handling 11/750 */
+#define NEX_MEM4 0x08 /* 4K chips, non-interleaved mem */
+#define NEX_MEM4I 0x09 /* 4K chips, interleaved mem */
+#define NEX_MEM16 0x10 /* 16K chips, non-interleaved mem */
+#define NEX_MEM16I 0x11 /* 16K chips, interleaved mem */
+#define NEX_MBA 0x20 /* Massbus adaptor */
+#define NEX_UBA0 0x28 /* Unibus adaptor */
+#define NEX_UBA1 0x29 /* 4 flavours for 4 addr spaces */
+#define NEX_UBA2 0x2a
+#define NEX_UBA3 0x2b
+#define NEX_DR32 0x30 /* DR32 user i'face to SBI */
+#define NEX_CI 0x38 /* CI adaptor */
+#define NEX_MPM0 0x40 /* Multi-port mem */
+#define NEX_MPM1 0x41 /* Who knows why 4 different ones ? */
+#define NEX_MPM2 0x42
+#define NEX_MPM3 0x43
+#define NEX_MEM64L 0x68 /* 64K chips, non-interleaved, lower */
+#define NEX_MEM64LI 0x69 /* 64K chips, ext-interleaved, lower */
+#define NEX_MEM64U 0x6a /* 64K chips, non-interleaved, upper */
+#define NEX_MEM64UI 0x6b /* 64K chips, ext-interleaved, upper */
+#define NEX_MEM64I 0x6c /* 64K chips, interleaved */
+#define NEX_MEM256L 0x70 /* 256K chips, non-interleaved, lower */
+#define NEX_MEM256LI 0x71 /* 256K chips, ext-interleaved, lower */
+#define NEX_MEM256U 0x72 /* 256K chips, non-interleaved, upper */
+#define NEX_MEM256UI 0x73 /* 256K chips, ext-interleaved, upper */
+#define NEX_MEM256I 0x74 /* 256K chips, interleaved */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)pcb.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * VAX process control block
+ */
+
+struct pcb
+{
+ int pcb_ksp; /* kernel stack pointer */
+ int pcb_esp; /* exec stack pointer */
+ int pcb_ssp; /* supervisor stack pointer */
+ int pcb_usp; /* user stack pointer */
+ int pcb_r0;
+ int pcb_r1;
+ int pcb_r2;
+ int pcb_r3;
+ int pcb_r4;
+ int pcb_r5;
+ int pcb_r6;
+ int pcb_r7;
+ int pcb_r8;
+ int pcb_r9;
+ int pcb_r10;
+ int pcb_r11;
+ int pcb_r12;
+#define pcb_ap pcb_r12
+ int pcb_r13;
+#define pcb_fp pcb_r13
+ int pcb_pc; /* program counter */
+ int pcb_psl; /* program status longword */
+ struct pte *pcb_p0br; /* seg 0 base register */
+ int pcb_p0lr; /* seg 0 length register and astlevel */
+ struct pte *pcb_p1br; /* seg 1 base register */
+ int pcb_p1lr; /* seg 1 length register and pme */
+/*
+ * Software pcb (extension)
+ */
+ int pcb_szpt; /* number of pages of user page table */
+ int pcb_cmap2;
+ int *pcb_sswap;
+ int pcb_sigc[5];
+};
+
+#define AST_NONE 0x04000000 /* ast level */
+#define AST_USER 0x03000000 /* ast for user mode */
+
+#define ASTLVL_NONE 4
+#define ASTLVL_USER 3
+
+#define AST_CLR 0x07000000
+#define PME_CLR 0x80000000
+
+#define aston() \
+ { \
+ mtpr(ASTLVL, ASTLVL_USER); \
+ }
+
+#define astoff() \
+ { \
+ mtpr(ASTLVL, ASTLVL_NONE); \
+ }
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)psl.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * VAX program status longword
+ */
+
+#define PSL_C 0x00000001 /* carry bit */
+#define PSL_V 0x00000002 /* overflow bit */
+#define PSL_Z 0x00000004 /* zero bit */
+#define PSL_N 0x00000008 /* negative bit */
+#define PSL_ALLCC 0x0000000f /* all cc bits - unlikely */
+#define PSL_T 0x00000010 /* trace enable bit */
+#define PSL_IV 0x00000020 /* integer overflow enable bit */
+#define PSL_FU 0x00000040 /* floating point underflow enable */
+#define PSL_DV 0x00000080 /* decimal overflow enable bit */
+#define PSL_IPL 0x001f0000 /* interrupt priority level */
+#define PSL_PRVMOD 0x00c00000 /* previous mode (all on is user) */
+#define PSL_CURMOD 0x03000000 /* current mode (all on is user) */
+#define PSL_IS 0x04000000 /* interrupt stack */
+#define PSL_FPD 0x08000000 /* first part done */
+#define PSL_TP 0x40000000 /* trace pending */
+#define PSL_CM 0x80000000 /* compatibility mode */
+
+#define PSL_MBZ 0x3020ff00 /* must be zero bits */
+
+#define PSL_USERSET (PSL_PRVMOD|PSL_CURMOD)
+#define PSL_USERCLR (PSL_IS|PSL_IPL|PSL_MBZ)
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)pte.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * VAX page table entry
+ *
+ * There are two major kinds of pte's: those which have ever existed (and are
+ * thus either now in core or on the swap device), and those which have
+ * never existed, but which will be filled on demand at first reference.
+ * There is a structure describing each. There is also an ancillary
+ * structure used in page clustering.
+ */
+
+/*#ifndef LOCORE*/
+struct pte
+{
+unsigned int pg_pfnum:21, /* core page frame number or 0 */
+ :2,
+ pg_vreadm:1, /* modified since vread (or with _m) */
+ pg_swapm:1, /* have to write back to swap */
+ pg_fod:1, /* is fill on demand (=0) */
+ pg_m:1, /* hardware maintained modified bit */
+ pg_prot:4, /* access control */
+ pg_v:1; /* valid bit */
+};
+struct hpte
+{
+unsigned int pg_pfnum:21,
+ :2,
+ pg_high:9; /* special for clustering */
+};
+struct fpte
+{
+unsigned int pg_blkno:24, /* file system block number */
+ pg_fileno:1, /* file mapped from or TEXT or ZERO */
+ pg_fod:1, /* is fill on demand (=1) */
+ :1,
+ pg_prot:4,
+ pg_v:1;
+};
+#endif
+
+#define PG_V 0x80000000
+#define PG_PROT 0x78000000
+#define PG_M 0x04000000
+#define PG_FOD 0x02000000
+#define PG_VREADM 0x00800000
+#define PG_PFNUM 0x001fffff
+
+#define PG_FZERO 0
+#define PG_FTEXT 1
+#define PG_FMAX (PG_FTEXT)
+
+#define PG_NOACC 0
+#define PG_KW 0x10000000
+#define PG_KR 0x18000000
+#define PG_UW 0x20000000
+#define PG_URKW 0x70000000
+#define PG_URKR 0x78000000
+
+/*
+ * Pte related macros
+ */
+#define dirty(pte) ((pte)->pg_fod == 0 && (pte)->pg_pfnum && \
+ ((pte)->pg_m || (pte)->pg_swapm))
+
+#ifndef LOCORE
+#ifdef KERNEL
+
+/* utilities defined in locore.s */
+extern struct pte Sysmap[];
+extern struct pte Usrptmap[];
+extern struct pte usrpt[];
+extern struct pte Swapmap[];
+extern struct pte Forkmap[];
+extern struct pte Xswapmap[];
+extern struct pte Xswap2map[];
+extern struct pte Pushmap[];
+extern struct pte Vfmap[];
+extern struct pte mmap[];
+extern struct pte msgbufmap[];
+extern struct pte camap[];
+extern struct pte Nexmap[][16];
+extern struct pte Ioamap[][1];
+#ifdef VAX630
+extern struct pte Clockmap[];
+extern struct pte Ka630map[];
+#endif
+#endif
+/*#endif*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)reg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Location of the users' stored
+ * registers relative to R0.
+ * Usage is u.u_ar0[XX].
+ */
+#define R0 (-18)
+#define R1 (-17)
+#define R2 (-16)
+#define R3 (-15)
+#define R4 (-14)
+#define R5 (-13)
+#define R6 (-12)
+#define R7 (-11)
+#define R8 (-10)
+#define R9 (-9)
+#define R10 (-8)
+#define R11 (-7)
+#define R12 (-21)
+#define R13 (-20)
+
+#define AP (-21)
+#define FP (-20)
+#define SP (-5)
+#define PS (-1)
+#define PC (-2)
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)rpb.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * The restart parameter block, which is a page in (very) low
+ * core which runs after a crash. Currently, the restart
+ * procedure takes a dump.
+ */
+struct rpb {
+ struct rpb *rp_selfref; /* self-reference */
+/* int (*rp_dumprout)();*/ /* routine to be called */
+ long rp_checksum; /* checksum of 31 words of dumprout */
+ long rp_flag; /* set to 1 when dumprout runs */
+/* the dump stack grows from the end of the rpb page not to reach here */
+};
+#ifdef KERNEL
+extern struct rpb rpb;
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)rsp.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * TU58 transfer protocol constants and data structures
+ */
+
+/*
+ * Structure of a command packet
+ */
+struct packet {
+ u_char pk_flag; /* indicates packet type (cmd, data, etc.) */
+ u_char pk_mcount; /* length of packet (bytes) */
+ u_char pk_op; /* operation to perform (read, write, etc.) */
+ u_char pk_mod; /* modifier for op or returned status */
+ u_char pk_unit; /* unit number */
+ u_char pk_sw; /* switches */
+ u_short pk_seq; /* sequence number, always zero */
+ u_short pk_count; /* requested byte count for read or write */
+ u_short pk_block; /* block number for read, write, or seek */
+ u_short pk_chksum; /* checksum, by words with end around carry */
+};
+
+/*
+ * States
+ */
+#define TUS_INIT1 0 /* sending nulls */
+#define TUS_INIT2 1 /* sending inits */
+#define TUS_IDLE 2 /* initialized, no transfer in progress */
+#define TUS_SENDH 3 /* sending header */
+#define TUS_SENDD 4 /* sending data */
+#define TUS_SENDC 5 /* sending checksum */
+#define TUS_SENDR 6 /* sending read command packet */
+#define TUS_SENDW 7 /* sending write command packet */
+#define TUS_GETH 8 /* reading header */
+#define TUS_GETD 9 /* reading data */
+#define TUS_GETC 10 /* reading checksum */
+#define TUS_GET 11 /* reading an entire packet */
+#define TUS_WAIT 12 /* waiting for continue */
+#define TUS_RCVERR 13 /* receiver error in pseudo DMA routine */
+#define TUS_CHKERR 14 /* checksum error in pseudo DMA routine */
+
+#define TUS_NSTATES 15
+
+#define printstate(state) \
+ if ((state) < TUS_NSTATES) \
+ printf("%s", tustates[(state)]); \
+ else \
+ printf("%d", (state));
+
+/*
+ * Packet Flags
+ */
+#define TUF_DATA 1 /* data packet */
+#define TUF_CMD 2 /* command packet */
+#define TUF_INITF 4 /* initialize */
+#define TUF_CONT 020 /* continue */
+#define TUF_XOFF 023 /* flow control */
+
+/*
+ * Op Codes
+ */
+#define TUOP_NOOP 0 /* no operation */
+#define TUOP_INIT 1 /* initialize */
+#define TUOP_READ 2 /* read block */
+#define TUOP_WRITE 3 /* write block */
+#define TUOP_SEEK 5 /* seek to block */
+#define TUOP_DIAGNOSE 7 /* run micro-diagnostics */
+#define TUOP_END 0100 /* end packet */
+
+/*
+ * Mod Flags
+ */
+#define TUMD_WRV 1 /* write with read verify */
+
+/*
+ * Switches
+ */
+#define TUSW_MRSP 010 /* use Modified RSP */
+
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)scb.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * VAX System control block layout
+ */
+
+struct scb {
+/* int (*scb_stray)();*/ /* reserved */
+/* int (*scb_machchk)();*/ /* machine chack */
+/* int (*scb_kspinval)();*/ /* KSP invalid */
+/* int (*scb_powfail)();*/ /* power fail */
+/* int (*scb_resinstr)();*/ /* reserved instruction */
+/* int (*scb_custinst)();*/ /* XFC instr */
+/* int (*scb_resopnd)();*/ /* reserved operand */
+/* int (*scb_resaddr)();*/ /* reserved addr mode */
+/* int (*scb_acv)();*/ /* access control violation */
+/* int (*scb_tnv)();*/ /* translation not valid */
+/* int (*scb_tracep)();*/ /* trace pending */
+/* int (*scb_bpt)();*/ /* breakpoint instr */
+/* int (*scb_compat)();*/ /* compatibility mode fault */
+/* int (*scb_arith)();*/ /* arithmetic fault */
+/* int (*scb_stray2)();*/
+/* int (*scb_stray3)();*/
+/* int (*scb_chmk)();*/ /* CHMK instr */
+/* int (*scb_chme)();*/ /* CHME instr */
+/* int (*scb_chms)();*/ /* CHMS instr */
+/* int (*scb_chmu)();*/ /* CHMU instr */
+/* int (*scb_sbisilo)();*/ /* SBI silo compare */
+/* int (*scb_cmrd)();*/ /* corrected mem read data */
+/* int (*scb_sbialert)();*/ /* SBI alert */
+/* int (*scb_sbiflt)();*/ /* SBI fault */
+/* int (*scb_wtime)();*/ /* memory write timeout */
+/* int (*scb_stray4[8])();*/
+/* int (*scb_soft[15])();*/ /* software interrupt */
+/* int (*scb_timer)();*/ /* interval timer interrupt */
+/* int (*scb_stray5[7])();*/
+/* int (*scb_stray6[4])();*/
+/* int (*scb_csdr)();*/ /* console storage receive */
+/* int (*scb_csdx)();*/ /* console storage transmit */
+/* int (*scb_ctr)();*/ /* console terminal receive */
+/* int (*scb_ctx)();*/ /* console terminal transmit */
+/* int (*scb_ipl14[16])();*/ /* device interrupts IPL 14 */
+/* int (*scb_ipl15[16])();*/ /* " " IPL 15 */
+/* int (*scb_ipl16[16])();*/ /* " " IPL 16 */
+/* int (*scb_ipl17[16])();*/ /* " " IPL 17 */
+/* int (*scb_ubaint[128])();*/ /* Unibus device intr */
+/* int (*scb_uba1int[128])();*/ /* Unibus 1 device intr */
+};
+
+#ifdef KERNEL
+extern struct scb scb;
+/* scb.scb_ubaint is the same as UNIvec */
+#endif
+
+#define scbentry(f, how) ((int (*)())(((int)f)+how))
+
+#define SCB_KSTACK 0
+#define SCB_ISTACK 1
+#define SCB_WCS 2
+#define SCB_HALT 3
--- /dev/null
+/* @(#)tmscp.h 7.1 (Berkeley) 6/5/86 */
+
+/*
+ * @(#)tmscp.h 1.3 10/21/85
+ * Definitions for the Tape Mass Storage Control Protocol
+ */
+
+/****************************************************************
+ * *
+ * Licensed from Digital Equipment Corporation *
+ * Copyright (c) *
+ * Digital Equipment Corporation *
+ * Maynard, Massachusetts *
+ * 1985, 1986 *
+ * All rights reserved. *
+ * *
+ * The Information in this software is subject to change *
+ * without notice and should not be construed as a commitment *
+ * by Digital Equipment Corporation. Digital makes no *
+ * representations about the suitability of this software for *
+ * any purpose. It is supplied "As Is" without expressed or *
+ * implied warranty. *
+ * *
+ * If the Regents of the University of California or its *
+ * licensees modify the software in a manner creating *
+ * diriviative copyright rights, appropriate copyright *
+ * legends may be placed on the drivative work in addition *
+ * to that set forth above. *
+ * *
+ ****************************************************************
+ *
+ * Modification history: /sys/vax/tmscp.h
+ *
+ * 18-Oct-85 - afd
+ * Added: defines for tape format (density) flag values.
+ *
+ * 18-Jul-85 - afd
+ * Added: #define M_UF_WBKNV 0000100
+ * for write back (which enables cache).
+ ************************************************************************/
+
+
+/*
+ * Control message opcodes
+ */
+#define M_OP_ABORT 0001 /* Abort command */
+#define M_OP_GTCMD 0002 /* Get command status command */
+#define M_OP_GTUNT 0003 /* Get unit status command */
+#define M_OP_STCON 0004 /* Set controller characteristics command */
+#define M_OP_AVAIL 0010 /* Available command */
+#define M_OP_ONLIN 0011 /* Online command */
+#define M_OP_STUNT 0012 /* Set unit characteristics command */
+#define M_OP_DTACP 0013 /* Determine access paths command */
+#define M_OP_ACCES 0020 /* Access command */
+#define M_OP_CMPCD 0021 /* Compare controller data command */
+#define M_OP_ERASE 0022 /* Erase command */
+#define M_OP_FLUSH 0023 /* Flush command */
+#define M_OP_ERGAP 0026 /* Erase gap command */
+#define M_OP_COMP 0040 /* Compare host data command */
+#define M_OP_READ 0041 /* Read command */
+#define M_OP_WRITE 0042 /* Write command */
+#define M_OP_WRITM 0044 /* Write tape mark command */
+#define M_OP_REPOS 0045 /* Reposition command */
+#define M_OP_AVATN 0100 /* Available attention message */
+#define M_OP_DUPUN 0101 /* Duplicate unit number attention message */
+#define M_OP_ACPTH 0102 /* Access path attention message */
+#define M_OP_END 0200 /* End message flag */
+
+
+/*
+ * Generic command modifiers
+ */
+#define M_MD_COMP 0040000 /* Compare */
+#define M_MD_CLSEX 0020000 /* Clear serious exception */
+#define M_MD_SECOR 0001000 /* Suppress error correction */
+#define M_MD_SEREC 0000400 /* Suppress error recovery */
+#define M_MD_STWRP 0000004 /* Set write protect */
+#define M_MD_ALLCD 0000002 /* All class drivers */
+#define M_MD_NXUNT 0000001 /* Next unit */
+
+/*
+ * TMSCP command modifiers
+ */
+#define M_MD_DLEOT 0000200 /* Delete LEOT */
+#define M_MD_IMMED 0000100 /* Immediate completion */
+#define M_MD_EXCAC 0000040 /* Exclusive access */
+#define M_MD_UNLOD 0000020 /* Unload */
+#define M_MD_REVRS 0000010 /* reverse */
+#define M_MD_OBJCT 0000004 /* object count */
+#define M_MD_REWND 0000002 /* rewind */
+
+/*
+ * End message flags
+ */
+#define M_EF_ERLOG 0040 /* Error log generated */
+#define M_EF_SEREX 0020 /* Serious exception */
+#define M_EF_EOT 0010 /* End of tape encountered */
+#define M_EF_PLS 0004 /* Position lost */
+
+
+/*
+ * Controller flags
+ */
+#define M_CF_ATTN 0200 /* Enable attention messages */
+#define M_CF_MISC 0100 /* Enable miscellaneous error log messages */
+#define M_CF_OTHER 0040 /* Enable other host's error log messages */
+#define M_CF_THIS 0020 /* Enable this host's error log messages */
+
+
+/*
+ * Unit flags
+ */
+#define M_UF_WRTPH 0020000 /* Write protect (hardware) */
+#define M_UF_WRTPS 0010000 /* Write protect (software or volume) */
+#define M_UF_WBKNV 0000100 /* Write back (enables cache) */
+#define M_UF_VSMSU 0000040 /* Variable speed mode suppression */
+#define M_UF_VARSP 0000020 /* Variable speed unit */
+#define M_UF_CMPWR 0000002 /* Compare writes */
+#define M_UF_CMPRD 0000001 /* Compare reads */
+
+
+/*
+ * Status codes
+ */
+#define M_ST_MASK 037 /* Status code mask */
+#define M_ST_SUCC 000 /* Success */
+#define M_ST_ICMD 001 /* Invalid command */
+#define M_ST_ABRTD 002 /* Command aborted */
+#define M_ST_OFFLN 003 /* Unit offline */
+#define M_ST_AVLBL 004 /* Unit available */
+#define M_ST_WRTPR 006 /* Write protected */
+#define M_ST_COMP 007 /* Compare error */
+#define M_ST_DATA 010 /* Data error */
+#define M_ST_HSTBF 011 /* Host buffer access error */
+#define M_ST_CNTLR 012 /* Controller error */
+#define M_ST_DRIVE 013 /* Drive error */
+#define M_ST_FMTER 014 /* Formatter error */
+#define M_ST_BOT 015 /* BOT encountered */
+#define M_ST_TAPEM 016 /* Tape mark encountered */
+#define M_ST_RDTRN 020 /* Record data truncated */
+#define M_ST_PLOST 021 /* Position lost */
+#define M_ST_SEX 022 /* Serious exception */
+#define M_ST_LED 023 /* LEOT detected */
+#define M_ST_DIAG 037 /* Message from an internal diagnostic */
+
+/*
+ * An MSCP packet
+ */
+
+struct mscp {
+ struct mscp_header mscp_header;/* device specific header */
+ long mscp_cmdref; /* command reference number */
+ short mscp_unit; /* unit number */
+ short mscp_xxx1; /* unused */
+ u_char mscp_opcode; /* opcode */
+ u_char mscp_flags; /* end message flags */
+ short mscp_modifier; /* modifiers */
+ union {
+ struct {
+ long Mscp_bytecnt; /* byte count */
+ long Mscp_buffer; /* buffer descriptor */
+ long Mscp_mapbase; /* physical addr of map registers */
+ long Mscp_xxx2; /* unused */
+ long Mscp_lbn; /* logical block number */
+ long Mscp_xxx4; /* unused */
+ long *Mscp_dscptr; /* pointer to descriptor (software) */
+ long Mscp_sftwds[17];/* software words, padding */
+ } mscp_generic;
+ struct {
+ short Mscp_version; /* MSCP version */
+ short Mscp_cntflgs; /* controller flags */
+ short Mscp_hsttmo; /* host timeout */
+ short Mscp_usefrac; /* use fraction */
+ quad Mscp_time; /* time and date */
+ long Mscp_cntdep; /* controller dependent parameters */
+ } mscp_setcntchar;
+ struct {
+ short Mscp_multunt; /* multi-unit code */
+ short Mscp_unitflgs; /* unit flags */
+ long Mscp_hostid; /* host identifier */
+ quad Mscp_unitid; /* unit identifier */
+ long Mscp_mediaid; /* media type identifier */
+ short Mscp_format; /* format (tape density) */
+ short Mscp_speed; /* tape speed = (ips * bpi) /1000 */
+ short Mscp_fmtmenu; /* format menu */
+ short Mscp_group; /* group size */
+ short Mscp_cylinder; /* cylinder size */
+ short Mscp_xxx3; /* reserved */
+ short Mscp_rctsize; /* RCT table size */
+ char Mscp_rbns; /* RBNs / track */
+ char Mscp_rctcpys; /* RCT copies */
+ } mscp_getunitsts;
+ } mscp_un;
+ short mscp_fil1;
+ short mscp_fil2;
+ short mscp_fil3;
+};
+
+#define mscp_msglen (sizeof (struct mscp) - sizeof(struct mscp_header))
+
+/*
+ * generic packet
+ */
+
+#define mscp_bytecnt mscp_un.mscp_generic.Mscp_bytecnt
+#define mscp_buffer mscp_un.mscp_generic.Mscp_buffer
+#define mscp_mapbase mscp_un.mscp_generic.Mscp_mapbase
+#define mscp_lbn mscp_un.mscp_generic.Mscp_lbn
+#define mscp_dscptr mscp_un.mscp_generic.Mscp_dscptr
+#define mscp_sftwds mscp_un.mscp_generic.Mscp_sftwds
+#define mscp_status mscp_modifier
+
+/*
+ * Abort / Get Command Status packet
+ */
+
+#define mscp_outref mscp_bytecnt
+
+/*
+ * Set Controller Characteristics packet
+ */
+
+#define mscp_version mscp_un.mscp_setcntchar.Mscp_version
+#define mscp_cntflgs mscp_un.mscp_setcntchar.Mscp_cntflgs
+#define mscp_hsttmo mscp_un.mscp_setcntchar.Mscp_hsttmo
+#define mscp_usefrac mscp_un.mscp_setcntchar.Mscp_usefrac
+#define mscp_time mscp_un.mscp_setcntchar.Mscp_time
+#define mscp_cntdep mscp_un.mscp_setcntchar.Mscp_cntdep
+
+/*
+ * Reposition command packet fields
+ */
+
+#define mscp_reccnt mscp_bytecnt /* record/object count */
+#define mscp_tmkcnt mscp_buffer /* tape mark count */
+
+/*
+ * Get Unit Status end packet
+ */
+
+#define mscp_multunt mscp_un.mscp_getunitsts.Mscp_multunt
+#define mscp_unitflgs mscp_un.mscp_getunitsts.Mscp_unitflgs
+#define mscp_hostid mscp_un.mscp_getunitsts.Mscp_hostid
+#define mscp_unitid mscp_un.mscp_getunitsts.Mscp_unitid
+#define mscp_mediaid mscp_un.mscp_getunitsts.Mscp_mediaid
+#define mscp_format mscp_un.mscp_getunitsts.Mscp_format /* density:0=high */
+#define mscp_speed mscp_un.mscp_getunitsts.Mscp_speed /* (ips*bpi)/1000 */
+#define mscp_fmtmenu mscp_un.mscp_getunitsts.Mscp_fmtmenu
+
+/*
+ * Online / Set Unit Characteristics end packet
+ */
+
+#define mscp_maxwrt mscp_dscptr /* max write byte count */
+#define mscp_noiserec mscp_cylinder /* noise record */
+
+/*
+ * Set Controller Characteristics end packet
+ */
+
+#define mscp_cnttmo mscp_hsttmo /* controller timeout */
+#define mscp_cntcmdl mscp_usefrac /* controller soft & hardware version */
+#define mscp_cntid mscp_unitid /* controller id */
+
+
+/*
+ * Error Log message format codes
+ */
+#define M_FM_CNTERR 0 /* Controller error */
+#define M_FM_BUSADDR 1 /* Host memory access error */
+#define M_FM_TAPETRN 5 /* Tape transfer error */
+#define M_FM_STIERR 6 /* STI communication or command failure */
+#define M_FM_STIDEL 7 /* STI drive error log */
+#define M_FM_STIFEL 010 /* STI formatter error log */
+
+/*
+ * Error Log message flags
+ */
+#define M_LF_SUCC 0200 /* Operation successful */
+#define M_LF_CONT 0100 /* Operation continuing */
+#define M_LF_SQNRS 0001 /* Sequence number reset */
+
+/*
+ * Tape Format Flag Values
+ */
+#define M_TF_800 001 /* NRZI 800 bpi */
+#define M_TF_PE 002 /* Phase Encoded 1600 bpi */
+#define M_TF_GCR 004 /* Group Code Recording 6250 bpi */
+#define M_TF_BLK 010 /* Cartridge Block Mode */
+
+/*
+ * MSCP Error Log packet
+ *
+ * NOTE: MSCP packet must be padded to this size.
+ */
+
+struct mslg {
+ struct mscp_header mslg_header;/* device specific header */
+ long mslg_cmdref; /* command reference number */
+ short mslg_unit; /* unit number */
+ short mslg_seqnum; /* sequence number */
+ u_char mslg_format; /* format */
+ u_char mslg_flags; /* error log message flags */
+ short mslg_event; /* event code */
+ quad mslg_cntid; /* controller id */
+ u_char mslg_cntsvr; /* controller software version */
+ u_char mslg_cnthvr; /* controller hardware version */
+ short mslg_multunt; /* multi-unit code */
+ quad mslg_unitid; /* unit id */
+ u_char mslg_unitsvr; /* unit software version */
+ u_char mslg_unithvr; /* unit hardware version */
+ short mslg_group; /* group; retry + level */
+ long mslg_position; /* position (object count) */
+ u_char mslg_fmtsvr; /* formatter software version */
+ u_char mslg_fmthvr; /* formatter hardware version */
+ short mslg_xxx2; /* unused */
+ char mslg_stiunsucc[62]; /* STI status information */
+};
+
+#define mslg_busaddr mslg_unitid.val[0]
+#define mslg_sdecyl mslg_group
+
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)trap.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Trap type values
+ */
+
+/* The first three constant values are known to the real world <signal.h> */
+#define T_RESADFLT 0 /* reserved addressing fault */
+#define T_PRIVINFLT 1 /* privileged instruction fault */
+#define T_RESOPFLT 2 /* reserved operand fault */
+/* End of known constants */
+#define T_BPTFLT 3 /* bpt instruction fault */
+#define T_XFCFLT 4 /* xfc instruction fault */
+#define T_SYSCALL 5 /* chmk instruction (syscall trap) */
+#define T_ARITHTRAP 6 /* arithmetic trap */
+#define T_ASTFLT 7 /* software level 2 trap (ast deliv) */
+#define T_SEGFLT 8 /* segmentation fault */
+#define T_PROTFLT 9 /* protection fault */
+#define T_TRCTRAP 10 /* trace trap */
+#define T_COMPATFLT 11 /* compatibility mode fault */
+#define T_PAGEFLT 12 /* page fault */
+#define T_TABLEFLT 13 /* page table fault */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)vmparam.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Machine dependent constants for VAX
+ */
+/*
+ * USRTEXT is the start of the user text/data space, while USRSTACK
+ * is the top (end) of the user stack. LOWPAGES and HIGHPAGES are
+ * the number of pages from the beginning of the P0 region to the
+ * beginning of the text and from the beginning of the P1 region to the
+ * beginning of the stack respectively.
+ */
+#define USRTEXT 0
+#define USRSTACK (0x80000000-UPAGES*NBPG) /* Start of user stack */
+#define BTOPUSRSTACK (0x400000 - UPAGES) /* btop(USRSTACK) */
+/* number of ptes per page */
+#define P1PAGES 0x200000 /* number of pages in P1 region */
+#define LOWPAGES 0
+#define HIGHPAGES UPAGES
+
+/*
+ * Virtual memory related constants, all in bytes
+ */
+#ifndef MAXTSIZ
+#define MAXTSIZ (6*1024*1024) /* max text size */
+#endif
+#ifndef DFLDSIZ
+#define DFLDSIZ (6*1024*1024) /* initial data size limit */
+#endif
+#ifndef MAXDSIZ
+#define MAXDSIZ (16*1024*1024) /* max data size */
+#endif
+#ifndef DFLSSIZ
+#define DFLSSIZ (512*1024) /* initial stack size limit */
+#endif
+#ifndef MAXSSIZ
+#define MAXSSIZ MAXDSIZ /* max stack size */
+#endif
+
+/*
+ * Default sizes of swap allocation chunks (see dmap.h).
+ * The actual values may be changed in vminit() based on MAXDSIZ.
+ * With MAXDSIZ of 16Mb and NDMAP of 38, dmmax will be 1024.
+ */
+#define DMMIN 32 /* smallest swap allocation */
+#define DMMAX 4096 /* largest potential swap allocation */
+#define DMTEXT 1024 /* swap allocation for text */
+
+/*
+ * Sizes of the system and user portions of the system page table.
+ */
+/* SYSPTSIZE IS SILLY; IT SHOULD BE COMPUTED AT BOOT TIME */
+#define SYSPTSIZE ((20+MAXUSERS)*NPTEPG)
+#define USRPTSIZE (32*NPTEPG)
+
+/*
+ * The size of the clock loop.
+ */
+#define LOOPPAGES (maxfree - firstfree)
+
+/*
+ * The time for a process to be blocked before being very swappable.
+ * This is a number of seconds which the system takes as being a non-trivial
+ * amount of real time. You probably shouldn't change this;
+ * it is used in subtle ways (fractions and multiples of it are, that is, like
+ * half of a ``long time'', almost a long time, etc.)
+ * It is related to human patience and other factors which don't really
+ * change over time.
+ */
+#define MAXSLP 20
+
+/*
+ * A swapped in process is given a small amount of core without being bothered
+ * by the page replacement algorithm. Basically this says that if you are
+ * swapped in you deserve some resources. We protect the last SAFERSS
+ * pages against paging and will just swap you out rather than paging you.
+ * Note that each process has at least UPAGES+CLSIZE pages which are not
+ * paged anyways (this is currently 8+2=10 pages or 5k bytes), so this
+ * number just means a swapped in process is given around 25k bytes.
+ * Just for fun: current memory prices are 4600$ a megabyte on VAX (4/22/81),
+ * so we loan each swapped in process memory worth 100$, or just admit
+ * that we don't consider it worthwhile and swap it out to disk which costs
+ * $30/mb or about $0.75.
+ */
+#define SAFERSS 32 /* nominal ``small'' resident set size
+ protected against replacement */
+
+/*
+ * DISKRPM is used to estimate the number of paging i/o operations
+ * which one can expect from a single disk controller.
+ */
+#define DISKRPM 60
+
+/*
+ * Klustering constants. Klustering is the gathering
+ * of pages together for pagein/pageout, while clustering
+ * is the treatment of hardware page size as though it were
+ * larger than it really is.
+ *
+ * KLMAX gives maximum cluster size in CLSIZE page (cluster-page)
+ * units. Note that KLMAX*CLSIZE must be <= DMMIN in dmap.h.
+ */
+
+#define KLMAX (32/CLSIZE)
+#define KLSEQL (16/CLSIZE) /* in klust if vadvise(VA_SEQL) */
+#define KLIN (8/CLSIZE) /* default data/stack in klust */
+#define KLTXT (4/CLSIZE) /* default text in klust */
+#define KLOUT (32/CLSIZE)
+
+/*
+ * KLSDIST is the advance or retard of the fifo reclaim for sequential
+ * processes data space.
+ */
+#define KLSDIST 3 /* klusters advance/retard for seq. fifo */
+
+/*
+ * Paging thresholds (see vm_sched.c).
+ * Strategy of 1/19/85:
+ * lotsfree is 512k bytes, but at most 1/4 of memory
+ * desfree is 200k bytes, but at most 1/8 of memory
+ * minfree is 64k bytes, but at most 1/2 of desfree
+ */
+#define LOTSFREE (512 * 1024)
+#define LOTSFREEFRACT 4
+#define DESFREE (200 * 1024)
+#define DESFREEFRACT 8
+#define MINFREE (64 * 1024)
+#define MINFREEFRACT 2
+
+/*
+ * There are two clock hands, initially separated by HANDSPREAD bytes
+ * (but at most all of user memory). The amount of time to reclaim
+ * a page once the pageout process examines it increases with this
+ * distance and decreases as the scan rate rises.
+ */
+#define HANDSPREAD (2 * 1024 * 1024)
+
+/*
+ * The number of times per second to recompute the desired paging rate
+ * and poke the pagedaemon.
+ */
+#define RATETOSCHEDPAGING 4
+
+/*
+ * Believed threshold (in megabytes) for which interleaved
+ * swapping area is desirable.
+ */
+#define LOTSOFMEM 2
+
+/*
+ * BEWARE THIS DEFINITION WORKS ONLY WITH COUNT OF 1
+ */
+#define mapin(pte, v, pfnum, count, prot) \
+ (*(int *)(pte) = (pfnum) | (prot), mtpr(TBIS, ptob(v)))
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_accreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * ACC LH/DH-11 interface
+ */
+
+struct accdma {
+ short csr; /* control and status */
+ short db; /* data buffer */
+ u_short ba; /* buss address */
+ short wc; /* word count */
+};
+
+struct accdevice {
+ struct accdma input;
+ struct accdma output;
+};
+
+#define icsr input.csr
+#define iba input.ba
+#define iwc input.wc
+#define ocsr output.csr
+#define oba output.ba
+#define owc output.wc
+
+/*
+ * Bits Common to both input and out CSR's
+ */
+#define ACC_ERR 0x8000 /* error present */
+#define ACC_NXM 0x4000 /* non-existant memory */
+#define ACC_RDY 0x0080 /* ready */
+#define ACC_IE 0x0040 /* interrupt enable */
+#define ACC_RESET 0x0002 /* reset interface */
+#define ACC_GO 0x0001 /* start operation */
+
+/*
+ * Input Control Status Register
+ */
+#define IN_EOM 0x2000 /* end-of-message recieved */
+#define IN_HRDY 0x0800 /* host ready */
+#define IN_IMPBSY 0x0400 /* IMP not ready */
+#define IN_RMR 0x0200 /* receive master ready error */
+#define IN_IBF 0x0100 /* input data buffer full */
+#define IN_WEN 0x0008 /* write enable */
+#define IN_MRDY 0x0004 /* master ready */
+
+#define ACC_INBITS \
+"\20\20ERR\17NXM\16EOM\14HRDY\13IMPBSY\12RMR\11IBF\10RDY\7IE\
+\4WEN\3MRDY\2RESET\1GO"
+
+/*
+ * Output Control Status Register
+ */
+#define OUT_TMR 0x0200 /* transmit master ready error */
+#define OUT_BBACK 0x0008 /* bus back */
+#define OUT_ENLB 0x0004 /* enable last bit */
+
+#define ACC_OUTBITS \
+"\20\20ERR\17NXM\12TMR\10RDY\7IE\4BBACK\3ENLB\2RESET\1GO"
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_cssreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * DEC/CSS IMP11-A ARPAnet interface
+ */
+
+struct cssdma {
+ short wc; /* word count */
+ u_short ba; /* bus address (low 16 bits) */
+ short csr; /* status register */
+ short db; /* data buffer*/
+};
+
+struct cssdevice {
+ struct cssdma css_output; /* transmit DR11-B */
+ struct cssdma css_hole; /* unclever gap */
+ struct cssdma css_input; /* receive DR11-B */
+};
+
+#define css_icsr css_input.csr
+#define css_iba css_input.ba
+#define css_iwc css_input.wc
+#define css_ocsr css_output.csr
+#define css_oba css_output.ba
+#define css_owc css_output.wc
+
+/*
+ * Bits Common to both input and out CSR's
+ */
+#define CSS_ERR 0x8000 /* error present */
+#define CSS_NXM 0x4000 /* non-existant memory */
+#define CSS_ATTN 0x2000 /* attention */
+#define CSS_MAINT 0x1000 /* maintenance mode */
+#define CSS_CYCLE 0x0100 /* force bus cycle */
+#define CSS_RDY 0x0080 /* ready */
+#define CSS_IE 0x0040 /* interrupt enable */
+#define CSS_XA 0x0030 /* extended address bits */
+#define CSS_CLR 0x0020 /* clear status (reset) */
+#define CSS_GO 0x0001 /* start operation */
+
+/*
+ * Input Control Status Register
+ */
+#define IN_EOM 0x0800 /* end-of-message recieved */
+#define IN_IMPNR 0x0400 /* IMP not ready */
+#define IN_RLE 0x0200 /* ready line error */
+#define IN_WEN 0x0008 /* write enable */
+#define IN_HRDY 0x0004 /* host ready */
+
+#define CSS_INBITS \
+"\20\20ERR\17NXM\16ATTN\15MAINT\14EOM\13IMPNR\12RLE\11CYCLE\10RDY\7IE\6XBA17\5XBA16\4WE\3HRDY\2CLR\1GO"
+
+
+/*
+ * Output Control Status Register
+ */
+#define OUT_TXEC 0x0008 /* tx error clear */
+#define OUT_ENLB 0x0004 /* enable last bit */
+
+#define CSS_OUTBITS \
+"\20\20ERR\17NXM\16ATTN\15MAINT\11CYCLE\10RDY\7IE\6XBA17\5XBA16\4TXEC\3ENLB\2CLR\1GO"
--- /dev/null
+/* @(#)if_ddnreg.h 7.1 (Berkeley) 6/5/86 */
+
+
+/************************************************************************\
+
+ ________________________________________________________
+ / \
+ | AAA CCCCCCCCCCCCCC CCCCCCCCCCCCCC |
+ | AAAAA CCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC |
+ | AAAAAAA CCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCC |
+ | AAAA AAAA CCCC CCCC |
+ | AAAA AAAA CCCC CCCC |
+ | AAAA AAAA CCCC CCCC |
+ | AAAA AAAA CCCC CCCC |
+ | AAAA AAAAAAAAAAA CCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCC |
+ | AAAA AAAAAAAAAAA CCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC |
+ | AAAA AAAAAAAAA CCCCCCCCCCCCCC CCCCCCCCCCCCCC |
+ \________________________________________________________/
+
+ Copyright (c) 1985 by Advanced Computer Communications
+ 720 Santa Barbara Street, Santa Barbara, California 93101
+ (805) 963-9431
+
+ This software may be duplicated and used on systems
+ which are licensed to run U.C. Berkeley versions of
+ the UNIX operating system. Any duplication of any
+ part of this software must include a copy of ACC's
+ copyright notice.
+
+
+File:
+ if_ddnreg.h
+
+Author:
+ Art Berggreen
+
+Project:
+ 4.2 DDN X.25 network driver
+
+Function:
+ This file contains definitions of the hardware
+ interface of the ACP625 (IF-11/X25).
+
+Components:
+
+Revision History:
+ 16-May-1985: V1.0 - First release.
+ Art Berggreen.
+
+\************************************************************************/
+\f
+
+/* if_ddnvar.h V1.0 5/16/85 */
+
+/*
+ * ACC IF-11/DDN-X25 interface
+ */
+
+struct ddnregs { /* device registers */
+ u_short csr; /* control and status register */
+ u_char iochn; /* logical channel */
+ u_char ioadx; /* address extension (A16,A17) */
+ u_short ioadl; /* buffer address (A0-A15) */
+ u_short iocnt; /* byte count */
+ u_char iofcn; /* UMC funciton code */
+ u_char iosbf; /* UMC subfunction code */
+ u_char ioini; /* comm regs valid flag */
+ u_char staack; /* interrupt acknowledge flag */
+ u_char ionmi; /* NMI routine active flag */
+ u_char xfrgnt; /* UMR transfer grant flag */
+ u_char stachn; /* interrupt channel number */
+ u_char statyp; /* interrupt type code */
+ u_char stacc; /* completion function code */
+ u_char stacs; /* completion subfunction code */
+ u_short stacnt; /* completion byte count */
+};
+
+#define iovect iochn
+
+/* defines for CSR */
+
+#define DDN_UER 0100000 /* UMC error condition */
+#define DDN_NXM 0040000 /* non-existent memory error */
+#define DDN_PER 0020000 /* UNIBUS parity error */
+#define DDN_ZRUN 0010000 /* Z80 running */
+#define DDN_ZGO 0004000 /* Z80 not in wait state */
+#define DDN_MBLK 0000200 /* memory swap state (0=main, 1=srv) */
+#define DDN_SRV 0000100 /* select UMC service memory */
+#define DDN_MAIN 0000040 /* select UMC main memory */
+#define DDN_DMA 0000020 /* DMA enable */
+#define DDN_WRT 0000010 /* DMA write enable */
+#define DDN_IEN 0000004 /* interrupt enable */
+#define DDN_RST 0000002 /* reset */
+#define DDN_NMI 0000001 /* cause NMI */
+
+#define DDN_BITS \
+"\10\20UER\17NXM\16PER\15ZRUN\14ZGO\10MBLK\7SRV\6MAIN\5DMA\4WRT\3IEN\2RST\1NMI"
+
+/* start i/o function code definitions */
+
+#define DDNWRT 0 /* write to if-11 */
+#define DDNRDB 1 /* read from if-11 */
+#define DDNSTR 2 /* stream flag */
+#define DDNEOS (4|DDNSTR) /* end of stream flag */
+#define DDNABT 8 /* abort flag */
+#define DDNUMR 16 /* UMR protocol flag */
+
+/* interrupt type definitions */
+
+#define DDNSACK 0 /* start i/o ack */
+#define DDNDONE 1 /* i/o completion */
+#define DDNXREQ 2 /* UMR protocol transfer request */
+
+/* i/o completion codes */
+
+#define DDNIOCOK 0001 /* successful completion */
+#define DDNIOCOKP 0002 /* successful completion, more data pending */
+#define DDNIOCABT 0361 /* i/o aborted */
+#define DDNIOCERR 0321 /* program error */
+#define DDNIOCOVR 0363 /* overrun error */
+#define DDNIOCUBE 0374 /* non-existant memory or unibus error */
+
+/* UMR protocol transfer grant code definitions */
+
+#define DDNXEVN 1 /* start with even address */
+#define DDNXODD 2 /* start with odd address */
+#define DDNNUMR 4 /* non-UMR transfer */
+#define DDNXABT 8 /* abort transfer */
--- /dev/null
+/* @(#)if_ddnvar.h 7.1 (Berkeley) 6/5/86 */
+
+
+
+/************************************************************************\
+
+ ________________________________________________________
+ / \
+ | AAA CCCCCCCCCCCCCC CCCCCCCCCCCCCC |
+ | AAAAA CCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC |
+ | AAAAAAA CCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCC |
+ | AAAA AAAA CCCC CCCC |
+ | AAAA AAAA CCCC CCCC |
+ | AAAA AAAA CCCC CCCC |
+ | AAAA AAAA CCCC CCCC |
+ | AAAA AAAAAAAAAAA CCCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCCC |
+ | AAAA AAAAAAAAAAA CCCCCCCCCCCCCCCC CCCCCCCCCCCCCCCC |
+ | AAAA AAAAAAAAA CCCCCCCCCCCCCC CCCCCCCCCCCCCC |
+ \________________________________________________________/
+
+ Copyright (c) 1985 by Advanced Computer Communications
+ 720 Santa Barbara Street, Santa Barbara, California 93101
+ (805) 963-9431
+
+ This software may be duplicated and used on systems
+ which are licensed to run U.C. Berkeley versions of
+ the UNIX operating system. Any duplication of any
+ part of this software must include a copy of ACC's
+ copyright notice.
+
+
+File:
+ if_ddnvar.h
+
+Author:
+ Art Berggreen
+
+Project:
+ 4.2 DDN X.25 network driver
+
+Function:
+ This file contains definitions used to control and
+ track the status of the ACP625 (IF-11/X25).
+
+Components:
+
+Revision History:
+ 16-May-1985: V1.0 - First release.
+ Art Berggreen.
+
+\************************************************************************/
+\f
+
+/* if_ddnvar.h V1.0 5/16/85 */
+
+/* program parameters */
+
+#define DDNMTU 1006 /* maximum IP msg length */
+#define DDN_OQMAX 8 /* max IP msgs on LCN output q */
+#define NDDNCH 32 /* number of X.25 channels */
+#define DELAY_CNT 50000
+#define DDN_TIMEOUT 10
+
+#define DC_OBUSY 0x01
+
+typedef unsigned char byte;
+typedef int boolean;
+
+/* X25 LCN state definitions */
+#define LC_DOWN 0 /* X25 circuit down */
+#define LC_RESTART 1 /* X25 circuit restarting */
+#define LC_IDLE 2 /* X25 circuit not in use */
+#define LC_CALL_PENDING 3 /* X25 circuit call pending */
+#define LC_DATA_IDLE 4 /* X25 circuit open */
+#define LC_CLR_PENDING 5 /* X25 circuit clear pending */
+
+/* Timeout definitions */
+#define TMO_OFF 0 /* timer off */
+#define TMO_RESTART ( 90/DDN_TIMEOUT) /* restart timeout */
+#define TMO_CALL_PENDING (180/DDN_TIMEOUT) /* call timeout */
+#define TMO_DATA_IDLE ( 30/DDN_TIMEOUT) /* idle circuit timeout */
+#define TMO_CLR_PENDING ( 30/DDN_TIMEOUT) /* clear timeout */
+
+/* Link status codes */
+#define LINK_DOWN 0x00 /* Link layer is down */
+#define LINK_UP 0x01 /* Link layer is up */
+
+/* Line control codes */
+#define LINK_DISABLE 0x00 /* Disable link layer */
+#define LINK_ENABLE 0x01 /* Enable link layer */
+#define LINK_LOOPBACK 0x42 /* Link layer loopback mode */
+#define LOOP_OFF 0x00 /* Loopback off */
+#define LOOP_EXTERNAL 0x01 /* Loopback external */
+#define LOOP_INTERNAL 0x03 /* Loopback internal */
+#define PKT_SIZE 0x90 /* Packet size */
+#define PKT_WINDOW 0x4f /* Packet window */
+
+/* X25 supervisor message codes */
+#define CALL 0x00 /* outgoing call */
+#define RING 0x01 /* incoming call */
+#define CLEARVC 0x02 /* clear by VCN */
+#define ANSWER 0x03 /* answer call */
+#define CLEARLC 0x04 /* clear by LCN */
+#define RESET 0x20 /* reset LCN */
+#define RESET_ACK 0x21 /* reset ack */
+#define INTERRUPT 0x22 /* X25 interrupt */
+#define READY 0x23 /* flow control ready */
+#define INTR_ACK 0x24 /* interrupt ack */
+#define RESTART 0x40 /* X25 restart */
+#define RSTRT_ACK 0x41 /* restart ack */
+#define SYS_STATUS 0x42 /* system status msg */
+#define LINE_CNTL 0x60 /* link control cmnd */
+#define LINE_STATUS 0x61 /* link status resp */
+
+/* X25 facilities */
+#define X25_FACIL_DDN 0x04 /* DDN mode facility */
+#define FAC_DDNSTD 0x01 /* DDN standard mode */
+
+/* X25 protocols */
+#define X25_PROTO_IP 0xcc /* X25 IP protocol type code */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_dereg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * DEC DEUNA interface
+ */
+struct dedevice {
+ union {
+ short p0_w;
+ char p0_b[2];
+ } u_p0;
+#define pcsr0 u_p0.p0_w
+#define pclow u_p0.p0_b[0]
+#define pchigh u_p0.p0_b[1]
+ short pcsr1;
+ short pcsr2;
+ short pcsr3;
+};
+
+/*
+ * PCSR 0 bit descriptions
+ */
+#define PCSR0_SERI 0x8000 /* Status error interrupt */
+#define PCSR0_PCEI 0x4000 /* Port command error interrupt */
+#define PCSR0_RXI 0x2000 /* Receive done interrupt */
+#define PCSR0_TXI 0x1000 /* Transmit done interrupt */
+#define PCSR0_DNI 0x0800 /* Done interrupt */
+#define PCSR0_RCBI 0x0400 /* Receive buffer unavail intrpt */
+#define PCSR0_FATI 0x0100 /* Fatal error interrupt */
+#define PCSR0_INTR 0x0080 /* Interrupt summary */
+#define PCSR0_INTE 0x0040 /* Interrupt enable */
+#define PCSR0_RSET 0x0020 /* DEUNA reset */
+#define PCSR0_CMASK 0x000f /* command mask */
+
+#define PCSR0_BITS "\20\20SERI\17PCEI\16RXI\15TXI\14DNI\13RCBI\11FATI\10INTR\7INTE\6RSET"
+
+/* bits 0-3 are for the PORT_COMMAND */
+#define CMD_NOOP 0x0
+#define CMD_GETPCBB 0x1 /* Get PCB Block */
+#define CMD_GETCMD 0x2 /* Execute command in PCB */
+#define CMD_STEST 0x3 /* Self test mode */
+#define CMD_START 0x4 /* Reset xmit and receive ring ptrs */
+#define CMD_BOOT 0x5 /* Boot DEUNA */
+#define CMD_PDMD 0x8 /* Polling demand */
+#define CMD_TMRO 0x9 /* Sanity timer on */
+#define CMD_TMRF 0xa /* Sanity timer off */
+#define CMD_RSTT 0xb /* Reset sanity timer */
+#define CMD_STOP 0xf /* Suspend operation */
+
+/*
+ * PCSR 1 bit descriptions
+ */
+#define PCSR1_XPWR 0x8000 /* Transceiver power BAD */
+#define PCSR1_ICAB 0x4000 /* Interconnect cabling BAD */
+#define PCSR1_STCODE 0x3f00 /* Self test error code */
+#define PCSR1_PCTO 0x0080 /* Port command timed out */
+#define PCSR1_ILLINT 0x0040 /* Illegal interrupt */
+#define PCSR1_TIMEOUT 0x0020 /* Timeout */
+#define PCSR1_POWER 0x0010 /* Power fail */
+#define PCSR1_RMTC 0x0008 /* Remote console reserved */
+#define PCSR1_STMASK 0x0007 /* State */
+
+/* bit 0-3 are for STATE */
+#define STAT_RESET 0x0
+#define STAT_PRIMLD 0x1 /* Primary load */
+#define STAT_READY 0x2
+#define STAT_RUN 0x3
+#define STAT_UHALT 0x5 /* UNIBUS halted */
+#define STAT_NIHALT 0x6 /* NI halted */
+#define STAT_NIUHALT 0x7 /* NI and UNIBUS Halted */
+
+#define PCSR1_BITS "\20\20XPWR\17ICAB\10PCTO\7ILLINT\6TIMEOUT\5POWER\4RMTC"
+
+/*
+ * Port Control Block Base
+ */
+struct de_pcbb {
+ short pcbb0; /* function */
+ short pcbb2; /* command specific */
+ short pcbb4;
+ short pcbb6;
+};
+
+/* PCBB function codes */
+#define FC_NOOP 0x00 /* NO-OP */
+#define FC_LSUADDR 0x01 /* Load and start microaddress */
+#define FC_RDDEFAULT 0x02 /* Read default physical address */
+#define FC_RDPHYAD 0x04 /* Read physical address */
+#define FC_WTPHYAD 0x05 /* Write physical address */
+#define FC_RDMULTI 0x06 /* Read multicast address list */
+#define FC_WTMULTI 0x07 /* Read multicast address list */
+#define FC_RDRING 0x08 /* Read ring format */
+#define FC_WTRING 0x09 /* Write ring format */
+#define FC_RDCNTS 0x0a /* Read counters */
+#define FC_RCCNTS 0x0b /* Read and clear counters */
+#define FC_RDMODE 0x0c /* Read mode */
+#define FC_WTMODE 0x0d /* Write mode */
+#define FC_RDSTATUS 0x0e /* Read port status */
+#define FC_RCSTATUS 0x0f /* Read and clear port status */
+#define FC_DUMPMEM 0x10 /* Dump internal memory */
+#define FC_LOADMEM 0x11 /* Load internal memory */
+#define FC_RDSYSID 0x12 /* Read system ID parameters */
+#define FC_WTSYSID 0x13 /* Write system ID parameters */
+#define FC_RDSERAD 0x14 /* Read load server address */
+#define FC_WTSERAD 0x15 /* Write load server address */
+
+/*
+ * Unibus Data Block Base (UDBB) for ring buffers
+ */
+struct de_udbbuf {
+ short b_tdrbl; /* Transmit desc ring base low 16 bits */
+ char b_tdrbh; /* Transmit desc ring base high 2 bits */
+ char b_telen; /* Length of each transmit entry */
+ short b_trlen; /* Number of entries in the XMIT desc ring */
+ short b_rdrbl; /* Receive desc ring base low 16 bits */
+ char b_rdrbh; /* Receive desc ring base high 2 bits */
+ char b_relen; /* Length of each receive entry */
+ short b_rrlen; /* Number of entries in the RECV desc ring */
+};
+
+/*
+ * Transmit/Receive Ring Entry
+ */
+struct de_ring {
+ short r_slen; /* Segment length */
+ short r_segbl; /* Segment address (low 16 bits) */
+ char r_segbh; /* Segment address (hi 2 bits) */
+ u_char r_flags; /* Status flags */
+ u_short r_tdrerr; /* Errors */
+#define r_lenerr r_tdrerr
+ short r_rid; /* Request ID */
+};
+
+#define XFLG_OWN 0x80 /* If 0 then owned by driver */
+#define XFLG_ERRS 0x40 /* Error summary */
+#define XFLG_MTCH 0x20 /* Address match on xmit request */
+#define XFLG_MORE 0x10 /* More than one entry required */
+#define XFLG_ONE 0x08 /* One collision encountered */
+#define XFLG_DEF 0x04 /* Transmit deferred */
+#define XFLG_STP 0x02 /* Start of packet */
+#define XFLG_ENP 0x01 /* End of packet */
+
+#define XFLG_BITS "\10\10OWN\7ERRS\6MTCH\5MORE\4ONE\3DEF\2STP\1ENP"
+
+#define XERR_BUFL 0x8000 /* Buffer length error */
+#define XERR_UBTO 0x4000 /* UNIBUS tiemout
+#define XERR_LCOL 0x1000 /* Late collision */
+#define XERR_LCAR 0x0800 /* Loss of carrier */
+#define XERR_RTRY 0x0400 /* Failed after 16 retries */
+#define XERR_TDR 0x03ff /* TDR value */
+
+#define XERR_BITS "\20\20BUFL\17UBTO\15LCOL\14LCAR\13RTRY"
+
+#define RFLG_OWN 0x80 /* If 0 then owned by driver */
+#define RFLG_ERRS 0x40 /* Error summary */
+#define RFLG_FRAM 0x20 /* Framing error */
+#define RFLG_OFLO 0x10 /* Message overflow */
+#define RFLG_CRC 0x08 /* CRC error */
+#define RFLG_STP 0x02 /* Start of packet */
+#define RFLG_ENP 0x01 /* End of packet */
+
+#define RFLG_BITS "\10\10OWN\7ERRS\6FRAM\5OFLO\4CRC\2STP\1ENP"
+
+#define RERR_BUFL 0x8000 /* Buffer length error */
+#define RERR_UBTO 0x4000 /* UNIBUS tiemout */
+#define RERR_NCHN 0x2000 /* No data chaining */
+#define RERR_MLEN 0x0fff /* Message length */
+
+#define RERR_BITS "\20\20BUFL\17UBTO\16NCHN"
+
+/* mode description bits */
+#define MOD_HDX 0x0001 /* Half duplex mode */
+#define MOD_LOOP 0x0004 /* Enable internal loopback */
+#define MOD_DTCR 0x0008 /* Disables CRC generation */
+#define MOD_DMNT 0x0200 /* Disable maintenance features */
+#define MOD_ECT 0x0400 /* Enable collision test */
+#define MOD_TPAD 0x1000 /* Transmit message pad enable */
+#define MOD_DRDC 0x2000 /* Disable data chaining */
+#define MOD_ENAL 0x4000 /* Enable all multicast */
+#define MOD_PROM 0x8000 /* Enable promiscuous mode */
+
+struct de_buf {
+ struct ether_header db_head; /* header */
+ char db_data[ETHERMTU]; /* packet data */
+ int db_crc; /* CRC - on receive only */
+};
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_dmc.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * DMC-11 Interface
+ */
+
+struct dmcdevice {
+ char bsel0;
+ char bsel1;
+ char bsel2;
+ char bsel3;
+ short sel4;
+ short sel6;
+};
+
+/*
+ * dmc software packet encapsulation. This allows the dmc
+ * link to be multiplexed among several protocols.
+ * The first eight bytes of the dmc header are garbage,
+ * since on a vax the uba has been known to mung these
+ * bytes. The next two bytes encapsulate packet type.
+ */
+struct dmc_header {
+ char dmc_buf[8]; /* space for uba on vax */
+ short dmc_type; /* encapsulate packet type */
+};
+
+/* packet types */
+#define DMC_IPTYPE 1
+#define DMC_TRAILER 2
+#define DMC_NTRAILER 16
+
+/*
+ * DMCMTU includes space for data (1024) +
+ * protocol header (256) + trailer descriptor (4).
+ * The software link encapsulation header (dmc_header)
+ * is handled separately.
+ */
+#define DMCMTU 1284
+
+#define RDYSCAN 16 /* loop delay for RDYI after RQI */
+
+/* defines for bsel0 */
+#define DMC_BACCI 0
+#define DMC_CNTLI 1
+#define DMC_PERR 2
+#define DMC_BASEI 3
+#define DMC_WRITE 0 /* transmit block */
+#define DMC_READ 4 /* read block */
+#define DMC_RQI 0040 /* port request bit */
+#define DMC_IEI 0100 /* enable input interrupts */
+#define DMC_RDYI 0200 /* port ready */
+#define DMC0BITS "\10\8RDI\7IEI\6RQI"
+
+/* defines for bsel1 */
+#define DMC_MCLR 0100 /* DMC11 Master Clear */
+#define DMC_RUN 0200 /* clock running */
+#define DMC1BITS "\10\8RUN\7MCLR"
+
+/* defines for bsel2 */
+#define DMC_BACCO 0
+#define DMC_CNTLO 1
+#define DMC_OUX 0 /* transmit block */
+#define DMC_OUR 4 /* read block */
+#define DMC_IEO 0100 /* enable output interrupts */
+#define DMC_RDYO 0200 /* port available */
+#define DMC2BITS "\10\8RDO\7IEO"
+
+/* defines for CNTLI mode */
+#define DMC_HDPLX 02000 /* half duplex DDCMP operation */
+#define DMC_SEC 04000 /* half duplex secondary station */
+#define DMC_MAINT 00400 /* enter maintenance mode */
+
+/* defines for BACCI/O and BASEI mode */
+#define DMC_XMEM 0140000 /* xmem bit position */
+#define DMC_CCOUNT 0037777 /* character count mask */
+#define DMC_RESUME 0002000 /* resume (BASEI only) */
+
+/* defines for CNTLO */
+#define DMC_CNTMASK 01777
+
+#define DMC_DATACK 01
+#define DMC_TIMEOUT 02
+#define DMC_NOBUFS 04
+#define DMC_MAINTREC 010
+#define DMC_LOSTDATA 020
+#define DMC_DISCONN 0100
+#define DMC_START 0200
+#define DMC_NEXMEM 0400
+#define DMC_ERROR 01000
+
+#define DMC_FATAL (DMC_ERROR|DMC_NEXMEM|DMC_START|DMC_LOSTDATA|DMC_MAINTREC)
+#define CNTLO_BITS \
+ "\10\12ERROR\11NEXMEM\10START\7DISC\5LSTDATA\4MAINT\3NOBUF\2TIMEO\1DATACK"
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_ecreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * 3Com Ethernet controller registers.
+ */
+struct ecdevice {
+ short ec_rcr; /* Receive Control Register */
+ short ec_xcr; /* Transmit Control Register */
+};
+
+/*
+ * Control and status bits -- rcr
+ */
+#define EC_SPIE 0x8000 /* set parity interrupt enable */
+#define EC_ASTEP 0x4000 /* increment address counter */
+#define EC_AROM 0x2000 /* 1: Use address ROM, 0: use RAM */
+#define EC_PE 0x2000 /* Parity error */
+#define EC_AWCLK 0x1000 /* address write clock bit */
+#define EC_PIE 0x1000 /* Parity interrupt enable (read) */
+#define EC_ADATA 0x0f00 /* address/filtering */
+#define EC_RDONE 0x0080 /* receive done */
+#define EC_MDISAB 0x0080 /* memory disable */
+#define EC_RINTEN 0x0040 /* receive interrupt enable */
+#define EC_RCLR 0x0020 /* clear RDONE bit */
+#define EC_RWBN 0x0010 /* submit buffer for receive */
+#define EC_RBN 0x000f /* buffer number */
+
+#define EC_RBITS "\10\16PE\15PIE\10RDONE\7RINTEN"
+
+/*
+ * Control and status bits -- xcr
+ */
+#define EC_JAM 0x8000 /* collision dectected */
+#define EC_JINTEN 0x4000 /* collision interrupt enable */
+#define EC_JCLR 0x2000 /* clear collision detect */
+#define EC_UECLR 0x0100 /* reset controller */
+#define EC_XDONE 0x0080 /* transmit done */
+#define EC_XINTEN 0x0040 /* transmit interrupt enable */
+#define EC_XCLR 0x0020 /* clear XDONE bit */
+#define EC_XWBN 0x0010 /* submit buffer for transmit */
+#define EC_XBN 0x000f /* buffer number */
+
+#define EC_XBITS "\10\20JAM\17JINTEN\10XDONE\7XINTEN"
+
+/*
+ * Useful combinations
+ */
+#define EC_READ (0x600|EC_RINTEN|EC_RWBN)
+#define EC_WRITE (EC_JINTEN|EC_XINTEN|EC_XWBN)
+#define EC_CLEAR (EC_JINTEN|EC_XINTEN|EC_JCLR)
+
+/*
+ * Buffer number definitions
+ */
+#define ECTBF 0 /* Buffer for transmit */
+#define ECRLBF 1 /* First buffer for receive */
+#define ECRHBF 15 /* Last buffer for receive */
+
+#define ECRDOFF 528 /* Packet offset in read buffer */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_en.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Structure of a Ethernet header.
+ */
+struct en_header {
+ u_char en_shost;
+ u_char en_dhost;
+ u_short en_type;
+};
+
+#define ENTYPE_PUP 0x0200 /* PUP protocol */
+#define ENTYPE_IP 0x0201 /* IP protocol */
+
+/*
+ * The ENTYPE_NTRAILER packet types starting at
+ * ENTYPE_TRAIL have (type-ENTYPE_TRAIL)*512 bytes
+ * of data followed by an Ethernet type (as given above)
+ * and then the (variable-length) header.
+ */
+#define ENTYPE_TRAIL 0x1000 /* Trailer type */
+#define ENTYPE_NTRAILER 16
+
+#define EN_BROADCAST 0 /* Hardware broadcast address */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_enreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Xerox experimental ethernet registers.
+ *
+ * N.B.: status register and device address are read/write,
+ * device address is read-only, rest are WRITE ONLY!
+ */
+struct endevice {
+ short en_owc; /* output word count (10 bits) */
+ short en_oba; /* output buffer address */
+ short en_ostat; /* output control and status */
+ short en_odelay; /* output start delay, 25usec units */
+ short en_iwc; /* input word count */
+ short en_iba; /* input buffer address */
+ short en_istat; /* input csr */
+ short en_addr; /* ~device address (low 8 bits) */
+};
+
+/*
+ * Control and status bits.
+ */
+#define EN_IERROR 0x8000 /* CRC error, buf ovflo or overrun */
+#define EN_OERROR 0x8000 /* collision or output underrun */
+#define EN_OPDONE 0x0080 /* previous operation completed */
+#define EN_IEN 0x0040 /* enable interrupt when DONE */
+#define EN_PROMISCUOUS 0x0002 /* promiscuous, input any packet */
+#define EN_GO 0x0001 /* start op bit */
+
+#define EN_BITS "\10\20ERR\10OPDONE\7IEN\2PROM\1GO"
+
+#define spl_enet() spl5()
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_exreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+
+struct exdevice {
+ char xd_porta; /* write on porta resets EXOS */
+ char xd_pad_a;
+ char xd_portb; /* write on portb interrupts EXOS */
+ /* read on portb returns status bits */
+ char xd_pad_b;
+};
+
+/* EXOS I/O PORT A write definitions */
+#define EX_RESET 0 /* value doesn't really matter... */
+
+/* EXOS I/O PORT B write definitions */
+#define EX_NTRUPT 0
+
+/* EXOS I/O PORT B read definitions */
+#define EX_TESTOK 1 /* set when self-diagnostics passed */
+#define EX_UNREADY (1<<3) /* set until EXOS ready to read from B */
+
+/* message buffer status field definitions */
+#define MH_OWNER 1 /* mask for status bit for owner */
+#define MH_HOST 0 /* if 0, the host owns the buffer */
+#define MH_EXOS 1 /* if 1, the EXOS owns the buffer */
+
+/* EXOS Link Level request codes */
+#define LLTRANSMIT 0xC /* send a packet */
+#define LLRTRANSMIT 0xE /* send a packet, and self-receive */
+#define LLRECEIVE 0xD /* receive a packet */
+#define LLNET_MODE 0x8 /* read/write mode control objects */
+#define LLNET_ADDRS 0x9 /* read/write receive address slots */
+#define LLNET_RECV 0xA /* read/alter receive slot enable bit */
+#define LLNET_STSTCS 0xB /* read/reset network statistics objects */
+
+/* Link Level return codes common to all requests */
+#define LL_OK 0 /* successful completion */
+#define LLX_MODE 0xA1 /* EXOS not in link level mode (impossible) */
+
+/* LLTRANSMIT unique return codes */
+#define LLXM_1RTRY 0x1 /* successful xmission, 1 retry */
+#define LLXM_RTRYS 0x2 /* successful xmission, more than 1 retry */
+#define LLXM_NSQE 0x8 /* successful xmission, no SQE TEST signal */
+#define LLXM_CLSN 0x10 /* xmission failed, excess retries */
+#define LLXM_NCS 0x20 /* xmission failed, no carrier sense */
+#define LLXM_LNGTH 0x40 /* xmission failed, bad packet length */
+#define XMIT_BITS "\7\7LENGTH\6CARRIER\5XCLSNS\4SQETST"
+#define LLXM_ERROR (LLXM_NSQE|LLXM_CLSN|LLXM_NCS|LLXM_LNGTH)
+
+/* LLRECEIVE unique return codes */
+#define LLRC_TRUNC 0x4 /* pkt received, but truncated to fit buffer */
+#define LLRC_ALIGN 0x10 /* pkt received, but with alignment error */
+#define LLRC_CRC 0x20 /* pkt received, but with CRC error */
+#define LLRC_BUFLEN 0x40 /* no pkt received, buffer less than 64 bytes */
+ /* this should never happen here */
+#define RECV_BITS "\7\7BUFLEN\6CRC\5ALIGN\3TRUNC"
+
+/* LLNET_ADDRS unique return codes */
+#define LLNA_BADSLOT 0xD1 /* slot doesn't exist or can't be accessed */
+#define LLNA_BADADDR 0xD3 /* invalid address for designated slot */
+
+/* LLNET_RECV unique return codes */
+#define LLNR_BADSLOT 0xD1 /* slot doesn't exist or can't be accessed */
+#define LLNR_BADADDR 0xD2 /* designated slot was empty */
+
+/* address slot object indices */
+#define NULLSLOT 0 /* the null slot */
+#define MINMCSLOT 1 /* minimum multicast slot index */
+#define MAXMCSLOT 8 /* default maximum multicast slot index */
+#define PHYSSLOT 253 /* physical slot index */
+#define UNVRSSLOT 254 /* universal slot index */
+#define BROADSLOT 255 /* broadcast slot index */
+
+/* request mask bit definitions */
+#define WRITE_OBJ 1 /* write the object */
+#define READ_OBJ 2 /* read the object */
+#define ENABLE_RCV 4 /* enable reception on designated slot */
+
+/* NET_MODE options mask bit definitions */
+#define OPT_ALIGN 0x10 /* receive packets with alignment errors */
+#define OPT_CRC 0x20 /* receive packets with CRC errors */
+#define OPT_DSABLE 0x80 /* disconnect controller hardware */
+
+/* NET_MODE mode field value definitions */
+#define MODE_OFF 0 /* stop transmission and reception */
+#define MODE_PERF 1 /* perfect multicast address filtering */
+#define MODE_HW 2 /* hardware-only multicast address filtering */
+#define MODE_PROM 3 /* promiscuous reception */
+
+#define NFRAGMENTS 1 /* number fragments that the EXOS will scatter/gather */
+#define EXMAXRBUF 1520 /* per EXOS 101 manual 5.3.7 (maybe 1518 would do) */
+
+/*
+ * N.B. Structures below are carefully constructed so that
+ * they correspond to the message formats that NX firmware
+ * defines. None of them should contain any compiler-instigated
+ * padding. Be especially careful about VAX C longword alignment!
+ */
+
+struct stat_array {
+ u_long sa_fsent; /* frames sent without errors */
+ u_long sa_xsclsn; /* frames aborted excess collisions */
+ u_long sa_nsqe; /* frames subject to heartbeat failure */
+ u_long sa_undef; /* undefined (TDR on EXOS 101) */
+ u_long sa_frcvd; /* frames received no errors */
+ u_long sa_align; /* frames received alignment error */
+ u_long sa_crc; /* frames received crc error */
+ u_long sa_flost; /* frames lost */
+};
+
+struct buf_blk { /* packet/buffer block descriptor */
+ u_short bb_len; /* length of block, in bytes */
+ u_short bb_addr[2]; /* address of block */
+ /*
+ * Array above is really a single u_long field.
+ * We kludge its definition to defeat word-alignment.
+ * Access would look like:
+ * longaddr = *(u_long *)bp->.mb_er.er_blks[0].bb_addr;
+ */
+};
+
+struct net_mode { /* read/write mode control objects */
+/*12*/ u_char nm_rqst; /* request code */
+/*13*/ u_char nm_rply; /* reply code */
+/*14*/ u_char nm_mask; /* bit-wise switches for read, write */
+/*15*/ u_char nm_optn; /* acceptable packet reception errors */
+/*16*/ u_char nm_mode; /* EXOS filtering mode */
+/*17*/
+};
+
+struct net_addrs { /* read/write receive address slots */
+/*12*/ u_char na_rqst; /* request code */
+/*13*/ u_char na_rply; /* reply code */
+/*14*/ u_char na_mask; /* bit-wise switches for read, write */
+/*15*/ u_char na_slot; /* index of address slot */
+/*16*/ u_char na_addrs[6]; /* address read and/or written */
+/*22*/
+};
+
+struct net_recv { /* read/alter receive slot enable bit */
+/*12*/ u_char nr_rqst; /* request code */
+/*13*/ u_char nr_rply; /* reply code */
+/*14*/ u_char nr_mask; /* bit-wise switches for read, write */
+/*15*/ u_char nr_slot; /* index of address slot */
+/*16*/
+};
+
+struct net_ststcs { /* read/reset network statistics objects */
+/*12*/ u_char ns_rqst; /* request code */
+/*13*/ u_char ns_rply; /* reply code */
+/*14*/ u_char ns_mask; /* bit-wise switches for read, write */
+/*15*/ u_char ns_rsrv; /* reserved for EXOS */
+/*16*/ u_short ns_nobj; /* number of objects to work on */
+/*18*/ u_short ns_xobj; /* index of first object to work on */
+/*20*/ u_long ns_bufp; /* pointer to statistics buffer */
+/*24*/
+};
+
+struct enet_xmit { /* send a packet on the Ethernet */
+/*12*/ u_char et_rqst; /* request code */
+/*13*/ u_char et_rply; /* reply code */
+/*14*/ u_char et_slot; /* address slot matching dest address */
+/*15*/ u_char et_nblock; /* number of blocks composing packet */
+/*16*/ struct buf_blk et_blks[NFRAGMENTS]; /* array of block descriptors */
+/*22-64*/
+};
+
+struct enet_recv { /* receive a packet on the Ethernet */
+/*12*/ u_char er_rqst; /* request code */
+/*13*/ u_char er_rply; /* reply code */
+/*14*/ u_char er_slot; /* address slot matching dest address */
+/*15*/ u_char er_nblock; /* number of blocks composing buffer */
+/*16*/ struct buf_blk er_blks[NFRAGMENTS]; /* array of block descriptors */
+/*22-64*/
+};
+
+/* we send requests and receive replys with the EXOS using this structure */
+struct ex_msg {
+/*00*/ u_short mb_link; /* address of next message buffer */
+/*02*/ u_char mb_rsrv; /* reserved for use by EXOS */
+/*03*/ u_char mb_status; /* used bit-wise for message protocol */
+/*04*/ u_short mb_length; /* length, in bytes, of the rest */
+/*06*/ short mb_1rsrv; /* reserved for used by EXOS */
+/*08*/ long mb_mid; /* available to user */
+/*12*/ union mb_all {
+ struct net_mode mb_net_mode;
+ struct net_addrs mb_net_addrs;
+ struct net_recv mb_net_recv;
+ struct net_ststcs mb_net_ststcs;
+ struct enet_xmit mb_enet_xmit;
+ struct enet_recv mb_enet_recv;
+ } mb_all;
+/* following field is used only by host, not read by board */
+ struct ex_msg *mb_next; /* host's pointer to next message */
+};
+#define mb_nm mb_all.mb_net_mode
+#define mb_na mb_all.mb_net_addrs
+#define mb_nr mb_all.mb_net_recv
+#define mb_ns mb_all.mb_net_ststcs
+#define mb_et mb_all.mb_enet_xmit
+#define mb_er mb_all.mb_enet_recv
+#define mb_rqst mb_nm.nm_rqst
+#define mb_rply mb_nm.nm_rply
+#define MBDATALEN (sizeof(union mb_all)+6)
+
+struct confmsg {
+/*00*/ u_short cm_1rsrv; /* reserved, must be 1 */
+/*02*/ char cm_vc[4]; /* returns ASCII version code */
+/*06*/ u_char cm_cc; /* returns config completion code */
+/*07*/ u_char cm_opmode; /* specifies operation mode */
+/*08*/ u_short cm_dfo; /* specifies host data format option */
+/*10*/ u_char cm_dcn1; /* reserved, must be 1 */
+/*11*/ u_char cm_2rsrv[2]; /* reserved, must be 0 */
+/*13*/ u_char cm_ham; /* specifies host address mode */
+/*14*/ u_char cm_3rsrv; /* reserved, must be 0 */
+/*15*/ u_char cm_mapsiz; /* reserved, must be 0 */
+/*16*/ u_char cm_byteptrn[4]; /* host data format option test pattern */
+/*20*/ u_short cm_wordptrn[2];
+/*24*/ u_long cm_lwordptrn;
+/*28*/ u_char cm_rsrvd[20];
+/*48*/ u_long cm_mba; /* use 0xFFFFFFFF in link level mode */
+/*52*/ u_char cm_nproc; /* use 0xFF in link level mode */
+/*53*/ u_char cm_nmbox; /* use 0xFF in link level mode */
+/*54*/ u_char cm_nmcast; /* use 0xFF in link level mode */
+/*55*/ u_char cm_nhost; /* use 1 in link level mode */
+
+ /* the next five parameters define the request message queue */
+/*56*/ u_long cm_h2xba; /* base address of message queue */
+/*60*/ u_short cm_h2xhdr; /* address offset of msg Q header */
+/*62*/ u_char cm_h2xtyp; /* interrupt type */
+/*63*/ u_char cm_h2xval; /* interrupt value (not used) */
+/*64*/ u_short cm_h2xaddr; /* interrupt vector */
+/*66*/ u_short cm_h2xpad; /* pad out unused portion of vector */
+
+ /* the next five parameters define the reply message queue */
+/*68*/ u_long cm_x2hba; /* base address of message queue */
+/*72*/ u_short cm_x2hhdr; /* address offset of msg Q header */
+/*74*/ u_char cm_x2htyp; /* interrupt type */
+/*75*/ u_char cm_x2hval; /* interrupt value (not used) */
+/*76*/ u_short cm_x2haddr; /* interrupt vector */
+/*78*/ u_short cm_x2hpad; /* pad out unused portion of vector */
+/*80*/
+};
+
--- /dev/null
+/* @(#)if_hdhreg.h 7.1 (Berkeley) 6/5/86 */
+
+
+/* $Header$ */
+
+/*
+ * ACC IF-11/HDH interface
+ */
+
+struct hdhregs { /* device registers */
+ u_short csr; /* control and status register */
+ u_char iochn; /* logical channel */
+ u_char ioadx; /* address extension (A16,A17) */
+ u_short ioadl; /* buffer address (A0-A15) */
+ u_short iocnt; /* byte count */
+ u_char iofcn; /* UMC funciton code */
+ u_char iosbf; /* UMC subfunction code */
+ u_char ioini; /* comm regs valid flag */
+ u_char staack; /* interrupt acknowledge flag */
+ u_char ionmi; /* NMI routine active flag */
+ u_char ioxfrg; /* UMR transfer grant flag */
+ u_char stachn; /* interrupt channel number */
+ u_char statyp; /* interrupt type code */
+ u_char stacc; /* completion function code */
+ u_char stacs; /* completion subfunction code */
+ u_short stacnt; /* completion byte count */
+};
+
+/* defines for CSR */
+
+#define HDH_UER 0100000 /* UMC error condition */
+#define HDH_NXM 0040000 /* non-existent memory error */
+#define HDH_PER 0020000 /* UNIBUS parity error */
+#define HDH_ZRUN 0010000 /* Z80 running */
+#define HDH_ZGO 0004000 /* Z80 not in wait state */
+#define HDH_MBLK 0000200 /* memory swap state (0=main, 1=srv) */
+#define HDH_SRV 0000100 /* select UMC service memory */
+#define HDH_MAIN 0000040 /* select UMC main memory */
+#define HDH_DMA 0000020 /* DMA enable */
+#define HDH_WRT 0000010 /* DMA write enable */
+#define HDH_IEN 0000004 /* interrupt enable */
+#define HDH_RST 0000002 /* reset */
+#define HDH_NMI 0000001 /* cause NMI */
+
+#define HDH_BITS \
+"\10\20UER\17NXM\16PER\15ZRUN\14ZGO\10MBLK\7SRV\6MAIN\5DMA\4WRT\3IEN\2RST\1NMI"
+
+/* start i/o function code definitions */
+
+#define HDHWRT 0 /* write to if-11 */
+#define HDHRDB 1 /* read from if-11 */
+#define HDHSTR 2 /* stream flag */
+#define HDHEOS 6 /* end of stream flag */
+#define HDHABT 8 /* abort flag */
+#define HDHUMR 16 /* UMR protocol flag */
+
+/* interrupt type definitions */
+
+#define HDHSACK 0 /* start i/o ack */
+#define HDHDONE 1 /* i/o completion */
+#define HDHXREQ 2 /* UMR protocol transfer request */
+
+/* i/o completion codes */
+
+#define HDHIOCOK 0001 /* successful completion */
+#define HDHIOCOKP 0002 /* successful completion, more data pending */
+#define HDHIOCABT 0361 /* i/o aborted */
+#define HDHIOCERR 0321 /* program error */
+#define HDHIOCOVR 0363 /* overrun error */
+#define HDHIOCUBE 0374 /* non-existant memory or unibus error */
+
+/* UMR protocol transfer grant code definitions */
+
+#define HDHXEVN 1 /* start with even address */
+#define HDHXODD 2 /* start with odd address */
+#define HDHNUMR 4 /* non-UMR transfer */
+#define HDHXABT 8 /* abort transfer */
+
+/* HDH supervisor request code definitions */
+#define HDHINIT 0x42 /* SYSINIT opcode */
+
+#define HDHSUP 0xf0 /* supervisor HDH status/line control prefix */
+#define HDHIMP 0x400 /* IMP line up modifier */
+#define HDHREFL 0x800 /* reflect mode modifier */
+#define HDHINLB 0x1000 /* internal loopback modifier */
+#define HDHEXLP 0x2000 /* external loopback modifier */
+#define HDHRQST (HDHSUP+0x0000) /* line status request */
+#define HDHRQUP (HDHSUP+0x0100) /* line up request */
+#define HDHRQDN (HDHSUP+0x0200) /* line down request */
+
+/* HDH supervisor reply code definitions */
+
+#define HDHIACK (HDHSUP+0x4200) /* line init ack */
+#define HDHLNUP (HDHSUP+0x0100) /* line up reply */
+#define HDHLNDN (HDHSUP+0x0200) /* line down reply */
+#define HDHLNACK (HDHSUP+0x0300) /* ack line up request (but line is down now) */
+#define HDHTIMO (HDHSUP+0x0400) /* line timeout */
+#define HDHLOOP (HDHSUP+0x0500) /* loopback message */
+#define HDHDTERR (HDHSUP+0x0600) /* host data error detected */
+#define HDHSQRCV (HDHSUP+0x0700) /* HDLC sequence error detected by IMP */
+#define HDHSQERR (HDHSUP+0x0800) /* HDLC sequence error detected by if-11 */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_hy.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * 4.2 BSD Unix Kernel - Vax Network Interface Support
+ *
+ * $Header: if_hy.h,v 10.0 84/06/30 19:51:21 steveg Stable $
+ * $Locker: $
+ *
+ * Modifications from Berkeley 4.2 BSD
+ * Copyright (c) 1983, Tektronix Inc.
+ * All Rights Reserved
+ *
+ *
+ * $Log: if_hy.h,v $
+ * Revision 10.0 84/06/30 19:51:21 steveg
+ * Big Build
+ *
+ * Revision 3.13 84/05/30 19:40:58 steveg
+ * update hy_stat to reflect new microcode
+ *
+ * Revision 3.12 84/05/30 19:06:57 steveg
+ * move driver state number definition here from if_hy.c
+ *
+ * Revision 3.11 84/05/30 18:56:15 steveg
+ * add definition of HYE_MAX and HYE_SIZE
+ *
+ * Revision 3.10 84/05/30 17:14:04 steveg
+ * add hyl_filter
+ *
+ * Revision 3.9 84/05/30 13:45:24 steveg
+ * rework logging
+ *
+ * Revision 3.8 84/05/04 05:18:59 steveg
+ * hyr_key now a u_long
+ *
+ * Revision 3.7 84/05/01 22:45:20 steveg
+ * add H_RLOOPBK for A710 remote end loopback command
+ *
+ *
+ */
+
+
+/*
+ * Structure of a HYPERchannel adapter header
+ */
+struct hy_hdr {
+ short hyh_ctl; /* control */
+ short hyh_access; /* access code */
+ union {
+ short hyh_addr;
+ char hyh_baddr[2];
+ } hyh_uto, hyh_ufrom; /* to/from address */
+ short hyh_param; /* parameter word */
+ short hyh_type; /* record type */
+};
+
+
+#define hyh_to hyh_uto.hyh_addr
+#define hyh_to_port hyh_uto.hyh_baddr[1]
+#define hyh_to_adapter hyh_uto.hyh_baddr[0]
+
+#define hyh_from hyh_ufrom.hyh_addr
+#define hyh_from_port hyh_ufrom.hyh_baddr[1]
+#define hyh_from_adapter hyh_ufrom.hyh_baddr[0]
+
+/*
+ * Structure of a HYPERchannel message header (from software)
+ */
+struct hym_hdr {
+ struct {
+ short hymd_mplen; /* message proper len, if associated data */
+ } hym_d;
+ struct hy_hdr hym_h; /* hardware header, MUST BE LAST */
+};
+
+#define hym_mplen hym_d.hymd_mplen
+
+#define hym_ctl hym_h.hyh_ctl
+#define hym_access hym_h.hyh_access
+#define hym_param hym_h.hyh_param
+#define hym_type hym_h.hyh_type
+
+#define hym_to hym_h.hyh_to
+#define hym_to_port hym_h.hyh_to_port
+#define hym_to_adapter hym_h.hyh_to_adapter
+
+#define hym_from hym_h.hyh_from
+#define hym_from_port hym_h.hyh_from_port
+#define hym_from_adapter hym_h.hyh_from_adapter
+
+#define HYM_SWLEN (sizeof(struct hym_hdr) - sizeof(struct hy_hdr))
+
+/*
+ * HYPERchannel header word control bits
+ */
+#define H_XTRUNKS 0x00F0 /* transmit trunks */
+#define H_RTRUNKS 0x000F /* remote trunks to transmit on for loopback */
+#define H_ASSOC 0x0100 /* has associated data */
+#define H_LOOPBK 0x00FF /* loopback command */
+#define H_RLOOPBK 0x008F /* A710 remote loopback command */
+
+/*
+ * Hyperchannel record types
+ */
+#define HYLINK_IP 0 /* Internet Protocol Packet */
+
+/*
+ * Routing database
+ */
+#define HYRSIZE 37 /* max number of adapters in routing tables */
+
+struct hy_route {
+ time_t hyr_lasttime; /* last update time */
+ u_char hyr_gateway[256];
+ struct hyr_hash {
+ u_long hyr_key; /* desired address */
+ u_short hyr_flags; /* status flags - see below */
+ u_short hyr_size; /* number of entries */
+ union {
+ /*
+ * direct entry (can get there directly)
+ */
+ struct {
+ u_short hyru_dst; /* adapter number & port */
+ u_short hyru_ctl; /* trunks to try */
+ u_short hyru_access; /* access code (mostly unused) */
+ } hyr_d;
+#define hyr_dst hyr_u.hyr_d.hyru_dst
+#define hyr_ctl hyr_u.hyr_d.hyru_ctl
+#define hyr_access hyr_u.hyr_d.hyru_access
+ /*
+ * indirect entry (one or more hops required)
+ */
+ struct {
+ u_char hyru_pgate; /* 1st gateway slot */
+ u_char hyru_egate; /* # gateways */
+ u_char hyru_nextgate; /* gateway to use next */
+ } hyr_i;
+#define hyr_pgate hyr_u.hyr_i.hyru_pgate
+#define hyr_egate hyr_u.hyr_i.hyru_egate
+#define hyr_nextgate hyr_u.hyr_i.hyru_nextgate
+ } hyr_u;
+ } hyr_hash[HYRSIZE];
+};
+
+/*
+ * routing table set/get structure
+ *
+ * used to just pass the entire routing table through, but 4.2 ioctls
+ * limit the data part of an ioctl to 128 bytes or so and use the
+ * interface name to get things sent the right place.
+ * see ../net/if.h for additional details.
+ */
+struct hyrsetget {
+ char hyrsg_name[IFNAMSIZ]; /* if name, e.g. "hy0" */
+ struct hy_route *hyrsg_ptr; /* pointer to routing table */
+ unsigned hyrsg_len; /* size of routing table provided */
+};
+
+#define HYR_INUSE 0x01 /* entry in use */
+#define HYR_DIR 0x02 /* direct entry */
+#define HYR_GATE 0x04 /* gateway entry */
+#define HYR_LOOP 0x08 /* hardware loopback entry */
+#define HYR_RLOOP 0x10 /* remote adapter hardware loopback entry */
+
+#define HYRHASH(x) (((x) ^ ((x) >> 16)) % HYRSIZE)
+
+#define HYSETROUTE _IOW(i, 0x80, struct hyrsetget)
+#define HYGETROUTE _IOW(i, 0x81, struct hyrsetget)
+
+struct hylsetget {
+ char hylsg_name[IFNAMSIZ]; /* if name, e.g. "hy0" */
+ int hylsg_cmd; /* logging command */
+ caddr_t hylsg_ptr; /* pointer to table */
+ u_long hylsg_len; /* size of table provided */
+};
+
+#define HYSETLOG _IOW(i, 0x82, struct hylsetget)
+#define HYGETLOG _IOW(i, 0x83, struct hylsetget)
+#define HYGETELOG _IOW(i, 0x84, struct hylsetget)
+
+/*
+ * Structure of Statistics Record (counters)
+ */
+struct hy_stat {
+ u_char hyc_df0[3]; /* # data frames trunk 0 */
+ u_char hyc_df1[3]; /* # data frames trunk 1 */
+ u_char hyc_df2[3]; /* # data frames trunk 2 */
+ u_char hyc_df3[3]; /* # data frames trunk 3 */
+ u_char hyc_cancel[2]; /* # cancel operations */
+ u_char hyc_abort[2]; /* # aborts */
+ u_char hyc_ret0[3]; /* # retransmissions trunk 0 */
+ u_char hyc_ret1[3]; /* # retransmissions trunk 1 */
+ u_char hyc_ret2[3]; /* # retransmissions trunk 2 */
+ u_char hyc_ret3[3]; /* # retransmissions trunk 3 */
+ u_char hyc_atype[3]; /* adapter type and revision level */
+ u_char hyc_uaddr; /* adapter unit number */
+};
+
+/*
+ * Structure of the Status Record
+ */
+struct hy_status {
+ u_char hys_gen_status; /* general status byte */
+ u_char hys_last_fcn; /* last function code issued */
+ u_char hys_resp_trunk; /* trunk response byte */
+ u_char hys_status_trunk; /* trunk status byte */
+ u_char hys_recd_resp; /* recieved response byte */
+ u_char hys_error; /* error code */
+ u_char hys_caddr; /* compressed addr of 1st msg on chain */
+ u_char hys_pad; /* not used */
+};
+
+/*
+ * Get port number from status record
+ */
+#define PORTNUM(p) (((p)->hys_gen_status >> 6) & 0x03)
+
+#define HYL_SIZE 16*1024
+struct hy_log {
+ struct hy_log *hyl_self;
+ u_char hyl_enable; /* logging enabled? */
+ u_char hyl_onerr; /* state to enter on error */
+ u_short hyl_wait; /* number of bytes till next wakeup */
+ u_short hyl_count; /* number of samples till stop */
+ u_short hyl_icount; /* initial value of hyl_count */
+ u_long hyl_filter; /* log items with specific bits set */
+ u_char *hyl_eptr; /* &hy_log.hyl_buf[HYL_SIZE] */
+ u_char *hyl_ptr; /* pointer into hyl_buf */
+ u_char hyl_buf[HYL_SIZE]; /* log buffer space */
+};
+
+#define HYL_NOP 0
+#define HYL_UP 1 /* markup */
+#define HYL_STATUS 2 /* status results (struct hy_status) */
+#define HYL_STATISTICS 3 /* statistics (struct hy_stat) */
+#define HYL_XMIT 4 /* packed being send (struct hym_hdr) */
+#define HYL_RECV 5 /* recieved pkt (short len; struct hym_hdr) */
+#define HYL_CMD 6 /* cmd issued (uchar cmd, state; short count) */
+#define HYL_INT 7 /* interrupt (short csr, wcr) */
+#define HYL_CANCEL 8 /* cancel transmit attempt */
+#define HYL_RESET 9 /* hyinit or unibus reset */
+#define HYL_IOCTL 10 /* hyioctl */
+
+#define HYL_DISABLED 0 /* logging disabled */
+#define HYL_CONTINUOUS 1 /* continuous logging */
+#define HYL_CATCHN 2 /* hyl_count transactions being captured */
+
+/*
+ * error code histograms
+ */
+#define HYE_MAX 0x18 /* maximum adapter error code */
+#define HYE_BINS 4 /* number of command bins */
+#define HYE_SIZE (HYE_MAX+1)*HYE_BINS /* size of histogram buffer */
+
+/*
+ * Requests for service (in order by descending priority).
+ */
+#define RQ_ENDOP 001 /* end the last adapter function */
+#define RQ_REISSUE 002 /* reissue previous cmd after status */
+#define RQ_STATUS 004 /* get the status of the adapter */
+#define RQ_STATISTICS 010 /* get the statistics of the adapter */
+#define RQ_MARKDOWN 020 /* mark this adapter port down */
+#define RQ_MARKUP 040 /* mark this interface up */
+
+#define RQ_XASSOC 0100 /* associated data to transmit */
+
+/*
+ * Driver states.
+ */
+#define STARTUP 0 /* initial state (before fully there) */
+#define IDLE 1 /* idle state */
+#define STATSENT 2 /* status cmd sent to adapter */
+#define ENDOPSENT 3 /* end operation cmd sent */
+#define RECVSENT 4 /* input message cmd sent */
+#define RECVDATASENT 5 /* input data cmd sent */
+#define XMITSENT 6 /* transmit message cmd sent */
+#define XMITDATASENT 7 /* transmit data cmd sent */
+#define WAITING 8 /* waiting for messages */
+#define CLEARSENT 9 /* clear wait for message cmd sent */
+#define MARKPORT 10 /* mark this host's adapter port down issued */
+#define RSTATSENT 11 /* read statistics cmd sent to adapter */
+
+#ifdef HYLOG
+char *hy_state_names[] = {
+ "Startup",
+ "Idle",
+ "Status Sent",
+ "End op Sent",
+ "Recieve Message Proper Sent",
+ "Recieve Data Sent",
+ "Transmit Message Proper Sent",
+ "Transmit Data Sent",
+ "Wait for Message Sent",
+ "Clear Wait for Message Sent",
+ "Mark Port Down Sent",
+ "Read Statistics Sent"
+};
+#endif
+
--- /dev/null
+/*
+ * @(#)if_hyreg.h 7.1 (Berkeley) 6/5/86
+ *
+ * $Header: if_hyreg.h,v 10.0 84/06/30 19:51:34 steveg Stable $
+ * $Locker: $
+ *
+ * Modifications from Berkeley 4.2 BSD
+ * Copyright (c) 1983, Tektronix Inc.
+ * All Rights Reserved
+ *
+ */
+
+
+/*
+ * Network Systems Corporation Hyperchannel interface
+ *
+ * supports A410 adapter interfaced via a DEC DR-11B, NSC PI-13 or PI-14
+ * (PI-14 is a PI-13 with different line drivers, software is
+ * identical to a PI-13)
+ *
+ * Written by Steve Glaser, Tektronix Inc., July 1982
+ *
+ * NOTE:
+ *
+ * DR11B code has not been fully checked out with 4.1a.
+ * The first adapters at Tek came with DR11Bs, and the code once worked,
+ * but those have been upgraded to PI-13s.
+ */
+
+/*
+ * The HYPERchannel driver sends and receives messages formatted:
+ *
+ * +---------------------------------------+ ---
+ * | | /|\
+ * | HYPERchannel adapter header (hy_hdr) | |
+ * | | |
+ * +---------------------------------------+ |
+ * | | |
+ * | Internet Protocol header (ip) | message proper
+ * | | (64 bytes max)
+ * +---------------------------------------+ |
+ * | | |
+ * | TCP header + user data | |
+ * | (if it all fits here) | |
+ * | | \|/
+ * +---------------------------------------+ ---
+ *
+ * +---------------------------------------+ ---
+ * | | /|\
+ * | | |
+ * | TCP header + user data | associated data
+ * | | |
+ * | | \|/
+ * +---------------------------------------+ ---
+ *
+ * If all of the datagram will fit in the message proper (including
+ * the TCP header and user data) the entire datagram is passed in
+ * the message proper and the associated data feature of the HYPERchannel
+ * is not used.
+ *
+ * The mapping from internet addresses to HYPERchannel addresses is:
+ *
+ * 0 7 8 15 16 31
+ * +---------+---------+-----------------------+
+ * | network | special | HYPERchannel address |
+ * +---------+---------+-----------------------+
+ *
+ * |<------------ internet address ----------->|
+ *
+ * The hyperchannel address is decoded as follows:
+ *
+ * 0 7 8 13 14 15
+ * +-------------------+----------------+------+
+ * | adapter number | zero | port |
+ * +-------------------+----------------+------+
+ *
+ * The low 2 bits are port number (interpreted by hyperchannel hardware).
+ *
+ * The encoding of special bits is:
+ *
+ * 00 normal packet
+ *
+ * 01 loop this packet back to the sender at the
+ * specified adapter (ip header source/destination addresses
+ * swapped before sending, command bits added to tell the
+ * remote HYPERchannel adapter debug & performance studies]
+ * this code acts like 02 (below) if the ip destination (before
+ * any swapping) and the destination address don't match (e.g.
+ * this packet is being routed through a gateway)
+ *
+ * 02 loop this packet back to the sender at the
+ * specified adapter, but go through the specified adapter's
+ * IP. This is for testing IP's store and forward mechanism.
+ *
+ * other undefined, currently treated as normal packet
+ *
+ */
+#define MPSIZE 64 /* "Message Proper" size */
+#define MAXRETRY 4
+
+/*
+ * Device registers
+ */
+struct hydevice {
+ short hyd_wcr; /* word count (negated) */
+ u_short hyd_bar; /* bus address bits 15-0 */
+ u_short hyd_csr; /* control and status */
+ u_short hyd_dbuf; /* data buffer */
+};
+
+/*
+ * CSR bit layout
+ */
+#define S_ERROR 0100000 /* error */
+#define S_NEX 0040000 /* non-existent memory error */
+#define S_ATTN 0020000 /* attn (always zero) */
+#ifdef PI13
+#define S_STKINTR 0010000 /* stacked interrupt */
+#else
+#define S_MAINT 0010000 /* maintenance (not used) */
+#endif
+#define S_A 0004000 /* device status A (recieve data available) */
+#define S_B 0002000 /* device status B (normal termination) */
+#define S_C 0001000 /* device status C (abnormal termination) */
+#ifdef PI13
+#define S_POWEROFF 0000400 /* power off indicator */
+#else
+#define S_CYCLE 0000400 /* cycle (not used) */
+#endif
+#define S_READY 0000200 /* ready */
+#define S_IE 0000100 /* interrupt enable */
+#define S_XBA 0000060 /* bus address bit bits 17 and 16 */
+#define S_CLRINT 0000014 /* clear stacked interrupt */
+#define S_IATTN 0000010 /* interrupt on attention only */
+#define S_WC 0000004 /* interrupt on word count == 0 only */
+#define S_IATTNWC 0000000 /* interrupt on word count == 0 and attention */
+#define S_BURST 0000002 /* burst mode DMA (not used) */
+#define S_GO 0000001 /* go */
+
+#define XBASHIFT 12
+
+#define HY_CSR_BITS "\20\
+\20ERROR\17NEX\16ATTN\15STKINTR\14RECV_DATA\13NORMAL\12ABNORMAL\11POWER\
+\10READY\07IENABLE\06XBA17\05XBA16\04IATTN\03IWC\02BURST\01GO"
+
+/*
+ * PI13 status conditions
+ */
+#define HYS_RECVDATA(x) (((x)->hyd_csr & S_A) != 0) /* get adapter data */
+#define HYS_NORMAL(x) (((x)->hyd_csr & S_B) != 0) /* done normally */
+#define HYS_ABNORMAL(x) (((x)->hyd_csr & S_C) != 0) /* done abnormally */
+#define HYS_ERROR(x) (((x)->hyd_csr & S_ERROR) != 0) /* error condition */
+#define HYS_DONE(x) (((x)->hyd_csr & (S_ERROR|S_B|S_C)) != 0)
+
+/*
+ * Function Codes for the Hyperchannel Adapter
+ * The codes are offset so they can be "or"ed into
+ * the reg data buffer
+ */
+#define HYF_XMITMSG 0x04 /* transmit message */
+#define HYF_XMITDATA 0x08 /* transmit associated data */
+#define HYF_XMITLSTDATA 0x0C /* transmit last associated data */
+#define HYF_XMITLOCMSG 0x10 /* transmit local message */
+#define HYF_INPUTMSG 0x24 /* input message proper */
+#define HYF_INPUTDATA 0x28 /* input assiciated data */
+#define HYF_STATUS 0x40 /* request status */
+#define HYF_DUMPREGS 0x50 /* dump extention registers */
+#define HYF_MARKP0 0x60 /* mark down port 0 */
+#define HYF_MARKP1 0x64 /* mark down port 1 */
+#define HYF_MARKP2 0x68 /* mark down port 2 */
+#define HYF_MARKP3 0x6C /* mark down port 3 */
+#define HYF_MP0RR 0x70 /* mark down port 0 and reroute messages */
+#define HYF_MP1RR 0x74 /* mark down port 1 and reroute messages */
+#define HYF_MP2RR 0x78 /* mark down port 2 and reroute messages */
+#define HYF_MP3RR 0x7C /* mark down port 3 and reroute messages */
+#define HYF_RSTATS 0xA0 /* read statistics */
+#define HYF_RCSTATS 0xA4 /* read and clear statistics */
+#define HYF_SETTEST 0xC0 /* enable test operations *set test mode) */
+#define HYF_SADDR_LEN 0xC4 /* test mode: set address and length */
+#define HYF_WBUFF 0xC8 /* test mode: write buffer */
+#define HYF_RBUFF 0xCC /* test mode: read buffer */
+#define HYF_CLRADAPTER 0xE0 /* clear adapter */
+#define HYF_END_OP 0xE4 /* end operation */
+#define HYF_CLRWFMSG 0xE6 /* clear wait for mwssage */
+#define HYF_WAITFORMSG 0xE8 /* wait for message */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_il.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Structure of an Ethernet header -- receive format
+ */
+struct il_rheader {
+ u_char ilr_status; /* Frame Status */
+ u_char ilr_fill1;
+ u_short ilr_length; /* Frame Length */
+ u_char ilr_dhost[6]; /* Destination Host */
+ u_char ilr_shost[6]; /* Source Host */
+ u_short ilr_type; /* Type of packet */
+};
+
+/*
+ * Structure of statistics record
+ */
+struct il_stats {
+ u_short ils_fill1;
+ u_short ils_length; /* Length (should be 62) */
+ u_char ils_addr[6]; /* Ethernet Address */
+ u_short ils_frames; /* Number of Frames Received */
+ u_short ils_rfifo; /* Number of Frames in Receive FIFO */
+ u_short ils_xmit; /* Number of Frames Transmitted */
+ u_short ils_xcollis; /* Number of Excess Collisions */
+ u_short ils_frag; /* Number of Fragments Received */
+ u_short ils_lost; /* Number of Times Frames Lost */
+ u_short ils_multi; /* Number of Multicasts Accepted */
+ u_short ils_rmulti; /* Number of Multicasts Rejected */
+ u_short ils_crc; /* Number of CRC Errors */
+ u_short ils_align; /* Number of Alignment Errors */
+ u_short ils_collis; /* Number of Collisions */
+ u_short ils_owcollis; /* Number of Out-of-window Collisions */
+ u_short ils_fill2[8];
+ char ils_module[8]; /* Module ID */
+ char ils_firmware[8]; /* Firmware ID */
+};
+
+/*
+ * Structure of Collision Delay Time Record
+ */
+struct il_collis {
+ u_short ilc_fill1;
+ u_short ilc_length; /* Length (should be 0-32) */
+ u_short ilc_delay[16]; /* Delay Times */
+};
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_ilreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Interlan Ethernet Communications Controller interface
+ */
+struct ildevice {
+ short il_csr; /* Command and Status Register */
+ short il_bar; /* Buffer Address Register */
+ short il_bcr; /* Byte Count Register */
+};
+
+/*
+ * Command and status bits
+ */
+#define IL_EUA 0xc000 /* Extended Unibus Address */
+#define IL_CMD 0x3f00 /* Command Function Code */
+#define IL_CDONE 0x0080 /* Command Done */
+#define IL_CIE 0x0040 /* Command Interrupt Enable */
+#define IL_RDONE 0x0020 /* Receive DMA Done */
+#define IL_RIE 0x0010 /* Receive Interrupt Enable */
+#define IL_STATUS 0x000f /* Command Status Code */
+
+#define IL_BITS "\20\10CDONE\7CIE\6RDONE\5RIE"
+
+/* command definitions */
+#define ILC_MLPBAK 0x0100 /* Set Module Interface Loopback Mode */
+#define ILC_ILPBAK 0x0200 /* Set Internal Loopback Mode */
+#define ILC_CLPBAK 0x0300 /* Clear Loopback Mode */
+#define ILC_PRMSC 0x0400 /* Set Promiscuous Receive Mode */
+#define ILC_CLPRMSC 0x0500 /* Clear Promiscuous Receive Mode */
+#define ILC_RCVERR 0x0600 /* Set Receive-On-Error Bit */
+#define ILC_CRCVERR 0x0700 /* Clear Receive-On-Error Bit */
+#define ILC_OFFLINE 0x0800 /* Go Offline */
+#define ILC_ONLINE 0x0900 /* Go Online */
+#define ILC_DIAG 0x0a00 /* Run On-board Diagnostics */
+#define ILC_ISA 0x0d00 /* Set Insert Source Address Mode */
+#define ILC_CISA 0x0e00 /* Clear Insert Source Address Mode */
+#define ILC_DEFPA 0x0f00 /* Set Physical Address to Default */
+#define ILC_ALLMC 0x1000 /* Set Receive All Multicast Packets */
+#define ILC_CALLMC 0x1100 /* Clear Receive All Multicast */
+#define ILC_STAT 0x1800 /* Report and Reset Statistics */
+#define ILC_DELAYS 0x1900 /* Report Collision Delay Times */
+#define ILC_RCV 0x2000 /* Supply Receive Buffer */
+#define ILC_LDXMIT 0x2800 /* Load Transmit Data */
+#define ILC_XMIT 0x2900 /* Load Transmit Data and Send */
+#define ILC_LDGRPS 0x2a00 /* Load Group Addresses */
+#define ILC_RMGRPS 0x2b00 /* Delete Group Addresses */
+#define ILC_LDPA 0x2c00 /* Load Physical Address */
+#define ILC_FLUSH 0x3000 /* Flush Receive BAR/BCR Queue */
+#define ILC_RESET 0x3f00 /* Reset */
+
+/*
+ * Error codes found in the status bits of the csr.
+ */
+#define ILERR_SUCCESS 0 /* command successful */
+#define ILERR_RETRIES 1 /* " " with retries */
+#define ILERR_BADCMD 2 /* illegal command */
+#define ILERR_INVCMD 3 /* invalid command */
+#define ILERR_RECVERR 4 /* receiver error */
+#define ILERR_BUFSIZ 5 /* buffer size too big */
+#define ILERR_FRAMESIZ 6 /* frame size too small */
+#define ILERR_COLLISIONS 8 /* excessive collisions */
+#define ILERR_BUFALIGNMENT 10 /* buffer not word aligned */
+#define ILERR_NXM 15 /* non-existent memory */
+
+#define NILERRS 16
+#ifdef ILERRS
+char *ilerrs[NILERRS] = {
+ "success", /* 0 */
+ "success with retries", /* 1 */
+ "illegal command", /* 2 */
+ "inappropriate command", /* 3 */
+ "failure", /* 4 */
+ "buffer size exceeded", /* 5 */
+ "frame too small", /* 6 */
+ 0, /* 7 */
+ "excessive collisions", /* 8 */
+ 0, /* 9 */
+ "buffer alignment error", /* 10 */
+ 0, /* 11 */
+ 0, /* 12 */
+ 0, /* 13 */
+ 0, /* 14 */
+ "non-existent memory" /* 15 */
+};
+#endif
+
+/*
+ * Diagnostics codes.
+ */
+#define ILDIAG_SUCCESS 0 /* no problems */
+#define ILDIAG_CHKSUMERR 1 /* ROM/RAM checksum error */
+#define ILDIAG_DMAERR 2 /* DMA not working */
+#define ILDIAG_XMITERR 3 /* xmit circuitry failure */
+#define ILDIAG_RECVERR 4 /* rcvr circuitry failure */
+#define ILDIAG_LOOPBACK 5 /* loopback test failed */
+
+#define NILDIAGS 6
+#ifdef ILDIAGS
+char *ildiag[NILDIAGS] = {
+ "success", /* 0 */
+ "checksum error", /* 1 */
+ "NM10 dma error", /* 2 */
+ "transmitter error", /* 3 */
+ "receiver error", /* 4 */
+ "loopback failure", /* 5 */
+};
+#endif
+
+/*
+ * Frame status bits, returned in frame status byte
+ * at the top of each received packet.
+ */
+#define ILFSTAT_C 0x1 /* CRC error */
+#define ILFSTAT_A 0x2 /* alignment error */
+#define ILFSTAT_L 0x4 /* 1+ frames lost just before */
--- /dev/null
+/*
+ * Copyright (c) 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_ix.h 7.1 (Berkeley) 6/5/86
+ */
+
+union ix_stats {
+ struct { /* General statistics below */
+ u_char macg_physaddr[6];
+ u_short macg_pad;
+ u_long dlag_rcvmac; /* packets received by DLA from MAC */
+ u_long dlag_rcvpass; /* packets passed to users by DLA */
+ u_long dlag_txreq; /* packets sent by users to DLA */
+ u_long dlag_txsnt; /* packets sent by DLA to MAC */
+ u_short dlag_chaopn; /* channels open */
+ u_short dlag_maxopn; /* max channels opened concurrently */
+ u_long macg_frmtos; /* packets discarded by MAC */
+ u_long macg_frmpas; /* packets sent to DLA by MAC */
+ u_long macg_x2x; /* packets put on wire by MAC */
+ u_long macg_x2r; /* packets looped by MAC */
+ u_long macg_xrty; /* transmitter retries */
+ u_short macg_noap; /* open MAC paths */
+ u_short macg_nprom; /* open promiscuous paths */
+ u_short macg_conopn; /* max concurrent MAC paths */
+ u_short sysg_crce; /* CRC errors */
+ u_short sysg_alne; /* alignment errors */
+ u_short sysg_rsce; /* resource errors */
+ u_short sysg_ovre; /* overrun errors */
+ } ixg;
+ struct { /* Channel statistics below */
+ u_long dabc_rcvacc; /* packets received */
+ u_long dabc_rcvtoss; /* packets discarded, queue full */
+ u_long dabc_rcvpass; /* packets passed to user */
+ u_long dabc_txreq; /* packets sent by user */
+ u_long dabc_txsent; /* packets sent to MAC */
+ u_long macc_rcvcnt; /* packets received by MAC */
+ u_long macc_txtcnt; /* packets sent by MAC to wire */
+ u_long macc_lowmem; /* packets discarded, no mem */
+ } ixc;
+};
+#define IXC_MAP(a) (((a) << 6) | 0100077)
+
+#define IXC_OPEN IXC_MAP(1) /* Open Channel */
+#define IXC_CLOSE IXC_MAP(2) /* Close Channel */
+#define IXC_MCAST IXC_MAP(3) /* Set Multicast Addresses */
+#define IXC_RECV IXC_MAP(4) /* Receive Frame */
+#define IXC_RECVF IXC_MAP(5) /* Receive Fragment */
+#define IXC_XMIT IXC_MAP(6) /* Send Frame */
+#define IXC_GSTAT IXC_MAP(7) /* Get General Statistics */
+#define IXC_CSTAT IXC_MAP(8) /* Get Channel Statistics */
+#define IXC_GSCLR IXC_MAP(9) /* Clear General Statistics */
+#define IXC_CSCLR IXC_MAP(10) /* Clear Channel Statistics */
+#define IXC_RESET IXC_MAP(11) /* Reset DLA module */
+#define IXC_LDPA IXC_MAP(12) /* Load Physical Address */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_pclreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * DEC CSS PCL-11B Parallel Communications Interface
+ */
+
+struct pcldevice {
+ u_short pcl_tcr; /* Transmitter Command Register */
+ u_short pcl_tsr; /* Transmitter Status Register */
+ u_short pcl_tsdb; /* Transmitter Source Data Buffer */
+ short pcl_tsbc; /* Transmitter Source Byte Count */
+ u_short pcl_tsba; /* Transmitter Source Bus Address */
+ u_short pcl_tmmr; /* Transmitter Master/Maint Regs */
+ u_short pcl_tscrc; /* Transmitter Source CRC */
+ u_short pcl_spare;
+ u_short pcl_rcr; /* Receiver Command Register */
+ u_short pcl_rsr; /* Receiver Status Register */
+ u_short pcl_rddb; /* Receiver Destination Data Buffer */
+ short pcl_rdbc; /* Receiver Destination Byte Count */
+ u_short pcl_rdba; /* Receiver Destination Bus Address */
+ u_short pcl_rdcrc; /* Receiver Destination CRC */
+};
+
+/* Transmitter Command and Status Bits */
+#define PCL_STTXM (1<<0) /* Start transmission */
+#define PCL_TXINIT (1<<1) /* Transmitter Initialize */
+#define PCL_IE (1<<6) /* Interrupt Enable */
+#define PCL_SNDWD (1<<13) /* Send word */
+#define PCL_TXNPR (1<<14) /* Transmitter NPR */
+#define PCL_RIB (1<<15) /* Retry if busy */
+
+#define PCL_RESPA (3<<0) /* Response A bits (tsr & rsr) */
+#define PCL_RESPB (3<<2) /* Response B bits (tsr & rsr) */
+#define PCL_MSTDWN (1<<11) /* Master down */
+#define PCL_ERR (1<<15) /* Error summary */
+
+#define PCL_MASTER (1<<8) /* Set MASTER status */
+#define PCL_AUTOADDR (1<<12) /* Auto time slicing */
+
+/* Receiver Command and Status Bits */
+#define PCL_RCVDAT (1<<0) /* Receive data */
+#define PCL_RCINIT (1<<1) /* Receiver Initialize */
+#define PCL_RCVWD (1<<13) /* Receive word */
+#define PCL_RCNPR (1<<14) /* Receive NRP */
+#define PCL_REJ (1<<15) /* Reject transmission */
+
+#define PCL_BCOFL (1<<9) /* Byte Counter Overflow */
+
+#define PCL_TERRBITS "\20\20ERR\17NXL\16MEM_OFL\15TXM_ERR\14MST_DWN\13TIM_OUT\12OVERRUN\11DTI_RDY\10SUC_TXF\07BUSY\06SOREJ\05TBS_BUSY"
+#define PCL_TCSRBITS "\20\20RIB\17TX_NPR\16SND_WD\10RD_SILO\07IE\04DTO_RDY\03INH_ADI\02TX_INIT\01START_TXM"
+
+#define PCL_RERRBITS "\20\20ERR\17NXL\16MEM_OFL\15TXM_ERR\14PARITY\13TIM_OUT\12BC_OFL\11DTO_RDY\10SUC_TXF\07BUSY\06REJ_COMP\05CHN_OPN"
+#define PCL_RCSRBITS "\20\20REJ\17RC_NPR\16RCV_WD\10LD_SILO\07IE\04DTI_RDY\03INH_ADI\02RC_INIT\01RCV_DAT"
--- /dev/null
+/* @(#)if_qereg.h 7.1 (Berkeley) 6/5/86 */
+
+/* @(#)if_qereg.h 1.2 (ULTRIX) 1/3/85 */
+
+/****************************************************************
+ * *
+ * Licensed from Digital Equipment Corporation *
+ * Copyright (c) *
+ * Digital Equipment Corporation *
+ * Maynard, Massachusetts *
+ * 1985, 1986 *
+ * All rights reserved. *
+ * *
+ * The Information in this software is subject to change *
+ * without notice and should not be construed as a commitment *
+ * by Digital Equipment Corporation. Digital makes no *
+ * representations about the suitability of this software for *
+ * any purpose. It is supplied "As Is" without expressed or *
+ * implied warranty. *
+ * *
+ * If the Regents of the University of California or its *
+ * licensees modify the software in a manner creating *
+ * diriviative copyright rights, appropriate copyright *
+ * legends may be placed on the drivative work in addition *
+ * to that set forth above. *
+ * *
+ ****************************************************************/
+/* ---------------------------------------------------------------------
+ * Modification History
+ *
+ * 13 Feb. 84 -- rjl
+ *
+ * Initial version of driver. derived from IL driver.
+ *
+ * ---------------------------------------------------------------------
+ */
+
+/*
+ * Digital Q-BUS to NI Adapter
+ */
+struct qedevice {
+ u_short qe_sta_addr[2]; /* Station address (actually 6 */
+ u_short qe_rcvlist_lo; /* Receive list lo address */
+ u_short qe_rcvlist_hi; /* Receive list hi address */
+ u_short qe_xmtlist_lo; /* Transmit list lo address */
+ u_short qe_xmtlist_hi; /* Transmit list hi address */
+ u_short qe_vector; /* Interrupt vector */
+ u_short qe_csr; /* Command and Status Register */
+};
+
+/*
+ * Command and status bits (csr)
+ */
+#define QE_RCV_ENABLE 0x0001 /* Receiver enable */
+#define QE_RESET 0x0002 /* Software reset */
+#define QE_NEX_MEM_INT 0x0004 /* Non existant mem interrupt */
+#define QE_LOAD_ROM 0x0008 /* Load boot/diag from rom */
+#define QE_XL_INVALID 0x0010 /* Transmit list invalid */
+#define QE_RL_INVALID 0x0020 /* Receive list invalid */
+#define QE_INT_ENABLE 0x0040 /* Interrupt enable */
+#define QE_XMIT_INT 0x0080 /* Transmit interrupt */
+#define QE_ILOOP 0x0100 /* Internal loopback */
+#define QE_ELOOP 0x0200 /* External loopback */
+#define QE_STIM_ENABLE 0x0400 /* Sanity timer enable */
+#define QE_POWERUP 0x1000 /* Tranceiver power on */
+#define QE_CARRIER 0x2000 /* Carrier detect */
+#define QE_RCV_INT 0x8000 /* Receiver interrupt */
+
+/*
+ * Transmit and receive ring discriptor ---------------------------
+ *
+ * The QNA uses the flag, status1 and the valid bit as a handshake/semiphore
+ * mechinism.
+ *
+ * The flag word is written on ( bits 15,15 set to 1 ) when it reads the
+ * descriptor. If the valid bit is set it considers the address to be valid.
+ * When it uses the buffer pointed to by the valid address it sets status word
+ * one.
+ */
+struct qe_ring {
+ u_short qe_flag; /* Buffer utilization flags */
+ u_short qe_addr_hi:6, /* Hi order bits of buffer addr */
+ qe_odd_begin:1, /* Odd byte begin and end (xmit)*/
+ qe_odd_end:1,
+ qe_fill1:4,
+ qe_setup:1, /* Setup packet */
+ qe_eomsg:1, /* End of message flag */
+ qe_chain:1, /* Chain address instead of buf */
+ qe_valid:1; /* Address field is valid */
+ u_short qe_addr_lo; /* Low order bits of address */
+ short qe_buf_len; /* Negative buffer length */
+ u_short qe_status1; /* Status word one */
+ u_short qe_status2; /* Status word two */
+};
+
+/*
+ * Status word definations (receive)
+ * word1
+ */
+#define QE_OVF 0x0001 /* Receiver overflow */
+#define QE_CRCERR 0x0002 /* CRC error */
+#define QE_FRAME 0x0004 /* Framing alignment error */
+#define QE_SHORT 0x0008 /* Packet size < 10 bytes */
+#define QE_RBL_HI 0x0700 /* Hi bits of receive len */
+#define QE_RUNT 0x0800 /* Runt packet */
+#define QE_DISCARD 0x1000 /* Discard the packet */
+#define QE_ESETUP 0x2000 /* Looped back setup or eloop */
+#define QE_ERROR 0x4000 /* Receiver error */
+#define QE_LASTNOT 0x8000 /* Not the last in the packet */
+/* word2 */
+#define QE_RBL_LO 0x00ff /* Low bits of receive len */
+
+/*
+ * Status word definations (transmit)
+ * word1
+ */
+#define QE_CCNT 0x00f0 /* Collision count this packet */
+#define QE_FAIL 0x0100 /* Heart beat check failure */
+#define QE_ABORT 0x0200 /* Transmission abort */
+#define QE_STE16 0x0400 /* Sanity timer default on */
+#define QE_NOCAR 0x0800 /* No carrier */
+#define QE_LOSS 0x1000 /* Loss of carrier while xmit */
+/* word2 */
+#define QE_TDR 0x3fff /* Time domain reflectometry */
+
+/*
+ * General constant definations
+ */
+#define QEALLOC 0 /* Allocate an mbuf */
+#define QENOALLOC 1 /* No mbuf allocation */
+#define QEDEALLOC 2 /* Release an mbuf chain */
+
+#define QE_NOTYET 0x8000 /* Descriptor not in use yet */
+#define QE_INUSE 0x4000 /* Descriptor being used by QNA */
+#define QE_MASK 0xc000 /* Lastnot/error/used mask */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_uba.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Structure and routine definitions
+ * for UNIBUS network interfaces.
+ */
+
+#define IF_MAXNUBAMR 10
+/*
+ * Each interface has structures giving information
+ * about UNIBUS resources held by the interface
+ * for each send and receive buffer.
+ *
+ * We hold IF_NUBAMR map registers for datagram data, starting
+ * at ifr_mr. Map register ifr_mr[-1] maps the local network header
+ * ending on the page boundary. Bdp's are reserved for read and for
+ * write, given by ifr_bdp. The prototype of the map register for
+ * read and for write is saved in ifr_proto.
+ *
+ * When write transfers are not full pages on page boundaries we just
+ * copy the data into the pages mapped on the UNIBUS and start the
+ * transfer. If a write transfer is of a (1024 byte) page on a page
+ * boundary, we swap in UNIBUS pte's to reference the pages, and then
+ * remap the initial pages (from ifu_wmap) when the transfer completes.
+ *
+ * When read transfers give whole pages of data to be input, we
+ * allocate page frames from a network page list and trade them
+ * with the pages already containing the data, mapping the allocated
+ * pages to replace the input pages for the next UNIBUS data input.
+ */
+
+/*
+ * Information per interface.
+ */
+struct ifubinfo {
+ short iff_uban; /* uba number */
+ short iff_hlen; /* local net header length */
+ struct uba_regs *iff_uba; /* uba regs, in vm */
+ short iff_flags; /* used during uballoc's */
+};
+
+/*
+ * Information per buffer.
+ */
+struct ifrw {
+ caddr_t ifrw_addr; /* virt addr of header */
+ short ifrw_bdp; /* unibus bdp */
+ short ifrw_flags; /* type, etc. */
+#define IFRW_W 0x01 /* is a transmit buffer */
+ int ifrw_info; /* value from ubaalloc */
+ int ifrw_proto; /* map register prototype */
+ struct pte *ifrw_mr; /* base of map registers */
+};
+
+/*
+ * Information per transmit buffer, including the above.
+ */
+struct ifxmt {
+ struct ifrw ifrw;
+ caddr_t ifw_base; /* virt addr of buffer */
+ struct pte ifw_wmap[IF_MAXNUBAMR]; /* base pages for output */
+ struct mbuf *ifw_xtofree; /* pages being dma'd out */
+ short ifw_xswapd; /* mask of clusters swapped */
+ short ifw_nmr; /* number of entries in wmap */
+};
+#define ifw_addr ifrw.ifrw_addr
+#define ifw_bdp ifrw.ifrw_bdp
+#define ifw_flags ifrw.ifrw_flags
+#define ifw_info ifrw.ifrw_info
+#define ifw_proto ifrw.ifrw_proto
+#define ifw_mr ifrw.ifrw_mr
+
+/*
+ * Most interfaces have a single receive and a single transmit buffer,
+ * and use struct ifuba to store all of the unibus information.
+ */
+struct ifuba {
+ struct ifubinfo ifu_info;
+ struct ifrw ifu_r;
+ struct ifxmt ifu_xmt;
+};
+
+#define ifu_uban ifu_info.iff_uban
+#define ifu_hlen ifu_info.iff_hlen
+#define ifu_uba ifu_info.iff_uba
+#define ifu_flags ifu_info.iff_flags
+#define ifu_w ifu_xmt.ifrw
+#define ifu_xtofree ifu_xmt.ifw_xtofree
+
+#ifdef KERNEL
+#define if_ubainit(ifuba, uban, hlen, nmr) \
+ if_ubaminit(&(ifuba)->ifu_info, uban, hlen, nmr, \
+ &(ifuba)->ifu_r, 1, &(ifuba)->ifu_xmt, 1)
+#define if_rubaget(ifu, totlen, off0, ifp) \
+ if_ubaget(&(ifu)->ifu_info, &(ifu)->ifu_r, totlen, off0, ifp)
+#define if_wubaput(ifu, m) \
+ if_ubaput(&(ifu)->ifu_info, &(ifu)->ifu_xmt, m)
+/*struct mbuf *if_ubaget();*/
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)if_vv.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * ECO 176-748 changed the braodcast address from 0 to 0xff, at
+ * CTL (p1002) serial number around 150.
+ * It was implemented in August, 1982. This is a field-installable ECO,
+ * which improves net reliability. If the broadcast address has not been
+ * changed, comment out the following line.
+ */
+#define NEW_BROADCAST /* new chip for broadcast problem */
+
+/*
+ * Local network header for proNET Ring
+ * This is arbitrated by "jas@proteon"
+ * (aka John Shriver, 617-655-3340)
+ */
+
+struct vv_header {
+ /* the first two fields are required by the hardware */
+ u_char vh_dhost; /* destination address */
+ u_char vh_shost; /* source address */
+ /* the next three fields are the local network header */
+ u_char vh_version; /* header version */
+ u_char vh_type; /* packet type => protocol number */
+ short vh_info; /* protocol-specific information */
+};
+
+#define RING_VERSION 2 /* current version of v2lni header */
+
+/*
+ * Packet types (protocol numbers) in proNET protocol header
+ * Other types are defined, but are proprietary.
+ */
+#define RING_IP 1
+#define RING_TRAILER 2 /* offset now in vh_info only */
+#define RING_ARP 3
+#define RING_HDLC 4
+#define RING_VAXDB 5
+#define RING_RINGWAY 6
+#define RING_RINGWAYM 8
+#define RING_NOVELL 10
+#define RING_PUP 12
+#define RING_XNS 14
+#define RING_DIAGNOSTICS 15 /* protocol type for testing */
+#define RING_ECHO 16
+
+#ifdef NEW_BROADCAST
+#define VV_BROADCAST 0xff /* hardware-defined broadcast address */
+#else
+#define VV_BROADCAST 0x00 /* hardware-defined broadcast address */
+#endif
+
+/*
+ * Proteon proNET Hardware definitions
+ * register bit definitions
+ */
+#define VV_ENB 01 /* Enable Operation */
+#define VV_DEN 02 /* Enable DMA */
+#define VV_HEN 04 /* Host Relay Enable (Rcv) */
+#define VV_CPB 04 /* Clear Packet Buffer (Xmit) */
+#define VV_STE 010 /* Self Test Enable (Rcv) */
+#define VV_UT1 010 /* Unused (Xmit) */
+#define VV_LPB 020 /* Modem Disable (Rcv) */
+#define VV_INR 020 /* Initialize Ring (Xmit) */
+#define VV_RST 040 /* Reset */
+#define VV_IEN 0100 /* Interrupt Enable */
+#define VV_RDY 0200 /* Done */
+#define VV_DPR 0400 /* Data Present (Rcv) */
+#define VV_RFS 0400 /* Refused (Xmit) */
+#define VV_NXM 01000 /* Non Existent Memory */
+#define VV_OVR 02000 /* Overrun */
+#define VV_ODB 04000 /* Odd Byte (Rcv) */
+#define VV_UT2 04000 /* Unused (Xmit) */
+#define VV_LDE 010000 /* Parity on 10 megabit (Rcv), */
+ /* Link Data Error on 80 megabit (Rcv) */
+#define VV_OPT 010000 /* Output Timeout (Xmit) */
+#define VV_NOK 020000 /* Ring Not OK */
+#define VV_BDF 040000 /* Bad Format in Operation */
+#define VV_NIR 0100000 /* Not in Ring */
+
+#define VVXERR (VV_NXM|VV_OVR|VV_OPT|VV_BDF) /* Xmit errs */
+#define VVRERR (VV_NXM|VV_OVR|VV_ODB|VV_BDF|VV_DPR) /* Rcv errs */
+#define VVFE (VV_NXM|VV_OVR) /* Fatal errors */
+
+#define VV_IBITS \
+"\10\20NIR\17BDF\16NOK\15LDE\14ODB\13OVR\12NXM\11DPR\10RDY\7IEN\6RST\5LPB\4STE\3HEN\2DEN\1ENB"
+
+#define VV_OBITS \
+"\10\20NIR\17BDF\16NOK\15OPT\13OVR\12NXM\11RFS\10RDY\7IEN\6RST\5INR\3HEN\2DEN\1ENB"
+
+/* device registers */
+struct vvreg {
+ short vvicsr; /* input csr */
+ u_short vviwc; /* input word count */
+ u_short vviba; /* input addr lo */
+ u_short vviea; /* input addr hi */
+ short vvocsr; /* output csr */
+ u_short vvowc; /* output word count */
+ u_short vvoba; /* output addr lo */
+ u_short vvoea; /* output addr hi */
+};
+
+#define VVRETRY 7 /* output retry limit */
+#define VVIDENTSUCC 5 /* number of successes required in self-test */
+#define VVIDENTRETRY 10 /* identify loop attempt limit */
+#define VVTIMEOUT 60 /* seconds before a transmit timeout */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)hpreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+struct hpdevice
+{
+ int hpcs1; /* control and status register 1 */
+ int hpds; /* drive status */
+ int hper1; /* error register 1 */
+ int hpmr; /* maintenance */
+ int hpas; /* attention summary */
+ int hpda; /* desired address register */
+ int hpdt; /* drive type */
+ int hpla; /* look ahead */
+ int hpsn; /* serial number */
+ int hpof; /* offset register */
+ int hpdc; /* desired cylinder address register */
+ int hpcc; /* current cylinder */
+#define hphr hpcc /* holding register */
+/* on an rp drive, mr2 is called er2 and er2 is called er3 */
+/* we use rm terminology here */
+ int hpmr2; /* maintenance register 2 */
+ int hper2; /* error register 2 */
+ int hpec1; /* burst error bit position */
+ int hpec2; /* burst error bit pattern */
+};
+
+/* hpcs1 */
+#define HP_SC 0100000 /* special condition */
+#define HP_TRE 0040000 /* transfer error */
+#define HP_DVA 0004000 /* drive available */
+#define HP_RDY 0000200 /* controller ready */
+#define HP_IE 0000100 /* interrupt enable */
+/* bits 5-1 are the command */
+#define HP_GO 0000001
+
+/* commands */
+#define HP_NOP 000 /* no operation */
+#define HP_UNLOAD 002 /* offline drive */
+#define HP_SEEK 004 /* seek */
+#define HP_RECAL 006 /* recalibrate */
+#define HP_DCLR 010 /* drive clear */
+#define HP_RELEASE 012 /* release */
+#define HP_OFFSET 014 /* offset */
+#define HP_RTC 016 /* return to centerline */
+#define HP_PRESET 020 /* read-in preset */
+#define HP_PACK 022 /* pack acknowledge */
+#define HP_SEARCH 030 /* search */
+#define HP_DIAGNOSE 034 /* diagnose drive */
+#define HP_WCDATA 050 /* write check data */
+#define HP_WCHDR 052 /* write check header and data */
+#define HP_WCOM 060 /* write data */
+#define HP_WHDR 062 /* write header */
+#define HP_WTRACKD 064 /* write track descriptor */
+#define HP_RCOM 070 /* read data */
+#define HP_RHDR 072 /* read header and data */
+#define HP_RTRACKD 074 /* read track descriptor */
+
+/* hpds */
+#define HPDS_ATA 0100000 /* attention active */
+#define HPDS_ERR 0040000 /* composite drive error */
+#define HPDS_PIP 0020000 /* positioning in progress */
+#define HPDS_MOL 0010000 /* medium on line */
+#define HPDS_WRL 0004000 /* write locked */
+#define HPDS_LST 0002000 /* last sector transferred */
+#define HPDS_PGM 0001000 /* programmable */
+#define HPDS_DPR 0000400 /* drive present */
+#define HPDS_DRY 0000200 /* drive ready */
+#define HPDS_VV 0000100 /* volume valid */
+/* bits 1-5 are spare */
+#define HPDS_OM 0000001 /* offset mode */
+
+#define HPDS_DREADY (HPDS_DPR|HPDS_DRY|HPDS_MOL|HPDS_VV)
+#define HPDS_BITS \
+"\10\20ATA\17ERR\16PIP\15MOL\14WRL\13LST\12PGM\11DPR\10DRY\7VV\1OM"
+
+/* hper1 */
+#define HPER1_DCK 0100000 /* data check */
+#define HPER1_UNS 0040000 /* drive unsafe */
+#define HPER1_OPI 0020000 /* operation incomplete */
+#define HPER1_DTE 0010000 /* drive timing error */
+#define HPER1_WLE 0004000 /* write lock error */
+#define HPER1_IAE 0002000 /* invalid address error */
+#define HPER1_AOE 0001000 /* address overflow error */
+#define HPER1_HCRC 0000400 /* header crc error */
+#define HPER1_HCE 0000200 /* header compare error */
+#define HPER1_ECH 0000100 /* ecc hard error */
+#define HPER1_WCF 0000040 /* write clock fail */
+#define HPER1_FER 0000020 /* format error */
+#define HPER1_PAR 0000010 /* parity error */
+#define HPER1_RMR 0000004 /* register modification refused */
+#define HPER1_ILR 0000002 /* illegal register */
+#define HPER1_ILF 0000001 /* illegal function */
+
+#define HPER1_BITS \
+"\10\20DCK\17UNS\16OPI\15DTE\14WLE\13IAE\12AOE\11HCRC\10HCE\
+\7ECH\6WCF\5FER\4PAR\3RMR\2ILR\1ILF"
+#define HPER1_HARD \
+ (HPER1_WLE|HPER1_IAE|HPER1_AOE|\
+ HPER1_FER|HPER1_RMR|HPER1_ILR|HPER1_ILF)
+
+/* hper2 */
+#define HPER2_BSE 0100000 /* bad sector error */
+#define HPER2_SKI 0040000 /* seek incomplete */
+#define HPER2_OPE 0020000 /* operator plug error */
+#define HPER2_IVC 0010000 /* invalid command */
+#define HPER2_LSC 0004000 /* loss of system clock */
+#define HPER2_LBC 0002000 /* loss of bit check */
+#define HPER2_DVC 0000200 /* device check */
+#define HPER2_SSE 0000040 /* skip sector error (rm80) */
+#define HPER2_DPE 0000010 /* data parity error */
+
+#define HPER2_BITS \
+"\10\20BSE\17SKI\16OPE\15IVC\14LSC\13LBC\10DVC\6SSE\4DPE"
+#define HPER2_HARD (HPER2_OPE)
+
+/* hpof */
+#define HPOF_CMO 0100000 /* command modifier */
+#define HPOF_MTD 0040000 /* move track descriptor */
+#define HPOF_FMT22 0010000 /* 16 bit format */
+#define HPOF_ECI 0004000 /* ecc inhibit */
+#define HPOF_HCI 0002000 /* header compare inhibit */
+#define HPOF_SSEI 0001000 /* skip sector inhibit */
+
+#define HPOF_P400 020 /* +400 uinches */
+#define HPOF_M400 0220 /* -400 uinches */
+#define HPOF_P800 040 /* +800 uinches */
+#define HPOF_M800 0240 /* -800 uinches */
+#define HPOF_P1200 060 /* +1200 uinches */
+#define HPOF_M1200 0260 /* -1200 uinches */
+
+/* hphr (alias hpcc) commands */
+#define HPHR_MAXCYL 0x8017 /* maximum cylinder address */
+#define HPHR_MAXTRAK 0x8018 /* maximum track address */
+#define HPHR_MAXSECT 0x8019 /* maximum sector address */
+#define HPHR_FMTENABLE 0xffff /* enable format command in cs1 */
+
+/* hpmr */
+#define HPMR_SZ 0174000 /* ML11 system size */
+#define HPMR_ARRTYP 0002000 /* ML11 array type */
+#define HPMR_TRT 0001400 /* ML11 transfer rate */
+
+/*
+ * Systems Industries kludge: use value in
+ * the serial # register to figure out real drive type.
+ */
+#define SIMB_MB 0xff00 /* model byte value */
+#define SIMB_S6 0x2000 /* switch s6 */
+#define SIMB_LU 0x0007 /* logical unit (should = drive #) */
+
+#define SI9775D 0x0700 /* 9775 direct */
+#define SI9775M 0x0e00 /* 9775 mapped */
+#define SI9730D 0x0b00 /* 9730 direct */
+#define SI9730M 0x0d00 /* 9730 mapped */
+#define SI9766 0x0300 /* 9766 */
+#define SI9762 0x0100 /* 9762 */
+#define SICAPD 0x0500 /* Capricorn direct */
+#define SICAPN 0x0400 /* Capricorn mapped */
+#define SI9751D 0x0f00 /* Eagle direct */
+
+#define SIRM03 0x8000 /* RM03 indication */
+#define SIRM05 0x0000 /* RM05 pseudo-indication */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)htreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+struct htdevice
+{
+ int htcs1; /* control status register */
+ int htds; /* drive status register */
+ int hter; /* error register */
+ int htmr; /* maintenance register */
+ int htas; /* attention status register */
+ int htfc; /* frame counter */
+ int htdt; /* drive type register */
+ int htck; /* nrzi check (crc) error character */
+ int htsn; /* serial number register */
+ int httc; /* tape controll register */
+};
+
+/* htcs1 */
+#define HT_GO 000001 /* go bit */
+#define HT_SENSE 000000 /* no operations (sense) */
+#define HT_REWOFFL 000002 /* rewind offline */
+#define HT_REW 000006 /* rewind */
+#define HT_DCLR 000010 /* drive clear */
+#define HT_RIP 000020 /* read in preset */
+#define HT_ERASE 000024 /* erase */
+#define HT_WEOF 000026 /* write tape mark */
+#define HT_SFORW 000030 /* space forward */
+#define HT_SREV 000032 /* space reverse */
+#define HT_WCHFWD 000050 /* write check forward */
+#define HT_WCHREV 000056 /* write check reverse */
+#define HT_WCOM 000060 /* write forward */
+#define HT_RCOM 000070 /* read forward */
+#define HT_RREV 000076 /* read reverse */
+
+/* htds */
+#define HTDS_ATA 0100000 /* attention active */
+#define HTDS_ERR 0040000 /* composite error */
+#define HTDS_PIP 0020000 /* positioning in progress */
+#define HTDS_MOL 0010000 /* medium on line */
+#define HTDS_WRL 0004000 /* write lock */
+#define HTDS_EOT 0002000 /* end of tape */
+/* bit 9 is unused */
+#define HTDS_DPR 0000400 /* drive present (always 1) */
+#define HTDS_DRY 0000200 /* drive ready */
+#define HTDS_SSC 0000100 /* slave status change */
+#define HTDS_PES 0000040 /* phase-encoded status */
+#define HTDS_SDWN 0000020 /* settle down */
+#define HTDS_IDB 0000010 /* identification burst */
+#define HTDS_TM 0000004 /* tape mark */
+#define HTDS_BOT 0000002 /* beginning of tape */
+#define HTDS_SLA 0000001 /* slave attention */
+
+#define HTDS_BITS \
+"\10\20ATA\17ERR\16PIP\15MOL\14WRL\13EOT\11DPR\10DRY\
+\7SSC\6PES\5SDWN\4IDB\3TM\2BOT\1SLA"
+
+/* hter */
+#define HTER_CORCRC 0100000 /* correctible data or ecc */
+#define HTER_UNS 0040000 /* unsafe */
+#define HTER_OPI 0020000 /* operation incomplete */
+#define HTER_DTE 0010000 /* drive timing error */
+#define HTER_NEF 0004000 /* non-executable function */
+#define HTER_CSITM 0002000 /* correctable skew/illegal tape mark */
+#define HTER_FCE 0001000 /* frame count error */
+#define HTER_NSG 0000400 /* non-standard gap */
+#define HTER_PEFLRC 0000200 /* format error or lrc error */
+#define HTER_INCVPE 0000100 /* incorrectable data error or vertical
+ parity error */
+#define HTER_DPAR 0000040 /* data parity error */
+#define HTER_FMT 0000020 /* format error */
+#define HTER_CPAR 0000010 /* control bus parity error */
+#define HTER_RMR 0000004 /* register modification refused */
+#define HTER_ILR 0000002 /* illegal register */
+#define HTER_ILF 0000001 /* illegal function */
+
+#define HTER_BITS \
+"\10\20CORCRC\17UNS\16OPI\15DTE\14NEF\13CSITM\12FCE\11NSG\10PEFLRC\
+\7INCVPE\6DPAR\5FMT\4CPAR\3RMR\2ILR\1ILF"
+#define HTER_HARD \
+ (HTER_UNS|HTER_OPI|HTER_NEF|HTER_DPAR|HTER_FMT|HTER_CPAR| \
+ HTER_RMR|HTER_ILR|HTER_ILF)
+
+/* htdt */
+#define HTDT_NSA 0100000 /* not sector addressed; always 1 */
+#define HTDT_TAP 0040000 /* tape; always 1 */
+#define HTDT_MOH 0020000 /* moving head; always 0 */
+#define HTDT_7CH 0010000 /* 7 channel; always 0 */
+#define HTDT_DRQ 0004000 /* drive requested; always 0 */
+#define HTDT_SPR 0002000 /* slave present */
+/* bit 9 is spare */
+/* bits 8-0 are formatter/transport type */
+
+/* httc */
+#define HTTC_ACCL 0100000 /* transport is not reading/writing */
+#define HTTC_FCS 0040000 /* frame count status */
+#define HTTC_SAC 0020000 /* slave address change */
+#define HTTC_EAODTE 0010000 /* enable abort on data xfer errors */
+/* bits 8-10 are density select */
+#define HTTC_800BPI 0001400 /* in bits 8-10, dens=1600 */
+#define HTTC_1600BPI 0002000 /* in bits 8-10, dens=800 */
+/* bits 4-7 are format select */
+#define HTTC_PDP11 0000300 /* in bits 4-7, pdp11 normal format */
+#define HTTC_EVEN 0000010 /* select even parity */
+/* bits 0 - 2 are slave select */
+
+#define b_repcnt b_bcount
+#define b_command b_resid
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)mbareg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * VAX MASSBUS adapter registers
+ */
+
+struct mba_regs
+{
+ int mba_csr; /* configuration register */
+ int mba_cr; /* control register */
+ int mba_sr; /* status register */
+ int mba_var; /* virtual address register */
+ int mba_bcr; /* byte count register */
+ int mba_dr;
+ int mba_pad1[250];
+ struct mba_drv { /* per drive registers */
+ int mbd_cs1; /* control status */
+ int mbd_ds; /* drive status */
+ int mbd_er1; /* error register */
+ int mbd_mr1; /* maintenance register */
+ int mbd_as; /* attention status */
+ int mbd_da; /* desired address (disks) */
+#define mbd_fc mbd_da /* frame count (tapes) */
+ int mbd_dt; /* drive type */
+ int mbd_la; /* look ahead (disks) */
+#define mbd_ck mbd_la /* ??? (tapes) */
+ int mbd_sn; /* serial number */
+ int mbd_of; /* ??? */
+#define mbd_tc mbd_of /* ??? */
+ int mbd_fill[22];
+ } mba_drv[8];
+ struct pte mba_map[256]; /* io space virtual map */
+ int mba_pad2[256*5]; /* to size of a nexus */
+};
+
+/*
+ * Bits in mba_cr
+ */
+#define MBCR_INIT 0x1 /* init mba */
+#define MBCR_IE 0x4 /* enable mba interrupts */
+
+/*
+ * Bits in mba_sr
+ */
+#define MBSR_DTBUSY 0x80000000 /* data transfer busy */
+#define MBSR_NRCONF 0x40000000 /* no response confirmation */
+#define MBSR_CRD 0x20000000 /* corrected read data */
+#define MBSR_CBHUNG 0x00800000 /* control bus hung */
+#define MBSR_PGE 0x00080000 /* programming error */
+#define MBSR_NED 0x00040000 /* non-existant drive */
+#define MBSR_MCPE 0x00020000 /* massbus control parity error */
+#define MBSR_ATTN 0x00010000 /* attention from massbus */
+#define MBSR_SPE 0x00004000 /* silo parity error */
+#define MBSR_DTCMP 0x00002000 /* data transfer completed */
+#define MBSR_DTABT 0x00001000 /* data transfer aborted */
+#define MBSR_DLT 0x00000800 /* data late */
+#define MBSR_WCKUP 0x00000400 /* write check upper */
+#define MBSR_WCKLWR 0x00000200 /* write check lower */
+#define MBSR_MXF 0x00000100 /* miss transfer error */
+#define MBSR_MBEXC 0x00000080 /* massbus exception */
+#define MBSR_MDPE 0x00000040 /* massbus data parity error */
+#define MBSR_MAPPE 0x00000020 /* page frame map parity error */
+#define MBSR_INVMAP 0x00000010 /* invalid map */
+#define MBSR_ERRCONF 0x00000008 /* error confirmation */
+#define MBSR_RDS 0x00000004 /* read data substitute */
+#define MBSR_ISTIMO 0x00000002 /* interface sequence timeout */
+#define MBSR_RDTIMO 0x00000001 /* read data timeout */
+
+#define MBSR_BITS \
+"\20\40DTBUSY\37NRCONF\36CRD\30CBHUNG\24PGE\23NED\22MCPE\21ATTN\
+\17SPE\16DTCMP\15DTABT\14DLT\13WCKUP\12WCKLWR\11MXF\10MBEXC\7MDPE\
+\6MAPPE\5INVMAP\4ERRCONF\3RDS\2ISTIMO\1RDTIMO"
+
+#define MBSR_HARD (MBSR_PGE|MBSR_ERRCONF|MBSR_ISTIMO|MBSR_RDTIMO)
+
+#define MBSR_EBITS (~(MBSR_DTBUSY|MBSR_CRD|MBSR_ATTN|MBSR_DTCMP))
+
+#ifdef KERNEL
+extern char mbsr_bits[];
+#endif
+
+/*
+ * Commands for mbd_cs1
+ */
+#define MB_WCOM 0x30
+#define MB_RCOM 0x38
+#define MB_GO 0x1
+
+/*
+ * Bits in mbd_ds.
+ */
+#define MBDS_ERR 0x00004000 /* error in drive */
+#define MBDS_MOL 0x00001000 /* medium on line */
+#define MBDS_DPR 0x00000100 /* drive present */
+#define MBDS_DRY 0x00000080 /* drive ready */
+
+#define MBDS_DREADY (MBDS_MOL|MBDS_DPR|MBDS_DRY)
+
+/*
+ * Bits in mbd_dt
+ */
+#define MBDT_NSA 0x8000 /* not sector addressible */
+#define MBDT_TAP 0x4000 /* is a tape */
+#define MBDT_MOH 0x2000 /* moving head */
+#define MBDT_7CH 0x1000 /* 7 channel */
+#define MBDT_DRQ 0x800 /* drive request required */
+#define MBDT_SPR 0x400 /* slave present */
+
+#define MBDT_TYPE 0x1ff
+#define MBDT_MASK (MBDT_NSA|MBDT_TAP|MBDT_TYPE)
+
+/* type codes for disk drives */
+#define MBDT_RP04 020
+#define MBDT_RP05 021
+#define MBDT_RP06 022
+#define MBDT_RP07 042
+#define MBDT_RM02 025
+#define MBDT_RM03 024
+#define MBDT_RM05 027
+#define MBDT_RM80 026
+#define MBDT_ML11A 0110
+#define MBDT_ML11B 0111
+
+/* type codes for tape drives */
+#define MBDT_TM03 050
+#define MBDT_TE16 051
+#define MBDT_TU45 052
+#define MBDT_TU77 054
+#define MBDT_TU78 0101
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)mbavar.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * This file contains definitions related to the kernel structures
+ * for dealing with the massbus adapters.
+ *
+ * Each mba has a mba_hd structure.
+ * Each massbus device has a mba_device structure.
+ * Each massbus slave has a mba_slave structure.
+ *
+ * At boot time we prowl the structures and fill in the pointers
+ * for devices which we find.
+ */
+
+/*
+ * Per-mba structure.
+ *
+ * The initialization routine uses the information in the mbdinit table
+ * to initialize the what is attached to each massbus slot information.
+ * It counts the number of devices on each mba (to see if bothering to
+ * search/seek is appropriate).
+ *
+ * During normal operation, the devices attached to the mba which wish
+ * to transfer are queued on the mh_act? links.
+ */
+struct mba_hd {
+ short mh_active; /* set if mba is active */
+ short mh_ndrive; /* number of devices, to avoid seeks */
+ struct mba_regs *mh_mba; /* virt addr of mba */
+ struct mba_regs *mh_physmba; /* phys addr of mba */
+ struct mba_device *mh_mbip[8]; /* what is attached to each dev */
+ struct mba_device *mh_actf; /* head of queue to transfer */
+ struct mba_device *mh_actl; /* tail of queue to transfer */
+};
+
+/*
+ * Per-device structure
+ * (one for each RM/RP disk, and one for each tape formatter).
+ *
+ * This structure is used by the device driver as its argument
+ * to the massbus driver, and by the massbus driver to locate
+ * the device driver for a particular massbus slot.
+ *
+ * The device drivers hang ready buffers on this structure,
+ * and the massbus driver will start i/o on the first such buffer
+ * when appropriate.
+ */
+struct mba_device {
+ struct mba_driver *mi_driver;
+ short mi_unit; /* unit number to the system */
+ short mi_mbanum; /* the mba it is on */
+ short mi_drive; /* controller on mba */
+ short mi_dk; /* driver number for iostat */
+ short mi_alive; /* device exists */
+ short mi_type; /* driver specific unit type */
+ struct buf mi_tab; /* head of queue for this device */
+ struct mba_device *mi_forw;
+/* we could compute these every time, but hereby save time */
+ struct mba_regs *mi_mba;
+ struct mba_drv *mi_drv;
+ struct mba_hd *mi_hd;
+};
+
+#define b_bdone b_bufsize /* redefinition for mi_tab XXX */
+
+/*
+ * Tape formatter slaves are specified by
+ * the following information which is used
+ * at boot time to initialize the tape driver
+ * internal tables.
+ */
+struct mba_slave {
+ struct mba_driver *ms_driver;
+ short ms_ctlr; /* which of several formatters */
+ short ms_unit; /* which unit to system */
+ short ms_slave; /* which slave to formatter */
+ short ms_alive;
+};
+
+/*
+ * Per device-type structure.
+ *
+ * Each massbus driver defines entries for a set of routines used
+ * by the massbus driver, as well as an array of types which are
+ * acceptable to it.
+ */
+struct mba_driver {
+/* int (*md_attach)();*/ /* attach a device */
+/* int (*md_slave)();*/ /* attach a slave */
+/* int (*md_ustart)();*/ /* unit start routine */
+/* int (*md_start)();*/ /* setup a data transfer */
+/* int (*md_dtint)();*/ /* data transfer complete */
+/* int (*md_ndint)();*/ /* non-data transfer interrupt */
+ short *md_type; /* array of drive type codes */
+ char *md_dname, *md_sname; /* device, slave names */
+ struct mba_device **md_info; /* backpointers to mbinit structs */
+};
+
+/*
+ * Possible return values from unit start routines.
+ */
+#define MBU_NEXT 0 /* skip to next operation */
+#define MBU_BUSY 1 /* dual port busy; wait for intr */
+#define MBU_STARTED 2 /* non-data transfer started */
+#define MBU_DODATA 3 /* data transfer ready; start mba */
+
+/*
+ * Possible return values from data transfer interrupt handling routines
+ */
+#define MBD_DONE 0 /* data transfer complete */
+#define MBD_RETRY 1 /* error occurred, please retry */
+#define MBD_RESTARTED 2 /* driver restarted i/o itself */
+#define MBD_REPOSITION 3 /* driver started unit, not transfer */
+
+/*
+ * Possible return values from non-data-transfer interrupt handling routines
+ */
+#define MBN_DONE 0 /* non-data transfer complete */
+#define MBN_RETRY 1 /* failed; retry the operation */
+#define MBN_SKIP 2 /* don't do anything */
+
+/*
+ * Clear attention status for specified device.
+ */
+#define mbclrattn(mi) ((mi)->mi_mba->mba_drv[0].mbd_as = 1 << (mi)->mi_drive)
+
+/*
+ * Kernel definitions related to mba.
+ */
+#ifdef KERNEL
+int nummba;
+#if NMBA > 0
+struct mba_hd mba_hd[NMBA];
+/*extern Xmba0int(), Xmba1int(), Xmba2int(), Xmba3int();*/
+
+extern struct mba_device mbdinit[];
+extern struct mba_slave mbsinit[];
+#endif
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)mtreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * TU78 registers.
+ */
+
+struct mtdevice {
+ int mtcs; /* control status register */
+ int mter; /* error register */
+ int mtca; /* command address, rec cnt, skp cnt reg */
+ int mtmr1; /* maintenance register */
+ int mtas; /* attention summary register */
+ int mtbc; /* byte count register */
+ int mtdt; /* drive type register */
+ int mtds; /* drive status register */
+ int mtsn; /* serial number register */
+ int mtmr2; /* maintenance register */
+ int mtmr3; /* maintenance register */
+ int mtner; /* non-data transfer error register */
+ int mtncs[4]; /* non-data transfer command registers */
+ int mtia; /* internal address */
+ int mtid; /* internal data */
+};
+
+/* mtcs */
+#define MT_GO 000001 /* go bit */
+#define MT_NOOP 000002 /* no operation */
+#define MT_UNLOAD 000004 /* unload tape */
+#define MT_REW 000006 /* rewind */
+#define MT_SENSE 000010 /* sense */
+#define MT_DSE 000012 /* data security erase */
+#define MT_WTMPE 000014 /* write phase encoded tape mark */
+#define MT_WTM MT_WTMPE /* generic write tape mark */
+#define MT_WTMGCR 000016 /* write GCR tape mark */
+#define MT_SFORW 000020 /* space forward record */
+#define MT_SREV 000022 /* space reverse record */
+#define MT_SFORWF 000024 /* space forward file */
+#define MT_SREVF 000026 /* space reverse file */
+#define MT_SFORWE 000030 /* space forward either */
+#define MT_SREVE 000032 /* space reverse either */
+#define MT_ERGPE 000034 /* erase tape, set PE */
+#define MT_ERASE MT_ERGPE /* generic erase tape */
+#define MT_ERGGCR 000036 /* erase tape, set GCR */
+#define MT_CLSPE 000040 /* close file PE */
+#define MT_CLS MT_CLSPE /* generic close file */
+#define MT_CLSGCR 000042 /* close file GCR */
+#define MT_SLEOT 000044 /* space to logical EOT */
+#define MT_SFLEOT 000046 /* space forward file, stop on LEOT */
+#define MT_WCHFWD 000050 /* write check forward */
+#define MT_WCHREV 000056 /* write check reverse */
+#define MT_WRITEPE 000060 /* write phase encoded */
+#define MT_WRITE MT_WRITEPE /* generic write */
+#define MT_WRITEGCR 000062 /* write group coded */
+#define MT_READ 000070 /* read forward */
+#define MT_EXSNS 000072 /* read extended sense error log */
+#define MT_READREV 000076 /* read reverse */
+#define MT_GCR 000002 /* make generic ops GCR ops */
+
+/* mtds */
+#define MTDS_RDY 0100000 /* tape ready */
+#define MTDS_PRES 0040000 /* tape unit has power */
+#define MTDS_ONL 0020000 /* online */
+#define MTDS_REW 0010000 /* tape rewinding */
+#define MTDS_PE 0004000 /* tape set for phase encoded */
+#define MTDS_BOT 0002000 /* tape at BOT */
+#define MTDS_EOT 0001000 /* tape at EOT */
+#define MTDS_FPT 0000400 /* write protected */
+#define MTDS_AVAIL 0000200 /* unit available */
+#define MTDS_SHR 0000100 /* unit is shared */
+#define MTDS_MAINT 0000040 /* maintenance mode */
+#define MTDS_DSE 0000020 /* DSE in progress */
+
+#define MTDS_BITS \
+"\10\20RDY\17PRES\16ONL\15REW\14PE\13BOT\12EOT\11FPT\10AVAIL\
+\7SHR\6MAINT\5DSE"
+
+/* mter */
+#define MTER_INTCODE 0377 /* mask for interrupt code */
+#define MTER_FAILCODE 0176000 /* failure code */
+
+/* interrupt codes */
+#define MTER_DONE 001 /* operation complete */
+#define MTER_TM 002 /* unexpected tape mark */
+#define MTER_BOT 003 /* unexpected BOT detected */
+#define MTER_EOT 004 /* tape positioned beyond EOT */
+#define MTER_LEOT 005 /* unexpected LEOT detected */
+#define MTER_NOOP 006 /* no-op completed */
+#define MTER_RWDING 007 /* rewinding */
+#define MTER_FPT 010 /* write protect error */
+#define MTER_NOTRDY 011 /* not ready */
+#define MTER_NOTAVL 012 /* not available */
+#define MTER_OFFLINE 013 /* offline */
+#define MTER_NONEX 014 /* unit does not exist */
+#define MTER_NOTCAP 015 /* not capable */
+#define MTER_ONLINE 017 /* tape came online */
+#define MTER_LONGREC 020 /* long tape record */
+#define MTER_SHRTREC 021 /* short tape record */
+#define MTER_RETRY 022 /* retry */
+#define MTER_RDOPP 023 /* read opposite */
+#define MTER_UNREAD 024 /* unreadable */
+#define MTER_ERROR 025 /* error */
+#define MTER_EOTERR 026 /* EOT error */
+#define MTER_BADTAPE 027 /* tape position lost */
+#define MTER_TMFLTA 030 /* TM fault A */
+#define MTER_TUFLTA 031 /* TU fault A */
+#define MTER_TMFLTB 032 /* TM fault B */
+#define MTER_MBFLT 034 /* Massbus fault */
+#define MTER_KEYFAIL 077 /* keypad entry error */
+
+/* mtdt */
+#define MTDT_NSA 0100000 /* not sector addressed; always 1 */
+#define MTDT_TAP 0040000 /* tape; always 1 */
+#define MTDT_MOH 0020000 /* moving head; always 0 */
+#define MTDT_7CH 0010000 /* 7 channel; always 0 */
+#define MTDT_DRQ 0004000 /* drive request required */
+#define MTDT_SPR 0002000 /* slave present; always 1 ??? */
+/* bit 9 is spare */
+/* bits 8-0 are formatter/transport type */
+
+/* mtid */
+#define MTID_RDY 0100000 /* controller ready */
+#define MTID_CLR 0040000 /* controller clear */
+
+#define b_repcnt b_bcount
+#define b_command b_resid
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)adreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+struct addevice {
+ short int ad_csr; /* Control status register */
+ short int ad_data; /* Data buffer */
+};
+
+#define AD_CHAN ADIOSCHAN
+#define AD_READ ADIOGETW
+#define ADIOSCHAN _IOW(a, 0, int) /* set channel */
+#define ADIOGETW _IOR(a, 1, int) /* read one word */
+
+/*
+ * Unibus CSR register bits
+ */
+
+#define AD_START 01
+#define AD_SCHMITT 020
+#define AD_CLOCK 040
+#define AD_IENABLE 0100
+#define AD_DONE 0200
+#define AD_INCENABLE 040000
+#define AD_ERROR 0100000
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dhreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * DH-11 device register definitions.
+ */
+struct dhdevice {
+ union {
+ short dhcsr; /* control-status register */
+ char dhcsrl; /* low byte for line select */
+ } un;
+ short dhrcr; /* receive character register */
+ short dhlpr; /* line parameter register */
+ u_short dhcar; /* current address register */
+ short dhbcr; /* byte count register */
+ u_short dhbar; /* buffer active register */
+ short dhbreak; /* break control register */
+ short dhsilo; /* silo status register */
+};
+
+/* Bits in dhcsr */
+#define DH_TI 0100000 /* transmit interrupt */
+#define DH_SI 0040000 /* storage interrupt */
+#define DH_TIE 0020000 /* transmit interrupt enable */
+#define DH_SIE 0010000 /* storage interrupt enable */
+#define DH_MC 0004000 /* master clear */
+#define DH_NXM 0002000 /* non-existant memory */
+#define DH_MM 0001000 /* maintenance mode */
+#define DH_CNI 0000400 /* clear non-existant memory interrupt */
+#define DH_RI 0000200 /* receiver interrupt */
+#define DH_RIE 0000100 /* receiver interrupt enable */
+
+/* Bits in dhlpr */
+#define BITS6 01
+#define BITS7 02
+#define BITS8 03
+#define TWOSB 04
+#define PENABLE 020
+/* DEC manuals incorrectly say this bit causes generation of even parity. */
+#define OPAR 040
+#define HDUPLX 040000
+
+#define DH_IE (DH_TIE|DH_SIE|DH_RIE)
+
+/* Bits in dhrcr */
+#define DH_PE 0010000 /* parity error */
+#define DH_FE 0020000 /* framing error */
+#define DH_DO 0040000 /* data overrun */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dhureg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * DHU-11 device register definitions.
+ */
+struct dhudevice {
+ union {
+ short csr; /* control-status register */
+ struct {
+ char csrl; /* low byte for line select */
+ char csrh; /* high byte for tx line */
+ } cb;
+ } un1;
+#define dhucsr un1.csr
+#define dhucsrl un1.cb.csrl
+#define dhucsrh un1.cb.csrh
+ union {
+ short rbuf; /* recv.char/ds.change register (R) */
+ short timo; /* delay between recv -> intr (W) */
+ } un2;
+#define dhurbuf un2.rbuf
+#define dhutimo un2.timo
+ short dhulpr; /* line parameter register */
+ union {
+ char fbyte[1]; /* fifo data byte (low byte only) (W) */
+ short fdata; /* fifo data word (W) */
+ char sbyte[2]; /* line status/fifo size (R) */
+ } un3;
+#define dhubyte un3.fbyte[0]
+#define dhufifo un3.fdata
+#define dhusize un3.sbyte[0]
+#define dhustat un3.sbyte[1]
+ short dhulcr; /* line control register */
+ short dhubar1; /* buffer address register 1 */
+ char dhubar2; /* buffer address register 2 */
+ char dhulcr2; /* xmit enable bit */
+ short dhubcr; /* buffer count register */
+};
+
+/* Bits in dhucsr */
+#define DHU_CS_TIE 0x4000 /* transmit interrupt enable */
+#define DHU_CS_DFAIL 0x2000 /* diagnostic fail */
+#define DHU_CS_RI 0x0080 /* receiver interrupt */
+#define DHU_CS_RIE 0x0040 /* receiver interrupt enable */
+#define DHU_CS_MCLR 0x0020 /* master clear */
+#define DHU_CS_SST 0x0010 /* skip self test (with DHU_CS_MCLR) */
+#define DHU_CS_IAP 0x000f /* indirect address pointer */
+
+#define DHU_IE (DHU_CS_TIE|DHU_CS_RIE)
+
+/* map unit into iap register select */
+#define DHU_SELECT(unit) ((unit) & DHU_CS_IAP)
+
+/* Transmitter bits in high byte of dhucsr */
+#define DHU_CSH_TI 0x80 /* transmit interrupt */
+#define DHU_CSH_NXM 0x10 /* transmit dma err: non-exist-mem */
+#define DHU_CSH_TLN 0x0f /* transmit line number */
+
+/* map csrh line bits into line */
+#define DHU_TX_LINE(csrh) ((csrh) & DHU_CSH_TLN)
+
+/* Bits in dhurbuf */
+#define DHU_RB_VALID 0x8000 /* data valid */
+#define DHU_RB_STAT 0x7000 /* status bits */
+#define DHU_RB_DO 0x4000 /* data overrun */
+#define DHU_RB_FE 0x2000 /* framing error */
+#define DHU_RB_PE 0x1000 /* parity error */
+#define DHU_RB_RLN 0x0f00 /* receive line number */
+#define DHU_RB_RDS 0x00ff /* receive data/status */
+#define DHU_RB_DIAG 0x0001 /* if DHU_RB_STAT -> diag vs modem */
+
+/* map rbuf line bits into line */
+#define DHU_RX_LINE(rbuf) (((rbuf) & DHU_RB_RLN) >> 8)
+
+/* Bits in dhulpr */
+#define DHU_LP_TSPEED 0xf000
+#define DHU_LP_RSPEED 0x0f00
+#define DHU_LP_TWOSB 0x0080
+#define DHU_LP_EPAR 0x0040
+#define DHU_LP_PENABLE 0x0020
+#define DHU_LP_BITS8 0x0018
+#define DHU_LP_BITS7 0x0010
+#define DHU_LP_BITS6 0x0008
+
+/* Bits in dhustat */
+#define DHU_ST_DSR 0x80 /* data set ready */
+#define DHU_ST_RI 0x20 /* ring indicator */
+#define DHU_ST_DCD 0x10 /* carrier detect */
+#define DHU_ST_CTS 0x04 /* clear to send */
+#define DHU_ST_DHU 0x01 /* always one on a dhu, zero on dhv */
+
+/* Bits in dhulcr */
+#define DHU_LC_RTS 0x1000 /* request to send */
+#define DHU_LC_DTR 0x0200 /* data terminal ready */
+#define DHU_LC_MODEM 0x0100 /* modem control enable */
+#define DHU_LC_MAINT 0x00c0 /* maintenance mode */
+#define DHU_LC_FXOFF 0x0020 /* force xoff */
+#define DHU_LC_OAUTOF 0x0010 /* output auto flow */
+#define DHU_LC_BREAK 0x0008 /* break control */
+#define DHU_LC_RXEN 0x0004 /* receiver enable */
+#define DHU_LC_IAUTOF 0x0002 /* input auto flow */
+#define DHU_LC_TXABORT 0x0001 /* transmitter abort */
+
+/* Bits in dhulcr2 */
+#define DHU_LC2_TXEN 0x80 /* transmitter enable */
+
+/* Bits in dhubar2 */
+#define DHU_BA2_DMAGO 0x80 /* transmit dma start */
+#define DHU_BA2_XBA 0x03 /* top two bits of dma address */
+#define DHU_XBA_SHIFT 16 /* amount to shift xba bits */
+
+/* Bits for dhumctl only: stat bits are shifted up 16 */
+#define DHU_ON (DHU_LC_DTR|DHU_LC_RTS|DHU_LC_MODEM)
+#define DHU_OFF DHU_LC_MODEM
+
+#define DHU_DSR (DHU_ST_DSR << 16)
+#define DHU_RNG (DHU_ST_RI << 16)
+#define DHU_CAR (DHU_ST_DCD << 16)
+#define DHU_CTS (DHU_ST_CTS << 16)
+
+#define DHU_RTS DHU_LC_RTS
+#define DHU_DTR DHU_LC_DTR
+#define DHU_BRK DHU_LC_BREAK
+#define DHU_LE DHU_LC_MODEM
+
+/* bits in dm lsr, copied from dmreg.h */
+#define DML_DSR 0000400 /* data set ready, not a real DM bit */
+#define DML_RNG 0000200 /* ring */
+#define DML_CAR 0000100 /* carrier detect */
+#define DML_CTS 0000040 /* clear to send */
+#define DML_SR 0000020 /* secondary receive */
+#define DML_ST 0000010 /* secondary transmit */
+#define DML_RTS 0000004 /* request to send */
+#define DML_DTR 0000002 /* data terminal ready */
+#define DML_LE 0000001 /* line enable */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dmfreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * DMF-32 definitions.
+ */
+
+/*
+ * "dmf" (unqualified) refers to the async portion of the dmf32,
+ * "dmfc" to the combo portion,
+ * "dmfs" to the sync portion,
+ * "dmfl" to the lp portion, and
+ * "dmfd" to the dr portion.
+ */
+struct dmfdevice {
+ short dmfccsr0; /* combo csr 0 */
+ short dmfccsr1; /* combo csr 1 */
+ short dmfs[4];
+ short dmfcsr; /* control-status register */
+ short dmflpr; /* line parameter register */
+ short dmfrbuf; /* receiver buffer (ro) */
+ union {
+ u_short dmfirw; /* indirect register word */
+ u_char dmfirc[2]; /* " " bytes */
+ } dmfun;
+ short dmfl_ctrl; /* line printer control register */
+ short dmfl_indrct; /* line printer indirect register */
+ short dmfd[4]; /* for dr11 (not implemented) */
+};
+
+#define dmfrsp dmfrbuf /* receive silo parameter register (wo) */
+#define dmftbuf dmfun.dmfirc[0] /* transmit buffer */
+#define dmftsc dmfun.dmfirc[0] /* transmit silo count */
+#define dmfrms dmfun.dmfirc[1] /* receive modem status */
+#define dmflctms dmfun.dmfirw /* line control, transmit modem status */
+#define dmftba dmfun.dmfirw /* transmit buffer address */
+#define dmftcc dmfun.dmfirw /* transmit character count */
+
+/* bits in dmfcsr */
+#define DMF_TI 0100000 /* transmit interrupt */
+#define DMF_TIE 0040000 /* transmit interrupt enable */
+#define DMF_NXM 0020000 /* non-existant memory */
+#define DMF_LIN 0003400 /* transmit line number */
+#define DMF_RI 0000200 /* receiver interrupt */
+#define DMF_RIE 0000100 /* receiver interrupt enable */
+#define DMF_CLR 0000040 /* master reset */
+#define DMF_IAD 0000037 /* indirect address register */
+
+#define DMFIR_TBUF 000 /* select tbuf indirect register */
+#define DMFIR_LCR 010 /* select lcr indirect register */
+#define DMFIR_TBA 020 /* select tba indirect register */
+#define DMFIR_TCC 030 /* select tcc indirect register */
+
+/* bits in dmflpr */
+#define BITS6 (01<<3)
+#define BITS7 (02<<3)
+#define BITS8 (03<<3)
+#define TWOSB 0200
+#define PENABLE 040
+#define EPAR 0100
+
+#define DMF_IE (DMF_TIE|DMF_RIE)
+
+#define DMF_SILOCNT 32 /* size of DMF output silo (per line) */
+
+/* bits in dmfrbuf */
+#define DMF_DSC 0004000 /* data set change */
+#define DMF_PE 0010000 /* parity error */
+#define DMF_FE 0020000 /* framing error */
+#define DMF_DO 0040000 /* data overrun */
+
+/* bits in dmfrms */
+#define DMF_USRR 0004 /* user modem signal (pin 25) */
+#define DMF_SR 0010 /* secondary receive */
+#define DMF_CTS 0020 /* clear to send */
+#define DMF_CAR 0040 /* carrier detect */
+#define DMF_RNG 0100 /* ring */
+#define DMF_DSR 0200 /* data set ready */
+
+/* bits in dmftms */
+#define DMF_USRW 0001 /* user modem signal (pin 18) */
+#define DMF_DTR 0002 /* data terminal ready */
+#define DMF_RATE 0004 /* data signal rate select */
+#define DMF_ST 0010 /* secondary transmit */
+#define DMF_RTS 0020 /* request to send */
+#define DMF_BRK 0040 /* pseudo break bit */
+#define DMF_PREEMPT 0200 /* preempt output */
+
+/* flags for modem control */
+#define DMF_ON (DMF_DTR|DMF_RTS)
+#define DMF_OFF 0
+
+/* bits in dmflctms */
+#define DMF_MIE 0040 /* modem interrupt enable */
+#define DMF_FLUSH 0020 /* flush transmit silo */
+#define DMF_RBRK 0010 /* real break bit */
+#define DMF_RE 0004 /* receive enable */
+#define DMF_AUTOX 0002 /* auto XON/XOFF */
+#define DMF_TE 0001 /* transmit enable */
+
+#define DMFLCR_ENA (DMF_MIE|DMF_RE|DMF_TE)
+
+/* bits in dm lsr, copied from dh.c */
+#define DML_USR 0001000 /* usr modem sig, not a real DM bit */
+#define DML_DSR 0000400 /* data set ready, not a real DM bit */
+#define DML_RNG 0000200 /* ring */
+#define DML_CAR 0000100 /* carrier detect */
+#define DML_CTS 0000040 /* clear to send */
+#define DML_SR 0000020 /* secondary receive */
+#define DML_ST 0000010 /* secondary transmit */
+#define DML_RTS 0000004 /* request to send */
+#define DML_DTR 0000002 /* data terminal ready */
+#define DML_LE 0000001 /* line enable */
+
+/* dmf line printer csr def */
+#define DMFL_PEN (1<<0) /* print enable */
+#define DMFL_RESET (1<<1) /* master reset */
+#define DMFL_FORMAT (1<<2) /* format control */
+#define DMFL_UNUSED (3<<3)
+#define DMFL_MAINT (1<<5) /* maintenance mode on */
+#define DMFL_IE (1<<6) /* intr enable */
+#define DMFL_PDONE (1<<7) /* print done bit */
+#define DMFL_INDIR (7<<8) /* indirect reg */
+#define DMFL_UNUSED2 (1<<11)
+#define DMFL_CONV (1<<12) /* connect verify */
+#define DMFL_DAVRDY (1<<13) /* davfu ready */
+#define DMFL_OFFLINE (1<<14) /* printer offline */
+#define DMFL_DMAERR (1<<15) /* dma error bit */
+#define DMFL_BUFSIZ 512 /* max chars per dma */
+#define DMFL_DEFCOLS 132 /* default # of cols/line <=255 */
+#define DMFL_DEFLINES 66 /* default # of lines/page <=255 */
+#define DMFL_OPTIONS ((1 << 8) | (1 << 9) | (1 << 15))
+ /* auto cr, real ff, no lower to upper */
+
+/*
+ * Bits in the configuration register
+ */
+#define DMFC_CONFMASK 0xf000 /* picks off the configuration bits */
+#define DMFC_DR 0x1000 /* DR11 parallel interface */
+#define DMFC_LP 0x2000 /* LP dma parallel lineprinter i'face */
+#define DMFC_SYNC 0x4000 /* Synchronous serial interface */
+#define DMFC_ASYNC 0x8000 /* 8 Serial ports */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dmreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * DM-11 device register definitions.
+ */
+struct dmdevice {
+ short dmcsr; /* control status register */
+ short dmlstat; /* line status register */
+ short dmpad1[2];
+};
+
+/* bits in dm csr */
+#define DM_RF 0100000 /* ring flag */
+#define DM_CF 0040000 /* carrier flag */
+#define DM_CTS 0020000 /* clear to send */
+#define DM_SRF 0010000 /* secondary receive flag */
+#define DM_CS 0004000 /* clear scan */
+#define DM_CM 0002000 /* clear multiplexor */
+#define DM_MM 0001000 /* maintenance mode */
+#define DM_STP 0000400 /* step */
+#define DM_DONE 0000200 /* scanner is done */
+#define DM_IE 0000100 /* interrupt enable */
+#define DM_SE 0000040 /* scan enable */
+#define DM_BUSY 0000020 /* scan busy */
+
+/* bits in dm lsr */
+#define DML_RNG 0000200 /* ring */
+#define DML_CAR 0000100 /* carrier detect */
+#define DML_CTS 0000040 /* clear to send */
+#define DML_SR 0000020 /* secondary receive */
+#define DML_ST 0000010 /* secondary transmit */
+#define DML_RTS 0000004 /* request to send */
+#define DML_DTR 0000002 /* data terminal ready */
+#define DML_LE 0000001 /* line enable */
+
+#define DML_ON (DML_DTR|DML_RTS|DML_LE)
+#define DML_OFF (DML_LE)
--- /dev/null
+/*
+ * Copyright (c) 1985, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dmzreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * HISTORY
+ * 23-Apr-85 Joe Camaratta (jcc) at Siemens RTL
+ * Header file for DEC's DMZ32
+ */
+
+struct dmzdevice {
+ short dmz_config; /* configuration cntl and status register */
+ short dmz_diag; /* diagnostic control and status register */
+ struct {
+ short octet_csr; /* octet control and status */
+ short octet_lprm; /* line parameter */
+ union{
+ short octet_rb; /* receiver buffer */
+ short octet_rsp; /* receive silo parameter */
+ } octet_receive;
+ union{
+ u_short word; /* word */
+ u_char bytes[2]; /* bytes */
+ } octet_ir; /* indirect registers */
+ } octet[3];
+ short dmz_unused[2];
+};
+
+#define octet_sato octet_rsp
+
+/* aliases for asynchronous indirect control registers */
+#define IR_TBUF 000 /* transmit character */
+#define IR_RMSTSC 000 /* receive modem status, transmit silo count */
+#define IR_LCTMR 010 /* line control and transmit modem */
+#define IR_TBA 020 /* transmit buffer address register */
+#define IR_TCC 030 /* transmit character count (DMA) */
+
+#define octet_tbf octet_ir.bytes[0] /* transmit buffer */
+#define octet_tbf2 octet_ir.word /* transmit buffer, 2 chars */
+#define octet_rmstsc octet_ir.word /* rcv modem status, xmit silo count */
+#define octet_lctmr octet_ir.word /* line control, xmit modem */
+#define octet_tba octet_ir.word /* transmit buffer address */
+#define octet_tcc octet_ir.word /* transmit character count */
+
+/* bits in octet_csr */
+#define DMZ_TRDY 0100000 /* transmit ready */
+#define DMZ_TIE 0040000 /* transmit interrupt enable */
+#define DMZ_NXM 0030000 /* non-existant memory */
+#define DMZ_LIN 0003400 /* transmit line number */
+#define DMZ_RRDY 0000200 /* receiver data available */
+#define DMZ_RIE 0000100 /* receiver interrupt enable */
+#define DMZ_RESET 0000040 /* master reset */
+#define DMZ_IAD 0000037 /* indirect address register */
+
+#define DMZ_IE (DMZ_TIE | DMZ_RIE) /* enable transmit and receive */
+
+/* bits in octet_lprm (taken from dmfreg.h) */
+#define DMZ_6BT 0010 /* 6 bits per character */
+#define DMZ_7BT 0020 /* 7 bits per character */
+#define DMZ_8BT 0030 /* 8 bits per character */
+#define DMZ_PEN 0040 /* parity enable */
+#define DMZ_EPR 0100 /* even parity */
+#define DMZ_SCD 0200 /* stop code */
+#define DMZ_XTE 0170000 /* transmit rate */
+#define DMZ_RRT 0007400 /* receive rate */
+#define DMZ_LSL 0000007 /* line select */
+
+/* baud rates */
+#define BR_50 000
+#define BR_75 001
+#define BR_110 002
+#define BR_134_5 003
+#define BR_150 004
+#define BR_300 005
+#define BR_600 006
+#define BR_1200 007
+#define BR_1800 010
+#define BR_2000 011
+#define BR_2400 012
+#define BR_3600 013
+#define BR_4800 014
+#define BR_7200 015
+#define BR_9600 016
+#define BR_19200 017
+
+/* bits in octet_rb (taken from dmfreg.h) */
+#define DMZ_DSC 0004000 /* data set change */
+#define DMZ_PE 0010000 /* parity error */
+#define DMZ_FE 0020000 /* framing error */
+#define DMZ_DO 0040000 /* data overrun */
+#define DMZ_DV 0100000 /* data valid */
+#define DMZ_RL 0003400 /* line */
+#define DMZ_RD 0000377 /* data */
+#define DMZ_AT 0000377 /* alarm timeout */
+
+/* bits in dmz_rmstsc */
+#define DMZ_TSC 0x00ff /* transmit silo count */
+#define DMZ_USRR 0x0400 /* user modem signal (pin 25) */
+#define DMF_SR 0x0800 /* secondary receive */
+#define DMZ_CTS 0x1000 /* clear to send */
+#define DMZ_CAR 0x2000 /* carrier detect */
+#define DMZ_RNG 0x4000 /* ring */
+#define DMZ_DSR 0x8000 /* data set ready */
+
+/* bits in dmz_lctmr (tms half) */
+#define DMZ_USRW 0x0100 /* user modem signal (pin 18) */
+#define DMZ_DTR 0x0200 /* data terminal ready */
+#define DMZ_RATE 0x0400 /* data signal rate select */
+#define DMF_ST 0x0800 /* secondary transmit */
+#define DMZ_RTS 0x1000 /* request to send */
+#define DMZ_PREEMPT 0x8000 /* preempt output */
+
+/* bits in octet_lctmr (lc half) */
+#define DMZ_MIE 0040 /* modem interrupt enable */
+#define DMZ_FLS 0020 /* flush transmit silo */
+#define DMZ_BRK 0010 /* send break bit */
+#define DMZ_RE 0004 /* receive enable */
+#define DMZ_AUT 0002 /* auto XON/XOFF */
+#define DMZ_TE 0001 /* transmit enable */
+#define DMZ_CF 0300 /* control function */
+
+#define DMZ_LCE (DMZ_MIE|DMZ_RE|DMZ_TE)
+#define DMZ_ON (DMZ_DTR|DMZ_RTS|DMZ_LCE)
+#define DMZ_OFF DMZ_LCE
+
+
+/* bits in octet_tcc */
+#define DMZ_HA 0140000 /* high address bits */
+
+/* bits added to dm lsr for DMGET/DMSET */
+#define DML_USR 0001000 /* usr modem sig, not a real DM bit */
+#define DML_DSR 0000400 /* data set ready, not a real DM bit */
+
+#define DMZ_SIZ 32 /* size of DMZ output silo (per line) */
+
+#define DMZ(a) (a/24)
+#define OCTET(a) ((a%24)/8)
+#define LINE(a) ((a%24)%8)
+
+#define DMZ_NOC_MASK 03
+#define DMZ_INTERFACE 000
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)dzreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * DZ-11/DZ-32 Registers and bits.
+ */
+struct dzdevice {
+ short dzcsr;
+ short dzrbuf;
+ union {
+ struct {
+ char dztcr0;
+ char dzdtr0;
+ char dztbuf0;
+ char dzbrk0;
+ } dz11;
+ struct {
+ short dzlcs0;
+ char dztbuf0;
+ char dzlnen0;
+ } dz32;
+ } dzun;
+};
+
+#define dzlpr dzrbuf
+#define dzmsr dzun.dz11.dzbrk0
+#define dztcr dzun.dz11.dztcr0
+#define dzdtr dzun.dz11.dzdtr0
+#define dztbuf dzun.dz11.dztbuf0
+#define dzlcs dzun.dz32.dzlcs0
+#define dzbrk dzmsr
+#define dzlnen dzun.dz32.dzlnen0
+#define dzmtsr dzun.dz32.dztbuf0
+
+/* bits in dzlpr */
+#define BITS7 0020
+#define BITS8 0030
+#define TWOSB 0040
+#define PENABLE 0100
+#define OPAR 0200
+
+/* bits in dzrbuf */
+#define DZ_PE 010000
+#define DZ_FE 020000
+#define DZ_DO 040000
+
+/* bits in dzcsr */
+#define DZ_32 000001 /* DZ32 mode */
+#define DZ_MIE 000002 /* Modem Interrupt Enable */
+#define DZ_CLR 000020 /* Reset dz */
+#define DZ_MSE 000040 /* Master Scan Enable */
+#define DZ_RIE 000100 /* Receiver Interrupt Enable */
+#define DZ_MSC 004000 /* Modem Status Change */
+#define DZ_SAE 010000 /* Silo Alarm Enable */
+#define DZ_TIE 040000 /* Transmit Interrupt Enable */
+#define DZ_IEN (DZ_32|DZ_MIE|DZ_MSE|DZ_RIE|DZ_TIE)
+
+/* flags for modem-control */
+#define DZ_ON DZ_DTR
+#define DZ_OFF 0
+
+/* bits in dzlcs */
+#define DZ_ACK 0100000 /* ACK bit in dzlcs */
+#define DZ_RTS 0010000 /* Request To Send */
+#define DZ_ST 0004000 /* Secondary Transmit */
+#define DZ_BRK 0002000 /* Break */
+#define DZ_DTR 0001000 /* Data Terminal Ready */
+#define DZ_LE 0000400 /* Line Enable */
+#define DZ_DSR 0000200 /* Data Set Ready */
+#define DZ_RI 0000100 /* Ring Indicate */
+#define DZ_CD 0000040 /* Carrier Detect */
+#define DZ_CTS 0000020 /* Clear To Send */
+#define DZ_SR 0000010 /* Secondary Receive */
+
+/* bits in dm lsr, copied from dmreg.h */
+#define DML_DSR 0000400 /* data set ready, not a real DM bit */
+#define DML_RNG 0000200 /* ring */
+#define DML_CAR 0000100 /* carrier detect */
+#define DML_CTS 0000040 /* clear to send */
+#define DML_SR 0000020 /* secondary receive */
+#define DML_ST 0000010 /* secondary transmit */
+#define DML_RTS 0000004 /* request to send */
+#define DML_DTR 0000002 /* data terminal ready */
+#define DML_LE 0000001 /* line enable */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)idcreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+#define NRB02SECT 40 /* RB02 sectors/track */
+#define NRB02TRK 2 /* RB02 tracks/cylinder */
+#define NRB02CYL 512 /* RB02 cylinders/disk */
+#define NRB80SECT 31 /* RB80 sectors/track */
+#define NRB80TRK 14 /* RB80 tracks/cylinder */
+#define NRB80CYL 559 /* RB80 cylinders/disk */
+
+struct idcdevice
+{
+ int idccsr; /* control status register */
+ int idcbar; /* bus address register */
+ int idcbcr; /* byte count register */
+ int idcdar; /* disk address register */
+ int idcmpr; /* multi-purpose register */
+ int idceccpos; /* ecc position register */
+ int idceccpat; /* ecc pattern register */
+ int idcreset; /* master reset register */
+};
+
+/* idccsr */
+#define IDC_TOI 0x10000000 /* time out inhibit */
+#define IDC_ASSI 0x08000000 /* automatic skip sector inhibit */
+#define IDC_R80 0x04000000 /* selected disk is R80 */
+#define IDC_MTN 0x02000000 /* maintenance */
+#define IDC_IR 0x01000000 /* interrupt request */
+#define IDC_SSE 0x00800000 /* R80 skip sector error */
+#define IDC_SSEI 0x00400000 /* R80 skip sector error inhibit */
+#define IDC_ECS 0x00300000 /* R80 ecc status */
+#define IDC_ECS_NONE 0x00000000 /* no data error */
+#define IDC_ECS_HARD 0x00200000 /* hard ecc error */
+#define IDC_ECS_SOFT 0x00300000 /* soft ecc error */
+#define IDC_ATTN 0x000f0000 /* attention bits */
+#define IDC_ERR 0x00008000 /* composite error */
+#define IDC_DE 0x00004000 /* drive error */
+#define IDC_NXM 0x00002000 /* non-existant memory */
+#define IDC_DLT 0x00001000 /* data late */
+#define IDC_HNF IDC_DLT /* header not found */
+#define IDC_DCK 0x00000800 /* data check */
+#define IDC_OPI 0x00000400 /* operation incomplete */
+#define IDC_DS 0x00000300 /* drive select bits */
+#define IDC_CRDY 0x00000080 /* controller ready */
+#define IDC_IE 0x00000040 /* interrupt enable */
+#define IDC_FUNC 0x0000000e /* function code */
+#define IDC_DRDY 0x00000001 /* drive ready */
+
+#define IDC_HARD (IDC_NXM|IDC_DE)
+
+#define IDCCSR_BITS \
+"\20\35TOI\34ASSI\33R80\32MTN\31IR\30SSE\27SSEI\26ECS1\25ECS0\24ATN3\
+\23ATN2\22ATN1\21ATN0\20ERR\17DE\16NXM\15DLT\14DCK\13OPI\12DS1\11DS0\
+\10CRDY\7IE\4F2\3F1\2F0\1DRDY"
+
+/* function codes */
+#define IDC_NOP 000 /* no operation */
+#define IDC_WCHK 002 /* write check data */
+#define IDC_GETSTAT 004 /* get status */
+#define IDC_SEEK 006 /* seek */
+#define IDC_RHDR 010 /* read header */
+#define IDC_WRITE 012 /* write data */
+#define IDC_READ 014 /* read data */
+#define IDC_RNOHCHK 016 /* read data w/o header check */
+
+/* idcmpr for RL02 get status command */
+#define IDCGS_RST 010 /* reset */
+#define IDCGS_GS 002 /* get status, must be 1 */
+#define IDCGS_M 001 /* mark, must be 1 */
+#define IDCGS_GETSTAT (IDCGS_RST|IDCGS_GS|IDCGS_M)
+
+/* RL02 status word */
+#define IDCDS_WDE 0100000 /* write data error */
+#define IDCDS_HCE 0040000 /* head current error */
+#define IDCDS_WL 0020000 /* write lock */
+#define IDCDS_SKTO 0010000 /* seek timeout */
+#define IDCDS_SPD 0004000 /* spindle error */
+#define IDCDS_WGE 0002000 /* write gate error */
+#define IDCDS_VC 0001000 /* volume check */
+#define IDCDS_DSE 0000400 /* drive select error */
+#define IDCDS_HS 0000100 /* head select */
+#define IDCDS_CO 0000040 /* cover open */
+#define IDCDS_HO 0000020 /* heads out */
+#define IDCDS_BH 0000010 /* brush home */
+#define IDCDS_STATE 0000007 /* drive state */
+
+#define IDCRB02DS_BITS \
+"\10\20WDE\17HCE\16WL\15SKTO\14SPD\13WBE\12VC\11DSE\
+\7HS\6CO\5HO\4BH\3STC\2STB\1STA"
+
+/* R80 status word */
+#define IDCDS_WTP 0020000 /* write protect */
+#define IDCDS_DRDY 0010000 /* driver ready */
+#define IDCDS_ONCY 0004000 /* on cylinder */
+#define IDCDS_SKE 0002000 /* seek error */
+#define IDCDS_PLGV 0001000 /* plug valid */
+#define IDCDS_FLT 0000400 /* fault */
+
+#define IDCRB80DS_BITS \
+"\10\16WTP\15DRDY\14ONCY\13SKE\12PLGV\11FLT\5SEC4\4SEC3\3SEC2\2SEC1\1SEC0"
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ikreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+struct ikdevice {
+ short ik_wc; /* Unibus word count reg */
+ u_short ik_ubaddr; /* Unibus address register */
+ u_short ik_ustat; /* Unibus status/command reg */
+ u_short ik_data; /* Data register */
+ u_short ik_xaddr; /* X address in frame buffer */
+ u_short ik_yaddr; /* Y address in frame buffer */
+ u_short ik_istat; /* Ikonas status/command reg */
+ u_short ik_chan; /* Channel control register */
+};
+
+#define IK_GETADDR IKIOGETADDR
+#define IK_WAITINT IKIOWAITINT
+#define IKIOGETADDR _IOR(i, 0, caddr_t) /* get Unibus device address */
+#define IKIOWAITINT _IO(i, 1) /* await device interrupt */
+
+/*
+ * Unibus status/command register bits
+ */
+
+#define IK_GO 01
+#define IK_IENABLE 0100
+#define IK_READY 0200
+#define IK_IKONAS_INTR 0100000
+
+/*
+ * Ikonas status/command register bits
+ */
+
+#define WORD32 0
+#define RES512 2
+#define RES1024 3
+#define READ_SELECT 0
+#define WRITE_MASK 010
+#define WRITE_SELECT 020
+#define HALFWORD 040
+#define DMAENABLE 0100
+#define INVISIBLE_IO 0200
+#define AUTOINCREMENT 0400
+#define RUN_PROCESSOR 01000
+#define CLEAR 02000
+#define BYTE_MODE 04000
+#define FRAME_ENABLE 010000
+#define PROC_ENABLE 020000
+#define RED_SELECT 0
+#define GREEN_SELECT 040000
+#define BLUE_SELECT 0100000
+#define ALPHA_SELECT 0140000
+
+/*
+ * Frame buffer controller
+ */
+
+#define FBC0 060000000
+#define FBC1 062000000
+
+#define VIEWPORT_LOC 0
+#define VIEWPORT_SIZE 1
+#define WINDOW_LOC 2
+#define ZOOM 3
+#define DISPLAY_RATE 4
+#define VIDEO_CONTROL 5
+#define FORMAT_CONTROL_MASK 03
+#define CURSOR_ON 04
+#define LOW_RESOL 0
+#define HIGH_RESOL 010
+#define AUTO_CLEAR 040
+#define EXT_SYNC 0100
+#define COLOR_MAP_PAGES 0600
+#define HIGH_RESOL_SYNC 01000
+#define REPEAT_FIELD 02000
+#define PIXEL_CLOCK_RATE_MASK 077
+#define CURSOR_LOC 6
+#define CURSOR_SHADE 7
+
+#define CURSOR_MAP 0400
+
+/*
+ * Color map lookup table
+ */
+
+#define CMAP0 040600000
+#define CMAP1 040610000
+
+#define CHAN_SELECT 02000
+
+/*
+ * Frame buffer memories
+ */
+
+#define MEM0 000000000
+#define MEM1 004000000
+
+/*
+ * Bit-slice processor
+ */
+
+#define UMEM 040000000
+#define SCRPAD 040400000
+#define PROC 041200000
+
+/*
+ * Frame grabber
+ */
+
+#define FMG0 060200000
--- /dev/null
+/*
+ * Copyright (c) 1986 MICOM-Interlan, Inc., Boxborough Mass
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)npreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * NPREG.H
+ *
+ * This file contain definitions of specific hardware interest
+ * to be used when communicating with the NI1510 Network Processor
+ * Board. More complete information can be found in the NI1510
+ * Multibus compatible Ethernet Communications Processor Hardware
+ * Specification.
+ */
+
+
+#define NNPCNN 4 /* Number of connections per board */
+#define NPUNIT(a) ((minor(a) >> 4) & 0x0F)
+#define NPCONN(a) ((minor(a)) & 0x03)
+
+#define TRUE 1
+#define FALSE 0
+
+#define IBOOTADDR 0xF8000l /* Addr of 80186 Boot ROM */
+#define INETBOOT 0xF8087l
+#define IXEQADDR 0x400 /* Where to begin Board image XEQ */
+#define DIAGTIME 1200 /* Time for timeout /HZ seconds */
+
+#define DELAYTIME 1000000L /* delay count */
+#define NPDELAY(N) {register int n = (N) >> 1; while(--n > 0); }
+
+/* Handy macros for talking to the Board */
+
+#define RESET(x) (WCSR3(x->iobase,0xff))
+#define CLEARINT(x) {unsign16 y; y = RCSR2(x->iobase); }
+#define INTNI(x) (WCSR1(x->iobase,0xFF))
+
+/* Command and Status Register (CSR) Definitions */
+
+/*
+ * CSR0 is the only direct means for data transfer between the host processor
+ * and the 3510. Access is controlled by the 80186 who sets the CSR1 Enable and
+ * Ready bits to allow writing here. Writing to this register will always
+ * result in an interrupt to the 80186.
+ */
+
+/*
+ * Bit definitions for CSR1.
+ */
+
+#define NPRFU 0x01 /* Reserved for Future Use */
+#define NPHOK 0x02 /* Hardware OK */
+#define NPLAN 0x04 /* Logic 0 indicates operational LAN exists */
+#define NP_IP 0x08 /* Interrupt pending from this board */
+#define NP_IE 0x10 /* Interrupts enabled for this board */
+#define NPRDR 0x20 /* Set when 80186 writes data into CSR0 */
+#define NPRDY 0x40 /* CSR0 ready to accept data */
+#define NPENB 0x80 /* CSR0 available for use by the host */
+
+/*
+ * Bit defintions for CSR0 Command Block
+ */
+
+#define NPLST 0x20 /* Last Command */
+#define NPCMD 0x80 /* Shared Memory Address */
+#define NPBGN 0x200 /* Begin Execution in On-Board Memory */
+#define NPCBI 0x800 /* Interrupt at completion of Command Block */
+#define NPDMP 0x2000 /* Dump 80186 On-Board Memory to Multibus */
+#define NPLD 0x8000 /* Load 80186 On-board Memory from Multibus */
+
+/*
+ * CSR0 Count definitions. These are the lengths of the Command Blocks for the
+ * CSR0 commands above (not counting the Command Word itself).
+ */
+
+#define LSTCNT 0
+#define CMDCNT 2
+#define BGNCNT 2
+#define CBICNT 1
+#define DMPCNT 5
+#define LDCNT 5
+#define IOCNT 5
+
+/* Macros for reading and writing CSR's (Control and Status Registers) */
+
+#define WCSR0(x,y) ((x)->CSR0 = y)
+#define WCSR1(x,y) ((x)->CSR1 = y)
+#define WCSR2(x,y) ((x)->CSR2 = y)
+#define WCSR3(x,y) ((x)->CSR3 = y)
+
+#define RCSR0(x) ((x)->CSR0)
+#define RCSR1(x) ((x)->CSR1)
+#define RCSR2(x) ((x)->CSR2)
+#define RCSR3(x) ((x)->CSR3)
+
+#define NPRESET 0x01 /* reset the board */
+#define NPSTART 0x04 /* start board execution */
+#define NPGPANIC 0x05 /* Get panic message */
+#define NPINIT 0x06 /* initialize software on board */
+#define NPSTATS 0x07
+#define NPRCSR0 0x08 /* read CSR0 */
+#define NPRCSR1 0x09 /* read CSR1 */
+#define NPRCSR2 0x0a /* read CSR2 */
+#define NPRCSR3 0x0b /* read CSR3 */
+#define NPWCSR0 0x0c /* write CSR0 */
+#define NPWCSR1 0x0d /* write CSR1 */
+#define NPWCSR2 0x0e /* write CSR2 */
+#define NPWCSR3 0x0f /* write CSR3 */
+#define NPPOLL 0x10
+#define NPKILL 0x11
+#define NPSETPROT 0x12 /* set the protocol to use */
+#define NPSETBOARD 0x13 /* set board to use */
+#define NPSETNPDEB 0x14 /* set nc debuging level */
+#define NPSETADDR 0x15 /* set host address */
+#define NPNETBOOT 0x16 /* boot from the network */
+
+/* ICP Board Requests */
+
+#define ICPLOAD 0x02
+#define ICPDUMP 0x03
+#define ICPPANIC 0x05
+#define ICPPOLL 0x10
+
+/*
+ * Typedefs for the VAX
+ */
+
+typedef short sign16; /* 16 bit signed value */
+typedef unsigned short unsign16; /* 16 bit unsigned value */
+typedef unsigned unsign32; /* 32 bit unsigned value */
+typedef long paddr_t; /* Physical addresses */
+
+
+/*
+ * Tunables
+ */
+
+
+#define NUMCQE 40 /* Number of CQE's per board */
+
+/* Host configuration word in Status Block */
+
+/*
+ * To disable the lock/unlock internal function calls clear the 0x8000
+ * bit in the host configuration word (HOSTCONF)
+ */
+
+#define HOSTCONF 0x0109 /* See above */
+#define LOWBYTE 1
+#define HIGHBYTE 0
+#define BUFFMAPPED 0
+
+/*
+ * Memory mapping definintions for PM68DUAL hardware.
+ */
+
+#ifdef PM68DUAL
+#define PISHMEM 0x200000
+#define PISHMEMSIZE 2
+#define PIOFF 0x8000 /* change this to unique mem add. */
+#define PIWINDOW MBUSBUFR + PIOFF
+#define WINDOWSIZE 2
+#endif
+#define NPMAXXFR 32768 /* Maximum number of bytes / read */
+
+/*
+ * Define the protocols supported by the NP Driver.
+ */
+
+#define NONE 0x00 /* No protocols active for a process */
+#define NPMAINT 0x01 /* Maintenance protocol, superusers only */
+#define NPNTS 0x02 /* NTS Terminal Server */
+#define NPDLA 0x04 /* Direct Datalink Access */
+#define NPXNS 0x06 /* Xerox NS ITP */
+#define NPTCP 0x08 /* TCP/IP */
+#define NPISO 0x0A /* ISO */
+#define NPCLCONN 0xFF /* Closed connection, i.e. no protocol */
+
+/*
+ * Convert the protocol to a value used in the Device Protocol Mask field
+ * of the Shared Memory Status Block.
+ */
+
+#define PROTOMASK(x) ( 1 << (x) )
+
+/*
+ * Special requests handled by the NP Driver
+ */
+
+#define OS_STP 03400 /* Shut down connection on I Board */
+#define NPSTOP 3 /* Conversion from above (OS_STP) */
+#define NPCHNGP 50 /* Change the protocol on a connection */
+#define NPCHNGB 51 /* Change the Board number */
+
+/*
+ * Miscellaneous
+ */
+
+#define ON 0x8000 /* Used for Command Q's scan and change flag */
+#define UBADDRMASK 0x3FFFF /* 18 bit UNIBUS address */
+#define INTMASK 0xFFFFFFFC /* Used for address validation */
+#define CMDMASK 0xFFFF /* Mask ioctl cmd field (see ioctl.h) */
+#define NPPSADDR 0x324 /* Pointer to addr of on-board panic string */
+#define PANLEN 133 /* length of the panic buffer */
+
+/*
+ * Map function code from user to I-Board format
+ */
+
+#define FUNCTMAP(x) (((x) << 6) | 077) /* Maps user function to NP funcs */
+
+/*
+ * Round up to a 16 byte boundary
+ */
+
+#define ROUND16(x) (((x) + 15) & (~0x0F)) /* Round to 16 byte boundary */
+#define ADDR24 1 /* Used by iomalloc() to specify 24 bit address */
+
+#define NPERRSHIFT 8 /* Used in function ReqDone() */
+#define NPOK 0
+
+#define LOWORD(X) (((ushort *)&(X))[0])
+#define HIWORD(X) (((ushort *)&(X))[1])
+
+/* Everyday flag settings */
+
+#define NPSET 1
+#define NPCLEAR 0
+
+/*
+ * Command Queue Elements are the primary data structure for passing data
+ * between the driver and the device.
+ */
+
+struct CQE {
+
+ struct npreq *cqe_reqid;/* Address of asssociated npreq */
+ unsign32 cqe_famid; /* Family ID (Process ID) */
+ unsign16 cqe_func; /* I/O function to be performed */
+#ifdef mc68000
+ char cqe_prot; /* Protocol type for I/O request */
+ char cqe_lenrpb; /* Length of the RPB in bytes */
+#else
+ char cqe_lenrpb; /* Length of the RPB in bytes */
+ char cqe_prot; /* Protocol type for I/O request */
+#endif
+ unsign16 cqe_ust0; /* Protocol status return */
+ unsign16 cqe_ust1; /* Protocol status return */
+ unsign16 cqe_devrsv; /* Reserved for use by device only! */
+#ifdef mc68000
+ char cqe_char; /* CQE characteristics */
+ char cqe_sts; /* Status return from device to user */
+ char cqe_wind; /* Buffer mapping window size (page units) */
+ char cqe_nbuf; /* Number of data buffers for I/O */
+#else
+ char cqe_sts; /* Status return from device to user */
+ char cqe_char; /* CQE characteristics */
+ char cqe_nbuf; /* Number of data buffers for I/O */
+ char cqe_wind; /* Buffer mapping window size (page units) */
+#endif
+ unsign16 cqe_bcnt; /* Total number of bytes in the data buffer */
+ unsign16 cqe_unused; /* Unused */
+ unsign16 cqe_dma[2]; /* Address of the MULTIBUS data buffer */
+ unsign16 rpb1; /* Word 1 of protocol parameters */
+ unsign16 rpb2; /* Word 2 of protocol parameters */
+ unsign16 rpb3; /* Word 3 of protocol parameters */
+ unsign16 rpb4; /* Word 4 of protocol parameters */
+ unsign16 rpb5; /* Word 5 of protocol parameters */
+ unsign16 rpb6; /* Word 6 of protocol parameters */
+ unsign16 rpb7; /* Word 7 of protocol parameters */
+ unsign16 rpb8; /* Word 8 of protocol parameters */
+ unsign16 rpb9; /* Word 9 of protocol parameters */
+ unsign16 rpb10; /* Word 10 of protocol parameters */
+ unsign16 rpb11; /* Word 11 of protocol parameters */
+ unsign16 rpb12; /* Word 12 of protocol parameters */
+
+};
+
+/*
+ * NP Driver Request structure contains information about a request
+ * maintained solely by the driver. One per CQE, plus a header.
+ */
+
+struct npreq {
+
+ struct npreq *forw; /* Forward pointer for active list */
+ struct npreq *back; /* Backward pointer for active list */
+ struct npreq *free; /* Next member on free list */
+ struct CQE *element; /* CQE associated with this request */
+ int flags; /* Always useful */
+ int reqcnt; /* Request count for reqtab */
+ int bufoffset; /* Offset into buffer for turns */
+ int bytecnt; /* Number of bytes to transfer */
+ caddr_t virtmem; /* Virtual address of buffer */
+ int mapbase; /* Address of the mapping register */
+ int mapsize; /* Size of mapped area */
+ caddr_t bufaddr; /* Address of the user buffer */
+ struct buf buf; /* Buf structure needed for mem. mgmt */
+ struct proc *procp; /* Pointer to process of requestor */
+ caddr_t user; /* Structure passed by user from itpuser.h */
+/* int (*intr)();*/ /* Ptr to routine to call at interrupt time */
+};
+
+/*
+ * Npmaster structure, one per device, is used for boardwise centralization
+ * of relevant information including queues, I/O addresses and request pools.
+ */
+
+struct npmaster {
+
+ struct npmaster *next; /* Linked list of these, NULL terminator */
+ struct npspace *shmemp; /* Shared memory address (driver <-> device) */
+ struct uba_device *devp; /* UBA Device for this unit */
+ struct NPREG *iobase; /* I/O base address for this board */
+ struct npreq *reqtab; /* Header for pool of CQE requests */
+ int iomapbase; /* Base index of I/O map reg's allocated */
+ int flags; /* State of the Board */
+ int unit; /* Unit number of this device */
+ int vector; /* Interrupt vector for this unit */
+};
+
+struct npconn {
+
+ struct npmaster *unit; /* Unit number (board) of this connection */
+ unsign16 protocol; /* Protocol used on this connection */
+ struct buf np_wbuf; /* write buf structure for raw access */
+ struct buf np_rbuf; /* read buf structure for raw access */
+};
+
+struct NPREG {
+ unsign16 CSR0; /* Control Status Register 0 */
+ unsign16 CSR1; /* Control Status Register 1 */
+ unsign16 CSR2; /* Control Status Register 2 */
+ unsign16 CSR3; /* Control Status Register 3 */
+
+};
+
+/*
+ * The following structures are used for communicating with the
+ * Intelligent Board and are located in Shared Memory.
+ */
+
+/*
+ * Status Block
+ */
+
+struct NpStat{
+
+ unsign16 sb_drw; /* Device Request Word */
+ unsign16 sb_hcw; /* Host Configuration Word */
+ unsign16 sb_dcw; /* Device Configuration Word */
+ unsign16 sb_dpm; /* Device Protocol Mask */
+ unsign16 sb_dcq; /* Offset to Device CQ */
+ unsign16 sb_hcq; /* Offset to Host CQ */
+};
+
+/*
+ * Command Queue, two per device. One is owned by the driver and the other
+ * is owned by the device.
+ */
+
+struct CmdQue {
+
+ unsign16 scanflag; /* Scan Flag, MSB set if being scanned */
+ unsign16 chngflag; /* Change Flag, MSB set by initiator */
+ unsign16 cq_wrap; /* Offset to last CQE entry +2 */
+ unsign16 cq_add; /* Offset to add a CQE to the queue */
+ unsign16 cq_rem; /* Offset to remove a CQE from the queue */
+ unsign16 cq_cqe[NUMCQE]; /* Command Queue Element Offsets */
+};
+
+/*
+ * Structure of the shared memory area per board. Declared this way to avoid
+ * compiler word alignment vagaries when computing offsets.
+ */
+
+struct npspace {
+
+ struct NpStat statblock; /* Status Block */
+ struct CmdQue devcq; /* Device's Command Queue */
+ struct CmdQue hostcq; /* Host's Command Queue */
+ struct CQE elements[NUMCQE]; /* Shared Command Queue Elements */
+ unsign16 filler[8]; /* Here for 16 byte alignment */
+};
+
+/*
+ * Structure of array of base addresses of I-Board controllers
+ * (See global data definitions in np.c)
+ */
+
+struct npbase {
+ caddr_t baseaddr;
+};
+
+/* State of the NP Driver as kept in NpState */
+
+#define ICPAVAIL 0x01 /* ICP is waiting for a request */
+
+/* Tells ICP Process that there are no more requests for this board */
+
+#define BRDDONE 1
+
+/* Flags used by the driver (npreq structure) to monitor status of requests */
+
+#define REQDONE 0x01 /* Request completed */
+#define IOIFC 0x02 /* Internal Function Code Request */
+#define IOERR 0x04 /* Error on Request */
+#define NPPEND 0x08 /* Unused at this time */
+#define IOABORT 0x10 /* Request aborted by ICP */
+#define KERNREQ 0x20 /* Request was from the kernel */
+#define WANTREQ 0x40 /* Process is waiting for a npreq structure */
+#define NPUIO 0x80 /* Process doing physio */
+
+/* Service Request Commands from the Intelligent Board */
+
+#define NOREQ 0x00 /* No service requested */
+#define NPLOAD 0x01 /* Dump request */
+#define NPDUMP 0x02 /* Load request */
+#define NPPANIC 0x100 /* Panic request */
+
+/* Definitions of Status returned from the I-Board */
+
+#define NPDONE 0x01 /* Normal completion */
+#define NPIFC 0x00 /* Internal Function Code request */
+#define NPPERR 0x80 /* Protocol error */
+#define NPMERR 0x82 /* Memory allocation failure on I-Board */
+
+/* Definitions of IFC type requests from I-Board */
+
+#define NPLOCK 0x64 /* Lock the process's data area */
+#define NPUNLOCK 0xA4 /* Unlock the process */
+#define NPREMAP 0x124 /* Window turn */
+
+/* Definition of flags for the Npmaster structure */
+
+#define CSRPEND 0x01 /* CSR0 command pending */
+#define PANICREQ 0x02 /* Panic request */
+#define DUMPREQ 0x04 /* Dump request */
+#define LOADREQ 0x08 /* Load request */
+#define BOARDREQ 0x10 /* Any request by the board */
+#define BADBOARD 0x20 /* Board disabled */
+#define AVAILABLE 0x40 /* Board available */
+#define BRDRESET 0x80 /* Board is being reset */
+#define PANIC1 0x100 /* Driver wants panic address */
+#define PANIC2 0x200 /* Driver wants panic string */
+#define PANIC3 0x400 /* Clear first byte of panic string */
+
+/*
+ * Debugging Constants
+ */
+
+#define DEBENTRY 0x0001 /* debug entry points */
+#define DEBMEM 0x0002 /* debug memory */
+#define DEBREQ 0x0004 /* debug requests */
+#define DEBCQE 0x0008 /* debug cqe's */
+#define DEBCQ 0x0010 /* debug cq's */
+#define DEBMAINT 0x0020 /* debug maintainance requests */
+#define DEBINTR 0x0040 /* debug interrupt routines */
+#define DEBINIT 0x0080 /* debug initialization routines */
+#define DEBIFC 0x0100 /* debug Internal function codes */
+#define DEBIOCTL 0x0200 /* debug ioctl calls */
+#define DEBOPEN 0x0400 /* debug open calls */
+#define DEBIO 0x0800 /* debug read & write calls */
+#define DEBCSR 0x1000 /* debug CSR commands */
+#define DEBLOCK 0x2000 /* debug lock / unlock calls */
+#define NOBOARD 0x4000 /* debug user/host interface */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)pdma.h 7.1 (Berkeley) 6/5/86
+ */
+
+struct pdma {
+ struct dzdevice *p_addr;
+ char *p_mem;
+ char *p_end;
+ int p_arg;
+/* int (*p_fcn)();*/
+};
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)psreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+
+/*
+ * The Real Nitty Gritty Device Registers
+ */
+
+struct psdevice {
+ short int ps_data; /* data register */
+ short int ps_addr; /* address register */
+ short int ps_wcount; /* word count register */
+ short int ps_busaddr; /* unibus address register */
+ short int ps_iostat; /* io status register */
+};
+
+/*
+ * Possible ioctl's
+ */
+#define PSIOAUTOREFRESH _IO(p, 0) /* auto refresh */
+#define PSIOSINGLEREFRESH _IO(p, 1) /* single refresh */
+#define PSIOAUTOMAP _IO(p, 2) /* auto map */
+#define PSIOSINGLEMAP _IO(p, 3) /* single map */
+#define PSIODOUBLEBUFFER _IO(p, 4) /* double buffer */
+#define PSIOSINGLEBUFFER _IO(p, 5) /* single buffer */
+#define PSIOWAITREFRESH _IO(p, 6) /* await refresh */
+#define PSIOWAITMAP _IO(p, 7) /* await map */
+#define PSIOWAITHIT _IO(p, 8) /* await hit */
+#define PSIOSTOPREFRESH _IO(p, 9) /* stop refresh */
+#define PSIOSTOPMAP _IO(p,10) /* stop map */
+#define PSIOGETADDR _IOR(p,11, int) /* get Unibus address */
+#define PSIOTIMEREFRESH _IO(p,12) /* time refresh */
+
+/*
+ * Picture system io status register bits
+ */
+
+#define DIOREADY 0100000
+#define PSAHOLD 040000
+#define PSRESET 020000
+#define DIORESET 010000
+#define DMARESET 04000
+#define PSIE 0400
+#define DMAREADY 0200
+#define DMAIE 0100
+#define PASSIVE 010
+#define DMAIN 04
+#define NEXEM 02
+#define GO 01
+
+/*
+ * Picture system memory mapping control registers: SCB 0177400-0177410
+ */
+
+#define EXMMR_DMA 0177400
+#define EXMMR_DIO 0177404
+#define EXMMR_RC 0177405
+#define EXMMR_MAPOUT 0177406
+#define EXMMR_MAPIN 0177407
+#define EXMSR 0177410
+
+/*
+ * Extended memory status register bits
+ */
+
+#define DBERROR 0100000
+#define SBERROR 040000
+#define MEMREADY 0200
+#define DBIE 0100
+#define MMENBL 02
+#define INITMEM 01
+
+/*
+ * Size of extended memory
+ */
+
+#define NEXMPAGES (256*2)
+#define WORDSPERPAGE (256)
+
+/*
+ * MAP picture processor registers: SCB 0177750-0177753
+ */
+
+#define MAOL 0177750
+#define MAOA 0177751
+#define MAIA 0177752
+#define MASR 0177753
+#define MAMSR 0177754
+
+/*
+ * MAP status register bits
+ */
+
+#define PPDONE 0100000
+#define FIFOFULL 040000
+#define FIFOEMPTY 020000
+#define HIT 010000
+#define IB 04000
+#define TAKE 02000
+#define MMODE 01400
+#define MOSTOPPED 0200
+#define IOUT 0100
+#define MAO 040
+#define MAI 020
+#define HIT_HOLD 010
+#define RSR_HOLD 04
+#define VEC_HOLD 02
+#define MAP_RESET 01
+
+/*
+ * Refresh controller registers: SCB 0177730-0177737
+ */
+
+#define RFCSN 0177730
+#define RFSN 0177731
+#define RFAWA 0177732
+#define RFAWL 0177733
+#define RFAIA 0177734
+#define RFASA 0177735
+#define RFAIL 0177736
+#define RFSR 0177737
+
+/*
+ * Refresh controller status register bits
+ */
+
+#define RFSTOPPED 0100000
+#define RFHOLD 040000
+#define RFSTART 020000
+#define AUTOREF 010000
+#define RFBLANK 04000
+#define RIGHT 02000
+#define LGFIFO_FULL 01000
+#define NOT_EXEC 0200
+#define SKIPSEG 0100
+#define WRITEBACK 040
+#define SEARCH 020
+#define MATCH_HOLD 010
+#define MATCH_DEC 04
+#define SEARCH_MODE 03
+
+/*
+ * Interrupt control
+ */
+
+#define RTCREQ 0177760
+#define RTCIE 0177761
+#define SYSREQ 0177762
+#define SYSIE 0177763
+#define DEVREQ 0177764
+#define DEVIE 0177765
+
+/*
+ * System interrupt request bits
+ */
+
+#define LPEN_REQ 0200
+#define MATCH_REQ 0100
+#define WBSTOP_REQ 040
+#define RFSTOP_REQ 020
+#define MOSTOP_REQ 010
+#define JUMP_REQ 04
+#define HIT_REQ 02
+#define HALT_REQ 01
+
+/*
+ * Real-Time Clock registers
+ */
+
+#define RTCCNT 0177744
+#define RTCSR 0177745
+
+/*
+ * Real-Time Clock status register bits
+ */
+
+#define HZ120 040
+#define EXT 020
+#define SYNC 010
+#define EXTSEL2 04
+#define EXTSEL1 02
+#define RUN 01
+
+/*
+ * Control dials a/d registers
+ */
+
+#define ADDR0 0177500
+#define ADDR1 0177501
+#define ADDR2 0177502
+#define ADDR3 0177503
+#define ADDR4 0177504
+#define ADDR5 0177505
+#define ADDR6 0177506
+#define ADDR7 0177507
+
+/*
+ * Function switches and lights
+ */
+
+#define FSWR 0177626
+#define FSLR 0177627
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)rkreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+#define NRK7CYL 815
+#define NRK6CYL 411
+#define NRKSECT 22
+#define NRKTRK 3
+
+struct rkdevice
+{
+ short rkcs1; /* control status reg 1 */
+ short rkwc; /* word count */
+ u_short rkba; /* bus address */
+ short rkda; /* disk address */
+ short rkcs2; /* control status reg 2 */
+ short rkds; /* drive status */
+ short rker; /* driver error register */
+ short rkatt; /* attention status/offset register */
+ short rkcyl; /* current cylinder register */
+ short rkxxx;
+ short rkdb; /* data buffer register */
+ short rkmr1; /* maint reg 1 */
+ short rkec1; /* burst error bit position */
+ short rkec2; /* burst error bit pattern */
+ short rkmr2; /* maint reg 2 */
+ short rkmr3; /* maint reg 3 */
+};
+
+/* rkcs1 */
+#define RK_CCLR 0100000 /* controller clear (also error) */
+#define RK_CERR RK_CCLR
+#define RK_DI 0040000 /* drive interrupt */
+#define RK_DTCPAR 0020000 /* drive to controller parity */
+#define RK_CFMT 0010000 /* 18 bit word format */
+#define RK_CTO 0004000 /* controller timeout */
+#define RK_CDT 0002000 /* drive type (rk07/rk06) */
+/* bits 8 and 9 are the extended bus address */
+#define RK_CRDY 0000200 /* controller ready */
+#define RK_IE 0000100 /* interrupt enable */
+/* bits 1 to 4 are the function code */
+#define RK_GO 0000001
+
+/* commands */
+#define RK_SELECT 000 /* select drive */
+#define RK_PACK 002 /* pack acknowledge */
+#define RK_DCLR 004 /* drive clear */
+#define RK_UNLOAD 006 /* unload */
+#define RK_START 010 /* start spindle */
+#define RK_RECAL 012 /* recalibrate */
+#define RK_OFFSET 014 /* offset */
+#define RK_SEEK 016 /* seek */
+#define RK_READ 020 /* read data */
+#define RK_WRITE 022 /* write data */
+#define RK_RHDR 026 /* read header */
+#define RK_WHDR 030 /* write header */
+
+/* rkcs2 */
+#define RKCS2_DLT 0100000 /* data late */
+#define RKCS2_WCE 0040000 /* write check */
+#define RKCS2_UPE 0020000 /* unibus parity */
+#define RKCS2_NED 0010000 /* non-existant drive */
+#define RKCS2_NEM 0004000 /* non-existant memory */
+#define RKCS2_PGE 0002000 /* programming error */
+#define RKCS2_MDS 0001000 /* multiple drive select */
+#define RKCS2_UFE 0000400 /* unit field error */
+#define RKCS2_OR 0000200 /* output ready */
+#define RKCS2_IR 0000100 /* input ready */
+#define RKCS2_SCLR 0000040 /* subsystem clear */
+#define RKCS2_BAI 0000020 /* bus address increment inhibit */
+#define RKCS2_RLS 0000010 /* release */
+/* bits 0-2 are drive select */
+
+#define RKCS2_BITS \
+"\10\20DLT\17WCE\16UPE\15NED\14NEM\13PGE\12MDS\11UFE\
+\10OR\7IR\6SCLR\5BAI\4RLS"
+
+#define RKCS2_HARD (RKCS2_NED|RKCS2_PGE)
+
+/* rkds */
+#define RKDS_SVAL 0100000 /* status valid */
+#define RKDS_CDA 0040000 /* current drive attention */
+#define RKDS_PIP 0020000 /* positioning in progress */
+/* bit 12 is spare */
+#define RKDS_WRL 0004000 /* write lock */
+/* bits 9 and 10 are spare */
+#define RKDS_DDT 0000400 /* disk drive type */
+#define RKDS_DRDY 0000200 /* drive ready */
+#define RKDS_VV 0000100 /* volume valid */
+#define RKDS_DROT 0000040 /* drive off track */
+#define RKDS_SPLS 0000020 /* speed loss */
+#define RKDS_ACLO 0000010 /* ac low */
+#define RKDS_OFF 0000004 /* offset mode */
+#define RKDS_DRA 0000001 /* drive available */
+
+#define RKDS_DREADY (RKDS_DRA|RKDS_VV|RKDS_DRDY)
+#define RKDS_BITS \
+"\10\20SVAL\17CDA\16PIP\14WRL\11DDT\
+\10DRDY\7VV\6DROT\5SPLS\4ACLO\3OFF\1DRA"
+#define RKDS_HARD (RKDS_ACLO|RKDS_SPLS)
+
+/* rker */
+#define RKER_DCK 0100000 /* data check */
+#define RKER_UNS 0040000 /* drive unsafe */
+#define RKER_OPI 0020000 /* operation incomplete */
+#define RKER_DTE 0010000 /* drive timing error */
+#define RKER_WLE 0004000 /* write lock error */
+#define RKER_IDAE 0002000 /* invalid disk address error */
+#define RKER_COE 0001000 /* cylinder overflow error */
+#define RKER_HRVC 0000400 /* header vertical redundancy check */
+#define RKER_BSE 0000200 /* bad sector error */
+#define RKER_ECH 0000100 /* hard ecc error */
+#define RKER_DTYE 0000040 /* drive type error */
+#define RKER_FMTE 0000020 /* format error */
+#define RKER_DRPAR 0000010 /* control-to-drive parity error */
+#define RKER_NXF 0000004 /* non-executable function */
+#define RKER_SKI 0000002 /* seek incomplete */
+#define RKER_ILF 0000001 /* illegal function */
+
+#define RKER_BITS \
+"\10\20DCK\17UNS\16OPI\15DTE\14WLE\13IDAE\12COE\11HRVC\
+\10BSE\7ECH\6DTYE\5FMTE\4DRPAR\3NXF\2SKI\1ILF"
+#define RKER_HARD \
+ (RKER_WLE|RKER_IDAE|RKER_COE|RKER_DTYE|RKER_FMTE|RKER_ILF)
+
+/* offset bits in rkas */
+#define RKAS_P400 0020 /* +400 RK06, +200 RK07 */
+#define RKAS_M400 0220 /* -400 RK06, -200 RK07 */
+#define RKAS_P800 0040 /* +800 RK06, +400 RK07 */
+#define RKAS_M800 0240 /* -800 RK06, -400 RK07 */
+#define RKAS_P1200 0060 /* +800 RK06, +400 RK07 */
+#define RKAS_M1200 0260 /* -1200 RK06, -1200 RK07 */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)rlreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+struct rldevice {
+ short rlcs; /* control status */
+ u_short rlba; /* bus address */
+ union { /* disk address */
+ u_short seek; /* disk seek address */
+ u_short rw; /* disk read/write address */
+ u_short getstat; /* get disk status command */
+ } rlda;
+ union { /* multi-purpose register */
+ u_short getstat; /* get status */
+ u_short readhdr; /* read header */
+ u_short rw; /* read/write word count */
+ } rlmp;
+};
+
+#define NRLCYLN 512 /* number of cylinders per disk */
+#define NRLTRKS 2 /* number of tracks per cylinder */
+#define NRLSECT 40 /* number of sectors per track */
+#define NRLBPSC 256 /* bytes per sector */
+
+/* rlcs */
+/* commands */
+#define RL_NOOP 0000000 /* no-operation */
+#define RL_WCHECK 0000002 /* write check */
+#define RL_GETSTAT 0000004 /* get status */
+#define RL_SEEK 0000006 /* seek */
+#define RL_RHDR 0000010 /* read header */
+#define RL_WRITE 0000012 /* write data */
+#define RL_READ 0000014 /* read data */
+#define RL_RDNCK 0000016 /* read data without hdr check */
+
+#define RL_DRDY 0000001 /* When set indicates drive ready */
+#define RL_BAE 0000060 /* UNIBUS address bits 16 & 17 */
+#define RL_IE 0000100 /* interrupt enable */
+#define RL_CRDY 0000200 /* controller ready */
+#define RL_DS0 0000400 /* drive select 0 */
+#define RL_DS1 0001000 /* drive select 1 */
+#define RL_OPI 0002000 /* operation incomplete */
+#define RL_DCRC 0004000 /* CRC error occurred */
+#define RL_DLT 0010000 /* data late or header not found */
+#define RL_NXM 0020000 /* non-existant memory */
+#define RL_DE 0040000 /* selected drive flagged an error */
+#define RL_ERR 0100000 /* composite error */
+
+#define RL_DCRDY (RL_DRDY | RL_CRDY)
+
+#define RLCS_BITS \
+"\10\20ERR\17DE\16NXM\15DLT\14DCRC\13OPI\1DRDY"
+
+/* da_seek */
+#define RLDA_LOW 0000001 /* lower cylinder seek */
+#define RLDA_HGH 0000005 /* higher cylinder seek */
+#define RLDA_HSU 0000000 /* upper head select */
+#define RLDA_HSL 0000020 /* lower head select */
+#define RLDA_CA 0177600 /* cylinder address */
+
+/* da_rw */
+#define RLDA_SA 0000077 /* sector address */
+#define RLDA_HST 0000000 /* upper head select */
+#define RLDA_HSB 0000100 /* lower head select */
+
+/* da_getstat */
+
+#define RL_GSTAT 0000003 /* Get status */
+#define RL_RESET 0000013 /* get status with reset */
+
+/* mp_getstat */
+#define RLMP_STA 0000001 /* drive state: load cartridge */
+#define RLMP_STB 0000002 /* drive state: brush cycle */
+#define RLMP_STC 0000004 /* drive state: seek */
+#define RLMP_BH 0000010 /* set when brushes are home */
+#define RLMP_HO 0000020 /* set when brushes over the disk */
+#define RLMP_CO 0000040 /* set when cover open */
+#define RLMP_HS 0000100 /* indicates selected head:
+ 0 upper head
+ 1 lower head */
+#define RLMP_DT 0000200 /* indicates drive type:
+ 0 RL01
+ 1 RL02 */
+#define RLMP_DSE 0000400 /* set on multiple drive selection */
+#define RLMP_VC 0001000 /* set on pack mounted and spining */
+#define RLMP_WGE 0002000 /* write gate error */
+#define RLMP_SPE 0004000 /* spin speed error */
+#define RLMP_SKTO 0010000 /*\\b* seek time out error */
+#define RLMP_WL 0020000 /* set on protected drive */
+#define RLMP_CHE 0040000 /* current head error */
+#define RLMP_WDE 0100000 /* write data error */
+
+/* mp_rhc */
+#define RLMP_SA 0000077 /* sector address */
+#define RLMP_CA 0177600 /* cylinder address */
+
+/* check these bits after a get status and reset */
+#define RLMP_STATUS (RLMP_WDE|RLMP_CHE|RLMP_SKTO|RLMP_SPE|RLMP_WGE \
+ |RLMP_VC|RLMP_DSE|RLMP_CO|RLMP_HO|RLMP_BH|RLMP_STC|RLMP_STB|RLMP_STA)
+
+/* these are the bits that should be on in the above check */
+#define RLMP_STATOK (RLMP_HO|RLMP_BH|RLMP_STC|RLMP_STA)
+
+/* mp_rw */
+#define RLMP_WC 0017777 /* word count 2's complement */
+
+#define RLER_BITS \
+"\10\20WDE\17CHE\16WL\15SKTO\14SPE\13WGE\12VC\11DSE\
+\10DT\7HS\6CO\5HO\4BH\3STC\2STB\1STA"
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)rxreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+#ifdef KERNEL
+/*#include "ioctl.h"*/
+#else
+/*#include <sys/ioctl.h>*/
+#endif
+
+/*
+ * RX02 registers
+ */
+struct rxdevice {
+ short rxcs; /* control/status register */
+ short rxdb; /* data buffer register */
+};
+
+/*
+ * RX211 Command and Status Register (RX2CS)
+ */
+#define RX_DRV0 0x0000 /* select drive 0 */
+#define RX_DRV1 0x0010 /* select drive 1 */
+#define RX_DONE 0x0020 /* function complete */
+#define RX_INTR 0x0040 /* interrupt enable */
+#define RX_TREQ 0x0080 /* transfer request (data only) */
+#define RX_SDEN 0x0000 /* single density */
+#define RX_DDEN 0x0100 /* double density */
+#define RX_EXT 0x3000 /* extended address bits */
+#define RX_INIT 0x4000 /* initialize RX211 interface */
+#define RX_ERR 0x8000 /* general error bit */
+
+/*
+ * RX211 control function bits (0-3 of RX2CS)
+ */
+#define RX_FILL 0x0001 /* fill the buffer */
+#define RX_EMPTY 0x0003 /* empty the buffer */
+#define RX_WRITE 0x0005 /* write the buffer to disk */
+#define RX_READ 0x0007 /* read a disk sector to the buffer */
+#define RX_FORMAT 0x0009 /* set the media density (format) */
+#define RX_RDSTAT 0x000b /* read the disk status */
+#define RX_WDDS 0x000d /* write a deleted-data sector */
+#define RX_RDERR 0x000f /* read the error registers */
+
+#define RXCS_BITS \
+"\20\20RX_ERR\17RX_INIT\11RX_DDEN\10RX_TREQ\7RX_IE\6RX_DONE\5RX_DRV1"
+
+/*
+ * RX211 Error and Status Register (RX2ES) --
+ * information is located in RX2DB after completion of function.
+ * The READY bit's value is available only after a "read status".
+ */
+#define RXES_CRCERR 0x0001 /* CRC error (data read error) */
+#define RXES_IDONE 0x0004 /* reinitialization complete */
+#define RXES_DENERR 0x0010 /* density error */
+#define RXES_DBLDEN 0x0020 /* set if double density */
+#define RXES_DDMARK 0x0040 /* deleted-data mark */
+#define RXES_READY 0x0080 /* drive is ready */
+
+#define RXES_BITS \
+"\20\14RXES_NXM\13RXES_WCOF\11RXES_DRV1\10RXES_RDY\7RXES_DDMK\6RXES_DDEN\5\
+RXES_DNER\4RXES_ACLO\3RXES_ID\1RXES_CRC"
+
+/*
+ * Ioctl commands, move to dkio.h later
+ */
+#define RXIOC_FORMAT _IOW(d, 1, int) /* format the disk */
+#define RXIOC_WDDS _IOW(d, 2, int) /* write `deleted data' mark */
+ /* on next sector */
+#define RXIOC_RDDSMK _IOR(d, 3, int) /* did last read sector contain */
+ /* `deleted data'?*/
+#define RXIOC_GDENS _IOR(d, 4, int) /* return density of current disk */
+
+#ifdef RXDEFERR
+/*
+ * Table of values for definitive error code (rxxt[0] & 0xff)
+ */
+struct rxdeferr {
+ short errval;
+ char *errmsg;
+} rxdeferr[] = {
+ { 0010, "Can't find home on drive 0" },
+ { 0020, "Can't find home on drive 1" },
+ { 0040, "Bad track number requested" },
+ { 0050, "Home found too soon" },
+ { 0070, "Can't find desired sector" },
+ { 0110, "No SEP clock seen" },
+ { 0120, "No preamble found" },
+ { 0130, "Preamble, but no ID mark" },
+ { 0140, "Header CRC error"},
+ { 0150, "Track addr wrong in header" },
+ { 0160, "Too many tries for ID AM" },
+ { 0170, "No data AM found" },
+ { 0200, "Data CRC error" },
+ { 0220, "Maintenance test failure" },
+ { 0230, "Word count overflow" },
+ { 0240, "Density error" },
+ { 0250, "Set-density protocol bad" },
+ { 0, "Undefined error code" }
+};
+#endif
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tmreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * TM11 controller registers
+ */
+struct tmdevice {
+ u_short tmer; /* error register, per drive */
+ u_short tmcs; /* control-status register */
+ short tmbc; /* byte/frame count */
+ u_short tmba; /* address */
+ short tmdb; /* data buffer */
+ short tmrd; /* read lines */
+ short tmmr; /* maintenance register */
+#ifdef AVIV
+ short tmfsr; /* formatter status reading */
+#endif
+};
+
+#define b_repcnt b_bcount
+#define b_command b_resid
+
+/* bits in tmcs */
+#define TM_GO 0000001
+#define TM_OFFL 0000000 /* offline */
+#define TM_RCOM 0000002 /* read */
+#define TM_WCOM 0000004 /* write */
+#define TM_WEOF 0000006 /* write-eof */
+#define TM_SFORW 0000010 /* space forward */
+#define TM_SREV 0000012 /* space backwards */
+#define TM_WIRG 0000014 /* write with xtra interrecord gap */
+#define TM_REW 0000016 /* rewind */
+#define TM_SENSE TM_IE /* sense (internal to driver) */
+
+#define tmreverseop(cmd) ((cmd)==TM_SREV || (cmd)==TM_REW)
+
+/* TM_SNS is a pseudo-op used to get tape status */
+#define TM_IE 0000100 /* interrupt enable */
+#define TM_CUR 0000200 /* control unit is ready */
+#define TM_DCLR 0010000 /* drive clear */
+#define TM_D800 0060000 /* select 800 bpi density */
+#define TM_ERR 0100000 /* drive error summary */
+
+/* bits in tmer */
+#define TMER_ILC 0100000 /* illegal command */
+#define TMER_EOF 0040000 /* end of file */
+#define TMER_CRE 0020000 /* cyclic redundancy error */
+#define TMER_PAE 0010000 /* parity error */
+#define TMER_BGL 0004000 /* bus grant late */
+#define TMER_EOT 0002000 /* at end of tape */
+#define TMER_RLE 0001000 /* record length error */
+#define TMER_BTE 0000400 /* bad tape error */
+#define TMER_NXM 0000200 /* non-existant memory */
+#define TMER_SELR 0000100 /* tape unit properly selected */
+#define TMER_BOT 0000040 /* at beginning of tape */
+#define TMER_CH7 0000020 /* 7 channel tape */
+#define TMER_SDWN 0000010 /* gap settling down */
+#define TMER_WRL 0000004 /* tape unit write protected */
+#define TMER_RWS 0000002 /* tape unit rewinding */
+#define TMER_TUR 0000001 /* tape unit ready */
+
+#define TMER_BITS \
+"\10\20ILC\17EOF\16CRE\15PAE\14BGL\13EOT\12RLE\11BTE\10NXM\
+\7SELR\6BOT\5CH7\4SDWN\3WRL\2RWS\1TUR"
+
+#define TMER_HARD (TMER_ILC|TMER_EOT)
+#define TMER_SOFT (TMER_CRE|TMER_PAE|TMER_BGL|TMER_RLE|TMER_BTE|TMER_NXM)
+
+#ifdef AVIV
+/* bits in tmmr (formatter diagnostic reading) */
+#define DTS 000000 /* select dead track status */
+# define DTS_MASK 0xff
+
+#define DAB 010000 /* select diagnostic aid bits */
+# define DAB_MASK 037 /* reject code only */
+
+#define RWERR 020000 /* select read-write errors */
+# define RWERR_MASK 01777 /* include bit 9 (MAI) */
+# define RWERR_BITS \
+"\10\12MAI\11CRC ERR\10WTMCHK\7UCE\6PART REC\5MTE\3END DATA CHK\
+\2VEL ERR\1DIAG MODE"
+
+#define DRSENSE 030000 /* select drive sense */
+# define DRSENSE_MASK 0777
+# define DRSENSE_BITS \
+"\10\11WRTS\10EOTS\7BOTS\6WNHB\5PROS\4BWDS\3HDNG\2RDYS\1ON LINE"
+
+#define CRCF 040000 /* CRC-F Generator */
+
+#define FSR_BITS \
+"\10\20REJ\17TMS\16OVRN\15DATACHK\14SSC\13EOTS\12WRTS\11ROMPS\10CRERR\
+\7ONLS\6BOTS\5HDENS\4BUPER\3FPTS\2REWS\1RDYS"
+#endif AVIV
--- /dev/null
+/* @(#)tmscpreg.h 7.1 (Berkeley) 6/5/86 */
+
+/* @(#)tmscpreg.h 1.1 11/2/84 84/09/25 */
+
+/****************************************************************
+ * *
+ * Licensed from Digital Equipment Corporation *
+ * Copyright (c) *
+ * Digital Equipment Corporation *
+ * Maynard, Massachusetts *
+ * 1985, 1986 *
+ * All rights reserved. *
+ * *
+ * The Information in this software is subject to change *
+ * without notice and should not be construed as a commitment *
+ * by Digital Equipment Corporation. Digital makes no *
+ * representations about the suitability of this software for *
+ * any purpose. It is supplied "As Is" without expressed or *
+ * implied warranty. *
+ * *
+ * If the Regents of the University of California or its *
+ * licensees modify the software in a manner creating *
+ * diriviative copyright rights, appropriate copyright *
+ * legends may be placed on the drivative work in addition *
+ * to that set forth above. *
+ * *
+ ****************************************************************/
+/*
+ * TMSCP registers and structures
+ */
+
+struct tmscpdevice {
+ short tmscpip; /* initialization and polling */
+ short tmscpsa; /* status and address */
+};
+
+#define TMSCP_ERR 0100000 /* error bit */
+#define TMSCP_STEP4 0040000 /* step 4 has started */
+#define TMSCP_STEP3 0020000 /* step 3 has started */
+#define TMSCP_STEP2 0010000 /* step 2 has started */
+#define TMSCP_STEP1 0004000 /* step 1 has started */
+#define TMSCP_NV 0002000 /* no host settable interrupt vector */
+#define TMSCP_QB 0001000 /* controller supports Q22 bus */
+#define TMSCP_DI 0000400 /* controller implements diagnostics */
+#define TMSCP_OD 0000200 /* port allows odd host addr's in the buffer descriptor */
+#define TMSCP_IE 0000200 /* interrupt enable */
+#define TMSCP_MP 0000100 /* port supports address mapping */
+#define TMSCP_LF 0000002 /* host requests last fail response packet */
+#define TMSCP_PI 0000001 /* host requests adapter purge interrupts */
+#define TMSCP_GO 0000001 /* start operation, after init */
+
+
+/*
+ * TMSCP Communications Area
+ */
+
+struct tmscpca {
+ short ca_xxx1; /* unused */
+ char ca_xxx2; /* unused */
+ char ca_bdp; /* BDP to purge */
+ short ca_cmdint; /* command queue transition interrupt flag */
+ short ca_rspint; /* response queue transition interrupt flag */
+ long ca_rspdsc[NRSP];/* response descriptors */
+ long ca_cmddsc[NCMD];/* command descriptors */
+};
+
+#define ca_ringbase ca_rspdsc[0]
+
+#define TMSCP_OWN 0x80000000 /* port owns this descriptor (else host
+ owns it) */
+#define TMSCP_INT 0x40000000 /* allow interrupt on ring transition */
+
+#define TMSCP_MAP 0x80000000 /* modifier for mapped buffer descriptors */
+
+/*
+ * TMSCP packet info (same as MSCP)
+ */
+struct mscp_header {
+ short tmscp_msglen; /* length of MSCP packet */
+ char tmscp_credits; /* low 4 bits: credits, high 4 bits: msgtype */
+ char tmscp_vcid; /* virtual circuit id (connection id) */
+};
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)tsreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * TS11 controller registers
+ */
+struct tsdevice {
+ u_short tsdb; /* data buffer */
+ u_short tssr; /* status register */
+};
+
+/* Bits in (unibus) status register */
+#define TS_SC 0100000 /* special condition (error) */
+#define TS_UPE 0040000 /* Unibus parity error */
+#define TS_SPE 0020000 /* serial bus parity error */
+#define TS_RMR 0010000 /* register modification refused */
+#define TS_NXM 0004000 /* nonexistant memory */
+#define TS_NBA 0002000 /* need buffer address */
+#define TS_XMEM 0001400 /* Unibus xmem bits */
+#define TS_SSR 0000200 /* subsytem ready */
+#define TS_OFL 0000100 /* off-line */
+#define TS_FTC 0000060 /* fatal termination class */
+#define TS_TC 0000016 /* termination class */
+
+#define TS_SUCC 000 /* successful termination */
+#define TS_ATTN 002 /* attention */
+#define TS_ALERT 004 /* tape status alert */
+#define TS_REJECT 06 /* function reject */
+#define TS_RECOV 010 /* recoverable error */
+#define TS_RECNM 012 /* recoverable error, no tape motion */
+#define TS_UNREC 014 /* unrecoverable error */
+#define TS_FATAL 016 /* fatal error */
+
+#define TSSR_BITS \
+"\10\20SC\17UPE\16SPE\15RMR\14NXM\13NBA\12A17\11A16\10SSR\
+\7OFL\6FC1\5FC0\4TC2\3TC1\2TC0\1-"
+
+#define b_repcnt b_bcount
+#define b_command b_resid
+
+/* status message */
+struct ts_sts {
+ u_short s_sts; /* packet header */
+ u_short s_len; /* packet length */
+ u_short s_rbpcr; /* residual frame count */
+ u_short s_xs0; /* extended status 0 - 3 */
+ u_short s_xs1;
+ u_short s_xs2;
+ u_short s_xs3;
+};
+
+/* Error codes in xstat 0 */
+#define TS_TMK 0100000 /* tape mark detected */
+#define TS_RLS 0040000 /* record length short */
+#define TS_LET 0020000 /* logical end of tape */
+#define TS_RLL 0010000 /* record length long */
+#define TS_WLE 0004000 /* write lock error */
+#define TS_NEF 0002000 /* non-executable function */
+#define TS_ILC 0001000 /* illegal command */
+#define TS_ILA 0000400 /* illegal address */
+#define TS_MOT 0000200 /* capstan is moving */
+#define TS_ONL 0000100 /* on-line */
+#define TS_IES 0000040 /* interrupt enable status */
+#define TS_VCK 0000020 /* volume check */
+#define TS_PED 0000010 /* phase-encoded drive */
+#define TS_WLK 0000004 /* write locked */
+#define TS_BOT 0000002 /* beginning of tape */
+#define TS_EOT 0000001 /* end of tape */
+
+#define TSXS0_BITS \
+"\10\20TMK\17RLS\16LET\15RLL\14WLE\13NEF\12ILC\11ILA\10MOT\
+\7ONL\6IES\5VCK\4PED\3WLK\2BOT\1EOT"
+
+/* Error codes in xstat 1 */
+#define TS_DLT 0100000 /* data late */
+#define TS_COR 0020000 /* correctable data */
+#define TS_CRS 0010000 /* crease detected */
+#define TS_TIG 0004000 /* trash in the gap */
+#define TS_DBF 0002000 /* deskew buffer full */
+#define TS_SCK 0001000 /* speed check */
+#define TS_IPR 0000200 /* invalid preamble */
+#define TS_SYN 0000100 /* synchronization failure */
+#define TS_IPO 0000040 /* invalid postamble */
+#define TS_IED 0000020 /* invalid end of data */
+#define TS_POS 0000010 /* postamble short */
+#define TS_POL 0000004 /* postamble long */
+#define TS_UNC 0000002 /* uncorrectable data */
+#define TS_MTE 0000001 /* multitrack error */
+
+#define TSXS1_BITS \
+"\10\20DLT\17-\16COR\15CRS\14TIG\13DBF\12SCK\11-\10IPR\
+\7SYN\6IPO\5IED\4POS\3POL\2UNC\1MTE"
+
+/* Error codes in xstat 2 */
+#define TS_OPM 0100000 /* operation in progress */
+#define TS_SIP 0040000 /* silo parity error */
+#define TS_BPE 0020000 /* serial bus parity error */
+#define TS_CAF 0010000 /* capstan acceleration failure */
+#define TS_WCF 0002000 /* write card fail */
+#define TS_DTP 0000400 /* dead track parity */
+#define TS_DT 0000377 /* dead tracks */
+
+#define TSXS2_BITS \
+"\10\20OPM\17SIP\16BPE\15CAF\14-\13WCF\12-\11DTP"
+
+/* Error codes in xstat 3 */
+#define TS_MEC 0177400 /* microdiagnostic error code */
+#define TS_LMX 0000200 /* limit exceeded */
+#define TS_OPI 0000100 /* operation incomplete */
+#define TS_REV 0000040 /* reverse */
+#define TS_CRF 0000020 /* capstan response fail */
+#define TS_DCK 0000010 /* density check */
+#define TS_NOI 0000004 /* noise record */
+#define TS_LXS 0000002 /* limit exceeded statically */
+#define TS_RIB 0000001 /* reverse into BOT */
+
+#define TSXS3_BITS \
+"\10\10LMX\7OPI\6REV\5CRF\4DCK\3NOI\2LXS\1RIB"
+
+
+/* command message */
+struct ts_cmd {
+ u_short c_cmd; /* command */
+ u_short c_loba; /* low order buffer address */
+ u_short c_hiba; /* high order buffer address */
+#define c_repcnt c_loba
+ u_short c_size; /* byte count */
+};
+
+/* commands and command bits */
+#define TS_ACK 0100000 /* ack - release command packet */
+#define TS_CVC 0040000 /* clear volume check */
+#define TS_IE 0000200
+#define TS_RCOM 0000001
+#define TS_REREAD 0001001 /* read data retry */
+#define TS_SETCHR 0000004 /* set characteristics */
+#define TS_WCOM 0000005
+#define TS_REWRITE 0001005 /* write data retry */
+#define TS_RETRY 0001000 /* retry bit for read and write */
+#define TS_SFORW 0000010 /* forward space record */
+#define TS_SREV 0000410 /* reverse space record */
+#define TS_SFORWF 0001010 /* forward space file */
+#define TS_SREVF 0001410 /* reverse space file */
+#define TS_REW 0002010 /* rewind */
+#define TS_OFFL 0000412 /* unload */
+#define TS_WEOF 0000011 /* write tape mark */
+#define TS_SENSE 0000017 /* get status */
+
+/* characteristics data */
+struct ts_char {
+ long char_addr; /* address of status packet */
+ u_short char_size; /* its size */
+ u_short char_mode; /* characteristics */
+};
+
+
+/* characteristics */
+#define TS_ESS 0200 /* enable skip tape marks stop */
+#define TS_ENB 0100 /* ??? */
+#define TS_EAI 0040 /* enable attention interrupts */
+#define TS_ERI 0020 /* enable message buffer release interrupts */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ubareg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * VAX UNIBUS adapter registers
+ */
+
+/*
+ * size of unibus address space in pages
+ */
+#define UBAPAGES 512
+
+/*
+ * Number of UNIBUS map registers. We can't use the last 8k of UNIBUS
+ * address space for i/o transfers since it is used by the devices,
+ * hence have slightly less than 256K of UNIBUS address space.
+ */
+#define NUBMREG 496
+
+#ifndef LOCORE
+/*
+ * UBA hardware registers
+ */
+struct uba_regs
+{
+ int uba_cnfgr; /* configuration register */
+ int uba_cr; /* control register */
+ int uba_sr; /* status register */
+ int uba_dcr; /* diagnostic control register */
+ int uba_fmer; /* failed map entry register */
+ int uba_fubar; /* failed UNIBUS address register */
+ int pad1[2];
+ int uba_brsvr[4];
+ int uba_brrvr[4]; /* receive vector registers */
+ int uba_dpr[16]; /* buffered data path register */
+ int pad2[480];
+ struct pte uba_map[NUBMREG]; /* unibus map register */
+ int pad3[16]; /* no maps for device address space */
+};
+#endif
+
+#if defined(VAX780) || defined(VAX8600)
+/* uba_cnfgr */
+#define UBACNFGR_UBINIT 0x00040000 /* unibus init asserted */
+#define UBACNFGR_UBPDN 0x00020000 /* unibus power down */
+#define UBACNFGR_UBIC 0x00010000 /* unibus init complete */
+
+#define UBACNFGR_BITS \
+"\40\40PARFLT\37WSQFLT\36URDFLT\35ISQFLT\34MXTFLT\33XMTFLT\30ADPDN\27ADPUP\23UBINIT\22UBPDN\21UBIC"
+
+/* uba_cr */
+#define UBACR_MRD16 0x40000000 /* map reg disable bit 4 */
+#define UBACR_MRD8 0x20000000 /* map reg disable bit 3 */
+#define UBACR_MRD4 0x10000000 /* map reg disable bit 2 */
+#define UBACR_MRD2 0x08000000 /* map reg disable bit 1 */
+#define UBACR_MRD1 0x04000000 /* map reg disable bit 0 */
+#define UBACR_IFS 0x00000040 /* interrupt field switch */
+#define UBACR_BRIE 0x00000020 /* BR interrupt enable */
+#define UBACR_USEFIE 0x00000010 /* UNIBUS to SBI error field IE */
+#define UBACR_SUEFIE 0x00000008 /* SBI to UNIBUS error field IE */
+#define UBACR_CNFIE 0x00000004 /* configuration IE */
+#define UBACR_UPF 0x00000002 /* UNIBUS power fail */
+#define UBACR_ADINIT 0x00000001 /* adapter init */
+
+/* uba_sr */
+#define UBASR_BR7FULL 0x08000000 /* BR7 receive vector reg full */
+#define UBASR_BR6FULL 0x04000000 /* BR6 receive vector reg full */
+#define UBASR_BR5FULL 0x02000000 /* BR5 receive vector reg full */
+#define UBASR_BR4FULL 0x01000000 /* BR4 receive vector reg full */
+#define UBASR_RDTO 0x00000400 /* UNIBUS to SBI read data timeout */
+#define UBASR_RDS 0x00000200 /* read data substitute */
+#define UBASR_CRD 0x00000100 /* corrected read data */
+#define UBASR_CXTER 0x00000080 /* command transmit error */
+#define UBASR_CXTMO 0x00000040 /* command transmit timeout */
+#define UBASR_DPPE 0x00000020 /* data path parity error */
+#define UBASR_IVMR 0x00000010 /* invalid map register */
+#define UBASR_MRPF 0x00000008 /* map register parity failure */
+#define UBASR_LEB 0x00000004 /* lost error */
+#define UBASR_UBSTO 0x00000002 /* UNIBUS select timeout */
+#define UBASR_UBSSYNTO 0x00000001 /* UNIBUS slave sync timeout */
+
+#define UBASR_BITS \
+"\20\13RDTO\12RDS\11CRD\10CXTER\7CXTMO\6DPPE\5IVMR\4MRPF\3LEB\2UBSTO\1UBSSYNTO"
+
+/* uba_brrvr[] */
+#define UBABRRVR_AIRI 0x80000000 /* adapter interrupt request */
+#define UBABRRVR_DIV 0x0000ffff /* device interrupt vector field */
+#endif
+
+/* uba_dpr */
+#if defined(VAX780) || defined(VAX8600)
+#define UBADPR_BNE 0x80000000 /* buffer not empty - purge */
+#define UBADPR_BTE 0x40000000 /* buffer transfer error */
+#define UBADPR_DPF 0x20000000 /* DP function (RO) */
+#define UBADPR_BS 0x007f0000 /* buffer state field */
+#define UBADPR_BUBA 0x0000ffff /* buffered UNIBUS address */
+#define UBA_PURGE780(uba, bdp) \
+ ((uba)->uba_dpr[bdp] |= UBADPR_BNE)
+#else
+#define UBA_PURGE780(uba, bdp)
+#endif
+#if VAX750
+#define UBADPR_ERROR 0x80000000 /* error occurred */
+#define UBADPR_NXM 0x40000000 /* nxm from memory */
+#define UBADPR_UCE 0x20000000 /* uncorrectable error */
+#define UBADPR_PURGE 0x00000001 /* purge bdp */
+/* the DELAY is for a hardware problem */
+#define UBA_PURGE750(uba, bdp) { \
+ ((uba)->uba_dpr[bdp] |= (UBADPR_PURGE|UBADPR_NXM|UBADPR_UCE)); \
+ DELAY(8); \
+}
+#else
+#define UBA_PURGE750(uba, bdp)
+#endif
+
+/*
+ * Macros for fast buffered data path purging in time-critical routines.
+ *
+ * Too bad C pre-processor doesn't have the power of LISP in macro
+ * expansion...
+ */
+
+#if defined(VAX8600) || defined(VAX780) || defined(VAX750)
+#define UBAPURGE(uba, bdp) { \
+ switch (cpu) { \
+ case VAX_8600: case VAX_780: UBA_PURGE780((uba), (bdp)); break; \
+ case VAX_750: UBA_PURGE750((uba), (bdp)); break; \
+ } \
+}
+#endif
+#if !defined(VAX8600) && !defined(VAX780) && !defined(VAX750)
+#define UBAPURGE(uba, bdp)
+#endif
+
+
+
+/* uba_mr[] */
+#define UBAMR_MRV 0x80000000 /* map register valid */
+#define UBAMR_BO 0x02000000 /* byte offset bit */
+#define UBAMR_DPDB 0x01e00000 /* data path designator field */
+#define UBAMR_SBIPFN 0x000fffff /* SBI page address field */
+
+#define UBAMR_DPSHIFT 21 /* shift to data path designator */
+
+/*
+ * Number of unibus buffered data paths and possible uba's per cpu type.
+ */
+#define NBDP8600 15
+#define NBDP780 15
+#define NBDP750 3
+#define NBDP730 0
+#define NBDP630 0
+#define MAXNBDP 15
+
+/*
+ * Symbolic BUS addresses for UBAs.
+ */
+
+#if VAX630
+#define UMEM630 ((u_short *)(0x1ffc2000))
+#endif
+
+#if VAX730
+#define UMEM730 ((u_short *)(0xfc0000))
+#endif
+
+#if VAX750
+#define UMEM750(i) ((u_short *)(0xfc0000-(i)*0x40000))
+#endif
+
+#if VAX780
+#define UMEM780(i) ((u_short *)(0x20100000+(i)*0x40000))
+#endif
+
+#if VAX8600
+#define UMEMA8600(i) ((u_short *)(0x20100000+(i)*0x40000))
+#define UMEMB8600(i) ((u_short *)(0x22100000+(i)*0x40000))
+#endif
+
+/*
+ * Macro to offset a UNIBUS device address, often expressed as
+ * something like 0172520 by forcing it into the last 8K of UNIBUS memory
+ * space.
+ */
+#define ubdevreg(addr) (0760000|((addr)&017777))
+
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)ubavar.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * This file contains definitions related to the kernel structures
+ * for dealing with the unibus adapters.
+ *
+ * Each uba has a uba_hd structure.
+ * Each unibus controller which is not a device has a uba_ctlr structure.
+ * Each unibus device has a uba_device structure.
+ */
+
+/*#ifndef LOCORE*/
+/*
+ * Per-uba structure.
+ *
+ * This structure holds the interrupt vector for the uba,
+ * and its address in physical and virtual space. At boot time
+ * we determine the devices attached to the uba's and their
+ * interrupt vectors, filling in uh_vec. We free the map
+ * register and bdp resources of the uba into the structures
+ * defined here.
+ *
+ * During normal operation, resources are allocated and returned
+ * to the structures here. We watch the number of passive releases
+ * on each uba, and if the number is excessive may reset the uba.
+ *
+ * When uba resources are needed and not available, or if a device
+ * which can tolerate no other uba activity (rk07) gets on the bus,
+ * then device drivers may have to wait to get to the bus and are
+ * queued here. It is also possible for processes to block in
+ * the unibus driver in resource wait (mrwant, bdpwant); these
+ * wait states are also recorded here.
+ */
+struct uba_hd {
+ struct uba_regs *uh_uba; /* virt addr of uba */
+ struct uba_regs *uh_physuba; /* phys addr of uba */
+/* int (**uh_vec)();*/ /* interrupt vector */
+ struct uba_device *uh_actf; /* head of queue to transfer */
+ struct uba_device *uh_actl; /* tail of queue to transfer */
+ short uh_mrwant; /* someone is waiting for map reg */
+ short uh_bdpwant; /* someone awaits bdp's */
+ int uh_bdpfree; /* free bdp's */
+ int uh_hangcnt; /* number of ticks hung */
+ int uh_zvcnt; /* number of recent 0 vectors */
+ long uh_zvtime; /* time over which zvcnt accumulated */
+ int uh_zvtotal; /* total number of 0 vectors */
+ int uh_errcnt; /* number of errors */
+ int uh_lastiv; /* last free interrupt vector */
+ short uh_users; /* transient bdp use count */
+ short uh_xclu; /* an rk07 is using this uba! */
+ int uh_lastmem; /* limit of any unibus memory */
+#define UAMSIZ 100
+ struct map *uh_map; /* buffered data path regs free */
+};
+
+#ifndef LOCORE
+/*
+ * Per-controller structure.
+ * (E.g. one for each disk and tape controller, and other things
+ * which use and release buffered data paths.)
+ *
+ * If a controller has devices attached, then there are
+ * cross-referenced uba_drive structures.
+ * This structure is the one which is queued in unibus resource wait,
+ * and saves the information about unibus resources which are used.
+ * The queue of devices waiting to transfer is also attached here.
+ */
+struct uba_ctlr {
+ struct uba_driver *um_driver;
+ short um_ctlr; /* controller index in driver */
+ short um_ubanum; /* the uba it is on */
+ short um_alive; /* controller exists */
+/* int (**um_intr)();*/ /* interrupt handler(s) */
+ caddr_t um_addr; /* address of device in i/o space */
+ struct uba_hd *um_hd;
+/* the driver saves the prototype command here for use in its go routine */
+ int um_cmd; /* communication to dgo() */
+ int um_ubinfo; /* save unibus registers, etc */
+ struct buf um_tab; /* queue of devices for this controller */
+};
+
+/*
+ * Per ``device'' structure.
+ * (A controller has devices or uses and releases buffered data paths).
+ * (Everything else is a ``device''.)
+ *
+ * If a controller has many drives attached, then there will
+ * be several uba_device structures associated with a single uba_ctlr
+ * structure.
+ *
+ * This structure contains all the information necessary to run
+ * a unibus device such as a dz or a dh. It also contains information
+ * for slaves of unibus controllers as to which device on the slave
+ * this is. A flags field here can also be given in the system specification
+ * and is used to tell which dz lines are hard wired or other device
+ * specific parameters.
+ */
+struct uba_device {
+ struct uba_driver *ui_driver;
+ short ui_unit; /* unit number on the system */
+ short ui_ctlr; /* mass ctlr number; -1 if none */
+ short ui_ubanum; /* the uba it is on */
+ short ui_slave; /* slave on controller */
+/* int (**ui_intr)();*/ /* interrupt handler(s) */
+ caddr_t ui_addr; /* address of device in i/o space */
+ short ui_dk; /* if init 1 set to number for iostat */
+ int ui_flags; /* parameter from system specification */
+ short ui_alive; /* device exists */
+ short ui_type; /* driver specific type information */
+ caddr_t ui_physaddr; /* phys addr, for standalone (dump) code */
+/* this is the forward link in a list of devices on a controller */
+ struct uba_device *ui_forw;
+/* if the device is connected to a controller, this is the controller */
+ struct uba_ctlr *ui_mi;
+ struct uba_hd *ui_hd;
+};
+#endif
+
+/*
+ * Per-driver structure.
+ *
+ * Each unibus driver defines entries for a set of routines
+ * as well as an array of types which are acceptable to it.
+ * These are used at boot time by the configuration program.
+ */
+struct uba_driver {
+/* int (*ud_probe)();*/ /* see if a driver is really there */
+/* int (*ud_slave)();*/ /* see if a slave is there */
+/* int (*ud_attach)();*/ /* setup driver for a slave */
+/* int (*ud_dgo)();*/ /* fill csr/ba to start transfer */
+ u_short *ud_addr; /* device csr addresses */
+ char *ud_dname; /* name of a device */
+ struct uba_device **ud_dinfo; /* backpointers to ubdinit structs */
+ char *ud_mname; /* name of a controller */
+ struct uba_ctlr **ud_minfo; /* backpointers to ubminit structs */
+ short ud_xclu; /* want exclusive use of bdp's */
+/* int (*ud_ubamem)();*/ /* see if dedicated memory is present */
+};
+#endif
+
+/*
+ * Flags to UBA map/bdp allocation routines
+ */
+#define UBA_NEEDBDP 0x01 /* transfer needs a bdp */
+#define UBA_CANTWAIT 0x02 /* don't block me */
+#define UBA_NEED16 0x04 /* need 16 bit addresses only */
+#define UBA_HAVEBDP 0x08 /* use bdp specified in high bits */
+
+/*
+ * Macros to bust return word from map allocation routines.
+ */
+#define UBAI_BDP(i) ((int)(((unsigned)(i))>>28))
+#define UBAI_NMR(i) ((int)((i)>>18)&0x3ff)
+#define UBAI_MR(i) ((int)((i)>>9)&0x1ff)
+#define UBAI_BOFF(i) ((int)((i)&0x1ff))
+#define UBAI_ADDR(i) ((int)((i)&0x3ffff)) /* uba addr (boff+mr) */
+
+#ifndef LOCORE
+#ifdef KERNEL
+/*
+ * UBA related kernel variables
+ */
+int numuba; /* number of uba's */
+struct uba_hd uba_hd[];
+
+/*
+ * Ubminit and ubdinit initialize the mass storage controller and
+ * device tables specifying possible devices.
+ */
+extern struct uba_ctlr ubminit[];
+extern struct uba_device ubdinit[];
+
+/*
+ * UNIbus device address space is mapped by UMEMmap
+ * into virtual address umem[][].
+ */
+extern struct pte UMEMmap[][512]; /* uba device addr pte's */
+extern char umem[][512*NBPG]; /* uba device addr space */
+
+/*
+ * Since some VAXen vector their unibus interrupts
+ * just adjacent to the system control block, we must
+ * allocate space there when running on ``any'' cpu. This space is
+ * used for the vectors for uba0 and uba1 on all cpu's.
+ */
+/*extern int (*UNIvec[])();*/ /* unibus vec for uba0 */
+#if NUBA > 1
+/*extern int (*UNI1vec[])();*/ /* unibus vec for uba1 */
+#endif
+
+#if defined(VAX780) || defined(VAX8600)
+/*
+ * On 780's, we must set the scb vectors for the nexus of the
+ * UNIbus adaptors to vector to locore unibus adaptor interrupt dispatchers
+ * which make 780's look like the other VAXen.
+ */
+/*extern Xua0int(), Xua1int(), Xua2int(), Xua3int();*/
+#endif VAX780
+#endif KERNEL
+/*#endif*/
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)udareg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * UDA-50 registers and structures
+ */
+
+struct udadevice {
+ short udaip; /* initialization and polling */
+ short udasa; /* status and address */
+};
+
+#define UDA_ERR 0100000 /* error bit */
+#define UDA_STEP4 0040000 /* step 4 has started */
+#define UDA_STEP3 0020000 /* step 3 has started */
+#define UDA_STEP2 0010000 /* step 2 has started */
+#define UDA_STEP1 0004000 /* step 1 has started */
+#define UDA_NV 0002000 /* no host settable interrupt vector */
+#define UDA_QB 0001000 /* controller supports Q22 bus */
+#define UDA_DI 0000400 /* controller implements diagnostics */
+#define UDA_IE 0000200 /* interrupt enable */
+#define UDA_PI 0000001 /* host requests adapter purge interrupts */
+#define UDA_GO 0000001 /* start operation, after init */
+
+
+/*
+ * UDA Communications Area
+ */
+
+struct udaca {
+ short ca_xxx1; /* unused */
+ char ca_xxx2; /* unused */
+ char ca_bdp; /* BDP to purge */
+ short ca_cmdint; /* command queue transition interrupt flag */
+ short ca_rspint; /* response queue transition interrupt flag */
+ long ca_rspdsc[NRSP];/* response descriptors */
+ long ca_cmddsc[NCMD];/* command descriptors */
+};
+
+#define ca_ringbase ca_rspdsc[0]
+
+#define UDA_OWN 0x80000000 /* UDA owns this descriptor */
+#define UDA_INT 0x40000000 /* allow interrupt on ring transition */
+
+/*
+ * MSCP packet info
+ */
+struct mscp_header {
+ short uda_msglen; /* length of MSCP packet */
+ char uda_credits; /* low 4 bits: credits, high 4 bits: msgtype */
+ char uda_vcid; /* virtual circuit id */
+};
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)upreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * Unibus rm emulation via sc21:
+ * registers and bits.
+ */
+
+struct updevice
+{
+ u_short upcs1; /* control and status register 1 */
+ short upwc; /* word count register */
+ u_short upba; /* UNIBUS address register */
+ u_short upda; /* desired address register */
+ u_short upcs2; /* control and status register 2 */
+ u_short upds; /* drive Status */
+ u_short uper1; /* error register 1 */
+ u_short upas; /* attention summary */
+ u_short upla; /* look ahead */
+ u_short updb; /* data buffer */
+ u_short upmr; /* maintenance */
+ u_short updt; /* drive type */
+ u_short upsn; /* serial number */
+ u_short upof; /* offset register */
+ u_short updc; /* desired cylinder address register */
+ u_short uphr; /* holding register */
+ u_short upmr2; /* maintenance register 2 */
+ u_short uper2; /* error register 2 */
+ u_short upec1; /* burst error bit position */
+ u_short upec2; /* burst error bit pattern */
+};
+
+/* Other bits of upcs1 */
+#define UP_SC 0100000 /* special condition */
+#define UP_TRE 0040000 /* transfer error */
+#define UP_PSEL 0010000 /* port select */
+#define UP_DVA 0004000 /* drive available */
+/* bits 8 and 9 are the extended address bits */
+#define UP_RDY 0000200 /* controller ready */
+#define UP_IE 0000100 /* interrupt enable */
+/* bits 5-1 are the command */
+#define UP_GO 0000001
+
+/* commands */
+#define UP_NOP 000
+#define UP_SEEK 004 /* seek */
+#define UP_RECAL 006 /* recalibrate */
+#define UP_DCLR 010 /* drive clear */
+#define UP_RELEASE 012 /* release */
+#define UP_OFFSET 014 /* offset */
+#define UP_RTC 016 /* return to center-line */
+#define UP_PRESET 020 /* read-in preset */
+#define UP_PACK 022 /* pack acknowledge */
+#define UP_DMABAND 024 /* dma bandwidth set */
+#define UP_SEARCH 030 /* search */
+#define UP_WCDATA 050 /* write check data */
+#define UP_WCHDR 052 /* write check header and data */
+#define UP_WCOM 060 /* write */
+#define UP_WHDR 062 /* write header and data */
+#define UP_RCOM 070 /* read data */
+#define UP_RHDR 072 /* read header and data */
+#define UP_BOOT 074 /* boot */
+#define UP_FORMAT 076 /* format */
+
+/* upcs2 */
+#define UPCS2_DLT 0100000 /* data late */
+#define UPCS2_WCE 0040000 /* write check error */
+#define UPCS2_UPE 0020000 /* UNIBUS parity error */
+#define UPCS2_NED 0010000 /* nonexistent drive */
+#define UPCS2_NEM 0004000 /* nonexistent memory */
+#define UPCS2_PGE 0002000 /* programming error */
+#define UPCS2_MXF 0001000 /* missed transfer */
+#define UPCS2_MDPE 0000400 /* massbus data parity error (0) */
+#define UPCS2_OR 0000200 /* output ready */
+#define UPCS2_IR 0000100 /* input ready */
+#define UPCS2_CLR 0000040 /* controller clear */
+#define UPCS2_PAT 0000020 /* parity test */
+#define UPCS2_BAI 0000010 /* address increment inhibit */
+/* bits 0-2 are drive select */
+
+#define UPCS2_BITS \
+"\10\20DLT\17WCE\16UPE\15NED\14NEM\13PGE\12MXF\11MDPE\
+\10OR\7IR\6CLR\5PAT\4BAI"
+
+/* upds */
+#define UPDS_ATA 0100000 /* attention active */
+#define UPDS_ERR 0040000 /* composite drive error */
+#define UPDS_PIP 0020000 /* positioning in progress */
+#define UPDS_MOL 0010000 /* medium on line */
+#define UPDS_WRL 0004000 /* write locked */
+#define UPDS_LST 0002000 /* last sector transferred */
+#define UPDS_PGM 0001000 /* programmable */
+#define UPDS_DPR 0000400 /* drive present */
+#define UPDS_DRY 0000200 /* drive ready */
+#define UPDS_VV 0000100 /* volume valid */
+/* bits 1-5 are spare */
+#define UPDS_OM 0000001 /* offset mode */
+
+#define UPDS_DREADY (UPDS_DPR|UPDS_DRY|UPDS_MOL|UPDS_VV)
+
+#define UPDS_BITS \
+"\10\20ATA\17ERR\16PIP\15MOL\14WRL\13LST\12PGM\11DPR\10DRY\7VV\1OM"
+
+/* uper1 */
+#define UPER1_DCK 0100000 /* data check */
+#define UPER1_UNS 0040000 /* drive unsafe */
+#define UPER1_OPI 0020000 /* operation incomplete */
+#define UPER1_DTE 0010000 /* drive timing error */
+#define UPER1_WLE 0004000 /* write lock error */
+#define UPER1_IAE 0002000 /* invalid address error */
+#define UPER1_AOE 0001000 /* address overflow error */
+#define UPER1_HCRC 0000400 /* header crc error */
+#define UPER1_HCE 0000200 /* header compare error */
+#define UPER1_ECH 0000100 /* ecc hard error */
+#define UPER1_WCF 0000040 /* write clock fail (0) */
+#define UPER1_FER 0000020 /* format error */
+#define UPER1_PAR 0000010 /* parity error */
+#define UPER1_RMR 0000004 /* register modification refused */
+#define UPER1_ILR 0000002 /* illegal register */
+#define UPER1_ILF 0000001 /* illegal function */
+
+#define UPER1_BITS \
+"\10\20DCK\17UNS\16OPI\15DTE\14WLE\13IAE\12AOE\11HCRC\10HCE\
+\7ECH\6WCF\5FER\4PAR\3RMR\2ILR\1ILF"
+
+/* uphr */
+/* write these int uphr and then read back values */
+#define UPHR_MAXCYL 0100027 /* max cyl address */
+#define UPHR_MAXTRAK 0100030 /* max track address */
+#define UPHR_MAXSECT 0100031 /* max sector address */
+
+/* uper2 */
+#define UPER2_BSE 0100000 /* bad sector error */
+#define UPER2_SKI 0040000 /* seek incomplete */
+#define UPER2_OPE 0020000 /* operator plug error */
+#define UPER2_IVC 0010000 /* invalid command */
+#define UPER2_LSC 0004000 /* loss of sector clock */
+#define UPER2_LBC 0002000 /* loss of bit clock */
+#define UPER2_MDS 0001000 /* multiple drive select */
+#define UPER2_DCU 0000400 /* dc power unsafe */
+#define UPER2_DVC 0000200 /* device check */
+#define UPER2_ACU 0000100 /* ac power unsafe */
+/* bits 5 and 4 are spare */
+#define UPER2_DPE 0000010 /* data parity error (0) */
+/* bits 2-0 are spare */
+
+#define UPER2_BITS \
+"\10\20BSE\17SKI\16OPE\15IVC\14LSC\13LBC\12MDS\11DCU\10DVC\7ACU\4DPE"
+
+/* upof */
+#define UPOF_FMT22 0010000 /* 16 bit format */
+#define UPOF_ECI 0004000 /* ecc inhibit */
+#define UPOF_HCI 0002000 /* header compare inhibit */
+
+/* THE SC21 ACTUALLY JUST IMPLEMENTS ADVANCE/RETARD... */
+#define UPOF_P400 0020 /* +400 uinches */
+#define UPOF_M400 0220 /* -400 uinches */
+#define UPOF_P800 0040 /* +800 uinches */
+#define UPOF_M800 0240 /* -800 uinches */
+#define UPOF_P1200 0060 /* +1200 uinches */
+#define UPOF_M1200 0260 /* -1200 uinches */
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)utreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+/*
+ * System Industries Model 9700 Tape Drive
+ * emulates TU45 on the UNIBUS
+ */
+
+struct utdevice {
+ u_short utcs1; /* control status register 1 */
+ short utwc; /* word count register */
+ u_short utba; /* low 16-bits of bus address */
+ short utfc; /* frame counter */
+ u_short utcs2; /* control status register 2 */
+ u_short utds; /* drive status register */
+ u_short uter; /* error register */
+ u_short utas; /* attention status register */
+ u_short utcc; /* NRZI CRC character for validation */
+ u_short utdb; /* data buffer reg (not emulated) */
+ u_short utmr; /* maintenance reg (not emulated) */
+ u_short utdt; /* drive type register (not emulated) */
+ u_short utsn; /* serial number reg (not emulated) */
+ u_short uttc; /* tape control register */
+ u_short utbae; /* buffer address extension register */
+ u_short utcs3; /* control and status register 3 */
+};
+
+/*
+ * utcs1 --
+ * cmds, interrupt enable, extended address bits, and status
+ */
+#define UT_GO 0x0001 /* go bit */
+/* function codes reside in bits 5-1 */
+#define UT_NOP 0x0000 /* no operation */
+#define UT_REWOFFL 0x0002 /* rewind offline */
+#define UT_LOOP 0x0004 /* loop read/write */
+#define UT_REW 0x0006 /* rewind */
+#define UT_CLEAR 0x0008 /* drive clear */
+#define UT_SENSE 0x000a /* drive sense */
+#define UT_PRESET 0x0010 /* read in preset */
+#define UT_DIAGN 0x0012 /* diagnostic mode set */
+#define UT_ERASE 0x0014 /* erase */
+#define UT_WEOF 0x0016 /* write tape mark */
+#define UT_SFORW 0x0018 /* forward space block */
+#define UT_SREV 0x001a /* reverse space block */
+#define UT_SFORWF 0x001c /* forward space file */
+#define UT_SREVF 0x001e /* reverse space file */
+#define UT_WCHFORW 0x0028 /* write check forward */
+#define UT_WCHREV 0x002e /* write check reverse */
+#define UT_WCOM 0x0030 /* write forward */
+#define UT_RCOM 0x0038 /* read forward */
+#define UT_RREV 0x003e /* read reverse */
+/* the remainder are control and status bits */
+#define UT_IE 0x0040 /* interrupt-enable */
+#define UT_RDY 0x0080 /* controller ready */
+#define UT_EADDR 0x0300 /* extended address bits */
+/* bit 10 unused */
+#define UT_DVA 0x0800 /* drive available */
+/* bit 12 unused */
+/* bit 13 - massbus control parity error not emulated */
+#define UT_TRE 0x4000 /* transfer error */
+#define UT_SC 0x8000 /* special condition */
+
+#define UT_BITS \
+"\10\20SC\17TRE\14DVA\10RDY\7IE\1GO"
+
+/*
+ * utcs2 --
+ * controller clear, error flags, and unit select
+ */
+/* bits 0-2 are unit select */
+#define UTCS2_BAI 0x0008 /* UNIBUS address increment inhibit */
+#define UTCS2_PAT 0x0010 /* parity test */
+#define UTCS2_CLR 0x0020 /* controller clear */
+#define UTCS2_IR 0x0040 /* input ready (not emulated) */
+#define UTCS2_OR 0x0080 /* output ready (not emulated) */
+#define UTCS2_RPE 0x0100 /* rom parity error */
+#define UTCS2_MXF 0x0200 /* missed transfer */
+#define UTCS2_NEM 0x0400 /* non existant memory */
+#define UTCS2_PGE 0x0800 /* program error */
+#define UTCS2_NED 0x1000 /* non existent drive */
+#define UTCS2_PE 0x2000 /* parity error */
+#define UTCS2_WCE 0x4000 /* write check error */
+#define UTCS2_DLT 0x8000 /* data late */
+
+#define UTCS2_BITS \
+"\10\20DLT\17WCE\16PE\15NED\14\NEM\13\PGE\12\MXF\11RPE\10OR\7IR\6CLR\5PAT\4\BAI"
+
+/*
+ * utds --
+ * beginning of tape, end of tape, error summary bit, plus lots more
+ */
+#define UTDS_SLA 0x0001 /* slave attention */
+#define UTDS_BOT 0x0002 /* beginning of tape */
+#define UTDS_TM 0x0004 /* tape mark */
+#define UTDS_IDB 0x0008 /* identification burst */
+#define UTDS_SDWN 0x0010 /* slowing down */
+#define UTDS_PES 0x0020 /* phase encode status */
+#define UTDS_SSC 0x0040 /* slave status change */
+#define UTDS_DRY 0x0080 /* drive ready */
+#define UTDS_DPR 0x0100 /* drive present (always 1) */
+#define UTDS_GCR 0x0200 /* GCR status */
+#define UTDS_EOT 0x0400 /* end of tape */
+#define UTDS_WRL 0x0800 /* write lock */
+#define UTDS_MOL 0x1000 /* medium on line */
+#define UTDS_PIP 0x2000 /* positioning in progress */
+#define UTDS_ERR 0x4000 /* composite error */
+#define UTDS_ATA 0x8000 /* attention active */
+
+#define UTDS_BITS \
+"\10\20ATA\17ERR\16PIP\15MOL\14WRL\13EOT\12GCR\11DPR\10DRY\
+\7SSC\6PES\5SDWN\4IDB\3TM\2BOT\1SLA"
+
+/*
+ * uter --
+ * detailed breakdown of error summary bit from cs2
+ */
+#define UTER_ILF 0x0001 /* illegal function */
+#define UTER_ILR 0x0002 /* illegal register (always 0) */
+#define UTER_RMR 0x0004 /* register modification refused */
+#define UTER_RPE 0x0008 /* read data parity error */
+#define UTER_FMT 0x0010 /* format error */
+#define UTER_DPAR 0x0020 /* data bus parity error */
+#define UTER_INC 0x0040 /* incorrectable data */
+#define UTER_PEF 0x0080 /* PE format error */
+#define UTER_NSG 0x0100 /* non standard gap */
+#define UTER_FCE 0x0200 /* frame count error */
+#define UTER_CS 0x0400 /* correctable skew */
+#define UTER_NEF 0x0800 /* non executable function */
+#define UTER_DTE 0x1000 /* drive timing error */
+#define UTER_OPI 0x2000 /* operation incomplete */
+#define UTER_UNS 0x4000 /* unsafe */
+#define UTER_COR 0x8000 /* correctible data error */
+
+/*
+ * These errors we consider "hard"; UTER_OPI and UTER_RPE
+ * are considered "soft", at least for the moment.
+ */
+#define UTER_HARD (UTER_UNS|UTER_NEF|UTER_DPAR|UTER_FMT|UTER_RMR|\
+ UTER_ILR|UTER_ILF)
+
+#define UTER_BITS \
+"\10\20COR\17UNS\16OPI\15DTE\14NEF\13CS\12FCE\11NSG\10PEF\
+\7INC\6DPAR\5FMT\4RPE\3RMR\2ILR\1ILF"
+
+/*
+ * uttc --
+ * tape format and density
+ */
+/* bits 0-2 are slave select */
+#define UTTC_EVPAR 0x0008 /* even parity */
+#define UTTC_FMT 0x00f0 /* format select (see below) */
+#define UTTC_DEN 0x0700 /* density select (see below) */
+/* bit 11 not used */
+#define UTTC_EAODTE 0x1000 /* (not emulated) */
+#define UTTC_TCW 0x2000 /* tape control write */
+#define UTTC_FCS 0x4000 /* frame count status */
+#define UTTC_ACCL 0x8000 /* acceleration */
+
+/* the bits to stuff in UTTC_DEN */
+#define UT_NRZI 0x0000 /* 800 bpi code */
+#define UT_PE 0x0400 /* 1600 bpi code */
+#define UT_GCR 0x0500 /* 6250 bpi code */
+
+/* tape formats - only PDP-11 standard is supported */
+#define PDP11FMT 0x00c0 /* PDP-11 standard */
+
+#define b_repcnt b_bcount
+#define b_command b_resid
+#define b_state b_active
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)uureg.h 7.1 (Berkeley) 6/5/86
+ */
+
+
+/*
+ * DL11-E/DL11-W UNIBUS (for TU58) controller registers
+ */
+struct uudevice {
+ short rcs; /* receiver status register */
+ short rdb; /* receiver data buffer register */
+ short tcs; /* transmitter status register */
+ short tdb; /* transmitter data buffer register */
+};
+
+/*
+ * Receiver/transmitter status register status/command bits
+ */
+#define UUCS_DONE 0x80 /* done/ready */
+#define UUCS_READY 0x80
+#define UUCS_INTR 0x40 /* interrupt enable */
+#define UUCS_MAINT 0x02 /* maintenance check (xmitter only) */
+#define UUCS_BREAK 0x01 /* send break (xmitter only) */
+
+/*
+ * Receiver data buffer register status bits
+ */
+#define UURDB_ERROR 0x8000 /* Error (overrun or break) */
+#define UURDB_ORUN 0x4000 /* Data overrun error */
+#define UURDB_BREAK 0x2000 /* TU58 break */
+
+#define UUDB_DMASK 0x00ff /* data mask (send and receive data) */
+
--- /dev/null
+/*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)vpreg.h 7.1 (Berkeley) 6/5/86
+ */
+
+#define VPPRI (PZERO-1)
+
+struct vpdevice {
+ short plbcr;
+ short pbxaddr;
+ short prbcr;
+ u_short pbaddr;
+ short plcsr;
+ short plbuf;
+ short prcsr;
+ u_short prbuf;
+};
+
+#define VP_ERROR 0100000
+#define VP_DTCINTR 0040000
+#define VP_DMAACT 0020000
+#define VP_READY 0000200
+#define VP_IENABLE 0000100
+#define VP_TERMCOM 0000040
+#define VP_FFCOM 0000020
+#define VP_EOTCOM 0000010
+#define VP_CLRCOM 0000004
+#define VP_RESET 0000002
+#define VP_SPP 0000001
--- /dev/null
+/* @(#)vsreg.h 7.1 (MIT) 6/5/86 */
+ /****************************************************************************
+ * *
+ * Copyright (c) 1983, 1984 by *
+ * DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts. *
+ * All rights reserved. *
+ * *
+ * This software is furnished on an as-is basis and may be used and copied *
+ * only with inclusion of the above copyright notice. This software or any *
+ * other copies thereof may be provided or otherwise made available to *
+ * others only for non-commercial purposes. No title to or ownership of *
+ * the software is hereby transferred. *
+ * *
+ * The information in this software is subject to change without notice *
+ * and should not be construed as a commitment by DIGITAL EQUIPMENT *
+ * CORPORATION. *
+ * *
+ * DIGITAL assumes no responsibility for the use or reliability of its *
+ * software on equipment which is not supplied by DIGITAL. *
+ * *
+ * *
+ ****************************************************************************/
+
+/*
+ * vsreg.h - VS100 Registers and Bits
+ *
+ * Author: Christopher A. Kent
+ * Digital Equipment Corporation
+ * Western Research Lab
+ * Date: Tue Jun 14 1983
+ */
+
+struct vsdevice{
+ u_short vs_csr0; /* Control and Status */
+ u_short vs_csr1; /* Interrupt Reason */
+ u_short vs_csr2; /* Keyboard Receive */
+ u_short vs_csr3; /* Function Parameter Low */
+ u_short vs_csr4; /* Function Parameter High */
+ u_short vs_csr5; /* Cursor Position X */
+ u_short vs_csr6; /* Cursor Position Y */
+ u_short vs_csr7; /* Interrupt Vector */
+ u_short vs_csr8; /* Spare 1 */
+ u_short vs_csr9; /* Spare 2 */
+ u_short vs_csra; /* Spare 3 */
+ u_short vs_csrb; /* Spare 4 */
+ u_short vs_csrc; /* Spare 5 */
+ u_short vs_csrd; /* Spare 6 */
+ u_short vs_csre; /* Spare 7 */
+ u_short vs_csrf; /* Interrupt Vector (2Bs) */
+};
+
+/*
+ * CSR0 - Control and Status
+ */
+
+#define VS_LNK_TRNS 0100000 /* Link Transition */
+#define VS_LNK_AVL 0040000 /* Link Available */
+#define VS_LNK_ERR 0020000 /* Link Error */
+#define VS_XMIT_ON 0010000 /* Transmitter On */
+#define VS_MNT_MODE 0004000 /* Maintenance Mode */
+#define VS_CRC_DIS 0002000 /* CRC Disable */
+#define VS_MNT_DONE 0001000 /* Maintenance Done */
+#define VS_SPARE 0000400 /* Spare */
+#define VS_OWN 0000200 /* Owner */
+#define VS_IE 0000100 /* Interrupt Enable */
+#define VS_FCN 0000076 /* Function Code */
+#define VS_GO 0000001 /* GO! */
+
+struct vs_csr{
+ union{
+ u_short _register;
+ struct{
+ unsigned _go : 1;
+ unsigned _function : 5;
+ unsigned _ie : 1;
+ unsigned _own : 1;
+ unsigned _spare : 1;
+ unsigned _mainDone : 1;
+ unsigned _CRCdisable : 1;
+ unsigned _mainMode : 1;
+ unsigned _xmitOn : 1;
+ unsigned _linkErr : 1;
+ unsigned _linkAvail : 1;
+ unsigned _linkTran : 1;
+ }_bits;
+ }_X;
+};
+
+#define csr_reg _X._register
+#define csr_go _X._bits._go
+#define csr_ie _X._bits._ie
+#define csr_own _X._bits._own
+#define csr_mainDone _X._bits._mainDone
+#define csr_CRCdisable _X._bits._CRCdisable
+#define csr_mainMode _X._bits._mainMode
+#define csr_xmitOn _X._bits._xmitOn
+#define csr_linkErr _X._bits._linkErr
+#define csr_linkAvail _X._bits._linkAvail
+#define csr_linkTran _X._bits._linkTran
+
+/* Function Codes */
+
+#define VS_INIT 01 /* Initialize Display */
+#define VS_SEND 02 /* Send Packet */
+#define VS_START 03 /* Start Microcode */
+#define VS_ABORT 04 /* Abort Command Chain */
+#define VS_PWRUP 05 /* Power Up Reset */
+/**/
+#define VS_ENABBA 020 /* Enable BBA */
+#define VS_DISBBA 021 /* Disable BBA */
+#define VS_INFINITE 022 /* Inifinite Retries */
+#define VS_FINITE 023 /* Finite Retries */
+
+/* amount to shift to get function code into right place */
+
+#define VS_FCSHIFT 01
+
+/*
+ * CSR1 - Interrupt Reason
+ */
+
+#define vs_irr vs_csr1
+
+#define VS_ERROR 0100000 /* Any error */
+#define VS_REASON 0077777 /* Reason Mask */
+#define VSIRR_BITS \
+"\20\20ERROR\10PWRUP\6TABLET\5MOUSE\4BUTTON\3START\2DONE\1INIT"
+
+#define VS_INT_US 0
+#define VS_INT_ID 01
+#define VS_INT_CD 02
+#define VS_INT_SE 04
+#define VS_INT_BE 010
+#define VS_INT_MM 020
+#define VS_INT_TM 040
+#define VS_INT_PWR 0200
+
+struct vs_intr{
+ union{
+ u_short _register; /* whole register */
+ struct{
+ unsigned _reason : 14; /* Reason bits */
+ unsigned _diagnostic : 1; /* Diagnostic Error bit */
+ unsigned _error : 1; /* Error bit */
+ }_bits;
+ }_X;
+};
+
+#define intr_reg _X._register
+#define intr_reason _X._bits._reason
+#define intr_diagnostic _X._bits._diagnostic /* not in rev 2b */
+#define intr_error _X._bits._error
+
+/*
+ * CSR2 - Keyboard Receive
+ */
+
+#define vs_krr vs_csr2
+
+#define VS_KBDEV 0007000 /* Device mask */
+#define VS_KBT 0000400 /* Transition direction */
+#define VS_KBKEY 0000377 /* Key mask */
+
+struct vs_kbd{
+ union{
+ u_short _register; /* whole register */
+ struct{
+ unsigned _key : 8; /* Key number */
+ unsigned _transition : 1; /* Transition direction */
+ unsigned _device : 3; /* Device */
+ unsigned _x : 4; /* Unused */
+ }_bits;
+ }_X;
+};
+
+#define kbd_reg _X._register
+#define kbd_key _X._bits._key
+#define kbd_transition _X._bits._transition
+#define kbd_device _X._bits._device
+
+#define VS_KBTUP 0 /* up */
+#define VS_KBTDOWN 1 /* down */
+
+/*
+ * CSR3/4 Function Parameter Address
+ */
+
+#define vs_pr1 vs_csr3
+#define vs_pr2 vs_csr4
+
+struct vs_fparm{
+ union{
+ struct{
+ u_short _plow; /* low 16 bits of address */
+ u_short _phigh; /* high 16 bits of address */
+ }_parts;
+ caddr_t _pall;
+ }_X;
+};
+#define fparm_low _X._parts._plow
+#define fparm_high _X._parts._phigh
+#define fparm_all _X._pall
+
+/*
+ * CSR5/6 - Cursor position
+ */
+
+#define vs_cxr vs_csr5
+#define vs_cyr vs_csr6
+
+
+/*
+ * CSR 7 - Interrupt vector in fiber cable machines
+ */
+
+#define vs_ivr vs_csr7
+
+/*
+ * CSR 8 through 14 Spare
+ */
+
+#define vs_spr2 vs_csr8
+#define vs_spr3 vs_csr9
+#define vs_spr4 vs_csra
+#define vs_spr5 vs_csrb
+#define vs_spr6 vs_csrc
+#define vs_spr7 vs_csrd
+#define vs_spr8 vs_csre
+
+/*
+ * CSR 15 - Interrupt vector in rev 2B
+ */
+
+#define vs_ivr2 vs_csrf
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * @(#)vfont.h 5.1 (Berkeley) 5/30/85
+ */
+
+/*
+ * The structures header and dispatch define the format of a font file.
+ *
+ * See vfont(5) for more details.
+ */
+struct header {
+ short magic;
+ unsigned short size;
+ short maxx;
+ short maxy;
+ short xtend;
+};
+
+struct dispatch {
+ unsigned short addr;
+ short nbytes;
+ char up,down,left,right;
+ short width;
+};
--- /dev/null
+/* inet/inet_addr.c */
+u_long inet_addr __P((register char *cp));
+/* inet/inet_makeaddr.c */
+struct in_addr inet_makeaddr __P((int net, int host));
+/* inet/inet_netof.c */
+int inet_netof __P((struct in_addr in));
+/* inet/inet_ntoa.c */
+char *inet_ntoa __P((struct in_addr in));
+/* inet/inet_lnaof.c */
+int inet_lnaof __P((struct in_addr in));
+/* inet/inet_network.c */
+u_long inet_network __P((register char *cp));
--- /dev/null
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 5.4 (Berkeley) 9/5/85
+#
+
+SRCS= inet_addr.c inet_network.c \
+ inet_netof.c inet_ntoa.c inet_lnaof.c \
+ inet_makeaddr.c
+OBJS= inet_addr.o inet_network.o \
+ inet_netof.o inet_ntoa.o inet_lnaof.o \
+ inet_makeaddr.o
+CFLAGS= -O ${DEFS}
+TAGSFILE=tags
+
+.c.o:
+ ${CC} -p -c ${CFLAGS} $*.c
+ -ld -X -r $*.o
+ mv a.out profiled/$*.o
+ ${CC} ${CFLAGS} -c $*.c
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+inetlib inetlib_p: ${OBJS}
+ @echo "building profiled inetlib"
+ @cd profiled; ar cru ../inetlib_p ${OBJS}
+ @echo "building normal inetlib"
+ @ar cru inetlib ${OBJS}
+
+tags:
+ cwd=`pwd`; \
+ for i in ${SRCS}; do \
+ ctags -a -f ${TAGSFILE} $$cwd/$$i; \
+ done
+
+clean:
+ rm -f inetlib inetlib_p *.o profiled/*.o errs a.out core \
+ tags Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+inet_addr.o: inet_addr.c /usr/include/sys/types.h /usr/include/ctype.h
+inet_addr.o: /usr/include/netinet/in.h
+inet_network.o: inet_network.c /usr/include/sys/types.h /usr/include/ctype.h
+inet_netof.o: inet_netof.c /usr/include/sys/types.h /usr/include/netinet/in.h
+inet_ntoa.o: inet_ntoa.c /usr/include/sys/types.h /usr/include/netinet/in.h
+inet_lnaof.o: inet_lnaof.c /usr/include/sys/types.h /usr/include/netinet/in.h
+inet_makeaddr.o: inet_makeaddr.c /usr/include/sys/types.h
+inet_makeaddr.o: /usr/include/netinet/in.h
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)inet_addr.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <ctype.h>
+#include <netinet/in.h>
+
+/*
+ * Internet address interpretation routine.
+ * All the network library routines call this
+ * routine to interpret entries in the data bases
+ * which are expected to be an address.
+ * The value returned is in network order.
+ */
+u_long
+inet_addr(cp)
+ register char *cp;
+{
+ register u_long val, base, n;
+ register char c;
+ u_long parts[4], *pp = parts;
+
+again:
+ /*
+ * Collect number up to ``.''.
+ * Values are specified as for C:
+ * 0x=hex, 0=octal, other=decimal.
+ */
+ val = 0; base = 10;
+ if (*cp == '0')
+ base = 8, cp++;
+ if (*cp == 'x' || *cp == 'X')
+ base = 16, cp++;
+ while (c = *cp) {
+ if (isdigit(c)) {
+ val = (val * base) + (c - '0');
+ cp++;
+ continue;
+ }
+ if (base == 16 && isxdigit(c)) {
+ val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
+ cp++;
+ continue;
+ }
+ break;
+ }
+ if (*cp == '.') {
+ /*
+ * Internet format:
+ * a.b.c.d
+ * a.b.c (with c treated as 16-bits)
+ * a.b (with b treated as 24 bits)
+ */
+ if (pp >= parts + 4)
+ return (-1);
+ *pp++ = val, cp++;
+ goto again;
+ }
+ /*
+ * Check for trailing characters.
+ */
+ if (*cp && !isspace(*cp))
+ return (-1);
+ *pp++ = val;
+ /*
+ * Concoct the address according to
+ * the number of parts specified.
+ */
+ n = pp - parts;
+ switch (n) {
+
+ case 1: /* a -- 32 bits */
+ val = parts[0];
+ break;
+
+ case 2: /* a.b -- 8.24 bits */
+ val = (parts[0] << 24) | (parts[1] & 0xffffff);
+ break;
+
+ case 3: /* a.b.c -- 8.8.16 bits */
+ val = (parts[0] << 24) | ((parts[1] & 0xff) << 16) |
+ (parts[2] & 0xffff);
+ break;
+
+ case 4: /* a.b.c.d -- 8.8.8.8 bits */
+ val = (parts[0] << 24) | ((parts[1] & 0xff) << 16) |
+ ((parts[2] & 0xff) << 8) | (parts[3] & 0xff);
+ break;
+
+ default:
+ return (-1);
+ }
+ val = htonl(val);
+ return (val);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)inet_lnaof.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <netinet/in.h>
+
+/*
+ * Return the local network address portion of an
+ * internet address; handles class a/b/c network
+ * number formats.
+ */
+inet_lnaof(in)
+ struct in_addr in;
+{
+ register u_long i = ntohl(in.s_addr);
+
+ if (IN_CLASSA(i))
+ return ((i)&IN_CLASSA_HOST);
+ else if (IN_CLASSB(i))
+ return ((i)&IN_CLASSB_HOST);
+ else
+ return ((i)&IN_CLASSC_HOST);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)inet_makeaddr.c 5.1 (Berkeley) 3/11/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <netinet/in.h>
+
+/*
+ * Formulate an Internet address from network + host. Used in
+ * building addresses stored in the ifnet structure.
+ */
+struct in_addr
+inet_makeaddr(net, host)
+ int net, host;
+{
+ u_long addr;
+
+ if (net < 128)
+ addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST);
+ else if (net < 65536)
+ addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST);
+ else
+ addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST);
+ addr = htonl(addr);
+ return (*(struct in_addr *)&addr);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)inet_netof.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <netinet/in.h>
+
+/*
+ * Return the network number from an internet
+ * address; handles class a/b/c network #'s.
+ */
+inet_netof(in)
+ struct in_addr in;
+{
+ register u_long i = ntohl(in.s_addr);
+
+ if (IN_CLASSA(i))
+ return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT);
+ else if (IN_CLASSB(i))
+ return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT);
+ else
+ return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)inet_network.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <ctype.h>
+
+/*
+ * Internet network address interpretation routine.
+ * The library routines call this routine to interpret
+ * network numbers.
+ */
+u_long
+inet_network(cp)
+ register char *cp;
+{
+ register u_long val, base, n;
+ register char c;
+ u_long parts[4], *pp = parts;
+ register int i;
+
+again:
+ val = 0; base = 10;
+ if (*cp == '0')
+ base = 8, cp++;
+ if (*cp == 'x' || *cp == 'X')
+ base = 16, cp++;
+ while (c = *cp) {
+ if (isdigit(c)) {
+ val = (val * base) + (c - '0');
+ cp++;
+ continue;
+ }
+ if (base == 16 && isxdigit(c)) {
+ val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A'));
+ cp++;
+ continue;
+ }
+ break;
+ }
+ if (*cp == '.') {
+ if (pp >= parts + 4)
+ return (-1);
+ *pp++ = val, cp++;
+ goto again;
+ }
+ if (*cp && !isspace(*cp))
+ return (-1);
+ *pp++ = val;
+ n = pp - parts;
+ if (n > 4)
+ return (-1);
+ for (val = 0, i = 0; i < n; i++) {
+ val <<= 8;
+ val |= parts[i] & 0xff;
+ }
+ return (val);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)inet_ntoa.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Convert network-format internet address
+ * to base 256 d.d.d.d representation.
+ */
+#include <sys/types.h>
+#include <netinet/in.h>
+
+char *
+inet_ntoa(in)
+ struct in_addr in;
+{
+ static char b[18];
+ register char *p;
+
+ p = (char *)∈
+#define UC(b) (((int)b)&0xff)
+ sprintf(b, "%d.%d.%d.%d", UC(p[0]), UC(p[1]), UC(p[2]), UC(p[3]));
+ return (b);
+}
--- /dev/null
+diff --git a/lib/libc/compat-4.1/gtty.c b/lib/libc/compat-4.1/gtty.c
+index 9e589ae..2326582 100644
+--- a/lib/libc/compat-4.1/gtty.c
++++ b/lib/libc/compat-4.1/gtty.c
+@@ -15,7 +15,7 @@ static char sccsid[] = "@(#)gtty.c 5.2 (Berkeley) 3/9/86";
+ #include <sgtty.h>
+
+ gtty(fd, ap)
+- struct sgtty *ap;
++ struct sgttyb *ap;
+ {
+
+ return(ioctl(fd, TIOCGETP, ap));
+diff --git a/lib/libc/compat-4.1/stty.c b/lib/libc/compat-4.1/stty.c
+index 6253baf..a423a32 100644
+--- a/lib/libc/compat-4.1/stty.c
++++ b/lib/libc/compat-4.1/stty.c
+@@ -15,7 +15,7 @@ static char sccsid[] = "@(#)stty.c 5.2 (Berkeley) 3/9/86";
+ #include <sgtty.h>
+
+ stty(fd, ap)
+- struct sgtty *ap;
++ struct sgttyb *ap;
+ {
+
+ return(ioctl(fd, TIOCSETP, ap));
+diff --git a/lib/libc/stdio/Makefile b/lib/libc/stdio/Makefile
+index e837cfd..cd18527 100644
+--- a/lib/libc/stdio/Makefile
++++ b/lib/libc/stdio/Makefile
+@@ -25,15 +25,15 @@ STDSRC= clrerr.c doscan.c \
+ fprintf.c fputc.c fread.c freopen.c fseek.c ftell.c \
+ fwrite.c getchar.c getw.c printf.c putchar.c \
+ putw.c rew.c scanf.c setbuf.c setbuffer.c sibuf.c sobuf.c \
+- sprintf.c strout.c ungetc.c
+-VAXSRC= fgets.c fputs.c gets.c puts.c
++ sprintf.c strout.c ungetc.c vfprintf.c vprintf.c vsprintf.c
++VAXSRC= doprnt.c fgets.c fputs.c gets.c puts.c
+ STDOBJ= clrerr.o doscan.o \
+ exit.o fdopen.o fgetc.o filbuf.o findiop.o flsbuf.o fopen.o \
+ fprintf.o fputc.o fread.o freopen.o fseek.o ftell.o \
+ fwrite.o getchar.o getw.o printf.o putchar.o \
+ putw.o rew.o scanf.o setbuf.o setbuffer.o sibuf.o sobuf.o \
+- sprintf.o strout.o ungetc.o
+-VAXOBJ= fgets.o fputs.o gets.o puts.o
++ sprintf.o strout.o ungetc.o vfprintf.o vprintf.o vsprintf.o
++VAXOBJ= doprnt.o fgets.o fputs.o gets.o puts.o
+ TAGSFILE=tags
+
+ .c.o:
+diff --git a/lib/libc/stdio/doprnt.c b/lib/libc/stdio/doprnt.c
+new file mode 100644
+index 0000000..fb26796
+--- /dev/null
++++ b/lib/libc/stdio/doprnt.c
+@@ -0,0 +1,665 @@
++/*
++ * Copyright (c) 1988 Regents of the University of California.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms are permitted
++ * provided that the above copyright notice and this paragraph are
++ * duplicated in all such forms and that any documentation,
++ * advertising materials, and other materials related to such
++ * distribution and use acknowledge that the software was developed
++ * by the University of California, Berkeley. The name of the
++ * University may not be used to endorse or promote products derived
++ * from this software without specific prior written permission.
++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ */
++
++#if defined(LIBC_SCCS) && !defined(lint)
++static char sccsid[] = "@(#)doprnt.c 5.35 (Berkeley) 6/27/88";
++#endif /* LIBC_SCCS and not lint */
++
++#include <sys/types.h>
++#include <varargs.h>
++#include <stdio.h>
++#include <ctype.h>
++
++/* 11-bit exponent (VAX G floating point) is 308 decimal digits */
++#define MAXEXP 308
++/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */
++#define MAXFRACT 39
++
++#define DEFPREC 6
++
++#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
++
++#define PUTC(ch) (void) putc(ch, fp)
++
++#define ARG() \
++ _ulong = flags&LONGINT ? va_arg(argp, long) : \
++ flags&SHORTINT ? va_arg(argp, short) : va_arg(argp, int);
++
++#define todigit(c) ((c) - '0')
++#define tochar(n) ((n) + '0')
++
++/* have to deal with the negative buffer count kludge */
++#define NEGATIVE_COUNT_KLUDGE
++
++#define LONGINT 0x01 /* long integer */
++#define LONGDBL 0x02 /* long double; unimplemented */
++#define SHORTINT 0x04 /* short integer */
++#define ALT 0x08 /* alternate form */
++#define LADJUST 0x10 /* left adjustment */
++#define ZEROPAD 0x20 /* zero (as opposed to blank) pad */
++#define HEXPREFIX 0x40 /* add 0x or 0X prefix */
++
++_doprnt(fmt0, argp, fp)
++ u_char *fmt0;
++ va_list argp;
++ register FILE *fp;
++{
++ register u_char *fmt; /* format string */
++ register int ch; /* character from fmt */
++ register int cnt; /* return value accumulator */
++ register int n; /* random handy integer */
++ register char *t; /* buffer pointer */
++ double _double; /* double precision arguments %[eEfgG] */
++ u_long _ulong; /* integer arguments %[diouxX] */
++ int base; /* base for [diouxX] conversion */
++ int dprec; /* decimal precision in [diouxX] */
++ int fieldsz; /* field size expanded by sign, etc */
++ int flags; /* flags as above */
++ int fpprec; /* `extra' floating precision in [eEfgG] */
++ int prec; /* precision from format (%.3d), or -1 */
++ int realsz; /* field size expanded by decimal precision */
++ int size; /* size of converted field or string */
++ int width; /* width from format (%8d), or 0 */
++ char sign; /* sign prefix (' ', '+', '-', or \0) */
++ char softsign; /* temporary negative sign for floats */
++ char *digs; /* digits for [diouxX] conversion */
++ char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
++
++ if (fp->_flag & _IORW) {
++ fp->_flag |= _IOWRT;
++ fp->_flag &= ~(_IOEOF|_IOREAD);
++ }
++ if ((fp->_flag & _IOWRT) == 0)
++ return (EOF);
++
++ fmt = fmt0;
++ digs = "0123456789abcdef";
++ for (cnt = 0;; ++fmt) {
++ n = fp->_cnt;
++ for (t = (char *)fp->_ptr; (ch = *fmt) && ch != '%';
++ ++cnt, ++fmt)
++ if (--n < 0
++#ifdef NEGATIVE_COUNT_KLUDGE
++ && (!(fp->_flag & _IOLBF) || -n >= fp->_bufsiz)
++#endif
++ || ch == '\n' && fp->_flag & _IOLBF) {
++ fp->_cnt = n;
++ fp->_ptr = t;
++ (void) _flsbuf((u_char)ch, fp);
++ n = fp->_cnt;
++ t = (char *)fp->_ptr;
++ } else
++ *t++ = ch;
++ fp->_cnt = n;
++ fp->_ptr = t;
++ if (!ch)
++ return (cnt);
++
++ flags = 0; dprec = 0; fpprec = 0; width = 0;
++ prec = -1;
++ sign = '\0';
++
++rflag: switch (*++fmt) {
++ case ' ':
++ /*
++ * ``If the space and + flags both appear, the space
++ * flag will be ignored.''
++ * -- ANSI X3J11
++ */
++ if (!sign)
++ sign = ' ';
++ goto rflag;
++ case '#':
++ flags |= ALT;
++ goto rflag;
++ case '*':
++ /*
++ * ``A negative field width argument is taken as a
++ * - flag followed by a positive field width.''
++ * -- ANSI X3J11
++ * They don't exclude field widths read from args.
++ */
++ if ((width = va_arg(argp, int)) >= 0)
++ goto rflag;
++ width = -width;
++ /* FALLTHROUGH */
++ case '-':
++ flags |= LADJUST;
++ goto rflag;
++ case '+':
++ sign = '+';
++ goto rflag;
++ case '.':
++ if (*++fmt == '*')
++ n = va_arg(argp, int);
++ else {
++ n = 0;
++ while (isascii(*fmt) && isdigit(*fmt))
++ n = 10 * n + todigit(*fmt++);
++ --fmt;
++ }
++ prec = n < 0 ? -1 : n;
++ goto rflag;
++ case '0':
++ /*
++ * ``Note that 0 is taken as a flag, not as the
++ * beginning of a field width.''
++ * -- ANSI X3J11
++ */
++ flags |= ZEROPAD;
++ goto rflag;
++ case '1': case '2': case '3': case '4':
++ case '5': case '6': case '7': case '8': case '9':
++ n = 0;
++ do {
++ n = 10 * n + todigit(*fmt);
++ } while (isascii(*++fmt) && isdigit(*fmt));
++ width = n;
++ --fmt;
++ goto rflag;
++ case 'L':
++ flags |= LONGDBL;
++ goto rflag;
++ case 'h':
++ flags |= SHORTINT;
++ goto rflag;
++ case 'l':
++ flags |= LONGINT;
++ goto rflag;
++ case 'c':
++ *(t = buf) = va_arg(argp, int);
++ size = 1;
++ sign = '\0';
++ goto pforw;
++ case 'D':
++ flags |= LONGINT;
++ /*FALLTHROUGH*/
++ case 'd':
++ case 'i':
++ ARG();
++ if ((long)_ulong < 0) {
++ _ulong = -_ulong;
++ sign = '-';
++ }
++ base = 10;
++ goto number;
++ case 'e':
++ case 'E':
++ case 'f':
++ case 'g':
++ case 'G':
++ _double = va_arg(argp, double);
++ /*
++ * don't do unrealistic precision; just pad it with
++ * zeroes later, so buffer size stays rational.
++ */
++ if (prec > MAXFRACT) {
++ if (*fmt != 'g' && *fmt != 'G' || (flags&ALT))
++ fpprec = prec - MAXFRACT;
++ prec = MAXFRACT;
++ }
++ else if (prec == -1)
++ prec = DEFPREC;
++ /*
++ * softsign avoids negative 0 if _double is < 0 and
++ * no significant digits will be shown
++ */
++ if (_double < 0) {
++ softsign = '-';
++ _double = -_double;
++ }
++ else
++ softsign = 0;
++ /*
++ * cvt may have to round up past the "start" of the
++ * buffer, i.e. ``intf("%.2f", (double)9.999);'';
++ * if the first char isn't NULL, it did.
++ */
++ *buf = NULL;
++ size = cvt(_double, prec, flags, &softsign, *fmt, buf,
++ buf + sizeof(buf));
++ if (softsign)
++ sign = '-';
++ t = *buf ? buf : buf + 1;
++ goto pforw;
++ case 'n':
++ if (flags & LONGINT)
++ *va_arg(argp, long *) = cnt;
++ else if (flags & SHORTINT)
++ *va_arg(argp, short *) = cnt;
++ else
++ *va_arg(argp, int *) = cnt;
++ break;
++ case 'O':
++ flags |= LONGINT;
++ /*FALLTHROUGH*/
++ case 'o':
++ ARG();
++ base = 8;
++ goto nosign;
++ case 'p':
++ /*
++ * ``The argument shall be a pointer to void. The
++ * value of the pointer is converted to a sequence
++ * of printable characters, in an implementation-
++ * defined manner.''
++ * -- ANSI X3J11
++ */
++ /* NOSTRICT */
++ _ulong = (u_long)va_arg(argp, void *);
++ base = 16;
++ goto nosign;
++ case 's':
++ if (!(t = va_arg(argp, char *)))
++ t = "(null)";
++ if (prec >= 0) {
++ /*
++ * can't use strlen; can only look for the
++ * NUL in the first `prec' characters, and
++ * strlen() will go further.
++ */
++ char *p, *memchr();
++
++ if (p = memchr(t, 0, prec)) {
++ size = p - t;
++ if (size > prec)
++ size = prec;
++ } else
++ size = prec;
++ } else
++ size = strlen(t);
++ sign = '\0';
++ goto pforw;
++ case 'U':
++ flags |= LONGINT;
++ /*FALLTHROUGH*/
++ case 'u':
++ ARG();
++ base = 10;
++ goto nosign;
++ case 'X':
++ digs = "0123456789ABCDEF";
++ /* FALLTHROUGH */
++ case 'x':
++ ARG();
++ base = 16;
++ /* leading 0x/X only if non-zero */
++ if (flags & ALT && _ulong != 0)
++ flags |= HEXPREFIX;
++
++ /* unsigned conversions */
++nosign: sign = '\0';
++ /*
++ * ``... diouXx conversions ... if a precision is
++ * specified, the 0 flag will be ignored.''
++ * -- ANSI X3J11
++ */
++number: if ((dprec = prec) >= 0)
++ flags &= ~ZEROPAD;
++
++ /*
++ * ``The result of converting a zero value with an
++ * explicit precision of zero is no characters.''
++ * -- ANSI X3J11
++ */
++ t = buf + BUF;
++ if (_ulong != 0 || prec != 0) {
++ do {
++ *--t = digs[_ulong % base];
++ _ulong /= base;
++ } while (_ulong);
++ digs = "0123456789abcdef";
++ if (flags & ALT && base == 8 && *t != '0')
++ *--t = '0'; /* octal leading 0 */
++ }
++ size = buf + BUF - t;
++
++pforw:
++ /*
++ * All reasonable formats wind up here. At this point,
++ * `t' points to a string which (if not flags&LADJUST)
++ * should be padded out to `width' places. If
++ * flags&ZEROPAD, it should first be prefixed by any
++ * sign or other prefix; otherwise, it should be blank
++ * padded before the prefix is emitted. After any
++ * left-hand padding and prefixing, emit zeroes
++ * required by a decimal [diouxX] precision, then print
++ * the string proper, then emit zeroes required by any
++ * leftover floating precision; finally, if LADJUST,
++ * pad with blanks.
++ */
++
++ /*
++ * compute actual size, so we know how much to pad
++ * fieldsz excludes decimal prec; realsz includes it
++ */
++ fieldsz = size + fpprec;
++ if (sign)
++ fieldsz++;
++ if (flags & HEXPREFIX)
++ fieldsz += 2;
++ realsz = dprec > fieldsz ? dprec : fieldsz;
++
++ /* right-adjusting blank padding */
++ if ((flags & (LADJUST|ZEROPAD)) == 0 && width)
++ for (n = realsz; n < width; n++)
++ PUTC(' ');
++ /* prefix */
++ if (sign)
++ PUTC(sign);
++ if (flags & HEXPREFIX) {
++ PUTC('0');
++ PUTC((char)*fmt);
++ }
++ /* right-adjusting zero padding */
++ if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
++ for (n = realsz; n < width; n++)
++ PUTC('0');
++ /* leading zeroes from decimal precision */
++ for (n = fieldsz; n < dprec; n++)
++ PUTC('0');
++
++ /* the string or number proper */
++ if (fp->_cnt - (n = size) >= 0 &&
++ (fp->_flag & _IOLBF) == 0) {
++ fp->_cnt -= n;
++ bcopy(t, (char *)fp->_ptr, n);
++ fp->_ptr += n;
++ } else
++ while (--n >= 0)
++ PUTC(*t++);
++ /* trailing f.p. zeroes */
++ while (--fpprec >= 0)
++ PUTC('0');
++ /* left-adjusting padding (always blank) */
++ if (flags & LADJUST)
++ for (n = realsz; n < width; n++)
++ PUTC(' ');
++ /* finally, adjust cnt */
++ cnt += width > realsz ? width : realsz;
++ break;
++ case '\0': /* "%?" prints ?, unless ? is NULL */
++ return (cnt);
++ default:
++ PUTC((char)*fmt);
++ cnt++;
++ }
++ }
++ /* NOTREACHED */
++}
++
++static
++cvt(number, prec, flags, signp, fmtch, startp, endp)
++ double number;
++ register int prec;
++ int flags;
++ u_char fmtch;
++ char *signp, *startp, *endp;
++{
++ register char *p, *t;
++ register double fract;
++ int dotrim, expcnt, gformat;
++ double integer, tmp, modf();
++ char *exponent(), *round();
++
++ dotrim = expcnt = gformat = 0;
++ fract = modf(number, &integer);
++
++ /* get an extra slot for rounding. */
++ t = ++startp;
++
++ /*
++ * get integer portion of number; put into the end of the buffer; the
++ * .01 is added for modf(356.0 / 10, &integer) returning .59999999...
++ */
++ for (p = endp - 1; integer; ++expcnt) {
++ tmp = modf(integer / 10, &integer);
++ *p-- = tochar((int)((tmp + .01) * 10));
++ }
++ switch(fmtch) {
++ case 'f':
++ /* reverse integer into beginning of buffer */
++ if (expcnt)
++ for (; ++p < endp; *t++ = *p);
++ else
++ *t++ = '0';
++ /*
++ * if precision required or alternate flag set, add in a
++ * decimal point.
++ */
++ if (prec || flags&ALT)
++ *t++ = '.';
++ /* if requires more precision and some fraction left */
++ if (fract) {
++ if (prec)
++ do {
++ fract = modf(fract * 10, &tmp);
++ *t++ = tochar((int)tmp);
++ } while (--prec && fract);
++ if (fract)
++ startp = round(fract, (int *)NULL, startp,
++ t - 1, (char)0, signp);
++ }
++ for (; prec--; *t++ = '0');
++ break;
++ case 'e':
++ case 'E':
++eformat: if (expcnt) {
++ *t++ = *++p;
++ if (prec || flags&ALT)
++ *t++ = '.';
++ /* if requires more precision and some integer left */
++ for (; prec && ++p < endp; --prec)
++ *t++ = *p;
++ /*
++ * if done precision and more of the integer component,
++ * round using it; adjust fract so we don't re-round
++ * later.
++ */
++ if (!prec && ++p < endp) {
++ fract = 0;
++ startp = round((double)0, &expcnt, startp,
++ t - 1, *p, signp);
++ }
++ /* adjust expcnt for digit in front of decimal */
++ --expcnt;
++ }
++ /* until first fractional digit, decrement exponent */
++ else if (fract) {
++ /* adjust expcnt for digit in front of decimal */
++ for (expcnt = -1;; --expcnt) {
++ fract = modf(fract * 10, &tmp);
++ if (tmp)
++ break;
++ }
++ *t++ = tochar((int)tmp);
++ if (prec || flags&ALT)
++ *t++ = '.';
++ }
++ else {
++ *t++ = '0';
++ if (prec || flags&ALT)
++ *t++ = '.';
++ }
++ /* if requires more precision and some fraction left */
++ if (fract) {
++ if (prec)
++ do {
++ fract = modf(fract * 10, &tmp);
++ *t++ = tochar((int)tmp);
++ } while (--prec && fract);
++ if (fract)
++ startp = round(fract, &expcnt, startp,
++ t - 1, (char)0, signp);
++ }
++ /* if requires more precision */
++ for (; prec--; *t++ = '0');
++
++ /* unless alternate flag, trim any g/G format trailing 0's */
++ if (gformat && !(flags&ALT)) {
++ while (t > startp && *--t == '0');
++ if (*t == '.')
++ --t;
++ ++t;
++ }
++ t = exponent(t, expcnt, fmtch);
++ break;
++ case 'g':
++ case 'G':
++ /* a precision of 0 is treated as a precision of 1. */
++ if (!prec)
++ ++prec;
++ /*
++ * ``The style used depends on the value converted; style e
++ * will be used only if the exponent resulting from the
++ * conversion is less than -4 or greater than the precision.''
++ * -- ANSI X3J11
++ */
++ if (expcnt > prec || !expcnt && fract && fract < .0001) {
++ /*
++ * g/G format counts "significant digits, not digits of
++ * precision; for the e/E format, this just causes an
++ * off-by-one problem, i.e. g/G considers the digit
++ * before the decimal point significant and e/E doesn't
++ * count it as precision.
++ */
++ --prec;
++ fmtch -= 2; /* G->E, g->e */
++ gformat = 1;
++ goto eformat;
++ }
++ /*
++ * reverse integer into beginning of buffer,
++ * note, decrement precision
++ */
++ if (expcnt)
++ for (; ++p < endp; *t++ = *p, --prec);
++ else
++ *t++ = '0';
++ /*
++ * if precision required or alternate flag set, add in a
++ * decimal point. If no digits yet, add in leading 0.
++ */
++ if (prec || flags&ALT) {
++ dotrim = 1;
++ *t++ = '.';
++ }
++ else
++ dotrim = 0;
++ /* if requires more precision and some fraction left */
++ if (fract) {
++ if (prec) {
++ do {
++ fract = modf(fract * 10, &tmp);
++ *t++ = tochar((int)tmp);
++ } while(!tmp);
++ while (--prec && fract) {
++ fract = modf(fract * 10, &tmp);
++ *t++ = tochar((int)tmp);
++ }
++ }
++ if (fract)
++ startp = round(fract, (int *)NULL, startp,
++ t - 1, (char)0, signp);
++ }
++ /* alternate format, adds 0's for precision, else trim 0's */
++ if (flags&ALT)
++ for (; prec--; *t++ = '0');
++ else if (dotrim) {
++ while (t > startp && *--t == '0');
++ if (*t != '.')
++ ++t;
++ }
++ }
++ return(t - startp);
++}
++
++static char *
++round(fract, exp, start, end, ch, signp)
++ double fract;
++ int *exp;
++ register char *start, *end;
++ char ch, *signp;
++{
++ double tmp;
++
++ if (fract)
++ (void)modf(fract * 10, &tmp);
++ else
++ tmp = todigit(ch);
++ if (tmp > 4)
++ for (;; --end) {
++ if (*end == '.')
++ --end;
++ if (++*end <= '9')
++ break;
++ *end = '0';
++ if (end == start) {
++ if (exp) { /* e/E; increment exponent */
++ *end = '1';
++ ++*exp;
++ }
++ else { /* f; add extra digit */
++ *--end = '1';
++ --start;
++ }
++ break;
++ }
++ }
++ /* ``"%.3f", (double)-0.0004'' gives you a negative 0. */
++ else if (*signp == '-')
++ for (;; --end) {
++ if (*end == '.')
++ --end;
++ if (*end != '0')
++ break;
++ if (end == start)
++ *signp = 0;
++ }
++ return(start);
++}
++
++static char *
++exponent(p, exp, fmtch)
++ register char *p;
++ register int exp;
++ u_char fmtch;
++{
++ register char *t;
++ char expbuf[MAXEXP];
++
++ *p++ = fmtch;
++ if (exp < 0) {
++ exp = -exp;
++ *p++ = '-';
++ }
++ else
++ *p++ = '+';
++ t = expbuf + MAXEXP;
++ if (exp > 9) {
++ do {
++ *--t = tochar(exp % 10);
++ } while ((exp /= 10) > 9);
++ *--t = tochar(exp);
++ for (; t < expbuf + MAXEXP; *p++ = *t++);
++ }
++ else {
++ *p++ = '0';
++ *p++ = tochar(exp);
++ }
++ return(p);
++}
+diff --git a/lib/libc/stdio/doscan.c b/lib/libc/stdio/doscan.c
+index 85fd7ad..415d6ed 100644
+--- a/lib/libc/stdio/doscan.c
++++ b/lib/libc/stdio/doscan.c
+@@ -3,7 +3,8 @@ static char sccsid[] = "@(#)doscan.c 5.2 (Berkeley) 3/9/86";
+ #endif LIBC_SCCS and not lint
+
+ #include <stdio.h>
+-#include <ctype.h>
++#include <ctype.h>
++#include <varargs.h>
+
+ #define SPC 01
+ #define STP 02
+@@ -27,14 +28,14 @@ static char _sctab[256] = {
+ 0,0,0,0,0,0,0,0,
+ };
+
+-_doscan(iop, fmt, argp)
++_doscan(iop, fmt, ap)
+ FILE *iop;
+ register char *fmt;
+-register int **argp;
++register va_list ap;
+ {
+ register int ch;
+ int nmatch, len, ch1;
+- int **ptr, fileended, size;
++ int *ptr, fileended, size;
+
+ nmatch = 0;
+ fileended = 0;
+@@ -46,7 +47,7 @@ register int **argp;
+ goto def;
+ ptr = 0;
+ if (ch != '*')
+- ptr = argp++;
++ ptr = va_arg(ap, int *);
+ else
+ ch = *fmt++;
+ len = 0;
+@@ -100,7 +101,7 @@ register int **argp;
+
+ static
+ _innum(ptr, type, len, size, iop, eofptr)
+-int **ptr, *eofptr;
++int *ptr, *eofptr;
+ FILE *iop;
+ {
+ extern double atof();
+@@ -111,7 +112,7 @@ FILE *iop;
+ long lcval;
+
+ if (type=='c' || type=='s' || type=='[')
+- return(_instr(ptr? *(char **)ptr: (char *)NULL, type, len, iop, eofptr));
++ return(_instr(ptr? (char *)ptr: (char *)NULL, type, len, iop, eofptr));
+ lcval = 0;
+ ndigit = 0;
+ scale = INT;
+@@ -185,23 +186,23 @@ FILE *iop;
+
+ case (FLOAT<<4) | SHORT:
+ case (FLOAT<<4) | REGULAR:
+- **(float **)ptr = atof(numbuf);
++ *(float *)ptr = atof(numbuf);
+ break;
+
+ case (FLOAT<<4) | LONG:
+- **(double **)ptr = atof(numbuf);
++ *(double *)ptr = atof(numbuf);
+ break;
+
+ case (INT<<4) | SHORT:
+- **(short **)ptr = lcval;
++ *(short *)ptr = lcval;
+ break;
+
+ case (INT<<4) | REGULAR:
+- **(int **)ptr = lcval;
++ *(int *)ptr = lcval;
+ break;
+
+ case (INT<<4) | LONG:
+- **(long **)ptr = lcval;
++ *(long *)ptr = lcval;
+ break;
+ }
+ return(1);
+diff --git a/lib/libc/stdio/fprintf.c b/lib/libc/stdio/fprintf.c
+index f5dfac0..29f2efa 100644
+--- a/lib/libc/stdio/fprintf.c
++++ b/lib/libc/stdio/fprintf.c
+@@ -1,32 +1,49 @@
+ /*
+ * Copyright (c) 1980 Regents of the University of California.
+- * All rights reserved. The Berkeley software License Agreement
+- * specifies the terms and conditions for redistribution.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms are permitted
++ * provided that the above copyright notice and this paragraph are
++ * duplicated in all such forms and that any documentation,
++ * advertising materials, and other materials related to such
++ * distribution and use acknowledge that the software was developed
++ * by the University of California, Berkeley. The name of the
++ * University may not be used to endorse or promote products derived
++ * from this software without specific prior written permission.
++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+ #if defined(LIBC_SCCS) && !defined(lint)
+-static char sccsid[] = "@(#)fprintf.c 5.2 (Berkeley) 3/9/86";
+-#endif LIBC_SCCS and not lint
++static char sccsid[] = "@(#)fprintf.c 5.4 (Berkeley) 6/27/88";
++#endif /* LIBC_SCCS and not lint */
+
+-#include <stdio.h>
++#include <stdio.h>
++#include <varargs.h>
+
+-fprintf(iop, fmt, args)
+-register FILE *iop;
+-char *fmt;
++fprintf(iop, fmt, va_alist)
++ register FILE *iop;
++ char *fmt;
++ va_dcl
+ {
++ va_list ap;
++ int len;
+ char localbuf[BUFSIZ];
+
++ va_start(ap);
+ if (iop->_flag & _IONBF) {
+ iop->_flag &= ~_IONBF;
+ iop->_ptr = iop->_base = localbuf;
+ iop->_bufsiz = BUFSIZ;
+- _doprnt(fmt, &args, iop);
++ len = _doprnt(fmt, ap, iop);
+ fflush(iop);
+ iop->_flag |= _IONBF;
+ iop->_base = NULL;
+ iop->_bufsiz = NULL;
+ iop->_cnt = 0;
+ } else
+- _doprnt(fmt, &args, iop);
+- return(ferror(iop)? EOF: 0);
++ len = _doprnt(fmt, ap, iop);
++ va_end(ap);
++ return(ferror(iop) ? EOF : len);
+ }
+diff --git a/lib/libc/stdio/printf.c b/lib/libc/stdio/printf.c
+index 2798278..7c14a77 100644
+--- a/lib/libc/stdio/printf.c
++++ b/lib/libc/stdio/printf.c
+@@ -1,12 +1,36 @@
++/*
++ * Copyright (c) 1987 Regents of the University of California.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms are permitted
++ * provided that the above copyright notice and this paragraph are
++ * duplicated in all such forms and that any documentation,
++ * advertising materials, and other materials related to such
++ * distribution and use acknowledge that the software was developed
++ * by the University of California, Berkeley. The name of the
++ * University may not be used to endorse or promote products derived
++ * from this software without specific prior written permission.
++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ */
++
+ #if defined(LIBC_SCCS) && !defined(lint)
+-static char sccsid[] = "@(#)printf.c 5.2 (Berkeley) 3/9/86";
+-#endif LIBC_SCCS and not lint
++static char sccsid[] = "@(#)printf.c 5.4 (Berkeley) 6/27/88";
++#endif /* LIBC_SCCS and not lint */
+
+-#include <stdio.h>
++#include <stdio.h>
++#include <varargs.h>
+
+-printf(fmt, args)
+-char *fmt;
++printf(fmt, va_alist)
++ char *fmt;
++ va_dcl
+ {
+- _doprnt(fmt, &args, stdout);
+- return(ferror(stdout)? EOF: 0);
++ va_list ap;
++ int len;
++
++ va_start(ap);
++ len = _doprnt(fmt, ap, stdout);
++ va_end(ap);
++ return(ferror(stdout) ? EOF : len);
+ }
+diff --git a/lib/libc/stdio/scanf.c b/lib/libc/stdio/scanf.c
+index 9f1cab6..9bca136 100644
+--- a/lib/libc/stdio/scanf.c
++++ b/lib/libc/stdio/scanf.c
+@@ -2,32 +2,53 @@
+ static char sccsid[] = "@(#)scanf.c 5.2 (Berkeley) 3/9/86";
+ #endif LIBC_SCCS and not lint
+
+-#include <stdio.h>
++#include <stdio.h>
++#include <varargs.h>
+
+-scanf(fmt, args)
++scanf(fmt, va_alist)
+ char *fmt;
++va_dcl
+ {
+- return(_doscan(stdin, fmt, &args));
++ va_list ap;
++ int len;
++
++ va_start(ap);
++ len = _doscan(stdin, fmt, &args);
++ va_end(ap);
++ return len;
+ }
+
+-fscanf(iop, fmt, args)
++fscanf(iop, fmt, va_alist)
+ FILE *iop;
+ char *fmt;
++va_dcl
+ {
+- return(_doscan(iop, fmt, &args));
++ va_list ap;
++ int len;
++
++ va_start(ap);
++ len = _doscan(iop, fmt, &args);
++ va_end(ap);
++ return len;
+ }
+
+-sscanf(str, fmt, args)
++sscanf(str, fmt, va_alist)
+ register char *str;
+ char *fmt;
++va_dcl
+ {
+ FILE _strbuf;
++ va_list ap;
++ int len;
+
++ va_start(ap);
+ _strbuf._flag = _IOREAD|_IOSTRG;
+ _strbuf._ptr = _strbuf._base = str;
+ _strbuf._cnt = 0;
+ while (*str++)
+ _strbuf._cnt++;
+ _strbuf._bufsiz = _strbuf._cnt;
+- return(_doscan(&_strbuf, fmt, &args));
++ len = _doscan(&_strbuf, fmt, &args);
++ va_end(ap);
++ return len;
+ }
+diff --git a/lib/libc/stdio/sprintf.c b/lib/libc/stdio/sprintf.c
+index 6bbacce..e4e9143 100644
+--- a/lib/libc/stdio/sprintf.c
++++ b/lib/libc/stdio/sprintf.c
+@@ -1,18 +1,41 @@
++/*
++ * Copyright (c) 1987 Regents of the University of California.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms are permitted
++ * provided that the above copyright notice and this paragraph are
++ * duplicated in all such forms and that any documentation,
++ * advertising materials, and other materials related to such
++ * distribution and use acknowledge that the software was developed
++ * by the University of California, Berkeley. The name of the
++ * University may not be used to endorse or promote products derived
++ * from this software without specific prior written permission.
++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ */
++
+ #if defined(LIBC_SCCS) && !defined(lint)
+-static char sccsid[] = "@(#)sprintf.c 5.2 (Berkeley) 3/9/86";
+-#endif LIBC_SCCS and not lint
++static char sccsid[] = "@(#)sprintf.c 5.5 (Berkeley) 6/27/88";
++#endif /* LIBC_SCCS and not lint */
+
+-#include <stdio.h>
++#include <stdio.h>
++#include <varargs.h>
+
+-char *sprintf(str, fmt, args)
+-char *str, *fmt;
++sprintf(str, fmt, va_alist)
++ char *str, *fmt;
++ va_dcl
+ {
++ va_list ap;
+ FILE _strbuf;
++ int len;
+
++ va_start(ap);
+ _strbuf._flag = _IOWRT+_IOSTRG;
+ _strbuf._ptr = str;
+ _strbuf._cnt = 32767;
+- _doprnt(fmt, &args, &_strbuf);
+- putc('\0', &_strbuf);
+- return(str);
++ len = _doprnt(fmt, ap, &_strbuf);
++ *_strbuf._ptr = 0;
++ va_end(ap);
++ return(len);
+ }
+diff --git a/lib/libc/stdio/vfprintf.c b/lib/libc/stdio/vfprintf.c
+new file mode 100644
+index 0000000..94f0fb5
+--- /dev/null
++++ b/lib/libc/stdio/vfprintf.c
+@@ -0,0 +1,47 @@
++/*
++ * Copyright (c) 1988 Regents of the University of California.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms are permitted
++ * provided that the above copyright notice and this paragraph are
++ * duplicated in all such forms and that any documentation,
++ * advertising materials, and other materials related to such
++ * distribution and use acknowledge that the software was developed
++ * by the University of California, Berkeley. The name of the
++ * University may not be used to endorse or promote products derived
++ * from this software without specific prior written permission.
++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ */
++
++#if defined(LIBC_SCCS) && !defined(lint)
++static char sccsid[] = "@(#)vfprintf.c 5.2 (Berkeley) 6/27/88";
++#endif /* LIBC_SCCS and not lint */
++
++#include <stdio.h>
++#include <varargs.h>
++
++int
++vfprintf(iop, fmt, ap)
++ FILE *iop;
++ char *fmt;
++ va_list ap;
++{
++ int len;
++ char localbuf[BUFSIZ];
++
++ if (iop->_flag & _IONBF) {
++ iop->_flag &= ~_IONBF;
++ iop->_ptr = iop->_base = localbuf;
++ len = _doprnt(fmt, ap, iop);
++ (void) fflush(iop);
++ iop->_flag |= _IONBF;
++ iop->_base = NULL;
++ iop->_bufsiz = 0;
++ iop->_cnt = 0;
++ } else
++ len = _doprnt(fmt, ap, iop);
++
++ return (ferror(iop) ? EOF : len);
++}
+diff --git a/lib/libc/stdio/vprintf.c b/lib/libc/stdio/vprintf.c
+new file mode 100644
+index 0000000..ff99f39
+--- /dev/null
++++ b/lib/libc/stdio/vprintf.c
+@@ -0,0 +1,34 @@
++/*
++ * Copyright (c) 1988 Regents of the University of California.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms are permitted
++ * provided that the above copyright notice and this paragraph are
++ * duplicated in all such forms and that any documentation,
++ * advertising materials, and other materials related to such
++ * distribution and use acknowledge that the software was developed
++ * by the University of California, Berkeley. The name of the
++ * University may not be used to endorse or promote products derived
++ * from this software without specific prior written permission.
++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ */
++
++#if defined(LIBC_SCCS) && !defined(lint)
++static char sccsid[] = "@(#)vprintf.c 5.2 (Berkeley) 6/27/88";
++#endif /* LIBC_SCCS and not lint */
++
++#include <stdio.h>
++#include <varargs.h>
++
++int
++vprintf(fmt, ap)
++ char *fmt;
++ va_list ap;
++{
++ int len;
++
++ len = _doprnt(fmt, ap, stdout);
++ return (ferror(stdout) ? EOF : len);
++}
+diff --git a/lib/libc/stdio/vsprintf.c b/lib/libc/stdio/vsprintf.c
+new file mode 100644
+index 0000000..7f43f90
+--- /dev/null
++++ b/lib/libc/stdio/vsprintf.c
+@@ -0,0 +1,39 @@
++/*
++ * Copyright (c) 1988 Regents of the University of California.
++ * All rights reserved.
++ *
++ * Redistribution and use in source and binary forms are permitted
++ * provided that the above copyright notice and this paragraph are
++ * duplicated in all such forms and that any documentation,
++ * advertising materials, and other materials related to such
++ * distribution and use acknowledge that the software was developed
++ * by the University of California, Berkeley. The name of the
++ * University may not be used to endorse or promote products derived
++ * from this software without specific prior written permission.
++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ */
++
++#if defined(LIBC_SCCS) && !defined(lint)
++static char sccsid[] = "@(#)vsprintf.c 5.2 (Berkeley) 6/27/88";
++#endif /* LIBC_SCCS and not lint */
++
++#include <stdio.h>
++#include <varargs.h>
++
++int
++vsprintf(str, fmt, ap)
++ char *str, *fmt;
++ va_list ap;
++{
++ FILE f;
++ int len;
++
++ f._flag = _IOWRT+_IOSTRG;
++ f._ptr = str;
++ f._cnt = 32767;
++ len = _doprnt(fmt, ap, &f);
++ *f._ptr = 0;
++ return (len);
++}
--- /dev/null
+/* @(#)llib-lc 1.37 (Berkeley) 5/17/86 */
+
+/* LINTLIBRARY */
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <sys/dir.h>
+#include <sys/resource.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/timeb.h>
+#include <sys/times.h>
+#include <sys/uio.h>
+#include <sys/vtimes.h>
+#include <sys/wait.h>
+
+#include <netinet/in.h>
+
+#include <netns/ns.h>
+
+#include <arpa/inet.h>
+
+#include <disktab.h>
+#include <fstab.h>
+#include <grp.h>
+#include <ndbm.h>
+#include <netdb.h>
+#include <nlist.h>
+#include <pwd.h>
+#include <setjmp.h>
+#include <sgtty.h>
+#include <signal.h>
+#include <stdio.h>
+#include <ttyent.h>
+
+ /*** SECTION 2 ***/
+int errno;
+
+int accept(s, a, l) struct sockaddr *a; int *l; { return s; }
+int access( p, m) char *p; { return 0; }
+int acct(f) char *f; { return 0;}
+int adjtime(delta, odelta) struct timeval *delta, *odelta; { return 0; }
+int bind(s, n, l) struct sockaddr *n; { return 0; }
+char *brk(a) char *a; { return(a); }
+int chdir(s) char *s; { return(0); }
+int chmod(s, m) char *s; { return(0); }
+int chown(s, u, g) char *s; { return(0); }
+int chroot( d ) char *d; { return 0; }
+int close(f) { return(0); }
+int connect( s, n, l) struct sockaddr *n; { return 0; }
+int dup(f) { return(f); }
+int dup2( o, n) { return o; }
+ execve(s, v, e) char *s, *v[], *e[]; {;}
+ _exit(s) {;}
+int fchmod(f, m) { return(0); }
+int fchown(f, u, g) { return(0); }
+int fcntl(f, c, a) { return (0); }
+int flock( f, o ) { return 0; }
+int fork() { return(0); }
+int fsync( f ) { return 0; }
+int fstat(f, b) struct stat *b; { return(0); }
+int ftruncate( d, l) off_t l; { return 0;}
+int getdtablesize() { return 20 ; }
+gid_t getegid() { return((gid_t)1); }
+uid_t geteuid() { return((uid_t)1); }
+gid_t getgid() { return((gid_t)1); }
+int getgroups( n, g ) int n, *g; { return 0; }
+long gethostid() { return 1L; }
+int gethostname( n, l ) char *n; int l; { return 0 ;}
+int getitimer( w, v ) struct itimerval *v; { return 0; }
+int getpagesize() { return 1; }
+int getpeername(s, n, l) struct sockaddr *n; int *l; { return (0); }
+int getpgrp(p) { return 1; }
+int getpid() { return(1); }
+int getppid() { return(1); }
+int getpriority( w, who) { return 1;}
+int getrlimit( res, rip) struct rlimit *rip; { return 0;}
+int getrusage( res, rip) struct rusage *rip; { return 0;}
+int getsockname(s, name, namelen) char *name; int *namelen; { return(0); }
+int getsockopt( s, level, opt, buf, len ) char *buf; int *len; { return 0;}
+int gettimeofday( t, z ) struct timeval *t; struct timezone *z; { return 0;}
+uid_t getuid() { return((uid_t)1); }
+int ioctl( d, r, p) u_long r; char *p; { return 0;}
+int kill(p, s) { return(0); }
+int killpg( pg, s) { return 0;}
+int link(a, b) char *a, *b; { return(0); }
+int listen( s, b ){ return 0; }
+off_t lseek(f, o, d) off_t o; { return(o); }
+int lstat(s, b) char *s; struct stat *b; { return(0); }
+#ifdef notdef
+int madvise( a, l, b ) char * a; int l, b; { return 0;}
+int mmap( a, l, p, s, f, o ) char * a; off_t o; { return 0;}
+int mincore( a, l, v ) char * a; int l; char *v; { return 0; }
+#endif
+int mkdir( p, m ) char *p; { return 0; }
+int mknod(n, m, a) char *n; { return(0); }
+int mount(s, n, f) char *s, *n; { return(0); }
+#ifdef notdef
+int mprotect( a, l, p) char * a; { return 0;}
+int mremap( a, l, p, s, f) char * a, f; { return 0;}
+int munmap( a, l) char * a; { return 0;}
+#endif
+ /* VARARGS2 */
+int open(f, m, stuff) char *f; { return(0); }
+int pipe(f) int f[2]; { return(0); }
+ profil(b, s, o, i) char *b; {;}
+int ptrace(r, p, a, d) int *a; { return(0); }
+int quota(c, u, a, ad) char *ad; { return(0); }
+int read(f, b, l) char *b; { return(l); }
+int readv( d, v, l) struct iovec *v; { return l; }
+int readlink( p, b, s ) char *p, *b; { return 1; }
+ reboot( h ) {;}
+int recv( s, b, l, f ) char *b; { return l ; }
+int recvfrom( s, b, l, f, fr, fl ) char *b; struct sockaddr *fr; int *fl;
+ { return l; }
+int recvmsg( s, m, f ) struct msghdr m[]; { return 1; }
+int rename( f, t ) char *f, *t; { return 0;}
+int rmdir( p ) char *p; { return 0;}
+char *sbrk(i) { return((char *)0); }
+int select( n, r, w, e, t ) fd_set *r, *w, *e; struct timeval *t; { return n; }
+int send( s, m, l, f ) char *m; { return l; }
+int sendto( s, m, l, f, t, tl ) char *m; struct sockaddr *t; { return l; }
+int sendmsg( s, m, l) struct msghdr m[]; { return l; }
+int setgroups( n, g) int *g; { return 0; }
+int sethostid( h ) long h; { return 0;}
+int sethostname( n, l ) char *n; int l; { return 0 ;}
+int setitimer( w, v, ov ) struct itimerval *v, *ov; { return 0; }
+int setpgrp( g, pg) { return 0; }
+int setpriority( w, who, pri ) { return 1;}
+int setquota(s, f) char *s, *f; { return 0; }
+int setregid( r, e) int r, e; { return 0; }
+int setreuid( r, e) int r, e; { return 0; }
+int setrlimit( res, rip) struct rlimit *rip; { return 0;}
+ /* VARARGS */
+int setsockopt( s, level, opt, buf, len ) char *buf; { return 0;}
+int settimeofday( t, z ) struct timeval *t; struct timezone *z; { return 0;}
+int shutdown( s, h ){ return 0;}
+int (*signal(c, f))() int (*f)(); { return(f); }
+int sigvec(c, f, m) struct sigvec *f, *m; { return 0; }
+int sigblock(m) { return (m); }
+int sigsetmask(m) { return (m); }
+ sigpause(m) { ; }
+int sigreturn(scp) struct sigcontext *scp; { return -1; }
+int sigstack(ss, oss) struct sigstack *ss, *oss; { return 0 ; }
+int socket( a, t, p) {return 1;}
+int socketpair( d, t, p, s ) int s[2]; { return 0; }
+int stat(s, b) char *s; struct stat *b; { return(0); }
+#ifdef notdef
+char * stk( a ) char * a; { return a; }
+char * sstk( a ) int a; { return (char *)0; }
+#endif
+int swapon( s ) char *s; { return 0;}
+int symlink( t, f) char *t, *f; { return 0;}
+ sync(){;}
+int truncate( p, l) char *p; off_t l; { return 0;}
+int umask( n ) { return n; }
+int umount(s) char *s; { return 0; }
+int unlink(s) char *s; { return(0); }
+int utimes( f, t ) char *f; struct timeval t[2]; { return 0 ;}
+int vfork() { return(0); }
+ vhangup() { ; }
+int wait(s) union wait *s; { return(1); }
+int wait3( s, o, r) union wait *s; struct rusage *r; { return 1;}
+int write(f, b, l) char *b; { return(l); }
+int writev( f, v, l) struct iovec *v; { return l; }
+
+
+ /*** SECTION 3 ***/
+
+struct qelem { /* this should really be defined in an include file */
+ struct qelem *q_forw;
+ struct qelem *q_back;
+ char data[1];
+}
+
+ /* antique system calls and unclassified */
+ _longjmp( e, v) jmp_buf e; {;}
+int _setjmp(e) jmp_buf e; { return(0); }
+ abort() {;}
+int abs(i) int i; { return(i); }
+int alarm(s) unsigned s; { return(s); }
+ alphasort( d1, d2) struct direct **d1, **d2; { return 0;}
+char * asctime(t) struct tm *t; { return(""); }
+double atof(s) char *s; { return(1.); }
+int atoi(s) char *s; { return 1; }
+long atol(s) char *s; { return 1L; }
+int bcmp(b1, b2, length) char *b1, *b2; { return 0; }
+ bcopy(src, dst, length) char *src, *dst; { ; }
+ bzero(b, length) char *b; { ; }
+char * calloc(n,s) unsigned n, s; { static char c[1]; return(c); }
+void closedir( p ) DIR *p; {}
+ closelog() {}
+int creat(s, m) char *s; { return(0); }
+char * crypt(k,s) char *k, *s; { return(""); }
+char * ctime(c) long *c;{ return(""); }
+char _ctype_[];
+DBM * dbm_open(file, flags, mode) char *file; { return (DBM *) 0; }
+void dbm_close(db) DBM *db; { ; }
+datum dbm_fetch(db, key) DBM *db; datum key; { return key; }
+int dbm_store(db, key, cont, flags) DBM *db; datum key, cont; { return 0; }
+int dbm_delete(db, key) DBM *db; datum key; { return 0; }
+datum dbm_firstkey(db) DBM *db; { datum key; return key; }
+datum dbm_nextkey(db) DBM *db; { datum key; return key; }
+char * ecvt(v, n, d, s) double v; int *d, *s; { return(""); }
+ encrypt(s, i) char *s; {}
+int endfsent() { return 0; }
+int endgrent() { return 0; }
+ endhostent() { ; }
+ endnetent() { ; }
+ endprotoent() { ; }
+ endpwent() {}
+ endservent() { ; }
+ endttyent() { ; }
+ endusershell() { ; }
+char ** environ;
+ /* VARARGS */
+ execl(f, a) char *f, *a; {;}
+ /* VARARGS */
+ execle(f, a) char *f, *a; {;}
+ /* VARARGS */
+ execlp(f, a) char *f, *a; {;}
+ execv(s, v) char *s, *v[]; {;}
+ execvp(s, v) char *s, *v[]; {;}
+ exect(s, v, e) char *s, *v[], *e[]; {;}
+ exit(s) {;}
+char * fcvt(v, n, d, s) double v; int *d, *s; { return(""); }
+int ffs(i) { return i; }
+ free(p) char *p; {;}
+double frexp( v, e) double v; int *e; { return v; }
+ ftime(tp) struct timeb *tp; { ; }
+char * gcvt(v, n, b) double v; char *b; { return(""); }
+struct disktab * getdiskbyname(name) char *name; { return (struct disktab *) 0; }
+char * getenv( n ) char *n; { return n; }
+struct fstab * getfsent() { return (struct fstab *)NULL; }
+struct fstab * getfsspec( n ) char *n; { return (struct fstab *)NULL; }
+struct fstab * getfsfile( n ) char *n; { return (struct fstab *)NULL; }
+struct fstab * getfstype( t ) char *t; { return (struct fstab *)NULL; }
+struct group * getgrent() { return (struct group *)NULL; }
+struct group * getgrgid( n ) { return (struct group *)NULL; }
+struct group * getgrnam( n ) char *n; { return (struct group *)NULL; }
+struct hostent * gethostbyaddr(addr, len, type) char *addr; { return (struct hostent *) 0; }
+struct hostent * gethostbyname(name) char *name; { return (struct hostent *) 0; }
+struct hostent * gethostent() { return (struct hostent *) 0; }
+char * getlogin(){ return " "; }
+struct netent * getnetbyaddr(net, type) { return (struct netent *) 0; }
+struct netent * getnetbyname(name) char *name; { return (struct netent *) 0; }
+struct netent * getnetent() { return (struct netent *) 0; }
+int getopt(argc, argv, optstr) char **argv, *optstr; { return EOF; }
+char * getpass( n ) char *n ; { return n; }
+struct protoent * getprotobyname(name) char *name; { return (struct protoent *) 0; }
+struct protoent * getprotobynumber(proto) { return (struct protoent *) 0; }
+struct protoent * getprotoent() { return (struct protoent *) 0; }
+int getpw( u, b) char *b; { return 0; }
+struct passwd * getpwent() { return (struct passwd *)NULL; }
+struct passwd * getpwuid( n ) { return (struct passwd *)NULL; }
+struct passwd * getpwnam( n ) char *n; { return (struct passwd *)NULL; }
+struct servent * getservbyname(name, proto) char *name, *proto; { return (struct servent *) 0; }
+struct servent * getservbyport(port, proto) char *proto; { return (struct servent *) 0; }
+struct servent * getservent() { return (struct servent *) 0; }
+struct ttyent * getttynam(name) char *name; { return (struct ttyent *) 0; }
+char * getusershell() { return (char *) 0; }
+char * getwd(pathname) char *pathname; { return pathname; }
+struct tm * gmtime(c) long *c; { return gmtime(c); }
+int gtty(f, b) struct sgttyb *b; { return(0); }
+#ifndef htonl
+u_long htonl(hostlong) u_long hostlong; { return hostlong; }
+#endif htonl
+#ifndef htons
+u_short htons(hostshort) u_short hostshort; { return hostshort; }
+#endif htons
+char * index(s, c) char *s, c; { return s; }
+u_long inet_addr(cp) char *cp; { return 0L; }
+int inet_lnaof(in) struct in_addr in; { return 0; }
+int inet_netof(in) struct in_addr in; { return 0; }
+struct in_addr inet_makeaddr(net, host) { struct in_addr in; return in; }
+u_long inet_network(cp) char *cp; { return 0L; }
+char * inet_ntoa(in) struct in_addr in; { return (char *) 0; }
+int initgroups(uname, agroup) char *uname; { return 0; }
+char * initstate( s, st, n) unsigned s; char *st; { return st; }
+ insque(elem, pred) struct qelem *elem, pred; { ; }
+int isatty(f) { return 1; }
+double ldexp( v, e) double v; { return v; }
+ longjmp( e, v) jmp_buf e; {;}
+ longjmperror() {;}
+struct tm *localtime(c) long *c; { return localtime(c); }
+char * malloc(n) unsigned n; {static char c; return(&c);}
+char * memccpy(t, f, c, n) char *t, *f; { return t; }
+char * memchr(s, c, n) char *s; { return s; }
+int memcmp(s1, s2, n) char *s1, *s2; { return 0; }
+char * memcpy(t, f, n) char *t, *f; { return t; }
+char * memset(s, c, n) char *s; { return s; }
+char * mktemp(p) char *p; { return(p);}
+int mkstemp(p) char *p; { return(0);}
+double modf( v, p ) double v, *p; { return v; }
+ moncontrol(mode) { ; }
+ monitor(l, h, b, s, n) int (*l)(), (*h)(); short *b; {}
+ monstartup( l, h) int (*l)(), (*h)(); {;}
+int nice(incr) { return 0; }
+int nlist( f, n) char *f; struct nlist n[]; { return (0);}
+struct ns_addr ns_addr(name) char *name; { struct ns_addr ns; return ns; }
+char * ns_ntoa(addr) struct ns_addr addr; { return (char *) 0; }
+#ifndef ntohl
+u_long ntohl(netlong) u_long netlong; { return netlong; }
+#endif ntohl
+#ifndef ntohs
+u_short ntohs(netshort) u_short netshort; { return netshort; }
+#endif ntohs
+DIR * opendir( f ) char *f; { return (DIR *)NULL; }
+ openlog(s, f, l) char *s; {}
+char * optarg;
+int optind;
+ pause() {;}
+ perror(s) char *s; {}
+ psignal(sig, s) unsigned sig; char *s; {}
+ qsort( b, n, w, c ) char *b; int (*c)(); {;}
+int rand(){ return 1; }
+long random() { return 1L; }
+int rcmd(a, rp, lu, ru, c, f) char **a, *lu, *ru, *c; u_short rp; int *f; { return 0; }
+char * re_comp(s) char *s ; { return s; }
+int re_exec(s) char *s ; { return 1; }
+struct direct * readdir( p ) DIR *p; { return (struct direct *)NULL; }
+char * realloc(p, n) char *p; unsigned n; { static char c[1]; return(c);}
+ remque(elem) struct qelem *elem; { ; }
+int rexec(a, rp, n, p, c, f) char **a, *n, *p, *c; u_short rp; int *f; { return 0; }
+char * rindex(s, c) char *s, c; { return s; }
+int rresvport(p) int *p; { return 0; }
+int ruserok(rh, su, ru, lu) char *rh, *ru, *lu; { return 0; }
+int scandir(d, n, s, c) char *d; struct direct *(*n[]); int (*s)(),(*c)();
+ { return 1; }
+void seekdir( p, l) DIR *p; long l; {}
+int setegid(egid) gid_t egid; { return 0; }
+int seteuid(euid) uid_t euid; { return 0; }
+int setfsent() { return 0; }
+int setgrent() { return 0; }
+int setgid(g) gid_t g; { return(0); }
+ sethostent(stayopen) { ; }
+ sethostfile(name) char *name; { ; }
+int setjmp(e) jmp_buf e; { return(0); }
+ setkey(k) char *k; {}
+int setlogmask(m) { return(0); }
+ setnetent(stayopen) { ; }
+ setprotoent(stayopen) { ; }
+ setpwent() {}
+ setpwfile(file) char *file; {}
+int setrgid(rgid) gid_t rgid; { return 0; }
+int setruid(ruid) uid_t ruid; { return 0; }
+ setservent(stayopen) { ; }
+char * setstate( st ) char *st; { return st; }
+ setttyent() { ; }
+int setuid(u) uid_t u; { return(0); }
+ setusershell() { ; }
+int siginterrupt(sig, flag) { return 0; }
+ sleep(i) unsigned i; {}
+int srand(s){ return s; }
+char * strcat(a, b) char *a, *b; { return a; }
+char * strcatn(a, b, n) char *a, *b; { return a;}
+char * strchr(s, c) char *s, c; { return s; }
+int strcmp(a, b) char *a, *b; { return(1); }
+int strcmpn(a, b, n) char *a, *b; { return(1); }
+char * strcpy(a, b) char *a, *b; { return a; }
+char * strcpyn(a, b, n) char *a, *b; { return a; }
+int strcspn(s, set) char *s, *set; { return(0); }
+int strlen(s) char *s; { return(1); }
+char * strncat(a, b, n) char *a, *b; { return a;}
+int strncmp(a, b, n) char *a, *b; { return(1); }
+char * strncpy(a, b, n) char *a, *b; { return a; }
+char * strpbrk(s, brk) char *s, *brk; { return s; }
+char * strrchr(s, c) char *s, c; { return s; }
+int strspn(s, set) char *s, *set; { return(0); }
+char * strtok(s, sep) char *s, *sep; { return s; }
+int stty(f, b) struct sgttyb *b; { return(0); }
+ swab( f, t, n) char *f, *t; {;}
+ /* VARARGS2 */
+ syslog(l, f) char *f; {}
+char * sys_errlist[];
+char * sys_siglist[];
+int sys_nerr;
+int system(s) char *s; { return(0); }
+long tell(f) { return((long)0); }
+long telldir( p ) DIR *p; { return 1L; }
+long time(t) long *t; { return( 0L );}
+int times(tmsp) struct tms *tmsp; { return 0; }
+char * timezone( z, d ){ return (char *)0; }
+char * tmpnam(s) char *s; { return s; }
+char * ttyname(f) { return " "; }
+int ttyslot() { return 1; }
+unsigned ualarm(value, interval) unsigned value, interval; { return 0; }
+ usleep(useconds) unsigned useconds; { ; }
+int utime(name, timep) char *name; time_t *timep; { return 0; }
+char * valloc(s) unsigned s; { return malloc(s); }
+int vlimit(limit, value) { return 0; }
+int vtimes(par, ch) struct vtimes *par, *ch; { return 0; }
+
+ /* standard I/O library */
+
+int fclose(f) FILE *f; {return(0);}
+FILE * fdopen(fd, m) char *m; { return(stdin);}
+int fflush(f) FILE *f; {return(0);}
+int fgetc(f) FILE *f; {return 0; }
+char * fgets( s, l, f ) char *s; FILE *f; { return(s); }
+int _filbuf( f ) FILE *f; { return 0; }
+int _flsbuf( c, f ) unsigned char c; FILE *f; { return 0; }
+FILE * fopen(s,m) char *s, *m; { return(stdin); }
+ /* VARARGS2 */
+ fprintf( f, s ) FILE *f; char *s; {;}
+int fputc(c, f) char c; FILE *f; {return 0; }
+ fputs(s,f) char *s; FILE *f; {;}
+int fread( p, s, n, f ) char *p; FILE *f; {return(1);}
+FILE * freopen(s, m, f) char *s, *m; FILE *f; { return(stdin); }
+ /* VARARGS2 */
+ fscanf( f, s ) FILE *f; char *s; {return(1);}
+int fseek(f, o, p) FILE *f; long o; { return(0); }
+long ftell(f) FILE *f; { return(0L); }
+int fwrite( p, s, n, f ) char *p; FILE *f; {return(0);}
+#ifndef getc
+int getc(f) FILE *f; { return EOF; }
+#endif getc
+int getw(f) FILE *f; { return 0;}
+char * gets( s ) char *s; { return(s); }
+struct _iobuf _iob[];
+int pclose( f ) FILE *f; { return 0; }
+FILE * popen( c, t ) char *c, *t; { return(stdin); }
+ /* VARARGS1 */
+ printf( s ) char *s; {;}
+ puts(s) char *s;{;}
+#ifndef putc
+int putc(c, f) char c; FILE *f; { return 0; }
+#endif putc
+int putw(w, f) FILE *f; { return 0;}
+ rewind(f) FILE *f; {;}
+ /* VARARGS1 */
+ scanf( f ) char *f; {return(1); }
+ setbuf( f, b ) FILE *f; char *b; {;}
+ setbuffer( f, b, s ) FILE *f; char *b; {;}
+ setlinebuf( f ) FILE *f; {;}
+ /* VARARGS2 */
+char * sprintf( s, f ) char *s, *f; { return(s);}
+ /* VARARGS2 */
+ sscanf( s, f ) char *s, *f; { return(1); }
+ ungetc( c, f ) FILE *f; { return(c); }
--- /dev/null
+/*@(#)llib-lc 1.37 (Berkeley) 5/17/86 */
+
+/*LINTLIBRARY */
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include <sys/dir.h>
+#include <sys/resource.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+#include <sys/timeb.h>
+#include <sys/times.h>
+#include <sys/uio.h>
+#include <sys/vtimes.h>
+#include <sys/wait.h>
+
+#include <netinet/in.h>
+
+#include <netns/ns.h>
+
+#include <arpa/inet.h>
+
+#include <disktab.h>
+#include <fstab.h>
+#include <grp.h>
+#include <ndbm.h>
+#include <netdb.h>
+#include <nlist.h>
+#include <pwd.h>
+#include <setjmp.h>
+#include <sgtty.h>
+#include <signal.h>
+#include <stdio.h>
+#include <ttyent.h>
+
+void /***SECTION 2 ***/
+int errno;
+
+int accept(s, a, l) struct sockaddr *a; int *l; { return s; }
+int access(p, m) char *p; { return 0; }
+int acct(f) char *f; { return 0;}
+int adjtime(delta, odelta) struct timeval *delta, *odelta; { return 0; }
+int bind(s, n, l) struct sockaddr *n; { return 0; }
+char *brk(a) char *a; { return(a); }
+int chdir(s) char *s; { return(0); }
+int chmod(s, m) char *s; { return(0); }
+int chown(s, u, g) char *s; { return(0); }
+int chroot(d) char *d; { return 0; }
+int close(f) { return(0); }
+int connect(s, n, l) struct sockaddr *n; { return 0; }
+int dup(f) { return(f); }
+int dup2(o, n) { return o; }
+void execve(s, v, e) char *s, *v[], *e[]; {;}
+void _exit(s) {;}
+int fchmod(f, m) { return(0); }
+int fchown(f, u, g) { return(0); }
+int fcntl(f, c, a) { return (0); }
+int flock(f, o) { return 0; }
+int fork() { return(0); }
+int fsync(f) { return 0; }
+int fstat(f, b) struct stat *b; { return(0); }
+int ftruncate(d, l) off_t l; { return 0;}
+int getdtablesize() { return 20 ; }
+gid_t getegid() { return((gid_t)1); }
+uid_t geteuid() { return((uid_t)1); }
+gid_t getgid() { return((gid_t)1); }
+int getgroups(n, g) int n, *g; { return 0; }
+long gethostid() { return 1L; }
+int gethostname(n, l) char *n; int l; { return 0 ;}
+int getitimer(w, v) struct itimerval *v; { return 0; }
+int getpagesize() { return 1; }
+int getpeername(s, n, l) struct sockaddr *n; int *l; { return (0); }
+int getpgrp(p) { return 1; }
+int getpid() { return(1); }
+int getppid() { return(1); }
+int getpriority(w, who) { return 1;}
+int getrlimit(res, rip) struct rlimit *rip; { return 0;}
+int getrusage(res, rip) struct rusage *rip; { return 0;}
+int getsockname(s, name, namelen) char *name; int *namelen; { return(0); }
+int getsockopt(s, level, opt, buf, len) char *buf; int *len; { return 0;}
+int gettimeofday(t, z) struct timeval *t; struct timezone *z; { return 0;}
+uid_t getuid() { return((uid_t)1); }
+int ioctl(d, r, p) u_long r; char *p; { return 0;}
+int kill(p, s) { return(0); }
+int killpg(pg, s) { return 0;}
+int link(a, b) char *a, *b; { return(0); }
+int listen(s, b){ return 0; }
+off_t lseek(f, o, d) off_t o; { return(o); }
+int lstat(s, b) char *s; struct stat *b; { return(0); }
+#ifdef notdef
+int madvise(a, l, b) char *a; int l, b; { return 0;}
+int mmap(a, l, p, s, f, o) char *a; off_t o; { return 0;}
+int mincore(a, l, v) char *a; int l; char *v; { return 0; }
+#endif
+int mkdir(p, m) char *p; { return 0; }
+int mknod(n, m, a) char *n; { return(0); }
+int mount(s, n, f) char *s, *n; { return(0); }
+#ifdef notdef
+int mprotect(a, l, p) char *a; { return 0;}
+int mremap(a, l, p, s, f) char *a, f; { return 0;}
+int munmap(a, l) char *a; { return 0;}
+#endif
+void /*VARARGS2 */
+int open(f, m, stuff) char *f; { return(0); }
+int pipe(f) int f[2]; { return(0); }
+void profil(b, s, o, i) char *b; {;}
+int ptrace(r, p, a, d) int *a; { return(0); }
+int quota(c, u, a, ad) char *ad; { return(0); }
+int read(f, b, l) char *b; { return(l); }
+int readv(d, v, l) struct iovec *v; { return l; }
+int readlink(p, b, s) char *p, *b; { return 1; }
+void reboot(h) {;}
+int recv(s, b, l, f) char *b; { return l ; }
+int recvfrom(s, b, l, f, fr, fl) char *b; struct sockaddr *fr; int *fl;
+void { return l; }
+int recvmsg(s, m, f) struct msghdr m[]; { return 1; }
+int rename(f, t) char *f, *t; { return 0;}
+int rmdir(p) char *p; { return 0;}
+char *sbrk(i) { return((char *)0); }
+int select(n, r, w, e, t) fd_set *r, *w, *e; struct timeval *t; { return n; }
+int send(s, m, l, f) char *m; { return l; }
+int sendto(s, m, l, f, t, tl) char *m; struct sockaddr *t; { return l; }
+int sendmsg(s, m, l) struct msghdr m[]; { return l; }
+int setgroups(n, g) int *g; { return 0; }
+int sethostid(h) long h; { return 0;}
+int sethostname(n, l) char *n; int l; { return 0 ;}
+int setitimer(w, v, ov) struct itimerval *v, *ov; { return 0; }
+int setpgrp(g, pg) { return 0; }
+int setpriority(w, who, pri) { return 1;}
+int setquota(s, f) char *s, *f; { return 0; }
+int setregid(r, e) int r, e; { return 0; }
+int setreuid(r, e) int r, e; { return 0; }
+int setrlimit(res, rip) struct rlimit *rip; { return 0;}
+void /*VARARGS */
+int setsockopt(s, level, opt, buf, len) char *buf; { return 0;}
+int settimeofday(t, z) struct timeval *t; struct timezone *z; { return 0;}
+int shutdown(s, h){ return 0;}
+int (*signal(c, f))() int (*f)(); { return(f); }
+int sigvec(c, f, m) struct sigvec *f, *m; { return 0; }
+int sigblock(m) { return (m); }
+int sigsetmask(m) { return (m); }
+void sigpause(m) { ; }
+int sigreturn(scp) struct sigcontext *scp; { return -1; }
+int sigstack(ss, oss) struct sigstack *ss, *oss; { return 0 ; }
+int socket(a, t, p) {return 1;}
+int socketpair(d, t, p, s) int s[2]; { return 0; }
+int stat(s, b) char *s; struct stat *b; { return(0); }
+#ifdef notdef
+char *stk(a) char *a; { return a; }
+char *sstk(a) int a; { return (char *)0; }
+#endif
+int swapon(s) char *s; { return 0;}
+int symlink(t, f) char *t, *f; { return 0;}
+void sync(){;}
+int truncate(p, l) char *p; off_t l; { return 0;}
+int umask(n) { return n; }
+int umount(s) char *s; { return 0; }
+int unlink(s) char *s; { return(0); }
+int utimes(f, t) char *f; struct timeval t[2]; { return 0 ;}
+int vfork() { return(0); }
+void vhangup() { ; }
+int wait(s) union wait *s; { return(1); }
+int wait3(s, o, r) union wait *s; struct rusage *r; { return 1;}
+int write(f, b, l) char *b; { return(l); }
+int writev(f, v, l) struct iovec *v; { return l; }
+
+
+void /***SECTION 3 ***/
+
+struct qelem { /*this should really be defined in an include file */
+void struct qelem *q_forw;
+void struct qelem *q_back;
+void char data[1];
+}
+
+void /*antique system calls and unclassified */
+void _longjmp(e, v) jmp_buf e; {;}
+int _setjmp(e) jmp_buf e; { return(0); }
+void abort() {;}
+int abs(i) int i; { return(i); }
+int alarm(s) unsigned s; { return(s); }
+void alphasort(d1, d2) struct direct **d1, **d2; { return 0;}
+char *asctime(t) struct tm *t; { return(""); }
+double atof(s) char *s; { return(1.); }
+int atoi(s) char *s; { return 1; }
+long atol(s) char *s; { return 1L; }
+int bcmp(b1, b2, length) char *b1, *b2; { return 0; }
+void bcopy(src, dst, length) char *src, *dst; { ; }
+void bzero(b, length) char *b; { ; }
+char *calloc(n,s) unsigned n, s; { static char c[1]; return(c); }
+void closedir(p) DIR *p; {}
+void closelog() {}
+int creat(s, m) char *s; { return(0); }
+char *crypt(k,s) char *k, *s; { return(""); }
+char *ctime(c) long *c;{ return(""); }
+char _ctype_[];
+DBM *dbm_open(file, flags, mode) char *file; { return (DBM *) 0; }
+void dbm_close(db) DBM *db; { ; }
+datum dbm_fetch(db, key) DBM *db; datum key; { return key; }
+int dbm_store(db, key, cont, flags) DBM *db; datum key, cont; { return 0; }
+int dbm_delete(db, key) DBM *db; datum key; { return 0; }
+datum dbm_firstkey(db) DBM *db; { datum key; return key; }
+datum dbm_nextkey(db) DBM *db; { datum key; return key; }
+char *ecvt(v, n, d, s) double v; int *d, *s; { return(""); }
+void encrypt(s, i) char *s; {}
+int endfsent() { return 0; }
+int endgrent() { return 0; }
+void endhostent() { ; }
+void endnetent() { ; }
+void endprotoent() { ; }
+void endpwent() {}
+void endservent() { ; }
+void endttyent() { ; }
+void endusershell() { ; }
+char **environ;
+void /*VARARGS */
+void execl(f, a) char *f, *a; {;}
+void /*VARARGS */
+void execle(f, a) char *f, *a; {;}
+void /*VARARGS */
+void execlp(f, a) char *f, *a; {;}
+void execv(s, v) char *s, *v[]; {;}
+void execvp(s, v) char *s, *v[]; {;}
+void exect(s, v, e) char *s, *v[], *e[]; {;}
+void exit(s) {;}
+char *fcvt(v, n, d, s) double v; int *d, *s; { return(""); }
+int ffs(i) { return i; }
+void free(p) char *p; {;}
+double frexp(v, e) double v; int *e; { return v; }
+void ftime(tp) struct timeb *tp; { ; }
+char *gcvt(v, n, b) double v; char *b; { return(""); }
+struct disktab *getdiskbyname(name) char *name; { return (struct disktab *) 0; }
+char *getenv(n) char *n; { return n; }
+struct fstab *getfsent() { return (struct fstab *)NULL; }
+struct fstab *getfsspec(n) char *n; { return (struct fstab *)NULL; }
+struct fstab *getfsfile(n) char *n; { return (struct fstab *)NULL; }
+struct fstab *getfstype(t) char *t; { return (struct fstab *)NULL; }
+struct group *getgrent() { return (struct group *)NULL; }
+struct group *getgrgid(n) { return (struct group *)NULL; }
+struct group *getgrnam(n) char *n; { return (struct group *)NULL; }
+struct hostent *gethostbyaddr(addr, len, type) char *addr; { return (struct hostent *) 0; }
+struct hostent *gethostbyname(name) char *name; { return (struct hostent *) 0; }
+struct hostent *gethostent() { return (struct hostent *) 0; }
+char *getlogin(){ return " "; }
+struct netent *getnetbyaddr(net, type) { return (struct netent *) 0; }
+struct netent *getnetbyname(name) char *name; { return (struct netent *) 0; }
+struct netent *getnetent() { return (struct netent *) 0; }
+int getopt(argc, argv, optstr) char **argv, *optstr; { return EOF; }
+char *getpass(n) char *n ; { return n; }
+struct protoent *getprotobyname(name) char *name; { return (struct protoent *) 0; }
+struct protoent *getprotobynumber(proto) { return (struct protoent *) 0; }
+struct protoent *getprotoent() { return (struct protoent *) 0; }
+int getpw(u, b) char *b; { return 0; }
+struct passwd *getpwent() { return (struct passwd *)NULL; }
+struct passwd *getpwuid(n) { return (struct passwd *)NULL; }
+struct passwd *getpwnam(n) char *n; { return (struct passwd *)NULL; }
+struct servent *getservbyname(name, proto) char *name, *proto; { return (struct servent *) 0; }
+struct servent *getservbyport(port, proto) char *proto; { return (struct servent *) 0; }
+struct servent *getservent() { return (struct servent *) 0; }
+struct ttyent *getttynam(name) char *name; { return (struct ttyent *) 0; }
+char *getusershell() { return (char *) 0; }
+char *getwd(pathname) char *pathname; { return pathname; }
+struct tm *gmtime(c) long *c; { return gmtime(c); }
+int gtty(f, b) struct sgttyb *b; { return(0); }
+#ifndef htonl
+u_long htonl(hostlong) u_long hostlong; { return hostlong; }
+#endif htonl
+#ifndef htons
+u_short htons(hostshort) u_short hostshort; { return hostshort; }
+#endif htons
+char *index(s, c) char *s, c; { return s; }
+u_long inet_addr(cp) char *cp; { return 0L; }
+int inet_lnaof(in) struct in_addr in; { return 0; }
+int inet_netof(in) struct in_addr in; { return 0; }
+struct in_addr inet_makeaddr(net, host) { struct in_addr in; return in; }
+u_long inet_network(cp) char *cp; { return 0L; }
+char *inet_ntoa(in) struct in_addr in; { return (char *) 0; }
+int initgroups(uname, agroup) char *uname; { return 0; }
+char *initstate(s, st, n) unsigned s; char *st; { return st; }
+void insque(elem, pred) struct qelem *elem, pred; { ; }
+int isatty(f) { return 1; }
+double ldexp(v, e) double v; { return v; }
+void longjmp(e, v) jmp_buf e; {;}
+void longjmperror() {;}
+struct tm *localtime(c) long *c; { return localtime(c); }
+char *malloc(n) unsigned n; {static char c; return(&c);}
+char *memccpy(t, f, c, n) char *t, *f; { return t; }
+char *memchr(s, c, n) char *s; { return s; }
+int memcmp(s1, s2, n) char *s1, *s2; { return 0; }
+char *memcpy(t, f, n) char *t, *f; { return t; }
+char *memset(s, c, n) char *s; { return s; }
+char *mktemp(p) char *p; { return(p);}
+int mkstemp(p) char *p; { return(0);}
+double modf(v, p) double v, *p; { return v; }
+void moncontrol(mode) { ; }
+void monitor(l, h, b, s, n) int (*l)(), (*h)(); short *b; {}
+void monstartup(l, h) int (*l)(), (*h)(); {;}
+int nice(incr) { return 0; }
+int nlist(f, n) char *f; struct nlist n[]; { return (0);}
+struct ns_addr ns_addr(name) char *name; { struct ns_addr ns; return ns; }
+char *ns_ntoa(addr) struct ns_addr addr; { return (char *) 0; }
+#ifndef ntohl
+u_long ntohl(netlong) u_long netlong; { return netlong; }
+#endif ntohl
+#ifndef ntohs
+u_short ntohs(netshort) u_short netshort; { return netshort; }
+#endif ntohs
+DIR *opendir(f) char *f; { return (DIR *)NULL; }
+void openlog(s, f, l) char *s; {}
+char *optarg;
+int optind;
+void pause() {;}
+void perror(s) char *s; {}
+void psignal(sig, s) unsigned sig; char *s; {}
+void qsort(b, n, w, c) char *b; int (*c)(); {;}
+int rand(){ return 1; }
+long random() { return 1L; }
+int rcmd(a, rp, lu, ru, c, f) char **a, *lu, *ru, *c; u_short rp; int *f; { return 0; }
+char *re_comp(s) char *s ; { return s; }
+int re_exec(s) char *s ; { return 1; }
+struct direct *readdir(p) DIR *p; { return (struct direct *)NULL; }
+char *realloc(p, n) char *p; unsigned n; { static char c[1]; return(c);}
+void remque(elem) struct qelem *elem; { ; }
+int rexec(a, rp, n, p, c, f) char **a, *n, *p, *c; u_short rp; int *f; { return 0; }
+char *rindex(s, c) char *s, c; { return s; }
+int rresvport(p) int *p; { return 0; }
+int ruserok(rh, su, ru, lu) char *rh, *ru, *lu; { return 0; }
+int scandir(d, n, s, c) char *d; struct direct *(*n[]); int (*s)(),(*c)();
+void { return 1; }
+void seekdir(p, l) DIR *p; long l; {}
+int setegid(egid) gid_t egid; { return 0; }
+int seteuid(euid) uid_t euid; { return 0; }
+int setfsent() { return 0; }
+int setgrent() { return 0; }
+int setgid(g) gid_t g; { return(0); }
+void sethostent(stayopen) { ; }
+void sethostfile(name) char *name; { ; }
+int setjmp(e) jmp_buf e; { return(0); }
+void setkey(k) char *k; {}
+int setlogmask(m) { return(0); }
+void setnetent(stayopen) { ; }
+void setprotoent(stayopen) { ; }
+void setpwent() {}
+void setpwfile(file) char *file; {}
+int setrgid(rgid) gid_t rgid; { return 0; }
+int setruid(ruid) uid_t ruid; { return 0; }
+void setservent(stayopen) { ; }
+char *setstate(st) char *st; { return st; }
+void setttyent() { ; }
+int setuid(u) uid_t u; { return(0); }
+void setusershell() { ; }
+int siginterrupt(sig, flag) { return 0; }
+void sleep(i) unsigned i; {}
+int srand(s){ return s; }
+char *strcat(a, b) char *a, *b; { return a; }
+char *strcatn(a, b, n) char *a, *b; { return a;}
+char *strchr(s, c) char *s, c; { return s; }
+int strcmp(a, b) char *a, *b; { return(1); }
+int strcmpn(a, b, n) char *a, *b; { return(1); }
+char *strcpy(a, b) char *a, *b; { return a; }
+char *strcpyn(a, b, n) char *a, *b; { return a; }
+int strcspn(s, set) char *s, *set; { return(0); }
+int strlen(s) char *s; { return(1); }
+char *strncat(a, b, n) char *a, *b; { return a;}
+int strncmp(a, b, n) char *a, *b; { return(1); }
+char *strncpy(a, b, n) char *a, *b; { return a; }
+char *strpbrk(s, brk) char *s, *brk; { return s; }
+char *strrchr(s, c) char *s, c; { return s; }
+int strspn(s, set) char *s, *set; { return(0); }
+char *strtok(s, sep) char *s, *sep; { return s; }
+int stty(f, b) struct sgttyb *b; { return(0); }
+void swab(f, t, n) char *f, *t; {;}
+void /*VARARGS2 */
+void syslog(l, f) char *f; {}
+char *sys_errlist[];
+char *sys_siglist[];
+int sys_nerr;
+int system(s) char *s; { return(0); }
+long tell(f) { return((long)0); }
+long telldir(p) DIR *p; { return 1L; }
+long time(t) long *t; { return(0L);}
+int times(tmsp) struct tms *tmsp; { return 0; }
+char *timezone(z, d){ return (char *)0; }
+char *tmpnam(s) char *s; { return s; }
+char *ttyname(f) { return " "; }
+int ttyslot() { return 1; }
+unsigned ualarm(value, interval) unsigned value, interval; { return 0; }
+void usleep(useconds) unsigned useconds; { ; }
+int utime(name, timep) char *name; time_t *timep; { return 0; }
+char *valloc(s) unsigned s; { return malloc(s); }
+int vlimit(limit, value) { return 0; }
+int vtimes(par, ch) struct vtimes *par, *ch; { return 0; }
+
+void /*standard I/O library */
+
+int fclose(f) FILE *f; {return(0);}
+FILE *fdopen(fd, m) char *m; { return(stdin);}
+int fflush(f) FILE *f; {return(0);}
+int fgetc(f) FILE *f; {return 0; }
+char *fgets(s, l, f) char *s; FILE *f; { return(s); }
+int _filbuf(f) FILE *f; { return 0; }
+int _flsbuf(c, f) unsigned char c; FILE *f; { return 0; }
+FILE *fopen(s,m) char *s, *m; { return(stdin); }
+void /*VARARGS2 */
+void fprintf(f, s) FILE *f; char *s; {;}
+int fputc(c, f) char c; FILE *f; {return 0; }
+void fputs(s,f) char *s; FILE *f; {;}
+int fread(p, s, n, f) char *p; FILE *f; {return(1);}
+FILE *freopen(s, m, f) char *s, *m; FILE *f; { return(stdin); }
+void /*VARARGS2 */
+void fscanf(f, s) FILE *f; char *s; {return(1);}
+int fseek(f, o, p) FILE *f; long o; { return(0); }
+long ftell(f) FILE *f; { return(0L); }
+int fwrite(p, s, n, f) char *p; FILE *f; {return(0);}
+#ifndef getc
+int getc(f) FILE *f; { return EOF; }
+#endif getc
+int getw(f) FILE *f; { return 0;}
+char *gets(s) char *s; { return(s); }
+struct _iobuf _iob[];
+int pclose(f) FILE *f; { return 0; }
+FILE *popen(c, t) char *c, *t; { return(stdin); }
+void /*VARARGS1 */
+void printf(s) char *s; {;}
+void puts(s) char *s;{;}
+#ifndef putc
+int putc(c, f) char c; FILE *f; { return 0; }
+#endif putc
+int putw(w, f) FILE *f; { return 0;}
+void rewind(f) FILE *f; {;}
+void /*VARARGS1 */
+void scanf(f) char *f; {return(1); }
+void setbuf(f, b) FILE *f; char *b; {;}
+void setbuffer(f, b, s) FILE *f; char *b; {;}
+void setlinebuf(f) FILE *f; {;}
+void /*VARARGS2 */
+char *sprintf(s, f) char *s, *f; { return(s);}
+void /*VARARGS2 */
+void sscanf(s, f) char *s, *f; { return(1); }
+void ungetc(c, f) FILE *f; { return(c); }
--- /dev/null
+#!/bin/sh
+
+rm -rf compat-4.1 compat-sys5 gen include inet net ns stdio sys vax
+
+find ../../include -name '*.h' -print |\
+sed -e 's:^\.\./\.\./include/::' |\
+while read i
+do
+ mkdir --parents include/`dirname $i`
+ cp ../../include/$i include/$i
+done
+
+find ../../sys/h -name '*.h' -print |\
+sed -e 's:^\.\./\.\./sys/h/::' |\
+while read i
+do
+ mkdir --parents include/sys/`dirname $i`
+ cp ../../sys/h/$i include/sys
+done
+
+for i in net netimp netinet netns stand vax vaxif vaxmba vaxuba
+do
+ find ../../sys/$i -name '*.h' -print |\
+ sed -e "s:^\.\./\.\./sys/$i/::" |\
+ while read j
+ do
+ mkdir --parents include/$i/`dirname $j`
+ cp ../../sys/$i/$j include/$i/$j
+ done
+done
+
+(
+ cd include
+ ln -s vax machine
+ ln -s machine/frame.h frame.h
+ for i in errno.h signal.h syslog.h
+ do
+ ln -s sys/$i $i
+ done
+)
+
+find ../libc \( -name '*.c' -o -name 'Makefile' \) -print |\
+sed -e 's:^\.\./libc/::' |\
+while read i
+do
+ mkdir --parents `dirname $i`
+ cp ../libc/$i $i
+done
+
+find ../libc -name '*.s' -print |\
+sed -e 's:^\.\./libc/\(.*\)\.s:\1:' |\
+while read i
+do
+ mkdir --parents `dirname $i`
+ cp ../libc/$i.s $i.c
+done
+
+patch --strip 1 <include.patch
+patch --strip 3 <libc.patch
--- /dev/null
+/* net/getservbyname.c */
+struct servent *getservbyname __P((char *name, char *proto));
+/* net/htons.c */
+/* net/res_debug.c */
+int p_query __P((char *msg));
+int fp_query __P((char *msg, FILE *file));
+char *p_cdname __P((char *cp, char *msg, FILE *file));
+char *p_rr __P((char *cp, char *msg, FILE *file));
+char *p_type __P((int type));
+char *p_class __P((int class));
+/* net/res_init.c */
+int res_init __P((void));
+/* net/res_comp.c */
+int dn_expand __P((char *msg, char *eomorig, char *comp_dn, char *exp_dn, int length));
+int dn_comp __P((char *exp_dn, char *comp_dn, int length, char **dnptrs, char **lastdnptr));
+int dn_skip __P((char *comp_dn));
+int dn_find __P((char *exp_dn, char *msg, char **dnptrs, char **lastdnptr));
+u_short getshort __P((char *msgp));
+u_long getlong __P((char *msgp));
+int putshort __P((int s, register char *msgp));
+int putlong __P((register u_long l, register char *msgp));
+/* net/getproto.c */
+struct protoent *getprotobynumber __P((register int proto));
+/* net/getnetent.c */
+int setnetent __P((int f));
+int endnetent __P((void));
+struct netent *getnetent __P((void));
+/* net/rexec.c */
+int rexec __P((char **ahost, int rport, char *name, char *pass, char *cmd, int *fd2p));
+/* net/htonl.c */
+/* net/rcmd.c */
+int rcmd __P((char **ahost, int rport, char *locuser, char *remuser, char *cmd, int *fd2p));
+int rresvport __P((int *alport));
+int ruserok __P((char *rhost, int superuser, char *ruser, char *luser));
+int _validuser __P((FILE *hostf, char *rhost, char *luser, char *ruser, int baselen));
+int _checkhost __P((char *rhost, char *lhost, int len));
+/* net/getnetbyname.c */
+struct netent *getnetbyname __P((register char *name));
+/* net/ruserpass.c */
+int ruserpass __P((char *host, char **aname, char **apass));
+int mkpwunclear __P((char *spasswd, int mch, char *sencpasswd));
+int mkpwclear __P((char *sencpasswd, int mch, char *spasswd));
+/* net/getprotoname.c */
+struct protoent *getprotobyname __P((register char *name));
+/* net/ntohl.c */
+/* net/getprotoent.c */
+int setprotoent __P((int f));
+int endprotoent __P((void));
+struct protoent *getprotoent __P((void));
+/* net/getservbyport.c */
+struct servent *getservbyport __P((int port, char *proto));
+/* net/hosttable/gethostnamadr.c */
+struct hostent *gethostbyname __P((register char *nam));
+struct hostent *gethostbyaddr __P((char *addr, register int length, register int type));
+/* net/hosttable/gethostent.c */
+int sethostent __P((int f));
+int endhostent __P((void));
+struct hostent *gethostent __P((void));
+int sethostfile __P((char *file));
+/* net/res_send.c */
+int res_send __P((char *buf, int buflen, char *answer, int anslen));
+int _res_close __P((void));
+/* net/ntohs.c */
+/* net/named/gethostnamadr.c */
+struct hostent *gethostbyname __P((char *name));
+struct hostent *gethostbyaddr __P((char *addr, int len, int type));
+int _sethtent __P((int f));
+int _endhtent __P((void));
+struct hostent *_gethtent __P((void));
+struct hostent *_gethtbyname __P((char *name));
+struct hostent *_gethtbyaddr __P((char *addr, int len, int type));
+/* net/named/sethostent.c */
+int sethostent __P((int stayopen));
+int endhostent __P((void));
+int sethostfile __P((char *name));
+/* net/res_mkquery.c */
+int res_mkquery __P((int op, char *dname, int class, int type, char *data, int datalen, struct rrec *newrr, char *buf, int buflen));
+/* net/getservent.c */
+int setservent __P((int f));
+int endservent __P((void));
+struct servent *getservent __P((void));
+/* net/getnetbyaddr.c */
+struct netent *getnetbyaddr __P((register int net, register int type));
--- /dev/null
+#
+# Copyright (c) 1983 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 5.13 (Berkeley) 3/18/86
+#
+SRCS= getnetbyaddr.c getnetent.c getnetbyname.c \
+ getproto.c getprotoent.c getprotoname.c \
+ getservent.c getservbyport.c getservbyname.c \
+ rcmd.c rexec.c ruserpass.c \
+ res_comp.c res_debug.c res_init.c res_mkquery.c res_send.c
+
+OBJS= getnetbyaddr.o getnetent.o getnetbyname.o \
+ getproto.o getprotoent.o getprotoname.o \
+ getservent.o getservbyport.o getservbyname.o \
+ rcmd.o rexec.o ruserpass.o \
+ res_comp.o res_debug.o res_init.o res_mkquery.o res_send.o
+
+CFLAGS= -O ${DEFS}
+TAGSFILE=tags
+
+.c.o:
+ ${CC} -p -c ${CFLAGS} $*.c
+ -ld -X -r $*.o
+ mv a.out profiled/$*.o
+ ${CC} ${CFLAGS} -c $*.c
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+netlib netlib_p: ${OBJS}
+ @echo "building profiled netlib"
+ @cd profiled; ar cru ../netlib_p ${OBJS}
+ @echo "building normal netlib"
+ @ar cru netlib ${OBJS}
+
+tags:
+ cwd=`pwd`; \
+ for i in ${SRCS}; do \
+ ctags -a -f ${TAGSFILE} $$cwd/$$i; \
+ done
+
+clean:
+ rm -f *.o profiled/*.o errs a.out core netlib netlib_p \
+ tags Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+getnetbyaddr.o: getnetbyaddr.c /usr/include/netdb.h
+getnetent.o: getnetent.c /usr/include/stdio.h /usr/include/sys/types.h
+getnetent.o: /usr/include/sys/socket.h /usr/include/netdb.h
+getnetent.o: /usr/include/ctype.h
+getnetbyname.o: getnetbyname.c /usr/include/netdb.h
+getproto.o: getproto.c /usr/include/netdb.h
+getnetbyaddr.o: getnetbyaddr.c /usr/include/netdb.h
+getnetent.o: getnetent.c /usr/include/stdio.h /usr/include/sys/types.h
+getnetent.o: /usr/include/sys/socket.h /usr/include/netdb.h
+getnetent.o: /usr/include/ctype.h
+getnetbyname.o: getnetbyname.c /usr/include/netdb.h
+getproto.o: getproto.c /usr/include/netdb.h
+getprotoent.o: getprotoent.c /usr/include/stdio.h /usr/include/sys/types.h
+getprotoent.o: /usr/include/sys/socket.h /usr/include/netdb.h
+getprotoent.o: /usr/include/ctype.h
+getprotoname.o: getprotoname.c /usr/include/netdb.h
+getservent.o: getservent.c /usr/include/stdio.h /usr/include/sys/types.h
+getservent.o: /usr/include/sys/socket.h /usr/include/netdb.h
+getservent.o: /usr/include/ctype.h
+getservbyport.o: getservbyport.c /usr/include/netdb.h
+getservbyname.o: getservbyname.c /usr/include/netdb.h
+rcmd.o: rcmd.c /usr/include/stdio.h /usr/include/ctype.h /usr/include/pwd.h
+rcmd.o: /usr/include/sys/param.h /usr/include/machine/machparam.h
+rcmd.o: /usr/include/signal.h /usr/include/sys/types.h
+rcmd.o: /usr/include/sys/socket.h /usr/include/sys/stat.h
+rcmd.o: /usr/include/netinet/in.h /usr/include/netdb.h /usr/include/errno.h
+rexec.o: rexec.c /usr/include/sys/types.h /usr/include/sys/socket.h
+rexec.o: /usr/include/netinet/in.h /usr/include/stdio.h /usr/include/netdb.h
+rexec.o: /usr/include/errno.h
+ruserpass.o: ruserpass.c /usr/include/stdio.h /usr/include/utmp.h
+ruserpass.o: /usr/include/ctype.h /usr/include/sys/types.h
+ruserpass.o: /usr/include/sys/stat.h /usr/include/errno.h
+res_comp.o: res_comp.c /usr/include/sys/types.h /usr/include/stdio.h
+res_comp.o: /usr/include/arpa/nameser.h
+res_debug.o: res_debug.c /usr/include/sys/types.h /usr/include/netinet/in.h
+res_debug.o: /usr/include/stdio.h /usr/include/arpa/nameser.h
+res_init.o: res_init.c /usr/include/sys/types.h /usr/include/sys/socket.h
+res_init.o: /usr/include/netinet/in.h /usr/include/stdio.h
+res_init.o: /usr/include/arpa/nameser.h /usr/include/resolv.h
+res_mkquery.o: res_mkquery.c /usr/include/stdio.h /usr/include/sys/types.h
+res_mkquery.o: /usr/include/netinet/in.h /usr/include/arpa/nameser.h
+res_mkquery.o: /usr/include/resolv.h
+res_send.o: res_send.c /usr/include/sys/param.h
+res_send.o: /usr/include/machine/machparam.h /usr/include/signal.h
+res_send.o: /usr/include/sys/types.h /usr/include/sys/time.h
+res_send.o: /usr/include/time.h /usr/include/sys/socket.h
+res_send.o: /usr/include/netinet/in.h /usr/include/stdio.h /usr/include/errno.h
+res_send.o: /usr/include/arpa/nameser.h /usr/include/resolv.h
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getnetbyaddr.c 5.3 (Berkeley) 5/19/86";
+#endif LIBC_SCCS and not lint
+
+#include <netdb.h>
+
+extern int _net_stayopen;
+
+struct netent *
+getnetbyaddr(net, type)
+ register int net, type;
+{
+ register struct netent *p;
+
+ setnetent(_net_stayopen);
+ while (p = getnetent())
+ if (p->n_addrtype == type && p->n_net == net)
+ break;
+ if (!_net_stayopen)
+ endnetent();
+ return (p);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getnetbyname.c 5.3 (Berkeley) 5/19/86";
+#endif LIBC_SCCS and not lint
+
+#include <netdb.h>
+
+extern int _net_stayopen;
+
+struct netent *
+getnetbyname(name)
+ register char *name;
+{
+ register struct netent *p;
+ register char **cp;
+
+ setnetent(_net_stayopen);
+ while (p = getnetent()) {
+ if (strcmp(p->n_name, name) == 0)
+ break;
+ for (cp = p->n_aliases; *cp != 0; cp++)
+ if (strcmp(*cp, name) == 0)
+ goto found;
+ }
+found:
+ if (!_net_stayopen)
+ endnetent();
+ return (p);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getnetent.c 5.3 (Berkeley) 5/19/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <ctype.h>
+
+#define MAXALIASES 35
+
+static char NETDB[] = "/etc/networks";
+static FILE *netf = NULL;
+static char line[BUFSIZ+1];
+static struct netent net;
+static char *net_aliases[MAXALIASES];
+int _net_stayopen;
+static char *any();
+
+setnetent(f)
+ int f;
+{
+ if (netf == NULL)
+ netf = fopen(NETDB, "r" );
+ else
+ rewind(netf);
+ _net_stayopen |= f;
+}
+
+endnetent()
+{
+ if (netf) {
+ fclose(netf);
+ netf = NULL;
+ }
+ _net_stayopen = 0;
+}
+
+struct netent *
+getnetent()
+{
+ char *p;
+ register char *cp, **q;
+
+ if (netf == NULL && (netf = fopen(NETDB, "r" )) == NULL)
+ return (NULL);
+again:
+ p = fgets(line, BUFSIZ, netf);
+ if (p == NULL)
+ return (NULL);
+ if (*p == '#')
+ goto again;
+ cp = any(p, "#\n");
+ if (cp == NULL)
+ goto again;
+ *cp = '\0';
+ net.n_name = p;
+ cp = any(p, " \t");
+ if (cp == NULL)
+ goto again;
+ *cp++ = '\0';
+ while (*cp == ' ' || *cp == '\t')
+ cp++;
+ p = any(cp, " \t");
+ if (p != NULL)
+ *p++ = '\0';
+ net.n_net = inet_network(cp);
+ net.n_addrtype = AF_INET;
+ q = net.n_aliases = net_aliases;
+ if (p != NULL)
+ cp = p;
+ while (cp && *cp) {
+ if (*cp == ' ' || *cp == '\t') {
+ cp++;
+ continue;
+ }
+ if (q < &net_aliases[MAXALIASES - 1])
+ *q++ = cp;
+ cp = any(cp, " \t");
+ if (cp != NULL)
+ *cp++ = '\0';
+ }
+ *q = NULL;
+ return (&net);
+}
+
+static char *
+any(cp, match)
+ register char *cp;
+ char *match;
+{
+ register char *mp, c;
+
+ while (c = *cp) {
+ for (mp = match; *mp; mp++)
+ if (*mp == c)
+ return (cp);
+ cp++;
+ }
+ return ((char *)0);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getproto.c 5.3 (Berkeley) 5/19/86";
+#endif LIBC_SCCS and not lint
+
+#include <netdb.h>
+
+extern int _proto_stayopen;
+
+struct protoent *
+getprotobynumber(proto)
+ register int proto;
+{
+ register struct protoent *p;
+
+ setprotoent(_proto_stayopen);
+ while (p = getprotoent())
+ if (p->p_proto == proto)
+ break;
+ if (!_proto_stayopen)
+ endprotoent();
+ return (p);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getprotoent.c 5.3 (Berkeley) 5/19/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <ctype.h>
+
+#define MAXALIASES 35
+
+static char PROTODB[] = "/etc/protocols";
+static FILE *protof = NULL;
+static char line[BUFSIZ+1];
+static struct protoent proto;
+static char *proto_aliases[MAXALIASES];
+static char *any();
+int _proto_stayopen;
+
+setprotoent(f)
+ int f;
+{
+ if (protof == NULL)
+ protof = fopen(PROTODB, "r" );
+ else
+ rewind(protof);
+ _proto_stayopen |= f;
+}
+
+endprotoent()
+{
+ if (protof) {
+ fclose(protof);
+ protof = NULL;
+ }
+ _proto_stayopen = 0;
+}
+
+struct protoent *
+getprotoent()
+{
+ char *p;
+ register char *cp, **q;
+
+ if (protof == NULL && (protof = fopen(PROTODB, "r" )) == NULL)
+ return (NULL);
+again:
+ if ((p = fgets(line, BUFSIZ, protof)) == NULL)
+ return (NULL);
+ if (*p == '#')
+ goto again;
+ cp = any(p, "#\n");
+ if (cp == NULL)
+ goto again;
+ *cp = '\0';
+ proto.p_name = p;
+ cp = any(p, " \t");
+ if (cp == NULL)
+ goto again;
+ *cp++ = '\0';
+ while (*cp == ' ' || *cp == '\t')
+ cp++;
+ p = any(cp, " \t");
+ if (p != NULL)
+ *p++ = '\0';
+ proto.p_proto = atoi(cp);
+ q = proto.p_aliases = proto_aliases;
+ if (p != NULL) {
+ cp = p;
+ while (cp && *cp) {
+ if (*cp == ' ' || *cp == '\t') {
+ cp++;
+ continue;
+ }
+ if (q < &proto_aliases[MAXALIASES - 1])
+ *q++ = cp;
+ cp = any(cp, " \t");
+ if (cp != NULL)
+ *cp++ = '\0';
+ }
+ }
+ *q = NULL;
+ return (&proto);
+}
+
+static char *
+any(cp, match)
+ register char *cp;
+ char *match;
+{
+ register char *mp, c;
+
+ while (c = *cp) {
+ for (mp = match; *mp; mp++)
+ if (*mp == c)
+ return (cp);
+ cp++;
+ }
+ return ((char *)0);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getprotoname.c 5.3 (Berkeley) 5/19/86";
+#endif LIBC_SCCS and not lint
+
+#include <netdb.h>
+
+extern int _proto_stayopen;
+
+struct protoent *
+getprotobyname(name)
+ register char *name;
+{
+ register struct protoent *p;
+ register char **cp;
+
+ setprotoent(_proto_stayopen);
+ while (p = getprotoent()) {
+ if (strcmp(p->p_name, name) == 0)
+ break;
+ for (cp = p->p_aliases; *cp != 0; cp++)
+ if (strcmp(*cp, name) == 0)
+ goto found;
+ }
+found:
+ if (!_proto_stayopen)
+ endprotoent();
+ return (p);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getservbyname.c 5.3 (Berkeley) 5/19/86";
+#endif LIBC_SCCS and not lint
+
+#include <netdb.h>
+
+extern int _serv_stayopen;
+
+struct servent *
+getservbyname(name, proto)
+ char *name, *proto;
+{
+ register struct servent *p;
+ register char **cp;
+
+ setservent(_serv_stayopen);
+ while (p = getservent()) {
+ if (strcmp(name, p->s_name) == 0)
+ goto gotname;
+ for (cp = p->s_aliases; *cp; cp++)
+ if (strcmp(name, *cp) == 0)
+ goto gotname;
+ continue;
+gotname:
+ if (proto == 0 || strcmp(p->s_proto, proto) == 0)
+ break;
+ }
+ if (!_serv_stayopen)
+ endservent();
+ return (p);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getservbyport.c 5.3 (Berkeley) 5/19/86";
+#endif LIBC_SCCS and not lint
+
+#include <netdb.h>
+
+extern int _serv_stayopen;
+
+struct servent *
+getservbyport(port, proto)
+ int port;
+ char *proto;
+{
+ register struct servent *p;
+
+ setservent(_serv_stayopen);
+ while (p = getservent()) {
+ if (p->s_port != port)
+ continue;
+ if (proto == 0 || strcmp(p->s_proto, proto) == 0)
+ break;
+ }
+ if (!_serv_stayopen)
+ endservent();
+ return (p);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getservent.c 5.3 (Berkeley) 5/19/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <ctype.h>
+
+#define MAXALIASES 35
+
+static char SERVDB[] = "/etc/services";
+static FILE *servf = NULL;
+static char line[BUFSIZ+1];
+static struct servent serv;
+static char *serv_aliases[MAXALIASES];
+static char *any();
+int _serv_stayopen;
+
+setservent(f)
+ int f;
+{
+ if (servf == NULL)
+ servf = fopen(SERVDB, "r" );
+ else
+ rewind(servf);
+ _serv_stayopen |= f;
+}
+
+endservent()
+{
+ if (servf) {
+ fclose(servf);
+ servf = NULL;
+ }
+ _serv_stayopen = 0;
+}
+
+struct servent *
+getservent()
+{
+ char *p;
+ register char *cp, **q;
+
+ if (servf == NULL && (servf = fopen(SERVDB, "r" )) == NULL)
+ return (NULL);
+again:
+ if ((p = fgets(line, BUFSIZ, servf)) == NULL)
+ return (NULL);
+ if (*p == '#')
+ goto again;
+ cp = any(p, "#\n");
+ if (cp == NULL)
+ goto again;
+ *cp = '\0';
+ serv.s_name = p;
+ p = any(p, " \t");
+ if (p == NULL)
+ goto again;
+ *p++ = '\0';
+ while (*p == ' ' || *p == '\t')
+ p++;
+ cp = any(p, ",/");
+ if (cp == NULL)
+ goto again;
+ *cp++ = '\0';
+ serv.s_port = htons((u_short)atoi(p));
+ serv.s_proto = cp;
+ q = serv.s_aliases = serv_aliases;
+ cp = any(cp, " \t");
+ if (cp != NULL)
+ *cp++ = '\0';
+ while (cp && *cp) {
+ if (*cp == ' ' || *cp == '\t') {
+ cp++;
+ continue;
+ }
+ if (q < &serv_aliases[MAXALIASES - 1])
+ *q++ = cp;
+ cp = any(cp, " \t");
+ if (cp != NULL)
+ *cp++ = '\0';
+ }
+ *q = NULL;
+ return (&serv);
+}
+
+static char *
+any(cp, match)
+ register char *cp;
+ char *match;
+{
+ register char *mp, c;
+
+ while (c = *cp) {
+ for (mp = match; *mp; mp++)
+ if (*mp == c)
+ return (cp);
+ cp++;
+ }
+ return ((char *)0);
+}
--- /dev/null
+
+#
+# Copyright (c) 1983 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 5.4 (Berkeley) 9/5/85
+#
+
+OBJS= gethostnamadr.o gethostent.o
+SRCS= gethostnamadr.c gethostent.c
+CFLAGS= -O ${DEFS}
+
+.c.o:
+ ${CC} -p -c ${CFLAGS} $*.c
+ -ld -X -r $*.o
+ mv a.out profiled/$*.o
+ ${CC} ${CFLAGS} -c $*.c
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+hostlib hostlib_p: ${OBJS}
+ @echo "building profiled hostlib"
+ @cd profiled; ar cru ../hostlib_p ${OBJS}
+ @echo "building normal netlib"
+ @ar cru hostlib ${OBJS}
+
+tags:
+ cwd=`pwd`; \
+ for i in ${SRCS}; do \
+ ctags -a -f ${TAGSFILE} $$cwd/$$i; \
+ done
+
+clean:
+ rm -f *.o errs a.out core hostlib hostlib_p profiled/*.o \
+ tags Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+gethostnamadr.o: gethostnamadr.c /usr/include/stdio.h /usr/include/netdb.h
+gethostnamadr.o: /usr/include/sys/file.h /usr/include/ndbm.h
+gethostent.o: gethostent.c /usr/include/stdio.h /usr/include/sys/types.h
+gethostent.o: /usr/include/sys/socket.h /usr/include/netdb.h
+gethostent.o: /usr/include/ctype.h /usr/include/ndbm.h
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)gethostent.c 5.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <ctype.h>
+#include <ndbm.h>
+
+/*
+ * Internet version.
+ */
+#define MAXALIASES 35
+#define MAXADDRSIZE 14
+
+static FILE *hostf = NULL;
+static char line[BUFSIZ+1];
+static char hostaddr[MAXADDRSIZE];
+static struct hostent host;
+static char *host_aliases[MAXALIASES];
+static char *host_addrs[] = {
+ hostaddr,
+ NULL
+};
+
+/*
+ * The following is shared with gethostnamadr.c
+ */
+char *_host_file = "/etc/hosts";
+int _host_stayopen;
+DBM *_host_db; /* set by gethostbyname(), gethostbyaddr() */
+
+static char *any();
+
+sethostent(f)
+ int f;
+{
+ if (hostf != NULL)
+ rewind(hostf);
+ _host_stayopen |= f;
+}
+
+endhostent()
+{
+ if (hostf) {
+ fclose(hostf);
+ hostf = NULL;
+ }
+ if (_host_db) {
+ dbm_close(_host_db);
+ _host_db = (DBM *)NULL;
+ }
+ _host_stayopen = 0;
+}
+
+struct hostent *
+gethostent()
+{
+ char *p;
+ register char *cp, **q;
+
+ if (hostf == NULL && (hostf = fopen(_host_file, "r" )) == NULL)
+ return (NULL);
+again:
+ if ((p = fgets(line, BUFSIZ, hostf)) == NULL)
+ return (NULL);
+ if (*p == '#')
+ goto again;
+ cp = any(p, "#\n");
+ if (cp == NULL)
+ goto again;
+ *cp = '\0';
+ cp = any(p, " \t");
+ if (cp == NULL)
+ goto again;
+ *cp++ = '\0';
+ /* THIS STUFF IS INTERNET SPECIFIC */
+ host.h_addr_list = host_addrs;
+ *((u_long *)host.h_addr) = inet_addr(p);
+ host.h_length = sizeof (u_long);
+ host.h_addrtype = AF_INET;
+ while (*cp == ' ' || *cp == '\t')
+ cp++;
+ host.h_name = cp;
+ q = host.h_aliases = host_aliases;
+ cp = any(cp, " \t");
+ if (cp != NULL)
+ *cp++ = '\0';
+ while (cp && *cp) {
+ if (*cp == ' ' || *cp == '\t') {
+ cp++;
+ continue;
+ }
+ if (q < &host_aliases[MAXALIASES - 1])
+ *q++ = cp;
+ cp = any(cp, " \t");
+ if (cp != NULL)
+ *cp++ = '\0';
+ }
+ *q = NULL;
+ return (&host);
+}
+
+sethostfile(file)
+ char *file;
+{
+ _host_file = file;
+}
+
+static char *
+any(cp, match)
+ register char *cp;
+ char *match;
+{
+ register char *mp, c;
+
+ while (c = *cp) {
+ for (mp = match; *mp; mp++)
+ if (*mp == c)
+ return (cp);
+ cp++;
+ }
+ return ((char *)0);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)gethostnamadr.c 5.5 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <netdb.h>
+#include <sys/file.h>
+#include <ndbm.h>
+#include <ctype.h>
+
+#define MAXALIASES 35
+
+static struct hostent host;
+static char *host_aliases[MAXALIASES];
+static char hostbuf[BUFSIZ+1];
+static char *host_addrs[2];
+
+int h_errno;
+
+/*
+ * The following is shared with gethostent.c
+ */
+extern char *_host_file;
+DBM *_host_db = (DBM *)NULL;
+int _host_stayopen; /* set by sethostent(), cleared by endhostent() */
+
+static struct hostent *
+fetchhost(key)
+ datum key;
+{
+ register char *cp, *tp, **ap;
+ int naliases;
+
+ if (key.dptr == 0)
+ return ((struct hostent *)NULL);
+ key = dbm_fetch(_host_db, key);
+ if (key.dptr == 0)
+ return ((struct hostent *)NULL);
+ cp = key.dptr;
+ tp = hostbuf;
+ host.h_name = tp;
+ while (*tp++ = *cp++)
+ ;
+ bcopy(cp, (char *)&naliases, sizeof(int)); cp += sizeof (int);
+ for (ap = host_aliases; naliases > 0; naliases--) {
+ *ap++ = tp;
+ while (*tp++ = *cp++)
+ ;
+ }
+ *ap = (char *)NULL;
+ host.h_aliases = host_aliases;
+ bcopy(cp, (char *)&host.h_addrtype, sizeof (int));
+ cp += sizeof (int);
+ bcopy(cp, (char *)&host.h_length, sizeof (int));
+ cp += sizeof (int);
+ host.h_addr_list = host_addrs;
+ host.h_addr = tp;
+ bcopy(cp, tp, host.h_length);
+ return (&host);
+}
+
+struct hostent *
+gethostbyname(nam)
+ register char *nam;
+{
+ register struct hostent *hp;
+ register char **cp;
+ datum key;
+ char lowname[128];
+ register char *lp = lowname;
+
+ while (*nam)
+ if (isupper(*nam))
+ *lp++ = tolower(*nam++);
+ else
+ *lp++ = *nam++;
+ *lp = '\0';
+
+ if ((_host_db == (DBM *)NULL)
+ && ((_host_db = dbm_open(_host_file, O_RDONLY)) == (DBM *)NULL)) {
+ sethostent(_host_stayopen);
+ while (hp = gethostent()) {
+ if (strcmp(hp->h_name, lowname) == 0)
+ break;
+ for (cp = hp->h_aliases; cp != 0 && *cp != 0; cp++)
+ if (strcmp(*cp, lowname) == 0)
+ goto found;
+ }
+ found:
+ if (!_host_stayopen)
+ endhostent();
+ return (hp);
+ }
+ key.dptr = lowname;
+ key.dsize = strlen(lowname);
+ hp = fetchhost(key);
+ if (!_host_stayopen) {
+ dbm_close(_host_db);
+ _host_db = (DBM *)NULL;
+ }
+ if ( hp == NULL)
+ h_errno = HOST_NOT_FOUND;
+ return (hp);
+}
+
+struct hostent *
+gethostbyaddr(addr, length, type)
+ char *addr;
+ register int length;
+ register int type;
+{
+ register struct hostent *hp;
+ datum key;
+
+ if ((_host_db == (DBM *)NULL)
+ && ((_host_db = dbm_open(_host_file, O_RDONLY)) == (DBM *)NULL)) {
+ sethostent(_host_stayopen);
+ while (hp = gethostent()) {
+ if (hp->h_addrtype == type && hp->h_length == length
+ && bcmp(hp->h_addr, addr, length) == 0)
+ break;
+ }
+ if (!_host_stayopen)
+ endhostent();
+ if ( hp == NULL)
+ h_errno = HOST_NOT_FOUND;
+ return (hp);
+ }
+ key.dptr = addr;
+ key.dsize = length;
+ hp = fetchhost(key);
+ if (!_host_stayopen) {
+ dbm_close(_host_db);
+ _host_db = (DBM *)NULL;
+ }
+ if ( hp == NULL)
+ h_errno = HOST_NOT_FOUND;
+ return (hp);
+}
--- /dev/null
+#include "gen.h"
+u_long htonl(hostlong) u_long hostlong; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+u_short htons(hostshort) u_short hostshort; {
+ abort();
+}
--- /dev/null
+#
+# Copyright (c) 1983 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 6.3 (Berkeley) 3/18/86
+#
+
+OBJS= gethostnamadr.o sethostent.o
+
+SRCS= gethostnamadr.c sethostent.c
+
+CFLAGS= -O ${DEFS}
+TAGSFILE= tags
+DESTDIR=
+
+.c.o:
+ ${CC} -p -c ${CFLAGS} $*.c
+ -ld -X -r $*.o
+ mv a.out profiled/$*.o
+ ${CC} ${CFLAGS} -c $*.c
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+hostlib hostlib_p: ${OBJS}
+ @echo "building profiled hostlib"
+ @cd profiled; ar cru ../hostlib_p ${OBJS}
+ @echo "building normal hostlib"
+ @ar cru hostlib ${OBJS}
+
+tags:
+ cwd=`pwd`; \
+ for i in ${SRCS}; do \
+ ctags -a -f ${TAGSFILE} $$cwd/$$i; \
+ done
+
+clean:
+ rm -f *.o errs a.out core hostlib hostlib_p profiled/*.o \
+ tags Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+gethostnamadr.o: gethostnamadr.c /usr/include/sys/param.h
+gethostnamadr.o: /usr/include/machine/machparam.h /usr/include/signal.h
+gethostnamadr.o: /usr/include/sys/types.h /usr/include/sys/socket.h
+gethostnamadr.o: /usr/include/netinet/in.h /usr/include/sys/types.h
+gethostnamadr.o: /usr/include/ctype.h /usr/include/netdb.h /usr/include/stdio.h
+gethostnamadr.o: /usr/include/errno.h /usr/include/arpa/nameser.h
+gethostnamadr.o: /usr/include/resolv.h
+sethostent.o: sethostent.c
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)gethostnamadr.c 6.12 (Berkeley) 5/19/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <ctype.h>
+#include <netdb.h>
+#include <stdio.h>
+#include <errno.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+
+#define MAXALIASES 35
+#define MAXADDRS 35
+
+static char *h_addr_ptrs[MAXADDRS + 1];
+
+static struct hostent host;
+static char *host_aliases[MAXALIASES];
+static char hostbuf[BUFSIZ+1];
+static struct in_addr host_addr;
+static char HOSTDB[] = "/etc/hosts";
+static FILE *hostf = NULL;
+static char line[BUFSIZ+1];
+static char hostaddr[MAXADDRS];
+static char *host_addrs[2];
+static int stayopen = 0;
+static char *any();
+
+typedef union {
+ HEADER qb1;
+ char qb2[PACKETSZ];
+} querybuf;
+
+static union {
+ long al;
+ char ac;
+} align;
+
+
+int h_errno;
+extern errno;
+
+static struct hostent *
+getanswer(msg, msglen, iquery)
+ char *msg;
+ int msglen, iquery;
+{
+ register HEADER *hp;
+ register char *cp;
+ register int n;
+ querybuf answer;
+ char *eom, *bp, **ap;
+ int type, class, buflen, ancount, qdcount;
+ int haveanswer, getclass = C_ANY;
+ char **hap;
+
+ n = res_send(msg, msglen, (char *)&answer, sizeof(answer));
+ if (n < 0) {
+#ifdef DEBUG
+ int terrno;
+ terrno = errno;
+ if (_res.options & RES_DEBUG)
+ printf("res_send failed\n");
+ errno = terrno;
+#endif
+ h_errno = TRY_AGAIN;
+ return (NULL);
+ }
+ eom = (char *)&answer + n;
+ /*
+ * find first satisfactory answer
+ */
+ hp = (HEADER *) &answer;
+ ancount = ntohs(hp->ancount);
+ qdcount = ntohs(hp->qdcount);
+ if (hp->rcode != NOERROR || ancount == 0) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ printf("rcode = %d, ancount=%d\n", hp->rcode, ancount);
+#endif
+ switch (hp->rcode) {
+ case NXDOMAIN:
+ /* Check if it's an authoritive answer */
+ if (hp->aa)
+ h_errno = HOST_NOT_FOUND;
+ else
+ h_errno = TRY_AGAIN;
+ break;
+ case SERVFAIL:
+ h_errno = TRY_AGAIN;
+ break;
+ case NOERROR:
+ h_errno = NO_ADDRESS;
+ break;
+ case FORMERR:
+ case NOTIMP:
+ case REFUSED:
+ h_errno = NO_RECOVERY;
+ }
+ return (NULL);
+ }
+ bp = hostbuf;
+ buflen = sizeof(hostbuf);
+ cp = (char *)&answer + sizeof(HEADER);
+ if (qdcount) {
+ if (iquery) {
+ if ((n = dn_expand((char *)&answer, eom,
+ cp, bp, buflen)) < 0) {
+ h_errno = NO_RECOVERY;
+ return (NULL);
+ }
+ cp += n + QFIXEDSZ;
+ host.h_name = bp;
+ n = strlen(bp) + 1;
+ bp += n;
+ buflen -= n;
+ } else
+ cp += dn_skip(cp) + QFIXEDSZ;
+ while (--qdcount > 0)
+ cp += dn_skip(cp) + QFIXEDSZ;
+ } else if (iquery) {
+ if (hp->aa)
+ h_errno = HOST_NOT_FOUND;
+ else
+ h_errno = TRY_AGAIN;
+ return (NULL);
+ }
+ ap = host_aliases;
+ host.h_aliases = host_aliases;
+ hap = h_addr_ptrs;
+ host.h_addr_list = h_addr_ptrs;
+ haveanswer = 0;
+ while (--ancount >= 0 && cp < eom) {
+ if ((n = dn_expand((char *)&answer, eom, cp, bp, buflen)) < 0)
+ break;
+ cp += n;
+ type = getshort(cp);
+ cp += sizeof(u_short);
+ class = getshort(cp);
+ cp += sizeof(u_short) + sizeof(u_long);
+ n = getshort(cp);
+ cp += sizeof(u_short);
+ if (type == T_CNAME) {
+ cp += n;
+ if (ap >= &host_aliases[MAXALIASES-1])
+ continue;
+ *ap++ = bp;
+ n = strlen(bp) + 1;
+ bp += n;
+ buflen -= n;
+ continue;
+ }
+ if (type == T_PTR) {
+ if ((n = dn_expand((char *)&answer, eom,
+ cp, bp, buflen)) < 0) {
+ cp += n;
+ continue;
+ }
+ cp += n;
+ host.h_name = bp;
+ return(&host);
+ }
+ if (type != T_A) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ printf("unexpected answer type %d, size %d\n",
+ type, n);
+#endif
+ cp += n;
+ continue;
+ }
+ if (haveanswer) {
+ if (n != host.h_length) {
+ cp += n;
+ continue;
+ }
+ if (class != getclass) {
+ cp += n;
+ continue;
+ }
+ } else {
+ host.h_length = n;
+ getclass = class;
+ host.h_addrtype = (class == C_IN) ? AF_INET : AF_UNSPEC;
+ if (!iquery) {
+ host.h_name = bp;
+ bp += strlen(bp) + 1;
+ }
+ }
+
+ bp += ((u_long)bp % sizeof(align));
+
+ if (bp + n >= &hostbuf[sizeof(hostbuf)]) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ printf("size (%d) too big\n", n);
+#endif
+ break;
+ }
+ bcopy(cp, *hap++ = bp, n);
+ bp +=n;
+ cp += n;
+ haveanswer++;
+ }
+ if (haveanswer) {
+ *ap = NULL;
+ *hap = NULL;
+ return (&host);
+ } else {
+ h_errno = TRY_AGAIN;
+ return (NULL);
+ }
+}
+
+struct hostent *
+gethostbyname(name)
+ char *name;
+{
+ int n;
+ querybuf buf;
+ register struct hostent *hp;
+ extern struct hostent *_gethtbyname();
+
+ n = res_mkquery(QUERY, name, C_IN, T_A, (char *)NULL, 0, NULL,
+ (char *)&buf, sizeof(buf));
+ if (n < 0) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ printf("res_mkquery failed\n");
+#endif
+ return (NULL);
+ }
+ hp = getanswer((char *)&buf, n, 0);
+ if (hp == NULL && errno == ECONNREFUSED)
+ hp = _gethtbyname(name);
+ return(hp);
+}
+
+struct hostent *
+gethostbyaddr(addr, len, type)
+ char *addr;
+ int len, type;
+{
+ int n;
+ querybuf buf;
+ register struct hostent *hp;
+ char qbuf[MAXDNAME];
+ extern struct hostent *_gethtbyaddr();
+
+ if (type != AF_INET)
+ return (NULL);
+ (void)sprintf(qbuf, "%d.%d.%d.%d.in-addr.arpa",
+ ((unsigned)addr[3] & 0xff),
+ ((unsigned)addr[2] & 0xff),
+ ((unsigned)addr[1] & 0xff),
+ ((unsigned)addr[0] & 0xff));
+ n = res_mkquery(QUERY, qbuf, C_IN, T_PTR, (char *)NULL, 0, NULL,
+ (char *)&buf, sizeof(buf));
+ if (n < 0) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ printf("res_mkquery failed\n");
+#endif
+ return (NULL);
+ }
+ hp = getanswer((char *)&buf, n, 1);
+ if (hp == NULL && errno == ECONNREFUSED)
+ hp = _gethtbyaddr(addr, len, type);
+ if (hp == NULL)
+ return(NULL);
+ hp->h_addrtype = type;
+ hp->h_length = len;
+ h_addr_ptrs[0] = (char *)&host_addr;
+ h_addr_ptrs[1] = (char *)0;
+ host_addr = *(struct in_addr *)addr;
+ return(hp);
+}
+
+
+_sethtent(f)
+ int f;
+{
+ if (hostf == NULL)
+ hostf = fopen(HOSTDB, "r" );
+ else
+ rewind(hostf);
+ stayopen |= f;
+}
+
+_endhtent()
+{
+ if (hostf && !stayopen) {
+ (void) fclose(hostf);
+ hostf = NULL;
+ }
+}
+
+struct hostent *
+_gethtent()
+{
+ char *p;
+ register char *cp, **q;
+
+ if (hostf == NULL && (hostf = fopen(HOSTDB, "r" )) == NULL)
+ return (NULL);
+again:
+ if ((p = fgets(line, BUFSIZ, hostf)) == NULL)
+ return (NULL);
+ if (*p == '#')
+ goto again;
+ cp = any(p, "#\n");
+ if (cp == NULL)
+ goto again;
+ *cp = '\0';
+ cp = any(p, " \t");
+ if (cp == NULL)
+ goto again;
+ *cp++ = '\0';
+ /* THIS STUFF IS INTERNET SPECIFIC */
+ host.h_addr_list = host_addrs;
+ host.h_addr = hostaddr;
+ *((u_long *)host.h_addr) = inet_addr(p);
+ host.h_length = sizeof (u_long);
+ host.h_addrtype = AF_INET;
+ while (*cp == ' ' || *cp == '\t')
+ cp++;
+ host.h_name = cp;
+ q = host.h_aliases = host_aliases;
+ cp = any(cp, " \t");
+ if (cp != NULL)
+ *cp++ = '\0';
+ while (cp && *cp) {
+ if (*cp == ' ' || *cp == '\t') {
+ cp++;
+ continue;
+ }
+ if (q < &host_aliases[MAXALIASES - 1])
+ *q++ = cp;
+ cp = any(cp, " \t");
+ if (cp != NULL)
+ *cp++ = '\0';
+ }
+ *q = NULL;
+ return (&host);
+}
+
+static char *
+any(cp, match)
+ register char *cp;
+ char *match;
+{
+ register char *mp, c;
+
+ while (c = *cp) {
+ for (mp = match; *mp; mp++)
+ if (*mp == c)
+ return (cp);
+ cp++;
+ }
+ return ((char *)0);
+}
+
+struct hostent *
+_gethtbyname(name)
+ char *name;
+{
+ register struct hostent *p;
+ register char **cp;
+ char lowname[128];
+ register char *lp = lowname;
+
+ while (*name)
+ if (isupper(*name))
+ *lp++ = tolower(*name++);
+ else
+ *lp++ = *name++;
+ *lp = '\0';
+
+ _sethtent(0);
+ while (p = _gethtent()) {
+ if (strcmp(p->h_name, lowname) == 0)
+ break;
+ for (cp = p->h_aliases; *cp != 0; cp++)
+ if (strcmp(*cp, lowname) == 0)
+ goto found;
+ }
+found:
+ _endhtent();
+ return (p);
+}
+
+struct hostent *
+_gethtbyaddr(addr, len, type)
+ char *addr;
+ int len, type;
+{
+ register struct hostent *p;
+
+ _sethtent(0);
+ while (p = _gethtent())
+ if (p->h_addrtype == type && !bcmp(p->h_addr, addr, len))
+ break;
+ _endhtent();
+ return (p);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)sethostent.c 6.3 (Berkeley) 4/10/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <arpa/nameser.h>
+#include <netinet/in.h>
+#include <resolv.h>
+
+sethostent(stayopen)
+{
+ if (stayopen)
+ _res.options |= RES_STAYOPEN | RES_USEVC;
+}
+
+endhostent()
+{
+ _res.options &= ~(RES_STAYOPEN | RES_USEVC);
+ _res_close();
+}
+
+sethostfile(name)
+char *name;
+{
+#ifdef lint
+name = name;
+#endif
+}
--- /dev/null
+#include "gen.h"
+u_long ntohl(netlong) u_long netlong; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+u_short ntohs(netshort) u_short netshort; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rcmd.c 5.11 (Berkeley) 5/6/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <ctype.h>
+#include <pwd.h>
+#include <sys/param.h>
+#include <sys/file.h>
+#include <sys/signal.h>
+#include <sys/socket.h>
+#include <sys/stat.h>
+
+#include <netinet/in.h>
+
+#include <netdb.h>
+#include <errno.h>
+
+extern errno;
+char *index(), *sprintf();
+
+rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
+ char **ahost;
+ u_short rport;
+ char *locuser, *remuser, *cmd;
+ int *fd2p;
+{
+ int s, timo = 1, pid, oldmask;
+ struct sockaddr_in sin, sin2, from;
+ char c;
+ int lport = IPPORT_RESERVED - 1;
+ struct hostent *hp;
+
+ pid = getpid();
+ hp = gethostbyname(*ahost);
+ if (hp == 0) {
+ fprintf(stderr, "%s: unknown host\n", *ahost);
+ return (-1);
+ }
+ *ahost = hp->h_name;
+ oldmask = sigblock(sigmask(SIGURG));
+ for (;;) {
+ s = rresvport(&lport);
+ if (s < 0) {
+ if (errno == EAGAIN)
+ fprintf(stderr, "socket: All ports in use\n");
+ else
+ perror("rcmd: socket");
+ sigsetmask(oldmask);
+ return (-1);
+ }
+ fcntl(s, F_SETOWN, pid);
+ sin.sin_family = hp->h_addrtype;
+ bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr, hp->h_length);
+ sin.sin_port = rport;
+ if (connect(s, (caddr_t)&sin, sizeof (sin), 0) >= 0)
+ break;
+ (void) close(s);
+ if (errno == EADDRINUSE) {
+ lport--;
+ continue;
+ }
+ if (errno == ECONNREFUSED && timo <= 16) {
+ sleep(timo);
+ timo *= 2;
+ continue;
+ }
+ if (hp->h_addr_list[1] != NULL) {
+ int oerrno = errno;
+
+ fprintf(stderr,
+ "connect to address %s: ", inet_ntoa(sin.sin_addr));
+ errno = oerrno;
+ perror(0);
+ hp->h_addr_list++;
+ bcopy(hp->h_addr_list[0], (caddr_t)&sin.sin_addr,
+ hp->h_length);
+ fprintf(stderr, "Trying %s...\n",
+ inet_ntoa(sin.sin_addr));
+ continue;
+ }
+ perror(hp->h_name);
+ sigsetmask(oldmask);
+ return (-1);
+ }
+ lport--;
+ if (fd2p == 0) {
+ write(s, "", 1);
+ lport = 0;
+ } else {
+ char num[8];
+ int s2 = rresvport(&lport), s3;
+ int len = sizeof (from);
+
+ if (s2 < 0)
+ goto bad;
+ listen(s2, 1);
+ (void) sprintf(num, "%d", lport);
+ if (write(s, num, strlen(num)+1) != strlen(num)+1) {
+ perror("write: setting up stderr");
+ (void) close(s2);
+ goto bad;
+ }
+ s3 = accept(s2, &from, &len, 0);
+ (void) close(s2);
+ if (s3 < 0) {
+ perror("accept");
+ lport = 0;
+ goto bad;
+ }
+ *fd2p = s3;
+ from.sin_port = ntohs((u_short)from.sin_port);
+ if (from.sin_family != AF_INET ||
+ from.sin_port >= IPPORT_RESERVED) {
+ fprintf(stderr,
+ "socket: protocol failure in circuit setup.\n");
+ goto bad2;
+ }
+ }
+ (void) write(s, locuser, strlen(locuser)+1);
+ (void) write(s, remuser, strlen(remuser)+1);
+ (void) write(s, cmd, strlen(cmd)+1);
+ if (read(s, &c, 1) != 1) {
+ perror(*ahost);
+ goto bad2;
+ }
+ if (c != 0) {
+ while (read(s, &c, 1) == 1) {
+ (void) write(2, &c, 1);
+ if (c == '\n')
+ break;
+ }
+ goto bad2;
+ }
+ sigsetmask(oldmask);
+ return (s);
+bad2:
+ if (lport)
+ (void) close(*fd2p);
+bad:
+ (void) close(s);
+ sigsetmask(oldmask);
+ return (-1);
+}
+
+rresvport(alport)
+ int *alport;
+{
+ struct sockaddr_in sin;
+ int s;
+
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = INADDR_ANY;
+ s = socket(AF_INET, SOCK_STREAM, 0);
+ if (s < 0)
+ return (-1);
+ for (;;) {
+ sin.sin_port = htons((u_short)*alport);
+ if (bind(s, (caddr_t)&sin, sizeof (sin)) >= 0)
+ return (s);
+ if (errno != EADDRINUSE) {
+ (void) close(s);
+ return (-1);
+ }
+ (*alport)--;
+ if (*alport == IPPORT_RESERVED/2) {
+ (void) close(s);
+ errno = EAGAIN; /* close */
+ return (-1);
+ }
+ }
+}
+
+ruserok(rhost, superuser, ruser, luser)
+ char *rhost;
+ int superuser;
+ char *ruser, *luser;
+{
+ FILE *hostf;
+ char fhost[MAXHOSTNAMELEN];
+ int first = 1;
+ register char *sp, *p;
+ int baselen = -1;
+
+ sp = rhost;
+ p = fhost;
+ while (*sp) {
+ if (*sp == '.') {
+ if (baselen == -1)
+ baselen = sp - rhost;
+ *p++ = *sp++;
+ } else {
+ *p++ = isupper(*sp) ? tolower(*sp++) : *sp++;
+ }
+ }
+ *p = '\0';
+ hostf = superuser ? (FILE *)0 : fopen("/etc/hosts.equiv", "r");
+again:
+ if (hostf) {
+ if (!_validuser(hostf, fhost, luser, ruser, baselen)) {
+ (void) fclose(hostf);
+ return(0);
+ }
+ (void) fclose(hostf);
+ }
+ if (first == 1) {
+ struct stat sbuf;
+ struct passwd *pwd;
+ char pbuf[MAXPATHLEN];
+
+ first = 0;
+ if ((pwd = getpwnam(luser)) == NULL)
+ return(-1);
+ (void)strcpy(pbuf, pwd->pw_dir);
+ (void)strcat(pbuf, "/.rhosts");
+ if ((hostf = fopen(pbuf, "r")) == NULL)
+ return(-1);
+ (void)fstat(fileno(hostf), &sbuf);
+ if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) {
+ fclose(hostf);
+ return(-1);
+ }
+ goto again;
+ }
+ return (-1);
+}
+
+_validuser(hostf, rhost, luser, ruser, baselen)
+char *rhost, *luser, *ruser;
+FILE *hostf;
+int baselen;
+{
+ char *user;
+ char ahost[MAXHOSTNAMELEN];
+ register char *p;
+
+ while (fgets(ahost, sizeof (ahost), hostf)) {
+ p = ahost;
+ while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') {
+ *p = isupper(*p) ? tolower(*p) : *p;
+ p++;
+ }
+ if (*p == ' ' || *p == '\t') {
+ *p++ = '\0';
+ while (*p == ' ' || *p == '\t')
+ p++;
+ user = p;
+ while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0')
+ p++;
+ } else
+ user = p;
+ *p = '\0';
+ if (_checkhost(rhost, ahost, baselen) &&
+ !strcmp(ruser, *user ? user : luser)) {
+ return (0);
+ }
+ }
+ return (-1);
+}
+
+_checkhost(rhost, lhost, len)
+char *rhost, *lhost;
+int len;
+{
+ static char ldomain[MAXHOSTNAMELEN + 1];
+ static char *domainp = NULL;
+ register char *cp;
+
+ if (len == -1)
+ return(!strcmp(rhost, lhost));
+ if (strncmp(rhost, lhost, len))
+ return(0);
+ if (!strcmp(rhost, lhost))
+ return(1);
+ if (*(lhost + len) != '\0')
+ return(0);
+ if (!domainp) {
+ if (gethostname(ldomain, sizeof(ldomain)) == -1) {
+ domainp = (char *)1;
+ return(0);
+ }
+ ldomain[MAXHOSTNAMELEN] = NULL;
+ if ((domainp = index(ldomain, '.') + 1) == (char *)1)
+ return(0);
+ cp = domainp;
+ while (*cp) {
+ *cp = isupper(*cp) ? tolower(*cp) : *cp;
+ cp++;
+ }
+ }
+ if (domainp == (char *)1)
+ return(0);
+ return(!strcmp(domainp, rhost + len +1));
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)res_comp.c 6.7 (Berkeley) 3/11/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <arpa/nameser.h>
+
+
+/*
+ * Expand compressed domain name 'comp_dn' to full domain name.
+ * 'msg' is a pointer to the begining of the message,
+ * 'eomorig' points to the first location after the message,
+ * 'exp_dn' is a pointer to a buffer of size 'length' for the result.
+ * Return size of compressed name or -1 if there was an error.
+ */
+dn_expand(msg, eomorig, comp_dn, exp_dn, length)
+ char *msg, *eomorig, *comp_dn, *exp_dn;
+ int length;
+{
+ register char *cp, *dn;
+ register int n, c;
+ char *eom;
+ int len = -1;
+
+ dn = exp_dn;
+ cp = comp_dn;
+ eom = exp_dn + length - 1;
+ /*
+ * fetch next label in domain name
+ */
+ while (n = *cp++) {
+ /*
+ * Check for indirection
+ */
+ switch (n & INDIR_MASK) {
+ case 0:
+ if (dn != exp_dn) {
+ if (dn >= eom)
+ return (-1);
+ *dn++ = '.';
+ }
+ if (dn+n >= eom)
+ return (-1);
+ while (--n >= 0) {
+ if ((c = *cp++) == '.') {
+ if (dn+n+1 >= eom)
+ return (-1);
+ *dn++ = '\\';
+ }
+ *dn++ = c;
+ if (cp >= eomorig) /* out of range */
+ return(-1);
+ }
+ break;
+
+ case INDIR_MASK:
+ if (len < 0)
+ len = cp - comp_dn + 1;
+ cp = msg + (((n & 0x3f) << 8) | (*cp & 0xff));
+ if (cp < msg || cp >= eomorig) /* out of range */
+ return(-1);
+ break;
+
+ default:
+ return (-1); /* flag error */
+ }
+ }
+ *dn = '\0';
+ if (len < 0)
+ len = cp - comp_dn;
+ return (len);
+}
+
+/*
+ * Compress domain name 'exp_dn' into 'comp_dn'.
+ * Return the size of the compressed name or -1.
+ * 'length' is the size of the array pointed to by 'comp_dn'.
+ * 'dnptrs' is a list of pointers to previous compressed names. dnptrs[0]
+ * is a pointer to the beginning of the message. The list ends with NULL.
+ * 'lastdnptr' is a pointer to the end of the arrary pointed to
+ * by 'dnptrs'. Side effect is to update the list of pointers for
+ * labels inserted into the message as we compress the name.
+ * If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr'
+ * is NULL, we don't update the list.
+ */
+dn_comp(exp_dn, comp_dn, length, dnptrs, lastdnptr)
+ char *exp_dn, *comp_dn;
+ int length;
+ char **dnptrs, **lastdnptr;
+{
+ register char *cp, *dn;
+ register int c, l;
+ char **cpp, **lpp, *sp, *eob;
+ char *msg;
+
+ dn = exp_dn;
+ cp = comp_dn;
+ eob = cp + length;
+ if (dnptrs != NULL) {
+ if ((msg = *dnptrs++) != NULL) {
+ for (cpp = dnptrs; *cpp != NULL; cpp++)
+ ;
+ lpp = cpp; /* end of list to search */
+ }
+ } else
+ msg = NULL;
+ for (c = *dn++; c != '\0'; ) {
+ /* look to see if we can use pointers */
+ if (msg != NULL) {
+ if ((l = dn_find(dn-1, msg, dnptrs, lpp)) >= 0) {
+ if (cp+1 >= eob)
+ return (-1);
+ *cp++ = (l >> 8) | INDIR_MASK;
+ *cp++ = l % 256;
+ return (cp - comp_dn);
+ }
+ /* not found, save it */
+ if (lastdnptr != NULL && cpp < lastdnptr-1) {
+ *cpp++ = cp;
+ *cpp = NULL;
+ }
+ }
+ sp = cp++; /* save ptr to length byte */
+ do {
+ if (c == '.') {
+ c = *dn++;
+ break;
+ }
+ if (c == '\\') {
+ if ((c = *dn++) == '\0')
+ break;
+ }
+ if (cp >= eob)
+ return (-1);
+ *cp++ = c;
+ } while ((c = *dn++) != '\0');
+ /* catch trailing '.'s but not '..' */
+ if ((l = cp - sp - 1) == 0 && c == '\0') {
+ cp--;
+ break;
+ }
+ if (l <= 0 || l > MAXLABEL)
+ return (-1);
+ *sp = l;
+ }
+ if (cp >= eob)
+ return (-1);
+ *cp++ = '\0';
+ return (cp - comp_dn);
+}
+
+/*
+ * Skip over a compressed domain name. Return the size or -1.
+ */
+dn_skip(comp_dn)
+ char *comp_dn;
+{
+ register char *cp;
+ register int n;
+
+ cp = comp_dn;
+ while (n = *cp++) {
+ /*
+ * check for indirection
+ */
+ switch (n & INDIR_MASK) {
+ case 0: /* normal case, n == len */
+ cp += n;
+ continue;
+ default: /* illegal type */
+ return (-1);
+ case INDIR_MASK: /* indirection */
+ cp++;
+ }
+ break;
+ }
+ return (cp - comp_dn);
+}
+
+/*
+ * Search for expanded name from a list of previously compressed names.
+ * Return the offset from msg if found or -1.
+ */
+dn_find(exp_dn, msg, dnptrs, lastdnptr)
+ char *exp_dn, *msg;
+ char **dnptrs, **lastdnptr;
+{
+ register char *dn, *cp, **cpp;
+ register int n;
+ char *sp;
+
+ for (cpp = dnptrs + 1; cpp < lastdnptr; cpp++) {
+ dn = exp_dn;
+ sp = cp = *cpp;
+ while (n = *cp++) {
+ /*
+ * check for indirection
+ */
+ switch (n & INDIR_MASK) {
+ case 0: /* normal case, n == len */
+ while (--n >= 0) {
+ if (*dn == '\\')
+ dn++;
+ if (*dn++ != *cp++)
+ goto next;
+ }
+ if ((n = *dn++) == '\0' && *cp == '\0')
+ return (sp - msg);
+ if (n == '.')
+ continue;
+ goto next;
+
+ default: /* illegal type */
+ return (-1);
+
+ case INDIR_MASK: /* indirection */
+ cp = msg + (((n & 0x3f) << 8) | (*cp & 0xff));
+ }
+ }
+ if (*dn == '\0')
+ return (sp - msg);
+ next: ;
+ }
+ return (-1);
+}
+
+/*
+ * Routines to insert/extract short/long's. Must account for byte
+ * order and non-alignment problems. This code at least has the
+ * advantage of being portable.
+ */
+
+u_short
+getshort(msgp)
+ char *msgp;
+{
+ register u_char *p = (u_char *) msgp;
+#ifdef vax
+ /*
+ * vax compiler doesn't put shorts in registers
+ */
+ register u_long u;
+#else
+ register u_short u;
+#endif
+
+ u = *p++ << 8;
+ return ((u_short)(u | *p));
+}
+
+u_long
+getlong(msgp)
+ char *msgp;
+{
+ register u_char *p = (u_char *) msgp;
+ register u_long u;
+
+ u = *p++; u <<= 8;
+ u |= *p++; u <<= 8;
+ u |= *p++; u <<= 8;
+ return (u | *p);
+}
+
+
+putshort(s, msgp)
+ register u_short s;
+ register char *msgp;
+{
+
+ msgp[1] = s;
+ msgp[0] = s >> 8;
+}
+
+putlong(l, msgp)
+ register u_long l;
+ register char *msgp;
+{
+
+ msgp[3] = l;
+ msgp[2] = (l >>= 8);
+ msgp[1] = (l >>= 8);
+ msgp[0] = l >> 8;
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)res_debug.c 5.13 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#if defined(lint) && !defined(DEBUG)
+#define DEBUG
+#endif
+
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <arpa/nameser.h>
+
+extern char *p_cdname(), *p_rr(), *p_type(), *p_class();
+extern char *inet_ntoa();
+
+char *opcodes[] = {
+ "QUERY",
+ "IQUERY",
+ "CQUERYM",
+ "CQUERYU",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "UPDATEA",
+ "UPDATED",
+ "UPDATEM",
+ "ZONEINIT",
+ "ZONEREF",
+};
+
+char *rcodes[] = {
+ "NOERROR",
+ "FORMERR",
+ "SERVFAIL",
+ "NXDOMAIN",
+ "NOTIMP",
+ "REFUSED",
+ "6",
+ "7",
+ "8",
+ "9",
+ "10",
+ "11",
+ "12",
+ "13",
+ "14",
+ "NOCHANGE",
+};
+
+p_query(msg)
+ char *msg;
+{
+#ifdef DEBUG
+ fp_query(msg,stdout);
+#endif
+}
+
+/*
+ * Print the contents of a query.
+ * This is intended to be primarily a debugging routine.
+ */
+fp_query(msg,file)
+ char *msg;
+ FILE *file;
+{
+#ifdef DEBUG
+ register char *cp;
+ register HEADER *hp;
+ register int n;
+
+ /*
+ * Print header fields.
+ */
+ hp = (HEADER *)msg;
+ cp = msg + sizeof(HEADER);
+ fprintf(file,"HEADER:\n");
+ fprintf(file,"\topcode = %s", opcodes[hp->opcode]);
+ fprintf(file,", id = %d", ntohs(hp->id));
+ fprintf(file,", rcode = %s\n", rcodes[hp->rcode]);
+ fprintf(file,"\theader flags: ");
+ if (hp->qr)
+ fprintf(file," qr");
+ if (hp->aa)
+ fprintf(file," aa");
+ if (hp->tc)
+ fprintf(file," tc");
+ if (hp->rd)
+ fprintf(file," rd");
+ if (hp->ra)
+ fprintf(file," ra");
+ if (hp->pr)
+ fprintf(file," pr");
+ fprintf(file,"\n\tqdcount = %d", ntohs(hp->qdcount));
+ fprintf(file,", ancount = %d", ntohs(hp->ancount));
+ fprintf(file,", nscount = %d", ntohs(hp->nscount));
+ fprintf(file,", arcount = %d\n\n", ntohs(hp->arcount));
+ /*
+ * Print question records.
+ */
+ if (n = ntohs(hp->qdcount)) {
+ fprintf(file,"QUESTIONS:\n");
+ while (--n >= 0) {
+ fprintf(file,"\t");
+ cp = p_cdname(cp, msg, file);
+ if (cp == NULL)
+ return;
+ fprintf(file,", type = %s", p_type(getshort(cp)));
+ cp += sizeof(u_short);
+ fprintf(file,", class = %s\n\n", p_class(getshort(cp)));
+ cp += sizeof(u_short);
+ }
+ }
+ /*
+ * Print authoritative answer records
+ */
+ if (n = ntohs(hp->ancount)) {
+ fprintf(file,"ANSWERS:\n");
+ while (--n >= 0) {
+ fprintf(file,"\t");
+ cp = p_rr(cp, msg, file);
+ if (cp == NULL)
+ return;
+ }
+ }
+ /*
+ * print name server records
+ */
+ if (n = ntohs(hp->nscount)) {
+ fprintf(file,"NAME SERVERS:\n");
+ while (--n >= 0) {
+ fprintf(file,"\t");
+ cp = p_rr(cp, msg, file);
+ if (cp == NULL)
+ return;
+ }
+ }
+ /*
+ * print additional records
+ */
+ if (n = ntohs(hp->arcount)) {
+ fprintf(file,"ADDITIONAL RECORDS:\n");
+ while (--n >= 0) {
+ fprintf(file,"\t");
+ cp = p_rr(cp, msg, file);
+ if (cp == NULL)
+ return;
+ }
+ }
+#endif
+}
+
+char *
+p_cdname(cp, msg, file)
+ char *cp, *msg;
+ FILE *file;
+{
+#ifdef DEBUG
+ char name[MAXDNAME];
+ int n;
+
+ if ((n = dn_expand(msg, msg + 512, cp, name, sizeof(name))) < 0)
+ return (NULL);
+ if (name[0] == '\0') {
+ name[0] = '.';
+ name[1] = '\0';
+ }
+ fputs(name, file);
+ return (cp + n);
+#endif
+}
+
+/*
+ * Print resource record fields in human readable form.
+ */
+char *
+p_rr(cp, msg, file)
+ char *cp, *msg;
+ FILE *file;
+{
+#ifdef DEBUG
+ int type, class, dlen, n, c;
+ struct in_addr inaddr;
+ char *cp1;
+
+ if ((cp = p_cdname(cp, msg, file)) == NULL)
+ return (NULL); /* compression error */
+ fprintf(file,"\n\ttype = %s", p_type(type = getshort(cp)));
+ cp += sizeof(u_short);
+ fprintf(file,", class = %s", p_class(class = getshort(cp)));
+ cp += sizeof(u_short);
+ fprintf(file,", ttl = %u", getlong(cp));
+ cp += sizeof(u_long);
+ fprintf(file,", dlen = %d\n", dlen = getshort(cp));
+ cp += sizeof(u_short);
+ cp1 = cp;
+ /*
+ * Print type specific data, if appropriate
+ */
+ switch (type) {
+ case T_A:
+ switch (class) {
+ case C_IN:
+ bcopy(cp, (char *)&inaddr, sizeof(inaddr));
+ if (dlen == 4) {
+ fprintf(file,"\tinternet address = %s\n",
+ inet_ntoa(inaddr));
+ cp += dlen;
+ } else if (dlen == 7) {
+ fprintf(file,"\tinternet address = %s",
+ inet_ntoa(inaddr));
+ fprintf(file,", protocol = %d", cp[4]);
+ fprintf(file,", port = %d\n",
+ (cp[5] << 8) + cp[6]);
+ cp += dlen;
+ }
+ break;
+ }
+ break;
+ case T_CNAME:
+ case T_MB:
+#ifdef OLDRR
+ case T_MD:
+ case T_MF:
+#endif /* OLDRR */
+ case T_MG:
+ case T_MR:
+ case T_NS:
+ case T_PTR:
+ fprintf(file,"\tdomain name = ");
+ cp = p_cdname(cp, msg, file);
+ fprintf(file,"\n");
+ break;
+
+ case T_HINFO:
+ if (n = *cp++) {
+ fprintf(file,"\tCPU=%.*s\n", n, cp);
+ cp += n;
+ }
+ if (n = *cp++) {
+ fprintf(file,"\tOS=%.*s\n", n, cp);
+ cp += n;
+ }
+ break;
+
+ case T_SOA:
+ fprintf(file,"\torigin = ");
+ cp = p_cdname(cp, msg, file);
+ fprintf(file,"\n\tmail addr = ");
+ cp = p_cdname(cp, msg, file);
+ fprintf(file,"\n\tserial=%ld", getlong(cp));
+ cp += sizeof(u_long);
+ fprintf(file,", refresh=%ld", getlong(cp));
+ cp += sizeof(u_long);
+ fprintf(file,", retry=%ld", getlong(cp));
+ cp += sizeof(u_long);
+ fprintf(file,", expire=%ld", getlong(cp));
+ cp += sizeof(u_long);
+ fprintf(file,", min=%ld\n", getlong(cp));
+ cp += sizeof(u_long);
+ break;
+
+ case T_MX:
+ fprintf(file,"\tpreference = %ld,",getshort(cp));
+ cp += sizeof(u_short);
+ fprintf(file," name = ");
+ cp = p_cdname(cp, msg, file);
+ break;
+
+ case T_MINFO:
+ fprintf(file,"\trequests = ");
+ cp = p_cdname(cp, msg, file);
+ fprintf(file,"\n\terrors = ");
+ cp = p_cdname(cp, msg, file);
+ break;
+
+ case T_UINFO:
+ fprintf(file,"\t%s\n", cp);
+ cp += dlen;
+ break;
+
+ case T_UID:
+ case T_GID:
+ if (dlen == 4) {
+ fprintf(file,"\t%ld\n", getlong(cp));
+ cp += sizeof(int);
+ }
+ break;
+
+ case T_WKS:
+ if (dlen < sizeof(u_long) + 1)
+ break;
+ bcopy(cp, (char *)&inaddr, sizeof(inaddr));
+ cp += sizeof(u_long);
+ fprintf(file,"\tinternet address = %s, protocol = %d\n\t",
+ inet_ntoa(inaddr), *cp++);
+ n = 0;
+ while (cp < cp1 + dlen) {
+ c = *cp++;
+ do {
+ if (c & 0200)
+ fprintf(file," %d", n);
+ c <<= 1;
+ } while (++n & 07);
+ }
+ putc('\n',file);
+ break;
+
+ default:
+ fprintf(file,"\t???\n");
+ cp += dlen;
+ }
+ if (cp != cp1 + dlen)
+ fprintf(file,"packet size error (%#x != %#x)\n", cp, cp1+dlen);
+ fprintf(file,"\n");
+ return (cp);
+#endif
+}
+
+static char nbuf[20];
+extern char *sprintf();
+
+/*
+ * Return a string for the type
+ */
+char *
+p_type(type)
+ int type;
+{
+ switch (type) {
+ case T_A:
+ return("A");
+ case T_NS: /* authoritative server */
+ return("NS");
+#ifdef OLDRR
+ case T_MD: /* mail destination */
+ return("MD");
+ case T_MF: /* mail forwarder */
+ return("MF");
+#endif /* OLDRR */
+ case T_CNAME: /* connonical name */
+ return("CNAME");
+ case T_SOA: /* start of authority zone */
+ return("SOA");
+ case T_MB: /* mailbox domain name */
+ return("MB");
+ case T_MG: /* mail group member */
+ return("MG");
+ case T_MX: /* mail routing info */
+ return("MX");
+ case T_MR: /* mail rename name */
+ return("MR");
+ case T_NULL: /* null resource record */
+ return("NULL");
+ case T_WKS: /* well known service */
+ return("WKS");
+ case T_PTR: /* domain name pointer */
+ return("PTR");
+ case T_HINFO: /* host information */
+ return("HINFO");
+ case T_MINFO: /* mailbox information */
+ return("MINFO");
+ case T_AXFR: /* zone transfer */
+ return("AXFR");
+ case T_MAILB: /* mail box */
+ return("MAILB");
+ case T_MAILA: /* mail address */
+ return("MAILA");
+ case T_ANY: /* matches any type */
+ return("ANY");
+ case T_UINFO:
+ return("UINFO");
+ case T_UID:
+ return("UID");
+ case T_GID:
+ return("GID");
+ default:
+ return (sprintf(nbuf, "%d", type));
+ }
+}
+
+/*
+ * Return a mnemonic for class
+ */
+char *
+p_class(class)
+ int class;
+{
+
+ switch (class) {
+ case C_IN: /* internet class */
+ return("IN");
+ case C_ANY: /* matches any class */
+ return("ANY");
+ default:
+ return (sprintf(nbuf, "%d", class));
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)res_init.c 6.5 (Berkeley) 4/11/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+
+/*
+ * Resolver configuration file. Contains the address of the
+ * inital name server to query and the default domain for
+ * non fully qualified domain names.
+ */
+
+#ifdef CONFFILE
+char *conffile = CONFFILE;
+#else
+char *conffile = "/etc/resolv.conf";
+#endif
+
+/*
+ * Resolver state default settings
+ */
+
+#ifndef RES_TIMEOUT
+#define RES_TIMEOUT 4
+#endif
+
+struct state _res = {
+ RES_TIMEOUT, /* retransmition time interval */
+ 4, /* number of times to retransmit */
+ RES_RECURSE|RES_DEFNAMES, /* options flags */
+ 1, /* number of name servers */
+};
+
+/*
+ * Set up default settings. If the configuration file exist, the values
+ * there will have precedence. Otherwise, the server address is set to
+ * INADDR_ANY and the default domain name comes from the gethostname().
+ *
+ * The configuration file should only be used if you want to redefine your
+ * domain or run without a server on your machine.
+ *
+ * Return 0 if completes successfully, -1 on error
+ */
+res_init()
+{
+ register FILE *fp;
+ char buf[BUFSIZ], *cp;
+ extern u_long inet_addr();
+ extern char *index();
+ extern char *strcpy(), *strncpy();
+#ifdef DEBUG
+ extern char *getenv();
+#endif DEBUG
+ int n = 0; /* number of nameserver records read from file */
+
+ _res.nsaddr.sin_addr.s_addr = INADDR_ANY;
+ _res.nsaddr.sin_family = AF_INET;
+ _res.nsaddr.sin_port = htons(NAMESERVER_PORT);
+ _res.nscount = 1;
+ _res.defdname[0] = '\0';
+
+ if ((fp = fopen(conffile, "r")) != NULL) {
+ /* read the config file */
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ /* read default domain name */
+ if (!strncmp(buf, "domain", sizeof("domain") - 1)) {
+ cp = buf + sizeof("domain") - 1;
+ while (*cp == ' ' || *cp == '\t')
+ cp++;
+ if (*cp == '\0')
+ continue;
+ (void)strncpy(_res.defdname, cp, sizeof(_res.defdname));
+ _res.defdname[sizeof(_res.defdname) - 1] = '\0';
+ if ((cp = index(_res.defdname, '\n')) != NULL)
+ *cp = '\0';
+ continue;
+ }
+ /* read nameservers to query */
+ if (!strncmp(buf, "nameserver",
+ sizeof("nameserver") - 1) && (n < MAXNS)) {
+ cp = buf + sizeof("nameserver") - 1;
+ while (*cp == ' ' || *cp == '\t')
+ cp++;
+ if (*cp == '\0')
+ continue;
+ _res.nsaddr_list[n].sin_addr.s_addr = inet_addr(cp);
+ if (_res.nsaddr_list[n].sin_addr.s_addr == (unsigned)-1)
+ _res.nsaddr_list[n].sin_addr.s_addr = INADDR_ANY;
+ _res.nsaddr_list[n].sin_family = AF_INET;
+ _res.nsaddr_list[n].sin_port = htons(NAMESERVER_PORT);
+ if ( ++n >= MAXNS) {
+ n = MAXNS;
+#ifdef DEBUG
+ if ( _res.options & RES_DEBUG )
+ printf("MAXNS reached, reading resolv.conf\n");
+#endif DEBUG
+ }
+ continue;
+ }
+ }
+ if ( n > 1 )
+ _res.nscount = n;
+ (void) fclose(fp);
+ }
+ if (_res.defdname[0] == 0) {
+ if (gethostname(buf, sizeof(_res.defdname)) == 0 &&
+ (cp = index(buf, '.')))
+ (void)strcpy(_res.defdname, cp + 1);
+ }
+
+#ifdef DEBUG
+ /* Allow user to override the local domain definition */
+ if ((cp = getenv("LOCALDOMAIN")) != NULL)
+ (void)strncpy(_res.defdname, cp, sizeof(_res.defdname));
+#endif DEBUG
+ _res.options |= RES_INIT;
+ return(0);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)res_mkquery.c 6.3 (Berkeley) 3/17/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+
+extern char *sprintf();
+
+/*
+ * Form all types of queries.
+ * Returns the size of the result or -1.
+ */
+res_mkquery(op, dname, class, type, data, datalen, newrr, buf, buflen)
+ int op; /* opcode of query */
+ char *dname; /* domain name */
+ int class, type; /* class and type of query */
+ char *data; /* resource record data */
+ int datalen; /* length of data */
+ struct rrec *newrr; /* new rr for modify or append */
+ char *buf; /* buffer to put query */
+ int buflen; /* size of buffer */
+{
+ register HEADER *hp;
+ register char *cp;
+ register int n;
+ char dnbuf[MAXDNAME];
+ char *dnptrs[10], **dpp, **lastdnptr;
+ extern char *index();
+
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ printf("res_mkquery(%d, %s, %d, %d)\n", op, dname, class, type);
+#endif DEBUG
+ /*
+ * Initialize header fields.
+ */
+ hp = (HEADER *) buf;
+ hp->id = htons(++_res.id);
+ hp->opcode = op;
+ hp->qr = hp->aa = hp->tc = hp->ra = 0;
+ hp->pr = (_res.options & RES_PRIMARY) != 0;
+ hp->rd = (_res.options & RES_RECURSE) != 0;
+ hp->rcode = NOERROR;
+ hp->qdcount = 0;
+ hp->ancount = 0;
+ hp->nscount = 0;
+ hp->arcount = 0;
+ cp = buf + sizeof(HEADER);
+ buflen -= sizeof(HEADER);
+ dpp = dnptrs;
+ *dpp++ = buf;
+ *dpp++ = NULL;
+ lastdnptr = dnptrs + sizeof(dnptrs)/sizeof(dnptrs[0]);
+ /*
+ * If the domain name contains no dots (single label), then
+ * append the default domain name to the one given.
+ */
+ if ((_res.options & RES_DEFNAMES) && dname != 0 && dname[0] != '\0' &&
+ index(dname, '.') == NULL) {
+ if (!(_res.options & RES_INIT))
+ if (res_init() == -1)
+ return(-1);
+ if (_res.defdname[0] != '\0')
+ dname = sprintf(dnbuf, "%s.%s", dname, _res.defdname);
+ }
+ /*
+ * perform opcode specific processing
+ */
+ switch (op) {
+ case QUERY:
+ case CQUERYM:
+ case CQUERYU:
+ buflen -= QFIXEDSZ;
+ if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
+ return (-1);
+ cp += n;
+ buflen -= n;
+ putshort(type, cp);
+ cp += sizeof(u_short);
+ putshort(class, cp);
+ cp += sizeof(u_short);
+ hp->qdcount = htons(1);
+ if (op == QUERY || data == NULL)
+ break;
+ /*
+ * Make an additional record for completion domain.
+ */
+ buflen -= RRFIXEDSZ;
+ if ((n = dn_comp(data, cp, buflen, dnptrs, lastdnptr)) < 0)
+ return (-1);
+ cp += n;
+ buflen -= n;
+ putshort(T_NULL, cp);
+ cp += sizeof(u_short);
+ putshort(class, cp);
+ cp += sizeof(u_short);
+ putlong(0, cp);
+ cp += sizeof(u_long);
+ putshort(0, cp);
+ cp += sizeof(u_short);
+ hp->arcount = htons(1);
+ break;
+
+ case IQUERY:
+ /*
+ * Initialize answer section
+ */
+ if (buflen < 1 + RRFIXEDSZ + datalen)
+ return (-1);
+ *cp++ = '\0'; /* no domain name */
+ putshort(type, cp);
+ cp += sizeof(u_short);
+ putshort(class, cp);
+ cp += sizeof(u_short);
+ putlong(0, cp);
+ cp += sizeof(u_long);
+ putshort(datalen, cp);
+ cp += sizeof(u_short);
+ if (datalen) {
+ bcopy(data, cp, datalen);
+ cp += datalen;
+ }
+ hp->ancount = htons(1);
+ break;
+
+#ifdef notdef
+ case UPDATED:
+ /*
+ * Put record to be added or deleted in additional section
+ */
+ buflen -= RRFIXEDSZ + datalen;
+ if ((n = dn_comp(dname, cp, buflen, NULL, NULL)) < 0)
+ return (-1);
+ cp += n;
+ *((u_short *)cp) = htons(type);
+ cp += sizeof(u_short);
+ *((u_short *)cp) = htons(class);
+ cp += sizeof(u_short);
+ *((u_long *)cp) = 0;
+ cp += sizeof(u_long);
+ *((u_short *)cp) = htons(datalen);
+ cp += sizeof(u_short);
+ if (datalen) {
+ bcopy(data, cp, datalen);
+ cp += datalen;
+ }
+ break;
+
+ case UPDATEM:
+ /*
+ * Record to be modified followed by its replacement
+ */
+ buflen -= RRFIXEDSZ + datalen;
+ if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
+ return (-1);
+ cp += n;
+ *((u_short *)cp) = htons(type);
+ cp += sizeof(u_short);
+ *((u_short *)cp) = htons(class);
+ cp += sizeof(u_short);
+ *((u_long *)cp) = 0;
+ cp += sizeof(u_long);
+ *((u_short *)cp) = htons(datalen);
+ cp += sizeof(u_short);
+ if (datalen) {
+ bcopy(data, cp, datalen);
+ cp += datalen;
+ }
+
+ case UPDATEA:
+ buflen -= RRFIXEDSZ + newrr->r_size;
+ if ((n = dn_comp(dname, cp, buflen, dnptrs, lastdnptr)) < 0)
+ return (-1);
+ cp += n;
+ *((u_short *)cp) = htons(newrr->r_type);
+ cp += sizeof(u_short);
+ *((u_short *)cp) = htons(newrr->r_type);
+ cp += sizeof(u_short);
+ *((u_long *)cp) = htonl(newrr->r_ttl);
+ cp += sizeof(u_long);
+ *((u_short *)cp) = htons(newrr->r_size);
+ cp += sizeof(u_short);
+ if (newrr->r_size) {
+ bcopy(newrr->r_data, cp, newrr->r_size);
+ cp += newrr->r_size;
+ }
+ break;
+#endif
+ }
+ return (cp - buf);
+}
--- /dev/null
+
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)res_send.c 6.14 (Berkeley) 7/2/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Send query to name server and wait for reply.
+ */
+
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <errno.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+
+extern int errno;
+
+static int s = -1; /* socket used for communications */
+
+#define KEEPOPEN (RES_USEVC|RES_STAYOPEN)
+
+res_send(buf, buflen, answer, anslen)
+ char *buf;
+ int buflen;
+ char *answer;
+ int anslen;
+{
+ register int n;
+ int retry, v_circuit, resplen, ns;
+ int gotsomewhere = 0;
+ u_short id, len;
+ char *cp;
+ fd_set dsmask;
+ struct timeval timeout;
+ HEADER *hp = (HEADER *) buf;
+ HEADER *anhp = (HEADER *) answer;
+ struct iovec iov[2];
+ int terrno = ETIMEDOUT;
+
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG) {
+ printf("res_send()\n");
+ p_query(buf);
+ }
+#endif DEBUG
+ if (!(_res.options & RES_INIT))
+ if (res_init() == -1) {
+ return(-1);
+ }
+ v_circuit = (_res.options & RES_USEVC) || buflen > PACKETSZ;
+ id = hp->id;
+ /*
+ * Send request, RETRY times, or until successful
+ */
+ for (retry = _res.retry; retry > 0; retry--) {
+ for (ns = 0; ns < _res.nscount; ns++) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ printf("Querying server (# %d) address = %s\n", ns+1,
+ inet_ntoa(_res.nsaddr_list[ns].sin_addr.s_addr));
+#endif DEBUG
+ if (v_circuit) {
+ /*
+ * Use virtual circuit.
+ */
+ if (s < 0) {
+ s = socket(AF_INET, SOCK_STREAM, 0);
+ if (s < 0) {
+ terrno = errno;
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ perror("socket failed");
+#endif DEBUG
+ continue;
+ }
+ if (connect(s, &(_res.nsaddr_list[ns]),
+ sizeof(struct sockaddr)) < 0) {
+ terrno = errno;
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ perror("connect failed");
+#endif DEBUG
+ (void) close(s);
+ s = -1;
+ continue;
+ }
+ }
+ /*
+ * Send length & message
+ */
+ len = htons((u_short)buflen);
+ iov[0].iov_base = (caddr_t)&len;
+ iov[0].iov_len = sizeof(len);
+ iov[1].iov_base = buf;
+ iov[1].iov_len = buflen;
+ if (writev(s, iov, 2) != sizeof(len) + buflen) {
+ terrno = errno;
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ perror("write failed");
+#endif DEBUG
+ (void) close(s);
+ s = -1;
+ continue;
+ }
+ /*
+ * Receive length & response
+ */
+ cp = answer;
+ len = sizeof(short);
+ while (len != 0 &&
+ (n = read(s, (char *)cp, (int)len)) > 0) {
+ cp += n;
+ len -= n;
+ }
+ if (n <= 0) {
+ terrno = errno;
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ perror("read failed");
+#endif DEBUG
+ (void) close(s);
+ s = -1;
+ continue;
+ }
+ cp = answer;
+ resplen = len = ntohs(*(u_short *)cp);
+ while (len != 0 &&
+ (n = read(s, (char *)cp, (int)len)) > 0) {
+ cp += n;
+ len -= n;
+ }
+ if (n <= 0) {
+ terrno = errno;
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ perror("read failed");
+#endif DEBUG
+ (void) close(s);
+ s = -1;
+ continue;
+ }
+ } else {
+ /*
+ * Use datagrams.
+ */
+ if (s < 0)
+ s = socket(AF_INET, SOCK_DGRAM, 0);
+#if BSD >= 43
+ if (connect(s, &_res.nsaddr_list[ns],
+ sizeof(struct sockaddr)) < 0 ||
+ send(s, buf, buflen, 0) != buflen) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ perror("connect");
+#endif DEBUG
+ continue;
+ }
+#else BSD
+ if (sendto(s, buf, buflen, 0, &_res.nsaddr_list[ns],
+ sizeof(struct sockaddr)) != buflen) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ perror("sendto");
+#endif DEBUG
+ continue;
+ }
+#endif BSD
+ /*
+ * Wait for reply
+ */
+ timeout.tv_sec = (_res.retrans << (_res.retry - retry))
+ / _res.nscount;
+ if (timeout.tv_sec <= 0)
+ timeout.tv_sec = 1;
+ timeout.tv_usec = 0;
+wait:
+ FD_ZERO(&dsmask);
+ FD_SET(s, &dsmask);
+ n = select(s+1, &dsmask, (fd_set *)NULL,
+ (fd_set *)NULL, &timeout);
+ if (n < 0) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ perror("select");
+#endif DEBUG
+ continue;
+ }
+ if (n == 0) {
+ /*
+ * timeout
+ */
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ printf("timeout\n");
+#endif DEBUG
+ gotsomewhere = 1;
+ continue;
+ }
+ if ((resplen = recv(s, answer, anslen, 0)) <= 0) {
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ perror("recvfrom");
+#endif DEBUG
+ continue;
+ }
+ gotsomewhere = 1;
+ if (id != anhp->id) {
+ /*
+ * response from old query, ignore it
+ */
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG) {
+ printf("old answer:\n");
+ p_query(answer);
+ }
+#endif DEBUG
+ goto wait;
+ }
+ if (!(_res.options & RES_IGNTC) && anhp->tc) {
+ /*
+ * get rest of answer
+ */
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG)
+ printf("truncated answer\n");
+#endif DEBUG
+ (void) close(s);
+ s = -1;
+ /*
+ * retry decremented on continue
+ * to desired starting value
+ */
+ retry = _res.retry + 1;
+ v_circuit = 1;
+ continue;
+ }
+ }
+#ifdef DEBUG
+ if (_res.options & RES_DEBUG) {
+ printf("got answer:\n");
+ p_query(answer);
+ }
+#endif DEBUG
+ /*
+ * We are going to assume that the first server is preferred
+ * over the rest (i.e. it is on the local machine) and only
+ * keep that one open.
+ */
+ if ((_res.options & KEEPOPEN) == KEEPOPEN && ns == 0) {
+ return (resplen);
+ } else {
+ (void) close(s);
+ s = -1;
+ return (resplen);
+ }
+ }
+ }
+ if (s >= 0) {
+ (void) close(s);
+ s = -1;
+ }
+ if (v_circuit == 0)
+ if (gotsomewhere == 0)
+ errno = ECONNREFUSED;
+ else
+ errno = ETIMEDOUT;
+ else
+ errno = terrno;
+ return (-1);
+}
+
+/*
+ * This routine is for closing the socket if a virtual circuit is used and
+ * the program wants to close it. This provides support for endhostent()
+ * which expects to close the socket.
+ *
+ * This routine is not expected to be user visible.
+ */
+_res_close()
+{
+ if (s != -1) {
+ (void) close(s);
+ s = -1;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rexec.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+#include <netinet/in.h>
+
+#include <stdio.h>
+#include <netdb.h>
+#include <errno.h>
+
+extern errno;
+char *index(), *sprintf();
+int rexecoptions;
+char *getpass(), *getlogin();
+
+rexec(ahost, rport, name, pass, cmd, fd2p)
+ char **ahost;
+ int rport;
+ char *name, *pass, *cmd;
+ int *fd2p;
+{
+ int s, timo = 1, s3;
+ struct sockaddr_in sin, sin2, from;
+ char c;
+ short port;
+ struct hostent *hp;
+
+ hp = gethostbyname(*ahost);
+ if (hp == 0) {
+ fprintf(stderr, "%s: unknown host\n", *ahost);
+ return (-1);
+ }
+ *ahost = hp->h_name;
+ ruserpass(hp->h_name, &name, &pass);
+retry:
+ s = socket(AF_INET, SOCK_STREAM, 0);
+ if (s < 0) {
+ perror("rexec: socket");
+ return (-1);
+ }
+ sin.sin_family = hp->h_addrtype;
+ sin.sin_port = rport;
+ bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length);
+ if (connect(s, &sin, sizeof(sin)) < 0) {
+ if (errno == ECONNREFUSED && timo <= 16) {
+ (void) close(s);
+ sleep(timo);
+ timo *= 2;
+ goto retry;
+ }
+ perror(hp->h_name);
+ return (-1);
+ }
+ if (fd2p == 0) {
+ (void) write(s, "", 1);
+ port = 0;
+ } else {
+ char num[8];
+ int s2, sin2len;
+
+ s2 = socket(AF_INET, SOCK_STREAM, 0);
+ if (s2 < 0) {
+ (void) close(s);
+ return (-1);
+ }
+ listen(s2, 1);
+ sin2len = sizeof (sin2);
+ if (getsockname(s2, (char *)&sin2, &sin2len) < 0 ||
+ sin2len != sizeof (sin2)) {
+ perror("getsockname");
+ (void) close(s2);
+ goto bad;
+ }
+ port = ntohs((u_short)sin2.sin_port);
+ (void) sprintf(num, "%d", port);
+ (void) write(s, num, strlen(num)+1);
+ { int len = sizeof (from);
+ s3 = accept(s2, &from, &len, 0);
+ close(s2);
+ if (s3 < 0) {
+ perror("accept");
+ port = 0;
+ goto bad;
+ }
+ }
+ *fd2p = s3;
+ }
+ (void) write(s, name, strlen(name) + 1);
+ /* should public key encypt the password here */
+ (void) write(s, pass, strlen(pass) + 1);
+ (void) write(s, cmd, strlen(cmd) + 1);
+ if (read(s, &c, 1) != 1) {
+ perror(*ahost);
+ goto bad;
+ }
+ if (c != 0) {
+ while (read(s, &c, 1) == 1) {
+ (void) write(2, &c, 1);
+ if (c == '\n')
+ break;
+ }
+ goto bad;
+ }
+ return (s);
+bad:
+ if (port)
+ (void) close(*fd2p);
+ (void) close(s);
+ return (-1);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ruserpass.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <utmp.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <errno.h>
+
+char *renvlook(), *malloc(), *index(), *getenv(), *getpass(), *getlogin();
+struct utmp *getutmp();
+static FILE *cfile;
+
+ruserpass(host, aname, apass)
+ char *host, **aname, **apass;
+{
+
+ renv(host, aname, apass);
+ if (*aname == 0 || *apass == 0)
+ rnetrc(host, aname, apass);
+ if (*aname == 0) {
+ char *myname = getlogin();
+ *aname = malloc(16);
+ printf("Name (%s:%s): ", host, myname);
+ fflush(stdout);
+ if (read(2, *aname, 16) <= 0)
+ exit(1);
+ if ((*aname)[0] == '\n')
+ *aname = myname;
+ else
+ if (index(*aname, '\n'))
+ *index(*aname, '\n') = 0;
+ }
+ if (*aname && *apass == 0) {
+ printf("Password (%s:%s): ", host, *aname);
+ fflush(stdout);
+ *apass = getpass("");
+ }
+}
+
+static
+renv(host, aname, apass)
+ char *host, **aname, **apass;
+{
+ register char *cp;
+ char *stemp, fgetlogin, *comma;
+
+ cp = renvlook(host);
+ if (cp == NULL)
+ return;
+ if (!isalpha(cp[0]))
+ return;
+ comma = index(cp, ',');
+ if (comma == 0)
+ return;
+ if (*aname == 0) {
+ *aname = malloc(comma - cp + 1);
+ strncpy(*aname, cp, comma - cp);
+ } else
+ if (strncmp(*aname, cp, comma - cp))
+ return;
+ comma++;
+ cp = malloc(strlen(comma)+1);
+ strcpy(cp, comma);
+ *apass = malloc(16);
+ mkpwclear(cp, host[0], *apass);
+}
+
+static
+char *
+renvlook(host)
+ char *host;
+{
+ register char *cp, **env;
+ extern char **environ;
+
+ env = environ;
+ for (env = environ; *env != NULL; env++)
+ if (!strncmp(*env, "MACH", 4)) {
+ cp = index(*env, '=');
+ if (cp == 0)
+ continue;
+ if (strncmp(*env+4, host, cp-(*env+4)))
+ continue;
+ return (cp+1);
+ }
+ return (NULL);
+}
+
+#define DEFAULT 1
+#define LOGIN 2
+#define PASSWD 3
+#define NOTIFY 4
+#define WRITE 5
+#define YES 6
+#define NO 7
+#define COMMAND 8
+#define FORCE 9
+#define ID 10
+#define MACHINE 11
+
+static char tokval[100];
+
+static struct toktab {
+ char *tokstr;
+ int tval;
+} toktab[]= {
+ "default", DEFAULT,
+ "login", LOGIN,
+ "password", PASSWD,
+ "notify", NOTIFY,
+ "write", WRITE,
+ "yes", YES,
+ "y", YES,
+ "no", NO,
+ "n", NO,
+ "command", COMMAND,
+ "force", FORCE,
+ "machine", MACHINE,
+ 0, 0
+};
+
+static
+rnetrc(host, aname, apass)
+ char *host, **aname, **apass;
+{
+ char *hdir, buf[BUFSIZ];
+ int t;
+ struct stat stb;
+ extern int errno;
+
+ hdir = getenv("HOME");
+ if (hdir == NULL)
+ hdir = ".";
+ sprintf(buf, "%s/.netrc", hdir);
+ cfile = fopen(buf, "r");
+ if (cfile == NULL) {
+ if (errno != ENOENT)
+ perror(buf);
+ return;
+ }
+next:
+ while ((t = token())) switch(t) {
+
+ case DEFAULT:
+ (void) token();
+ continue;
+
+ case MACHINE:
+ if (token() != ID || strcmp(host, tokval))
+ continue;
+ while ((t = token()) && t != MACHINE) switch(t) {
+
+ case LOGIN:
+ if (token())
+ if (*aname == 0) {
+ *aname = malloc(strlen(tokval) + 1);
+ strcpy(*aname, tokval);
+ } else {
+ if (strcmp(*aname, tokval))
+ goto next;
+ }
+ break;
+ case PASSWD:
+ if (fstat(fileno(cfile), &stb) >= 0
+ && (stb.st_mode & 077) != 0) {
+ fprintf(stderr, "Error - .netrc file not correct mode.\n");
+ fprintf(stderr, "Remove password or correct mode.\n");
+ exit(1);
+ }
+ if (token() && *apass == 0) {
+ *apass = malloc(strlen(tokval) + 1);
+ strcpy(*apass, tokval);
+ }
+ break;
+ case COMMAND:
+ case NOTIFY:
+ case WRITE:
+ case FORCE:
+ (void) token();
+ break;
+ default:
+ fprintf(stderr, "Unknown .netrc option %s\n", tokval);
+ break;
+ }
+ goto done;
+ }
+done:
+ fclose(cfile);
+}
+
+static
+token()
+{
+ char *cp;
+ int c;
+ struct toktab *t;
+
+ if (feof(cfile))
+ return (0);
+ while ((c = getc(cfile)) != EOF &&
+ (c == '\n' || c == '\t' || c == ' ' || c == ','))
+ continue;
+ if (c == EOF)
+ return (0);
+ cp = tokval;
+ if (c == '"') {
+ while ((c = getc(cfile)) != EOF && c != '"') {
+ if (c == '\\')
+ c = getc(cfile);
+ *cp++ = c;
+ }
+ } else {
+ *cp++ = c;
+ while ((c = getc(cfile)) != EOF
+ && c != '\n' && c != '\t' && c != ' ' && c != ',') {
+ if (c == '\\')
+ c = getc(cfile);
+ *cp++ = c;
+ }
+ }
+ *cp = 0;
+ if (tokval[0] == 0)
+ return (0);
+ for (t = toktab; t->tokstr; t++)
+ if (!strcmp(t->tokstr, tokval))
+ return (t->tval);
+ return (ID);
+}
+/* rest is nbs.c stolen from berknet */
+
+char *deblknot(), *deblkclr();
+char *nbs8decrypt(), *nbs8encrypt();
+static char E[48];
+
+/*
+ * The E bit-selection table.
+ */
+static char e[] = {
+ 32, 1, 2, 3, 4, 5,
+ 4, 5, 6, 7, 8, 9,
+ 8, 9,10,11,12,13,
+ 12,13,14,15,16,17,
+ 16,17,18,19,20,21,
+ 20,21,22,23,24,25,
+ 24,25,26,27,28,29,
+ 28,29,30,31,32, 1,
+};
+static
+char *nbsencrypt(str,key,result)
+ char *result;
+ char *str, *key; {
+ static char buf[20],oldbuf[20];
+ register int j;
+ result[0] = 0;
+ strcpy(oldbuf,key);
+ while(*str){
+ for(j=0;j<10;j++)buf[j] = 0;
+ for(j=0;j<8 && *str;j++)buf[j] = *str++;
+ strcat(result,nbs8encrypt(buf,oldbuf));
+ strcat(result,"$");
+ strcpy(oldbuf,buf);
+ }
+ return(result);
+ }
+static
+char *nbsdecrypt(cpt,key,result)
+ char *result;
+ char *cpt,*key; {
+ char *s;
+ char c,oldbuf[20];
+ result[0] = 0;
+ strcpy(oldbuf,key);
+ while(*cpt){
+ for(s = cpt;*s && *s != '$';s++);
+ c = *s;
+ *s = 0;
+ strcpy(oldbuf,nbs8decrypt(cpt,oldbuf));
+ strcat(result,oldbuf);
+ if(c == 0)break;
+ cpt = s + 1;
+ }
+ return(result);
+ }
+
+static
+char *nbs8encrypt(str,key)
+char *str, *key; {
+ static char keyblk[100], blk[100];
+ register int i;
+
+ enblkclr(keyblk,key);
+ nbssetkey(keyblk);
+
+ for(i=0;i<48;i++) E[i] = e[i];
+ enblkclr(blk,str);
+ blkencrypt(blk,0); /* forward dir */
+
+ return(deblknot(blk));
+}
+
+static
+char *nbs8decrypt(crp,key)
+char *crp, *key; {
+ static char keyblk[100], blk[100];
+ register int i;
+
+ enblkclr(keyblk,key);
+ nbssetkey(keyblk);
+
+ for(i=0;i<48;i++) E[i] = e[i];
+ enblknot(blk,crp);
+ blkencrypt(blk,1); /* backward dir */
+
+ return(deblkclr(blk));
+}
+
+static
+enblkclr(blk,str) /* ignores top bit of chars in string str */
+char *blk,*str; {
+ register int i,j;
+ char c;
+ for(i=0;i<70;i++)blk[i] = 0;
+ for(i=0; (c= *str) && i<64; str++){
+ for(j=0; j<7; j++, i++)
+ blk[i] = (c>>(6-j)) & 01;
+ i++;
+ }
+ }
+
+static
+char *deblkclr(blk)
+char *blk; {
+ register int i,j;
+ char c;
+ static char iobuf[30];
+ for(i=0; i<10; i++){
+ c = 0;
+ for(j=0; j<7; j++){
+ c <<= 1;
+ c |= blk[8*i+j];
+ }
+ iobuf[i] = c;
+ }
+ iobuf[i] = 0;
+ return(iobuf);
+ }
+
+static
+enblknot(blk,crp)
+char *blk;
+char *crp; {
+ register int i,j;
+ char c;
+ for(i=0;i<70;i++)blk[i] = 0;
+ for(i=0; (c= *crp) && i<64; crp++){
+ if(c>'Z') c -= 6;
+ if(c>'9') c -= 7;
+ c -= '.';
+ for(j=0; j<6; j++, i++)
+ blk[i] = (c>>(5-j)) & 01;
+ }
+ }
+
+static
+char *deblknot(blk)
+char *blk; {
+ register int i,j;
+ char c;
+ static char iobuf[30];
+ for(i=0; i<11; i++){
+ c = 0;
+ for(j=0; j<6; j++){
+ c <<= 1;
+ c |= blk[6*i+j];
+ }
+ c += '.';
+ if(c > '9')c += 7;
+ if(c > 'Z')c += 6;
+ iobuf[i] = c;
+ }
+ iobuf[i] = 0;
+ return(iobuf);
+}
+
+/*
+ * This program implements the
+ * Proposed Federal Information Processing
+ * Data Encryption Standard.
+ * See Federal Register, March 17, 1975 (40FR12134)
+ */
+
+/*
+ * Initial permutation,
+ */
+static char IP[] = {
+ 58,50,42,34,26,18,10, 2,
+ 60,52,44,36,28,20,12, 4,
+ 62,54,46,38,30,22,14, 6,
+ 64,56,48,40,32,24,16, 8,
+ 57,49,41,33,25,17, 9, 1,
+ 59,51,43,35,27,19,11, 3,
+ 61,53,45,37,29,21,13, 5,
+ 63,55,47,39,31,23,15, 7,
+};
+
+/*
+ * Final permutation, FP = IP^(-1)
+ */
+static char FP[] = {
+ 40, 8,48,16,56,24,64,32,
+ 39, 7,47,15,55,23,63,31,
+ 38, 6,46,14,54,22,62,30,
+ 37, 5,45,13,53,21,61,29,
+ 36, 4,44,12,52,20,60,28,
+ 35, 3,43,11,51,19,59,27,
+ 34, 2,42,10,50,18,58,26,
+ 33, 1,41, 9,49,17,57,25,
+};
+
+/*
+ * Permuted-choice 1 from the key bits
+ * to yield C and D.
+ * Note that bits 8,16... are left out:
+ * They are intended for a parity check.
+ */
+static char PC1_C[] = {
+ 57,49,41,33,25,17, 9,
+ 1,58,50,42,34,26,18,
+ 10, 2,59,51,43,35,27,
+ 19,11, 3,60,52,44,36,
+};
+
+static char PC1_D[] = {
+ 63,55,47,39,31,23,15,
+ 7,62,54,46,38,30,22,
+ 14, 6,61,53,45,37,29,
+ 21,13, 5,28,20,12, 4,
+};
+
+/*
+ * Sequence of shifts used for the key schedule.
+*/
+static char shifts[] = {
+ 1,1,2,2,2,2,2,2,1,2,2,2,2,2,2,1,
+};
+
+/*
+ * Permuted-choice 2, to pick out the bits from
+ * the CD array that generate the key schedule.
+ */
+static char PC2_C[] = {
+ 14,17,11,24, 1, 5,
+ 3,28,15, 6,21,10,
+ 23,19,12, 4,26, 8,
+ 16, 7,27,20,13, 2,
+};
+
+static char PC2_D[] = {
+ 41,52,31,37,47,55,
+ 30,40,51,45,33,48,
+ 44,49,39,56,34,53,
+ 46,42,50,36,29,32,
+};
+
+/*
+ * The C and D arrays used to calculate the key schedule.
+ */
+
+static char C[28];
+static char D[28];
+/*
+ * The key schedule.
+ * Generated from the key.
+ */
+static char KS[16][48];
+
+/*
+ * Set up the key schedule from the key.
+ */
+
+static
+nbssetkey(key)
+char *key;
+{
+ register i, j, k;
+ int t;
+
+ /*
+ * First, generate C and D by permuting
+ * the key. The low order bit of each
+ * 8-bit char is not used, so C and D are only 28
+ * bits apiece.
+ */
+ for (i=0; i<28; i++) {
+ C[i] = key[PC1_C[i]-1];
+ D[i] = key[PC1_D[i]-1];
+ }
+ /*
+ * To generate Ki, rotate C and D according
+ * to schedule and pick up a permutation
+ * using PC2.
+ */
+ for (i=0; i<16; i++) {
+ /*
+ * rotate.
+ */
+ for (k=0; k<shifts[i]; k++) {
+ t = C[0];
+ for (j=0; j<28-1; j++)
+ C[j] = C[j+1];
+ C[27] = t;
+ t = D[0];
+ for (j=0; j<28-1; j++)
+ D[j] = D[j+1];
+ D[27] = t;
+ }
+ /*
+ * get Ki. Note C and D are concatenated.
+ */
+ for (j=0; j<24; j++) {
+ KS[i][j] = C[PC2_C[j]-1];
+ KS[i][j+24] = D[PC2_D[j]-28-1];
+ }
+ }
+}
+
+
+/*
+ * The 8 selection functions.
+ * For some reason, they give a 0-origin
+ * index, unlike everything else.
+ */
+static char S[8][64] = {
+ 14, 4,13, 1, 2,15,11, 8, 3,10, 6,12, 5, 9, 0, 7,
+ 0,15, 7, 4,14, 2,13, 1,10, 6,12,11, 9, 5, 3, 8,
+ 4, 1,14, 8,13, 6, 2,11,15,12, 9, 7, 3,10, 5, 0,
+ 15,12, 8, 2, 4, 9, 1, 7, 5,11, 3,14,10, 0, 6,13,
+
+ 15, 1, 8,14, 6,11, 3, 4, 9, 7, 2,13,12, 0, 5,10,
+ 3,13, 4, 7,15, 2, 8,14,12, 0, 1,10, 6, 9,11, 5,
+ 0,14, 7,11,10, 4,13, 1, 5, 8,12, 6, 9, 3, 2,15,
+ 13, 8,10, 1, 3,15, 4, 2,11, 6, 7,12, 0, 5,14, 9,
+
+ 10, 0, 9,14, 6, 3,15, 5, 1,13,12, 7,11, 4, 2, 8,
+ 13, 7, 0, 9, 3, 4, 6,10, 2, 8, 5,14,12,11,15, 1,
+ 13, 6, 4, 9, 8,15, 3, 0,11, 1, 2,12, 5,10,14, 7,
+ 1,10,13, 0, 6, 9, 8, 7, 4,15,14, 3,11, 5, 2,12,
+
+ 7,13,14, 3, 0, 6, 9,10, 1, 2, 8, 5,11,12, 4,15,
+ 13, 8,11, 5, 6,15, 0, 3, 4, 7, 2,12, 1,10,14, 9,
+ 10, 6, 9, 0,12,11, 7,13,15, 1, 3,14, 5, 2, 8, 4,
+ 3,15, 0, 6,10, 1,13, 8, 9, 4, 5,11,12, 7, 2,14,
+
+ 2,12, 4, 1, 7,10,11, 6, 8, 5, 3,15,13, 0,14, 9,
+ 14,11, 2,12, 4, 7,13, 1, 5, 0,15,10, 3, 9, 8, 6,
+ 4, 2, 1,11,10,13, 7, 8,15, 9,12, 5, 6, 3, 0,14,
+ 11, 8,12, 7, 1,14, 2,13, 6,15, 0, 9,10, 4, 5, 3,
+
+ 12, 1,10,15, 9, 2, 6, 8, 0,13, 3, 4,14, 7, 5,11,
+ 10,15, 4, 2, 7,12, 9, 5, 6, 1,13,14, 0,11, 3, 8,
+ 9,14,15, 5, 2, 8,12, 3, 7, 0, 4,10, 1,13,11, 6,
+ 4, 3, 2,12, 9, 5,15,10,11,14, 1, 7, 6, 0, 8,13,
+
+ 4,11, 2,14,15, 0, 8,13, 3,12, 9, 7, 5,10, 6, 1,
+ 13, 0,11, 7, 4, 9, 1,10,14, 3, 5,12, 2,15, 8, 6,
+ 1, 4,11,13,12, 3, 7,14,10,15, 6, 8, 0, 5, 9, 2,
+ 6,11,13, 8, 1, 4,10, 7, 9, 5, 0,15,14, 2, 3,12,
+
+ 13, 2, 8, 4, 6,15,11, 1,10, 9, 3,14, 5, 0,12, 7,
+ 1,15,13, 8,10, 3, 7, 4,12, 5, 6,11, 0,14, 9, 2,
+ 7,11, 4, 1, 9,12,14, 2, 0, 6,10,13,15, 3, 5, 8,
+ 2, 1,14, 7, 4,10, 8,13,15,12, 9, 0, 3, 5, 6,11,
+};
+
+/*
+ * P is a permutation on the selected combination
+ * of the current L and key.
+ */
+static char P[] = {
+ 16, 7,20,21,
+ 29,12,28,17,
+ 1,15,23,26,
+ 5,18,31,10,
+ 2, 8,24,14,
+ 32,27, 3, 9,
+ 19,13,30, 6,
+ 22,11, 4,25,
+};
+
+/*
+ * The current block, divided into 2 halves.
+ */
+static char L[32], R[32];
+static char tempL[32];
+static char f[32];
+
+/*
+ * The combination of the key and the input, before selection.
+ */
+static char preS[48];
+
+/*
+ * The payoff: encrypt a block.
+ */
+
+static
+blkencrypt(block, edflag)
+char *block;
+{
+ int i, ii;
+ register t, j, k;
+
+ /*
+ * First, permute the bits in the input
+ */
+ for (j=0; j<64; j++)
+ L[j] = block[IP[j]-1];
+ /*
+ * Perform an encryption operation 16 times.
+ */
+ for (ii=0; ii<16; ii++) {
+ /*
+ * Set direction
+ */
+ if (edflag)
+ i = 15-ii;
+ else
+ i = ii;
+ /*
+ * Save the R array,
+ * which will be the new L.
+ */
+ for (j=0; j<32; j++)
+ tempL[j] = R[j];
+ /*
+ * Expand R to 48 bits using the E selector;
+ * exclusive-or with the current key bits.
+ */
+ for (j=0; j<48; j++)
+ preS[j] = R[E[j]-1] ^ KS[i][j];
+ /*
+ * The pre-select bits are now considered
+ * in 8 groups of 6 bits each.
+ * The 8 selection functions map these
+ * 6-bit quantities into 4-bit quantities
+ * and the results permuted
+ * to make an f(R, K).
+ * The indexing into the selection functions
+ * is peculiar; it could be simplified by
+ * rewriting the tables.
+ */
+ for (j=0; j<8; j++) {
+ t = 6*j;
+ k = S[j][(preS[t+0]<<5)+
+ (preS[t+1]<<3)+
+ (preS[t+2]<<2)+
+ (preS[t+3]<<1)+
+ (preS[t+4]<<0)+
+ (preS[t+5]<<4)];
+ t = 4*j;
+ f[t+0] = (k>>3)&01;
+ f[t+1] = (k>>2)&01;
+ f[t+2] = (k>>1)&01;
+ f[t+3] = (k>>0)&01;
+ }
+ /*
+ * The new R is L ^ f(R, K).
+ * The f here has to be permuted first, though.
+ */
+ for (j=0; j<32; j++)
+ R[j] = L[j] ^ f[P[j]-1];
+ /*
+ * Finally, the new L (the original R)
+ * is copied back.
+ */
+ for (j=0; j<32; j++)
+ L[j] = tempL[j];
+ }
+ /*
+ * The output L and R are reversed.
+ */
+ for (j=0; j<32; j++) {
+ t = L[j];
+ L[j] = R[j];
+ R[j] = t;
+ }
+ /*
+ * The final output
+ * gets the inverse permutation of the very original.
+ */
+ for (j=0; j<64; j++)
+ block[j] = L[FP[j]-1];
+}
+/*
+ getutmp()
+ return a pointer to the system utmp structure associated with
+ terminal sttyname, e.g. "/dev/tty3"
+ Is version independent-- will work on v6 systems
+ return NULL if error
+*/
+static
+struct utmp *getutmp(sttyname)
+char *sttyname;
+{
+ static struct utmp utmpstr;
+ FILE *fdutmp;
+
+ if(sttyname == NULL || sttyname[0] == 0)return(NULL);
+
+ fdutmp = fopen("/etc/utmp","r");
+ if(fdutmp == NULL)return(NULL);
+
+ while(fread(&utmpstr,1,sizeof utmpstr,fdutmp) == sizeof utmpstr)
+ if(strcmp(utmpstr.ut_line,sttyname+5) == 0){
+ fclose(fdutmp);
+ return(&utmpstr);
+ }
+ fclose(fdutmp);
+ return(NULL);
+}
+
+static
+sreverse(sto, sfrom)
+ register char *sto, *sfrom;
+{
+ register int i;
+
+ i = strlen(sfrom);
+ while (i >= 0)
+ *sto++ = sfrom[i--];
+}
+
+static
+char *mkenvkey(mch)
+ char mch;
+{
+ static char skey[40];
+ register struct utmp *putmp;
+ char stemp[40], stemp1[40], sttyname[30];
+ register char *sk,*p;
+
+ if (isatty(2))
+ strcpy(sttyname,ttyname(2));
+ else if (isatty(0))
+ strcpy(sttyname,ttyname(0));
+ else if (isatty(1))
+ strcpy(sttyname,ttyname(1));
+ else
+ return (NULL);
+ putmp = getutmp(sttyname);
+ if (putmp == NULL)
+ return (NULL);
+ sk = skey;
+ p = putmp->ut_line;
+ while (*p)
+ *sk++ = *p++;
+ *sk++ = mch;
+ sprintf(stemp, "%ld", putmp->ut_time);
+ sreverse(stemp1, stemp);
+ p = stemp1;
+ while (*p)
+ *sk++ = *p++;
+ *sk = 0;
+ return (skey);
+}
+
+mkpwunclear(spasswd,mch,sencpasswd)
+ char mch, *spasswd, *sencpasswd;
+{
+ register char *skey;
+
+ if (spasswd[0] == 0) {
+ sencpasswd[0] = 0;
+ return;
+ }
+ skey = mkenvkey(mch);
+ if (skey == NULL) {
+ fprintf(stderr, "Can't make key\n");
+ exit(1);
+ }
+ nbsencrypt(spasswd, skey, sencpasswd);
+}
+
+mkpwclear(sencpasswd,mch,spasswd)
+ char mch, *spasswd, *sencpasswd;
+{
+ register char *skey;
+
+ if (sencpasswd[0] == 0) {
+ spasswd[0] = 0;
+ return;
+ }
+ skey = mkenvkey(mch);
+ if (skey == NULL) {
+ fprintf(stderr, "Can't make key\n");
+ exit(1);
+ }
+ nbsdecrypt(sencpasswd, skey, spasswd);
+}
--- /dev/null
+/* ns/ns_addr.c */
+struct ns_addr ns_addr __P((char *name));
+/* ns/ns_ntoa.c */
+char *ns_ntoa __P((struct ns_addr addr));
--- /dev/null
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 6.1 (Berkeley) 1/29/86
+#
+
+SRCS= ns_addr.c ns_ntoa.c
+OBJS= ns_addr.o ns_ntoa.o
+CFLAGS= -O ${DEFS}
+TAGSFILE=tags
+
+.c.o:
+ ${CC} -p -c ${CFLAGS} $*.c
+ -ld -X -r $*.o
+ mv a.out profiled/$*.o
+ ${CC} ${CFLAGS} -c $*.c
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+nslib nslib_p: ${OBJS}
+ @echo "building profiled nslib"
+ @cd profiled; ar cru ../nslib_p ${OBJS}
+ @echo "building normal nslib"
+ @ar cru nslib ${OBJS}
+
+tags:
+ cwd=`pwd`; \
+ for i in ${SRCS}; do \
+ ctags -a -f ${TAGSFILE} $$cwd/$$i; \
+ done
+
+clean:
+ rm -f nslib nslib_p *.o profiled/*.o errs a.out core \
+ tags Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+ns_addr.o: ns_addr.c /usr/include/sys/types.h /usr/include/netns/ns.h
+ns_ntoa.o: ns_ntoa.c /usr/include/sys/types.h /usr/include/netns/ns.h
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+/*
+ * Copyright (c) 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ * Includes material written at Cornell University, by J. Q. Johnson.
+ * Used by permission.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ns_addr.c 6.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <netns/ns.h>
+
+static struct ns_addr addr, zero_addr;
+
+struct ns_addr
+ns_addr(name)
+ char *name;
+{
+ u_long net;
+ u_short socket;
+ char separator = '.';
+ char *hostname, *socketname, *cp;
+ char buf[50];
+ extern char *index();
+
+ addr = zero_addr;
+ strncpy(buf, name, 49);
+
+ /*
+ * First, figure out what he intends as a field separtor.
+ * Despite the way this routine is written, the prefered
+ * form 2-272.AA001234H.01777, i.e. XDE standard.
+ * Great efforts are made to insure backward compatability.
+ */
+ if (hostname = index(buf, '#'))
+ separator = '#';
+ else {
+ hostname = index(buf, '.');
+ if ((cp = index(buf, ':')) &&
+ ( (hostname && cp < hostname) || (hostname == 0))) {
+ hostname = cp;
+ separator = ':';
+ }
+ }
+ if (hostname)
+ *hostname++ = 0;
+ Field(buf, addr.x_net.c_net, 4);
+ if (hostname == 0)
+ return (addr); /* No separator means net only */
+
+ socketname = index(hostname, separator);
+ if (socketname) {
+ *socketname++ = 0;
+ Field(socketname, &addr.x_port, 2);
+ }
+
+ Field(hostname, addr.x_host.c_host, 6);
+
+ return (addr);
+}
+
+static
+Field(buf, out, len)
+char *buf;
+u_char *out;
+int len;
+{
+ register char *bp = buf;
+ int i, ibase, base16 = 0, base10 = 0, clen = 0;
+ int hb[6], *hp;
+ char *fmt;
+
+ /*
+ * first try 2-273#2-852-151-014#socket
+ */
+ if ((*buf != '-') &&
+ (1 < (i = sscanf(buf, "%d-%d-%d-%d-%d",
+ &hb[0], &hb[1], &hb[2], &hb[3], &hb[4])))) {
+ cvtbase(1000, 256, hb, i, out, len);
+ return;
+ }
+ /*
+ * try form 8E1#0.0.AA.0.5E.E6#socket
+ */
+ if (1 < (i = sscanf(buf,"%x.%x.%x.%x.%x.%x",
+ &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) {
+ cvtbase(256, 256, hb, i, out, len);
+ return;
+ }
+ /*
+ * try form 8E1#0:0:AA:0:5E:E6#socket
+ */
+ if (1 < (i = sscanf(buf,"%x:%x:%x:%x:%x:%x",
+ &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) {
+ cvtbase(256, 256, hb, i, out, len);
+ return;
+ }
+ /*
+ * This is REALLY stretching it but there was a
+ * comma notation separting shorts -- definitely non standard
+ */
+ if (1 < (i = sscanf(buf,"%x,%x,%x",
+ &hb[0], &hb[1], &hb[2]))) {
+ hb[0] = htons(hb[0]); hb[1] = htons(hb[1]);
+ hb[2] = htons(hb[2]);
+ cvtbase(65536, 256, hb, i, out, len);
+ return;
+ }
+
+ /* Need to decide if base 10, 16 or 8 */
+ while (*bp) switch (*bp++) {
+
+ case '0': case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '-':
+ break;
+
+ case '8': case '9':
+ base10 = 1;
+ break;
+
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ base16 = 1;
+ break;
+
+ case 'x': case 'X':
+ *--bp = '0';
+ base16 = 1;
+ break;
+
+ case 'h': case 'H':
+ base16 = 1;
+ /* fall into */
+
+ default:
+ *--bp = 0; /* Ends Loop */
+ }
+ if (base16) {
+ fmt = "%3x";
+ ibase = 4096;
+ } else if (base10 == 0 && *buf == '0') {
+ fmt = "%3o";
+ ibase = 512;
+ } else {
+ fmt = "%3d";
+ ibase = 1000;
+ }
+
+ for (bp = buf; *bp++; ) clen++;
+ if (clen == 0) clen++;
+ if (clen > 18) clen = 18;
+ i = ((clen - 1) / 3) + 1;
+ bp = clen + buf - 3;
+ hp = hb + i - 1;
+
+ while (hp > hb) {
+ sscanf(bp, fmt, hp);
+ bp[0] = 0;
+ hp--;
+ bp -= 3;
+ }
+ sscanf(buf, fmt, hp);
+ cvtbase(ibase, 256, hb, i, out, len);
+}
+
+static
+cvtbase(oldbase,newbase,input,inlen,result,reslen)
+ int oldbase, newbase;
+ int input[];
+ int inlen;
+ unsigned char result[];
+ int reslen;
+{
+ int d, e;
+ long sum;
+
+ e = 1;
+ while (e > 0 && reslen > 0) {
+ d = 0; e = 0; sum = 0;
+ /* long division: input=input/newbase */
+ while (d < inlen) {
+ sum = sum*oldbase + (long) input[d];
+ e += (sum > 0);
+ input[d++] = sum / newbase;
+ sum %= newbase;
+ }
+ result[--reslen] = sum; /* accumulate remainder */
+ }
+ for (d=0; d < reslen; d++)
+ result[d] = 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 1986 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ *
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ns_ntoa.c 6.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <netns/ns.h>
+
+char *
+ns_ntoa(addr)
+struct ns_addr addr;
+{
+ static char obuf[40];
+ char *spectHex();
+ union { union ns_net net_e; u_long long_e; } net;
+ u_short port = htons(addr.x_port);
+ register char *cp;
+ char *cp2;
+ register u_char *up = addr.x_host.c_host;
+ u_char *uplim = up + 6;
+
+ net.net_e = addr.x_net;
+ sprintf(obuf, "%lx", ntohl(net.long_e));
+ cp = spectHex(obuf);
+ cp2 = cp + 1;
+ while (*up==0 && up < uplim) up++;
+ if (up == uplim) {
+ if (port) {
+ sprintf(cp, ".0");
+ cp += 2;
+ }
+ } else {
+ sprintf(cp, ".%x", *up++);
+ while (up < uplim) {
+ while (*cp) cp++;
+ sprintf(cp, "%02x", *up++);
+ }
+ cp = spectHex(cp2);
+ }
+ if (port) {
+ sprintf(cp, ".%x", port);
+ spectHex(cp + 1);
+ }
+ return (obuf);
+}
+
+static char *
+spectHex(p0)
+char *p0;
+{
+ int ok = 0;
+ int nonzero = 0;
+ register char *p = p0;
+ for (; *p; p++) switch (*p) {
+
+ case 'a': case 'b': case 'c': case 'd': case 'e': case 'f':
+ *p += ('A' - 'a');
+ /* fall into . . . */
+ case 'A': case 'B': case 'C': case 'D': case 'E': case 'F':
+ ok = 1;
+ case '1': case '2': case '3': case '4': case '5':
+ case '6': case '7': case '8': case '9':
+ nonzero = 1;
+ }
+ if (nonzero && !ok) { *p++ = 'H'; *p = 0; }
+ return (p);
+}
--- /dev/null
+#!/bin/sh
+
+sed -e 's/[\t ]\+/ /g;s/^ /void /;s/\* /*/g;s/( /(/g;s/ )/)/g' llib-lc >llib-lc.temp
+
+find vax -name '*.c' -print |\
+sed -e 's:^vax\/\(.*\)\.c:\1:' |\
+while read i
+do
+ if grep -q "^}" vax/$i.c
+ then
+ mkdir -p `dirname $i`
+ mv vax/$i.c $i.c
+ else
+ mv vax/$i.c vax/$i.s
+ if test -f /mnt/4.3tahoe/usr/src/lib/libc/$i.c
+ then
+ cp /mnt/4.3tahoe/usr/src/lib/libc/$i.c vax/$i.c.tahoe
+ fi
+ entries="`sed -ne 's/^\(ASENTRY\|ENTRY\|PSEUDO\|SYSCALL\)(\([^),]*\)\(,[^)]*\)\?)$/\2/p' vax/$i.s`"
+ echo "i=$i entries=$entries"
+ if test -n "$entries"
+ then
+ for j in $entries
+ do
+ grep "[^0-9A-Za-z_]$j[ ]*(" llib-lc.temp |\
+ sed -e 's/{.*}/{\n abort();\n}/'
+ done >a
+ if test -s a
+ then
+ n=vax/$i.c.abort
+ (
+ echo '#include "gen.h"'
+ cat a
+ ) >vax/$i.c.abort
+ fi
+ fi
+ if ! test -f $i.c
+ then
+ if test -f vax/$i.c.tahoe
+ then
+ mkdir -p `dirname $i`
+ cp vax/$i.c.tahoe $i.c
+ elif test -f vax/$i.c.abort
+ then
+ mkdir -p `dirname $i`
+ cp vax/$i.c.abort $i.c
+ fi
+ fi
+ fi
+done
+
+touch include/gen.h
--- /dev/null
+#!/bin/sh
+
+rm -f include.txt funcdef.txt
+
+find include -name '*.h' -print |\
+while read i
+do
+ rm -f xx*
+ csplit -b '%05d' -q $i '/^#/' '{*}'
+ if test -f xx00001
+ then
+ for j in xx*
+ do
+ :
+ done
+ define="`sed -ne 's/^#[ ]*ifndef[ ]\+\([A-Za-z_][0-9A-Za-z_]*\).*/\1/p' xx00001`"
+ echo "i=$i j=$j define=$define"
+ if test -n "$define" && grep -q '^#[ ]*endif' $j
+ then
+ sed -e "s/^#[ ]*ifndef[ ]\\+$define/\\/\\*&\\*\\//" -i xx00001
+ sed -e "s/^\(#[ ]*define[ ]\\+$define\)[ ]*$/\\/\\*\1\\*\\//" -i xx00002
+ sed -e 's/^\(#[ ]*endif\).*/\/\*\1\*\//' -i $j
+ cat xx* >$i
+ fi
+ fi
+
+ grep -H '^#[ ]*include[ ]*<\([^>]*\)>' $i >>include.txt
+ sed -e 's/^#[ ]*include[ ]*<\([^>]*\)>/\/\*&\*\//' -i $i
+
+ grep -H '^#[ ]*include[ ]*"\([^"]*\)"' $i >>include.txt
+ sed -e 's/^#[ ]*include[ ]*"\([^"]*\)"/\/\*&\*\//' -i $i
+
+ grep -H '^.*()\(,[^;]*\)\?;' $i >>funcdef.txt
+ sed -e 's/^.*()\(,[^;]*\)\?;/\/\*&\*\//' -i $i
+done
--- /dev/null
+/* stdio/flsbuf.c */
+int _flsbuf __P((int c, register FILE *iop));
+int fflush __P((register FILE *iop));
+int fclose __P((register FILE *iop));
+/* stdio/strout.c */
+int _strout __P((register count, register char *string, int adjust, register FILE *file, int fillch));
+/* stdio/fseek.c */
+int fseek __P((register FILE *iop, long offset, int ptrname));
+/* stdio/gets.c */
+char *gets __P((char *s));
+/* stdio/doscan.c */
+int _doscan __P((FILE *iop, register char *fmt, register va_list ap));
+/* stdio/ftell.c */
+long ftell __P((register FILE *iop));
+/* stdio/vsprintf.c */
+int vsprintf __P((char *str, char *fmt, va_list ap));
+/* stdio/sibuf.c */
+/* stdio/fputc.c */
+int fputc __P((int c, register FILE *fp));
+/* stdio/setbuffer.c */
+int setbuffer __P((register FILE *iop, char *buf, int size));
+int setlinebuf __P((register FILE *iop));
+/* stdio/exit.c */
+int exit __P((int code));
+/* stdio/puts.c */
+int puts __P((register char *s));
+/* stdio/fopen.c */
+FILE *fopen __P((char *file, register char *mode));
+/* stdio/vfprintf.c */
+int vfprintf __P((FILE *iop, char *fmt, va_list ap));
+/* stdio/scanf.c */
+int scanf __P((char *fmt, ...));
+int fscanf __P((FILE *iop, char *fmt, ...));
+int sscanf __P((register char *str, char *fmt, ...));
+/* stdio/getchar.c */
+int getchar __P((void));
+/* stdio/ungetc.c */
+int ungetc __P((int c, register FILE *iop));
+/* stdio/sprintf.c */
+int sprintf __P((char *str, char *fmt, ...));
+/* stdio/findiop.c */
+FILE *_findiop __P((void));
+int _f_morefiles __P((void));
+int f_prealloc __P((void));
+int _fwalk __P((register int (*function)(void)));
+int _cleanup __P((void));
+/* stdio/doprnt.c */
+int _doprnt __P((u_char *fmt0, va_list argp, register FILE *fp));
+/* stdio/fwrite.c */
+int fwrite __P((register char *ptr, unsigned size, unsigned count, register FILE *iop));
+/* stdio/vprintf.c */
+int vprintf __P((char *fmt, va_list ap));
+/* stdio/rew.c */
+int rewind __P((register FILE *iop));
+/* stdio/fgetc.c */
+int fgetc __P((FILE *fp));
+/* stdio/clrerr.c */
+int clearerr __P((register FILE *iop));
+/* stdio/fgets.c */
+char *fgets __P((char *s, int n, register FILE *iop));
+/* stdio/freopen.c */
+FILE *freopen __P((char *file, register char *mode, register FILE *iop));
+/* stdio/setbuf.c */
+int setbuf __P((register FILE *iop, char *buf));
+/* stdio/fdopen.c */
+FILE *fdopen __P((int fd, register char *mode));
+/* stdio/fputs.c */
+int fputs __P((register char *s, register FILE *iop));
+/* stdio/putw.c */
+int putw __P((int w, register FILE *iop));
+/* stdio/fprintf.c */
+int fprintf __P((register FILE *iop, char *fmt, ...));
+/* stdio/getw.c */
+int getw __P((register FILE *iop));
+/* stdio/printf.c */
+int printf __P((char *fmt, ...));
+/* stdio/putchar.c */
+int putchar __P((register c));
+/* stdio/filbuf.c */
+int _filbuf __P((register FILE *iop));
+/* stdio/sobuf.c */
+/* stdio/fread.c */
+int fread __P((register char *ptr, unsigned size, unsigned count, register FILE *iop));
--- /dev/null
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 5.4 (Berkeley) 9/5/85
+#
+# Several routines have been rewritten in assembly language for the VAX.
+# If you are not running on a VAX, you should use the original C sources
+# which are included in this directory. Regretably we do not have a C
+# version of doprnt().
+#
+#ifndef vax
+#SRCS= ${STDSRC} ${VAXSRC}
+#OBJS= ${STDOBJ} ${VAXOBJ}
+#else
+SRCS= ${STDSRC}
+OBJS= ${STDOBJ}
+#endif not vax
+
+CFLAGS= -O ${DEFS}
+
+STDSRC= clrerr.c doscan.c \
+ exit.c fdopen.c fgetc.c filbuf.c findiop.c flsbuf.c fopen.c \
+ fprintf.c fputc.c fread.c freopen.c fseek.c ftell.c \
+ fwrite.c getchar.c getw.c printf.c putchar.c \
+ putw.c rew.c scanf.c setbuf.c setbuffer.c sibuf.c sobuf.c \
+ sprintf.c strout.c ungetc.c vfprintf.c vprintf.c vsprintf.c
+VAXSRC= doprnt.c fgets.c fputs.c gets.c puts.c
+STDOBJ= clrerr.o doscan.o \
+ exit.o fdopen.o fgetc.o filbuf.o findiop.o flsbuf.o fopen.o \
+ fprintf.o fputc.o fread.o freopen.o fseek.o ftell.o \
+ fwrite.o getchar.o getw.o printf.o putchar.o \
+ putw.o rew.o scanf.o setbuf.o setbuffer.o sibuf.o sobuf.o \
+ sprintf.o strout.o ungetc.o vfprintf.o vprintf.o vsprintf.o
+VAXOBJ= doprnt.o fgets.o fputs.o gets.o puts.o
+TAGSFILE=tags
+
+.c.o:
+ ${CC} -p ${CFLAGS} -c $*.c
+ -ld -X -r $*.o
+ mv a.out profiled/$*.o
+ ${CC} ${CFLAGS} -c $*.c
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+stdiolib stdiolib_p: ${OBJS}
+ @echo "building profiled stdiolib"
+ @cd profiled; ar cru ../stdiolib_p ${OBJS}
+ @echo "building normal stdiolib"
+ @ar cru stdiolib ${OBJS}
+
+tags:
+ cwd=`pwd`; \
+ for i in ${SRCS}; do \
+ ctags -a -f ${TAGSFILE} $$cwd/$$i; \
+ done
+
+clean:
+ rm -f stdiolib stdiolib_p *.o profiled/*.o tags Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+clrerr.o: clrerr.c /usr/include/stdio.h
+doscan.o: doscan.c /usr/include/stdio.h /usr/include/ctype.h
+exit.o: exit.c
+fdopen.o: fdopen.c /usr/include/sys/types.h /usr/include/sys/file.h
+fdopen.o: /usr/include/stdio.h
+fgetc.o: fgetc.c /usr/include/stdio.h
+filbuf.o: filbuf.c /usr/include/stdio.h /usr/include/sys/types.h
+filbuf.o: /usr/include/sys/stat.h
+findiop.o: findiop.c /usr/include/stdio.h
+flsbuf.o: flsbuf.c /usr/include/stdio.h /usr/include/sys/types.h
+flsbuf.o: /usr/include/sys/stat.h
+fopen.o: fopen.c /usr/include/sys/types.h /usr/include/sys/file.h
+fopen.o: /usr/include/stdio.h
+fprintf.o: fprintf.c /usr/include/stdio.h
+fputc.o: fputc.c /usr/include/stdio.h
+fread.o: fread.c /usr/include/stdio.h
+freopen.o: freopen.c /usr/include/sys/types.h /usr/include/sys/file.h
+freopen.o: /usr/include/stdio.h
+fseek.o: fseek.c /usr/include/stdio.h
+ftell.o: ftell.c /usr/include/stdio.h
+fwrite.o: fwrite.c /usr/include/stdio.h
+getchar.o: getchar.c /usr/include/stdio.h
+getw.o: getw.c /usr/include/stdio.h
+printf.o: printf.c /usr/include/stdio.h
+putchar.o: putchar.c /usr/include/stdio.h
+putw.o: putw.c /usr/include/stdio.h
+rew.o: rew.c /usr/include/stdio.h
+scanf.o: scanf.c /usr/include/stdio.h
+setbuf.o: setbuf.c /usr/include/stdio.h
+setbuffer.o: setbuffer.c /usr/include/stdio.h
+sibuf.o: sibuf.c /usr/include/stdio.h
+sobuf.o: sobuf.c /usr/include/stdio.h
+sprintf.o: sprintf.c /usr/include/stdio.h
+strout.o: strout.c /usr/include/stdio.h
+ungetc.o: ungetc.c /usr/include/stdio.h
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)clrerr.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#undef clearerr
+
+clearerr(iop)
+ register FILE *iop;
+{
+ iop->_flag &= ~(_IOERR|_IOEOF);
+}
--- /dev/null
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)doprnt.c 5.35 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <varargs.h>
+#include <stdio.h>
+#include <ctype.h>
+
+/* 11-bit exponent (VAX G floating point) is 308 decimal digits */
+#define MAXEXP 308
+/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */
+#define MAXFRACT 39
+
+#define DEFPREC 6
+
+#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
+
+#define PUTC(ch) (void) putc(ch, fp)
+
+#define ARG() \
+ _ulong = flags&LONGINT ? va_arg(argp, long) : \
+ flags&SHORTINT ? va_arg(argp, short) : va_arg(argp, int);
+
+#define todigit(c) ((c) - '0')
+#define tochar(n) ((n) + '0')
+
+/* have to deal with the negative buffer count kludge */
+#define NEGATIVE_COUNT_KLUDGE
+
+#define LONGINT 0x01 /* long integer */
+#define LONGDBL 0x02 /* long double; unimplemented */
+#define SHORTINT 0x04 /* short integer */
+#define ALT 0x08 /* alternate form */
+#define LADJUST 0x10 /* left adjustment */
+#define ZEROPAD 0x20 /* zero (as opposed to blank) pad */
+#define HEXPREFIX 0x40 /* add 0x or 0X prefix */
+
+_doprnt(fmt0, argp, fp)
+ u_char *fmt0;
+ va_list argp;
+ register FILE *fp;
+{
+ register u_char *fmt; /* format string */
+ register int ch; /* character from fmt */
+ register int cnt; /* return value accumulator */
+ register int n; /* random handy integer */
+ register char *t; /* buffer pointer */
+ double _double; /* double precision arguments %[eEfgG] */
+ u_long _ulong; /* integer arguments %[diouxX] */
+ int base; /* base for [diouxX] conversion */
+ int dprec; /* decimal precision in [diouxX] */
+ int fieldsz; /* field size expanded by sign, etc */
+ int flags; /* flags as above */
+ int fpprec; /* `extra' floating precision in [eEfgG] */
+ int prec; /* precision from format (%.3d), or -1 */
+ int realsz; /* field size expanded by decimal precision */
+ int size; /* size of converted field or string */
+ int width; /* width from format (%8d), or 0 */
+ char sign; /* sign prefix (' ', '+', '-', or \0) */
+ char softsign; /* temporary negative sign for floats */
+ char *digs; /* digits for [diouxX] conversion */
+ char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
+
+ if (fp->_flag & _IORW) {
+ fp->_flag |= _IOWRT;
+ fp->_flag &= ~(_IOEOF|_IOREAD);
+ }
+ if ((fp->_flag & _IOWRT) == 0)
+ return (EOF);
+
+ fmt = fmt0;
+ digs = "0123456789abcdef";
+ for (cnt = 0;; ++fmt) {
+ n = fp->_cnt;
+ for (t = (char *)fp->_ptr; (ch = *fmt) && ch != '%';
+ ++cnt, ++fmt)
+ if (--n < 0
+#ifdef NEGATIVE_COUNT_KLUDGE
+ && (!(fp->_flag & _IOLBF) || -n >= fp->_bufsiz)
+#endif
+ || ch == '\n' && fp->_flag & _IOLBF) {
+ fp->_cnt = n;
+ fp->_ptr = t;
+ (void) _flsbuf((u_char)ch, fp);
+ n = fp->_cnt;
+ t = (char *)fp->_ptr;
+ } else
+ *t++ = ch;
+ fp->_cnt = n;
+ fp->_ptr = t;
+ if (!ch)
+ return (cnt);
+
+ flags = 0; dprec = 0; fpprec = 0; width = 0;
+ prec = -1;
+ sign = '\0';
+
+rflag: switch (*++fmt) {
+ case ' ':
+ /*
+ * ``If the space and + flags both appear, the space
+ * flag will be ignored.''
+ * -- ANSI X3J11
+ */
+ if (!sign)
+ sign = ' ';
+ goto rflag;
+ case '#':
+ flags |= ALT;
+ goto rflag;
+ case '*':
+ /*
+ * ``A negative field width argument is taken as a
+ * - flag followed by a positive field width.''
+ * -- ANSI X3J11
+ * They don't exclude field widths read from args.
+ */
+ if ((width = va_arg(argp, int)) >= 0)
+ goto rflag;
+ width = -width;
+ /* FALLTHROUGH */
+ case '-':
+ flags |= LADJUST;
+ goto rflag;
+ case '+':
+ sign = '+';
+ goto rflag;
+ case '.':
+ if (*++fmt == '*')
+ n = va_arg(argp, int);
+ else {
+ n = 0;
+ while (isascii(*fmt) && isdigit(*fmt))
+ n = 10 * n + todigit(*fmt++);
+ --fmt;
+ }
+ prec = n < 0 ? -1 : n;
+ goto rflag;
+ case '0':
+ /*
+ * ``Note that 0 is taken as a flag, not as the
+ * beginning of a field width.''
+ * -- ANSI X3J11
+ */
+ flags |= ZEROPAD;
+ goto rflag;
+ case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ n = 0;
+ do {
+ n = 10 * n + todigit(*fmt);
+ } while (isascii(*++fmt) && isdigit(*fmt));
+ width = n;
+ --fmt;
+ goto rflag;
+ case 'L':
+ flags |= LONGDBL;
+ goto rflag;
+ case 'h':
+ flags |= SHORTINT;
+ goto rflag;
+ case 'l':
+ flags |= LONGINT;
+ goto rflag;
+ case 'c':
+ *(t = buf) = va_arg(argp, int);
+ size = 1;
+ sign = '\0';
+ goto pforw;
+ case 'D':
+ flags |= LONGINT;
+ /*FALLTHROUGH*/
+ case 'd':
+ case 'i':
+ ARG();
+ if ((long)_ulong < 0) {
+ _ulong = -_ulong;
+ sign = '-';
+ }
+ base = 10;
+ goto number;
+ case 'e':
+ case 'E':
+ case 'f':
+ case 'g':
+ case 'G':
+ _double = va_arg(argp, double);
+ /*
+ * don't do unrealistic precision; just pad it with
+ * zeroes later, so buffer size stays rational.
+ */
+ if (prec > MAXFRACT) {
+ if (*fmt != 'g' && *fmt != 'G' || (flags&ALT))
+ fpprec = prec - MAXFRACT;
+ prec = MAXFRACT;
+ }
+ else if (prec == -1)
+ prec = DEFPREC;
+ /*
+ * softsign avoids negative 0 if _double is < 0 and
+ * no significant digits will be shown
+ */
+ if (_double < 0) {
+ softsign = '-';
+ _double = -_double;
+ }
+ else
+ softsign = 0;
+ /*
+ * cvt may have to round up past the "start" of the
+ * buffer, i.e. ``intf("%.2f", (double)9.999);'';
+ * if the first char isn't NULL, it did.
+ */
+ *buf = NULL;
+ size = cvt(_double, prec, flags, &softsign, *fmt, buf,
+ buf + sizeof(buf));
+ if (softsign)
+ sign = '-';
+ t = *buf ? buf : buf + 1;
+ goto pforw;
+ case 'n':
+ if (flags & LONGINT)
+ *va_arg(argp, long *) = cnt;
+ else if (flags & SHORTINT)
+ *va_arg(argp, short *) = cnt;
+ else
+ *va_arg(argp, int *) = cnt;
+ break;
+ case 'O':
+ flags |= LONGINT;
+ /*FALLTHROUGH*/
+ case 'o':
+ ARG();
+ base = 8;
+ goto nosign;
+ case 'p':
+ /*
+ * ``The argument shall be a pointer to void. The
+ * value of the pointer is converted to a sequence
+ * of printable characters, in an implementation-
+ * defined manner.''
+ * -- ANSI X3J11
+ */
+ /* NOSTRICT */
+ _ulong = (u_long)va_arg(argp, void *);
+ base = 16;
+ goto nosign;
+ case 's':
+ if (!(t = va_arg(argp, char *)))
+ t = "(null)";
+ if (prec >= 0) {
+ /*
+ * can't use strlen; can only look for the
+ * NUL in the first `prec' characters, and
+ * strlen() will go further.
+ */
+ char *p, *memchr();
+
+ if (p = memchr(t, 0, prec)) {
+ size = p - t;
+ if (size > prec)
+ size = prec;
+ } else
+ size = prec;
+ } else
+ size = strlen(t);
+ sign = '\0';
+ goto pforw;
+ case 'U':
+ flags |= LONGINT;
+ /*FALLTHROUGH*/
+ case 'u':
+ ARG();
+ base = 10;
+ goto nosign;
+ case 'X':
+ digs = "0123456789ABCDEF";
+ /* FALLTHROUGH */
+ case 'x':
+ ARG();
+ base = 16;
+ /* leading 0x/X only if non-zero */
+ if (flags & ALT && _ulong != 0)
+ flags |= HEXPREFIX;
+
+ /* unsigned conversions */
+nosign: sign = '\0';
+ /*
+ * ``... diouXx conversions ... if a precision is
+ * specified, the 0 flag will be ignored.''
+ * -- ANSI X3J11
+ */
+number: if ((dprec = prec) >= 0)
+ flags &= ~ZEROPAD;
+
+ /*
+ * ``The result of converting a zero value with an
+ * explicit precision of zero is no characters.''
+ * -- ANSI X3J11
+ */
+ t = buf + BUF;
+ if (_ulong != 0 || prec != 0) {
+ do {
+ *--t = digs[_ulong % base];
+ _ulong /= base;
+ } while (_ulong);
+ digs = "0123456789abcdef";
+ if (flags & ALT && base == 8 && *t != '0')
+ *--t = '0'; /* octal leading 0 */
+ }
+ size = buf + BUF - t;
+
+pforw:
+ /*
+ * All reasonable formats wind up here. At this point,
+ * `t' points to a string which (if not flags&LADJUST)
+ * should be padded out to `width' places. If
+ * flags&ZEROPAD, it should first be prefixed by any
+ * sign or other prefix; otherwise, it should be blank
+ * padded before the prefix is emitted. After any
+ * left-hand padding and prefixing, emit zeroes
+ * required by a decimal [diouxX] precision, then print
+ * the string proper, then emit zeroes required by any
+ * leftover floating precision; finally, if LADJUST,
+ * pad with blanks.
+ */
+
+ /*
+ * compute actual size, so we know how much to pad
+ * fieldsz excludes decimal prec; realsz includes it
+ */
+ fieldsz = size + fpprec;
+ if (sign)
+ fieldsz++;
+ if (flags & HEXPREFIX)
+ fieldsz += 2;
+ realsz = dprec > fieldsz ? dprec : fieldsz;
+
+ /* right-adjusting blank padding */
+ if ((flags & (LADJUST|ZEROPAD)) == 0 && width)
+ for (n = realsz; n < width; n++)
+ PUTC(' ');
+ /* prefix */
+ if (sign)
+ PUTC(sign);
+ if (flags & HEXPREFIX) {
+ PUTC('0');
+ PUTC((char)*fmt);
+ }
+ /* right-adjusting zero padding */
+ if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
+ for (n = realsz; n < width; n++)
+ PUTC('0');
+ /* leading zeroes from decimal precision */
+ for (n = fieldsz; n < dprec; n++)
+ PUTC('0');
+
+ /* the string or number proper */
+ if (fp->_cnt - (n = size) >= 0 &&
+ (fp->_flag & _IOLBF) == 0) {
+ fp->_cnt -= n;
+ bcopy(t, (char *)fp->_ptr, n);
+ fp->_ptr += n;
+ } else
+ while (--n >= 0)
+ PUTC(*t++);
+ /* trailing f.p. zeroes */
+ while (--fpprec >= 0)
+ PUTC('0');
+ /* left-adjusting padding (always blank) */
+ if (flags & LADJUST)
+ for (n = realsz; n < width; n++)
+ PUTC(' ');
+ /* finally, adjust cnt */
+ cnt += width > realsz ? width : realsz;
+ break;
+ case '\0': /* "%?" prints ?, unless ? is NULL */
+ return (cnt);
+ default:
+ PUTC((char)*fmt);
+ cnt++;
+ }
+ }
+ /* NOTREACHED */
+}
+
+static
+cvt(number, prec, flags, signp, fmtch, startp, endp)
+ double number;
+ register int prec;
+ int flags;
+ u_char fmtch;
+ char *signp, *startp, *endp;
+{
+ register char *p, *t;
+ register double fract;
+ int dotrim, expcnt, gformat;
+ double integer, tmp, modf();
+ char *exponent(), *round();
+
+ dotrim = expcnt = gformat = 0;
+ fract = modf(number, &integer);
+
+ /* get an extra slot for rounding. */
+ t = ++startp;
+
+ /*
+ * get integer portion of number; put into the end of the buffer; the
+ * .01 is added for modf(356.0 / 10, &integer) returning .59999999...
+ */
+ for (p = endp - 1; integer; ++expcnt) {
+ tmp = modf(integer / 10, &integer);
+ *p-- = tochar((int)((tmp + .01) * 10));
+ }
+ switch(fmtch) {
+ case 'f':
+ /* reverse integer into beginning of buffer */
+ if (expcnt)
+ for (; ++p < endp; *t++ = *p);
+ else
+ *t++ = '0';
+ /*
+ * if precision required or alternate flag set, add in a
+ * decimal point.
+ */
+ if (prec || flags&ALT)
+ *t++ = '.';
+ /* if requires more precision and some fraction left */
+ if (fract) {
+ if (prec)
+ do {
+ fract = modf(fract * 10, &tmp);
+ *t++ = tochar((int)tmp);
+ } while (--prec && fract);
+ if (fract)
+ startp = round(fract, (int *)NULL, startp,
+ t - 1, (char)0, signp);
+ }
+ for (; prec--; *t++ = '0');
+ break;
+ case 'e':
+ case 'E':
+eformat: if (expcnt) {
+ *t++ = *++p;
+ if (prec || flags&ALT)
+ *t++ = '.';
+ /* if requires more precision and some integer left */
+ for (; prec && ++p < endp; --prec)
+ *t++ = *p;
+ /*
+ * if done precision and more of the integer component,
+ * round using it; adjust fract so we don't re-round
+ * later.
+ */
+ if (!prec && ++p < endp) {
+ fract = 0;
+ startp = round((double)0, &expcnt, startp,
+ t - 1, *p, signp);
+ }
+ /* adjust expcnt for digit in front of decimal */
+ --expcnt;
+ }
+ /* until first fractional digit, decrement exponent */
+ else if (fract) {
+ /* adjust expcnt for digit in front of decimal */
+ for (expcnt = -1;; --expcnt) {
+ fract = modf(fract * 10, &tmp);
+ if (tmp)
+ break;
+ }
+ *t++ = tochar((int)tmp);
+ if (prec || flags&ALT)
+ *t++ = '.';
+ }
+ else {
+ *t++ = '0';
+ if (prec || flags&ALT)
+ *t++ = '.';
+ }
+ /* if requires more precision and some fraction left */
+ if (fract) {
+ if (prec)
+ do {
+ fract = modf(fract * 10, &tmp);
+ *t++ = tochar((int)tmp);
+ } while (--prec && fract);
+ if (fract)
+ startp = round(fract, &expcnt, startp,
+ t - 1, (char)0, signp);
+ }
+ /* if requires more precision */
+ for (; prec--; *t++ = '0');
+
+ /* unless alternate flag, trim any g/G format trailing 0's */
+ if (gformat && !(flags&ALT)) {
+ while (t > startp && *--t == '0');
+ if (*t == '.')
+ --t;
+ ++t;
+ }
+ t = exponent(t, expcnt, fmtch);
+ break;
+ case 'g':
+ case 'G':
+ /* a precision of 0 is treated as a precision of 1. */
+ if (!prec)
+ ++prec;
+ /*
+ * ``The style used depends on the value converted; style e
+ * will be used only if the exponent resulting from the
+ * conversion is less than -4 or greater than the precision.''
+ * -- ANSI X3J11
+ */
+ if (expcnt > prec || !expcnt && fract && fract < .0001) {
+ /*
+ * g/G format counts "significant digits, not digits of
+ * precision; for the e/E format, this just causes an
+ * off-by-one problem, i.e. g/G considers the digit
+ * before the decimal point significant and e/E doesn't
+ * count it as precision.
+ */
+ --prec;
+ fmtch -= 2; /* G->E, g->e */
+ gformat = 1;
+ goto eformat;
+ }
+ /*
+ * reverse integer into beginning of buffer,
+ * note, decrement precision
+ */
+ if (expcnt)
+ for (; ++p < endp; *t++ = *p, --prec);
+ else
+ *t++ = '0';
+ /*
+ * if precision required or alternate flag set, add in a
+ * decimal point. If no digits yet, add in leading 0.
+ */
+ if (prec || flags&ALT) {
+ dotrim = 1;
+ *t++ = '.';
+ }
+ else
+ dotrim = 0;
+ /* if requires more precision and some fraction left */
+ if (fract) {
+ if (prec) {
+ do {
+ fract = modf(fract * 10, &tmp);
+ *t++ = tochar((int)tmp);
+ } while(!tmp);
+ while (--prec && fract) {
+ fract = modf(fract * 10, &tmp);
+ *t++ = tochar((int)tmp);
+ }
+ }
+ if (fract)
+ startp = round(fract, (int *)NULL, startp,
+ t - 1, (char)0, signp);
+ }
+ /* alternate format, adds 0's for precision, else trim 0's */
+ if (flags&ALT)
+ for (; prec--; *t++ = '0');
+ else if (dotrim) {
+ while (t > startp && *--t == '0');
+ if (*t != '.')
+ ++t;
+ }
+ }
+ return(t - startp);
+}
+
+static char *
+round(fract, exp, start, end, ch, signp)
+ double fract;
+ int *exp;
+ register char *start, *end;
+ char ch, *signp;
+{
+ double tmp;
+
+ if (fract)
+ (void)modf(fract * 10, &tmp);
+ else
+ tmp = todigit(ch);
+ if (tmp > 4)
+ for (;; --end) {
+ if (*end == '.')
+ --end;
+ if (++*end <= '9')
+ break;
+ *end = '0';
+ if (end == start) {
+ if (exp) { /* e/E; increment exponent */
+ *end = '1';
+ ++*exp;
+ }
+ else { /* f; add extra digit */
+ *--end = '1';
+ --start;
+ }
+ break;
+ }
+ }
+ /* ``"%.3f", (double)-0.0004'' gives you a negative 0. */
+ else if (*signp == '-')
+ for (;; --end) {
+ if (*end == '.')
+ --end;
+ if (*end != '0')
+ break;
+ if (end == start)
+ *signp = 0;
+ }
+ return(start);
+}
+
+static char *
+exponent(p, exp, fmtch)
+ register char *p;
+ register int exp;
+ u_char fmtch;
+{
+ register char *t;
+ char expbuf[MAXEXP];
+
+ *p++ = fmtch;
+ if (exp < 0) {
+ exp = -exp;
+ *p++ = '-';
+ }
+ else
+ *p++ = '+';
+ t = expbuf + MAXEXP;
+ if (exp > 9) {
+ do {
+ *--t = tochar(exp % 10);
+ } while ((exp /= 10) > 9);
+ *--t = tochar(exp);
+ for (; t < expbuf + MAXEXP; *p++ = *t++);
+ }
+ else {
+ *p++ = '0';
+ *p++ = tochar(exp);
+ }
+ return(p);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)doscan.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <ctype.h>
+#include <varargs.h>
+
+#define SPC 01
+#define STP 02
+
+#define SHORT 0
+#define REGULAR 1
+#define LONG 2
+#define INT 0
+#define FLOAT 1
+
+static char *_getccl();
+
+static char _sctab[256] = {
+ 0,0,0,0,0,0,0,0,
+ 0,SPC,SPC,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ SPC,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+};
+
+_doscan(iop, fmt, ap)
+FILE *iop;
+register char *fmt;
+register va_list ap;
+{
+ register int ch;
+ int nmatch, len, ch1;
+ int *ptr, fileended, size;
+
+ nmatch = 0;
+ fileended = 0;
+ for (;;) switch (ch = *fmt++) {
+ case '\0':
+ return (nmatch);
+ case '%':
+ if ((ch = *fmt++) == '%')
+ goto def;
+ ptr = 0;
+ if (ch != '*')
+ ptr = va_arg(ap, int *);
+ else
+ ch = *fmt++;
+ len = 0;
+ size = REGULAR;
+ while (isdigit(ch)) {
+ len = len*10 + ch - '0';
+ ch = *fmt++;
+ }
+ if (len == 0)
+ len = 30000;
+ if (ch=='l') {
+ size = LONG;
+ ch = *fmt++;
+ } else if (ch=='h') {
+ size = SHORT;
+ ch = *fmt++;
+ } else if (ch=='[')
+ fmt = _getccl(fmt);
+ if (isupper(ch)) {
+ ch = tolower(ch);
+ size = LONG;
+ }
+ if (ch == '\0')
+ return(-1);
+ if (_innum(ptr, ch, len, size, iop, &fileended) && ptr)
+ nmatch++;
+ if (fileended)
+ return(nmatch? nmatch: -1);
+ break;
+
+ case ' ':
+ case '\n':
+ case '\t':
+ while ((ch1 = getc(iop))==' ' || ch1=='\t' || ch1=='\n')
+ ;
+ if (ch1 != EOF)
+ ungetc(ch1, iop);
+ break;
+
+ default:
+ def:
+ ch1 = getc(iop);
+ if (ch1 != ch) {
+ if (ch1==EOF)
+ return(-1);
+ ungetc(ch1, iop);
+ return(nmatch);
+ }
+ }
+}
+
+static
+_innum(ptr, type, len, size, iop, eofptr)
+int *ptr, *eofptr;
+FILE *iop;
+{
+ extern double atof();
+ register char *np;
+ char numbuf[64];
+ register c, base;
+ int expseen, scale, negflg, c1, ndigit;
+ long lcval;
+
+ if (type=='c' || type=='s' || type=='[')
+ return(_instr(ptr? (char *)ptr: (char *)NULL, type, len, iop, eofptr));
+ lcval = 0;
+ ndigit = 0;
+ scale = INT;
+ if (type=='e'||type=='f')
+ scale = FLOAT;
+ base = 10;
+ if (type=='o')
+ base = 8;
+ else if (type=='x')
+ base = 16;
+ np = numbuf;
+ expseen = 0;
+ negflg = 0;
+ while ((c = getc(iop))==' ' || c=='\t' || c=='\n');
+ if (c=='-') {
+ negflg++;
+ *np++ = c;
+ c = getc(iop);
+ len--;
+ } else if (c=='+') {
+ len--;
+ c = getc(iop);
+ }
+ for ( ; --len>=0; *np++ = c, c = getc(iop)) {
+ if (isdigit(c)
+ || base==16 && ('a'<=c && c<='f' || 'A'<=c && c<='F')) {
+ ndigit++;
+ if (base==8)
+ lcval <<=3;
+ else if (base==10)
+ lcval = ((lcval<<2) + lcval)<<1;
+ else
+ lcval <<= 4;
+ c1 = c;
+ if (isdigit(c))
+ c -= '0';
+ else if ('a'<=c && c<='f')
+ c -= 'a'-10;
+ else
+ c -= 'A'-10;
+ lcval += c;
+ c = c1;
+ continue;
+ } else if (c=='.') {
+ if (base!=10 || scale==INT)
+ break;
+ ndigit++;
+ continue;
+ } else if ((c=='e'||c=='E') && expseen==0) {
+ if (base!=10 || scale==INT || ndigit==0)
+ break;
+ expseen++;
+ *np++ = c;
+ c = getc(iop);
+ if (c!='+'&&c!='-'&&('0'>c||c>'9'))
+ break;
+ } else
+ break;
+ }
+ if (negflg)
+ lcval = -lcval;
+ if (c != EOF) {
+ ungetc(c, iop);
+ *eofptr = 0;
+ } else
+ *eofptr = 1;
+ if (ptr==NULL || np==numbuf || (negflg && np==numbuf+1) )/* gene dykes*/
+ return(0);
+ *np++ = 0;
+ switch((scale<<4) | size) {
+
+ case (FLOAT<<4) | SHORT:
+ case (FLOAT<<4) | REGULAR:
+ *(float *)ptr = atof(numbuf);
+ break;
+
+ case (FLOAT<<4) | LONG:
+ *(double *)ptr = atof(numbuf);
+ break;
+
+ case (INT<<4) | SHORT:
+ *(short *)ptr = lcval;
+ break;
+
+ case (INT<<4) | REGULAR:
+ *(int *)ptr = lcval;
+ break;
+
+ case (INT<<4) | LONG:
+ *(long *)ptr = lcval;
+ break;
+ }
+ return(1);
+}
+
+static
+_instr(ptr, type, len, iop, eofptr)
+register char *ptr;
+register FILE *iop;
+int *eofptr;
+{
+ register ch;
+ register char *optr;
+ int ignstp;
+
+ *eofptr = 0;
+ optr = ptr;
+ if (type=='c' && len==30000)
+ len = 1;
+ ignstp = 0;
+ if (type=='s')
+ ignstp = SPC;
+ while ((ch = getc(iop)) != EOF && _sctab[ch] & ignstp)
+ ;
+ ignstp = SPC;
+ if (type=='c')
+ ignstp = 0;
+ else if (type=='[')
+ ignstp = STP;
+ while (ch!=EOF && (_sctab[ch]&ignstp)==0) {
+ if (ptr)
+ *ptr++ = ch;
+ if (--len <= 0)
+ break;
+ ch = getc(iop);
+ }
+ if (ch != EOF) {
+ if (len > 0)
+ ungetc(ch, iop);
+ *eofptr = 0;
+ } else
+ *eofptr = 1;
+ if (ptr && ptr!=optr) {
+ if (type!='c')
+ *ptr++ = '\0';
+ return(1);
+ }
+ return(0);
+}
+
+static char *
+_getccl(s)
+register unsigned char *s;
+{
+ register c, t;
+
+ t = 0;
+ if (*s == '^') {
+ t++;
+ s++;
+ }
+ for (c = 0; c < (sizeof _sctab / sizeof _sctab[0]); c++)
+ if (t)
+ _sctab[c] &= ~STP;
+ else
+ _sctab[c] |= STP;
+ if ((c = *s) == ']' || c == '-') { /* first char is special */
+ if (t)
+ _sctab[c] |= STP;
+ else
+ _sctab[c] &= ~STP;
+ s++;
+ }
+ while ((c = *s++) != ']') {
+ if (c==0)
+ return((char *)--s);
+ else if (c == '-' && *s != ']' && s[-2] < *s) {
+ for (c = s[-2] + 1; c < *s; c++)
+ if (t)
+ _sctab[c] |= STP;
+ else
+ _sctab[c] &= ~STP;
+ } else if (t)
+ _sctab[c] |= STP;
+ else
+ _sctab[c] &= ~STP;
+ }
+ return((char *)s);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)exit.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+exit(code)
+ int code;
+{
+
+ _cleanup();
+ _exit(code);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fdopen.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Unix routine to do an "fopen" on file descriptor
+ * The mode has to be repeated because you can't query its
+ * status
+ */
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <stdio.h>
+
+FILE *
+fdopen(fd, mode)
+ register char *mode;
+{
+ extern FILE *_findiop();
+ static int nofile = -1;
+ register FILE *iop;
+
+ if (nofile < 0)
+ nofile = getdtablesize();
+
+ if (fd < 0 || fd >= nofile)
+ return (NULL);
+
+ iop = _findiop();
+ if (iop == NULL)
+ return (NULL);
+
+ iop->_cnt = 0;
+ iop->_file = fd;
+ iop->_bufsiz = 0;
+ iop->_base = iop->_ptr = NULL;
+
+ switch (*mode) {
+ case 'r':
+ iop->_flag = _IOREAD;
+ break;
+ case 'a':
+ lseek(fd, (off_t)0, L_XTND);
+ /* fall into ... */
+ case 'w':
+ iop->_flag = _IOWRT;
+ break;
+ default:
+ return (NULL);
+ }
+
+ if (mode[1] == '+')
+ iop->_flag = _IORW;
+
+ return (iop);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fgetc.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+fgetc(fp)
+FILE *fp;
+{
+ return(getc(fp));
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fgets.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+char *
+fgets(s, n, iop)
+char *s;
+register FILE *iop;
+{
+ register c;
+ register char *cs;
+
+ cs = s;
+ while (--n>0 && (c = getc(iop)) != EOF) {
+ *cs++ = c;
+ if (c=='\n')
+ break;
+ }
+ if (c == EOF && cs==s)
+ return(NULL);
+ *cs++ = '\0';
+ return(s);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)filbuf.c 5.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+char *malloc();
+
+_filbuf(iop)
+register FILE *iop;
+{
+ int size;
+ struct stat stbuf;
+ extern char *_smallbuf;
+ char c;
+
+ if (iop->_flag & _IORW)
+ iop->_flag |= _IOREAD;
+
+ if ((iop->_flag&_IOREAD) == 0)
+ return(EOF);
+ if (iop->_flag&(_IOSTRG|_IOEOF))
+ return(EOF);
+tryagain:
+ if (iop->_base==NULL) {
+ if (iop->_flag&_IONBF) {
+ iop->_base = _smallbuf ? &_smallbuf[fileno(iop)] : &c;
+ goto tryagain;
+ }
+ if (fstat(fileno(iop), &stbuf) < 0 || stbuf.st_blksize <= NULL)
+ size = BUFSIZ;
+ else
+ size = stbuf.st_blksize;
+ if ((iop->_base = malloc(size)) == NULL) {
+ iop->_flag |= _IONBF;
+ goto tryagain;
+ }
+ iop->_flag |= _IOMYBUF;
+ iop->_bufsiz = size;
+ }
+ if (iop == stdin) {
+ if (stdout->_flag&_IOLBF)
+ fflush(stdout);
+ if (stderr->_flag&_IOLBF)
+ fflush(stderr);
+ }
+ iop->_cnt = read(fileno(iop), iop->_base,
+ iop->_flag & _IONBF ? 1 : iop->_bufsiz);
+ iop->_ptr = iop->_base;
+ if (iop->_flag & _IONBF && iop->_base == &c)
+ iop->_base = NULL;
+ if (--iop->_cnt < 0) {
+ if (iop->_cnt == -1) {
+ iop->_flag |= _IOEOF;
+ if (iop->_flag & _IORW)
+ iop->_flag &= ~_IOREAD;
+ } else
+ iop->_flag |= _IOERR;
+ iop->_cnt = 0;
+ return(EOF);
+ }
+ return(*iop->_ptr++&0377);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983, 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)findiop.c 5.6 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <errno.h>
+
+extern int errno;
+
+#define active(iop) ((iop)->_flag & (_IOREAD|_IOWRT|_IORW))
+
+#define NSTATIC 20 /* stdin + stdout + stderr + the usual */
+
+FILE _iob[NSTATIC] = {
+ { 0, NULL, NULL, 0, _IOREAD, 0 }, /* stdin */
+ { 0, NULL, NULL, 0, _IOWRT, 1 }, /* stdout */
+ { 0, NULL, NULL, 0, _IOWRT|_IONBF, 2 }, /* stderr */
+};
+
+extern char *calloc();
+
+static char sbuf[NSTATIC];
+char *_smallbuf = sbuf;
+static FILE **iobglue;
+static FILE **endglue;
+
+/*
+ * Find a free FILE for fopen et al.
+ * We have a fixed static array of entries, and in addition
+ * may allocate additional entries dynamically, up to the kernel
+ * limit on the number of open files.
+ * At first just check for a free slot in the fixed static array.
+ * If none are available, then we allocate a structure to glue together
+ * the old and new FILE entries, which are then no longer contiguous.
+ */
+FILE *
+_findiop()
+{
+ register FILE **iov, *iop;
+ register FILE *fp;
+
+ if (iobglue == 0) {
+ for (iop = _iob; iop < _iob + NSTATIC; iop++)
+ if (!active(iop))
+ return (iop);
+
+ if (_f_morefiles() == 0) {
+ errno = ENOMEM;
+ return (NULL);
+ }
+ }
+
+ iov = iobglue;
+ while (*iov != NULL && active(*iov))
+ if (++iov >= endglue) {
+ errno = EMFILE;
+ return (NULL);
+ }
+
+ if (*iov == NULL)
+ *iov = (FILE *)calloc(1, sizeof **iov);
+
+ return (*iov);
+}
+
+_f_morefiles()
+{
+ register FILE **iov;
+ register FILE *fp;
+ register char *cp;
+ int nfiles;
+
+ nfiles = getdtablesize();
+
+ iobglue = (FILE **)calloc(nfiles, sizeof *iobglue);
+ if (iobglue == NULL)
+ return (0);
+
+ endglue = iobglue + nfiles;
+
+ for (fp = _iob, iov = iobglue; fp < &_iob[NSTATIC]; /* void */)
+ *iov++ = fp++;
+
+ _smallbuf = calloc(nfiles, sizeof(*_smallbuf));
+ return (1);
+}
+
+f_prealloc()
+{
+ register FILE **iov;
+ register FILE *fp;
+
+ if (iobglue == NULL && _f_morefiles() == 0)
+ return;
+
+ for (iov = iobglue; iov < endglue; iov++)
+ if (*iov == NULL)
+ *iov = (FILE *)calloc(1, sizeof **iov);
+}
+
+_fwalk(function)
+ register int (*function)();
+{
+ register FILE **iov;
+ register FILE *fp;
+
+ if (iobglue == NULL) {
+ for (fp = _iob; fp < &_iob[NSTATIC]; fp++)
+ if (active(fp))
+ (*function)(fp);
+ } else {
+ for (iov = iobglue; iov < endglue; iov++)
+ if (*iov && active(*iov))
+ (*function)(*iov);
+ }
+}
+
+_cleanup()
+{
+ extern int fclose();
+
+ _fwalk(fclose);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)flsbuf.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+char *malloc();
+
+_flsbuf(c, iop)
+unsigned char c;
+register FILE *iop;
+{
+ register char *base;
+ register n, rn;
+ char c1;
+ int size;
+ struct stat stbuf;
+
+ if (iop->_flag & _IORW) {
+ iop->_flag |= _IOWRT;
+ iop->_flag &= ~(_IOEOF|_IOREAD);
+ }
+
+ if ((iop->_flag&_IOWRT)==0)
+ return(EOF);
+tryagain:
+ if (iop->_flag&_IOLBF) {
+ base = iop->_base;
+ *iop->_ptr++ = c;
+ if (iop->_ptr >= base+iop->_bufsiz || c == '\n') {
+ n = write(fileno(iop), base, rn = iop->_ptr - base);
+ iop->_ptr = base;
+ iop->_cnt = 0;
+ } else
+ rn = n = 0;
+ } else if (iop->_flag&_IONBF) {
+ c1 = c;
+ rn = 1;
+ n = write(fileno(iop), &c1, rn);
+ iop->_cnt = 0;
+ } else {
+ if ((base=iop->_base)==NULL) {
+ if (fstat(fileno(iop), &stbuf) < 0 ||
+ stbuf.st_blksize <= NULL)
+ size = BUFSIZ;
+ else
+ size = stbuf.st_blksize;
+ if ((iop->_base=base=malloc(size)) == NULL) {
+ iop->_flag |= _IONBF;
+ goto tryagain;
+ }
+ iop->_flag |= _IOMYBUF;
+ iop->_bufsiz = size;
+ if (iop==stdout && isatty(fileno(stdout))) {
+ iop->_flag |= _IOLBF;
+ iop->_ptr = base;
+ goto tryagain;
+ }
+ rn = n = 0;
+ } else if ((rn = n = iop->_ptr - base) > 0) {
+ iop->_ptr = base;
+ n = write(fileno(iop), base, n);
+ }
+ iop->_cnt = iop->_bufsiz-1;
+ *base++ = c;
+ iop->_ptr = base;
+ }
+ if (rn != n) {
+ iop->_flag |= _IOERR;
+ return(EOF);
+ }
+ return(c);
+}
+
+fflush(iop)
+register FILE *iop;
+{
+ register char *base;
+ register n;
+
+ if ((iop->_flag&(_IONBF|_IOWRT))==_IOWRT
+ && (base=iop->_base)!=NULL && (n=iop->_ptr-base)>0) {
+ iop->_ptr = base;
+ iop->_cnt = (iop->_flag&(_IOLBF|_IONBF)) ? 0 : iop->_bufsiz;
+ if (write(fileno(iop), base, n)!=n) {
+ iop->_flag |= _IOERR;
+ return(EOF);
+ }
+ }
+ return(0);
+}
+
+fclose(iop)
+ register FILE *iop;
+{
+ register int r;
+
+ r = EOF;
+ if (iop->_flag&(_IOREAD|_IOWRT|_IORW) && (iop->_flag&_IOSTRG)==0) {
+ r = fflush(iop);
+ if (close(fileno(iop)) < 0)
+ r = EOF;
+ if (iop->_flag&_IOMYBUF)
+ free(iop->_base);
+ }
+ iop->_cnt = 0;
+ iop->_base = (char *)NULL;
+ iop->_ptr = (char *)NULL;
+ iop->_bufsiz = 0;
+ iop->_flag = 0;
+ iop->_file = 0;
+ return(r);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fopen.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <stdio.h>
+
+FILE *
+fopen(file, mode)
+ char *file;
+ register char *mode;
+{
+ register FILE *iop;
+ register f, rw, oflags;
+ extern FILE *_findiop();
+
+ iop = _findiop();
+ if (iop == NULL)
+ return (NULL);
+
+ rw = (mode[1] == '+');
+
+ switch (*mode) {
+ case 'a':
+ oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY);
+ break;
+ case 'r':
+ oflags = rw ? O_RDWR : O_RDONLY;
+ break;
+ case 'w':
+ oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY);
+ break;
+ default:
+ return (NULL);
+ }
+
+ f = open(file, oflags, 0666);
+ if (f < 0)
+ return (NULL);
+
+ if (*mode == 'a')
+ lseek(f, (off_t)0, L_XTND);
+
+ iop->_cnt = 0;
+ iop->_file = f;
+ iop->_bufsiz = 0;
+ if (rw)
+ iop->_flag = _IORW;
+ else if (*mode == 'r')
+ iop->_flag = _IOREAD;
+ else
+ iop->_flag = _IOWRT;
+ iop->_base = iop->_ptr = NULL;
+ return (iop);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fprintf.c 5.4 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <varargs.h>
+
+fprintf(iop, fmt, va_alist)
+ register FILE *iop;
+ char *fmt;
+ va_dcl
+{
+ va_list ap;
+ int len;
+ char localbuf[BUFSIZ];
+
+ va_start(ap);
+ if (iop->_flag & _IONBF) {
+ iop->_flag &= ~_IONBF;
+ iop->_ptr = iop->_base = localbuf;
+ iop->_bufsiz = BUFSIZ;
+ len = _doprnt(fmt, ap, iop);
+ fflush(iop);
+ iop->_flag |= _IONBF;
+ iop->_base = NULL;
+ iop->_bufsiz = NULL;
+ iop->_cnt = 0;
+ } else
+ len = _doprnt(fmt, ap, iop);
+ va_end(ap);
+ return(ferror(iop) ? EOF : len);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fputc.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+fputc(c, fp)
+register FILE *fp;
+{
+ return(putc(c, fp));
+}
--- /dev/null
+/*
+ * Copyright (c) 1984 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fputs.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+fputs(s, iop)
+register char *s;
+register FILE *iop;
+{
+ register r = 0;
+ register c;
+ int unbuffered;
+ char localbuf[BUFSIZ];
+
+ unbuffered = iop->_flag & _IONBF;
+ if (unbuffered) {
+ iop->_flag &= ~_IONBF;
+ iop->_ptr = iop->_base = localbuf;
+ iop->_bufsiz = BUFSIZ;
+ }
+
+ while (c = *s++)
+ r = putc(c, iop);
+
+ if (unbuffered) {
+ fflush(iop);
+ iop->_flag |= _IONBF;
+ iop->_base = NULL;
+ iop->_bufsiz = NULL;
+ iop->_cnt = 0;
+ }
+
+ return(r);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fread.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+fread(ptr, size, count, iop)
+ register char *ptr;
+ unsigned size, count;
+ register FILE *iop;
+{
+ register int s;
+ int c;
+
+ s = size * count;
+ while (s > 0) {
+ if (iop->_cnt < s) {
+ if (iop->_cnt > 0) {
+ bcopy(iop->_ptr, ptr, iop->_cnt);
+ ptr += iop->_cnt;
+ s -= iop->_cnt;
+ }
+ /*
+ * filbuf clobbers _cnt & _ptr,
+ * so don't waste time setting them.
+ */
+ if ((c = _filbuf(iop)) == EOF)
+ break;
+ *ptr++ = c;
+ s--;
+ }
+ if (iop->_cnt >= s) {
+ bcopy(iop->_ptr, ptr, s);
+ iop->_ptr += s;
+ iop->_cnt -= s;
+ return (count);
+ }
+ }
+ return (size != 0 ? count - ((s + size - 1) / size) : 0);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)freopen.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <sys/types.h>
+#include <sys/file.h>
+#include <stdio.h>
+
+FILE *
+freopen(file, mode, iop)
+ char *file;
+ register char *mode;
+ register FILE *iop;
+{
+ register f, rw, oflags;
+
+ rw = (mode[1] == '+');
+
+ fclose(iop);
+
+ switch (*mode) {
+ case 'a':
+ oflags = O_CREAT | (rw ? O_RDWR : O_WRONLY);
+ break;
+ case 'r':
+ oflags = rw ? O_RDWR : O_RDONLY;
+ break;
+ case 'w':
+ oflags = O_TRUNC | O_CREAT | (rw ? O_RDWR : O_WRONLY);
+ break;
+ default:
+ return (NULL);
+ }
+
+ f = open(file, oflags, 0666);
+ if (f < 0)
+ return (NULL);
+
+ if (*mode == 'a')
+ lseek(f, (off_t)0, L_XTND);
+
+ iop->_cnt = 0;
+ iop->_file = f;
+ iop->_bufsiz = 0;
+ if (rw)
+ iop->_flag = _IORW;
+ else if (*mode == 'r')
+ iop->_flag = _IOREAD;
+ else
+ iop->_flag = _IOWRT;
+ iop->_base = iop->_ptr = NULL;
+ return (iop);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fseek.c 5.3 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Seek for standard library. Coordinates with buffering.
+ */
+
+#include <stdio.h>
+
+long lseek();
+
+fseek(iop, offset, ptrname)
+ register FILE *iop;
+ long offset;
+{
+ register resync, c;
+ long p = -1; /* can't happen? */
+
+ iop->_flag &= ~_IOEOF;
+ if (iop->_flag&_IOREAD) {
+ if (ptrname<2 && iop->_base &&
+ !(iop->_flag&_IONBF)) {
+ c = iop->_cnt;
+ p = offset;
+ if (ptrname==0) {
+ long curpos = lseek(fileno(iop), 0L, 1);
+ if (curpos == -1)
+ return (-1);
+ p += c - curpos;
+ } else
+ offset -= c;
+ if(!(iop->_flag&_IORW) && c>0&&p<=c
+ && p>=iop->_base-iop->_ptr){
+ iop->_ptr += (int)p;
+ iop->_cnt -= (int)p;
+ return(0);
+ }
+ resync = offset&01;
+ } else
+ resync = 0;
+ if (iop->_flag & _IORW) {
+ iop->_ptr = iop->_base;
+ iop->_flag &= ~_IOREAD;
+ resync = 0;
+ }
+ p = lseek(fileno(iop), offset-resync, ptrname);
+ iop->_cnt = 0;
+ if (resync && p != -1)
+ if (getc(iop) == EOF)
+ p = -1;
+ }
+ else if (iop->_flag & (_IOWRT|_IORW)) {
+ p = fflush(iop);
+ if (iop->_flag & _IORW) {
+ iop->_cnt = 0;
+ iop->_flag &= ~_IOWRT;
+ iop->_ptr = iop->_base;
+ }
+ return(lseek(fileno(iop), offset, ptrname) == -1 || p == EOF ?
+ -1 : 0);
+ }
+ return(p==-1?-1:0);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ftell.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Return file offset.
+ * Coordinates with buffering.
+ */
+
+#include <stdio.h>
+long lseek();
+
+
+long ftell(iop)
+register FILE *iop;
+{
+ register long tres;
+ register adjust;
+
+ if (iop->_cnt < 0)
+ iop->_cnt = 0;
+ if (iop->_flag&_IOREAD)
+ adjust = - iop->_cnt;
+ else if (iop->_flag&(_IOWRT|_IORW)) {
+ adjust = 0;
+ if (iop->_flag&_IOWRT && iop->_base && (iop->_flag&_IONBF)==0)
+ adjust = iop->_ptr - iop->_base;
+ } else
+ return(-1);
+ tres = lseek(fileno(iop), 0L, 1);
+ if (tres<0)
+ return(tres);
+ tres += adjust;
+ return(tres);
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fwrite.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+fwrite(ptr, size, count, iop)
+ register char *ptr;
+ unsigned size, count;
+ register FILE *iop;
+{
+ register int s;
+
+ s = size * count;
+ if (iop->_flag & _IOLBF)
+ while (s > 0) {
+ if (--iop->_cnt > -iop->_bufsiz && *ptr != '\n')
+ *iop->_ptr++ = *ptr++;
+ else if (_flsbuf(*(unsigned char *)ptr++, iop) == EOF)
+ break;
+ s--;
+ }
+ else while (s > 0) {
+ if (iop->_cnt < s) {
+ if (iop->_cnt > 0) {
+ bcopy(ptr, iop->_ptr, iop->_cnt);
+ ptr += iop->_cnt;
+ iop->_ptr += iop->_cnt;
+ s -= iop->_cnt;
+ }
+ if (_flsbuf(*(unsigned char *)ptr++, iop) == EOF)
+ break;
+ s--;
+ }
+ if (iop->_cnt >= s) {
+ bcopy(ptr, iop->_ptr, s);
+ iop->_ptr += s;
+ iop->_cnt -= s;
+ return (count);
+ }
+ }
+ return (size != 0 ? count - ((s + size - 1) / size) : 0);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getchar.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * A subroutine version of the macro getchar.
+ */
+#include <stdio.h>
+
+#undef getchar
+
+getchar()
+{
+ return(getc(stdin));
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)gets.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+char *
+gets(s)
+char *s;
+{
+ register c;
+ register char *cs;
+
+ cs = s;
+ while ((c = getchar()) != '\n' && c != EOF)
+ *cs++ = c;
+ if (c == EOF && cs==s)
+ return(NULL);
+ *cs++ = '\0';
+ return(s);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)getw.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+getw(iop)
+register FILE *iop;
+{
+ register i;
+ register char *p;
+ int w;
+
+ p = (char *)&w;
+ for (i=sizeof(int); --i>=0;)
+ *p++ = getc(iop);
+ if (feof(iop))
+ return(EOF);
+ return(w);
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)printf.c 5.4 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <varargs.h>
+
+printf(fmt, va_alist)
+ char *fmt;
+ va_dcl
+{
+ va_list ap;
+ int len;
+
+ va_start(ap);
+ len = _doprnt(fmt, ap, stdout);
+ va_end(ap);
+ return(ferror(stdout) ? EOF : len);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)putchar.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * A subroutine version of the macro putchar
+ */
+#include <stdio.h>
+
+#undef putchar
+
+putchar(c)
+register c;
+{
+ putc(c, stdout);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)puts.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+puts(s)
+register char *s;
+{
+ register c;
+
+ while (c = *s++)
+ putchar(c);
+ return(putchar('\n'));
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)putw.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+putw(w, iop)
+register FILE *iop;
+{
+ register char *p;
+ register i;
+
+ p = (char *)&w;
+ for (i=sizeof(int); --i>=0;)
+ putc(*p++, iop);
+ return(ferror(iop));
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rew.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+rewind(iop)
+register FILE *iop;
+{
+ fflush(iop);
+ lseek(fileno(iop), 0L, 0);
+ iop->_cnt = 0;
+ iop->_ptr = iop->_base;
+ iop->_flag &= ~(_IOERR|_IOEOF);
+ if (iop->_flag & _IORW)
+ iop->_flag &= ~(_IOREAD|_IOWRT);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)scanf.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+#include <varargs.h>
+
+scanf(fmt, va_alist)
+char *fmt;
+va_dcl
+{
+ va_list ap;
+ int len;
+
+ va_start(ap);
+ len = _doscan(stdin, fmt, &args);
+ va_end(ap);
+ return len;
+}
+
+fscanf(iop, fmt, va_alist)
+FILE *iop;
+char *fmt;
+va_dcl
+{
+ va_list ap;
+ int len;
+
+ va_start(ap);
+ len = _doscan(iop, fmt, &args);
+ va_end(ap);
+ return len;
+}
+
+sscanf(str, fmt, va_alist)
+register char *str;
+char *fmt;
+va_dcl
+{
+ FILE _strbuf;
+ va_list ap;
+ int len;
+
+ va_start(ap);
+ _strbuf._flag = _IOREAD|_IOSTRG;
+ _strbuf._ptr = _strbuf._base = str;
+ _strbuf._cnt = 0;
+ while (*str++)
+ _strbuf._cnt++;
+ _strbuf._bufsiz = _strbuf._cnt;
+ len = _doscan(&_strbuf, fmt, &args);
+ va_end(ap);
+ return len;
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)setbuf.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+setbuf(iop, buf)
+register FILE *iop;
+char *buf;
+{
+ if (iop->_base != NULL && iop->_flag&_IOMYBUF)
+ free(iop->_base);
+ iop->_flag &= ~(_IOMYBUF|_IONBF|_IOLBF);
+ if ((iop->_base = buf) == NULL) {
+ iop->_flag |= _IONBF;
+ iop->_bufsiz = NULL;
+ } else {
+ iop->_ptr = iop->_base;
+ iop->_bufsiz = BUFSIZ;
+ }
+ iop->_cnt = 0;
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)setbuffer.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+setbuffer(iop, buf, size)
+ register FILE *iop;
+ char *buf;
+ int size;
+{
+ if (iop->_base != NULL && iop->_flag&_IOMYBUF)
+ free(iop->_base);
+ iop->_flag &= ~(_IOMYBUF|_IONBF|_IOLBF);
+ if ((iop->_base = buf) == NULL) {
+ iop->_flag |= _IONBF;
+ iop->_bufsiz = NULL;
+ } else {
+ iop->_ptr = iop->_base;
+ iop->_bufsiz = size;
+ }
+ iop->_cnt = 0;
+}
+
+/*
+ * set line buffering for either stdout or stderr
+ */
+setlinebuf(iop)
+ register FILE *iop;
+{
+ char *buf;
+ extern char *malloc();
+
+ fflush(iop);
+ setbuffer(iop, NULL, 0);
+ buf = malloc(BUFSIZ);
+ if (buf != NULL) {
+ setbuffer(iop, buf, BUFSIZ);
+ iop->_flag |= _IOLBF|_IOMYBUF;
+ }
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)sibuf.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+char _sibuf[BUFSIZ];
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)sobuf.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+char _sobuf[BUFSIZ];
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)sprintf.c 5.5 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <varargs.h>
+
+sprintf(str, fmt, va_alist)
+ char *str, *fmt;
+ va_dcl
+{
+ va_list ap;
+ FILE _strbuf;
+ int len;
+
+ va_start(ap);
+ _strbuf._flag = _IOWRT+_IOSTRG;
+ _strbuf._ptr = str;
+ _strbuf._cnt = 32767;
+ len = _doprnt(fmt, ap, &_strbuf);
+ *_strbuf._ptr = 0;
+ va_end(ap);
+ return(len);
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strout.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+_strout(count, string, adjust, file, fillch)
+register char *string;
+register count;
+int adjust;
+register FILE *file;
+{
+ while (adjust < 0) {
+ if (*string=='-' && fillch=='0') {
+ putc(*string++, file);
+ count--;
+ }
+ putc(fillch, file);
+ adjust++;
+ }
+ while (--count>=0)
+ putc(*string++, file);
+ while (adjust) {
+ putc(fillch, file);
+ adjust--;
+ }
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ungetc.c 5.3 (Berkeley) 3/26/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+ungetc(c, iop)
+ register FILE *iop;
+{
+ if (c == EOF || (iop->_flag & (_IOREAD|_IORW)) == 0 ||
+ iop->_ptr == NULL || iop->_base == NULL)
+ return (EOF);
+
+ if (iop->_ptr == iop->_base)
+ if (iop->_cnt == 0)
+ iop->_ptr++;
+ else
+ return (EOF);
+
+ iop->_cnt++;
+ *--iop->_ptr = c;
+
+ return (c);
+}
--- /dev/null
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)vfprintf.c 5.2 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <varargs.h>
+
+int
+vfprintf(iop, fmt, ap)
+ FILE *iop;
+ char *fmt;
+ va_list ap;
+{
+ int len;
+ char localbuf[BUFSIZ];
+
+ if (iop->_flag & _IONBF) {
+ iop->_flag &= ~_IONBF;
+ iop->_ptr = iop->_base = localbuf;
+ len = _doprnt(fmt, ap, iop);
+ (void) fflush(iop);
+ iop->_flag |= _IONBF;
+ iop->_base = NULL;
+ iop->_bufsiz = 0;
+ iop->_cnt = 0;
+ } else
+ len = _doprnt(fmt, ap, iop);
+
+ return (ferror(iop) ? EOF : len);
+}
--- /dev/null
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)vprintf.c 5.2 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <varargs.h>
+
+int
+vprintf(fmt, ap)
+ char *fmt;
+ va_list ap;
+{
+ int len;
+
+ len = _doprnt(fmt, ap, stdout);
+ return (ferror(stdout) ? EOF : len);
+}
--- /dev/null
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)vsprintf.c 5.2 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+#include <varargs.h>
+
+int
+vsprintf(str, fmt, ap)
+ char *str, *fmt;
+ va_list ap;
+{
+ FILE f;
+ int len;
+
+ f._flag = _IOWRT+_IOSTRG;
+ f._ptr = str;
+ f._cnt = 32767;
+ len = _doprnt(fmt, ap, &f);
+ *f._ptr = 0;
+ return (len);
+}
--- /dev/null
+/* sys/ioctl.c */
+/* sys/socket.c */
+int socket __P((int a, int t, int p));
+/* sys/getgid.c */
+/* sys/chmod.c */
+int chmod __P((char *s, int m));
+/* sys/setitimer.c */
+int setitimer __P((int w, struct itimerval *v, struct itimerval *ov));
+/* sys/socketpair.c */
+int socketpair __P((int d, int t, int p, int s[2]));
+/* sys/listen.c */
+int listen __P((int s, int b));
+/* sys/truncate.c */
+/* sys/getpid.c */
+int getpid __P((void));
+/* sys/umount.c */
+int umount __P((char *s));
+/* sys/syscall.c */
+/* sys/sethostname.c */
+int sethostname __P((char *n, int l));
+/* sys/open.c */
+int open __P((char *f, int m, int stuff));
+/* sys/sigsetmask.c */
+int sigsetmask __P((int m));
+/* sys/readlink.c */
+int readlink __P((char *p, char *b, int s));
+/* sys/fork.c */
+int fork __P((void));
+/* sys/getgroups.c */
+int getgroups __P((int n, int *g));
+/* sys/creat.c */
+int creat __P((char *s, int m));
+/* sys/ptrace.c */
+int ptrace __P((int r, int p, int *a, int d));
+/* sys/unlink.c */
+int unlink __P((char *s));
+/* sys/getpagesize.c */
+int getpagesize __P((void));
+/* sys/acct.c */
+int acct __P((char *f));
+/* sys/fcntl.c */
+int fcntl __P((int f, int c, int a));
+/* sys/geteuid.c */
+/* sys/sigvec.c */
+int sigvec __P((int c, struct sigvec *f, struct sigvec *m));
+/* sys/recvfrom.c */
+/* sys/link.c */
+int link __P((char *a, char *b));
+/* sys/profil.c */
+void profil __P((char *b, int s, int o, int i));
+/* sys/killpg.c */
+int killpg __P((int pg, int s));
+/* sys/setpriority.c */
+int setpriority __P((int w, int who, int pri));
+/* sys/read.c */
+int read __P((int f, char *b, int l));
+/* sys/getpeername.c */
+int getpeername __P((int s, struct sockaddr *n, int *l));
+/* sys/gettimeofday.c */
+int gettimeofday __P((struct timeval *t, struct timezone *z));
+/* sys/getuid.c */
+/* sys/setgroups.c */
+int setgroups __P((int n, int *g));
+/* sys/sigstack.c */
+int sigstack __P((struct sigstack *ss, struct sigstack *oss));
+/* sys/sethostid.c */
+int sethostid __P((long h));
+/* sys/access.c */
+int access __P((char *p, int m));
+/* sys/recvmsg.c */
+int recvmsg __P((int s, struct msghdr m[], int f));
+/* sys/lstat.c */
+int lstat __P((char *s, struct stat *b));
+/* sys/readv.c */
+int readv __P((int d, struct iovec *v, int l));
+/* sys/recv.c */
+int recv __P((int s, char *b, int l, int f));
+/* sys/getsockname.c */
+int getsockname __P((int s, char *name, int *namelen));
+/* sys/write.c */
+int write __P((int f, char *b, int l));
+/* sys/execle.c */
+void execle __P((char *f, char *a));
+/* sys/close.c */
+int close __P((int f));
+/* sys/flock.c */
+int flock __P((int f, int o));
+/* sys/setrlimit.c */
+int setrlimit __P((int res, struct rlimit *rip));
+/* sys/execve.c */
+void execve __P((char *s, char *v[], char *e[]));
+/* sys/sendmsg.c */
+int sendmsg __P((int s, struct msghdr m[], int l));
+/* sys/setregid.c */
+int setregid __P((int r, int e));
+/* sys/getppid.c */
+int getppid __P((void));
+/* sys/sigreturn.c */
+int sigreturn __P((struct sigcontext *scp));
+/* sys/chdir.c */
+int chdir __P((char *s));
+/* sys/cerror.c */
+/* sys/accept.c */
+int accept __P((int s, struct sockaddr *a, int *l));
+/* sys/utimes.c */
+int utimes __P((char *f, struct timeval t[2]));
+/* sys/bind.c */
+int bind __P((int s, struct sockaddr *n, int l));
+/* sys/writev.c */
+int writev __P((int f, struct iovec *v, int l));
+/* sys/sendto.c */
+int sendto __P((int s, char *m, int l, int f, struct sockaddr *t, int tl));
+/* sys/lseek.c */
+/* sys/setsockopt.c */
+int setsockopt __P((int s, int level, int opt, char *buf, int len));
+/* sys/chown.c */
+int chown __P((char *s, int u, int g));
+/* sys/gethostid.c */
+long gethostid __P((void));
+/* sys/Ovfork.c */
+/* sys/brk.c */
+char *brk __P((char *a));
+/* sys/connect.c */
+int connect __P((int s, struct sockaddr *n, int l));
+/* sys/quota.c */
+int quota __P((int c, int u, int a, char *ad));
+/* sys/sigpause.c */
+void sigpause __P((int m));
+/* sys/getrlimit.c */
+int getrlimit __P((int res, struct rlimit *rip));
+/* sys/sigblock.c */
+int sigblock __P((int m));
+/* sys/Ovadvise.c */
+/* sys/fstat.c */
+int fstat __P((int f, struct stat *b));
+/* sys/dup.c */
+int dup __P((int f));
+/* sys/wait.c */
+int wait __P((union wait *s));
+/* sys/send.c */
+int send __P((int s, char *m, int l, int f));
+/* sys/getpgrp.c */
+int getpgrp __P((int p));
+/* sys/fsync.c */
+int fsync __P((int f));
+/* sys/_exit.c */
+void _exit __P((int s));
+/* sys/mount.c */
+int mount __P((char *s, char *n, int f));
+/* sys/getsockopt.c */
+int getsockopt __P((int s, int level, int opt, char *buf, int *len));
+/* sys/reboot.c */
+void reboot __P((int h));
+/* sys/mkdir.c */
+int mkdir __P((char *p, int m));
+/* sys/setpgrp.c */
+int setpgrp __P((int g, int pg));
+/* sys/fchmod.c */
+int fchmod __P((int f, int m));
+/* sys/ftruncate.c */
+/* sys/getpriority.c */
+int getpriority __P((int w, int who));
+/* sys/getitimer.c */
+int getitimer __P((int w, struct itimerval *v));
+/* sys/dup2.c */
+int dup2 __P((int o, int n));
+/* sys/getdtablesize.c */
+int getdtablesize __P((void));
+/* sys/getrusage.c */
+int getrusage __P((int res, struct rusage *rip));
+/* sys/exect.c */
+void exect __P((char *s, char *v[], char *e[]));
+/* sys/stat.c */
+int stat __P((char *s, struct stat *b));
+/* sys/adjtime.c */
+int adjtime __P((struct timeval *delta, struct timeval *odelta));
+/* sys/mknod.c */
+int mknod __P((char *n, int m, int a));
+/* sys/setreuid.c */
+int setreuid __P((int r, int e));
+/* sys/kill.c */
+int kill __P((int p, int s));
+/* sys/swapon.c */
+int swapon __P((char *s));
+/* sys/settimeofday.c */
+int settimeofday __P((struct timeval *t, struct timezone *z));
+/* sys/sync.c */
+void sync __P((void));
+/* sys/getegid.c */
+/* sys/shutdown.c */
+int shutdown __P((int s, int h));
+/* sys/symlink.c */
+int symlink __P((char *t, char *f));
+/* sys/chroot.c */
+int chroot __P((char *d));
+/* sys/fchown.c */
+int fchown __P((int f, int u, int g));
+/* sys/umask.c */
+int umask __P((int n));
+/* sys/gethostname.c */
+int gethostname __P((char *n, int l));
+/* sys/pipe.c */
+int pipe __P((int f[2]));
+/* sys/rmdir.c */
+int rmdir __P((char *p));
+/* sys/execl.c */
+void execl __P((char *f, char *a));
+/* sys/setquota.c */
+int setquota __P((char *s, char *f));
+/* sys/execv.c */
+void execv __P((char *s, char *v[]));
+/* sys/vhangup.c */
+void vhangup __P((void));
+/* sys/rename.c */
+int rename __P((char *f, char *t));
+/* sys/select.c */
+/* sys/wait3.c */
+int wait3 __P((union wait *s, int o, struct rusage *r));
+/* sys/sbrk.c */
+char *sbrk __P((int i));
--- /dev/null
+#include "gen.h"
+void _exit(s) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int accept(s, a, l) struct sockaddr *a; int *l; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int access(p, m) char *p; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int acct(f) char *f; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int adjtime(delta, odelta) struct timeval *delta, *odelta; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int bind(s, n, l) struct sockaddr *n; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+char *brk(a) char *a; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int chdir(s) char *s; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int chmod(s, m) char *s; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int chown(s, u, g) char *s; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int chroot(d) char *d; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int close(f) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int connect(s, n, l) struct sockaddr *n; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int creat(s, m) char *s; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int dup(f) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int dup2(o, n) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+void execl(f, a) char *f, *a; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+void execle(f, a) char *f, *a; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+void exect(s, v, e) char *s, *v[], *e[]; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+void execv(s, v) char *s, *v[]; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+void execve(s, v, e) char *s, *v[], *e[]; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int fchmod(f, m) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int fchown(f, u, g) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int fcntl(f, c, a) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int flock(f, o) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int fork() {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int fstat(f, b) struct stat *b; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int fsync(f) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int ftruncate(d, l) off_t l; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getdtablesize() {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+gid_t getegid() {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+uid_t geteuid() {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+gid_t getgid() {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getgroups(n, g) int n, *g; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+long gethostid() {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int gethostname(n, l) char *n; int l; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getitimer(w, v) struct itimerval *v; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getpagesize() {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getpeername(s, n, l) struct sockaddr *n; int *l; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getpgrp(p) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getpid() {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getppid() {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getpriority(w, who) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getrlimit(res, rip) struct rlimit *rip; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getrusage(res, rip) struct rusage *rip; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getsockname(s, name, namelen) char *name; int *namelen; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int getsockopt(s, level, opt, buf, len) char *buf; int *len; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int gettimeofday(t, z) struct timeval *t; struct timezone *z; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+uid_t getuid() {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int ioctl(d, r, p) u_long r; char *p; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int kill(p, s) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int killpg(pg, s) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int link(a, b) char *a, *b; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int listen(s, b){
+ abort();
+}
--- /dev/null
+#include "gen.h"
+off_t lseek(f, o, d) off_t o; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int lstat(s, b) char *s; struct stat *b; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int mkdir(p, m) char *p; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int mknod(n, m, a) char *n; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int mount(s, n, f) char *s, *n; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int open(f, m, stuff) char *f; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int pipe(f) int f[2]; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+void profil(b, s, o, i) char *b; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int ptrace(r, p, a, d) int *a; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int quota(c, u, a, ad) char *ad; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int read(f, b, l) char *b; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int readlink(p, b, s) char *p, *b; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int readv(d, v, l) struct iovec *v; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+void reboot(h) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int recv(s, b, l, f) char *b; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int recvfrom(s, b, l, f, fr, fl) char *b; struct sockaddr *fr; int *fl;
--- /dev/null
+#include "gen.h"
+int recvmsg(s, m, f) struct msghdr m[]; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int rename(f, t) char *f, *t; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int rmdir(p) char *p; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+char *sbrk(i) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int select(n, r, w, e, t) fd_set *r, *w, *e; struct timeval *t; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int send(s, m, l, f) char *m; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int sendmsg(s, m, l) struct msghdr m[]; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int sendto(s, m, l, f, t, tl) char *m; struct sockaddr *t; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int setgroups(n, g) int *g; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int sethostid(h) long h; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int sethostname(n, l) char *n; int l; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int setitimer(w, v, ov) struct itimerval *v, *ov; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int setpgrp(g, pg) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int setpriority(w, who, pri) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int setquota(s, f) char *s, *f; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int setregid(r, e) int r, e; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int setreuid(r, e) int r, e; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int setrlimit(res, rip) struct rlimit *rip; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int setsockopt(s, level, opt, buf, len) char *buf; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int settimeofday(t, z) struct timeval *t; struct timezone *z; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int shutdown(s, h){
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int sigblock(m) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+void sigpause(m) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int sigreturn(scp) struct sigcontext *scp; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int sigsetmask(m) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int sigstack(ss, oss) struct sigstack *ss, *oss; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int sigvec(c, f, m) struct sigvec *f, *m; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int socket(a, t, p) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int socketpair(d, t, p, s) int s[2]; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int stat(s, b) char *s; struct stat *b; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int swapon(s) char *s; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int symlink(t, f) char *t, *f; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+void sync(){
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int truncate(p, l) char *p; off_t l; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int umask(n) {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int umount(s) char *s; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int unlink(s) char *s; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int utimes(f, t) char *f; struct timeval t[2]; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+void vhangup() {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int wait(s) union wait *s; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int wait3(s, o, r) union wait *s; struct rusage *r; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int write(f, b, l) char *b; {
+ abort();
+}
--- /dev/null
+#include "gen.h"
+int writev(f, v, l) struct iovec *v; {
+ abort();
+}
--- /dev/null
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 5.5 (Berkeley) 9/5/85
+#
+# Machine dependent routines for the VAX are located here
+#
+COMPAT= compat-4.1
+ALL= gen net stdio sys ${COMPAT}
+TAGSFILE=tags
+
+vaxlib vaxlib_p: ${ALL}
+ -mkdir tmp
+ for i in ${ALL}; do (cd tmp; ar x ../$$i/$${i}lib); done
+ ar cr vaxlib `ls tmp/*.o | sort -t/ +1`
+ rm -f tmp/*
+ for i in ${ALL}; do (cd tmp; ar x ../$$i/$${i}lib_p); done
+ ar cr vaxlib_p `ls tmp/*.o | sort -t/ +1`
+ rm -rf tmp
+
+${ALL}: FRC
+ cd $@; make ${MFLAGS} DEFS=${DEFS}
+
+FRC:
+
+tags:
+ for i in ${ALL}; do \
+ (cd $$i; make ${MFLAGS} TAGSFILE=../${TAGSFILE} tags); \
+ done
+
+clean:
+ for i in ${ALL}; do (cd $$i; make ${MFLAGS} clean); done
+ rm -f vaxlib vaxlib_p tmp/*.o;
+ -rmdir tmp
+
+depend:
+ for i in ${ALL}; do \
+ (cd $$i; make ${MFLAGS} DEFS=${DEFS} depend); done
--- /dev/null
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 5.5 (Berkeley) 9/6/85
+#
+SRCS= reset.c
+OBJS= reset.o
+CFLAGS= ${DEFS}
+TAGSFILE=tags
+
+.c.o:
+ /lib/cpp -E ${CFLAGS} -DPROF $*.c | ${AS} -o $*.o
+ -ld -X -r $*.o
+ mv a.out profiled/$*.o
+ /lib/cpp -E ${CFLAGS} $*.c | ${AS} -o $*.o
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+compat-4.1lib compat-4.1lib_p: ${OBJS}
+ @echo "building profiled compat-4.1"
+ @cd profiled; ar cru ../compat-4.1lib_p ${OBJS}
+ @echo "building normal compat-4.1"
+ @ar cru compat-4.1lib ${OBJS}
+
+tags:
+
+clean:
+ rm -f *.o profiled/*.o errs a.out core \
+ compat-4.1lib compat-4.1lib_p tags
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+reset.o: reset.c ./DEFS.h
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+#ifdef LIBC_SCCS
+_sccsid:.asciz "@(#)reset.c 5.4 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * C library -- reset, setexit
+ *
+ * reset(x)
+ * will generate a "return" from
+ * the last call to
+ * setexit()
+ * by restoring r6 - r12, ap, fp
+ * and doing a return.
+ * The returned value is x; on the original
+ * call the returned value is 0.
+ *
+ * useful for going back to the main loop
+ * after a horrible error in a lowlevel
+ * routine.
+ */
+#include "DEFS.h"
+
+ENTRY(setexit)
+ movab setsav,r0
+ movq r6,(r0)+
+ movq r8,(r0)+
+ movq r10,(r0)+
+ movq 8(fp),(r0)+ # ap, fp
+ movab 4(ap),(r0)+ # sp
+ movl 16(fp),(r0) # pc
+ clrl r0
+ ret
+
+ENTRY(reset)
+ movl 4(ap),r0 # returned value
+ movab setsav,r1
+ movq (r1)+,r6
+ movq (r1)+,r8
+ movq (r1)+,r10
+ movq (r1)+,r12
+ movl (r1)+,sp
+ jmp *(r1)
+
+ .data
+setsav: .space 10*4
--- /dev/null
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 5.4 (Berkeley) 9/5/85
+#
+# crt0 Normal C run time startoff
+# mcrt0 C run time start off for profiling, ``prof'' conventions
+# gcrt0 C run time start off for profiling, ``gprof'' conventions
+#
+DESTDIR=
+SRCS= crt0.c mon.c gmon.c
+OBJS= crt0.o mcrt0.o gcrt0.o mon.o gmon.o
+TAGSFILE=tags
+
+all: ${OBJS}
+
+install: ${OBJS}
+ mv crt0.o ${DESTDIR}/lib/crt0.o
+ mv mcrt0.o ${DESTDIR}/lib/mcrt0.o
+ mv gcrt0.o ${DESTDIR}/usr/lib/gcrt0.o
+
+crt0.o: crt0.c
+ cc -S ${DFLAGS} -DCRT0 crt0.c
+ /lib/cpp crt0.s > x.s
+ as -o x.o x.s
+ ld -x -r -o crt0.o x.o
+ rm -f x.s x.o crt0.s
+
+moncrt0.o: crt0.c
+ cc -S ${DFLAGS} -DMCRT0 crt0.c
+ /lib/cpp crt0.s > x.s
+ as -o x.o x.s
+ ld -x -r -o moncrt0.o x.o
+ rm -f x.s x.o crt0.s
+
+gcrt0.o: moncrt0.o gmon.o
+ ld -x -r -o gcrt0.o moncrt0.o gmon.o
+
+mcrt0.o: moncrt0.o mon.o
+ ld -x -r -o mcrt0.o moncrt0.o mon.o
+
+mon.o: mon.c mon.ex
+ cc -S ${DEFS} ${DFLAGS} mon.c
+ ex - mon.s < mon.ex
+ as -o x.o mon.s
+ ld -x -r -o mon.o x.o
+ rm -f x.o mon.s
+
+gmon.o: gmon.c gmon.h gmon.ex
+ cc -S ${DEFS} ${DFLAGS} gmon.c
+ ex - gmon.s < gmon.ex
+ as -o x.o gmon.s
+ ld -x -r -o gmon.o x.o
+ rm -f x.o gmon.s
+
+tags:
+ cwd=`pwd`; \
+ for i in ${SRCS}; do \
+ ctags -a -f ${TAGSFILE} $$cwd/$$i; \
+ done
+
+clean:
+ rm -f ${OBJS} *.o *.s core errs tags Makefile.bak
+
+lint: crt0.c
+ lint crt0.c -DMCRT0
+ lint crt0.c -DGCRT0
+ lint crt0.c -DCRT0
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${DEFS} ${DFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+crt0.o: crt0.c
+mon.o: mon.c
+gmon.o: gmon.c ./gmon.h
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+# Makefile 4.13 86/01/09
+#
+SRCS= _setjmp.s abs.s alloca.s atof.s bcmp.s bcopy.s bzero.s disktab.c \
+ ecvt.c fabs.s ffs.s frexp.s index.s insque.s ldexp.s modf.s nargs.s \
+ remque.s rindex.s setjmp.s setjmperr.c strcat.s strcmp.s strcpy.s \
+ strlen.s strncat.s strncmp.s strncpy.s udiv.s urem.s
+OBJS= _setjmp.o abs.o alloca.o atof.o bcmp.o bcopy.o bzero.o disktab.o \
+ ecvt.o fabs.o ffs.o frexp.o index.o insque.o ldexp.o modf.o nargs.o \
+ remque.o rindex.o setjmp.o setjmperr.o strcat.o strcmp.o strcpy.o \
+ strlen.o strncat.o strncmp.o strncpy.o udiv.o urem.o
+CFLAGS= -O ${DEFS}
+TAGSFILE=tags
+
+.s.o:
+ /lib/cpp -E ${DEFS} -DPROF $*.s | ${AS} -o $*.o
+ -ld -X -r $*.o
+ mv a.out profiled/$*.o
+ /lib/cpp -E ${DEFS} $*.s | ${AS} -o $*.o
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+.c.o:
+ cc -p -c ${CFLAGS} $*.c
+ -ld -X -r $*.o
+ mv a.out profiled/$*.o
+ cc -c ${CFLAGS} $*.c
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+genlib genlib_p: ${OBJS}
+ @echo "building profiled genlib"
+ @cd profiled; ar cru ../genlib_p ${OBJS}
+ @echo "building normal genlib"
+ @ar cru genlib ${OBJS}
+
+tags:
+ cwd=`pwd`; \
+ for i in disktab.c ecvt.c; do \
+ ctags -a -f ${TAGSFILE} $$cwd/$$i; \
+ done
+
+clean:
+ rm -f *.o profiled/*.o errs a.out core genlib genlib_p \
+ tags Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+_setjmp.o: _setjmp.s ./DEFS.h
+abs.o: abs.s ./DEFS.h
+alloca.o: alloca.s ./DEFS.h
+atof.o: atof.s ./DEFS.h
+bcmp.o: bcmp.s ./DEFS.h
+bcopy.o: bcopy.s ./DEFS.h
+bzero.o: bzero.s ./DEFS.h
+disktab.o: disktab.c /usr/include/disktab.h /usr/include/stdio.h
+disktab.o: /usr/include/ctype.h
+ecvt.o: ecvt.c
+fabs.o: fabs.s ./DEFS.h
+ffs.o: ffs.s ./DEFS.h
+frexp.o: frexp.s ./DEFS.h
+index.o: index.s ./DEFS.h
+insque.o: insque.s ./DEFS.h
+ldexp.o: ldexp.s ./DEFS.h /usr/include/errno.h
+modf.o: modf.s ./DEFS.h
+nargs.o: nargs.s ./DEFS.h
+remque.o: remque.s ./DEFS.h
+rindex.o: rindex.s ./DEFS.h
+setjmp.o: setjmp.s ./DEFS.h /usr/include/vax/machparam.h
+strcat.o: strcat.s ./DEFS.h
+strcmp.o: strcmp.s ./DEFS.h
+strcpy.o: strcpy.s ./DEFS.h
+strlen.o: strlen.s ./DEFS.h
+strncat.o: strncat.s ./DEFS.h
+strncmp.o: strncmp.s ./DEFS.h
+strncpy.o: strncpy.s ./DEFS.h
+udiv.o: udiv.s ./DEFS.h ./DEFS.h
+urem.o: urem.s ./DEFS.h ./DEFS.h
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+#include "gen.h"
+int _setjmp(e) jmp_buf e; {
+ abort();
+}
+void _longjmp(e, v) jmp_buf e; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)_setjmp.s 5.5 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+
+/*
+ * C library -- _setjmp, _longjmp
+ *
+ * _longjmp(a,v)
+ * will generate a "return(v)" from
+ * the last call to
+ * _setjmp(a)
+ * by restoring registers from the stack,
+ * The previous signal state is NOT restored.
+ */
+
+#include "DEFS.h"
+
+ENTRY(_setjmp, 0)
+ movl 4(ap),r0
+ movl 12(fp),(r0) # save frame pointer of caller
+ movl 16(fp),4(r0) # save pc of caller
+ clrl r0
+ ret
+
+ENTRY(_longjmp, 0)
+ movl 8(ap),r0 # return(v)
+ movl 4(ap),r1 # fetch buffer
+ tstl (r1)
+ beql botch
+loop:
+ bitw $1,6(fp) # r0 saved?
+ beql 1f
+ movl r0,20(fp)
+ bitw $2,6(fp) # was r1 saved?
+ beql 2f
+ movl r1,24(fp)
+ brb 2f
+1:
+ bitw $2,6(fp) # was r1 saved?
+ beql 2f
+ movl r1,20(fp)
+2:
+ cmpl (r1),12(fp)
+ beql done
+ blssu botch
+ movl $loop,16(fp)
+ ret # pop another frame
+
+done:
+ cmpb *16(fp),reiins # returning to an "rei"?
+ bneq 1f
+ movab 3f,16(fp) # do return w/ psl-pc pop
+ brw 2f
+1:
+ movab 4f,16(fp) # do standard return
+2:
+ ret # unwind stack before signals enabled
+3:
+ addl2 $8,sp # compensate for PSL-PC push
+4:
+ jmp *4(r1) # done, return....
+
+botch:
+ calls $0,_longjmperror
+ halt
+
+ .data
+reiins: rei
--- /dev/null
+#include "gen.h"
+int abs(i) int i; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)abs.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+
+/* abs - int absolute value */
+
+#include "DEFS.h"
+
+ENTRY(abs, 0)
+ movl 4(ap),r0
+ bgeq 1f
+ mnegl r0,r0
+1:
+ ret
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)alloca.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* like alloc, but automatic free in return */
+
+#include "DEFS.h"
+
+ENTRY(alloca, 0)
+ subl2 4(ap),sp /* crude allocation */
+ movl 16(fp),r1 /* pc */
+ movq 8(fp),ap /* new (old) ap and fp */
+ bicl2 $3,sp /* 4-byte align */
+ addl2 $7*4,sp /* reuse space of mscp */
+ movl sp,r0 /* return value */
+ jmp (r1) /* funny return */
--- /dev/null
+#include "gen.h"
+double atof(s) char *s; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)atof.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+#include "DEFS.h"
+
+/*
+ * atof: convert ascii to floating
+ *
+ * C usage:
+ *
+ * double atof (s)
+ * char *s;
+ *
+ * Register usage:
+ *
+ * r0-1: value being developed
+ * r2: first section: pointer to the next character
+ * second section: binary exponent
+ * r3: flags
+ * r4: first section: the current character
+ * second section: scratch
+ * r5: the decimal exponent
+ * r6-7: scratch
+ */
+ .set msign,0 # mantissa has negative sign
+ .set esign,1 # exponent has negative sign
+ .set decpt,2 # decimal point encountered
+
+ENTRY(atof, R6|R7)
+/*
+ * Initialization
+ */
+ clrl r3 # All flags start out false
+ movl 4(ap),r2 # Address the first character
+ clrl r5 # Clear starting exponent
+/*
+ * Skip leading white space
+ */
+sk0: movzbl (r2)+,r4 # Fetch the next (first) character
+ cmpb $' ,r4 # Is it blank?
+ jeql sk0 # ...yes
+ cmpb r4,$8 # 8 is lowest of white-space group
+ jlss sk1 # Jump if char too low to be white space
+ cmpb r4,$13 # 13 is highest of white-space group
+ jleq sk0 # Jump if character is white space
+sk1:
+/*
+ * Check for a sign
+ */
+ cmpb $'+,r4 # Positive sign?
+ jeql cs1 # ... yes
+ cmpb $'-,r4 # Negative sign?
+ jneq cs2 # ... no
+ bisb2 $1<msign,r3 # Indicate a negative mantissa
+cs1: movzbl (r2)+,r4 # Skip the character
+cs2:
+/*
+ * Accumulate digits, keeping track of the exponent
+ */
+ clrq r0 # Clear the accumulator
+ad0: cmpb r4,$'0 # Do we have a digit?
+ jlss ad4 # ... no, too small
+ cmpb r4,$'9
+ jgtr ad4 # ... no, too large
+/*
+ * We got a digit. Accumulate it
+ */
+ cmpl r1,$214748364 # Would this digit cause overflow?
+ jgeq ad1 # ... yes
+/*
+ * Multiply (r0,r1) by 10. This is done by developing
+ * (r0,r1)*2 in (r6,r7), shifting (r0,r1) left three bits,
+ * and adding the two quadwords.
+ */
+ ashq $1,r0,r6 # (r6,r7)=(r0,r1)*2
+ ashq $3,r0,r0 # (r0,r1)=(r0,r1)*8
+ addl2 r6,r0 # Add low halves
+ adwc r7,r1 # Add high halves
+/*
+ * Add in the digit
+ */
+ subl2 $'0,r4 # Get the digit value
+ addl2 r4,r0 # Add it into the accumulator
+ adwc $0,r1 # Possible carry into high half
+ jbr ad2 # Join common code
+/*
+ * Here when the digit won't fit in the accumulator
+ */
+ad1: incl r5 # Ignore the digit, bump exponent
+/*
+ * If we have seen a decimal point, decrease the exponent by 1
+ */
+ad2: jbc $decpt,r3,ad3 # Jump if decimal point not seen
+ decl r5 # Decrease exponent
+ad3:
+/*
+ * Fetch the next character, back for more
+ */
+ movzbl (r2)+,r4 # Fetch
+ jbr ad0 # Try again
+/*
+ * Not a digit. Could it be a decimal point?
+ */
+ad4: cmpb r4,$'. # If it's not a decimal point, either it's
+ jneq ad5 # the end of the number or the start of
+ # the exponent.
+ jbcs $decpt,r3,ad3 # If it IS a decimal point, we record that
+ # we've seen one, and keep collecting
+ # digits if it is the first one.
+/*
+ * Check for an exponent
+ */
+ad5: clrl r6 # Initialize the exponent accumulator
+
+ cmpb r4,$'e # We allow both lower case e
+ jeql ex1 # ... and ...
+ cmpb r4,$'E # upper-case E
+ jneq ex7
+/*
+ * Does the exponent have a sign?
+ */
+ex1: movzbl (r2)+,r4 # Get next character
+ cmpb r4,$'+ # Positive sign?
+ jeql ex2 # ... yes ...
+ cmpb r4,$'- # Negative sign?
+ jneq ex3 # ... no ...
+ bisb2 $1<esign,r3 # Indicate exponent is negative
+ex2: movzbl (r2)+,r4 # Grab the next character
+/*
+ * Accumulate exponent digits in r6
+ */
+ex3: cmpb r4,$'0 # A digit is within the range
+ jlss ex4 # '0' through
+ cmpb r4,$'9 # '9',
+ jgtr ex4 # inclusive.
+ cmpl r6,$214748364 # Exponent outrageously large already?
+ jgeq ex2 # ... yes
+ moval (r6)[r6],r6 # r6 *= 5
+ movaw -'0(r4)[r6],r6 # r6 = r6 * 2 + r4 - '0'
+ jbr ex2 # Go 'round again
+ex4:
+/*
+ * Now get the final exponent and force it within a reasonable
+ * range so our scaling loops don't take forever for values
+ * that will ultimately cause overflow or underflow anyway.
+ * A tight check on over/underflow will be done by ldexp.
+ */
+ jbc $esign,r3,ex5 # Jump if exponent not negative
+ mnegl r6,r6 # If sign, negate exponent
+ex5: addl2 r6,r5 # Add given exponent to calculated exponent
+ cmpl r5,$-100 # Absurdly small?
+ jgtr ex6 # ... no
+ movl $-100,r5 # ... yes, force within limit
+ex6: cmpl r5,$100 # Absurdly large?
+ jlss ex7 # ... no
+ movl $100,r5 # ... yes, force within bounds
+ex7:
+/*
+ * Our number has now been reduced to a mantissa and an exponent.
+ * The mantissa is a 63-bit positive binary integer in r0,r1,
+ * and the exponent is a signed power of 10 in r5. The msign
+ * bit in r3 will be on if the mantissa should ultimately be
+ * considered negative.
+ *
+ * We now have to convert it to a standard format floating point
+ * number. This will be done by accumulating a binary exponent
+ * in r2, as we progressively get r5 closer to zero.
+ *
+ * Don't bother scaling if the mantissa is zero
+ */
+ movq r0,r0 # Mantissa zero?
+ jeql exit # ... yes
+
+ clrl r2 # Initialize binary exponent
+ tstl r5 # Which way to scale?
+ jleq sd0 # Scale down if decimal exponent <= 0
+/*
+ * Scale up by "multiplying" r0,r1 by 10 as many times as necessary,
+ * as follows:
+ *
+ * Step 1: Shift r0,r1 right as necessary to ensure that no
+ * overflow can occur when multiplying.
+ */
+su0: cmpl r1,$429496729 # Compare high word to (2**31)/5
+ jlss su1 # Jump out if guaranteed safe
+ ashq $-1,r0,r0 # Else shift right one bit
+ incl r2 # bump exponent to compensate
+ jbr su0 # and go back to test again.
+/*
+ * Step 2: Multiply r0,r1 by 5, by appropriate shifting and
+ * double-precision addition
+ */
+su1: ashq $2,r0,r6 # (r6,r7) := (r0,r1) * 4
+ addl2 r6,r0 # Add low-order halves
+ adwc r7,r1 # and high-order halves
+/*
+ * Step 3: Increment the binary exponent to take care of the final
+ * factor of 2, and go back if we still need to scale more.
+ */
+ incl r2 # Increment the exponent
+ sobgtr r5,su0 # and back for more (maybe)
+
+ jbr cm0 # Merge to build final value
+
+/*
+ * Scale down. We must "divide" r0,r1 by 10 as many times
+ * as needed, as follows:
+ *
+ * Step 0: Right now, the condition codes reflect the state
+ * of r5. If it's zero, we are done.
+ */
+sd0: jeql cm0 # If finished, build final number
+/*
+ * Step 1: Shift r0,r1 left until the high-order bit (not counting
+ * the sign bit) is nonzero, so that the division will preserve
+ * as much precision as possible.
+ */
+ tstl r1 # Is the entire high-order half zero?
+ jneq sd2 # ...no, go shift one bit at a time
+ ashq $30,r0,r0 # ...yes, shift left 30,
+ subl2 $30,r2 # decrement the exponent to compensate,
+ # and now it's known to be safe to shift
+ # at least once more.
+sd1: ashq $1,r0,r0 # Shift (r0,r1) left one, and
+ decl r2 # decrement the exponent to compensate
+sd2: jbc $30,r1,sd1 # If the high-order bit is off, go shift
+/*
+ * Step 2: Divide the high-order part of (r0,r1) by 5,
+ * giving a quotient in r1 and a remainder in r7.
+ */
+sd3: movl r1,r6 # Copy the high-order part
+ clrl r7 # Zero-extend to 64 bits
+ ediv $5,r6,r1,r7 # Divide (cannot overflow)
+/*
+ * Step 3: Divide the low-order part of (r0,r1) by 5,
+ * using the remainder from step 2 for rounding.
+ * Note that the result of this computation is unsigned,
+ * so we have to allow for the fact that an ordinary division
+ * by 5 could overflow. We make allowance by dividing by 10,
+ * multiplying the quotient by 2, and using the remainder
+ * to adjust the modified quotient.
+ */
+ addl3 $2,r0,r6 # Dividend is low part of (r0,r1) plus
+ adwc $0,r7 # 2 for rounding plus
+ # (2**32) * previous remainder
+ ediv $10,r6,r0,r6 # r0 := quotient, r6 := remainder.
+ addl2 r0,r0 # Make r0 result of dividing by 5
+ cmpl r6,$5 # If remainder is 5 or greater,
+ jlss sd4 # increment the adjustted quotient.
+ incl r0
+/*
+ * Step 4: Increment the decimal exponent, decrement the binary
+ * exponent (to make the division by 5 into a division by 10),
+ * and back for another iteration.
+ */
+sd4: decl r2 # Binary exponent
+ aoblss $0,r5,sd2
+/*
+ * We now have the following:
+ *
+ * r0: low-order half of a 64-bit integer
+ * r1: high-order half of the same 64-bit integer
+ * r2: a binary exponent
+ *
+ * Our final result is the integer represented by (r0,r1)
+ * multiplied by 2 to the power contained in r2.
+ * We will transform (r0,r1) into a floating-point value,
+ * set the sign appropriately, and let ldexp do the
+ * rest of the work.
+ *
+ * Step 1: if the high-order bit (excluding the sign) of
+ * the high-order half (r1) is 1, then we have 63 bits of
+ * fraction, too many to convert easily. However, we also
+ * know we won't need them all, so we will just throw the
+ * low-order bit away (and adjust the exponent appropriately).
+ */
+cm0: jbc $30,r1,cm1 # jump if no adjustment needed
+ ashq $-1,r0,r0 # lose the low-order bit
+ incl r2 # increase the exponent to compensate
+/*
+ * Step 2: split the 62-bit number in (r0,r1) into two
+ * 31-bit positive quantities
+ */
+cm1: ashq $1,r0,r0 # put the high-order bits in r1
+ # and a 0 in the bottom of r0
+ rotl $-1,r0,r0 # right-justify the bits in r0
+ # moving the 0 from the ashq
+ # into the sign bit.
+/*
+ * Step 3: convert both halves to floating point
+ */
+ cvtld r0,r6 # low-order part in r6-r7
+ cvtld r1,r0 # high-order part in r0-r1
+/*
+ * Step 4: multiply the high order part by 2**31 and combine them
+ */
+ muld2 two31,r0 # multiply
+ addd2 r6,r0 # combine
+/*
+ * Step 5: if appropriate, negate the floating value
+ */
+ jbc $msign,r3,cm2 # Jump if mantissa not signed
+ mnegd r0,r0 # If negative, make it so
+/*
+ * Step 6: call ldexp to complete the job
+ */
+cm2: pushl r2 # Put exponent in parameter list
+ movd r0,-(sp) # and also mantissa
+ calls $3,_ldexp # go combine them
+
+exit:
+ ret
+
+ .align 2
+two31: .word 0x5000 # 2 ** 31
+ .word 0 # (=2147483648)
+ .word 0 # in floating-point
+ .word 0 # (so atof doesn't have to convert it)
--- /dev/null
+#include "gen.h"
+int bcmp(b1, b2, length) char *b1, *b2; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bcmp.c 5.1 (Berkeley) 1/27/87";
+#endif LIBC_SCCS and not lint
+
+/*
+ * bcmp -- vax cmpc3 instruction
+ */
+bcmp(b1, b2, length)
+ register char *b1, *b2;
+ register int length;
+{
+
+ if (length == 0)
+ return (0);
+ do
+ if (*b1++ != *b2++)
+ break;
+ while (--length);
+ return(length);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)bcmp.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* bcmp(s1, s2, n) */
+
+#include "DEFS.h"
+
+ENTRY(bcmp, 0)
+ movl 4(ap),r1
+ movl 8(ap),r3
+ movl 12(ap),r4
+1:
+ movzwl $65535,r0
+ cmpl r4,r0
+ jleq 2f
+ subl2 r0,r4
+ cmpc3 r0,(r1),(r3)
+ jeql 1b
+ addl2 r4,r0
+ ret
+2:
+ cmpc3 r4,(r1),(r3)
+ ret
--- /dev/null
+#include "gen.h"
+void bcopy(src, dst, length) char *src, *dst; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bcopy.c 5.1 (Berkeley) 1/27/87";
+#endif LIBC_SCCS and not lint
+
+/*
+ * bcopy -- vax movc3 instruction
+ */
+bcopy(src, dst, length)
+ register char *src, *dst;
+ register int length;
+{
+ if (length && src != dst)
+ if ((u_int)dst < (u_int)src)
+ if (((int)src | (int)dst | length) & 3)
+ do /* copy by bytes */
+ *dst++ = *src++;
+ while (--length);
+ else {
+ length >>= 2;
+ do /* copy by longs */
+ *((long *)dst)++ = *((long *)src)++;
+ while (--length);
+ }
+ else { /* copy backwards */
+ src += length;
+ dst += length;
+ if (((int)src | (int)dst | length) & 3)
+ do /* copy by bytes */
+ *--dst = *--src;
+ while (--length);
+ else {
+ length >>= 2;
+ do /* copy by shorts */
+ *--((long *)dst) = *--((long *)src);
+ while (--length);
+ }
+ }
+ return(0);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)bcopy.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* bcopy(from, to, size) */
+
+#include "DEFS.h"
+
+ENTRY(bcopy, R6)
+ movl 4(ap),r1
+ movl 8(ap),r3
+ movl 12(ap),r6
+ cmpl r1,r3
+ bgtr 2f # normal forward case
+ blss 3f # overlapping, must do backwards
+ ret # equal, nothing to do
+1:
+ subl2 r0,r6
+ movc3 r0,(r1),(r3)
+2:
+ movzwl $65535,r0
+ cmpl r6,r0
+ jgtr 1b
+ movc3 r6,(r1),(r3)
+ ret
+3:
+ addl2 r6,r1
+ addl2 r6,r3
+ movzwl $65535,r0
+ jbr 5f
+4:
+ subl2 r0,r6
+ subl2 r0,r1
+ subl2 r0,r3
+ movc3 r0,(r1),(r3)
+ movzwl $65535,r0
+ subl2 r0,r1
+ subl2 r0,r3
+5:
+ cmpl r6,r0
+ jgtr 4b
+ subl2 r6,r1
+ subl2 r6,r3
+ movc3 r6,(r1),(r3)
+ ret
--- /dev/null
+#include "gen.h"
+void bzero(b, length) char *b; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)bzero.c 5.1 (Berkeley) 1/27/87";
+#endif LIBC_SCCS and not lint
+
+/*
+ * bzero -- vax movc5 instruction
+ */
+bzero(b, length)
+ register char *b;
+ register int length;
+{
+
+ if (length)
+ do
+ *b++ = '\0';
+ while (--length);
+ return(length);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)bzero.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* bzero(base, length) */
+
+#include "DEFS.h"
+
+ENTRY(bzero, 0)
+ movl 4(ap),r3
+ jbr 2f
+1:
+ subl2 r0,8(ap)
+ movc5 $0,(r3),$0,r0,(r3)
+2:
+ movzwl $65535,r0
+ cmpl 8(ap),r0
+ jgtr 1b
+ movc5 $0,(r3),$0,8(ap),(r3)
+ ret
--- /dev/null
+#ifdef LIBC_SCCS
+ .asciz "@(#)fabs.s 5.2 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* fabs - floating absolute value */
+
+#include "DEFS.h"
+
+ENTRY(fabs, 0)
+ movd 4(ap),r0
+ bgeq 1f
+ mnegd r0,r0
+1:
+ ret
--- /dev/null
+#include "gen.h"
+int ffs(i) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)ffs.c 5.2 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+/*
+ * ffs -- vax ffs instruction
+ */
+ffs(mask)
+ register long mask;
+{
+ register int cnt;
+
+ if (mask == 0)
+ return(0);
+ for (cnt = 1; !(mask & 1); cnt++)
+ mask >>= 1;
+ return(cnt);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)ffs.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* bit = ffs(value) */
+
+#include "DEFS.h"
+
+ENTRY(ffs, 0)
+ ffs $0,$32,4(ap),r0
+ bneq 1f
+ mnegl $1,r0
+1:
+ incl r0
+ ret
--- /dev/null
+#include "gen.h"
+double frexp(v, e) double v; int *e; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)frexp.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* C library -- frexp(value, eptr) */
+
+#include "DEFS.h"
+
+ENTRY(frexp, 0)
+ movd 4(ap),r0 # (r0,r1) := value
+ extzv $7,$8,r0,*12(ap) # Fetch exponent
+ jeql 1f # If exponent zero, we're done
+ subl2 $128,*12(ap) # Bias the exponent appropriately
+ insv $128,$7,$8,r0 # Force result exponent to biased 0
+1:
+ ret
--- /dev/null
+#include "gen.h"
+char *index(s, c) char *s, c; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)index.c 5.4 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+
+char *
+index(p, ch)
+ register char *p, ch;
+{
+ for (;; ++p) {
+ if (*p == ch)
+ return(p);
+ if (!*p)
+ return((char *)NULL);
+ }
+ /* NOTREACHED */
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)index.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * Find the first occurence of c in the string cp.
+ * Return pointer to match or null pointer.
+ *
+ * char *
+ * index(cp, c)
+ * char *cp, c;
+ */
+#include "DEFS.h"
+
+ENTRY(index, 0)
+ movq 4(ap),r1 # r1 = cp; r2 = c
+ tstl r2 # check for special case c == '\0'
+ bneq 2f
+1:
+ locc $0,$65535,(r1) # just find end of string
+ beql 1b # still looking
+ movl r1,r0 # found it
+ ret
+2:
+ moval tbl,r3 # r3 = address of table
+ bbss $0,(r3),5f # insure not reentering
+ movab (r3)[r2],r5 # table entry for c
+ incb (r5)
+ movzwl $65535,r4 # fast access
+3:
+ scanc r4,(r1),(r3),$1 # look for c or '\0'
+ beql 3b # still looking
+ movl r1,r0 # return pointer to char
+ tstb (r0) # if have found '\0'
+ bneq 4f
+ clrl r0 # else return 0
+4:
+ clrb (r5) # clean up table
+ clrb (r3)
+ ret
+
+ .data
+tbl: .space 256
+ .text
+
+/*
+ * Reentrant, but slower version of index
+ */
+5:
+ movl r1,r3
+6:
+ locc $0,$65535,(r3) # look for '\0'
+ bneq 7f
+ locc r2,$65535,(r3) # look for c
+ bneq 8f
+ movl r1,r3 # reset pointer and ...
+ jbr 6b # ... try again
+7:
+ subl3 r3,r1,r4 # length of short block
+ incl r4 # +1 for '\0'
+ locc r2,r4,(r3) # look for c
+ bneq 8f
+ ret
+8:
+ movl r1,r0 # return pointer to char
+ ret
--- /dev/null
+#include "gen.h"
+void insque(elem, pred) struct qelem *elem, pred; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)insque.c 5.1 (Berkeley) 1/27/87";
+#endif LIBC_SCCS and not lint
+
+/*
+ * insque -- vax insque instruction
+ *
+ * NOTE: this implementation is non-atomic!!
+ */
+
+struct vaxque { /* queue format expected by VAX queue instructions */
+ struct vaxque *vq_next;
+ struct vaxque *vq_prev;
+};
+
+insque(e, prev)
+ register struct vaxque *e, *prev;
+{
+ e->vq_prev = prev;
+ e->vq_next = prev->vq_next;
+ prev->vq_next->vq_prev = e;
+ prev->vq_next = e;
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)insque.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* insque(new, pred) */
+
+#include "DEFS.h"
+
+ENTRY(insque, 0)
+ insque *4(ap), *8(ap)
+ ret
--- /dev/null
+#include "gen.h"
+double ldexp(v, e) double v; {
+ abort();
+}
--- /dev/null
+#ifdef LIBC_SCCS
+ .asciz "@(#)ldexp.s 5.2 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * double ldexp (value, exp)
+ * double value;
+ * int exp;
+ *
+ * Ldexp returns value*2**exp, if that result is in range.
+ * If underflow occurs, it returns zero. If overflow occurs,
+ * it returns a value of appropriate sign and largest
+ * possible magnitude. In case of either overflow or underflow,
+ * errno is set to ERANGE. Note that errno is not modified if
+ * no error occurs.
+ */
+
+#include "DEFS.h"
+#include <errno.h>
+
+ .globl _errno
+
+ENTRY(ldexp, 0)
+ movd 4(ap),r0 /* fetch "value" */
+ extzv $7,$8,r0,r2 /* r2 := biased exponent */
+ jeql 1f /* if zero, done */
+
+ addl2 12(ap),r2 /* r2 := new biased exponent */
+ jleq 2f /* if <= 0, underflow */
+ cmpl r2,$256 /* otherwise check if too big */
+ jgeq 3f /* jump if overflow */
+ insv r2,$7,$8,r0 /* put exponent back in result */
+1:
+ ret
+2:
+ clrd r0
+ jbr 1f
+3:
+ movd huge,r0 /* largest possible floating magnitude */
+ jbc $15,4(ap),1f /* jump if argument was positive */
+ mnegd r0,r0 /* if arg < 0, make result negative */
+1:
+ movl $ERANGE,_errno
+ ret
+
+ .data
+huge: .word 0x7fff /* the largest number that can */
+ .word 0xffff /* be represented in a long floating */
+ .word 0xffff /* number. This is given in hex in order */
+ .word 0xffff /* to avoid floating conversions */
--- /dev/null
+#include "gen.h"
+double modf(v, p) double v, *p; {
+ abort();
+}
--- /dev/null
+#ifdef LIBC_SCCS
+ .asciz "@(#)modf.s 5.2 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * double modf (value, iptr)
+ * double value, *iptr;
+ *
+ * Modf returns the fractional part of "value",
+ * and stores the integer part indirectly through "iptr".
+ */
+
+#include "DEFS.h"
+
+ENTRY(modf, 0)
+ emodd 4(ap),$0,$0f1.0,r2,r0
+ jvs 1f # integer overflow
+ cvtld r2,*12(ap)
+ ret
+1:
+ subd3 r0,4(ap),*12(ap)
+ ret
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)nargs.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* C library -- nargs */
+
+#include "DEFS.h"
+
+ENTRY(nargs, 0)
+ movzbl *8(fp),r0 /* 8(fp) is old ap */
+ ret
--- /dev/null
+#include "gen.h"
+void remque(elem) struct qelem *elem; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1987 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)remque.c 5.1 (Berkeley) 1/27/87";
+#endif LIBC_SCCS and not lint
+
+/*
+ * remque -- vax remque instruction
+ *
+ * NOTE: this implementation is non-atomic!!
+ */
+
+struct vaxque { /* queue format expected by VAX queue instructions */
+ struct vaxque *vq_next;
+ struct vaxque *vq_prev;
+};
+
+remque(e)
+ register struct vaxque *e;
+{
+ e->vq_prev->vq_next = e->vq_next;
+ e->vq_next->vq_prev = e->vq_prev;
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)remque.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* remque(entry) */
+
+#include "DEFS.h"
+
+ENTRY(remque, 0)
+ remque *4(ap),r0
+ ret
--- /dev/null
+#include "gen.h"
+char *rindex(s, c) char *s, c; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)rindex.c 5.4 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+#include <stdio.h>
+
+char *
+rindex(p, ch)
+ register char *p, ch;
+{
+ register char *save;
+
+ for (save = NULL;; ++p) {
+ if (*p == ch)
+ save = p;
+ if (!*p)
+ return(save);
+ }
+ /* NOTREACHED */
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)rindex.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * Find the last occurence of c in the string cp.
+ * Return pointer to match or null pointer.
+ *
+ * char *
+ * rindex(cp, c)
+ * char *cp, c;
+ */
+#include "DEFS.h"
+
+ENTRY(rindex, 0)
+ movq 4(ap),r1 # r1 = cp; r2 = c
+ tstl r2 # check for special case c == '\0'
+ bneq 2f
+1:
+ locc $0,$65535,(r1) # just find end of string
+ beql 1b # still looking
+ movl r1,r0 # found it
+ ret
+2:
+ moval tbl,r3 # r3 = address of table
+ bbss $0,(r3),5f # insure not reentering
+ movab (r3)[r2],r5 # table entry for c
+ incb (r5)
+ clrl r4 # last found
+3:
+ scanc $65535,(r1),(r3),$1 # look for c or '\0'
+ beql 3b # keep looking
+ tstb (r1) # if have found '\0'
+ beql 4f # we are done
+ movl r1,r4 # save most recently found
+ incl r1 # skip over character
+ jbr 3b # keep looking
+4:
+ movl r4,r0 # return last found (if any)
+ clrb (r5) # clean up table
+ clrb (r3)
+ ret
+
+ .data
+tbl: .space 256
+ .text
+
+/*
+ * Reentrant, but slower version of rindex
+ */
+5:
+ movl r1,r3
+ clrl r4 # r4 = pointer to last match
+6:
+ locc $0,$65535,(r3) # look for '\0'
+ bneq 8f
+ decw r0 # r0 = 65535
+1:
+ locc r2,r0,(r3) # look for c
+ bneq 7f
+ movl r1,r3 # reset pointer and ...
+ jbr 6b # ... try again
+7:
+ movl r1,r4 # stash pointer ...
+ addl3 $1,r1,r3 # ... skip over match and ...
+ decl r0 # ... decrement count
+ jbr 6b # ... try again
+8:
+ subl3 r3,r1,r0 # length of short block
+ incl r0 # +1 for '\0'
+9:
+ locc r2,r0,(r3) # look for c
+ beql 0f
+ movl r1,r4 # stash pointer ...
+ addl3 $1,r1,r3 # ... skip over match ...
+ decl r0 # ... adjust count and ...
+ jbr 9b # ... try again
+0:
+ movl r4,r0 # return stashed pointer
+ ret
--- /dev/null
+#include "gen.h"
+int setjmp(e) jmp_buf e; {
+ abort();
+}
+void longjmp(e, v) jmp_buf e; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)setjmp.s 5.5 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * C library -- setjmp, longjmp
+ *
+ * longjmp(a,v)
+ * will generate a "return(v)" from
+ * the last call to
+ * setjmp(a)
+ * by restoring registers from the stack,
+ * and a struct sigcontext, see <signal.h>
+ */
+
+#include "DEFS.h"
+
+ENTRY(setjmp, R6)
+ movl 4(ap),r6 # construct sigcontext
+ subl2 $8,sp # space for current struct sigstack
+ pushl sp # get current values
+ pushl $0 # no new values
+ calls $3,_sigstack # pop args plus signal stack value
+ movl (sp)+,(r6)+ # save onsigstack status of caller
+ pushl $0
+ calls $1,_sigblock # get signal mask
+ movl r0,(r6)+ # save signal mask of caller
+ movl (ap),r0
+ moval 4(ap)[r0],(r6)+ # save sp of caller
+ movl 12(fp),(r6)+ # save frame pointer of caller
+ movl 8(fp),(r6)+ # save argument pointer of caller
+ movl 16(fp),(r6)+ # save pc of caller
+ movpsl (r6) # save psl of caller
+ movw 4(fp),(r6)
+ clrl r0
+ ret
+
+ENTRY(longjmp, 0)
+ movl 8(ap),r0 # return(v)
+ movl 4(ap),r1 # fetch buffer
+ tstl 12(r1)
+ beql botch
+loop:
+ cmpl 12(r1),fp # are we there yet?
+ beql done
+ blssu botch
+ moval 20(fp),r2
+ blbc 6(fp),1f # was r0 saved?
+ movl r0,(r2)+
+1:
+ bbc $1,6(fp),2f # was r1 saved?
+ movl r1,(r2)
+2:
+ movl $loop,16(fp)
+ ret # pop another frame
+
+done:
+
+#ifndef NOCOMPAT
+/*
+ * This code checks to see if it can use the new sigreturn.
+ * If it finds that sigtramp is using the new system call,
+ * it will also use it. Otherwise it uses the old system call
+ * to preserve compatibility.
+ */
+#include <vax/machparam.h>
+#define U (0x80000000-UPAGES*NBPG)
+#define PCB_SIGC 0x6c
+#define CHMKINS 7
+ cmpl 3f,U+PCB_SIGC+CHMKINS # check to see how sigtramp returns
+ beql 4f # sigtramp uses the new system call
+ pushl r1 # must use the old signal return
+ chmk $139 # restore previous context
+ jmp *20(r1) # done, return
+3:
+ chmk $103 # the new system call for sigreturn
+4:
+#endif NOCOMPAT
+
+ pushl r1 # pointer to sigcontext
+ calls $1,_sigreturn # restore previous context
+ # we should never return
+botch:
+ calls $0,_longjmperror
+ halt
--- /dev/null
+#include "gen.h"
+char *strcat(a, b) char *a, *b; {
+ abort();
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcat.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Concatenate s2 on the end of s1. S1's space must be large enough.
+ * Return s1.
+ */
+
+char *
+strcat(s1, s2)
+register char *s1, *s2;
+{
+ register char *os1;
+
+ os1 = s1;
+ while (*s1++)
+ ;
+ --s1;
+ while (*s1++ = *s2++)
+ ;
+ return(os1);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)strcat.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * Concatenate string s2 to the end of s1
+ * and return the base of s1.
+ *
+ * char *
+ * strcat(s1, s2)
+ * char *s1, *s2;
+ */
+#include "DEFS.h"
+
+ENTRY(strcat, R6|R7)
+ movq 4(ap), r6 # r6 = s1; r7 = s2
+ movl r6,r1
+0:
+ locc $0,$65535,(r1) # look for '\0'
+ beql 0b
+ movl r1,r3 # save end of s1
+1:
+ locc $0,$65535,(r7) # find length of s2
+ bneq 2f
+ movc3 $65535,(r7),(r3)# copy full block
+ movl r1,r7
+ jbr 1b
+2:
+ subl2 r7,r1 # calculate length
+ incl r1
+ movc3 r1,(r7),(r3) # copy remainder
+ movl r6,r0
+ ret
--- /dev/null
+#include "gen.h"
+int strcmp(a, b) char *a, *b; {
+ abort();
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcmp.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Compare strings: s1>s2: >0 s1==s2: 0 s1<s2: <0
+ */
+
+strcmp(s1, s2)
+register char *s1, *s2;
+{
+
+ while (*s1 == *s2++)
+ if (*s1++=='\0')
+ return(0);
+ return(*s1 - *--s2);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)strcmp.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * Compare string s1 lexicographically to string s2.
+ * Return:
+ * 0 s1 == s2
+ * > 0 s1 > s2
+ * < 0 s2 < s2
+ *
+ * strcmp(s1, s2)
+ * char *s1, *s2;
+ */
+#include "DEFS.h"
+
+ENTRY(strcmp, 0)
+ movl 4(ap),r1 # r1 = s1
+ movl 8(ap),r3 # r3 = s2
+ subb3 (r3),(r1),r0 # quick check for first char different
+ beql 1f # have to keep checking
+ cvtbl r0,r0
+ ret
+1:
+ clrl r5 # calculate min bytes to next page boundry
+ subb3 r1,$255,r5 # r5 = (bytes - 1) to end of page for s1
+ subb3 r3,$255,r0 # r0 = (bytes - 1) to end of page for s2
+ cmpb r0,r5 # r5 = min(r0, r5);
+ bgtru 2f
+ movb r0,r5
+2:
+ incl r5 # r5 = min bytes to next page boundry
+ cmpc3 r5,(r1),(r3) # compare strings
+ bneq 3f
+ subl2 r5,r1 # check if found null yet
+ locc $0,r5,(r1)
+ beql 1b # not yet done, continue checking
+ subl2 r0,r3
+ mnegb (r3),r0 # r0 = '\0' - *s2
+ cvtbl r0,r0
+ ret
+3:
+ subl2 r0,r5 # check for null in matching string
+ subl2 r5,r1
+ locc $0,r5,(r1)
+ bneq 4f
+ subb3 (r3),(r1),r0 # r0 = *s1 - *s2
+ cvtbl r0,r0
+ ret
+4:
+ clrl r0 # both the same to null
+ ret
--- /dev/null
+#include "gen.h"
+char *strcpy(a, b) char *a, *b; {
+ abort();
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strcpy.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Copy string s2 to s1. s1 must be large enough.
+ * return s1
+ */
+
+char *
+strcpy(s1, s2)
+register char *s1, *s2;
+{
+ register char *os1;
+
+ os1 = s1;
+ while (*s1++ = *s2++)
+ ;
+ return(os1);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)strcpy.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * Copy string s2 over top of s1.
+ * Return base of s1.
+ *
+ * char *
+ * strcpy(s1, s2)
+ * char *s1, *s2;
+ */
+#include "DEFS.h"
+
+ENTRY(strcpy, R6)
+ movl 4(ap), r3 # r3 = s1
+ movl 8(ap), r6 # r6 = s2
+1:
+ locc $0,$65535,(r6) # find length of s2
+ bneq 2f
+ movc3 $65535,(r6),(r3)# copy full block
+ movl r1,r6
+ jbr 1b
+2:
+ subl2 r6,r1 # calculate length
+ incl r1
+ movc3 r1,(r6),(r3) # copy remainder
+ movl 4(ap),r0 # return base of s1
+ ret
--- /dev/null
+#include "gen.h"
+int strlen(s) char *s; {
+ abort();
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strlen.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Returns the number of
+ * non-NULL bytes in string argument.
+ */
+
+strlen(s)
+register char *s;
+{
+ register n;
+
+ n = 0;
+ while (*s++)
+ n++;
+ return(n);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)strlen.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * Return the length of cp (not counting '\0').
+ *
+ * strlen(cp)
+ * char *cp;
+ */
+#include "DEFS.h"
+
+ENTRY(strlen, 0)
+ movl 4(ap),r1
+1:
+ locc $0,$65535,(r1) # look for '\0'
+ beql 1b
+ subl3 4(ap),r1,r0 # len = cp - base
+ ret
--- /dev/null
+#include "gen.h"
+char *strncat(a, b, n) char *a, *b; {
+ abort();
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strncat.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Concatenate s2 on the end of s1. S1's space must be large enough.
+ * At most n characters are moved.
+ * Return s1.
+ */
+
+char *
+strncat(s1, s2, n)
+register char *s1, *s2;
+register n;
+{
+ register char *os1;
+
+ os1 = s1;
+ while (*s1++)
+ ;
+ --s1;
+ while (*s1++ = *s2++)
+ if (--n < 0) {
+ *--s1 = '\0';
+ break;
+ }
+ return(os1);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)strncat.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * Concatenate string s2 on the end of s1
+ * and return the base of s1. The parameter
+ * n is the maximum length of string s2 to
+ * concatenate.
+ *
+ * char *
+ * strncat(s1, s2, n)
+ * char *s1, *s2;
+ * int n;
+ */
+#include "DEFS.h"
+
+ENTRY(strncat, R6)
+ movl 12(ap),r6 # r6 = n
+ bleq done # n <= 0
+ movl 4(ap),r3 # r3 = s1
+ movl r3,r1
+0:
+ locc $0,$65535,(r1)
+ beql 0b
+ movl r1,r3 # r3 = index(s1, '\0');
+ movl 8(ap),r1 # r1 = s2
+1:
+ movzwl $65535,r2 # r2 = bytes in first chunk
+ cmpl r6,r2 # r2 = min(bytes in chunk, n);
+ jgeq 2f
+ movl r6,r2
+2:
+ subl2 r2,r6 # update n
+ locc $0,r2,(r1) # '\0' found?
+ jneq 3f
+ subl2 r2,r1 # back up pointer updated by locc
+ movc3 r2,(r1),(r3) # copy in next piece
+ tstl r6 # run out of space?
+ jneq 1b
+ clrb (r3) # force '\0' termination
+ jbr done
+3:
+ subl2 r0,r2 # r2 = number of bytes to move
+ subl2 r2,r1 # back up pointer updated by locc
+ incl r2 # copy '\0' as well
+ movc3 r2,(r1),(r3) # copy in last piece
+done:
+ movl 4(ap),r0 # return s1
+ ret
--- /dev/null
+#include "gen.h"
+int strncmp(a, b, n) char *a, *b; {
+ abort();
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strncmp.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Compare strings (at most n bytes): s1>s2: >0 s1==s2: 0 s1<s2: <0
+ */
+
+strncmp(s1, s2, n)
+register char *s1, *s2;
+register n;
+{
+
+ while (--n >= 0 && *s1 == *s2++)
+ if (*s1++ == '\0')
+ return(0);
+ return(n<0 ? 0 : *s1 - *--s2);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)strncmp.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * Compare at most n characters of string
+ * s1 lexicographically to string s2.
+ * Return:
+ * 0 s1 == s2
+ * > 0 s1 > s2
+ * < 0 s2 < s2
+ *
+ * strncmp(s1, s2, n)
+ * char *s1, *s2;
+ * int n;
+ */
+#include "DEFS.h"
+
+ENTRY(strncmp, 0)
+ movl 4(ap),r1 # r1 = s1
+ movq 8(ap),r3 # r3 = s2; r4 = n
+1:
+ clrl r5 # calculate min bytes to next page boundry
+ subb3 r1,$255,r5 # r5 = (bytes - 1) to end of page for s1
+ subb3 r3,$255,r0 # r0 = (bytes - 1) to end of page for s2
+ cmpb r0,r5 # r5 = min(r0, r5);
+ bgtru 2f
+ movb r0,r5
+2:
+ incl r5 # r5 = min bytes to next page boundry
+ cmpl r4,r5 # r5 = min(n, r5);
+ bgeq 3f
+ movl r4,r5
+3:
+ cmpc3 r5,(r1),(r3) # compare strings
+ bneq 4f
+ subl2 r5,r4 # check for end of comparison
+ beql 5f
+ subl2 r5,r1 # check if found null yet
+ locc $0,r5,(r1)
+ beql 1b # not yet done, continue checking
+ subl2 r0,r3
+ mnegb (r3),r0 # r0 = '\0' - *s2
+ cvtbl r0,r0
+ ret
+4:
+ subl2 r0,r5 # check for null in matching string
+ subl2 r5,r1
+ locc $0,r5,(r1)
+ bneq 5f
+ subb3 (r3),(r1),r0 # r0 = *s1 - *s2
+ cvtbl r0,r0
+ ret
+5:
+ clrl r0 # both the same to null
+ ret
--- /dev/null
+#include "gen.h"
+char *strncpy(a, b, n) char *a, *b; {
+ abort();
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)strncpy.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+/*
+ * Copy s2 to s1, truncating or null-padding to always copy n bytes
+ * return s1
+ */
+
+char *
+strncpy(s1, s2, n)
+register char *s1, *s2;
+{
+ register i;
+ register char *os1;
+
+ os1 = s1;
+ for (i = 0; i < n; i++)
+ if ((*s1++ = *s2++) == '\0') {
+ while (++i < n)
+ *s1++ = '\0';
+ return(os1);
+ }
+ return(os1);
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+ .asciz "@(#)strncpy.s 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * Copy string s2 over top of string s1.
+ * Truncate or null-pad to n bytes.
+ *
+ * char *
+ * strncpy(s1, s2, n)
+ * char *s1, *s2;
+ */
+#include "DEFS.h"
+
+ENTRY(strncpy, R6)
+ movl 12(ap),r6 # r6 = n
+ bleq done # n <= 0
+ movl 4(ap),r3 # r3 = s1
+ movl 8(ap),r1 # r1 = s2
+1:
+ movzwl $65535,r2 # r2 = bytes in first chunk
+ cmpl r6,r2 # r2 = min(bytes in chunk, n);
+ jgeq 2f
+ movl r6,r2
+2:
+ subl2 r2,r6 # update n
+ locc $0,r2,(r1) # '\0' found?
+ jneq 3f
+ subl2 r2,r1 # back up pointer updated by locc
+ movc3 r2,(r1),(r3) # copy in next piece
+ tstl r6 # run out of space?
+ jneq 1b
+ jbr done
+3: # copy up to '\0' logic
+ addl2 r0,r6 # r6 = number of null-pad bytes
+ subl2 r0,r2 # r2 = number of bytes to move
+ subl2 r2,r1 # back up pointer updated by locc
+ movc3 r2,(r1),(r3) # copy in last piece
+4: # null-pad logic
+ movzwl $65535,r2 # r2 = bytes in first chunk
+ cmpl r6,r2 # r2 = min(bytes in chunk, n);
+ jgeq 5f
+ movl r6,r2
+5:
+ subl2 r2,r6 # update n
+ movc5 $0,(r3),$0,r2,(r3)# pad with '\0's
+ tstl r6 # finished padding?
+ jneq 4b
+done:
+ movl 4(ap),r0 # return s1
+ ret
--- /dev/null
+#ifdef LIBC_SCCS
+ .asciz "@(#)udiv.s 5.2 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * udiv - unsigned division for vax-11
+ *
+ * arguments: dividend, divisor.
+ * result: quotient.
+ * uses r0-r2
+ *
+ * If 1 < divisor <= 2147483647, zero-extend the dividend
+ * to 64 bits and let ediv do the work. If the divisor is 1,
+ * ediv will overflow if bit 31 of the dividend is on, so
+ * just return the dividend unchanged. If the divisor is 0,
+ * do the ediv also, so it will generate the proper exception.
+ * All other values of the divisor have bit 31 on: in this case
+ * the quotient must be 0 if divisor > dividend, and 1 otherwise,
+ * provided that the comparison is made as unsigned.
+ */
+
+#include "DEFS.h"
+
+ASENTRY(udiv, 0)
+ movl 4(ap),r0 /* dividend */
+ movl 8(ap),r2 /* divisor */
+ jeql 1f /* if divisor=0, force exception */
+ cmpl r2,$1 /* if divisor <= 1 (signed), */
+ jleq 2f /* no division is necessary */
+1:
+ clrl r1 /* zero-extend the dividend */
+ ediv r2,r0,r0,r2 /* divide. q->r0, r->r2 (discarded) */
+ ret
+2:
+ jeql 1f /* if divisor=1, return dividend */
+ cmpl r0,r2 /* unsigned comparison between */
+ jgequ 2f /* dividend and divisor */
+ clrl r0 /* dividend < divisor, return 0 */
+ ret
+2:
+ movl $1,r0 /* dividend >= divisor, return 1 */
+1:
+ ret
+
+/*
+ * audiv - unsigned division for vax-11
+ *
+ * arguments: *dividend, divisor.
+ * result: quotient in r0 and *dividend.
+ * uses r0-r2
+ */
+
+#include "DEFS.h"
+
+ASENTRY(audiv, 0)
+ movl *4(ap),r0 /* dividend */
+ movl 8(ap),r2 /* divisor */
+ jeql 1f /* if divisor=0, force exception */
+ cmpl r2,$1 /* if divisor <= 1 (signed), */
+ jleq 2f /* no division is necessary */
+1:
+ clrl r1 /* zero-extend the dividend */
+ ediv r2,r0,r0,r2 /* divide. q->r0, r->r2 (discarded) */
+ movl r0,*4(ap) /* save result */
+ ret
+2:
+ jeql 1f /* if divisor=1, return dividend */
+ cmpl r0,r2 /* unsigned comparison between */
+ jgequ 2f /* dividend and divisor */
+ clrl r0 /* dividend < divisor, return 0 */
+ clrl *4(ap) /* save result */
+ ret
+2:
+ movl $1,r0 /* dividend >= divisor, return 1 */
+1:
+ movl r0,*4(ap) /* save result */
+ ret
--- /dev/null
+#ifdef LIBC_SCCS
+ .asciz "@(#)urem.s 5.2 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * urem - unsigned remainder for vax-11
+ *
+ * arguments: dividend, divisor
+ * result: remainder
+ * uses r0-r2
+ *
+ * if 1 < divisor <= 2147483647, zero-extend the dividend
+ * to 64 bits and let ediv do the work. If the divisor is 1,
+ * ediv will overflow if bit 31 of the dividend is on, so
+ * just return 0. If the divisor is 0, do the ediv also,
+ * so it will generate the proper exception. All other values
+ * of the divisor have bit 31 on: in this case the remainder
+ * must be the dividend if divisor > dividend, and the dividend
+ * minus the divisor otherwise. The comparison must be unsigned.
+ */
+#include "DEFS.h"
+
+ASENTRY(urem, 0)
+ movl 4(ap),r0 /* dividend */
+ movl 8(ap),r2 /* divisor */
+ jeql 1f /* if divisor=0, force exception */
+ cmpl r2,$1 /* if divisor <= 1 (signed), */
+ jleq 2f /* no division is necessary */
+1:
+ clrl r1 /* zero-extend the dividend */
+ ediv r2,r0,r2,r0 /* divide. q->r2 (discarded), r->r0 */
+ ret
+2:
+ jneq 1f /* if divisor=1, return 0 */
+ clrl r0 /* (because doing the divide will overflow */
+ ret /* if the dividend has its high bit on) */
+1:
+ cmpl r0,r2 /* if dividend < divisor (unsigned) */
+ jlssu 1f /* remainder is dividend */
+ subl2 r2,r0 /* else remainder is dividend - divisor */
+1:
+ ret
+
+/*
+ * aurem - unsigned remainder for vax-11
+ *
+ * arguments: *dividend, divisor
+ * result: remainder in r0 and *dividend
+ * uses r0-r2
+ */
+#include "DEFS.h"
+
+ASENTRY(aurem, 0)
+ movl *4(ap),r0 /* dividend */
+ movl 8(ap),r2 /* divisor */
+ jeql 1f /* if divisor=0, force exception */
+ cmpl r2,$1 /* if divisor <= 1 (signed), */
+ jleq 2f /* no division is necessary */
+1:
+ clrl r1 /* zero-extend the dividend */
+ ediv r2,r0,r2,r0 /* divide. q->r2 (discarded), r->r0 */
+ movl r0,*4(ap) /* save result */
+ ret
+2:
+ jneq 1f /* if divisor=1, return 0 */
+ clrl r0 /* (because doing the divide will overflow */
+ clrl *4(ap) /* if the dividend has its high bit on) */
+ ret
+1:
+ cmpl r0,r2 /* if dividend < divisor (unsigned) */
+ jlssu 1f /* remainder is dividend */
+ subl2 r2,r0 /* else remainder is dividend - divisor */
+1:
+ movl r0,*4(ap) /* save result */
+ ret
--- /dev/null
+#
+# Copyright (c) 1983 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 5.4 (Berkeley) 9/5/85
+#
+SRCS= htonl.c htons.c ntohl.c ntohs.c
+OBJS= htonl.o htons.o ntohl.o ntohs.o
+CFLAGS= ${DEFS}
+TAGSFILE=tags
+
+.c.o:
+ /lib/cpp -E ${CFLAGS} -DPROF $*.c | ${AS} -o $*.o
+ -ld -x -r $*.o
+ mv a.out profiled/$*.o
+ /lib/cpp -E ${CFLAGS} $*.c | ${AS} -o $*.o
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+netlib netlib_p: ${OBJS}
+ @echo "building profiled netlib"
+ @cd profiled; ar cru ../netlib_p ${OBJS}
+ @echo "building normal netlib"
+ @ar cru netlib ${OBJS}
+
+tags:
+# cwd=`pwd`; \
+# for i in ${SRCS}; do \
+# ctags -a -f ${TAGSFILE} $$cwd/$$i; \
+# done
+
+clean:
+ rm -f *.o profiled/*.o errs a.out core netlib netlib_p \
+ tags Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+htonl.o: htonl.c ./DEFS.h
+htons.o: htons.c ./DEFS.h
+ntohl.o: ntohl.c ./DEFS.h
+ntohs.o: ntohs.c ./DEFS.h
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+#include "gen.h"
+u_long htonl(hostlong) u_long hostlong; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+_sccsid:.asciz "@(#)htonl.c 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* netorder = htonl(hostorder) */
+
+#include "DEFS.h"
+
+ENTRY(htonl)
+ rotl $-8,4(ap),r0
+ insv r0,$16,$8,r0
+ movb 7(ap),r0
+ ret
--- /dev/null
+#include "gen.h"
+u_short htons(hostshort) u_short hostshort; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+_sccsid:.asciz "@(#)htons.c 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* hostorder = htons(netorder) */
+
+#include "DEFS.h"
+
+ENTRY(htons)
+ rotl $8,4(ap),r0
+ movb 5(ap),r0
+ movzwl r0,r0
+ ret
--- /dev/null
+#include "gen.h"
+u_long ntohl(netlong) u_long netlong; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+_sccsid:.asciz "@(#)ntohl.c 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* hostorder = ntohl(netorder) */
+
+#include "DEFS.h"
+
+ENTRY(ntohl)
+ rotl $-8,4(ap),r0
+ insv r0,$16,$8,r0
+ movb 7(ap),r0
+ ret
--- /dev/null
+#include "gen.h"
+u_short ntohs(netshort) u_short netshort; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+_sccsid:.asciz "@(#)ntohs.c 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/* hostorder = ntohs(netorder) */
+
+#include "DEFS.h"
+
+ENTRY(ntohs)
+ rotl $8,4(ap),r0
+ movb 5(ap),r0
+ movzwl r0,r0
+ ret
--- /dev/null
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 5.4 (Berkeley) 9/5/85
+#
+# printf & co are here because they are machine dependent
+#
+CFLAGS= ${DEFS} -I../gen
+OBJS= doprnt.o fputs.o fgets.o puts.o gets.o
+SRCS= doprnt.c fputs.c fgets.c puts.c gets.c
+TAGSFILE=tags
+
+.c.o:
+ cc -E -DPROF ${CFLAGS} $*.c | as -o $*.o
+ -ld -x -r $*.o
+ mv a.out profiled/$*.o
+ cc -E ${CFLAGS} $*.c | as -o $*.o
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+stdiolib stdiolib_p: ${OBJS}
+ @echo "building profiled stdiolib"
+ @cd profiled; ar cru ../stdiolib_p ${OBJS}
+ @echo "building normal stdiolib"
+ @ar cru stdiolib ${OBJS}
+
+tags:
+
+clean:
+ rm -f stdiolib stdiolib_p *.o profiled/*.o tags Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${CFLAGS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+doprnt.o: doprnt.c ../gen/DEFS.h
+fputs.o: fputs.c ../gen/DEFS.h
+fgets.o: fgets.c ../gen/DEFS.h
+puts.o: puts.c ../gen/DEFS.h
+gets.o: gets.c ../gen/DEFS.h
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley. The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)doprnt.c 5.35 (Berkeley) 6/27/88";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+#include <varargs.h>
+#include <stdio.h>
+#include <ctype.h>
+
+/* 11-bit exponent (VAX G floating point) is 308 decimal digits */
+#define MAXEXP 308
+/* 128 bit fraction takes up 39 decimal digits; max reasonable precision */
+#define MAXFRACT 39
+
+#define DEFPREC 6
+
+#define BUF (MAXEXP+MAXFRACT+1) /* + decimal point */
+
+#define PUTC(ch) (void) putc(ch, fp)
+
+#define ARG() \
+ _ulong = flags&LONGINT ? va_arg(argp, long) : \
+ flags&SHORTINT ? va_arg(argp, short) : va_arg(argp, int);
+
+#define todigit(c) ((c) - '0')
+#define tochar(n) ((n) + '0')
+
+/* have to deal with the negative buffer count kludge */
+#define NEGATIVE_COUNT_KLUDGE
+
+#define LONGINT 0x01 /* long integer */
+#define LONGDBL 0x02 /* long double; unimplemented */
+#define SHORTINT 0x04 /* short integer */
+#define ALT 0x08 /* alternate form */
+#define LADJUST 0x10 /* left adjustment */
+#define ZEROPAD 0x20 /* zero (as opposed to blank) pad */
+#define HEXPREFIX 0x40 /* add 0x or 0X prefix */
+
+_doprnt(fmt0, argp, fp)
+ u_char *fmt0;
+ va_list argp;
+ register FILE *fp;
+{
+ register u_char *fmt; /* format string */
+ register int ch; /* character from fmt */
+ register int cnt; /* return value accumulator */
+ register int n; /* random handy integer */
+ register char *t; /* buffer pointer */
+ double _double; /* double precision arguments %[eEfgG] */
+ u_long _ulong; /* integer arguments %[diouxX] */
+ int base; /* base for [diouxX] conversion */
+ int dprec; /* decimal precision in [diouxX] */
+ int fieldsz; /* field size expanded by sign, etc */
+ int flags; /* flags as above */
+ int fpprec; /* `extra' floating precision in [eEfgG] */
+ int prec; /* precision from format (%.3d), or -1 */
+ int realsz; /* field size expanded by decimal precision */
+ int size; /* size of converted field or string */
+ int width; /* width from format (%8d), or 0 */
+ char sign; /* sign prefix (' ', '+', '-', or \0) */
+ char softsign; /* temporary negative sign for floats */
+ char *digs; /* digits for [diouxX] conversion */
+ char buf[BUF]; /* space for %c, %[diouxX], %[eEfgG] */
+
+ if (fp->_flag & _IORW) {
+ fp->_flag |= _IOWRT;
+ fp->_flag &= ~(_IOEOF|_IOREAD);
+ }
+ if ((fp->_flag & _IOWRT) == 0)
+ return (EOF);
+
+ fmt = fmt0;
+ digs = "0123456789abcdef";
+ for (cnt = 0;; ++fmt) {
+ n = fp->_cnt;
+ for (t = (char *)fp->_ptr; (ch = *fmt) && ch != '%';
+ ++cnt, ++fmt)
+ if (--n < 0
+#ifdef NEGATIVE_COUNT_KLUDGE
+ && (!(fp->_flag & _IOLBF) || -n >= fp->_bufsiz)
+#endif
+ || ch == '\n' && fp->_flag & _IOLBF) {
+ fp->_cnt = n;
+ fp->_ptr = t;
+ (void) _flsbuf((u_char)ch, fp);
+ n = fp->_cnt;
+ t = (char *)fp->_ptr;
+ } else
+ *t++ = ch;
+ fp->_cnt = n;
+ fp->_ptr = t;
+ if (!ch)
+ return (cnt);
+
+ flags = 0; dprec = 0; fpprec = 0; width = 0;
+ prec = -1;
+ sign = '\0';
+
+rflag: switch (*++fmt) {
+ case ' ':
+ /*
+ * ``If the space and + flags both appear, the space
+ * flag will be ignored.''
+ * -- ANSI X3J11
+ */
+ if (!sign)
+ sign = ' ';
+ goto rflag;
+ case '#':
+ flags |= ALT;
+ goto rflag;
+ case '*':
+ /*
+ * ``A negative field width argument is taken as a
+ * - flag followed by a positive field width.''
+ * -- ANSI X3J11
+ * They don't exclude field widths read from args.
+ */
+ if ((width = va_arg(argp, int)) >= 0)
+ goto rflag;
+ width = -width;
+ /* FALLTHROUGH */
+ case '-':
+ flags |= LADJUST;
+ goto rflag;
+ case '+':
+ sign = '+';
+ goto rflag;
+ case '.':
+ if (*++fmt == '*')
+ n = va_arg(argp, int);
+ else {
+ n = 0;
+ while (isascii(*fmt) && isdigit(*fmt))
+ n = 10 * n + todigit(*fmt++);
+ --fmt;
+ }
+ prec = n < 0 ? -1 : n;
+ goto rflag;
+ case '0':
+ /*
+ * ``Note that 0 is taken as a flag, not as the
+ * beginning of a field width.''
+ * -- ANSI X3J11
+ */
+ flags |= ZEROPAD;
+ goto rflag;
+ case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ n = 0;
+ do {
+ n = 10 * n + todigit(*fmt);
+ } while (isascii(*++fmt) && isdigit(*fmt));
+ width = n;
+ --fmt;
+ goto rflag;
+ case 'L':
+ flags |= LONGDBL;
+ goto rflag;
+ case 'h':
+ flags |= SHORTINT;
+ goto rflag;
+ case 'l':
+ flags |= LONGINT;
+ goto rflag;
+ case 'c':
+ *(t = buf) = va_arg(argp, int);
+ size = 1;
+ sign = '\0';
+ goto pforw;
+ case 'D':
+ flags |= LONGINT;
+ /*FALLTHROUGH*/
+ case 'd':
+ case 'i':
+ ARG();
+ if ((long)_ulong < 0) {
+ _ulong = -_ulong;
+ sign = '-';
+ }
+ base = 10;
+ goto number;
+ case 'e':
+ case 'E':
+ case 'f':
+ case 'g':
+ case 'G':
+ _double = va_arg(argp, double);
+ /*
+ * don't do unrealistic precision; just pad it with
+ * zeroes later, so buffer size stays rational.
+ */
+ if (prec > MAXFRACT) {
+ if (*fmt != 'g' && *fmt != 'G' || (flags&ALT))
+ fpprec = prec - MAXFRACT;
+ prec = MAXFRACT;
+ }
+ else if (prec == -1)
+ prec = DEFPREC;
+ /*
+ * softsign avoids negative 0 if _double is < 0 and
+ * no significant digits will be shown
+ */
+ if (_double < 0) {
+ softsign = '-';
+ _double = -_double;
+ }
+ else
+ softsign = 0;
+ /*
+ * cvt may have to round up past the "start" of the
+ * buffer, i.e. ``intf("%.2f", (double)9.999);'';
+ * if the first char isn't NULL, it did.
+ */
+ *buf = NULL;
+ size = cvt(_double, prec, flags, &softsign, *fmt, buf,
+ buf + sizeof(buf));
+ if (softsign)
+ sign = '-';
+ t = *buf ? buf : buf + 1;
+ goto pforw;
+ case 'n':
+ if (flags & LONGINT)
+ *va_arg(argp, long *) = cnt;
+ else if (flags & SHORTINT)
+ *va_arg(argp, short *) = cnt;
+ else
+ *va_arg(argp, int *) = cnt;
+ break;
+ case 'O':
+ flags |= LONGINT;
+ /*FALLTHROUGH*/
+ case 'o':
+ ARG();
+ base = 8;
+ goto nosign;
+ case 'p':
+ /*
+ * ``The argument shall be a pointer to void. The
+ * value of the pointer is converted to a sequence
+ * of printable characters, in an implementation-
+ * defined manner.''
+ * -- ANSI X3J11
+ */
+ /* NOSTRICT */
+ _ulong = (u_long)va_arg(argp, void *);
+ base = 16;
+ goto nosign;
+ case 's':
+ if (!(t = va_arg(argp, char *)))
+ t = "(null)";
+ if (prec >= 0) {
+ /*
+ * can't use strlen; can only look for the
+ * NUL in the first `prec' characters, and
+ * strlen() will go further.
+ */
+ char *p, *memchr();
+
+ if (p = memchr(t, 0, prec)) {
+ size = p - t;
+ if (size > prec)
+ size = prec;
+ } else
+ size = prec;
+ } else
+ size = strlen(t);
+ sign = '\0';
+ goto pforw;
+ case 'U':
+ flags |= LONGINT;
+ /*FALLTHROUGH*/
+ case 'u':
+ ARG();
+ base = 10;
+ goto nosign;
+ case 'X':
+ digs = "0123456789ABCDEF";
+ /* FALLTHROUGH */
+ case 'x':
+ ARG();
+ base = 16;
+ /* leading 0x/X only if non-zero */
+ if (flags & ALT && _ulong != 0)
+ flags |= HEXPREFIX;
+
+ /* unsigned conversions */
+nosign: sign = '\0';
+ /*
+ * ``... diouXx conversions ... if a precision is
+ * specified, the 0 flag will be ignored.''
+ * -- ANSI X3J11
+ */
+number: if ((dprec = prec) >= 0)
+ flags &= ~ZEROPAD;
+
+ /*
+ * ``The result of converting a zero value with an
+ * explicit precision of zero is no characters.''
+ * -- ANSI X3J11
+ */
+ t = buf + BUF;
+ if (_ulong != 0 || prec != 0) {
+ do {
+ *--t = digs[_ulong % base];
+ _ulong /= base;
+ } while (_ulong);
+ digs = "0123456789abcdef";
+ if (flags & ALT && base == 8 && *t != '0')
+ *--t = '0'; /* octal leading 0 */
+ }
+ size = buf + BUF - t;
+
+pforw:
+ /*
+ * All reasonable formats wind up here. At this point,
+ * `t' points to a string which (if not flags&LADJUST)
+ * should be padded out to `width' places. If
+ * flags&ZEROPAD, it should first be prefixed by any
+ * sign or other prefix; otherwise, it should be blank
+ * padded before the prefix is emitted. After any
+ * left-hand padding and prefixing, emit zeroes
+ * required by a decimal [diouxX] precision, then print
+ * the string proper, then emit zeroes required by any
+ * leftover floating precision; finally, if LADJUST,
+ * pad with blanks.
+ */
+
+ /*
+ * compute actual size, so we know how much to pad
+ * fieldsz excludes decimal prec; realsz includes it
+ */
+ fieldsz = size + fpprec;
+ if (sign)
+ fieldsz++;
+ if (flags & HEXPREFIX)
+ fieldsz += 2;
+ realsz = dprec > fieldsz ? dprec : fieldsz;
+
+ /* right-adjusting blank padding */
+ if ((flags & (LADJUST|ZEROPAD)) == 0 && width)
+ for (n = realsz; n < width; n++)
+ PUTC(' ');
+ /* prefix */
+ if (sign)
+ PUTC(sign);
+ if (flags & HEXPREFIX) {
+ PUTC('0');
+ PUTC((char)*fmt);
+ }
+ /* right-adjusting zero padding */
+ if ((flags & (LADJUST|ZEROPAD)) == ZEROPAD)
+ for (n = realsz; n < width; n++)
+ PUTC('0');
+ /* leading zeroes from decimal precision */
+ for (n = fieldsz; n < dprec; n++)
+ PUTC('0');
+
+ /* the string or number proper */
+ if (fp->_cnt - (n = size) >= 0 &&
+ (fp->_flag & _IOLBF) == 0) {
+ fp->_cnt -= n;
+ bcopy(t, (char *)fp->_ptr, n);
+ fp->_ptr += n;
+ } else
+ while (--n >= 0)
+ PUTC(*t++);
+ /* trailing f.p. zeroes */
+ while (--fpprec >= 0)
+ PUTC('0');
+ /* left-adjusting padding (always blank) */
+ if (flags & LADJUST)
+ for (n = realsz; n < width; n++)
+ PUTC(' ');
+ /* finally, adjust cnt */
+ cnt += width > realsz ? width : realsz;
+ break;
+ case '\0': /* "%?" prints ?, unless ? is NULL */
+ return (cnt);
+ default:
+ PUTC((char)*fmt);
+ cnt++;
+ }
+ }
+ /* NOTREACHED */
+}
+
+static
+cvt(number, prec, flags, signp, fmtch, startp, endp)
+ double number;
+ register int prec;
+ int flags;
+ u_char fmtch;
+ char *signp, *startp, *endp;
+{
+ register char *p, *t;
+ register double fract;
+ int dotrim, expcnt, gformat;
+ double integer, tmp, modf();
+ char *exponent(), *round();
+
+ dotrim = expcnt = gformat = 0;
+ fract = modf(number, &integer);
+
+ /* get an extra slot for rounding. */
+ t = ++startp;
+
+ /*
+ * get integer portion of number; put into the end of the buffer; the
+ * .01 is added for modf(356.0 / 10, &integer) returning .59999999...
+ */
+ for (p = endp - 1; integer; ++expcnt) {
+ tmp = modf(integer / 10, &integer);
+ *p-- = tochar((int)((tmp + .01) * 10));
+ }
+ switch(fmtch) {
+ case 'f':
+ /* reverse integer into beginning of buffer */
+ if (expcnt)
+ for (; ++p < endp; *t++ = *p);
+ else
+ *t++ = '0';
+ /*
+ * if precision required or alternate flag set, add in a
+ * decimal point.
+ */
+ if (prec || flags&ALT)
+ *t++ = '.';
+ /* if requires more precision and some fraction left */
+ if (fract) {
+ if (prec)
+ do {
+ fract = modf(fract * 10, &tmp);
+ *t++ = tochar((int)tmp);
+ } while (--prec && fract);
+ if (fract)
+ startp = round(fract, (int *)NULL, startp,
+ t - 1, (char)0, signp);
+ }
+ for (; prec--; *t++ = '0');
+ break;
+ case 'e':
+ case 'E':
+eformat: if (expcnt) {
+ *t++ = *++p;
+ if (prec || flags&ALT)
+ *t++ = '.';
+ /* if requires more precision and some integer left */
+ for (; prec && ++p < endp; --prec)
+ *t++ = *p;
+ /*
+ * if done precision and more of the integer component,
+ * round using it; adjust fract so we don't re-round
+ * later.
+ */
+ if (!prec && ++p < endp) {
+ fract = 0;
+ startp = round((double)0, &expcnt, startp,
+ t - 1, *p, signp);
+ }
+ /* adjust expcnt for digit in front of decimal */
+ --expcnt;
+ }
+ /* until first fractional digit, decrement exponent */
+ else if (fract) {
+ /* adjust expcnt for digit in front of decimal */
+ for (expcnt = -1;; --expcnt) {
+ fract = modf(fract * 10, &tmp);
+ if (tmp)
+ break;
+ }
+ *t++ = tochar((int)tmp);
+ if (prec || flags&ALT)
+ *t++ = '.';
+ }
+ else {
+ *t++ = '0';
+ if (prec || flags&ALT)
+ *t++ = '.';
+ }
+ /* if requires more precision and some fraction left */
+ if (fract) {
+ if (prec)
+ do {
+ fract = modf(fract * 10, &tmp);
+ *t++ = tochar((int)tmp);
+ } while (--prec && fract);
+ if (fract)
+ startp = round(fract, &expcnt, startp,
+ t - 1, (char)0, signp);
+ }
+ /* if requires more precision */
+ for (; prec--; *t++ = '0');
+
+ /* unless alternate flag, trim any g/G format trailing 0's */
+ if (gformat && !(flags&ALT)) {
+ while (t > startp && *--t == '0');
+ if (*t == '.')
+ --t;
+ ++t;
+ }
+ t = exponent(t, expcnt, fmtch);
+ break;
+ case 'g':
+ case 'G':
+ /* a precision of 0 is treated as a precision of 1. */
+ if (!prec)
+ ++prec;
+ /*
+ * ``The style used depends on the value converted; style e
+ * will be used only if the exponent resulting from the
+ * conversion is less than -4 or greater than the precision.''
+ * -- ANSI X3J11
+ */
+ if (expcnt > prec || !expcnt && fract && fract < .0001) {
+ /*
+ * g/G format counts "significant digits, not digits of
+ * precision; for the e/E format, this just causes an
+ * off-by-one problem, i.e. g/G considers the digit
+ * before the decimal point significant and e/E doesn't
+ * count it as precision.
+ */
+ --prec;
+ fmtch -= 2; /* G->E, g->e */
+ gformat = 1;
+ goto eformat;
+ }
+ /*
+ * reverse integer into beginning of buffer,
+ * note, decrement precision
+ */
+ if (expcnt)
+ for (; ++p < endp; *t++ = *p, --prec);
+ else
+ *t++ = '0';
+ /*
+ * if precision required or alternate flag set, add in a
+ * decimal point. If no digits yet, add in leading 0.
+ */
+ if (prec || flags&ALT) {
+ dotrim = 1;
+ *t++ = '.';
+ }
+ else
+ dotrim = 0;
+ /* if requires more precision and some fraction left */
+ if (fract) {
+ if (prec) {
+ do {
+ fract = modf(fract * 10, &tmp);
+ *t++ = tochar((int)tmp);
+ } while(!tmp);
+ while (--prec && fract) {
+ fract = modf(fract * 10, &tmp);
+ *t++ = tochar((int)tmp);
+ }
+ }
+ if (fract)
+ startp = round(fract, (int *)NULL, startp,
+ t - 1, (char)0, signp);
+ }
+ /* alternate format, adds 0's for precision, else trim 0's */
+ if (flags&ALT)
+ for (; prec--; *t++ = '0');
+ else if (dotrim) {
+ while (t > startp && *--t == '0');
+ if (*t != '.')
+ ++t;
+ }
+ }
+ return(t - startp);
+}
+
+static char *
+round(fract, exp, start, end, ch, signp)
+ double fract;
+ int *exp;
+ register char *start, *end;
+ char ch, *signp;
+{
+ double tmp;
+
+ if (fract)
+ (void)modf(fract * 10, &tmp);
+ else
+ tmp = todigit(ch);
+ if (tmp > 4)
+ for (;; --end) {
+ if (*end == '.')
+ --end;
+ if (++*end <= '9')
+ break;
+ *end = '0';
+ if (end == start) {
+ if (exp) { /* e/E; increment exponent */
+ *end = '1';
+ ++*exp;
+ }
+ else { /* f; add extra digit */
+ *--end = '1';
+ --start;
+ }
+ break;
+ }
+ }
+ /* ``"%.3f", (double)-0.0004'' gives you a negative 0. */
+ else if (*signp == '-')
+ for (;; --end) {
+ if (*end == '.')
+ --end;
+ if (*end != '0')
+ break;
+ if (end == start)
+ *signp = 0;
+ }
+ return(start);
+}
+
+static char *
+exponent(p, exp, fmtch)
+ register char *p;
+ register int exp;
+ u_char fmtch;
+{
+ register char *t;
+ char expbuf[MAXEXP];
+
+ *p++ = fmtch;
+ if (exp < 0) {
+ exp = -exp;
+ *p++ = '-';
+ }
+ else
+ *p++ = '+';
+ t = expbuf + MAXEXP;
+ if (exp > 9) {
+ do {
+ *--t = tochar(exp % 10);
+ } while ((exp /= 10) > 9);
+ *--t = tochar(exp);
+ for (; t < expbuf + MAXEXP; *p++ = *t++);
+ }
+ else {
+ *p++ = '0';
+ *p++ = tochar(exp);
+ }
+ return(p);
+}
--- /dev/null
+#ifdef LIBC_SCCS
+ .data
+_sccsid:
+ .asciz "@(#)doprnt.c 5.4 (Berkeley) 3/9/86"
+ .text
+#endif LIBC_SCCS
+
+ # C library -- conversions
+
+#include "DEFS.h"
+
+.globl __doprnt
+.globl __flsbuf
+
+#define vbit 1
+#define flags r10
+#define ndfnd 0
+#define prec 1
+#define zfill 2
+#define minsgn 3
+#define plssgn 4
+#define numsgn 5
+#define caps 6
+#define blank 7
+#define gflag 8
+#define dpflag 9
+#define width r9
+#define ndigit r8
+#define llafx r7
+#define lrafx r6
+#define fdesc -4(fp)
+#define exp -8(fp)
+#define sexp -12(fp)
+#define nchar -16(fp)
+#define sign -17(fp)
+ .set ch.zer,'0 # cpp doesn't like single appostrophes
+
+ .align 2
+strtab: # translate table for detecting null and percent
+ .byte 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15
+ .byte 16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31
+ .byte ' ,'!,'",'#,'$, 0,'&,'','(,'),'*,'+,',,'-,'.,'/
+ .byte '0,'1,'2,'3,'4,'5,'6,'7,'8,'9,':,';,'<,'=,'>,'?
+ .byte '@,'A,'B,'C,'D,'E,'F,'G,'H,'I,'J,'K,'L,'M,'N,'O
+ .byte 'P,'Q,'R,'S,'T,'U,'V,'W,'X,'Y,'Z,'[,'\,'],'^,'_
+ .byte '`,'a,'b,'c,'d,'e,'f,'g,'h,'i,'j,'k,'l,'m,'n,'o
+ .byte 'p,'q,'r,'s,'t,'u,'v,'w,'x,'y,'z,'{,'|,'},'~,127
+ .byte 128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143
+ .byte 144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159
+ .byte 160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175
+ .byte 176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191
+ .byte 192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207
+ .byte 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223
+ .byte 224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239
+ .byte 240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255
+
+ENTRY(_doprnt, R6|R7|R8|R9|R10|R11)
+ jbr doit
+
+strfoo:
+ clrl r4 # fix interrupt race
+ jbr strok # and try again
+strout2: # enter here to force out r2; r0,r1 must be set
+ # do some tricks with line buffering (_IOLBF) first
+ movl fdesc,r3
+ jbc $7,16(r3),0f # not line buffered (unbuffered)
+ addl3 12(r3),8(r3),r4 # fdesc->_base+fdesc->_bufsiz
+ cmpl 4(r3),r4 # buffer full?
+ jgeq 0f # yes
+ cmpl r2,$10 # c == '\n'?
+ jeql 0f # yes
+ movb r2,*4(r3) # line buffered and not buffer full
+ incl 4(r3) # and not newline
+ clrl (r3) # just stuff it and fix _cnt
+ incl nchar # count the char
+ jbr strout # skip __flsbuf
+0: pushr $3 # save input descriptor
+ pushl fdesc # FILE
+ pushl r2 # the char
+ calls $2,__flsbuf # please empty the buffer and handle 1 char
+ tstl r0 # successful?
+ jgeq strm1 # yes
+ jbcs $31,nchar,strm1 # turn on sign bit of nchar to signify error
+strm1:
+ incl nchar # count the char
+ popr $3 # get input descriptor back
+strout: # enter via bsb with (r0,r1)=input descriptor
+ movab strtab,r3 # table address
+ movq *fdesc,r4 # output descriptor
+ jbs $31,r4,strfoo # negative count is a no no
+strok:
+ addl2 r0,nchar # we intend to move this many chars
+/******* Start bogus movtuc workaround *****/
+ clrl r2
+ tstl r0
+ bleq movdon
+movlp:
+ tstl r4
+ bleq movdon
+ movzbl (r1)+,r3
+ tstb strtab[r3]
+ bneq 1f
+ mnegl $1,r2
+ decl r1
+ brb movdon
+1:
+ movb r3,(r5)+
+ decl r4
+ sobgtr r0,movlp
+ /******* End bogus movtuc workaround ***
+ movtuc r0,(r1),$0,(r3),r4,(r5)
+ movpsl r2 /* squirrel away condition codes */
+ /******* End equally bogus movtuc ****/
+movdon: movq r4,*fdesc /* update output descriptor */
+ subl2 r0,nchar # some chars not moved
+ jbs $vbit,r2,stresc # terminated by escape?
+ sobgeq r0,strmore # no; but out buffer might be full
+stresc:
+ rsb
+strmore:
+ movzbl (r1)+,r2 # one char
+ tstb strtab[r2] # translate
+ jneq strout2 # bad guy in disguise (outbuf is full)
+ incl r0 # fix the length
+ decl r1 # and the addr
+ movl $1<vbit,r2 # fake condition codes
+ rsb
+
+errdone:
+ jbcs $31,nchar,prdone # set error bit
+prdone:
+ movl nchar,r0
+ ret
+
+doit:
+ movab -256(sp),sp # work space
+ movl 4(ap),r11 # addr of format string
+ movl 12(ap),fdesc # output FILE ptr
+ movl 8(ap),ap # addr of first arg
+ clrl nchar # number of chars transferred
+loop:
+ movzwl $65535,r0 # pseudo length
+ movl r11,r1 # fmt addr
+ # comet sucks.
+ movq *fdesc,r4
+ subl3 r1,r5,r2
+ jlss lp1
+ cmpl r0,r2
+ jleq lp1
+ movl r2,r0
+lp1:
+ #
+ bsbw strout # copy to output, stop at null or percent
+ movl r1,r11 # new fmt
+ jbc $vbit,r2,loop # if no escape, then very long fmt
+ tstb (r11)+ # escape; null or percent?
+ jeql prdone # null means end of fmt
+
+ movl sp,r5 # reset output buffer pointer
+ clrq r9 # width; flags
+ clrq r6 # lrafx,llafx
+longorunsg: # we can ignore both of these distinctions
+short:
+L4a:
+ movzbl (r11)+,r0 # so capital letters can tail merge
+L4: caseb r0,$' ,$'x-' # format char
+L5:
+ .word space-L5 # space
+ .word fmtbad-L5 # !
+ .word fmtbad-L5 # "
+ .word sharp-L5 # #
+ .word fmtbad-L5 # $
+ .word fmtbad-L5 # %
+ .word fmtbad-L5 # &
+ .word fmtbad-L5 # '
+ .word fmtbad-L5 # (
+ .word fmtbad-L5 # )
+ .word indir-L5 # *
+ .word plus-L5 # +
+ .word fmtbad-L5 # ,
+ .word minus-L5 # -
+ .word dot-L5 # .
+ .word fmtbad-L5 # /
+ .word gnum0-L5 # 0
+ .word gnum-L5 # 1
+ .word gnum-L5 # 2
+ .word gnum-L5 # 3
+ .word gnum-L5 # 4
+ .word gnum-L5 # 5
+ .word gnum-L5 # 6
+ .word gnum-L5 # 7
+ .word gnum-L5 # 8
+ .word gnum-L5 # 9
+ .word fmtbad-L5 # :
+ .word fmtbad-L5 # ;
+ .word fmtbad-L5 # <
+ .word fmtbad-L5 # =
+ .word fmtbad-L5 # >
+ .word fmtbad-L5 # ?
+ .word fmtbad-L5 # @
+ .word fmtbad-L5 # A
+ .word fmtbad-L5 # B
+ .word fmtbad-L5 # C
+ .word decimal-L5 # D
+ .word capital-L5 # E
+ .word fmtbad-L5 # F
+ .word capital-L5 # G
+ .word fmtbad-L5 # H
+ .word fmtbad-L5 # I
+ .word fmtbad-L5 # J
+ .word fmtbad-L5 # K
+ .word fmtbad-L5 # L
+ .word fmtbad-L5 # M
+ .word fmtbad-L5 # N
+ .word octal-L5 # O
+ .word fmtbad-L5 # P
+ .word fmtbad-L5 # Q
+ .word fmtbad-L5 # R
+ .word fmtbad-L5 # S
+ .word fmtbad-L5 # T
+ .word unsigned-L5 # U
+ .word fmtbad-L5 # V
+ .word fmtbad-L5 # W
+ .word capital-L5 # X
+ .word fmtbad-L5 # Y
+ .word fmtbad-L5 # Z
+ .word fmtbad-L5 # [
+ .word fmtbad-L5 # \
+ .word fmtbad-L5 # ]
+ .word fmtbad-L5 # ^
+ .word fmtbad-L5 # _
+ .word fmtbad-L5 # `
+ .word fmtbad-L5 # a
+ .word fmtbad-L5 # b
+ .word charac-L5 # c
+ .word decimal-L5 # d
+ .word scien-L5 # e
+ .word float-L5 # f
+ .word general-L5 # g
+ .word short-L5 # h
+ .word fmtbad-L5 # i
+ .word fmtbad-L5 # j
+ .word fmtbad-L5 # k
+ .word longorunsg-L5 # l
+ .word fmtbad-L5 # m
+ .word fmtbad-L5 # n
+ .word octal-L5 # o
+ .word fmtbad-L5 # p
+ .word fmtbad-L5 # q
+ .word fmtbad-L5 # r
+ .word string-L5 # s
+ .word fmtbad-L5 # t
+ .word unsigned-L5 # u
+ .word fmtbad-L5 # v
+ .word fmtbad-L5 # w
+ .word hex-L5 # x
+fmtbad:
+ movb r0,(r5)+ # print the unfound character
+ jeql errdone # dumb users who end the format with a %
+ jbr prbuf
+capital:
+ bisl2 $1<caps,flags # note that it was capitalized
+ xorb2 $'a^'A,r0 # make it small
+ jbr L4 # and try again
+
+string:
+ movl ndigit,r0
+ jbs $prec,flags,L20 # max length was specified
+ mnegl $1,r0 # default max length
+L20: movl (ap)+,r2 # addr first byte
+ locc $0,r0,(r2) # find the zero at the end
+ movl r1,r5 # addr last byte +1
+ movl r2,r1 # addr first byte
+ jbr prstr
+
+htab: .byte '0,'1,'2,'3,'4,'5,'6,'7,'8,'9,'a,'b,'c,'d,'e,'f
+Htab: .byte '0,'1,'2,'3,'4,'5,'6,'7,'8,'9,'A,'B,'C,'D,'E,'F
+
+octal:
+ movl $30,r2 # init position
+ movl $3,r3 # field width
+ movab htab,llafx # translate table
+ jbr L10
+
+hex:
+ movl $28,r2 # init position
+ movl $4,r3 # field width
+ movab htab,llafx # translate table
+ jbc $caps,flags,L10
+ movab Htab,llafx
+L10: mnegl r3,r6 # increment
+ clrl r1
+ addl2 $4,r5 # room for left affix (2) and slop [forced sign?]
+ movl (ap)+,r0 # fetch arg
+L11: extzv r2,r3,r0,r1 # pull out a digit
+ movb (llafx)[r1],(r5)+ # convert to character
+L12: acbl $0,r6,r2,L11 # continue until done
+ clrq r6 # lrafx, llafx
+ clrb (r5) # flag end
+ skpc $'0,$11,4(sp) # skip over leading zeroes
+ jbc $numsgn,flags,prn3 # easy if no left affix
+ tstl -4(ap) # original value
+ jeql prn3 # no affix on 0, for some reason
+ cmpl r3,$4 # were we doing hex or octal?
+ jneq L12a # octal
+ movb $'x,r0
+ jbc $caps,flags,L12b
+ movb $'X,r0
+L12b: movb r0,-(r1)
+ movl $2,llafx # leading 0x for hex is an affix
+L12a: movb $'0,-(r1) # leading zero for octal is a digit, not an affix
+ jbr prn3 # omit sign (plus, blank) massaging
+
+unsigned:
+lunsigned:
+ bicl2 $1<plssgn|1<blank,flags # omit sign (plus, blank) massaging
+ extzv $1,$31,(ap),r0 # right shift logical 1 bit
+ cvtlp r0,$10,(sp) # convert [n/2] to packed
+ movp $10,(sp),8(sp) # copy packed
+ addp4 $10,8(sp),$10,(sp) # 2*[n/2] in packed, at (sp)
+ blbc (ap)+,L14 # n was even
+ addp4 $1,pone,$10,(sp) # n was odd
+ jbr L14
+
+patdec: # editpc pattern for decimal printing
+ .byte 0xAA # eo$float 10
+ .byte 0x01 # eo$end_float
+ .byte 0 # eo$end
+
+decimal:
+ cvtlp (ap)+,$10,(sp) # 10 digits max
+ jgeq L14
+ incl llafx # minus sign is a left affix
+L14: editpc $10,(sp),patdec,8(sp) # ascii at 8(sp); r5=end+1
+ skpc $' ,$11,8(sp) # skip leading blanks; r1=first
+
+prnum: # r1=addr first byte, r5=addr last byte +1, llafx=size of signs
+ # -1(r1) vacant, for forced sign
+ tstl llafx
+ jneq prn3 # already some left affix, dont fuss
+ jbc $plssgn,flags,prn2
+ movb $'+,-(r1) # needs a plus sign
+ jbr prn4
+prn2: jbc $blank,flags,prn3
+ movb $' ,-(r1) # needs a blank sign
+prn4: incl llafx
+prn3: jbs $prec,flags,prn1
+ movl $1,ndigit # default precision is 1
+prn1: subl3 r1,r5,lrafx # raw width
+ subl2 llafx,lrafx # number of digits
+ subl2 lrafx,ndigit # number of leading zeroes needed
+ jleq prstr # none
+ addl2 llafx,r1 # where current digits start
+ pushl r1 # movcx gobbles registers
+ # check bounds on users who say %.300d
+ movab 32(r5)[ndigit],r2
+ subl2 fp,r2
+ jlss prn5
+ subl2 r2,ndigit
+prn5:
+ #
+ movc3 lrafx,(r1),(r1)[ndigit] # make room in middle
+ movc5 $0,(r1),$ch.zer,ndigit,*(sp) # '0 fill
+ subl3 llafx,(sp)+,r1 # first byte addr
+ addl3 lrafx,r3,r5 # last byte addr +1
+
+prstr: # r1=addr first byte; r5=addr last byte +1
+ # width=minimum width; llafx=len. left affix
+ # ndigit=<avail>
+ subl3 r1,r5,ndigit # raw width
+ subl3 ndigit,width,r0 # pad length
+ jleq padlno # in particular, no left padding
+ jbs $minsgn,flags,padlno
+ # extension for %0 flag causing left zero padding to field width
+ jbs $zfill,flags,padlz
+ # this bsbb needed even if %0 flag extension is removed
+ bsbb padb # blank pad on left
+ jbr padnlz
+padlz:
+ movl llafx,r0
+ jleq padnlx # left zero pad requires left affix first
+ subl2 r0,ndigit # part of total length will be transferred
+ subl2 r0,width # and will account for part of minimum width
+ bsbw strout # left affix
+padnlx:
+ subl3 ndigit,width,r0 # pad length
+ bsbb padz # zero pad on left
+padnlz:
+ # end of extension for left zero padding
+padlno: # remaining: root, possible right padding
+ subl2 ndigit,width # root reduces minimum width
+ movl ndigit,r0 # root length
+p1: bsbw strout # transfer to output buffer
+p3: jbc $vbit,r2,padnpct # percent sign (or null byte via %c) ?
+ decl r0 # yes; adjust count
+ movzbl (r1)+,r2 # fetch byte
+ movq *fdesc,r4 # output buffer descriptor
+ sobgeq r4,p2 # room at the out [inn] ?
+ bsbw strout2 # no; force it, then try rest
+ jbr p3 # here we go 'round the mullberry bush, ...
+p2: movb r2,(r5)+ # hand-deposit the percent or null
+ incl nchar # count it
+ movq r4,*fdesc # store output descriptor
+ jbr p1 # what an expensive hiccup!
+padnpct:
+ movl width,r0 # size of pad
+ jleq loop
+ bsbb padb
+ jbr loop
+
+padz:
+ movb $'0,r2
+ jbr pad
+padb:
+ movb $' ,r2
+pad:
+ subl2 r0,width # pad width decreases minimum width
+ pushl r1 # save non-pad addr
+ movl r0,llafx # remember width of pad
+ subl2 r0,sp # allocate
+ movc5 $0,(r0),r2,llafx,(sp) # create pad string
+ movl llafx,r0 # length
+ movl sp,r1 # addr
+ bsbw strout
+ addl2 llafx,sp # deallocate
+ movl (sp)+,r1 # recover non-pad addr
+ rsb
+
+pone: .byte 0x1C # packed 1
+
+charac:
+ movl (ap)+,r0 # word containing the char
+ movb r0,(r5)+ # one byte, that's all
+
+prbuf:
+ movl sp,r1 # addr first byte
+ jbr prstr
+
+space: bisl2 $1<blank,flags # constant width e fmt, no plus sign
+ jbr L4a
+sharp: bisl2 $1<numsgn,flags # 'self identifying', please
+ jbr L4a
+plus: bisl2 $1<plssgn,flags # always print sign for floats
+ jbr L4a
+minus: bisl2 $1<minsgn,flags # left justification, please
+ jbr L4a
+gnum0: jbs $ndfnd,flags,gnum
+ jbs $prec,flags,gnump # ignore when reading precision
+ bisl2 $1<zfill,flags # leading zero fill, please
+gnum: jbs $prec,flags,gnump
+ moval (width)[width],width # width *= 5;
+ movaw -ch.zer(r0)[width],width # width = 2*witdh + r0 - '0';
+ jbr gnumd
+gnump: moval (ndigit)[ndigit],ndigit # ndigit *= 5;
+ movaw -ch.zer(r0)[ndigit],ndigit # ndigit = 2*ndigit + r0 - '0';
+gnumd: bisl2 $1<ndfnd,flags # digit seen
+ jbr L4a
+dot: clrl ndigit # start on the precision
+ bisl2 $1<prec,flags
+ bicl2 $1<ndfnd,flags
+ jbr L4a
+indir:
+ jbs $prec,flags,in1
+ movl (ap)+,width # width specified by parameter
+ jgeq gnumd
+ xorl2 $1<minsgn,flags # parameterized left adjustment
+ mnegl width,width
+ jbr gnumd
+in1:
+ movl (ap)+,ndigit # precision specified by paratmeter
+ jgeq gnumd
+ mnegl ndigit,ndigit
+ jbr gnumd
+
+float:
+ jbs $prec,flags,float1
+ movl $6,ndigit # default # digits to right of decpt.
+float1: bsbw fltcvt
+ addl3 exp,ndigit,r7
+ movl r7,r6 # for later "underflow" checking
+ bgeq fxplrd
+ clrl r7 # poor programmer planning
+fxplrd: cmpl r7,$31 # expressible in packed decimal?
+ bleq fnarro # yes
+ movl $31,r7
+fnarro: subl3 $17,r7,r0 # where to round
+ ashp r0,$17,(sp),$5,r7,16(sp) # do it
+ bvc fnovfl
+ # band-aid for microcode error (spurious overflow)
+ # clrl r0 # assume even length result
+ # jlbc r7,fleven # right
+ # movl $4,r0 # odd length result
+ #fleven: cmpv r0,$4,16(sp),$0 # top digit zero iff true overflow
+ # bneq fnovfl
+ # end band-aid
+ aobleq $0,r6,fnovfl # if "underflow" then jump
+ movl r7,r0
+ incl exp
+ incl r7
+ ashp r0,$1,pone,$0,r7,16(sp)
+ ashl $-1,r7,r0 # displ to last byte
+ bisb2 sign,16(sp)[r0] # insert sign
+fnovfl:
+ movab 16(sp),r1 # packed source
+ movl r7,r6 # packed length
+ pushab prnum # goto prnum after fall-through call to fedit
+
+
+ # enter via bsb
+ # r1=addr of packed source
+ # 16(r1) used to unpack source
+ # 48(r1) used to construct pattern to unpack source
+ # 48(r1) used to hold result
+ # r6=length of packed source (destroyed)
+ # exp=# digits to left of decimal point (destroyed)
+ # ndigit=# digits to right of decimal point (destroyed)
+ # sign=1 if negative, 0 otherwise
+ # stack will be used for work space for pattern and unpacked source
+ # exits with
+ # r1=addr of punctuated result
+ # r5=addr of last byte +1
+ # llafx=1 if minus sign inserted, 0 otherwise
+fedit:
+ pushab 48(r1) # save result addr
+ movab 48(r1),r3 # pattern addr
+ movb $0x03,(r3)+ # eo$set_signif
+ movc5 $0,(r1),$0x91,r6,(r3) # eo$move 1
+ clrb (r3) # eo$end
+ editpc r6,(r1),48(r1),16(r1) # unpack 'em all
+ subl3 r6,r5,r1 # addr unpacked source
+ movl (sp),r3 # punctuated output placed here
+ clrl llafx
+ jlbc sign,f1
+ movb $'-,(r3)+ # negative
+ incl llafx
+f1: movl exp,r0
+ jgtr f2
+ movb $'0,(r3)+ # must have digit before decimal point
+ jbr f3
+f2: cmpl r0,r6 # limit on packed length
+ jleq f4
+ movl r6,r0
+f4: subl2 r0,r6 # eat some digits
+ subl2 r0,exp # from the exponent
+ movc3 r0,(r1),(r3) # (most of the) digits to left of decimal point
+ movl exp,r0 # need any more?
+ jleq f3
+ movc5 $0,(r1),$'0,r0,(r3) # '0 fill
+f3: movl ndigit,r0 # # digits to right of decimal point
+ jgtr f5
+ jbs $numsgn,flags,f5 # no decimal point unless forced
+ jbcs $dpflag,flags,f6 # no decimal point
+f5: movb $'.,(r3)+ # the decimal point
+f6: mnegl exp,r0 # "leading" zeroes to right of decimal point
+ jleq f9
+ cmpl r0,ndigit # cant exceed this many
+ jleq fa
+ movl ndigit,r0
+fa: subl2 r0,ndigit
+ movc5 $0,(r1),$'0,r0,(r3)
+f9: movl ndigit,r0
+ cmpl r0,r6 # limit on packed length
+ jleq f7
+ movl r6,r0
+f7: subl2 r0,ndigit # eat some digits from the fraction
+ movc3 r0,(r1),(r3) # (most of the) digits to right of decimal point
+ movl ndigit,r0 # need any more?
+ jleq f8
+ # check bounds on users who say %.300f
+ movab 32(r3)[r0],r2
+ subl2 fp,r2
+ jlss fb
+ subl2 r2,r0 # truncate, willy-nilly
+ movl r0,ndigit # and no more digits later, either
+fb:
+ #
+ subl2 r0,ndigit # eat some digits from the fraction
+ movc5 $0,(r1),$'0,r0,(r3) # '0 fill
+f8: movl r3,r5 # addr last byte +1
+ popr $1<1 # [movl (sp)+,r1] addr first byte
+ rsb
+
+patexp: .byte 0x03 # eo$set_signif
+ .byte 0x44,'e # eo$insert 'e
+ .byte 0x42,'+ # eo$load_plus '+
+ .byte 0x04 # eo$store_sign
+ .byte 0x92 # eo$move 2
+ .byte 0 # eo$end
+
+scien:
+ incl ndigit
+ jbs $prec,flags,L23
+ movl $7,ndigit
+L23: bsbw fltcvt # get packed digits
+ movl ndigit,r7
+ cmpl r7,$31 # expressible in packed decimal?
+ jleq snarro # yes
+ movl $31,r7
+snarro: subl3 $17,r7,r0 # rounding position
+ ashp r0,$17,(sp),$5,r7,16(sp) # shift and round
+ bvc snovfl
+ # band-aid for microcode error (spurious overflow)
+ # clrl r0 # assume even length result
+ # jlbc ndigit,sceven # right
+ # movl $4,r0 # odd length result
+ #sceven: cmpv r0,$4,16(sp),$0 # top digit zero iff true overflow
+ # bneq snovfl
+ # end band-aid
+ incl exp # rounding overflowed to 100...
+ subl3 $1,r7,r0
+ ashp r0,$1,pone,$0,r7,16(sp)
+ ashl $-1,r7,r0 # displ to last byte
+ bisb2 sign,16(sp)[r0] # insert sign
+snovfl:
+ jbs $gflag,flags,gfmt # %g format
+ movab 16(sp),r1
+ bsbb eedit
+eexp:
+ movl r1,r6 # save fwa from destruction by cvtlp
+ subl3 $1,sexp,r0 # 1P exponent
+ cvtlp r0,$2,(sp) # packed
+ editpc $2,(sp),patexp,(r5)
+ movl r6,r1 # fwa
+ jbc $caps,flags,prnum
+ xorb2 $'e^'E,-4(r5)
+ jbr prnum
+
+eedit:
+ movl r7,r6 # packed length
+ decl ndigit # 1 digit before decimal point
+ movl exp,sexp # save from destruction
+ movl $1,exp # and pretend
+ jbr fedit
+
+gfmt:
+ addl3 $3,exp,r0 # exp is 1 more than e
+ jlss gfmte # (e+1)+3<0, e+4<=-1, e<=-5
+ subl2 $3,r0 # exp [==(e+1)]
+ cmpl r0,ndigit
+ jgtr gfmte # e+1>n, e>=n
+gfmtf:
+ movl r7,r6
+ subl2 r0,ndigit # n-e-1
+ movab 16(sp),r1
+ bsbw fedit
+g1: jbs $numsgn,flags,g2
+ jbs $dpflag,flags,g2 # dont strip if no decimal point
+g3: cmpb -(r5),$'0 # strip trailing zeroes
+ jeql g3
+ cmpb (r5),$'. # and trailing decimal point
+ jeql g2
+ incl r5
+g2: jbc $gflag,flags,eexp
+ jbr prnum
+gfmte:
+ movab 16(sp),r1 # packed source
+ bsbw eedit
+ jbsc $gflag,flags,g1 # gflag now means "use %f" [hence no exponent]
+
+general:
+ jbs $prec,flags,gn1
+ movl $6,ndigit # default precision is 6 significant digits
+gn1: tstl ndigit # cannot allow precision of 0
+ jgtr gn2
+ movl $1,ndigit # change 0 to 1, willy-nilly
+gn2: jbcs $gflag,flags,L23
+ jbr L23 # safety net
+
+ # convert double-floating at (ap) to 17-digit packed at (sp),
+ # set 'sign' and 'exp', advance ap.
+fltcvt:
+ clrb sign
+ movd (ap)+,r5
+ jeql fzero
+ bgtr fpos
+ mnegd r5,r5
+ incb sign
+fpos:
+ extzv $7,$8,r5,r2 # exponent of 2
+ movab -0200(r2),r2 # unbias
+ mull2 $59,r2 # 59/196: 3rd convergent continued frac of log10(2)
+ jlss eneg
+ movab 196(r2),r2
+eneg:
+ movab -98(r2),r2
+ divl2 $196,r2
+ bsbw expten
+ cmpd r0,r5
+ bgtr ceil
+ incl r2
+ceil: movl r2,exp
+ mnegl r2,r2
+ cmpl r2,$29 # 10^(29+9) is all we can handle
+ bleq getman
+ muld2 ten16,r5
+ subl2 $16,r2
+getman: addl2 $9,r2 # -ceil(log10(x)) + 9
+ jsb expten
+ emodd r0,r4,r5,r0,r5 # (r0+r4)*r5; r0=int, r5=frac
+fz1: cvtlp r0,$9,16(sp) # leading 9 digits
+ ashp $8,$9,16(sp),$0,$17,4(sp) # as top 9 of 17
+ emodd ten8,$0,r5,r0,r5
+ cvtlp r0,$8,16(sp) # trailing 8 digits
+ # if precision >= 17, must round here
+ movl ndigit,r7 # so figure out what precision is
+ pushab scien
+ cmpl (sp)+,(sp)
+ jleq gm1 # who called us?
+ addl2 exp,r7 # float; adjust for exponent
+gm1: cmpl r7,$17
+ jlss gm2
+ cmpd r5,$0d0.5 # must round here; check fraction
+ jlss gm2
+ bisb2 $0x10,8+4(sp) # increment l.s. digit
+gm2: # end of "round here" code
+ addp4 $8,16(sp),$17,4(sp) # combine leading and trailing
+ bisb2 sign,12(sp) # and insert sign
+ rsb
+fzero: clrl r0
+ movl $1,exp # 0.000e+00 and 0.000 rather than 0.000e-01 and .000
+ jbr fz1
+
+ .align 2
+lsb: .long 0x00010000 # lsb in the crazy floating-point format
+
+ # return 10^r2 as a double float in r0||r1 and 8 extra bits of precision in r4
+ # preserve r2, r5||r6
+expten:
+ movd $0d1.0,r0 # begin computing 10^exp10
+ clrl r4 # bit counter
+ movad ten1,r3 # table address
+ tstl r2
+ bgeq e10lp
+ mnegl r2,r2 # get absolute value
+ jbss $6,r2,e10lp # flag as negative
+e10lp: jbc r4,r2,el1 # want this power?
+ muld2 (r3),r0 # yes
+el1: addl2 $8,r3 # advance to next power
+ aobleq $5,r4,e10lp # through 10^32
+ jbcc $6,r2,el2 # correct for negative exponent
+ divd3 r0,$0d1.0,r0 # by taking reciprocal
+ cmpl $28,r2
+ jneq enm28
+ addl2 lsb,r1 # 10**-28 needs lsb incremented
+enm28: mnegl r2,r2 # original exponent of 10
+el2: addl3 $5*8,r2,r3 # negative bit positions are illegal?
+ jbc r3,xlsbh-5,eoklsb
+ subl2 lsb,r1 # lsb was too high
+eoklsb:
+ movzbl xprec[r2],r4 # 8 extra bits
+ rsb
+
+ # powers of ten
+ .align 2
+ten1: .word 0x4220,0,0,0
+ten2: .word 0x43c8,0,0,0
+ten4: .word 0x471c,0x4000,0,0
+ten8: .word 0x4dbe,0xbc20,0,0
+ten16: .word 0x5b0e,0x1bc9,0xbf04,0
+ten32: .word 0x759d,0xc5ad,0xa82b,0x70b6
+
+ # whether lsb is too high or not
+ .byte 1:0,1:0,1:0,1:0,1:1,1:0,1:1,1:0 # -40 thru -33
+ .byte 1:0,1:1,1:0,1:0,1:0,1:0,1:1,1:0 # -32 thru -25
+ .byte 1:0,1:0,1:1,1:1,1:1,1:1,1:0,1:0 # -24 thru -17
+ .byte 1:0,1:1,1:0,1:0,1:1,1:1,1:1,1:1 # -16 thru -9
+ .byte 1:1,1:1,1:1,1:0,1:0,1:0,1:0,1:1 # -8 thru -1
+xlsbh:
+ .byte 1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0 # 0 thru 7
+ .byte 1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0 # 8 thru 15
+ .byte 1:0,1:0,1:0,1:0,1:0,1:0,1:0,1:0 # 16 thru 23
+ .byte 1:0,1:1,1:1,1:0,1:1,1:1,1:1,1:1 # 24 thru 31
+ .byte 1:1,1:1,1:1,1:1,1:1,1:1,1:1 # 32 thru 38
+
+ # bytes of extra precision
+ .byte 0x56,0x76,0xd3,0x88,0xb5,0x62 # -38 thru -33
+ .byte 0xba,0xf5,0x32,0x3e,0x0e,0x48,0xdb,0x51 # -32 thru -25
+ .byte 0x53,0x27,0xb1,0xef,0xeb,0xa5,0x07,0x49 # -24 thru -17
+ .byte 0x5b,0xd9,0x0f,0x13,0xcd,0xff,0xbf,0x97 # -16 thru -9
+ .byte 0xfd,0xbc,0xb6,0x23,0x2c,0x3b,0x0a,0xcd # -8 thru -1
+xprec:
+ .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 # 0 thru 7
+ .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 # 8 thru 15
+ .byte 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 # 16 thru 23
+ .byte 0x00,0xa0,0xc8,0x3a,0x84,0xe4,0xdc,0x92 # 24 thru 31
+ .byte 0x9b,0x00,0xc0,0x58,0xae,0x18,0xef # 32 thru 38
--- /dev/null
+#include "gen.h"
+char *fgets(s, l, f) char *s; FILE *f; {
+ abort();
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fgets.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+char *
+fgets(s, n, iop)
+char *s;
+register FILE *iop;
+{
+ register c;
+ register char *cs;
+
+ cs = s;
+ while (--n>0 && (c = getc(iop)) != EOF) {
+ *cs++ = c;
+ if (c=='\n')
+ break;
+ }
+ if (c == EOF && cs==s)
+ return(NULL);
+ *cs++ = '\0';
+ return(s);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+_sccsid:.asciz "@(#)fgets.c 5.3 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * char *fgets(s, n, iptr);
+ * char *s;
+ * int n;
+ * FILE *iptr;
+ *
+ * arguments: a target string, a length, and a file pointer.
+ * side effects: reads up to and including a newline, or up to n-1 bytes,
+ * whichever is less, from the file indicated by iptr into the target
+ * string and null terminates.
+ * result: the target string if successful, 0 otherwise.
+ */
+
+#include "DEFS.h"
+
+#define NL 0xa
+
+ENTRY(fgets, R11|R10|R9)
+
+#define OLD_S 4(ap)
+#define S r11
+ movl OLD_S,S
+
+#define N 8(ap)
+
+#define IPTR r10
+#define _CNT
+#define _PTR 4
+#define _BASE 8
+ movl 12(ap),IPTR
+
+#define COUNT r9
+
+ /*
+ * Sanity check -- is the buffer big enough?
+ */
+ cmpl N,$1
+ jleq Lerror
+
+ subl3 $1,N,COUNT /* We scan at most COUNT chars */
+
+ /*
+ * If no characters, call _filbuf() to get some.
+ */
+ tstl _CNT(IPTR)
+ jgtr Lscan
+
+Lloop:
+ pushl IPTR
+ calls $1,__filbuf
+ tstl r0
+ jlss Leof
+ movb r0,(S)+ /* Save the returned character */
+ decl N
+ decl COUNT
+ jleq 1f
+ cmpb r0,$NL /* If it was a newline, we're done */
+ jneq 2f
+1:
+ clrb (S)
+ jbr Lret
+2:
+ tstl _BASE(IPTR) /* Is the input buffered? */
+ jeql Lloop /* If not, loop inefficiently */
+
+ /*
+ * Look for a newline in the buffer.
+ */
+Lscan:
+ cmpl _CNT(IPTR),COUNT /* Is buffer bigger than N-1? */
+ jgeq 1f
+ movl _CNT(IPTR),COUNT /* If not, don't read off the end */
+1:
+ locc $NL,COUNT,*_PTR(IPTR) /* Scan the buffer */
+ jeql Lagain
+
+ /*
+ * Success -- copy the data and return.
+ */
+ decl r0 /* How many characters did we read? */
+ subl2 r0,COUNT
+ movc3 COUNT,*_PTR(IPTR),(S) /* Copy the data */
+ clrb (r3)
+ subl2 COUNT,_CNT(IPTR) /* Fix up the I/O buffer */
+ movl r1,_PTR(IPTR)
+
+Lret:
+ movl OLD_S,r0
+ ret
+
+ /*
+ * If we run out of characters, copy the buffer and loop if needed.
+ */
+Lagain:
+ movc3 COUNT,*_PTR(IPTR),(S) /* Copy the data */
+ subl2 COUNT,_CNT(IPTR) /* Adjust the buffers and counts */
+ movl r1,_PTR(IPTR)
+ subl2 COUNT,N
+ movl r3,S
+ subl3 $1,N,COUNT
+ jgtr Lloop
+
+ /*
+ * End of file? Check to see if we copied any data.
+ */
+Leof:
+ cmpl S,OLD_S
+ jeql Lerror
+ clrb (S)
+ jbr Lret
+
+ /*
+ * Error return -- null pointer.
+ */
+Lerror:
+ clrl r0
+ ret
--- /dev/null
+#include "gen.h"
+void fputs(s,f) char *s; FILE *f; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1984 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)fputs.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+fputs(s, iop)
+register char *s;
+register FILE *iop;
+{
+ register r = 0;
+ register c;
+ int unbuffered;
+ char localbuf[BUFSIZ];
+
+ unbuffered = iop->_flag & _IONBF;
+ if (unbuffered) {
+ iop->_flag &= ~_IONBF;
+ iop->_ptr = iop->_base = localbuf;
+ iop->_bufsiz = BUFSIZ;
+ }
+
+ while (c = *s++)
+ r = putc(c, iop);
+
+ if (unbuffered) {
+ fflush(iop);
+ iop->_flag |= _IONBF;
+ iop->_base = NULL;
+ iop->_bufsiz = NULL;
+ iop->_cnt = 0;
+ }
+
+ return(r);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+_sccsid:.asciz "@(#)fputs.c 5.4 (Berkeley) 4/1/86"
+#endif LIBC_SCCS
+
+/*
+ * fputs(s, iop);
+ * char *s;
+ * FILE *iop;
+ *
+ * arguments: a source string and a file pointer.
+ * side effects: writes to the file indicated by iop using the data in
+ * the null-terminated source string.
+ * result: technically void; for compatibility we return 0 for the null
+ * string, non-zero otherwise. We return zero for errors too.
+ */
+
+#include "DEFS.h"
+
+#define NBF 04
+#define LBF 0200
+
+#define NL 012
+
+ENTRY(fputs, R11|R10|R9)
+
+#define S r11
+ movl 4(ap),S
+#define IOP r10
+#define _CNT
+#define _PTR 4
+#define _BASE 8
+#define _BUFSIZ 12
+#define _FLAG 16
+ movl 8(ap),IOP
+
+#define UNBUF -4(fp)
+
+#define COUNT r9
+
+ /*
+ * For compatibility (sigh).
+ */
+ tstb (S)
+ jeql Lerror
+
+ /*
+ * For unbuffered I/O, line buffer the output line.
+ * Ugly but fast -- and doesn't CURRENTLY break anything (sigh).
+ */
+ movab -1028(sp),sp
+ bicw3 $~NBF,_FLAG(IOP),UNBUF
+ jeql 1f
+
+ bicw2 $NBF,_FLAG(IOP) /* Clear no-buffering flag */
+ movl sp,_BASE(IOP) /* Create a buffer */
+ movl sp,_PTR(IOP)
+ cvtwl $1024,_BUFSIZ(IOP)
+ jbr 2f
+
+1:
+ tstl _CNT(IOP) /* Has a buffer been allocated? */
+ jgtr 2f
+ pushl IOP /* Get _flsbuf() to do the work */
+ pushl $0
+ calls $2,__flsbuf
+ tstl r0
+ jlss Lerror
+ incl _CNT(IOP) /* Unput the char we sent */
+ decl _PTR(IOP)
+2:
+
+ /*
+ * Search for the terminating null.
+ * We only need to look at _BUFSIZ bytes or less on each pass.
+ */
+Lloop:
+ addl3 _BASE(IOP),_BUFSIZ(IOP),COUNT /* How many bytes? */
+ subl2 _PTR(IOP),COUNT
+ locc $0,COUNT,(S) /* Look for a null */
+ jeql Lagain
+
+ subl2 r0,COUNT /* Copy the data */
+ movc3 COUNT,(S),*_PTR(IOP)
+ movl r3,_PTR(IOP) /* Fix up IOP */
+ subl2 COUNT,_CNT(IOP)
+ bitw $LBF,_FLAG(IOP) /* If line buffered... */
+ jneq 1f
+ tstw UNBUF /* or unbuffered... */
+ jneq 1f
+ tstl _CNT(IOP) /* or a full buffer... */
+ jgtr 2f
+1:
+ pushl IOP /* ... flush the buffer */
+ calls $1,_fflush
+ tstl r0
+ jlss Lerror
+2:
+
+ /*
+ * Fix up buffering again.
+ */
+Lfixup:
+ tstw UNBUF
+ jeql 1f
+ bisw2 $NBF,_FLAG(IOP) /* Reset flag */
+ clrl _BASE(IOP) /* Clear data structure */
+ clrl _BUFSIZ(IOP)
+ clrl _CNT(IOP)
+1:
+ cvtbl $NL,r0 /* Compatibility hack */
+ ret
+
+ /*
+ * We didn't find the null -- loop.
+ */
+Lagain:
+ movc3 COUNT,(S),*_PTR(IOP) /* Copy the data */
+ movl r1,S
+ movl r3,_PTR(IOP) /* Fix up IOP */
+ subl2 COUNT,_CNT(IOP)
+ pushl IOP /* The buffer is full -- flush it */
+ calls $1,_fflush
+ tstl r0
+ jlss Lerror
+ tstb (S) /* More data? */
+ jneq Lloop
+ jbr Lfixup
+
+ /*
+ * Bomb out. Return 0 (why not? that's what the old one did).
+ */
+Lerror:
+ clrl r0
+ ret
--- /dev/null
+#include "gen.h"
+char *gets(s) char *s; {
+ abort();
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)gets.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+char *
+gets(s)
+char *s;
+{
+ register c;
+ register char *cs;
+
+ cs = s;
+ while ((c = getchar()) != '\n' && c != EOF)
+ *cs++ = c;
+ if (c == EOF && cs==s)
+ return(NULL);
+ *cs++ = '\0';
+ return(s);
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+_sccsid:.asciz "@(#)gets.c 5.2 (Berkeley) 3/9/86"
+#endif LIBC_SCCS
+
+/*
+ * char *gets(s);
+ * char *s;
+ *
+ * argument: a target string
+ * side effects: reads bytes up to and including a newline from the
+ * standard input into the target string and replaces the newline
+ * with a null to null-terminate the string.
+ * result: the target string if successful, 0 otherwise.
+ */
+
+#include "DEFS.h"
+
+#define NL 0xa
+
+ENTRY(gets, R11|R10)
+
+#define S r11
+ movl 4(ap),S
+#define IPTR r10
+#define _CNT
+#define _PTR 4
+#define _BASE 8
+#define _BUFSIZ 12
+#define _FLAG 16
+ movab __iob,IPTR
+
+#define OLD_S 4(ap)
+
+ /*
+ * If no characters, call _filbuf() to get some.
+ */
+ tstl _CNT(IPTR)
+ jgtr Lscan
+
+Lloop:
+ pushl IPTR
+ calls $1,__filbuf
+ tstl r0 /* What did _filbuf() return? */
+ jlss Leof
+ cmpb r0,$NL
+ jneq 1f
+ clrb (S)
+ jbr Lret
+1:
+ movb r0,(S)+ /* Save the returned character */
+ tstl _BASE(IPTR) /* Is input buffered? */
+ jeql Lloop
+
+ /*
+ * Look for a newline in the buffer.
+ */
+Lscan:
+ locc $NL,_CNT(IPTR),*_PTR(IPTR)
+ jeql Lagain
+
+ /*
+ * Success -- copy the data and return.
+ */
+ subl3 r0,_CNT(IPTR),r2
+ subl2 r2,_CNT(IPTR)
+ movc3 r2,*_PTR(IPTR),(S) /* Copy the data */
+ clrb (r3)
+ movl r1,_PTR(IPTR)
+ decl _CNT(IPTR) /* Skip the newline */
+ incl _PTR(IPTR)
+
+ /*
+ * Normal return.
+ */
+Lret:
+ movl OLD_S,r0
+ ret
+
+ /*
+ * If we run out of characters, copy the buffer and loop.
+ */
+Lagain:
+ movc3 _CNT(IPTR),*_PTR(IPTR),(S) /* Copy the data */
+ movl r3,S
+ movl _BASE(IPTR),_PTR(IPTR) /* Reset stdio */
+ clrl _CNT(IPTR)
+ jbr Lloop
+
+ /*
+ * End of file? Check to see if we copied any data.
+ */
+Leof:
+ cmpl S,OLD_S
+ jeql Lerror
+ clrb (S)
+ jbr Lret
+
+ /*
+ * Error/eof return -- null pointer.
+ */
+Lerror:
+ clrl r0
+ ret
--- /dev/null
+#include "gen.h"
+void puts(s) char *s;{
+ abort();
+}
--- /dev/null
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)puts.c 5.2 (Berkeley) 3/9/86";
+#endif LIBC_SCCS and not lint
+
+#include <stdio.h>
+
+puts(s)
+register char *s;
+{
+ register c;
+
+ while (c = *s++)
+ putchar(c);
+ return(putchar('\n'));
+}
--- /dev/null
+/*
+ * Copyright (c) 1985 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef LIBC_SCCS
+_sccsid:.asciz "@(#)puts.c 5.4 (Berkeley) 4/1/86"
+#endif LIBC_SCCS
+
+/*
+ * puts(s);
+ * char *s;
+ *
+ * argument: a source string.
+ * side effects: writes to the standard output using the data in
+ * the null-terminated source string; a newline is appended.
+ * result: technically void; for compatibility we return 0 for the null
+ * string, non-zero otherwise. We return zero for errors too.
+ */
+
+#include "DEFS.h"
+
+#define NBF 04
+#define LBF 0200
+
+#define NL 012
+
+ENTRY(puts, R11|R10|R9)
+
+#define S r11
+ movl 4(ap),S
+#define IOP r10
+#define _CNT
+#define _PTR 4
+#define _BASE 8
+#define _BUFSIZ 12
+#define _FLAG 16
+ movab __iob+20,IOP
+
+#define UNBUF -4(fp)
+
+#define COUNT r9
+
+ /*
+ * For unbuffered I/O, line buffer the output line.
+ * Ugly but fast -- and doesn't CURRENTLY break anything (sigh).
+ */
+ movab -1028(sp),sp
+ bicw3 $~NBF,_FLAG(IOP),UNBUF
+ jeql 1f
+
+ bicw2 $NBF,_FLAG(IOP) /* Clear no-buffering flag */
+ movl sp,_BASE(IOP) /* Create a buffer */
+ movl sp,_PTR(IOP)
+ cvtwl $1024,_BUFSIZ(IOP)
+ jbr 2f
+
+1:
+ tstl _CNT(IOP) /* Has a buffer been allocated? */
+ jgtr 2f
+ pushl IOP /* Get _flsbuf() to make one */
+ pushl $0
+ calls $2,__flsbuf
+ tstl r0
+ jlss Lerror
+ incl _CNT(IOP) /* Unput the char we sent */
+ decl _PTR(IOP)
+2:
+
+ /*
+ * Search for the terminating null.
+ */
+Lloop:
+ addl3 _BASE(IOP),_BUFSIZ(IOP),COUNT /* How many bytes? */
+ subl2 _PTR(IOP),COUNT
+ locc $0,COUNT,(S) /* Look for a null */
+ jeql Lagain
+
+ subl2 r0,COUNT /* Copy the data */
+ movc3 COUNT,(S),*_PTR(IOP)
+ movl r3,_PTR(IOP) /* Fix up IOP */
+ subl2 COUNT,_CNT(IOP)
+
+Lnl:
+ movb $NL,*_PTR(IOP) /* Append a newline */
+ incl _PTR(IOP)
+ decl _CNT(IOP)
+
+ bitw $LBF,_FLAG(IOP) /* If line buffered... */
+ jneq 1f
+ tstw UNBUF /* or unbuffered... */
+ jneq 1f
+ tstl _CNT(IOP) /* or a full buffer... */
+ jgtr 2f
+1:
+ pushl IOP /* ... flush the buffer */
+ calls $1,_fflush
+ tstl r0
+ jlss Lerror
+2:
+
+ /*
+ * Fix up buffering again.
+ */
+ tstw UNBUF
+ jeql 1f
+ bisw2 $NBF,_FLAG(IOP) /* Reset flag */
+ clrl _BASE(IOP) /* Clear data structure */
+ clrl _BUFSIZ(IOP)
+ clrl _CNT(IOP)
+1:
+ cvtbl $NL,r0 /* Compatibility hack */
+ ret
+
+ /*
+ * We didn't find the null -- loop.
+ */
+Lagain:
+ movc3 COUNT,(S),*_PTR(IOP) /* Copy the data */
+ movl r1,S
+ movl r3,_PTR(IOP) /* Fix up IOP */
+ subl2 COUNT,_CNT(IOP)
+ pushl IOP /* The buffer is full -- flush it */
+ calls $1,_fflush
+ tstl r0
+ jlss Lerror
+ tstb (S) /* More data? */
+ jneq Lloop
+ jbr Lnl
+
+ /*
+ * Bomb out. Return 0 (why not? that's what the old one did).
+ */
+Lerror:
+ clrl r0
+ ret
--- /dev/null
+#
+# Copyright (c) 1980 Regents of the University of California.
+# All rights reserved. The Berkeley software License Agreement
+# specifies the terms and conditions for redistribution.
+#
+# @(#)Makefile 5.4 (Berkeley) 9/5/85
+#
+
+SRCS= Ovfork.c Ovadvise.c \
+ accept.c access.c acct.c \
+ adjtime.c bind.c brk.c \
+ cerror.c chdir.c chmod.c chown.c chroot.c close.c connect.c \
+ creat.c \
+ dup.c dup2.c \
+ execl.c execle.c exect.c execv.c execve.c _exit.c \
+ fchmod.c fchown.c fcntl.c flock.c fork.c fstat.c fsync.c ftruncate.c \
+ getdtablesize.c getegid.c geteuid.c getgid.c \
+ getgroups.c gethostid.c gethostname.c getitimer.c getrlimit.c \
+ getpagesize.c getpeername.c getpgrp.c getpid.c getppid.c \
+ getpriority.c getrusage.c getsockname.c getsockopt.c \
+ gettimeofday.c getuid.c \
+ ioctl.c \
+ kill.c killpg.c \
+ link.c listen.c lseek.c lstat.c \
+ mkdir.c mknod.c mount.c \
+ open.c \
+ pipe.c profil.c ptrace.c \
+ quota.c \
+ read.c readlink.c readv.c reboot.c recv.c recvfrom.c \
+ recvmsg.c rename.c rmdir.c \
+ sbrk.c select.c send.c sendmsg.c sendto.c setregid.c setgroups.c \
+ sethostid.c sethostname.c setitimer.c setquota.c setrlimit.c \
+ setpgrp.c setpriority.c setsockopt.c settimeofday.c setreuid.c \
+ shutdown.c sigblock.c sigpause.c sigreturn.c \
+ sigsetmask.c sigstack.c sigvec.c socket.c socketpair.c stat.c \
+ swapon.c symlink.c sync.c syscall.c \
+ truncate.c \
+ umask.c umount.c unlink.c utimes.c \
+ vhangup.c \
+ wait.c wait3.c write.c writev.c
+OBJS= Ovfork.o Ovadvise.o \
+ accept.o access.o acct.o \
+ adjtime.o bind.o brk.o \
+ cerror.o chdir.o chmod.o chown.o chroot.o close.o connect.o \
+ creat.o \
+ dup.o dup2.o \
+ execl.o execle.o exect.o execv.o execve.o _exit.o \
+ fchmod.o fchown.o fcntl.o flock.o fork.o fstat.o fsync.o ftruncate.o \
+ getdtablesize.o getegid.o geteuid.o getgid.o \
+ getgroups.o gethostid.o gethostname.o getitimer.o getrlimit.o \
+ getpagesize.o getpeername.o getpgrp.o getpid.o getppid.o \
+ getpriority.o getrusage.o getsockname.o getsockopt.o \
+ gettimeofday.o getuid.o \
+ ioctl.o \
+ kill.o killpg.o \
+ link.o listen.o lseek.o lstat.o \
+ mkdir.o mknod.o mount.o \
+ open.o \
+ pipe.o profil.o ptrace.o \
+ quota.o \
+ read.o readlink.o readv.o reboot.o recv.o recvfrom.o \
+ recvmsg.o rename.o rmdir.o \
+ sbrk.o select.o send.o sendmsg.o sendto.o setregid.o setgroups.o \
+ sethostid.o sethostname.o setitimer.o setquota.o setrlimit.o \
+ setpgrp.o setpriority.o setsockopt.o settimeofday.o setreuid.o \
+ shutdown.o sigblock.o sigpause.o sigreturn.o \
+ sigsetmask.o sigstack.o sigvec.o socket.o socketpair.o stat.o \
+ swapon.o symlink.o sync.o syscall.o \
+ truncate.o \
+ umask.o umount.o unlink.o utimes.o \
+ vhangup.o \
+ wait.o wait3.o write.o writev.o
+TAGSFILE=tags
+
+.c.o:
+ /lib/cpp -E ${DEFS} -DPROF $*.c | ${AS} -o $*.o
+ -ld -x -r $*.o
+ mv a.out profiled/$*.o
+ /lib/cpp -E ${DEFS} $*.c | ${AS} -o $*.o
+ -ld -x -r $*.o
+ mv a.out $*.o
+
+syslib syslib_p: ${OBJS}
+ @echo "building profiled syslib_p"
+ @cd profiled; ar cru ../syslib_p ${OBJS}
+ @echo "building normal syslib_p"
+ @ar cru syslib ${OBJS}
+
+tags:
+
+clean:
+ rm -f syslib syslib_p ${OBJS} profiled/*.o tags Makefile.bak
+
+depend:
+ for i in ${SRCS}; do \
+ cc -M ${DEFS} $$i | awk ' { if ($$1 != prev) \
+ { if (rec != "") print rec; rec = $$0; prev = $$1; } \
+ else { if (length(rec $$2) > 78) { print rec; rec = $$0; } \
+ else rec = rec " " $$2 } } \
+ END { print rec } ' >> makedep; done
+ echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
+ echo '$$r makedep' >>eddep
+ echo 'w' >>eddep
+ cp Makefile Makefile.bak
+ ed - Makefile < eddep
+ rm eddep makedep
+ echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
+ echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
+ echo '# see make depend above' >> Makefile
+
+# DO NOT DELETE THIS LINE -- make depend uses it
+
+Ovfork.o: Ovfork.c
+Ovadvise.o: Ovadvise.c ./SYS.h /usr/include/syscall.h
+accept.o: accept.c ./SYS.h /usr/include/syscall.h
+access.o: access.c ./SYS.h /usr/include/syscall.h
+acct.o: acct.c ./SYS.h /usr/include/syscall.h
+adjtime.o: adjtime.c ./SYS.h /usr/include/syscall.h
+bind.o: bind.c ./SYS.h /usr/include/syscall.h
+brk.o: brk.c ./SYS.h /usr/include/syscall.h
+cerror.o: cerror.c ./SYS.h /usr/include/syscall.h
+chdir.o: chdir.c ./SYS.h /usr/include/syscall.h
+chmod.o: chmod.c ./SYS.h /usr/include/syscall.h
+chown.o: chown.c ./SYS.h /usr/include/syscall.h
+chroot.o: chroot.c ./SYS.h /usr/include/syscall.h
+close.o: close.c ./SYS.h /usr/include/syscall.h
+connect.o: connect.c ./SYS.h /usr/include/syscall.h
+creat.o: creat.c ./SYS.h /usr/include/syscall.h
+dup.o: dup.c ./SYS.h /usr/include/syscall.h
+dup2.o: dup2.c ./SYS.h /usr/include/syscall.h
+execl.o: execl.c ./SYS.h /usr/include/syscall.h
+execle.o: execle.c ./SYS.h /usr/include/syscall.h
+exect.o: exect.c ./SYS.h /usr/include/syscall.h /usr/include/machine/psl.h
+execv.o: execv.c ./SYS.h /usr/include/syscall.h
+execve.o: execve.c ./SYS.h /usr/include/syscall.h
+_exit.o: _exit.c ./SYS.h /usr/include/syscall.h
+fchmod.o: fchmod.c ./SYS.h /usr/include/syscall.h
+fchown.o: fchown.c ./SYS.h /usr/include/syscall.h
+fcntl.o: fcntl.c ./SYS.h /usr/include/syscall.h
+flock.o: flock.c ./SYS.h /usr/include/syscall.h
+fork.o: fork.c ./SYS.h /usr/include/syscall.h
+fstat.o: fstat.c ./SYS.h /usr/include/syscall.h
+fsync.o: fsync.c ./SYS.h /usr/include/syscall.h
+ftruncate.o: ftruncate.c ./SYS.h /usr/include/syscall.h
+getdtablesize.o: getdtablesize.c ./SYS.h /usr/include/syscall.h
+getegid.o: getegid.c ./SYS.h /usr/include/syscall.h
+geteuid.o: geteuid.c ./SYS.h /usr/include/syscall.h
+getgid.o: getgid.c ./SYS.h /usr/include/syscall.h
+getgroups.o: getgroups.c ./SYS.h /usr/include/syscall.h
+gethostid.o: gethostid.c ./SYS.h /usr/include/syscall.h
+gethostname.o: gethostname.c ./SYS.h /usr/include/syscall.h
+getitimer.o: getitimer.c ./SYS.h /usr/include/syscall.h
+getrlimit.o: getrlimit.c ./SYS.h /usr/include/syscall.h
+getpagesize.o: getpagesize.c ./SYS.h /usr/include/syscall.h
+getpeername.o: getpeername.c ./SYS.h /usr/include/syscall.h
+getpgrp.o: getpgrp.c ./SYS.h /usr/include/syscall.h
+getpid.o: getpid.c ./SYS.h /usr/include/syscall.h
+getppid.o: getppid.c ./SYS.h /usr/include/syscall.h
+getpriority.o: getpriority.c ./SYS.h /usr/include/syscall.h
+getrusage.o: getrusage.c ./SYS.h /usr/include/syscall.h
+getsockname.o: getsockname.c ./SYS.h /usr/include/syscall.h
+getsockopt.o: getsockopt.c ./SYS.h /usr/include/syscall.h
+gettimeofday.o: gettimeofday.c ./SYS.h /usr/include/syscall.h
+getuid.o: getuid.c ./SYS.h /usr/include/syscall.h
+ioctl.o: ioctl.c ./SYS.h /usr/include/syscall.h
+kill.o: kill.c ./SYS.h /usr/include/syscall.h
+killpg.o: killpg.c ./SYS.h /usr/include/syscall.h
+link.o: link.c ./SYS.h /usr/include/syscall.h
+listen.o: listen.c ./SYS.h /usr/include/syscall.h
+lseek.o: lseek.c ./SYS.h /usr/include/syscall.h
+lstat.o: lstat.c ./SYS.h /usr/include/syscall.h
+mkdir.o: mkdir.c ./SYS.h /usr/include/syscall.h
+mknod.o: mknod.c ./SYS.h /usr/include/syscall.h
+mount.o: mount.c ./SYS.h /usr/include/syscall.h
+open.o: open.c ./SYS.h /usr/include/syscall.h
+pipe.o: pipe.c ./SYS.h /usr/include/syscall.h
+profil.o: profil.c ./SYS.h /usr/include/syscall.h
+ptrace.o: ptrace.c ./SYS.h /usr/include/syscall.h
+quota.o: quota.c ./SYS.h /usr/include/syscall.h
+read.o: read.c ./SYS.h /usr/include/syscall.h
+readlink.o: readlink.c ./SYS.h /usr/include/syscall.h
+readv.o: readv.c ./SYS.h /usr/include/syscall.h
+reboot.o: reboot.c ./SYS.h /usr/include/syscall.h
+recv.o: recv.c ./SYS.h /usr/include/syscall.h
+recvfrom.o: recvfrom.c ./SYS.h /usr/include/syscall.h
+recvmsg.o: recvmsg.c ./SYS.h /usr/include/syscall.h
+rename.o: rename.c ./SYS.h /usr/include/syscall.h
+rmdir.o: rmdir.c ./SYS.h /usr/include/syscall.h
+sbrk.o: sbrk.c ./SYS.h /usr/include/syscall.h
+select.o: select.c ./SYS.h /usr/include/syscall.h
+send.o: send.c ./SYS.h /usr/include/syscall.h
+sendmsg.o: sendmsg.c ./SYS.h /usr/include/syscall.h
+sendto.o: sendto.c ./SYS.h /usr/include/syscall.h
+setregid.o: setregid.c ./SYS.h /usr/include/syscall.h
+setgroups.o: setgroups.c ./SYS.h /usr/include/syscall.h
+sethostid.o: sethostid.c ./SYS.h /usr/include/syscall.h
+sethostname.o: sethostname.c ./SYS.h /usr/include/syscall.h
+setitimer.o: setitimer.c ./SYS.h /usr/include/syscall.h
+setquota.o: setquota.c ./SYS.h /usr/include/syscall.h
+setrlimit.o: setrlimit.c ./SYS.h /usr/include/syscall.h
+setpgrp.o: setpgrp.c ./SYS.h /usr/include/syscall.h
+setpriority.o: setpriority.c ./SYS.h /usr/include/syscall.h
+setsockopt.o: setsockopt.c ./SYS.h /usr/include/syscall.h
+settimeofday.o: settimeofday.c ./SYS.h /usr/include/syscall.h
+setreuid.o: setreuid.c ./SYS.h /usr/include/syscall.h
+shutdown.o: shutdown.c ./SYS.h /usr/include/syscall.h
+sigblock.o: sigblock.c ./SYS.h /usr/include/syscall.h
+sigpause.o: sigpause.c ./SYS.h /usr/include/syscall.h
+sigreturn.o: sigreturn.c ./SYS.h /usr/include/syscall.h
+sigsetmask.o: sigsetmask.c ./SYS.h /usr/include/syscall.h
+sigstack.o: sigstack.c ./SYS.h /usr/include/syscall.h
+sigvec.o: sigvec.c ./SYS.h /usr/include/syscall.h
+socket.o: socket.c ./SYS.h /usr/include/syscall.h
+socketpair.o: socketpair.c ./SYS.h /usr/include/syscall.h
+stat.o: stat.c ./SYS.h /usr/include/syscall.h
+swapon.o: swapon.c ./SYS.h /usr/include/syscall.h
+symlink.o: symlink.c ./SYS.h /usr/include/syscall.h
+sync.o: sync.c ./SYS.h /usr/include/syscall.h
+syscall.o: syscall.c ./SYS.h /usr/include/syscall.h
+truncate.o: truncate.c ./SYS.h /usr/include/syscall.h
+umask.o: umask.c ./SYS.h /usr/include/syscall.h
+umount.o: umount.c ./SYS.h /usr/include/syscall.h
+unlink.o: unlink.c ./SYS.h /usr/include/syscall.h
+utimes.o: utimes.c ./SYS.h /usr/include/syscall.h
+vhangup.o: vhangup.c ./SYS.h /usr/include/syscall.h
+wait.o: wait.c ./SYS.h /usr/include/syscall.h
+wait3.o: wait3.c ./SYS.h /usr/include/syscall.h
+write.o: write.c ./SYS.h /usr/include/syscall.h
+writev.o: writev.c ./SYS.h /usr/include/syscall.h
+# DEPENDENCIES MUST END AT END OF FILE
+# IF YOU PUT STUFF HERE IT WILL GO AWAY
+# see make depend above
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)Ovadvise.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+#define SYS_vadvise 72
+
+SYSCALL(vadvise)
+ ret
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)Ovfork.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+/*
+ * @(#)vfork.s 4.1 (Berkeley) 12/21/80
+ * C library -- vfork
+ */
+
+/*
+ * pid = vfork();
+ *
+ * r1 == 0 in parent process, r1 == 1 in child process.
+ * r0 == pid of child in parent, r0 == pid of parent in child.
+ *
+ * trickery here, due to keith sklower, uses ret to clear the stack,
+ * and then returns with a jump indirect, since only one person can return
+ * with a ret off this stack... we do the ret before we vfork!
+ */
+
+ .set vfork,66
+.globl _vfork
+
+_vfork:
+ .word 0x0000
+ movl 16(fp),r2
+ movab here,16(fp)
+ ret
+here:
+ chmk $vfork
+ bcc vforkok
+ jmp verror
+vforkok:
+ tstl r1 # child process ?
+ bneq child # yes
+ bcc parent # if c-bit not set, fork ok
+.globl _errno
+verror:
+ movl r0,_errno
+ mnegl $1,r0
+ jmp (r2)
+child:
+ clrl r0
+parent:
+ jmp (r2)
--- /dev/null
+#include "gen.h"
+void _exit(s) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)_exit.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+ .align 1
+PSEUDO(_exit,exit)
+ # _exit(status)
--- /dev/null
+#include "gen.h"
+int accept(s, a, l) struct sockaddr *a; int *l; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)accept.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(accept)
+ ret
--- /dev/null
+#include "gen.h"
+int access(p, m) char *p; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)access.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(access)
+ ret
--- /dev/null
+#include "gen.h"
+int acct(f) char *f; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)acct.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(acct)
+ ret
--- /dev/null
+#include "gen.h"
+int adjtime(delta, odelta) struct timeval *delta, *odelta; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)adjtime.c 5.2 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(adjtime)
+ ret
--- /dev/null
+#include "gen.h"
+int bind(s, n, l) struct sockaddr *n; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)bind.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(bind)
+ ret
--- /dev/null
+#include "gen.h"
+char *brk(a) char *a; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)brk.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+#define SYS_brk 17
+
+ .globl curbrk
+ .globl minbrk
+ENTRY(_brk)
+ jbr ok
+
+ENTRY(brk)
+ cmpl 4(ap),minbrk
+ bgeq ok
+ movl minbrk,4(ap)
+ok:
+ chmk $SYS_brk
+ jcs err
+ movl 4(ap),curbrk
+ clrl r0
+ ret
+err:
+ jmp cerror
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)cerror.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+ .globl _errno
+cerror:
+ movl r0,_errno
+ mnegl $1,r0
+ ret
--- /dev/null
+#include "gen.h"
+int chdir(s) char *s; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)chdir.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(chdir)
+ ret
--- /dev/null
+#include "gen.h"
+int chmod(s, m) char *s; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)chmod.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(chmod)
+ ret
--- /dev/null
+#include "gen.h"
+int chown(s, u, g) char *s; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)chown.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(chown)
+ ret
--- /dev/null
+#include "gen.h"
+int chroot(d) char *d; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)chroot.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(chroot)
+ ret
--- /dev/null
+#include "gen.h"
+int close(f) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)close.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(close)
+ ret
--- /dev/null
+#include "gen.h"
+int connect(s, n, l) struct sockaddr *n; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)connect.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(connect)
+ ret
--- /dev/null
+#include "gen.h"
+int creat(s, m) char *s; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)creat.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(creat)
+ ret
--- /dev/null
+#include "gen.h"
+int dup(f) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)dup.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(dup)
+ ret
--- /dev/null
+#include "gen.h"
+int dup2(o, n) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)dup2.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(dup2)
+ ret
--- /dev/null
+#include "gen.h"
+void execl(f, a) char *f, *a; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)execl.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+ENTRY(execl)
+ pushab 8(ap)
+ pushl 4(ap)
+ calls $2,_execv
+ ret # execl(file, arg1, arg2, ..., 0);
--- /dev/null
+#include "gen.h"
+void execle(f, a) char *f, *a; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)execle.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+ENTRY(execle)
+ movl (ap),r0
+ pushl (ap)[r0]
+ pushab 8(ap)
+ pushl 4(ap)
+ calls $3,_execve
+ ret # execle(file, arg1, arg2, ..., env);
--- /dev/null
+#include "gen.h"
+void exect(s, v, e) char *s, *v[], *e[]; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)exect.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+#include <machine/psl.h>
+
+ENTRY(exect)
+ bispsw $PSL_T
+ chmk $SYS_execve
+ jmp cerror # exect(file, argv, env)
--- /dev/null
+#include "gen.h"
+void execv(s, v) char *s, *v[]; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)execv.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+ENTRY(execv)
+ .globl _environ
+ pushl _environ
+ pushl 8(ap)
+ pushl 4(ap)
+ calls $3,_execve
+ ret # execv(file, argv)
--- /dev/null
+#include "gen.h"
+void execve(s, v, e) char *s, *v[], *e[]; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)execve.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(execve)
+ ret # execve(file, argv, arge)
--- /dev/null
+#include "gen.h"
+int fchmod(f, m) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)fchmod.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(fchmod)
+ ret
--- /dev/null
+#include "gen.h"
+int fchown(f, u, g) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)fchown.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(fchown)
+ ret
--- /dev/null
+#include "gen.h"
+int fcntl(f, c, a) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)fcntl.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(fcntl)
+ ret
--- /dev/null
+#include "gen.h"
+int flock(f, o) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)flock.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(flock)
+ ret
--- /dev/null
+#include "gen.h"
+int fork() {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)fork.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(fork)
+ jlbc r1,1f # parent, since r1 == 0 in parent, 1 in child
+ clrl r0
+1:
+ ret # pid = fork()
--- /dev/null
+#include "gen.h"
+int fstat(f, b) struct stat *b; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)fstat.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(fstat)
+ ret
--- /dev/null
+#include "gen.h"
+int fsync(f) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)fsync.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+
+#include "SYS.h"
+
+SYSCALL(fsync)
+ ret
--- /dev/null
+#include "gen.h"
+int ftruncate(d, l) off_t l; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)ftruncate.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(ftruncate)
+ ret
--- /dev/null
+#include "gen.h"
+int getdtablesize() {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getdtablesize.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getdtablesize)
+ ret
--- /dev/null
+#include "gen.h"
+gid_t getegid() {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getegid.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+PSEUDO(getegid,getgid)
+ movl r1,r0
+ ret # egid = getegid();
--- /dev/null
+#include "gen.h"
+uid_t geteuid() {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)geteuid.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+PSEUDO(geteuid,getuid)
+ movl r1,r0
+ ret # euid = geteuid();
--- /dev/null
+#include "gen.h"
+gid_t getgid() {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getgid.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getgid)
+ ret # gid = getgid();
--- /dev/null
+#include "gen.h"
+int getgroups(n, g) int n, *g; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getgroups.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getgroups)
+ ret # ngroups = getgroups(gidsetsize, gidset)
--- /dev/null
+#include "gen.h"
+long gethostid() {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)gethostid.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(gethostid)
+ ret # hostid = gethostid()
--- /dev/null
+#include "gen.h"
+int gethostname(n, l) char *n; int l; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)gethostname.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(gethostname)
+ ret # len = gethostname(buf, buflen)
--- /dev/null
+#include "gen.h"
+int getitimer(w, v) struct itimerval *v; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getitimer.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getitimer)
+ ret
--- /dev/null
+#include "gen.h"
+int getpagesize() {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getpagesize.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getpagesize)
+ ret
--- /dev/null
+#include "gen.h"
+int getpeername(s, n, l) struct sockaddr *n; int *l; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getpeername.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getpeername)
+ ret
--- /dev/null
+#include "gen.h"
+int getpgrp(p) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getpgrp.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getpgrp)
+ ret # pgrp = getpgrp(pid);
--- /dev/null
+#include "gen.h"
+int getpid() {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getpid.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getpid)
+ ret # pid = getpid();
--- /dev/null
+#include "gen.h"
+int getppid() {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getppid.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+PSEUDO(getppid,getpid)
+ movl r1,r0
+ ret # ppid = getppid();
--- /dev/null
+#include "gen.h"
+int getpriority(w, who) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getpriority.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getpriority)
+ ret
--- /dev/null
+#include "gen.h"
+int getrlimit(res, rip) struct rlimit *rip; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getrlimit.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getrlimit)
+ ret
--- /dev/null
+#include "gen.h"
+int getrusage(res, rip) struct rusage *rip; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getrusage.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getrusage)
+ ret
--- /dev/null
+#include "gen.h"
+int getsockname(s, name, namelen) char *name; int *namelen; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getsockname.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getsockname)
+ ret
--- /dev/null
+#include "gen.h"
+int getsockopt(s, level, opt, buf, len) char *buf; int *len; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getsockopt.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getsockopt)
+ ret
--- /dev/null
+#include "gen.h"
+int gettimeofday(t, z) struct timeval *t; struct timezone *z; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)gettimeofday.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(gettimeofday)
+ ret
--- /dev/null
+#include "gen.h"
+uid_t getuid() {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)getuid.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(getuid)
+ ret # uid = getuid();
--- /dev/null
+#include "gen.h"
+int ioctl(d, r, p) u_long r; char *p; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)ioctl.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(ioctl)
+ ret
--- /dev/null
+#include "gen.h"
+int kill(p, s) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)kill.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(kill)
+ ret
--- /dev/null
+#include "gen.h"
+int killpg(pg, s) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)killpg.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(killpg)
+ ret
--- /dev/null
+#include "gen.h"
+int link(a, b) char *a, *b; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)link.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(link)
+ ret
--- /dev/null
+#include "gen.h"
+int listen(s, b){
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)listen.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(listen)
+ ret
--- /dev/null
+#include "gen.h"
+off_t lseek(f, o, d) off_t o; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)lseek.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(lseek)
+ ret
--- /dev/null
+#include "gen.h"
+int lstat(s, b) char *s; struct stat *b; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)lstat.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(lstat)
+ ret
--- /dev/null
+#include "gen.h"
+int mkdir(p, m) char *p; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)mkdir.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(mkdir)
+ ret
--- /dev/null
+#include "gen.h"
+int mknod(n, m, a) char *n; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)mknod.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(mknod)
+ ret
--- /dev/null
+#include "gen.h"
+int mount(s, n, f) char *s, *n; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)mount.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(mount)
+ clrl r0
+ ret
--- /dev/null
+#include "gen.h"
+int open(f, m, stuff) char *f; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)open.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(open)
+ ret
--- /dev/null
+#include "gen.h"
+int pipe(f) int f[2]; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)pipe.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(pipe)
+ movl 4(ap),r2
+ movl r0,(r2)+
+ movl r1,(r2)
+ clrl r0
+ ret
--- /dev/null
+#include "gen.h"
+void profil(b, s, o, i) char *b; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)profil.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(profil)
+ ret
--- /dev/null
+#include "gen.h"
+int ptrace(r, p, a, d) int *a; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)ptrace.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+ENTRY(ptrace)
+ clrl _errno
+ chmk $SYS_ptrace
+ jcs err
+ ret
+err:
+ jmp cerror
--- /dev/null
+#include "gen.h"
+int quota(c, u, a, ad) char *ad; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)quota.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(quota)
+ ret
--- /dev/null
+#include "gen.h"
+int read(f, b, l) char *b; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)read.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(read)
+ ret
--- /dev/null
+#include "gen.h"
+int readlink(p, b, s) char *p, *b; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)readlink.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(readlink)
+ ret
--- /dev/null
+#include "gen.h"
+int readv(d, v, l) struct iovec *v; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)readv.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+
+#include "SYS.h"
+
+SYSCALL(readv)
+ ret
--- /dev/null
+#include "gen.h"
+void reboot(h) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)reboot.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(reboot)
+ halt
--- /dev/null
+#include "gen.h"
+int recv(s, b, l, f) char *b; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)recv.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(recv)
+ ret
--- /dev/null
+#include "gen.h"
+int recvfrom(s, b, l, f, fr, fl) char *b; struct sockaddr *fr; int *fl;
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)recvfrom.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(recvfrom)
+ ret
--- /dev/null
+#include "gen.h"
+int recvmsg(s, m, f) struct msghdr m[]; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)recvmsg.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(recvmsg)
+ ret
--- /dev/null
+#include "gen.h"
+int rename(f, t) char *f, *t; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)rename.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(rename)
+ ret
--- /dev/null
+#include "gen.h"
+int rmdir(p) char *p; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)rmdir.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(rmdir)
+ ret
--- /dev/null
+#include "gen.h"
+char *sbrk(i) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)sbrk.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+#define SYS_brk 17
+
+ .globl _end
+ .globl minbrk
+ .globl curbrk
+
+ .data
+minbrk: .long _end
+curbrk: .long _end
+ .text
+
+ENTRY(sbrk)
+ addl3 curbrk,4(ap),-(sp)
+ pushl $1
+ movl ap,r3
+ movl sp,ap
+ chmk $SYS_brk
+ jcs err
+ movl curbrk,r0
+ addl2 4(r3),curbrk
+ ret
+err:
+ jmp cerror
--- /dev/null
+#include "gen.h"
+int select(n, r, w, e, t) fd_set *r, *w, *e; struct timeval *t; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)select.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(select)
+ ret
--- /dev/null
+#include "gen.h"
+int send(s, m, l, f) char *m; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)send.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(send)
+ ret
--- /dev/null
+#include "gen.h"
+int sendmsg(s, m, l) struct msghdr m[]; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)sendmsg.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(sendmsg)
+ ret
--- /dev/null
+#include "gen.h"
+int sendto(s, m, l, f, t, tl) char *m; struct sockaddr *t; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)sendto.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(sendto)
+ ret
--- /dev/null
+#include "gen.h"
+int setgroups(n, g) int *g; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)setgroups.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(setgroups)
+ ret # setgroups(gidsetsize, gidset)
--- /dev/null
+#include "gen.h"
+int sethostid(h) long h; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)sethostid.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(sethostid)
+ ret # sethostid(hostid)
--- /dev/null
+#include "gen.h"
+int sethostname(n, l) char *n; int l; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)sethostname.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(sethostname)
+ ret # sethostname(name, len)
--- /dev/null
+#include "gen.h"
+int setitimer(w, v, ov) struct itimerval *v, *ov; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)setitimer.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(setitimer)
+ ret
--- /dev/null
+#include "gen.h"
+int setpgrp(g, pg) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)setpgrp.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(setpgrp)
+ ret # setpgrp(pid, pgrp);
--- /dev/null
+#include "gen.h"
+int setpriority(w, who, pri) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)setpriority.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(setpriority)
+ ret
--- /dev/null
+#include "gen.h"
+int setquota(s, f) char *s, *f; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)setquota.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(setquota)
+ ret
--- /dev/null
+#include "gen.h"
+int setregid(r, e) int r, e; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)setregid.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(setregid)
+ ret # setregid(rgid, egid)
--- /dev/null
+#include "gen.h"
+int setreuid(r, e) int r, e; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)setreuid.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(setreuid)
+ ret # setreuid(ruid, euid)
--- /dev/null
+#include "gen.h"
+int setrlimit(res, rip) struct rlimit *rip; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)setrlimit.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(setrlimit)
+ ret
--- /dev/null
+#include "gen.h"
+int setsockopt(s, level, opt, buf, len) char *buf; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)setsockopt.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(setsockopt)
+ ret
--- /dev/null
+#include "gen.h"
+int settimeofday(t, z) struct timeval *t; struct timezone *z; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)settimeofday.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(settimeofday)
+ ret
--- /dev/null
+#include "gen.h"
+int shutdown(s, h){
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)shutdown.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(shutdown)
+ ret
--- /dev/null
+#include "gen.h"
+int sigblock(m) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)sigblock.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(sigblock)
+ ret
--- /dev/null
+#include "gen.h"
+void sigpause(m) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)sigpause.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(sigpause)
+ ret
--- /dev/null
+#include "gen.h"
+int sigreturn(scp) struct sigcontext *scp; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)sigreturn.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+/*
+ * We must preserve the state of the registers as the user has set them up.
+ */
+#ifdef PROF
+#undef ENTRY
+#define ENTRY(x) \
+ .globl _/**/x; .align 2; _/**/x: .word 0; pushr $0x3f; \
+ .data; 1:; .long 0; .text; moval 1b,r0; jsb mcount; popr $0x3f
+#endif PROF
+
+SYSCALL(sigreturn)
+ ret
--- /dev/null
+#include "gen.h"
+int sigsetmask(m) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)sigsetmask.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(sigsetmask)
+ ret
--- /dev/null
+#include "gen.h"
+int sigstack(ss, oss) struct sigstack *ss, *oss; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)sigstack.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(sigstack)
+ ret
--- /dev/null
+#include "gen.h"
+int sigvec(c, f, m) struct sigvec *f, *m; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)sigvec.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(sigvec)
+ ret
--- /dev/null
+#include "gen.h"
+int socket(a, t, p) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)socket.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(socket)
+ ret
--- /dev/null
+#include "gen.h"
+int socketpair(d, t, p, s) int s[2]; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)socketpair.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(socketpair)
+ ret
--- /dev/null
+#include "gen.h"
+int stat(s, b) char *s; struct stat *b; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)stat.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+
+#include "SYS.h"
+
+SYSCALL(stat)
+ ret
--- /dev/null
+#include "gen.h"
+int swapon(s) char *s; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)swapon.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(swapon)
+ ret
--- /dev/null
+#include "gen.h"
+int symlink(t, f) char *t, *f; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)symlink.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(symlink)
+ ret
--- /dev/null
+#include "gen.h"
+void sync(){
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)sync.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(sync)
+ ret
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)syscall.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+ENTRY(syscall)
+ movl 4(ap),r0 # syscall number
+ subl3 $1,(ap)+,(ap) # one fewer arguments
+ chmk r0
+ jcs 1f
+ ret
+1:
+ jmp cerror
--- /dev/null
+#include "gen.h"
+int truncate(p, l) char *p; off_t l; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)truncate.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(truncate)
+ ret
--- /dev/null
+#include "gen.h"
+int umask(n) {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)umask.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(umask)
+ ret
--- /dev/null
+#include "gen.h"
+int umount(s) char *s; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)umount.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(umount)
+ ret
--- /dev/null
+#include "gen.h"
+int unlink(s) char *s; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)unlink.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(unlink)
+ ret
--- /dev/null
+#include "gen.h"
+int utimes(f, t) char *f; struct timeval t[2]; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)utimes.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(utimes)
+ ret
--- /dev/null
+#include "gen.h"
+void vhangup() {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)vhangup.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+#define SYS_vhangup 76
+
+SYSCALL(vhangup)
+ ret
--- /dev/null
+#include "gen.h"
+int wait(s) union wait *s; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)wait.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(wait)
+ tstl 4(ap)
+ jeql 1f
+ movl r1,*4(ap)
+1:
+ ret
--- /dev/null
+#include "gen.h"
+int wait3(s, o, r) union wait *s; struct rusage *r; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)wait3.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+/* @(#)wait3.c 5.3 (Berkeley) 3/9/86 */
+
+/*
+ * C library -- wait3
+ *
+ * pid = wait3(&status, flags, &rusage);
+ *
+ * pid == -1 if error
+ * status indicates fate of process, if given
+ * flags may indicate process is not to hang or
+ * that untraced stopped children are to be reported.
+ * rusage optionally returns detailed resource usage information
+ */
+#include "SYS.h"
+
+#define SYS_wait3 SYS_wait
+
+ENTRY(wait3)
+ movl 8(ap),r0 /* make it easy for system to get */
+ movl 12(ap),r1 /* these extra arguments */
+ bispsw $0xf /* flags wait3() */
+ chmk $SYS_wait3
+ bcc noerror
+ movl r0,_errno
+ mnegl $1,r0
+ ret
+noerror:
+ tstl 4(ap) /* status desired? */
+ beql nostatus /* no */
+ movl r1,*4(ap) /* store child's status */
+nostatus:
+ ret
--- /dev/null
+#include "gen.h"
+int write(f, b, l) char *b; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)write.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(write)
+ ret
--- /dev/null
+#include "gen.h"
+int writev(f, v, l) struct iovec *v; {
+ abort();
+}
--- /dev/null
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved. The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifdef SYSLIBC_SCCS
+_sccsid:.asciz "@(#)writev.c 5.3 (Berkeley) 3/9/86"
+#endif SYSLIBC_SCCS
+
+#include "SYS.h"
+
+SYSCALL(writev)
+ ret