386BSD 0.1 before patchkit commits
authorWilliam F. Jolitz and Lynne Greer Jolitz <{wjolitz@soda.berkeley.edu,ljolitz@cardio.ucsf.edu}>
Wed, 15 Jul 1992 07:32:23 +0000 (07:32 +0000)
committerWilliam F. Jolitz and Lynne Greer Jolitz <{wjolitz@soda.berkeley.edu,ljolitz@cardio.ucsf.edu}>
Wed, 15 Jul 1992 07:32:23 +0000 (07:32 +0000)
294 files changed:
dev/MAKEDEV [new file with mode: 0644]
usr/include/a.out.h [new file with mode: 0644]
usr/include/ar.h [new file with mode: 0644]
usr/include/arpa/ftp.h [new file with mode: 0644]
usr/include/arpa/inet.h [new file with mode: 0644]
usr/include/arpa/nameser.h [new file with mode: 0644]
usr/include/arpa/telnet.h [new file with mode: 0644]
usr/include/arpa/tftp.h [new file with mode: 0644]
usr/include/assert.h [new file with mode: 0644]
usr/include/bitstring.h [new file with mode: 0644]
usr/include/ctype.h [new file with mode: 0644]
usr/include/curses.h [new file with mode: 0644]
usr/include/db.h [new file with mode: 0644]
usr/include/dirent.h [new file with mode: 0644]
usr/include/disktab.h [new file with mode: 0644]
usr/include/errno.h [new symlink]
usr/include/fcntl.h [new symlink]
usr/include/float.h [new symlink]
usr/include/frame.h [new symlink]
usr/include/fstab.h [new file with mode: 0644]
usr/include/fts.h [new file with mode: 0644]
usr/include/g++/ACG.h [new file with mode: 0644]
usr/include/g++/AllocRing.h [new file with mode: 0644]
usr/include/g++/Binomial.h [new file with mode: 0644]
usr/include/g++/BitSet.h [new file with mode: 0644]
usr/include/g++/BitString.h [new file with mode: 0644]
usr/include/g++/Complex.h [new file with mode: 0644]
usr/include/g++/CursesW.h [new file with mode: 0644]
usr/include/g++/DiscUnif.h [new file with mode: 0644]
usr/include/g++/Erlang.h [new file with mode: 0644]
usr/include/g++/File.h [new file with mode: 0644]
usr/include/g++/Filebuf.h [new file with mode: 0644]
usr/include/g++/Fix.h [new file with mode: 0644]
usr/include/g++/Fix16.h [new file with mode: 0644]
usr/include/g++/Fix24.h [new file with mode: 0644]
usr/include/g++/Fmodes.h [new file with mode: 0644]
usr/include/g++/Geom.h [new file with mode: 0644]
usr/include/g++/GetOpt.h [new file with mode: 0644]
usr/include/g++/HypGeom.h [new file with mode: 0644]
usr/include/g++/Incremental.h [new file with mode: 0644]
usr/include/g++/Integer.h [new file with mode: 0644]
usr/include/g++/LogNorm.h [new file with mode: 0644]
usr/include/g++/MLCG.h [new file with mode: 0644]
usr/include/g++/NegExp.h [new file with mode: 0644]
usr/include/g++/Normal.h [new file with mode: 0644]
usr/include/g++/Obstack.h [new file with mode: 0644]
usr/include/g++/Pix.h [new file with mode: 0644]
usr/include/g++/PlotFile.h [new file with mode: 0644]
usr/include/g++/Poisson.h [new file with mode: 0644]
usr/include/g++/RNG.h [new file with mode: 0644]
usr/include/g++/Random.h [new file with mode: 0644]
usr/include/g++/Rational.h [new file with mode: 0644]
usr/include/g++/Regex.h [new file with mode: 0644]
usr/include/g++/RndInt.h [new file with mode: 0644]
usr/include/g++/SFile.h [new file with mode: 0644]
usr/include/g++/SmplHist.h [new file with mode: 0644]
usr/include/g++/SmplStat.h [new file with mode: 0644]
usr/include/g++/String.h [new file with mode: 0644]
usr/include/g++/Uniform.h [new file with mode: 0644]
usr/include/g++/Weibull.h [new file with mode: 0644]
usr/include/g++/abs.h [new file with mode: 0644]
usr/include/g++/assert.h [new file with mode: 0644]
usr/include/g++/bool.h [new file with mode: 0644]
usr/include/g++/builtin.h [new file with mode: 0644]
usr/include/g++/compare.h [new file with mode: 0644]
usr/include/g++/complex.h [new file with mode: 0644]
usr/include/g++/curses.h [new file with mode: 0644]
usr/include/g++/file.h [new file with mode: 0644]
usr/include/g++/filebuf.h [new file with mode: 0644]
usr/include/g++/gen/AVLMap.ccP [new file with mode: 0644]
usr/include/g++/gen/AVLMap.hP [new file with mode: 0644]
usr/include/g++/gen/AVLSet.ccP [new file with mode: 0644]
usr/include/g++/gen/AVLSet.hP [new file with mode: 0644]
usr/include/g++/gen/AVec.ccP [new file with mode: 0644]
usr/include/g++/gen/AVec.hP [new file with mode: 0644]
usr/include/g++/gen/BSTSet.ccP [new file with mode: 0644]
usr/include/g++/gen/BSTSet.hP [new file with mode: 0644]
usr/include/g++/gen/Bag.ccP [new file with mode: 0644]
usr/include/g++/gen/Bag.hP [new file with mode: 0644]
usr/include/g++/gen/CHBag.ccP [new file with mode: 0644]
usr/include/g++/gen/CHBag.hP [new file with mode: 0644]
usr/include/g++/gen/CHMap.ccP [new file with mode: 0644]
usr/include/g++/gen/CHMap.hP [new file with mode: 0644]
usr/include/g++/gen/CHSet.ccP [new file with mode: 0644]
usr/include/g++/gen/CHSet.hP [new file with mode: 0644]
usr/include/g++/gen/DLDeque.ccP [new file with mode: 0644]
usr/include/g++/gen/DLDeque.hP [new file with mode: 0644]
usr/include/g++/gen/DLList.ccP [new file with mode: 0644]
usr/include/g++/gen/DLList.hP [new file with mode: 0644]
usr/include/g++/gen/Deque.ccP [new file with mode: 0644]
usr/include/g++/gen/Deque.hP [new file with mode: 0644]
usr/include/g++/gen/FPQueue.ccP [new file with mode: 0644]
usr/include/g++/gen/FPQueue.hP [new file with mode: 0644]
usr/include/g++/gen/FPStack.ccP [new file with mode: 0644]
usr/include/g++/gen/FPStack.hP [new file with mode: 0644]
usr/include/g++/gen/FPlex.ccP [new file with mode: 0644]
usr/include/g++/gen/FPlex.hP [new file with mode: 0644]
usr/include/g++/gen/List.ccP [new file with mode: 0644]
usr/include/g++/gen/List.hP [new file with mode: 0644]
usr/include/g++/gen/MPlex.ccP [new file with mode: 0644]
usr/include/g++/gen/MPlex.hP [new file with mode: 0644]
usr/include/g++/gen/Map.ccP [new file with mode: 0644]
usr/include/g++/gen/Map.hP [new file with mode: 0644]
usr/include/g++/gen/OSLBag.ccP [new file with mode: 0644]
usr/include/g++/gen/OSLBag.hP [new file with mode: 0644]
usr/include/g++/gen/OSLSet.ccP [new file with mode: 0644]
usr/include/g++/gen/OSLSet.hP [new file with mode: 0644]
usr/include/g++/gen/OXPBag.ccP [new file with mode: 0644]
usr/include/g++/gen/OXPBag.hP [new file with mode: 0644]
usr/include/g++/gen/OXPSet.ccP [new file with mode: 0644]
usr/include/g++/gen/OXPSet.hP [new file with mode: 0644]
usr/include/g++/gen/PHPQ.ccP [new file with mode: 0644]
usr/include/g++/gen/PHPQ.hP [new file with mode: 0644]
usr/include/g++/gen/PQ.ccP [new file with mode: 0644]
usr/include/g++/gen/PQ.hP [new file with mode: 0644]
usr/include/g++/gen/Plex.ccP [new file with mode: 0644]
usr/include/g++/gen/Plex.hP [new file with mode: 0644]
usr/include/g++/gen/Queue.ccP [new file with mode: 0644]
usr/include/g++/gen/Queue.hP [new file with mode: 0644]
usr/include/g++/gen/RAVLMap.ccP [new file with mode: 0644]
usr/include/g++/gen/RAVLMap.hP [new file with mode: 0644]
usr/include/g++/gen/RPlex.ccP [new file with mode: 0644]
usr/include/g++/gen/RPlex.hP [new file with mode: 0644]
usr/include/g++/gen/SLBag.ccP [new file with mode: 0644]
usr/include/g++/gen/SLBag.hP [new file with mode: 0644]
usr/include/g++/gen/SLList.ccP [new file with mode: 0644]
usr/include/g++/gen/SLList.hP [new file with mode: 0644]
usr/include/g++/gen/SLQueue.ccP [new file with mode: 0644]
usr/include/g++/gen/SLQueue.hP [new file with mode: 0644]
usr/include/g++/gen/SLSet.ccP [new file with mode: 0644]
usr/include/g++/gen/SLSet.hP [new file with mode: 0644]
usr/include/g++/gen/SLStack.ccP [new file with mode: 0644]
usr/include/g++/gen/SLStack.hP [new file with mode: 0644]
usr/include/g++/gen/Set.ccP [new file with mode: 0644]
usr/include/g++/gen/Set.hP [new file with mode: 0644]
usr/include/g++/gen/SplayBag.ccP [new file with mode: 0644]
usr/include/g++/gen/SplayBag.hP [new file with mode: 0644]
usr/include/g++/gen/SplayMap.ccP [new file with mode: 0644]
usr/include/g++/gen/SplayMap.hP [new file with mode: 0644]
usr/include/g++/gen/SplayPQ.ccP [new file with mode: 0644]
usr/include/g++/gen/SplayPQ.hP [new file with mode: 0644]
usr/include/g++/gen/SplaySet.ccP [new file with mode: 0644]
usr/include/g++/gen/SplaySet.hP [new file with mode: 0644]
usr/include/g++/gen/Stack.ccP [new file with mode: 0644]
usr/include/g++/gen/Stack.hP [new file with mode: 0644]
usr/include/g++/gen/VHBag.ccP [new file with mode: 0644]
usr/include/g++/gen/VHBag.hP [new file with mode: 0644]
usr/include/g++/gen/VHMap.ccP [new file with mode: 0644]
usr/include/g++/gen/VHMap.hP [new file with mode: 0644]
usr/include/g++/gen/VHSet.ccP [new file with mode: 0644]
usr/include/g++/gen/VHSet.hP [new file with mode: 0644]
usr/include/g++/gen/VOHSet.ccP [new file with mode: 0644]
usr/include/g++/gen/VOHSet.hP [new file with mode: 0644]
usr/include/g++/gen/VQueue.ccP [new file with mode: 0644]
usr/include/g++/gen/VQueue.hP [new file with mode: 0644]
usr/include/g++/gen/VStack.ccP [new file with mode: 0644]
usr/include/g++/gen/VStack.hP [new file with mode: 0644]
usr/include/g++/gen/Vec.ccP [new file with mode: 0644]
usr/include/g++/gen/Vec.hP [new file with mode: 0644]
usr/include/g++/gen/XPBag.ccP [new file with mode: 0644]
usr/include/g++/gen/XPBag.hP [new file with mode: 0644]
usr/include/g++/gen/XPDeque.ccP [new file with mode: 0644]
usr/include/g++/gen/XPDeque.hP [new file with mode: 0644]
usr/include/g++/gen/XPPQ.ccP [new file with mode: 0644]
usr/include/g++/gen/XPPQ.hP [new file with mode: 0644]
usr/include/g++/gen/XPQueue.ccP [new file with mode: 0644]
usr/include/g++/gen/XPQueue.hP [new file with mode: 0644]
usr/include/g++/gen/XPSet.ccP [new file with mode: 0644]
usr/include/g++/gen/XPSet.hP [new file with mode: 0644]
usr/include/g++/gen/XPStack.ccP [new file with mode: 0644]
usr/include/g++/gen/XPStack.hP [new file with mode: 0644]
usr/include/g++/gen/XPlex.ccP [new file with mode: 0644]
usr/include/g++/gen/XPlex.hP [new file with mode: 0644]
usr/include/g++/gen/defs.hP [new file with mode: 0644]
usr/include/g++/generic.h [new file with mode: 0644]
usr/include/g++/istream.h [new file with mode: 0644]
usr/include/g++/malloc.h [new file with mode: 0644]
usr/include/g++/max.h [new file with mode: 0644]
usr/include/g++/min.h [new file with mode: 0644]
usr/include/g++/minmax.h [new file with mode: 0644]
usr/include/g++/new.h [new file with mode: 0644]
usr/include/g++/open.h [new file with mode: 0644]
usr/include/g++/osfcn.h [new file with mode: 0644]
usr/include/g++/ostream.h [new file with mode: 0644]
usr/include/g++/regex.h [new file with mode: 0644]
usr/include/g++/std.h [new file with mode: 0644]
usr/include/g++/strclass.h [new file with mode: 0644]
usr/include/g++/stream.h [new file with mode: 0644]
usr/include/g++/streambuf.h [new file with mode: 0644]
usr/include/g++/swap.h [new file with mode: 0644]
usr/include/g++/values.h [new file with mode: 0644]
usr/include/glob.h [new file with mode: 0644]
usr/include/grp.h [new file with mode: 0644]
usr/include/kvm.h [new file with mode: 0644]
usr/include/limits.h [new file with mode: 0644]
usr/include/locale.h [new file with mode: 0644]
usr/include/machine [new symlink]
usr/include/math.h [new file with mode: 0644]
usr/include/memory.h [new file with mode: 0644]
usr/include/ndbm.h [new file with mode: 0644]
usr/include/net [new symlink]
usr/include/netdb.h [new file with mode: 0644]
usr/include/netimp [new symlink]
usr/include/netinet [new symlink]
usr/include/netiso [new symlink]
usr/include/netns [new symlink]
usr/include/nfs [new symlink]
usr/include/nlist.h [new file with mode: 0644]
usr/include/paths.h [new file with mode: 0644]
usr/include/protocols/dumprestore.h [new file with mode: 0644]
usr/include/protocols/routed.h [new file with mode: 0644]
usr/include/protocols/rwhod.h [new file with mode: 0644]
usr/include/protocols/talkd.h [new file with mode: 0644]
usr/include/protocols/timed.h [new file with mode: 0644]
usr/include/pwd.h [new file with mode: 0644]
usr/include/ranlib.h [new file with mode: 0644]
usr/include/regexp.h [new file with mode: 0644]
usr/include/resolv.h [new file with mode: 0644]
usr/include/rpc/auth.h [new file with mode: 0644]
usr/include/rpc/auth_unix.h [new file with mode: 0644]
usr/include/rpc/clnt.h [new file with mode: 0644]
usr/include/rpc/pmap_clnt.h [new file with mode: 0644]
usr/include/rpc/pmap_prot.h [new file with mode: 0644]
usr/include/rpc/pmap_rmt.h [new file with mode: 0644]
usr/include/rpc/rpc.h [new file with mode: 0644]
usr/include/rpc/rpc_msg.h [new file with mode: 0644]
usr/include/rpc/svc.h [new file with mode: 0644]
usr/include/rpc/svc_auth.h [new file with mode: 0644]
usr/include/rpc/types.h [new file with mode: 0644]
usr/include/rpc/xdr.h [new file with mode: 0644]
usr/include/setjmp.h [new file with mode: 0644]
usr/include/sgtty.h [new file with mode: 0644]
usr/include/signal.h [new symlink]
usr/include/stab.h [new file with mode: 0644]
usr/include/stdarg.h [new file with mode: 0644]
usr/include/stddef.h [new file with mode: 0644]
usr/include/stdio.h [new file with mode: 0644]
usr/include/stdlib.h [new file with mode: 0644]
usr/include/string.h [new file with mode: 0644]
usr/include/strings.h [new file with mode: 0644]
usr/include/struct.h [new file with mode: 0644]
usr/include/sys [new symlink]
usr/include/syscall.h [new symlink]
usr/include/sysexits.h [new file with mode: 0644]
usr/include/syslog.h [new symlink]
usr/include/termios.h [new symlink]
usr/include/time.h [new file with mode: 0644]
usr/include/ttyent.h [new file with mode: 0644]
usr/include/tzfile.h [new file with mode: 0644]
usr/include/ufs [new symlink]
usr/include/unistd.h [new file with mode: 0644]
usr/include/utime.h [new file with mode: 0644]
usr/include/utmp.h [new file with mode: 0644]
usr/include/varargs.h [new file with mode: 0644]
usr/include/vis.h [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/A/A.pe [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/A/numericstring.pe [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg1 [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg1.pe [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg2 [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg2.pe [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg3 [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg3.pe [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg4 [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg4.pe [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg5 [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg5.pe [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg6 [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg6.pe [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg7 [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/mhs/msg7.pe [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/test1.pe [new file with mode: 0644]
usr/othersrc/contrib/isode/pepy/test/test2.pe [new file with mode: 0644]
usr/othersrc/public/textutils-1.3/bin/cat [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/cmp [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/comm [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/csplit [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/cut [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/expand [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/fold [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/head [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/join [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/nl [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/paste [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/pr [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/sort [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/split [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/sum [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/tac [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/tail [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/tr [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/unexpand [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/uniq [new file with mode: 0755]
usr/othersrc/public/textutils-1.3/bin/wc [new file with mode: 0755]

diff --git a/dev/MAKEDEV b/dev/MAKEDEV
new file mode 100644 (file)
index 0000000..6799a52
--- /dev/null
@@ -0,0 +1,160 @@
+#!/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:
+#      std     standard devices
+#      local   configuration specific devices
+#
+# Tapes:
+#      wt*     QIC-interfaced (e.g. not SCSI) 3M cartridge tape
+#
+# Disks:
+#      wd*     "winchester" disk drives (ST506,IDE,ESDI,RLL,...)
+#      fd*     "floppy" disk drives (3 1/2", 5 1/4")
+#      as*     "SCSI" disk/tape/CDROM drives
+#
+# Terminal ports:
+#      com*    standard PC COM ports
+#
+# Pseudo terminals:
+#      pty*    set of 16 master and slave pseudo terminals
+#
+# Printers:
+#
+# Call units:
+#
+# Special purpose devices:
+#      flog*   kernel logging device
+#
+
+PATH=/sbin:/bin/:/usr/bin:/usr/sbin:
+umask 77
+for i
+do
+case $i in
+
+std)
+       rm -f console drum mem kmdem null 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 tty               c 1 0   ; chmod 666 tty
+       mknod klog              c 7 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
+       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 53 %d;", i, i)}'`)
+       chown -R bin.bin fd
+       chmod 555 fd
+       chmod 666 fd/*
+       ;;
+
+wt*)
+       umask 2
+       mknod wt0 b 3 0
+       mknod rwt0 c 10 0
+       umask 77
+       ;;
+
+fd*|wd*|as*)
+       umask 2 ; unit=`expr $i : '..\(.*\)'`
+       case $i in
+       fd*) name=fd; blk=2; chr=9;;
+       wd*) name=wd; blk=0; chr=3;;
+       as*) name=as; blk=4; chr=13;;
+       esac
+       rm -f $name$unit? r$name$unit?
+       case $unit in
+       0|1)
+               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
+       ;;
+
+com*)
+       unit=`expr $i : 'com\(.*\)'`
+       rm -f com0$unit
+       mknod com0$unit c 8 $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("mknod tty%s%x c 5 %d; \
+                                       mknod pty%s%x c 6 %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
+       ;;
+
+esac
+done
diff --git a/usr/include/a.out.h b/usr/include/a.out.h
new file mode 100644 (file)
index 0000000..1008155
--- /dev/null
@@ -0,0 +1,91 @@
+/*-
+ * 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>
+
+#if defined(hp300) || defined(i386)
+#define        __LDPGSZ        4096
+#endif
+#if defined(tahoe) || defined(vax)
+#define        __LDPGSZ        1024
+#endif
+
+/* Valid magic number check. */
+#define        N_BADMAG(ex) \
+       ((ex).a_magic != NMAGIC && (ex).a_magic != OMAGIC && \
+           (ex).a_magic != ZMAGIC)
+
+/* Address of the bottom of the text segment. */
+#define N_TXTADDR(X)   0
+
+/* Address of the bottom of the data segment. */
+#define N_DATADDR(ex) \
+       (N_TXTADDR(ex) + ((ex).a_magic == OMAGIC ? (ex).a_text \
+       : __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
+
+/* Text segment offset. */
+#define        N_TXTOFF(ex) \
+       ((ex).a_magic == ZMAGIC ? __LDPGSZ : sizeof(struct exec))
+
+/* Data segment offset. */
+#define        N_DATOFF(ex) \
+       (N_TXTOFF(ex) + ((ex).a_magic != ZMAGIC ? (ex).a_text \
+       : __LDPGSZ + ((ex).a_text - 1 & ~(__LDPGSZ - 1))))
+
+/* Symbol table offset. */
+#define N_SYMOFF(ex) \
+       (N_TXTOFF(ex) + (ex).a_text + (ex).a_data + (ex).a_trsize + \
+           (ex).a_drsize)
+
+/* String table offset. */
+#define        N_STROFF(ex)    (N_SYMOFF(ex) + (ex).a_syms)
+
+/* Relocation format. */
+struct relocation_info {
+       int r_address;                  /* offset in text or data segment */
+       unsigned int r_symbolnum : 24,  /* ordinal number of add symbol */
+                        r_pcrel :  1,  /* 1 if value should be pc-relative */
+                       r_length :  2,  /* log base 2 of value's width */
+                       r_extern :  1,  /* 1 if need to add symbol to value */
+                                :  4;  /* reserved */
+};
+
+#define _AOUT_INCLUDE_
+#include <nlist.h>
+
+#endif /* !_AOUT_H_ */
diff --git a/usr/include/ar.h b/usr/include/ar.h
new file mode 100644 (file)
index 0000000..b0bd443
--- /dev/null
@@ -0,0 +1,62 @@
+/*-
+ * Copyright (c) 1991 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * 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        5.4 (Berkeley) 4/3/91
+ */
+
+#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/usr/include/arpa/ftp.h b/usr/include/arpa/ftp.h
new file mode 100644 (file)
index 0000000..3a2079c
--- /dev/null
@@ -0,0 +1,109 @@
+/*
+ * 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/usr/include/arpa/inet.h b/usr/include/arpa/inet.h
new file mode 100644 (file)
index 0000000..cfe2a2f
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * 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
+extern unsigned long    inet_addr __P((const char *));
+extern unsigned long    inet_lnaof __P((struct in_addr));
+extern struct in_addr   inet_makeaddr __P((u_long , u_long));
+extern unsigned long    inet_netof __P((struct in_addr));
+extern unsigned long    inet_network __P((const char *));
+extern char            *inet_ntoa __P((struct in_addr));
+__END_DECLS
+
+#endif /* !_INET_H_ */
diff --git a/usr/include/arpa/nameser.h b/usr/include/arpa/nameser.h
new file mode 100644 (file)
index 0000000..84ed990
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * 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_
+
+/*
+ * 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 nemed 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 */
+       /* 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) */
+       /* 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
+
+#ifndef BYTE_ORDER
+#define        LITTLE_ENDIAN   1234    /* least-significant byte first (vax) */
+#define        BIG_ENDIAN      4321    /* most-significant byte first (IBM, net) */
+#define        PDP_ENDIAN      3412    /* LSB first in word, MSW first in long (pdp) */
+
+#if defined(vax) || defined(ns32000) || defined(sun386) || defined(MIPSEL) || \
+    defined(BIT_ZERO_ON_RIGHT)
+#define BYTE_ORDER     LITTLE_ENDIAN
+
+#endif
+#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
+    defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
+    defined(MIPSEB) || defined (BIT_ZERO_ON_LEFT)
+#define BYTE_ORDER     BIG_ENDIAN
+#endif
+#endif /* BYTE_ORDER */
+
+#ifndef BYTE_ORDER
+       /* you must determine what the correct bit order is for your compiler */
+       UNDEFINED_BIT_ORDER;
+#endif
+/*
+ * 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 {
+       short   r_zone;                 /* zone number */
+       short   r_class;                /* class number */
+       short   r_type;                 /* type number */
+       u_long  r_ttl;                  /* time to live */
+       int     r_size;                 /* size of data area */
+       char    *r_data;                /* pointer to data */
+};
+
+extern u_short _getshort();
+extern u_long  _getlong();
+
+/*
+ * 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) { \
+       (s) = *(cp)++ << 8; \
+       (s) |= *(cp)++; \
+}
+
+#define GETLONG(l, cp) { \
+       (l) = *(cp)++ << 8; \
+       (l) |= *(cp)++; (l) <<= 8; \
+       (l) |= *(cp)++; (l) <<= 8; \
+       (l) |= *(cp)++; \
+}
+
+
+#define PUTSHORT(s, cp) { \
+       *(cp)++ = (s) >> 8; \
+       *(cp)++ = (s); \
+}
+
+/*
+ * Warning: PUTLONG destroys its first argument.
+ */
+#define PUTLONG(l, cp) { \
+       (cp)[3] = l; \
+       (cp)[2] = (l >>= 8); \
+       (cp)[1] = (l >>= 8); \
+       (cp)[0] = l >> 8; \
+       (cp) += sizeof(u_long); \
+}
+
+#endif /* !_NAMESER_H_ */
diff --git a/usr/include/arpa/telnet.h b/usr/include/arpa/telnet.h
new file mode 100644 (file)
index 0000000..019bfeb
--- /dev/null
@@ -0,0 +1,310 @@
+/*
+ * 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.
+ *
+ *     @(#)telnet.h    5.14 (Berkeley) 4/3/91
+ */
+
+#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)    ((x) <= TELCMD_LAST && (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_ENVIRON 36      /* Environment variables */
+#define        TELOPT_AUTHENTICATION 37/* Authenticate */
+#define        TELOPT_ENCRYPT  38      /* Encryption option */
+#define        TELOPT_EXOPL    255     /* extended-options-list */
+
+
+#define        NTELOPTS        (1+TELOPT_ENCRYPT)
+#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", "ENVIRON", "AUTHENTICATION",
+       "ENCRYPT",
+       0,
+};
+#define        TELOPT_FIRST    TELOPT_BINARY
+#define        TELOPT_LAST     TELOPT_ENCRYPT
+#define        TELOPT_OK(x)    ((x) <= TELOPT_LAST && (x) >= TELOPT_FIRST)
+#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 */
+
+/*
+ * 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)  ((x) >= 0 && (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        ENV_VALUE       0
+#define        ENV_VAR         1
+#define        ENV_ESC         2
+
+/*
+ * 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)     ((x) >= 0 && (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)      ((x) >= 0 && (x) < ENCRYPT_CNT)
+#define        ENCRYPT_NAME(x)         encrypt_names[x]
+
+#define        ENCTYPE_NAME_OK(x)      ((x) >= 0 && (x) < ENCTYPE_CNT)
+#define        ENCTYPE_NAME(x)         enctype_names[x]
+
+#endif /* !_TELNET_H_ */
diff --git a/usr/include/arpa/tftp.h b/usr/include/arpa/tftp.h
new file mode 100644 (file)
index 0000000..370fbb3
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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/usr/include/assert.h b/usr/include/assert.h
new file mode 100644 (file)
index 0000000..2c2c5be
--- /dev/null
@@ -0,0 +1,54 @@
+/*-
+ * 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.
+ *
+ *     @(#)assert.h    4.4 (Berkeley) 4/3/91
+ */
+
+#ifndef _ASSERT_H_
+#define        _ASSERT_H_
+
+#ifdef NDEBUG
+#define        assert
+#define        _assert
+#else
+#define        assert(expression) { \
+       if (!(expression)) { \
+               (void)fprintf(stderr, \
+                   "assertion \"%s\" failed: file \"%s\", line %d\n", \
+                   "expression", __FILE__, __LINE__); \
+               exit(2); \
+       } \
+}
+#define        _assert(expression)     assert(expression)
+#endif
+
+#endif /* !_ASSERT_H_ */
diff --git a/usr/include/bitstring.h b/usr/include/bitstring.h
new file mode 100644 (file)
index 0000000..21f10f6
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * 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, 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.
+ *
+ *     @(#)bitstring.h 5.5 (Berkeley) 4/3/91
+ */
+
+#ifndef _BITSTRING_H_
+#define        _BITSTRING_H_
+
+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) - 1) >> 3) + 1)
+
+                               /* allocate a bitstring */
+#define        bit_alloc(nbits) \
+       (bitstr_t *)calloc(1, \
+           (unsigned int)_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; \
+       register int _startbyte = _bit_byte(_start); \
+       register int _stopbyte = _bit_byte(_stop); \
+       _name[_startbyte] &= 0xff >> (8 - (_start&0x7)); \
+       while (++_startbyte < _stopbyte) \
+               _name[_startbyte] = 0; \
+       _name[_stopbyte] &= 0xff << ((_stop&0x7) + 1); \
+}
+
+                               /* set bits start ... stop in bitstring */
+#define        bit_nset(name, start, stop) { \
+       register bitstr_t *_name = name; \
+       register int _start = start, _stop = stop; \
+       register int _startbyte = _bit_byte(_start); \
+       register int _stopbyte = _bit_byte(_stop); \
+       _name[_startbyte] |= 0xff << ((start)&0x7); \
+       while (++_startbyte < _stopbyte) \
+           _name[_startbyte] = 0xff; \
+       _name[_stopbyte] |= 0xff >> (7 - (_stop&0x7)); \
+}
+
+                               /* find first bit clear in name */
+#define        bit_ffc(name, nbits, value) { \
+       register bitstr_t *_name = name; \
+       register int _byte, _nbits = nbits; \
+       register int _stopbyte = _bit_byte(_nbits), _value = -1; \
+       for (_byte = 0; _byte <= _stopbyte; ++_byte) \
+               if (_name[_byte] != 0xff) { \
+                       _value = _byte << 3; \
+                       for (_stopbyte = _name[_byte]; (_stopbyte&0x1); \
+                           ++_value, _stopbyte >>= 1); \
+                       break; \
+               } \
+       *(value) = _value; \
+}
+
+                               /* find first bit set in name */
+#define        bit_ffs(name, nbits, value) { \
+       register bitstr_t *_name = name; \
+       register int _byte, _nbits = nbits; \
+       register int _stopbyte = _bit_byte(_nbits), _value = -1; \
+       for (_byte = 0; _byte <= _stopbyte; ++_byte) \
+               if (_name[_byte]) { \
+                       _value = _byte << 3; \
+                       for (_stopbyte = _name[_byte]; !(_stopbyte&0x1); \
+                           ++_value, _stopbyte >>= 1); \
+                       break; \
+               } \
+       *(value) = _value; \
+}
+
+#endif /* !_BITSTRING_H_ */
diff --git a/usr/include/ctype.h b/usr/include/ctype.h
new file mode 100644 (file)
index 0000000..880c4d3
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ *
+ *     @(#)ctype.h     5.3 (Berkeley) 4/3/91
+ */
+
+#ifndef _CTYPE_H_
+#define _CTYPE_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 char    _ctype_[];
+
+#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        isascii(c)      ((unsigned)(c) <= 0177)
+#define        toupper(c)      ((c) - 'a' + 'A')
+#define        tolower(c)      ((c) - 'A' + 'a')
+#define        toascii(c)      ((c) & 0177)
+
+#endif /* !_CTYPE_H_ */
diff --git a/usr/include/curses.h b/usr/include/curses.h
new file mode 100644 (file)
index 0000000..3c71191
--- /dev/null
@@ -0,0 +1,217 @@
+/*
+ * Copyright (c) 1981 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.
+ *
+ *     @(#)curses.h    5.9 (Berkeley) 7/1/90
+ */
+
+#ifndef WINDOW
+
+#include       <stdio.h>
+#define USE_OLD_TTY
+#include       <sys/ioctl.h>
+#undef USE_OLD_TTY
+
+#define        bool    char
+#define        reg     register
+
+#define        TRUE    (1)
+#define        FALSE   (0)
+#define        ERR     (0)
+#define        OK      (1)
+
+#define        _ENDLINE        001
+#define        _FULLWIN        002
+#define        _SCROLLWIN      004
+#define        _FLUSH          010
+#define        _FULLLINE       020
+#define        _IDLINE         040
+#define        _STANDOUT       0200
+#define        _NOCHANGE       -1
+
+#define        _puts(s)        tputs(s, 0, _putchar)
+
+typedef        struct sgttyb   SGTTY;
+
+/*
+ * Capabilities from termcap
+ */
+
+extern bool     AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
+               XB, XN, XT, XS, XX;
+extern char    *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
+               *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
+               *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
+               *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
+               *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
+               *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
+               *LEFT_PARM, *RIGHT_PARM;
+extern char    PC;
+
+/*
+ * From the tty modes...
+ */
+
+extern bool    GT, NONL, UPPERCASE, normtty, _pfast;
+
+struct _win_st {
+       short           _cury, _curx;
+       short           _maxy, _maxx;
+       short           _begy, _begx;
+       short           _flags;
+       short           _ch_off;
+       bool            _clear;
+       bool            _leave;
+       bool            _scroll;
+       char            **_y;
+       short           *_firstch;
+       short           *_lastch;
+       struct _win_st  *_nextp, *_orig;
+};
+
+#define        WINDOW  struct _win_st
+
+extern bool    My_term, _echoit, _rawmode, _endwin;
+
+extern char    *Def_term, ttytype[];
+
+extern int     LINES, COLS, _tty_ch, _res_flg;
+
+extern SGTTY   _tty;
+
+extern WINDOW  *stdscr, *curscr;
+
+/*
+ *     Define VOID to stop lint from generating "null effect"
+ * comments.
+ */
+#ifdef lint
+int    __void__;
+#define        VOID(x) (__void__ = (int) (x))
+#else
+#define        VOID(x) (x)
+#endif
+
+/*
+ * psuedo functions for standard screen
+ */
+#define        addch(ch)       VOID(waddch(stdscr, ch))
+#define        getch()         VOID(wgetch(stdscr))
+#define        addbytes(da,co) VOID(waddbytes(stdscr, da,co))
+#define        addstr(str)     VOID(waddbytes(stdscr, str, strlen(str)))
+#define        getstr(str)     VOID(wgetstr(stdscr, str))
+#define        move(y, x)      VOID(wmove(stdscr, y, x))
+#define        clear()         VOID(wclear(stdscr))
+#define        erase()         VOID(werase(stdscr))
+#define        clrtobot()      VOID(wclrtobot(stdscr))
+#define        clrtoeol()      VOID(wclrtoeol(stdscr))
+#define        insertln()      VOID(winsertln(stdscr))
+#define        deleteln()      VOID(wdeleteln(stdscr))
+#define        refresh()       VOID(wrefresh(stdscr))
+#define        inch()          VOID(winch(stdscr))
+#define        insch(c)        VOID(winsch(stdscr,c))
+#define        delch()         VOID(wdelch(stdscr))
+#define        standout()      VOID(wstandout(stdscr))
+#define        standend()      VOID(wstandend(stdscr))
+
+/*
+ * mv functions
+ */
+#define        mvwaddch(win,y,x,ch)    VOID(wmove(win,y,x)==ERR?ERR:waddch(win,ch))
+#define        mvwgetch(win,y,x)       VOID(wmove(win,y,x)==ERR?ERR:wgetch(win))
+#define        mvwaddbytes(win,y,x,da,co) \
+               VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,da,co))
+#define        mvwaddstr(win,y,x,str) \
+               VOID(wmove(win,y,x)==ERR?ERR:waddbytes(win,str,strlen(str)))
+#define mvwgetstr(win,y,x,str)  VOID(wmove(win,y,x)==ERR?ERR:wgetstr(win,str))
+#define        mvwinch(win,y,x)        VOID(wmove(win,y,x) == ERR ? ERR : winch(win))
+#define        mvwdelch(win,y,x)       VOID(wmove(win,y,x) == ERR ? ERR : wdelch(win))
+#define        mvwinsch(win,y,x,c)     VOID(wmove(win,y,x) == ERR ? ERR:winsch(win,c))
+#define        mvaddch(y,x,ch)         mvwaddch(stdscr,y,x,ch)
+#define        mvgetch(y,x)            mvwgetch(stdscr,y,x)
+#define        mvaddbytes(y,x,da,co)   mvwaddbytes(stdscr,y,x,da,co)
+#define        mvaddstr(y,x,str)       mvwaddstr(stdscr,y,x,str)
+#define mvgetstr(y,x,str)       mvwgetstr(stdscr,y,x,str)
+#define        mvinch(y,x)             mvwinch(stdscr,y,x)
+#define        mvdelch(y,x)            mvwdelch(stdscr,y,x)
+#define        mvinsch(y,x,c)          mvwinsch(stdscr,y,x,c)
+
+/*
+ * psuedo functions
+ */
+
+#define        clearok(win,bf)  (win->_clear = bf)
+#define        leaveok(win,bf)  (win->_leave = bf)
+#define        scrollok(win,bf) (win->_scroll = bf)
+#define flushok(win,bf)         (bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH))
+#define        getyx(win,y,x)   y = win->_cury, x = win->_curx
+#define        winch(win)       (win->_y[win->_cury][win->_curx] & 0177)
+
+#define raw()   (_tty.sg_flags|=RAW, _pfast=_rawmode=TRUE, \
+       ioctl(_tty_ch, TIOCSETP, &_tty))
+#define noraw()         (_tty.sg_flags&=~RAW,_rawmode=FALSE,\
+       _pfast=!(_tty.sg_flags&CRMOD),ioctl(_tty_ch, TIOCSETP, &_tty))
+#define cbreak() (_tty.sg_flags |= CBREAK, _rawmode = TRUE, \
+       ioctl(_tty_ch, TIOCSETP, &_tty))
+#define nocbreak() (_tty.sg_flags &= ~CBREAK,_rawmode=FALSE, \
+       ioctl(_tty_ch, TIOCSETP, &_tty))
+#define crmode() cbreak()      /* backwards compatability */
+#define nocrmode() nocbreak()  /* backwards compatability */
+#define echo()  (_tty.sg_flags |= ECHO, _echoit = TRUE, \
+       ioctl(_tty_ch, TIOCSETP, &_tty))
+#define noecho() (_tty.sg_flags &= ~ECHO, _echoit = FALSE, \
+       ioctl(_tty_ch, TIOCSETP, &_tty))
+#define nl()    (_tty.sg_flags |= CRMOD,_pfast = _rawmode, \
+       ioctl(_tty_ch, TIOCSETP, &_tty))
+#define nonl()  (_tty.sg_flags &= ~CRMOD, _pfast = TRUE, \
+       ioctl(_tty_ch, TIOCSETP, &_tty))
+#define        savetty() ((void) ioctl(_tty_ch, TIOCGETP, &_tty), \
+       _res_flg = _tty.sg_flags)
+#define        resetty() (_tty.sg_flags = _res_flg, \
+       _echoit = ((_res_flg & ECHO) == ECHO), \
+       _rawmode = ((_res_flg & (CBREAK|RAW)) != 0), \
+       _pfast = ((_res_flg & CRMOD) ? _rawmode : TRUE), \
+       (void) ioctl(_tty_ch, TIOCSETP, &_tty))
+
+#define        erasechar()     (_tty.sg_erase)
+#define        killchar()      (_tty.sg_kill)
+#define baudrate()     (_tty.sg_ospeed)
+
+WINDOW *initscr(), *newwin(), *subwin();
+char   *longname(), *getcap();
+
+/*
+ * Used to be in unctrl.h.
+ */
+#define        unctrl(c)       _unctrl[(c) & 0177]
+extern char *_unctrl[];
+#endif
diff --git a/usr/include/db.h b/usr/include/db.h
new file mode 100644 (file)
index 0000000..44c1099
--- /dev/null
@@ -0,0 +1,158 @@
+/*-
+ * 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.
+ *
+ *     @(#)db.h        5.10 (Berkeley) 4/2/91
+ */
+
+#ifndef _DB_H_
+#define        _DB_H_
+
+#include <sys/cdefs.h>
+
+/* flags for DB.put() call */
+#define        R_IBEFORE       1               /* RECNO */
+#define        R_IAFTER        2               /* RECNO */
+#define        R_NOOVERWRITE   3               /* BTREE, HASH, RECNO */
+#define        R_PUT           4               /* BTREE, HASH, RECNO */
+
+/* flags for DB.seq() call */
+#define        R_CURSOR        1               /* BTREE, RECNO */
+#define        R_FIRST         2               /* BTREE, HASH, RECNO */
+#define        R_LAST          3               /* BTREE, RECNO */
+#define        R_NEXT          4               /* BTREE, HASH, RECNO */
+#define        R_PREV          5               /* BTREE, RECNO */
+
+/* key/data structure -- a data-base thang */
+typedef struct {
+       void *data;
+       int size;
+} DBT;
+
+/* access method description structure */
+typedef struct __db {
+       void *internal;         /* access method private */
+#define        DB_BTREE        1
+#define        DB_HASH         2
+#define        DB_RECNO        3
+       int type;               /* type of underlying db */
+       int (*close) __P((const struct __db *));
+       int (*del) __P((const struct __db *, const DBT *, unsigned int));
+       int (*get) __P((const struct __db *, DBT *, DBT *, unsigned int));
+       int (*put) __P((const struct __db *, const DBT *, const DBT *,
+               unsigned int));
+       int (*seq) __P((const struct __db *, DBT *, DBT *, unsigned int));
+       int (*sync) __P((const struct __db *));
+} DB;
+
+#define        BTREEMAGIC      0x053162
+#define        BTREEVERSION    2
+
+/* structure used to pass parameters to the btree routines */
+typedef struct {
+#define        R_DUP           0x01    /* duplicate keys */
+       u_long flags;
+       int cachesize;          /* bytes to cache */
+       int psize;              /* page size */
+       int (*compare)();       /* compare function */
+       int lorder;             /* byte order */
+} BTREEINFO;
+
+#define        HASHMAGIC       0x061561
+#define        HASHVERSION     1
+
+/* structure used to pass parameters to the hashing routines */
+typedef struct {
+       int bsize;              /* bucket size */
+       int ffactor;            /* fill factor */
+       int nelem;              /* number of elements */
+       int cachesize;          /* bytes to cache */
+       int (*hash)();          /* hash function */
+       int lorder;             /* byte order */
+} HASHINFO;
+
+/* structure used to pass parameters to the record routines */
+typedef struct {
+#define        R_FIXEDLEN      0x01    /* fixed-length records */
+       u_long flags;
+       int cachesize;          /* bytes to cache */
+       size_t reclen;          /* record length (fixed-length records) */
+       u_char bval;            /* delimiting byte (variable-length records */
+} RECNOINFO;
+
+/* key structure for the record routines */
+typedef struct {
+       u_long number;
+       u_long offset;
+       u_long length;
+#define        R_LENGTH        0x01    /* length is valid */
+#define        R_NUMBER        0x02    /* record number is valid */
+#define        R_OFFSET        0x04    /* offset is valid */
+       u_char valid;
+} RECNOKEY;
+
+/* Little endian <--> big endian long swap macros. */
+#define BLSWAP(a) { \
+       u_long _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        BLSWAP_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 short swap macros. */
+#define BSSWAP(a) { \
+       u_short _tmp = a; \
+       ((char *)&a)[0] = ((char *)&_tmp)[1]; \
+       ((char *)&a)[1] = ((char *)&_tmp)[0]; \
+}
+#define BSSWAP_COPY(a,b) { \
+       ((char *)&(b))[0] = ((char *)&(a))[1]; \
+       ((char *)&(b))[1] = ((char *)&(a))[0]; \
+}
+
+__BEGIN_DECLS
+DB     *btree_open
+           __P((const char *, int, int, const BTREEINFO *));
+DB     *hash_open
+           __P((const char *, int, int, const HASHINFO *));
+DB     *recno_open
+           __P((const char *, int, int, const RECNOINFO *));
+__END_DECLS
+
+#endif /* !_DB_H_ */
diff --git a/usr/include/dirent.h b/usr/include/dirent.h
new file mode 100644 (file)
index 0000000..fb42a44
--- /dev/null
@@ -0,0 +1,107 @@
+/*-
+ * 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.
+ *
+ *     @(#)dirent.h    5.18 (Berkeley) 2/23/91
+ */
+
+#ifndef _DIRENT_H_
+#define _DIRENT_H_
+
+/*
+ * A directory entry has a struct dirent at the front of it, containing its
+ * inode number, the length of the entry, and the length of the name
+ * contained in the entry.  These are followed by the name padded to a 4
+ * byte boundary with null bytes.  All names are guaranteed null terminated.
+ * The maximum length of a name in a directory is MAXNAMLEN.
+ */
+
+struct dirent {
+       u_long  d_fileno;               /* file number of entry */
+       u_short d_reclen;               /* length of this record */
+       u_short d_namlen;               /* length of string in d_name */
+#ifdef _POSIX_SOURCE
+       char    d_name[255 + 1];        /* name must be no longer than this */
+#else
+#define        MAXNAMLEN       255
+       char    d_name[MAXNAMLEN + 1];  /* name must be no longer than this */
+#endif
+};
+
+#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 */
+} DIR;
+
+#define        dirfd(dirp)     ((dirp)->dd_fd)
+
+#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
+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/usr/include/disktab.h b/usr/include/disktab.h
new file mode 100644 (file)
index 0000000..fe99acb
--- /dev/null
@@ -0,0 +1,61 @@
+/*
+ * 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/usr/include/errno.h b/usr/include/errno.h
new file mode 120000 (symlink)
index 0000000..7280063
--- /dev/null
@@ -0,0 +1 @@
+sys/errno.h
\ No newline at end of file
diff --git a/usr/include/fcntl.h b/usr/include/fcntl.h
new file mode 120000 (symlink)
index 0000000..b5c3c64
--- /dev/null
@@ -0,0 +1 @@
+sys/fcntl.h
\ No newline at end of file
diff --git a/usr/include/float.h b/usr/include/float.h
new file mode 120000 (symlink)
index 0000000..4326e7f
--- /dev/null
@@ -0,0 +1 @@
+machine/float.h
\ No newline at end of file
diff --git a/usr/include/frame.h b/usr/include/frame.h
new file mode 120000 (symlink)
index 0000000..ebe366b
--- /dev/null
@@ -0,0 +1 @@
+machine/frame.h
\ No newline at end of file
diff --git a/usr/include/fstab.h b/usr/include/fstab.h
new file mode 100644 (file)
index 0000000..5359313
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * 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/usr/include/fts.h b/usr/include/fts.h
new file mode 100644 (file)
index 0000000..b7af5d5
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * 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.
+ *
+ *     @(#)fts.h       5.14 (Berkeley) 4/3/91
+ */
+
+#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_savelink;   /* saved link if node had a cycle */
+       struct _ftsent **fts_array;     /* sort array */
+       dev_t rdev;                     /* starting device # */
+       char *fts_path;                 /* path for this descent */
+       int fts_dfd;                    /* fd for directories */
+       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_LOGICAL     0x001           /* logical walk */
+#define        FTS_NOCHDIR     0x002           /* don't change directories */
+#define        FTS_NOSTAT      0x004           /* don't get stat info */
+#define        FTS_PHYSICAL    0x008           /* physical walk */
+#define        FTS_SEEDOT      0x010           /* return dot and dot-dot */
+#define        FTS_STOP        0x020           /* (private) unrecoverable error */
+#define        FTS_XDEV        0x040           /* don't cross devices */
+       int fts_options;                /* openfts() options */
+} FTS;
+
+typedef struct _ftsent {
+       struct _ftsent *fts_parent;     /* parent directory */
+       struct _ftsent *fts_link;       /* cycle or next file structure */
+       union {
+               long number;            /* local numeric value */
+               void *pointer;          /* local address value */
+       } fts_local;
+#define        fts_number      fts_local.number
+#define        fts_pointer     fts_local.pointer
+       char *fts_accpath;              /* access path */
+       char *fts_path;                 /* root path */
+       int fts_cderr;                  /* chdir failed -- errno */
+       short fts_pathlen;              /* strlen(fts_path) */
+       short fts_namelen;              /* strlen(fts_name) */
+
+#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_DP           5              /* postorder directory */
+#define        FTS_ERR          6              /* error; errno is set */
+#define        FTS_F            7              /* regular file */
+#define        FTS_NS           8              /* stat(2) failed */
+#define        FTS_NSOK         9              /* no stat(2) requested */
+#define        FTS_SL          10              /* symbolic link */
+#define        FTS_SLNONE      11              /* symbolic link without target */
+       u_short fts_info;               /* user 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_statb;          /* stat(2) information */
+       char fts_name[1];               /* file name */
+} FTSENT;
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+FTSENT *fts_children __P((FTS *));
+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/usr/include/g++/ACG.h b/usr/include/g++/ACG.h
new file mode 100644 (file)
index 0000000..aba4ddc
--- /dev/null
@@ -0,0 +1,74 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _ACG_h
+#define _ACG_h 1 
+
+#include <RNG.h>
+#include <math.h>
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+
+//
+//     Additive number generator. This method is presented in Volume II
+//     of The Art of Computer Programming by Knuth. I've coded the algorithm
+//     and have added the extensions by Andres Nowatzyk of CMU to randomize
+//     the result of algorithm M a bit by using an LCG & a spatial
+//     permutation table.
+//
+//     The version presented uses the same constants for the LCG that Andres
+//     uses (chosen by trial & error). The spatial permutation table is
+//     the same size (it's based on word size). This is for 32-bit words.
+//
+//     The ``auxillary table'' used by the LCG table varies in size, and
+//     is chosen to be the the smallest power of two which is larger than
+//     twice the size of the state table.
+//
+
+class ACG : public RNG {
+
+    unsigned long initialSeed; // used to reset generator
+    int initialTableEntry;
+
+    unsigned long *state;
+    unsigned long *auxState;
+    short stateSize;
+    short auxSize;
+    unsigned long lcgRecurr;
+    short j;
+    short k;
+
+protected:
+
+public:
+    ACG(unsigned long seed = 0, int size = 55);
+    virtual ~ACG();
+    //
+    // Return a long-words word of random bits
+    //
+    virtual unsigned long asLong();
+    virtual void reset();
+};
+
+#endif
diff --git a/usr/include/g++/AllocRing.h b/usr/include/g++/AllocRing.h
new file mode 100644 (file)
index 0000000..ac42cbb
--- /dev/null
@@ -0,0 +1,68 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1989 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _AllocRing_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _AllocRing_h 1
+
+
+/*
+  An AllocRing holds the last n malloc'ed strings, reallocating/reusing 
+  one only when the queue wraps around. It thus guarantees that the
+  last n allocations are intact. It is useful for things like I/O
+  formatting where reasonable restrictions may be made about the
+  number of allowable live allocations before auto-deletion.
+*/
+
+class AllocRing
+{
+
+  struct AllocQNode
+  {
+    void*  ptr;
+    int    sz;
+  };
+
+  AllocQNode* nodes;
+  int         n;
+  int         current;
+
+  int         find(void* p);
+
+public:
+
+              AllocRing(int max);
+             ~AllocRing();
+
+  void*       alloc(int size);
+  int         contains(void* ptr);
+  void        clear();
+  void        free(void* p);
+};
+
+
+#endif
diff --git a/usr/include/g++/Binomial.h b/usr/include/g++/Binomial.h
new file mode 100644 (file)
index 0000000..bae38a5
--- /dev/null
@@ -0,0 +1,63 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _Binomial_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Binomial_h 1
+
+#include <Random.h>
+
+class Binomial: public Random {
+protected:
+    int pN;
+    double pU;
+public:
+    Binomial(int n, double u, RNG *gen);
+
+    int n();
+    int n(int xn);
+
+    double u();
+    double u(int xu);
+
+    virtual double operator()();
+
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline Binomial::Binomial(int n, double u, RNG *gen)
+: (gen){
+  pN = n; pU = u;
+}
+
+inline int Binomial::n() { return pN; }
+inline int Binomial::n(int xn) { int tmp = pN; pN = xn; return tmp; }
+
+inline double Binomial::u() { return pU; }
+inline double Binomial::u(int xu) { double tmp = pU; pU = xu; return tmp; }
+
+#endif
+#endif
diff --git a/usr/include/g++/BitSet.h b/usr/include/g++/BitSet.h
new file mode 100644 (file)
index 0000000..a99340e
--- /dev/null
@@ -0,0 +1,385 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _BitSet_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+
+#define _BitSet_h 1
+
+#include <stream.h>
+#include <values.h>
+
+#define BITSETBITS  BITS(short)
+
+struct BitSetRep
+{
+  unsigned short  len;          // number of shorts in s
+  unsigned short  sz;           // allocated slots
+  unsigned short  virt;         // virtual 0 or 1
+  unsigned short  s[1];         // bits start here
+};
+
+extern BitSetRep*   BitSetalloc(BitSetRep*, const unsigned short*, 
+                                int, int, int);
+extern BitSetRep*   BitSetcopy(BitSetRep*, const BitSetRep*);
+extern BitSetRep*   BitSetresize(BitSetRep*, int);
+extern BitSetRep*   BitSetop(const BitSetRep*, const BitSetRep*, 
+                             BitSetRep*, char);
+extern BitSetRep*   BitSetcmpl(const BitSetRep*, BitSetRep*);
+
+
+extern BitSetRep    _nilBitSetRep;
+
+class BitSet;
+
+class BitSetBit
+{
+protected:
+  BitSet*            src;
+  unsigned long      pos;
+
+ public:
+                     BitSetBit(BitSet* v, int p);
+                     BitSetBit(const BitSetBit& b);
+                    ~BitSetBit();
+                     operator int();
+  int                operator = (int b);
+  int                operator == (int b);
+  int                operator != (int b);
+};
+
+class BitSet
+{
+protected:
+  BitSetRep*          rep;
+
+  
+public:
+
+// constructors
+                     BitSet();
+                     BitSet(const BitSet&);
+
+                    ~BitSet();
+
+  void               operator =  (const BitSet& y);
+
+// equality & subset tests
+
+  friend int         operator == (const BitSet& x, const BitSet& y);
+  friend int         operator != (const BitSet& x, const BitSet& y);
+  friend int         operator <  (const BitSet& x, const BitSet& y);
+  friend int         operator <= (const BitSet& x, const BitSet& y);
+  friend int         operator >  (const BitSet& x, const BitSet& y);
+  friend int         operator >= (const BitSet& x, const BitSet& y);
+
+
+// operations on self
+
+  void               operator |= (const BitSet& y);
+  void               operator &= (const BitSet& y);
+  void               operator -= (const BitSet& y);
+  void               operator ^= (const BitSet& y);
+
+  void               complement();
+
+// individual bit manipulation
+
+  void               set(int pos);
+  void               set(int from, int to);
+  void               set(); // set all
+
+  void               clear(int pos);
+  void               clear(int from, int to);
+  void               clear(); // clear all
+
+  void               invert(int pos);
+  void               invert(int from, int to);
+
+  int                test(int pos) const;
+  int                test(int from, int to) const;
+
+  BitSetBit          operator [] (int i);
+  
+// iterators
+
+  int                first(int b = 1) const;
+  int                last(int b = 1) const;
+
+  int                next(int pos, int b = 1) const;
+  int                previous(int pos, int b = 1) const;
+
+// status
+
+  int                empty() const;
+  int                virtual_bit() const;
+  int                count(int b = 1) const;
+  
+// convertors & IO
+
+  friend BitSet      atoBitSet(const char* s, 
+                               char f='0', char t='1', char star='*');
+  friend const char* BitSettoa(const BitSet& x, 
+                               char f='0', char t='1', char star='*');
+
+  friend BitSet      shorttoBitSet(unsigned short w);
+  friend BitSet      longtoBitSet(unsigned long w);
+
+  friend ostream&    operator << (ostream& s, const BitSet& x);
+
+// procedural versions of operators
+
+  friend void        and(const BitSet& x, const BitSet& y, BitSet& r);
+  friend void        or(const BitSet& x, const BitSet& y, BitSet& r);
+  friend void        xor(const BitSet& x, const BitSet& y, BitSet& r);
+  friend void        diff(const BitSet& x, const BitSet& y, BitSet& r);
+  friend void        complement(const BitSet& x, BitSet& r);
+
+// misc
+
+  volatile void      error(const char* msg) const;
+  int                OK() const;
+};
+
+
+typedef BitSet BitSetTmp;
+
+
+  BitSet      operator |  (const BitSet& x, const BitSet& y);
+  BitSet      operator &  (const BitSet& x, const BitSet& y);
+  BitSet      operator -  (const BitSet& x, const BitSet& y);
+  BitSet      operator ^  (const BitSet& x, const BitSet& y);
+
+  BitSet      operator ~  (const BitSet& x);
+
+// These are inlined regardless of optimization
+
+inline int BitSet_index(int l)
+{
+  return (unsigned)(l) / BITSETBITS;
+}
+
+inline int BitSet_pos(int l)
+{
+  return l & (BITSETBITS - 1);
+}
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+
+inline BitSet::BitSet() : rep(&_nilBitSetRep) {}
+
+inline BitSet::BitSet(const BitSet& x) :rep(BitSetcopy(0, x.rep)) {}
+
+inline BitSet::~BitSet() { if (rep != &_nilBitSetRep) delete rep; }
+
+inline void BitSet::operator =  (const BitSet& y)
+{ 
+  rep = BitSetcopy(rep, y.rep);
+}
+
+inline int operator != (const BitSet& x, const BitSet& y) { return !(x == y); }
+
+inline int operator >  (const BitSet& x, const BitSet& y) { return y < x; }
+
+inline int operator >= (const BitSet& x, const BitSet& y) { return y <= x; }
+
+inline void and(const BitSet& x, const BitSet& y, BitSet& r)
+{
+  r.rep =  BitSetop(x.rep, y.rep, r.rep, '&');
+}
+
+inline void or(const BitSet& x, const BitSet& y, BitSet& r)
+{
+  r.rep =  BitSetop(x.rep, y.rep, r.rep, '|');
+}
+
+inline void xor(const BitSet& x, const BitSet& y, BitSet& r)
+{
+  r.rep =  BitSetop(x.rep, y.rep, r.rep, '^');
+}
+
+inline void diff(const BitSet& x, const BitSet& y, BitSet& r)
+{
+  r.rep =  BitSetop(x.rep, y.rep, r.rep, '-');
+}
+
+inline void complement(const BitSet& x, BitSet& r)
+{
+  r.rep = BitSetcmpl(x.rep, r.rep);
+}
+
+#if defined(__GNUG__) && !defined(NO_NRV)
+
+inline BitSet operator & (const BitSet& x, const BitSet& y) return r
+{
+  and(x, y, r);
+}
+
+inline BitSet operator | (const BitSet& x, const BitSet& y) return r
+{
+  or(x, y, r);
+}
+
+inline BitSet operator ^ (const BitSet& x, const BitSet& y) return r
+{
+  xor(x, y, r);
+}
+
+inline BitSet operator - (const BitSet& x, const BitSet& y) return r
+{
+  diff(x, y, r);
+}
+
+inline BitSet operator ~ (const BitSet& x) return r
+{
+  ::complement(x, r);
+}
+
+#else /* NO_NRV */
+
+inline BitSet operator & (const BitSet& x, const BitSet& y) 
+{
+  BitSet r; and(x, y, r); return r;
+}
+
+inline BitSet operator | (const BitSet& x, const BitSet& y) 
+{
+  BitSet r; or(x, y, r); return r;
+}
+
+inline BitSet operator ^ (const BitSet& x, const BitSet& y) 
+{
+  BitSet r; xor(x, y, r); return r;
+}
+
+inline BitSet operator - (const BitSet& x, const BitSet& y) 
+{
+  BitSet r; diff(x, y, r); return r;
+}
+
+inline BitSet operator ~ (const BitSet& x) 
+{
+  BitSet r; ::complement(x, r); return r;
+}
+
+#endif
+
+inline void BitSet::operator &= (const BitSet& y)
+{
+  and(*this, y, *this);
+}
+
+inline void BitSet::operator |= (const BitSet& y)
+{
+  or(*this, y, *this);
+}
+
+inline void BitSet::operator ^= (const BitSet& y)
+{
+  xor(*this, y, *this);
+}
+
+inline void BitSet::operator -= (const BitSet& y)
+{
+  diff(*this, y, *this);
+}
+
+
+inline void BitSet::complement()
+{
+  ::complement(*this, *this);
+}
+
+inline int BitSet::virtual_bit() const
+{
+  return rep->virt;
+}
+
+inline int BitSet::first(int b) const
+{
+  return next(-1, b);
+}
+
+inline int BitSet::test(int p) const
+{
+  if (p < 0) error("Illegal bit index");
+  int index = BitSet_index(p);
+  return (index >= rep->len)? rep->virt : 
+         ((rep->s[index] & (1 << BitSet_pos(p))) != 0);
+}
+
+
+inline void BitSet::clear()
+{
+  if (rep->len > 0) bzero(rep->s, rep->sz * sizeof(short));
+  rep->len = rep->virt = 0;
+}
+
+inline void BitSet::set()
+{
+  rep = BitSetalloc(rep, 0, 0, 1, 0);
+}
+
+inline BitSetBit::BitSetBit(const BitSetBit& b) :src(b.src), pos(b.pos) {}
+
+inline BitSetBit::BitSetBit(BitSet* v, int p)
+{
+  src = v;  pos = p;
+}
+
+inline BitSetBit::~BitSetBit() {}
+
+inline BitSetBit::operator int()
+{
+  return src->test(pos);
+}
+
+inline int BitSetBit::operator = (int b)
+{
+  if (b) src->set(pos); else src->clear(pos); return b;
+}
+
+inline int BitSetBit::operator == (int b)
+{
+  return src->test(pos) == b;
+}
+
+inline int BitSetBit::operator != (int b)
+{
+  return src->test(pos) != b;
+}
+
+inline BitSetBit BitSet::operator [] (int i)
+{
+  if (i < 0) error("illegal bit index");
+  return BitSetBit(this, i);
+}
+
+
+
+#endif
+#endif
diff --git a/usr/include/g++/BitString.h b/usr/include/g++/BitString.h
new file mode 100644 (file)
index 0000000..bdcf4c1
--- /dev/null
@@ -0,0 +1,773 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _BitString_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+
+#define _BitString_h 1
+
+#include <stream.h>
+#include <values.h>
+
+#define BITSTRBITS   BITS(short)
+
+struct BitStrRep
+{
+  unsigned int    len;          // length in bits
+  unsigned short  sz;           // allocated slots
+  unsigned short  s[1];         // bits start here
+};
+
+extern BitStrRep*  BStr_alloc(BitStrRep*, const unsigned short*, int, int,int);
+extern BitStrRep*  BStr_resize(BitStrRep*, int);
+extern BitStrRep*  BStr_copy(BitStrRep*, const BitStrRep*);
+extern BitStrRep*  cmpl(const BitStrRep*, BitStrRep*);
+extern BitStrRep*  and(const BitStrRep*, const BitStrRep*, BitStrRep*);
+extern BitStrRep*  or(const BitStrRep*, const BitStrRep*, BitStrRep*);
+extern BitStrRep*  xor(const BitStrRep*, const BitStrRep*, BitStrRep*);
+extern BitStrRep*  diff(const BitStrRep*, const BitStrRep*, BitStrRep*);
+extern BitStrRep*  cat(const BitStrRep*, const BitStrRep*, BitStrRep*);
+extern BitStrRep*  cat(const BitStrRep*, unsigned int, BitStrRep*);
+extern BitStrRep*  lshift(const BitStrRep*, int, BitStrRep*);
+
+
+class BitString;
+class BitPattern;
+
+class BitStrBit
+{
+protected:
+  BitString&        src;
+  unsigned int      pos;
+
+ public:
+                    BitStrBit(BitString& v, int p);
+                    BitStrBit(const BitStrBit& b);
+                   ~BitStrBit();
+                    operator unsigned int() const;
+  int               operator =  (unsigned int b);
+  int               operator == (unsigned int b) const ;
+  int               operator != (unsigned int b) const ;
+};
+
+class BitSubString
+{
+  friend class      BitString;
+  friend class      BitPattern;
+
+protected:
+
+  BitString&        S;
+  int               pos;
+  int               len;
+
+                    BitSubString(BitString& x, int p, int l);
+                    BitSubString(const BitSubString& x);
+public:
+                    ~BitSubString();
+
+  void              operator =  (const BitString&);
+  void              operator =  (const BitSubString&);
+
+  int               length() const;
+  int               empty() const;
+
+  int               OK() const;
+};
+
+class BitString
+{
+  friend class       BitSubString;
+  friend class       BitPattern;
+protected:
+  BitStrRep*         rep;
+
+  int                search(int, int, const unsigned short*, int, int) const;
+  int                match(int, int, int, const unsigned short*,int,int) const;
+  BitSubString       _substr(int first, int l);
+
+public:
+
+// constructors
+                     BitString();
+                     BitString(const BitString&);
+                     BitString(const BitSubString& y);
+
+                    ~BitString();
+
+  void               operator =  (unsigned int bit);
+  void               operator =  (const BitString& y);
+  void               operator =  (const BitSubString& y);
+
+// equality & subset tests
+
+  friend int         operator == (const BitString&, const BitString&);
+  friend int         operator != (const BitString&, const BitString&);
+  friend int         operator <  (const BitString&, const BitString&);
+  friend int         operator <= (const BitString&, const BitString&);
+  friend int         operator >  (const BitString&, const BitString&);
+  friend int         operator >= (const BitString&, const BitString&);
+
+// procedural versions of operators
+
+
+  friend void        and(const BitString&, const BitString&, BitString&);
+  friend void        or(const BitString&, const BitString&, BitString&);
+  friend void        xor(const BitString&, const BitString&, BitString&);
+  friend void        diff(const BitString&, const BitString&, BitString&);
+  friend void        cat(const BitString&, const BitString&, BitString&);
+  friend void        cat(const BitString&, unsigned int, BitString&);
+  friend void        lshift(const BitString&, int, BitString&);
+  friend void        rshift(const BitString&, int, BitString&);
+
+  friend void        complement(const BitString&, BitString&);
+
+  friend int         lcompare(const BitString&, const BitString&); 
+
+// assignment-based operators
+// (constuctive versions decalred inline below
+
+  void               operator |= (const BitString&);
+  void               operator &= (const BitString&);
+  void               operator -= (const BitString&);
+  void               operator ^= (const BitString&);
+  void               operator += (const BitString&);
+  void               operator += (unsigned int b);
+  void               operator <<=(int s);
+  void               operator >>=(int s);
+
+  void               complement();
+
+// individual bit manipulation
+
+  void               set(int pos);
+  void               set(int from, int to);
+  void               set();
+
+  void               clear(int pos);
+  void               clear(int from, int to);
+  void               clear(); 
+
+  void               invert(int pos);
+  void               invert(int from, int to);
+
+  int                test(int pos) const;
+  int                test(int from, int to) const;
+
+  void               assign(int p, unsigned int bit);
+
+// indexing
+
+  BitStrBit          operator [] (int pos);
+
+// iterators
+
+  int                first(unsigned int bit = 1) const;
+  int                last(unsigned int b = 1) const;
+
+  int                next(int pos, unsigned int b = 1) const;
+  int                previous(int pos, unsigned int b = 1) const;
+
+// searching & matching
+
+  int                index(unsigned int bit, int startpos = 0) const ;      
+  int                index(const BitString&, int startpos = 0) const;
+  int                index(const BitSubString&, int startpos = 0) const;
+  int                index(const BitPattern&, int startpos = 0) const;
+
+  int                contains(const BitString&) const;
+  int                contains(const BitSubString&) const;
+  int                contains(const BitPattern&) const;
+
+  int                contains(const BitString&, int pos) const;
+  int                contains(const BitSubString&, int pos) const;
+  int                contains(const BitPattern&, int pos) const;
+
+  int                matches(const BitString&, int pos = 0) const;
+  int                matches(const BitSubString&, int pos = 0) const;
+  int                matches(const BitPattern&, int pos = 0) const;
+
+// BitSubString extraction
+
+  BitSubString       at(int pos, int len);
+  BitSubString       at(const BitString&, int startpos = 0); 
+  BitSubString       at(const BitSubString&, int startpos = 0); 
+  BitSubString       at(const BitPattern&, int startpos = 0); 
+
+  BitSubString       before(int pos);
+  BitSubString       before(const BitString&, int startpos = 0);
+  BitSubString       before(const BitSubString&, int startpos = 0);
+  BitSubString       before(const BitPattern&, int startpos = 0);
+
+  BitSubString       after(int pos);
+  BitSubString       after(const BitString&, int startpos = 0);
+  BitSubString       after(const BitSubString&, int startpos = 0);
+  BitSubString       after(const BitPattern&, int startpos = 0);
+
+// other friends & utilities
+
+  friend BitString   common_prefix(const BitString&, const BitString&, 
+                                   int pos = 0);
+  friend BitString   common_suffix(const BitString&, const BitString&, 
+                                   int pos = -1);
+  friend BitString   reverse(const BitString&);
+
+  void               right_trim(unsigned int bit);
+  void               left_trim(unsigned int bit);
+
+// status
+
+  int                empty() const ;
+  int                count(unsigned int bit = 1) const;
+  int                length() const;
+
+// convertors & IO
+
+  friend BitString   atoBitString(const char* s, char f='0', char t='1');
+  friend const char* BitStringtoa(const BitString&, char f='0', char t='1');
+
+  friend BitString   shorttoBitString(unsigned short);
+  friend BitString   longtoBitString(unsigned long);
+
+  friend ostream&    operator << (ostream& s, const BitString&);
+
+// misc
+
+  volatile void      error(const char* msg) const;
+
+// indirect friends
+
+  friend const char* BitPatterntoa(const BitPattern& p, 
+                                  char f='0',char t='1',char x='X');
+  friend BitPattern  atoBitPattern(const char* s,
+                                  char f='0',char t='1',char x='X');
+
+  int                OK() const;
+};
+
+
+class BitPattern
+{
+public:
+  BitString          pattern;
+  BitString          mask;
+
+                     BitPattern();
+                     BitPattern(const BitPattern&);
+                     BitPattern(const BitString& p, const BitString& m);
+
+                    ~BitPattern();
+
+  friend const char* BitPatterntoa(const BitPattern&, char f, char t, char x);
+  friend BitPattern atoBitPattern(const char* s, char f,char t, char x);
+  friend ostream&   operator << (ostream& s, const BitPattern&);
+
+  int               search(const unsigned short*, int, int) const;
+  int               match(const unsigned short* xs, int, int, int) const;
+
+  int               OK() const;
+};
+
+BitString  operator & (const BitString& x, const BitString& y);
+BitString  operator | (const BitString& x, const BitString& y);
+BitString  operator ^ (const BitString& x, const BitString& y);
+BitString  operator << (const BitString& x, int y);
+BitString  operator >> (const BitString& x, int y);
+BitString  operator - (const BitString& x, const BitString& y);
+BitString  operator + (const BitString& x, const BitString& y);
+BitString  operator + (const BitString& x, unsigned int y);
+BitString  operator ~ (const BitString& x);
+int operator != (const BitString& x, const BitString& y);
+int operator>(const BitString& x, const BitString& y);
+int operator>=(const BitString& x, const BitString& y);
+
+extern BitStrRep    _nilBitStrRep;
+extern BitString    _nil_BitString;
+
+// primitive bit extraction
+
+// These must be inlined regardless of optimization.
+
+inline int BitStr_index(int l) { return (unsigned)(l) / BITSTRBITS; }
+
+inline int BitStr_pos(int l) { return l & (BITSTRBITS - 1); }
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+// constructors & assignment
+
+inline BitString::BitString() :rep(&_nilBitStrRep) {}
+
+inline BitString::BitString(const BitString& x) :rep(BStr_copy(0, x.rep)) {}
+
+inline BitString::BitString(const BitSubString& y) 
+   :rep (BStr_alloc(0, y.S.rep->s, y.pos, y.pos+y.len, y.len)) {}
+
+inline BitString::~BitString()
+{ 
+  if (rep != &_nilBitStrRep) delete rep;
+}
+
+#if defined(__GNUG__) && !defined(NO_NRV)
+
+inline BitString shorttoBitString(unsigned short w) return r
+{ 
+  r.rep = BStr_alloc(0, &w, 0, BITSTRBITS, BITSTRBITS);
+}
+
+inline BitString longtoBitString(unsigned long w) return r
+{ 
+  unsigned short u[2];
+  u[0] = w & ((unsigned short)(~(0)));
+  u[1] = w >> BITSTRBITS;
+  r.rep = BStr_alloc(0, &u[0], 0, 2*BITSTRBITS, 2*BITSTRBITS);
+}
+
+#else
+
+inline BitString shorttoBitString(unsigned short w) 
+{ 
+  BitString r; r.rep = BStr_alloc(0, &w, 0, BITSTRBITS, BITSTRBITS); return r;
+}
+
+inline BitString longtoBitString(unsigned long w) 
+{ 
+  BitString r;
+  unsigned short u[2];
+  u[0] = w & ((unsigned short)(~(0)));
+  u[1] = w >> BITSTRBITS;
+  r.rep = BStr_alloc(0, &u[0], 0, 2*BITSTRBITS, 2*BITSTRBITS);
+  return r;
+}
+
+#endif
+
+inline void BitString::operator =  (const BitString& y)
+{ 
+  rep = BStr_copy(rep, y.rep);
+}
+
+inline void BitString::operator = (unsigned int b)
+{ 
+  unsigned short bit = b;
+  rep = BStr_alloc(rep, &bit, 0, 1, 1);
+}
+
+inline void BitString::operator=(const BitSubString&  y)
+{
+  rep = BStr_alloc(rep, y.S.rep->s, y.pos, y.pos+y.len, y.len);
+}
+
+inline BitSubString::BitSubString(const BitSubString& x) 
+    :S(x.S), pos(x.pos), len(x.len) {}
+
+inline BitSubString::BitSubString(BitString& x, int p, int l)
+     : S(x), pos(p), len(l) {}
+
+inline BitSubString::~BitSubString() {}
+
+inline BitPattern::BitPattern(const BitString& p, const BitString& m)
+    :pattern(p), mask(m) {}
+
+inline BitPattern::BitPattern(const BitPattern& b)
+    :pattern(b.pattern), mask(b.mask) {}
+
+inline BitPattern::BitPattern() {}
+inline BitPattern::~BitPattern() {}
+
+
+// procedural versions of operators
+
+inline void and(const BitString& x, const BitString& y, BitString& r)
+{
+  r.rep = and(x.rep, y.rep, r.rep);
+}
+
+inline void or(const BitString& x, const BitString& y, BitString& r)
+{
+  r.rep = or(x.rep, y.rep, r.rep);
+}
+
+inline void xor(const BitString& x, const BitString& y, BitString& r)
+{
+  r.rep = xor(x.rep, y.rep, r.rep);
+}
+
+inline void diff(const BitString& x, const BitString& y, BitString& r)
+{
+  r.rep = diff(x.rep, y.rep, r.rep);
+}
+
+inline void cat(const BitString& x, const BitString& y, BitString& r)
+{
+  r.rep = cat(x.rep, y.rep, r.rep);
+}
+
+inline void cat(const BitString& x, unsigned int y, BitString& r)
+{
+  r.rep = cat(x.rep, y, r.rep);
+}
+
+inline void rshift(const BitString& x, int y, BitString& r)
+{
+  r.rep = lshift(x.rep, -y, r.rep);
+}
+
+inline void lshift(const BitString& x, int y, BitString& r)
+{
+  r.rep = lshift(x.rep, y, r.rep);
+}
+
+inline void complement(const BitString& x, BitString& r)
+{
+  r.rep = cmpl(x.rep, r.rep);
+}
+
+// operators
+
+
+inline void BitString::operator &= (const BitString& y)
+{
+  and(*this, y, *this);
+}
+
+
+inline void BitString::operator |= (const BitString& y)
+{
+  or(*this, y, *this);
+}
+
+inline void BitString::operator ^= (const BitString& y)
+{
+  xor(*this, y, *this);
+}
+
+inline void BitString::operator <<= (int y)
+{
+  lshift(*this, y, *this);
+}
+
+inline void BitString::operator >>= (int y)
+{
+  rshift(*this, y, *this);
+}
+
+inline void BitString::operator -= (const BitString& y)
+{
+  diff(*this, y, *this);
+}
+
+inline void BitString::operator += (const BitString& y)
+{
+  cat(*this, y, *this);
+}
+
+inline void BitString::operator += (unsigned int y)
+{
+  cat(*this, y, *this);
+}
+
+inline void BitString::complement()
+{
+  ::complement(*this, *this);
+}
+
+#if defined(__GNUG__) && !defined(NO_NRV)
+
+inline BitString  operator & (const BitString& x, const BitString& y) return r
+{
+  and(x, y, r);
+}
+
+inline BitString  operator | (const BitString& x, const BitString& y) return r
+{
+  or(x, y, r);
+}
+
+inline BitString  operator ^ (const BitString& x, const BitString& y) return r
+{
+  xor(x, y, r);
+}
+
+inline BitString  operator << (const BitString& x, int y) return r
+{
+  lshift(x, y, r);
+}
+
+inline BitString  operator >> (const BitString& x, int y) return r
+{
+  rshift(x, y, r);
+}
+
+inline BitString  operator - (const BitString& x, const BitString& y) return r
+{
+  diff(x, y, r);
+}
+
+inline BitString  operator + (const BitString& x, const BitString& y) return r
+{
+  cat(x, y, r);
+}
+
+inline BitString  operator + (const BitString& x, unsigned int y) return r
+{
+  cat(x, y, r);
+}
+
+inline BitString  operator ~ (const BitString& x) return r
+{
+  complement(x, r);
+}
+
+#else /* NO_NRV */
+
+inline BitString  operator & (const BitString& x, const BitString& y) 
+{
+  BitString r; and(x, y, r); return r;
+}
+
+inline BitString  operator | (const BitString& x, const BitString& y) 
+{
+  BitString r; or(x, y, r); return r;
+}
+
+inline BitString  operator ^ (const BitString& x, const BitString& y) 
+{
+  BitString r; xor(x, y, r); return r;
+}
+
+inline BitString  operator << (const BitString& x, int y) 
+{
+  BitString r; lshift(x, y, r); return r;
+}
+
+inline BitString  operator >> (const BitString& x, int y) 
+{
+  BitString r; rshift(x, y, r); return r;
+}
+
+inline BitString  operator - (const BitString& x, const BitString& y) 
+{
+  BitString r; diff(x, y, r); return r;
+}
+
+inline BitString  operator + (const BitString& x, const BitString& y) 
+{
+  BitString r; cat(x, y, r); return r;
+}
+
+inline BitString  operator + (const BitString& x, unsigned int y) 
+{
+  BitString r; cat(x, y, r); return r;
+}
+
+inline BitString  operator ~ (const BitString& x) 
+{
+  BitString r; complement(x, r); return r;
+}
+
+#endif
+
+// status, matching
+
+inline int BitString::length() const
+{ 
+  return rep->len;
+}
+
+inline int BitString::empty() const
+{ 
+  return rep->len == 0;
+}
+
+inline int BitString::index(const BitString& y, int startpos) const
+{   
+  return search(startpos, rep->len, y.rep->s, 0, y.rep->len);
+}
+
+inline int BitString::index(const BitSubString& y, int startpos) const
+{   
+  return search(startpos, rep->len, y.S.rep->s, y.pos, y.pos+y.len);
+}
+
+inline int BitString::contains(const BitString& y) const
+{   
+  return search(0, rep->len, y.rep->s, 0, y.rep->len) >= 0;
+}
+
+inline int BitString::contains(const BitSubString& y) const
+{   
+  return search(0, rep->len, y.S.rep->s, y.pos, y.pos+y.len) >= 0;
+}
+
+inline int BitString::contains(const BitString& y, int p) const
+{
+  return match(p, rep->len, 0, y.rep->s, 0, y.rep->len);
+}
+
+inline int BitString::matches(const BitString& y, int p) const
+{
+  return match(p, rep->len, 1, y.rep->s, 0, y.rep->len);
+}
+
+inline int BitString::contains(const BitSubString& y, int p) const
+{
+  return match(p, rep->len, 0, y.S.rep->s, y.pos, y.pos+y.len);
+}
+
+inline int BitString::matches(const BitSubString& y, int p) const
+{
+  return match(p, rep->len, 1, y.S.rep->s, y.pos, y.pos+y.len);
+}
+
+inline int BitString::contains(const BitPattern& r) const
+{
+  return r.search(rep->s, 0, rep->len) >= 0;
+}
+
+inline int BitString::contains(const BitPattern& r, int p) const
+{
+  return r.match(rep->s, p, rep->len, 0);
+}
+
+inline int BitString::matches(const BitPattern& r, int p) const
+{
+  return r.match(rep->s, p, rep->len, 1);
+}
+
+inline int BitString::index(const BitPattern& r, int startpos) const
+{
+  return r.search(rep->s, startpos, rep->len);
+}
+
+inline  int BitSubString::length() const
+{ 
+  return len;
+}
+
+inline  int BitSubString::empty() const
+{ 
+  return len == 0;
+}
+
+inline int operator != (const BitString& x, const BitString& y)
+{
+  return !(x == y);
+}
+
+inline int operator>(const BitString& x, const BitString& y)
+{
+  return y < x;
+}
+
+inline int operator>=(const BitString& x, const BitString& y)
+{
+  return y <= x;
+}
+
+inline int BitString::first(unsigned int b) const
+{
+  return next(-1, b);
+}
+
+inline int BitString::last(unsigned int b) const
+{
+  return previous(rep->len, b);
+}
+
+inline int BitString::index(unsigned int bit, int startpos) const
+{
+  if (startpos >= 0)
+    return next(startpos - 1, bit);
+  else
+    return previous(rep->len + startpos + 1, bit);
+}
+
+inline void BitString::right_trim(unsigned int b) 
+{
+  int nb = (b == 0)? 1 : 0;
+  rep = BStr_resize(rep, previous(rep->len, nb) + 1);
+}
+
+inline void BitString::left_trim(unsigned int b)
+{
+  int nb = (b == 0)? 1 : 0;
+  int p = next(-1, nb);
+  rep = BStr_alloc(rep, rep->s, p, rep->len, rep->len - p);
+}
+
+inline int BitString::test(int i) const
+{
+  return ((unsigned)(i) >= rep->len)? 0 : 
+         ((rep->s[BitStr_index(i)] & (1 << (BitStr_pos(i)))) != 0);
+}
+
+
+// subscripting
+
+inline BitStrBit::BitStrBit(const BitStrBit& b) :src(b.src), pos(b.pos) {}
+
+inline BitStrBit::BitStrBit(BitString& v, int p) :src(v), pos(p) {}
+
+inline BitStrBit::~BitStrBit() {}
+
+inline BitStrBit::operator unsigned int() const
+{
+  return src.test(pos);
+}
+
+inline int BitStrBit::operator = (unsigned int b)
+{
+  src.assign(pos, b); return b;
+}
+
+inline int BitStrBit::operator == (unsigned int b) const
+{
+  return src.test(pos) == b;
+}
+
+inline int BitStrBit::operator != (unsigned int b) const
+{
+  return src.test(pos) != b;
+}
+
+inline BitStrBit BitString::operator [] (int i)
+{
+  if ((unsigned)(i) >= rep->len) error("illegal bit index");
+  return BitStrBit(*this, i);
+}
+
+inline BitSubString BitString::_substr(int first, int l)
+{
+  if (first < 0 || l <= 0 || (unsigned)(first + l) > rep->len)
+    return BitSubString(_nil_BitString, 0, 0) ;
+  else 
+    return BitSubString(*this, first, l);
+}
+
+#endif
+
+#endif
diff --git a/usr/include/g++/Complex.h b/usr/include/g++/Complex.h
new file mode 100644 (file)
index 0000000..a16a274
--- /dev/null
@@ -0,0 +1,293 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _Complex_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Complex_h 1
+
+
+#include <stream.h>
+#include <math.h>
+
+class Complex
+{
+#ifdef __ATT_complex__
+public:
+#else
+protected:
+#endif
+
+  double           re;
+  double           im;
+
+public:
+
+  double           real() const;
+  double           imag() const;
+
+                   Complex();
+                   Complex(const Complex& y);
+                   Complex(double r, double i=0);
+
+                  ~Complex();
+
+  Complex&         operator =  (const Complex& y);
+
+  Complex&         operator += (const Complex& y);
+  Complex&         operator += (double y);
+  Complex&         operator -= (const Complex& y);
+  Complex&         operator -= (double y);
+  Complex&         operator *= (const Complex& y);
+  Complex&         operator *= (double y);
+
+  Complex&         operator /= (const Complex& y); 
+  Complex&         operator /= (double y); 
+
+  void             error(const char* msg) const;
+};
+
+
+// error handlers
+
+extern  void default_Complex_error_handler(const char*);
+extern  one_arg_error_handler_t Complex_error_handler;
+
+extern  one_arg_error_handler_t 
+        set_Complex_error_handler(one_arg_error_handler_t f);
+
+
+// non-inline functions
+
+Complex   operator /  (const Complex& x, const Complex& y);
+Complex   operator /  (const Complex& x, double y);
+Complex   operator /  (double   x, const Complex& y);
+
+Complex   cos(const Complex& x);
+Complex   sin(const Complex& x);
+
+Complex   cosh(const Complex& x);
+Complex   sinh(const Complex& x);
+
+Complex   exp(const Complex& x);
+Complex   log(const Complex& x);
+
+Complex   pow(const Complex& x, long p);
+Complex   pow(const Complex& x, const Complex& p);
+Complex   pow(const Complex& x, double y);
+Complex   sqrt(const Complex& x);
+   
+istream&  operator >> (istream& s, Complex& x);
+ostream&  operator << (ostream& s, const Complex& x);
+
+// other functions defined as inlines
+
+int  operator == (const Complex& x, const Complex& y);
+int  operator == (const Complex& x, double y);
+int  operator != (const Complex& x, const Complex& y);
+int  operator != (const Complex& x, double y);
+
+Complex  operator - (const Complex& x);
+Complex  conj(const Complex& x);
+Complex  operator + (const Complex& x, const Complex& y);
+Complex  operator + (const Complex& x, double y);
+Complex  operator + (double x, const Complex& y);
+Complex  operator - (const Complex& x, const Complex& y);
+Complex  operator - (const Complex& x, double y);
+Complex  operator - (double x, const Complex& y);
+Complex  operator * (const Complex& x, const Complex& y);
+Complex  operator * (const Complex& x, double y);
+Complex  operator * (double x, const Complex& y);
+
+double  real(const Complex& x);
+double  imag(const Complex& x);
+double  abs(const Complex& x);
+double  norm(const Complex& x);
+double  arg(const Complex& x);
+
+Complex  polar(double r, double t = 0.0);
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+// inline members
+
+inline double  Complex::real() const { return re; }
+inline double  Complex::imag() const { return im; }
+
+inline Complex::Complex() {}
+inline Complex::Complex(const Complex& y) :re(y.real()), im(y.imag()) {}
+inline Complex::Complex(double r, double i) :re(r), im(i) {}
+
+inline Complex::~Complex() {}
+
+inline Complex&  Complex::operator =  (const Complex& y) 
+{ 
+  re = y.real(); im = y.imag(); return *this; 
+} 
+
+inline Complex&  Complex::operator += (const Complex& y)
+{ 
+  re += y.real();  im += y.imag(); return *this; 
+}
+
+inline Complex&  Complex::operator += (double y)
+{ 
+  re += y; return *this; 
+}
+
+inline Complex&  Complex::operator -= (const Complex& y)
+{ 
+  re -= y.real();  im -= y.imag(); return *this; 
+}
+
+inline Complex&  Complex::operator -= (double y)
+{ 
+  re -= y; return *this; 
+}
+
+inline Complex&  Complex::operator *= (const Complex& y)
+{  
+  double r = re * y.real() - im * y.imag();
+  im = re * y.imag() + im * y.real(); 
+  re = r; 
+  return *this; 
+}
+
+inline Complex&  Complex::operator *= (double y)
+{  
+  re *=  y; im *=  y; return *this; 
+}
+
+
+//  functions
+
+inline int  operator == (const Complex& x, const Complex& y)
+{
+  return x.real() == y.real() && x.imag() == y.imag();
+}
+
+inline int  operator == (const Complex& x, double y)
+{
+  return x.imag() == 0.0 && x.real() == y;
+}
+
+inline int  operator != (const Complex& x, const Complex& y)
+{
+  return x.real() != y.real() || x.imag() != y.imag();
+}
+
+inline int  operator != (const Complex& x, double y)
+{
+  return x.imag() != 0.0 || x.real() != y;
+}
+
+inline Complex  operator - (const Complex& x)
+{
+  return Complex(-x.real(), -x.imag());
+}
+
+inline Complex  conj(const Complex& x)
+{
+  return Complex(x.real(), -x.imag());
+}
+
+inline Complex  operator + (const Complex& x, const Complex& y)
+{
+  return Complex(x.real() + y.real(), x.imag() + y.imag());
+}
+
+inline Complex  operator + (const Complex& x, double y)
+{
+  return Complex(x.real() + y, x.imag());
+}
+
+inline Complex  operator + (double x, const Complex& y)
+{
+  return Complex(x + y.real(), y.imag());
+}
+
+inline Complex  operator - (const Complex& x, const Complex& y)
+{
+  return Complex(x.real() - y.real(), x.imag() - y.imag());
+}
+
+inline Complex  operator - (const Complex& x, double y)
+{
+  return Complex(x.real() - y, x.imag());
+}
+
+inline Complex  operator - (double x, const Complex& y)
+{
+  return Complex(x - y.real(), -y.imag());
+}
+
+inline Complex  operator * (const Complex& x, const Complex& y)
+{
+  return Complex(x.real() * y.real() - x.imag() * y.imag(), 
+                 x.real() * y.imag() + x.imag() * y.real());
+}
+
+inline Complex  operator * (const Complex& x, double y)
+{
+  return Complex(x.real() * y, x.imag() * y);
+}
+
+inline Complex  operator * (double x, const Complex& y)
+{
+  return Complex(x * y.real(), x * y.imag());
+}
+
+inline double  real(const Complex& x)
+{
+  return x.real();
+}
+
+inline double  imag(const Complex& x)
+{
+  return x.imag();
+}
+
+inline double  abs(const Complex& x)
+{
+  return hypot(x.real(), x.imag());
+}
+
+inline double  norm(const Complex& x)
+{
+  return (x.real() * x.real() + x.imag() * x.imag());
+}
+
+inline double  arg(const Complex& x)
+{
+  return atan2(x.imag(), x.real());
+}
+
+inline Complex  polar(double r, double t)
+{
+  return Complex(r * cos(t), r * sin(t));
+}
+
+#endif __OPTIMIZE__
+#endif
diff --git a/usr/include/g++/CursesW.h b/usr/include/g++/CursesW.h
new file mode 100644 (file)
index 0000000..7056db5
--- /dev/null
@@ -0,0 +1,397 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+/* 
+Copyright (C) 1989 Free Software Foundation
+    written by Eric Newton (newton@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _CursesWindow_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _CursesWindow_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+
+#include   <curses.h> 
+
+/*
+ *
+ * C++ class for windows.
+ *
+ *
+ */
+
+class CursesWindow 
+{
+protected:
+  static int     count;           // count of all active windows:
+                                  //   We rely on the c++ promise that
+                                  //   all otherwise uninitialized
+                                  //   static class vars are set to 0
+
+  WINDOW *       w;               // the curses WINDOW
+
+  int            alloced;         // true if we own the WINDOW
+
+  CursesWindow*  par;             // parent, if subwindow
+  CursesWindow*  subwins;         // head of subwindows list
+  CursesWindow*  sib;             // next subwindow of parent
+
+  void           kill_subwindows(); // disable all subwindows
+
+public:
+                 CursesWindow(WINDOW* &window);   // useful only for stdscr
+
+                 CursesWindow(int lines,          // number of lines
+                              int cols,           // number of columns
+                              int begin_y,        // line origin
+                              int begin_x);       // col origin
+
+                 CursesWindow(CursesWindow& par,  // parent window
+                              int lines,          // number of lines
+                              int cols,           // number of columns
+                              int by,             // absolute or relative
+                              int bx,             //   origins:
+                              char absrel = 'a'); // if `a', by & bx are
+                                                  // absolute screen pos,
+                                                  // else if `r', they are
+                                                  // relative to par origin
+                ~CursesWindow();
+
+// terminal status
+  int            lines(); // number of lines on terminal, *not* window
+  int            cols();  // number of cols  on terminal, *not* window
+
+// window status
+  int            height(); // number of lines in this window
+  int            width();  // number of cols in this window
+  int            begx();   // smallest x coord in window
+  int            begy();   // smallest y coord in window
+  int            maxx();   // largest  x coord in window
+  int            maxy();   // largest  x coord in window
+
+// window positioning
+  int            move(int y, int x);
+
+// coordinate positioning
+  void           getyx(int& y, int& x);
+  int            mvcur(int sy, int ey, int sx, int ex);
+
+// input
+  int            getch();
+  int            getstr(char * str);
+  int            scanw(const char *, ...);
+
+// input + positioning
+  int            mvgetch(int y, int x);
+  int            mvgetstr(int y, int x, char * str);
+  int            mvscanw(int, int, const char*, ...);
+
+// output
+  int            addch(const char ch);
+  int            addstr(const char * str);
+  int            printw(const char * fmt, ...);
+  int            inch();
+  int            insch(char c);
+  int            insertln();
+
+// output + positioning
+  int            mvaddch(int y, int x, char ch);
+  int            mvaddstr(int y, int x, char * str);
+  int            mvprintw(int y, int x, const char * fmt, ...);
+  int            mvinch(int y, int x);
+  int            mvinsch(int y, int x, char ch);
+
+// borders
+  int            box(char vert, char  hor);
+
+// erasure
+  int            erase();
+  int            clear();
+  int            clearok(cbool bf);
+  int            clrtobot();
+  int            clrtoeol();
+  int            delch();
+  int            mvdelch(int y, int x);
+  int            deleteln();
+
+// screen control
+  int            scroll();
+  int            scrollok(cbool bf);
+  int            touchwin();
+  int            refresh();
+  int            leaveok(cbool bf);
+  int            flushok(cbool bf);
+  int            standout();
+  int            standend();
+
+// multiple window control
+  int            overlay(CursesWindow &win);
+  int            overwrite(CursesWindow &win);
+
+
+// traversal support
+  CursesWindow*  child();
+  CursesWindow*  sibling();
+  CursesWindow*  parent();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+
+inline int CursesWindow::begx()
+{
+  return w->_begx;
+}
+
+inline int CursesWindow::begy()
+{
+  return w->_begy;
+}
+
+inline int CursesWindow::maxx()
+{
+  return w->_maxx;
+}
+
+inline int CursesWindow::maxy()
+{
+  return w->_maxy;
+}
+
+inline int CursesWindow::height()
+{
+  return maxy() - begy() + 1;
+}
+
+inline int CursesWindow::width()
+{
+  return maxx() - begx() + 1;
+}
+
+inline int CursesWindow::box(char vert, char  hor)    
+{
+  return ::box(w, vert, hor); 
+}
+
+inline int CursesWindow::overlay(CursesWindow &win)         
+{
+  return ::overlay(w, win.w); 
+}
+
+inline int CursesWindow::overwrite(CursesWindow &win)       
+{
+  return ::overwrite(w, win.w); 
+}
+
+inline int CursesWindow::scroll()                     
+{
+  return ::scroll(w); 
+}
+
+
+inline int CursesWindow::touchwin()                   
+{
+  return ::touchwin(w); 
+}
+
+inline int CursesWindow::addch(const char ch)         
+{
+  return ::waddch(w, ch); 
+}
+
+inline int CursesWindow::addstr(const char * str)     
+{
+  return ::waddstr(w, str); 
+}
+
+inline int CursesWindow::clear()                      
+{
+  return ::wclear(w); 
+}
+
+inline int CursesWindow::clrtobot()                   
+{
+  return ::wclrtobot(w); 
+}
+
+inline int CursesWindow::clrtoeol()                   
+{
+  return ::wclrtoeol(w); 
+}
+
+inline int CursesWindow::delch()                      
+{
+  return ::wdelch(w); 
+}
+
+inline int CursesWindow::deleteln()                   
+{
+  return ::wdeleteln(w); 
+}
+
+inline int CursesWindow::erase()                      
+{
+  return ::werase(w); 
+}
+
+inline int CursesWindow::getch()                      
+{
+  return ::wgetch(w); 
+}
+
+inline int CursesWindow::getstr(char * str)           
+{
+  return ::wgetstr(w, str); 
+}
+
+inline int CursesWindow::inch()                       
+{
+  return winch(w); 
+}
+
+inline int CursesWindow::insch(char c)               
+{
+  return ::winsch(w, c); 
+}
+
+inline int CursesWindow::insertln()                   
+{
+  return ::winsertln(w); 
+}
+
+inline int CursesWindow::move(int y, int x)           
+{
+  return ::wmove(w, y, x); 
+}
+
+
+inline int CursesWindow::mvcur(int sy, int ey, int sx, int ex)
+{
+  return ::mvcur(sy, ey, sx,ex);
+}
+
+inline int CursesWindow::mvaddch(int y, int x, char ch)
+{
+  return (::wmove(w, y, x)==0) ? 0 : ::waddch(w, ch);
+}
+
+inline int CursesWindow::mvgetch(int y, int x)
+{
+  return (::wmove(w, y, x)==0) ? 0 : ::wgetch(w);
+}
+
+inline int CursesWindow::mvaddstr(int y, int x, char * str)
+{
+  return (::wmove(w, y, x)==0) ? 0 : ::waddstr(w, str);
+}
+
+inline int CursesWindow::mvgetstr(int y, int x, char * str)
+{
+  return (::wmove(w, y, x)==0) ? 0 : ::wgetstr(w, str);
+}
+
+inline int CursesWindow::mvinch(int y, int x)
+{
+  return (::wmove(w, y, x)==0) ? 0 : ::winch(w);
+}
+
+inline int CursesWindow::mvdelch(int y, int x)
+{
+  return (::wmove(w, y, x)==0) ? 0 : ::wdelch(w);
+}
+
+inline int CursesWindow::mvinsch(int y, int x, char ch)
+{
+  return (::wmove(w, y, x)==0) ? 0 : ::winsch(w, ch);
+}
+
+inline int CursesWindow::refresh()                   
+{
+  return ::wrefresh(w); 
+}
+
+inline int CursesWindow::clearok(cbool bf)             
+{
+  return ::clearok(w,bf); 
+}
+
+inline int CursesWindow::leaveok(cbool bf)             
+{
+  return ::leaveok(w,bf); 
+}
+
+inline int CursesWindow::scrollok(cbool bf)            
+{
+  return ::scrollok(w,bf); 
+}
+
+inline int CursesWindow::flushok(cbool bf)            
+{
+  return ::flushok(w, bf); 
+}
+
+inline void CursesWindow::getyx(int& y, int& x)       
+{
+  ::getyx(w, y, x); 
+}
+
+inline int CursesWindow::standout()                   
+{
+  return ::wstandout(w); 
+}
+
+inline int CursesWindow::standend()                   
+{
+  return ::wstandend(w); 
+}
+
+inline int CursesWindow::lines()                      
+{
+  return LINES; 
+}
+
+inline int CursesWindow::cols()                       
+{
+  return COLS; 
+}
+
+inline CursesWindow* CursesWindow::child()
+{
+  return subwins;
+}
+
+inline CursesWindow* CursesWindow::parent()
+{
+  return par;
+}
+
+inline CursesWindow* CursesWindow::sibling()
+{
+  return sib;
+}
+
+
+# endif
+#endif
diff --git a/usr/include/g++/DiscUnif.h b/usr/include/g++/DiscUnif.h
new file mode 100644 (file)
index 0000000..d99a7d4
--- /dev/null
@@ -0,0 +1,79 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _DiscreteUniform_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _DiscreteUniform_h 1
+
+#include <Random.h>
+
+//
+//     The interval [lo..hi)
+// 
+
+class DiscreteUniform: public Random {
+    long pLow;
+    long pHigh;
+    double delta;
+public:
+    DiscreteUniform(long low, long high, RNG *gen);
+
+    long low();
+    long low(long x);
+    long high();
+    long high(long x);
+
+    virtual double operator()();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline DiscreteUniform::DiscreteUniform(long low, long high, RNG *gen) : (gen)
+{
+    pLow = (low < high) ? low : high;
+    pHigh = (low < high) ? high : low;
+    delta = (pHigh - pLow) + 1;
+}
+
+inline long DiscreteUniform::low() { return pLow; }
+
+inline long DiscreteUniform::low(long x) {
+  long tmp = pLow;
+  pLow = x;
+  delta = (pHigh - pLow) + 1;
+  return tmp;
+}
+
+inline long DiscreteUniform::high() { return pHigh; }
+
+inline long DiscreteUniform::high(long x) {
+  long tmp = pHigh;
+  pHigh = x;
+  delta = (pHigh - pLow) + 1;
+  return tmp;
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/Erlang.h b/usr/include/g++/Erlang.h
new file mode 100644 (file)
index 0000000..e770e5a
--- /dev/null
@@ -0,0 +1,77 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _Erlang_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Erlang_h 1 
+
+#include <Random.h>
+
+class Erlang: public Random {
+protected:
+    double pMean;
+    double pVariance;
+    int k;
+    double a;
+    void setState();
+public:
+    Erlang(double mean, double variance, RNG *gen);
+
+    double mean();
+    double mean(double x);
+    double variance();
+    double variance(double x);
+
+    virtual double operator()();
+
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline void Erlang::setState() {
+  k = int( (pMean * pMean ) / pVariance + 0.5 );
+  k = (k > 0) ? k : 1;
+  a = k / pMean;
+}
+
+inline Erlang::Erlang(double mean, double variance, RNG *gen) : (gen)
+{
+  pMean = mean; pVariance = variance;
+  setState();
+}
+
+inline double Erlang::mean() { return pMean; }
+inline double Erlang::mean(double x) {
+  double tmp = pMean; pMean = x; setState(); return tmp;
+};
+
+inline double Erlang::variance() { return pVariance; }
+inline double Erlang::variance(double x) {
+  double tmp = pVariance; pVariance = x; setState(); return tmp;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/File.h b/usr/include/g++/File.h
new file mode 100644 (file)
index 0000000..ce9dbef
--- /dev/null
@@ -0,0 +1,302 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _File_h 
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _File_h 1
+
+#include <builtin.h>
+#include <stdio.h>
+#include <stddef.h>
+
+#include <Fmodes.h>
+
+class Filebuf;
+
+class File
+{
+  friend class  Filebuf;
+protected:
+  FILE*         fp;              // _iobuf file pointer
+  char*         nm;              // file name (dynamically allocated)
+  char          rw;              //  1 = read; 2 = write; 3 = readwrite
+                                 //  bit 2 (4) means read/write into string
+  state_value   state;           // _good/_eof/_fail/_bad
+  long          stat;            // last read/write/... return value
+
+  void          initialize();
+  void          reinitialize(const char*);
+  char         *readline (int chunk_number, char terminator);
+
+public:
+                File();
+                File(const char* filename, io_mode m, access_mode a);
+                File(const char* filename, const char* m);   
+                File(int filedesc, io_mode m);
+                File(FILE* fileptr);
+                File(int sz, char* buf, io_mode m);
+
+                ~File();
+
+// binding, rebinding, unbinding to physical files
+
+  File&         open(const char* filename, io_mode m, access_mode a);
+  File&         open(const char* filename, const char* m);
+  File&         open(int  filedesc, io_mode m);
+  File&         open(FILE* fileptr);
+
+  File&         close();
+  File&         remove();
+
+// class variable access
+
+  int           filedesc();
+  const char*   name();
+  void          setname(const char* newname);
+  int           iocount();
+
+  int           rdstate();
+  int           eof();
+  int           fail();
+  int           bad();
+  int           good();
+
+// other status queries
+
+  int           readable();
+  int           writable();
+  int           is_open();
+
+                operator void*();
+
+// error handling
+
+  void          error();
+  void          clear(state_value f = _good); // poorly named
+  void          set(state_value f); // set corresponding but
+  void          unset(state_value f); // clear corresponding bit
+  File&         failif(int cond);
+  void          check_state();
+
+// character IO
+
+  File&         get(char& c);
+  File&         put(char  c);
+  File&         unget(char c);
+  File&         putback(char c); // a synonym for unget
+
+// char* IO
+
+  File&         put(const char* s);
+  File&         get    (char* s, int n, char terminator = '\n');
+  File&         getline(char* s, int n, char terminator = '\n');
+  File&         gets   (char **s, char terminator = '\n');
+
+// binary IO
+
+  File&         read(void* x, int sz, int n);
+  File&         write(void* x, int sz, int n);
+
+// formatted IO
+
+  File&         form(const char* ...);
+  File&         scan(const char* ...);
+
+// buffer IO
+
+  File&         flush();
+
+// position control
+
+  File&         seek(long pos, int seek_mode=0); // default seek mode=absolute
+  long          tell();
+
+// buffer control
+
+  File&         setbuf(int buffer_kind); // legal vals: _IONBF, _IOFBF, _IOLBF
+  File&         setbuf(int size, char* buf);
+  File&         raw();
+};
+
+
+// error handlers
+
+extern void  verbose_File_error_handler(const char*);
+extern void  quiet_File_error_handler(const char*);
+extern void  fatal_File_error_handler(const char*);
+extern one_arg_error_handler_t File_error_handler;
+extern one_arg_error_handler_t set_File_error_handler(one_arg_error_handler_t);
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+
+
+inline int File::filedesc()
+{ 
+  return fileno(fp);
+}
+
+inline const char* File::name()
+{ 
+  return nm; 
+}
+
+inline int File::iocount()
+{ 
+  return stat; 
+}
+
+inline void File::clear(state_value flag)
+{ 
+  state = flag;
+}
+
+inline void File::set(state_value flag)
+{ 
+  state = state_value(int(state) | int(flag));
+}
+
+inline void File::unset(state_value flag)
+{ 
+  state = state_value(int(state) & ~int(flag));
+}
+
+inline int File::readable()
+{ 
+  if (fp != 0) { if (feof(fp)) set(_eof); if (ferror(fp)) set(_bad);}
+  return (state == _good && (rw & 01));
+}
+
+inline int File::writable()
+{ 
+  if (fp != 0 && ferror(fp)) set(_bad);
+  return ((int(state) & (int(_fail)|int(_bad))) == 0 && (rw & 02));
+}
+
+inline int File::is_open()
+{ 
+  return (fp != 0);
+}
+
+
+inline File& File::raw()
+{ 
+  return this->File::setbuf(_IONBF); 
+}
+
+
+inline File& File::failif(int cond)
+{ 
+  if (cond) set(_fail);  return *this; 
+}
+
+inline File& File::get(char& c)
+{ 
+  if (readable())
+  {
+    int ch = getc(fp);
+    c = ch;
+    failif (ch == EOF);
+  }
+  return *this;
+}
+
+inline File& File::put(char  c) 
+{ 
+  return failif (!writable() ||  putc(c, fp) == EOF);
+}
+
+inline File& File::unget(char c)
+{ 
+  return failif(!is_open() || !(rw & 01) || ungetc(c, fp) == EOF);
+} 
+
+inline File& File::putback(char c)
+{ 
+  return failif (!is_open() || !(rw & 01) || ungetc(c, fp) == EOF);
+}
+
+inline File& File::read(void* x, int sz, int n)
+{ 
+  return failif (!readable() || (stat = fread(x, sz, n, fp)) != n);
+} 
+
+inline File& File::write(void* x, int sz, int n) 
+{ 
+  return failif (!writable() || (stat = fwrite(x, sz, n, fp)) != n);
+}
+
+inline File& File::flush()
+{ 
+  return failif(!is_open() || fflush(fp) == EOF);
+}
+
+
+inline File& File::seek(long pos, int seek_mode)
+{ 
+  return failif (!is_open() || fseek(fp, pos, seek_mode) < 0); 
+}
+
+inline long File::tell()
+{ 
+  failif (!is_open() || ((stat = ftell(fp)) < 0));
+  return stat;
+}
+
+inline int File::rdstate()
+{ 
+  check_state();  return state; // check_state is necessary in rare but
+}                               // possible circumstances
+
+inline File::operator void*()
+{ 
+  check_state();  return (int(state) & (int(_bad)|int(_fail)))? 0 : this ; 
+}
+
+inline int File::eof()
+{ 
+  check_state(); return state & _eof; 
+}
+
+inline int File::fail()
+{ 
+  check_state(); return state & _fail; 
+}
+
+inline int File::bad()
+{ 
+  check_state(); return state & _bad; 
+}
+
+inline int File::good()
+{ 
+  check_state(); return rdstate() == _good; 
+}
+
+
+#endif
+
+#endif
diff --git a/usr/include/g++/Filebuf.h b/usr/include/g++/Filebuf.h
new file mode 100644 (file)
index 0000000..2124e21
--- /dev/null
@@ -0,0 +1,32 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _Filebuf_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Filebuf_h 1
+
+
+#endif
diff --git a/usr/include/g++/Fix.h b/usr/include/g++/Fix.h
new file mode 100644 (file)
index 0000000..d325228
--- /dev/null
@@ -0,0 +1,468 @@
+//
+// Fix.h : variable length fixed point data type 
+//
+
+#ifndef _Fix_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Fix_h 1
+
+#include <stream.h>
+#include <std.h>
+#include <stddef.h>
+#include <Integer.h>
+
+typedef unsigned short uint16;
+typedef short int16;
+typedef unsigned long  uint32;
+typedef long int32;
+
+#define _Fix_min_length        1
+#define _Fix_max_length                65535
+
+#define _Fix_min_value         -1.0
+#define _Fix_max_value         1.0
+
+extern uint16 Fix_default_length;
+extern int    Fix_default_print_width;
+
+struct _Frep                    // internal Fix representation
+{
+  uint16 len;                          // length in bits
+  uint16 siz;                  // allocated storage
+  int16 ref;                   // reference count
+  uint16 s[1];                 // start of ushort array represention
+};
+
+typedef struct _Frep* _Fix;
+
+extern _Frep _Frep_0;
+extern _Frep _Frep_m1;
+extern _Frep _Frep_quotient_bump;
+
+class Fix
+{
+  _Fix            rep;
+
+                 Fix(_Fix);
+
+  void           unique();
+
+public:
+                 Fix();
+                  Fix(Fix&);
+                 Fix(double&);
+                  Fix(int);
+                  Fix(int, Fix&);
+                  Fix(int, double&);
+                  Fix(int, _Frep*);
+
+                  ~Fix();
+
+  Fix             operator =  (Fix&);
+  Fix             operator =  (double&);
+
+  friend int      operator == (Fix&, Fix& );
+  friend int      operator != (Fix&, Fix&);
+
+  friend int      operator <  (Fix&, Fix&);
+  friend int      operator <= (Fix&, Fix&);
+  friend int      operator >  (Fix&, Fix&);
+  friend int      operator >= (Fix&, Fix&);
+
+  Fix&            operator +  ();
+  Fix             operator -  ();
+
+  friend Fix      operator +  (Fix&, Fix&);
+  friend Fix      operator -  (Fix&, Fix&);
+  friend Fix      operator *  (Fix&, Fix&);
+  friend Fix      operator /  (Fix&, Fix&);
+
+  friend Fix      operator *  (Fix&, int);
+  friend Fix      operator *  (int, Fix&);
+  friend Fix      operator %  (Fix&, int);
+  friend Fix      operator << (Fix&, int);
+  friend Fix      operator >> (Fix&, int);
+
+#ifdef __GNUG__
+  friend Fix     operator <? (Fix&, Fix&); // min
+  friend Fix     operator >? (Fix&, Fix&); // max
+#endif
+
+  Fix            operator += (Fix&);
+  Fix            operator -= (Fix&);
+  Fix            operator *= (Fix&);
+  Fix            operator /= (Fix&);
+
+  Fix            operator *= (int);
+  Fix            operator %= (int);
+  Fix            operator <<=(int);
+  Fix            operator >>=(int);
+
+  friend char*    Ftoa(Fix&, int width = Fix_default_print_width);
+  friend Fix      atoF(const char*, int len = Fix_default_length);
+  
+  friend istream& operator >> (istream&, Fix&);
+  friend ostream& operator << (ostream&, Fix&);
+
+  // built-in functions
+  friend Fix      abs(Fix);            // absolute value
+  friend int      sgn(Fix&);           // -1, 0, +1
+  friend Integer  mantissa(Fix&);      // integer representation
+  friend double   value(Fix&);         // double value
+  friend int      length(Fix&);                // field length
+  friend void    show(Fix&);           // show contents
+
+  // error handlers
+  void            error(const char* msg);              // error handler
+  void            range_error(const char* msg);        // range error handler
+
+  // internal class functions
+  friend void    mask(_Fix);
+  friend int      compare(_Fix, _Fix = &_Frep_0);
+
+  friend _Fix    new_Fix(uint16);
+  friend _Fix    new_Fix(uint16, _Fix);
+  friend _Fix    new_Fix(uint16, double);
+
+  friend _Fix    copy(_Fix, _Fix);
+  friend _Fix    negate(_Fix, _Fix = NULL);
+  friend _Fix    add(_Fix, _Fix, _Fix = NULL);
+  friend _Fix    subtract(_Fix, _Fix, _Fix = NULL);
+  friend _Fix    multiply(_Fix, _Fix, _Fix = NULL);
+  friend _Fix    multiply(_Fix, int, _Fix = NULL);
+  friend _Fix    divide(_Fix, _Fix, _Fix = NULL, _Fix = NULL);
+  friend _Fix    shift(_Fix, int, _Fix = NULL);
+
+  // non-operator versions for user
+  friend void    negate(Fix& x, Fix& r);
+  friend void    add(Fix& x, Fix& y, Fix& r);
+  friend void    subtract(Fix& x, Fix& y, Fix& r);
+  friend void    multiply(Fix& x, Fix& y, Fix& r);
+  friend void    divide(Fix& x, Fix& y, Fix& q, Fix& r);
+  friend void    shift(Fix& x, int y, Fix& r);
+};
+
+// error handlers
+
+extern void    
+  default_Fix_error_handler(const char*),
+  default_Fix_range_error_handler(const char*);
+
+extern one_arg_error_handler_t 
+  Fix_error_handler,
+  Fix_range_error_handler;
+
+extern one_arg_error_handler_t 
+  set_Fix_error_handler(one_arg_error_handler_t f),
+  set_Fix_range_error_handler(one_arg_error_handler_t f);
+
+typedef void (*Fix_peh)(_Fix&);
+extern Fix_peh Fix_overflow_handler;
+
+extern void 
+  Fix_overflow_saturate(_Fix&),
+  Fix_overflow_wrap(_Fix&),
+  Fix_overflow_warning_saturate(_Fix&),
+  Fix_overflow_warning(_Fix&),
+  Fix_overflow_error(_Fix&);
+
+extern Fix_peh set_overflow_handler(Fix_peh);
+
+extern int Fix_set_default_length(int);
+
+// function definitions
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline void Fix::unique()
+{
+  if ( rep->ref > 1 )
+  {
+    rep->ref--;
+    rep = new_Fix(rep->len,rep);
+  }
+}
+
+inline void mask (_Fix x)
+{
+  int n = x->len & 0x0f;
+  if ( n )
+    x->s[x->siz - 1] &= 0xffff0000 >> n; 
+}
+
+inline _Fix copy(_Fix from, _Fix to)
+{
+  uint16 *ts = to->s, *fs = from->s;
+  int ilim = to->siz < from->siz ? to->siz : from->siz;
+  for ( int i=0; i < ilim; i++ )
+    *ts++ = *fs++;
+  for ( ; i < to->siz; i++ )
+    *ts++ = 0;
+  mask(to);
+  return to;
+}
+
+inline Fix::Fix(_Fix f)
+{
+  rep = f;
+}
+
+inline Fix::Fix()
+{
+  rep = new_Fix(Fix_default_length);
+}
+
+inline Fix::Fix(int len)
+{
+  if ( len < _Fix_min_length || len > _Fix_max_length )
+    error("illegal length in declaration");
+  rep = new_Fix((uint16 )len);
+}
+
+inline Fix::Fix(double& d)
+{
+  rep = new_Fix(Fix_default_length,d);
+}
+
+inline Fix::Fix(Fix&  y)
+{
+  rep = y.rep; rep->ref++;
+}
+
+inline Fix::Fix(int len, Fix&  y)
+{
+  if ( len < _Fix_min_length || len > _Fix_max_length )
+    error("illegal length in declaration");
+  rep = new_Fix((uint16 )len,y.rep);
+}
+
+inline Fix::Fix(int len, _Frep* fr)
+{
+  if ( len <   1  || len >     65535  )
+    error("illegal length in declaration");
+  rep = new_Fix((uint16 )len,fr);
+}
+
+inline Fix::Fix(int len, double& d)
+{
+  if ( len < _Fix_min_length || len > _Fix_max_length )
+    error("illegal length in declaration");
+  rep = new_Fix((uint16 )len,d);
+}
+
+inline Fix::~Fix()
+{
+  if ( --rep->ref <= 0 ) delete rep;
+}
+
+inline Fix  Fix::operator = (Fix&  y)
+{
+  if ( rep->len == y.rep->len ) {
+    ++y.rep->ref;
+    if ( --rep->ref <= 0 ) delete rep;
+    rep = y.rep; 
+  }
+  else {
+    unique();
+    copy(y.rep,rep);
+  }
+  return *this;
+}
+
+inline Fix  Fix::operator = (double& d)
+{
+  int oldlen = rep->len;
+  if ( --rep->ref <= 0 ) delete rep;
+  rep = new_Fix(oldlen,d);
+  return *this;
+}
+
+inline int operator == (Fix&  x, Fix&  y)
+{
+  return compare(x.rep, y.rep) == 0; 
+}
+
+inline int operator != (Fix&  x, Fix&  y)
+{
+  return compare(x.rep, y.rep) != 0; 
+}
+
+inline int operator <  (Fix&  x, Fix&  y)
+{
+  return compare(x.rep, y.rep) <  0; 
+}
+
+inline int operator <= (Fix&  x, Fix&  y)
+{
+  return compare(x.rep, y.rep) <= 0; 
+}
+
+inline int operator >  (Fix&  x, Fix&  y)
+{
+  return compare(x.rep, y.rep) >  0; 
+}
+
+inline int operator >= (Fix&  x, Fix&  y)
+{
+  return compare(x.rep, y.rep) >= 0; 
+}
+
+inline Fix& Fix::operator +  ()
+{
+  return *this;
+}
+
+inline Fix Fix::operator -  ()
+{
+  _Fix r = negate(rep); return r;
+}
+
+inline Fix      operator +  (Fix&  x, Fix& y)
+{
+  _Fix r = add(x.rep, y.rep); return r;
+}
+
+inline Fix      operator -  (Fix&  x, Fix& y)
+{
+  _Fix r = subtract(x.rep, y.rep); return r;
+}
+
+inline Fix      operator *  (Fix&  x, Fix& y)
+{
+  _Fix r = multiply(x.rep, y.rep); return r;
+}
+
+inline Fix      operator *  (Fix&  x, int y)
+{
+  _Fix r = multiply(x.rep, y); return r;
+}
+
+inline Fix      operator *  (int  y, Fix& x)
+{
+  _Fix r = multiply(x.rep, y); return r;
+}
+
+inline Fix operator / (Fix& x, Fix& y)
+{
+  _Fix r = divide(x.rep, y.rep); return r;
+}
+
+inline Fix  Fix::operator += (Fix& y)
+{
+  unique(); add(rep, y.rep, rep); return *this;
+}
+
+inline Fix  Fix::operator -= (Fix& y)
+{
+  unique(); subtract(rep, y.rep, rep); return *this;
+}
+
+inline Fix  Fix::operator *= (Fix& y)
+{
+  unique(); multiply(rep, y.rep, rep); return *this;
+}
+
+inline Fix  Fix::operator *= (int y)
+{
+  unique(); multiply(rep, y, rep); return *this;
+}
+
+inline Fix Fix::operator /= (Fix& y)
+{
+  unique(); divide(rep, y.rep, rep); return *this;
+}
+
+inline Fix operator % (Fix& x, int y)
+{
+  Fix r((int )x.rep->len + y, x); return r;
+}
+
+inline Fix      operator << (Fix&  x, int y)
+{
+  _Fix rep = shift(x.rep, y); return rep;
+}
+
+inline Fix      operator >> (Fix&  x, int y)
+{  
+  _Fix rep = shift(x.rep, -y); return rep;
+}
+
+inline Fix Fix::operator <<= (int y)
+{
+  unique(); shift(rep, y, rep); return *this;
+}
+
+inline Fix  Fix::operator >>= (int y)
+{
+  unique(); shift(rep, -y, rep); return *this;
+}
+
+#ifdef __GNUG__
+inline Fix operator <? (Fix& x, Fix& y)
+{
+  if ( compare(x.rep, y.rep) <= 0 ) return x; else return y;
+}
+
+inline Fix operator >? (Fix& x, Fix& y)
+{
+  if ( compare(x.rep, y.rep) >= 0 ) return x; else return y;
+}
+#endif
+
+inline Fix abs(Fix  x)
+{
+  _Fix r = (compare(x.rep) >= 0 ? new_Fix(x.rep->len,x.rep) : negate(x.rep));
+  return r;
+}
+
+inline int sgn(Fix& x)
+{
+  int a = compare(x.rep);
+  return a == 0 ? 0 : (a > 0 ? 1 : -1);
+}
+
+inline int length(Fix& x)
+{
+  return x.rep->len;
+}
+
+inline ostream& operator << (ostream& s, Fix& y)
+{
+  return s << Ftoa(y);
+}
+
+inline void    negate (Fix& x, Fix& r)
+{
+  negate(x.rep, r.rep);
+}
+
+inline void    add (Fix& x, Fix& y, Fix& r)
+{
+  add(x.rep, y.rep, r.rep);
+}
+
+inline void    subtract (Fix& x, Fix& y, Fix& r)
+{
+  subtract(x.rep, y.rep, r.rep);
+}
+
+inline void    multiply (Fix& x, Fix& y, Fix& r)
+{
+  multiply(x.rep, y.rep, r.rep);
+}
+
+inline void    divide (Fix& x, Fix& y, Fix& q, Fix& r)
+{
+  divide(x.rep, y.rep, q.rep, r.rep);
+}
+
+inline void    shift (Fix& x, int y, Fix& r)
+{
+  shift(x.rep, y, r.rep);
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/Fix16.h b/usr/include/g++/Fix16.h
new file mode 100644 (file)
index 0000000..0024c9d
--- /dev/null
@@ -0,0 +1,647 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu)
+    adapted for libg++ by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _Fix16_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Fix16_h 1
+
+#include <stream.h>
+#include <std.h>
+
+// constant definitions
+
+#define Fix16_fs       ((double)((unsigned)(1 << 15)))
+
+#define Fix16_msb      (1 << 15)
+#define Fix16_m_max    ((1 << 15) - 1)
+#define Fix16_m_min    ((short)(1 << 15))
+
+#define Fix16_mult     Fix16_fs
+#define Fix16_div      (1./Fix16_fs)
+#define Fix16_max      (1. - .5/Fix16_fs)
+#define Fix16_min      (-1.)
+
+
+#define Fix32_fs       ((double)((unsigned long)(1 << 31)))
+
+#define Fix32_msb      ((unsigned long)(1 << 31))
+#define Fix32_m_max    ((1 << 31) - 1)
+#define Fix32_m_min    ((long)(1 << 31))
+
+#define Fix32_mult     Fix32_fs
+#define Fix32_div      (1./Fix32_fs)
+#define Fix32_max      (1. - .5/Fix32_fs)
+#define Fix32_min      (-1.)
+
+
+//
+// Fix16    class: 16-bit Fixed point data type
+//
+//     consists of a 16-bit mantissa (sign bit & 15 data bits).
+//
+
+class Fix16 
+{ 
+  friend class          Fix32;
+
+  short                 m;
+
+  short                 round(double d);
+  short                 assign(double d);
+                        Fix16(short i);
+                        Fix16(int i);
+
+         operator       double();
+
+
+public:
+                        Fix16();
+                        Fix16(Fix16&  f);
+                        Fix16(double d);
+                        Fix16(Fix32& f);
+
+                        ~Fix16();
+
+  Fix16&                operator=(Fix16&  f);
+  Fix16&                operator=(double d);
+  Fix16&                operator=(Fix32& f);
+
+  friend short&         mantissa(Fix16&  f);
+  friend double         value(Fix16&  f);
+
+  Fix16                 operator +  ();
+  Fix16                 operator -  ();
+
+  friend Fix16          operator +  (Fix16&  f, Fix16&  g);
+  friend Fix16          operator -  (Fix16&  f, Fix16&  g);
+  friend Fix32          operator *  (Fix16&  f, Fix16&  g);
+  friend Fix16          operator /  (Fix16&  f, Fix16&  g);
+  friend Fix16          operator << (Fix16&  f, int b);
+  friend Fix16          operator >> (Fix16&  f, int b);
+
+  Fix16&                operator += (Fix16&  f);
+  Fix16&                operator -= (Fix16&  f);
+  Fix16&                operator *= (Fix16& );
+  Fix16&                operator /= (Fix16&  f);
+  
+  Fix16&                operator <<=(int b);
+  Fix16&                operator >>=(int b);
+
+  friend int            operator == (Fix16&  f, Fix16&  g);
+  friend int            operator != (Fix16&  f, Fix16&  g);
+  friend int            operator >= (Fix16&  f, Fix16&  g);
+  friend int            operator <= (Fix16&  f, Fix16&  g);
+  friend int            operator >  (Fix16&  f, Fix16&  g);
+  friend int            operator <  (Fix16&  f, Fix16&  g);
+
+  friend istream&       operator >> (istream& s, Fix16&  f);
+  friend ostream&       operator << (ostream& s, Fix16&  f);
+
+  void                  overflow(short&);
+  void                  range_error(short&);
+
+  friend Fix16          operator *  (Fix16&  f, int g);
+  friend Fix16          operator *  (int g, Fix16&  f);
+  Fix16&                operator *= (int g);
+};
+
+//
+// Fix32 class: 32-bit Fixed point data type
+//
+//     consists of a 32-bit mantissa (sign bit & 31 data bits).
+//
+
+class Fix32 
+{ 
+  friend class         Fix16;
+
+  long                 m;
+
+  long                 round(double d);
+  long                 assign(double d);
+
+                       Fix32(long i);
+                       operator double();
+
+
+public:
+                       Fix32();
+                       Fix32(Fix32& f);
+                       Fix32(Fix16&  f);
+                       Fix32(double d);
+                       ~Fix32();
+
+  Fix32&               operator =  (Fix32& f);
+  Fix32&               operator =  (Fix16&  f);
+  Fix32&               operator =  (double d);
+
+  friend long&         mantissa(Fix32& f);
+  friend double        value(Fix32& f);
+
+  Fix32                operator +  ();
+  Fix32                operator -  ();
+
+  friend Fix32         operator +  (Fix32& f, Fix32& g);
+  friend Fix32         operator -  (Fix32& f, Fix32& g);
+  friend Fix32         operator *  (Fix32& f, Fix32& g);
+  friend Fix32         operator /  (Fix32& f, Fix32& g);
+  friend Fix32         operator << (Fix32& f, int b);
+  friend Fix32         operator >> (Fix32& f, int b);
+
+  friend Fix32         operator *  (Fix16&  f, Fix16&  g);
+
+  Fix32&               operator += (Fix32& f);
+  Fix32&               operator -= (Fix32& f);
+  Fix32&               operator *= (Fix32& f);
+  Fix32&               operator /= (Fix32& f);
+  Fix32&               operator <<=(int b);
+  Fix32&               operator >>=(int b);
+
+  friend int           operator == (Fix32& f, Fix32& g);
+  friend int           operator != (Fix32& f, Fix32& g);
+  friend int           operator >= (Fix32& f, Fix32& g);
+  friend int           operator <= (Fix32& f, Fix32& g);
+  friend int           operator >  (Fix32& f, Fix32& g);
+  friend int           operator <  (Fix32& f, Fix32& g);
+
+  friend istream&      operator >> (istream& s, Fix32& f);
+  friend ostream&      operator << (ostream& s, Fix32& f);
+
+  void                 overflow(long& i);
+  void                 range_error(long& i);
+
+  friend Fix32          operator *  (Fix32&  f, int g);
+  friend Fix32          operator *  (int g, Fix32&  f);
+  Fix32&                operator *= (int g);
+};
+
+// active error handler declarations
+
+typedef void (*Fix16_peh)(short&);
+typedef void (*Fix32_peh)(long&);
+
+extern Fix16_peh Fix16_overflow_handler;
+extern Fix32_peh Fix32_overflow_handler;
+
+extern Fix16_peh Fix16_range_error_handler;
+extern Fix32_peh Fix32_range_error_handler;
+
+#if defined(SHORT_NAMES) || defined(VMS)
+#define        set_overflow_handler    sohndl
+#define set_range_error_handler        srnghdl
+#endif
+
+
+// error handler declarations
+
+extern Fix16_peh set_Fix16_overflow_handler(Fix16_peh);
+extern Fix32_peh set_Fix32_overflow_handler(Fix32_peh);
+extern void set_overflow_handler(Fix16_peh, Fix32_peh);
+
+extern Fix16_peh set_Fix16_range_error_handler(Fix16_peh);
+extern Fix32_peh set_Fix32_range_error_handler(Fix32_peh);
+extern void set_range_error_handler(Fix16_peh, Fix32_peh);
+
+extern void
+  Fix16_ignore(short&),
+  Fix16_overflow_saturate(short&),
+  Fix16_overflow_warning_saturate(short&),
+  Fix16_warning(short&),
+  Fix16_abort(short&);
+
+extern void
+  Fix32_ignore(long&),
+  Fix32_overflow_saturate(long&),
+  Fix32_overflow_warning_saturate(long&),
+  Fix32_warning(long&),
+  Fix32_abort(long&);
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline Fix16::~Fix16() {}
+
+inline short Fix16::round(double d)
+{ 
+  return short( (d >= 0)? d + 0.5 : d - 0.5); 
+}
+
+inline Fix16::Fix16(short i)           
+{ 
+  m = i; 
+}
+
+inline Fix16::Fix16(int i)         
+{ 
+  m = i; 
+}
+
+inline Fix16::operator double() 
+{ 
+  return  Fix16_div * m; 
+}
+
+inline Fix16::Fix16()                          
+{ 
+  m = 0; 
+}
+
+inline Fix16::Fix16(Fix16&  f)         
+{ 
+  m = f.m; 
+}
+
+inline Fix16::Fix16(double d)          
+{
+  m = assign(d);
+}
+
+
+inline Fix16&  Fix16::operator=(Fix16&  f)     
+{ 
+  m = f.m; 
+  return *this; 
+}
+
+inline Fix16&  Fix16::operator=(double d) 
+{ 
+  m = assign(d); 
+  return *this; 
+}
+
+
+inline Fix32::Fix32()                      
+{ 
+  m = 0;
+}
+
+inline Fix32::Fix32(long i)            
+{ 
+  m = i;
+}
+
+inline Fix32:: operator double()               
+{ 
+  return Fix32_div * m;
+}
+
+
+inline Fix32::Fix32(Fix32& f)          
+{ 
+  m = f.m;
+}
+
+inline Fix32::Fix32(Fix16&  f)    
+{ 
+  m = long(f.m) << 16;
+}
+
+inline Fix32::Fix32(double d)          
+{ 
+  m = assign(d);
+}
+
+inline Fix16::Fix16(Fix32& f)          
+{ 
+  m = f.m >> 16; 
+}
+
+
+inline Fix16&  Fix16::operator=(Fix32& f)
+{ 
+  m = f.m >> 16; 
+  return *this; 
+}
+
+inline Fix32& Fix32::operator=(Fix32& f)       
+{ 
+  m = f.m;
+  return *this; 
+}
+
+inline Fix32& Fix32::operator=(Fix16&  f)      
+{ 
+  m = long(f.m) << 16;
+  return *this;
+}
+
+inline Fix32& Fix32::operator=(double d)       
+{ 
+  m = assign(d);
+  return *this; 
+}
+
+inline short& mantissa(Fix16&  f)      
+{ 
+  return f.m; 
+}
+
+inline double value(Fix16&  f)         
+{ 
+  return double(f); 
+}
+
+inline Fix16 Fix16::operator+()                
+{ 
+  return m; 
+}
+
+inline Fix16 Fix16::operator-()                
+{ 
+  return -m; 
+}
+
+inline Fix16 operator+(Fix16&  f, Fix16&  g) 
+{
+  short sum = f.m + g.m;
+  if ( (f.m ^ sum) & (g.m ^ sum) & Fix16_msb )
+    f.overflow(sum);
+  return sum;
+}
+
+inline Fix16 operator-(Fix16&  f, Fix16&  g) 
+{
+  short sum = f.m - g.m;
+  if ( (f.m ^ sum) & (-g.m ^ sum) & Fix16_msb )
+    f.overflow(sum);
+  return sum;
+}
+
+inline Fix32 operator*(Fix16&  f, Fix16&  g)
+{ 
+  return Fix32( long( long(f.m) * long(g.m) << 1)); 
+}
+
+inline Fix16 operator<<(Fix16& a, int b)       
+{ 
+  return a.m << b; 
+}
+
+inline Fix16 operator>>(Fix16& a, int b)       
+{ 
+  return a.m >> b; 
+}
+
+inline  Fix16&  Fix16:: operator+=(Fix16&  f)
+{ 
+  return *this = *this + f; 
+}
+
+inline Fix16&  Fix16:: operator-=(Fix16&  f)   
+{ 
+  return *this = *this - f; 
+}
+
+inline Fix16& Fix16::operator*=(Fix16& f)      
+{ 
+  return *this = *this * f; 
+}
+
+inline Fix16&  Fix16:: operator/=(Fix16&  f)   
+{ 
+  return *this = *this / f; 
+}
+
+inline Fix16&  Fix16:: operator<<=(int b)      
+{ 
+  return *this = *this << b;
+}
+
+inline Fix16&  Fix16:: operator>>=(int b)      
+{ 
+  return *this = *this >> b;
+}
+
+inline int operator==(Fix16&  f, Fix16&  g)    
+{ 
+  return f.m == g.m;
+}
+
+inline int operator!=(Fix16&  f, Fix16&  g)    
+{ 
+  return f.m != g.m;
+}
+
+inline int operator>=(Fix16&  f, Fix16&  g)    
+{ 
+  return f.m >= g.m;
+}
+
+inline int operator<=(Fix16&  f, Fix16&  g)    
+{ 
+  return f.m <= g.m;
+}
+
+inline int operator>(Fix16&  f, Fix16&  g)     
+{ 
+  return f.m > g.m;
+}
+
+inline int operator<(Fix16&  f, Fix16&  g)     
+{ 
+  return f.m < g.m;
+}
+
+inline istream&  operator>>(istream& s, Fix16&  f)
+{ 
+  double d;
+  s >> d; 
+  f = d; 
+  return s; 
+}
+
+inline ostream&  operator<<(ostream& s, Fix16&  f)
+{ 
+  return s << double(f);
+}
+
+
+inline Fix16 operator*(Fix16&  f, int g)
+{
+  return Fix16(short(f.m * g));
+}
+
+inline Fix16 operator*(int g, Fix16&  f)
+{
+  return f * g;
+}
+
+
+inline Fix16& Fix16::operator*=(int g)
+{
+  return *this = *this * g;
+}
+
+inline Fix32::~Fix32() {}
+
+inline long Fix32::round(double d)
+{ 
+  return long( (d >= 0)? d + 0.5 : d - 0.5);
+}
+
+
+inline long& mantissa(Fix32& f)        
+{ 
+  return f.m;
+}
+
+inline double value(Fix32& f)          
+{ 
+  return double(f);
+}
+
+inline Fix32 Fix32::operator+()                
+{ 
+  return m;
+}
+
+inline Fix32 Fix32::operator-()                
+{ 
+  return -m;
+}
+
+inline Fix32 operator+(Fix32& f, Fix32& g) 
+{
+  long sum = f.m + g.m;
+  if ( (f.m ^ sum) & (g.m ^ sum) & Fix32_msb )
+    f.overflow(sum);
+  return sum;
+}
+
+inline Fix32 operator-(Fix32& f, Fix32& g) 
+{
+  long sum = f.m - g.m;
+  if ( (f.m ^ sum) & (-g.m ^ sum) & Fix32_msb )
+    f.overflow(sum);
+  return sum;
+}
+
+inline Fix32 operator<<(Fix32& a, int b)       
+{ 
+  return a.m << b;
+}
+
+inline Fix32 operator>>(Fix32& a, int b)       
+{ 
+  return a.m >> b;
+}
+
+inline Fix32& Fix32::operator+=(Fix32& f)      
+{ 
+  return *this = *this + f;
+}
+
+inline Fix32& Fix32::operator-=(Fix32& f)      
+{ 
+  return *this = *this - f;
+}
+
+inline Fix32& Fix32::operator*=(Fix32& f)      
+{ 
+  return *this = *this * f;
+}
+
+inline Fix32& Fix32::operator/=(Fix32& f)      
+{ 
+  return *this = *this / f;
+}
+
+
+inline Fix32& Fix32::operator<<=(int b)        
+{ 
+  return *this = *this << b;
+}
+
+inline Fix32& Fix32::operator>>=(int b)        
+{ 
+  return *this = *this >> b;
+}
+
+inline int operator==(Fix32& f, Fix32& g)      
+{ 
+  return f.m == g.m;
+}
+
+inline int operator!=(Fix32& f, Fix32& g)      
+{ 
+  return f.m != g.m;
+}
+
+inline int operator>=(Fix32& f, Fix32& g)      
+{ 
+  return f.m >= g.m;
+}
+
+inline int operator<=(Fix32& f, Fix32& g)      
+{ 
+  return f.m <= g.m;
+}
+
+inline int operator>(Fix32& f, Fix32& g)       
+{ 
+  return f.m > g.m;
+}
+
+inline int operator<(Fix32& f, Fix32& g)       
+{ 
+  return f.m < g.m;
+}
+
+inline istream& operator>>(istream& s, Fix32& f)
+{ 
+  double d;
+  s >> d; 
+  f = d; 
+  return s; 
+}
+
+inline ostream& operator<<(ostream& s, Fix32& f)
+{ 
+  return s << double(f);
+}
+
+inline Fix32 operator*(Fix32&  f, int g)
+{
+  return Fix32(long(f.m * g));
+}
+
+inline Fix32 operator*(int g, Fix32&  f)
+{
+  return f * g;
+}
+
+
+
+inline Fix32& Fix32::operator*=(int g)
+{
+  return *this = *this * g;
+}
+
+
+#endif
+#endif
+
diff --git a/usr/include/g++/Fix24.h b/usr/include/g++/Fix24.h
new file mode 100644 (file)
index 0000000..ec48afc
--- /dev/null
@@ -0,0 +1,595 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Kurt Baudendistel (gt-eedsp!baud@gatech.edu)
+    adapted for libg++ by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _Fix24_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Fix24_h 1
+
+#include <stream.h>
+#include <std.h>
+
+// extra type definitions 
+
+typedef struct {
+  long                 u;
+  unsigned long               l;
+} twolongs;
+
+// constant definitions
+
+static const int
+  Fix24_shift = 31;
+                 
+static const double
+  Fix24_fs = 2147483648.,              // 2^Fix24_shift
+  Fix24_mult = Fix24_fs,
+  Fix24_div = 1./Fix24_fs,
+  Fix24_max = 1. - .5/Fix24_fs,
+  Fix24_min = -1.;
+         
+static const unsigned long
+  Fix24_msb = 0x80000000L,
+  Fix24_lsb = 0x00000100L,
+  Fix24_m_max = 0x7fffff00L,
+  Fix24_m_min = 0x80000000L;
+
+static const double
+  Fix48_fs = 36028797018963968.,       // 2^(24+Fix24_shift)
+  Fix48_max = 1. - .5/Fix48_fs,
+  Fix48_min = -1.,
+  Fix48_div_u = 1./Fix24_fs,
+  Fix48_div_l = 1./Fix48_fs;
+   
+static const twolongs
+  Fix48_msb = { 0x80000000L, 0L },
+  Fix48_lsb = { 0L, 0x00000100L },
+  Fix48_m_max = { 0x7fffff00L, 0xffffff00L },
+  Fix48_m_min = { 0x80000000L, 0L };
+                 
+//
+// Fix24    class: 24-bit Fixed point data type
+//
+//     consists of a 24-bit mantissa (sign bit & 23 data bits).
+//
+
+class Fix24 
+{ 
+  friend class          Fix48;
+
+  long                  m;
+
+  long                  assign(double d);
+         operator       double();
+                        Fix24(long i);
+                        Fix24(int i);
+
+
+public:
+                        Fix24();
+                        Fix24(Fix24&  f);
+                        Fix24(double d);
+                        Fix24(Fix48& f);
+
+                        ~Fix24();
+
+  Fix24&                operator=(Fix24&  f);
+  Fix24&                operator=(double d);
+  Fix24&                operator=(Fix48& f);
+
+  friend long&          mantissa(Fix24&  f);
+  friend double         value(Fix24&  f);
+
+  Fix24                 operator +  ();
+  Fix24                 operator -  ();
+
+  friend Fix24          operator +  (Fix24&  f, Fix24&  g);
+  friend Fix24          operator -  (Fix24&  f, Fix24&  g);
+  friend Fix48          operator *  (Fix24&  f, Fix24&  g);
+  friend Fix24          operator *  (Fix24&  f, int     g);
+  friend Fix24          operator *  (int     g, Fix24&  f);
+  friend Fix24          operator /  (Fix24&  f, Fix24&  g);
+  friend Fix24          operator << (Fix24&  f, int b);
+  friend Fix24          operator >> (Fix24&  f, int b);
+
+  Fix24&                operator += (Fix24&  f);
+  Fix24&                operator -= (Fix24&  f);
+  Fix24&                operator *= (Fix24&  f);
+  Fix24&                operator *= (int     b);
+  Fix24&                operator /= (Fix24&  f);
+
+  Fix24&                operator <<=(int b);
+  Fix24&                operator >>=(int b);
+
+  friend int            operator == (Fix24&  f, Fix24&  g);
+  friend int            operator != (Fix24&  f, Fix24&  g);
+  friend int            operator >= (Fix24&  f, Fix24&  g);
+  friend int            operator <= (Fix24&  f, Fix24&  g);
+  friend int            operator >  (Fix24&  f, Fix24&  g);
+  friend int            operator <  (Fix24&  f, Fix24&  g);
+
+  friend istream&       operator >> (istream& s, Fix24&  f);
+  friend ostream&       operator << (ostream& s, Fix24&  f);
+
+  void                  overflow(long&);
+  void                  range_error(long&);
+};
+
+//
+// Fix48 class: 48-bit Fixed point data type
+//
+//     consists of a 48-bit mantissa (sign bit & 47 data bits).
+//
+
+class Fix48 
+{ 
+  friend class         Fix24;
+
+  twolongs             m;
+
+  twolongs             assign(double d);
+         operator      double();
+                       Fix48(twolongs i);
+
+public:
+                       Fix48();
+                       Fix48(Fix48& f);
+                       Fix48(Fix24&  f);
+                       Fix48(double d);
+                       ~Fix48();
+
+  Fix48&               operator =  (Fix48& f);
+  Fix48&               operator =  (Fix24&  f);
+  Fix48&               operator =  (double d);
+
+  friend twolongs&     mantissa(Fix48& f);
+  friend double        value(Fix48& f);
+
+  Fix48                operator +  ();
+  Fix48                operator -  ();
+
+  friend Fix48         operator +  (Fix48& f, Fix48& g);
+  friend Fix48         operator -  (Fix48& f, Fix48& g);
+  friend Fix48         operator *  (Fix48& f, int    g);
+  friend Fix48         operator *  (int    g, Fix48& f);
+  friend Fix48         operator << (Fix48& f, int b);
+  friend Fix48         operator >> (Fix48& f, int b);
+
+  friend Fix48         operator *  (Fix24&  f, Fix24&  g);
+
+  Fix48&               operator += (Fix48& f);
+  Fix48&               operator -= (Fix48& f);
+  Fix48&               operator *= (int    b);
+  Fix48&               operator <<=(int b);
+  Fix48&               operator >>=(int b);
+
+  friend int           operator == (Fix48& f, Fix48& g);
+  friend int           operator != (Fix48& f, Fix48& g);
+  friend int           operator >= (Fix48& f, Fix48& g);
+  friend int           operator <= (Fix48& f, Fix48& g);
+  friend int           operator >  (Fix48& f, Fix48& g);
+  friend int           operator <  (Fix48& f, Fix48& g);
+
+  friend istream&      operator >> (istream& s, Fix48& f);
+  friend ostream&      operator << (ostream& s, Fix48& f);
+
+  void                 overflow(twolongs& i);
+  void                 range_error(twolongs& i);
+};
+
+
+// active error handler declarations
+
+typedef void (*Fix24_peh)(long&);
+typedef void (*Fix48_peh)(twolongs&);
+
+extern Fix24_peh Fix24_overflow_handler;
+extern Fix48_peh Fix48_overflow_handler;
+
+extern Fix24_peh Fix24_range_error_handler;
+extern Fix48_peh Fix48_range_error_handler;
+
+
+// error handler declarations
+
+#if defined(SHORT_NAMES) || defined(VMS)
+#define        set_overflow_handler    sohndl
+#define set_range_error_handler        srnghdl
+#endif
+
+extern Fix24_peh set_Fix24_overflow_handler(Fix24_peh);
+extern Fix48_peh set_Fix48_overflow_handler(Fix48_peh);
+extern void set_overflow_handler(Fix24_peh, Fix48_peh);
+
+extern Fix24_peh set_Fix24_range_error_handler(Fix24_peh);
+extern Fix48_peh set_Fix48_range_error_handler(Fix48_peh);
+extern void set_range_error_handler(Fix24_peh, Fix48_peh);
+
+extern void
+  Fix24_ignore(long&),
+  Fix24_overflow_saturate(long&),
+  Fix24_overflow_warning_saturate(long&),
+  Fix24_warning(long&),
+  Fix24_abort(long&);
+
+extern void
+  Fix48_ignore(twolongs&),
+  Fix48_overflow_saturate(twolongs&),
+  Fix48_overflow_warning_saturate(twolongs&),
+  Fix48_warning(twolongs&),
+  Fix48_abort(twolongs&);
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline Fix24::~Fix24() {}
+
+inline Fix24::Fix24(long i)            
+{ 
+  m = i; 
+}
+
+inline Fix24::Fix24(int i)         
+{ 
+  m = i; 
+}
+
+inline Fix24::operator double() 
+{ 
+  return  Fix24_div * m; 
+}
+
+inline Fix24::Fix24()                          
+{ 
+  m = 0; 
+}
+
+inline Fix24::Fix24(Fix24&  f)         
+{ 
+  m = f.m; 
+}
+
+inline Fix24::Fix24(double d)          
+{
+  m = assign(d);
+}
+
+inline Fix24::Fix24(Fix48& f)          
+{ 
+  m = f.m.u;
+}
+
+inline Fix24&  Fix24::operator=(Fix24&  f)     
+{ 
+  m = f.m; 
+  return *this; 
+}
+
+inline Fix24&  Fix24::operator=(double d) 
+{ 
+  m = assign(d); 
+  return *this; 
+}
+
+inline Fix24&  Fix24::operator=(Fix48& f)
+{ 
+  m = f.m.u;
+  return *this; 
+}
+
+inline long& mantissa(Fix24&  f)       
+{ 
+  return f.m; 
+}
+
+inline double value(Fix24&  f)         
+{ 
+  return double(f); 
+}
+
+inline Fix24 Fix24::operator+()                
+{ 
+  return m; 
+}
+
+inline Fix24 Fix24::operator-()                
+{ 
+  return -m; 
+}
+
+inline Fix24 operator+(Fix24&  f, Fix24&  g) 
+{
+  long sum = f.m + g.m;
+  if ( (f.m ^ sum) & (g.m ^ sum) & Fix24_msb )
+    f.overflow(sum);
+  return sum;
+}
+
+inline Fix24 operator-(Fix24&  f, Fix24&  g) 
+{
+  long sum = f.m - g.m;
+  if ( (f.m ^ sum) & (-g.m ^ sum) & Fix24_msb )
+    f.overflow(sum);
+  return sum;
+}
+
+inline Fix24 operator*(Fix24& a, int b)        
+{ 
+  return a.m * b; 
+}
+
+inline Fix24 operator*(int b, Fix24& a)        
+{ 
+  return a * b; 
+}
+
+inline Fix24 operator<<(Fix24& a, int b)       
+{ 
+  return a.m << b; 
+}
+
+inline Fix24 operator>>(Fix24& a, int b)       
+{ 
+  return (a.m >> b) & 0xffffff00L; 
+}
+
+inline  Fix24&  Fix24:: operator+=(Fix24&  f)
+{ 
+  return *this = *this + f; 
+}
+
+inline Fix24&  Fix24:: operator-=(Fix24&  f)   
+{ 
+  return *this = *this - f; 
+}
+
+inline Fix24& Fix24::operator*=(Fix24& f)      
+{ 
+  return *this = *this * f; 
+}
+
+inline Fix24&  Fix24:: operator/=(Fix24&  f)   
+{ 
+  return *this = *this / f; 
+}
+
+inline Fix24&  Fix24:: operator<<=(int b)      
+{ 
+  return *this = *this << b;
+}
+
+inline Fix24&  Fix24:: operator>>=(int b)      
+{ 
+  return *this = *this >> b;
+}
+
+inline Fix24& Fix24::operator*=(int b)
+{ 
+  return *this = *this * b; 
+}
+
+inline int operator==(Fix24&  f, Fix24&  g)    
+{ 
+  return f.m == g.m;
+}
+
+inline int operator!=(Fix24&  f, Fix24&  g)    
+{ 
+  return f.m != g.m;
+}
+
+inline int operator>=(Fix24&  f, Fix24&  g)    
+{ 
+  return f.m >= g.m;
+}
+
+inline int operator<=(Fix24&  f, Fix24&  g)    
+{ 
+  return f.m <= g.m;
+}
+
+inline int operator>(Fix24&  f, Fix24&  g)     
+{ 
+  return f.m > g.m;
+}
+
+inline int operator<(Fix24&  f, Fix24&  g)     
+{ 
+  return f.m < g.m;
+}
+
+inline istream&  operator>>(istream& s, Fix24&  f)
+{ 
+  double d;
+  s >> d; 
+  f = d; 
+  return s; 
+}
+
+inline ostream&  operator<<(ostream& s, Fix24&  f)
+{ 
+  return s << double(f);
+}
+
+inline Fix48::~Fix48() {}
+
+inline Fix48::Fix48(twolongs i)                
+{ 
+  m = i;
+}
+
+inline Fix48:: operator double()               
+{ 
+/*
+ * Note: can't simply do Fix48_div_u * m.u + Fix48_div_l * m.l, because
+ * m.u is signed and m.l is unsigned.
+ */
+  return (m.u >= 0)? Fix48_div_u * m.u + Fix48_div_l * m.l :
+      (Fix48_div_u * ((unsigned long)(m.u & 0xffffff00)) 
+         + Fix48_div_l * m.l) - 2;
+}
+
+inline Fix48::Fix48()                      
+{ 
+  m.u = 0;
+  m.l = 0;
+}
+
+inline Fix48::Fix48(Fix48& f)          
+{ 
+  m = f.m;
+}
+
+inline Fix48::Fix48(Fix24&  f)    
+{ 
+  m.u = f.m;
+  m.l = 0;
+}
+
+inline Fix48::Fix48(double d)          
+{ 
+  m = assign(d);
+}
+
+inline Fix48& Fix48::operator=(Fix48& f)       
+{ 
+  m = f.m;
+  return *this; 
+}
+
+inline Fix48& Fix48::operator=(Fix24&  f)      
+{ 
+  m.u = f.m;
+  m.l = 0;
+  return *this;
+}
+
+inline Fix48& Fix48::operator=(double d)       
+{ 
+  m = assign(d);
+  return *this; 
+}
+
+inline twolongs& mantissa(Fix48& f)    
+{ 
+  return f.m;
+}
+
+inline double value(Fix48& f)          
+{ 
+  return double(f);
+}
+
+inline Fix48 Fix48::operator+()                
+{ 
+  return m;
+}
+
+inline Fix48 Fix48::operator-()                
+{ 
+  twolongs n;
+  n.l = -m.l;
+  n.u = ~m.u + ((n.l ^ m.l) & Fix24_msb ? 0 : Fix24_lsb);
+  return Fix48(n);
+}
+
+inline Fix48 operator*(int b, Fix48& a)        
+{ 
+  return a * b; 
+}
+
+inline Fix48& Fix48::operator+=(Fix48& f)      
+{ 
+  return *this = *this + f;
+}
+
+inline Fix48& Fix48::operator-=(Fix48& f)      
+{ 
+  return *this = *this - f;
+}
+
+inline Fix48& Fix48::operator*=(int b) 
+{ 
+  return *this = *this * b;
+}
+
+inline Fix48& Fix48::operator<<=(int b)        
+{ 
+  return *this = *this << b;
+}
+
+inline Fix48& Fix48::operator>>=(int b)        
+{ 
+  return *this = *this >> b;
+}
+
+inline int operator==(Fix48& f, Fix48& g)      
+{ 
+  return f.m.u == g.m.u && f.m.l == g.m.l;
+}
+
+inline int operator!=(Fix48& f, Fix48& g)      
+{ 
+  return f.m.u != g.m.u || f.m.l != g.m.l;
+}
+
+inline int operator>=(Fix48& f, Fix48& g)      
+{ 
+  return f.m.u >= g.m.u || (f.m.u == g.m.u && f.m.l >= g.m.l);
+}
+
+inline int operator<=(Fix48& f, Fix48& g)      
+{ 
+  return f.m.u <= g.m.u || (f.m.u == g.m.u && f.m.l <= g.m.l);
+}
+
+inline int operator>(Fix48& f, Fix48& g)       
+{ 
+  return f.m.u > g.m.u || (f.m.u == g.m.u && f.m.l > g.m.l);
+}
+
+inline int operator<(Fix48& f, Fix48& g)       
+{ 
+  return f.m.u < g.m.u || (f.m.u == g.m.u && f.m.l < g.m.l);
+}
+
+inline istream& operator>>(istream& s, Fix48& f)
+{ 
+  double d;
+  s >> d; 
+  f = d; 
+  return s; 
+}
+
+inline ostream& operator<<(ostream& s, Fix48& f)
+{ 
+  return s << double(f);
+}
+
+
+#endif
+#endif
+
diff --git a/usr/include/g++/Fmodes.h b/usr/include/g++/Fmodes.h
new file mode 100644 (file)
index 0000000..524c2bd
--- /dev/null
@@ -0,0 +1,34 @@
+
+#ifndef _Fmodes_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Fmodes_h 1
+
+enum io_mode                    // known unix file IO modes
+{
+  io_readonly   = 0,            
+  io_writeonly  = 1,
+  io_readwrite  = 2, 
+  io_appendonly = 3,
+  io_append     = 4,            // append, plus allow reads
+};
+
+enum access_mode                // ways to open a file
+{
+  a_createonly  = 0,            // create, fail if file exists
+  a_create      = 1,            // create if doesn't exist, else truncate
+  a_useonly     = 2,            // use (no truncate)  fail if doesn't exist
+  a_use         = 3,            // use (no truncate), create if doesn't exist
+};
+
+enum state_value                // File states
+{ 
+  _good         = 0,            // all is well
+  _eof          = 1,            // at eof
+  _fail         = 2,            // logical or physical IO error
+  _bad          = 4             // unopened/corrupted
+};
+
+#endif
diff --git a/usr/include/g++/Geom.h b/usr/include/g++/Geom.h
new file mode 100644 (file)
index 0000000..d70b96a
--- /dev/null
@@ -0,0 +1,59 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _Geometric_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Geometric_h 
+
+#include <Random.h>
+
+class Geometric: public Random {
+protected:
+    double pMean;
+public:
+    Geometric(double mean, RNG *gen);
+
+    double mean();
+    double mean(double x);
+
+    virtual double operator()();
+
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline Geometric::Geometric(double mean, RNG *gen) : (gen)
+{
+  pMean = mean;
+}
+
+
+inline double Geometric::mean() { return pMean; }
+inline double Geometric::mean(double x) {
+  double tmp = pMean; pMean = x; return tmp;
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/GetOpt.h b/usr/include/g++/GetOpt.h
new file mode 100644 (file)
index 0000000..413c52d
--- /dev/null
@@ -0,0 +1,131 @@
+/* Getopt for GNU. 
+   Copyright (C) 1987, 1989 Free Software Foundation, Inc.
+   (Modified by Douglas C. Schmidt for use with GNU G++.)
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 1, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+
+
+\f
+/* This version of `getopt' appears to the caller like standard Unix `getopt'
+   but it behaves differently for the user, since it allows the user
+   to intersperse the options with the other arguments.
+
+   As `getopt' works, it permutes the elements of `argv' so that,
+   when it is done, all the options precede everything else.  Thus
+   all application programs are extended to handle flexible argument order.
+
+   Setting the environment variable _POSIX_OPTION_ORDER disables permutation.
+   Then the behavior is completely standard.
+
+   GNU application programs can use a third alternative mode in which
+   they can distinguish the relative order of options and other arguments.  */
+
+#ifndef GetOpt_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define GetOpt_h 1
+
+#include <std.h>
+#include <stdio.h>
+
+class GetOpt
+{
+private:
+  /* The next char to be scanned in the option-element
+     in which the last option character we returned was found.
+     This allows us to pick up the scan where we left off.
+        
+     If this is zero, or a null string, it means resume the scan
+     by advancing to the next ARGV-element.  */
+  
+  static char *nextchar;
+  
+  
+  /* Describe how to deal with options that follow non-option ARGV-elements.
+    
+    UNSPECIFIED means the caller did not specify anything;
+    the default is then REQUIRE_ORDER if the environment variable
+    _OPTIONS_FIRST is defined, PERMUTE otherwise.
+      
+    REQUIRE_ORDER means don't recognize them as options.
+    Stop option processing when the first non-option is seen.
+    This is what Unix does.
+            
+    PERMUTE is the default.  We permute the contents of `argv' as we scan,
+    so that eventually all the options are at the end.  This allows options
+    to be given in any order, even with programs that were not written to
+    expect this.
+        
+    RETURN_IN_ORDER is an option available to programs that were written
+    to expect options and other ARGV-elements in any order and that care about
+    the ordering of the two.  We describe each non-option ARGV-element
+    as if it were the argument of an option with character code zero.
+    Using `-' as the first character of the list of option characters
+    requests this mode of operation.
+                    
+    The special argument `--' forces an end of option-scanning regardless
+    of the value of `ordering'.  In the case of RETURN_IN_ORDER, only
+    `--' can cause `getopt' to return EOF with `optind' != ARGC.  */
+  
+  static enum { REQUIRE_ORDER, PERMUTE, RETURN_IN_ORDER } ordering;
+
+  /* Handle permutation of arguments.  */
+  
+  /* Describe the part of ARGV that contains non-options that have
+     been skipped.  `first_nonopt' is the index in ARGV of the first of them;
+     `last_nonopt' is the index after the last of them.  */
+  
+  static int first_nonopt;
+  static int last_nonopt;
+  
+  void exchange (char **argv);
+public:
+  /* For communication from `getopt' to the caller.
+     When `getopt' finds an option that takes an argument,
+     the argument value is returned here.
+     Also, when `ordering' is RETURN_IN_ORDER,
+     each non-option ARGV-element is returned here.  */
+  
+  char *optarg;
+  
+  /* Index in ARGV of the next element to be scanned.
+     This is used for communication to and from the caller
+     and for communication between successive calls to `getopt'.
+     On entry to `getopt', zero means this is the first call; initialize.
+          
+     When `getopt' returns EOF, this is the index of the first of the
+     non-option elements that the caller should itself scan.
+              
+     Otherwise, `optind' communicates from one call to the next
+     how much of ARGV has been scanned so far.  */
+  
+  int optind;
+
+  /* Callers store zero here to inhibit the error message
+     for unrecognized options.  */
+  
+  int opterr;
+  
+  int    nargc;
+  char **nargv;
+  char  *noptstring;
+  
+  GetOpt (int argc, char **argv, char *optstring);
+  int operator () (void);
+};
+
+#endif
diff --git a/usr/include/g++/HypGeom.h b/usr/include/g++/HypGeom.h
new file mode 100644 (file)
index 0000000..b120f10
--- /dev/null
@@ -0,0 +1,78 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _HyperGeometric_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _HyperGeometric_h 
+
+#include <Random.h>
+
+class HyperGeometric: public Random {
+protected:
+    double pMean;
+    double pVariance;
+    double pP;
+    void setState();
+
+public:
+    HyperGeometric(double mean, double variance, RNG *gen);
+
+    double mean();
+    double mean(double x);
+    double variance();
+    double variance(double x);
+
+    virtual double operator()();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline void HyperGeometric::setState() {
+  double z = pVariance / (pMean * pMean);
+  pP = 0.5 * (1.0 - sqrt((z - 1.0) / ( z + 1.0 )));
+}
+
+inline HyperGeometric::HyperGeometric(double mean, double variance, RNG *gen)
+: (gen) {
+  pMean = mean; pVariance = variance;
+  setState();
+}
+
+inline double HyperGeometric::mean() { return pMean; };
+
+inline double HyperGeometric::mean(double x) {
+  double t = pMean; pMean = x;
+  setState(); return t;
+}
+
+inline double HyperGeometric::variance() { return pVariance; }
+
+inline double HyperGeometric::variance(double x) {
+  double t = pVariance; pVariance = x;
+  setState(); return t;
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/Incremental.h b/usr/include/g++/Incremental.h
new file mode 100644 (file)
index 0000000..9b6bb3f
--- /dev/null
@@ -0,0 +1,13 @@
+#ifndef Incremental_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define Incremental_h
+#define DECLARE_INIT_FUNCTION(USER_INIT_FUNCTION) \
+static void USER_INIT_FUNCTION (); extern void (*_initfn)(); \
+static struct xyzzy { xyzzy () {_initfn = USER_INIT_FUNCTION;}; \
+~xyzzy () {};} __2xyzzy;
+#else
+#error Incremental.h was not the first file included in this module
+#endif
diff --git a/usr/include/g++/Integer.h b/usr/include/g++/Integer.h
new file mode 100644 (file)
index 0000000..a241e65
--- /dev/null
@@ -0,0 +1,1114 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _Integer_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Integer_h 1
+
+#include <stream.h>
+
+struct IntRep                    // internal Integer representations
+{
+  unsigned short  len;          // current length
+  unsigned short  sz;           // allocated space
+  short           sgn;          // 1 means >= 0; 0 means < 0 
+  unsigned short  s[1];         // represented as ushort array starting here
+};
+
+extern IntRep*  Ialloc(IntRep*, const unsigned short *, int, int, int);
+extern IntRep*  Icalloc(IntRep*, int);
+extern IntRep*  Icopy_long(IntRep*, long);
+extern IntRep*  Icopy(IntRep*, const IntRep*);
+extern IntRep*  Iresize(IntRep*, int);
+extern IntRep*  add(const IntRep*, int, const IntRep*, int, IntRep*);
+extern IntRep*  add(const IntRep*, int, long, IntRep*);
+extern IntRep*  multiply(const IntRep*, const IntRep*, IntRep*);
+extern IntRep*  multiply(const IntRep*, long, IntRep*);
+extern IntRep*  lshift(const IntRep*, long, IntRep*);
+extern IntRep*  lshift(const IntRep*, const IntRep*, int, IntRep*);
+extern IntRep*  bitop(const IntRep*, const IntRep*, IntRep*, char);
+extern IntRep*  bitop(const IntRep*, long, IntRep*, char);
+extern IntRep*  power(const IntRep*, long, IntRep*);
+extern IntRep*  div(const IntRep*, const IntRep*, IntRep*);
+extern IntRep*  mod(const IntRep*, const IntRep*, IntRep*);
+extern IntRep*  div(const IntRep*, long, IntRep*);
+extern IntRep*  mod(const IntRep*, long, IntRep*);
+extern IntRep*  compl(const IntRep*, IntRep*);
+extern IntRep*  abs(const IntRep*, IntRep*);
+extern IntRep*  negate(const IntRep*, IntRep*);
+extern IntRep*  pow(const IntRep*, long);
+extern IntRep*  gcd(const IntRep*, const IntRep* y);
+extern int      compare(const IntRep*, const IntRep*);
+extern int      compare(const IntRep*, long);
+extern int      ucompare(const IntRep*, const IntRep*);
+extern int      ucompare(const IntRep*, long);
+extern char*    Itoa(const IntRep* x, int base = 10, int width = 0);
+extern IntRep*  atoIntRep(const char* s, int base = 10);
+extern long     Itolong(const IntRep*);
+extern double   Itodouble(const IntRep*);
+extern int      Iislong(const IntRep*);
+extern int      Iisdouble(const IntRep*);
+extern long     lg(const IntRep*);
+
+
+class Integer
+{
+protected:
+  IntRep*         rep;
+public:
+                  Integer();
+                  Integer(long);
+                  Integer(const Integer&);
+
+                  ~Integer();
+
+  void            operator =  (const Integer&);
+  void            operator =  (long);
+
+// unary operations to self
+
+  void            operator ++ ();
+  void            operator -- ();
+  void            negate();          // negate in-place
+  void            abs();             // absolute-value in-place
+  void            complement();      // bitwise complement in-place
+
+// assignment-based operations
+
+  void            operator += (const Integer&);
+  void            operator -= (const Integer&);
+  void            operator *= (const Integer&);
+  void            operator /= (const Integer&);
+  void            operator %= (const Integer&);
+  void            operator <<=(const Integer&);
+  void            operator >>=(const Integer&);
+  void            operator &= (const Integer&);
+  void            operator |= (const Integer&);
+  void            operator ^= (const Integer&);
+
+  void            operator += (long);
+  void            operator -= (long);
+  void            operator *= (long);
+  void            operator /= (long);
+  void            operator %= (long);
+  void            operator <<=(long);
+  void            operator >>=(long);
+  void            operator &= (long);
+  void            operator |= (long);
+  void            operator ^= (long);
+
+// (constructive binary operations are inlined below)
+
+#ifdef __GNUG__
+  friend Integer operator <? (const Integer& x, const Integer& y); // min
+  friend Integer operator >? (const Integer& x, const Integer& y); // max
+#endif
+
+// builtin Integer functions that must be friends
+
+  friend long     lg (const Integer&); // floor log base 2 of abs(x)
+  friend double   ratio(const Integer& x, const Integer& y);
+                  // return x/y as a double
+
+  friend Integer  gcd(const Integer&, const Integer&);
+  friend int      even(const Integer&); // true if even
+  friend int      odd(const Integer&); // true if odd
+  friend int      sign(const Integer&); // returns -1, 0, +1
+
+  friend void     setbit(Integer& x, long b);   // set b'th bit of x
+  friend void     clearbit(Integer& x, long b); // clear b'th bit
+  friend int      testbit(const Integer& x, long b);  // return b'th bit
+
+// procedural versions of operators
+
+  friend void     abs(const Integer& x, Integer& dest);
+  friend void     negate(const Integer& x, Integer& dest);
+  friend void     complement(const Integer& x, Integer& dest);
+
+  friend int      compare(const Integer&, const Integer&);  
+  friend int      ucompare(const Integer&, const Integer&); 
+  friend void     add(const Integer& x, const Integer& y, Integer& dest);
+  friend void     sub(const Integer& x, const Integer& y, Integer& dest);
+  friend void     mul(const Integer& x, const Integer& y, Integer& dest);
+  friend void     div(const Integer& x, const Integer& y, Integer& dest);
+  friend void     mod(const Integer& x, const Integer& y, Integer& dest);
+  friend void     divide(const Integer& x, const Integer& y, 
+                         Integer& q, Integer& r);
+  friend void     and(const Integer& x, const Integer& y, Integer& dest);
+  friend void     or(const Integer& x, const Integer& y, Integer& dest);
+  friend void     xor(const Integer& x, const Integer& y, Integer& dest);
+  friend void     lshift(const Integer& x, const Integer& y, Integer& dest);
+  friend void     rshift(const Integer& x, const Integer& y, Integer& dest);
+  friend void     pow(const Integer& x, const Integer& y, Integer& dest);
+
+  friend int      compare(const Integer&, long);  
+  friend int      ucompare(const Integer&, long); 
+  friend void     add(const Integer& x, long y, Integer& dest);
+  friend void     sub(const Integer& x, long y, Integer& dest);
+  friend void     mul(const Integer& x, long y, Integer& dest);
+  friend void     div(const Integer& x, long y, Integer& dest);
+  friend void     mod(const Integer& x, long y, Integer& dest);
+  friend void     divide(const Integer& x, long y, Integer& q, long& r);
+  friend void     and(const Integer& x, long y, Integer& dest);
+  friend void     or(const Integer& x, long y, Integer& dest);
+  friend void     xor(const Integer& x, long y, Integer& dest);
+  friend void     lshift(const Integer& x, long y, Integer& dest);
+  friend void     rshift(const Integer& x, long y, Integer& dest);
+  friend void     pow(const Integer& x, long y, Integer& dest);
+
+  friend int      compare(long, const Integer&);  
+  friend int      ucompare(long, const Integer&); 
+  friend void     add(long x, const Integer& y, Integer& dest);
+  friend void     sub(long x, const Integer& y, Integer& dest);
+  friend void     mul(long x, const Integer& y, Integer& dest);
+  friend void     and(long x, const Integer& y, Integer& dest);
+  friend void     or(long x, const Integer& y, Integer& dest);
+  friend void     xor(long x, const Integer& y, Integer& dest);
+
+// coercion & conversion
+
+  int             fits_in_long() const;
+  int             fits_in_double() const;
+
+                  operator long() const;
+                  operator double() const;
+
+  friend char*    Itoa(const Integer& x, int base = 10, int width = 0);
+  friend Integer  atoI(const char* s, int base = 10);
+  
+  friend istream& operator >> (istream& s, Integer& y);
+  friend ostream& operator << (ostream& s, const Integer& y);
+
+// error detection
+
+  int             initialized() const;
+  volatile void   error(const char* msg) const;
+  int             OK() const;  
+};
+
+
+//  (These are declared inline)
+
+  int      operator == (const Integer&, const Integer&);
+  int      operator == (const Integer&, long);
+  int      operator != (const Integer&, const Integer&);
+  int      operator != (const Integer&, long);
+  int      operator <  (const Integer&, const Integer&);
+  int      operator <  (const Integer&, long);
+  int      operator <= (const Integer&, const Integer&);
+  int      operator <= (const Integer&, long);
+  int      operator >  (const Integer&, const Integer&);
+  int      operator >  (const Integer&, long);
+  int      operator >= (const Integer&, const Integer&);
+  int      operator >= (const Integer&, long);
+  Integer  operator -  (const Integer&);
+  Integer  operator ~  (const Integer&);
+  Integer  operator +  (const Integer&, const Integer&);
+  Integer  operator +  (const Integer&, long);
+  Integer  operator +  (long, const Integer&);
+  Integer  operator -  (const Integer&, const Integer&);
+  Integer  operator -  (const Integer&, long);
+  Integer  operator -  (long, const Integer&);
+  Integer  operator *  (const Integer&, const Integer&);
+  Integer  operator *  (const Integer&, long);
+  Integer  operator *  (long, const Integer&);
+  Integer  operator /  (const Integer&, const Integer&);
+  Integer  operator /  (const Integer&, long);
+  Integer  operator %  (const Integer&, const Integer&);
+  Integer  operator %  (const Integer&, long);
+  Integer  operator << (const Integer&, const Integer&);
+  Integer  operator << (const Integer&, long);
+  Integer  operator >> (const Integer&, const Integer&);
+  Integer  operator >> (const Integer&, long);
+  Integer  operator &  (const Integer&, const Integer&);
+  Integer  operator &  (const Integer&, long);
+  Integer  operator &  (long, const Integer&);
+  Integer  operator |  (const Integer&, const Integer&);
+  Integer  operator |  (const Integer&, long);
+  Integer  operator |  (long, const Integer&);
+  Integer  operator ^  (const Integer&, const Integer&);
+  Integer  operator ^  (const Integer&, long);
+  Integer  operator ^  (long, const Integer&);
+
+  Integer  abs(const Integer&); // absolute value
+  Integer  sqr(const Integer&); // square
+
+  Integer  pow(const Integer& x, const Integer& y);
+  Integer  pow(const Integer& x, long y);
+  Integer  Ipow(long x, long y); // x to the y as Integer 
+
+
+extern char*    dec(const Integer& x, int width = 0);
+extern char*    oct(const Integer& x, int width = 0);
+extern char*    hex(const Integer& x, int width = 0);
+extern Integer  sqrt(const Integer&); // floor of square root
+extern Integer  lcm(const Integer& x, const Integer& y); // least common mult
+  
+
+typedef Integer IntTmp; // for backward compatibility
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+
+inline Integer::Integer() :rep(0) {}
+
+inline Integer::Integer(long y) :rep(Icopy_long(0, y)) {}
+
+inline Integer::Integer(const Integer&  y) :rep(Icopy(0, y.rep)) {}
+
+inline Integer::~Integer() { delete rep; }
+
+inline void  Integer::operator = (const Integer&  y)
+{
+  rep = Icopy(rep, y.rep);
+}
+
+inline void Integer::operator = (long y)
+{
+  rep = Icopy_long(rep, y); 
+}
+
+inline Integer::operator long() const
+{ 
+  return Itolong(rep);
+}
+
+inline int Integer::initialized() const
+{
+  return rep != 0;
+}
+
+inline int Integer::fits_in_long() const
+{
+  return Iislong(rep);
+}
+
+inline Integer::operator double() const
+{ 
+  return Itodouble(rep);
+}
+
+inline int Integer::fits_in_double() const
+{
+  return Iisdouble(rep);
+}
+
+// procedural versions
+
+inline int compare(const Integer& x, const Integer& y)
+{
+  return compare(x.rep, y.rep);
+}
+
+inline int ucompare(const Integer& x, const Integer& y)
+{
+  return ucompare(x.rep, y.rep);
+}
+
+inline int compare(const Integer& x, long y)
+{
+  return compare(x.rep, y);
+}
+
+inline int ucompare(const Integer& x, long y)
+{
+  return ucompare(x.rep, y);
+}
+
+inline int compare(long x, const Integer& y)
+{
+  return -compare(y.rep, x);
+}
+
+inline int ucompare(long x, const Integer& y)
+{
+  return -ucompare(y.rep, x);
+}
+
+inline void  add(const Integer& x, const Integer& y, Integer& dest)
+{
+  dest.rep = add(x.rep, 0, y.rep, 0, dest.rep);
+}
+
+inline void  sub(const Integer& x, const Integer& y, Integer& dest)
+{
+  dest.rep = add(x.rep, 0, y.rep, 1, dest.rep);
+}
+
+inline void  mul(const Integer& x, const Integer& y, Integer& dest)
+{
+  dest.rep = multiply(x.rep, y.rep, dest.rep);
+}
+
+inline void  div(const Integer& x, const Integer& y, Integer& dest)
+{
+  dest.rep = div(x.rep, y.rep, dest.rep);
+}
+
+inline void  mod(const Integer& x, const Integer& y, Integer& dest)
+{
+  dest.rep = mod(x.rep, y.rep, dest.rep);
+}
+
+inline void  and(const Integer& x, const Integer& y, Integer& dest)
+{
+  dest.rep = bitop(x.rep, y.rep, dest.rep, '&');
+}
+
+inline void  or(const Integer& x, const Integer& y, Integer& dest)
+{
+  dest.rep = bitop(x.rep, y.rep, dest.rep, '|');
+}
+
+inline void  xor(const Integer& x, const Integer& y, Integer& dest)
+{
+  dest.rep = bitop(x.rep, y.rep, dest.rep, '^');
+}
+
+inline void  lshift(const Integer& x, const Integer& y, Integer& dest)
+{
+  dest.rep = lshift(x.rep, y.rep, 0, dest.rep);
+}
+
+inline void  rshift(const Integer& x, const Integer& y, Integer& dest)
+{
+  dest.rep = lshift(x.rep, y.rep, 1, dest.rep);
+}
+
+inline void  pow(const Integer& x, const Integer& y, Integer& dest)
+{
+  dest.rep = power(x.rep, long(y), dest.rep); // not incorrect
+}
+
+inline void  add(const Integer& x, long y, Integer& dest)
+{
+  dest.rep = add(x.rep, 0, y, dest.rep);
+}
+
+inline void  sub(const Integer& x, long y, Integer& dest)
+{
+  dest.rep = add(x.rep, 0, -y, dest.rep);
+}
+
+inline void  mul(const Integer& x, long y, Integer& dest)
+{
+  dest.rep = multiply(x.rep, y, dest.rep);
+}
+
+inline void  div(const Integer& x, long y, Integer& dest)
+{
+  dest.rep = div(x.rep, y, dest.rep);
+}
+
+inline void  mod(const Integer& x, long y, Integer& dest)
+{
+  dest.rep = mod(x.rep, y, dest.rep);
+}
+
+inline void  and(const Integer& x, long y, Integer& dest)
+{
+  dest.rep = bitop(x.rep, y, dest.rep, '&');
+}
+
+inline void  or(const Integer& x, long y, Integer& dest)
+{
+  dest.rep = bitop(x.rep, y, dest.rep, '|');
+}
+
+inline void  xor(const Integer& x, long y, Integer& dest)
+{
+  dest.rep = bitop(x.rep, y, dest.rep, '^');
+}
+
+inline void  lshift(const Integer& x, long y, Integer& dest)
+{
+  dest.rep = lshift(x.rep, y, dest.rep);
+}
+
+inline void  rshift(const Integer& x, long y, Integer& dest)
+{
+  dest.rep = lshift(x.rep, -y, dest.rep);
+}
+
+inline void  pow(const Integer& x, long y, Integer& dest)
+{
+  dest.rep = power(x.rep, y, dest.rep);
+}
+
+inline void abs(const Integer& x, Integer& dest)
+{
+  dest.rep = abs(x.rep, dest.rep);
+}
+
+inline void negate(const Integer& x, Integer& dest)
+{
+  dest.rep = negate(x.rep, dest.rep);
+}
+
+inline void complement(const Integer& x, Integer& dest)
+{
+  dest.rep = compl(x.rep, dest.rep);
+}
+
+inline void  add(long x, const Integer& y, Integer& dest)
+{
+  dest.rep = add(y.rep, 0, x, dest.rep);
+}
+
+inline void  sub(long x, const Integer& y, Integer& dest)
+{
+  dest.rep = add(y.rep, 1, x, dest.rep);
+}
+
+inline void  mul(long x, const Integer& y, Integer& dest)
+{
+  dest.rep = multiply(y.rep, x, dest.rep);
+}
+
+inline void  and(long x, const Integer& y, Integer& dest)
+{
+  dest.rep = bitop(y.rep, x, dest.rep, '&');
+}
+
+inline void  or(long x, const Integer& y, Integer& dest)
+{
+  dest.rep = bitop(y.rep, x, dest.rep, '|');
+}
+
+inline void  xor(long x, const Integer& y, Integer& dest)
+{
+  dest.rep = bitop(y.rep, x, dest.rep, '^');
+}
+
+
+// operator versions
+
+inline int operator == (const Integer&  x, const Integer&  y)
+{
+  return compare(x, y) == 0; 
+}
+
+inline int operator == (const Integer&  x, long y)
+{
+  return compare(x, y) == 0; 
+}
+
+inline int operator != (const Integer&  x, const Integer&  y)
+{
+  return compare(x, y) != 0; 
+}
+
+inline int operator != (const Integer&  x, long y)
+{
+  return compare(x, y) != 0; 
+}
+
+inline int operator <  (const Integer&  x, const Integer&  y)
+{
+  return compare(x, y) <  0; 
+}
+
+inline int operator <  (const Integer&  x, long y)
+{
+  return compare(x, y) <  0; 
+}
+
+inline int operator <= (const Integer&  x, const Integer&  y)
+{
+  return compare(x, y) <= 0; 
+}
+
+inline int operator <= (const Integer&  x, long y)
+{
+  return compare(x, y) <= 0; 
+}
+
+inline int operator >  (const Integer&  x, const Integer&  y)
+{
+  return compare(x, y) >  0; 
+}
+
+inline int operator >  (const Integer&  x, long y)
+{
+  return compare(x, y) >  0; 
+}
+
+inline int operator >= (const Integer&  x, const Integer&  y)
+{
+  return compare(x, y) >= 0; 
+}
+
+inline int operator >= (const Integer&  x, long y)
+{
+  return compare(x, y) >= 0; 
+}
+
+
+inline void  Integer::operator += (const Integer& y)
+{
+  add(*this, y, *this);
+}
+
+inline void  Integer::operator += (long y)
+{
+  add(*this, y, *this);
+}
+
+inline void Integer::operator ++ ()
+{
+  add(*this, 1, *this);
+}
+
+
+inline void  Integer::operator -= (const Integer& y)
+{
+  sub(*this, y, *this);
+}
+
+inline void  Integer::operator -= (long y)
+{
+  sub(*this, y, *this);
+}
+
+inline void Integer::operator -- ()
+{
+  add(*this, -1, *this);
+}
+
+
+
+inline void Integer::operator *= (const Integer& y)
+{
+  mul(*this, y, *this);
+}
+
+inline void Integer::operator *= (long y)
+{
+  mul(*this, y, *this);
+}
+
+
+inline void  Integer::operator &= (const Integer& y)
+{
+  and(*this, y, *this);
+}
+
+inline void  Integer::operator &= (long y)
+{
+  and(*this, y, *this);
+}
+
+inline void  Integer::operator |= (const Integer& y)
+{
+  or(*this, y, *this);
+}
+
+inline void  Integer::operator |= (long y)
+{
+  or(*this, y, *this);
+}
+
+
+inline void  Integer::operator ^= (const Integer& y)
+{
+  xor(*this, y, *this);
+}
+
+inline void  Integer::operator ^= (long y)
+{
+  xor(*this, y, *this);
+}
+
+
+
+inline void Integer::operator /= (const Integer& y)
+{
+  div(*this, y, *this);
+}
+
+inline void Integer::operator /= (long y)
+{
+  div(*this, y, *this);
+}
+
+
+inline void Integer::operator %= (const Integer& y)
+{
+  mod(*this, y, *this);
+}
+
+inline void Integer::operator %= (long y)
+{
+  mod(*this, y, *this);
+}
+
+
+inline void Integer::operator <<= (const Integer&  y)
+{
+  lshift(*this, y, *this);
+}
+
+inline void Integer::operator <<= (long  y)
+{
+  lshift(*this, y, *this);
+}
+
+
+inline void Integer::operator >>= (const Integer&  y)
+{
+  rshift(*this, y, *this);
+}
+
+inline void  Integer::operator >>= (long y)
+{
+  rshift(*this, y, *this);
+}
+
+#ifdef __GNUG__
+inline Integer operator <? (const Integer& x, const Integer& y)
+{
+  return (compare(x.rep, y.rep) <= 0) ? x : y;
+}
+
+inline Integer operator >? (const Integer& x, const Integer& y)
+{
+  return (compare(x.rep, y.rep) >= 0)?  x : y;
+}
+#endif
+
+
+inline void Integer::abs()
+{
+  ::abs(*this, *this);
+}
+
+inline void Integer::negate()
+{
+  ::negate(*this, *this);
+}
+
+
+inline void Integer::complement()
+{
+  ::complement(*this, *this);
+}
+
+
+inline int sign(const Integer& x)
+{
+  return (x.rep->len == 0) ? 0 : ( (x.rep->sgn == 1) ? 1 : -1 );
+}
+
+inline int even(const Integer& y)
+{
+  return y.rep->len == 0 || !(y.rep->s[0] & 1);
+}
+
+inline int odd(const Integer& y)
+{
+  return y.rep->len > 0 && (y.rep->s[0] & 1);
+}
+
+inline char* Itoa(const Integer& y, int base, int width)
+{
+  return Itoa(y.rep, base, width);
+}
+
+
+inline ostream& operator << (ostream& s, const Integer& y)
+{
+  return s << Itoa(y.rep);
+}
+
+inline long lg(const Integer& x) 
+{
+  return lg(x.rep);
+}
+
+// constructive operations 
+
+#if defined(__GNUG__) && !defined(NO_NRV)
+
+inline Integer  operator +  (const Integer& x, const Integer& y) return r
+{
+  add(x, y, r);
+}
+
+inline Integer  operator +  (const Integer& x, long y) return r
+{
+  add(x, y, r);
+}
+
+inline Integer  operator +  (long  x, const Integer& y) return r
+{
+  add(x, y, r);
+}
+
+inline Integer  operator -  (const Integer& x, const Integer& y) return r
+{
+  sub(x, y, r);
+}
+
+inline Integer  operator -  (const Integer& x, long y) return r
+{
+  sub(x, y, r);
+}
+
+inline Integer  operator -  (long  x, const Integer& y) return r
+{
+  sub(x, y, r);
+}
+
+inline Integer  operator *  (const Integer& x, const Integer& y) return r
+{
+  mul(x, y, r);
+}
+
+inline Integer  operator *  (const Integer& x, long y) return r
+{
+  mul(x, y, r);
+}
+
+inline Integer  operator *  (long  x, const Integer& y) return r
+{
+  mul(x, y, r);
+}
+
+inline Integer sqr(const Integer& x) return r
+{
+  mul(x, x, r);
+}
+
+inline Integer  operator &  (const Integer& x, const Integer& y) return r
+{
+  and(x, y, r);
+}
+
+inline Integer  operator &  (const Integer& x, long y) return r
+{
+  and(x, y, r);
+}
+
+inline Integer  operator &  (long  x, const Integer& y) return r
+{
+  and(x, y, r);
+}
+
+inline Integer  operator |  (const Integer& x, const Integer& y) return r
+{
+  or(x, y, r);
+}
+
+inline Integer  operator |  (const Integer& x, long y) return r
+{
+  or(x, y, r);
+}
+
+inline Integer  operator |  (long  x, const Integer& y) return r
+{
+  or(x, y, r);
+}
+
+inline Integer  operator ^  (const Integer& x, const Integer& y) return r
+{
+  xor(x, y, r);
+}
+
+inline Integer  operator ^  (const Integer& x, long y) return r
+{
+  xor(x, y, r);
+}
+
+inline Integer  operator ^  (long  x, const Integer& y) return r
+{
+  xor(x, y, r);
+}
+
+inline Integer  operator /  (const Integer& x, const Integer& y) return r
+{
+  div(x, y, r);
+}
+
+inline Integer operator /  (const Integer& x, long y) return r
+{
+  div(x, y, r);
+}
+
+inline Integer operator %  (const Integer& x, const Integer& y) return r
+{
+  mod(x, y, r);
+}
+
+inline Integer operator %  (const Integer& x, long y) return r
+{
+  mod(x, y, r);
+}
+
+inline Integer operator <<  (const Integer& x, const Integer& y) return r
+{
+  lshift(x, y, r);
+}
+
+inline Integer operator <<  (const Integer& x, long y) return r
+{
+  lshift(x, y, r);
+}
+
+inline Integer operator >>  (const Integer& x, const Integer& y) return r;
+{
+  rshift(x, y, r);
+}
+
+inline Integer operator >>  (const Integer& x, long y) return r
+{
+  rshift(x, y, r);
+}
+
+inline Integer pow(const Integer& x, long y) return r
+{
+  pow(x, y, r);
+}
+
+inline Integer Ipow(long x, long y) return r(x)
+{
+  pow(r, y, r);
+}
+
+inline Integer pow(const Integer& x, const Integer& y) return r
+{
+  pow(x, y, r);
+}
+
+
+
+inline Integer abs(const Integer& x) return r
+{
+  abs(x, r);
+}
+
+inline Integer operator - (const Integer& x) return r
+{
+  negate(x, r);
+}
+
+inline Integer operator ~ (const Integer& x) return r
+{
+  complement(x, r);
+}
+
+inline Integer  atoI(const char* s, int base) return r
+{
+  r.rep = atoIntRep(s, base);
+}
+
+inline Integer  gcd(const Integer& x, const Integer& y) return r
+{
+  r.rep = gcd(x.rep, y.rep);
+}
+
+#else /* NO_NRV */
+
+inline Integer  operator +  (const Integer& x, const Integer& y) 
+{
+  Integer r; add(x, y, r); return r;
+}
+
+inline Integer  operator +  (const Integer& x, long y) 
+{
+  Integer r; add(x, y, r); return r;
+}
+
+inline Integer  operator +  (long  x, const Integer& y) 
+{
+  Integer r; add(x, y, r); return r;
+}
+
+inline Integer  operator -  (const Integer& x, const Integer& y) 
+{
+  Integer r; sub(x, y, r); return r;
+}
+
+inline Integer  operator -  (const Integer& x, long y) 
+{
+  Integer r; sub(x, y, r); return r;
+}
+
+inline Integer  operator -  (long  x, const Integer& y) 
+{
+  Integer r; sub(x, y, r); return r;
+}
+
+inline Integer  operator *  (const Integer& x, const Integer& y) 
+{
+  Integer r; mul(x, y, r); return r;
+}
+
+inline Integer  operator *  (const Integer& x, long y) 
+{
+  Integer r; mul(x, y, r); return r;
+}
+
+inline Integer  operator *  (long  x, const Integer& y) 
+{
+  Integer r; mul(x, y, r); return r;
+}
+
+inline Integer sqr(const Integer& x) 
+{
+  Integer r; mul(x, x, r); return r;
+}
+
+inline Integer  operator &  (const Integer& x, const Integer& y) 
+{
+  Integer r; and(x, y, r); return r;
+}
+
+inline Integer  operator &  (const Integer& x, long y) 
+{
+  Integer r; and(x, y, r); return r;
+}
+
+inline Integer  operator &  (long  x, const Integer& y) 
+{
+  Integer r; and(x, y, r); return r;
+}
+
+inline Integer  operator |  (const Integer& x, const Integer& y) 
+{
+  Integer r; or(x, y, r); return r;
+}
+
+inline Integer  operator |  (const Integer& x, long y) 
+{
+  Integer r; or(x, y, r); return r;
+}
+
+inline Integer  operator |  (long  x, const Integer& y) 
+{
+  Integer r; or(x, y, r); return r;
+}
+
+inline Integer  operator ^  (const Integer& x, const Integer& y) 
+{
+  Integer r; xor(x, y, r); return r;
+}
+
+inline Integer  operator ^  (const Integer& x, long y) 
+{
+  Integer r; xor(x, y, r); return r;
+}
+
+inline Integer  operator ^  (long  x, const Integer& y) 
+{
+  Integer r; xor(x, y, r); return r;
+}
+
+inline Integer  operator /  (const Integer& x, const Integer& y) 
+{
+  Integer r; div(x, y, r); return r;
+}
+
+inline Integer operator /  (const Integer& x, long y) 
+{
+  Integer r; div(x, y, r); return r;
+}
+
+inline Integer operator %  (const Integer& x, const Integer& y) 
+{
+  Integer r; mod(x, y, r); return r;
+}
+
+inline Integer operator %  (const Integer& x, long y) 
+{
+  Integer r; mod(x, y, r); return r;
+}
+
+inline Integer operator <<  (const Integer& x, const Integer& y) 
+{
+  Integer r; lshift(x, y, r); return r;
+}
+
+inline Integer operator <<  (const Integer& x, long y) 
+{
+  Integer r; lshift(x, y, r); return r;
+}
+
+inline Integer operator >>  (const Integer& x, const Integer& y) 
+{
+  Integer r; rshift(x, y, r); return r;
+}
+
+inline Integer operator >>  (const Integer& x, long y) 
+{
+  Integer r; rshift(x, y, r); return r;
+}
+
+inline Integer pow(const Integer& x, long y) 
+{
+  Integer r; pow(x, y, r); return r;
+}
+
+inline Integer Ipow(long x, long y) 
+{
+  Integer r(x); pow(r, y, r); return r;
+}
+
+inline Integer pow(const Integer& x, const Integer& y) 
+{
+  Integer r; pow(x, y, r); return r;
+}
+
+
+
+inline Integer abs(const Integer& x) 
+{
+  Integer r; abs(x, r); return r;
+}
+
+inline Integer operator - (const Integer& x) 
+{
+  Integer r; negate(x, r); return r;
+}
+
+inline Integer operator ~ (const Integer& x) 
+{
+  Integer r; complement(x, r); return r;
+}
+
+inline Integer  atoI(const char* s, int base) 
+{
+  Integer r; r.rep = atoIntRep(s, base); return r;
+}
+
+inline Integer  gcd(const Integer& x, const Integer& y) 
+{
+  Integer r; r.rep = gcd(x.rep, y.rep); return r;
+}
+
+#endif
+#endif
+#endif
diff --git a/usr/include/g++/LogNorm.h b/usr/include/g++/LogNorm.h
new file mode 100644 (file)
index 0000000..6c7c74c
--- /dev/null
@@ -0,0 +1,84 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _LogNormal_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _LogNormal_h 
+
+#include "Normal.h"
+
+class LogNormal: public Normal {
+protected:
+    double logMean;
+    double logVariance;
+    void setState();
+public:
+    LogNormal(double mean, double variance, RNG *gen);
+    double mean();
+    double mean(double x);
+    double variance();
+    double variance(double x);
+    virtual double operator()();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline void LogNormal::setState()
+{
+    double m2 = logMean * logMean;
+    pMean = log(m2 / sqrt(logVariance + m2) );
+    pVariance = log((sqrt(logVariance + m2)/m2 ));
+}
+
+inline LogNormal::LogNormal(double mean, double variance, RNG *gen)
+    : (mean, variance, gen)
+{
+    logMean = mean;
+    logVariance = variance;
+    setState();
+}
+
+inline double LogNormal::mean() {
+    return logMean;
+}
+
+inline double LogNormal::mean(double x)
+{
+    double t=logMean; logMean = x; setState();
+    return t;
+}
+
+inline double LogNormal::variance() {
+    return logVariance;
+}
+
+inline double LogNormal::variance(double x)
+{
+    double t=logVariance; logVariance = x; setState();
+    return t;
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/MLCG.h b/usr/include/g++/MLCG.h
new file mode 100644 (file)
index 0000000..73791f0
--- /dev/null
@@ -0,0 +1,97 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _MLCG_h
+#define _MLCG_h 1 
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+
+#include <RNG.h>
+#include <math.h>
+
+//
+//     Multiplicative Linear Conguential Generator
+//
+
+class MLCG : public RNG {
+    long initialSeedOne;
+    long initialSeedTwo;
+    long seedOne;
+    long seedTwo;
+
+protected:
+
+public:
+    MLCG(long seed1 = 0, long seed2 = 1);
+    //
+    // Return a long-words word of random bits
+    //
+    virtual unsigned long asLong();
+    virtual void reset();
+    long seed1();
+    void seed1(long);
+    long seed2();
+    void seed2(long);
+    void reseed(long, long);
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline long
+MLCG::seed1()
+{
+    return(seedOne);
+}
+
+inline void
+MLCG::seed1(long s)
+{
+    initialSeedOne = s;
+    reset();
+}
+
+inline long
+MLCG::seed2()
+{
+    return(seedTwo);
+}
+
+inline void
+MLCG::seed2(long s)
+{
+    initialSeedTwo = s;
+    reset();
+}
+
+inline void
+MLCG::reseed(long s1, long s2)
+{
+    initialSeedOne = s1;
+    initialSeedTwo = s2;
+    reset();
+}
+
+#endif
+
+#endif
diff --git a/usr/include/g++/NegExp.h b/usr/include/g++/NegExp.h
new file mode 100644 (file)
index 0000000..21a1a18
--- /dev/null
@@ -0,0 +1,63 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _NegativeExpntl_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _NegativeExpntl_h 1
+
+
+//
+//     Negative Exponential Random Numbers
+//
+// 
+
+#include <Random.h>
+
+class NegativeExpntl: public Random {
+protected:
+    double pMean;
+public:
+    NegativeExpntl(double xmean, RNG *gen);
+    double mean();
+    double mean(double x);
+
+    virtual double operator()();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline NegativeExpntl::NegativeExpntl(double xmean, RNG *gen)
+: (gen) {
+  pMean = xmean;
+}
+
+inline double NegativeExpntl::mean() { return pMean; }
+inline double NegativeExpntl::mean(double x) {
+  double t = pMean; pMean = x;
+  return t;
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/Normal.h b/usr/include/g++/Normal.h
new file mode 100644 (file)
index 0000000..b8a209e
--- /dev/null
@@ -0,0 +1,74 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _Normal_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Normal_h 
+
+#include <Random.h>
+
+class Normal: public Random {
+    char haveCachedNormal;
+    double cachedNormal;
+
+protected:
+    double pMean;
+    double pVariance;
+    double pStdDev;
+    
+public:
+    Normal(double xmean, double xvariance, RNG *gen);
+    double mean();
+    double mean(double x);
+    double variance();
+    double variance(double x);
+    virtual double operator()();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline Normal::Normal(double xmean, double xvariance, RNG *gen)
+: (gen) {
+  pMean = xmean;
+  pVariance = xvariance;
+  pStdDev = sqrt(pVariance);
+  haveCachedNormal = 0;
+}
+
+inline double Normal::mean() { return pMean; };
+inline double Normal::mean(double x) {
+  double t=pMean; pMean = x;
+  return t;
+}
+
+inline double Normal::variance() { return pVariance; }
+inline double Normal::variance(double x) {
+  double t=pVariance; pVariance = x;
+  pStdDev = sqrt(pVariance);
+  return t;
+};
+
+#endif
+#endif
diff --git a/usr/include/g++/Obstack.h b/usr/include/g++/Obstack.h
new file mode 100644 (file)
index 0000000..0cc2e9b
--- /dev/null
@@ -0,0 +1,226 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _Obstack_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Obstack_h 1
+
+#include <std.h>
+
+class Obstack
+{
+  struct _obstack_chunk
+  {
+    char*           limit;
+    _obstack_chunk* prev;
+    char            contents[4];
+  };
+
+protected:
+  long           chunksize;
+  _obstack_chunk* chunk;
+  char*                  objectbase;
+  char*                  nextfree;
+  char*                  chunklimit;
+  int             alignmentmask;
+
+  void  _free(void* obj);
+  void  newchunk(int size);
+
+public:
+        Obstack(int size = 4080, int alignment = 4); // 4080=4096-mallocslop
+
+        ~Obstack();
+
+  void* base();
+  void* next_free();
+  int   alignment_mask();
+  int   chunk_size();
+  int   size();
+  int   room();
+  int   contains(void* p);      // does Obstack hold pointer p?
+
+  void  grow(const void* data, int size);
+  void  grow(const void* data, int size, char terminator);
+  void  grow(const char* s);
+  void  grow(char c);
+  void  grow_fast(char c);
+  void  blank(int size);
+  void  blank_fast(int size);
+
+  void* finish();
+  void* finish(char terminator);
+
+  void* copy(const void* data, int size);
+  void* copy(const void* data, int size, char terminator);
+  void* copy(const char* s);
+  void* copy(char c);
+  void* alloc(int size);
+
+  void  free(void* obj);
+  void  shrink(int size = 1); // suggested by ken@cs.rochester.edu
+
+  int   OK();                   // rep invariant
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+
+inline Obstack::~Obstack()
+{
+  _free(0); 
+}
+
+inline void* Obstack::base()
+{
+  return objectbase; 
+}
+
+inline void* Obstack::next_free()
+{
+  return nextfree; 
+}
+
+inline int Obstack::alignment_mask()
+{
+  return alignmentmask; 
+}
+
+inline int Obstack::chunk_size()
+{
+  return chunksize; 
+}
+
+inline int Obstack::size()
+{
+  return nextfree - objectbase; 
+}
+
+inline int Obstack::room()
+{
+  return chunklimit - nextfree; 
+}
+
+inline void Obstack:: grow(const void* data, int size)
+{
+  if (nextfree+size > chunklimit) 
+    newchunk(size);
+  bcopy(data, nextfree, size);
+  nextfree += size; 
+}
+
+inline void Obstack:: grow(const void* data, int size, char terminator)
+{
+  if (nextfree+size+1 > chunklimit) 
+    newchunk(size+1);
+  bcopy(data, nextfree, size);
+  nextfree += size; 
+  *(nextfree)++ = terminator; 
+}
+
+inline void Obstack:: grow(const char* s)
+{
+  grow((void*)s, strlen(s), 0); 
+}
+
+inline void Obstack:: grow(char c)
+{
+  if (nextfree+1 > chunklimit) 
+    newchunk(1); 
+  *(nextfree)++ = c; 
+}
+
+inline void Obstack:: blank(int size)
+{
+  if (nextfree+size > chunklimit) 
+    newchunk(size);
+  nextfree += size; 
+}
+
+inline void* Obstack::finish(char terminator)
+{
+  grow(terminator); 
+  return finish(); 
+}
+
+inline void* Obstack::copy(const void* data, int size)
+{
+  grow (data, size);
+  return finish(); 
+}
+
+inline void* Obstack::copy(const void* data, int size, char terminator)
+{
+  grow(data, size, terminator); 
+  return finish(); 
+}
+
+inline void* Obstack::copy(const char* s)
+{
+  grow((void*)s, strlen(s), 0); 
+  return finish(); 
+}
+
+inline void* Obstack::copy(char c)
+{
+  grow(c);
+  return finish(); 
+}
+
+inline void* Obstack::alloc(int size)
+{
+  blank(size);
+  return finish(); 
+}
+
+inline void Obstack:: free(void* obj)     
+{
+  if (obj >= (void*)chunk && obj<(void*)chunklimit)
+    nextfree = objectbase = (char *) obj;
+  else 
+    _free(obj); 
+}
+
+inline void Obstack:: grow_fast(char c)
+{
+  *(nextfree)++ = c; 
+}
+
+inline void Obstack:: blank_fast(int size)
+{
+  nextfree += size; 
+}
+
+inline void Obstack:: shrink(int size) // from ken@cs.rochester.edu
+{
+  if (nextfree >= objectbase + size)
+    nextfree -= size;
+}
+
+#endif
+
+#endif
diff --git a/usr/include/g++/Pix.h b/usr/include/g++/Pix.h
new file mode 100644 (file)
index 0000000..0e08796
--- /dev/null
@@ -0,0 +1,9 @@
+
+#ifndef _Pix_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Pix_h 1
+typedef void* Pix;
+#endif
diff --git a/usr/include/g++/PlotFile.h b/usr/include/g++/PlotFile.h
new file mode 100644 (file)
index 0000000..1a69396
--- /dev/null
@@ -0,0 +1,154 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+/* 
+   a very simple implementation of a class to output unix "plot"
+   format plotter files. See corresponding unix man pages for
+   more details. 
+*/
+
+#ifndef _PlotFile_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _PlotFile_h
+
+#include <File.h>
+
+/*   
+   Some plot libraries have the `box' command to draw boxes. Some don't.
+   `box' is included here via moves & lines to allow both possiblilties.
+*/
+
+
+class PlotFile : private File
+{
+protected:
+  PlotFile& cmd(char c);
+  PlotFile& operator << (const int x);
+  PlotFile& operator << (const char *s);
+  
+public:
+  
+  PlotFile();
+  PlotFile(const char* filename, io_mode m, access_mode a);
+  PlotFile(const char* filename, const char* m);
+  PlotFile(int filedesc, const io_mode m = io_writeonly);
+  PlotFile(FILE* fileptr);
+  
+  ~PlotFile();
+  
+  operator void*();
+  
+  PlotFile& close() { File::close(); return *this; }
+  PlotFile& remove() { File::remove(); return *this; }
+  
+  int           filedesc() { return File::filedesc(); }
+  const char*   name() { return File::name(); }
+  void          setname(const char* newname) { File::setname(newname); }
+  int           iocount() { return File::iocount(); }
+  
+  int           rdstate() { return File::rdstate(); }
+  int           eof() { return File::eof(); }
+  int           fail() { return File::fail(); }
+  int           bad() { return File::bad(); }
+  int           good() { return File::good(); }
+  
+  // other status queries
+  
+  int           readable() { return File::readable(); }
+  int           writable() { return File::writable(); }
+  int           is_open() { return File::is_open(); }
+  
+  void          error() {  File::error(); }
+  void          clear(state_value f = _good) {  File::clear(f); }
+  void          set(state_value f) { File::set(f); }
+  void          unset(state_value f) { File::unset(f); }
+  PlotFile&     failif(int cond) {  File::failif(cond); return *this; }
+  void          check_state() { File::check_state(); }
+  
+  PlotFile&     raw() { File::raw(); return *this; }
+  
+  PlotFile& open(const char* filename, io_mode m, access_mode a);
+  PlotFile& open(const char* filename, const char* m);
+  PlotFile& open(int  filedesc,  io_mode m);
+  PlotFile& open(FILE* fileptr);
+  PlotFile& setbuf(const int buffer_kind); // vals: _IONBF, _IOFBF, _IOLBF
+  PlotFile& setbuf(const int size, char* buf);
+  
+  PlotFile& arc(const int xi, const int yi,
+                const int x0, const int y0,
+                const int x1, const int y1);
+  PlotFile& box(const int x0, const int y0,
+                const int x1, const int y1);
+  PlotFile& circle(const int x, const int y, const int r);
+  PlotFile& cont(const int xi, const int yi);
+  PlotFile& dot(const int xi, const int yi, const int dx,
+                int n, const int* pat);
+  PlotFile& erase(); 
+  PlotFile& label(const char* s);
+  PlotFile& line(const int x0, const int y0,
+                 const int x1, const int y1);
+  PlotFile& linemod(const char* s);
+  PlotFile& move(const int xi, const int yi);
+  PlotFile& point(const int xi, const int yi);
+  PlotFile& space(const int x0, const int y0,
+                  const int x1, const int y1);
+};
+
+
+#endif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/usr/include/g++/Poisson.h b/usr/include/g++/Poisson.h
new file mode 100644 (file)
index 0000000..aaac6e7
--- /dev/null
@@ -0,0 +1,60 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _Poisson_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Poisson_h 
+
+#include <Random.h>
+
+class Poisson: public Random {
+protected:
+    double pMean;
+public:
+    Poisson(double mean, RNG *gen);
+
+    double mean();
+    double mean(double x);
+
+    virtual double operator()();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline Poisson::Poisson(double mean, RNG *gen)
+: (gen) {
+  pMean = mean;
+}
+
+inline double Poisson::mean() { return pMean; }
+inline double Poisson::mean(double x) {
+  double t = pMean;
+  pMean = x;
+  return t;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/RNG.h b/usr/include/g++/RNG.h
new file mode 100644 (file)
index 0000000..414b57f
--- /dev/null
@@ -0,0 +1,88 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _RNG_h
+#define _RNG_h 1
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+
+#include <assert.h>
+#include <math.h>
+
+union PrivateRNGSingleType {                   // used to access floats as unsigneds
+    float s;
+    unsigned long u;
+};
+
+union PrivateRNGDoubleType {                   // used to access doubles as unsigneds
+    double d;
+    unsigned long u[2];
+};
+
+//
+// Base class for Random Number Generators. See ACG and MLCG for instances.
+//
+class RNG {
+    static PrivateRNGSingleType singleMantissa;        // mantissa bit vector
+    static PrivateRNGDoubleType doubleMantissa;        // mantissa bit vector
+public:
+    RNG();
+    //
+    // Return a long-words word of random bits
+    //
+    virtual unsigned long asLong() = 0;
+    virtual void reset() = 0;
+    //
+    // Return random bits converted to either a float or a double
+    //
+    float asFloat();
+    double asDouble();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+
+inline float RNG::asFloat()
+{
+    PrivateRNGSingleType result;
+    result.s = 1.0;
+    result.u |= (asLong() & singleMantissa.u);
+    result.s -= 1.0;
+    assert( result.s < 1.0 && result.s >= 0);
+    return( result.s );
+}
+       
+inline double RNG::asDouble()
+{
+    PrivateRNGDoubleType result;
+    result.d = 1.0;
+    result.u[0] |= (asLong() & doubleMantissa.u[0]);
+    result.u[1] |= (asLong() & doubleMantissa.u[1]);
+    result.d -= 1.0;
+    assert( result.d < 1.0 && result.d >= 0);
+    return( result.d );
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/Random.h b/usr/include/g++/Random.h
new file mode 100644 (file)
index 0000000..94efa09
--- /dev/null
@@ -0,0 +1,67 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _Random_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Random_h 1
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+
+#include <math.h>
+#include "RNG.h"
+
+class Random {
+protected:
+    RNG *pGenerator;
+public:
+    Random(RNG *generator);
+    virtual double operator()() = 0;
+
+    RNG *generator();
+    void generator(RNG *p);
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline Random::Random(RNG *gen)
+{
+    pGenerator = gen;
+}
+
+inline RNG *Random::generator()
+{
+    return(pGenerator);
+}
+
+inline void Random::generator(RNG *p)
+{
+    pGenerator = p;
+}
+
+#endif
+
+#endif
diff --git a/usr/include/g++/Rational.h b/usr/include/g++/Rational.h
new file mode 100644 (file)
index 0000000..3e7e35f
--- /dev/null
@@ -0,0 +1,270 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _Rational_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Rational_h 1
+
+#include <Integer.h>
+#include <math.h>
+
+class Rational
+{
+protected:
+  Integer          num;
+  Integer          den;
+
+  void             normalize();
+
+public:
+                   Rational();
+                   Rational(double);
+                   Rational(long n, long d = 1);
+                   Rational(const Integer& n);
+                   Rational(const Integer& n, const Integer& d);
+                   Rational(const Rational&);
+
+                  ~Rational();
+
+  void             operator =  (const Rational& y);
+
+  friend int       operator == (const Rational& x, const Rational& y);
+  friend int       operator != (const Rational& x, const Rational& y);
+  friend int       operator <  (const Rational& x, const Rational& y);
+  friend int       operator <= (const Rational& x, const Rational& y);
+  friend int       operator >  (const Rational& x, const Rational& y);
+  friend int       operator >= (const Rational& x, const Rational& y);
+
+  friend Rational  operator +  (const Rational& x, const Rational& y);
+  friend Rational  operator -  (const Rational& x, const Rational& y);
+  friend Rational  operator *  (const Rational& x, const Rational& y);
+  friend Rational  operator /  (const Rational& x, const Rational& y);
+
+  void             operator += (const Rational& y);
+  void             operator -= (const Rational& y);
+  void             operator *= (const Rational& y);
+  void             operator /= (const Rational& y);
+
+#ifdef __GNUG__
+  friend Rational  operator <? (const Rational& x, const Rational& y); // min
+  friend Rational  operator >? (const Rational& x, const Rational& y); // max
+#endif
+
+  friend Rational  operator - (const Rational& x);
+
+
+// builtin Rational functions
+
+
+  void             negate();                      // x = -x
+  void             invert();                      // x = 1/x
+
+  friend int       sign(const Rational& x);             // -1, 0, or +1
+  friend Rational  abs(const Rational& x);              // absolute value
+  friend Rational  sqr(const Rational& x);              // square
+  friend Rational  pow(const Rational& x, long y);
+  friend Rational  pow(const Rational& x, Integer& y);
+  const Integer&   numerator() const;
+  const Integer&   denominator() const;
+
+// coercion & conversion
+
+                   operator double() const;
+  friend Integer   floor(const Rational& x);
+  friend Integer   ceil(const Rational& x);
+  friend Integer   trunc(const Rational& x);
+  friend Integer   round(const Rational& x);
+
+  friend istream&  operator >> (istream& s, Rational& y);
+  friend ostream&  operator << (ostream& s, const Rational& y);
+
+
+// procedural versions of operators
+
+  friend int       compare(const Rational& x, const Rational& y);
+  friend void      add(const Rational& x, const Rational& y, Rational& dest);
+  friend void      sub(const Rational& x, const Rational& y, Rational& dest);
+  friend void      mul(const Rational& x, const Rational& y, Rational& dest);
+  friend void      div(const Rational& x, const Rational& y, Rational& dest);
+
+// error detection
+
+  volatile void    error(const char* msg) const;
+  int              OK() const;
+
+};
+
+typedef Rational RatTmp; // backwards compatibility
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline Rational::Rational()  {}
+inline Rational::~Rational() {}
+
+inline Rational::Rational(const Rational& y) :num(y.num), den(y.den) {}
+
+inline Rational::Rational(const Integer& n) :num(n), den(1) {}
+
+inline Rational::Rational(const Integer& n, const Integer& d) :num(n),den(d)
+{
+  normalize();
+}
+
+inline Rational::Rational(long n, long d) :num(n), den(d)
+{
+  normalize();
+}
+
+inline  void Rational::operator =  (const Rational& y)
+{
+  num = y.num;  den = y.den;
+}
+
+inline int operator == (const Rational& x, const Rational& y)
+{
+  return compare(x.num, y.num) == 0 && compare(x.den, y.den) == 0;
+}
+
+inline int operator != (const Rational& x, const Rational& y)
+{
+  return compare(x.num, y.num) != 0 || compare(x.den, y.den) != 0;
+}
+
+inline int operator <  (const Rational& x, const Rational& y)
+{
+  return compare(x, y) <  0; 
+}
+
+inline int operator <= (const Rational& x, const Rational& y)
+{
+  return compare(x, y) <= 0; 
+}
+
+inline int operator >  (const Rational& x, const Rational& y)
+{
+  return compare(x, y) >  0; 
+}
+
+inline int operator >= (const Rational& x, const Rational& y)
+{
+  return compare(x, y) >= 0; 
+}
+
+inline int sign(const Rational& x)
+{
+  return sign(x.num);
+}
+
+inline void Rational::negate()
+{
+  num.negate();
+}
+
+
+inline void Rational::operator += (const Rational& y) 
+{
+  add(*this, y, *this);
+}
+
+inline void Rational::operator -= (const Rational& y) 
+{
+  sub(*this, y, *this);
+}
+
+inline void Rational::operator *= (const Rational& y) 
+{
+  mul(*this, y, *this);
+}
+
+inline void Rational::operator /= (const Rational& y) 
+{
+  div(*this, y, *this);
+}
+
+inline const Integer& Rational::numerator() const { return num; }
+inline const Integer& Rational::denominator() const { return den; }
+inline Rational::operator double() const { return ratio(num, den); }
+
+#ifdef __GNUG__
+inline Rational operator <? (const Rational& x, const Rational& y)
+{
+  if (compare(x, y) <= 0) return x; else return y;
+}
+
+inline Rational operator >? (const Rational& x, const Rational& y)
+{
+  if (compare(x, y) >= 0) return x; else return y;
+}
+#endif
+
+#if defined(__GNUG__) && !defined(NO_NRV)
+
+inline Rational operator + (const Rational& x, const Rational& y) return r
+{
+  add(x, y, r);
+}
+
+inline Rational operator - (const Rational& x, const Rational& y) return r
+{
+  sub(x, y, r);
+}
+
+inline Rational operator * (const Rational& x, const Rational& y) return r
+{
+  mul(x, y, r);
+}
+
+inline Rational operator / (const Rational& x, const Rational& y) return r
+{
+  div(x, y, r);
+}
+
+#else /* NO_NRV */
+
+inline Rational operator + (const Rational& x, const Rational& y) 
+{
+  Rational r; add(x, y, r); return r;
+}
+
+inline Rational operator - (const Rational& x, const Rational& y)
+{
+  Rational r; sub(x, y, r); return r;
+}
+
+inline Rational operator * (const Rational& x, const Rational& y)
+{
+  Rational r; mul(x, y, r); return r;
+}
+
+inline Rational operator / (const Rational& x, const Rational& y)
+{
+  Rational r; div(x, y, r); return r;
+}
+#endif
+#endif
+
+#endif
diff --git a/usr/include/g++/Regex.h b/usr/include/g++/Regex.h
new file mode 100644 (file)
index 0000000..d0cff26
--- /dev/null
@@ -0,0 +1,76 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _Regex_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Regex_h 1
+
+struct re_pattern_buffer;       // defined elsewhere
+struct re_registers;
+
+class Regex
+{
+private:
+
+                     Regex(const Regex&) {}  // no X(X&)
+  void               operator = (const Regex&) {} // no assignment
+
+protected:
+  re_pattern_buffer* buf;
+  re_registers*      reg;
+
+public:
+                     Regex(const char* t, 
+                           int fast = 0, 
+                           int bufsize = 40, 
+                           const char* transtable = 0);
+
+                    ~Regex();
+
+  int                match(const char* s, int len, int pos = 0) const;
+  int                search(const char* s, int len, 
+                            int& matchlen, int startpos = 0) const;
+  int                match_info(int& start, int& length, int nth = 0) const;
+
+  int                OK() const;  // representation invariant
+};
+
+// some built in regular expressions
+
+extern const Regex RXwhite;          // = "[ \n\t\r\v\f]+"
+extern const Regex RXint;            // = "-?[0-9]+"
+extern const Regex RXdouble;         // = "-?\\(\\([0-9]+\\.[0-9]*\\)\\|
+                                     //    \\([0-9]+\\)\\|\\(\\.[0-9]+\\)\\)
+                                     //    \\([eE][---+]?[0-9]+\\)?"
+extern const Regex RXalpha;          // = "[A-Za-z]+"
+extern const Regex RXlowercase;      // = "[a-z]+"
+extern const Regex RXuppercase;      // = "[A-Z]+"
+extern const Regex RXalphanum;       // = "[0-9A-Za-z]+"
+extern const Regex RXidentifier;     // = "[A-Za-z_][A-Za-z0-9_]*"
+
+
+#endif
diff --git a/usr/include/g++/RndInt.h b/usr/include/g++/RndInt.h
new file mode 100644 (file)
index 0000000..f674796
--- /dev/null
@@ -0,0 +1,169 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1990 Free Software Foundation
+    adapted from a submission from John Reidl <riedl@cs.purdue.edu>
+
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _RandomInteger_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _RandomInteger_h 1
+
+// RandomInteger uses a random number generator to generate an integer
+// in a specified range.  By default the range is 0..1.  Since in my
+// experience random numbers are often needed for a wide variety of
+// ranges in the same program, this generator accepts a new low or high value
+// as an argument to the asLong and operator() methods to temporarily 
+// override stored values
+
+#include <math.h>
+#include "RNG.h"
+
+class RandomInteger 
+{
+ protected:
+  RNG *pGenerator;
+  long pLow;
+  long pHigh;
+
+  long _asLong(long, long);
+
+ public:
+
+       RandomInteger(long low, long high, RNG *gen);
+       RandomInteger(long high, RNG *gen);
+       RandomInteger(RNG *gen);
+
+// read params
+
+  long low() const;
+  long high() const;
+  RNG* generator() const;
+
+// change params
+
+  long low(long x);
+  long high(long x);
+  RNG* generator(RNG *gen);
+
+// get a random number
+
+  long asLong();
+  long operator()(); // synonym for asLong
+  int  asInt();      // (possibly) truncate as int
+
+// override params for one shot
+
+  long asLong(long high);
+  long asLong(long low, long high);
+
+  long operator () (long high);  // synonyms
+  long operator () (long low, long high);
+
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline RandomInteger::RandomInteger(long low, long high, RNG *gen) 
+     : pLow((low < high) ? low : high),
+       pHigh((low < high) ? high : low),
+       pGenerator(gen)
+{}
+
+inline RandomInteger::RandomInteger(long high, RNG *gen) 
+     : pLow((0 < high) ? 0 : high),
+       pHigh((0 < high) ? high : 0),
+       pGenerator(gen)
+{}
+  
+
+inline RandomInteger::RandomInteger(RNG *gen) 
+     : pLow(0),
+       pHigh(1),
+       pGenerator(gen)
+{}
+
+inline RNG* RandomInteger::generator() const { return pGenerator;}
+inline long RandomInteger::low() const       { return pLow; }
+inline long RandomInteger::high() const      { return pHigh; }
+
+inline RNG* RandomInteger::generator(RNG *gen) 
+{
+  RNG *tmp = pGenerator; pGenerator = gen;  return tmp;
+}
+
+inline long RandomInteger::low(long x)  
+{
+  long tmp = pLow;  pLow = x;  return tmp;
+}
+
+inline long RandomInteger:: high(long x) 
+{
+  long tmp = pHigh; pHigh = x; return tmp;
+}
+
+inline long RandomInteger:: _asLong(long low, long high)
+{      
+  return (pGenerator->asLong() % (high-low+1)) + low;
+}
+
+
+inline long RandomInteger:: asLong() 
+{
+  return _asLong(pLow, pHigh);
+}
+
+inline long RandomInteger:: asLong(long high)
+{
+  return _asLong(pLow, high);
+}
+
+inline long RandomInteger:: asLong(long low, long high)
+{
+  return _asLong(low, high);
+}
+
+inline long RandomInteger:: operator () () 
+{
+  return _asLong(pLow, pHigh);
+}
+
+inline long RandomInteger:: operator () (long high)
+{
+  return _asLong(pLow, high);
+}
+
+inline long RandomInteger:: operator () (long low, long high)
+{
+  return _asLong(low, high);
+}
+
+
+
+
+inline int RandomInteger:: asInt() 
+{
+  return int(asLong());
+}
+
+#endif
+
+#endif
diff --git a/usr/include/g++/SFile.h b/usr/include/g++/SFile.h
new file mode 100644 (file)
index 0000000..598078e
--- /dev/null
@@ -0,0 +1,88 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _SFile_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _SFile_h 1
+
+#include <File.h>
+
+class SFile: public File
+{
+protected:
+  int       sz;                   // unit size for structured binary IO
+
+public:
+            SFile();
+            SFile(const char* filename, int size, io_mode m, access_mode a);
+            SFile(const char* filename, int size, const char* m);
+            SFile(int filedesc, int size, io_mode m);
+            SFile(FILE* fileptr,  int size);
+
+            ~SFile();
+
+  int       size();
+  int       setsize(int s);
+
+  SFile&    get(void* x);
+  SFile&    put(void* x);
+  SFile&    operator[](long i);
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+
+inline  int SFile::size()
+{ 
+  return sz; 
+}          
+
+inline  int SFile::setsize(int s)
+{ 
+  int old = sz; 
+  sz = s;  
+  return old; 
+}
+
+inline  SFile& SFile::get(void* x)
+{ 
+  read(x, sz, 1);  return *this; 
+}
+
+inline  SFile& SFile::put(void* x)
+{ 
+  write(x, sz, 1);  return *this; 
+}
+
+inline SFile&  SFile::operator[](long i)
+{ 
+  seek(i * sz, 0);  return *this; 
+}
+
+
+#endif
+
+#endif
diff --git a/usr/include/g++/SmplHist.h b/usr/include/g++/SmplHist.h
new file mode 100644 (file)
index 0000000..ed1fb5d
--- /dev/null
@@ -0,0 +1,82 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef SampleHistogram_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define SampleHistogram_h 1
+
+#include <stream.h>
+#include <SmplStat.h>
+
+extern const int SampleHistogramMinimum;
+extern const int SampleHistogramMaximum;
+
+class SampleHistogram : public SampleStatistic 
+{
+protected:
+    short howManyBuckets;
+    int *bucketCount;
+    double *bucketLimit;
+
+public:
+    
+    SampleHistogram(double low, double hi, double bucketWidth = -1.0);
+
+    ~SampleHistogram();
+
+    virtual void reset();
+    virtual void operator+=(double);
+
+    int similarSamples(double);
+
+    int buckets();
+
+    double bucketThreshold(int i);
+    int inBucket(int i);
+    void printBuckets(ostream&);
+
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+    inline int SampleHistogram:: buckets() { return(howManyBuckets); };
+
+    inline double SampleHistogram:: bucketThreshold(int i) {
+      if (i < 0 || i >= howManyBuckets)
+        error("invalid bucket access");
+       return(bucketLimit[i]);
+    }
+
+    inline int SampleHistogram:: inBucket(int i) {
+      if (i < 0 || i >= howManyBuckets)
+        error("invalid bucket access");
+       return(bucketCount[i]);
+    }
+
+
+#endif
+
+#endif
diff --git a/usr/include/g++/SmplStat.h b/usr/include/g++/SmplStat.h
new file mode 100644 (file)
index 0000000..6aea14a
--- /dev/null
@@ -0,0 +1,73 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef SampleStatistic_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define SampleStatistic_h 1
+
+#include <builtin.h>
+
+class SampleStatistic {
+protected:
+    int        n;
+    double x;
+    double x2;
+    double minValue, maxValue;
+
+    public :
+
+    SampleStatistic();
+    virtual void reset(); 
+
+    virtual void operator+=(double);
+    int  samples();
+    double mean();
+    double stdDev();
+    double var();
+    double min();
+    double max();
+    double confidence(int p_percentage);
+    double confidence(double p_value);
+
+    void            error(const char* msg);
+};
+
+// error handlers
+
+extern  void default_SampleStatistic_error_handler(const char*);
+extern  one_arg_error_handler_t SampleStatistic_error_handler;
+
+extern  one_arg_error_handler_t 
+        set_SampleStatistic_error_handler(one_arg_error_handler_t f);
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+    inline SampleStatistic:: SampleStatistic(){ reset();}
+    inline int SampleStatistic::  samples() {return(n);}
+    inline double SampleStatistic:: min() {return(minValue);}
+    inline double SampleStatistic:: max() {return(maxValue);}
+
+#endif
+#endif
diff --git a/usr/include/g++/String.h b/usr/include/g++/String.h
new file mode 100644 (file)
index 0000000..871b9a2
--- /dev/null
@@ -0,0 +1,1341 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#if defined(SHORT_NAMES) || defined(VMS)
+#define re_compile_pattern     recmppat
+#define re_pattern_buffer      repatbuf
+#define re_registers           reregs
+#endif
+
+#ifndef _String_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _String_h 1
+
+#include <stream.h>
+#include <Regex.h>
+
+struct StrRep                     // internal String representations
+{
+  unsigned short    len;         // string length 
+  unsigned short    sz;          // allocated space
+  char              s[1];        // the string starts here 
+                                 // (at least 1 char for trailing null)
+                                 // allocated & expanded via non-public fcts
+};
+
+// primitive ops on StrReps -- nearly all String fns go through these.
+
+StrRep*     Salloc(StrRep*, const char*, int, int);
+StrRep*     Scopy(StrRep*, StrRep*);
+StrRep*     Sresize(StrRep*, int);
+StrRep*     Scat(StrRep*, const char*, int, const char*, int);
+StrRep*     Scat(StrRep*, const char*, int,const char*,int, const char*,int);
+StrRep*     Sprepend(StrRep*, const char*, int);
+StrRep*     Sreverse(StrRep*, StrRep*);
+StrRep*     Supcase(StrRep*, StrRep*);
+StrRep*     Sdowncase(StrRep*, StrRep*);
+StrRep*     Scapitalize(StrRep*, StrRep*);
+
+// These classes need to be defined in the order given
+
+class String;
+class SubString;
+
+class SubString
+{
+  friend class      String;
+protected:
+
+  String&           S;        // The String I'm a substring of
+  unsigned short    pos;      // starting position in S's rep
+  unsigned short    len;      // length of substring
+
+  void              assign(StrRep*, const char*, int = -1);
+                    SubString(String& x, int p, int l);
+                    SubString(const SubString& x);
+
+public:
+
+// Note there are no public constructors. SubStrings are always
+// created via String operations
+
+                   ~SubString();
+
+  void              operator =  (const String&     y);
+  void              operator =  (const SubString&  y);
+  void              operator =  (const char* t);
+  void              operator =  (char        c);
+
+// return 1 if target appears anywhere in SubString; else 0
+
+  int               contains(char        c) const;
+  int               contains(const String&     y) const;
+  int               contains(const SubString&  y) const;
+  int               contains(const char* t) const;
+  int               contains(const Regex&       r) const;
+
+// return 1 if target matches entire SubString
+
+  int               matches(const Regex&  r) const;
+
+// IO 
+
+  friend ostream&   operator<<(ostream& s, const SubString& x);
+
+// status
+
+  int               length() const;
+  int               empty() const;
+  const char*       chars() const;
+
+  int               OK() const; 
+
+};
+
+
+class String
+{
+  friend class      SubString;
+
+protected:
+  StrRep*           rep;   // Strings are pointers to their representations
+
+// some helper functions
+
+  int               search(int, int, const char*, int = -1) const;
+  int               search(int, int, char) const;
+  int               match(int, int, int, const char*, int = -1) const;
+  int               _gsub(const char*, int, const char* ,int);
+  int               _gsub(const Regex&, const char*, int);
+  SubString         _substr(int, int);
+
+public:
+
+// constructors & assignment
+
+                    String();
+                    String(const String& x);
+                    String(const SubString&  x);
+                    String(const char* t);
+                    String(const char* t, int len);
+                    String(char c);
+
+                    ~String();
+
+  void              operator =  (const String&     y);
+  void              operator =  (const char* y);
+  void              operator =  (char        c);
+  void              operator =  (const SubString&  y);
+
+// concatenation
+
+  void              operator += (const String&     y); 
+  void              operator += (const SubString&  y);
+  void              operator += (const char* t);
+  void              operator += (char        c);
+
+  void              prepend(const String&     y); 
+  void              prepend(const SubString&  y);
+  void              prepend(const char* t);
+  void              prepend(char        c);
+
+
+// procedural versions:
+// concatenate first 2 args, store result in last arg
+
+  friend void     cat(const String&, const String&, String&);
+  friend void     cat(const String&, const SubString&, String&);
+  friend void     cat(const String&, const char*, String&);
+  friend void     cat(const String&, char, String&);
+
+  friend void     cat(const SubString&, const String&, String&);
+  friend void     cat(const SubString&, const SubString&, String&);
+  friend void     cat(const SubString&, const char*, String&);
+  friend void     cat(const SubString&, char, String&);
+
+  friend void     cat(const char*, const String&, String&);
+  friend void     cat(const char*, const SubString&, String&);
+  friend void     cat(const char*, const char*, String&);
+  friend void     cat(const char*, char, String&);
+
+// double concatenation, by request. (yes, there are too many versions, 
+// but if one is supported, then the others should be too...)
+// Concatenate first 3 args, store in last arg
+
+  friend void     cat(const String&,const String&, const String&,String&);
+  friend void     cat(const String&,const String&,const SubString&,String&);
+  friend void     cat(const String&,const String&, const char*, String&);
+  friend void     cat(const String&,const String&, char, String&);
+  friend void     cat(const String&,const SubString&,const String&,String&);
+  friend void     cat(const String&,const SubString&,const SubString&,String&);
+  friend void     cat(const String&,const SubString&, const char*, String&);
+  friend void     cat(const String&,const SubString&, char, String&);
+  friend void     cat(const String&,const char*, const String&,    String&);
+  friend void     cat(const String&,const char*, const SubString&, String&);
+  friend void     cat(const String&,const char*, const char*, String&);
+  friend void     cat(const String&,const char*, char, String&);
+
+  friend void     cat(const char*, const String&, const String&,String&);
+  friend void     cat(const char*,const String&,const SubString&,String&);
+  friend void     cat(const char*,const String&, const char*, String&);
+  friend void     cat(const char*,const String&, char, String&);
+  friend void     cat(const char*,const SubString&,const String&,String&);
+  friend void     cat(const char*,const SubString&,const SubString&,String&);
+  friend void     cat(const char*,const SubString&, const char*, String&);
+  friend void     cat(const char*,const SubString&, char, String&);
+  friend void     cat(const char*,const char*, const String&,    String&);
+  friend void     cat(const char*,const char*, const SubString&, String&);
+  friend void     cat(const char*,const char*, const char*, String&);
+  friend void     cat(const char*,const char*, char, String&);
+
+
+// searching & matching
+
+// return position of target in string or -1 for failure
+
+  int               index(char        c, int startpos = 0) const;      
+  int               index(const String&     y, int startpos = 0) const;      
+  int               index(const SubString&  y, int startpos = 0) const;      
+  int               index(const char* t, int startpos = 0) const;  
+  int               index(const Regex&      r, int startpos = 0) const;       
+
+// return 1 if target appears anyhere in String; else 0
+
+  int               contains(char        c) const;
+  int               contains(const String&     y) const;
+  int               contains(const SubString&  y) const;
+  int               contains(const char* t) const;
+  int               contains(const Regex&      r) const;
+
+// return 1 if target appears anywhere after position pos 
+// (or before, if pos is negative) in String; else 0
+
+  int               contains(char        c, int pos) const;
+  int               contains(const String&     y, int pos) const;
+  int               contains(const SubString&  y, int pos) const;
+  int               contains(const char* t, int pos) const;
+  int               contains(const Regex&      r, int pos) const;
+
+// return 1 if target appears at position pos in String; else 0
+
+  int               matches(char        c, int pos = 0) const;
+  int               matches(const String&     y, int pos = 0) const;
+  int               matches(const SubString&  y, int pos = 0) const;
+  int               matches(const char* t, int pos = 0) const;
+  int               matches(const Regex&      r, int pos = 0) const;
+
+//  return number of occurences of target in String
+
+  int               freq(char        c) const; 
+  int               freq(const String&     y) const;
+  int               freq(const SubString&  y) const;
+  int               freq(const char* t) const;
+
+// SubString extraction
+
+// Note that you can't take a substring of a const String, since
+// this leaves open the possiblility of indirectly modifying the
+// String through the SubString
+
+  SubString         at(int         pos, int len);
+  SubString         operator () (int         pos, int len); // synonym for at
+
+  SubString         at(const String&     x, int startpos = 0); 
+  SubString         at(const SubString&  x, int startpos = 0); 
+  SubString         at(const char* t, int startpos = 0);
+  SubString         at(char        c, int startpos = 0);
+  SubString         at(const Regex&      r, int startpos = 0); 
+
+  SubString         before(int          pos);
+  SubString         before(const String&      x, int startpos = 0);
+  SubString         before(const SubString&   x, int startpos = 0);
+  SubString         before(const char*  t, int startpos = 0);
+  SubString         before(char         c, int startpos = 0);
+  SubString         before(const Regex&       r, int startpos = 0);
+
+  SubString         through(int          pos);
+  SubString         through(const String&      x, int startpos = 0);
+  SubString         through(const SubString&   x, int startpos = 0);
+  SubString         through(const char*  t, int startpos = 0);
+  SubString         through(char         c, int startpos = 0);
+  SubString         through(const Regex&       r, int startpos = 0);
+
+  SubString         from(int          pos);
+  SubString         from(const String&      x, int startpos = 0);
+  SubString         from(const SubString&   x, int startpos = 0);
+  SubString         from(const char*  t, int startpos = 0);
+  SubString         from(char         c, int startpos = 0);
+  SubString         from(const Regex&       r, int startpos = 0);
+
+  SubString         after(int         pos);
+  SubString         after(const String&     x, int startpos = 0);
+  SubString         after(const SubString&  x, int startpos = 0);
+  SubString         after(const char* t, int startpos = 0);
+  SubString         after(char        c, int startpos = 0);
+  SubString         after(const Regex&      r, int startpos = 0);
+
+
+// deletion
+
+// delete len chars starting at pos
+  void              del(int         pos, int len);
+
+// delete the first occurrence of target after startpos
+
+  void              del(const String&     y, int startpos = 0);
+  void              del(const SubString&  y, int startpos = 0);
+  void              del(const char* t, int startpos = 0);
+  void              del(char        c, int startpos = 0);
+  void              del(const Regex&      r, int startpos = 0);
+
+// global substitution: substitute all occurrences of pat with repl
+
+  int               gsub(const String&     pat, const String&     repl);
+  int               gsub(const SubString&  pat, const String&     repl);
+  int               gsub(const char* pat, const String&     repl);
+  int               gsub(const char* pat, const char* repl);
+  int               gsub(const Regex&      pat, const String&     repl);
+
+// friends & utilities
+
+// split string into array res at separators; return number of elements
+
+  friend int        split(const String& x, String res[], int maxn, 
+                          const String& sep);
+  friend int        split(const String& x, String res[], int maxn, 
+                          const Regex&  sep);
+
+  friend String     common_prefix(const String& x, const String& y, 
+                                  int startpos = 0);
+  friend String     common_suffix(const String& x, const String& y, 
+                                  int startpos = -1);
+  friend String     replicate(char        c, int n);
+  friend String     replicate(const String&     y, int n);
+  friend String     join(String src[], int n, const String& sep);
+
+// simple builtin transformations
+
+  friend String     reverse(const String& x);
+  friend String     upcase(const String& x);
+  friend String     downcase(const String& x);
+  friend String     capitalize(const String& x);
+
+// in-place versions of above
+
+  void              reverse();
+  void              upcase();
+  void              downcase();
+  void              capitalize();
+
+// element extraction
+
+  char&             operator [] (int i);
+  char              elem(int i) const;
+  char              firstchar() const;
+  char              lastchar() const;
+
+// conversion
+
+                    operator const char*() const;
+  const char*       chars() const;
+
+
+// IO
+
+  friend ostream&   operator<<(ostream& s, const String& x);
+  friend ostream&   operator<<(ostream& s, const SubString& x);
+  friend istream&   operator>>(istream& s, String& x);
+
+  friend int        readline(istream& s, String& x, 
+                             char terminator = '\n',
+                             int discard_terminator = 1);
+
+// status
+
+  int               length() const;
+  int               empty() const;
+
+// preallocate some space for String
+  void              alloc(int newsize);
+
+// report current allocation (not length!)
+
+  int               allocation() const;
+
+
+  volatile void     error(const char* msg) const;
+
+  int               OK() const;
+};
+
+typedef String StrTmp; // for backward compatibility
+
+// other externs
+
+int        compare(const String&    x, const String&     y);
+int        compare(const String&    x, const SubString&  y);
+int        compare(const String&    x, const char* y);
+int        compare(const SubString& x, const String&     y);
+int        compare(const SubString& x, const SubString&  y);
+int        compare(const SubString& x, const char* y);
+int        fcompare(const String&   x, const String&     y); // ignore case
+
+extern StrRep  _nilStrRep;
+extern String _nilString;
+
+// other inlines
+
+String operator + (const String& x, const String& y);
+String operator + (const String& x, const SubString& y);
+String operator + (const String& x, const char* y);
+String operator + (const String& x, char y);
+String operator + (const SubString& x, const String& y);
+String operator + (const SubString& x, const SubString& y);
+String operator + (const SubString& x, const char* y);
+String operator + (const SubString& x, char y);
+String operator + (const char* x, const String& y);
+String operator + (const char* x, const SubString& y);
+
+int operator==(const String& x, const String& y); 
+int operator!=(const String& x, const String& y);
+int operator> (const String& x, const String& y);
+int operator>=(const String& x, const String& y);
+int operator< (const String& x, const String& y);
+int operator<=(const String& x, const String& y);
+int operator==(const String& x, const SubString&  y);
+int operator!=(const String& x, const SubString&  y);
+int operator> (const String& x, const SubString&  y);
+int operator>=(const String& x, const SubString&  y);
+int operator< (const String& x, const SubString&  y);
+int operator<=(const String& x, const SubString&  y);
+int operator==(const String& x, const char* t);
+int operator!=(const String& x, const char* t);
+int operator> (const String& x, const char* t);
+int operator>=(const String& x, const char* t);
+int operator< (const String& x, const char* t);
+int operator<=(const String& x, const char* t);
+int operator==(const SubString& x, const String& y);
+int operator!=(const SubString& x, const String& y);
+int operator> (const SubString& x, const String& y);
+int operator>=(const SubString& x, const String& y);
+int operator< (const SubString& x, const String& y);
+int operator<=(const SubString& x, const String& y);
+int operator==(const SubString& x, const SubString&  y);
+int operator!=(const SubString& x, const SubString&  y);
+int operator> (const SubString& x, const SubString&  y);
+int operator>=(const SubString& x, const SubString&  y);
+int operator< (const SubString& x, const SubString&  y);
+int operator<=(const SubString& x, const SubString&  y);
+int operator==(const SubString& x, const char* t);
+int operator!=(const SubString& x, const char* t);
+int operator> (const SubString& x, const char* t);
+int operator>=(const SubString& x, const char* t);
+int operator< (const SubString& x, const char* t);
+int operator<=(const SubString& x, const char* t);
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+
+// status reports, needed before defining other things
+
+inline int         String::length() const {  return rep->len; }
+inline int         String::empty() const { return rep->len == 0; }
+inline const char* String::chars() const { return &(rep->s[0]); }
+inline int         String::allocation() const { return rep->sz; }
+inline void        String::alloc(int newsize) { rep = Sresize(rep, newsize); }
+
+inline int         SubString::length() const { return len; }
+inline int         SubString::empty() const { return len == 0; }
+inline const char* SubString::chars() const { return &(S.rep->s[pos]); }
+
+
+// constructors
+
+inline String::String() 
+  : rep(&_nilStrRep) {}
+inline String::String(const String& x) 
+  : rep(Scopy(0, x.rep)) {}
+inline String::String(const char* t) 
+  : rep(Salloc(0, t, -1, -1)) {}
+inline String::String(const char* t, int tlen)
+  : rep(Salloc(0, t, tlen, tlen)) {}
+inline String::String(const SubString& y)
+  : rep(Salloc(0, y.chars(), y.length(), y.length())) {}
+inline String::String(char c) 
+  : rep(Salloc(0, &c, 1, 1)) {}
+
+inline String::~String() { if (rep != &_nilStrRep) delete rep; }
+
+inline SubString::SubString(const SubString& x)
+  :S(x.S), pos(x.pos), len(x.len) {}
+inline SubString::SubString(String& x, int first, int l)
+  :S(x), pos(first), len(l) {}
+
+inline SubString::~SubString() {}
+
+// assignment
+
+inline void String::operator =  (const String& y)
+{ 
+  rep = Scopy(rep, y.rep);
+}
+
+inline void String::operator=(const char* t)
+{
+  rep = Salloc(rep, t, -1, -1); 
+}
+
+inline void String::operator=(const SubString&  y)
+{
+  rep = Salloc(rep, y.chars(), y.length(), y.length());
+}
+
+inline void String::operator=(char c)
+{
+  rep = Salloc(rep, &c, 1, 1); 
+}
+
+
+inline void SubString::operator = (const char* ys)
+{
+  assign(0, ys);
+}
+
+inline void SubString::operator = (char ch)
+{
+  assign(0, &ch, 1);
+}
+
+inline void SubString::operator = (const String& y)
+{
+  assign(y.rep, y.chars(), y.length());
+}
+
+inline void SubString::operator = (const SubString& y)
+{
+  assign(y.S.rep, y.chars(), y.length());
+}
+
+// Zillions of cats...
+
+inline void cat(const String& x, const String& y, String& r)
+{
+  r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
+}
+
+inline void cat(const String& x, const SubString& y, String& r)
+{
+  r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
+}
+
+inline void cat(const String& x, const char* y, String& r)
+{
+  r.rep = Scat(r.rep, x.chars(), x.length(), y, -1);
+}
+
+inline void cat(const String& x, char y, String& r)
+{
+  r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1);
+}
+
+inline void cat(const SubString& x, const String& y, String& r)
+{
+  r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
+}
+
+inline void cat(const SubString& x, const SubString& y, String& r)
+{
+  r.rep = Scat(r.rep, x.chars(), x.length(), y.chars(), y.length());
+}
+
+inline void cat(const SubString& x, const char* y, String& r)
+{
+  r.rep = Scat(r.rep, x.chars(), x.length(), y, -1);
+}
+
+inline void cat(const SubString& x, char y, String& r)
+{
+  r.rep = Scat(r.rep, x.chars(), x.length(), &y, 1);
+}
+
+inline void cat(const char* x, const String& y, String& r)
+{
+  r.rep = Scat(r.rep, x, -1, y.chars(), y.length());
+}
+
+inline void cat(const char* x, const SubString& y, String& r)
+{
+  r.rep = Scat(r.rep, x, -1, y.chars(), y.length());
+}
+
+inline void cat(const char* x, const char* y, String& r)
+{
+  r.rep = Scat(r.rep, x, -1, y, -1);
+}
+
+inline void cat(const char* x, char y, String& r)
+{
+  r.rep = Scat(r.rep, x, -1, &y, 1);
+}
+
+inline void cat(const String& a, const String& x, const String& y, String& r)
+{
+  r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
+}
+
+inline void cat(const String& a, const String& x, const SubString& y, String& r)
+{
+  r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
+}
+
+inline void cat(const String& a, const String& x, const char* y, String& r)
+{
+  r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1);
+}
+
+inline void cat(const String& a, const String& x, char y, String& r)
+{
+  r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1);
+}
+
+inline void cat(const String& a, const SubString& x, const String& y, String& r)
+{
+  r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
+}
+
+inline void cat(const String& a, const SubString& x, const SubString& y, String& r)
+{
+  r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y.chars(), y.length());
+}
+
+inline void cat(const String& a, const SubString& x, const char* y, String& r)
+{
+  r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), y, -1);
+}
+
+inline void cat(const String& a, const SubString& x, char y, String& r)
+{
+  r.rep = Scat(r.rep, a.chars(), a.length(), x.chars(), x.length(), &y, 1);
+}
+
+inline void cat(const String& a, const char* x, const String& y, String& r)
+{
+  r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length());
+}
+
+inline void cat(const String& a, const char* x, const SubString& y, String& r)
+{
+  r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y.chars(), y.length());
+}
+
+inline void cat(const String& a, const char* x, const char* y, String& r)
+{
+  r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, y, -1);
+}
+
+inline void cat(const String& a, const char* x, char y, String& r)
+{
+  r.rep = Scat(r.rep, a.chars(), a.length(), x, -1, &y, 1);
+}
+
+
+inline void cat(const char* a, const String& x, const String& y, String& r)
+{
+  r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
+}
+
+inline void cat(const char* a, const String& x, const SubString& y, String& r)
+{
+  r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
+}
+
+inline void cat(const char* a, const String& x, const char* y, String& r)
+{
+  r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1);
+}
+
+inline void cat(const char* a, const String& x, char y, String& r)
+{
+  r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1);
+}
+
+inline void cat(const char* a, const SubString& x, const String& y, String& r)
+{
+  r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
+}
+
+inline void cat(const char* a, const SubString& x, const SubString& y, String& r)
+{
+  r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y.chars(), y.length());
+}
+
+inline void cat(const char* a, const SubString& x, const char* y, String& r)
+{
+  r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), y, -1);
+}
+
+inline void cat(const char* a, const SubString& x, char y, String& r)
+{
+  r.rep = Scat(r.rep, a, -1, x.chars(), x.length(), &y, 1);
+}
+
+inline void cat(const char* a, const char* x, const String& y, String& r)
+{
+  r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length());
+}
+
+inline void cat(const char* a, const char* x, const SubString& y, String& r)
+{
+  r.rep = Scat(r.rep, a, -1, x, -1, y.chars(), y.length());
+}
+
+inline void cat(const char* a, const char* x, const char* y, String& r)
+{
+  r.rep = Scat(r.rep, a, -1, x, -1, y, -1);
+}
+
+inline void cat(const char* a, const char* x, char y, String& r)
+{
+  r.rep = Scat(r.rep, a, -1, x, -1, &y, 1);
+}
+
+
+// operator versions
+
+inline void String::operator +=(const String& y)
+{
+  cat(*this, y, *this);
+}
+
+inline void String::operator +=(const SubString& y)
+{
+  cat(*this, y, *this);
+}
+
+inline void String::operator += (const char* y)
+{
+  cat(*this, y, *this);
+}
+
+inline void String:: operator +=(char y)
+{
+  cat(*this, y, *this);
+}
+
+// constructive concatenation
+
+#if defined(__GNUG__) && !defined(NO_NRV)
+
+inline String operator + (const String& x, const String& y) return r;
+{
+  cat(x, y, r);
+}
+
+inline String operator + (const String& x, const SubString& y) return r;
+{
+  cat(x, y, r);
+}
+
+inline String operator + (const String& x, const char* y) return r;
+{
+  cat(x, y, r);
+}
+
+inline String operator + (const String& x, char y) return r;
+{
+  cat(x, y, r);
+}
+
+inline String operator + (const SubString& x, const String& y) return r;
+{
+  cat(x, y, r);
+}
+
+inline String operator + (const SubString& x, const SubString& y) return r;
+{
+  cat(x, y, r);
+}
+
+inline String operator + (const SubString& x, const char* y) return r;
+{
+  cat(x, y, r);
+}
+
+inline String operator + (const SubString& x, char y) return r;
+{
+  cat(x, y, r);
+}
+
+inline String operator + (const char* x, const String& y) return r;
+{
+  cat(x, y, r);
+}
+
+inline String operator + (const char* x, const SubString& y) return r;
+{
+  cat(x, y, r);
+}
+
+inline String reverse(const String& x) return r;
+{
+  r.rep = Sreverse(x.rep, r.rep);
+}
+
+inline String upcase(const String& x) return r;
+{
+  r.rep = Supcase(x.rep, r.rep);
+}
+
+inline String downcase(const String& x) return r;
+{
+  r.rep = Sdowncase(x.rep, r.rep);
+}
+
+inline String capitalize(const String& x) return r;
+{
+  r.rep = Scapitalize(x.rep, r.rep);
+}
+
+#else /* NO_NRV */
+
+inline String operator + (const String& x, const String& y)
+{
+  String r;  cat(x, y, r);  return r;
+}
+
+inline String operator + (const String& x, const SubString& y) 
+{
+  String r; cat(x, y, r); return r;
+}
+
+inline String operator + (const String& x, const char* y) 
+{
+  String r; cat(x, y, r); return r;
+}
+
+inline String operator + (const String& x, char y) 
+{
+  String r; cat(x, y, r); return r;
+}
+
+inline String operator + (const SubString& x, const String& y) 
+{
+  String r; cat(x, y, r); return r;
+}
+
+inline String operator + (const SubString& x, const SubString& y) 
+{
+  String r; cat(x, y, r); return r;
+}
+
+inline String operator + (const SubString& x, const char* y) 
+{
+  String r; cat(x, y, r); return r;
+}
+
+inline String operator + (const SubString& x, char y) 
+{
+  String r; cat(x, y, r); return r;
+}
+
+inline String operator + (const char* x, const String& y) 
+{
+  String r; cat(x, y, r); return r;
+}
+
+inline String operator + (const char* x, const SubString& y) 
+{
+  String r; cat(x, y, r); return r;
+}
+
+inline String reverse(const String& x) 
+{
+  String r; r.rep = Sreverse(x.rep, r.rep); return r;
+}
+
+inline String upcase(const String& x) 
+{
+  String r; r.rep = Supcase(x.rep, r.rep); return r;
+}
+
+inline String downcase(const String& x) 
+{
+  String r; r.rep = Sdowncase(x.rep, r.rep); return r;
+}
+
+inline String capitalize(const String& x) 
+{
+  String r; r.rep = Scapitalize(x.rep, r.rep); return r;
+}
+
+#endif
+
+// prepend
+
+inline void String::prepend(const String& y)
+{
+  rep = Sprepend(rep, y.chars(), y.length());
+}
+
+inline void String::prepend(const char* y)
+{
+  rep = Sprepend(rep, y, -1); 
+}
+
+inline void String::prepend(char y)
+{
+  rep = Sprepend(rep, &y, 1); 
+}
+
+inline void String::prepend(const SubString& y)
+{
+  rep = Sprepend(rep, y.chars(), y.length());
+}
+
+// misc transformations
+
+
+inline void String::reverse()
+{
+  rep = Sreverse(rep, rep);
+}
+
+
+inline void String::upcase()
+{
+  rep = Supcase(rep, rep);
+}
+
+
+inline void String::downcase()
+{
+  rep = Sdowncase(rep, rep);
+}
+
+
+inline void String::capitalize()
+{
+  rep = Scapitalize(rep, rep);
+}
+
+// element extraction
+
+inline char&  String::operator [] (int i) 
+{ 
+  if (((unsigned)i) >= length()) error("invalid index");
+  return rep->s[i];
+}
+
+inline char  String::elem (int i) const
+{ 
+  if (((unsigned)i) >= length()) error("invalid index");
+  return rep->s[i];
+}
+
+inline char  String::firstchar() const
+{ 
+  return elem(0);
+}
+
+inline char  String::lastchar() const
+{ 
+  return elem(length() - 1);
+}
+
+// searching
+
+inline int String::index(char c, int startpos) const
+{
+  return search(startpos, length(), c);
+}
+
+inline int String::index(const char* t, int startpos) const
+{   
+  return search(startpos, length(), t);
+}
+
+inline int String::index(const String& y, int startpos) const
+{   
+  return search(startpos, length(), y.chars(), y.length());
+}
+
+inline int String::index(const SubString& y, int startpos) const
+{   
+  return search(startpos, length(), y.chars(), y.length());
+}
+
+inline int String::index(const Regex& r, int startpos) const
+{
+  int unused;  return r.search(chars(), length(), unused, startpos);
+}
+
+inline int String::contains(char c) const
+{
+  return search(0, length(), c) >= 0;
+}
+
+inline int String::contains(const char* t) const
+{   
+  return search(0, length(), t) >= 0;
+}
+
+inline int String::contains(const String& y) const
+{   
+  return search(0, length(), y.chars(), y.length()) >= 0;
+}
+
+inline int String::contains(const SubString& y) const
+{   
+  return search(0, length(), y.chars(), y.length()) >= 0;
+}
+
+inline int String::contains(char c, int p) const
+{
+  return match(p, length(), 0, &c, 1) >= 0;
+}
+
+inline int String::contains(const char* t, int p) const
+{
+  return match(p, length(), 0, t) >= 0;
+}
+
+inline int String::contains(const String& y, int p) const
+{
+  return match(p, length(), 0, y.chars(), y.length()) >= 0;
+}
+
+inline int String::contains(const SubString& y, int p) const
+{
+  return match(p, length(), 0, y.chars(), y.length()) >= 0;
+}
+
+inline int String::contains(const Regex& r) const
+{
+  int unused;  return r.search(chars(), length(), unused, 0) >= 0;
+}
+
+inline int String::contains(const Regex& r, int p) const
+{
+  return r.match(chars(), length(), p) >= 0;
+}
+
+
+inline int String::matches(const SubString& y, int p) const
+{
+  return match(p, length(), 1, y.chars(), y.length()) >= 0;
+}
+
+inline int String::matches(const String& y, int p) const
+{
+  return match(p, length(), 1, y.chars(), y.length()) >= 0;
+}
+
+inline int String::matches(const char* t, int p) const
+{
+  return match(p, length(), 1, t) >= 0;
+}
+
+inline int String::matches(char c, int p) const
+{
+  return match(p, length(), 1, &c, 1) >= 0;
+}
+
+inline int String::matches(const Regex& r, int p) const
+{
+  int l = (p < 0)? -p : length() - p;
+  return r.match(chars(), length(), p) == l;
+}
+
+
+inline int SubString::contains(const char* t) const
+{   
+  return S.search(pos, pos+len, t) >= 0;
+}
+
+inline int SubString::contains(const String& y) const
+{   
+  return S.search(pos, pos+len, y.chars(), y.length()) >= 0;
+}
+
+inline int SubString::contains(const SubString&  y) const
+{   
+  return S.search(pos, pos+len, y.chars(), y.length()) >= 0;
+}
+
+inline int SubString::contains(char c) const
+{
+  return S.search(pos, pos+len, 0, c) >= 0;
+}
+
+inline int SubString::contains(const Regex& r) const
+{
+  int unused;  return r.search(chars(), len, unused, 0) >= 0;
+}
+
+inline int SubString::matches(const Regex& r) const
+{
+  return r.match(chars(), len, 0) == len;
+}
+
+
+inline int String::gsub(const String& pat, const String& r)
+{
+  return _gsub(pat.chars(), pat.length(), r.chars(), r.length());
+}
+
+inline int String::gsub(const SubString&  pat, const String& r)
+{
+  return _gsub(pat.chars(), pat.length(), r.chars(), r.length());
+}
+
+inline int String::gsub(const Regex& pat, const String& r)
+{
+  return _gsub(pat, r.chars(), r.length());
+}
+
+inline int String::gsub(const char* pat, const String& r)
+{
+  return _gsub(pat, -1, r.chars(), r.length());
+}
+
+inline int String::gsub(const char* pat, const char* r)
+{
+  return _gsub(pat, -1, r, -1);
+}
+
+
+inline String::operator const char*() const
+{ 
+  return str(chars());
+}
+
+inline  ostream& operator<<(ostream& s, const String& x)
+{
+#ifdef VMS
+   s << x.chars(); return s;
+#else
+  s.put(x.chars()); return s;
+#endif
+
+}
+
+// a zillion comparison operators
+
+inline int operator==(const String& x, const String& y) 
+{
+  return compare(x, y) == 0; 
+}
+
+inline int operator!=(const String& x, const String& y)
+{
+  return compare(x, y) != 0; 
+}
+
+inline int operator>(const String& x, const String& y)
+{
+  return compare(x, y) > 0; 
+}
+
+inline int operator>=(const String& x, const String& y)
+{
+  return compare(x, y) >= 0; 
+}
+
+inline int operator<(const String& x, const String& y)
+{
+  return compare(x, y) < 0; 
+}
+
+inline int operator<=(const String& x, const String& y)
+{
+  return compare(x, y) <= 0; 
+}
+
+inline int operator==(const String& x, const SubString&  y) 
+{
+  return compare(x, y) == 0; 
+}
+
+inline int operator!=(const String& x, const SubString&  y)
+{
+  return compare(x, y) != 0; 
+}
+
+inline int operator>(const String& x, const SubString&  y)      
+{
+  return compare(x, y) > 0; 
+}
+
+inline int operator>=(const String& x, const SubString&  y)
+{
+  return compare(x, y) >= 0; 
+}
+
+inline int operator<(const String& x, const SubString&  y) 
+{
+  return compare(x, y) < 0; 
+}
+
+inline int operator<=(const String& x, const SubString&  y)
+{
+  return compare(x, y) <= 0; 
+}
+
+inline int operator==(const String& x, const char* t) 
+{
+  return compare(x, t) == 0; 
+}
+
+inline int operator!=(const String& x, const char* t) 
+{
+  return compare(x, t) != 0; 
+}
+
+inline int operator>(const String& x, const char* t)  
+{
+  return compare(x, t) > 0; 
+}
+
+inline int operator>=(const String& x, const char* t) 
+{
+  return compare(x, t) >= 0; 
+}
+
+inline int operator<(const String& x, const char* t)  
+{
+  return compare(x, t) < 0; 
+}
+
+inline int operator<=(const String& x, const char* t) 
+{
+  return compare(x, t) <= 0; 
+}
+
+inline int operator==(const SubString& x, const String& y) 
+{
+  return compare(y, x) == 0; 
+}
+
+inline int operator!=(const SubString& x, const String& y)
+{
+  return compare(y, x) != 0;
+}
+
+inline int operator>(const SubString& x, const String& y)      
+{
+  return compare(y, x) < 0;
+}
+
+inline int operator>=(const SubString& x, const String& y)     
+{
+  return compare(y, x) <= 0;
+}
+
+inline int operator<(const SubString& x, const String& y)      
+{
+  return compare(y, x) > 0;
+}
+
+inline int operator<=(const SubString& x, const String& y)     
+{
+  return compare(y, x) >= 0;
+}
+
+inline int operator==(const SubString& x, const SubString&  y) 
+{
+  return compare(x, y) == 0; 
+}
+
+inline int operator!=(const SubString& x, const SubString&  y)
+{
+  return compare(x, y) != 0;
+}
+
+inline int operator>(const SubString& x, const SubString&  y)      
+{
+  return compare(x, y) > 0;
+}
+
+inline int operator>=(const SubString& x, const SubString&  y)
+{
+  return compare(x, y) >= 0;
+}
+
+inline int operator<(const SubString& x, const SubString&  y) 
+{
+  return compare(x, y) < 0;
+}
+
+inline int operator<=(const SubString& x, const SubString&  y)
+{
+  return compare(x, y) <= 0;
+}
+
+inline int operator==(const SubString& x, const char* t) 
+{
+  return compare(x, t) == 0; 
+}
+
+inline int operator!=(const SubString& x, const char* t) 
+{
+  return compare(x, t) != 0;
+}
+
+inline int operator>(const SubString& x, const char* t)  
+{
+  return compare(x, t) > 0; 
+}
+
+inline int operator>=(const SubString& x, const char* t) 
+{
+  return compare(x, t) >= 0; 
+}
+
+inline int operator<(const SubString& x, const char* t)  
+{
+  return compare(x, t) < 0; 
+}
+
+inline int operator<=(const SubString& x, const char* t) 
+{
+  return compare(x, t) <= 0; 
+}
+
+
+// a helper needed by at, before, etc.
+
+inline SubString String::_substr(int first, int l)
+{
+  if (first < 0 || (unsigned)(first + l) > length()) 
+    return SubString(_nilString, 0, 0) ;
+  else 
+    return SubString(*this, first, l);
+}
+
+
+#endif
+
+#endif
diff --git a/usr/include/g++/Uniform.h b/usr/include/g++/Uniform.h
new file mode 100644 (file)
index 0000000..5d896e8
--- /dev/null
@@ -0,0 +1,81 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _Uniform_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Uniform_h 1
+
+#include <Random.h>
+
+//
+//     The interval [lo..hi]
+// 
+
+class Uniform: public Random {
+    double pLow;
+    double pHigh;
+    double delta;
+public:
+    Uniform(double low, double high, RNG *gen);
+
+    double low();
+    double low(double x);
+    double high();
+    double high(double x);
+
+    virtual double operator()();
+};
+
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline Uniform::Uniform(double low, double high, RNG *gen):(gen)
+{
+    pLow = (low < high) ? low : high;
+    pHigh = (low < high) ? high : low;
+    delta = pHigh - pLow;
+}
+
+inline double Uniform::low() { return pLow; }
+
+inline double Uniform::low(double x) {
+  double tmp = pLow;
+  pLow = x;
+  delta = pHigh - pLow;
+  return tmp;
+}
+
+inline double Uniform::high() { return pHigh; }
+
+inline double Uniform::high(double x) {
+  double tmp = pHigh;
+  pHigh = x;
+  delta = pHigh - pLow;
+  return tmp;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/Weibull.h b/usr/include/g++/Weibull.h
new file mode 100644 (file)
index 0000000..6ce8eab
--- /dev/null
@@ -0,0 +1,83 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+#ifndef _Weibull_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _Weibull_h 
+
+#include <Random.h>
+
+class Weibull: public Random {
+protected:
+    double pAlpha;
+    double pInvAlpha;
+    double pBeta;
+
+    void setState();
+    
+public:
+    Weibull(double alpha, double beta, RNG *gen);
+
+    double alpha();
+    double alpha(double x);
+
+    double beta();
+    double beta(double x);
+
+    virtual double operator()();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline void Weibull::setState() {
+  pInvAlpha = 1.0 / pAlpha;
+}
+    
+inline Weibull::Weibull(double alpha, double beta,  RNG *gen) : (gen)
+{
+  pAlpha = alpha;
+  pBeta = beta;
+  setState();
+}
+
+inline double Weibull::alpha() { return pAlpha; }
+
+inline double Weibull::alpha(double x) {
+  double tmp = pAlpha;
+  pAlpha = x;
+  setState();
+  return tmp;
+}
+
+inline double Weibull::beta() { return pBeta; };
+inline double Weibull::beta(double x) {
+  double tmp = pBeta;
+  pBeta = x;
+  return tmp;
+};
+
+
+#endif
+#endif
diff --git a/usr/include/g++/abs.h b/usr/include/g++/abs.h
new file mode 100644 (file)
index 0000000..8c2c8f9
--- /dev/null
@@ -0,0 +1 @@
+#include <builtin.h>
diff --git a/usr/include/g++/assert.h b/usr/include/g++/assert.h
new file mode 100644 (file)
index 0000000..4a96c96
--- /dev/null
@@ -0,0 +1,45 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+/* Allow this file to be included multiple times
+   with different settings of NDEBUG.  */
+#undef assert
+#undef assertval
+
+#ifdef NDEBUG
+#define assert(ignore)
+#define assertval(ex)  (ex)
+#else
+
+extern "C" void __eprintf (char*, int, char*);         /* Defined in gnulib */
+extern "C" volatile void   abort();
+
+#define assert(ex) \
+        ((ex) ? 1 : \
+              (__eprintf("Failed assertion " #ex " at line %d of `%s'.\n", \
+               __LINE__, __FILE__), abort (), 0))
+#define assertval(ex) \
+        ((ex) ? 1 : \
+              (__eprintf("Failed assertion " #ex " at line %d of `%s'.\n", \
+               __LINE__, __FILE__), abort (), 0))
+
+#endif NDEBUG
diff --git a/usr/include/g++/bool.h b/usr/include/g++/bool.h
new file mode 100644 (file)
index 0000000..e843aa9
--- /dev/null
@@ -0,0 +1,10 @@
+
+#ifndef _bool_h
+#ifdef __GNUG__
+#pragma once
+#endif
+#define _bool_h 1
+
+enum bool { FALSE = 0, TRUE = 1 };
+
+#endif
diff --git a/usr/include/g++/builtin.h b/usr/include/g++/builtin.h
new file mode 100644 (file)
index 0000000..904059b
--- /dev/null
@@ -0,0 +1,276 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+/*
+  arithmetic, etc. functions on built in types
+*/
+
+
+#ifndef _builtin_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _builtin_h 1
+
+
+typedef void (*one_arg_error_handler_t)(const char*);
+typedef void (*two_arg_error_handler_t)(const char*, const char*);
+
+
+
+#include <stddef.h>
+#include <std.h>
+#include <math.h>
+
+long         gcd(long, long);
+long         lg(unsigned long); 
+double       pow(double, long);
+long         pow(long, long);
+
+double       start_timer();
+double       return_elapsed_time(double last_time = 0.0);
+
+char*        itoa(long x, int base = 10, int width = 0);
+char*        itoa(unsigned long x, int base = 10, int width = 0);
+#ifdef __GNUG__
+char*        itoa(long long x, int base = 10, int width = 0);
+char*        itoa(unsigned long long x, int base = 10, int width = 0);
+#endif
+char*        dtoa(double x, char cvt = 'g', int width = 0, int prec = 6);
+
+char*        hex(long x, int width = 0);
+char*        hex(unsigned long x, int width = 0);
+char*        hex(int x, int width = 0);
+char*        hex(short x, int width = 0);
+char*        hex(unsigned int x, int width = 0);
+char*        hex(unsigned short x, int width = 0);
+
+char*        oct(long x, int width = 0);
+char*        oct(unsigned long x, int width = 0);
+char*        oct(int x, int width = 0);
+char*        oct(short x, int width = 0);
+char*        oct(unsigned int x, int width = 0) ;
+char*        oct(unsigned short x, int width = 0); 
+
+char*        dec(long x, int width = 0);
+char*        dec(unsigned long x, int width = 0);
+char*        dec(int x, int width = 0);
+char*        dec(short x, int width = 0);
+char*        dec(unsigned int x, int width = 0) ;
+char*        dec(unsigned short x, int width = 0); 
+
+char*        form(const char* fmt ...);
+char*        chr(char ch, int width = 0);
+char*        str(const char* s, int width = 0);
+
+unsigned int hashpjw(const char*);
+unsigned int multiplicativehash(int);
+unsigned int foldhash(double);
+
+extern void default_one_arg_error_handler(const char*);
+extern void default_two_arg_error_handler(const char*, const char*);
+
+extern two_arg_error_handler_t lib_error_handler;
+
+extern two_arg_error_handler_t 
+       set_lib_error_handler(two_arg_error_handler_t f);
+
+
+double abs(double arg);
+float abs(float arg);
+short abs(short arg);
+long abs(long arg);
+int sign(long arg);
+int sign(double arg);
+long sqr(long arg);
+double sqr(double arg);
+int even(long arg);
+int odd(long arg);
+long lcm(long x, long y);
+void setbit(long& x, long b);
+void clearbit(long& x, long b);
+int testbit(long x, long b);
+
+signed char min(signed char a, signed char b);
+unsigned char min(unsigned char a, unsigned char b);
+
+signed short min(signed short a, signed short b);
+unsigned short min(unsigned short a, unsigned short b);
+
+signed int min(signed int a, signed int b);
+unsigned int min(unsigned int a, unsigned int b);
+
+signed long min(signed long a, signed long b);
+unsigned long min(unsigned long a, unsigned long b);
+
+float min(float a, float b);
+
+double min(double a, double b);
+
+signed char max(signed char a, signed char b);
+unsigned char max(unsigned char a, unsigned char b);
+
+signed short max(signed short a, signed short b);
+unsigned short max(unsigned short a, unsigned short b);
+
+signed int max(signed int a, signed int b);
+unsigned int max(unsigned int a, unsigned int b);
+
+signed long max(signed long a, signed long b);
+unsigned long max(unsigned long a, unsigned long b);
+
+float max(float a, float b);
+
+double max(double a, double b);
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+
+inline double abs(double arg) 
+{
+  return (arg < 0.0)? -arg : arg;
+}
+
+inline float abs(float arg) 
+{
+  return (arg < 0.0)? -arg : arg;
+}
+
+inline short abs(short arg) 
+{
+  return (arg < 0)? -arg : arg;
+}
+
+inline long abs(long arg) 
+{
+  return (arg < 0)? -arg : arg;
+}
+
+inline int sign(long arg)
+{
+  return (arg == 0) ? 0 : ( (arg > 0) ? 1 : -1 );
+}
+
+inline int sign(double arg)
+{
+  return (arg == 0.0) ? 0 : ( (arg > 0.0) ? 1 : -1 );
+}
+
+inline long sqr(long arg)
+{
+  return arg * arg;
+}
+
+inline double sqr(double arg)
+{
+  return arg * arg;
+}
+
+inline int even(long arg)
+{
+  return !(arg & 1);
+}
+
+inline int odd(long arg)
+{
+  return (arg & 1);
+}
+
+inline long lcm(long x, long y)
+{
+  return x / gcd(x, y) * y;
+}
+
+inline void setbit(long& x, long b)
+{
+  x |= (1 << b);
+}
+
+inline void clearbit(long& x, long b)
+{
+  x &= ~(1 << b);
+}
+
+inline int testbit(long x, long b)
+{
+  return ((x & (1 << b)) != 0);
+}
+
+inline char* hex(int x, int width = 0) { return hex(long(x), width); }
+inline char* hex(short x, int width = 0) { return hex(long(x), width); }
+inline char* hex(unsigned int x, int width = 0) 
+{ return hex((unsigned long)(x), width); }
+inline char* hex(unsigned short x, int width = 0) 
+{ return hex((unsigned long)(x), width); }
+
+inline char* oct(int x, int width = 0) { return oct(long(x), width); }
+inline char* oct(short x, int width = 0) { return oct(long(x), width); }
+inline char* oct(unsigned int x, int width = 0) 
+{ return oct((unsigned long)(x), width); }
+inline char* oct(unsigned short x, int width = 0) 
+{ return oct((unsigned long)(x), width); }
+
+inline char* dec(int x, int width = 0) { return dec(long(x), width); }
+inline char* dec(short x, int width = 0) { return dec(long(x), width); }
+inline char* dec(unsigned int x, int width = 0) 
+{ return dec((unsigned long)(x), width); }
+inline char* dec(unsigned short x, int width = 0) 
+{ return dec((unsigned long)(x), width); }
+
+inline signed char min(signed char a, signed char b) { return (a < b)?a:b;}
+inline unsigned char min(unsigned char a, unsigned char b) {return (a < b)?a:b;}
+
+inline signed short min(signed short a, signed short b) {return (a < b) ?a:b;}
+inline unsigned short min(unsigned short a, unsigned short b) {return (a < b)?a:b;}
+
+inline signed int min(signed int a, signed int b) {return (a < b)?a:b;}
+inline unsigned int min(unsigned int a, unsigned int b) {return (a < b)?a:b;}
+
+inline signed long min(signed long a, signed long b) {return (a < b)?a:b;}
+inline unsigned long min(unsigned long a, unsigned long b) {return (a < b)?a:b;}
+
+inline float min(float a, float b) {return (a < b)?a:b;}
+
+inline double min(double a, double b) {return (a < b)?a:b;}
+
+inline signed char max(signed char a, signed char b) { return (a > b)?a:b;}
+inline unsigned char max(unsigned char a, unsigned char b) {return (a > b)?a:b;}
+
+inline signed short max(signed short a, signed short b) {return (a > b) ?a:b;}
+inline unsigned short max(unsigned short a, unsigned short b) {return (a > b)?a:b;}
+
+inline signed int max(signed int a, signed int b) {return (a > b)?a:b;}
+inline unsigned int max(unsigned int a, unsigned int b) {return (a > b)?a:b;}
+
+inline signed long max(signed long a, signed long b) {return (a > b)?a:b;}
+inline unsigned long max(unsigned long a, unsigned long b) {return (a > b)?a:b;}
+
+inline float max(float a, float b) {return (a > b)?a:b;}
+
+inline double max(double a, double b) {return (a > b)?a:b;}
+
+#endif
+
+#endif
diff --git a/usr/include/g++/compare.h b/usr/include/g++/compare.h
new file mode 100644 (file)
index 0000000..e298e2f
--- /dev/null
@@ -0,0 +1,98 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _compare_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _compare_h 1
+
+#include <builtin.h>
+
+int compare(int a, int b);
+int compare(short a, short b);
+int compare(char a, char b);
+int compare(unsigned long a, unsigned long b);
+int compare(unsigned int a, unsigned int b);
+int compare(unsigned short a, unsigned short b);
+int compare(unsigned char a, unsigned char b);
+int compare(float a, float b);
+int compare(double a, double b);
+int compare(const char* a, const char* b);
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline int compare(int a, int b)
+{
+  return a - b;
+}
+
+inline int compare(short a, short b)
+{
+  return a - b;
+}
+
+inline int compare(char a, char b)
+{
+  return a - b;
+}
+
+inline int compare(unsigned long a, unsigned long b)
+{
+  return (a < b)? -1 : (a > b)? 1 : 0;
+}
+
+inline int compare(unsigned int a, unsigned int b)
+{
+  return (a < b)? -1 : (a > b)? 1 : 0;
+}
+
+inline int compare(unsigned short a, unsigned short b)
+{
+  return (a < b)? -1 : (a > b)? 1 : 0;
+}
+
+inline int compare(unsigned char a, unsigned char b)
+{
+  return (a < b)? -1 : (a > b)? 1 : 0;
+}
+
+inline int compare(float a, float b)
+{
+  return (a < b)? -1 : (a > b)? 1 : 0;
+}
+
+inline int compare(double a, double b)
+{
+  return (a < b)? -1 : (a > b)? 1 : 0;
+}
+
+inline int compare(const char* a, const char* b)
+{
+  return strcmp(a,b);
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/complex.h b/usr/include/g++/complex.h
new file mode 100644 (file)
index 0000000..1411c22
--- /dev/null
@@ -0,0 +1,9 @@
+#ifndef _complex_h
+#ifdef __GNUG__
+#pragma once
+#endif
+#define _complex_h
+#define __ATT_complex__
+#include <Complex.h>
+typedef class Complex complex;
+#endif
diff --git a/usr/include/g++/curses.h b/usr/include/g++/curses.h
new file mode 100644 (file)
index 0000000..6a4d61c
--- /dev/null
@@ -0,0 +1,342 @@
+// This may look like C code, but it is really -*- C++ -*-
+
+/* 
+Copyright (C) 1989 Free Software Foundation
+    written by Eric Newton (newton@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+/*
+ * Edited for compatablity with C++, 2/28/89 <ecn>
+ * This file has all the /usr/include/curses.h info (with proper prototypes)
+ * used for the CursesWindow classes.  You may need to change this to be
+ * compatable with your curses implementation.
+ *
+ */
+
+#ifndef _curses_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _curses_h
+
+# include   <stddef.h>
+# include   <std.h>
+# include   <stdio.h> 
+extern "C" {
+#ifndef VMS
+# include   <sgtty.h>
+#endif
+
+// protection against possibility that these are macros:
+
+#ifndef stty
+extern int stty(int, struct sgttyb*); 
+#endif
+
+#ifndef gtty
+extern int gtty(int, struct sgttyb*); 
+#endif
+
+}
+
+typedef char cbool; // curses explicitly declares bools as chars
+
+#if defined(hpux)
+enum CursesStatus { ERR = -1, OK = 0 };                // curses lib uses define's
+#else
+enum CursesStatus { ERR = 0, OK = 1 };         // curses lib uses define's
+#endif
+
+/*
+ *  BSD'ish.  Warning!!
+ *
+ */
+# define    _ENDLINE    001
+# define    _FULLWIN    002
+# define    _SCROLLWIN  004
+# define    _FLUSH      010
+# define    _FULLLINE   020
+# define    _IDLINE     040
+# define    _STANDOUT   0200
+# define    _NOCHANGE   -1
+
+# define    _puts(s)    tputs(s, 0, _putchar)
+
+/*
+ * Capabilities from termcap
+ */
+
+extern cbool     AM, BS, CA, DA, DB, EO, HC, HZ, IN, MI, MS, NC, NS, OS, UL,
+        XB, XN, XT, XS, XX;
+extern char *AL, *BC, *BT, *CD, *CE, *CL, *CM, *CR, *CS, *DC, *DL,
+        *DM, *DO, *ED, *EI, *K0, *K1, *K2, *K3, *K4, *K5, *K6,
+        *K7, *K8, *K9, *HO, *IC, *IM, *IP, *KD, *KE, *KH, *KL,
+        *KR, *KS, *KU, *LL, *MA, *ND, *NL, *RC, *SC, *SE, *SF,
+        *SO, *SR, *TA, *TE, *TI, *UC, *UE, *UP, *US, *VB, *VS,
+        *VE, *AL_PARM, *DL_PARM, *UP_PARM, *DOWN_PARM,
+        *LEFT_PARM, *RIGHT_PARM;
+
+extern char PC;
+
+extern cbool    GT, NONL, UPPERCASE, normtty, _pfast;
+
+struct _win_st {
+#ifdef VMS
+    int                _cury, _curx;
+    int                _maxy, _maxx;
+    int                _begy, _begx;
+#else
+    short       _cury, _curx;
+    short       _maxy, _maxx;
+    short       _begy, _begx;
+#endif
+    short       _flags;
+#ifndef VMS
+    short       _ch_off;
+#endif
+    cbool       _clear;
+    cbool       _leave;
+    cbool       _scroll;
+#ifdef VMS
+    cbool      _wrap;
+#endif
+    char        **_y;
+    short       *_firstch;
+    short       *_lastch;
+    struct _win_st  *_nextp, *_orig;
+#ifdef VMS
+    struct _win_st  *_parent , *_child;
+    int                _id;
+#endif
+};
+
+#define WINDOW  struct _win_st
+
+extern cbool My_term;
+extern cbool _echoit;
+extern cbool _rawmode;
+extern cbool _endwin;
+
+extern char *Def_term;
+extern char  ttytype[];
+
+extern int  LINES;
+extern int  COLS; 
+extern int  _tty_ch;
+extern int  _res_flg;
+
+
+typedef struct sgttyb SGTTY;
+
+extern SGTTY _tty;
+
+/*
+ * standard curses functions.
+ *
+ */
+
+extern "C"
+{
+extern WINDOW * stdscr;
+extern WINDOW * curscr;
+WINDOW * newwin(int lines, int cols, int sy, int sx);
+WINDOW * subwin(WINDOW *w, int lines, int cols, int sy, int sx);
+WINDOW * initscr();
+int      box (WINDOW*, char, char);
+int      delwin(WINDOW*);
+int      mvcur(int, int, int, int);
+int      overlay(WINDOW*, WINDOW*);
+int      overwrite(WINDOW*, WINDOW*);
+int      scroll(WINDOW*);
+int      touchwin(WINDOW*);
+int      waddch(WINDOW*, char);
+int      waddstr(WINDOW*, const char*);
+int      wclear(WINDOW*);
+int      wclrtobot(WINDOW*);
+int      wclrtoeol(WINDOW*);
+int      wdelch(WINDOW*);
+int      wdeleteln(WINDOW*);
+int      werase(WINDOW*);
+int      wgetch(WINDOW*);
+int      wgetstr(WINDOW*, char*);
+int      winsch(WINDOW*, char);
+int      winsertln(WINDOW*);
+int      wmove(WINDOW*, int, int);
+int      wrefresh(WINDOW*);
+int      wstandend(WINDOW*);
+int      wstandout(WINDOW*);
+int      wprintw(WINDOW*, const char * fmt, ...);
+int      mvwprintw(WINDOW*, int y, int x, const char * fmt, ...);
+int      wscanw(WINDOW*, const char *, ...);
+int      mvwscanw(int, int, WINDOW*, const char*, ...);
+int      endwin();
+}
+
+/* Pseudo functions */
+/* 
+ * these are inlines rather than defines here so as to allow overloaded
+ * versions in the CursesWindow class
+ */
+
+int clearok(WINDOW* win, cbool bf);
+int leaveok(WINDOW* win, cbool bf);
+int scrollok(WINDOW* win, cbool bf);
+int flushok(WINDOW* win, cbool bf);
+void getyx(WINDOW* win, int& y, int& x);
+int winch(WINDOW* win);
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline int clearok(WINDOW* win, cbool bf)  { return(win->_clear = bf); }
+inline int leaveok(WINDOW* win, cbool bf)  { return(win->_leave = bf); }
+inline int scrollok(WINDOW* win, cbool bf) { return(win->_scroll = bf); }
+inline int flushok(WINDOW* win, cbool bf)  
+{ return(bf ? (win->_flags |= _FLUSH):(win->_flags &= ~_FLUSH)); }
+inline void getyx(WINDOW* win, int& y, int& x)   
+{ y = win->_cury; x = win->_curx; }
+inline int winch(WINDOW* win)   
+{return  win->_y[win->_cury][win->_curx] & 0177; }
+
+#endif /* __OPTIMIZE__ */
+
+#if defined(USG) || defined(VMS)
+extern "C" {
+int raw();
+int noraw();
+int cbreak();
+int nocbreak();
+}
+
+#else
+
+int raw();
+int noraw();
+int cbreak();
+int nocbreak();
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline int raw()    
+{ return _tty.sg_flags|=RAW, _pfast=_rawmode=1, stty(_tty_ch,&_tty); }
+inline int noraw()  
+{ return _tty.sg_flags&=~RAW,_rawmode=0,_pfast=!(_tty.sg_flags&CRMOD),stty(_tty_ch,&_tty); }
+inline int cbreak() 
+{ return _tty.sg_flags |= CBREAK, _rawmode = 1, stty(_tty_ch,&_tty); }
+inline int nocbreak() 
+{ return _tty.sg_flags &= ~CBREAK,_rawmode=0,stty(_tty_ch,&_tty); }
+
+#endif /* __ OPTIMIZE __ */
+
+#endif /* USG */
+
+
+int crmode();
+int nocrmode();
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline int crmode() { return  cbreak(); }
+inline int nocrmode() { return  nocbreak(); }
+
+#endif /* __ OPTIMIZE __ */
+
+#if defined(USG) || defined(VMS)
+
+extern "C" {
+int _setecho(int);
+int _setnonl(int);
+}
+
+int echo();
+int noecho();
+int nl();
+int nonl();
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline int echo()   { return _setecho(1); }
+inline int noecho() { return _setecho(0); }
+inline int nl()     { return _setnonl(0); }
+inline int nonl()   { return _setnonl(1); }
+
+#endif /* __ OPTIMIZE __ */
+
+extern "C" {
+int savetty();
+int resetty();
+int erasechar();
+int killchar();
+int baudrate();
+}
+
+#else /* not USG */
+
+int echo();
+int noecho();
+int nl();
+int nonl();
+int savetty();
+inline int resetty();
+int erasechar();
+int killchar();
+int baudrate();
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline int echo()   
+{ return _tty.sg_flags |= ECHO, _echoit = 1, stty(_tty_ch, &_tty); }
+inline int noecho() 
+{ return _tty.sg_flags &= ~ECHO, _echoit = 0, stty(_tty_ch, &_tty); }
+inline int nl()     
+{ return _tty.sg_flags |= CRMOD,_pfast = _rawmode,stty(_tty_ch, &_tty); }
+inline int nonl()   
+{ return _tty.sg_flags &= ~CRMOD, _pfast = 1, stty(_tty_ch, &_tty); }
+inline int savetty() 
+{ return (void) gtty(_tty_ch, &_tty), _res_flg = _tty.sg_flags; }
+inline int resetty() 
+{ return _tty.sg_flags = _res_flg, stty(_tty_ch, &_tty); }
+inline int erasechar() 
+{ return _tty.sg_erase; }
+inline int killchar()  
+{ return _tty.sg_kill; }
+inline int baudrate()  
+{ return _tty.sg_ospeed; }
+
+#endif /* __ OPTIMIZE __ */
+
+#endif /* USG */
+
+extern "C" {
+char *longname(char *, char *);
+char *getcap(char *);
+extern char *_unctrl[];
+}
+
+
+char * unctrl(int c);
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline char * unctrl(int c) {  return _unctrl[(c) & 0177]; }
+
+#endif /* __ OPTIMIZE __ */
+
+#endif
diff --git a/usr/include/g++/file.h b/usr/include/g++/file.h
new file mode 100644 (file)
index 0000000..ca11245
--- /dev/null
@@ -0,0 +1,8 @@
+
+#ifndef file_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#include <sys/file.h>
+#endif
diff --git a/usr/include/g++/filebuf.h b/usr/include/g++/filebuf.h
new file mode 100644 (file)
index 0000000..9cf35cc
--- /dev/null
@@ -0,0 +1,63 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _filebuf_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _filebuf_h 1
+
+#include <streambuf.h>
+#include <stdio.h>
+
+class filebuf: public streambuf
+{
+public:
+  int         fd;
+  char        opened;
+
+  int         overflow(int c = EOF);
+  int         underflow();
+
+              filebuf();
+              filebuf(int newfd);
+              filebuf(int newfd, char* buf, int buflen);
+              filebuf(const char* filename, io_mode m, access_mode a);
+              filebuf(const char* filename, const char* m);   
+              filebuf(int filedesc, io_mode m);
+              filebuf(FILE* fileptr);
+
+             ~filebuf();
+
+  streambuf*  open(const char* name, open_mode m);
+  streambuf*  open(const char* filename, io_mode m, access_mode a);
+  streambuf*  open(const char* filename, const char* m);
+  streambuf*  open(int  filedesc, io_mode m);
+  streambuf*  open(FILE* fileptr);
+  int         is_open();
+  int         close();
+};
+
+
+#endif
diff --git a/usr/include/g++/gen/AVLMap.ccP b/usr/include/g++/gen/AVLMap.ccP
new file mode 100644 (file)
index 0000000..12b52f5
--- /dev/null
@@ -0,0 +1,608 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include <assert.h>
+#include "<T>.<C>.AVLMap.h"
+
+
+/*
+ constants & inlines for maintaining balance & thread status in tree nodes
+*/
+
+#define AVLBALANCEMASK    3
+#define AVLBALANCED       0
+#define AVLLEFTHEAVY      1
+#define AVLRIGHTHEAVY     2
+
+#define LTHREADBIT        4
+#define RTHREADBIT        8
+
+
+static inline int bf(<T><C>AVLNode* t)
+{
+  return t->stat & AVLBALANCEMASK;
+}
+
+static inline void set_bf(<T><C>AVLNode* t, int b)
+{
+  t->stat = (t->stat & ~AVLBALANCEMASK) | (b & AVLBALANCEMASK);
+}
+
+
+static inline int rthread(<T><C>AVLNode* t)
+{
+  return t->stat & RTHREADBIT;
+}
+
+static inline void set_rthread(<T><C>AVLNode* t, int b)
+{
+  if (b)
+    t->stat |= RTHREADBIT;
+  else
+    t->stat &= ~RTHREADBIT;
+}
+
+static inline int lthread(<T><C>AVLNode* t)
+{
+  return t->stat & LTHREADBIT;
+}
+
+static inline void set_lthread(<T><C>AVLNode* t, int b)
+{
+  if (b)
+    t->stat |= LTHREADBIT;
+  else
+    t->stat &= ~LTHREADBIT;
+}
+
+/*
+ traversal primitives
+*/
+
+
+<T><C>AVLNode* <T><C>AVLMap::leftmost()
+{
+  <T><C>AVLNode* t = root;
+  if (t != 0) while (t->lt != 0) t = t->lt;
+  return t;
+}
+
+<T><C>AVLNode* <T><C>AVLMap::rightmost()
+{
+  <T><C>AVLNode* t = root;
+  if (t != 0) while (t->rt != 0) t = t->rt;
+  return t;
+}
+
+<T><C>AVLNode* <T><C>AVLMap::succ(<T><C>AVLNode* t)
+{
+  <T><C>AVLNode* r = t->rt;
+  if (!rthread(t)) while (!lthread(r)) r = r->lt;
+  return r;
+}
+
+<T><C>AVLNode* <T><C>AVLMap::pred(<T><C>AVLNode* t)
+{
+  <T><C>AVLNode* l = t->lt;
+  if (!lthread(t)) while (!rthread(l)) l = l->rt;
+  return l;
+}
+
+
+Pix <T><C>AVLMap::seek(<T&> key)
+{
+  <T><C>AVLNode* t = root;
+  if (t == 0)
+    return 0;
+  for (;;)
+  {
+    int cmp = <T>CMP(key, t->item);
+    if (cmp == 0)
+      return Pix(t);
+    else if (cmp < 0)
+    {
+      if (lthread(t))
+        return 0;
+      else
+        t = t->lt;
+    }
+    else if (rthread(t))
+      return 0;
+    else
+      t = t->rt;
+  }
+}
+
+
+/*
+ The combination of threads and AVL bits make adding & deleting
+ interesting, but very awkward.
+
+ We use the following statics to avoid passing them around recursively
+*/
+
+static int _need_rebalancing;   // to send back balance info from rec. calls
+static <T>*   _target_item;     // add/del_item target
+static <T><C>AVLNode* _found_node; // returned added/deleted node
+static int    _already_found;   // for deletion subcases
+
+
+void <T><C>AVLMap:: _add(<T><C>AVLNode*& t)
+{
+  int cmp = <T>CMP(*_target_item, t->item);
+  if (cmp == 0)
+  {
+    _found_node = t;
+    return;
+  }
+  else if (cmp < 0)
+  {
+    if (lthread(t))
+    {
+      ++count;
+      _found_node = new <T><C>AVLNode(*_target_item, def);
+      set_lthread(_found_node, 1);
+      set_rthread(_found_node, 1);
+      _found_node->lt = t->lt;
+      _found_node->rt = t;
+      t->lt = _found_node;
+      set_lthread(t, 0);
+      _need_rebalancing = 1;
+    }
+    else
+      _add(t->lt);
+    if (_need_rebalancing)
+    {
+      switch(bf(t))
+      {
+      case AVLRIGHTHEAVY:
+        set_bf(t, AVLBALANCED);
+        _need_rebalancing = 0;
+        return;
+      case AVLBALANCED:
+        set_bf(t, AVLLEFTHEAVY);
+        return;
+      case AVLLEFTHEAVY:
+        <T><C>AVLNode* l = t->lt;
+        if (bf(l) == AVLLEFTHEAVY)
+        {
+          if (rthread(l))
+            t->lt = l;
+          else
+            t->lt = l->rt;
+          set_lthread(t, rthread(l));
+          l->rt = t;
+          set_rthread(l, 0);
+          set_bf(t, AVLBALANCED);
+          set_bf(l, AVLBALANCED);
+          t = l;
+          _need_rebalancing = 0;
+        }
+        else
+        {
+          <T><C>AVLNode* r = l->rt;
+          set_rthread(l, lthread(r));
+          if (lthread(r))
+            l->rt = r;
+          else
+            l->rt = r->lt;
+          r->lt = l;
+          set_lthread(r, 0);
+          set_lthread(t, rthread(r));
+          if (rthread(r))
+            t->lt = r;
+          else
+            t->lt = r->rt;
+          r->rt = t;
+          set_rthread(r, 0);
+          if (bf(r) == AVLLEFTHEAVY)
+            set_bf(t, AVLRIGHTHEAVY);
+          else
+            set_bf(t, AVLBALANCED);
+          if (bf(r) == AVLRIGHTHEAVY)
+            set_bf(l, AVLLEFTHEAVY);
+          else
+            set_bf(l, AVLBALANCED);
+          set_bf(r, AVLBALANCED);
+          t = r;
+          _need_rebalancing = 0;
+          return;
+        }
+      }
+    }
+  }
+  else
+  {
+    if (rthread(t))
+    {
+      ++count;
+      _found_node = new <T><C>AVLNode(*_target_item, def);
+      set_rthread(t, 0);
+      set_lthread(_found_node, 1);
+      set_rthread(_found_node, 1);
+      _found_node->lt = t;
+      _found_node->rt = t->rt;
+      t->rt = _found_node;
+      _need_rebalancing = 1;
+    }
+    else
+      _add(t->rt);
+    if (_need_rebalancing)
+    {
+      switch(bf(t))
+      {
+      case AVLLEFTHEAVY:
+        set_bf(t, AVLBALANCED);
+        _need_rebalancing = 0;
+        return;
+      case AVLBALANCED:
+        set_bf(t, AVLRIGHTHEAVY);
+        return;
+      case AVLRIGHTHEAVY:
+        <T><C>AVLNode* r = t->rt;
+        if (bf(r) == AVLRIGHTHEAVY)
+        {
+          if (lthread(r))
+            t->rt = r;
+          else
+            t->rt = r->lt;
+          set_rthread(t, lthread(r));
+          r->lt = t;
+          set_lthread(r, 0);
+          set_bf(t, AVLBALANCED);
+          set_bf(r, AVLBALANCED);
+          t = r;
+          _need_rebalancing = 0;
+        }
+        else
+        {
+          <T><C>AVLNode* l = r->lt;
+          set_lthread(r, rthread(l));
+          if (rthread(l))
+            r->lt = l;
+          else
+            r->lt = l->rt;
+          l->rt = r;
+          set_rthread(l, 0);
+          set_rthread(t, lthread(l));
+          if (lthread(l))
+            t->rt = l;
+          else
+            t->rt = l->lt;
+          l->lt = t;
+          set_lthread(l, 0);
+          if (bf(l) == AVLRIGHTHEAVY)
+            set_bf(t, AVLLEFTHEAVY);
+          else
+            set_bf(t, AVLBALANCED);
+          if (bf(l) == AVLLEFTHEAVY)
+            set_bf(r, AVLRIGHTHEAVY);
+          else
+            set_bf(r, AVLBALANCED);
+          set_bf(l, AVLBALANCED);
+          t = l;
+          _need_rebalancing = 0;
+          return;
+        }
+      }
+    }
+  }
+}
+
+    
+<C>& <T><C>AVLMap::operator [] (<T&> item)
+{
+  if (root == 0)
+  {
+    ++count;
+    root = new <T><C>AVLNode(item, def);
+    set_rthread(root, 1);
+    set_lthread(root, 1);
+    return root->cont;
+  }
+  else
+  {
+    _target_item = &item;
+    _need_rebalancing = 0;
+    _add(root);
+    return _found_node->cont;
+  }
+}
+
+
+void <T><C>AVLMap::_del(<T><C>AVLNode* par, <T><C>AVLNode*& t)
+{
+  int comp;
+  if (_already_found)
+  {
+    if (rthread(t))
+      comp = 0;
+    else
+      comp = 1;
+  }
+  else 
+    comp = <T>CMP(*_target_item, t->item);
+  if (comp == 0)
+  {
+    if (lthread(t) && rthread(t))
+    {
+      _found_node = t;
+      if (t == par->lt)
+      {
+        set_lthread(par, 1);
+        par->lt = t->lt;
+      }
+      else
+      {
+        set_rthread(par, 1);
+        par->rt = t->rt;
+      }
+      _need_rebalancing = 1;
+      return;
+    }
+    else if (lthread(t))
+    {
+      _found_node = t;
+      <T><C>AVLNode* s = succ(t);
+      if (s != 0 && lthread(s))
+        s->lt = t->lt;
+      t = t->rt;
+      _need_rebalancing = 1;
+      return;
+    }
+    else if (rthread(t))
+    {
+      _found_node = t;
+      <T><C>AVLNode* p = pred(t);
+      if (p != 0 && rthread(p))
+        p->rt = t->rt;
+      t = t->lt;
+      _need_rebalancing = 1;
+      return;
+    }
+    else                        // replace item & find someone deletable
+    {
+      <T><C>AVLNode* p = pred(t);
+      t->item = p->item;
+      t->cont = p->cont;
+      _already_found = 1;
+      comp = -1;                // fall through below to left
+    }
+  }
+
+  if (comp < 0)
+  {
+    if (lthread(t))
+      return;
+    _del(t, t->lt);
+    if (!_need_rebalancing)
+      return;
+    switch (bf(t))
+    {
+    case AVLLEFTHEAVY:
+      set_bf(t, AVLBALANCED);
+      return;
+    case AVLBALANCED:
+      set_bf(t, AVLRIGHTHEAVY);
+      _need_rebalancing = 0;
+      return;
+    case AVLRIGHTHEAVY:
+      <T><C>AVLNode* r = t->rt;
+      switch (bf(r))
+      {
+      case AVLBALANCED:
+        if (lthread(r))
+          t->rt = r;
+        else
+          t->rt = r->lt;
+        set_rthread(t, lthread(r));
+        r->lt = t;
+        set_lthread(r, 0);
+        set_bf(t, AVLRIGHTHEAVY);
+        set_bf(r, AVLLEFTHEAVY);
+        _need_rebalancing = 0;
+        t = r;
+        return;
+      case AVLRIGHTHEAVY:
+        if (lthread(r))
+          t->rt = r;
+        else
+          t->rt = r->lt;
+        set_rthread(t, lthread(r));
+        r->lt = t;
+        set_lthread(r, 0);
+        set_bf(t, AVLBALANCED);
+        set_bf(r, AVLBALANCED);
+        t = r;
+        return;
+      case AVLLEFTHEAVY:
+        <T><C>AVLNode* l = r->lt;
+        set_lthread(r, rthread(l));
+        if (rthread(l))
+          r->lt = l;
+        else
+          r->lt = l->rt;
+        l->rt = r;
+        set_rthread(l, 0);
+        set_rthread(t, lthread(l));
+        if (lthread(l))
+          t->rt = l;
+        else
+          t->rt = l->lt;
+        l->lt = t;
+        set_lthread(l, 0);
+        if (bf(l) == AVLRIGHTHEAVY)
+          set_bf(t, AVLLEFTHEAVY);
+        else
+          set_bf(t, AVLBALANCED);
+        if (bf(l) == AVLLEFTHEAVY)
+          set_bf(r, AVLRIGHTHEAVY);
+        else
+          set_bf(r, AVLBALANCED);
+        set_bf(l, AVLBALANCED);
+        t = l;
+        return;
+      }
+    }
+  }
+  else
+  {
+    if (rthread(t))
+      return;
+    _del(t, t->rt);
+    if (!_need_rebalancing)
+      return;
+    switch (bf(t))
+    {
+    case AVLRIGHTHEAVY:
+      set_bf(t, AVLBALANCED);
+      return;
+    case AVLBALANCED:
+      set_bf(t, AVLLEFTHEAVY);
+      _need_rebalancing = 0;
+      return;
+    case AVLLEFTHEAVY:
+      <T><C>AVLNode* l = t->lt;
+      switch (bf(l))
+      {
+      case AVLBALANCED:
+        if (rthread(l))
+          t->lt = l;
+        else
+          t->lt = l->rt;
+        set_lthread(t, rthread(l));
+        l->rt = t;
+        set_rthread(l, 0);
+        set_bf(t, AVLLEFTHEAVY);
+        set_bf(l, AVLRIGHTHEAVY);
+        _need_rebalancing = 0;
+        t = l;
+        return;
+      case AVLLEFTHEAVY:
+        if (rthread(l))
+          t->lt = l;
+        else
+          t->lt = l->rt;
+        set_lthread(t, rthread(l));
+        l->rt = t;
+        set_rthread(l, 0);
+        set_bf(t, AVLBALANCED);
+        set_bf(l, AVLBALANCED);
+        t = l;
+        return;
+      case AVLRIGHTHEAVY:
+        <T><C>AVLNode* r = l->rt;
+        set_rthread(l, lthread(r));
+        if (lthread(r))
+          l->rt = r;
+        else
+          l->rt = r->lt;
+        r->lt = l;
+        set_lthread(r, 0);
+        set_lthread(t, rthread(r));
+        if (rthread(r))
+          t->lt = r;
+        else
+          t->lt = r->rt;
+        r->rt = t;
+        set_rthread(r, 0);
+        if (bf(r) == AVLLEFTHEAVY)
+          set_bf(t, AVLRIGHTHEAVY);
+        else
+          set_bf(t, AVLBALANCED);
+        if (bf(r) == AVLRIGHTHEAVY)
+          set_bf(l, AVLLEFTHEAVY);
+        else
+          set_bf(l, AVLBALANCED);
+        set_bf(r, AVLBALANCED);
+        t = r;
+        return;
+      }
+    }
+  }
+}
+
+        
+
+void <T><C>AVLMap::del(<T&> item)
+{
+  if (root == 0) return;
+  _need_rebalancing = 0;
+  _already_found = 0;
+  _found_node = 0;
+  _target_item = &item;
+  _del(root, root);
+  if (_found_node)
+  {
+    delete(_found_node);
+    if (--count == 0)
+      root = 0;
+  }
+}
+
+void <T><C>AVLMap::_kill(<T><C>AVLNode* t)
+{
+  if (t != 0)
+  {
+    if (!lthread(t)) _kill(t->lt);
+    if (!rthread(t)) _kill(t->rt);
+    delete t;
+  }
+}
+
+
+<T><C>AVLMap::<T><C>AVLMap(<T><C>AVLMap& b) :<T><C>Map(b.def)
+{
+  root = 0;
+  count = 0;
+  for (Pix i = b.first(); i != 0; b.next(i)) 
+    (*this)[b.key(i)] = b.contents(i);
+}
+
+
+int <T><C>AVLMap::OK()
+{
+  int v = 1;
+  if (root == 0) 
+    v = count == 0;
+  else
+  {
+    int n = 1;
+    <T><C>AVLNode* trail = leftmost();
+    <T><C>AVLNode* t = succ(trail);
+    while (t != 0)
+    {
+      ++n;
+      v &= <T>CMP(trail->item, t->item) < 0;
+      trail = t;
+      t = succ(t);
+    }
+    v &= n == count;
+  }
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/AVLMap.hP b/usr/include/g++/gen/AVLMap.hP
new file mode 100644 (file)
index 0000000..cbf0ffb
--- /dev/null
@@ -0,0 +1,157 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T><C>AVLMap_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T><C>AVLMap_h 1
+
+#include "<T>.<C>.Map.h"
+
+struct <T><C>AVLNode
+{
+  <T><C>AVLNode*      lt;
+  <T><C>AVLNode*      rt;
+  <T>                 item;
+  <C>                 cont;
+  char                stat;
+                      <T><C>AVLNode(<T&> h, <C&> c, 
+                                    <T><C>AVLNode* l=0, <T><C>AVLNode* r=0);
+                      ~<T><C>AVLNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T><C>AVLNode::<T><C>AVLNode(<T&> h, <C&> c, 
+                                    <T><C>AVLNode* l, <T><C>AVLNode* r)
+     :item(h), cont(c), lt(l), rt(r), stat(0) {}
+
+inline <T><C>AVLNode::~<T><C>AVLNode() {}
+
+#endif
+
+typedef <T><C>AVLNode* <T><C>AVLNodePtr;
+
+
+class <T><C>AVLMap : public <T><C>Map
+{
+protected:
+  <T><C>AVLNode*   root;
+
+  <T><C>AVLNode*   leftmost();
+  <T><C>AVLNode*   rightmost();
+  <T><C>AVLNode*   pred(<T><C>AVLNode* t);
+  <T><C>AVLNode*   succ(<T><C>AVLNode* t);
+  void            _kill(<T><C>AVLNode* t);
+  void            _add(<T><C>AVLNode*& t);
+  void            _del(<T><C>AVLNode* p, <T><C>AVLNode*& t);
+
+public:
+                <T><C>AVLMap(<C&> dflt);
+                <T><C>AVLMap(<T><C>AVLMap& a);
+                ~<T><C>AVLMap();
+
+  <C>&          operator [] (<T&> key);
+
+  void          del(<T&> key);
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          key(Pix i);
+  <C>&          contents(Pix i);
+
+  Pix           seek(<T&> key);
+  int           contains(<T&> key);
+
+  void          clear(); 
+
+  Pix           last();
+  void          prev(Pix& i);
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T><C>AVLMap::~<T><C>AVLMap()
+{
+  _kill(root);
+}
+
+inline <T><C>AVLMap::<T><C>AVLMap(<C&> dflt) :(dflt)
+{
+  root = 0;
+}
+
+
+inline Pix <T><C>AVLMap::first()
+{
+  return Pix(leftmost());
+}
+
+inline Pix <T><C>AVLMap::last()
+{
+  return Pix(rightmost());
+}
+
+inline void <T><C>AVLMap::next(Pix& i)
+{
+  if (i != 0) i = Pix(succ((<T><C>AVLNode*)i));
+}
+
+inline void <T><C>AVLMap::prev(Pix& i)
+{
+  if (i != 0) i = Pix(pred((<T><C>AVLNode*)i));
+}
+
+inline <T>& <T><C>AVLMap::key(Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T><C>AVLNode*)i)->item;
+}
+
+inline <C>& <T><C>AVLMap::contents(Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T><C>AVLNode*)i)->cont;
+}
+
+inline void <T><C>AVLMap::clear()
+{
+  _kill(root);
+  count = 0;
+  root = 0;
+}
+
+inline int <T><C>AVLMap::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/AVLSet.ccP b/usr/include/g++/gen/AVLSet.ccP
new file mode 100644 (file)
index 0000000..ee43325
--- /dev/null
@@ -0,0 +1,885 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include <assert.h>
+#include "<T>.AVLSet.h"
+
+
+/*
+ constants & inlines for maintaining balance & thread status in tree nodes
+*/
+
+#define AVLBALANCEMASK    3
+#define AVLBALANCED       0
+#define AVLLEFTHEAVY      1
+#define AVLRIGHTHEAVY     2
+
+#define LTHREADBIT        4
+#define RTHREADBIT        8
+
+
+static inline int bf(<T>AVLNode* t)
+{
+  return t->stat & AVLBALANCEMASK;
+}
+
+static inline void set_bf(<T>AVLNode* t, int b)
+{
+  t->stat = (t->stat & ~AVLBALANCEMASK) | (b & AVLBALANCEMASK);
+}
+
+
+static inline int rthread(<T>AVLNode* t)
+{
+  return t->stat & RTHREADBIT;
+}
+
+static inline void set_rthread(<T>AVLNode* t, int b)
+{
+  if (b)
+    t->stat |= RTHREADBIT;
+  else
+    t->stat &= ~RTHREADBIT;
+}
+
+static inline int lthread(<T>AVLNode* t)
+{
+  return t->stat & LTHREADBIT;
+}
+
+static inline void set_lthread(<T>AVLNode* t, int b)
+{
+  if (b)
+    t->stat |= LTHREADBIT;
+  else
+    t->stat &= ~LTHREADBIT;
+}
+
+/*
+ traversal primitives
+*/
+
+
+<T>AVLNode* <T>AVLSet::leftmost()
+{
+  <T>AVLNode* t = root;
+  if (t != 0) while (t->lt != 0) t = t->lt;
+  return t;
+}
+
+<T>AVLNode* <T>AVLSet::rightmost()
+{
+  <T>AVLNode* t = root;
+  if (t != 0) while (t->rt != 0) t = t->rt;
+  return t;
+}
+
+<T>AVLNode* <T>AVLSet::succ(<T>AVLNode* t)
+{
+  <T>AVLNode* r = t->rt;
+  if (!rthread(t)) while (!lthread(r)) r = r->lt;
+  return r;
+}
+
+<T>AVLNode* <T>AVLSet::pred(<T>AVLNode* t)
+{
+  <T>AVLNode* l = t->lt;
+  if (!lthread(t)) while (!rthread(l)) l = l->rt;
+  return l;
+}
+
+
+Pix <T>AVLSet::seek(<T&> key)
+{
+  <T>AVLNode* t = root;
+  if (t == 0)
+    return 0;
+  for (;;)
+  {
+    int cmp = <T>CMP(key, t->item);
+    if (cmp == 0)
+      return Pix(t);
+    else if (cmp < 0)
+    {
+      if (lthread(t))
+        return 0;
+      else
+        t = t->lt;
+    }
+    else if (rthread(t))
+      return 0;
+    else
+      t = t->rt;
+  }
+}
+
+
+/*
+ The combination of threads and AVL bits make adding & deleting
+ interesting, but very awkward.
+
+ We use the following statics to avoid passing them around recursively
+*/
+
+static int _need_rebalancing;   // to send back balance info from rec. calls
+static <T>*   _target_item;     // add/del_item target
+static <T>AVLNode* _found_node; // returned added/deleted node
+static int    _already_found;   // for deletion subcases
+
+static <T>AVLNode** _hold_nodes;       // used for rebuilding trees
+static int  _max_hold_index;              // # elements-1 in _hold_nodes
+
+
+void <T>AVLSet:: _add(<T>AVLNode*& t)
+{
+  int cmp = <T>CMP(*_target_item, t->item);
+  if (cmp == 0)
+  {
+    _found_node = t;
+    return;
+  }
+  else if (cmp < 0)
+  {
+    if (lthread(t))
+    {
+      ++count;
+      _found_node = new <T>AVLNode(*_target_item);
+      set_lthread(_found_node, 1);
+      set_rthread(_found_node, 1);
+      _found_node->lt = t->lt;
+      _found_node->rt = t;
+      t->lt = _found_node;
+      set_lthread(t, 0);
+      _need_rebalancing = 1;
+    }
+    else
+      _add(t->lt);
+    if (_need_rebalancing)
+    {
+      switch(bf(t))
+      {
+      case AVLRIGHTHEAVY:
+        set_bf(t, AVLBALANCED);
+        _need_rebalancing = 0;
+        return;
+      case AVLBALANCED:
+        set_bf(t, AVLLEFTHEAVY);
+        return;
+      case AVLLEFTHEAVY:
+        <T>AVLNode* l = t->lt;
+        if (bf(l) == AVLLEFTHEAVY)
+        {
+          if (rthread(l))
+            t->lt = l;
+          else
+            t->lt = l->rt;
+          set_lthread(t, rthread(l));
+          l->rt = t;
+          set_rthread(l, 0);
+          set_bf(t, AVLBALANCED);
+          set_bf(l, AVLBALANCED);
+          t = l;
+          _need_rebalancing = 0;
+        }
+        else
+        {
+          <T>AVLNode* r = l->rt;
+          set_rthread(l, lthread(r));
+          if (lthread(r))
+            l->rt = r;
+          else
+            l->rt = r->lt;
+          r->lt = l;
+          set_lthread(r, 0);
+          set_lthread(t, rthread(r));
+          if (rthread(r))
+            t->lt = r;
+          else
+            t->lt = r->rt;
+          r->rt = t;
+          set_rthread(r, 0);
+          if (bf(r) == AVLLEFTHEAVY)
+            set_bf(t, AVLRIGHTHEAVY);
+          else
+            set_bf(t, AVLBALANCED);
+          if (bf(r) == AVLRIGHTHEAVY)
+            set_bf(l, AVLLEFTHEAVY);
+          else
+            set_bf(l, AVLBALANCED);
+          set_bf(r, AVLBALANCED);
+          t = r;
+          _need_rebalancing = 0;
+          return;
+        }
+      }
+    }
+  }
+  else
+  {
+    if (rthread(t))
+    {
+      ++count;
+      _found_node = new <T>AVLNode(*_target_item);
+      set_rthread(t, 0);
+      set_lthread(_found_node, 1);
+      set_rthread(_found_node, 1);
+      _found_node->lt = t;
+      _found_node->rt = t->rt;
+      t->rt = _found_node;
+      _need_rebalancing = 1;
+    }
+    else
+      _add(t->rt);
+    if (_need_rebalancing)
+    {
+      switch(bf(t))
+      {
+      case AVLLEFTHEAVY:
+        set_bf(t, AVLBALANCED);
+        _need_rebalancing = 0;
+        return;
+      case AVLBALANCED:
+        set_bf(t, AVLRIGHTHEAVY);
+        return;
+      case AVLRIGHTHEAVY:
+        <T>AVLNode* r = t->rt;
+        if (bf(r) == AVLRIGHTHEAVY)
+        {
+          if (lthread(r))
+            t->rt = r;
+          else
+            t->rt = r->lt;
+          set_rthread(t, lthread(r));
+          r->lt = t;
+          set_lthread(r, 0);
+          set_bf(t, AVLBALANCED);
+          set_bf(r, AVLBALANCED);
+          t = r;
+          _need_rebalancing = 0;
+        }
+        else
+        {
+          <T>AVLNode* l = r->lt;
+          set_lthread(r, rthread(l));
+          if (rthread(l))
+            r->lt = l;
+          else
+            r->lt = l->rt;
+          l->rt = r;
+          set_rthread(l, 0);
+          set_rthread(t, lthread(l));
+          if (lthread(l))
+            t->rt = l;
+          else
+            t->rt = l->lt;
+          l->lt = t;
+          set_lthread(l, 0);
+          if (bf(l) == AVLRIGHTHEAVY)
+            set_bf(t, AVLLEFTHEAVY);
+          else
+            set_bf(t, AVLBALANCED);
+          if (bf(l) == AVLLEFTHEAVY)
+            set_bf(r, AVLRIGHTHEAVY);
+          else
+            set_bf(r, AVLBALANCED);
+          set_bf(l, AVLBALANCED);
+          t = l;
+          _need_rebalancing = 0;
+          return;
+        }
+      }
+    }
+  }
+}
+
+    
+Pix <T>AVLSet::add(<T&> item)
+{
+  if (root == 0)
+  {
+    ++count;
+    root = new <T>AVLNode(item);
+    set_rthread(root, 1);
+    set_lthread(root, 1);
+    return Pix(root);
+  }
+  else
+  {
+    _target_item = &item;
+    _need_rebalancing = 0;
+    _add(root);
+    return Pix(_found_node);
+  }
+}
+
+
+void <T>AVLSet::_del(<T>AVLNode* par, <T>AVLNode*& t)
+{
+  int comp;
+  if (_already_found)
+  {
+    if (rthread(t))
+      comp = 0;
+    else
+      comp = 1;
+  }
+  else 
+    comp = <T>CMP(*_target_item, t->item);
+  if (comp == 0)
+  {
+    if (lthread(t) && rthread(t))
+    {
+      _found_node = t;
+      if (t == par->lt)
+      {
+        set_lthread(par, 1);
+        par->lt = t->lt;
+      }
+      else
+      {
+        set_rthread(par, 1);
+        par->rt = t->rt;
+      }
+      _need_rebalancing = 1;
+      return;
+    }
+    else if (lthread(t))
+    {
+      _found_node = t;
+      <T>AVLNode* s = succ(t);
+      if (s != 0 && lthread(s))
+        s->lt = t->lt;
+      t = t->rt;
+      _need_rebalancing = 1;
+      return;
+    }
+    else if (rthread(t))
+    {
+      _found_node = t;
+      <T>AVLNode* p = pred(t);
+      if (p != 0 && rthread(p))
+        p->rt = t->rt;
+      t = t->lt;
+      _need_rebalancing = 1;
+      return;
+    }
+    else                        // replace item & find someone deletable
+    {
+      <T>AVLNode* p = pred(t);
+      t->item = p->item;
+      _already_found = 1;
+      comp = -1;                // fall through below to left
+    }
+  }
+
+  if (comp < 0)
+  {
+    if (lthread(t))
+      return;
+    _del(t, t->lt);
+    if (!_need_rebalancing)
+      return;
+    switch (bf(t))
+    {
+    case AVLLEFTHEAVY:
+      set_bf(t, AVLBALANCED);
+      return;
+    case AVLBALANCED:
+      set_bf(t, AVLRIGHTHEAVY);
+      _need_rebalancing = 0;
+      return;
+    case AVLRIGHTHEAVY:
+      <T>AVLNode* r = t->rt;
+      switch (bf(r))
+      {
+      case AVLBALANCED:
+        if (lthread(r))
+          t->rt = r;
+        else
+          t->rt = r->lt;
+        set_rthread(t, lthread(r));
+        r->lt = t;
+        set_lthread(r, 0);
+        set_bf(t, AVLRIGHTHEAVY);
+        set_bf(r, AVLLEFTHEAVY);
+        _need_rebalancing = 0;
+        t = r;
+        return;
+      case AVLRIGHTHEAVY:
+        if (lthread(r))
+          t->rt = r;
+        else
+          t->rt = r->lt;
+        set_rthread(t, lthread(r));
+        r->lt = t;
+        set_lthread(r, 0);
+        set_bf(t, AVLBALANCED);
+        set_bf(r, AVLBALANCED);
+        t = r;
+        return;
+      case AVLLEFTHEAVY:
+        <T>AVLNode* l = r->lt;
+        set_lthread(r, rthread(l));
+        if (rthread(l))
+          r->lt = l;
+        else
+          r->lt = l->rt;
+        l->rt = r;
+        set_rthread(l, 0);
+        set_rthread(t, lthread(l));
+        if (lthread(l))
+          t->rt = l;
+        else
+          t->rt = l->lt;
+        l->lt = t;
+        set_lthread(l, 0);
+        if (bf(l) == AVLRIGHTHEAVY)
+          set_bf(t, AVLLEFTHEAVY);
+        else
+          set_bf(t, AVLBALANCED);
+        if (bf(l) == AVLLEFTHEAVY)
+          set_bf(r, AVLRIGHTHEAVY);
+        else
+          set_bf(r, AVLBALANCED);
+        set_bf(l, AVLBALANCED);
+        t = l;
+        return;
+      }
+    }
+  }
+  else
+  {
+    if (rthread(t))
+      return;
+    _del(t, t->rt);
+    if (!_need_rebalancing)
+      return;
+    switch (bf(t))
+    {
+    case AVLRIGHTHEAVY:
+      set_bf(t, AVLBALANCED);
+      return;
+    case AVLBALANCED:
+      set_bf(t, AVLLEFTHEAVY);
+      _need_rebalancing = 0;
+      return;
+    case AVLLEFTHEAVY:
+      <T>AVLNode* l = t->lt;
+      switch (bf(l))
+      {
+      case AVLBALANCED:
+        if (rthread(l))
+          t->lt = l;
+        else
+          t->lt = l->rt;
+        set_lthread(t, rthread(l));
+        l->rt = t;
+        set_rthread(l, 0);
+        set_bf(t, AVLLEFTHEAVY);
+        set_bf(l, AVLRIGHTHEAVY);
+        _need_rebalancing = 0;
+        t = l;
+        return;
+      case AVLLEFTHEAVY:
+        if (rthread(l))
+          t->lt = l;
+        else
+          t->lt = l->rt;
+        set_lthread(t, rthread(l));
+        l->rt = t;
+        set_rthread(l, 0);
+        set_bf(t, AVLBALANCED);
+        set_bf(l, AVLBALANCED);
+        t = l;
+        return;
+      case AVLRIGHTHEAVY:
+        <T>AVLNode* r = l->rt;
+        set_rthread(l, lthread(r));
+        if (lthread(r))
+          l->rt = r;
+        else
+          l->rt = r->lt;
+        r->lt = l;
+        set_lthread(r, 0);
+        set_lthread(t, rthread(r));
+        if (rthread(r))
+          t->lt = r;
+        else
+          t->lt = r->rt;
+        r->rt = t;
+        set_rthread(r, 0);
+        if (bf(r) == AVLLEFTHEAVY)
+          set_bf(t, AVLRIGHTHEAVY);
+        else
+          set_bf(t, AVLBALANCED);
+        if (bf(r) == AVLRIGHTHEAVY)
+          set_bf(l, AVLLEFTHEAVY);
+        else
+          set_bf(l, AVLBALANCED);
+        set_bf(r, AVLBALANCED);
+        t = r;
+        return;
+      }
+    }
+  }
+}
+
+        
+
+void <T>AVLSet::del(<T&> item)
+{
+  if (root == 0) return;
+  _need_rebalancing = 0;
+  _already_found = 0;
+  _found_node = 0;
+  _target_item = &item;
+  _del(root, root);
+  if (_found_node)
+  {
+    delete(_found_node);
+    if (--count == 0)
+      root = 0;
+  }
+}
+
+// build an ordered array of pointers to tree nodes back into a tree
+// we know that at least one element exists
+
+static <T>AVLNode* _do_treeify(int lo, int hi, int& h)
+{
+  int lh, rh;
+  int mid = (lo + hi) / 2;
+  <T>AVLNode* t = _hold_nodes[mid];
+  if (lo > mid - 1)
+  {
+    set_lthread(t, 1);
+    if (mid == 0)
+      t->lt = 0;
+    else
+      t->lt = _hold_nodes[mid-1];
+    lh = 0;
+  }
+  else
+  {
+    set_lthread(t, 0);
+    t->lt = _do_treeify(lo, mid-1, lh);
+  }
+  if (hi < mid + 1)
+  {
+    set_rthread(t, 1);
+    if (mid == _max_hold_index)
+      t->rt = 0;
+    else
+      t->rt = _hold_nodes[mid+1];
+    rh = 0;
+  }
+  else 
+  {
+    set_rthread(t, 0);
+    t->rt = _do_treeify(mid+1, hi, rh);
+  }
+  if (lh == rh)
+  {
+    set_bf(t, AVLBALANCED);
+    h = lh + 1;
+  }
+  else if (lh == rh - 1)
+  {
+    set_bf(t, AVLRIGHTHEAVY);
+    h = rh + 1;
+  }
+  else if (rh == lh - 1)
+  {
+    set_bf(t, AVLLEFTHEAVY);
+    h = lh + 1;
+  }
+  else                          // can't happen
+    abort();
+
+  return t;
+}
+
+static <T>AVLNode* _treeify(int n)
+{
+  <T>AVLNode* t;
+  if (n == 0)
+    t = 0;
+  else
+  {
+    int b;
+    _max_hold_index = n-1;
+    t = _do_treeify(0, _max_hold_index, b);
+  }
+  delete _hold_nodes;
+  return t;
+}
+
+
+void <T>AVLSet::_kill(<T>AVLNode* t)
+{
+  if (t != 0)
+  {
+    if (!lthread(t)) _kill(t->lt);
+    if (!rthread(t)) _kill(t->rt);
+    delete t;
+  }
+}
+
+
+<T>AVLSet::<T>AVLSet(<T>AVLSet& b)
+{
+  if ((count = b.count) == 0)
+  {
+    root = 0;
+  }
+  else
+  {
+    _hold_nodes = new <T>AVLNodePtr [count];
+    <T>AVLNode* t = b.leftmost();
+    int i = 0;
+    while (t != 0)
+    {
+      _hold_nodes[i++] = new <T>AVLNode(t->item);
+      t = b.succ(t);
+    }
+    root = _treeify(count);
+  }
+}
+
+
+int <T>AVLSet::operator == (<T>AVLSet& y)
+{
+  if (count != y.count)
+    return 0;
+  else
+  {
+    <T>AVLNode* t = leftmost();
+    <T>AVLNode* u = y.leftmost();
+    for (;;)
+    {
+      if (t == 0)
+        return 1;
+      else if (!(<T>EQ(t->item, u->item)))
+        return 0;
+      else
+      {
+        t = succ(t);
+        u = y.succ(u);
+      }
+    }
+  }
+}
+
+int <T>AVLSet::operator <= (<T>AVLSet& y)
+{
+  if (count > y.count)
+    return 0;
+  else
+  {
+    <T>AVLNode* t = leftmost();
+    <T>AVLNode* u = y.leftmost();
+    for (;;)
+    {
+      if (t == 0)
+        return 1;
+      else if (u == 0)
+        return 0;
+      int cmp = <T>CMP(t->item, u->item);
+      if (cmp == 0)
+      {
+        t = succ(t);
+        u = y.succ(u);
+      }
+      else if (cmp < 0)
+        return 0;
+      else
+        u = y.succ(u);
+    }
+  }
+}
+
+void <T>AVLSet::operator |=(<T>AVLSet& y)
+{
+  <T>AVLNode* t = leftmost();
+  <T>AVLNode* u = y.leftmost();
+  int rsize = count + y.count;
+  _hold_nodes = new <T>AVLNodePtr [rsize];
+  int k = 0;
+  for (;;)
+  {
+    if (t == 0)
+    {
+      while (u != 0)
+      {
+        _hold_nodes[k++] = new <T>AVLNode(u->item);
+        u = y.succ(u);
+      }
+      break;
+    }
+    else if (u == 0)
+    {
+      while (t != 0)
+      {
+        _hold_nodes[k++] = t;
+        t = succ(t);
+      }
+      break;
+    }
+    int cmp = <T>CMP(t->item, u->item);
+    if (cmp == 0)
+    {
+      _hold_nodes[k++] = t;
+      t = succ(t);
+      u = y.succ(u);
+    }
+    else if (cmp < 0)
+    {
+      _hold_nodes[k++] = t;
+      t = succ(t);
+    }
+    else
+    {
+      _hold_nodes[k++] = new <T>AVLNode(u->item);
+      u = y.succ(u);
+    }
+  }
+  root = _treeify(k);
+  count = k;
+}
+
+void <T>AVLSet::operator &= (<T>AVLSet& y)
+{
+  <T>AVLNode* t = leftmost();
+  <T>AVLNode* u = y.leftmost();
+  int rsize = (count < y.count)? count : y.count;
+  _hold_nodes = new <T>AVLNodePtr [rsize];
+  int k = 0;
+  for (;;)
+  {
+    if (t == 0)
+      break;
+    if (u == 0)
+    {
+      while (t != 0)
+      {
+        <T>AVLNode* tmp = succ(t);
+        delete t;
+        t = tmp;
+      }
+      break;
+    }
+    int cmp = <T>CMP(t->item, u->item);
+    if (cmp == 0)
+    {
+      _hold_nodes[k++] = t;
+      t = succ(t);
+      u = y.succ(u);
+    }
+    else if (cmp < 0)
+    {
+      <T>AVLNode* tmp = succ(t);
+      delete t;
+      t = tmp;
+    }
+    else
+      u = y.succ(u);
+  }
+  root = _treeify(k);
+  count = k;
+}
+
+
+void <T>AVLSet::operator -=(<T>AVLSet& y)
+{
+  <T>AVLNode* t = leftmost();
+  <T>AVLNode* u = y.leftmost();
+  int rsize = count;
+  _hold_nodes = new <T>AVLNodePtr [rsize];
+  int k = 0;
+  for (;;)
+  {
+    if (t == 0)
+      break;
+    else if (u == 0)
+    {
+      while (t != 0)
+      {
+        _hold_nodes[k++] = t;
+        t = succ(t);
+      }
+      break;
+    }
+    int cmp = <T>CMP(t->item, u->item);
+    if (cmp == 0)
+    {
+      <T>AVLNode* tmp = succ(t);
+      delete t;
+      t = tmp;
+      u = y.succ(u);
+    }
+    else if (cmp < 0)
+    {
+      _hold_nodes[k++] = t;
+      t = succ(t);
+    }
+    else
+      u = y.succ(u);
+  }
+  root = _treeify(k);
+  count = k;
+}
+
+int <T>AVLSet::owns(Pix i)
+{
+  if (i == 0) return 0;
+  for (<T>AVLNode* t = leftmost(); t != 0; t = succ(t)) 
+    if (Pix(t) == i) return 1;
+  return 0;
+}
+
+int <T>AVLSet::OK()
+{
+  int v = 1;
+  if (root == 0) 
+    v = count == 0;
+  else
+  {
+    int n = 1;
+    <T>AVLNode* trail = leftmost();
+    <T>AVLNode* t = succ(trail);
+    while (t != 0)
+    {
+      ++n;
+      v &= <T>CMP(trail->item, t->item) < 0;
+      trail = t;
+      t = succ(t);
+    }
+    v &= n == count;
+  }
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/AVLSet.hP b/usr/include/g++/gen/AVLSet.hP
new file mode 100644 (file)
index 0000000..b9adfb4
--- /dev/null
@@ -0,0 +1,167 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>AVL_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>AVL_h 1
+
+#include "<T>.Set.h"
+
+struct <T>AVLNode
+{
+  <T>AVLNode*         lt;
+  <T>AVLNode*         rt;
+  <T>                 item;
+  char                stat;
+                      <T>AVLNode(<T&> h, <T>AVLNode* l=0, <T>AVLNode* r=0);
+                      ~<T>AVLNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>AVLNode::<T>AVLNode(<T&> h, <T>AVLNode* l, <T>AVLNode* r)
+:item(h), lt(l), rt(r), stat(0) {}
+
+inline <T>AVLNode::~<T>AVLNode() {}
+
+#endif
+
+typedef <T>AVLNode* <T>AVLNodePtr;
+
+
+class <T>AVLSet : public <T>Set
+{
+protected:
+  <T>AVLNode*   root;
+
+                <T>AVLSet(<T>AVLNode* p, int l);
+
+  <T>AVLNode*   leftmost();
+  <T>AVLNode*   rightmost();
+  <T>AVLNode*   pred(<T>AVLNode* t);
+  <T>AVLNode*   succ(<T>AVLNode* t);
+  void          _kill(<T>AVLNode* t);
+  void          _add(<T>AVLNode*& t);
+  void          _del(<T>AVLNode* p, <T>AVLNode*& t);
+
+public:
+                <T>AVLSet();
+                <T>AVLSet(<T>AVLSet& a);
+                ~<T>AVLSet();
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  int           owns(Pix i);
+  Pix           seek(<T&> item);
+
+  Pix           last();
+  void          prev(Pix& i);
+
+  void          operator |= (<T>AVLSet& b);
+  void          operator -= (<T>AVLSet& b);
+  void          operator &= (<T>AVLSet& b);
+
+  int           operator == (<T>AVLSet& b);
+  int           operator != (<T>AVLSet& b);
+  int           operator <= (<T>AVLSet& b); 
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>AVLSet::~<T>AVLSet()
+{
+  _kill(root);
+}
+
+inline <T>AVLSet::<T>AVLSet()
+{
+  root = 0;
+  count = 0;
+}
+
+inline <T>AVLSet::<T>AVLSet(<T>AVLNode* p, int l)
+{
+  root = p;
+  count = l;
+}
+
+inline int <T>AVLSet::operator != (<T>AVLSet& b)
+{
+  return ! ((*this) == b);
+}
+
+inline Pix <T>AVLSet::first()
+{
+  return Pix(leftmost());
+}
+
+inline Pix <T>AVLSet::last()
+{
+  return Pix(rightmost());
+}
+
+inline void <T>AVLSet::next(Pix& i)
+{
+  if (i != 0) i = Pix(succ((<T>AVLNode*)i));
+}
+
+inline void <T>AVLSet::prev(Pix& i)
+{
+  if (i != 0) i = Pix(pred((<T>AVLNode*)i));
+}
+
+inline <T>& <T>AVLSet::operator () (Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T>AVLNode*)i)->item;
+}
+
+inline void <T>AVLSet::clear()
+{
+  _kill(root);
+  count = 0;
+  root = 0;
+}
+
+inline int <T>AVLSet::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/AVec.ccP b/usr/include/g++/gen/AVec.ccP
new file mode 100644 (file)
index 0000000..e2f4034
--- /dev/null
@@ -0,0 +1,401 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include "<T>.AVec.h"
+
+/*
+ The following brought to you by the department of redundancy department
+*/
+
+<T>AVec& <T>AVec::operator = (<T>AVec& v)
+{
+  if (len != 0 && len != v.capacity())
+    error("nonconformant vectors.");
+  if (len == 0)
+    s = new <T> [len = v.capacity()];
+  if (s != v.vec())
+  {
+    for (int i = 0; i < len; ++i)
+      s[i] = v.vec()[i];
+  }
+  return *this;
+}
+
+<T>AVec& <T>AVec::operator = (<T&> f)
+{
+  for (int i = 0; i < len; ++i) s[i] = f;
+  return *this;
+}
+
+
+<T>AVec concat(<T>AVec & a, <T>AVec & b)
+{
+  int newl = a.capacity() + b.capacity();
+  <T>* news = new <T> [newl];
+  <T>* p = news;
+  <T>* top = &(a.vec()[a.capacity()]);
+  <T>* t = a.vec();
+  while (t < top) *p++ = *t++;
+  top = &(b.vec()[b.capacity()]);
+  t = b.vec();
+  while (t < top) *p++ = *t++;
+  return <T>AVec(newl, news);
+}
+
+
+<T>AVec combine(<T>Combiner f, <T>AVec& a, <T>AVec& b)
+{
+  int newl = (a.capacity() < b.capacity())? a.capacity() : b.capacity();
+  <T>* news = new <T> [newl];
+  <T>* p = news;
+  <T>* top = &(a.vec()[newl]);
+  <T>* t = a.vec();
+  <T>* u = b.vec();
+  while (t < top) *p++ = (*f)(*t++, *u++);
+  return <T>AVec(newl, news);
+}
+
+<T>AVec reverse(<T>AVec& a)
+{
+  <T>* news = new <T> [a.capacity()];
+  if (a.capacity() != 0)
+  {
+    <T>* lo = news;
+    <T>* hi = &(news[a.capacity() - 1]);
+    while (lo < hi)
+    {
+      <T> tmp = *lo;
+      *lo++ = *hi;
+      *hi-- = tmp;
+    }
+  }
+  return <T>AVec(a.capacity(), news);
+}
+
+<T>AVec map(<T>Mapper f, <T>AVec& a)
+{
+  <T>* news = new <T> [a.capacity()];
+  <T>* p = news;
+  <T>* top = &(a.vec()[a.capacity()]);
+  <T>* t = a.vec();
+  while(t < top) *p++ = (*f)(*t++);
+  return <T>AVec(a.capacity(), news);
+}
+
+<T>AVec <T>AVec::at(int from, int n)
+{
+  int to;
+  if (n < 0)
+  {
+    n = len - from;
+    to = len - 1;
+  }
+  else
+    to = from + n - 1;
+  if ((unsigned)from > to)
+    range_error();
+  <T>* news = new <T> [n];
+  <T>* p = news;
+  <T>* t = &(s[from]);
+  <T>* top = &(s[to]);
+  while (t <= top) *p++ = *t++;
+  return <T>AVec(n, news);
+}
+
+<T>AVec merge(<T>AVec & a, <T>AVec & b, <T>Comparator f)
+{
+  int newl = a.capacity() + b.capacity();
+  <T>* news = new <T> [newl];
+  <T>* p = news;
+  <T>* topa = &(a.vec()[a.capacity()]);
+  <T>* as = a.vec();
+  <T>* topb = &(b.vec()[b.capacity()]);
+  <T>* bs = b.vec();
+
+  for (;;)
+  {
+    if (as >= topa)
+    {
+      while (bs < topb) *p++ = *bs++;
+      break;
+    }
+    else if (bs >= topb)
+    {
+      while (as < topa) *p++ = *as++;
+      break;
+    }
+    else if ((*f)(*as, *bs) <= 0)
+      *p++ = *as++;
+    else
+      *p++ = *bs++;
+  }
+  return <T>AVec(newl, news);
+}
+
+<T>AVec operator + (<T>AVec& a, <T>AVec& b)
+{
+  a.check_len(b.capacity());
+  <T>* news = new <T> [a.capacity()];
+  <T>* p = news;
+  <T>* top = &(a.vec()[a.capacity()]);
+  <T>* t = a.vec();
+  <T>* u = b.vec();
+  while (t < top) *p++ = *t++ + *u++;
+  return <T>AVec(a.capacity(), news);
+}
+
+<T>AVec operator - (<T>AVec& a, <T>AVec& b)
+{
+  a.check_len(b.capacity());
+  <T>* news = new <T> [a.capacity()];
+  <T>* p = news;
+  <T>* top = &(a.vec()[a.capacity()]);
+  <T>* t = a.vec();
+  <T>* u = b.vec();
+  while (t < top) *p++ = *t++ - *u++;
+  return <T>AVec(a.capacity(), news);
+}
+
+<T>AVec  product (<T>AVec& a, <T>AVec& b)
+{
+  a.check_len(b.capacity());
+  <T>* news = new <T> [a.capacity()];
+  <T>* p = news;
+  <T>* top = &(a.vec()[a.capacity()]);
+  <T>* t = a.vec();
+  <T>* u = b.vec();
+  while (t < top) *p++ = *t++ * *u++;
+  return <T>AVec(a.capacity(), news);
+}
+
+<T>AVec quotient(<T>AVec& a, <T>AVec& b)
+{
+  a.check_len(b.capacity());
+  <T>* news = new <T> [a.capacity()];
+  <T>* p = news;
+  <T>* top = &(a.vec()[a.capacity()]);
+  <T>* t = a.vec();
+  <T>* u = b.vec();
+  while (t < top) *p++ = *t++ / *u++;
+  return <T>AVec(a.capacity(), news);
+}
+
+<T>AVec operator + (<T>AVec& a, <T&> b)
+{
+  <T>* news = new <T> [a.capacity()];
+  <T>* p = news;
+  <T>* top = &(a.vec()[a.capacity()]);
+  <T>* t = a.vec();
+  while (t < top) *p++ = *t++ + b;
+  return <T>AVec(a.capacity(), news);
+}
+
+<T>AVec operator - (<T>AVec& a, <T&> b)
+{
+  <T>* news = new <T> [a.capacity()];
+  <T>* p = news;
+  <T>* top = &(a.vec()[a.capacity()]);
+  <T>* t = a.vec();
+  while (t < top) *p++ = *t++ - b;
+  return <T>AVec(a.capacity(), news);
+}
+
+<T>AVec operator * (<T>AVec& a, <T&> b)
+{
+  <T>* news = new <T> [a.capacity()];
+  <T>* p = news;
+  <T>* top = &(a.vec()[a.capacity()]);
+  <T>* t = a.vec();
+  while (t < top) *p++ = *t++ * b;
+  return <T>AVec(a.capacity(), news);
+}
+
+<T>AVec operator / (<T>AVec& a, <T&> b)
+{
+  <T>* news = new <T> [a.capacity()];
+  <T>* p = news;
+  <T>* top = &(a.vec()[a.capacity()]);
+  <T>* t = a.vec();
+  while (t < top) *p++ = *t++ / b;
+  return <T>AVec(a.capacity(), news);
+}
+
+<T>AVec <T>AVec::operator - ()
+{
+  <T>* news = new <T> [len];
+  <T>* p = news;
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) *p++ = -(*t++);
+  return <T>AVec(len, news);
+}
+
+<T>AVec& <T>AVec::operator += (<T>AVec& b)
+{
+  check_len(b.capacity());
+  <T>* u = b.vec();
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) *t++ += *u++;
+  return *this;
+}
+
+<T>AVec& <T>AVec::operator -= (<T>AVec& b)
+{
+  check_len(b.capacity());
+  <T>* u = b.vec();
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) *t++ -= *u++;
+  return *this;
+}
+
+<T>AVec& <T>AVec::product(<T>AVec& b)
+{
+  check_len(b.capacity());
+  <T>* u = b.vec();
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) *t++ *= *u++;
+  return *this;
+}
+
+<T>AVec& <T>AVec::quotient(<T>AVec& b)
+{
+  check_len(b.capacity());
+  <T>* u = b.vec();
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) *t++ /= *u++;
+  return *this;
+}
+
+<T>AVec& <T>AVec::operator += (<T&> b)
+{
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) *t++ += b;
+  return *this;
+}
+
+<T>AVec& <T>AVec::operator -= (<T&> b)
+{
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) *t++ -= b;
+  return *this;
+}
+
+<T>AVec& <T>AVec::operator *= (<T&> b)
+{
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) *t++ *= b;
+  return *this;
+}
+
+<T>AVec& <T>AVec::operator /= (<T&> b)
+{
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) *t++ /= b;
+  return *this;
+}
+
+<T> <T>AVec::max()
+{
+  if (len == 0)
+    return 0;
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  <T> res = *t++;
+  for (; t < top; ++t) if (*t > res) res = *t;
+  return res;
+}
+
+int <T>AVec::max_index()
+{
+  if (len == 0)
+    return -1;
+  int ind = 0;
+  for (int i = 1; i < len; ++i)
+    if (s[i] > s[ind])
+      ind = i;
+  return ind;
+}
+
+<T> <T>AVec::min()
+{
+  if (len == 0)
+    return 0;
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  <T> res = *t++;
+  for (; t < top; ++t) if (*t < res) res = *t;
+  return res;
+}
+
+int <T>AVec::min_index()
+{
+  if (len == 0)
+    return -1;
+  int ind = 0;
+  for (int i = 1; i < len; ++i)
+    if (s[i] < s[ind])
+      ind = i;
+  return ind;
+}
+
+<T> <T>AVec::sum()
+{
+  <T> res = 0;
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) res += *t++;
+  return res;
+}
+
+
+<T> <T>AVec::sumsq()
+{
+  <T> res = 0;
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  for (; t < top; ++t) res += *t * *t;
+  return res;
+}
+
+<T> operator * (<T>AVec& a, <T>AVec& b)
+{
+  a.check_len(b.capacity());
+  <T>* top = &(a.vec()[a.capacity()]);
+  <T>* t = a.vec();
+  <T>* u = b.vec();
+  <T> res = 0;
+  while (t < top) res += *t++ * *u++;
+  return res;
+}
diff --git a/usr/include/g++/gen/AVec.hP b/usr/include/g++/gen/AVec.hP
new file mode 100644 (file)
index 0000000..9c57d20
--- /dev/null
@@ -0,0 +1,123 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>AVec_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>AVec_h 1
+
+#include "<T>.Vec.h"
+
+class <T>AVec : public <T>Vec
+{
+protected:
+  void                  check_len(int l);
+  <T>*                  vec();
+                        <T>AVec(int l, <T>* d);
+  public:
+                        <T>AVec ();
+                        <T>AVec (int l);
+                        <T>AVec (int l, <T&> fill_value);
+                        <T>AVec (<T>AVec&);
+                        ~<T>AVec ();
+
+  <T>AVec&              operator =  (<T>AVec& a);
+  <T>AVec&              operator =  (<T&> fill_value);
+
+// vector by scalar -> vector operations
+
+  friend <T>AVec        operator +  (<T>AVec& a, <T&> b);
+  friend <T>AVec        operator -  (<T>AVec& a, <T&> b);
+  friend <T>AVec        operator *  (<T>AVec& a, <T&> b);
+  friend <T>AVec        operator /  (<T>AVec& a, <T&> b);
+
+  <T>AVec&              operator += (<T&> b);
+  <T>AVec&              operator -= (<T&> b);
+  <T>AVec&              operator *= (<T&> b);
+  <T>AVec&              operator /= (<T&> b);
+
+// vector by vector -> vector operations
+
+  friend <T>AVec        operator +  (<T>AVec& a, <T>AVec& b);
+  friend <T>AVec        operator -  (<T>AVec& a, <T>AVec& b);
+  <T>AVec&              operator += (<T>AVec& b);
+  <T>AVec&              operator -= (<T>AVec& b);
+
+  <T>AVec               operator - ();
+
+  friend <T>AVec        product(<T>AVec& a, <T>AVec& b);
+  <T>AVec&              product(<T>AVec& b);
+  friend <T>AVec        quotient(<T>AVec& a, <T>AVec& b);
+  <T>AVec&              quotient(<T>AVec& b);
+
+// vector -> scalar operations
+
+  friend <T>            operator * (<T>AVec& a, <T>AVec& b);
+
+  <T>                   sum();
+  <T>                   min();
+  <T>                   max();
+  <T>                   sumsq();
+
+// indexing
+
+  int                   min_index();
+  int                   max_index();
+
+// redundant but necesssary
+  friend <T>AVec        concat(<T>AVec& a, <T>AVec& b);
+  friend <T>AVec        map(<T>Mapper f, <T>AVec& a);
+  friend <T>AVec        merge(<T>AVec& a, <T>AVec& b, <T>Comparator f);
+  friend <T>AVec        combine(<T>Combiner f, <T>AVec& a, <T>AVec& b);
+  friend <T>AVec        reverse(<T>AVec& a);
+  <T>AVec               at(int from = 0, int n = -1);
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>AVec::<T>AVec() {}
+inline <T>AVec::<T>AVec(int l) :<T>Vec(l) {}
+inline <T>AVec::<T>AVec(int l, <T&> fill_value) : <T>Vec (l, fill_value) {}
+inline <T>AVec::<T>AVec(<T>AVec& v) :(v) {}
+inline <T>AVec::<T>AVec(int l, <T>* d) :<T>Vec(l, d) {}
+inline <T>AVec::~<T>AVec() {}
+
+
+inline <T>* <T>AVec::vec()
+{
+  return s;
+}
+
+
+inline void <T>AVec::check_len(int l)
+{
+  if (l != len)
+    error("nonconformant vectors.");
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/BSTSet.ccP b/usr/include/g++/gen/BSTSet.ccP
new file mode 100644 (file)
index 0000000..5edb1d6
--- /dev/null
@@ -0,0 +1,383 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include "<T>.BSTSet.h"
+
+
+/*
+ traversal primitives
+*/
+
+
+<T>BSTNode* <T>BSTSet::leftmost()
+{
+  <T>BSTNode* t = root;
+  if (t != 0) while (t->lt != 0) t = t->lt;
+  return t;
+}
+
+<T>BSTNode* <T>BSTSet::rightmost()
+{
+  <T>BSTNode* t = root;
+  if (t != 0) while (t->rt != 0) t = t->rt;
+  return t;
+}
+
+<T>BSTNode* <T>BSTSet::succ(<T>BSTNode* t)
+{
+  if (t == 0)
+    return 0;
+  if (t->rt != 0)
+  {
+    t = t->rt;
+    while (t->lt != 0) t = t->lt;
+    return t;
+  }
+  else
+  {
+    for (;;)
+    {
+      if (t->par == 0 || t == t->par->lt)
+        return t->par;
+      else
+        t = t->par;
+    }
+  }
+}
+
+<T>BSTNode* <T>BSTSet::pred(<T>BSTNode* t)
+{
+  if (t == 0)
+    return 0;
+  else if (t->lt != 0)
+  {
+    t = t->lt;
+    while (t->rt != 0) t = t->rt;
+    return t;
+  }
+  else
+  {
+    for (;;)
+    {
+      if (t->par == 0 || t == t->par->rt)
+        return t->par;
+      else
+        t = t->par;
+    }
+  }
+}
+
+
+Pix <T>BSTSet::seek(<T&> key)
+{
+  <T>BSTNode* t = root;
+  for (;;)
+  {
+    if (t == 0)
+      return 0;
+    int comp = <T>CMP(key, t->item);
+    if (comp == 0)
+      return Pix(t);
+    else if (comp < 0)
+      t = t->lt;
+    else
+      t = t->rt;
+  }
+}
+
+
+Pix <T>BSTSet::add(<T&> item)
+{
+  if (root == 0)
+  {
+    ++count;
+    root = new <T>BSTNode(item);
+    return Pix(root);
+  }
+
+  <T>BSTNode* t = root;
+  <T>BSTNode* p = root;
+  int comp;
+  for (;;)
+  {
+    if (t == 0)
+    {
+      ++count;
+      t = new <T>BSTNode(item);
+      if (comp > 0)
+        p->lt = t;
+      else
+        p->rt = t;
+      t->par = p;
+      return Pix(t);
+    }
+    p = t;
+    comp = <T>CMP(t->item, item);
+    if (comp == 0)
+      return Pix(t);
+    else if (comp > 0)
+      t = t->lt;
+    else
+      t = t->rt;
+  }
+}
+
+
+void <T>BSTSet::del(<T&> key)
+{
+  <T>BSTNode* t = root;
+  <T>BSTNode* p = root;
+  int comp;
+  for (;;)
+  {
+    if (t == 0)
+      return;
+    comp = <T>CMP(key, t->item);
+    if (comp == 0)
+    {
+      --count;
+      <T>BSTNode* repl;
+      if (t->lt == 0)
+        repl = t->rt;
+      else if (t->rt == 0)
+        repl = t->lt;
+      else
+      {
+        <T>BSTNode* prepl = t;
+        repl = t->lt;
+        while (repl->rt != 0)
+        {
+          prepl = repl;
+          repl = repl->rt;
+        }
+        if (prepl != t)
+        {
+          prepl->rt = repl->lt;
+          if (prepl->rt != 0) prepl->rt->par = prepl;
+          repl->lt = t->lt;
+          if (repl->lt != 0) repl->lt->par = repl;
+        }
+        repl->rt = t->rt;
+        if (repl->rt != 0) repl->rt->par = repl;
+      }
+      if (t == root)
+      {
+        root = repl;
+        if (repl != 0) repl->par = 0;
+      }
+      else
+      {
+        if (t == p->lt)
+          p->lt = repl;
+        else
+          p->rt = repl;
+        if (repl != 0) repl->par = p;
+      }
+      delete t;
+      return;
+    }
+    p = t;
+    if (comp < 0)
+      t = t->lt;
+    else
+      t = t->rt;
+  }
+}
+
+
+void <T>BSTSet::_kill(<T>BSTNode* t)
+{
+  if (t != 0)
+  {
+    _kill(t->lt);
+    _kill(t->rt);
+    delete t;
+  }
+}
+
+<T>BSTNode* <T>BSTSet::_copy(<T>BSTNode* t)
+{
+  if (t == 0)
+    return 0;
+  else
+  {
+    <T>BSTNode* u = new <T>BSTNode(t->item, _copy(t->lt), _copy(t->rt));
+    if (u->lt != 0) u->lt->par = u;
+    if (u->rt != 0) u->rt->par = u;
+    return u;
+  }
+}
+
+
+int <T>BSTSet::operator == (<T>BSTSet& y)
+{
+  if (count != y.count)
+    return 0;
+  else
+  {
+    <T>BSTNode* t = leftmost();
+    <T>BSTNode* u = y.leftmost();
+    for (;;)
+    {
+      if (t == 0)
+        return 1;
+      else if (!<T>EQ(t->item, u->item))
+        return 0;
+      else
+      {
+        t = succ(t);
+        u = y.succ(u);
+      }
+    }
+  }
+}
+
+int <T>BSTSet::operator <= (<T>BSTSet& y)
+{
+  if (count > y.count)
+    return 0;
+  else
+  {
+    <T>BSTNode* t = leftmost();
+    <T>BSTNode* u = y.leftmost();
+    for (;;)
+    {
+      if (t == 0)
+        return 1;
+      else if (u == 0)
+        return 0;
+      int cmp = <T>CMP(t->item, u->item);
+      if (cmp == 0)
+      {
+        t = succ(t);
+        u = y.succ(u);
+      }
+      else if (cmp < 0)
+        return 0;
+      else
+        u = y.succ(u);
+    }
+  }
+}
+
+
+// linear-time, zero space overhead binary tree rebalancing from
+// Stout & Warren, ``Tree rebalancing in linear space and time''
+// CACM, Sept, 1986, p902.
+
+
+void <T>BSTSet::balance()
+{
+  if (count <= 2) return; // don't bother -- 
+                          // also we assume non-null root, below
+
+  // make re-attaching the root easy via trickery
+
+  struct _fake_node { _fake_node *lt, *rt, *par; } fake_root;
+
+  fake_root.rt = (_fake_node*)root; 
+  fake_root.par = 0;
+  <T>BSTNode* pseudo_root = (<T>BSTNode*)&fake_root;
+
+  // phase 1: tree-to-vine
+
+  <T>BSTNode* vine_tail = pseudo_root;
+  <T>BSTNode* remainder = root;
+
+  while (remainder != 0)
+  {
+    if (remainder->lt == 0)
+    {
+      vine_tail = remainder;
+      remainder = remainder->rt;
+    }
+    else
+    {
+      <T>BSTNode* tmp = remainder->lt;
+      remainder->lt = tmp->rt;
+      if (remainder->lt != 0) remainder->lt->par = remainder;
+      tmp->rt = remainder;
+      remainder->par = tmp;
+      vine_tail->rt = remainder = tmp;
+    }
+  }
+
+  // phase 2: vine-to-tree
+  
+  // Uses the slightly simpler version adapted from
+  // Day ``Balancing a binary tree'' Computer Journal, Nov. 1976,
+  // since it's not generally important whether the `stray' leaves are
+  // on the left or on the right.
+
+  unsigned int spines = count - 1;
+  while (spines > 1)
+  {
+    int compressions = spines >> 1; // compress every other node
+    spines -= compressions + 1;     // halve for next time
+
+    <T>BSTNode* scanner = pseudo_root;
+    while (compressions-- > 0)
+    {
+      <T>BSTNode* child = scanner->rt;
+      <T>BSTNode* grandchild = child->rt;
+      scanner->rt = grandchild;
+      grandchild->par = scanner;
+      child->rt = grandchild->lt;
+      if (child->rt != 0) child->rt->par = child;
+      grandchild->lt = child;
+      child->par = grandchild;
+      scanner = grandchild;
+    }
+  }
+
+  root = pseudo_root->rt;
+  root->par = 0;
+}
+
+
+int <T>BSTSet::OK()
+{
+  int v = 1;
+  if (root == 0) 
+    v = count == 0;
+  else
+  {
+    int n = 1;
+    <T>BSTNode* trail = leftmost();
+    <T>BSTNode* t = succ(trail);
+    while (t != 0)
+    {
+      ++n;
+      v &= <T>CMP(trail->item, t->item) < 0;
+      trail = t;
+      t = succ(t);
+    }
+    v &= n == count;
+  }
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/BSTSet.hP b/usr/include/g++/gen/BSTSet.hP
new file mode 100644 (file)
index 0000000..4ac9f40
--- /dev/null
@@ -0,0 +1,166 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>BSTSet_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>BSTSet_h 1
+
+#include "<T>.Set.h"
+
+#ifndef _<T>BSTNode
+#define _<T>BSTNode 1
+
+struct <T>BSTNode
+{
+  <T>BSTNode*         lt;
+  <T>BSTNode*         rt;
+  <T>BSTNode*         par;
+  <T>                 item;
+                      <T>BSTNode(<T&> h, <T>BSTNode* l=0, <T>BSTNode* r=0,
+                                 <T>BSTNode* p = 0);
+                      ~<T>BSTNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>BSTNode::<T>BSTNode(<T&> h, <T>BSTNode* l, <T>BSTNode* r,
+                              <T>BSTNode* p)
+:item(h), lt(l), rt(r), par(p) {}
+
+inline <T>BSTNode::~<T>BSTNode() {}
+
+#endif
+
+typedef <T>BSTNode* <T>BSTNodePtr;
+
+#endif
+
+class <T>BSTSet : public <T>Set
+{
+protected:
+  <T>BSTNode*      root;
+
+  <T>BSTNode*     leftmost();
+  <T>BSTNode*     rightmost();
+  <T>BSTNode*     pred(<T>BSTNode* t);
+  <T>BSTNode*     succ(<T>BSTNode* t);
+  void            _kill(<T>BSTNode* t);
+  <T>BSTNode*     _copy(<T>BSTNode* t);
+
+public:
+                   <T>BSTSet();
+                   <T>BSTSet(<T>BSTSet& a);
+                   ~<T>BSTSet();
+
+  Pix             add(<T&> item);
+  void            del(<T&> item);
+  int             contains(<T&> item);
+
+  void            clear();
+
+  Pix             first();
+  void            next(Pix& i);
+  <T>&            operator () (Pix i);
+  Pix             seek(<T&> item);
+
+  Pix             last();
+  void            prev(Pix& i);
+
+  int             operator == (<T>BSTSet& b);
+  int             operator != (<T>BSTSet& b);
+  int             operator <= (<T>BSTSet& b); 
+
+  void            balance();
+  int             OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>BSTSet::~<T>BSTSet()
+{
+  _kill(root);
+}
+
+inline <T>BSTSet::<T>BSTSet()
+{
+  root = 0;
+  count = 0;
+}
+
+
+inline <T>BSTSet::<T>BSTSet(<T>BSTSet& a)
+{
+  count = a.count;
+  root = _copy(a.root);
+}
+
+inline int <T>BSTSet::operator != (<T>BSTSet& b)
+{
+  return ! (*this == b);
+}
+
+inline Pix <T>BSTSet::first()
+{
+  return Pix(leftmost());
+}
+
+inline Pix <T>BSTSet::last()
+{
+  return Pix(rightmost());
+}
+
+inline void <T>BSTSet::next(Pix& i)
+{
+  if (i != 0) i = Pix(succ((<T>BSTNode*)i));
+}
+
+inline void <T>BSTSet::prev(Pix& i)
+{
+  if (i != 0) i = Pix(pred((<T>BSTNode*)i));
+}
+
+inline <T>& <T>BSTSet::operator () (Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T>BSTNode*)i)->item;
+}
+
+inline void <T>BSTSet::clear()
+{
+  _kill(root);
+  count = 0;
+  root = 0;
+}
+
+inline int <T>BSTSet::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/Bag.ccP b/usr/include/g++/gen/Bag.ccP
new file mode 100644 (file)
index 0000000..694c9b7
--- /dev/null
@@ -0,0 +1,79 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <builtin.h>
+#include "<T>.Bag.h"
+
+// error handling
+
+void <T>Bag::error(const char* msg)
+{
+  (*lib_error_handler)("Bag", msg);
+}
+
+
+Pix <T>Bag::seek(<T&> item, Pix i)
+{
+  if (i == 0) 
+    i = first();
+  else
+    next(i);
+  for (;i != 0 && (!(<T>EQ((*this)(i), item))); next(i));
+  return i;
+}
+
+int <T>Bag::owns(Pix p)
+{
+  if (p == 0) return 0;
+  for (Pix i = first(); i != 0; next(i)) if (i == p) return 1;
+  return 0;
+}
+
+void <T>Bag::remove(<T&> item)
+{
+  int i = nof(item);
+  while (i-- > 0) del(item);
+}
+
+
+int <T>Bag::nof(<T&> item)
+{
+  int n = 0;
+  for (Pix p = first(); p; next(p)) if (<T>EQ((*this)(p), item)) ++n;
+  return n;
+}
+
+void <T>Bag::clear()
+{
+  Pix i = first(); 
+  while (i != 0)
+  {
+    del((*this)(i));
+    i = first();
+  }
+}
+
+
diff --git a/usr/include/g++/gen/Bag.hP b/usr/include/g++/gen/Bag.hP
new file mode 100644 (file)
index 0000000..af87a8b
--- /dev/null
@@ -0,0 +1,87 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>Bag_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>Bag_h 1
+
+#include <Pix.h>
+#include "<T>.defs.h"
+
+class <T>Bag
+{
+protected:
+  int                   count;
+
+public:
+  virtual              ~<T>Bag();
+
+  int                   length();                // current number of items
+  int                   empty();
+
+  virtual Pix           add(<T&> item) = 0;      // add item; return Pix
+
+  virtual void          del(<T&> item) = 0;      // delete 1 occurrence of item
+  virtual void          remove(<T&> item);       // delete all occurrences
+  virtual void          clear();                 // delete all items
+
+  virtual int           contains(<T&> item);     // is item in Bag?
+  virtual int           nof(<T&> item);          // how many in Bag?
+
+  virtual Pix           first() = 0;             // Pix of first item or 0
+  virtual void          next(Pix& i) = 0;        // advance to next or 0
+
+  virtual <T>&          operator () (Pix i) = 0; // access item at i
+
+  virtual Pix           seek(<T&> item, Pix from=0); // Pix of next occurrence
+  virtual int           owns(Pix i);             // is i a valid Pix  ?
+
+  void                  error(const char* msg);
+  virtual int           OK() = 0;                // rep invariant
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>Bag::~<T>Bag() {}
+
+inline int <T>Bag::length()
+{
+  return count;
+}
+
+inline int <T>Bag::empty()
+{
+  return count == 0;
+}
+
+inline int <T>Bag::contains(<T&> item)
+{
+  return seek(item) != 0;
+}
+#endif
+#endif
diff --git a/usr/include/g++/gen/CHBag.ccP b/usr/include/g++/gen/CHBag.ccP
new file mode 100644 (file)
index 0000000..b7f97ec
--- /dev/null
@@ -0,0 +1,214 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.CHBag.h"
+
+// The nodes are linked together serially via a version
+// of a trick used in some vtables: odd pointers are
+// actually links to the next table entry. 
+// Not terrible, but not wonderful either
+
+static inline int goodCHptr(<T>CHNode* t)
+{
+  return ((((unsigned)t) & 1) == 0);
+}
+
+static inline <T>CHNode* index_to_CHptr(int i)
+{
+  return (<T>CHNode*)((i << 1) + 1);
+}
+
+static inline int CHptr_to_index(<T>CHNode* t)
+{
+  return ( ((unsigned) t) >> 1);
+}
+
+<T>CHBag::<T>CHBag(unsigned int sz)
+{
+  tab = (<T>CHNode**)(new <T>CHNodePtr[size = sz]);
+  for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1);
+  count = 0;
+}
+
+<T>CHBag::<T>CHBag(<T>CHBag& a)
+{
+  tab = (<T>CHNode**)(new <T>CHNodePtr[size = a.size]);
+  for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1);
+  count = 0;
+  for (Pix p = a.first(); p; a.next(p)) add(a(p));
+}
+
+
+Pix <T>CHBag::seek(<T&> key, Pix i)
+{
+  <T>CHNode* p = (<T>CHNode*)i;
+  if (p == 0 || !<T>EQ(p->hd, key))
+  {
+    unsigned int h = <T>HASH(key) % size;
+    for (<T>CHNode* t = tab[h]; goodCHptr(t); t = t->tl)
+      if (<T>EQ(key, t->hd))
+        return Pix(t);
+  }
+  else
+  {
+    for (p = p->tl; goodCHptr(p); p = p->tl) 
+      if (<T>EQ(p->hd, key))
+        return Pix(p);
+  }
+  return 0;
+}
+
+int <T>CHBag::nof(<T&> key)
+{
+  int n = 0;
+  unsigned int h = <T>HASH(key) % size;
+  for (<T>CHNode* t = tab[h]; goodCHptr(t); t = t->tl) 
+    if (<T>EQ(key, t->hd)) ++n;
+  return n;
+}
+
+
+Pix <T>CHBag::add(<T&> item)
+{
+  unsigned int h = <T>HASH(item) % size;
+  <T>CHNode* t = new <T>CHNode(item);
+  t->tl = tab[h];
+  tab[h] = t;
+  ++count;
+  return Pix(t);
+}
+
+void <T>CHBag::del(<T&> key)
+{
+  unsigned int h = <T>HASH(key) % size;
+
+  <T>CHNode* t = tab[h]; 
+  <T>CHNode* trail = t;
+  while (goodCHptr(t))
+  {
+    if (<T>EQ(key, t->hd))
+    {
+      if (trail == t)
+        tab[h] = t->tl;
+      else
+        trail->tl = t->tl;
+      delete t;
+      --count;
+      return;
+    }
+    trail = t;
+    t = t->tl;
+  }
+}
+
+void <T>CHBag::remove(<T&> key)
+{
+  unsigned int h = <T>HASH(key) % size;
+
+  <T>CHNode* t = tab[h]; 
+  <T>CHNode* trail = t;
+  while (goodCHptr(t))
+  {
+    if (<T>EQ(key, t->hd))
+    {
+      --count;
+      if (trail == t)
+      {
+        tab[h] = t->tl;
+        delete t;
+        t = trail = tab[h];
+      }
+      else
+      {
+        trail->tl = t->tl;
+        delete t;
+        t = trail->tl;
+      }
+    }
+    else
+    {
+      trail = t;
+      t = t->tl;
+    }
+  }
+}
+
+
+void <T>CHBag::clear()
+{
+  for (unsigned int i = 0; i < size; ++i)
+  {
+    <T>CHNode* p = tab[i];
+    tab[i] = index_to_CHptr(i+1);
+    while (goodCHptr(p))
+    {
+      <T>CHNode* nxt = p->tl;
+      delete(p);
+      p = nxt;
+    }
+  }
+  count = 0;
+}
+
+Pix <T>CHBag::first()
+{
+  for (unsigned int i = 0; i < size; ++i) if (goodCHptr(tab[i])) return Pix(tab[i]);
+  return 0;
+}
+
+void <T>CHBag::next(Pix& p)
+{
+  if (p == 0) return;
+  <T>CHNode* t = ((<T>CHNode*)p)->tl;
+  if (goodCHptr(t))
+    p = Pix(t);
+  else
+  {
+    for (unsigned int i = CHptr_to_index(t); i < size; ++i) 
+    {
+      if (goodCHptr(tab[i]))
+      {
+        p =  Pix(tab[i]);
+        return;
+      }
+    }
+    p = 0;
+  }
+}
+
+int <T>CHBag::OK()
+{
+  int v = tab != 0;
+  int n = 0;
+  for (unsigned int i = 0; i < size; ++i)
+  {
+    for (<T>CHNode* p = tab[i]; goodCHptr(p); p = p->tl) ++n;
+    v &= CHptr_to_index(p) == i + 1;
+  }
+  v &= count == n;
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/CHBag.hP b/usr/include/g++/gen/CHBag.hP
new file mode 100644 (file)
index 0000000..5254f8f
--- /dev/null
@@ -0,0 +1,110 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>CHBag_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>CHBag_h 1
+
+#include "<T>.Bag.h"
+
+
+#ifndef _<T>CHNode_h
+#define _<T>CHNode_h 1
+
+struct <T>CHNode
+{
+  <T>CHNode*         tl;
+  <T>                hd;
+                     <T>CHNode();
+                     <T>CHNode(<T&> h, <T>CHNode* t = 0);
+                     ~<T>CHNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>CHNode::<T>CHNode() {}
+
+inline <T>CHNode::<T>CHNode(<T&> h, <T>CHNode* t) :hd(h), tl(t) {}
+
+inline <T>CHNode::~<T>CHNode() {}
+
+#endif
+
+typedef <T>CHNode* <T>CHNodePtr;
+
+#endif
+
+
+class <T>CHBag : public <T>Bag
+{
+protected:
+  <T>CHNode**   tab;
+  unsigned int  size;
+
+public:
+                <T>CHBag(unsigned int sz = DEFAULT_INITIAL_CAPACITY);
+                <T>CHBag(<T>CHBag& a);
+                ~<T>CHBag();
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  void          remove(<T&>item);
+  int           nof(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  Pix           seek(<T&> item, Pix from = 0);
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>CHBag::~<T>CHBag()
+{
+  clear();
+  delete tab;
+}
+
+inline int <T>CHBag::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+inline <T>& <T>CHBag::operator () (Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T>CHNode*)i)->hd;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/CHMap.ccP b/usr/include/g++/gen/CHMap.ccP
new file mode 100644 (file)
index 0000000..edb942f
--- /dev/null
@@ -0,0 +1,171 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.<C>.CHMap.h"
+
+// The nodes are linked together serially via a version
+// of a trick used in some vtables: odd pointers are
+// actually links to the next table entry. 
+// Not terrible, but not wonderful either
+
+static inline int goodCHptr(<T><C>CHNode* t)
+{
+  return ((((unsigned)t) & 1) == 0);
+}
+
+static inline <T><C>CHNode* index_to_CHptr(int i)
+{
+  return (<T><C>CHNode*)((i << 1) + 1);
+}
+
+static inline int CHptr_to_index(<T><C>CHNode* t)
+{
+  return ( ((unsigned) t) >> 1);
+}
+
+<T><C>CHMap::<T><C>CHMap(<C&> dflt, unsigned int sz)
+     :<T><C>Map(dflt)
+{
+  tab = (<T><C>CHNode**)(new <T><C>CHNodePtr[size = sz]);
+  for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1);
+  count = 0;
+}
+
+<T><C>CHMap::<T><C>CHMap(<T><C>CHMap& a) :<T><C>Map(a.def)
+{
+  tab = (<T><C>CHNode**)(new <T><C>CHNodePtr[size = a.size]);
+  for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1);
+  count = 0;
+  for (Pix p = a.first(); p; a.next(p)) (*this)[a.key(p)] = a.contents(p);
+}
+
+
+Pix <T><C>CHMap::seek(<T&> key)
+{
+  unsigned int h = <T>HASH(key) % size;
+
+  for (<T><C>CHNode* t = tab[h]; goodCHptr(t); t = t->tl)
+    if (<T>EQ(key, t->hd))
+      return Pix(t);
+
+  return 0;
+}
+
+
+<C>& <T><C>CHMap::operator [](<T&> item)
+{
+  unsigned int h = <T>HASH(item) % size;
+
+  for (<T><C>CHNode* t = tab[h]; goodCHptr(t); t = t->tl)
+    if (<T>EQ(item, t->hd))
+      return t->cont;
+
+  t = new <T><C>CHNode(item, def, tab[h]);
+  tab[h] = t;
+  ++count;
+  return t->cont;
+}
+
+
+void <T><C>CHMap::del(<T&> key)
+{
+  unsigned int h = <T>HASH(key) % size;
+
+  <T><C>CHNode* t = tab[h]; 
+  <T><C>CHNode* trail = t;
+  while (goodCHptr(t))
+  {
+    if (<T>EQ(key, t->hd))
+    {
+      if (trail == t)
+        tab[h] = t->tl;
+      else
+        trail->tl = t->tl;
+      delete t;
+      --count;
+      return;
+    }
+    trail = t;
+    t = t->tl;
+  }
+}
+
+
+void <T><C>CHMap::clear()
+{
+  for (unsigned int i = 0; i < size; ++i)
+  {
+    <T><C>CHNode* p = tab[i];
+    tab[i] = index_to_CHptr(i+1);
+    while (goodCHptr(p))
+    {
+      <T><C>CHNode* nxt = p->tl;
+      delete(p);
+      p = nxt;
+    }
+  }
+  count = 0;
+}
+
+Pix <T><C>CHMap::first()
+{
+  for (unsigned int i = 0; i < size; ++i) if (goodCHptr(tab[i])) return Pix(tab[i]);
+  return 0;
+}
+
+void <T><C>CHMap::next(Pix& p)
+{
+  <T><C>CHNode* t = ((<T><C>CHNode*)p)->tl;
+  if (goodCHptr(t))
+    p = Pix(t);
+  else
+  {
+    for (unsigned int i = CHptr_to_index(t); i < size; ++i) 
+    {
+      if (goodCHptr(tab[i]))
+      {
+        p =  Pix(tab[i]);
+        return;
+      }
+    }
+    p = 0;
+  }
+}
+
+
+int <T><C>CHMap::OK()
+{
+  int v = tab != 0;
+  int n = 0;
+  for (unsigned int i = 0; i < size; ++i)
+  {
+    for (<T><C>CHNode* p = tab[i]; goodCHptr(p); p = p->tl) ++n;
+    v &= CHptr_to_index(p) == i + 1;
+  }
+  v &= count == n;
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/CHMap.hP b/usr/include/g++/gen/CHMap.hP
new file mode 100644 (file)
index 0000000..0347971
--- /dev/null
@@ -0,0 +1,118 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T><C>CHMap_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T><C>CHMap_h 1
+
+#include "<T>.<C>.Map.h"
+
+#ifndef _<T><C>CHNode_h
+#define _<T><C>CHNode_h 1
+
+struct <T><C>CHNode
+{
+  <T><C>CHNode*      tl;
+  <T>                hd;
+  <C>                cont;
+                     <T><C>CHNode();
+                     <T><C>CHNode(<T&> h, <C&> c, <T><C>CHNode* t = 0);
+                     ~<T><C>CHNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T><C>CHNode::<T><C>CHNode() {}
+
+inline <T><C>CHNode::<T><C>CHNode(<T&> h, <C&> c, <T><C>CHNode* t)
+     : hd(h), cont(c), tl(t) {}
+
+inline <T><C>CHNode::~<T><C>CHNode() {}
+
+
+#endif
+
+typedef <T><C>CHNode* <T><C>CHNodePtr;
+
+#endif
+
+
+class <T><C>CHMap : public <T><C>Map
+{
+protected:
+  <T><C>CHNode** tab;
+  unsigned int   size;
+
+public:
+                <T><C>CHMap(<C&> dflt,unsigned int sz=DEFAULT_INITIAL_CAPACITY);
+                <T><C>CHMap(<T><C>CHMap& a);
+                ~<T><C>CHMap();
+
+  <C>&          operator [] (<T&> key);
+
+  void          del(<T&> key);
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          key(Pix i);
+  <C>&          contents(Pix i);
+
+  Pix           seek(<T&> key);
+  int           contains(<T&> key);
+
+  void          clear(); 
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T><C>CHMap::~<T><C>CHMap()
+{
+  clear();
+  delete tab;
+}
+
+inline int <T><C>CHMap::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+inline <T>& <T><C>CHMap::key(Pix p)
+{
+  if (p == 0) error("null Pix");
+  return ((<T><C>CHNode*)p)->hd;
+}
+
+inline <C>& <T><C>CHMap::contents(Pix p)
+{
+  if (p == 0) error("null Pix");
+  return ((<T><C>CHNode*)p)->cont;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/CHSet.ccP b/usr/include/g++/gen/CHSet.ccP
new file mode 100644 (file)
index 0000000..07c57d3
--- /dev/null
@@ -0,0 +1,276 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.CHSet.h"
+
+// A CHSet is implemented as an array (tab) of buckets, each of which
+// contains a pointer to a list of <T>CHNodes.  Each node contains a
+// pointer to the next node in the list, and a pointer to the <T>.
+// The end of the list is marked by a next node pointer which is odd
+// when considered as an integer (least significant bit = 1).  The
+// assumption is that CHNodes will all begin on even addresses.  If
+// the odd pointer is right-shifted by one bit, it becomes the index
+// within the tab array of the next bucket (that is, bucket i has
+// next bucket pointer 2*(i+1)+1).
+
+// The bucket pointers are initialized by the constructor and
+// used to support the next(Pix&) method.
+
+// This implementation is not portable to machines with different
+// pointer and integer sizes, or on which CHNodes might be aligned on
+// odd byte boundaries, but allows the same pointer to be used for
+// chaining within a bucket and to the next bucket.
+
+
+static inline int goodCHptr(<T>CHNode* t)
+{
+  return ((((unsigned)t) & 1) == 0);
+}
+
+static inline <T>CHNode* index_to_CHptr(int i)
+{
+  return (<T>CHNode*)((i << 1) + 1);
+}
+
+static inline int CHptr_to_index(<T>CHNode* t)
+{
+  return ( ((unsigned) t) >> 1);
+}
+
+<T>CHSet::<T>CHSet(unsigned int sz)
+{
+  tab = (<T>CHNode**)(new <T>CHNodePtr[size = sz]);
+  for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1);
+  count = 0;
+}
+
+<T>CHSet::<T>CHSet(<T>CHSet& a)
+{
+  tab = (<T>CHNode**)(new <T>CHNodePtr[size = a.size]);
+  for (unsigned int i = 0; i < size; ++i) tab[i] = index_to_CHptr(i+1);
+  count = 0;
+  for (Pix p = a.first(); p; a.next(p)) add(a(p));
+}
+
+
+Pix <T>CHSet::seek(<T&> key)
+{
+  unsigned int h = <T>HASH(key) % size;
+
+  for (<T>CHNode* t = tab[h]; goodCHptr(t); t = t->tl)
+    if (<T>EQ(key, t->hd))
+      return Pix(t);
+
+  return 0;
+}
+
+
+Pix <T>CHSet::add(<T&> item)
+{
+  unsigned int h = <T>HASH(item) % size;
+
+  for (<T>CHNode* t = tab[h]; goodCHptr(t); t = t->tl)
+    if (<T>EQ(item, t->hd))
+      return Pix(t);
+
+  ++count;
+  t = new <T>CHNode(item, tab[h]);
+  tab[h] = t;
+  return Pix(t);
+}
+
+
+void <T>CHSet::del(<T&> key)
+{
+  unsigned int h = <T>HASH(key) % size;
+
+  <T>CHNode* t = tab[h]; 
+  <T>CHNode* trail = t;
+  while (goodCHptr(t))
+  {
+    if (<T>EQ(key, t->hd))
+    {
+      if (trail == t)
+        tab[h] = t->tl;
+      else
+        trail->tl = t->tl;
+      delete t;
+      --count;
+      return;
+    }
+    trail = t;
+    t = t->tl;
+  }
+}
+
+
+void <T>CHSet::clear()
+{
+  for (unsigned int i = 0; i < size; ++i)
+  {
+    <T>CHNode* p = tab[i];
+    tab[i] = index_to_CHptr(i+1);
+    while (goodCHptr(p))
+    {
+      <T>CHNode* nxt = p->tl;
+      delete(p);
+      p = nxt;
+    }
+  }
+  count = 0;
+}
+
+Pix <T>CHSet::first()
+{
+  for (unsigned int i = 0; i < size; ++i) if (goodCHptr(tab[i])) return Pix(tab[i]);
+  return 0;
+}
+
+void <T>CHSet::next(Pix& p)
+{
+  if (p == 0) return;
+  <T>CHNode* t = ((<T>CHNode*)p)->tl;
+  if (goodCHptr(t))
+    p = Pix(t);
+  else
+  {
+    for (unsigned int i = CHptr_to_index(t); i < size; ++i) 
+    {
+      if (goodCHptr(tab[i]))
+      {
+        p =  Pix(tab[i]);
+        return;
+      }
+    }
+    p = 0;
+  }
+}
+
+int <T>CHSet::operator == (<T>CHSet& b)
+{
+  if (count != b.count)
+    return 0;
+  else
+  {
+    <T>CHNode* p;
+    for (unsigned int i = 0; i < size; ++i)
+      for (p = tab[i]; goodCHptr(p); p = p->tl)
+        if (b.seek(p->hd) == 0)
+          return 0;
+    for (i = 0; i < b.size; ++i)
+      for (p = b.tab[i]; goodCHptr(p); p = p->tl)
+        if (seek(p->hd) == 0)
+          return 0;
+    return 1;
+  }
+}
+
+int <T>CHSet::operator <= (<T>CHSet& b)
+{
+  if (count > b.count)
+    return 0;
+  else
+  {
+    for (unsigned int i = 0; i < size; ++i)
+      for (<T>CHNode* p = tab[i]; goodCHptr(p); p = p->tl)
+        if (b.seek(p->hd) == 0)
+          return 0;
+    return 1;
+  }
+}
+
+void <T>CHSet::operator |= (<T>CHSet& b)
+{
+  if (&b == this || b.count == 0)
+    return;
+  for (unsigned int i = 0; i < b.size; ++i)
+    for (<T>CHNode* p = b.tab[i]; goodCHptr(p); p = p->tl)
+      add(p->hd);
+}
+
+void <T>CHSet::operator &= (<T>CHSet& b)
+{
+  for (unsigned int i = 0; i < size; ++i)
+  {
+    <T>CHNode* t = tab[i]; 
+    <T>CHNode* trail = t;
+    while (goodCHptr(t))
+    {
+      <T>CHNode* nxt = t->tl;
+      if (b.seek(t->hd) == 0)
+      {
+        if (trail == tab[i])
+          trail = tab[i] = nxt;
+        else
+          trail->tl = nxt;
+        delete t;
+        --count;
+      }
+      else
+        trail = t;
+      t = nxt;
+    }
+  }
+}
+
+void <T>CHSet::operator -= (<T>CHSet& b)
+{
+  for (unsigned int i = 0; i < size; ++i)
+  {
+    <T>CHNode* t = tab[i]; 
+    <T>CHNode* trail = t;
+    while (goodCHptr(t))
+    {
+      <T>CHNode* nxt = t->tl;
+      if (b.seek(t->hd) != 0)
+      {
+        if (trail == tab[i])
+          trail = tab[i] = nxt;
+        else
+          trail->tl = nxt;
+        delete t;
+        --count;
+      }
+      else
+        trail = t;
+      t = nxt;
+    }
+  }
+}
+
+int <T>CHSet::OK()
+{
+  int v = tab != 0;
+  int n = 0;
+  for (unsigned int i = 0; i < size; ++i)
+  {
+    for (<T>CHNode* p = tab[i]; goodCHptr(p); p = p->tl) ++n;
+    v &= CHptr_to_index(p) == i + 1;
+  }
+  v &= count == n;
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/CHSet.hP b/usr/include/g++/gen/CHSet.hP
new file mode 100644 (file)
index 0000000..51cad80
--- /dev/null
@@ -0,0 +1,121 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>CHSet_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>CHSet_h 1
+
+#include "<T>.Set.h"
+
+
+#ifndef _<T>CHNode_h
+#define _<T>CHNode_h 1
+
+struct <T>CHNode
+{
+  <T>CHNode*         tl;
+  <T>                hd;
+                     <T>CHNode();
+                     <T>CHNode(<T&> h, <T>CHNode* t = 0);
+                     ~<T>CHNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>CHNode::<T>CHNode() {}
+
+inline <T>CHNode::<T>CHNode(<T&> h, <T>CHNode* t) : hd(h), tl(t) {}
+
+inline <T>CHNode::~<T>CHNode() {}
+
+#endif
+
+typedef <T>CHNode* <T>CHNodePtr;
+
+#endif
+
+
+class <T>CHSet : public <T>Set
+{
+protected:
+  <T>CHNode**   tab;
+  unsigned int  size;
+
+public:
+                <T>CHSet(unsigned int sz = DEFAULT_INITIAL_CAPACITY);
+                <T>CHSet(<T>CHSet& a);
+                ~<T>CHSet();
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  Pix           seek(<T&> item);
+
+  void          operator |= (<T>CHSet& b);
+  void          operator -= (<T>CHSet& b);
+  void          operator &= (<T>CHSet& b);
+
+  int           operator == (<T>CHSet& b);
+  int           operator != (<T>CHSet& b);
+  int           operator <= (<T>CHSet& b); 
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>CHSet::~<T>CHSet()
+{
+  clear();
+  delete tab;
+}
+
+inline int <T>CHSet::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+inline <T>& <T>CHSet::operator () (Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T>CHNode*)i)->hd;
+}
+
+inline int <T>CHSet::operator != (<T>CHSet& b)
+{
+  return ! ((*this) == b);
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/DLDeque.ccP b/usr/include/g++/gen/DLDeque.ccP
new file mode 100644 (file)
index 0000000..d5a0db7
--- /dev/null
@@ -0,0 +1,4 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.DLDeque.h"
diff --git a/usr/include/g++/gen/DLDeque.hP b/usr/include/g++/gen/DLDeque.hP
new file mode 100644 (file)
index 0000000..5ef7c4c
--- /dev/null
@@ -0,0 +1,138 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>DLDeque_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>DLDeque_h
+
+#include "<T>.DLList.h"
+#include "<T>.Deque.h"
+
+class <T>DLDeque : public <T>Deque
+{
+  <T>DLList    p;
+
+public:
+               <T>DLDeque();
+               <T>DLDeque(const <T>DLDeque& d);
+               ~<T>DLDeque();
+
+  void          operator = (const <T>DLDeque&);
+
+  void          push(<T&> item); // insert at front
+  void          enq(<T&> item);  // insert at rear
+
+  <T>&          front();
+  <T>&          rear();
+
+  <T>           deq();
+  void          del_front();
+  void          del_rear();               
+
+  void          clear();
+  int           empty();
+  int           full();
+  int           length();
+               
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>DLDeque::<T>DLDeque() : p() {}
+inline <T>DLDeque::<T>DLDeque(const <T>DLDeque& d) : p(d.p) {}
+
+inline <T>DLDeque::~<T>DLDeque() {}
+
+inline void <T>DLDeque::push(<T&>item)
+{
+  p.prepend(item);
+}
+
+inline void <T>DLDeque::enq(<T&>item)
+{
+  p.append(item);
+}
+
+inline <T> <T>DLDeque::deq()
+{
+  return p.remove_front();
+}
+
+inline <T>& <T>DLDeque::front()
+{
+  return p.front();
+}
+
+inline <T>& <T>DLDeque::rear()
+{
+  return p.rear();
+}
+
+inline void <T>DLDeque::del_front()
+{
+  p.del_front();
+}
+
+inline void <T>DLDeque::del_rear()
+{
+  p.del_rear();
+}
+
+inline void <T>DLDeque::operator =(const <T>DLDeque& s)
+{
+  p.operator = (s.p);
+}
+
+
+inline int <T>DLDeque::empty()
+{
+  return p.empty();
+}
+
+inline int <T>DLDeque::full()
+{
+  return 0;
+}
+
+inline int <T>DLDeque::length()
+{
+  return p.length();
+}
+
+inline int <T>DLDeque::OK()
+{
+  return p.OK();
+}
+
+inline void <T>DLDeque::clear()
+{
+  p.clear();
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/DLList.ccP b/usr/include/g++/gen/DLList.ccP
new file mode 100644 (file)
index 0000000..c9965a6
--- /dev/null
@@ -0,0 +1,317 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <values.h>
+#include <stream.h>
+#include "<T>.DLList.h"
+
+// error handling
+
+
+
+void <T>DLList::error(const char* msg)
+{
+  (*lib_error_handler)("DLList", msg);
+}
+
+int <T>DLList::length()
+{
+  int l = 0;
+  <T>DLListNode* t = h;
+  if (t != 0) do { ++l; t = t->fd; } while (t != h);
+  return l;
+}
+
+<T>DLList::<T>DLList(<T>DLList& a)
+{
+  if (a.h == 0)
+    h = 0;
+  else
+  {
+    <T>DLListNode* p = a.h;
+    <T>DLListNode* t = new <T>DLListNode(p->hd);
+    h = t;
+    p = p->fd;
+    while (p != a.h)
+    {
+      <T>DLListNode* n = new <T>DLListNode(p->hd);
+      t->fd = n;
+      n->bk = t;
+      t = n;
+        p = p->fd;
+    }
+    t->fd = h;
+    h->bk = t;
+    return;
+  }
+}
+
+<T>DLList& <T>DLList::operator = (<T>DLList& a)
+{
+  if (h != a.h)
+  {
+    clear();
+    if (a.h != 0)
+    {
+      <T>DLListNode* p = a.h;
+      <T>DLListNode* t = new <T>DLListNode(p->hd);
+      h = t;
+      p = p->fd;
+      while (p != a.h)
+      {
+        <T>DLListNode* n = new <T>DLListNode(p->hd);
+        t->fd = n;
+        n->bk = t;
+        t = n;
+        p = p->fd;
+      }
+      t->fd = h;
+      h->bk = t;
+    }
+  }
+  return *this;
+}
+
+void <T>DLList::clear()
+{
+  if (h == 0)
+    return;
+
+  <T>DLListNode* p = h->fd;
+  h->fd = 0;
+  h = 0;
+
+  while (p != 0)
+  {
+    <T>DLListNode* nxt = p->fd;
+    delete(p);
+    p = nxt;
+  }
+}
+
+
+Pix <T>DLList::prepend(<T&> item)
+{
+  <T>DLListNode* t = new <T>DLListNode(item);
+  if (h == 0)
+    t->fd = t->bk = h = t;
+  else
+  {
+    t->fd = h;
+    t->bk = h->bk;
+    h->bk->fd = t;
+    h->bk = t;
+    h = t;
+  }
+  return Pix(t);
+}
+
+Pix <T>DLList::append(<T&> item)
+{
+  <T>DLListNode* t = new <T>DLListNode(item);
+  if (h == 0)
+    t->fd = t->bk = h = t;
+  else
+  {
+    t->bk = h->bk;
+    t->bk->fd = t;
+    t->fd = h;
+    h->bk = t;
+  }
+  return Pix(t);
+}
+
+Pix <T>DLList::ins_after(Pix p, <T&> item)
+{
+  if (p == 0) return prepend(item);
+  <T>DLListNode* u = (<T>DLListNode*) p;
+  <T>DLListNode* t = new <T>DLListNode(item, u, u->fd);
+  u->fd->bk = t;
+  u->fd = t;
+  return Pix(t);
+}
+
+Pix <T>DLList::ins_before(Pix p, <T&> item)
+{
+  if (p == 0) error("null Pix");
+  <T>DLListNode* u = (<T>DLListNode*) p;
+  <T>DLListNode* t = new <T>DLListNode(item, u->bk, u);
+  u->bk->fd = t;
+  u->bk = t;
+  if (u == h) h = t;
+  return Pix(t);
+}
+
+void <T>DLList::join(<T>DLList& b)
+{
+  <T>DLListNode* t = b.h;
+  b.h = 0;
+  if (h == 0)
+    h = t;
+  else if (t != 0)
+  {
+    <T>DLListNode* l = t->bk;
+    h->bk->fd = t;
+    t->bk = h->bk;
+    h->bk = l;
+    l->fd = h;
+  }
+}
+
+int <T>DLList::owns(Pix p)
+{
+  <T>DLListNode* t = h;
+  if (t != 0 && p != 0)
+  {
+    do
+    {
+      if (Pix(t) == p) return 1;
+      t = t->fd;
+    } while (t != h);
+  }
+  return 0;
+}
+
+void <T>DLList::del(Pix& p, int dir)
+{
+  if (p == 0) error("null Pix");
+  <T>DLListNode* t = (<T>DLListNode*) p;
+  if (t->fd == t)
+  {
+    h = 0;
+    p = 0;
+  }
+  else
+  {
+    if (dir < 0)
+    {
+      if (t == h)
+        p = 0;
+      else
+        p = Pix(t->bk);
+    }
+    else
+    {
+      if (t == h->bk)
+        p = 0;
+      else
+        p = Pix(t->fd);
+    }
+    t->bk->fd = t->fd;
+    t->fd->bk = t->bk;
+    if (t == h) h = t->fd;
+  }
+  delete t;
+}
+
+<T> <T>DLList::remove_front()
+{
+  if (h == 0)
+    error("remove_front of empty list");
+  <T>DLListNode* t = h;
+  <T> res = t->hd;
+  if (h->fd == h)
+    h = 0;
+  else
+  {
+    h->fd->bk = h->bk;
+    h->bk->fd = h->fd;
+    h = h->fd;
+  }
+  delete t;
+  return res;
+}
+
+
+void <T>DLList::del_front()
+{
+  if (h == 0)
+    error("del_front of empty list");
+  <T>DLListNode* t = h;
+  if (h->fd == h)
+    h = 0;
+  else
+  {
+    h->fd->bk = h->bk;
+    h->bk->fd = h->fd;
+    h = h->fd;
+  }
+  delete t;
+}
+
+<T> <T>DLList::remove_rear()
+{
+  if (h == 0)
+    error("remove_rear of empty list");
+  <T>DLListNode* t = h->bk;
+  <T> res = t->hd;
+  if (h->fd == h)
+    h = 0;
+  else
+  {
+    t->fd->bk = t->bk;
+    t->bk->fd = t->fd;
+  }
+  delete t;
+  return res;
+}
+
+
+void <T>DLList::del_rear()
+{
+  if (h == 0)
+    error("del_rear of empty list");
+  <T>DLListNode* t = h->bk;
+  if (h->fd == h)
+    h = 0;
+  else
+  {
+    t->fd->bk = t->bk;
+    t->bk->fd = t->fd;
+  }
+  delete t;
+}
+
+
+int <T>DLList::OK()
+{
+  int v = 1;
+  if (h != 0)
+  {
+    <T>DLListNode* t = h;
+    long count = MAXLONG;      // Lots of chances to find h!
+    do
+    {
+      count--;
+      v &= t->bk->fd == t;
+      v &= t->fd->bk == t;
+      t = t->fd;
+    } while (v && count > 0 && t != h);
+    v &= count > 0;
+  }
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/DLList.hP b/usr/include/g++/gen/DLList.hP
new file mode 100644 (file)
index 0000000..511c7b5
--- /dev/null
@@ -0,0 +1,170 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>DLList_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>DLList_h 1
+
+#include <Pix.h>
+#include "<T>.defs.h"
+
+#ifndef _<T>DLListNode_h
+#define _<T>DLListNode_h 1
+
+struct <T>DLListNode
+{
+  <T>DLListNode*         bk;
+  <T>DLListNode*         fd;
+  <T>                    hd;
+                         <T>DLListNode();
+                         <T>DLListNode(<T&> h, 
+                                       <T>DLListNode* p = 0,
+                                       <T>DLListNode* n = 0);
+                         ~<T>DLListNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>DLListNode::<T>DLListNode() {}
+
+inline <T>DLListNode::<T>DLListNode(<T&> h, <T>DLListNode* p,
+                                    <T>DLListNode* n)
+  :hd(h), bk(p), fd(n) {}
+
+inline <T>DLListNode::~<T>DLListNode() {}
+
+#endif
+
+typedef <T>DLListNode* <T>DLListNodePtr;
+
+#endif
+
+class <T>DLList
+{
+  friend class          <T>DLListTrav;
+
+  <T>DLListNode*        h;
+
+public:
+                        <T>DLList();
+                        <T>DLList(<T>DLList& a);
+                        ~<T>DLList();
+
+  <T>DLList&            operator = (<T>DLList& a);
+
+  int                   empty();
+  int                   length();
+
+  void                  clear();
+
+  Pix                   prepend(<T&> item);
+  Pix                   append(<T&> item);
+  void                  join(<T>DLList&);
+
+  <T>&                  front();
+  <T>                   remove_front();
+  void                  del_front();
+
+  <T>&                  rear();
+  <T>                   remove_rear();
+  void                  del_rear();
+
+  <T>&                  operator () (Pix p);
+  Pix                   first();
+  Pix                   last();
+  void                  next(Pix& p);
+  void                  prev(Pix& p);
+  int                   owns(Pix p);
+  Pix                   ins_after(Pix p, <T&> item);
+  Pix                   ins_before(Pix p, <T&> item);
+  void                  del(Pix& p, int dir = 1);
+
+  void                  error(const char* msg);
+  int                   OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>DLList::~<T>DLList()
+{
+  clear();
+}
+
+inline <T>DLList::<T>DLList()
+{
+  h = 0;
+}
+
+inline int <T>DLList::empty()
+{
+  return h == 0;
+}
+
+
+inline void <T>DLList::next(Pix& p)
+{
+  p = (p == 0 || p == h->bk)? 0 : Pix(((<T>DLListNode*)p)->fd);
+}
+
+inline void <T>DLList::prev(Pix& p)
+{
+  p = (p == 0 || p == h)? 0 : Pix(((<T>DLListNode*)p)->bk);
+}
+
+inline Pix <T>DLList::first()
+{
+  return Pix(h);
+}
+
+inline Pix <T>DLList::last()
+{
+  return (h == 0)? 0 : Pix(h->bk);
+}
+
+inline <T>& <T>DLList::operator () (Pix p)
+{
+  if (p == 0) error("null Pix");
+  return ((<T>DLListNode*)p)->hd;
+}
+
+inline <T>& <T>DLList::front()
+{
+  if (h == 0) error("front: empty list");
+  return h->hd;
+}
+
+inline <T>& <T>DLList::rear()
+{
+  if (h == 0) error("rear: empty list");
+  return h->bk->hd;
+}
+
+
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/Deque.ccP b/usr/include/g++/gen/Deque.ccP
new file mode 100644 (file)
index 0000000..79a9b72
--- /dev/null
@@ -0,0 +1,11 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.Deque.h"
+
+<T>Deque::~<T>Deque() {}
+
+void <T>Deque::error(const char* msg)
+{
+  (*lib_error_handler)("Deque", msg);
+}
diff --git a/usr/include/g++/gen/Deque.hP b/usr/include/g++/gen/Deque.hP
new file mode 100644 (file)
index 0000000..a82607b
--- /dev/null
@@ -0,0 +1,67 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>Deque_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>Deque_h
+
+#include <builtin.h>
+
+#include "<T>.defs.h"
+
+class <T>Deque
+{
+public:
+                        <T>Deque();
+                        ~<T>Deque();
+
+  virtual void          push(<T&> item) = 0; // insert at front
+  virtual void          enq(<T&> item) = 0;  // insert at rear
+
+  virtual <T>&          front() = 0;
+  virtual <T>&          rear() = 0;
+
+  virtual <T>           deq() = 0;
+  virtual void          del_front() = 0;
+  virtual void          del_rear() = 0;               
+
+  virtual int           empty() = 0;
+  virtual int           full() = 0;
+  virtual int           length() = 0;
+  virtual void          clear() = 0;
+  
+  virtual int           OK() = 0;
+
+  void                  error(const char*);
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+inline <T>Deque::<T>Deque() {}
+#endif
+
+#endif
diff --git a/usr/include/g++/gen/FPQueue.ccP b/usr/include/g++/gen/FPQueue.ccP
new file mode 100644 (file)
index 0000000..a358cac
--- /dev/null
@@ -0,0 +1,4 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.FPQueue.h"
diff --git a/usr/include/g++/gen/FPQueue.hP b/usr/include/g++/gen/FPQueue.hP
new file mode 100644 (file)
index 0000000..9fcb81b
--- /dev/null
@@ -0,0 +1,121 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>FPQueue_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>FPQueue_h
+
+#include "<T>.FPlex.h"
+#include "<T>.Queue.h"
+
+class <T>FPQueue : public <T>Queue
+{
+  <T>FPlex     p;
+
+public:
+               <T>FPQueue(int chunksize = DEFAULT_<T>PLEX_CHUNK_SIZE);
+               <T>FPQueue(const <T>FPQueue& q);
+               ~<T>FPQueue();
+
+  void          operator = (const <T>FPQueue&);
+
+  void          enq(<T&> item);
+  <T>           deq();
+  <T>&          front();
+  void          del_front();
+
+  void          clear();
+  int           empty();
+  int           full();
+  int           length();
+               
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>FPQueue::<T>FPQueue(int chunksize) : p(chunksize) {}
+inline <T>FPQueue::<T>FPQueue(const <T>FPQueue& q) : p(q.p) {}
+
+inline <T>FPQueue::~<T>FPQueue() {}
+
+inline void <T>FPQueue::enq(<T&>item)
+{
+  p.add_high(item);
+}
+
+inline <T> <T>FPQueue::deq()
+{
+  <T> res = p.low_element();
+  p.del_low();
+  return res;
+}
+
+inline <T>& <T>FPQueue::front()
+{
+  return p.low_element();
+}
+
+
+inline void <T>FPQueue::del_front()
+{
+  p.del_low();
+}
+
+inline void <T>FPQueue::operator =(const <T>FPQueue& s)
+{
+  p = s.p;
+}
+
+inline int <T>FPQueue::empty()
+{
+  return p.empty();
+}
+
+inline int <T>FPQueue::full()
+{
+  return p.full();
+}
+
+inline int <T>FPQueue::length()
+{
+  return p.length();
+}
+
+inline int <T>FPQueue::OK()
+{
+  return p.OK();
+}
+
+inline void <T>FPQueue::clear()
+{
+  p.clear();
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/FPStack.ccP b/usr/include/g++/gen/FPStack.ccP
new file mode 100644 (file)
index 0000000..9549911
--- /dev/null
@@ -0,0 +1,4 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.FPStack.h"
diff --git a/usr/include/g++/gen/FPStack.hP b/usr/include/g++/gen/FPStack.hP
new file mode 100644 (file)
index 0000000..1ec4673
--- /dev/null
@@ -0,0 +1,123 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>FPStack_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>FPStack_h
+
+#include "<T>.FPlex.h"
+#include "<T>.Stack.h"
+
+class <T>FPStack : public <T>Stack
+{
+  <T>FPlex      p;
+
+public:
+                <T>FPStack(int chunksize = DEFAULT_<T>PLEX_CHUNK_SIZE);
+                <T>FPStack(const <T>FPStack& s);
+                ~<T>FPStack();
+
+  void          operator = (const <T>FPStack&);
+
+  void          push(<T&> item);
+  <T>           pop();
+  <T>&          top();               
+  void          del_top();
+
+  int           empty();
+  int           full();
+  int           length();
+
+  void          clear();
+
+  int           OK();
+
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>FPStack::<T>FPStack(int chunksize) : p(chunksize) {}
+inline <T>FPStack::<T>FPStack(const <T>FPStack& s) : p(s.p) {}
+
+inline <T>FPStack::~<T>FPStack() {}
+
+inline void <T>FPStack::push(<T&>item)
+{
+  p.add_high(item);
+}
+
+inline <T> <T>FPStack::pop()
+{
+  <T> res = p.high_element();
+  p.del_high();
+  return res;
+}
+
+inline <T>& <T>FPStack::top()
+{
+  return p.high_element();
+}
+
+inline void <T>FPStack::del_top()
+{
+  p.del_high();
+}
+
+inline void <T>FPStack::operator =(const <T>FPStack& s)
+{
+  p = s.p;
+}
+
+inline int <T>FPStack::empty() 
+{
+  return p.empty();
+}
+
+inline int <T>FPStack::full() 
+{
+  return p.full();
+}
+
+inline int <T>FPStack::length() 
+{
+  return p.length();
+}
+
+inline int <T>FPStack::OK() 
+{
+  return p.OK();
+}
+
+inline void <T>FPStack::clear() 
+{
+  p.clear();
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/FPlex.ccP b/usr/include/g++/gen/FPlex.ccP
new file mode 100644 (file)
index 0000000..235d290
--- /dev/null
@@ -0,0 +1,182 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.FPlex.h"
+
+
+<T>FPlex:: <T>FPlex()
+{
+  lo = fnc = 0;
+  csize = DEFAULT_INITIAL_CAPACITY;
+  <T>* data = new <T>[csize];
+  hd = new <T>IChunk(data,  lo, lo, fnc, csize);
+}
+
+<T>FPlex:: <T>FPlex(int maxsize)
+{
+  if (maxsize == 0) error("invalid constructor specification");
+  lo = fnc = 0;
+  if (maxsize > 0)
+  {
+    csize = maxsize;
+    <T>* data = new <T>[csize];
+    hd = new <T>IChunk(data,  lo, lo, fnc, csize);
+  }
+  else
+  {
+    csize = -maxsize;
+    <T>* data = new <T>[csize];
+    hd = new <T>IChunk(data,  maxsize, lo, fnc, fnc);
+  }
+}
+
+
+<T>FPlex:: <T>FPlex(int l, int maxsize)
+{
+  if (maxsize == 0) error("invalid constructor specification");
+  lo = fnc = l;
+  if (maxsize > 0)
+  {
+    csize = maxsize;
+    <T>* data = new <T>[csize];
+    hd = new <T>IChunk(data,  lo, lo, fnc, csize+lo);
+  }
+  else
+  {
+    csize = -maxsize;
+    <T>* data = new <T>[csize];
+    hd = new <T>IChunk(data,  maxsize+lo, lo, fnc, fnc);
+  }
+}
+
+<T>FPlex:: <T>FPlex(int l, int hi, const <T&> initval, int maxsize)
+{
+  lo = l;
+  fnc = hi + 1;
+  if (maxsize >= 0)
+  {
+    csize = maxsize;
+    if (csize < fnc - lo)
+      csize = fnc - lo;
+    <T>* data = new <T>[csize];
+    hd = new <T>IChunk(data,  lo, lo, fnc, csize);
+  }
+  else
+  {
+    csize = -maxsize;
+    if (csize < fnc - lo)
+      csize = fnc - lo;
+    <T>* data = new <T>[csize];
+    hd = new <T>IChunk(data,  -csize, lo, fnc, fnc);
+  }
+  fill(initval);
+}
+
+<T>FPlex::<T>FPlex(const <T>FPlex& a)
+{
+  lo = a.lo;
+  fnc = a.fnc;
+  csize = fnc - lo;
+  if (csize < a.csize) csize = a.csize;
+  <T>* data = new <T> [csize];
+  hd = new <T>IChunk(data,  lo, lo, fnc, lo+csize);
+  for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i];
+}
+
+void <T>FPlex::operator= (const <T>FPlex& a)
+{
+  if (&a != this)
+  {
+    del_chunk(hd);
+    lo = a.lo;
+    fnc = a.fnc;
+    csize = fnc - lo;
+    if (csize < a.csize) csize = a.csize;
+    <T>* data = new <T> [csize];
+    hd = new <T>IChunk(data,  lo, lo, fnc, lo+csize);
+    for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i];
+  }
+}
+
+
+void <T>FPlex::append (const <T>FPlex& a)
+{
+  for (int i = a.low(); i < a.fence(); a.next(i)) add_high(a[i]);
+}
+
+void <T>FPlex::prepend (const <T>FPlex& a)
+{
+  for (int i = a.high(); i > a.ecnef(); a.prev(i)) add_low(a[i]);
+}
+
+void <T>FPlex::reverse()
+{
+  <T> tmp;
+  int l = lo;
+  int h = fnc - 1;
+  while (l < h)
+  {
+    tmp = (*this)[l];
+    (*this)[l] = (*this)[h];
+    (*this)[h] = tmp;
+    next(l);
+    prev(h);
+  }
+}
+
+void <T>FPlex::fill(const <T&> x)
+{
+  for (int i = lo; i < fnc; ++i) (*this)[i] = x;
+}
+
+void <T>FPlex::fill(const <T&> x, int lo, int hi)
+{
+  for (int i = lo; i <= hi; ++i) (*this)[i] = x;
+}
+
+void <T>FPlex::clear()
+{
+  if (fnc != lo)
+  {
+    hd->clear(lo);
+    fnc = lo;
+  }
+}
+
+int <T>FPlex::OK () const
+{
+  int v = hd != 0;                    // hd exists
+  v &= hd-><T>IChunk::OK();           // and is OK
+  v &= fnc - lo <= hd->size();        // and has enough space
+  v &= lo <= fnc;                     // plex indices consistent
+  v &= lo == hd->low_index();         // and match those 
+  v &= fnc == hd->fence_index();      //   of chunk
+  v &= one_chunk();                   // and only one chunk
+  if (!v) error("invariant failure");
+  return v;
+}
+
diff --git a/usr/include/g++/gen/FPlex.hP b/usr/include/g++/gen/FPlex.hP
new file mode 100644 (file)
index 0000000..2fda48d
--- /dev/null
@@ -0,0 +1,263 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _<T>FPlex_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>FPlex_h 1
+
+#include "<T>.Plex.h"
+
+class <T>FPlex : public <T>Plex
+{
+public:
+                   <T>FPlex();                 // set low = 0;
+                                               // fence = 0;
+                                               // csize = default
+
+                   <T>FPlex(int maxsize);      // low = 0; 
+                                               // fence = 0;
+                                               // csize = maxsize
+
+                   <T>FPlex(int lo,            // low = lo; 
+                            int maxsize);      // fence=lo
+                                               // csize = maxsize
+
+                   <T>FPlex(int lo,            // low = lo
+                            int hi,            // fence = hi+1
+                            const <T&> initval,// fill with initval,
+                            int maxsize = 0);  // csize = maxsize
+                                               // or fence - lo if 0
+
+                   <T>FPlex(const <T>FPlex&);   // X(X&)
+
+                   ~<T>FPlex();
+
+  void             operator= (const <T>FPlex&);
+
+// virtuals
+
+  <T>&             high_element ();
+  <T>&             low_element ();
+
+  const <T>&       high_element () const;
+  const <T>&       low_element () const;
+
+  Pix              first() const;
+  Pix              last() const;
+  void             prev(Pix& ptr) const;
+  void             next(Pix& ptr) const;
+  int              owns(Pix p) const;
+  <T>&             operator () (Pix p);
+  const <T>&       operator () (Pix p) const;
+
+  int              low() const; 
+  int              high() const;
+  int              valid(int idx) const;
+  void             prev(int& idx) const;
+  void             next(int& x) const;
+  <T>&             operator [] (int index);
+  const <T>&       operator [] (int index) const;
+    
+  int              Pix_to_index(Pix p) const;
+  Pix              index_to_Pix(int idx) const;    
+
+  int              can_add_high() const;
+  int              can_add_low() const;
+  int              full() const;
+
+  int              add_high(const <T&> elem);
+  int              del_high ();
+  int              add_low (const <T&> elem);
+  int              del_low ();
+
+  void             fill(const <T&> x);
+  void             fill(const <T&> x, int from, int to);
+  void             clear();
+  void             reverse();
+  void             append(const <T>FPlex& a); 
+  void             prepend(const <T>FPlex& a);
+    
+  int              OK () const; 
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline  int <T>FPlex::valid (int idx) const
+{
+  return idx >= lo && idx < fnc;
+}
+
+inline int <T>FPlex::low() const
+{
+  return lo;
+}
+
+inline int <T>FPlex::high() const
+{
+  return fnc - 1;
+}
+
+inline Pix  <T>FPlex::first() const
+{
+  return (Pix)(hd-><T>IChunk::first_pointer());
+}
+
+inline void  <T>FPlex::prev(Pix&  p) const
+{
+  p = Pix(hd-><T>IChunk::pred((<T>*) p));
+}
+
+inline void  <T>FPlex::next(Pix&  p) const
+{
+  p =  Pix(hd-><T>IChunk::succ((<T>*) p));
+}
+
+inline Pix <T>FPlex::last() const
+{
+  return Pix(hd-><T>IChunk::last_pointer());
+}
+
+inline  int <T>FPlex::full () const
+{
+  return fnc - lo == csize;
+}
+
+inline void <T>FPlex::prev(int& idx) const
+{
+  --idx;
+}
+
+inline void <T>FPlex::next(int& idx) const
+{
+  ++idx;
+}
+
+inline <T>& <T>FPlex:: operator [] (int idx)
+{
+  if (idx < lo || idx >= fnc) index_error();
+  return *(hd->pointer_to(idx));
+}
+
+inline <T>& <T>FPlex:: operator () (Pix p)
+{
+  return *((<T>*)p);
+}
+
+inline  <T>& <T>FPlex::low_element ()
+{
+  if (empty()) index_error();
+  return *(hd->pointer_to(lo));
+}
+
+inline  <T>& <T>FPlex::high_element ()
+{
+  if (empty()) index_error();
+  return *(hd->pointer_to(fnc - 1));
+}
+
+inline const <T>& <T>FPlex:: operator [] (int idx) const
+{
+  if (idx < lo || idx >= fnc) index_error();
+  return *(hd->pointer_to(idx));
+}
+
+inline const <T>& <T>FPlex:: operator () (Pix p) const
+{
+  return *((const <T>*)p);
+}
+
+inline const <T>& <T>FPlex::low_element () const
+{
+  if (empty()) index_error();
+  return *(hd->pointer_to(lo));
+}
+
+inline const  <T>& <T>FPlex::high_element () const
+{
+  if (empty()) index_error();
+  return *(hd->pointer_to(fnc - 1));
+}
+
+inline int <T>FPlex::can_add_high() const
+{
+  return hd->can_grow_high();
+}
+
+inline int <T>FPlex::can_add_low() const
+{
+  return hd->can_grow_low();
+}
+
+inline int <T>FPlex::add_high(const <T&> elem)
+{
+  if (!can_add_high()) full_error();
+  *((hd-><T>IChunk::grow_high())) = elem;
+  return fnc++;
+}
+
+inline  int <T>FPlex::del_high ()
+{
+  if (empty()) empty_error();
+  hd-><T>IChunk::shrink_high();
+  return --fnc - 1;
+}
+
+inline  int <T>FPlex::add_low (const <T&> elem)
+{
+  if (!can_add_low()) full_error();
+  *((hd-><T>IChunk::grow_low())) = elem;
+  return --lo;
+}
+
+inline  int <T>FPlex::del_low ()
+{
+  if (empty()) empty_error();
+  hd-><T>IChunk::shrink_low();
+  return ++lo;
+}
+
+inline  int <T>FPlex::owns (Pix p) const
+{
+  return hd->actual_pointer((<T>*)p);
+}
+
+inline  int <T>FPlex::Pix_to_index(Pix p) const
+{
+  if (!hd->actual_pointer((const <T>*)p)) index_error();
+  return hd->index_of((const <T>*)p);
+}
+
+inline  Pix <T>FPlex::index_to_Pix(int idx) const
+{
+  if (idx < lo || idx >= fnc) index_error();
+  return Pix(hd->pointer_to(idx));
+}
+
+inline <T>FPlex::~<T>FPlex() {}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/List.ccP b/usr/include/g++/gen/List.ccP
new file mode 100644 (file)
index 0000000..75c09a9
--- /dev/null
@@ -0,0 +1,959 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <builtin.h>
+#include "<T>.List.h"
+
+<T>ListNode Nil<T>ListNode;
+
+class init_Nil<T>ListNode
+{
+public:
+  inline init_Nil<T>ListNode() 
+  {
+    Nil<T>ListNode.tl = &Nil<T>ListNode;
+    Nil<T>ListNode.ref = -1;
+  }
+};
+
+static init_Nil<T>ListNode Nil<T>ListNode_initializer;
+
+<T>List& <T>List::operator = (<T>List& a)
+{
+  reference(a.P);
+  dereference(P);
+  P = a.P;
+  return *this;
+}
+
+<T> <T>List::pop()
+{
+  <T> res = P->hd;
+  <T>ListNode* tail = P->tl;
+  reference(tail);
+  dereference(P);
+  P = tail;
+  return res;
+}
+
+void <T>List::set_tail(<T>List& a)
+{
+  reference(a.P);
+  dereference(P->tl);
+  P->tl = a.P;
+}
+
+<T>List <T>List::nth(int n)
+{
+  for (<T>ListNode* p = P; n-- > 0; p = p->tl);
+  reference(p);
+  return <T>List(p);
+}
+
+<T>List <T>List::last()
+{
+  <T>ListNode* p = P;
+  if (p != &Nil<T>ListNode) while (p->tl != &Nil<T>ListNode) p = p->tl;
+  reference(p);
+  return <T>List(p);
+}
+
+void <T>List::append(<T>List& l)
+{
+  <T>ListNode* p = P;
+  <T>ListNode* a = l.P;
+  reference(a);
+  if (p != &Nil<T>ListNode)
+  {
+    while (p->tl != &Nil<T>ListNode) p = p->tl;
+    p->tl = a;
+  }
+  else
+    P = a;
+}
+
+int <T>List::length()
+{
+  int l = 0;
+  for (<T>ListNode* p = P; p != &Nil<T>ListNode; p = p->tl) ++l;
+  return l;
+}
+
+<T>&  <T>List::operator [] (int n)
+{
+  for (<T>ListNode* p = P; n-- > 0; p = p->tl);
+  return (p->hd);
+}
+
+int operator == (<T>List& x, <T>List& y)
+{
+  <T>ListNode* a = x.P;
+  <T>ListNode* b = y.P;
+  
+  for (;;)
+  {
+    if (a == &Nil<T>ListNode)
+      return b == &Nil<T>ListNode;
+    else if (b == &Nil<T>ListNode)
+      return 0;
+    else if (a->hd == b->hd)
+    {
+      a = a->tl;
+      b = b->tl;
+    }
+    else
+      return 0;
+  }
+}
+
+
+void <T>List::apply(<T>Procedure f)
+{
+  for(<T>ListNode* p = P; p != &Nil<T>ListNode; p = p->tl)
+    (*f)((p->hd));
+}
+
+void <T>List::subst(<T&> old, <T&> repl)
+{
+  for(<T>ListNode* p = P; p != &Nil<T>ListNode; p = p->tl)
+    if (p->hd == old)
+      p->hd = repl;
+}
+
+<T> <T>List::reduce(<T>Combiner f, <T&> base)
+{
+  <T> r = base;
+  for(<T>ListNode* p = P; p != &Nil<T>ListNode; p = p->tl)
+    r = (*f)(r, (p->hd));
+  return r;
+}
+
+int <T>List::position(<T&> targ)
+{
+  int l = 0;
+  <T>ListNode* p = P;
+  for (;;)
+  {
+    if (p == &Nil<T>ListNode)
+      return -1;
+    else if (p->hd == targ)
+      return l;
+    else
+    {
+      ++l;
+      p = p->tl;
+    }
+  }
+}
+
+int <T>List::contains(<T&> targ)
+{
+  <T>ListNode* p = P;
+  for (;;)
+  {
+    if (p == &Nil<T>ListNode)
+      return 0;
+    else if (p->hd == targ)
+      return 1;
+    else
+      p = p->tl;
+  }
+}
+
+<T>List <T>List::find(<T&> targ)
+{
+  for (<T>ListNode* p = P; p != &Nil<T>ListNode && !(p->hd == targ); p=p->tl);
+  reference(p);
+  return <T>List(p);
+}
+
+Pix <T>List::seek(<T&> targ)
+{
+  <T>ListNode* p = P; 
+  for (;;)
+  {
+    if (p == &Nil<T>ListNode)
+      return 0;
+    else if (p->hd == targ)
+      return Pix(p);
+    else
+      p = p->tl;
+  }
+}
+
+int <T>List::owns(Pix i)
+{
+  <T>ListNode* p = P; 
+  for (;;)
+  {
+    if (p == &Nil<T>ListNode)
+      return 0;
+    else if (Pix(p) == i)
+      return 1;
+    else
+      p = p->tl;
+  }
+}
+
+<T>List <T>List::find(<T>List& target)
+{
+  <T>ListNode* targ = target.P;
+  if (targ == &Nil<T>ListNode)
+    return <T>List(targ);
+
+  <T>ListNode* p = P;
+  while (p != &Nil<T>ListNode)
+  {
+    if (p->hd == targ->hd)
+    {
+      <T>ListNode* a = p->tl;
+      <T>ListNode* t = targ->tl;
+      for(;;)
+      {
+        if (t == &Nil<T>ListNode)
+        {
+          reference(p);
+          return <T>List(p);
+        }
+        else if (a == &Nil<T>ListNode || !(a->hd == t->hd))
+          break;
+        else
+        {
+          a = a->tl;
+          t = t->tl;
+        }
+      }
+    }
+    p = p->tl;
+  }
+  return <T>List(&Nil<T>ListNode);
+}
+
+int <T>List::contains(<T>List& target)
+{
+  <T>ListNode* targ = target.P;
+  if (targ == &Nil<T>ListNode)
+    return 0;
+
+  <T>ListNode* p = P;
+  while (p != &Nil<T>ListNode)
+  {
+    if (p->hd == targ->hd)
+    {
+      <T>ListNode* a = p->tl;
+      <T>ListNode* t = targ->tl;
+      for(;;)
+      {
+        if (t == &Nil<T>ListNode)
+          return 1;
+        else if (a == &Nil<T>ListNode || !(a->hd == t->hd))
+          break;
+        else
+        {
+          a = a->tl;
+          t = t->tl;
+        }
+      }
+    }
+    p = p->tl;
+  }
+  return 0;
+}
+
+void <T>List::del(<T&> targ)
+{
+  <T>ListNode* h = P;
+
+  for (;;)
+  {
+    if (h == &Nil<T>ListNode)
+    {
+      P = h;
+      return;
+    }
+    else if (h->hd == targ)
+    {
+      <T>ListNode* nxt = h->tl;
+      reference(nxt);
+      dereference(h);
+      h = nxt;
+    }
+    else
+      break;
+  }
+
+  <T>ListNode* trail = h;
+  <T>ListNode* p = h->tl;
+  while (p != &Nil<T>ListNode)
+  {
+    if (p->hd == targ)
+    {
+      <T>ListNode* nxt = p->tl;
+      reference(nxt);
+      dereference(p);
+      trail->tl = nxt;
+      p = nxt;
+    }
+    else
+    {
+      trail = p;
+      p = p->tl;
+    }
+  }
+  P = h;
+}
+
+void <T>List::del(<T>Predicate f)
+{
+  <T>ListNode* h = P;
+  for (;;)
+  {
+    if (h == &Nil<T>ListNode)
+    {
+      P = h;
+      return;
+    }
+    else if ((*f)(h->hd))
+    {
+      <T>ListNode* nxt = h->tl;
+      reference(nxt);
+      dereference(h);
+      h = nxt;
+    }
+    else
+      break;
+  }
+
+  <T>ListNode* trail = h;
+  <T>ListNode* p = h->tl;
+  while (p != &Nil<T>ListNode)
+  {
+    if ((*f)(p->hd))
+    {
+      <T>ListNode* nxt = p->tl;
+      reference(nxt);
+      dereference(p);
+      trail->tl = nxt;
+      p = nxt;
+    }
+    else
+    {
+      trail = p;
+      p = p->tl;
+    }
+  }
+  P = h;
+}
+
+void <T>List::select(<T>Predicate f)
+{
+  <T>ListNode* h = P;
+  for (;;)
+  {
+    if (h == &Nil<T>ListNode)
+    {
+      P = h;
+      return;
+    }
+    else if (!(*f)(h->hd))
+    {
+      <T>ListNode* nxt = h->tl;
+      reference(nxt);
+      dereference(h);
+      h = nxt;
+    }
+    else
+      break;
+  }
+  <T>ListNode* trail = h;
+  <T>ListNode* p = h->tl;
+  while (p != &Nil<T>ListNode)
+  {
+    if (!(*f)(p->hd))
+    {
+      <T>ListNode* nxt = p->tl;
+      reference(nxt);
+      dereference(p);
+      trail->tl = nxt;
+      p = nxt;
+    }
+    else
+    {
+      trail = p;
+      p = p->tl;
+    }
+  }
+  P = h;
+}
+
+void <T>List::reverse()
+{
+  <T>ListNode* l = &Nil<T>ListNode;
+  <T>ListNode* p = P; 
+  while (p != &Nil<T>ListNode)
+  {
+    <T>ListNode* nxt = p->tl;
+    p->tl = l;
+    l = p;
+    p = nxt;
+  }
+  P = l;
+}
+
+
+<T>List copy(<T>List& x)
+{
+  <T>ListNode* a = x.P;
+  if (a == &Nil<T>ListNode)
+    return <T>List(a);
+  else
+  {
+    <T>ListNode* h = new<T>ListNode(a->hd);
+    <T>ListNode* trail = h;
+    for(a = a->tl; a != &Nil<T>ListNode; a = a->tl)
+    {
+      <T>ListNode* n = new<T>ListNode(a->hd);
+      trail->tl = n;
+      trail = n;
+    }
+    trail->tl = &Nil<T>ListNode;
+    return <T>List(h);
+  }
+}
+
+
+<T>List subst(<T&> old, <T&> repl, <T>List& x)
+{
+  <T>ListNode* a = x.P;
+  if (a == &Nil<T>ListNode)
+    return <T>List(a);
+  else
+  {
+    <T>ListNode* h = new <T>ListNode;
+    h->ref = 1;
+    if (a->hd == old)
+      h->hd = repl;
+    else
+      h->hd = a->hd;
+    <T>ListNode* trail = h;
+    for(a = a->tl; a != &Nil<T>ListNode; a = a->tl)
+    {
+      <T>ListNode* n = new <T>ListNode;
+      n->ref = 1;
+      if (a->hd == old)
+        n->hd = repl;
+      else
+        n->hd = a->hd;
+      trail->tl = n;
+      trail = n;
+    }
+    trail->tl = &Nil<T>ListNode;
+    return <T>List(h);
+  }
+}
+
+<T>List combine(<T>Combiner f, <T>List& x, <T>List& y)
+{
+  <T>ListNode* a = x.P;
+  <T>ListNode* b = y.P;
+  if (a == &Nil<T>ListNode || b == &Nil<T>ListNode)
+    return <T>List(&Nil<T>ListNode);
+  else
+  {
+    <T>ListNode* h = new<T>ListNode((*f)(a->hd, b->hd));
+    <T>ListNode* trail = h;
+    a = a->tl;
+    b = b->tl;
+    while (a != &Nil<T>ListNode && b != &Nil<T>ListNode)
+    {
+      <T>ListNode* n = new<T>ListNode((*f)(a->hd, b->hd));
+      trail->tl = n;
+      trail = n;
+      a = a->tl;
+      b = b->tl;
+    }
+    trail->tl = &Nil<T>ListNode;
+    return <T>List(h);
+  }
+}
+
+<T>List reverse(<T>List& x)
+{
+  <T>ListNode* a = x.P;
+  if (a == &Nil<T>ListNode)
+    return <T>List(a);
+  else
+  {
+    <T>ListNode* l = new<T>ListNode(a->hd);
+    l->tl = &Nil<T>ListNode;
+    for(a = a->tl; a != &Nil<T>ListNode; a = a->tl)
+    {
+      <T>ListNode* n = new<T>ListNode(a->hd);
+      n->tl = l;
+      l = n;
+    }
+    return <T>List(l);
+  }
+}
+
+<T>List append(<T>List& x, <T>List& y)
+{
+  <T>ListNode* a = x.P;
+  <T>ListNode* b = y.P;
+  reference(b);
+  if (a != &Nil<T>ListNode)
+  {
+    <T>ListNode* h = new<T>ListNode(a->hd);
+    <T>ListNode* trail = h;
+    for(a = a->tl; a != &Nil<T>ListNode; a = a->tl)
+    {
+      <T>ListNode* n = new<T>ListNode(a->hd);
+      trail->tl = n;
+      trail = n;
+    }
+    trail->tl = b;
+    return <T>List(h);
+  }
+  else
+    return <T>List(b);
+}
+
+void <T>List::prepend(<T>List& y)
+{
+  <T>ListNode* b = y.P;
+  if (b != &Nil<T>ListNode)
+  {
+    <T>ListNode* h = new<T>ListNode(b->hd);
+    <T>ListNode* trail = h;
+    for(b = b->tl; b != &Nil<T>ListNode; b = b->tl)
+    {
+      <T>ListNode* n = new<T>ListNode(b->hd);
+      trail->tl = n;
+      trail = n;
+    }
+    trail->tl = P;
+    P = h;
+  }
+}
+
+<T>List concat(<T>List& x, <T>List& y)
+{
+  <T>ListNode* a = x.P;
+  <T>ListNode* b = y.P;
+  if (a != &Nil<T>ListNode)
+  {
+    <T>ListNode* h = new<T>ListNode(a->hd);
+    <T>ListNode* trail = h;
+    for(a = a->tl; a != &Nil<T>ListNode; a = a->tl)
+    {
+      <T>ListNode* n = new<T>ListNode(a->hd);
+      trail->tl = n;
+      trail = n;
+    };
+    for(;b != &Nil<T>ListNode; b = b->tl)
+    {
+      <T>ListNode* n = new<T>ListNode(b->hd);
+      trail->tl = n;
+      trail = n;
+    }
+    trail->tl = &Nil<T>ListNode;
+    return <T>List(h);
+  }
+  else if (b != &Nil<T>ListNode)
+  {
+    <T>ListNode* h = new<T>ListNode(b->hd);
+    <T>ListNode* trail = h;
+    for(b = b->tl; b != &Nil<T>ListNode; b = b->tl)
+    {
+      <T>ListNode* n = new<T>ListNode(b->hd);
+      trail->tl = n;
+      trail = n;
+    }
+    trail->tl = &Nil<T>ListNode;
+    return <T>List(h);
+  }
+  else
+    return <T>List(&Nil<T>ListNode);
+}
+
+<T>List select(<T>Predicate f, <T>List& x)
+{
+  <T>ListNode* a = x.P;
+  <T>ListNode* h = &Nil<T>ListNode;
+  while (a != &Nil<T>ListNode)
+  {
+    if ((*f)(a->hd))
+    {
+      h = new<T>ListNode(a->hd);
+      <T>ListNode* trail = h;
+      for(a = a->tl; a != &Nil<T>ListNode; a = a->tl)
+      {
+        if ((*f)(a->hd))
+        {
+          <T>ListNode* n = new<T>ListNode(a->hd);
+          trail->tl = n;
+          trail = n;
+        }
+      }
+      trail->tl = &Nil<T>ListNode;
+      break;
+    }
+    else
+      a = a->tl;
+  }
+  return <T>List(h);
+}
+
+<T>List remove(<T>Predicate f, <T>List& x)
+{
+  <T>ListNode* a = x.P;
+  <T>ListNode* h = &Nil<T>ListNode;
+  while (a != &Nil<T>ListNode)
+  {
+    if (!(*f)(a->hd))
+    {
+      h = new<T>ListNode(a->hd);
+      <T>ListNode* trail = h;
+      for(a = a->tl; a != &Nil<T>ListNode; a = a->tl)
+      {
+        if (!(*f)(a->hd))
+        {
+          <T>ListNode* n = new<T>ListNode(a->hd);
+          trail->tl = n;
+          trail = n;
+        }
+      }
+      trail->tl = &Nil<T>ListNode;
+      break;
+    }
+    else
+      a = a->tl;
+  }
+  return <T>List(h);
+}
+
+<T>List remove(<T&> targ, <T>List& x)
+{
+  <T>ListNode* a = x.P;
+  <T>ListNode* h = &Nil<T>ListNode;
+  while (a != &Nil<T>ListNode)
+  {
+    if (!(a->hd == targ))
+    {
+      h = new<T>ListNode(a->hd);
+      <T>ListNode* trail = h;
+      for(a = a->tl; a != &Nil<T>ListNode; a = a->tl)
+      {
+        if (!(a->hd == targ))
+        {
+          <T>ListNode* n = new<T>ListNode(a->hd);
+          trail->tl = n;
+          trail = n;
+        }
+      }
+      trail->tl = &Nil<T>ListNode;
+      break;
+    }
+    else
+      a = a->tl;
+  }
+  return <T>List(h);
+}
+
+<T>List map(<T>Mapper f, <T>List& x)
+{
+  <T>ListNode* a = x.P;
+  <T>ListNode* h = &Nil<T>ListNode;
+  if (a != &Nil<T>ListNode)
+  {
+    h = new<T>ListNode((*f)(a->hd));
+    <T>ListNode* trail = h;
+    for(a = a->tl; a != &Nil<T>ListNode; a = a->tl)
+    {
+      <T>ListNode* n = new<T>ListNode((*f)(a->hd));
+      trail->tl = n;
+      trail = n;
+    }
+    trail->tl = &Nil<T>ListNode;
+  }
+  return <T>List(h);
+}
+
+
+<T>List merge(<T>List& x, <T>List& y, <T>Comparator f)
+{
+  <T>ListNode* a = x.P;
+  <T>ListNode* b = y.P;
+
+  if (a == &Nil<T>ListNode)
+  {
+    if (b == &Nil<T>ListNode)
+      return <T>List(&Nil<T>ListNode);
+    else
+      return copy(y);
+  }
+  else if (b == &Nil<T>ListNode)
+    return copy(x);
+
+  <T>ListNode* h = new <T>ListNode;
+  h->ref = 1;
+  if ((*f)(a->hd, b->hd) <= 0)
+  {
+    h->hd = a->hd;
+    a = a->tl;
+  }
+  else
+  {
+    h->hd = b->hd;
+    b = b->tl;
+  }
+
+  <T>ListNode* r = h;
+
+  for(;;)
+  {
+    if (a == &Nil<T>ListNode)
+    {
+      while (b != &Nil<T>ListNode)
+      {
+        <T>ListNode* n = new <T>ListNode;
+        n->ref = 1;
+        n->hd = b->hd;
+        r->tl = n;
+        r = n;
+        b = b->tl;
+      }
+      r->tl = &Nil<T>ListNode;
+      return <T>List(h);
+    }
+    else if (b == &Nil<T>ListNode)
+    {
+      while (a != &Nil<T>ListNode)
+      {
+        <T>ListNode* n = new <T>ListNode;
+        n->ref = 1;
+        n->hd = a->hd;
+        r->tl = n;
+        r = n;
+        a = a->tl;
+      }
+      r->tl = &Nil<T>ListNode;
+      return <T>List(h);
+    }
+    else if ((*f)(a->hd, b->hd) <= 0)
+    {
+      <T>ListNode* n = new <T>ListNode;
+      n->ref = 1;
+      n->hd = a->hd;
+      r->tl = n;
+      r = n;
+      a = a->tl;
+    }
+    else
+    {
+      <T>ListNode* n = new <T>ListNode;
+      n->ref = 1;
+      n->hd = b->hd;
+      r->tl = n;
+      r = n;
+      b = b->tl;
+    }
+  }
+}
+
+void <T>List::sort(<T>Comparator f)
+{
+  // strategy: place runs in queue, merge runs until done
+  // This is often very fast
+
+  if (P == &Nil<T>ListNode || P->tl == &Nil<T>ListNode)
+    return;
+
+  int qlen = 250;   // guess a good queue size, realloc if necessary
+
+  <T>ListNode** queue = (<T>ListNode**)malloc(qlen * sizeof(<T>ListNode*));
+
+  <T>ListNode* h = P;
+  <T>ListNode* a = h;
+  <T>ListNode* b = a->tl;
+  int qin = 0;
+
+  while (b != &Nil<T>ListNode)
+  {
+    if ((*f)(a->hd, b->hd) > 0)
+    {
+      if (h == a)               // minor optimization: ensure runlen >= 2
+      {
+        h = b;
+        a->tl = b->tl;
+        b->tl = a;
+        b = a->tl;
+      }
+      else
+      {
+        if (qin >= qlen)
+        {
+          qlen *= 2;
+          queue = (<T>ListNode**)realloc(queue, qlen * sizeof(<T>ListNode*));
+        }
+        queue[qin++] = h;
+        a->tl = &Nil<T>ListNode;
+        h = a = b;
+        b = b->tl;
+      }
+    }
+    else
+    {
+      a = b;
+      b = b->tl;
+    }
+  }
+
+  int count = qin;
+  queue[qin] = h;
+  if (++qin >= qlen) qin = 0;
+  int qout = 0;
+
+  while (count-- > 0)
+  {
+    a = queue[qout];
+    if (++qout >= qlen) qout = 0;
+    b = queue[qout];
+    if (++qout >= qlen) qout = 0;
+
+    if ((*f)(a->hd, b->hd) <= 0)
+    {
+      h = a;
+      a = a->tl;
+    }
+    else
+    {
+      h = b;
+      b = b->tl;
+    }
+    queue[qin] = h;
+    if (++qin >= qlen) qin = 0;
+
+    for (;;)
+    {
+      if (a == &Nil<T>ListNode)
+      {
+        h->tl = b;
+        break;
+      }
+      else if (b == &Nil<T>ListNode)
+      {
+        h->tl = a;
+        break;
+      }
+      else if ((*f)(a->hd, b->hd) <= 0)
+      {
+        h->tl = a;
+        h = a;
+        a = a->tl;
+      }
+      else
+      {
+        h->tl = b;
+        h = b;
+        b = b->tl;
+      }
+    }
+  }
+  P = queue[qout];
+  free(queue);
+}
+    
+int <T>List::list_length()
+{
+  <T>ListNode* fast = P;
+  if (fast == &Nil<T>ListNode)
+    return 0;
+
+  <T>ListNode* slow = fast->tl;
+  if (slow == &Nil<T>ListNode)
+    return 1;
+
+  fast = slow->tl;
+  int n = 2;
+
+  for (;;)
+  {
+    if (fast == &Nil<T>ListNode)
+      return n;
+    else if (fast->tl == &Nil<T>ListNode)
+      return n+1;
+    else if (fast == slow)
+      return -1;
+    else
+    {
+      n += 2;
+      fast = fast->tl->tl;
+      slow = slow->tl;
+    }
+  }
+}
+
+void <T>List::error(const char* msg)
+{
+  (*lib_error_handler)("List", msg);
+}
+
+int <T>List::OK()
+{
+  int v = P != 0;               // have a node
+  // check that all nodes OK, even if circular:
+
+  <T>ListNode* fast = P;
+  if (fast != &Nil<T>ListNode)
+  {
+    v &= fast->ref != 0;
+    <T>ListNode* slow = fast->tl;
+    v &= slow->ref != 0;
+    if (v && slow != &Nil<T>ListNode)
+    {
+      fast = slow->tl;
+      v &= fast->ref != 0;
+      while (v)
+      {
+        if (fast == &Nil<T>ListNode)
+          break;
+        else if (fast->tl == &Nil<T>ListNode)
+          break;
+        else if (fast == slow)
+          break;
+        else
+        {
+          v &= fast->ref != 0 && slow->ref != 0;
+          fast = fast->tl->tl;
+          slow = slow->tl;
+        }
+      }
+    }
+  }
+  if (!v) error ("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/List.hP b/usr/include/g++/gen/List.hP
new file mode 100644 (file)
index 0000000..cade890
--- /dev/null
@@ -0,0 +1,279 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>List_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>List_h 1
+
+#ifndef _<T>_typedefs
+#define _<T>_typedefs 1
+typedef void (*<T>Procedure)(<T&>);
+typedef <T>  (*<T>Mapper)(<T&>);
+typedef <T>  (*<T>Combiner)(<T&>, <T&>);
+typedef int  (*<T>Predicate)(<T&>);
+typedef int  (*<T>Comparator)(<T&>, <T&>);
+#endif
+
+#include <Pix.h>
+
+struct <T>ListNode
+{
+  <T>ListNode*          tl;
+  short                 ref;
+  <T>                   hd;
+};
+
+extern <T>ListNode Nil<T>ListNode;
+
+class <T>List
+{
+protected:
+  <T>ListNode*          P;
+
+                        <T>List(<T>ListNode* p);
+public:
+                        <T>List();
+                        <T>List(<T&> head);
+                        <T>List(<T&> head, <T>List& tl);
+                        <T>List(<T>List& a);
+                        <T>List(Pix p);
+                        ~<T>List();
+
+  <T>List&              operator = (<T>List& a);
+
+  int                   null();
+  int                   valid();
+                        operator const void* ();
+  int                   operator ! ();
+
+  int                   length();
+  int                   list_length();
+
+  <T>&                  get();
+  <T>&                  head();
+  <T>&                  operator [] (int n);
+
+  <T>List               nth(int n);
+  <T>List               tail();
+  <T>List               last();
+
+  <T>List               find(<T&> targ);
+  <T>List               find(<T>List& targ);
+  int                   contains(<T&> targ);
+  int                   contains(<T>List& targ);
+  int                   position(<T&> targ);
+
+  friend <T>List        copy(<T>List& a);
+  friend <T>List        concat(<T>List& a, <T>List& b);
+  friend <T>List        append(<T>List& a, <T>List& b);
+  friend <T>List        map(<T>Mapper f, <T>List& a);
+  friend <T>List        merge(<T>List& a, <T>List& b, <T>Comparator f);
+  friend <T>List        combine(<T>Combiner f, <T>List& a, <T>List& b);
+  friend <T>List        reverse(<T>List& a);
+  friend <T>List        select(<T>Predicate f, <T>List& a);        
+  friend <T>List        remove(<T&> targ, <T>List& a);
+  friend <T>List        remove(<T>Predicate f, <T>List& a);
+  friend <T>List        subst(<T&> old, <T&> repl, <T>List& a);
+
+  void                  push(<T&> x);
+  <T>                   pop();
+
+  void                  set_tail(<T>List& p);
+  void                  append(<T>List& p);
+  void                  prepend(<T>List& p);
+  void                  del(<T&> targ);
+  void                  del(<T>Predicate f);
+  void                  select(<T>Predicate f);
+  void                  subst(<T&> old, <T&> repl);
+  void                  reverse();
+  void                  sort(<T>Comparator f);
+
+  void                  apply(<T>Procedure f);
+  <T>                   reduce(<T>Combiner f, <T&> base);
+
+  friend int            operator == (<T>List& a, <T>List& b);
+  friend int            operator != (<T>List& a, <T>List& b);
+
+  Pix                   first();
+  void                  next(Pix& p);
+  Pix                   seek(<T&> item);
+  <T>&                  operator () (Pix p);
+  int                   owns(Pix p);
+
+  void                  error(const char*);
+  int                   OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline void reference(<T>ListNode* p)
+{
+  if (p->ref >= 0) ++p->ref;
+}
+
+inline void dereference(<T>ListNode* p)
+{
+  while (p->ref > 0 && --p->ref == 0)
+  {
+    <T>ListNode* n = p->tl;
+    delete(p);
+    p = n;
+  }
+}
+
+
+inline <T>ListNode* new<T>ListNode(<T&> h)
+{
+  <T>ListNode* p = new <T>ListNode;
+  p->ref = 1;
+  p->hd = h;
+  return p;
+}
+
+inline <T>ListNode* new<T>ListNode(<T&> h, <T>ListNode* t)
+{
+  <T>ListNode* p = new <T>ListNode;
+  p->ref = 1;
+  p->hd = h;
+  p->tl = t;
+  return p;
+}
+
+
+inline <T>List::~<T>List()
+{
+  dereference(P);
+}
+
+inline <T>List::<T>List()
+{
+  P = &Nil<T>ListNode;
+}
+
+inline <T>List::<T>List(<T>ListNode* p)
+{
+  P = p;
+}
+
+inline <T>List::<T>List(<T&> head)
+{
+  P = new<T>ListNode(head);
+  P->tl = &Nil<T>ListNode;
+}
+
+inline <T>List::<T>List(<T&> head, <T>List& tl)
+{
+  P = new<T>ListNode(head, tl.P);
+  reference(P->tl);
+}
+
+inline <T>List::<T>List(<T>List& a)
+{
+  reference(a.P);
+  P = a.P;
+}
+
+
+inline <T>& <T>List::get()
+{
+  return P->hd;
+}
+
+inline <T>& <T>List::head()
+{
+  return P->hd;
+}
+
+
+inline <T>List <T>List::tail()
+{
+  reference(P->tl);
+  return <T>List(P->tl);
+}
+
+
+
+inline int <T>List::null()
+{
+  return P == &Nil<T>ListNode;
+}
+
+inline int <T>List::valid()
+{
+  return P != &Nil<T>ListNode;
+}
+
+inline <T>List::operator const void* ()
+{
+  return (P == &Nil<T>ListNode)? 0 : this;
+}
+
+inline int <T>List::operator ! ()
+{
+  return (P == &Nil<T>ListNode);
+}
+
+
+inline void <T>List::push(<T&> head)
+{
+  <T>ListNode* oldp = P;
+  P = new<T>ListNode(head, oldp);
+}
+
+
+inline int operator != (<T>List& x, <T>List& y)
+{
+  return !(x == y);
+}
+
+inline Pix <T>List::first()
+{
+  return (P == &Nil<T>ListNode)? 0 : Pix(P);
+}
+
+inline <T>& <T>List::operator () (Pix p)
+{
+  return ((<T>ListNode*)p)->hd;
+}
+
+inline void <T>List::next(Pix& p)
+{
+  if (p != 0)
+  {
+    p = Pix(((<T>ListNode*)p)->tl);
+    if (p == &Nil<T>ListNode) p = 0;
+  }
+}
+
+inline <T>List::<T>List(Pix p)
+{
+  P = (<T>ListNode*)p;
+  reference(P);
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/MPlex.ccP b/usr/include/g++/gen/MPlex.ccP
new file mode 100644 (file)
index 0000000..2008d85
--- /dev/null
@@ -0,0 +1,850 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.MPlex.h"
+
+// <T>MChunk support
+
+
+<T>MChunk::<T>MChunk(<T>*    d,      
+               int      baseidx,
+               int      lowidx, 
+               int      fenceidx,
+               int      topidx)
+     : <T>IChunk(d, baseidx, lowidx, fenceidx, topidx)
+{
+  unused = fence - low;
+  unsigned msize = (top - base)/_MAP_BITS + 1;
+  map = (unsigned long *) (new long[msize]);
+  bzero((void*)map, msize * sizeof(long));
+}
+
+void <T>MChunk:: shrink_high ()
+{
+  if (fence <= low) empty_error();
+  --fence;
+  if (!valid(fence)) 
+    --unused;
+  else
+    free(fence);
+  reset_high();
+}
+
+void <T>MChunk:: shrink_low ()
+{
+  if (fence <= low) empty_error();
+  if (!valid(low)) 
+    --unused;
+  else
+    free(low);
+  ++low;
+  reset_low();
+}
+
+void <T>MChunk::clear(int lo)
+{
+  int s = top - base;
+  low = base = fence = lo;
+  top = base + s;
+  unused = 0;
+  bzero((void*)map, ((top - base)/_MAP_BITS + 1) * sizeof(long));
+}
+
+void <T>MChunk::cleardown(int hi)
+{
+  int s = top - base;
+  low = top = fence = hi;
+  base = top - s;
+  unused = 0;
+  bzero((void*)map, ((top - base)/_MAP_BITS + 1) * sizeof(long));
+}
+
+int <T>MChunk::del(int idx)
+{
+  if (idx < low || idx >= fence) index_error();
+  int v = valid(idx);
+  if (v)
+  {
+    free(idx);
+    ++unused;
+  }
+  return v;
+}
+
+
+int <T>MChunk::undel(int idx)
+{
+  if (idx < low || idx >= fence) index_error();
+  int v = valid(idx);
+  if (!v)
+  {
+    mark(idx);
+    --unused;
+  }
+  return v;
+}
+
+int <T>MChunk::unused_index() const
+{
+  if (unused_indices() == 0) index_error();
+  int slot;
+  if (low == base)              // can traverse 32 slots at a time
+  {
+    int blk = 0;
+    while (map[blk] == ~0L) ++blk;
+    slot = blk * _MAP_BITS + base;
+  }
+  else
+    slot = low;
+
+  while(valid(slot)) ++slot;
+  return slot;
+}
+
+int <T>MChunk::first_index() const
+{
+  if (empty()) return fence;
+  int slot;
+  if (low == base)
+  {
+    int blk = 0;
+    while (map[blk] == 0) ++blk;
+    slot = blk * _MAP_BITS + base;
+  }
+  else
+    slot = low;
+
+  while(!valid(slot)) ++slot;
+  return slot;
+}
+
+int <T>MChunk::last_index() const
+{
+  if (empty()) return low - 1;
+  int slot;
+  if (top == fence)
+  {
+    int blk = (top - base) / _MAP_BITS;
+    while (map[blk] == 0) --blk;
+    slot = blk * _MAP_BITS + base + _MAP_BITS - 1;
+  }
+  else
+    slot = fence - 1;
+
+  while(!valid(slot)) --slot;
+  return slot;
+}
+
+
+int <T>MChunk:: OK() const
+{
+  int v = data != 0;             // have some data
+  v &= map != 0;                 // and a map
+  v &= base <= low;              // ok, index-wise
+  v &= low <= fence;
+  v &= fence <= top;
+
+  v &=  ((<T>MChunk*)(nxt->prev())) == this;      // and links are OK
+  v &=  ((<T>MChunk*)(prv->next())) == this;
+
+  int bitcount = 0;              // and unused count correct
+  for (int i = low; i < fence; ++i) if (!valid(i)) ++bitcount;
+  v &= unused == bitcount;
+  
+  if (!v) error("invariant failure");
+  return(v);
+}
+
+<T>* <T>MChunk::succ(<T>* p) const
+{
+  int i = ((int) p - (int) data) / sizeof(<T>) + base + 1;
+  if (p == 0 || i < low) return 0;
+  while (i < fence && !valid(i)) ++i;
+  if (i >= fence) return 0;
+  return pointer_to(i);
+}
+
+<T>* <T>MChunk::pred(<T>* p) const
+{
+  int i = ((int) p - (int) data) / sizeof(<T>) + base - 1;
+  if (p == 0 || i >= fence) return 0;
+  while (i >= low && !valid(i)) --i;
+  if (i < low) return 0;
+  return pointer_to(i);
+}
+
+<T>* <T>MChunk::first_pointer() const
+{
+  if (empty()) return 0;
+  int slot;
+  if (low == base)
+  {
+    int blk = 0;
+    while (map[blk] == 0) ++blk;
+    slot = blk * _MAP_BITS + base;
+  }
+  else
+    slot = low;
+
+  while(!valid(slot)) ++slot;
+  return pointer_to(slot);
+}
+
+<T>* <T>MChunk::last_pointer() const
+{
+  if (empty()) return 0;
+  int slot;
+  if (top == fence)
+  {
+    int blk = (top - base) / _MAP_BITS;
+    while (map[blk] == 0) --blk;
+    slot = blk * _MAP_BITS + base + _MAP_BITS - 1;
+  }
+  else
+    slot = fence - 1;
+
+  while(!valid(slot)) --slot;
+  return pointer_to(slot);
+}
+
+<T>MPlex:: <T>MPlex()
+{
+  unused = 0;
+  lo = fnc = 0;
+  csize = DEFAULT_INITIAL_CAPACITY;
+  <T>* data = new <T>[csize];
+  hd = ch = new <T>MChunk(data,  lo, lo, fnc, lo+csize);
+}
+
+<T>MPlex:: <T>MPlex(int chunksize)
+{
+  if (chunksize == 0) error("invalid constructor specification");
+  unused = 0;
+  lo = fnc = 0;
+  if (chunksize > 0)
+  {
+    csize = chunksize;
+    <T>* data = new <T>[csize];
+    hd = ch = new <T>MChunk(data,  lo, lo, fnc, csize);
+  }
+  else
+  {
+    csize = -chunksize;
+    <T>* data = new <T>[csize];
+    hd = ch = new <T>MChunk(data,  chunksize, lo, fnc, fnc);
+  }
+}
+
+
+<T>MPlex:: <T>MPlex(int l, int chunksize)
+{
+  if (chunksize == 0) error("invalid constructor specification");
+  unused = 0;
+  lo = fnc = l;
+  if (chunksize > 0)
+  {
+    csize = chunksize;
+    <T>* data = new <T>[csize];
+    hd = ch = new <T>MChunk(data,  lo, lo, fnc, csize+lo);
+  }
+  else
+  {
+    csize = -chunksize;
+    <T>* data = new <T>[csize];
+    hd = ch = new <T>MChunk(data,  chunksize+lo, lo, fnc, fnc);
+  }
+}
+
+
+void <T>MPlex::make_initial_chunks(int up)
+{
+  int need = fnc - lo;
+  hd = 0;
+  if (up)
+  {
+    int l = lo;
+    do
+    {
+      int sz;
+      if (need >= csize)
+        sz = csize;
+      else
+        sz = need;
+      <T>* data = new <T> [csize];
+      <T>MChunk* h = new <T>MChunk(data,  l, l, l+sz, l+csize);
+      if (hd != 0)
+        h->link_to_next(hd);
+      else
+        hd = h;
+      l += sz;
+      need -= sz;
+    } while (need > 0);
+  }
+  else
+  {
+    int hi = fnc;
+    do
+    {
+      int sz;
+      if (need >= csize)
+        sz = csize;
+      else
+        sz = need;
+      <T>* data = new <T> [csize];
+      <T>MChunk* h = new <T>MChunk(data,  hi-csize, hi-sz, hi, hi);
+      if (hd != 0)
+        h->link_to_next(hd);
+      hd = h;
+      hi -= sz;
+      need -= sz;
+    } while (need > 0);
+  }
+  ch = (<T>MChunk*) hd;
+}
+
+<T>MPlex:: <T>MPlex(int l, int hi, const <T&> initval, int chunksize)
+{
+  lo = l;
+  fnc = hi + 1;
+  if (chunksize == 0)
+  {
+    csize = fnc - l;
+    make_initial_chunks(1);
+  }
+  else if (chunksize < 0)
+  {
+    csize = -chunksize;
+    make_initial_chunks(0);
+  }
+  else
+  {
+    csize = chunksize;
+    make_initial_chunks(1);
+  }
+  unused = fnc - lo;
+  for (int i=lo; i<fnc; ++i)
+    undel_index(i);
+  fill(initval);
+}
+
+<T>MPlex::<T>MPlex(const <T>MPlex& a)
+{
+  lo = a.lo;
+  fnc = a.fnc;
+  csize = a.csize;
+  unused = fnc - lo;
+  hd = 0;
+  const <T>IChunk* p = a.hd;
+  do
+  {
+    <T>* data = new <T> [p->size()];
+    <T>MChunk* h = new <T>MChunk(data,  p->base_index(),
+                          p->low_index(), p->fence_index(), p->top_index());
+    if (hd != 0)
+      h->link_to_next(hd);
+    else
+      hd = h;
+    p = p->next();
+  } while (p != a.hd);
+  ch = (<T>MChunk*) hd;
+  for (int i = a.low(); i < a.fence(); a.next(i)) 
+  {
+    undel_index(i);
+    (*this)[i] = a[i];
+  }
+}
+
+void <T>MPlex::operator= (const <T>MPlex& a)
+{
+  if (&a != this)
+  {
+    invalidate();
+    lo = a.lo;
+    fnc = a.fnc;
+    csize = a.csize;
+    unused = fnc - lo;
+    hd = 0;
+    const <T>IChunk* p = a.hd;
+    do
+    {
+      <T>* data = new <T> [p->size()];
+      <T>MChunk* h = new <T>MChunk(data,  p->base_index(),
+                                   p->low_index(), p->fence_index(), 
+                                   p->top_index());
+      if (hd != 0)
+        h->link_to_next(hd);
+      else
+        hd = h;
+      p = p->next();
+    } while (p != a.hd);
+    ch = (<T>MChunk*) hd;
+    for (int i = a.low(); i < a.fence(); a.next(i)) 
+    {
+      undel_index(i);
+      (*this)[i] = a[i];
+    }
+  }
+}
+
+int <T>MPlex::valid(int idx) const
+{
+  const <T>MChunk* tail = (<T>MChunk*)tl();
+  const <T>MChunk* t = ch;
+  while (idx >= t->fence_index())
+  {
+    if (t == tail)  return 0; 
+    t = ((<T>MChunk*)(t->next()));
+  }
+  while (idx < t->low_index())
+  {
+    if (t == (<T>MChunk*)(hd)) return 0; 
+    t = ((<T>MChunk*)(t->prev()));
+  }
+  set_cache(t);
+  return t-><T>MChunk::valid_index(idx);
+}
+
+void <T>MPlex::cache(int idx) const
+{
+  const <T>MChunk* tail = (<T>MChunk*)tl();
+  const <T>MChunk* t = ch;
+  while (idx >= t->fence_index())
+  {
+    if (t == tail) index_error();
+    t = ((<T>MChunk*)(t->next()));
+  }
+  while (idx < t->low_index())
+  {
+    if (t == (<T>MChunk*)hd) index_error();
+    t = ((<T>MChunk*)(t->prev()));
+  }
+  if (!t-><T>MChunk::valid_index(idx)) index_error();
+  set_cache(t);
+}
+
+void <T>MPlex::cache(const <T>* p) const
+{
+  const <T>MChunk* old = ch;
+  const <T>MChunk* t = ch;
+  while (!t->actual_pointer(p))
+  {
+    t = ((<T>MChunk*)(t->next()));
+    if (t == old) index_error();
+  }
+  if (!t-><T>MChunk::valid_pointer(p)) index_error();
+  set_cache(t);
+}
+
+int <T>MPlex::owns(Pix px) const
+{
+  <T>* p = (<T>*)px;
+  const <T>MChunk* old = ch;
+  const <T>MChunk* t = ch;
+  while (!t->actual_pointer(p))
+  {
+    t = ((<T>MChunk*)(t->next()));
+    if (t == old)  return 0; 
+  }
+  set_cache(t);
+  return t-><T>MChunk::valid_pointer(p);
+}
+
+int <T>MPlex::add_high(const <T&> elem)
+{
+  <T>MChunk* t = ((<T>MChunk*) tl());
+
+  if (!t->can_grow_high())
+  {
+    <T>* data = new <T> [csize];
+    t = (new <T>MChunk(data, fnc,fnc,fnc,fnc+csize));
+    t->link_to_prev(tl());
+  }
+
+  *((t-><T>MChunk::grow_high())) = elem;
+  set_cache(t);
+  return fnc++;
+}
+
+int <T>MPlex::add_low (const <T&> elem)
+{
+  <T>MChunk* t = ((<T>MChunk*) hd);
+  if (!t->can_grow_low())
+  {
+    <T>* data = new <T> [csize];
+    hd = new <T>MChunk(data,  lo-csize, lo, lo, lo);
+    hd->link_to_next(t);
+    t = ((<T>MChunk*) hd);
+  }
+
+  *((t-><T>MChunk::grow_low())) = elem;
+  set_cache(t);
+  return --lo;
+}
+
+void <T>MPlex::adjust_bounds()
+{
+  <T>MChunk* t = ((<T>MChunk*) tl());
+
+  // clean up tail
+
+  t->reset_high();
+  while (t-><T>MChunk::empty() && !one_chunk())
+  {
+    <T>MChunk* pred = (<T>MChunk*)(t->prev());
+    del_chunk(t);
+    pred->reset_high();
+    t = (pred);
+  }
+  if (one_chunk())
+    t->reset_high();
+
+  int oldfnc = fnc;
+  fnc = t->fence_index();
+  unused -= oldfnc - fnc;
+
+  // and head..
+  t = ((<T>MChunk*) hd);
+  t->reset_low();
+  while (t-><T>MChunk::empty() && !one_chunk())
+  {
+    hd = (<T>MChunk*)(t->next());
+    del_chunk(t);
+    t = ((<T>MChunk*) hd);
+    t->reset_low();
+  }
+
+  int oldlo = lo;
+  lo = t->low_index();
+  unused -= lo - oldlo;
+
+
+  set_cache(t);
+}
+
+int <T>MPlex::del_high ()
+{
+  if (empty()) empty_error();
+  <T>MChunk* t = ((<T>MChunk*) tl());
+  while (t-><T>MChunk::empty() && !one_chunk()) // possible stragglers
+  {
+    <T>MChunk* pred = (<T>MChunk*)(t->prev());
+    del_chunk(t);
+    pred->reset_high();
+    t = (pred);
+  }
+  t-><T>MChunk::shrink_high();
+  while (t-><T>MChunk::empty() && !one_chunk())
+  {
+    <T>MChunk* pred = (<T>MChunk*)(t->prev());
+    del_chunk(t);
+    pred->reset_high();
+    t = (pred);
+  }
+  int oldfnc = fnc;
+  fnc = t->fence_index();
+  unused -= oldfnc - fnc - 1;
+  set_cache(t);
+  return fnc - 1;
+}
+
+int <T>MPlex::del_low ()
+{
+  if (empty()) empty_error();
+  <T>MChunk* t = ((<T>MChunk*) hd);
+  while (t-><T>MChunk::empty() && !one_chunk())
+  {
+    hd = (<T>MChunk*)(t->next());
+    del_chunk(t);
+    t = ((<T>MChunk*) hd);
+    t->reset_low();
+  }
+  t-><T>MChunk::shrink_low();
+  while (t-><T>MChunk::empty() && !one_chunk())
+  {
+    hd = (<T>MChunk*)(t->next());
+    del_chunk(t);
+    t = ((<T>MChunk*) hd);
+    t->reset_low();
+  }
+  int oldlo = lo;
+  lo = t->low_index();
+  unused -= lo - oldlo - 1;
+  set_cache(t);
+  return lo;
+}
+
+int <T>MPlex::add(const <T&> elem)
+{
+  if (unused == 0) 
+    return add_high(elem);
+
+  for(<T>MChunk* t = ch; 
+      t->unused_indices() == 0; 
+      t = (<T>MChunk*)(t->prev()))
+    ;
+
+  int i =  t->unused_index();
+  set_cache(t);
+  undel_index(i);
+  (*this)[i] = elem;
+  return i;
+}
+
+int <T>MPlex::unused_index() const
+{
+  if (unused == 0) index_error();
+
+  for(<T>MChunk* t = ch; 
+      t->unused_indices() == 0; 
+      t = (<T>MChunk*)(t->prev()))
+    ;
+
+  set_cache(t);
+  return t->unused_index();
+}
+
+Pix <T>MPlex::unused_Pix() const
+{
+  if (unused == 0) return 0;
+
+  for(<T>MChunk* t = ch; 
+      t->unused_indices() == 0; 
+      t = (<T>MChunk*)(t->prev()))
+    ;
+
+  set_cache(t);
+  return t->pointer_to(t->unused_index()); 
+}
+
+int <T>MPlex::del_index(int idx)
+{
+  if (idx < lo || idx >= fnc) index_error();
+  if (<T>MPlex::valid(idx))
+  {
+    ++unused;
+    ch-><T>MChunk::del(idx);
+    return 1;
+  }
+  else
+    return 0;
+}
+
+int <T>MPlex::dopred(int idx) const
+{
+
+  if (idx >= fnc) idx = fnc;
+  if (idx <= lo) return lo - 1;
+
+  const <T>MChunk* t = ch;
+  
+  while (idx > t->fence_index())
+  {
+    t = ((<T>MChunk*)(t->next()));
+  }
+  while (idx <= t->low_index())
+  {
+    t = ((<T>MChunk*)(t->prev()));
+  }
+  int i = t-><T>MChunk::pred(idx);
+  while (i < t->low_index() && i >= lo)
+  {
+    t = ((<T>MChunk*)(t->prev()));
+    i = t-><T>MChunk::last_index();
+  }
+  set_cache(t);
+  return i;
+}
+
+
+int <T>MPlex::dosucc(int idx) const
+{
+  if (idx < lo) idx = lo;
+  if (idx >= fnc - 1) return fnc;
+
+  const <T>MChunk* t = ch;
+  while (idx >= t->fence_index())
+  {
+    t = ((<T>MChunk*)(t->next()));
+  }
+  while (idx < t->low_index())
+  {
+    t = ((<T>MChunk*)(t->prev()));
+  }
+  int i = t-><T>MChunk::succ(idx);
+  while (i >= t->fence_index() && i < fnc)
+  {
+    t = (<T>MChunk*)(t->next());
+    i = t-><T>MChunk::first_index();
+  }
+  set_cache(t);
+  return i;
+}
+
+void <T>MPlex::prev(Pix& i) const
+{
+  if (i == 0) return;
+
+  <T>* p = (<T>*) i;
+  const <T>MChunk* old = ch;
+  const <T>MChunk* t = ch;
+
+  while (!t->actual_pointer(p))
+  {
+    t = ((<T>MChunk*)(t->prev()));
+    if (t == old) 
+    { 
+      i = 0; 
+      return; 
+    }
+  }
+  <T>* q = t-><T>MChunk::pred(p);
+  while (q == 0 && t != (<T>MChunk*)hd)
+  {
+    t = ((<T>MChunk*)(t->prev()));
+    q = t-><T>MChunk::last_pointer();
+  }
+
+  i = Pix(q); 
+  set_cache(t);
+  return; 
+}
+
+void <T>MPlex::next(Pix& i) const
+{
+  if (i == 0) return;
+
+  <T>* p = (<T>*) i;
+  const <T>MChunk* tail = (<T>MChunk*)(tl());
+  const <T>MChunk* old = ch;
+  const <T>MChunk* t = ch;
+
+  while (!t->actual_pointer(p))
+  {
+    t = ((<T>MChunk*)(t->next()));
+    if (t == old) 
+    { 
+      i = 0; 
+      return; 
+    }
+  }
+  <T>* q = t-><T>MChunk::succ(p);
+  while  (q == 0 && t != tail)
+  {
+    t = ((<T>MChunk*)(t->next()));
+    q = t-><T>MChunk::first_pointer();
+  }
+
+  i = Pix(q); 
+  set_cache(t);
+  return; 
+}
+
+    
+void <T>MPlex::undel_index(int idx)
+{
+  if (idx < lo || idx >= fnc) index_error();
+
+  <T>MChunk* t = ch;
+  while (idx >= t->fence_index())
+  {
+    t = ((<T>MChunk*)(t->next()));
+  }
+  while (idx < t->low_index())
+  {
+    t = ((<T>MChunk*)(t->prev()));
+  }
+  int was_present = t-><T>MChunk::undel(idx);
+  if (!was_present) 
+  {
+    --unused;
+  }
+  set_cache(t);
+  return;
+}
+
+void <T>MPlex::clear()
+{
+  if (fnc != lo)
+  {
+    <T>MChunk* t = ((<T>MChunk*)tl());
+    while (t != hd)
+    {
+      <T>MChunk* prv = (<T>MChunk*)(t->prev());
+      del_chunk(t);
+      t = prv;
+    }
+    t-><T>MChunk::clear(lo);
+    set_cache(t);
+    fnc = lo;
+    unused = 0;
+  }
+}
+
+int <T>MPlex::OK () const
+{
+  int v = hd != 0;                    // at least one chunk
+
+  int found_ch = 0;                   // to make sure ch is in list;
+
+  int count = 0;                      // to count unused slots
+
+  const <T>MChunk* t = (<T>MChunk*)(hd);
+
+  int gap = t->low_index() - lo;
+  v &= gap == 0;                      // hd lo not less than lo.
+  count += gap;
+
+  for (;;)
+  {
+    if (t == ch) ++found_ch;
+    v &= t-><T>MChunk::OK();             // each chunk is OK
+    count += t->unused_indices();
+    if (t == (<T>MChunk*)(tl()))
+      break;
+    else                              // and has indices less than succ
+    {
+      gap = t->next()->base_index() - t->top_index();
+      v &= gap == 0;
+      count += gap;
+
+      if (t != (<T>MChunk*)hd)                  // internal chunks can't grow
+        v &= !t->can_grow_low() && !t->can_grow_high();
+
+      t = (const <T>MChunk*)(t->next());
+    }
+  }
+  gap = fnc - t->fence_index();
+  v &= gap == 0;
+  count += gap;
+
+  v &= count == unused;              // chunk counts agree with plex
+
+  v &= found_ch == 1;
+  if (!v) error("invariant failure");
+  return v;
+}
+
diff --git a/usr/include/g++/gen/MPlex.hP b/usr/include/g++/gen/MPlex.hP
new file mode 100644 (file)
index 0000000..83e2863
--- /dev/null
@@ -0,0 +1,422 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _<T>MPlex_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>MPlex_h 1
+
+
+#include "<T>.Plex.h"
+
+
+// Number of bits per long, used in MChunk bit map operations
+
+#define _MAP_BITS  32
+
+
+class <T>MChunk : public <T>IChunk
+{
+protected:
+
+  unsigned long* map;          // bitmap of slots
+  int            unused;       // number of unused internal slots 
+
+  void           mark(int);    // bitmap operations
+  void           free(int);
+  int            valid(int) const;
+
+public:
+
+                 <T>MChunk(<T>*    d,        // ptr to array of elements
+                        int      base_idx, // initial indices
+                        int      low_idx,  // & initially clear map
+                        int      fence_idx,
+                        int      top_idx);
+
+                 ~<T>MChunk();
+
+// virtuals
+
+  int            first_index() const;
+  int            last_index() const;
+  int            succ(int idx) const;
+  int            pred(int idx) const;
+  <T>*           first_pointer() const;                 
+  <T>*           last_pointer() const;                 
+  <T>*           succ(<T>*) const;                 
+  <T>*           pred(<T>*) const; 
+  int            empty() const;
+  int            full() const;
+  int            valid_index(int i) const;
+  int            valid_pointer(const <T>* p) const;
+  <T>*           grow_high ();
+  <T>*           grow_low ();  
+  void           shrink_high ();
+  void           shrink_low ();     
+  void           clear(int);
+  void           cleardown(int);
+  int            OK() const;
+
+// extensions
+
+  int            unused_indices() const;   // how many free slot in low..fence?
+
+  int            unused_index() const;     // return index of free slot
+
+  int            del(int i);         // delete data indexed by i
+                                     // return true if was present
+  int            undel(int idx);     // un-delete data indexed by i
+                                     // return true if already present
+
+  void           reset_low();        // reset low = lowest valid index; 
+  void           reset_high();       // same for high
+
+};
+
+
+class <T>MPlex: public <T>Plex
+{
+  <T>MChunk*       ch;          // cached chunk
+  int              unused;      // # of free slots between low & fence
+
+  void             make_initial_chunks(int up = 1);
+  void             cache(int idx) const;
+  void             cache(const <T>* p) const;
+  int              dopred(int) const;
+  int              dosucc(int) const;
+
+  void             set_cache(const <T>MChunk* t) const; // logically, 
+                                               // not physically const
+
+public:
+                   <T>MPlex();                 // set low = 0;
+                                               // fence = 0;
+                                               // csize = default
+
+                   <T>MPlex(int ch_size);      // low = 0; 
+                                               // fence = 0;
+                                               // csize = ch_size
+
+                   <T>MPlex(int lo,            // low = lo; 
+                            int ch_size);      // fence=lo
+                                               // csize = ch_size
+
+                   <T>MPlex(int lo,            // low = lo
+                            int hi,            // fence = hi+1
+                            const <T&> initval,// fill with initval,
+                            int ch_size = 0);  // csize= ch_size
+                                               // or fence-lo if 0
+
+                   <T>MPlex(const <T>MPlex&);
+
+  void             operator= (const <T>MPlex&);
+
+// virtuals 
+
+  <T>&             high_element ();
+  <T>&             low_element ();
+  const <T>&       high_element () const;
+  const <T>&       low_element () const;
+
+  Pix              first() const;
+  Pix              last() const ;
+  void             prev(Pix& ptr) const;
+  void             next(Pix& ptr) const;
+  int              owns(Pix p) const;
+  <T>&             operator () (Pix p);
+  const <T>&       operator () (Pix p) const;
+
+  int              low() const; 
+  int              high() const;
+  int              valid(int idx) const;
+  void             prev(int& idx) const;
+  void             next(int& x) const;
+  <T>&             operator [] (int index);
+  const <T>&       operator [] (int index) const;
+    
+  int              Pix_to_index(Pix p) const;
+  Pix              index_to_Pix(int idx) const;
+
+  int              can_add_high() const;
+  int              can_add_low() const;
+  int              full() const;
+
+  int              add_high(const <T&> elem);
+  int              del_high ();
+  int              add_low (const <T&> elem);
+  int              del_low ();
+  void             clear();
+
+  int              OK () const; 
+
+// extensions
+
+  int              count() const;             // # valid elements
+  int              available() const;         // # deleted elements
+
+  int              unused_index()const;       // return index of a deleted elem
+  Pix              unused_Pix() const;        // return Pix of a deleted elem
+
+  int              del_index(int idx);        // logically delete at idx;
+                                              // return true if was present
+  int              del_Pix(Pix p);            // delete at p
+
+  void             undel_index(int idx);      // undelete at idx;
+  void             undel_Pix(Pix p);          // undelete at p;
+
+  void             adjust_bounds();           // reset lo, hi to lowest &
+                                              // highest valid indices
+
+  int              add(const <T&> elem);      // add anywhere
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>MChunk:: ~<T>MChunk()
+{
+  delete map;
+}
+
+inline void <T>MChunk::mark(int idx)
+{
+  unsigned int i = idx - base;
+  map[i / _MAP_BITS] |= 1 << (i & (_MAP_BITS - 1));
+}
+
+inline void <T>MChunk::free(int idx)
+{
+  unsigned int i = idx - base;
+  map[i / _MAP_BITS] &= ~(1 << (i & (_MAP_BITS - 1)));
+}
+
+inline int <T>MChunk::valid(int idx) const
+{
+  unsigned int i = idx - base;
+  return map[i / _MAP_BITS] & (1 << (i & (_MAP_BITS - 1)));
+}
+
+inline  int <T>MChunk:: valid_index(int i) const
+{
+  return i >= low && i < fence && valid(i);
+}
+
+inline  int  <T>MChunk:: valid_pointer(const <T>* p) const
+{
+  int i = ((int)p - (int)data) / sizeof(<T>);
+  return i >= 0 && i < (fence - base) &&
+    (map[(unsigned)i / _MAP_BITS] & (1 << (i & (_MAP_BITS - 1))));
+}
+
+inline int <T>MChunk::empty() const
+{
+  return  fence - low - unused == 0;
+}
+
+inline int <T>MChunk::full() const
+{
+  return  unused + (top - fence) + (low - base) == 0;
+}
+
+inline int <T>MChunk::succ(int idx) const
+{
+  int i = (idx < low)? low : idx + 1;
+  while (i < fence && !valid(i)) ++i;
+  return i;
+}
+
+inline int <T>MChunk::pred(int idx) const
+{
+  int i = (idx > fence)? (fence - 1) : idx - 1;
+  while (i >= low && !valid(i)) --i;
+  return i;
+}
+
+inline int <T>MChunk::unused_indices() const
+{
+  return unused;
+}
+
+inline <T>*   <T>MChunk:: grow_high ()
+{
+  if (!can_grow_high()) full_error();
+  mark(fence);
+  return &(data[fence++ - base]);
+}
+
+inline <T>*   <T>MChunk:: grow_low ()
+{
+  if (!can_grow_low()) full_error();
+  mark(--low);
+  return &(data[low - base]);
+}
+
+inline void <T>MChunk::reset_low()
+{
+  while (low < fence && !valid(low))
+  {
+    --unused;
+    ++low;
+  }
+}
+
+inline void <T>MChunk::reset_high()
+{
+  while (fence > low && !valid(fence - 1))
+  {
+    --unused;
+    --fence;
+  }
+}
+
+inline  int <T>MPlex::full () const
+{
+  return 0;
+}
+
+inline int <T>MPlex::can_add_high() const
+{
+  return 1;
+}
+
+inline int <T>MPlex::can_add_low() const
+{
+  return 1;
+}
+
+inline int <T>MPlex::available() const
+{
+  return unused;
+}
+
+inline int <T>MPlex::count() const
+{
+  return fnc - lo - unused;
+}
+
+inline void <T>MPlex::set_cache(const <T>MChunk* t) const
+{
+  ((<T>MPlex*)(this))->ch = (<T>MChunk*)t;
+}
+
+inline <T>& <T>MPlex:: operator [] (int idx)
+{
+  if (!ch-><T>MChunk::valid_index(idx)) cache(idx);
+  return * (ch->pointer_to(idx));
+}
+
+inline const <T>& <T>MPlex:: operator [] (int idx) const
+{
+  if (!ch-><T>MChunk::valid_index(idx)) cache(idx);
+  return * ((const <T>*)(ch->pointer_to(idx)));
+}
+
+inline  int <T>MPlex::Pix_to_index(Pix p) const
+{
+  if (!ch-><T>MChunk::valid_pointer((<T>*)p)) cache((<T>*)p);
+  return ch->index_of((<T>*)p);
+}
+
+inline int <T>MPlex::high() const
+{
+  return (((const <T>MChunk*)tl())-><T>MChunk::valid_index(fnc-1)) ? 
+    fnc-1 : dopred(fnc-1);
+}
+
+inline int <T>MPlex::low() const
+{
+  return (((const <T>MChunk*)hd)-><T>MChunk::valid_index(lo))? lo : dosucc(lo);
+}
+
+inline  <T>& <T>MPlex::low_element ()
+{
+  return (*this)[low()];
+}
+
+inline const <T>& <T>MPlex::low_element () const
+{
+  return (*this)[low()];
+}
+
+inline  <T>& <T>MPlex::high_element ()
+{
+  return (*this)[high()];
+}
+
+inline const <T>& <T>MPlex::high_element () const
+{
+  return (*this)[high()];
+}
+
+inline  Pix <T>MPlex::index_to_Pix(int idx) const
+{
+  if (!ch-><T>MChunk::valid_index(idx)) cache(idx);
+  return Pix(ch->pointer_to(idx));
+}
+
+inline void <T>MPlex::next(int& idx) const
+{
+  idx = (ch-><T>MChunk::valid_index(idx+1))? idx+1 : dosucc(idx);
+}
+
+inline void <T>MPlex::prev(int& idx) const
+{
+  idx = (ch-><T>MChunk::valid_index(idx-1))? idx-1 : dopred(idx);
+}
+
+inline Pix <T>MPlex::first() const
+{
+  return index_to_Pix(low());
+}
+
+inline Pix <T>MPlex::last() const
+{
+  return index_to_Pix(high());
+}
+
+
+inline void <T>MPlex::undel_Pix(Pix p)
+{
+  undel_index(Pix_to_index(p));
+}
+
+inline int <T>MPlex::del_Pix(Pix p)
+{
+  return del_index(Pix_to_index(p));
+}
+
+inline <T>& <T>MPlex:: operator () (Pix p)
+{
+  return *((<T>*)p);
+}
+
+inline const <T>& <T>MPlex:: operator () (Pix p) const
+{
+  return *((const <T>*)p);
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/Map.ccP b/usr/include/g++/gen/Map.ccP
new file mode 100644 (file)
index 0000000..4bf2541
--- /dev/null
@@ -0,0 +1,63 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <builtin.h>
+#include "<T>.<C>.Map.h"
+
+
+Pix <T><C>Map::seek(<T&> item)
+{
+  for (Pix i = first(); i != 0 && !(<T>EQ(key(i), item)); next(i));
+  return i;
+}
+
+int <T><C>Map::owns(Pix idx)
+{
+  if (idx == 0) return 0;
+  for (Pix i = first(); i; next(i)) if (i == idx) return 1;
+  return 0;
+}
+
+void <T><C>Map::clear()
+{
+  Pix i = first(); 
+  while (i != 0)
+  {
+    del(key(i));
+    i = first();
+  }
+}
+
+int <T><C>Map::contains (<T&> item)
+{
+  return seek(item) != 0;
+}
+
+
+void <T><C>Map::error(const char* msg)
+{
+  (*lib_error_handler)("Map", msg);
+}
diff --git a/usr/include/g++/gen/Map.hP b/usr/include/g++/gen/Map.hP
new file mode 100644 (file)
index 0000000..301a4ab
--- /dev/null
@@ -0,0 +1,96 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T><C>Map_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T><C>Map_h 1
+
+#include <Pix.h>
+#include "<T>.defs.h"
+
+class <T><C>Map
+{
+protected:
+  int                   count;
+  <C>                   def;
+
+public:
+                        <T><C>Map(<C&> dflt);
+  virtual              ~<T><C>Map();
+
+  int                   length();                // current number of items
+  int                   empty();
+
+  virtual int           contains(<T&> key);      // is key mapped?
+
+  virtual void          clear();                 // delete all items
+
+  virtual <C>&          operator [] (<T&> key) = 0; // access contents by key
+
+  virtual void          del(<T&> key) = 0;       // delete entry
+
+  virtual Pix           first() = 0;             // Pix of first item or 0
+  virtual void          next(Pix& i) = 0;        // advance to next or 0
+  virtual <T>&          key(Pix i) = 0;          // access key at i
+  virtual <C>&          contents(Pix i) = 0;     // access contents at i
+
+  virtual int           owns(Pix i);             // is i a valid Pix  ?
+  virtual Pix           seek(<T&> key);          // Pix of key
+
+  <C>&                  dflt();                  // access default val
+
+  void                  error(const char* msg);
+  virtual int           OK() = 0;                // rep invariant
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T><C>Map::~<T><C>Map() {}
+
+inline int <T><C>Map::length()
+{
+  return count;
+}
+
+inline int <T><C>Map::empty()
+{
+  return count == 0;
+}
+
+inline <C>& <T><C>Map::dflt()
+{
+  return def;
+}
+
+inline <T><C>Map::<T><C>Map(<C&> dflt) :def(dflt)
+{
+  count = 0;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/OSLBag.ccP b/usr/include/g++/gen/OSLBag.ccP
new file mode 100644 (file)
index 0000000..79c95cb
--- /dev/null
@@ -0,0 +1,201 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.OSLBag.h"
+
+
+Pix <T>OSLBag::seek(<T&> item, Pix i)
+{
+  if (i == 0) i = p.first(); else next(i);
+  for (; i != 0; p.next(i))
+  {
+    int cmp = <T>CMP(item, p(i));
+    if (cmp == 0)
+      return i;
+    else if (cmp < 0)
+      return 0;
+  }
+  return 0;
+}
+
+int <T>OSLBag::nof(<T&> item)
+{
+  int n = 0;
+  for (Pix i = p.first(); i != 0; p.next(i))
+  {
+    int cmp = <T>CMP(item, p(i));
+    if (cmp == 0)
+      ++n;
+    else if (cmp < 0)
+      break;
+  }
+  return n;
+}
+
+Pix <T>OSLBag::add(<T&> item)
+{
+  Pix i = p.first();
+  if (i == 0) 
+  {
+    ++count;
+    return p.prepend(item);
+  }
+  int cmp = <T>CMP(item, p(i));
+  if (cmp <= 0)
+  {
+    ++count;
+    return p.prepend(item);
+  }
+  else
+  {
+    Pix trail = i;
+    p.next(i);
+    for (;;)
+    {
+      if (i == 0)
+      {
+        ++count;
+        return p.append(item);
+      }
+      cmp = <T>CMP(item, p(i));
+      if (cmp <= 0)
+      {
+        ++count;
+        return p.ins_after(trail, item);
+      }
+      else
+      {
+        trail = i;
+        p.next(i);
+      }
+    }
+  }
+}
+
+void <T>OSLBag::del(<T&> item)
+{
+  Pix i = p.first();
+  if (i == 0)
+    return;
+  int cmp = <T>CMP(item, p(i));
+  if (cmp < 0)
+    return;
+  else if (cmp == 0)
+  {
+    --count;
+    p.del_front();
+  }
+  else
+  {
+    Pix trail = i;
+    p.next(i);
+    while (i != 0)
+    {
+      cmp = <T>CMP(item, p(i));
+      if (cmp < 0)
+        return;
+      else if (cmp == 0)
+      {
+        --count;
+        p.del_after(trail);
+        return;
+      }
+      else
+      {
+        trail = i;
+        p.next(i);
+      }
+    }
+  }
+}
+
+void <T>OSLBag::remove(<T&> item)
+{
+  Pix i = p.first();
+  if (i == 0)
+    return;
+  int cmp = <T>CMP(item, p(i));
+  if (cmp < 0)
+    return;
+  else if (cmp == 0)
+  {
+    do
+    {
+      --count;
+      p.del_front();
+      i = p.first();
+    } while (i != 0 && <T>EQ(item, p(i)));
+  }
+  else
+  {
+    Pix trail = i;
+    p.next(i);
+    while (i != 0)
+    {
+      cmp = <T>CMP(item, p(i));
+      if (cmp < 0)
+        return;
+      else if (cmp == 0)
+      {
+        do
+        {
+          --count;
+          p.del_after(trail);
+          i = trail;
+          next(i);
+        } while (i != 0 && <T>EQ(item, p(i)));
+        return;
+      }
+      else
+      {
+        trail = i;
+        p.next(i);
+      }
+    }
+  }
+}
+        
+int <T>OSLBag::OK()
+{
+  int v = p.OK();
+  v &= count == p.length();
+  Pix trail = p.first();
+  if (trail == 0)
+    v &= count == 0;
+  else
+  {
+    Pix i = trail; next(i);
+    while (i != 0)
+    {
+      v &= <T>CMP(p(trail), p(i)) <= 0;
+      trail = i;
+      next(i);
+    }
+  }
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/OSLBag.hP b/usr/include/g++/gen/OSLBag.hP
new file mode 100644 (file)
index 0000000..36d74bc
--- /dev/null
@@ -0,0 +1,100 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>OSLBag_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>OSLBag_h 1
+
+#include "<T>.Bag.h"
+#include "<T>.SLList.h"
+
+class <T>OSLBag : public <T>Bag
+{
+protected:
+  <T>SLList     p;
+
+public:
+                <T>OSLBag();
+                <T>OSLBag(const <T>OSLBag&);
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  void          remove(<T&>item);
+
+  int           contains(<T&> item);
+  int           nof(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  int           owns(Pix i);
+  Pix           seek(<T&> item, Pix from = 0);
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>OSLBag::<T>OSLBag() : p() { count = 0; }
+
+inline <T>OSLBag::<T>OSLBag(const <T>OSLBag& s) : p(s.p) { count = s.count; }
+
+inline Pix <T>OSLBag::first()
+{
+  return p.first();
+}
+
+inline void <T>OSLBag::next(Pix  & idx)
+{
+  p.next(idx);
+}
+
+inline <T>& <T>OSLBag::operator ()(Pix   idx)
+{
+  return p(idx);
+}
+
+inline void <T>OSLBag::clear()
+{
+  count = 0;  p.clear();
+}
+
+inline int <T>OSLBag::owns (Pix   idx)
+{
+  return p.owns(idx);
+}
+
+inline int <T>OSLBag::contains(<T&> item)
+{
+  return seek(item) != 0;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/OSLSet.ccP b/usr/include/g++/gen/OSLSet.ccP
new file mode 100644 (file)
index 0000000..2ab1944
--- /dev/null
@@ -0,0 +1,326 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.OSLSet.h"
+
+
+Pix <T>OSLSet::seek(<T&> item)
+{
+  for (Pix i = p.first(); i != 0; p.next(i))
+  {
+    int cmp = <T>CMP(item, p(i));
+    if (cmp == 0)
+      return i;
+    else if (cmp < 0)
+      return 0;
+  }
+  return 0;
+}
+
+Pix <T>OSLSet::add(<T&> item)
+{
+  Pix i = p.first();
+  if (i == 0) 
+  {
+    ++count;
+    return p.prepend(item);
+  }
+  int cmp = <T>CMP(item, p(i));
+  if (cmp == 0)
+    return i;
+  else if (cmp < 0)
+  {
+    ++count;
+    return p.prepend(item);
+  }
+  else
+  {
+    Pix trail = i;
+    p.next(i);
+    for (;;)
+    {
+      if (i == 0)
+      {
+        ++count;
+        return p.append(item);
+      }
+      cmp = <T>CMP(item, p(i));
+      if (cmp == 0)
+        return i;
+      else if (cmp < 0)
+      {
+        ++count;
+        return p.ins_after(trail, item);
+      }
+      else
+      {
+        trail = i;
+        p.next(i);
+      }
+    }
+  }
+}
+
+void <T>OSLSet::del(<T&> item)
+{
+  Pix i = p.first();
+  if (i == 0)
+    return;
+  int cmp = <T>CMP(item, p(i));
+  if (cmp < 0)
+    return;
+  else if (cmp == 0)
+  {
+    --count;
+    p.del_front();
+  }
+  else
+  {
+    Pix trail = i;
+    p.next(i);
+    while (i != 0)
+    {
+      cmp = <T>CMP(item, p(i));
+      if (cmp < 0)
+        return;
+      else if (cmp == 0)
+      {
+        --count;
+        p.del_after(trail);
+        return;
+      }
+      else
+      {
+        trail = i;
+        p.next(i);
+      }
+    }
+  }
+}
+        
+
+int <T>OSLSet::operator <= (<T>OSLSet& b)
+{
+  if (count > b.count) return 0;
+  Pix i = first();
+  Pix j = b.first();
+  for (;;)
+  {
+    if (i == 0)
+      return 1;
+    else if (j == 0)
+      return 0;
+    int cmp = <T>CMP(p(i), b.p(j));
+    if (cmp == 0)
+    {
+      next(i); b.next(j);
+    }
+    else if (cmp < 0)
+      return 0;
+    else
+      b.next(j);
+  }
+}
+
+int <T>OSLSet::operator == (<T>OSLSet& b)
+{
+  if (count != b.count) return 0;
+  if (count == 0) return 1;
+  Pix i = p.first();
+  Pix j = b.p.first();
+  while (i != 0)
+  {
+    if (!<T>EQ(p(i),b.p(j))) return 0;
+    next(i);
+    b.next(j);
+  }
+  return 1;
+}
+
+
+void <T>OSLSet::operator |= (<T>OSLSet& b)
+{
+  if (&b == this || b.count == 0)
+    return;
+  else
+  {
+    Pix j = b.p.first();
+    Pix i = p.first();
+    Pix trail = 0;
+    for (;;)
+    {
+      if (j == 0)
+        return;
+      else if (i == 0)
+      {
+        for (; j != 0; b.next(j))
+        {
+          ++count;
+          p.append(b.p(j));
+        }
+        return;
+      }
+      int cmp = <T>CMP(p(i), b.p(j));
+      if (cmp <= 0)
+      {
+        if (cmp == 0) b.next(j);
+        trail = i;
+        next(i);
+      }
+      else
+      {
+        ++count;
+        if (trail == 0)
+          trail = p.prepend(b.p(j));
+        else
+          trail = p.ins_after(trail, b.p(j));
+        b.next(j);
+      }
+    }
+  }
+}
+
+
+void <T>OSLSet::operator -= (<T>OSLSet& b)
+{
+  if (&b == this)
+    clear();
+  else if (count != 0 && b.count != 0)
+  {
+    Pix i = p.first();
+    Pix j = b.p.first();
+    Pix trail = 0;
+    for (;;)
+    {
+      if (j == 0 || i == 0)
+        return;
+      int cmp = <T>CMP(p(i), b.p(j));
+      if (cmp == 0)
+      {
+        --count;
+        b.next(j);
+        if (trail == 0)
+        {
+          p.del_front();
+          i = p.first();
+        }
+        else
+        {
+          next(i);
+          p.del_after(trail);
+        }
+      }
+      else if (cmp < 0)
+      {
+        trail = i;
+        next(i);
+      }
+      else
+        b.next(j);
+    }
+  }
+}
+
+void <T>OSLSet::operator &= (<T>OSLSet& b)
+{
+  if (b.count == 0)
+    clear();
+  else if (&b != this && count != 0)
+  {
+    Pix i = p.first();
+    Pix j = b.p.first();
+    Pix trail = 0;
+    for (;;)
+    {
+      if (i == 0)
+        return;
+      else if (j == 0)
+      {
+        if (trail == 0)
+        {
+          p.clear();
+          count = 0;
+        }
+        else
+        {
+          while (i != 0)
+          {
+            --count;
+            next(i);
+            p.del_after(trail);
+          }
+        }
+        return;
+      }
+      int cmp = <T>CMP(p(i), b.p(j));
+
+      if (cmp == 0)
+      {
+        trail = i;
+        next(i);
+        b.next(j);
+      }
+      else if (cmp < 0)
+      {
+        --count;
+        if (trail == 0)
+        {
+          p.del_front();
+          i = p.first();
+        }
+        else
+        {
+          next(i);
+          p.del_after(trail);
+        }
+      }
+      else
+        b.next(j);
+    }
+  }
+}
+
+
+int <T>OSLSet::OK()
+{
+  int v = p.OK();
+  v &= count == p.length();
+  Pix trail = p.first();
+  if (trail == 0)
+    v &= count == 0;
+  else
+  {
+    Pix i = trail; next(i);
+    while (i != 0)
+    {
+      v &= <T>CMP(p(trail), p(i)) < 0;
+      trail = i;
+      next(i);
+    }
+  }
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/OSLSet.hP b/usr/include/g++/gen/OSLSet.hP
new file mode 100644 (file)
index 0000000..1e94c09
--- /dev/null
@@ -0,0 +1,109 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>OSLSet_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>OSLSet_h 1
+
+#include "<T>.Set.h"
+#include "<T>.SLList.h"
+
+class <T>OSLSet : public <T>Set
+{
+protected:
+  <T>SLList     p;
+
+public:
+                <T>OSLSet();
+                <T>OSLSet(const <T>OSLSet&);
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  int           owns(Pix i);
+  Pix           seek(<T&> item);
+
+  void          operator |= (<T>OSLSet& b);
+  void          operator -= (<T>OSLSet& b);
+  void          operator &= (<T>OSLSet& b);
+
+  int           operator == (<T>OSLSet& b);
+  int           operator != (<T>OSLSet& b);
+  int           operator <= (<T>OSLSet& b); 
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>OSLSet::<T>OSLSet() : p() { count = 0; }
+
+inline <T>OSLSet::<T>OSLSet(const <T>OSLSet& s) : p(s.p) { count = s.count; }
+
+inline Pix <T>OSLSet::first()
+{
+  return p.first();
+}
+
+inline void <T>OSLSet::next(Pix  & idx)
+{
+  p.next(idx);
+}
+
+inline <T>& <T>OSLSet::operator ()(Pix   idx)
+{
+  return p(idx);
+}
+
+inline void <T>OSLSet::clear()
+{
+  count = 0;  p.clear();
+}
+
+inline int <T>OSLSet::contains (<T&> item)
+{
+  return seek(item) != 0;
+}
+
+inline int <T>OSLSet::owns (Pix   idx)
+{
+  return p.owns(idx);
+}
+
+inline int <T>OSLSet::operator != (<T>OSLSet& b)
+{
+  return !(*this == b);
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/OXPBag.ccP b/usr/include/g++/gen/OXPBag.ccP
new file mode 100644 (file)
index 0000000..2a39644
--- /dev/null
@@ -0,0 +1,226 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.OXPBag.h"
+
+
+Pix <T>OXPBag::seek(<T&> item, Pix i)
+{
+  if (i == 0)
+  {
+    int l = p.low();
+    int h = p.high();
+    while (l <= h)
+    {
+      int mid = (l + h) / 2;
+      int cmp = <T>CMP(item, p[mid]);
+      if (cmp == 0)
+      {
+        while (mid > p.low() && <T>EQ(item, p[mid - 1])) --mid;
+        return p.index_to_Pix(mid);
+      }
+      else if (cmp < 0)
+        h = mid - 1;
+      else
+        l = mid + 1;
+    }
+    return 0;
+  }
+  int cmp = <T>CMP(item, p(i));
+  if (cmp == 0)
+  {
+    next(i);
+    return (<T>EQ(item, p(i)))? i : 0;
+  }
+  else if (cmp < 0)
+  {
+    int ind = p.Pix_to_index(i);
+    int l = ind;
+    int h = p.high();
+    while (l <= h)
+    {
+      int mid = (l + h) / 2;
+      cmp = <T>CMP(item, p[mid]);
+      if (cmp == 0)
+      {
+        while (mid > ind && <T>EQ(item, p[mid - 1])) --mid;
+        return p.index_to_Pix(mid);
+      }
+      else if (cmp < 0)
+        h = mid - 1;
+      else
+        l = mid + 1;
+    }
+    return 0;
+  }
+  else
+    return 0;
+}
+
+int <T>OXPBag::nof(<T&> item)
+{
+  int l = p.low();
+  int h = p.high();
+  while (l <= h)
+  {
+    int mid = (l + h) / 2;
+    int cmp = <T>CMP(item, p[mid]);
+    if (cmp == 0)
+    {
+      l = h = mid;
+      while (l > p.low() && <T>EQ(item, p[l - 1])) --l;
+      while (h < p.high() && <T>EQ(item, p[h + 1])) ++h;
+      return h - l + 1;
+    }
+    else if (cmp < 0)
+      h = mid - 1;
+    else
+      l = mid + 1;
+  }
+  return 0;
+}
+
+Pix <T>OXPBag::add(<T&> item)
+{
+  if (count == 0) 
+  {
+    ++count;
+    return p.index_to_Pix(p.add_high(item));
+  }
+  int l = p.low();
+  int h = p.high();
+  while (l <= h)
+  {
+    int mid = (l + h) / 2;
+    int cmp = <T>CMP(item, p[mid]);
+    if (cmp == 0)
+    {
+      l = mid;
+      break;
+    }
+    else if (cmp < 0)
+      h = mid - 1;
+    else
+      l = mid + 1;
+  }
+  // add on whichever side is shortest
+  ++count;
+  if (l == p.fence())
+    return p.index_to_Pix(p.add_high(item));
+  else if (l == p.low())
+    return p.index_to_Pix(p.add_low(item));
+  else 
+  {
+    if (p.high() - l < l - p.low())
+    {
+      h = p.add_high(p.high_element());
+      for (int i = h - 1; i > l; --i) p[i] = p[i-1];
+    }
+    else
+    {
+      --l;
+      h = p.add_low(p.low_element());
+      for (int i = h + 1; i < l; ++i) p[i] = p[i+1];
+    }
+    p[l] = item;
+    return p.index_to_Pix(l);
+  }
+}
+
+void <T>OXPBag::del(<T&> item)
+{
+  int l = p.low();
+  int h = p.high();
+  while (l <= h)
+  {
+    int mid = (l + h) / 2;
+    int cmp = <T>CMP(item, p[mid]);
+    if (cmp == 0)
+    {
+      --count;
+      if (p.high() - mid < mid - p.low())
+      {
+        for (int i = mid; i < p.high(); ++i) p[i] = p[i+1];
+        p.del_high();
+      }
+      else
+      {
+        for (int i = mid; i > p.low(); --i) p[i] = p[i-1];
+        p.del_low();
+      }
+      return;
+    }
+    else if (cmp < 0)
+      h = mid - 1;
+    else
+      l = mid + 1;
+  }
+}
+
+void <T>OXPBag::remove(<T&> item)
+{
+  int l = p.low();
+  int h = p.high();
+  while (l <= h)
+  {
+    int mid = (l + h) / 2;
+    int cmp = <T>CMP(item, p[mid]);
+    if (cmp == 0)
+    {
+      l = h = mid;
+      while (l > p.low() && <T>EQ(item, p[l - 1])) --l;
+      while (h < p.high() && <T>EQ(item, p[h + 1])) ++h;
+      int n = h - l + 1;
+      count -= n;
+      if (p.high() - h < l - p.low())
+      {
+        h = p.high() - n;
+        for (int i = l; i <= h; ++i) p[i] = p[i+n];
+        while (n-- > 0) p.del_high();
+      }
+      else
+      {
+        l = p.low() + n;
+        for (int i = h; i >= l; --i) p[i] = p[i-n];
+        while (n-- > 0) p.del_low();
+      }
+      return;
+    }
+    else if (cmp < 0)
+      h = mid - 1;
+    else
+      l = mid + 1;
+  }
+}
+
+int <T>OXPBag::OK()
+{
+  int v = p.OK();
+  v &= count == p.length();
+  for (int i = p.low(); i < p.high(); ++i) v &= <T>CMP(p[i], p[i+1]) <= 0;
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/OXPBag.hP b/usr/include/g++/gen/OXPBag.hP
new file mode 100644 (file)
index 0000000..5542a27
--- /dev/null
@@ -0,0 +1,76 @@
+#ifndef _<T>OXPBag_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>OXPBag_h 1
+
+#include "<T>.Bag.h"
+#include "<T>.XPlex.h"
+
+class <T>OXPBag : public <T>Bag
+{
+protected:
+  <T>XPlex       p;
+
+public:
+                <T>OXPBag(int chunksize = DEFAULT_INITIAL_CAPACITY);
+                <T>OXPBag(const <T>OXPBag&);
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  void          remove(<T&>item);
+  int           nof(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  int           owns(Pix i);
+  Pix           seek(<T&> item, Pix from = 0);
+
+  int           OK();
+};
+
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>OXPBag::<T>OXPBag(int chunksize) 
+     : p(chunksize) { count = 0; }
+
+inline <T>OXPBag::<T>OXPBag(const <T>OXPBag& s) : p(s.p) { count = s.count; }
+
+inline Pix <T>OXPBag::first()
+{
+  return p.first();
+}
+
+inline void <T>OXPBag::next(Pix  & idx)
+{
+  p.next(idx);
+}
+
+inline <T>& <T>OXPBag::operator ()(Pix   idx)
+{
+  return p(idx);
+}
+
+inline void <T>OXPBag::clear()
+{
+  count = 0;  p.clear();
+}
+
+inline int <T>OXPBag::owns (Pix   idx)
+{
+  return p.owns(idx);
+}
+
+inline int <T>OXPBag::contains(<T&> item)
+{
+  return seek(item) != 0;
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/OXPSet.ccP b/usr/include/g++/gen/OXPSet.ccP
new file mode 100644 (file)
index 0000000..f7a99f8
--- /dev/null
@@ -0,0 +1,285 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.OXPSet.h"
+
+
+Pix <T>OXPSet::seek(<T&> item)
+{
+  int l = p.low();
+  int h = p.high();
+  while (l <= h)
+  {
+    int mid = (l + h) / 2;
+    int cmp = <T>CMP(item, p[mid]);
+    if (cmp == 0)
+      return p.index_to_Pix(mid);
+    else if (cmp < 0)
+      h = mid - 1;
+    else
+      l = mid + 1;
+  }
+  return 0;
+}
+
+Pix <T>OXPSet::add(<T&> item)
+{
+  if (count == 0) 
+  {
+    ++count;
+    return p.index_to_Pix(p.add_high(item));
+  }
+  int l = p.low();
+  int h = p.high();
+  while (l <= h)
+  {
+    int mid = (l + h) / 2;
+    int cmp = <T>CMP(item, p[mid]);
+    if (cmp == 0)
+      return p.index_to_Pix(mid);
+    else if (cmp < 0)
+        h = mid - 1;
+    else
+      l = mid + 1;
+  }
+  // add on whichever side is shortest
+  ++count;
+  if (l == p.fence())
+    return p.index_to_Pix(p.add_high(item));
+  else if (l == p.low())
+    return p.index_to_Pix(p.add_low(item));
+  else 
+  {
+    if (p.fence() - l < l - p.low())
+    {
+      h = p.add_high(p.high_element());
+      for (int i = h - 1; i > l; --i) p[i] = p[i-1];
+    }
+    else
+    {
+      --l;
+      h = p.add_low(p.low_element());
+      for (int i = h + 1; i < l; ++i) p[i] = p[i+1];
+    }
+    p[l] = item;
+    return p.index_to_Pix(l);
+  }
+}
+
+void <T>OXPSet::del(<T&> item)
+{
+  int l = p.low();
+  int h = p.high();
+  while (l <= h)
+  {
+    int mid = (l + h) / 2;
+    int cmp = <T>CMP(item, p[mid]);
+    if (cmp == 0)
+    {
+      --count;
+      if (p.high() - mid < mid - p.low())
+      {
+        for (int i = mid; i < p.high(); ++i) p[i] = p[i+1];
+        p.del_high();
+      }
+      else
+      {
+        for (int i = mid; i > p.low(); --i) p[i] = p[i-1];
+        p.del_low();
+      }
+      return;
+    }
+    else if (cmp < 0)
+      h = mid - 1;
+    else
+      l = mid + 1;
+  }
+}
+
+int <T>OXPSet::operator <= (<T>OXPSet& b)
+{
+  if (count > b.count) return 0;
+  int i = p.low();
+  int j = b.p.low();
+  for (;;)
+  {
+    if (i >= p.fence())
+      return 1;
+    else if (j >= b.p.fence()) 
+      return 0;
+    int cmp = <T>CMP(p[i], b.p[j]);
+    if (cmp == 0)
+    {
+      ++i; ++j;
+    }
+    else if (cmp < 0)
+      return 0;
+    else
+      ++j;
+  }
+}
+
+int <T>OXPSet::operator == (<T>OXPSet& b)
+{
+  int n = count;
+  if (n != b.count) return 0;
+  if (n == 0) return 1;
+  int i = p.low();
+  int j = b.p.low();
+  while (n-- > 0) if (!<T>EQ(p[i++], b.p[j++])) return 0;
+  return 1;
+}
+
+
+void <T>OXPSet::operator |= (<T>OXPSet& b)
+{
+  if (&b == this || b.count == 0)
+    return;
+  else if (b.count <= 2) // small b -- just add
+    for (Pix i = b.first(); i; b.next(i)) add(b(i));
+  else
+  {
+    // strategy: merge into top of p, simultaneously killing old bottom
+    int oldfence = p.fence();
+    int i = p.low();
+    int j = b.p.low();
+    for (;;)
+    {
+      if (i == oldfence)
+      {
+        while (j < b.p.fence()) p.add_high(b.p[j++]);
+        break;
+      }
+      else if (j == b.p.fence())
+      {
+        while (i++ < oldfence) 
+        {
+          p.add_high(p.low_element());
+          p.del_low();
+        }
+        break;
+      }
+      int cmp = <T>CMP(p[i], b.p[j]);
+      if (cmp <= 0)
+      {
+        ++i;
+        if (cmp == 0)  ++j;
+        p.add_high(p.low_element());
+        p.del_low();
+      }
+      else
+        p.add_high(b.p[j++]);
+    }
+    count = p.length();
+  }
+}
+
+
+
+void <T>OXPSet::operator -= (<T>OXPSet& b)
+{
+  if (&b == this)
+    clear();
+  else if (count != 0 && b.count != 0)
+  {
+    int i = p.low();
+    int k = i;
+    int j = b.p.low();
+    int oldfence = p.fence();
+    for (;;)
+    {
+      if (i >= oldfence)
+        break;
+      else if (j >= b.p.fence())
+      {
+        if (k != i)
+          while (i < oldfence) p[k++] = p[i++];
+        else
+          k = oldfence;
+        break;
+      }
+      int cmp = <T>CMP(p[i], b.p[j]);
+      if (cmp == 0)
+      {
+        ++i; ++j;
+      }
+      else if (cmp < 0)
+      {
+        if (k != i) p[k] = p[i];
+        ++i; ++k;
+      }
+      else
+        j++;
+    }
+    while (k++ < oldfence)
+    {
+      --count;
+      p.del_high();
+    }
+  }
+}
+
+void <T>OXPSet::operator &= (<T>OXPSet& b)
+{
+  if (b.count == 0)
+    clear();
+  else if (&b != this && count != 0)
+  {
+    int i = p.low();
+    int k = i;
+    int j = b.p.low();
+    int oldfence = p.fence();
+    for (;;)
+    {
+      if (i >= oldfence || j >= b.p.fence())
+        break;
+      int cmp = <T>CMP(p[i], b.p[j]);
+      if (cmp == 0)
+      {
+        if (k != i) p[k] = p[i];
+        ++i; ++k; ++j;
+      }
+      else if (cmp < 0)
+        ++i;
+      else
+        ++j;
+    }
+    while (k++ < oldfence)
+    {
+      --count;
+      p.del_high();
+    }
+  }
+}
+
+int <T>OXPSet::OK()
+{
+  int v = p.OK();
+  v &= count == p.length();
+  for (int i = p.low(); i < p.high(); ++i) v &= <T>CMP(p[i], p[i+1]) < 0;
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/OXPSet.hP b/usr/include/g++/gen/OXPSet.hP
new file mode 100644 (file)
index 0000000..fb1cb3c
--- /dev/null
@@ -0,0 +1,110 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>OXPSet_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>OXPSet_h 1
+
+#include "<T>.Set.h"
+#include "<T>.XPlex.h"
+
+class <T>OXPSet : public <T>Set
+{
+protected:
+  <T>XPlex       p;
+
+public:
+                <T>OXPSet(int chunksize = DEFAULT_INITIAL_CAPACITY);
+                <T>OXPSet(const <T>OXPSet&);
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  int           owns(Pix i);
+  Pix           seek(<T&> item);
+
+  void          operator |= (<T>OXPSet& b);
+  void          operator -= (<T>OXPSet& b);
+  void          operator &= (<T>OXPSet& b);
+
+  int           operator == (<T>OXPSet& b);
+  int           operator != (<T>OXPSet& b);
+  int           operator <= (<T>OXPSet& b); 
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>OXPSet::<T>OXPSet(int chunksize) 
+     : p(chunksize) { count = 0; }
+
+inline <T>OXPSet::<T>OXPSet(const <T>OXPSet& s) : p(s.p) { count = s.count; }
+
+inline Pix <T>OXPSet::first()
+{
+  return p.first();
+}
+
+inline void <T>OXPSet::next(Pix  & idx)
+{
+  p.next(idx);
+}
+
+inline <T>& <T>OXPSet::operator ()(Pix   idx)
+{
+  return p(idx);
+}
+
+inline void <T>OXPSet::clear()
+{
+  count = 0;  p.clear();
+}
+
+inline int <T>OXPSet::contains (<T&> item)
+{
+  return seek(item) != 0;
+}
+
+inline int <T>OXPSet::owns (Pix   idx)
+{
+  return p.owns(idx);
+}
+
+inline int <T>OXPSet::operator != (<T>OXPSet& b)
+{
+  return !(*this == b);
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/PHPQ.ccP b/usr/include/g++/gen/PHPQ.ccP
new file mode 100644 (file)
index 0000000..cc68873
--- /dev/null
@@ -0,0 +1,342 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+    adapted for libg++ by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <values.h>
+#include "<T>.PHPQ.h"
+
+//
+//     This defines a Pairing Heap structure
+//
+//     See ``The Pairing Heap: A New Form of Self-Adjusting Heap''
+//     Fredman, Segdewick et al,
+//     Algorithmica (1986) 1:111-129
+//
+//     In particular, this implements the pairing heap using the circular
+//     list.
+//
+//
+
+<T>PHPQ::<T>PHPQ(int sz)
+{
+  storage = 0;
+  root = 0;
+  count = 0;
+  size = 0;
+  prealloc(sz);
+}
+
+<T>PHPQ::<T>PHPQ(<T>PHPQ& a)
+{
+  storage = 0;
+  root  = 0;
+  count = 0;
+  size = 0;
+  prealloc(a.size);
+  for (Pix i = a.first(); i != 0; a.next(i)) enq(a(i));
+}
+
+
+void <T>PHPQ::prealloc(int newsize)
+{
+  ++newsize; // leave a spot for freelist
+  if (size != 0)
+  {
+    int news = size;
+    while (news <= newsize) news = (news * 3) / 2;
+    newsize = news;
+  }
+  // see if indices are OK
+  <T>PHPQNode test;
+  test.sibling = 0;
+  test.sibling = ~test.sibling;
+  if ((unsigned long)newsize > (unsigned long)(test.sibling))
+    error("storage size exceeds index range");
+
+  if (storage == 0)
+  {
+    storage = new <T>PHPQNode[size = newsize];
+    for (int i = 0; i < size; ++i) 
+    {
+      storage[i].sibling = i + 1;
+      storage[i].valid = 0;
+    }
+    storage[size-1].sibling = 0;
+  }
+  else
+  {
+    <T>PHPQNode* newstor = new <T>PHPQNode[newsize];
+    for (int i = 1; i < size; ++i)
+      newstor[i] = storage[i];
+    delete [size] storage;
+    storage = newstor;
+    for (i = size; i < newsize; ++i) 
+    {
+      storage[i].sibling = i + 1;
+      storage[i].valid = 0;
+    }
+    storage[newsize-1].sibling = 0;
+    storage[0].sibling = size;
+    size = newsize;
+  }
+}
+
+
+void <T>PHPQ::clear()
+{
+  for (int i = 0; i < size; ++i) 
+  {
+    storage[i].sibling = i + 1;
+    storage[i].valid = 0;
+  }
+  storage[size-1].sibling = 0;
+  root = 0;
+  count = 0;
+}
+
+Pix <T>PHPQ::enq(<T&> item)
+{
+  ++count;
+  if (storage[0].sibling == 0)
+    prealloc(count);
+
+  int cell = storage[0].sibling;
+  storage[0].sibling = storage[cell].sibling;
+  storage[cell].sibling = 0;
+  storage[cell].children = 0;
+  storage[cell].item = item;
+  storage[cell].valid = 1;
+  
+  if (root == 0) 
+  {
+    root = cell;
+    return Pix(root);
+  }
+  else 
+  {
+    int parent;
+    int child;
+    
+    if (<T>LE(storage[root].item, storage[cell].item))
+    {
+      parent = root; child = cell;
+    } 
+    else 
+    {
+      parent = cell; child = root;
+    }
+    int popsKid = storage[parent].children;
+    
+    if (popsKid == 0) 
+    {
+      storage[parent].children = child;
+      storage[child].sibling = child;
+    } 
+    else 
+    {
+      int temp = storage[popsKid].sibling;
+      storage[popsKid].sibling = child;
+      storage[child].sibling = temp;
+      storage[parent].children = child;
+    }
+    root = parent;
+    return Pix(cell);
+  }
+}
+
+//
+//     Item removal is the most complicated routine.
+//
+//     We remove the root (should there be one) and then select a new
+//     root. The siblings of the root are in a circular list. We continue
+//     to pair elements in this list until there is a single element.
+//     This element will be the new root.
+
+void <T>PHPQ::del_front()
+{
+  int valid = 0;
+  do 
+  {
+    if (root == 0) return;
+       if (valid = storage[root].valid)
+      --count;
+    storage[root].valid = 0;
+       int child = storage[root].children;
+    storage[root].sibling = storage[0].sibling;
+    storage[0].sibling = root;
+
+       if (child == 0)
+    {
+      root = 0;
+      return;
+    }
+    else 
+    {
+      while(storage[child].sibling != child) 
+      {
+               // We have at least two kids, but we may only have
+               // two kids. So, oneChild != child, but it is possible
+               // that twoChild == child.
+        
+               int oneChild = storage[child].sibling;
+               int twoChild = storage[oneChild].sibling;
+
+               // Remove the two from the sibling list
+
+               storage[child].sibling = storage[twoChild].sibling;
+               storage[oneChild].sibling = 0;
+               storage[twoChild].sibling = 0;
+               
+        int bestChild;
+        int worstChild;
+    
+        if (<T>LE(storage[oneChild].item, storage[twoChild].item))
+        {
+          bestChild = oneChild; worstChild = twoChild;
+        } 
+        else 
+        {
+          bestChild = twoChild; worstChild = oneChild;
+        }
+        int popsKid = storage[bestChild].children;
+        
+        if (popsKid == 0) 
+        {
+          storage[bestChild].children = worstChild;
+          storage[worstChild].sibling = worstChild;
+        } 
+        else 
+        {
+          int temp = storage[popsKid].sibling;
+          storage[popsKid].sibling = worstChild;
+          storage[worstChild].sibling = temp;
+          storage[bestChild].children = worstChild;
+        }
+               if (twoChild == child) 
+        {
+          // We have reduced the two to one, so we'll be exiting.
+          child = bestChild;
+          storage[child].sibling = child;
+        } 
+        else 
+        {
+          // We've removed two siblings, now we need to insert
+          // the better of the two
+          storage[bestChild].sibling = storage[child].sibling;
+          storage[child].sibling = bestChild;
+          child = storage[bestChild].sibling;
+               }
+      }
+      root = child;
+       }
+  } while ( !valid );
+}
+
+void <T>PHPQ::del(Pix p) 
+{
+  if (p == 0) error("null Pix");
+  int i = int(p);
+  if (storage[i].valid)
+  {
+    if (i == root)
+      del_front();
+    else
+    {
+      storage[i].valid = 0;
+      --count;
+    }
+  }
+}
+
+
+Pix <T>PHPQ::seek(<T&> key)
+{
+  for (int i = 1; i < size; ++i)
+    if (storage[i].valid && <T>EQ(storage[i].item, key))
+      return Pix(i);
+  return 0;
+}
+
+Pix <T>PHPQ::first()
+{
+  for (int i = 1; i < size; ++i)
+    if (storage[i].valid)
+      return Pix(i);
+  return 0;
+}
+
+
+void <T>PHPQ::next(Pix& p)
+{
+  if (p == 0) return;
+  for (int i = int(p)+1; i < size; ++i)
+    if (storage[i].valid)
+    {
+      p = Pix(i); 
+      return;
+    }
+  p = 0;
+}
+
+int <T>PHPQ::OK()
+{
+  int v = storage != 0;
+  int n = check_sibling_list(root, 0);
+  v &= n  == count;
+  int ct = MAXLONG;
+  n = 0;
+  int f = storage[0].sibling;
+  while (f != 0 && ct-- > 0)
+  {
+    f = storage[f].sibling;
+    ++n;
+  }
+  v &= ct > 0;
+  v &= n <= size - count;
+  if (!v) error("invariant failure");
+  return v;
+}
+
+
+int <T>PHPQ::check_sibling_list(int t, int cnt)
+{
+  if (t != 0)
+  {
+    int s = t;
+    long ct = MAXLONG;      // Lots of chances to find self!
+    do 
+    {
+      if (storage[s].valid) cnt++;
+      cnt += check_sibling_list(storage[s].children, cnt);
+      s = storage[s].sibling;
+    } while (ct-- > 0 && s != t && s != 0);
+    if (ct <= 0) return -1;
+  }
+  return cnt;
+}
+
+
diff --git a/usr/include/g++/gen/PHPQ.hP b/usr/include/g++/gen/PHPQ.hP
new file mode 100644 (file)
index 0000000..acc6ebb
--- /dev/null
@@ -0,0 +1,118 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Dirk Grunwald (grunwald@cs.uiuc.edu)
+    adapted for libg++ by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef <T>PHPQ_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define <T>PHPQ_h 1
+
+#include "<T>.PQ.h"
+
+#ifndef <T>PHPQIndex
+#define <T>PHPQIndex unsigned short
+#endif
+
+struct <T>PHPQNode
+{
+  <T>PHPQIndex   sibling;
+  <T>PHPQIndex   children;
+  <T>            item;
+  char           valid;
+};
+
+
+class <T>PHPQ : public <T>PQ
+{
+  <T>PHPQNode*  storage;        // table -- freelist in storage[0].sibling
+  int           root;
+  int           size;
+
+  void          prealloc(int);
+  int           check_sibling_list(int, int);
+
+public:
+
+                <T>PHPQ(int sz = DEFAULT_INITIAL_CAPACITY);
+                <T>PHPQ(<T>PHPQ&);
+                ~<T>PHPQ();
+
+  Pix           enq(<T&> item);
+  <T>           deq(); 
+
+  <T>&          front();
+  void          del_front();
+
+  int           contains(<T&> item);
+
+  void          clear(); 
+
+  Pix           first(); 
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  void          del(Pix i);
+  Pix           seek(<T&> item);
+
+  int           OK();                    // rep invariant
+};
+
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>PHPQ::~<T>PHPQ()
+{
+  delete [size] storage;
+}
+
+
+inline <T> <T>PHPQ::deq()
+{
+  if (count == 0) error("deq of empty PQ");
+  <T> x = storage[root].item;
+  del_front();
+  return x;
+}
+
+
+inline <T>& <T>PHPQ::front()
+{
+  if (count == 0) error("front of empty PQ");
+  return storage[root].item;
+}
+
+inline int <T>PHPQ::contains(<T&> item)
+{
+  return seek(item) != 0;
+}
+
+inline <T>& <T>PHPQ::operator() (Pix p)
+{
+  if (p == 0) error("null Pix");
+  return storage[int(p)].item;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/PQ.ccP b/usr/include/g++/gen/PQ.ccP
new file mode 100644 (file)
index 0000000..7aeddcb
--- /dev/null
@@ -0,0 +1,67 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <builtin.h>
+#include "<T>.PQ.h"
+
+
+
+<T> <T>PQ::deq()
+{
+  <T> x = front();
+  del_front();
+  return x;
+}
+
+Pix <T>PQ::seek(<T&> item)
+{
+  for (Pix i = first(); i != 0 && !(<T>EQ((*this)(i), item)); next(i));
+  return i;
+}
+
+int <T>PQ::owns(Pix idx)
+{
+  if (idx == 0) return 0;
+  for (Pix i = first(); i; next(i)) if (i == idx) return 1;
+  return 0;
+}
+
+void <T>PQ::clear()
+{
+  while (count != 0) del_front();
+}
+
+int <T>PQ::contains (<T&> item)
+{
+  return seek(item) != 0;
+}
+
+
+void <T>PQ::error(const char* msg)
+{
+  (*lib_error_handler)("PQ", msg);
+}
+
diff --git a/usr/include/g++/gen/PQ.hP b/usr/include/g++/gen/PQ.hP
new file mode 100644 (file)
index 0000000..eb7b22c
--- /dev/null
@@ -0,0 +1,80 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>PQ_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>PQ_h 1
+
+#include <Pix.h>
+#include "<T>.defs.h"
+
+class <T>PQ
+{
+protected:
+
+  int                   count;
+
+public:
+  int                   length();                // current number of items
+  int                   empty();
+
+  virtual Pix           enq(<T&> item) = 0;      // add item; return Pix
+  virtual <T>           deq();                   // return & remove min
+
+  virtual <T>&          front() = 0;             // access min item
+  virtual void          del_front() = 0;         // delete min item
+
+  virtual int           contains(<T&> item);     // is item in PQ?
+
+  virtual void          clear();                 // delete all items
+
+  virtual Pix           first() = 0;             // Pix of first item or 0
+  virtual void          next(Pix& i) = 0;        // advance to next or 0
+  virtual <T>&          operator () (Pix i) = 0; // access item at i
+  virtual void          del(Pix i) = 0;          // delete item at i
+  virtual int           owns(Pix i);             // is i a valid Pix  ?
+  virtual Pix           seek(<T&> item);         // Pix of item
+
+  void                  error(const char* msg);
+  virtual int           OK() = 0;                // rep invariant
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline int <T>PQ::length()
+{
+  return count;
+}
+
+inline int <T>PQ::empty()
+{
+  return count == 0;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/Plex.ccP b/usr/include/g++/gen/Plex.ccP
new file mode 100644 (file)
index 0000000..9d47561
--- /dev/null
@@ -0,0 +1,227 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include "<T>.Plex.h"
+
+// IChunk support
+
+volatile void <T>IChunk::error(const char* msg) const
+{
+  (*lib_error_handler)("<T>IChunk", msg);
+}
+
+volatile void <T>IChunk::index_error() const
+{
+  error("attempt to use invalid index");
+}
+
+volatile void <T>IChunk::empty_error() const
+{
+  error("invalid use of empty chunk");
+}
+
+volatile void <T>IChunk::full_error() const
+{
+  error("attempt to extend chunk beyond bounds");
+}
+
+<T>IChunk:: ~<T>IChunk() {}
+
+<T>IChunk::<T>IChunk(<T>*     d,    
+                     int      baseidx,
+                     int      lowidx,
+                     int      fenceidx,
+                     int      topidx)
+{
+  if (d == 0 || baseidx > lowidx || lowidx > fenceidx || fenceidx > topidx)
+    error("inconsistent specification");
+  data = d;
+  base = baseidx;
+  low = lowidx;
+  fence = fenceidx;
+  top = topidx;
+  nxt = prv = this;
+}
+
+void <T>IChunk:: re_index(int lo)
+{
+  int delta = lo - low;
+  base += delta;
+  low += delta;
+  fence += delta;
+  top += delta;
+}
+
+
+void <T>IChunk::clear(int lo)
+{
+  int s = top - base;
+  low = base = fence = lo;
+  top = base + s;
+}
+
+void <T>IChunk::cleardown(int hi)
+{
+  int s = top - base;
+  low = top = fence = hi;
+  base = top - s;
+}
+
+int <T>IChunk:: OK() const
+{
+  int v = data != 0;             // have some data
+  v &= base <= low;              // ok, index-wise
+  v &= low <= fence;
+  v &= fence <= top;
+
+  v &=  nxt->prv == this;      // and links are OK
+  v &=  prv->nxt == this;
+  if (!v) error("invariant failure");
+  return(v);
+}
+
+
+// error handling
+
+
+volatile void <T>Plex::error(const char* msg) const
+{
+  (*lib_error_handler)("Plex", msg);
+}
+
+volatile void <T>Plex::index_error() const
+{
+  error("attempt to access invalid index");
+}
+
+volatile void <T>Plex::empty_error() const
+{
+  error("attempted operation on empty plex");
+}
+
+volatile void <T>Plex::full_error() const
+{
+  error("attempt to increase size of plex past limit");
+}
+
+// generic plex ops
+
+<T>Plex:: ~<T>Plex()
+{
+  invalidate();
+}  
+
+
+void <T>Plex::append (const <T>Plex& a)
+{
+  for (int i = a.low(); i < a.fence(); a.next(i)) add_high(a[i]);
+}
+
+void <T>Plex::prepend (const <T>Plex& a)
+{
+  for (int i = a.high(); i > a.ecnef(); a.prev(i)) add_low(a[i]);
+}
+
+void <T>Plex::reverse()
+{
+  <T> tmp;
+  int l = low();
+  int h = high();
+  while (l < h)
+  {
+    tmp = (*this)[l];
+    (*this)[l] = (*this)[h];
+    (*this)[h] = tmp;
+    next(l);
+    prev(h);
+  }
+}
+
+
+void <T>Plex::fill(const <T&> x)
+{
+  for (int i = lo; i < fnc; ++i) (*this)[i] = x;
+}
+
+void <T>Plex::fill(const <T&> x, int lo, int hi)
+{
+  for (int i = lo; i <= hi; ++i) (*this)[i] = x;
+}
+
+
+void <T>Plex::del_chunk(<T>IChunk* x)
+{
+  if (x != 0)
+  {
+    x->unlink();
+    int sz = x->size();
+    <T>* data = (<T>*)(x->invalidate());
+    delete [sz] data;
+    delete x;
+  }
+}
+
+
+void <T>Plex::invalidate()
+{
+  <T>IChunk* t = hd;
+  if (t != 0)
+  {
+    <T>IChunk* tail = tl();
+    while (t != tail)
+    {
+      <T>IChunk* nxt = t->next();
+      del_chunk(t);
+      t = nxt;
+    } 
+    del_chunk(t);
+    hd = 0;
+  }
+}
+
+int <T>Plex::reset_low(int l)
+{
+  int old = lo;
+  int diff = l - lo;
+  if (diff != 0)
+  {
+    lo += diff;
+    fnc += diff;
+    <T>IChunk* t = hd;
+    do
+    {
+      t->re_index(t->low_index() + diff);
+      t = t->next();
+    } while (t != hd);
+  }
+  return old;
+}
+
+
+
+
diff --git a/usr/include/g++/gen/Plex.hP b/usr/include/g++/gen/Plex.hP
new file mode 100644 (file)
index 0000000..38a1ef6
--- /dev/null
@@ -0,0 +1,503 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _<T>Plex_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>Plex_h 1
+
+#include <std.h>
+#include <Pix.h>
+#include "<T>.defs.h"
+
+// Plexes are made out of <T>IChunks
+
+#include <stddef.h>
+
+class <T>IChunk
+{
+//public: // kludge until C++ `protected' policies settled
+protected:      
+
+  <T>*           data;           // data, from client
+
+  int            base;           // lowest possible index
+  int            low;            // lowest valid index
+  int            fence;          // highest valid index + 1
+  int            top;            // highest possible index + 1
+
+  <T>IChunk*     nxt;            // circular links
+  <T>IChunk*     prv;
+
+public:
+
+// constructors
+
+                 <T>IChunk(<T>*     d,       // ptr to array of elements
+                        int      base_idx, // initial indices
+                        int      low_idx,  
+                        int      fence_idx,
+                        int      top_idx);
+
+  virtual       ~<T>IChunk();
+
+// status reports
+
+  int            size() const;    // number of slots
+
+  virtual int    empty() const ;
+  virtual int    full() const ; 
+
+  int            can_grow_high () const ;  // there is space to add data
+  int            can_grow_low () const;        
+  
+  int            base_index() const;   // lowest possible index;
+  int            low_index() const;    // lowest actual index;
+  virtual int    first_index() const;  // lowest valid index or fence if none
+  virtual int    last_index() const;   // highest valid index or low-1 if none
+  int            fence_index() const;  // highest actual index + 1
+  int            top_index() const;    // highest possible index + 1
+
+// indexing conversion
+
+  int            possible_index(int i) const; // i between base and top
+  int            actual_index(int i) const;   // i between low and fence
+  virtual int    valid_index(int i) const;    // i not deleted (mainly for mchunks)
+
+  int            possible_pointer(const <T>* p) const; // same for ptr
+  int            actual_pointer(const <T>* p) const; 
+  virtual int    valid_pointer(const <T>* p) const; 
+
+  <T>*           pointer_to(int i) const ;   // pointer to data indexed by i
+                                      // caution: i is not checked for validity
+  int            index_of(const <T>* p) const; // index of data pointed to by p
+                                      // caution: p is not checked for validity
+
+  virtual int    succ(int idx) const;     // next valid index or fence if none
+  virtual int    pred(int idx) const;     // previous index or low - 1 if none
+
+  virtual <T>*   first_pointer() const;   // pointer to first valid pos or 0
+  virtual <T>*   last_pointer() const;    // pointer to first valid pos or 0
+  virtual <T>*   succ(<T>*  p) const;     // next pointer or 0
+  virtual <T>*   pred(<T>* p) const;     // previous pointer or 0
+
+// modification
+
+  virtual <T>*   grow_high ();      // return spot to add an element
+  virtual <T>*   grow_low ();  
+
+  virtual void   shrink_high ();    // logically delete top index
+  virtual void   shrink_low ();     
+
+  virtual void   clear(int lo);     // reset to empty ch with base = lo
+  virtual void   cleardown(int hi); // reset to empty ch with top = hi
+  void           re_index(int lo);  // re-index so lo is new low
+
+// chunk traversal
+
+  <T>IChunk*     next() const;
+  <T>IChunk*     prev() const;
+
+  void           link_to_prev(<T>IChunk* prev);
+  void           link_to_next(<T>IChunk* next);
+  void           unlink();
+
+// state checks
+
+  <T>*           invalidate();     // mark self as invalid; return data
+                                   // for possible deletion
+
+  virtual int    OK() const;             // representation invariant
+
+  volatile void   error(const char*) const;
+  volatile void   empty_error() const;
+  volatile void   full_error() const;
+  volatile void   index_error() const;
+};
+
+// <T>Plex is a partly `abstract' class: few of the virtuals
+// are implemented at the Plex level, only in the subclasses
+
+class <T>Plex
+{
+protected:      
+
+  <T>IChunk*       hd;          // a chunk holding the data
+  int              lo;          // lowest  index
+  int              fnc;         // highest index + 1
+  int              csize;       // size of the chunk
+
+  void             invalidate();              // mark so OK() is false
+  void             del_chunk(<T>IChunk*);        // delete a chunk
+
+  <T>IChunk*       tl() const;                // last chunk;
+  int              one_chunk() const;         // true if hd == tl()
+
+public:
+
+// constructors, etc.
+
+                    <T>Plex();                  // no-op
+
+  virtual           ~<T>Plex();
+
+  
+// Access functions 
+    
+  virtual <T>&      operator [] (int idx) = 0; // access by index;
+  virtual <T>&      operator () (Pix p) = 0;   // access by Pix;
+
+  virtual <T>&      high_element () = 0;      // access high element
+  virtual <T>&      low_element () = 0;       // access low element
+
+// read-only versions for const Plexes
+
+  virtual const <T>& operator [] (int idx) const = 0; // access by index;
+  virtual const <T>& operator () (Pix p) const = 0;   // access by Pix;
+
+  virtual const <T>& high_element () const = 0;      // access high element
+  virtual const <T>& low_element () const = 0;       // access low element
+
+
+// Index functions
+
+  virtual int       valid (int idx) const = 0;      // idx is an OK index
+
+  virtual int       low() const = 0;         // lowest index or fence if none
+  virtual int       high() const = 0;        // highest index or low-1 if none
+
+  int               ecnef() const;         // low limit index (low-1)
+  int               fence() const;         // high limit index (high+1)
+
+  virtual void      prev(int& idx) const= 0; // set idx to preceding index
+                                          // caution: pred may be out of bounds
+
+  virtual void      next(int& idx) const = 0;       // set to next index
+                                          // caution: succ may be out of bounds
+
+  virtual Pix       first() const = 0;        // Pix to low element or 0
+  virtual Pix       last() const = 0;         // Pix to high element or 0
+  virtual void      prev(Pix& pix) const = 0;  // preceding pix or 0
+  virtual void      next(Pix& pix) const = 0;  // next pix or 0
+  virtual int       owns(Pix p) const = 0;     // p is an OK Pix
+
+// index<->Pix 
+
+  virtual int       Pix_to_index(Pix p) const = 0;   // get index via Pix
+  virtual Pix       index_to_Pix(int idx) const = 0; // Pix via index
+
+// Growth
+
+  virtual int       add_high(const <T&> elem) =0;// add new element at high end
+                                                // return new high
+
+  virtual int       add_low(const <T&> elem) = 0;   // add new low element,
+                                                // return new low
+
+// Shrinkage
+
+  virtual int       del_high() = 0;           // remove the element at high end
+                                          // return new high
+  virtual int       del_low() = 0;        // delete low element, return new lo
+
+                                          // caution: del_low/high
+                                          // does not necessarily 
+                                          // immediately call <T>::~<T>
+
+
+// operations on multiple elements
+
+  virtual void      fill(const <T&> x);          // set all elements = x
+  virtual void      fill(const <T&> x, int from, int to); // fill from to to
+  virtual void      clear() = 0;                // reset to zero-sized Plex
+  virtual int       reset_low(int newlow); // change low index,return old
+  virtual void      reverse();                   // reverse in-place
+  virtual void      append(const <T>Plex& a);    // concatenate a copy
+  virtual void      prepend(const <T>Plex& a);   // prepend a copy
+
+// status
+
+  virtual int       can_add_high() const = 0;
+  virtual int       can_add_low() const = 0;
+  
+  int               length () const;       // number of slots
+
+  int               empty () const;        // is the plex empty?
+  virtual int       full() const = 0;      // it it full?
+
+  int               chunk_size() const;    // report chunk size;
+
+  virtual int       OK() const = 0;        // representation invariant
+
+  volatile void     error(const char* msg) const;
+  volatile void     index_error() const;
+  volatile void     empty_error() const;
+  volatile void     full_error() const;
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+// <T>IChunk ops
+
+inline int <T>IChunk:: size() const
+{
+  return top - base;
+}
+
+
+inline int <T>IChunk:: base_index() const
+{
+  return base;
+}
+
+inline  int <T>IChunk:: low_index() const
+{
+  return low;
+}
+
+inline  int  <T>IChunk:: fence_index() const
+{
+  return fence;
+}
+
+inline  int  <T>IChunk:: top_index() const
+{
+  return top;
+}
+
+inline  <T>* <T>IChunk:: pointer_to(int i) const
+{
+  return &(data[i-base]);
+}
+
+inline  int  <T>IChunk:: index_of(const <T>* p) const
+{
+  return ((int)p - (int)data) / sizeof(<T>) + base;
+}
+
+inline  int  <T>IChunk:: possible_index(int i) const
+{
+  return i >= base && i < top;
+}
+
+inline  int  <T>IChunk:: possible_pointer(const <T>* p) const
+{
+  return p >= data && p < &(data[top-base]);
+}
+
+inline  int  <T>IChunk:: actual_index(int i) const
+{
+  return i >= low && i < fence;
+}
+
+inline  int  <T>IChunk:: actual_pointer(const <T>* p) const
+{
+  return p >= data && p < &(data[fence-base]);
+}
+
+inline  int  <T>IChunk:: can_grow_high () const
+{
+  return fence < top;
+}
+
+inline  int  <T>IChunk:: can_grow_low () const
+{
+  return base < low;
+}
+
+inline  <T>* <T>IChunk:: invalidate()
+{
+  <T>* p = data;
+  data = 0;
+  return p;
+}
+
+
+inline <T>IChunk* <T>IChunk::prev() const
+{
+  return prv;
+}
+
+inline <T>IChunk* <T>IChunk::next() const
+{
+  return nxt;
+}
+
+inline void <T>IChunk::link_to_prev(<T>IChunk* prev)
+{
+  nxt = prev->nxt;
+  prv = prev;
+  nxt->prv = this;
+  prv->nxt = this;
+}
+
+inline void <T>IChunk::link_to_next(<T>IChunk* next)
+{
+  prv = next->prv;
+  nxt = next;
+  nxt->prv = this;
+  prv->nxt = this;
+}
+
+inline void <T>IChunk::unlink()
+{
+  <T>IChunk* n = nxt;
+  <T>IChunk* p = prv;
+  n->prv = p;
+  p->nxt = n;
+  prv = nxt = this;
+}
+
+inline  int <T>IChunk:: empty() const
+{
+  return low == fence;
+}
+
+inline  int  <T>IChunk:: full() const
+{
+  return top - base == fence - low;
+}
+
+inline int <T>IChunk:: first_index() const
+{
+  return (low == fence)? fence : low;
+}
+
+inline int <T>IChunk:: last_index() const
+{
+  return (low == fence)? low - 1 : fence - 1;
+}
+
+inline  int  <T>IChunk:: succ(int i) const
+{
+  return (i < low) ? low : i + 1;
+}
+
+inline  int  <T>IChunk:: pred(int i) const
+{
+  return (i > fence) ? (fence - 1) : i - 1;
+}
+
+inline  int  <T>IChunk:: valid_index(int i) const
+{
+  return i >= low && i < fence;
+}
+
+inline  int  <T>IChunk:: valid_pointer(const <T>* p) const
+{
+  return p >= &(data[low - base]) && p < &(data[fence - base]);
+}
+
+inline  <T>* <T>IChunk:: grow_high ()
+{
+  if (!can_grow_high()) full_error();
+  return &(data[fence++ - base]);
+}
+
+inline  <T>* <T>IChunk:: grow_low ()
+{
+  if (!can_grow_low()) full_error();
+  return &(data[--low - base]);
+}
+
+inline  void <T>IChunk:: shrink_high ()
+{
+  if (empty()) empty_error();
+  --fence;
+}
+
+inline  void <T>IChunk:: shrink_low ()
+{
+  if (empty()) empty_error();
+  ++low;
+}
+
+inline <T>* <T>IChunk::first_pointer() const
+{
+  return (low == fence)? 0 : &(data[low - base]);
+}
+
+inline <T>* <T>IChunk::last_pointer() const
+{
+  return (low == fence)? 0 : &(data[fence - base - 1]);
+}
+
+inline <T>* <T>IChunk::succ(<T>* p) const
+{
+  return ((p+1) <  &(data[low - base]) || (p+1) >= &(data[fence - base])) ? 
+    0 : (p+1);
+}
+
+inline <T>* <T>IChunk::pred(<T>* p) const
+{
+  return ((p-1) <  &(data[low - base]) || (p-1) >= &(data[fence - base])) ? 
+    0 : (p-1);
+}
+
+
+// generic Plex operations
+
+inline <T>Plex::<T>Plex() {}
+
+inline int <T>Plex::chunk_size() const
+{
+  return csize;
+}
+
+inline  int <T>Plex::ecnef () const
+{
+  return lo - 1;
+}
+
+
+inline  int <T>Plex::fence () const
+{
+  return fnc;
+}
+
+inline int <T>Plex::length () const
+{
+  return fnc - lo;
+}
+
+inline  int <T>Plex::empty () const
+{
+  return fnc == lo;
+}
+
+inline <T>IChunk* <T>Plex::tl() const
+{
+  return hd->prev();
+}
+
+inline int <T>Plex::one_chunk() const
+{
+  return hd == hd->prev();
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/Queue.ccP b/usr/include/g++/gen/Queue.ccP
new file mode 100644 (file)
index 0000000..fb48d95
--- /dev/null
@@ -0,0 +1,14 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.Queue.h"
+
+<T>Queue::~<T>Queue() {}
+
+
+// error handling
+
+void <T>Queue::error(const char* msg)
+{
+  (*lib_error_handler)("Queue", msg);
+}
diff --git a/usr/include/g++/gen/Queue.hP b/usr/include/g++/gen/Queue.hP
new file mode 100644 (file)
index 0000000..3ff62c8
--- /dev/null
@@ -0,0 +1,62 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>Queue_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>Queue_h
+
+#include <builtin.h>
+
+#include "<T>.defs.h"
+
+class <T>Queue
+{
+public:
+                        <T>Queue();
+  virtual              ~<T>Queue();
+
+  virtual void          enq(<T&> item) = 0;
+  virtual <T>           deq() = 0;
+  virtual <T>&          front() = 0;
+  virtual void          del_front() = 0;
+
+  virtual void          clear() = 0;
+  virtual int           empty() = 0;
+  virtual int           full() = 0;
+  virtual int           length() = 0;
+
+  void                  error(const char*);
+  
+  virtual int           OK() = 0;
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>Queue::<T>Queue() {}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/RAVLMap.ccP b/usr/include/g++/gen/RAVLMap.ccP
new file mode 100644 (file)
index 0000000..8153423
--- /dev/null
@@ -0,0 +1,684 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include <assert.h>
+#include "<T>.<C>.RAVLMap.h"
+
+
+/*
+ constants & inlines for maintaining balance & thread status in tree nodes
+*/
+
+#define AVLBALANCEMASK    3
+#define AVLBALANCED       0
+#define AVLLEFTHEAVY      1
+#define AVLRIGHTHEAVY     2
+
+#define LTHREADBIT        4
+#define RTHREADBIT        8
+
+
+static inline int bf(<T><C>RAVLNode* t)
+{
+  return t->stat & AVLBALANCEMASK;
+}
+
+static inline void set_bf(<T><C>RAVLNode* t, int b)
+{
+  t->stat = (t->stat & ~AVLBALANCEMASK) | (b & AVLBALANCEMASK);
+}
+
+
+static inline int rthread(<T><C>RAVLNode* t)
+{
+  return t->stat & RTHREADBIT;
+}
+
+static inline void set_rthread(<T><C>RAVLNode* t, int b)
+{
+  if (b)
+    t->stat |= RTHREADBIT;
+  else
+    t->stat &= ~RTHREADBIT;
+}
+
+static inline int lthread(<T><C>RAVLNode* t)
+{
+  return t->stat & LTHREADBIT;
+}
+
+static inline void set_lthread(<T><C>RAVLNode* t, int b)
+{
+  if (b)
+    t->stat |= LTHREADBIT;
+  else
+    t->stat &= ~LTHREADBIT;
+}
+
+/*
+ traversal primitives
+*/
+
+
+<T><C>RAVLNode* <T><C>RAVLMap::leftmost()
+{
+  <T><C>RAVLNode* t = root;
+  if (t != 0) while (t->lt != 0) t = t->lt;
+  return t;
+}
+
+<T><C>RAVLNode* <T><C>RAVLMap::rightmost()
+{
+  <T><C>RAVLNode* t = root;
+  if (t != 0) while (t->rt != 0) t = t->rt;
+  return t;
+}
+
+<T><C>RAVLNode* <T><C>RAVLMap::succ(<T><C>RAVLNode* t)
+{
+  <T><C>RAVLNode* r = t->rt;
+  if (!rthread(t)) while (!lthread(r)) r = r->lt;
+  return r;
+}
+
+<T><C>RAVLNode* <T><C>RAVLMap::pred(<T><C>RAVLNode* t)
+{
+  <T><C>RAVLNode* l = t->lt;
+  if (!lthread(t)) while (!rthread(l)) l = l->rt;
+  return l;
+}
+
+
+Pix <T><C>RAVLMap::seek(<T&> key)
+{
+  <T><C>RAVLNode* t = root;
+  if (t == 0)
+    return 0;
+  for (;;)
+  {
+    int cmp = <T>CMP(key, t->item);
+    if (cmp == 0)
+      return Pix(t);
+    else if (cmp < 0)
+    {
+      if (lthread(t))
+        return 0;
+      else
+        t = t->lt;
+    }
+    else if (rthread(t))
+      return 0;
+    else
+      t = t->rt;
+  }
+}
+
+
+int <T><C>RAVLMap::rankof(<T&> key)
+{
+  int r;
+  <T><C>RAVLNode* t = root;
+  if (t == 0)
+    return 0;
+  for (r=t->rank; t != 0; r+=t->rank)
+  {
+    int cmp = <T>CMP(key, t->item);
+    if (cmp == 0)
+      return r;
+    else if (cmp < 0)
+    {
+      if (lthread(t))
+        return 0;
+      else
+      {
+        r -= t->rank;  
+        t = t->lt;
+      }
+    }
+    else if (rthread(t))
+      return 0;
+    else
+    {
+      t = t->rt;
+    }
+  }
+  return 0;
+}
+
+Pix <T><C>RAVLMap::ranktoPix(int i)
+{
+  int r;
+  <T><C>RAVLNode* t = root;
+
+  if ((i<1)||(i>count))
+    return 0;
+  for (r=t->rank; r!=i; r+=t->rank)
+  {
+    if (r>i)
+    {
+      r -= t->rank;
+      t = t->lt;
+    }
+    else
+      t = t->rt;
+  }
+  return Pix(t);
+}
+
+/*
+ The combination of threads and AVL bits make adding & deleting
+ interesting, but very awkward.
+
+ We use the following statics to avoid passing them around recursively
+*/
+
+static int _need_rebalancing;   // to send back balance info from rec. calls
+static <T>*   _target_item;     // add/del_item target
+static <T><C>RAVLNode* _found_node; // returned added/deleted node
+static int    _already_found;   // for deletion subcases
+static int    _rank_changed;    // for rank computation
+
+
+void <T><C>RAVLMap:: _add(<T><C>RAVLNode*& t)
+{
+  int cmp = <T>CMP(*_target_item, t->item);
+  if (cmp == 0)
+  {
+    _found_node = t;
+    return;
+  }
+  else if (cmp < 0)
+  {
+    if (lthread(t))
+    {
+      ++count;
+      _found_node = new <T><C>RAVLNode(*_target_item, def);
+      set_lthread(_found_node, 1);
+      set_rthread(_found_node, 1);
+      _found_node->lt = t->lt;
+      _found_node->rt = t;
+      t->lt = _found_node;
+      set_lthread(t, 0);
+      _need_rebalancing = 1;
+      _rank_changed = 1;
+    }
+    else
+      _add(t->lt);
+    if (_rank_changed) ++t->rank;
+    if (_need_rebalancing)
+    {
+      switch(bf(t))
+      {
+      case AVLRIGHTHEAVY:
+        set_bf(t, AVLBALANCED);
+        _need_rebalancing = 0;
+        return;
+      case AVLBALANCED:
+        set_bf(t, AVLLEFTHEAVY);
+        return;
+      case AVLLEFTHEAVY:
+        <T><C>RAVLNode* l = t->lt;
+        if (bf(l) == AVLLEFTHEAVY)
+        {
+         t->rank -= l->rank;
+          if (rthread(l))
+            t->lt = l;
+          else
+            t->lt = l->rt;
+          set_lthread(t, rthread(l));
+          l->rt = t;
+          set_rthread(l, 0);
+          set_bf(t, AVLBALANCED);
+          set_bf(l, AVLBALANCED);
+          t = l;
+          _need_rebalancing = 0;
+        }
+        else
+        {
+          <T><C>RAVLNode* r = l->rt;
+         r->rank += l->rank;
+         t->rank -= r->rank;
+          set_rthread(l, lthread(r));
+          if (lthread(r))
+            l->rt = r;
+          else
+            l->rt = r->lt;
+          r->lt = l;
+          set_lthread(r, 0);
+          set_lthread(t, rthread(r));
+          if (rthread(r))
+            t->lt = r;
+          else
+            t->lt = r->rt;
+          r->rt = t;
+          set_rthread(r, 0);
+          if (bf(r) == AVLLEFTHEAVY)
+            set_bf(t, AVLRIGHTHEAVY);
+          else
+            set_bf(t, AVLBALANCED);
+          if (bf(r) == AVLRIGHTHEAVY)
+            set_bf(l, AVLLEFTHEAVY);
+          else
+            set_bf(l, AVLBALANCED);
+          set_bf(r, AVLBALANCED);
+          t = r;
+          _need_rebalancing = 0;
+          return;
+        }
+      }
+    }
+  }
+  else
+  {
+    if (rthread(t))
+    {
+      ++count;
+      _found_node = new <T><C>RAVLNode(*_target_item, def);
+      set_rthread(t, 0);
+      set_lthread(_found_node, 1);
+      set_rthread(_found_node, 1);
+      _found_node->lt = t;
+      _found_node->rt = t->rt;
+      t->rt = _found_node;
+      _need_rebalancing = 1;
+      _rank_changed = 1;
+    }
+    else
+      _add(t->rt);
+    if (_need_rebalancing)
+    {
+      switch(bf(t))
+      {
+      case AVLLEFTHEAVY:
+        set_bf(t, AVLBALANCED);
+        _need_rebalancing = 0;
+        return;
+      case AVLBALANCED:
+        set_bf(t, AVLRIGHTHEAVY);
+        return;
+      case AVLRIGHTHEAVY:
+        <T><C>RAVLNode* r = t->rt;
+        if (bf(r) == AVLRIGHTHEAVY)
+        {
+         r->rank += t->rank;
+          if (lthread(r))
+            t->rt = r;
+          else
+            t->rt = r->lt;
+          set_rthread(t, lthread(r));
+          r->lt = t;
+          set_lthread(r, 0);
+          set_bf(t, AVLBALANCED);
+          set_bf(r, AVLBALANCED);
+          t = r;
+          _need_rebalancing = 0;
+        }
+        else
+        {
+          <T><C>RAVLNode* l = r->lt;
+         r->rank -= l->rank;
+         l->rank += t->rank;
+          set_lthread(r, rthread(l));
+          if (rthread(l))
+            r->lt = l;
+          else
+            r->lt = l->rt;
+          l->rt = r;
+          set_rthread(l, 0);
+          set_rthread(t, lthread(l));
+          if (lthread(l))
+            t->rt = l;
+          else
+            t->rt = l->lt;
+          l->lt = t;
+          set_lthread(l, 0);
+          if (bf(l) == AVLRIGHTHEAVY)
+            set_bf(t, AVLLEFTHEAVY);
+          else
+            set_bf(t, AVLBALANCED);
+          if (bf(l) == AVLLEFTHEAVY)
+            set_bf(r, AVLRIGHTHEAVY);
+          else
+            set_bf(r, AVLBALANCED);
+          set_bf(l, AVLBALANCED);
+          t = l;
+          _need_rebalancing = 0;
+          return;
+        }
+      }
+    }
+  }
+}
+
+    
+<C>& <T><C>RAVLMap::operator [] (<T&> item)
+{
+  if (root == 0)
+  {
+    ++count;
+    root = new <T><C>RAVLNode(item, def);
+    set_rthread(root, 1);
+    set_lthread(root, 1);
+    return root->cont;
+  }
+  else
+  {
+    _target_item = &item;
+    _need_rebalancing = 0;
+    _rank_changed = 0;
+    _add(root);
+    return _found_node->cont;
+  }
+}
+
+
+void <T><C>RAVLMap::_del(<T><C>RAVLNode* par, <T><C>RAVLNode*& t)
+{
+  int comp;
+  if (_already_found)
+  {
+    if (rthread(t))
+      comp = 0;
+    else
+      comp = 1;
+  }
+  else 
+    comp = <T>CMP(*_target_item, t->item);
+  if (comp == 0)
+  {
+    if (lthread(t) && rthread(t))
+    {
+      _found_node = t;
+      if (t == par->lt)
+      {
+        set_lthread(par, 1);
+        par->lt = t->lt;
+      }
+      else
+      {
+        set_rthread(par, 1);
+        par->rt = t->rt;
+      }
+      _need_rebalancing = 1;
+      _rank_changed = 1;
+      return;
+    }
+    else if (lthread(t))
+    {
+      _found_node = t;
+      <T><C>RAVLNode* s = succ(t);
+      if (s != 0 && lthread(s))
+        s->lt = t->lt;
+      t = t->rt;
+      _need_rebalancing = 1;
+      _rank_changed = 1;
+      return;
+    }
+    else if (rthread(t))
+    {
+      _found_node = t;
+      <T><C>RAVLNode* p = pred(t);
+      if (p != 0 && rthread(p))
+        p->rt = t->rt;
+      t = t->lt;
+      _need_rebalancing = 1;
+      _rank_changed = 1;
+      return;
+    }
+    else                        // replace item & find someone deletable
+    {
+      <T><C>RAVLNode* p = pred(t);
+      t->item = p->item;
+      t->cont = p->cont;
+      _already_found = 1;
+      comp = -1;                // fall through below to left
+    }
+  }
+
+  if (comp < 0)
+  {
+    if (lthread(t))
+      return;
+    _del(t, t->lt);
+    if (_rank_changed) --t->rank;
+    if (!_need_rebalancing)
+      return;
+    switch (bf(t))
+    {
+    case AVLLEFTHEAVY:
+      set_bf(t, AVLBALANCED);
+      return;
+    case AVLBALANCED:
+      set_bf(t, AVLRIGHTHEAVY);
+      _need_rebalancing = 0;
+      return;
+    case AVLRIGHTHEAVY:
+      <T><C>RAVLNode* r = t->rt;
+      switch (bf(r))
+      {
+      case AVLBALANCED:
+       r->rank += t->rank;
+        if (lthread(r))
+          t->rt = r;
+        else
+          t->rt = r->lt;
+        set_rthread(t, lthread(r));
+        r->lt = t;
+        set_lthread(r, 0);
+        set_bf(t, AVLRIGHTHEAVY);
+        set_bf(r, AVLLEFTHEAVY);
+        _need_rebalancing = 0;
+        t = r;
+        return;
+      case AVLRIGHTHEAVY:
+       r->rank += t->rank;
+        if (lthread(r))
+          t->rt = r;
+        else
+          t->rt = r->lt;
+        set_rthread(t, lthread(r));
+        r->lt = t;
+        set_lthread(r, 0);
+        set_bf(t, AVLBALANCED);
+        set_bf(r, AVLBALANCED);
+        t = r;
+        return;
+      case AVLLEFTHEAVY:
+        <T><C>RAVLNode* l = r->lt;
+       r->rank -= l->rank;
+       l->rank += t->rank;
+        set_lthread(r, rthread(l));
+        if (rthread(l))
+          r->lt = l;
+        else
+          r->lt = l->rt;
+        l->rt = r;
+        set_rthread(l, 0);
+        set_rthread(t, lthread(l));
+        if (lthread(l))
+          t->rt = l;
+        else
+          t->rt = l->lt;
+        l->lt = t;
+        set_lthread(l, 0);
+        if (bf(l) == AVLRIGHTHEAVY)
+          set_bf(t, AVLLEFTHEAVY);
+        else
+          set_bf(t, AVLBALANCED);
+        if (bf(l) == AVLLEFTHEAVY)
+          set_bf(r, AVLRIGHTHEAVY);
+        else
+          set_bf(r, AVLBALANCED);
+        set_bf(l, AVLBALANCED);
+        t = l;
+        return;
+      }
+    }
+  }
+  else
+  {
+    if (rthread(t))
+      return;
+    _del(t, t->rt);
+    if (!_need_rebalancing)
+      return;
+    switch (bf(t))
+    {
+    case AVLRIGHTHEAVY:
+      set_bf(t, AVLBALANCED);
+      return;
+    case AVLBALANCED:
+      set_bf(t, AVLLEFTHEAVY);
+      _need_rebalancing = 0;
+      return;
+    case AVLLEFTHEAVY:
+      <T><C>RAVLNode* l = t->lt;
+      switch (bf(l))
+      {
+      case AVLBALANCED:
+       t->rank -= l->rank;
+        if (rthread(l))
+          t->lt = l;
+        else
+          t->lt = l->rt;
+        set_lthread(t, rthread(l));
+        l->rt = t;
+        set_rthread(l, 0);
+        set_bf(t, AVLLEFTHEAVY);
+        set_bf(l, AVLRIGHTHEAVY);
+        _need_rebalancing = 0;
+        t = l;
+        return;
+      case AVLLEFTHEAVY:
+       t->rank -= l->rank;
+        if (rthread(l))
+          t->lt = l;
+        else
+          t->lt = l->rt;
+        set_lthread(t, rthread(l));
+        l->rt = t;
+        set_rthread(l, 0);
+        set_bf(t, AVLBALANCED);
+        set_bf(l, AVLBALANCED);
+        t = l;
+        return;
+      case AVLRIGHTHEAVY:
+        <T><C>RAVLNode* r = l->rt;
+       r->rank += l->rank;
+       t->rank -= r->rank;
+        set_rthread(l, lthread(r));
+        if (lthread(r))
+          l->rt = r;
+        else
+          l->rt = r->lt;
+        r->lt = l;
+        set_lthread(r, 0);
+        set_lthread(t, rthread(r));
+        if (rthread(r))
+          t->lt = r;
+        else
+          t->lt = r->rt;
+        r->rt = t;
+        set_rthread(r, 0);
+        if (bf(r) == AVLLEFTHEAVY)
+          set_bf(t, AVLRIGHTHEAVY);
+        else
+          set_bf(t, AVLBALANCED);
+        if (bf(r) == AVLRIGHTHEAVY)
+          set_bf(l, AVLLEFTHEAVY);
+        else
+          set_bf(l, AVLBALANCED);
+        set_bf(r, AVLBALANCED);
+        t = r;
+        return;
+      }
+    }
+  }
+}
+
+
+void <T><C>RAVLMap::del(<T&> item)
+{
+  if (root == 0) return;
+  _need_rebalancing = 0;
+  _already_found = 0;
+  _found_node = 0;
+  _rank_changed = 0;
+  _target_item = &item;
+  _del(root, root);
+  if (_found_node)
+  {
+    delete(_found_node);
+    if (--count == 0)
+      root = 0;
+  }
+}
+
+void <T><C>RAVLMap::_kill(<T><C>RAVLNode* t)
+{
+  if (t != 0)
+  {
+    if (!lthread(t)) _kill(t->lt);
+    if (!rthread(t)) _kill(t->rt);
+    delete t;
+  }
+}
+
+
+<T><C>RAVLMap::<T><C>RAVLMap(<T><C>RAVLMap& b) :<T><C>Map(b.def)
+{
+  root = 0;
+  count = 0;
+  for (Pix i = b.first(); i != 0; b.next(i)) 
+    (*this)[b.key(i)] = b.contents(i);
+}
+
+
+int <T><C>RAVLMap::OK()
+{
+  int v = 1;
+  if (root == 0) 
+    v = count == 0;
+  else
+  {
+    int n = 1;
+    <T><C>RAVLNode* trail = leftmost();
+    v &= rankof(trail->item) == n;
+    <T><C>RAVLNode* t = succ(trail);
+    while (t != 0)
+    {
+      ++n;
+      v &= <T>CMP(trail->item, t->item) < 0;
+      v &= rankof(t->item) == n;
+      trail = t;
+      t = succ(t);
+    }
+    v &= n == count;
+  }
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/RAVLMap.hP b/usr/include/g++/gen/RAVLMap.hP
new file mode 100644 (file)
index 0000000..cf216e5
--- /dev/null
@@ -0,0 +1,162 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu) 
+    ranking code from Paul Anderson (paul%lfcs.ed.ac.uk)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T><C>RAVLMap_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T><C>RAVLMap_h 1
+
+#include "<T>.<C>.Map.h"
+
+struct <T><C>RAVLNode
+{
+  <T><C>RAVLNode*      lt;
+  <T><C>RAVLNode*      rt;
+  <T>                 item;
+  <C>                 cont;
+  int                 rank;
+  char                stat;
+                      <T><C>RAVLNode(<T&> h, <C&> c, 
+                           <T><C>RAVLNode* l=0, <T><C>RAVLNode* r=0, int k=1);
+                      ~<T><C>RAVLNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T><C>RAVLNode::<T><C>RAVLNode(<T&> h, <C&> c, 
+                           <T><C>RAVLNode* l, <T><C>RAVLNode* r, int k)
+     :item(h), cont(c), lt(l), rt(r), rank(k), stat(0) {}
+
+inline <T><C>RAVLNode::~<T><C>RAVLNode() {}
+
+#endif
+
+typedef <T><C>RAVLNode* <T><C>RAVLNodePtr;
+
+
+class <T><C>RAVLMap : public <T><C>Map
+{
+protected:
+  <T><C>RAVLNode*   root;
+
+  <T><C>RAVLNode*   leftmost();
+  <T><C>RAVLNode*   rightmost();
+  <T><C>RAVLNode*   pred(<T><C>RAVLNode* t);
+  <T><C>RAVLNode*   succ(<T><C>RAVLNode* t);
+  void            _kill(<T><C>RAVLNode* t);
+  void            _add(<T><C>RAVLNode*& t);
+  void            _del(<T><C>RAVLNode* p, <T><C>RAVLNode*& t);
+
+public:
+                <T><C>RAVLMap(<C&> dflt);
+                <T><C>RAVLMap(<T><C>RAVLMap& a);
+                ~<T><C>RAVLMap();
+
+  <C>&          operator [] (<T&> key);
+
+  void          del(<T&> key);
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          key(Pix i);
+  <C>&          contents(Pix i);
+
+  Pix           seek(<T&> key);
+  int           contains(<T&> key);
+
+  Pix           ranktoPix(int i);
+  int           rankof(<T&> key);
+
+  void          clear(); 
+
+  Pix           last();
+  void          prev(Pix& i);
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T><C>RAVLMap::~<T><C>RAVLMap()
+{
+  _kill(root);
+}
+
+inline <T><C>RAVLMap::<T><C>RAVLMap(<C&> dflt) :(dflt)
+{
+  root = 0;
+}
+
+
+inline Pix <T><C>RAVLMap::first()
+{
+  return Pix(leftmost());
+}
+
+inline Pix <T><C>RAVLMap::last()
+{
+  return Pix(rightmost());
+}
+
+inline void <T><C>RAVLMap::next(Pix& i)
+{
+  if (i != 0) i = Pix(succ((<T><C>RAVLNode*)i));
+}
+
+inline void <T><C>RAVLMap::prev(Pix& i)
+{
+  if (i != 0) i = Pix(pred((<T><C>RAVLNode*)i));
+}
+
+inline <T>& <T><C>RAVLMap::key(Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T><C>RAVLNode*)i)->item;
+}
+
+inline <C>& <T><C>RAVLMap::contents(Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T><C>RAVLNode*)i)->cont;
+}
+
+inline void <T><C>RAVLMap::clear()
+{
+  _kill(root);
+  count = 0;
+  root = 0;
+}
+
+inline int <T><C>RAVLMap::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/RPlex.ccP b/usr/include/g++/gen/RPlex.ccP
new file mode 100644 (file)
index 0000000..a91bbeb
--- /dev/null
@@ -0,0 +1,492 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.RPlex.h"
+
+typedef <T>IChunk* _<T>IChunk_ptr;
+
+<T>RPlex:: <T>RPlex()
+{
+  lo = fnc = 0;
+  csize = DEFAULT_INITIAL_CAPACITY;
+  <T>* data = new <T>[csize];
+  set_cache(new <T>IChunk(data,  lo, lo, fnc, lo+csize));
+  hd = ch;
+  maxch = MIN_NCHUNKS;
+  lch = maxch / 2;
+  fch = lch + 1;
+  base = ch->base_index() - lch * csize;
+  chunks = new _<T>IChunk_ptr[maxch];
+  chunks[lch] = ch;
+}
+
+<T>RPlex:: <T>RPlex(int chunksize)
+{
+  if (chunksize == 0) error("invalid constructor specification");
+  lo = fnc = 0;
+  if (chunksize > 0)
+  {
+    csize = chunksize;
+    <T>* data = new <T>[csize];
+    set_cache(new <T>IChunk(data,  lo, lo, fnc, csize+lo));
+    hd = ch;
+  }
+  else
+  {
+    csize = -chunksize;
+    <T>* data = new <T>[csize];
+    set_cache(new <T>IChunk(data,  chunksize+lo, lo, fnc, fnc));
+    hd = ch;
+  }
+  maxch = MIN_NCHUNKS;
+  lch = maxch / 2;
+  fch = lch + 1;
+  base = ch->base_index() - lch * csize;
+  chunks = new _<T>IChunk_ptr[maxch];
+  chunks[lch] = ch;
+}
+
+
+<T>RPlex:: <T>RPlex(int l, int chunksize)
+{
+  if (chunksize == 0) error("invalid constructor specification");
+  lo = fnc = l;
+  if (chunksize > 0)
+  {
+    csize = chunksize;
+    <T>* data = new <T>[csize];
+    set_cache(new <T>IChunk(data,  lo, lo, fnc, lo+csize));
+    hd = ch;
+  }
+  else
+  {
+    csize = -chunksize;
+    <T>* data = new <T>[csize];
+    set_cache(new <T>IChunk(data,  chunksize+lo, lo, fnc, fnc));
+    hd = ch;
+  }
+  maxch = MIN_NCHUNKS;
+  lch = maxch / 2;
+  fch = lch + 1;
+  base = ch->base_index() - lch * csize;
+  chunks = new _<T>IChunk_ptr[maxch];
+  chunks[lch] = ch;
+}
+
+void <T>RPlex::make_initial_chunks(int up)
+{
+  int count = 0;
+  int need = fnc - lo;
+  hd = 0;
+  if (up)
+  {
+    int l = lo;
+    do
+    {
+      ++count;
+      int sz;
+      if (need >= csize)
+        sz = csize;
+      else
+        sz = need;
+      <T>* data = new <T> [csize];
+      <T>IChunk* h = new <T>IChunk(data,  l, l, l+sz, l+csize);
+      if (hd != 0)
+        h->link_to_next(hd);
+      else
+        hd = h;
+      l += sz;
+      need -= sz;
+    } while (need > 0);
+  }
+  else
+  {
+    int hi = fnc;
+    do
+    {
+      ++count;
+      int sz;
+      if (need >= csize)
+        sz = csize;
+      else
+        sz = need;
+      <T>* data = new <T> [csize];
+      <T>IChunk* h = new <T>IChunk(data,  hi-csize, hi-sz, hi, hi);
+      if (hd != 0)
+        h->link_to_next(hd);
+      hd = h;
+      hi -= sz;
+      need -= sz;
+    } while (need > 0);
+  }
+  set_cache((<T>IChunk*)hd);
+  
+  maxch = MIN_NCHUNKS;
+  if (maxch < count * 2)
+    maxch = count * 2;
+  chunks = new _<T>IChunk_ptr[maxch];
+  lch = maxch / 3;
+  fch = lch + count;
+  base = ch->base_index() - csize * lch;
+  int k = lch;
+  do
+  {
+    chunks[k++] = ch;
+    set_cache(ch->next());
+  } while (ch != hd);
+}
+
+<T>RPlex:: <T>RPlex(int l, int hi, const <T&> initval, int chunksize)
+{
+  lo = l;
+  fnc = hi + 1;
+  if (chunksize == 0)
+  {
+    csize = fnc - l;
+    make_initial_chunks(1);
+  }
+  else if (chunksize < 0)
+  {
+    csize = -chunksize;
+    make_initial_chunks(0);
+  }
+  else
+  {
+    csize = chunksize;
+    make_initial_chunks(1);
+  }
+  fill(initval);
+}
+
+<T>RPlex::<T>RPlex(const <T>RPlex& a)
+{
+  lo = a.lo;
+  fnc = a.fnc;
+  csize = a.csize;
+  make_initial_chunks();
+  for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i];
+}
+
+void <T>RPlex::operator= (const <T>RPlex& a)
+{
+  if (&a != this)
+  {
+    invalidate();
+    lo = a.lo;
+    fnc = a.fnc;
+    csize = a.csize;
+    make_initial_chunks();
+    for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i];
+  }
+}
+
+
+void <T>RPlex::cache(const <T>* p) const
+{
+  const <T>IChunk* old = ch;
+  const <T>IChunk* t = ch;
+  while (!t->actual_pointer(p))
+  {
+    t = (t->next());
+    if (t == old) index_error();
+  }
+  set_cache(t);
+}
+
+int <T>RPlex::owns(Pix px) const
+{
+  <T>* p = (<T>*)px;
+  const <T>IChunk* old = ch;
+  const <T>IChunk* t = ch;
+  while (!t->actual_pointer(p))
+  {
+    t = (t->next());
+    if (t == old) return 0;
+  }
+  set_cache(t);
+  return 1;
+}
+
+
+<T>* <T>RPlex::dosucc(const <T>* p) const
+{
+  if (p == 0) return 0;
+  const <T>IChunk* old = ch;
+  const <T>IChunk* t = ch;
+  while (!t->actual_pointer(p))
+  {
+    t = (t->next());
+    if (t == old) return 0;
+  }
+  int i = t->index_of(p) + 1;
+  if (i >= fnc) return 0;
+  if (i >= t->fence_index()) t = (t->next());
+  set_cache(t);
+  return t->pointer_to(i);
+}
+
+<T>* <T>RPlex::dopred(const <T>* p) const
+{
+  if (p == 0) return 0;
+  const <T>IChunk* old = ch;
+  const <T>IChunk* t = ch;
+  while (!t->actual_pointer(p))
+  {
+    t = (t->prev());
+    if (t == old) return 0;
+  }
+  int i = t->index_of(p) - 1;
+  if (i < lo) return 0;
+  if (i < t->low_index()) t = (t->prev());
+  set_cache(t);
+  return (t->pointer_to(i));
+}
+
+int <T>RPlex::add_high(const <T&> elem)
+{
+  <T>IChunk* t = tl();
+  if (!t->can_grow_high())
+  {
+    if (t-><T>IChunk::empty() && one_chunk())
+    {
+      t->clear(fnc);
+      base = t->base_index() - lch * csize;
+    }
+    else
+    {
+      <T>* data = new <T> [csize];
+      t = (new <T>IChunk(data,  fnc, fnc, fnc,fnc+csize));
+      t->link_to_prev(tl());
+      if (fch == maxch)
+      {
+        maxch *= 2;
+        <T>IChunk** newch = new _<T>IChunk_ptr [maxch];
+        bcopy(chunks, newch, fch * sizeof(_<T>IChunk_ptr));
+        delete chunks;
+        chunks = newch;
+      }
+      chunks[fch++] = t;
+    }
+  }
+  *((t-><T>IChunk::grow_high())) = elem;
+  set_cache(t);
+  return fnc++;
+}
+
+int <T>RPlex::del_high ()
+{
+  if (empty()) empty_error();
+  <T>IChunk* t = tl();
+  if (t-><T>IChunk::empty()) // kill straggler first
+  {
+    <T>IChunk* pred = t->prev();
+    del_chunk(t);
+    t = (pred);
+    --fch;
+  }
+  t-><T>IChunk::shrink_high();
+  if (t-><T>IChunk::empty() && !one_chunk())
+  {
+    <T>IChunk* pred = t->prev();
+    del_chunk(t);
+    t = (pred);
+    --fch;
+  }
+  set_cache(t);
+  return --fnc - 1;
+}
+
+int <T>RPlex::add_low (const <T&> elem)
+{
+  <T>IChunk* t = hd;
+  if (!t->can_grow_low())
+  {
+    if (t-><T>IChunk::empty() && one_chunk())
+    {
+      t->cleardown(lo);
+      base = t->base_index() - lch * csize;
+    }
+    else
+    {
+      <T>* data = new <T> [csize];
+      hd = new <T>IChunk(data,  lo-csize, lo, lo, lo);
+      hd->link_to_next(t);
+      t = ( hd);
+      if (lch == 0)
+      {
+        lch = maxch;
+        fch += maxch;
+        maxch *= 2;
+        <T>IChunk** newch = new _<T>IChunk_ptr [maxch];
+        bcopy(chunks, &(newch[lch]), lch * sizeof(_<T>IChunk_ptr));
+        delete chunks;
+        chunks = newch;
+        base = t->base_index() - (lch - 1) * csize;
+      }
+      chunks[--lch] = t;
+    }
+  }
+  *((t-><T>IChunk::grow_low())) = elem;
+  set_cache(t);
+  return --lo;
+}
+
+
+int <T>RPlex::del_low ()
+{
+  if (empty()) empty_error();
+  <T>IChunk* t = hd;
+  if (t-><T>IChunk::empty())
+  {
+    hd = t->next();
+    del_chunk(t);
+    t = hd;
+    ++lch;
+  }
+  t-><T>IChunk::shrink_low();
+  if (t-><T>IChunk::empty() && !one_chunk())
+  {
+    hd = t->next();
+    del_chunk(t);
+    t = hd;
+    ++lch;
+  }
+  set_cache(t);
+  return ++lo;
+}
+
+void <T>RPlex::append(const <T>RPlex& a)
+{
+  for (int i = a.low(); i < a.fence(); a.next(i)) add_high(a[i]);
+}
+
+void <T>RPlex::prepend (const <T>RPlex& a)
+{
+  for (int i = a.high(); i > a.ecnef(); a.prev(i)) add_low(a[i]);
+}
+
+void <T>RPlex::reverse()
+{
+  <T> tmp;
+  int l = lo;
+  int h = fnc - 1;
+  <T>IChunk* loch = hd;
+  <T>IChunk* hich = tl();
+  while (l < h)
+  {
+    <T>* lptr = loch->pointer_to(l);
+    <T>* hptr = hich->pointer_to(h);
+    tmp = *lptr;
+    *lptr = *hptr;
+    *hptr = tmp;
+    if (++l >= loch->fence_index()) loch = loch->next();
+    if (--h < hich->low_index()) hich = hich->prev();
+  }
+}
+
+void <T>RPlex::fill(const <T&> x)
+{
+  for (int i = lo; i < fnc; ++i) (*this)[i] = x;
+}
+
+void <T>RPlex::fill(const <T&> x, int lo, int hi)
+{
+  for (int i = lo; i <= hi; ++i) (*this)[i] = x;
+}
+
+
+void <T>RPlex::clear()
+{
+  for (int i = lch + 1; i < fch; ++i)
+    del_chunk(chunks[i]);
+  fch = lch + 1;
+  set_cache(chunks[lch]);
+  ch-><T>IChunk::clear(lo);
+  fnc = lo;
+}
+
+int <T>RPlex::reset_low(int l)
+{
+  int old = lo;
+  int diff = l - lo;
+  if (diff != 0)
+  {
+    lo += diff;
+    fnc += diff;
+    <T>IChunk* t = hd;
+    do
+    {
+      t->re_index(t->low_index() + diff);
+      t = t->next();
+    } while (t != hd);
+  }
+  base = hd->base_index() - lch * csize;
+  return old;
+}
+
+
+int <T>RPlex::OK () const
+{
+  int v = hd != 0 && ch != 0;         // at least one chunk
+
+  v &= fnc == tl()->fence_index();  // last chunk fnc == plex fnc
+  v &= lo == hd-><T>IChunk::low_index();    // first lo == plex lo
+
+  v &= base == hd->base_index() - lch * csize; // base is correct;
+  v &= lch < fch;
+  v &= fch <= maxch;                  // within allocation;
+
+// loop for others:
+
+  int k = lch;                        // to cross-check nch
+
+  int found_ch = 0;                   // to make sure ch is in list;
+  const <T>IChunk* t = (hd);
+  for (;;)
+  {
+    v &= chunks[k++] == t;             // each chunk is at proper index
+    if (t == ch) ++found_ch;
+    v &= t-><T>IChunk::OK();              // each chunk is OK
+    if (t == tl())
+      break;
+    else                              // and has indices contiguous to succ
+    {
+      v &= t->top_index() == t->next()->base_index();
+      if (t != hd)                  // internal chunks full
+      {
+        v &= !t->empty();
+        v &= !t->can_grow_low();
+        v &= !t->can_grow_high();
+      }
+      t = t->next();
+    }
+  }
+  v &= found_ch == 1;
+  v &= fch == k;
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/RPlex.hP b/usr/include/g++/gen/RPlex.hP
new file mode 100644 (file)
index 0000000..7a21f5b
--- /dev/null
@@ -0,0 +1,268 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _<T>RPlex_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>RPlex_h 1
+
+#include "<T>.Plex.h"
+
+// minimum number of chunks to index
+
+#ifndef MIN_NCHUNKS
+#define MIN_NCHUNKS  16
+#endif
+
+class <T>RPlex: public <T>Plex
+{
+  int              base;        // base index of lowest chunk
+  int              lch;         // index of lowest used chunk
+  int              fch;         // 1 + index of highest used chunk
+  int              maxch;       // max chunks in array
+  <T>IChunk**      chunks;      // array of chunks
+  <T>IChunk*       ch;          // cached chunk
+
+  void             make_initial_chunks(int up = 1);
+
+  void             cache(int idx) const;
+  void             cache(const <T>* p) const;
+  <T>*             dopred(const <T>* p) const;
+  <T>*             dosucc(const <T>* p) const;
+
+  void             set_cache(const <T>IChunk* t) const; // logically, 
+                                               // not physically const
+
+public:
+                   <T>RPlex();                 // set low = 0;
+                                               // fence = 0;
+                                               // csize = default
+
+                   <T>RPlex(int ch_size);      // low = 0; 
+                                               // fence = 0;
+                                               // csize = ch_size
+
+                   <T>RPlex(int lo,            // low = lo; 
+                            int ch_size);      // fence=lo
+                                               // csize = ch_size
+
+                   <T>RPlex(int lo,            // low = lo
+                            int hi,            // fence = hi+1
+                            const <T&> initval,// fill with initval,
+                            int ch_size = 0);  // csize= ch_size
+                                               // or fence-lo if 0
+
+                   <T>RPlex(const <T>RPlex&);
+
+                   ~<T>RPlex();
+
+  void             operator= (const <T>RPlex&);
+
+// virtuals
+
+  <T>&             high_element ();
+  <T>&             low_element ();
+
+  const <T>&       high_element () const;
+  const <T>&       low_element () const;
+
+  Pix              first() const;
+  Pix              last() const;
+  void             prev(Pix& ptr) const;
+  void             next(Pix& ptr) const;
+  int              owns(Pix p) const;
+  <T>&             operator () (Pix p);
+  const <T>&       operator () (Pix p) const;
+
+  int              low() const; 
+  int              high() const;
+  int              valid(int idx) const;
+  void             prev(int& idx) const;
+  void             next(int& x) const;
+  <T>&             operator [] (int index);
+  const <T>&       operator [] (int index) const;
+    
+  int              Pix_to_index(Pix p) const;
+  Pix              index_to_Pix(int idx) const;    
+
+  int              can_add_high() const;
+  int              can_add_low() const;
+  int              full() const;
+
+  int              add_high(const <T&> elem);
+  int              del_high ();
+  int              add_low (const <T&> elem);
+  int              del_low ();
+
+  void             fill(const <T&> x);
+  void             fill(const <T&> x, int from, int to);
+  void             clear();
+  void             reverse();
+  void             append(const <T>RPlex& a); 
+  void             prepend(const <T>RPlex& a);
+
+  int              reset_low(int newlow);
+    
+  int              OK () const; 
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline void <T>RPlex::prev(int& idx) const
+{
+  --idx;
+}
+
+inline void <T>RPlex::next(int& idx) const 
+{
+  ++idx;
+}
+
+inline  int <T>RPlex::full ()  const
+{
+  return 0;
+}
+
+inline int <T>RPlex::can_add_high() const
+{
+  return 1;
+}
+
+inline int <T>RPlex::can_add_low() const
+{
+  return 1;
+}
+
+inline  int <T>RPlex::valid (int idx) const
+{
+  return idx >= lo && idx < fnc;
+}
+
+inline int <T>RPlex::low() const
+{
+  return lo;
+}
+
+inline int <T>RPlex::high() const
+{
+  return fnc - 1;
+}
+
+inline void <T>RPlex::set_cache(const <T>IChunk* t) const
+{
+  ((<T>RPlex*)(this))->ch = (<T>IChunk*)t;
+}
+
+inline void <T>RPlex::cache(int idx) const
+{
+  if (idx < lo || idx >= fnc) index_error();
+  set_cache(chunks[(idx - base) / csize]);
+}  
+
+inline  <T>& <T>RPlex::low_element () 
+{
+  cache(lo); return *(ch->pointer_to(lo));
+}
+
+inline  <T>& <T>RPlex::high_element ()
+{
+  cache(fnc-1); return *(ch->pointer_to(fnc - 1));
+}
+
+inline const <T>& <T>RPlex::low_element () const
+{
+  cache(lo); return *((const <T>*)(ch->pointer_to(lo)));
+}
+
+inline const <T>& <T>RPlex::high_element () const
+{
+  cache(fnc-1); return *((const <T>*)(ch->pointer_to(fnc - 1)));
+}
+
+inline  int <T>RPlex::Pix_to_index(Pix px) const
+{
+  <T>* p = (<T>*)px;
+  if (!ch->actual_pointer(p)) cache(p);
+  return ch->index_of(p);
+}
+
+inline  Pix <T>RPlex::index_to_Pix(int idx) const
+{
+  if (!ch->actual_index(idx)) cache(idx);
+  return (Pix)(ch->pointer_to(idx));
+}
+
+inline Pix <T>RPlex::first() const
+{
+  return Pix(hd-><T>IChunk::first_pointer());
+}
+
+inline Pix <T>RPlex::last() const
+{
+  return Pix(tl()-><T>IChunk::last_pointer());
+}
+
+inline void <T>RPlex::prev(Pix& p) const
+{
+  Pix q = Pix(ch-><T>IChunk::pred((<T>*)p));
+  p = (q == 0)? Pix(dopred((<T>*)p)) : q;
+}
+
+inline void <T>RPlex::next(Pix& p) const
+{
+  Pix q = Pix(ch-><T>IChunk::succ((<T>*)p));
+  p = (q == 0)? Pix(dosucc((<T>*)p)) : q;
+}
+
+inline <T>& <T>RPlex:: operator () (Pix p)
+{
+  return *((<T>*)p);
+}
+
+
+inline <T>& <T>RPlex:: operator [] (int idx)
+{
+  cache(idx); return *(ch->pointer_to(idx));
+}
+
+inline const <T>& <T>RPlex:: operator () (Pix p) const
+{
+  return *((const <T>*)p);
+}
+
+inline const <T>& <T>RPlex:: operator [] (int idx) const
+{
+  cache(idx); return *((const <T>*)(ch->pointer_to(idx)));
+}
+
+inline <T>RPlex::~<T>RPlex()
+{
+  delete chunks;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/SLBag.ccP b/usr/include/g++/gen/SLBag.ccP
new file mode 100644 (file)
index 0000000..172a652
--- /dev/null
@@ -0,0 +1,110 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.SLBag.h"
+
+int <T>SLBag::OK()
+{
+  int v = p.OK();
+  v &= count == p.length();
+  if (!v) error("invariant failure");
+  return v;
+}
+
+Pix <T>SLBag::seek(<T&> item, Pix i)
+{
+  if (i == 0) i = first(); else next(i);
+  for (; i != 0 && (!(<T>EQ(p(i), item))); p.next(i));
+  return i;
+}
+
+int <T>SLBag::nof(<T&> item)
+{
+  int n = 0;
+  for (Pix p = first(); p; next(p)) if (<T>EQ((*this)(p), item)) ++n;
+  return n;
+}
+
+
+void <T>SLBag::del(<T&> item)
+{
+  Pix i = p.first();
+  if (i == 0) 
+    return;
+  else if (<T>EQ(p(i), item))
+  {
+    --count;
+    p.del_front();
+  }
+  else
+  {
+    Pix trail = i;
+    p.next(i);
+    while (i != 0)
+    {
+      if (<T>EQ(p(i), item))
+      {
+        --count;
+        p.del_after(trail);
+        return;
+      }
+      trail = i;
+      p.next(i);
+    }
+  }
+}    
+
+void <T>SLBag::remove(<T&> item)
+{
+  Pix i = p.first();
+  while (i != 0 && <T>EQ(p(i), item))
+  {
+    --count;
+    p.del_front();
+    i = p.first();
+  }
+  if (i != 0)
+  {
+    Pix trail = i;
+    p.next(i);
+    while (i != 0)
+    {
+      if (<T>EQ(p(i), item))
+      {
+        --count;
+        p.del_after(trail);
+        i = trail;
+        p.next(i);
+      }
+      else
+      {
+        trail = i;
+        p.next(i);
+      }
+    }
+  }
+}    
+
diff --git a/usr/include/g++/gen/SLBag.hP b/usr/include/g++/gen/SLBag.hP
new file mode 100644 (file)
index 0000000..d039241
--- /dev/null
@@ -0,0 +1,104 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>SLBag_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>SLBag_h 1
+
+#include "<T>.Bag.h"
+#include "<T>.SLList.h"
+
+class <T>SLBag : public <T>Bag
+{
+protected:
+  <T>SLList     p;
+
+public:
+                <T>SLBag();
+                <T>SLBag(const <T>SLBag&);
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  void          remove(<T&>item);
+  int           contains(<T&> item);
+  int           nof(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  int           owns(Pix i);
+  Pix           seek(<T&> item, Pix from = 0);
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>SLBag::<T>SLBag() : p() { count = 0; }
+
+inline <T>SLBag::<T>SLBag(const <T>SLBag& s) : p(s.p) { count = s.count; }
+
+inline Pix <T>SLBag::first()
+{
+  return p.first();
+}
+
+inline void <T>SLBag::next(Pix  & idx)
+{
+  p.next(idx);
+}
+
+inline <T>& <T>SLBag::operator ()(Pix   idx)
+{
+  return p(idx);
+}
+
+inline void <T>SLBag::clear()
+{
+  count = 0;  p.clear();
+}
+
+inline int <T>SLBag::owns (Pix   idx)
+{
+  return p.owns(idx);
+}
+
+inline Pix <T>SLBag::add(<T&> item)
+{
+  ++count;
+  return p.append(item);
+}
+
+inline int <T>SLBag::contains(<T&> item)
+{
+  return seek(item) != 0;
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/SLList.ccP b/usr/include/g++/gen/SLList.ccP
new file mode 100644 (file)
index 0000000..57920c3
--- /dev/null
@@ -0,0 +1,296 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <values.h>
+#include <stream.h>
+#include "<T>.SLList.h"
+
+
+void <T>SLList::error(const char* msg)
+{
+  (*lib_error_handler)("SLList", msg);
+}
+
+int <T>SLList::length()
+{
+  int l = 0;
+  <T>SLListNode* t = last;
+  if (t != 0) do { ++l; t = t->tl; } while (t != last);
+  return l;
+}
+
+<T>SLList::<T>SLList(<T>SLList& a)
+{
+  if (a.last == 0)
+    last = 0;
+  else
+  {
+    <T>SLListNode* p = a.last->tl;
+    <T>SLListNode* h = new <T>SLListNode(p->hd);
+    last = h;
+    for (;;)
+    {
+      if (p == a.last)
+      {
+        last->tl = h;
+        return;
+      }
+      p = p->tl;
+      <T>SLListNode* n = new <T>SLListNode(p->hd);
+      last->tl = n;
+      last = n;
+    }
+  }
+}
+
+<T>SLList& <T>SLList::operator = (<T>SLList& a)
+{
+  if (last != a.last)
+  {
+    clear();
+    if (a.last != 0)
+    {
+      <T>SLListNode* p = a.last->tl;
+      <T>SLListNode* h = new <T>SLListNode(p->hd);
+      last = h;
+      for (;;)
+      {
+        if (p == a.last)
+        {
+          last->tl = h;
+          break;
+        }
+        p = p->tl;
+        <T>SLListNode* n = new <T>SLListNode(p->hd);
+        last->tl = n;
+        last = n;
+      }
+    }
+  }
+  return *this;
+}
+
+void <T>SLList::clear()
+{
+  if (last == 0)
+    return;
+
+  <T>SLListNode* p = last->tl;
+  last->tl = 0;
+  last = 0;
+
+  while (p != 0)
+  {
+    <T>SLListNode* nxt = p->tl;
+    delete(p);
+    p = nxt;
+  }
+}
+
+
+Pix <T>SLList::prepend(<T&> item)
+{
+  <T>SLListNode* t = new <T>SLListNode(item);
+  if (last == 0)
+    t->tl = last = t;
+  else
+  {
+    t->tl = last->tl;
+    last->tl = t;
+  }
+  return Pix(t);
+}
+
+
+Pix <T>SLList::prepend(<T>SLListNode* t)
+{
+  if (t == 0) return 0;
+  if (last == 0)
+    t->tl = last = t;
+  else
+  {
+    t->tl = last->tl;
+    last->tl = t;
+  }
+  return Pix(t);
+}
+
+
+Pix <T>SLList::append(<T&> item)
+{
+  <T>SLListNode* t = new <T>SLListNode(item);
+  if (last == 0)
+    t->tl = last = t;
+  else
+  {
+    t->tl = last->tl;
+    last->tl = t;
+    last = t;
+  }
+  return Pix(t);
+}
+
+Pix <T>SLList::append(<T>SLListNode* t)
+{
+  if (t == 0) return 0;
+  if (last == 0)
+    t->tl = last = t;
+  else
+  {
+    t->tl = last->tl;
+    last->tl = t;
+    last = t;
+  }
+  return Pix(t);
+}
+
+void <T>SLList::join(<T>SLList& b)
+{
+  <T>SLListNode* t = b.last;
+  b.last = 0;
+  if (last == 0)
+    last = t;
+  else if (t != 0)
+  {
+    <T>SLListNode* f = last->tl;
+    last->tl = t->tl;
+    t->tl = f;
+    last = t;
+  }
+}
+
+Pix <T>SLList::ins_after(Pix p, <T&> item)
+{
+  <T>SLListNode* u = (<T>SLListNode*)p;
+  <T>SLListNode* t = new <T>SLListNode(item);
+  if (last == 0)
+    t->tl = last = t;
+  else if (u == 0) // ins_after 0 means prepend
+  {
+    t->tl = last->tl;
+    last->tl = t;
+  }
+  else
+  {
+    t->tl = u->tl;
+    u->tl = t;
+    if (u == last) 
+      last = t;
+  }
+  return Pix(t);
+}
+
+
+void <T>SLList::del_after(Pix p)
+{
+  <T>SLListNode* u = (<T>SLListNode*)p;
+  if (last == 0 || u == last) error("cannot del_after last");
+  if (u == 0) u = last; // del_after 0 means delete first
+  <T>SLListNode* t = u->tl;
+  if (u == t)
+    last = 0;
+  else
+  {
+    u->tl = t->tl;
+    if (last == t)
+      last = u;
+  }
+  delete t;
+}
+
+int <T>SLList::owns(Pix p)
+{
+  <T>SLListNode* t = last;
+  if (t != 0 && p != 0)
+  {
+    do
+    {
+      if (Pix(t) == p) return 1;
+      t = t->tl;
+    } while (t != last);
+  }
+  return 0;
+}
+
+<T> <T>SLList::remove_front()
+{
+  if (last == 0) error("remove_front of empty list");
+  <T>SLListNode* t = last->tl;
+  <T> res = t->hd;
+  if (t == last)
+    last = 0;
+  else
+    last->tl = t->tl;
+  delete t;
+  return res;
+}
+
+int <T>SLList::remove_front(<T>& x)
+{
+  if (last == 0)
+    return 0;
+  else
+  {
+    <T>SLListNode* t = last->tl;
+    x = t->hd;
+    if (t == last)
+      last = 0;
+    else
+      last->tl = t->tl;
+    delete t;
+    return 1;
+  }
+}
+
+
+void <T>SLList::del_front()
+{
+  if (last == 0) error("del_front of empty list");
+  <T>SLListNode* t = last->tl;
+  if (t == last)
+    last = 0;
+  else
+    last->tl = t->tl;
+  delete t;
+}
+
+int <T>SLList::OK()
+{
+  int v = 1;
+  if (last != 0)
+  {
+    <T>SLListNode* t = last;
+    long count = MAXLONG;      // Lots of chances to find last!
+    do
+    {
+      count--;
+      t = t->tl;
+    } while (count > 0 && t != last);
+    v &= count > 0;
+  }
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/SLList.hP b/usr/include/g++/gen/SLList.hP
new file mode 100644 (file)
index 0000000..1886b68
--- /dev/null
@@ -0,0 +1,152 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>SLList_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>SLList_h 1
+
+#include <Pix.h>
+#include "<T>.defs.h"
+
+#ifndef _<T>SLListNode_h
+#define _<T>SLListNode_h 1
+
+struct <T>SLListNode
+{
+  <T>SLListNode*         tl;
+  <T>                    hd;
+                         <T>SLListNode();
+                         <T>SLListNode(<T&> h, <T>SLListNode* t = 0);
+                         ~<T>SLListNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>SLListNode::<T>SLListNode() {}
+
+inline <T>SLListNode::<T>SLListNode(<T&> h, <T>SLListNode* t) :hd(h), tl(t) {}
+
+inline <T>SLListNode::~<T>SLListNode() {}
+
+#endif
+
+typedef <T>SLListNode* <T>SLListNodePtr;
+
+#endif
+
+
+class <T>SLList
+{
+protected:
+  <T>SLListNode*        last;
+
+public:
+                        <T>SLList();
+                        <T>SLList(<T>SLList& a);
+                        ~<T>SLList();
+
+  <T>SLList&            operator = (<T>SLList& a);
+
+  int                   empty();
+  int                   length();
+
+  void                  clear();
+
+  Pix                   prepend(<T&> item);
+  Pix                   append(<T&> item);
+
+  void                  join(<T>SLList&);
+
+  Pix                   prepend(<T>SLListNode*);
+  Pix                   append(<T>SLListNode*);
+
+  <T>&                  operator () (Pix p);
+  Pix                   first();
+  void                  next(Pix& p);
+  int                   owns(Pix p);
+  Pix                   ins_after(Pix p, <T&> item);
+  void                  del_after(Pix p);
+
+  <T>&                  front();
+  <T>&                  rear();
+  <T>                   remove_front();
+  int                   remove_front(<T>& x);
+  void                  del_front();
+
+  void                  error(const char* msg);
+  int                   OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>SLList::~<T>SLList()
+{
+  clear();
+}
+
+inline <T>SLList::<T>SLList()
+{
+  last = 0;
+}
+
+inline int <T>SLList::empty()
+{
+  return last == 0;
+}
+
+
+inline Pix <T>SLList::first()
+{
+  return (last == 0)? 0 : Pix(last->tl);
+}
+
+inline void <T>SLList::next(Pix& p)
+{
+  p = (p == 0 || p == last)? 0 : Pix(((<T>SLListNode*)(p))->tl);
+}
+
+inline <T>& <T>SLList::operator () (Pix p)
+{
+  if (p == 0) error("null Pix");
+  return ((<T>SLListNode*)(p))->hd;
+}
+
+inline <T>& <T>SLList::front()
+{
+  if (last == 0) error("front: empty list");
+  return last->tl->hd;
+}
+
+inline <T>& <T>SLList::rear()
+{
+  if (last == 0) error("rear: empty list");
+  return last->hd;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/SLQueue.ccP b/usr/include/g++/gen/SLQueue.ccP
new file mode 100644 (file)
index 0000000..8a5935b
--- /dev/null
@@ -0,0 +1,4 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.SLQueue.h"
diff --git a/usr/include/g++/gen/SLQueue.hP b/usr/include/g++/gen/SLQueue.hP
new file mode 100644 (file)
index 0000000..5e75031
--- /dev/null
@@ -0,0 +1,118 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _<T>SLQueue_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>SLQueue_h
+
+#include "<T>.SLList.h"
+#include "<T>.Queue.h"
+
+class <T>SLQueue : public <T>Queue
+{
+  <T>SLList    p;
+
+public:
+               <T>SLQueue();
+               <T>SLQueue(const <T>SLQueue& q);
+               ~<T>SLQueue();
+
+  void          operator = (const <T>SLQueue&);
+
+  void          enq(<T&> item);
+  <T>           deq();
+  <T>&          front();
+  void          del_front();
+
+  void          clear();
+  int           empty();
+  int           full();
+  int           length();
+               
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>SLQueue::<T>SLQueue() :p() {}
+inline <T>SLQueue::<T>SLQueue(const <T>SLQueue& q) : p(q.p) {}
+
+inline <T>SLQueue::~<T>SLQueue() {}
+
+inline void <T>SLQueue::enq(<T&>item)
+{
+  p.append(item);
+}
+
+inline <T> <T>SLQueue::deq()
+{
+  return p.remove_front();
+}
+
+inline <T>& <T>SLQueue::front()
+{
+  return p.front();
+}
+
+
+inline void <T>SLQueue::del_front()
+{
+  p.del_front();
+}
+
+inline void <T>SLQueue::operator =(const <T>SLQueue& s)
+{
+  p = s.p;
+}
+
+inline int <T>SLQueue::empty()
+{
+  return p.empty();
+}
+
+inline int <T>SLQueue::full()
+{
+  return 0;
+}
+
+inline int <T>SLQueue::length()
+{
+  return p.length();
+}
+
+inline int <T>SLQueue::OK()
+{
+  return p.OK();
+}
+
+inline void <T>SLQueue::clear()
+{
+  p.clear();
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/SLSet.ccP b/usr/include/g++/gen/SLSet.ccP
new file mode 100644 (file)
index 0000000..5854b2b
--- /dev/null
@@ -0,0 +1,81 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.SLSet.h"
+
+int <T>SLSet::OK()
+{
+  int v = p.OK();
+  v &= count == p.length();
+  if (!v) error("invariant failure");
+  return v;
+}
+
+Pix <T>SLSet::seek(<T&> item)
+{
+  for (Pix i = p.first(); i != 0 && !<T>EQ(p(i),item); p.next(i));
+  return i;
+}
+
+Pix <T>SLSet::add(<T&> item)
+{
+  Pix i = seek(item);
+  if (i == 0)
+  {
+    ++count;
+    i = p.append(item);
+  }
+  return i;
+}
+
+void <T>SLSet::del(<T&> item)
+{
+  Pix i = p.first();
+  if (i == 0)
+    return;
+  else if (<T>EQ(p(i), item))
+  {
+    --count;
+    p.del_front();
+  }
+  else
+  {
+    Pix trail = i;
+    p.next(i);
+    while (i != 0)
+    {
+      if (<T>EQ(p(i), item))
+      {
+        --count;
+        p.del_after(trail);
+        return;
+      }
+      trail = i;
+      p.next(i);
+    }
+  }
+}    
+
diff --git a/usr/include/g++/gen/SLSet.hP b/usr/include/g++/gen/SLSet.hP
new file mode 100644 (file)
index 0000000..bc11a74
--- /dev/null
@@ -0,0 +1,97 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>SLSet_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>SLSet_h 1
+
+#include "<T>.Set.h"
+#include "<T>.SLList.h"
+
+class <T>SLSet : public <T>Set
+{
+protected:
+  <T>SLList     p;
+
+public:
+                <T>SLSet();
+                <T>SLSet(const <T>SLSet&);
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  int           owns(Pix i);
+  Pix           seek(<T&> item);
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>SLSet::<T>SLSet() : p() { count = 0; }
+
+inline <T>SLSet::<T>SLSet(const <T>SLSet& s) : p(s.p) { count = s.count; }
+
+inline Pix <T>SLSet::first()
+{
+  return p.first();
+}
+
+inline void <T>SLSet::next(Pix  & idx)
+{
+  p.next(idx);
+}
+
+inline <T>& <T>SLSet::operator ()(Pix   idx)
+{
+  return p(idx);
+}
+
+inline void <T>SLSet::clear()
+{
+  count = 0;  p.clear();
+}
+
+inline int <T>SLSet::contains (<T&> item)
+{
+  return seek(item) != 0;
+}
+
+inline int <T>SLSet::owns (Pix   idx)
+{
+  return p.owns(idx);
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/SLStack.ccP b/usr/include/g++/gen/SLStack.ccP
new file mode 100644 (file)
index 0000000..3996b41
--- /dev/null
@@ -0,0 +1,4 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.SLStack.h"
diff --git a/usr/include/g++/gen/SLStack.hP b/usr/include/g++/gen/SLStack.hP
new file mode 100644 (file)
index 0000000..dced467
--- /dev/null
@@ -0,0 +1,119 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>SLStack_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>SLStack_h 1
+
+#include "<T>.SLList.h"
+#include "<T>.Stack.h"
+
+class <T>SLStack : public <T>Stack
+{
+  <T>SLList     p;
+
+public:
+                <T>SLStack();
+                <T>SLStack(const <T>SLStack& s);
+                ~<T>SLStack();
+
+  void          operator = (const <T>SLStack&);
+
+  void          push(<T&> item);
+  <T>           pop();
+  <T>&          top();               
+  void          del_top();
+
+  int           empty();
+  int           full();
+  int           length();
+
+  void          clear();
+
+  int           OK();
+
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>SLStack::<T>SLStack() :p() {}
+inline <T>SLStack::<T>SLStack(const <T>SLStack& a) : p(a.p) {}
+inline <T>SLStack::~<T>SLStack() {}
+
+inline void <T>SLStack::push(<T&> item)
+{
+  p.prepend(item);
+}
+
+inline <T> <T>SLStack::pop()
+{
+  return p.remove_front();
+}
+
+inline <T>& <T>SLStack::top()
+{
+  return p.front();
+}
+
+inline void <T>SLStack::del_top()
+{
+  p.del_front();
+}
+
+inline void <T>SLStack::operator =(const <T>SLStack& s)
+{
+  p = s.p;
+}
+
+inline int <T>SLStack::empty() 
+{
+  return p.empty();
+}
+
+inline int <T>SLStack::full() 
+{
+  return 0;
+}
+
+inline int <T>SLStack::length() 
+{
+  return p.length();
+}
+
+inline int <T>SLStack::OK() 
+{
+  return p.OK();
+}
+
+inline void <T>SLStack::clear() 
+{
+  p.clear();
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/Set.ccP b/usr/include/g++/gen/Set.ccP
new file mode 100644 (file)
index 0000000..c472602
--- /dev/null
@@ -0,0 +1,121 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <builtin.h>
+#include "<T>.Set.h"
+
+
+Pix <T>Set::seek(<T&> item)
+{
+  for (Pix i = first(); i != 0 && !(<T>EQ((*this)(i), item)); next(i));
+  return i;
+}
+
+int <T>Set::owns(Pix idx)
+{
+  if (idx == 0) return 0;
+  for (Pix i = first(); i; next(i)) if (i == idx) return 1;
+  return 0;
+}
+
+void <T>Set::clear()
+{
+  Pix i = first(); 
+  while (i != 0)
+  {
+    del((*this)(i));
+    i = first();
+  }
+}
+
+int <T>Set::contains (<T&> item)
+{
+  return seek(item) != 0;
+}
+
+int <T>Set::operator <= (<T>Set& b)
+{
+  if (count > b.count) return 0;
+  if (count == 0) return 1;
+  for (Pix i = first(); i; next(i)) if (b.seek((*this)(i)) == 0) return 0;
+  return 1;
+}
+
+int <T>Set::operator == (<T>Set& b)
+{
+  int n = count;
+  if (n != b.count) return 0;
+  if (n == 0) return 1;
+  Pix i = first();
+  Pix j = b.first();
+  while (n-- > 0)
+  {
+    if ((b.seek((*this)(i)) == 0) || (seek(b(j)) == 0)) return 0;
+    next(i);
+    b.next(j);
+  }
+  return 1;
+}
+
+int <T>Set::operator != (<T>Set& b)
+{
+  return !(*this == b);
+}
+
+void <T>Set::operator |= (<T>Set& b)
+{
+  if (&b != this)
+    for (Pix i = b.first(); i; b.next(i)) add(b(i));
+}
+
+void <T>Set::operator -= (<T>Set& b)
+{
+  if (&b == this)
+    clear();
+  else
+    for (Pix i = b.first(); i; b.next(i)) del(b(i));
+}
+
+
+void <T>Set::operator &= (<T>Set& b)
+{
+  if (&b != this)
+  {
+    Pix i = first();
+    Pix n = i;
+    while (i != 0)
+    {
+      next(n);
+      if (b.seek((*this)(i)) == 0) del((*this)(i));
+      i = n;
+    }
+  }
+}
+
+void <T>Set::error(const char* msg)
+{
+  (*lib_error_handler)("Set", msg);
+}
diff --git a/usr/include/g++/gen/Set.hP b/usr/include/g++/gen/Set.hP
new file mode 100644 (file)
index 0000000..b2c08ce
--- /dev/null
@@ -0,0 +1,88 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>Set_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>Set_h 1
+
+#include <Pix.h>
+#include "<T>.defs.h"
+
+class <T>Set
+{
+protected:
+
+  int                   count;
+
+public:
+  virtual              ~<T>Set();
+
+  int                   length();                // current number of items
+  int                   empty();
+
+  virtual Pix           add(<T&> item) = 0;      // add item; return Pix
+  virtual void          del(<T&> item) = 0;      // delete item
+  virtual int           contains(<T&> item);     // is item in set?
+
+  virtual void          clear();                 // delete all items
+
+  virtual Pix           first() = 0;             // Pix of first item or 0
+  virtual void          next(Pix& i) = 0;        // advance to next or 0
+  virtual <T>&          operator () (Pix i) = 0; // access item at i
+
+  virtual int           owns(Pix i);             // is i a valid Pix  ?
+  virtual Pix           seek(<T&> item);         // Pix of item
+
+  void                  operator |= (<T>Set& b); // add all items in b
+  void                  operator -= (<T>Set& b); // delete items also in b
+  void                  operator &= (<T>Set& b); // delete items not in b
+
+  int                   operator == (<T>Set& b);
+  int                   operator != (<T>Set& b);
+  int                   operator <= (<T>Set& b); 
+
+  void                  error(const char* msg);
+  virtual int           OK() = 0;                // rep invariant
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>Set::~<T>Set() {}
+
+inline int <T>Set::length()
+{
+  return count;
+}
+
+inline int <T>Set::empty()
+{
+  return count == 0;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/SplayBag.ccP b/usr/include/g++/gen/SplayBag.ccP
new file mode 100644 (file)
index 0000000..1e16a7e
--- /dev/null
@@ -0,0 +1,451 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include <assert.h>
+#include "<T>.SplayBag.h"
+
+
+/* 
+
+ struct to simulate the special `null' node in the Sleater & Tarjan JACM 1985
+ splay tree algorithms
+
+ All routines use a version of their `simple top-down' splay alg. (p 669)
+
+*/
+
+struct _dummySplayNode
+{
+  <T>SplayNode*    lt;
+  <T>SplayNode*    rt;
+  <T>SplayNode*    par;
+} _dummy_null;
+
+
+/*
+ traversal primitives
+*/
+
+
+<T>SplayNode* <T>SplayBag::leftmost()
+{
+  <T>SplayNode* t = root;
+  if (t != 0) while (t->lt != 0) t = t->lt;
+  return t;
+}
+
+<T>SplayNode* <T>SplayBag::rightmost()
+{
+  <T>SplayNode* t = root;
+  if (t != 0) while (t->rt != 0) t = t->rt;
+  return t;
+}
+
+<T>SplayNode* <T>SplayBag::succ(<T>SplayNode* t)
+{
+  if (t == 0)
+    return 0;
+  if (t->rt != 0)
+  {
+    t = t->rt;
+    while (t->lt != 0) t = t->lt;
+    return t;
+  }
+  else
+  {
+    for (;;)
+    {
+      if (t->par == 0 || t == t->par->lt)
+        return t->par;
+      else
+        t = t->par;
+    }
+  }
+}
+
+<T>SplayNode* <T>SplayBag::pred(<T>SplayNode* t)
+{
+  if (t == 0)
+    return 0;
+  else if (t->lt != 0)
+  {
+    t = t->lt;
+    while (t->rt != 0) t = t->rt;
+    return t;
+  }
+  else
+  {
+    for (;;)
+    {
+      if (t->par == 0 || t == t->par->rt)
+        return t->par;
+      else
+        t = t->par;
+    }
+  }
+}
+
+
+
+Pix <T>SplayBag::seek(<T&> key, Pix i)
+{
+  if (root == 0) return 0;
+
+  <T>SplayNode* t = (<T>SplayNode*) i;
+  if (t != 0)
+  {
+    int cmp = <T>CMP(key, t->item);
+    if (cmp == 0)
+    {
+      t = succ(t);
+      if (t != 0 && <T>EQ(key, t->item))
+        return Pix(t);
+      else
+        return 0;
+    }
+    else if (cmp < 0)
+      return 0;
+  }
+
+  t = root;
+  int comp = <T>CMP(key, t->item);
+  if (comp == 0)
+    return Pix(t);
+
+  <T>SplayNode* dummy = (<T>SplayNode*)(&_dummy_null);
+  <T>SplayNode* l = dummy;
+  <T>SplayNode* r = dummy;
+  dummy->rt = dummy->lt = dummy->par = 0;
+
+  while (comp != 0)
+  {
+    if (comp > 0)
+    {
+      <T>SplayNode* tr = t->rt;
+      if (tr == 0)
+        break;
+      else
+      {
+        comp = <T>CMP(key, tr->item);
+        if (comp <= 0 || tr->rt == 0)
+        {
+          l->rt = t; t->par = l;
+          l = t;
+          t = tr;
+          if (comp >= 0)
+            break;
+        }
+        else
+        {
+          if ((t->rt = tr->lt) != 0) t->rt->par = t;
+          tr->lt = t; t->par = tr;
+          l->rt = tr; tr->par = l;
+          l = tr;
+          t = tr->rt;
+          comp = <T>CMP(key, t->item);
+        }
+      }
+    }
+    else
+    {
+      <T>SplayNode* tl = t->lt;
+      if (tl == 0)
+        break;
+      else
+      {
+        comp = <T>CMP(key, tl->item);
+        if (comp >= 0 || tl->lt == 0)
+        {
+          r->lt = t; t->par = r;
+          r = t;
+          t = tl;
+          if (comp <= 0)
+            break;
+        }
+        else
+        {
+          if ((t->lt = tl->rt) != 0) t->lt->par = t;
+          tl->rt = t; t->par = tl;
+          r->lt = tl; tl->par = r;
+          r = tl;
+          t = tl->lt;
+          comp = <T>CMP(key, t->item);
+        }
+      }
+    }
+  }
+  if ((r->lt = t->rt) != 0) r->lt->par = r;
+  if ((l->rt = t->lt) != 0) l->rt->par = l;
+  if ((t->lt = dummy->rt) != 0) t->lt->par = t;
+  if ((t->rt = dummy->lt) != 0) t->rt->par = t;
+  t->par = 0;
+  root = t;
+  if (comp != 0)
+    return 0;
+  else
+  {
+    l = pred(t);
+    while (l != 0 && <T>EQ(l->item, key)) { t = l; l = pred(l); }
+    return Pix(t);
+  }
+}
+
+int <T>SplayBag::nof(<T&> item)
+{
+  int n = 0;
+  <T>SplayNode* t = (<T>SplayNode*)(seek(item));
+  if (t != 0)
+  {
+    do
+    {
+      ++n;
+      t = succ(t);
+    } while (t != 0 && <T>EQ(item, t->item));
+  }
+  return n;
+}
+
+Pix <T>SplayBag::add(<T&> item)
+{
+  ++count;
+  <T>SplayNode* newnode = new <T>SplayNode(item);
+  <T>SplayNode* t = root;
+  if (t == 0)
+  {
+    root = newnode;
+    return Pix(root);
+  }
+
+  int comp = <T>CMP(item, t->item);
+
+  <T>SplayNode* dummy = (<T>SplayNode*)(&_dummy_null);
+  <T>SplayNode* l = dummy;
+  <T>SplayNode* r = dummy;
+  dummy->rt = dummy->lt = dummy->par = 0;
+  
+  int done = 0;
+  while (!done)
+  {
+    if (comp >= 0)
+    {
+      <T>SplayNode* tr = t->rt;
+      if (tr == 0)
+      {
+        tr = newnode;
+        comp = 0; done = 1;
+      }
+      else
+        comp = <T>CMP(item, tr->item);
+        
+      if (comp <= 0)
+      {
+        l->rt = t; t->par = l;
+        l = t;
+        t = tr;
+      }
+      else 
+      {
+        <T>SplayNode* trr = tr->rt;
+        if (trr == 0)
+        {
+          trr =  newnode;
+          comp = 0; done = 1;
+        }
+        else
+          comp = <T>CMP(item, trr->item);
+
+        if ((t->rt = tr->lt) != 0) t->rt->par = t;
+        tr->lt = t; t->par = tr;
+        l->rt = tr; tr->par = l;
+        l = tr;
+        t = trr;
+      }
+    }
+    else
+    {
+      <T>SplayNode* tl = t->lt;
+      if (tl == 0)
+      {
+        tl = newnode;
+        comp = 0; done = 1;
+      }
+      else
+        comp = <T>CMP(item, tl->item);
+
+      if (comp >= 0)
+      {
+        r->lt = t; t->par = r;
+        r = t;
+        t = tl;
+      }
+      else
+      {
+        <T>SplayNode* tll = tl->lt;
+        if (tll == 0)
+        {
+          tll = newnode;
+          comp = 0; done = 1;
+        }
+        else
+          comp = <T>CMP(item, tll->item);
+
+        if ((t->lt = tl->rt) != 0) t->lt->par = t;
+        tl->rt = t; t->par = tl;
+        r->lt = tl; tl->par = r;
+        r = tl;
+        t = tll;
+      }
+    }
+  }
+  if ((r->lt = t->rt) != 0) r->lt->par = r;
+  if ((l->rt = t->lt) != 0) l->rt->par = l;
+  if ((t->lt = dummy->rt) != 0) t->lt->par = t;
+  if ((t->rt = dummy->lt) != 0) t->rt->par = t;
+  t->par = 0;
+  root = t;
+  return Pix(root);
+}
+
+void <T>SplayBag::_del(<T>SplayNode* t)
+{
+  if (t == 0) return;
+
+  <T>SplayNode* p = t->par;
+
+  --count;
+  if (t->rt == 0)
+  {
+    if (t == root)
+    {
+      if ((root = t->lt) != 0) root->par = 0;
+    }
+    else if (t == p->lt)
+    {
+      if ((p->lt = t->lt) != 0) p->lt->par = p;
+    }
+    else
+      if ((p->rt = t->lt) != 0) p->rt->par = p;
+  }
+  else
+  {
+    <T>SplayNode* r = t->rt;
+    <T>SplayNode* l = r->lt;
+    for(;;)
+    {
+      if (l == 0)
+      {
+        if (t == root)
+        {
+          root = r;
+          r->par = 0;
+        }
+        else if (t == p->lt) 
+        {
+          p->lt = r;
+          r->par = p;
+        }
+        else
+        {
+          p->rt = r;
+          r->par = p;
+        }
+        if ((r->lt = t->lt) != 0) r->lt->par = r;
+        break;
+      }
+      else
+      {
+        if ((r->lt = l->rt) != 0) r->lt->par = r;
+        l->rt = r; r->par = l;
+        r = l;
+        l = l->lt;
+      }
+    }
+  }
+  delete t;
+}
+
+
+void <T>SplayBag::remove(<T&> key)
+{
+  <T>SplayNode* t = (<T>SplayNode*)(seek(key));
+  while (t != 0)
+  {
+    _del(t);
+    t = (<T>SplayNode*)(seek(key));
+  }
+}
+
+
+void <T>SplayBag::_kill(<T>SplayNode* t)
+{
+  if (t != 0)
+  {
+    _kill(t->lt);
+    _kill(t->rt);
+    delete t;
+  }
+}
+
+
+<T>SplayNode* <T>SplayBag::_copy(<T>SplayNode* t)
+{
+  if (t != 0)
+  {
+    <T>SplayNode* l = _copy(t->lt);
+    <T>SplayNode* r = _copy(t->rt);
+    <T>SplayNode* x = new <T>SplayNode(t->item, l, r);
+    if (l != 0) l->par = x;
+    if (r != 0) r->par = x;
+    return x;
+  }
+  else 
+    return 0;
+}
+
+int <T>SplayBag::OK()
+{
+  int v = 1;
+  if (root == 0) 
+    v = count == 0;
+  else
+  {
+    int n = 1;
+    <T>SplayNode* trail = leftmost();
+    <T>SplayNode* t = succ(trail);
+    while (t != 0)
+    {
+      ++n;
+      v &= <T>CMP(trail->item, t->item) <= 0;
+      trail = t;
+      t = succ(t);
+    }
+    v &= n == count;
+  }
+  if (!v) error("invariant failure");
+  return v;
+}
+
diff --git a/usr/include/g++/gen/SplayBag.hP b/usr/include/g++/gen/SplayBag.hP
new file mode 100644 (file)
index 0000000..5d3723b
--- /dev/null
@@ -0,0 +1,160 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>SplayBag_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>SplayBag_h 1
+
+#include "<T>.Bag.h"
+
+#ifndef _<T>SplayNode
+#define _<T>SplayNode 1
+
+struct <T>SplayNode
+{
+  <T>SplayNode*   lt;
+  <T>SplayNode*   rt;
+  <T>SplayNode*   par;
+  <T>             item;
+                  <T>SplayNode(<T&> h, <T>SplayNode* l=0, <T>SplayNode* r=0);
+                  ~<T>SplayNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>SplayNode::<T>SplayNode(<T&> h, <T>SplayNode* l, <T>SplayNode* r)
+:item(h), lt(l), rt(r), par(0) {}
+
+inline <T>SplayNode::~<T>SplayNode() {}
+
+#endif
+
+typedef <T>SplayNode* <T>SplayNodePtr;
+
+#endif
+
+class <T>SplayBag : public <T>Bag
+{
+protected:
+  <T>SplayNode*   root;
+
+  <T>SplayNode*   leftmost();
+  <T>SplayNode*   rightmost();
+  <T>SplayNode*   pred(<T>SplayNode* t);
+  <T>SplayNode*   succ(<T>SplayNode* t);
+  void            _kill(<T>SplayNode* t);
+  <T>SplayNode*   _copy(<T>SplayNode* t);
+  void            _del(<T>SplayNode* t);
+
+public:
+                  <T>SplayBag();
+                  <T>SplayBag(<T>SplayBag& a);
+                  ~<T>SplayBag();
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  void          remove(<T&>item);
+  int           nof(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  Pix           seek(<T&> item, Pix from = 0);
+
+  Pix           last();
+  void          prev(Pix& i);
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>SplayBag::~<T>SplayBag()
+{
+  _kill(root);
+}
+
+inline <T>SplayBag::<T>SplayBag()
+{
+  root = 0;
+  count = 0;
+}
+
+inline <T>SplayBag::<T>SplayBag(<T>SplayBag& b)
+{
+  count = b.count;
+  root = _copy(b.root);
+}
+
+inline Pix <T>SplayBag::first()
+{
+  return Pix(leftmost());
+}
+
+inline Pix <T>SplayBag::last()
+{
+  return Pix(rightmost());
+}
+
+inline void <T>SplayBag::next(Pix& i)
+{
+  if (i != 0) i = Pix(succ((<T>SplayNode*)i));
+}
+
+inline void <T>SplayBag::prev(Pix& i)
+{
+  if (i != 0) i = Pix(pred((<T>SplayNode*)i));
+}
+
+inline <T>& <T>SplayBag::operator () (Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T>SplayNode*)i)->item;
+}
+
+inline void <T>SplayBag::clear()
+{
+  _kill(root);
+  count = 0;
+  root = 0;
+}
+
+inline int <T>SplayBag::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+inline void <T>SplayBag::del(<T&> key)
+{
+  _del((<T>SplayNode*)(seek(key)));
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/SplayMap.ccP b/usr/include/g++/gen/SplayMap.ccP
new file mode 100644 (file)
index 0000000..0d86c2d
--- /dev/null
@@ -0,0 +1,407 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include <assert.h>
+#include "<T>.<C>.SplayMap.h"
+
+
+/* 
+
+ struct to simulate the special `null' node in the Sleater & Tarjan JACM 1985
+ splay tree algorithms
+
+ All routines use a version of their `simple top-down' splay alg. (p 669)
+
+*/
+
+struct _dummySplayNode
+{
+  <T><C>SplayNode*    lt;
+  <T><C>SplayNode*    rt;
+  <T><C>SplayNode*    par;
+} _dummy_null;
+
+
+/*
+ traversal primitives
+*/
+
+
+<T><C>SplayNode* <T><C>SplayMap::leftmost()
+{
+  <T><C>SplayNode* t = root;
+  if (t != 0) while (t->lt != 0) t = t->lt;
+  return t;
+}
+
+<T><C>SplayNode* <T><C>SplayMap::rightmost()
+{
+  <T><C>SplayNode* t = root;
+  if (t != 0) while (t->rt != 0) t = t->rt;
+  return t;
+}
+
+<T><C>SplayNode* <T><C>SplayMap::succ(<T><C>SplayNode* t)
+{
+  if (t == 0)
+    return 0;
+  if (t->rt != 0)
+  {
+    t = t->rt;
+    while (t->lt != 0) t = t->lt;
+    return t;
+  }
+  else
+  {
+    for (;;)
+    {
+      if (t->par == 0 || t == t->par->lt)
+        return t->par;
+      else
+        t = t->par;
+    }
+  }
+}
+
+<T><C>SplayNode* <T><C>SplayMap::pred(<T><C>SplayNode* t)
+{
+  if (t == 0)
+    return 0;
+  else if (t->lt != 0)
+  {
+    t = t->lt;
+    while (t->rt != 0) t = t->rt;
+    return t;
+  }
+  else
+  {
+    for (;;)
+    {
+      if (t->par == 0 || t == t->par->rt)
+        return t->par;
+      else
+        t = t->par;
+    }
+  }
+}
+
+
+Pix <T><C>SplayMap::seek(<T&> key)
+{
+  <T><C>SplayNode* t = root;
+  if (t == 0)
+    return 0;
+
+  int comp = <T>CMP(key, t->item);
+  if (comp == 0)
+    return Pix(t);
+
+  <T><C>SplayNode* dummy = (<T><C>SplayNode*)(&_dummy_null);
+  <T><C>SplayNode* l = dummy;
+  <T><C>SplayNode* r = dummy;
+  dummy->rt = dummy->lt = dummy->par = 0;
+
+  while (comp != 0)
+  {
+    if (comp > 0)
+    {
+      <T><C>SplayNode* tr = t->rt;
+      if (tr == 0)
+        break;
+      else
+      {
+        comp = <T>CMP(key, tr->item);
+        if (comp <= 0 || tr->rt == 0)
+        {
+          l->rt = t; t->par = l;
+          l = t;
+          t = tr;
+          if (comp >= 0)
+            break;
+        }
+        else
+        {
+          if ((t->rt = tr->lt) != 0) t->rt->par = t;
+          tr->lt = t; t->par = tr;
+          l->rt = tr; tr->par = l;
+          l = tr;
+          t = tr->rt;
+          comp = <T>CMP(key, t->item);
+        }
+      }
+    }
+    else
+    {
+      <T><C>SplayNode* tl = t->lt;
+      if (tl == 0)
+        break;
+      else
+      {
+        comp = <T>CMP(key, tl->item);
+        if (comp >= 0 || tl->lt == 0)
+        {
+          r->lt = t; t->par = r;
+          r = t;
+          t = tl;
+          if (comp <= 0)
+            break;
+        }
+        else
+        {
+          if ((t->lt = tl->rt) != 0) t->lt->par = t;
+          tl->rt = t; t->par = tl;
+          r->lt = tl; tl->par = r;
+          r = tl;
+          t = tl->lt;
+          comp = <T>CMP(key, t->item);
+        }
+      }
+    }
+  }
+  if ((r->lt = t->rt) != 0) r->lt->par = r;
+  if ((l->rt = t->lt) != 0) l->rt->par = l;
+  if ((t->lt = dummy->rt) != 0) t->lt->par = t;
+  if ((t->rt = dummy->lt) != 0) t->rt->par = t;
+  t->par = 0;
+  root = t;
+  return (comp == 0) ? Pix(t) : 0;
+}
+
+
+<C>& <T><C>SplayMap::operator [] (<T&> item)
+{
+  <T><C>SplayNode* t = root;
+  if (t == 0)
+  {
+    ++count;
+    root = new <T><C>SplayNode(item, def);
+    return root->cont;
+  }
+  int comp = <T>CMP(item, t->item);
+  if (comp == 0)
+    return t->cont;
+
+  <T><C>SplayNode* dummy = (<T><C>SplayNode*)(&_dummy_null);
+  <T><C>SplayNode* l = dummy;
+  <T><C>SplayNode* r = dummy;
+  dummy->rt = dummy->lt = dummy->par = 0;
+
+  while (comp != 0)
+  {
+    if (comp > 0)
+    {
+      <T><C>SplayNode* tr = t->rt;
+      if (tr == 0)
+      {
+        ++count;
+        tr = new <T><C>SplayNode(item, def);
+        comp = 0;
+      }
+      else
+        comp = <T>CMP(item, tr->item);
+        
+      if (comp <= 0)
+      {
+        l->rt = t; t->par = l;
+        l = t;
+        t = tr;
+      }
+      else 
+      {
+        <T><C>SplayNode* trr = tr->rt;
+        if (trr == 0)
+        {
+          ++count;
+          trr =  new <T><C>SplayNode(item, def);
+          comp = 0;
+        }
+        else
+          comp = <T>CMP(item, trr->item);
+
+        if ((t->rt = tr->lt) != 0) t->rt->par = t;
+        tr->lt = t; t->par = tr;
+        l->rt = tr; tr->par = l;
+        l = tr;
+        t = trr;
+      }
+    }
+    else
+    {
+      <T><C>SplayNode* tl = t->lt;
+      if (tl == 0)
+      {
+        ++count;
+        tl = new <T><C>SplayNode(item, def);
+        comp = 0;
+      }
+      else
+        comp = <T>CMP(item, tl->item);
+
+      if (comp >= 0)
+      {
+        r->lt = t; t->par = r;
+        r = t;
+        t = tl;
+      }
+      else
+      {
+        <T><C>SplayNode* tll = tl->lt;
+        if (tll == 0)
+        {
+          ++count;
+          tll = new <T><C>SplayNode(item, def);
+          comp = 0;
+        }
+        else
+          comp = <T>CMP(item, tll->item);
+
+        if ((t->lt = tl->rt) != 0) t->lt->par = t;
+        tl->rt = t; t->par = tl;
+        r->lt = tl; tl->par = r;
+        r = tl;
+        t = tll;
+      }
+    }
+  }
+  if ((r->lt = t->rt) != 0) r->lt->par = r;
+  if ((l->rt = t->lt) != 0) l->rt->par = l;
+  if ((t->lt = dummy->rt) != 0) t->lt->par = t;
+  if ((t->rt = dummy->lt) != 0) t->rt->par = t;
+  t->par = 0;
+  root = t;
+  return root->cont;
+}
+
+void <T><C>SplayMap::del(<T&> key)
+{
+  <T><C>SplayNode* t = (<T><C>SplayNode*)(seek(key));
+  if (t == 0) return;
+
+  <T><C>SplayNode* p = t->par;
+
+  --count;
+  if (t->rt == 0)
+  {
+    if (t == root)
+    {
+      if ((root = t->lt) != 0) root->par = 0;
+    }
+    else if (t == p->lt)
+    {
+      if ((p->lt = t->lt) != 0) p->lt->par = p;
+    }
+    else
+      if ((p->rt = t->lt) != 0) p->rt->par = p;
+  }
+  else
+  {
+    <T><C>SplayNode* r = t->rt;
+    <T><C>SplayNode* l = r->lt;
+    for(;;)
+    {
+      if (l == 0)
+      {
+        if (t == root)
+        {
+          root = r;
+          r->par = 0;
+        }
+        else if (t == p->lt) 
+        {
+          p->lt = r;
+          r->par = p;
+        }
+        else
+        {
+          p->rt = r;
+          r->par = p;
+        }
+        if ((r->lt = t->lt) != 0) r->lt->par = r;
+        break;
+      }
+      else
+      {
+        if ((r->lt = l->rt) != 0) r->lt->par = r;
+        l->rt = r; r->par = l;
+        r = l;
+        l = l->lt;
+      }
+    }
+  }
+  delete t;
+}
+
+
+void <T><C>SplayMap::_kill(<T><C>SplayNode* t)
+{
+  if (t != 0)
+  {
+    _kill(t->lt);
+    _kill(t->rt);
+    delete t;
+  }
+}
+
+
+<T><C>SplayNode* <T><C>SplayMap::_copy(<T><C>SplayNode* t)
+{
+  if (t != 0)
+  {
+    <T><C>SplayNode* l = _copy(t->lt);
+    <T><C>SplayNode* r = _copy(t->rt);
+    <T><C>SplayNode* x = new <T><C>SplayNode(t->item, t->cont, l, r);
+    if (l != 0) l->par = x;
+    if (r != 0) r->par = x;
+    return x;
+  }
+  else 
+    return 0;
+}
+
+
+int <T><C>SplayMap::OK()
+{
+  int v = 1;
+  if (root == 0) 
+    v = count == 0;
+  else
+  {
+    int n = 1;
+    <T><C>SplayNode* trail = leftmost();
+    <T><C>SplayNode* t = succ(trail);
+    while (t != 0)
+    {
+      ++n;
+      v &= <T>CMP(trail->item, t->item) < 0;
+      trail = t;
+      t = succ(t);
+    }
+    v &= n == count;
+  }
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/SplayMap.hP b/usr/include/g++/gen/SplayMap.hP
new file mode 100644 (file)
index 0000000..39cbe12
--- /dev/null
@@ -0,0 +1,166 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T><C>SplayMap_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T><C>SplayMap_h 1
+
+#include "<T>.<C>.Map.h"
+
+#ifndef _<T><C>SplayNode
+#define _<T><C>SplayNode 1
+
+struct <T><C>SplayNode
+{
+  <T><C>SplayNode*   lt;
+  <T><C>SplayNode*   rt;
+  <T><C>SplayNode*   par;
+  <T>                item;
+  <C>                cont;
+                     <T><C>SplayNode(<T&> h, <C&> c, 
+                                     <T><C>SplayNode* l=0, 
+                                     <T><C>SplayNode* r=0);
+                  ~<T><C>SplayNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T><C>SplayNode::<T><C>SplayNode(<T&> h, <C&> c, 
+                                        <T><C>SplayNode* l, 
+                                        <T><C>SplayNode* r)
+     :item(h), cont(c), lt(l), rt(r), par(0) {}
+
+inline <T><C>SplayNode::~<T><C>SplayNode() {}
+
+#endif
+
+typedef <T><C>SplayNode* <T><C>SplayNodePtr;
+
+#endif
+
+class <T><C>SplayMap : public <T><C>Map
+{
+protected:
+  <T><C>SplayNode*   root;
+
+  <T><C>SplayNode*   leftmost();
+  <T><C>SplayNode*   rightmost();
+  <T><C>SplayNode*   pred(<T><C>SplayNode* t);
+  <T><C>SplayNode*   succ(<T><C>SplayNode* t);
+  void               _kill(<T><C>SplayNode* t);
+  <T><C>SplayNode*   _copy(<T><C>SplayNode* t);
+
+public:
+               <T><C>SplayMap(<C&> dflt);
+               <T><C>SplayMap(<T><C>SplayMap& a);
+               ~<T><C>SplayMap();
+
+  <C>&          operator [] (<T&> key);
+
+  void          del(<T&> key);
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          key(Pix i);
+  <C>&          contents(Pix i);
+
+  Pix           seek(<T&> key);
+  int           contains(<T&> key);
+
+  void          clear(); 
+
+  Pix           last();
+  void          prev(Pix& i);
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T><C>SplayMap::~<T><C>SplayMap()
+{
+  _kill(root);
+}
+
+inline <T><C>SplayMap::<T><C>SplayMap(<C&> dflt) :(dflt)
+{
+  root = 0;
+}
+
+inline <T><C>SplayMap::<T><C>SplayMap(<T><C>SplayMap& b) :(b.def)
+{
+  count = b.count;
+  root = _copy(b.root);
+}
+
+inline Pix <T><C>SplayMap::first()
+{
+  return Pix(leftmost());
+}
+
+inline Pix <T><C>SplayMap::last()
+{
+  return Pix(rightmost());
+}
+
+inline void <T><C>SplayMap::next(Pix& i)
+{
+  if (i != 0) i = Pix(succ((<T><C>SplayNode*)i));
+}
+
+inline void <T><C>SplayMap::prev(Pix& i)
+{
+  if (i != 0) i = Pix(pred((<T><C>SplayNode*)i));
+}
+
+inline <T>& <T><C>SplayMap::key (Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T><C>SplayNode*)i)->item;
+}
+
+inline <C>& <T><C>SplayMap::contents (Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T><C>SplayNode*)i)->cont;
+}
+
+inline void <T><C>SplayMap::clear()
+{
+  _kill(root);
+  count = 0;
+  root = 0;
+}
+
+inline int <T><C>SplayMap::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/SplayPQ.ccP b/usr/include/g++/gen/SplayPQ.ccP
new file mode 100644 (file)
index 0000000..cfb8ab4
--- /dev/null
@@ -0,0 +1,529 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include <assert.h>
+#include "<T>.SplayPQ.h"
+
+
+/* 
+
+ struct to simulate the special `null' node in the Sleater & Tarjan JACM 1985
+ splay tree algorithms
+
+ All routines use a version of their `simple top-down' splay alg. (p 669)
+
+*/
+
+struct _dummySplayNode
+{
+  <T>SplayNode*    lt;
+  <T>SplayNode*    rt;
+  <T>SplayNode*    par;
+} _dummy_null;
+
+
+/*
+ traversal primitives
+*/
+
+
+<T>SplayNode* <T>SplayPQ::leftmost()
+{
+  <T>SplayNode* t = root;
+  if (t != 0) while (t->lt != 0) t = t->lt;
+  return t;
+}
+
+<T>SplayNode* <T>SplayPQ::rightmost()
+{
+  <T>SplayNode* t = root;
+  if (t != 0) while (t->rt != 0) t = t->rt;
+  return t;
+}
+
+<T>SplayNode* <T>SplayPQ::succ(<T>SplayNode* t)
+{
+  if (t == 0)
+    return 0;
+  if (t->rt != 0)
+  {
+    t = t->rt;
+    while (t->lt != 0) t = t->lt;
+    return t;
+  }
+  else
+  {
+    for (;;)
+    {
+      if (t->par == 0 || t == t->par->lt)
+        return t->par;
+      else
+        t = t->par;
+    }
+  }
+}
+
+<T>SplayNode* <T>SplayPQ::pred(<T>SplayNode* t)
+{
+  if (t == 0)
+    return 0;
+  else if (t->lt != 0)
+  {
+    t = t->lt;
+    while (t->rt != 0) t = t->rt;
+    return t;
+  }
+  else
+  {
+    for (;;)
+    {
+      if (t->par == 0 || t == t->par->rt)
+        return t->par;
+      else
+        t = t->par;
+    }
+  }
+}
+
+
+Pix <T>SplayPQ::seek(<T&> key)
+{
+  <T>SplayNode* t = root;
+  if (t == 0)
+    return 0;
+
+  int comp = <T>CMP(key, t->item);
+  if (comp == 0)
+    return Pix(t);
+
+  <T>SplayNode* dummy = (<T>SplayNode*)(&_dummy_null);
+  <T>SplayNode* l = dummy;
+  <T>SplayNode* r = dummy;
+  dummy->rt = dummy->lt = dummy->par = 0;
+
+  while (comp != 0)
+  {
+    if (comp > 0)
+    {
+      <T>SplayNode* tr = t->rt;
+      if (tr == 0)
+        break;
+      else
+      {
+        comp = <T>CMP(key, tr->item);
+        if (comp <= 0 || tr->rt == 0)
+        {
+          l->rt = t; t->par = l;
+          l = t;
+          t = tr;
+          if (comp >= 0)
+            break;
+        }
+        else
+        {
+          if ((t->rt = tr->lt) != 0) t->rt->par = t;
+          tr->lt = t; t->par = tr;
+          l->rt = tr; tr->par = l;
+          l = tr;
+          t = tr->rt;
+          comp = <T>CMP(key, t->item);
+        }
+      }
+    }
+    else
+    {
+      <T>SplayNode* tl = t->lt;
+      if (tl == 0)
+        break;
+      else
+      {
+        comp = <T>CMP(key, tl->item);
+        if (comp >= 0 || tl->lt == 0)
+        {
+          r->lt = t; t->par = r;
+          r = t;
+          t = tl;
+          if (comp <= 0)
+            break;
+        }
+        else
+        {
+          if ((t->lt = tl->rt) != 0) t->lt->par = t;
+          tl->rt = t; t->par = tl;
+          r->lt = tl; tl->par = r;
+          r = tl;
+          t = tl->lt;
+          comp = <T>CMP(key, t->item);
+        }
+      }
+    }
+  }
+  if ((r->lt = t->rt) != 0) r->lt->par = r;
+  if ((l->rt = t->lt) != 0) l->rt->par = l;
+  if ((t->lt = dummy->rt) != 0) t->lt->par = t;
+  if ((t->rt = dummy->lt) != 0) t->rt->par = t;
+  t->par = 0;
+  root = t;
+  return (comp == 0) ? Pix(t) : 0;
+}
+
+
+Pix <T>SplayPQ::enq(<T&> item)
+{
+  ++count;
+  <T>SplayNode* newnode = new <T>SplayNode(item);
+  <T>SplayNode* t = root;
+  if (t == 0)
+  {
+    root = newnode;
+    return Pix(root);
+  }
+
+  int comp = <T>CMP(item, t->item);
+
+  <T>SplayNode* dummy = (<T>SplayNode*)(&_dummy_null);
+  <T>SplayNode* l = dummy;
+  <T>SplayNode* r = dummy;
+  dummy->rt = dummy->lt = dummy->par = 0;
+  
+  int done = 0;
+  while (!done)
+  {
+    if (comp >= 0)
+    {
+      <T>SplayNode* tr = t->rt;
+      if (tr == 0)
+      {
+        tr = newnode;
+        comp = 0; done = 1;
+      }
+      else
+        comp = <T>CMP(item, tr->item);
+        
+      if (comp <= 0)
+      {
+        l->rt = t; t->par = l;
+        l = t;
+        t = tr;
+      }
+      else 
+      {
+        <T>SplayNode* trr = tr->rt;
+        if (trr == 0)
+        {
+          trr =  newnode;
+          comp = 0; done = 1;
+        }
+        else
+          comp = <T>CMP(item, trr->item);
+
+        if ((t->rt = tr->lt) != 0) t->rt->par = t;
+        tr->lt = t; t->par = tr;
+        l->rt = tr; tr->par = l;
+        l = tr;
+        t = trr;
+      }
+    }
+    else
+    {
+      <T>SplayNode* tl = t->lt;
+      if (tl == 0)
+      {
+        tl = newnode;
+        comp = 0; done = 1;
+      }
+      else
+        comp = <T>CMP(item, tl->item);
+
+      if (comp >= 0)
+      {
+        r->lt = t; t->par = r;
+        r = t;
+        t = tl;
+      }
+      else
+      {
+        <T>SplayNode* tll = tl->lt;
+        if (tll == 0)
+        {
+          tll = newnode;
+          comp = 0; done = 1;
+        }
+        else
+          comp = <T>CMP(item, tll->item);
+
+        if ((t->lt = tl->rt) != 0) t->lt->par = t;
+        tl->rt = t; t->par = tl;
+        r->lt = tl; tl->par = r;
+        r = tl;
+        t = tll;
+      }
+    }
+  }
+  if ((r->lt = t->rt) != 0) r->lt->par = r;
+  if ((l->rt = t->lt) != 0) l->rt->par = l;
+  if ((t->lt = dummy->rt) != 0) t->lt->par = t;
+  if ((t->rt = dummy->lt) != 0) t->rt->par = t;
+  t->par = 0;
+  root = t;
+  return Pix(root);
+}
+
+
+void <T>SplayPQ::del(Pix pix)
+{
+  <T>SplayNode* t = (<T>SplayNode*)pix;
+  if (t == 0) return;
+
+  <T>SplayNode* p = t->par;
+
+  --count;
+  if (t->rt == 0)
+  {
+    if (t == root)
+    {
+      if ((root = t->lt) != 0) root->par = 0;
+    }
+    else if (t == p->lt)
+    {
+      if ((p->lt = t->lt) != 0) p->lt->par = p;
+    }
+    else
+      if ((p->rt = t->lt) != 0) p->rt->par = p;
+  }
+  else
+  {
+    <T>SplayNode* r = t->rt;
+    <T>SplayNode* l = r->lt;
+    for(;;)
+    {
+      if (l == 0)
+      {
+        if (t == root)
+        {
+          root = r;
+          r->par = 0;
+        }
+        else if (t == p->lt) 
+        {
+          p->lt = r;
+          r->par = p;
+        }
+        else
+        {
+          p->rt = r;
+          r->par = p;
+        }
+        if ((r->lt = t->lt) != 0) r->lt->par = r;
+        break;
+      }
+      else
+      {
+        if ((r->lt = l->rt) != 0) r->lt->par = r;
+        l->rt = r; r->par = l;
+        r = l;
+        l = l->lt;
+      }
+    }
+  }
+  delete t;
+}
+
+<T>& <T>SplayPQ::front()
+{
+  if (root == 0)
+    error ("min: empty tree\n");
+//  else 
+  {
+    <T>SplayNode* t = root;
+    <T>SplayNode* l = root->lt;
+    for(;;)
+    {
+      if (l == 0)
+      {
+        root = t;
+        root->par = 0;
+        return root->item;
+      }
+      else
+      {
+        if ((t->lt = l->rt) != 0) t->lt->par = t;
+        l->rt = t; t->par = l;
+        t = l;
+        l = l->lt;
+      }
+    }
+  }
+}
+
+void <T>SplayPQ::del_front()
+{
+  if (root != 0)
+  {
+    --count;
+    <T>SplayNode* t = root;
+    <T>SplayNode* l = root->lt;
+    if (l == 0)
+    {
+      if ((root = t->rt) != 0) root->par = 0;
+      delete t;
+    }
+    else
+    {
+      for(;;)
+      {
+        <T>SplayNode* ll = l->lt;
+        if (ll == 0)
+        {
+          if ((t->lt = l->rt) != 0) t->lt->par = t;
+          delete l;
+          break;
+        }
+        else
+        {
+          <T>SplayNode* lll = ll->lt;
+          if (lll == 0)
+          {
+            if ((l->lt = ll->rt) != 0) l->lt->par = l;
+            delete ll;
+            break;
+          }
+          else
+          {
+            t->lt = ll; ll->par = t;
+            if ((l->lt = ll->rt) != 0) l->lt->par = l;
+            ll->rt = l; l->par = ll;
+            t = ll;
+            l = lll;
+          }
+        }
+      }
+    }
+  }
+}
+
+<T> <T>SplayPQ::deq()
+{
+  if (root == 0)
+    error("deq: empty tree");
+//  else
+  {
+    --count;
+    <T>SplayNode* t = root;
+    <T>SplayNode* l = root->lt;
+    if (l == 0)
+    {
+      if ((root = t->rt) != 0) root->par = 0;
+      <T> res = t->item;
+      delete t;
+      return res;
+    }
+    else
+    {
+      for(;;)
+      {
+        <T>SplayNode* ll = l->lt;
+        if (ll == 0)
+        {
+          if ((t->lt = l->rt) != 0) t->lt->par = t;
+          <T> res = l->item;
+          delete l;
+          return res;
+        }
+        else
+        {
+          <T>SplayNode* lll = ll->lt;
+          if (lll == 0)
+          {
+            if ((l->lt = ll->rt) != 0) l->lt->par = l;
+            <T> res = ll->item;
+            delete ll;
+            return res;
+          }
+          else
+          {
+            t->lt = ll; ll->par = t;
+            if ((l->lt = ll->rt) != 0) l->lt->par = l;
+            ll->rt = l; l->par = ll;
+            t = ll;
+            l = lll;
+          }
+        }
+      }
+    }
+  }
+}
+
+
+void <T>SplayPQ::_kill(<T>SplayNode* t)
+{
+  if (t != 0)
+  {
+    _kill(t->lt);
+    _kill(t->rt);
+    delete t;
+  }
+}
+
+
+<T>SplayNode* <T>SplayPQ::_copy(<T>SplayNode* t)
+{
+  if (t != 0)
+  {
+    <T>SplayNode* l = _copy(t->lt);
+    <T>SplayNode* r = _copy(t->rt);
+    <T>SplayNode* x = new <T>SplayNode(t->item, l, r);
+    if (l != 0) l->par = x;
+    if (r != 0) r->par = x;
+    return x;
+  }
+  else 
+    return 0;
+}
+
+int <T>SplayPQ::OK()
+{
+  int v = 1;
+  if (root == 0) 
+    v = count == 0;
+  else
+  {
+    int n = 1;
+    <T>SplayNode* trail = leftmost();
+    <T>SplayNode* t = succ(trail);
+    while (t != 0)
+    {
+      ++n;
+      v &= <T>CMP(trail->item, t->item) < 0;
+      trail = t;
+      t = succ(t);
+    }
+    v &= n == count;
+  }
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/SplayPQ.hP b/usr/include/g++/gen/SplayPQ.hP
new file mode 100644 (file)
index 0000000..8c73825
--- /dev/null
@@ -0,0 +1,157 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>SplayPQ_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>SplayPQ_h 1
+
+#include "<T>.PQ.h"
+
+#ifndef _<T>SplayNode
+#define _<T>SplayNode 1
+
+struct <T>SplayNode
+{
+  <T>SplayNode*   lt;
+  <T>SplayNode*   rt;
+  <T>SplayNode*   par;
+  <T>             item;
+                  <T>SplayNode(<T&> h, <T>SplayNode* l=0, <T>SplayNode* r=0);
+                  ~<T>SplayNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>SplayNode::<T>SplayNode(<T&> h, <T>SplayNode* l, <T>SplayNode* r)
+:item(h), lt(l), rt(r), par(0) {}
+
+inline <T>SplayNode::~<T>SplayNode() {}
+
+#endif
+
+typedef <T>SplayNode* <T>SplayNodePtr;
+
+#endif
+
+class <T>SplayPQ : public <T>PQ
+{
+protected:
+  <T>SplayNode*   root;
+
+  <T>SplayNode*   leftmost();
+  <T>SplayNode*   rightmost();
+  <T>SplayNode*   pred(<T>SplayNode* t);
+  <T>SplayNode*   succ(<T>SplayNode* t);
+  void            _kill(<T>SplayNode* t);
+  <T>SplayNode*   _copy(<T>SplayNode* t);
+
+public:
+                  <T>SplayPQ();
+                  <T>SplayPQ(<T>SplayPQ& a);
+                  ~<T>SplayPQ();
+
+  Pix           enq(<T&> item);
+  <T>           deq(); 
+
+  <T>&          front();
+  void          del_front();
+
+  int           contains(<T&> item);
+
+  void          clear(); 
+
+  Pix           first(); 
+  Pix           last(); 
+  void          next(Pix& i);
+  void          prev(Pix& i);
+  <T>&          operator () (Pix i);
+  void          del(Pix i);
+  Pix           seek(<T&> item);
+
+  int           OK();                    // rep invariant
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>SplayPQ::~<T>SplayPQ()
+{
+  _kill(root);
+}
+
+inline <T>SplayPQ::<T>SplayPQ()
+{
+  root = 0;
+  count = 0;
+}
+
+inline <T>SplayPQ::<T>SplayPQ(<T>SplayPQ& b)
+{
+  count = b.count;
+  root = _copy(b.root);
+}
+
+inline Pix <T>SplayPQ::first()
+{
+  return Pix(leftmost());
+}
+
+inline Pix <T>SplayPQ::last()
+{
+  return Pix(rightmost());
+}
+
+inline void <T>SplayPQ::next(Pix& i)
+{
+  if (i != 0) i = Pix(succ((<T>SplayNode*)i));
+}
+
+inline void <T>SplayPQ::prev(Pix& i)
+{
+  if (i != 0) i = Pix(pred((<T>SplayNode*)i));
+}
+
+inline <T>& <T>SplayPQ::operator () (Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T>SplayNode*)i)->item;
+}
+
+inline void <T>SplayPQ::clear()
+{
+  _kill(root);
+  count = 0;
+  root = 0;
+}
+
+inline int <T>SplayPQ::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/SplaySet.ccP b/usr/include/g++/gen/SplaySet.ccP
new file mode 100644 (file)
index 0000000..fc037a0
--- /dev/null
@@ -0,0 +1,505 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include <assert.h>
+#include "<T>.SplaySet.h"
+
+
+/* 
+
+ struct to simulate the special `null' node in the Sleater & Tarjan JACM 1985
+ splay tree algorithms
+
+ All routines use a version of their `simple top-down' splay alg. (p 669)
+
+*/
+
+struct _dummySplayNode
+{
+  <T>SplayNode*    lt;
+  <T>SplayNode*    rt;
+  <T>SplayNode*    par;
+} _dummy_null;
+
+
+/*
+ traversal primitives
+*/
+
+
+<T>SplayNode* <T>SplaySet::leftmost()
+{
+  <T>SplayNode* t = root;
+  if (t != 0) while (t->lt != 0) t = t->lt;
+  return t;
+}
+
+<T>SplayNode* <T>SplaySet::rightmost()
+{
+  <T>SplayNode* t = root;
+  if (t != 0) while (t->rt != 0) t = t->rt;
+  return t;
+}
+
+<T>SplayNode* <T>SplaySet::succ(<T>SplayNode* t)
+{
+  if (t == 0)
+    return 0;
+  if (t->rt != 0)
+  {
+    t = t->rt;
+    while (t->lt != 0) t = t->lt;
+    return t;
+  }
+  else
+  {
+    for (;;)
+    {
+      if (t->par == 0 || t == t->par->lt)
+        return t->par;
+      else
+        t = t->par;
+    }
+  }
+}
+
+<T>SplayNode* <T>SplaySet::pred(<T>SplayNode* t)
+{
+  if (t == 0)
+    return 0;
+  else if (t->lt != 0)
+  {
+    t = t->lt;
+    while (t->rt != 0) t = t->rt;
+    return t;
+  }
+  else
+  {
+    for (;;)
+    {
+      if (t->par == 0 || t == t->par->rt)
+        return t->par;
+      else
+        t = t->par;
+    }
+  }
+}
+
+
+Pix <T>SplaySet::seek(<T&> key)
+{
+  <T>SplayNode* t = root;
+  if (t == 0)
+    return 0;
+
+  int comp = <T>CMP(key, t->item);
+  if (comp == 0)
+    return Pix(t);
+
+  <T>SplayNode* dummy = (<T>SplayNode*)(&_dummy_null);
+  <T>SplayNode* l = dummy;
+  <T>SplayNode* r = dummy;
+  dummy->rt = dummy->lt = dummy->par = 0;
+
+  while (comp != 0)
+  {
+    if (comp > 0)
+    {
+      <T>SplayNode* tr = t->rt;
+      if (tr == 0)
+        break;
+      else
+      {
+        comp = <T>CMP(key, tr->item);
+        if (comp <= 0 || tr->rt == 0)
+        {
+          l->rt = t; t->par = l;
+          l = t;
+          t = tr;
+          if (comp >= 0)
+            break;
+        }
+        else
+        {
+          if ((t->rt = tr->lt) != 0) t->rt->par = t;
+          tr->lt = t; t->par = tr;
+          l->rt = tr; tr->par = l;
+          l = tr;
+          t = tr->rt;
+          comp = <T>CMP(key, t->item);
+        }
+      }
+    }
+    else
+    {
+      <T>SplayNode* tl = t->lt;
+      if (tl == 0)
+        break;
+      else
+      {
+        comp = <T>CMP(key, tl->item);
+        if (comp >= 0 || tl->lt == 0)
+        {
+          r->lt = t; t->par = r;
+          r = t;
+          t = tl;
+          if (comp <= 0)
+            break;
+        }
+        else
+        {
+          if ((t->lt = tl->rt) != 0) t->lt->par = t;
+          tl->rt = t; t->par = tl;
+          r->lt = tl; tl->par = r;
+          r = tl;
+          t = tl->lt;
+          comp = <T>CMP(key, t->item);
+        }
+      }
+    }
+  }
+  if ((r->lt = t->rt) != 0) r->lt->par = r;
+  if ((l->rt = t->lt) != 0) l->rt->par = l;
+  if ((t->lt = dummy->rt) != 0) t->lt->par = t;
+  if ((t->rt = dummy->lt) != 0) t->rt->par = t;
+  t->par = 0;
+  root = t;
+  return (comp == 0) ? Pix(t) : 0;
+}
+
+
+
+Pix <T>SplaySet::add(<T&> item)
+{
+  <T>SplayNode* t = root;
+  if (t == 0)
+  {
+    ++count;
+    root = new <T>SplayNode(item);
+    return Pix(root);
+  }
+  int comp = <T>CMP(item, t->item);
+  if (comp == 0)
+    return Pix(t);
+
+  <T>SplayNode* dummy = (<T>SplayNode*)(&_dummy_null);
+  <T>SplayNode* l = dummy;
+  <T>SplayNode* r = dummy;
+  dummy->rt = dummy->lt = dummy->par = 0;
+
+  while (comp != 0)
+  {
+    if (comp > 0)
+    {
+      <T>SplayNode* tr = t->rt;
+      if (tr == 0)
+      {
+        ++count;
+        tr = new <T>SplayNode(item);
+        comp = 0;
+      }
+      else
+        comp = <T>CMP(item, tr->item);
+        
+      if (comp <= 0)
+      {
+        l->rt = t; t->par = l;
+        l = t;
+        t = tr;
+      }
+      else 
+      {
+        <T>SplayNode* trr = tr->rt;
+        if (trr == 0)
+        {
+          ++count;
+          trr =  new <T>SplayNode(item);
+          comp = 0;
+        }
+        else
+          comp = <T>CMP(item, trr->item);
+
+        if ((t->rt = tr->lt) != 0) t->rt->par = t;
+        tr->lt = t; t->par = tr;
+        l->rt = tr; tr->par = l;
+        l = tr;
+        t = trr;
+      }
+    }
+    else
+    {
+      <T>SplayNode* tl = t->lt;
+      if (tl == 0)
+      {
+        ++count;
+        tl = new <T>SplayNode(item);
+        comp = 0;
+      }
+      else
+        comp = <T>CMP(item, tl->item);
+
+      if (comp >= 0)
+      {
+        r->lt = t; t->par = r;
+        r = t;
+        t = tl;
+      }
+      else
+      {
+        <T>SplayNode* tll = tl->lt;
+        if (tll == 0)
+        {
+          ++count;
+          tll = new <T>SplayNode(item);
+          comp = 0;
+        }
+        else
+          comp = <T>CMP(item, tll->item);
+
+        if ((t->lt = tl->rt) != 0) t->lt->par = t;
+        tl->rt = t; t->par = tl;
+        r->lt = tl; tl->par = r;
+        r = tl;
+        t = tll;
+      }
+    }
+  }
+  if ((r->lt = t->rt) != 0) r->lt->par = r;
+  if ((l->rt = t->lt) != 0) l->rt->par = l;
+  if ((t->lt = dummy->rt) != 0) t->lt->par = t;
+  if ((t->rt = dummy->lt) != 0) t->rt->par = t;
+  t->par = 0;
+  root = t;
+  return Pix(root);
+}
+
+void <T>SplaySet::del(<T&> key)
+{
+  <T>SplayNode* t = (<T>SplayNode*)(seek(key));
+  if (t == 0) return;
+
+  <T>SplayNode* p = t->par;
+
+  --count;
+  if (t->rt == 0)
+  {
+    if (t == root)
+    {
+      if ((root = t->lt) != 0) root->par = 0;
+    }
+    else if (t == p->lt)
+    {
+      if ((p->lt = t->lt) != 0) p->lt->par = p;
+    }
+    else
+      if ((p->rt = t->lt) != 0) p->rt->par = p;
+  }
+  else
+  {
+    <T>SplayNode* r = t->rt;
+    <T>SplayNode* l = r->lt;
+    for(;;)
+    {
+      if (l == 0)
+      {
+        if (t == root)
+        {
+          root = r;
+          r->par = 0;
+        }
+        else if (t == p->lt) 
+        {
+          p->lt = r;
+          r->par = p;
+        }
+        else
+        {
+          p->rt = r;
+          r->par = p;
+        }
+        if ((r->lt = t->lt) != 0) r->lt->par = r;
+        break;
+      }
+      else
+      {
+        if ((r->lt = l->rt) != 0) r->lt->par = r;
+        l->rt = r; r->par = l;
+        r = l;
+        l = l->lt;
+      }
+    }
+  }
+  delete t;
+}
+
+
+void <T>SplaySet::_kill(<T>SplayNode* t)
+{
+  if (t != 0)
+  {
+    _kill(t->lt);
+    _kill(t->rt);
+    delete t;
+  }
+}
+
+
+<T>SplayNode* <T>SplaySet::_copy(<T>SplayNode* t)
+{
+  if (t != 0)
+  {
+    <T>SplayNode* l = _copy(t->lt);
+    <T>SplayNode* r = _copy(t->rt);
+    <T>SplayNode* x = new <T>SplayNode(t->item, l, r);
+    if (l != 0) l->par = x;
+    if (r != 0) r->par = x;
+    return x;
+  }
+  else 
+    return 0;
+}
+
+/* relationals */
+
+int <T>SplaySet::operator == (<T>SplaySet& y)
+{
+  if (count != y.count)
+    return 0;
+  else
+  {
+    <T>SplayNode* t = leftmost();
+    <T>SplayNode* u = y.leftmost();
+    for (;;)
+    {
+      if (t == 0)
+        return 1;
+      else if (!<T>EQ(t->item, u->item))
+        return 0;
+      else
+      {
+        t = succ(t);
+        u = y.succ(u);
+      }
+    }
+  }
+}
+
+int <T>SplaySet::operator <= (<T>SplaySet& y)
+{
+  if (count > y.count)
+    return 0;
+  else
+  {
+    <T>SplayNode* t = leftmost();
+    <T>SplayNode* u = y.leftmost();
+    for (;;)
+    {
+      if (t == 0)
+        return 1;
+      else if (u == 0)
+        return 0;
+      int cmp = <T>CMP(t->item, u->item);
+      if (cmp == 0)
+      {
+        t = succ(t);
+        u = y.succ(u);
+      }
+      else if (cmp < 0)
+        return 0;
+      else
+        u = y.succ(u);
+    }
+  }
+}
+
+
+void <T>SplaySet::operator |=(<T>SplaySet& y)
+{
+  if (&y == this) return;
+  <T>SplayNode* u = y.leftmost();
+  while (u != 0)
+  {
+    add(u->item);
+    u = y.succ(u);
+  }
+}
+
+void <T>SplaySet::operator &= (<T>SplaySet& y)
+{
+  if (y.count == 0)
+    clear();
+  else if (&y != this && count != 0)
+  {
+    <T>SplayNode* t = leftmost();
+    while (t != 0)
+    {
+      <T>SplayNode* s = succ(t);
+      if (y.seek(t->item) == 0) del(t->item);
+      t = s;
+    }
+  }
+}
+
+
+void <T>SplaySet::operator -=(<T>SplaySet& y)
+{
+  if (&y == this)
+    clear();
+  else if (y.count != 0)
+  {
+    <T>SplayNode* t = leftmost();
+    while (t != 0)
+    {
+      <T>SplayNode* s = succ(t);
+      if (y.seek(t->item) != 0) del(t->item);
+      t = s;
+    }
+  }
+}
+
+int <T>SplaySet::OK()
+{
+  int v = 1;
+  if (root == 0) 
+    v = count == 0;
+  else
+  {
+    int n = 1;
+    <T>SplayNode* trail = leftmost();
+    <T>SplayNode* t = succ(trail);
+    while (t != 0)
+    {
+      ++n;
+      v &= <T>CMP(trail->item, t->item) < 0;
+      trail = t;
+      t = succ(t);
+    }
+    v &= n == count;
+  }
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/SplaySet.hP b/usr/include/g++/gen/SplaySet.hP
new file mode 100644 (file)
index 0000000..b499fdc
--- /dev/null
@@ -0,0 +1,167 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>SplaySet_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>SplaySet_h 1
+
+#include "<T>.Set.h"
+
+#ifndef _<T>SplayNode
+#define _<T>SplayNode 1
+
+struct <T>SplayNode
+{
+  <T>SplayNode*   lt;
+  <T>SplayNode*   rt;
+  <T>SplayNode*   par;
+  <T>             item;
+                  <T>SplayNode(<T&> h, <T>SplayNode* l=0, <T>SplayNode* r=0);
+                  ~<T>SplayNode();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>SplayNode::<T>SplayNode(<T&> h, <T>SplayNode* l, <T>SplayNode* r)
+:item(h), lt(l), rt(r), par(0) {}
+
+inline <T>SplayNode::~<T>SplayNode() {}
+
+#endif
+
+typedef <T>SplayNode* <T>SplayNodePtr;
+
+#endif
+
+class <T>SplaySet : public <T>Set
+{
+protected:
+  <T>SplayNode*   root;
+
+  <T>SplayNode*   leftmost();
+  <T>SplayNode*   rightmost();
+  <T>SplayNode*   pred(<T>SplayNode* t);
+  <T>SplayNode*   succ(<T>SplayNode* t);
+  void            _kill(<T>SplayNode* t);
+  <T>SplayNode*   _copy(<T>SplayNode* t);
+
+public:
+                  <T>SplaySet();
+                  <T>SplaySet(<T>SplaySet& a);
+                  ~<T>SplaySet();
+
+  Pix             add(<T&> item);
+  void            del(<T&> item);
+  int             contains(<T&> item);
+
+  void            clear();
+
+  Pix             first();
+  void            next(Pix& i);
+  <T>&            operator () (Pix i);
+  Pix             seek(<T&> item);
+
+  Pix             last();
+  void            prev(Pix& i);
+
+  void            operator |= (<T>SplaySet& b);
+  void            operator -= (<T>SplaySet& b);
+  void            operator &= (<T>SplaySet& b);
+
+  int             operator == (<T>SplaySet& b);
+  int             operator != (<T>SplaySet& b);
+  int             operator <= (<T>SplaySet& b); 
+
+  int             OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>SplaySet::~<T>SplaySet()
+{
+  _kill(root);
+}
+
+inline <T>SplaySet::<T>SplaySet()
+{
+  root = 0;
+  count = 0;
+}
+
+inline <T>SplaySet::<T>SplaySet(<T>SplaySet& b)
+{
+  count = b.count;
+  root = _copy(b.root);
+}
+
+
+inline int <T>SplaySet::operator != (<T>SplaySet& b)
+{
+  return ! (*this == b);
+}
+
+inline Pix <T>SplaySet::first()
+{
+  return Pix(leftmost());
+}
+
+inline Pix <T>SplaySet::last()
+{
+  return Pix(rightmost());
+}
+
+inline void <T>SplaySet::next(Pix& i)
+{
+  if (i != 0) i = Pix(succ((<T>SplayNode*)i));
+}
+
+inline void <T>SplaySet::prev(Pix& i)
+{
+  if (i != 0) i = Pix(pred((<T>SplayNode*)i));
+}
+
+inline <T>& <T>SplaySet::operator () (Pix i)
+{
+  if (i == 0) error("null Pix");
+  return ((<T>SplayNode*)i)->item;
+}
+
+inline void <T>SplaySet::clear()
+{
+  _kill(root);
+  count = 0;
+  root = 0;
+}
+
+inline int <T>SplaySet::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/Stack.ccP b/usr/include/g++/gen/Stack.ccP
new file mode 100644 (file)
index 0000000..efb6b8e
--- /dev/null
@@ -0,0 +1,11 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.Stack.h"
+
+<T>Stack::~<T>Stack() {}
+
+void <T>Stack::error(const char* msg)
+{
+  (*lib_error_handler)("Stack", msg);
+}
diff --git a/usr/include/g++/gen/Stack.hP b/usr/include/g++/gen/Stack.hP
new file mode 100644 (file)
index 0000000..46c4799
--- /dev/null
@@ -0,0 +1,62 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>Stack_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>Stack_h
+
+#include <builtin.h>
+
+#include "<T>.defs.h"
+
+class <T>Stack
+{
+public:
+                        <T>Stack();
+  virtual              ~<T>Stack();
+
+  virtual void          push(<T&> item) = 0;
+  virtual <T>           pop() = 0;
+  virtual <T>&          top() = 0;               
+  virtual void          del_top() = 0;
+
+  virtual int           empty() = 0;
+  virtual int           full() = 0;
+  virtual int           length() = 0;
+
+  virtual void          clear() = 0;
+
+  void                  error(const char*);
+  virtual int           OK() = 0;
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+inline <T>Stack::<T>Stack() {}
+#endif
+
+
+#endif
diff --git a/usr/include/g++/gen/VHBag.ccP b/usr/include/g++/gen/VHBag.ccP
new file mode 100644 (file)
index 0000000..d56643d
--- /dev/null
@@ -0,0 +1,269 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.VHBag.h"
+
+/* codes for status fields */
+
+#define EMPTYCELL   0
+#define VALIDCELL   1
+#define DELETEDCELL 2
+
+
+<T>VHBag::<T>VHBag(unsigned int sz)
+{
+  tab = new <T>[size = sz];
+  status = new char[size];
+  for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = 0;
+}
+<T>VHBag::<T>VHBag(<T>VHBag& a)
+{
+  tab = new <T>[size = a.size];
+  status = new char[size];
+  for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = 0;
+  for (Pix p = a.first(); p; a.next(p)) add(a(p));
+}
+
+
+/* 
+ * hashing method: double hash based on high bits of hash fct,
+ * followed by linear probe. Can't do too much better if table
+ * sizes not constrained to be prime.
+*/
+
+
+static inline unsigned int doublehashinc(unsigned int h, unsigned int s)
+{
+  unsigned int dh =  ((h / s) % s);
+  return (dh > 1)? dh : 1;
+}
+
+Pix <T>VHBag::seek(<T&> key, Pix p)
+{
+  <T>* t = (<T>*) p;
+  if (t == 0 || !<T>EQ(*t, key))
+  {
+    unsigned int hashval = <T>HASH(key);
+    unsigned int h = hashval % size;
+    for (unsigned int i = 0; i <= size; ++i)
+    {
+      if (status[h] == EMPTYCELL)
+        return 0;
+      else if (status[h] == VALIDCELL && <T>EQ(key, tab[h]))
+        return Pix(&tab[h]);
+      if (i == 0)
+        h = (h + doublehashinc(hashval, size)) % size;
+      else if (++h >= size)
+        h -= size;
+    }
+    return 0;
+  }
+  else
+  {
+    int seent = 0;
+    unsigned int hashval = <T>HASH(key);
+    unsigned int h = hashval % size;
+    for (unsigned int i = 0; i <= size; ++i)
+    {
+      if (status[h] == EMPTYCELL)
+        return 0;
+      else if (&tab[h] == t)
+        seent = 1;
+      else if (seent && status[h] == VALIDCELL && <T>EQ(key, tab[h]))
+        return Pix(&tab[h]);
+      if (i == 0)
+        h = (h + doublehashinc(hashval, size)) % size;
+      else if (++h >= size)
+        h -= size;
+    }
+    return 0;
+  }
+}
+
+int <T>VHBag::nof(<T&> item)
+{
+  int n = 0;
+  unsigned int hashval = <T>HASH(item);
+  unsigned int h = hashval % size;
+  unsigned int firsth = size;
+  for (unsigned int i = 0; i <= size; ++i)
+  {
+    if (status[h] == EMPTYCELL)
+      return n;
+    else if (h != firsth && status[h] == VALIDCELL && <T>EQ(item, tab[h]))
+    {
+      ++n;
+      if (firsth >= size)
+        firsth = h;
+    }
+    if (i == 0)
+      h = (h + doublehashinc(hashval, size)) % size;
+    else if (++h >= size)
+      h -= size;
+  }
+  return n;
+}
+
+
+Pix <T>VHBag::add(<T&> item)
+{
+  if (size <= count + 1)
+    resize();
+  unsigned int bestspot = size;
+  unsigned int hashval = <T>HASH(item);
+  unsigned int h = hashval % size;
+  for (unsigned int i = 0; i <= size; ++i)
+  {
+    if (status[h] == EMPTYCELL)
+    {
+      if (bestspot >= size) bestspot = h;
+      tab[bestspot] = item;
+      status[bestspot] = VALIDCELL;
+      ++count;
+      return Pix(&tab[bestspot]);
+    }
+    else if (status[h] == DELETEDCELL)
+    {
+      if (bestspot >= size) bestspot = h;
+    }
+
+    if (i == 0)
+      h = (h + doublehashinc(hashval, size)) % size;
+    else if (++h >= size)
+      h -= size;
+  }
+  tab[bestspot] = item;
+  status[bestspot] = VALIDCELL;
+  ++count;
+  return Pix(&tab[bestspot]);
+}
+
+
+void <T>VHBag::del(<T&> key)
+{
+  unsigned int hashval = <T>HASH(key);
+  unsigned int h = hashval % size;
+  for (unsigned int i = 0; i <= size; ++i)
+  {
+    if (status[h] == EMPTYCELL)
+      return;
+    else if (status[h] == VALIDCELL && <T>EQ(key, tab[h]))
+    {
+      status[h] = DELETEDCELL;
+      --count;
+      return;
+    }
+    if (i == 0)
+      h = (h + doublehashinc(hashval, size)) % size;
+    else if (++h >= size)
+      h -= size;
+  }
+}
+
+void <T>VHBag::remove(<T&> key)
+{
+  unsigned int hashval = <T>HASH(key);
+  unsigned int h = hashval % size;
+  for (unsigned int i = 0; i <= size; ++i)
+  {
+    if (status[h] == EMPTYCELL)
+      return;
+    else if (status[h] == VALIDCELL && <T>EQ(key, tab[h]))
+    {
+      status[h] = DELETEDCELL;
+      --count;
+    }
+    if (i == 0)
+      h = (h + doublehashinc(hashval, size)) % size;
+    else if (++h >= size)
+      h -= size;
+  }
+}
+
+void <T>VHBag::clear()
+{
+  for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = 0;
+}
+
+void <T>VHBag::resize(unsigned int newsize)
+{
+  if (newsize <= count)
+  {
+    newsize = DEFAULT_INITIAL_CAPACITY;
+    while (newsize <= count) newsize <<= 1;
+  }
+  <T>* oldtab = tab;
+  char* oldstatus = status;
+  unsigned int oldsize = size;
+  tab = new <T>[size = newsize];
+  status = new char[size];
+  for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = 0;
+  for (i = 0; i < oldsize; ++i) if (oldstatus[i] == VALIDCELL) add(oldtab[i]);
+  delete [oldsize] oldtab;
+  delete oldstatus;
+}
+
+Pix <T>VHBag::first()
+{
+  for (unsigned int pos = 0; pos < size; ++pos)
+    if (status[pos] == VALIDCELL) return Pix(&tab[pos]);
+  return 0;
+}
+
+void <T>VHBag::next(Pix& i)
+{
+  if (i == 0) return;
+  unsigned int pos = ((unsigned)i - (unsigned)tab) / sizeof(<T>) + 1;
+  for (; pos < size; ++pos)
+    if (status[pos] == VALIDCELL)
+    {
+      i = Pix(&tab[pos]);
+      return;
+    }
+  i = 0;
+}
+
+  
+int <T>VHBag::OK()
+{
+  int v = tab != 0;
+  v &= status != 0;
+  int n = 0;
+  for (unsigned int i = 0; i < size; ++i) 
+  {
+    if (status[i] == VALIDCELL) ++n;
+    else if (status[i] != DELETEDCELL && status[i] != EMPTYCELL)
+      v = 0;
+  }
+  v &= n == count;
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/VHBag.hP b/usr/include/g++/gen/VHBag.hP
new file mode 100644 (file)
index 0000000..b88673c
--- /dev/null
@@ -0,0 +1,92 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>VHBag_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>VHBag_h 1
+
+#include "<T>.Bag.h"
+
+
+class <T>VHBag : public <T>Bag
+{
+protected:
+  <T>*          tab;
+  char*         status;
+  unsigned int  size;
+
+public:
+                <T>VHBag(unsigned int sz = DEFAULT_INITIAL_CAPACITY);
+                <T>VHBag(<T>VHBag& a);
+                ~<T>VHBag();
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  void          remove(<T&>item);
+  int           nof(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  Pix           seek(<T&> item, Pix from = 0);
+
+  int           capacity();
+  void          resize(unsigned int newsize = 0);
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>VHBag::~<T>VHBag()
+{
+  delete [size] tab;
+  delete status;
+}
+
+
+inline int <T>VHBag::capacity()
+{
+  return size;
+}
+
+inline int <T>VHBag::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+inline <T>& <T>VHBag::operator () (Pix i)
+{
+  if (i == 0) error("null Pix");
+  return *((<T>*)i);
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/VHMap.ccP b/usr/include/g++/gen/VHMap.ccP
new file mode 100644 (file)
index 0000000..b612944
--- /dev/null
@@ -0,0 +1,215 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.<C>.VHMap.h"
+
+/* codes for status fields */
+
+#define EMPTYCELL   0
+#define VALIDCELL   1
+#define DELETEDCELL 2
+
+
+<T><C>VHMap::<T><C>VHMap(<C&> dflt, unsigned int sz)
+     :<T><C>Map(dflt)
+{
+  tab = new <T>[size = sz];
+  cont = new <C>[size];
+  status = new char[size];
+  for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+}
+
+<T><C>VHMap::<T><C>VHMap(<T><C>VHMap& a) : <T><C>Map(a.def)
+{
+  tab = new <T>[size = a.size];
+  cont = new <C>[size];
+  status = new char[size];
+  for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = 0;
+  for (Pix p = a.first(); p; a.next(p)) (*this)[a.key(p)] = a.contents(p);
+}
+
+
+/* 
+ * hashing method: double hash based on high bits of hash fct,
+ * followed by linear probe. Can't do too much better if table
+ * sizes not constrained to be prime.
+*/
+
+
+static inline unsigned int doublehashinc(unsigned int h, unsigned int s)
+{
+  unsigned int dh =  ((h / s) % s);
+  return (dh > 1)? dh : 1;
+}
+
+Pix <T><C>VHMap::seek(<T&> key)
+{
+  unsigned int hashval = <T>HASH(key);
+  unsigned int h = hashval % size;
+  for (unsigned int i = 0; i <= size; ++i)
+  {
+    if (status[h] == EMPTYCELL)
+      return 0;
+    else if (status[h] == VALIDCELL && <T>EQ(key, tab[h]))
+      return Pix(&tab[h]);
+    if (i == 0)
+      h = (h + doublehashinc(hashval, size)) % size;
+    else if (++h >= size)
+      h -= size;
+  }
+  return 0;
+}
+
+
+<C>& <T><C>VHMap::operator [](<T&> item)
+{
+  if (size <= count + 1)
+    resize();
+
+  unsigned int bestspot = size;
+  unsigned int hashval = <T>HASH(item);
+  unsigned int h = hashval % size;
+  for (unsigned int i = 0; i <= size; ++i)
+  {
+    if (status[h] == EMPTYCELL)
+    {
+      ++count;
+      if (bestspot >= size) bestspot = h;
+      tab[bestspot] = item;
+      status[bestspot] = VALIDCELL;
+      cont[bestspot] = def;
+      return cont[bestspot];
+    }
+    else if (status[h] == DELETEDCELL)
+    {
+      if (bestspot >= size) bestspot = h;
+    }
+    else if (<T>EQ(tab[h],item))
+      return cont[h];
+
+    if (i == 0)
+      h = (h + doublehashinc(hashval, size)) % size;
+    else if (++h >= size)
+      h -= size;
+  }
+
+  ++count;
+  status[bestspot] = VALIDCELL;
+  tab[bestspot] = item;
+  cont[bestspot] = def;
+  return cont[bestspot];
+}
+
+
+void <T><C>VHMap::del(<T&> key)
+{
+  unsigned int hashval = <T>HASH(key);
+  unsigned int h = hashval % size;
+  for (unsigned int i = 0; i <= size; ++i)
+  {
+    if (status[h] == EMPTYCELL)
+      return;
+    else if (status[h] == VALIDCELL && <T>EQ(key, tab[h]))
+    {
+      status[h] = DELETEDCELL;
+      --count;
+      return;
+    }
+    if (i == 0)
+      h = (h + doublehashinc(hashval, size)) % size;
+    else if (++h >= size)
+      h -= size;
+  }
+}
+
+
+void <T><C>VHMap::clear()
+{
+  for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = 0;
+}
+
+void <T><C>VHMap::resize(unsigned int newsize)
+{
+  if (newsize <= count)
+  {
+    newsize = DEFAULT_INITIAL_CAPACITY;
+    while (newsize <= count) newsize <<= 1;
+  }
+  <T>* oldtab = tab;
+  <C>* oldcont = cont;
+  char* oldstatus = status;
+  unsigned int oldsize = size;
+  tab = new <T>[size = newsize];
+  cont = new <C>[size];
+  status = new char[size];
+  for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = 0;
+  for (i = 0; i < oldsize; ++i) 
+    if (oldstatus[i] == VALIDCELL) 
+      (*this)[oldtab[i]] = oldcont[i];
+  delete [oldsize] oldtab;
+  delete [oldsize] oldcont;
+  delete oldstatus;
+}
+
+Pix <T><C>VHMap::first()
+{
+  for (unsigned int pos = 0; pos < size; ++pos)
+    if (status[pos] == VALIDCELL) return Pix(&tab[pos]);
+  return 0;
+}
+
+void <T><C>VHMap::next(Pix& i)
+{
+  if (i == 0) return;
+  unsigned int pos = ((unsigned)i - (unsigned)tab) / sizeof(<T>) + 1;
+  for (; pos < size; ++pos)
+    if (status[pos] == VALIDCELL)
+    {
+      i = Pix(&tab[pos]);
+      return;
+    }
+  i = 0;
+}
+  
+
+int <T><C>VHMap::OK()
+{
+  int v = tab != 0;
+  v &= status != 0;
+  int n = 0;
+  for (unsigned int i = 0; i < size; ++i) 
+  {
+    if (status[i] == VALIDCELL) ++n;
+    else if (status[i] != DELETEDCELL && status[i] != EMPTYCELL)
+      v = 0;
+  }
+  v &= n == count;
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/VHMap.hP b/usr/include/g++/gen/VHMap.hP
new file mode 100644 (file)
index 0000000..b0b1ecc
--- /dev/null
@@ -0,0 +1,94 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T><C>VHMap_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T><C>VHMap_h 1
+
+#include "<T>.<C>.Map.h"
+
+
+class <T><C>VHMap : public <T><C>Map
+{
+protected:
+  <T>*           tab;
+  <C>*           cont;
+  char*          status;
+  unsigned int   size;
+
+public:
+                <T><C>VHMap(<C&> dflt,unsigned int sz=DEFAULT_INITIAL_CAPACITY);
+                <T><C>VHMap(<T><C>VHMap& a);
+                ~<T><C>VHMap();
+
+  <C>&          operator [] (<T&> key);
+
+  void          del(<T&> key);
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          key(Pix i);
+  <C>&          contents(Pix i);
+
+  Pix           seek(<T&> key);
+  int           contains(<T&> key);
+
+  void          clear(); 
+  void          resize(unsigned int newsize = 0);
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T><C>VHMap::~<T><C>VHMap()
+{
+  delete [size] tab;
+  delete [size] cont;
+  delete [size] status;
+}
+
+inline int <T><C>VHMap::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+inline <T>& <T><C>VHMap::key(Pix i)
+{
+  if (i == 0) error("null Pix");
+  return *((<T>*)i);
+}
+
+inline <C>& <T><C>VHMap::contents(Pix i)
+{
+  if (i == 0) error("null Pix");
+  return cont[((unsigned)(i) - (unsigned)(tab)) / sizeof(<T>)];
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/VHSet.ccP b/usr/include/g++/gen/VHSet.ccP
new file mode 100644 (file)
index 0000000..f93f135
--- /dev/null
@@ -0,0 +1,268 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.VHSet.h"
+
+/* codes for status fields */
+
+#define EMPTYCELL   0
+#define VALIDCELL   1
+#define DELETEDCELL 2
+
+
+<T>VHSet::<T>VHSet(unsigned int sz)
+{
+  tab = new <T>[size = sz];
+  status = new char[size];
+  for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = 0;
+}
+
+<T>VHSet::<T>VHSet(<T>VHSet& a)
+{
+  tab = new <T>[size = a.size];
+  status = new char[size];
+  for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = 0;
+  for (Pix p = a.first(); p; a.next(p)) add(a(p));
+}
+
+
+/* 
+ * hashing method: double hash based on high bits of hash fct,
+ * followed by linear probe. Can't do too much better if table
+ * sizes not constrained to be prime.
+*/
+
+
+static inline unsigned int doublehashinc(unsigned int h, unsigned int s)
+{
+  unsigned int dh =  ((h / s) % s);
+  return (dh > 1)? dh : 1;
+}
+
+Pix <T>VHSet::seek(<T&> key)
+{
+  unsigned int hashval = <T>HASH(key);
+  unsigned int h = hashval % size;
+  for (unsigned int i = 0; i <= size; ++i)
+  {
+    if (status[h] == EMPTYCELL)
+      return 0;
+    else if (status[h] == VALIDCELL && <T>EQ(key, tab[h]))
+      return Pix(&tab[h]);
+    if (i == 0)
+      h = (h + doublehashinc(hashval, size)) % size;
+    else if (++h >= size)
+      h -= size;
+  }
+  return 0;
+}
+
+
+Pix <T>VHSet::add(<T&> item)
+{
+  if (size <= count + 1)
+    resize();
+
+  unsigned int bestspot = size;
+  unsigned int hashval = <T>HASH(item);
+  unsigned int h = hashval % size;
+  for (unsigned int i = 0; i <= size; ++i)
+  {
+    if (status[h] == EMPTYCELL)
+    {
+      if (bestspot >= size) bestspot = h;
+      tab[bestspot] = item;
+      status[bestspot] = VALIDCELL;
+      ++count;
+      return Pix(&tab[bestspot]);
+    }
+    else if (status[h] == DELETEDCELL)
+    {
+      if (bestspot >= size) bestspot = h;
+    }
+    else if (<T>EQ(tab[h],item))
+      return Pix(&tab[h]);
+
+    if (i == 0)
+      h = (h + doublehashinc(hashval, size)) % size;
+    else if (++h >= size)
+      h -= size;
+  }
+  tab[bestspot] = item;
+  status[bestspot] = VALIDCELL;
+  ++count;
+  return Pix(&tab[bestspot]);
+
+}
+
+
+void <T>VHSet::del(<T&> key)
+{
+  unsigned int hashval = <T>HASH(key);
+  unsigned int h = hashval % size;
+  for (unsigned int i = 0; i <= size; ++i)
+  {
+    if (status[h] == EMPTYCELL)
+      return;
+    else if (status[h] == VALIDCELL && <T>EQ(key, tab[h]))
+    {
+      status[h] = DELETEDCELL;
+      --count;
+      return;
+    }
+    if (i == 0)
+      h = (h + doublehashinc(hashval, size)) % size;
+    else if (++h >= size)
+      h -= size;
+  }
+}
+
+
+void <T>VHSet::clear()
+{
+  for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = 0;
+}
+
+void <T>VHSet::resize(unsigned int newsize)
+{
+  if (newsize <= count)
+  {
+    newsize = DEFAULT_INITIAL_CAPACITY;
+    while (newsize <= count) newsize <<= 1;
+  }
+  <T>* oldtab = tab;
+  char* oldstatus = status;
+  unsigned int oldsize = size;
+  tab = new <T>[size = newsize];
+  status = new char[size];
+  for (unsigned int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = 0;
+  for (i = 0; i < oldsize; ++i) if (oldstatus[i] == VALIDCELL) add(oldtab[i]);
+  delete [oldsize] oldtab;
+  delete oldstatus;
+}
+
+Pix <T>VHSet::first()
+{
+  for (unsigned int pos = 0; pos < size; ++pos)
+    if (status[pos] == VALIDCELL) return Pix(&tab[pos]);
+  return 0;
+}
+
+void <T>VHSet::next(Pix& i)
+{
+  if (i == 0) return;
+  unsigned int pos = ((unsigned)i - (unsigned)tab) / sizeof(<T>) + 1;
+  for (; pos < size; ++pos)
+    if (status[pos] == VALIDCELL)
+    {
+      i = Pix(&tab[pos]);
+      return;
+    }
+  i = 0;
+}
+  
+int <T>VHSet:: operator == (<T>VHSet& b)
+{
+  if (count != b.count)
+    return 0;
+  else
+  {
+    for (unsigned int i = 0; i < size; ++i)
+      if (status[i] == VALIDCELL && b.seek(tab[i]) == 0)
+          return 0;
+    for (i = 0; i < b.size; ++i)
+      if (b.status[i] == VALIDCELL && seek(b.tab[i]) == 0)
+          return 0;
+    return 1;
+  }
+}
+
+int <T>VHSet::operator <= (<T>VHSet& b)
+{
+  if (count > b.count)
+    return 0;
+  else
+  {
+    for (unsigned int i = 0; i < size; ++i)
+      if (status[i] == VALIDCELL && b.seek(tab[i]) == 0)
+          return 0;
+    return 1;
+  }
+}
+
+void <T>VHSet::operator |= (<T>VHSet& b)
+{
+  if (&b == this || b.count == 0)
+    return;
+  for (unsigned int i = 0; i < b.size; ++i)
+    if (b.status[i] == VALIDCELL) add(b.tab[i]);
+}
+
+void <T>VHSet::operator &= (<T>VHSet& b)
+{
+  if (&b == this || count == 0)
+    return;
+  for (unsigned int i = 0; i < size; ++i)
+  {
+    if (status[i] == VALIDCELL && b.seek(tab[i]) == 0)
+    {
+      status[i] = DELETEDCELL;
+      --count;
+    }
+  }
+}
+
+void <T>VHSet::operator -= (<T>VHSet& b)
+{
+  for (unsigned int i = 0; i < size; ++i)
+  {
+    if (status[i] == VALIDCELL && b.seek(tab[i]) != 0)
+    {
+      status[i] = DELETEDCELL;
+      --count;
+    }
+  }
+}
+
+int <T>VHSet::OK()
+{
+  int v = tab != 0;
+  v &= status != 0;
+  int n = 0;
+  for (unsigned int i = 0; i < size; ++i) 
+  {
+    if (status[i] == VALIDCELL) ++n;
+    else if (status[i] != DELETEDCELL && status[i] != EMPTYCELL)
+      v = 0;
+  }
+  v &= n == count;
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/VHSet.hP b/usr/include/g++/gen/VHSet.hP
new file mode 100644 (file)
index 0000000..3ec4d52
--- /dev/null
@@ -0,0 +1,105 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>VHSet_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>VHSet_h 1
+
+#include "<T>.Set.h"
+
+
+
+class <T>VHSet : public <T>Set
+{
+protected:
+  <T>*          tab;
+  char*         status;
+  unsigned int  size;
+
+public:
+                <T>VHSet(unsigned int sz = DEFAULT_INITIAL_CAPACITY);
+                <T>VHSet(<T>VHSet& a);
+                ~<T>VHSet();
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  Pix           seek(<T&> item);
+
+  void          operator |= (<T>VHSet& b);
+  void          operator -= (<T>VHSet& b);
+  void          operator &= (<T>VHSet& b);
+
+  int           operator == (<T>VHSet& b);
+  int           operator != (<T>VHSet& b);
+  int           operator <= (<T>VHSet& b); 
+
+  int           capacity();
+  void          resize(unsigned int newsize = 0);
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>VHSet::~<T>VHSet()
+{
+  delete [size] tab;
+  delete status;
+}
+
+
+inline int <T>VHSet::capacity()
+{
+  return size;
+}
+
+inline int <T>VHSet::contains(<T&> key)
+{
+  return seek(key) != 0;
+}
+
+inline <T>& <T>VHSet::operator () (Pix i)
+{
+  if (i == 0) error("null Pix");
+  return *((<T>*)i);
+}
+
+inline int <T>VHSet::operator != (<T>VHSet& b)
+{
+  return ! ((*this) == b);
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/VOHSet.ccP b/usr/include/g++/gen/VOHSet.ccP
new file mode 100644 (file)
index 0000000..382e1e9
--- /dev/null
@@ -0,0 +1,313 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+     based on code by Doug Schmidt
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include "<T>.VOHSet.h"
+
+
+/* codes for status fields */
+#define EMPTYCELL   0
+#define VALIDCELL   1
+#define DELETEDCELL 2
+
+
+<T>VOHSet::<T>VOHSet(int sz)
+{
+// The size of the hash table is always the smallest power of 2 >= the size
+// indicated by the user.  This allows several optimizations, including
+// the use of actual double hashing and elimination of the mod instruction.
+
+  size = 1;
+  while (size < sz) size <<= 1;
+  tab = new <T>[size];
+  status = new char[size];
+  for (int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = cnt = 0;
+}
+
+<T>VOHSet::<T>VOHSet(<T>VOHSet& a)
+{
+  tab = new <T>[size = a.size];
+  status = new char[size];
+  for (int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = cnt = 0;
+  for (Pix p = a.first(); p; a.next(p)) add(a(p));
+}
+
+Pix <T>VOHSet::seek(<T&> key)
+{
+// Uses ordered double hashing to perform a search of the table.
+// This greatly speeds up the average-case time for an unsuccessful search.
+
+  unsigned hashval = <T>HASH(key);
+
+  // We can avoid the mod operation since size is a power of 2.
+  unsigned h = hashval & (size - 1);
+
+  // The increment must be odd, since all odd numbers are relatively
+  // prime to a power of 2!!
+  unsigned inc = ((((hashval / size) << 1) + 1) & (size - 1));
+  
+  // There is always at least 1 empty cell, so this loop is guaranteed to halt!
+  while (status[h] != EMPTYCELL)
+  {
+    int cmp = <T>CMP (key, tab[h]);
+    if (cmp == 0)
+    {
+      if (status[h] == VALIDCELL)
+        return Pix(&tab[h]);
+      else
+        return 0;
+    }
+    else if (cmp > 0)
+      return 0;
+    else
+      h = ((h + inc) & (size - 1));
+  }
+  return 0;
+}
+
+// This adds an item if it doesn't already exist.  By performing the initial
+// comparison we assure that the table always contains at least 1 empty
+// spot.  This speeds up later searching by a constant factor.
+// The insertion algorithm uses ordered double hashing.  See Standish's
+// 1980 ``Data Structure's Techniques'' book for details.
+
+Pix <T>VOHSet::add(<T&> x)
+{
+  if (size <= cnt+1) 
+    resize();
+  
+  unsigned hashval = <T>HASH(x);
+  unsigned h = hashval & (size - 1);
+
+  if (status[h] != VALIDCELL)   // save some work if possible
+  {
+    if (status[h] == EMPTYCELL)
+      cnt++;
+    count++;
+    tab[h] = x; 
+    status[h] = VALIDCELL; 
+    return Pix(&tab[h]);
+  }
+  int cmp = <T>CMP(x, tab[h]);
+  if (cmp == 0)
+    return Pix(&tab[h]);
+
+  <T> item = x;
+  Pix mypix = 0;
+  unsigned inc = ((((hashval / size) << 1) + 1) & (size - 1));
+
+  for (;;)
+  {
+    if (cmp < 0)
+    {
+      <T> temp = tab[h];
+      tab[h] = item;
+      item = temp;
+      if (mypix == 0) mypix = Pix(&tab[h]);
+      inc = ((((<T>HASH(item) / size) << 1) + 1) & (size - 1));
+      h = ((h + inc) & (size - 1));
+      cmp = <T>CMP(item, tab[h]);
+    }
+    else
+      h = ((h + inc) & (size - 1));
+    if (status[h] != VALIDCELL)
+    {
+      if (status[h] == EMPTYCELL)
+        cnt++;
+      count++;
+      tab[h] = item; 
+      status[h] = VALIDCELL; 
+      return (mypix == 0)? Pix(&tab[h]) : mypix;
+    }
+  }
+}
+
+
+void <T>VOHSet::del(<T&> key)
+{
+// This performs a deletion by marking the item's status field.
+// Note that we only decrease the count, *not* the cnt, since this
+// would cause trouble for subsequent steps in the algorithm.  See
+// Reingold and Hanson's ``Data Structure's'' book for a justification
+// of this approach.
+
+  unsigned hashval = <T>HASH(key);
+  unsigned h   = hashval & (size - 1);
+  unsigned inc = ((((hashval / size) << 1) + 1) & (size - 1));
+  
+  while (status[h] != EMPTYCELL)
+  {
+    int cmp = <T>CMP(key, tab[h]);
+    if (cmp < 0)
+      h = ((h + inc) & (size - 1));
+    else if (status[h] == VALIDCELL && cmp == 0)
+    {
+      status[h] = DELETEDCELL;
+      count--;
+      return;
+    }
+    else 
+      return;
+  }
+}
+
+void <T>VOHSet::clear()
+{
+  for (int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = cnt = 0;
+}
+
+void <T>VOHSet::resize(int newsize)
+{
+  if (newsize <= count)
+    newsize = count;
+  int s = 1;
+  while (s <= newsize) s <<= 1;
+  newsize = s;
+
+  <T>* oldtab = tab;
+  char* oldstatus = status;
+  int oldsize = size;
+  tab = new <T>[size = newsize];
+  status = new char[size];
+  for (int i = 0; i < size; ++i) status[i] = EMPTYCELL;
+  count = cnt = 0;
+  
+  for (i = 0; i < oldsize; ++i) if (oldstatus[i] == VALIDCELL) add(oldtab[i]);
+  delete [oldsize] oldtab;
+  delete oldstatus;
+}
+
+Pix <T>VOHSet::first()
+{
+  for (int pos = 0; pos < size; ++pos)
+    if (status[pos] == VALIDCELL) return Pix(&tab[pos]);
+  return 0;
+}
+
+void <T>VOHSet::next(Pix& i)
+{
+  if (i == 0) return;
+  int pos = ((unsigned)i - (unsigned)tab) / sizeof(<T>) + 1;
+  for (; pos < size; ++pos)
+    if (status[pos] == VALIDCELL)
+    {
+      i = Pix(&tab[pos]);
+      return;
+    }
+  i = 0;
+}
+
+
+int <T>VOHSet:: operator == (<T>VOHSet& b)
+{
+  if (count != b.count)
+    return 0;
+  else
+  {
+    for (int i = 0; i < size; ++i)
+      if (status[i] == VALIDCELL && b.seek(tab[i]) == 0)
+          return 0;
+    for (i = 0; i < b.size; ++i)
+      if (b.status[i] == VALIDCELL && seek(b.tab[i]) == 0)
+          return 0;
+    return 1;
+  }
+}
+
+int <T>VOHSet:: operator != (<T>VOHSet& b)
+{
+  return !(*this == b);
+}
+
+int <T>VOHSet::operator <= (<T>VOHSet& b)
+{
+  if (count > b.count)
+    return 0;
+  else
+  {
+    for (int i = 0; i < size; ++i)
+      if (status[i] == VALIDCELL && b.seek(tab[i]) == 0)
+          return 0;
+    return 1;
+  }
+}
+
+void <T>VOHSet::operator |= (<T>VOHSet& b)
+{
+  if (&b == this || b.count == 0)
+    return;
+  for (int i = 0; i < b.size; ++i)
+    if (b.status[i] == VALIDCELL) add(b.tab[i]);
+}
+
+void <T>VOHSet::operator &= (<T>VOHSet& b)
+{
+  if (&b == this || count == 0)
+    return;
+  for (int i = 0; i < size; ++i)
+  {
+    if (status[i] == VALIDCELL && b.seek(tab[i]) == 0)
+    {
+      status[i] = DELETEDCELL;
+      --count;
+    }
+  }
+}
+
+void <T>VOHSet::operator -= (<T>VOHSet& b)
+{
+  for (int i = 0; i < size; ++i)
+  {
+    if (status[i] == VALIDCELL && b.seek(tab[i]) != 0)
+    {
+      status[i] = DELETEDCELL;
+      --count;
+    }
+  }
+}
+
+int <T>VOHSet::OK()
+{
+  int v = tab != 0;
+  v &= status != 0;
+  int n = 0;
+  for (int i = 0; i < size; ++i) 
+  {
+    if (status[i] == VALIDCELL) ++n;
+    else if (status[i] != DELETEDCELL && status[i] != EMPTYCELL)
+      v = 0;
+  }
+  v &= n == count;
+  if (!v) error("invariant failure");
+  return v;
+}
+
+
+  
diff --git a/usr/include/g++/gen/VOHSet.hP b/usr/include/g++/gen/VOHSet.hP
new file mode 100644 (file)
index 0000000..6c71288
--- /dev/null
@@ -0,0 +1,97 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+     based on code by Doug Schmidt
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>VOHSet_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>VOHSet_h 1
+
+#include "<T>.Set.h"
+
+
+
+class <T>VOHSet : public <T>Set
+{
+  <T>*                  tab;
+  char*                 status;
+  int                   size;
+  int                   cnt; // keeps track of VALIDCELLs and DELETEDCELLs
+
+public:
+                        <T>VOHSet(int sz = DEFAULT_INITIAL_CAPACITY);
+                        <T>VOHSet(<T>VOHSet&);
+                        ~<T>VOHSet();
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  Pix           seek(<T&> item);
+
+  void          operator |= (<T>VOHSet& b);
+  void          operator -= (<T>VOHSet& b);
+  void          operator &= (<T>VOHSet& b);
+
+  int           operator == (<T>VOHSet& b);
+  int           operator != (<T>VOHSet& b);
+  int           operator <= (<T>VOHSet& b); 
+
+  int           capacity();
+  void          resize(int newsize = 0);
+
+  int           OK();
+};
+
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>VOHSet::~<T>VOHSet()
+{
+  delete [size] tab;
+  delete status;
+}
+
+
+inline int <T>VOHSet::contains(int  key)
+{
+  return seek(key) != 0;
+}
+
+
+inline <T>& <T>VOHSet::operator () (Pix p)
+{
+  if (p == 0) error("null Pix");
+  return *((<T>*)p);
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/VQueue.ccP b/usr/include/g++/gen/VQueue.ccP
new file mode 100644 (file)
index 0000000..7ffab10
--- /dev/null
@@ -0,0 +1,88 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include "<T>.VQueue.h"
+
+<T>VQueue::<T>VQueue(<T>VQueue& b)
+:size(b.size), cnt(b.cnt), inp(b.inp), outp(b.outp), s(new <T> [b.size])
+{
+  int j = outp;
+  for (int i = 0; i < cnt; ++i)
+  {
+    s[j] = b.s[j];
+    if (++j == size) j = 0;
+  }
+}
+
+void <T>VQueue::operator = (<T>VQueue& b)
+{
+  if (&b == this) return;
+  if (size != b.size)
+  {
+    delete [size] s;
+    s = new <T> [b.size];
+    size = b.size;
+  }
+  inp = b.inp; outp = b.outp; cnt = b.cnt;
+  int j = outp;
+  for (int i = 0; i < cnt; ++i)
+  {
+    s[j] = b.s[j];
+    if (++j == size) j = 0;
+  }
+}
+
+
+void <T>VQueue::resize(int newsz)
+{
+  if (newsz < cnt)
+    error("resize: new size too small");
+  <T>* news = new <T> [newsz];
+  int j = outp;
+  for (int i = 0; i < cnt; ++i)
+  {
+    news[i] = s[j];
+    if (++j == size) j = 0;
+  }
+  inp = j;
+  outp = 0;
+  delete [size] s;
+  s = news;
+  size = newsz;
+}
+
+int <T>VQueue::OK()
+{
+  int v = s != 0;               // have space
+  v &= size >= 0;               // a legal size
+  v &= inp >= 0 && inp <= size; // pointers with bounds  
+  v &= outp >= 0 && outp <= size;
+  int c = (size + inp - outp) % size;
+  v &= cnt == size || cnt == c; // correct count
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/VQueue.hP b/usr/include/g++/gen/VQueue.hP
new file mode 100644 (file)
index 0000000..66f58d8
--- /dev/null
@@ -0,0 +1,139 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>VQueue_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>VQueue_h 1
+
+#include "<T>.Queue.h"
+
+class <T>VQueue : public <T>Queue
+{
+protected:
+  int                   size;
+  int                   cnt;
+  int                   inp;
+  int                   outp;
+  <T>*                  s;
+
+public:
+
+                        <T>VQueue(int sz = DEFAULT_INITIAL_CAPACITY);
+                        <T>VQueue(<T>VQueue&);
+                        ~<T>VQueue();
+
+  void                  operator = (<T>VQueue&);
+
+  void                  enq(<T&> item);
+  <T>                   deq();
+  <T>&                  front();
+  void                  del_front();
+
+  int                   length();
+  int                   empty();
+  int                   full();
+
+  int                   capacity();
+  void                  resize(int sz);
+  void                  clear();
+
+  int                   OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>VQueue::<T>VQueue(int sz)
+{
+  s = new <T> [size = sz];
+  cnt = inp = outp = 0;
+}
+
+inline <T>VQueue::~<T>VQueue()
+{
+  delete [size] s;
+}
+
+inline void <T>VQueue::clear()
+{
+  inp = outp = 0;
+  cnt = 0;
+}
+
+inline int <T>VQueue::empty()
+{
+  return cnt <= 0;
+}
+
+inline int <T>VQueue::capacity()
+{
+  return size;
+}
+
+inline int <T>VQueue::full()
+{
+  return cnt >= size;
+}
+
+inline int <T>VQueue::length()
+{
+  return cnt;
+}
+
+inline void <T>VQueue::enq(<T&> item)
+{
+  if (cnt >= size) error("enq to full Queue.");
+  ++cnt;
+  s[inp] = item;
+  if (++inp == size) inp = 0;
+}
+
+inline <T> <T>VQueue::deq()
+{
+  if (cnt <= 0) error("deq from empty Queue.");
+  --cnt;
+  int i = outp;
+  if (++outp == size) outp = 0;
+  return s[i];
+}
+
+
+inline void <T>VQueue::del_front()
+{
+  if (cnt <= 0) error("delete from empty Queue.");
+  --cnt;
+  if (++outp == size) outp = 0;
+}
+
+inline <T>& <T>VQueue::front()
+{
+  if (empty()) error("top from empty Queue.");
+  return s[outp];
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/VStack.ccP b/usr/include/g++/gen/VStack.ccP
new file mode 100644 (file)
index 0000000..0404aa3
--- /dev/null
@@ -0,0 +1,71 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include "<T>.VStack.h"
+
+// error handling
+
+
+<T>VStack::<T>VStack(<T>VStack& b)
+:size(b.size), ptr(b.ptr), s(new <T> [b.size])
+{
+  for (int i = 0; i < ptr; ++i) s[i] = b.s[i];
+}
+
+void <T>VStack::operator = (<T>VStack& b)
+{
+  if (&b == this) return;
+  if (size < b.ptr)
+  {
+    delete [size] s;
+    s = new <T> [b.size];
+    size = b.size;
+  }
+  ptr = b.ptr;
+  for (int i = 0; i < ptr; ++i) s[i] = b.s[i];
+}
+
+
+void <T>VStack::resize(int newsz)
+{
+  if (newsz < ptr) error("resize: new size too small");
+  <T>* news = new <T> [newsz];
+  for (int i = 0; i < ptr; ++i) news[i] = s[i];
+  delete [size] s;
+  s = news;
+  size = newsz;
+}
+
+int <T>VStack::OK()
+{
+  int v = s != 0;               // have space
+  v &= size >= 0;               // a legal size
+  v &= ptr <= size;             // ptr within bounds
+  v &= ptr >= 0;
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/VStack.hP b/usr/include/g++/gen/VStack.hP
new file mode 100644 (file)
index 0000000..c41bcba
--- /dev/null
@@ -0,0 +1,128 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>VStack_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>VStack_h 1
+
+#include "<T>.Stack.h"
+
+class <T>VStack : public <T>Stack
+{
+protected:
+  int                   size;
+  int                   ptr;
+  <T>*                  s;
+
+public:
+
+                        <T>VStack(int sz = DEFAULT_INITIAL_CAPACITY);
+                        <T>VStack(<T>VStack&);
+                        ~<T>VStack();
+
+  void                  operator = (<T>VStack&);
+  void                  push(<T&> item);
+  <T>                   pop();
+  <T>&                  top();
+  void                  del_top();
+
+  int                   length();
+  int                   empty();
+  int                   full();
+  void                  clear();
+
+  void                  resize(int sz);
+  int                   capacity();
+
+  int                   OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>VStack::<T>VStack(int sz)
+{
+  s = new <T> [size = sz];
+  ptr = 0;
+}
+
+inline <T>VStack::~<T>VStack()
+{
+  delete [size] s;
+}
+
+inline void <T>VStack::clear()
+{
+  ptr = 0;
+}
+
+inline int <T>VStack::capacity()
+{
+  return size;
+}
+
+inline int <T>VStack::empty()
+{
+  return ptr == 0;
+}
+
+inline int <T>VStack::full()
+{
+  return ptr == size;
+}
+
+inline int <T>VStack::length()
+{
+  return ptr;
+}
+
+inline void <T>VStack::push(<T&> item)
+{
+  if (full()) error("push to full stack.");
+  s[ptr++] = item;
+}
+
+inline <T> <T>VStack::pop()
+{
+  if (empty()) error("pop from empty stack.");
+  return s[--ptr];
+}
+
+
+inline void <T>VStack::del_top()
+{
+  if (empty()) error("del_top from empty stack.");
+  --ptr;
+}
+
+inline <T>& <T>VStack::top()
+{
+  if (empty()) error("top from empty stack.");
+  return s[ptr-1];
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/Vec.ccP b/usr/include/g++/gen/Vec.ccP
new file mode 100644 (file)
index 0000000..381b7d6
--- /dev/null
@@ -0,0 +1,474 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include <stream.h>
+#include "<T>.Vec.h"
+
+// error handling
+
+
+void default_<T>Vec_error_handler(const char* msg)
+{
+  cerr << "Fatal <T>Vec error. " << msg << "\n";
+  exit(1);
+}
+
+one_arg_error_handler_t <T>Vec_error_handler = default_<T>Vec_error_handler;
+
+one_arg_error_handler_t set_<T>Vec_error_handler(one_arg_error_handler_t f)
+{
+  one_arg_error_handler_t old = <T>Vec_error_handler;
+  <T>Vec_error_handler = f;
+  return old;
+}
+
+void <T>Vec::error(const char* msg)
+{
+  (*<T>Vec_error_handler)(msg);
+}
+
+void <T>Vec::range_error()
+{
+  (*<T>Vec_error_handler)("Index out of range.");
+}
+
+<T>Vec::<T>Vec(<T>Vec& v)
+{
+  s = new <T> [len = v.len];
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  <T>* u = v.s;
+  while (t < top) *t++ = *u++;
+}
+
+<T>Vec::<T>Vec(int l, <T&> fill_value)
+{
+  s = new <T> [len = l];
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) *t++ = fill_value;
+}
+
+
+<T>Vec& <T>Vec::operator = (<T>Vec& v)
+{
+  if (this != &v)
+  {
+    delete[len] s;
+    s = new <T> [len = v.len];
+    <T>* top = &(s[len]);
+    <T>* t = s;
+    <T>* u = v.s;
+    while (t < top) *t++ = *u++;
+  }
+  return *this;
+}
+
+void <T>Vec::apply(<T>Procedure f)
+{
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) (*f)(*t++);
+}
+
+// can't just realloc since there may be need for constructors/destructors
+void <T>Vec::resize(int newl)
+{
+  <T>* news = new <T> [newl];
+  <T>* p = news;
+  int minl = (len < newl)? len : newl;
+  <T>* top = &(s[minl]);
+  <T>* t = s;
+  while (t < top) *p++ = *t++;
+  delete [len] s;
+  s = news;
+  len = newl;
+}
+
+<T>Vec concat(<T>Vec & a, <T>Vec & b)
+{
+  int newl = a.len + b.len;
+  <T>* news = new <T> [newl];
+  <T>* p = news;
+  <T>* top = &(a.s[a.len]);
+  <T>* t = a.s;
+  while (t < top) *p++ = *t++;
+  top = &(b.s[b.len]);
+  t = b.s;
+  while (t < top) *p++ = *t++;
+  return <T>Vec(newl, news);
+}
+
+
+<T>Vec combine(<T>Combiner f, <T>Vec& a, <T>Vec& b)
+{
+  int newl = (a.len < b.len)? a.len : b.len;
+  <T>* news = new <T> [newl];
+  <T>* p = news;
+  <T>* top = &(a.s[newl]);
+  <T>* t = a.s;
+  <T>* u = b.s;
+  while (t < top) *p++ = (*f)(*t++, *u++);
+  return <T>Vec(newl, news);
+}
+
+<T> <T>Vec::reduce(<T>Combiner f, <T&> base)
+{
+  <T> r = base;
+  <T>* top = &(s[len]);
+  <T>* t = s;
+  while (t < top) r = (*f)(r, *t++);
+  return r;
+}
+
+<T>Vec reverse(<T>Vec& a)
+{
+  <T>* news = new <T> [a.len];
+  if (a.len != 0)
+  {
+    <T>* lo = news;
+    <T>* hi = &(news[a.len - 1]);
+    while (lo < hi)
+    {
+      <T> tmp = *lo;
+      *lo++ = *hi;
+      *hi-- = tmp;
+    }
+  }
+  return <T>Vec(a.len, news);
+}
+
+void <T>Vec::reverse()
+{
+  if (len != 0)
+  {
+    <T>* lo = s;
+    <T>* hi = &(s[len - 1]);
+    while (lo < hi)
+    {
+      <T> tmp = *lo;
+      *lo++ = *hi;
+      *hi-- = tmp;
+    }
+  }
+}
+
+int <T>Vec::index(<T&> targ)
+{
+  for (int i = 0; i < len; ++i) if (targ == s[i]) return i;
+  return -1;
+}
+
+<T>Vec map(<T>Mapper f, <T>Vec& a)
+{
+  <T>* news = new <T> [a.len];
+  <T>* p = news;
+  <T>* top = &(a.s[a.len]);
+  <T>* t = a.s;
+  while(t < top) *p++ = (*f)(*t++);
+  return <T>Vec(a.len, news);
+}
+
+int operator == (<T>Vec& a, <T>Vec& b)
+{
+  if (a.len != b.len)
+    return 0;
+  <T>* top = &(a.s[a.len]);
+  <T>* t = a.s;
+  <T>* u = b.s;
+  while (t < top) if (*t++ != *u++) return 0;
+  return 1;
+}
+
+void <T>Vec::fill(<T&> val, int from, int n)
+{
+  int to;
+  if (n < 0)
+    to = len - 1;
+  else
+    to = from + n - 1;
+  if ((unsigned)from > to)
+    range_error();
+  <T>* t = &(s[from]);
+  <T>* top = &(s[to]);
+  while (t <= top) *t++ = val;
+}
+
+<T>Vec <T>Vec::at(int from, int n)
+{
+  int to;
+  if (n < 0)
+  {
+    n = len - from;
+    to = len - 1;
+  }
+  else
+    to = from + n - 1;
+  if ((unsigned)from > to)
+    range_error();
+  <T>* news = new <T> [n];
+  <T>* p = news;
+  <T>* t = &(s[from]);
+  <T>* top = &(s[to]);
+  while (t <= top) *p++ = *t++;
+  return <T>Vec(n, news);
+}
+
+<T>Vec merge(<T>Vec & a, <T>Vec & b, <T>Comparator f)
+{
+  int newl = a.len + b.len;
+  <T>* news = new <T> [newl];
+  <T>* p = news;
+  <T>* topa = &(a.s[a.len]);
+  <T>* as = a.s;
+  <T>* topb = &(b.s[b.len]);
+  <T>* bs = b.s;
+
+  for (;;)
+  {
+    if (as >= topa)
+    {
+      while (bs < topb) *p++ = *bs++;
+      break;
+    }
+    else if (bs >= topb)
+    {
+      while (as < topa) *p++ = *as++;
+      break;
+    }
+    else if ((*f)(*as, *bs) <= 0)
+      *p++ = *as++;
+    else
+      *p++ = *bs++;
+  }
+  return <T>Vec(newl, news);
+}
+
+static int gsort(<T>*, int, <T>Comparator);
+void <T>Vec::sort (<T>Comparator compar)
+{
+  gsort(s, len, compar);
+}
+
+
+// An adaptation og Schmidt's new quicksort
+
+static inline void SWAP(<T>* A, <T>* B)
+{
+  <T> tmp = *A; *A = *B; *B = tmp;
+}
+
+/* This should be replaced by a standard ANSI macro. */
+#define BYTES_PER_WORD 8
+#define BYTES_PER_LONG 4
+
+/* The next 4 #defines implement a very fast in-line stack abstraction. */
+
+#define STACK_SIZE (BYTES_PER_WORD * BYTES_PER_LONG)
+#define PUSH(LOW,HIGH) do {top->lo = LOW;top++->hi = HIGH;} while (0)
+#define POP(LOW,HIGH)  do {LOW = (--top)->lo;HIGH = top->hi;} while (0)
+#define STACK_NOT_EMPTY (stack < top)                
+
+/* Discontinue quicksort algorithm when partition gets below this size.
+   This particular magic number was chosen to work best on a Sun 4/260. */
+#define MAX_THRESH 4
+
+
+/* Order size using quicksort.  This implementation incorporates
+   four optimizations discussed in Sedgewick:
+   
+   1. Non-recursive, using an explicit stack of pointer that
+      store the next array partition to sort.  To save time, this
+      maximum amount of space required to store an array of
+      MAX_INT is allocated on the stack.  Assuming a 32-bit integer,
+      this needs only 32 * sizeof (stack_node) == 136 bits.  Pretty
+      cheap, actually.
+
+   2. Chose the pivot element using a median-of-three decision tree.
+      This reduces the probability of selecting a bad pivot value and 
+      eliminates certain extraneous comparisons.
+
+   3. Only quicksorts TOTAL_ELEMS / MAX_THRESH partitions, leaving
+      insertion sort to order the MAX_THRESH items within each partition.  
+      This is a big win, since insertion sort is faster for small, mostly
+      sorted array segements.
+   
+   4. The larger of the two sub-partitions is always pushed onto the
+      stack first, with the algorithm then concentrating on the
+      smaller partition.  This *guarantees* no more than log (n)
+      stack size is needed! */
+      
+static int gsort (<T> *base_ptr, int total_elems, <T>Comparator cmp)
+{
+/* Stack node declarations used to store unfulfilled partition obligations. */
+  struct stack_node {  <T> *lo;  <T> *hi; };
+  <T>   pivot_buffer;
+  int   max_thresh   = MAX_THRESH;
+
+  if (total_elems > MAX_THRESH)
+    {
+      <T>       *lo = base_ptr;
+      <T>       *hi = lo + (total_elems - 1);
+      <T>       *left_ptr;
+      <T>       *right_ptr;
+      stack_node stack[STACK_SIZE]; /* Largest size needed for 32-bit int!!! */
+      stack_node *top = stack + 1;
+
+      while (STACK_NOT_EMPTY)
+        {
+          {
+            <T> *pivot = &pivot_buffer;
+            {
+              /* Select median value from among LO, MID, and HI. Rearrange
+                 LO and HI so the three values are sorted. This lowers the 
+                 probability of picking a pathological pivot value and 
+                 skips a comparison for both the LEFT_PTR and RIGHT_PTR. */
+
+              <T> *mid = lo + ((hi - lo) >> 1);
+
+              if ((*cmp) (*mid, *lo) < 0)
+                SWAP (mid, lo);
+              if ((*cmp) (*hi, *mid) < 0)
+              {
+                SWAP (mid, hi);
+                if ((*cmp) (*mid, *lo) < 0)
+                  SWAP (mid, lo);
+              }
+              *pivot = *mid;
+              pivot = &pivot_buffer;
+            }
+            left_ptr  = lo + 1;
+            right_ptr = hi - 1; 
+
+            /* Here's the famous ``collapse the walls'' section of quicksort.  
+               Gotta like those tight inner loops!  They are the main reason 
+               that this algorithm runs much faster than others. */
+            do 
+              {
+                while ((*cmp) (*left_ptr, *pivot) < 0)
+                  left_ptr += 1;
+
+                while ((*cmp) (*pivot, *right_ptr) < 0)
+                  right_ptr -= 1;
+
+                if (left_ptr < right_ptr) 
+                  {
+                    SWAP (left_ptr, right_ptr);
+                    left_ptr += 1;
+                    right_ptr -= 1;
+                  }
+                else if (left_ptr == right_ptr) 
+                  {
+                    left_ptr += 1;
+                    right_ptr -= 1;
+                    break;
+                  }
+              } 
+            while (left_ptr <= right_ptr);
+
+          }
+
+          /* Set up pointers for next iteration.  First determine whether
+             left and right partitions are below the threshold size. If so, 
+             ignore one or both.  Otherwise, push the larger partition's
+             bounds on the stack and continue sorting the smaller one. */
+
+          if ((right_ptr - lo) <= max_thresh)
+            {
+              if ((hi - left_ptr) <= max_thresh) /* Ignore both small partitions. */
+                POP (lo, hi); 
+              else              /* Ignore small left partition. */  
+                lo = left_ptr;
+            }
+          else if ((hi - left_ptr) <= max_thresh) /* Ignore small right partition. */
+            hi = right_ptr;
+          else if ((right_ptr - lo) > (hi - left_ptr)) /* Push larger left partition indices. */
+            {                   
+              PUSH (lo, right_ptr);
+              lo = left_ptr;
+            }
+          else                  /* Push larger right partition indices. */
+            {                   
+              PUSH (left_ptr, hi);
+              hi = right_ptr;
+            }
+        }
+    }
+
+  /* Once the BASE_PTR array is partially sorted by quicksort the rest
+     is completely sorted using insertion sort, since this is efficient 
+     for partitions below MAX_THRESH size. BASE_PTR points to the beginning 
+     of the array to sort, and END_PTR points at the very last element in
+     the array (*not* one beyond it!). */
+
+
+  {
+    <T> *end_ptr = base_ptr + 1 * (total_elems - 1);
+    <T> *run_ptr;
+    <T> *tmp_ptr = base_ptr;
+    <T> *thresh  = (end_ptr < (base_ptr + max_thresh))? 
+      end_ptr : (base_ptr + max_thresh);
+
+    /* Find smallest element in first threshold and place it at the
+       array's beginning.  This is the smallest array element,
+       and the operation speeds up insertion sort's inner loop. */
+
+    for (run_ptr = tmp_ptr + 1; run_ptr <= thresh; run_ptr += 1)
+      if ((*cmp) (*run_ptr, *tmp_ptr) < 0)
+        tmp_ptr = run_ptr;
+
+    if (tmp_ptr != base_ptr)
+      SWAP (tmp_ptr, base_ptr);
+
+    /* Insertion sort, running from left-hand-side up to `right-hand-side.' 
+       Pretty much straight out of the original GNU qsort routine. */
+
+    for (run_ptr = base_ptr + 1; (tmp_ptr = run_ptr += 1) <= end_ptr; )
+      {
+
+        while ((*cmp) (*run_ptr, *(tmp_ptr -= 1)) < 0)
+          ;
+
+        if ((tmp_ptr += 1) != run_ptr)
+          {
+            <T> *trav;
+
+            for (trav = run_ptr + 1; --trav >= run_ptr;)
+              {
+                <T> c = *trav;
+                <T> *hi, *lo;
+
+                for (hi = lo = trav; (lo -= 1) >= tmp_ptr; hi = lo)
+                  *hi = *lo;
+                *hi = c;
+              }
+          }
+
+      }
+  }
+  return 1;
+}
diff --git a/usr/include/g++/gen/Vec.hP b/usr/include/g++/gen/Vec.hP
new file mode 100644 (file)
index 0000000..8addfd6
--- /dev/null
@@ -0,0 +1,142 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>Vec_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>Vec_h 1
+
+#ifndef _<T>_typedefs
+#define _<T>_typedefs 1
+typedef void (*<T>Procedure)(<T&>);
+typedef <T>  (*<T>Mapper)(<T&>);
+typedef <T>  (*<T>Combiner)(<T&>, <T&>);
+typedef int  (*<T>Predicate)(<T&>);
+typedef int  (*<T>Comparator)(<T&>, <T&>);
+#endif
+
+
+class <T>Vec 
+{
+protected:      
+  int                   len;
+  <T>                   *s;                  
+
+                        <T>Vec(int l, <T>* d);
+public:
+                        <T>Vec ();
+                        <T>Vec (int l);
+                        <T>Vec (int l, <T&> fill_value);
+                        <T>Vec (<T>Vec&);
+                        ~<T>Vec ();
+
+  <T>Vec &              operator = (<T>Vec & a);
+  <T>Vec                at(int from = 0, int n = -1);
+
+  int                   capacity();
+  void                  resize(int newlen);                        
+
+  <T>&                  operator [] (int n);
+  <T>&                  elem(int n);
+
+  friend <T>Vec         concat(<T>Vec & a, <T>Vec & b);
+  friend <T>Vec         map(<T>Mapper f, <T>Vec & a);
+  friend <T>Vec         merge(<T>Vec & a, <T>Vec & b, <T>Comparator f);
+  friend <T>Vec         combine(<T>Combiner f, <T>Vec & a, <T>Vec & b);
+  friend <T>Vec         reverse(<T>Vec & a);
+
+  void                  reverse();
+  void                  sort(<T>Comparator f);
+  void                  fill(<T&> val, int from = 0, int n = -1);
+
+  void                  apply(<T>Procedure f);
+  <T>                   reduce(<T>Combiner f, <T&> base);
+  int                   index(<T&> targ);
+
+  friend int            operator == (<T>Vec& a, <T>Vec& b);
+  friend int            operator != (<T>Vec& a, <T>Vec& b);
+
+  void                  error(const char* msg);
+  void                  range_error();
+};
+
+extern void default_<T>Vec_error_handler(const char*);
+extern one_arg_error_handler_t <T>Vec_error_handler;
+
+extern one_arg_error_handler_t 
+        set_<T>Vec_error_handler(one_arg_error_handler_t f);
+
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>Vec::<T>Vec()
+{
+  len = 0; s = 0;
+}
+
+inline <T>Vec::<T>Vec(int l)
+{
+  s = new <T> [len = l];
+}
+
+
+inline <T>Vec::<T>Vec(int l, <T>* d) :len(l), s(d) {}
+
+
+inline <T>Vec::~<T>Vec()
+{
+  delete[len] s;
+}
+
+
+inline <T>& <T>Vec::operator [] (int n)
+{
+  if ((unsigned)n >= len)
+    range_error();
+  return s[n];
+}
+
+inline <T>& <T>Vec::elem(int n)
+{
+  return s[n];
+}
+
+
+inline int <T>Vec::capacity()
+{
+  return len;
+}
+
+
+
+inline int operator != (<T>Vec& a, <T>Vec& b)
+{
+  return !(a == b);
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/XPBag.ccP b/usr/include/g++/gen/XPBag.ccP
new file mode 100644 (file)
index 0000000..59fa706
--- /dev/null
@@ -0,0 +1,77 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.XPBag.h"
+
+int <T>XPBag::OK()
+{
+  int v = p.OK();
+  v &= count == p.length();
+  if (!v) error("invariant failure");
+  return v;
+}
+
+Pix <T>XPBag::seek(<T&> item, Pix i)
+{
+  if (i == 0) i = p.first(); else next(i);
+  for (; i != 0; p.next(i)) if (<T>EQ(p(i), item)) return i;
+  return 0;
+}
+
+int <T>XPBag::nof(<T&> item)
+{
+  int n = 0;
+  for (int i = p.low(); i < p.fence(); p.next(i)) if (<T>EQ(p[i], item)) ++n;
+  return n;
+}
+
+void <T>XPBag::del(<T&> item)
+{
+  for (int i = p.low(); i < p.fence(); p.next(i))
+  {
+    if (<T>EQ(p[i], item))
+    {
+      --count;
+      p[i] = p.low_element();
+      p.del_low();
+      return;
+    }
+  }
+}
+
+void <T>XPBag::remove(<T&> item)
+{
+  for (int i = p.low(); i < p.fence(); p.next(i))
+  {
+    if (<T>EQ(p[i], item))
+    {
+      --count;
+      p[i] = p.low_element();
+      p.del_low();
+    }
+  }
+}
+
diff --git a/usr/include/g++/gen/XPBag.hP b/usr/include/g++/gen/XPBag.hP
new file mode 100644 (file)
index 0000000..4e8aad7
--- /dev/null
@@ -0,0 +1,105 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>XPBag_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>XPBag_h 1
+
+#include "<T>.Bag.h"
+#include "<T>.XPlex.h"
+
+class <T>XPBag : public <T>Bag
+{
+protected:
+  <T>XPlex              p;
+
+public:
+                <T>XPBag(int chunksize = DEFAULT_INITIAL_CAPACITY);
+                <T>XPBag(const <T>XPBag&);
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  void          remove(<T&>item);
+  int           nof(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  int           owns(Pix i);
+  Pix           seek(<T&> item, Pix from = 0);
+
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>XPBag::<T>XPBag(int chunksize) 
+     : p(chunksize) { count = 0; }
+
+inline <T>XPBag::<T>XPBag(const <T>XPBag& s) : p(s.p) { count = s.count; }
+
+inline Pix <T>XPBag::first()
+{
+  return p.first();
+}
+
+inline void <T>XPBag::next(Pix  & idx)
+{
+  p.next(idx);
+}
+
+inline <T>& <T>XPBag::operator ()(Pix   idx)
+{
+  return p(idx);
+}
+
+inline void <T>XPBag::clear()
+{
+  count = 0;  p.clear();
+}
+
+inline int <T>XPBag::owns (Pix   idx)
+{
+  return p.owns(idx);
+}
+
+inline Pix <T>XPBag::add(<T&> item)
+{
+  ++count;
+  return p.index_to_Pix(p.add_high(item));
+}
+
+inline int <T>XPBag::contains(<T&> item)
+{
+  return seek(item) != 0;
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/XPDeque.ccP b/usr/include/g++/gen/XPDeque.ccP
new file mode 100644 (file)
index 0000000..6b363d9
--- /dev/null
@@ -0,0 +1,4 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.XPDeque.h"
diff --git a/usr/include/g++/gen/XPDeque.hP b/usr/include/g++/gen/XPDeque.hP
new file mode 100644 (file)
index 0000000..528766a
--- /dev/null
@@ -0,0 +1,142 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>XPDeque_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>XPDeque_h
+
+#include "<T>.XPlex.h"
+#include "<T>.Deque.h"
+
+class <T>XPDeque : public <T>Deque
+{
+  <T>XPlex     p;
+
+public:
+               <T>XPDeque(int chunksize = DEFAULT_INITIAL_CAPACITY);
+               <T>XPDeque(const <T>XPDeque& d);
+               ~<T>XPDeque();
+
+  void          operator = (const <T>XPDeque&);
+
+  void          push(<T&> item); // insert at front
+  void          enq(<T&> item);  // insert at rear
+
+  <T>&          front();
+  <T>&          rear();
+
+  <T>           deq();
+  void          del_front();
+  void          del_rear();               
+
+  void          clear();
+  int           empty();
+  int           full();
+  int           length();
+               
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>XPDeque::<T>XPDeque(int chunksize) 
+     : p(chunksize) {}
+inline <T>XPDeque::<T>XPDeque(const <T>XPDeque& d) : p(d.p) {}
+
+inline <T>XPDeque::~<T>XPDeque() {}
+
+inline void <T>XPDeque::push(<T&>item)
+{
+  p.add_low(item);
+}
+
+inline void <T>XPDeque::enq(<T&>item)
+{
+  p.add_high(item);
+}
+
+inline <T> <T>XPDeque::deq()
+{
+  <T> res = p.low_element();
+  p.del_low();
+  return res;
+}
+
+inline <T>& <T>XPDeque::front()
+{
+  return p.low_element();
+}
+
+inline <T>& <T>XPDeque::rear()
+{
+  return p.high_element();
+}
+
+inline void <T>XPDeque::del_front()
+{
+  p.del_low();
+}
+
+inline void <T>XPDeque::del_rear()
+{
+  p.del_high();
+}
+
+inline void <T>XPDeque::operator =(const <T>XPDeque& s)
+{
+  p.operator = (s.p);
+}
+
+
+inline int <T>XPDeque::empty()
+{
+  return p.empty();
+}
+
+inline int <T>XPDeque::full()
+{
+  return p.full();
+}
+
+inline int <T>XPDeque::length()
+{
+  return p.length();
+}
+
+inline int <T>XPDeque::OK()
+{
+  return p.OK();
+}
+
+inline void <T>XPDeque::clear()
+{
+  p.clear();
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/XPPQ.ccP b/usr/include/g++/gen/XPPQ.ccP
new file mode 100644 (file)
index 0000000..f11731d
--- /dev/null
@@ -0,0 +1,148 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.XPPQ.h"
+
+int <T>XPPQ::OK()
+{
+  int v = p.OK();
+  v &= p.low() == 1;
+  v &= count == p.length();
+  if (!v) error("invariant failure");
+  return v;
+}
+
+Pix <T>XPPQ::seek(<T&> item)
+{
+  for (int i = p.low(); i < p.fence(); p.next(i))
+    if (<T>EQ(p[i],item)) return p.index_to_Pix(i);
+  return 0;
+}
+
+// standard 2-ary heap ops
+// pointers are used a lot to avoid thrashing across chunks with plexes
+
+Pix <T>XPPQ::enq(<T&> item)
+{
+  p.add_high(item);
+  <T>* pk = &(p.high_element());
+  int par = ++count >> 1;
+  while (par != 0)
+  {
+    <T>* ppar = &(p[par]);
+    if (!(<T>LE(*ppar, item)))
+    {
+      *pk = *ppar;
+      pk = ppar;
+      par >>= 1;
+    }
+    else
+      break;
+  }
+  *pk = item;
+  return Pix(pk);
+}
+
+void <T>XPPQ::del_front()
+{
+  if (count == 0) error("empty PQ");
+  --count;
+  <T>* pk = &(p.low_element());
+  <T>* ph = &(p.high_element());
+  int child = 2;
+  while (child <= count)
+  {
+    <T>* pchild = &(p[child]);
+    if (child < count)
+    {
+      <T>* prchild = &(p[child+1]);
+      if (!(<T>LE(*pchild, *prchild)))
+      {
+        pchild = prchild;
+        ++child;
+      }
+    }
+    if (!(<T>LE(*ph, *pchild)))
+    {
+      *pk = *pchild;
+      pk = pchild;
+      child <<= 1;
+    }
+    else
+      break;
+  }
+  *pk = *ph;
+  p.del_high();
+}
+
+
+void <T>XPPQ::del(Pix i)
+{
+  if (i == 0) error("null Pix");
+  --count;
+  int k = p.Pix_to_index(i);
+  <T>* pk = &(p[k]);
+  <T>* ph = &(p.high_element());
+  int child = k << 1;
+  while (child <= count)
+  {
+    <T>* pchild = &(p[child]);
+    if (child < count)
+    {
+      <T>* prchild = &(p[child+1]);
+      if (!(<T>LE(*pchild, *prchild)))
+      {
+        pchild = prchild;
+        ++child;
+      }
+    }
+    if (!(<T>LE(*ph, *pchild)))
+    {
+      *pk = *pchild;
+      pk = pchild;
+      child <<= 1;
+    }
+    else
+      break;
+  }
+  int par = child >> 2;
+  while (par != 0)
+  {
+    <T>* ppar = &(p[par]);
+    if (!(<T>LE(*ppar, *ph)))
+    {
+      *pk = *ppar;
+      pk = ppar;
+      par >>= 1;
+    }
+    else
+      break;
+  }
+  *pk = *ph;
+  p.del_high();
+}
+
+
diff --git a/usr/include/g++/gen/XPPQ.hP b/usr/include/g++/gen/XPPQ.hP
new file mode 100644 (file)
index 0000000..46cdfdb
--- /dev/null
@@ -0,0 +1,115 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>XPPQ_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>XPPQ_h 1
+
+#include "<T>.PQ.h"
+#include "<T>.XPlex.h"
+
+class <T>XPPQ : public <T>PQ
+{
+protected:
+  <T>XPlex              p;
+
+public:
+                <T>XPPQ(int chunksize = DEFAULT_INITIAL_CAPACITY);
+                <T>XPPQ(const <T>XPPQ&);
+
+  Pix           enq(<T&> item);
+  <T>           deq(); 
+
+  <T>&          front();
+  void          del_front();
+
+  int           contains(<T&> item);
+
+  void          clear(); 
+
+  Pix           first(); 
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  void          del(Pix i);
+  int           owns(Pix i);
+  Pix           seek(<T&> item);
+
+  int           OK();                    // rep invariant
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>XPPQ::<T>XPPQ(int chunksize) 
+     : p(1, chunksize) { count = 0; }
+
+inline <T>XPPQ::<T>XPPQ(const <T>XPPQ& s) : p(s.p) { count = s.count; }
+
+inline Pix <T>XPPQ::first()
+{
+  return p.first();
+}
+
+inline void <T>XPPQ::next(Pix  & idx)
+{
+  p.next(idx);
+}
+
+inline <T>& <T>XPPQ::operator ()(Pix   idx)
+{
+  return p(idx);
+}
+
+inline <T>& <T>XPPQ::front ()
+{
+  return p.low_element();
+}
+
+inline <T> <T>XPPQ::deq ()
+{
+  <T> x = p.low_element();
+  del_front();
+  return x;
+}
+
+inline void <T>XPPQ::clear()
+{
+  count = 0;  p.clear();
+}
+
+inline int <T>XPPQ::contains (<T&> item)
+{
+  return seek(item) != 0;
+}
+
+inline int <T>XPPQ::owns (Pix   idx)
+{
+  return p.owns(idx);
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/XPQueue.ccP b/usr/include/g++/gen/XPQueue.ccP
new file mode 100644 (file)
index 0000000..77bfd1c
--- /dev/null
@@ -0,0 +1,4 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.XPQueue.h"
diff --git a/usr/include/g++/gen/XPQueue.hP b/usr/include/g++/gen/XPQueue.hP
new file mode 100644 (file)
index 0000000..da070fd
--- /dev/null
@@ -0,0 +1,123 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>XPQueue_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>XPQueue_h
+
+#include "<T>.XPlex.h"
+#include "<T>.Queue.h"
+
+class <T>XPQueue : public <T>Queue
+{
+protected:
+  <T>XPlex     p;
+
+public:
+               <T>XPQueue(int chunksize = DEFAULT_INITIAL_CAPACITY);
+               <T>XPQueue(const <T>XPQueue& q);
+               ~<T>XPQueue();
+
+  void          operator = (const <T>XPQueue&);
+
+  void          enq(<T&> item);
+  <T>           deq();
+  <T>&          front();
+  void          del_front();
+
+  void          clear();
+  int           empty();
+  int           full();
+  int           length();
+               
+  int           OK();
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>XPQueue::<T>XPQueue(int chunksize) 
+     : p(chunksize) {}
+inline <T>XPQueue::<T>XPQueue(const <T>XPQueue& q) : p(q.p) {}
+
+inline <T>XPQueue::~<T>XPQueue() {}
+
+inline void <T>XPQueue::enq(<T&>item)
+{
+  p.add_high(item);
+}
+
+inline <T> <T>XPQueue::deq()
+{
+  <T> res = p.low_element();
+  p.del_low();
+  return res;
+}
+
+inline <T>& <T>XPQueue::front()
+{
+  return p.low_element();
+}
+
+
+inline void <T>XPQueue::del_front()
+{
+  p.del_low();
+}
+
+inline void <T>XPQueue::operator =(const <T>XPQueue& s)
+{
+  p.operator = (s.p);
+}
+
+inline int <T>XPQueue::empty()
+{
+  return p.empty();
+}
+
+inline int <T>XPQueue::full()
+{
+  return p.full();
+}
+
+inline int <T>XPQueue::length()
+{
+  return p.length();
+}
+
+inline int <T>XPQueue::OK()
+{
+  return p.OK();
+}
+
+inline void <T>XPQueue::clear()
+{
+  p.clear();
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/XPSet.ccP b/usr/include/g++/gen/XPSet.ccP
new file mode 100644 (file)
index 0000000..9774373
--- /dev/null
@@ -0,0 +1,68 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.XPSet.h"
+
+int <T>XPSet::OK()
+{
+  int v = p.OK();
+  v &= count == p.length();
+  if (!v) error("invariant failure");
+  return v;
+}
+
+Pix <T>XPSet::seek(<T&> item)
+{
+  for (int i = p.low(); i < p.fence(); p.next(i))
+    if (<T>EQ(p[i],item)) return p.index_to_Pix(i);
+  return 0;
+}
+
+Pix <T>XPSet::add(<T&> item)
+{
+  Pix i = seek(item);
+  if (i == 0)
+  {
+    ++count;
+    i = p.index_to_Pix(p.add_high(item));
+  }
+  return i;
+}
+
+void <T>XPSet::del(<T&> item)
+{
+  for (int i = p.low(); i < p.fence(); p.next(i))
+  {
+    if (<T>EQ(p[i], item))
+    {
+      --count;
+      p[i] = p.low_element();
+      p.del_low();
+      return;
+    }
+  }
+}
+
diff --git a/usr/include/g++/gen/XPSet.hP b/usr/include/g++/gen/XPSet.hP
new file mode 100644 (file)
index 0000000..5e06b81
--- /dev/null
@@ -0,0 +1,99 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>XPSet_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>XPSet_h 1
+
+#include "<T>.Set.h"
+#include "<T>.XPlex.h"
+
+class <T>XPSet : public <T>Set
+{
+protected:
+  <T>XPlex              p;
+
+public:
+                <T>XPSet(int chunksize = DEFAULT_INITIAL_CAPACITY);
+                <T>XPSet(const <T>XPSet&);
+
+  Pix           add(<T&> item);
+  void          del(<T&> item);
+  int           contains(<T&> item);
+
+  void          clear();
+
+  Pix           first();
+  void          next(Pix& i);
+  <T>&          operator () (Pix i);
+  int           owns(Pix i);
+  Pix           seek(<T&> item);
+
+  int           OK();
+};
+
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>XPSet::<T>XPSet(int chunksize) 
+     : p(chunksize) { count = 0; }
+
+inline <T>XPSet::<T>XPSet(const <T>XPSet& s) : p(s.p) { count = s.count; }
+
+inline Pix <T>XPSet::first()
+{
+  return p.first();
+}
+
+inline void <T>XPSet::next(Pix  & idx)
+{
+  p.next(idx);
+}
+
+inline <T>& <T>XPSet::operator ()(Pix   idx)
+{
+  return p(idx);
+}
+
+inline void <T>XPSet::clear()
+{
+  count = 0;  p.clear();
+}
+
+inline int <T>XPSet::contains (<T&> item)
+{
+  return seek(item) != 0;
+}
+
+inline int <T>XPSet::owns (Pix   idx)
+{
+  return p.owns(idx);
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/XPStack.ccP b/usr/include/g++/gen/XPStack.ccP
new file mode 100644 (file)
index 0000000..fe24f0f
--- /dev/null
@@ -0,0 +1,4 @@
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.XPStack.h"
diff --git a/usr/include/g++/gen/XPStack.hP b/usr/include/g++/gen/XPStack.hP
new file mode 100644 (file)
index 0000000..f0c1849
--- /dev/null
@@ -0,0 +1,124 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>XPStack_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>XPStack_h
+
+#include "<T>.XPlex.h"
+#include "<T>.Stack.h"
+
+class <T>XPStack : public <T>Stack
+{
+  <T>XPlex      p;
+
+public:
+                <T>XPStack(int chunksize = DEFAULT_INITIAL_CAPACITY);
+                <T>XPStack(const <T>XPStack& s);
+                ~<T>XPStack();
+
+  void          operator = (const <T>XPStack&);
+
+  void          push(<T&> item);
+  <T>           pop();
+  <T>&          top();               
+  void          del_top();
+
+  int           empty();
+  int           full();
+  int           length();
+
+  void          clear();
+
+  int           OK();
+
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline <T>XPStack::<T>XPStack(int chunksize) 
+     : p(chunksize) {}
+inline <T>XPStack::<T>XPStack(const <T>XPStack& s) : p(s.p) {}
+
+inline <T>XPStack::~<T>XPStack() {}
+
+inline void <T>XPStack::push(<T&>item)
+{
+  p.add_high(item);
+}
+
+inline <T> <T>XPStack::pop()
+{
+  <T> res = p.high_element();
+  p.del_high();
+  return res;
+}
+
+inline <T>& <T>XPStack::top()
+{
+  return p.high_element();
+}
+
+inline void <T>XPStack::del_top()
+{
+  p.del_high();
+}
+
+inline void <T>XPStack::operator =(const <T>XPStack& s)
+{
+  p.operator = (s.p);
+}
+
+inline int <T>XPStack::empty() 
+{
+  return p.empty();
+}
+
+inline int <T>XPStack::full() 
+{
+  return p.full();
+}
+
+inline int <T>XPStack::length() 
+{
+  return p.length();
+}
+
+inline int <T>XPStack::OK() 
+{
+  return p.OK();
+}
+
+inline void <T>XPStack::clear() 
+{
+  p.clear();
+}
+
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/XPlex.ccP b/usr/include/g++/gen/XPlex.ccP
new file mode 100644 (file)
index 0000000..2cef529
--- /dev/null
@@ -0,0 +1,412 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifdef __GNUG__
+#pragma implementation
+#endif
+#include "<T>.XPlex.h"
+
+
+<T>XPlex:: <T>XPlex()
+{
+  lo = fnc = 0;
+  csize = DEFAULT_INITIAL_CAPACITY;
+  <T>* data = new <T>[csize];
+  set_cache(new <T>IChunk(data,  lo, lo, fnc, lo+csize));
+  hd = ch;
+}
+
+<T>XPlex:: <T>XPlex(int chunksize)
+{
+  if (chunksize == 0) error("invalid constructor specification");
+  lo = fnc = 0;
+  if (chunksize > 0)
+  {
+    csize = chunksize;
+    <T>* data = new <T>[csize];
+    set_cache(new <T>IChunk(data,  lo, lo, fnc, csize));
+    hd = ch;
+  }
+  else
+  {
+    csize = -chunksize;
+    <T>* data = new <T>[csize];
+    set_cache(new <T>IChunk(data,  chunksize, lo, fnc, fnc));
+    hd = ch;
+  }
+}
+
+
+<T>XPlex:: <T>XPlex(int l, int chunksize)
+{
+  if (chunksize == 0) error("invalid constructor specification");
+  lo = fnc = l;
+  if (chunksize > 0)
+  {
+    csize = chunksize;
+    <T>* data = new <T>[csize];
+    set_cache(new <T>IChunk(data,  lo, lo, fnc, csize+lo));
+    hd = ch;
+  }
+  else
+  {
+    csize = -chunksize;
+    <T>* data = new <T>[csize];
+    set_cache(new <T>IChunk(data,  chunksize+lo, lo, fnc, fnc));
+    hd = ch;
+  }
+}
+
+void <T>XPlex::make_initial_chunks(int up)
+{
+  int need = fnc - lo;
+  hd = 0;
+  if (up)
+  {
+    int l = lo;
+    do
+    {
+      int sz;
+      if (need >= csize)
+        sz = csize;
+      else
+        sz = need;
+      <T>* data = new <T> [csize];
+      <T>IChunk* h = new <T>IChunk(data,  l, l, l+sz, l+csize);
+      if (hd != 0)
+        h->link_to_next(hd);
+      else
+        hd = h;
+      l += sz;
+      need -= sz;
+    } while (need > 0);
+  }
+  else
+  {
+    int hi = fnc;
+    do
+    {
+      int sz;
+      if (need >= csize)
+        sz = csize;
+      else
+        sz = need;
+      <T>* data = new <T> [csize];
+      <T>IChunk* h = new <T>IChunk(data,  hi-csize, hi-sz, hi, hi);
+      if (hd != 0)
+        h->link_to_next(hd);
+      hd = h;
+      hi -= sz;
+      need -= sz;
+    } while (need > 0);
+  }
+  set_cache(hd);
+}
+
+<T>XPlex:: <T>XPlex(int l, int hi, const <T&> initval, int chunksize)
+{
+  lo = l;
+  fnc = hi + 1;
+  if (chunksize == 0)
+  {
+    csize = fnc - l;
+    make_initial_chunks(1);
+  }
+  else if (chunksize < 0)
+  {
+    csize = -chunksize;
+    make_initial_chunks(0);
+  }
+  else
+  {
+    csize = chunksize;
+    make_initial_chunks(1);
+  }
+  fill(initval);
+}
+
+<T>XPlex::<T>XPlex(const <T>XPlex& a)
+{
+  lo = a.lo;
+  fnc = a.fnc;
+  csize = a.csize;
+  make_initial_chunks();
+  for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i];
+}
+
+void <T>XPlex::operator= (const <T>XPlex& a)
+{
+  if (&a != this)
+  {
+    invalidate();
+    lo = a.lo;
+    fnc = a.fnc;
+    csize = a.csize;
+    make_initial_chunks();
+    for (int i = a.low(); i < a.fence(); a.next(i)) (*this)[i] = a[i];
+  }
+}
+
+
+void <T>XPlex::cache(int idx) const
+{
+  const <T>IChunk* tail = tl();
+  const <T>IChunk* t = ch;
+  while (idx >= t->fence_index())
+  {
+    if (t == tail) index_error();
+    t = (t->next());
+  }
+  while (idx < t->low_index())
+  {
+    if (t == hd) index_error();
+    t = (t->prev());
+  }
+  set_cache(t);
+}
+
+
+void <T>XPlex::cache(const <T>* p) const
+{
+  const <T>IChunk* old = ch;
+  const <T>IChunk* t = ch;
+  while (!t->actual_pointer(p))
+  {
+    t = (t->next());
+    if (t == old) index_error();
+  }
+  set_cache(t);
+}
+
+int <T>XPlex::owns(Pix px) const
+{
+  <T>* p = (<T>*)px;
+  const <T>IChunk* old = ch;
+  const <T>IChunk* t = ch;
+  while (!t->actual_pointer(p))
+  {
+    t = (t->next());
+    if (t == old) { set_cache(t); return 0; }
+  }
+  set_cache(t);
+  return 1;
+}
+
+
+<T>* <T>XPlex::dosucc(const <T>* p) const
+{
+  if (p == 0) return 0;
+  const <T>IChunk* old = ch;
+  const <T>IChunk* t = ch;
+  while (!t->actual_pointer(p))
+  {
+    t = (t->next());
+    if (t == old)  return 0;
+  }
+  int i = t->index_of(p) + 1;
+  if (i >= fnc) return 0;
+  if (i >= t->fence_index()) t = (t->next());
+  set_cache(t);
+  return (t->pointer_to(i));
+}
+
+<T>* <T>XPlex::dopred(const <T>* p) const
+{
+  if (p == 0) return 0;
+  const <T>IChunk* old = ch;
+  const <T>IChunk* t = ch;
+  while (!t->actual_pointer(p))
+  {
+    t = (t->prev());
+    if (t == old) return 0;
+  }
+  int i = t->index_of(p) - 1;
+  if (i < lo) return 0;
+  if (i < t->low_index()) t = (t->prev());
+  set_cache(t);
+  return (t->pointer_to(i));
+}
+
+
+int <T>XPlex::add_high(const <T&> elem)
+{
+  <T>IChunk* t = tl();
+  if (!t->can_grow_high())
+  {
+    if (t-><T>IChunk::empty() && one_chunk())
+      t->clear(fnc);
+    else
+    {
+      <T>* data = new <T> [csize];
+      t = (new <T>IChunk(data,  fnc, fnc, fnc,fnc+csize));
+      t->link_to_prev(tl());
+    }
+  }
+  *((t-><T>IChunk::grow_high())) = elem;
+  set_cache(t);
+  return fnc++;
+}
+
+int <T>XPlex::del_high ()
+{
+  if (empty()) empty_error();
+  <T>IChunk* t = tl();
+  t-><T>IChunk::shrink_high();
+  if (t-><T>IChunk::empty() && !one_chunk())
+  {
+    <T>IChunk* pred = t->prev();
+    del_chunk(t);
+    t = pred;
+  }
+  set_cache(t);
+  return --fnc - 1;
+}
+
+int <T>XPlex::add_low (const <T&> elem)
+{
+  <T>IChunk* t = hd;
+  if (!t->can_grow_low())
+  {
+    if (t-><T>IChunk::empty() && one_chunk())
+      t->cleardown(lo);
+    else
+    {
+      <T>* data = new <T> [csize];
+      hd = new <T>IChunk(data,  lo-csize, lo, lo, lo);
+      hd->link_to_next(t);
+      t = hd;
+    }
+  }
+  *((t-><T>IChunk::grow_low())) = elem;
+  set_cache(t);
+  return --lo;
+}
+
+
+int <T>XPlex::del_low ()
+{
+  if (empty()) empty_error();
+  <T>IChunk* t = hd;
+  t-><T>IChunk::shrink_low();
+  if (t-><T>IChunk::empty() && !one_chunk())
+  {
+    hd = t->next();
+    del_chunk(t);
+    t = hd;
+  }
+  set_cache(t);
+  return ++lo;
+}
+
+void <T>XPlex::append (const <T>XPlex& a)
+{
+  for (int i = a.low(); i < a.fence(); a.next(i)) add_high(a[i]);
+}
+
+void <T>XPlex::prepend (const <T>XPlex& a)
+{
+  for (int i = a.high(); i > a.ecnef(); a.prev(i)) add_low(a[i]);
+}
+
+void <T>XPlex::reverse()
+{
+  <T> tmp;
+  int l = lo;
+  int h = fnc - 1;
+  <T>IChunk* loch = hd;
+  <T>IChunk* hich = tl();
+  while (l < h)
+  {
+    <T>* lptr = loch->pointer_to(l);
+    <T>* hptr = hich->pointer_to(h);
+    tmp = *lptr;
+    *lptr = *hptr;
+    *hptr = tmp;
+    if (++l >= loch->fence_index()) loch = loch->next();
+    if (--h < hich->low_index()) hich = hich->prev();
+  }
+}
+
+void <T>XPlex::fill(const <T&> x)
+{
+  for (int i = lo; i < fnc; ++i) (*this)[i] = x;
+}
+
+void <T>XPlex::fill(const <T&> x, int l, int hi)
+{
+  for (int i = l; i <= hi; ++i) (*this)[i] = x;
+}
+
+
+void <T>XPlex::clear()
+{
+  if (fnc != lo)
+  {
+    <T>IChunk* t = tl();
+    while (t != hd)
+    {
+      <T>IChunk* prv = t->prev();
+      del_chunk(t);
+      t = prv;
+    }
+    t-><T>IChunk::clear(lo);
+    set_cache(t);
+    fnc = lo;
+  }
+}
+
+
+int <T>XPlex::OK () const
+{
+  int v = hd != 0 && ch != 0;     // at least one chunk
+
+  v &= fnc == tl()->fence_index();// last chunk fence == plex fence
+  v &= lo == ((hd))-><T>IChunk::low_index();    // first lo == plex lo
+
+// loop for others:
+  int found_ch = 0;                   // to make sure ch is in list;
+  const <T>IChunk* t = (hd);
+  for (;;)
+  {
+    if (t == ch) ++found_ch;
+    v &= t-><T>IChunk::OK();              // each chunk is OK
+    if (t == tl())
+      break;
+    else                              // and has indices contiguous to succ
+    {
+      v &= t->top_index() == t->next()->base_index();
+      if (t != hd)                  // internal chunks full
+      {
+        v &= !t->empty();
+        v &= !t->can_grow_low();
+        v &= !t->can_grow_high();
+      }
+      t = t->next();
+    }
+  }
+  v &= found_ch == 1;
+  if (!v) error("invariant failure");
+  return v;
+}
diff --git a/usr/include/g++/gen/XPlex.hP b/usr/include/g++/gen/XPlex.hP
new file mode 100644 (file)
index 0000000..41acef7
--- /dev/null
@@ -0,0 +1,248 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+    based on code by Marc Shapiro (shapiro@sor.inria.fr)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _<T>XPlex_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _<T>XPlex_h 1
+
+#include "<T>.Plex.h"
+
+class <T>XPlex: public <T>Plex
+{
+  <T>IChunk*       ch;           // cached chunk
+
+  void             make_initial_chunks(int up = 1);
+
+  void             cache(int idx) const;
+  void             cache(const <T>* p) const;
+
+  <T>*             dopred(const <T>* p) const;
+  <T>*             dosucc(const <T>* p) const;
+
+  void             set_cache(const <T>IChunk* t) const; // logically, 
+                                               // not physically const
+public:
+                   <T>XPlex();                 // set low = 0;
+                                               // fence = 0;
+                                               // csize = default
+
+                   <T>XPlex(int ch_size);      // low = 0; 
+                                               // fence = 0;
+                                               // csize = ch_size
+
+                   <T>XPlex(int lo,            // low = lo; 
+                            int ch_size);      // fence=lo
+                                               // csize = ch_size
+
+                   <T>XPlex(int lo,            // low = lo
+                            int hi,            // fence = hi+1
+                            const <T&> initval,// fill with initval,
+                            int ch_size = 0);  // csize= ch_size
+                                               // or fence-lo if 0
+
+                   <T>XPlex(const <T>XPlex&);
+  
+  void             operator= (const <T>XPlex&);
+
+// virtuals
+
+
+  <T>&             high_element ();
+  <T>&             low_element ();
+
+  const <T>&       high_element () const;
+  const <T>&       low_element () const;
+
+  Pix              first() const;
+  Pix              last() const;
+  void             prev(Pix& ptr) const;
+  void             next(Pix& ptr) const;
+  int              owns(Pix p) const;
+  <T>&             operator () (Pix p);
+  const <T>&       operator () (Pix p) const;
+
+  int              low() const; 
+  int              high() const;
+  int              valid(int idx) const;
+  void             prev(int& idx) const;
+  void             next(int& x) const;
+  <T>&             operator [] (int index);
+  const <T>&       operator [] (int index) const;
+    
+  int              Pix_to_index(Pix p) const;
+  Pix              index_to_Pix(int idx) const;    
+
+  int              can_add_high() const;
+  int              can_add_low() const;
+  int              full() const;
+
+  int              add_high(const <T&> elem);
+  int              del_high ();
+  int              add_low (const <T&> elem);
+  int              del_low ();
+
+  void             fill(const <T&> x);
+  void             fill(const <T&> x, int from, int to);
+  void             clear();
+  void             reverse();
+  void             append(const <T>XPlex& a); 
+  void             prepend(const <T>XPlex& a);
+    
+  int              OK () const; 
+
+};
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+inline void <T>XPlex::prev(int& idx) const
+{
+  --idx;
+}
+
+inline void <T>XPlex::next(int& idx) const
+{
+  ++idx;
+}
+
+inline  int <T>XPlex::full () const
+{
+  return 0;
+}
+
+inline int <T>XPlex::can_add_high() const
+{
+  return 1;
+}
+
+inline int <T>XPlex::can_add_low() const
+{
+  return 1;
+}
+
+inline  int <T>XPlex::valid (int idx) const
+{
+  return idx >= lo && idx < fnc;
+}
+
+inline int <T>XPlex::low() const
+{
+  return lo;
+}
+
+inline int <T>XPlex::high() const
+{
+  return fnc - 1;
+}
+
+inline <T>& <T>XPlex:: operator [] (int idx)
+{
+  if (!ch->actual_index(idx)) cache(idx);
+  return *(ch->pointer_to(idx));
+}
+
+inline const <T>& <T>XPlex:: operator [] (int idx) const
+{
+  if (!ch->actual_index(idx)) cache(idx);
+  return *((const <T>*)(ch->pointer_to(idx)));
+}
+
+inline  <T>& <T>XPlex::low_element ()
+{
+  if (empty()) index_error();
+  return *(hd->pointer_to(lo));
+}
+
+inline  const <T>& <T>XPlex::low_element () const
+{
+  if (empty()) index_error();
+  return *((const <T>*)(hd->pointer_to(lo)));
+}
+
+inline  <T>& <T>XPlex::high_element ()
+{
+  if (empty()) index_error();
+  return *(tl()->pointer_to(fnc - 1));
+}
+
+inline const <T>& <T>XPlex::high_element () const
+{
+  if (empty()) index_error();
+  return *((const <T>*)(tl()->pointer_to(fnc - 1)));
+}
+
+inline  int <T>XPlex::Pix_to_index(Pix px) const
+{
+  <T>* p = (<T>*)px;
+  if (!ch->actual_pointer(p)) cache(p);
+  return ch->index_of(p);
+}
+
+inline  Pix <T>XPlex::index_to_Pix(int idx) const
+{
+  if (!ch->actual_index(idx)) cache(idx);
+  return (Pix)(ch->pointer_to(idx));
+}
+
+inline Pix <T>XPlex::first() const
+{
+  return Pix(hd-><T>IChunk::first_pointer());
+}
+
+inline Pix <T>XPlex::last() const
+{
+  return Pix(tl()-><T>IChunk::last_pointer());
+}
+
+inline void <T>XPlex::prev(Pix& p) const
+{
+  Pix q = Pix(ch-><T>IChunk::pred((<T>*) p));
+  p = (q == 0)? Pix(dopred((const <T>*) p)) : q;
+}
+
+inline void <T>XPlex::next(Pix& p) const
+{
+  Pix q = Pix(ch-><T>IChunk::succ((<T>*) p));
+  p = (q == 0)? Pix(dosucc((const <T>*)p)) : q;
+}
+
+inline <T>& <T>XPlex:: operator () (Pix p)
+{
+  return *((<T>*)p);
+}
+
+inline const <T>& <T>XPlex:: operator () (Pix p) const
+{
+  return *((const <T>*)p);
+}
+
+inline void <T>XPlex::set_cache(const <T>IChunk* t) const
+{
+  ((<T>XPlex*)(this))->ch = (<T>IChunk*)t;
+}
+
+#endif
+#endif
diff --git a/usr/include/g++/gen/defs.hP b/usr/include/g++/gen/defs.hP
new file mode 100644 (file)
index 0000000..4efc82d
--- /dev/null
@@ -0,0 +1,60 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _<T>defs_h
+#ifdef __GNUG__
+#pragma once
+#endif
+#define _<T>defs_h 1
+
+
+// equality operator
+#ifndef <T>EQ
+#define <T>EQ(a, b)  ((a) == (b))
+#endif
+
+// less-than-or-equal
+#ifndef <T>LE
+#define <T>LE(a, b)  ((a) <= (b))
+#endif
+
+// comparison : less-than -> < 0; equal -> 0; greater-than -> > 0
+#ifndef <T>CMP
+#define <T>CMP(a, b) ( ((a) <= (b))? (((a) == (b))? 0 : -1) : 1 )
+#endif
+
+// hash function
+#ifndef <T>HASH
+extern unsigned int hash(<T&>);
+#define <T>HASH(x)  hash(x)
+#endif
+
+// initial capacity for structures requiring one
+
+#ifndef DEFAULT_INITIAL_CAPACITY
+#define DEFAULT_INITIAL_CAPACITY 100
+#endif
+
+
+#endif
diff --git a/usr/include/g++/generic.h b/usr/include/g++/generic.h
new file mode 100644 (file)
index 0000000..743a26d
--- /dev/null
@@ -0,0 +1,63 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef generic_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define generic_h 1
+
+/*
+ *     See the CPP manual, argument prescan section for explanation
+ */
+
+#define name2(a,b) gEnErIc2(a,b)
+#define gEnErIc2(a,b) a ## b
+
+#define name3(a,b,c) gEnErIc3(a,b,c)
+#define gEnErIc3(a,b,c) a ## b ## c
+
+#define name4(a,b,c,d) gEnErIc4(a,b,c,d)
+#define gEnErIc4(a,b,c,d) a ## b ## c ## d
+
+#define GENERIC_STRING(a) gEnErIcStRiNg(a)
+#define gEnErIcStRiNg(a) #a
+
+#define declare(clas,t)        name2(clas,declare)(t)
+#define declare2(clas,t1,t2)   name2(clas,declare2)(t1,t2)
+
+#define implement(clas,t)      name2(clas,implement)(t)
+#define implement2(clas,t1,t2) name2(clas,implement2)(t1,t2)
+
+extern genericerror(int,char*);
+typedef int (*GPT)(int,char*);
+
+#define set_handler(gen,type,x) name4(set_,type,gen,_handler)(x)
+
+#define errorhandler(gen,type)  name3(type,gen,handler)
+
+#define callerror(gen,type,a,b) (*errorhandler(gen,type))(a,b)
+
+
+#endif generic_h
diff --git a/usr/include/g++/istream.h b/usr/include/g++/istream.h
new file mode 100644 (file)
index 0000000..1fa10fe
--- /dev/null
@@ -0,0 +1,259 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1989 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+/* *** Version 1.2 -- nearly 100% AT&T 1.2 compatible *** */
+
+/* istream.h now separately includable */
+
+#ifndef _istream_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _istream_h 1
+
+
+#include <File.h>
+#include <streambuf.h>
+#include <filebuf.h>
+#include <Filebuf.h>
+
+class whitespace                // a class used only to input and
+{                               // discard white space characters
+  char filler;                     
+};
+
+class ostream;
+
+class istream
+{
+  friend void   eatwhite(istream& s);
+protected:
+  streambuf*    bp;
+  state_value   state;           // _good/_eof/_fail/_bad
+  ostream*      tied_to;
+  char          skipws;
+  char          ownbuf;
+  void          _flush();
+  char*         readline (int chunk_number, char terminator);
+  
+public:
+                istream(const char* filename, io_mode m, access_mode a, 
+                        int sk=1, ostream* t = 0);
+                istream(const char* filename, const char* m, 
+                        int sk=1, ostream* t = 0);
+                istream(int filedesc, io_mode m, int sk=1, ostream* t = 0);
+                istream(FILE* fileptr, int sk=1, ostream* t = 0);
+                istream(int sz, char* buf, int sk=1, ostream* t = 0);
+                istream(int filedesc, int sk=1, ostream* t = 0);
+                istream(int filedesc, char* buf, int buflen, 
+                        int sk, ostream* t = 0);
+                istream(streambuf* s, int sk=1, ostream* t = 0);
+
+               ~istream();
+
+  istream&      open(const char* filename, io_mode m, access_mode a);
+  istream&      open(const char* filename, const char* m);
+  istream&      open(int  filedesc, io_mode m);
+  istream&      open(FILE* fileptr);
+  istream&      open(const char* filenam, open_mode m);
+
+  istream&      close();
+
+  ostream*      tie(ostream* s);
+  int           skip(int);
+
+// stream status
+
+  int           rdstate();
+  int           eof();
+  int           fail();
+  int           bad();
+  int           good();
+
+// other status queries
+
+  int           readable();
+  int           writable();
+  int           is_open();
+
+                operator void*();
+  int           operator !();
+
+  const char*   name();
+
+  char*         bufptr();
+
+// error handling
+
+  void          error();
+  void          clear(state_value f = _good); // poorly named
+  void          set(state_value f); // set corresponding bit
+  void          unset(state_value f); // clear corresponding bit
+  istream&      failif(int cond);
+
+// unformatted IO
+
+  istream&      get(char& c);
+  istream&      unget(char c);
+  istream&      putback(char c); // a synonym for unget
+
+  istream&      get    (char* s, int n, char terminator = '\n');
+  istream&      getline(char* s, int n, char terminator = '\n');
+  istream&      gets   (char **s, char terminator = '\n');
+
+
+  istream&      operator >> (char&   c);
+  istream&      operator >> (short&  n);
+  istream&      operator >> (unsigned short& n);
+  istream&      operator >> (int&    n);
+  istream&      operator >> (unsigned int& n);
+  istream&      operator >> (long&   n);
+  istream&      operator >> (unsigned long& n);
+#ifdef __GNUG__
+  istream&      operator >> (long long& n);
+  istream&      operator >> (unsigned long long& n);
+#endif
+  istream&      operator >> (float&  n);
+  istream&      operator >> (double& n);
+  istream&      operator >> (char*   s);
+  istream&      operator >> (whitespace& w);
+};
+
+// pre-declared streams
+
+extern istream  cin;             // stdin
+
+extern whitespace WS;            // for convenience
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+
+inline void istream::clear(state_value flag)
+{
+  state = flag;
+}
+
+inline void istream::set(state_value flag)
+{
+  state = state_value(int(state) | int(flag));
+}
+
+inline void istream::unset(state_value flag)
+{
+  state = state_value(int(state) & ~int(flag));
+}
+
+inline int istream::rdstate()
+{
+  return int(state);
+}
+
+inline int istream::good()
+{
+  return state == _good;
+}
+
+inline int istream::eof()
+{
+  return int(state) & int(_eof);
+}
+
+inline int istream::fail()
+{
+  return int(state) & int(_fail);
+}
+
+inline int istream::bad()
+{
+  return int(state) & int(_bad);
+}
+
+inline istream::operator void*()
+{
+  return (state == _good)? this : 0;
+}
+
+inline int istream::operator !()
+{
+  return (state != _good);
+}
+
+inline istream& istream::failif(int cond)
+{
+  if (cond) set(_fail); return *this;
+}
+
+inline int istream::is_open()
+{
+  return bp->is_open();
+}
+
+inline int istream::readable()
+{
+  return (bp != 0) && (bp->is_open()) && (state == _good);
+}
+
+inline int istream::writable()
+{
+  return 0;
+}
+
+
+inline char* istream::bufptr()
+{
+  return bp->base;
+}
+
+
+inline istream& istream::close()
+{
+  bp->close();  return *this;
+}
+
+
+inline int istream::skip(int sk)
+{
+  int was = skipws; skipws = sk; return was;
+}
+
+
+inline istream& istream::unget(char c)
+{
+  if (bp->sputbackc(c) == EOF) set(_fail); return *this;
+}
+
+inline istream& istream::putback(char c)
+{
+  if (bp->sputbackc(c) == EOF) set(_fail); return *this;
+}
+
+inline void eatwhite(istream& s)
+{
+  s >> WS;
+}
+
+#endif
+
+
+#endif
diff --git a/usr/include/g++/malloc.h b/usr/include/g++/malloc.h
new file mode 100644 (file)
index 0000000..dff79ed
--- /dev/null
@@ -0,0 +1 @@
+#include <std.h>
diff --git a/usr/include/g++/max.h b/usr/include/g++/max.h
new file mode 100644 (file)
index 0000000..8c2c8f9
--- /dev/null
@@ -0,0 +1 @@
+#include <builtin.h>
diff --git a/usr/include/g++/min.h b/usr/include/g++/min.h
new file mode 100644 (file)
index 0000000..8c2c8f9
--- /dev/null
@@ -0,0 +1 @@
+#include <builtin.h>
diff --git a/usr/include/g++/minmax.h b/usr/include/g++/minmax.h
new file mode 100644 (file)
index 0000000..8c2c8f9
--- /dev/null
@@ -0,0 +1 @@
+#include <builtin.h>
diff --git a/usr/include/g++/new.h b/usr/include/g++/new.h
new file mode 100644 (file)
index 0000000..95d86e0
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef _new_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _new_h 1
+
+#include <stddef.h>
+#include <std.h>
+
+#ifndef NO_LIBGXX_MALLOC
+#define MALLOC_ALIGN_MASK   7 /* ptrs aligned at 8 byte boundaries */
+#define MALLOC_MIN_OVERHEAD 8 /* 8 bytes of overhead per pointer */
+#endif
+
+typedef void (*new_handler_t)();
+extern "C" void default_new_handler();
+extern "C" new_handler_t set_new_handler(new_handler_t);
+
+#ifdef __GNUG__
+#define NEW(where) new { where }
+#endif
+
+// default placement version of operator new
+static inline void *operator new(size_t, void *place) { return place; }
+
+// provide a C++ interface to vector-resize via realloc 
+static inline void *operator new(size_t size, void *ptr, size_t new_len)
+{
+  return realloc(ptr, new_len * size);
+}
+
+#endif
diff --git a/usr/include/g++/open.h b/usr/include/g++/open.h
new file mode 100644 (file)
index 0000000..ffe81a1
--- /dev/null
@@ -0,0 +1,39 @@
+
+#ifndef _open_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _open_h 1
+
+#include <File.h>
+#include <sys/file.h>           // needed to determine values of O_RDONLY...
+
+/*
+
+ translation stuff for opening files. 
+
+*/
+
+
+enum sys_open_cmd_io_mode  // These should be correct for most systems
+{                        
+  sio_read      = O_RDONLY,
+  sio_write     = O_WRONLY,
+  sio_readwrite = O_RDWR,
+  sio_append    = O_APPEND
+};
+
+enum sys_open_cmd_access_mode
+{
+  sa_create     = O_CREAT,
+  sa_truncate   = O_TRUNC,
+  sa_createonly = O_EXCL | O_CREAT
+};
+
+  
+int open_cmd_arg(io_mode i, access_mode a); // decode modes
+char* fopen_cmd_arg(io_mode i);
+int open_cmd_arg(const char* m);
+
+#endif
diff --git a/usr/include/g++/osfcn.h b/usr/include/g++/osfcn.h
new file mode 100644 (file)
index 0000000..52b3063
--- /dev/null
@@ -0,0 +1,4 @@
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
diff --git a/usr/include/g++/ostream.h b/usr/include/g++/ostream.h
new file mode 100644 (file)
index 0000000..3bf30d7
--- /dev/null
@@ -0,0 +1,256 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1989 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+/* *** Version 1.2 -- nearly 100% AT&T 1.2 compatible *** */
+
+/* ostream.h now  separately includable */
+
+#ifndef _ostream_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _ostream_h 1
+
+/* uncomment the next line to disable    ostream << char */
+//#define NO_OUTPUT_CHAR
+
+
+#include <File.h>
+#include <streambuf.h>
+#include <filebuf.h>
+#include <Filebuf.h>
+
+class istream;
+
+class ostream
+{
+  friend class istream;
+protected:
+  streambuf*    bp;
+  state_value   state;           // _good/_eof/_fail/_bad
+  char          ownbuf;          // true if we own *bp
+  
+public:
+                ostream(const char* filename, io_mode m, access_mode a);
+                ostream(const char* filename, const char* m);
+                ostream(int filedesc, io_mode m);
+                ostream(FILE* fileptr);
+                ostream(int sz, char* buf);
+                ostream(int filedesc, char* buf, int buflen);
+                ostream(int filedesc);
+                ostream(streambuf* s);
+
+               ~ostream();
+
+  ostream&      open(const char* filename, io_mode m, access_mode a);
+  ostream&      open(const char* filename, const char* m);
+  ostream&      open(int  filedesc, io_mode m);
+  ostream&      open(FILE* fileptr);
+  ostream&      open(const char* filenam, open_mode m);
+
+  ostream&      close();
+  ostream&      flush();
+
+// stream status
+
+  int           rdstate();
+  int           eof();
+  int           fail();
+  int           bad();
+  int           good();
+
+// other status queries
+
+  int           readable();
+  int           writable();
+  int           is_open();
+
+                operator void*();
+  int           operator !();
+
+  const char*   name();
+
+  char*         bufptr();
+
+// error handling
+
+  void          error();
+  void          clear(state_value f = _good); // poorly named
+  void          set(state_value f); // set corresponding bit
+  void          unset(state_value); // clear corresponding bit
+  ostream&      failif(int cond);
+
+// unformatted IO
+
+  ostream&      put(char  c);
+  ostream&      put(const char* s);
+  ostream&      put(const char* s, int slen);
+           
+// formatted IO
+
+  ostream&      form(const char* fmt, ...);           
+
+  ostream&      operator << (short  n);
+  ostream&      operator << (unsigned short n);
+  ostream&      operator << (int    n);
+  ostream&      operator << (unsigned int n);
+  ostream&      operator << (long   n);
+  ostream&      operator << (unsigned long n);
+#ifdef __GNUG__
+  ostream&      operator << (long long n);
+  ostream&      operator << (unsigned long long n);
+#endif __GNUG__
+  ostream&      operator << (float  n);
+  ostream&      operator << (double n);
+  ostream&      operator << (const char* s);
+  ostream&      operator << (const void* ptr);
+
+#ifndef NO_OUTPUT_CHAR
+  ostream&      operator << (char   c);
+#endif
+
+};
+
+extern ostream  cout;            // stdout
+extern ostream  cerr;            // stderr
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+
+inline void ostream::clear(state_value flag)
+{
+  state = flag;
+}
+
+inline void ostream::set(state_value flag)
+{
+  state = state_value(int(state) | int(flag));
+}
+
+inline void ostream::unset(state_value flag)
+{
+  state = state_value(int(state) & ~int(flag));
+}
+
+inline int ostream::rdstate()
+{
+  return int(state);
+}
+
+inline int ostream::good()
+{
+  return state == _good;
+}
+
+inline int ostream::eof()
+{
+  return int(state) & int(_eof);
+}
+
+inline int ostream::fail()
+{
+  return int(state) & int(_fail);
+}
+
+inline int ostream::bad()
+{
+  return int(state) & int(_bad);
+}
+
+inline ostream::operator void*()
+{
+  return (state == _good)? this : 0;
+}
+
+inline int ostream::operator !()
+{
+  return (state != _good);
+}
+
+inline ostream& ostream::failif(int cond)
+{
+  if (cond) set(_fail); return *this;
+}
+
+inline int ostream::is_open()
+{
+  return bp->is_open();
+}
+
+inline int ostream::readable()
+{
+  return 0;
+}
+
+inline int ostream::writable()
+{
+  return (bp != 0) && (state == _good);
+}
+
+
+inline char* ostream::bufptr()
+{
+  return bp->base;
+}
+
+inline ostream& ostream::flush()
+{
+  bp->overflow(); return *this;
+}
+
+inline ostream& ostream::close()
+{
+  bp->overflow(); bp->close();  return *this;
+}
+
+inline ostream& ostream::put(char ch)
+{
+  return failif((state != _good) || bp->sputc((int)ch &0xff) == EOF);
+}
+
+#ifndef NO_OUTPUT_CHAR
+inline ostream& ostream::operator << (char ch)
+{
+  return failif((state != _good) || bp->sputc((int)ch &0xff) == EOF);
+}
+#endif
+
+inline ostream& ostream::put(const char* s)
+{
+  return failif((state != _good) || bp->sputs(s) == EOF);
+}
+
+inline ostream& ostream::put(const char* s, int len)
+{
+  return failif((state != _good) || bp->sputsn(s, len) == EOF);
+}
+
+inline ostream& ostream::operator << (const char* s)
+{
+  return failif((state != _good) || bp->sputs(s) == EOF);
+}
+
+#endif
+
+#endif
diff --git a/usr/include/g++/regex.h b/usr/include/g++/regex.h
new file mode 100644 (file)
index 0000000..e0252cb
--- /dev/null
@@ -0,0 +1,280 @@
+/* Definitions for data structures callers pass the regex library.
+   Copyright (C) 1985 Free Software Foundation, Inc.
+
+                      NO WARRANTY
+
+  BECAUSE THIS PROGRAM IS LICENSED FREE OF CHARGE, WE PROVIDE ABSOLUTELY
+NO WARRANTY, TO THE EXTENT PERMITTED BY APPLICABLE STATE LAW.  EXCEPT
+WHEN OTHERWISE STATED IN WRITING, FREE SOFTWARE FOUNDATION, INC,
+RICHARD M. STALLMAN AND/OR OTHER PARTIES PROVIDE THIS PROGRAM "AS IS"
+WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY
+AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE PROGRAM PROVE
+DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR
+CORRECTION.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW WILL RICHARD M.
+STALLMAN, THE FREE SOFTWARE FOUNDATION, INC., AND/OR ANY OTHER PARTY
+WHO MAY MODIFY AND REDISTRIBUTE THIS PROGRAM AS PERMITTED BELOW, BE
+LIABLE TO YOU FOR DAMAGES, INCLUDING ANY LOST PROFITS, LOST MONIES, OR
+OTHER SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR
+DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY THIRD PARTIES OR
+A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS) THIS
+PROGRAM, EVEN IF YOU HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES, OR FOR ANY CLAIM BY ANY OTHER PARTY.
+
+               GENERAL PUBLIC LICENSE TO COPY
+
+  1. You may copy and distribute verbatim copies of this source file
+as you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy a valid copyright notice "Copyright
+(C) 1985 Free Software Foundation, Inc."; and include following the
+copyright notice a verbatim copy of the above disclaimer of warranty
+and of this License.  You may charge a distribution fee for the
+physical act of transferring a copy.
+
+  2. You may modify your copy or copies of this source file or
+any portion of it, and copy and distribute such modifications under
+the terms of Paragraph 1 above, provided that you also do the following:
+
+    a) cause the modified files to carry prominent notices stating
+    that you changed the files and the date of any change; and
+
+    b) cause the whole of any work that you distribute or publish,
+    that in whole or in part contains or is a derivative of this
+    program or any part thereof, to be licensed at no charge to all
+    third parties on terms identical to those contained in this
+    License Agreement (except that you may choose to grant more extensive
+    warranty protection to some or all third parties, at your option).
+
+    c) You may charge a distribution fee for the physical act of
+    transferring a copy, and you may at your option offer warranty
+    protection in exchange for a fee.
+
+Mere aggregation of another unrelated program with this program (or its
+derivative) on a volume of a storage or distribution medium does not bring
+the other program under the scope of these terms.
+
+  3. You may copy and distribute this program (or a portion or derivative
+of it, under Paragraph 2) in object code or executable form under the terms
+of Paragraphs 1 and 2 above provided that you also do one of the following:
+
+    a) accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of
+    Paragraphs 1 and 2 above; or,
+
+    b) accompany it with a written offer, valid for at least three
+    years, to give any third party free (except for a nominal
+    shipping charge) a complete machine-readable copy of the
+    corresponding source code, to be distributed under the terms of
+    Paragraphs 1 and 2 above; or,
+
+    c) accompany it with the information you received as to where the
+    corresponding source code may be obtained.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form alone.)
+
+For an executable file, complete source code means all the source code for
+all modules it contains; but, as a special exception, it need not include
+source code for modules which are standard libraries that accompany the
+operating system on which the executable file runs.
+
+  4. You may not copy, sublicense, distribute or transfer this program
+except as expressly provided under this License Agreement.  Any attempt
+otherwise to copy, sublicense, distribute or transfer this program is void and
+your rights to use the program under this License agreement shall be
+automatically terminated.  However, parties who have received computer
+software programs from you with this License Agreement will not have
+their licenses terminated so long as such parties remain in full compliance.
+
+  5. If you wish to incorporate parts of this program into other free
+programs whose distribution conditions are different, write to the Free
+Software Foundation at 675 Mass Ave, Cambridge, MA 02139.  We have not yet
+worked out a simple rule that can be stated here, but we will often permit
+this.  We will be guided by the two goals of preserving the free status of
+all derivatives of our free software and of promoting the sharing and reuse of
+software.
+
+
+In other words, you are welcome to use, share and improve this program.
+You are forbidden to forbid anyone else to use, share and improve
+what you give them.   Help stamp out software-hoarding!  */
+
+#if defined(SHORT_NAMES) || defined(VMS)
+#define re_compile_pattern     recmppat
+#define re_pattern_buffer      repatbuf
+#define re_registers           reregs
+#endif
+
+/* Define number of parens for which we record the beginnings and ends.
+   This affects how much space the `struct re_registers' type takes up.  */
+#ifndef RE_NREGS
+#define RE_NREGS 10
+#endif
+
+/* These bits are used in the obscure_syntax variable to choose among
+   alternative regexp syntaxes.  */
+
+/* 1 means plain parentheses serve as grouping, and backslash
+     parentheses are needed for literal searching.
+   0 means backslash-parentheses are grouping, and plain parentheses
+     are for literal searching.  */
+#define RE_NO_BK_PARENS 1
+
+/* 1 means plain | serves as the "or"-operator, and \| is a literal.
+   0 means \| serves as the "or"-operator, and | is a literal.  */
+#define RE_NO_BK_VBAR 2
+
+/* 0 means plain + or ? serves as an operator, and \+, \? are literals.
+   1 means \+, \? are operators and plain +, ? are literals.  */
+#define RE_BK_PLUS_QM 4
+
+/* 1 means | binds tighter than ^ or $.
+   0 means the contrary.  */
+#define RE_TIGHT_VBAR 8
+
+/* 1 means treat \n as an _OR operator
+   0 means treat it as a normal character */
+#define RE_NEWLINE_OR 16
+
+/* 0 means that a special characters (such as *, ^, and $) always have
+     their special meaning regardless of the surrounding context.
+   1 means that special characters may act as normal characters in some
+     contexts.  Specifically, this applies to:
+       ^ - only special at the beginning, or after ( or |
+       $ - only special at the end, or before ) or |
+       *, +, ? - only special when not after the beginning, (, or | */
+#define RE_CONTEXT_INDEP_OPS 32
+
+/* Now define combinations of bits for the standard possibilities.  */
+#define RE_SYNTAX_AWK (RE_NO_BK_PARENS | RE_NO_BK_VBAR | RE_CONTEXT_INDEP_OPS)
+#define RE_SYNTAX_EGREP (RE_SYNTAX_AWK | RE_NEWLINE_OR)
+#define RE_SYNTAX_GREP (RE_BK_PLUS_QM | RE_NEWLINE_OR)
+#define RE_SYNTAX_EMACS 0
+
+/* This data structure is used to represent a compiled pattern. */
+
+struct re_pattern_buffer
+  {
+    char *buffer;      /* Space holding the compiled pattern commands. */
+    int allocated;     /* Size of space that  buffer  points to */
+    int used;          /* Length of portion of buffer actually occupied */
+    char *fastmap;     /* Pointer to fastmap, if any, or zero if none. */
+                       /* re_search uses the fastmap, if there is one,
+                          to skip quickly over totally implausible characters */
+    char *translate;   /* Translate table to apply to all characters before comparing.
+                          Or zero for no translation.
+                          The translation is applied to a pattern when it is compiled
+                          and to data when it is matched. */
+    char fastmap_accurate;
+                       /* Set to zero when a new pattern is stored,
+                          set to one when the fastmap is updated from it. */
+    char can_be_null;   /* Set to one by compiling fastmap
+                          if this pattern might match the null string.
+                          It does not necessarily match the null string
+                          in that case, but if this is zero, it cannot.
+                          2 as value means can match null string
+                          but at end of range or before a character
+                          listed in the fastmap.  */
+  };
+
+/* Structure to store "register" contents data in.
+
+   Pass the address of such a structure as an argument to re_match, etc.,
+   if you want this information back.
+
+   start[i] and end[i] record the string matched by \( ... \) grouping i,
+   for i from 1 to RE_NREGS - 1.
+   start[0] and end[0] record the entire string matched. */
+
+struct re_registers
+  {
+    int start[RE_NREGS];
+    int end[RE_NREGS];
+  };
+
+/* These are the command codes that appear in compiled regular expressions, one per byte.
+  Some command codes are followed by argument bytes.
+  A command code can specify any interpretation whatever for its arguments.
+  Zero-bytes may appear in the compiled regular expression. */
+
+enum regexpcode
+  {
+    unused,
+    exactn,    /* followed by one byte giving n, and then by n literal bytes */
+    begline,   /* fails unless at beginning of line */
+    endline,   /* fails unless at end of line */
+    jump,       /* followed by two bytes giving relative address to jump to */
+    on_failure_jump,    /* followed by two bytes giving relative address of place
+                           to resume at in case of failure. */
+    finalize_jump,      /* Throw away latest failure point and then jump to address. */
+    maybe_finalize_jump, /* Like jump but finalize if safe to do so.
+                           This is used to jump back to the beginning
+                           of a repeat.  If the command that follows
+                           this jump is clearly incompatible with the
+                           one at the beginning of the repeat, such that
+                           we can be sure that there is no use backtracking
+                           out of repetitions already completed,
+                           then we finalize. */
+    dummy_failure_jump,  /* jump, and push a dummy failure point.
+                           This failure point will be thrown away
+                           if an attempt is made to use it for a failure.
+                           A + construct makes this before the first repeat.  */
+    anychar,    /* matches any one character */
+    charset,     /* matches any one char belonging to specified set.
+                   First following byte is # bitmap bytes.
+                   Then come bytes for a bit-map saying which chars are in.
+                   Bits in each byte are ordered low-bit-first.
+                   A character is in the set if its bit is 1.
+                   A character too large to have a bit in the map
+                   is automatically not in the set */
+    charset_not, /* similar but match any character that is NOT one of those specified */
+    start_memory, /* starts remembering the text that is matched
+                   and stores it in a memory register.
+                   followed by one byte containing the register number.
+                   Register numbers must be in the range 0 through NREGS. */
+    stop_memory, /* stops remembering the text that is matched
+                   and stores it in a memory register.
+                   followed by one byte containing the register number.
+                   Register numbers must be in the range 0 through NREGS. */
+    duplicate,    /* match a duplicate of something remembered.
+                   Followed by one byte containing the index of the memory register. */
+    before_dot,         /* Succeeds if before dot */
+    at_dot,     /* Succeeds if at dot */
+    after_dot,  /* Succeeds if after dot */
+    begbuf,      /* Succeeds if at beginning of buffer */
+    endbuf,      /* Succeeds if at end of buffer */
+    wordchar,    /* Matches any word-constituent character */
+    notwordchar, /* Matches any char that is not a word-constituent */
+    wordbeg,    /* Succeeds if at word beginning */
+    wordend,    /* Succeeds if at word end */
+    wordbound,   /* Succeeds if at a word boundary */
+    notwordbound, /* Succeeds if not at a word boundary */
+    syntaxspec,  /* Matches any character whose syntax is specified.
+                   followed by a byte which contains a syntax code, Sword or such like */
+    notsyntaxspec /* Matches any character whose syntax differs from the specified. */
+  };
+\f
+
+extern char *re_compile_pattern (char*, int, struct re_pattern_buffer*);
+/* Is this really advertised? */
+extern void re_compile_fastmap (struct re_pattern_buffer*);
+extern int re_search(struct re_pattern_buffer*, char*, int, int,
+ int, struct re_registers*);
+extern int re_search_2 (struct re_pattern_buffer*, char*, int, 
+ char*, int, int, int, struct re_registers*, int);
+extern int re_match (struct re_pattern_buffer*, char*, int, int, 
+ struct re_registers*);
+extern int re_match_2 (struct re_pattern_buffer*, unsigned char*, int, 
+ unsigned char*, int, int, struct re_registers*, int);
+
+/* 4.2 bsd compatibility (yuck) */
+extern char *re_comp (char*);
+extern int re_exec (char*);
+
+#ifdef SYNTAX_TABLE
+extern char *re_syntax_table;
+#endif
+
diff --git a/usr/include/g++/std.h b/usr/include/g++/std.h
new file mode 100644 (file)
index 0000000..52b3063
--- /dev/null
@@ -0,0 +1,4 @@
+#include <errno.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
diff --git a/usr/include/g++/strclass.h b/usr/include/g++/strclass.h
new file mode 100644 (file)
index 0000000..e1799f1
--- /dev/null
@@ -0,0 +1,8 @@
+#ifndef _strclass_h
+#ifdef __GNUG__
+#pragma once
+#endif
+#define _strclass_h
+#include <String.h>
+typedef class String string;
+#endif
diff --git a/usr/include/g++/stream.h b/usr/include/g++/stream.h
new file mode 100644 (file)
index 0000000..f55e978
--- /dev/null
@@ -0,0 +1,13 @@
+/* ostream.h and istream.h now separately includable */
+
+#ifndef _stream_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _stream_h 1
+
+#include <ostream.h>
+#include <istream.h>
+
+#endif
diff --git a/usr/include/g++/streambuf.h b/usr/include/g++/streambuf.h
new file mode 100644 (file)
index 0000000..61a3de5
--- /dev/null
@@ -0,0 +1,165 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+#ifndef _streambuf_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _streambuf_h 1
+
+/* streambufs. 
+   basic streambufs and filebufs are as in Stroustrup, ch 8,
+   but the base class contains virtual extensions that allow
+   most capabilities of libg++ Files to be used as streambufs
+   via `Filebufs'.
+*/
+
+#include <stdio.h>
+#include <builtin.h>
+#include <Fmodes.h>
+
+// see below for NO_LINE_BUFFER_STREAMBUFS
+
+#ifndef BUFSIZE
+#ifdef BUFSIZ
+#define BUFSIZE BUFSIZ
+#else
+#define BUFSIZE 1024
+#endif
+#endif
+
+enum open_mode // filebuf open modes
+{ 
+  input=0, 
+  output=1, 
+  append=2 
+}; 
+
+class streambuf
+{
+public:
+  char*       base;          // start of buffer
+  char*       pptr;          // put-pointer (and gptr fence)
+  char*       gptr;          // get-pointer
+  char*       eptr;          // last valid addr in buffer
+
+  char        alloc;         // true if we own freestore alloced buffer
+
+              streambuf();
+              streambuf(char* buf, int buflen);
+  virtual    ~streambuf();
+
+  int         doallocate();
+  int         allocate();
+
+
+  int         must_overflow(int ch); // true if should call overflow
+
+  virtual int overflow(int c = EOF); // flush -- return EOF if fail
+  virtual int underflow();           // fill -- return EOF if fail
+
+  int         sgetc();          // get one char (as int) or EOF
+  int         snextc();         // get and advance
+  void        stossc();         // advance only
+
+  int         sputbackc(char);   // unget
+
+  int         sputc(int c = EOF); // write one char
+
+  virtual streambuf*  setbuf(char* buf, int buflen, int preloaded_count = 0);
+                                // (not virtual in AT&T)
+
+// the following aren't in AT&T version:
+
+  int         sputs(const char* s);           // write null-terminated str
+  int         sputsn(const char* s, int len); // write len bytes
+
+  virtual const char* name();
+
+
+  virtual streambuf*  open(const char* name, open_mode m);
+  virtual streambuf*  open(const char* filename, io_mode m, access_mode a);
+  virtual streambuf*  open(const char* filename, const char* m);
+  virtual streambuf*  open(int  filedesc, io_mode m);
+  virtual streambuf*  open(FILE* fileptr);
+
+  virtual int         is_open();
+  virtual int         close();
+
+  virtual void        error();
+};
+
+
+#if defined(__OPTIMIZE__) || defined(USE_LIBGXX_INLINES)
+
+
+inline int streambuf::must_overflow(int ch)
+{
+#ifndef NO_LINE_BUFFER_STREAMBUF
+  return pptr >= eptr || ch == '\n';
+#else
+  return pptr >= eptr;
+#endif
+}
+
+
+inline int streambuf::allocate()
+{
+  return (base == 0)? doallocate() : 0; 
+}
+
+inline int streambuf::sgetc()
+{
+  return (gptr >= pptr)? underflow() : int((unsigned char)(*gptr));
+}
+
+
+inline int streambuf::snextc()
+{
+  ++gptr;
+  return (gptr >= pptr)? underflow() : int((unsigned char)(*gptr));
+}
+
+
+inline void streambuf::stossc()
+{
+  if (gptr >= pptr) underflow(); else gptr++;
+}
+
+
+inline int streambuf::sputbackc(char ch)
+{
+  return (gptr > base)? int((unsigned char)(*--gptr = ch)) : EOF;
+}
+
+inline int streambuf::sputc(int ch)
+{
+  return must_overflow(ch)? overflow(ch) : 
+                            int((unsigned char)(*pptr++ = char(ch)));
+}
+
+#endif
+
+#endif
diff --git a/usr/include/g++/swap.h b/usr/include/g++/swap.h
new file mode 100644 (file)
index 0000000..005cb0e
--- /dev/null
@@ -0,0 +1,3 @@
+/* From Ron Guillmette; apparently needed for Hansen's code */
+
+#define swap(a,b) ({ typeof(a) temp = (a); (a) = (b); (b) = temp; })
diff --git a/usr/include/g++/values.h b/usr/include/g++/values.h
new file mode 100644 (file)
index 0000000..9b6bb5c
--- /dev/null
@@ -0,0 +1,183 @@
+// This may look like C code, but it is really -*- C++ -*-
+/* 
+Copyright (C) 1988 Free Software Foundation
+    written by Doug Lea (dl@rocky.oswego.edu)
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY.  No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing.  Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License.   A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities.  It should be in a
+file named COPYING.  Among other things, the copyright notice
+and this notice must be preserved on all copies.  
+*/
+
+
+#ifndef _values_h
+#ifdef __GNUG__
+#pragma once
+#pragma interface
+#endif
+#define _values_h 1
+
+#define BITSPERBYTE 8
+#define BITS(type)  (BITSPERBYTE * (int)sizeof(type))
+
+#define CHARBITS    BITS(char)
+#define SHORTBITS   BITS(short)
+#define INTBITS     BITS(int)
+#define LONGBITS    BITS(long)
+#define PTRBITS     BITS(char*)
+#define DOUBLEBITS  BITS(double)
+#define FLOATBITS   BITS(float)
+
+#define MINSHORT    ((short)(1 << (SHORTBITS - 1)))
+#define MININT      (1 << (INTBITS - 1))
+#define MINLONG     (1L << (LONGBITS - 1))
+
+#define MAXSHORT    ((short)~MINSHORT)
+#define MAXINT      (~MININT)
+#define MAXLONG     (~MINLONG)
+
+#define HIBITS MINSHORT
+#define HIBITL MINLONG
+
+#if defined(sun) || defined(hp300) || defined(hpux) || defined(masscomp)
+#ifdef masscomp
+#define MAXDOUBLE                                                      \
+({                                                                     \
+  double maxdouble_val;                                                        \
+                                                                       \
+  __asm ("fmove%.d #0x7fefffffffffffff,%0"     /* Max double */        \
+        : "=f" (maxdouble_val)                                         \
+        : /* no inputs */);                                            \
+  maxdouble_val;                                                       \
+})
+#define MAXFLOAT ((float) 3.40e+38)
+#else
+#define MAXDOUBLE   1.79769313486231470e+308
+#define MAXFLOAT    ((float)3.40282346638528860e+38)
+#endif
+#define MINDOUBLE   4.94065645841246544e-324
+#define MINFLOAT    ((float)1.40129846432481707e-45)
+#define _IEEE       1
+#define _DEXPLEN    11
+#define _FEXPLEN    8
+#define _HIDDENBIT  1
+#define DMINEXP     (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
+#define FMINEXP     (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
+#define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
+#define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
+
+#elif defined(sony) 
+#define MAXDOUBLE   1.79769313486231470e+308
+#define MAXFLOAT    ((float)3.40282346638528860e+38)
+#define MINDOUBLE   2.2250738585072010e-308
+#define MINFLOAT    ((float)1.17549435e-38)
+#define _IEEE       1
+#define _DEXPLEN    11
+#define _FEXPLEN    8
+#define _HIDDENBIT  1
+#define DMINEXP     (-(DMAXEXP + DSIGNIF - _HIDDENBIT - 3))
+#define FMINEXP     (-(FMAXEXP + FSIGNIF - _HIDDENBIT - 3))
+#define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
+#define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
+
+#elif defined(sequent)
+extern double _maxdouble, _mindouble;
+extern float _maxfloat, _minfloat;
+#define MAXDOUBLE      _maxdouble
+#define MAXFLOAT       _maxfloat
+#define MINDOUBLE      _mindouble
+#define MINFLOAT       _minfloat
+#define _IEEE       1
+#define _DEXPLEN    11
+#define _FEXPLEN    8
+#define _HIDDENBIT  1
+#define DMINEXP     (-(DMAXEXP - 3))
+#define FMINEXP     (-(FMAXEXP - 3))
+#define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
+#define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
+
+#elif defined(i386)
+#define MAXDOUBLE   1.79769313486231570e+308
+#define MAXFLOAT    ((float)3.40282346638528860e+38)
+#define MINDOUBLE   2.22507385850720140e-308
+#define MINFLOAT    ((float)1.17549435082228750e-38)
+#define _IEEE       0
+#define _DEXPLEN    11
+#define _FEXPLEN    8
+#define _HIDDENBIT  1
+#define DMINEXP     (-DMAXEXP)
+#define FMINEXP     (-FMAXEXP)
+#define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
+#define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
+
+/* from Andrew Klossner <andrew%frip.wv.tek.com@relay.cs.net> */
+#elif defined(m88k)
+       /* These are "good" guesses ...
+          I'll figure out the true mins and maxes later, at the time I find
+          out the mins and maxes that the compiler can tokenize. */
+#define MAXDOUBLE   1.79769313486231e+308
+#define MAXFLOAT    ((float)3.40282346638528e+38)
+#define MINDOUBLE   2.22507385850720e-308
+#define MINFLOAT    ((float)1.17549435082228e-38)
+#define _IEEE       1
+#define _DEXPLEN    11
+#define _FEXPLEN    8
+#define _HIDDENBIT  1
+#define DMINEXP     (1-DMAXEXP)
+#define FMINEXP     (1-FMAXEXP)
+#define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
+#define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
+
+#elif defined(convex)
+#define MAXDOUBLE   8.9884656743115785e+306
+#define MAXFLOAT    ((float) 1.70141173e+38)
+#define MINDOUBLE   5.5626846462680035e-308
+#define MINFLOAT    ((float) 2.93873588e-39)
+#define _IEEE       0
+#define _DEXPLEN    11
+#define _FEXPLEN    8
+#define _HIDDENBIT  1
+#define DMINEXP     (-DMAXEXP)
+#define FMINEXP     (-FMAXEXP)
+#define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
+#define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
+
+// #elif defined(vax)
+// use vax versions by default -- they seem to be the most conservative
+#else 
+
+#define MAXDOUBLE   1.701411834604692293e+38
+#define MINDOUBLE   (2.938735877055718770e-39)
+
+#define MAXFLOAT    1.7014117331926443e+38
+#define MINFLOAT    2.9387358770557188e-39
+
+#define _IEEE       0
+#define _DEXPLEN    8
+#define _FEXPLEN    8
+#define _HIDDENBIT  1
+#define DMINEXP     (-DMAXEXP)
+#define FMINEXP     (-FMAXEXP)
+#define DMAXEXP     ((1 << _DEXPLEN - 1) - 1 + _IEEE)
+#define FMAXEXP     ((1 << _FEXPLEN - 1) - 1 + _IEEE)
+#endif
+
+#define DSIGNIF     (DOUBLEBITS - _DEXPLEN + _HIDDENBIT - 1)
+#define FSIGNIF     (FLOATBITS  - _FEXPLEN + _HIDDENBIT - 1)
+#define DMAXPOWTWO  ((double)(1L << LONGBITS -2)*(1L << DSIGNIF - LONGBITS +1))
+#define FMAXPOWTWO  ((float)(1L << FSIGNIF - 1))
+
+#endif
+
diff --git a/usr/include/glob.h b/usr/include/glob.h
new file mode 100644 (file)
index 0000000..4bc1320
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 1989 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      5.6 (Berkeley) 4/3/91
+ */
+
+#ifndef _GLOB_H_
+#define        _GLOB_H_
+
+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() */
+       int (*gl_errfunc)();    /* copy of errfunc parameter to glob() */
+       char **gl_pathv;        /* list of paths matching pattern */
+} glob_t;
+
+#define        GLOB_APPEND     0x01    /* append to output from previous call */
+#define        GLOB_DOOFFS     0x02    /* use gl_offs */
+#define        GLOB_ERR        0x04    /* return on error */
+#ifndef _POSIX_SOURCE
+#define        GLOB_MAGCHAR    0x08    /* pattern had globbing characters */
+#endif
+#define        GLOB_MARK       0x10    /* append / to matching directories */
+#define        GLOB_NOCHECK    0x20    /* return pattern itself if nothing matches */
+#define        GLOB_NOSORT     0x40    /* don't sort */
+#ifndef _POSIX_SOURCE
+#define        GLOB_QUOTE      0x80    /* quote special chars with \ */
+#endif
+
+#define        GLOB_NOSPACE    (-1)    /* malloc call failed */
+#define        GLOB_ABEND      (-2)    /* unignored error */
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int glob __P((const char *, int, int (*)(char *, int), glob_t *));
+void globfree __P((glob_t *));
+__END_DECLS
+
+#endif /* !_GLOB_H_ */
diff --git a/usr/include/grp.h b/usr/include/grp.h
new file mode 100644 (file)
index 0000000..0e699af
--- /dev/null
@@ -0,0 +1,64 @@
+/*-
+ * 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.
+ *
+ *     @(#)grp.h       5.4 (Berkeley) 4/3/91
+ */
+
+#ifndef _GRP_H_
+#define        _GRP_H_
+
+#ifndef _POSIX_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));
+int setgrent __P((void));
+void endgrent __P((void));
+void setgrfile __P((const char *));
+int setgroupent __P((int));
+#endif
+__END_DECLS
+
+#endif /* !_GRP_H_ */
diff --git a/usr/include/kvm.h b/usr/include/kvm.h
new file mode 100644 (file)
index 0000000..5be4402
--- /dev/null
@@ -0,0 +1,59 @@
+/*-
+ * 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.
+ *
+ *     @(#)kvm.h       5.6 (Berkeley) 4/23/91
+ */
+
+#ifndef _KVM_H_
+#define        _KVM_H_
+
+/* Default version symbol. */
+#define        VRS_SYM         "_version"
+#define        VRS_KEY         "VERSION"
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+struct proc;
+struct user;
+char           *kvm_getargs __P((const struct proc *, const struct user *));
+struct eproc   *kvm_geteproc __P((const struct proc *));
+char           *kvm_geterr __P((void));
+int             kvm_getprocs __P((int, int));
+struct user    *kvm_getu __P((const struct proc *));
+struct proc    *kvm_nextproc __P((void));
+int             kvm_nlist __P((struct nlist *));
+int             kvm_openfiles __P((const char *, const char *, const char *));
+int             kvm_read __P((void *, void *, int));
+__END_DECLS
+
+#endif /* !_KVM_H_ */
diff --git a/usr/include/limits.h b/usr/include/limits.h
new file mode 100644 (file)
index 0000000..02ec23b
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * 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_
+
+#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        _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_EQUIV_CLASS_MAX 2
+#define        _POSIX2_EXPR_NEST_MAX   32
+#define        _POSIX2_LINE_MAX        2048
+#define        _POSIX2_RE_DUP_MAX      255
+
+#include <machine/limits.h>
+#include <sys/syslimits.h>
+
+#endif /* !_LIMITS_H_ */
diff --git a/usr/include/locale.h b/usr/include/locale.h
new file mode 100644 (file)
index 0000000..de1702e
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * 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_LAST        6               /* 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/usr/include/machine b/usr/include/machine
new file mode 120000 (symlink)
index 0000000..9177dca
--- /dev/null
@@ -0,0 +1 @@
+/sys/i386/include
\ No newline at end of file
diff --git a/usr/include/math.h b/usr/include/math.h
new file mode 100644 (file)
index 0000000..e8eee44
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (c) 1985, 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.
+ *
+ *     @(#)math.h      5.8 (Berkeley) 4/2/91
+ */
+
+#ifndef        _MATH_H_
+#define        _MATH_H_
+
+#if defined(vax) || defined(tahoe)             /* DBL_MAX from float.h */
+#define        HUGE_VAL        1.701411834604692294E+38
+#else
+#define        HUGE_VAL        1e500                   /* IEEE: positive infinity */
+#endif
+
+#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+#if defined(vax) || defined(tahoe)
+/*
+ * HUGE for the VAX and Tahoe converts to the largest possible F-float value.
+ * This implies an understanding of the conversion behavior of atof(3).  It
+ * was defined to be the largest float so that overflow didn't occur when it
+ * was assigned to a single precision number.  HUGE_VAL is strongly preferred.
+ */
+#define        HUGE    1.701411733192644270E+38                
+#else
+#define        HUGE    HUGE_VAL
+#endif
+#endif
+
+#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) */
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+double acos __P((double));
+double asin __P((double));
+double atan __P((double));
+double atan2 __P((double, double));
+double ceil __P((double));
+double cos __P((double));
+double cosh __P((double));
+double exp __P((double));
+double fabs __P((double));
+double floor __P((double));
+double fmod __P((double, double));
+double frexp __P((double, int *));
+double ldexp __P((double, int));
+double log __P((double));
+double log10 __P((double));
+double modf __P((double, double *));
+double pow __P((double, double));
+double sin __P((double));
+double sinh __P((double));
+double sqrt __P((double));
+double tan __P((double));
+double tanh __P((double));
+
+#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+double acosh __P((double));
+double asinh __P((double));
+double atanh __P((double));
+double cabs();         /* we can't describe cabs()'s argument properly */
+double cbrt __P((double));
+double copysign __P((double, double));
+double drem __P((double, double));
+double erf __P((double));
+double erfc __P((double));
+double expm1 __P((double));
+int    finite __P((double));
+double hypot __P((double, double));
+#if defined(vax) || defined(tahoe)
+double infnan __P((int));
+#endif
+int    isinf __P((double));
+int    isnan __P((double));
+double j0 __P((double));
+double j1 __P((double));
+double jn __P((int, double));
+double lgamma __P((double));
+double log1p __P((double));
+double logb __P((double));
+double rint __P((double));
+double scalb __P((double, int));
+double y0 __P((double));
+double y1 __P((double));
+double yn __P((int, double));
+#endif
+
+__END_DECLS
+
+#endif /* _MATH_H_ */
diff --git a/usr/include/memory.h b/usr/include/memory.h
new file mode 100644 (file)
index 0000000..1008e2f
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * 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/usr/include/ndbm.h b/usr/include/ndbm.h
new file mode 100644 (file)
index 0000000..67f0293
--- /dev/null
@@ -0,0 +1,76 @@
+/*-
+ * Copyright (c) 1990 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      5.6 (Berkeley) 4/3/91
+ */
+
+#ifndef _NDBM_H_
+#define        _NDBM_H_
+
+#include <sys/cdefs.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;
+
+__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));
+__END_DECLS
+
+#endif /* !_NDBM_H_ */
diff --git a/usr/include/net b/usr/include/net
new file mode 120000 (symlink)
index 0000000..460abc0
--- /dev/null
@@ -0,0 +1 @@
+/sys/net
\ No newline at end of file
diff --git a/usr/include/netdb.h b/usr/include/netdb.h
new file mode 100644 (file)
index 0000000..ec6ab51
--- /dev/null
@@ -0,0 +1,121 @@
+/*-
+ * 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).
+ */
+
+#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((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 *));
+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/usr/include/netimp b/usr/include/netimp
new file mode 120000 (symlink)
index 0000000..9f72c6a
--- /dev/null
@@ -0,0 +1 @@
+/sys/netimp
\ No newline at end of file
diff --git a/usr/include/netinet b/usr/include/netinet
new file mode 120000 (symlink)
index 0000000..8d5d07c
--- /dev/null
@@ -0,0 +1 @@
+/sys/netinet
\ No newline at end of file
diff --git a/usr/include/netiso b/usr/include/netiso
new file mode 120000 (symlink)
index 0000000..8d9efd5
--- /dev/null
@@ -0,0 +1 @@
+/sys/netiso
\ No newline at end of file
diff --git a/usr/include/netns b/usr/include/netns
new file mode 120000 (symlink)
index 0000000..3ab507f
--- /dev/null
@@ -0,0 +1 @@
+/sys/netns
\ No newline at end of file
diff --git a/usr/include/nfs b/usr/include/nfs
new file mode 120000 (symlink)
index 0000000..d892d82
--- /dev/null
@@ -0,0 +1 @@
+/sys/nfs
\ No newline at end of file
diff --git a/usr/include/nlist.h b/usr/include/nlist.h
new file mode 100644 (file)
index 0000000..e397b74
--- /dev/null
@@ -0,0 +1,80 @@
+/*-
+ * 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.
+ *
+ *     @(#)nlist.h     5.6 (Berkeley) 4/4/91
+ */
+
+#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_COMM  0x12            /* common reference */
+#define        N_FN    0x1e            /* file name */
+
+#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/usr/include/paths.h b/usr/include/paths.h
new file mode 100644 (file)
index 0000000..c601bcb
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * 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.
+ *
+ *     @(#)paths.h     5.15 (Berkeley) 5/29/91
+ */
+
+#ifndef _PATHS_H_
+#define        _PATHS_H_
+
+/* Default search path. */
+#define        _PATH_DEFPATH   "/usr/bin:/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_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_TTY       "/dev/tty"
+#define        _PATH_UNIX      "/386bsd"
+#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_VARRUN    "/var/run/"
+#define        _PATH_VARTMP    "/var/tmp/"
+
+#endif /* !_PATHS_H_ */
diff --git a/usr/include/protocols/dumprestore.h b/usr/include/protocols/dumprestore.h
new file mode 100644 (file)
index 0000000..3b7b8c3
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ *
+ *     @(#)dumprestore.h       5.6 (Berkeley) 4/3/91
+ */
+
+#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 previous dump */
+               time_t  c_ddate;            /* date of this 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 */
+       } 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   1       /* new format tape header */
+
+#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/usr/include/protocols/routed.h b/usr/include/protocols/routed.h
new file mode 100644 (file)
index 0000000..76cf73b
--- /dev/null
@@ -0,0 +1,104 @@
+/*-
+ * 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        RIPVERSION      1
+
+struct netinfo {
+       struct  sockaddr rip_dst;       /* destination net/host */
+       int     rip_metric;             /* cost of route */
+};
+
+struct rip {
+       u_char  rip_cmd;                /* request/response */
+       u_char  rip_vers;               /* protocol version # */
+       u_char  rip_res1[2];            /* pad to 32-bit boundary */
+       union {
+               struct  netinfo ru_nets[1];     /* variable length... */
+               char    ru_tracefile[1];        /* ditto ... */
+       } ripun;
+#define        rip_nets        ripun.ru_nets
+#define        rip_tracefile   ripun.ru_tracefile
+};
+/*
+ * Packet types.
+ */
+#define        RIPCMD_REQUEST          1       /* want info */
+#define        RIPCMD_RESPONSE         2       /* responding to request */
+#define        RIPCMD_TRACEON          3       /* turn tracing on */
+#define        RIPCMD_TRACEOFF         4       /* turn it off */
+
+#define        RIPCMD_MAX              5
+#ifdef RIPCMDS
+char *ripcmds[RIPCMD_MAX] =
+  { "#0", "REQUEST", "RESPONSE", "TRACEON", "TRACEOFF" };
+#endif
+
+#define        HOPCNT_INFINITY         16      /* per Xerox NS */
+#define        MAXPACKETSIZE           512     /* max broadcast size */
+
+/*
+ * Timer values used in managing the routing table.
+ * 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/usr/include/protocols/rwhod.h b/usr/include/protocols/rwhod.h
new file mode 100644 (file)
index 0000000..6abfd66
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * 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/usr/include/protocols/talkd.h b/usr/include/protocols/talkd.h
new file mode 100644 (file)
index 0000000..bcd52fa
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * 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_long  id_num;         /* message id */
+       struct  osockaddr addr;         /* old (4.3) style */
+       struct  osockaddr ctl_addr;     /* old (4.3) style */
+       long    pid;            /* caller's process id */
+#define        NAME_SIZE       12
+       char    l_name[NAME_SIZE];/* caller's name */
+       char    r_name[NAME_SIZE];/* callee's name */
+#define        TTY_SIZE        16
+       char    r_tty[TTY_SIZE];/* callee's tty name */
+} CTL_MSG;
+
+/*
+ * Server->client response message format.
+ */
+typedef struct {
+       u_char  vers;           /* protocol version */
+       u_char  type;           /* type of request message, see below */
+       u_char  answer;         /* respose to request message, see below */
+       u_char  pad;
+       u_long  id_num;         /* message id */
+       struct  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/usr/include/protocols/timed.h b/usr/include/protocols/timed.h
new file mode 100644 (file)
index 0000000..c000875
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ * 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/usr/include/pwd.h b/usr/include/pwd.h
new file mode 100644 (file)
index 0000000..7c78d53
--- /dev/null
@@ -0,0 +1,85 @@
+/*-
+ * 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.
+ *
+ *     @(#)pwd.h       5.13 (Berkeley) 5/28/91
+ */
+
+#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 */
+#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));
+int             setpassent __P((int));
+int             setpwent __P((void));
+void            endpwent __P((void));
+#endif
+__END_DECLS
+
+#endif /* !_PWD_H_ */
diff --git a/usr/include/ranlib.h b/usr/include/ranlib.h
new file mode 100644 (file)
index 0000000..d05873f
--- /dev/null
@@ -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.
+ *
+ *     @(#)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 {
+               off_t ran_strx;         /* string table index */
+               char *ran_name;         /* in memory symbol name */
+       } ran_un;
+       off_t ran_off;                  /* archive file offset */
+};
+
+#endif /* !_RANLIB_H_ */
diff --git a/usr/include/regexp.h b/usr/include/regexp.h
new file mode 100644 (file)
index 0000000..086f990
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * 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/usr/include/resolv.h b/usr/include/resolv.h
new file mode 100644 (file)
index 0000000..f798b76
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * 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_
+
+/*
+ * 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        RES_TIMEOUT             5       /* min. seconds between retries */
+
+struct state {
+       int     retrans;                /* retransmition time interval */
+       int     retry;                  /* number of times to retransmit */
+       long    options;                /* option flags - see below. */
+       int     nscount;                /* number of name servers */
+       struct  sockaddr_in nsaddr_list[MAXNS]; /* address of name server */
+#define        nsaddr  nsaddr_list[0]          /* for backward compatibility */
+       u_short id;                     /* current packet id */
+       char    defdname[MAXDNAME];     /* default domain */
+       char    *dnsrch[MAXDNSRCH+1];   /* components of domain to search */
+};
+
+/*
+ * 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)
+
+extern struct 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_long, u_char *));
+void    __putshort __P((u_short, u_char *));
+char   *__p_class __P((int));
+char   *__p_time __P((u_long));
+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_mkquery __P((int, const char *, int, int, const char *, int,
+               const struct rrec *, char *, int));
+int     res_send __P((const char *, int, char *, int));
+__END_DECLS
+
+#endif /* !_RESOLV_H_ */
diff --git a/usr/include/rpc/auth.h b/usr/include/rpc/auth.h
new file mode 100644 (file)
index 0000000..c94505d
--- /dev/null
@@ -0,0 +1,166 @@
+/* @(#)auth.h  2.3 88/08/07 4.0 RPCSRC; from 1.17 88/02/08 SMI */
+/*
+ * 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
+ */
+
+/*
+ * 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".
+ */
+
+
+#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 */
+};
+
+#if (mc68000 || sparc || vax || i386 || tahoe || hp300)
+typedef u_long u_int32;        /* 32-bit unsigned integers */
+#endif
+
+union des_block {
+       struct {
+               u_int32 high;
+               u_int32 low;
+       } key;
+       char c[8];
+};
+typedef union des_block des_block;
+extern bool_t xdr_des_block();
+
+/*
+ * 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 {
+       struct  opaque_auth     ah_cred;
+       struct  opaque_auth     ah_verf;
+       union   des_block       ah_key;
+       struct auth_ops {
+               void    (*ah_nextverf)();
+               int     (*ah_marshal)();        /* nextverf & serialize */
+               int     (*ah_validate)();       /* validate varifier */
+               int     (*ah_refresh)();        /* refresh credentials */
+               void    (*ah_destroy)();        /* destroy this structure */
+       } *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;
+ */
+extern AUTH *authunix_create();
+extern AUTH *authunix_create_default();        /* takes no parameters */
+extern AUTH *authnone_create();                /* takes no parameters */
+extern AUTH *authdes_create();
+
+#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) */
diff --git a/usr/include/rpc/auth_unix.h b/usr/include/rpc/auth_unix.h
new file mode 100644 (file)
index 0000000..705741e
--- /dev/null
@@ -0,0 +1,72 @@
+/* @(#)auth_unix.h     2.2 88/07/29 4.0 RPCSRC; from 1.8 88/02/08 SMI */
+/*
+ * 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
+ */
+/*      @(#)auth_unix.h 1.5 86/07/16 SMI      */
+
+/*
+ * 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.
+ */
+
+/* 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;
+};
+
+extern bool_t xdr_authunix_parms();
+
+/* 
+ * 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;
+};
diff --git a/usr/include/rpc/clnt.h b/usr/include/rpc/clnt.h
new file mode 100644 (file)
index 0000000..8c002a1
--- /dev/null
@@ -0,0 +1,331 @@
+/* @(#)clnt.h  2.1 88/07/29 4.0 RPCSRC; from 1.31 88/02/08 SMI*/
+/*
+ * 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
+ */
+
+/*
+ * clnt.h - Client side remote procedure call interface.
+ *
+ * Copyright (C) 1984, Sun Microsystems, Inc.
+ */
+
+#ifndef _CLNT_
+#define _CLNT_
+
+/*
+ * 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_long low;     /* lowest verion supported */
+                       u_long high;    /* highest verion supported */
+               } RE_vers;
+               struct {                /* maybe meaningful if RPC_FAILED */
+                       long s1;
+                       long 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 {
+       AUTH    *cl_auth;                       /* authenticator */
+       struct clnt_ops {
+               enum clnt_stat  (*cl_call)();   /* call remote procedure */
+               void            (*cl_abort)();  /* abort a call */
+               void            (*cl_geterr)(); /* get specific error code */
+               bool_t          (*cl_freeres)(); /* frees results */
+               void            (*cl_destroy)();/* destroy this structure */
+               bool_t          (*cl_control)();/* the ioctl() of rpc */
+       } *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, argsp, xres, resp, secs))
+#define        clnt_call(rh, proc, xargs, argsp, xres, resp, secs)     \
+       ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, 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;
+ */
+extern CLIENT *clntraw_create();
+
+
+/*
+ * Generic client creation routine. Supported protocols are "udp" and "tcp"
+ */
+extern CLIENT *
+clnt_create(/*host, prog, vers, prot*/); /*
+       char *host;     -- hostname
+       u_long prog;    -- program number
+       u_long vers;    -- version number
+       char *prot;     -- protocol
+*/
+
+
+
+
+/*
+ * 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;
+ */
+extern CLIENT *clnttcp_create();
+
+/*
+ * 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;
+ */
+extern CLIENT *clntudp_create();
+extern CLIENT *clntudp_bufcreate();
+
+/*
+ * Print why creation failed
+ */
+void clnt_pcreateerror(/* char *msg */);       /* stderr */
+char *clnt_spcreateerror(/* char *msg */);     /* string */
+
+/*
+ * Like clnt_perror(), but is more verbose in its output
+ */ 
+void clnt_perrno(/* enum clnt_stat num */);    /* stderr */
+
+/*
+ * Print an English error message, given the client error code
+ */
+void clnt_perror(/* CLIENT *clnt, char *msg */);       /* stderr */
+char *clnt_sperror(/* CLIENT *clnt, char *msg */);     /* string */
+
+/* 
+ * 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;
+
+
+
+/*
+ * Copy error message to buffer.
+ */
+char *clnt_sperrno(/* enum clnt_stat num */);  /* string */
+
+
+
+#define UDPMSGSIZE     8800    /* rpc imposed limit on udp msg size */
+#define RPCSMALLMSGSIZE        400     /* a more reasonable packet size */
+
+#endif /*!_CLNT_*/
diff --git a/usr/include/rpc/pmap_clnt.h b/usr/include/rpc/pmap_clnt.h
new file mode 100644 (file)
index 0000000..d2ea2a8
--- /dev/null
@@ -0,0 +1,65 @@
+/* @(#)pmap_clnt.h     2.1 88/07/29 4.0 RPCSRC; from 1.11 88/02/08 SMI */
+/*
+ * 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
+ */
+
+/*
+ * 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.
+ */
+
+extern bool_t          pmap_set();
+extern bool_t          pmap_unset();
+extern struct pmaplist *pmap_getmaps();
+enum clnt_stat         pmap_rmtcall();
+enum clnt_stat         clnt_broadcast();
+extern u_short         pmap_getport();
diff --git a/usr/include/rpc/pmap_prot.h b/usr/include/rpc/pmap_prot.h
new file mode 100644 (file)
index 0000000..ccf7a77
--- /dev/null
@@ -0,0 +1,94 @@
+/* @(#)pmap_prot.h     2.1 88/07/29 4.0 RPCSRC; from 1.14 88/02/08 SMI */
+/*
+ * 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
+ */
+
+/*
+ * 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.
+ */
+
+#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;
+};
+
+extern bool_t xdr_pmap();
+
+struct pmaplist {
+       struct pmap     pml_map;
+       struct pmaplist *pml_next;
+};
+
+extern bool_t xdr_pmaplist();
diff --git a/usr/include/rpc/pmap_rmt.h b/usr/include/rpc/pmap_rmt.h
new file mode 100644 (file)
index 0000000..ee68ceb
--- /dev/null
@@ -0,0 +1,53 @@
+/* @(#)pmap_rmt.h      2.1 88/07/29 4.0 RPCSRC; from 1.2 88/02/08 SMI */
+/*
+ * 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
+ */
+
+/*
+ * Structures and XDR routines for parameters to and replies from
+ * the portmapper remote-call-service.
+ *
+ * Copyright (C) 1986, Sun Microsystems, Inc.
+ */
+
+struct rmtcallargs {
+       u_long prog, vers, proc, arglen;
+       caddr_t args_ptr;
+       xdrproc_t xdr_args;
+};
+
+bool_t xdr_rmtcall_args();
+
+struct rmtcallres {
+       u_long *port_ptr;
+       u_long resultslen;
+       caddr_t results_ptr;
+       xdrproc_t xdr_results;
+};
+
+bool_t xdr_rmtcallres();
diff --git a/usr/include/rpc/rpc.h b/usr/include/rpc/rpc.h
new file mode 100644 (file)
index 0000000..cd403b7
--- /dev/null
@@ -0,0 +1,80 @@
+/* @(#)rpc.h   2.4 89/07/11 4.0 RPCSRC; from 1.9 88/02/08 SMI */
+/*
+ * 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
+ */
+
+/*
+ * rpc.h, Just includes the billions of rpc header files necessary to
+ * do remote procedure calling.
+ *
+ * Copyright (C) 1984, Sun Microsystems, Inc.
+ */
+#ifndef __RPC_HEADER__
+#define __RPC_HEADER__
+
+#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).
+ */
+/*#include <rpc/auth_des.h>    /* protocol for des style cred */
+
+/* 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 */
+};
+
+struct rpcent *getrpcbyname(), *getrpcbynumber(), *getrpcent();
+
+#endif /* ndef __RPC_HEADER__ */
diff --git a/usr/include/rpc/rpc_msg.h b/usr/include/rpc/rpc_msg.h
new file mode 100644 (file)
index 0000000..b78872b
--- /dev/null
@@ -0,0 +1,187 @@
+/* @(#)rpc_msg.h       2.1 88/07/29 4.0 RPCSRC */
+/*
+ * 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
+ */
+/*      @(#)rpc_msg.h 1.7 86/07/16 SMI      */
+
+/*
+ * rpc_msg.h
+ * rpc message definition
+ *
+ * Copyright (C) 1984, Sun Microsystems, Inc.
+ */
+
+#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_long  low;
+                       u_long  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_long low;
+                       u_long 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_long cb_rpcvers;      /* must be equal to two */
+       u_long cb_prog;
+       u_long cb_vers;
+       u_long cb_proc;
+       struct opaque_auth cb_cred;
+       struct opaque_auth cb_verf; /* protocol specific - provided by client */
+};
+
+/*
+ * The rpc message
+ */
+struct rpc_msg {
+       u_long                  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
+
+
+/*
+ * XDR routine to handle a rpc message.
+ * xdr_callmsg(xdrs, cmsg)
+ *     XDR *xdrs;
+ *     struct rpc_msg *cmsg;
+ */
+extern bool_t  xdr_callmsg();
+
+/*
+ * 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();
+
+/*
+ * XDR routine to handle a rpc reply.
+ * xdr_replymsg(xdrs, rmsg)
+ *     XDR *xdrs;
+ *     struct rpc_msg *rmsg;
+ */
+extern bool_t  xdr_replymsg();
+
+/*
+ * 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();
diff --git a/usr/include/rpc/svc.h b/usr/include/rpc/svc.h
new file mode 100644 (file)
index 0000000..3cb07ef
--- /dev/null
@@ -0,0 +1,280 @@
+/* @(#)svc.h   2.2 88/07/29 4.0 RPCSRC; from 1.20 88/02/08 SMI */
+/*
+ * 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
+ */
+
+/*
+ * svc.h, Server-side remote procedure call interface.
+ *
+ * Copyright (C) 1984, Sun Microsystems, Inc.
+ */
+
+#ifndef __SVC_HEADER__
+#define __SVC_HEADER__
+
+/*
+ * 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 {
+       int             xp_sock;
+       u_short         xp_port;         /* associated port number */
+       struct xp_ops {
+           bool_t      (*xp_recv)();    /* receive incomming requests */
+           enum xprt_stat (*xp_stat)(); /* get transport status */
+           bool_t      (*xp_getargs)(); /* get arguments */
+           bool_t      (*xp_reply)();   /* send reply */
+           bool_t      (*xp_freeargs)();/* free mem allocated for args */
+           void        (*xp_destroy)(); /* destroy this struct */
+       } *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_long          rq_prog;        /* service program number */
+       u_long          rq_vers;        /* service protocol version */
+       u_long          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 
+ */
+extern bool_t  svc_register();
+
+/*
+ * Service un-registration
+ *
+ * svc_unregister(prog, vers)
+ *     u_long prog;
+ *     u_long vers;
+ */
+extern void    svc_unregister();
+
+/*
+ * Transport registration.
+ *
+ * xprt_register(xprt)
+ *     SVCXPRT *xprt;
+ */
+extern void    xprt_register();
+
+/*
+ * Transport un-register
+ *
+ * xprt_unregister(xprt)
+ *     SVCXPRT *xprt;
+ */
+extern void    xprt_unregister();
+
+
+
+
+/*
+ * 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!
+ */
+
+extern bool_t  svc_sendreply();
+extern void    svcerr_decode();
+extern void    svcerr_weakauth();
+extern void    svcerr_noproc();
+extern void    svcerr_progvers();
+extern void    svcerr_auth();
+extern void    svcerr_noprog();
+extern void    svcerr_systemerr();
+    
+/*
+ * 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 
+ */
+#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();
+
+extern void    svc_getreq();
+extern void    svc_getreqset();        /* takes fdset instead of int */
+extern void    svc_run();       /* never returns */
+
+/*
+ * 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.
+ */
+extern SVCXPRT *svcraw_create();
+
+/*
+ * Udp based rpc.
+ */
+extern SVCXPRT *svcudp_create();
+extern SVCXPRT *svcudp_bufcreate();
+
+/*
+ * Tcp based rpc.
+ */
+extern SVCXPRT *svctcp_create();
+
+
+
+#endif !__SVC_HEADER__
diff --git a/usr/include/rpc/svc_auth.h b/usr/include/rpc/svc_auth.h
new file mode 100644 (file)
index 0000000..a36a01a
--- /dev/null
@@ -0,0 +1,42 @@
+/* @(#)svc_auth.h      2.1 88/07/29 4.0 RPCSRC */
+/*
+ * 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
+ */
+/*      @(#)svc_auth.h 1.6 86/07/16 SMI      */
+
+/*
+ * svc_auth.h, Service side of rpc authentication.
+ * 
+ * Copyright (C) 1984, Sun Microsystems, Inc.
+ */
+
+
+/*
+ * Server side authenticator
+ */
+extern enum auth_stat _authenticate();
diff --git a/usr/include/rpc/types.h b/usr/include/rpc/types.h
new file mode 100644 (file)
index 0000000..06d22bf
--- /dev/null
@@ -0,0 +1,63 @@
+/* @(#)types.h 2.3 88/08/15 4.0 RPCSRC */
+/*
+ * 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
+ */
+/*      @(#)types.h 1.18 87/07/24 SMI      */
+
+/*
+ * Rpc additions to <sys/types.h>
+ */
+#ifndef __TYPES_RPC_HEADER__
+#define __TYPES_RPC_HEADER__
+
+#define        bool_t  int
+#define        enum_t  int
+#define        FALSE   (0)
+#define        TRUE    (1)
+#define __dontcare__   -1
+#ifndef NULL
+#      define NULL 0
+#endif
+
+void *malloc();
+#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>
+
+#ifndef INADDR_LOOPBACK
+#define       INADDR_LOOPBACK         (u_long)0x7F000001
+#endif
+#ifndef MAXHOSTNAMELEN
+#define        MAXHOSTNAMELEN  64
+#endif
+
+#endif /* ndef __TYPES_RPC_HEADER__ */
diff --git a/usr/include/rpc/xdr.h b/usr/include/rpc/xdr.h
new file mode 100644 (file)
index 0000000..6cd3e6f
--- /dev/null
@@ -0,0 +1,270 @@
+/* @(#)xdr.h   2.2 88/07/29 4.0 RPCSRC */
+/*
+ * 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
+ */
+/*      @(#)xdr.h 1.19 87/04/22 SMI      */
+
+/*
+ * xdr.h, External Data Representation Serialization Routines.
+ *
+ * Copyright (C) 1984, Sun Microsystems, Inc.
+ */
+
+#ifndef __XDR_HEADER__
+#define __XDR_HEADER__
+
+/*
+ * 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)
+
+/*
+ * 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.
+ * bool_t      (*xdrproc_t)(XDR *, caddr_t *);
+ */
+typedef        bool_t (*xdrproc_t)();
+
+/*
+ * 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 {
+       enum xdr_op     x_op;           /* operation; fast additional param */
+       struct xdr_ops {
+               bool_t  (*x_getlong)(); /* get a long from underlying stream */
+               bool_t  (*x_putlong)(); /* put a long to " */
+               bool_t  (*x_getbytes)();/* get some bytes from " */
+               bool_t  (*x_putbytes)();/* put some bytes to " */
+               u_int   (*x_getpostn)();/* returns bytes off from beginning */
+               bool_t  (*x_setpostn)();/* lets you reposition the stream */
+               long *  (*x_inline)();  /* buf quick ptr to buffered data */
+               void    (*x_destroy)(); /* free privates of this xdr_stream */
+       } *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;
+
+/*
+ * 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.
+ */
+extern bool_t  xdr_void();
+extern bool_t  xdr_int();
+extern bool_t  xdr_u_int();
+extern bool_t  xdr_long();
+extern bool_t  xdr_u_long();
+extern bool_t  xdr_short();
+extern bool_t  xdr_u_short();
+extern bool_t  xdr_bool();
+extern bool_t  xdr_enum();
+extern bool_t  xdr_array();
+extern bool_t  xdr_bytes();
+extern bool_t  xdr_opaque();
+extern bool_t  xdr_string();
+extern bool_t  xdr_union();
+extern bool_t  xdr_char();
+extern bool_t  xdr_u_char();
+extern bool_t  xdr_vector();
+extern bool_t  xdr_float();
+extern bool_t  xdr_double();
+extern bool_t  xdr_reference();
+extern bool_t  xdr_pointer();
+extern bool_t  xdr_wrapstring();
+
+/*
+ * 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();
+
+/*
+ * These are the public routines for the various implementations of
+ * xdr streams.
+ */
+extern void   xdrmem_create();         /* XDR using memory buffers */
+extern void   xdrstdio_create();       /* XDR using stdio library */
+extern void   xdrrec_create();         /* XDR pseudo records for tcp */
+extern bool_t xdrrec_endofrecord();    /* make end of xdr record */
+extern bool_t xdrrec_skiprecord();     /* move to beginning of next record */
+extern bool_t xdrrec_eof();            /* true if no more input */
+
+#endif !__XDR_HEADER__
diff --git a/usr/include/setjmp.h b/usr/include/setjmp.h
new file mode 100644 (file)
index 0000000..6851821
--- /dev/null
@@ -0,0 +1,85 @@
+/*-
+ * 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.
+ *
+ *     @(#)setjmp.h    5.5 (Berkeley) 6/8/91
+ */
+
+#ifndef _SETJMP_H_
+#define _SETJMP_H_
+
+#if defined(hp300) || defined(__hp300__)
+#define _JBLEN 17
+#endif
+
+#if defined(i386) || defined(__i386__)
+#define _JBLEN 10
+#endif
+
+#if defined(tahoe) || defined(__tahoe__)
+#define _JBLEN 10
+#endif
+
+#if defined(vax) || defined(__vax__)
+#define _JBLEN 10
+#endif
+
+#ifndef _ANSI_SOURCE
+/*
+ * WARNING: sigsetjmp() isn't supported yet, this is a placeholder.
+ */
+typedef int sigjmp_buf[_JBLEN + 1];
+#endif /* not ANSI */
+
+typedef int jmp_buf[_JBLEN];
+
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+int    setjmp __P((jmp_buf));
+void   longjmp __P((jmp_buf, int));
+
+#ifndef _ANSI_SOURCE
+/*
+ * WARNING: sigsetjmp() isn't supported yet, this is a placeholder.
+ */
+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/usr/include/sgtty.h b/usr/include/sgtty.h
new file mode 100644 (file)
index 0000000..cb345e2
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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>
diff --git a/usr/include/signal.h b/usr/include/signal.h
new file mode 120000 (symlink)
index 0000000..df1896d
--- /dev/null
@@ -0,0 +1 @@
+sys/signal.h
\ No newline at end of file
diff --git a/usr/include/stab.h b/usr/include/stab.h
new file mode 100644 (file)
index 0000000..8cb8902
--- /dev/null
@@ -0,0 +1,67 @@
+/*-
+ * 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
+ */
+
+/*
+ * 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 */
diff --git a/usr/include/stdarg.h b/usr/include/stdarg.h
new file mode 100644 (file)
index 0000000..5ad2b98
--- /dev/null
@@ -0,0 +1,41 @@
+/*-
+ * 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.
+ *
+ *     @(#)stdarg.h    5.6 (Berkeley) 4/3/91
+ */
+
+#ifndef _STDARG_H
+#define        _STDARG_H
+
+#include <machine/stdarg.h>
+
+#endif /* !_STDARG_H */
diff --git a/usr/include/stddef.h b/usr/include/stddef.h
new file mode 100644 (file)
index 0000000..b5ebfd9
--- /dev/null
@@ -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.
+ *
+ *     @(#)stddef.h    5.5 (Berkeley) 4/3/91
+ */
+
+#ifndef _STDDEF_H_
+#define _STDDEF_H_
+
+#include <machine/ansi.h>
+
+typedef        _PTRDIFF_T_     ptrdiff_t;
+
+#ifdef _SIZE_T_
+typedef        _SIZE_T_        size_t;
+#undef _SIZE_T_
+#endif
+
+#ifdef _WCHAR_T_
+typedef        _WCHAR_T_       wchar_t;
+#undef _WCHAR_T_
+#endif
+
+#ifndef        NULL
+#define        NULL    0
+#endif
+
+#define        offsetof(type, member)  ((size_t)(&((type *)0)->member))
+
+#endif /* _STDDEF_H_ */
diff --git a/usr/include/stdio.h b/usr/include/stdio.h
new file mode 100644 (file)
index 0000000..5489652
--- /dev/null
@@ -0,0 +1,353 @@
+/*-
+ * 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_
+
+#include <sys/cdefs.h>
+
+#include <machine/ansi.h>
+#ifdef _SIZE_T_
+typedef        _SIZE_T_        size_t;
+#undef _SIZE_T_
+#endif
+
+#ifndef NULL
+#define        NULL    0
+#endif
+
+typedef long fpos_t;           /* Must match off_t <sys/types.h> */
+
+#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 fgetline() when line crosses buffer boundary */
+       struct  __sbuf _lb;     /* buffer for fgetline() */
+
+       /* Unix stdio files get aligned to block boundaries on fseek() */
+       int     _blksize;       /* stat.st_blksize (may be != _bf._size) */
+       int     _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 => fgetline 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 *, size_t, 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 *));
+int     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((const FILE *));
+int     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 char *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((char *, const char *, ...));
+FILE   *tmpfile __P((void));
+char   *tmpnam __P((char *));
+int     ungetc __P((int, FILE *));
+int     vfprintf __P((FILE *, const char *, _VA_LIST_));
+int     vprintf __P((const char *, _VA_LIST_));
+int     vsprintf __P((char *, const char *, _VA_LIST_));
+__END_DECLS
+
+/*
+ * Functions defined in POSIX 1003.1.
+ */
+#ifndef _ANSI_SOURCE
+#define        L_cuserid       9       /* size for cuserid(); UT_NAMESIZE + 1 */
+#define        L_ctermid       1024    /* size for ctermid(); PATH_MAX */
+
+__BEGIN_DECLS
+char   *ctermid __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   *fgetline __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 *, ...));
+int     vsnprintf __P((char *, size_t, const char *, _VA_LIST_));
+int     vscanf __P((const char *, _VA_LIST_));
+int     vsscanf __P((const char *, const char *, _VA_LIST_));
+__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 *, _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/usr/include/stdlib.h b/usr/include/stdlib.h
new file mode 100644 (file)
index 0000000..8e9a595
--- /dev/null
@@ -0,0 +1,124 @@
+/*-
+ * 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 <sys/types.h>
+
+#ifdef _WCHAR_T_
+typedef        _WCHAR_T_       wchar_t;
+#undef _WCHAR_T_
+#endif
+
+typedef struct {
+       int quot;               /* quotient */
+       int rem;                /* remainder */
+} div_t;
+typedef struct {
+       long quot;              /* quotient */
+       long rem;               /* remainder */
+} ldiv_t;
+
+#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));
+
+#ifndef _ANSI_SOURCE
+void    cfree __P((void *));
+int     putenv __P((const char *));
+int     setenv __P((const char *, const char *, int));
+#endif /* not ANSI */
+
+#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
+void   *alloca __P((size_t));  /* built-in for gcc */
+extern  char *optarg;                  /* getopt(3) external variables */
+extern  int optind;
+extern  int opterr;
+int     getopt __P((int, char * const *, const char *));
+extern  char *suboptarg;               /* getsubopt(3) external variable */
+int     getsubopt __P((char **, char * const *, char **));
+int     heapsort __P((void *, size_t, size_t,
+           int (*)(const void *, const void *)));
+char   *initstate __P((unsigned, char *, int));
+int     radixsort __P((const u_char **, int, const u_char *, u_char));
+long    random __P((void));
+char   *setstate __P((char *));
+void    srandom __P((unsigned));
+void    unsetenv __P((const char *));
+#endif /* neither ANSI nor POSIX */
+
+__END_DECLS
+
+#endif /* _STDLIB_H_ */
diff --git a/usr/include/string.h b/usr/include/string.h
new file mode 100644 (file)
index 0000000..f27ac2c
--- /dev/null
@@ -0,0 +1,93 @@
+/*-
+ * 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 _SIZE_T_
+typedef        _SIZE_T_        size_t;
+#undef _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 */
+#ifndef _ANSI_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 *));
+void    swab __P((const void *, void *, size_t));
+#endif 
+__END_DECLS
+
+#endif /* _STRING_H_ */
diff --git a/usr/include/strings.h b/usr/include/strings.h
new file mode 100644 (file)
index 0000000..24dd3b4
--- /dev/null
@@ -0,0 +1,36 @@
+/*-
+ * 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/usr/include/struct.h b/usr/include/struct.h
new file mode 100644 (file)
index 0000000..e641a2d
--- /dev/null
@@ -0,0 +1,51 @@
+/*-
+ * 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/usr/include/sys b/usr/include/sys
new file mode 120000 (symlink)
index 0000000..38ed406
--- /dev/null
@@ -0,0 +1 @@
+/sys/sys
\ No newline at end of file
diff --git a/usr/include/syscall.h b/usr/include/syscall.h
new file mode 120000 (symlink)
index 0000000..c2e879e
--- /dev/null
@@ -0,0 +1 @@
+/usr/include/sys/syscall.h
\ No newline at end of file
diff --git a/usr/include/sysexits.h b/usr/include/sysexits.h
new file mode 100644 (file)
index 0000000..9879b46
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * 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        _SYSEXIST_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 /* !_SYSEXIST_H_ */
diff --git a/usr/include/syslog.h b/usr/include/syslog.h
new file mode 120000 (symlink)
index 0000000..11b106a
--- /dev/null
@@ -0,0 +1 @@
+sys/syslog.h
\ No newline at end of file
diff --git a/usr/include/termios.h b/usr/include/termios.h
new file mode 120000 (symlink)
index 0000000..fc0a85b
--- /dev/null
@@ -0,0 +1 @@
+sys/termios.h
\ No newline at end of file
diff --git a/usr/include/time.h b/usr/include/time.h
new file mode 100644 (file)
index 0000000..8b40b8c
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * 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.
+ *
+ *     @(#)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 _CLOCK_T_
+typedef        _CLOCK_T_       clock_t;
+#undef _CLOCK_T_
+#endif
+
+#ifdef _TIME_T_
+typedef        _TIME_T_        time_t;
+#undef _TIME_T_
+#endif
+
+#ifdef _SIZE_T_
+typedef        _SIZE_T_        size_t;
+#undef _SIZE_T_
+#endif
+
+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 *));
+
+#ifndef _ANSI_SOURCE
+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/usr/include/ttyent.h b/usr/include/ttyent.h
new file mode 100644 (file)
index 0000000..ed7d996
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * 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"
+
+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 */
+       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/usr/include/tzfile.h b/usr/include/tzfile.h
new file mode 100644 (file)
index 0000000..43f5642
--- /dev/null
@@ -0,0 +1,151 @@
+/*
+ * 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/usr/include/ufs b/usr/include/ufs
new file mode 120000 (symlink)
index 0000000..1d9faad
--- /dev/null
@@ -0,0 +1 @@
+/sys/ufs
\ No newline at end of file
diff --git a/usr/include/unistd.h b/usr/include/unistd.h
new file mode 100644 (file)
index 0000000..9675bd6
--- /dev/null
@@ -0,0 +1,185 @@
+/*-
+ * 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 */
+
+/* fnmatch(3) defines */
+#define        FNM_PATHNAME    0x01    /* match pathnames, not filenames */
+#ifndef _POSIX_SOURCE
+#define        FNM_QUOTE       0x02    /* escape special chars with \ */
+#endif
+
+#ifndef NULL
+#define        NULL            0       /* null pointer constant */
+#endif
+
+typedef        int ssize_t;            /* count of bytes or error indication */
+
+__BEGIN_DECLS
+void    _exit __P((int));
+int     access __P((const char *, int));
+u_int   alarm __P((u_int));
+int     chdir __P((const char *));
+int     chown __P((const char *, uid_t, gid_t));
+int     close __P((int));
+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, int *));           /* XXX (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));
+u_int   sleep __P((u_int));
+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 *));
+int     async_daemon __P((void));
+char   *brk __P((const char *));
+int     chflags __P((const char *, long));
+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     fchflags __P((int, long));
+int     fchown __P((int, int, int));
+int     fnmatch __P((const char *, const char *, int));
+int     fsync __P((int));
+int     ftruncate __P((int, off_t));
+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     mknod __P((const char *, mode_t, dev_t));
+int     mkstemp __P((char *));
+char   *mktemp __P((char *));
+int     nfssvc __P((int));
+int     nice __P((int));
+void    psignal __P((u_int, const char *));
+extern char *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     setegid __P((gid_t));
+int     seteuid __P((uid_t));
+int     setgroups __P((int, const int *));
+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));
+void    usleep __P((u_int));
+void   *valloc __P((size_t));                  /* obsoleted by malloc() */
+int     vfork __P((void));
+
+#endif /* !_POSIX_SOURCE */
+__END_DECLS
+
+#endif /* !_UNISTD_H_ */
diff --git a/usr/include/utime.h b/usr/include/utime.h
new file mode 100644 (file)
index 0000000..791962a
--- /dev/null
@@ -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.
+ *
+ *     @(#)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/usr/include/utmp.h b/usr/include/utmp.h
new file mode 100644 (file)
index 0000000..8dc3c6d
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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.
+ *
+ *     @(#)utmp.h      5.11 (Berkeley) 4/3/91
+ */
+
+#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];
+       long    ut_time;
+};
+
+#endif /* !_UTMP_H_ */
diff --git a/usr/include/varargs.h b/usr/include/varargs.h
new file mode 100644 (file)
index 0000000..4974210
--- /dev/null
@@ -0,0 +1,48 @@
+/*-
+ * 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.
+ *
+ *     @(#)varargs.h   5.3 (Berkeley) 4/3/91
+ */
+
+#ifndef _VARARGS_H_
+#define        _VARARGS_H_
+
+#include <stdarg.h>
+
+#undef va_dcl
+#define        va_dcl  int va_alist;
+
+#undef va_start
+#define        va_start(ap) \
+       ap = (char *)&va_alist
+
+#endif /* !_VARARGS_H_ */
diff --git a/usr/include/vis.h b/usr/include/vis.h
new file mode 100644 (file)
index 0000000..72d6114
--- /dev/null
@@ -0,0 +1,84 @@
+/*-
+ * 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 *, char, int, char));
+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/usr/othersrc/contrib/isode/pepy/test/A/A.pe b/usr/othersrc/contrib/isode/pepy/test/A/A.pe
new file mode 100644 (file)
index 0000000..373911a
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/A/A.pe differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/A/numericstring.pe b/usr/othersrc/contrib/isode/pepy/test/A/numericstring.pe
new file mode 100644 (file)
index 0000000..87252c8
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/A/numericstring.pe differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg1 b/usr/othersrc/contrib/isode/pepy/test/mhs/msg1
new file mode 100644 (file)
index 0000000..bdcfd97
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg1 differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg1.pe b/usr/othersrc/contrib/isode/pepy/test/mhs/msg1.pe
new file mode 100644 (file)
index 0000000..22086bc
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg1.pe differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg2 b/usr/othersrc/contrib/isode/pepy/test/mhs/msg2
new file mode 100644 (file)
index 0000000..2252d19
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg2 differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg2.pe b/usr/othersrc/contrib/isode/pepy/test/mhs/msg2.pe
new file mode 100644 (file)
index 0000000..10701b6
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg2.pe differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg3 b/usr/othersrc/contrib/isode/pepy/test/mhs/msg3
new file mode 100644 (file)
index 0000000..75332d2
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg3 differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg3.pe b/usr/othersrc/contrib/isode/pepy/test/mhs/msg3.pe
new file mode 100644 (file)
index 0000000..a609a88
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg3.pe differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg4 b/usr/othersrc/contrib/isode/pepy/test/mhs/msg4
new file mode 100644 (file)
index 0000000..518e290
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg4 differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg4.pe b/usr/othersrc/contrib/isode/pepy/test/mhs/msg4.pe
new file mode 100644 (file)
index 0000000..747bdc4
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg4.pe differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg5 b/usr/othersrc/contrib/isode/pepy/test/mhs/msg5
new file mode 100644 (file)
index 0000000..a255e41
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg5 differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg5.pe b/usr/othersrc/contrib/isode/pepy/test/mhs/msg5.pe
new file mode 100644 (file)
index 0000000..8dfe586
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg5.pe differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg6 b/usr/othersrc/contrib/isode/pepy/test/mhs/msg6
new file mode 100644 (file)
index 0000000..9b5e04e
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg6 differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg6.pe b/usr/othersrc/contrib/isode/pepy/test/mhs/msg6.pe
new file mode 100644 (file)
index 0000000..f4b5665
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg6.pe differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg7 b/usr/othersrc/contrib/isode/pepy/test/mhs/msg7
new file mode 100644 (file)
index 0000000..071edbb
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg7 differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/mhs/msg7.pe b/usr/othersrc/contrib/isode/pepy/test/mhs/msg7.pe
new file mode 100644 (file)
index 0000000..bbd9e7d
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/mhs/msg7.pe differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/test1.pe b/usr/othersrc/contrib/isode/pepy/test/test1.pe
new file mode 100644 (file)
index 0000000..e5a4aec
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/test1.pe differ
diff --git a/usr/othersrc/contrib/isode/pepy/test/test2.pe b/usr/othersrc/contrib/isode/pepy/test/test2.pe
new file mode 100644 (file)
index 0000000..e5a4aec
Binary files /dev/null and b/usr/othersrc/contrib/isode/pepy/test/test2.pe differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/cat b/usr/othersrc/public/textutils-1.3/bin/cat
new file mode 100755 (executable)
index 0000000..b798734
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/cat differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/cmp b/usr/othersrc/public/textutils-1.3/bin/cmp
new file mode 100755 (executable)
index 0000000..6c8c9dd
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/cmp differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/comm b/usr/othersrc/public/textutils-1.3/bin/comm
new file mode 100755 (executable)
index 0000000..70223a5
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/comm differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/csplit b/usr/othersrc/public/textutils-1.3/bin/csplit
new file mode 100755 (executable)
index 0000000..b582869
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/csplit differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/cut b/usr/othersrc/public/textutils-1.3/bin/cut
new file mode 100755 (executable)
index 0000000..dfba21e
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/cut differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/expand b/usr/othersrc/public/textutils-1.3/bin/expand
new file mode 100755 (executable)
index 0000000..56dd7d4
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/expand differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/fold b/usr/othersrc/public/textutils-1.3/bin/fold
new file mode 100755 (executable)
index 0000000..baa4e58
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/fold differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/head b/usr/othersrc/public/textutils-1.3/bin/head
new file mode 100755 (executable)
index 0000000..bbd7d79
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/head differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/join b/usr/othersrc/public/textutils-1.3/bin/join
new file mode 100755 (executable)
index 0000000..0a1b9ca
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/join differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/nl b/usr/othersrc/public/textutils-1.3/bin/nl
new file mode 100755 (executable)
index 0000000..bf444da
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/nl differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/paste b/usr/othersrc/public/textutils-1.3/bin/paste
new file mode 100755 (executable)
index 0000000..52ad160
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/paste differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/pr b/usr/othersrc/public/textutils-1.3/bin/pr
new file mode 100755 (executable)
index 0000000..909d1e1
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/pr differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/sort b/usr/othersrc/public/textutils-1.3/bin/sort
new file mode 100755 (executable)
index 0000000..91677d9
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/sort differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/split b/usr/othersrc/public/textutils-1.3/bin/split
new file mode 100755 (executable)
index 0000000..3bae966
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/split differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/sum b/usr/othersrc/public/textutils-1.3/bin/sum
new file mode 100755 (executable)
index 0000000..8aafc48
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/sum differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/tac b/usr/othersrc/public/textutils-1.3/bin/tac
new file mode 100755 (executable)
index 0000000..30db729
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/tac differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/tail b/usr/othersrc/public/textutils-1.3/bin/tail
new file mode 100755 (executable)
index 0000000..8b64da3
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/tail differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/tr b/usr/othersrc/public/textutils-1.3/bin/tr
new file mode 100755 (executable)
index 0000000..f562a80
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/tr differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/unexpand b/usr/othersrc/public/textutils-1.3/bin/unexpand
new file mode 100755 (executable)
index 0000000..36ba555
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/unexpand differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/uniq b/usr/othersrc/public/textutils-1.3/bin/uniq
new file mode 100755 (executable)
index 0000000..ce6bee3
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/uniq differ
diff --git a/usr/othersrc/public/textutils-1.3/bin/wc b/usr/othersrc/public/textutils-1.3/bin/wc
new file mode 100755 (executable)
index 0000000..5bcb480
Binary files /dev/null and b/usr/othersrc/public/textutils-1.3/bin/wc differ