From 47b73ff83c630e53ce21b34569f21c75bff4cac5 Mon Sep 17 00:00:00 2001 From: deraadt <> Date: Wed, 18 Oct 1995 08:43:13 +0000 Subject: [PATCH] initial import of NetBSD tree --- src/etc/MAKEDEV.local | 49 + src/etc/Makefile | 147 ++ src/etc/aliases | 33 + src/etc/bootptab | 69 + src/etc/changelist | 48 + src/etc/crontab | 18 + src/etc/csh.cshrc | 1 + src/etc/csh.login | 1 + src/etc/csh.logout | 1 + src/etc/daily | 128 ++ src/etc/dm.conf | 19 + src/etc/etc.alpha/MAKEDEV | 260 +++ src/etc/etc.alpha/disktab | 10 + src/etc/etc.alpha/fstab.sd | 3 + src/etc/etc.alpha/ttys | 56 + src/etc/etc.amiga/MAKEDEV | 434 +++++ src/etc/etc.amiga/Makefile.inc | 14 + src/etc/etc.amiga/disktab | 45 + src/etc/etc.amiga/fstab.tmp | 20 + src/etc/etc.amiga/ttys | 48 + src/etc/etc.atari/MAKEDEV | 388 ++++ src/etc/etc.atari/Makefile.inc | 22 + src/etc/etc.atari/disktab | 51 + src/etc/etc.atari/fstab.tmp | 9 + src/etc/etc.atari/ttys | 44 + src/etc/etc.hp300/MAKEDEV | 320 ++++ src/etc/etc.hp300/Makefile.inc | 28 + src/etc/etc.hp300/disktab | 290 +++ src/etc/etc.hp300/fstab.rd | 6 + src/etc/etc.hp300/fstab.sd | 6 + src/etc/etc.hp300/ttys | 52 + src/etc/etc.i386/MAKEDEV | 348 ++++ src/etc/etc.i386/Makefile.inc | 38 + src/etc/etc.i386/Makefile.kc | 52 + src/etc/etc.i386/disktab | 119 ++ src/etc/etc.i386/files.kc/copy_kernel | 113 ++ src/etc/etc.i386/files.kc/dot.profile | 8 + src/etc/etc.i386/files.kc/list | 2 + src/etc/etc.i386/fstab.wd | 3 + src/etc/etc.i386/ttys | 48 + src/etc/etc.mac68k/MAKEDEV | 326 ++++ src/etc/etc.mac68k/disktab | 116 ++ src/etc/etc.mac68k/fstab.sd | 5 + src/etc/etc.mac68k/ttys | 56 + src/etc/etc.pc532/MAKEDEV | 247 +++ src/etc/etc.pc532/disktab | 70 + src/etc/etc.pc532/fstab.sd | 3 + src/etc/etc.pc532/ttys | 45 + src/etc/etc.pmax/MAKEDEV | 254 +++ src/etc/etc.pmax/disktab | 192 ++ src/etc/etc.pmax/fstab.rz | 3 + src/etc/etc.pmax/ttys | 47 + src/etc/etc.sparc/MAKEDEV | 299 +++ src/etc/etc.sparc/Makefile.inc | 27 + src/etc/etc.sparc/README | 118 ++ src/etc/etc.sparc/disktab | 2 + src/etc/etc.sparc/fstab.sd | 3 + src/etc/etc.sparc/install.sh | 20 + src/etc/etc.sparc/ttys | 40 + src/etc/etc.sun3/MAKEDEV | 213 +++ src/etc/etc.sun3/Makefile.inc | 20 + src/etc/etc.sun3/README | 51 + src/etc/etc.sun3/disktab | 42 + src/etc/etc.sun3/fstab.nfs | 2 + src/etc/etc.sun3/fstab.sd0 | 3 + src/etc/etc.sun3/install.sh | 23 + src/etc/etc.sun3/ttys | 46 + src/etc/etc.svr4/SVR4_MAKEDEV | 79 + src/etc/etc.svr4/netconfig | 7 + src/etc/etc.svr4/nsswitch.conf | 15 + src/etc/etc.vax/MAKEDEV | 387 ++++ src/etc/etc.vax/disktab | 491 +++++ src/etc/etc.vax/fstab.ra | 3 + src/etc/etc.vax/pcs750.bin.uu | 254 +++ src/etc/etc.vax/ttys | 53 + src/etc/ftpchroot | 3 + src/etc/ftpusers | 4 + src/etc/gettytab | 153 ++ src/etc/group | 17 + src/etc/hosts | 13 + src/etc/hosts.equiv | 2 + src/etc/hosts.lpd | 1 + src/etc/inetd.conf | 43 + src/etc/man.conf | 55 + src/etc/master.passwd | 10 + src/etc/monthly | 21 + src/etc/motd | 4 + src/etc/mrouted.conf | 14 + src/etc/mtree/4.4BSD.dist | 1457 ++++++++++++++ src/etc/mtree/4.4BSD.root | 163 ++ src/etc/mtree/4.4BSD.usr | 1668 +++++++++++++++++ src/etc/mtree/4.4BSD.var | 442 +++++ src/etc/mtree/special | 163 ++ src/etc/myname | 1 + src/etc/namedb/localhost.rev | 10 + src/etc/namedb/named.boot | 21 + src/etc/namedb/root.cache | 65 + src/etc/netstart | 102 + src/etc/networks | 16 + src/etc/newsyslog.conf | 12 + src/etc/phones | 7 + src/etc/printcap | 4 + src/etc/protocols | 28 + src/etc/rbootd.conf | 13 + src/etc/rc | 242 +++ src/etc/rc.local | 31 + src/etc/remote | 35 + src/etc/root/dot.cshrc | 26 + src/etc/root/dot.klogin | 2 + src/etc/root/dot.login | 2 + src/etc/root/dot.profile | 8 + src/etc/rpc | 35 + src/etc/security | 536 ++++++ src/etc/services | 181 ++ src/etc/shells | 6 + src/etc/syslog.conf | 9 + src/etc/weekly | 57 + src/include/Makefile | 114 ++ src/include/a.out.h | 47 + src/include/ar.h | 69 + src/include/arpa/ftp.h | 111 ++ src/include/arpa/inet.h | 55 + src/include/arpa/nameser.h | 248 +++ src/include/arpa/telnet.h | 322 ++++ src/include/arpa/tftp.h | 82 + src/include/assert.h | 67 + src/include/bitstring.h | 115 ++ src/include/bm.h | 61 + src/include/ctype.h | 108 ++ src/include/db.h | 234 +++ src/include/dirent.h | 104 + src/include/disktab.h | 63 + src/include/dlfcn.h | 62 + src/include/err.h | 70 + src/include/fnmatch.h | 53 + src/include/fstab.h | 81 + src/include/fts.h | 130 ++ src/include/glob.h | 92 + src/include/grp.h | 74 + src/include/ieeefp.h | 19 + src/include/iso646.h | 23 + src/include/kvm.h | 71 + src/include/langinfo.h | 73 + src/include/limits.h | 80 + src/include/link.h | 283 +++ src/include/locale.h | 83 + src/include/malloc.h | 3 + src/include/math.h | 274 +++ src/include/memory.h | 38 + src/include/mpool.h | 137 ++ src/include/ndbm.h | 81 + src/include/netdb.h | 126 ++ src/include/netgroup.h | 68 + src/include/nl_types.h | 48 + src/include/nlist.h | 90 + src/include/paths.h | 72 + src/include/protocols/dumprestore.h | 114 ++ src/include/protocols/routed.h | 113 ++ src/include/protocols/rwhod.h | 70 + src/include/protocols/talkd.h | 116 ++ src/include/protocols/timed.h | 101 + src/include/pwd.h | 102 + src/include/ranlib.h | 52 + src/include/regex.h | 108 ++ src/include/regexp.h | 71 + src/include/resolv.h | 166 ++ src/include/rpc/auth.h | 184 ++ src/include/rpc/auth_unix.h | 83 + src/include/rpc/clnt.h | 372 ++++ src/include/rpc/pmap_clnt.h | 86 + src/include/rpc/pmap_prot.h | 105 ++ src/include/rpc/pmap_rmt.h | 64 + src/include/rpc/rpc.h | 92 + src/include/rpc/rpc_msg.h | 196 ++ src/include/rpc/svc.h | 322 ++++ src/include/rpc/svc_auth.h | 51 + src/include/rpc/types.h | 63 + src/include/rpc/xdr.h | 307 +++ src/include/rpcsvc/yp_prot.h | 344 ++++ src/include/rpcsvc/ypclnt.h | 88 + src/include/search.h | 57 + src/include/setjmp.h | 72 + src/include/sgtty.h | 47 + src/include/signal.h | 119 ++ src/include/stab.h | 74 + src/include/stddef.h | 61 + src/include/stdio.h | 375 ++++ src/include/stdlib.h | 197 ++ src/include/string.h | 96 + src/include/strings.h | 38 + src/include/struct.h | 53 + src/include/sysexits.h | 120 ++ src/include/time.h | 109 ++ src/include/ttyent.h | 76 + src/include/tzfile.h | 153 ++ src/include/unistd.h | 188 ++ src/include/utime.h | 52 + src/include/utmp.h | 67 + src/include/vis.h | 86 + src/lib/libc/stdlib/Makefile.inc | 45 + src/lib/libc/stdlib/_rand48.c | 46 + src/lib/libc/stdlib/a64l.c | 34 + src/lib/libc/stdlib/abort.3 | 71 + src/lib/libc/stdlib/abort.c | 65 + src/lib/libc/stdlib/abs.3 | 74 + src/lib/libc/stdlib/abs.c | 46 + src/lib/libc/stdlib/alloca.3 | 79 + src/lib/libc/stdlib/atexit.3 | 78 + src/lib/libc/stdlib/atexit.c | 68 + src/lib/libc/stdlib/atexit.h | 46 + src/lib/libc/stdlib/atof.3 | 74 + src/lib/libc/stdlib/atof.c | 46 + src/lib/libc/stdlib/atoi.3 | 75 + src/lib/libc/stdlib/atoi.c | 46 + src/lib/libc/stdlib/atol.3 | 75 + src/lib/libc/stdlib/atol.c | 46 + src/lib/libc/stdlib/bsearch.3 | 91 + src/lib/libc/stdlib/bsearch.c | 80 + src/lib/libc/stdlib/calloc.3 | 71 + src/lib/libc/stdlib/calloc.c | 53 + src/lib/libc/stdlib/div.3 | 70 + src/lib/libc/stdlib/div.c | 80 + src/lib/libc/stdlib/drand48.c | 22 + src/lib/libc/stdlib/erand48.c | 23 + src/lib/libc/stdlib/exit.3 | 84 + src/lib/libc/stdlib/exit.c | 61 + src/lib/libc/stdlib/free.3 | 82 + src/lib/libc/stdlib/getenv.3 | 152 ++ src/lib/libc/stdlib/getenv.c | 82 + src/lib/libc/stdlib/getopt.3 | 260 +++ src/lib/libc/stdlib/getopt.c | 118 ++ src/lib/libc/stdlib/heapsort.c | 184 ++ src/lib/libc/stdlib/jrand48.c | 21 + src/lib/libc/stdlib/l64a.c | 43 + src/lib/libc/stdlib/labs.3 | 67 + src/lib/libc/stdlib/labs.c | 46 + src/lib/libc/stdlib/lcong48.c | 30 + src/lib/libc/stdlib/ldiv.3 | 72 + src/lib/libc/stdlib/ldiv.c | 59 + src/lib/libc/stdlib/lrand48.c | 23 + src/lib/libc/stdlib/malloc.3 | 91 + src/lib/libc/stdlib/malloc.c | 421 +++++ src/lib/libc/stdlib/memory.3 | 71 + src/lib/libc/stdlib/merge.c | 348 ++++ src/lib/libc/stdlib/mrand48.c | 23 + src/lib/libc/stdlib/multibyte.c | 131 ++ src/lib/libc/stdlib/nrand48.c | 21 + src/lib/libc/stdlib/putenv.c | 59 + src/lib/libc/stdlib/qabs.3 | 62 + src/lib/libc/stdlib/qabs.c | 46 + src/lib/libc/stdlib/qdiv.3 | 66 + src/lib/libc/stdlib/qdiv.c | 59 + src/lib/libc/stdlib/qsort.3 | 234 +++ src/lib/libc/stdlib/qsort.c | 175 ++ src/lib/libc/stdlib/radixsort.3 | 161 ++ src/lib/libc/stdlib/radixsort.c | 318 ++++ src/lib/libc/stdlib/rand.3 | 85 + src/lib/libc/stdlib/rand.c | 55 + src/lib/libc/stdlib/rand48.3 | 160 ++ src/lib/libc/stdlib/rand48.h | 30 + src/lib/libc/stdlib/random.3 | 167 ++ src/lib/libc/stdlib/random.c | 364 ++++ src/lib/libc/stdlib/realloc.3 | 100 + src/lib/libc/stdlib/realpath.3 | 126 ++ src/lib/libc/stdlib/realpath.c | 159 ++ src/lib/libc/stdlib/seed48.c | 36 + src/lib/libc/stdlib/setenv.c | 120 ++ src/lib/libc/stdlib/srand48.c | 30 + src/lib/libc/stdlib/strtod.3 | 114 ++ src/lib/libc/stdlib/strtod.c | 2499 +++++++++++++++++++++++++ src/lib/libc/stdlib/strtol.3 | 169 ++ src/lib/libc/stdlib/strtol.c | 130 ++ src/lib/libc/stdlib/strtoq.c | 136 ++ src/lib/libc/stdlib/strtoul.3 | 164 ++ src/lib/libc/stdlib/strtoul.c | 108 ++ src/lib/libc/stdlib/strtouq.c | 114 ++ src/lib/libc/stdlib/system.3 | 99 + src/lib/libc/stdlib/system.c | 79 + src/lib/libc/string/Makefile.inc | 108 ++ src/lib/libc/string/__strerror.c | 92 + src/lib/libc/string/__strsignal.c | 86 + src/lib/libc/string/bcmp.3 | 72 + src/lib/libc/string/bcmp.c | 59 + src/lib/libc/string/bcopy.3 | 72 + src/lib/libc/string/bcopy.c | 139 ++ src/lib/libc/string/bm.3 | 114 ++ src/lib/libc/string/bm.c | 220 +++ src/lib/libc/string/bstring.3 | 110 ++ src/lib/libc/string/bzero.3 | 68 + src/lib/libc/string/bzero.c | 53 + src/lib/libc/string/ffs.3 | 63 + src/lib/libc/string/ffs.c | 55 + src/lib/libc/string/index.3 | 83 + src/lib/libc/string/index.c | 56 + src/lib/libc/string/memccpy.3 | 73 + src/lib/libc/string/memccpy.c | 59 + src/lib/libc/string/memchr.3 | 82 + src/lib/libc/string/memchr.c | 59 + src/lib/libc/string/memcmp.3 | 83 + src/lib/libc/string/memcmp.c | 61 + src/lib/libc/string/memcpy.3 | 84 + src/lib/libc/string/memmove.3 | 76 + src/lib/libc/string/memset.3 | 67 + src/lib/libc/string/memset.c | 59 + src/lib/libc/string/rindex.3 | 81 + src/lib/libc/string/rindex.c | 58 + src/lib/libc/string/strcasecmp.3 | 88 + src/lib/libc/string/strcasecmp.c | 115 ++ src/lib/libc/string/strcat.3 | 94 + src/lib/libc/string/strcat.c | 51 + src/lib/libc/string/strchr.3 | 88 + src/lib/libc/string/strcmp.3 | 94 + src/lib/libc/string/strcmp.c | 55 + src/lib/libc/string/strcoll.3 | 75 + src/lib/libc/string/strcoll.c | 53 + src/lib/libc/string/strcpy.3 | 122 ++ src/lib/libc/string/strcpy.c | 50 + src/lib/libc/string/strcspn.3 | 85 + src/lib/libc/string/strcspn.c | 68 + src/lib/libc/string/strdup.3 | 65 + src/lib/libc/string/strdup.c | 54 + src/lib/libc/string/strerror.3 | 66 + src/lib/libc/string/strerror.c | 56 + src/lib/libc/string/strftime.3 | 202 ++ src/lib/libc/string/strftime.c | 317 ++++ src/lib/libc/string/string.3 | 156 ++ src/lib/libc/string/strlen.3 | 71 + src/lib/libc/string/strlen.c | 50 + src/lib/libc/string/strmode.3 | 149 ++ src/lib/libc/string/strmode.c | 148 ++ src/lib/libc/string/strncat.c | 68 + src/lib/libc/string/strncmp.c | 56 + src/lib/libc/string/strncpy.c | 68 + src/lib/libc/string/strpbrk.3 | 80 + src/lib/libc/string/strpbrk.c | 57 + src/lib/libc/string/strrchr.3 | 91 + src/lib/libc/string/strsep.3 | 92 + src/lib/libc/string/strsep.c | 79 + src/lib/libc/string/strsignal.3 | 61 + src/lib/libc/string/strsignal.c | 50 + src/lib/libc/string/strspn.3 | 80 + src/lib/libc/string/strspn.c | 61 + src/lib/libc/string/strstr.3 | 89 + src/lib/libc/string/strstr.c | 65 + src/lib/libc/string/strtok.3 | 112 ++ src/lib/libc/string/strtok.c | 90 + src/lib/libc/string/strxfrm.3 | 69 + src/lib/libc/string/strxfrm.c | 74 + src/lib/libc/string/swab.3 | 66 + src/lib/libc/string/swab.c | 66 + src/lib/libutil/Makefile | 8 + src/lib/libutil/login.c | 66 + src/lib/libutil/login_tty.c | 58 + src/lib/libutil/logout.c | 73 + src/lib/libutil/logwtmp.c | 70 + src/lib/libutil/pty.c | 135 ++ src/lib/libutil/shlib_version | 2 + 357 files changed, 38704 insertions(+) create mode 100644 src/etc/MAKEDEV.local create mode 100644 src/etc/Makefile create mode 100644 src/etc/aliases create mode 100644 src/etc/bootptab create mode 100644 src/etc/changelist create mode 100644 src/etc/crontab create mode 100644 src/etc/csh.cshrc create mode 100644 src/etc/csh.login create mode 100644 src/etc/csh.logout create mode 100644 src/etc/daily create mode 100644 src/etc/dm.conf create mode 100644 src/etc/etc.alpha/MAKEDEV create mode 100644 src/etc/etc.alpha/disktab create mode 100644 src/etc/etc.alpha/fstab.sd create mode 100644 src/etc/etc.alpha/ttys create mode 100644 src/etc/etc.amiga/MAKEDEV create mode 100644 src/etc/etc.amiga/Makefile.inc create mode 100644 src/etc/etc.amiga/disktab create mode 100644 src/etc/etc.amiga/fstab.tmp create mode 100644 src/etc/etc.amiga/ttys create mode 100644 src/etc/etc.atari/MAKEDEV create mode 100644 src/etc/etc.atari/Makefile.inc create mode 100644 src/etc/etc.atari/disktab create mode 100644 src/etc/etc.atari/fstab.tmp create mode 100644 src/etc/etc.atari/ttys create mode 100644 src/etc/etc.hp300/MAKEDEV create mode 100644 src/etc/etc.hp300/Makefile.inc create mode 100644 src/etc/etc.hp300/disktab create mode 100644 src/etc/etc.hp300/fstab.rd create mode 100644 src/etc/etc.hp300/fstab.sd create mode 100644 src/etc/etc.hp300/ttys create mode 100644 src/etc/etc.i386/MAKEDEV create mode 100644 src/etc/etc.i386/Makefile.inc create mode 100644 src/etc/etc.i386/Makefile.kc create mode 100644 src/etc/etc.i386/disktab create mode 100644 src/etc/etc.i386/files.kc/copy_kernel create mode 100644 src/etc/etc.i386/files.kc/dot.profile create mode 100644 src/etc/etc.i386/files.kc/list create mode 100644 src/etc/etc.i386/fstab.wd create mode 100644 src/etc/etc.i386/ttys create mode 100644 src/etc/etc.mac68k/MAKEDEV create mode 100644 src/etc/etc.mac68k/disktab create mode 100644 src/etc/etc.mac68k/fstab.sd create mode 100644 src/etc/etc.mac68k/ttys create mode 100644 src/etc/etc.pc532/MAKEDEV create mode 100644 src/etc/etc.pc532/disktab create mode 100644 src/etc/etc.pc532/fstab.sd create mode 100644 src/etc/etc.pc532/ttys create mode 100644 src/etc/etc.pmax/MAKEDEV create mode 100644 src/etc/etc.pmax/disktab create mode 100644 src/etc/etc.pmax/fstab.rz create mode 100644 src/etc/etc.pmax/ttys create mode 100644 src/etc/etc.sparc/MAKEDEV create mode 100644 src/etc/etc.sparc/Makefile.inc create mode 100644 src/etc/etc.sparc/README create mode 100644 src/etc/etc.sparc/disktab create mode 100644 src/etc/etc.sparc/fstab.sd create mode 100644 src/etc/etc.sparc/install.sh create mode 100644 src/etc/etc.sparc/ttys create mode 100644 src/etc/etc.sun3/MAKEDEV create mode 100644 src/etc/etc.sun3/Makefile.inc create mode 100644 src/etc/etc.sun3/README create mode 100644 src/etc/etc.sun3/disktab create mode 100644 src/etc/etc.sun3/fstab.nfs create mode 100644 src/etc/etc.sun3/fstab.sd0 create mode 100644 src/etc/etc.sun3/install.sh create mode 100644 src/etc/etc.sun3/ttys create mode 100644 src/etc/etc.svr4/SVR4_MAKEDEV create mode 100644 src/etc/etc.svr4/netconfig create mode 100644 src/etc/etc.svr4/nsswitch.conf create mode 100644 src/etc/etc.vax/MAKEDEV create mode 100644 src/etc/etc.vax/disktab create mode 100644 src/etc/etc.vax/fstab.ra create mode 100644 src/etc/etc.vax/pcs750.bin.uu create mode 100644 src/etc/etc.vax/ttys create mode 100644 src/etc/ftpchroot create mode 100644 src/etc/ftpusers create mode 100644 src/etc/gettytab create mode 100644 src/etc/group create mode 100644 src/etc/hosts create mode 100644 src/etc/hosts.equiv create mode 100644 src/etc/hosts.lpd create mode 100644 src/etc/inetd.conf create mode 100644 src/etc/man.conf create mode 100644 src/etc/master.passwd create mode 100644 src/etc/monthly create mode 100644 src/etc/motd create mode 100644 src/etc/mrouted.conf create mode 100644 src/etc/mtree/4.4BSD.dist create mode 100644 src/etc/mtree/4.4BSD.root create mode 100644 src/etc/mtree/4.4BSD.usr create mode 100644 src/etc/mtree/4.4BSD.var create mode 100644 src/etc/mtree/special create mode 100644 src/etc/myname create mode 100644 src/etc/namedb/localhost.rev create mode 100644 src/etc/namedb/named.boot create mode 100644 src/etc/namedb/root.cache create mode 100644 src/etc/netstart create mode 100644 src/etc/networks create mode 100644 src/etc/newsyslog.conf create mode 100644 src/etc/phones create mode 100644 src/etc/printcap create mode 100644 src/etc/protocols create mode 100644 src/etc/rbootd.conf create mode 100644 src/etc/rc create mode 100644 src/etc/rc.local create mode 100644 src/etc/remote create mode 100644 src/etc/root/dot.cshrc create mode 100644 src/etc/root/dot.klogin create mode 100644 src/etc/root/dot.login create mode 100644 src/etc/root/dot.profile create mode 100644 src/etc/rpc create mode 100644 src/etc/security create mode 100644 src/etc/services create mode 100644 src/etc/shells create mode 100644 src/etc/syslog.conf create mode 100644 src/etc/weekly create mode 100644 src/include/Makefile create mode 100644 src/include/a.out.h create mode 100644 src/include/ar.h create mode 100644 src/include/arpa/ftp.h create mode 100644 src/include/arpa/inet.h create mode 100644 src/include/arpa/nameser.h create mode 100644 src/include/arpa/telnet.h create mode 100644 src/include/arpa/tftp.h create mode 100644 src/include/assert.h create mode 100644 src/include/bitstring.h create mode 100644 src/include/bm.h create mode 100644 src/include/ctype.h create mode 100644 src/include/db.h create mode 100644 src/include/dirent.h create mode 100644 src/include/disktab.h create mode 100644 src/include/dlfcn.h create mode 100644 src/include/err.h create mode 100644 src/include/fnmatch.h create mode 100644 src/include/fstab.h create mode 100644 src/include/fts.h create mode 100644 src/include/glob.h create mode 100644 src/include/grp.h create mode 100644 src/include/ieeefp.h create mode 100644 src/include/iso646.h create mode 100644 src/include/kvm.h create mode 100644 src/include/langinfo.h create mode 100644 src/include/limits.h create mode 100644 src/include/link.h create mode 100644 src/include/locale.h create mode 100644 src/include/malloc.h create mode 100644 src/include/math.h create mode 100644 src/include/memory.h create mode 100644 src/include/mpool.h create mode 100644 src/include/ndbm.h create mode 100644 src/include/netdb.h create mode 100644 src/include/netgroup.h create mode 100644 src/include/nl_types.h create mode 100644 src/include/nlist.h create mode 100644 src/include/paths.h create mode 100644 src/include/protocols/dumprestore.h create mode 100644 src/include/protocols/routed.h create mode 100644 src/include/protocols/rwhod.h create mode 100644 src/include/protocols/talkd.h create mode 100644 src/include/protocols/timed.h create mode 100644 src/include/pwd.h create mode 100644 src/include/ranlib.h create mode 100644 src/include/regex.h create mode 100644 src/include/regexp.h create mode 100644 src/include/resolv.h create mode 100644 src/include/rpc/auth.h create mode 100644 src/include/rpc/auth_unix.h create mode 100644 src/include/rpc/clnt.h create mode 100644 src/include/rpc/pmap_clnt.h create mode 100644 src/include/rpc/pmap_prot.h create mode 100644 src/include/rpc/pmap_rmt.h create mode 100644 src/include/rpc/rpc.h create mode 100644 src/include/rpc/rpc_msg.h create mode 100644 src/include/rpc/svc.h create mode 100644 src/include/rpc/svc_auth.h create mode 100644 src/include/rpc/types.h create mode 100644 src/include/rpc/xdr.h create mode 100644 src/include/rpcsvc/yp_prot.h create mode 100644 src/include/rpcsvc/ypclnt.h create mode 100644 src/include/search.h create mode 100644 src/include/setjmp.h create mode 100644 src/include/sgtty.h create mode 100644 src/include/signal.h create mode 100644 src/include/stab.h create mode 100644 src/include/stddef.h create mode 100644 src/include/stdio.h create mode 100644 src/include/stdlib.h create mode 100644 src/include/string.h create mode 100644 src/include/strings.h create mode 100644 src/include/struct.h create mode 100644 src/include/sysexits.h create mode 100644 src/include/time.h create mode 100644 src/include/ttyent.h create mode 100644 src/include/tzfile.h create mode 100644 src/include/unistd.h create mode 100644 src/include/utime.h create mode 100644 src/include/utmp.h create mode 100644 src/include/vis.h create mode 100644 src/lib/libc/stdlib/Makefile.inc create mode 100644 src/lib/libc/stdlib/_rand48.c create mode 100644 src/lib/libc/stdlib/a64l.c create mode 100644 src/lib/libc/stdlib/abort.3 create mode 100644 src/lib/libc/stdlib/abort.c create mode 100644 src/lib/libc/stdlib/abs.3 create mode 100644 src/lib/libc/stdlib/abs.c create mode 100644 src/lib/libc/stdlib/alloca.3 create mode 100644 src/lib/libc/stdlib/atexit.3 create mode 100644 src/lib/libc/stdlib/atexit.c create mode 100644 src/lib/libc/stdlib/atexit.h create mode 100644 src/lib/libc/stdlib/atof.3 create mode 100644 src/lib/libc/stdlib/atof.c create mode 100644 src/lib/libc/stdlib/atoi.3 create mode 100644 src/lib/libc/stdlib/atoi.c create mode 100644 src/lib/libc/stdlib/atol.3 create mode 100644 src/lib/libc/stdlib/atol.c create mode 100644 src/lib/libc/stdlib/bsearch.3 create mode 100644 src/lib/libc/stdlib/bsearch.c create mode 100644 src/lib/libc/stdlib/calloc.3 create mode 100644 src/lib/libc/stdlib/calloc.c create mode 100644 src/lib/libc/stdlib/div.3 create mode 100644 src/lib/libc/stdlib/div.c create mode 100644 src/lib/libc/stdlib/drand48.c create mode 100644 src/lib/libc/stdlib/erand48.c create mode 100644 src/lib/libc/stdlib/exit.3 create mode 100644 src/lib/libc/stdlib/exit.c create mode 100644 src/lib/libc/stdlib/free.3 create mode 100644 src/lib/libc/stdlib/getenv.3 create mode 100644 src/lib/libc/stdlib/getenv.c create mode 100644 src/lib/libc/stdlib/getopt.3 create mode 100644 src/lib/libc/stdlib/getopt.c create mode 100644 src/lib/libc/stdlib/heapsort.c create mode 100644 src/lib/libc/stdlib/jrand48.c create mode 100644 src/lib/libc/stdlib/l64a.c create mode 100644 src/lib/libc/stdlib/labs.3 create mode 100644 src/lib/libc/stdlib/labs.c create mode 100644 src/lib/libc/stdlib/lcong48.c create mode 100644 src/lib/libc/stdlib/ldiv.3 create mode 100644 src/lib/libc/stdlib/ldiv.c create mode 100644 src/lib/libc/stdlib/lrand48.c create mode 100644 src/lib/libc/stdlib/malloc.3 create mode 100644 src/lib/libc/stdlib/malloc.c create mode 100644 src/lib/libc/stdlib/memory.3 create mode 100644 src/lib/libc/stdlib/merge.c create mode 100644 src/lib/libc/stdlib/mrand48.c create mode 100644 src/lib/libc/stdlib/multibyte.c create mode 100644 src/lib/libc/stdlib/nrand48.c create mode 100644 src/lib/libc/stdlib/putenv.c create mode 100644 src/lib/libc/stdlib/qabs.3 create mode 100644 src/lib/libc/stdlib/qabs.c create mode 100644 src/lib/libc/stdlib/qdiv.3 create mode 100644 src/lib/libc/stdlib/qdiv.c create mode 100644 src/lib/libc/stdlib/qsort.3 create mode 100644 src/lib/libc/stdlib/qsort.c create mode 100644 src/lib/libc/stdlib/radixsort.3 create mode 100644 src/lib/libc/stdlib/radixsort.c create mode 100644 src/lib/libc/stdlib/rand.3 create mode 100644 src/lib/libc/stdlib/rand.c create mode 100644 src/lib/libc/stdlib/rand48.3 create mode 100644 src/lib/libc/stdlib/rand48.h create mode 100644 src/lib/libc/stdlib/random.3 create mode 100644 src/lib/libc/stdlib/random.c create mode 100644 src/lib/libc/stdlib/realloc.3 create mode 100644 src/lib/libc/stdlib/realpath.3 create mode 100644 src/lib/libc/stdlib/realpath.c create mode 100644 src/lib/libc/stdlib/seed48.c create mode 100644 src/lib/libc/stdlib/setenv.c create mode 100644 src/lib/libc/stdlib/srand48.c create mode 100644 src/lib/libc/stdlib/strtod.3 create mode 100644 src/lib/libc/stdlib/strtod.c create mode 100644 src/lib/libc/stdlib/strtol.3 create mode 100644 src/lib/libc/stdlib/strtol.c create mode 100644 src/lib/libc/stdlib/strtoq.c create mode 100644 src/lib/libc/stdlib/strtoul.3 create mode 100644 src/lib/libc/stdlib/strtoul.c create mode 100644 src/lib/libc/stdlib/strtouq.c create mode 100644 src/lib/libc/stdlib/system.3 create mode 100644 src/lib/libc/stdlib/system.c create mode 100644 src/lib/libc/string/Makefile.inc create mode 100644 src/lib/libc/string/__strerror.c create mode 100644 src/lib/libc/string/__strsignal.c create mode 100644 src/lib/libc/string/bcmp.3 create mode 100644 src/lib/libc/string/bcmp.c create mode 100644 src/lib/libc/string/bcopy.3 create mode 100644 src/lib/libc/string/bcopy.c create mode 100644 src/lib/libc/string/bm.3 create mode 100644 src/lib/libc/string/bm.c create mode 100644 src/lib/libc/string/bstring.3 create mode 100644 src/lib/libc/string/bzero.3 create mode 100644 src/lib/libc/string/bzero.c create mode 100644 src/lib/libc/string/ffs.3 create mode 100644 src/lib/libc/string/ffs.c create mode 100644 src/lib/libc/string/index.3 create mode 100644 src/lib/libc/string/index.c create mode 100644 src/lib/libc/string/memccpy.3 create mode 100644 src/lib/libc/string/memccpy.c create mode 100644 src/lib/libc/string/memchr.3 create mode 100644 src/lib/libc/string/memchr.c create mode 100644 src/lib/libc/string/memcmp.3 create mode 100644 src/lib/libc/string/memcmp.c create mode 100644 src/lib/libc/string/memcpy.3 create mode 100644 src/lib/libc/string/memmove.3 create mode 100644 src/lib/libc/string/memset.3 create mode 100644 src/lib/libc/string/memset.c create mode 100644 src/lib/libc/string/rindex.3 create mode 100644 src/lib/libc/string/rindex.c create mode 100644 src/lib/libc/string/strcasecmp.3 create mode 100644 src/lib/libc/string/strcasecmp.c create mode 100644 src/lib/libc/string/strcat.3 create mode 100644 src/lib/libc/string/strcat.c create mode 100644 src/lib/libc/string/strchr.3 create mode 100644 src/lib/libc/string/strcmp.3 create mode 100644 src/lib/libc/string/strcmp.c create mode 100644 src/lib/libc/string/strcoll.3 create mode 100644 src/lib/libc/string/strcoll.c create mode 100644 src/lib/libc/string/strcpy.3 create mode 100644 src/lib/libc/string/strcpy.c create mode 100644 src/lib/libc/string/strcspn.3 create mode 100644 src/lib/libc/string/strcspn.c create mode 100644 src/lib/libc/string/strdup.3 create mode 100644 src/lib/libc/string/strdup.c create mode 100644 src/lib/libc/string/strerror.3 create mode 100644 src/lib/libc/string/strerror.c create mode 100644 src/lib/libc/string/strftime.3 create mode 100644 src/lib/libc/string/strftime.c create mode 100644 src/lib/libc/string/string.3 create mode 100644 src/lib/libc/string/strlen.3 create mode 100644 src/lib/libc/string/strlen.c create mode 100644 src/lib/libc/string/strmode.3 create mode 100644 src/lib/libc/string/strmode.c create mode 100644 src/lib/libc/string/strncat.c create mode 100644 src/lib/libc/string/strncmp.c create mode 100644 src/lib/libc/string/strncpy.c create mode 100644 src/lib/libc/string/strpbrk.3 create mode 100644 src/lib/libc/string/strpbrk.c create mode 100644 src/lib/libc/string/strrchr.3 create mode 100644 src/lib/libc/string/strsep.3 create mode 100644 src/lib/libc/string/strsep.c create mode 100644 src/lib/libc/string/strsignal.3 create mode 100644 src/lib/libc/string/strsignal.c create mode 100644 src/lib/libc/string/strspn.3 create mode 100644 src/lib/libc/string/strspn.c create mode 100644 src/lib/libc/string/strstr.3 create mode 100644 src/lib/libc/string/strstr.c create mode 100644 src/lib/libc/string/strtok.3 create mode 100644 src/lib/libc/string/strtok.c create mode 100644 src/lib/libc/string/strxfrm.3 create mode 100644 src/lib/libc/string/strxfrm.c create mode 100644 src/lib/libc/string/swab.3 create mode 100644 src/lib/libc/string/swab.c create mode 100644 src/lib/libutil/Makefile create mode 100644 src/lib/libutil/login.c create mode 100644 src/lib/libutil/login_tty.c create mode 100644 src/lib/libutil/logout.c create mode 100644 src/lib/libutil/logwtmp.c create mode 100644 src/lib/libutil/pty.c create mode 100644 src/lib/libutil/shlib_version diff --git a/src/etc/MAKEDEV.local b/src/etc/MAKEDEV.local new file mode 100644 index 00000000..3e06d0a7 --- /dev/null +++ b/src/etc/MAKEDEV.local @@ -0,0 +1,49 @@ +#!/bin/sh - +# +# Copyright (c) 1991 The Regents of the University of California. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the University of +# California, Berkeley and its contributors. +# 4. Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# @(#)MAKEDEV.local 5.1 (Berkeley) 3/22/91 +# + +# Local device MAKEDEV script. + +PATH=/sbin:/bin:/usr/bin +umask 77 +for i +do +case $i in + +*) + echo 'MAKEDEV.local: no such device.' + ;; +esac +done diff --git a/src/etc/Makefile b/src/etc/Makefile new file mode 100644 index 00000000..b893fc52 --- /dev/null +++ b/src/etc/Makefile @@ -0,0 +1,147 @@ +# from: @(#)Makefile 5.11 (Berkeley) 5/21/91 +# $Id: Makefile,v 1.1.1.1 1995/10/18 08:37:55 deraadt Exp $ + +TZDIR= /usr/share/zoneinfo +LOCALTIME= US/Pacific + +NOOBJ= oobj + +.if exists(etc.${MACHINE}/Makefile.inc) +.include "etc.${MACHINE}/Makefile.inc" +.endif + +# disktab may be wrong -- hcx9 is a tahoe, but gets its own. +# -rw-r--r-- +BINOWN= root +BINGRP= wheel +BIN1= aliases bootptab changelist csh.cshrc csh.login csh.logout daily \ + dm.conf ftpusers ftpchroot gettytab group hosts hosts.equiv hosts.lpd \ + inetd.conf man.conf monthly motd myname netstart newsyslog.conf \ + phones printcap protocols rc rc.local remote rpc security services \ + shells syslog.conf weekly etc.${MACHINE}/ttys etc.${MACHINE}/disktab + +# -rw-rw-r-- +BIN2= motd + +NAMEDB= localhost.rev named.boot root.cache +PCS= pcs750.bin +WCS1= wcs fppwcs poc poc1 poc2 fppoc +WCS2= fpevent fppwcs fppwcs_dual hdcwcs load_diags start_fpp wcs wcs_dual + +all clean cleandir depend etc install lint: + +.ifndef DESTDIR +distribution distrib-dirs snapshot: + @echo setenv DESTDIR before doing that! + @false +.else +distribution: distrib-dirs + (cd ..; ${MAKE} install) + install -c -o ${BINOWN} -g ${BINGRP} -m 644 ${BIN1} ${DESTDIR}/etc + install -c -o ${BINOWN} -g ${BINGRP} -m 664 ${BIN2} ${DESTDIR}/etc + install -c -o root -g wheel -m 600 crontab ${DESTDIR}/var/cron/tabs/root + install -c -o root -g wheel -m 600 master.passwd ${DESTDIR}/etc + chroot ${DESTDIR}/ pwd_mkdb -p /etc/master.passwd + install -c -o ${BINOWN} -g ${BINGRP} -m 555 \ + MAKEDEV.local etc.${MACHINE}/MAKEDEV ${DESTDIR}/dev + (cd root; \ + install -c -o root -g wheel -m 644 dot.cshrc \ + ${DESTDIR}/root/.cshrc; \ + install -c -o root -g wheel -m 644 dot.klogin \ + ${DESTDIR}/root/.klogin; \ + install -c -o root -g wheel -m 644 dot.login \ + ${DESTDIR}/root/.login; \ + install -c -o root -g wheel -m 644 dot.profile \ + ${DESTDIR}/root/.profile; \ + rm -f ${DESTDIR}/.cshrc ${DESTDIR}/.profile; \ + ln ${DESTDIR}/root/.cshrc ${DESTDIR}/.cshrc; \ + ln ${DESTDIR}/root/.profile ${DESTDIR}/.profile) + (cd mtree; \ + install -c -o root -g wheel -m 600 special \ + ${DESTDIR}/etc/mtree; \ + install -c -o root -g wheel -m 444 4.4BSD.dist \ + ${DESTDIR}/etc/mtree) + cd namedb; install -c -o ${BINOWN} -g ${BINGRP} -m 644 ${NAMEDB} \ + ${DESTDIR}/etc/namedb + /bin/rm -f ${DESTDIR}/etc/localtime + ln -s ${TZDIR}/${LOCALTIME} ${DESTDIR}/etc/localtime + /bin/rm -f ${DESTDIR}/etc/rmt + ln -s /usr/sbin/rmt ${DESTDIR}/etc/rmt + install -c -o ${BINOWN} -g operator -m 664 /dev/null \ + ${DESTDIR}/etc/dumpdates + install -c -o ${BINOWN} -g operator -m 644 /dev/null \ + ${DESTDIR}/etc/skeykeys + install -c -o root -g wheel -m 600 /dev/null \ + ${DESTDIR}/var/cron/log + install -c -o nobody -g ${BINGRP} -m 664 /dev/null \ + ${DESTDIR}/var/db/locate.database + install -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ + ${DESTDIR}/var/log/lastlog + install -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ + ${DESTDIR}/var/log/lpd-errs + install -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ + ${DESTDIR}/var/log/maillog + install -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ + ${DESTDIR}/var/log/messages + install -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ + ${DESTDIR}/var/log/wtmp + install -c -o daemon -g staff -m 664 /dev/null \ + ${DESTDIR}/var/msgs/bounds + install -c -o ${BINOWN} -g ${BINGRP} -m 664 /dev/null \ + ${DESTDIR}/var/run/utmp + (cd etc.${MACHINE}; install -c -o ${BINOWN} -g ${BINGRP} -m 444 \ + fstab.* ${DESTDIR}/etc) + (cd ${DESTDIR}/dev; ./MAKEDEV all) +.if ${MACHINE} == "tahoe" + (cd etc.tahoe; install -c -o ${BINOWN} -g ${BINGRP} -m 444 ${WCS1} \ + ${DESTDIR}/) +.endif +.if ${MACHINE} == "vax" + (cd etc.vax; install -c -o ${BINOWN} -g ${BINGRP} -m 444 ${PCS} \ + ${DESTDIR}/) +.endif + (cd ../usr.sbin/sendmail/cf/cf; ${MAKE} distribution) + +hcx9-distribution: + (cd etc.tahoe; install -c -o ${BINOWN} -g ${BINGRP} -m 444 ${WCS2} \ + ${DESTDIR}/) + +distrib-dirs: + install -d -o root -g wheel -m 755 ${DESTDIR} + -mtree -def mtree/4.4BSD.dist -p ${DESTDIR}/ -u + cd ${DESTDIR}; rm -f sys; ln -s usr/src/sys sys + +snapshot: distribution snap_pre snap_tar snap_md + cd ${DESTDIR}/snapshot && cksum * > CKSUMS + +snap_pre: + /bin/rm -rf ${DESTDIR}/snapshot + install -d -o root -g wheel -m 755 ${DESTDIR}/snapshot + +snap_tar: + cd ${DESTDIR} && tar cf - bin | gzip -9 > snapshot/bin.tar.gz + cd ${DESTDIR} && tar cf - dev | gzip -9 > snapshot/dev.tar.gz + cd ${DESTDIR} && tar cf - .profile .cshrc etc mnt root sys tmp | \ + gzip -9 > snapshot/etc.tar.gz + cd ${DESTDIR} && tar cf - sbin | gzip -9 > snapshot/sbin.tar.gz + cd ${DESTDIR} && tar cf - usr/bin | gzip -9 > snapshot/usr.bin.tar.gz + cd ${DESTDIR} && tar cf - usr/games | gzip -9 > \ + snapshot/usr.games.tar.gz + cd ${DESTDIR} && tar cf - usr/include | gzip -9 > \ + snapshot/usr.include.tar.gz + cd ${DESTDIR} && tar cf - usr/lib | gzip -9 > snapshot/usr.lib.tar.gz + cd ${DESTDIR} && tar cf - usr/libexec | gzip -9 > \ + snapshot/usr.libexec.tar.gz + cd ${DESTDIR} && tar cf - usr/mdec usr/local usr/src usr/obj | \ + gzip -9 > snapshot/usr.misc.tar.gz + cd ${DESTDIR} && tar cf - usr/sbin | gzip -9 > snapshot/usr.sbin.tar.gz + cd ${DESTDIR} && tar cf - usr/share | gzip -9 > \ + snapshot/usr.share.tar.gz + cd ${DESTDIR} && tar cf - var | gzip -9 > snapshot/var.tar.gz + +snap_md: +# nothing here -- look in the machine-dependent Makefile.inc + +.endif # DESTDIR check + +.include <bsd.prog.mk> diff --git a/src/etc/aliases b/src/etc/aliases new file mode 100644 index 00000000..b77e0ac3 --- /dev/null +++ b/src/etc/aliases @@ -0,0 +1,33 @@ +# +# @(#)aliases 5.3 (Berkeley) 5/24/90 +# +# Aliases in this file will NOT be expanded in the header from +# Mail, but WILL be visible over networks or from /bin/mail. +# +# >>>>>>>>>> The program "newaliases" must be run after +# >> NOTE >> this file is updated for any changes to +# >>>>>>>>>> show through to sendmail. +# + +# Basic system aliases -- these MUST be present +MAILER-DAEMON: postmaster +postmaster: root + +# General redirections for pseudo accounts +bin: root +daemon: root +games: root +ingres: root +nobody: root +system: root +toor: root +uucp: root + +# Well-known aliases -- these should be filled in! +# root: +# manager: +# dumper: +# operator: + +# uncomment this for msgs: +# msgs: "|/usr/bin/msgs -s" diff --git a/src/etc/bootptab b/src/etc/bootptab new file mode 100644 index 00000000..f1a98ab9 --- /dev/null +++ b/src/etc/bootptab @@ -0,0 +1,69 @@ +# /etc/bootptab: database for bootp server (/etc/bootpd) +# Last update Mon 11/7/88 18:03 +# Blank lines and lines beginning with '#' are ignored. +# +# Legend: +# +# first field -- hostname +# (may be full domain name and probably should be) +# +# hd -- home directory +# bf -- bootfile +# cs -- cookie servers +# df -- dumpfile +# dn -- domain name +# ds -- domain name servers +# gw -- gateways +# ha -- hardware address +# ht -- hardware type +# im -- impress servers +# ip -- host IP address +# lg -- log servers +# lp -- LPR servers +# ns -- IEN-116 name servers +# rl -- resource location protocol servers +# rp -- root path +# sm -- subnet mask +# sw -- swap server +# tc -- template host (points to similar host entry) +# to -- time offset (seconds) +# ts -- time servers + +# +# Be careful about including backslashes where they're needed. Weird (bad) +# things can happen when a backslash is omitted where one is intended. +# + + +# First, we define a global entry which specifies the stuff every host uses. + +global.dummy:\ + :sm=255.255.255.0:\ + :hd=/home/nfsclient:bf=null:\ + :ds=128.32.149.141:\ + :ns=0x80020b4d 0x80020ffd:\ + :ts=0x80020b4d 0x80020ffd:\ + :to=18000: + +# Next, we can define different master entries for each subnet. . . + +#subnet13.dummy:\ +# :tc=global.dummy:gw=128.2.13.1: +# +# +# We should be able to use as many levels of indirection as desired. Use +# your imagination. . . +# + + +# Individual entries (could also have different servers for some/all of these +# hosts, but we don't really use this feature at CMU): + +#carnegie:tc=subnet13.dummy:ht=ieee802:ha=7FF8100000AF:ip=128.2.11.1: +#baldwin:tc=subnet19.dummy:ht=ethernet:ha=0800200159C3:ip=128.2.11.10: + + +#example nfs diskless client + +#timesink:hd=/home/nfsclient/timesink:\ +# tc=subnet149.dummy:ht=ethernet:ha=0800200168A7:ip=128.32.149.20: diff --git a/src/etc/changelist b/src/etc/changelist new file mode 100644 index 00000000..8092cee5 --- /dev/null +++ b/src/etc/changelist @@ -0,0 +1,48 @@ +# from: @(#)changelist 8.1 (Berkeley) 6/9/93 +# $Id: changelist,v 1.1.1.1 1995/10/18 08:37:56 deraadt Exp $ +# +# List of files which the security script backs up and checks +# for modifications. + +/etc/Distfile +/etc/aliases +/etc/changelist +/etc/crontab +/etc/csh.cshrc +/etc/csh.login +/etc/daily +/etc/distfile +/etc/exports +/etc/fstab +/etc/ftpusers +/etc/group +/etc/hosts.equiv +/etc/mail.rc +/etc/master.passwd +/etc/monthly +/etc/named.boot +/etc/netstart +/etc/networks +/etc/nfsstart +/etc/passwd +/etc/printcap +/etc/protocols +/etc/rc +/etc/rc.local +/etc/remote +/etc/security +/etc/sendmail.cf +/etc/sendmail.cw +/etc/services +/etc/shells +/etc/slip.hosts +/etc/slip.login +/etc/start-amd +/etc/syslog.conf +/etc/ttys +/etc/weekly +/root/.cshrc +/root/.klogin +/root/.login +/root/.profile +/root/.rhosts diff --git a/src/etc/crontab b/src/etc/crontab new file mode 100644 index 00000000..dc4e4cfe --- /dev/null +++ b/src/etc/crontab @@ -0,0 +1,18 @@ +# /var/cron/tabs/root - root's crontab for NetBSD +# $Id: crontab,v 1.1.1.1 1995/10/18 08:37:56 deraadt Exp $ +# +SHELL=/bin/sh +PATH=/etc:/bin:/sbin:/usr/bin:/usr/sbin +HOME=/var/log +# +#minute hour mday month wday command +# +0-59/10 * * * * /usr/libexec/atrun +# +# rotate log files every hour, if necessary +0 * * * * /usr/bin/newsyslog +# +# do daily/weekly/monthly maintenance +0 2 * * * /bin/sh /etc/daily 2>&1 | tee /var/log/daily.out | mail -s "daily output" root +30 3 * * 6 /bin/sh /etc/weekly 2>&1 | tee /var/log/weekly.out | mail -s "weekly output" root +30 5 1 * * /bin/sh /etc/monthly 2>&1 | tee /var/log/monthly.out | mail -s "monthly output" root diff --git a/src/etc/csh.cshrc b/src/etc/csh.cshrc new file mode 100644 index 00000000..4a3bf3ff --- /dev/null +++ b/src/etc/csh.cshrc @@ -0,0 +1 @@ +# System-wide .cshrc file for csh(1). diff --git a/src/etc/csh.login b/src/etc/csh.login new file mode 100644 index 00000000..0b573ff5 --- /dev/null +++ b/src/etc/csh.login @@ -0,0 +1 @@ +# System-wide .login file for csh(1). diff --git a/src/etc/csh.logout b/src/etc/csh.logout new file mode 100644 index 00000000..f8601c07 --- /dev/null +++ b/src/etc/csh.logout @@ -0,0 +1 @@ +# System-wide .logout file for csh(1). diff --git a/src/etc/daily b/src/etc/daily new file mode 100644 index 00000000..b92916a5 --- /dev/null +++ b/src/etc/daily @@ -0,0 +1,128 @@ +#!/bin/sh - +# +# @(#)daily 5.12 (Berkeley) 5/24/91 +# +PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local +host=`hostname -s` +echo "Subject: $host daily run output" + +echo "" +echo "Removing scratch and junk files:" +if [ -d /tmp -a ! -h /tmp ]; then + cd /tmp && { + find . -type f -atime +3 -exec rm -f -- {} \; + find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ + >/dev/null 2>&1; } +fi + +if [ -d /var/tmp -a ! -h /var/tmp ]; then + cd /var/tmp && { + find . ! -name . -atime +7 -exec rm -f -- {} \; + find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ + >/dev/null 2>&1; } +fi + +if [ -d /scratch -a ! -h /scratch ]; then + cd /scratch && { + find . ! -name . -atime +1 -exec rm -f -- {} \; + find . ! -name . -type d -mtime +1 -exec rmdir -- {} \; \ + >/dev/null 2>&1; } +fi + +# XXX should go away/be replaced by nvi version +if [ -d /var/preserve -a ! -h /var/preserve ]; then + cd /var/preserve && { + find . ! -name . -mtime +7 -exec rm -f -- {} \; ; } +fi + +if [ -d /var/rwho -a ! -h /var/rwho ] ; then + cd /var/rwho && { + find . ! -name . -mtime +7 -exec rm -f -- {} \; ; } +fi + +cd /tmp +TMP=daily.$$ +find / \( ! -fstype local -o -fstype rdonly -o -fstype fdesc \ + -o -fstype kernfs -o -fstype procfs \) -a -prune -o \ + -name 'lost+found' -a -prune -o \ + -name '*.core' -a -print -o \ + \( -name '[#,]*' -o -name '.#*' -o -name a.out \ + -o -name '*.CKP' -o -name '.emacs_[0-9]*' \) \ + -a -atime +3 -exec rm -f -- {} \; -a -print > $TMP + +echo "" +echo "Possible core dumps:" +egrep '\.core' $TMP + +echo "" +echo "Deleted files:" +egrep -v '\.core' $TMP + +rm -f $TMP + +msgs -c + +if [ -f /etc/news.expire ]; then + /etc/news.expire +fi + +if [ -f /var/account/acct ]; then + echo "" ; + echo "Purging accounting records:" ; + mv /var/account/acct.2 /var/account/acct.3 ; + mv /var/account/acct.1 /var/account/acct.2 ; + mv /var/account/acct.0 /var/account/acct.1 ; + cp /var/account/acct /var/account/acct.0 ; + sa -sq ; +fi + +echo "" +echo "Running calendar:" +calendar -a + +# Rotation of mail log now handled automatically by cron and 'newsyslog' + +if [ -d /var/spool/uucp -a -f /etc/uuclean.daily ]; then + echo "" + echo "Cleaning up UUCP:" + echo /etc/uuclean.daily | su daemon +fi + +echo "" +echo "" +echo "Checking subsystem status:" +echo "" +echo "disks:" +df -k +echo "" +dump W +echo "" + + +echo "" +echo "mail:" +mailq + +if [ -d /var/spool/uucp ]; then + echo "" + echo "uucp:" + uustat -a +fi + +echo "" +echo "network:" +netstat -i +echo "" +ruptime + +echo "" +echo "Checking filesystems:" +fsck -n | grep -v '^\*\* Phase' + +echo "" +if [ -f /etc/Distfile ]; then + echo "Running rdist:" + rdist -f /etc/Distfile +fi + +sh /etc/security 2>&1 | mail -s "daily insecurity output" root diff --git a/src/etc/dm.conf b/src/etc/dm.conf new file mode 100644 index 00000000..48c24de5 --- /dev/null +++ b/src/etc/dm.conf @@ -0,0 +1,19 @@ +# +# Game Control File +# @(#)dm.conf 5.5 (Berkeley) 4/12/89 +# + +# TTYNAME +# badtty /dev/tty19 # news +# badtty /dev/tty20 # news/mail + +# DAY OF WEEK START STOP +# time Monday 7 16 # 7am to 4pm +# time Tuesday 7 16 +# time Wednesday 7 16 +# time Thursday 7 16 +# time Friday 7 16 + +# GAME MAX LOAD MAX USERS PRIORITY +# default must be the last entry for the ``game'' keyword +game default 5 * * diff --git a/src/etc/etc.alpha/MAKEDEV b/src/etc/etc.alpha/MAKEDEV new file mode 100644 index 00000000..9497fb25 --- /dev/null +++ b/src/etc/etc.alpha/MAKEDEV @@ -0,0 +1,260 @@ +#!/bin/sh - +# $NetBSD: MAKEDEV,v 1.5 1995/08/17 18:02:27 thorpej Exp $ +# +# Copyright (c) 1990 The Regents of the University of California. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the University of +# California, Berkeley and its contributors. +# 4. Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# Device "make" file. Valid arguments: +# all makes all known devices, including local devices. +# Tries to make the 'standard' number of each type. +# std standard devices +# local configuration specific devices +# +# Tapes: +# st* SCSI tape +# +# Disks: +# sd* SCSI disks +# cd* SCSI CD-ROM +# vnd* "file" pseudo-disks +# ccd* concatenated disk driver +# +# Terminals: +# ttyB? DEC 3000 ZS8530 ("scc") serial ports +# ttyC? AlphaStation NS16550 ("com") serial ports +# ttyE? Workstation console (framebuffer & keyboard) tty emulators +# +# Pseudo terminals: +# pty* set of 16 master and slave pseudo terminals +# +# Special purpose devices: +# ch* SCSI media changer +# bpf* packet filter +# fd file descriptors +# lkm loadable kernel modules interface +# tun* network tunnel driver + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +umask 77 +for i +do +case $i in + +all) + sh MAKEDEV std fd sd0 sd1 sd2 sd3 sd4 pty0 pty1 + sh MAKEDEV st0 st1 ch0 cd0 cd1 vnd0 vnd1 vnd2 vnd3 + sh MAKEDEV ccd0 ccd1 ccd2 ccd3 + sh MAKEDEV bpf0 bpf1 bpf2 bpf3 tun0 tun1 tun2 tun3 + sh MAKEDEV ttyB0 ttyB1 ttyC0 ttyC1 ttyE0 ttyE1 lkm local + ;; + +std) + rm -f console drum mem kmem null zero io tty klog stdin stdout stderr + mknod console c 0 0 + mknod drum c 3 0 ; chmod 640 drum ; chgrp kmem drum + mknod kmem c 2 1 ; chmod 640 kmem ; chgrp kmem kmem + mknod mem c 2 0 ; chmod 640 mem ; chgrp kmem mem + mknod null c 2 2 ; chmod 666 null + mknod zero c 2 12 ; chmod 666 zero + mknod tty c 1 0 ; chmod 666 tty + mknod klog c 6 0 ; chmod 600 klog + mknod stdin c 10 0 ; chmod 666 stdin + mknod stdout c 10 1 ; chmod 666 stdout + mknod stderr c 10 2 ; chmod 666 stderr + ;; + +fd) + rm -f fd/* + mkdir fd > /dev/null 2>&1 + (cd fd && eval `echo "" | awk ' BEGIN { \ + for (i = 0; i < 64; i++) \ + printf("mknod %d c 10 %d;", i, i)}'`) + chown -R bin.bin fd + chmod 555 fd + chmod 666 fd/* + ;; + +sd*|vnd*|ccd*) + umask 2 ; unit=`expr $i : '.*d\(.*\)'` + case $i in + sd*) name=sd; blk=8; chr=8;; + vnd*) name=vnd; blk=9; chr=9;; + ccd*) name=ccd; blk=7; chr=27;; + esac + rm -f $name$unit? r$name$unit? + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1` + mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4` + mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5` + mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6` + mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1` + mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4` + mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5` + mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6` + mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + umask 77 + ;; + +ttyB*|ttyC*|ttyE*) + type=`expr $i : 'tty\(.\).'` + unit=`expr $i : 'tty.\(.\)'` + case $type in + B) major=15; minor=`expr $unit \* 2` ;; + C) major=26; minor=$unit ;; + E) major=25; minor=$unit ;; + esac + rm -f tty$type$unit + mknod tty$type$unit c $major $minor + chown uucp.wheel tty$type$unit + ;; + +pty*) + class=`expr $i : 'pty\(.*\)'` + case $class in + 0) offset=0 name=p;; + 1) offset=16 name=q;; + 2) offset=32 name=r;; + 3) offset=48 name=s;; +# Note that telnetd, rlogind, and xterm (at least) only look at p-s. + 4) offset=64 name=t;; + *) echo bad unit for pty in: $i;; + esac + case $class in + 0|1|2|3|4) + umask 0 + eval `echo $offset $name | awk ' { b=$1; n=$2 } END { + for (i = 0; i < 16; i++) + printf("rm -f tty%s%x; mknod tty%s%x c 4 %d; \ + rm -f pty%s%x; mknod pty%s%x c 5 %d; ", \ + n, i, n, i, b+i, n, i, n, i, b+i); }'` + umask 77 + if [ $class = 1 ]; then + mv ttyqf ttyv0; mv ptyqf ptyv0 + fi + ;; + esac + ;; + +st*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + st*) name=st; blk=2; chr=12;; + esac + rm -f $name$unit n$name$unit e$name$unit en$name$unit \ + r$name$unit nr$name$unit er$name$unit enr$name$unit + mknod ${name}${unit} b $blk `expr $unit '*' 16 + 0` + mknod n${name}${unit} b $blk `expr $unit '*' 16 + 1` + mknod e${name}${unit} b $blk `expr $unit '*' 16 + 2` + mknod en${name}${unit} b $blk `expr $unit '*' 16 + 3` + mknod r${name}${unit} c $chr `expr $unit '*' 16 + 0` + mknod nr${name}${unit} c $chr `expr $unit '*' 16 + 1` + mknod er${name}${unit} c $chr `expr $unit '*' 16 + 2` + mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3` + chgrp operator ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + chmod 640 ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + umask 77 + ;; + +ch*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + ch*) name=ch; chr=14;; + esac + rm -f $name$unit + mknod ${name}${unit} c $chr `expr $unit '*' 16 + 0` + chgrp operator ${name}${unit} + chmod 640 ${name}${unit} + umask 77 + ;; + +cd*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + cd*) name=cd; blk=3; chr=13;; + esac + rm -f $name$unit? r$name$unit? + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 3` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 3` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + umask 77 + ;; + +bpf*) + unit=`expr $i : 'bpf\(.*\)'` + rm -f bpf$unit + mknod bpf$unit c 11 $unit + chmod 600 bpf$unit + chown root.wheel bpf$unit + ;; + +tun*) + unit=`expr $i : 'tun\(.*\)'` + rm -f tun$unit + mknod tun$unit c 7 $unit + chmod 600 tun$unit + chown root.wheel tun$unit + ;; + +lkm) + rm -f lkm + mknod lkm c 16 0 + chown root.kmem lkm + chmod 640 lkm + ;; + +local) + umask 0 + sh MAKEDEV.local + ;; + +*) + echo $i: unknown device + ;; + +esac +done diff --git a/src/etc/etc.alpha/disktab b/src/etc/etc.alpha/disktab new file mode 100644 index 00000000..191f1618 --- /dev/null +++ b/src/etc/etc.alpha/disktab @@ -0,0 +1,10 @@ +# $NetBSD: disktab,v 1.1 1995/02/23 05:59:32 cgd Exp $ + +# A DEC RZ25, configured so that all of the free partition IDs are at +# the end, etc. A good setup to make a disk image from... +rz25|RZ25|DEC RZ25 SCSI:\ + :ty=winchester:dt=SCSI:ns#62:nt#9:nc#1476:\ + :pa#139500:oa#0:ba#8192:fa#1024:ta=4.2BSD:\ + :pb#139500:ob#139500:tb=swap:\ + :pc#823608:oc#0:\ + :pd#544608:od#279000:bd#8192:fd#1024:td=4.2BSD: diff --git a/src/etc/etc.alpha/fstab.sd b/src/etc/etc.alpha/fstab.sd new file mode 100644 index 00000000..b8cf22cb --- /dev/null +++ b/src/etc/etc.alpha/fstab.sd @@ -0,0 +1,3 @@ +/dev/sd0a / ffs rw 1 1 +/dev/sd0b none swap sw 0 0 +/dev/sd0d /usr ffs rw 1 2 diff --git a/src/etc/etc.alpha/ttys b/src/etc/etc.alpha/ttys new file mode 100644 index 00000000..21e4a4ea --- /dev/null +++ b/src/etc/etc.alpha/ttys @@ -0,0 +1,56 @@ +# +# $NetBSD: ttys,v 1.4 1995/07/30 19:52:13 cgd Exp $ +# +# name getty type status comments + +# In normal operation, getty on 'console' pseudo-device is disabled, and is +# enabled for the correct 'real' device (e.g. one of the serial ports). + +# console pseudo-device +console "/usr/libexec/getty std.9600" unknown on secure + +# Workstation console (framebuffer) ttys +ttyE0 "/usr/libexec/getty std.9600" unknown off secure +ttyE1 "/usr/libexec/getty std.9600" unknown off secure + +# DEC 3000 Z8530 ("scc") serial ports +ttyB0 "/usr/libexec/getty std.9600" unknown off secure +ttyB1 "/usr/libexec/getty std.9600" unknown off secure + +# AlphaStation NS16550 ("com") serial ports +ttyC0 "/usr/libexec/getty std.9600" unknown off secure +ttyC1 "/usr/libexec/getty std.9600" unknown off secure + +# pseudo-ttys +ttyp0 none network +ttyp1 none network +ttyp2 none network +ttyp3 none network +ttyp4 none network +ttyp5 none network +ttyp6 none network +ttyp7 none network +ttyp8 none network +ttyp9 none network +ttypa none network +ttypb none network +ttypc none network +ttypd none network +ttype none network +ttypf none network +ttyq0 none network +ttyq1 none network +ttyq2 none network +ttyq3 none network +ttyq4 none network +ttyq5 none network +ttyq6 none network +ttyq7 none network +ttyq8 none network +ttyq9 none network +ttyqa none network +ttyqb none network +ttyqc none network +ttyqd none network +ttyqe none network +ttyqf none network diff --git a/src/etc/etc.amiga/MAKEDEV b/src/etc/etc.amiga/MAKEDEV new file mode 100644 index 00000000..62e9654a --- /dev/null +++ b/src/etc/etc.amiga/MAKEDEV @@ -0,0 +1,434 @@ +#!/bin/sh - +# +# $NetBSD: MAKEDEV,v 1.17 1995/10/09 02:23:07 chopps Exp $ +# +# Copyright (c) 1990 The Regents of the University of California. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the University of +# California, Berkeley and its contributors. +# 4. Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# from: +# hp300/MAKEDEV (1/15/94), from: +# @(#)MAKEDEV 5.5 (Berkeley) 5/28/91 +# +# Device "make" file. Valid arguments: +# all makes all known devices, including local devices, +# Tries to make the ``standard'' number of each. +# fd makes fd/* for the fdescfs. +# floppy devices needed for install floppies +# std standard devices +# local configuration specific devices +# +# Tapes: +# st* SCSI tapes +# +# Disks: +# fd* Floppy disks +# sd* SCSI disks, includes flopticals +# cd* SCSI cdrom discs +# vnd* "file" pseudo-disks +# ccd* concatenated disk driver +# +# Console ports: +# ttye* ite bitmapped consoles +# +# Pointing devices: +# mouse* Amiga mice +# +# Terminal ports: +# tty00 standard serial port. +# ttyA* mfc serial ports +# +# Pseudo terminals: +# pty* set of 16 master and slave pseudo terminals +# +# Printers: +# par* motherboard parallel port +# +# Special purpose devices: +# grf* custom chip (grf0), Retina Z2/Z3 (grf1/grf2), +# Cirrus boards (grf3), A2410 (grf4) video or +# CyberVision 64 (grf5) +# kbd Amiga keyboard +# view* generic interface to graphic displays. +# aconf autoconfig information (not yet) +# lkm loadable kernel modules interface. +# bpf* Berkeley Packet Filter +# tun* network tunnel driver + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +umask 77 +for i +do +case $i in +all) + sh MAKEDEV std fd st0 ttye0 ttye1 ttye2 ttye3 ttye4 mouse0 mouse1 + sh MAKEDEV tty00 ttyA0 ttyA1 grf0 grf1 grf2 grf3 grf4 grf5 + sh MAKEDEV kbd sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 vnd0 vnd1 vnd2 + sh MAKEDEV vnd3 vnd4 view00 view01 view02 view03 view04 view05 pty0 + sh MAKEDEV vnd5 vnd6 cd0 fd0 fd1 fd2 fd3 bpf0 bpf1 bpf2 bpf3 + sh MAKEDEV ccd0 ccd1 ccd2 ccd3 + sh MAKEDEV tun0 tun1 par0 lkm local + ;; + +floppy) + sh MAKEDEV std kbd pty0 tty00 ttyA0 ttyA1 tun0 tun1 + sh MAKEDEV grf0 grf1 grf2 grf3 grf4 grf5 ttye0 ttye1 ttye2 ttye3 ttye4 + sh MAKEDEV cd0 sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 st0 + sh MAKEDEV fd0 fd1 fd2 fd3 + ;; + +std) + rm -f console drum kmem mem reload null zero tty + rm -f klog stdin stdout stderr + mknod console c 0 0 + mknod drum c 3 0 ; chmod 640 drum ; chgrp kmem drum + mknod kmem c 2 1 ; chmod 640 kmem ; chgrp kmem kmem + mknod mem c 2 0 ; chmod 640 mem ; chgrp kmem mem + mknod reload c 2 20 ; chmod 640 mem ; chgrp kmem mem + mknod zero c 2 12 ; chmod 666 zero + mknod null c 2 2 ; chmod 666 null + mknod tty c 1 0 ; chmod 666 tty + mknod klog c 6 0 ; chmod 600 klog + mknod stdin c 21 0 ; chmod 666 stdin + mknod stdout c 21 1 ; chmod 666 stdout + mknod stderr c 21 2 ; chmod 666 stderr + ;; + +fd) + rm -f fd/* + mkdir fd > /dev/null 2>&1 + (cd fd && i=0 && while [ $i -lt 64 ]; do + mknod $i c 21 $i + i=$(($i+1)) + done) + chown -R bin.bin fd + chmod 555 fd + chmod 666 fd/* + ;; + +st*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + st*) name=st; blk=5; chr=20;; + esac + rm -f $name$unit n$name$unit e$name$unit en$name$unit \ + r$name$unit nr$name$unit er$name$unit enr$name$unit + case $unit in + 0|1|2|3|4|5|6) + mknod ${name}${unit} b $blk `expr $unit '*' 16 + 0` + mknod n${name}${unit} b $blk `expr $unit '*' 16 + 1` + mknod e${name}${unit} b $blk `expr $unit '*' 16 + 2` + mknod en${name}${unit} b $blk `expr $unit '*' 16 + 3` + mknod r${name}${unit} c $chr `expr $unit '*' 16 + 0` + mknod nr${name}${unit} c $chr `expr $unit '*' 16 + 1` + mknod er${name}${unit} c $chr `expr $unit '*' 16 + 2` + mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3` + chgrp operator ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + chmod 640 ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + ;; + *) + echo bad unit for tape in: $i + ;; + esac + umask 77 + ;; + +fd*) + umask 2 ; unit=`expr $i : '.*[^0-9]\([0-9]*\)'` + rm -f fd$unit? rfd$unit? + case $unit in + 0|1|2|3) + mknod fd${unit}a b 2 `expr $unit '*' 16` + mknod fd${unit}b b 2 `expr $unit '*' 16 + 1` + mknod rfd${unit}a c 18 `expr $unit '*' 16` + mknod rfd${unit}b c 18 `expr $unit '*' 16 + 1` + chgrp operator fd$unit? rfd$unit? + chmod 640 fd$unit? rfd$unit? + ;; + *) + echo bad unit for floppy disk in: $i + ;; + esac + umask 77 + ;; + +sd*|vnd*|ccd*) + umask 2 ; unit=`expr $i : '.*[^0-9]\([0-9]*\)'` + case $i in + sd*) name=sd; blk=4; chr=8;; + vnd*) name=vnd; blk=6; chr=19;; + ccd*) name=ccd; blk=8; chr=7;; + esac + rm -f $name$unit? r$name$unit? + case $unit in + 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15) + mknod ${name}${unit}c b $blk `expr $unit '*' 16 + 2` + mknod r${name}${unit}c c $chr `expr $unit '*' 16 + 2` + if [ $name != cd -a $name != vnd ] + then + mknod ${name}${unit}a b $blk `expr $unit '*' 16 + 0` + mknod ${name}${unit}b b $blk `expr $unit '*' 16 + 1` + mknod ${name}${unit}d b $blk `expr $unit '*' 16 + 3` + mknod ${name}${unit}e b $blk `expr $unit '*' 16 + 4` + mknod ${name}${unit}f b $blk `expr $unit '*' 16 + 5` + mknod ${name}${unit}g b $blk `expr $unit '*' 16 + 6` + mknod ${name}${unit}h b $blk `expr $unit '*' 16 + 7` + mknod ${name}${unit}i b $blk `expr $unit '*' 16 + 8` + mknod ${name}${unit}j b $blk `expr $unit '*' 16 + 9` + mknod ${name}${unit}k b $blk `expr $unit '*' 16 + 10` + mknod ${name}${unit}l b $blk `expr $unit '*' 16 + 11` + mknod ${name}${unit}m b $blk `expr $unit '*' 16 + 12` + mknod ${name}${unit}n b $blk `expr $unit '*' 16 + 13` + mknod ${name}${unit}o b $blk `expr $unit '*' 16 + 14` + mknod ${name}${unit}p b $blk `expr $unit '*' 16 + 15` + mknod r${name}${unit}a c $chr `expr $unit '*' 16 + 0` + mknod r${name}${unit}b c $chr `expr $unit '*' 16 + 1` + mknod r${name}${unit}d c $chr `expr $unit '*' 16 + 3` + mknod r${name}${unit}e c $chr `expr $unit '*' 16 + 4` + mknod r${name}${unit}f c $chr `expr $unit '*' 16 + 5` + mknod r${name}${unit}g c $chr `expr $unit '*' 16 + 6` + mknod r${name}${unit}h c $chr `expr $unit '*' 16 + 7` + mknod r${name}${unit}i c $chr `expr $unit '*' 16 + 8` + mknod r${name}${unit}j c $chr `expr $unit '*' 16 + 9` + mknod r${name}${unit}k c $chr `expr $unit '*' 16 + 10` + mknod r${name}${unit}l c $chr `expr $unit '*' 16 + 11` + mknod r${name}${unit}m c $chr `expr $unit '*' 16 + 12` + mknod r${name}${unit}n c $chr `expr $unit '*' 16 + 13` + mknod r${name}${unit}o c $chr `expr $unit '*' 16 + 14` + mknod r${name}${unit}p c $chr `expr $unit '*' 16 + 15` + fi + chgrp operator ${name}${unit}[a-p] r${name}${unit}[a-p] + chmod 640 ${name}${unit}[a-p] r${name}${unit}[a-p] + ;; + *) + echo bad unit for disk in: $i + ;; + esac + umask 77 + ;; + +cd*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + cd*) name=cd; blk=7; chr=9;; + esac + rm -f $name$unit? r$name$unit? + case $unit in + 0|1|2|3|4|5|6) + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + ;; + *) + echo bad unit for disk in: $i + ;; + esac + umask 77 + ;; + +tty0*|ttyA*) + type=`expr $i : 'tty\(.\).'` + unit=`expr $i : 'tty.\(.\)'` + rm -f ser${unit} + case $type in + 0) case $unit in + 0) + rm -f tty0${unit} ttym${unit} + mknod tty0${unit} c 12 0 + mknod ttym${unit} c 12 128 + chown uucp:wheel tty0${unit} ttym${unit} + ;; + *) + echo bad unit for tty0 in: $i + ;; + esac + ;; + A) case $unit in + 0|1) + rm -f ttyA${unit} ttyM${unit} + mknod ttyA${unit} c 17 $unit + mknod ttyM${unit} c 17 `expr 128 + $unit` + chown uucp:wheel ttyA${unit} ttyM${unit} + ;; + *) + echo bad unit for ttyA in: $i + ;; + esac + ;; + *) + echo bad type for tty in: $i + ;; + esac + ;; + +par*) + unit=`expr $i : 'par\(.*\)'` + rm -f par${unit} + case $unit in + 0) + mknod par${unit} c 11 ${unit} + ;; + *) + echo bad unit for par in: $i + ;; + esac + ;; + + +ttye*) + unit=`expr $i : 'ttye\(.*\)'` + rm -f ttye${unit} + rm -f ite* + case $unit in + 0|1|2|3|4) + mknod ttye${unit} c 13 ${unit} + ;; + *) + echo bad unit for ttye in: $i + ;; + esac + ;; + +grf*) + unit=`expr $i : 'grf\(.*\)'` + rm -f grf${unit} + case $unit in + 0|1|2|3|4|5) + mknod grf${unit} c 10 ${unit}; chmod 666 grf${unit} + ;; + *) + echo bad unit for grf in: $i + ;; + esac + ;; + +mouse*) + unit=`expr $i : 'mouse\(.*\)'` + rm -f mouse${unit} + case $unit in + 0|1) + mknod mouse${unit} c 15 ${unit}; chmod 666 mouse${unit} + if [ $unit = 0 ] + then + rm -f mouse; ln -s mouse${unit} mouse + fi + ;; + *) + echo bad unit for mouse in: $i + ;; + esac + ;; + +kbd) + rm -f kbd + mknod kbd c 14 0 + ;; + + +view*) + unit=`expr $i : 'view\(.*\)'` + rm -f view${unit} + case $unit in + 00|01|02|03|04|05|06|07|08|09) + mknod view${unit} c 16 ${unit}; chmod 666 view${unit} + ;; + *) + echo bad unit for view in: $i + ;; + esac + ;; + +pty*) + class=`expr $i : 'pty\(.*\)'` + case $class in + 0) offset=0 name=p;; + 1) offset=16 name=q;; + 2) offset=32 name=r;; + 3) offset=48 name=s;; +# Note that telnetd, rlogind, and xterm (at least) only look at p-s. + 4) offset=64 name=t;; + *) echo bad unit for pty in: $i;; + esac + case $class in + 0|1|2|3|4) + umask 0 + (i=0; while [ $i -lt 16 ]; do + eval `printf "rm -f tty%s%x; mknod tty%s%x c 4 %d; \ + rm -f pty%s%x; mknod pty%s%x c 5 %d" $name $i \ + $name $i $offset $name $i $name $i $offset` + offset=$(($offset+1)) + i=$(($i+1)) + done) + umask 77 + ;; + esac + ;; + +bpf*) + unit=`expr $i : 'bpf\(.*\)'` + rm -f bpf$unit + mknod bpf$unit c 22 $unit + chown root.wheel bpf$unit + ;; + +tun*) + unit=`expr $i : 'tun\(.*\)'` + rm -f tun$unit + mknod tun$unit c 23 $unit + chmod 600 tun$unit + chown root.wheel tun$unit + ;; + +lkm) + rm -f lkm + mknod lkm c 24 0 + chown root:kmem lkm + chmod 640 lkm + ;; + +local) + umask 0 + sh MAKEDEV.local + umask 77 + ;; + +*) + echo $i: unknown device + ;; +esac +done diff --git a/src/etc/etc.amiga/Makefile.inc b/src/etc/etc.amiga/Makefile.inc new file mode 100644 index 00000000..b85537ed --- /dev/null +++ b/src/etc/etc.amiga/Makefile.inc @@ -0,0 +1,14 @@ +# +# etc.amiga/Makefile.inc -- amiga-specific etc Makefile targets +# +# $NetBSD: Makefile.inc,v 1.6 1995/10/09 02:25:41 chopps Exp $ + +.ifdef DESTDIR +snap_md: netbsd-generic + cp ${.CURDIR}/../sys/arch/amiga/compile/GENERIC/netbsd.gz \ + ${DESTDIR}/snapshot/netbsd-generic.gz +netbsd-generic: + cd ${.CURDIR}/../sys/arch/amiga/conf && config GENERIC + cd ${.CURDIR}/../sys/arch/amiga/compile/GENERIC && \ + make clean && make depend && make && gzip -9 netbsd +.endif # DESTDIR check diff --git a/src/etc/etc.amiga/disktab b/src/etc/etc.amiga/disktab new file mode 100644 index 00000000..6e65da4f --- /dev/null +++ b/src/etc/etc.amiga/disktab @@ -0,0 +1,45 @@ +# +# $NetBSD: disktab,v 1.3 1995/10/09 02:25:43 chopps Exp $ +# +# Disk geometry and partition layout tables. +# Key: +# dt controller type +# ty type of disk (fixed, removeable, simulated) +# d[0-4] drive-type-dependent parameters +# ns #sectors/track +# nt #tracks/cylinder +# nc #cylinders/disk +# sc #sectors/cylinder, ns*nt default +# su #sectors/unit, sc*nc default +# se sector size, DEV_BSIZE default +# rm rpm, 3600 default +# sf supports bad144-style bad sector forwarding +# sk sector skew per track, default 0 +# cs sector skew per cylinder, default 0 +# hs headswitch time, default 0 +# ts one-cylinder seek time, default 0 +# il sector interleave (n:1), 1 default +# bs boot block size, default BBSIZE +# sb superblock size, default SBSIZE +# o[a-h] partition offsets in sectors +# p[a-h] partition sizes in sectors +# b[a-h] partition block sizes in bytes +# f[a-h] partition fragment sizes in bytes +# t[a-h] partition types (filesystem, swap, etc) +# +# All partition sizes reserve space for bad sector tables. +# (5 cylinders needed for maintenance + replacement sectors) +# +floppy|floppy3|3in|Amiga 3.5in Double Density Floppy:\ + :ty=floppy:se#512:nt#2:rm#300:ns#11:nc#80:\ + :ts#3500:\ + :ta=4.2BSD:pa#1760:oa#0:ba#4096:fa#512:\ + :pb#0:ob#0:\ + :pc#1760:oc#0: + +floppyhd|floppy3hd|3inhd|Amiga 3.5in High Density Floppy:\ + :ty=floppy:se#512:nt#2:rm#300:ns#22:nc#80:\ + :ts=3500:\ + :pa#3520:oa#0:ba#4096:fa#512:\ + :pb#0:ob#0:\ + :pc#3520:oc#0: diff --git a/src/etc/etc.amiga/fstab.tmp b/src/etc/etc.amiga/fstab.tmp new file mode 100644 index 00000000..b6393894 --- /dev/null +++ b/src/etc/etc.amiga/fstab.tmp @@ -0,0 +1,20 @@ +# +# $NetBSD: fstab.tmp,v 1.8 1995/10/09 02:25:44 chopps Exp $ +# +# fast file system on / root partition (NBR\7) lowest scsi disk unit +/dev/sd0a / ffs rw 1 1 +# fast file system on /usr (NBU\7) next to lowest scsi disk unit +/dev/sd0d /usr ffs rw 1 2 +# virtual mem file system on /tmp using swap (NBS\0) scsi id 0 size 5M +#/dev/sd0b /tmp mfs rw,-s10240 +# amigados file system on /amiga (DOS/1) +# It is recomended that you mount it on a dir that matches the +# volume name and then slinks will resolve correctly. All ados +# unknonwn and NBU type filesystems are addressed in physical +# offset (on media) order. So in this example the bsd usr part is +# first on the disk followed by the ados. +#/dev/sd0e /amiga ados ro +# process file system +#procfs /proc procfs ro +# kernel file system +#kernfs /kern kernfs ro diff --git a/src/etc/etc.amiga/ttys b/src/etc/etc.amiga/ttys new file mode 100644 index 00000000..292ed44f --- /dev/null +++ b/src/etc/etc.amiga/ttys @@ -0,0 +1,48 @@ +# +# $NetBSD: ttys,v 1.11 1995/10/09 02:25:46 chopps Exp $ +# +# from: @(#)ttys 5.1 (Berkeley) 4/17/89 +# +# name getty type status comments +# +# If the console is marked insecure, single-user requires +# the root password. +console "/usr/libexec/getty Pc" vt220 off secure +ttye0 "/usr/libexec/getty Pc" vt220 on secure # custom chips +ttye1 "/usr/libexec/getty Pc" vt220 on secure # retina +ttye2 "/usr/libexec/getty Pc" vt220 on secure # retina +ttye3 "/usr/libexec/getty Pc" vt220 on secure # cirrus logic +ttye4 "/usr/libexec/getty Pc" vt220 on secure # a2410 +tty00 "/usr/libexec/getty std.9600" unknown off secure # int. serial. +ttyp0 none network +ttyp1 none network +ttyp2 none network +ttyp3 none network +ttyp4 none network +ttyp5 none network +ttyp6 none network +ttyp7 none network +ttyp8 none network +ttyp9 none network +ttypa none network +ttypb none network +ttypc none network +ttypd none network +ttype none network +ttypf none network +ttyq0 none network +ttyq1 none network +ttyq2 none network +ttyq3 none network +ttyq4 none network +ttyq5 none network +ttyq6 none network +ttyq7 none network +ttyq8 none network +ttyq9 none network +ttyqa none network +ttyqb none network +ttyqc none network +ttyqd none network +ttyqe none network +ttyqf none network diff --git a/src/etc/etc.atari/MAKEDEV b/src/etc/etc.atari/MAKEDEV new file mode 100644 index 00000000..d5767016 --- /dev/null +++ b/src/etc/etc.atari/MAKEDEV @@ -0,0 +1,388 @@ +#!/bin/sh - +# +# $NetBSD: MAKEDEV,v 1.4 1995/08/17 18:02:31 thorpej Exp $ +# +# Copyright (c) 1990 The Regents of the University of California. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the University of +# California, Berkeley and its contributors. +# 4. Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# from: +# hp300/MAKEDEV (1/15/94), from: +# @(#)MAKEDEV 5.5 (Berkeley) 5/28/91 +# +# Device "make" file. Valid arguments: +# all makes all known devices, including local devices, +# Tries to make the ``standard'' number of each. +# fd makes fd/* for the fdescfs. +# floppy devices needed for install floppies +# std standard devices +# local configuration specific devices +# +# Tapes: +# st* SCSI tapes +# +# Disks: +# fd* Floppy disks (fdxa: 360Kb, fdxb: 720Kb, fdxc: 1.44Mb) +# sd* SCSI disks, includes flopticals +# cd* SCSI cdrom discs +# vnd* "file" pseudo-disks +# ccd* concatedated disk driver +# +# Console ports: +# ttye* ite bitmapped consoles +# +# Pointing devices: +# mouse* Atari mice +# +# Terminal ports: +# ser02 serial2 port (channel A on 8530) +# mdm02 modem2 port (channel B on 8530) +# +# Pseudo terminals: +# pty* set of 16 master and slave pseudo terminals +# +# Special purpose devices: +# grf* Motherboard bitmapped video. +# kbd Atari keyboard. +# view* generic interface to graphic displays. +# aconf autoconfig information (not yet) +# lkm loadable kernel modules interface. +# bpf* Berkeley Packet Filter + +PATH=/sbin:/bin:/usr/sbin:/usr/bin +umask 77 +for i +do +case $i in +all) + sh MAKEDEV std fd st0 ttye0 ttye1 ttye2 mouse0 mouse1 grf0 grf1 grf2 + sh MAKEDEV kbd sd0 sd1 sd2 sd3 sd4 sd5 sd6 sd7 sd8 sd9 vnd0 vnd1 vnd2 + sh MAKEDEV vnd3 vnd4 view00 view01 view02 view03 view04 view05 pty0 + sh MAKEDEV vnd5 vnd6 cd0 fd0 fd1 fd2 fd3 bpf0 bpf1 bpf2 bpf3 + sh MAKEDEV ccd0 ccd1 ccd2 ccd3 + sh MAKEDEV lkm ser02 mdm02 local + ;; + +floppy) + sh MAKEDEV std st0 ttye0 ttye1 ttye2 grf0 grf1 grf2 kbd + sh MAKEDEV sd0 sd1 sd2 sd3 sd4 sd5 sd6 cd0 fd0 fd1 rd0 + ;; + +std) + rm -f console drum kmem mem reload null zero tty + rm -f klog stdin stdout stderr + mknod console c 0 0 + mknod drum c 3 0 ; chmod 640 drum ; chgrp kmem drum + mknod kmem c 2 1 ; chmod 640 kmem ; chgrp kmem kmem + mknod mem c 2 0 ; chmod 640 mem ; chgrp kmem mem + mknod reload c 2 20 ; chmod 640 mem ; chgrp kmem mem + mknod zero c 2 12 ; chmod 666 zero + mknod null c 2 2 ; chmod 666 null + mknod tty c 1 0 ; chmod 666 tty + mknod klog c 6 0 ; chmod 600 klog + mknod stdin c 18 0 ; chmod 666 stdin + mknod stdout c 18 1 ; chmod 666 stdout + mknod stderr c 18 2 ; chmod 666 stderr + ;; + +fd) + rm -f fd/* + mkdir fd > /dev/null 2>&1 + (cd fd && i=0 && while [ $i -lt 64 ]; do + mknod $i c 18 $i + i=$(($i+1)) + done) + chown -R bin.bin fd + chmod 555 fd + chmod 666 fd/* + ;; + +ser02) + rm -f ser02 + mknod ser02 c 7 0 + chown uucp:wheel ser02 + ;; + +mdm02) + rm -f mdm02 + mknod mdm02 c 7 16 + chown uucp:wheel mdm02 + ;; + +st*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + st*) name=st; blk=5; chr=10;; + esac + rm -f $name$unit n$name$unit e$name$unit en$name$unit \ + r$name$unit nr$name$unit er$name$unit enr$name$unit + case $unit in + 0|1|2|3|4|5|6) + mknod ${name}${unit} b $blk `expr $unit '*' 16 + 0` + mknod n${name}${unit} b $blk `expr $unit '*' 16 + 1` + mknod e${name}${unit} b $blk `expr $unit '*' 16 + 2` + mknod en${name}${unit} b $blk `expr $unit '*' 16 + 3` + mknod r${name}${unit} c $chr `expr $unit '*' 16 + 0` + mknod nr${name}${unit} c $chr `expr $unit '*' 16 + 1` + mknod er${name}${unit} c $chr `expr $unit '*' 16 + 2` + mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3` + chgrp operator ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + chmod 640 ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + ;; + *) + echo bad unit for tape in: $i + ;; + esac + umask 77 + ;; + +fd*) + umask 2 ; unit=`expr $i : '.*[^0-9]\([0-9]*\)'` + rm -f fd$unit? rfd$unit? + case $unit in + 0|1|2|3) + mknod fd${unit}a b 2 `expr $unit '*' 16` + mknod fd${unit}b b 2 `expr $unit '*' 16 + 1` + mknod fd${unit}c b 2 `expr $unit '*' 16 + 2` + mknod rfd${unit}a c 16 `expr $unit '*' 16` + mknod rfd${unit}b c 16 `expr $unit '*' 16 + 1` + mknod rfd${unit}c c 16 `expr $unit '*' 16 + 2` + chgrp operator fd$unit? rfd$unit? + chmod 640 fd$unit? rfd$unit? + ;; + *) + echo bad unit for floppy disk in: $i + ;; + esac + umask 77 + ;; + +rd0) # Ramdisk, only usefull for boot-floppy + umask 2; rm -f rd0 + mknod rd0 b 1 0 + umask 77 + ;; + +sd*|vnd*|ccd*) + umask 2 ; unit=`expr $i : '.*[^0-9]\([0-9]*\)'` + case $i in + sd*) name=sd; blk=4; chr=8;; + vnd*) name=vnd; blk=0; chr=17;; + ccd*) name=ccd; blk=13; chr=27;; + esac + rm -f $name$unit? r$name$unit? + case $unit in + 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15) + mknod ${name}${unit}c b $blk `expr $unit '*' 16 + 2` + mknod r${name}${unit}c c $chr `expr $unit '*' 16 + 2` + if [ $name != cd -a $name != vnd ] + then + mknod ${name}${unit}a b $blk `expr $unit '*' 16 + 0` + mknod ${name}${unit}b b $blk `expr $unit '*' 16 + 1` + mknod ${name}${unit}d b $blk `expr $unit '*' 16 + 3` + mknod ${name}${unit}e b $blk `expr $unit '*' 16 + 4` + mknod ${name}${unit}f b $blk `expr $unit '*' 16 + 5` + mknod ${name}${unit}g b $blk `expr $unit '*' 16 + 6` + mknod ${name}${unit}h b $blk `expr $unit '*' 16 + 7` + mknod ${name}${unit}i b $blk `expr $unit '*' 16 + 8` + mknod ${name}${unit}j b $blk `expr $unit '*' 16 + 9` + mknod ${name}${unit}k b $blk `expr $unit '*' 16 + 10` + mknod ${name}${unit}l b $blk `expr $unit '*' 16 + 11` + mknod ${name}${unit}m b $blk `expr $unit '*' 16 + 12` + mknod ${name}${unit}n b $blk `expr $unit '*' 16 + 13` + mknod ${name}${unit}o b $blk `expr $unit '*' 16 + 14` + mknod ${name}${unit}p b $blk `expr $unit '*' 16 + 15` + mknod r${name}${unit}a c $chr `expr $unit '*' 16 + 0` + mknod r${name}${unit}b c $chr `expr $unit '*' 16 + 1` + mknod r${name}${unit}d c $chr `expr $unit '*' 16 + 3` + mknod r${name}${unit}e c $chr `expr $unit '*' 16 + 4` + mknod r${name}${unit}f c $chr `expr $unit '*' 16 + 5` + mknod r${name}${unit}g c $chr `expr $unit '*' 16 + 6` + mknod r${name}${unit}h c $chr `expr $unit '*' 16 + 7` + mknod r${name}${unit}i c $chr `expr $unit '*' 16 + 8` + mknod r${name}${unit}j c $chr `expr $unit '*' 16 + 9` + mknod r${name}${unit}k c $chr `expr $unit '*' 16 + 10` + mknod r${name}${unit}l c $chr `expr $unit '*' 16 + 11` + mknod r${name}${unit}m c $chr `expr $unit '*' 16 + 12` + mknod r${name}${unit}n c $chr `expr $unit '*' 16 + 13` + mknod r${name}${unit}o c $chr `expr $unit '*' 16 + 14` + mknod r${name}${unit}p c $chr `expr $unit '*' 16 + 15` + fi + chgrp operator ${name}${unit}[a-p] r${name}${unit}[a-p] + chmod 640 ${name}${unit}[a-p] r${name}${unit}[a-p] + ;; + *) + echo bad unit for disk in: $i + ;; + esac + umask 77 + ;; + +cd*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + cd*) name=cd; blk=6; chr=9;; + esac + rm -f $name$unit? r$name$unit? + case $unit in + 0|1|2|3|4|5|6) + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + ;; + *) + echo bad unit for disk in: $i + ;; + esac + umask 77 + ;; + +ttye*) + unit=`expr $i : 'ttye\(.*\)'` + rm -f ttye${unit} + rm -f ite* + case $unit in + 0|1|2) + mknod ttye${unit} c 12 ${unit} + ;; + *) + echo bad unit for ttye in: $i + ;; + esac + ;; + +grf*) + unit=`expr $i : 'grf\(.*\)'` + rm -f grf${unit} + case $unit in + 0|1|2) + mknod grf${unit} c 11 ${unit}; chmod 666 grf${unit} + ;; + *) + echo bad unit for grf in: $i + ;; + esac + ;; + +mouse*) + unit=`expr $i : 'mouse\(.*\)'` + rm -f mouse${unit} + case $unit in + 0|1) + mknod mouse${unit} c 15 ${unit}; chmod 666 mouse${unit} + if [ $unit = 0 ] + then + rm -f mouse; ln -s mouse${unit} mouse + fi + ;; + *) + echo bad unit for mouse in: $i + ;; + esac + ;; + +kbd) + rm -f kbd + mknod kbd c 14 0 + ;; + + +view*) + unit=`expr $i : 'view\(.*\)'` + rm -f view${unit} + case $unit in + 00|01|02|03|04|05|06|07|08|09) + mknod view${unit} c 13 ${unit}; chmod 666 view${unit} + ;; + *) + echo bad unit for view in: $i + ;; + esac + ;; + +pty*) + class=`expr $i : 'pty\(.*\)'` + case $class in + 0) offset=0 name=p;; + 1) offset=16 name=q;; + 2) offset=32 name=r;; + 3) offset=48 name=s;; +# Note that telnetd, rlogind, and xterm (at least) only look at p-s. + 4) offset=64 name=t;; + *) echo bad unit for pty in: $i;; + esac + case $class in + 0|1|2|3|4) + umask 0 + (i=0; while [ $i -lt 16 ]; do + eval `printf "rm -f tty%s%x; mknod tty%s%x c 4 %d; \ + rm -f pty%s%x; mknod pty%s%x c 5 %d" $name $i \ + $name $i $offset $name $i $name $i $offset` + offset=$(($offset+1)) + i=$(($i+1)) + done) + umask 77 + ;; + esac + ;; + +bpf*) + unit=`expr $i : 'bpf\(.*\)'` + rm -f bpf$unit + mknod bpf$unit c 19 $unit + chown root.wheel bpf$unit + ;; + +lkm) + rm -f lkm + mknod lkm c 20 0 + chown root:kmem lkm + chmod 640 lkm + ;; + +local) + umask 0 + sh MAKEDEV.local + umask 77 + ;; + +*) + echo $i: unknown device + ;; +esac +done diff --git a/src/etc/etc.atari/Makefile.inc b/src/etc/etc.atari/Makefile.inc new file mode 100644 index 00000000..31c165f7 --- /dev/null +++ b/src/etc/etc.atari/Makefile.inc @@ -0,0 +1,22 @@ +# +# $NetBSD: Makefile.inc,v 1.1.1.1 1995/03/30 05:44:08 leo Exp $ +# +# etc.atari/Makefile.inc -- atari-specific etc Makefile targets +# + +.ifdef DESTDIR +snap_md: netbsd-generic netbsd-ataritt + cp ${.CURDIR}/../sys/arch/atari/compile/GENERIC/netbsd.gz \ + ${DESTDIR}/snapshot/netbsd-generic.gz + cp ${.CURDIR}/../sys/arch/atari/compile/ATARITT/netbsd.gz \ + ${DESTDIR}/snapshot/netbsd-ataritt.gz +netbsd-generic: + cd ${.CURDIR}/../sys/arch/atari/conf && config.new GENERIC + cd ${.CURDIR}/../sys/arch/atari/compile/GENERIC && \ + make clean && make depend && make && gzip -9 netbsd + +netbsd-ataritt: + cd ${.CURDIR}/../sys/arch/atari/conf && config.new ATARITT + cd ${.CURDIR}/../sys/arch/atari/compile/ATARITT && \ + make clean && make depend && make && gzip -9 netbsd +.endif # DESTDIR check diff --git a/src/etc/etc.atari/disktab b/src/etc/etc.atari/disktab new file mode 100644 index 00000000..3bc239ee --- /dev/null +++ b/src/etc/etc.atari/disktab @@ -0,0 +1,51 @@ +# +# $NetBSD: disktab,v 1.1.1.1 1995/03/30 05:44:08 leo Exp $ +# +# Disk geometry and partition layout tables. +# Key: +# dt controller type +# ty type of disk (fixed, removeable, simulated) +# d[0-4] drive-type-dependent parameters +# ns #sectors/track +# nt #tracks/cylinder +# nc #cylinders/disk +# sc #sectors/cylinder, ns*nt default +# su #sectors/unit, sc*nc default +# se sector size, DEV_BSIZE default +# rm rpm, 3600 default +# sf supports bad144-style bad sector forwarding +# sk sector skew per track, default 0 +# cs sector skew per cylinder, default 0 +# hs headswitch time, default 0 +# ts one-cylinder seek time, default 0 +# il sector interleave (n:1), 1 default +# bs boot block size, default BBSIZE +# sb superblock size, default SBSIZE +# o[a-h] partition offsets in sectors +# p[a-h] partition sizes in sectors +# b[a-h] partition block sizes in bytes +# f[a-h] partition fragment sizes in bytes +# t[a-h] partition types (filesystem, swap, etc) +# +# All partition sizes reserve space for bad sector tables. +# (5 cylinders needed for maintenance + replacement sectors) +# +floppy|floppy3|3in|Atari 3.5in Double Density Floppy:\ + :ty=floppy:se#512:nt#2:rm#300:ns#9:nc#80:\ + :ts#3500:\ + :ta=4.2BSD:pa#1440:oa#0:ba#4096:fa#512:\ + :pb#0:ob#0:\ + :pc#1440:oc#0: + +floppyhd|floppy3hd|3inhd|Atari 3.5in High Density Floppy:\ + :ty=floppy:se#512:nt#2:rm#300:ns#18:nc#80:\ + :ts=3500:\ + :pa#2880:oa#0:ba#4096:fa#512:\ + :pb#0:ob#0:\ + :pc#2880:oc#0: +floppybt|Atari 3.5in Boot Floppy:\ + :ty=floppy:se#512:nt#2:rm#300:ns#18:nc#60:\ + :ts=3500:\ + :ta=4.4BSD:pa#2160:oa#0:ba#4096:fa#512:\ + :pb#0:ob#0:\ + :pc#2160:oc#0: diff --git a/src/etc/etc.atari/fstab.tmp b/src/etc/etc.atari/fstab.tmp new file mode 100644 index 00000000..66d9e500 --- /dev/null +++ b/src/etc/etc.atari/fstab.tmp @@ -0,0 +1,9 @@ +# +# $NetBSD: fstab.tmp,v 1.2 1995/08/22 19:52:31 jtc Exp $ +# +/dev/sd0a / ffs rw 1 1 +/dev/sd0d /usr ffs rw 1 2 +#/dev/sd0b /tmp mfs rw,-s10240 +#/dev/sd0e /atari msdos rw +#procfs /proc procfs ro +#kernfs /kern kernfs ro diff --git a/src/etc/etc.atari/ttys b/src/etc/etc.atari/ttys new file mode 100644 index 00000000..c4537148 --- /dev/null +++ b/src/etc/etc.atari/ttys @@ -0,0 +1,44 @@ +# +# $NetBSD: ttys,v 1.1.1.1 1995/03/30 05:44:08 leo Exp $ +# +# from: @(#)ttys 5.1 (Berkeley) 4/17/89 +# +# name getty type status comments +# +# If the console is marked insecure, single-user requires +# the root password. +console "/usr/libexec/getty Pc" vt200 off secure +ttye0 "/usr/libexec/getty Pc" vt200 on secure # ite0 console +ttye1 "/usr/libexec/getty Pc" vt200 on secure # ite1 +ttyp0 none network +ttyp1 none network +ttyp2 none network +ttyp3 none network +ttyp4 none network +ttyp5 none network +ttyp6 none network +ttyp7 none network +ttyp8 none network +ttyp9 none network +ttypa none network +ttypb none network +ttypc none network +ttypd none network +ttype none network +ttypf none network +ttyq0 none network +ttyq1 none network +ttyq2 none network +ttyq3 none network +ttyq4 none network +ttyq5 none network +ttyq6 none network +ttyq7 none network +ttyq8 none network +ttyq9 none network +ttyqa none network +ttyqb none network +ttyqc none network +ttyqd none network +ttyqe none network +ttyqf none network diff --git a/src/etc/etc.hp300/MAKEDEV b/src/etc/etc.hp300/MAKEDEV new file mode 100644 index 00000000..acc95e57 --- /dev/null +++ b/src/etc/etc.hp300/MAKEDEV @@ -0,0 +1,320 @@ +#!/bin/sh - +# +# $NetBSD: MAKEDEV,v 1.11 1995/09/30 21:59:57 thorpej Exp $ +# +# Copyright (c) 1990 The Regents of the University of California. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the University of +# California, Berkeley and its contributors. +# 4. Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# @(#)MAKEDEV 5.5 (Berkeley) 5/28/91 +# +# Device "make" file. Valid arguments: +# std standard devices +# local configuration specific devices +# Tapes: +# ct* HP300 HP-IB cartridge tape +# mt* (Magnetic) 9-track reel tape +# st* Exabyte tape +# Disks: +# ccd* "concatenated" pseudo-disks +# rd* HP300 HP-IB disks +# sd* HP300 SCSI disks +# vnd* "file" pseudo-disks +# Terminal multiplexors: +# dca* HP200/300 single port serial interface +# dcm* HP200/300 4 port serial mux interface +# Pseudo terminals: +# pty* set of 16 master and slave pseudo terminals +# Printers: +# Call units: +# Special purpose devices: +# fd file descriptors +# grf* raw interface to HP300 graphics devices +# ite* terminal emulator interface to HP300 graphics devices +# hil HP300 HIL input devices +# bpf* packet filter +# tun* network tunnel driver +# lkm loadable kernel modules interface +# + +PATH=/sbin:/bin/:/usr/bin:/usr/sbin +umask 77 +for i +do +case $i in + +all) + sh MAKEDEV std fd ct0 ct1 st0 st1 ccd0 ccd1 ccd2 rd0 rd1 rd2 + sh MAKEDEV sd0 sd1 sd2 pty0 vnd0 vnd1 vnd2 vnd3 + sh MAKEDEV hil grf0 ite0 dca0 dcm0 dcm1 dcm2 dcm3 + sh MAKEDEV bpf0 bpf1 bpf2 bpf3 tun0 tun1 tun2 tun3 lkm + sh MAKEDEV local + ;; + +std) + mknod console c 0 0 + mknod drum c 3 0 ; chmod 640 drum ; chgrp kmem drum + mknod kmem c 2 1 ; chmod 640 kmem ; chgrp kmem kmem + mknod mem c 2 0 ; chmod 640 mem ; chgrp kmem mem + mknod null c 2 2 ; chmod 666 null + mknod zero c 2 12 ; chmod 666 zero + mknod tty c 1 0 ; chmod 666 tty + mknod klog c 6 0 ; chmod 600 klog + mknod stdin c 21 0 ; chmod 666 stdin + mknod stdout c 21 1 ; chmod 666 stdout + mknod stderr c 21 2 ; chmod 666 stderr + ;; + +fd) + rm -f fd/* + mkdir fd > /dev/null 2>&1 + (cd fd && eval `echo "" | awk ' BEGIN { \ + for (i = 0; i < 64; i++) \ + printf("mknod %d c 21 %d;", i, i)}'`) + chown -R bin.bin fd + chmod 555 fd + chmod 666 fd/* + ;; + +ct*|mt*|st*) + umask 0 ; unit=`expr $i : '..\(.*\)'` + case $i in + ct*) name=ct; blk=0; chr=7;; + mt*) name=mt; blk=1; chr=16;; + st*) name=st; blk=6; chr=20;; + esac + case $unit in + 0|1|2|3|4|5|6|7) + four=`expr $unit + 4` ; eight=`expr $unit + 8` + twelve=`expr $unit + 12`; twenty=`expr $unit + 20` + # + # block devices don't work so don't make them + #mknod ${name}${unit} b $blk $unit + #mknod ${name}${four} b $blk $four + #mknod ${name}${eight} b $blk $eight + #mknod ${name}${twelve} b $blk $twelve + #mknod n${name}${unit} b $blk $four ;: sanity w/pdp11 v7 + #mknod n${name}${eight} b $blk $twelve ;: ditto + # + mknod r${name}${unit} c $chr $unit + mknod r${name}${four} c $chr $four + mknod r${name}${eight} c $chr $eight + mknod r${name}${twelve} c $chr $twelve + ln r${name}${four} nr${name}${unit} ;: sanity w/pdp11 v7 + ln r${name}${twelve} nr${name}${eight} ;: ditto + ;; + *) + echo bad unit for tape in: $1 + ;; + esac + umask 77 + ;; + +bpf*) + unit=`expr $i : 'bpf\(.*\)'` + rm -f bpf$unit + mknod bpf$unit c 22 $unit + chmod 600 bpf$unit + chown root.wheel bpf$unit + ;; + +tun*) + unit=`expr $i : 'tun\(.*\)'` + rm -f tun$unit + mknod tun$unit c 23 $unit + chmod 600 tun$unit + chown root.wheel tun$unit + ;; + +ccd*|fd*|rd*|sd*|vnd*) + umask 2 ; unit=`expr $i : '.*d\(.*\)'` + case $i in + rd*) name=rd; blk=2; chr=9;; + sd*) name=sd; blk=4; chr=8;; + ccd*) name=ccd; blk=5; chr=17;; + vnd*) name=vnd; blk=6; chr=19;; + esac + case $unit in + 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|\ + 17|18|19|20|21|22|23|24|25|26|27|28|29|30|31) + rm -f $name$unit? r$name$unit? + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1` + mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4` + mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5` + mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6` + mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1` + mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4` + mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5` + mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6` + mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + ;; + *) + echo bad unit for disk in: $i + ;; + esac + umask 77 + ;; + +dca*) + unit=`expr $i : 'dca\(.*\)'` + case $unit in + 0) + mknod tty0 c 12 0 + ;; + *) + echo bad unit for dca in: $i + ;; + esac + ;; + +dcm*) + unit=`expr $i : 'dcm\(.*\)'` + case $unit in + 0|1|2|3) + eval `echo $unit | awk ' { unit = $1; u = 4 * $1 } END { + for (i = 0; i < 4; i++) + printf("mknod tty0%x c 15 %d; ",u+i,u+i); }'` + ;; + *) + echo bad unit for dcm in: $i + ;; + esac + ;; + +ite*) + unit=`expr $i : 'ite\(.*\)'` + case $unit in + 0|1|2|3) + mknod ttye${unit} c 13 ${unit} + ;; + *) + echo bad unit for ite in: $i + ;; + esac + ;; + +grf*) + unit=`expr $i : 'grf\(.*\)'` + case $unit in + 0|1|2|3) + mknod grf${unit} c 10 ${unit}; chmod 666 grf${unit} +# echo "grf${unit}: use MAKEDEV.hpux to make HP-UX names for device" + ;; + *) + echo bad unit for grf in: $i + ;; + esac + ;; + +hil) + for unit in 0 1 2 3 4 5 6 7 + do + mknod hil${unit} c 14 ${unit} + if [ -f /usr/sbin/hilinfo ] + then + case `/usr/sbin/hilinfo -t hil${unit}` in + mouse) + if [ ! -f locator ] + then + ln hil${unit} locator + fi + ;; + keyboard) + if [ ! -f keyboard ] + then + ln hil${unit} keyboard + fi + ;; + *) + ;; + esac + fi + done + if [ ! -f /usr/sbin/hilinfo ] + then + ln hil1 keyboard + ln hil3 locator + fi + chmod 666 hil* +# echo "hil: use MAKEDEV.hpux to make HP-UX names for devices" + ;; + +lkm) + rm -f lkm + mknod lkm c 24 0 + chown root.kmem lkm + chmod 640 lkm + ;; + +pty*) + class=`expr $i : 'pty\(.*\)'` + case $class in + 0) offset=0 name=p;; + 1) offset=16 name=q;; + 2) offset=32 name=r;; + 3) offset=48 name=s;; +# Note that telnetd, rlogind, and xterm (at least) only look at p-s. + 4) offset=64 name=t;; + *) echo bad unit for pty in: $i;; + esac + case $class in + 0|1|2|3|4) + umask 0 + eval `echo $offset $name | awk ' { b=$1; n=$2 } END { + for (i = 0; i < 16; i++) + printf("mknod tty%s%x c 4 %d; \ + mknod pty%s%x c 5 %d; ", \ + n, i, b+i, n, i, b+i); }'` + umask 77 + if [ $class = 1 ]; then + mv ttyqf ttyv0; mv ptyqf ptyv0 + fi + ;; + esac + ;; + +local) + umask 0 + sh MAKEDEV.local + ;; +*) + echo $i: unknown device + ;; +esac +done diff --git a/src/etc/etc.hp300/Makefile.inc b/src/etc/etc.hp300/Makefile.inc new file mode 100644 index 00000000..3f51f795 --- /dev/null +++ b/src/etc/etc.hp300/Makefile.inc @@ -0,0 +1,28 @@ +# $NetBSD: Makefile.inc,v 1.1 1995/09/06 16:17:41 thorpej Exp $ +# +# etc.hp300/Makefile.inc -- hp300-specific etc Makefile targets + +.ifdef DESTDIR +snap_md: netbsd-gen.gz netbsd-dl.gz + +netbsd-gen: + cd ${.CURDIR}/../sys/arch/hp300/conf && config.old GENERIC + cd ${.CURDIR}/../sys/arch/hp300/compile/GENERIC && \ + make clean && make depend && make + cp ${.CURDIR}/../sys/arch/hp300/compile/GENERIC/netbsd \ + ${DESTDIR}/snapshot/netbsd-gen + +netbsd-dl: + cd ${.CURDIR}/../sys/arch/hp300/conf && config.old DISKLESS + cd ${.CURDIR}/../sys/arch/hp300/compile/DISKLESS && \ + make clean && make depend && make + cp ${.CURDIR}/../sys/arch/hp300/compile/DISKLESS/netbsd \ + ${DESTDIR}/snapshot/netbsd-dl + +netbsd-gen.gz: netbsd-gen + gzip -9 ${DESTDIR}/snapshot/netbsd-gen + +netbsd-dl.gz: netbsd-dl + gzip -9 ${DESTDIR}/snapshot/netbsd-dl + +.endif # DESTDIR check diff --git a/src/etc/etc.hp300/disktab b/src/etc/etc.hp300/disktab new file mode 100644 index 00000000..a14c4986 --- /dev/null +++ b/src/etc/etc.hp300/disktab @@ -0,0 +1,290 @@ +# $NetBSD: disktab,v 1.3 1995/09/30 21:57:48 thorpej Exp $ +# +# @(#)disktab 5.5 (Berkeley) 2/27/91 +# +# Disk geometry and partition layout tables. +# Key: +# ty type of disk +# ns #sectors/track +# nt #tracks/cylinder +# nc #cylinders/disk +# rm rpm, 3600 default +# se sector size, 512 default +# sf supports bad144-style bad sector forwarding +# so partition offsets in sectors +# p[a-h] partition sizes in sectors +# b[a-h] partition block sizes in bytes +# f[a-h] partition fragment sizes in bytes +# +# All partition sizes contain space +# for bad sector tables unless the +# device drivers fail to support this. +# +# Entries may also be used for other compatible drives +# with the same geometry. + +# +# HP CS80 Drives on rd (new style partitioning). These mapping support +# three basic layouts: +# +# A/B/G: This is the "traditional" setup for a bootable disk. +# A is the root partition, B the swap, and G is for /usr +# and users. +# A/D/E/F (large drives): +# A/D/H (small drives): +# This is a setup for bootable systems requiring more swap +# (e.g. those who need CL). It has A as the root, D as a +# larger swap, E and F (or H) as smaller user partitions. +# E could be used for /usr and F for users (or H for both). +# C: This gives a single, non-bootable, large user filesystem. +# Good for second drives on a machine as either /usr/src +# or a large /usr or user partition. + +# pseudo-geometry taken from rd7945 +miniroot:\ + :ty=winchester:ns#16:nt#7:nc#968:\ + :pa#10240:ba#8192:fa#1024: + +rd7945|rd7946|rd7945A|rd7946A|HP7945A|HP7946A:\ + :ty=winchester:ns#16:nt#7:nc#968:\ + :pa#15904:ba#8192:fa#1024:\ + :pb#20160:\ + :pc#108416:bc#4096:fc#1024:\ + :pd#40320:\ + :pg#72240:bg#4096:fg#512:\ + :ph#52080:bh#4096:fh#512: +rd7957|rd7957A|HP7957A:\ + :ty=winchester:ns#22:nt#7:nc#1036:\ + :pa#16016:ba#8192:fa#1024:\ + :pb#24640:\ + :pc#159544:bc#4096:fc#1024:\ + :pd#42350:\ + :pe#54824:be#4096:fe#512:\ + :pf#46200:bf#4096:ff#1024:\ + :pg#118734:bg#4096:fg#1024:\ + :ph#101024:bh#4096:fh#1024: +rd7958|rd7958A|HP7958A:\ + :ty=winchester:ns#36:nt#7:nc#1013:\ + :pa#16128:ba#8192:fa#1024:\ + :pb#32256:\ + :pc#255276:bc#4096:fc#1024:\ + :pd#48384:\ + :pe#100800:be#4096:fe#512:\ + :pf#89712:bf#4096:ff#1024:\ + :pg#206640:bg#4096:fg#1024:\ + :ph#190512:bh#4096:fh#1024: +rd7933|rd7933H|HP7933H:\ + :ty=winchester:ns#46:nt#13:nc#1321:\ + :pa#16146:ba#8192:fa#1024:\ + :pb#66976:\ + :pc#789958:bc#4096:fc#1024:\ + :pd#16146:bd#8192:fd#1024:\ + :pe#165646:be#4096:fe#1024:\ + :pf#165646:bf#4096:ff#1024:\ + :pg#706238:bg#4096:fg#1024:\ + :ph#358800:bh#4096:fh#1024: +rd7937|rd7937H|HP7937H:\ + :ty=winchester:ns#123:nt#13:nc#698:\ + :pa#15990:ba#8192:fa#1024:\ + :pb#67158:\ + :pc#1116102:bc#4096:fc#1024:\ + :pd#15990:bd#8192:fd#1024:\ + :pe#246246:be#4096:fe#1024:\ + :pf#246246:bf#4096:ff#1024:\ + :pg#1031355:bg#4096:fg#512:\ + :ph#522873:bh#4096:fh#1024: +rd9134|rd9134L|HP9134L:\ + :ty=winchester:ns#16:nt#5:nc#973:\ + :pa#15920:ba#8192:fa#1024:\ + :pb#20000:\ + :pc#77840:bc#4096:fc#1024\ + :pd#32000:\ + :pg#41840:bg#4096:fg#512:\ + :ph#29840:bh#4096:fh#512: +rd7936|rd7937H|HP7936H:\ + :ty=winchester:ns#123:nt#7:nc#698:\ + :pa#16359:ba#8192:fa#1024:\ + :pb#67158:\ + :pc#600978:bc#4096:fc#1024:\ + :pd#16359:bd#8192:fd#1024:\ + :pe#120540:be#4096:fe#1024:\ + :pf#120540:bf#4096:ff#1024:\ + :pg#516600:bg#4096:fg#512:\ + :ph#259161:bh#4096:fh#1024 +rd7957B|HP7957B:\ + :ty=winchester:ns#18:nt#7:nc#1269:\ + :pa#16002:ba#8192:fa#1024:\ + :pb#32760:\ + :pc#159894:bc#4096:fc#1024:\ + :pd#49140:\ + :pe#50400:be#4096:fe#512:\ + :pf#44226:bf#4096:ff#1024:\ + :pg#111006:bg#4096:fg#1024:\ + :ph#94626:bh#4096:fh#1024: +rd7958B|rd7962|rd7962B|HP7958B|HP7962B:\ + :ty=winchester:ns#42:nt#9:nc#786:\ + :pa#16254:ba#8192:fa#1024:\ + :pb#32886:\ + :pc#297108:bc#4096:fc#1024:\ + :pd#49140:\ + :pe#121716:be#4096:fe#512:\ + :pf#109620:bf#4096:ff#1024:\ + :pg#247590:bg#4096:fg#1024:\ + :ph#231336:bh#4096:fh#1024: +rd7959B|rd7963|rd7963B|HP7959B|HP7963B:\ + :ty=winchester:ns#42:nt#9:nc#1572:\ + :pa#16254:ba#8192:fa#1024:\ + :pb#49140:\ + :pc#594216:bc#4096:fc#1024:\ + :pd#65772:\ + :pe#303912:be#4096:fe#512:\ + :pf#207900:bf#4096:ff#1024:\ + :pg#528444:bg#4096:fg#1024:\ + :ph#511812:bh#4096:fh#1024: +rd335H|rd335|HP2200A|2200A|HP335H|HP6000/335H:\ + :ty=winchester:ns#113:nt#4:nc#1449:\ + :pa#16272:ba#8192:fa#1024:\ + :pb#49720:\ + :pc#654948:bc#4096:fc#1024:\ + :pd#65992:\ + :pe#304648:be#4096:fe#512:\ + :pf#267584:bf#4096:ff#1024:\ + :pg#588504:bg#4096:fg#1024:\ + :ph#572232:bh#4096:fh#1024: +rd670H|rd670|HP2203A|2203A|HP670H|HP6000/670H:\ + :ty=winchester:ns#113:nt#8:nc#1449:\ + :pa#16272:ba#8192:fa#1024:\ + :pb#67800:\ + :pc#1309896:bc#4096:fc#1024:\ + :pd#16272:\ + :pe#305552:be#4096:fe#512:\ + :pf#305552:bf#4096:ff#1024:\ + :pg#1224920:bg#4096:fg#1024:\ + :ph#597544:bh#4096:fh#1024: +# +# Utah derivatives +# +rd7937-utah|HP7937H with Utah partitions:\ + :ty=winchester:ns#123:nt#13:nc#698:\ + :pa#15990:ba#8192:fa#1024:\ + :pb#67158:\ + :pc#1116102:bc#4096:fc#1024:\ + :pd#124722:bd#8192:fd#1024:\ + :pe#163098:be#4096:fe#1024:\ + :pf#287820:bf#4096:ff#1024:\ + :pg#1031355:bg#4096:fg#512:\ + :ph#455715:bh#4096:fh#1024: +# +# Antiques +# +rd9134D|HP9134D:\ + :ty=winchester:ns#16:nt#6:nc#303:\ + :pa#15936:ba#8192:fa#1024:\ + :pb#13056:\ + :pc#29088:bc#8192:fc#1024: +rd9122|rd9122S|rd9122D|HP9122S|HP9122D:\ + :ty=winchester:ns#8:nt#2:nc#77:\ + :pc#1232:bc#8192:fc#1024: +rd7912|rd7912P|HP7912P:\ + :ty=winchester:ns#32:nt#7:nc#572:\ + :pa#15904:ba#8192:fa#1024:\ + :pb#22400:\ + :pc#128128:bc#4096:fc#1024:\ + :pd#42560:\ + :pg#89600:bg#4096:fg#1024:\ + :ph#69440:bh#4096:fh#1024: +rd7914|rd7914P|rd7914CT|HP7914P|HP7914CT:\ + :ty=winchester:ns#32:nt#7:nc#1152:\ + :pa#15904:ba#8192:fa#1024:\ + :pb#40320:\ + :pc#258048:bc#4096:fc#1024:\ + :pd#64960:\ + :pe#98560:be#4096:fe#512:\ + :pf#78400:bf#4096:ff#1024:\ + :pg#201600:bg#4096:fg#1024:\ + :ph#176960:bh#4096:fh#1024: +# +# SCSI disks +# Again, these mapping support three basic layouts: +# Again, these mapping support three basic layouts: +# +# A/B/G: This is the "traditional" setup for a bootable disk. +# A is the root partition, B the swap, and G is for /usr +# and users. +# A/D/E/F (large drives): +# A/D/H (small drives): +# This is a setup for bootable systems requiring more swap +# (e.g. those who need CL). It has A as the root, D as a +# larger swap, E and F (or H) as smaller user partitions. +# E could be used for /usr and F for users (or H for both). +# Or, E could be used for /var and F for /usr and users. +# C: This gives a single, non-bootable, large user filesystem. +# Good for second drives on a machine as either /usr/src +# or a large /usr or user partition. +# +# A/B/G: This is the "traditional" setup for a bootable disk. +# A is the root partition, B the swap, and G is for /usr +# and users. +# A/D/E/F (large drives): +# A/D/H (small drives): +# This is a setup for bootable systems requiring more swap +# (e.g. those who need CL). It has A as the root, D as a +# larger swap, E and F (or H) as smaller user partitions. +# E could be used for /usr and F for users (or H for both). +# Or, E could be used for /var and F for /usr and users. +# C: This gives a single, non-bootable, large user filesystem. +# Good for second drives on a machine as either /usr/src +# or a large /usr or user partition. +# +sd7958|sd7958-utah|HP7958S:\ + :ty=winchester:ns#32:nt#6:nc#1643:\ + :pa#16384:oa#1024:ba#8192:fa#1024:\ + :pb#65536:ob#17408:\ + :pc#315455:oc#0:bc#8192:fc#1024:\ + :pd#98304:od#17408:\ + :pe#102400:oe#115712:be#4096:fe#512:\ + :pf#97343:of#218112:bf#4096:ff#1024:\ + :pg#232511:og#82944:bg#8192:fg#1024:\ + :ph#199743:oh#115712:bh#8192:fh#1024: +sd7959|sd330|sd7959-utah|HP7959S:\ + :ty=winchester:ns#32:nt#12:nc#1643:\ + :pa#16384:oa#1024:ba#8192:fa#1024:\ + :pb#65536:ob#17408:\ + :pc#630911:oc#0:bc#8192:fc#1024:\ + :pd#98304:od#17408:\ + :pe#102400:oe#115712:be#4096:fe#512:\ + :pf#412799:of#218112:bf#4096:ff#1024:\ + :pg#547967:og#82944:bg#8192:fg#1024:\ + :ph#515199:oh#115712:bh#8192:fh#1024: +sd7548-utah|sd660|HP97548S with Utah partitions:\ + :ty=winchester:ns#56:nt#16:nc#1447:\ + :pa#16384:oa#1024:ba#8192:fa#1024:\ + :pb#65536:ob#17408:\ + :pc#1296511:oc#0:bc#8192:fc#1024:\ + :pd#98304:od#17408:\ + :pe#102400:oe#115712:be#4096:fe#512:\ + :pf#1078399:of#218112:bf#4096:ff#1024:\ + :pg#1213567:og#82944:bg#8192:fg#1024:\ + :ph#1180799:oh#115712:bh#8192:fh#1024: +# +# HP magneto-optical drive. +# (ns, nt, nc are totally bogus) +# actually 1K sectors +sd650-sony|mo650-sony|HP6300/650A Magneto-optical drive with Sony format:\ + :ty=optical:ns#61:nt#8:nc#1306:\ + :pa#16384:oa#1024:ba#8192:fa#1024:\ + :pb#65536:ob#17408:\ + :pc#637328:oc#0:bc#8192:fc#1024:\ + :pd#98304:od#17408:\ + :pe#102400:oe#115712:be#4096:fe#1024:\ + :pf#419216:of#218112:bf#4096:ff#1024:\ + :pg#554384:og#82944:bg#8192:fg#1024: +sd650|mo650|mo650-ansi|HP6300/650A Magneto-optical with ANSI format drive:\ + :ty=optical:ns#61:nt#8:nc#1306:\ + :pa#16384:oa#1024:ba#8192:fa#1024:\ + :pb#65536:ob#17408:\ + :pc#629136:oc#0:bc#8192:fc#1024:\ + :pd#98304:od#17408:\ + :pe#102400:oe#115712:be#4096:fe#1024:\ + :pf#411024:of#218112:bf#4096:ff#1024:\ + :pg#546192:og#82944:bg#8192:fg#1024: diff --git a/src/etc/etc.hp300/fstab.rd b/src/etc/etc.hp300/fstab.rd new file mode 100644 index 00000000..d797a9f3 --- /dev/null +++ b/src/etc/etc.hp300/fstab.rd @@ -0,0 +1,6 @@ +/dev/rd0a / ffs rw 1 1 +/dev/rd0e /usr ffs rw 1 2 +/dev/rd0f /var ffs rw 1 2 +/kern /kern kernfs ro 0 0 +/proc /proc procfs ro 0 0 +fdesc /dev fdesc ro,-o=union 0 0 diff --git a/src/etc/etc.hp300/fstab.sd b/src/etc/etc.hp300/fstab.sd new file mode 100644 index 00000000..737589e9 --- /dev/null +++ b/src/etc/etc.hp300/fstab.sd @@ -0,0 +1,6 @@ +/dev/sd0a / ffs rw 1 1 +/dev/sd0e /var ffs rw 1 2 +/dev/sd0f /usr ffs rw 1 2 +/kern /kern kernfs ro 0 0 +/proc /proc procfs ro 0 0 +fdesc /dev fdesc ro,-o=union 0 0 diff --git a/src/etc/etc.hp300/ttys b/src/etc/etc.hp300/ttys new file mode 100644 index 00000000..e0bed947 --- /dev/null +++ b/src/etc/etc.hp300/ttys @@ -0,0 +1,52 @@ +# $NetBSD: ttys,v 1.7 1995/09/30 22:03:02 thorpej Exp $ +# from: @(#)ttys 5.1 (Berkeley) 4/17/89 +# +# name getty type status comments +# +# If the console is marked insecure, single-user requires +# the root password. +console "/usr/libexec/getty Pc" hp300h on secure + +# Hardwired lines are marked off, by default, so getty(8) +# is quiet when they don't exist. +tty00 "/usr/libexec/getty std.9600" unknown off secure +tty01 "/usr/libexec/getty std.9600" unknown off secure +tty02 "/usr/libexec/getty std.9600" unknown off secure +tty03 "/usr/libexec/getty std.9600" unknown off secure +tty04 "/usr/libexec/getty std.9600" unknown off secure +tty05 "/usr/libexec/getty std.9600" unknown off secure +tty06 "/usr/libexec/getty std.9600" unknown off secure +tty07 "/usr/libexec/getty std.9600" unknown off secure + +ttyp0 none network +ttyp1 none network +ttyp2 none network +ttyp3 none network +ttyp4 none network +ttyp5 none network +ttyp6 none network +ttyp7 none network +ttyp8 none network +ttyp9 none network +ttypa none network +ttypb none network +ttypc none network +ttypd none network +ttype none network +ttypf none network +ttyq0 none network +ttyq1 none network +ttyq2 none network +ttyq3 none network +ttyq4 none network +ttyq5 none network +ttyq6 none network +ttyq7 none network +ttyq8 none network +ttyq9 none network +ttyqa none network +ttyqb none network +ttyqc none network +ttyqd none network +ttyqe none network +ttyqf none network diff --git a/src/etc/etc.i386/MAKEDEV b/src/etc/etc.i386/MAKEDEV new file mode 100644 index 00000000..60f88b01 --- /dev/null +++ b/src/etc/etc.i386/MAKEDEV @@ -0,0 +1,348 @@ +#!/bin/sh - +# +# Copyright (c) 1990 The Regents of the University of California. +# All rights reserved. +# +# Written and contributed by W. Jolitz 12/90 +# +# Redistribution and use in source and binary forms are permitted provided +# that: (1) source distributions retain this entire copyright notice and +# comment, and (2) distributions including binaries display the following +# acknowledgement: ``This product includes software developed by the +# University of California, Berkeley and its contributors'' in the +# documentation or other materials provided with the distribution and in +# all advertising materials mentioning features or use of this software. +# Neither the name of the University nor the names of its contributors may +# 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 +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +# +# @(#)MAKEDEV 5.2 (Berkeley) 6/22/90 +# +# Device "make" file. Valid arguments: +# all makes all known devices, including local devices. +# Tries to make the 'standard' number of each type. +# floppy devices to be put on install floppies +# std standard devices +# local configuration specific devices +# +# Tapes: +# wt* QIC-interfaced (e.g. not SCSI) 3M cartridge tape +# st* SCSI tapes +# +# Disks: +# wd* "winchester" disk drives (ST506,IDE,ESDI,RLL,...) +# fd* "floppy" disk drives (3 1/2", 5 1/4") +# sd* SCSI disks +# cd* SCSI CD-ROM +# mcd* Mitsumi CD-ROM +# vnd* "file" pseudo-disks +# ccd* contatenated disk devices +# +# Console ports: +# ttyv0 pccons or pcvt screen 0 +# ttyv* pcvt +# +# Pointing devices: +# mms* Microsoft bus mouse +# lms* Logitech bus mouse +# pms* PS/2 mouse +# mouse-* "mouse link" (XXX) +# +# Terminal ports: +# com* standard PC COM ports (XXX) +# tty* alias for PC COM ports, this is what the system really wants +# +# Pseudo terminals: +# pty* set of 16 master and slave pseudo terminals +# +# Printers: +# lpt* stock lp +# lpa* interruptless lp +# +# Call units: +# +# Special purpose devices: +# fd file descriptors +# bpf* packet filter +# speaker pc speaker (XXX - installed) +# lkm loadable kernel modules interface +# audio audio device +# tun* network tunnel driver +# + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +umask 77 +for i +do +case $i in + +all) + sh MAKEDEV std fd wt0 fd0 fd1 wd0 wd1 sd0 sd1 sd2 tty0 tty1 pty0 pty1 + sh MAKEDEV st0 st1 ch0 cd0 cd1 mcd0 vnd0 vnd1 lpa0 lpa1 + sh MAKEDEV ccd0 ccd1 ccd2 ccd3 + sh MAKEDEV lpt0 lpt1 lpt2 ttyv0 bpf0 bpf1 bpf2 bpf3 tun0 tun1 tun2 + sh MAKEDEV speaker lkm mms0 lms0 pms0 audio local +# MISSING: +# sh MAKEDEV mouse-? + ;; + +floppy) + sh MAKEDEV std wt0 fd0 fd1 wd0 wd1 sd0 sd1 sd2 tty0 tty1 + sh MAKEDEV st0 st1 cd0 cd1 mcd0 ttyv0 + ;; + +std) + rm -f console drum mem kmem null zero io tty klog stdin stdout stderr + mknod console c 0 0 + mknod drum c 4 0 ; chmod 640 drum ; chgrp kmem drum + mknod kmem c 2 1 ; chmod 640 kmem ; chgrp kmem kmem + mknod mem c 2 0 ; chmod 640 mem ; chgrp kmem mem + mknod null c 2 2 ; chmod 666 null + mknod zero c 2 12 ; chmod 666 zero + mknod io c 2 14 ; chmod 640 io ; chgrp kmem io + mknod tty c 1 0 ; chmod 666 tty + mknod klog c 7 0 ; chmod 600 klog + mknod stdin c 22 0 ; chmod 666 stdin + mknod stdout c 22 1 ; chmod 666 stdout + mknod stderr c 22 2 ; chmod 666 stderr + ;; + +ttyv*) + unit=`expr $i : 'ttyv\(.*\)'` + rm -f ttyv$unit + mknod ttyv$unit c 12 $unit + chown root.wheel ttyv$unit + case $unit in + 0) + rm -f vga + ln -s ttyv0 vga + ;; + esac + ;; + +fd) + rm -f fd/* + mkdir fd > /dev/null 2>&1 + (cd fd && eval `echo "" | awk ' BEGIN { \ + for (i = 0; i < 64; i++) \ + printf("mknod %d c 22 %d;", i, i)}'`) + chown -R bin.bin fd + chmod 555 fd + chmod 666 fd/* + ;; + +wt*) + umask 2 + rm -f wt0 rwt0 + mknod wt0 b 3 0; chown root.operator wt0 + mknod rwt0 c 10 0; chown root.operator rwt0 + umask 77 + ;; + +ccd*|fd*|sd*|vnd*|wd*) + umask 2 ; unit=`expr $i : '.*d\(.*\)'` + case $i in + ccd*) name=ccd; blk=16; chr=18;; + fd*) name=fd; blk=2; chr=9;; + sd*) name=sd; blk=4; chr=13;; + vnd*) name=vnd; blk=14; chr=41;; + wd*) name=wd; blk=0; chr=3;; + esac + rm -f $name$unit? r$name$unit? + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1` + mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4` + mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5` + mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6` + mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1` + mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4` + mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5` + mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6` + mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + umask 77 + ;; + +com*|tty*) # (XXX -- com should die) + unit=`expr $i : '...\(.*\)'` + rm -f com$unit tty0$unit + mknod tty0$unit c 8 $unit + chown uucp.wheel tty0$unit + ;; + +pty*) + class=`expr $i : 'pty\(.*\)'` + case $class in + 0) offset=0 name=p;; + 1) offset=16 name=q;; + 2) offset=32 name=r;; + 3) offset=48 name=s;; +# Note that telnetd, rlogind, and xterm (at least) only look at p-s. + 4) offset=64 name=t;; + *) echo bad unit for pty in: $i;; + esac + case $class in + 0|1|2|3|4) + umask 0 + eval `echo $offset $name | awk ' { b=$1; n=$2 } END { + for (i = 0; i < 16; i++) + printf("rm -f tty%s%x; mknod tty%s%x c 5 %d; \ + rm -f pty%s%x; mknod pty%s%x c 6 %d; ", \ + n, i, n, i, b+i, n, i, n, i, b+i); }'` + umask 77 + ;; + esac + ;; + +st*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + st*) name=st; chr=14; blk=5;; + esac + rm -f $name$unit n$name$unit e$name$unit en$name$unit \ + r$name$unit nr$name$unit er$name$unit enr$name$unit + mknod ${name}${unit} b $blk `expr $unit '*' 16 + 0` + mknod n${name}${unit} b $blk `expr $unit '*' 16 + 1` + mknod e${name}${unit} b $blk `expr $unit '*' 16 + 2` + mknod en${name}${unit} b $blk `expr $unit '*' 16 + 3` + mknod r${name}${unit} c $chr `expr $unit '*' 16 + 0` + mknod nr${name}${unit} c $chr `expr $unit '*' 16 + 1` + mknod er${name}${unit} c $chr `expr $unit '*' 16 + 2` + mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3` + chgrp operator ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + chmod 640 ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + umask 77 + ;; + +ch*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + ch*) name=ch; chr=17;; + esac + rm -f $name$unit + mknod ${name}${unit} c $chr `expr $unit '*' 16 + 0` + chgrp operator ${name}${unit} + chmod 640 ${name}${unit} + umask 77 + ;; + +cd*|mcd*) + umask 2 ; unit=`expr $i : '.*cd\(.*\)'` + case $i in + cd*) name=cd; blk=6; chr=15;; + mcd*) name=mcd; blk=7; chr=39;; + esac + rm -f $name$unit? r$name$unit? + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + umask 77 + ;; + +lpa*) + unit=`expr $i : 'lpa\(.*\)'` + rm -f lpa$unit + mknod lpa$unit c 16 `expr $unit + 128` + chown root.wheel lpa$unit + ;; + +lpt*) + unit=`expr $i : 'lpt\(.*\)'` + rm -f lpt$unit + mknod lpt$unit c 16 $unit + chown root.wheel lpt$unit + ;; + +bpf*) + unit=`expr $i : 'bpf\(.*\)'` + rm -f bpf$unit + mknod bpf$unit c 23 $unit + chown root.wheel bpf$unit + ;; + +tun*) + unit=`expr $i : 'tun\(.*\)'` + rm -f tun$unit + mknod tun$unit c 40 $unit + chmod 600 tun$unit + chown root.wheel tun$unit + ;; + +speaker) # (XXX - installed) + rm -f speaker + mknod speaker c 27 0 + chown root.wheel speaker + ;; + +lkm) + rm -f lkm + mknod lkm c 28 0 + chown root.kmem lkm + chmod 640 lkm + ;; + +mms*) + unit=`expr $i : 'mms\(.*\)'` + rm -f mms$unit + mknod mms$unit c 35 $unit + chown root.wheel mms$unit + ;; + +lms*) + unit=`expr $i : 'lms\(.*\)'` + rm -f lms$unit + mknod lms$unit c 36 $unit + chown root.wheel lms$unit + ;; + +pms*) + unit=`expr $i : 'pms\(.*\)'` + rm -f pms$unit + mknod pms$unit c 37 $unit + chown root.wheel pms$unit + ;; + +mouse*) # (XXX) + name=`expr $i : 'mouse-\(.*\)'` + if [ ! -c $name ]; then + $0 $name # make the appropriate device + fi + rm -f mouse + ln -s $name mouse + ;; + +audio*) + rm -f audio sound mixer + mknod sound c 42 0 + mknod audio c 42 128 + mknod mixer c 42 16 + chown root.wheel audio sound mixer + chmod 666 audio sound mixer + ;; + +local) + umask 0 + sh MAKEDEV.local + ;; + +esac +done diff --git a/src/etc/etc.i386/Makefile.inc b/src/etc/etc.i386/Makefile.inc new file mode 100644 index 00000000..ded97957 --- /dev/null +++ b/src/etc/etc.i386/Makefile.inc @@ -0,0 +1,38 @@ +# +# etc.i386/Makefile.inc -- i386-specific etc Makefile targets +# +# $Id: Makefile.inc,v 1.1.1.1 1995/10/18 08:38:00 deraadt Exp $ + +.ifdef DESTDIR +snap_md: netbsd-aha netbsd-bt +#snap_md: kc_aha.fs kc_bt.fs + +netbsd-aha: + cd ${.CURDIR}/../sys/arch/i386/conf && config GENERICAHA + cd ${.CURDIR}/../sys/arch/i386/compile/GENERICAHA && \ + make clean && make depend && make + cp ${.CURDIR}/../sys/arch/i386/compile/GENERICAHA/netbsd \ + ${DESTDIR}/snapshot/netbsd-aha + +netbsd-bt: + cd ${.CURDIR}/../sys/arch/i386/conf && config GENERICBT + cd ${.CURDIR}/../sys/arch/i386/compile/GENERICBT && \ + make clean && make depend && make + cp ${.CURDIR}/../sys/arch/i386/compile/GENERICBT/netbsd \ + ${DESTDIR}/snapshot/netbsd-bt + +kc_aha.fs: + make -f ${.CURDIR}/etc.i386/Makefile.kc \ + IMAGE=${DESTDIR}/snapshot/kc_aha.fs \ + KERNEL=${DESTDIR}/snapshot/netbsd-aha || \ + make -f ${.CURDIR}/etc.i386/Makefile.kc \ + IMAGE=${DESTDIR}/snapshot/kc_aha.fs unconfig + +kc_bt.fs: + make -f ${.CURDIR}/etc.i386/Makefile.kc \ + IMAGE=${DESTDIR}/snapshot/kc_bt.fs \ + KERNEL=${DESTDIR}/snapshot/netbsd-bt || \ + make -f ${.CURDIR}/etc.i386/Makefile.kc \ + IMAGE=${DESTDIR}/snapshot/kc_bt.fs unconfig + +.endif # DESTDIR check diff --git a/src/etc/etc.i386/Makefile.kc b/src/etc/etc.i386/Makefile.kc new file mode 100644 index 00000000..3a179b28 --- /dev/null +++ b/src/etc/etc.i386/Makefile.kc @@ -0,0 +1,52 @@ +# $Id: Makefile.kc,v 1.1.1.1 1995/10/18 08:38:00 deraadt Exp $ + +.ifndef MOUNT_POINT +MOUNT_POINT= /mnt +.endif +.if !defined(VND_DEV) || !defined(VND_DEV) +VND_DEV= /dev/vnd0a +VND_RDEV= /dev/rvnd0a +.endif + +ROOTDIRLIST= / /bin /dev /instbin /mnt /sbin /usr +BINDIRLIST= /usr/bin +FLOPPYBINS= fsck init mount reboot sh tar test umount + +all: +.if !defined(IMAGE) || !defined(KERNEL) + @echo both IMAGE and KERNEL must be defined + @false +.else + dd if=/dev/zero of=${IMAGE} bs=100k count=12 + vnconfig -c ${VND_DEV} ${IMAGE} + disklabel -r -w ${VND_DEV} floppy5 \ + ${DESTDIR}/usr/mdec/fdboot ${DESTDIR}/usr/mdec/bootfd + newfs -m 0 -o space -i 6144 -c 80 ${VND_DEV} floppy5 + mount ${VND_DEV} ${MOUNT_POINT} + for d in ${ROOTDIRLIST} ; do \ + install -d -o root -g wheel -m 755 ${MOUNT_POINT}$$d ; \ + done + for d in ${BINDIRLIST} ; do \ + install -d -o ${BINOWN} -g ${BINGRP} -m 755 ${MOUNT_POINT}$$d ; \ + done + cp ${KERNEL} ${MOUNT_POINT} + cp ${.CURDIR}/etc.i386/MAKEDEV ${MOUNT_POINT}/dev + (cd ${MOUNT_POINT}/dev; sh MAKEDEV floppy) + for b in ${FLOPPYBINS} ; do \ + ( cd ${.CURDIR}/../sys/arch/i386/floppy/$$b ; \ + make DESTDIR=${MOUNT_POINT} install ) ; \ + done + set -- `grep -v '^#' ${.CURDIR}/etc.i386/files.kc/list`; \ + while [ $$# -ge 2 ]; do \ + from=$$1; shift; \ + to=$$1; shift; \ + cp ${.CURDIR}/etc.i386/files.kc/$$from ${MOUNT_POINT}/$$to; \ + done + umount ${MOUNT_POINT} + vnconfig -u ${VND_DEV} ${IMAGE} +.endif + +unconfig: + -umount -f ${MOUNT_POINT} + -vnconfig -u ${VND_DEV} ${IMAGE} + -/bin/rm -f ${IMAGE} diff --git a/src/etc/etc.i386/disktab b/src/etc/etc.i386/disktab new file mode 100644 index 00000000..44d0a970 --- /dev/null +++ b/src/etc/etc.i386/disktab @@ -0,0 +1,119 @@ +# Disk geometry and partition layout tables. +# Key: +# dt controller type +# ty type of disk (fixed, removeable, simulated) +# d[0-4] drive-type-dependent parameters +# ns #sectors/track +# nt #tracks/cylinder +# nc #cylinders/disk +# sc #sectors/cylinder, ns*nt default +# su #sectors/unit, sc*nc default +# se sector size, DEV_BSIZE default +# rm rpm, 3600 default +# sf supports bad144-style bad sector forwarding +# sk sector skew per track, default 0 +# cs sector skew per cylinder, default 0 +# hs headswitch time, default 0 +# ts one-cylinder seek time, default 0 +# il sector interleave (n:1), 1 default +# bs boot block size, default BBSIZE +# sb superblock size, default SBSIZE +# o[a-h] partition offsets in sectors +# p[a-h] partition sizes in sectors +# b[a-h] partition block sizes in bytes +# f[a-h] partition fragment sizes in bytes +# t[a-h] partition types (filesystem, swap, etc) +# +# All partition sizes reserve space for bad sector tables. +# (5 cylinders needed for maintenance + replacement sectors) +# +qp120at|Quantum Peripherals 120MB IDE:\ + :dt=ESDI:ty=winchester:se#512:nt#9:ns#32:nc#813:sf: \ + :pa#13824:oa#0:ta=4.2BSD:ba#4096:fa#512: \ + :pb#13824:ob#13824:tb=swap: \ + :pc#234144:oc#0: \ + :ph#206496:oh#27648:th=4.2BSD:bh#4096:fh#512: + +pan60|Panasonic Laptop's 60MB IDE:\ + :dt=ST506:ty=winchester:se#512:nt#13:ns#17:nc#565:\ + :pa#13260:oa#0:ta=4.2BSD:ba#4096:fa#512:\ + :pb#13260:ob#13260:tb=swap: \ + :pc#124865:oc#0: \ + :ph#97682:oh#26520:th=4.2BSD:bh#4096:fh#512: + +mk156|toshiba156|Toshiba MK156 156Mb:\ + :dt=SCSI:ty=winchester:se#512:nt#10:ns#35:nc#825:\ + :pa#15748:oa#0:ba#4096:fa#512:ta=4.2BSD:\ + :pb#15748:ob#15748:tb=swap:\ + :pc#288750:oc#0:\ + :ph#257250:oh#31500:bh#4096:fh#512:th=4.2BSD: + +cp3100|Conner Peripherals 100MB IDE:\ + :dt=ST506:ty=winchester:se#512:nt#8:ns#33:nc#766: \ + :pa#12144:oa#0:ta=4.2BSD:ba#4096:fa#512: \ + :pb#12144:ob#12144:tb=swap: \ + :pc#202224:oc#0: \ + :ph#177936:oh#24288:th=4.2BSD:bh#4096:fh#512: + +# a == root +# b == swap +# c == d == whole disk +# e == /var +# f == scratch +# h == /usr + +cp3100new|Conner Peripherals 100MB IDE, with a different configuration:\ + :dt=ST506:ty=winchester:se#512:nt#8:ns#33:nc#766: \ + :pa#15840:oa#0:ta=4.2BSD:ba#4096:fa#512: \ + :pb#24288:ob#15840:tb=swap: \ + :pc#202224:oc#0: \ + :pd#202224:od#0: \ + :pe#15840:oe#40128:te=4.2BSD:be#4096:fe#512: \ + :pg#15840:og#55968:tg=4.2BSD:bg#4096:fg#512: \ + :ph#130416:oh#71808:th=4.2BSD:bh#4096:fh#512: + +floppy|floppy3|3in|3.5in High Density Floppy:\ + :ty=floppy:se#512:nt#2:rm#300:ns#18:nc#80:\ + :pa#2880:oa#0:ba#4096:fa#512:\ + :pb#2880:ob#0:\ + :pc#2880:oc#0: + +floppy5|5in|5.25in High Density Floppy:\ + :ty=floppy:se#512:nt#2:rm#300:ns#15:nc#80:\ + :pa#2400:oa#0:ba#4096:fa#512:\ + :pb#2400:ob#0:bb#4096:fb#512:\ + :pc#2400:oc#0:bc#4096:fc#512: + +maxtor4380|Maxtor XT4380E ESDI :\ + :dt=ESDI:ty=winchester:se#512:nt#15:ns#36:nc#1222:sf: \ + :pa#21600:oa#0:ta=4.2BSD:ba#4096:fa#512:\ + :pb#21600:ob#21600:tb=swap: \ + :pc#659880:oc#0: \ + :pd#216000:od#53200:td=4.2BSD:bd#4096:fd#512: \ + :ph#398520:oh#269200:th=4.2BSD:bh#4096:fh#512: + +miniscribe9380|compaq38|Miniscribe 9380 ESDI :\ + :ty=winchester:dt=ESDI:se#512:nt#15:ns#35:nc#1223:rm#3600:sf: \ + :pa#21000:oa#0:ba#8192:fa#1024:ta=4.2BSD: \ + :pb#42000:ob#21000:tb=swap: \ + :pc#642075:oc#0: \ + :pd#21000:od#63000:bd#8192:fd#1024:td=4.2BSD: \ + :ph#556500:oh#84000:bh#8192:fh#1024:th=4.2BSD: + +ida4|compaq88|Compaq IDA (4 drives) :\ + :ty=winchester:dt=IDA:se#512:nt#16:ns#63:nc#1644:rm#3600:\ + :pa#20160:oa#0:ba#8192:fa#1024:ta=4.2BSD: \ + :pb#80640:ob#20160:tb=swap: \ + :pc#1659168:oc#0: \ + :pd#201600:od#100800:bd#8192:fd#1024:td=4.2BSD: \ + :pe#20160:oe#1310400:be#8192:fe#1024:te=4.2BSD: \ + :ph#1008000:oh#302400:bh#8192:fh#1024:th=4.2BSD: \ + :pg#302400:og#1330560:bg#4096:fg#512:tg=4.2BSD: + +fuji513|Fujitsu M22XXXX: \ + :ty=winchester:dt=ESDI:se#512:nt#16:ns#63:nc#954:rm#3600:\ + :pa#20160:oa#82656:ba#4096:fa#512:ta=4.2BSD: \ + :pb#40320:ob#102816:tb=swap: \ + :pc#961632:oc#0: \ + :ph#656208:oh#143136:bh#4096:fh#512:th=4.2BSD: + diff --git a/src/etc/etc.i386/files.kc/copy_kernel b/src/etc/etc.i386/files.kc/copy_kernel new file mode 100644 index 00000000..98b86477 --- /dev/null +++ b/src/etc/etc.i386/files.kc/copy_kernel @@ -0,0 +1,113 @@ +# $Id: copy_kernel,v 1.1.1.1 1995/10/18 08:38:00 deraadt Exp $ +# +# Kernel copy script + +DEFAULT_PARTITON=sd0a +MOUNT_POINT=/mnt +KERNEL_NAME=/netbsd +#TEST=testfn + +testfn() { + echo $* + sleep 5 +} + +cancel() { + echo "" + echo "Copy cancelled." + exit 1 +} + +umountfs() { + echo "Unmounting filesystem; please wait." + trap 2 3 + ${TEST} umount ${MOUNT_POINT} + case $? in + 0) + ;; + *) + echo "Warning: Unmount of ${MOUNT_POINT} failed." + ;; + esac +} + +warning() { + echo "" + echo "Copy failed or was interrupted." + echo "Warning: Copied kernel my be corrupted!" +} + +trap "cancel;" 2 3 +echo "NetBSD kernel copy program" +echo "" +echo "Default answers are displayed in brackets. You may hit Control-C" +echo "at any time to cancel this operation (though if you hit Control-C at" +echo "a prompt, you need to hit return for it to be noticed)." + +echo "" +echo "What disk partition should the kernel be installed on?" +echo "(For example, \"sd0a\", \"wd0a\", etc.)" +echo "" +echo -n "Partition? [${DEFAULT_PARTITON}] " +read diskpart +if [ "X${diskpart}" = "X" ]; then + diskpart=${DEFAULT_PARTITON} +fi +rawdiskpart="r${diskpart}" + +echo "" +echo -n "Are you sure you want to copy a new kernel to ${diskpart}? [n] " +read reply +case ${reply} in +y*|Y*) + ;; +*) + cancel + ;; +esac + +echo "" +echo "Checking ${diskpart} partition; please wait." +${TEST} fsck -p "/dev/${rawdiskpart}" +case $? in +0) + ;; +*) + echo "File system check failed or aborted!" + cancel + ;; +esac + +echo "Mounting /dev/${diskpart} on ${MOUNT_POINT}." +trap "echo ''; umountfs; cancel;" 2 3 +${TEST} mount "/dev/${diskpart}" ${MOUNT_POINT} +case $? in +0) + ;; +*) + echo "Mount failed!" + cancel + ;; +esac + +echo "Copying kernel to ${MOUNT_POINT}." +trap "warning; umountfs; cancel;" 2 3 +${TEST} cp ${KERNEL_NAME} ${MOUNT_POINT} +case $? in +0) + ;; +*) + warning + umountfs + cancel + ;; +esac + +umountfs + +echo "" +echo "Copy completed." +echo "" +echo "Use \"halt\" to halt the system, then (when the system is halted)" +echo "eject the floppy disk and hit any key to reboot from the hard disk." +exit 0 diff --git a/src/etc/etc.i386/files.kc/dot.profile b/src/etc/etc.i386/files.kc/dot.profile new file mode 100644 index 00000000..8c845855 --- /dev/null +++ b/src/etc/etc.i386/files.kc/dot.profile @@ -0,0 +1,8 @@ +# $Id: dot.profile,v 1.1.1.1 1995/10/18 08:38:00 deraadt Exp $ + +PATH=/sbin:/bin:/instbin +export PATH + +echo "Enter 'copy_kernel' at the prompt to copy a kernel to your hard disk," +echo "'reboot' to reboot the system, or 'halt' to halt the system." +echo "" diff --git a/src/etc/etc.i386/files.kc/list b/src/etc/etc.i386/files.kc/list new file mode 100644 index 00000000..2f6458a1 --- /dev/null +++ b/src/etc/etc.i386/files.kc/list @@ -0,0 +1,2 @@ +dot.profile .profile +copy_kernel instbin/copy_kernel diff --git a/src/etc/etc.i386/fstab.wd b/src/etc/etc.i386/fstab.wd new file mode 100644 index 00000000..5f4355b2 --- /dev/null +++ b/src/etc/etc.i386/fstab.wd @@ -0,0 +1,3 @@ +/dev/wd0a / ffs rw 1 1 +#/dev/wd0d /var ffs rw 1 2 +#/dev/wd0h /usr ffs rw 1 3 diff --git a/src/etc/etc.i386/ttys b/src/etc/etc.i386/ttys new file mode 100644 index 00000000..5193bdf9 --- /dev/null +++ b/src/etc/etc.i386/ttys @@ -0,0 +1,48 @@ +# +# from: @(#)ttys 5.1 (Berkeley) 4/17/89 +# $Id: ttys,v 1.1.1.1 1995/10/18 08:38:00 deraadt Exp $ +# +# name getty type status comments +# +console "/usr/libexec/getty Pc" pc3 off secure +ttyv0 "/usr/libexec/getty Pc" pc3 on secure +tty00 "/usr/libexec/getty std.9600" unknown off secure +tty01 "/usr/libexec/getty std.9600" unknown off secure +tty02 "/usr/libexec/getty std.9600" unknown off secure +tty03 "/usr/libexec/getty std.9600" unknown off secure +tty04 "/usr/libexec/getty std.9600" unknown off secure +tty05 "/usr/libexec/getty std.9600" unknown off secure +tty06 "/usr/libexec/getty std.9600" unknown off secure +tty07 "/usr/libexec/getty std.9600" unknown off secure +ttyp0 none network +ttyp1 none network +ttyp2 none network +ttyp3 none network +ttyp4 none network +ttyp5 none network +ttyp6 none network +ttyp7 none network +ttyp8 none network +ttyp9 none network +ttypa none network +ttypb none network +ttypc none network +ttypd none network +ttype none network +ttypf none network +ttyq0 none network +ttyq1 none network +ttyq2 none network +ttyq3 none network +ttyq4 none network +ttyq5 none network +ttyq6 none network +ttyq7 none network +ttyq8 none network +ttyq9 none network +ttyqa none network +ttyqb none network +ttyqc none network +ttyqd none network +ttyqe none network +ttyqf none network diff --git a/src/etc/etc.mac68k/MAKEDEV b/src/etc/etc.mac68k/MAKEDEV new file mode 100644 index 00000000..a4171bf6 --- /dev/null +++ b/src/etc/etc.mac68k/MAKEDEV @@ -0,0 +1,326 @@ +#!/bin/sh - +# +# Copyright (c) 1990 The Regents of the University of California. +# All rights reserved. +# +# Written and contributed by W. Jolitz 12/90 +# +# Redistribution and use in source and binary forms are permitted provided +# that: (1) source distributions retain this entire copyright notice and +# comment, and (2) distributions including binaries display the following +# acknowledgement: ``This product includes software developed by the +# University of California, Berkeley and its contributors'' in the +# documentation or other materials provided with the distribution and in +# all advertising materials mentioning features or use of this software. +# Neither the name of the University nor the names of its contributors may +# 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 +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +# +# from: @(#)MAKEDEV 5.2 (Berkeley) 6/22/90 +# $NetBSD: MAKEDEV,v 1.16 1995/10/09 02:19:36 thorpej Exp $ +# +# Device "make" file. Valid arguments: +# all a smattering--at least one of each except +# fd* (unimp.) and ch* +# +# std standard devices +# fd file descriptor device nodes +# local configuration specific devices +# raminst for RAM disk install +# +# Tapes: +# st* scsi tapes +# +# Disks: +# fd* floppy disk drives (3 1/2") (unimp.) +# sd* SCSI disks +# cd* SCSI compact discs +# ch* SCSI changers +# vnd* vnode pseudo-disks +# ccd* concatenated disk driver +# +# Terminal ports: +# ttye* ite consoles +# tty* standard built-in serial ports (2) +# +# Pseudo terminals: +# pty* set of 16 master and slave pseudo terminals +# +# Graphics devices: +# grf* Bitmapped graphics device +# +# Special purpose devices: +# bpf* packet filter +# tun* network tunnel driver +# lkm Device to for loadable kernel modules +# + +PATH=/sbin:/bin/:/usr/bin:/usr/sbin +umask 77 +for i +do +case $i in + +all) + sh MAKEDEV std fd + sh MAKEDEV sd0 sd1 sd2 sd3 st0 st1 cd0 cd1 + sh MAKEDEV vnd0 vnd1 vnd2 vnd3 + sh MAKEDEV ccd0 ccd1 ccd2 ccd3 + sh MAKEDEV adb grf0 grf1 ttye0 + sh MAKEDEV tty00 tty01 pty0 + sh MAKEDEV bpf0 bpf1 bpf2 bpf3 bpf4 bpf5 bpf6 bpf7 + sh MAKEDEV bpf8 bpf9 bpfa bpfb + sh MAKEDEV tun0 tun1 tun2 tun3 + sh MAKEDEV lkm + sh MAKEDEV local + ;; + +raminst) + sh MAKEDEV std + sh MAKEDEV sd0 sd1 sd2 sd3 st0 st1 cd0 cd1 + sh MAKEDEV adb grf0 grf1 ttye0 + sh MAKEDEV tty00 tty01 pty0 + ;; + +std) + rm -f console drum kmem mem reload zero null tty + rm -f klog stdin stdout stderr + mknod console c 0 0 + mknod drum c 3 0 ; chmod 640 drum ; chgrp kmem drum + mknod kmem c 2 1 ; chmod 640 kmem ; chgrp kmem kmem + mknod mem c 2 0 ; chmod 640 mem ; chgrp kmem mem + mknod reload c 2 20 ; chmod 640 reload ; chgrp kmem reload + mknod zero c 2 12 ; chmod 666 zero + mknod null c 2 2 ; chmod 666 null + mknod tty c 1 0 ; chmod 666 tty + mknod klog c 6 0 ; chmod 600 klog + mknod stdin c 21 0 ; chmod 666 stdin + mknod stdout c 21 1 ; chmod 666 stdout + mknod stderr c 21 2 ; chmod 666 stderr + ;; + +fd) + rm -f fd/* + mkdir fd > /dev/null 2>&1 + (cd fd && eval `echo "" | awk ' BEGIN { \ + for (i = 0; i < 64; i++) \ + printf("mknod %d c 21 %d;", i, i)}'`) + chown -R bin.bin fd + chmod 555 fd + chmod 666 fd/* + ;; + +sd*|vnd*|ccd*) + umask 2 ; unit=`expr $i : '.*[^0-9]\([0-9]*\)'` + case $i in + sd*) name=sd; blk=4; chr=13;; + vnd*) name=vnd; blk=8; chr=19;; + ccd*) name=ccd; blk=9; chr=20;; + esac + rm -f $name$unit? r$name$unit? + case $unit in + 0|1|2|3|4|5|6) + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1` + mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4` + mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5` + mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6` + mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1` + mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4` + mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5` + mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6` + mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + ;; + *) + echo bad unit for disk in: $i + ;; + esac + umask 77 + ;; + +tty0*) + unit=`expr $i : 'tty0\(.*\)'` + rm -f ser${unit} tty${unit} tty0${unit} + case ${unit} in + 0|1) + mknod tty0${unit} c 12 ${unit} + chown uucp.wheel tty0${unit} + ;; + *) + echo bad unit for serial tty in: $i + ;; + esac + ;; + +ttye*) + unit=`expr $i : 'ttye\(.*\)'` + rm -f ttye${unit} + rm -f ite* + case $unit in + 0|1) + mknod ttye${unit} c 11 ${unit} + ;; + *) + echo bad unit for ttye in: $i + ;; + esac + ;; + +pty*) + class=`expr $i : 'pty\(.*\)'` + case $class in + 0) offset=0 name=p;; + 1) offset=16 name=q;; + 2) offset=32 name=r;; + 3) offset=48 name=s;; +# Note that telnetd, rlogind, and xterm (at least) only look at p-s. + 4) offset=64 name=t;; + *) echo bad unit for pty in: $i;; + esac + case $class in + 0|1|2|3|4) + umask 0 + eval `echo $offset $name | awk ' { b=$1; n=$2 } END { + for (i = 0; i < 16; i++) + printf("rm -f tty%s%x; mknod tty%s%x c 4 %d; \ + rm -f pty%s%x; mknod pty%s%x c 5 %d; ", \ + n, i, n, i, b+i, n, i, n, i, b+i); }'` + umask 77 + ;; + esac + ;; + +st*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + st*) name=st; chr=14; blk=5;; + esac + rm -f $name$unit n$name$unit e$name$unit en$name$unit \ + r$name$unit nr$name$unit er$name$unit enr$name$unit + case $unit in + 0|1|2|3|4|5|6) + mknod ${name}${unit} b $blk `expr $unit '*' 16 + 0` + mknod n${name}${unit} b $blk `expr $unit '*' 16 + 1` + mknod e${name}${unit} b $blk `expr $unit '*' 16 + 2` + mknod en${name}${unit} b $blk `expr $unit '*' 16 + 3` + mknod r${name}${unit} c $chr `expr $unit '*' 16 + 0` + mknod nr${name}${unit} c $chr `expr $unit '*' 16 + 1` + mknod er${name}${unit} c $chr `expr $unit '*' 16 + 2` + mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3` + chgrp operator ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + chmod 640 ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + ;; + *) + echo bad unit for tape in: $i + ;; + esac + umask 77 + ;; + +ch*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + ch*) name=ch; chr=17;; + esac + rm -f $name$unit + case $unit in + 0|1|2|3|4|5|6) + mknod ${name}${unit} c $chr `expr $unit '*' 16 + 0` + chgrp operator ${name}${unit} + chmod 640 ${name}${unit} + ;; + *) + echo bad unit for media changer in: $i + ;; + esac + umask 77 + ;; + +cd*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + cd*) name=cd; blk=6; chr=15;; + esac + rm -f $name$unit? r$name$unit? + case $unit in + 0|1|2|3|4|5|6) + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + ;; + *) + echo bad unit for disk in: $i + ;; + esac + umask 77 + ;; + +grf*) + unit=`expr $i : 'grf\(.*\)'` + rm -f grf${unit} + case ${unit} in + 0|1) + mknod grf${unit} c 10 ${unit} ; chmod 666 grf${unit} + ;; + *) + echo bad unit for grf in: $i + ;; + esac + ;; + +adb) + rm -f adb + mknod adb c 23 0 ; chmod 666 adb + ;; + +bpf*) + unit=`expr $i : 'bpf\(.*\)'` + rm -f bpf${unit} + mknod bpf${unit} c 22 ${unit} + chown root.wheel bpf${unit} + ;; + +tun*) + unit=`expr $i : 'tun\(.*\)'` + rm -f tun$unit + mknod tun$unit c 24 $unit + chmod 600 tun$unit + chown root.wheel tun$unit + ;; + +lkm) + rm -f lkm + mknod lkm c 25 0 + chown root.kmem lkm + chmod 640 lkm + ;; + +local) + umask 0 + sh MAKEDEV.local + ;; + +*) + echo $i: unknown device +esac +done diff --git a/src/etc/etc.mac68k/disktab b/src/etc/etc.mac68k/disktab new file mode 100644 index 00000000..7f18d7b2 --- /dev/null +++ b/src/etc/etc.mac68k/disktab @@ -0,0 +1,116 @@ +# $NetBSD: disktab,v 1.3 1995/10/09 02:19:38 thorpej Exp $ +# @(#)disktab 5.5 (Berkeley) 2/27/91 +# +# Disk geometry and partition layout tables. +# Key: +# ty type of disk +# ns #sectors/track +# nt #tracks/cylinder +# nc #cylinders/disk +# rm rpm, 3600 default +# se sector size, 512 default +# sf supports bad144-style bad sector forwarding +# so partition offsets in sectors +# p[a-h] partition sizes in sectors +# b[a-h] partition block sizes in bytes +# f[a-h] partition fragment sizes in bytes +# +# All partition sizes contain space +# for bad sector tables unless the +# device drivers fail to support this. +# +# Entries may also be used for other compatible drives +# with the same geometry. + +# +# SCSI disks +# Again, these mapping support three basic layouts: +# Again, these mapping support three basic layouts: +# +# A/B/G: This is the "traditional" setup for a bootable disk. +# A is the root partition, B the swap, and G is for /usr +# and users. +# A/D/E/F (large drives): +# A/D/H (small drives): +# This is a setup for bootable systems requiring more swap +# (e.g. those who need CL). It has A as the root, D as a +# larger swap, E and F (or H) as smaller user partitions. +# E could be used for /usr and F for users (or H for both). +# Or, E could be used for /var and F for /usr and users. +# C: This gives a single, non-bootable, large user filesystem. +# Good for second drives on a machine as either /usr/src +# or a large /usr or user partition. +# +# A/B/G: This is the "traditional" setup for a bootable disk. +# A is the root partition, B the swap, and G is for /usr +# and users. +# A/D/E/F (large drives): +# A/D/H (small drives): +# This is a setup for bootable systems requiring more swap +# (e.g. those who need CL). It has A as the root, D as a +# larger swap, E and F (or H) as smaller user partitions. +# E could be used for /usr and F for users (or H for both). +# Or, E could be used for /var and F for /usr and users. +# C: This gives a single, non-bootable, large user filesystem. +# Good for second drives on a machine as either /usr/src +# or a large /usr or user partition. +# +sd7958|sd7958-utah|HP7958S:\ + :ty=winchester:ns#32:nt#6:nc#1643:\ + :pa#16384:oa#1024:ba#8192:fa#1024:\ + :pb#65536:ob#17408:\ + :pc#315455:oc#0:bc#8192:fc#1024:\ + :pd#98304:od#17408:\ + :pe#102400:oe#115712:be#4096:fe#512:\ + :pf#97343:of#218112:bf#4096:ff#1024:\ + :pg#232511:og#82944:bg#8192:fg#1024:\ + :ph#199743:oh#115712:bh#8192:fh#1024: +sd7959|sd330|sd7959-utah|HP7959S:\ + :ty=winchester:ns#32:nt#12:nc#1643:\ + :pa#16384:oa#1024:ba#8192:fa#1024:\ + :pb#65536:ob#17408:\ + :pc#630911:oc#0:bc#8192:fc#1024:\ + :pd#98304:od#17408:\ + :pe#102400:oe#115712:be#4096:fe#512:\ + :pf#412799:of#218112:bf#4096:ff#1024:\ + :pg#547967:og#82944:bg#8192:fg#1024:\ + :ph#515199:oh#115712:bh#8192:fh#1024: +sd7548-utah|sd660|HP97548S with Utah partitions:\ + :ty=winchester:ns#56:nt#16:nc#1447:\ + :pa#16384:oa#1024:ba#8192:fa#1024:\ + :pb#65536:ob#17408:\ + :pc#1296511:oc#0:bc#8192:fc#1024:\ + :pd#98304:od#17408:\ + :pe#102400:oe#115712:be#4096:fe#512:\ + :pf#1078399:of#218112:bf#4096:ff#1024:\ + :pg#1213567:og#82944:bg#8192:fg#1024:\ + :ph#1180799:oh#115712:bh#8192:fh#1024: +# +# HP magneto-optical drive. +# (ns, nt, nc are totally bogus) +# actually 1K sectors +sd650-sony|mo650-sony|HP6300/650A Magneto-optical drive with Sony format:\ + :ty=optical:ns#61:nt#8:nc#1306:\ + :pa#16384:oa#1024:ba#8192:fa#1024:\ + :pb#65536:ob#17408:\ + :pc#637328:oc#0:bc#8192:fc#1024:\ + :pd#98304:od#17408:\ + :pe#102400:oe#115712:be#4096:fe#1024:\ + :pf#419216:of#218112:bf#4096:ff#1024:\ + :pg#554384:og#82944:bg#8192:fg#1024: +sd650|mo650|mo650-ansi|HP6300/650A Magneto-optical with ANSI format drive:\ + :ty=optical:ns#61:nt#8:nc#1306:\ + :pa#16384:oa#1024:ba#8192:fa#1024:\ + :pb#65536:ob#17408:\ + :pc#629136:oc#0:bc#8192:fc#1024:\ + :pd#98304:od#17408:\ + :pe#102400:oe#115712:be#4096:fe#1024:\ + :pf#411024:of#218112:bf#4096:ff#1024:\ + :pg#546192:og#82944:bg#8192:fg#1024: + +# RAM disk +ram:\ + :ty=winchester:ns#512:nt#4:nc#1:\ + :pa#2048:oa#0:ba#4096:fa#512:\ + :pb#2048:ob#0:bb#4096:fb#512:\ + :pc#2048:oc#0:bc#4096:fc#512: diff --git a/src/etc/etc.mac68k/fstab.sd b/src/etc/etc.mac68k/fstab.sd new file mode 100644 index 00000000..ea140344 --- /dev/null +++ b/src/etc/etc.mac68k/fstab.sd @@ -0,0 +1,5 @@ +/dev/sd0a / ffs rw 1 1 +/dev/sd0b none swap sw 0 0 +#/dev/sd0g /usr ffs rw 1 2 +kern /kern kernfs rw 0 0 +proc /proc procfs rw 0 0 diff --git a/src/etc/etc.mac68k/ttys b/src/etc/etc.mac68k/ttys new file mode 100644 index 00000000..61cd9b8a --- /dev/null +++ b/src/etc/etc.mac68k/ttys @@ -0,0 +1,56 @@ +# +# $NetBSD: ttys,v 1.11 1995/10/09 02:19:39 thorpej Exp $ +# from: @(#)ttys 5.1 (Berkeley) 4/17/89 +# +# name getty type status comments +# +# If the console is marked insecure, single-user requires +# the root password. +console "/usr/libexec/getty Pc" vt220 off secure + +# Define the console that we actually run getty on. +ttye0 "/usr/libexec/getty Pc" vt220 on secure + +# Hardwired lines are marked off, by default, so getty(8) +# is quiet when they don't exist. +tty00 "/usr/libexec/getty std.9600" unknown off secure +tty01 "/usr/libexec/getty std.9600" unknown off secure +tty02 "/usr/libexec/getty std.9600" unknown off secure +tty03 "/usr/libexec/getty std.9600" unknown off secure +tty04 "/usr/libexec/getty std.9600" unknown off secure +tty05 "/usr/libexec/getty std.9600" unknown off secure +tty06 "/usr/libexec/getty std.9600" unknown off secure +tty07 "/usr/libexec/getty std.9600" unknown off secure + +ttyp0 none network +ttyp1 none network +ttyp2 none network +ttyp3 none network +ttyp4 none network +ttyp5 none network +ttyp6 none network +ttyp7 none network +ttyp8 none network +ttyp9 none network +ttypa none network +ttypb none network +ttypc none network +ttypd none network +ttype none network +ttypf none network +ttyq0 none network +ttyq1 none network +ttyq2 none network +ttyq3 none network +ttyq4 none network +ttyq5 none network +ttyq6 none network +ttyq7 none network +ttyq8 none network +ttyq9 none network +ttyqa none network +ttyqb none network +ttyqc none network +ttyqd none network +ttyqe none network +ttyqf none network diff --git a/src/etc/etc.pc532/MAKEDEV b/src/etc/etc.pc532/MAKEDEV new file mode 100644 index 00000000..369102cf --- /dev/null +++ b/src/etc/etc.pc532/MAKEDEV @@ -0,0 +1,247 @@ +#!/bin/sh - +# +# Copyright (c) 1990 The Regents of the University of California. +# All rights reserved. +# +# Written and contributed by W. Jolitz 12/90 +# +# Redistribution and use in source and binary forms are permitted provided +# that: (1) source distributions retain this entire copyright notice and +# comment, and (2) distributions including binaries display the following +# acknowledgement: ``This product includes software developed by the +# University of California, Berkeley and its contributors'' in the +# documentation or other materials provided with the distribution and in +# all advertising materials mentioning features or use of this software. +# Neither the name of the University nor the names of its contributors may +# 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 +# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +# +# @(#)MAKEDEV 5.2 (Berkeley) 6/22/90 +# +# Device "make" file. Valid arguments: +# all makes all known devices, including local devices. +# Tries to make the 'standard' number of each type. +# floppy devices to be put on install floppies +# std standard devices +# local configuration specific devices +# +# Tapes: +# st* SCSI tapes +# +# Disks: +# sd* SCSI disks +# cd* SCSI CD-ROM +# vnd* "file" pseudo-disks +# ccd* concatenated disk driver +# +# Terminal ports: +# tty* rs232 devices +# +# Pseudo terminals: +# pty* set of 16 master and slave pseudo terminals +# +# Printers: +# lpt* Matthias's lp interface +# +# Special purpose devices: +# fd file descriptors +# bpf* packet filter +# lkm loadable kernel modules interface +# tun* network tunnel driver +# + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +umask 77 +for i +do +case $i in + +all) + sh MAKEDEV std fd sd0 sd1 sd2 st0 st1 cd0 cd1 + sh MAKEDEV tty0 tty1 tty2 tty3 tty4 tty5 tty6 tty7 + sh MAKEDEV pty0 pty1 vnd0 vnd1 bpf0 bpf1 bpf2 bpf3 + sh MAKEDEV tun0 tun1 tun2 lkm + sh MAKEDEV ccd0 ccd1 ccd2 ccd3 + ;; + +floppy) + sh MAKEDEV std sd0 sd1 sd2 tty0 tty1 tty2 tty3 + sh MAKEDEV st0 st1 cd0 cd1 rd0 + ;; + +std) + rm -f console drum mem kmem null zero io tty klog stdin stdout stderr + mknod console c 0 0 + mknod drum c 4 0 ; chmod 640 drum ; chgrp kmem drum + mknod kmem c 2 1 ; chmod 640 kmem ; chgrp kmem kmem + mknod mem c 2 0 ; chmod 640 mem ; chgrp kmem mem + mknod null c 2 2 ; chmod 666 null + mknod zero c 2 12 ; chmod 666 zero + mknod tty c 1 0 ; chmod 666 tty + mknod klog c 7 0 ; chmod 600 klog + mknod stdin c 11 0 ; chmod 666 stdin + mknod stdout c 11 1 ; chmod 666 stdout + mknod stderr c 11 2 ; chmod 666 stderr + ;; + +fd) + rm -f fd/* + mkdir fd > /dev/null 2>&1 + (cd fd && eval `echo "" | awk ' BEGIN { \ + for (i = 0; i < 64; i++) \ + printf("mknod %d c 11 %d;", i, i)}'`) + chown -R bin.bin fd + chmod 555 fd + chmod 666 fd/* + ;; + +rd*) + umask 2 ; unit=`expr $i : '.*d\(.*\)'` + mknod rd${unit} b 3 $unit + mknod rrd${unit} c 9 $unit + chgrp operator rd${unit} rrd${unit} + chmod 640 rd${unit} rrd${unit} + umask 77 + ;; + +sd*|vnd*|ccd*) + umask 2 ; unit=`expr $i : '.*d\(.*\)'` + case $i in + sd*) name=sd; blk=0; chr=3;; + vnd*) name=vnd; blk=5; chr=13;; + ccd*) name=ccd; blk=6; chr=18;; + esac + rm -f $name$unit? r$name$unit? + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1` + mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4` + mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5` + mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6` + mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1` + mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4` + mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5` + mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6` + mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + umask 77 + ;; + +tty*) + unit=`expr $i : '...\(.*\)'` + mknod tty0$unit c 8 $unit + chown uucp.wheel tty0$unit + ;; + +pty*) + class=`expr $i : 'pty\(.*\)'` + case $class in + 0) offset=0 name=p;; + 1) offset=16 name=q;; + 2) offset=32 name=r;; + 3) offset=48 name=s;; +# Note that telnetd, rlogind, and xterm (at least) only look at p-s. + 4) offset=64 name=t;; + *) echo bad unit for pty in: $i;; + esac + case $class in + 0|1|2|3|4) + umask 0 + eval `echo $offset $name | awk ' { b=$1; n=$2 } END { + for (i = 0; i < 16; i++) + printf("rm -f tty%s%x; mknod tty%s%x c 5 %d; \ + rm -f pty%s%x; mknod pty%s%x c 6 %d; ", \ + n, i, n, i, b+i, n, i, n, i, b+i); }'` + umask 77 + ;; + esac + ;; + +st*) + umask 2 ; unit=`expr $i : '..\(.*\)'` + case $i in + st*) name=st; chr=10; blk=2;; + esac + rm -f $name$unit n$name$unit e$name$unit en$name$unit \ + r$name$unit nr$name$unit er$name$unit enr$name$unit + mknod ${name}${unit} b $blk `expr $unit '*' 16 + 0` + mknod n${name}${unit} b $blk `expr $unit '*' 16 + 1` + mknod e${name}${unit} b $blk `expr $unit '*' 16 + 2` + mknod en${name}${unit} b $blk `expr $unit '*' 16 + 3` + mknod r${name}${unit} c $chr `expr $unit '*' 16 + 0` + mknod nr${name}${unit} c $chr `expr $unit '*' 16 + 1` + mknod er${name}${unit} c $chr `expr $unit '*' 16 + 2` + mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3` + chgrp operator ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + chmod 640 ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + umask 77 + ;; + +cd*) + umask 2 ; unit=`expr $i : '.*cd\(.*\)'` + case $i in + cd*) name=cd; blk=4; chr=12;; + esac + rm -f $name$unit? r$name$unit? + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + umask 77 + ;; + +lpt*) + unit=`expr $i : 'lpt\(.*\)'` + rm -f lpt${unit} lpt${unit}p + mknod lpt${unit} c 17 `expr $unit + 64` + mknod lpt${unit}p c 17 $unit + chmod 0220 lpt${unit} lpt${unit}p + chown root.wheel lpt$unit + ;; + +bpf*) + unit=`expr $i : 'bpf\(.*\)'` + rm -f bpf$unit + mknod bpf$unit c 14 $unit + chown root.wheel bpf$unit + ;; + +tun*) + unit=`expr $i : 'tun\(.*\)'` + rm -f tun$unit + mknod tun$unit c 15 $unit + chmod 600 tun$unit + chown root.wheel tun$unit + ;; + +lkm) + rm -f lkm + mknod lkm c 18 0 + chown root.kmem lkm + chmod 640 lkm + ;; + +local) + umask 0 + sh MAKEDEV.local + ;; + +esac +done diff --git a/src/etc/etc.pc532/disktab b/src/etc/etc.pc532/disktab new file mode 100644 index 00000000..6f3aa270 --- /dev/null +++ b/src/etc/etc.pc532/disktab @@ -0,0 +1,70 @@ +# $Id: disktab,v 1.1.1.1 1995/10/18 08:38:01 deraadt Exp $ +# +# PC532 version. +# +# Disk geometry and partition layout tables. +# Key: +# dt controller type +# ty type of disk (fixed, removeable, simulated) +# d[0-4] drive-type-dependent parameters +# ns #sectors/track +# nt #tracks/cylinder +# nc #cylinders/disk +# sc #sectors/cylinder, ns*nt default +# su #sectors/unit, sc*nc default +# se sector size, DEV_BSIZE default +# rm rpm, 3600 default +# sf supports bad144-style bad sector forwarding +# sk sector skew per track, default 0 +# cs sector skew per cylinder, default 0 +# hs headswitch time, default 0 +# ts one-cylinder seek time, default 0 +# il sector interleave (n:1), 1 default +# bs boot block size, default BBSIZE +# sb superblock size, default SBSIZE +# o[a-h] partition offsets in sectors +# p[a-h] partition sizes in sectors +# b[a-h] partition block sizes in bytes +# f[a-h] partition fragment sizes in bytes +# t[a-h] partition types (filesystem, swap, etc) + +# +# Floppy and boot disk support +# + +floppy3|3in|3.5in High Density Floppy:\ + :ty=floppy:se#512:nt#2:rm#300:ns#18:nc#80:\ + :pa#2880:oa#0:ba#4096:fa#512:\ + :pc#2880:oc#0: + +floppy5|5in|5.25in High Density Floppy:\ + :ty=floppy:se#512:nt#2:rm#300:ns#15:nc#80:\ + :pa#2400:oa#0:ba#4096:fa#512:\ + :pc#2400:oc#0: + +boot3|3.5in High Density Boot Floppy:\ + :ty=floppy:se#512:nt#2:rm#300:ns#18:nc#80:\ + :ta=4.2BSD:pa#2844:oa#0:ba#4096:fa#512:\ + :tc=unused:pc#2880:oc#0:\ + :th=boot:ph#36:oh#2844: + +rd|2mb ramdisk:\ + :ty=floppy:se#512:nt#1:rm#8000:ns#256:nc#16:\ + :ta=4.2BSD:pa#4096:oa#0:ba#4096:fa#512:\ + :tc=unused:pc#4096:oc#0: + +# +# Others +# + +m2614esa|Fujitsu M2614 ESA 180Mb:\ + :ty=winchester:dt=SCSI:\ + :ns#34:nt#8:nc#1336:\ + :sc#267:su#356178::se#512:\ + :rm#3490:sk#12:cs#16:hs#5000:ts#8000:il#1:\ + :ta=4.2BSD:oa#267:pa#16554:ba#8192:fa#1024:\ + :tb=swap:ob#16821:pb#32841:\ + :tc=unused:oc#0:pc#356178:\ + :td=4.2BSD:od#49662:pd#16554:bd#8192:fd#1024:\ + :te=4.2BSD:oe#66216:pe#289962:be#8192:fe#1024:\ + :tg=boot:og#2:pg#265: diff --git a/src/etc/etc.pc532/fstab.sd b/src/etc/etc.pc532/fstab.sd new file mode 100644 index 00000000..9d233952 --- /dev/null +++ b/src/etc/etc.pc532/fstab.sd @@ -0,0 +1,3 @@ +/dev/sd0a / ffs rw 1 1 +/dev/sd0b none swap sw 0 0 +/dev/sd0e /usr ffs rw 1 2 diff --git a/src/etc/etc.pc532/ttys b/src/etc/etc.pc532/ttys new file mode 100644 index 00000000..1dda4366 --- /dev/null +++ b/src/etc/etc.pc532/ttys @@ -0,0 +1,45 @@ +# +# @(#)ttys 5.1 (Berkeley) 4/17/89 +# +# name getty type status comments +# +console "/usr/libexec/getty std.9600" unknown on secure +tty01 "/usr/libexec/getty std.9600" unknown off secure +tty02 "/usr/libexec/getty std.9600" unknown off secure +tty03 "/usr/libexec/getty std.9600" unknown off secure +tty04 "/usr/libexec/getty std.9600" unknown off secure +tty05 "/usr/libexec/getty std.9600" unknown off secure +tty06 "/usr/libexec/getty std.9600" unknown off secure +tty07 "/usr/libexec/getty std.9600" unknown off secure +ttyp0 none network +ttyp1 none network +ttyp2 none network +ttyp3 none network +ttyp4 none network +ttyp5 none network +ttyp6 none network +ttyp7 none network +ttyp8 none network +ttyp9 none network +ttypa none network +ttypb none network +ttypc none network +ttypd none network +ttype none network +ttypf none network +ttyq0 none network +ttyq1 none network +ttyq2 none network +ttyq3 none network +ttyq4 none network +ttyq5 none network +ttyq6 none network +ttyq7 none network +ttyq8 none network +ttyq9 none network +ttyqa none network +ttyqb none network +ttyqc none network +ttyqd none network +ttyqe none network +ttyqf none network diff --git a/src/etc/etc.pmax/MAKEDEV b/src/etc/etc.pmax/MAKEDEV new file mode 100644 index 00000000..6314d940 --- /dev/null +++ b/src/etc/etc.pmax/MAKEDEV @@ -0,0 +1,254 @@ +#!/bin/sh - +# +# @(#)MAKEDEV 8.1 (Berkeley) 6/9/93 +# + +# Device "make" file. Valid arguments: +# std standard devices +# local configuration specific devices +# Tapes: +# tz* SCSI tapes, DEC TK50 cartridge tape +# Disks: +# rz* SCSI disks +# vnd* "file" pseudo-disks +# ccd* concatenated disk driver +# Terminal multiplexors: +# dc* 4 channel serial interface (keyboard, mouse, modem, printer) +# scc* 82530 serial interface +# Pseudo terminals: +# pty* set of 16 master and slave pseudo terminals +# Printers: +# Call units: +# Special purpose devices: +# bpf* packet filter +# lkm loadable kernel modules interface +# tun* network tunnel driver +# Platform-specific devices: +# NOTE: /dev/mouse should be a link to one of these for X windows. +# pm* raw interface to PMAX graphics devices +# cfb* raw interface to turbochannel PMAG-BA color frame buffer +# xcfb* raw interface to maxine graphics devices +# mfb* raw interface to mono graphics devices + +PATH=/sbin:/bin/:/usr/bin:/usr/sbin +umask 77 +for i +do +case $i in + +std) + mknod console c 0 0 + mknod drum c 1 0 ; chmod 640 drum ; chgrp kmem drum + mknod kmem c 3 1 ; chmod 640 kmem ; chgrp kmem kmem + mknod mem c 3 0 ; chmod 640 mem ; chgrp kmem mem + mknod null c 3 2 ; chmod 666 null + mknod zero c 3 12 ; chmod 666 zero + mknod tty c 2 0 ; chmod 666 tty + mknod klog c 6 0 ; chmod 600 klog + mknod stdin c 7 0 ; chmod 666 stdin + mknod stdout c 7 1 ; chmod 666 stdout + mknod stderr c 7 2 ; chmod 666 stderr + mkdir fd > /dev/null 2>&1 + (cd fd && eval `echo "" | awk ' BEGIN { \ + for (i = 0; i < 64; i++) \ + printf("mknod %d c 7 %d;", i, i)}'`) + chown -R bin.bin fd + chmod 555 fd + chmod 666 fd/* + ;; + +tz*) + umask 0 ; unit=`expr $i : '..\(.*\)'` + case $i in + tz*) chr=10;; + esac + case $unit in + 0|1|2|3|4|5|6) + unit0=`expr $unit \* 16` + unit1=`expr $unit \* 16 + 1` + unit2=`expr $unit \* 16 + 2` + unit3=`expr $unit \* 16 + 3` + mknod rmt$unit c $chr $unit0 + mknod nrmt$unit c $chr $unit1 + mknod rmth$unit c $chr $unit2 + mknod nrmth$unit c $chr $unit3 + chmod 666 rmt$unit nrmt$unit rmth$unit nrmth$unit + ;; + *) + echo bad unit for tape in: $1 + ;; + esac + umask 77 + ;; + +bpf*) + unit=`expr $i : 'bpf\(.*\)'` + rm -f bpf$unit + mknod bpf$unit c 12 $unit + chmod 600 bpf$unit + chown root.wheel bpf$unit + ;; + +#tun*) +# unit=`expr $i : 'tun\(.*\)'` +# rm -f tun$unit +# mknod tun$unit c 111 $unit +# chmod 600 tun$unit +# chown root.wheel tun$unit +# ;; +#lkm) +# rm -f lkm +# mknod lkm c 112 0 +# chown root.kmem lkm +# chmod 640 lkm +# ;; + +rz*|vnd*|vn*|ccd*) + umask 2 ; unit=`expr $i : '.*[dz]\(.*\)'` + case $i in + rz*) name=rz; blk=21; chr=56;; + vn*) name=vnd; blk=2; chr=11;; + ccd*) name=ccd; blk=24; chr=87;; + esac + case $unit in + 0|1|2|3|4|5|6) + mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2` + mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2` + if [ $name != vnd ] + then + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4` + mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5` + mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6` + mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4` + mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5` + mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6` + mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7` + fi + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + ;; + *) + echo bad unit for disk in: $i + ;; + esac + umask 77 + ;; + +dc*) + unit=`expr $i : 'dc\(.*\)'` + case $unit in + 0) + mknod tty00 c 16 2 + mknod tty01 c 16 3 + ;; + *) + echo bad unit for dc in: $i + ;; + esac + ;; + +scc*) + unit=`expr $i : 'scc\(.*\)'` + case $unit in + 0) + mknod tty00 c 17 2 + mknod tty01 c 17 3 + ;; + *) + echo bad unit for scc in: $i + ;; + esac + ;; + +pm*) + unit=`expr $i : 'pm\(.*\)'` + case $unit in + 0) + mknod pm0 c 8 0 + ;; + *) + echo bad unit for pm in: $i + ;; + esac + ;; + +cfb*) + unit=`expr $i : 'cfb\(.*\)'` + case $unit in + 0) + mknod cfb0 c 13 0 + ;; + *) + echo bad unit for cfb in: $i + ;; + esac + ;; + +xcfb*) + unit=`expr $i : 'xcfb\(.*\)'` + case $unit in + 0) + mknod xcfb0 c 14 0 + ;; + *) + echo bad unit for xcfb in: $i + ;; + esac + ;; + +mfb*) + unit=`expr $i : 'mfb\(.*\)'` + case $unit in + 0) + mknod mfb0 c 18 0 + ;; + *) + echo bad unit for mfb in: $i + ;; + esac + ;; + +pty*) + class=`expr $i : 'pty\(.*\)'` + case $class in + 0) offset=0 name=p;; + 1) offset=16 name=q;; + 2) offset=32 name=r;; + 3) offset=48 name=s;; +# Note that telnetd, rlogind, and xterm (at least) only look at p-s. + 4) offset=64 name=t;; + *) echo bad unit for pty in: $i;; + esac + case $class in + 0|1|2|3|4) + umask 0 + eval `echo $offset $name | awk ' { b=$1; n=$2 } END { + for (i = 0; i < 16; i++) + printf("mknod tty%s%x c 4 %d; \ + mknod pty%s%x c 5 %d; ", \ + n, i, b+i, n, i, b+i); }'` + umask 77 + if [ $class = 1 ]; then + mv ttyqf ttyv0; mv ptyqf ptyv0 + fi + ;; + esac + ;; + +local) + umask 0 + sh MAKEDEV.local + ;; + +*) + echo $i: unknown device + ;; +esac +done diff --git a/src/etc/etc.pmax/disktab b/src/etc/etc.pmax/disktab new file mode 100644 index 00000000..fa90a1c6 --- /dev/null +++ b/src/etc/etc.pmax/disktab @@ -0,0 +1,192 @@ +# +# @(#)disktab 8.1 (Berkeley) 6/9/93 +# + +# Disk geometry and partition layout tables. +# Key: +# dt controller type +# ty type of disk (fixed, removeable, simulated) +# d[0-4] drive-type-dependent parameters +# ns #sectors/track +# nt #tracks/cylinder +# nc #cylinders/disk +# sc #sectors/cylinder, nc*nt default +# su #sectors/unit, sc*nc default +# se sector size, DEV_BSIZE default +# rm rpm, 3600 default +# sf supports bad144-style bad sector forwarding +# sk sector skew per track, default 0 +# cs sector skew per cylinder, default 0 +# hs headswitch time, default 0 +# ts one-cylinder seek time, default 0 +# il sector interleave (n:1), 1 default +# bs boot block size, default BBSIZE +# sb superblock size, default SBSIZE +# o[a-h] partition offsets in sectors +# p[a-h] partition sizes in sectors +# b[a-h] partition block sizes in bytes +# f[a-h] partition fragment sizes in bytes +# t[a-h] partition types (filesystem, swap, etc) +# b[0-1] primary and secondary bootstraps, optional +# +# All partition sizes contain space for bad sector tables unless +# the device drivers fail to support this. Smaller disks may +# not have all partitions and all disks have no defaults for +# the `h' partition. The strategy here is that `a' always +# has the same amount for all disks. The `b' partition is +# four times `a' while `c' is always the entire disk. The +# sum of `d', `e', and `f' is equal to `g' which is everything else. + +rz22|RZ22|DEC RZ22 Winchester:\ + :dt=SCSI:ty=winchester:ns#33:nt#4:nc#776:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#69664:ob#32768:bb#8192:fb#1024:tb=swap:\ + :pc#102432:oc#0:bc#8192:fc#1024: + +rz23|RZ23|DEC RZ23 Winchester:\ + :dt=SCSI:ty=winchester:ns#33:nt#8:nc#776:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#131072:ob#32768:bb#8192:fb#1024:tb=swap:\ + :pc#204864:oc#0:bc#8192:fc#1024:\ + :pd#13674:od#163840:bd#8192:fd#1024:\ + :pe#13674:oe#177514:be#8192:fe#1024:\ + :pf#13676:of#191188:bf#8192:ff#1024:\ + :pg#41024:og#163840:bg#8192:fg#1024: + +rz23l|RZ23L|DEC RZ23L Winchester:\ + :dt=SCSI:ty=winchester:ns#39:nt#4:nc#1524:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#66690:ob#32768:bb#4096:fb#1024:tb=swap\ + :pc#237588:oc#0:bc#8192:fc#1024:\ + :pd#35135:od#99458:bd#8192:fd#1024:\ + :pe#35135:oe#134593:be#8192:fe#1024:\ + :pf#67860:of#169728:bf#8192:ff#1024:\ + :pg#138130:og#99458:bg#8192:fg#1024: + +rz24|RZ24|DEC RZ24 Winchester:\ + :dt=SCSI:ty=winchester:ns#38:nt#8:nc#1348:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#131072:ob#32768:bb#4096:fb#1024:tb=swap:\ + :pc#409792:oc#0:bc#8192:fc#1024:\ + :pd#81984:od#163840:bd#8192:fd#1024:\ + :pe#81984:oe#245824:be#8192:fe#1024:\ + :pf#81984:of#327808:bf#8192:ff#1024:\ + :pg#245952:og#163840:bg#8192:fg#1024: + +# +# The RZ24L uses ZBR, so (pc = #_logical_blocks) > ns * nt * nc. +# #_logical_blocks was obtained from the 'scu' "show pages" command. +# +rz24l|RZ24L|DEC RZ24L Winchester:\ + :dt=SCSI:ty=winchester:ns#65:nt#4:nc#1818:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#131072:ob#32768:bb#4096:fb#1024:tb=swap:\ + :pc#479350:oc#0:bc#8192:fc#1024:\ + :pd#105170:od#163840:bd#8192:fd#1024:\ + :pe#105170:oe#269010:be#8192:fe#1024:\ + :pf#105170:of#374180:bf#8192:ff#1024:\ + :pg#315510:og#163840:bg#8192:fg#1024: + +rz25|RZ25|DEC RZ25 Winchester:\ + :dt=SCSI:ty=winchester:ns#62:nt#9:nc#1476:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#131072:ob#32768:bb#8192:fb#1024:tb=swap:\ + :pc#832527:oc#0:bc#8192:fc#1024:\ + :pd#222896:od#163840:bd#8192:fd#1024:\ + :pe#222896:oe#386736:be#8192:fe#1024:\ + :pf#222895:of#609632:bf#8192:ff#1024:\ + :pg#668687:og#163840:bg#8192:fg#1024: + +rz26|RZ26|DEC RZ26 Winchester:\ + :dt=SCSI:ty=winchester:ns#57:nt#14:nc#2570:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#131072:ob#32768:bb#8192:fb#1024:tb=swap:\ + :pc#2050860:oc#0:bc#8192:fc#1024:\ + :pd#629006:od#163840:bd#8192:fd#1024:\ + :pe#629006:oe#792846:be#8192:fe#1024:\ + :pf#629008:of#1421852:bf#8192:ff#1024:\ + :pg#819200:og#163840:bg#8192:fg#1024:\ + :ph#1067820:oh#983040:bh#8192:fh#1024: + +rz55|RZ55|DEC RZ55 Winchester:\ + :dt=SCSI:ty=winchester:ns#36:nt#15:nc#1224:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#131072:ob#32768:bb#8192:fb#1024:tb=swap:\ + :pc#649040:oc#0:bc#8192:fc#1024:\ + :pd#152446:od#163840:bd#8192:fd#1024:\ + :pe#152446:oe#316286:be#8192:fe#1024:\ + :pf#180308:of#468732:bf#8192:ff#1024:\ + :pg#485200:og#163840:bg#8192:fg#1024: + +rz56|RZ56|DEC RZ56 Winchester:\ + :dt=SCSI:ty=winchester:ns#54:nt#15:nc#1632:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#131072:ob#32768:bb#4096:fb#1024:tb=swap:\ + :pc#1299174:oc#0:bc#8192:fc#1024:\ + :pd#292530:od#163840:bd#8192:fd#1024:\ + :pe#292530:oe#456370:be#8192:fe#1024:\ + :pf#550274:of#748900:bf#8192:ff#1024:\ + :pg#567666:og#163840:bg#8192:fg#1024:\ + :ph#567668:oh#731506:bh#8192:fh#1024: + +#rz57|RZ57|DEC RZ57 Winchester:\ +# :dt=SCSI:ty=winchester:ns#71:nt#15:nc#1854:\ +# :pa#32768:ba#8192:fa#1024:\ +# :pb#184320:bb#4096:fb#1024:tb=swap:\ +# :pc#1954050:bc#8192:fc#1024:\ +# :pd#299008:bd#8192:fd#1024:\ +# :pe#299008:be#8192:fe#1024:\ +# :pf#524546:bf#8192:ff#1024:\ +# :pg#614400:bg#8192:fg#1024:\ +# :ph#1122562:bh#8192:fh#1024: + +rz57|RZ57|DEC RZ57 Winchester:\ + :dt=SCSI:ty=winchester:ns#70:nt#15:nc#1861:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#184320:ob#32768:bb#8192:fb#1024:tb=swap:\ + :pc#1954050:oc#0:bc#8192:fc#1024:\ + :pd#299008:od#831488:bd#8192:fd#1024:\ + :pe#299008:oe#1130496:be#8192:fe#1024:\ + :pf#524546:of#1429504:bf#8192:ff#1024:\ + :pg#614400:og#217088:bg#8192:fg#1024:\ + :ph#1122562:oh#831488:bh#8192:fh#1024: + +# NOTE: The RZ58 uses a recording technique called zoned recording. +# Using this technique, the number of sectors per track will vary +# depending on what zone of the disk is in use (simply multiplying +# ns*nt*nc does not give true capacity of the drive). The ns (number +# of sectors per track) is calculated by "ns = total sectors/(nt*nc)" +# and is a rounded value. Therefore, the value "ns" is an approximation, +# not a true representation, of what is stored on disk. +# +# The 'c' partition listed below gives the true size of the RZ58 +# (this information can be obtained by use of the DEVGETGEOM ioctl). +# + +rz58|RZ58|DEC RZ58 Winchester:\ + :ty=winchester:ns#85:nt#15:nc#2112:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#131072:ob#32768:bb#4096:fb#1024:tb=swap:\ + :pc#2698061:oc#0:bc#8192:fc#1024:\ + :pd#844800:od#163840:bd#8192:fd#1024:\ + :pe#844800:oe#1008640:be#8192:fe#1024:\ + :pf#844620:of#1853440:bf#8192:ff#1024:\ + :pg#819200:og#163840:bg#8192:fg#1024:\ + :ph#1715019:oh#983040:bh#8192:fh#1024: + +xt8760|XT8760|Maxtor XT8760 Winchester:\ + :dt=SCSI:ty=winchester:ns#54:nt#15:nc#1616:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#131072:ob#32768:bb#8192:fb#1024:tb=swap:\ + :pc#1308930:oc#0:bc#8192:fc#1024:\ + :pd#152446:od#163840:bd#8192:fd#1024:\ + :pe#152446:oe#316286:be#8192:fe#1024:\ + :pf#840198:of#468732:bf#8192:ff#1024:\ + :pg#1145090:og#163840:bg#8192:fg#1024: + +ep976|EP976|EPSON HMD-976 Winchester:\ + :dt=SCSI:ty=winchester:ns#34:nt#6:nc#670:\ + :pa#32768:oa#0:ba#8192:fa#1024:\ + :pb#69664:ob#32768:bb#8192:fb#1024:tb=swap:\ + :pc#136680:oc#0:bc#8192:fc#1024:\ + :pg#34248:og#102432:bg#8192:fg#1024: diff --git a/src/etc/etc.pmax/fstab.rz b/src/etc/etc.pmax/fstab.rz new file mode 100644 index 00000000..ed807474 --- /dev/null +++ b/src/etc/etc.pmax/fstab.rz @@ -0,0 +1,3 @@ +/dev/rz0a / ffs rw 1 1 +#/dev/rz0d /var ffs rw 1 2 +#/dev/rz0h /usr ffs rw 1 3 diff --git a/src/etc/etc.pmax/ttys b/src/etc/etc.pmax/ttys new file mode 100644 index 00000000..ed7d1f5d --- /dev/null +++ b/src/etc/etc.pmax/ttys @@ -0,0 +1,47 @@ +# +# from: @(#)ttys 5.1 (Berkeley) 4/17/89 +# $Id: ttys,v 1.1.1.1 1995/10/18 08:38:01 deraadt Exp $ +# +# name getty type status comments +# +console "/usr/libexec/getty std.9600" unknown on secure +tty00 "/usr/libexec/getty std.9600" unknown off secure +tty01 "/usr/libexec/getty std.9600" unknown off secure +tty02 "/usr/libexec/getty std.9600" unknown off secure +tty03 "/usr/libexec/getty std.9600" unknown off secure +tty04 "/usr/libexec/getty std.9600" unknown off secure +tty05 "/usr/libexec/getty std.9600" unknown off secure +tty06 "/usr/libexec/getty std.9600" unknown off secure +tty07 "/usr/libexec/getty std.9600" unknown off secure +ttyp0 none network +ttyp1 none network +ttyp2 none network +ttyp3 none network +ttyp4 none network +ttyp5 none network +ttyp6 none network +ttyp7 none network +ttyp8 none network +ttyp9 none network +ttypa none network +ttypb none network +ttypc none network +ttypd none network +ttype none network +ttypf none network +ttyq0 none network +ttyq1 none network +ttyq2 none network +ttyq3 none network +ttyq4 none network +ttyq5 none network +ttyq6 none network +ttyq7 none network +ttyq8 none network +ttyq9 none network +ttyqa none network +ttyqb none network +ttyqc none network +ttyqd none network +ttyqe none network +ttyqf none network diff --git a/src/etc/etc.sparc/MAKEDEV b/src/etc/etc.sparc/MAKEDEV new file mode 100644 index 00000000..f2bdfd6e --- /dev/null +++ b/src/etc/etc.sparc/MAKEDEV @@ -0,0 +1,299 @@ +#!/bin/sh - +# +# Copyright (c) 1990 The Regents of the University of California. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the University of +# California, Berkeley and its contributors. +# 4. Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# @(#)MAKEDEV 5.5 (Berkeley) 5/28/91 +# +# Device "make" file. Valid arguments: +# std standard devices +# local configuration specific devices +# Tapes: +# st* ? tape +# Disks: +# sd* SCSI disks +# cd* SCSI cdrom drives +# st* SCSI tape +# ch* SCSI changer +# xy* Xylogic 450/451 disks +# xd* Xylogic 753/7053 disks +# fd* Floppies +# vnd* "file" pseudo-disks +# ccd* concatenated disk devices +# Pseudo terminals: +# pty* set of 16 master and slave pseudo terminals +# Printers: +# Call units: +# Special purpose devices: +# audio +# openprom +# bwtwo* +# cgthree* +# cgfour* +# cgsix* +# cgeight* +# bpf* packet filter +# lkm loadable kernel modules interface +# tun* network tunnel driver + +PATH=/sbin:/bin/:/usr/bin:/usr/sbin:/usr/etc +umask 77 + +for i +do + +unit=`expr $i : '[a-z][a-z]*\([0-9][0-9]*\)'` +[ "$unit" ] || unit=0 + +case $i in + +all) + sh MAKEDEV std sd0 sd1 sd2 sd3 sd4 xd0 xd1 xd2 xd3 xy0 xy1 xy2 xy3 + sh MAKEDEV cd0 st0 st1 fd0 + sh MAKEDEV pty0 vnd0 vnd1 vnd2 vnd3 audio tun0 tun1 tun2 tun3 + sh MAKEDEV ccd0 ccd1 ccd2 ccd3 + sh MAKEDEV bpf0 bpf1 bpf2 bpf3 bwtwo0 cgthree0 cgfour0 cgsix0 + sh MAKEDEV cgeight0 + sh MAKEDEV lkm local + ;; +std) + mknod console c 0 0 + mknod tty c 2 0 ; chmod 666 tty + mknod kmem c 3 1 ; chmod 640 kmem ; chgrp kmem kmem + mknod mem c 3 0 ; chmod 640 mem ; chgrp kmem mem + mknod null c 3 2 ; chmod 666 null + mknod zero c 3 12 ; chmod 666 zero + mknod eeprom c 3 11 ; chmod 640 eeprom ; chgrp kmem eeprom + mknod openprom c 70 0 ; chmod 644 openprom + mknod drum c 7 0 ; chmod 640 drum ; chgrp kmem drum + mknod klog c 16 0 ; chmod 600 klog + mknod stdin c 24 0 ; chmod 666 stdin + mknod stdout c 24 1 ; chmod 666 stdout + mknod stderr c 24 2 ; chmod 666 stderr + mkdir fd > /dev/null 2>&1 + (cd fd && eval `echo "" | awk ' BEGIN { \ + for (i = 0; i < 64; i++) \ + printf("mknod %d c 24 %d;", i, i)}'`) + chown -R bin.bin fd + chmod 555 fd + chmod 666 fd/* + + mknod ttya c 12 0 + mknod ttyb c 12 1 + mknod fb c 22 0 ; chmod 666 fb + mknod mouse c 13 0 ; chmod 666 mouse + mknod kbd c 29 0 ; chmod 666 kbd + ;; + +bwtwo*) + mknod bwtwo$unit c 27 $unit; chmod 666 bwtwo$unit + ;; + +cgthree*) + mknod cgthree$unit c 55 $unit; chmod 666 cgthree$unit + ;; + +cgfour*) + mknod cgfour$unit c 39 $unit; chmod 666 cgfour$unit + ;; + +cgsix*) + mknod cgsix$unit c 67 $unit; chmod 666 cgsix$unit + ;; + +cgeight*) + mknod cgeight$unit c 64 $unit; chmod 666 cgeight$unit + ;; + +audio) + mknod audio c 69 0; chmod 666 audio + ;; + +openprom) + mknod openprom c 70 0; chmod 600 openprom + ;; + +bpf*) + rm -f bpf$unit + mknod bpf$unit c 105 $unit + chmod 600 bpf$unit + chown root.wheel bpf$unit + ;; + +tun*) + rm -f tun$unit + mknod tun$unit c 111 $unit + chmod 600 tun$unit + chown root.wheel tun$unit + ;; + +vnd*) + name=vnd; blk=8; chr=110 + rm -f ${name}${unit}c r${name}${unit}c + mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2` + mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2` + chgrp operator ${name}${unit}c r${name}${unit}c + chmod 640 ${name}${unit}c r${name}${unit}c + ;; + +ccd*|fd*|sd*|xd*|xy*) + umask 2 + case $i in + ccd*) name=ccd; blk=9; chr=23;; + fd*) name=fd; blk=16; chr=54;; + sd*) name=sd; blk=7; chr=17;; + xd*) name=xd; blk=10; chr=42;; + xy*) name=xy; blk=3; chr=9;; + esac + case $unit in + 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|\ + 17|18|19|20|21|22|23|24|25|26|27|28|29|30|31) + mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2` + mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2` + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4` + mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5` + mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6` + mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4` + mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5` + mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6` + mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + ;; + *) + echo bad unit for disk in: $i + ;; + esac + umask 77 + ;; + +st*) + umask 2 + case $i in + st*) name=st; blk=11; chr=18;; + esac + rm -f $name$unit n$name$unit e$name$unit en$name$unit \ + r$name$unit nr$name$unit er$name$unit enr$name$unit + mknod ${name}${unit} b $blk `expr $unit '*' 16 + 0` + mknod n${name}${unit} b $blk `expr $unit '*' 16 + 1` + mknod e${name}${unit} b $blk `expr $unit '*' 16 + 2` + mknod en${name}${unit} b $blk `expr $unit '*' 16 + 3` + mknod r${name}${unit} c $chr `expr $unit '*' 16 + 0` + mknod nr${name}${unit} c $chr `expr $unit '*' 16 + 1` + mknod er${name}${unit} c $chr `expr $unit '*' 16 + 2` + mknod enr${name}${unit} c $chr `expr $unit '*' 16 + 3` + chgrp operator ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + chmod 640 ${name}${unit} n${name}${unit} \ + e$name$unit en$name$unit \ + r${name}${unit} nr${name}${unit} \ + er${name}${unit} enr${name}${unit} + umask 77 + ;; + +ch*) + umask 2 + case $i in + ch*) name=ch; chr=19;; + esac + rm -f $name$unit + mknod ${name}${unit} c $chr `expr $unit '*' 16 + 0` + chgrp operator ${name}${unit} + chmod 640 ${name}${unit} + umask 77 + ;; + +cd*) + umask 2 + case $i in + cd*) name=cd; blk=18; chr=58;; + esac + rm -f $name$unit? r$name$unit? + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + umask 77 + ;; + +lkm) + rm -f lkm + mknod lkm c 112 0 + chown root.kmem lkm + chmod 640 lkm + ;; + +pty*) + case $unit in + 0) offset=0 name=p;; + 1) offset=16 name=q;; + 2) offset=32 name=r;; + 3) offset=48 name=s;; +# Note that telnetd, rlogind, and xterm (at least) only look at p-s. + 4) offset=64 name=t;; + *) echo bad unit for pty in: $i;; + esac + case $unit in + 0|1|2|3|4) + umask 0 + eval `echo $offset $name | awk ' { b=$1; n=$2 } END { + for (i = 0; i < 16; i++) + printf("mknod tty%s%x c 20 %d; \ + mknod pty%s%x c 21 %d; ", \ + n, i, b+i, n, i, b+i); }'` + umask 77 + if [ $unit = 1 ]; then + mv ttyqf ttyv0; mv ptyqf ptyv0 + fi + ;; + esac + ;; + +local) + umask 0 + sh MAKEDEV.local + ;; +*) + echo $i: unknown device + ;; +esac +done diff --git a/src/etc/etc.sparc/Makefile.inc b/src/etc/etc.sparc/Makefile.inc new file mode 100644 index 00000000..ca1eedca --- /dev/null +++ b/src/etc/etc.sparc/Makefile.inc @@ -0,0 +1,27 @@ +# +# etc.sparc/Makefile.inc -- sparc-specific etc Makefile targets +# +# $Id: Makefile.inc,v 1.1.1.1 1995/10/18 08:38:01 deraadt Exp $ + +.ifdef DESTDIR +snap_md: netbsd netbsd.scsi3 inst + cp ${.CURDIR}/../sys/arch/sparc/compile/GENERIC/netbsd \ + ${DESTDIR}/snapshot/netbsd + cp ${.CURDIR}/../sys/arch/sparc/compile/GENERIC_SCSI3/netbsd \ + ${DESTDIR}/snapshot/netbsd.scsi3 + +netbsd: + cd ${.CURDIR}/../sys/arch/sparc/conf && config GENERIC + cd ${.CURDIR}/../sys/arch/sparc/compile/GENERIC && \ + make clean && make depend && make + +netbsd.scsi3: + cd ${.CURDIR}/../sys/arch/sparc/conf && config GENERIC_SCSI3 + cd ${.CURDIR}/../sys/arch/sparc/compile/GENERIC_SCSI3 && \ + make clean && make depend && make + +inst: + cp ${.CURDIR}/etc.sparc/README ${DESTDIR}/snapshot/README + cp ${.CURDIR}/etc.sparc/install.sh ${DESTDIR}/snapshot/install.sh + +.endif # DESTDIR check diff --git a/src/etc/etc.sparc/README b/src/etc/etc.sparc/README new file mode 100644 index 00000000..3602a718 --- /dev/null +++ b/src/etc/etc.sparc/README @@ -0,0 +1,118 @@ +# $Id: README,v 1.1.1.1 1995/10/18 08:38:01 deraadt Exp $ + +Initial test versions of a NetBSD/sparc binaries install are available +at + ftp.iastate.edu:/pub/netbsd/NetBSD-current/binaries/sparc + sun-lamp.cs.berkeley.edu:pub/NetBSD/arch/sparc + ftp.wonderland.org:NetBSD/arch/sparc [UK] + ftp.informatik.tu-muenchen.de:\ + /pub/comp/os/bsd/NetBSD/NetBSD-current/binaries/sparc +and many other NetBSD mirror sites. Some mirror sites may take a day +or two to catch up. + +The NetBSD/sparc port runs on sun4c class machines, ie. the +SS 1, 1+, 2, IPC, IPX, SLC, and ELC. it does not run on the +server-series machines, or the SS10-series machines. + +The ftp directory contains a number of very large .tar.gz files in there, +as well as this document and a helper install script. + +NOTE: THESE INSTRUCTIONS MAY CHANGE WITH EACH SNAPSHOT. + +Until there are better instructions written, here's a rough idea: + +1. format and partition the disk using sunos. yup, NetBSD/sparc uses + sunos disk labels. i am running a quantum 105 with these partition + sizes: + a: 28140 0 4.2BSD 1024 8192 16 # (Cyl. 0 - 133) + b: 16170 28140 unused 0 0 # (Cyl. 134 - 210) + c: 204540 0 unused 0 0 # (Cyl. 0 - 973) + g: 160230 44310 4.2BSD 1024 8192 16 # (Cyl. 211 - 973) + + Filesystem 512-blocks Used Avail Capacity Mounted on + /dev/sd0a 26090 18846 4634 80% / + /dev/sd0g 149444 131496 3002 98% /usr + amd:43 0 0 0 100% /home + gecko:/usr/src 1549722 851783 542966 61% /usr/src + komodo:/usr/local 269346 243428 -1016 100% /usr/local + newt:/newt.usera 1128328 836910 178584 82% /tmp_mnt/newt/newt.usera + +2. newfs it using sunos. yup, the filesystem format is identical. + UFS hasn't changed much over the years. (If you can, there is + a performance benefit from newfs'ing using NetBSD.) + + If you newfs using the NetBSD newfs command, be sure to use -O + to specify the `4.3BSD filesystem format' for your / partition, + otherwise you will not be able to boot. The SunOS boot blocks do + not understand the extended 4.4 filesystem format. + +3. put a SunOS /boot program in the root partition, and use + "installboot" to cause it to work. the "installboot" man page + says to do something like this: say you are running SunOS, and + the drive you are installing NetBSD/sparc on is currently at + /dev/sd1. You have made the filesystems on that drive already. + # mount /dev/sd1a /mnt + # cp /boot /mnt/boot + # /usr/mdec/installboot -vlt /mnt/boot /usr/mdec/bootsd /dev/rsd1a + +4. extract the provided *.tar.gz files onto the disk. the file + "install.sh" will help you do this. + + mount your partition(s) in a proper tree starting at /mnt. In the + same directory as your *.tar.gz files are, run "./install.sh". + (Now you may cut the head off the chicken and spray the blood over + your walls and ceiling. :-) + +5. copy /mnt/etc/fstab.sd to /mnt/etc/fstab and edit to match your + disk layout. + +6. the install script copies the kernel called "netbsd.scsi3" to + /mnt/netbsd. Two sample kernels are supplied: "netbsd" and + "netbsd.scsi3". + + Unlike SunOS and the ROM, NetBSD numbers scsi drives sequentially + as it finds them. The drive with the lowest scsi-id will be called + sd0. SunOS and the ROM map normally map sd0 to scsi-id 3. Thus, if + you have two drives, it's quite likely that NetBSD will disagree with + the ROM. + + The "netbsd.scsi3" kernel gets around this problem, by hard-wiring + scsi-id#3 to sd0. The remaining drives will be dynamically mapped + to other sd* numbers. If you have more than one drive you will + want to use this kernel. + + the "netbsd" kernel expects your root drive to be at the standard + SunOS sd0==scsi-id#3 location. If you have a second drive at any + of scsi-id's 0, 1, or 2, this kernel will NOT work for you. If you + know what you are doing, you could use this kernel. + +7. your ROM may need some setup. make sure you boot from `new command mode'. + If your machine comes up and gives you a `>' prompt instead of `ok', type: + >n + ok setenv sunmon-compat? false + ok + this is needed because netbsd cannot handle the old-mode yet, + and will firework on you. + + you cannot use the security modes of the sparc ROM. sorry, same + problem as above. + ok setenv security-mode none + +8. if needed, swap your scsi id's. now try a reboot. initially I'd + suggest you boot "-bs", then try multiuser after that. if you boot + single-user the netbsd incantation for making root read-write + is "mount -u /dev/sd0a /". alternatively, the command reboot is + found in /sbin. + +9. to boot from netbsd by default, tell something like this to your + ROM. + >n + ok setenv boot-from sd(0,0,0)netbsd + ok + +please let me know of any errors in these instructions or in the +archives. if so i'll correct them. + +good luck. + +<deraadt@fsa.ca> diff --git a/src/etc/etc.sparc/disktab b/src/etc/etc.sparc/disktab new file mode 100644 index 00000000..9b4b228a --- /dev/null +++ b/src/etc/etc.sparc/disktab @@ -0,0 +1,2 @@ +# $Id: disktab,v 1.1.1.1 1995/10/18 08:38:02 deraadt Exp $ +# Sparc has no need for disktab (yet) diff --git a/src/etc/etc.sparc/fstab.sd b/src/etc/etc.sparc/fstab.sd new file mode 100644 index 00000000..acec3f63 --- /dev/null +++ b/src/etc/etc.sparc/fstab.sd @@ -0,0 +1,3 @@ +/dev/sd0a / ffs rw 1 1 +/dev/sd0b none swap sw 0 0 +/dev/sd0g /usr ffs rw 1 2 diff --git a/src/etc/etc.sparc/install.sh b/src/etc/etc.sparc/install.sh new file mode 100644 index 00000000..860b5547 --- /dev/null +++ b/src/etc/etc.sparc/install.sh @@ -0,0 +1,20 @@ +#!/bin/sh +# $Id: install.sh,v 1.1.1.1 1995/10/18 08:38:02 deraadt Exp $ +umask 0 +cat ./bin.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cat ./etc.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cat ./sbin.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cat ./usr.bin.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cat ./usr.games.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cat ./usr.include.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cat ./usr.lib.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cat ./usr.libexec.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cat ./usr.misc.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cat ./usr.sbin.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cat ./usr.share.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cat ./var.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cat ./dev.tar.gz | gzip -d | (cd /mnt; tar xvpf -) +cp ./netbsd.scsi3 /mnt/netbsd +chmod 640 /mnt/netbsd; chown root.kmem /mnt/netbsd +cd /mnt/dev; ./MAKEDEV all +mv /mnt/etc/fstab.sd /mnt/etc/fstab diff --git a/src/etc/etc.sparc/ttys b/src/etc/etc.sparc/ttys new file mode 100644 index 00000000..63c5a8b4 --- /dev/null +++ b/src/etc/etc.sparc/ttys @@ -0,0 +1,40 @@ +# +# @(#)ttys 5.1 (Berkeley) 4/17/89 +# +# name getty type status comments +# +console "/usr/libexec/getty suncons" sun on secure +ttya "/usr/libexec/getty std.9600" unknown off secure +ttyb "/usr/libexec/getty std.9600" unknown off secure +ttyp0 none network +ttyp1 none network +ttyp2 none network +ttyp3 none network +ttyp4 none network +ttyp5 none network +ttyp6 none network +ttyp7 none network +ttyp8 none network +ttyp9 none network +ttypa none network +ttypb none network +ttypc none network +ttypd none network +ttype none network +ttypf none network +ttyq0 none network +ttyq1 none network +ttyq2 none network +ttyq3 none network +ttyq4 none network +ttyq5 none network +ttyq6 none network +ttyq7 none network +ttyq8 none network +ttyq9 none network +ttyqa none network +ttyqb none network +ttyqc none network +ttyqd none network +ttyqe none network +ttyqf none network diff --git a/src/etc/etc.sun3/MAKEDEV b/src/etc/etc.sun3/MAKEDEV new file mode 100644 index 00000000..17d4a496 --- /dev/null +++ b/src/etc/etc.sun3/MAKEDEV @@ -0,0 +1,213 @@ +#!/bin/sh - +# +# Copyright (c) 1990 The Regents of the University of California. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. All advertising materials mentioning features or use of this software +# must display the following acknowledgement: +# This product includes software developed by the University of +# California, Berkeley and its contributors. +# 4. Neither the name of the University nor the names of its contributors +# may be used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# @(#)MAKEDEV 5.5 (Berkeley) 5/28/91 +# $Id: MAKEDEV,v 1.1.1.1 1995/10/18 08:38:02 deraadt Exp $ +# +# Device "make" file. Valid arguments: +# std standard devices +# local configuration specific devices +# Tapes: +# st* ? tape +# Disks: +# sd* Sun SCSI disks +# fd* Floppies +# vnd* "file" pseudo-disks +# ccd* concatenated disk driver +# Pseudo terminals: +# pty* set of 16 master and slave pseudo terminals +# Printers: +# Call units: +# Special purpose devices: +# bwtwo* +# cgtwo* +# cgfour* +# bpf* packet filter +# lkm loadable kernel modules interface +# tun* network tunnel driver +# rd* RAM-disk + +# XXX - Keep /usr/etc so SunOS can find chown +PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/etc +umask 77 + +# set this to echo for Echo-Only debugging +eo= + +# mk name b/c major minor [mode] [group] +mk() { + $eo mknod $1 $2 $3 $4 + $eo chmod ${5-666} $1 + test -n "$6" && $eo chgrp $6 $1 + return 0 +} + +for arg +do + +unit=`expr $arg : '[a-z][a-z]*\([0-9][0-9]*\)'` +[ "$unit" ] || unit=0 + +case $arg in + +all) + sh MAKEDEV std sd0 sd1 sd2 sd3 st0 st1 pty0 + ;; + +std) + mk console c 0 0 622 + mk kd c 1 0 622 + mk tty c 2 0 + + mk mem c 3 0 640 kmem + mk kmem c 3 1 640 kmem + mk null c 3 2 + mk eeprom c 3 11 640 kmem + mk zero c 3 12 + mk drum c 7 0 640 kmem + + mk ttya c 12 0 + mk ttyb c 12 1 + mk mouse c 13 0 + mk klog c 16 0 600 + mk fb c 22 0 + mk kbd c 29 0 + ;; + +fd) + mkdir fd >/dev/null 2>&1 + i=0 ; while [ $i != 64 ] + do + mk fd/$i c 23 $i + i=`expr $i + 1` + done + ;; + +bpf*) + mk bpf$unit c 36 $unit 600 + ;; + +tun*) + mk tun$unit c 24 $unit 600 + ;; + +pty*) + case $unit in + 0) offset=0 name=p;; + 1) offset=16 name=q;; + 2) offset=32 name=r;; + 3) offset=48 name=s;; +# Note that telnetd, rlogind, and xterm (at least) only look at p-s. + 4) offset=64 name=t;; + *) echo bad unit for pty in: $arg;; + esac + for pair in 0.0 1.1 2.2 3.3 4.4 5.5 6.6 7.7 \ + 8.8 9.9 a.10 b.11 c.12 d.13 e.14 f.15 + do + ( + tmp="$IFS" ; IFS="$IFS." + set -- $pair + IFS="$tmp" ; unset tmp + minor=`expr $offset + $2` + mk tty$name$1 c 20 $minor + mk pty$name$1 c 21 $minor + ) + done + ;; + +cd*|sd*|xy*|vnd*|ccd*) + case $arg in + cd*) name=cd; blk=18; chr=58;; + sd*) name=sd; blk=7; chr=17;; + xy*) name=xy; blk=3; chr=9 ;; + vnd*) name=vnd; blk=5; chr=19;; + ccd*) name=ccd; blk=9; chr=33;; + esac + case $unit in + 0|1|2|3|4) offset=`expr $unit \* 8`;; + *) echo bad unit for $name in: $arg;; + esac + for part in a.0 b.1 c.2 d.3 e.4 f.5 g.6 h.7 + do + ( + tmp="$IFS" ; IFS="$IFS." + set -- $part + IFS="$tmp" ; unset tmp + minor=`expr $offset + $2` + mk $name$unit$1 b $blk $minor 640 operator + mk r$name$unit$1 c $chr $minor 640 operator + ) + done + ;; + +st*) + name=st; blk=11; chr=18; + case $unit in + 0|1|2|3) offset=`expr $unit \* 16`;; + *) echo bad unit for $name in: $arg;; + esac + mk r$name$unit c $chr `expr $offset + 0` + mk nr$name$unit c $chr `expr $offset + 1` + mk er$name$unit c $chr `expr $offset + 2` + mk enr$name$unit c $chr `expr $offset + 3` + ;; + +bwtwo*) + mk bwtwo$unit c 27 $unit + ;; + +cgtwo*) + mk cgtwo$unit c 31 $unit + ;; + +cgfour*) + mk cgfour$unit c 39 $unit + ;; + +rd*) + mk rd$unit b 13 $unit +# mk rrd$unit b 13 `expr $unit + 16` + mk rd${unit}c b 13 `expr $unit + 16` + ;; + +local) + umask 0 + sh MAKEDEV.local + ;; +*) + echo $arg: unknown device + ;; + +esac +done + diff --git a/src/etc/etc.sun3/Makefile.inc b/src/etc/etc.sun3/Makefile.inc new file mode 100644 index 00000000..7d2ad90d --- /dev/null +++ b/src/etc/etc.sun3/Makefile.inc @@ -0,0 +1,20 @@ +# +# etc.sun3/Makefile.inc -- sun3-specific etc Makefile targets +# +# $Id: Makefile.inc,v 1.1.1.1 1995/10/18 08:38:02 deraadt Exp $ + +.ifdef DESTDIR +snap_md: netbsd-gen netbsd-dl + cp -p ${.CURDIR}/etc.sun3/README ${DESTDIR}/snapshot/README + +netbsd-gen: + cd ${.CURDIR}/../sys/arch/sun3/compile/GENERIC && make + gzip -9 < ${.CURDIR}/../sys/arch/sun3/compile/GENERIC/netbsd \ + > ${DESTDIR}/snapshot/netbsd-gen.gz + +netbsd-dl: + cd ${.CURDIR}/../sys/arch/sun3/compile/DISKLESS && make + gzip -9 < ${.CURDIR}/../sys/arch/sun3/compile/DISKLESS/netbsd \ + > ${DESTDIR}/snapshot/netbsd-dl.gz + +.endif # DESTDIR check diff --git a/src/etc/etc.sun3/README b/src/etc/etc.sun3/README new file mode 100644 index 00000000..7f1e8709 --- /dev/null +++ b/src/etc/etc.sun3/README @@ -0,0 +1,51 @@ +# $Id: README,v 1.1.1.1 1995/10/18 08:38:02 deraadt Exp $ -*- text -*- + +NetBSD/Sun3 Binary Snapshot + +This FTP directory contains a binary snapshot of NetBSD/Sun3. + +The NetBSD/sun3 port runs on most Sun3 machines, including: + + Sun3/{50,60,110,160,260} + +Devices currently supported include: + + Intel Ether (ie), on-board or VME + Lance Ether (le), on-board + SCSI (sd,st,...), on-board or VME + keyboard/display console + serial port (ttya/ttyb) console + +Other Features: + + Generic kernel supports root on: sd[0123], ie0, le0 + Kernel debugger included (ddb) + Runs SunOS binaries (see sparc sun shared lib notes) + +There's still a lot left to do (see doc/sun3/TODO). + +Before using the files in this directory, you should start by +unpacking doc.shar and reading all the files it contains. +Suggested reading order is: + doc/sun3/README + doc/sun3/STATUS + doc/sun3/INSTALL + doc/sun3/SUP + doc/sun3/BUILDING + doc/sun3/TODO + +To use this, all you need to do it unpack everything onto the +disk that will be used for root and usr, which can be either a +real disk or some part of your NFS server. + +REMEMBER: run dev/MAKEDEV after you unpack things! +(cd dev ; MAKEDEV std) + +If you have any questions or comments about this port please +send mail to the list: <port-sun3@netbsd.org> + +If you'd like to help, send me mail at <gwr@netbsd.org> +so I can coordinate efforts. + +Enjoy! +Gordon Ross diff --git a/src/etc/etc.sun3/disktab b/src/etc/etc.sun3/disktab new file mode 100644 index 00000000..44d2437b --- /dev/null +++ b/src/etc/etc.sun3/disktab @@ -0,0 +1,42 @@ +# +# $NetBSD: disktab,v 1.2 1995/10/08 23:26:03 gwr Exp $ +# +# Disk geometry and partition layout tables. +# Key: +# dt controller type +# ty type of disk (fixed, removeable, simulated) +# d[0-4] drive-type-dependent parameters +# ns #sectors/track +# nt #tracks/cylinder +# nc #cylinders/disk +# sc #sectors/cylinder, ns*nt default +# su #sectors/unit, sc*nc default +# se sector size, DEV_BSIZE default +# rm rpm, 3600 default +# sf supports bad144-style bad sector forwarding +# sk sector skew per track, default 0 +# cs sector skew per cylinder, default 0 +# hs headswitch time, default 0 +# ts one-cylinder seek time, default 0 +# il sector interleave (n:1), 1 default +# bs boot block size, default BBSIZE +# sb superblock size, default SBSIZE +# o[a-h] partition offsets in sectors +# p[a-h] partition sizes in sectors +# b[a-h] partition block sizes in bytes +# f[a-h] partition fragment sizes in bytes +# t[a-h] partition types (filesystem, swap, etc) +# +# All partition sizes reserve space for bad sector tables. +# (5 cylinders needed for maintenance + replacement sectors) +# +# XXX - Would like :ba#4096:fa#512: but that panics... +# Leave nc=16; adjust size using: ns +rdroot|ramdiskroot|RAM-disk root FS image:\ + :ty=simulated:se#512:nc#16:nt#2:ns#16:\ + :ta=4.4BSD:oa#0:pa#512:\ + :ob#0:pb#0:oc#0:pc#512: +miniroot|Installation root-on-swap FS image:\ + :ty=simulated:se#512:ns#32:nt#8:nc#48:\ + :ta=4.4BSD:oa#0:pa#12288:\ + :ob#0:pb#0:oc#0:pc#12288: diff --git a/src/etc/etc.sun3/fstab.nfs b/src/etc/etc.sun3/fstab.nfs new file mode 100644 index 00000000..8ef95952 --- /dev/null +++ b/src/etc/etc.sun3/fstab.nfs @@ -0,0 +1,2 @@ +server:/export/client/root / nfs rw,-r=1024,-w=1024 +server:/export/netbsd.sun3/usr /usr nfs ro,-r=1024,-w=1024 diff --git a/src/etc/etc.sun3/fstab.sd0 b/src/etc/etc.sun3/fstab.sd0 new file mode 100644 index 00000000..1739db21 --- /dev/null +++ b/src/etc/etc.sun3/fstab.sd0 @@ -0,0 +1,3 @@ +/dev/sd0a / ufs rw 1 1 +/dev/sd0b none swap sw 0 0 +/dev/sd0g /usr ufs rw 1 2 diff --git a/src/etc/etc.sun3/install.sh b/src/etc/etc.sun3/install.sh new file mode 100644 index 00000000..5a18ddeb --- /dev/null +++ b/src/etc/etc.sun3/install.sh @@ -0,0 +1,23 @@ +#!/bin/sh +# $Id: install.sh,v 1.1.1.1 1995/10/18 08:38:02 deraadt Exp $ +umask 0 +[ "$TARDIR" ] || { echo "$0: set TARDIR first" ; exit 1; } + +while read f +do + gzip -d < $TARDIR/$f | tar xvpf - +done << \END_LIST +etc.tar.gz +dev.tar.gz +var.tar.gz +bin.tar.gz +sbin.tar.gz +usr.bin.tar.gz +usr.games.tar.gz +usr.include.tar.gz +usr.lib.tar.gz +usr.libexec.tar.gz +usr.misc.tar.gz +usr.sbin.tar.gz +usr.share.tar.gz +END_LIST diff --git a/src/etc/etc.sun3/ttys b/src/etc/etc.sun3/ttys new file mode 100644 index 00000000..cb5d08f4 --- /dev/null +++ b/src/etc/etc.sun3/ttys @@ -0,0 +1,46 @@ +# +# @(#)ttys 5.1 (Berkeley) 4/17/89 +# $Id: ttys,v 1.1.1.1 1995/10/18 08:38:02 deraadt Exp $ +# +# name getty type status comments +# +# Note: you may want to change the "default" entry in /etc/gettytab +# to make "no parity" the default (add the :np: flag). +# +# Also: the console is one of: kd, ttya, ttyb +console "/usr/libexec/getty std.9600" sun off secure +kd "/usr/libexec/getty std.9600" sun on secure +ttya "/usr/libexec/getty std.9600" unknown on secure +ttyb "/usr/libexec/getty std.9600" unknown off secure +ttyp0 none network +ttyp1 none network +ttyp2 none network +ttyp3 none network +ttyp4 none network +ttyp5 none network +ttyp6 none network +ttyp7 none network +ttyp8 none network +ttyp9 none network +ttypa none network +ttypb none network +ttypc none network +ttypd none network +ttype none network +ttypf none network +ttyq0 none network +ttyq1 none network +ttyq2 none network +ttyq3 none network +ttyq4 none network +ttyq5 none network +ttyq6 none network +ttyq7 none network +ttyq8 none network +ttyq9 none network +ttyqa none network +ttyqb none network +ttyqc none network +ttyqd none network +ttyqe none network +ttyqf none network diff --git a/src/etc/etc.svr4/SVR4_MAKEDEV b/src/etc/etc.svr4/SVR4_MAKEDEV new file mode 100644 index 00000000..7446b11e --- /dev/null +++ b/src/etc/etc.svr4/SVR4_MAKEDEV @@ -0,0 +1,79 @@ +#!/bin/sh - +# $NetBSD: SVR4_MAKEDEV,v 1.1 1995/07/02 06:29:46 christos Exp $ +# +# Copyright (c) 1995 Christos Zoulas +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# 3. The name of the author may not be used to endorse or promote products +# derived from this software without specific prior written permission +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +# +# Device "make" file. Valid arguments: +# all everything +# Network: +# udp UDP socket creation +# tcp TCP socket creation +# ticotsord XXX: tcp for now +# Various: +# wabi Windows emulation; /dev/null for now +# +PATH=/sbin:/bin/:/usr/bin:/usr/sbin:/usr/etc +umask 77 + +for i +do + +unit=`expr $i : '[a-z][a-z]*\([0-9][0-9]*\)'` +[ "$unit" ] || unit=0 + +case $i in + +all) + sh SVR4_MAKEDEV tcp udp wabi ticotsord + ;; +tcp) + mknod $i c 43 35 + chown bin.bin $i + chmod 666 $i + ;; + +udp) + mknod udp c 43 36 + chown bin.bin $i + chmod 666 $i + ;; +wabi) + mknod $i c 3 2 # /dev/null + chown bin.bin $i + chmod 666 $i + ;; +ticotsord) + mknod $i c 43 35 # /dev/tcp + chown bin.bin $i + chmod 666 $i + ;; + +*) + echo $i: unknown device + ;; +esac +done + diff --git a/src/etc/etc.svr4/netconfig b/src/etc/etc.svr4/netconfig new file mode 100644 index 00000000..21830244 --- /dev/null +++ b/src/etc/etc.svr4/netconfig @@ -0,0 +1,7 @@ +# $NetBSD: netconfig,v 1.1 1995/07/02 06:29:49 christos Exp $ +# SVR4 Network configuration file +# +# service name fl family proto device library +udp tpi_clts v inet udp /dev/udp - +tcp tpi_cots_ord v inet tcp /dev/tcp - +ticotsord tpi_cots_ord v loopback - /dev/ticotsord straddr.so diff --git a/src/etc/etc.svr4/nsswitch.conf b/src/etc/etc.svr4/nsswitch.conf new file mode 100644 index 00000000..3e3f4de9 --- /dev/null +++ b/src/etc/etc.svr4/nsswitch.conf @@ -0,0 +1,15 @@ +# $NetBSD: nsswitch.conf,v 1.1 1995/07/02 06:29:51 christos Exp $ +# Name service switch file +# +hosts: dns files +networks: nis files +protocols: nis files +ethers: nis files +rpc: nis files +netmasks: nis files +bootparams: nis files +services: files nis +# +passwd: files nis +group: files nis +netgroup: nis files diff --git a/src/etc/etc.vax/MAKEDEV b/src/etc/etc.vax/MAKEDEV new file mode 100644 index 00000000..87208e4e --- /dev/null +++ b/src/etc/etc.vax/MAKEDEV @@ -0,0 +1,387 @@ +#!/bin/sh - +# $NetBSD: MAKEDEV,v 1.2 1995/09/05 19:53:01 ragge Exp $ +# +# @(#)MAKEDEV 8.1 (Berkeley) 6/9/93 +# +# Device "make" file. Valid arguments: +# std standard devices +# local configuration specific devices +# Tapes: +# ht* massbus tm03 & tu?? +# tm* unibus tm11 & te10 emulations (e.g. Emulex tc-11) +# tms* unibus/qbus TMSCP (e.g. TU81, TK50) +# ts* unibus ts11 +# mt* massbus tu78 +# ut* unibus tu45 emulations (e.g.si 9700) +# uu* tu58 cassettes on dl11 controller +# Disks: +# hp* massbus rm?? +# hk* unibus rk06 and rk07 +# up* other unibus devices (e.g. on Emulex sc-21v controller) +# ra* unibus uda50 w/ ra?? +# kra* bi kdb50 w/ ra?? +# rl* unibus rl02 +# rb* 730 idc w/ rb80 and/or rb02 +# rx* unibus rx211 floppy disk +# ccd* "concatenated" pseudo-disks +# vnd* "file" pseudo-disks +# Terminal multiplexors: +# dz* unibus dz11 and dz32 +# dh* unibus dh11 and emulations (e.g. Able dmax, Emulex cs-11) +# dmf* unibus dmf32 +# dhu* unibus dhu11 +# dmz* unibus dmz32 +# Pseudo terminals: +# pty* set of 16 master and slave pseudo terminals +# Printers: +# ct* unibus parallel interface to CAT typesetter +# lp* unibus lp11 parallel interface +# va* unibus varian parallel interface +# vp* unibus versatec parallel interface +# Call units: +# dn* unibus dn11 and emulations (e.g. Able Quadracall) +# Special purpose devices: +# ik* unibus interface to ikonas frame buffer +# ps* unibus interface to e&s picture system 2 +# ad* unibus interface to data translation a/d converter +# np* unibus ethernet co-processor interface, for downloading. +# qv* qvss (microvax) display +# ttyv0 qvss (microvax) display reserved pty +# lkm loadable kernel modules +PATH=/sbin:/bin:/usr/bin +umask 77 +for i +do +case $i in + +std) + mknod console c 0 0 + mknod drum c 7 0 ; chmod 640 drum ; chgrp kmem drum + mknod floppy c 8 0 + mknod crl c 35 0 + mknod csa1 c 51 0 + mknod csa2 c 51 1 + mknod tu0 b 8 0 + mknod tu1 b 8 1 + mknod kUmem c 3 3 ; chmod 600 kUmem + mknod kmem c 3 1 ; chmod 640 kmem ; chgrp kmem kmem + mknod mem c 3 0 ; chmod 640 mem ; chgrp kmem mem + mknod null c 3 2 ; chmod 666 null + mknod zero c 3 12 ; chmod 666 zero + mknod tty c 2 0 ; chmod 666 tty + mknod klog c 33 0 ; chmod 600 klog + mknod stdin c 53 0 ; chmod 666 stdin + mknod stdout c 53 1 ; chmod 666 stdout + mknod stderr c 53 2 ; chmod 666 stderr + mkdir fd > /dev/null 2>&1 + (cd fd && eval `echo "" | awk ' BEGIN { \ + for (i = 0; i < 64; i++) \ + printf("mknod %d c 53 %d;", i, i)}'`) + chown -R bin.bin fd + chmod 555 fd + chmod 666 fd/* + ;; + +ht*|tm*|tms*|ts*|ut*) + umask 0 ; unit=`expr $i : '[^0-9]*\(.*\)'` + case $i in + ht*) blk=1; chr=5 ;; + tms*) blk=15; chr=38;; + tm*) blk=5; chr=14;; + ts*) blk=6; chr=16;; + ut*) blk=10; chr=17;; + esac + case $unit in + 0|1|2|3|4|5|6|7) + four=`expr $unit + 4` ; eight=`expr $unit + 8` + twelve=`expr $unit + 12`; twenty=`expr $unit + 20` + mknod mt$unit b $blk $unit + mknod mt$four b $blk $four + mknod mt$eight b $blk $eight + mknod mt$twelve b $blk $twelve + mknod nmt$unit b $blk $four ;: sanity w/pdp11 v7 + mknod nmt$eight b $blk $twelve ;: ditto + mknod nrmt$unit c $chr $four ;: sanity w/pdp11 v7 + mknod nrmt$eight c $chr $twelve ;: ditto + mknod rmt$unit c $chr $unit + mknod rmt$four c $chr $four + mknod rmt$eight c $chr $eight + mknod rmt$twelve c $chr $twelve + if [ $i = ut ] + then + mknod mt$twenty b $blk $twenty + mknod rmt$twenty c $chr $twenty + fi + ;; + *) + echo bad unit for tape in: $1 + ;; + esac + umask 77 + ;; + +mt*) + umask 0 ; unit=`expr $i : '..\(.*\)'` + case $i in + mt*) blk=7; chr=19;; + esac + case $unit in + 0|1|2|3|4|5|6|7) + eight=`expr $unit + 0`; + twelve=`expr $unit + 4`; + sixteen=`expr $unit + 8`; + twenty=`expr $unit + 12`; + mknod mt8 b $blk $eight + mknod mt12 b $blk $twelve + mknod mt16 b $blk $sixteen + mknod mt20 b $blk $twenty + mknod nmt8 b $blk $twelve ;: ditto + mknod nrmt8 c $chr $twelve ;: ditto + mknod rmt8 c $chr $eight + mknod rmt12 c $chr $twelve + mknod rmt16 c $chr $sixteen + mknod rmt20 c $chr $twenty + mknod nmt16 b $blk $twenty ;: ditto + mknod nrmt16 c $chr $twenty ;: ditto + ;; + *) + echo bad unit for tape in: $1 + ;; + esac + umask 77 + ;; + +hp*|hk*|up*|ra*|kra*|rl*|rb*|ccd*|vnd*) + umask 2 ; unit=`expr $i : '.*[^0-9]\([0-9]*\)'` + case $i in + hp*) name=hp; blk=0; chr=4;; + hk*) name=hk; blk=3; chr=11;; + up*) name=up; blk=2; chr=13;; + ra*) name=ra; blk=9; chr=9;; + kra*) name=kra; blk=16; chr=52;; + rb*) name=rb; blk=11; chr=23;; + rl*) name=rl; blk=14; chr=32;; + ccd*) name=ccd; blk=17; chr=54;; + vnd*) name=vnd; blk=18; chr=55;; + esac + case $unit in + 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|\ + 17|18|19|20|21|22|23|24|25|26|27|28|29|30|31) + mknod ${name}${unit}a b $blk `expr $unit '*' 8 + 0` + mknod ${name}${unit}b b $blk `expr $unit '*' 8 + 1` + mknod ${name}${unit}c b $blk `expr $unit '*' 8 + 2` + mknod ${name}${unit}g b $blk `expr $unit '*' 8 + 6` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1` + mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2` + mknod r${name}${unit}g c $chr `expr $unit '*' 8 + 6` + if [ $name != hk ] + then + mknod ${name}${unit}d b $blk `expr $unit '*' 8 + 3` + mknod ${name}${unit}e b $blk `expr $unit '*' 8 + 4` + mknod ${name}${unit}f b $blk `expr $unit '*' 8 + 5` + mknod ${name}${unit}h b $blk `expr $unit '*' 8 + 7` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + mknod r${name}${unit}e c $chr `expr $unit '*' 8 + 4` + mknod r${name}${unit}f c $chr `expr $unit '*' 8 + 5` + mknod r${name}${unit}h c $chr `expr $unit '*' 8 + 7` + fi + chgrp operator ${name}${unit}[a-h] r${name}${unit}[a-h] + chmod 640 ${name}${unit}[a-h] r${name}${unit}[a-h] + ;; + *) + echo bad unit for disk in: $i + ;; + esac + umask 77 + ;; + +rx*) + unit=`expr $i : '..\(.*\)'` + name=rx; chr=30; blk=12; + case $unit in + 0|1|2|3|4|5|6|7) + mknod ${name}${unit} b $blk `expr $unit '*' 8 + 0` + mknod r${name}${unit}a c $chr `expr $unit '*' 8 + 0` + mknod r${name}${unit}b c $chr `expr $unit '*' 8 + 1` + mknod r${name}${unit}c c $chr `expr $unit '*' 8 + 2` + mknod r${name}${unit}d c $chr `expr $unit '*' 8 + 3` + ;; + *) + echo bad unit for floppy disk in: $i + ;; + esac + ;; + +uu*) + unit=`expr $i : '..\(.*\)'` + name=uu; blk=13; + case $unit in + 0|1|2|3) + mknod ${name}${unit} b $blk `expr $unit '*' 2 + 0` + mknod ${name}${unit}a b $blk `expr $unit '*' 2 + 1` + ;; + *) + echo bad unit for uu cassette in: $i + ;; + esac + ;; + +dz*) + unit=`expr $i : 'dz\(.*\)'` + case $unit in + 0|1|2|3|4|5|6|7) + eval `echo $unit | awk ' { u = $1 } END { + for (i = 0; i < 8; i++) + printf("mknod tty%02d c 1 %d; ",u*8+i,u*8+i); }'` + ;; + *) + echo bad unit for dz in: $i + ;; + esac + ;; + +dhu*|dh*|dmf*|dmz*) + case $i in + dmz*) name=dmz; major=37; count=24; + unit=`expr $i : "$name\(.*\)"` + case $unit in + 0) ch=a ;; 1) ch=b ;; 2) ch=c ;; 3) ch=e ;; + 4) ch=f ;; 5) ch=g ;; + *) echo bad unit for $name in: $i ;; + esac;; + dmf*) name=dmf; major=22; count=8; + unit=`expr $i : "$name\(.*\)"` + case $unit in + 0) ch=A ;; 1) ch=B ;; 2) ch=C ;; 3) ch=E ;; + 4) ch=F ;; 5) ch=G ;; 6) ch=H ;; 7) ch=I ;; + *) echo bad unit for $name in: $i ;; + esac;; + dhu*) name=dhu; major=34; count=16; + unit=`expr $i : "$name\(.*\)"`; + case $unit in + 0) ch=S ;; 1) ch=T ;; 2) ch=U ;; 3) ch=V ;; + 4) ch=W ;; 5) ch=X ;; 6) ch=Y ;; 7) ch=Z ;; + *) echo bad unit for $name in: $i ;; + esac;; + dh*) name=dh; major=12; count=16; + unit=`expr $i : "$name\(.*\)"` + case $unit in + 0) ch=h ;; 1) ch=i ;; 2) ch=j ;; 3) ch=k ;; + 4) ch=l ;; 5) ch=m ;; 6) ch=n ;; 7) ch=o ;; + *) echo bad unit for $name in: $i ;; + esac;; + esac + eval `echo $ch $unit $major $count | + awk ' { ch = $1; u = $4 * $2; m = $3; cnt = $4 } END { + for (i = 0; i < cnt; i++) + if (i < 10) + printf("mknod tty%s%x c %d %d; ",ch,i,m,u+i); + else + printf("mknod tty%s%c c %d %d; ",ch,87+i,m,u+i); }'` + ;; + +lp*|va*|vp*) + case $i in + lp*) name=lp; major=15;; + va*) name=va; major=10;; + vp*) name=vp; major=6;; + esac + unit=`expr $i : "$name\(.*\)"` + case $unit in + 0|1|2|3|4|5|6|7) + mknod $i c $major $unit; + chmod 666 $i + ;; + *) + echo bad unit for $name in: $i + ;; + esac + ;; + +pty*) + class=`expr $i : 'pty\(.*\)'` + case $class in + 0) offset=0 name=p;; + 1) offset=16 name=q;; + 2) offset=32 name=r;; + 3) offset=48 name=s;; + 4) offset=64 name=t;; + 5) offset=80 name=u;; + *) echo bad unit for pty in: $i;; + esac + case $class in + 0|1|2|3|4|5) + umask 0 + eval `echo $offset $name | awk ' { b=$1; n=$2 } END { + for (i = 0; i < 16; i++) + printf("mknod tty%s%x c 20 %d; \ + mknod pty%s%x c 21 %d; ", \ + n, i, b+i, n, i, b+i); }'` + umask 77 + ;; + esac + ;; + +np*) + class=`expr $i : 'np\(.*\)'` + case $class in + 0) offset=0 name=0;; + 1) offset=16 name=1;; + 2) offset=32 name=2;; + *) echo bad unit for np in: $i;; + esac + case $class in + 0|1|2) + eval `echo $offset | awk ' { b=$1 } END { + for (i = 0; i < 4; i++) + printf("mknod np%02d c 39 %d;", \ + b+i, b+i); }'` + ;; + esac + ;; + +dn*|ik*|ps*|ad*|ct*) + unit=`expr $i : '..\(.*\)'` + case $i in + ct*) name=ct; chr=18;; + dn*) name=cu; chr=24;; + ps*) name=ps; chr=27;; + ad*) name=ad; chr=29;; + ik*) name=ik; chr=31;; + esac + case $unit in + 0|1|2|3|4|5|6|7) + umask 0 + mknod ${name}${unit} c ${chr} ${unit} + umask 77 + ;; + *) + echo bad unit for ${name} in: $i + ;; + esac + ;; + +lkm) + mknod lkm c 28 0 + chown root.kmem lkm + chmod 640 lkm + ;; + +qv0) + mknod qv0 c 40 0 + mknod qvcons c 40 1 + mknod mouse c 40 2 + ;; + +ttyv0) + if [ ! -f ttyqe ]; then sh ./MAKEDEV pty1; fi + mv ttyqf ttyv0 + mv ptyqf ptyv0 + ;; + +local) + sh MAKEDEV.local + ;; +esac +done diff --git a/src/etc/etc.vax/disktab b/src/etc/etc.vax/disktab new file mode 100644 index 00000000..70dbfd46 --- /dev/null +++ b/src/etc/etc.vax/disktab @@ -0,0 +1,491 @@ +# $NetBSD: disktab,v 1.1 1995/08/25 21:25:11 ragge Exp $ +# +# @(#)disktab 8.1 (Berkeley) 6/9/93 +# +# Disk geometry and partition layout tables. +# Key: +# dt controller type +# ty type of disk (fixed, removeable, simulated) +# d[0-4] drive-type-dependent parameters +# ns #sectors/track +# nt #tracks/cylinder +# nc #cylinders/disk +# sc #sectors/cylinder, nc*nt default +# su #sectors/unit, sc*nc default +# se sector size, DEV_BSIZE default +# rm rpm, 3600 default +# sf supports bad144-style bad sector forwarding +# sk sector skew per track, default 0 +# cs sector skew per cylinder, default 0 +# hs headswitch time, default 0 +# ts one-cylinder seek time, default 0 +# il sector interleave (n:1), 1 default +# bs boot block size, default BBSIZE +# sb superblock size, default SBSIZE +# o[a-h] partition offsets in sectors +# p[a-h] partition sizes in sectors +# b[a-h] partition block sizes in bytes +# f[a-h] partition fragment sizes in bytes +# t[a-h] partition types (filesystem, swap, etc) +# b[0-1] primary and secondary bootstraps, optional +# +# WARNING: +# On drives that contain bad-sector replacement areas, +# `c' partitions DO overlap the bad-sector replacements. +# This may change again. +# Other partitions do not overlap the bad-sector replacement area. +# +# Existing entries may also be used for other compatible drives +# with the same geometry. + +# +# Drives on hp +# +# drive-type parameters for SMD disks: +# d0 binary flags: 1=skip-sector support (RM80) +# d1 mindist (closest #sectors from desired for starting transfer) +# d2 maxdist (farthest #sectors from desired for starting transfer) +# d3 sdist (distance from desired sector for search) +# NOTE: c partitions include bad-sector replacement areas! +rm03|RM03|DEC RM03:\ + :ty=removable:ns#32:nt#5:nc#823:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#16000:bb#8192:fb#1024:tb=swap:\ + :pc#131680:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#49440:bd#4096:fd#512:\ + :pe#55936:oe#65440:be#8192:fe#1024:\ + :pf#10080:of#121440:bf#8192:ff#1024:\ + :pg#82080:og#49440:bg#8192:fg#1024: +# :pc#131520:oc#0:bc#8192:fc#1024: +rm05|RM05|DEC RM05:\ + :ty=removable:ns#32:nt#19:nc#823:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#16416:bb#8192:fb#1024:tb=swap:\ + :pc#500384:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#341696:bd#4096:fd#512:\ + :pe#55936:oe#358112:be#8192:fe#1024:\ + :pf#86176:of#414048:bf#8192:ff#1024:\ + :pg#158528:og#341696:bg#8192:fg#1024:\ + :ph#291346:oh#49856:bh#8192:fh#1024: +# :pc#500224:oc#0:bc#8192:fc#1024: +rp06|RP06|DEC RP06:\ + :ty=removable:ns#22:nt#19:nc#815:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#15884:bb#8192:fb#1024:tb=swap:\ + :pc#340670:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#49324:bd#4096:fd#512:\ + :pe#55936:oe#65208:be#8192:fe#1024:\ + :pf#219296:of#121220:bf#8192:ff#1024:\ + :pg#291192:og#49324:bg#8192:fg#1024: +# :pc#340516:oc#0:bc#8192:fc#1024: +rm80|RM80|DEC RM80:\ + :ty=winchester:ns#31:nt#14:nc#559:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#16058:bb#8192:fb#1024:tb=swap:\ + :pc#242606:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#49910:bd#4096:fd#512:\ + :pe#55936:oe#65968:be#8192:fe#1024:\ + :pf#120466:of#121954:bf#8192:ff#1024:\ + :pg#192510:og#49910:bg#8192:fg#1024: +# :pc#242420:oc#0:bc#8192:fc#1024: +rp05|RP05|DEC RP05:\ + :ty=removable:ns#22:nt#19:nc#411:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#15884:bb#8192:fb#1024:tb=swap:\ + :pc#171798:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#49324:bd#4096:fd#512:\ + :pe#55936:oe#65208:be#8192:fe#1024:\ + :pf#50424:of#121220:bf#8192:ff#1024:\ + :pg#122320:og#49324:bg#8192:fg#1024: +# :pc#171644:oc#0:bc#8192:fc#1024: +rp07|RP07|DEC RP07:\ + :ty=winchester:ns#50:nt#32:nc#630:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#66880:ob#16000:bb#8192:fb#1024:tb=swap:\ + :pc#1008000:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#376000:bd#4096:fd#512:\ + :pe#307200:oe#392000:be#8192:fe#1024:\ + :pf#308600:of#699200:bf#8192:ff#1024:\ + :pg#631800:og#376000:bg#8192:fg#1024:\ + :ph#291346:oh#83200:bh#8192:fh#1024: +# :pc#1007800:oc#0:bc#8192:fc#1024: +ml11|ml11a|ml11b|ML11A|ML11B|DEC disk emulator:\ + :ty=simulated:dt=SMD:ns#1:nt#1:nc#2000: +9775|CDC 9775:\ + :ty=winchester:ns#32:nt#40:nc#842:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#66880:ob#16640:bb#8192:fb#1024:tb=swap:\ + :pc#1077760:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#376320:bd#4096:fd#512:\ + :pe#307200:oe#392960:be#8192:fe#1024:\ + :pf#377440:of#700160:bf#8192:ff#1024:\ + :pg#701280:og#376320:bg#8192:fg#1024:\ + :ph#291346:oh#84480:bh#8192:fh#1024: +# :pc#1077600:oc#0:bc#8192:fc#1024: +9730|CDC 9730:\ + :ty=removable:ns#32:nt#10:nc#823:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#16000:bb#8192:fb#1024:tb=swap:\ + :pc#263360:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#49600:bd#4096:fd#512:\ + :pe#55936:oe#65600:be#8192:fe#1024:\ + :pf#141600:of#121600:bf#8192:ff#1024:\ + :pg#213600:og#49600:bg#8192:fg#1024: +# :pc#263200:oc#0:bc#8192:fc#1024: +capricorn|330|Capricorn|Ampex Capricorn:\ + :ty=winchester:ns#32:nt#16:nc#1024:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#16384:bb#8192:fb#1024:tb=swap:\ + :pc#524488:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#342016:bd#4096:fd#512:\ + :pe#55936:oe#358400:be#8192:fe#1024:\ + :pf#109408:of#414720:bf#8192:ff#1024:\ + :pg#182112:og#342016:bg#8192:fg#1024:\ + :ph#291346:oh#50176:bh#8192:fh#1024: +# :pc#524128:oc#0:bc#8192:fc#1024: +eagle|Eagle|2351|2351A|Fujitsu Eagle 2351A (48 sectors):\ + :ty=winchester:ns#48:nt#20:nc#842:rm#3961:sf:\ + :dt=smd:d0#0:d1#6:d2#17:d3#7:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#66880:ob#16320:bb#8192:fb#1024:tb=swap:\ + :pc#808320:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#375360:bd#4096:fd#512:\ + :pe#307200:oe#391680:be#8192:fe#1024:\ + :pf#109248:of#698880:bf#8192:ff#1024:\ + :pg#432768:og#375360:bg#8192:fg#1024:\ + :ph#291346:oh#83520:bh#8192:fh#1024: +# :pc#808128:oc#0:bc#8192:fc#1024: +2361|doubleeagle|Fujitsu 2361 (Double Eagle, 64 sectors):\ + :ty=winchester:ns#64:nt#20:nc#842:sf:\ + :dt=smd:d0#0:d1#6:d2#17:d3#7:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#66880:ob#16640:bb#8192:fb#1024:tb=swap:\ + :pc#1077760:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#376320:bd#4096:fd#512:\ + :pe#307200:oe#392960:be#8192:fe#1024:\ + :pf#377408:of#700160:bf#8192:ff#1024:\ + :pg#701248:og#376320:bg#8192:fg#1024:\ + :ph#291346:oh#84480:bh#8192:fh#1024: +# :pc#1077568:oc#0:bc#8192:fc#1024: + +2361a|doubleeagle|Fujitsu 2361 (Double Eagle, 68 sectors):\ + :ty=winchester:ns#68:nt#20:nc#842:sf:\ + :dt=smd:d0#0:d1#6:d2#17:d3#7:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#66880:ob#16320:bb#8192:fb#1024:tb=swap:\ + :pc#1145120:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#376720:bd#4096:fd#512:\ + :pe#307200:oe#393040:be#8192:fe#1024:\ + :pf#444516:of#700400:bf#8192:ff#1024:\ + :pg#768196:og#376720:bg#8192:fg#1024:\ + :ph#291346:oh#84320:bh#8192:fh#1024: +# :pc#1144916:oc#0:bc#8192:fc#1024: +# +# IDC disks +# +# RL02/RB02 have 256-byte sectors, +# but partitions are still in units of 512-byte sectors +rb02|RB02|DEC RL02 on 730 IDC:\ + :ty=removable:se#256:ns#40:nt#2:nc#512:\ + :dt=old DEC:\ + :pa#15884:oa#0:ba#4096:fa#1024:\ + :pb#4480:ob#16000:bb#4096:fb#512:tb=swap:\ + :pc#20480:oc#0:bc#4096:fc#512: +rb80|RB80|DEC R80 on 730 IDC:\ + :ty=winchester:ns#31:nt#14:nc#559:\ + :dt=old DEC:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#16058:bb#8192:fb#1024:tb=swap:\ + :pc#242606:oc#0:bc#8192:fc#1024:\ + :pg#82080:og#49910:bg#4096:fg#512:\ + :ph#192696:oh#132270:bh#8192:fh#1024: +# +# Disks for rk +# +rk06|RK06|DEC RK06:\ + :ty=removable:ns#22:nt#3:nc#411:sf:\ + :dt=old DEC:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#11154:ob#15906:bb#4096:fb#512:tb=swap:\ + :pc#27126:oc#0:bc#4096:fc#512: +# :pc#26978:oc#0:bc#4096:fc#512: +rk07|RK07|DEC RK07:\ + :ty=removable:ns#22:nt#3:nc#815:sf:\ + :dt=old DEC:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#10032:ob#15906:bb#8192:fb#1024:tb=swap:\ + :pc#53790:oc#0:bc#4096:fc#512:\ + :pd#15884:od#25938:bd#4096:fd#512:\ + :pf#11792:of#41844:bf#4096:ff#1024:\ + :pg#27698:og#25938:bg#4096:fg#512: +# :pc#53636:oc#0:bc#4096:fc#512: +# +# Disks normally on up +# +160|fuji|fuji160|Fujitsu 160:\ + :ty=winchester:ns#32:nt#10:nc#823:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#16000:bb#8192:fb#1024:tb=swap:\ + :pc#263360:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#49600:bd#4096:fd#512:\ + :pe#55936:oe#65600:be#8192:fe#1024:\ + :pf#141600:of#121600:bf#8192:ff#1024:\ + :pg#213600:og#49600:bg#8192:fg#1024: +# :pc#263200:oc#0:bc#8192:fc#1024: +9300|Ampex 9300:\ + :ty=removable:ns#32:nt#19:nc#815:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#16416:bb#8192:fb#1024:tb=swap:\ + :pc#495520:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#341696:bd#4096:fd#512:\ + :pe#55936:oe#358112:be#8192:fe#1024:\ + :pf#81312:of#414048:bf#8192:ff#1024:\ + :pg#153664:og#341696:bg#8192:fg#1024:\ + :ph#291346:oh#49856:bh#8192:fh#1024: +# :pc#495360:oc#0:bc#8192:fc#1024: +9766|CDC 9766:\ + :ty=removable:ns#32:nt#19:nc#823:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#16416:bb#8192:fb#1024:tb=swap:\ + :pc#500384:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#341696:bd#4096:fd#512:\ + :pe#55936:oe#358112:be#8192:fe#1024:\ + :pf#86176:of#414048:bf#8192:ff#1024:\ + :pg#158528:og#341696:bg#8192:fg#1024:\ + :ph#291346:oh#49856:bh#8192:fh#1024: +# :pc#500224:oc#0:bc#8192:fc#1024: +980|9762|AMPEX DM980|CDC 9762:\ + :ty=removable:ns#32:nt#5:nc#823:sf:\ + :dt=smd:d0#0:d1#3:d2#10:d3#6:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#16000:bb#8192:fb#1024:tb=swap:\ + :pc#131680:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#49440:bd#4096:fd#512:\ + :pe#55936:oe#65440:be#8192:fe#1024:\ + :pf#10080:of#121440:bf#8192:ff#1024:\ + :pg#82080:og#49440:bg#8192:fg#1024: +# :pc#131520:oc#0:bc#8192:fc#1024: +# +# Disk on a UDA50 +# NOTE: new partition sizes since 4.2. +# +# RA60: standard use a-b-f +# 4.2 compatible use a-b-d-e where 4.2 g == d; 4.2 h == e +# UCB compatible use a-b-h-g where UCB h == h; UCB g == g +ra60|RA60|DEC RA60 Removable:\ + :ty=removable:ns#42:nt#4:nc#2382:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#15884:bb#8192:fb#1024:tb=swap:\ + :pc#400176:oc#0:bc#8192:fc#1024:\ + :pd#82080:od#49324:bd#4096:fd#512:\ + :pe#268772:oe#131404:be#4096:fe#512:\ + :pf#350852:of#49324:bf#4096:ff#512:\ + :pg#157570:og#242606:bg#4096:fg#1024:\ + :ph#193282:oh#49324:bh#4096:fh#512: +# +# RA80: standard use a-b-g +# 4.2 compatible use a-b-f-h where 4.2 g == f; 4.2 h == h +# UCB compatible use a-b-e where UCB h == e +ra80|RA80|DEC RA80 Winchester:\ + :ty=winchester:ns#31:nt#14:nc#546:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#15884:bb#8192:fb#1024:tb=swap:\ + :pc#236964:oc#0:bc#8192:fc#1024:\ + :pe#187640:oe#49324:be#4096:fe#512:\ + :pf#82080:of#49324:bf#4096:ff#512:\ + :pg#187054:og#49910:bg#4096:fg#1024:\ + :ph#105560:oh#131404:bh#4096:fh#512: +# +# RA81: standard use a-b-h-g or a-b-h-d-e-f +# When compiled as COMPAT_42 d-e-f are used for 4.2 compatible as: +# 4.2 g == d; 4.2 h == e; 4.2 f == f +ra81|RA81|DEC RA81 Winchester:\ + :ty=winchester:ns#51:nt#14:nc#1248:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#66880:ob#16422:bb#8192:fb#1024:tb=swap:\ + :pc#891072:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#375564:bd#4096:fd#512:\ + :pe#307200:oe#391986:be#8192:fe#1024:\ + :pf#191352:of#699720:bf#8192:ff#1024:\ + :pg#515508:og#375564:bg#8192:fg#1024:\ + :ph#291346:oh#83538:bh#8192:fh#1024: +# RACOMPAT RA81: should you need to create more of these awful partitions +# When compiled as RACOMPAT d-e-f are used for 4.2 compatible as: +# 4.2 g == d; 4.2 h == e; 4.2 f == f +racompat81|compat_42ra81|COMPAT_42RA81|DEC COMPAT_42RA81 Winchester:\ + :ty=winchester:ns#51:nt#14:nc#1248:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#66880:ob#16422:bb#8192:fb#1024:tb=swap:\ + :pc#891072:oc#0:bc#8192:fc#1024:\ + :pd#82080:od#49324:bd#4096:fd#512:\ + :pe#759668:oe#131404:be#4096:fe#512:\ + :pf#478582:of#412490:bf#4096:ff#512: + :pg#515508:og#375564:bg#8192:fg#1024:\ + :ph#291346:oh#83538:bh#8192:fh#1024: +# +# UCB RA81: use a-b-h-g or a-b-h-d-e-f +ucbra81|UCBRA81|DEC UCBRA81 Winchester:\ + :ty=winchester:ns#51:nt#14:nc#1248:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#15884:bb#4096:fb#512:tb=swap:\ + :pc#891072:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#242606:bd#4096:fd#512:\ + :pe#307200:oe#258490:be#8192:fe#1024:\ + :pf#325382:of#565690:bf#4096:ff#512:\ + :pg#648466:og#242606:bg#4096:fg#1024:\ + :ph#193282:oh#49324:bh#4096:fh#512: +# +# RA82: standard, use a-b-h-g or a-b-h-d-e-f +ra82|RA81|DEC RA82 Winchester:\ + :ty=winchester:ns#57:nt#15:nc#1423:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#66880:ob#16245:bb#8192:fb#1024:tb=swap:\ + :pc#1216665:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#375345:bd#4096:fd#512:\ + :pe#307200:oe#391590:be#8192:fe#1024:\ + :pf#517275:of#699390:bf#8192:ff#1024:\ + :pg#841320:og#375345:bg#8192:fg#1024:\ + :ph#291346:oh#83790:bh#8192:fh#1024: +# +# RA90 +ra90|RA90|DEC RA90 Winchester:\ + :ty=winchester:ns#69:nt#13:nc#2649:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#66880:ob#16146:bb#8192:fb#1024:tb=swap:\ + :pc#2376153:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#374946:bd#4096:fd#512:\ + :pe#307200:oe#391092:be#8192:fe#1024:\ + :pf#1677390:of#698763:bf#8192:ff#1024:\ + :pg#2001207:og#374946:bg#8192:fg#1024:\ + :ph#291346:oh#83421:bh#8192:fh#1024: +# +# RA92 +ra92|RA92|DEC RA92 Winchester:\ + :ty=winchester:ns#69:nt#13:nc#3279:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#66880:ob#16146:bb#8192:fb#1024:tb=swap:\ + :pc#2941263:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#374946:bd#4096:fd#512:\ + :pe#307200:oe#391092:be#8192:fe#1024:\ + :pf#2242500:of#698763:bf#8192:ff#1024:\ + :pg#2566317:og#374946:bg#8192:fg#1024:\ + :ph#291346:oh#83421:bh#8192:fh#1024: +# +# RA70 +ra70|RA70|DEC RA70:\ + :ty=winchester:ns#33:nt#11:nc#1507:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#15972:bb#8192:fb#1024:tb=swap:\ + :pc#547041:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#341220:bd#4096:fd#512:\ + :pe#55936:oe#357192:be#8192:fe#1024:\ + :pf#133584:of#413457:bf#8192:ff#1024:\ + :pg#205821:og#341220:bg#8192:fg#1024:\ + :ph#291346:oh#49731:bh#8192:fh#1024: +# +# RC25 +rc25|RC25:\ + :ty=winchester:ns#42:nt#4:nc#302:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#10032:ob#15884:bb#8192:fb#1024:tb=swap:\ + :pc#50736:oc#0:bc#8192:fc#1024:\ + :pg#24820:og#25916:bg#8192:fg#1024: +# +# Disks on RQDX Q-bus controllers +rd52|RD52|DEC RD52 on Microvax:\ + :ty=winchester:ns#18:nt#7:nc#480:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#4096:fa#1024:\ + :pb#9766:ob#15884:bb#4096:fb#512:tb=swap:\ + :pc#60480:oc#0:bc#4096:fc#512:\ + :pg#34830:og#25650:bg#4096:fg#512:\ + :b0=rdboot: +# +rd53|RD53|DEC RD53 on Microvax:\ + :ty=winchester:ns#18:nt#8:nc#963:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#15884:bb#4096:fb#512:tb=swap:\ + :pc#138672:oc#0:bc#4096:fc#512:\ + :pe#33440:oe#0:be#4096:fe#512:\ + :pf#105232:of#33440:bf#4096:ff#512:\ + :pg#89348:og#49324:bg#4096:fg#512:\ + :ph#122788:oh#15884:bh#4096:fh#512:\ + :b0=rdboot: +# +rd54|RD54|DEC RD54 on Microvax:\ + :ty=winchester:ns#17:nt#15:nc#1225:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#33440:ob#15884:bb#8192:fb#1024:tb=swap:\ + :pc#311200:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#49324:bd#4096:fd#512:\ + :pe#55936:oe#65208:be#8192:fe#1024:\ + :pf#190485:of#121144:bf#8192:ff#1024:\ + :pg#261876:og#49324:bg#8192:fg#1024:\ + :b0=rdboot: +# +qdeagle|qd-eagle|Fujitsu 2351A eagle on QD33 (Microvax):\ + :ty=winchester:ns#47:nt#20:nc#840:\ + :dt=MSCP:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#66880:ob#15980:bb#8192:fb#1024:tb=swap:\ + :pc#787156:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#375060:bd#4096:fd#512:\ + :pe#307200:oe#391040:be#8192:fe#1024:\ + :pf#88736:of#698420:bf#8192:ff#1024:\ + :pg#412096:og#375060:bg#8192:fg#1024:\ + :ph#291346:oh#83660:bh#8192:fh#1024:\ + :b0=rdboot: +# +# RX02 floppy disk drives +# +rx02|RX02|DEC RX02:\ + :ty=removable:ns#13:nt#1:nc#77:\ + :dt=floppy:\ + :pa#1001:oa#0:ba#4096:fa#512: + +ncc|nec800|800 Mb NEC:\ + :ty=winchester:ns#66:nt#23:nc#850:rm#3600:se#512:\ + :dt=SMD:\ + :d0#0:d1#40960:\ + :pa#97152:oa#0:ba#8192:fa#1024:\ + :pb#92598:ob#97152:bb#8192:fb#1024:tb=swap:\ + :pc#1092960:oc#189750:bc#8192:fc#1024:\ + :ph#1282710:oh#0:bh#8192:fh#1024: + +ncc2|nec2363|1Gb NEC:\ + :ty=winchester:ns#64:nt#27:nc#1024:rm#3600:se#512:\ + :dt=SMD:\ + :d0#0:\ + :pa#15884:oa#0:ba#8192:fa#1024:\ + :pb#66880:ob#17280:bb#8192:fb#1024:tb=swap:\ + :pc#1769472:oc#0:bc#8192:fc#1024:\ + :pd#15884:od#376704:bd#4096:fd#512:\ + :pe#307200:oe#393984:be#8192:fe#1024:\ + :pf#1067904:of#701568:bf#8192:ff#1024:\ + :pg#1392768:og#376704:bg#8192:fg#1024:\ + :ph#291346:oh#84672:bh#8192:fh#1024: + diff --git a/src/etc/etc.vax/fstab.ra b/src/etc/etc.vax/fstab.ra new file mode 100644 index 00000000..dab6fc3b --- /dev/null +++ b/src/etc/etc.vax/fstab.ra @@ -0,0 +1,3 @@ +/dev/ra0a / ffs rw 1 1 +/dev/ra0g /mnt ffs rw 1 3 +/dev/ra0h /usr ffs rw 1 2 diff --git a/src/etc/etc.vax/pcs750.bin.uu b/src/etc/etc.vax/pcs750.bin.uu new file mode 100644 index 00000000..ebc35f36 --- /dev/null +++ b/src/etc/etc.vax/pcs750.bin.uu @@ -0,0 +1,254 @@ +begin 644 pcs750.bin +M_________________________________________[__________________ +M____________________________________________________________ +M____________________________________________________________ +M________________________W___________________________________ +M____________________________________________________________ +M____________________________________W_______________________ +M____________________________________________________________ +M____________________________________________________________ +M____________________________________________O_______________ +M__________________O___O_____________________________________ +M____________________________]_______________________________ +MW______]____________________________________________________ +M____________________________________________________________ +M________________________________]?__________________________ +M____________________________________________________________ +M___________________________W__________OW____________________ +M____?_______________________________________________________ +M____________________________________________________________ +M____________________________________________________________ +M____________________________________________________________ +M____________________________________________________________ +M____________________________________________________________ +M_____________________________________________SDH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@8+W".>;,D6T#".2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2,LL@%T``B19$`BP<'"$!:]QPQW8.2A'```#9`,`2#DH1P```V0#`$BZ +M+G`$`0-PPV,2NBYP!`$#<,-C$CDH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$A5 +M,W"$!P,XU>59.2A'```#9`,`2.@7<`0"`R3!:QA&*7"$`P,@P6M8.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(..2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'``` +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.#!P2M@#)``$1@H7<`04`X``1$A$Z=`%`'MD`P!(TS)P2M@# +MI`,`2#DH1P```V0#`$@Y*$<```-D`P!(@#YP2``#$'$:B#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!([!9P!`0#)%E2!/*6<`0#HR#!`9@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#@PL%T``B19`8[T +MEG"$`*,@P0$8[C)P.`@#9`-`SCDS<`0``V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(BA9P!$`# +M<%M`"(P6<`1``21;(`A^%G`$0`%P.T/(X:IPA`!O`,%CF#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!((BMP!$`! +M)%L@"#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(L2AP!-@#I`-M"(T5X%0"`R3)$IBN*'`$`0,XQ6P8.2A'```# +M9`,`2(P5<`0!`R3%;-@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$A,*'`$`0,XQ6P8O15P!`$# +M),5L6$TH\`4X`R196PBZ%2`$``-D`P!(Q#]P!`$+<,-K&+L5\,L!`SC!&Q@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(..2A'``` +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$C0+W!*"`,"P1M6.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(\Q1P!`(`Y%E7R/84,(4`9G&O`%8Y +M*$<```-D`P!(.2A'```#9`,`2/@4<`0`IZ``$LCX%'`$`*.@`!*(Z#AP!`!G +M9`,`B.@X<%C89&2!`(@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2(R4<`0!HP#!"]BL%'`$``-D`P!(CI1P!`!O)%D,B)`4<&0``V0#:PBL +M%'`$``-D`P!(DI1P!`6G(,D+V)04<`^1;`$B1%'`$`@,DQ6R8K!1P!`$# +M<,-KV):4<`00HR#)#!B:%'!(``,D61K(H11P!``#9`,`R)B4<(0`HR#)"]B; +M%'`$.`,D65N(HU1P!``#9`,`R,`_<`0`"V0#``BC5'!*V`,0`!J(HU1P2@(# +M$,$:V)X4<$HX`^1;`(B?%'!(``,D61K(H!1P!``#9`,`2,`_<`0`#V0#`$BC +M5'`$`0,XQ6P8/P!P!``+9`,`"*04<`4``V0#`$BE%'#H`0-PRP"8IA1P9``# +M9`-K"*<4<&`%`W#+`)BH%'!0V`/D6QM(J11PX`8#<,L`F*H4<%#8`^1;&\BK +M%'!@``,D60M(P3]P!``+9`,`B*T4<&0``V0#:<@Z-'`$!*<@R0E8.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2&(P<`4``V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +M9`,`2#$P<(0Q`R3;8E@Y*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y +M*$<```-D`P!(.2A'```#9`,`2#DH1P```V0#`$@Y*$<```-D`P!(.2A'```# +.9`,`2#DH1P```V0#`$@# +` +end diff --git a/src/etc/etc.vax/ttys b/src/etc/etc.vax/ttys new file mode 100644 index 00000000..c620d11f --- /dev/null +++ b/src/etc/etc.vax/ttys @@ -0,0 +1,53 @@ +# $NetBSD: ttys,v 1.1 1995/08/25 21:25:14 ragge Exp $ +# +# @(#)ttys 5.2 (Berkeley) 6/10/93 +# +# name getty type status comments +# +# If the console is marked insecure, single-user requires +# the root password. +console "/usr/libexec/getty std.9600" unknown on secure + +# Hardwired lines are marked off, by default, so getty(8) +# is quiet when they don't exist. +tty00 "/usr/libexec/getty std.9600" unknown off secure +tty01 "/usr/libexec/getty std.9600" unknown off secure +tty02 "/usr/libexec/getty std.9600" unknown off secure +tty03 "/usr/libexec/getty std.9600" unknown off secure +tty04 "/usr/libexec/getty std.9600" unknown off secure +tty05 "/usr/libexec/getty std.9600" unknown off secure +tty06 "/usr/libexec/getty std.9600" unknown off secure +tty07 "/usr/libexec/getty std.9600" unknown off secure + +ttyp0 none network +ttyp1 none network +ttyp2 none network +ttyp3 none network +ttyp4 none network +ttyp5 none network +ttyp6 none network +ttyp7 none network +ttyp8 none network +ttyp9 none network +ttypa none network +ttypb none network +ttypc none network +ttypd none network +ttype none network +ttypf none network +ttyq0 none network +ttyq1 none network +ttyq2 none network +ttyq3 none network +ttyq4 none network +ttyq5 none network +ttyq6 none network +ttyq7 none network +ttyq8 none network +ttyq9 none network +ttyqa none network +ttyqb none network +ttyqc none network +ttyqd none network +ttyqe none network +ttyqf none network diff --git a/src/etc/ftpchroot b/src/etc/ftpchroot new file mode 100644 index 00000000..c008ec51 --- /dev/null +++ b/src/etc/ftpchroot @@ -0,0 +1,3 @@ +# list of users given ftp access to a chrooted area. +# read by ftpd(8). +joeuser diff --git a/src/etc/ftpusers b/src/etc/ftpusers new file mode 100644 index 00000000..d23c64ac --- /dev/null +++ b/src/etc/ftpusers @@ -0,0 +1,4 @@ +# list of users disallowed any ftp access. +# read by ftpd(8). +root +uucp diff --git a/src/etc/gettytab b/src/etc/gettytab new file mode 100644 index 00000000..484c32d2 --- /dev/null +++ b/src/etc/gettytab @@ -0,0 +1,153 @@ +# from: @(#)gettytab 5.14 (Berkeley) 3/27/91 +# +# Most of the table entries here are just copies of the old getty table, +# it is by no means certain, or even likely, that any of them are optimal +# for any purpose whatever. Nor is it likely that more than a couple are +# even correct. +# +# The default gettytab entry, used to set defaults for all other +# entries, and in cases where getty is called with no table name +# +default:\ + :ap:im=\r\n%s/%m (%h) (%t)\r\n\r\n:sp#1200: + +# +# Fixed speed entries +# +# The "std.NNN" names are known to the special case +# portselector code in getty, however they can +# be assigned to any table desired. +# The "NNN-baud" names are known to the special case +# autobaud code in getty, and likewise can +# be assigned to any table desired (hopefully the same speed). +# +a|std.110|110-baud:\ + :nd#1:cd#1:uc:sp#110: +b|std.134|134.5-baud:\ + :ep:nd#1:cd#2:ff#1:td#1:sp#134:ht:nl: +1|std.150|150-baud:\ + :ep:nd#1:cd#2:td#1:fd#1:sp#150:ht:nl:lm=\E\72\6\6\17login\72 : +c|std.300|300-baud:\ + :nd#1:cd#1:sp#300: +d|std.600|600-baud:\ + :nd#1:cd#1:sp#600: +f|std.1200|1200-baud:\ + :fd#1:sp#1200: +6|std.2400|2400-baud:\ + :sp#2400: +7|std.4800|4800-baud:\ + :sp#4800: +2|std.9600|9600-baud:\ + :sp#9600: +g|std.19200|19200-baud:\ + :sp#19200: +std.38400|38400-baud:\ + :sp#38400: +std.57600|57600-baud:\ + :sp#57600: +std.115200|115200-baud:\ + :sp#115200: + +# +# Dial in rotary tables, speed selection via 'break' +# +0|d300|Dial-300:\ + :nx=d1200:cd#2:sp#300: +d1200|Dial-1200:\ + :nx=d150:fd#1:sp#1200: +d150|Dial-150:\ + :nx=d110:lm@:tc=150-baud: +d110|Dial-110:\ + :nx=d300:tc=300-baud: + +# +# Fast dialup terminals, 2400/1200/300 rotary (can start either way) +# +D2400|d2400|Fast-Dial-2400:\ + :nx=D1200:tc=2400-baud: +3|D1200|Fast-Dial-1200:\ + :nx=D300:tc=1200-baud: +5|D300|Fast-Dial-300:\ + :nx=D2400:tc=300-baud: + +# +#telebit (19200) +# +t19200:\ + :nx=t2400:tc=19200-baud: +t2400:\ + :nx=t1200:tc=2400-baud: +t1200:\ + :nx=t19200:tc=1200-baud: + +# +#telebit (9600) +# +t9600:\ + :nx=t2400a:tc=19200-baud: +t2400a:\ + :nx=t1200a:tc=2400-baud: +t1200a:\ + :nx=t9600:tc=1200-baud: + +# +# Odd special case terminals +# +-|tty33|asr33|Pity the poor user of this beast:\ + :tc=110-baud: + +4|Console|Console Decwriter II:\ + :nd@:cd@:rw:tc=300-baud: + +e|Console-1200|Console Decwriter III:\ + :fd@:nd@:cd@:rw:tc=1200-baud: + +i|Interdata console:\ + :uc:sp#0: + +l|lsi chess terminal:\ + :sp#300: + +X|Xwindow|X window system:\ + :fd@:nd@:cd@:rw:sp#9600: + +P|Pc|Pc console:\ + :np:ap:sp#9600: + +# 8 bit clean Sun console +S|suncons|Sun Console:\ + :np:sp#9600: + +# +# Wierdo special case for fast crt's with hardcopy devices +# +8|T9600|CRT with hardcopy:\ + :nx=T300:tc=9600-baud: +9|T300|CRT with hardcopy (300):\ + :nx=T9600:tc=300-baud: + +# +# Plugboard, and misc other terminals +# +plug-9600|Plugboard-9600:\ + :pf#1:tc=9600-baud: +p|P9600|Plugboard-9600-rotary:\ + :pf#1:nx=P300:tc=9600-baud: +q|P300|Plugboard-300:\ + :pf#1:nx=P1200:tc=300-baud: +r|P1200|Plugboard-1200:\ + :pf#1:nx=P9600:tc=1200-baud: + +# +# XXXX Port selector +# +s|DSW|Port Selector:\ + :ps:sp#2400: + +# +# Auto-baud speed detect entry for Micom 600. +# Special code in getty will switch this out +# to one of the NNN-baud entries. +# +A|Auto-baud:\ + :ab:sp#2400:f0#040: diff --git a/src/etc/group b/src/etc/group new file mode 100644 index 00000000..ff75b7cb --- /dev/null +++ b/src/etc/group @@ -0,0 +1,17 @@ +wheel:*:0:root +daemon:*:1:daemon +kmem:*:2:root +sys:*:3:root +tty:*:4:root +operator:*:5:root +bin:*:7: +news:*:8: +wsrc:*:9: +games:*:13: +staff:*:20:root +guest:*:31:root +nobody:*:39: +utmp:*:45: +ingres:*:74:ingres +dialer:*:117: +nogroup:*:32766: diff --git a/src/etc/hosts b/src/etc/hosts new file mode 100644 index 00000000..29402c58 --- /dev/null +++ b/src/etc/hosts @@ -0,0 +1,13 @@ +# +# Host Database +# This file should contain the addresses and aliases +# for local hosts that share this file. +# It is used only for "ifconfig" and other operations +# before the nameserver is started. +# +# +127.1 localhost localhost.my.domain +# +# Imaginary network. +0.2 myname.my.domain myname +0.3 myfriend.my.domain myfriend diff --git a/src/etc/hosts.equiv b/src/etc/hosts.equiv new file mode 100644 index 00000000..f6efd09a --- /dev/null +++ b/src/etc/hosts.equiv @@ -0,0 +1,2 @@ +localhost +my_very_good_friend.domain diff --git a/src/etc/hosts.lpd b/src/etc/hosts.lpd new file mode 100644 index 00000000..1be6dada --- /dev/null +++ b/src/etc/hosts.lpd @@ -0,0 +1 @@ +machine.domain diff --git a/src/etc/inetd.conf b/src/etc/inetd.conf new file mode 100644 index 00000000..8d0fbc8b --- /dev/null +++ b/src/etc/inetd.conf @@ -0,0 +1,43 @@ +# +# Internet server configuration database +# +# @(#)inetd.conf 5.4 (Berkeley) 6/30/90 +# +ftp stream tcp nowait root /usr/libexec/ftpd ftpd -l +telnet stream tcp nowait root /usr/libexec/telnetd telnetd +shell stream tcp nowait root /usr/libexec/rshd rshd +login stream tcp nowait root /usr/libexec/rlogind rlogind +#exec stream tcp nowait root /usr/libexec/rexecd rexecd +#uucpd stream tcp nowait root /usr/libexec/uucpd uucpd +#nntp stream tcp nowait usenet /usr/libexec/nntpd nntpd +finger stream tcp nowait nobody /usr/libexec/fingerd fingerd +#ident stream tcp wait nobody.kmem /usr/libexec/identd identd -w -t60 -l -o -e -N +#tftp dgram udp wait root /usr/libexec/tftpd tftpd -s /tftpboot +comsat dgram udp wait root /usr/libexec/comsat comsat +ntalk dgram udp wait root /usr/libexec/ntalkd ntalkd +#bootps dgram udp wait root /usr/sbin/bootpd bootpd +# Internal services +echo stream tcp nowait root internal +discard stream tcp nowait root internal +chargen stream tcp nowait root internal +daytime stream tcp nowait root internal +time stream tcp nowait root internal +echo dgram udp wait root internal +discard dgram udp wait root internal +chargen dgram udp wait root internal +daytime dgram udp wait root internal +time dgram udp wait root internal +# Kerberos authenticated services +#klogin stream tcp nowait root /usr/libexec/rlogind rlogind -k +#eklogin stream tcp nowait root /usr/libexec/rlogind rlogind -k -x +#kshell stream tcp nowait root /usr/libexec/rshd rshd -k +# Services run ONLY on the Kerberos server +#krbupdate stream tcp nowait root /usr/libexec/registerd registerd +#kpasswd stream tcp nowait root /usr/libexec/kpasswdd kpasswdd +# RPC based services +#mountd/1 dgram rpc/udp wait root /sbin/mountd mountd +rstatd/1-3 dgram rpc/udp wait root /usr/libexec/rpc.rstatd rpc.rstatd +rusersd/2-3 dgram rpc/udp wait root /usr/libexec/rpc.rusersd rpc.rusersd +walld/1 dgram rpc/udp wait root /usr/libexec/rpc.rwalld rpc.rwalld +#sprayd/1 dgram rpc/udp wait root /usr/libexec/rpc.sprayd rpc.sprayd +#rquotad/1 dgram rpc/udp wait root /usr/libexec/rpc.rquotad rpc.rquotad diff --git a/src/etc/man.conf b/src/etc/man.conf new file mode 100644 index 00000000..36261cb7 --- /dev/null +++ b/src/etc/man.conf @@ -0,0 +1,55 @@ +# $Id: man.conf,v 1.1.1.1 1995/10/18 08:37:56 deraadt Exp $ + +# Sheer, raging paranoia... +_version BSD.2 + +# The whatis/apropos database. +_whatdb /usr/share/man/whatis.db + +# Subdirectories for paths ending in '/', IN SEARCH ORDER. +_subdir cat1 man1 cat8 man8 cat6 man6 cat2 man2 cat3 man3 cat4 man4 cat5 man5 cat7 man7 cat3f man3f + +# Files typed by suffix and their commands. +# Note the order, .Z must come after .[1-9].Z, or it will match first. +_suffix .0 +_build .0.Z /usr/bin/zcat %s +_build .0.gz /usr/bin/gunzip -c %s +_build .[1-9] /usr/bin/nroff -man %s +_build .[1-9].Z /usr/bin/zcat %s | /usr/bin/nroff -man +_build .[1-9].gz /usr/bin/gunzip -c %s | /usr/bin/nroff -man +_build .tbl /usr/bin/tbl %s | /usr/bin/nroff -man +_build .tbl.Z /usr/bin/zcat %s | /usr/bin/tbl | /usr/bin/nroff -man +_build .tbl.gz /usr/bin/gunzip -c %s | /usr/bin/tbl | /usr/bin/nroff -man +_build .n /usr/bin/nroff -me %s 2>/dev/null | cat -s +_build .me /usr/bin/nroff -me %s 2>/dev/null | cat -s + +# Sections and their directories. +# All paths ending in '/' are the equivalent of entries specifying that +# directory with all of the subdirectories listed for the keyword _subdir. + +# default +_default /usr/{share,X11R6,X386,X11,X11R4,contrib,gnu,local}/{man,man/old}/ + +# Other sections that represent complete man subdirectories. +X11 /usr/X11/man/ +X11R4 /usr/X11R4/man/ +X11R6 /usr/X11R6/man/ +X386 /usr/X386/man/ +contrib /usr/contrib/man/ +local /usr/local/man/ +new /usr/contrib/man/ +old /usr/share/man/old/ + +doc /usr/share/doc/{sendmail/op,sendmail/intro} + +# Specific section/directory combinations. +1 /usr/{share,X11R6,X386,X11,X11R4,contrib,local}/{man/,man/old/}{cat,man}1 +2 /usr/{share,X11R6,X386,X11,X11R4,contrib,local}/{man/,man/old/}{cat,man}2 +3 /usr/{share,X11R6,X386,X11,X11R4,contrib,local}/{man/,man/old/}{cat,man}3 +3F /usr/share/man/cat3f +3f /usr/share/man/cat3f +4 /usr/{share,X11R6,X386,X11,X11R4,contrib,local}/{man/,man/old/}{cat,man}4 +5 /usr/{share,X11R6,X386,X11,X11R4,contrib,local}/{man/,man/old/}{cat,man}5 +6 /usr/{share,X11R6,X386,X11,X11R4,contrib,local}/{man/,man/old/}{cat,man}6 +7 /usr/{share,X11R6,X386,X11,X11R4,contrib,local}/{man/,man/old/}{cat,man}7 +8 /usr/{share,X11R6,X386,X11,X11R4,contrib,local}/{man/,man/old/}{cat,man}8 diff --git a/src/etc/master.passwd b/src/etc/master.passwd new file mode 100644 index 00000000..7506ab05 --- /dev/null +++ b/src/etc/master.passwd @@ -0,0 +1,10 @@ +root::0:0::0:0:Charlie &:/root:/bin/csh +toor:*:0:0::0:0:Bourne-again Superuser:/root: +daemon:*:1:31::0:0:The devil himself:/root: +operator:*:2:20::0:0:System &:/usr/guest/operator:/bin/csh +bin:*:3:7::0:0:Binaries Commands and Source,,,:/:/dev/null +games:*:7:13::0:0:Games pseudo-user:/usr/games: +uucp:*:66:1::0:0:UNIX-to-UNIX Copy:/var/spool/uucppublic:/usr/libexec/uucp/uucico +nobody:*:32767:9999::0:0:Unprivileged user:/nonexistent:/dev/null +ingres:*:267:74::0:0:& Group:/usr/ingres:/bin/csh +falken:*:32766:31::0:0:Prof. Stephen &:/usr/games:/usr/games/wargames diff --git a/src/etc/monthly b/src/etc/monthly new file mode 100644 index 00000000..2a5e77e4 --- /dev/null +++ b/src/etc/monthly @@ -0,0 +1,21 @@ +#!/bin/sh - +# +# @(#)monthly 5.5 (Berkeley) 6/17/91 +# + +host=`hostname -s` +echo "Subject: $host monthly run output" + +# echo "" +# echo "Doing login accounting:" +# ac -p | sort -nr +1 + +# Rotation of these logs now handled automatically by cron and 'newsyslog': +# kerberos.log +# lpd-errs +# wtmp +# aculog +# cron + +echo "Nothing to do!" +#echo "." diff --git a/src/etc/motd b/src/etc/motd new file mode 100644 index 00000000..35f8066c --- /dev/null +++ b/src/etc/motd @@ -0,0 +1,4 @@ +NetBSD ?.? (UNKNOWN) + +Welcome to NetBSD! + diff --git a/src/etc/mrouted.conf b/src/etc/mrouted.conf new file mode 100644 index 00000000..211fbba2 --- /dev/null +++ b/src/etc/mrouted.conf @@ -0,0 +1,14 @@ +# $Id: mrouted.conf,v 1.1.1.1 1995/10/18 08:37:56 deraadt Exp $ +# +# This is the configuration file for "mrouted", an IP multicast router. +# mrouted looks for it in "/etc/mrouted.conf". +# +# Command formats: +# +# phyint <local-addr> [disable] [metric <m>] [threshold <t>] +# tunnel <local-addr> <remote-addr> [srcrt] [metric <m>] [threshold <t>] +# +# any phyint commands MUST precede any tunnel commands +# + +tunnel 36.8.0.77 36.2.0.8 metric 3 # <-- EXAMPLE; REPLACE OR DELETE diff --git a/src/etc/mtree/4.4BSD.dist b/src/etc/mtree/4.4BSD.dist new file mode 100644 index 00000000..8395e1ee --- /dev/null +++ b/src/etc/mtree/4.4BSD.dist @@ -0,0 +1,1457 @@ +# from: @(#)4.4BSD.dist 8.1 (Berkeley) 6/13/93 +# $Id: 4.4BSD.dist,v 1.1.1.1 1995/10/18 08:38:03 deraadt Exp $ + +/set type=dir uname=root gname=wheel mode=0755 +# . +. + +# ./altroot +altroot +# ./altroot +.. + +# ./bin +bin +# ./bin +.. + +# ./dev +dev + +# ./dev/fd +fd +# ./dev/fd +.. + +# ./dev +.. + +# ./etc +etc + +# ./etc/disklabels +disklabels +# ./etc/disklabels +.. + +# ./etc/kerberosIV +kerberosIV +# ./etc/kerberosIV +.. + +# ./etc/mtree +mtree +# ./etc/mtree +.. + +# ./etc/namedb +namedb +# ./etc/namedb +.. + +# ./etc/sliphome +sliphome +# ./etc/sliphome +.. + +# ./etc/uucp +uucp +# ./etc/uucp +.. + +# ./etc +.. + +# ./home +home +# ./home +.. + +# ./mnt +mnt +# ./mnt +.. + +# ./root +root +# ./root +.. + +# ./sbin +sbin +# ./sbin +.. + +# ./stand +stand +# ./stand +.. + +# ./tmp +tmp mode=01777 +# ./tmp +.. + +# ./usr +usr + +# ./usr/bin +bin +# ./usr/bin +.. + +# ./usr/games +games + +# ./usr/games/hide +hide gname=games uname=games mode=0700 +# ./usr/games/hide +.. + +# ./usr/games +.. + +# ./usr/include +include + +# ./usr/include/arpa +arpa +# ./usr/include/arpa +.. + +# ./usr/include/g++ +g++ + +# ./usr/include/g++/gen +gen +# ./usr/include/g++/gen +.. + +# ./usr/include/g++ +.. + +# ./usr/include/kerberosIV +kerberosIV +# ./usr/include/kerberosIV +.. + +# ./usr/include/protocols +protocols +# ./usr/include/protocols +.. + +# ./usr/include/rpc +rpc +# ./usr/include/rpc +.. + +# ./usr/include/rpcsvc +rpcsvc +# ./usr/include/rpcsvc +.. + +# ./usr/include +.. + +# ./usr/lib +lib +# ./usr/lib +.. + +# ./usr/libdata +libdata + +# ./usr/libdata/lint +lint +# ./usr/libdata/lint +.. + +# ./usr/libdata +.. + +# ./usr/libexec +libexec + +# ./usr/libexec/lpr +lpr +# ./usr/libexec/lpr +.. + +# ./usr/libexec/uucp +uucp +# ./usr/libexec/uucp +.. + +# ./usr/libexec +.. + +# ./usr/local +local + +# ./usr/local/bin +bin +# ./usr/local/bin +.. + +# ./usr/local/lib +lib +# ./usr/local/lib +.. + +# ./usr/local/libdata +libdata +# ./usr/local/libdata +.. + +# ./usr/local/libexec +libexec +# ./usr/local/libexec +.. + +# ./usr/local/man +man + +# ./usr/local/man/cat1 +cat1 +# ./usr/local/man/cat1 +.. + +# ./usr/local/man/cat2 +cat2 +# ./usr/local/man/cat2 +.. + +# ./usr/local/man/cat3 +cat3 +# ./usr/local/man/cat3 +.. + +# ./usr/local/man/cat4 +cat4 +# ./usr/local/man/cat4 +.. + +# ./usr/local/man/cat5 +cat5 +# ./usr/local/man/cat5 +.. + +# ./usr/local/man/cat6 +cat6 +# ./usr/local/man/cat6 +.. + +# ./usr/local/man/cat7 +cat7 +# ./usr/local/man/cat7 +.. + +# ./usr/local/man/cat8 +cat8 +# ./usr/local/man/cat8 +.. + +# ./usr/local/man/man1 +man1 +# ./usr/local/man/man1 +.. + +# ./usr/local/man/man2 +man2 +# ./usr/local/man/man2 +.. + +# ./usr/local/man/man3 +man3 +# ./usr/local/man/man3 +.. + +# ./usr/local/man/man4 +man4 +# ./usr/local/man/man4 +.. + +# ./usr/local/man/man5 +man5 +# ./usr/local/man/man5 +.. + +# ./usr/local/man/man6 +man6 +# ./usr/local/man/man6 +.. + +# ./usr/local/man/man7 +man7 +# ./usr/local/man/man7 +.. + +# ./usr/local/man/man8 +man8 +# ./usr/local/man/man8 +.. + +# ./usr/local/man +.. + +# ./usr/local/sbin +sbin +# ./usr/local/sbin +.. + +# ./usr/local +.. + +# ./usr/mdec +mdec +# ./usr/mdec +.. + +# ./usr/obj XXX +obj +# ./usr/obj XXX +.. + +# ./usr/sbin +sbin +# ./usr/sbin +.. + +# ./usr/share +share + +# ./usr/share/calendar +calendar +# ./usr/share/calendar +.. + +# ./usr/share/dict +dict + +# ./usr/share/dict/papers +papers +# ./usr/share/dict/papers +.. + +# ./usr/share/dict/special +special +# ./usr/share/dict/special +.. + +# ./usr/share/dict +.. + +# ./usr/share/doc +doc + +# ./usr/share/doc/psd +psd + +# ./usr/share/doc/psd/01.cacm +01.cacm +# ./usr/share/doc/psd/01.cacm +.. + +# ./usr/share/doc/psd/02.implement +02.implement +# ./usr/share/doc/psd/02.implement +.. + +# ./usr/share/doc/psd/03.iosys +03.iosys +# ./usr/share/doc/psd/03.iosys +.. + +# ./usr/share/doc/psd/04.uprog +04.uprog +# ./usr/share/doc/psd/04.uprog +.. + +# ./usr/share/doc/psd/05.sysman +05.sysman +# ./usr/share/doc/psd/05.sysman +.. + +# ./usr/share/doc/psd/06.Clang +06.Clang +# ./usr/share/doc/psd/06.Clang +.. + +# ./usr/share/doc/psd/07.pascal +07.pascal +# ./usr/share/doc/psd/07.pascal +.. + +# ./usr/share/doc/psd/08.f77 +08.f77 +# ./usr/share/doc/psd/08.f77 +.. + +# ./usr/share/doc/psd/09.f77io +09.f77io +# ./usr/share/doc/psd/09.f77io +.. + +# ./usr/share/doc/psd/10.gdb +10.gdb +# ./usr/share/doc/psd/10.gdb +.. + +# ./usr/share/doc/psd/11.adb +11.adb +# ./usr/share/doc/psd/11.adb +.. + +# ./usr/share/doc/psd/12.make +12.make +# ./usr/share/doc/psd/12.make +.. + +# ./usr/share/doc/psd/13.rcs +13.rcs +# ./usr/share/doc/psd/13.rcs +.. + +# ./usr/share/doc/psd/14.sccs +14.sccs +# ./usr/share/doc/psd/14.sccs +.. + +# ./usr/share/doc/psd/15.yacc +15.yacc +# ./usr/share/doc/psd/15.yacc +.. + +# ./usr/share/doc/psd/16.lex +16.lex +# ./usr/share/doc/psd/16.lex +.. + +# ./usr/share/doc/psd/17.m4 +17.m4 +# ./usr/share/doc/psd/17.m4 +.. + +# ./usr/share/doc/psd/18.gprof +18.gprof +# ./usr/share/doc/psd/18.gprof +.. + +# ./usr/share/doc/psd/19.curses +19.curses +# ./usr/share/doc/psd/19.curses +.. + +# ./usr/share/doc/psd/20.ipctut +20.ipctut +# ./usr/share/doc/psd/20.ipctut +.. + +# ./usr/share/doc/psd/21.ipc +21.ipc +# ./usr/share/doc/psd/21.ipc +.. + +# ./usr/share/doc/psd +.. + +# ./usr/share/doc/smm +smm + +# ./usr/share/doc/smm/01.setup +01.setup + +# ./usr/share/doc/smm/01.setup/tahoe +tahoe +# ./usr/share/doc/smm/01.setup/tahoe +.. + +# ./usr/share/doc/smm/01.setup/vax +vax +# ./usr/share/doc/smm/01.setup/vax +.. + +# ./usr/share/doc/smm/01.setup +.. + +# ./usr/share/doc/smm/02.config +02.config +# ./usr/share/doc/smm/02.config +.. + +# ./usr/share/doc/smm/03.fsck +03.fsck +# ./usr/share/doc/smm/03.fsck +.. + +# ./usr/share/doc/smm/04.quotas +04.quotas +# ./usr/share/doc/smm/04.quotas +.. + +# ./usr/share/doc/smm/05.fastfs +05.fastfs +# ./usr/share/doc/smm/05.fastfs +.. + +# ./usr/share/doc/smm/06.nfs +06.nfs +# ./usr/share/doc/smm/06.nfs +.. + +# ./usr/share/doc/smm/07.lpd +07.lpd +# ./usr/share/doc/smm/07.lpd +.. + +# ./usr/share/doc/smm/08.sendmailop +08.sendmailop +# ./usr/share/doc/smm/08.sendmailop +.. + +# ./usr/share/doc/smm/09.sendmail +09.sendmail +# ./usr/share/doc/smm/09.sendmail +.. + +# ./usr/share/doc/smm/10.named +10.named +# ./usr/share/doc/smm/10.named +.. + +# ./usr/share/doc/smm/11.timedop +11.timedop +# ./usr/share/doc/smm/11.timedop +.. + +# ./usr/share/doc/smm/12.timed +12.timed +# ./usr/share/doc/smm/12.timed +.. + +# ./usr/share/doc/smm/13.amd +13.amd +# ./usr/share/doc/smm/13.amd +.. + +# ./usr/share/doc/smm/14.uucpimpl +14.uucpimpl +# ./usr/share/doc/smm/14.uucpimpl +.. + +# ./usr/share/doc/smm/15.uucpnet +15.uucpnet +# ./usr/share/doc/smm/15.uucpnet +.. + +# ./usr/share/doc/smm/16.security +16.security +# ./usr/share/doc/smm/16.security +.. + +# ./usr/share/doc/smm/17.password +17.password +# ./usr/share/doc/smm/17.password +.. + +# ./usr/share/doc/smm/18.net +18.net +# ./usr/share/doc/smm/18.net +.. + +# ./usr/share/doc/smm +.. + +# ./usr/share/doc/usd +usd + +# ./usr/share/doc/usd/01.begin +01.begin +# ./usr/share/doc/usd/01.begin +.. + +# ./usr/share/doc/usd/02.learn +02.learn +# ./usr/share/doc/usd/02.learn +.. + +# ./usr/share/doc/usd/03.shell +03.shell +# ./usr/share/doc/usd/03.shell +.. + +# ./usr/share/doc/usd/04.csh +04.csh +# ./usr/share/doc/usd/04.csh +.. + +# ./usr/share/doc/usd/05.dc +05.dc +# ./usr/share/doc/usd/05.dc +.. + +# ./usr/share/doc/usd/06.bc +06.bc +# ./usr/share/doc/usd/06.bc +.. + +# ./usr/share/doc/usd/07.mail +07.mail +# ./usr/share/doc/usd/07.mail +.. + +# ./usr/share/doc/usd/08.mh +08.mh +# ./usr/share/doc/usd/08.mh +.. + +# ./usr/share/doc/usd/09.edtut +09.edtut +# ./usr/share/doc/usd/09.edtut +.. + +# ./usr/share/doc/usd/10.edadv +10.edadv +# ./usr/share/doc/usd/10.edadv +.. + +# ./usr/share/doc/usd/11.edit +11.edit +# ./usr/share/doc/usd/11.edit +.. + +# ./usr/share/doc/usd/12.vi +12.vi +# ./usr/share/doc/usd/12.vi +.. + +# ./usr/share/doc/usd/13.viref +13.viref +# ./usr/share/doc/usd/13.viref +.. + +# ./usr/share/doc/usd/13.ex +13.ex +# ./usr/share/doc/usd/13.ex +.. + +# ./usr/share/doc/usd/14.jove +14.jove +# ./usr/share/doc/usd/14.jove +.. + +# ./usr/share/doc/usd/15.sed +15.sed +# ./usr/share/doc/usd/15.sed +.. + +# ./usr/share/doc/usd/16.awk +16.awk +# ./usr/share/doc/usd/16.awk +.. + +# ./usr/share/doc/usd/17.msmacros +17.msmacros +# ./usr/share/doc/usd/17.msmacros +.. + +# ./usr/share/doc/usd/18.msdiffs +18.msdiffs +# ./usr/share/doc/usd/18.msdiffs +.. + +# ./usr/share/doc/usd/19.memacros +19.memacros +# ./usr/share/doc/usd/19.memacros +.. + +# ./usr/share/doc/usd/20.meref +20.meref +# ./usr/share/doc/usd/20.meref +.. + +# ./usr/share/doc/usd/21.troff +21.troff +# ./usr/share/doc/usd/21.troff +.. + +# ./usr/share/doc/usd/22.trofftut +22.trofftut +# ./usr/share/doc/usd/22.trofftut +.. + +# ./usr/share/doc/usd/23.eqn +23.eqn +# ./usr/share/doc/usd/23.eqn +.. + +# ./usr/share/doc/usd/24.eqnguide +24.eqnguide +# ./usr/share/doc/usd/24.eqnguide +.. + +# ./usr/share/doc/usd/25.tbl +25.tbl +# ./usr/share/doc/usd/25.tbl +.. + +# ./usr/share/doc/usd/26.refer +26.refer +# ./usr/share/doc/usd/26.refer +.. + +# ./usr/share/doc/usd/27.invert +27.invert +# ./usr/share/doc/usd/27.invert +.. + +# ./usr/share/doc/usd/28.bib +28.bib +# ./usr/share/doc/usd/28.bib +.. + +# ./usr/share/doc/usd/29.diction +29.diction +# ./usr/share/doc/usd/29.diction +.. + +# ./usr/share/doc/usd/30.rogue +30.rogue +# ./usr/share/doc/usd/30.rogue +.. + +# ./usr/share/doc/usd/31.trek +31.trek +# ./usr/share/doc/usd/31.trek +.. + +# ./usr/share/doc/usd +.. + +# ./usr/share/doc +.. + +# ./usr/share/games +games + +# ./usr/share/games/atc +atc +# ./usr/share/games/atc +.. + +# ./usr/share/games/boggle +boggle +# ./usr/share/games/boggle +.. + +# ./usr/share/games/ching +ching +# ./usr/share/games/ching +.. + +# ./usr/share/games/fortune +fortune +# ./usr/share/games/fortune +.. + +# ./usr/share/games/larn +larn +# ./usr/share/games/larn +.. + +# ./usr/share/games/quiz.db +quiz.db +# ./usr/share/games/quiz.db +.. + +# ./usr/share/games +.. + +# ./usr/share/gnats +gnats +# ./usr/share/gnats +.. + +# ./usr/share/groff_font +groff_font + +# ./usr/share/groff_font/devX100 +devX100 +# ./usr/share/groff_font/devX100 +.. + +# ./usr/share/groff_font/devX100-12 +devX100-12 +# ./usr/share/groff_font/devX100-12 +.. + +# ./usr/share/groff_font/devX75 +devX75 +# ./usr/share/groff_font/devX75 +.. + +# ./usr/share/groff_font/devX75-12 +devX75-12 +# ./usr/share/groff_font/devX75-12 +.. + +# ./usr/share/groff_font/devascii +devascii +# ./usr/share/groff_font/devascii +.. + +# ./usr/share/groff_font/devdvi +devdvi + +# ./usr/share/groff_font/devdvi/generate +generate +# ./usr/share/groff_font/devdvi/generate +.. + +# ./usr/share/groff_font/devdvi +.. + +# ./usr/share/groff_font/devlatin1 +devlatin1 +# ./usr/share/groff_font/devlatin1 +.. + +# ./usr/share/groff_font/devps +devps + +# ./usr/share/groff_font/devps/generate +generate +# ./usr/share/groff_font/devps/generate +.. + +# ./usr/share/groff_font/devps +.. + +# ./usr/share/groff_font +.. + +# ./usr/share/lkm +lkm + +# ./usr/share/lkm/misc +misc +# ./usr/share/lkm/misc +.. + +# ./usr/share/lkm/syscall +syscall +# ./usr/share/lkm/syscall +.. + +# ./usr/share/lkm/vfs +vfs +# ./usr/share/lkm/vfs +.. + +# ./usr/share/lkm +.. + +# ./usr/share/locale +locale +# ./usr/share/locale +.. + +# ./usr/share/man +man + +# ./usr/share/man/cat1 +cat1 +# ./usr/share/man/cat1 +.. + +# ./usr/share/man/cat2 +cat2 +# ./usr/share/man/cat2 +.. + +# ./usr/share/man/cat3 +cat3 +# ./usr/share/man/cat3 +.. + +# ./usr/share/man/cat3f +cat3f +# ./usr/share/man/cat3f +.. + +# ./usr/share/man/cat4 +cat4 + +# ./usr/share/man/cat4/amiga +amiga +# ./usr/share/man/cat4/amiga +.. + +# ./usr/share/man/cat4/hp300 +hp300 +# ./usr/share/man/cat4/hp300 +.. + +# ./usr/share/man/cat4/i386 +i386 +# ./usr/share/man/cat4/i386 +.. + +# ./usr/share/man/cat4/mac68k +mac68k +# ./usr/share/man/cat4/mac68k +.. + +# ./usr/share/man/cat4/pc532 +pc532 +# ./usr/share/man/cat4/pc532 +.. + +# ./usr/share/man/cat4/sparc +sparc +# ./usr/share/man/cat4/sparc +.. + +# ./usr/share/man/cat4/sun3 +sun3 +# ./usr/share/man/cat4/sun3 +.. + +# ./usr/share/man/cat4/tahoe +tahoe +# ./usr/share/man/cat4/tahoe +.. + +# ./usr/share/man/cat4/vax +vax +# ./usr/share/man/cat4/vax +.. + +# ./usr/share/man/cat4 +.. + +# ./usr/share/man/cat5 +cat5 +# ./usr/share/man/cat5 +.. + +# ./usr/share/man/cat6 +cat6 +# ./usr/share/man/cat6 +.. + +# ./usr/share/man/cat7 +cat7 +# ./usr/share/man/cat7 +.. + +# ./usr/share/man/cat8 +cat8 + +# ./usr/share/man/cat8/amiga +amiga +# ./usr/share/man/cat8/amiga +.. + +# ./usr/share/man/cat8/hp300 +hp300 +# ./usr/share/man/cat8/hp300 +.. + +# ./usr/share/man/cat8/i386 +i386 +# ./usr/share/man/cat8/i386 +.. + +# ./usr/share/man/cat8/mac68k +mac68k +# ./usr/share/man/cat8/mac68k +.. + +# ./usr/share/man/cat8/pc532 +pc532 +# ./usr/share/man/cat8/pc532 +.. + +# ./usr/share/man/cat8/sparc +sparc +# ./usr/share/man/cat8/sparc +.. + +# ./usr/share/man/cat8/sun3 +sun3 +# ./usr/share/man/cat8/sun3 +.. + +# ./usr/share/man/cat8/tahoe +tahoe +# ./usr/share/man/cat8/tahoe +.. + +# ./usr/share/man/cat8/vax +vax +# ./usr/share/man/cat8/vax +.. + +# ./usr/share/man/cat8 +.. + +# ./usr/share/man/man1 +man1 +# ./usr/share/man/man1 +.. + +# ./usr/share/man/man2 +man2 +# ./usr/share/man/man2 +.. + +# ./usr/share/man/man3 +man3 +# ./usr/share/man/man3 +.. + +# ./usr/share/man/man3f +man3f +# ./usr/share/man/man3f +.. + +# ./usr/share/man/man4 +man4 + +# ./usr/share/man/man4/amiga +amiga +# ./usr/share/man/man4/amiga +.. + +# ./usr/share/man/man4/hp300 +hp300 +# ./usr/share/man/man4/hp300 +.. + +# ./usr/share/man/man4/i386 +i386 +# ./usr/share/man/man4/i386 +.. + +# ./usr/share/man/man4/mac68k +mac68k +# ./usr/share/man/man4/mac68k +.. + +# ./usr/share/man/man4/pc532 +pc532 +# ./usr/share/man/man4/pc532 +.. + +# ./usr/share/man/man4/sparc +sparc +# ./usr/share/man/man4/sparc +.. + +# ./usr/share/man/man4/sun3 +sun3 +# ./usr/share/man/man4/sun3 +.. + +# ./usr/share/man/man4/tahoe +tahoe +# ./usr/share/man/man4/tahoe +.. + +# ./usr/share/man/man4/vax +vax +# ./usr/share/man/man4/vax +.. + +# ./usr/share/man/man4 +.. + +# ./usr/share/man/man5 +man5 +# ./usr/share/man/man5 +.. + +# ./usr/share/man/man6 +man6 +# ./usr/share/man/man6 +.. + +# ./usr/share/man/man7 +man7 +# ./usr/share/man/man7 +.. + +# ./usr/share/man/man8 +man8 + +# ./usr/share/man/man8/amiga +amiga +# ./usr/share/man/man8/amiga +.. + +# ./usr/share/man/man8/hp300 +hp300 +# ./usr/share/man/man8/hp300 +.. + +# ./usr/share/man/man8/i386 +i386 +# ./usr/share/man/man8/i386 +.. + +# ./usr/share/man/man8/mac68k +mac68k +# ./usr/share/man/man8/mac68k +.. + +# ./usr/share/man/man8/pc532 +pc532 +# ./usr/share/man/man8/pc532 +.. + +# ./usr/share/man/man8/sparc +sparc +# ./usr/share/man/man8/sparc +.. + +# ./usr/share/man/man8/sun3 +sun3 +# ./usr/share/man/man8/sun3 +.. + +# ./usr/share/man/man8/tahoe +tahoe +# ./usr/share/man/man8/tahoe +.. + +# ./usr/share/man/man8/vax +vax +# ./usr/share/man/man8/vax +.. + +# ./usr/share/man/man8 +.. + +# ./usr/share/man +.. + +# ./usr/share/me +me +# ./usr/share/me +.. + +# ./usr/share/misc +misc +# ./usr/share/misc +.. + +# ./usr/share/mk +mk +# ./usr/share/mk +.. + +# ./usr/share/ms +ms +# ./usr/share/ms +.. + +# ./usr/share/nls +nls +# ./usr/share/nls +.. + +# ./usr/share/skel +skel +# ./usr/share/skel +.. + +# ./usr/share/tabset +tabset +# ./usr/share/tabset +.. + +# ./usr/share/tmac +tmac + +# ./usr/share/tmac/mm +mm +# ./usr/share/tmac/mm +.. + +# ./usr/share/tmac +.. + +# ./usr/share/zoneinfo +zoneinfo mode=0555 + +# ./usr/share/zoneinfo/Australia +Australia mode=0555 +# ./usr/share/zoneinfo/Australia +.. + +# ./usr/share/zoneinfo/Brazil +Brazil mode=0555 +# ./usr/share/zoneinfo/Brazil +.. + +# ./usr/share/zoneinfo/Canada +Canada mode=0555 +# ./usr/share/zoneinfo/Canada +.. + +# ./usr/share/zoneinfo/Chile +Chile mode=0555 +# ./usr/share/zoneinfo/Chile +.. + +# ./usr/share/zoneinfo/Mexico +Mexico mode=0555 +# ./usr/share/zoneinfo/Mexico +.. + +# ./usr/share/zoneinfo/SystemV +SystemV mode=0555 +# ./usr/share/zoneinfo/SystemV +.. + +# ./usr/share/zoneinfo/US +US mode=0555 +# ./usr/share/zoneinfo/US +.. + +# ./usr/share/zoneinfo +.. + +# ./usr/share +.. + +# ./usr/src +src +# ./usr/src +.. + +# ./usr +.. + +# ./var +var + +# ./var/account +account +# ./var/account +.. + +# ./var/at +at + +# ./var/at/jobs +jobs mode=0700 +# ./var/at/jobs +.. + +# ./var/at/spool +spool mode=0700 +# ./var/at/spool +.. + +# ./var/at +.. + +# ./var/backups +backups +# ./var/backups +.. + +# ./var/crash +crash mode=775 +# ./var/crash +.. + +# ./var/cron +cron + +# ./var/cron/tabs +tabs mode=0700 +# ./var/cron/tabs +.. + +# ./var/cron +.. + +# ./var/db +db + +# ./var/db/ns +ns +# ./var/db/ns +.. + +# ./var/db +.. + +# ./var/games +games uname=games gname=games mode=0775 + +# ./var/games/hackdir +hackdir uname=games gname=games mode=0775 + +# ./var/games/hackdir/save +save uname=games gname=games mode=0770 +# ./var/games/hackdir/save +.. + +# ./var/games/hackdir +.. + +# ./var/games/hackdir/save XXX +save uname=games gname=games mode=0775 +# ./var/games/hackdir/save XXX +.. + +# ./var/games/larn +larn uname=games gname=games mode=0775 +# ./var/games/larn +.. + +# ./var/games/phantasia +phantasia uname=games gname=games mode=0775 +# ./var/games/phantasia +.. + +# ./var/games +.. + +# ./var/log +log + +# ./var/log/rdist +rdist +# ./var/log/rdist +.. + +# ./var/log +.. + +# ./var/mail +mail +# ./var/mail +.. + +# ./var/msgs +msgs +# ./var/msgs +.. + +# ./var/obj XXX +#obj +# ./var/obj XXX +#.. + +# ./var/preserve +preserve +# ./var/preserve +.. + +# ./var/quotas +quotas gname=operator mode=0750 +# ./var/quotas +.. + +# ./var/run +run +# ./var/run +.. + +# ./var/rwho +rwho +# ./var/rwho +.. + +# ./var/spool +spool + +# ./var/spool/ftp +ftp + +# ./var/spool/ftp/bin +bin +# ./var/spool/ftp/bin +.. + +# ./var/spool/ftp/etc +etc +# ./var/spool/ftp/etc +.. + +# ./var/spool/ftp/hidden +hidden mode=0111 +# ./var/spool/ftp/hidden +.. + +# ./var/spool/ftp/pub XXX +#pub mode=0777 +# ./var/spool/ftp/pub XXX +#.. + +# ./var/spool/ftp +.. + +# ./var/spool/lock +lock uname=uucp gname=daemon +# ./var/spool/lock +.. + +# ./var/spool/lpd +lpd +# ./var/spool/lpd +.. + +# ./var/spool/mqueue +mqueue +# ./var/spool/mqueue +.. + +# ./var/spool/output +output +# ./var/spool/output +.. + +# ./var/spool/secretmail +secretmail +# ./var/spool/secretmail +.. + +# ./var/spool/sockets +sockets mode=777 +# ./var/spool/sockets +.. + +/set uname=uucp gname=daemon +# ./var/spool/uucp +uucp +# ./var/spool/uucp +.. + +# ./var/spool/uucppublic +uucppublic mode=01777 +# ./var/spool/uucppublic +.. + +/set uname=root gname=wheel +# ./var/spool +.. + +# ./var/tmp +tmp mode=01777 + +# ./var/tmp/vi.recover +vi.recover mode=01777 +# ./var/tmp/vi.recover +.. + +# ./var/tmp +.. + +# ./var +.. diff --git a/src/etc/mtree/4.4BSD.root b/src/etc/mtree/4.4BSD.root new file mode 100644 index 00000000..bcb141fa --- /dev/null +++ b/src/etc/mtree/4.4BSD.root @@ -0,0 +1,163 @@ +# user: bostic +# machine: vangogh.CS.Berkeley.EDU +# tree: / +# date: Tue Jul 20 13:15:45 1993 + +# . +/set type=file gname=wheel uname=root mode=0755 +. type=dir + +# ./a +/set type=file gname=guest uname=root mode=0755 +a type=dir gname=wheel +# ./a +.. + + +# ./altroot +altroot type=dir gname=wheel +# ./altroot +.. + + +# ./amd +/set type=file gname=wheel uname=root mode=0755 +amd type=dir mode=0555 +# ./amd +.. + + +# ./b +b type=dir mode=0775 +# ./b +.. + + +# ./bin +/set type=file gname=bin uname=bin mode=0555 +bin type=dir uname=root gname=wheel mode=0755 +# ./bin +.. + + +# ./c +/set type=file gname=wheel uname=root mode=0750 +c type=dir mode=0755 +# ./c +.. + + +# ./dev +/set type=file gname=operator uname=root mode=0640 +dev type=dir gname=wheel mode=0755 + +# ./dev/fd +/set type=file gname=bin uname=bin mode=0666 +fd type=dir uname=root gname=wheel mode=0755 +# ./dev/fd +.. + +# ./dev +.. + + +# ./dump +/set type=file gname=wheel uname=root mode=0750 +dump type=dir gname=operator uname=operator mode=0775 +# ./dump +.. + + +# ./etc +/set type=file gname=wheel uname=root mode=0644 +etc type=dir mode=0755 + +# ./etc/disklabels +/set type=file gname=wheel uname=root mode=0444 +disklabels type=dir mode=0775 +# ./etc/disklabels +.. + + +# ./etc/kerberosIV +/set type=file gname=wheel uname=root mode=0444 +kerberosIV type=dir mode=0755 +# ./etc/kerberosIV +.. + + +# ./etc/mtree +/set type=file gname=wheel uname=root mode=0600 +mtree type=dir mode=0755 +# ./etc/mtree +.. + + +# ./etc/namedb +/set type=file gname=wheel uname=root mode=0600 +namedb type=dir mode=0755 +# ./etc/namedb +.. + + +# ./etc/sliphome +/set type=file gname=wheel uname=root mode=0755 +sliphome type=dir +# ./etc/sliphome +.. + +# ./etc +.. + + +# ./home +home type=dir mode=0555 +# ./home +.. + + +# ./mnt +mnt type=dir +# ./mnt +.. + + +# ./root +/set type=file gname=wheel uname=root mode=0644 +root type=dir mode=0755 +# ./root +.. + + +# ./sbin +/set type=file gname=bin uname=bin mode=0555 +sbin type=dir uname=root gname=wheel mode=0755 +# ./sbin +.. + + +# ./stand +stand type=dir uname=root gname=wheel mode=0755 +# ./stand +.. + + +# ./tmp +/set type=file gname=wheel uname=root mode=0600 +tmp type=dir mode=01777 +# ./tmp +.. + + +# ./usr +/set type=file gname=wheel uname=root mode=0755 +usr type=dir +# ./usr +.. + + +# ./var +/set type=file gname=wheel uname=root mode=0755 +var type=dir +# ./var +.. diff --git a/src/etc/mtree/4.4BSD.usr b/src/etc/mtree/4.4BSD.usr new file mode 100644 index 00000000..f4478f6f --- /dev/null +++ b/src/etc/mtree/4.4BSD.usr @@ -0,0 +1,1668 @@ +# user: bostic +# machine: vangogh.CS.Berkeley.EDU +# tree: /usr +# date: Tue Jul 20 13:17:28 1993 + +# . +/set type=file gname=wheel uname=root mode=0755 +. type=dir + +# ./.src +/set type=file gname=sww uname=sww mode=02775 +.src type=dir uname=root gname=wheel mode=0755 +# ./.src +.. + + +# ./X11R4 +/set type=file gname=wheel uname=root mode=0775 +X11R4 type=dir mode=0755 +# ./X11R4 +.. + + +# ./X11R5 +/set type=file gname=wheel uname=root mode=0755 +X11R5 type=dir +# ./X11R5 +.. + + +# ./bin +/set type=file gname=bin uname=bin mode=0555 +bin type=dir uname=root gname=wheel mode=0755 +# ./bin +.. + + +# ./contrib +/set type=file gname=wheel uname=root mode=0755 +contrib type=dir + +# ./contrib/bin +/set type=file gname=wheel uname=root mode=0755 +bin type=dir +# ./contrib/bin +.. + + +# ./contrib/lib +/set type=file gname=wheel uname=root mode=0755 +lib type=dir + +# ./contrib/lib/bmac +/set type=file gname=wheel uname=root mode=0444 +bmac type=dir mode=0775 + +# ./contrib/lib/bmac/bibmacs +/set type=file gname=wheel uname=root mode=0444 +bibmacs type=dir mode=0775 +# ./contrib/lib/bmac/bibmacs +.. + + +# ./contrib/lib/bmac/tibmacs +/set type=file gname=wheel uname=root mode=0444 +tibmacs type=dir mode=0775 +# ./contrib/lib/bmac/tibmacs +.. + +# ./contrib/lib/bmac +.. + + +# ./contrib/lib/emacs +/set type=file gname=wheel uname=root mode=0755 +emacs type=dir mode=0777 + +# ./contrib/lib/emacs/etc +/set type=file gname=wsrc uname=bin mode=0664 +etc type=dir uname=root gname=wheel mode=0755 +# ./contrib/lib/emacs/etc +.. + + +# ./contrib/lib/emacs/info +/set type=file gname=wsrc uname=bin mode=0664 +info type=dir uname=root gname=wheel mode=0755 +# ./contrib/lib/emacs/info +.. + + +# ./contrib/lib/emacs/lisp +/set type=file gname=wsrc uname=bin mode=0664 +lisp type=dir uname=root gname=wheel mode=0755 + +# ./contrib/lib/emacs/lisp/term +/set type=file gname=wsrc uname=bin mode=0666 +term type=dir uname=root gname=wheel mode=0755 +# ./contrib/lib/emacs/lisp/term +.. + +# ./contrib/lib/emacs/lisp +.. + +# ./contrib/lib/emacs +.. + + +# ./contrib/lib/jove +/set type=file gname=wheel uname=root mode=0755 +jove type=dir +# ./contrib/lib/jove +.. + + +# ./contrib/lib/perl +/set type=file gname=obin uname=root mode=0644 +perl type=dir mode=0755 +# ./contrib/lib/perl +.. + +# ./contrib/lib +.. + + +# ./contrib/man +/set type=file gname=wheel uname=root mode=0755 +man type=dir + +# ./contrib/man/cat1 +/set type=file gname=wheel uname=root mode=0644 +cat1 type=dir mode=0755 +# ./contrib/man/cat1 +.. + + +# ./contrib/man/cat2 +cat2 type=dir mode=0755 +# ./contrib/man/cat2 +.. + + +# ./contrib/man/cat3 +/set type=file gname=obin uname=root mode=0444 +cat3 type=dir gname=wheel mode=0755 +# ./contrib/man/cat3 +.. + + +# ./contrib/man/cat3f +cat3f type=dir gname=wheel mode=0755 +# ./contrib/man/cat3f +.. + + +# ./contrib/man/cat4 +cat4 type=dir gname=wheel mode=0755 +# ./contrib/man/cat4 +.. + + +# ./contrib/man/cat5 +/set type=file gname=wheel uname=root mode=0644 +cat5 type=dir mode=0755 +# ./contrib/man/cat5 +.. + + +# ./contrib/man/cat6 +/set type=file gname=bin uname=bin mode=0444 +cat6 type=dir uname=root gname=wheel mode=0755 +# ./contrib/man/cat6 +.. + + +# ./contrib/man/cat7 +cat7 type=dir uname=root gname=wheel mode=0755 +# ./contrib/man/cat7 +.. + + +# ./contrib/man/cat8 +/set type=file gname=obin uname=root mode=0444 +cat8 type=dir gname=wheel mode=0755 +# ./contrib/man/cat8 +.. + +# ./contrib/man +.. + + +# ./contrib/mh-6.8 +/set type=file gname=wheel uname=root mode=0755 +mh-6.8 type=dir + +# ./contrib/mh-6.8/bin +/set type=file gname=wheel uname=root mode=0755 +bin type=dir +# ./contrib/mh-6.8/bin +.. + + +# ./contrib/mh-6.8/lib +/set type=file gname=wheel uname=root mode=0644 +lib type=dir mode=0755 +# ./contrib/mh-6.8/lib +.. + +# ./contrib/mh-6.8 +.. + + +# ./contrib/news +/set type=file gname=news uname=news mode=0775 +news type=dir + +# ./contrib/news/bin +bin type=dir +# ./contrib/news/bin +.. + +# ./contrib/news +.. + + +# ./contrib/rnews +rnews type=dir +# ./contrib/rnews +.. + +# ./contrib +.. + + +# ./games +/set type=file gname=wheel uname=root mode=0755 +games type=dir + +# ./games/hide +/set type=file gname=bin uname=games mode=04700 +hide type=dir gname=games mode=0700 +# ./games/hide +.. + +# ./games +.. + + +# ./include +/set type=file gname=bin uname=bin mode=0444 +include type=dir uname=root gname=wheel mode=0755 + +# ./include/arpa +/set type=file gname=bin uname=bin mode=0444 +arpa type=dir mode=0755 +# ./include/arpa +.. + + +# ./include/g++ +/set type=file gname=wheel uname=root mode=0444 +g++ type=dir mode=0755 + +# ./include/g++/sys +/set type=file gname=wheel uname=root mode=0444 +sys type=dir mode=0755 +# ./include/g++/sys +.. + +# ./include/g++ +.. + + +# ./include/kerberosIV +/set type=file gname=bin uname=bin mode=0444 +kerberosIV type=dir uname=root gname=wheel mode=0755 +# ./include/kerberosIV +.. + + +# ./include/pascal +/set type=file gname=bin uname=bin mode=0444 +pascal type=dir uname=root gname=wheel mode=0755 +# ./include/pascal +.. + + +# ./include/protocols +/set type=file gname=bin uname=bin mode=0444 +protocols type=dir mode=0755 +# ./include/protocols +.. + + +# ./include/rpc +/set type=file gname=bin uname=bin mode=0444 +rpc type=dir mode=0755 +# ./include/rpc +.. + + +# ./include/xnscourier +/set type=file gname=staff uname=root mode=0644 +xnscourier type=dir gname=wheel mode=0755 +# ./include/xnscourier +.. + +# ./include +.. + + +# ./lib +/set type=file gname=bin uname=bin mode=0444 +lib type=dir uname=root gname=wheel mode=0755 + +# ./lib/uucp +/set type=file gname=daemon uname=uucp mode=06550 +uucp type=dir mode=0755 +# ./lib/uucp +.. + +# ./lib +.. + + +# ./libdata +/set type=file gname=wheel uname=root mode=0755 +libdata type=dir + +# ./libdata/learn +/set type=file gname=wsrc uname=bin mode=0775 +learn type=dir uname=root gname=wheel mode=0755 + +# ./libdata/learn/C +/set type=file gname=wsrc uname=bin mode=0444 +C type=dir mode=0775 +# ./libdata/learn/C +.. + + +# ./libdata/learn/bin +/set type=file gname=bin uname=bin mode=0444 +bin type=dir uname=root gname=wheel mode=0755 +# ./libdata/learn/bin +.. + + +# ./libdata/learn/editor +/set type=file gname=wsrc uname=bin mode=0444 +editor type=dir mode=0775 +# ./libdata/learn/editor +.. + + +# ./libdata/learn/eqn +/set type=file gname=wsrc uname=bin mode=0444 +eqn type=dir mode=0775 +# ./libdata/learn/eqn +.. + + +# ./libdata/learn/files +/set type=file gname=wsrc uname=bin mode=0444 +files type=dir mode=0775 +# ./libdata/learn/files +.. + + +# ./libdata/learn/macros +/set type=file gname=wsrc uname=bin mode=0444 +macros type=dir mode=0775 +# ./libdata/learn/macros +.. + + +# ./libdata/learn/morefiles +/set type=file gname=wsrc uname=bin mode=0444 +morefiles type=dir mode=0775 +# ./libdata/learn/morefiles +.. + +# ./libdata/learn +.. + +# ./libdata +.. + + +# ./libexec +/set type=file gname=bin uname=bin mode=0555 +libexec type=dir uname=root gname=wheel mode=0755 + +# ./libexec/gcc2 +/set type=file gname=wheel uname=root mode=0775 +gcc2 type=dir mode=0755 + +# ./libexec/gcc2/gcc-lib +/set type=file gname=wheel uname=root mode=0755 +gcc-lib type=dir + +# ./libexec/gcc2/gcc-lib/include +include type=dir +# ./libexec/gcc2/gcc-lib/include +.. + + +# ./libexec/gcc2/gcc-lib/m68k-hp-bsd +/set type=file gname=wheel uname=root mode=0755 +m68k-hp-bsd type=dir + +# ./libexec/gcc2/gcc-lib/m68k-hp-bsd/2.3.3 +/set type=file gname=wheel uname=root mode=0755 +2.3.3 type=dir + +# ./libexec/gcc2/gcc-lib/m68k-hp-bsd/2.3.3/include +include type=dir +# ./libexec/gcc2/gcc-lib/m68k-hp-bsd/2.3.3/include +.. + +# ./libexec/gcc2/gcc-lib/m68k-hp-bsd/2.3.3 +.. + +# ./libexec/gcc2/gcc-lib/m68k-hp-bsd +.. + +# ./libexec/gcc2/gcc-lib +.. + +# ./libexec/gcc2 +.. + + +# ./libexec/lpr +/set type=file gname=bin uname=bin mode=0555 +lpr type=dir uname=root gname=wheel mode=0755 +# ./libexec/lpr +.. + + +# ./libexec/pascal +pascal type=dir uname=root gname=wheel mode=0755 +# ./libexec/pascal +.. + + +# ./libexec/plot +/set type=file gname=bin uname=bin mode=0555 +plot type=dir uname=root gname=wheel mode=0755 +# ./libexec/plot +.. + +# ./libexec +.. + + +# ./local +/set type=file gname=wheel uname=root mode=0755 +local type=dir + +# ./local/bin +/set type=file gname=bin uname=bin mode=0755 +bin type=dir uname=root gname=wheel +# ./local/bin +.. + + +# ./local/lib +/set type=file gname=bin uname=bin mode=0444 +lib type=dir uname=root gname=wheel mode=0755 +# ./local/lib +.. + + +# ./local/libdata +/set type=file gname=bin uname=root mode=0775 +libdata type=dir gname=wheel mode=0755 +# ./local/libdata +.. + + +# ./local/libexec +/set type=file gname=bin uname=root mode=0755 +libexec type=dir gname=wheel +# ./local/libexec +.. + + +# ./local/man +/set type=file gname=wheel uname=root mode=0755 +man type=dir + +# ./local/man/cat1 +/set type=file gname=bin uname=bin mode=0444 +cat1 type=dir uname=root gname=wheel mode=0755 +# ./local/man/cat1 +.. + + +# ./local/man/cat2 +cat2 type=dir uname=root gname=wheel mode=0755 +# ./local/man/cat2 +.. + + +# ./local/man/cat3 +cat3 type=dir uname=root gname=wheel mode=0755 +# ./local/man/cat3 +.. + + +# ./local/man/cat4 +cat4 type=dir uname=root gname=wheel mode=0755 +# ./local/man/cat4 +.. + + +# ./local/man/cat5 +/set type=file gname=bin uname=bin mode=0444 +cat5 type=dir uname=root gname=wheel mode=0755 +# ./local/man/cat5 +.. + + +# ./local/man/cat6 +cat6 type=dir uname=root gname=wheel mode=0755 +# ./local/man/cat6 +.. + + +# ./local/man/cat7 +/set type=file gname=bin uname=root mode=0664 +cat7 type=dir gname=wheel mode=0755 +# ./local/man/cat7 +.. + + +# ./local/man/cat8 +/set type=file gname=wheel uname=root mode=0644 +cat8 type=dir mode=0755 +# ./local/man/cat8 +.. + +# ./local/man +.. + + +# ./local/sbin +/set type=file gname=wheel uname=root mode=0755 +sbin type=dir +# ./local/sbin +.. + +# ./local +.. + + +# ./mdec +/set type=file gname=bin uname=bin mode=0444 +mdec type=dir uname=root gname=wheel mode=0755 +# ./mdec +.. + + +# ./old +/set type=file gname=wheel uname=root mode=0755 +old type=dir + +# ./old/bin +/set type=file gname=bin uname=bin mode=0555 +bin type=dir uname=root gname=wheel mode=0755 +# ./old/bin +.. + + +# ./old/dict +/set type=file gname=wheel uname=root mode=0755 +dict type=dir + +# ./old/dict/papers +/set type=file gname=wheel uname=root mode=0444 +papers type=dir mode=0755 +# ./old/dict/papers +.. + +# ./old/dict +.. + + +# ./old/lib +/set type=file gname=wheel uname=root mode=0755 +lib type=dir + +# ./old/lib/ms +/set type=file gname=bin uname=bin mode=0444 +ms type=dir uname=root gname=wheel mode=0755 +# ./old/lib/ms +.. + + +# ./old/lib/tmac +/set type=file gname=bin uname=bin mode=0444 +tmac type=dir uname=root gname=wheel mode=0755 +# ./old/lib/tmac +.. + +# ./old/lib +.. + + +# ./old/libdata +/set type=file gname=wheel uname=root mode=0755 +libdata type=dir + +# ./old/libdata/adb +/set type=file gname=bin uname=bin mode=0444 +adb type=dir uname=root gname=wheel mode=0755 +# ./old/libdata/adb +.. + + +# ./old/libdata/term +/set type=file gname=bin uname=bin mode=0444 +term type=dir uname=root gname=wheel mode=0755 +# ./old/libdata/term +.. + + +# ./old/libdata/troff_font +/set type=file gname=bin uname=bin mode=0444 +troff_font type=dir uname=root gname=wheel mode=0755 +# ./old/libdata/troff_font +.. + +# ./old/libdata +.. + + +# ./old/libexec +/set type=file gname=bin uname=bin mode=0555 +libexec type=dir uname=root gname=wheel mode=0755 +# ./old/libexec +.. + +# ./old +.. + + +# ./public +/set type=file gname=hosttabl uname=root mode=0644 +public type=dir gname=wheel mode=0755 +# ./public +.. + + +# ./sbin +/set type=file gname=bin uname=bin mode=0555 +sbin type=dir uname=root gname=wheel mode=0755 +# ./sbin +.. + + +# ./share +/set type=file gname=wheel uname=root mode=0755 +share type=dir + +# ./share/calendar +/set type=file gname=bin uname=bin mode=0444 +calendar type=dir uname=root gname=wheel mode=0755 +# ./share/calendar +.. + + +# ./share/dict +/set type=file gname=bin uname=bin mode=0444 +dict type=dir uname=root gname=wheel mode=0755 + +# ./share/dict/papers +papers type=dir uname=root gname=wheel mode=0755 +# ./share/dict/papers +.. + + +# ./share/dict/special +/set type=file gname=bin uname=bin mode=0444 +special type=dir uname=root gname=wheel mode=0755 +# ./share/dict/special +.. + +# ./share/dict +.. + + +# ./share/doc +/set type=file gname=wheel uname=root mode=0775 +doc type=dir mode=0755 + +# ./share/doc/psd +/set type=file gname=wheel uname=root mode=0775 +psd type=dir + +# ./share/doc/psd/01.cacm +/set type=file gname=bin uname=bin mode=0444 +01.cacm type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/01.cacm +.. + + +# ./share/doc/psd/02.implement +/set type=file gname=bin uname=bin mode=0444 +02.implement type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/02.implement +.. + + +# ./share/doc/psd/03.iosys +/set type=file gname=bin uname=bin mode=0444 +03.iosys type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/03.iosys +.. + + +# ./share/doc/psd/04.uprog +/set type=file gname=bin uname=bin mode=0444 +04.uprog type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/04.uprog +.. + + +# ./share/doc/psd/05.sysman +/set type=file gname=bin uname=bin mode=0444 +05.sysman type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/05.sysman +.. + + +# ./share/doc/psd/06.Clang +/set type=file gname=bin uname=bin mode=0444 +06.Clang type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/06.Clang +.. + + +# ./share/doc/psd/07.pascal +/set type=file gname=bin uname=bin mode=0444 +07.pascal type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/07.pascal +.. + + +# ./share/doc/psd/08.f77 +/set type=file gname=bin uname=bin mode=0444 +08.f77 type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/08.f77 +.. + + +# ./share/doc/psd/09.f77io +/set type=file gname=bin uname=bin mode=0444 +09.f77io type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/09.f77io +.. + + +# ./share/doc/psd/10.gdb +10.gdb type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/10.gdb +.. + + +# ./share/doc/psd/11.adb +/set type=file gname=bin uname=bin mode=0444 +11.adb type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/11.adb +.. + + +# ./share/doc/psd/12.make +/set type=file gname=bin uname=bin mode=0444 +12.make type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/12.make +.. + + +# ./share/doc/psd/13.rcs +13.rcs type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/13.rcs +.. + + +# ./share/doc/psd/14.sccs +/set type=file gname=bin uname=bin mode=0444 +14.sccs type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/14.sccs +.. + + +# ./share/doc/psd/15.yacc +/set type=file gname=bin uname=bin mode=0444 +15.yacc type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/15.yacc +.. + + +# ./share/doc/psd/16.lex +/set type=file gname=bin uname=bin mode=0444 +16.lex type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/16.lex +.. + + +# ./share/doc/psd/17.m4 +/set type=file gname=bin uname=bin mode=0444 +17.m4 type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/17.m4 +.. + + +# ./share/doc/psd/18.gprof +/set type=file gname=bin uname=bin mode=0444 +18.gprof type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/18.gprof +.. + + +# ./share/doc/psd/19.curses +/set type=file gname=bin uname=bin mode=0444 +19.curses type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/19.curses +.. + + +# ./share/doc/psd/20.ipctut +/set type=file gname=bin uname=bin mode=0444 +20.ipctut type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/20.ipctut +.. + + +# ./share/doc/psd/21.ipc +/set type=file gname=bin uname=bin mode=0444 +21.ipc type=dir uname=root gname=wheel mode=0775 +# ./share/doc/psd/21.ipc +.. + +# ./share/doc/psd +.. + + +# ./share/doc/smm +/set type=file gname=wheel uname=root mode=0775 +smm type=dir + +# ./share/doc/smm/01.setup +/set type=file gname=bin uname=bin mode=0444 +01.setup type=dir uname=root gname=wheel mode=0775 + +# ./share/doc/smm/01.setup/tahoe +/set type=file gname=bin uname=bin mode=0444 +tahoe type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/01.setup/tahoe +.. + + +# ./share/doc/smm/01.setup/vax +/set type=file gname=bin uname=bin mode=0444 +vax type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/01.setup/vax +.. + +# ./share/doc/smm/01.setup +.. + + +# ./share/doc/smm/02.config +/set type=file gname=bin uname=bin mode=0444 +02.config type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/02.config +.. + + +# ./share/doc/smm/03.fsck +/set type=file gname=bin uname=bin mode=0444 +03.fsck type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/03.fsck +.. + + +# ./share/doc/smm/04.quotas +/set type=file gname=bin uname=bin mode=0444 +04.quotas type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/04.quotas +.. + + +# ./share/doc/smm/05.fastfs +/set type=file gname=bin uname=bin mode=0444 +05.fastfs type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/05.fastfs +.. + + +# ./share/doc/smm/06.nfs +/set type=file gname=bin uname=bin mode=0444 +06.nfs type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/06.nfs +.. + + +# ./share/doc/smm/07.lpd +/set type=file gname=bin uname=bin mode=0444 +07.lpd type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/07.lpd +.. + + +# ./share/doc/smm/08.sendmailop +/set type=file gname=bin uname=bin mode=0444 +08.sendmailop type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/08.sendmailop +.. + + +# ./share/doc/smm/09.sendmail +/set type=file gname=bin uname=bin mode=0444 +09.sendmail type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/09.sendmail +.. + + +# ./share/doc/smm/10.named +10.named type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/10.named +.. + + +# ./share/doc/smm/11.timedop +/set type=file gname=bin uname=bin mode=0444 +11.timedop type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/11.timedop +.. + + +# ./share/doc/smm/12.timed +/set type=file gname=bin uname=bin mode=0444 +12.timed type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/12.timed +.. + + +# ./share/doc/smm/13.amd +13.amd type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/13.amd +.. + + +# ./share/doc/smm/14.uucpimpl +/set type=file gname=bin uname=bin mode=0444 +14.uucpimpl type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/14.uucpimpl +.. + + +# ./share/doc/smm/15.uucpnet +/set type=file gname=bin uname=bin mode=0444 +15.uucpnet type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/15.uucpnet +.. + + +# ./share/doc/smm/16.security +/set type=file gname=bin uname=bin mode=0444 +16.security type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/16.security +.. + + +# ./share/doc/smm/17.password +/set type=file gname=bin uname=bin mode=0444 +17.password type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/17.password +.. + + +# ./share/doc/smm/18.net +/set type=file gname=bin uname=bin mode=0444 +18.net type=dir uname=root gname=wheel mode=0775 +# ./share/doc/smm/18.net +.. + +# ./share/doc/smm +.. + + +# ./share/doc/usd +/set type=file gname=wheel uname=root mode=0775 +usd type=dir + +# ./share/doc/usd/01.begin +/set type=file gname=bin uname=bin mode=0444 +01.begin type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/01.begin +.. + + +# ./share/doc/usd/02.learn +/set type=file gname=bin uname=bin mode=0444 +02.learn type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/02.learn +.. + + +# ./share/doc/usd/03.shell +/set type=file gname=bin uname=bin mode=0444 +03.shell type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/03.shell +.. + + +# ./share/doc/usd/04.csh +/set type=file gname=bin uname=bin mode=0444 +04.csh type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/04.csh +.. + + +# ./share/doc/usd/05.dc +/set type=file gname=bin uname=bin mode=0444 +05.dc type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/05.dc +.. + + +# ./share/doc/usd/06.bc +/set type=file gname=bin uname=bin mode=0444 +06.bc type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/06.bc +.. + + +# ./share/doc/usd/07.mail +/set type=file gname=bin uname=bin mode=0444 +07.mail type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/07.mail +.. + + +# ./share/doc/usd/08.mh +08.mh type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/08.mh +.. + + +# ./share/doc/usd/09.edtut +/set type=file gname=bin uname=bin mode=0444 +09.edtut type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/09.edtut +.. + + +# ./share/doc/usd/10.edadv +/set type=file gname=bin uname=bin mode=0444 +10.edadv type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/10.edadv +.. + + +# ./share/doc/usd/11.edit +/set type=file gname=bin uname=bin mode=0444 +11.edit type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/11.edit +.. + + +# ./share/doc/usd/12.vi +/set type=file gname=bin uname=bin mode=0444 +12.vi type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/12.vi +.. + + +# ./share/doc/usd/13.ex +/set type=file gname=bin uname=bin mode=0444 +13.ex type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/13.ex +.. + + +# ./share/doc/usd/14.jove +/set type=file gname=bin uname=bin mode=0444 +14.jove type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/14.jove +.. + + +# ./share/doc/usd/15.sed +/set type=file gname=bin uname=bin mode=0444 +15.sed type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/15.sed +.. + + +# ./share/doc/usd/16.awk +/set type=file gname=bin uname=bin mode=0444 +16.awk type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/16.awk +.. + + +# ./share/doc/usd/17.msmacros +/set type=file gname=bin uname=bin mode=0444 +17.msmacros type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/17.msmacros +.. + + +# ./share/doc/usd/18.msdiffs +/set type=file gname=bin uname=bin mode=0444 +18.msdiffs type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/18.msdiffs +.. + + +# ./share/doc/usd/19.memacros +/set type=file gname=bin uname=bin mode=0444 +19.memacros type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/19.memacros +.. + + +# ./share/doc/usd/20.meref +/set type=file gname=bin uname=bin mode=0444 +20.meref type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/20.meref +.. + + +# ./share/doc/usd/21.troff +/set type=file gname=bin uname=bin mode=0444 +21.troff type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/21.troff +.. + + +# ./share/doc/usd/22.trofftut +/set type=file gname=bin uname=bin mode=0444 +22.trofftut type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/22.trofftut +.. + + +# ./share/doc/usd/23.eqn +/set type=file gname=bin uname=bin mode=0444 +23.eqn type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/23.eqn +.. + + +# ./share/doc/usd/24.eqnguide +/set type=file gname=bin uname=bin mode=0444 +24.eqnguide type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/24.eqnguide +.. + + +# ./share/doc/usd/25.tbl +/set type=file gname=bin uname=bin mode=0444 +25.tbl type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/25.tbl +.. + + +# ./share/doc/usd/26.refer +/set type=file gname=bin uname=bin mode=0444 +26.refer type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/26.refer +.. + + +# ./share/doc/usd/27.invert +/set type=file gname=bin uname=bin mode=0444 +27.invert type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/27.invert +.. + + +# ./share/doc/usd/28.bib +/set type=file gname=bin uname=bin mode=0444 +28.bib type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/28.bib +.. + + +# ./share/doc/usd/29.diction +/set type=file gname=bin uname=bin mode=0444 +29.diction type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/29.diction +.. + + +# ./share/doc/usd/30.rogue +/set type=file gname=bin uname=bin mode=0444 +30.rogue type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/30.rogue +.. + + +# ./share/doc/usd/31.trek +/set type=file gname=bin uname=bin mode=0444 +31.trek type=dir uname=root gname=wheel mode=0775 +# ./share/doc/usd/31.trek +.. + +# ./share/doc/usd +.. + +# ./share/doc +.. + + +# ./share/games +/set type=file gname=wheel uname=root mode=0444 +games type=dir mode=0755 + +# ./share/games/atc +/set type=file gname=bin uname=games mode=0400 +atc type=dir uname=root gname=wheel mode=0755 +# ./share/games/atc +.. + + +# ./share/games/boggle +/set type=file gname=bin uname=bin mode=0444 +boggle type=dir uname=root gname=wheel mode=0775 +# ./share/games/boggle +.. + + +# ./share/games/ching +/set type=file gname=bin uname=games mode=0444 +ching type=dir uname=root gname=wheel mode=0755 +# ./share/games/ching +.. + + +# ./share/games/fortune +/set type=file gname=bin uname=bin mode=0444 +fortune type=dir uname=root gname=wheel mode=0755 +# ./share/games/fortune +.. + + +# ./share/games/larn +/set type=file gname=bin uname=games mode=0444 +larn type=dir uname=root gname=wheel mode=0755 +# ./share/games/larn +.. + + +# ./share/games/quiz.db +/set type=file gname=bin uname=games mode=0444 +quiz.db type=dir uname=root gname=wheel mode=0755 +# ./share/games/quiz.db +.. + +# ./share/games +.. + + +# ./share/groff_font +/set type=file gname=wheel uname=root mode=0755 +groff_font type=dir + +# ./share/groff_font/devX100 +/set type=file gname=wheel uname=root mode=0644 +devX100 type=dir mode=0755 +# ./share/groff_font/devX100 +.. + + +# ./share/groff_font/devX100-12 +/set type=file gname=wheel uname=root mode=0644 +devX100-12 type=dir mode=0755 +# ./share/groff_font/devX100-12 +.. + + +# ./share/groff_font/devX75 +/set type=file gname=wheel uname=root mode=0644 +devX75 type=dir mode=0755 +# ./share/groff_font/devX75 +.. + + +# ./share/groff_font/devX75-12 +/set type=file gname=wheel uname=root mode=0644 +devX75-12 type=dir mode=0755 +# ./share/groff_font/devX75-12 +.. + + +# ./share/groff_font/devascii +/set type=file gname=wheel uname=root mode=0644 +devascii type=dir mode=0755 +# ./share/groff_font/devascii +.. + + +# ./share/groff_font/devdvi +/set type=file gname=wheel uname=root mode=0644 +devdvi type=dir mode=0755 + +# ./share/groff_font/devdvi/generate +/set type=file gname=wheel uname=root mode=0644 +generate type=dir mode=0755 +# ./share/groff_font/devdvi/generate +.. + +# ./share/groff_font/devdvi +.. + + +# ./share/groff_font/devlatin1 +/set type=file gname=wheel uname=root mode=0644 +devlatin1 type=dir mode=0755 +# ./share/groff_font/devlatin1 +.. + + +# ./share/groff_font/devps +/set type=file gname=wheel uname=root mode=0644 +devps type=dir mode=0755 + +# ./share/groff_font/devps/generate +/set type=file gname=wheel uname=root mode=0644 +generate type=dir mode=0755 +# ./share/groff_font/devps/generate +.. + +# ./share/groff_font/devps +.. + +# ./share/groff_font +.. + + +# ./share/locale +locale type=dir mode=0755 +# ./share/locale +.. + + +# ./share/man +/set type=file gname=wheel uname=root mode=0755 +man type=dir + +# ./share/man/cat1 +/set type=file gname=bin uname=bin mode=0444 +cat1 type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat1 +.. + + +# ./share/man/cat2 +/set type=file gname=bin uname=bin mode=0444 +cat2 type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat2 +.. + + +# ./share/man/cat3 +/set type=file gname=bin uname=bin mode=0444 +cat3 type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat3 +.. + + +# ./share/man/cat3f +/set type=file gname=bin uname=bin mode=0444 +cat3f type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat3f +.. + + +# ./share/man/cat4 +/set type=file gname=bin uname=bin mode=0444 +cat4 type=dir uname=root gname=wheel mode=0755 + +# ./share/man/cat4/hp300 +/set type=file gname=bin uname=bin mode=0444 +hp300 type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat4/hp300 +.. + + +# ./share/man/cat4/i386 +/set type=file gname=bin uname=bin mode=0444 +i386 type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat4/i386 +.. + + +# ./share/man/cat4/sparc +/set type=file gname=bin uname=bin mode=0444 +sparc type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat4/sparc +.. + + +# ./share/man/cat4/tahoe +/set type=file gname=bin uname=bin mode=0444 +tahoe type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat4/tahoe +.. + + +# ./share/man/cat4/vax +/set type=file gname=bin uname=bin mode=0444 +vax type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat4/vax +.. + +# ./share/man/cat4 +.. + + +# ./share/man/cat5 +/set type=file gname=bin uname=bin mode=0444 +cat5 type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat5 +.. + + +# ./share/man/cat6 +/set type=file gname=bin uname=bin mode=0444 +cat6 type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat6 +.. + + +# ./share/man/cat7 +/set type=file gname=bin uname=bin mode=0444 +cat7 type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat7 +.. + + +# ./share/man/cat8 +/set type=file gname=bin uname=bin mode=0444 +cat8 type=dir uname=root gname=wheel mode=0755 + +# ./share/man/cat8/hp300 +/set type=file gname=bin uname=bin mode=0444 +hp300 type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat8/hp300 +.. + + +# ./share/man/cat8/i386 +/set type=file gname=bin uname=bin mode=0444 +i386 type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat8/i386 +.. + + +# ./share/man/cat8/sparc +/set type=file gname=bin uname=bin mode=0444 +sparc type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat8/sparc +.. + + +# ./share/man/cat8/tahoe +/set type=file gname=bin uname=bin mode=0444 +tahoe type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat8/tahoe +.. + + +# ./share/man/cat8/vax +/set type=file gname=bin uname=bin mode=0444 +vax type=dir uname=root gname=wheel mode=0755 +# ./share/man/cat8/vax +.. + +# ./share/man/cat8 +.. + + +# ./share/man/old +/set type=file gname=wheel uname=root mode=0755 +old type=dir uname=bin gname=bin + +# ./share/man/old/cat1 +/set type=file gname=bin uname=bin mode=0444 +cat1 type=dir uname=root gname=wheel mode=0755 +# ./share/man/old/cat1 +.. + + +# ./share/man/old/cat2 +cat2 type=dir uname=root gname=wheel mode=0755 +# ./share/man/old/cat2 +.. + + +# ./share/man/old/cat3 +cat3 type=dir uname=root gname=wheel mode=0755 +# ./share/man/old/cat3 +.. + + +# ./share/man/old/cat4 +cat4 type=dir uname=root gname=wheel mode=0755 +# ./share/man/old/cat4 +.. + + +# ./share/man/old/cat5 +/set type=file gname=bin uname=bin mode=0444 +cat5 type=dir uname=root gname=wheel mode=0755 +# ./share/man/old/cat5 +.. + + +# ./share/man/old/cat6 +cat6 type=dir uname=root gname=wheel mode=0755 +# ./share/man/old/cat6 +.. + + +# ./share/man/old/cat7 +cat7 type=dir uname=root gname=wheel mode=0755 +# ./share/man/old/cat7 +.. + + +# ./share/man/old/cat8 +cat8 type=dir uname=root gname=wheel mode=0755 +# ./share/man/old/cat8 +.. + +# ./share/man/old +.. + +# ./share/man +.. + + +# ./share/me +/set type=file gname=bin uname=bin mode=0444 +me type=dir uname=root gname=wheel mode=0755 +# ./share/me +.. + + +# ./share/misc +/set type=file gname=bin uname=bin mode=0444 +misc type=dir uname=root gname=wheel mode=0755 +# ./share/misc +.. + + +# ./share/mk +/set type=file gname=bin uname=bin mode=0444 +mk type=dir uname=root gname=wheel mode=0755 +# ./share/mk +.. + + +# ./share/skel +/set type=file gname=bin uname=bin mode=0444 +skel type=dir uname=root gname=wheel mode=0755 +# ./share/skel +.. + + +# ./share/tabset +/set type=file gname=bin uname=bin mode=0444 +tabset type=dir uname=root gname=wheel mode=0755 +# ./share/tabset +.. + + +# ./share/tmac +/set type=file gname=wheel uname=root mode=0644 +tmac type=dir mode=0755 + +# ./share/tmac/mm +/set type=file gname=wheel uname=root mode=0644 +mm type=dir mode=0755 +# ./share/tmac/mm +.. + +# ./share/tmac +.. + + +# ./share/zoneinfo +/set type=file gname=bin uname=bin mode=0444 +zoneinfo type=dir mode=0555 + +# ./share/zoneinfo/Australia +/set type=file gname=bin uname=bin mode=0444 +Australia type=dir mode=0555 +# ./share/zoneinfo/Australia +.. + + +# ./share/zoneinfo/Brazil +/set type=file gname=bin uname=bin mode=0444 +Brazil type=dir mode=0555 +# ./share/zoneinfo/Brazil +.. + + +# ./share/zoneinfo/Canada +/set type=file gname=bin uname=bin mode=0444 +Canada type=dir mode=0555 +# ./share/zoneinfo/Canada +.. + + +# ./share/zoneinfo/Chile +/set type=file gname=bin uname=bin mode=0444 +Chile type=dir mode=0555 +# ./share/zoneinfo/Chile +.. + + +# ./share/zoneinfo/Mexico +/set type=file gname=bin uname=bin mode=0444 +Mexico type=dir mode=0555 +# ./share/zoneinfo/Mexico +.. + + +# ./share/zoneinfo/SystemV +/set type=file gname=bin uname=bin mode=0444 +SystemV type=dir mode=0555 +# ./share/zoneinfo/SystemV +.. + + +# ./share/zoneinfo/US +/set type=file gname=bin uname=bin mode=0444 +US type=dir mode=0555 +# ./share/zoneinfo/US +.. + +# ./share/zoneinfo +.. + +# ./share +.. + + +# ./src +/set type=file gname=wsrc uname=bin mode=0775 +src type=dir +# ./src +.. + + +# ./ucb +/set type=file gname=wheel uname=root mode=0755 +ucb type=dir +# ./ucb +.. diff --git a/src/etc/mtree/4.4BSD.var b/src/etc/mtree/4.4BSD.var new file mode 100644 index 00000000..3e21d9eb --- /dev/null +++ b/src/etc/mtree/4.4BSD.var @@ -0,0 +1,442 @@ +# user: bostic +# machine: vangogh.CS.Berkeley.EDU +# tree: /var +# date: Tue Jul 20 12:55:06 1993 + +# . +/set type=file gname=wheel uname=root mode=0755 +. type=dir + +# ./account +/set type=file gname=wheel uname=root mode=0644 +account type=dir mode=0755 +# ./account +.. + + +# ./at +/set type=file gname=daemon uname=root mode=0644 +at type=dir mode=0755 + +# ./at/past +past type=dir gname=wheel mode=0755 +# ./at/past +.. + +# ./at +.. + + +# ./backups +/set type=file gname=wheel uname=root mode=0644 +backups type=dir mode=0755 +# ./backups +.. + + +# ./crash +/set type=file gname=wheel uname=root mode=0660 +crash type=dir uname=root mode=0770 +# ./crash +.. + + +# ./db +/set type=file gname=wheel uname=root mode=0755 +db type=dir +# ./db +.. + + +# ./emacs +/set type=file gname=wheel uname=root mode=0777 +emacs type=dir mode=0755 + +# ./emacs/lock +/set type=file gname=wheel uname=root mode=0666 +lock type=dir uname=root mode=0777 +# ./emacs/lock +.. + +# ./emacs +.. + + +# ./games +/set type=file gname=games uname=games mode=0644 +games type=dir mode=0775 + +# ./games/hackdir +/set type=file gname=bin uname=games mode=0444 +hackdir type=dir gname=games mode=0755 +# ./games/hackdir +.. + + +# ./games/larn +/set type=file gname=bin uname=games mode=0660 +larn type=dir gname=games mode=0755 +# ./games/larn +.. + + +# ./games/phantasia +/set type=file gname=bin uname=games mode=0660 +phantasia type=dir gname=games mode=0755 +# ./games/phantasia +.. + +# ./games +.. + + +# ./log +/set type=file gname=wheel uname=root mode=0644 +log type=dir mode=0755 + +# ./log/rdist +/set type=file gname=staff uname=root mode=0644 +rdist type=dir mode=0775 +# ./log/rdist +.. + +# ./log +.. + + +# ./mail +/set type=file gname=guest uname=root mode=0600 +mail type=dir uname=root gname=wheel mode=0755 +# ./mail +.. + + +# ./msgs +/set type=file gname=staff uname=daemon mode=0644 +msgs type=dir mode=0775 +# ./msgs +.. + + +# ./obj +/set type=file gname=wsrc uname=root mode=0775 +obj type=dir gname=wheel +# ./obj +.. + + +# ./preserve +/set type=file gname=wheel uname=bostic mode=0600 +preserve type=dir uname=root mode=0755 +# ./preserve +.. + + +# ./quotas +quotas type=dir uname=root gname=operator mode=0750 +# ./quotas +.. + + +# ./run +/set type=file gname=wheel uname=root mode=0644 +run type=dir mode=0755 +# ./run +.. + + +# ./rwho +/set type=file gname=wheel uname=root mode=0644 +rwho type=dir mode=0755 +# ./rwho +.. + + +# ./spool +/set type=file gname=wheel uname=root mode=0755 +spool type=dir + +# ./spool/ftp +/set type=file gname=wheel uname=root mode=0755 +ftp type=dir + +# ./spool/ftp/bin +/set type=file gname=wheel uname=root mode=0555 +bin type=dir mode=0755 +# ./spool/ftp/bin +.. + + +# ./spool/ftp/etc +/set type=file gname=wheel uname=root mode=0644 +etc type=dir mode=0755 +# ./spool/ftp/etc +.. + + +# ./spool/ftp/hidden +/set type=file gname=wheel uname=bostic mode=0644 +hidden type=dir uname=root mode=0751 +# ./spool/ftp/hidden +.. + + +# ./spool/ftp/pub +/set type=file gname=wheel uname=root mode=0777 +pub type=dir + + +# ./spool/ftp/pub/incoming +/set type=file gname=wheel uname=root mode=0644 +incoming type=dir uname=root mode=0733 +# ./spool/ftp/pub/incoming +.. + + +# ./spool/ftp/pub +.. + +# ./spool/ftp +.. + + +# ./spool/mqueue +/set type=file gname=wheel uname=root mode=0600 +mqueue type=dir mode=0755 +# ./spool/mqueue +.. + + +# ./spool/news +/set type=file gname=news uname=news mode=0775 +news type=dir uname=root gname=wheel mode=0755 + +# ./spool/news/data +/set type=file gname=news uname=news mode=0775 +data type=dir + +# ./spool/news/data/OLD +OLD type=dir +# ./spool/news/data/OLD +.. + + +# ./spool/news/data/ctlbin +ctlbin type=dir +# ./spool/news/data/ctlbin +.. + + +# ./spool/news/data/innd +innd type=dir +# ./spool/news/data/innd +.. + + +# ./spool/news/data/trn +trn type=dir +# ./spool/news/data/trn +.. + +# ./spool/news/data +.. + + +# ./spool/news/news.archive +news.archive type=dir +# ./spool/news/news.archive +.. + + +# ./spool/news/out.going +out.going type=dir +# ./spool/news/out.going +.. + + +# ./spool/news/spool +/set type=file gname=news uname=news mode=0775 +spool type=dir + +# ./spool/news/spool/in.coming +/set type=file gname=news uname=news mode=0775 +in.coming type=dir + +# ./spool/news/spool/in.coming/bad +bad type=dir +# ./spool/news/spool/in.coming/bad +.. + + +# ./spool/news/spool/in.coming/tmp +tmp type=dir +# ./spool/news/spool/in.coming/tmp +.. + +# ./spool/news/spool/in.coming +.. + +# ./spool/news/spool +.. + +# ./spool/news +.. + + +# ./spool/output +/set type=file gname=daemon uname=daemon mode=0775 +output type=dir uname=root gname=wheel mode=0755 +# ./spool/output +.. + + +# ./spool/secretmail +secretmail type=dir uname=root gname=wheel mode=0755 +# ./spool/secretmail +.. + + +# ./spool/sockets +/set type=file gname=wheel uname=root mode=0777 +sockets type=dir + +# ./spool/sockets/X11 +X11 type=dir +# ./spool/sockets/X11 +.. + +# ./spool/sockets +.. + + +# ./spool/uucp +/set type=file gname=daemon uname=uucp mode=0755 +uucp type=dir + +# ./spool/uucp/AUDIT +AUDIT type=dir +# ./spool/uucp/AUDIT +.. + + +# ./spool/uucp/C. +C. type=dir +# ./spool/uucp/C. +.. + + +# ./spool/uucp/CORRUPT +CORRUPT type=dir +# ./spool/uucp/CORRUPT +.. + + +# ./spool/uucp/D. +D. type=dir +# ./spool/uucp/D. +.. + + +# ./spool/uucp/D.X +D.X type=dir +# ./spool/uucp/D.X +.. + + +# ./spool/uucp/LCK +LCK type=dir mode=0777 +# ./spool/uucp/LCK +.. + + +# ./spool/uucp/LOG +/set type=file gname=daemon uname=uucp mode=0755 +LOG type=dir + +# ./spool/uucp/LOG/uucico +uucico type=dir +# ./spool/uucp/LOG/uucico +.. + + +# ./spool/uucp/LOG/uucp +uucp type=dir +# ./spool/uucp/LOG/uucp +.. + + +# ./spool/uucp/LOG/uux +uux type=dir +# ./spool/uucp/LOG/uux +.. + + +# ./spool/uucp/LOG/uuxqt +uuxqt type=dir +# ./spool/uucp/LOG/uuxqt +.. + + +# ./spool/uucp/LOG/xferstats +xferstats type=dir +# ./spool/uucp/LOG/xferstats +.. + +# ./spool/uucp/LOG +.. + + +# ./spool/uucp/STST +STST type=dir +# ./spool/uucp/STST +.. + + +# ./spool/uucp/TM. +TM. type=dir +# ./spool/uucp/TM. +.. + + +# ./spool/uucp/X. +X. type=dir +# ./spool/uucp/X. +.. + + +# ./spool/uucp/XTMP +XTMP type=dir +# ./spool/uucp/XTMP +.. + +# ./spool/uucp +.. + + +# ./spool/uucppublic +uucppublic type=dir mode=0777 +# ./spool/uucppublic +.. + +# ./spool +.. + + +# ./tmp +/set type=file gname=wheel uname=nobody mode=0600 +tmp type=dir uname=root mode=01777 + +# ./vi.recover +/set type=file gname=wheel uname=nobody mode=0600 +vi.recover type=dir uname=root mode=01777 +# ./vi.recover +.. + +# ./tmp +.. + +# ./users +/set type=file gname=wheel uname=nobody mode=0600 +users type=dir uname=root mode=755 +# ./users +.. diff --git a/src/etc/mtree/special b/src/etc/mtree/special new file mode 100644 index 00000000..2c15ab94 --- /dev/null +++ b/src/etc/mtree/special @@ -0,0 +1,163 @@ +# $NetBSD: special,v 1.3 1995/04/21 00:22:04 cgd Exp $ +# @(#)special 8.2 (Berkeley) 1/23/94 +# +# Hand-crafted mtree specification for the dangerous files. +# + +. type=dir mode=0755 uname=root gname=wheel + +dev type=dir mode=0755 uname=root gname=wheel +drum type=char mode=640 uname=root gname=kmem +fd type=dir mode=0755 uname=root gname=wheel ignore +.. #dev/fd +kmem type=char mode=640 uname=root gname=kmem +mem type=char mode=640 uname=root gname=kmem ignore +.. #dev + +etc type=dir mode=0755 uname=root gname=wheel +aliases type=file mode=0644 uname=root gname=wheel +aliases.db type=file mode=0644 uname=root gname=wheel +crontab type=file mode=0644 uname=root gname=wheel +csh.cshrc type=file mode=0644 uname=root gname=wheel +csh.login type=file mode=0644 uname=root gname=wheel +csh.logout type=file mode=0644 uname=root gname=wheel +daily type=file mode=0644 uname=root gname=wheel +disklabels type=dir mode=0755 uname=root gname=wheel ignore +.. #disklabels +exports type=file mode=0644 uname=root gname=wheel +fstab type=file mode=0644 uname=root gname=wheel +ftpusers type=file mode=0644 uname=root gname=wheel +group type=file mode=0644 uname=root gname=wheel +hosts.equiv type=file mode=0600 uname=root gname=wheel +kerberosIV type=dir mode=0755 uname=root gname=wheel ignore +.. #kerberosIV +mail.rc type=file mode=0644 uname=root gname=wheel +master.passwd type=file mode=600 uname=root gname=wheel +monthly type=file mode=0644 uname=root gname=wheel +mtree type=dir mode=0755 uname=root gname=wheel +special type=file mode=0600 uname=root gname=wheel +.. #mtree +named.boot type=file mode=0644 uname=root gname=wheel +netstart type=file mode=0744 uname=root gname=wheel +passwd type=file mode=644 uname=root gname=wheel +printcap type=file mode=0644 uname=root gname=wheel +rc type=file mode=0644 uname=root gname=wheel +rc.local type=file mode=0644 uname=root gname=wheel +security type=file mode=0644 uname=root gname=wheel +sendmail.cf type=file mode=0644 uname=root gname=wheel +shells type=file mode=0644 uname=root gname=wheel +spwd.db type=file mode=0600 uname=root gname=wheel +syslog.conf type=file mode=0644 uname=root gname=wheel +ttys type=file mode=0644 uname=root gname=wheel +weekly type=file mode=0644 uname=root gname=wheel +.. #etc + +root type=dir mode=0755 uname=root gname=wheel +.cshrc type=file mode=0644 uname=root gname=wheel +.klogin type=file mode=0600 uname=root gname=wheel +.login type=file mode=0644 uname=root gname=wheel +.profile type=file mode=0644 uname=root gname=wheel +.rhosts type=file mode=0600 uname=root gname=wheel +.. #root + +sbin type=dir mode=0755 uname=root gname=wheel ignore +.. #sbin + +usr type=dir mode=0755 uname=root gname=wheel +bin type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/bin +contrib type=dir mode=0755 uname=root gname=wheel +bin type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/contrib/bin +lib type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/contrib/lib +.. #usr/contrib +games type=dir mode=0755 uname=root gname=wheel +hide type=dir mode=0700 uname=games gname=wheel ignore +.. #usr/games/hide +.. #usr/games +include type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/include +lib type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/lib +libdata type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/libdata +libexec type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/libexec +local type=dir mode=0755 uname=root gname=wheel +bin type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/local/bin +lib type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/local/lib +.. #usr/local +new type=dir mode=0755 uname=root gname=wheel +bin type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/new/bin +lib type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/new/lib +.. #usr/new +old type=dir mode=0755 uname=root gname=wheel +bin type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/old/bin +lib type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/old/lib +.. #usr/old +sbin type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/sbin +share type=dir mode=0755 uname=root gname=wheel ignore +.. #usr/share +src type=dir mode=0775 uname=root gname=wsrc ignore +.. #usr/src +.. #usr + +var type=dir mode=0755 uname=root gname=wheel +account type=dir mode=0755 uname=root gname=wheel +acct type=file mode=644 uname=root gname=wheel +.. #var/account +at type=dir mode=0755 uname=root gname=daemon ignore +.. #var/at +backups type=dir mode=0755 uname=root gname=wheel ignore +.. #var/backups +db type=dir mode=0755 uname=root gname=wheel +kvm_netbsd.db type=file mode=0644 uname=root gname=wheel +.. #var/db +log type=dir mode=0755 uname=root gname=wheel +secure type=file mode=0600 uname=root gname=wheel +wtmp type=file mode=0644 uname=root gname=wheel +.. #var/log +mail type=dir mode=0755 uname=root gname=wheel ignore +.. #var/mail +preserve type=dir mode=0755 uname=root gname=wheel ignore +.. #var/preserve +run type=dir mode=0755 uname=root gname=wheel +utmp type=file mode=0664 uname=root gname=utmp +.. #var/run +spool type=dir mode=0755 uname=root gname=wheel +ftp type=dir mode=0755 uname=root gname=wheel +bin type=dir mode=0755 uname=root gname=wheel +ls type=file mode=555 uname=root gname=wheel +.. #var/spool/ftp/bin +etc type=dir mode=0755 uname=root gname=wheel +group type=file mode=644 uname=root gname=wheel +localtime type=file mode=644 uname=root gname=wheel +master.passwd type=file mode=644 uname=root gname=wheel +passwd type=file mode=644 uname=root gname=wheel +.. #var/spool/ftp/etc +hidden type=dir mode=0111 uname=root gname=wheel ignore +.. #var/spool/ftp/hidden +pub type=dir mode=0777 uname=root gname=wheel ignore +.. #var/spool/ftp/pub +.. #var/spool/ftp +mqueue type=dir mode=0755 uname=root gname=wheel ignore +.. #var/spool/mqueue +news type=dir mode=0755 uname=root gname=wheel ignore +.. #var/spool/news +output type=dir mode=0755 uname=root gname=wheel ignore +.. #var/spool/output +secretmail type=dir mode=0755 uname=root gname=wheel ignore +.. #var/spool/secretmail +uucp type=dir mode=0755 uname=uucp gname=daemon ignore +.. #var/spool/uucp +uucppublic type=dir mode=0777 uname=uucp gname=daemon ignore +.. #var/spool/uucppublic +.. #var/spool diff --git a/src/etc/myname b/src/etc/myname new file mode 100644 index 00000000..a0d6cce3 --- /dev/null +++ b/src/etc/myname @@ -0,0 +1 @@ +myname.my.domain diff --git a/src/etc/namedb/localhost.rev b/src/etc/namedb/localhost.rev new file mode 100644 index 00000000..d6e59658 --- /dev/null +++ b/src/etc/namedb/localhost.rev @@ -0,0 +1,10 @@ +; @(#)localhost.rev 5.1 (Berkeley) 6/30/90 + +@ IN SOA ucbvax.Berkeley.EDU. rwh.ucbvax.Berkeley.EDU. ( + 1.4 ; Serial + 3600 ; Refresh + 300 ; Retry + 3600000 ; Expire + 3600 ) ; Minimum + IN NS ucbvax.Berkeley.EDU. +1 IN PTR localhost.Berkeley.EDU. diff --git a/src/etc/namedb/named.boot b/src/etc/namedb/named.boot new file mode 100644 index 00000000..93db3085 --- /dev/null +++ b/src/etc/namedb/named.boot @@ -0,0 +1,21 @@ +; @(#)named.boot 5.1 (Berkeley) 6/30/90 + +; boot file for secondary name server +; Note that there should be one primary entry for each SOA record. + +sortlist 128.3.0.0 + +directory /etc/namedb + +; type domain source host/file backup file + +cache . root.cache +primary 0.0.127.IN-ADDR.ARPA localhost.rev + +; example secondary server config: +; secondary Berkeley.EDU 128.32.130.11 128.32.133.1 ucbhosts.bak +; secondary 32.128.IN-ADDR.ARPA 128.32.130.11 128.32.133.1 ucbhosts.rev.bak + +; example primary server config: +; primary Berkeley.EDU ucbhosts +; primary 32.128.IN-ADDR.ARPA ucbhosts.rev diff --git a/src/etc/namedb/root.cache b/src/etc/namedb/root.cache new file mode 100644 index 00000000..6fec42da --- /dev/null +++ b/src/etc/namedb/root.cache @@ -0,0 +1,65 @@ +; $NetBSD: root.cache,v 1.4 1995/09/19 05:30:34 thorpej Exp $ +; +; This file holds the information on root name servers needed to +; initialize cache of Internet domain name servers +; (e.g. reference this file in the "cache . <file>" +; configuration file of BIND domain name servers). +; +; This file is made available by InterNIC registration services +; under anonymous FTP as +; file /domain/named.root +; on server FTP.RS.INTERNIC.NET +; -OR- under Gopher at RS.INTERNIC.NET +; under menu InterNIC Registration Services (NSI) +; submenu InterNIC Registration Archives +; file named.root +; +; last update: Sep 1, 1995 +; related version of root zone: 1995090100 +; +; +; formerly NS.INTERNIC.NET +; +. 3600000 IN NS A.ROOT-SERVERS.NET. +A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4 +; +; formerly NS1.ISI.EDU +; +. 3600000 NS B.ROOT-SERVERS.NET. +B.ROOT-SERVERS.NET. 3600000 A 128.9.0.107 +; +; formerly C.PSI.NET +; +. 3600000 NS C.ROOT-SERVERS.NET. +C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12 +; +; formerly TERP.UMD.EDU +; +. 3600000 NS D.ROOT-SERVERS.NET. +D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90 +; +; formerly NS.NASA.GOV +; +. 3600000 NS E.ROOT-SERVERS.NET. +E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10 +; +; formerly NS.ISC.ORG +; +. 3600000 NS F.ROOT-SERVERS.NET. +F.ROOT-SERVERS.NET. 3600000 A 39.13.229.241 +; +; formerly NS.NIC.DDN.MIL +; +. 3600000 NS G.ROOT-SERVERS.NET. +G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4 +; +; formerly AOS.ARL.ARMY.MIL +; +. 3600000 NS H.ROOT-SERVERS.NET. +H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53 +; +; formerly NIC.NORDU.NET +; +. 3600000 NS I.ROOT-SERVERS.NET. +I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17 +; End of File diff --git a/src/etc/netstart b/src/etc/netstart new file mode 100644 index 00000000..9d4149ac --- /dev/null +++ b/src/etc/netstart @@ -0,0 +1,102 @@ +#!/bin/sh - +# +# $NetBSD: netstart,v 1.21 1995/10/08 18:11:40 thorpej Exp $ +# @(#)netstart 5.9 (Berkeley) 3/30/91 + +# set these to "NO" to turn them off. otherwise, they're used as flags +routed_flags=-q +rarpd_flags=NO # for 'normal' use: rarpd_flags="-a" +bootparamd_flags=NO # for 'normal' use: bootparamd_flags="" +rbootd_flags=NO # for 'normal' use: rbootd_flags="" +sendmail_flags=NO # for 'normal' use: sendmail_flags="-bd -q30m" +named_flags=NO # for 'normal' use: named_flags="" +timed_flags= + +# set the following to "YES" to turn them on +rwhod=NO +nfs_server=NO +nfs_client=NO +gated=NO +kerberos_server=NO +amd=NO + +# miscellaneous other flags +# only used if the appropriate server is marked YES above +gated_flags= +amd_dir=/amd # AMD's mount directory +amd_master=/etc/amd/master # AMD 'master' map + +# /etc/myname contains my symbolic name +# +hostname=`cat /etc/myname` +hostname $hostname +if [ -f /etc/defaultdomain ]; then + domainname `cat /etc/defaultdomain` +fi + +# configure all of the interfaces which we know about. +# do this by reading /etc/hostname.* files, where * is the name +# of a given interface. +# +# these files are formatted like the following, but with no # at the +# beginning of the line +# +# addr_family hostname netmask broadcast_addr options +# dest dest_addr +# +# addr_family is the address family of the interface, generally inet +# hostname is the host name that belongs to the interface, in /etc/hosts. +# netmask is the network mask for the interface. +# broadcast_addr is the broadcast address for the interface +# options are misc. options to ifconfig for the interface. +# +# dest is simply the string "dest" (no quotes, though) if the interface +# has a "destination" (i.e. it's a point-to-point link, like SLIP). +# dest_addr is the hostname of the other end of the link, in /etc/hosts +# +# the only required contents of the file are the addr_family field +# and the hostname. + +( + tmp="$IFS" + IFS="$IFS." + set -- `echo /etc/hostname*` + IFS=$tmp + unset tmp + + while [ $# -ge 2 ] ; do + shift # get rid of "hostname" + ( + read af name mask bcaddr extras + read dt dtaddr + + if [ ! -n "$name" ]; then + echo "/etc/hostname.$1: invalid network configuration file" + exit + fi + + cmd="ifconfig $1 $af $name " + if [ "${dt}" = "dest" ]; then cmd="$cmd $dtaddr"; fi + if [ -n "$mask" ]; then cmd="$cmd netmask $mask"; fi + if [ -n "$bcaddr" -a "X$bcaddr" != "XNONE" ]; then + cmd="$cmd broadcast $bcaddr"; + fi + cmd="$cmd $extras" + + $cmd + ) < /etc/hostname.$1 + shift + done +) + +# set the address for the loopback interface +ifconfig lo0 inet localhost + +# use loopback, not the wire +route add $hostname localhost + +# /etc/mygate, if it exists, contains the name of my gateway host +# that name must be in /etc/hosts. +if [ -f /etc/mygate ]; then + route add default `cat /etc/mygate` +fi diff --git a/src/etc/networks b/src/etc/networks new file mode 100644 index 00000000..71aeb5b0 --- /dev/null +++ b/src/etc/networks @@ -0,0 +1,16 @@ +# @(#)networks 5.1 (Berkeley) 6/30/90 +# +# Your Local Networks Database +# +your-net 127 # your comment +your-netmask 255.255.255 # subnet mask for your-net + +# +# Your subnets +# +subnet1 127.0.1 alias1 # comment 1 +subnet2 127.0.2 alias2 # comment 2 + +# +# Internet networks (from nic.ddn.mil) +# diff --git a/src/etc/newsyslog.conf b/src/etc/newsyslog.conf new file mode 100644 index 00000000..03b4ffe1 --- /dev/null +++ b/src/etc/newsyslog.conf @@ -0,0 +1,12 @@ +# configuration file for newsyslog +# $Id: newsyslog.conf,v 1.1.1.1 1995/10/18 08:37:57 deraadt Exp $ +# +# logfilename owner.group mode ngen size time [ZB] +/var/cron/log root.wheel 600 3 10 * Z +/var/log/aculog uucp.dialer 640 7 * 24 Z +/var/log/kerberos.log 640 7 * 24 Z +/var/log/lpd-errs 640 7 10 * Z +/var/log/maillog 600 7 * 24 Z +/var/log/messages 644 5 30 * Z +/var/log/wtmp 644 7 * 168 ZB +/var/log/xferlog 640 7 250 * Z diff --git a/src/etc/phones b/src/etc/phones new file mode 100644 index 00000000..941b0edc --- /dev/null +++ b/src/etc/phones @@ -0,0 +1,7 @@ +# @(#)phones 5.2 (Berkeley) 6/30/90 +# +# phones -- remote host phone number data base +# see tip(1), phones(5) + +system1 9=3156427750 +system2 9148841241 diff --git a/src/etc/printcap b/src/etc/printcap new file mode 100644 index 00000000..06791f85 --- /dev/null +++ b/src/etc/printcap @@ -0,0 +1,4 @@ +# @(#)printcap 5.3 (Berkeley) 6/30/90 + +#lp|local line printer:\ +# :lp=/dev/lp:sd=/var/spool/lpd:lf=/var/log/lpd-errs: diff --git a/src/etc/protocols b/src/etc/protocols new file mode 100644 index 00000000..e23676bc --- /dev/null +++ b/src/etc/protocols @@ -0,0 +1,28 @@ +# +# Internet (IP) protocols +# +# from: @(#)protocols 5.1 (Berkeley) 4/17/89 +# $Id: protocols,v 1.1.1.1 1995/10/18 08:37:57 deraadt Exp $ +# +# Updated for NetBSD based on RFC 1340, Assigned Numbers (July 1992). +# +ip 0 IP # internet protocol, pseudo protocol number +icmp 1 ICMP # internet control message protocol +igmp 2 IGMP # Internet Group Management +ggp 3 GGP # gateway-gateway protocol +ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'') +st 5 ST # ST datagram mode +tcp 6 TCP # transmission control protocol +egp 8 EGP # exterior gateway protocol +pup 12 PUP # PARC universal packet protocol +udp 17 UDP # user datagram protocol +hmp 20 HMP # host monitoring protocol +xns-idp 22 XNS-IDP # Xerox NS IDP +rdp 27 RDP # "reliable datagram" protocol +iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 +xtp 36 XTP # Xpress Tranfer Protocol +idpr-cmtp 39 IDPR-CMTP # IDPR Control Message Transport +vmtp 81 VMTP # Versatile Message Transport +ospf 89 OSPFIGP # Open Shortest Path First IGP +ipip 94 IPIP # Yet Another IP encapsulation +encap 98 ENCAP # Yet Another IP encapsulation diff --git a/src/etc/rbootd.conf b/src/etc/rbootd.conf new file mode 100644 index 00000000..8ec7b9ac --- /dev/null +++ b/src/etc/rbootd.conf @@ -0,0 +1,13 @@ +# +# Configuration file for rbootd server. +# +# $Header: /tmp/openntpd-cvs2git/cvs/src/etc/Attic/rbootd.conf,v 1.1.1.1 1995/10/18 08:37:57 deraadt Exp $ +# + +# +# ethernet addr boot file(s) comments +# +08:00:09:00:66:ad SYSHPBSD # snake (4.3BSD) +08:00:09:00:59:17 # vandy (anything) +8::9:10:1e:9b SYSHPUX,hp-ux # critter (HP-UX) +8::9:10:8A:14 SYSHPBSD,SYSHPUX,hp-ux # jaguar (either) diff --git a/src/etc/rc b/src/etc/rc new file mode 100644 index 00000000..a18c1789 --- /dev/null +++ b/src/etc/rc @@ -0,0 +1,242 @@ +# $NetBSD: rc,v 1.54 1995/10/08 18:11:43 thorpej Exp $ +# from: @(#)rc 8.2 (Berkeley) 3/17/94 + +# System startup script run by init on autoboot +# or after single-user. +# Output and error are redirected to console by init, +# and the console is the controlling terminal. + +stty status '^T' + +# Set shell to ignore SIGINT (2), but not children; +# shell catches SIGQUIT (3) and returns to single user after fsck. +trap : 2 +trap : 3 # shouldn't be needed + +HOME=/; export HOME +PATH=/sbin:/bin:/usr/sbin:/usr/bin +export PATH + +# Configure ccd devices. +if [ -f /etc/ccd.conf ] +then + ccdconfig -C +fi + +if [ -e /fastboot ] +then + echo "Fast boot: skipping disk checks." +elif [ $1x = autobootx ] +then + echo "Automatic boot in progress: starting file system checks." + fsck -p + case $? in + 0) + ;; + 2) + exit 1 + ;; + 4) + echo "Rebooting..." + reboot + echo "Reboot failed; help!" + exit 1 + ;; + 8) + echo "Automatic file system check failed; help!" + exit 1 + ;; + 12) + echo "Boot interrupted." + exit 1 + ;; + 130) + # interrupt before catcher installed + exit 1 + ;; + *) + echo "Unknown error; help!" + exit 1 + ;; + esac +fi + +trap "echo 'Boot interrupted.'; exit 1" 3 + +swapon -a + +umount -a >/dev/null 2>&1 +mount -a -t nonfs +rm -f /fastboot # XXX (root now writeable) + +# set flags on ttys. (do early, in case they use tty for SLIP in netstart) +echo 'setting tty flags' +ttyflags -a + +# set hostname, turn on network +echo 'starting network' +. /etc/netstart + +mount /usr >/dev/null 2>&1 +mount /var >/dev/null 2>&1 + +# clean up left-over files +rm -f /etc/nologin +rm -f /var/spool/lock/LCK.* +rm -f /var/spool/uucp/STST/* +(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; }) + +echo -n 'starting rpc daemons:' +echo -n ' portmap'; portmap + +if [ -f /usr/sbin/ypbind -a -d /var/yp ]; then + echo -n ' ypbind'; ypbind +fi + +# $nfs_server is imported from /etc/netstart; +# if $nfs_server == YES, the machine is setup for being an nfs server +if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then + rm -f /var/db/mountdtab + echo -n > /var/db/mountdtab + echo -n ' mountd'; mountd + echo -n ' nfsd'; nfsd -tun 4 +fi + +# $nfs_client is imported from /etc/netstart; +# if $nfs_client == YES, the machine is setup for being an nfs client +if [ X${nfs_client} = X"YES" ]; then + echo -n ' nfsiod'; nfsiod -n 4 +fi + +if [ X${amd} = X"YES" -a -d ${amd_dir} -a -r ${amd_master} ]; then + echo -n ' amd' + amd -l syslog -x error,noinfo,nostats -p \ + -a ${amd_dir} `cat ${amd_master}` > /var/run/amd.pid +fi + +echo '.' +mount -a -t nfs + +echo -n 'starting system logger' +rm -f /dev/log +syslogd + +# $timed_flags is imported from /etc/netstart; +# if $timed_flags == NO, timed isn't run. +if [ "X${timed_flags}" != X"NO" ]; then + echo -n ', time daemon'; timed $timed_flags +fi +echo '.' + +# /var/crash should be a directory or a symbolic link +# to the crash directory if core dumps are to be saved. +if [ -d /var/crash ]; then + echo checking for core dump... + savecore /var/crash +fi + + echo -n 'checking quotas:' +quotacheck -a + echo ' done.' +quotaon -a + +# build ps databases +echo 'building databases...' +kvm_mkdb /netbsd +dev_mkdb + +chmod 666 /dev/tty[pqrs]* + +# check the password temp/lock file +if [ -f /etc/ptmp ] +then + logger -s -p auth.err \ + 'password file may be incorrect -- /etc/ptmp exists' +fi + +virecovery=/var/tmp/vi.recover/recover.* +if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then + echo preserving editor files + for i in $virecovery; do + sendmail -t < $i + done +fi + +echo clearing /tmp + +# prune quickly with one rm, then use find to clean up /tmp/[lq]* +# (not needed with mfs /tmp, but doesn't hurt there...) +(cd /tmp && rm -rf [a-km-pr-zA-Z]* && + find . ! -name . ! -name lost+found ! -name quota.user \ + ! -name quota.group -exec rm -rf -- {} \; -type d -prune) + +if [ -f /var/account/acct ]; then + echo 'turning on accounting'; accton /var/account/acct +fi + +echo -n standard daemons: +echo -n ' update'; update +echo -n ' cron'; cron +echo '.' + +echo -n starting network daemons: + +# $gated and $routed_flags are imported from /etc/netstart. +# If $gated == YES, gated is used; otherwise routed. +# If $routed_flags == NO, routed isn't run. +if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then + echo -n ' gated'; gated $gated_flags +elif [ "X${routed_flags}" != X"NO" ]; then + echo -n ' routed'; routed $routed_flags +fi + +# $name_flags is imported from /etc/netstart; +# if $named_flags != NO, named is run. +if [ "X${named_flags}" != X"NO" ]; then + echo -n ' named'; named $named_flags +fi + +# $rwhod is imported from /etc/netstart; +# if $rwhod == YES, rwhod is run. +if [ X${rwhod} = X"YES" ]; then + echo -n ' rwhod'; rwhod +fi + +echo -n ' printer'; lpd + +# $sendmail_flags is imported from /etc/netstart; +# If $sendmail_flags == NO or /etc/sendmail.cf doesn't exist, then +# sendmail isn't run. +if [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then + echo -n ' sendmail'; sendmail ${sendmail_flags} +fi + +echo -n ' inetd'; inetd + +# $rarpd_flags is imported from /etc/netstart; +# If $rarpd_flags == NO or /etc/ethers doesn't exist, then +# rarpd isn't run. +if [ "X${rarpd_flags}" != X"NO" -a -r /etc/ethers ]; then + echo -n ' rarpd'; rarpd ${rarpd_flags} +fi + +# $bootparamd_flags is imported from /etc/netstart; +# If $bootparamd_flags == NO or /etc/bootparams doesn't exist, then +# bootparamd isn't run. +if [ "X${bootparamd_flags}" != X"NO" -a -r /etc/bootparams ]; then + echo -n ' rpc.bootparamd'; rpc.bootparamd ${bootparamd_flags} +fi + +# $rbootd_flags is imported from /etc/netstart; +# If $rbootd_flags == NO or /etc/rbootd.conf doesn't exist, then +# rbootd isn't run. +if [ "X${rbootd_flags}" != X"NO" -a -r /etc/rbootd.conf ]; then + echo -n ' rbootd'; rbootd ${rbootd_flags} +fi + +echo '.' + +. /etc/rc.local + +date +exit 0 diff --git a/src/etc/rc.local b/src/etc/rc.local new file mode 100644 index 00000000..b3054228 --- /dev/null +++ b/src/etc/rc.local @@ -0,0 +1,31 @@ +# +# site-specific startup actions, daemons +# +# From: @(#)rc.local 5.4 (Berkeley) 12/14/90 +# $Id: rc.local,v 1.1.1.1 1995/10/18 08:37:57 deraadt Exp $ +# + +if [ ! -f /etc/motd ]; then + install -c -o root -g wheel -m 664 /dev/null /etc/motd +fi +T=/tmp/_motd +rm -f $T +sysctl -n kern.version | sed 1q > $T +echo "" >> $T +sed '1,/^$/d' < /etc/motd >> $T +cmp -s $T /etc/motd || cp $T /etc/motd +rm -f $T + +if [ -f /sbin/ldconfig ]; then + echo 'creating runtime link editor directory cache.' + ldconfig +fi + +echo -n 'starting local daemons:' + +# Kerberos runs ONLY on the Kerberos server machine +if [ X${kerberos_server} = X"YES" ]; then + echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & +fi + +echo '.' diff --git a/src/etc/remote b/src/etc/remote new file mode 100644 index 00000000..37d3ffd8 --- /dev/null +++ b/src/etc/remote @@ -0,0 +1,35 @@ +# @(#)remote 5.2 (Berkeley) 6/30/90 +# +# remote -- remote host description file +# see tip(1), remote(5) +# +# dv device to use for the tty +# el EOL marks (default is NULL) +# du make a call flag (dial up) +# pn phone numbers (@ =>'s search phones file; possibly taken from +# PHONES environment variable) +# at ACU type +# ie input EOF marks (default is NULL) +# oe output EOF string (default is NULL) +# cu call unit (default is dv) +# br baud rate (defaults to 300) +# fs frame size (default is BUFSIZ) -- used in buffering writes on +# receive operations +# tc to continue a capability + +# UNIX system definitions +unix1200|1200 Baud dial-out to another UNIX system:\ + :el=^U^C^R^O^D^S^Q:ie=%$:oe=^D:tc=dial1200: +unix300|300 Baud dial-out to another UNIX system:\ + :el=^U^C^R^O^D^S^Q:ie=%$:oe=^D:tc=dial300: + +# General dialer definitions used below +# +dial2400|2400 Baud Hayes attributes:\ + :dv=/dev/tty00:br#2400:cu=/dev/tty00:at=hayes:du: +dial1200|1200 Baud Hayes attributes:\ + :dv=/dev/tty00:br#1200:cu=/dev/tty00:at=hayes:du: + +# Hardwired line +com0c|com0:dv=/dev/tty00:br#9600: +com0b:dv=/dev/tty00:br#2400: diff --git a/src/etc/root/dot.cshrc b/src/etc/root/dot.cshrc new file mode 100644 index 00000000..b8c28f2c --- /dev/null +++ b/src/etc/root/dot.cshrc @@ -0,0 +1,26 @@ +alias mail Mail +set history=1000 +set path=(/sbin /usr/sbin /bin /usr/bin) + +# directory stuff: cdpath/cd/back +set cdpath=(/sys /usr/src/{bin,sbin,usr.{bin,sbin},pgrm,lib,libexec,share,contrib,local,devel,games,old,}) + +setenv BLOCKSIZE 1k + +alias cd 'set old=$cwd; chdir \!*' +alias h history +alias j jobs -l +alias ll ls -l +alias back 'set back=$old; set old=$cwd; cd $back; unset back; dirs' + +alias z suspend +alias x exit +alias pd pushd +alias pd2 pushd +2 +alias pd3 pushd +3 +alias pd4 pushd +4 +alias tset 'set noglob histchars=""; eval `\tset -s \!*`; unset noglob histchars' + +if ($?prompt) then + set prompt="`hostname -s`# " +endif diff --git a/src/etc/root/dot.klogin b/src/etc/root/dot.klogin new file mode 100644 index 00000000..8de6b57c --- /dev/null +++ b/src/etc/root/dot.klogin @@ -0,0 +1,2 @@ +user1.root@your.realm.wherever +user2.root@your.realm.wherever diff --git a/src/etc/root/dot.login b/src/etc/root/dot.login new file mode 100644 index 00000000..da3c3734 --- /dev/null +++ b/src/etc/root/dot.login @@ -0,0 +1,2 @@ +tset -Q \?$TERM +echo "Don't login as root, use su" diff --git a/src/etc/root/dot.profile b/src/etc/root/dot.profile new file mode 100644 index 00000000..0482fb0e --- /dev/null +++ b/src/etc/root/dot.profile @@ -0,0 +1,8 @@ +PATH=/sbin:/usr/sbin:/bin:/usr/bin +export PATH +HOME=/root +export HOME + +if [ -x /usr/bin/tset ]; then + eval `/usr/bin/tset -sQ \?$TERM` +fi diff --git a/src/etc/rpc b/src/etc/rpc new file mode 100644 index 00000000..1c18f9eb --- /dev/null +++ b/src/etc/rpc @@ -0,0 +1,35 @@ +# +# rpc 88/08/01 4.0 RPCSRC; from 1.12 88/02/07 SMI +# +portmapper 100000 portmap sunrpc +rstatd 100001 rstat rstat_svc rup perfmeter +rusersd 100002 rusers +nfs 100003 nfsprog +ypserv 100004 ypprog +mountd 100005 mount showmount +ypbind 100007 +walld 100008 rwall shutdown +yppasswdd 100009 yppasswd +etherstatd 100010 etherstat +rquotad 100011 rquotaprog quota rquota +sprayd 100012 spray +3270_mapper 100013 +rje_mapper 100014 +selection_svc 100015 selnsvc +database_svc 100016 +rexd 100017 rex +alis 100018 +sched 100019 +llockmgr 100020 +nlockmgr 100021 +x25.inr 100022 +statmon 100023 +status 100024 +bootparam 100026 +ypupdated 100028 ypupdate +keyserv 100029 keyserver +tfsd 100037 +nsed 100038 +nsemntd 100039 +pcnfsd 150001 pcnfs +amd 300019 amq diff --git a/src/etc/security b/src/etc/security new file mode 100644 index 00000000..de02d8ab --- /dev/null +++ b/src/etc/security @@ -0,0 +1,536 @@ +#!/bin/sh - +# +# from: @(#)security 8.1 (Berkeley) 6/9/93 +# $Id: security,v 1.1.1.1 1995/10/18 08:37:57 deraadt Exp $ +# + +PATH=/sbin:/usr/sbin:/bin:/usr/bin + +umask 077 + +ERR=/tmp/_secure1.$$ +TMP1=/tmp/_secure2.$$ +TMP2=/tmp/_secure3.$$ +TMP3=/tmp/_secure4.$$ +LIST=/tmp/_secure5.$$ +OUTPUT=/tmp/_secure6.$$ + +trap 'rm -f $ERR $TMP1 $TMP2 $TMP3 $LIST $OUTPUT' 0 + +# Check the master password file syntax. +MP=/etc/master.passwd +awk -F: '{ + if ($0 ~ /^[ ]*$/) { + printf("Line %d is a blank line.\n", NR); + next; + } + if (NF != 10) + printf("Line %d has the wrong number of fields.\n", NR); + if ($1 !~ /^[A-Za-z0-9]*$/) + printf("Login %s has non-alphanumeric characters.\n", $1); + if (length($1) > 8) + printf("Login %s has more than 8 characters.\n", $1); + if ($2 == "") + printf("Login %s has no password.\n", $1); + if (length($2) != 13 && ($10 ~ /.*sh$/ || $10 == "")) + printf("Login %s is off but still has a valid shell.\n", $1); + if ($3 == 0 && $1 != "root" && $1 != "toor") + printf("Login %s has a user id of 0.\n", $1); + if ($3 < 0) + printf("Login %s has a negative user id.\n", $1); + if ($4 < 0) + printf("Login %s has a negative group id.\n", $1); +}' < $MP > $OUTPUT +if [ -s $OUTPUT ] ; then + printf "\nChecking the $MP file:\n" + cat $OUTPUT +fi + +awk -F: '{ print $1 }' $MP | sort | uniq -d > $OUTPUT +if [ -s $OUTPUT ] ; then + printf "\n$MP has duplicate user names.\n" + column $OUTPUT +fi + +awk -F: '{ print $1 " " $3 }' $MP | sort -n +1 | tee $TMP1 | +uniq -d -f 1 | awk '{ print $2 }' > $TMP2 +if [ -s $TMP2 ] ; then + printf "\n$MP has duplicate user id's.\n" + while read uid; do + grep -w $uid $TMP1 + done < $TMP2 | column +fi + +# Backup the master password file; a special case, the normal backup +# mechanisms also print out file differences and we don't want to do +# that because this file has encrypted passwords in it. +CUR=/var/backups/`basename $MP`.current +BACK=/var/backups/`basename $MP`.backup +if [ -s $CUR ] ; then + if cmp -s $CUR $MP; then + : + else + cp -p $CUR $BACK + cp -p $MP $CUR + chown root.wheel $CUR + fi +else + cp -p $MP $CUR + chown root.wheel $CUR +fi + +# Check the group file syntax. +GRP=/etc/group +awk -F: '{ + if ($0 ~ /^[ ]*$/) { + printf("Line %d is a blank line.\n", NR); + next; + } + if (NF != 4) + printf("Line %d has the wrong number of fields.\n", NR); + if ($1 !~ /^[A-za-z0-9]*$/) + printf("Group %s has non-alphanumeric characters.\n", $1); + if (length($1) > 8) + printf("Group %s has more than 8 characters.\n", $1); + if ($3 !~ /[0-9]*/) + printf("Login %s has a negative group id.\n", $1); +}' < $GRP > $OUTPUT +if [ -s $OUTPUT ] ; then + printf "\nChecking the $GRP file:\n" + cat $OUTPUT +fi + +awk -F: '{ print $1 }' $GRP | sort | uniq -d > $OUTPUT +if [ -s $OUTPUT ] ; then + printf "\n$GRP has duplicate group names.\n" + column $OUTPUT +fi + +# Check for root paths, umask values in startup files. +# The check for the root paths is problematical -- it's likely to fail +# in other environments. Once the shells have been modified to warn +# of '.' in the path, the path tests should go away. +> $OUTPUT +rhome=/root +umaskset=no +list="/etc/csh.cshrc /etc/csh.login ${rhome}/.cshrc ${rhome}/.login" +for i in $list ; do + if [ -f $i ] ; then + if egrep umask $i > /dev/null ; then + umaskset=yes + fi + egrep umask $i | + awk '$2 % 100 < 20 \ + { print "Root umask is group writeable" } + $2 % 10 < 2 \ + { print "Root umask is other writeable" }' >> $OUTPUT + /bin/csh -f -s << end-of-csh > /dev/null 2>&1 + unset path + source $i + /bin/ls -ldgT \$path > $TMP1 +end-of-csh + awk '{ + if ($10 ~ /^\.$/) { + print "The root path includes ."; + next; + } + } + $1 ~ /^d....w/ \ + { print "Root path directory " $10 " is group writeable." } \ + $1 ~ /^d.......w/ \ + { print "Root path directory " $10 " is other writeable." }' \ + < $TMP1 >> $OUTPUT + fi +done +if [ $umaskset = "no" -o -s $OUTPUT ] ; then + printf "\nChecking root csh paths, umask values:\n$list\n" + if [ -s $OUTPUT ]; then + cat $OUTPUT + fi + if [ $umaskset = "no" ] ; then + printf "\nRoot csh startup files do not set the umask.\n" + fi +fi + +> $OUTPUT +rhome=/root +umaskset=no +list="${rhome}/.profile" +for i in $list; do + if [ -f $i ] ; then + if egrep umask $i > /dev/null ; then + umaskset=yes + fi + egrep umask $i | + awk '$2 % 100 < 20 \ + { print "Root umask is group writeable" } \ + $2 % 10 < 2 \ + { print "Root umask is other writeable" }' >> $OUTPUT + /bin/sh << end-of-sh > /dev/null 2>&1 + PATH= + . $i + list=\`echo \$PATH | /usr/bin/sed -e 's/:/ /g'\` + /bin/ls -ldgT \$list > $TMP1 +end-of-sh + awk '{ + if ($10 ~ /^\.$/) { + print "The root path includes ."; + next; + } + } + $1 ~ /^d....w/ \ + { print "Root path directory " $10 " is group writeable." } \ + $1 ~ /^d.......w/ \ + { print "Root path directory " $10 " is other writeable." }' \ + < $TMP1 >> $OUTPUT + + fi +done +if [ $umaskset = "no" -o -s $OUTPUT ] ; then + printf "\nChecking root sh paths, umask values:\n$list\n" + if [ -s $OUTPUT ]; then + cat $OUTPUT + fi + if [ $umaskset = "no" ] ; then + printf "\nRoot sh startup files do not set the umask.\n" + fi +fi + +# Root and uucp should both be in /etc/ftpusers. +if egrep root /etc/ftpusers > /dev/null ; then + : +else + printf "\nRoot not listed in /etc/ftpusers file.\n" +fi +if egrep uucp /etc/ftpusers > /dev/null ; then + : +else + printf "\nUucp not listed in /etc/ftpusers file.\n" +fi + +# Uudecode should not be in the /etc/aliases file. +if egrep 'uudecode|decode' /etc/aliases; then + printf "\nThere is an entry for uudecode in the /etc/aliases file.\n" +fi + +# Files that should not have + signs. +list="/etc/hosts.equiv /etc/hosts.lpd" +for f in $list ; do + if egrep '\+' $f > /dev/null ; then + printf "\nPlus sign in $f file.\n" + fi +done + +# Check for special users with .rhosts files. Only root and toor should +# have a .rhosts files. Also, .rhosts files should not plus signs. +awk -F: '$1 != "root" && $1 != "toor" && \ + ($3 < 100 || $1 == "ftp" || $1 == "uucp") \ + { print $1 " " $6 }' /etc/passwd | +while read uid homedir; do + if [ -f ${homedir}/.rhosts ] ; then + rhost=`ls -ldgT ${homedir}/.rhosts` + printf "$uid: $rhost\n" + fi +done > $OUTPUT +if [ -s $OUTPUT ] ; then + printf "\nChecking for special users with .rhosts files.\n" + cat $OUTPUT +fi + +awk -F: '{ print $1 " " $6 }' /etc/passwd | \ +while read uid homedir; do + if [ -f ${homedir}/.rhosts ] && \ + egrep '\+' ${homedir}/.rhosts > /dev/null ; then + printf "$uid: + in .rhosts file.\n" + fi +done > $OUTPUT +if [ -s $OUTPUT ] ; then + printf "\nChecking .rhosts files syntax.\n" + cat $OUTPUT +fi + +# Check home directories. Directories should not be owned by someone else +# or writeable. +awk -F: '{ print $1 " " $6 }' /etc/passwd | \ +while read uid homedir; do + if [ -d ${homedir}/ ] ; then + file=`ls -ldgT ${homedir}` + printf "$uid $file\n" + fi +done | +awk '$1 != $4 && $4 != "root" \ + { print "user " $1 " home directory is owned by " $4 } + $2 ~ /^-....w/ \ + { print "user " $1 " home directory is group writeable" } + $2 ~ /^-.......w/ \ + { print "user " $1 " home directory is other writeable" }' > $OUTPUT +if [ -s $OUTPUT ] ; then + printf "\nChecking home directories.\n" + cat $OUTPUT +fi + +# Files that should not be owned by someone else or readable. +list=".netrc .rhosts" +awk -F: '{ print $1 " " $6 }' /etc/passwd | \ +while read uid homedir; do + for f in $list ; do + file=${homedir}/${f} + if [ -f $file ] ; then + printf "$uid $f `ls -ldgT $file`\n" + fi + done +done | +awk '$1 != $5 && $5 != "root" \ + { print "user " $1 " " $2 " file is owned by " $5 } + $3 ~ /^-...r/ \ + { print "user " $1 " " $2 " file is group readable" } + $3 ~ /^-......r/ \ + { print "user " $1 " " $2 " file is other readable" } + $3 ~ /^-....w/ \ + { print "user " $1 " " $2 " file is group writeable" } + $3 ~ /^-.......w/ \ + { print "user " $1 " " $2 " file is other writeable" }' > $OUTPUT + +# Files that should not be owned by someone else or writeable. +list=".bashrc .cshrc .emacs .exrc .forward .klogin .login .logout \ + .profile .tcshrc" +awk -F: '{ print $1 " " $6 }' /etc/passwd | \ +while read uid homedir; do + for f in $list ; do + file=${homedir}/${f} + if [ -f $file ] ; then + printf "$uid $f `ls -ldgT $file`\n" + fi + done +done | +awk '$1 != $5 && $5 != "root" \ + { print "user " $1 " " $2 " file is owned by " $5 } + $3 ~ /^-....w/ \ + { print "user " $1 " " $2 " file is group writeable" } + $3 ~ /^-.......w/ \ + { print "user " $1 " " $2 " file is other writeable" }' >> $OUTPUT +if [ -s $OUTPUT ] ; then + printf "\nChecking dot files.\n" + cat $OUTPUT +fi + +# Mailboxes should be owned by user and unreadable. +ls -l /var/mail | sed 1d | \ +awk '$3 != $9 \ + { print "user " $9 " mailbox is owned by " $3 } + $1 != "-rw-------" \ + { print "user " $9 " mailbox is " $1 ", group " $4 }' > $OUTPUT +if [ -s $OUTPUT ] ; then + printf "\nChecking mailbox ownership.\n" + cat $OUTPUT +fi + +# File systems should not be globally exported. +awk '{ + readonly = 0; + for (i = 2; i <= NF; ++i) { + if ($i ~ /-ro/) + readonly = 1; + else if ($i !~ /^-/) + next; + } + if (readonly) + print "File system " $1 " globally exported, read-only." + else + print "File system " $1 " globally exported, read-write." +}' < /etc/exports > $OUTPUT +if [ -s $OUTPUT ] ; then + printf "\nChecking for globally exported file systems.\n" + cat $OUTPUT +fi + +# Display any changes in setuid files and devices. +printf "\nChecking setuid files and devices:\n" +(find / \( ! -fstype local -o -fstype fdesc -o -fstype kernfs \ + -o -fstype procfs \) -a -prune -o \ + \( -perm -u+s -o -perm -g+s -o ! -type d -a ! -type f -a ! -type l -a \ + ! -type s \) | \ +sort | sed -e 's/^/ls -ldgT /' | sh > $LIST) 2> $OUTPUT + +# Display any errors that occurred during system file walk. +if [ -s $OUTPUT ] ; then + printf "Setuid/device find errors:\n" + cat $OUTPUT + printf "\n" +fi + +# Display any changes in the setuid file list. +egrep -v '^[bc]' $LIST > $TMP1 +if [ -s $TMP1 ] ; then + # Check to make sure uudecode isn't setuid. + if grep -w uudecode $TMP1 > /dev/null ; then + printf "\nUudecode is setuid.\n" + fi + + CUR=/var/backups/setuid.current + BACK=/var/backups/setuid.backup + + if [ -s $CUR ] ; then + if cmp -s $CUR $TMP1 ; then + : + else + > $TMP2 + join -110 -210 -v2 $CUR $TMP1 > $OUTPUT + if [ -s $OUTPUT ] ; then + printf "Setuid additions:\n" + tee -a $TMP2 < $OUTPUT + printf "\n" + fi + + join -110 -210 -v1 $CUR $TMP1 > $OUTPUT + if [ -s $OUTPUT ] ; then + printf "Setuid deletions:\n" + tee -a $TMP2 < $OUTPUT + printf "\n" + fi + + sort +9 $TMP2 $CUR $TMP1 | \ + sed -e 's/[ ][ ]*/ /g' | uniq -u > $OUTPUT + if [ -s $OUTPUT ] ; then + printf "Setuid changes:\n" + column -t $OUTPUT + printf "\n" + fi + + cp $CUR $BACK + cp $TMP1 $CUR + fi + else + printf "Setuid additions:\n" + column -t $TMP1 + printf "\n" + cp $TMP1 $CUR + fi +fi + +# Check for block and character disk devices that are readable or writeable +# or not owned by root.operator. +>$TMP1 +DISKLIST="dk fd hd hk hp jb kra ra rb rd rl rx rz sd up wd" +for i in $DISKLIST; do + egrep "^b.*/${i}[0-9][0-9]*[a-h]$" $LIST >> $TMP1 + egrep "^c.*/r${i}[0-9][0-9]*[a-h]$" $LIST >> $TMP1 +done + +awk '$3 != "root" || $4 != "operator" || $1 !~ /.rw-r-----/ \ + { printf("Disk %s is user %s, group %s, permissions %s.\n", \ + $11, $3, $4, $1); }' < $TMP1 > $OUTPUT +if [ -s $OUTPUT ] ; then + printf "\nChecking disk ownership and permissions.\n" + cat $OUTPUT + printf "\n" +fi + +# Display any changes in the device file list. +egrep '^[bc]' $LIST | sort +10 > $TMP1 +if [ -s $TMP1 ] ; then + CUR=/var/backups/device.current + BACK=/var/backups/device.backup + + if [ -s $CUR ] ; then + if cmp -s $CUR $TMP1 ; then + : + else + > $TMP2 + join -111 -211 -v2 $CUR $TMP1 > $OUTPUT + if [ -s $OUTPUT ] ; then + printf "Device additions:\n" + tee -a $TMP2 < $OUTPUT + printf "\n" + fi + + join -111 -211 -v1 $CUR $TMP1 > $OUTPUT + if [ -s $OUTPUT ] ; then + printf "Device deletions:\n" + tee -a $TMP2 < $OUTPUT + printf "\n" + fi + + # Report any block device change. Ignore character + # devices, only the name is significant. + cat $TMP2 $CUR $TMP1 | \ + sed -e '/^c/d' | \ + sort +10 | \ + sed -e 's/[ ][ ]*/ /g' | \ + uniq -u > $OUTPUT + if [ -s $OUTPUT ] ; then + printf "Block device changes:\n" + column -t $OUTPUT + printf "\n" + fi + + cp $CUR $BACK + cp $TMP1 $CUR + fi + else + printf "Device additions:\n" + column -t $TMP1 + printf "\n" + cp $TMP1 $CUR + fi +fi + +# Check special files. +# Check system binaries. +# +# Create the mtree tree specifications using: +# +# mtree -cx -pDIR -kcksum,gid,mode,nlink,size,link,time,uid > DIR.secure +# chown root.wheel DIR.SECURE +# chmod 600 DIR.SECURE +# +# Note, this is not complete protection against Trojan horsed binaries, as +# the hacker can modify the tree specification to match the replaced binary. +# For details on really protecting yourself against modified binaries, see +# the mtree(8) manual page. +if cd /etc/mtree; then + mtree -e -p / -f /etc/mtree/special > $OUTPUT + if [ -s $OUTPUT ] ; then + printf "\nChecking special files and directories.\n" + cat $OUTPUT + fi + + > $OUTPUT + for file in *.secure; do + tree=`sed -n -e '3s/.* //p' -e 3q $file` + mtree -f $file -p $tree > $TMP1 + if [ -s $TMP1 ]; then + printf "\nChecking $tree:\n" >> $OUTPUT + cat $TMP1 >> $OUTPUT + fi + done + if [ -s $OUTPUT ] ; then + printf "\nChecking system binaries:\n" + cat $OUTPUT + fi +fi + +# List of files that get backed up and checked for any modifications. Each +# file is expected to have two backups, /var/backups/file.{current,backup}. +# Any changes cause the files to rotate. +if [ -s /etc/changelist ] ; then + for file in `cat /etc/changelist`; do + CUR=/var/backups/`basename $file`.current + BACK=/var/backups/`basename $file`.backup + if [ -s $file ]; then + if [ -s $CUR ] ; then + diff $CUR $file > $OUTPUT + if [ -s $OUTPUT ] ; then + printf "\n======\n%s diffs (OLD < > NEW)\n======\n" $file + cat $OUTPUT + cp -p $CUR $BACK + cp -p $file $CUR + chown root.wheel $CUR $BACK + fi + else + cp -p $file $CUR + chown root.wheel $CUR + fi + fi + done +fi diff --git a/src/etc/services b/src/etc/services new file mode 100644 index 00000000..1e763741 --- /dev/null +++ b/src/etc/services @@ -0,0 +1,181 @@ +# +# Network services, Internet style +# +# Note that it is presently the policy of IANA to assign a single well-known +# port number for both TCP and UDP; hence, most entries here have two entries +# even if the protocol doesn't support UDP operations. +# Updated from RFC 1340, ``Assigned Numbers'' (July 1992). Not all ports +# are included, only the more common ones. +# +# from: @(#)services 5.8 (Berkeley) 5/9/91 +# $Id: services,v 1.1.1.1 1995/10/18 08:37:57 deraadt Exp $ +# +tcpmux 1/tcp # TCP port service multiplexer +echo 7/tcp +echo 7/udp +discard 9/tcp sink null +discard 9/udp sink null +systat 11/tcp users +daytime 13/tcp +daytime 13/udp +netstat 15/tcp +qotd 17/tcp quote +msp 18/tcp # message send protocol +msp 18/udp # message send protocol +chargen 19/tcp ttytst source +chargen 19/udp ttytst source +ftp-data 20/tcp # default ftp data port +ftp 21/tcp +# 22 - unassigned +telnet 23/tcp +# 24 - private +smtp 25/tcp mail +# 26 - unassigned +time 37/tcp timserver +time 37/udp timserver +rlp 39/udp resource # resource location +nameserver 42/tcp name # IEN 116 +whois 43/tcp nicname +domain 53/tcp nameserver # name-domain server +domain 53/udp nameserver +mtp 57/tcp # deprecated +bootps 67/tcp # BOOTP server +bootps 67/udp +bootpc 68/tcp # BOOTP client +bootpc 68/udp +tftp 69/udp +gopher 70/tcp # Internet Gopher +gopher 70/udp +rje 77/tcp netrjs +finger 79/tcp +www 80/tcp http # WorldWideWeb HTTP +www 80/udp # HyperText Transfer Protocol +link 87/tcp ttylink +kerberos 88/tcp krb5 # Kerberos v5 +kerberos 88/udp +supdup 95/tcp +# 100 - reserved +hostnames 101/tcp hostname # usually from sri-nic +iso-tsap 102/tcp tsap # part of ISODE. +csnet-ns 105/tcp cso-ns # also used by CSO name server +csnet-ns 105/udp cso-ns +rtelnet 107/tcp # Remote Telnet +rtelnet 107/udp +pop2 109/tcp postoffice # POP version 2 +pop2 109/udp +pop3 110/tcp # POP version 3 +pop3 110/udp +sunrpc 111/tcp +sunrpc 111/udp +auth 113/tcp authentication tap ident +sftp 115/tcp +uucp-path 117/tcp +nntp 119/tcp readnews untp # USENET News Transfer Protocol +ntp 123/tcp +ntp 123/udp # Network Time Protocol +netbios-ns 137/tcp # NETBIOS Name Service +netbios-ns 137/udp +netbios-dgm 138/tcp # NETBIOS Datagram Service +netbios-dgm 138/udp +netbios-ssn 139/tcp # NETBIOS session service +netbios-ssn 139/udp +imap2 143/tcp # Interim Mail Access Proto v2 +imap2 143/udp +snmp 161/udp # Simple Net Mgmt Proto +snmp-trap 162/udp snmptrap # Traps for SNMP +cmip-man 163/tcp # ISO mgmt over IP (CMOT) +cmip-man 163/udp +cmip-agent 164/tcp +cmip-agent 164/udp +xdmcp 177/tcp # X Display Mgr. Control Proto +xdmcp 177/udp +nextstep 178/tcp NeXTStep NextStep # NeXTStep window +nextstep 178/udp NeXTStep NextStep # server +bgp 179/tcp # Border Gateway Proto. +bgp 179/udp +prospero 191/tcp # Cliff Neuman's Prospero +prospero 191/udp +irc 194/tcp # Internet Relay Chat +irc 194/udp +smux 199/tcp # SNMP Unix Multiplexer +smux 199/udp +at-rtmp 201/tcp # AppleTalk routing +at-rtmp 201/udp +at-nbp 202/tcp # AppleTalk name binding +at-nbp 202/udp +at-echo 204/tcp # AppleTalk echo +at-echo 204/udp +at-zis 206/tcp # AppleTalk zone information +at-zis 206/udp +z3950 210/tcp wais # NISO Z39.50 database +z3950 210/udp wais +ipx 213/tcp # IPX +ipx 213/udp +imap3 220/tcp # Interactive Mail Access +imap3 220/udp # Protocol v3 +ulistserv 372/tcp # UNIX Listserv +ulistserv 372/udp +# +# UNIX specific services +# +exec 512/tcp +biff 512/udp comsat +login 513/tcp +who 513/udp whod +shell 514/tcp cmd # no passwords used +syslog 514/udp +printer 515/tcp spooler # line printer spooler +talk 517/udp +ntalk 518/udp +route 520/udp router routed # RIP +timed 525/udp timeserver +tempo 526/tcp newdate +courier 530/tcp rpc +conference 531/tcp chat +netnews 532/tcp readnews +netwall 533/udp # -for emergency broadcasts +uucp 540/tcp uucpd # uucp daemon +remotefs 556/tcp rfs_server rfs # Brunhoff remote filesystem +# +webster 765/tcp # Network dictionary +webster 765/udp +# +# From ``Assigned Numbers'': +# +#> The Registered Ports are not controlled by the IANA and on most systems +#> can be used by ordinary user processes or programs executed by ordinary +#> users. +# +#> Ports are used in the TCP [45,106] to name the ends of logical +#> connections which carry long term conversations. For the purpose of +#> providing services to unknown callers, a service contact port is +#> defined. This list specifies the port used by the server process as its +#> contact port. While the IANA can not control uses of these ports it +#> does register or list uses of these ports as a convienence to the +#> community. +# +ingreslock 1524/tcp +ingreslock 1524/udp +prospero-np 1525/tcp # Prospero non-privileged +prospero-np 1525/udp +rfe 5002/tcp # Radio Free Ethernet +rfe 5002/udp # Actually uses UDP only +# +# +# Kerberos (Project Athena/MIT) services +# Note that these are for Kerberos v4, and are unofficial. Sites running +# v4 should uncomment these and comment out the v5 entries above. +# +klogin 543/tcp # Kerberos `rlogin' +kshell 544/tcp krcmd # Kerberos `rsh' +kerberos-adm 749/tcp # Kerberos `kadmin' (v5) +#kerberos 750/udp kdc # Kerberos (server) udp +#kerberos 750/tcp kdc # Kerberos (server) tcp +krbupdate 760/tcp kreg # Kerberos registration +kpasswd 761/tcp kpwd # Kerberos `passwd' +eklogin 2105/tcp # Kerberos encrypted `rlogin' +# +# Unofficial but necessary (for NetBSD) services +# +supfilesrv 871/tcp # SUP server +supfiledbg 1127/tcp # SUP debugging diff --git a/src/etc/shells b/src/etc/shells new file mode 100644 index 00000000..df377f13 --- /dev/null +++ b/src/etc/shells @@ -0,0 +1,6 @@ +# List of acceptable shells for chpass(1). +# Ftpd will not allow users to connect who are not using +# one of these shells. + +/bin/sh +/bin/csh diff --git a/src/etc/syslog.conf b/src/etc/syslog.conf new file mode 100644 index 00000000..ce1df975 --- /dev/null +++ b/src/etc/syslog.conf @@ -0,0 +1,9 @@ +*.err;kern.debug;auth.notice;mail.crit /dev/console +*.notice;kern.debug;lpr,auth.info;mail.crit /var/log/messages +mail.info /var/log/maillog +lpr.info /var/log/lpd-errs +cron.info /var/cron/log +*.err root +*.notice;auth.debug root +*.alert root +*.emerg * diff --git a/src/etc/weekly b/src/etc/weekly new file mode 100644 index 00000000..c60679e8 --- /dev/null +++ b/src/etc/weekly @@ -0,0 +1,57 @@ +#!/bin/sh - +# +# @(#)weekly 5.14 (Berkeley) 6/23/91 +# + +PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/libexec +export PATH + +host=`hostname -s` +echo "Subject: $host weekly run output" + +#echo "" +#echo "Removing old .o files:" +#find /usr/src -name '*.o' -atime +21 -print -a -exec rm -f {} \; + +# see if /usr/src exists and is local +# before looking there for checked-out files + +#if [ -d /usr/src -a \ +# X"`find -f /usr/src ! -fstype local -prune -or -type d -print -prune`" != X ]; +#then +# echo "looking for checked out files:" +# TDIR=/tmp/_checkout$$ +# +# mkdir $TDIR +# for file in `find -f /usr/src ! -fstype local -prune -or \ +# -name 'p.*' -print | egrep 'SCCS/p\.'`; do +# owner=`awk '{ print $3 }' $file` +# echo "$owner $file" +# echo $file >> $TDIR/$owner +# done | sed -e 's,SCCS/p.,,' +# for file in $TDIR/*; do +# sed -e 's,SCCS/p.,,' $file | \ +# Mail -s 'checked out files' `basename $file` +# done +# rm -rf $TDIR +#fi + +if [ -f /usr/lib/uucp/clean.weekly ]; then + echo "" + echo "Cleaning up UUCP:" + echo /usr/lib/uucp/clean.weekly | su daemon +fi +echo "" + +# Rotation of message log now handled automatically by cron and 'newsyslog' + +echo "" +if [ -f /var/db/locate.database ]; then + echo "Rebuilding locate database:" + chmod 644 /var/db/locate.database + chown nobody.nobody /var/db/locate.database + echo /usr/libexec/locate.updatedb | nice -5 su -m nobody 2>/dev/null + chown root.wheel /var/db/locate.database +else + echo "Not rebuilding locate database; no /var/db/locate.database" +fi diff --git a/src/include/Makefile b/src/include/Makefile new file mode 100644 index 00000000..77f7d87e --- /dev/null +++ b/src/include/Makefile @@ -0,0 +1,114 @@ +# $NetBSD: Makefile,v 1.55 1995/06/05 00:24:55 pk Exp $ + +# @(#)Makefile 5.45.1.1 (Berkeley) 5/6/91 + +# Doing a make install builds /usr/include +# +# The ``rm -rf''s used below are safe because rm doesn't follow symbolic +# links. + +# Missing: mp.h + +FILES= a.out.h ar.h assert.h bitstring.h bm.h ctype.h db.h dirent.h disktab.h \ + dlfcn.h err.h fnmatch.h fstab.h fts.h glob.h grp.h ieeefp.h iso646.h \ + kvm.h langinfo.h limits.h link.h locale.h malloc.h math.h memory.h \ + mpool.h ndbm.h netdb.h netgroup.h nlist.h nl_types.h paths.h pwd.h \ + ranlib.h regex.h regexp.h resolv.h search.h setjmp.h sgtty.h signal.h \ + stab.h stddef.h stdio.h stdlib.h string.h strings.h struct.h \ + sysexits.h time.h ttyent.h tzfile.h unistd.h utime.h utmp.h vis.h + +MFILES= float.h frame.h stdarg.h varargs.h +LFILES= errno.h fcntl.h syslog.h termios.h + +DIRS= arpa protocols rpc rpcsvc +LDIRS= dev net netinet netccitt netiso netns nfs sys ufs vm + +NOOBJ= noobj + +# Change SYS_INCLUDE in bsd.own.mk to "symlinks" if you don't want copies +.include <bsd.own.mk> +SYS_INCLUDE?= copies + +realinstall: + @echo installing ${FILES} + @-for i in ${FILES}; do \ + cmp -s $$i ${DESTDIR}/usr/include/$$i || \ + install -c -m 444 $$i ${DESTDIR}/usr/include/$$i; \ + done + @echo installing ${DIRS} + @-for i in ${DIRS}; do \ + install -d -o ${BINOWN} -g ${BINGRP} -m 755 \ + ${DESTDIR}/usr/include/$$i; \ + (cd $$i; for j in *.[ih]; do \ + cmp -s $$j ${DESTDIR}/usr/include/$$i/$$j || \ + install -c -m 444 $$j ${DESTDIR}/usr/include/$$i/$$j; \ + done); \ + done + @echo installing ${LFILES} + @-for i in ${LFILES}; do \ + rm -f ${DESTDIR}/usr/include/$$i; \ + ln -s sys/$$i ${DESTDIR}/usr/include/$$i; \ + done + @echo installing ${MFILES} + @-for i in ${MFILES}; do \ + rm -f ${DESTDIR}/usr/include/$$i; \ + ln -s machine/$$i ${DESTDIR}/usr/include/$$i; \ + done + chown -R ${BINOWN}:${BINGRP} ${DESTDIR}/usr/include + find ${DESTDIR}/usr/include -type f | \ + xargs chmod a=r + find ${DESTDIR}/usr/include -type d | \ + xargs chmod u=rwx,go=rx + +beforeinstall: + install -d -o ${BINOWN} -g ${BINGRP} -m 755 ${DESTDIR}/usr/include + +copies: + @echo copies: ${LDIRS} + @-for i in ${LDIRS}; do \ + rm -rf ${DESTDIR}/usr/include/$$i; \ + install -d -o ${BINOWN} -g ${BINGRP} -m 755 \ + ${DESTDIR}/usr/include/$$i ; \ + done + cd ../sys; \ + pax -rw -pa -L \ + `find ${LDIRS} -follow -type f -name '*.h' '!' -path \ + 'netiso/xebec/*' -print` ${DESTDIR}/usr/include + rm -rf ${DESTDIR}/usr/include/machine + install -d -o ${BINOWN} -g ${BINGRP} -m 755 \ + ${DESTDIR}/usr/include/machine + pax -rw -pa -s "|../sys/arch/${MACHINE}/include||" \ + ../sys/arch/${MACHINE}/include/*.h \ + ${DESTDIR}/usr/include/machine + rm -rf ${DESTDIR}/usr/include/${MACHINE_ARCH} + if test ${MACHINE} != ${MACHINE_ARCH} -a \ + -d ../sys/arch/${MACHINE_ARCH}/include; then \ + install -d -o ${BINOWN} -g ${BINGRP} -m 755 \ + ${DESTDIR}/usr/include/${MACHINE_ARCH}; \ + pax -rw -pa -s "|../sys/arch/${MACHINE_ARCH}/include||" \ + ../sys/arch/${MACHINE_ARCH}/include/*.h \ + ${DESTDIR}/usr/include/${MACHINE_ARCH}; \ + else \ + ln -s machine ${DESTDIR}/usr/include/${MACHINE_ARCH}; \ + fi + +symlinks: + @echo symlinks: ${LDIRS} + @for i in ${LDIRS}; do \ + rm -rf ${DESTDIR}/usr/include/$$i; \ + ln -s /sys/$$i ${DESTDIR}/usr/include/$$i; \ + done + rm -rf ${DESTDIR}/usr/include/machine + ln -s /sys/arch/${MACHINE}/include ${DESTDIR}/usr/include/machine + rm -rf ${DESTDIR}/usr/include/${MACHINE_ARCH} + if test ${MACHINE} != ${MACHINE_ARCH} -a \ + -d ../sys/arch/${MACHINE_ARCH}/include ; then \ + ln -s /sys/arch/${MACHINE_ARCH}/include \ + ${DESTDIR}/usr/include/${MACHINE_ARCH} ; \ + else \ + ln -s machine ${DESTDIR}/usr/include/${MACHINE_ARCH} ; \ + fi + +.include <bsd.prog.mk> + +realinstall: ${SYS_INCLUDE} diff --git a/src/include/a.out.h b/src/include/a.out.h new file mode 100644 index 00000000..b556657c --- /dev/null +++ b/src/include/a.out.h @@ -0,0 +1,47 @@ +/* $NetBSD: a.out.h,v 1.15 1994/10/26 00:55:42 cgd Exp $ */ + +/*- + * Copyright (c) 1993 Theo de Raadt + * Copyright (c) 1991 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)a.out.h 5.6 (Berkeley) 4/30/91 + */ + +#ifndef _AOUT_H_ +#define _AOUT_H_ + +#include <sys/exec.h> + +#define _AOUT_INCLUDE_ +#include <nlist.h> + +#endif /* !_AOUT_H_ */ diff --git a/src/include/ar.h b/src/include/ar.h new file mode 100644 index 00000000..ac2e4ca9 --- /dev/null +++ b/src/include/ar.h @@ -0,0 +1,69 @@ +/* $NetBSD: ar.h,v 1.4 1994/10/26 00:55:43 cgd Exp $ */ + +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * This code is derived from software contributed to Berkeley by + * Hugh Smith at The University of Guelph. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ar.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _AR_H_ +#define _AR_H_ + +/* Pre-4BSD archives had these magic numbers in them. */ +#define OARMAG1 0177555 +#define OARMAG2 0177545 + +#define ARMAG "!<arch>\n" /* ar "magic number" */ +#define SARMAG 8 /* strlen(ARMAG); */ + +#define AR_EFMT1 "#1/" /* extended format #1 */ + +struct ar_hdr { + char ar_name[16]; /* name */ + char ar_date[12]; /* modification time */ + char ar_uid[6]; /* user id */ + char ar_gid[6]; /* group id */ + char ar_mode[8]; /* octal file permissions */ + char ar_size[10]; /* size in bytes */ +#define ARFMAG "`\n" + char ar_fmag[2]; /* consistency check */ +}; + +#endif /* !_AR_H_ */ diff --git a/src/include/arpa/ftp.h b/src/include/arpa/ftp.h new file mode 100644 index 00000000..1fd9010a --- /dev/null +++ b/src/include/arpa/ftp.h @@ -0,0 +1,111 @@ +/* $NetBSD: ftp.h,v 1.3 1994/10/26 00:56:43 cgd Exp $ */ + +/* + * Copyright (c) 1983, 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ftp.h 5.6 (Berkeley) 4/3/91 + */ + +#ifndef _FTP_H_ +#define _FTP_H_ + +/* 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 */ + +#ifdef FTP_NAMES +char *typenames[] = {"0", "ASCII", "EBCDIC", "Image", "Local" }; +#endif + +/* + * Form codes + */ +#define FORM_N 1 /* non-print */ +#define FORM_T 2 /* telnet format effectors */ +#define FORM_C 3 /* carriage control (ASA) */ +#ifdef FTP_NAMES +char *formnames[] = {"0", "Nonprint", "Telnet", "Carriage-control" }; +#endif + +/* + * Structure codes + */ +#define STRU_F 1 /* file (no record structure) */ +#define STRU_R 2 /* record structure */ +#define STRU_P 3 /* page structure */ +#ifdef FTP_NAMES +char *strunames[] = {"0", "File", "Record", "Page" }; +#endif + +/* + * Mode types + */ +#define MODE_S 1 /* stream */ +#define MODE_B 2 /* block */ +#define MODE_C 3 /* compressed */ +#ifdef FTP_NAMES +char *modenames[] = {"0", "Stream", "Block", "Compressed" }; +#endif + +/* + * 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 */ + +#endif /* !_FTP_H_ */ diff --git a/src/include/arpa/inet.h b/src/include/arpa/inet.h new file mode 100644 index 00000000..d84d62a1 --- /dev/null +++ b/src/include/arpa/inet.h @@ -0,0 +1,55 @@ +/* $NetBSD: inet.h,v 1.4 1994/10/26 00:56:44 cgd Exp $ */ + +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)inet.h 5.7 (Berkeley) 4/3/91 + */ + +#ifndef _INET_H_ +#define _INET_H_ + +/* External definitions for functions in inet(3) */ + +#include <sys/cdefs.h> + +__BEGIN_DECLS +unsigned long inet_addr __P((const char *)); +int inet_aton __P((const char *, struct in_addr *)); +unsigned long inet_lnaof __P((struct in_addr)); +struct in_addr inet_makeaddr __P((u_long, u_long)); +unsigned long inet_netof __P((struct in_addr)); +unsigned long inet_network __P((const char *)); +char *inet_ntoa __P((struct in_addr)); +__END_DECLS + +#endif /* !_INET_H_ */ diff --git a/src/include/arpa/nameser.h b/src/include/arpa/nameser.h new file mode 100644 index 00000000..b9db7ba5 --- /dev/null +++ b/src/include/arpa/nameser.h @@ -0,0 +1,248 @@ +/* $NetBSD: nameser.h,v 1.7 1994/10/26 00:56:45 cgd Exp $ */ + +/* + * Copyright (c) 1983, 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)nameser.h 5.25 (Berkeley) 4/3/91 + */ + +#ifndef _NAMESER_H_ +#define _NAMESER_H_ + +#include <machine/endian.h> +#include <sys/cdefs.h> + +/* + * 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 0x0 /* standard query */ +#define IQUERY 0x1 /* inverse query */ +#define STATUS 0x2 /* nameserver status query */ +/*#define xxx 0x3 /* 0x3 reserved */ + /* non standard */ +#define UPDATEA 0x9 /* add resource record */ +#define UPDATED 0xa /* delete a specific resource record */ +#define UPDATEDA 0xb /* delete all named resource record */ +#define UPDATEM 0xc /* modify a specific resource record */ +#define UPDATEMA 0xd /* modify all named resource record */ + +#define ZONEINIT 0xe /* initial zone transfer */ +#define ZONEREF 0xf /* 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 0xf /* 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 */ +#define T_TXT 16 /* text strings */ +#define T_RP 17 /* responsible person */ +#define T_AFSDB 18 /* AFS cell database */ +#define T_NSAP 22 /* NSAP address */ +#define T_NSAP_PTR 23 /* reverse lookup for NSAP */ + /* non standard */ +#define T_UINFO 100 /* user (finger) information */ +#define T_UID 101 /* user ID */ +#define T_GID 102 /* group ID */ +#define T_UNSPEC 103 /* Unspecified format (binary data) */ +#define T_SA 200 /* shuffle address */ + /* 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 */ +#define C_HS 4 /* for Hesiod name server at MIT */ + /* Query class values which do not appear in resource records */ +#define C_ANY 255 /* wildcard match */ + +/* + * Status return codes for T_UNSPEC conversion routines + */ +#define CONV_SUCCESS 0 +#define CONV_OVERFLOW -1 +#define CONV_BADFMT -2 +#define CONV_BADCKSUM -3 +#define CONV_BADBUFLEN -4 + +/* + * 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 BYTE_ORDER == BIG_ENDIAN + /* 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 */ +#endif +#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN + /* 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 */ +#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 { + int16_t r_zone; /* zone number */ + int16_t r_class; /* class number */ + int16_t r_type; /* type number */ + u_int32_t r_ttl; /* time to live */ + int r_size; /* size of data area */ + char *r_data; /* pointer to data */ +}; + +extern u_int16_t _getshort(); +extern u_int32_t _getlong(); + +/* + * Inline versions of get/put short/long. + * Pointer is advanced; we assume that both arguments + * are lvalues and will already be in registers. + * cp MUST be u_char *. + */ +#define GETSHORT(s, cp) { \ + register u_char *t_cp = (u_char *)(cp); \ + (s) = ((u_int16_t)t_cp[0] << 8) \ + | ((u_int16_t)t_cp[1]) ;\ + (cp) += sizeof(u_int16_t); \ +} + +#define GETLONG(l, cp) { \ + register u_char *t_cp = (u_char *)(cp); \ + (l) = ((u_int32_t)t_cp[0] << 24) \ + | ((u_int32_t)t_cp[1] << 16) \ + | ((u_int32_t)t_cp[2] << 8) \ + | ((u_int32_t)t_cp[3]) ;\ + (cp) += sizeof(u_int32_t); \ +} + +#define PUTSHORT(s, cp) { \ + register u_int16_t t_s = (u_int16_t)(s); \ + register u_char *t_cp = (u_char *)(cp); \ + *t_cp++ = t_s >> 8; \ + *t_cp = t_s; \ + (cp) += sizeof(u_int16_t); \ +} + +/* + * Warning: PUTLONG --no-longer-- destroys its first argument. if you + * were depending on this "feature", you will lose. + */ +#define PUTLONG(l, cp) { \ + register u_int32_t t_l = (u_int32_t)(l); \ + register u_char *t_cp = (u_char *)(cp); \ + *t_cp++ = t_l >> 24; \ + *t_cp++ = t_l >> 16; \ + *t_cp++ = t_l >> 8; \ + *t_cp = t_l; \ + (cp) += sizeof(u_int32_t); \ +} + +#endif /* !_NAMESER_H_ */ diff --git a/src/include/arpa/telnet.h b/src/include/arpa/telnet.h new file mode 100644 index 00000000..d19ff3ee --- /dev/null +++ b/src/include/arpa/telnet.h @@ -0,0 +1,322 @@ +/* $NetBSD: telnet.h,v 1.4 1994/10/26 00:56:46 cgd Exp $ */ + +/* + * Copyright (c) 1983, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)telnet.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _TELNET_H_ +#define _TELNET_H_ + +/* + * 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 ABORT 238 /* Abort process */ +#define SUSP 237 /* Suspend process */ +#define xEOF 236 /* End of file: EOF is already used... */ + +#define SYNCH 242 /* for telfunc calls */ + +#ifdef TELCMDS +char *telcmds[] = { + "EOF", "SUSP", "ABORT", "EOR", + "SE", "NOP", "DMARK", "BRK", "IP", "AO", "AYT", "EC", + "EL", "GA", "SB", "WILL", "WONT", "DO", "DONT", "IAC", 0, +}; +#else +extern char *telcmds[]; +#endif + +#define TELCMD_FIRST xEOF +#define TELCMD_LAST IAC +#define TELCMD_OK(x) ((unsigned int)(x) <= TELCMD_LAST && \ + (unsigned int)(x) >= TELCMD_FIRST) +#define TELCMD(x) telcmds[(x)-TELCMD_FIRST] + +/* 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_TUID 26 /* TACACS user identification */ +#define TELOPT_OUTMRK 27 /* output marking */ +#define TELOPT_TTYLOC 28 /* terminal location number */ +#define TELOPT_3270REGIME 29 /* 3270 regime */ +#define TELOPT_X3PAD 30 /* X.3 PAD */ +#define TELOPT_NAWS 31 /* window size */ +#define TELOPT_TSPEED 32 /* terminal speed */ +#define TELOPT_LFLOW 33 /* remote flow control */ +#define TELOPT_LINEMODE 34 /* Linemode option */ +#define TELOPT_XDISPLOC 35 /* X Display Location */ +#define TELOPT_OLD_ENVIRON 36 /* Old - Environment variables */ +#define TELOPT_AUTHENTICATION 37/* Authenticate */ +#define TELOPT_ENCRYPT 38 /* Encryption option */ +#define TELOPT_NEW_ENVIRON 39 /* New - Environment variables */ +#define TELOPT_EXOPL 255 /* extended-options-list */ + + +#define NTELOPTS (1+TELOPT_NEW_ENVIRON) +#ifdef TELOPTS +char *telopts[NTELOPTS+1] = { + "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", + "TACACS UID", "OUTPUT MARKING", "TTYLOC", + "3270 REGIME", "X.3 PAD", "NAWS", "TSPEED", "LFLOW", + "LINEMODE", "XDISPLOC", "OLD-ENVIRON", "AUTHENTICATION", + "ENCRYPT", "NEW-ENVIRON", + 0, +}; +#define TELOPT_FIRST TELOPT_BINARY +#define TELOPT_LAST TELOPT_NEW_ENVIRON +#define TELOPT_OK(x) ((unsigned int)(x) <= TELOPT_LAST) +#define TELOPT(x) telopts[(x)-TELOPT_FIRST] +#endif + +/* sub-option qualifiers */ +#define TELQUAL_IS 0 /* option is... */ +#define TELQUAL_SEND 1 /* send option */ +#define TELQUAL_INFO 2 /* ENVIRON: informational version of IS */ +#define TELQUAL_REPLY 2 /* AUTHENTICATION: client version of IS */ +#define TELQUAL_NAME 3 /* AUTHENTICATION: client version of IS */ + +#define LFLOW_OFF 0 /* Disable remote flow control */ +#define LFLOW_ON 1 /* Enable remote flow control */ +#define LFLOW_RESTART_ANY 2 /* Restart output on any char */ +#define LFLOW_RESTART_XON 3 /* Restart output only on XON */ + +/* + * LINEMODE suboptions + */ + +#define LM_MODE 1 +#define LM_FORWARDMASK 2 +#define LM_SLC 3 + +#define MODE_EDIT 0x01 +#define MODE_TRAPSIG 0x02 +#define MODE_ACK 0x04 +#define MODE_SOFT_TAB 0x08 +#define MODE_LIT_ECHO 0x10 + +#define MODE_MASK 0x1f + +/* Not part of protocol, but needed to simplify things... */ +#define MODE_FLOW 0x0100 +#define MODE_ECHO 0x0200 +#define MODE_INBIN 0x0400 +#define MODE_OUTBIN 0x0800 +#define MODE_FORCE 0x1000 + +#define SLC_SYNCH 1 +#define SLC_BRK 2 +#define SLC_IP 3 +#define SLC_AO 4 +#define SLC_AYT 5 +#define SLC_EOR 6 +#define SLC_ABORT 7 +#define SLC_EOF 8 +#define SLC_SUSP 9 +#define SLC_EC 10 +#define SLC_EL 11 +#define SLC_EW 12 +#define SLC_RP 13 +#define SLC_LNEXT 14 +#define SLC_XON 15 +#define SLC_XOFF 16 +#define SLC_FORW1 17 +#define SLC_FORW2 18 + +#define NSLC 18 + +/* + * For backwards compatability, we define SLC_NAMES to be the + * list of names if SLC_NAMES is not defined. + */ +#define SLC_NAMELIST "0", "SYNCH", "BRK", "IP", "AO", "AYT", "EOR", \ + "ABORT", "EOF", "SUSP", "EC", "EL", "EW", "RP", \ + "LNEXT", "XON", "XOFF", "FORW1", "FORW2", 0, +#ifdef SLC_NAMES +char *slc_names[] = { + SLC_NAMELIST +}; +#else +extern char *slc_names[]; +#define SLC_NAMES SLC_NAMELIST +#endif + +#define SLC_NAME_OK(x) ((unsigned int)(x) <= NSLC) +#define SLC_NAME(x) slc_names[x] + +#define SLC_NOSUPPORT 0 +#define SLC_CANTCHANGE 1 +#define SLC_VARIABLE 2 +#define SLC_DEFAULT 3 +#define SLC_LEVELBITS 0x03 + +#define SLC_FUNC 0 +#define SLC_FLAGS 1 +#define SLC_VALUE 2 + +#define SLC_ACK 0x80 +#define SLC_FLUSHIN 0x40 +#define SLC_FLUSHOUT 0x20 + +#define OLD_ENV_VAR 1 +#define OLD_ENV_VALUE 0 +#define NEW_ENV_VAR 0 +#define NEW_ENV_VALUE 1 +#define ENV_ESC 2 +#define ENV_USERVAR 3 + +/* + * AUTHENTICATION suboptions + */ + +/* + * Who is authenticating who ... + */ +#define AUTH_WHO_CLIENT 0 /* Client authenticating server */ +#define AUTH_WHO_SERVER 1 /* Server authenticating client */ +#define AUTH_WHO_MASK 1 + +/* + * amount of authentication done + */ +#define AUTH_HOW_ONE_WAY 0 +#define AUTH_HOW_MUTUAL 2 +#define AUTH_HOW_MASK 2 + +#define AUTHTYPE_NULL 0 +#define AUTHTYPE_KERBEROS_V4 1 +#define AUTHTYPE_KERBEROS_V5 2 +#define AUTHTYPE_SPX 3 +#define AUTHTYPE_MINK 4 +#define AUTHTYPE_CNT 5 + +#define AUTHTYPE_TEST 99 + +#ifdef AUTH_NAMES +char *authtype_names[] = { + "NULL", "KERBEROS_V4", "KERBEROS_V5", "SPX", "MINK", 0, +}; +#else +extern char *authtype_names[]; +#endif + +#define AUTHTYPE_NAME_OK(x) ((unsigned int)(x) < AUTHTYPE_CNT) +#define AUTHTYPE_NAME(x) authtype_names[x] + +/* + * ENCRYPTion suboptions + */ +#define ENCRYPT_IS 0 /* I pick encryption type ... */ +#define ENCRYPT_SUPPORT 1 /* I support encryption types ... */ +#define ENCRYPT_REPLY 2 /* Initial setup response */ +#define ENCRYPT_START 3 /* Am starting to send encrypted */ +#define ENCRYPT_END 4 /* Am ending encrypted */ +#define ENCRYPT_REQSTART 5 /* Request you start encrypting */ +#define ENCRYPT_REQEND 6 /* Request you send encrypting */ +#define ENCRYPT_ENC_KEYID 7 +#define ENCRYPT_DEC_KEYID 8 +#define ENCRYPT_CNT 9 + +#define ENCTYPE_ANY 0 +#define ENCTYPE_DES_CFB64 1 +#define ENCTYPE_DES_OFB64 2 +#define ENCTYPE_CNT 3 + +#ifdef ENCRYPT_NAMES +char *encrypt_names[] = { + "IS", "SUPPORT", "REPLY", "START", "END", + "REQUEST-START", "REQUEST-END", "ENC-KEYID", "DEC-KEYID", + 0, +}; +char *enctype_names[] = { + "ANY", "DES_CFB64", "DES_OFB64", 0, +}; +#else +extern char *encrypt_names[]; +extern char *enctype_names[]; +#endif + + +#define ENCRYPT_NAME_OK(x) ((unsigned int)(x) < ENCRYPT_CNT) +#define ENCRYPT_NAME(x) encrypt_names[x] + +#define ENCTYPE_NAME_OK(x) ((unsigned int)(x) < ENCTYPE_CNT) +#define ENCTYPE_NAME(x) enctype_names[x] + +#endif /* !_TELNET_H_ */ diff --git a/src/include/arpa/tftp.h b/src/include/arpa/tftp.h new file mode 100644 index 00000000..9234c6c6 --- /dev/null +++ b/src/include/arpa/tftp.h @@ -0,0 +1,82 @@ +/* $NetBSD: tftp.h,v 1.3 1994/10/26 00:56:48 cgd Exp $ */ + +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tftp.h 5.4 (Berkeley) 4/3/91 + */ + +#ifndef _TFTP_H_ +#define _TFTP_H_ + +/* + * 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 */ + +#endif /* !_TFTP_H_ */ diff --git a/src/include/assert.h b/src/include/assert.h new file mode 100644 index 00000000..8494ea0c --- /dev/null +++ b/src/include/assert.h @@ -0,0 +1,67 @@ +/* $NetBSD: assert.h,v 1.6 1994/10/26 00:55:44 cgd Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)assert.h 8.2 (Berkeley) 1/21/94 + */ + +/* + * Unlike other ANSI header files, <assert.h> may usefully be included + * multiple times, with and without NDEBUG defined. + */ + +#undef assert +#undef _assert + +#ifdef NDEBUG +#define assert(e) ((void)0) +#define _assert(e) ((void)0) +#else +#define _assert(e) assert(e) +#ifdef __STDC__ +#define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, #e)) +#else /* PCC */ +#define assert(e) ((e) ? (void)0 : __assert(__FILE__, __LINE__, "e")) +#endif +#endif + +#include <sys/cdefs.h> + +__BEGIN_DECLS +void __assert __P((const char *, int, const char *)); +__END_DECLS diff --git a/src/include/bitstring.h b/src/include/bitstring.h new file mode 100644 index 00000000..5966a1d3 --- /dev/null +++ b/src/include/bitstring.h @@ -0,0 +1,115 @@ +/* $NetBSD: bitstring.h,v 1.4 1994/10/26 00:55:45 cgd Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Paul Vixie. + * + * 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 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. + * + * @(#)bitstring.h 5.2 (Berkeley) 4/4/90 + */ + +#ifndef _BITSTRING_H_ +#define _BITSTRING_H_ + +/* modified for SV/AT and bitstring bugfix by M.R.Murphy, 11oct91 + * bitstr_size changed gratuitously, but shorter + * bit_alloc spelling error fixed + * the following were efficient, but didn't work, they've been made to + * work, but are no longer as efficient :-) + * bit_nclear, bit_nset, bit_ffc, bit_ffs + */ +typedef unsigned char bitstr_t; + +/* internal macros */ + /* byte of the bitstring bit is in */ +#define _bit_byte(bit) \ + ((bit) >> 3) + + /* mask for the bit within its byte */ +#define _bit_mask(bit) \ + (1 << ((bit)&0x7)) + +/* external macros */ + /* bytes in a bitstring of nbits bits */ +#define bitstr_size(nbits) \ + (((nbits) + 7) >> 3) + + /* allocate a bitstring */ +#define bit_alloc(nbits) \ + (bitstr_t *)calloc((size_t)bitstr_size(nbits), sizeof(bitstr_t)) + + /* allocate a bitstring on the stack */ +#define bit_decl(name, nbits) \ + (name)[bitstr_size(nbits)] + + /* is bit N of bitstring name set? */ +#define bit_test(name, bit) \ + ((name)[_bit_byte(bit)] & _bit_mask(bit)) + + /* set bit N of bitstring name */ +#define bit_set(name, bit) \ + (name)[_bit_byte(bit)] |= _bit_mask(bit) + + /* clear bit N of bitstring name */ +#define bit_clear(name, bit) \ + (name)[_bit_byte(bit)] &= ~_bit_mask(bit) + + /* clear bits start ... stop in bitstring */ +#define bit_nclear(name, start, stop) { \ + register bitstr_t *_name = name; \ + register int _start = start, _stop = stop; \ + while (_start <= _stop) { \ + bit_clear(_name, _start); \ + _start++; \ + } \ +} + + /* set bits start ... stop in bitstring */ +#define bit_nset(name, start, stop) { \ + register bitstr_t *_name = name; \ + register int _start = start, _stop = stop; \ + while (_start <= _stop) { \ + bit_set(_name, _start); \ + _start++; \ + } \ +} + + /* find first bit clear in name */ +#define bit_ffc(name, nbits, value) { \ + register bitstr_t *_name = name; \ + register int _bit, _nbits = nbits, _value = -1; \ + for (_bit = 0; _bit < _nbits; ++_bit) \ + if (!bit_test(_name, _bit)) { \ + _value = _bit; \ + break; \ + } \ + *(value) = _value; \ +} + + /* find first bit set in name */ +#define bit_ffs(name, nbits, value) { \ + register bitstr_t *_name = name; \ + register int _bit, _nbits = nbits, _value = -1; \ + for (_bit = 0; _bit < _nbits; ++_bit) \ + if (bit_test(_name, _bit)) { \ + _value = _bit; \ + break; \ + } \ + *(value) = _value; \ +} + +#endif /* !_BITSTRING_H_ */ diff --git a/src/include/bm.h b/src/include/bm.h new file mode 100644 index 00000000..2cdd5e83 --- /dev/null +++ b/src/include/bm.h @@ -0,0 +1,61 @@ +/* $NetBSD: bm.h,v 1.3 1994/10/26 00:55:46 cgd Exp $ */ + +/*- + * Copyright (c) 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Andrew Hume of AT&T Bell Laboratories. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)bm.h 8.6 (Berkeley) 6/21/94 + */ + +#ifndef _BM_H_ +#define _BM_H_ + +typedef struct { + u_char *pat; /* pattern */ + size_t patlen; /* pattern length */ + size_t *delta; /* skip delta */ + int rarec; /* rare character */ + size_t rareoff; /* rare offset */ + size_t md2; /* mini delta */ +} bm_pat; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +bm_pat *bm_comp __P((u_char const *, size_t, u_char const *)); +u_char *bm_exec __P((bm_pat *, u_char *, size_t)); +void bm_free __P((bm_pat *)); +__END_DECLS + +#endif /* !_BM_H_ */ diff --git a/src/include/ctype.h b/src/include/ctype.h new file mode 100644 index 00000000..4909fee5 --- /dev/null +++ b/src/include/ctype.h @@ -0,0 +1,108 @@ +/* $NetBSD: ctype.h,v 1.14 1994/10/26 00:55:47 cgd Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ctype.h 5.3 (Berkeley) 4/3/91 + */ + +#ifndef _CTYPE_H_ +#define _CTYPE_H_ +#include <sys/cdefs.h> + +#define _U 0x01 +#define _L 0x02 +#define _N 0x04 +#define _S 0x08 +#define _P 0x10 +#define _C 0x20 +#define _X 0x40 +#define _B 0x80 + +extern const char *_ctype_; +extern const short *_tolower_tab_; +extern const short *_toupper_tab_; + +__BEGIN_DECLS +extern int isalnum __P ((int)); +extern int isalpha __P ((int)); +extern int iscntrl __P ((int)); +extern int isdigit __P ((int)); +extern int isgraph __P ((int)); +extern int islower __P ((int)); +extern int isprint __P ((int)); +extern int ispunct __P ((int)); +extern int isspace __P ((int)); +extern int isupper __P ((int)); +extern int isxdigit __P ((int)); +extern int tolower __P ((int)); +extern int toupper __P ((int)); + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +extern int isblank __P ((int)); +extern int isascii __P ((int)); +extern int toascii __P ((int)); +extern int _tolower __P ((int)); +extern int _toupper __P ((int)); +#endif +__END_DECLS + +#define isdigit(c) ((_ctype_ + 1)[c] & _N) +#define islower(c) ((_ctype_ + 1)[c] & _L) +#define isspace(c) ((_ctype_ + 1)[c] & _S) +#define ispunct(c) ((_ctype_ + 1)[c] & _P) +#define isupper(c) ((_ctype_ + 1)[c] & _U) +#define isalpha(c) ((_ctype_ + 1)[c] & (_U|_L)) +#define isxdigit(c) ((_ctype_ + 1)[c] & (_N|_X)) +#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 tolower(c) ((_tolower_tab_ + 1)[c]) +#define toupper(c) ((_toupper_tab_ + 1)[c]) + +#if !defined(_ANSI_SOURCE) && !defined (_POSIX_SOURCE) +#if notyet +#define isblank(c) ((_ctype_ + 1)[c] & _B) +#endif +#define isascii(c) ((unsigned)(c) <= 0177) +#define toascii(c) ((c) & 0177) +#define _tolower(c) ((c) - 'A' + 'a') +#define _toupper(c) ((c) - 'a' + 'A') +#endif + +#endif /* !_CTYPE_H_ */ diff --git a/src/include/db.h b/src/include/db.h new file mode 100644 index 00000000..21d43aaf --- /dev/null +++ b/src/include/db.h @@ -0,0 +1,234 @@ +/* $NetBSD: db.h,v 1.13 1994/10/26 00:55:48 cgd Exp $ */ + +/*- + * Copyright (c) 1990, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)db.h 8.7 (Berkeley) 6/16/94 + */ + +#ifndef _DB_H_ +#define _DB_H_ + +#include <sys/types.h> +#include <sys/cdefs.h> + +#include <limits.h> + +#define RET_ERROR -1 /* Return values. */ +#define RET_SUCCESS 0 +#define RET_SPECIAL 1 + +#ifndef __BIT_TYPES_DEFINED__ +#define __BIT_TYPES_DEFINED__ +typedef __signed char int8_t; +typedef unsigned char u_int8_t; +typedef short int16_t; +typedef unsigned short u_int16_t; +typedef int int32_t; +typedef unsigned int u_int32_t; +#ifdef WE_DONT_NEED_QUADS +typedef long long int64_t; +typedef unsigned long long u_int64_t; +#endif +#endif + +#define MAX_PAGE_NUMBER 0xffffffff /* >= # of pages in a file */ +typedef u_int32_t pgno_t; +#define MAX_PAGE_OFFSET 65535 /* >= # of bytes in a page */ +typedef u_int16_t indx_t; +#define MAX_REC_NUMBER 0xffffffff /* >= # of records in a tree */ +typedef u_int32_t recno_t; + +/* Key/data structure -- a Data-Base Thang. */ +typedef struct { + void *data; /* data */ + size_t size; /* data length */ +} DBT; + +/* Routine flags. */ +#define R_CURSOR 1 /* del, put, seq */ +#define __R_UNUSED 2 /* UNUSED */ +#define R_FIRST 3 /* seq */ +#define R_IAFTER 4 /* put (RECNO) */ +#define R_IBEFORE 5 /* put (RECNO) */ +#define R_LAST 6 /* seq (BTREE, RECNO) */ +#define R_NEXT 7 /* seq */ +#define R_NOOVERWRITE 8 /* put */ +#define R_PREV 9 /* seq (BTREE, RECNO) */ +#define R_SETCURSOR 10 /* put (RECNO) */ +#define R_RECNOSYNC 11 /* sync (RECNO) */ + +typedef enum { DB_BTREE, DB_HASH, DB_RECNO } DBTYPE; + +/* + * !!! + * The following flags are included in the dbopen(3) call as part of the + * open(2) flags. In order to avoid conflicts with the open flags, start + * at the top of the 16 or 32-bit number space and work our way down. If + * the open flags were significantly expanded in the future, it could be + * a problem. Wish I'd left another flags word in the dbopen call. + * + * !!! + * None of this stuff is implemented yet. The only reason that it's here + * is so that the access methods can skip copying the key/data pair when + * the DB_LOCK flag isn't set. + */ +#if UINT_MAX > 65535 +#define DB_LOCK 0x20000000 /* Do locking. */ +#define DB_SHMEM 0x40000000 /* Use shared memory. */ +#define DB_TXN 0x80000000 /* Do transactions. */ +#else +#define DB_LOCK 0x2000 /* Do locking. */ +#define DB_SHMEM 0x4000 /* Use shared memory. */ +#define DB_TXN 0x8000 /* Do transactions. */ +#endif + +/* Access method description structure. */ +typedef struct __db { + DBTYPE type; /* Underlying db type. */ + int (*close) __P((struct __db *)); + int (*del) __P((const struct __db *, const DBT *, u_int)); + int (*get) __P((const struct __db *, const DBT *, DBT *, u_int)); + int (*put) __P((const struct __db *, DBT *, const DBT *, u_int)); + int (*seq) __P((const struct __db *, DBT *, DBT *, u_int)); + int (*sync) __P((const struct __db *, u_int)); + void *internal; /* Access method private. */ + int (*fd) __P((const struct __db *)); +} DB; + +#define BTREEMAGIC 0x053162 +#define BTREEVERSION 3 + +/* Structure used to pass parameters to the btree routines. */ +typedef struct { +#define R_DUP 0x01 /* duplicate keys */ + u_long flags; + u_int cachesize; /* bytes to cache */ + int maxkeypage; /* maximum keys per page */ + int minkeypage; /* minimum keys per page */ + u_int psize; /* page size */ + int (*compare) /* comparison function */ + __P((const DBT *, const DBT *)); + size_t (*prefix) /* prefix function */ + __P((const DBT *, const DBT *)); + int lorder; /* byte order */ +} BTREEINFO; + +#define HASHMAGIC 0x061561 +#define HASHVERSION 2 + +/* Structure used to pass parameters to the hashing routines. */ +typedef struct { + u_int bsize; /* bucket size */ + u_int ffactor; /* fill factor */ + u_int nelem; /* number of elements */ + u_int cachesize; /* bytes to cache */ + u_int32_t /* hash function */ + (*hash) __P((const void *, size_t)); + int lorder; /* byte order */ +} HASHINFO; + +/* Structure used to pass parameters to the record routines. */ +typedef struct { +#define R_FIXEDLEN 0x01 /* fixed-length records */ +#define R_NOKEY 0x02 /* key not required */ +#define R_SNAPSHOT 0x04 /* snapshot the input */ + u_long flags; + u_int cachesize; /* bytes to cache */ + u_int psize; /* page size */ + int lorder; /* byte order */ + size_t reclen; /* record length (fixed-length records) */ + u_char bval; /* delimiting byte (variable-length records */ + char *bfname; /* btree file name */ +} RECNOINFO; + +#ifdef __DBINTERFACE_PRIVATE +/* + * Little endian <==> big endian 32-bit swap macros. + * M_32_SWAP swap a memory location + * P_32_SWAP swap a referenced memory location + * P_32_COPY swap from one location to another + */ +#define M_32_SWAP(a) { \ + u_int32_t _tmp = a; \ + ((char *)&a)[0] = ((char *)&_tmp)[3]; \ + ((char *)&a)[1] = ((char *)&_tmp)[2]; \ + ((char *)&a)[2] = ((char *)&_tmp)[1]; \ + ((char *)&a)[3] = ((char *)&_tmp)[0]; \ +} +#define P_32_SWAP(a) { \ + u_int32_t _tmp = *(u_int32_t *)a; \ + ((char *)a)[0] = ((char *)&_tmp)[3]; \ + ((char *)a)[1] = ((char *)&_tmp)[2]; \ + ((char *)a)[2] = ((char *)&_tmp)[1]; \ + ((char *)a)[3] = ((char *)&_tmp)[0]; \ +} +#define P_32_COPY(a, b) { \ + ((char *)&(b))[0] = ((char *)&(a))[3]; \ + ((char *)&(b))[1] = ((char *)&(a))[2]; \ + ((char *)&(b))[2] = ((char *)&(a))[1]; \ + ((char *)&(b))[3] = ((char *)&(a))[0]; \ +} + +/* + * Little endian <==> big endian 16-bit swap macros. + * M_16_SWAP swap a memory location + * P_16_SWAP swap a referenced memory location + * P_16_COPY swap from one location to another + */ +#define M_16_SWAP(a) { \ + u_int16_t _tmp = a; \ + ((char *)&a)[0] = ((char *)&_tmp)[1]; \ + ((char *)&a)[1] = ((char *)&_tmp)[0]; \ +} +#define P_16_SWAP(a) { \ + u_int16_t _tmp = *(u_int16_t *)a; \ + ((char *)a)[0] = ((char *)&_tmp)[1]; \ + ((char *)a)[1] = ((char *)&_tmp)[0]; \ +} +#define P_16_COPY(a, b) { \ + ((char *)&(b))[0] = ((char *)&(a))[1]; \ + ((char *)&(b))[1] = ((char *)&(a))[0]; \ +} +#endif + +__BEGIN_DECLS +DB *dbopen __P((const char *, int, int, DBTYPE, const void *)); + +#ifdef __DBINTERFACE_PRIVATE +DB *__bt_open __P((const char *, int, int, const BTREEINFO *, int)); +DB *__hash_open __P((const char *, int, int, const HASHINFO *, int)); +DB *__rec_open __P((const char *, int, int, const RECNOINFO *, int)); +void __dbpanic __P((DB *dbp)); +#endif +__END_DECLS +#endif /* !_DB_H_ */ diff --git a/src/include/dirent.h b/src/include/dirent.h new file mode 100644 index 00000000..f5301cbb --- /dev/null +++ b/src/include/dirent.h @@ -0,0 +1,104 @@ +/* $NetBSD: dirent.h,v 1.9 1995/03/26 20:13:37 jtc Exp $ */ + +/*- + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)dirent.h 8.2 (Berkeley) 7/28/94 + */ + +#ifndef _DIRENT_H_ +#define _DIRENT_H_ + +/* + * The kernel defines the format of directory entries returned by + * the getdirentries(2) system call. + */ +#include <sys/dirent.h> + +#ifdef _POSIX_SOURCE +typedef void * DIR; +#else + +#define d_ino d_fileno /* backward compatibility */ + +/* definitions for library routines operating on directories. */ +#define DIRBLKSIZ 1024 + +/* structure describing an open directory. */ +typedef struct _dirdesc { + int dd_fd; /* file descriptor associated with directory */ + long dd_loc; /* offset in current buffer */ + long dd_size; /* amount of data returned by getdirentries */ + char *dd_buf; /* data buffer */ + int dd_len; /* size of data buffer */ + long dd_seek; /* magic cookie returned by getdirentries */ + long dd_rewind; /* magic cookie for rewinding */ + int dd_flags; /* flags for readdir */ +} DIR; + +#define dirfd(dirp) ((dirp)->dd_fd) + +/* flags for opendir2 */ +#define DTF_HIDEW 0x0001 /* hide whiteout entries */ +#define DTF_NODUP 0x0002 /* don't return duplicate names */ +#define DTF_REWIND 0x0004 /* rewind after reading union stack */ +#define __DTF_READALL 0x0008 /* everything has been read */ + +#ifndef NULL +#define NULL 0 +#endif + +#endif /* _POSIX_SOURCE */ + +#ifndef _KERNEL + +#include <sys/cdefs.h> + +__BEGIN_DECLS +DIR *opendir __P((const char *)); +struct dirent *readdir __P((DIR *)); +void rewinddir __P((DIR *)); +int closedir __P((DIR *)); +#ifndef _POSIX_SOURCE +DIR *__opendir2 __P((const char *, int)); +long telldir __P((const DIR *)); +void seekdir __P((DIR *, long)); +int scandir __P((const char *, struct dirent ***, + int (*)(struct dirent *), int (*)(const void *, const void *))); +int alphasort __P((const void *, const void *)); +int getdirentries __P((int, char *, int, long *)); +#endif /* not POSIX */ +__END_DECLS + +#endif /* !_KERNEL */ + +#endif /* !_DIRENT_H_ */ diff --git a/src/include/disktab.h b/src/include/disktab.h new file mode 100644 index 00000000..364c4a0c --- /dev/null +++ b/src/include/disktab.h @@ -0,0 +1,63 @@ +/* $NetBSD: disktab.h,v 1.3 1994/10/26 00:55:51 cgd Exp $ */ + +/* + * Copyright (c) 1983 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)disktab.h 5.6 (Berkeley) 4/20/91 + */ + +#ifndef _DISKTAB_H_ +#define _DISKTAB_H_ + +/* + * 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]; +}; + +#endif /* !_DISKTAB_H_ */ diff --git a/src/include/dlfcn.h b/src/include/dlfcn.h new file mode 100644 index 00000000..f61dbad9 --- /dev/null +++ b/src/include/dlfcn.h @@ -0,0 +1,62 @@ +/* $NetBSD: dlfcn.h,v 1.2 1995/06/05 19:38:00 pk Exp $ */ + +/* + * Copyright (c) 1995 Paul Kranenburg + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Paul Kranenburg. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software withough specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _DLFCN_H_ +#define _DLFCN_H_ + +#include <sys/cdefs.h> + +/* + * User interface to the run-time linker. + */ +__BEGIN_DECLS +extern void *dlopen __P((char *, int)); +extern int dlclose __P((void *)); +extern void *dlsym __P((void *, char *)); +extern int dlctl __P((void *, int, void *)); +extern char *dlerror __P((void)); +__END_DECLS + +/* Values for dlopen `mode'. */ +#define DL_LAZY 1 +#define RTLD_LAZY DL_LAZY /* SunOS Compat */ + +/* + * dlctl() commands + */ +#define DL_GETERRNO 1 +#define DL_SETSRCHPATH x +#define DL_GETLIST x +#define DL_GETREFCNT x +#define DL_GETLOADADDR x + +#endif /* _DLFCN_H_ */ diff --git a/src/include/err.h b/src/include/err.h new file mode 100644 index 00000000..b903562a --- /dev/null +++ b/src/include/err.h @@ -0,0 +1,70 @@ +/* $NetBSD: err.h,v 1.11 1994/10/26 00:55:52 cgd Exp $ */ + +/*- + * Copyright (c) 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)err.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _ERR_H_ +#define _ERR_H_ + +/* + * Don't use va_list in the err/warn prototypes. Va_list is typedef'd in two + * places (<machine/varargs.h> and <machine/stdarg.h>), so if we include one + * of them here we may collide with the utility's includes. It's unreasonable + * for utilities to have to include one of them to include err.h, so we get + * _BSD_VA_LIST_ from <machine/ansi.h> and use it. + */ +#include <machine/ansi.h> +#include <sys/cdefs.h> + +__BEGIN_DECLS +__dead void err __P((int, const char *, ...)) + __attribute__((noreturn, format (printf, 2, 3))); +__dead void verr __P((int, const char *, _BSD_VA_LIST_)) + __attribute__((noreturn, format (printf, 2, 0))); +__dead void errx __P((int, const char *, ...)) + __attribute__((noreturn, format (printf, 2, 3))); +__dead void verrx __P((int, const char *, _BSD_VA_LIST_)) + __attribute__((noreturn, format (printf, 2, 0))); +void warn __P((const char *, ...)) + __attribute__((format (printf, 1, 2))); +void vwarn __P((const char *, _BSD_VA_LIST_)) + __attribute__((format (printf, 1, 0))); +void warnx __P((const char *, ...)) + __attribute__((format (printf, 1, 2))); +void vwarnx __P((const char *, _BSD_VA_LIST_)) + __attribute__((format (printf, 1, 0))); +__END_DECLS + +#endif /* !_ERR_H_ */ diff --git a/src/include/fnmatch.h b/src/include/fnmatch.h new file mode 100644 index 00000000..87d0a2b4 --- /dev/null +++ b/src/include/fnmatch.h @@ -0,0 +1,53 @@ +/* $NetBSD: fnmatch.h,v 1.5 1994/10/26 00:55:53 cgd Exp $ */ + +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)fnmatch.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _FNMATCH_H_ +#define _FNMATCH_H_ + +#define FNM_NOMATCH 1 /* Match failed. */ + +#define FNM_NOESCAPE 0x01 /* Disable backslash escaping. */ +#define FNM_PATHNAME 0x02 /* Slash must be matched by slash. */ +#define FNM_PERIOD 0x04 /* Period must be matched by period. */ + +#include <sys/cdefs.h> + +__BEGIN_DECLS +int fnmatch __P((const char *, const char *, int)); +__END_DECLS + +#endif /* !_FNMATCH_H_ */ diff --git a/src/include/fstab.h b/src/include/fstab.h new file mode 100644 index 00000000..4043d7ab --- /dev/null +++ b/src/include/fstab.h @@ -0,0 +1,81 @@ +/* $NetBSD: fstab.h,v 1.3 1994/10/26 00:55:53 cgd Exp $ */ + +/* + * Copyright (c) 1980 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)fstab.h 5.12 (Berkeley) 4/3/91 + */ + +#ifndef _FSTAB_H_ +#define _FSTAB_H_ + +/* + * File system table, see fstab(5). + * + * Used by dump, mount, umount, swapon, fsck, df, ... + * + * For ufs 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 _PATH_FSTAB "/etc/fstab" +#define FSTAB "/etc/fstab" /* deprecated */ + +#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_vfstype; /* File system type, ufs, nfs */ + char *fs_mntops; /* Mount options ala -o */ + char *fs_type; /* FSTAB_* from fs_mntops */ + int fs_freq; /* dump frequency, in days */ + int fs_passno; /* pass number on parallel dump */ +}; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +struct fstab *getfsent __P((void)); +struct fstab *getfsspec __P((const char *)); +struct fstab *getfsfile __P((const char *)); +int setfsent __P((void)); +void endfsent __P((void)); +__END_DECLS + +#endif /* !_FSTAB_H_ */ diff --git a/src/include/fts.h b/src/include/fts.h new file mode 100644 index 00000000..c6bc5ff7 --- /dev/null +++ b/src/include/fts.h @@ -0,0 +1,130 @@ +/* $NetBSD: fts.h,v 1.5 1994/12/28 01:41:50 mycroft Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)fts.h 8.3 (Berkeley) 8/14/94 + */ + +#ifndef _FTS_H_ +#define _FTS_H_ + +typedef struct { + struct _ftsent *fts_cur; /* current node */ + struct _ftsent *fts_child; /* linked list of children */ + struct _ftsent **fts_array; /* sort array */ + dev_t fts_dev; /* starting device # */ + char *fts_path; /* path for this descent */ + int fts_rfd; /* fd for root */ + int fts_pathlen; /* sizeof(path) */ + int fts_nitems; /* elements in the sort array */ + int (*fts_compar)(); /* compare function */ + +#define FTS_COMFOLLOW 0x001 /* follow command line symlinks */ +#define FTS_LOGICAL 0x002 /* logical walk */ +#define FTS_NOCHDIR 0x004 /* don't change directories */ +#define FTS_NOSTAT 0x008 /* don't get stat info */ +#define FTS_PHYSICAL 0x010 /* physical walk */ +#define FTS_SEEDOT 0x020 /* return dot and dot-dot */ +#define FTS_XDEV 0x040 /* don't cross devices */ +#define FTS_WHITEOUT 0x080 /* return whiteout information */ +#define FTS_OPTIONMASK 0x0ff /* valid user option mask */ + +#define FTS_NAMEONLY 0x100 /* (private) child names only */ +#define FTS_STOP 0x200 /* (private) unrecoverable error */ + int fts_options; /* fts_open options, global flags */ +} FTS; + +typedef struct _ftsent { + struct _ftsent *fts_cycle; /* cycle node */ + struct _ftsent *fts_parent; /* parent directory */ + struct _ftsent *fts_link; /* next file in directory */ + long fts_number; /* local numeric value */ + void *fts_pointer; /* local address value */ + char *fts_accpath; /* access path */ + char *fts_path; /* root path */ + int fts_errno; /* errno for this node */ + int fts_symfd; /* fd for symlink */ + u_short fts_pathlen; /* strlen(fts_path) */ + u_short fts_namelen; /* strlen(fts_name) */ + + ino_t fts_ino; /* inode */ + dev_t fts_dev; /* device */ + nlink_t fts_nlink; /* link count */ + +#define FTS_ROOTPARENTLEVEL -1 +#define FTS_ROOTLEVEL 0 + short fts_level; /* depth (-1 to N) */ + +#define FTS_D 1 /* preorder directory */ +#define FTS_DC 2 /* directory that causes cycles */ +#define FTS_DEFAULT 3 /* none of the above */ +#define FTS_DNR 4 /* unreadable directory */ +#define FTS_DOT 5 /* dot or dot-dot */ +#define FTS_DP 6 /* postorder directory */ +#define FTS_ERR 7 /* error; errno is set */ +#define FTS_F 8 /* regular file */ +#define FTS_INIT 9 /* initialized only */ +#define FTS_NS 10 /* stat(2) failed */ +#define FTS_NSOK 11 /* no stat(2) requested */ +#define FTS_SL 12 /* symbolic link */ +#define FTS_SLNONE 13 /* symbolic link without target */ +#define FTS_W 14 /* whiteout object */ + u_short fts_info; /* user flags for FTSENT structure */ + +#define FTS_DONTCHDIR 0x01 /* don't chdir .. to the parent */ +#define FTS_SYMFOLLOW 0x02 /* followed a symlink to get here */ +#define FTS_ISW 0x04 /* this is a whiteout object */ + u_short fts_flags; /* private flags for FTSENT structure */ + +#define FTS_AGAIN 1 /* read node again */ +#define FTS_FOLLOW 2 /* follow symbolic link */ +#define FTS_NOINSTR 3 /* no instructions */ +#define FTS_SKIP 4 /* discard node */ + u_short fts_instr; /* fts_set() instructions */ + + struct stat *fts_statp; /* stat(2) information */ + char fts_name[1]; /* file name */ +} FTSENT; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +FTSENT *fts_children __P((FTS *, int)); +int fts_close __P((FTS *)); +FTS *fts_open __P((char * const *, int, + int (*)(const FTSENT **, const FTSENT **))); +FTSENT *fts_read __P((FTS *)); +int fts_set __P((FTS *, FTSENT *, int)); +__END_DECLS + +#endif /* !_FTS_H_ */ diff --git a/src/include/glob.h b/src/include/glob.h new file mode 100644 index 00000000..92ac7a73 --- /dev/null +++ b/src/include/glob.h @@ -0,0 +1,92 @@ +/* $NetBSD: glob.h,v 1.5 1994/10/26 00:55:56 cgd Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Guido van Rossum. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)glob.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _GLOB_H_ +#define _GLOB_H_ + +#include <sys/cdefs.h> + +struct stat; +typedef struct { + int gl_pathc; /* Count of total paths so far. */ + int gl_matchc; /* Count of paths matching pattern. */ + int gl_offs; /* Reserved at beginning of gl_pathv. */ + int gl_flags; /* Copy of flags parameter to glob. */ + char **gl_pathv; /* List of paths matching pattern. */ + /* Copy of errfunc parameter to glob. */ + int (*gl_errfunc) __P((const char *, int)); + + /* + * Alternate filesystem access methods for glob; replacement + * versions of closedir(3), readdir(3), opendir(3), stat(2) + * and lstat(2). + */ + void (*gl_closedir) __P((void *)); + struct dirent *(*gl_readdir) __P((void *)); + void *(*gl_opendir) __P((const char *)); + int (*gl_lstat) __P((const char *, struct stat *)); + int (*gl_stat) __P((const char *, struct stat *)); +} glob_t; + +#define GLOB_APPEND 0x0001 /* Append to output from previous call. */ +#define GLOB_DOOFFS 0x0002 /* Use gl_offs. */ +#define GLOB_ERR 0x0004 /* Return on error. */ +#define GLOB_MARK 0x0008 /* Append / to matching directories. */ +#define GLOB_NOCHECK 0x0010 /* Return pattern itself if nothing matches. */ +#define GLOB_NOSORT 0x0020 /* Don't sort. */ + +#ifndef _POSIX_SOURCE +#define GLOB_ALTDIRFUNC 0x0040 /* Use alternately specified directory funcs. */ +#define GLOB_BRACE 0x0080 /* Expand braces ala csh. */ +#define GLOB_MAGCHAR 0x0100 /* Pattern had globbing characters. */ +#define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ +#define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ +#define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ +#endif + +#define GLOB_NOSPACE (-1) /* Malloc call failed. */ +#define GLOB_ABEND (-2) /* Unignored error. */ + +__BEGIN_DECLS +int glob __P((const char *, int, int (*)(const char *, int), glob_t *)); +void globfree __P((glob_t *)); +__END_DECLS + +#endif /* !_GLOB_H_ */ diff --git a/src/include/grp.h b/src/include/grp.h new file mode 100644 index 00000000..2fe6ca9b --- /dev/null +++ b/src/include/grp.h @@ -0,0 +1,74 @@ +/* $NetBSD: grp.h,v 1.7 1995/04/29 05:30:40 cgd Exp $ */ + +/*- + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)grp.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _GRP_H_ +#define _GRP_H_ + +#if !defined(_POSIX_SOURCE) && !defined(_XOPEN_SOURCE) +#define _PATH_GROUP "/etc/group" +#endif + +struct group { + char *gr_name; /* group name */ + char *gr_passwd; /* group password */ + int gr_gid; /* group id */ + char **gr_mem; /* group members */ +}; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +struct group *getgrgid __P((gid_t)); +struct group *getgrnam __P((const char *)); +#ifndef _POSIX_SOURCE +struct group *getgrent __P((void)); +void setgrent __P((void)); +void endgrent __P((void)); +void setgrfile __P((const char *)); +#ifndef _XOPEN_SOURCE +char *group_from_gid __P((gid_t, int)); +int setgroupent __P((int)); +#endif /* !_XOPEN_SOURCE */ +#endif /* !_POSIX_SOURCE */ +__END_DECLS + +#endif /* !_GRP_H_ */ diff --git a/src/include/ieeefp.h b/src/include/ieeefp.h new file mode 100644 index 00000000..cd4f9985 --- /dev/null +++ b/src/include/ieeefp.h @@ -0,0 +1,19 @@ +/* + * Written by J.T. Conklin, Apr 6, 1995 + * Public domain. + */ + +#ifndef _IEEEFP_H_ +#define _IEEEFP_H_ + +#include <sys/cdefs.h> +#include <machine/ieeefp.h> + +extern fp_rnd fpgetround __P((void)); +extern fp_rnd fpsetround __P((fp_rnd)); +extern fp_except fpgetmask __P((void)); +extern fp_except fpsetmask __P((fp_except)); +extern fp_except fpgetsticky __P((void)); +extern fp_except fpsetsticky __P((fp_except)); + +#endif /* _IEEEFP_H_ */ diff --git a/src/include/iso646.h b/src/include/iso646.h new file mode 100644 index 00000000..56ea2fef --- /dev/null +++ b/src/include/iso646.h @@ -0,0 +1,23 @@ +/* $NetBSD: iso646.h,v 1.1 1995/02/17 09:08:10 jtc Exp $ */ + +/* + * Written by J.T. Conklin <jtc@wimsey.com> 02/16/95. + * Public domain. + */ + +#ifndef _ISO646_H_ +#define _ISO646_H_ + +#define and && +#define and_eq &= +#define bitand & +#define bitor | +#define compl ~ +#define not ! +#define not_eq != +#define or || +#define or_eq |= +#define xor ^ +#define xor_eq ^= + +#endif /* !_ISO646_H_ */ diff --git a/src/include/kvm.h b/src/include/kvm.h new file mode 100644 index 00000000..8ff2ad5b --- /dev/null +++ b/src/include/kvm.h @@ -0,0 +1,71 @@ +/* $NetBSD: kvm.h,v 1.6 1994/10/26 00:55:58 cgd Exp $ */ + +/*- + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)kvm.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _KVM_H_ +#define _KVM_H_ + +/* Default version symbol. */ +#define VRS_SYM "_version" +#define VRS_KEY "VERSION" + +#include <nlist.h> +#include <sys/cdefs.h> + +__BEGIN_DECLS + +typedef struct __kvm kvm_t; + +struct kinfo_proc; +int kvm_close __P((kvm_t *)); +char **kvm_getargv __P((kvm_t *, const struct kinfo_proc *, int)); +char **kvm_getenvv __P((kvm_t *, const struct kinfo_proc *, int)); +char *kvm_geterr __P((kvm_t *)); +int kvm_getloadavg __P((kvm_t *, double [], int)); +char *kvm_getfiles __P((kvm_t *, int, int, int *)); +struct kinfo_proc * + kvm_getprocs __P((kvm_t *, int, int, int *)); +int kvm_nlist __P((kvm_t *, struct nlist *)); +kvm_t *kvm_open + __P((const char *, const char *, const char *, int, const char *)); +kvm_t *kvm_openfiles + __P((const char *, const char *, const char *, int, char *)); +ssize_t kvm_read __P((kvm_t *, u_long, void *, size_t)); +ssize_t kvm_write __P((kvm_t *, u_long, const void *, size_t)); + +__END_DECLS + +#endif /* !_KVM_H_ */ diff --git a/src/include/langinfo.h b/src/include/langinfo.h new file mode 100644 index 00000000..778205ea --- /dev/null +++ b/src/include/langinfo.h @@ -0,0 +1,73 @@ +/* $NetBSD: langinfo.h,v 1.3 1995/04/28 23:30:54 jtc Exp $ */ + +/* + * Written by J.T. Conklin <jtc@netbsd.org> + * Public domain. + */ + +#ifndef _LANGINFO_H_ +#define _LANGINFO_H_ +#include <sys/cdefs.h> + +#define D_T_FMT 0 /* String for formatting date and time */ +#define D_FMT 1 /* Date format string */ +#define T_FMT 2 /* Time format string */ +#define T_FMT_AMPM 3 /* Time format string with 12 hour clock */ +#define AM_STR 4 /* Ante Meridiem afix */ +#define PM_STR 5 /* Post Meridiem afix */ + +#define DAY_1 6 /* Name of the first day of the week */ +#define DAY_2 7 +#define DAY_3 8 +#define DAY_4 9 +#define DAY_5 10 +#define DAY_6 11 +#define DAY_7 12 + +#define ABDAY_1 13 /* Abbrev. name of the first day of the week */ +#define ABDAY_2 14 +#define ABDAY_3 15 +#define ABDAY_4 16 +#define ABDAY_5 17 +#define ABDAY_6 18 +#define ABDAY_7 19 + +#define MON_1 20 /* Name of the first month */ +#define MON_2 21 +#define MON_3 22 +#define MON_4 23 +#define MON_5 24 +#define MON_6 25 +#define MON_7 26 +#define MON_8 27 +#define MON_9 28 +#define MON_10 29 +#define MON_11 30 +#define MON_12 31 + +#define ABMON_1 32 /* Abbrev. name of the first month */ +#define ABMON_2 33 +#define ABMON_3 34 +#define ABMON_4 35 +#define ABMON_5 36 +#define ABMON_6 37 +#define ABMON_7 38 +#define ABMON_8 39 +#define ABMON_9 40 +#define ABMON_10 41 +#define ABMON_11 42 +#define ABMON_12 43 + +#define RADIXCHAR 44 /* Radix character */ +#define THOUSEP 45 /* Separator for thousands */ +#define YESSTR 46 /* Affirmitive response for yes/no queries */ +#define YESEXPR 47 /* Affirmitive response for yes/no queries */ +#define NOSTR 48 /* Negative response for yes/no queries */ +#define NOEXPR 49 /* Negative response for yes/no queries */ +#define CRNCYSTR 50 /* Currency symbol */ + +__BEGIN_DECLS +char *nl_langinfo __P((nl_item)); +__END_DECLS + +#endif /* _LANGINFO_H_ */ diff --git a/src/include/limits.h b/src/include/limits.h new file mode 100644 index 00000000..046ac292 --- /dev/null +++ b/src/include/limits.h @@ -0,0 +1,80 @@ +/* $NetBSD: limits.h,v 1.7 1994/10/26 00:56:00 cgd Exp $ */ + +/* + * Copyright (c) 1988 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)limits.h 5.9 (Berkeley) 4/3/91 + */ + +#ifndef _LIMITS_H_ +#define _LIMITS_H_ + +#if !defined(_ANSI_SOURCE) +#define _POSIX_ARG_MAX 4096 +#define _POSIX_CHILD_MAX 6 +#define _POSIX_LINK_MAX 8 +#define _POSIX_MAX_CANON 255 +#define _POSIX_MAX_INPUT 255 +#define _POSIX_NAME_MAX 14 +#define _POSIX_NGROUPS_MAX 0 +#define _POSIX_OPEN_MAX 16 +#define _POSIX_PATH_MAX 255 +#define _POSIX_PIPE_BUF 512 +#define _POSIX_SSIZE_MAX 32727 +#define _POSIX_STREAM_MAX 8 +#define _POSIX_TZNAME_MAX 3 + +#define _POSIX2_BC_BASE_MAX 99 +#define _POSIX2_BC_DIM_MAX 2048 +#define _POSIX2_BC_SCALE_MAX 99 +#define _POSIX2_BC_STRING_MAX 1000 +#define _POSIX2_COLL_WEIGHTS_MAX 2 +#define _POSIX2_EXPR_NEST_MAX 32 +#define _POSIX2_LINE_MAX 2048 +#define _POSIX2_RE_DUP_MAX 255 +#endif /* !_ANSI_SOURCE */ + +#if (!defined(_ANSI_SOURCE)&&!defined(_POSIX_SOURCE)) || defined(_XOPEN_SOURCE) +#define PASS_MAX 128 + +#define NL_ARGMAX 9 +#define NL_LANGMAX 14 +#define NL_MSGMAX 32767 +#define NL_NMAX 1 +#define NL_SETMAX 255 +#define NL_TEXTMAX 255 +#endif + +#include <machine/limits.h> +#include <sys/syslimits.h> + +#endif /* !_LIMITS_H_ */ diff --git a/src/include/link.h b/src/include/link.h new file mode 100644 index 00000000..b5f256a8 --- /dev/null +++ b/src/include/link.h @@ -0,0 +1,283 @@ +/* $NetBSD: link.h,v 1.9 1995/09/23 22:26:15 pk Exp $ */ + +/* + * Copyright (c) 1993 Paul Kranenburg + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Paul Kranenburg. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software withough specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * RRS section definitions. + * + * The layout of some data structures defined in this header file is + * such that we can provide compatibility with the SunOS 4.x shared + * library scheme. + */ + +#ifndef _LINK_H_ +#define _LINK_H_ + +/* + * A `Shared Object Descriptor' descibes a shared object that is needed + * to complete the link edit process of the object containing it. + * A list of such objects (chained through `sod_next') is pointed at + * by `sdt_sods' in the section_dispatch_table structure. + */ + +struct sod { /* Shared Object Descriptor */ + long sod_name; /* name (relative to load address) */ + u_int sod_library : 1, /* Searched for by library rules */ + sod_reserved : 31; + short sod_major; /* major version number */ + short sod_minor; /* minor version number */ + long sod_next; /* next sod */ +}; + +/* + * `Shared Object Map's are used by the run-time link editor (ld.so) to + * keep track of all shared objects loaded into a process' address space. + * These structures are only used at run-time and do not occur within + * the text or data segment of an executable or shared library. + */ +struct so_map { /* Shared Object Map */ + caddr_t som_addr; /* Address at which object mapped */ + char *som_path; /* Path to mmap'ed file */ + struct so_map *som_next; /* Next map in chain */ + struct sod *som_sod; /* Sod responsible for this map */ + caddr_t som_sodbase; /* Base address of this sod */ + u_int som_write : 1; /* Text is currently writable */ + struct _dynamic *som_dynamic; /* _dynamic structure */ + caddr_t som_spd; /* Private data */ +}; + +/* + * Symbol description with size. This is simply an `nlist' with + * one field (nz_size) added. + * Used to convey size information on items in the data segment + * of shared objects. An array of these live in the shared object's + * text segment and is addressed by the `sdt_nzlist' field. + */ +struct nzlist { + struct nlist nlist; + u_long nz_size; +#define nz_un nlist.n_un +#define nz_strx nlist.n_un.n_strx +#define nz_name nlist.n_un.n_name +#define nz_type nlist.n_type +#define nz_value nlist.n_value +#define nz_desc nlist.n_desc +#define nz_other nlist.n_other +}; + +#define N_AUX(p) ((p)->n_other & 0xf) +#define N_BIND(p) (((unsigned int)(p)->n_other >> 4) & 0xf) +#define N_OTHER(r, v) (((unsigned int)(r) << 4) | ((v) & 0xf)) + +#define AUX_OBJECT 1 +#define AUX_FUNC 2 +/*#define BIND_LOCAL 0 not used */ +/*#define BIND_GLOBAL 1 not used */ +#define BIND_WEAK 2 + + +/* + * The `section_dispatch_table' structure contains offsets to various data + * structures needed to do run-time relocation. + */ +struct section_dispatch_table { + struct so_map *sdt_loaded; /* List of loaded objects */ + long sdt_sods; /* List of shared objects descriptors */ + long sdt_paths; /* Library search paths */ + long sdt_got; /* Global offset table */ + long sdt_plt; /* Procedure linkage table */ + long sdt_rel; /* Relocation table */ + long sdt_hash; /* Symbol hash table */ + long sdt_nzlist; /* Symbol table itself */ + long sdt_filler2; /* Unused (was: stab_hash) */ + long sdt_buckets; /* Number of hash buckets */ + long sdt_strings; /* Symbol strings */ + long sdt_str_sz; /* Size of symbol strings */ + long sdt_text_sz; /* Size of text area */ + long sdt_plt_sz; /* Size of procedure linkage table */ +}; + +/* + * RRS symbol hash table, addressed by `sdt_hash' in section_dispatch_table. + * Used to quickly lookup symbols of the shared object by hashing + * on the symbol's name. `rh_symbolnum' is the index of the symbol + * in the shared object's symbol list (`sdt_nzlist'), `rh_next' is + * the next symbol in the hash bucket (in case of collisions). + */ +struct rrs_hash { + int rh_symbolnum; /* Symbol number */ + int rh_next; /* Next hash entry */ +}; + +/* + * `rt_symbols' is used to keep track of run-time allocated commons + * and data items copied from shared objects. + */ +struct rt_symbol { + struct nzlist *rt_sp; /* The symbol */ + struct rt_symbol *rt_next; /* Next in linear list */ + struct rt_symbol *rt_link; /* Next in bucket */ + caddr_t rt_srcaddr; /* Address of "master" copy */ + struct so_map *rt_smp; /* Originating map */ +}; + +/* + * Debugger interface structure. + */ +struct so_debug { + int dd_version; /* Version # of interface */ + int dd_in_debugger; /* Set when run by debugger */ + int dd_sym_loaded; /* Run-time linking brought more + symbols into scope */ + char *dd_bpt_addr; /* Address of rtld-generated bpt */ + int dd_bpt_shadow; /* Original contents of bpt */ + struct rt_symbol *dd_cc; /* Allocated commons/copied data */ +}; + +/* + * Entry points into ld.so - user interface to the run-time linker. + */ +struct ld_entry { + void *(*dlopen) __P((char *, int)); + int (*dlclose) __P((void *)); + void *(*dlsym) __P((void *, char *)); + int (*dlctl) __P((void *, int, void *)); + void (*dlexit) __P((void)); + void (*dlrsrvd[3]) __P((void)); +}; + +/* + * This is the structure pointed at by the __DYNAMIC symbol if an + * executable requires the attention of the run-time link editor. + * __DYNAMIC is given the value zero if no run-time linking needs to + * be done (it is always present in shared objects). + * The union `d_un' provides for different versions of the dynamic + * linking mechanism (switched on by `d_version'). The last version + * used by Sun is 3. We leave some room here and go to version number + * 8 for NetBSD, the main difference lying in the support for the + * `nz_list' type of symbols. + */ + +struct _dynamic { + int d_version; /* version # of this interface */ + struct so_debug *d_debug; + union { + struct section_dispatch_table *d_sdt; + } d_un; + struct ld_entry *d_entry; /* compat - now in crt_ldso */ +}; + +#define LD_VERSION_SUN (3) +#define LD_VERSION_BSD (8) +#define LD_VERSION_NZLIST_P(v) ((v) >= 8) + +#define LD_GOT(x) ((x)->d_un.d_sdt->sdt_got) +#define LD_PLT(x) ((x)->d_un.d_sdt->sdt_plt) +#define LD_REL(x) ((x)->d_un.d_sdt->sdt_rel) +#define LD_SYMBOL(x) ((x)->d_un.d_sdt->sdt_nzlist) +#define LD_HASH(x) ((x)->d_un.d_sdt->sdt_hash) +#define LD_STRINGS(x) ((x)->d_un.d_sdt->sdt_strings) +#define LD_NEED(x) ((x)->d_un.d_sdt->sdt_sods) +#define LD_BUCKETS(x) ((x)->d_un.d_sdt->sdt_buckets) +#define LD_PATHS(x) ((x)->d_un.d_sdt->sdt_paths) + +#define LD_GOTSZ(x) ((x)->d_un.d_sdt->sdt_plt - (x)->d_un.d_sdt->sdt_got) +#define LD_RELSZ(x) ((x)->d_un.d_sdt->sdt_hash - (x)->d_un.d_sdt->sdt_rel) +#define LD_HASHSZ(x) ((x)->d_un.d_sdt->sdt_nzlist - (x)->d_un.d_sdt->sdt_hash) +#define LD_STABSZ(x) ((x)->d_un.d_sdt->sdt_strings - (x)->d_un.d_sdt->sdt_nzlist) +#define LD_PLTSZ(x) ((x)->d_un.d_sdt->sdt_plt_sz) +#define LD_STRSZ(x) ((x)->d_un.d_sdt->sdt_str_sz) +#define LD_TEXTSZ(x) ((x)->d_un.d_sdt->sdt_text_sz) + +/* + * Interface to ld.so + */ +struct crt_ldso { + int crt_ba; /* Base address of ld.so */ + int crt_dzfd; /* "/dev/zero" file decriptor (SunOS) */ + int crt_ldfd; /* ld.so file descriptor */ + struct _dynamic *crt_dp; /* Main's __DYNAMIC */ + char **crt_ep; /* environment strings */ + caddr_t crt_bp; /* Breakpoint if run from debugger */ + char *crt_prog; /* Program name (v3) */ + char *crt_ldso; /* Link editor name (v4) */ + struct ld_entry *crt_ldentry; /* dl*() access (v4) */ +}; + +/* + * Version passed from crt0 to ld.so (1st argument to _rtld()). + */ +#define CRT_VERSION_SUN 1 +#define CRT_VERSION_BSD_2 2 +#define CRT_VERSION_BSD_3 3 +#define CRT_VERSION_BSD_4 4 + + +/* + * Maximum number of recognized shared object version numbers. + */ +#define MAXDEWEY 8 + +/* + * Header of the hints file. + */ +struct hints_header { + long hh_magic; +#define HH_MAGIC 011421044151 + long hh_version; /* Interface version number */ +#define LD_HINTS_VERSION_1 1 + long hh_hashtab; /* Location of hash table */ + long hh_nbucket; /* Number of buckets in hashtab */ + long hh_strtab; /* Location of strings */ + long hh_strtab_sz; /* Size of strings */ + long hh_ehints; /* End of hints (max offset in file) */ +}; + +#define HH_BADMAG(hdr) ((hdr).hh_magic != HH_MAGIC) + +/* + * Hash table element in hints file. + */ +struct hints_bucket { + /* namex and pathx are indices into the string table */ + int hi_namex; /* Library name */ + int hi_pathx; /* Full path */ + int hi_dewey[MAXDEWEY]; /* The versions */ + int hi_ndewey; /* Number of version numbers */ +#define hi_major hi_dewey[0] +#define hi_minor hi_dewey[1] + int hi_next; /* Next in this bucket */ +}; + +#define _PATH_LD_HINTS "/var/run/ld.so.hints" + +#endif /* _LINK_H_ */ + diff --git a/src/include/locale.h b/src/include/locale.h new file mode 100644 index 00000000..4d68b26d --- /dev/null +++ b/src/include/locale.h @@ -0,0 +1,83 @@ +/* $NetBSD: locale.h,v 1.6 1994/10/26 00:56:02 cgd Exp $ */ + +/* + * Copyright (c) 1991 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)locale.h 5.2 (Berkeley) 2/24/91 + */ + +#ifndef _LOCALE_H_ +#define _LOCALE_H_ + +struct lconv { + char *decimal_point; + char *thousands_sep; + char *grouping; + char *int_curr_symbol; + char *currency_symbol; + char *mon_decimal_point; + char *mon_thousands_sep; + char *mon_grouping; + char *positive_sign; + char *negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; +}; + +#ifndef NULL +#define NULL 0 +#endif + +#define LC_ALL 0 +#define LC_COLLATE 1 +#define LC_CTYPE 2 +#define LC_MONETARY 3 +#define LC_NUMERIC 4 +#define LC_TIME 5 +#define LC_MESSAGES 6 + +#define _LC_LAST 7 /* marks end */ + +#include <sys/cdefs.h> + +__BEGIN_DECLS +struct lconv *localeconv __P((void)); +char *setlocale __P((int, const char *)); +__END_DECLS + +#endif /* _LOCALE_H_ */ diff --git a/src/include/malloc.h b/src/include/malloc.h new file mode 100644 index 00000000..fd313a34 --- /dev/null +++ b/src/include/malloc.h @@ -0,0 +1,3 @@ +/* $NetBSD: malloc.h,v 1.3 1994/10/26 00:56:03 cgd Exp $ */ + +#include <stdlib.h> diff --git a/src/include/math.h b/src/include/math.h new file mode 100644 index 00000000..2701b777 --- /dev/null +++ b/src/include/math.h @@ -0,0 +1,274 @@ +/* $NetBSD: math.h,v 1.10 1994/10/26 00:56:05 cgd Exp $ */ + +/* + * ==================================================== + * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. + * + * Developed at SunPro, a Sun Microsystems, Inc. business. + * Permission to use, copy, modify, and distribute this + * software is freely granted, provided that this notice + * is preserved. + * ==================================================== + */ + +/* + * @(#)fdlibm.h 5.1 93/09/24 + */ + +#ifndef _MATH_H_ +#define _MATH_H_ + +/* + * ANSI/POSIX + */ +extern char __infinity[]; +#define HUGE_VAL (*(double *) __infinity) + +/* + * XOPEN/SVID + */ +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +#define M_E 2.7182818284590452354 /* e */ +#define M_LOG2E 1.4426950408889634074 /* log 2e */ +#define M_LOG10E 0.43429448190325182765 /* log 10e */ +#define M_LN2 0.69314718055994530942 /* log e2 */ +#define M_LN10 2.30258509299404568402 /* log e10 */ +#define M_PI 3.14159265358979323846 /* pi */ +#define M_PI_2 1.57079632679489661923 /* pi/2 */ +#define M_PI_4 0.78539816339744830962 /* pi/4 */ +#define M_1_PI 0.31830988618379067154 /* 1/pi */ +#define M_2_PI 0.63661977236758134308 /* 2/pi */ +#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ +#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ +#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ + +#define MAXFLOAT ((float)3.40282346638528860e+38) +extern int signgam; + +#if !defined(_XOPEN_SOURCE) +enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix}; + +#define _LIB_VERSION_TYPE enum fdversion +#define _LIB_VERSION _fdlib_version + +/* if global variable _LIB_VERSION is not desirable, one may + * change the following to be a constant by: + * #define _LIB_VERSION_TYPE const enum version + * In that case, after one initializes the value _LIB_VERSION (see + * s_lib_version.c) during compile time, it cannot be modified + * in the middle of a program + */ +extern _LIB_VERSION_TYPE _LIB_VERSION; + +#define _IEEE_ fdlibm_ieee +#define _SVID_ fdlibm_svid +#define _XOPEN_ fdlibm_xopen +#define _POSIX_ fdlibm_posix + +struct exception { + int type; + char *name; + double arg1; + double arg2; + double retval; +}; + +#define HUGE MAXFLOAT + +/* + * set X_TLOSS = pi*2**52, which is possibly defined in <values.h> + * (one may replace the following line by "#include <values.h>") + */ + +#define X_TLOSS 1.41484755040568800000e+16 + +#define DOMAIN 1 +#define SING 2 +#define OVERFLOW 3 +#define UNDERFLOW 4 +#define TLOSS 5 +#define PLOSS 6 + +#endif /* !_XOPEN_SOURCE */ +#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ + + +#include <sys/cdefs.h> +__BEGIN_DECLS +/* + * ANSI/POSIX + */ +extern double acos __P((double)); +extern double asin __P((double)); +extern double atan __P((double)); +extern double atan2 __P((double, double)); +extern double cos __P((double)); +extern double sin __P((double)); +extern double tan __P((double)); + +extern double cosh __P((double)); +extern double sinh __P((double)); +extern double tanh __P((double)); + +extern double exp __P((double)); +extern double frexp __P((double, int *)); +extern double ldexp __P((double, int)); +extern double log __P((double)); +extern double log10 __P((double)); +extern double modf __P((double, double *)); + +extern double pow __P((double, double)); +extern double sqrt __P((double)); + +extern double ceil __P((double)); +extern double fabs __P((double)); +extern double floor __P((double)); +extern double fmod __P((double, double)); + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +extern double erf __P((double)); +extern double erfc __P((double)); +extern double gamma __P((double)); +extern double hypot __P((double, double)); +extern int isinf __P((double)); +extern int isnan __P((double)); +extern int finite __P((double)); +extern double j0 __P((double)); +extern double j1 __P((double)); +extern double jn __P((int, double)); +extern double lgamma __P((double)); +extern double y0 __P((double)); +extern double y1 __P((double)); +extern double yn __P((int, double)); + +#if !defined(_XOPEN_SOURCE) +extern double acosh __P((double)); +extern double asinh __P((double)); +extern double atanh __P((double)); +extern double cbrt __P((double)); +extern double logb __P((double)); +extern double nextafter __P((double, double)); +extern double remainder __P((double, double)); +extern double scalb __P((double, double)); + +extern int matherr __P((struct exception *)); + +/* + * IEEE Test Vector + */ +extern double significand __P((double)); + +/* + * Functions callable from C, intended to support IEEE arithmetic. + */ +extern double copysign __P((double, double)); +extern int ilogb __P((double)); +extern double rint __P((double)); +extern double scalbn __P((double, int)); + +/* + * BSD math library entry points + */ +extern double cabs(); +extern double drem __P((double, double)); +extern double expm1 __P((double)); +extern double log1p __P((double)); + +/* + * Reentrant version of gamma & lgamma; passes signgam back by reference + * as the second argument; user must allocate space for signgam. + */ +#ifdef _REENTRANT +extern double gamma_r __P((double, int *)); +extern double lgamma_r __P((double, int *)); +#endif /* _REENTRANT */ + + +/* float versions of ANSI/POSIX functions */ +extern float acosf __P((float)); +extern float asinf __P((float)); +extern float atanf __P((float)); +extern float atan2f __P((float, float)); +extern float cosf __P((float)); +extern float sinf __P((float)); +extern float tanf __P((float)); + +extern float coshf __P((float)); +extern float sinhf __P((float)); +extern float tanhf __P((float)); + +extern float expf __P((float)); +extern float frexpf __P((float, int *)); +extern float ldexpf __P((float, int)); +extern float logf __P((float)); +extern float log10f __P((float)); +extern float modff __P((float, float *)); + +extern float powf __P((float, float)); +extern float sqrtf __P((float)); + +extern float ceilf __P((float)); +extern float fabsf __P((float)); +extern float floorf __P((float)); +extern float fmodf __P((float, float)); + +extern float erff __P((float)); +extern float erfcf __P((float)); +extern float gammaf __P((float)); +extern float hypotf __P((float, float)); +extern int isnanf __P((float)); +extern int finitef __P((float)); +extern float j0f __P((float)); +extern float j1f __P((float)); +extern float jnf __P((int, float)); +extern float lgammaf __P((float)); +extern float y0f __P((float)); +extern float y1f __P((float)); +extern float ynf __P((int, float)); + +extern float acoshf __P((float)); +extern float asinhf __P((float)); +extern float atanhf __P((float)); +extern float cbrtf __P((float)); +extern float logbf __P((float)); +extern float nextafterf __P((float, float)); +extern float remainderf __P((float, float)); +extern float scalbf __P((float, float)); + +/* + * float version of IEEE Test Vector + */ +extern float significandf __P((float)); + +/* + * Float versions of functions callable from C, intended to support + * IEEE arithmetic. + */ +extern float copysignf __P((float, float)); +extern int ilogbf __P((float)); +extern float rintf __P((float)); +extern float scalbnf __P((float, int)); + +/* + * float versions of BSD math library entry points + */ +extern float cabsf (); +extern float dremf __P((float, float)); +extern float expm1f __P((float)); +extern float log1pf __P((float)); + +/* + * Float versions of reentrant version of gamma & lgamma; passes + * signgam back by reference as the second argument; user must + * allocate space for signgam. + */ +#ifdef _REENTRANT +extern float gammaf_r __P((float, int *)); +extern float lgammaf_r __P((float, int *)); +#endif /* _REENTRANT */ + +#endif /* !_XOPEN_SOURCE */ +#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ +__END_DECLS + +#endif /* _MATH_H_ */ diff --git a/src/include/memory.h b/src/include/memory.h new file mode 100644 index 00000000..cfd1fdb7 --- /dev/null +++ b/src/include/memory.h @@ -0,0 +1,38 @@ +/* $NetBSD: memory.h,v 1.3 1994/10/26 00:56:06 cgd Exp $ */ + +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)memory.h 5.5 (Berkeley) 6/1/90 + */ + +#include <string.h> diff --git a/src/include/mpool.h b/src/include/mpool.h new file mode 100644 index 00000000..84972975 --- /dev/null +++ b/src/include/mpool.h @@ -0,0 +1,137 @@ +/* $NetBSD: mpool.h,v 1.6 1994/10/26 00:56:07 cgd Exp $ */ + +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)mpool.h 8.1 (Berkeley) 6/2/93 + */ + +/* + * The memory pool scheme is a simple one. Each in memory page is referenced + * by a bucket which is threaded in three ways. All active pages are threaded + * on a hash chain (hashed by the page number) and an lru chain. Inactive + * pages are threaded on a free chain. Each reference to a memory pool is + * handed an MPOOL which is the opaque cookie passed to all of the memory + * routines. + */ +#define HASHSIZE 128 +#define HASHKEY(pgno) ((pgno - 1) % HASHSIZE) + +/* The BKT structures are the elements of the lists. */ +typedef struct BKT { + struct BKT *hnext; /* next hash bucket */ + struct BKT *hprev; /* previous hash bucket */ + struct BKT *cnext; /* next free/lru bucket */ + struct BKT *cprev; /* previous free/lru bucket */ + void *page; /* page */ + pgno_t pgno; /* page number */ + +#define MPOOL_DIRTY 0x01 /* page needs to be written */ +#define MPOOL_PINNED 0x02 /* page is pinned into memory */ + unsigned long flags; /* flags */ +} BKT; + +/* The BKTHDR structures are the heads of the lists. */ +typedef struct BKTHDR { + struct BKT *hnext; /* next hash bucket */ + struct BKT *hprev; /* previous hash bucket */ + struct BKT *cnext; /* next free/lru bucket */ + struct BKT *cprev; /* previous free/lru bucket */ +} BKTHDR; + +typedef struct MPOOL { + BKTHDR free; /* The free list. */ + BKTHDR lru; /* The LRU list. */ + BKTHDR hashtable[HASHSIZE]; /* Hashed list by page number. */ + pgno_t curcache; /* Current number of cached pages. */ + pgno_t maxcache; /* Max number of cached pages. */ + pgno_t npages; /* Number of pages in the file. */ + u_long pagesize; /* File page size. */ + int fd; /* File descriptor. */ + /* Page in conversion routine. */ + void (*pgin) __P((void *, pgno_t, void *)); + /* Page out conversion routine. */ + void (*pgout) __P((void *, pgno_t, void *)); + void *pgcookie; /* Cookie for page in/out routines. */ +#ifdef STATISTICS + unsigned long cachehit; + unsigned long cachemiss; + unsigned long pagealloc; + unsigned long pageflush; + unsigned long pageget; + unsigned long pagenew; + unsigned long pageput; + unsigned long pageread; + unsigned long pagewrite; +#endif +} MPOOL; + +#ifdef __MPOOLINTERFACE_PRIVATE +/* Macros to insert/delete into/from hash chain. */ +#define rmhash(bp) { \ + (bp)->hprev->hnext = (bp)->hnext; \ + (bp)->hnext->hprev = (bp)->hprev; \ +} +#define inshash(bp, pg) { \ + hp = &mp->hashtable[HASHKEY(pg)]; \ + (bp)->hnext = hp->hnext; \ + (bp)->hprev = (struct BKT *)hp; \ + hp->hnext->hprev = (bp); \ + hp->hnext = (bp); \ +} + +/* Macros to insert/delete into/from lru and free chains. */ +#define rmchain(bp) { \ + (bp)->cprev->cnext = (bp)->cnext; \ + (bp)->cnext->cprev = (bp)->cprev; \ +} +#define inschain(bp, dp) { \ + (bp)->cnext = (dp)->cnext; \ + (bp)->cprev = (struct BKT *)(dp); \ + (dp)->cnext->cprev = (bp); \ + (dp)->cnext = (bp); \ +} +#endif + +__BEGIN_DECLS +MPOOL *mpool_open __P((DBT *, int, pgno_t, pgno_t)); +void mpool_filter __P((MPOOL *, void (*)(void *, pgno_t, void *), + void (*)(void *, pgno_t, void *), void *)); +void *mpool_new __P((MPOOL *, pgno_t *)); +void *mpool_get __P((MPOOL *, pgno_t, u_int)); +int mpool_put __P((MPOOL *, void *, u_int)); +int mpool_sync __P((MPOOL *)); +int mpool_close __P((MPOOL *)); +#ifdef STATISTICS +void mpool_stat __P((MPOOL *)); +#endif +__END_DECLS diff --git a/src/include/ndbm.h b/src/include/ndbm.h new file mode 100644 index 00000000..a9c6b301 --- /dev/null +++ b/src/include/ndbm.h @@ -0,0 +1,81 @@ +/* $NetBSD: ndbm.h,v 1.6 1995/07/20 23:31:11 jtc Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Margo Seltzer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ndbm.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _NDBM_H_ +#define _NDBM_H_ + +#include <db.h> + +/* Map dbm interface onto db(3). */ +#define DBM_RDONLY O_RDONLY + +/* Flags to dbm_store(). */ +#define DBM_INSERT 0 +#define DBM_REPLACE 1 + +/* + * The db(3) support for ndbm(3) always appends this suffix to the + * file name to avoid overwriting the user's original database. + */ +#define DBM_SUFFIX ".db" + +typedef struct { + char *dptr; + int dsize; +} datum; + +typedef DB DBM; +#define dbm_pagfno(a) DBM_PAGFNO_NOT_AVAILABLE + +__BEGIN_DECLS +void dbm_close __P((DBM *)); +int dbm_delete __P((DBM *, datum)); +datum dbm_fetch __P((DBM *, datum)); +datum dbm_firstkey __P((DBM *)); +long dbm_forder __P((DBM *, datum)); +datum dbm_nextkey __P((DBM *)); +DBM *dbm_open __P((const char *, int, int)); +int dbm_store __P((DBM *, datum, datum, int)); +int dbm_dirfno __P((DBM *)); +int dbm_error __P((DBM *)); +int dbm_clearerr __P((DBM *)); +__END_DECLS + +#endif /* !_NDBM_H_ */ diff --git a/src/include/netdb.h b/src/include/netdb.h new file mode 100644 index 00000000..ab363d7d --- /dev/null +++ b/src/include/netdb.h @@ -0,0 +1,126 @@ +/* $NetBSD: netdb.h,v 1.5 1995/07/03 22:59:12 jtc Exp $ */ + +/*- + * Copyright (c) 1980, 1983, 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)netdb.h 5.15 (Berkeley) 4/3/91 + */ + +#ifndef _NETDB_H_ +#define _NETDB_H_ + +#define _PATH_HEQUIV "/etc/hosts.equiv" +#define _PATH_HOSTS "/etc/hosts" +#define _PATH_NETWORKS "/etc/networks" +#define _PATH_PROTOCOLS "/etc/protocols" +#define _PATH_SERVICES "/etc/services" + +/* + * 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 # */ +}; + +/* + * Error return codes from gethostbyname() and gethostbyaddr() + * (left in extern int h_errno). + */ + +extern int h_errno; + +#define HOST_NOT_FOUND 1 /* Authoritative 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_DATA 4 /* Valid name, no data record of requested type */ +#define NO_ADDRESS NO_DATA /* no address, look for MX record */ + +#include <sys/cdefs.h> + +__BEGIN_DECLS +void endhostent __P((void)); +void endnetent __P((void)); +void endprotoent __P((void)); +void endservent __P((void)); +struct hostent *gethostbyaddr __P((const char *, int, int)); +struct hostent *gethostbyname __P((const char *)); +struct hostent *gethostent __P((void)); +struct netent *getnetbyaddr __P((long, int)); /* u_long? */ +struct netent *getnetbyname __P((const char *)); +struct netent *getnetent __P((void)); +struct protoent *getprotobyname __P((const char *)); +struct protoent *getprotobynumber __P((int)); +struct protoent *getprotoent __P((void)); +struct servent *getservbyname __P((const char *, const char *)); +struct servent *getservbyport __P((int, const char *)); +struct servent *getservent __P((void)); +void herror __P((const char *)); +char *hstrerror __P((int)); +void sethostent __P((int)); +/* void sethostfile __P((const char *)); */ +void setnetent __P((int)); +void setprotoent __P((int)); +void setservent __P((int)); +__END_DECLS + +#endif /* !_NETDB_H_ */ diff --git a/src/include/netgroup.h b/src/include/netgroup.h new file mode 100644 index 00000000..c29dad39 --- /dev/null +++ b/src/include/netgroup.h @@ -0,0 +1,68 @@ +/* + * Copyright (c) 1994 Christos Zoulas + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Christos Zoulas. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * $Id: netgroup.h,v 1.1.1.1 1995/10/18 08:41:13 deraadt Exp $ + */ +#ifndef _NETGROUP_H_ +#define _NETGROUP_H_ + +#define _PATH_NETGROUP "/etc/netgroup" + +#define _PATH_NETGROUP_DB "/etc/netgroup.db" + +#define _PATH_NETGROUP_MKDB "/usr/sbin/netgroup_mkdb" + +#define _NG_KEYBYNAME '1' /* stored by name */ +#define _NG_KEYBYUSER '2' /* stored by user */ +#define _NG_KEYBYHOST '3' /* stored by host */ + +#define _NG_ERROR -1 +#define _NG_NONE 0 +#define _NG_NAME 1 +#define _NG_GROUP 2 + +struct netgroup { + char *ng_host; /* host name */ + char *ng_user; /* user name */ + char *ng_domain; /* domain name */ + struct netgroup *ng_next; /* thread */ +}; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +void setnetgrent __P((const char *)); +int getnetgrent __P((const char **, const char **, const char **)); +void endnetgrent __P((void)); +int innetgr __P((const char *, const char *, const char *, + const char *)); +__END_DECLS + +#endif /* !_NETGROUP_H_ */ diff --git a/src/include/nl_types.h b/src/include/nl_types.h new file mode 100644 index 00000000..37cbee88 --- /dev/null +++ b/src/include/nl_types.h @@ -0,0 +1,48 @@ +/* $NetBSD: nl_types.h,v 1.5 1995/03/01 08:01:23 jtc Exp $ */ + +/*********************************************************** +Copyright 1990, by Alfalfa Software Incorporated, Cambridge, Massachusetts. + + All Rights Reserved + +Permission to use, copy, modify, and distribute this software and its +documentation for any purpose and without fee is hereby granted, +provided that the above copyright notice appear in all copies and that +both that copyright notice and this permission notice appear in +supporting documentation, and that Alfalfa's name not be used in +advertising or publicity pertaining to distribution of the software +without specific, written prior permission. + +ALPHALPHA DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING +ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL +ALPHALPHA BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR +ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, +WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, +ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS +SOFTWARE. + +If you make any modifications, bugfixes or other changes to this software +we'd appreciate it if you could send a copy to us so we can keep things +up-to-date. Many thanks. + Kee Hinckley + Alfalfa Software, Inc. + 267 Allston St., #3 + Cambridge, MA 02139 USA + nazgul@alfalfa.com + +******************************************************************/ + +#ifndef _NL_TYPES_H_ +#define _NL_TYPES_H_ +#include <sys/cdefs.h> + +#define NL_SETD 0 + +typedef long nl_catd; +typedef long nl_item; + +extern nl_catd catopen __P((__const char *, int)); +extern char *catgets __P((nl_catd, int, int, char *)); +extern int catclose __P((nl_catd)); + +#endif /* _NL_TYPES_H_ */ diff --git a/src/include/nlist.h b/src/include/nlist.h new file mode 100644 index 00000000..e9c1691c --- /dev/null +++ b/src/include/nlist.h @@ -0,0 +1,90 @@ +/* $NetBSD: nlist.h,v 1.5 1994/10/26 00:56:11 cgd Exp $ */ + +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)nlist.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _NLIST_H_ +#define _NLIST_H_ + +/* + * Symbol table entry format. The #ifdef's are so that programs including + * nlist.h can initialize nlist structures statically. + */ +struct nlist { +#ifdef _AOUT_INCLUDE_ + union { + char *n_name; /* symbol name (in memory) */ + long n_strx; /* file string table offset (on disk) */ + } n_un; +#else + char *n_name; /* symbol name (in memory) */ +#endif + +#define N_UNDF 0x00 /* undefined */ +#define N_ABS 0x02 /* absolute address */ +#define N_TEXT 0x04 /* text segment */ +#define N_DATA 0x06 /* data segment */ +#define N_BSS 0x08 /* bss segment */ +#define N_INDR 0x0a /* alias definition */ +#define N_SIZE 0x0c /* pseudo type, defines a symbol's size */ +#define N_COMM 0x12 /* common reference */ +#define N_FN 0x1e /* file name (N_EXT on) */ +#define N_WARN 0x1e /* warning message (N_EXT off) */ + +#define N_EXT 0x01 /* external (global) bit, OR'ed in */ +#define N_TYPE 0x1e /* mask for all the type bits */ + unsigned char n_type; /* type defines */ + + char n_other; /* spare */ +#define n_hash n_desc /* used internally by ld(1); XXX */ + short n_desc; /* used by stab entries */ + unsigned long n_value; /* address/value of the symbol */ +}; + +#define N_FORMAT "%08x" /* namelist value format; XXX */ +#define N_STAB 0x0e0 /* mask for debugger symbols -- stab(5) */ + +#include <sys/cdefs.h> + +__BEGIN_DECLS +int nlist __P((const char *, struct nlist *)); +__END_DECLS + +#endif /* !_NLIST_H_ */ diff --git a/src/include/paths.h b/src/include/paths.h new file mode 100644 index 00000000..95e6532e --- /dev/null +++ b/src/include/paths.h @@ -0,0 +1,72 @@ +/* $NetBSD: paths.h,v 1.7 1994/10/26 00:56:12 cgd Exp $ */ + +/* + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)paths.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _PATHS_H_ +#define _PATHS_H_ + +/* Default search path. */ +#define _PATH_DEFPATH "/usr/bin:/bin" +/* All standard utilities path. */ +#define _PATH_STDPATH \ + "/usr/bin:/bin:/usr/sbin:/sbin:/usr/contrib/bin:/usr/old/bin" + +#define _PATH_BSHELL "/bin/sh" +#define _PATH_CONSOLE "/dev/console" +#define _PATH_CSHELL "/bin/csh" +#define _PATH_DEVDB "/var/run/dev.db" +#define _PATH_DEVNULL "/dev/null" +#define _PATH_DRUM "/dev/drum" +#define _PATH_KMEM "/dev/kmem" +#define _PATH_LOCALE "/usr/share/locale" +#define _PATH_MAILDIR "/var/mail" +#define _PATH_MAN "/usr/share/man" +#define _PATH_MEM "/dev/mem" +#define _PATH_NOLOGIN "/etc/nologin" +#define _PATH_SENDMAIL "/usr/sbin/sendmail" +#define _PATH_SHELLS "/etc/shells" +#define _PATH_TTY "/dev/tty" +#define _PATH_UNIX "/netbsd" +#define _PATH_VI "/usr/bin/vi" + +/* Provide trailing slash, since mostly used for building pathnames. */ +#define _PATH_DEV "/dev/" +#define _PATH_TMP "/tmp/" +#define _PATH_VARDB "/var/db/" +#define _PATH_VARRUN "/var/run/" +#define _PATH_VARTMP "/var/tmp/" + +#endif /* !_PATHS_H_ */ diff --git a/src/include/protocols/dumprestore.h b/src/include/protocols/dumprestore.h new file mode 100644 index 00000000..bc014cef --- /dev/null +++ b/src/include/protocols/dumprestore.h @@ -0,0 +1,114 @@ +/* $NetBSD: dumprestore.h,v 1.6 1994/10/26 00:56:49 cgd Exp $ */ + +/* + * Copyright (c) 1980, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)dumprestore.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _DUMPRESTORE_H_ +#define _DUMPRESTORE_H_ + +/* + * 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 LBLSIZE 16 +#define NAMELEN 64 + +#define OFS_MAGIC (int)60011 +#define NFS_MAGIC (int)60012 +#define CHECKSUM (int)84446 + +union u_spcl { + char dummy[TP_BSIZE]; + struct s_spcl { + long c_type; /* record type (see below) */ + time_t c_date; /* date of this dump */ + time_t c_ddate; /* date of previous dump */ + long c_volume; /* dump volume number */ + daddr_t c_tapea; /* logical block of this record */ + ino_t c_inumber; /* number of inode */ + long c_magic; /* magic number (see above) */ + long c_checksum; /* record checksum */ + struct dinode c_dinode; /* ownership and mode of inode */ + long c_count; /* number of valid c_addr entries */ + char c_addr[TP_NINDIR]; /* 1 => data; 0 => hole in inode */ + char c_label[LBLSIZE]; /* dump label */ + long c_level; /* level of this dump */ + char c_filesys[NAMELEN]; /* name of dumpped file system */ + char c_dev[NAMELEN]; /* name of dumpped device */ + char c_host[NAMELEN]; /* name of dumpped host */ + long c_flags; /* additional information */ + long c_firstrec; /* first record on volume */ + long c_spare[32]; /* reserved for future uses */ + } s_spcl; +} u_spcl; +#define spcl u_spcl.s_spcl +/* + * special record types + */ +#define TS_TAPE 1 /* dump tape header */ +#define TS_INODE 2 /* beginning of file record */ +#define TS_ADDR 4 /* continuation of file record */ +#define TS_BITS 3 /* map of inodes on tape */ +#define TS_CLRI 6 /* map of inodes deleted since last dump */ +#define TS_END 5 /* end of volume marker */ + +/* + * flag values + */ +#define DR_NEWHEADER 0x0001 /* new format tape header */ +#define DR_NEWINODEFMT 0x0002 /* new format inodes on tape */ + +#define DUMPOUTFMT "%-16s %c %s" /* for printf */ + /* name, level, ctime(date) */ +#define DUMPINFMT "%16s %c %[^\n]\n" /* inverse for scanf */ + +#endif /* !_DUMPRESTORE_H_ */ diff --git a/src/include/protocols/routed.h b/src/include/protocols/routed.h new file mode 100644 index 00000000..d2fd8aa5 --- /dev/null +++ b/src/include/protocols/routed.h @@ -0,0 +1,113 @@ +/* $NetBSD: routed.h,v 1.4 1995/06/20 22:22:04 christos Exp $ */ + +/*- + * Copyright (c) 1983, 1989 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)routed.h 5.3 (Berkeley) 4/3/91 + */ + +#ifndef _ROUTED_H_ +#define _ROUTED_H_ + +/* + * 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 RIP_VERSION_0 0 +#define RIP_VERSION_1 1 +#define RIP_VERSION_2 2 + +struct netinfo { + u_int16_t rip_family; + u_int16_t rip_tag; + u_int32_t rip_dst; /* destination net/host */ + /* Version 2 specific info */ + u_int32_t rip_netmask; + u_int32_t rip_router; + u_int32_t 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. + * Complete tables are broadcast every SUPPLY_INTERVAL seconds. + * If changes occur between updates, dynamic updates containing only changes + * may be sent. When these are sent, a timer is set for a random value + * between MIN_WAITTIME and MAX_WAITTIME, and no additional dynamic updates + * are sent until the timer expires. + * + * Every update of a routing entry 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 MIN_WAITTIME 2 /* min. interval to broadcast changes */ +#define MAX_WAITTIME 5 /* max. time to delay changes */ + +#define EXPIRE_TIME 180 /* time to mark entry invalid */ +#define GARBAGE_TIME 240 /* time to garbage collect */ + +#endif /* !_ROUTED_H_ */ diff --git a/src/include/protocols/rwhod.h b/src/include/protocols/rwhod.h new file mode 100644 index 00000000..3833e59f --- /dev/null +++ b/src/include/protocols/rwhod.h @@ -0,0 +1,70 @@ +/* $NetBSD: rwhod.h,v 1.3 1994/10/26 00:56:51 cgd Exp $ */ + +/* + * Copyright (c) 1983 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)rwhod.h 5.6 (Berkeley) 4/3/91 + */ + +#ifndef _RWHOD_H_ +#define _RWHOD_H_ + +/* + * 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 */ + +#define _PATH_RWHODIR "/var/rwho" + +#endif /* !_RWHOD_H_ */ diff --git a/src/include/protocols/talkd.h b/src/include/protocols/talkd.h new file mode 100644 index 00000000..eea5a0ea --- /dev/null +++ b/src/include/protocols/talkd.h @@ -0,0 +1,116 @@ +/* $NetBSD: talkd.h,v 1.5 1995/03/04 07:59:30 cgd Exp $ */ + +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)talkd.h 5.7 (Berkeley) 4/3/91 + */ + +#ifndef _TALKD_H_ +#define _TALKD_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_int32_t id_num; /* message id */ + struct osockaddr addr; /* old (4.3) style */ + struct osockaddr ctl_addr; /* old (4.3) style */ + int32_t 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_int32_t id_num; /* message id */ + struct osockaddr 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 */ + +#endif /* !_TALKD_H_ */ diff --git a/src/include/protocols/timed.h b/src/include/protocols/timed.h new file mode 100644 index 00000000..427adffe --- /dev/null +++ b/src/include/protocols/timed.h @@ -0,0 +1,101 @@ +/* $NetBSD: timed.h,v 1.3 1994/10/26 00:56:53 cgd Exp $ */ + +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)timed.h 1.10 (Berkeley) 4/3/91 + */ + +#ifndef _TIMED_H_ +#define _TIMED_H_ + +/* + * 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 + +#endif /* !_TIMED_H_ */ diff --git a/src/include/pwd.h b/src/include/pwd.h new file mode 100644 index 00000000..767ae19d --- /dev/null +++ b/src/include/pwd.h @@ -0,0 +1,102 @@ +/* $NetBSD: pwd.h,v 1.8 1995/07/28 05:30:52 phil Exp $ */ + +/*- + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * Portions Copyright(C) 1995, Jason Downs. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)pwd.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _PWD_H_ +#define _PWD_H_ + +#include <sys/types.h> + +#ifndef _POSIX_SOURCE +#define _PATH_PASSWD "/etc/passwd" +#define _PATH_MASTERPASSWD "/etc/master.passwd" + +#define _PATH_MP_DB "/etc/pwd.db" +#define _PATH_SMP_DB "/etc/spwd.db" + +#define _PATH_PWD_MKDB "/usr/sbin/pwd_mkdb" + +#define _PW_KEYBYNAME '1' /* stored by name */ +#define _PW_KEYBYNUM '2' /* stored by entry in the "file" */ +#define _PW_KEYBYUID '3' /* stored by uid */ + +#define _PASSWORD_EFMT1 '_' /* extended encryption format */ + +#define _PASSWORD_LEN 128 /* max length, not counting NULL */ + +#define _PASSWORD_NOUID 0x01 /* flag for no specified uid. */ +#define _PASSWORD_NOGID 0x02 /* flag for no specified gid. */ +#define _PASSWORD_NOCHG 0x04 /* flag for no specified change. */ +#define _PASSWORD_NOEXP 0x08 /* flag for no specified expire. */ + +#endif + +struct passwd { + char *pw_name; /* user name */ + char *pw_passwd; /* encrypted password */ + int pw_uid; /* user uid */ + int pw_gid; /* user gid */ + time_t pw_change; /* password change time */ + char *pw_class; /* user access class */ + char *pw_gecos; /* Honeywell login info */ + char *pw_dir; /* home directory */ + char *pw_shell; /* default shell */ + time_t pw_expire; /* account expiration */ +}; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +struct passwd *getpwuid __P((uid_t)); +struct passwd *getpwnam __P((const char *)); +#ifndef _POSIX_SOURCE +struct passwd *getpwent __P((void)); +#ifndef _XOPEN_SOURCE +int setpassent __P((int)); +char *user_from_uid __P((uid_t, int)); +#endif +void setpwent __P((void)); +void endpwent __P((void)); +#endif +__END_DECLS + +#endif /* !_PWD_H_ */ diff --git a/src/include/ranlib.h b/src/include/ranlib.h new file mode 100644 index 00000000..894def33 --- /dev/null +++ b/src/include/ranlib.h @@ -0,0 +1,52 @@ +/* $NetBSD: ranlib.h,v 1.4 1994/10/26 00:56:14 cgd Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ranlib.h 5.2 (Berkeley) 4/3/91 + */ + +#ifndef _RANLIB_H_ +#define _RANLIB_H_ + +#define RANLIBMAG "__.SYMDEF" /* archive file name */ +#define RANLIBSKEW 3 /* creation time offset */ + +struct ranlib { + union { + long ran_strx; /* string table index */ + char *ran_name; /* in memory symbol name */ + } ran_un; + long ran_off; /* archive file offset */ +}; + +#endif /* !_RANLIB_H_ */ diff --git a/src/include/regex.h b/src/include/regex.h new file mode 100644 index 00000000..bcc3e575 --- /dev/null +++ b/src/include/regex.h @@ -0,0 +1,108 @@ +/* $NetBSD: regex.h,v 1.4 1994/10/26 00:56:14 cgd Exp $ */ + +/*- + * Copyright (c) 1992 Henry Spencer. + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Henry Spencer of the University of Toronto. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)regex.h 8.1 (Berkeley) 6/2/93 + */ + +#ifndef _REGEX_H_ +#define _REGEX_H_ + +#include <sys/cdefs.h> + +/* types */ +typedef off_t regoff_t; + +typedef struct { + int re_magic; + size_t re_nsub; /* number of parenthesized subexpressions */ + const char *re_endp; /* end pointer for REG_PEND */ + struct re_guts *re_g; /* none of your business :-) */ +} regex_t; + +typedef struct { + regoff_t rm_so; /* start of match */ + regoff_t rm_eo; /* end of match */ +} regmatch_t; + +/* regcomp() flags */ +#define REG_BASIC 0000 +#define REG_EXTENDED 0001 +#define REG_ICASE 0002 +#define REG_NOSUB 0004 +#define REG_NEWLINE 0010 +#define REG_NOSPEC 0020 +#define REG_PEND 0040 +#define REG_DUMP 0200 + +/* regerror() flags */ +#define REG_NOMATCH 1 +#define REG_BADPAT 2 +#define REG_ECOLLATE 3 +#define REG_ECTYPE 4 +#define REG_EESCAPE 5 +#define REG_ESUBREG 6 +#define REG_EBRACK 7 +#define REG_EPAREN 8 +#define REG_EBRACE 9 +#define REG_BADBR 10 +#define REG_ERANGE 11 +#define REG_ESPACE 12 +#define REG_BADRPT 13 +#define REG_EMPTY 14 +#define REG_ASSERT 15 +#define REG_INVARG 16 +#define REG_ATOI 255 /* convert name to number (!) */ +#define REG_ITOA 0400 /* convert number to name (!) */ + +/* regexec() flags */ +#define REG_NOTBOL 00001 +#define REG_NOTEOL 00002 +#define REG_STARTEND 00004 +#define REG_TRACE 00400 /* tracing of execution */ +#define REG_LARGE 01000 /* force large representation */ +#define REG_BACKR 02000 /* force use of backref code */ + +__BEGIN_DECLS +int regcomp __P((regex_t *, const char *, int)); +size_t regerror __P((int, const regex_t *, char *, size_t)); +int regexec __P((const regex_t *, + const char *, size_t, regmatch_t [], int)); +void regfree __P((regex_t *)); +__END_DECLS + +#endif /* !_REGEX_H_ */ diff --git a/src/include/regexp.h b/src/include/regexp.h new file mode 100644 index 00000000..c1b6c3a1 --- /dev/null +++ b/src/include/regexp.h @@ -0,0 +1,71 @@ +/* $NetBSD: regexp.h,v 1.3 1994/10/26 00:56:15 cgd Exp $ */ + +/* + * Copyright (c) 1986 by University of Toronto. + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley + * by Henry Spencer. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)regexp.h 5.2 (Berkeley) 4/3/91 + */ + +#ifndef _REGEXP_H_ +#define _REGEXP_H_ + +/* + * Definitions etc. for regexp(3) routines. + * + * Caveat: this is V8 regexp(3) [actually, a reimplementation thereof], + * not the System V one. + */ +#define NSUBEXP 10 +typedef struct regexp { + char *startp[NSUBEXP]; + char *endp[NSUBEXP]; + char regstart; /* Internal use only. */ + char reganch; /* Internal use only. */ + char *regmust; /* Internal use only. */ + int regmlen; /* Internal use only. */ + char program[1]; /* Unwarranted chumminess with compiler. */ +} regexp; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +regexp *regcomp __P((const char *)); +int regexec __P((const regexp *, const char *)); +void regsub __P((const regexp *, const char *, char *)); +void regerror __P((const char *)); +__END_DECLS + +#endif /* !_REGEXP_H_ */ diff --git a/src/include/resolv.h b/src/include/resolv.h new file mode 100644 index 00000000..4d2e543b --- /dev/null +++ b/src/include/resolv.h @@ -0,0 +1,166 @@ +/* $NetBSD: resolv.h,v 1.8 1994/10/26 00:56:16 cgd Exp $ */ + +/* + * Copyright (c) 1983, 1987, 1989 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)resolv.h 5.15 (Berkeley) 4/3/91 + */ + +#ifndef _RESOLV_H_ +#define _RESOLV_H_ + +/* + * revision information. this is the release date in YYYYMMDD format. + * it can change every day so the right thing to do with it is use it + * in preprocessor commands such as "#if (__RES > 19931104)". do not + * compare for equality; rather, use it to determine whether your resolver + * is new enough to contain a certain feature. + */ + +#define __RES 19931104 + +/* + * Resolver configuration file. + * Normally not present, but may contain the address of the + * inital name server(s) to query and the domain search list. + */ + +#ifndef _PATH_RESCONF +#define _PATH_RESCONF "/etc/resolv.conf" +#endif + +/* + * Global defines and variables for resolver stub. + */ +#define MAXNS 3 /* max # name servers we'll track */ +#define MAXDFLSRCH 3 /* # default domain levels to try */ +#define MAXDNSRCH 6 /* max # domains in search path */ +#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */ +#define MAXDNSLUS 4 /* max # of host lookup types */ + +#define RES_TIMEOUT 5 /* min. seconds between retries */ +#define MAXRESOLVSORT 10 /* number of net to sort on */ +#define RES_MAXNDOTS 15 /* should reflect bit field size */ + +struct __res_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 *dnsrch[MAXDNSRCH+1]; /* components of domain to search */ + char defdname[MAXDNAME]; /* default domain */ + long pfcode; /* RES_PRF_ flags - see below. */ + u_char ndots:4; /* threshold for initial abs. query */ + u_char nsort:4; /* number of elements in sort_list[] */ + char unused[3]; + struct { + struct in_addr addr; + u_int32_t mask; + } sort_list[MAXRESOLVSORT]; + char lookups[MAXDNSLUS]; +}; + +/* + * 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 */ +#define RES_DNSRCH 0x0200 /* search up local domain tree */ + +#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH) + +/* + * Resolver "pfcode" values. Used by dig. + */ +#define RES_PRF_STATS 0x0001 +/* 0x0002 */ +#define RES_PRF_CLASS 0x0004 +#define RES_PRF_CMD 0x0008 +#define RES_PRF_QUES 0x0010 +#define RES_PRF_ANS 0x0020 +#define RES_PRF_AUTH 0x0040 +#define RES_PRF_ADD 0x0080 +#define RES_PRF_HEAD1 0x0100 +#define RES_PRF_HEAD2 0x0200 +#define RES_PRF_TTLID 0x0400 +#define RES_PRF_HEADX 0x0800 +#define RES_PRF_QUERY 0x1000 +#define RES_PRF_REPLY 0x2000 +#define RES_PRF_INIT 0x4000 +/* 0x8000 */ + +extern struct __res_state _res; + +#include <sys/cdefs.h> +#include <stdio.h> + +/* Private routines shared between libc/net, named, nslookup and others. */ +#define dn_skipname __dn_skipname +#define fp_query __fp_query +#define hostalias __hostalias +#define putlong __putlong +#define putshort __putshort +#define p_class __p_class +#define p_time __p_time +#define p_type __p_type +__BEGIN_DECLS +int __dn_skipname __P((const u_char *, const u_char *)); +void __fp_query __P((char *, FILE *)); +char *__hostalias __P((const char *)); +void __putlong __P((u_int32_t, u_char *)); +void __putshort __P((u_int16_t, u_char *)); +char *__p_class __P((int)); +char *__p_time __P((u_int32_t)); +char *__p_type __P((int)); + +int dn_comp __P((const u_char *, u_char *, int, u_char **, u_char **)); +int dn_expand __P((const u_char *, const u_char *, const u_char *, + u_char *, int)); +int res_init __P((void)); +int res_query __P((char *, int, int, u_char *, int)); +int res_search __P((const char *, int, int, u_char *, int)); +int res_mkquery __P((int, const char *, int, int, const char *, int, + const char *, char *, int)); +int res_send __P((const char *, int, char *, int)); +__END_DECLS + +#endif /* !_RESOLV_H_ */ diff --git a/src/include/rpc/auth.h b/src/include/rpc/auth.h new file mode 100644 index 00000000..7f7f0c70 --- /dev/null +++ b/src/include/rpc/auth.h @@ -0,0 +1,184 @@ +/* $NetBSD: auth.h,v 1.7 1995/04/29 05:27:55 cgd Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)auth.h 1.17 88/02/08 SMI + * @(#)auth.h 2.3 88/08/07 4.0 RPCSRC + */ + +/* + * auth.h, Authentication interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The data structures are completely opaque to the client. The client + * is required to pass a AUTH * to routines that create rpc + * "sessions". + */ + +#ifndef _RPC_AUTH_H +#define _RPC_AUTH_H +#include <sys/cdefs.h> + +#define MAX_AUTH_BYTES 400 +#define MAXNETNAMELEN 255 /* maximum length of network user's name */ + +/* + * Status returned from authentication check + */ +enum auth_stat { + AUTH_OK=0, + /* + * failed at remote end + */ + AUTH_BADCRED=1, /* bogus credentials (seal broken) */ + AUTH_REJECTEDCRED=2, /* client should begin new session */ + AUTH_BADVERF=3, /* bogus verifier (seal broken) */ + AUTH_REJECTEDVERF=4, /* verifier expired or was replayed */ + AUTH_TOOWEAK=5, /* rejected due to security reasons */ + /* + * failed locally + */ + AUTH_INVALIDRESP=6, /* bogus response verifier */ + AUTH_FAILED=7 /* some unknown reason */ +}; + +typedef u_int32_t u_int32; /* 32-bit unsigned integers */ + +union des_block { + struct { + u_int32 high; + u_int32 low; + } key; + char c[8]; +}; +typedef union des_block des_block; +__BEGIN_DECLS +extern bool_t xdr_des_block __P((XDR *, des_block *)); +__END_DECLS + +/* + * Authentication info. Opaque to client. + */ +struct opaque_auth { + enum_t oa_flavor; /* flavor of auth */ + caddr_t oa_base; /* address of more auth stuff */ + u_int oa_length; /* not to exceed MAX_AUTH_BYTES */ +}; + + +/* + * Auth handle, interface to client side authenticators. + */ +typedef struct __rpc_auth { + struct opaque_auth ah_cred; + struct opaque_auth ah_verf; + union des_block ah_key; + struct auth_ops { + void (*ah_nextverf) __P((struct __rpc_auth *)); + /* nextverf & serialize */ + int (*ah_marshal) __P((struct __rpc_auth *, XDR *)); + /* validate varifier */ + int (*ah_validate) __P((struct __rpc_auth *, + struct opaque_auth *)); + /* refresh credentials */ + int (*ah_refresh) __P((struct __rpc_auth *)); + /* destroy this structure */ + void (*ah_destroy) __P((struct __rpc_auth *)); + } *ah_ops; + caddr_t ah_private; +} AUTH; + + +/* + * Authentication ops. + * The ops and the auth handle provide the interface to the authenticators. + * + * AUTH *auth; + * XDR *xdrs; + * struct opaque_auth verf; + */ +#define AUTH_NEXTVERF(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) +#define auth_nextverf(auth) \ + ((*((auth)->ah_ops->ah_nextverf))(auth)) + +#define AUTH_MARSHALL(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) +#define auth_marshall(auth, xdrs) \ + ((*((auth)->ah_ops->ah_marshal))(auth, xdrs)) + +#define AUTH_VALIDATE(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) +#define auth_validate(auth, verfp) \ + ((*((auth)->ah_ops->ah_validate))((auth), verfp)) + +#define AUTH_REFRESH(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) +#define auth_refresh(auth) \ + ((*((auth)->ah_ops->ah_refresh))(auth)) + +#define AUTH_DESTROY(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) +#define auth_destroy(auth) \ + ((*((auth)->ah_ops->ah_destroy))(auth)) + + +extern struct opaque_auth _null_auth; + + +/* + * These are the various implementations of client side authenticators. + */ + +/* + * Unix style authentication + * AUTH *authunix_create(machname, uid, gid, len, aup_gids) + * char *machname; + * int uid; + * int gid; + * int len; + * int *aup_gids; + */ +__BEGIN_DECLS +struct sockaddr_in; +extern AUTH *authunix_create __P((char *, int, int, int, int *)); +extern AUTH *authunix_create_default __P((void)); +extern AUTH *authnone_create __P((void)); +extern AUTH *authdes_create __P((char *, u_int, + struct sockaddr_in *, des_block *)); +__END_DECLS + +#define AUTH_NONE 0 /* no authentication */ +#define AUTH_NULL 0 /* backward compatibility */ +#define AUTH_UNIX 1 /* unix style (uid, gids) */ +#define AUTH_SHORT 2 /* short hand unix style */ +#define AUTH_DES 3 /* des style (encrypted timestamps) */ + +#endif /* !_RPC_AUTH_H */ diff --git a/src/include/rpc/auth_unix.h b/src/include/rpc/auth_unix.h new file mode 100644 index 00000000..9c3e76b7 --- /dev/null +++ b/src/include/rpc/auth_unix.h @@ -0,0 +1,83 @@ +/* $NetBSD: auth_unix.h,v 1.4 1994/10/26 00:56:56 cgd Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)auth_unix.h 1.8 88/02/08 SMI + * @(#)auth_unix.h 2.2 88/07/29 4.0 RPCSRC + */ + +/* + * auth_unix.h, Protocol for UNIX style authentication parameters for RPC + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +/* + * The system is very weak. The client uses no encryption for it + * credentials and only sends null verifiers. The server sends backs + * null verifiers or optionally a verifier that suggests a new short hand + * for the credentials. + */ + +#ifndef _RPC_AUTH_UNIX_H +#define _RPC_AUTH_UNIX_H +#include <sys/cdefs.h> + +/* The machine name is part of a credential; it may not exceed 255 bytes */ +#define MAX_MACHINE_NAME 255 + +/* gids compose part of a credential; there may not be more than 16 of them */ +#define NGRPS 16 + +/* + * Unix style credentials. + */ +struct authunix_parms { + u_long aup_time; + char *aup_machname; + int aup_uid; + int aup_gid; + u_int aup_len; + int *aup_gids; +}; + +__BEGIN_DECLS +extern bool_t xdr_authunix_parms __P((XDR *, struct authunix_parms *)); +__END_DECLS + +/* + * If a response verifier has flavor AUTH_SHORT, + * then the body of the response verifier encapsulates the following structure; + * again it is serialized in the obvious fashion. + */ +struct short_hand_verf { + struct opaque_auth new_cred; +}; + +#endif /* !_RPC_AUTH_UNIX_H */ diff --git a/src/include/rpc/clnt.h b/src/include/rpc/clnt.h new file mode 100644 index 00000000..b2fc7e27 --- /dev/null +++ b/src/include/rpc/clnt.h @@ -0,0 +1,372 @@ +/* $NetBSD: clnt.h,v 1.6 1995/04/29 05:27:58 cgd Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)clnt.h 1.31 88/02/08 SMI + * @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC + */ + +/* + * clnt.h - Client side remote procedure call interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_CLNT_H_ +#define _RPC_CLNT_H_ +#include <sys/cdefs.h> + +/* + * Rpc calls return an enum clnt_stat. This should be looked at more, + * since each implementation is required to live with this (implementation + * independent) list of errors. + */ +enum clnt_stat { + RPC_SUCCESS=0, /* call succeeded */ + /* + * local errors + */ + RPC_CANTENCODEARGS=1, /* can't encode arguments */ + RPC_CANTDECODERES=2, /* can't decode results */ + RPC_CANTSEND=3, /* failure in sending call */ + RPC_CANTRECV=4, /* failure in receiving result */ + RPC_TIMEDOUT=5, /* call timed out */ + /* + * remote errors + */ + RPC_VERSMISMATCH=6, /* rpc versions not compatible */ + RPC_AUTHERROR=7, /* authentication error */ + RPC_PROGUNAVAIL=8, /* program not available */ + RPC_PROGVERSMISMATCH=9, /* program version mismatched */ + RPC_PROCUNAVAIL=10, /* procedure unavailable */ + RPC_CANTDECODEARGS=11, /* decode arguments error */ + RPC_SYSTEMERROR=12, /* generic "other problem" */ + + /* + * callrpc & clnt_create errors + */ + RPC_UNKNOWNHOST=13, /* unknown host name */ + RPC_UNKNOWNPROTO=17, /* unkown protocol */ + + /* + * _ create errors + */ + RPC_PMAPFAILURE=14, /* the pmapper failed in its call */ + RPC_PROGNOTREGISTERED=15, /* remote program is not registered */ + /* + * unspecified error + */ + RPC_FAILED=16 +}; + + +/* + * Error info. + */ +struct rpc_err { + enum clnt_stat re_status; + union { + int RE_errno; /* realated system error */ + enum auth_stat RE_why; /* why the auth error occurred */ + struct { + u_int32_t low; /* lowest verion supported */ + u_int32_t high; /* highest verion supported */ + } RE_vers; + struct { /* maybe meaningful if RPC_FAILED */ + int32_t s1; + int32_t s2; + } RE_lb; /* life boot & debugging only */ + } ru; +#define re_errno ru.RE_errno +#define re_why ru.RE_why +#define re_vers ru.RE_vers +#define re_lb ru.RE_lb +}; + + +/* + * Client rpc handle. + * Created by individual implementations, see e.g. rpc_udp.c. + * Client is responsible for initializing auth, see e.g. auth_none.c. + */ +typedef struct __rpc_client { + AUTH *cl_auth; /* authenticator */ + struct clnt_ops { + /* call remote procedure */ + enum clnt_stat (*cl_call) __P((struct __rpc_client *, + u_long, xdrproc_t, caddr_t, xdrproc_t, + caddr_t, struct timeval)); + /* abort a call */ + void (*cl_abort) __P((struct __rpc_client *)); + /* get specific error code */ + void (*cl_geterr) __P((struct __rpc_client *, + struct rpc_err *)); + /* frees results */ + bool_t (*cl_freeres) __P((struct __rpc_client *, + xdrproc_t, caddr_t)); + /* destroy this structure */ + void (*cl_destroy) __P((struct __rpc_client *)); + /* the ioctl() of rpc */ + bool_t (*cl_control) __P((struct __rpc_client *, u_int, + char *)); + } *cl_ops; + caddr_t cl_private; /* private stuff */ +} CLIENT; + + +/* + * client side rpc interface ops + * + * Parameter types are: + * + */ + +/* + * enum clnt_stat + * CLNT_CALL(rh, proc, xargs, argsp, xres, resp, timeout) + * CLIENT *rh; + * u_long proc; + * xdrproc_t xargs; + * caddr_t argsp; + * xdrproc_t xres; + * caddr_t resp; + * struct timeval timeout; + */ +#define CLNT_CALL(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, (caddr_t)argsp, \ + xres, (caddr_t)resp, secs)) +#define clnt_call(rh, proc, xargs, argsp, xres, resp, secs) \ + ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, (caddr_t)argsp, \ + xres, (caddr_t)resp, secs)) + +/* + * void + * CLNT_ABORT(rh); + * CLIENT *rh; + */ +#define CLNT_ABORT(rh) ((*(rh)->cl_ops->cl_abort)(rh)) +#define clnt_abort(rh) ((*(rh)->cl_ops->cl_abort)(rh)) + +/* + * struct rpc_err + * CLNT_GETERR(rh); + * CLIENT *rh; + */ +#define CLNT_GETERR(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) +#define clnt_geterr(rh,errp) ((*(rh)->cl_ops->cl_geterr)(rh, errp)) + + +/* + * bool_t + * CLNT_FREERES(rh, xres, resp); + * CLIENT *rh; + * xdrproc_t xres; + * caddr_t resp; + */ +#define CLNT_FREERES(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) +#define clnt_freeres(rh,xres,resp) ((*(rh)->cl_ops->cl_freeres)(rh,xres,resp)) + +/* + * bool_t + * CLNT_CONTROL(cl, request, info) + * CLIENT *cl; + * u_int request; + * char *info; + */ +#define CLNT_CONTROL(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) +#define clnt_control(cl,rq,in) ((*(cl)->cl_ops->cl_control)(cl,rq,in)) + +/* + * control operations that apply to both udp and tcp transports + */ +#define CLSET_TIMEOUT 1 /* set timeout (timeval) */ +#define CLGET_TIMEOUT 2 /* get timeout (timeval) */ +#define CLGET_SERVER_ADDR 3 /* get server's address (sockaddr) */ +/* + * udp only control operations + */ +#define CLSET_RETRY_TIMEOUT 4 /* set retry timeout (timeval) */ +#define CLGET_RETRY_TIMEOUT 5 /* get retry timeout (timeval) */ + +/* + * void + * CLNT_DESTROY(rh); + * CLIENT *rh; + */ +#define CLNT_DESTROY(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) +#define clnt_destroy(rh) ((*(rh)->cl_ops->cl_destroy)(rh)) + + +/* + * RPCTEST is a test program which is accessable on every rpc + * transport/port. It is used for testing, performance evaluation, + * and network administration. + */ + +#define RPCTEST_PROGRAM ((u_long)1) +#define RPCTEST_VERSION ((u_long)1) +#define RPCTEST_NULL_PROC ((u_long)2) +#define RPCTEST_NULL_BATCH_PROC ((u_long)3) + +/* + * By convention, procedure 0 takes null arguments and returns them + */ + +#define NULLPROC ((u_long)0) + +/* + * Below are the client handle creation routines for the various + * implementations of client side rpc. They can return NULL if a + * creation failure occurs. + */ + +/* + * Memory based rpc (for speed check and testing) + * CLIENT * + * clntraw_create(prog, vers) + * u_long prog; + * u_long vers; + */ +__BEGIN_DECLS +extern CLIENT *clntraw_create __P((u_long, u_long)); +__END_DECLS + + +/* + * Generic client creation routine. Supported protocols are "udp" and "tcp" + * CLIENT * + * clnt_create(host, prog, vers, prot); + * char *host; -- hostname + * u_long prog; -- program number + * u_long vers; -- version number + * char *prot; -- protocol + */ +__BEGIN_DECLS +extern CLIENT *clnt_create __P((char *, u_long, u_long, char *)); +__END_DECLS + + +/* + * TCP based rpc + * CLIENT * + * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * u_long prog; + * u_long version; + * register int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +__BEGIN_DECLS +extern CLIENT *clnttcp_create __P((struct sockaddr_in *, + u_long, + u_long, + int *, + u_int, + u_int)); +__END_DECLS + + +/* + * UDP based rpc. + * CLIENT * + * clntudp_create(raddr, program, version, wait, sockp) + * struct sockaddr_in *raddr; + * u_long program; + * u_long version; + * struct timeval wait; + * int *sockp; + * + * Same as above, but you specify max packet sizes. + * CLIENT * + * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) + * struct sockaddr_in *raddr; + * u_long program; + * u_long version; + * struct timeval wait; + * int *sockp; + * u_int sendsz; + * u_int recvsz; + */ +__BEGIN_DECLS +extern CLIENT *clntudp_create __P((struct sockaddr_in *, + u_long, + u_long, + struct timeval, + int *)); +extern CLIENT *clntudp_bufcreate __P((struct sockaddr_in *, + u_long, + u_long, + struct timeval, + int *, + u_int, + u_int)); +__END_DECLS + + +/* + * Print why creation failed + */ +__BEGIN_DECLS +extern void clnt_pcreateerror __P((char *)); /* stderr */ +extern char *clnt_spcreateerror __P((char *)); /* string */ +__END_DECLS + +/* + * Like clnt_perror(), but is more verbose in its output + */ +__BEGIN_DECLS +extern void clnt_perrno __P((enum clnt_stat)); /* stderr */ +extern char *clnt_sperrno __P((enum clnt_stat)); /* string */ +__END_DECLS + +/* + * Print an English error message, given the client error code + */ +__BEGIN_DECLS +extern void clnt_perror __P((CLIENT *, char *)); /* stderr */ +extern char *clnt_sperror __P((CLIENT *, char *)); /* string */ +__END_DECLS + + +/* + * If a creation fails, the following allows the user to figure out why. + */ +struct rpc_createerr { + enum clnt_stat cf_stat; + struct rpc_err cf_error; /* useful when cf_stat == RPC_PMAPFAILURE */ +}; + +extern struct rpc_createerr rpc_createerr; + + +#define UDPMSGSIZE 8800 /* rpc imposed limit on udp msg size */ +#define RPCSMALLMSGSIZE 400 /* a more reasonable packet size */ + +#endif /* !_RPC_CLNT_H */ diff --git a/src/include/rpc/pmap_clnt.h b/src/include/rpc/pmap_clnt.h new file mode 100644 index 00000000..528fe2f5 --- /dev/null +++ b/src/include/rpc/pmap_clnt.h @@ -0,0 +1,86 @@ +/* $NetBSD: pmap_clnt.h,v 1.5 1994/12/04 01:12:42 cgd Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)pmap_clnt.h 1.11 88/02/08 SMI + * @(#)pmap_clnt.h 2.1 88/07/29 4.0 RPCSRC + */ + +/* + * pmap_clnt.h + * Supplies C routines to get to portmap services. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +/* + * Usage: + * success = pmap_set(program, version, protocol, port); + * success = pmap_unset(program, version); + * port = pmap_getport(address, program, version, protocol); + * head = pmap_getmaps(address); + * clnt_stat = pmap_rmtcall(address, program, version, procedure, + * xdrargs, argsp, xdrres, resp, tout, port_ptr) + * (works for udp only.) + * clnt_stat = clnt_broadcast(program, version, procedure, + * xdrargs, argsp, xdrres, resp, eachresult) + * (like pmap_rmtcall, except the call is broadcasted to all + * locally connected nets. For each valid response received, + * the procedure eachresult is called. Its form is: + * done = eachresult(resp, raddr) + * bool_t done; + * caddr_t resp; + * struct sockaddr_in raddr; + * where resp points to the results of the call and raddr is the + * address if the responder to the broadcast. + */ + +#ifndef _RPC_PMAPCLNT_H +#define _RPC_PMAPCLNT_H +#include <sys/cdefs.h> + +__BEGIN_DECLS +extern bool_t pmap_set __P((u_long, u_long, int, int)); +extern bool_t pmap_unset __P((u_long, u_long)); +extern struct pmaplist *pmap_getmaps __P((struct sockaddr_in *)); +extern enum clnt_stat pmap_rmtcall __P((struct sockaddr_in *, + u_long, u_long, u_long, + xdrproc_t, caddr_t, + xdrproc_t, caddr_t, + struct timeval, u_long *)); +extern enum clnt_stat clnt_broadcast __P((u_long, u_long, u_long, + xdrproc_t, char *, + xdrproc_t, char *, + bool_t (*) __P((caddr_t, + struct sockaddr_in *)))); +extern u_short pmap_getport __P((struct sockaddr_in *, + u_long, u_long, u_int)); +__END_DECLS + +#endif /* !_RPC_PMAPCLNT_H */ diff --git a/src/include/rpc/pmap_prot.h b/src/include/rpc/pmap_prot.h new file mode 100644 index 00000000..56d115aa --- /dev/null +++ b/src/include/rpc/pmap_prot.h @@ -0,0 +1,105 @@ +/* $NetBSD: pmap_prot.h,v 1.4 1994/10/26 00:57:00 cgd Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)pmap_prot.h 1.14 88/02/08 SMI + * @(#)pmap_prot.h 2.1 88/07/29 4.0 RPCSRC + */ + +/* + * pmap_prot.h + * Protocol for the local binder service, or pmap. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + * + * The following procedures are supported by the protocol: + * + * PMAPPROC_NULL() returns () + * takes nothing, returns nothing + * + * PMAPPROC_SET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Registers the tuple + * [prog, vers, prot, port]. + * + * PMAPPROC_UNSET(struct pmap) returns (bool_t) + * TRUE is success, FALSE is failure. Un-registers pair + * [prog, vers]. prot and port are ignored. + * + * PMAPPROC_GETPORT(struct pmap) returns (long unsigned). + * 0 is failure. Otherwise returns the port number where the pair + * [prog, vers] is registered. It may lie! + * + * PMAPPROC_DUMP() RETURNS (struct pmaplist *) + * + * PMAPPROC_CALLIT(unsigned, unsigned, unsigned, string<>) + * RETURNS (port, string<>); + * usage: encapsulatedresults = PMAPPROC_CALLIT(prog, vers, proc, encapsulatedargs); + * Calls the procedure on the local machine. If it is not registered, + * this procedure is quite; ie it does not return error information!!! + * This procedure only is supported on rpc/udp and calls via + * rpc/udp. This routine only passes null authentication parameters. + * This file has no interface to xdr routines for PMAPPROC_CALLIT. + * + * The service supports remote procedure calls on udp/ip or tcp/ip socket 111. + */ + +#ifndef _RPC_PMAPPROT_H +#define _RPC_PMAPPROT_H +#include <sys/cdefs.h> + +#define PMAPPORT ((u_short)111) +#define PMAPPROG ((u_long)100000) +#define PMAPVERS ((u_long)2) +#define PMAPVERS_PROTO ((u_long)2) +#define PMAPVERS_ORIG ((u_long)1) +#define PMAPPROC_NULL ((u_long)0) +#define PMAPPROC_SET ((u_long)1) +#define PMAPPROC_UNSET ((u_long)2) +#define PMAPPROC_GETPORT ((u_long)3) +#define PMAPPROC_DUMP ((u_long)4) +#define PMAPPROC_CALLIT ((u_long)5) + +struct pmap { + long unsigned pm_prog; + long unsigned pm_vers; + long unsigned pm_prot; + long unsigned pm_port; +}; + +struct pmaplist { + struct pmap pml_map; + struct pmaplist *pml_next; +}; + +__BEGIN_DECLS +extern bool_t xdr_pmap __P((XDR *, struct pmap *)); +extern bool_t xdr_pmaplist __P((XDR *, struct pmaplist **)); +__END_DECLS + +#endif /* !_RPC_PMAPPROT_H */ diff --git a/src/include/rpc/pmap_rmt.h b/src/include/rpc/pmap_rmt.h new file mode 100644 index 00000000..f9b4d8c4 --- /dev/null +++ b/src/include/rpc/pmap_rmt.h @@ -0,0 +1,64 @@ +/* $NetBSD: pmap_rmt.h,v 1.4 1994/10/26 00:57:01 cgd Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)pmap_rmt.h 1.2 88/02/08 SMI + * @(#)pmap_rmt.h 2.1 88/07/29 4.0 RPCSRC + */ + +/* + * Structures and XDR routines for parameters to and replies from + * the portmapper remote-call-service. + * + * Copyright (C) 1986, Sun Microsystems, Inc. + */ + +#ifndef _RPC_PMAPRMT_H +#define _RPC_PMAPRMT_H +#include <sys/cdefs.h> + +struct rmtcallargs { + u_long prog, vers, proc, arglen; + caddr_t args_ptr; + xdrproc_t xdr_args; +}; + +struct rmtcallres { + u_long *port_ptr; + u_long resultslen; + caddr_t results_ptr; + xdrproc_t xdr_results; +}; + +__BEGIN_DECLS +extern bool_t xdr_rmtcall_args __P((XDR *, struct rmtcallargs *)); +extern bool_t xdr_rmtcallres __P((XDR *, struct rmtcallres *)); +__END_DECLS + +#endif /* !_RPC_PMAPRMT_H */ diff --git a/src/include/rpc/rpc.h b/src/include/rpc/rpc.h new file mode 100644 index 00000000..89b48ac3 --- /dev/null +++ b/src/include/rpc/rpc.h @@ -0,0 +1,92 @@ +/* $NetBSD: rpc.h,v 1.5 1994/12/04 01:15:30 cgd Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)rpc.h 1.9 88/02/08 SMI + * @(#)rpc.h 2.4 89/07/11 4.0 RPCSRC + */ + +/* + * rpc.h, Just includes the billions of rpc header files necessary to + * do remote procedure calling. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ +#ifndef _RPC_RPC_H +#define _RPC_RPC_H + +#include <rpc/types.h> /* some typedefs */ +#include <netinet/in.h> + +/* external data representation interfaces */ +#include <rpc/xdr.h> /* generic (de)serializer */ + +/* Client side only authentication */ +#include <rpc/auth.h> /* generic authenticator (client side) */ + +/* Client side (mostly) remote procedure call */ +#include <rpc/clnt.h> /* generic rpc stuff */ + +/* semi-private protocol headers */ +#include <rpc/rpc_msg.h> /* protocol for rpc messages */ +#include <rpc/auth_unix.h> /* protocol for unix style cred */ +/* + * Uncomment-out the next line if you are building the rpc library with + * DES Authentication (see the README file in the secure_rpc/ directory). + */ +#ifdef notdef +#include <rpc/auth_des.h> /* protocol for des style cred */ +#endif + +/* Server side only remote procedure callee */ +#include <rpc/svc.h> /* service manager and multiplexer */ +#include <rpc/svc_auth.h> /* service side authenticator */ + +/* + * COMMENT OUT THE NEXT INCLUDE (or add to the #ifndef) IF RUNNING ON + * A VERSION OF UNIX THAT USES SUN'S NFS SOURCE. These systems will + * already have the structures defined by <rpc/netdb.h> included in <netdb.h>. + */ +/* routines for parsing /etc/rpc */ + +struct rpcent { + char *r_name; /* name of server for this rpc program */ + char **r_aliases; /* alias list */ + int r_number; /* rpc program number */ +}; + +__BEGIN_DECLS +extern struct rpcent *getrpcbyname __P((char *)); +extern struct rpcent *getrpcbynumber __P((int)); +extern struct rpcent *getrpcent __P((void)); +extern void setrpcent __P((int)); +extern void endrpcent __P((void)); +__END_DECLS + +#endif /* !_RPC_RPC_H */ diff --git a/src/include/rpc/rpc_msg.h b/src/include/rpc/rpc_msg.h new file mode 100644 index 00000000..224651ef --- /dev/null +++ b/src/include/rpc/rpc_msg.h @@ -0,0 +1,196 @@ +/* $NetBSD: rpc_msg.h,v 1.5 1995/04/29 05:28:00 cgd Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)rpc_msg.h 1.7 86/07/16 SMI + * @(#)rpc_msg.h 2.1 88/07/29 4.0 RPCSRC + */ + +/* + * rpc_msg.h + * rpc message definition + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_RPCMSG_H +#define _RPC_RPCMSG_H + +#define RPC_MSG_VERSION ((u_long) 2) +#define RPC_SERVICE_PORT ((u_short) 2048) + +/* + * Bottom up definition of an rpc message. + * NOTE: call and reply use the same overall stuct but + * different parts of unions within it. + */ + +enum msg_type { + CALL=0, + REPLY=1 +}; + +enum reply_stat { + MSG_ACCEPTED=0, + MSG_DENIED=1 +}; + +enum accept_stat { + SUCCESS=0, + PROG_UNAVAIL=1, + PROG_MISMATCH=2, + PROC_UNAVAIL=3, + GARBAGE_ARGS=4, + SYSTEM_ERR=5 +}; + +enum reject_stat { + RPC_MISMATCH=0, + AUTH_ERROR=1 +}; + +/* + * Reply part of an rpc exchange + */ + +/* + * Reply to an rpc request that was accepted by the server. + * Note: there could be an error even though the request was + * accepted. + */ +struct accepted_reply { + struct opaque_auth ar_verf; + enum accept_stat ar_stat; + union { + struct { + u_int32_t low; + u_int32_t high; + } AR_versions; + struct { + caddr_t where; + xdrproc_t proc; + } AR_results; + /* and many other null cases */ + } ru; +#define ar_results ru.AR_results +#define ar_vers ru.AR_versions +}; + +/* + * Reply to an rpc request that was rejected by the server. + */ +struct rejected_reply { + enum reject_stat rj_stat; + union { + struct { + u_int32_t low; + u_int32_t high; + } RJ_versions; + enum auth_stat RJ_why; /* why authentication did not work */ + } ru; +#define rj_vers ru.RJ_versions +#define rj_why ru.RJ_why +}; + +/* + * Body of a reply to an rpc request. + */ +struct reply_body { + enum reply_stat rp_stat; + union { + struct accepted_reply RP_ar; + struct rejected_reply RP_dr; + } ru; +#define rp_acpt ru.RP_ar +#define rp_rjct ru.RP_dr +}; + +/* + * Body of an rpc request call. + */ +struct call_body { + u_int32_t cb_rpcvers; /* must be equal to two */ + u_int32_t cb_prog; + u_int32_t cb_vers; + u_int32_t cb_proc; + struct opaque_auth cb_cred; + struct opaque_auth cb_verf; /* protocol specific - provided by client */ +}; + +/* + * The rpc message + */ +struct rpc_msg { + u_int32_t rm_xid; + enum msg_type rm_direction; + union { + struct call_body RM_cmb; + struct reply_body RM_rmb; + } ru; +#define rm_call ru.RM_cmb +#define rm_reply ru.RM_rmb +}; +#define acpted_rply ru.RM_rmb.ru.RP_ar +#define rjcted_rply ru.RM_rmb.ru.RP_dr + +__BEGIN_DECLS +/* + * XDR routine to handle a rpc message. + * xdr_callmsg(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callmsg __P((XDR *, struct rpc_msg *)); + +/* + * XDR routine to pre-serialize the static part of a rpc message. + * xdr_callhdr(xdrs, cmsg) + * XDR *xdrs; + * struct rpc_msg *cmsg; + */ +extern bool_t xdr_callhdr __P((XDR *, struct rpc_msg *)); + +/* + * XDR routine to handle a rpc reply. + * xdr_replymsg(xdrs, rmsg) + * XDR *xdrs; + * struct rpc_msg *rmsg; + */ +extern bool_t xdr_replymsg __P((XDR *, struct rpc_msg *)); + +/* + * Fills in the error part of a reply message. + * _seterr_reply(msg, error) + * struct rpc_msg *msg; + * struct rpc_err *error; + */ +extern void _seterr_reply __P((struct rpc_msg *, struct rpc_err *)); +__END_DECLS + +#endif /* !_RPC_RPCMSG_H */ diff --git a/src/include/rpc/svc.h b/src/include/rpc/svc.h new file mode 100644 index 00000000..038b3a3c --- /dev/null +++ b/src/include/rpc/svc.h @@ -0,0 +1,322 @@ +/* $NetBSD: svc.h,v 1.9 1995/04/29 05:28:01 cgd Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)svc.h 1.20 88/02/08 SMI + * @(#)svc.h 2.2 88/07/29 4.0 RPCSRC + */ + +/* + * svc.h, Server-side remote procedure call interface. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_SVC_H +#define _RPC_SVC_H +#include <sys/cdefs.h> + +/* + * This interface must manage two items concerning remote procedure calling: + * + * 1) An arbitrary number of transport connections upon which rpc requests + * are received. The two most notable transports are TCP and UDP; they are + * created and registered by routines in svc_tcp.c and svc_udp.c, respectively; + * they in turn call xprt_register and xprt_unregister. + * + * 2) An arbitrary number of locally registered services. Services are + * described by the following four data: program number, version number, + * "service dispatch" function, a transport handle, and a boolean that + * indicates whether or not the exported program should be registered with a + * local binder service; if true the program's number and version and the + * port number from the transport handle are registered with the binder. + * These data are registered with the rpc svc system via svc_register. + * + * A service's dispatch function is called whenever an rpc request comes in + * on a transport. The request's program and version numbers must match + * those of the registered service. The dispatch function is passed two + * parameters, struct svc_req * and SVCXPRT *, defined below. + */ + +enum xprt_stat { + XPRT_DIED, + XPRT_MOREREQS, + XPRT_IDLE +}; + +/* + * Server side transport handle + */ +typedef struct __rpc_svcxprt { + int xp_sock; + u_short xp_port; /* associated port number */ + struct xp_ops { + /* receive incomming requests */ + bool_t (*xp_recv) __P((struct __rpc_svcxprt *, + struct rpc_msg *)); + /* get transport status */ + enum xprt_stat (*xp_stat) __P((struct __rpc_svcxprt *)); + /* get arguments */ + bool_t (*xp_getargs) __P((struct __rpc_svcxprt *, xdrproc_t, + caddr_t)); + /* send reply */ + bool_t (*xp_reply) __P((struct __rpc_svcxprt *, + struct rpc_msg *)); + /* free mem allocated for args */ + bool_t (*xp_freeargs) __P((struct __rpc_svcxprt *, xdrproc_t, + caddr_t)); + /* destroy this struct */ + void (*xp_destroy) __P((struct __rpc_svcxprt *)); + } *xp_ops; + int xp_addrlen; /* length of remote address */ + struct sockaddr_in xp_raddr; /* remote address */ + struct opaque_auth xp_verf; /* raw response verifier */ + caddr_t xp_p1; /* private */ + caddr_t xp_p2; /* private */ +} SVCXPRT; + +/* + * Approved way of getting address of caller + */ +#define svc_getcaller(x) (&(x)->xp_raddr) + +/* + * Operations defined on an SVCXPRT handle + * + * SVCXPRT *xprt; + * struct rpc_msg *msg; + * xdrproc_t xargs; + * caddr_t argsp; + */ +#define SVC_RECV(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) +#define svc_recv(xprt, msg) \ + (*(xprt)->xp_ops->xp_recv)((xprt), (msg)) + +#define SVC_STAT(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) +#define svc_stat(xprt) \ + (*(xprt)->xp_ops->xp_stat)(xprt) + +#define SVC_GETARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) +#define svc_getargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_getargs)((xprt), (xargs), (argsp)) + +#define SVC_REPLY(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) +#define svc_reply(xprt, msg) \ + (*(xprt)->xp_ops->xp_reply) ((xprt), (msg)) + +#define SVC_FREEARGS(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) +#define svc_freeargs(xprt, xargs, argsp) \ + (*(xprt)->xp_ops->xp_freeargs)((xprt), (xargs), (argsp)) + +#define SVC_DESTROY(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) +#define svc_destroy(xprt) \ + (*(xprt)->xp_ops->xp_destroy)(xprt) + + +/* + * Service request + */ +struct svc_req { + u_int32_t rq_prog; /* service program number */ + u_int32_t rq_vers; /* service protocol version */ + u_int32_t rq_proc; /* the desired procedure */ + struct opaque_auth rq_cred; /* raw creds from the wire */ + caddr_t rq_clntcred; /* read only cooked cred */ + SVCXPRT *rq_xprt; /* associated transport */ +}; + + +/* + * Service registration + * + * svc_register(xprt, prog, vers, dispatch, protocol) + * SVCXPRT *xprt; + * u_long prog; + * u_long vers; + * void (*dispatch)(); + * int protocol; like TCP or UDP, zero means do not register + */ +__BEGIN_DECLS +extern bool_t svc_register __P((SVCXPRT *, u_long, u_long, + void (*) __P((struct svc_req *, SVCXPRT *)), int)); +__END_DECLS + +/* + * Service un-registration + * + * svc_unregister(prog, vers) + * u_long prog; + * u_long vers; + */ +__BEGIN_DECLS +extern void svc_unregister __P((u_long, u_long)); +__END_DECLS + +/* + * Transport registration. + * + * xprt_register(xprt) + * SVCXPRT *xprt; + */ +__BEGIN_DECLS +extern void xprt_register __P((SVCXPRT *)); +__END_DECLS + +/* + * Transport un-register + * + * xprt_unregister(xprt) + * SVCXPRT *xprt; + */ +__BEGIN_DECLS +extern void xprt_unregister __P((SVCXPRT *)); +__END_DECLS + + + + +/* + * When the service routine is called, it must first check to see if it + * knows about the procedure; if not, it should call svcerr_noproc + * and return. If so, it should deserialize its arguments via + * SVC_GETARGS (defined above). If the deserialization does not work, + * svcerr_decode should be called followed by a return. Successful + * decoding of the arguments should be followed the execution of the + * procedure's code and a call to svc_sendreply. + * + * Also, if the service refuses to execute the procedure due to too- + * weak authentication parameters, svcerr_weakauth should be called. + * Note: do not confuse access-control failure with weak authentication! + * + * NB: In pure implementations of rpc, the caller always waits for a reply + * msg. This message is sent when svc_sendreply is called. + * Therefore pure service implementations should always call + * svc_sendreply even if the function logically returns void; use + * xdr.h - xdr_void for the xdr routine. HOWEVER, tcp based rpc allows + * for the abuse of pure rpc via batched calling or pipelining. In the + * case of a batched call, svc_sendreply should NOT be called since + * this would send a return message, which is what batching tries to avoid. + * It is the service/protocol writer's responsibility to know which calls are + * batched and which are not. Warning: responding to batch calls may + * deadlock the caller and server processes! + */ + +__BEGIN_DECLS +extern bool_t svc_sendreply __P((SVCXPRT *, xdrproc_t, char *)); +extern void svcerr_decode __P((SVCXPRT *)); +extern void svcerr_weakauth __P((SVCXPRT *)); +extern void svcerr_noproc __P((SVCXPRT *)); +extern void svcerr_progvers __P((SVCXPRT *, u_long, u_long)); +extern void svcerr_auth __P((SVCXPRT *, enum auth_stat)); +extern void svcerr_noprog __P((SVCXPRT *)); +extern void svcerr_systemerr __P((SVCXPRT *)); +__END_DECLS + +/* + * Lowest level dispatching -OR- who owns this process anyway. + * Somebody has to wait for incoming requests and then call the correct + * service routine. The routine svc_run does infinite waiting; i.e., + * svc_run never returns. + * Since another (co-existant) package may wish to selectively wait for + * incoming calls or other events outside of the rpc architecture, the + * routine svc_getreq is provided. It must be passed readfds, the + * "in-place" results of a select system call (see select, section 2). + */ + +/* + * Global keeper of rpc service descriptors in use + * dynamic; must be inspected before each call to select + */ +extern int svc_maxfd; +#ifdef FD_SETSIZE +extern fd_set svc_fdset; +#define svc_fds svc_fdset.fds_bits[0] /* compatibility */ +#else +extern int svc_fds; +#endif /* def FD_SETSIZE */ + +/* + * a small program implemented by the svc_rpc implementation itself; + * also see clnt.h for protocol numbers. + */ +extern void rpctest_service(); /* XXX relic? */ + +__BEGIN_DECLS +extern void svc_getreq __P((int)); +extern void svc_getreqset __P((fd_set *)); +extern void svc_run __P((void)); +__END_DECLS + +/* + * Socket to use on svcxxx_create call to get default socket + */ +#define RPC_ANYSOCK -1 + +/* + * These are the existing service side transport implementations + */ + +/* + * Memory based rpc for testing and timing. + */ +__BEGIN_DECLS +extern SVCXPRT *svcraw_create __P((void)); +__END_DECLS + + +/* + * Udp based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svcudp_create __P((int)); +extern SVCXPRT *svcudp_bufcreate __P((int, u_int, u_int)); +__END_DECLS + + +/* + * Tcp based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svctcp_create __P((int, u_int, u_int)); +__END_DECLS + +/* + * Fd based rpc. + */ +__BEGIN_DECLS +extern SVCXPRT *svcfd_create __P((int, u_int, u_int)); +__END_DECLS + +#endif /* !_RPC_SVC_H */ diff --git a/src/include/rpc/svc_auth.h b/src/include/rpc/svc_auth.h new file mode 100644 index 00000000..a4d4a631 --- /dev/null +++ b/src/include/rpc/svc_auth.h @@ -0,0 +1,51 @@ +/* $NetBSD: svc_auth.h,v 1.4 1994/10/26 00:57:07 cgd Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)svc_auth.h 1.6 86/07/16 SMI + * @(#)svc_auth.h 2.1 88/07/29 4.0 RPCSRC + */ + +/* + * svc_auth.h, Service side of rpc authentication. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_SVCAUTH_H +#define _RPC_SVCAUTH_H + +/* + * Server side authenticator + */ +__BEGIN_DECLS +extern enum auth_stat _authenticate __P((struct svc_req *, struct rpc_msg *)); +__END_DECLS + +#endif /* !_RPC_SVCAUTH_H */ diff --git a/src/include/rpc/types.h b/src/include/rpc/types.h new file mode 100644 index 00000000..9e8d8956 --- /dev/null +++ b/src/include/rpc/types.h @@ -0,0 +1,63 @@ +/* $NetBSD: types.h,v 1.8 1995/04/29 05:28:05 cgd Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)types.h 1.18 87/07/24 SMI + * @(#)types.h 2.3 88/08/15 4.0 RPCSRC + */ + +/* + * Rpc additions to <sys/types.h> + */ +#ifndef _RPC_TYPES_H +#define _RPC_TYPES_H + +#define bool_t int32_t +#define enum_t int32_t +#define __dontcare__ -1 + +#ifndef FALSE +# define FALSE (0) +#endif +#ifndef TRUE +# define TRUE (1) +#endif +#ifndef NULL +# define NULL 0 +#endif + +#define mem_alloc(bsize) malloc(bsize) +#define mem_free(ptr, bsize) free(ptr) + +#ifndef makedev /* ie, we haven't already included it */ +#include <sys/types.h> +#endif +#include <sys/time.h> + +#endif /* !_RPC_TYPES_H */ diff --git a/src/include/rpc/xdr.h b/src/include/rpc/xdr.h new file mode 100644 index 00000000..28ded811 --- /dev/null +++ b/src/include/rpc/xdr.h @@ -0,0 +1,307 @@ +/* $NetBSD: xdr.h,v 1.7 1995/04/29 05:28:06 cgd Exp $ */ + +/* + * Sun RPC is a product of Sun Microsystems, Inc. and is provided for + * unrestricted use provided that this legend is included on all tape + * media and as a part of the software program in whole or part. Users + * may copy or modify Sun RPC without charge, but are not authorized + * to license or distribute it to anyone else except as part of a product or + * program developed by the user. + * + * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE + * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR + * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE. + * + * Sun RPC is provided with no support and without any obligation on the + * part of Sun Microsystems, Inc. to assist in its use, correction, + * modification or enhancement. + * + * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE + * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC + * OR ANY PART THEREOF. + * + * In no event will Sun Microsystems, Inc. be liable for any lost revenue + * or profits or other special, indirect and consequential damages, even if + * Sun has been advised of the possibility of such damages. + * + * Sun Microsystems, Inc. + * 2550 Garcia Avenue + * Mountain View, California 94043 + * + * from: @(#)xdr.h 1.19 87/04/22 SMI + * @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC + */ + +/* + * xdr.h, External Data Representation Serialization Routines. + * + * Copyright (C) 1984, Sun Microsystems, Inc. + */ + +#ifndef _RPC_XDR_H +#define _RPC_XDR_H +#include <sys/cdefs.h> + +/* + * XDR provides a conventional way for converting between C data + * types and an external bit-string representation. Library supplied + * routines provide for the conversion on built-in C data types. These + * routines and utility routines defined here are used to help implement + * a type encode/decode routine for each user-defined type. + * + * Each data type provides a single procedure which takes two arguments: + * + * bool_t + * xdrproc(xdrs, argresp) + * XDR *xdrs; + * <type> *argresp; + * + * xdrs is an instance of a XDR handle, to which or from which the data + * type is to be converted. argresp is a pointer to the structure to be + * converted. The XDR handle contains an operation field which indicates + * which of the operations (ENCODE, DECODE * or FREE) is to be performed. + * + * XDR_DECODE may allocate space if the pointer argresp is null. This + * data can be freed with the XDR_FREE operation. + * + * We write only one procedure per data type to make it easy + * to keep the encode and decode procedures for a data type consistent. + * In many cases the same code performs all operations on a user defined type, + * because all the hard work is done in the component type routines. + * decode as a series of calls on the nested data types. + */ + +/* + * Xdr operations. XDR_ENCODE causes the type to be encoded into the + * stream. XDR_DECODE causes the type to be extracted from the stream. + * XDR_FREE can be used to release the space allocated by an XDR_DECODE + * request. + */ +enum xdr_op { + XDR_ENCODE=0, + XDR_DECODE=1, + XDR_FREE=2 +}; + +/* + * This is the number of bytes per unit of external data. + */ +#define BYTES_PER_XDR_UNIT (4) +#define RNDUP(x) ((((x) + BYTES_PER_XDR_UNIT - 1) / BYTES_PER_XDR_UNIT) \ + * BYTES_PER_XDR_UNIT) + +/* + * The XDR handle. + * Contains operation which is being applied to the stream, + * an operations vector for the paticular implementation (e.g. see xdr_mem.c), + * and two private fields for the use of the particular impelementation. + */ +typedef struct __rpc_xdr { + enum xdr_op x_op; /* operation; fast additional param */ + struct xdr_ops { + /* get a long from underlying stream */ + bool_t (*x_getlong) __P((struct __rpc_xdr *, long *)); + /* put a long to " */ + bool_t (*x_putlong) __P((struct __rpc_xdr *, long *)); + /* get some bytes from " */ + bool_t (*x_getbytes) __P((struct __rpc_xdr *, caddr_t, u_int)); + /* put some bytes to " */ + bool_t (*x_putbytes) __P((struct __rpc_xdr *, caddr_t, u_int)); + /* returns bytes off from beginning */ + u_int (*x_getpostn) __P((struct __rpc_xdr *)); + /* lets you reposition the stream */ + bool_t (*x_setpostn) __P((struct __rpc_xdr *, u_int)); + /* buf quick ptr to buffered data */ + int32_t *(*x_inline) __P((struct __rpc_xdr *, u_int)); + /* free privates of this xdr_stream */ + void (*x_destroy) __P((struct __rpc_xdr *)); + } *x_ops; + caddr_t x_public; /* users' data */ + caddr_t x_private; /* pointer to private data */ + caddr_t x_base; /* private used for position info */ + int x_handy; /* extra private word */ +} XDR; + +/* + * A xdrproc_t exists for each data type which is to be encoded or decoded. + * + * The second argument to the xdrproc_t is a pointer to an opaque pointer. + * The opaque pointer generally points to a structure of the data type + * to be decoded. If this pointer is 0, then the type routines should + * allocate dynamic storage of the appropriate size and return it. + * + * XXX can't actually prototype it, because some take three args!!! + */ +typedef bool_t (*xdrproc_t) __P((/* XDR *, void *, u_int */)); + +/* + * Operations defined on a XDR handle + * + * XDR *xdrs; + * long *longp; + * caddr_t addr; + * u_int len; + * u_int pos; + */ +#define XDR_GETLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) +#define xdr_getlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_getlong)(xdrs, longp) + +#define XDR_PUTLONG(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) +#define xdr_putlong(xdrs, longp) \ + (*(xdrs)->x_ops->x_putlong)(xdrs, longp) + +#define XDR_GETBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) +#define xdr_getbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_getbytes)(xdrs, addr, len) + +#define XDR_PUTBYTES(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) +#define xdr_putbytes(xdrs, addr, len) \ + (*(xdrs)->x_ops->x_putbytes)(xdrs, addr, len) + +#define XDR_GETPOS(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) +#define xdr_getpos(xdrs) \ + (*(xdrs)->x_ops->x_getpostn)(xdrs) + +#define XDR_SETPOS(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) +#define xdr_setpos(xdrs, pos) \ + (*(xdrs)->x_ops->x_setpostn)(xdrs, pos) + +#define XDR_INLINE(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) +#define xdr_inline(xdrs, len) \ + (*(xdrs)->x_ops->x_inline)(xdrs, len) + +#define XDR_DESTROY(xdrs) \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs) +#define xdr_destroy(xdrs) \ + if ((xdrs)->x_ops->x_destroy) \ + (*(xdrs)->x_ops->x_destroy)(xdrs) + +/* + * Support struct for discriminated unions. + * You create an array of xdrdiscrim structures, terminated with + * a entry with a null procedure pointer. The xdr_union routine gets + * the discriminant value and then searches the array of structures + * for a matching value. If a match is found the associated xdr routine + * is called to handle that part of the union. If there is + * no match, then a default routine may be called. + * If there is no match and no default routine it is an error. + */ +#define NULL_xdrproc_t ((xdrproc_t)0) +struct xdr_discrim { + int value; + xdrproc_t proc; +}; + +/* + * In-line routines for fast encode/decode of primitve data types. + * Caveat emptor: these use single memory cycles to get the + * data from the underlying buffer, and will fail to operate + * properly if the data is not aligned. The standard way to use these + * is to say: + * if ((buf = XDR_INLINE(xdrs, count)) == NULL) + * return (FALSE); + * <<< macro calls >>> + * where ``count'' is the number of bytes of data occupied + * by the primitive data types. + * + * N.B. and frozen for all time: each data type here uses 4 bytes + * of external representation. + */ +#define IXDR_GET_LONG(buf) ((long)ntohl((u_long)*(buf)++)) +#define IXDR_PUT_LONG(buf, v) (*(buf)++ = (long)htonl((u_long)v)) + +#define IXDR_GET_BOOL(buf) ((bool_t)IXDR_GET_LONG(buf)) +#define IXDR_GET_ENUM(buf, t) ((t)IXDR_GET_LONG(buf)) +#define IXDR_GET_U_LONG(buf) ((u_long)IXDR_GET_LONG(buf)) +#define IXDR_GET_SHORT(buf) ((short)IXDR_GET_LONG(buf)) +#define IXDR_GET_U_SHORT(buf) ((u_short)IXDR_GET_LONG(buf)) + +#define IXDR_PUT_BOOL(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_ENUM(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_U_LONG(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) +#define IXDR_PUT_U_SHORT(buf, v) IXDR_PUT_LONG((buf), ((long)(v))) + +/* + * These are the "generic" xdr routines. + */ +__BEGIN_DECLS +extern bool_t xdr_void __P((void)); +extern bool_t xdr_int __P((XDR *, int *)); +extern bool_t xdr_u_int __P((XDR *, u_int *)); +extern bool_t xdr_long __P((XDR *, long *)); +extern bool_t xdr_u_long __P((XDR *, u_long *)); +extern bool_t xdr_short __P((XDR *, short *)); +extern bool_t xdr_u_short __P((XDR *, u_short *)); +extern bool_t xdr_int16_t __P((XDR *, int16_t *)); +extern bool_t xdr_u_int16_t __P((XDR *, u_int16_t *)); +extern bool_t xdr_int32_t __P((XDR *, int32_t *)); +extern bool_t xdr_u_int32_t __P((XDR *, u_int32_t *)); +extern bool_t xdr_bool __P((XDR *, bool_t *)); +extern bool_t xdr_enum __P((XDR *, enum_t *)); +extern bool_t xdr_array __P((XDR *, char **, u_int *, u_int, u_int, xdrproc_t)); +extern bool_t xdr_bytes __P((XDR *, char **, u_int *, u_int)); +extern bool_t xdr_opaque __P((XDR *, caddr_t, u_int)); +extern bool_t xdr_string __P((XDR *, char **, u_int)); +extern bool_t xdr_union __P((XDR *, enum_t *, char *, struct xdr_discrim *, xdrproc_t)); +extern bool_t xdr_char __P((XDR *, char *)); +extern bool_t xdr_u_char __P((XDR *, u_char *)); +extern bool_t xdr_vector __P((XDR *, char *, u_int, u_int, xdrproc_t)); +extern bool_t xdr_float __P((XDR *, float *)); +extern bool_t xdr_double __P((XDR *, double *)); +extern bool_t xdr_reference __P((XDR *, caddr_t *, u_int, xdrproc_t)); +extern bool_t xdr_pointer __P((XDR *, caddr_t *, u_int, xdrproc_t)); +extern bool_t xdr_wrapstring __P((XDR *, char **)); +extern void xdr_free __P((xdrproc_t, char *)); +__END_DECLS + +/* + * Common opaque bytes objects used by many rpc protocols; + * declared here due to commonality. + */ +#define MAX_NETOBJ_SZ 1024 +struct netobj { + u_int n_len; + char *n_bytes; +}; +typedef struct netobj netobj; +extern bool_t xdr_netobj __P((XDR *, struct netobj *)); + +/* + * These are the public routines for the various implementations of + * xdr streams. + */ +__BEGIN_DECLS +/* XDR using memory buffers */ +extern void xdrmem_create __P((XDR *, char *, u_int, enum xdr_op)); + +#ifdef _STDIO_H_ +/* XDR using stdio library */ +extern void xdrstdio_create __P((XDR *, FILE *, enum xdr_op)); +#endif + +/* XDR pseudo records for tcp */ +extern void xdrrec_create __P((XDR *, u_int, u_int, char *, + int (*) __P((caddr_t, caddr_t, int)), + int (*) __P((caddr_t, caddr_t, int)))); + +/* make end of xdr record */ +extern bool_t xdrrec_endofrecord __P((XDR *, int)); + +/* move to beginning of next record */ +extern bool_t xdrrec_skiprecord __P((XDR *)); + +/* true if no more input */ +extern bool_t xdrrec_eof __P((XDR *)); +__END_DECLS + +#endif /* !_RPC_XDR_H */ diff --git a/src/include/rpcsvc/yp_prot.h b/src/include/rpcsvc/yp_prot.h new file mode 100644 index 00000000..37b2c270 --- /dev/null +++ b/src/include/rpcsvc/yp_prot.h @@ -0,0 +1,344 @@ +/* $NetBSD: yp_prot.h,v 1.6 1995/07/14 21:10:58 christos Exp $ */ + +/* + * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Theo de Raadt. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RPCSVC_YP_PROT_H_ +#define _RPCSVC_YP_PROT_H_ + +/* + * YPSERV PROTOCOL: + * + * ypserv supports the following procedures: + * + * YPPROC_NULL takes (void), returns (void). + * called to check if server is alive. + * YPPROC_DOMAIN takes (char *), returns (bool_t). + * true if ypserv serves the named domain. + * YPPROC_DOMAIN_NOACK takes (char *), returns (bool_t). + * true if ypserv serves the named domain. + * used for broadcasts, does not ack if ypserv + * doesn't handle named domain. + * YPPROC_MATCH takes (struct ypreq_key), returns (struct ypresp_val) + * does a lookup. + * YPPROC_FIRST takes (struct ypreq_nokey) returns (ypresp_key_val). + * gets the first key/datum from the map. + * YPPROC_NEXT takes (struct ypreq_key) returns (ypresp_key_val). + * gets the next key/datum from the map. + * YPPROC_XFR takes (struct ypreq_xfr), returns (void). + * tells ypserv to check if there is a new version of + * the map. + * YPPROC_CLEAR takes (void), returns (void). + * tells ypserv to flush it's file cache, so that + * newly transferred files will get read. + * YPPROC_ALL takes (struct ypreq_nokey), returns (bool_t and + * struct ypresp_key_val). + * returns an array of data, with the bool_t being + * false on the last datum. read the source, it's + * convoluted. + * YPPROC_MASTER takes (struct ypreq_nokey), returns (ypresp_master). + * YPPROC_ORDER takes (struct ypreq_nokey), returns (ypresp_order). + * YPPROC_MAPLIST takes (char *), returns (struct ypmaplist *). + */ + +#ifndef BOOL_DEFINED +typedef u_int bool; +#define BOOL_DEFINED +#endif + + +/* Program and version symbols, magic numbers */ +#define YPPROG ((u_long)100004) +#define YPVERS ((u_long)2) +#define YPVERS_ORIG ((u_long)1) +#define YPMAXRECORD ((u_long)1024) +#define YPMAXDOMAIN ((u_long)64) +#define YPMAXMAP ((u_long)64) +#define YPMAXPEER ((u_long)256) + +/* + * I don't know if anything of sun's depends on this, or if they + * simply defined it so that their own code wouldn't try to send + * packets over the ethernet MTU. This YP code doesn't use it. + */ +#define YPMSGSZ 1600 + +#ifndef DATUM +typedef struct { + const char *dptr; + int dsize; +} datum; +#define DATUM +#endif + +struct ypmap_parms { + const char *domain; + const char *map; + u_long ordernum; + char *owner; +}; + +struct ypreq_key { + const char *domain; + const char *map; + datum keydat; +}; + +struct ypreq_nokey { + const char *domain; + const char *map; +}; + +struct ypreq_xfr { + struct ypmap_parms map_parms; + u_long transid; + u_long proto; + u_short port; +}; +#define ypxfr_domain map_parms.domain +#define ypxfr_map map_parms.map +#define ypxfr_ordernum map_parms.ordernum +#define ypxfr_owner map_parms.owner + +struct ypresp_val { + u_long status; + datum valdat; +}; + +struct ypresp_key_val { + u_long status; + datum keydat; + datum valdat; +}; + +struct ypresp_master { + u_long status; + char *master; +}; + +struct ypresp_order { + u_long status; + u_long ordernum; +}; + +struct ypresp_all { + bool_t more; + union { + struct ypresp_key_val val; + } ypresp_all_u; +}; + +struct ypmaplist { + char ypml_name[YPMAXMAP + 1]; + struct ypmaplist *ypml_next; +}; + +struct ypresp_maplist { + u_long status; + struct ypmaplist *list; +}; + +/* ypserv procedure numbers */ +#define YPPROC_NULL ((u_long)0) +#define YPPROC_DOMAIN ((u_long)1) +#define YPPROC_DOMAIN_NONACK ((u_long)2) +#define YPPROC_MATCH ((u_long)3) +#define YPPROC_FIRST ((u_long)4) +#define YPPROC_NEXT ((u_long)5) +#define YPPROC_XFR ((u_long)6) +#define YPPROC_CLEAR ((u_long)7) +#define YPPROC_ALL ((u_long)8) +#define YPPROC_MASTER ((u_long)9) +#define YPPROC_ORDER ((u_long)10) +#define YPPROC_MAPLIST ((u_long)11) + +/* ypserv procedure return status values */ +#define YP_TRUE ((long)1) /* general purpose success code */ +#define YP_NOMORE ((long)2) /* no more entries in map */ +#define YP_FALSE ((long)0) /* general purpose failure code */ +#define YP_NOMAP ((long)-1) /* no such map in domain */ +#define YP_NODOM ((long)-2) /* domain not supported */ +#define YP_NOKEY ((long)-3) /* no such key in map */ +#define YP_BADOP ((long)-4) /* invalid operation */ +#define YP_BADDB ((long)-5) /* server data base is bad */ +#define YP_YPERR ((long)-6) /* YP server error */ +#define YP_BADARGS ((long)-7) /* request arguments bad */ +#define YP_VERS ((long)-8) /* YP server version mismatch */ + +/* + * Sun's header file says: + * "Domain binding data structure, used by ypclnt package and ypserv modules. + * Users of the ypclnt package (or of this protocol) don't HAVE to know about + * it, but it must be available to users because _yp_dobind is a public + * interface." + * + * This is totally bogus! Nowhere else does Sun state that _yp_dobind() is + * a public interface, and I don't know any reason anyone would want to call + * it. But, just in case anyone does actually expect it to be available.. + * we provide this.. exactly as Sun wants it. + */ +struct dom_binding { + struct dom_binding *dom_pnext; + char dom_domain[YPMAXDOMAIN + 1]; + struct sockaddr_in dom_server_addr; + u_short dom_server_port; + int dom_socket; + CLIENT *dom_client; + u_short dom_local_port; + long dom_vers; +}; + +/* + * YPBIND PROTOCOL: + * + * ypbind supports the following procedures: + * + * YPBINDPROC_NULL takes (void), returns (void). + * to check if ypbind is running. + * YPBINDPROC_DOMAIN takes (char *), returns (struct ypbind_resp). + * requests that ypbind start to serve the + * named domain (if it doesn't already) + * YPBINDPROC_SETDOM takes (struct ypbind_setdom), returns (void). + * used by ypset. + */ + +#define YPBINDPROG ((u_long)100007) +#define YPBINDVERS ((u_long)2) +#define YPBINDVERS_ORIG ((u_long)1) + +/* ypbind procedure numbers */ +#define YPBINDPROC_NULL ((u_long)0) +#define YPBINDPROC_DOMAIN ((u_long)1) +#define YPBINDPROC_SETDOM ((u_long)2) + +/* error code in ypbind_resp.ypbind_status */ +enum ypbind_resptype { + YPBIND_SUCC_VAL = 1, + YPBIND_FAIL_VAL = 2 +}; + +/* network order, of course */ +struct ypbind_binding { + struct in_addr ypbind_binding_addr; + u_short ypbind_binding_port; +}; + +struct ypbind_resp { + enum ypbind_resptype ypbind_status; + union { + u_long ypbind_error; + struct ypbind_binding ypbind_bindinfo; + } ypbind_respbody; +}; + +/* error code in ypbind_resp.ypbind_respbody.ypbind_error */ +#define YPBIND_ERR_ERR 1 /* internal error */ +#define YPBIND_ERR_NOSERV 2 /* no bound server for passed domain */ +#define YPBIND_ERR_RESC 3 /* system resource allocation failure */ + +/* + * Request data structure for ypbind "Set domain" procedure. + */ +struct ypbind_setdom { + char ypsetdom_domain[YPMAXDOMAIN + 1]; + struct ypbind_binding ypsetdom_binding; + u_short ypsetdom_vers; +}; +#define ypsetdom_addr ypsetdom_binding.ypbind_binding_addr +#define ypsetdom_port ypsetdom_binding.ypbind_binding_port + +/* + * YPPUSH PROTOCOL: + * + * Sun says: + * "Protocol between clients (ypxfr, only) and yppush + * yppush speaks a protocol in the transient range, which + * is supplied to ypxfr as a command-line parameter when it + * is activated by ypserv." + * + * This protocol is not implimented, naturally, because this YP + * implimentation only does the client side. + */ +#define YPPUSHVERS ((u_long)1) +#define YPPUSHVERS_ORIG ((u_long)1) + +/* yppush procedure numbers */ +#define YPPUSHPROC_NULL ((u_long)0) +#define YPPUSHPROC_XFRRESP ((u_long)1) + +struct yppushresp_xfr { + u_long transid; + u_long status; +}; + +/* yppush status value in yppushresp_xfr.status */ +#define YPPUSH_SUCC ((long)1) /* Success */ +#define YPPUSH_AGE ((long)2) /* Master's version not newer */ +#define YPPUSH_NOMAP ((long)-1) /* Can't find server for map */ +#define YPPUSH_NODOM ((long)-2) /* Domain not supported */ +#define YPPUSH_RSRC ((long)-3) /* Local resouce alloc failure */ +#define YPPUSH_RPC ((long)-4) /* RPC failure talking to server */ +#define YPPUSH_MADDR ((long)-5) /* Can't get master address */ +#define YPPUSH_YPERR ((long)-6) /* YP server/map db error */ +#define YPPUSH_BADARGS ((long)-7) /* Request arguments bad */ +#define YPPUSH_DBM ((long)-8) /* Local dbm operation failed */ +#define YPPUSH_FILE ((long)-9) /* Local file I/O operation failed */ +#define YPPUSH_SKEW ((long)-10) /* Map version skew during transfer */ +#define YPPUSH_CLEAR ((long)-11) /* Can't send "Clear" req to local ypserv */ +#define YPPUSH_FORCE ((long)-12) /* No local order number in map - use -f */ +#define YPPUSH_XFRERR ((long)-13) /* ypxfr error */ +#define YPPUSH_REFUSED ((long)-14) /* Transfer request refused by ypserv */ + +__BEGIN_DECLS +bool_t xdr_domainname __P((XDR *, char *)); +bool_t xdr_peername __P((XDR *, char *)); +bool_t xdr_datum __P((XDR *, datum *)); +bool_t xdr_mapname __P((XDR *, char *)); +bool_t xdr_ypreq_key __P((XDR *, struct ypreq_key *)); +bool_t xdr_ypreq_nokey __P((XDR *, struct ypreq_nokey *)); +bool_t xdr_yp_inaddr __P((XDR *, struct in_addr *)); +bool_t xdr_ypbind_binding __P((XDR *, struct ypbind_binding *)); +bool_t xdr_ypbind_resptype __P((XDR *, enum ypbind_resptype *)); +bool_t xdr_ypstat __P((XDR *, enum ypbind_resptype *)); +bool_t xdr_ypbind_resp __P((XDR *, struct ypbind_resp *)); +bool_t xdr_ypresp_val __P((XDR *, struct ypresp_val *)); +bool_t xdr_ypbind_setdom __P((XDR *, struct ypbind_setdom *)); +bool_t xdr_ypresp_key_val __P((XDR *, struct ypresp_key_val *)); +bool_t xdr_ypresp_all __P((XDR *, struct ypresp_all *)); +bool_t xdr_ypresp_all_seq __P((XDR *, u_long *)); +bool_t xdr_ypresp_master __P((XDR *, struct ypresp_master *)); +bool_t xdr_ypmaplist_str __P((XDR *, char *)); +bool_t xdr_ypmaplist __P((XDR *, struct ypmaplist *)); +bool_t xdr_ypresp_maplist __P((XDR *, struct ypresp_maplist *)); +bool_t xdr_ypresp_order __P((XDR *, struct ypresp_order *)); +__END_DECLS + +#endif /* _RPCSVC_YP_PROT_H_ */ diff --git a/src/include/rpcsvc/ypclnt.h b/src/include/rpcsvc/ypclnt.h new file mode 100644 index 00000000..dcdfce48 --- /dev/null +++ b/src/include/rpcsvc/ypclnt.h @@ -0,0 +1,88 @@ +/* $NetBSD: ypclnt.h,v 1.7 1995/07/14 21:11:10 christos Exp $ */ + +/* + * Copyright (c) 1992, 1993 Theo de Raadt <deraadt@fsa.ca> + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Theo de Raadt. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS + * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef _RPCSVC_YPCLNT_H_ +#define _RPCSVC_YPCLNT_H_ + +#define YPERR_BADARGS 1 /* args to function are bad */ +#define YPERR_RPC 2 /* RPC failure */ +#define YPERR_DOMAIN 3 /* can't bind to a server for domain */ +#define YPERR_MAP 4 /* no such map in server's domain */ +#define YPERR_KEY 5 /* no such key in map */ +#define YPERR_YPERR 6 /* some internal YP server or client error */ +#define YPERR_RESRC 7 /* local resource allocation failure */ +#define YPERR_NOMORE 8 /* no more records in map database */ +#define YPERR_PMAP 9 /* can't communicate with portmapper */ +#define YPERR_YPBIND 10 /* can't communicate with ypbind */ +#define YPERR_YPSERV 11 /* can't communicate with ypserv */ +#define YPERR_NODOM 12 /* local domain name not set */ +#define YPERR_BADDB 13 /* YP data base is bad */ +#define YPERR_VERS 14 /* YP version mismatch */ +#define YPERR_ACCESS 15 /* access violation */ +#define YPERR_BUSY 16 /* database is busy */ + +/* + * Types of update operations + */ +#define YPOP_CHANGE 1 /* change, do not add */ +#define YPOP_INSERT 2 /* add, do not change */ +#define YPOP_DELETE 3 /* delete this entry */ +#define YPOP_STORE 4 /* add, or change */ + +struct ypall_callback { + /* return non-0 to stop getting called */ + int (*foreach) __P((u_long, char *, int, char *, int, void *)); + char *data; /* opaque pointer for use of callback fn */ +}; + +__BEGIN_DECLS +int yp_bind __P((const char *)); +struct dom_binding; +int _yp_dobind __P((const char *, struct dom_binding **)); +void yp_unbind __P((const char *)); +int yp_get_default_domain __P((char **)); +int yp_match __P((const char *, const char *, const char *, + int , char **, int *)); +int yp_first __P((const char *, const char *, char **, int *, + char **, int *)); +int yp_next __P((const char *, const char *, const char *, + int, char **, int *, char **, int *)); +int yp_master __P((const char *, const char *, char **)); +int yp_order __P((const char *, const char *, int *)); +int yp_all __P((const char *, const char *, + struct ypall_callback *)); +char * yperr_string __P((int)); +int ypprot_err __P((unsigned int)); +__END_DECLS + +#endif /* _RPCSVC_YPCLNT_H_ */ diff --git a/src/include/search.h b/src/include/search.h new file mode 100644 index 00000000..a2889bfd --- /dev/null +++ b/src/include/search.h @@ -0,0 +1,57 @@ +/* $NetBSD: search.h,v 1.9 1995/08/08 21:14:45 jtc Exp $ */ + +/* + * Written by J.T. Conklin <jtc@netbsd.org> + * Public domain. + */ + +#ifndef _SEARCH_H_ +#define _SEARCH_H_ +#include <sys/cdefs.h> +#include <machine/ansi.h> + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +typedef struct entry { + char *key; + char *data; +} ENTRY; + +typedef enum { + FIND, ENTER +} ACTION; + +typedef enum { + preorder, + postorder, + endorder, + leaf +} VISIT; + +__BEGIN_DECLS +extern void *bsearch __P((const void *, const void *, size_t, size_t, + int (*)(const void *, const void *))); +extern int hcreate __P((unsigned int)); +extern void hdestroy __P((void)); +extern ENTRY *hsearch __P((ENTRY, ACTION)); + +extern void *lfind __P((const void *, const void *, size_t *, size_t, + int (*)(const void *, const void *))); +extern void *lsearch __P((const void *, const void *, size_t *, size_t, + int (*)(const void *, const void *))); +extern void insque __P((void *, void *)); +extern void remque __P((void *)); + +extern void *tdelete __P((const void *, void **, + int (*)(const void *, const void *))); +extern void *tfind __P((const void *, void **, + int (*)(const void *, const void *))); +extern void *tsearch __P((const void *, void **, + int (*)(const void *, const void *))); +extern void twalk __P((const void *, void (*)(const void *, VISIT, int))); +__END_DECLS + +#endif diff --git a/src/include/setjmp.h b/src/include/setjmp.h new file mode 100644 index 00000000..187ff762 --- /dev/null +++ b/src/include/setjmp.h @@ -0,0 +1,72 @@ +/* $NetBSD: setjmp.h,v 1.11 1994/12/20 10:35:44 cgd Exp $ */ + +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)setjmp.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _SETJMP_H_ +#define _SETJMP_H_ + +#include <machine/setjmp.h> + +#ifndef _ANSI_SOURCE +typedef long sigjmp_buf[_JBLEN + 1]; +#endif /* not ANSI */ + +typedef long jmp_buf[_JBLEN]; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +int setjmp __P((jmp_buf)); +void longjmp __P((jmp_buf, int)); + +#ifndef _ANSI_SOURCE +int sigsetjmp __P((sigjmp_buf, int)); +void siglongjmp __P((sigjmp_buf, int)); +#endif /* not ANSI */ + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +int _setjmp __P((jmp_buf)); +void _longjmp __P((jmp_buf, int)); +void longjmperror __P((void)); +#endif /* neither ANSI nor POSIX */ +__END_DECLS + +#endif /* !_SETJMP_H_ */ diff --git a/src/include/sgtty.h b/src/include/sgtty.h new file mode 100644 index 00000000..a37e0db4 --- /dev/null +++ b/src/include/sgtty.h @@ -0,0 +1,47 @@ +/* $NetBSD: sgtty.h,v 1.4 1995/06/05 19:40:33 pk Exp $ */ + +/* + * Copyright (c) 1985 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)sgtty.h 5.2 (Berkeley) 6/26/91 + */ + +#ifndef USE_OLD_TTY +#define USE_OLD_TTY +#endif +#include <sys/ioctl.h> +#include <sys/cdefs.h> + +__BEGIN_DECLS +int gtty __P((int, struct sgttyb *)); +int stty __P((int, struct sgttyb *)); +__END_DECLS diff --git a/src/include/signal.h b/src/include/signal.h new file mode 100644 index 00000000..45d50e93 --- /dev/null +++ b/src/include/signal.h @@ -0,0 +1,119 @@ +/* $NetBSD: signal.h,v 1.7 1995/05/28 03:10:06 jtc Exp $ */ + +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)signal.h 8.3 (Berkeley) 3/30/94 + */ + +#ifndef _USER_SIGNAL_H +#define _USER_SIGNAL_H + +#include <sys/cdefs.h> +#include <sys/signal.h> + +#if !defined(_ANSI_SOURCE) +#include <sys/types.h> +#endif + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +extern __const char *__const sys_signame[_NSIG]; +extern __const char *__const sys_siglist[_NSIG]; +#endif + +__BEGIN_DECLS +int raise __P((int)); +#ifndef _ANSI_SOURCE +int kill __P((pid_t, int)); +int sigaction __P((int, const struct sigaction *, struct sigaction *)); +int sigaddset __P((sigset_t *, int)); +int sigdelset __P((sigset_t *, int)); +int sigemptyset __P((sigset_t *)); +int sigfillset __P((sigset_t *)); +int sigismember __P((const sigset_t *, int)); +int sigpending __P((sigset_t *)); +int sigprocmask __P((int, const sigset_t *, sigset_t *)); +int sigsuspend __P((const sigset_t *)); + +#if defined(__GNUC__) && defined(__STDC__) +extern __inline int sigaddset(sigset_t *set, int signo) { + extern int errno; + + if (signo <= 0 || signo >= _NSIG) { + errno = 22; /* EINVAL */ + return -1; + } + *set |= (1 << ((signo)-1)); /* sigmask(signo) */ + return (0); +} + +extern __inline int sigdelset(sigset_t *set, int signo) { + extern int errno; + + if (signo <= 0 || signo >= _NSIG) { + errno = 22; /* EINVAL */ + return -1; + } + *set &= ~(1 << ((signo)-1)); /* sigmask(signo) */ + return (0); +} + +extern __inline int sigismember(const sigset_t *set, int signo) { + extern int errno; + + if (signo <= 0 || signo >= _NSIG) { + errno = 22; /* EINVAL */ + return -1; + } + return ((*set & (1 << ((signo)-1))) != 0); +} +#endif + +/* List definitions after function declarations, or Reiser cpp gets upset. */ +#define sigemptyset(set) (*(set) = 0, 0) +#define sigfillset(set) (*(set) = ~(sigset_t)0, 0) + +#ifndef _POSIX_SOURCE +int killpg __P((pid_t, int)); +int sigblock __P((int)); +int siginterrupt __P((int, int)); +int sigpause __P((int)); +int sigreturn __P((struct sigcontext *)); +int sigsetmask __P((int)); +int sigstack __P((const struct sigstack *, struct sigstack *)); +int sigvec __P((int, struct sigvec *, struct sigvec *)); +void psignal __P((unsigned int, const char *)); +#endif /* !_POSIX_SOURCE */ +#endif /* !_ANSI_SOURCE */ +__END_DECLS + +#endif /* !_USER_SIGNAL_H */ diff --git a/src/include/stab.h b/src/include/stab.h new file mode 100644 index 00000000..6b9cb01b --- /dev/null +++ b/src/include/stab.h @@ -0,0 +1,74 @@ +/* $NetBSD: stab.h,v 1.4 1994/10/26 00:56:25 cgd Exp $ */ + +/*- + * Copyright (c) 1991 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stab.h 5.2 (Berkeley) 4/4/91 + */ + +#ifndef _STAB_H_ +#define _STAB_H_ + +/* + * The following are symbols used by various debuggers and by the Pascal + * compiler. Each of them must have one (or more) of the bits defined by + * the N_STAB mask set. + */ + +#define N_GSYM 0x20 /* global symbol */ +#define N_FNAME 0x22 /* F77 function name */ +#define N_FUN 0x24 /* procedure name */ +#define N_STSYM 0x26 /* data segment variable */ +#define N_LCSYM 0x28 /* bss segment variable */ +#define N_MAIN 0x2a /* main function name */ +#define N_PC 0x30 /* global Pascal symbol */ +#define N_RSYM 0x40 /* register variable */ +#define N_SLINE 0x44 /* text segment line number */ +#define N_DSLINE 0x46 /* data segment line number */ +#define N_BSLINE 0x48 /* bss segment line number */ +#define N_SSYM 0x60 /* structure/union element */ +#define N_SO 0x64 /* main source file name */ +#define N_LSYM 0x80 /* stack variable */ +#define N_BINCL 0x82 /* include file beginning */ +#define N_SOL 0x84 /* included source file name */ +#define N_PSYM 0xa0 /* parameter variable */ +#define N_EINCL 0xa2 /* include file end */ +#define N_ENTRY 0xa4 /* alternate entry point */ +#define N_LBRAC 0xc0 /* left bracket */ +#define N_EXCL 0xc2 /* deleted include file */ +#define N_RBRAC 0xe0 /* right bracket */ +#define N_BCOMM 0xe2 /* begin common */ +#define N_ECOMM 0xe4 /* end common */ +#define N_ECOML 0xe8 /* end common (local name) */ +#define N_LENG 0xfe /* length of preceding entry */ + +#endif /* !_STAB_H_ */ diff --git a/src/include/stddef.h b/src/include/stddef.h new file mode 100644 index 00000000..818be650 --- /dev/null +++ b/src/include/stddef.h @@ -0,0 +1,61 @@ +/* $NetBSD: stddef.h,v 1.4 1994/10/26 00:56:26 cgd Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stddef.h 5.5 (Berkeley) 4/3/91 + */ + +#ifndef _STDDEF_H_ +#define _STDDEF_H_ + +#include <machine/ansi.h> + +typedef _BSD_PTRDIFF_T_ ptrdiff_t; + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#ifdef _BSD_WCHAR_T_ +typedef _BSD_WCHAR_T_ wchar_t; +#undef _BSD_WCHAR_T_ +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#define offsetof(type, member) ((size_t)(&((type *)0)->member)) + +#endif /* _STDDEF_H_ */ diff --git a/src/include/stdio.h b/src/include/stdio.h new file mode 100644 index 00000000..1ece1e7c --- /dev/null +++ b/src/include/stdio.h @@ -0,0 +1,375 @@ +/* $NetBSD: stdio.h,v 1.16 1995/03/25 02:51:02 jtc Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stdio.h 5.17 (Berkeley) 6/3/91 + */ + +#ifndef _STDIO_H_ +#define _STDIO_H_ + +#if !defined(_ANSI_SOURCE) && !defined(__STRICT_ANSI_) +#include <sys/types.h> +#endif + +#include <sys/cdefs.h> + +#include <machine/ansi.h> +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#ifndef NULL +#define NULL 0 +#endif + +/* + * This is fairly grotesque, but pure ANSI code must not inspect the + * innards of an fpos_t anyway. The library internally uses off_t, + * which we assume is exactly as big as eight chars. + */ +#if !defined(_ANSI_SOURCE) && !defined(__STRICT_ANSI__) +typedef off_t fpos_t; +#else +typedef struct __sfpos { + long long _pos; /* XXX must be the same as off_t */ +} fpos_t; +#endif + +#define _FSTDIO /* Define for new stdio with functions. */ + +/* + * NB: to fit things in six character monocase externals, the stdio + * code uses the prefix `__s' for stdio objects, typically followed + * by a three-character attempt at a mnemonic. + */ + +/* stdio buffers */ +struct __sbuf { + unsigned char *_base; + int _size; +}; + +/* + * stdio state variables. + * + * The following always hold: + * + * if (_flags&(__SLBF|__SWR)) == (__SLBF|__SWR), + * _lbfsize is -_bf._size, else _lbfsize is 0 + * if _flags&__SRD, _w is 0 + * if _flags&__SWR, _r is 0 + * + * This ensures that the getc and putc macros (or inline functions) never + * try to write or read from a file that is in `read' or `write' mode. + * (Moreover, they can, and do, automatically switch from read mode to + * write mode, and back, on "r+" and "w+" files.) + * + * _lbfsize is used only to make the inline line-buffered output stream + * code as compact as possible. + * + * _ub, _up, and _ur are used when ungetc() pushes back more characters + * than fit in the current _bf, or when ungetc() pushes back a character + * that does not match the previous one in _bf. When this happens, + * _ub._base becomes non-nil (i.e., a stream has ungetc() data iff + * _ub._base!=NULL) and _up and _ur save the current values of _p and _r. + */ +typedef struct __sFILE { + unsigned char *_p; /* current position in (some) buffer */ + int _r; /* read space left for getc() */ + int _w; /* write space left for putc() */ + short _flags; /* flags, below; this FILE is free if 0 */ + short _file; /* fileno, if Unix descriptor, else -1 */ + struct __sbuf _bf; /* the buffer (at least 1 byte, if !NULL) */ + int _lbfsize; /* 0 or -_bf._size, for inline putc */ + + /* operations */ + void *_cookie; /* cookie passed to io functions */ + int (*_close) __P((void *)); + int (*_read) __P((void *, char *, int)); + fpos_t (*_seek) __P((void *, fpos_t, int)); + int (*_write) __P((void *, const char *, int)); + + /* separate buffer for long sequences of ungetc() */ + struct __sbuf _ub; /* ungetc buffer */ + unsigned char *_up; /* saved _p when _p is doing ungetc data */ + int _ur; /* saved _r when _r is counting ungetc data */ + + /* tricks to meet minimum requirements even when malloc() fails */ + unsigned char _ubuf[3]; /* guarantee an ungetc() buffer */ + unsigned char _nbuf[1]; /* guarantee a getc() buffer */ + + /* separate buffer for fgetln() when line crosses buffer boundary */ + struct __sbuf _lb; /* buffer for fgetln() */ + + /* Unix stdio files get aligned to block boundaries on fseek() */ + int _blksize; /* stat.st_blksize (may be != _bf._size) */ + fpos_t _offset; /* current lseek offset */ +} FILE; + +__BEGIN_DECLS +extern FILE __sF[]; +__END_DECLS + +#define __SLBF 0x0001 /* line buffered */ +#define __SNBF 0x0002 /* unbuffered */ +#define __SRD 0x0004 /* OK to read */ +#define __SWR 0x0008 /* OK to write */ + /* RD and WR are never simultaneously asserted */ +#define __SRW 0x0010 /* open for reading & writing */ +#define __SEOF 0x0020 /* found EOF */ +#define __SERR 0x0040 /* found error */ +#define __SMBF 0x0080 /* _buf is from malloc */ +#define __SAPP 0x0100 /* fdopen()ed in append mode */ +#define __SSTR 0x0200 /* this is an sprintf/snprintf string */ +#define __SOPT 0x0400 /* do fseek() optimisation */ +#define __SNPT 0x0800 /* do not do fseek() optimisation */ +#define __SOFF 0x1000 /* set iff _offset is in fact correct */ +#define __SMOD 0x2000 /* true => fgetln modified _p text */ + +/* + * The following three definitions are for ANSI C, which took them + * from System V, which brilliantly took internal interface macros and + * made them official arguments to setvbuf(), without renaming them. + * Hence, these ugly _IOxxx names are *supposed* to appear in user code. + * + * Although numbered as their counterparts above, the implementation + * does not rely on this. + */ +#define _IOFBF 0 /* setvbuf should set fully buffered */ +#define _IOLBF 1 /* setvbuf should set line buffered */ +#define _IONBF 2 /* setvbuf should set unbuffered */ + +#define BUFSIZ 1024 /* size of buffer used by setbuf */ +#define EOF (-1) + +/* + * FOPEN_MAX is a minimum maximum, and should be the number of descriptors + * that the kernel can provide without allocation of a resource that can + * fail without the process sleeping. Do not use this for anything. + */ +#define FOPEN_MAX 20 /* must be <= OPEN_MAX <sys/syslimits.h> */ +#define FILENAME_MAX 1024 /* must be <= PATH_MAX <sys/syslimits.h> */ + +/* System V/ANSI C; this is the wrong way to do this, do *not* use these. */ +#ifndef _ANSI_SOURCE +#define P_tmpdir "/var/tmp/" +#endif +#define L_tmpnam 1024 /* XXX must be == PATH_MAX */ +#define TMP_MAX 308915776 + +#ifndef SEEK_SET +#define SEEK_SET 0 /* set file offset to offset */ +#endif +#ifndef SEEK_CUR +#define SEEK_CUR 1 /* set file offset to current plus offset */ +#endif +#ifndef SEEK_END +#define SEEK_END 2 /* set file offset to EOF plus offset */ +#endif + +#define stdin (&__sF[0]) +#define stdout (&__sF[1]) +#define stderr (&__sF[2]) + +/* + * Functions defined in ANSI C standard. + */ +__BEGIN_DECLS +void clearerr __P((FILE *)); +int fclose __P((FILE *)); +int feof __P((FILE *)); +int ferror __P((FILE *)); +int fflush __P((FILE *)); +int fgetc __P((FILE *)); +int fgetpos __P((FILE *, fpos_t *)); +char *fgets __P((char *, int, FILE *)); +FILE *fopen __P((const char *, const char *)); +int fprintf __P((FILE *, const char *, ...)); +int fputc __P((int, FILE *)); +int fputs __P((const char *, FILE *)); +size_t fread __P((void *, size_t, size_t, FILE *)); +FILE *freopen __P((const char *, const char *, FILE *)); +int fscanf __P((FILE *, const char *, ...)); +int fseek __P((FILE *, long, int)); +int fsetpos __P((FILE *, const fpos_t *)); +long ftell __P((FILE *)); +size_t fwrite __P((const void *, size_t, size_t, FILE *)); +int getc __P((FILE *)); +int getchar __P((void)); +char *gets __P((char *)); +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +extern int sys_nerr; /* perror(3) external variables */ +extern const char *const sys_errlist[]; +#endif +void perror __P((const char *)); +int printf __P((const char *, ...)); +int putc __P((int, FILE *)); +int putchar __P((int)); +int puts __P((const char *)); +int remove __P((const char *)); +int rename __P((const char *, const char *)); +void rewind __P((FILE *)); +int scanf __P((const char *, ...)); +void setbuf __P((FILE *, char *)); +int setvbuf __P((FILE *, char *, int, size_t)); +int sprintf __P((char *, const char *, ...)); +int sscanf __P((const char *, const char *, ...)); +FILE *tmpfile __P((void)); +char *tmpnam __P((char *)); +int ungetc __P((int, FILE *)); +int vfprintf __P((FILE *, const char *, _BSD_VA_LIST_)); +int vprintf __P((const char *, _BSD_VA_LIST_)); +int vsprintf __P((char *, const char *, _BSD_VA_LIST_)); +__END_DECLS + +/* + * Functions defined in POSIX 1003.1. + */ +#ifndef _ANSI_SOURCE +#define L_ctermid 1024 /* size for ctermid(); PATH_MAX */ +#define L_cuserid 9 /* size for cuserid(); UT_NAMESIZE + 1 */ + +__BEGIN_DECLS +char *ctermid __P((char *)); +char *cuserid __P((char *)); +FILE *fdopen __P((int, const char *)); +int fileno __P((FILE *)); +__END_DECLS +#endif /* not ANSI */ + +/* + * Routines that are purely local. + */ +#if !defined (_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +__BEGIN_DECLS +char *fgetln __P((FILE *, size_t *)); +int fpurge __P((FILE *)); +int getw __P((FILE *)); +int pclose __P((FILE *)); +FILE *popen __P((const char *, const char *)); +int putw __P((int, FILE *)); +void setbuffer __P((FILE *, char *, int)); +int setlinebuf __P((FILE *)); +char *tempnam __P((const char *, const char *)); +int snprintf __P((char *, size_t, const char *, ...)) + __attribute__((format (printf, 3, 4))); +int vsnprintf __P((char *, size_t, const char *, _BSD_VA_LIST_)) + __attribute__((format (printf, 3, 0))); +int vscanf __P((const char *, _BSD_VA_LIST_)) + __attribute__((format (scanf, 1, 0))); +int vsscanf __P((const char *, const char *, _BSD_VA_LIST_)) + __attribute__((format (scanf, 2, 0))); +__END_DECLS + +/* + * This is a #define because the function is used internally and + * (unlike vfscanf) the name __svfscanf is guaranteed not to collide + * with a user function when _ANSI_SOURCE or _POSIX_SOURCE is defined. + */ +#define vfscanf __svfscanf + +/* + * Stdio function-access interface. + */ +__BEGIN_DECLS +FILE *funopen __P((const void *, + int (*)(void *, char *, int), + int (*)(void *, const char *, int), + fpos_t (*)(void *, fpos_t, int), + int (*)(void *))); +__END_DECLS +#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0) +#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0) +#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ + +/* + * Functions internal to the implementation. + */ +__BEGIN_DECLS +int __srget __P((FILE *)); +int __svfscanf __P((FILE *, const char *, _BSD_VA_LIST_)); +int __swbuf __P((int, FILE *)); +__END_DECLS + +/* + * The __sfoo macros are here so that we can + * define function versions in the C library. + */ +#define __sgetc(p) (--(p)->_r < 0 ? __srget(p) : (int)(*(p)->_p++)) +#if defined(__GNUC__) && defined(__STDC__) +static __inline int __sputc(int _c, FILE *_p) { + if (--_p->_w >= 0 || (_p->_w >= _p->_lbfsize && (char)_c != '\n')) + return (*_p->_p++ = _c); + else + return (__swbuf(_c, _p)); +} +#else +/* + * This has been tuned to generate reasonable code on the vax using pcc. + */ +#define __sputc(c, p) \ + (--(p)->_w < 0 ? \ + (p)->_w >= (p)->_lbfsize ? \ + (*(p)->_p = (c)), *(p)->_p != '\n' ? \ + (int)*(p)->_p++ : \ + __swbuf('\n', p) : \ + __swbuf((int)(c), p) : \ + (*(p)->_p = (c), (int)*(p)->_p++)) +#endif + +#define __sfeof(p) (((p)->_flags & __SEOF) != 0) +#define __sferror(p) (((p)->_flags & __SERR) != 0) +#define __sclearerr(p) ((void)((p)->_flags &= ~(__SERR|__SEOF))) +#define __sfileno(p) ((p)->_file) + +#define feof(p) __sfeof(p) +#define ferror(p) __sferror(p) +#define clearerr(p) __sclearerr(p) + +#ifndef _ANSI_SOURCE +#define fileno(p) __sfileno(p) +#endif + +#ifndef lint +#define getc(fp) __sgetc(fp) +#define putc(x, fp) __sputc(x, fp) +#endif /* lint */ + +#define getchar() getc(stdin) +#define putchar(x) putc(x, stdout) +#endif /* _STDIO_H_ */ diff --git a/src/include/stdlib.h b/src/include/stdlib.h new file mode 100644 index 00000000..c42440b9 --- /dev/null +++ b/src/include/stdlib.h @@ -0,0 +1,197 @@ +/* $NetBSD: stdlib.h,v 1.24 1995/03/22 01:08:31 jtc Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)stdlib.h 5.13 (Berkeley) 6/4/91 + */ + +#ifndef _STDLIB_H_ +#define _STDLIB_H_ +#include <machine/ansi.h> + +#if !defined(_ANSI_SOURCE) /* for quad_t, etc. */ +#include <sys/types.h> +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#ifdef _BSD_WCHAR_T_ +typedef _BSD_WCHAR_T_ wchar_t; +#undef _BSD_WCHAR_T_ +#endif + +typedef struct { + int quot; /* quotient */ + int rem; /* remainder */ +} div_t; + +typedef struct { + long quot; /* quotient */ + long rem; /* remainder */ +} ldiv_t; + +#if !defined(_ANSI_SOURCE) +typedef struct { + quad_t quot; /* quotient */ + quad_t rem; /* remainder */ +} qdiv_t; +#endif + + +#ifndef NULL +#define NULL 0 +#endif + +#define EXIT_FAILURE 1 +#define EXIT_SUCCESS 0 + +#define RAND_MAX 0x7fffffff + +#define MB_CUR_MAX 1 /* XXX */ + +#include <sys/cdefs.h> + +__BEGIN_DECLS +void abort __P((void)); +int abs __P((int)); +int atexit __P((void (*)(void))); +double atof __P((const char *)); +int atoi __P((const char *)); +long atol __P((const char *)); +void *bsearch __P((const void *, const void *, size_t, + size_t, int (*)(const void *, const void *))); +void *calloc __P((size_t, size_t)); +div_t div __P((int, int)); +void exit __P((int)); +void free __P((void *)); +char *getenv __P((const char *)); +long labs __P((long)); +ldiv_t ldiv __P((long, long)); +void *malloc __P((size_t)); +void qsort __P((void *, size_t, size_t, + int (*)(const void *, const void *))); +int rand __P((void)); +void *realloc __P((void *, size_t)); +void srand __P((unsigned)); +double strtod __P((const char *, char **)); +long strtol __P((const char *, char **, int)); +unsigned long + strtoul __P((const char *, char **, int)); +int system __P((const char *)); + +/* these are currently just stubs */ +int mblen __P((const char *, size_t)); +size_t mbstowcs __P((wchar_t *, const char *, size_t)); +int wctomb __P((char *, wchar_t)); +int mbtowc __P((wchar_t *, const char *, size_t)); +size_t wcstombs __P((char *, const wchar_t *, size_t)); + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +#if defined(alloca) && (alloca == __builtin_alloca) && (__GNUC__ < 2) +void *alloca __P((int)); /* built-in for gcc */ +#else +void *alloca __P((size_t)); +#endif /* __GNUC__ */ + +char *getbsize __P((int *, long *)); +char *cgetcap __P((char *, char *, int)); +int cgetclose __P((void)); +int cgetent __P((char **, char **, char *)); +int cgetfirst __P((char **, char **)); +int cgetmatch __P((char *, char *)); +int cgetnext __P((char **, char **)); +int cgetnum __P((char *, char *, long *)); +int cgetset __P((char *)); +int cgetstr __P((char *, char *, char **)); +int cgetustr __P((char *, char *, char **)); + +int daemon __P((int, int)); +char *devname __P((int, int)); +int getloadavg __P((double [], int)); + +long a64l __P((const char *)); +char *l64a __P((long)); + +void cfree __P((void *)); + +int getopt __P((int, char * const *, const char *)); +extern char *optarg; /* getopt(3) external variables */ +extern int opterr; +extern int optind; +extern int optopt; +extern int optreset; +int getsubopt __P((char **, char * const *, char **)); +extern char *suboptarg; /* getsubopt(3) external variable */ + +int heapsort __P((void *, size_t, size_t, + int (*)(const void *, const void *))); +int mergesort __P((void *, size_t, size_t, + int (*)(const void *, const void *))); +int radixsort __P((const unsigned char **, int, const unsigned char *, + unsigned)); +int sradixsort __P((const unsigned char **, int, const unsigned char *, + unsigned)); + +char *initstate __P((unsigned, char *, int)); +long random __P((void)); +char *realpath __P((const char *, char *)); +char *setstate __P((char *)); +void srandom __P((unsigned)); + +int putenv __P((const char *)); +int setenv __P((const char *, const char *, int)); +void unsetenv __P((const char *)); +void setproctitle __P((const char *, ...)); + +quad_t qabs __P((quad_t)); +qdiv_t qdiv __P((quad_t, quad_t)); +quad_t strtoq __P((const char *, char **, int)); +u_quad_t strtouq __P((const char *, char **, int)); + +double drand48 __P((void)); +double erand48 __P((unsigned short[3])); +long jrand48 __P((unsigned short[3])); +void lcong48 __P((unsigned short[7])); +long lrand48 __P((void)); +long mrand48 __P((void)); +long nrand48 __P((unsigned short[3])); +unsigned short *seed48 __P((unsigned short[3])); +void srand48 __P((long)); +#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ + +__END_DECLS + +#endif /* _STDLIB_H_ */ diff --git a/src/include/string.h b/src/include/string.h new file mode 100644 index 00000000..b1029409 --- /dev/null +++ b/src/include/string.h @@ -0,0 +1,96 @@ +/* $NetBSD: string.h,v 1.6 1994/10/26 00:56:30 cgd Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)string.h 5.10 (Berkeley) 3/9/91 + */ + +#ifndef _STRING_H_ +#define _STRING_H_ +#include <machine/ansi.h> + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#ifndef NULL +#define NULL 0 +#endif + +#include <sys/cdefs.h> + +__BEGIN_DECLS +void *memchr __P((const void *, int, size_t)); +int memcmp __P((const void *, const void *, size_t)); +void *memcpy __P((void *, const void *, size_t)); +void *memmove __P((void *, const void *, size_t)); +void *memset __P((void *, int, size_t)); +char *strcat __P((char *, const char *)); +char *strchr __P((const char *, int)); +int strcmp __P((const char *, const char *)); +int strcoll __P((const char *, const char *)); +char *strcpy __P((char *, const char *)); +size_t strcspn __P((const char *, const char *)); +char *strerror __P((int)); +size_t strlen __P((const char *)); +char *strncat __P((char *, const char *, size_t)); +int strncmp __P((const char *, const char *, size_t)); +char *strncpy __P((char *, const char *, size_t)); +char *strpbrk __P((const char *, const char *)); +char *strrchr __P((const char *, int)); +size_t strspn __P((const char *, const char *)); +char *strstr __P((const char *, const char *)); +char *strtok __P((char *, const char *)); +size_t strxfrm __P((char *, const char *, size_t)); + +/* Nonstandard routines */ +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +int bcmp __P((const void *, const void *, size_t)); +void bcopy __P((const void *, void *, size_t)); +void bzero __P((void *, size_t)); +int ffs __P((int)); +char *index __P((const char *, int)); +void *memccpy __P((void *, const void *, int, size_t)); +char *rindex __P((const char *, int)); +int strcasecmp __P((const char *, const char *)); +char *strdup __P((const char *)); +void strmode __P((int, char *)); +int strncasecmp __P((const char *, const char *, size_t)); +char *strsep __P((char **, const char *)); +char *strsignal __P((int)); +void swab __P((const void *, void *, size_t)); +#endif +__END_DECLS + +#endif /* _STRING_H_ */ diff --git a/src/include/strings.h b/src/include/strings.h new file mode 100644 index 00000000..a4866f6e --- /dev/null +++ b/src/include/strings.h @@ -0,0 +1,38 @@ +/* $NetBSD: strings.h,v 1.3 1994/10/26 00:56:31 cgd Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)strings.h 5.8 (Berkeley) 5/15/90 + */ + +#include <string.h> diff --git a/src/include/struct.h b/src/include/struct.h new file mode 100644 index 00000000..0a23b4a4 --- /dev/null +++ b/src/include/struct.h @@ -0,0 +1,53 @@ +/* $NetBSD: struct.h,v 1.3 1994/10/26 00:56:32 cgd Exp $ */ + +/*- + * Copyright (c) 1983 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)struct.h 5.2 (Berkeley) 4/3/91 + */ + +#ifndef _STRUCT_H_ +#define _STRUCT_H_ + +/* Offset of the field in the structure. */ +#define fldoff(name, field) \ + ((int)&(((struct name *)0)->field)) + +/* Size of the field in the structure. */ +#define fldsiz(name, field) \ + (sizeof(((struct name *)0)->field)) + +/* Address of the structure from a field. */ +#define strbase(name, addr, field) \ + ((struct name *)((char *)(addr) - fldoff(name, field))) + +#endif /* !_STRUCT_H_ */ diff --git a/src/include/sysexits.h b/src/include/sysexits.h new file mode 100644 index 00000000..c4f522e2 --- /dev/null +++ b/src/include/sysexits.h @@ -0,0 +1,120 @@ +/* $NetBSD: sysexits.h,v 1.4 1994/10/26 00:56:33 cgd Exp $ */ + +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)sysexits.h 4.8 (Berkeley) 4/3/91 + */ + +#ifndef _SYSEXITS_H_ +#define _SYSEXITS_H_ + +/* + * 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. + */ + +#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 */ +#define EX_CONFIG 78 /* configuration error */ + +#define EX__MAX 78 /* maximum listed value */ + +#endif /* !_SYSEXITS_H_ */ diff --git a/src/include/time.h b/src/include/time.h new file mode 100644 index 00000000..b99ce5d9 --- /dev/null +++ b/src/include/time.h @@ -0,0 +1,109 @@ +/* $NetBSD: time.h,v 1.9 1994/10/26 00:56:35 cgd Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)time.h 5.12 (Berkeley) 3/9/91 + */ + +#ifndef _TIME_H_ +#define _TIME_H_ + +#include <machine/ansi.h> + +#ifndef NULL +#define NULL 0 +#endif + +#ifdef _BSD_CLOCK_T_ +typedef _BSD_CLOCK_T_ clock_t; +#undef _BSD_CLOCK_T_ +#endif + +#ifdef _BSD_TIME_T_ +typedef _BSD_TIME_T_ time_t; +#undef _BSD_TIME_T_ +#endif + +#ifdef _BSD_SIZE_T_ +typedef _BSD_SIZE_T_ size_t; +#undef _BSD_SIZE_T_ +#endif + +#define CLOCKS_PER_SEC 100 + +struct tm { + int tm_sec; /* seconds after the minute [0-60] */ + int tm_min; /* minutes after the hour [0-59] */ + int tm_hour; /* hours since midnight [0-23] */ + int tm_mday; /* day of the month [1-31] */ + int tm_mon; /* months since January [0-11] */ + int tm_year; /* years since 1900 */ + int tm_wday; /* days since Sunday [0-6] */ + int tm_yday; /* days since January 1 [0-365] */ + int tm_isdst; /* Daylight Savings Time flag */ + long tm_gmtoff; /* offset from CUT in seconds */ + char *tm_zone; /* timezone abbreviation */ +}; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +char *asctime __P((const struct tm *)); +clock_t clock __P((void)); +char *ctime __P((const time_t *)); +double difftime __P((time_t, time_t)); +struct tm *gmtime __P((const time_t *)); +struct tm *localtime __P((const time_t *)); +time_t mktime __P((struct tm *)); +size_t strftime __P((char *, size_t, const char *, const struct tm *)); +time_t time __P((time_t *)); + +#if !defined(_ANSI_SOURCE) +#define CLK_TCK 100 +extern char *tzname[2]; +void tzset __P((void)); +#endif /* not ANSI */ + +#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) +char *timezone __P((int, int)); +void tzsetwall __P((void)); +#endif /* neither ANSI nor POSIX */ +__END_DECLS + +#endif /* !_TIME_H_ */ diff --git a/src/include/ttyent.h b/src/include/ttyent.h new file mode 100644 index 00000000..de6a21e5 --- /dev/null +++ b/src/include/ttyent.h @@ -0,0 +1,76 @@ +/* $NetBSD: ttyent.h,v 1.5 1994/10/26 00:56:36 cgd Exp $ */ + +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)ttyent.h 5.7 (Berkeley) 4/3/91 + */ + +#ifndef _TTYENT_H_ +#define _TTYENT_H_ + +#define _PATH_TTYS "/etc/ttys" + +#define _TTYS_OFF "off" +#define _TTYS_ON "on" +#define _TTYS_SECURE "secure" +#define _TTYS_WINDOW "window" +#define _TTYS_LOCAL "local" +#define _TTYS_RTSCTS "rtscts" +#define _TTYS_SOFTCAR "softcar" +#define _TTYS_MDMBUF "mdmbuf" + +struct ttyent { + char *ty_name; /* terminal device name */ + char *ty_getty; /* command to execute, usually getty */ + char *ty_type; /* terminal type for termcap */ +#define TTY_ON 0x01 /* enable logins (start ty_getty program) */ +#define TTY_SECURE 0x02 /* allow uid of 0 to login */ +#define TTY_LOCAL 0x04 /* set 'CLOCAL' on open (dev. specific) */ +#define TTY_RTSCTS 0x08 /* set 'CRTSCTS' on open (dev. specific) */ +#define TTY_SOFTCAR 0x10 /* ignore hardware carrier (dev. spec.) */ +#define TTY_MDMBUF 0x20 /* set 'MDMBUF' on open (dev. specific) */ + int ty_status; /* status flags */ + char *ty_window; /* command to start up window manager */ + char *ty_comment; /* comment field */ +}; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +struct ttyent *getttyent __P((void)); +struct ttyent *getttynam __P((const char *)); +int setttyent __P((void)); +int endttyent __P((void)); +__END_DECLS + +#endif /* !_TTYENT_H_ */ diff --git a/src/include/tzfile.h b/src/include/tzfile.h new file mode 100644 index 00000000..7f796c55 --- /dev/null +++ b/src/include/tzfile.h @@ -0,0 +1,153 @@ +/* $NetBSD: tzfile.h,v 1.3 1994/10/26 00:56:37 cgd Exp $ */ + +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Arthur David Olson of the National Cancer Institute. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)tzfile.h 5.10 (Berkeley) 4/3/91 + */ + +#ifndef _TZFILE_H_ +#define _TZFILE_H_ + +/* + * Information about time zone files. + */ + /* Time zone object file directory */ +#define TZDIR "/usr/share/zoneinfo" +#define TZDEFAULT "/etc/localtime" +#define TZDEFRULES "posixrules" + +/* +** Each file begins with. . . +*/ + +struct tzhead { + char tzh_reserved[24]; /* reserved for future use */ + char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ + char tzh_leapcnt[4]; /* coded number of leap seconds */ + char tzh_timecnt[4]; /* coded number of transition times */ + char tzh_typecnt[4]; /* coded number of local time types */ + char tzh_charcnt[4]; /* coded number of abbr. chars */ +}; + +/* +** . . .followed by. . . +** +** tzh_timecnt (char [4])s coded transition times a la time(2) +** tzh_timecnt (unsigned char)s types of local time starting at above +** tzh_typecnt repetitions of +** one (char [4]) coded GMT offset in seconds +** one (unsigned char) used to set tm_isdst +** one (unsigned char) that's an abbreviation list index +** tzh_charcnt (char)s '\0'-terminated zone abbreviations +** tzh_leapcnt repetitions of +** one (char [4]) coded leap second transition times +** one (char [4]) total correction after above +** tzh_ttisstdcnt (char)s indexed by type; if TRUE, transition +** time is standard time, if FALSE, +** transition time is wall clock time +** if absent, transition times are +** assumed to be wall clock time +*/ + +/* +** In the current implementation, "tzset()" refuses to deal with files that +** exceed any of the limits below. +*/ + +/* +** The TZ_MAX_TIMES value below is enough to handle a bit more than a +** year's worth of solar time (corrected daily to the nearest second) or +** 138 years of Pacific Presidential Election time +** (where there are three time zone transitions every fourth year). +*/ +#define TZ_MAX_TIMES 370 + +#define NOSOLAR /* 4BSD doesn't currently handle solar time */ + +#ifndef NOSOLAR +#define TZ_MAX_TYPES 256 /* Limited by what (unsigned char)'s can hold */ +#else +#define TZ_MAX_TYPES 10 /* Maximum number of local time types */ +#endif + +#define TZ_MAX_CHARS 50 /* Maximum number of abbreviation characters */ + +#define TZ_MAX_LEAPS 50 /* Maximum number of leap second corrections */ + +#define SECSPERMIN 60 +#define MINSPERHOUR 60 +#define HOURSPERDAY 24 +#define DAYSPERWEEK 7 +#define DAYSPERNYEAR 365 +#define DAYSPERLYEAR 366 +#define SECSPERHOUR (SECSPERMIN * MINSPERHOUR) +#define SECSPERDAY ((long) SECSPERHOUR * HOURSPERDAY) +#define MONSPERYEAR 12 + +#define TM_SUNDAY 0 +#define TM_MONDAY 1 +#define TM_TUESDAY 2 +#define TM_WEDNESDAY 3 +#define TM_THURSDAY 4 +#define TM_FRIDAY 5 +#define TM_SATURDAY 6 + +#define TM_JANUARY 0 +#define TM_FEBRUARY 1 +#define TM_MARCH 2 +#define TM_APRIL 3 +#define TM_MAY 4 +#define TM_JUNE 5 +#define TM_JULY 6 +#define TM_AUGUST 7 +#define TM_SEPTEMBER 8 +#define TM_OCTOBER 9 +#define TM_NOVEMBER 10 +#define TM_DECEMBER 11 + +#define TM_YEAR_BASE 1900 + +#define EPOCH_YEAR 1970 +#define EPOCH_WDAY TM_THURSDAY + +/* +** Accurate only for the past couple of centuries; +** that will probably do. +*/ + +#define isleap(y) (((y) % 4) == 0 && ((y) % 100) != 0 || ((y) % 400) == 0) + +#endif /* !_TZFILE_H_ */ diff --git a/src/include/unistd.h b/src/include/unistd.h new file mode 100644 index 00000000..19e11f7a --- /dev/null +++ b/src/include/unistd.h @@ -0,0 +1,188 @@ +/* $NetBSD: unistd.h,v 1.25 1995/03/19 22:51:38 mycroft Exp $ */ + +/*- + * Copyright (c) 1991 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)unistd.h 5.13 (Berkeley) 6/17/91 + */ + +#ifndef _UNISTD_H_ +#define _UNISTD_H_ + +#include <sys/cdefs.h> +#include <sys/types.h> +#include <sys/unistd.h> + +#define STDIN_FILENO 0 /* standard input file descriptor */ +#define STDOUT_FILENO 1 /* standard output file descriptor */ +#define STDERR_FILENO 2 /* standard error file descriptor */ + +#ifndef NULL +#define NULL 0 /* null pointer constant */ +#endif + +__BEGIN_DECLS +__dead void _exit __P((int)) __attribute__((noreturn)); +int access __P((const char *, int)); +unsigned alarm __P((unsigned)); +int chdir __P((const char *)); +int chown __P((const char *, uid_t, gid_t)); +int close __P((int)); +size_t confstr __P((int, char *, size_t)); +char *cuserid __P((char *)); +int dup __P((int)); +int dup2 __P((int, int)); +int execl __P((const char *, const char *, ...)); +int execle __P((const char *, const char *, ...)); +int execlp __P((const char *, const char *, ...)); +int execv __P((const char *, char * const *)); +int execve __P((const char *, char * const *, char * const *)); +int execvp __P((const char *, char * const *)); +pid_t fork __P((void)); +long fpathconf __P((int, int)); /* not yet */ +char *getcwd __P((char *, size_t)); +gid_t getegid __P((void)); +uid_t geteuid __P((void)); +gid_t getgid __P((void)); +int getgroups __P((int, gid_t *)); +char *getlogin __P((void)); +pid_t getpgrp __P((void)); +pid_t getpid __P((void)); +pid_t getppid __P((void)); +uid_t getuid __P((void)); +int isatty __P((int)); +int link __P((const char *, const char *)); +off_t lseek __P((int, off_t, int)); +long pathconf __P((const char *, int)); /* not yet */ +int pause __P((void)); +int pipe __P((int *)); +ssize_t read __P((int, void *, size_t)); +int rmdir __P((const char *)); +int setgid __P((gid_t)); +int setpgid __P((pid_t, pid_t)); +pid_t setsid __P((void)); +int setuid __P((uid_t)); +unsigned sleep __P((unsigned)); +long sysconf __P((int)); /* not yet */ +pid_t tcgetpgrp __P((int)); +int tcsetpgrp __P((int, pid_t)); +char *ttyname __P((int)); +int unlink __P((const char *)); +ssize_t write __P((int, const void *, size_t)); + +#ifndef _POSIX_SOURCE + +/* structure timeval required for select() */ +#include <sys/time.h> + +int acct __P((const char *)); +char *brk __P((const char *)); +int chroot __P((const char *)); +char *crypt __P((const char *, const char *)); +int des_cipher __P((const char *, char *, long, int)); +int des_setkey __P((const char *key)); +int encrypt __P((char *, int)); +void endusershell __P((void)); +int exect __P((const char *, char * const *, char * const *)); +int fchdir __P((int)); +int fchown __P((int, uid_t, gid_t)); +int fsync __P((int)); +int ftruncate __P((int, off_t)); +int getdomainname __P((char *, int)); +int getdtablesize __P((void)); +long gethostid __P((void)); +int gethostname __P((char *, int)); +mode_t getmode __P((const void *, mode_t)); +int getpagesize __P((void)); +char *getpass __P((const char *)); +char *getusershell __P((void)); +char *getwd __P((char *)); /* obsoleted by getcwd() */ +int initgroups __P((const char *, int)); +int iruserok __P((u_long, int, const char *, const char *)); +int mknod __P((const char *, mode_t, dev_t)); +int mkstemp __P((char *)); +char *mktemp __P((char *)); +int nfssvc __P((int, void *)); +int nice __P((int)); +void psignal __P((unsigned int, const char *)); +extern __const char *__const sys_siglist[]; +int profil __P((char *, int, int, int)); +int rcmd __P((char **, int, const char *, + const char *, const char *, int *)); +char *re_comp __P((const char *)); +int re_exec __P((const char *)); +int readlink __P((const char *, char *, int)); +int reboot __P((int)); +int revoke __P((const char *)); +int rresvport __P((int *)); +int ruserok __P((const char *, int, const char *, const char *)); +char *sbrk __P((int)); +int select __P((int, fd_set *, fd_set *, fd_set *, struct timeval *)); +int setdomainname __P((const char *, int)); +int setegid __P((gid_t)); +int seteuid __P((uid_t)); +int setgroups __P((int, const gid_t *)); +void sethostid __P((long)); +int sethostname __P((const char *, int)); +int setkey __P((const char *)); +int setlogin __P((const char *)); +void *setmode __P((const char *)); +int setpgrp __P((pid_t pid, pid_t pgrp)); /* obsoleted by setpgid() */ +int setregid __P((int, int)); +int setreuid __P((int, int)); +int setrgid __P((gid_t)); +int setruid __P((uid_t)); +void setusershell __P((void)); +int swapon __P((const char *)); +int symlink __P((const char *, const char *)); +void sync __P((void)); +int syscall __P((int, ...)); +int truncate __P((const char *, off_t)); +int ttyslot __P((void)); +u_int ualarm __P((u_int, u_int)); +int undelete __P((const char *)); +void usleep __P((u_int)); +void *valloc __P((size_t)); /* obsoleted by malloc() */ +pid_t vfork __P((void)); + +int getopt __P((int, char * const *, const char *)); +extern char *optarg; /* getopt(3) external variables */ +extern int opterr; +extern int optind; +extern int optopt; +extern int optreset; +int getsubopt __P((char **, char * const *, char **)); +extern char *suboptarg; /* getsubopt(3) external variable */ +#endif /* !_POSIX_SOURCE */ +__END_DECLS + +#endif /* !_UNISTD_H_ */ diff --git a/src/include/utime.h b/src/include/utime.h new file mode 100644 index 00000000..7085a30d --- /dev/null +++ b/src/include/utime.h @@ -0,0 +1,52 @@ +/* $NetBSD: utime.h,v 1.3 1994/10/26 00:56:39 cgd Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)utime.h 5.4 (Berkeley) 4/3/91 + */ + +#ifndef _UTIME_H_ +#define _UTIME_H_ + +struct utimbuf { + time_t actime; /* Access time */ + time_t modtime; /* Modification time */ +}; + +#include <sys/cdefs.h> + +__BEGIN_DECLS +int utime __P((const char *, const struct utimbuf *)); +__END_DECLS + +#endif /* !_UTIME_H_ */ diff --git a/src/include/utmp.h b/src/include/utmp.h new file mode 100644 index 00000000..b24c1cfa --- /dev/null +++ b/src/include/utmp.h @@ -0,0 +1,67 @@ +/* $NetBSD: utmp.h,v 1.6 1994/10/26 00:56:40 cgd Exp $ */ + +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)utmp.h 8.2 (Berkeley) 1/21/94 + */ + +#ifndef _UTMP_H_ +#define _UTMP_H_ + +#define _PATH_UTMP "/var/run/utmp" +#define _PATH_WTMP "/var/log/wtmp" +#define _PATH_LASTLOG "/var/log/lastlog" + +#define UT_NAMESIZE 8 +#define UT_LINESIZE 8 +#define UT_HOSTSIZE 16 + +struct lastlog { + time_t ll_time; + char ll_line[UT_LINESIZE]; + char ll_host[UT_HOSTSIZE]; +}; + +struct utmp { + char ut_line[UT_LINESIZE]; + char ut_name[UT_NAMESIZE]; + char ut_host[UT_HOSTSIZE]; + time_t ut_time; +}; + +#endif /* !_UTMP_H_ */ diff --git a/src/include/vis.h b/src/include/vis.h new file mode 100644 index 00000000..18343929 --- /dev/null +++ b/src/include/vis.h @@ -0,0 +1,86 @@ +/* $NetBSD: vis.h,v 1.4 1994/10/26 00:56:41 cgd Exp $ */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)vis.h 5.9 (Berkeley) 4/3/91 + */ + +#ifndef _VIS_H_ +#define _VIS_H_ + +/* + * to select alternate encoding format + */ +#define VIS_OCTAL 0x01 /* use octal \ddd format */ +#define VIS_CSTYLE 0x02 /* use \[nrft0..] where appropiate */ + +/* + * to alter set of characters encoded (default is to encode all + * non-graphic except space, tab, and newline). + */ +#define VIS_SP 0x04 /* also encode space */ +#define VIS_TAB 0x08 /* also encode tab */ +#define VIS_NL 0x10 /* also encode newline */ +#define VIS_WHITE (VIS_SP | VIS_TAB | VIS_NL) +#define VIS_SAFE 0x20 /* only encode "unsafe" characters */ + +/* + * other + */ +#define VIS_NOSLASH 0x40 /* inhibit printing '\' */ + +/* + * unvis return codes + */ +#define UNVIS_VALID 1 /* character valid */ +#define UNVIS_VALIDPUSH 2 /* character valid, push back passed char */ +#define UNVIS_NOCHAR 3 /* valid sequence, no character produced */ +#define UNVIS_SYNBAD -1 /* unrecognized escape sequence */ +#define UNVIS_ERROR -2 /* decoder in unknown state (unrecoverable) */ + +/* + * unvis flags + */ +#define UNVIS_END 1 /* no more characters */ + +#include <sys/cdefs.h> + +__BEGIN_DECLS +char *vis __P((char *, int, int, int)); +int strvis __P((char *, const char *, int)); +int strvisx __P((char *, const char *, size_t, int)); +int strunvis __P((char *, const char *)); +int unvis __P((char *, char, int *, int)); +__END_DECLS + +#endif /* !_VIS_H_ */ diff --git a/src/lib/libc/stdlib/Makefile.inc b/src/lib/libc/stdlib/Makefile.inc new file mode 100644 index 00000000..782a4ab0 --- /dev/null +++ b/src/lib/libc/stdlib/Makefile.inc @@ -0,0 +1,45 @@ +# from: @(#)Makefile.inc 5.6 (Berkeley) 6/4/91 +# $Id: Makefile.inc,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $ + +# stdlib sources +.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/stdlib ${.CURDIR}/stdlib + +SRCS+= a64l.c abort.c atexit.c atoi.c atof.c atol.c bsearch.c calloc.c \ + exit.c getenv.c getopt.c heapsort.c l64a.c malloc.c merge.c \ + multibyte.c putenv.c qsort.c radixsort.c rand.c random.c realpath.c \ + setenv.c strtod.c strtol.c strtoq.c strtoul.c strtouq.c system.c \ + _rand48.c drand48.c erand48.c jrand48.c lcong48.c lrand48.c \ + mrand48.c nrand48.c seed48.c srand48.c qabs.c qdiv.c + +.if (${MACHINE_ARCH} == "m68k") +SRCS+= abs.S div.c labs.c ldiv.c +.elif (${MACHINE_ARCH} == "i386") +SRCS+= abs.S div.S labs.S ldiv.S +.elif (${MACHINE_ARCH} == "ns32k") +SRCS+= abs.S div.c labs.c ldiv.c +.elif (${MACHINE_ARCH} == "tahoe") +SRCS+= abs.S div.c labs.c ldiv.c +.elif (${MACHINE_ARCH} == "vax") +SRCS+= abs.c div.c labs.c ldiv.c +.elif (${MACHINE_ARCH} == "alpha") +# XXX should be .S's +SRCS+= abs.c div.c labs.c ldiv.c +.else +SRCS+= abs.c div.c labs.c ldiv.c +.endif + +MAN+= abort.3 abs.3 alloca.3 atexit.3 atof.3 atoi.3 atol.3 bsearch.3 \ + calloc.3 div.3 exit.3 free.3 getenv.3 getopt.3 labs.3 ldiv.3 \ + malloc.3 memory.3 qabs.3 qdiv.3 qsort.3 radixsort.3 rand48.3 \ + rand.3 random.3 realloc.3 realpath.3 strtod.3 strtol.3 strtoul.3 \ + system.3 + +MLINKS+=getenv.3 setenv.3 getenv.3 unsetenv.3 getenv.3 putenv.3 +MLINKS+=qsort.3 heapsort.3 qsort.3 mergesort.3 +MLINKS+=rand.3 srand.3 +MLINKS+=strtol.3 strtoq.3 +MLINKS+=strtoul.3 strtouq.3 +MLINKS+=random.3 initstate.3 random.3 setstate.3 random.3 srandom.3 +MLINKS+=rand48.3 drand48.3 rand48.3 erand48.3 rand48.3 lrand48.3 +MLINKS+=rand48.3 mrand48.3 rand48.3 nrand48.3 rand48.3 jrand48.3 +MLINKS+=rand48.3 srand48.3 rand48.3 seed48.3 rand48.3 lcong48.3 diff --git a/src/lib/libc/stdlib/_rand48.c b/src/lib/libc/stdlib/_rand48.c new file mode 100644 index 00000000..83ade464 --- /dev/null +++ b/src/lib/libc/stdlib/_rand48.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +unsigned short __rand48_seed[3] = { + RAND48_SEED_0, + RAND48_SEED_1, + RAND48_SEED_2 +}; +unsigned short __rand48_mult[3] = { + RAND48_MULT_0, + RAND48_MULT_1, + RAND48_MULT_2 +}; +unsigned short __rand48_add = RAND48_ADD; + +void +__dorand48(unsigned short xseed[3]) +{ + unsigned long accu; + unsigned short temp[2]; + + accu = (unsigned long) __rand48_mult[0] * (unsigned long) xseed[0] + + (unsigned long) __rand48_add; + temp[0] = (unsigned short) accu; /* lower 16 bits */ + accu >>= sizeof(unsigned short) * 8; + accu += (unsigned long) __rand48_mult[0] * (unsigned long) xseed[1] + + (unsigned long) __rand48_mult[1] * (unsigned long) xseed[0]; + temp[1] = (unsigned short) accu; /* middle 16 bits */ + accu >>= sizeof(unsigned short) * 8; + accu += __rand48_mult[0] * xseed[2] + __rand48_mult[1] * xseed[1] + __rand48_mult[2] * xseed[0]; + xseed[0] = temp[0]; + xseed[1] = temp[1]; + xseed[2] = (unsigned short) accu; +} diff --git a/src/lib/libc/stdlib/a64l.c b/src/lib/libc/stdlib/a64l.c new file mode 100644 index 00000000..03fc77e0 --- /dev/null +++ b/src/lib/libc/stdlib/a64l.c @@ -0,0 +1,34 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$NetBSD: a64l.c,v 1.3 1995/05/11 23:04:47 jtc Exp $"; +#endif + +long +a64l(s) + const char *s; +{ + long value, digit, shift; + int i; + + value = 0; + shift = 0; + for (i = 0; *s && i < 6; i++, s++) { + if (*s <= '/') + digit = *s - '.'; + else if (*s <= '9') + digit = *s - '0' + 2; + else if (*s <= 'Z') + digit = *s - 'A' + 12; + else + digit = *s - 'a' + 38; + + value |= digit << shift; + shift += 6; + } + + return (long) value; +} diff --git a/src/lib/libc/stdlib/abort.3 b/src/lib/libc/stdlib/abort.3 new file mode 100644 index 00000000..ab573275 --- /dev/null +++ b/src/lib/libc/stdlib/abort.3 @@ -0,0 +1,71 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)abort.3 6.7 (Berkeley) 6/29/91 +.\" $Id: abort.3,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt ABORT 3 +.Os +.Sh NAME +.Nm abort +.Nd cause abnormal program termination +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft void +.Fn abort void +.Sh DESCRIPTION +The +.Fn abort +function causes abnormal program termination to occur, unless the +signal +.Dv SIGABRT +is being caught and the signal handler does not return. +.Pp +No open streams are closed or flushed. +.Sh RETURN VALUES +The +.Nm abort +function +never returns. +.Sh SEE ALSO +.Xr sigaction 2 , +.Xr exit 2 +.Sh STANDARDS +The +.Fn abort +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/abort.c b/src/lib/libc/stdlib/abort.c new file mode 100644 index 00000000..c298e016 --- /dev/null +++ b/src/lib/libc/stdlib/abort.c @@ -0,0 +1,65 @@ +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)abort.c 5.11 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: abort.c,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <signal.h> +#include <stdlib.h> +#include <unistd.h> + +void +abort() +{ + sigset_t mask; + + sigfillset(&mask); + /* + * don't block SIGABRT to give any handler a chance; we ignore + * any errors -- X311J doesn't allow abort to return anyway. + */ + sigdelset(&mask, SIGABRT); + (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); + (void)kill(getpid(), SIGABRT); + + /* + * if SIGABRT ignored, or caught and the handler returns, do + * it again, only harder. + */ + (void)signal(SIGABRT, SIG_DFL); + (void)sigprocmask(SIG_SETMASK, &mask, (sigset_t *)NULL); + (void)kill(getpid(), SIGABRT); + exit(1); +} diff --git a/src/lib/libc/stdlib/abs.3 b/src/lib/libc/stdlib/abs.3 new file mode 100644 index 00000000..4748d89e --- /dev/null +++ b/src/lib/libc/stdlib/abs.3 @@ -0,0 +1,74 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)abs.3 6.4 (Berkeley) 6/29/91 +.\" $Id: abs.3,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt ABS 3 +.Os +.Sh NAME +.Nm abs +.Nd integer absolute value function +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft int +.Fn abs "int j" +.Sh DESCRIPTION +The +.Fn abs +function +computes +the absolute value of the integer +.Ar j . +.Sh RETURN VALUES +The +.Fn abs +function +returns +the absolute value. +.Sh SEE ALSO +.Xr floor 3 , +.Xr labs 3 , +.Xr cabs 3 , +.Xr hypot 3 , +.Xr math 3 +.Sh STANDARDS +The +.Fn abs +function conforms to +.St -ansiC . +.Sh BUGS +The absolute value of the most negative integer remains negative. diff --git a/src/lib/libc/stdlib/abs.c b/src/lib/libc/stdlib/abs.c new file mode 100644 index 00000000..64468e02 --- /dev/null +++ b/src/lib/libc/stdlib/abs.c @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)abs.c 5.2 (Berkeley) 5/17/90";*/ +static char *rcsid = "$Id: abs.c,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> + +int +abs(j) + int j; +{ + return(j < 0 ? -j : j); +} diff --git a/src/lib/libc/stdlib/alloca.3 b/src/lib/libc/stdlib/alloca.3 new file mode 100644 index 00000000..dcb97ab1 --- /dev/null +++ b/src/lib/libc/stdlib/alloca.3 @@ -0,0 +1,79 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)alloca.3 5.1 (Berkeley) 5/2/91 +.\" $Id: alloca.3,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $ +.\" +.Dd May 2, 1991 +.Dt ALLOCA 3 +.Os BSD 4 +.Sh NAME +.Nm alloca +.Nd memory allocator +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft void * +.Fn alloca "size_t size" +.Sh DESCRIPTION +The +.Fn alloca +function +allocates +.Fa size +bytes of space in the stack frame of the caller. +This temporary space is automatically freed on +return. +.Sh RETURN VALUES +The +.Fn alloca +function returns a pointer to the beginning of the allocated space. +If the allocation failed, a +.Dv NULL +pointer is returned. +.Sh SEE ALSO +.Xr brk 2 , +.Xr pagesize 2 +.Xr calloc 3 , +.Xr malloc 3 , +.Xr realloc 3 , +.Sh BUGS +The +.Fn alloca +function +is machine dependent; its use is discouraged. +.\" .Sh HISTORY +.\" The +.\" .Fn alloca +.\" function appeared in +.\" .Bx ?? . +.\" The function appeared in 32v, pwb and pwb.2 and in 3bsd 4bsd +.\" The first man page (or link to a man page that I can find at the +.\" moment is 4.3... diff --git a/src/lib/libc/stdlib/atexit.3 b/src/lib/libc/stdlib/atexit.3 new file mode 100644 index 00000000..07de054d --- /dev/null +++ b/src/lib/libc/stdlib/atexit.3 @@ -0,0 +1,78 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)atexit.3 5.3 (Berkeley) 6/29/91 +.\" $Id: atexit.3,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt ATEXIT 3 +.Os +.Sh NAME +.Nm atexit +.Nd register a function to be called on exit +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft int +.Fn atexit "void (*function)(void)" +.Sh DESCRIPTION +The +.Fn atexit +function +registers the given +.Ar function +to be called at program exit, whether via +.Xr exit 3 +or via return from the program's +.Em main . +Functions so registered are called in reverse order; +no arguments are passed. +At least 32 functions can always be registered, +and more are allowed as long as sufficient memory can be allocated. +.Sh RETURN VALUES +.Rv -std atexit +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er ENOMEM +No memory was available to add the function to the list. +The existing list of functions is unmodified. +.El +.Sh SEE ALSO +.Xr exit 3 +.Sh STANDARDS +The +.Fn atexit +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/atexit.c b/src/lib/libc/stdlib/atexit.c new file mode 100644 index 00000000..4da1eb0d --- /dev/null +++ b/src/lib/libc/stdlib/atexit.c @@ -0,0 +1,68 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)atexit.c 5.2 (Berkeley) 11/14/90";*/ +static char *rcsid = "$Id: atexit.c,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> +#include "atexit.h" + +struct atexit *__atexit; + +/* + * Register a function to be performed at exit. + */ +int +atexit(fn) + void (*fn)(); +{ + static struct atexit __atexit0; /* one guaranteed table */ + register struct atexit *p; + + if ((p = __atexit) == NULL) + __atexit = p = &__atexit0; + else if (p->ind >= ATEXIT_SIZE) { + if ((p = malloc(sizeof(*p))) == NULL) + return (-1); + p->ind = 0; + p->next = __atexit; + __atexit = p; + } + p->fns[p->ind++] = fn; + return (0); +} diff --git a/src/lib/libc/stdlib/atexit.h b/src/lib/libc/stdlib/atexit.h new file mode 100644 index 00000000..8b756e8f --- /dev/null +++ b/src/lib/libc/stdlib/atexit.h @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * from: @(#)atexit.h 5.1 (Berkeley) 5/15/90 + * $Id: atexit.h,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $ + */ + +/* must be at least 32 to guarantee ANSI conformance */ +#define ATEXIT_SIZE 32 + +struct atexit { + struct atexit *next; /* next in list */ + int ind; /* next index in this table */ + void (*fns[ATEXIT_SIZE])(); /* the table itself */ +}; + +extern struct atexit *__atexit; /* points to head of LIFO stack */ diff --git a/src/lib/libc/stdlib/atof.3 b/src/lib/libc/stdlib/atof.3 new file mode 100644 index 00000000..53e04f71 --- /dev/null +++ b/src/lib/libc/stdlib/atof.3 @@ -0,0 +1,74 @@ +.\" Copyright (c) 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)atof.3 6.4 (Berkeley) 6/29/91 +.\" $Id: atof.3,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt ATOF 3 +.Os +.Sh NAME +.Nm atof +.Nd convert +.Tn ASCII +string to double +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft double +.Fn atof "const char *nptr" +.Sh DESCRIPTION +The +.Fn atof +function converts the initial portion of the string pointed to by +.Ar nptr +to +.Ar double +representation. +.Pp +It is equivalent to: +.Bd -literal -offset indent +strtod(nptr, (char **)NULL); +.Ed +.Sh SEE ALSO +.Xr atoi 3 , +.Xr atol 3 , +.Xr strtod 3 , +.Xr strtol 3 , +.Xr strtoul 3 +.Sh STANDARDS +The +.Fn atof +function conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/atof.c b/src/lib/libc/stdlib/atof.c new file mode 100644 index 00000000..9202de50 --- /dev/null +++ b/src/lib/libc/stdlib/atof.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1988 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)atof.c 5.3 (Berkeley) 1/8/93";*/ +static char *rcsid = "$Id: atof.c,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> + +double +atof(ascii) + const char *ascii; +{ + return(strtod(ascii, (char **)NULL)); +} diff --git a/src/lib/libc/stdlib/atoi.3 b/src/lib/libc/stdlib/atoi.3 new file mode 100644 index 00000000..219ba73c --- /dev/null +++ b/src/lib/libc/stdlib/atoi.3 @@ -0,0 +1,75 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)atoi.3 5.3 (Berkeley) 6/29/91 +.\" $Id: atoi.3,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt ATOI 3 +.Os +.Sh NAME +.Nm atoi +.Nd convert +.Tn ASCII +string to integer +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft int +.Fn atoi "const char *nptr" +.Sh DESCRIPTION +The +.Fn atoi +function converts the initial portion of the string pointed to by +.Em nptr +to +.Em integer +representation. +.Pp +It is equivalent to: +.Pp +.Bd -literal -offset indent +(int)strtol(nptr, (char **)NULL, 10); +.Ed +.Sh SEE ALSO +.Xr atof 3 , +.Xr atol 3 , +.Xr strtod 3 , +.Xr strtol 3 , +.Xr strtoul 3 +.Sh STANDARDS +The +.Fn atoi +function conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/atoi.c b/src/lib/libc/stdlib/atoi.c new file mode 100644 index 00000000..df7845f9 --- /dev/null +++ b/src/lib/libc/stdlib/atoi.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)atoi.c 5.7 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: atoi.c,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> + +int +atoi(str) + const char *str; +{ + return((int)strtol(str, (char **)NULL, 10)); +} diff --git a/src/lib/libc/stdlib/atol.3 b/src/lib/libc/stdlib/atol.3 new file mode 100644 index 00000000..86e3d324 --- /dev/null +++ b/src/lib/libc/stdlib/atol.3 @@ -0,0 +1,75 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)atol.3 5.3 (Berkeley) 6/29/91 +.\" $Id: atol.3,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt ATOL 3 +.Os +.Sh NAME +.Nm atol +.Nd convert +.Tn ASCII +string to long integer +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft long +.Fn atol "const char *nptr" +.Sh DESCRIPTION +The +.Fn atol +function converts the initial portion of the string pointed to by +.Ar nptr +to +.Em long integer +representation. +.Pp +It is equivalent to: +.Bd -literal -offset indent +strtol(nptr, (char **)NULL, 10); +.Ed +.Sh SEE ALSO +.Xr atof 3 , +.Xr atoi 3 , +.Xr strtod 3 , +.Xr strtol 3 , +.Xr strtoul 3 +.Sh STANDARDS +The +.Fn atol +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/atol.c b/src/lib/libc/stdlib/atol.c new file mode 100644 index 00000000..31ed0629 --- /dev/null +++ b/src/lib/libc/stdlib/atol.c @@ -0,0 +1,46 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)atol.c 5.7 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: atol.c,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> + +long +atol(str) + const char *str; +{ + return(strtol(str, (char **)NULL, 10)); +} diff --git a/src/lib/libc/stdlib/bsearch.3 b/src/lib/libc/stdlib/bsearch.3 new file mode 100644 index 00000000..1622c96c --- /dev/null +++ b/src/lib/libc/stdlib/bsearch.3 @@ -0,0 +1,91 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)bsearch.3 5.6 (Berkeley) 6/29/91 +.\" $Id: bsearch.3,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt BSEARCH 3 +.Os +.Sh NAME +.Nm bsearch +.Nd binary search of a sorted table +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft void * +.Fn bsearch "const void *key" "const void *base" "size_t nmemb" "size_t size" "int (*compar) (const void *, const void *)" +.Sh DESCRIPTION +The +.Fn bsearch +function searches an array of +.Fa nmemb +objects, the initial member of which is +pointed to by +.Fa base , +for a member that matches the object pointed to by +.Fa key . +The size of each member of the array is specified by +.Fa size . +.Pp +The contents of the array should be in ascending sorted order according +to the comparison function referenced by +.Fa compar . +The +.Fa compar +routine +is expected to have two +two arguments which point to the +.Fa key +object and to an array member, in that order, and should return an integer +less than, equal to, or greater than zero if the +.Fa key +object is found, respectively, to be less than, to match, or be +greater than the array member. +.Sh RETURN VALUES +The +.Fn bsearch +function returns a pointer to a matching member of the array, or a null +pointer if no match is found. +If two members compare as equal, which member is matched is unspecified. +.Sh SEE ALSO +.Xr db 3 , +.Xr lsearch 3 , +.Xr qsort 3 , +.\" .Xr tsearch 3 +.Sh STANDARDS +The +.Fn bsearch +function conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/bsearch.c b/src/lib/libc/stdlib/bsearch.c new file mode 100644 index 00000000..fac03f69 --- /dev/null +++ b/src/lib/libc/stdlib/bsearch.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)bsearch.c 5.4 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: bsearch.c,v 1.1.1.1 1995/10/18 08:42:16 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> + +/* + * Perform a binary search. + * + * The code below is a bit sneaky. After a comparison fails, we + * divide the work in half by moving either left or right. If lim + * is odd, moving left simply involves halving lim: e.g., when lim + * is 5 we look at item 2, so we change lim to 2 so that we will + * look at items 0 & 1. If lim is even, the same applies. If lim + * is odd, moving right again involes halving lim, this time moving + * the base up one item past p: e.g., when lim is 5 we change base + * to item 3 and make lim 2 so that we will look at items 3 and 4. + * If lim is even, however, we have to shrink it by one before + * halving: e.g., when lim is 4, we still looked at item 2, so we + * have to make lim 3, then halve, obtaining 1, so that we will only + * look at item 3. + */ +void * +bsearch(key, base0, nmemb, size, compar) + register const void *key; + const void *base0; + size_t nmemb; + register size_t size; + register int (*compar) __P((const void *, const void *)); +{ + register const char *base = base0; + register int lim, cmp; + register const void *p; + + for (lim = nmemb; lim != 0; lim >>= 1) { + p = base + (lim >> 1) * size; + cmp = (*compar)(key, p); + if (cmp == 0) + return ((void *)p); + if (cmp > 0) { /* key > p: move right */ + base = (char *)p + size; + lim--; + } /* else move left */ + } + return (NULL); +} diff --git a/src/lib/libc/stdlib/calloc.3 b/src/lib/libc/stdlib/calloc.3 new file mode 100644 index 00000000..d0754b46 --- /dev/null +++ b/src/lib/libc/stdlib/calloc.3 @@ -0,0 +1,71 @@ +.\" Copyright (c) 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)calloc.3 5.2 (Berkeley) 6/29/91 +.\" $Id: calloc.3,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt CALLOC 3 +.Os +.Sh NAME +.Nm calloc +.Nd allocate clean memory (zero initialized space) +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft void * +.Fn calloc "size_t nmemb" "size_t size" +.Sh DESCRIPTION +The +.Fn calloc +function allocates space for an array of +.Fa nmemb +objects, each of whose size is +.Fa size . +The space is initialized to all bits zero. +.Sh RETURN VALUES +The +.Fn calloc +function returns +a pointer to the +the allocated space if successful; otherwise a null pointer is returned. +.Sh SEE ALSO +.Xr malloc 3 , +.Xr realloc 3 , +.Xr free 3 +.Sh STANDARDS +The +.Fn calloc +function conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/calloc.c b/src/lib/libc/stdlib/calloc.c new file mode 100644 index 00000000..3353fab0 --- /dev/null +++ b/src/lib/libc/stdlib/calloc.c @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)calloc.c 5.6 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: calloc.c,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> +#include <string.h> + +void * +calloc(num, size) + size_t num; + register size_t size; +{ + register void *p; + + size *= num; + if (p = malloc(size)) + memset(p, '\0', size); + return(p); +} diff --git a/src/lib/libc/stdlib/div.3 b/src/lib/libc/stdlib/div.3 new file mode 100644 index 00000000..a4730694 --- /dev/null +++ b/src/lib/libc/stdlib/div.3 @@ -0,0 +1,70 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)div.3 5.2 (Berkeley) 4/19/91 +.\" $Id: div.3,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt DIV 3 +.Os +.Sh NAME +.Nm div +.Nd return quotient and remainder from division +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft div_t +.Fn div "int num" "int denom" +.Sh DESCRIPTION +The +.Fn div +function +computes the value +.Fa num/denom +and returns the quotient and remainder in a structure named +.Fa div_t +that contains two +.Em int +members named +.Fa quot +and +.Fa rem . +.Sh SEE ALSO +.Xr ldiv 3 , +.Xr qdiv 3 , +.Xr math 3 +.Sh STANDARDS +The +.Fn div +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/div.c b/src/lib/libc/stdlib/div.c new file mode 100644 index 00000000..122ac0de --- /dev/null +++ b/src/lib/libc/stdlib/div.c @@ -0,0 +1,80 @@ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)div.c 5.2 (Berkeley) 4/16/91";*/ +static char *rcsid = "$Id: div.c,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> /* div_t */ + +div_t +div(num, denom) + int num, denom; +{ + div_t r; + + r.quot = num / denom; + r.rem = num % denom; + /* + * The ANSI standard says that |r.quot| <= |n/d|, where + * n/d is to be computed in infinite precision. In other + * words, we should always truncate the quotient towards + * 0, never -infinity. + * + * Machine division and remainer may work either way when + * one or both of n or d is negative. If only one is + * negative and r.quot has been truncated towards -inf, + * r.rem will have the same sign as denom and the opposite + * sign of num; if both are negative and r.quot has been + * truncated towards -inf, r.rem will be positive (will + * have the opposite sign of num). These are considered + * `wrong'. + * + * If both are num and denom are positive, r will always + * be positive. + * + * This all boils down to: + * if num >= 0, but r.rem < 0, we got the wrong answer. + * In that case, to get the right answer, add 1 to r.quot and + * subtract denom from r.rem. + */ + if (num >= 0 && r.rem < 0) { + r.quot++; + r.rem -= denom; + } + return (r); +} diff --git a/src/lib/libc/stdlib/drand48.c b/src/lib/libc/stdlib/drand48.c new file mode 100644 index 00000000..ae1a8634 --- /dev/null +++ b/src/lib/libc/stdlib/drand48.c @@ -0,0 +1,22 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +extern unsigned short __rand48_seed[3]; + +double +drand48(void) +{ + return erand48(__rand48_seed); +} diff --git a/src/lib/libc/stdlib/erand48.c b/src/lib/libc/stdlib/erand48.c new file mode 100644 index 00000000..cc9fbf77 --- /dev/null +++ b/src/lib/libc/stdlib/erand48.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +double +erand48(unsigned short xseed[3]) +{ + __dorand48(xseed); + return ldexp((double) xseed[0], -48) + + ldexp((double) xseed[1], -32) + + ldexp((double) xseed[2], -16); +} diff --git a/src/lib/libc/stdlib/exit.3 b/src/lib/libc/stdlib/exit.3 new file mode 100644 index 00000000..adb81ffc --- /dev/null +++ b/src/lib/libc/stdlib/exit.3 @@ -0,0 +1,84 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)exit.3 6.6 (Berkeley) 6/29/91 +.\" $Id: exit.3,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt EXIT 3 +.Os +.Sh NAME +.Nm exit +.Nd perform normal program termination +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft void +.Fn exit "int status" +.Sh DESCRIPTION +.Fn Exit +terminates a process. +.Pp +Before termination it performs the following functions in the +order listed: +.Bl -enum -offset indent +.It +Call the functions registered with the +.Xr atexit 3 +function, in the reverse order of their registration. +.It +Flush all open output streams. +.It +Close all open streams. +.It +Unlink all files created with the +.Xr tmpfile 3 +function. +.El +.Sh RETURN VALUES +The +.Fn exit +function +never returns. +.Sh SEE ALSO +.Xr _exit 2 , +.Xr atexit 3 , +.Xr intro 3 , +.Xr tmpfile 3 +.Sh STANDARDS +The +.Fn exit +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/exit.c b/src/lib/libc/stdlib/exit.c new file mode 100644 index 00000000..b1412f42 --- /dev/null +++ b/src/lib/libc/stdlib/exit.c @@ -0,0 +1,61 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)exit.c 5.4 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: exit.c,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> +#include <unistd.h> +#include "atexit.h" + +void (*__cleanup)(); + +/* + * Exit, flushing stdio buffers if necessary. + */ +void +exit(status) + int status; +{ + register struct atexit *p; + register int n; + + for (p = __atexit; p; p = p->next) + for (n = p->ind; --n >= 0;) + (*p->fns[n])(); + if (__cleanup) + (*__cleanup)(); + _exit(status); +} diff --git a/src/lib/libc/stdlib/free.3 b/src/lib/libc/stdlib/free.3 new file mode 100644 index 00000000..3d0131d7 --- /dev/null +++ b/src/lib/libc/stdlib/free.3 @@ -0,0 +1,82 @@ +.\" Copyright (c) 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)free.3 5.2 (Berkeley) 6/29/91 +.\" $Id: free.3,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt FREE 3 +.Os +.Sh NAME +.Nm free +.Nd free up memory allocated with malloc, calloc or realloc +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft void +.Fn free "void *ptr" +.Sh DESCRIPTION +The +.Fn free +function causes the space pointed to by +.Fa ptr +to be deallocated, that is, made available +for further allocation. +If +.Fa ptr +is a null pointer, no action occurs. +Otherwise, if the argument does not match a pointer earlier +returned by the +.Xr calloc , +.Xr malloc , +or +.Xr realloc +function, or if the space has been deallocated by a call to +.Fn free +or +.Xr realloc , +general havoc may occur. +.Sh RETURN VALUES +The +.Fn free +function returns no value. +.Sh SEE ALSO +.Xr calloc 3 , +.Xr malloc 3 , +.Xr realloc 3 +.Sh STANDARDS +The +.Fn free +function conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/getenv.3 b/src/lib/libc/stdlib/getenv.3 new file mode 100644 index 00000000..411eb35d --- /dev/null +++ b/src/lib/libc/stdlib/getenv.3 @@ -0,0 +1,152 @@ +.\" Copyright (c) 1988, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)getenv.3 6.11 (Berkeley) 6/29/91 +.\" $Id: getenv.3,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt GETENV 3 +.Os +.Sh NAME +.Nm getenv , +.Nm putenv , +.Nm setenv , +.Nm unsetenv +.Nd environment variable functions +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft char * +.Fn getenv "const char *name" +.Ft int +.Fn setenv "const char *name" "const char *value" "int overwrite" +.Ft int +.Fn putenv "const char *string" +.Ft void +.Fn unsetenv "const char *name" +.Sh DESCRIPTION +These functions set, unset and fetch environment variables from the +host +.Em environment list . +For compatibility with differing environment conventions, +the given arguments +.Ar name +and +.Ar value +may be appended and prepended, +respectively, +with an equal sign +.Dq Li \&= . +.Pp +The +.Fn getenv +function obtains the current value of the environment variable, +.Ar name . +If the variable +.Ar name +is not in the current environment , +a null pointer is returned. +.Pp +The +.Fn setenv +function inserts or resets the environment variable +.Ar name +in the current environment list. +If the variable +.Ar name +does not exist in the list, +it is inserted with the given +.Ar value. +If the variable does exist, the argument +.Ar overwrite +is tested; if +.Ar overwrite is +zero, the +variable is not reset, otherwise it is reset +to the given +.Ar value . +.Pp +The +.Fn putenv +function takes an argument of the form ``name=value'' and is +equivalent to: +.Bd -literal -offset indent +setenv(name, value, 1); +.Ed +.Pp +The +.Fn unsetenv +function +deletes all instances of the variable name pointed to by +.Fa name +from the list. +.Sh RETURN VALUES +The functions +.Fn setenv +and +.Fn putenv +return zero if successful; otherwise the global variable +.Va errno +is set to indicate the error and a +\-1 is returned. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er ENOMEM +The function +.Fn setenv +or +.Fn putenv +failed because they were unable to allocate memory for the environment. +.El +.Sh SEE ALSO +.Xr csh 1 , +.Xr sh 1 , +.Xr execve 2 , +.Xr environ 7 +.Sh STANDARDS +The +.Fn getenv +function conforms to +.St -ansiC . +.Sh HISTORY +The functions +.Fn setenv +and +.Fn unsetenv +appeared in +.At v7 . +The +.Fn putenv +function appeared in +.Bx 4.3 Reno . diff --git a/src/lib/libc/stdlib/getenv.c b/src/lib/libc/stdlib/getenv.c new file mode 100644 index 00000000..09d47f21 --- /dev/null +++ b/src/lib/libc/stdlib/getenv.c @@ -0,0 +1,82 @@ +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)getenv.c 5.8 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: getenv.c,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> +#include <string.h> + +/* + * getenv -- + * Returns ptr to value associated with name, if any, else NULL. + */ +char * +getenv(name) + const char *name; +{ + int offset; + char *__findenv(); + + return(__findenv(name, &offset)); +} + +/* + * __findenv -- + * Returns pointer to value associated with name, if any, else NULL. + * Sets offset to be the offset of the name/value combination in the + * environmental array, for use by setenv(3) and unsetenv(3). + * Explicitly removes '=' in argument name. + * + * This routine *should* be a static; don't use it. + */ +char * +__findenv(name, offset) + register char *name; + int *offset; +{ + extern char **environ; + register int len; + register char **P, *C; + + for (C = name, len = 0; *C && *C != '='; ++C, ++len); + for (P = environ; *P; ++P) + if (!strncmp(*P, name, len)) + if (*(C = *P + len) == '=') { + *offset = P - environ; + return(++C); + } + return(NULL); +} diff --git a/src/lib/libc/stdlib/getopt.3 b/src/lib/libc/stdlib/getopt.3 new file mode 100644 index 00000000..f843881a --- /dev/null +++ b/src/lib/libc/stdlib/getopt.3 @@ -0,0 +1,260 @@ +.\" Copyright (c) 1988, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" @(#)getopt.3 8.4 (Berkeley) 4/19/94 +.\" +.Dd April 19, 1994 +.Dt GETOPT 3 +.Os BSD 4.3 +.Sh NAME +.Nm getopt +.Nd get option character from command line argument list +.Sh SYNOPSIS +.Fd #include <unistd.h> +.Vt extern char *optarg; +.Vt extern int optind; +.Vt extern int optopt; +.Vt extern int opterr; +.Vt extern int optreset; +.Ft int +.Fn getopt "int argc" "char * const *argv" "const char *optstring" +.Sh DESCRIPTION +The +.Fn getopt +function incrementally parses a command line argument list +.Fa argv +and returns the next +.Em known +option character. +An option character is +.Em known +if it has been specified in the string of accepted option characters, +.Fa optstring . +.Pp +The option string +.Fa optstring +may contain the following elements: individual characters, and +characters followed by a colon to indicate an option argument +is to follow. +For example, an option string +.Li "\&""x"" +recognizes an option +.Dq Fl x , +and an option string +.Li "\&""x:"" +recognizes an option and argument +.Dq Fl x Ar argument . +It does not matter to +.Fn getopt +if a following argument has leading white space. +.Pp +On return from +.Fn getopt , +.Va optarg +points to an option argument, if it is anticipated, +and the variable +.Va optind +contains the index to the next +.Fa argv +argument for a subsequent call +to +.Fn getopt . +The variable +.Va optopt +saves the last +.Em known +option character returned by +.Fn getopt . +.Pp +The variable +.Va opterr +and +.Va optind +are both initialized to 1. +The +.Va optind +variable may be set to another value before a set of calls to +.Fn getopt +in order to skip over more or less argv entries. +.Pp +In order to use +.Fn getopt +to evaluate multiple sets of arguments, or to evaluate a single set of +arguments multiple times, +the variable +.Va optreset +must be set to 1 before the second and each additional set of calls to +.Fn getopt , +and the variable +.Va optind +must be reinitialized. +.Pp +The +.Fn getopt +function +returns \-1 +when the argument list is exhausted, or a non-recognized +option is encountered. +The interpretation of options in the argument list may be cancelled +by the option +.Ql -- +(double dash) which causes +.Fn getopt +to signal the end of argument processing and returns \-1. +When all options have been processed (i.e., up to the first non-option +argument), +.Fn getopt +returns \-1. +.Sh DIAGNOSTICS +If the +.Fn getopt +function encounters a character not found in the string +.Va optarg +or detects +a missing option argument it writes an error message and returns +.Ql ? +to the +.Em stderr . +Setting +.Va opterr +to a zero will disable these error messages. +If +.Va optstring +has a leading +.Ql \&: +then a missing option argument causes a +.Ql \&: +to be returned in addition to suppressing any error messages. +.Pp +Option arguments are allowed to begin with +.Dq Li \- ; +this is reasonable but +reduces the amount of error checking possible. +.Sh EXTENSIONS +The +.Va optreset +variable was added to make it possible to call the +.Fn getopt +function multiple times. +This is an extension to the +.St -p1003.2 +specification. +.Sh EXAMPLE +.Bd -literal -compact +extern char *optarg; +extern int optind; +int bflag, ch, fd; + +bflag = 0; +while ((ch = getopt(argc, argv, "bf:")) != -1) + switch(ch) { + case 'b': + bflag = 1; + break; + case 'f': + if ((fd = open(optarg, O_RDONLY, 0)) < 0) { + (void)fprintf(stderr, + "myname: %s: %s\en", optarg, strerror(errno)); + exit(1); + } + break; + case '?': + default: + usage(); +} +argc -= optind; +argv += optind; +.Ed +.Sh HISTORY +The +.Fn getopt +function appeared +.Bx 4.3 . +.Sh BUGS +The +.Fn getopt +function was once specified to return +.Dv EOF +instead of \-1. +This was changed by +.St -p1003.2-92 +to decouple +.Fn getopt +from +.Pa <stdio.h> . +.Pp +A single dash +.Dq Li - +may be specified as an character in +.Fa optstring , +however it should +.Em never +have an argument associated with it. +This allows +.Fn getopt +to be used with programs that expect +.Dq Li - +as an option flag. +This practice is wrong, and should not be used in any current development. +It is provided for backward compatibility +.Em only . +By default, a single dash causes +.Fn getopt +to return \-1. +This is, we believe, compatible with System V. +.Pp +It is also possible to handle digits as option letters. +This allows +.Fn getopt +to be used with programs that expect a number +.Pq Dq Li \&-\&3 +as an option. +This practice is wrong, and should not be used in any current development. +It is provided for backward compatibility +.Em only . +The following code fragment works in most cases. +.Bd -literal -offset indent +int length; +char *p; + +while ((c = getopt(argc, argv, "0123456789")) != -1) + switch (c) { + case '0': case '1': case '2': case '3': case '4': + case '5': case '6': case '7': case '8': case '9': + p = argv[optind - 1]; + if (p[0] == '-' && p[1] == ch && !p[2]) + length = atoi(++p); + else + length = atoi(argv[optind] + 1); + break; + } +} +.Ed diff --git a/src/lib/libc/stdlib/getopt.c b/src/lib/libc/stdlib/getopt.c new file mode 100644 index 00000000..63c5e6a4 --- /dev/null +++ b/src/lib/libc/stdlib/getopt.c @@ -0,0 +1,118 @@ +/* + * Copyright (c) 1987, 1993, 1994 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/* static char sccsid[] = "from: @(#)getopt.c 8.2 (Berkeley) 4/2/94"; */ +static char *rcsid = "$Id: getopt.c,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +int opterr = 1, /* if error message should be printed */ + optind = 1, /* index into parent argv vector */ + optopt, /* character checked for validity */ + optreset; /* reset getopt */ +char *optarg; /* argument associated with option */ + +#define BADCH (int)'?' +#define BADARG (int)':' +#define EMSG "" + +/* + * getopt -- + * Parse argc/argv argument vector. + */ +int +getopt(nargc, nargv, ostr) + int nargc; + char * const *nargv; + const char *ostr; +{ + extern char *__progname; + static char *place = EMSG; /* option letter processing */ + char *oli; /* option letter list index */ + + if (optreset || !*place) { /* update scanning pointer */ + optreset = 0; + if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = EMSG; + return (-1); + } + if (place[1] && *++place == '-') { /* found "--" */ + ++optind; + place = EMSG; + return (-1); + } + } /* option letter okay? */ + if ((optopt = (int)*place++) == (int)':' || + !(oli = strchr(ostr, optopt))) { + /* + * if the user didn't specify '-' as an option, + * assume it means -1. + */ + if (optopt == (int)'-') + return (-1); + if (!*place) + ++optind; + if (opterr && *ostr != ':') + (void)fprintf(stderr, + "%s: illegal option -- %c\n", __progname, optopt); + return (BADCH); + } + if (*++oli != ':') { /* don't need argument */ + optarg = NULL; + if (!*place) + ++optind; + } + else { /* need an argument */ + if (*place) /* no white space */ + optarg = place; + else if (nargc <= ++optind) { /* no arg */ + place = EMSG; + if (*ostr == ':') + return (BADARG); + if (opterr) + (void)fprintf(stderr, + "%s: option requires an argument -- %c\n", + __progname, optopt); + return (BADCH); + } + else /* white space */ + optarg = nargv[optind]; + place = EMSG; + ++optind; + } + return (optopt); /* dump back option letter */ +} diff --git a/src/lib/libc/stdlib/heapsort.c b/src/lib/libc/stdlib/heapsort.c new file mode 100644 index 00000000..bd998fa3 --- /dev/null +++ b/src/lib/libc/stdlib/heapsort.c @@ -0,0 +1,184 @@ +/*- + * Copyright (c) 1991, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Ronnie Kon at Mindcraft Inc., Kevin Lew and Elmer Yglesias. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char sccsid[] = "from: @(#)heapsort.c 8.1 (Berkeley) 6/4/93";*/ +static char *rcsid = "$Id: heapsort.c,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <errno.h> +#include <stdlib.h> + +/* + * Swap two areas of size number of bytes. Although qsort(3) permits random + * blocks of memory to be sorted, sorting pointers is almost certainly the + * common case (and, were it not, could easily be made so). Regardless, it + * isn't worth optimizing; the SWAP's get sped up by the cache, and pointer + * arithmetic gets lost in the time required for comparison function calls. + */ +#define SWAP(a, b, count, size, tmp) { \ + count = size; \ + do { \ + tmp = *a; \ + *a++ = *b; \ + *b++ = tmp; \ + } while (--count); \ +} + +/* Copy one block of size size to another. */ +#define COPY(a, b, count, size, tmp1, tmp2) { \ + count = size; \ + tmp1 = a; \ + tmp2 = b; \ + do { \ + *tmp1++ = *tmp2++; \ + } while (--count); \ +} + +/* + * Build the list into a heap, where a heap is defined such that for + * the records K1 ... KN, Kj/2 >= Kj for 1 <= j/2 <= j <= N. + * + * There two cases. If j == nmemb, select largest of Ki and Kj. If + * j < nmemb, select largest of Ki, Kj and Kj+1. + */ +#define CREATE(initval, nmemb, par_i, child_i, par, child, size, count, tmp) { \ + for (par_i = initval; (child_i = par_i * 2) <= nmemb; \ + par_i = child_i) { \ + child = base + child_i * size; \ + if (child_i < nmemb && compar(child, child + size) < 0) { \ + child += size; \ + ++child_i; \ + } \ + par = base + par_i * size; \ + if (compar(child, par) <= 0) \ + break; \ + SWAP(par, child, count, size, tmp); \ + } \ +} + +/* + * Select the top of the heap and 'heapify'. Since by far the most expensive + * action is the call to the compar function, a considerable optimization + * in the average case can be achieved due to the fact that k, the displaced + * elememt, is ususally quite small, so it would be preferable to first + * heapify, always maintaining the invariant that the larger child is copied + * over its parent's record. + * + * Then, starting from the *bottom* of the heap, finding k's correct place, + * again maintianing the invariant. As a result of the invariant no element + * is 'lost' when k is assigned its correct place in the heap. + * + * The time savings from this optimization are on the order of 15-20% for the + * average case. See Knuth, Vol. 3, page 158, problem 18. + * + * XXX Don't break the #define SELECT line, below. Reiser cpp gets upset. + */ +#define SELECT(par_i, child_i, nmemb, par, child, size, k, count, tmp1, tmp2) { \ + for (par_i = 1; (child_i = par_i * 2) <= nmemb; par_i = child_i) { \ + child = base + child_i * size; \ + if (child_i < nmemb && compar(child, child + size) < 0) { \ + child += size; \ + ++child_i; \ + } \ + par = base + par_i * size; \ + COPY(par, child, count, size, tmp1, tmp2); \ + } \ + for (;;) { \ + child_i = par_i; \ + par_i = child_i / 2; \ + child = base + child_i * size; \ + par = base + par_i * size; \ + if (child_i == 1 || compar(k, par) < 0) { \ + COPY(child, k, count, size, tmp1, tmp2); \ + break; \ + } \ + COPY(child, par, count, size, tmp1, tmp2); \ + } \ +} + +/* + * Heapsort -- Knuth, Vol. 3, page 145. Runs in O (N lg N), both average + * and worst. While heapsort is faster than the worst case of quicksort, + * the BSD quicksort does median selection so that the chance of finding + * a data set that will trigger the worst case is nonexistent. Heapsort's + * only advantage over quicksort is that it requires little additional memory. + */ +int +heapsort(vbase, nmemb, size, compar) + void *vbase; + size_t nmemb, size; + int (*compar) __P((const void *, const void *)); +{ + register int cnt, i, j, l; + register char tmp, *tmp1, *tmp2; + char *base, *k, *p, *t; + + if (nmemb <= 1) + return (0); + + if (!size) { + errno = EINVAL; + return (-1); + } + + if ((k = malloc(size)) == NULL) + return (-1); + + /* + * Items are numbered from 1 to nmemb, so offset from size bytes + * below the starting address. + */ + base = (char *)vbase - size; + + for (l = nmemb / 2 + 1; --l;) + CREATE(l, nmemb, i, j, t, p, size, cnt, tmp); + + /* + * For each element of the heap, save the largest element into its + * final slot, save the displaced element (k), then recreate the + * heap. + */ + while (nmemb > 1) { + COPY(k, base + nmemb * size, cnt, size, tmp1, tmp2); + COPY(base + nmemb * size, base + size, cnt, size, tmp1, tmp2); + --nmemb; + SELECT(i, j, nmemb, t, p, size, k, cnt, tmp1, tmp2); + } + free(k); + return (0); +} diff --git a/src/lib/libc/stdlib/jrand48.c b/src/lib/libc/stdlib/jrand48.c new file mode 100644 index 00000000..205781e0 --- /dev/null +++ b/src/lib/libc/stdlib/jrand48.c @@ -0,0 +1,21 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +long +jrand48(unsigned short xseed[3]) +{ + __dorand48(xseed); + return ((long) xseed[2] << 16) + (long) xseed[1]; +} diff --git a/src/lib/libc/stdlib/l64a.c b/src/lib/libc/stdlib/l64a.c new file mode 100644 index 00000000..3069b31b --- /dev/null +++ b/src/lib/libc/stdlib/l64a.c @@ -0,0 +1,43 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Public domain. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$NetBSD: l64a.c,v 1.4 1995/05/11 23:04:52 jtc Exp $"; +#endif + +#include <stdlib.h> + +char * +l64a (value) + long value; +{ + static char buf[8]; + char *s = buf; + int digit; + int i; + + if (!value) + return NULL; + + for (i = 0; value != 0 && i < 6; i++) { + digit = value & 0x3f; + + if (digit < 2) + *s = digit + '.'; + else if (digit < 12) + *s = digit + '0' - 2; + else if (digit < 38) + *s = digit + 'A' - 12; + else + *s = digit + 'a' - 38; + + value >>= 6; + s++; + } + + *s = '\0'; + + return buf; +} diff --git a/src/lib/libc/stdlib/labs.3 b/src/lib/libc/stdlib/labs.3 new file mode 100644 index 00000000..28e4d205 --- /dev/null +++ b/src/lib/libc/stdlib/labs.3 @@ -0,0 +1,67 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)labs.3 5.3 (Berkeley) 6/29/91 +.\" $Id: labs.3,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt LABS 3 +.Os +.Sh NAME +.Nm labs +.Nd return the absolute value of a long integer +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft long +.Fn labs "long j" +.Sh DESCRIPTION +The +.Fn labs +function +returns the absolute value of the long integer +.Ar j . +.Sh SEE ALSO +.Xr abs 3 , +.Xr floor 3 , +.Xr cabs 3 , +.Xr math 3 +.Sh STANDARDS +The +.Fn labs +function +conforms to +.St -ansiC . +.Sh BUGS +The absolute value of the most negative integer remains negative. diff --git a/src/lib/libc/stdlib/labs.c b/src/lib/libc/stdlib/labs.c new file mode 100644 index 00000000..ccf14157 --- /dev/null +++ b/src/lib/libc/stdlib/labs.c @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)labs.c 5.2 (Berkeley) 5/17/90";*/ +static char *rcsid = "$Id: labs.c,v 1.1.1.1 1995/10/18 08:42:17 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> + +long +labs(j) + long j; +{ + return(j < 0 ? -j : j); +} diff --git a/src/lib/libc/stdlib/lcong48.c b/src/lib/libc/stdlib/lcong48.c new file mode 100644 index 00000000..965d46b1 --- /dev/null +++ b/src/lib/libc/stdlib/lcong48.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +extern unsigned short __rand48_seed[3]; +extern unsigned short __rand48_mult[3]; +extern unsigned short __rand48_add; + +void +lcong48(unsigned short p[7]) +{ + __rand48_seed[0] = p[0]; + __rand48_seed[1] = p[1]; + __rand48_seed[2] = p[2]; + __rand48_mult[0] = p[3]; + __rand48_mult[1] = p[4]; + __rand48_mult[2] = p[5]; + __rand48_add = p[6]; +} diff --git a/src/lib/libc/stdlib/ldiv.3 b/src/lib/libc/stdlib/ldiv.3 new file mode 100644 index 00000000..a7b5ccf8 --- /dev/null +++ b/src/lib/libc/stdlib/ldiv.3 @@ -0,0 +1,72 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)ldiv.3 5.3 (Berkeley) 6/29/91 +.\" $Id: ldiv.3,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt LDIV 3 +.Os +.Sh NAME +.Nm ldiv +.Nd return quotient and remainder from division +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft ldiv_t +.Fn ldiv "long num" "long denom" +.Sh DESCRIPTION +The +.Fn ldiv +function +computes the value +.Ar num/denom +and returns the quotient and remainder in a structure named +.Ar ldiv_t +that contains two +.Em long integer +members named +.Ar quot +and +.Ar rem . +.Sh SEE ALSO +.Xr div 3 , +.Xr qdiv 3 , +.Xr math 3 +.Sh STANDARDS +The +.Fn ldiv +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/ldiv.c b/src/lib/libc/stdlib/ldiv.c new file mode 100644 index 00000000..f7074507 --- /dev/null +++ b/src/lib/libc/stdlib/ldiv.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)ldiv.c 5.2 (Berkeley) 4/16/91";*/ +static char *rcsid = "$Id: ldiv.c,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> /* ldiv_t */ + +ldiv_t +ldiv(num, denom) + long num, denom; +{ + ldiv_t r; + + /* see div.c for comments */ + + r.quot = num / denom; + r.rem = num % denom; + if (num >= 0 && r.rem < 0) { + r.quot++; + r.rem -= denom; + } + return (r); +} diff --git a/src/lib/libc/stdlib/lrand48.c b/src/lib/libc/stdlib/lrand48.c new file mode 100644 index 00000000..8e7f2623 --- /dev/null +++ b/src/lib/libc/stdlib/lrand48.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +extern unsigned short __rand48_seed[3]; + +long +lrand48(void) +{ + __dorand48(__rand48_seed); + return ((long) __rand48_seed[2] << 15) + ((long) __rand48_seed[1] >> 1); +} diff --git a/src/lib/libc/stdlib/malloc.3 b/src/lib/libc/stdlib/malloc.3 new file mode 100644 index 00000000..3bbf2bf6 --- /dev/null +++ b/src/lib/libc/stdlib/malloc.3 @@ -0,0 +1,91 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)malloc.3 6.7 (Berkeley) 6/29/91 +.\" $Id: malloc.3,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt MALLOC 3 +.Os BSD 4 +.Sh NAME +.Nm malloc +.Nd general memory allocation function +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft void * +.Fn malloc "size_t size" +.Sh DESCRIPTION +The +.Fn malloc +function allocates uninitialized space for an object whose +size is specified by +.Fa size . +The +.Fn malloc +function maintains multiple lists of free blocks according to size, allocating +space from the appropriate list. +.Pp +The allocated space is +suitably aligned (after possible pointer +coercion) for storage of any type of object. If the space is of +.Em pagesize +or larger, the memory returned will be page-aligned. +.Sh RETURN VALUES +The +.Fn malloc +function returns +a pointer to the allocated space if successful; otherwise +a null pointer is returned. +.Sh SEE ALSO +.Xr brk 2 , +.Xr getpagesize 2 , +.Xr free 3 , +.Xr calloc 3 , +.Xr alloca 3 , +.Xr realloc 3 , +.Xr memory 3 +.Sh STANDARDS +The +.Fn malloc +function conforms to +.St -ansiC . +.Sh BUGS +The current implementation of +.Xr malloc +does not always fail gracefully when system +memory limits are approached. +It may fail to allocate memory when larger free blocks could be broken +up, or when limits are exceeded because the size is rounded up. +It is optimized for sizes that are powers of two. diff --git a/src/lib/libc/stdlib/malloc.c b/src/lib/libc/stdlib/malloc.c new file mode 100644 index 00000000..3c57fad0 --- /dev/null +++ b/src/lib/libc/stdlib/malloc.c @@ -0,0 +1,421 @@ +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)malloc.c 5.11 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: malloc.c,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $"; +#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> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#define NULL 0 + +static void morecore(); +static int findbucket(); + +/* + * 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_long 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 + +void * +malloc(nbytes) + size_t nbytes; +{ + register union overhead *op; + register long bucket, n; + register unsigned amt; + + /* + * 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) - ((long)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 = -((long)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. + */ +static void +morecore(bucket) + int bucket; +{ + register union overhead *op; + register long sz; /* size of desired block */ + long 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 ((long)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); + } +} + +void +free(cp) + void *cp; +{ + register long 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 */ + +void * +realloc(cp, nbytes) + void *cp; + size_t nbytes; +{ + register u_long onb; + register long 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 diff --git a/src/lib/libc/stdlib/memory.3 b/src/lib/libc/stdlib/memory.3 new file mode 100644 index 00000000..735252c8 --- /dev/null +++ b/src/lib/libc/stdlib/memory.3 @@ -0,0 +1,71 @@ +.\" Copyright (c) 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)memory.3 5.1 (Berkeley) 5/2/91 +.\" $Id: memory.3,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $ +.\" +.Dd May 2, 1991 +.Dt MEMORY 3 +.Os BSD 4 +.Sh NAME +.Nm malloc , +.Nm free , +.Nm realloc , +.Nm calloc , +.Nm alloca +.Nd general memory allocation operations +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft void * +.Fn malloc "size_t size" +.Ft void +.Fn free "void *ptr" +.Ft void * +.Fn realloc "void *ptr" "size_t size" +.Ft void * +.Fn calloc "size_t nelem" "size_t elsize" +.Ft void * +.Fn alloca "size_t size" +.Sh DESCRIPTION +These functions allocate and free memory for the calling process. +They are described in the +individual manual pages. +.Sh SEE ALSO +.Xr calloc 3 , +.Xr free 3 , +.Xr malloc 3 , +.Xr realloc 3 , +.Xr alloca 3 , +.Sh STANDARDS +These functions, with the exception of +.Fn alloca +conform to +.St -ansiC . diff --git a/src/lib/libc/stdlib/merge.c b/src/lib/libc/stdlib/merge.c new file mode 100644 index 00000000..381fdc08 --- /dev/null +++ b/src/lib/libc/stdlib/merge.c @@ -0,0 +1,348 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Peter McIlroy. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char sccsid[] = "from: @(#)merge.c 8.2 (Berkeley) 2/14/94";*/ +static char *rcsid = "$Id: merge.c,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +/* + * Hybrid exponential search/linear search merge sort with hybrid + * natural/pairwise first pass. Requires about .3% more comparisons + * for random data than LSMS with pairwise first pass alone. + * It works for objects as small as two bytes. + */ + +#define NATURAL +#define THRESHOLD 16 /* Best choice for natural merge cut-off. */ + +/* #define NATURAL to get hybrid natural merge. + * (The default is pairwise merging.) + */ + +#include <sys/types.h> + +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +static void setup __P((u_char *, u_char *, size_t, size_t, int (*)())); +static void insertionsort __P((u_char *, size_t, size_t, int (*)())); + +#define ISIZE sizeof(int) +#define PSIZE sizeof(u_char *) +#define ICOPY_LIST(src, dst, last) \ + do \ + *(int*)dst = *(int*)src, src += ISIZE, dst += ISIZE; \ + while(src < last) +#define ICOPY_ELT(src, dst, i) \ + do \ + *(int*) dst = *(int*) src, src += ISIZE, dst += ISIZE; \ + while (i -= ISIZE) + +#define CCOPY_LIST(src, dst, last) \ + do \ + *dst++ = *src++; \ + while (src < last) +#define CCOPY_ELT(src, dst, i) \ + do \ + *dst++ = *src++; \ + while (i -= 1) + +/* + * Find the next possible pointer head. (Trickery for forcing an array + * to do double duty as a linked list when objects do not align with word + * boundaries. + */ +/* Assumption: PSIZE is a power of 2. */ +#define EVAL(p) (u_char **) \ + ((u_char *)0 + \ + (((u_char *)p + PSIZE - 1 - (u_char *) 0) & ~(PSIZE - 1))) + +/* + * Arguments are as for qsort. + */ +int +mergesort(base, nmemb, size, cmp) + void *base; + size_t nmemb; + register size_t size; + int (*cmp) __P((const void *, const void *)); +{ + register int i, sense; + int big, iflag; + register u_char *f1, *f2, *t, *b, *tp2, *q, *l1, *l2; + u_char *list2, *list1, *p2, *p, *last, **p1; + + if (size < PSIZE / 2) { /* Pointers must fit into 2 * size. */ + errno = EINVAL; + return (-1); + } + + /* + * XXX + * Stupid subtraction for the Cray. + */ + iflag = 0; + if (!(size % ISIZE) && !(((char *)base - (char *)0) % ISIZE)) + iflag = 1; + + if ((list2 = malloc(nmemb * size + PSIZE)) == NULL) + return (-1); + + list1 = base; + setup(list1, list2, nmemb, size, cmp); + last = list2 + nmemb * size; + i = big = 0; + while (*EVAL(list2) != last) { + l2 = list1; + p1 = EVAL(list1); + for (tp2 = p2 = list2; p2 != last; p1 = EVAL(l2)) { + p2 = *EVAL(p2); + f1 = l2; + f2 = l1 = list1 + (p2 - list2); + if (p2 != last) + p2 = *EVAL(p2); + l2 = list1 + (p2 - list2); + while (f1 < l1 && f2 < l2) { + if ((*cmp)(f1, f2) <= 0) { + q = f2; + b = f1, t = l1; + sense = -1; + } else { + q = f1; + b = f2, t = l2; + sense = 0; + } + if (!big) { /* here i = 0 */ +LINEAR: while ((b += size) < t && cmp(q, b) >sense) + if (++i == 6) { + big = 1; + goto EXPONENTIAL; + } + } else { +EXPONENTIAL: for (i = size; ; i <<= 1) + if ((p = (b + i)) >= t) { + if ((p = t - size) > b && + (*cmp)(q, p) <= sense) + t = p; + else + b = p; + break; + } else if ((*cmp)(q, p) <= sense) { + t = p; + if (i == size) + big = 0; + goto FASTCASE; + } else + b = p; +SLOWCASE: while (t > b+size) { + i = (((t - b) / size) >> 1) * size; + if ((*cmp)(q, p = b + i) <= sense) + t = p; + else + b = p; + } + goto COPY; +FASTCASE: while (i > size) + if ((*cmp)(q, + p = b + (i >>= 1)) <= sense) + t = p; + else + b = p; +COPY: b = t; + } + i = size; + if (q == f1) { + if (iflag) { + ICOPY_LIST(f2, tp2, b); + ICOPY_ELT(f1, tp2, i); + } else { + CCOPY_LIST(f2, tp2, b); + CCOPY_ELT(f1, tp2, i); + } + } else { + if (iflag) { + ICOPY_LIST(f1, tp2, b); + ICOPY_ELT(f2, tp2, i); + } else { + CCOPY_LIST(f1, tp2, b); + CCOPY_ELT(f2, tp2, i); + } + } + } + if (f2 < l2) { + if (iflag) + ICOPY_LIST(f2, tp2, l2); + else + CCOPY_LIST(f2, tp2, l2); + } else if (f1 < l1) { + if (iflag) + ICOPY_LIST(f1, tp2, l1); + else + CCOPY_LIST(f1, tp2, l1); + } + *p1 = l2; + } + tp2 = list1; /* swap list1, list2 */ + list1 = list2; + list2 = tp2; + last = list2 + nmemb*size; + } + if (base == list2) { + memmove(list2, list1, nmemb*size); + list2 = list1; + } + free(list2); + return (0); +} + +#define swap(a, b) { \ + s = b; \ + i = size; \ + do { \ + tmp = *a; *a++ = *s; *s++ = tmp; \ + } while (--i); \ + a -= size; \ + } +#define reverse(bot, top) { \ + s = top; \ + do { \ + i = size; \ + do { \ + tmp = *bot; *bot++ = *s; *s++ = tmp; \ + } while (--i); \ + s -= size2; \ + } while(bot < s); \ +} + +/* + * Optional hybrid natural/pairwise first pass. Eats up list1 in runs of + * increasing order, list2 in a corresponding linked list. Checks for runs + * when THRESHOLD/2 pairs compare with same sense. (Only used when NATURAL + * is defined. Otherwise simple pairwise merging is used.) + */ +void +setup(list1, list2, n, size, cmp) + size_t n, size; + int (*cmp) __P((const void *, const void *)); + u_char *list1, *list2; +{ + int i, length, size2, tmp, sense; + u_char *f1, *f2, *s, *l2, *last, *p2; + + size2 = size*2; + if (n <= 5) { + insertionsort(list1, n, size, cmp); + *EVAL(list2) = (u_char*) list2 + n*size; + return; + } + /* + * Avoid running pointers out of bounds; limit n to evens + * for simplicity. + */ + i = 4 + (n & 1); + insertionsort(list1 + (n - i) * size, i, size, cmp); + last = list1 + size * (n - i); + *EVAL(list2 + (last - list1)) = list2 + n * size; + +#ifdef NATURAL + p2 = list2; + f1 = list1; + sense = (cmp(f1, f1 + size) > 0); + for (; f1 < last; sense = !sense) { + length = 2; + /* Find pairs with same sense. */ + for (f2 = f1 + size2; f2 < last; f2 += size2) { + if ((cmp(f2, f2+ size) > 0) != sense) + break; + length += 2; + } + if (length < THRESHOLD) { /* Pairwise merge */ + do { + p2 = *EVAL(p2) = f1 + size2 - list1 + list2; + if (sense > 0) + swap (f1, f1 + size); + } while ((f1 += size2) < f2); + } else { /* Natural merge */ + l2 = f2; + for (f2 = f1 + size2; f2 < l2; f2 += size2) { + if ((cmp(f2-size, f2) > 0) != sense) { + p2 = *EVAL(p2) = f2 - list1 + list2; + if (sense > 0) + reverse(f1, f2-size); + f1 = f2; + } + } + if (sense > 0) + reverse (f1, f2-size); + f1 = f2; + if (f2 < last || cmp(f2 - size, f2) > 0) + p2 = *EVAL(p2) = f2 - list1 + list2; + else + p2 = *EVAL(p2) = list2 + n*size; + } + } +#else /* pairwise merge only. */ + for (f1 = list1, p2 = list2; f1 < last; f1 += size2) { + p2 = *EVAL(p2) = p2 + size2; + if (cmp (f1, f1 + size) > 0) + swap(f1, f1 + size); + } +#endif /* NATURAL */ +} + +/* + * This is to avoid out-of-bounds addresses in sorting the + * last 4 elements. + */ +static void +insertionsort(a, n, size, cmp) + u_char *a; + size_t n, size; + int (*cmp) __P((const void *, const void *)); +{ + u_char *ai, *s, *t, *u, tmp; + int i; + + for (ai = a+size; --n >= 1; ai += size) + for (t = ai; t > a; t -= size) { + u = t - size; + if (cmp(u, t) <= 0) + break; + swap(u, t); + } +} diff --git a/src/lib/libc/stdlib/mrand48.c b/src/lib/libc/stdlib/mrand48.c new file mode 100644 index 00000000..43356e66 --- /dev/null +++ b/src/lib/libc/stdlib/mrand48.c @@ -0,0 +1,23 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +extern unsigned short __rand48_seed[3]; + +long +mrand48(void) +{ + __dorand48(__rand48_seed); + return ((long) __rand48_seed[2] << 16) + (long) __rand48_seed[1]; +} diff --git a/src/lib/libc/stdlib/multibyte.c b/src/lib/libc/stdlib/multibyte.c new file mode 100644 index 00000000..fe1cd578 --- /dev/null +++ b/src/lib/libc/stdlib/multibyte.c @@ -0,0 +1,131 @@ +/* + * Copyright (c) 1991 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)multibyte.c 5.1 (Berkeley) 2/18/91";*/ +static char *rcsid = "$Id: multibyte.c,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> + +/* + * Stub multibyte character functions. + * This cheezy implementation is fixed to the native single-byte + * character set. + */ + +int +mblen(s, n) + const char *s; + size_t n; +{ + if (s == NULL || *s == '\0') + return 0; + if (n == 0) + return -1; + return 1; +} + +/*ARGSUSED*/ +int +mbtowc(pwc, s, n) + wchar_t *pwc; + const char *s; + size_t n; +{ + if (s == NULL) + return 0; + if (n == 0) + return -1; + if (pwc) + *pwc = (wchar_t) *s; + return (*s != '\0'); +} + +/*ARGSUSED*/ +int +#ifdef __STDC__ +wctomb(char *s, wchar_t wchar) +#else +wctomb(s, wchar) + char *s; + wchar_t wchar; +#endif +{ + if (s == NULL) + return 0; + + *s = (char) wchar; + return 1; +} + +/*ARGSUSED*/ +size_t +mbstowcs(pwcs, s, n) + wchar_t *pwcs; + const char *s; + size_t n; +{ + int count = 0; + + if (n != 0) { + do { + if ((*pwcs++ = (wchar_t) *s++) == 0) + break; + count++; + } while (--n != 0); + } + + return count; +} + +/*ARGSUSED*/ +size_t +wcstombs(s, pwcs, n) + char *s; + const wchar_t *pwcs; + size_t n; +{ + int count = 0; + + if (n != 0) { + do { + if ((*s++ = (char) *pwcs++) == 0) + break; + count++; + } while (--n != 0); + } + + return count; +} + diff --git a/src/lib/libc/stdlib/nrand48.c b/src/lib/libc/stdlib/nrand48.c new file mode 100644 index 00000000..63f839cb --- /dev/null +++ b/src/lib/libc/stdlib/nrand48.c @@ -0,0 +1,21 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +long +nrand48(unsigned short xseed[3]) +{ + __dorand48(xseed); + return ((long) xseed[2] << 15) + ((long) xseed[1] >> 1); +} diff --git a/src/lib/libc/stdlib/putenv.c b/src/lib/libc/stdlib/putenv.c new file mode 100644 index 00000000..2194c2c6 --- /dev/null +++ b/src/lib/libc/stdlib/putenv.c @@ -0,0 +1,59 @@ +/*- + * Copyright (c) 1988 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)putenv.c 5.4 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: putenv.c,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> +#include <string.h> + +int +putenv(str) + const char *str; +{ + register char *p, *equal; + int rval; + + if (!(p = strdup(str))) + return(1); + if (!(equal = strchr(p, '='))) { + (void)free(p); + return(1); + } + *equal = '\0'; + rval = setenv(p, equal + 1, 1); + (void)free(p); + return(rval); +} diff --git a/src/lib/libc/stdlib/qabs.3 b/src/lib/libc/stdlib/qabs.3 new file mode 100644 index 00000000..cb1e0521 --- /dev/null +++ b/src/lib/libc/stdlib/qabs.3 @@ -0,0 +1,62 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)labs.3 5.3 (Berkeley) 6/29/91 +.\" $Id: qabs.3,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt QABS 3 +.Os +.Sh NAME +.Nm qabs +.Nd return the absolute value of a quad integer +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft quad_t +.Fn qabs "quad_t j" +.Sh DESCRIPTION +The +.Fn qabs +function +returns the absolute value of the quad integer +.Ar j . +.Sh SEE ALSO +.Xr abs 3 , +.Xr labs 3 , +.Xr floor 3 , +.Xr cabs 3 , +.Xr math 3 +.Sh BUGS +The absolute value of the most negative integer remains negative. diff --git a/src/lib/libc/stdlib/qabs.c b/src/lib/libc/stdlib/qabs.c new file mode 100644 index 00000000..9c51a8ba --- /dev/null +++ b/src/lib/libc/stdlib/qabs.c @@ -0,0 +1,46 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)labs.c 5.2 (Berkeley) 5/17/90";*/ +static char *rcsid = "$Id: qabs.c,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> + +quad_t +qabs(j) + quad_t j; +{ + return(j < 0 ? -j : j); +} diff --git a/src/lib/libc/stdlib/qdiv.3 b/src/lib/libc/stdlib/qdiv.3 new file mode 100644 index 00000000..0efcfc96 --- /dev/null +++ b/src/lib/libc/stdlib/qdiv.3 @@ -0,0 +1,66 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)qdiv.3 5.3 (Berkeley) 6/29/91 +.\" $Id: qdiv.3,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt QDIV 3 +.Os +.Sh NAME +.Nm qdiv +.Nd return quotient and remainder from division +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft qdiv_t +.Fn qdiv "quad_t num" "quad_t denom" +.Sh DESCRIPTION +The +.Fn qdiv +function +computes the value +.Ar num/denom +and returns the quotient and remainder in a structure named +.Ar qdiv_t +that contains two +.Em quad integer +members named +.Ar quot +and +.Ar rem . +.Sh SEE ALSO +.Xr div 3 , +.Xr ldiv 3 , +.Xr math 3 diff --git a/src/lib/libc/stdlib/qdiv.c b/src/lib/libc/stdlib/qdiv.c new file mode 100644 index 00000000..8f8e3f89 --- /dev/null +++ b/src/lib/libc/stdlib/qdiv.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)ldiv.c 5.2 (Berkeley) 4/16/91";*/ +static char *rcsid = "$Id: qdiv.c,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> /* qdiv_t */ + +qdiv_t +qdiv(num, denom) + quad_t num, denom; +{ + qdiv_t r; + + /* see div.c for comments */ + + r.quot = num / denom; + r.rem = num % denom; + if (num >= 0 && r.rem < 0) { + r.quot++; + r.rem -= denom; + } + return (r); +} diff --git a/src/lib/libc/stdlib/qsort.3 b/src/lib/libc/stdlib/qsort.3 new file mode 100644 index 00000000..eb122cde --- /dev/null +++ b/src/lib/libc/stdlib/qsort.3 @@ -0,0 +1,234 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)qsort.3 8.1 (Berkeley) 6/4/93 +.\" $Id: qsort.3,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $ +.\" +.Dd June 4, 1993 +.Dt QSORT 3 +.Os +.Sh NAME +.Nm qsort, heapsort, mergesort +.Nd sort functions +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft void +.Fn qsort "void *base" "size_t nmemb" "size_t size" "int (*compar)(const void *, const void *)" +.Ft int +.Fn heapsort "void *base" "size_t nmemb" "size_t size" "int (*compar)(const void *, const void *)" +.Ft int +.Fn mergesort "void *base" "size_t nmemb" "size_t size" "int (*compar)(const void *, const void *)" +.Sh DESCRIPTION +The +.Fn qsort +function is a modified partition-exchange sort, or quicksort. +The +.Fn heapsort +function is a modified selection sort. +The +.Fn mergesort +function is a modified merge sort with exponential search +intended for sorting data with pre-existing order. +.Pp +The +.Fn qsort +and +.Fn heapsort +functions sort an array of +.Fa nmemb +objects, the initial member of which is pointed to by +.Fa base . +The size of each object is specified by +.Fa size . +.Fn Mergesort +behaves similarly, but +.Em requires +that +.Fa size +be greater than +.Dq "sizeof(void *) / 2" . +.Pp +The contents of the array +.Fa base +are sorted in ascending order according to +a comparison function pointed to by +.Fa compar , +which requires two arguments pointing to the objects being +compared. +.Pp +The comparison function must return an integer less than, equal to, or +greater than zero if the first argument is considered to be respectively +less than, equal to, or greater than the second. +.Pp +The functions +.Fn qsort +and +.Fn heapsort +are +.Em not +stable, that is, if two members compare as equal, their order in +the sorted array is undefined. +The function +.Fn mergesort +is stable. +.Pp +The +.Fn qsort +function is an implementation of C.A.R. Hoare's ``quicksort'' algorithm, +a variant of partition-exchange sorting; in particular, see D.E. Knuth's +Algorithm Q. +.Fn Qsort +takes O N lg N average time. +This implementation uses median selection to avoid its +O N**2 worst-case behavior. +.Pp +The +.Fn heapsort +function is an implementation of J.W.J. William's ``heapsort'' algorithm, +a variant of selection sorting; in particular, see D.E. Knuth's Algorithm H. +.Fn Heapsort +takes O N lg N worst-case time. +Its +.Em only +advantage over +.Fn qsort +is that it uses almost no additional memory; while +.Fn qsort +does not allocate memory, it is implemented using recursion. +.Pp +The function +.Fn mergesort +requires additional memory of size +.Fa nmemb * +.Fa size +bytes; it should be used only when space is not at a premium. +.Fn Mergesort +is optimized for data with pre-existing order; its worst case +time is O N lg N; its best case is O N. +.Pp +Normally, +.Fn qsort +is faster than +.Fn mergesort +is faster than +.Fn heapsort . +Memory availability and pre-existing order in the data can make this +untrue. +.Sh RETURN VALUES +The +.Fn qsort +function +returns no value. +.Pp +Upon successful completion, +.Fn heapsort +and +.Fn mergesort +return 0. +Otherwise, they return \-1 and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +The +.Fn heapsort +function succeeds unless: +.Bl -tag -width Er +.It Bq Er EINVAL +The +.Fa size +argument is zero, or, +the +.Fa size +argument to +.Fn mergesort +is less than +.Dq "sizeof(void *) / 2" . +.It Bq Er ENOMEM +.Fn Heapsort +or +.Fn mergesort +were unable to allocate memory. +.El +.Sh COMPATIBILITY +Previous versions of +.Fn qsort +did not permit the comparison routine itself to call +.Fn qsort 3 . +This is no longer true. +.Sh SEE ALSO +.Xr sort 1 , +.Xr radixsort 3 +.Rs +.%A Hoare, C.A.R. +.%D 1962 +.%T "Quicksort" +.%J "The Computer Journal" +.%V 5:1 +.%P pp. 10-15 +.Re +.Rs +.%A Williams, J.W.J +.%D 1964 +.%T "Heapsort" +.%J "Communications of the ACM" +.%V 7:1 +.%P pp. 347-348 +.Re +.Rs +.%A Knuth, D.E. +.%D 1968 +.%B "The Art of Computer Programming" +.%V Vol. 3 +.%T "Sorting and Searching" +.%P pp. 114-123, 145-149 +.Re +.Rs +.%A Mcilroy, P.M. +.%T "Optimistic Sorting and Information Theoretic Complexity" +.%J "Fourth Annual ACM-SIAM Symposium on Discrete Algorithms" +.%V January 1992 +.Re +.Rs +.%A Bentley, J.L. +.%T "Engineering a Sort Function" +.%J "bentley@research.att.com" +.%V January 1992 +.Re +.Sh STANDARDS +The +.Fn qsort +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/qsort.c b/src/lib/libc/stdlib/qsort.c new file mode 100644 index 00000000..c06bd540 --- /dev/null +++ b/src/lib/libc/stdlib/qsort.c @@ -0,0 +1,175 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char sccsid[] = "from: @(#)qsort.c 8.1 (Berkeley) 6/4/93";*/ +static char *rcsid = "$Id: qsort.c,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <stdlib.h> + +static inline char *med3 __P((char *, char *, char *, int (*)())); +static inline void swapfunc __P((char *, char *, int, int)); + +#define min(a, b) (a) < (b) ? a : b + +/* + * Qsort routine from Bentley & McIlroy's "Engineering a Sort Function". + */ +#define swapcode(TYPE, parmi, parmj, n) { \ + long i = (n) / sizeof (TYPE); \ + register TYPE *pi = (TYPE *) (parmi); \ + register TYPE *pj = (TYPE *) (parmj); \ + do { \ + register TYPE t = *pi; \ + *pi++ = *pj; \ + *pj++ = t; \ + } while (--i > 0); \ +} + +#define SWAPINIT(a, es) swaptype = ((char *)a - (char *)0) % sizeof(long) || \ + es % sizeof(long) ? 2 : es == sizeof(long)? 0 : 1; + +static inline void +swapfunc(a, b, n, swaptype) + char *a, *b; + int n, swaptype; +{ + if(swaptype <= 1) + swapcode(long, a, b, n) + else + swapcode(char, a, b, n) +} + +#define swap(a, b) \ + if (swaptype == 0) { \ + long t = *(long *)(a); \ + *(long *)(a) = *(long *)(b); \ + *(long *)(b) = t; \ + } else \ + swapfunc(a, b, es, swaptype) + +#define vecswap(a, b, n) if ((n) > 0) swapfunc(a, b, n, swaptype) + +static inline char * +med3(a, b, c, cmp) + char *a, *b, *c; + int (*cmp)(); +{ + return cmp(a, b) < 0 ? + (cmp(b, c) < 0 ? b : (cmp(a, c) < 0 ? c : a )) + :(cmp(b, c) > 0 ? b : (cmp(a, c) < 0 ? a : c )); +} + +void +qsort(a, n, es, cmp) + void *a; + size_t n, es; + int (*cmp)(); +{ + char *pa, *pb, *pc, *pd, *pl, *pm, *pn; + int d, r, swaptype, swap_cnt; + +loop: SWAPINIT(a, es); + swap_cnt = 0; + if (n < 7) { + for (pm = a + es; pm < (char *) a + n * es; pm += es) + for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; + pl -= es) + swap(pl, pl - es); + return; + } + pm = a + (n / 2) * es; + if (n > 7) { + pl = a; + pn = a + (n - 1) * es; + if (n > 40) { + d = (n / 8) * es; + pl = med3(pl, pl + d, pl + 2 * d, cmp); + pm = med3(pm - d, pm, pm + d, cmp); + pn = med3(pn - 2 * d, pn - d, pn, cmp); + } + pm = med3(pl, pm, pn, cmp); + } + swap(a, pm); + pa = pb = a + es; + + pc = pd = a + (n - 1) * es; + for (;;) { + while (pb <= pc && (r = cmp(pb, a)) <= 0) { + if (r == 0) { + swap_cnt = 1; + swap(pa, pb); + pa += es; + } + pb += es; + } + while (pb <= pc && (r = cmp(pc, a)) >= 0) { + if (r == 0) { + swap_cnt = 1; + swap(pc, pd); + pd -= es; + } + pc -= es; + } + if (pb > pc) + break; + swap(pb, pc); + swap_cnt = 1; + pb += es; + pc -= es; + } + if (swap_cnt == 0) { /* Switch to insertion sort */ + for (pm = a + es; pm < (char *) a + n * es; pm += es) + for (pl = pm; pl > (char *) a && cmp(pl - es, pl) > 0; + pl -= es) + swap(pl, pl - es); + return; + } + + pn = a + n * es; + r = min(pa - (char *)a, pb - pa); + vecswap(a, pb - r, r); + r = min(pd - pc, pn - pd - es); + vecswap(pb, pn - r, r); + if ((r = pb - pa) > es) + qsort(a, r / es, es, cmp); + if ((r = pd - pc) > es) { + /* Iterate rather than recurse to save stack space */ + a = pn - r; + n = r / es; + goto loop; + } +/* qsort(pn - r, r / es, es, cmp);*/ +} diff --git a/src/lib/libc/stdlib/radixsort.3 b/src/lib/libc/stdlib/radixsort.3 new file mode 100644 index 00000000..a2af9f17 --- /dev/null +++ b/src/lib/libc/stdlib/radixsort.3 @@ -0,0 +1,161 @@ +.\" Copyright (c) 1990, 1991, 1993 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)radixsort.3 8.2 (Berkeley) 1/27/94 +.\" $Id: radixsort.3,v 1.1.1.1 1995/10/18 08:42:18 deraadt Exp $ +.\" +.Dd January 27, 1994 +.Dt RADIXSORT 3 +.Os +.Sh NAME +.Nm radixsort +.Nd radix sort +.Sh SYNOPSIS +.Fd #include <limits.h> +.Fd #include <stdlib.h> +.Ft int +.Fn radixsort "u_char **base" "int nmemb" "u_char *table" "u_int endbyte" +.Ft int +.Fn sradixsort "u_char **base" "int nmemb" "u_char *table" "u_int endbyte" +.Sh DESCRIPTION +The +.Fn radixsort +and +.Fn sradixsort +functions +are implementations of radix sort. +.Pp +These functions sort an array of pointers to byte strings, the initial +member of which is referenced by +.Fa base . +The byte strings may contain any values; the end of each string +is denoted by the user-specified value +.Fa endbyte . +.Pp +Applications may specify a sort order by providing the +.Fa table +argument. +If +.Pf non- Dv NULL , +.Fa table +must reference an array of +.Dv UCHAR_MAX ++ 1 bytes which contains the sort +weight of each possible byte value. +The end-of-string byte must have a sort weight of 0 or 255 +(for sorting in reverse order). +More than one byte may have the same sort weight. +The +.Fa table +argument +is useful for applications which wish to sort different characters +equally, for example, providing a table with the same weights +for A-Z as for a-z will result in a case-insensitive sort. +If +.Fa table +is NULL, the contents of the array are sorted in ascending order +according to the +.Tn ASCII +order of the byte strings they reference and +.Fa endbyte +has a sorting weight of 0. +.Pp +The +.Fn sradixsort +function is stable, that is, if two elements compare as equal, their +order in the sorted array is unchanged. +The +.Fn sradixsort +function uses additional memory sufficient to hold +.Fa nmemb +pointers. +.Pp +The +.Fn radixsort +function is not stable, but uses no additional memory. +.Pp +These functions are variants of most-significant-byte radix sorting; in +particular, see D.E. Knuth's Algorithm R and section 5.2.5, exercise 10. +They take linear time relative to the number of bytes in the strings. +.Sh RETURN VALUES +Upon successful completion 0 is returned. +Otherwise, \-1 is returned and the global variable +.Va errno +is set to indicate the error. +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er EINVAL +The value of the +.Fa endbyte +element of +.Fa table +is not 0 or 255. +.El +.Pp +Additionally, the +.Fn sradixsort +function +may fail and set +.Va errno +for any of the errors specified for the library routine +.Xr malloc 3 . +.Sh SEE ALSO +.Xr sort 1 , +.Xr qsort 3 +.Pp +.Rs +.%A Knuth, D.E. +.%D 1968 +.%B "The Art of Computer Programming" +.%T "Sorting and Searching" +.%V Vol. 3 +.%P pp. 170-178 +.Re +.Rs +.%A Paige, R. +.%D 1987 +.%T "Three Partition Refinement Algorithms" +.%J "SIAM J. Comput." +.%V Vol. 16 +.%N No. 6 +.Re +.Rs +.%A McIlroy, P. +.%D 1993 +.%B "Engineering Radix Sort" +.%T "Computing Systems" +.%V Vol. 6:1 +.%P pp. 5-27 +.Re +.Sh HISTORY +The +.Fn radixsort +function first appeared in 4.4BSD. diff --git a/src/lib/libc/stdlib/radixsort.c b/src/lib/libc/stdlib/radixsort.c new file mode 100644 index 00000000..dd51013c --- /dev/null +++ b/src/lib/libc/stdlib/radixsort.c @@ -0,0 +1,318 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Peter McIlroy and by Dan Bernstein at New York University, + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char sccsid[] = "from: @(#)radixsort.c 8.1 (Berkeley) 6/4/93";*/ +static char *rcsid = "$Id: radixsort.c,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +/* + * Radixsort routines. + * + * Program r_sort_a() is unstable but uses O(logN) extra memory for a stack. + * Use radixsort(a, n, trace, endchar) for this case. + * + * For stable sorting (using N extra pointers) use sradixsort(), which calls + * r_sort_b(). + * + * For a description of this code, see D. McIlroy, P. McIlroy, K. Bostic, + * "Engineering Radix Sort". + */ + +#include <sys/types.h> +#include <stdlib.h> +#include <errno.h> + +typedef struct { + const u_char **sa; + int sn, si; +} stack; + +static inline void simplesort + __P((const u_char **, int, int, const u_char *, u_int)); +static void r_sort_a __P((const u_char **, int, int, const u_char *, u_int)); +static void r_sort_b __P((const u_char **, + const u_char **, int, int, const u_char *, u_int)); + +#define THRESHOLD 20 /* Divert to simplesort(). */ +#define SIZE 512 /* Default stack size. */ + +#define SETUP { \ + if (tab == NULL) { \ + tr = tr0; \ + for (c = 0; c < endch; c++) \ + tr0[c] = c + 1; \ + tr0[c] = 0; \ + for (c++; c < 256; c++) \ + tr0[c] = c; \ + endch = 0; \ + } else { \ + endch = tab[endch]; \ + tr = tab; \ + if (endch != 0 && endch != 255) { \ + errno = EINVAL; \ + return (-1); \ + } \ + } \ +} + +int +radixsort(a, n, tab, endch) + const u_char **a, *tab; + int n; + u_int endch; +{ + const u_char *tr; + int c; + u_char tr0[256]; + + SETUP; + r_sort_a(a, n, 0, tr, endch); + return (0); +} + +int +sradixsort(a, n, tab, endch) + const u_char **a, *tab; + int n; + u_int endch; +{ + const u_char *tr, **ta; + int c; + u_char tr0[256]; + + SETUP; + if (n < THRESHOLD) + simplesort(a, n, 0, tr, endch); + else { + if ((ta = malloc(n * sizeof(a))) == NULL) + return (-1); + r_sort_b(a, ta, n, 0, tr, endch); + free(ta); + } + return (0); +} + +#define empty(s) (s >= sp) +#define pop(a, n, i) a = (--sp)->sa, n = sp->sn, i = sp->si +#define push(a, n, i) sp->sa = a, sp->sn = n, (sp++)->si = i +#define swap(a, b, t) t = a, a = b, b = t + +/* Unstable, in-place sort. */ +void +r_sort_a(a, n, i, tr, endch) + const u_char **a; + int n, i; + const u_char *tr; + u_int endch; +{ + static int count[256], nc, bmin; + register int c; + register const u_char **ak, *r; + stack s[SIZE], *sp, *sp0, *sp1, temp; + int *cp, bigc; + const u_char **an, *t, **aj, **top[256]; + + /* Set up stack. */ + sp = s; + push(a, n, i); + while (!empty(s)) { + pop(a, n, i); + if (n < THRESHOLD) { + simplesort(a, n, i, tr, endch); + continue; + } + an = a + n; + + /* Make character histogram. */ + if (nc == 0) { + bmin = 255; /* First occupied bin, excluding eos. */ + for (ak = a; ak < an;) { + c = tr[(*ak++)[i]]; + if (++count[c] == 1 && c != endch) { + if (c < bmin) + bmin = c; + nc++; + } + } + if (sp + nc > s + SIZE) { /* Get more stack. */ + r_sort_a(a, n, i, tr, endch); + continue; + } + } + + /* + * Set top[]; push incompletely sorted bins onto stack. + * top[] = pointers to last out-of-place element in bins. + * count[] = counts of elements in bins. + * Before permuting: top[c-1] + count[c] = top[c]; + * during deal: top[c] counts down to top[c-1]. + */ + sp0 = sp1 = sp; /* Stack position of biggest bin. */ + bigc = 2; /* Size of biggest bin. */ + if (endch == 0) /* Special case: set top[eos]. */ + top[0] = ak = a + count[0]; + else { + ak = a; + top[255] = an; + } + for (cp = count + bmin; nc > 0; cp++) { + while (*cp == 0) /* Find next non-empty pile. */ + cp++; + if (*cp > 1) { + if (*cp > bigc) { + bigc = *cp; + sp1 = sp; + } + push(ak, *cp, i+1); + } + top[cp-count] = ak += *cp; + nc--; + } + swap(*sp0, *sp1, temp); /* Play it safe -- biggest bin last. */ + + /* + * Permute misplacements home. Already home: everything + * before aj, and in bin[c], items from top[c] on. + * Inner loop: + * r = next element to put in place; + * ak = top[r[i]] = location to put the next element. + * aj = bottom of 1st disordered bin. + * Outer loop: + * Once the 1st disordered bin is done, ie. aj >= ak, + * aj<-aj + count[c] connects the bins in a linked list; + * reset count[c]. + */ + for (aj = a; aj < an; *aj = r, aj += count[c], count[c] = 0) + for (r = *aj; aj < (ak = --top[c = tr[r[i]]]);) + swap(*ak, r, t); + } +} + +/* Stable sort, requiring additional memory. */ +void +r_sort_b(a, ta, n, i, tr, endch) + const u_char **a, **ta; + int n, i; + const u_char *tr; + u_int endch; +{ + static int count[256], nc, bmin; + register int c; + register const u_char **ak, **ai; + stack s[512], *sp, *sp0, *sp1, temp; + const u_char **top[256]; + int *cp, bigc; + + sp = s; + push(a, n, i); + while (!empty(s)) { + pop(a, n, i); + if (n < THRESHOLD) { + simplesort(a, n, i, tr, endch); + continue; + } + + if (nc == 0) { + bmin = 255; + for (ak = a + n; --ak >= a;) { + c = tr[(*ak)[i]]; + if (++count[c] == 1 && c != endch) { + if (c < bmin) + bmin = c; + nc++; + } + } + if (sp + nc > s + SIZE) { + r_sort_b(a, ta, n, i, tr, endch); + continue; + } + } + + sp0 = sp1 = sp; + bigc = 2; + if (endch == 0) { + top[0] = ak = a + count[0]; + count[0] = 0; + } else { + ak = a; + top[255] = a + n; + count[255] = 0; + } + for (cp = count + bmin; nc > 0; cp++) { + while (*cp == 0) + cp++; + if ((c = *cp) > 1) { + if (c > bigc) { + bigc = c; + sp1 = sp; + } + push(ak, c, i+1); + } + top[cp-count] = ak += c; + *cp = 0; /* Reset count[]. */ + nc--; + } + swap(*sp0, *sp1, temp); + + for (ak = ta + n, ai = a+n; ak > ta;) /* Copy to temp. */ + *--ak = *--ai; + for (ak = ta+n; --ak >= ta;) /* Deal to piles. */ + *--top[tr[(*ak)[i]]] = *ak; + } +} + +static inline void +simplesort(a, n, b, tr, endch) /* insertion sort */ + register const u_char **a; + int n, b; + register const u_char *tr; + u_int endch; +{ + register u_char ch; + const u_char **ak, **ai, *s, *t; + + for (ak = a+1; --n >= 1; ak++) + for (ai = ak; ai > a; ai--) { + for (s = ai[0] + b, t = ai[-1] + b; + (ch = tr[*s]) != endch; s++, t++) + if (ch != tr[*t]) + break; + if (ch >= tr[*t]) + break; + swap(ai[0], ai[-1], s); + } +} diff --git a/src/lib/libc/stdlib/rand.3 b/src/lib/libc/stdlib/rand.3 new file mode 100644 index 00000000..a0e7740e --- /dev/null +++ b/src/lib/libc/stdlib/rand.3 @@ -0,0 +1,85 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)rand.3 6.7 (Berkeley) 6/29/91 +.\" $Id: rand.3,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt RAND 3 +.Os +.Sh NAME +.Nm rand , +.Nm srand +.Nd bad random number generator +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft void +.Fn srand "unsigned seed" +.Ft int +.Fn rand void +.Sh DESCRIPTION +.Bf -symbolic +These interfaces are obsoleted by random(3). +.Ef +.Pp +The +.Fn rand +function computes a sequence of pseudo-random integers in the range +of 0 to +.Dv RAND_MAX +(as defined by the header file +.Aq Pa stdlib.h ) . +.Pp +The +.Fn srand +function sets its argument as the seed for a new sequence of +pseudo-random numbers to be returned by +.Fn rand . +These sequences are repeatable by calling +.Fn srand +with the same seed value. +.Pp +If no seed value is provided, the functions are automatically +seeded with a value of 1. +.Sh SEE ALSO +.Xr random 3 +.Sh STANDARDS +The +.Fn rand +and +.Fn srand +functions +conform to +.St -ansiC . diff --git a/src/lib/libc/stdlib/rand.c b/src/lib/libc/stdlib/rand.c new file mode 100644 index 00000000..361d4734 --- /dev/null +++ b/src/lib/libc/stdlib/rand.c @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)rand.c 5.6 (Berkeley) 6/24/91";*/ +static char *rcsid = "$Id: rand.c,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <stdlib.h> + +static u_long next = 1; + +int +rand() +{ + return ((next = next * 1103515245 + 12345) % ((u_int)RAND_MAX + 1)); +} + +void +srand(seed) +u_int seed; +{ + next = seed; +} diff --git a/src/lib/libc/stdlib/rand48.3 b/src/lib/libc/stdlib/rand48.3 new file mode 100644 index 00000000..5a772c9a --- /dev/null +++ b/src/lib/libc/stdlib/rand48.3 @@ -0,0 +1,160 @@ +\" Copyright (c) 1993 Martin Birgmeier +.\" All rights reserved. +.\" +.\" You may redistribute unmodified or modified versions of this source +.\" code provided that the above copyright notice and this and the +.\" following conditions are retained. +.\" +.\" This software is provided ``as is'', and comes with no warranties +.\" of any kind. I shall in no event be liable for anything that happens +.\" to anyone/anything when using this software. +.\" +.\" $Id: rand48.3,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $ +.\" +.Dd October 8, 1993 +.Dt RAND48 3 +.Os +.Sh NAME +.Nm drand48 , +.Nm erand48 , +.Nm lrand48 , +.Nm nrand48 , +.Nm mrand48 , +.Nm jrand48 , +.Nm srand48 , +.Nm seed48 , +.Nm lcong48 +.Nd pseudo random number generators and initialization routines +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft double +.Fn drand48 void +.Ft double +.Fn erand48 "unsigned short xseed[3]" +.Ft long +.Fn lrand48 void +.Ft long +.Fn nrand48 "unsigned short xseed[3]" +.Ft long +.Fn mrand48 void +.Ft long +.Fn jrand48 "unsigned short xseed[3]" +.Ft void +.Fn srand48 "long seed" +.Ft "unsigned short *" +.Fn seed48 "unsigned short xseed[3]" +.Ft void +.Fn lcong48 "unsigned short p[7]" +.Sh DESCRIPTION +The +.Fn rand48 +family of functions generates pseudo-random numbers using a linear +congruential algorithm working on integers 48 bits in size. The +particular formula employed is +r(n+1) = (a * r(n) + c) mod m +where the default values are +for the multiplicand a = 0xfdeece66d = 25214903917 and +the addend c = 0xb = 11. The modulus is always fixed at m = 2 ** 48. +r(n) is called the seed of the random number generator. +.Pp +For all the six generator routines described next, the first +computational step is to perform a single iteration of the algorithm. +.Pp +.Fn drand48 +and +.Fn erand48 +return values of type double. The full 48 bits of r(n+1) are +loaded into the mantissa of the returned value, with the exponent set +such that the values produced lie in the interval [0.0, 1.0). +.Pp +.Fn lrand48 +and +.Fn nrand48 +return values of type long in the range +[0, 2**31-1]. The high-order (31) bits of +r(n+1) are loaded into the lower bits of the returned value, with +the topmost (sign) bit set to zero. +.Pp +.Fn mrand48 +and +.Fn jrand48 +return values of type long in the range +[-2**31, 2**31-1]. The high-order (32) bits of +r(n+1) are loaded into the returned value. +.Pp +.Fn drand48 , +.Fn lrand48 , +and +.Fn mrand48 +use an internal buffer to store r(n). For these functions +the initial value of r(0) = 0x1234abcd330e = 20017429951246. +.Pp +On the other hand, +.Fn erand48 , +.Fn nrand48 , +and +.Fn jrand48 +use a user-supplied buffer to store the seed r(n), +which consists of an array of 3 shorts, where the zeroth member +holds the least significant bits. +.Pp +All functions share the same multiplicand and addend. +.Pp +.Fn srand48 +is used to initialize the internal buffer r(n) of +.Fn drand48 , +.Fn lrand48 , +and +.Fn mrand48 +such that the 32 bits of the seed value are copied into the upper 32 bits +of r(n), with the lower 16 bits of r(n) arbitrarily being set to 0x330e. +Additionally, the constant multiplicand and addend of the algorithm are +reset to the default values given above. +.Pp +.Fn seed48 +also initializes the internal buffer r(n) of +.Fn drand48 , +.Fn lrand48 , +and +.Fn mrand48 , +but here all 48 bits of the seed can be specified in an array of 3 shorts, +where the zeroth member specifies the lowest bits. Again, +the constant multiplicand and addend of the algorithm are +reset to the default values given above. +.Fn seed48 +returns a pointer to an array of 3 shorts which contains the old seed. +This array is statically allocated, thus its contents are lost after +each new call to +.Fn seed48 . +.Pp +Finally, +.Fn lcong48 +allows full control over the multiplicand and addend used in +.Fn drand48 , +.Fn erand48 , +.Fn lrand48 , +.Fn nrand48 , +.Fn mrand48 , +and +.Fn jrand48 , +and the seed used in +.Fn drand48 , +.Fn lrand48 , +and +.Fn mrand48 . +An array of 7 shorts is passed as parameter; the first three shorts are +used to initialize the seed; the second three are used to initialize the +multiplicand; and the last short is used to initialize the addend. +It is thus not possible to use values greater than 0xffff as the addend. +.Pp +Note that all three methods of seeding the random number generator +always also set the multiplicand and addend for any of the six +generator calls. +.Pp +For a more powerful random number generator, see +.Xr random 3 +.Sh AUTHOR +Martin Birgmeier +.Sh SEE ALSO +.Xr rand 3 , +.Xr random 3 . diff --git a/src/lib/libc/stdlib/rand48.h b/src/lib/libc/stdlib/rand48.h new file mode 100644 index 00000000..12496d1c --- /dev/null +++ b/src/lib/libc/stdlib/rand48.h @@ -0,0 +1,30 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#ifndef _RAND48_H_ +#define _RAND48_H_ + +#include <math.h> +#include <stdlib.h> + +void __dorand48 __P((unsigned short[3])); + +#define RAND48_SEED_0 (0x330e) +#define RAND48_SEED_1 (0xabcd) +#define RAND48_SEED_2 (0x1234) +#define RAND48_MULT_0 (0xe66d) +#define RAND48_MULT_1 (0xdeec) +#define RAND48_MULT_2 (0x0005) +#define RAND48_ADD (0x000b) + +#endif /* _RAND48_H_ */ diff --git a/src/lib/libc/stdlib/random.3 b/src/lib/libc/stdlib/random.3 new file mode 100644 index 00000000..38c15a98 --- /dev/null +++ b/src/lib/libc/stdlib/random.3 @@ -0,0 +1,167 @@ +.\" Copyright (c) 1983, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)random.3 6.5 (Berkeley) 4/19/91 +.\" $Id: random.3,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt RANDOM 3 +.Os BSD 4.2 +.Sh NAME +.Nm random , +.Nm srandom , +.Nm initstate , +.Nm setstate +.Nd better random number generator; routines for changing generators +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft long +.Fn random void +.Ft void +.Fn srandom "unsigned seed" +.Ft char * +.Fn initstate "unsigned seed" "char *state" "int n" +.Ft char * +.Fn setstate "char *state" +.Sh DESCRIPTION +The +.Fn random +function +uses a non-linear additive feedback random number generator employing a +default table of size 31 long integers to return successive pseudo-random +numbers in the range from 0 to +.if t 2\u\s731\s10\d\(mi1. +.if n (2**31)\(mi1. +The period of this random number generator is very large, approximately +.if t 16\(mu(2\u\s731\s10\d\(mi1). +.if n 16*((2**31)\(mi1). +.Pp +The +.Fn random Ns / Fn srandom +have (almost) the same calling sequence and initialization properties as +.Xr rand 3 Ns / Xr srand 3 . +The difference is that +.Xr rand +produces a much less random sequence \(em in fact, the low dozen bits +generated by rand go through a cyclic pattern. All the bits generated by +.Fn random +are usable. For example, +.Sq Li random()&01 +will produce a random binary +value. +.Pp +Unlike +.Xr srand , +.Fn srandom +does not return the old seed; the reason for this is that the amount of +state information used is much more than a single word. (Two other +routines are provided to deal with restarting/changing random +number generators). Like +.Xr rand 3 , +however, +.Fn random +will by default produce a sequence of numbers that can be duplicated +by calling +.Fn srandom +with +.Ql 1 +as the seed. +.Pp +The +.Fn initstate +routine allows a state array, passed in as an argument, to be initialized +for future use. The size of the state array (in bytes) is used by +.Fn initstate +to decide how sophisticated a random number generator it should use \(em the +more state, the better the random numbers will be. +(Current "optimal" values for the amount of state information are +8, 32, 64, 128, and 256 bytes; other amounts will be rounded down to +the nearest known amount. Using less than 8 bytes will cause an error.) +The seed for the initialization (which specifies a starting point for +the random number sequence, and provides for restarting at the same +point) is also an argument. +The +.Fn initstate +function +returns a pointer to the previous state information array. +.Pp +Once a state has been initialized, the +.Fn setstate +routine provides for rapid switching between states. +The +.Fn setstate +function +returns a pointer to the previous state array; its +argument state array is used for further random number generation +until the next call to +.Fn initstate +or +.Fn setstate . +.Pp +Once a state array has been initialized, it may be restarted at a +different point either by calling +.Fn initstate +(with the desired seed, the state array, and its size) or by calling +both +.Fn setstate +(with the state array) and +.Fn srandom +(with the desired seed). +The advantage of calling both +.Fn setstate +and +.Fn srandom +is that the size of the state array does not have to be remembered after +it is initialized. +.Pp +With 256 bytes of state information, the period of the random number +generator is greater than +.if t 2\u\s769\s10\d, +.if n 2**69 +which should be sufficient for most purposes. +.Sh AUTHOR +Earl T. Cohen +.Sh DIAGNOSTICS +If +.Fn initstate +is called with less than 8 bytes of state information, or if +.Fn setstate +detects that the state information has been garbled, error +messages are printed on the standard error output. +.Sh SEE ALSO +.Xr rand 3 +.Sh HISTORY +These +functions appeared in +.Bx 4.2 . +.Sh BUGS +About 2/3 the speed of +.Xr rand 3 . diff --git a/src/lib/libc/stdlib/random.c b/src/lib/libc/stdlib/random.c new file mode 100644 index 00000000..469b6d97 --- /dev/null +++ b/src/lib/libc/stdlib/random.c @@ -0,0 +1,364 @@ +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)random.c 5.9 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: random.c,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdio.h> +#include <stdlib.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. + */ +void +srandom(x) + u_int 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++) + (void)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) + u_int 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_0) { + (void)fprintf(stderr, + "random: not enough state (%d bytes); ignored.\n", n); + return(0); + } + if (n < BREAK_1) { + 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: + (void)fprintf(stderr, + "random: state info corrupted; 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 the 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); +} diff --git a/src/lib/libc/stdlib/realloc.3 b/src/lib/libc/stdlib/realloc.3 new file mode 100644 index 00000000..66f09b20 --- /dev/null +++ b/src/lib/libc/stdlib/realloc.3 @@ -0,0 +1,100 @@ +.\" Copyright (c) 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)realloc.3 5.1 (Berkeley) 5/2/91 +.\" $Id: realloc.3,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $ +.\" +.Dd May 2, 1991 +.Dt REALLOC 3 +.Os +.Sh NAME +.Nm realloc +.Nd reallocation of memory function +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft void * +.Fn realloc "void *ptr" "size_t size" +.Sh DESCRIPTION +The +.Fn realloc +function changes the size of the object pointed to by +.Fa ptr +to the size specified by +.Fa size . +The contents of the object are unchanged up to the lesser +of the new and old sizes. +If the new size is larger, the value of the newly allocated portion +of the object is indeterminate. +If +.Fa ptr +is a null pointer, the +.Fn realloc +function behaves like the +.Xr malloc 3 +function for the specified size. +Otherwise, if +.Fa ptr +does not match a pointer earlier returned by the +.Xr calloc 3 , +.Xr malloc 3 , +or +.Fn realloc +function, or if the space has been deallocated +by a call to the +.Xr free +or +.Fn realloc +function, unpredictable and usually detrimental +behavior will occur. +If the space cannot be allocated, the object +pointed to by +.Fa ptr +is unchanged. +If +.Fa size +is zero and +.Fa ptr +is not a null pointer, the object it points to is freed. +.Pp +The +.Fn realloc +function returns either a null pointer or a pointer +to the possibly moved allocated space. +.Sh SEE ALSO +.Xr alloca 3 , +.Xr calloc 3 , +.Xr free 3 , +.Xr malloc 3 , +.Sh STANDARDS +The +.Fn realloc +function conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/realpath.3 b/src/lib/libc/stdlib/realpath.3 new file mode 100644 index 00000000..9d8b1ff2 --- /dev/null +++ b/src/lib/libc/stdlib/realpath.3 @@ -0,0 +1,126 @@ +.\" Copyright (c) 1994 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Jan-Simon Pendry. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)realpath.3 8.2 (Berkeley) 2/16/94 +.\" $Id: realpath.3,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $ +.\" +.Dd "February 16, 1994" +.Dt REALPATH 3 +.Os +.Sh NAME +.Nm realpath +.Nd returns the canonicalized absolute pathname +.Sh SYNOPSIS +.Fd #include <sys/param.h> +.Fd #include <stdlib.h> +.Ft "char *" +.Fn realpath "const char *pathname" "char resolvedname[MAXPATHLEN]" +.Sh DESCRIPTION +The +.Fn realpath +function resolves all symbolic links, extra +.Dq / +characters and references to +.Pa /./ +and +.Pa /../ +in +.Fa pathname , +and copies the resulting absolute pathname into +the memory referenced by +.Fa resolvedname . +The +.Fa resolvedname +argument +.Em must +refer to a buffer capable of storing at least +.Dv MAXPATHLEN +characters. +.Pp +The +.Fn realpath +function will resolve both absolute and relative paths +and return the absolute pathname corresponding to +.Fa pathname . +All but the last component of +.Fa pathname +must exist when +.Fn realpath +is called. +.Sh "RETURN VALUES" +The +.Fn realpath +function returns +.Fa resolved_name +on success. +If an error occurs, +.Fn realpath +returns +.Dv NULL , +and +.Fa resolved_name +contains the pathname which caused the problem. +.Sh ERRORS +The function +.Fn realpath +may fail and set the external variable +.Va errno +for any of the errors specified for the library functions +.Xr chdir 2 , +.Xr close 2 , +.Xr fchdir 2 , +.Xr lstat 2 , +.Xr open 2 , +.Xr readlink 2 +and +.Xr getcwd 3 . +.Sh CAVEATS +This implementation of +.Fn realpath +differs slightly from the Solaris implementation. +The +.Bx 4.4 +version always returns absolute pathnames, +whereas the Solaris implementation will, +under certain circumstances, return a relative +.Fa resolved_path +when given a relative +.Fa pathname . +.Sh "SEE ALSO" +.Xr getcwd 3 +.Sh HISTORY +The +.Fn realpath +function call first appeared in +.Bx 4.4 . diff --git a/src/lib/libc/stdlib/realpath.c b/src/lib/libc/stdlib/realpath.c new file mode 100644 index 00000000..e349b7e0 --- /dev/null +++ b/src/lib/libc/stdlib/realpath.c @@ -0,0 +1,159 @@ +/* + * Copyright (c) 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jan-Simon Pendry. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char sccsid[] = "from: @(#)realpath.c 8.1 (Berkeley) 2/16/94";*/ +static char *rcsid = "$Id: realpath.c,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/param.h> +#include <sys/stat.h> + +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +/* + * char *realpath(const char *path, char resolved_path[MAXPATHLEN]); + * + * Find the real name of path, by removing all ".", ".." and symlink + * components. Returns (resolved) on success, or (NULL) on failure, + * in which case the path which caused trouble is left in (resolved). + */ +char * +realpath(path, resolved) + const char *path; + char *resolved; +{ + struct stat sb; + int fd, n, rootd, serrno; + char *p, *q, wbuf[MAXPATHLEN]; + + /* Save the starting point. */ + if ((fd = open(".", O_RDONLY)) < 0) { + (void)strcpy(resolved, "."); + return (NULL); + } + + /* + * Find the dirname and basename from the path to be resolved. + * Change directory to the dirname component. + * lstat the basename part. + * if it is a symlink, read in the value and loop. + * if it is a directory, then change to that directory. + * get the current directory name and append the basename. + */ + (void)strncpy(resolved, path, MAXPATHLEN - 1); + resolved[MAXPATHLEN - 1] = '\0'; +loop: + q = strrchr(resolved, '/'); + if (q != NULL) { + p = q + 1; + if (q == resolved) + q = "/"; + else { + do { + --q; + } while (q > resolved && *q == '/'); + q[1] = '\0'; + q = resolved; + } + if (chdir(q) < 0) + goto err1; + } else + p = resolved; + + /* Deal with the last component. */ + if (lstat(p, &sb) == 0) { + if (S_ISLNK(sb.st_mode)) { + n = readlink(p, resolved, MAXPATHLEN); + if (n < 0) + goto err1; + resolved[n] = '\0'; + goto loop; + } + if (S_ISDIR(sb.st_mode)) { + if (chdir(p) < 0) + goto err1; + p = ""; + } + } + + /* + * Save the last component name and get the full pathname of + * the current directory. + */ + (void)strcpy(wbuf, p); + if (getcwd(resolved, MAXPATHLEN) == 0) + goto err1; + + /* + * Join the two strings together, ensuring that the right thing + * happens if the last component is empty, or the dirname is root. + */ + if (resolved[0] == '/' && resolved[1] == '\0') + rootd = 1; + else + rootd = 0; + + if (*wbuf) { + if (strlen(resolved) + strlen(wbuf) + rootd + 1 > MAXPATHLEN) { + errno = ENAMETOOLONG; + goto err1; + } + if (rootd == 0) + (void)strcat(resolved, "/"); + (void)strcat(resolved, wbuf); + } + + /* Go back to where we came from. */ + if (fchdir(fd) < 0) { + serrno = errno; + goto err2; + } + + /* It's okay if the close fails, what's an fd more or less? */ + (void)close(fd); + return (resolved); + +err1: serrno = errno; + (void)fchdir(fd); +err2: (void)close(fd); + errno = serrno; + return (NULL); +} diff --git a/src/lib/libc/stdlib/seed48.c b/src/lib/libc/stdlib/seed48.c new file mode 100644 index 00000000..e3d31901 --- /dev/null +++ b/src/lib/libc/stdlib/seed48.c @@ -0,0 +1,36 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +extern unsigned short __rand48_seed[3]; +extern unsigned short __rand48_mult[3]; +extern unsigned short __rand48_add; + +unsigned short * +seed48(unsigned short xseed[3]) +{ + static unsigned short sseed[3]; + + sseed[0] = __rand48_seed[0]; + sseed[1] = __rand48_seed[1]; + sseed[2] = __rand48_seed[2]; + __rand48_seed[0] = xseed[0]; + __rand48_seed[1] = xseed[1]; + __rand48_seed[2] = xseed[2]; + __rand48_mult[0] = RAND48_MULT_0; + __rand48_mult[1] = RAND48_MULT_1; + __rand48_mult[2] = RAND48_MULT_2; + __rand48_add = RAND48_ADD; + return sseed; +} diff --git a/src/lib/libc/stdlib/setenv.c b/src/lib/libc/stdlib/setenv.c new file mode 100644 index 00000000..a3666988 --- /dev/null +++ b/src/lib/libc/stdlib/setenv.c @@ -0,0 +1,120 @@ +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)setenv.c 5.6 (Berkeley) 6/4/91";*/ +static char *rcsid = "$Id: setenv.c,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> +#include <string.h> + +/* + * setenv -- + * Set the value of the environmental variable "name" to be + * "value". If rewrite is set, replace any current value. + */ +int +setenv(name, value, rewrite) + register const char *name; + register const char *value; + int rewrite; +{ + extern char **environ; + static int alloced; /* if allocated space before */ + register char *C; + int l_value, offset; + char *__findenv(); + + if (*value == '=') /* no `=' in value */ + ++value; + l_value = strlen(value); + if ((C = __findenv(name, &offset))) { /* find if already exists */ + if (!rewrite) + return (0); + if (strlen(C) >= l_value) { /* old larger; copy over */ + while (*C++ = *value++); + return (0); + } + } else { /* create new slot */ + register int cnt; + register char **P; + + for (P = environ, cnt = 0; *P; ++P, ++cnt); + if (alloced) { /* just increase size */ + environ = (char **)realloc((char *)environ, + (size_t)(sizeof(char *) * (cnt + 2))); + if (!environ) + return (-1); + } + else { /* get new space */ + alloced = 1; /* copy old entries into it */ + P = (char **)malloc((size_t)(sizeof(char *) * + (cnt + 2))); + if (!P) + return (-1); + bcopy(environ, P, cnt * sizeof(char *)); + environ = P; + } + environ[cnt + 1] = NULL; + offset = cnt; + } + for (C = (char *)name; *C && *C != '='; ++C); /* no `=' in name */ + if (!(environ[offset] = /* name + `=' + value */ + malloc((size_t)((int)(C - name) + l_value + 2)))) + return (-1); + for (C = environ[offset]; (*C = *name++) && *C != '='; ++C) + ; + for (*C++ = '='; *C++ = *value++; ) + ; + return (0); +} + +/* + * unsetenv(name) -- + * Delete environmental variable "name". + */ +void +unsetenv(name) + const char *name; +{ + extern char **environ; + register char **P; + int offset; + char *__findenv(); + + while (__findenv(name, &offset)) /* if set multiple times */ + for (P = &environ[offset];; ++P) + if (!(*P = *(P + 1))) + break; +} diff --git a/src/lib/libc/stdlib/srand48.c b/src/lib/libc/stdlib/srand48.c new file mode 100644 index 00000000..daf733f9 --- /dev/null +++ b/src/lib/libc/stdlib/srand48.c @@ -0,0 +1,30 @@ +/* + * Copyright (c) 1993 Martin Birgmeier + * All rights reserved. + * + * You may redistribute unmodified or modified versions of this source + * code provided that the above copyright notice and this and the + * following conditions are retained. + * + * This software is provided ``as is'', and comes with no warranties + * of any kind. I shall in no event be liable for anything that happens + * to anyone/anything when using this software. + */ + +#include "rand48.h" + +extern unsigned short __rand48_seed[3]; +extern unsigned short __rand48_mult[3]; +extern unsigned short __rand48_add; + +void +srand48(long seed) +{ + __rand48_seed[0] = RAND48_SEED_0; + __rand48_seed[1] = (unsigned short) seed; + __rand48_seed[2] = (unsigned short) (seed >> 16); + __rand48_mult[0] = RAND48_MULT_0; + __rand48_mult[1] = RAND48_MULT_1; + __rand48_mult[2] = RAND48_MULT_2; + __rand48_add = RAND48_ADD; +} diff --git a/src/lib/libc/stdlib/strtod.3 b/src/lib/libc/stdlib/strtod.3 new file mode 100644 index 00000000..0b7f9738 --- /dev/null +++ b/src/lib/libc/stdlib/strtod.3 @@ -0,0 +1,114 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strtod.3 5.3 (Berkeley) 6/29/91 +.\" $Id: strtod.3,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRTOD 3 +.Os +.Sh NAME +.Nm strtod +.Nd convert +.Tn ASCII +string to double +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft double +.Fn strtod "const char *nptr" "char **endptr" +.Sh DESCRIPTION +The +.Fn strtod +function converts the initial portion of the string +pointed to by +.Fa nptr +to +.Em double +representation. +.Pp +The expected form of the string is an optional plus (``+'') or minus +sign (``-'') followed by a sequence of digits optionally containing +a decimal-point character, optionally followed by an exponent. +An exponent consists of an ``E'' or ``e'', followed by an optional plus +or minus sign, followed by a sequence of digits. +.Pp +Leading white-space characters in the string (as defined by the +.Xr isspace 3 +function) are skipped. +.Sh RETURN VALUES +The +.Fn strtod +function returns the converted value, if any. +.Pp +If +.Fa endptr +is not +.Dv NULL , +a pointer to the character after the last character used +in the conversion is stored in the location referenced by +.Fa endptr . +.Pp +If no conversion is performed, zero is returned and the value of +.Fa nptr +is stored in the location referenced by +.Fa endptr . +.Pp +If the correct value would cause overflow, plus or minus +.Dv HUGE_VAL +is returned (according to the sign of the value), and +.Dv ERANGE +is stored in +.Va errno . +If the correct value would cause underflow, zero is +returned and +.Dv ERANGE +is stored in +.Va errno . +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er ERANGE +Overflow or underflow occurred. +.Sh SEE ALSO +.Xr atof 3 , +.Xr atoi 3 , +.Xr atol 3 , +.Xr strtol 3 , +.Xr strtoul 3 +.Sh STANDARDS +The +.Fn strtod +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/stdlib/strtod.c b/src/lib/libc/stdlib/strtod.c new file mode 100644 index 00000000..b13fa128 --- /dev/null +++ b/src/lib/libc/stdlib/strtod.c @@ -0,0 +1,2499 @@ +/**************************************************************** + * + * The author of this software is David M. Gay. + * + * Copyright (c) 1991 by AT&T. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose without fee is hereby granted, provided that this entire notice + * is included in all copies of any software which is or includes a copy + * or modification of this software and in all copies of the supporting + * documentation for such software. + * + * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED + * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR AT&T MAKES ANY + * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY + * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. + * + ***************************************************************/ + +/* Please send bug reports to + David M. Gay + AT&T Bell Laboratories, Room 2C-463 + 600 Mountain Avenue + Murray Hill, NJ 07974-2070 + U.S.A. + dmg@research.att.com or research!dmg + */ + +/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. + * + * This strtod returns a nearest machine number to the input decimal + * string (or sets errno to ERANGE). With IEEE arithmetic, ties are + * broken by the IEEE round-even rule. Otherwise ties are broken by + * biased rounding (add half and chop). + * + * Inspired loosely by William D. Clinger's paper "How to Read Floating + * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. + * + * Modifications: + * + * 1. We only require IEEE, IBM, or VAX double-precision + * arithmetic (not IEEE double-extended). + * 2. We get by with floating-point arithmetic in a case that + * Clinger missed -- when we're computing d * 10^n + * for a small integer d and the integer n is not too + * much larger than 22 (the maximum integer k for which + * we can represent 10^k exactly), we may be able to + * compute (d*10^k) * 10^(e-k) with just one roundoff. + * 3. Rather than a bit-at-a-time adjustment of the binary + * result in the hard case, we use floating-point + * arithmetic to determine the adjustment to within + * one bit; only in really hard cases do we need to + * compute a second residual. + * 4. Because of 3., we don't need a large table of powers of 10 + * for ten-to-e (just some small tables, e.g. of 10^k + * for 0 <= k <= 22). + */ + +/* + * #define IEEE_LITTLE_ENDIAN for IEEE-arithmetic machines where the least + * significant byte has the lowest address. + * #define IEEE_BIG_ENDIAN for IEEE-arithmetic machines where the most + * significant byte has the lowest address. + * #define Long int on machines with 32-bit ints and 64-bit longs. + * #define Sudden_Underflow for IEEE-format machines without gradual + * underflow (i.e., that flush to zero on underflow). + * #define IBM for IBM mainframe-style floating-point arithmetic. + * #define VAX for VAX-style floating-point arithmetic. + * #define Unsigned_Shifts if >> does treats its left operand as unsigned. + * #define No_leftright to omit left-right logic in fast floating-point + * computation of dtoa. + * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3. + * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines + * that use extended-precision instructions to compute rounded + * products and quotients) with IBM. + * #define ROUND_BIASED for IEEE-format with biased rounding. + * #define Inaccurate_Divide for IEEE-format with correctly rounded + * products but inaccurate quotients, e.g., for Intel i860. + * #define Just_16 to store 16 bits per 32-bit Long when doing high-precision + * integer arithmetic. Whether this speeds things up or slows things + * down depends on the machine and the number being converted. + * #define KR_headers for old-style C function headers. + * #define Bad_float_h if your system lacks a float.h or if it does not + * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, + * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. + * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) + * if memory is available and otherwise does something you deem + * appropriate. If MALLOC is undefined, malloc will be invoked + * directly -- and assumed always to succeed. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$Id: strtod.c,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#if defined(__m68k__) || defined(__sparc__) || defined(__i386__) || \ + defined(__mips__) || defined(__ns32k__) || defined(__alpha__) +#include <machine/endian.h> +#if BYTE_ORDER == BIG_ENDIAN +#define IEEE_BIG_ENDIAN +#else +#define IEEE_LITTLE_ENDIAN +#endif +#endif + +#ifdef vax +#define VAX +#endif + +#define Long int32_t +#define ULong u_int32_t + +#ifdef DEBUG +#include "stdio.h" +#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} +#endif + +#ifdef __cplusplus +#include "malloc.h" +#include "memory.h" +#else +#ifndef KR_headers +#include "stdlib.h" +#include "string.h" +#include "locale.h" +#else +#include "malloc.h" +#include "memory.h" +#endif +#endif + +#ifdef MALLOC +#ifdef KR_headers +extern char *MALLOC(); +#else +extern void *MALLOC(size_t); +#endif +#else +#define MALLOC malloc +#endif + +#include "ctype.h" +#include "errno.h" + +#ifdef Bad_float_h +#undef __STDC__ +#ifdef IEEE_BIG_ENDIAN +#define IEEE_ARITHMETIC +#endif +#ifdef IEEE_LITTLE_ENDIAN +#define IEEE_ARITHMETIC +#endif + +#ifdef IEEE_ARITHMETIC +#define DBL_DIG 15 +#define DBL_MAX_10_EXP 308 +#define DBL_MAX_EXP 1024 +#define FLT_RADIX 2 +#define FLT_ROUNDS 1 +#define DBL_MAX 1.7976931348623157e+308 +#endif + +#ifdef IBM +#define DBL_DIG 16 +#define DBL_MAX_10_EXP 75 +#define DBL_MAX_EXP 63 +#define FLT_RADIX 16 +#define FLT_ROUNDS 0 +#define DBL_MAX 7.2370055773322621e+75 +#endif + +#ifdef VAX +#define DBL_DIG 16 +#define DBL_MAX_10_EXP 38 +#define DBL_MAX_EXP 127 +#define FLT_RADIX 2 +#define FLT_ROUNDS 1 +#define DBL_MAX 1.7014118346046923e+38 +#endif + +#ifndef LONG_MAX +#define LONG_MAX 2147483647 +#endif +#else +#include "float.h" +#endif +#ifndef __MATH_H__ +#include "math.h" +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef CONST +#ifdef KR_headers +#define CONST /* blank */ +#else +#define CONST const +#endif +#endif + +#ifdef Unsigned_Shifts +#define Sign_Extend(a,b) if (b < 0) a |= 0xffff0000; +#else +#define Sign_Extend(a,b) /*no-op*/ +#endif + +#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + \ + defined(IBM) != 1 +Exactly one of IEEE_LITTLE_ENDIAN IEEE_BIG_ENDIAN, VAX, or +IBM should be defined. +#endif + +#ifdef IEEE_LITTLE_ENDIAN +#define word0(x) ((ULong *)&x)[1] +#define word1(x) ((ULong *)&x)[0] +#else +#define word0(x) ((ULong *)&x)[0] +#define word1(x) ((ULong *)&x)[1] +#endif + +/* The following definition of Storeinc is appropriate for MIPS processors. + * An alternative that might be better on some machines is + * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) + */ +#if defined(IEEE_LITTLE_ENDIAN) + defined(VAX) +#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \ +((unsigned short *)a)[0] = (unsigned short)c, a++) +#else +#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \ +((unsigned short *)a)[1] = (unsigned short)c, a++) +#endif + +/* #define P DBL_MANT_DIG */ +/* Ten_pmax = floor(P*log(2)/log(5)) */ +/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ +/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ +/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ + +#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) +#define Exp_shift 20 +#define Exp_shift1 20 +#define Exp_msk1 0x100000 +#define Exp_msk11 0x100000 +#define Exp_mask 0x7ff00000 +#define P 53 +#define Bias 1023 +#define IEEE_Arith +#define Emin (-1022) +#define Exp_1 0x3ff00000 +#define Exp_11 0x3ff00000 +#define Ebits 11 +#define Frac_mask 0xfffff +#define Frac_mask1 0xfffff +#define Ten_pmax 22 +#define Bletch 0x10 +#define Bndry_mask 0xfffff +#define Bndry_mask1 0xfffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 1 +#define Tiny0 0 +#define Tiny1 1 +#define Quick_max 14 +#define Int_max 14 +#define Infinite(x) (word0(x) == 0x7ff00000) /* sufficient test for here */ +#else +#undef Sudden_Underflow +#define Sudden_Underflow +#ifdef IBM +#define Exp_shift 24 +#define Exp_shift1 24 +#define Exp_msk1 0x1000000 +#define Exp_msk11 0x1000000 +#define Exp_mask 0x7f000000 +#define P 14 +#define Bias 65 +#define Exp_1 0x41000000 +#define Exp_11 0x41000000 +#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ +#define Frac_mask 0xffffff +#define Frac_mask1 0xffffff +#define Bletch 4 +#define Ten_pmax 22 +#define Bndry_mask 0xefffff +#define Bndry_mask1 0xffffff +#define LSB 1 +#define Sign_bit 0x80000000 +#define Log2P 4 +#define Tiny0 0x100000 +#define Tiny1 0 +#define Quick_max 14 +#define Int_max 15 +#else /* VAX */ +#define Exp_shift 23 +#define Exp_shift1 7 +#define Exp_msk1 0x80 +#define Exp_msk11 0x800000 +#define Exp_mask 0x7f80 +#define P 56 +#define Bias 129 +#define Exp_1 0x40800000 +#define Exp_11 0x4080 +#define Ebits 8 +#define Frac_mask 0x7fffff +#define Frac_mask1 0xffff007f +#define Ten_pmax 24 +#define Bletch 2 +#define Bndry_mask 0xffff007f +#define Bndry_mask1 0xffff007f +#define LSB 0x10000 +#define Sign_bit 0x8000 +#define Log2P 1 +#define Tiny0 0x80 +#define Tiny1 0 +#define Quick_max 15 +#define Int_max 15 +#endif +#endif + +#ifndef IEEE_Arith +#define ROUND_BIASED +#endif + +#ifdef RND_PRODQUOT +#define rounded_product(a,b) a = rnd_prod(a, b) +#define rounded_quotient(a,b) a = rnd_quot(a, b) +#ifdef KR_headers +extern double rnd_prod(), rnd_quot(); +#else +extern double rnd_prod(double, double), rnd_quot(double, double); +#endif +#else +#define rounded_product(a,b) a *= b +#define rounded_quotient(a,b) a /= b +#endif + +#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) +#define Big1 0xffffffff + +#ifndef Just_16 +/* When Pack_32 is not defined, we store 16 bits per 32-bit Long. + * This makes some inner loops simpler and sometimes saves work + * during multiplications, but it often seems to make things slightly + * slower. Hence the default is now to store 32 bits per Long. + */ +#ifndef Pack_32 +#define Pack_32 +#endif +#endif + +#define Kmax 15 + +#ifdef __cplusplus +extern "C" double strtod(const char *s00, char **se); +extern "C" char *__dtoa(double d, int mode, int ndigits, + int *decpt, int *sign, char **rve); +#endif + + struct +Bigint { + struct Bigint *next; + int k, maxwds, sign, wds; + ULong x[1]; + }; + + typedef struct Bigint Bigint; + + static Bigint *freelist[Kmax+1]; + + static Bigint * +Balloc +#ifdef KR_headers + (k) int k; +#else + (int k) +#endif +{ + int x; + Bigint *rv; + + if (rv = freelist[k]) { + freelist[k] = rv->next; + } + else { + x = 1 << k; + rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long)); + rv->k = k; + rv->maxwds = x; + } + rv->sign = rv->wds = 0; + return rv; + } + + static void +Bfree +#ifdef KR_headers + (v) Bigint *v; +#else + (Bigint *v) +#endif +{ + if (v) { + v->next = freelist[v->k]; + freelist[v->k] = v; + } + } + +#define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \ +y->wds*sizeof(Long) + 2*sizeof(int)) + + static Bigint * +multadd +#ifdef KR_headers + (b, m, a) Bigint *b; int m, a; +#else + (Bigint *b, int m, int a) /* multiply by m and add a */ +#endif +{ + int i, wds; + ULong *x, y; +#ifdef Pack_32 + ULong xi, z; +#endif + Bigint *b1; + + wds = b->wds; + x = b->x; + i = 0; + do { +#ifdef Pack_32 + xi = *x; + y = (xi & 0xffff) * m + a; + z = (xi >> 16) * m + (y >> 16); + a = (int)(z >> 16); + *x++ = (z << 16) + (y & 0xffff); +#else + y = *x * m + a; + a = (int)(y >> 16); + *x++ = y & 0xffff; +#endif + } + while(++i < wds); + if (a) { + if (wds >= b->maxwds) { + b1 = Balloc(b->k+1); + Bcopy(b1, b); + Bfree(b); + b = b1; + } + b->x[wds++] = a; + b->wds = wds; + } + return b; + } + + static Bigint * +s2b +#ifdef KR_headers + (s, nd0, nd, y9) CONST char *s; int nd0, nd; ULong y9; +#else + (CONST char *s, int nd0, int nd, ULong y9) +#endif +{ + Bigint *b; + int i, k; + Long x, y; + + x = (nd + 8) / 9; + for(k = 0, y = 1; x > y; y <<= 1, k++) ; +#ifdef Pack_32 + b = Balloc(k); + b->x[0] = y9; + b->wds = 1; +#else + b = Balloc(k+1); + b->x[0] = y9 & 0xffff; + b->wds = (b->x[1] = y9 >> 16) ? 2 : 1; +#endif + + i = 9; + if (9 < nd0) { + s += 9; + do b = multadd(b, 10, *s++ - '0'); + while(++i < nd0); + s++; + } + else + s += 10; + for(; i < nd; i++) + b = multadd(b, 10, *s++ - '0'); + return b; + } + + static int +hi0bits +#ifdef KR_headers + (x) register ULong x; +#else + (register ULong x) +#endif +{ + register int k = 0; + + if (!(x & 0xffff0000)) { + k = 16; + x <<= 16; + } + if (!(x & 0xff000000)) { + k += 8; + x <<= 8; + } + if (!(x & 0xf0000000)) { + k += 4; + x <<= 4; + } + if (!(x & 0xc0000000)) { + k += 2; + x <<= 2; + } + if (!(x & 0x80000000)) { + k++; + if (!(x & 0x40000000)) + return 32; + } + return k; + } + + static int +lo0bits +#ifdef KR_headers + (y) ULong *y; +#else + (ULong *y) +#endif +{ + register int k; + register ULong x = *y; + + if (x & 7) { + if (x & 1) + return 0; + if (x & 2) { + *y = x >> 1; + return 1; + } + *y = x >> 2; + return 2; + } + k = 0; + if (!(x & 0xffff)) { + k = 16; + x >>= 16; + } + if (!(x & 0xff)) { + k += 8; + x >>= 8; + } + if (!(x & 0xf)) { + k += 4; + x >>= 4; + } + if (!(x & 0x3)) { + k += 2; + x >>= 2; + } + if (!(x & 1)) { + k++; + x >>= 1; + if (!x & 1) + return 32; + } + *y = x; + return k; + } + + static Bigint * +i2b +#ifdef KR_headers + (i) int i; +#else + (int i) +#endif +{ + Bigint *b; + + b = Balloc(1); + b->x[0] = i; + b->wds = 1; + return b; + } + + static Bigint * +mult +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + Bigint *c; + int k, wa, wb, wc; + ULong carry, y, z; + ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0; +#ifdef Pack_32 + ULong z2; +#endif + + if (a->wds < b->wds) { + c = a; + a = b; + b = c; + } + k = a->k; + wa = a->wds; + wb = b->wds; + wc = wa + wb; + if (wc > a->maxwds) + k++; + c = Balloc(k); + for(x = c->x, xa = x + wc; x < xa; x++) + *x = 0; + xa = a->x; + xae = xa + wa; + xb = b->x; + xbe = xb + wb; + xc0 = c->x; +#ifdef Pack_32 + for(; xb < xbe; xb++, xc0++) { + if (y = *xb & 0xffff) { + x = xa; + xc = xc0; + carry = 0; + do { + z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; + carry = z >> 16; + z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; + carry = z2 >> 16; + Storeinc(xc, z2, z); + } + while(x < xae); + *xc = carry; + } + if (y = *xb >> 16) { + x = xa; + xc = xc0; + carry = 0; + z2 = *xc; + do { + z = (*x & 0xffff) * y + (*xc >> 16) + carry; + carry = z >> 16; + Storeinc(xc, z, z2); + z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; + carry = z2 >> 16; + } + while(x < xae); + *xc = z2; + } + } +#else + for(; xb < xbe; xc0++) { + if (y = *xb++) { + x = xa; + xc = xc0; + carry = 0; + do { + z = *x++ * y + *xc + carry; + carry = z >> 16; + *xc++ = z & 0xffff; + } + while(x < xae); + *xc = carry; + } + } +#endif + for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; + c->wds = wc; + return c; + } + + static Bigint *p5s; + + static Bigint * +pow5mult +#ifdef KR_headers + (b, k) Bigint *b; int k; +#else + (Bigint *b, int k) +#endif +{ + Bigint *b1, *p5, *p51; + int i; + static int p05[3] = { 5, 25, 125 }; + + if (i = k & 3) + b = multadd(b, p05[i-1], 0); + + if (!(k >>= 2)) + return b; + if (!(p5 = p5s)) { + /* first time */ + p5 = p5s = i2b(625); + p5->next = 0; + } + for(;;) { + if (k & 1) { + b1 = mult(b, p5); + Bfree(b); + b = b1; + } + if (!(k >>= 1)) + break; + if (!(p51 = p5->next)) { + p51 = p5->next = mult(p5,p5); + p51->next = 0; + } + p5 = p51; + } + return b; + } + + static Bigint * +lshift +#ifdef KR_headers + (b, k) Bigint *b; int k; +#else + (Bigint *b, int k) +#endif +{ + int i, k1, n, n1; + Bigint *b1; + ULong *x, *x1, *xe, z; + +#ifdef Pack_32 + n = k >> 5; +#else + n = k >> 4; +#endif + k1 = b->k; + n1 = n + b->wds + 1; + for(i = b->maxwds; n1 > i; i <<= 1) + k1++; + b1 = Balloc(k1); + x1 = b1->x; + for(i = 0; i < n; i++) + *x1++ = 0; + x = b->x; + xe = x + b->wds; +#ifdef Pack_32 + if (k &= 0x1f) { + k1 = 32 - k; + z = 0; + do { + *x1++ = *x << k | z; + z = *x++ >> k1; + } + while(x < xe); + if (*x1 = z) + ++n1; + } +#else + if (k &= 0xf) { + k1 = 16 - k; + z = 0; + do { + *x1++ = *x << k & 0xffff | z; + z = *x++ >> k1; + } + while(x < xe); + if (*x1 = z) + ++n1; + } +#endif + else do + *x1++ = *x++; + while(x < xe); + b1->wds = n1 - 1; + Bfree(b); + return b1; + } + + static int +cmp +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + ULong *xa, *xa0, *xb, *xb0; + int i, j; + + i = a->wds; + j = b->wds; +#ifdef DEBUG + if (i > 1 && !a->x[i-1]) + Bug("cmp called with a->x[a->wds-1] == 0"); + if (j > 1 && !b->x[j-1]) + Bug("cmp called with b->x[b->wds-1] == 0"); +#endif + if (i -= j) + return i; + xa0 = a->x; + xa = xa0 + j; + xb0 = b->x; + xb = xb0 + j; + for(;;) { + if (*--xa != *--xb) + return *xa < *xb ? -1 : 1; + if (xa <= xa0) + break; + } + return 0; + } + + static Bigint * +diff +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + Bigint *c; + int i, wa, wb; + Long borrow, y; /* We need signed shifts here. */ + ULong *xa, *xae, *xb, *xbe, *xc; +#ifdef Pack_32 + Long z; +#endif + + i = cmp(a,b); + if (!i) { + c = Balloc(0); + c->wds = 1; + c->x[0] = 0; + return c; + } + if (i < 0) { + c = a; + a = b; + b = c; + i = 1; + } + else + i = 0; + c = Balloc(a->k); + c->sign = i; + wa = a->wds; + xa = a->x; + xae = xa + wa; + wb = b->wds; + xb = b->x; + xbe = xb + wb; + xc = c->x; + borrow = 0; +#ifdef Pack_32 + do { + y = (*xa & 0xffff) - (*xb & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + z = (*xa++ >> 16) - (*xb++ >> 16) + borrow; + borrow = z >> 16; + Sign_Extend(borrow, z); + Storeinc(xc, z, y); + } + while(xb < xbe); + while(xa < xae) { + y = (*xa & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + z = (*xa++ >> 16) + borrow; + borrow = z >> 16; + Sign_Extend(borrow, z); + Storeinc(xc, z, y); + } +#else + do { + y = *xa++ - *xb++ + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + *xc++ = y & 0xffff; + } + while(xb < xbe); + while(xa < xae) { + y = *xa++ + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + *xc++ = y & 0xffff; + } +#endif + while(!*--xc) + wa--; + c->wds = wa; + return c; + } + + static double +ulp +#ifdef KR_headers + (x) double x; +#else + (double x) +#endif +{ + register Long L; + double a; + + L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; +#ifndef Sudden_Underflow + if (L > 0) { +#endif +#ifdef IBM + L |= Exp_msk1 >> 4; +#endif + word0(a) = L; + word1(a) = 0; +#ifndef Sudden_Underflow + } + else { + L = -L >> Exp_shift; + if (L < Exp_shift) { + word0(a) = 0x80000 >> L; + word1(a) = 0; + } + else { + word0(a) = 0; + L -= Exp_shift; + word1(a) = L >= 31 ? 1 : 1 << 31 - L; + } + } +#endif + return a; + } + + static double +b2d +#ifdef KR_headers + (a, e) Bigint *a; int *e; +#else + (Bigint *a, int *e) +#endif +{ + ULong *xa, *xa0, w, y, z; + int k; + double d; +#ifdef VAX + ULong d0, d1; +#else +#define d0 word0(d) +#define d1 word1(d) +#endif + + xa0 = a->x; + xa = xa0 + a->wds; + y = *--xa; +#ifdef DEBUG + if (!y) Bug("zero y in b2d"); +#endif + k = hi0bits(y); + *e = 32 - k; +#ifdef Pack_32 + if (k < Ebits) { + d0 = Exp_1 | y >> Ebits - k; + w = xa > xa0 ? *--xa : 0; + d1 = y << (32-Ebits) + k | w >> Ebits - k; + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + if (k -= Ebits) { + d0 = Exp_1 | y << k | z >> 32 - k; + y = xa > xa0 ? *--xa : 0; + d1 = z << k | y >> 32 - k; + } + else { + d0 = Exp_1 | y; + d1 = z; + } +#else + if (k < Ebits + 16) { + z = xa > xa0 ? *--xa : 0; + d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k; + w = xa > xa0 ? *--xa : 0; + y = xa > xa0 ? *--xa : 0; + d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k; + goto ret_d; + } + z = xa > xa0 ? *--xa : 0; + w = xa > xa0 ? *--xa : 0; + k -= Ebits + 16; + d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k; + y = xa > xa0 ? *--xa : 0; + d1 = w << k + 16 | y << k; +#endif + ret_d: +#ifdef VAX + word0(d) = d0 >> 16 | d0 << 16; + word1(d) = d1 >> 16 | d1 << 16; +#else +#undef d0 +#undef d1 +#endif + return d; + } + + static Bigint * +d2b +#ifdef KR_headers + (d, e, bits) double d; int *e, *bits; +#else + (double d, int *e, int *bits) +#endif +{ + Bigint *b; + int de, i, k; + ULong *x, y, z; +#ifdef VAX + ULong d0, d1; + d0 = word0(d) >> 16 | word0(d) << 16; + d1 = word1(d) >> 16 | word1(d) << 16; +#else +#define d0 word0(d) +#define d1 word1(d) +#endif + +#ifdef Pack_32 + b = Balloc(1); +#else + b = Balloc(2); +#endif + x = b->x; + + z = d0 & Frac_mask; + d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ +#ifdef Sudden_Underflow + de = (int)(d0 >> Exp_shift); +#ifndef IBM + z |= Exp_msk11; +#endif +#else + if (de = (int)(d0 >> Exp_shift)) + z |= Exp_msk1; +#endif +#ifdef Pack_32 + if (y = d1) { + if (k = lo0bits(&y)) { + x[0] = y | z << 32 - k; + z >>= k; + } + else + x[0] = y; + i = b->wds = (x[1] = z) ? 2 : 1; + } + else { +#ifdef DEBUG + if (!z) + Bug("Zero passed to d2b"); +#endif + k = lo0bits(&z); + x[0] = z; + i = b->wds = 1; + k += 32; + } +#else + if (y = d1) { + if (k = lo0bits(&y)) + if (k >= 16) { + x[0] = y | z << 32 - k & 0xffff; + x[1] = z >> k - 16 & 0xffff; + x[2] = z >> k; + i = 2; + } + else { + x[0] = y & 0xffff; + x[1] = y >> 16 | z << 16 - k & 0xffff; + x[2] = z >> k & 0xffff; + x[3] = z >> k+16; + i = 3; + } + else { + x[0] = y & 0xffff; + x[1] = y >> 16; + x[2] = z & 0xffff; + x[3] = z >> 16; + i = 3; + } + } + else { +#ifdef DEBUG + if (!z) + Bug("Zero passed to d2b"); +#endif + k = lo0bits(&z); + if (k >= 16) { + x[0] = z; + i = 0; + } + else { + x[0] = z & 0xffff; + x[1] = z >> 16; + i = 1; + } + k += 32; + } + while(!x[i]) + --i; + b->wds = i + 1; +#endif +#ifndef Sudden_Underflow + if (de) { +#endif +#ifdef IBM + *e = (de - Bias - (P-1) << 2) + k; + *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask); +#else + *e = de - Bias - (P-1) + k; + *bits = P - k; +#endif +#ifndef Sudden_Underflow + } + else { + *e = de - Bias - (P-1) + 1 + k; +#ifdef Pack_32 + *bits = 32*i - hi0bits(x[i-1]); +#else + *bits = (i+2)*16 - hi0bits(x[i]); +#endif + } +#endif + return b; + } +#undef d0 +#undef d1 + + static double +ratio +#ifdef KR_headers + (a, b) Bigint *a, *b; +#else + (Bigint *a, Bigint *b) +#endif +{ + double da, db; + int k, ka, kb; + + da = b2d(a, &ka); + db = b2d(b, &kb); +#ifdef Pack_32 + k = ka - kb + 32*(a->wds - b->wds); +#else + k = ka - kb + 16*(a->wds - b->wds); +#endif +#ifdef IBM + if (k > 0) { + word0(da) += (k >> 2)*Exp_msk1; + if (k &= 3) + da *= 1 << k; + } + else { + k = -k; + word0(db) += (k >> 2)*Exp_msk1; + if (k &= 3) + db *= 1 << k; + } +#else + if (k > 0) + word0(da) += k*Exp_msk1; + else { + k = -k; + word0(db) += k*Exp_msk1; + } +#endif + return da / db; + } + +static CONST double +tens[] = { + 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, + 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, + 1e20, 1e21, 1e22 +#ifdef VAX + , 1e23, 1e24 +#endif + }; + +#ifdef IEEE_Arith +static CONST double bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; +static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, 1e-256 }; +#define n_bigtens 5 +#else +#ifdef IBM +static CONST double bigtens[] = { 1e16, 1e32, 1e64 }; +static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 }; +#define n_bigtens 3 +#else +static CONST double bigtens[] = { 1e16, 1e32 }; +static CONST double tinytens[] = { 1e-16, 1e-32 }; +#define n_bigtens 2 +#endif +#endif + + double +strtod +#ifdef KR_headers + (s00, se) CONST char *s00; char **se; +#else + (CONST char *s00, char **se) +#endif +{ + int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, + e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; + CONST char *s, *s0, *s1; + double aadj, aadj1, adj, rv, rv0; + Long L; + ULong y, z; + Bigint *bb, *bb1, *bd, *bd0, *bs, *delta; + +#ifndef KR_headers + CONST char decimal_point = localeconv()->decimal_point[0]; +#else + CONST char decimal_point = '.'; +#endif + + sign = nz0 = nz = 0; + rv = 0.; + + + for(s = s00; isspace(*s); s++) + ; + + if (*s == '-') { + sign = 1; + s++; + } else if (*s == '+') { + s++; + } + + if (*s == '\0') { + s = s00; + goto ret; + } + + if (*s == '0') { + nz0 = 1; + while(*++s == '0') ; + if (!*s) + goto ret; + } + s0 = s; + y = z = 0; + for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) + if (nd < 9) + y = 10*y + c - '0'; + else if (nd < 16) + z = 10*z + c - '0'; + nd0 = nd; + if (c == decimal_point) { + c = *++s; + if (!nd) { + for(; c == '0'; c = *++s) + nz++; + if (c > '0' && c <= '9') { + s0 = s; + nf += nz; + nz = 0; + goto have_dig; + } + goto dig_done; + } + for(; c >= '0' && c <= '9'; c = *++s) { + have_dig: + nz++; + if (c -= '0') { + nf += nz; + for(i = 1; i < nz; i++) + if (nd++ < 9) + y *= 10; + else if (nd <= DBL_DIG + 1) + z *= 10; + if (nd++ < 9) + y = 10*y + c; + else if (nd <= DBL_DIG + 1) + z = 10*z + c; + nz = 0; + } + } + } + dig_done: + e = 0; + if (c == 'e' || c == 'E') { + if (!nd && !nz && !nz0) { + s = s00; + goto ret; + } + s00 = s; + esign = 0; + switch(c = *++s) { + case '-': + esign = 1; + case '+': + c = *++s; + } + if (c >= '0' && c <= '9') { + while(c == '0') + c = *++s; + if (c > '0' && c <= '9') { + L = c - '0'; + s1 = s; + while((c = *++s) >= '0' && c <= '9') + L = 10*L + c - '0'; + if (s - s1 > 8 || L > 19999) + /* Avoid confusion from exponents + * so large that e might overflow. + */ + e = 19999; /* safe for 16 bit ints */ + else + e = (int)L; + if (esign) + e = -e; + } + else + e = 0; + } + else + s = s00; + } + if (!nd) { + if (!nz && !nz0) + s = s00; + goto ret; + } + e1 = e -= nf; + + /* Now we have nd0 digits, starting at s0, followed by a + * decimal point, followed by nd-nd0 digits. The number we're + * after is the integer represented by those digits times + * 10**e */ + + if (!nd0) + nd0 = nd; + k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; + rv = y; + if (k > 9) + rv = tens[k - 9] * rv + z; + bd0 = 0; + if (nd <= DBL_DIG +#ifndef RND_PRODQUOT + && FLT_ROUNDS == 1 +#endif + ) { + if (!e) + goto ret; + if (e > 0) { + if (e <= Ten_pmax) { +#ifdef VAX + goto vax_ovfl_check; +#else + /* rv = */ rounded_product(rv, tens[e]); + goto ret; +#endif + } + i = DBL_DIG - nd; + if (e <= Ten_pmax + i) { + /* A fancier test would sometimes let us do + * this for larger i values. + */ + e -= i; + rv *= tens[i]; +#ifdef VAX + /* VAX exponent range is so narrow we must + * worry about overflow here... + */ + vax_ovfl_check: + word0(rv) -= P*Exp_msk1; + /* rv = */ rounded_product(rv, tens[e]); + if ((word0(rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) + goto ovfl; + word0(rv) += P*Exp_msk1; +#else + /* rv = */ rounded_product(rv, tens[e]); +#endif + goto ret; + } + } +#ifndef Inaccurate_Divide + else if (e >= -Ten_pmax) { + /* rv = */ rounded_quotient(rv, tens[-e]); + goto ret; + } +#endif + } + e1 += nd - k; + + /* Get starting approximation = rv * 10**e1 */ + + if (e1 > 0) { + if (i = e1 & 15) + rv *= tens[i]; + if (e1 &= ~15) { + if (e1 > DBL_MAX_10_EXP) { + ovfl: + errno = ERANGE; +#ifdef __STDC__ + rv = HUGE_VAL; +#else + /* Can't trust HUGE_VAL */ +#ifdef IEEE_Arith + word0(rv) = Exp_mask; + word1(rv) = 0; +#else + word0(rv) = Big0; + word1(rv) = Big1; +#endif +#endif + if (bd0) + goto retfree; + goto ret; + } + if (e1 >>= 4) { + for(j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + rv *= bigtens[j]; + /* The last multiplication could overflow. */ + word0(rv) -= P*Exp_msk1; + rv *= bigtens[j]; + if ((z = word0(rv) & Exp_mask) + > Exp_msk1*(DBL_MAX_EXP+Bias-P)) + goto ovfl; + if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { + /* set to largest number */ + /* (Can't trust DBL_MAX) */ + word0(rv) = Big0; + word1(rv) = Big1; + } + else + word0(rv) += P*Exp_msk1; + } + + } + } + else if (e1 < 0) { + e1 = -e1; + if (i = e1 & 15) + rv /= tens[i]; + if (e1 &= ~15) { + e1 >>= 4; + if (e1 >= 1 << n_bigtens) + goto undfl; + for(j = 0; e1 > 1; j++, e1 >>= 1) + if (e1 & 1) + rv *= tinytens[j]; + /* The last multiplication could underflow. */ + rv0 = rv; + rv *= tinytens[j]; + if (!rv) { + rv = 2.*rv0; + rv *= tinytens[j]; + if (!rv) { + undfl: + rv = 0.; + errno = ERANGE; + if (bd0) + goto retfree; + goto ret; + } + word0(rv) = Tiny0; + word1(rv) = Tiny1; + /* The refinement below will clean + * this approximation up. + */ + } + } + } + + /* Now the hard part -- adjusting rv to the correct value.*/ + + /* Put digits into bd: true value = bd * 10^e */ + + bd0 = s2b(s0, nd0, nd, y); + + for(;;) { + bd = Balloc(bd0->k); + Bcopy(bd, bd0); + bb = d2b(rv, &bbe, &bbbits); /* rv = bb * 2^bbe */ + bs = i2b(1); + + if (e >= 0) { + bb2 = bb5 = 0; + bd2 = bd5 = e; + } + else { + bb2 = bb5 = -e; + bd2 = bd5 = 0; + } + if (bbe >= 0) + bb2 += bbe; + else + bd2 -= bbe; + bs2 = bb2; +#ifdef Sudden_Underflow +#ifdef IBM + j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); +#else + j = P + 1 - bbbits; +#endif +#else + i = bbe + bbbits - 1; /* logb(rv) */ + if (i < Emin) /* denormal */ + j = bbe + (P-Emin); + else + j = P + 1 - bbbits; +#endif + bb2 += j; + bd2 += j; + i = bb2 < bd2 ? bb2 : bd2; + if (i > bs2) + i = bs2; + if (i > 0) { + bb2 -= i; + bd2 -= i; + bs2 -= i; + } + if (bb5 > 0) { + bs = pow5mult(bs, bb5); + bb1 = mult(bs, bb); + Bfree(bb); + bb = bb1; + } + if (bb2 > 0) + bb = lshift(bb, bb2); + if (bd5 > 0) + bd = pow5mult(bd, bd5); + if (bd2 > 0) + bd = lshift(bd, bd2); + if (bs2 > 0) + bs = lshift(bs, bs2); + delta = diff(bb, bd); + dsign = delta->sign; + delta->sign = 0; + i = cmp(delta, bs); + if (i < 0) { + /* Error is less than half an ulp -- check for + * special case of mantissa a power of two. + */ + if (dsign || word1(rv) || word0(rv) & Bndry_mask) + break; + delta = lshift(delta,Log2P); + if (cmp(delta, bs) > 0) + goto drop_down; + break; + } + if (i == 0) { + /* exactly half-way between */ + if (dsign) { + if ((word0(rv) & Bndry_mask1) == Bndry_mask1 + && word1(rv) == 0xffffffff) { + /*boundary case -- increment exponent*/ + word0(rv) = (word0(rv) & Exp_mask) + + Exp_msk1 +#ifdef IBM + | Exp_msk1 >> 4 +#endif + ; + word1(rv) = 0; + break; + } + } + else if (!(word0(rv) & Bndry_mask) && !word1(rv)) { + drop_down: + /* boundary case -- decrement exponent */ +#ifdef Sudden_Underflow + L = word0(rv) & Exp_mask; +#ifdef IBM + if (L < Exp_msk1) +#else + if (L <= Exp_msk1) +#endif + goto undfl; + L -= Exp_msk1; +#else + L = (word0(rv) & Exp_mask) - Exp_msk1; +#endif + word0(rv) = L | Bndry_mask1; + word1(rv) = 0xffffffff; +#ifdef IBM + goto cont; +#else + break; +#endif + } +#ifndef ROUND_BIASED + if (!(word1(rv) & LSB)) + break; +#endif + if (dsign) + rv += ulp(rv); +#ifndef ROUND_BIASED + else { + rv -= ulp(rv); +#ifndef Sudden_Underflow + if (!rv) + goto undfl; +#endif + } +#endif + break; + } + if ((aadj = ratio(delta, bs)) <= 2.) { + if (dsign) + aadj = aadj1 = 1.; + else if (word1(rv) || word0(rv) & Bndry_mask) { +#ifndef Sudden_Underflow + if (word1(rv) == Tiny1 && !word0(rv)) + goto undfl; +#endif + aadj = 1.; + aadj1 = -1.; + } + else { + /* special case -- power of FLT_RADIX to be */ + /* rounded down... */ + + if (aadj < 2./FLT_RADIX) + aadj = 1./FLT_RADIX; + else + aadj *= 0.5; + aadj1 = -aadj; + } + } + else { + aadj *= 0.5; + aadj1 = dsign ? aadj : -aadj; +#ifdef Check_FLT_ROUNDS + switch(FLT_ROUNDS) { + case 2: /* towards +infinity */ + aadj1 -= 0.5; + break; + case 0: /* towards 0 */ + case 3: /* towards -infinity */ + aadj1 += 0.5; + } +#else + if (FLT_ROUNDS == 0) + aadj1 += 0.5; +#endif + } + y = word0(rv) & Exp_mask; + + /* Check for overflow */ + + if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { + rv0 = rv; + word0(rv) -= P*Exp_msk1; + adj = aadj1 * ulp(rv); + rv += adj; + if ((word0(rv) & Exp_mask) >= + Exp_msk1*(DBL_MAX_EXP+Bias-P)) { + if (word0(rv0) == Big0 && word1(rv0) == Big1) + goto ovfl; + word0(rv) = Big0; + word1(rv) = Big1; + goto cont; + } + else + word0(rv) += P*Exp_msk1; + } + else { +#ifdef Sudden_Underflow + if ((word0(rv) & Exp_mask) <= P*Exp_msk1) { + rv0 = rv; + word0(rv) += P*Exp_msk1; + adj = aadj1 * ulp(rv); + rv += adj; +#ifdef IBM + if ((word0(rv) & Exp_mask) < P*Exp_msk1) +#else + if ((word0(rv) & Exp_mask) <= P*Exp_msk1) +#endif + { + if (word0(rv0) == Tiny0 + && word1(rv0) == Tiny1) + goto undfl; + word0(rv) = Tiny0; + word1(rv) = Tiny1; + goto cont; + } + else + word0(rv) -= P*Exp_msk1; + } + else { + adj = aadj1 * ulp(rv); + rv += adj; + } +#else + /* Compute adj so that the IEEE rounding rules will + * correctly round rv + adj in some half-way cases. + * If rv * ulp(rv) is denormalized (i.e., + * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid + * trouble from bits lost to denormalization; + * example: 1.2e-307 . + */ + if (y <= (P-1)*Exp_msk1 && aadj >= 1.) { + aadj1 = (double)(int)(aadj + 0.5); + if (!dsign) + aadj1 = -aadj1; + } + adj = aadj1 * ulp(rv); + rv += adj; +#endif + } + z = word0(rv) & Exp_mask; + if (y == z) { + /* Can we stop now? */ + L = aadj; + aadj -= L; + /* The tolerances below are conservative. */ + if (dsign || word1(rv) || word0(rv) & Bndry_mask) { + if (aadj < .4999999 || aadj > .5000001) + break; + } + else if (aadj < .4999999/FLT_RADIX) + break; + } + cont: + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(delta); + } + retfree: + Bfree(bb); + Bfree(bd); + Bfree(bs); + Bfree(bd0); + Bfree(delta); + ret: + if (se) + *se = (char *)s; + return sign ? -rv : rv; + } + + static int +quorem +#ifdef KR_headers + (b, S) Bigint *b, *S; +#else + (Bigint *b, Bigint *S) +#endif +{ + int n; + Long borrow, y; + ULong carry, q, ys; + ULong *bx, *bxe, *sx, *sxe; +#ifdef Pack_32 + Long z; + ULong si, zs; +#endif + + n = S->wds; +#ifdef DEBUG + /*debug*/ if (b->wds > n) + /*debug*/ Bug("oversize b in quorem"); +#endif + if (b->wds < n) + return 0; + sx = S->x; + sxe = sx + --n; + bx = b->x; + bxe = bx + n; + q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ +#ifdef DEBUG + /*debug*/ if (q > 9) + /*debug*/ Bug("oversized quotient in quorem"); +#endif + if (q) { + borrow = 0; + carry = 0; + do { +#ifdef Pack_32 + si = *sx++; + ys = (si & 0xffff) * q + carry; + zs = (si >> 16) * q + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + z = (*bx >> 16) - (zs & 0xffff) + borrow; + borrow = z >> 16; + Sign_Extend(borrow, z); + Storeinc(bx, z, y); +#else + ys = *sx++ * q + carry; + carry = ys >> 16; + y = *bx - (ys & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + *bx++ = y & 0xffff; +#endif + } + while(sx <= sxe); + if (!*bxe) { + bx = b->x; + while(--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + if (cmp(b, S) >= 0) { + q++; + borrow = 0; + carry = 0; + bx = b->x; + sx = S->x; + do { +#ifdef Pack_32 + si = *sx++; + ys = (si & 0xffff) + carry; + zs = (si >> 16) + (ys >> 16); + carry = zs >> 16; + y = (*bx & 0xffff) - (ys & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + z = (*bx >> 16) - (zs & 0xffff) + borrow; + borrow = z >> 16; + Sign_Extend(borrow, z); + Storeinc(bx, z, y); +#else + ys = *sx++ + carry; + carry = ys >> 16; + y = *bx - (ys & 0xffff) + borrow; + borrow = y >> 16; + Sign_Extend(borrow, y); + *bx++ = y & 0xffff; +#endif + } + while(sx <= sxe); + bx = b->x; + bxe = bx + n; + if (!*bxe) { + while(--bxe > bx && !*bxe) + --n; + b->wds = n; + } + } + return q; + } + +/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. + * + * Inspired by "How to Print Floating-Point Numbers Accurately" by + * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101]. + * + * Modifications: + * 1. Rather than iterating, we use a simple numeric overestimate + * to determine k = floor(log10(d)). We scale relevant + * quantities using O(log2(k)) rather than O(k) multiplications. + * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't + * try to generate digits strictly left to right. Instead, we + * compute with fewer bits and propagate the carry if necessary + * when rounding the final digit up. This is often faster. + * 3. Under the assumption that input will be rounded nearest, + * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. + * That is, we allow equality in stopping tests when the + * round-nearest rule will give the same floating-point value + * as would satisfaction of the stopping test with strict + * inequality. + * 4. We remove common factors of powers of 2 from relevant + * quantities. + * 5. When converting floating-point integers less than 1e16, + * we use floating-point arithmetic rather than resorting + * to multiple-precision integers. + * 6. When asked to produce fewer than 15 digits, we first try + * to get by with floating-point arithmetic; we resort to + * multiple-precision integer arithmetic only if we cannot + * guarantee that the floating-point calculation has given + * the correctly rounded result. For k requested digits and + * "uniformly" distributed input, the probability is + * something like 10^(k-15) that we must resort to the Long + * calculation. + */ + + char * +__dtoa +#ifdef KR_headers + (d, mode, ndigits, decpt, sign, rve) + double d; int mode, ndigits, *decpt, *sign; char **rve; +#else + (double d, int mode, int ndigits, int *decpt, int *sign, char **rve) +#endif +{ + /* Arguments ndigits, decpt, sign are similar to those + of ecvt and fcvt; trailing zeros are suppressed from + the returned string. If not null, *rve is set to point + to the end of the return value. If d is +-Infinity or NaN, + then *decpt is set to 9999. + + mode: + 0 ==> shortest string that yields d when read in + and rounded to nearest. + 1 ==> like 0, but with Steele & White stopping rule; + e.g. with IEEE P754 arithmetic , mode 0 gives + 1e23 whereas mode 1 gives 9.999999999999999e22. + 2 ==> max(1,ndigits) significant digits. This gives a + return value similar to that of ecvt, except + that trailing zeros are suppressed. + 3 ==> through ndigits past the decimal point. This + gives a return value similar to that from fcvt, + except that trailing zeros are suppressed, and + ndigits can be negative. + 4-9 should give the same return values as 2-3, i.e., + 4 <= mode <= 9 ==> same return as mode + 2 + (mode & 1). These modes are mainly for + debugging; often they run slower but sometimes + faster than modes 2-3. + 4,5,8,9 ==> left-to-right digit generation. + 6-9 ==> don't try fast floating-point estimate + (if applicable). + + Values of mode other than 0-9 are treated as mode 0. + + Sufficient space is allocated to the return value + to hold the suppressed trailing zeros. + */ + + int bbits, b2, b5, be, dig, i, ieps, ilim, ilim0, ilim1, + j, j1, k, k0, k_check, leftright, m2, m5, s2, s5, + spec_case, try_quick; + Long L; +#ifndef Sudden_Underflow + int denorm; + ULong x; +#endif + Bigint *b, *b1, *delta, *mlo, *mhi, *S; + double d2, ds, eps; + char *s, *s0; + static Bigint *result; + static int result_k; + + if (result) { + result->k = result_k; + result->maxwds = 1 << result_k; + Bfree(result); + result = 0; + } + + if (word0(d) & Sign_bit) { + /* set sign for everything, including 0's and NaNs */ + *sign = 1; + word0(d) &= ~Sign_bit; /* clear sign bit */ + } + else + *sign = 0; + +#if defined(IEEE_Arith) + defined(VAX) +#ifdef IEEE_Arith + if ((word0(d) & Exp_mask) == Exp_mask) +#else + if (word0(d) == 0x8000) +#endif + { + /* Infinity or NaN */ + *decpt = 9999; + s = +#ifdef IEEE_Arith + !word1(d) && !(word0(d) & 0xfffff) ? "Infinity" : +#endif + "NaN"; + if (rve) + *rve = +#ifdef IEEE_Arith + s[3] ? s + 8 : +#endif + s + 3; + return s; + } +#endif +#ifdef IBM + d += 0; /* normalize */ +#endif + if (!d) { + *decpt = 1; + s = "0"; + if (rve) + *rve = s + 1; + return s; + } + + b = d2b(d, &be, &bbits); +#ifdef Sudden_Underflow + i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); +#else + if (i = (int)(word0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1))) { +#endif + d2 = d; + word0(d2) &= Frac_mask1; + word0(d2) |= Exp_11; +#ifdef IBM + if (j = 11 - hi0bits(word0(d2) & Frac_mask)) + d2 /= 1 << j; +#endif + + /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 + * log10(x) = log(x) / log(10) + * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) + * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2) + * + * This suggests computing an approximation k to log10(d) by + * + * k = (i - Bias)*0.301029995663981 + * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); + * + * We want k to be too large rather than too small. + * The error in the first-order Taylor series approximation + * is in our favor, so we just round up the constant enough + * to compensate for any error in the multiplication of + * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, + * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, + * adding 1e-13 to the constant term more than suffices. + * Hence we adjust the constant term to 0.1760912590558. + * (We could get a more accurate k by invoking log10, + * but this is probably not worthwhile.) + */ + + i -= Bias; +#ifdef IBM + i <<= 2; + i += j; +#endif +#ifndef Sudden_Underflow + denorm = 0; + } + else { + /* d is denormalized */ + + i = bbits + be + (Bias + (P-1) - 1); + x = i > 32 ? word0(d) << 64 - i | word1(d) >> i - 32 + : word1(d) << 32 - i; + d2 = x; + word0(d2) -= 31*Exp_msk1; /* adjust exponent */ + i -= (Bias + (P-1) - 1) + 1; + denorm = 1; + } +#endif + ds = (d2-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; + k = (int)ds; + if (ds < 0. && ds != k) + k--; /* want k = floor(ds) */ + k_check = 1; + if (k >= 0 && k <= Ten_pmax) { + if (d < tens[k]) + k--; + k_check = 0; + } + j = bbits - i - 1; + if (j >= 0) { + b2 = 0; + s2 = j; + } + else { + b2 = -j; + s2 = 0; + } + if (k >= 0) { + b5 = 0; + s5 = k; + s2 += k; + } + else { + b2 -= k; + b5 = -k; + s5 = 0; + } + if (mode < 0 || mode > 9) + mode = 0; + try_quick = 1; + if (mode > 5) { + mode -= 4; + try_quick = 0; + } + leftright = 1; + switch(mode) { + case 0: + case 1: + ilim = ilim1 = -1; + i = 18; + ndigits = 0; + break; + case 2: + leftright = 0; + /* no break */ + case 4: + if (ndigits <= 0) + ndigits = 1; + ilim = ilim1 = i = ndigits; + break; + case 3: + leftright = 0; + /* no break */ + case 5: + i = ndigits + k + 1; + ilim = i; + ilim1 = i - 1; + if (i <= 0) + i = 1; + } + j = sizeof(ULong); + for(result_k = 0; sizeof(Bigint) - sizeof(ULong) + j <= i; + j <<= 1) result_k++; + result = Balloc(result_k); + s = s0 = (char *)result; + + if (ilim >= 0 && ilim <= Quick_max && try_quick) { + + /* Try to get by with floating-point arithmetic. */ + + i = 0; + d2 = d; + k0 = k; + ilim0 = ilim; + ieps = 2; /* conservative */ + if (k > 0) { + ds = tens[k&0xf]; + j = k >> 4; + if (j & Bletch) { + /* prevent overflows */ + j &= Bletch - 1; + d /= bigtens[n_bigtens-1]; + ieps++; + } + for(; j; j >>= 1, i++) + if (j & 1) { + ieps++; + ds *= bigtens[i]; + } + d /= ds; + } + else if (j1 = -k) { + d *= tens[j1 & 0xf]; + for(j = j1 >> 4; j; j >>= 1, i++) + if (j & 1) { + ieps++; + d *= bigtens[i]; + } + } + if (k_check && d < 1. && ilim > 0) { + if (ilim1 <= 0) + goto fast_failed; + ilim = ilim1; + k--; + d *= 10.; + ieps++; + } + eps = ieps*d + 7.; + word0(eps) -= (P-1)*Exp_msk1; + if (ilim == 0) { + S = mhi = 0; + d -= 5.; + if (d > eps) + goto one_digit; + if (d < -eps) + goto no_digits; + goto fast_failed; + } +#ifndef No_leftright + if (leftright) { + /* Use Steele & White method of only + * generating digits needed. + */ + eps = 0.5/tens[ilim-1] - eps; + for(i = 0;;) { + L = d; + d -= L; + *s++ = '0' + (int)L; + if (d < eps) + goto ret1; + if (1. - d < eps) + goto bump_up; + if (++i >= ilim) + break; + eps *= 10.; + d *= 10.; + } + } + else { +#endif + /* Generate ilim digits, then fix them up. */ + eps *= tens[ilim-1]; + for(i = 1;; i++, d *= 10.) { + L = d; + d -= L; + *s++ = '0' + (int)L; + if (i == ilim) { + if (d > 0.5 + eps) + goto bump_up; + else if (d < 0.5 - eps) { + while(*--s == '0'); + s++; + goto ret1; + } + break; + } + } +#ifndef No_leftright + } +#endif + fast_failed: + s = s0; + d = d2; + k = k0; + ilim = ilim0; + } + + /* Do we have a "small" integer? */ + + if (be >= 0 && k <= Int_max) { + /* Yes. */ + ds = tens[k]; + if (ndigits < 0 && ilim <= 0) { + S = mhi = 0; + if (ilim < 0 || d <= 5*ds) + goto no_digits; + goto one_digit; + } + for(i = 1;; i++) { + L = d / ds; + d -= L*ds; +#ifdef Check_FLT_ROUNDS + /* If FLT_ROUNDS == 2, L will usually be high by 1 */ + if (d < 0) { + L--; + d += ds; + } +#endif + *s++ = '0' + (int)L; + if (i == ilim) { + d += d; + if (d > ds || d == ds && L & 1) { + bump_up: + while(*--s == '9') + if (s == s0) { + k++; + *s = '0'; + break; + } + ++*s++; + } + break; + } + if (!(d *= 10.)) + break; + } + goto ret1; + } + + m2 = b2; + m5 = b5; + mhi = mlo = 0; + if (leftright) { + if (mode < 2) { + i = +#ifndef Sudden_Underflow + denorm ? be + (Bias + (P-1) - 1 + 1) : +#endif +#ifdef IBM + 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3); +#else + 1 + P - bbits; +#endif + } + else { + j = ilim - 1; + if (m5 >= j) + m5 -= j; + else { + s5 += j -= m5; + b5 += j; + m5 = 0; + } + if ((i = ilim) < 0) { + m2 -= i; + i = 0; + } + } + b2 += i; + s2 += i; + mhi = i2b(1); + } + if (m2 > 0 && s2 > 0) { + i = m2 < s2 ? m2 : s2; + b2 -= i; + m2 -= i; + s2 -= i; + } + if (b5 > 0) { + if (leftright) { + if (m5 > 0) { + mhi = pow5mult(mhi, m5); + b1 = mult(mhi, b); + Bfree(b); + b = b1; + } + if (j = b5 - m5) + b = pow5mult(b, j); + } + else + b = pow5mult(b, b5); + } + S = i2b(1); + if (s5 > 0) + S = pow5mult(S, s5); + + /* Check for special case that d is a normalized power of 2. */ + + if (mode < 2) { + if (!word1(d) && !(word0(d) & Bndry_mask) +#ifndef Sudden_Underflow + && word0(d) & Exp_mask +#endif + ) { + /* The special case */ + b2 += Log2P; + s2 += Log2P; + spec_case = 1; + } + else + spec_case = 0; + } + + /* Arrange for convenient computation of quotients: + * shift left if necessary so divisor has 4 leading 0 bits. + * + * Perhaps we should just compute leading 28 bits of S once + * and for all and pass them and a shift to quorem, so it + * can do shifts and ors to compute the numerator for q. + */ +#ifdef Pack_32 + if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f) + i = 32 - i; +#else + if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf) + i = 16 - i; +#endif + if (i > 4) { + i -= 4; + b2 += i; + m2 += i; + s2 += i; + } + else if (i < 4) { + i += 28; + b2 += i; + m2 += i; + s2 += i; + } + if (b2 > 0) + b = lshift(b, b2); + if (s2 > 0) + S = lshift(S, s2); + if (k_check) { + if (cmp(b,S) < 0) { + k--; + b = multadd(b, 10, 0); /* we botched the k estimate */ + if (leftright) + mhi = multadd(mhi, 10, 0); + ilim = ilim1; + } + } + if (ilim <= 0 && mode > 2) { + if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) { + /* no digits, fcvt style */ + no_digits: + k = -1 - ndigits; + goto ret; + } + one_digit: + *s++ = '1'; + k++; + goto ret; + } + if (leftright) { + if (m2 > 0) + mhi = lshift(mhi, m2); + + /* Compute mlo -- check for special case + * that d is a normalized power of 2. + */ + + mlo = mhi; + if (spec_case) { + mhi = Balloc(mhi->k); + Bcopy(mhi, mlo); + mhi = lshift(mhi, Log2P); + } + + for(i = 1;;i++) { + dig = quorem(b,S) + '0'; + /* Do we yet have the shortest decimal string + * that will round to d? + */ + j = cmp(b, mlo); + delta = diff(S, mhi); + j1 = delta->sign ? 1 : cmp(b, delta); + Bfree(delta); +#ifndef ROUND_BIASED + if (j1 == 0 && !mode && !(word1(d) & 1)) { + if (dig == '9') + goto round_9_up; + if (j > 0) + dig++; + *s++ = dig; + goto ret; + } +#endif + if (j < 0 || j == 0 && !mode +#ifndef ROUND_BIASED + && !(word1(d) & 1) +#endif + ) { + if (j1 > 0) { + b = lshift(b, 1); + j1 = cmp(b, S); + if ((j1 > 0 || j1 == 0 && dig & 1) + && dig++ == '9') + goto round_9_up; + } + *s++ = dig; + goto ret; + } + if (j1 > 0) { + if (dig == '9') { /* possible if i == 1 */ + round_9_up: + *s++ = '9'; + goto roundoff; + } + *s++ = dig + 1; + goto ret; + } + *s++ = dig; + if (i == ilim) + break; + b = multadd(b, 10, 0); + if (mlo == mhi) + mlo = mhi = multadd(mhi, 10, 0); + else { + mlo = multadd(mlo, 10, 0); + mhi = multadd(mhi, 10, 0); + } + } + } + else + for(i = 1;; i++) { + *s++ = dig = quorem(b,S) + '0'; + if (i >= ilim) + break; + b = multadd(b, 10, 0); + } + + /* Round off last digit */ + + b = lshift(b, 1); + j = cmp(b, S); + if (j > 0 || j == 0 && dig & 1) { + roundoff: + while(*--s == '9') + if (s == s0) { + k++; + *s++ = '1'; + goto ret; + } + ++*s++; + } + else { + while(*--s == '0'); + s++; + } + ret: + Bfree(S); + if (mhi) { + if (mlo && mlo != mhi) + Bfree(mlo); + Bfree(mhi); + } + ret1: + Bfree(b); + if (s == s0) { /* don't return empty string */ + *s++ = '0'; + k = 0; + } + *s = 0; + *decpt = k + 1; + if (rve) + *rve = s; + return s0; + } +#ifdef __cplusplus +} +#endif diff --git a/src/lib/libc/stdlib/strtol.3 b/src/lib/libc/stdlib/strtol.3 new file mode 100644 index 00000000..808ba901 --- /dev/null +++ b/src/lib/libc/stdlib/strtol.3 @@ -0,0 +1,169 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strtol.3 5.4 (Berkeley) 6/25/92 +.\" $Id: strtol.3,v 1.1.1.1 1995/10/18 08:42:19 deraadt Exp $ +.\" +.Dd June 25, 1992 +.Dt STRTOL 3 +.Os +.Sh NAME +.Nm strtol, strtoq +.Nd convert string value to a long or quad_t integer +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Fd #include <limits.h> +.Ft long +.Fn strtol "char *nptr" "char **endptr" "int base" + +.Fd #include <sys/types.h> +.Fd #include <stdlib.h> +.Fd #include <limits.h> +.Ft quad_t +.Fn strtoq "char *nptr" "char **endptr" "int base" +.Sh DESCRIPTION +The +.Fn strtol +function +converts the string in +.Fa nptr +to a +.Em long +value. +The +.Fn strtoq +function +converts the string in +.Fa nptr +to a +.Em quad_t +value. +The conversion is done according to the given +.Fa base , +which must be between 2 and 36 inclusive, +or be the special value 0. +.Pp +The string may begin with an arbitrary amount of white space +(as determined by +.Xr isspace 3 ) +followed by a single optional +.Ql + +or +.Ql - +sign. +If +.Fa base +is zero or 16, +the string may then include a +.Ql 0x +prefix, +and the number will be read in base 16; otherwise, a zero +.Fa base +is taken as 10 (decimal) unless the next character is +.Ql 0 , +in which case it is taken as 8 (octal). +.Pp +The remainder of the string is converted to a +.Em long +value in the obvious manner, +stopping at the first character which is not a valid digit +in the given base. +(In bases above 10, the letter +.Ql A +in either upper or lower case +represents 10, +.Ql B +represents 11, and so forth, with +.Ql Z +representing 35.) +.Pp +If +.Fa endptr +is non nil, +.Fn strtol +stores the address of the first invalid character in +.Fa *endptr . +If there were no digits at all, however, +.Fn strtol +stores the original value of +.Fa nptr +in +.Fa *endptr . +(Thus, if +.Fa *nptr +is not +.Ql \e0 +but +.Fa **endptr +is +.Ql \e0 +on return, the entire string was valid.) +.Sh RETURN VALUES +The +.Fn strtol +function +returns the result of the conversion, +unless the value would underflow or overflow. +If an underflow occurs, +.Fn strtol +returns +.Dv LONG_MIN . +If an overflow occurs, +.Fn strtol +returns +.Dv LONG_MAX . +In both cases, +.Va errno +is set to +.Er ERANGE . +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er ERANGE +The given string was out of range; the value converted has been clamped. +.El +.Sh SEE ALSO +.Xr atof 3 , +.Xr atoi 3 , +.Xr atol 3 , +.Xr strtod 3 , +.Xr strtoul 3 +.Sh STANDARDS +The +.Fn strtol +function +conforms to +.St -ansiC . +.Sh BUGS +Ignores the current locale. diff --git a/src/lib/libc/stdlib/strtol.c b/src/lib/libc/stdlib/strtol.c new file mode 100644 index 00000000..6f374abd --- /dev/null +++ b/src/lib/libc/stdlib/strtol.c @@ -0,0 +1,130 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strtol.c 5.4 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: strtol.c,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <limits.h> +#include <ctype.h> +#include <errno.h> +#include <stdlib.h> + + +/* + * Convert a string to a long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +long +strtol(nptr, endptr, base) + const char *nptr; + char **endptr; + register int base; +{ + register const char *s = nptr; + register unsigned long acc; + register int c; + register unsigned long cutoff; + register int neg = 0, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for longs is + * [-2147483648..2147483647] and the input base is 10, + * cutoff will be set to 214748364 and cutlim to either + * 7 (neg==0) or 8 (neg==1), meaning that if we have accumulated + * a value > 214748364, or equal but the next digit is > 7 (or 8), + * the number is too big, and we will return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? -(unsigned long)LONG_MIN : LONG_MAX; + cutlim = cutoff % (unsigned long)base; + cutoff /= (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = neg ? LONG_MIN : LONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} diff --git a/src/lib/libc/stdlib/strtoq.c b/src/lib/libc/stdlib/strtoq.c new file mode 100644 index 00000000..fc559e9d --- /dev/null +++ b/src/lib/libc/stdlib/strtoq.c @@ -0,0 +1,136 @@ +/*- + * Copyright (c) 1992 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strtoq.c 5.1 (Berkeley) 6/26/92"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> + +#include <limits.h> +#include <errno.h> +#include <ctype.h> +#include <stdlib.h> + +/* + * Convert a string to a quad integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +quad_t +strtoq(nptr, endptr, base) + const char *nptr; + char **endptr; + register int base; +{ + register const char *s; + register u_quad_t acc; + register int c; + register u_quad_t qbase, cutoff; + register int neg, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + s = nptr; + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for quads is + * [-9223372036854775808..9223372036854775807] and the input base + * is 10, cutoff will be set to 922337203685477580 and cutlim to + * either 7 (neg==0) or 8 (neg==1), meaning that if we have + * accumulated a value > 922337203685477580, or equal but the + * next digit is > 7 (or 8), the number is too big, and we will + * return a range error. + * + * Set any if any `digits' consumed; make it negative to indicate + * overflow. + */ + qbase = (unsigned)base; + cutoff = neg ? -(u_quad_t)QUAD_MIN : QUAD_MAX; + cutlim = cutoff % qbase; + cutoff /= qbase; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= qbase; + acc += c; + } + } + if (any < 0) { + acc = neg ? QUAD_MIN : QUAD_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} diff --git a/src/lib/libc/stdlib/strtoul.3 b/src/lib/libc/stdlib/strtoul.3 new file mode 100644 index 00000000..db551b01 --- /dev/null +++ b/src/lib/libc/stdlib/strtoul.3 @@ -0,0 +1,164 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strtoul.3 5.4 (Berkeley) 6/25/92 +.\" $Id: strtoul.3,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $ +.\" +.Dd June 25, 1992 +.Dt STRTOUL 3 +.Os +.Sh NAME +.Nm strtoul, strtouq +.Nd convert a string to an unsigned long or uquad_t integer +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Fd #include <limits.h> +.Ft unsigned long +.Fn strtoul "const char *nptr" "char **endptr" "int base" + +.Fd #include <sys/types.h> +.Fd #include <stdlib.h> +.Fd #include <limits.h> +.Ft u_quad_t +.Fn strtouq "const char *nptr" "char **endptr" "int base" +.Sh DESCRIPTION +The +.Fn strtoul +function +converts the string in +.Fa nptr +to an +.Em unsigned long +value. +The +.Fn strtouq +function +converts the string in +.Fa nptr +to a +.Em u_quad_t +value. +The conversion is done according to the given +.Fa base , +which must be between 2 and 36 inclusive, +or be the special value 0. +.Pp +The string may begin with an arbitrary amount of white space +(as determined by +.Xr isspace 3 ) +followed by a single optional +.Ql + +or +.Ql - +sign. +If +.Fa base +is zero or 16, +the string may then include a +.Ql 0x +prefix, +and the number will be read in base 16; otherwise, a zero +.Fa base +is taken as 10 (decimal) unless the next character is +.Ql 0 , +in which case it is taken as 8 (octal). +.Pp +The remainder of the string is converted to an +.Em unsigned long +value in the obvious manner, +stopping at the end of the string +or at the first character that does not produce a valid digit +in the given base. +(In bases above 10, the letter +.Ql A +in either upper or lower case +represents 10, +.Ql B +represents 11, and so forth, with +.Ql Z +representing 35.) +.Pp +If +.Fa endptr +is non nil, +.Fn strtoul +stores the address of the first invalid character in +.Fa *endptr . +If there were no digits at all, however, +.Fn strtoul +stores the original value of +.Fa nptr +in +.Fa *endptr . +(Thus, if +.Fa *nptr +is not +.Ql \e0 +but +.Fa **endptr +is +.Ql \e0 +on return, the entire string was valid.) +.Sh RETURN VALUES +The +.Fn strtoul +function +returns either the result of the conversion +or, if there was a leading minus sign, +the negation of the result of the conversion, +unless the original (non-negated) value would overflow; +in the latter case, +.Fn strtoul +returns +.Dv ULONG_MAX +and sets the global variable +.Va errno +to +.Er ERANGE . +.Sh ERRORS +.Bl -tag -width Er +.It Bq Er ERANGE +The given string was out of range; the value converted has been clamped. +.El +.Sh SEE ALSO +.Xr strtol 3 +.Sh STANDARDS +The +.Fn strtoul +function +conforms to +.St -ansiC . +.Sh BUGS +Ignores the current locale. diff --git a/src/lib/libc/stdlib/strtoul.c b/src/lib/libc/stdlib/strtoul.c new file mode 100644 index 00000000..00f7210f --- /dev/null +++ b/src/lib/libc/stdlib/strtoul.c @@ -0,0 +1,108 @@ +/* + * Copyright (c) 1990 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strtoul.c 5.3 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: strtoul.c,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <limits.h> +#include <ctype.h> +#include <errno.h> +#include <stdlib.h> + +/* + * Convert a string to an unsigned long integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +unsigned long +strtoul(nptr, endptr, base) + const char *nptr; + char **endptr; + register int base; +{ + register const char *s = nptr; + register unsigned long acc; + register int c; + register unsigned long cutoff; + register int neg = 0, any, cutlim; + + /* + * See strtol for comments as to the logic used. + */ + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else if (c == '+') + c = *s++; + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + cutoff = (unsigned long)ULONG_MAX / (unsigned long)base; + cutlim = (unsigned long)ULONG_MAX % (unsigned long)base; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = ULONG_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} diff --git a/src/lib/libc/stdlib/strtouq.c b/src/lib/libc/stdlib/strtouq.c new file mode 100644 index 00000000..cc647d8d --- /dev/null +++ b/src/lib/libc/stdlib/strtouq.c @@ -0,0 +1,114 @@ +/*- + * Copyright (c) 1992 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +static char sccsid[] = "@(#)strtouq.c 5.1 (Berkeley) 6/26/92"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> + +#include <limits.h> +#include <errno.h> +#include <ctype.h> +#include <stdlib.h> + +/* + * Convert a string to an unsigned quad integer. + * + * Ignores `locale' stuff. Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +u_quad_t +strtouq(nptr, endptr, base) + const char *nptr; + char **endptr; + register int base; +{ + register const char *s = nptr; + register u_quad_t acc; + register int c; + register u_quad_t qbase, cutoff; + register int neg, any, cutlim; + + /* + * See strtoq for comments as to the logic used. + */ + s = nptr; + do { + c = *s++; + } while (isspace(c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X')) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + qbase = (unsigned)base; + cutoff = (u_quad_t)UQUAD_MAX / qbase; + cutlim = (u_quad_t)UQUAD_MAX % qbase; + for (acc = 0, any = 0;; c = *s++) { + if (isdigit(c)) + c -= '0'; + else if (isalpha(c)) + c -= isupper(c) ? 'A' - 10 : 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || acc == cutoff && c > cutlim) + any = -1; + else { + any = 1; + acc *= qbase; + acc += c; + } + } + if (any < 0) { + acc = UQUAD_MAX; + errno = ERANGE; + } else if (neg) + acc = -acc; + if (endptr != 0) + *endptr = (char *) (any ? s - 1 : nptr); + return (acc); +} diff --git a/src/lib/libc/stdlib/system.3 b/src/lib/libc/stdlib/system.3 new file mode 100644 index 00000000..520f51db --- /dev/null +++ b/src/lib/libc/stdlib/system.3 @@ -0,0 +1,99 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)system.3 6.5 (Berkeley) 6/29/91 +.\" $Id: system.3,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt SYSTEM 3 +.Os +.Sh NAME +.Nm system +.Nd pass a command to the shell +.Sh SYNOPSIS +.Fd #include <stdlib.h> +.Ft int +.Fn system "const char *string" +.Sh DESCRIPTION +The +.Fn system +function +hands the argument +.Fa string +to the command interpreter +.Xr sh 1 . +The calling process waits for the shell to finish executing the command, +ignoring +.Dv SIGINT +and +.Dv SIGQUIT , +and blocking +.Dv SIGCHLD . +.Pp +If +.Fa string +is a +.Dv NULL +pointer, +.Fn system +will return non-zero. +Otherwise, +.Fn system +returns the termination status of the shell in the format specified by +.Xr waitpid 3 . +.Sh RETURN VALUES +If a child process cannot be created, or the termination status of +the shell cannot be obtained, +.Fn system +returns -1 and sets +.Va errno +to indicate the error. +If execution of the shell fails, +.Fn system +returns the termination status for a program that terminates with a call of +.Fn exit 127 . +.Sh SEE ALSO +.Xr sh 1 , +.Xr execve 2 , +.Xr popen 3 , +.Xr waitpid 3 , +.Sh STANDARDS +The +.Fn system +function +conforms to +.St -ansiC +and +.St -1003.2-92 . diff --git a/src/lib/libc/stdlib/system.c b/src/lib/libc/stdlib/system.c new file mode 100644 index 00000000..c2f39325 --- /dev/null +++ b/src/lib/libc/stdlib/system.c @@ -0,0 +1,79 @@ +/* + * Copyright (c) 1988 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)system.c 5.10 (Berkeley) 2/23/91";*/ +static char *rcsid = "$Id: system.c,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <sys/wait.h> +#include <signal.h> +#include <stdlib.h> +#include <unistd.h> +#include <paths.h> + +extern char **environ; + +int +system(command) + const char *command; +{ + pid_t pid; + sig_t intsave, quitsave; + int omask; + int pstat; + char *argp[] = {"sh", "-c", (char *) command, NULL}; + + if (!command) /* just checking... */ + return(1); + + omask = sigblock(sigmask(SIGCHLD)); + switch(pid = vfork()) { + case -1: /* error */ + (void)sigsetmask(omask); + return(-1); + case 0: /* child */ + (void)sigsetmask(omask); + execve(_PATH_BSHELL, argp, environ); + _exit(127); + } + + intsave = signal(SIGINT, SIG_IGN); + quitsave = signal(SIGQUIT, SIG_IGN); + pid = waitpid(pid, (int *)&pstat, 0); + (void)sigsetmask(omask); + (void)signal(SIGINT, intsave); + (void)signal(SIGQUIT, quitsave); + return(pid == -1 ? -1 : pstat); +} diff --git a/src/lib/libc/string/Makefile.inc b/src/lib/libc/string/Makefile.inc new file mode 100644 index 00000000..2b7ce63a --- /dev/null +++ b/src/lib/libc/string/Makefile.inc @@ -0,0 +1,108 @@ +# from: @(#)Makefile.inc 5.6 (Berkeley) 3/5/91 +# $Id: Makefile.inc,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $ + +# string sources +.PATH: ${.CURDIR}/arch/${MACHINE_ARCH}/string ${.CURDIR}/string + +SRCS+= bm.c memccpy.c strcasecmp.c strcoll.c strdup.c strerror.c \ + strftime.c strmode.c strsignal.c strtok.c strxfrm.c \ + __strerror.c __strsignal.c + +# machine-dependent net sources +# m-d Makefile.inc must include sources for: +# bcmp() bcopy() bzero() ffs() index() memchr() memcmp() memset() +# rindex() strcat() strcmp() strcpy() strcspn() strlen() +# strncat() strncmp() strncpy() strpbrk() strsep() +# strspn() strstr() swav() +# m-d Makefile.inc may include sources for: +# memcpy() memmove() strchr() strrchr() + +.include "${.CURDIR}/arch/${MACHINE_ARCH}/string/Makefile.inc" + +# if no machine specific memmove(3), build one out of bcopy(3). +.if empty(SRCS:Mmemmove.S) +OBJS+= memmove.o +memmove.o: bcopy.c + ${CC} -DMEMMOVE ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET} + @${LD} -x -r ${.TARGET} + @mv a.out ${.TARGET} + +memmove.po: bcopy.c + ${CC} -DMEMMOVE ${CFLAGS} ${CPPFLAGS} -c -p ${.ALLSRC} -o ${.TARGET} + @${LD} -X -r ${.TARGET} + @mv a.out ${.TARGET} + +memmove.so: bcopy.c + ${CC} ${PICFLAG} -DPIC -DMEMMOVE ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} \ + -o ${.TARGET} +.endif + +# if no machine specific memcpy(3), build one out of bcopy(3). +# if there is a machine specific memmove(3), we'll assume it aliases +# memcpy(3). +.if empty(SRCS:Mmemcpy.S) +.if empty(SRCS:Mmemmove.S) +OBJS+= memcpy.o +memcpy.o: bcopy.c + ${CC} -DMEMCOPY ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET} + @${LD} -x -r ${.TARGET} + @mv a.out ${.TARGET} + +memcpy.po: bcopy.c + ${CC} -DMEMCOPY ${CFLAGS} ${CPPFLAGS} -c -p ${.ALLSRC} -o ${.TARGET} + @${LD} -X -r ${.TARGET} + @mv a.out ${.TARGET} + +memcpy.so: bcopy.c + ${CC} ${PICFLAG} -DPIC -DMEMCOPY ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} \ + -o ${.TARGET} +.endif +.endif + +# if no machine specific strchr(3), build one out of index(3). +.if empty(SRCS:Mstrchr.S) +OBJS+= strchr.o +strchr.o: index.c + ${CC} -DSTRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET} + @${LD} -x -r ${.TARGET} + @mv a.out ${.TARGET} + +strchr.po: index.c + ${CC} -DSTRCHR ${CFLAGS} ${CPPFLAGS} -c -p ${.ALLSRC} -o ${.TARGET} + @${LD} -X -r ${.TARGET} + @mv a.out ${.TARGET} + +strchr.so: index.c + ${CC} ${PICFLAG} -DPIC -DSTRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} \ + -o ${.TARGET} +.endif + +# if no machine specific strrchr(3), build one out of rindex(3). +.if empty(SRCS:Mstrrchr.S) +OBJS+= strrchr.o +strrchr.o: rindex.c + ${CC} -DSTRRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} -o ${.TARGET} + @${LD} -x -r ${.TARGET} + @mv a.out ${.TARGET} + +strrchr.po: rindex.c + ${CC} -DSTRRCHR ${CFLAGS} ${CPPFLAGS} -c -p ${.ALLSRC} -o ${.TARGET} + @${LD} -X -r ${.TARGET} + @mv a.out ${.TARGET} + +strrchr.so: rindex.c + ${CC} ${PICFLAG} -DPIC -DSTRRCHR ${CFLAGS} ${CPPFLAGS} -c ${.ALLSRC} \ + -o ${.TARGET} +.endif + +MAN+= bm.3 bcmp.3 bcopy.3 bstring.3 bzero.3 ffs.3 index.3 memccpy.3 memchr.3 \ + memcmp.3 memcpy.3 memmove.3 memset.3 rindex.3 strcasecmp.3 strcat.3 \ + strchr.3 strcmp.3 strcoll.3 strcpy.3 strcspn.3 strerror.3 strftime.3 \ + string.3 strlen.3 strmode.3 strdup.3 strpbrk.3 strrchr.3 strsep.3 \ + strsignal.3 strspn.3 strstr.3 strtok.3 strxfrm.3 swab.3 + +MLINKS+=bm.3 bm_comp.3 bm.3 bm_exec.3 bm.3 bm_free.3 +MLINKS+=strcasecmp.3 strncasecmp.3 +MLINKS+=strcat.3 strncat.3 +MLINKS+=strcmp.3 strncmp.3 +MLINKS+=strcpy.3 strncpy.3 diff --git a/src/lib/libc/string/__strerror.c b/src/lib/libc/string/__strerror.c new file mode 100644 index 00000000..cd604906 --- /dev/null +++ b/src/lib/libc/string/__strerror.c @@ -0,0 +1,92 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strerror.c 5.6 (Berkeley) 5/4/91";*/ +static char *rcsid = "$Id: __strerror.c,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#ifdef NLS +#define catclose _catclose +#define catgets _catgets +#define catopen _catopen +#include <nl_types.h> +#endif + +#define sys_errlist _sys_errlist +#define sys_nerr _sys_nerr + +#include <stdio.h> +#include <string.h> + +/* + * Since perror() is not allowed to change the contents of strerror()'s + * static buffer, both functions supply their own buffers to the + * internal function __strerror(). + */ + +char * +__strerror(num, buf) + int num; + char *buf; +{ +#define UPREFIX "Unknown error: %u" + register unsigned int errnum; + +#ifdef NLS + nl_catd catd ; + catd = catopen("libc", 0); +#endif + + errnum = num; /* convert to unsigned */ + if (errnum < sys_nerr) { +#ifdef NLS + strcpy(buf, catgets(catd, 1, errnum, + (char *)sys_errlist[errnum])); +#else + return(sys_errlist[errnum]); +#endif + } else { +#ifdef NLS + sprintf(buf, catgets(catd, 1, 0xffff, UPREFIX), errnum); +#else + sprintf(buf, UPREFIX, errnum); +#endif + } + +#ifdef NLS + catclose(catd); +#endif + + return buf; +} diff --git a/src/lib/libc/string/__strsignal.c b/src/lib/libc/string/__strsignal.c new file mode 100644 index 00000000..1937e2d6 --- /dev/null +++ b/src/lib/libc/string/__strsignal.c @@ -0,0 +1,86 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strerror.c 5.6 (Berkeley) 5/4/91";*/ +static char *rcsid = "$Id: __strsignal.c,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#ifdef NLS +#define catclose _catclose +#define catgets _catgets +#define catopen _catopen +#include <nl_types.h> +#endif + +#define sys_siglist _sys_siglist + +#include <stdio.h> +#include <signal.h> +#include <string.h> + +char * +__strsignal(num, buf) + int num; + char *buf; +{ +#define UPREFIX "Unknown signal: %u" + register unsigned int signum; + +#ifdef NLS + nl_catd catd ; + catd = catopen("libc", 0); +#endif + + signum = num; /* convert to unsigned */ + if (signum < NSIG) { +#ifdef NLS + strcpy(buf, catgets(catd, 2, signum, + (char *)sys_siglist[signum])); +#else + return((char *)sys_siglist[signum]); +#endif + } else { +#ifdef NLS + sprintf(buf, catgets(catd, 1, 0xffff, UPREFIX), signum); +#else + sprintf(buf, UPREFIX, signum); +#endif + } + +#ifdef NLS + catclose(catd); +#endif + + return buf; +} diff --git a/src/lib/libc/string/bcmp.3 b/src/lib/libc/string/bcmp.3 new file mode 100644 index 00000000..118c55c5 --- /dev/null +++ b/src/lib/libc/string/bcmp.3 @@ -0,0 +1,72 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)bcmp.3 5.4 (Berkeley) 4/19/91 +.\" $Id: bcmp.3,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt BCMP 3 +.Os BSD 4.2 +.Sh NAME +.Nm bcmp +.Nd compare byte string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft int +.Fn bcmp "const void *b1" "const void *b2" "size_t len" +.Sh DESCRIPTION +The +.Fn bcmp +function +compares byte string +.Fa b1 +against byte string +.Fa b2 , +returning zero if they are identical, non-zero otherwise. +Both strings are assumed to be +.Fa len +bytes long. +Zero-length strings are always identical. +.Pp +The strings may overlap. +.Sh SEE ALSO +.Xr memcmp 3 , +.Xr strcasecmp 3 , +.Xr strcmp 3 , +.Xr strcoll 3 , +.Xr strxfrm 3 +.Sh HISTORY +A +.Fn bcmp +function first appeared in +.Bx 4.2 . diff --git a/src/lib/libc/string/bcmp.c b/src/lib/libc/string/bcmp.c new file mode 100644 index 00000000..2cc38bae --- /dev/null +++ b/src/lib/libc/string/bcmp.c @@ -0,0 +1,59 @@ +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)bcmp.c 5.6 (Berkeley) 2/24/91";*/ +static char *rcsid = "$Id: bcmp.c,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * bcmp -- vax cmpc3 instruction + */ +bcmp(b1, b2, length) + const void *b1, *b2; + register size_t length; +{ + register char *p1, *p2; + + if (length == 0) + return(0); + p1 = (char *)b1; + p2 = (char *)b2; + do + if (*p1++ != *p2++) + break; + while (--length); + return(length); +} diff --git a/src/lib/libc/string/bcopy.3 b/src/lib/libc/string/bcopy.3 new file mode 100644 index 00000000..6db3812c --- /dev/null +++ b/src/lib/libc/string/bcopy.3 @@ -0,0 +1,72 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)bcopy.3 5.3 (Berkeley) 4/19/91 +.\" $Id: bcopy.3,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt BCOPY 3 +.Os BSD 4.2 +.Sh NAME +.Nm bcopy +.Nd copy byte string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft void +.Fn bcopy "const void *src" "void *dst" "size_t len" +.Sh DESCRIPTION +The +.Fn bcopy +function +copies +.Fa len +bytes from string +.Fa src +to string +.Fa dst . +The two strings may overlap. +If +.Fa len +is zero, no bytes are copied. +.Sh SEE ALSO +.Xr memccpy 3 , +.Xr memcpy 3 , +.Xr memmove 3 , +.Xr strcpy 3 , +.Xr strncpy 3 +.Sh HISTORY +A +.Fn bcopy +function appeared in +.Bx 4.2 . diff --git a/src/lib/libc/string/bcopy.c b/src/lib/libc/string/bcopy.c new file mode 100644 index 00000000..92feed66 --- /dev/null +++ b/src/lib/libc/string/bcopy.c @@ -0,0 +1,139 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)bcopy.c 5.11 (Berkeley) 6/21/91";*/ +static char *rcsid = "$Id: bcopy.c,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * sizeof(word) MUST BE A POWER OF TWO + * SO THAT wmask BELOW IS ALL ONES + */ +typedef long word; /* "word" used for optimal copy speed */ + +#define wsize sizeof(word) +#define wmask (wsize - 1) + +/* + * Copy a block of memory, handling overlap. + * This is the routine that actually implements + * (the portable versions of) bcopy, memcpy, and memmove. + */ +#ifdef MEMCOPY +void * +memcpy(dst0, src0, length) +#else +#ifdef MEMMOVE +void * +memmove(dst0, src0, length) +#else +void +bcopy(src0, dst0, length) +#endif +#endif + void *dst0; + const void *src0; + register size_t length; +{ + register char *dst = dst0; + register const char *src = src0; + register size_t t; + + if (length == 0 || dst == src) /* nothing to do */ + goto done; + + /* + * Macros: loop-t-times; and loop-t-times, t>0 + */ +#define TLOOP(s) if (t) TLOOP1(s) +#define TLOOP1(s) do { s; } while (--t) + + if ((unsigned long)dst < (unsigned long)src) { + /* + * Copy forward. + */ + t = (long)src; /* only need low bits */ + if ((t | (long)dst) & wmask) { + /* + * Try to align operands. This cannot be done + * unless the low bits match. + */ + if ((t ^ (long)dst) & wmask || length < wsize) + t = length; + else + t = wsize - (t & wmask); + length -= t; + TLOOP1(*dst++ = *src++); + } + /* + * Copy whole words, then mop up any trailing bytes. + */ + t = length / wsize; + TLOOP(*(word *)dst = *(word *)src; src += wsize; dst += wsize); + t = length & wmask; + TLOOP(*dst++ = *src++); + } else { + /* + * Copy backwards. Otherwise essentially the same. + * Alignment works as before, except that it takes + * (t&wmask) bytes to align, not wsize-(t&wmask). + */ + src += length; + dst += length; + t = (long)src; + if ((t | (long)dst) & wmask) { + if ((t ^ (long)dst) & wmask || length <= wsize) + t = length; + else + t &= wmask; + length -= t; + TLOOP1(*--dst = *--src); + } + t = length / wsize; + TLOOP(src -= wsize; dst -= wsize; *(word *)dst = *(word *)src); + t = length & wmask; + TLOOP(*--dst = *--src); + } +done: +#if defined(MEMCOPY) || defined(MEMMOVE) + return (dst0); +#else + return; +#endif +} diff --git a/src/lib/libc/string/bm.3 b/src/lib/libc/string/bm.3 new file mode 100644 index 00000000..2264a6a1 --- /dev/null +++ b/src/lib/libc/string/bm.3 @@ -0,0 +1,114 @@ +.\" Copyright (c) 1994 +.\" The Regents of the University of California. All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Andrew Hume of AT&T Bell Laboratories. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)bm.3 8.4 (Berkeley) 6/21/94 +.\" $Id: bm.3,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $ +.\" +.TH BM 3 +.SH NAME +bm_comp, bm_exec, bm_free \- Boyer-Moore string search +.SH SYNOPSIS +.ft B +#include <sys/types.h> +.br +#include <bm.h> +.sp +bm_pat * +.br +bm_comp(u_char *pattern, size_t patlen, u_char freq[256]); +.sp +u_char * +.br +bm_exec(bm_pat *pdesc, u_char *text, size_t len); +.sp +void +.br +bm_free(bm_pat *pdesc); +.SH DESCRIPTION +These routines implement an efficient mechanism to find an +occurrence of a byte string within another byte string. +.PP +.I Bm_comp +evaluates the +.I patlen +bytes starting at +.IR pattern , +and returns a pointer to a structure describing them. +The bytes referenced by +.I pattern +may be of any value. +.PP +The search takes advantage of the frequency distribution of the +bytes in the text to be searched. +If specified, +.I freq +should be an array of 256 values, +with higher values indicating that the corresponding character occurs +more frequently. +(A less than optimal frequency distribution can only result in less +than optimal performance, not incorrect results.) +If +.I freq +is NULL, +a system default table is used. +.PP +.I Bm_exec +returns a pointer to the leftmost occurrence of the string given to +.I bm_comp +within +.IR text , +or NULL if none occurs. +The number of bytes in +.I text +must be specified by +.IR len . +.PP +Space allocated for the returned description is discarded +by calling +.I bm_free +with the returned description as an argument. +.PP +The asymptotic speed of +.I bm_exec +is +.RI O( len / patlen ). +.PP +.SH "SEE ALSO" +.IR regexp (3), +.IR strstr (3) +.sp +.IR "Fast String Searching" , +Hume and Sunday, +Software Practice and Experience, +Vol. 21, 11 (November 1991) pp. 1221-48. diff --git a/src/lib/libc/string/bm.c b/src/lib/libc/string/bm.c new file mode 100644 index 00000000..68eac22e --- /dev/null +++ b/src/lib/libc/string/bm.c @@ -0,0 +1,220 @@ +/*- + * Copyright (c) 1994 + * The Regents of the University of California. All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Andrew Hume of AT&T Bell Laboratories. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifndef lint +/* from: static char sccsid[] = "@(#)bm.c 8.7 (Berkeley) 6/21/94"; */ +static char *rcsid = "$Id: bm.c,v 1.1.1.1 1995/10/18 08:42:20 deraadt Exp $"; +#endif /* not lint */ + +#include <sys/types.h> + +#include <bm.h> +#include <errno.h> +#include <stdlib.h> +#include <string.h> + +/* + * XXX + * The default frequency table starts at 99 and counts down. The default + * table should probably be oriented toward text, and will necessarily be + * locale specific. This one is for English. It was derived from the + * OSF/1 and 4.4BSD formatted and unformatted manual pages, and about 100Mb + * of email and random text. Change it if you can find something better. + */ +static u_char const freq_def[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 77, 90, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, + 99, 28, 42, 27, 16, 14, 20, 51, + 66, 65, 59, 24, 75, 76, 84, 56, + 72, 74, 64, 55, 54, 47, 41, 37, + 44, 61, 70, 43, 23, 53, 49, 22, + 33, 58, 40, 46, 45, 57, 60, 26, + 30, 63, 21, 12, 32, 50, 38, 39, + 34, 11, 48, 67, 62, 35, 15, 29, + 71, 18, 9, 17, 25, 13, 10, 52, + 36, 95, 78, 86, 87, 98, 82, 80, + 88, 94, 19, 68, 89, 83, 93, 96, + 81, 7, 91, 92, 97, 85, 69, 73, + 31, 79, 8, 5, 4, 6, 3, 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, 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, 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, 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, 0, 0, 0, 0, 0, +}; + +bm_pat * +bm_comp(pb, len, freq) + u_char const *pb; + size_t len; + u_char const *freq; +{ + register u_char const *pe, *p; + register size_t *d, r; + register int j; + int sv_errno; + bm_pat *pat; + + if (len == 0) { + errno = EINVAL; + return (NULL); + } + if ((pat = malloc(sizeof(*pat))) == NULL) + return (NULL); + pat->pat = NULL; + pat->delta = NULL; + + pat->patlen = len; /* copy pattern */ + if ((pat->pat = malloc(pat->patlen)) == NULL) + goto mem; + memcpy(pat->pat, pb, pat->patlen); + /* get skip delta */ + if ((pat->delta = malloc(256 * sizeof(*d))) == NULL) + goto mem; + for (j = 0, d = pat->delta; j < 256; j++) + d[j] = pat->patlen; + for (pe = pb + pat->patlen - 1; pb <= pe; pb++) + d[*pb] = pe - pb; + + if (freq == NULL) /* default freq table */ + freq = freq_def; + r = 0; /* get guard */ + for (pb = pat->pat, pe = pb + pat->patlen - 1; pb < pe; pb++) + if (freq[*pb] < freq[pat->pat[r]]) + r = pb - pat->pat; + pat->rarec = pat->pat[r]; + pat->rareoff = r - (pat->patlen - 1); + + /* get md2 shift */ + for (pe = pat->pat + pat->patlen - 1, p = pe - 1; p >= pat->pat; p--) + if (*p == *pe) + break; + + /* *p is first leftward reoccurrence of *pe */ + pat->md2 = pe - p; + return (pat); + +mem: sv_errno = errno; + bm_free(pat); + errno = sv_errno; + return (NULL); +} + +void +bm_free(pat) + bm_pat *pat; +{ + if (pat->pat != NULL) + free(pat->pat); + if (pat->delta != NULL) + free(pat->delta); + free(pat); +} + +u_char * +bm_exec(pat, base, n) + bm_pat *pat; + u_char *base; + size_t n; +{ + register u_char *e, *ep, *p, *q, *s; + register size_t *d0, k, md2, n1, ro; + register int rc; + + if (n == 0) + return (NULL); + + d0 = pat->delta; + n1 = pat->patlen - 1; + md2 = pat->md2; + ro = pat->rareoff; + rc = pat->rarec; + ep = pat->pat + pat->patlen - 1; + s = base + (pat->patlen - 1); + + /* fast loop up to n - 3 * patlen */ + e = base + n - 3 * pat->patlen; + while (s < e) { + k = d0[*s]; /* ufast skip loop */ + while (k) { + k = d0[*(s += k)]; + k = d0[*(s += k)]; + } + if (s >= e) + break; + if (s[ro] != rc) /* guard test */ + goto mismatch1; + /* fwd match */ + for (p = pat->pat, q = s - n1; p < ep;) + if (*q++ != *p++) + goto mismatch1; + return (s - n1); + +mismatch1: s += md2; /* md2 shift */ + } + + /* slow loop up to end */ + e = base + n; + while (s < e) { + s += d0[*s]; /* step */ + if (s >= e) + break; + if (s[ro] != rc) /* guard test */ + goto mismatch2; + /* fwd match */ + for (p = pat->pat, q = s - n1; p <= ep;) + if (*q++ != *p++) + goto mismatch2; + return (s - n1); + +mismatch2: s += md2; /* md2 shift */ + } + + return (NULL); +} diff --git a/src/lib/libc/string/bstring.3 b/src/lib/libc/string/bstring.3 new file mode 100644 index 00000000..12fcfb0c --- /dev/null +++ b/src/lib/libc/string/bstring.3 @@ -0,0 +1,110 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)bstring.3 6.8 (Berkeley) 4/19/91 +.\" $Id: bstring.3,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt BSTRING 3 +.Os +.Sh NAME +.Nm bcmp , +.Nm bcopy , +.Nm bzero , +.Nm memccpy , +.Nm memchr , +.Nm memcmp , +.Nm memcpy , +.Nm memmove, +.Nm memset +.Nd byte string operations +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft int +.Fn bcmp "const void *b1" "const void *b2" "size_t len" +.Ft void +.Fn bcopy "const void *src" "void *dst" "size_t len" +.Ft void +.Fn bzero "void *b" "size_t len" +.Ft void * +.Fn memchr "const void *b" "int c" "size_t len" +.Ft int +.Fn memcmp "const void *b1" "const void *b2" "size_t len" +.Ft void * +.Fn memccpy "void *dst" "const void *src" "int c" "size_t len" +.Ft void * +.Fn memcpy "void *dst" "const void *src" "size_t len" +.Ft void * +.Fn memmove "void *dst" "const void *src" "size_t len" +.Ft void * +.Fn memset "void *b" "int c" "size_t len" +.Sh DESCRIPTION +These functions operate on variable length strings of bytes. +They do not check for terminating null bytes as the routines +listed in +.Xr string 3 +do. +.Pp +See the specific manual pages for more information. +.Sh SEE ALSO +.Xr bcmp 3 , +.Xr bcopy 3 , +.Xr bzero 3 , +.Xr memccpy 3 , +.Xr memchr 3 , +.Xr memcmp 3 , +.Xr memcpy 3 , +.Xr memmove 3 , +.Xr memset 3 +.Sh STANDARDS +The functions +.Fn memchr , +.Fn memcmp , +.Fn memcpy , +.Fn memmove , +and +.Fn memset +conform to +.St -ansiC . +.Sh HISTORY +The functions +.Fn bzero +and +.Fn memccpy +appeared in +.Bx 4.3 ; +the functions +.Fn bcmp , +.Fn bcopy , +appeared in +.Bx 4.2 . diff --git a/src/lib/libc/string/bzero.3 b/src/lib/libc/string/bzero.3 new file mode 100644 index 00000000..4f0141e0 --- /dev/null +++ b/src/lib/libc/string/bzero.3 @@ -0,0 +1,68 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)bzero.3 5.3 (Berkeley) 4/19/91 +.\" $Id: bzero.3,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt BZERO 3 +.Os BSD 4.3 +.Sh NAME +.Nm bzero +.Nd write zeroes to a byte string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft void +.Fn bzero "void *b" "size_t len" +.Sh DESCRIPTION +The +.Fn bzero +function +writes +.Fa len +zero bytes to the string +.Fa b . +If +.Fa len +is zero, +.Fn bzero +does nothing. +.Sh SEE ALSO +.Xr memset 3 , +.Xr swab 3 +.Sh HISTORY +A +.Fn bzero +function +appeared in +.Bx 4.3 . diff --git a/src/lib/libc/string/bzero.c b/src/lib/libc/string/bzero.c new file mode 100644 index 00000000..4865e396 --- /dev/null +++ b/src/lib/libc/string/bzero.c @@ -0,0 +1,53 @@ +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)bzero.c 5.7 (Berkeley) 2/24/91";*/ +static char *rcsid = "$Id: bzero.c,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * bzero -- vax movc5 instruction + */ +void +bzero(b, length) + void *b; + register size_t length; +{ + register char *p; + + for (p = b; length--;) + *p++ = '\0'; +} diff --git a/src/lib/libc/string/ffs.3 b/src/lib/libc/string/ffs.3 new file mode 100644 index 00000000..6464bea2 --- /dev/null +++ b/src/lib/libc/string/ffs.3 @@ -0,0 +1,63 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)ffs.3 5.3 (Berkeley) 4/19/91 +.\" $Id: ffs.3,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt FFS 3 +.Os +.Sh NAME +.Nm ffs +.Nd find first bit set in a bit string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft int +.Fn ffs "int value" +.Sh DESCRIPTION +The +.Fn ffs +function +finds the first bit set in +.Fa value +and returns the index of that bit. +Bits are numbered starting from 1, starting at the right-most +bit. +A return value of 0 means that the argument was zero. +.Sh SEE ALSO +.Xr bitstring 3 +.Sh HISTORY +The +.Fn ffs +function appeared in +.Bx 4.3 . diff --git a/src/lib/libc/string/ffs.c b/src/lib/libc/string/ffs.c new file mode 100644 index 00000000..42bc87dd --- /dev/null +++ b/src/lib/libc/string/ffs.c @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)ffs.c 5.4 (Berkeley) 5/17/90";*/ +static char *rcsid = "$Id: ffs.c,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * ffs -- vax ffs instruction + */ +int +ffs(mask) + register int mask; +{ + register int bit; + + if (mask == 0) + return(0); + for (bit = 1; !(mask & 1); bit++) + mask >>= 1; + return(bit); +} diff --git a/src/lib/libc/string/index.3 b/src/lib/libc/string/index.3 new file mode 100644 index 00000000..847b0362 --- /dev/null +++ b/src/lib/libc/string/index.3 @@ -0,0 +1,83 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)index.3 5.3 (Berkeley) 4/19/91 +.\" $Id: index.3,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt INDEX 3 +.Os +.Sh NAME +.Nm index +.Nd locate character in string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn index "const char *s" "int c" +.Sh DESCRIPTION +The +.Fn index +function +locates the first character matching +.Fa c +(converted to a +.Em char ) +in the null-terminated string +.Fa s . +.Sh RETURN VALUES +The character +.Fa c +is returned if it is found; otherwise +.Dv NULL +is returned. +If +.Fa c +is '\e0', +.Fn index +locates the terminating '\e0'. +.Sh SEE ALSO +.Xr memchr 3 , +.Xr rindex 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh HISTORY +A +.Fn index +function appeared in +.At v6 . diff --git a/src/lib/libc/string/index.c b/src/lib/libc/string/index.c new file mode 100644 index 00000000..3d9c05f9 --- /dev/null +++ b/src/lib/libc/string/index.c @@ -0,0 +1,56 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)index.c 5.7 (Berkeley) 2/24/91";*/ +static char *rcsid = "$Id: index.c,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +char * +#ifdef STRCHR +strchr(p, ch) +#else +index(p, ch) +#endif + register const char *p, ch; +{ + for (;; ++p) { + if (*p == ch) + return((char *)p); + if (!*p) + return((char *)NULL); + } + /* NOTREACHED */ +} diff --git a/src/lib/libc/string/memccpy.3 b/src/lib/libc/string/memccpy.3 new file mode 100644 index 00000000..61df7040 --- /dev/null +++ b/src/lib/libc/string/memccpy.3 @@ -0,0 +1,73 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)memccpy.3 5.4 (Berkeley) 4/19/91 +.\" $Id: memccpy.3,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt MEMCCPY 3 +.Os +.Sh NAME +.Nm memccpy +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft void * +.Fn memccpy "void *dst" "const void *src" "int c" "size_t len" +.Sh DESCRIPTION +The +.Fn memccpy +function +copies bytes from string +.Fa src +to string +.Fa dst . +If the character +.Fa c +(as converted to an unsigned char) occurs in the string +.Fa src , +the copy stops and a pointer to the byte after the copy of +.Fa c +in the string +.Fa dst +is returned. +Otherwise, +.Fa len +bytes are copied, and a NULL pointer is returned. +.Sh SEE ALSO +.Xr bcopy 3 , +.Xr memcpy 3 , +.Xr memmove 3 , +.Xr strcpy 3 +.Sh HISTORY +The +.Fn memccpy +function is +.Ud . diff --git a/src/lib/libc/string/memccpy.c b/src/lib/libc/string/memccpy.c new file mode 100644 index 00000000..3a1d7bcc --- /dev/null +++ b/src/lib/libc/string/memccpy.c @@ -0,0 +1,59 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)memccpy.c 5.8 (Berkeley) 5/30/91";*/ +static char *rcsid = "$Id: memccpy.c,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +void * +memccpy(t, f, c, n) + void *t; + const void *f; + int c; + register size_t n; +{ + + if (n) { + register unsigned char *tp = t; + register const unsigned char *fp = f; + register unsigned char uc = c; + do { + if ((*tp++ = *fp++) == uc) + return (tp); + } while (--n != 0); + } + return (0); +} diff --git a/src/lib/libc/string/memchr.3 b/src/lib/libc/string/memchr.3 new file mode 100644 index 00000000..265711e3 --- /dev/null +++ b/src/lib/libc/string/memchr.3 @@ -0,0 +1,82 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)memchr.3 5.4 (Berkeley) 6/29/91 +.\" $Id: memchr.3,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt MEMCHR 3 +.Os +.Sh NAME +.Nm memchr +.Nd locate byte in byte string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft void * +.Fn memchr "const void *b" "int c" "size_t len" +.Sh DESCRIPTION +The +.Fn memchr +function +locates the first occurrence of +.Fa c +(converted to an unsigned char) +in string +.Fa b . +.Sh RETURN VALUES +The +.Fn memchr +function +returns a pointer to the byte located, +or NULL if no such byte exists within +.Fa len +bytes. +.Sh SEE ALSO +.Xr index 3 , +.Xr rindex 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn memchr +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/memchr.c b/src/lib/libc/string/memchr.c new file mode 100644 index 00000000..61652c6b --- /dev/null +++ b/src/lib/libc/string/memchr.c @@ -0,0 +1,59 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)memchr.c 5.6 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: memchr.c,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +void * +memchr(s, c, n) + const void *s; + register unsigned char c; + register size_t n; +{ + if (n != 0) { + register const unsigned char *p = s; + + do { + if (*p++ == c) + return ((void *)(p - 1)); + } while (--n != 0); + } + return (NULL); +} diff --git a/src/lib/libc/string/memcmp.3 b/src/lib/libc/string/memcmp.3 new file mode 100644 index 00000000..13901c10 --- /dev/null +++ b/src/lib/libc/string/memcmp.3 @@ -0,0 +1,83 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)memcmp.3 5.5 (Berkeley) 6/29/91 +.\" $Id: memcmp.3,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt MEMCMP 3 +.Os +.Sh NAME +.Nm memcmp +.Nd compare byte string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft int +.Fn memcmp "const void *b1" "const void *b2" "size_t len" +.Sh DESCRIPTION +The +.Fn memcmp +function +compares byte string +.Fa b1 +against byte string +.Fa b2 . +Both strings are assumed to be +.Fa len +bytes long. +.Sh RETURN VALUES +The +.Fn memcmp +function +returns zero if the the two strings are identical, +otherwise returns the difference between the first two differing bytes +(treated as unsigned char values, so that +.Sq Li \e200 +is greater than +.Sq Li \&\e0 , +for example). +Zero-length strings are always identical. +.Sh SEE ALSO +.Xr bcmp 3 , +.Xr strcasecmp 3 , +.Xr strcmp 3 , +.Xr strcoll 3 , +.Xr strxfrm 3 +.Sh STANDARDS +The +.Fn memcmp +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/memcmp.c b/src/lib/libc/string/memcmp.c new file mode 100644 index 00000000..23d2ab23 --- /dev/null +++ b/src/lib/libc/string/memcmp.c @@ -0,0 +1,61 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)memcmp.c 5.6 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: memcmp.c,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * Compare memory regions. + */ +int +memcmp(s1, s2, n) + const void *s1, *s2; + size_t n; +{ + if (n != 0) { + register const unsigned char *p1 = s1, *p2 = s2; + + do { + if (*p1++ != *p2++) + return (*--p1 - *--p2); + } while (--n != 0); + } + return (0); +} diff --git a/src/lib/libc/string/memcpy.3 b/src/lib/libc/string/memcpy.3 new file mode 100644 index 00000000..3f4bb643 --- /dev/null +++ b/src/lib/libc/string/memcpy.3 @@ -0,0 +1,84 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)memcpy.3 5.5 (Berkeley) 6/29/91 +.\" $Id: memcpy.3,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt MEMCPY 3 +.Os +.Sh NAME +.Nm memcpy +.Nd copy byte string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft void * +.Fn memcpy "void *dst" "const void *src" "size_t len" +.Sh DESCRIPTION +The +.Fn memcpy +function +copies +.Fa len +bytes from string +.Fa src +to string +.Fa dst . +.Sh RETURN VALUES +The +.Fn memcpy +function +returns the original value of +.Fa dst . +.Sh SEE ALSO +.Xr bcopy 3 , +.Xr memccpy 3 , +.Xr memmove 3 , +.Xr strcpy 3 +.Sh STANDARDS +The +.Fn memcpy +function +conforms to +.St -ansiC . +.Sh BUGS +In this implementation +.Fn memcpy +is implemented using +.Xr bcopy 3 , +and therefore the strings may overlap. +On other systems, copying overlapping strings may produce surprises. +A simpler solution is to not use +.Fn memcpy . diff --git a/src/lib/libc/string/memmove.3 b/src/lib/libc/string/memmove.3 new file mode 100644 index 00000000..24422e79 --- /dev/null +++ b/src/lib/libc/string/memmove.3 @@ -0,0 +1,76 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)memmove.3 5.5 (Berkeley) 6/29/91 +.\" $Id: memmove.3,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt MEMMOVE 3 +.Os +.Sh NAME +.Nm memmove +.Nd copy byte string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft void * +.Fn memmove "void *dst" "const void *src" "size_t len" +.Sh DESCRIPTION +The +.Fn memmove +function +copies +.Fa len +bytes from string +.Fa src +to string +.Fa dst . +The two strings may overlap; +the copy is always done in a non-destructive manner. +.Sh RETURN VALUES +The +.Fn memmove +function returns the original value of +.Fa dst . +.Sh SEE ALSO +.Xr bcopy 3 , +.Xr memccpy 3 , +.Xr memcpy 3 , +.Xr strcpy 3 +.Sh STANDARDS +The +.Fn memmove +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/memset.3 b/src/lib/libc/string/memset.3 new file mode 100644 index 00000000..1afc0521 --- /dev/null +++ b/src/lib/libc/string/memset.3 @@ -0,0 +1,67 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)memset.3 5.4 (Berkeley) 6/29/91 +.\" $Id: memset.3,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt MEMSET 3 +.Os +.Sh NAME +.Nm memset +.Nd write a byte to byte string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft void * +.Fn memset "void *b" "int c" "size_t len" +.Sh DESCRIPTION +The +.Fn memset +function +writes +.Fa len +bytes of value +.Fa c +(converted to an unsigned char) to the string +.Fa b . +.Sh SEE ALSO +.Xr bzero 3 , +.Xr swab 3 +.Sh STANDARDS +The +.Fn memset +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/memset.c b/src/lib/libc/string/memset.c new file mode 100644 index 00000000..117de2e8 --- /dev/null +++ b/src/lib/libc/string/memset.c @@ -0,0 +1,59 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)memset.c 5.6 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: memset.c,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +void * +memset(dst, c, n) + void *dst; + register int c; + register size_t n; +{ + + if (n != 0) { + register char *d = dst; + + do + *d++ = c; + while (--n != 0); + } + return (dst); +} diff --git a/src/lib/libc/string/rindex.3 b/src/lib/libc/string/rindex.3 new file mode 100644 index 00000000..b13b3513 --- /dev/null +++ b/src/lib/libc/string/rindex.3 @@ -0,0 +1,81 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)rindex.3 5.2 (Berkeley) 4/19/91 +.\" $Id: rindex.3,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt RINDEX 3 +.Os +.Sh NAME +.Nm rindex +.Nd locate character in string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn rindex "const char *s" "int c" +.Sh DESCRIPTION +The +.Fn rindex +function +locates the last character +matching +.Fa c +(converted to a +.Em char ) +in the null-terminated string +.Fa s . +The character c is returned if it is found; otherwise NULL is returned. +If +.Fa c +is +.Ql \e0 , +.Fn rindex +locates the terminating +.Ql \e0 . +.Sh SEE ALSO +.Xr index 3 , +.Xr memchr 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh HISTORY +A +.Fn rindex +function appeared in +.At v6 . diff --git a/src/lib/libc/string/rindex.c b/src/lib/libc/string/rindex.c new file mode 100644 index 00000000..1b84c920 --- /dev/null +++ b/src/lib/libc/string/rindex.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)rindex.c 5.9 (Berkeley) 2/24/91";*/ +static char *rcsid = "$Id: rindex.c,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +char * +#ifdef STRRCHR +strrchr(p, ch) +#else +rindex(p, ch) +#endif + register const char *p, ch; +{ + register char *save; + + for (save = NULL;; ++p) { + if (*p == ch) + save = (char *)p; + if (!*p) + return(save); + } + /* NOTREACHED */ +} diff --git a/src/lib/libc/string/strcasecmp.3 b/src/lib/libc/string/strcasecmp.3 new file mode 100644 index 00000000..46e9010e --- /dev/null +++ b/src/lib/libc/string/strcasecmp.3 @@ -0,0 +1,88 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strcasecmp.3 5.4 (Berkeley) 4/19/91 +.\" $Id: strcasecmp.3,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt STRCASECMP 3 +.Os +.Sh NAME +.Nm strcasecmp +.Nd compare strings, ignoring case +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft int +.Fn strcasecmp "const char *s1" "const char *s2" +.Ft int +.Fn strncasecmp "const char *s1" "const char *s2" "size_t len" +.Sh DESCRIPTION +The +.Fn strcasecmp +and +.Fn strncasecmp +functions +compare the null-terminated strings +.Fa s1 +and +.Fa s2 +and return an integer greater than, equal to, or less than 0, +according as +.Fa s1 +is lexicographically greater than, equal to, or less than +.Fa s2 +after translation of each corresponding character to lower-case. +The strings themselves are not modified. +The comparison is done using unsigned characters, so that +.Sq Li \e200 +is greater than +.Ql \e0 . +.Pp +The +.Fn strncasecmp +compares at most +.Fa len +characters. +.Sh SEE ALSO +.Xr bcmp 3 , +.Xr memcmp 3 , +.Xr strcmp 3 , +.Xr strcoll 3 , +.Xr strxfrm 3 +.Sh HISTORY +The +.Fn strcasecmp +and +.Fn strncasecmp +functions are +.Ud . diff --git a/src/lib/libc/string/strcasecmp.c b/src/lib/libc/string/strcasecmp.c new file mode 100644 index 00000000..79bd0081 --- /dev/null +++ b/src/lib/libc/string/strcasecmp.c @@ -0,0 +1,115 @@ +/* + * Copyright (c) 1987 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static const char sccsid[] = "from: @(#)strcasecmp.c 5.10 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strcasecmp.c,v 1.1.1.1 1995/10/18 08:42:21 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +typedef unsigned char u_char; + +/* + * This array is designed for mapping upper and lower case letter + * together for a case independent comparison. The mappings are + * based upon ascii character sequences. + */ +static const u_char charmap[] = { + '\000', '\001', '\002', '\003', '\004', '\005', '\006', '\007', + '\010', '\011', '\012', '\013', '\014', '\015', '\016', '\017', + '\020', '\021', '\022', '\023', '\024', '\025', '\026', '\027', + '\030', '\031', '\032', '\033', '\034', '\035', '\036', '\037', + '\040', '\041', '\042', '\043', '\044', '\045', '\046', '\047', + '\050', '\051', '\052', '\053', '\054', '\055', '\056', '\057', + '\060', '\061', '\062', '\063', '\064', '\065', '\066', '\067', + '\070', '\071', '\072', '\073', '\074', '\075', '\076', '\077', + '\100', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\133', '\134', '\135', '\136', '\137', + '\140', '\141', '\142', '\143', '\144', '\145', '\146', '\147', + '\150', '\151', '\152', '\153', '\154', '\155', '\156', '\157', + '\160', '\161', '\162', '\163', '\164', '\165', '\166', '\167', + '\170', '\171', '\172', '\173', '\174', '\175', '\176', '\177', + '\200', '\201', '\202', '\203', '\204', '\205', '\206', '\207', + '\210', '\211', '\212', '\213', '\214', '\215', '\216', '\217', + '\220', '\221', '\222', '\223', '\224', '\225', '\226', '\227', + '\230', '\231', '\232', '\233', '\234', '\235', '\236', '\237', + '\240', '\241', '\242', '\243', '\244', '\245', '\246', '\247', + '\250', '\251', '\252', '\253', '\254', '\255', '\256', '\257', + '\260', '\261', '\262', '\263', '\264', '\265', '\266', '\267', + '\270', '\271', '\272', '\273', '\274', '\275', '\276', '\277', + '\300', '\301', '\302', '\303', '\304', '\305', '\306', '\307', + '\310', '\311', '\312', '\313', '\314', '\315', '\316', '\317', + '\320', '\321', '\322', '\323', '\324', '\325', '\326', '\327', + '\330', '\331', '\332', '\333', '\334', '\335', '\336', '\337', + '\340', '\341', '\342', '\343', '\344', '\345', '\346', '\347', + '\350', '\351', '\352', '\353', '\354', '\355', '\356', '\357', + '\360', '\361', '\362', '\363', '\364', '\365', '\366', '\367', + '\370', '\371', '\372', '\373', '\374', '\375', '\376', '\377', +}; + +int +strcasecmp(s1, s2) + const char *s1, *s2; +{ + register const u_char *cm = charmap, + *us1 = (const u_char *)s1, + *us2 = (const u_char *)s2; + + while (cm[*us1] == cm[*us2++]) + if (*us1++ == '\0') + return (0); + return (cm[*us1] - cm[*--us2]); +} + +int +strncasecmp(s1, s2, n) + const char *s1, *s2; + register size_t n; +{ + if (n != 0) { + register const u_char *cm = charmap, + *us1 = (const u_char *)s1, + *us2 = (const u_char *)s2; + + do { + if (cm[*us1] != cm[*us2++]) + return (cm[*us1] - cm[*--us2]); + if (*us1++ == '\0') + break; + } while (--n != 0); + } + return (0); +} diff --git a/src/lib/libc/string/strcat.3 b/src/lib/libc/string/strcat.3 new file mode 100644 index 00000000..5357d657 --- /dev/null +++ b/src/lib/libc/string/strcat.3 @@ -0,0 +1,94 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strcat.3 5.6 (Berkeley) 6/29/91 +.\" $Id: strcat.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRCAT 3 +.Os +.Sh NAME +.Nm strcat +.Nd concatenate strings +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn strcat "char *s" "const char *append" +.Ft char * +.Fn strncat "char *s" "const char *append" "size_t count" +.Sh DESCRIPTION +The +.Fn strcat +and +.Fn strncat +functions +append a copy of the null-terminated string +.Fa append +to the end of the null-terminated string +.Fa s , +then add a terminating +.Ql \e0 . +The string +.Fa s +must have sufficient space to hold the result. +.Pp +The +.Fn strncat +function +appends not more than +.Fa count +characters. +.Sh RETURN VALUES +The +.Fn strcat +and +.Fn strncat +functions +return the pointer +.Fa s . +.Sh SEE ALSO +.Xr bcopy 3 , +.Xr memccpy 3 , +.Xr memcpy 3 , +.Xr memmove 3 , +.Xr strcpy 3 +.Sh STANDARDS +The +.Fn strcat +and +.Fn strncat +functions +conform to +.St -ansiC . diff --git a/src/lib/libc/string/strcat.c b/src/lib/libc/string/strcat.c new file mode 100644 index 00000000..e741b84f --- /dev/null +++ b/src/lib/libc/string/strcat.c @@ -0,0 +1,51 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strcat.c 5.6 (Berkeley) 2/24/91";*/ +static char *rcsid = "$Id: strcat.c,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +char * +strcat(s, append) + register char *s; + register const char *append; +{ + char *save = s; + + for (; *s; ++s); + while (*s++ = *append++); + return(save); +} diff --git a/src/lib/libc/string/strchr.3 b/src/lib/libc/string/strchr.3 new file mode 100644 index 00000000..18b50301 --- /dev/null +++ b/src/lib/libc/string/strchr.3 @@ -0,0 +1,88 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strchr.3 5.4 (Berkeley) 6/29/91 +.\" $Id: strchr.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRCHR 3 +.Os +.Sh NAME +.Nm strchr +.Nd locate character in string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn strchr "const char *s" "int c" +.Sh DESCRIPTION +The +.Fn strchr +function locates the first occurrence of +.Ar c +in the string pointed to by +.Ar s . +The terminating +.Dv NULL +character is considered part of the string. +If +.Fa c +is +.Ql \e0 , +.Fn strchr +locates the terminating +.Ql \e0 . +.Sh RETURN VALUES +The function +.Fn strchr +returns a pointer to the located character, or +.Dv NULL +if the character does not appear in the string. +.Sh SEE ALSO +.Xr index 3 , +.Xr memchr 3 , +.Xr rindex 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strchr +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/strcmp.3 b/src/lib/libc/string/strcmp.3 new file mode 100644 index 00000000..fecaa854 --- /dev/null +++ b/src/lib/libc/string/strcmp.3 @@ -0,0 +1,94 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strcmp.3 5.6 (Berkeley) 6/29/91 +.\" $Id: strcmp.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRCMP 3 +.Os +.Sh NAME +.Nm strcmp +.Nd compare strings +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft int +.Fn strcmp "const char *s1" "const char *s2" +.Ft int +.Fn strncmp "const char *s1" "const char *s2" "size_t len" +.Sh DESCRIPTION +The +.Fn strcmp +and +.Fn strncmp +functions +lexicographically compare the null-terminated strings +.Fa s1 +and +.Fa s2 . +.Sh RETURN VALUES +The +.Fn strcmp +and +.Fn strncmp +return an integer greater than, equal to, or less than 0, according +as the string +.Fa s1 +is greater than, equal to, or less than the string +.Fa s2 . +The comparison is done using unsigned characters, so that +.Ql \e200 +is greater than +.Ql \e0 . +.Pp +The +.Fn strncmp +compares not more than +.Fa len +characters. +.Sh SEE ALSO +.Xr bcmp 3 , +.Xr memcmp 3 , +.Xr strcasecmp 3 , +.Xr strcoll 3 , +.Xr strxfrm 3 +.Sh STANDARDS +The +.Fn strcmp +and +.Fn strncmp +functions +conform to +.St -ansiC . diff --git a/src/lib/libc/string/strcmp.c b/src/lib/libc/string/strcmp.c new file mode 100644 index 00000000..ae19e2e2 --- /dev/null +++ b/src/lib/libc/string/strcmp.c @@ -0,0 +1,55 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strcmp.c 5.5 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strcmp.c,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * Compare strings. + */ +int +strcmp(s1, s2) + register const char *s1, *s2; +{ + while (*s1 == *s2++) + if (*s1++ == 0) + return (0); + return (*(unsigned char *)s1 - *(unsigned char *)--s2); +} diff --git a/src/lib/libc/string/strcoll.3 b/src/lib/libc/string/strcoll.3 new file mode 100644 index 00000000..12f73f98 --- /dev/null +++ b/src/lib/libc/string/strcoll.3 @@ -0,0 +1,75 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strcoll.3 5.6 (Berkeley) 6/29/91 +.\" $Id: strcoll.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRCOLL 3 +.Os +.Sh NAME +.Nm strcoll +.Nd compare strings according to current collation +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft int +.Fn strcoll "const char *s1" "const char *s2" +.Sh DESCRIPTION +The +.Fn strcoll +function +lexicographically compares the null-terminated strings +.Fa s1 +and +.Fa s2 +according to the current locale collation +and returns an integer greater than, equal to, or less than 0, +according as +.Fa s1 +is greater than, equal to, or less than +.Fa s2 . +.Sh SEE ALSO +.Xr bcmp 3 , +.Xr memcmp 3 , +.Xr setlocale 3 , +.Xr strcasecmp 3 , +.Xr strcmp 3 , +.Xr strxfrm 3 +.Sh STANDARDS +The +.Fn strcoll +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/strcoll.c b/src/lib/libc/string/strcoll.c new file mode 100644 index 00000000..86c742cb --- /dev/null +++ b/src/lib/libc/string/strcoll.c @@ -0,0 +1,53 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strcoll.c 5.2 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strcoll.c,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * Compare strings according to LC_COLLATE category of current locale. + */ +int +strcoll(s1, s2) + const char *s1, *s2; +{ + /* LC_COLLATE is unimplemented, hence always "C" */ + return (strcmp(s1, s2)); +} diff --git a/src/lib/libc/string/strcpy.3 b/src/lib/libc/string/strcpy.3 new file mode 100644 index 00000000..1ca12c27 --- /dev/null +++ b/src/lib/libc/string/strcpy.3 @@ -0,0 +1,122 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strcpy.3 5.4 (Berkeley) 6/29/91 +.\" $Id: strcpy.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRCPY 3 +.Os BSD 4 +.Sh NAME +.Nm strcpy +.Nd copy strings +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn strcpy "char *dst" "const char *src" +.Ft char * +.Fn strncpy "char *dst" "const char *src" "size_t len" +.Sh DESCRIPTION +The +.Fn strcpy +and +.Fn strncpy +functions +copy the string +.Fa src +to +.Fa dst +(including the terminating +.Ql \e0 +character). +.Pp +The +.Fn strncpy +copies not more than +.Fa len +characters into +.Fa dst , +appending +.Ql \e0 +characters if +.Fa src +is less than +.Fa len +characters long, and +.Em not +terminating +.Fa dst +if +.Fa src +is more than +.Fa len +characters long. +.Sh RETURN VALUES +The +.Fn strcpy +and +.Fn strncpy +functions +return +.Fa dst . +.Sh EXAMPLES +The following sets +.Dq Li chararray +to +.Dq Li abc\e0\e0\e0 : +.Bd -literal -offset indent +(void)strncpy(chararray, "abc", 6). +.Ed +.Pp +The following sets +.Dq Li chararray +to +.Dq Li abcdef : +.Bd -literal -offset indent +(void)strncpy(chararray, "abcdefgh", 6); +.Ed +.Sh SEE ALSO +.Xr bcopy 3 , +.Xr memccpy 3 , +.Xr memcpy 3 , +.Xr memmove 3 +.Sh STANDARDS +The +.Fn strcpy +and +.Fn strncpy +functions +conform to +.St -ansiC . diff --git a/src/lib/libc/string/strcpy.c b/src/lib/libc/string/strcpy.c new file mode 100644 index 00000000..669bfde2 --- /dev/null +++ b/src/lib/libc/string/strcpy.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strcpy.c 5.7 (Berkeley) 2/24/91";*/ +static char *rcsid = "$Id: strcpy.c,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +char * +strcpy(to, from) + register char *to; + register const char *from; +{ + char *save = to; + + for (; *to = *from; ++from, ++to); + return(save); +} diff --git a/src/lib/libc/string/strcspn.3 b/src/lib/libc/string/strcspn.3 new file mode 100644 index 00000000..cc9e5c2f --- /dev/null +++ b/src/lib/libc/string/strcspn.3 @@ -0,0 +1,85 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strcspn.3 5.3 (Berkeley) 6/29/91 +.\" $Id: strcspn.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRCSPN 3 +.Os +.Sh NAME +.Nm strcspn +.Nd span the complement of a string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft size_t +.Fn strcspn "const char *s" "const char *charset" +.Sh DESCRIPTION +The +.Fn strcspn +function +spans the initial part of the null-terminated string +.Fa s +as long as the characters from +.Fa s +do not occur in string +.Fa charset +(it +spans the +.Em complement +of +.Fa charset ) . +.Sh RETURN VALUES +The +.Fn strcspn +function +returns the number of characters spanned. +.Sh SEE ALSO +.Xr index 3 , +.Xr memchr 3 , +.Xr rindex 3 , +.Xr strchr 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strcspn +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/strcspn.c b/src/lib/libc/string/strcspn.c new file mode 100644 index 00000000..acb4d2a3 --- /dev/null +++ b/src/lib/libc/string/strcspn.c @@ -0,0 +1,68 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strcspn.c 5.6 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strcspn.c,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * Span the complement of string s2. + */ +size_t +strcspn(s1, s2) + const char *s1; + register const char *s2; +{ + register const char *p, *spanp; + register char c, sc; + + /* + * Stop as soon as we find any character from s2. Note that there + * must be a NUL in s2; it suffices to stop when we find that, too. + */ + for (p = s1;;) { + c = *p++; + spanp = s2; + do { + if ((sc = *spanp++) == c) + return (p - 1 - s1); + } while (sc != 0); + } + /* NOTREACHED */ +} diff --git a/src/lib/libc/string/strdup.3 b/src/lib/libc/string/strdup.3 new file mode 100644 index 00000000..925cbf3d --- /dev/null +++ b/src/lib/libc/string/strdup.3 @@ -0,0 +1,65 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strdup.3 5.3 (Berkeley) 4/19/91 +.\" $Id: strdup.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt STRDUP 3 +.Os +.Sh NAME +.Nm strdup +.Nd save a copy of a string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn strdup "const char *str" +.Sh DESCRIPTION +The +.Fn strdup +function +allocates sufficient memory for a copy +of the string +.Fa str , +does the copy, and returns a pointer to it. +The pointer may subsequently be used as an +argument to the function +.Xr free 3 . +.Sh SEE ALSO +.Xr free 3 , +.Xr malloc 3 , +.Xt strcpy 3 , +.Xt strlen 3 +.Sh HISTORY +The +.Fn strdup +function +.Ud . diff --git a/src/lib/libc/string/strdup.c b/src/lib/libc/string/strdup.c new file mode 100644 index 00000000..27ede441 --- /dev/null +++ b/src/lib/libc/string/strdup.c @@ -0,0 +1,54 @@ +/* + * Copyright (c) 1988 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strdup.c 5.4 (Berkeley) 2/24/91";*/ +static char *rcsid = "$Id: strdup.c,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <stdlib.h> +#include <string.h> + +char * +strdup(str) + const char *str; +{ + size_t len; + char *copy; + + len = strlen(str) + 1; + if (!(copy = malloc(len))) + return((char *)NULL); + memcpy(copy, str, len); + return(copy); +} diff --git a/src/lib/libc/string/strerror.3 b/src/lib/libc/string/strerror.3 new file mode 100644 index 00000000..c9d8504d --- /dev/null +++ b/src/lib/libc/string/strerror.3 @@ -0,0 +1,66 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strerror.3 6.9 (Berkeley) 6/29/91 +.\" $Id: strerror.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRERROR 3 +.Os BSD 4 +.Sh NAME +.Nm strerror +.Nd get error message string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn strerror "int errnum" +.Sh DESCRIPTION +The +.Fn strerror +function returns a pointer to the language-dependent error message +string affiliated with an error number. +.Pp +The array pointed to is not to be modified by the program, but may be +overwritten by subsequent calls to +.Fn strerror . +.Sh SEE ALSO +.Xr intro 2 , +.Xr perror 3 , +.Xr setlocale 3 +.Sh STANDARDS +The +.Fn strerror +function conforms to +.St -ansiC . diff --git a/src/lib/libc/string/strerror.c b/src/lib/libc/string/strerror.c new file mode 100644 index 00000000..c3f5ab5d --- /dev/null +++ b/src/lib/libc/string/strerror.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strerror.c 5.6 (Berkeley) 5/4/91";*/ +static char *rcsid = "$Id: strerror.c,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> +#include <limits.h> + +/* + * Since perror() is not allowed to change the contents of strerror()'s + * static buffer, both functions supply their own buffers to the + * internal function __strerror(). + */ + +extern char *__strerror __P((int, char *)); + +char * +strerror(num) + int num; +{ + static char buf[NL_TEXTMAX]; + return __strerror(num, buf); +} diff --git a/src/lib/libc/string/strftime.3 b/src/lib/libc/string/strftime.3 new file mode 100644 index 00000000..f14db4bb --- /dev/null +++ b/src/lib/libc/string/strftime.3 @@ -0,0 +1,202 @@ +.\" Copyright (c) 1989, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strftime.3 5.12 (Berkeley) 6/29/91 +.\" $Id: strftime.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRFTIME 3 +.Os +.Sh NAME +.Nm strftime +.Nd format date and time +.Sh SYNOPSIS +.Fd #include <time.h> +.Ft size_t +.Fn strftime "char *buf" "size_t maxsize" "const char *format" "const struct tm *timeptr" +.Sh DESCRIPTION +The +.Fn strftime +function formats the information from +.Fa timeptr +into the buffer +.Fa buf +according to the string pointed to by +.Fa format . +.Pp +The +.Fa format +string consists of zero or more conversion specifications and +ordinary characters. +All ordinary characters are copied directly into the buffer. +A conversion specification consists of a percent sign +.Ql % +and one other character. +.Pp +No more than +.Fa maxsize +characters will be placed into the array. +If the total number of resulting characters, including the terminating +null character, is not more than +.Fa maxsize , +.Fn strftime +returns the number of characters in the array, not counting the +terminating null. +Otherwise, zero is returned. +.Pp +Each conversion specification is replaced by the characters as +follows which are then copied into the buffer. +.Bl -tag -width "xxxx" +.It Cm \&%A +is replaced by the locale's full weekday name. +.It Cm %a +is replaced by the locale's abbreviated weekday name. +.It Cm \&%B +is replaced by the locale's full month name. +.It Cm \&%b No or Cm \&%h +is replaced by the locale's abbreviated month name. +.It Cm \&%C +is replaced by the century (a year divided by 100 and truncated to an integer) +as a decimal number (00-99). +.It Cm \&%c +is replaced by the locale's appropriate date and time representation. +.It Cm \&%D +is replaced by the date in the format +.Dq Li %m/%d/%y . +.It Cm \&%d +is replaced by the day of the month as a decimal number (01-31). +.It Cm \&%e +is replaced by the day of month as a decimal number (1-31); +single digits are preceded by a blank. +.It Cm \&%H +is replaced by the hour (24-hour clock) as a decimal number (00-23). +.It Cm \&%I +is replaced by the hour (12-hour clock) as a decimal number (01-12). +.It Cm \&%j +is replaced by the day of the year as a decimal number (001-366). +.It Cm \&%k +is replaced by the hour (24-hour clock) as a decimal number (0-23); +single digits are preceded by a blank. +.It Cm \&%l +is replaced by the hour (12-hour clock) as a decimal number (1-12); +single digits are preceded by a blank. +.It Cm \&%M +is replaced by the minute as a decimal number (00-59). +.It Cm %m +is replaced by the month as a decimal number (01-12). +.It Cm %n +is replaced by a newline. +.It Cm %p +is replaced by the locale's equivalent of either +.Dq Tn AM +or +.Dq Tn PM . +.It Cm \&%R +is replaced by the time in the format +.Dq Li %H:%M . +.It Cm \&%r +is replaced by the locale's representation of 12-hour clock time +using AM/PM notation. +.It Cm \&%T +is replaced by the time in the format +.Dq Li %H:%M:%S . +.It Cm \&%t +is replaced by a tab. +.It Cm \&%S +is replaced by the second as a decimal number (00-60). +.It Cm %s +is replaced by the number of seconds since the Epoch, UCT (see +.Xr mktime 3 ) . +.It Cm \&%U +is replaced by the week number of the year (Sunday as the first day of +the week) as a decimal number (00-53). +.It Cm \&%u +is replaced by the weekday (Monday as the first day of the week) +as a decimal number (1-7). +.It Cm \&%V +is replaced by the week number of the year (Monday as the first day of +the week) as a decimal number (01-53). If the week containing January +1 has four or more days in the new year, then it is week 1; otherwise +it is week 53 of the previous year, and the next week is week 1. +.It Cm \&%W +is replaced by the week number of the year (Monday as the first day of +the week) as a decimal number (00-53). +.It Cm \&%w +is replaced by the weekday (Sunday as the first day of the week) +as a decimal number (0-6). +.It Cm \&%X +is replaced by the locale's appropriate date representation. +.It Cm \&%x +is replaced by the locale's appropriate time representation. +.It Cm \&%Y +is replaced by the year with century as a decimal number. +.It Cm \&%y +is replaced by the year without century as a decimal number (00-99). +.It Cm \&%Z +is replaced by the time zone name. +.It Cm %% +is replaced by +.Ql % . +.El +.Sh SEE ALSO +.Xr date 1 , +.Xr ctime 3 , +.Xr printf 1 , +.Xr printf 3 +.Sh STANDARDS +The +.Fn strftime +function +conforms to +.St -ansiC . +The +.Ql \&%C , +.Ql \&%D , +.Ql \&%e , +.Ql \&%h , +.Ql \&%k , +.Ql \&%l , +.Ql \&%n , +.Ql \&%r , +.Ql \&%R , +.Ql \&%s . +.Ql \&%t , +.Ql \&%T , +.Ql \&%u , +and +.Ql \&%V +conversion specifications are extensions. +.Sh BUGS +There is no conversion specification for the phase of the moon. diff --git a/src/lib/libc/string/strftime.c b/src/lib/libc/string/strftime.c new file mode 100644 index 00000000..fffa9ecb --- /dev/null +++ b/src/lib/libc/string/strftime.c @@ -0,0 +1,317 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strftime.c 5.11 (Berkeley) 2/24/91";*/ +static char *rcsid = "$Id: strftime.c,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/localedef.h> +#include <locale.h> +#include <string.h> +#include <tzfile.h> +#include <time.h> + +static size_t gsize; +static char *pt; +static int _add(), _conv(), _secs(); +static size_t _fmt(); + +size_t +strftime(s, maxsize, format, t) + char *s; + size_t maxsize; + const char *format; + const struct tm *t; +{ + tzset(); + + pt = s; + if ((gsize = maxsize) < 1) + return(0); + if (_fmt(format, t)) { + *pt = '\0'; + return(maxsize - gsize); + } + return(0); +} + +#define SUN_WEEK(t) (((t)->tm_yday + 7 - \ + ((t)->tm_wday)) / 7) +#define MON_WEEK(t) (((t)->tm_yday + 7 - \ + ((t)->tm_wday ? (t)->tm_wday - 1 : 6)) / 7) +static size_t +_fmt(format, t) + register char *format; + struct tm *t; +{ + for (; *format; ++format) { + if (*format == '%') { + ++format; + if (*format == 'E') { + /* Alternate Era */ + ++format; + } else if (*format == 'O') { + /* Alternate numeric symbols */ + ++format; + } + switch(*format) { + case '\0': + --format; + break; + case 'A': + if (t->tm_wday < 0 || t->tm_wday > 6) + return(0); + if (!_add(_CurrentTimeLocale->day[t->tm_wday])) + return(0); + continue; + case 'a': + if (t->tm_wday < 0 || t->tm_wday > 6) + return(0); + if (!_add(_CurrentTimeLocale->abday[t->tm_wday])) + return(0); + continue; + case 'B': + if (t->tm_mon < 0 || t->tm_mon > 11) + return(0); + if (!_add(_CurrentTimeLocale->mon[t->tm_mon])) + return(0); + continue; + case 'b': + case 'h': + if (t->tm_mon < 0 || t->tm_mon > 11) + return(0); + if (!_add(_CurrentTimeLocale->abmon[t->tm_mon])) + return(0); + continue; + case 'C': + if (!_conv((t->tm_year + TM_YEAR_BASE) / 100, + 2, '0')) + return(0); + continue; + case 'c': + if (!_fmt(_CurrentTimeLocale->d_t_fmt, t)) + return(0); + continue; + case 'D': + if (!_fmt("%m/%d/%y", t)) + return(0); + continue; + case 'd': + if (!_conv(t->tm_mday, 2, '0')) + return(0); + continue; + case 'e': + if (!_conv(t->tm_mday, 2, ' ')) + return(0); + continue; + case 'H': + if (!_conv(t->tm_hour, 2, '0')) + return(0); + continue; + case 'I': + if (!_conv(t->tm_hour % 12 ? + t->tm_hour % 12 : 12, 2, '0')) + return(0); + continue; + case 'j': + if (!_conv(t->tm_yday + 1, 3, '0')) + return(0); + continue; + case 'k': + if (!_conv(t->tm_hour, 2, ' ')) + return(0); + continue; + case 'l': + if (!_conv(t->tm_hour % 12 ? + t->tm_hour % 12: 12, 2, ' ')) + return(0); + continue; + case 'M': + if (!_conv(t->tm_min, 2, '0')) + return(0); + continue; + case 'm': + if (!_conv(t->tm_mon + 1, 2, '0')) + return(0); + continue; + case 'n': + if (!_add("\n")) + return(0); + continue; + case 'p': + if (!_add(_CurrentTimeLocale->am_pm[t->tm_hour >= 12])) + return(0); + continue; + case 'R': + if (!_fmt("%H:%M", t)) + return(0); + continue; + case 'r': + if (!_fmt(_CurrentTimeLocale->t_fmt_ampm, t)) + return(0); + continue; + case 'S': + if (!_conv(t->tm_sec, 2, '0')) + return(0); + continue; + case 's': + if (!_secs(t)) + return(0); + continue; + case 'T': + if (!_fmt("%H:%M:%S", t)) + return(0); + continue; + case 't': + if (!_add("\t")) + return(0); + continue; + case 'U': + if (!_conv(SUN_WEEK(t), 2, '0')) + return(0); + continue; + case 'u': + if (!_conv(t->tm_wday ? t->tm_wday : 7, 2, '0')) + return(0); + continue; + case 'V': + { + /* ISO 8601 Week Of Year: + If the week (Monday - Sunday) containing + January 1 has four or more days in the new + year, then it is week 1; otherwise it is + week 53 of the previous year and the next + week is week one. */ + + int week = MON_WEEK(t); + + if (((t->tm_yday + 7 - (t->tm_wday + 1)) % 7) >= 4) { + week++; + } else if (week == 0) { + week = 53; + } + + if (!_conv(week, 2, '0')) + return(0); + continue; + } + case 'W': + if (!_conv(MON_WEEK(t), 2, '0')) + return(0); + continue; + case 'w': + if (!_conv(t->tm_wday, 1, '0')) + return(0); + continue; + case 'x': + if (!_fmt(_CurrentTimeLocale->d_fmt, t)) + return(0); + continue; + case 'X': + if (!_fmt(_CurrentTimeLocale->t_fmt, t)) + return(0); + continue; + case 'y': + if (!_conv((t->tm_year + TM_YEAR_BASE) % 100, + 2, '0')) + return(0); + continue; + case 'Y': + if (!_conv((t->tm_year + TM_YEAR_BASE), 4, '0')) + return(0); + continue; + case 'Z': + if (t->tm_zone && !_add(t->tm_zone)) + return(0); + continue; + case '%': + /* + * X311J/88-090 (4.12.3.5): if conversion char is + * undefined, behavior is undefined. Print out the + * character itself as printf(3) does. + */ + default: + break; + } + } + if (!gsize--) + return(0); + *pt++ = *format; + } + return(gsize); +} + +static +_secs(t) + struct tm *t; +{ + static char buf[15]; + register time_t s; + register char *p; + struct tm tmp; + + /* Make a copy, mktime(3) modifies the tm struct. */ + tmp = *t; + s = mktime(&tmp); + for (p = buf + sizeof(buf) - 2; s > 0 && p > buf; s /= 10) + *p-- = s % 10 + '0'; + return(_add(++p)); +} + +static +_conv(n, digits, pad) + int n, digits; + char pad; +{ + static char buf[10]; + register char *p; + + for (p = buf + sizeof(buf) - 2; n > 0 && p > buf; n /= 10, --digits) + *p-- = n % 10 + '0'; + while (p > buf && digits-- > 0) + *p-- = pad; + return(_add(++p)); +} + +static +_add(str) + register char *str; +{ + for (;; ++pt, --gsize) { + if (!gsize) + return(0); + if (!(*pt = *str++)) + return(1); + } +} diff --git a/src/lib/libc/string/string.3 b/src/lib/libc/string/string.3 new file mode 100644 index 00000000..aaf97e03 --- /dev/null +++ b/src/lib/libc/string/string.3 @@ -0,0 +1,156 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)string.3 6.9 (Berkeley) 4/19/91 +.\" $Id: string.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt STRING 3 +.Os BSD 4 +.Sh NAME +.Nm strcat , +.Nm strncat , +.Nm strchr , +.Nm strrchr , +.Nm strcmp , +.Nm strncmp , +.Nm strcasecmp, +.Nm strncasecmp , +.Nm strcpy , +.Nm strncpy , +.Nm strerror , +.Nm strlen , +.Nm strpbrk , +.Nm strsep, +.Nm strspn , +.Nm strcspn , +.Nm strstr , +.Nm strtok , +.Nm index , +.Nm rindex +.Nd string specific functions +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn strcat "char *s" "const char * append" +.Ft char * +.Fn strncat "char *s" "const char *append" "size_t count" +.Ft char * +.Fn strchr "const char *s" "int c" +.Ft char * +.Fn strrchr "const char *s" "int c" +.Ft int +.Fn strcmp "const char *s1" "const char *s2" +.Ft int +.Fn strncmp "const char *s1" "const char *s2" "size_t count" +.Ft int +.Fn strcasecmp "const char *s1" "const char *s2" +.Ft int +.Fn strncasecmp "const char *s1" "const char *s2" "size_t count" +.Ft char * +.Fn strcpy "char *dst" "const char *src" +.Ft char * +.Fn strncpy "char *dst" "const char *src" "size_t count" +.Ft char * +.Fn strerror "int errno" +.Ft size_t +.Fn strlen "const char *s" +.Ft char * +.Fn strpbrk "const char *s" "const char *charset" +.Ft char * +.Fn strsep "char **stringp" "const char *delim" +.Ft size_t +.Fn strspn "const char *s" "const char *charset" +.Ft size_t +.Fn strcspn "const char *s" "const char *charset" +.Ft char * +.Fn strstr "const char *big" "const char *little" +.Ft char * +.Fn strtok "char *s" "const char *delim" +.Ft char * +.Fn index "const char *s" "int c" +.Ft char * +.Fn rindex "const char *s" "int c" +.Sh DESCRIPTION +The string functions +functions manipulate strings terminated by a +null byte. +.Pp +See the specific manual pages for more information. +For manipulating variable length generic objects as byte +strings (without the null byte check), see +.Xr bstring 3 . +.Pp +Except as noted in their specific manual pages, +the string functions do not test the destination +for size limitations. +.Sh SEE ALSO +.Xr index 3 , +.Xr strcat 3 , +.Xr strchr 3 , +.Xr strrchr 3 , +.Xr strcmp 3 , +.Xr strcasecmp 3 , +.Xr strcpy 3 , +.Xr strerror 3 , +.Xr strlen 3 , +.Xr strpbrk 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strcspn 3 , +.Xr strstr 3 , +.Xr strtok 3 , +.Xr rindex 3 +.Xr bstring 3 +.Sh STANDARDS +The +.Fn strcat , +.Fn strncat , +.Fn strchr , +.Fn strrchr , +.Fn strcmp , +.Fn strncmp , +.Fn strcpy , +.Fn strncpy , +.Fn strerror , +.Fn strlen , +.Fn strpbrk , +.Fn strsep , +.Fn strspn , +.Fn strcspn , +.Fn strstr , +and +.Fn strtok +functions +conform to +.St -ansiC . diff --git a/src/lib/libc/string/strlen.3 b/src/lib/libc/string/strlen.3 new file mode 100644 index 00000000..f4aff363 --- /dev/null +++ b/src/lib/libc/string/strlen.3 @@ -0,0 +1,71 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strlen.3 5.4 (Berkeley) 6/29/91 +.\" $Id: strlen.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRLEN 3 +.Os +.Sh NAME +.Nm strlen +.Nd find length of string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft size_t +.Fn strlen "const char *s" +.Sh DESCRIPTION +The +.Fn strlen +function +computes the length of the string +.Fa s . +.Sh RETURN VALUES +The +.Fn strlen +function +returns +the number of characters that precede the +terminating +.Dv NUL +character. +.Sh SEE ALSO +.Xr string 3 +.Sh STANDARDS +The +.Fn strlen +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/strlen.c b/src/lib/libc/string/strlen.c new file mode 100644 index 00000000..d23aadaf --- /dev/null +++ b/src/lib/libc/string/strlen.c @@ -0,0 +1,50 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strlen.c 5.5 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strlen.c,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +size_t +strlen(str) + const char *str; +{ + register const char *s; + + for (s = str; *s; ++s); + return(s - str); +} + diff --git a/src/lib/libc/string/strmode.3 b/src/lib/libc/string/strmode.3 new file mode 100644 index 00000000..1907e7ab --- /dev/null +++ b/src/lib/libc/string/strmode.3 @@ -0,0 +1,149 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strmode.3 5.4 (Berkeley) 7/31/91 +.\" $Id: strmode.3,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $ +.\" +.Dd July 31, 1991 +.Dt STRMODE 3 +.Os +.Sh NAME +.Nm strmode +.Nd convert inode status information into a symbolic string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft void +.Fn strmode "mode_t mode" "char *bp" +.Sh DESCRIPTION +The +.Fn strmode +function +converts a file +.Fa mode +(the type and permission information associated with an inode, see +.Xr stat 2 ) +into a symbolic string which is stored in the location referenced by +.Fa bp . +This stored string is eleven characters in length plus a trailing +.Dv NULL . +.Pp +The first character is the inode type, and will be one of the following: +.Pp +.Bl -tag -width flag -offset indent -compact +.It \- +regular file +.It b +block special +.It c +character special +.It d +directory +.It l +symbolic link +.It p +fifo +.It s +socket +.It ? +unknown inode type +.El +.Pp +The next nine characters encode three sets of permissions, in three +characters each. +The first three characters are the permissions for the owner of the +file, the second three for the group the file belongs to, and the +third for the ``other'', or default, set of users. +.Pp +Permission checking is done as specifically as possible. +If read permission is denied to the owner of a file in the first set +of permissions, the owner of the file will not be able to read the file. +This is true even if the owner is in the file's group and the group +permissions allow reading or the ``other'' permissions allow reading. +.Pp +If the first character of the three character set is an ``r'', the file is +readable for that set of users; if a dash ``\-'', it is not readable. +.Pp +If the second character of the three character set is a ``w'', the file is +writable for that set of users; if a dash ``\-'', it is not writable. +.Pp +The third character is the first of the following characters that apply: +.Bl -tag -width xxxx +.It S +If the character is part of the owner permissions and the file is not +executable or the directory is not searchable, by the owner, and the +set-user-id bit is set. +.It S +If the character is part of the group permissions and the file is not +executable or the directory is not searchable, by the group, and the +set-group-id bit is set. +.It T +If the character is part of the other permissions and the file is not +executable or the directory is not searchable, by others, and the ``sticky'' +.Pq Dv S_ISVTX +bit is set. +.It s +If the character is part of the owner permissions and the file is +executable or the directory searchable, by the owner, and the set-user-id +bit is set. +.It s +If the character is part of the group permissions and the file is +executable or the directory searchable, by the group, and the set-group-id +bit is set. +.It t +If the character is part of the other permissions and the file is +executable or the directory searchable, by others, and the ``sticky'' +.Pq Dv S_ISVTX +bit is set. +.It x +The file is executable or the directory is searchable. +.It \- +None of the above apply. +.El +.Pp +The last character is a plus sign ``+'' if any there are any alternate +or additional access control methods associated with the inode, otherwise +it will be a space. +.Sh RETURN VALUES +The +.Fn strmode +function +always returns 0. +.Sh SEE ALSO +.Xr chmod 1 , +.Xr find 1 , +.Xr stat 2 , +.Xr getmode 3 , +.Xr setmode 3 +.Sh HISTORY +The +.Fn strmode +function +.Ud . diff --git a/src/lib/libc/string/strmode.c b/src/lib/libc/string/strmode.c new file mode 100644 index 00000000..441fc76e --- /dev/null +++ b/src/lib/libc/string/strmode.c @@ -0,0 +1,148 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strmode.c 5.3 (Berkeley) 5/18/90";*/ +static char *rcsid = "$Id: strmode.c,v 1.1.1.1 1995/10/18 08:42:22 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <sys/stat.h> +#include <string.h> + +void +strmode(mode, p) + register mode_t mode; + register char *p; +{ + /* print type */ + switch (mode & S_IFMT) { + case S_IFDIR: /* directory */ + *p++ = 'd'; + break; + case S_IFCHR: /* character special */ + *p++ = 'c'; + break; + case S_IFBLK: /* block special */ + *p++ = 'b'; + break; + case S_IFREG: /* regular */ + *p++ = '-'; + break; + case S_IFLNK: /* symbolic link */ + *p++ = 'l'; + break; + case S_IFSOCK: /* socket */ + *p++ = 's'; + break; +#ifdef S_IFIFO + case S_IFIFO: /* fifo */ + *p++ = 'p'; + break; +#endif + default: /* unknown */ + *p++ = '?'; + break; + } + /* usr */ + if (mode & S_IRUSR) + *p++ = 'r'; + else + *p++ = '-'; + if (mode & S_IWUSR) + *p++ = 'w'; + else + *p++ = '-'; + switch (mode & (S_IXUSR | S_ISUID)) { + case 0: + *p++ = '-'; + break; + case S_IXUSR: + *p++ = 'x'; + break; + case S_ISUID: + *p++ = 'S'; + break; + case S_IXUSR | S_ISUID: + *p++ = 's'; + break; + } + /* group */ + if (mode & S_IRGRP) + *p++ = 'r'; + else + *p++ = '-'; + if (mode & S_IWGRP) + *p++ = 'w'; + else + *p++ = '-'; + switch (mode & (S_IXGRP | S_ISGID)) { + case 0: + *p++ = '-'; + break; + case S_IXGRP: + *p++ = 'x'; + break; + case S_ISGID: + *p++ = 'S'; + break; + case S_IXGRP | S_ISGID: + *p++ = 's'; + break; + } + /* other */ + if (mode & S_IROTH) + *p++ = 'r'; + else + *p++ = '-'; + if (mode & S_IWOTH) + *p++ = 'w'; + else + *p++ = '-'; + switch (mode & (S_IXOTH | S_ISVTX)) { + case 0: + *p++ = '-'; + break; + case S_IXOTH: + *p++ = 'x'; + break; + case S_ISVTX: + *p++ = 'T'; + break; + case S_IXOTH | S_ISVTX: + *p++ = 't'; + break; + } + *p++ = ' '; /* will be a '+' if ACL's implemented */ + *p = '\0'; +} diff --git a/src/lib/libc/string/strncat.c b/src/lib/libc/string/strncat.c new file mode 100644 index 00000000..3d96452a --- /dev/null +++ b/src/lib/libc/string/strncat.c @@ -0,0 +1,68 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strncat.c 5.6 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strncat.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * Concatenate src on the end of dst. At most strlen(dst)+n+1 bytes + * are written at dst (at most n+1 bytes being appended). Return dst. + */ +char * +strncat(dst, src, n) + char *dst; + const char *src; + register size_t n; +{ + if (n != 0) { + register char *d = dst; + register const char *s = src; + + while (*d != 0) + d++; + do { + if ((*d = *s++) == 0) + break; + d++; + } while (--n != 0); + *d = 0; + } + return (dst); +} diff --git a/src/lib/libc/string/strncmp.c b/src/lib/libc/string/strncmp.c new file mode 100644 index 00000000..0638d4dc --- /dev/null +++ b/src/lib/libc/string/strncmp.c @@ -0,0 +1,56 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strncmp.c 5.6 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strncmp.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +int +strncmp(s1, s2, n) + register const char *s1, *s2; + register size_t n; +{ + + if (n == 0) + return (0); + do { + if (*s1 != *s2++) + return (*(unsigned char *)s1 - *(unsigned char *)--s2); + if (*s1++ == 0) + break; + } while (--n != 0); + return (0); +} diff --git a/src/lib/libc/string/strncpy.c b/src/lib/libc/string/strncpy.c new file mode 100644 index 00000000..5215311b --- /dev/null +++ b/src/lib/libc/string/strncpy.c @@ -0,0 +1,68 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strncpy.c 5.6 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strncpy.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * Copy src to dst, truncating or null-padding to always copy n bytes. + * Return dst. + */ +char * +strncpy(dst, src, n) + char *dst; + const char *src; + register size_t n; +{ + if (n != 0) { + register char *d = dst; + register const char *s = src; + + do { + if ((*d++ = *s++) == 0) { + /* NUL pad the remaining n-1 bytes */ + while (--n != 0) + *d++ = 0; + break; + } + } while (--n != 0); + } + return (dst); +} diff --git a/src/lib/libc/string/strpbrk.3 b/src/lib/libc/string/strpbrk.3 new file mode 100644 index 00000000..8578546c --- /dev/null +++ b/src/lib/libc/string/strpbrk.3 @@ -0,0 +1,80 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strpbrk.3 5.4 (Berkeley) 6/29/91 +.\" $Id: strpbrk.3,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRPBRK 3 +.Os +.Sh NAME +.Nm strpbrk +.Nd locate multiple characters in string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn strpbrk "const char *s" "const char *charset" +.Sh DESCRIPTION +The +.Fn strpbrk +function +locates in the null-terminated string +.Fa s +the first occurrence of any character in the string +.Fa charset +and returns a pointer to this character. +If no characters from +.Fa charset +occur anywhere in +.Fa s +.Fn strpbrk +returns NULL. +.Sh SEE ALSO +.Xr index 3 , +.Xr memchr 3 , +.Xr rindex 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strpbrk +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/strpbrk.c b/src/lib/libc/string/strpbrk.c new file mode 100644 index 00000000..f1d542a5 --- /dev/null +++ b/src/lib/libc/string/strpbrk.c @@ -0,0 +1,57 @@ +/* + * Copyright (c) 1985 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strpbrk.c 5.8 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strpbrk.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * Find the first occurrence in s1 of a character in s2 (excluding NUL). + */ +char * +strpbrk(s1, s2) + register const char *s1, *s2; +{ + register const char *scanp; + register int c, sc; + + while ((c = *s1++) != 0) { + for (scanp = s2; (sc = *scanp++) != 0;) + if (sc == c) + return ((char *)(s1 - 1)); + } + return (NULL); +} diff --git a/src/lib/libc/string/strrchr.3 b/src/lib/libc/string/strrchr.3 new file mode 100644 index 00000000..1d98cbff --- /dev/null +++ b/src/lib/libc/string/strrchr.3 @@ -0,0 +1,91 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strrchr.3 5.3 (Berkeley) 6/29/91 +.\" $Id: strrchr.3,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRRCHR 3 +.Os +.Sh NAME +.Nm strrchr +.Nd locate character in string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn strrchr "const char *s" "int c" +.Sh DESCRIPTION +The +.Fn strrchr +function +locates the last occurrence of +.Fa c +(converted to a char) +in the string +.Fa s . +If +.Fa c +is +.Ql \e0 , +.Fn strrchr +locates the terminating +.Ql \e0 . +.Sh RETURN VALUES +The +.Fn strrchr +function +returns a pointer to the character, +or a null +pointer if +.Fa c +does not occur anywhere in +.Fa s . +.Sh SEE ALSO +.Xr index 3 , +.Xr memchr 3 , +.Xr rindex 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strrchr +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/strsep.3 b/src/lib/libc/string/strsep.3 new file mode 100644 index 00000000..21aa7376 --- /dev/null +++ b/src/lib/libc/string/strsep.3 @@ -0,0 +1,92 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek. +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strsep.3 5.3 (Berkeley) 4/19/91 +.\" $Id: strsep.3,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $ +.\" +.Dd April 19, 1991 +.Dt STRSEP 3 +.Os +.Sh NAME +.Nm strsep +.Nd separate strings +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn strsep "char **stringp" "char *delim" +.Sh DESCRIPTION +The +.Fn strsep +locates in the null-terminated string at +.Fa *stringp +the first occurrence of any character in +.Fa delim +and replaces this with a +.Ql \e0 , +records the location of the immediate following character in +.Fa *stringp , +then returns the original value of +.Fa *stringp . +If no delimiter characters are found, +.Fn strsep +sets +.Fa *stringp +to +.Dv NULL ; +if +.Fa *stringp +is initially +.Dv NULL , +.Fn strsep +returns +.Dv NULL . +.Sh EXAMPLES +The following uses +.Fn strsep +to parse strings containing runs of white space, +making up an argument vector: +.Bd -literal -offset indent +char inputstring[100]; +char **argv[51], **ap = argv, *p, *val; +/* set up inputstring */ +for (p = inputstring; p != NULL; ) { + while ((val = strsep(&p, " \et")) != NULL && *val == '\e0'); + *ap++ = val; +} +*ap = 0; +.Ed +.Sh HISTORY +The +.Fn strsep +function is +.Ud . diff --git a/src/lib/libc/string/strsep.c b/src/lib/libc/string/strsep.c new file mode 100644 index 00000000..69be7fe0 --- /dev/null +++ b/src/lib/libc/string/strsep.c @@ -0,0 +1,79 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static const char sccsid[] = "from: @(#)strsep.c 5.4 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strsep.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * Get next token from string *stringp, where tokens are nonempty + * strings separated by characters from delim. + * + * Writes NULs into the string at *stringp to end tokens. + * delim need not remain constant from call to call. + * On return, *stringp points past the last NUL written (if there might + * be further tokens), or is NULL (if there are definitely no more tokens). + * + * If *stringp is NULL, strtoken returns NULL. + */ +char * +strsep(stringp, delim) + register char **stringp; + register const char *delim; +{ + register char *s; + register const char *spanp; + register int c, sc; + char *tok; + + if ((s = *stringp) == NULL) + return (NULL); + for (tok = s;;) { + c = *s++; + spanp = delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) + s = NULL; + else + s[-1] = 0; + *stringp = s; + return (tok); + } + } while (sc != 0); + } + /* NOTREACHED */ +} diff --git a/src/lib/libc/string/strsignal.3 b/src/lib/libc/string/strsignal.3 new file mode 100644 index 00000000..3287fef5 --- /dev/null +++ b/src/lib/libc/string/strsignal.3 @@ -0,0 +1,61 @@ +.\" Copyright (c) 1980, 1991 Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strerror.3 6.9 (Berkeley) 6/29/91 +.\" $Id: strsignal.3,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRSIGNAL 3 +.Os BSD 4 +.Sh NAME +.Nm strsignal +.Nd get signal description string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn strsignal "int sig" +.Sh DESCRIPTION +The +.Fn strsignal +function returns a pointer to the language-dependent string describing +a signal. +.Pp +The array pointed to is not to be modified by the program, but may be +overwritten by subsequent calls to +.Fn strsignal . +.Sh SEE ALSO +.Xr intro 2 , +.Xr psignal 3 , +.Xr setlocale 3 diff --git a/src/lib/libc/string/strsignal.c b/src/lib/libc/string/strsignal.c new file mode 100644 index 00000000..ec4a267e --- /dev/null +++ b/src/lib/libc/string/strsignal.c @@ -0,0 +1,50 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strerror.c 5.6 (Berkeley) 5/4/91";*/ +static char *rcsid = "$Id: strsignal.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> +#include <limits.h> + +extern char *__strsignal __P((int, char *)); + +char * +strsignal(sig) + int sig; +{ + static char buf[NL_TEXTMAX]; + return __strsignal(sig, buf); +} diff --git a/src/lib/libc/string/strspn.3 b/src/lib/libc/string/strspn.3 new file mode 100644 index 00000000..4de03aa5 --- /dev/null +++ b/src/lib/libc/string/strspn.3 @@ -0,0 +1,80 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strspn.3 5.3 (Berkeley) 6/29/91 +.\" $Id: strspn.3,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRSPN 3 +.Os +.Sh NAME +.Nm strspn +.Nd span a string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft size_t +.Fn strspn "const char *s" "const char *charset" +.Sh DESCRIPTION +The +.Xr strcspn +function +spans the initial part of the null-terminated string +.Fa s +as long as the characters from +.Fa s +occur in string +.Fa charset . +.Sh RETURN VALUES +The +.Fn strspn +function +returns the number of characters spanned. +.Sh SEE ALSO +.Xr index 3 , +.Xr memchr 3 , +.Xr rindex 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strstr 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strspn +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/strspn.c b/src/lib/libc/string/strspn.c new file mode 100644 index 00000000..6224b25c --- /dev/null +++ b/src/lib/libc/string/strspn.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 1989 The Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strspn.c 5.8 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strspn.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * Span the string s2 (skip characters that are in s2). + */ +size_t +strspn(s1, s2) + const char *s1; + register const char *s2; +{ + register const char *p = s1, *spanp; + register char c, sc; + + /* + * Skip any characters in s2, excluding the terminating \0. + */ +cont: + c = *p++; + for (spanp = s2; (sc = *spanp++) != 0;) + if (sc == c) + goto cont; + return (p - 1 - s1); +} diff --git a/src/lib/libc/string/strstr.3 b/src/lib/libc/string/strstr.3 new file mode 100644 index 00000000..24fdf540 --- /dev/null +++ b/src/lib/libc/string/strstr.3 @@ -0,0 +1,89 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strstr.3 5.3 (Berkeley) 6/29/91 +.\" $Id: strstr.3,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRSTR 3 +.Os +.Sh NAME +.Nm strstr +.Nd locate a substring in a string +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn strstr "const char *big" "const char *little" +.Sh DESCRIPTION +The +.Fn strstr +function +locates the first occurrence of the null-terminated string +.Fa little +in the null-terminated string +.Fa big . +If +.Fa little +is the empty string, +.Fn strstr +returns +.Fa big ; +if +.Fa little +occurs nowhere in +.Fa big , +.Fn strstr +returns NULL; +otherwise +.Fn strstr +returns a pointer to the first character of the first occurrence of +.Fa little . +.Sh SEE ALSO +.Xr index 3 , +.Xr memchr 3 , +.Xr rindex 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strtok 3 +.Sh STANDARDS +The +.Fn strstr +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/strstr.c b/src/lib/libc/string/strstr.c new file mode 100644 index 00000000..1ed59e35 --- /dev/null +++ b/src/lib/libc/string/strstr.c @@ -0,0 +1,65 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strstr.c 5.2 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strstr.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * Find the first occurrence of find in s. + */ +char * +strstr(s, find) + register const char *s, *find; +{ + register char c, sc; + register size_t len; + + if ((c = *find++) != 0) { + len = strlen(find); + do { + do { + if ((sc = *s++) == 0) + return (NULL); + } while (sc != c); + } while (strncmp(s, find, len) != 0); + s--; + } + return ((char *)s); +} diff --git a/src/lib/libc/string/strtok.3 b/src/lib/libc/string/strtok.3 new file mode 100644 index 00000000..644bd10a --- /dev/null +++ b/src/lib/libc/string/strtok.3 @@ -0,0 +1,112 @@ +.\" Copyright (c) 1988, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" the American National Standards Committee X3, on Information +.\" Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strtok.3 5.8 (Berkeley) 6/29/91 +.\" $Id: strtok.3,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRTOK 3 +.Os BSD 3 +.Sh NAME +.Nm strtok , +.Nm strsep +.Nd string token operations +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft char * +.Fn strtok "char *str" "const char *sep" +.Sh DESCRIPTION +.Bf -symbolic +This interface is obsoleted by strsep(3). +.Ef +.Pp +The +.Fn strtok +function +is used to isolate sequential tokens in a null-terminated string, +.Fa str . +These tokens are separated in the string by at least one of the +characters in +.Fa sep . +The first time that +.Fn strtok +is called, +.Fa str +should be specified; subsequent calls, wishing to obtain further tokens +from the same string, should pass a null pointer instead. +The separator string, +.Fa sep , +must be supplied each time, and may change between calls. +.Pp +The +.Fn strtok +function +returns a pointer to the beginning of each subsequent token in the string, +after replacing the separator character itself with a +.Dv NUL +character. +When no more tokens remain, a null pointer is returned. +.Sh SEE ALSO +.Xr index 3 , +.Xr memchr 3 , +.Xr rindex 3 , +.Xr strchr 3 , +.Xr strcspn 3 , +.Xr strpbrk 3 , +.Xr strrchr 3 , +.Xr strsep 3 , +.Xr strspn 3 , +.Xr strstr 3 +.Sh STANDARDS +The +.Fn strtok +function +conforms to +.St -ansiC . +.Sh BUGS +There is no way to get tokens from multiple strings simultaneously. +.Pp +The System V +.Fn strtok , +if handed a string containing only delimiter characters, +will not alter the next starting point, so that a call to +.Fn strtok +with a different (or empty) delimiter string +may return a +.Pf non- Dv NULL +value. +Since this implementation always alters the next starting point, +such a sequence of calls would always return +.Dv NULL . diff --git a/src/lib/libc/string/strtok.c b/src/lib/libc/string/strtok.c new file mode 100644 index 00000000..9f712579 --- /dev/null +++ b/src/lib/libc/string/strtok.c @@ -0,0 +1,90 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strtok.c 5.8 (Berkeley) 2/24/91";*/ +static char *rcsid = "$Id: strtok.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +char * +strtok(s, delim) + register char *s; + register const char *delim; +{ + register char *spanp; + register int c, sc; + char *tok; + static char *last; + + + if (s == NULL && (s = last) == NULL) + return (NULL); + + /* + * Skip (span) leading delimiters (s += strspn(s, delim), sort of). + */ +cont: + c = *s++; + for (spanp = (char *)delim; (sc = *spanp++) != 0;) { + if (c == sc) + goto cont; + } + + if (c == 0) { /* no non-delimiter characters */ + last = NULL; + return (NULL); + } + tok = s - 1; + + /* + * Scan token (scan for delimiters: s += strcspn(s, delim), sort of). + * Note that delim must have one NUL; we stop if we see that, too. + */ + for (;;) { + c = *s++; + spanp = (char *)delim; + do { + if ((sc = *spanp++) == c) { + if (c == 0) + s = NULL; + else + s[-1] = 0; + last = s; + return (tok); + } + } while (sc != 0); + } + /* NOTREACHED */ +} diff --git a/src/lib/libc/string/strxfrm.3 b/src/lib/libc/string/strxfrm.3 new file mode 100644 index 00000000..84fd9454 --- /dev/null +++ b/src/lib/libc/string/strxfrm.3 @@ -0,0 +1,69 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" This code is derived from software contributed to Berkeley by +.\" Chris Torek and the American National Standards Committee X3, +.\" on Information Processing Systems. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)strxfrm.3 5.4 (Berkeley) 6/29/91 +.\" $Id: strxfrm.3,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $ +.\" +.Dd June 29, 1991 +.Dt STRXFRM 3 +.Os +.Sh NAME +.Nm strxfrm +.Nd transform a string under locale +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft size_t +.Fn strxfrm "char *dst" "const char *src" "size_t n" +.Sh DESCRIPTION +The +.Fn strxfrm +function +does something horrible (see +.Tn ANSI +standard). +In this implementation it just copies. +.Sh SEE ALSO +.Xr bcmp 3 , +.Xr memcmp 3 , +.\" .Xr setlocale 3 , +.Xr strcasecmp 3 , +.Xr strcmp 3 , +.Xr strcoll 3 +.Sh STANDARDS +The +.Fn strxfrm +function +conforms to +.St -ansiC . diff --git a/src/lib/libc/string/strxfrm.c b/src/lib/libc/string/strxfrm.c new file mode 100644 index 00000000..d9df77b9 --- /dev/null +++ b/src/lib/libc/string/strxfrm.c @@ -0,0 +1,74 @@ +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Chris Torek. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)strxfrm.c 5.2 (Berkeley) 1/26/91";*/ +static char *rcsid = "$Id: strxfrm.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +/* + * Transform src, storing the result in dst, such that + * strcmp() on transformed strings returns what strcoll() + * on the original untransformed strings would return. + */ +size_t +strxfrm(dst, src, n) + register char *dst; + register const char *src; + register size_t n; +{ + register size_t r = 0; + register int c; + + /* + * Since locales are unimplemented, this is just a copy. + */ + if (n != 0) { + while ((c = *src++) != 0) { + r++; + if (--n == 0) { + while (*src++ != 0) + r++; + break; + } + *dst++ = c; + } + *dst = 0; + } + return (r); +} diff --git a/src/lib/libc/string/swab.3 b/src/lib/libc/string/swab.3 new file mode 100644 index 00000000..133c487b --- /dev/null +++ b/src/lib/libc/string/swab.3 @@ -0,0 +1,66 @@ +.\" Copyright (c) 1990, 1991 The Regents of the University of California. +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by the University of +.\" California, Berkeley and its contributors. +.\" 4. Neither the name of the University nor the names of its contributors +.\" may be used to endorse or promote products derived from this software +.\" without specific prior written permission. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" from: @(#)swab.3 6.6 (Berkeley) 5/1/91 +.\" $Id: swab.3,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $ +.\" +.Dd May 1, 1991 +.Dt SWAB 3 +.Os +.Sh NAME +.Nm swab +.Nd swap adjacent bytes +.Sh SYNOPSIS +.Fd #include <string.h> +.Ft void +.Fn swab "const void *src" "void *dst" "size_t len" +.Sh DESCRIPTION +The function +.Fn swab +copies +.Fa len +bytes from the location referenced by +.Fa src +to the location referenced by +.Fa dst , +swapping adjacent bytes. +.Pp +The argument +.Fa len +must be even number. +.Sh SEE ALSO +.Xr bzero 3 , +.Xr memset 3 +.Sh HISTORY +A +.Fn swab +function appeared in +.At v7 . diff --git a/src/lib/libc/string/swab.c b/src/lib/libc/string/swab.c new file mode 100644 index 00000000..f33fc53b --- /dev/null +++ b/src/lib/libc/string/swab.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1988 Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * Jeffrey Mogul. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/*static char *sccsid = "from: @(#)swab.c 5.10 (Berkeley) 3/6/91";*/ +static char *rcsid = "$Id: swab.c,v 1.1.1.1 1995/10/18 08:42:23 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <string.h> + +void +swab(from, to, len) + const void *from; + void *to; + size_t len; +{ + register unsigned long temp; + register int n; + register char *fp, *tp; + + n = (len >> 1) + 1; + fp = (char *)from; + tp = (char *)to; +#define STEP temp = *fp++,*tp++ = *fp++,*tp++ = temp + /* round to multiple of 8 */ + while ((--n) & 07) + STEP; + n >>= 3; + while (--n >= 0) { + STEP; STEP; STEP; STEP; + STEP; STEP; STEP; STEP; + } +} diff --git a/src/lib/libutil/Makefile b/src/lib/libutil/Makefile new file mode 100644 index 00000000..7c1299b0 --- /dev/null +++ b/src/lib/libutil/Makefile @@ -0,0 +1,8 @@ +# from: @(#)Makefile 8.1 (Berkeley) 6/4/93 +# $Id: Makefile,v 1.1.1.1 1995/10/18 08:43:13 deraadt Exp $ + +LIB= util +CFLAGS+=-DLIBC_SCCS +SRCS= login.c login_tty.c logout.c logwtmp.c pty.c + +.include <bsd.lib.mk> diff --git a/src/lib/libutil/login.c b/src/lib/libutil/login.c new file mode 100644 index 00000000..5cdbd3d6 --- /dev/null +++ b/src/lib/libutil/login.c @@ -0,0 +1,66 @@ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/* from: static char sccsid[] = "@(#)login.c 8.1 (Berkeley) 6/4/93"; */ +static char *rcsid = "$Id: login.c,v 1.1.1.1 1995/10/18 08:43:13 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> + +#include <fcntl.h> +#include <unistd.h> +#include <stdlib.h> +#include <utmp.h> +#include <stdio.h> + +void login __P((struct utmp *)); + +void +login(ut) + struct utmp *ut; +{ + register int fd; + int tty; + + tty = ttyslot(); + if (tty > 0 && (fd = open(_PATH_UTMP, O_WRONLY|O_CREAT, 0644)) >= 0) { + (void)lseek(fd, (off_t)(tty * sizeof(struct utmp)), L_SET); + (void)write(fd, ut, sizeof(struct utmp)); + (void)close(fd); + } + if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) >= 0) { + (void)write(fd, ut, sizeof(struct utmp)); + (void)close(fd); + } +} diff --git a/src/lib/libutil/login_tty.c b/src/lib/libutil/login_tty.c new file mode 100644 index 00000000..fe2cc4e1 --- /dev/null +++ b/src/lib/libutil/login_tty.c @@ -0,0 +1,58 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/* from: static char sccsid[] = "@(#)login_tty.c 8.1 (Berkeley) 6/4/93"; */ +static char *rcsid = "$Id: login_tty.c,v 1.1.1.1 1995/10/18 08:43:13 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/param.h> +#include <sys/ioctl.h> +#include <unistd.h> + +int login_tty __P((int)); + +int +login_tty(fd) + int fd; +{ + (void) setsid(); + if (ioctl(fd, TIOCSCTTY, (char *)NULL) == -1) + return (-1); + (void) dup2(fd, 0); + (void) dup2(fd, 1); + (void) dup2(fd, 2); + if (fd > 2) + (void) close(fd); + return (0); +} diff --git a/src/lib/libutil/logout.c b/src/lib/libutil/logout.c new file mode 100644 index 00000000..02c847d3 --- /dev/null +++ b/src/lib/libutil/logout.c @@ -0,0 +1,73 @@ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/* from: static char sccsid[] = "@(#)logout.c 8.1 (Berkeley) 6/4/93"; */ +static char *rcsid = "$Id: logout.c,v 1.1.1.1 1995/10/18 08:43:13 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <sys/time.h> + +#include <fcntl.h> +#include <utmp.h> +#include <unistd.h> +#include <stdlib.h> +#include <string.h> + +typedef struct utmp UTMP; + +int +logout(line) + register char *line; +{ + register int fd; + UTMP ut; + int rval; + + if ((fd = open(_PATH_UTMP, O_RDWR, 0)) < 0) + return(0); + rval = 0; + while (read(fd, &ut, sizeof(UTMP)) == sizeof(UTMP)) { + if (!ut.ut_name[0] || strncmp(ut.ut_line, line, UT_LINESIZE)) + continue; + bzero(ut.ut_name, UT_NAMESIZE); + bzero(ut.ut_host, UT_HOSTSIZE); + (void)time(&ut.ut_time); + (void)lseek(fd, -(off_t)sizeof(UTMP), L_INCR); + (void)write(fd, &ut, sizeof(UTMP)); + rval = 1; + } + (void)close(fd); + return(rval); +} diff --git a/src/lib/libutil/logwtmp.c b/src/lib/libutil/logwtmp.c new file mode 100644 index 00000000..e1fb193c --- /dev/null +++ b/src/lib/libutil/logwtmp.c @@ -0,0 +1,70 @@ +/* + * Copyright (c) 1988, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/* from: static char sccsid[] = "@(#)logwtmp.c 8.1 (Berkeley) 6/4/93"; */ +static char *rcsid = "$Id: logwtmp.c,v 1.1.1.1 1995/10/18 08:43:13 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <sys/file.h> +#include <sys/time.h> +#include <sys/stat.h> + +#include <string.h> +#include <unistd.h> +#include <utmp.h> + +void logwtmp __P((char *, char *, char *)); + +void +logwtmp(line, name, host) + char *line, *name, *host; +{ + struct utmp ut; + struct stat buf; + int fd; + + if ((fd = open(_PATH_WTMP, O_WRONLY|O_APPEND, 0)) < 0) + return; + if (fstat(fd, &buf) == 0) { + (void) strncpy(ut.ut_line, line, sizeof(ut.ut_line)); + (void) strncpy(ut.ut_name, name, sizeof(ut.ut_name)); + (void) strncpy(ut.ut_host, host, sizeof(ut.ut_host)); + (void) time(&ut.ut_time); + if (write(fd, (char *)&ut, sizeof(struct utmp)) != + sizeof(struct utmp)) + (void) ftruncate(fd, buf.st_size); + } + (void) close(fd); +} diff --git a/src/lib/libutil/pty.c b/src/lib/libutil/pty.c new file mode 100644 index 00000000..6119ed6b --- /dev/null +++ b/src/lib/libutil/pty.c @@ -0,0 +1,135 @@ +/*- + * Copyright (c) 1990, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if defined(LIBC_SCCS) && !defined(lint) +/* from: static char sccsid[] = "@(#)pty.c 8.1 (Berkeley) 6/4/93"; */ +static char *rcsid = "$Id: pty.c,v 1.1.1.1 1995/10/18 08:43:13 deraadt Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/cdefs.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include <fcntl.h> +#include <termios.h> +#include <errno.h> +#include <unistd.h> +#include <stdio.h> +#include <string.h> +#include <grp.h> + +int login_tty __P((int)); +int openpty __P((int *, int *, char *, struct termios *, struct winsize *)); +pid_t forkpty __P((int *, char *, struct termios *, struct winsize *)); + +int +openpty(amaster, aslave, name, termp, winp) + int *amaster, *aslave; + char *name; + struct termios *termp; + struct winsize *winp; +{ + static char line[] = "/dev/ptyXX"; + register const char *cp1, *cp2; + register int master, slave, ttygid; + struct group *gr; + + if ((gr = getgrnam("tty")) != NULL) + ttygid = gr->gr_gid; + else + ttygid = -1; + + for (cp1 = "pqrstuvwxyzPQRST"; *cp1; cp1++) { + line[8] = *cp1; + for (cp2 = "0123456789abcdef"; *cp2; cp2++) { + line[9] = *cp2; + if ((master = open(line, O_RDWR, 0)) == -1) { + if (errno == ENOENT) + return (-1); /* out of ptys */ + } else { + line[5] = 't'; + (void) chown(line, getuid(), ttygid); + (void) chmod(line, S_IRUSR|S_IWUSR|S_IWGRP); + (void) revoke(line); + if ((slave = open(line, O_RDWR, 0)) != -1) { + *amaster = master; + *aslave = slave; + if (name) + strcpy(name, line); + if (termp) + (void) tcsetattr(slave, + TCSAFLUSH, termp); + if (winp) + (void) ioctl(slave, TIOCSWINSZ, + (char *)winp); + return (0); + } + (void) close(master); + line[5] = 'p'; + } + } + } + errno = ENOENT; /* out of ptys */ + return (-1); +} + +pid_t +forkpty(amaster, name, termp, winp) + int *amaster; + char *name; + struct termios *termp; + struct winsize *winp; +{ + int master, slave; + pid_t pid; + + if (openpty(&master, &slave, name, termp, winp) == -1) + return (-1); + switch (pid = fork()) { + case -1: + return (-1); + case 0: + /* + * child + */ + (void) close(master); + login_tty(slave); + return (0); + } + /* + * parent + */ + *amaster = master; + (void) close(slave); + return (pid); +} diff --git a/src/lib/libutil/shlib_version b/src/lib/libutil/shlib_version new file mode 100644 index 00000000..3f0196eb --- /dev/null +++ b/src/lib/libutil/shlib_version @@ -0,0 +1,2 @@ +major=3 +minor=1