diff --git a/Makefile b/Makefile
index 1d745c0..1963c37 100644
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@ TMP:=${OBJ}/tmp
 ZIPS:=${SPD}/zips
 BOOKS:=${SPD}/books
 SPAD:=${SPD}/mnt/${SYS}
-SRCDIRS:="interpdir sharedir algebradir etcdir clefdir docdir \
+SRCDIRS:="interpdir sharedir algebradir etcdir docdir \
           graphdir smandir hyperdir browserdir inputdir"
 
 SYS:=$(notdir $(AXIOM))
@@ -124,7 +124,7 @@ WEAVE=${WEAVE} \
 XLIB=${XLIB} \
 ZIPS=${ZIPS} 
 
-all: rootdirs tanglec 
+all: rootdirs tanglec libspad
 	@ echo 1 making a ${SYS} system, PART=${PART} SUBPART=${SUBPART}
 	@ echo 2 Environment ${ENV}
 	@ ${BOOKS}/tanglec Makefile.pamphlet "Makefile.${SYS}" >Makefile.${SYS}
@@ -138,7 +138,6 @@ all: rootdirs tanglec
 	  else \
            if [ "${BUILD}" = "full" ] ; then \
 	   ( echo s4 starting serial make of input files ; \
-	     mkdir -p ${MNT}/${SYS}/doc/src/input ; \
              cd ${MNT}/${SYS}/doc/src/input ; \
 	     cp ${BOOKS}/axiom.sty . ; \
 	     for i in `ls ${SRC}/input/*.input.pamphlet` ; do \
@@ -179,20 +178,47 @@ all: rootdirs tanglec
 	@ ${ENV} $(MAKE) -f Makefile.${SYS} 
 	@ echo 3 finished system build on `date` | tee >lastBuildDate
 
+libspad: 
+	@ echo 11a making libspad
+	@ ( cd ${OBJ}/${SYS}/lib ; \
+	    ${BOOKS}/tanglec ${BOOKS}/bookvol8.pamphlet Makefile >Makefile ; \
+            ${ENV} ${MAKE} libspad.a )
+
 rootdirs:
 	@ echo 11 checking directory structure
-	@ mkdir -p ${TMP}
-	@ mkdir -p ${INT}/doc/lsp
-	@ mkdir -p ${INT}/doc/src
-	@ mkdir -p ${OBJ}/${SYS}
-	@ mkdir -p ${MNT}/${SYS}/bin/lib
-	@ mkdir -p ${MNT}/${SYS}/doc/src
+	 mkdir -p ${TMP}
+	 mkdir -p ${INT}/algebra
+	 mkdir -p ${INT}/hyper
+	 mkdir -p ${INT}/input
+	 mkdir -p ${INT}/interp
+	 mkdir -p ${INT}/sman
+	 mkdir -p ${OBJ}/${SYS}/bin
+	 mkdir -p ${OBJ}/${SYS}/etc
+	 mkdir -p ${OBJ}/${SYS}/graph
+	 mkdir -p ${OBJ}/${SYS}/hyper/pages
+	 mkdir -p ${OBJ}/${SYS}/interp
+	 mkdir -p ${OBJ}/${SYS}/lib
+	 mkdir -p ${OBJ}/${SYS}/sman
+	 mkdir -p ${MNT}/doc
+	 mkdir -p ${MNT}/${SYS}/algebra
+	 mkdir -p ${MNT}/${SYS}/autoload
+	 mkdir -p ${MNT}/${SYS}/bin
+	 mkdir -p ${MNT}/${SYS}/doc/axbook
+	 mkdir -p ${MNT}/${SYS}/doc/bitmaps
+	 mkdir -p ${MNT}/${SYS}/doc/hypertex/bitmaps
+	 mkdir -p ${MNT}/${SYS}/doc/msgs
+	 mkdir -p ${MNT}/${SYS}/doc/ps
+	 mkdir -p ${MNT}/${SYS}/doc/spadhelp
+	 mkdir -p ${MNT}/${SYS}/doc/src/input
+	 mkdir -p ${MNT}/${SYS}/graph/parabola.view
+	 mkdir -p ${MNT}/${SYS}/input
+	 mkdir -p ${MNT}/${SYS}/lib/graph
+	 mkdir -p ${MNT}/${SYS}/lib/scripts
 
 input:
 	@ echo p9 making input documents
 	@ if [ "${BUILD}" = "full" ] ; then \
-	  ( mkdir -p ${MNT}/${SYS}/doc/src/input ; \
-            cd ${MNT}/${SYS}/doc/src/input ; \
+	  ( cd ${MNT}/${SYS}/doc/src/input ; \
 	    cp ${BOOKS}/axiom.sty . ; \
 	    for i in `ls ${SRC}/input/*.input.pamphlet` ; \
               do latex $$i ; \
@@ -206,8 +232,6 @@ input:
 
 book:
 	@ echo 79 building the book as ${MNT}/${SYS}/doc/book.dvi 
-	@ mkdir -p ${TMP}
-	@ mkdir -p ${MNT}/${SYS}/doc
 	@ cp ${SRC}/doc/book.pamphlet ${MNT}/${SYS}/doc
 	@ cp -pr ${SRC}/doc/ps ${MNT}/${SYS}/doc
 	@ (cd ${MNT}/${SYS}/doc ; \
@@ -257,42 +281,39 @@ document:
 clean: 
 	@ echo 7 making a ${SYS} system, PART=${PART} SUBPART=${SUBPART}
 	@ echo 8 Environment ${ENV}
-	@ rm -f src/algebra/book*pamphlet
-	@ rm -f src/algebra/*.spad
-	@ rm -f src/interp/book*pamphlet
 	@ rm -f axiom.sty
+	@ rm -f Makefile.pdf
+	@ rm -f Makefile.dvi
+	@ rm -f Makefile.${SYS}
 	@ rm -f books/Makefile
 	@ rm -f books/Makefile.dvi
-	@ rm -f src/algebra/axiom.sty
+	@ rm -f books/Makefile.pdf
 	@ rm -f lsp/axiom.sty
+	@ rm -f lsp/Makefile lsp/Makefile.dvi lsp/Makefile.pdf
+	@ rm -rf lsp/gcl*
 	@ rm -f src/axiom.sty
-	@ rm -f src/clef/axiom.sty
+	@ rm -f src/Makefile
+	@ rm -f src/Makefile.dvi
+	@ rm -f src/Makefile.pdf
+	@ rm -f src/algebra/book*pamphlet
+	@ rm -f src/algebra/*.spad
 	@ rm -f src/etc/axiom.sty
-	@ rm -f src/doc/axiom.sty
-	@ rm -f src/lib/axiom.sty
-	@ rm -f src/share/axiom.sty
-	@ rm -f src/scripts/axiom.sty
+	@ rm -f src/etc/Makefile src/etc/Makefile.dvi src/etc/Makefile.pdf
+	@ rm -f src/interp/book*pamphlet
 	@ rm -f src/input/axiom.sty
-	@ rm -f src/interp/axiom.sty
-	@ rm -f lsp/Makefile.dvi
-	@ rm -f lsp/Makefile
-	@ rm -rf lsp/gcl*
-	@ rm -f trace
-	@ rm -f Makefile.${SYS}
-	@ rm -f Makefile.dvi
+	@ rm -f src/share/axiom.sty
+	@ rm -f src/share/Makefile src/share/Makefile.dvi 
+	@ rm -f src/share/Makefile.pdf
 	@ rm -rf int
 	@ rm -rf obj
 	@ rm -rf mnt
 	@ for i in `find . -name "*~"` ; do rm -f $$i ; done
-	@ for i in `find src -name "Makefile"` ; do rm -f $$i ; done
-	@ for i in `find src -name "Makefile.dvi"` ; do rm -f $$i ; done
 	@ rm -f lastBuildDate
 	@ rm -f books/tanglec
-	@ rm -f Makefile.pdf books/Makefile.pdf 
-	@ rm -f lsp/Makefile.pdf lsp/Makefile.pdf src/Makefile.pdf
-	@ rm -f src/algebra/Makefile.pdf src/clef/Makefile.pdf 
-	@ rm -f src/doc/Makefile.pdf
-	@ rm -f src/etc/Makefile.pdf src/input/Makefile.pdf 
-	@ rm -f src/interp/Makefile.pdf
-	@ rm -f src/scripts/Makefile.pdf src/share/Makefile.pdf
+	@ rm -f src/input/Makefile src/input/Makefile.dvi
+	@ rm -f src/input/Makefile.pdf 
+	@ rm -f src/interp/Makefile src/interp/Makefile.dvi
+	@ rm -f src/interp/Makefile.pdf 
+	@ rm -f src/share/Makefile src/share/Makefile.dvi
+	@ rm -f src/share/Makefile.pdf 
 
diff --git a/Makefile.pamphlet b/Makefile.pamphlet
index b80ea16..1f08124 100644
--- a/Makefile.pamphlet
+++ b/Makefile.pamphlet
@@ -54,7 +54,6 @@ and then themselves. The system is built in the following order
 \item layer 0 copy complete
 \end{itemize}
 \item src/etc   -- building etc
-\item src/clef  -- building clef
 \item src/doc   -- building doc files
 \item src/input -- running regression tests
 \end{enumerate}
@@ -88,7 +87,7 @@ Note that make cannot handle recursively calling itself in the same
 directory so we have to expand the serial forms inline. Cheesy.
 
 \begin{chunk}{parallel}
-all: rootdirs tanglec 
+all: rootdirs tanglec libspad
 	@ echo 1 making a ${SYS} system, PART=${PART} SUBPART=${SUBPART}
 	@ echo 2 Environment ${ENV}
 	@ ${BOOKS}/tanglec Makefile.pamphlet "Makefile.${SYS}" >Makefile.${SYS}
@@ -102,7 +101,6 @@ all: rootdirs tanglec
 	  else \
            if [ "${BUILD}" = "full" ] ; then \
 	   ( echo s4 starting serial make of input files ; \
-	     mkdir -p ${MNT}/${SYS}/doc/src/input ; \
              cd ${MNT}/${SYS}/doc/src/input ; \
 	     cp ${BOOKS}/axiom.sty . ; \
 	     for i in `ls ${SRC}/input/*.input.pamphlet` ; do \
@@ -143,20 +141,47 @@ all: rootdirs tanglec
 	@ ${ENV} $(MAKE) -f Makefile.${SYS} 
 	@ echo 3 finished system build on `date` | tee >lastBuildDate
 
+libspad: 
+	@ echo 11a making libspad
+	@ ( cd ${OBJ}/${SYS}/lib ; \
+	    ${BOOKS}/tanglec ${BOOKS}/bookvol8.pamphlet Makefile >Makefile ; \
+            ${ENV} ${MAKE} libspad.a )
+
 rootdirs:
 	@ echo 11 checking directory structure
-	@ mkdir -p ${TMP}
-	@ mkdir -p ${INT}/doc/lsp
-	@ mkdir -p ${INT}/doc/src
-	@ mkdir -p ${OBJ}/${SYS}
-	@ mkdir -p ${MNT}/${SYS}/bin/lib
-	@ mkdir -p ${MNT}/${SYS}/doc/src
+	 mkdir -p ${TMP}
+	 mkdir -p ${INT}/algebra
+	 mkdir -p ${INT}/hyper
+	 mkdir -p ${INT}/input
+	 mkdir -p ${INT}/interp
+	 mkdir -p ${INT}/sman
+	 mkdir -p ${OBJ}/${SYS}/bin
+	 mkdir -p ${OBJ}/${SYS}/etc
+	 mkdir -p ${OBJ}/${SYS}/graph
+	 mkdir -p ${OBJ}/${SYS}/hyper/pages
+	 mkdir -p ${OBJ}/${SYS}/interp
+	 mkdir -p ${OBJ}/${SYS}/lib
+	 mkdir -p ${OBJ}/${SYS}/sman
+	 mkdir -p ${MNT}/doc
+	 mkdir -p ${MNT}/${SYS}/algebra
+	 mkdir -p ${MNT}/${SYS}/autoload
+	 mkdir -p ${MNT}/${SYS}/bin
+	 mkdir -p ${MNT}/${SYS}/doc/axbook
+	 mkdir -p ${MNT}/${SYS}/doc/bitmaps
+	 mkdir -p ${MNT}/${SYS}/doc/hypertex/bitmaps
+	 mkdir -p ${MNT}/${SYS}/doc/msgs
+	 mkdir -p ${MNT}/${SYS}/doc/ps
+	 mkdir -p ${MNT}/${SYS}/doc/spadhelp
+	 mkdir -p ${MNT}/${SYS}/doc/src/input
+	 mkdir -p ${MNT}/${SYS}/graph/parabola.view
+	 mkdir -p ${MNT}/${SYS}/input
+	 mkdir -p ${MNT}/${SYS}/lib/graph
+	 mkdir -p ${MNT}/${SYS}/lib/scripts
 
 input:
 	@ echo p9 making input documents
 	@ if [ "${BUILD}" = "full" ] ; then \
-	  ( mkdir -p ${MNT}/${SYS}/doc/src/input ; \
-            cd ${MNT}/${SYS}/doc/src/input ; \
+	  ( cd ${MNT}/${SYS}/doc/src/input ; \
 	    cp ${BOOKS}/axiom.sty . ; \
 	    for i in `ls ${SRC}/input/*.input.pamphlet` ; \
               do latex $$i ; \
@@ -189,44 +214,41 @@ document:
 clean: 
 	@ echo 7 making a ${SYS} system, PART=${PART} SUBPART=${SUBPART}
 	@ echo 8 Environment ${ENV}
-	@ rm -f src/algebra/book*pamphlet
-	@ rm -f src/algebra/*.spad
-	@ rm -f src/interp/book*pamphlet
 	@ rm -f axiom.sty
+	@ rm -f Makefile.pdf
+	@ rm -f Makefile.dvi
+	@ rm -f Makefile.${SYS}
 	@ rm -f books/Makefile
 	@ rm -f books/Makefile.dvi
-	@ rm -f src/algebra/axiom.sty
+	@ rm -f books/Makefile.pdf
 	@ rm -f lsp/axiom.sty
+	@ rm -f lsp/Makefile lsp/Makefile.dvi lsp/Makefile.pdf
+	@ rm -rf lsp/gcl*
 	@ rm -f src/axiom.sty
-	@ rm -f src/clef/axiom.sty
+	@ rm -f src/Makefile
+	@ rm -f src/Makefile.dvi
+	@ rm -f src/Makefile.pdf
+	@ rm -f src/algebra/book*pamphlet
+	@ rm -f src/algebra/*.spad
 	@ rm -f src/etc/axiom.sty
-	@ rm -f src/doc/axiom.sty
-	@ rm -f src/lib/axiom.sty
-	@ rm -f src/share/axiom.sty
-	@ rm -f src/scripts/axiom.sty
+	@ rm -f src/etc/Makefile src/etc/Makefile.dvi src/etc/Makefile.pdf
+	@ rm -f src/interp/book*pamphlet
 	@ rm -f src/input/axiom.sty
-	@ rm -f src/interp/axiom.sty
-	@ rm -f lsp/Makefile.dvi
-	@ rm -f lsp/Makefile
-	@ rm -rf lsp/gcl*
-	@ rm -f trace
-	@ rm -f Makefile.${SYS}
-	@ rm -f Makefile.dvi
+	@ rm -f src/share/axiom.sty
+	@ rm -f src/share/Makefile src/share/Makefile.dvi 
+	@ rm -f src/share/Makefile.pdf
 	@ rm -rf int
 	@ rm -rf obj
 	@ rm -rf mnt
 	@ for i in `find . -name "*~"` ; do rm -f $$i ; done
-	@ for i in `find src -name "Makefile"` ; do rm -f $$i ; done
-	@ for i in `find src -name "Makefile.dvi"` ; do rm -f $$i ; done
 	@ rm -f lastBuildDate
 	@ rm -f books/tanglec
-	@ rm -f Makefile.pdf books/Makefile.pdf 
-	@ rm -f lsp/Makefile.pdf lsp/Makefile.pdf src/Makefile.pdf
-	@ rm -f src/algebra/Makefile.pdf src/clef/Makefile.pdf 
-	@ rm -f src/doc/Makefile.pdf
-	@ rm -f src/etc/Makefile.pdf src/input/Makefile.pdf 
-	@ rm -f src/interp/Makefile.pdf
-	@ rm -f src/scripts/Makefile.pdf src/share/Makefile.pdf
+	@ rm -f src/input/Makefile src/input/Makefile.dvi
+	@ rm -f src/input/Makefile.pdf 
+	@ rm -f src/interp/Makefile src/interp/Makefile.dvi
+	@ rm -f src/interp/Makefile.pdf 
+	@ rm -f src/share/Makefile src/share/Makefile.dvi
+	@ rm -f src/share/Makefile.pdf 
 
 \end{chunk}
 
@@ -412,7 +434,7 @@ one of:
 
 \begin{verbatim}
  (all | lib | install | lisp | interp | comp | graph | hyper 
-      | clef | input | sman | boot | include | doc | algebra )
+      | input | sman | boot | include | doc | algebra )
 \end{verbatim}
 
 It is possible to be more specific with a directory using SUBPART.
@@ -446,7 +468,7 @@ TMP:=${OBJ}/tmp
 ZIPS:=${SPD}/zips
 BOOKS:=${SPD}/books
 SPAD:=${SPD}/mnt/${SYS}
-SRCDIRS:="interpdir sharedir algebradir etcdir clefdir docdir \
+SRCDIRS:="interpdir sharedir algebradir etcdir docdir \
           graphdir smandir hyperdir browserdir inputdir"
 
 SYS:=$(notdir $(AXIOM))
@@ -559,8 +581,6 @@ run latex over the pamphlet file.
 \begin{chunk}{book}
 book:
 	@ echo 79 building the book as ${MNT}/${SYS}/doc/book.dvi 
-	@ mkdir -p ${TMP}
-	@ mkdir -p ${MNT}/${SYS}/doc
 	@ cp ${SRC}/doc/book.pamphlet ${MNT}/${SYS}/doc
 	@ cp -pr ${SRC}/doc/ps ${MNT}/${SYS}/doc
 	@ (cd ${MNT}/${SYS}/doc ; \
diff --git a/books/Makefile.pamphlet b/books/Makefile.pamphlet
index 9d37f49..59dac4e 100644
--- a/books/Makefile.pamphlet
+++ b/books/Makefile.pamphlet
@@ -36,19 +36,27 @@ BOOKPDF=${PDF}/bookvol0.pdf    ${PDF}/bookvol1.pdf    ${PDF}/bookvol2.pdf \
         ${PDF}/bookvol10.pdf   ${PDF}/bookvol10.1.pdf ${PDF}/bookvol10.2.pdf \
         ${PDF}/bookvol10.3.pdf ${PDF}/bookvol10.4.pdf ${PDF}/bookvol10.5.pdf \
         ${PDF}/bookvol11.pdf   ${PDF}/bookvol12.pdf   ${PDF}/bookvol13.pdf \
-        ${PDF}/bookvolbib.pdf  \
-        ${PDF}/refcard.pdf     ${PDF}/endpaper.pdf    ${PDF}/rosetta.pdf
+        ${PDF}/bookvolbib.pdf  
 
-all: announce ${BOOKPDF} ${PDF}/toc.pdf spadedit
+OTHER=  ${PDF}/refcard.pdf     ${PDF}/endpaper.pdf    ${PDF}/rosetta.pdf
+
+all: announce ${BOOKPDF} ${PDF}/toc.pdf ${OTHER} spadedit 
 	@(cd ${PDF} ; ${RM} *.out *.toc *.sty *.def *.png)
 
 announce:
 	@ echo ==================================
-	@ echo books BUILDING PDF FILES
+	@ echo BUILDING PDF FILES books/Makefile
 	@ echo ==================================
 
+finish:
+	@ echo ==========================================
+	@ echo FINISHED BUILDING PDF FILES books/Makefile
+	@ echo ==========================================
+
 ${PDF}/%.pdf: ${IN}/%.pamphlet 
-	@echo b1 making ${PDF}/$*.pdf from ${IN}/$*.pamphlet
+	@ echo ===========================================
+	@ echo making ${PDF}/$*.pdf from ${IN}/$*.pamphlet
+	@ echo ===========================================
 	@(cd ${PDF} ; \
           cp ${BOOKS}/axiom.sty ${PDF} ; \
           cp ${BOOKS}/bbold.sty ${PDF} ; \
@@ -247,10 +255,11 @@ ${PDF}/toc.pdf: ${BOOKPDF}
 \end{chunk}
 \begin{chunk}{*}
 spadedit:
-	@echo b4 making spadedit from ${BOOK}/bookvol5 to ${OUT1}/scripts
-	@mkdir -p ${OUT1}
-	@tanglec ${BOOK}/bookvol5.pamphlet spadedit >${OUT1}/scripts/SPADEDIT
+	@echo b4 making spadedit from ${BOOKS}/bookvol5 to ${OUT1}/scripts
+	@${BOOKS}/tanglec ${BOOKS}/bookvol5.pamphlet spadedit \
+            >${OUT1}/scripts/SPADEDIT
 
+\end{chunk}
 \section{Combined Bibliography}
 \eject
 \begin{thebibliography}{99}
diff --git a/books/bookvol10.pamphlet b/books/bookvol10.pamphlet
index f6e93c6..96aa078 100644
--- a/books/bookvol10.pamphlet
+++ b/books/bookvol10.pamphlet
@@ -17688,139 +17688,139 @@ We output these as each stage completes.
 \begin{chunk}{stages}
 
 layer0bootstrap:
-	@ echo =====================================
-	@ echo === algebra bootstrap complete ======
-	@ echo =====================================
+	@ echo ==========================================
+	@ echo === algebra bootstrap complete bookvol10
+	@ echo ==========================================
 
 layer0copy:
-	@ echo ==================================
-	@ echo === layer  0 copy complete  ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer  0 copy complete bookvol10
+	@ echo =======================================
 
 layer0done:
-	@ echo ==================================
-	@ echo === layer  0 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer  0 of 24 complete bookvol10
+	@ echo =======================================
 
 layer1done:
-	@ echo ==================================
-	@ echo === layer  1 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer  1 of 24 complete bookvol10
+	@ echo =======================================
 
 layer2done:
-	@ echo ==================================
-	@ echo === layer  2 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer  2 of 24 complete bookvol10
+	@ echo =======================================
 
 layer3done:
-	@ echo ==================================
-	@ echo === layer  3 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer  3 of 24 complete bookvol10
+	@ echo =======================================
 
 layer4done:
-	@ echo ==================================
-	@ echo === layer  4 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer  4 of 24 complete bookvol10
+	@ echo =======================================
 
 layer5done:
-	@ echo ==================================
-	@ echo === layer  5 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer  5 of 24 complete bookvol10
+	@ echo =======================================
 
 layer6done:
-	@ echo ==================================
-	@ echo === layer  6 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer  6 of 24 complete bookvol10
+	@ echo =======================================
 
 layer7done:
-	@ echo ==================================
-	@ echo === layer  7 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer  7 of 24 complete bookvol10
+	@ echo =======================================
 
 layer8done:
-	@ echo ==================================
-	@ echo === layer  8 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer  8 of 24 complete bookvol10
+	@ echo =======================================
 
 layer9done:
-	@ echo ==================================
-	@ echo === layer 9 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 9 of 24 complete bookvol10
+	@ echo =======================================
 
 layer10done:
-	@ echo ==================================
-	@ echo === layer 10 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 10 of 24 complete bookvol10
+	@ echo =======================================
 
 layer11done:
-	@ echo ==================================
-	@ echo === layer 11 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 11 of 24 complete bookvol10
+	@ echo =======================================
 
 layer12done:
-	@ echo ==================================
-	@ echo === layer 12 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 12 of 24 complete bookvol10
+	@ echo =======================================
 
 layer13done:
-	@ echo ==================================
-	@ echo === layer 13 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 13 of 24 complete bookvol10
+	@ echo =======================================
 
 layer14done:
-	@ echo ==================================
-	@ echo === layer 14 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 14 of 24 complete bookvol10
+	@ echo =======================================
 
 layer15done:
-	@ echo ==================================
-	@ echo === layer 15 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 15 of 24 complete bookvol10
+	@ echo =======================================
 
 layer16done:
-	@ echo ==================================
-	@ echo === layer 16 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 16 of 24 complete bookvol10
+	@ echo =======================================
 
 layer17done:
-	@ echo ==================================
-	@ echo === layer 17 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 17 of 24 complete bookvol10
+	@ echo =======================================
 
 layer18done:
-	@ echo ==================================
-	@ echo === layer 18 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 18 of 24 complete bookvol10
+	@ echo =======================================
 
 layer19done:
-	@ echo ==================================
-	@ echo === layer 19 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 19 of 24 complete bookvol10
+	@ echo =======================================
 
 layer20done:
-	@ echo ==================================
-	@ echo === layer 20 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 20 of 24 complete bookvol10
+	@ echo =======================================
 
 layer21done:
-	@ echo ==================================
-	@ echo === layer 21 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 21 of 24 complete bookvol10
+	@ echo =======================================
 
 layer22done:
-	@ echo ==================================
-	@ echo === layer 22 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 22 of 24 complete bookvol10
+	@ echo =======================================
 
 layer23done:
-	@ echo ==================================
-	@ echo === layer 23 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 23 of 24 complete bookvol10
+	@ echo =======================================
 
 layer24done:
-	@ echo ==================================
-	@ echo === layer 24 of 24 complete ======
-	@ echo ==================================
+	@ echo =======================================
+	@ echo === layer 24 of 24 complete bookvol10
+	@ echo =======================================
 
 \end{chunk}
 \subsection{Regression testing}
@@ -19043,13 +19043,18 @@ REGRESS= \
 	  fi 
 	@ fgrep "regression result" $*.regress 
 
-all: announce ${REGRESS}
+all: announce ${REGRESS} finish
 	@echo sa15 algebra test cases complete.
 
 announce:
-	@ echo ======================================
-	@ echo src/algebra RUNNING REGRESSION TESTING
-	@ echo ======================================
+	@ echo ==================================================
+	@ echo src/algebra RUNNING REGRESSION TESTING bookvol10
+	@ echo ==================================================
+
+finish:
+	@ echo =================================================
+	@ echo src/algebra RUNNING REGRESSION FINISH bookvol10
+	@ echo =================================================
 
 \end{chunk}
 \section{The Makefile}
@@ -19091,23 +19096,23 @@ all: fasthelp fastinput fastxhtml src ${OUT}/libdb.text \
 	@ echo sa16 finished ${IN}
 
 fasthelp:
-	@ echo ======================================
-	@ echo src/algebra BUILDING HELP FILES
-	@ echo ======================================
+	@ echo =========================================
+	@ echo src/algebra BUILDING HELP FILES bookvol10
+	@ echo =========================================
 	@echo sa17 making .help files with lisp
 	@ echo "(makeHelpFiles)" | ${LISP}
 
 fastinput:
-	@ echo ======================================
-	@ echo src/algebra BUILDING INPUT FILES
-	@ echo ======================================
+	@ echo ==========================================
+	@ echo src/algebra BUILDING INPUT FILES bookvol10
+	@ echo ==========================================
 	@echo sa18 making .input files with lisp
 	@ echo "(makeInputFiles)" | ${LISP}
 
 fastxhtml:
-	@ echo ======================================
-	@ echo src/algebra BUILDING XHTML FILES
-	@ echo ======================================
+	@ echo ==========================================
+	@ echo src/algebra BUILDING XHTML FILES bookvol10
+	@ echo ==========================================
 	@echo sa19 making .xhtml files with lisp
 	@ mkdir -p ${MNT}/doc
 	@ echo "(makeXHTMLFiles)" | ${LISP}
@@ -19123,8 +19128,6 @@ ${SPADBIN}/index.html:
 	   done)
 	@ echo "</body></html>" >>${SPADBIN}/index.html
 
-#all:	${SUBPART}
-
 gloss:
 	@ echo sa21 copying glossary files
 	@ cp ${SRC}/share/algebra/gloss.text ${MNT}/${SYS}/algebra
@@ -19141,9 +19144,9 @@ src:	announce ${ORDER}
 	@ echo sa23 Finished uilding nrlibS from spad sources
 
 announce:
-	@ echo ======================================
-	@ echo src/algebra BUILDING ALGEBRA FILES
-	@ echo ======================================
+	@ echo ==============================================
+	@ echo src/algebra BUILDING ALGEBRA FILES bookvol10
+	@ echo ==============================================
 
 \getchunk{genericRules}
 \getchunk{ps (DOC from SRC)}
diff --git a/books/bookvol11.pamphlet b/books/bookvol11.pamphlet
index 33da9b3..01dbce1 100644
--- a/books/bookvol11.pamphlet
+++ b/books/bookvol11.pamphlet
@@ -11,7 +11,8 @@ This book contains the Firefox browser AJAX routines.
   cd /home/silver
   export AXIOM=(where)
   export PATH=$AXIOM/bin/lib:$AXIOM/bin:$PATH
-  notangle -t8 bookvol11.pamphlet > Makefile
+  ( cd books ; gcc -o tanglec tanglec.c )
+  books/tanglec bookvol11.pamphlet > Makefile
   make -j 10
   axiom -nox
    -> )set mes auto off
@@ -40,16 +41,27 @@ OUT=${MNT}/${SYS}/doc/hypertex
 
 %.xhtml: ${BOOK}
 	@ echo making $*.xhtml
-	@ ${BOOKS}/tangle ${BOOK} "$*.xhtml" > $*.xhtml
+	@ ${BOOKS}/tanglec ${BOOK} "$*.xhtml" > $*.xhtml
 
 \getchunk{PAGES}
 
-all: ${PAGES}
+all: announce ${PAGES} finish
+
+announce:
+	@ echo ==============================================
+	@ echo Making Browser-base Hypertex pages bookvol11
+	@ echo ==============================================
+
+finish:
+	@ echo ==============================================
+	@ echo Finish Browser-base Hypertex pages bookvol11
+	@ echo ==============================================
+
 	@ mkdir -p bitmaps
-	@ ${BOOKS}/tangle ${BOOK} axiom1.bitmap  >bitmaps/axiom1.bitmap
-	@ ${BOOKS}/tangle ${BOOK} rcm3720.input  >rcm3720.input
-	@ ${BOOKS}/tangle ${BOOK} strang.input   >strang.input
-	@ ${BOOKS}/tangle ${BOOK} signatures.txt >signatures.txt
+	@ ${BOOKS}/tanglec ${BOOK} axiom1.bitmap  >bitmaps/axiom1.bitmap
+	@ ${BOOKS}/tanglec ${BOOK} rcm3720.input  >rcm3720.input
+	@ ${BOOKS}/tanglec ${BOOK} strang.input   >strang.input
+	@ ${BOOKS}/tanglec ${BOOK} signatures.txt >signatures.txt
 	@ cp ${SPD}/books/ps/doctitle.png ${OUT}/doctitle.png
 	@ cp ${SPD}/books/ps/lightbayou.png ${OUT}/lightbayou.png
 
@@ -48870,7 +48882,7 @@ Additional information sources:
 
 \subsection{rootpage.xhtml}
 \begin{verbatim}
-  notangle -R"rootpage.xhtml" bookvol11.pamphlet > rootpage.xhtml
+  books/tanglec books/bookvol11.pamphlet rootpage.xhtml > rootpage.xhtml
 \end{verbatim}
 \begin{chunk}{rootpage.xhtml}
 \getchunk{standard head}
diff --git a/books/bookvol3.pamphlet b/books/bookvol3.pamphlet
index 8dc8d7c..c5b324b 100644
--- a/books/bookvol3.pamphlet
+++ b/books/bookvol3.pamphlet
@@ -9,20 +9,6 @@ This book is actually a literate program\cite{2} and can contain
 executable source code. In particular, the Makefile for this book
 is part of the source of the book and is included below. Axiom 
 uses the ``noweb'' literate programming system by Norman Ramsey\cite{6}.
-\begin{chunk}{*}
-PROJECT=bookvol3
-TANGLE=/usr/local/bin/NOTANGLE
-WEAVE=/usr/local/bin/NOWEAVE
-LATEX=/usr/bin/latex
-MAKEINDEX=/usr/bin/makeindex
-
-all: 
-	${WEAVE} -t8 -delay ${PROJECT}.pamphlet >${PROJECT}.tex
-	${LATEX} ${PROJECT}.tex 2>/dev/null 1>/dev/null
-	${MAKEINDEX} ${PROJECT}.idx
-	${LATEX} ${PROJECT}.tex 2>/dev/null 1>/dev/null
-
-\end{chunk}
 \eject
 \begin{thebibliography}{99}
 \bibitem{1} Jenks, R.J. and Sutor, R.S. 
diff --git a/books/bookvol4.pamphlet b/books/bookvol4.pamphlet
index a9c639b..f29ec1b 100644
--- a/books/bookvol4.pamphlet
+++ b/books/bookvol4.pamphlet
@@ -6845,20 +6845,6 @@ This book is actually a literate program\cite{Kn92} and can contain
 executable source code. In particular, the Makefile for this book
 is part of the source of the book and is included below. Axiom 
 uses the ``noweb'' literate programming system by Norman Ramsey\cite{Ra03}.
-\begin{chunk}{*}
-PROJECT=bookvol4
-TANGLE=/usr/local/bin/NOTANGLE
-WEAVE=/usr/local/bin/NOWEAVE
-LATEX=/usr/bin/latex
-MAKEINDEX=/usr/bin/makeindex
-
-all: 
-	${WEAVE} -t8 -delay ${PROJECT}.pamphlet >${PROJECT}.tex
-	${LATEX} ${PROJECT}.tex 2>/dev/null 1>/dev/null
-	${MAKEINDEX} ${PROJECT}.idx
-	${LATEX} ${PROJECT}.tex 2>/dev/null 1>/dev/null
-
-\end{chunk}
 \eject
 \begin{thebibliography}{99}
 
diff --git a/books/bookvol6.pamphlet b/books/bookvol6.pamphlet
index c53f5a4..f31e5c5 100644
--- a/books/bookvol6.pamphlet
+++ b/books/bookvol6.pamphlet
@@ -31,7 +31,6 @@ axiom
   [-ht    |-noht]      whether to use HyperDoc
   [-gr    |-nogr]      whether to use Graphics
   [-clef  |-noclef]    whether to use Clef
-  [-nonag |-nag]       whether to use NAG
   [-noiw  |-iw]        start in interpreter in a separate window
   [-ihere |-noihere]   start an interpreter in this window
   [-nox]               don't use X Windows
@@ -39,7 +38,6 @@ axiom
   [-ws wsname]         use named workspace
   [-list]              list workspaces only
   [-grprog fname]      use named program for Graphics
-  [-nagprog fname]     use named program for Nag
   [-htprog fname]      use named program for HyperDoc
   [-clefprog fname]    use named program for Clef
   [-sessionprog fname] use named program for session
@@ -102,15 +100,6 @@ special keyboard keys.
 \end{itemize}
 See Jenks\cite{1} page 21 for further information on the {\tt clef} command.
 
-\subsection{[-nonag $\vert$ -nag]}
-\begin{verbatim}
-  [-nonag |-nag]       whether to use NAG
-\end{verbatim}
-The {\tt nag} option, disabled by default, will attempt to start
-the {\tt nagman} program in the \$AXIOM/lib subdirectory. Since
-the open source version does not include the NAG numeric libraries
-this option does not work.
-
 \subsection{[-noiw $\vert$ -iw]}
 \begin{verbatim}
   [-noiw  |-iw]        start in interpreter in a separate window
@@ -264,14 +253,6 @@ allows you to specify which program to use for the graphics.
 By default this is\\
 {\tt \$AXIOM/lib/viewman}.
 
-\subsection{[-nagprog fname]}
-\begin{verbatim}
-  [-nagprog fname]     use named program for Nag
-\end{verbatim}
-allows you to specify which program to use for the NAG library
-connection. By default this is\\
-{\tt \$AXIOM/lib/nagman} but it is disabled by default.
-
 \subsection{[-htprog fname]}
 \begin{verbatim}
   [-htprog fname]      use named program for Hyperdoc
@@ -324,7 +305,7 @@ MALLOCTYPE=3.1
 export MALLOCTYPE
 
 \end{chunk}
-The {\tt nagman} process needs to know the hostname
+
 \begin{chunk}{axiomcmd}
 HOST=`hostname`
 export HOST
@@ -354,7 +335,6 @@ echo "axiom"
 echo "  [-ht    |-noht]      whether to use HyperDoc"
 echo "  [-gr    |-nogr]      whether to use Graphics"
 echo "  [-clef  |-noclef]    whether to use Clef"
-echo "  [-nonag |-nag]       whether to use NAG"
 echo "  [-noiw  |-iw]        start in interpreter in a separate window"
 echo "  [-ihere |-noihere]   start an interpreter in this window"
 echo "  [-nox]               don't use X Windows"
@@ -362,7 +342,6 @@ echo "  [-go  |-nogo]        whether to start system"
 echo "  [-ws wsname]         use named workspace"
 echo "  [-list]              list workspaces only"
 echo "  [-grprog fname]      use named program for Graphics"
-echo "  [-nagprog fname]     use named program for Nag"
 echo "  [-htprog fname]      use named program for HyperDoc"
 echo "  [-clefprog fname]    use named program for Clef"
 echo "  [-sessionprog fname] use named program for session"
@@ -504,7 +483,7 @@ If the argument is missing we complain and exit.
 \end{chunk}
 We can specify the various subprograms to use.
 \begin{chunk}{axiomcmd}
-	-nagprog|-grprog|-htprog|-clefprog|-sessionprog|-clientprog)
+	-grprog|-htprog|-clefprog|-sessionprog|-clientprog)
 		if [ "$2" = "" ] ; then needsubopt "$1" ; fi
 		otheropts="$otheropts  $1 $2"
 		shift
@@ -523,7 +502,7 @@ We handle the various [{\tt -option} $\vert$ {\tt -nooption}] cases
 	-clef|-noclef|-gr|-nogr|-ht|-noht|-iw|-noiw)
 		otheropts="$otheropts $1"
 		;;
-        -ihere|-noihere|-nox|-nag|-nonag)
+        -ihere|-noihere|-nox)
 		otheropts="$otheropts $1"
 		;;
 \end{chunk}
@@ -588,13 +567,84 @@ All of the options have been processed so we start {\tt sman}
 exec $SPAD/bin/sman $otheropts -ws $serverws
 
 \end{chunk}
+
 \chapter{The {\tt sman} program}
-\section{sman.h}
+\section{include files}
+\begin{chunk}{include/sockio-c.h1}
+/* from bookvol6 chunk include/sockio-c.h1 */
+extern int get_int(Sock * );
+extern char * get_string(Sock * );
+extern double get_float(Sock * );
+extern Sock * connect_to_local_server(char *  , int  , int );
+extern int sread(Sock *  , char *  , int  , char * );
+extern double plus_infinity(void );
+extern double minus_infinity(void );
+extern double NANQ(void );
+extern void sigpipe_handler(int );
+extern int wait_for_client_read(Sock *  , char *  , int  , char * );
+extern int wait_for_client_write(Sock *  , char *  , int  , char * );
+extern int swrite(Sock *  , char *  , int  , char * );
+extern int sselect(int  , fd_set *  , fd_set *  , fd_set *  , void * );
+extern int fill_buf(Sock *  , char *  , int  , char * );
+extern int sock_get_int(int );
+extern int get_ints(Sock *  , int *  , int );
+extern int sock_get_ints(int  , int *  , int );
+extern int send_int(Sock *  , int );
+extern int sock_send_int(int  , int );
+extern int send_ints(Sock *  , int *  , int );
+extern int sock_send_ints(int  , int *  , int );
+extern int send_string(Sock *  , char * );
+extern int send_string_len(Sock *  , char *  , int );
+extern int sock_send_string(int  , char * );
+extern int sock_send_string_len(int  , char *  , int );
+extern int send_strings(Sock *  , char * *  , int );
+extern int sock_send_strings(int  , char * *  , int );
+extern char * sock_get_string(int );
+extern char * get_string_buf(Sock *  , char *  , int );
+extern char * sock_get_string_buf(int  , char *  , int );
+extern int get_strings(Sock *  , char * *  , int );
+extern int sock_get_strings(int  , char * *  , int );
+extern int send_float(Sock *  , double );
+extern int sock_send_float(int  , double );
+extern int send_sfloats(Sock *  , float *  , int );
+extern int sock_send_sfloats(int  , float *  , int );
+extern int send_floats(Sock *  , double *  , int );
+extern int sock_send_floats(int  , double *  , int );
+extern double sock_get_float(int );
+extern int get_sfloats(Sock *  , float *  , int );
+extern int sock_get_sfloats(int  , float *  , int );
+extern int get_floats(Sock *  , double *  , int );
+extern int sock_get_floats(int  , double *  , int );
+extern int wait_for_client_kill(Sock *  , int );
+extern int sock_get_remote_fd(int );
+extern int send_signal(Sock *  , int );
+extern int sock_send_signal(int  , int );
+extern int send_wakeup(Sock * );
+extern int sock_send_wakeup(int );
+extern Sock * connect_to_local_server_new(char *  , int  , int );
+extern void remote_stdio(Sock * );
+extern void init_purpose_table(void );
+extern int make_server_number(void );
+extern void close_socket(int  , char * );
+extern int make_server_name(char *  , char * );
+extern int open_server(char * );
+extern int accept_connection(Sock * );
+extern void get_socket_type(Sock * );
+extern int sock_accept_connection(int );
+extern void redirect_stdio(Sock * );
+extern void init_socks(void );
+extern int server_switch(void );
+extern void flush_stdout(void );
+extern void print_line(char * );
+\end{chunk}
+
+\subsection{include/sman.h}
 The spad\_proc structure holds information about the process id
 of a child process, what to do when it dies, and the shell command
 line necessary to restart the process. There is a linked list of
 these structures which maintains the process list for axiom.
-\begin{chunk}{sman.h}
+\begin{chunk}{include/sman.h}
+/* from bookvol6 chunk include/sman.h */
 /* Process control definitions.  Used by fork_you and spawn_of_hell */
 
 /* When a process dies it kills off everything else */
@@ -614,7 +664,198 @@ typedef struct spad_proc {
 } SpadProcess;
 
 \end{chunk}
-\section{sman}
+
+\subsection{include/com.h}
+\begin{chunk}{include/com.h}
+/* from bookvol6 chunk include/com.h */
+#ifndef _COM_H_
+#define _COM_H_
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#if defined(RIOSplatform)
+#include <sys/select.h>
+#endif
+
+typedef struct {
+  int socket;           /* socket number returned by "socket" call */
+  int type;             /* socket type (AF_UNIX or AF_INET) */
+  int purpose;          /* can be SessionManager, GraphicsServer, etc. */
+  int pid;              /* process ID of connected socket */
+  int frame;            /* spad interpreter frame (for interpreter windows) */
+  int remote_fd;        /* file descriptor of remote socket */
+  union {
+    struct sockaddr u_addr;
+    struct sockaddr_in i_addr;
+  } addr;
+  char *host_name;      /* name of foreign host if type == AF_INET */
+} Sock;
+
+#define MaxClients      150
+
+/* possible socket types (purpose) */
+
+#define SessionManager  1
+#define ViewportServer  2
+#define MenuServer      3
+#define SessionIO       4
+#define BaloonServer    5
+#define InterpWindow    6
+#define KillSpad        7
+#define DebugWindow     8  
+#define Forker          9
+#define AV              10 /*Simon's algebraic viewer */
+
+#define Acknowledge     255
+
+/* Timeout value for connection to remote socket */
+
+#define Forever 0
+
+/* Socket name for local AXIOM server and session manager */
+
+#define SpadServer              "/tmp/.d"
+#define SessionServer           "/tmp/.s"
+#define SessionIOName           "/tmp/.i"
+#define MenuServerName          "/tmp/.h"
+#define ForkServerName          "/tmp/.f"
+
+
+#define MASK_SIZE       (NBBY*sizeof(fd_set))
+
+
+/* table of dedicated socket types */
+
+extern Sock *purpose_table[];
+extern Sock server[];
+extern Sock clients[];
+extern fd_set socket_mask;
+extern fd_set server_mask;
+
+/* Commands sent over the AXIOM session manager or menu socket */
+
+#define CreateFrame             1
+#define SwitchFrames            2
+#define EndOfOutput             3
+#define CallInterp              4
+#define EndSession              5
+#define LispCommand             6
+#define SpadCommand             7
+#define SendXEventToHyperTeX    8
+#define QuietSpadCommand        9
+#define CloseClient             10
+#define QueryClients            11
+#define QuerySpad               12
+#define NonSmanSession          13
+#define KillLispSystem          14
+
+#define CreateFrameAnswer       50
+
+/* Commands from AXIOM menu server to interpreter windows */
+
+#define ReceiveInputLine        100
+#define TestLine                101
+
+#endif
+\end{chunk}
+
+\subsection{include/bsdsignal.h}
+\begin{chunk}{include/bsdsignal.h}
+/* from bookvol6 chunk include/bsdsignal.h */
+#ifndef _BSDSIGNAL_H_
+#define _BSDSIGNAL_H_
+
+#define RestartSystemCalls 1
+#define DontRestartSystemCalls 0
+
+typedef void (* SignalHandlerFunc)(int);
+
+#endif	    /* _BSDSIGNAL */
+\end{chunk}
+
+\subsection{include/bsdsignal.h1}
+\begin{chunk}{include/bsdsignal.h1}
+/* from bookvol6 chunk include/bsdsignal.h1 */
+extern SignalHandlerFunc bsdSignal(int  , SignalHandlerFunc  , int );
+\end{chunk}
+
+\subsection{include/openpty.h1}
+\begin{chunk}{include/openpty.h1}
+/* from bookvol6 chunk include/openpty.h1 */
+extern void makeNextPtyNames(char *  , char * );
+extern int ptyopen(int *  , int *  , char *  , char * );
+\end{chunk}
+
+\subsection{include/sman.h1}
+\begin{chunk}{include/sman.h1}
+/* from bookvol6 chunk include/sman.h1 */
+extern int main(int argc , char * argv[] , char * envp[]);
+#ifdef _SMAN_C
+static void process_arguments(int argc , char * * argv);
+static int should_I_clef(void);
+static int in_X(void);
+static void set_up_defaults(void);
+static void process_options(int argc , char * * argv);
+static void death_handler(int sig);
+static void sman_catch_signals(void);
+static void fix_env(char * * envp , int spadnum);
+static void init_term_io(void);
+static char * strPrefix(char * prefix , char * s);
+static void check_spad_proc(char * file , char * prefix);
+static void clean_up_old_sockets(void);
+static SpadProcess * fork_you(int death_action);
+static void exec_command_env(char * command , char * * env);
+static SpadProcess * spawn_of_hell(char * command , int death_action);
+static void start_the_spadclient(void);
+static void start_the_local_spadclient(void);
+static void start_the_session_manager(void);
+static void start_the_hypertex(void);
+static void start_the_graphics(void);
+static void fork_Axiom(void);
+static void start_the_Axiom(char * * envp);
+static void clean_up_sockets(void);
+static void clean_hypertex_socket(void);
+static void read_from_spad_io(int ptcNum);
+static void read_from_manager(int ptcNum);
+static void manage_spad_io(int ptcNum);
+static void init_spad_process_list(void);
+static SpadProcess * find_child(int proc_id);
+static void kill_all_children(void);
+static void clean_up_terminal(void);
+static void monitor_children(void);
+#endif
+\end{chunk}
+
+\subsection{include/session.h1}
+\begin{chunk}{include/session.h1}
+/* from bookvol6 chunk include/session.h1 */
+extern int main(void);
+#ifdef _SESSION_C
+static void usr1_handler(int sig);
+static void usr2_handler(int sig);
+static void term_handler(int sig);
+static void close_client(int frame);
+static void read_SpadServer_command(void);
+static int test_sock_for_process(Sock * sock);
+static void read_menu_client_command(void);
+static void read_from_spad_io(void);
+static void kill_spad(void);
+static int accept_session_connection(Sock * server_sock);
+static void read_from_session(Sock * sock);
+static void manage_sessions(void);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/spadclient.h1}
+/* from bookvol6 chunk include/spadclient.h1 */
+extern int main(void);
+#ifdef _SPADCLIENT_C
+static void inter_handler(int sig);
+#endif
+\end{chunk}
+
+\section{sman.c}
 \subsection{includes}
 \begin{chunk}{sman.includes}
 #include <stdlib.h>
@@ -633,14 +874,13 @@ typedef struct spad_proc {
 #include <sys/stropts.h>
 #endif
 
-#include "com.h"
-#include "bsdsignal.h"
-#include "sman.h"
-
-#include "bsdsignal.h1"
-#include "sockio-c.h1"
-#include "openpty.h1"
-#include "sman.h1"
+\getchunk{include/com.h}
+\getchunk{include/bsdsignal.h}
+\getchunk{include/sman.h}
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/sockio-c.h1}
+\getchunk{include/openpty.h1}
+\getchunk{include/sman.h1}
 
 \end{chunk}
 \subsection{variables}
@@ -648,7 +888,6 @@ typedef struct spad_proc {
 char *ws_path;                  /* location of the AXIOM executable */
 int start_clef;			/* start clef under spad */
 int start_graphics;		/* start the viewman */
-int start_nagman;               /* start the nagman */
 int start_ht;			/* start hypertex */
 int start_spadclient;		/* Start the client spad buffer */
 int start_local_spadclient;	/* Start the client spad buffer */
@@ -666,7 +905,6 @@ int tpd=0;                      /* to-print-debug information */
 /************************************************/
 
 \getchunk{the viewman command line}
-\getchunk{the nagman command line}
 \getchunk{the hypertex command line}
 \getchunk{the clef command line}
 \getchunk{the session manager command line}
@@ -707,7 +945,6 @@ int child_pid;                  /* child's process id */
 struct termios oldbuf;           /* the original settings */
 struct termios childbuf;         /* terminal structure for user i/o */
 
-int nagman_signal=0;
 int death_signal = 0;
 
 \end{chunk}
@@ -729,10 +966,6 @@ process_arguments(int argc,char ** argv)
       start_graphics = 1;
     else if (strcmp(argv[arg], "-nogr")        == 0)
       start_graphics = 0;
-    else if (strcmp(argv[arg], "-nag")          == 0)
-      start_nagman = 1;
-    else if (strcmp(argv[arg], "-nonag")        == 0)
-      start_nagman = 0;
     else if (strcmp(argv[arg], "-ht")          == 0)
       start_ht = 1;
     else if (strcmp(argv[arg], "-noht")        == 0)
@@ -759,8 +992,6 @@ process_arguments(int argc,char ** argv)
       }
     else if (strcmp(argv[arg], "-grprog")      == 0)
       GraphicsProgram = argv[++arg];
-    else if (strcmp(argv[arg], "-nagprog")      == 0)
-      NagManagerProgram = argv[++arg];
     else if (strcmp(argv[arg], "-htprog")      == 0)
       HypertexProgram = argv[++arg];
     else if (strcmp(argv[arg], "-clefprog")    == 0) {
@@ -780,9 +1011,9 @@ process_arguments(int argc,char ** argv)
       PasteFile = argv[++arg];
     else {
       fprintf(stderr, "Usage: sman <-clef|-noclef> <-gr|-nogr> <-ht|-noht>");
-      fprintf(stderr, " <-iw|-noiw> <-nag|-nonag> <-nox> <-comp>");
+      fprintf(stderr, " <-iw|-noiw> <-nox> <-comp>");
       fprintf(stderr, " <-ws spad_workspace> <-grprog path> <-htprog path>");
-      fprintf(stderr, " <-clefprog path> <-sessionprog path> <-nagprog path>");
+      fprintf(stderr, " <-clefprog path> <-sessionprog path>");
       fprintf(stderr, " <-clientprog path>\n");
       exit(-1);
     }
@@ -797,10 +1028,6 @@ process_arguments(int argc,char ** argv)
       fprintf(stderr,"-nogr ");
     else
       fprintf(stderr,"-gr ");
-    if (start_nagman == 0)
-      fprintf(stderr,"-nonag ");
-    else
-      fprintf(stderr,"-nag ");
     if (start_ht == 0)
       fprintf(stderr,"-noht ");
     else
@@ -823,8 +1050,6 @@ process_arguments(int argc,char ** argv)
     fprintf(stderr,"'%s' ",ws_path);
     fprintf(stderr,"-grprog ");
     fprintf(stderr,"'%s' ",GraphicsProgram);
-    fprintf(stderr,"-nagprog ");
-    fprintf(stderr,"'%s' ",NagManagerProgram);
     fprintf(stderr,"-htprog ");
     fprintf(stderr,"'%s' ",HypertexProgram);
     fprintf(stderr,"-clefprog ");
@@ -869,10 +1094,6 @@ These are the default values for sman. A '1' value means that
 sman will try to start the given process, a '0' value means not
 starting the process.
 
-We do not have replacement code for the nagman process nor
-do we have a copy of the nag fortran library to test the process.
-Until this changes we set start\_nagman = 0 in order to disable
-starting this process by default.
 \begin{chunk}{sman.setupdefaults}
 static  void
 set_up_defaults(void)
@@ -880,7 +1101,6 @@ set_up_defaults(void)
   if (tpd == 1) fprintf(stderr,"sman:set_up_defaults entered\n");
   start_clef = should_I_clef();
   start_graphics = 1;
-  start_nagman = 0;
   start_ht = 1;
   start_spadclient = 0;
   start_local_spadclient = 1;
@@ -911,15 +1131,7 @@ death_handler(int sig)
 }
 
 \end{chunk}
-\subsection{nagman\_handler}
-\begin{chunk}{sman.nagmanhandler}
-static void 
-nagman_handler(int sig)
-{
-  nagman_signal=1;
-}
 
-\end{chunk}
 \subsection{sman\_catch\_signals}
 \begin{chunk}{sman.smancatchsignals}
 static void
@@ -936,20 +1148,7 @@ sman_catch_signals(void)
   bsdSignal(SIGIOT,  death_handler,RestartSystemCalls);
   bsdSignal(SIGBUS,  death_handler,RestartSystemCalls);
   bsdSignal(SIGSEGV, death_handler,RestartSystemCalls);
-  /* don't restart wait call on SIGUSR1  */
-  bsdSignal(SIGUSR1, nagman_handler,DontRestartSystemCalls); 
-  /* ONLY nagman should send this.
-     If an error (such as C-c) interrupts a NAGLINK call, nagman
-     gets a signal to clean up. We need to start another nagman 
-     almost immediately to process the next NAGLINK request.
-     Since nagman takes a while to clean up, we treat it specially.
-     nagman should send a signal (USR1) to sman.
-     sman should respond by spawning a new nagman.
-     
-     so nagman is NOT a DoItAgain but a NadaDelShitsky.
-     
-     The USR1 mechanism does not work for HPUX 9 - use DoItAgain 
-     */
+  bsdSignal(SIGUSR1, death_handler,RestartSystemCalls); 
 
 }
 
@@ -1157,19 +1356,7 @@ start_the_local_spadclient(void)
 }
 
 \end{chunk}
-\subsection{start\_the\_nagman}
-\begin{chunk}{sman.startthenagman}
-static void
-start_the_nagman(void)
-{
-#if defined(HP9platform)
-  spawn_of_hell(NagManagerProgram,DoItAgain);
-#else
-  spawn_of_hell(NagManagerProgram,NadaDelShitsky );
-#endif
-}
 
-\end{chunk}
 \subsection{start\_the\_session\_manager}
 \begin{chunk}{sman.startthesessionmanager}
 static void
@@ -1512,14 +1699,6 @@ monitor_children(void)
       sleep(2);
       exit(0);
     }
-    /* Check the value of dead_baby, since wait may have returned
-       a pid but subsequently we have received a signal.  Yeuch! */
-    if(dead_baby == -1 && nagman_signal) {
-      nagman_signal=0;
-      spawn_of_hell(NagManagerProgram,NadaDelShitsky);
-      continue;
-    }
-
     if (dead_baby == -1) {
       fprintf(stderr, "sman: wait returned -1\n");
       continue;
@@ -1578,7 +1757,6 @@ main(int argc, char *argv[],char *envp[])
   start_the_session_manager();
   if (start_spadclient)       start_the_spadclient();
   if (start_local_spadclient) start_the_local_spadclient();
-  if (start_nagman)           start_the_nagman();
   if (start_ht)               start_the_hypertex();
   if (start_graphics)         start_the_graphics();
   sleep(1);
@@ -1594,8 +1772,8 @@ main(int argc, char *argv[],char *envp[])
 }
 
 \end{chunk}
-\subsection{sman}
-\begin{chunk}{sman}
+\subsection{sman.c}
+\begin{chunk}{sman.c}
 #define _SMAN_C
 
 \getchunk{sman.includes}
@@ -1606,7 +1784,6 @@ main(int argc, char *argv[],char *envp[])
 \getchunk{sman.setupdefaults}
 \getchunk{sman.processoptions}
 \getchunk{sman.deathhandler}
-\getchunk{sman.nagmanhandler}
 \getchunk{sman.smancatchsignals}
 \getchunk{sman.fixenv}
 \getchunk{sman.inittermio}
@@ -1618,7 +1795,6 @@ main(int argc, char *argv[],char *envp[])
 \getchunk{sman.spawnofhell}
 \getchunk{sman.startthespadclient}
 \getchunk{sman.startthelocalspadclient}
-\getchunk{sman.startthenagman}
 \getchunk{sman.startthesessionmanager}
 \getchunk{sman.startthehypertex}
 \getchunk{sman.startthegraphics}
@@ -1645,558 +1821,6 @@ are listed, one entry per line, in a file called command.list.
 \begin{chunk}{the viewman command line}
 char *GraphicsProgram = "$AXIOM/lib/viewman";
 \end{chunk}
-\chapter{The {\tt nagman} program}
-\begin{chunk}{the nagman command line}
-char *NagManagerProgram = "$AXIOM/lib/nagman";
-\end{chunk}
-\section{nag.x}
-\begin{chunk}{nag.nag.x}
-
-/*
- * msg.x: Remote message printing protocol
- */
-const MAXASP = 10;
-
-/*
- * the nago structure is essentially a variable length string
- */
-
-struct nago {
-  opaque z <>;
-  };
-struct nagerr {
-nago p;
-nago q;
-};
-
-struct host{
-nago h <>;
-};
-
-struct nagst {
-
-/* Okay, if you understand this bit you know the essentials of how the link
- * works. h <> is an array of nago, which is an array of fortran source 
- * code, the length of the array being the no. of asps (0 for most routines).
- * y is the actual (XDR) input data for the routine. nm is the name of the
- * routine. id is a tag identifying the host/axiom session. Finally per is a
- * number telling whether or not to erase old fortran files on the remote
- * machine (persistence - the number per distinct fortran files will be 
- * stored, any more than this and earlier ones will be deleted.
- */
-
-  nago h <>;
-  nago y;
-  nago nm;
-  nago id;
-  int per;
-  };
-program NAGPROG {
-   version NAGVERS {
-       nagerr CALLNAG(nagst) = 1;
-       nago NAGMON(int)=2;
-       void AXEND(nago)=3;
-   } = 1;
-/*
- * the following number is very important. It tells the 
- * portmapper what number to register the nag daemon under.
- * There are rules about which number to pick - check SUN
- * technical info for more details
- */
-} = 100088;
-
-
-\end{chunk}
-\section{nagman}
-\subsection{includes}
-\begin{chunk}{nag.includes}
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdio.h> 
-#include <string.h>
-#include <errno.h>
-#include <termios.h>
-#include <signal.h>
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <sys/socket.h>
-#include <sys/un.h>
-#include <rpc/rpc.h>     /* always needed */ 
-#include <fcntl.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <netdb.h>
-#include "nag.h"  /* generated by rpcgen */
-#include "com.h"
-#include "bsdsignal.h"
-#include "sockio-c.h1"
-#include "bsdsignal.h1"
-#include "nagman.h1"
-
-\end{chunk}
-\subsection{variables}
-\begin{chunk}{nag.variables}
-#ifdef ALPHAplatform
-extern int getdomainname( char *, int );
-#endif
-#ifdef SUN4OS5platform
-extern int getdomainname( char *, int );
-extern int gethostname( char *, int );
-#endif
-
-nagerr * callnag_1(nagst *,CLIENT *);
-nago * nagmon_1(int *,CLIENT *);
-void * axend_1(nago *,CLIENT *);
-
-#define DO 1
-#define DONT 0
-
-int hnum, vmax;
-char *datafile, *resultsfile;
-
-struct hostnode {
-  char * name;
-  struct hostnode *next; 
-} *hlist=NULL;
-
-nagst nag4;
-Sock *sock1;
-
-\end{chunk}
-\subsection{term}
-this code runs when the user quits axiom. before nagman dies, it does
-an rpc call to nagd to tell it to get rid of files etc. The rpc call in
-question is axend\_1
-we also send a USR1 to sman to beget another nagman
-\begin{chunk}{nag.term}
-static void 
-term(int sig)
-{
-  CLIENT *cld;
-  void *res;
-  struct hostnode *pnode;
-
-#ifndef HP9platform /* can't figure out a way to do this on HP/UX 9 */
-  kill(atoi(getenv("SPADNUM")) , SIGUSR1);
-#endif
-
-
-  if(hnum!=0)
-    {
-      unlink(datafile);
-      unlink(resultsfile);
-    }
-
-  for(pnode=hlist;pnode!=NULL;pnode=pnode->next)
-    {
-      cld=clnt_create(pnode->name,NAGPROG, NAGVERS, "tcp");
-      if (cld == NULL)
-	goto NOHOST;
-
-      res=axend_1(&(nag4.id),cld);
-    NOHOST:
-      clnt_destroy(cld);
-    }
-  exit(0);
-}
-
-\end{chunk}
-\subsection{size\_of\_file}
-\begin{chunk}{nag.sizeoffile}
-static long 
-size_of_file(char *filename)
-{
-  struct stat buf_stat;
-
-  stat(filename,&buf_stat);
-  return (buf_stat.st_size);
-
-}
-
-\end{chunk}
-\subsection{rpcloop}
-\begin{chunk}{nag.rpcloop}
-static void 
-rpcloop(void)
-{
-  CLIENT *cl;
-  int res,j,v=0,u,showMessage;
-  long i;
-  register struct hostent *alias1, *alias2;
-  struct in_addr *addrnum;
-  u_long junk;
-  struct timeval tv;
-  nagerr *result;
-  char *Buf , *buf1;
-  char *ffile[MAXASP];
-  char routine[12], naghost[256];
-  FILE *nfp1, *nfp2, *nfp3;
-  struct hostnode *phost;
-  int fd;
-  
-  for (;;)
-    {
-      
-      if((Buf=get_string(sock1))==NULL) term(1); /* one string carries all */
-      
-      if(hnum!=0)
-	{
-	  /* call parameters */
-	  free(nag4.nm.z.z_val); /* the routine name */
-	  free(nag4.y.z.z_val);  /* the XDR data */
-	  for(i=0;i<v;i++)
-	    {
-	      unlink(ffile[i]);
-	      free(ffile[i]); /* the asp filenames */
-	      free(nag4.h.h_val[i].z.z_val); /* the asps themselves*/
-	    }
-	  free(nag4.h.h_val); /* the asps array */
-	  unlink(datafile);
-	  unlink(resultsfile);
-	  free(resultsfile);
-	  free(datafile);
-	  vmax= (v>vmax)? v : vmax;
-	}
-      
-      
-      
-      
-      buf1=strtok(Buf," ");
-      if (buf1) strcpy(naghost,buf1);
-      else printf("can't parse the naghost\n");
-      /* INFO         printf("%s\n",naghost);*/
-      
-      buf1=strtok(NULL," ");
-      if (buf1) strcpy(routine,buf1);
-      else printf("can't parse the routine\n");
-      /* INFO         printf("%s\n",routine);*/
-      
-      /* make copy of filenames because we will reuse Buf before deleting the files*/
-      buf1=strtok(NULL," ");
-      if (buf1) resultsfile=strdup(buf1);
-      else printf("can't parse the resultsfile file\n");	
-      /* INFO         printf("%s\n",resultsfile);*/
-      
-      buf1=strtok(NULL," ");  
-      if (buf1) datafile=strdup(buf1); 
-      else printf("can't parse the datafile file\n");  
-      /* INFO         printf("%s\n",datafile);*/
-      
-      buf1=strtok(NULL," ");
-      if (buf1) nag4.per=atoi(buf1);
-      else printf("can't parse the persistence\n");
-      /* INFO         printf("%d\n",nag4.per);*/
-      
-      buf1=strtok(NULL," ");
-      if (buf1) {
-	if (!strcmp(buf1,"on")) showMessage=DO;
-	else showMessage=DONT;
-      }
-      else printf("can't parse the messages flag\n");
-      /* INFO         printf("%s\n",buf1);*/
-      
-      v=0; /* asp counter */
-      while( (buf1=strtok(NULL," ")) )
-	{
-	  ffile[v++]=strdup(buf1);
-	  /* INFO 	      	printf("%s\n",ffile[v-1]);*/
-	}
-      
-      /* INFO  	printf("number of asps seen %d\n",v);*/
-      
-      if(showMessage==DO) printf("nagman:acknowledging request for %s\n",routine);
-      
-      res=0;  /* prepare result integer to be sent to Lisp */
-      
-      if((nfp3=fopen(resultsfile,"w"))==NULL)
-	{
-	  printf("can't open output file\n");
-	  goto END;
-	}
-      
-      /* nag4.h is the XDR array of asp text */
-      nag4.h.h_len=v;
-      nag4.h.h_val=(nago *)malloc((v)*sizeof(nago));
-      
-      
-      /* get asp text in call argument */
-      for(u=0;u<v;u++)
-	{
-	  /* this should be done by mmap */
-	  if((nfp1=fopen(ffile[u],"r"))==NULL)
-	    {
-	      fprintf(stderr,"can't open asp file %s\n",ffile[u]);
-	      fclose(nfp1);
-	      goto END;
-	    }
-	  fclose(nfp1);
-	  i=size_of_file(ffile[u]);
-
-	  /* allocs memory for the file */
-	  nag4.h.h_val[u].z.z_val= (char *)malloc((i+1)*sizeof(char)); 
-	  
-	  fd=open(ffile[u],O_RDONLY);
-	  read(fd,nag4.h.h_val[u].z.z_val,i);
-	  close(fd);
-	  /* make null-term. string */
-	  nag4.h.h_val[u].z.z_val[i]='\0'; 
-	  /* set the length */
-	  nag4.h.h_val[u].z.z_len=strlen(nag4.h.h_val[u].z.z_val); 
-	}
-      
-      
-      nag4.nm.z.z_val=strdup(routine);
-      nag4.nm.z.z_len=strlen(routine);
-      
-      /* get XDR data in call argument */
-      /* should be done by mmap */
-      if((nfp2=fopen(datafile,"r"))==NULL)
-	{
-	  fprintf(stderr,"can't open data file\n");
-	  fclose(nfp2);
-	  goto END;
-	}
-      
-      fclose(nfp2);
-      i=size_of_file(datafile);
-      nag4.y.z.z_val=(char *)malloc(i*sizeof(char));
-      
-      fd=open(datafile,O_RDONLY);
-      read(fd,nag4.y.z.z_val,i);
-      close(fd);
-      nag4.y.z.z_len=i;
-      
-      
-      /*
-       * Create client "handle" used for calling MESSAGEPROG on
-       * the server designated on the command line.  We tell
-       * the RPC package to use the "tcp" protocol when
-       * contacting the server.
-       */
-      
-      /* update naghost by lookup */
-      
-      if ((junk = inet_addr(naghost))!=-1)
-	{
-	  addrnum=(struct in_addr *)junk;
-	  if((alias2=gethostbyaddr((char *)&addrnum,
-				   sizeof(addrnum),
-				   AF_INET))!=NULL)
-	    strcpy(naghost,alias2->h_name);
-	  else
-	    if((alias1=gethostbyname(naghost))!=NULL)
-	      strcpy(naghost,alias1->h_name);
-	}
-      else
-	if((alias1=gethostbyname(naghost))!=NULL)
-	  strcpy(naghost,alias1->h_name);
-      
-      
-      
-      
-      cl = clnt_create(naghost, NAGPROG, NAGVERS, "tcp");
-      if (cl == NULL)
-	{
-	  /*
-	   * Couldn't establish connection with server.
-	   * Print error message and die.
-	   */
-	  clnt_pcreateerror(naghost);
-	  goto END;
-	}
-      else
-	if (showMessage==DO)
-	  printf("nagman:connection successful to %s\n",naghost);
-      
-      /*
-       * this number here sets the "timeout" for the rpc call. after this number
-       * of seconds, the call will quit if no response is received
-       *
-       */
-      
-      tv.tv_sec=1000000;
-      tv.tv_usec=0;
-      clnt_control(cl,CLSET_TIMEOUT,(char *)&tv);
-      
-      
-      result = callnag_1(&nag4, cl);
-      
-      for(phost=hlist;phost!=NULL;phost=phost->next)
-	{
-	  /*
-	   * hlist is the "hostlist" of sites that have been contacted by nagman.
-	   * here we check if this call is contacting a new site, and if so add it
-	   * to the hostlist
-	   *
-	   */
-	  
-	  if(!strcmp(phost->name,naghost))
-	    goto SKIP;
-	}
-      
-      if(hnum==0) {
-	hlist=(struct hostnode *)malloc(sizeof(struct hostnode));
-	hlist->name=strdup(naghost);
-	hlist->next=NULL;
-      }
-      
-      else {
-	phost=(struct hostnode *)malloc(sizeof(struct hostnode));
-	phost->name=strdup(naghost);
-	phost->next=hlist;
-	hlist=phost;
-      }
-      hnum++;
-      
-      
-    SKIP:
-      if (result == NULL)
-	{
-	  /*
-	   * An error occurred while calling the server.
-	   * Print error message and die.
-	   */
-	  if (showMessage==DO)
-	    printf("nagman:no results (error) from %s\n",naghost);
-	  clnt_perror(cl,naghost);
-	  clnt_destroy(cl);
-	  goto END;
-	}
-      
-      /*
-       * (*result).p is the part of the result with the XDRed results in it 
-       * (numbers). (*result).q is the part with (text) error messages that 
-       * have come from the NAG library. If there is neither an XDR result,
-       * nor a text error message from the library, then something is wrong
-       * so we just print out the "no result or error returned" message.
-       *
-       */
-      
-      else if ((*result).p.z.z_len==0)
-	{
-	  if((*result).q.z.z_len==0)
-	    {
-	      if (showMessage==DO)
-		printf("nagman:empty result (error) from %s\n",naghost);
-	      clnt_destroy(cl);
-	      goto END;
-	    }
-	  else
-	    {
-	      if (showMessage==DO)
-		printf("nagman:receiving results from %s\n\n",naghost);
-	      for(j=0;j<(*result).q.z.z_len;j++)
-		printf("%c",(*result).q.z.z_val[j]);
-	      clnt_destroy(cl);
-	      goto END;
-	    }
-	}
-      else
-	if (showMessage==DO)
-	  printf("nagman:receiving results from %s\n\n",naghost);
-      
-      if (showMessage==DO)
-	fwrite(result->q.z.z_val,sizeof(char),result->q.z.z_len,stdout);
-      
-      /*INFO		printf("\nRESULTS of length %d\n",(*result).p.z.z_len);*/
-      
-      fwrite(result->p.z.z_val,sizeof(char),result->p.z.z_len, nfp3);
-      res=1;
-      clnt_destroy(cl);
-      
-      /*
-       * in case of any type of error, a goto END in the above code causes
-       * nagman to skip here and return to AXIOM
-       *
-       */
-      
-      
-    END:
-      fclose(nfp3);
-      /*
-       * if everything has gone alright, send_int returns the integer res=1. If
-       * not it returns res=0. This is detected by the boot code which acts 
-       * accordingly.
-       */
-      send_int(sock1,res);
-      free(Buf);
-    }
-  
-  
-}
-
-\end{chunk}
-\subsection{catchSignals}
-catchSignals sets up signal handling. If nagman gets a sigterm it does not
-die but goes back to rpcloop
-\begin{chunk}{nag.catchSignals}
-static void 
-catchSignals(void)
-{
-  bsdSignal(SIGTERM,term,RestartSystemCalls);
-  bsdSignal(SIGSEGV,term,RestartSystemCalls);
-}
-
-\end{chunk}
-\subsection{main nagman}
-\begin{chunk}{nag.main}
-void 
-main(int argc,char **argv)
-{
-  char this[256],*hname,*dname,*spadnum;
-  int stat;
- 
-  catchSignals();
-  stat=gethostname(this,256);
-  if (stat!=0) perror("gethostname");
-  hname=strdup(this);
-
-  stat=getdomainname(this,256);
-  if (stat!=0) perror("getdomainname");
-  dname=strdup(this);
-  spadnum=getenv("SPADNUM");
-  if (spadnum==0) {
-    fprintf(stderr,"nagman error: SPADNUM is not in the environment\n");
-    exit(0);
-  }
-
-  /* some machines return a full name from hostname 
-     need to check hname has a . in it */
-
-  if  (strchr(hname,'.'))
-    /* '.' found */
-    sprintf(this,"%s_%i",hname,atoi(spadnum));
-  else
-    /* substring not found */
-    sprintf(this,"%s.%s_%i",hname,dname,atoi(spadnum));
-
-  /* this must contain the Internet address of the current host */
-  nag4.id.z.z_val=strdup(this);
-  nag4.id.z.z_len=strlen(nag4.id.z.z_val);
-  hnum=0;
-  vmax=0;
-  /*
-   * this line sets up a socket for communication with the lisp
-   */
-
-  sock1 = connect_to_local_server(SpadServer, DebugWindow, 120 /*seconds*/);
-  if (!sock1) exit(0);
-
-  rpcloop();
-}
-
-\end{chunk}
-\subsection{nagman}
-\begin{chunk}{nagman}
-#define _NAGMAN_C
-\getchunk{nag.includes}
-\getchunk{nag.variables}
-\getchunk{nag.term}
-\getchunk{nag.sizeoffile}
-\getchunk{nag.rpcloop}
-\getchunk{nag.catchSignals}
-\getchunk{nag.main}
-\end{chunk}
 
 \chapter{The {\tt hypertex} program}
 \begin{chunk}{the hypertex command line}
@@ -2221,11 +1845,11 @@ char *SessionManagerProgram = "$AXIOM/lib/session";
 #ifdef SGIplatform
 #include <bstring.h>
 #endif
-#include "com.h"
-#include "bsdsignal.h"
-#include "sockio-c.h1"
-#include "bsdsignal.h1"
-#include "session.h1"
+\getchunk{include/com.h}
+\getchunk{include/bsdsignal.h}
+\getchunk{include/sockio-c.h1}
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/session.h1}
 
 \end{chunk}
 \subsection{variables}
@@ -2744,7 +2368,7 @@ main(void)
 
 \end{chunk}
 \subsection{session}
-\begin{chunk}{session}
+\begin{chunk}{session.c}
 /* #define DEBUG */
 #define _SESSION_C
 
@@ -2771,17 +2395,17 @@ main(void)
 char *SpadClientProgram = "$AXIOM/lib/spadclient";
 \end{chunk}
 \section{spadclient}
-\begin{chunk}{spadclient}
+\begin{chunk}{spadclient.c}
 #define _SPADCLIENT_C
 
 #include <stdio.h>
 #include <signal.h>
-#include "com.h"
-#include "bsdsignal.h"
 
-#include "bsdsignal.h1"
-#include "sockio-c.h1"
-#include "spadclient.h1"
+\getchunk{include/com.h}
+\getchunk{include/bsdsignal.h}
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/sockio-c.h1}
+\getchunk{include/spadclient.h1}
 
 Sock *sock;
 
@@ -6995,164 +6619,59 @@ real line in general but could, for instance, range over the complex plane.
 Note that the provisos need not be an interval. They could be anything
 such as a polynomial or a property like ``$f(x)$ is entire''.
 \chapter{Makefile}
-\section{Environment variables}
-\begin{chunk}{make.environment}
-BOOK=${SPD}/books/bookvol6.pamphlet
-
-# this is where we are compiling from
-IN=     ${SRC}/sman
-
-# this is the intermediate place 
-MID=    ${INT}/sman
+\begin{chunk}{*}
 
-# this is the intermediate place 
-MIDOBJ=    ${OBJ}/${SYS}/sman
+BOOK=${SPD}/books/bookvol6.pamphlet
 
 # this is where to put the various commands
 OUT=	${MNT}/${SYS}/bin
 OUTLIB=	${MNT}/${SYS}/lib
 
-# this is where the include files live
-INC=    ${SRC}/include
-
 # this is where we hid the libspad library
 LIB=	${OBJ}/${SYS}/lib
 
 # this is where the documentation ends up
-DOC=    ${MNT}/${SYS}/doc
-CFLAGS=	${CCF} 
 LDFLAGS= -L${LIB} -lspad ${LDF}
 
-SMANOBJS= ${LIB}/libspad.a
+all:	announce ${OUTLIB}/session ${OUTLIB}/spadclient ${OUT}/sman \
+        ${OUT}/axiom finish
 
-\end{chunk}
-\section{The axiom command}
-\begin{chunk}{make.axiomcmd}
-${OUT}/axiom: ${BOOK}
-	@echo 1 making ${OUT}/axiom from ${BOOK}
-	@ (cd ${OUT} ; \
-        echo '(tangle "${BOOK}" "axiomcmd" "axiom")' | ${OBJ}/${SYS}/bin/lisp )
-	@chmod +x ${OUT}/axiom
-	@ cp ${OUT}/axiom ${MID}
-
-\end{chunk}
-\section{session}
-\begin{chunk}{make.session}
-${OUTLIB}/session: ${SMANOBJS} ${MIDOBJ}/session.o
-	@ echo 1 linking session
-	@ ${CC} -o ${OUTLIB}/session ${MIDOBJ}/session.o ${SMANOBJS} 
-
-${MID}/session.c: ${BOOK}
-	@ echo 2 making ${MID}/session.c from ${BOOK}
-	@ (cd ${MID} ; \
-        echo '(tangle "${BOOK}" "session" "session.c")' | \
-          ${OBJ}/${SYS}/bin/lisp )
-
-${MIDOBJ}/session.o: ${MID}/session.c ${INC}/session.h1
-	@ echo 3 making ${MIDOBJ}/session.o from ${MID}/session.c
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MID}/session.c -I${INC} )
+announce:
+	@ echo ==================================================
+	@ echo Making sman, session, spadclient, axiom bookvol6
+	@ echo ==================================================
 
-\end{chunk}
-\section{nagman}
-Note that we do not build the nagman component as we do not have the
-necessary code (for instance, callnag).
-\begin{chunk}{make.nagman}
-${OUT}/nagman:	${SMANOBJS} ${MIDOBJ}/nagman.o
-	@ echo 5 linking nagman
-	@ ${CC} -o ${OUT}/nagman ${MIDOBJ}/nagman.o ${SMANOBJS} 
-
-${MID}/nagman.c: ${BOOK}
-	@ echo 6 making ${MID}/nagman.c from ${IN}/bookvol6.pamphlet
-	@ (cd ${MID} ; \
-        echo '(tangle "${BOOK}" "nagman" "nagman.c")' | \
-           ${OBJ}/${SYS}/bin/lisp )
-
-${MIDOBJ}/nagman.o: ${MID}/nagman.c ${INC}/nagman.h1
-	@ echo 7 making ${MIDOBJ}/nagman.o from ${MID}/nagman.c
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MID}/nagman.c -I${INC} )
+finish:
+	@ echo ====================================================
+	@ echo Finished sman, session, spadclient, axiom bookvol6
+	@ echo ====================================================
 
-\end{chunk}
-\section{spadclient}
-\begin{chunk}{make.spadclient}
-${OUTLIB}/spadclient: ${SMANOBJS} ${MIDOBJ}/spadclient.o
-	@ echo 9 linking spadclient
-	@ ${CC} -o ${OUTLIB}/spadclient ${MIDOBJ}/spadclient.o  ${SMANOBJS} 
+${OUTLIB}/session: ${LIB}/libspad.a
+	@ echo 1 making ${OUTLIB}/session from ${BOOK}
+	@ (cd ${LIB} ; \
+           ${BOOKS}/tanglec ${BOOK} session.c >session.c ; \
+	   ${CC} ${CCF} -o ${OUTLIB}/session session.c libspad.a )
 
-${MID}/spadclient.c: ${BOOK}
-	@ echo 10 making ${MID}/spadclient.c from ${IN}/bookvol6.pamphlet
-	@ (cd ${MID} ; \
-        echo '(tangle "${BOOK}" "spadclient" "spadclient.c")' | \
-           ${OBJ}/${SYS}/bin/lisp )
+${OUTLIB}/spadclient: ${LIB}/libspad.a
+	@ echo 2 making ${OUTLIB}/spadclient from ${BOOK}
+	@ (cd ${LIB} ; \
+           ${BOOKS}/tanglec ${BOOK} spadclient.c >spadclient.c ; \
+	   ${CC} ${CCF} -o ${OUTLIB}/spadclient spadclient.c libspad.a )
 
-${MIDOBJ}/spadclient.o: ${MID}/spadclient.c ${INC}/spadclient.h1
-	@ echo 11 making ${MIDOBJ}/spadclient.o from ${MID}/spadclient.c
-	@ ( cd ${MIDOBJ} ; ${CC} -c ${CFLAGS} ${MID}/spadclient.c -I${INC} )
+${OUT}/axiom: ${BOOK}
+	@ echo 3 making ${OUT}/axiom from ${BOOK}
+	@ (cd ${OUT} ; ${BOOKS}/tanglec ${BOOK} axiomcmd >axiom )
+	@ chmod +x ${OUT}/axiom
 
-\end{chunk}
-\section{sman}
-\begin{chunk}{make.sman}
-${OUT}/sman: ${SMANOBJS} ${MIDOBJ}/sman.o
-	@ echo 13 linking sman
-	@ ${CC} -o ${OUT}/sman ${MIDOBJ}/sman.o ${SMANOBJS} 
-
-${MID}/sman.h: ${BOOK}
-	@ echo 00 making ${MID}/sman.h from ${IN}/bookvol6.pamphlet
-	@ (cd ${MID} ; \
-        echo '(tangle "${BOOK}" "sman.h" "sman.h")' | \
-           ${OBJ}/${SYS}/bin/lisp )
-
-${MID}/sman.c: ${MID}/sman.h ${BOOK}
-	@ echo 14 making ${MID}/sman.c from ${IN}/bookvol6.pamphlet
-	@ (cd ${MID} ; \
-        echo '(tangle "${BOOK}" "sman" "sman.c")' | \
-           ${OBJ}/${SYS}/bin/lisp )
-
-${MIDOBJ}/sman.o: ${MID}/sman.c ${INC}/sman.h1
-	@ echo 15 making ${MIDOBJ}/sman.o from ${MID}/sman.c
-	@ ( cd ${MIDOBJ} ; ${CC} -I${INC} -I${MID} -c ${CFLAGS} ${MID}/sman.c )
+${OUT}/sman: ${LIB}/libspad.a
+	@ echo 4 making ${OUT}/sman from ${BOOK}
+	@ (cd ${LIB} ; \
+           ${BOOKS}/tanglec ${BOOK} sman.c >sman.c ; \
+	   ${CC} ${CCF} -o ${OUT}/sman sman.c libspad.a )
 
 \end{chunk}
-\begin{chunk}{*}
-\getchunk{make.environment}
-all:	${OUTLIB}/session ${OUTLIB}/spadclient ${OUT}/sman ${OUT}/axiom 
-	@ echo 18 finished ${IN}
-
-clean:
-	@echo 19 cleaning ${SRC}/sman
-
-\getchunk{make.axiomcmd}
-\getchunk{make.sman}
-\getchunk{make.session}
-\getchunk{make.spadclient}
-\getchunk{make.nagman}
-\end{chunk}
 \begin{thebibliography}{99}
-\bibitem{1} Jenks, R.J. and Sutor, R.S. \\
-``Axiom -- The Scientific Computation System''\\
-Springer-Verlag New York (1992)
-ISBN 0-387-97855-0
-\bibitem{2} Knuth, Donald E., ``Literate Programming''\\
-Center for the Study of Language and Information
-ISBN 0-937073-81-4
-Stanford CA (1992) 
-\bibitem{3} Page, William, ``The Axiom Wiki Website''\\
-{\bf http://wiki.axiom-developer.org}
-\bibitem{4} Watt, Stephen, ``Aldor'',\\
-{\bf http://www.aldor.org}
-\bibitem{5} Lamport, Leslie,\\
-``Latex -- A Document Preparation System'',
-Addison-Wesley, New York ISBN 0-201-52983-1
-\bibitem{6} Ramsey, Norman\\
-``Noweb -- A Simple, Extensible Tool for Literate Programming''\\
-{\bf http://www.eecs.harvard.edu/ $\tilde{}$nr/noweb}
-\bibitem{7} Axiom Book Volume 7 -- Hyperdoc\\
-{\bf file://usr/local/axiom/src/hyper/bookvol7.pamphlet}
-\bibitem{8} Axiom Book Volume 8 -- Graphics\\
-{\bf file://usr/local/axiom/src/graph/bookvol8.pamphlet}
-\bibitem{9} AIX Version 3.2 and 4 Performance Tuning Guide\\
-{\bf 
-http://www.rs6000.ibm.com/doc\_link/en\_US/\\
-{\hbox {\hskip 1.0cm}}a\_doc\_lib/aixbman/prftungd/toc.htm}
+\bibitem nothing
 \end{thebibliography}
 \printindex
 \end{document}
diff --git a/books/bookvol7.1.pamphlet b/books/bookvol7.1.pamphlet
index 04c5c59..1c25cb7 100644
--- a/books/bookvol7.1.pamphlet
+++ b/books/bookvol7.1.pamphlet
@@ -191405,13 +191405,18 @@ PAGEFILE=${HYPER}/bookvol7.1.pamphlet
 SMAN=${MNT}/${SYS}/bin/sman
 HTADD=${MNT}/${SYS}/bin/htadd
 
-all: dir ${PAGEFILE} ${HYPER}/ht.db
+all: announce ${PAGEFILE} ${HYPER}/ht.db finish
 	@echo 3 finished ${BOOK}
 
-dir:
-	@echo 0 making hypertex directories
-	@mkdir -p ${WORK}
-	@mkdir -p ${HYPER}
+announce:
+	@ echo ==================================
+	@ echo Making hyperdoc pages bookvol7.1
+	@ echo ==================================
+
+finish:
+	@ echo ==================================
+	@ echo Finish hyperdoc pages bookvol7.1
+	@ echo ==================================
 
 \end{chunk}
 Due to the awesome programming skills of Scott Morrison
diff --git a/books/bookvol7.pamphlet b/books/bookvol7.pamphlet
index dfbd745..1113a40 100644
--- a/books/bookvol7.pamphlet
+++ b/books/bookvol7.pamphlet
@@ -4074,6 +4074,1491 @@ cflow --emacs -l -n -b -T --omit-arguments hypertex.c
  1876 {   3}       \-fprintf()
 
 \end{verbatim}
+\chapter{include}
+\label{include}
+This chapter contains the include files. Unlike normal C programs
+we replace the 'include' directive by the actual chunk from this
+chapter. The results are that the include files never get written
+to disk and the compiler never sees the include directive, resulting
+in faster compile times.
+
+The include files are collected from both the view* programs and 
+the low level C code that supports them, including libspad which,
+in general, have the file extension of 'h1' rather than 'h'.
+\section{include/actions.h}
+\begin{chunk}{include/actions.h}
+/* from bookvol7 chunk include/actions.h */
+#define makeAViewport -1
+
+
+/* Viewport Types */
+#define view3DType     1
+#define viewGraphType  2
+#define view2DType     3
+#define viewTubeType   4
+
+/* 2D Viewport */
+
+#define translate2D   0
+#define scale2D       1
+#define pointsOnOff   2
+#define connectOnOff  3
+#define spline2D      4
+#define reset2D       5
+#define hideControl2D 6
+#define closeAll2D    7
+#define axesOnOff2D   8
+#define unitsOnOff2D  9
+#define pick2D        10
+#define drop2D        11
+#define clear2D       12
+#define ps2D          13
+#define graph1        14
+#define graph2        15
+#define graph3        16
+#define graph4        17
+#define graph5        18
+#define graph6        19
+#define graph7        20
+#define graph8        21
+#define graph9        22
+#define graphSelect1  23
+#define graphSelect2  24
+#define graphSelect3  25
+#define graphSelect4  26
+#define graphSelect5  27
+#define graphSelect6  28
+#define graphSelect7  29
+#define graphSelect8  30
+#define graphSelect9  31
+#define query2D       32
+#define zoom2Dx       33
+#define zoom2Dy       34
+#define translate2Dx  35
+#define translate2Dy  36
+
+#define maxButtons2D 37
+
+#define graphStart    14  /* the index of graph1 */
+#define graphSelectStart (graphStart+maxGraphs)
+
+/* 3D Viewport */
+
+#define controlButtonsStart3D 0
+
+#define rotate       0
+#define zoom         1
+#define translate    2
+#define render       3
+#define hideControl  4
+#define closeAll     5
+#define axesOnOff    6
+#define opaqueMesh   7
+#define resetView    8
+#define transparent  9 
+
+#define lighting     10
+#define viewVolume   11
+#define region3D     12
+#define outlineOnOff 13
+
+#define zoomx        14
+#define zoomy        15
+#define zoomz        16      
+#define originr      17   
+#define objectr      18
+#define xy           19
+#define xz           20
+#define yz           21
+#define smooth       22
+#define saveit       23
+#define bwColor      24
+
+#define maxControlButtons3D 25
+#define controlButtonsEnd3D (controlButtonsStart3D + maxControlButtons3D)
+
+#define graphStart3D  25  /* the index of g1 */
+#define graphSelectStart3D (graphStart3D+maxGraphs)
+
+/* these should be maxControlButtons3D+1.. (be sure to modify view3d.spad) */
+#define diagOnOff            (maxControlButtons3D+1)
+#define perspectiveOnOff     (maxControlButtons3D+2)
+#define clipRegionOnOff      66
+#define clipSurfaceOnOff     67
+
+#define query       11
+
+
+/* misc */
+
+#define spadPressedAButton 100  /* used for communications with the .AXIOM file */
+#define colorDef           101
+#define moveViewport       102
+#define resizeViewport     103
+#define changeTitle        104
+#define showing2D          105
+#define putGraph           106 /* for 2D */
+#define getGraph           107 /* for 2D */
+#define lightDef           108 /* for 3D */
+#define translucenceDef    109 /* for 3D */
+#define writeView          110 /* for both */
+#define eyeDistanceData    111 /* for 3D */
+#define axesColor2D        112 /* for 2D */  
+#define unitsColor2D       113 /* for 2D */
+#define modifyPOINT        114 /* for 3D */
+#define hitherPlaneData    116 /* for 3D */
+
+\end{chunk}
+
+\section{include/rgb.h}
+\index{rgb.h}
+\index{struct!RGB}
+\index{RGB struct}
+\index{struct!HSV}
+\index{HSV struct}
+\index{struct!HLS}
+\index{HLS struct}
+\begin{chunk}{include/rgb.h}
+/* from bookvol7 chunk include/rgb.h */
+typedef struct _RGB {
+  float r,g,b;
+} RGB ;
+
+typedef struct _HSV {
+  float h,s,v;
+} HSV ;
+
+typedef struct _HLS {
+  float h,l,s;
+} HLS ;
+
+\end{chunk}
+\section{include/spadcolors.h}
+\index{spadcolors.h}
+\begin{chunk}{include/spadcolors.h}
+/* from bookvol7 chunk include/spadcolors.h */
+#define numOfColors 240
+#define totalHuesConst   27 
+#define totalShadesConst 5 
+#define hueEnd  360
+#define hueStep 12    /* hueEnd/totalHuesConst */
+
+#define numPlanes 1
+#define numColors 10
+#define startColor 0
+#define endColor   startColor+numColors
+
+#define colorStep (maxColors+1)/numColors
+
+#define yes 1
+#define no 0
+
+#define smoothConst  50
+#define saymem(a,b,c) saymemWithLine(a,b,c,0)
+#define Colorcells 256   /* KF number of elements in permutation vector */
+#define shade 5
+#define saturation   0.8
+
+extern int       smoothHue;
+extern Colormap  colorMap;
+extern int       num;
+
+#define maxColors DisplayCells(dsply,scrn)-1
+
+\getchunk{include/rgb.h}
+\end{chunk}
+
+\section{include/addfile.h1}
+\begin{chunk}{include/addfile.h1}
+/* from bookvol7 chunk include/addfile.h1 */
+extern FILE * db_file_open(char * db_file);
+extern void extend_ht(char * name);
+extern FILE * ht_file_open(char * fname , char * aname , char * name);
+extern FILE * temp_file_open(char * temp_db_file);
+#ifdef _ADDFILE_C
+static int build_ht_filename(char * fname , char * aname , char * name);
+static int pathname(char * name);
+static int strpostfix(char * s , char * t);
+#endif
+\end{chunk}
+
+\section{include/all-hyper-proto.h1}
+\begin{chunk}{include/all-hyper-proto.h1}
+/* from bookvol7 chunk include/all-hyper-proto.h1 */
+\getchunk{include/addfile.h1}
+\getchunk{include/readbitmap.h1}
+\getchunk{include/dialog.h1}
+\getchunk{include/cond.h1}
+\getchunk{include/display.h1}
+\getchunk{include/event.h1}
+\getchunk{include/ex2ht.h1}
+\getchunk{include/form-ext.h1}
+\getchunk{include/extent1.h1}
+\getchunk{include/extent2.h1}
+\getchunk{include/halloc.h1}
+\getchunk{include/group.h1}
+\getchunk{include/hterror.h1}
+\getchunk{include/htinp.h1}
+\getchunk{include/hyper.h1}
+\getchunk{include/initx.h1}
+\getchunk{include/input.h1}
+\getchunk{include/keyin.h1}
+\getchunk{include/item.h1}
+\getchunk{include/lex.h1}
+\getchunk{include/parse.h1}
+\getchunk{include/macro.h1}
+\getchunk{include/parse-paste.h1}
+\getchunk{include/parse-aux.h1}
+\getchunk{include/parse-input.h1}
+\getchunk{include/show-types.h1}
+\getchunk{include/parse-types.h1}
+\getchunk{include/scrollbar.h1}
+\getchunk{include/titlebar.h1}
+\getchunk{include/spadint.h1}
+\getchunk{include/hash.h1}
+\getchunk{include/mem.h1}
+\end{chunk}
+
+\section{include/bsdsignal.h}
+\begin{chunk}{include/bsdsignal.h}
+/* from bookvol7 chunk include/bsdsignal.h */
+#ifndef _BSDSIGNAL_H_
+#define _BSDSIGNAL_H_
+
+#define RestartSystemCalls 1
+#define DontRestartSystemCalls 0
+
+typedef void (* SignalHandlerFunc)(int);
+
+#endif	    /* _BSDSIGNAL */
+\end{chunk}
+
+\section{include/bsdsignal.h1}
+\begin{chunk}{include/bsdsignal.h1}
+/* from bookvol7 chunk include/bsdsignal.h1 */
+extern SignalHandlerFunc bsdSignal(int  , SignalHandlerFunc  , int );
+\end{chunk}
+
+\section{include/com.h}
+\begin{chunk}{include/com.h}
+/* from bookvol7 chunk include/com.h */
+#ifndef _COM_H_
+#define _COM_H_
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#if defined(RIOSplatform)
+#include <sys/select.h>
+#endif
+
+typedef struct {
+  int socket;           /* socket number returned by "socket" call */
+  int type;             /* socket type (AF_UNIX or AF_INET) */
+  int purpose;          /* can be SessionManager, GraphicsServer, etc. */
+  int pid;              /* process ID of connected socket */
+  int frame;            /* spad interpreter frame (for interpreter windows) */
+  int remote_fd;        /* file descriptor of remote socket */
+  union {
+    struct sockaddr u_addr;
+    struct sockaddr_in i_addr;
+  } addr;
+  char *host_name;      /* name of foreign host if type == AF_INET */
+} Sock;
+
+#define MaxClients      150
+
+/* possible socket types (purpose) */
+
+#define SessionManager  1
+#define ViewportServer  2
+#define MenuServer      3
+#define SessionIO       4
+#define BaloonServer    5
+#define InterpWindow    6
+#define KillSpad        7
+#define DebugWindow     8  
+#define Forker          9
+#define AV              10 /*Simon's algebraic viewer */
+
+#define Acknowledge     255
+
+/* Timeout value for connection to remote socket */
+
+#define Forever 0
+
+/* Socket name for local AXIOM server and session manager */
+
+#define SpadServer              "/tmp/.d"
+#define SessionServer           "/tmp/.s"
+#define SessionIOName           "/tmp/.i"
+#define MenuServerName          "/tmp/.h"
+#define ForkServerName          "/tmp/.f"
+
+
+#define MASK_SIZE       (NBBY*sizeof(fd_set))
+
+
+/* table of dedicated socket types */
+
+extern Sock *purpose_table[];
+extern Sock server[];
+extern Sock clients[];
+extern fd_set socket_mask;
+extern fd_set server_mask;
+
+/* Commands sent over the AXIOM session manager or menu socket */
+
+#define CreateFrame             1
+#define SwitchFrames            2
+#define EndOfOutput             3
+#define CallInterp              4
+#define EndSession              5
+#define LispCommand             6
+#define SpadCommand             7
+#define SendXEventToHyperTeX    8
+#define QuietSpadCommand        9
+#define CloseClient             10
+#define QueryClients            11
+#define QuerySpad               12
+#define NonSmanSession          13
+#define KillLispSystem          14
+
+#define CreateFrameAnswer       50
+
+/* Commands from AXIOM menu server to interpreter windows */
+
+#define ReceiveInputLine        100
+#define TestLine                101
+
+#endif
+\end{chunk}
+
+\section{include/cond.h1}
+\begin{chunk}{include/cond.h1}
+/* from bookvol7 chunk include/cond.h1 */
+extern void change_cond(char * label , char * newcond);
+extern int check_condition(TextNode * node);
+extern void insert_cond(char * label , char * cond);
+#ifdef _COND_C
+static int check_memostack(TextNode * node);
+#endif
+\end{chunk}
+
+\section{include/cursor.h1}
+\begin{chunk}{include/cursor.h1}
+/* from bookvol7 chunk include/cursor.h1 */
+extern int Cursor_shape(int );
+\end{chunk}
+
+\section{include/debug.h}
+\begin{chunk}{include/debug.h}
+/* from bookvol7 chunk include/debug.h */
+/* redefine free */
+/* #define free hfree*/
+\end{chunk}
+
+\section{include/dialog.h1}
+\begin{chunk}{include/dialog.h1}
+/* from bookvol7 chunk include/dialog.h1 */
+extern void add_buffer_to_sym(char * buffer , InputItem * sym);
+extern void dialog(XEvent * event , KeySym keysym , char * buffer);
+extern void draw_inputsymbol(InputItem * sym);
+extern void update_inputsymbol(InputItem * sym);
+#ifdef _DIALOG_C
+static void back_over_char(InputItem * sym);
+static void back_over_eoln(InputItem * sym);
+static void clear_cursor(InputItem * sym);
+static void clear_cursorline(InputItem * sym);
+static void dec_line_numbers(LineStruct * line);
+static void decrease_line_numbers(LineStruct * line , int am);
+static void delete_char(InputItem * sym);
+static void delete_eoln(InputItem * sym);
+static int delete_one_char(InputItem * sym);
+static void delete_rest_of_line(InputItem * sym);
+static void draw_cursor(InputItem * sym);
+static void enter_new_line(InputItem * sym);
+static void inc_line_numbers(LineStruct * line);
+static void insert_buffer(char * buffer , InputItem * sym);
+static int move_back_one_char(InputItem * sym);
+static void move_cursor_backward(InputItem * sym);
+static void move_cursor_down(InputItem * sym);
+static void move_cursor_end(InputItem * sym);
+static void move_cursor_forward(InputItem * sym);
+static void move_cursor_home(InputItem * sym);
+static void move_cursor_up(InputItem * sym);
+static char move_rest_back(LineStruct * line , int size);
+static int move_sym_forward(LineStruct * line, int num, int size, 
+                            InputItem * sym);
+static char * mystrncpy(char * buff1 , char * buff2 , int n);
+static void overwrite_buffer(char * buffer , InputItem * item);
+static void redraw_win(void);
+static void tough_enter(InputItem * sym);
+#endif 
+\end{chunk}
+
+\section{include/display.h1}
+\begin{chunk}{include/display.h1}
+/* from bookvol7 chunk include/display.h1 */
+extern void expose_page(HyperDocPage * page);
+extern void paste_page(TextNode * node);
+extern void scroll_page(HyperDocPage * page);
+extern void show_page(HyperDocPage * page);
+\end{chunk}
+
+\section{include/edible.h}
+\begin{chunk}{include/edible.h}
+/* from bookvol7 chunk include/edible.h */
+extern int contNum;
+extern struct termios childbuf;	  /** the childs normal operating termio   ***/
+
+/***   the terminals mapping of the function keys			 ***/
+extern unsigned char  _INTR, _QUIT, _ERASE, _KILL, _EOF, _EOL, _RES1, _RES2;
+extern short  INS_MODE ;     /** Flag for insert mode		     **/
+extern short ECHOIT;	     /** Flag for echoing **/
+extern short PTY;   /* A flag which lets me know whether or not I am 
+		       talking to a socket or a pty. If I am not 
+		       talking to a PTY then I have to do things like echo
+		      back newlines, and send interuppts with an eoln
+		      */
+/***************************************************************************
+    Here are the key mapping my routines need
+****************************************************************************/
+
+#define	      _ESC   0X1B    /**  A character sent before every arrow key ***/
+#define	      _LBRACK  0X5B    /**  [				      **/
+#define	      _EOLN    '\n'    /** eoln				      **/
+#define	      _CR      0X0D    /**  cr				      **/
+#define	      _BLANK   0X20    /**  blank			      **/
+#define	      _BKSPC   0X08    /**  backspace			      **/
+#define	      _DEL     0X7F    /**  delete			      **/
+#define	      _BELL    0X07    /***  ring the bell		      **/
+#define	      _INT     0X7F    /***  interrupt			      **/
+#define	      _SQUASH  0X03    /**   kill my process		      **/
+#define	      _CNTRL_W 0X17    /**   cntrl-w, to back up a word	      **/
+#define	      _CARROT  0X5E    /** circumflex			      **/
+#define	      _TAB     0X09    /** tab forward			      **/
+
+#ifndef WCT
+#define	      _A       0X41    /**  A				      **/
+#define	      _B       0X42    /**  B				      **/
+#define	      _C       0X43    /**  C				      **/
+#define	      _D       0X44    /**  D				      **/
+#define	      _Z       0X5A    /**  Z				      **/
+#define	      _H       0X48    /**  H				      **/
+#define	      _M       0X4D    /**  M				      **/
+#define	      _x       0X78    /**  x				      **/
+#define	      _z       0X7A    /*** z				      **/
+#define	      _twiddle 0X7E    /*** ~				      **/
+#define	      _P       0X50    /*** P				      **/
+#define	      _1       0X31    /*** 1				      **/
+#define	      _2       0X32    /*** 2				      **/
+#define	      _3       0X33    /*** 3				      **/
+#define	      _4       0X34    /*** 4				      **/
+#define	      _5       0X35    /*** 5				      **/
+#define	      _6       0X36    /*** 6				      **/
+#define	      _7       0X37    /*** 7				      **/
+#define	      _8       0X38    /*** 8				      **/
+#define	      _9       0X39    /*** 9				      **/
+#define	      _0       0X30    /*** 0				      **/
+#define	      _q       0X71    /*** q				      **/
+#endif
+
+#define MAXLINE		   1024	  /** maximum chars. on a line		  ***/
+#define MAXBUFF		    64	 /** maximum lines saved in the buffer
+				       queue				***/
+
+/***  Here are the constants for my three different modes. ******/
+#define CLEFRAW			     0
+#define CLEFCANONICAL		     1
+#define CLEFCBREAK		     2
+
+extern int mode;   /** One of the above # defines *****/
+
+/**   Here is the structure for storing bound  pf-keys		   ***/
+typedef struct Fkey
+{
+  char *str;
+  short type;
+} fkey;
+
+extern fkey function_key[13] ;	  /** strings which replace function
+					  keys when a key is hit	  ***/
+
+
+extern char editorfilename[];
+
+/****  Here are a bunch of constant, variable and function defs for edin.c */
+#define UP		     0	 /** Tells the replace buffer command	***/
+#define DOWN		     1	 /**   to look up or down		 **/
+
+#define inc(x)	((x+1)%MAXBUFF)	 /** returns the increment of the presented
+				       pointer				***/
+#define dec(x)	( ((x-1) < 0) ?(MAXBUFF - 1):(x-1))/** ibid for decrementing */
+
+#define flip(x)	  (x?(x=0):(x=1))      /*** flip the bit		  ***/
+
+/*
+    All the previous commands will now be stored in a double linked list.
+  This way when I type a command I just have to circle through this list
+*/
+typedef struct que_struct {
+   char buff[1024];
+   int flags[1024];
+   struct que_struct *prev, *next;
+   } QueStruct;
+
+typedef struct wct {
+    char *fname;
+    off_t fsize;
+    time_t ftime;
+    char *fimage;
+    int wordc;
+    char **wordv;
+
+    struct wct *next;
+} Wct;
+
+typedef struct wix {
+    Wct *pwct;
+    int word;
+} Wix;
+
+
+extern QueStruct *ring;
+extern QueStruct *current;
+extern int ring_size;
+extern int prev_check;
+extern int MAXRING;
+
+extern char buff[MAXLINE];		   /**	Buffers for collecting input and  **/
+extern int  buff_flag[MAXLINE];	   /**	   flags for whether buff chars
+					   are printing
+					   or non-printing		  **/
+
+extern char in_buff[1024];   /**     buffer for characters read until they are
+				      processed				  **/
+extern int num_read;
+extern int num_proc;	     /**   num chars processed after a read	  **/
+extern int buff_pntr;	     /**   present length of  buff		  **/
+extern int curr_pntr;	     /** the current position in buff		  **/
+
+/** Here are a bunch of macros for edin.c. They are mostly just charcter
+	comparison stuff						  ***/
+#define back_word(x) (((*(x) == _5) && (*(x+1) == _9) && \
+					(*(x+2) == _q))?(1):(0))
+
+#define fore_word(x) (((*(x) == _6) && (*(x+1) == _8) && \
+					(*(x+2) == _q))?(1):(0))
+
+#define alt_f1(x) (((*(x) == _3) && (*(x+1) == _7) && \
+					(*(x+2) == _q))?(1):(0))
+
+#define cntrl_end(x) (((*(x) == _4) && (*(x+1) == _8) && \
+					(*(x+2) == _q))?(1):(0))
+
+#define insert_toggle(x) (((*(x) == _3) && (*(x+1) == _9) && \
+					(*(x+2) == _q))?(1):(0))
+
+#define end_key(x) (((*(x) == _4) && (*(x+1) == _6) && \
+					(*(x+2) == _q))?(1):(0))
+
+#define control_char(x) \
+     (((x >= 0x01) && (x <= 0x1a))?(1):(0))
+
+
+
+/***
+   Some global defs needed for emulating a pty. This was taken from guru.h
+***/
+
+
+
+/* Return an integer that is represented by a character string */
+#define ciret(x) ((cintu.c4[0]=(x)[0]), (cintu.c4[1]=(x)[1]), \
+		  (cintu.c4[2]=(x)[2]), (cintu.c4[3]=(x)[3]), cintu.i4)
+
+/* move an integer (x) to a character string (y) */
+
+#define icmove(x, y) ((cintu.i4=(x)), ((y)[0]=cintu.c4[0]), \
+		      ((y)[1]=cintu.c4[1]), ((y)[2]=cintu.c4[2]), \
+			 ((y)[3]=cintu.c4[3]))
+
+/* Return an integer that may not be on an integer boundary */
+#define iiret(x) ciret(((char *)&(x)))
+
+ /* Min of two expressions */
+#define min(x, y) ((x)<(y)?(x):(y))
+
+ /* Max of two expressions */
+#define max(x, y) ((x)>(y)?(x):(y))
+\end{chunk}
+
+\section{include/edible.h1}
+\begin{chunk}{include/edible.h1}
+/* from bookvol7 chunk include/edible.h1 */
+extern void check_flip(void);
+extern int main(int  , char * []);
+extern void catch_signals(void);
+extern void init_parent(void);
+extern void set_function_chars(void);
+extern void hangup_handler(int );
+extern void terminate_handler(int );
+extern void interrupt_handler(int );
+extern void child_handler(int );
+extern void alarm_handler(int );
+extern void flip_canonical(int );
+extern void flip_raw(int );
+extern void etc_get_next_line(char *  , int *  , int );
+\end{chunk}
+
+\section{include/edin.h1}
+\begin{chunk}{include/edin.h1}
+/* from bookvol7 chunk include/edin.h1 */
+extern void init_reader(void);
+extern void init_flag(int *  , int );
+extern void do_reading(void);
+extern void send_line_to_child(void);
+extern void insert_buff_nonprinting(int );
+extern void prev_buff(void);
+extern void next_buff(void);
+extern void insert_buff_printing(int );
+extern void insert_queue(void);
+extern int convert_buffer(char *  , char *  , int *  , int );
+extern void init_buff(char *  , int );
+extern void forwardcopy(char *  , char *  , int );
+extern void forwardflag_cpy(int *  ,int *  , int );
+extern void flagcpy(int *  , int * );
+extern void flagncpy(int *  , int *  , int );
+extern void send_function_to_child(void);
+extern void send_buff_to_child(int );
+\end{chunk}
+
+\section{include/event.h1}
+\begin{chunk}{include/event.h1}
+/* from bookvol7 chunk include/event.h1 */
+extern void exitHyperDoc(void );
+extern void helpForHyperDoc(void );
+extern void mainEventLoop(void );
+extern void make_window_link(char * name);
+extern void quitHyperDoc(void );
+extern void get_new_window(void );
+#ifdef _EVENT_C
+static void set_cursor(HDWindow * window , Cursor state);
+static void change_cursor(Cursor state , HDWindow * window);
+static void create_window(void );
+static void downlink(void );
+static HyperDocPage * find_page(TextNode * node);
+static void handle_button(int button , XButtonEvent * event);
+static void handle_event(XEvent * event);
+static void handle_motion_event(XMotionEvent * event);
+static int HyperDocErrorHandler(Display * display , XErrorEvent * xe);
+static void init_cursor_states(void );
+static void killAxiomPage(HyperDocPage * page);
+static void make_busy_cursor(HDWindow * window);
+static void make_busy_cursors(void );
+static void memolink(void );
+static void set_error_handlers(void );
+static int set_window(Window window);
+static void clear_exposures(Window w);
+static void kill_page(HyperDocPage * page);
+static HyperDocPage * returnlink(void );
+static HyperDocPage * uplink(void );
+static void windowlink_handler(TextNode * node);
+static void lispwindowlink_handler(HyperLink * link);
+static HyperDocPage * paste_button(PasteNode * paste);
+static HyperLink * findButtonInList(HDWindow * window , int x , int y);
+static HyperLink * get_hyper_link(XButtonEvent * event);
+static void init_cursor_state(HDWindow * window);
+#endif
+\end{chunk}
+
+\section{include/ex2ht.h1}
+\begin{chunk}{include/ex2ht.h1}
+/* from bookvol7 chunk include/ex2ht.h1 */
+extern int main(int argc , char * * argv);
+extern void openCoverPage(void);
+extern void exToHt(char * filename);
+extern void closeCoverPage(void);
+extern void addFile(char * filename);
+extern void closeCoverFile(void);
+extern char * allocString(char * s);
+extern char * strPrefix(char * prefix , char * s);
+extern char * getExTitle(FILE * inFile , char * line);
+extern void emitCoverLink(char * name , char * title);
+extern void emitHeader(FILE * outFile , char * pageName , char * pageTitle);
+extern void emitMenuEntry(char * line , FILE * outFile);
+extern void emitSpadCommand(char * line , char * prefix , FILE * outFile);
+extern void emitFooter(FILE * outFile);
+\end{chunk}
+
+\section{include/extent1.h1}
+\begin{chunk}{include/extent1.h1}
+/* from bookvol7 chunk include/extent1.h1 */
+extern void compute_header_extent(HyperDocPage * page);
+extern void compute_footer_extent(HyperDocPage * page);
+extern void compute_scrolling_extent(HyperDocPage * page);
+extern void compute_title_extent(HyperDocPage * page);
+extern void compute_text_extent(TextNode * node);
+#ifdef _EXTENT1_C
+static void compute_begin_items_extent(TextNode * node);
+static void compute_bf_extent(TextNode * node);
+static void compute_box_extent(TextNode * node);
+static void compute_button_extent(TextNode * node);
+static void compute_center_extent(TextNode * node);
+static void compute_dash_extent(TextNode * node);
+static void compute_em_extent(TextNode * node);
+static void compute_ifcond_extent(TextNode * node);
+static void compute_image_extent(TextNode * node);
+static void compute_input_extent(TextNode * node);
+static void compute_ir_extent(TextNode * node);
+static void compute_it_extent(TextNode * node);
+static void compute_item_extent(TextNode * node);
+static void compute_mbox_extent(TextNode * node);
+static void compute_mitem_extent(TextNode * node);
+static void compute_paste_extent(TextNode * node);
+static void compute_pastebutton_extent(TextNode * node);
+static void compute_punctuation_extent(TextNode * node);
+static void compute_rm_extent(TextNode * node);
+static void compute_spadcommand_extent(TextNode * node);
+static void compute_spadsrc_extent(TextNode * node);
+static void compute_spadsrctxt_extent(TextNode * node);
+static void compute_table_extent(TextNode * * node);
+static void compute_verbatim_extent(TextNode * node);
+static void compute_word_extent(TextNode * node);
+static void end_spadcommand_extent(TextNode * node);
+static void end_spadsrc_extent(TextNode * node);
+static void endbutton_extent(TextNode * node);
+static void endif_extent(TextNode * node);
+static void endpastebutton_extent(TextNode * node);
+#endif
+\end{chunk}
+
+\section{include/extent2.h1}
+\begin{chunk}{include/extent2.h1}
+/* from bookvol7 chunk include/extent2.h1 */
+extern void init_extents(void );
+extern void init_text(void );
+extern void init_title_extents(HyperDocPage * page);
+extern void insert_bitmap_file(TextNode * node);
+extern void insert_pixmap_file(TextNode * node);
+extern int max_x(TextNode * node , int Ender);
+extern int plh(int height);
+extern void start_newline(int distance , TextNode * node);
+extern int text_height(TextNode * node , int Ender);
+extern int text_width(TextNode * node , int Ender);
+extern int total_width(TextNode * node , int Ender);
+extern int trailing_space(TextNode * node);
+#ifdef _EXTENT2_C
+static void center_nodes(TextNode * begin_node , TextNode * end_node);
+static int input_string_width(TextNode * node);
+static int punctuation_width(TextNode * node);
+static int text_height1(TextNode * node , int Ender);
+static int verbatim_width(TextNode * node);
+static int width_of_dash(TextNode * node);
+static int word_width(TextNode * node);
+static int x_value(TextNode * node);
+#endif
+\end{chunk}
+
+\section{include/fnct-key.h1}
+\begin{chunk}{include/fnct-key.h1}
+/* from bookvol7 chunk include/fnct-key.h1 */
+extern void set_editor_key(void);
+extern void define_function_keys(void);
+extern int get_key(int  , char * );
+extern int get_str(int  , char * );
+extern void null_fnct(int );
+extern void handle_function_key(int  , int );
+\end{chunk}
+
+\section{include/form-ext.h1}
+\begin{chunk}{include/form-ext.h1}
+/* from bookvol7 chunk include/form-ext.h1 */
+extern void compute_form_page(HyperDocPage * page);
+extern int window_width(int cols);
+#ifdef _FORM_EXT_C
+static int window_height(HyperDocPage * page);
+static void form_header_extent(HyperDocPage * page);
+static void form_footer_extent(HyperDocPage * page);
+static void form_scrolling_extent(HyperDocPage * page);
+#endif 
+\end{chunk}
+
+\section{include/group.h1}
+\begin{chunk}{include/group.h1}
+/* from bookvol7 chunk include/group.h1 */
+extern void bf_top_group(void );
+extern GroupItem * copy_group_stack(void );
+extern void em_top_group(void );
+extern void free_group_stack(GroupItem * g);
+extern void init_group_stack(void );
+extern void init_top_group(void );
+extern void line_top_group(void );
+extern int pop_group_stack(void );
+extern void push_active_group(void );
+extern void push_group_stack(void );
+extern void push_spad_group(void );
+extern void rm_top_group(void );
+extern void tt_top_group(void );
+extern void center_top_group(void );
+\end{chunk}
+
+\section{include/halloc.h1}
+\begin{chunk}{include/halloc.h1}
+/* from bookvol7 chunk include/halloc.h1 */
+extern char * halloc(int bytes , char * msg);
+\end{chunk}
+
+\section{include/hash.h}
+\begin{chunk}{include/hash.h}
+/* from bookvol7 chunk include/hash.h */
+#ifndef _HASH_H_
+#define _HASH_H_ 1
+
+typedef struct hash_entry {
+  char *key;			/* pointer to key data */
+  char *data;			/* Pointer to entry */
+  struct hash_entry *next;	/* Link to next entry */
+} HashEntry;
+
+typedef int (*EqualFunction)(void *,void *);
+typedef int (*HashcodeFunction)(void *,int);
+typedef void (*MappableFunction) (void *);
+typedef void (*FreeFunction) (void *);
+typedef struct {
+  HashEntry **table;		/* the actual table */
+  int size;			/* size of table */
+  int num_entries;		/* number of elements in a hash table */
+  EqualFunction equal;		/* equality predicate for keys */
+  HashcodeFunction hash_code;	/* create hash code for a key */
+} HashTable;
+
+#endif
+\end{chunk}
+
+\section{include/hash.h1}
+\begin{chunk}{include/hash.h1}
+/* from bookvol7 chunk include/hash.h1 */
+extern char * alloc_string(char * str);
+extern HashEntry * hash_copy_entry(HashEntry * e);
+extern HashTable * hash_copy_table(HashTable * table);
+extern void hash_delete(HashTable * table , char * key);
+extern char * hash_find(HashTable * table , char * key);
+extern void hash_init(HashTable * table, int size, EqualFunction equal,
+                      HashcodeFunction hash_code);
+extern void free_hash(HashTable * table , FreeFunction free_fun);
+extern void hash_insert(HashTable * table , char * data , char * key);
+extern void hash_map(HashTable * table , MappableFunction func);
+extern char * hash_replace(HashTable * table , char * data , char * key);
+extern int string_equal(char * s1 , char * s2);
+extern int string_hash(char * s , int size);
+\end{chunk}
+
+\section{include/htadd.h1}
+\begin{chunk}{include/htadd.h1}
+/* from bookvol7 chunk include/htadd.h1 */
+extern int main(int argc , char * * argv);
+#ifdef _HTADD_C
+static void add_file(char * dbname , char * name , int fresh);
+static void add_new_pages(FILE * temp_db, FILE * new_file, 
+                          char * addname, char * fullname);
+static int build_db_filename(short flag , char * db_dir , char * dbfilename);
+static void copy_file(char * f1 , char * f2);
+static void delete_db(FILE * db , FILE * temp_db , char * name);
+static int delete_file(char * dbname , char * name);
+static void get_filename(void);
+static void parse_args(char * * argv, char * db_dir, 
+                       char * * filenames, short * fl);
+static void update_db(FILE * db, FILE * temp_db, FILE * new_file, 
+                      char * addname, char * fullname, int fresh);
+static int writable(struct stat buff);
+#endif
+\end{chunk}
+
+\section{include/hterror.h1}
+\begin{chunk}{include/hterror.h1}
+/* from bookvol7 chunk include/hterror.h1 */
+extern void print_page_and_filename(void );
+extern void jump(void );
+extern void print_token(void );
+extern void token_name(int type);
+extern void print_next_ten_tokens(void );
+extern void htperror(char * msg , int errno);
+\end{chunk}
+
+\section{include/hthits.h1}
+\begin{chunk}{include/hthits.h1}
+/* from bookvol7 chunk include/hthits.h1 */
+extern void regerr(int code);
+extern int main(int argc , char * * argv);
+extern void cmdline(int argc , char * * argv);
+extern void handleHtdb(void);
+extern void badDB(void);
+extern void handleFile(FILE * htdbFile);
+extern void handleFilePages(char * fname , int pgc , PgInfo * pgv);
+extern void handlePage(FILE * infile , PgInfo * pg);
+extern void splitpage(char * buf , char * * ptitle , char * * pbody);
+extern void untexbuf(register char * s);
+extern void searchPage(char * pgname , char * pgtitle , char * pgbody);
+extern void squirt(char * s , int n);
+\end{chunk}
+
+\section{include/htinp.h1}
+\begin{chunk}{include/htinp.h1}
+/* from bookvol7 chunk include/htinp.h1 */
+extern void ht2_input(void );
+extern void make_record(void );
+extern void verify_record(void );
+extern char * strCopy(char * s);
+extern void print_paste_line(FILE * pfile , char * str);
+extern void get_spad_output(FILE * pfile , char * command , int com_type);
+extern void get_graph_output(char * command , char * pagename , int com_type);
+#ifdef _HTINP_C
+static void make_input_file_list(void );
+static char * make_input_file_name(char * buf , char * filename);
+static char * make_paste_file_name(char * buf , char * filename);
+static void make_the_input_file(UnloadedPage * page);
+static void make_input_file_from_page(HyperDocPage * page);
+static int inListAndNewer(char * inputFile , char * htFile);
+static void print_paste(FILE * pfile, char * realcom, char * command, 
+                        char * pagename, int com_type);
+static void print_graph_paste(FILE * pfile, char * realcom, char * command, 
+                              char * pagename, int com_type);
+static void send_command(char * command , int com_type);
+#endif
+\end{chunk}
+
+\section{include/hyper.h1}
+\begin{chunk}{include/hyper.h1}
+/* from bookvol7 chunk include/hyper.h1 */
+extern void sigusr2_handler(int sig);
+extern void sigcld_handler(int sig);
+extern void clean_socket(void);
+extern int main(int argc , char * * argv);
+extern void init_page_structs(HDWindow * w);
+#ifdef _HYPER_C
+static void init_hash(void);
+static void make_server_connections(void);
+static void check_arguments(void);
+#endif
+\end{chunk}
+
+\section{include/initx.h1}
+\begin{chunk}{include/initx.h1}
+/* from bookvol7 chunk include/initx.h1 */
+extern void change_text(int color , XFontStruct * font);
+extern int init_form_window(char * name , int cols);
+extern int init_top_window(char * name);
+extern void initializeWindowSystem(void);
+extern int is_it_850(XFontStruct * fontarg);
+#ifdef _INITX_C
+static void get_GCs(HDWindow * window);
+static int get_border_properties(void);
+static int get_color(char * name , char * class , int def , Colormap * map);
+static void ingItColors_and_fonts(void);
+static void load_font(XFontStruct * * font_info , char * fontname);
+static void mergeDatabases(void);
+static void open_form_window(void);
+static void open_window(Window w);
+static void set_name_and_icon(void);
+static void set_size_hints(Window w);
+#endif
+\end{chunk}
+
+\section{include/input.h1}
+\begin{chunk}{include/input.h1}
+/* from bookvol7 chunk include/input.h1 */
+extern InputItem * return_item(char * name);
+extern void fill_box(Window w , ImageStruct * image);
+extern void toggle_input_box(HyperLink * link);
+extern void toggle_radio_box(HyperLink * link);
+extern void change_input_focus(HyperLink * link);
+extern void next_input_focus(void);
+extern void prev_input_focus(void);
+extern int delete_item(char * name);
+#ifdef _INPUT_C
+static void clear_rbs(InputBox * list);
+#endif
+\end{chunk}
+
+\section{include/item.h1}
+\begin{chunk}{include/item.h1}
+/* from bookvol7 chunk include/item.h1 */
+extern void push_item_stack(void);
+extern void clear_item_stack(void);
+extern void pop_item_stack(void);
+extern ItemStack * copy_item_stack(void);
+extern void free_item_stack(ItemStack * is);
+\end{chunk}
+
+\section{include/keyin.h1}
+\begin{chunk}{include/keyin.h1}
+/* from bookvol7 chunk include/keyin.h1 */
+extern void handle_key(XEvent * event);
+extern void init_keyin(void);
+\end{chunk}
+
+\section{include/lex.h1}
+\begin{chunk}{include/lex.h1}
+/* from bookvol7 chunk include/lex.h1 */
+extern int connect_spad(void);
+extern void get_expected_token(int type);
+extern void parser_init(void);
+extern void init_scanner(void);
+extern void save_scanner_state(void);
+extern void restore_scanner_state(void);
+extern void unget_char(int c);
+extern int get_char(void);
+extern void unget_token(void);
+extern int get_token(void);
+extern void push_be_stack(int type , char * id);
+extern void check_and_pop_be_stack(int type , char * id);
+extern int clear_be_stack(void);
+extern int be_type(char * which);
+extern int begin_type(void);
+extern int end_type(void);
+extern void reset_connection(void);
+extern int spad_busy(void);
+#ifdef _LEX_C
+static int get_char1(void );
+static void spad_error_handler(void );
+static int keyword_type(void );
+#endif
+\end{chunk}
+
+\section{include/macro.h1}
+\begin{chunk}{include/macro.h1}
+/* from bookvol7 chunk include/macro.h1 */
+extern void scan_HyperDoc(void);
+extern int number(char * str);
+extern ParameterList init_parameter_elem(int number);
+extern int push_parameters(ParameterList new);
+extern int pop_parameters(void);
+extern int parse_macro(void);
+extern void parse_parameters(void);
+#ifdef _MACRO_C
+static char * load_macro(MacroStore * macro);
+static void get_parameter_strings(int number , char * macro_name);
+#endif
+\end{chunk}
+
+\section{include/mem.h1}
+\begin{chunk}{include/mem.h1}
+/* from bookvol7 chunk include/mem.h1 */
+extern ButtonList * alloc_button_list(void);
+extern CondNode * alloc_condnode(void);
+extern HDWindow * alloc_hd_window(void);
+extern IfNode * alloc_ifnode(void);
+extern InputBox * alloc_inputbox(void);
+extern LineStruct * alloc_inputline(int size);
+extern TextNode * alloc_node(void);
+extern HyperDocPage * alloc_page(char * name);
+extern PasteNode * alloc_paste_node(char * name);
+extern RadioBoxes * alloc_rbs(void);
+extern void free_button_list(ButtonList * bl);
+extern void free_hd_window(HDWindow * w);
+extern void free_input_item(InputItem * sym , short des);
+extern void free_input_list(InputItem * il);
+extern void free_node(TextNode * node , short des);
+extern void free_page(HyperDocPage * page);
+extern void free_patch(PatchStore * p);
+extern void free_string(char * str);
+extern char * resizeBuffer(int size , char * oldBuf , int * oldSize);
+extern PatchStore * alloc_patchstore(void);
+#ifdef _MEM_C
+static void free_cond(CondNode * cond);
+static void free_depend(SpadcomDepend * sd);
+static void free_lines(LineStruct * lines);
+static void dont_free(void * link);
+static void free_if_non_NULL(void * p);
+static void free_input_box(InputBox * box);
+static void free_paste(PasteNode * paste , short des);
+static void free_pastearea(TextNode * node , short des);
+static void free_pastebutton(TextNode * node , short des);
+static void free_radio_boxes(RadioBoxes * radio);
+#endif
+\end{chunk}
+
+\section{include/parse-aux.h1}
+\begin{chunk}{include/parse-aux.h1}
+/* from bookvol7 chunk include/parse-aux.h1 */
+extern void add_dependencies(void );
+extern FILE * find_fp(FilePosition fp);
+extern char * get_input_string(void );
+extern HyperLink * make_link_window(TextNode * link_node , int type , int isSubWin);
+extern HyperLink * make_paste_window(PasteNode * paste);
+extern void make_special_pages(HashTable * pageHashTable);
+extern int window_code(Window * w , int size);
+extern int window_equal(Window * w1 , Window * w2);
+extern char * window_id(Window w);
+extern void read_ht_db(HashTable * page_hash , HashTable * macro_hash , HashTable * patch_hash);
+extern int get_filename(void);
+extern int is_number(char * str);
+extern void parser_error(char * str);
+extern int get_where(void);
+#ifdef _PARSE_AUX_C
+static void read_ht_file(HashTable * page_hash , HashTable * macro_hash , HashTable * patch_hash , FILE * db_fp , char * db_file);
+static HyperDocPage * make_special_page(int type , char * name);
+#endif
+\end{chunk}
+
+\section{include/parse.h1}
+\begin{chunk}{include/parse.h1}
+/* from bookvol7 chunk include/parse.h1 */
+extern void display_page(HyperDocPage * page);
+extern void init_parse_patch(HyperDocPage * page);
+extern void load_page(HyperDocPage * page);
+extern void parse_HyperDoc(void );
+extern void parse_from_string(char * str);
+extern HyperDocPage * parse_page_from_socket(void );
+extern HyperDocPage * parse_page_from_unixfd(void );
+#ifdef _PARSE_C
+static void end_a_page(void );
+static HyperDocPage * format_page(UnloadedPage * ulpage);
+static void parse_page(HyperDocPage * page);
+static void parse_replacepage(void );
+static void start_footer(void );
+static void start_scrolling(void );
+static void Push_MR(void );
+static void Pop_MR(void );
+static void parse_title(HyperDocPage * page);
+static void parse_header(HyperDocPage * page);
+static void init_parse_page(HyperDocPage * page);
+#endif
+\end{chunk}
+
+\section{include/parse-input.h1}
+\begin{chunk}{include/parse-input.h1}
+/* from bookvol7 chunk include/parse-input.h1 */
+extern HyperLink * make_input_window(InputItem * item);
+extern HyperLink * make_box_window(InputBox * box , int type);
+extern void initialize_default(InputItem * item , char * buff);
+extern void parse_inputstring(void);
+extern void parse_simplebox(void);
+extern void parse_radiobox(void);
+extern void init_paste_item(InputItem * item);
+extern void repaste_item(void);
+extern InputItem * current_item(void);
+extern int already_there(char * name);
+extern void parse_radioboxes(void);
+#ifdef _PARSE_INPUT_C
+static void insert_item(InputItem * item);
+static void add_box_to_rb_list(char * name , InputBox * box);
+static int check_others(InputBox * list);
+#endif 
+\end{chunk}
+
+\section{include/parse-paste.h1}
+\begin{chunk}{include/parse-paste.h1}
+/* from bookvol7 chunk include/parse-paste.h1 */
+extern void parse_paste(void);
+extern void parse_pastebutton(void);
+extern HyperDocPage * parse_patch(PasteNode * paste);
+#ifdef _PARSE_PASTE_C
+static void load_patch(PatchStore * patch);
+#endif 
+\end{chunk}
+
+\section{include/parse-types.h1}
+\begin{chunk}{include/parse-types.h1}
+/* from bookvol7 chunk include/parse-types.h1 */
+extern void parse_begin_items(void );
+extern void parse_box(void );
+extern void parse_button(void );
+extern void parse_centerline(void );
+extern void parse_command(void );
+extern void parse_env(TextNode * node);
+extern void parse_free(void );
+extern void parse_help(void );
+extern void parse_ifcond(void );
+extern void parse_input_pix(void );
+extern void parse_item(void );
+extern void parse_mbox(void );
+extern void parse_mitem(void );
+extern void parse_newcond(void );
+extern void parse_setcond(void );
+extern void parse_spadcommand(TextNode * spad_node);
+extern void parse_spadsrc(TextNode * spad_node);
+extern void parse_table(void );
+extern void parse_value1(void );
+extern void parse_value2(void );
+extern void parse_verbatim(int type);
+#ifdef _PARSE_TYPES_C
+static void parse_condnode(void );
+static void parse_hasreturnto(void );
+#endif 
+\end{chunk}
+
+\section{include/pixmap.h1}
+\begin{chunk}{include/pixmap.h1}
+/* from bookvol7 chunk include/pixmap.h1 */
+extern int file_exists(char * );
+extern FILE * zzopen(char *  , char * );
+extern void write_pixmap_file(Display *, int, char *, Window, int, int, 
+                              int, int );
+extern int read_pixmap_file(Display *, int, char *, XImage * *, int *, int * );
+\end{chunk}
+
+\section{include/prt.h1}
+\begin{chunk}{include/prt.h1}
+/* from bookvol7 chunk include/prt.h1 */
+extern void myputchar(char );
+extern void clear_buff(void);
+extern void move_end(void);
+extern void move_home(void);
+extern void move_fore_word(void);
+extern void move_back_word(void);
+extern void delete_current_char(void);
+extern void del_print(int  , int );
+extern void delete_to_end_of_line(void);
+extern void delete_line(void);
+extern void printbuff(int  , int );
+extern void ins_print(int  , int );
+extern void reprint(int );
+extern void back_up(int );
+extern void back_it_up(int );
+extern void print_whole_buff(void);
+extern void move_ahead(void);
+extern void move_back(void);
+extern void back_over_current_char(void);
+\end{chunk}
+
+\section{include/readbitmap.h1}
+\begin{chunk}{include/readbitmap.h1}
+/* from bookvol7 chunk include/readbitmap.h1 */
+extern XImage * HTReadBitmapFile(Display * display, int screen, 
+                                 char * filename, int * width, int * height);
+extern ImageStruct * insert_image_struct(char * filename);
+#ifdef _READBITMAP_C
+static int read_hot(FILE * fd , char Line[] , int * x_hot , int * y_hot);
+static int read_w_and_h(FILE * fd, unsigned int * width, 
+                        unsigned int * height);
+#endif
+\end{chunk}
+
+\section{include/scrollbar.h1}
+\begin{chunk}{include/scrollbar.h1}
+/* from bookvol7 chunk include/scrollbar.h1 */
+extern void calculateScrollBarMeasures(void );
+extern void drawScrollLines(void );
+extern void hideScrollBars(HDWindow * hdWindow);
+extern void getScrollBarMinimumSize(int * width , int * height);
+extern void linkScrollBars(void );
+extern void makeScrollBarWindows(void );
+extern void moveScroller(HDWindow * hdWindow);
+extern void scrollDown(void );
+extern void scrollDownPage(void );
+extern void scrollScroller(XButtonEvent * event);
+extern void scrollToFirstPage(void );
+extern void scrollUp(void );
+extern void scrollUpPage(void );
+extern void showScrollBars(HDWindow * hdWindow);
+#ifdef _SCROLLBAR_C
+static int ch(int height);
+static void changeWindowBackgroundPixmap(Window window , Pixmap pixmap);
+static void drawScroller3DEffects(HDWindow * hdWindow, int x1, int y1, 
+                                  int x2, int y2);
+
+#endif 
+\end{chunk}
+
+\section{include/show-types.h1}
+\begin{chunk}{include/show-types.h1}
+/* from bookvol7 chunk include/show-types.h1 */
+extern void show_text(TextNode * node , int Ender);
+#ifdef _SHOW_TYPES_C
+static void show_image(TextNode * node , GC gc);
+static void show_input(TextNode * node);
+static void show_link(TextNode * node);
+static void show_paste(TextNode * node);
+static void show_pastebutton(TextNode * node);
+static void show_simple_box(TextNode * node);
+static void show_spadcommand(TextNode * node);
+#endif 
+\end{chunk}
+
+\section{include/sockio-c.h1}
+\begin{chunk}{include/sockio-c.h1}
+/* from bookvol7 chunk include/sockio-c.h1 */
+extern int get_int(Sock * );
+extern char * get_string(Sock * );
+extern double get_float(Sock * );
+extern Sock * connect_to_local_server(char *  , int  , int );
+extern int sread(Sock *  , char *  , int  , char * );
+extern double plus_infinity(void );
+extern double minus_infinity(void );
+extern double NANQ(void );
+extern void sigpipe_handler(int );
+extern int wait_for_client_read(Sock *  , char *  , int  , char * );
+extern int wait_for_client_write(Sock *  , char *  , int  , char * );
+extern int swrite(Sock *  , char *  , int  , char * );
+extern int sselect(int  , fd_set *  , fd_set *  , fd_set *  , void * );
+extern int fill_buf(Sock *  , char *  , int  , char * );
+extern int sock_get_int(int );
+extern int get_ints(Sock *  , int *  , int );
+extern int sock_get_ints(int  , int *  , int );
+extern int send_int(Sock *  , int );
+extern int sock_send_int(int  , int );
+extern int send_ints(Sock *  , int *  , int );
+extern int sock_send_ints(int  , int *  , int );
+extern int send_string(Sock *  , char * );
+extern int send_string_len(Sock *  , char *  , int );
+extern int sock_send_string(int  , char * );
+extern int sock_send_string_len(int  , char *  , int );
+extern int send_strings(Sock *  , char * *  , int );
+extern int sock_send_strings(int  , char * *  , int );
+extern char * sock_get_string(int );
+extern char * get_string_buf(Sock *  , char *  , int );
+extern char * sock_get_string_buf(int  , char *  , int );
+extern int get_strings(Sock *  , char * *  , int );
+extern int sock_get_strings(int  , char * *  , int );
+extern int send_float(Sock *  , double );
+extern int sock_send_float(int  , double );
+extern int send_sfloats(Sock *  , float *  , int );
+extern int sock_send_sfloats(int  , float *  , int );
+extern int send_floats(Sock *  , double *  , int );
+extern int sock_send_floats(int  , double *  , int );
+extern double sock_get_float(int );
+extern int get_sfloats(Sock *  , float *  , int );
+extern int sock_get_sfloats(int  , float *  , int );
+extern int get_floats(Sock *  , double *  , int );
+extern int sock_get_floats(int  , double *  , int );
+extern int wait_for_client_kill(Sock *  , int );
+extern int sock_get_remote_fd(int );
+extern int send_signal(Sock *  , int );
+extern int sock_send_signal(int  , int );
+extern int send_wakeup(Sock * );
+extern int sock_send_wakeup(int );
+extern Sock * connect_to_local_server_new(char *  , int  , int );
+extern void remote_stdio(Sock * );
+extern void init_purpose_table(void );
+extern int make_server_number(void );
+extern void close_socket(int  , char * );
+extern int make_server_name(char *  , char * );
+extern int open_server(char * );
+extern int accept_connection(Sock * );
+extern void get_socket_type(Sock * );
+extern int sock_accept_connection(int );
+extern void redirect_stdio(Sock * );
+extern void init_socks(void );
+extern int server_switch(void );
+extern void flush_stdout(void );
+extern void print_line(char * );
+\end{chunk}
+
+\section{include/spadbuf.h1}
+\begin{chunk}{include/spadbuf.h1}
+/* from bookvol7 chunk include/spadbuf.h1 */
+extern int main(int argc , char * * argv);
+#ifdef _SPADBUF_C
+static void spadbuf_inter_handler(int sig);
+static void spadbuf_function_chars(void);
+static void interp_io(void);
+static void init_parent(void);
+#endif
+\end{chunk}
+
+\section{include/spadcolors.h1}
+\begin{chunk}{include/spadcolors.h1}
+/* from bookvol7 chunk include/spadcolors.h1 */
+extern RGB HSVtoRGB(HSV );
+extern RGB HLStoRGB(HLS );
+extern float value(float  , float  , float );
+extern int makeColors(Display *  , int  , Colormap *  , unsigned long * *  , int * );
+extern int makePermVector(Display *  , int  , unsigned long * * );
+extern int makeNewColorMap(Display *  , Colormap  , int );
+extern unsigned long XPixelColor(int );
+extern void FreePixels(Display *  , Colormap  , int );
+extern int AllocCells(Display *  , Colormap  , int );
+\end{chunk}
+
+\section{include/spadint.h1}
+\begin{chunk}{include/spadint.h1}
+/* from bookvol7 chunk include/spadint.h1 */
+extern HyperDocPage * issue_server_command(HyperLink * link);
+extern HyperDocPage * issue_unixlink(TextNode * node);
+extern char * print_to_string(TextNode * command);
+extern void issue_spadcommand(HyperDocPage * page , TextNode * command , 
+                              int immediate , int type);
+extern Sock * accept_menu_connection(Sock * server_sock);
+extern char * print_to_string1(TextNode * command , int * sizeBuf);
+extern int issue_serverpaste(TextNode * command);
+extern void issue_unixcommand(TextNode * node);
+extern int issue_unixpaste(TextNode * node);
+extern void service_session_socket(void);
+extern void send_lisp_command(char * command);
+extern void escape_string(char * s);
+extern void unescape_string(char * s);
+extern char * print_source_to_string1(TextNode * command , int * sizeBuf);
+extern char * print_source_to_string(TextNode * command);
+#ifdef _SPADINT_C
+static void start_user_buffer(HyperDocPage * page);
+static void clear_execution_marks(HashTable * depend_hash);
+static void issue_dependent_commands(HyperDocPage * page, TextNode * command, 
+                                     int type);
+static void send_pile(Sock * sock , char * str);
+static void mark_as_executed(HyperDocPage * page, TextNode * command, 
+                             int type);
+static void accept_menu_server_connection(HyperDocPage * page);
+static void switch_frames(void );
+static void close_client(int pid);
+#endif 
+\end{chunk}
+
+\section{include/titlebar.h1}
+\begin{chunk}{include/titlebar.h1}
+/* from bookvol7 chunk include/titlebar.h1 */
+extern void getTitleBarMinimumSize(int * width , int * height);
+extern void linkTitleBarWindows(void);
+extern void makeTitleBarWindows(void);
+extern void showTitleBar(void);
+#ifdef _TITLEBAR_C
+static void readTitleBarImages(void);
+#endif
+\end{chunk}
+
+\section{include/util.h1}
+\begin{chunk}{include/util.h1}
+/* from bookvol7 chunk include/util.h1 */
+extern int checker(int  , int  , char * );
+extern char * getmemWithLine(int  , char *  , int );
+extern char * saymemWithLine(char *  , int  , int  , int );
+extern void myfree(void *  , int );
+extern XPoint getWindowPositionXY(Display *  , Window );
+extern XPoint getWindowSizeXY(Display *  , Window );
+\end{chunk}
+
+\section{include/wct.h1}
+\begin{chunk}{include/wct.h1}
+/* from bookvol7 chunk include/wct.h1 */
+extern time_t ftime(char * );
+extern void fatal(char *  , char * );
+extern off_t fsize(char * );
+extern Wix * scanWct(Wct *  , char * );
+extern void reintern1Wct(Wct * );
+extern Wix * rescanWct(void);
+extern void skimWct(Wct * );
+extern void skim1Wct(Wct * );
+extern void printTime(long * );
+extern int skimString(char *  , int  , int  , int );
+extern int prChar(int );
+extern Wct * reread1Wct(Wct * );
+extern void sfatal(char * );
+extern Wct * read1Wct(char * );
+extern Wct * nconcWct(Wct *  , Wct * );
+extern void sortWct(Wct * );
+extern void sort1Wct(Wct * );
+extern int mystrcmp(const void  *  , const void * );
+extern void burstWct(Wct * );
+extern void burst1Wct(Wct * );
+extern Wct * intern1Wct(char * );
+extern void load_wct_file(char * );
+extern void  skim_wct(void);
+extern void  rescan_wct(void);
+extern void  find_wct(void);
+\end{chunk}
+
 \chapter{Shared Code}
 \subsection{BeStruct}
 \index{struct!BeStruct}
@@ -5555,9 +7040,9 @@ int connectSpad(void) {
 \section{htadd shared code}
 \index{htadd shared code}
 \begin{chunk}{htadd shared code}
-#include "bsdsignal.h"
-#include "bsdsignal.h1"
-#include "sockio-c.h1"
+\getchunk{include/bsdsignal.h}
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/sockio-c.h1}
 
 #define cwd(n) ((n[0] == '.' && n[1] == '/')?(1):(0))
 #define TokenHashSize   100
@@ -5706,7 +7191,7 @@ char *token_table[] = {
   "controlbitmap"
   };
 
-\getchunk{token.h}
+\getchunk{include/token.h}
 \getchunk{spadErrorHandler}
 \getchunk{spadBusy}
 \getchunk{connectSpad}
@@ -5756,9 +7241,9 @@ char *token_table[] = {
 \section{hypertex shared code}
 \index{hypertex shared code}
 \begin{chunk}{hypertex shared code}
-#include "bsdsignal.h"
-#include "bsdsignal.h1"
-#include "sockio-c.h1"
+\getchunk{include/bsdsignal.h}
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/sockio-c.h1}
 
 #define cwd(n) ((n[0] == '.' && n[1] == '/')?(1):(0))
 #define TokenHashSize   100
@@ -5907,7 +7392,7 @@ char *token_table[] = {
   "controlbitmap"
   };
 
-\getchunk{token.h}
+\getchunk{include/token.h}
 \getchunk{spadErrorHandler}
 \getchunk{spadBusy}
 \getchunk{connectSpad}
@@ -5957,7 +7442,7 @@ char *token_table[] = {
 \chapter{Shared include files}
 \section{debug.c}
 \begin{chunk}{debug.c}
-#include "debug.h"
+\getchunk{include/debug.h}
 
 #ifdef free
 #undef free
@@ -5967,7 +7452,7 @@ hfree(char *p) {
 #endif
 
 \end{chunk}
-\section{hyper.h}
+\section{include/hyper.h}
 The \verb|hypertex| function, of which this is the top level, is a browser
 for Axiom information. It works off a database of pages. The pages are
 stored in the \verb|$AXIOM/doc| subdirectory and there is
@@ -5988,19 +7473,19 @@ The \verb|hypertex| function looks in \verb|$AXIOM/doc| by
 default. This can be over-ridden by setting the \verb|HTPATH| shell
 variable to point to the desired directory containing the pages and
 the ht.db file.
-\begin{chunk}{hyper.h}
+\begin{chunk}{include/hyper.h}
+/* from bookvol7 chunk include/hyper.h */
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
 #include <limits.h>
-
 #include <X11/Xlib.h>
 #include <X11/Xutil.h>
 #include <X11/Xos.h>
 
-#include "com.h"
-\getchunk{token.h}
-#include "hash.h"
+\getchunk{include/com.h}
+\getchunk{include/token.h}
+\getchunk{include/hash.h}
 
 #define boolean unsigned short int
 
@@ -6560,18 +8045,18 @@ cflow --emacs -l -n -b -T --omit-arguments spadbuf.c
 \end{chunk}
 \subsection{Local includes}
 \begin{chunk}{spadbuf}
-#include "debug.h"
-#include "bsdsignal.h"
-#include "edible.h"
-#include "com.h"
-#include "spadbuf.h1"
-#include "bsdsignal.h1"
-#include "sockio-c.h1"
-#include "edin.h1"
-#include "wct.h1"
-#include "prt.h1"
-#include "cursor.h1"
-#include "fnct-key.h1"
+\getchunk{include/debug.h}
+\getchunk{include/bsdsignal.h}
+\getchunk{include/edible.h}
+\getchunk{include/com.h}
+\getchunk{include/spadbuf.h1}
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/sockio-c.h1}
+\getchunk{include/edin.h1}
+\getchunk{include/wct.h1}
+\getchunk{include/prt.h1}
+\getchunk{include/cursor.h1}
+\getchunk{include/fnct-key.h1}
 
 \end{chunk}
 \section{externs}
@@ -6847,8 +8332,8 @@ The ex2ht command creates a cover page for structured HyperDoc example pages
 \end{chunk}
 \subsection{Local includes}
 \begin{chunk}{ex2ht}
-#include "debug.h"
-#include "ex2ht.h1"
+\getchunk{include/debug.h}
+\getchunk{include/ex2ht.h1}
 
 \end{chunk}
 \section{defines}
@@ -7378,13 +8863,13 @@ typedef struct toke {   /* HyperDoc parser tokens */
 \end{chunk}
 \subsection{Local includes}
 \begin{chunk}{htadd}
-\getchunk{hyper.h}
-#include "htadd.h1"
-#include "addfile.h1"
-#include "halloc.h1"
-#include "hash.h1"
-#include "hterror.h1"
-#include "lex.h1"
+\getchunk{include/hyper.h}
+\getchunk{include/htadd.h1}
+\getchunk{include/addfile.h1}
+\getchunk{include/halloc.h1}
+\getchunk{include/hash.h1}
+\getchunk{include/hterror.h1}
+\getchunk{include/lex.h1}
 
 \end{chunk}
 \subsection{extern references}
@@ -8025,8 +9510,8 @@ typedef struct pgInfo {
 \end{chunk}
 \subsection{Local includes}
 \begin{chunk}{hthits}
-#include "debug.h"
-#include "hthits.h1"
+\getchunk{include/debug.h}
+\getchunk{include/hthits.h1}
 
 \end{chunk}
 \subsection{local variables}
@@ -8400,18 +9885,18 @@ typedef struct toke {   /* HyperDoc parser tokens */
 \end{chunk}
 \subsection{Local includes}
 \begin{chunk}{hypertex}
-#include "debug.h"
-\getchunk{hyper.h}
+\getchunk{include/debug.h}
+\getchunk{include/hyper.h}
 
-#include "all-hyper-proto.h1"
-#include "bsdsignal.h"
-#include "bsdsignal.h1"
-#include "hterror.h1"
-#include "pixmap.h1"
-#include "sockio-c.h1"
-#include "spadcolors.h"
-#include "spadcolors.h1"
-#include "util.h1"
+\getchunk{include/all-hyper-proto.h1}
+\getchunk{include/bsdsignal.h}
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/hterror.h1}
+\getchunk{include/pixmap.h1}
+\getchunk{include/sockio-c.h1}
+\getchunk{include/spadcolors.h}
+\getchunk{include/spadcolors.h1}
+\getchunk{include/util.h1}
 
 \end{chunk}
 \section{structs}
@@ -22976,7 +24461,7 @@ END {
 
 \end{chunk}
 \section{token.h}
-\begin{chunk}{token.h}
+\begin{chunk}{include/token.h}
 
 /*
  Here are a couple of flags added for whitespace stuff. They tell
@@ -23514,12 +24999,23 @@ SPADBUF_LIBS=${LIBS} ${LIB}/wct.o ${LIB}/edin.o ${LIB}/prt.o \
 
 HYPER_LIBS=${LIBS} ${LIB}/pixmap.o ${LIB}/spadcolors.o ${LIB}/util.o 
 
-all: ${OUTLIB}/spadbuf ${OUTLIB}/ex2ht ${OUTBIN}/htadd ${OUTLIB}/hthits \
+all: announce ${OUTLIB}/spadbuf ${OUTLIB}/ex2ht ${OUTBIN}/htadd \
+     ${OUTLIB}/hthits \
      ${OUTBIN}/htsearch ${OUTLIB}/presea ${OUTBIN}/hypertex \
-     ${HYPER}/axbook ${HYPER}/bigbayou.png ${HYPER}/doctitle.png 
+     ${HYPER}/axbook ${HYPER}/bigbayou.png ${HYPER}/doctitle.png finish
 	@cp -pr ${IN}/bitmaps ${HYPER}
 	@ echo 0 finished ${BOOK}
 
+announce:
+	@ echo ==========================
+	@ echo Making hyperdoc bookvol7
+	@ echo ==========================
+
+finish:
+	@ echo ==========================
+	@ echo Finish hyperdoc bookvol7
+	@ echo ==========================
+
 ${OUTLIB}/spadbuf: ${BOOK} 
 	@ echo 1 making ${OUTLIB}/spadbuf from ${BOOK}
 	@ (cd ${WORK} ; \
diff --git a/books/bookvol8.pamphlet b/books/bookvol8.pamphlet
index 3eb7b32..871a4e8 100644
--- a/books/bookvol8.pamphlet
+++ b/books/bookvol8.pamphlet
@@ -731,8 +731,18 @@ A data file, with uninteresting lines snipped is:
 \end{verbatim}
 \chapter{include}
 \label{include}
+This chapter contains the include files. Unlike normal C programs
+we replace the 'include' directive by the actual chunk from this
+chapter. The results are that the include files never get written
+to disk and the compiler never sees the include directive, resulting
+in faster compile times.
+
+The include files are collected from both the view* programs and 
+the low level C code that supports them, including libspad which,
+in general, have the file extension of 'h1' rather than 'h'.
 \section{actions.h}
 \begin{chunk}{include/actions.h}
+/* from bookvol8 chunk include/actions.h */
 #define makeAViewport -1
 
 
@@ -858,6 +868,7 @@ A data file, with uninteresting lines snipped is:
 This include file appears not to be used. 
 However, the moColor macro IS used but not included.
 \begin{chunk}{include/colors.h}
+/* from bookvol8 chunk include/colors.h */
 /*
   colors.h
   created on 25 November 1992, Jim Wen
@@ -912,6 +923,7 @@ However, the moColor macro IS used but not included.
 \section{component.h}
 \index{component.h}
 \begin{chunk}{include/component.h}
+/* from bookvol8 chunk include/component.h */
 /* 
    This file contains the definitions for the generalized point
    structures in 3D.
@@ -920,6 +932,7 @@ However, the moColor macro IS used but not included.
 \end{chunk}
 \index{tube.h}
 \begin{chunk}{include/component.h}
+/* from bookvol8 chunk include/component.h */
 \getchunk{include/tube.h}
 
 /* viewman's and viewAlone's refPt */
@@ -935,6 +948,7 @@ However, the moColor macro IS used but not included.
 \index{componentProp struct}
 \index{struct!componentProp}
 \begin{chunk}{include/component.h}
+/* from bookvol8 chunk include/component.h */
 typedef struct _componentProp {
   int closed,
     solid;
@@ -944,6 +958,7 @@ typedef struct _componentProp {
 \index{struct!LPoint}
 \index{LPoint struct}
 \begin{chunk}{include/component.h}
+/* from bookvol8 chunk include/component.h */
 typedef struct _LPoint { /* meaning list of points */
   componentProp prop;
   int numOfPoints;
@@ -954,6 +969,7 @@ typedef struct _LPoint { /* meaning list of points */
 \index{struct!LLPoint}
 \index{LLPoint struct}
 \begin{chunk}{include/component.h}
+/* from bookvol8 chunk include/component.h */
 typedef struct _LLPoint { /* meaning list of list of points */
   /* for the current 3D stuff:
      functions of 2 variables - closed is false (xmax does not close
@@ -970,6 +986,7 @@ typedef struct _LLPoint { /* meaning list of list of points */
 \index{struct!LLLPoint}
 \index{LLLPoint struct}
 \begin{chunk}{include/component.h}
+/* from bookvol8 chunk include/component.h */
 typedef struct _LLLPoint { /* meaning list of list of list of points */
   /* for the current 3D stuff -- that is functions of 2 variables and
      parametric surfaces of one variable (tubes) -- there would be
@@ -983,6 +1000,7 @@ typedef struct _LLLPoint { /* meaning list of list of list of points */
 \section{g.h}
 \index{g.h}
 \begin{chunk}{include/g.h}
+/* from bookvol8 chunk include/g.h */
 #define Xoption		0	/* Gdraw routine option */
 #define PSoption		1	/* Gdraw routine option */
 
@@ -1031,9 +1049,10 @@ typedef struct _LLLPoint { /* meaning list of list of list of points */
 \index{struct!GCptr}
 \index{GCptr struct}
 \begin{chunk}{include/g.h}
+/* from bookvol8 chunk include/g.h */
 typedef struct _GCstruct {
   GC	 GCint;
-  char		 GCchar[10];
+  char		 GCchar[16];
   struct _GCstruct *next;
 } GCstruct, *GCptr;
 
@@ -1041,6 +1060,7 @@ typedef struct _GCstruct {
 \section{nox10.h}
 \index{nox10.h}
 \begin{chunk}{include/nox10.h}
+/* from bookvol8 chunk include/nox10.h */
 
 /* Used in XDraw and XDrawFilled */
 
@@ -1048,6 +1068,7 @@ typedef struct _GCstruct {
 \index{struct!Vertex}
 \index{Vertex struct}
 \begin{chunk}{include/nox10.h}
+/* from bookvol8 chunk include/nox10.h */
 typedef struct _Vertex {
   short x, y;
   unsigned short flags;
@@ -1073,6 +1094,7 @@ which is contains an array of circular queues (buckets).
 \index{struct!XAssoc}
 \index{XAssoc struct}
 \begin{chunk}{include/nox10.h}
+/* from bookvol8 chunk include/nox10.h */
 typedef struct _XAssoc {
   struct _XAssoc *next;	/* Next object in this bucket. */
   struct _XAssoc *prev;	/* Previous obejct in this bucket. */
@@ -1092,6 +1114,7 @@ of buckets in the array.
 \index{struct!XAssocTable}
 \index{XAssocTable struct}
 \begin{chunk}{include/nox10.h}
+/* from bookvol8 chunk include/nox10.h */
 typedef struct _XAssocTable {
   XAssoc **buckets;		/* Pointer to first bucket in bucket array.*/
   int size;			/* Table size (number of buckets). */
@@ -1101,6 +1124,7 @@ typedef struct _XAssocTable {
 \section{override.h}
 \index{override.h}
 \begin{chunk}{include/override.h}
+/* from bookvol8 chunk include/override.h */
 #define overrideManager False   
 /* override_redirect setting for overriding the window manager's directives. 
    the window manager tends to stick its nose into too much - to the point 
@@ -1117,23 +1141,20 @@ typedef struct _XAssocTable {
 \index{rgb.h}
 \index{struct!RGB}
 \index{RGB struct}
+\index{struct!HSV}
+\index{HSV struct}
+\index{struct!HLS}
+\index{HLS struct}
 \begin{chunk}{include/rgb.h}
+/* from bookvol8 chunk include/rgb.h */
 typedef struct _RGB {
   float r,g,b;
 } RGB ;
 
-\end{chunk}
-\index{struct!HSV}
-\index{HSV struct}
-\begin{chunk}{include/rgb.h}
 typedef struct _HSV {
   float h,s,v;
 } HSV ;
 
-\end{chunk}
-\index{struct!HLS}
-\index{HLS struct}
-\begin{chunk}{include/rgb.h}
 typedef struct _HLS {
   float h,l,s;
 } HLS ;
@@ -1142,6 +1163,7 @@ typedef struct _HLS {
 \section{spadcolors.h}
 \index{spadcolors.h}
 \begin{chunk}{include/spadcolors.h}
+/* from bookvol8 chunk include/spadcolors.h */
 #define numOfColors 240
 #define totalHuesConst   27 
 #define totalShadesConst 5 
@@ -1170,14 +1192,12 @@ extern int       num;
 
 #define maxColors DisplayCells(dsply,scrn)-1
 
-\end{chunk}
-\index{rgb.h}
-\begin{chunk}{include/spadcolors.h}
 \getchunk{include/rgb.h}
 \end{chunk}
 \section{tube.h}
 \index{tube.h}
 \begin{chunk}{include/tube.h}
+/* from bookvol8 chunk include/tube.h */
 #define openTube 1
 #define closedTube 0
 
@@ -1185,6 +1205,7 @@ extern int       num;
 \index{struct!triple}
 \index{triple struct}
 \begin{chunk}{include/tube.h}
+/* from bookvol8 chunk include/tube.h */
 typedef struct _triple {    /* used for normals */
   float x,y,z;
 } triple;
@@ -1192,6 +1213,7 @@ typedef struct _triple {    /* used for normals */
 \end{chunk}
 \index{rgb.h}
 \begin{chunk}{include/tube.h}
+/* from bookvol8 chunk include/tube.h */
 \getchunk{include/rgb.h}
 
 \end{chunk}
@@ -1200,6 +1222,7 @@ typedef struct _triple {    /* used for normals */
 \index{struct!viewTriplePtr}
 \index{viewTriplePtr struct}
 \begin{chunk}{include/tube.h}
+/* from bookvol8 chunk include/tube.h */
 typedef struct _viewTriple { /* used for points in 3 space */
   float x,y,z,c,sc;          /* c is color component */
   float wx,wy,wz;            /* world space coords */
@@ -1223,6 +1246,7 @@ typedef struct _viewTriple { /* used for points in 3 space */
 \index{struct!poly}
 \index{poly struct}
 \begin{chunk}{include/tube.h}
+/* from bookvol8 chunk include/tube.h */
 typedef struct _poly {
   int num, sortNum,
     split;                   /* how many times the polygon's been split */
@@ -1248,6 +1272,7 @@ typedef struct _poly {
 \index{struct!polyList}
 \index{polyList struct}
 \begin{chunk}{include/tube.h}
+/* from bookvol8 chunk include/tube.h */
 typedef struct _polyList {
   int  numPolys;
   poly *polyIndx;
@@ -1258,6 +1283,7 @@ typedef struct _polyList {
 \index{struct!slice}
 \index{slice struct}
 \begin{chunk}{include/tube.h}
+/* from bookvol8 chunk include/tube.h */
 typedef struct _slice {
   int keyoffset;
   viewTriple *points;
@@ -1268,6 +1294,7 @@ typedef struct _slice {
 \index{struct!tubeModel}
 \index{tubeModel struct}
 \begin{chunk}{include/tube.h}
+/* from bookvol8 chunk include/tube.h */
 typedef struct _tubeModel {
   /* numslices are the number of pts on the curve */
   int numslices, slicepts, numPolygons;
@@ -1280,6 +1307,7 @@ typedef struct _tubeModel {
 \index{struct!pointInfo}
 \index{pointInfo struct}
 \begin{chunk}{include/tube.h}
+/* from bookvol8 chunk include/tube.h */
 typedef struct _pointInfo {
   viewTriple *theVT;
   int        onVertex,segmentNum;
@@ -1290,6 +1318,7 @@ typedef struct _pointInfo {
 \section{view2d.h}
 \index{view2d.h}
 \begin{chunk}{include/view2d.h}
+/* from bookvol8 chunk include/view2d.h */
 #include <X11/Xlib.h>
 #define maxGraphs 9
 
@@ -1297,6 +1326,7 @@ typedef struct _pointInfo {
 \index{struct!viewManager}
 \index{viewManager struct}
 \begin{chunk}{include/view2d.h}
+/* from bookvol8 chunk include/view2d.h */
 typedef struct _viewManager {
   int viewType,          /* specifies view3d, view2d, etc... */
     PID,               /* unique integer greater than zero */
@@ -1311,6 +1341,7 @@ typedef struct _viewManager {
 \index{struct!viewWithThisGraph}
 \index{viewWithThisGraph struct}
 \begin{chunk}{include/view2d.h}
+/* from bookvol8 chunk include/view2d.h */
 typedef struct _viewsWithThisGraph {
   viewManager *viewGr;
   struct _viewsWithThisGraph *nextViewthing;
@@ -1320,6 +1351,7 @@ typedef struct _viewsWithThisGraph {
 \index{struct!pointStruct}
 \index{pointStruct struct}
 \begin{chunk}{include/view2d.h}
+/* from bookvol8 chunk include/view2d.h */
 typedef struct _pointStruct {
   float x,y,hue,shade;
 } pointStruct;
@@ -1328,6 +1360,7 @@ typedef struct _pointStruct {
 \index{struct!pointListStruct}
 \index{pointListStruct struct}
 \begin{chunk}{include/view2d.h}
+/* from bookvol8 chunk include/view2d.h */
 typedef struct _pointListStruct {
   pointStruct             *listOfPoints;
   float                   hue, shade;
@@ -1339,6 +1372,7 @@ typedef struct _pointListStruct {
 \index{struct!graphStruct}
 \index{graphStruct struct}
 \begin{chunk}{include/view2d.h}
+/* from bookvol8 chunk include/view2d.h */
 typedef struct _graphStruct {
   int                 key;
   float               xmin,xmax,ymin,ymax;
@@ -1356,6 +1390,7 @@ typedef struct _graphStruct {
 \index{struct!view2DStruct}
 \index{view2DStruct struct}
 \begin{chunk}{include/view2d.h}
+/* from bookvol8 chunk include/view2d.h */
 typedef struct _view2DStruct {
   char        *title;
   int         vX,vY,vW,vH,
@@ -1369,6 +1404,7 @@ typedef struct _view2DStruct {
 \index{struct!graphStateStruct}
 \index{graphStateStruct struct}
 \begin{chunk}{include/view2d.h}
+/* from bookvol8 chunk include/view2d.h */
 typedef struct _graphStateStruct {
   float scaleX, scaleY, deltaX, deltaY, centerX, centerY;
   int   pointsOn, connectOn, splineOn, axesOn, unitsOn,
@@ -1383,6 +1419,7 @@ typedef struct _graphStateStruct {
 \index{view3d.h}
 \index{component.h}
 \begin{chunk}{include/view3d.h}
+/* from bookvol8 chunk include/view3d.h */
 \getchunk{include/component.h}
 
 /* we now have two substructures (in the union, kind):
@@ -1394,6 +1431,7 @@ typedef struct _graphStateStruct {
 \index{struct!fun2VarModel}
 \index{fun2VarModel struct}
 \begin{chunk}{include/view3d.h}
+/* from bookvol8 chunk include/view3d.h */
 typedef struct _fun2VarModel {
   float *zArray,*cArray;
   viewTriple *pointList;
@@ -1403,6 +1441,7 @@ typedef struct _fun2VarModel {
 \index{union!kindOf}
 \index{kindOf union}
 \begin{chunk}{include/view3d.h}
+/* from bookvol8 chunk include/view3d.h */
 union kindOf {
   /*  float *zArray; */
   fun2VarModel fun2Var;
@@ -1413,6 +1452,7 @@ union kindOf {
 \index{struct!view3DStruct}
 \index{view3DStruct struct}
 \begin{chunk}{include/view3d.h}
+/* from bookvol8 chunk include/view3d.h */
 typedef struct _view3DStruct {
   int typeOf3D;
   float xmin,xmax,ymin,ymax,zmin,zmax;
@@ -1458,6 +1498,7 @@ typedef struct _view3DStruct {
 \index{boxSideStruct struct}
 for drawing the region box
 \begin{chunk}{include/view3d.h}
+/* from bookvol8 chunk include/view3d.h */
 typedef struct _boxSideStruct {
   viewTriplePtr pointsPtr[4];	/* see notes for definition of box */
   int inside;
@@ -1467,6 +1508,7 @@ typedef struct _boxSideStruct {
 \section{viewcommand.h}
 \index{viewcommand.h}
 \begin{chunk}{include/viewcommand.h}
+/* from bookvol8 chunk include/viewcommand.h */
 /* Commands that the viewports could send to the viewport manager */
 
 #define viewportClosing 1
@@ -1474,6 +1516,7 @@ typedef struct _boxSideStruct {
 \section{view.h}
 \index{view.h}
 \begin{chunk}{include/view.h}
+/* from bookvol8 chunk include/view.h */
 /* This file is to be included by all the viewport files */
 
 #define check(code)	checker(code,__LINE__,"")
@@ -1535,6 +1578,7 @@ exitWithAck(RootWindow(dsply,scrn),Window,-1); \
 \section{write.h}
 \index{write.h}
 \begin{chunk}{include/write.h}
+/* from bookvol8 chunk include/write.h */
 /* These are types of files that the viewports would
    be able to write out upon a command from Axiom.
    Note that the numbers in this list is also the order
@@ -1548,6 +1592,7 @@ exitWithAck(RootWindow(dsply,scrn),Window,-1); \
 \section{xdefs.h}
 \index{xdefs.h}
 \begin{chunk}{include/xdefs.h}
+/* from bookvol8 chunk include/xdefs.h */
 /***      default fonts      ***/
 #ifdef  RTplatform
 #define messageFontDefault    "Rom14.500"
@@ -1581,6 +1626,1838 @@ exitWithAck(RootWindow(dsply,scrn),Window,-1); \
 #endif
 
 \end{chunk}
+\begin{chunk}{include/addfile.h1}
+/* from bookvol8 chunk include/addfile.h1 */
+extern FILE * db_file_open(char * db_file);
+extern void extend_ht(char * name);
+extern FILE * ht_file_open(char * fname , char * aname , char * name);
+extern FILE * temp_file_open(char * temp_db_file);
+#ifdef _ADDFILE_C
+static int build_ht_filename(char * fname , char * aname , char * name);
+static int pathname(char * name);
+static int strpostfix(char * s , char * t);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/all-hyper-proto.h1}
+/* from bookvol8 chunk include/all-hyper-proto.h1 */
+\getchunk{include/addfile.h1}
+\getchunk{include/readbitmap.h1}
+\getchunk{include/dialog.h1}
+\getchunk{include/cond.h1}
+\getchunk{include/display.h1}
+\getchunk{include/event.h1}
+\getchunk{include/ex2ht.h1}
+\getchunk{include/form-ext.h1}
+\getchunk{include/extent1.h1}
+\getchunk{include/extent2.h1}
+\getchunk{include/halloc.h1}
+\getchunk{include/group.h1}
+\getchunk{include/hterror.h1}
+\getchunk{include/htinp.h1}
+\getchunk{include/hyper.h1}
+\getchunk{include/initx.h1}
+\getchunk{include/input.h1}
+\getchunk{include/keyin.h1}
+\getchunk{include/item.h1}
+\getchunk{include/lex.h1}
+\getchunk{include/parse.h1}
+\getchunk{include/macro.h1}
+\getchunk{include/parse-paste.h1}
+\getchunk{include/parse-aux.h1}
+\getchunk{include/parse-input.h1}
+\getchunk{include/show-types.h1}
+\getchunk{include/parse-types.h1}
+\getchunk{include/scrollbar.h1}
+\getchunk{include/titlebar.h1}
+\getchunk{include/spadint.h1}
+\getchunk{include/hash.h1}
+\getchunk{include/mem.h1}
+\end{chunk}
+
+\begin{chunk}{include/bsdsignal.h}
+/* from bookvol8 chunk include/bsdsignal.h */
+#ifndef _BSDSIGNAL_H_
+#define _BSDSIGNAL_H_
+
+#define RestartSystemCalls 1
+#define DontRestartSystemCalls 0
+
+typedef void (* SignalHandlerFunc)(int);
+
+#endif	    /* _BSDSIGNAL */
+\end{chunk}
+
+\begin{chunk}{include/bsdsignal.h1}
+/* from bookvol8 chunk include/bsdsignal.h1 */
+extern SignalHandlerFunc bsdSignal(int  , SignalHandlerFunc  , int );
+\end{chunk}
+
+\begin{chunk}{include/cfuns-c.h1}
+/* from bookvol8 chunk include/cfuns-c.h1 */
+extern int addtopath(char * );
+extern int directoryp(char * );
+extern int make_path_from_file(char *  , char * );
+extern int writeablep(char * );
+\end{chunk}
+
+\begin{chunk}{include/com.h}
+/* from bookvol8 chunk include/com.h */
+#ifndef _COM_H_
+#define _COM_H_
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#if defined(RIOSplatform)
+#include <sys/select.h>
+#endif
+
+typedef struct {
+  int socket;           /* socket number returned by "socket" call */
+  int type;             /* socket type (AF_UNIX or AF_INET) */
+  int purpose;          /* can be SessionManager, GraphicsServer, etc. */
+  int pid;              /* process ID of connected socket */
+  int frame;            /* spad interpreter frame (for interpreter windows) */
+  int remote_fd;        /* file descriptor of remote socket */
+  union {
+    struct sockaddr u_addr;
+    struct sockaddr_in i_addr;
+  } addr;
+  char *host_name;      /* name of foreign host if type == AF_INET */
+} Sock;
+
+#define MaxClients      150
+
+/* possible socket types (purpose) */
+
+#define SessionManager  1
+#define ViewportServer  2
+#define MenuServer      3
+#define SessionIO       4
+#define BaloonServer    5
+#define InterpWindow    6
+#define KillSpad        7
+#define DebugWindow     8  
+#define Forker          9
+#define AV              10 /*Simon's algebraic viewer */
+
+#define Acknowledge     255
+
+/* Timeout value for connection to remote socket */
+
+#define Forever 0
+
+/* Socket name for local AXIOM server and session manager */
+
+#define SpadServer              "/tmp/.d"
+#define SessionServer           "/tmp/.s"
+#define SessionIOName           "/tmp/.i"
+#define MenuServerName          "/tmp/.h"
+#define ForkServerName          "/tmp/.f"
+
+
+#define MASK_SIZE       (NBBY*sizeof(fd_set))
+
+
+/* table of dedicated socket types */
+
+extern Sock *purpose_table[];
+extern Sock server[];
+extern Sock clients[];
+extern fd_set socket_mask;
+extern fd_set server_mask;
+
+/* Commands sent over the AXIOM session manager or menu socket */
+
+#define CreateFrame             1
+#define SwitchFrames            2
+#define EndOfOutput             3
+#define CallInterp              4
+#define EndSession              5
+#define LispCommand             6
+#define SpadCommand             7
+#define SendXEventToHyperTeX    8
+#define QuietSpadCommand        9
+#define CloseClient             10
+#define QueryClients            11
+#define QuerySpad               12
+#define NonSmanSession          13
+#define KillLispSystem          14
+
+#define CreateFrameAnswer       50
+
+/* Commands from AXIOM menu server to interpreter windows */
+
+#define ReceiveInputLine        100
+#define TestLine                101
+
+#endif
+\end{chunk}
+
+\begin{chunk}{include/cond.h1}
+/* from bookvol8 chunk include/cond.h1 */
+extern void change_cond(char * label , char * newcond);
+extern int check_condition(TextNode * node);
+extern void insert_cond(char * label , char * cond);
+#ifdef _COND_C
+static int check_memostack(TextNode * node);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/cursor.h1}
+/* from bookvol8 chunk include/cursor.h1 */
+extern int Cursor_shape(int );
+\end{chunk}
+
+\begin{chunk}{include/debug.h}
+/* from bookvol8 chunk include/debug.h */
+/* redefine free */
+/* #define free hfree*/
+\end{chunk}
+
+\begin{chunk}{include/dialog.h1}
+/* from bookvol8 chunk include/dialog.h1 */
+extern void add_buffer_to_sym(char * buffer , InputItem * sym);
+extern void dialog(XEvent * event , KeySym keysym , char * buffer);
+extern void draw_inputsymbol(InputItem * sym);
+extern void update_inputsymbol(InputItem * sym);
+#ifdef _DIALOG_C
+static void back_over_char(InputItem * sym);
+static void back_over_eoln(InputItem * sym);
+static void clear_cursor(InputItem * sym);
+static void clear_cursorline(InputItem * sym);
+static void dec_line_numbers(LineStruct * line);
+static void decrease_line_numbers(LineStruct * line , int am);
+static void delete_char(InputItem * sym);
+static void delete_eoln(InputItem * sym);
+static int delete_one_char(InputItem * sym);
+static void delete_rest_of_line(InputItem * sym);
+static void draw_cursor(InputItem * sym);
+static void enter_new_line(InputItem * sym);
+static void inc_line_numbers(LineStruct * line);
+static void insert_buffer(char * buffer , InputItem * sym);
+static int move_back_one_char(InputItem * sym);
+static void move_cursor_backward(InputItem * sym);
+static void move_cursor_down(InputItem * sym);
+static void move_cursor_end(InputItem * sym);
+static void move_cursor_forward(InputItem * sym);
+static void move_cursor_home(InputItem * sym);
+static void move_cursor_up(InputItem * sym);
+static char move_rest_back(LineStruct * line , int size);
+static int move_sym_forward(LineStruct * line, int num, int size, 
+                            InputItem * sym);
+static char * mystrncpy(char * buff1 , char * buff2 , int n);
+static void overwrite_buffer(char * buffer , InputItem * item);
+static void redraw_win(void);
+static void tough_enter(InputItem * sym);
+#endif 
+\end{chunk}
+
+\begin{chunk}{include/display.h1}
+/* from bookvol8 chunk include/display.h1 */
+extern void expose_page(HyperDocPage * page);
+extern void paste_page(TextNode * node);
+extern void scroll_page(HyperDocPage * page);
+extern void show_page(HyperDocPage * page);
+\end{chunk}
+
+\begin{chunk}{include/edible.h}
+/* from bookvol8 chunk include/edible.h */
+extern int contNum;
+extern struct termios childbuf;	  /** the childs normal operating termio   ***/
+
+/***   the terminals mapping of the function keys			 ***/
+extern unsigned char  _INTR, _QUIT, _ERASE, _KILL, _EOF, _EOL, _RES1, _RES2;
+extern short  INS_MODE ;     /** Flag for insert mode		     **/
+extern short ECHOIT;	     /** Flag for echoing **/
+extern short PTY;   /* A flag which lets me know whether or not I am 
+		       talking to a socket or a pty. If I am not 
+		       talking to a PTY then I have to do things like echo
+		      back newlines, and send interuppts with an eoln
+		      */
+/***************************************************************************
+    Here are the key mapping my routines need
+****************************************************************************/
+
+#define	      _ESC   0X1B    /**  A character sent before every arrow key ***/
+#define	      _LBRACK  0X5B    /**  [				      **/
+#define	      _EOLN    '\n'    /** eoln				      **/
+#define	      _CR      0X0D    /**  cr				      **/
+#define	      _BLANK   0X20    /**  blank			      **/
+#define	      _BKSPC   0X08    /**  backspace			      **/
+#define	      _DEL     0X7F    /**  delete			      **/
+#define	      _BELL    0X07    /***  ring the bell		      **/
+#define	      _INT     0X7F    /***  interrupt			      **/
+#define	      _SQUASH  0X03    /**   kill my process		      **/
+#define	      _CNTRL_W 0X17    /**   cntrl-w, to back up a word	      **/
+#define	      _CARROT  0X5E    /** circumflex			      **/
+#define	      _TAB     0X09    /** tab forward			      **/
+
+#ifndef WCT
+#define	      _A       0X41    /**  A				      **/
+#define	      _B       0X42    /**  B				      **/
+#define	      _C       0X43    /**  C				      **/
+#define	      _D       0X44    /**  D				      **/
+#define	      _Z       0X5A    /**  Z				      **/
+#define	      _H       0X48    /**  H				      **/
+#define	      _M       0X4D    /**  M				      **/
+#define	      _x       0X78    /**  x				      **/
+#define	      _z       0X7A    /*** z				      **/
+#define	      _twiddle 0X7E    /*** ~				      **/
+#define	      _P       0X50    /*** P				      **/
+#define	      _1       0X31    /*** 1				      **/
+#define	      _2       0X32    /*** 2				      **/
+#define	      _3       0X33    /*** 3				      **/
+#define	      _4       0X34    /*** 4				      **/
+#define	      _5       0X35    /*** 5				      **/
+#define	      _6       0X36    /*** 6				      **/
+#define	      _7       0X37    /*** 7				      **/
+#define	      _8       0X38    /*** 8				      **/
+#define	      _9       0X39    /*** 9				      **/
+#define	      _0       0X30    /*** 0				      **/
+#define	      _q       0X71    /*** q				      **/
+#endif
+
+#define MAXLINE		   1024	  /** maximum chars. on a line		  ***/
+#define MAXBUFF		    64	 /** maximum lines saved in the buffer
+				       queue				***/
+
+/***  Here are the constants for my three different modes. ******/
+#define CLEFRAW			     0
+#define CLEFCANONICAL		     1
+#define CLEFCBREAK		     2
+
+extern int mode;   /** One of the above # defines *****/
+
+/**   Here is the structure for storing bound  pf-keys		   ***/
+typedef struct Fkey
+{
+  char *str;
+  short type;
+} fkey;
+
+extern fkey function_key[13] ;	  /** strings which replace function
+					  keys when a key is hit	  ***/
+
+
+extern char editorfilename[];
+
+/****  Here are a bunch of constant, variable and function defs for edin.c */
+#define UP		     0	 /** Tells the replace buffer command	***/
+#define DOWN		     1	 /**   to look up or down		 **/
+
+#define inc(x)	((x+1)%MAXBUFF)	 /** returns the increment of the presented
+				       pointer				***/
+#define dec(x)	( ((x-1) < 0) ?(MAXBUFF - 1):(x-1))/** ibid for decrementing */
+
+#define flip(x)	  (x?(x=0):(x=1))      /*** flip the bit		  ***/
+
+/*
+    All the previous commands will now be stored in a double linked list.
+  This way when I type a command I just have to circle through this list
+*/
+typedef struct que_struct {
+   char buff[1024];
+   int flags[1024];
+   struct que_struct *prev, *next;
+   } QueStruct;
+
+typedef struct wct {
+    char *fname;
+    off_t fsize;
+    time_t ftime;
+    char *fimage;
+    int wordc;
+    char **wordv;
+
+    struct wct *next;
+} Wct;
+
+typedef struct wix {
+    Wct *pwct;
+    int word;
+} Wix;
+
+
+extern QueStruct *ring;
+extern QueStruct *current;
+extern int ring_size;
+extern int prev_check;
+extern int MAXRING;
+
+extern char buff[MAXLINE];		   /**	Buffers for collecting input and  **/
+extern int  buff_flag[MAXLINE];	   /**	   flags for whether buff chars
+					   are printing
+					   or non-printing		  **/
+
+extern char in_buff[1024];   /**     buffer for characters read until they are
+				      processed				  **/
+extern int num_read;
+extern int num_proc;	     /**   num chars processed after a read	  **/
+extern int buff_pntr;	     /**   present length of  buff		  **/
+extern int curr_pntr;	     /** the current position in buff		  **/
+
+/** Here are a bunch of macros for edin.c. They are mostly just charcter
+	comparison stuff						  ***/
+#define back_word(x) (((*(x) == _5) && (*(x+1) == _9) && \
+					(*(x+2) == _q))?(1):(0))
+
+#define fore_word(x) (((*(x) == _6) && (*(x+1) == _8) && \
+					(*(x+2) == _q))?(1):(0))
+
+#define alt_f1(x) (((*(x) == _3) && (*(x+1) == _7) && \
+					(*(x+2) == _q))?(1):(0))
+
+#define cntrl_end(x) (((*(x) == _4) && (*(x+1) == _8) && \
+					(*(x+2) == _q))?(1):(0))
+
+#define insert_toggle(x) (((*(x) == _3) && (*(x+1) == _9) && \
+					(*(x+2) == _q))?(1):(0))
+
+#define end_key(x) (((*(x) == _4) && (*(x+1) == _6) && \
+					(*(x+2) == _q))?(1):(0))
+
+#define control_char(x) \
+     (((x >= 0x01) && (x <= 0x1a))?(1):(0))
+
+
+
+/***
+   Some global defs needed for emulating a pty. This was taken from guru.h
+***/
+
+
+
+/* Return an integer that is represented by a character string */
+#define ciret(x) ((cintu.c4[0]=(x)[0]), (cintu.c4[1]=(x)[1]), \
+		  (cintu.c4[2]=(x)[2]), (cintu.c4[3]=(x)[3]), cintu.i4)
+
+/* move an integer (x) to a character string (y) */
+
+#define icmove(x, y) ((cintu.i4=(x)), ((y)[0]=cintu.c4[0]), \
+		      ((y)[1]=cintu.c4[1]), ((y)[2]=cintu.c4[2]), \
+			 ((y)[3]=cintu.c4[3]))
+
+/* Return an integer that may not be on an integer boundary */
+#define iiret(x) ciret(((char *)&(x)))
+
+ /* Min of two expressions */
+#define min(x, y) ((x)<(y)?(x):(y))
+
+ /* Max of two expressions */
+#define max(x, y) ((x)>(y)?(x):(y))
+\end{chunk}
+
+\begin{chunk}{include/edible.h1}
+/* from bookvol8 chunk include/edible.h1 */
+extern void check_flip(void);
+extern int main(int  , char * []);
+extern void catch_signals(void);
+extern void init_parent(void);
+extern void set_function_chars(void);
+extern void hangup_handler(int );
+extern void terminate_handler(int );
+extern void interrupt_handler(int );
+extern void child_handler(int );
+extern void alarm_handler(int );
+extern void flip_canonical(int );
+extern void flip_raw(int );
+extern void etc_get_next_line(char *  , int *  , int );
+\end{chunk}
+
+\begin{chunk}{include/edin.h1}
+/* from bookvol8 chunk include/edin.h1 */
+extern void init_reader(void);
+extern void init_flag(int *  , int );
+extern void do_reading(void);
+extern void send_line_to_child(void);
+extern void insert_buff_nonprinting(int );
+extern void prev_buff(void);
+extern void next_buff(void);
+extern void insert_buff_printing(int );
+extern void insert_queue(void);
+extern int convert_buffer(char *  , char *  , int *  , int );
+extern void init_buff(char *  , int );
+extern void forwardcopy(char *  , char *  , int );
+extern void forwardflag_cpy(int *  ,int *  , int );
+extern void flagcpy(int *  , int * );
+extern void flagncpy(int *  , int *  , int );
+extern void send_function_to_child(void);
+extern void send_buff_to_child(int );
+\end{chunk}
+
+\begin{chunk}{include/event.h1}
+/* from bookvol8 chunk include/event.h1 */
+extern void exitHyperDoc(void );
+extern void helpForHyperDoc(void );
+extern void mainEventLoop(void );
+extern void make_window_link(char * name);
+extern void quitHyperDoc(void );
+extern void get_new_window(void );
+#ifdef _EVENT_C
+static void set_cursor(HDWindow * window , Cursor state);
+static void change_cursor(Cursor state , HDWindow * window);
+static void create_window(void );
+static void downlink(void );
+static HyperDocPage * find_page(TextNode * node);
+static void handle_button(int button , XButtonEvent * event);
+static void handle_event(XEvent * event);
+static void handle_motion_event(XMotionEvent * event);
+static int HyperDocErrorHandler(Display * display , XErrorEvent * xe);
+static void init_cursor_states(void );
+static void killAxiomPage(HyperDocPage * page);
+static void make_busy_cursor(HDWindow * window);
+static void make_busy_cursors(void );
+static void memolink(void );
+static void set_error_handlers(void );
+static int set_window(Window window);
+static void clear_exposures(Window w);
+static void kill_page(HyperDocPage * page);
+static HyperDocPage * returnlink(void );
+static HyperDocPage * uplink(void );
+static void windowlink_handler(TextNode * node);
+static void lispwindowlink_handler(HyperLink * link);
+static HyperDocPage * paste_button(PasteNode * paste);
+static HyperLink * findButtonInList(HDWindow * window , int x , int y);
+static HyperLink * get_hyper_link(XButtonEvent * event);
+static void init_cursor_state(HDWindow * window);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/ex2ht.h1}
+/* from bookvol8 chunk include/ex2ht.h1 */
+extern int main(int argc , char * * argv);
+extern void openCoverPage(void);
+extern void exToHt(char * filename);
+extern void closeCoverPage(void);
+extern void addFile(char * filename);
+extern void closeCoverFile(void);
+extern char * allocString(char * s);
+extern char * strPrefix(char * prefix , char * s);
+extern char * getExTitle(FILE * inFile , char * line);
+extern void emitCoverLink(char * name , char * title);
+extern void emitHeader(FILE * outFile , char * pageName , char * pageTitle);
+extern void emitMenuEntry(char * line , FILE * outFile);
+extern void emitSpadCommand(char * line , char * prefix , FILE * outFile);
+extern void emitFooter(FILE * outFile);
+\end{chunk}
+
+\begin{chunk}{include/extent1.h1}
+/* from bookvol8 chunk include/extent1.h1 */
+extern void compute_header_extent(HyperDocPage * page);
+extern void compute_footer_extent(HyperDocPage * page);
+extern void compute_scrolling_extent(HyperDocPage * page);
+extern void compute_title_extent(HyperDocPage * page);
+extern void compute_text_extent(TextNode * node);
+#ifdef _EXTENT1_C
+static void compute_begin_items_extent(TextNode * node);
+static void compute_bf_extent(TextNode * node);
+static void compute_box_extent(TextNode * node);
+static void compute_button_extent(TextNode * node);
+static void compute_center_extent(TextNode * node);
+static void compute_dash_extent(TextNode * node);
+static void compute_em_extent(TextNode * node);
+static void compute_ifcond_extent(TextNode * node);
+static void compute_image_extent(TextNode * node);
+static void compute_input_extent(TextNode * node);
+static void compute_ir_extent(TextNode * node);
+static void compute_it_extent(TextNode * node);
+static void compute_item_extent(TextNode * node);
+static void compute_mbox_extent(TextNode * node);
+static void compute_mitem_extent(TextNode * node);
+static void compute_paste_extent(TextNode * node);
+static void compute_pastebutton_extent(TextNode * node);
+static void compute_punctuation_extent(TextNode * node);
+static void compute_rm_extent(TextNode * node);
+static void compute_spadcommand_extent(TextNode * node);
+static void compute_spadsrc_extent(TextNode * node);
+static void compute_spadsrctxt_extent(TextNode * node);
+static void compute_table_extent(TextNode * * node);
+static void compute_verbatim_extent(TextNode * node);
+static void compute_word_extent(TextNode * node);
+static void end_spadcommand_extent(TextNode * node);
+static void end_spadsrc_extent(TextNode * node);
+static void endbutton_extent(TextNode * node);
+static void endif_extent(TextNode * node);
+static void endpastebutton_extent(TextNode * node);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/extent2.h1}
+/* from bookvol8 chunk include/extent2.h1 */
+extern void init_extents(void );
+extern void init_text(void );
+extern void init_title_extents(HyperDocPage * page);
+extern void insert_bitmap_file(TextNode * node);
+extern void insert_pixmap_file(TextNode * node);
+extern int max_x(TextNode * node , int Ender);
+extern int plh(int height);
+extern void start_newline(int distance , TextNode * node);
+extern int text_height(TextNode * node , int Ender);
+extern int text_width(TextNode * node , int Ender);
+extern int total_width(TextNode * node , int Ender);
+extern int trailing_space(TextNode * node);
+#ifdef _EXTENT2_C
+static void center_nodes(TextNode * begin_node , TextNode * end_node);
+static int input_string_width(TextNode * node);
+static int punctuation_width(TextNode * node);
+static int text_height1(TextNode * node , int Ender);
+static int verbatim_width(TextNode * node);
+static int width_of_dash(TextNode * node);
+static int word_width(TextNode * node);
+static int x_value(TextNode * node);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/fnct-key.h1}
+/* from bookvol8 chunk include/fnct-key.h1 */
+extern void set_editor_key(void);
+extern void define_function_keys(void);
+extern int get_key(int  , char * );
+extern int get_str(int  , char * );
+extern void null_fnct(int );
+extern void handle_function_key(int  , int );
+\end{chunk}
+
+\begin{chunk}{include/form-ext.h1}
+/* from bookvol8 chunk include/form-ext.h1 */
+extern void compute_form_page(HyperDocPage * page);
+extern int window_width(int cols);
+#ifdef _FORM_EXT_C
+static int window_height(HyperDocPage * page);
+static void form_header_extent(HyperDocPage * page);
+static void form_footer_extent(HyperDocPage * page);
+static void form_scrolling_extent(HyperDocPage * page);
+#endif 
+\end{chunk}
+
+\begin{chunk}{include/group.h1}
+/* from bookvol8 chunk include/group.h1 */
+extern void bf_top_group(void );
+extern GroupItem * copy_group_stack(void );
+extern void em_top_group(void );
+extern void free_group_stack(GroupItem * g);
+extern void init_group_stack(void );
+extern void init_top_group(void );
+extern void line_top_group(void );
+extern int pop_group_stack(void );
+extern void push_active_group(void );
+extern void push_group_stack(void );
+extern void push_spad_group(void );
+extern void rm_top_group(void );
+extern void tt_top_group(void );
+extern void center_top_group(void );
+\end{chunk}
+
+\begin{chunk}{include/halloc.h1}
+/* from bookvol8 chunk include/halloc.h1 */
+extern char * halloc(int bytes , char * msg);
+\end{chunk}
+
+\begin{chunk}{include/hash.h}
+/* from bookvol8 chunk include/hash.h */
+#ifndef _HASH_H_
+#define _HASH_H_ 1
+
+typedef struct hash_entry {
+  char *key;			/* pointer to key data */
+  char *data;			/* Pointer to entry */
+  struct hash_entry *next;	/* Link to next entry */
+} HashEntry;
+
+typedef int (*EqualFunction)(void *,void *);
+typedef int (*HashcodeFunction)(void *,int);
+typedef void (*MappableFunction) (void *);
+typedef void (*FreeFunction) (void *);
+typedef struct {
+  HashEntry **table;		/* the actual table */
+  int size;			/* size of table */
+  int num_entries;		/* number of elements in a hash table */
+  EqualFunction equal;		/* equality predicate for keys */
+  HashcodeFunction hash_code;	/* create hash code for a key */
+} HashTable;
+
+#endif
+\end{chunk}
+
+\begin{chunk}{include/hash.h1}
+/* from bookvol8 chunk include/hash.h1 */
+extern char * alloc_string(char * str);
+extern HashEntry * hash_copy_entry(HashEntry * e);
+extern HashTable * hash_copy_table(HashTable * table);
+extern void hash_delete(HashTable * table , char * key);
+extern char * hash_find(HashTable * table , char * key);
+extern void hash_init(HashTable * table, int size, EqualFunction equal,
+                      HashcodeFunction hash_code);
+extern void free_hash(HashTable * table , FreeFunction free_fun);
+extern void hash_insert(HashTable * table , char * data , char * key);
+extern void hash_map(HashTable * table , MappableFunction func);
+extern char * hash_replace(HashTable * table , char * data , char * key);
+extern int string_equal(char * s1 , char * s2);
+extern int string_hash(char * s , int size);
+\end{chunk}
+
+\begin{chunk}{include/htadd.h1}
+/* from bookvol8 chunk include/htadd.h1 */
+extern int main(int argc , char * * argv);
+#ifdef _HTADD_C
+static void add_file(char * dbname , char * name , int fresh);
+static void add_new_pages(FILE * temp_db, FILE * new_file, 
+                          char * addname, char * fullname);
+static int build_db_filename(short flag , char * db_dir , char * dbfilename);
+static void copy_file(char * f1 , char * f2);
+static void delete_db(FILE * db , FILE * temp_db , char * name);
+static int delete_file(char * dbname , char * name);
+static void get_filename(void);
+static void parse_args(char * * argv, char * db_dir, 
+                       char * * filenames, short * fl);
+static void update_db(FILE * db, FILE * temp_db, FILE * new_file, 
+                      char * addname, char * fullname, int fresh);
+static int writable(struct stat buff);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/hterror.h1}
+/* from bookvol8 chunk include/hterror.h1 */
+extern void print_page_and_filename(void );
+extern void jump(void );
+extern void print_token(void );
+extern void token_name(int type);
+extern void print_next_ten_tokens(void );
+extern void htperror(char * msg , int errno);
+\end{chunk}
+
+\begin{chunk}{include/hthits.h1}
+/* from bookvol8 chunk include/hthits.h1 */
+extern void regerr(int code);
+extern int main(int argc , char * * argv);
+extern void cmdline(int argc , char * * argv);
+extern void handleHtdb(void);
+extern void badDB(void);
+extern void handleFile(FILE * htdbFile);
+extern void handleFilePages(char * fname , int pgc , PgInfo * pgv);
+extern void handlePage(FILE * infile , PgInfo * pg);
+extern void splitpage(char * buf , char * * ptitle , char * * pbody);
+extern void untexbuf(register char * s);
+extern void searchPage(char * pgname , char * pgtitle , char * pgbody);
+extern void squirt(char * s , int n);
+\end{chunk}
+
+\begin{chunk}{include/htinp.h1}
+/* from bookvol8 chunk include/htinp.h1 */
+extern void ht2_input(void );
+extern void make_record(void );
+extern void verify_record(void );
+extern char * strCopy(char * s);
+extern void print_paste_line(FILE * pfile , char * str);
+extern void get_spad_output(FILE * pfile , char * command , int com_type);
+extern void get_graph_output(char * command , char * pagename , int com_type);
+#ifdef _HTINP_C
+static void make_input_file_list(void );
+static char * make_input_file_name(char * buf , char * filename);
+static char * make_paste_file_name(char * buf , char * filename);
+static void make_the_input_file(UnloadedPage * page);
+static void make_input_file_from_page(HyperDocPage * page);
+static int inListAndNewer(char * inputFile , char * htFile);
+static void print_paste(FILE * pfile, char * realcom, char * command, 
+                        char * pagename, int com_type);
+static void print_graph_paste(FILE * pfile, char * realcom, char * command, 
+                              char * pagename, int com_type);
+static void send_command(char * command , int com_type);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/hyper.h1}
+/* from bookvol8 chunk include/hyper.h1 */
+extern void sigusr2_handler(int sig);
+extern void sigcld_handler(int sig);
+extern void clean_socket(void);
+extern int main(int argc , char * * argv);
+extern void init_page_structs(HDWindow * w);
+#ifdef _HYPER_C
+static void init_hash(void);
+static void make_server_connections(void);
+static void check_arguments(void);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/initx.h1}
+/* from bookvol8 chunk include/initx.h1 */
+extern void change_text(int color , XFontStruct * font);
+extern int init_form_window(char * name , int cols);
+extern int init_top_window(char * name);
+extern void initializeWindowSystem(void);
+extern int is_it_850(XFontStruct * fontarg);
+#ifdef _INITX_C
+static void get_GCs(HDWindow * window);
+static int get_border_properties(void);
+static int get_color(char * name , char * class , int def , Colormap * map);
+static void ingItColors_and_fonts(void);
+static void load_font(XFontStruct * * font_info , char * fontname);
+static void mergeDatabases(void);
+static void open_form_window(void);
+static void open_window(Window w);
+static void set_name_and_icon(void);
+static void set_size_hints(Window w);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/input.h1}
+/* from bookvol8 chunk include/input.h1 */
+extern InputItem * return_item(char * name);
+extern void fill_box(Window w , ImageStruct * image);
+extern void toggle_input_box(HyperLink * link);
+extern void toggle_radio_box(HyperLink * link);
+extern void change_input_focus(HyperLink * link);
+extern void next_input_focus(void);
+extern void prev_input_focus(void);
+extern int delete_item(char * name);
+#ifdef _INPUT_C
+static void clear_rbs(InputBox * list);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/item.h1}
+/* from bookvol8 chunk include/item.h1 */
+extern void push_item_stack(void);
+extern void clear_item_stack(void);
+extern void pop_item_stack(void);
+extern ItemStack * copy_item_stack(void);
+extern void free_item_stack(ItemStack * is);
+\end{chunk}
+
+\begin{chunk}{include/keyin.h1}
+/* from bookvol8 chunk include/keyin.h1 */
+extern void handle_key(XEvent * event);
+extern void init_keyin(void);
+\end{chunk}
+
+\begin{chunk}{include/lex.h1}
+/* from bookvol8 chunk include/lex.h1 */
+extern int connect_spad(void);
+extern void get_expected_token(int type);
+extern void parser_init(void);
+extern void init_scanner(void);
+extern void save_scanner_state(void);
+extern void restore_scanner_state(void);
+extern void unget_char(int c);
+extern int get_char(void);
+extern void unget_token(void);
+extern int get_token(void);
+extern void push_be_stack(int type , char * id);
+extern void check_and_pop_be_stack(int type , char * id);
+extern int clear_be_stack(void);
+extern int be_type(char * which);
+extern int begin_type(void);
+extern int end_type(void);
+extern void reset_connection(void);
+extern int spad_busy(void);
+#ifdef _LEX_C
+static int get_char1(void );
+static void spad_error_handler(void );
+static int keyword_type(void );
+#endif
+\end{chunk}
+
+\begin{chunk}{include/macro.h1}
+/* from bookvol8 chunk include/macro.h1 */
+extern void scan_HyperDoc(void);
+extern int number(char * str);
+extern ParameterList init_parameter_elem(int number);
+extern int push_parameters(ParameterList new);
+extern int pop_parameters(void);
+extern int parse_macro(void);
+extern void parse_parameters(void);
+#ifdef _MACRO_C
+static char * load_macro(MacroStore * macro);
+static void get_parameter_strings(int number , char * macro_name);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/mem.h1}
+/* from bookvol8 chunk include/mem.h1 */
+extern ButtonList * alloc_button_list(void);
+extern CondNode * alloc_condnode(void);
+extern HDWindow * alloc_hd_window(void);
+extern IfNode * alloc_ifnode(void);
+extern InputBox * alloc_inputbox(void);
+extern LineStruct * alloc_inputline(int size);
+extern TextNode * alloc_node(void);
+extern HyperDocPage * alloc_page(char * name);
+extern PasteNode * alloc_paste_node(char * name);
+extern RadioBoxes * alloc_rbs(void);
+extern void free_button_list(ButtonList * bl);
+extern void free_hd_window(HDWindow * w);
+extern void free_input_item(InputItem * sym , short des);
+extern void free_input_list(InputItem * il);
+extern void free_node(TextNode * node , short des);
+extern void free_page(HyperDocPage * page);
+extern void free_patch(PatchStore * p);
+extern void free_string(char * str);
+extern char * resizeBuffer(int size , char * oldBuf , int * oldSize);
+extern PatchStore * alloc_patchstore(void);
+#ifdef _MEM_C
+static void free_cond(CondNode * cond);
+static void free_depend(SpadcomDepend * sd);
+static void free_lines(LineStruct * lines);
+static void dont_free(void * link);
+static void free_if_non_NULL(void * p);
+static void free_input_box(InputBox * box);
+static void free_paste(PasteNode * paste , short des);
+static void free_pastearea(TextNode * node , short des);
+static void free_pastebutton(TextNode * node , short des);
+static void free_radio_boxes(RadioBoxes * radio);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/openpty.h1}
+/* from bookvol8 chunk include/openpty.h1 */
+extern void makeNextPtyNames(char *  , char * );
+extern int ptyopen(int *  , int *  , char *  , char * );
+\end{chunk}
+
+\begin{chunk}{include/parse-aux.h1}
+/* from bookvol8 chunk include/parse-aux.h1 */
+extern void add_dependencies(void );
+extern FILE * find_fp(FilePosition fp);
+extern char * get_input_string(void );
+extern HyperLink * make_link_window(TextNode * link_node , int type , int isSubWin);
+extern HyperLink * make_paste_window(PasteNode * paste);
+extern void make_special_pages(HashTable * pageHashTable);
+extern int window_code(Window * w , int size);
+extern int window_equal(Window * w1 , Window * w2);
+extern char * window_id(Window w);
+extern void read_ht_db(HashTable * page_hash , HashTable * macro_hash , HashTable * patch_hash);
+extern int get_filename(void);
+extern int is_number(char * str);
+extern void parser_error(char * str);
+extern int get_where(void);
+#ifdef _PARSE_AUX_C
+static void read_ht_file(HashTable * page_hash , HashTable * macro_hash , HashTable * patch_hash , FILE * db_fp , char * db_file);
+static HyperDocPage * make_special_page(int type , char * name);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/parse.h1}
+/* from bookvol8 chunk include/parse.h1 */
+extern void display_page(HyperDocPage * page);
+extern void init_parse_patch(HyperDocPage * page);
+extern void load_page(HyperDocPage * page);
+extern void parse_HyperDoc(void );
+extern void parse_from_string(char * str);
+extern HyperDocPage * parse_page_from_socket(void );
+extern HyperDocPage * parse_page_from_unixfd(void );
+#ifdef _PARSE_C
+static void end_a_page(void );
+static HyperDocPage * format_page(UnloadedPage * ulpage);
+static void parse_page(HyperDocPage * page);
+static void parse_replacepage(void );
+static void start_footer(void );
+static void start_scrolling(void );
+static void Push_MR(void );
+static void Pop_MR(void );
+static void parse_title(HyperDocPage * page);
+static void parse_header(HyperDocPage * page);
+static void init_parse_page(HyperDocPage * page);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/parse-input.h1}
+/* from bookvol8 chunk include/parse-input.h1 */
+extern HyperLink * make_input_window(InputItem * item);
+extern HyperLink * make_box_window(InputBox * box , int type);
+extern void initialize_default(InputItem * item , char * buff);
+extern void parse_inputstring(void);
+extern void parse_simplebox(void);
+extern void parse_radiobox(void);
+extern void init_paste_item(InputItem * item);
+extern void repaste_item(void);
+extern InputItem * current_item(void);
+extern int already_there(char * name);
+extern void parse_radioboxes(void);
+#ifdef _PARSE_INPUT_C
+static void insert_item(InputItem * item);
+static void add_box_to_rb_list(char * name , InputBox * box);
+static int check_others(InputBox * list);
+#endif 
+\end{chunk}
+
+\begin{chunk}{include/parse-paste.h1}
+/* from bookvol8 chunk include/parse-paste.h1 */
+extern void parse_paste(void);
+extern void parse_pastebutton(void);
+extern HyperDocPage * parse_patch(PasteNode * paste);
+#ifdef _PARSE_PASTE_C
+static void load_patch(PatchStore * patch);
+#endif 
+\end{chunk}
+
+\begin{chunk}{include/parse-types.h1}
+/* from bookvol8 chunk include/parse-types.h1 */
+extern void parse_begin_items(void );
+extern void parse_box(void );
+extern void parse_button(void );
+extern void parse_centerline(void );
+extern void parse_command(void );
+extern void parse_env(TextNode * node);
+extern void parse_free(void );
+extern void parse_help(void );
+extern void parse_ifcond(void );
+extern void parse_input_pix(void );
+extern void parse_item(void );
+extern void parse_mbox(void );
+extern void parse_mitem(void );
+extern void parse_newcond(void );
+extern void parse_setcond(void );
+extern void parse_spadcommand(TextNode * spad_node);
+extern void parse_spadsrc(TextNode * spad_node);
+extern void parse_table(void );
+extern void parse_value1(void );
+extern void parse_value2(void );
+extern void parse_verbatim(int type);
+#ifdef _PARSE_TYPES_C
+static void parse_condnode(void );
+static void parse_hasreturnto(void );
+#endif 
+\end{chunk}
+
+\begin{chunk}{include/pixmap.h1}
+/* from bookvol8 chunk include/pixmap.h1 */
+extern int file_exists(char * );
+extern FILE * zzopen(char *  , char * );
+extern void write_pixmap_file(Display *, int, char *, Window, int, int, 
+                              int, int );
+extern int read_pixmap_file(Display *, int, char *, XImage * *, int *, int * );
+\end{chunk}
+
+\begin{chunk}{include/prt.h1}
+/* from bookvol8 chunk include/prt.h1 */
+extern void myputchar(char );
+extern void clear_buff(void);
+extern void move_end(void);
+extern void move_home(void);
+extern void move_fore_word(void);
+extern void move_back_word(void);
+extern void delete_current_char(void);
+extern void del_print(int  , int );
+extern void delete_to_end_of_line(void);
+extern void delete_line(void);
+extern void printbuff(int  , int );
+extern void ins_print(int  , int );
+extern void reprint(int );
+extern void back_up(int );
+extern void back_it_up(int );
+extern void print_whole_buff(void);
+extern void move_ahead(void);
+extern void move_back(void);
+extern void back_over_current_char(void);
+\end{chunk}
+
+\begin{chunk}{include/readbitmap.h1}
+/* from bookvol8 chunk include/readbitmap.h1 */
+extern XImage * HTReadBitmapFile(Display * display, int screen, 
+                                 char * filename, int * width, int * height);
+extern ImageStruct * insert_image_struct(char * filename);
+#ifdef _READBITMAP_C
+static int read_hot(FILE * fd , char Line[] , int * x_hot , int * y_hot);
+static int read_w_and_h(FILE * fd, unsigned int * width, 
+                        unsigned int * height);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/scrollbar.h1}
+/* from bookvol8 chunk include/scrollbar.h1 */
+extern void calculateScrollBarMeasures(void );
+extern void drawScrollLines(void );
+extern void hideScrollBars(HDWindow * hdWindow);
+extern void getScrollBarMinimumSize(int * width , int * height);
+extern void linkScrollBars(void );
+extern void makeScrollBarWindows(void );
+extern void moveScroller(HDWindow * hdWindow);
+extern void scrollDown(void );
+extern void scrollDownPage(void );
+extern void scrollScroller(XButtonEvent * event);
+extern void scrollToFirstPage(void );
+extern void scrollUp(void );
+extern void scrollUpPage(void );
+extern void showScrollBars(HDWindow * hdWindow);
+#ifdef _SCROLLBAR_C
+static int ch(int height);
+static void changeWindowBackgroundPixmap(Window window , Pixmap pixmap);
+static void drawScroller3DEffects(HDWindow * hdWindow, int x1, int y1, 
+                                  int x2, int y2);
+
+#endif 
+\end{chunk}
+
+\begin{chunk}{include/session.h1}
+/* from bookvol8 chunk include/session.h1 */
+extern int main(void);
+#ifdef _SESSION_C
+static void usr1_handler(int sig);
+static void usr2_handler(int sig);
+static void term_handler(int sig);
+static void close_client(int frame);
+static void read_SpadServer_command(void);
+static int test_sock_for_process(Sock * sock);
+static void read_menu_client_command(void);
+static void read_from_spad_io(void);
+static void kill_spad(void);
+static int accept_session_connection(Sock * server_sock);
+static void read_from_session(Sock * sock);
+static void manage_sessions(void);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/show-types.h1}
+/* from bookvol8 chunk include/show-types.h1 */
+extern void show_text(TextNode * node , int Ender);
+#ifdef _SHOW_TYPES_C
+static void show_image(TextNode * node , GC gc);
+static void show_input(TextNode * node);
+static void show_link(TextNode * node);
+static void show_paste(TextNode * node);
+static void show_pastebutton(TextNode * node);
+static void show_simple_box(TextNode * node);
+static void show_spadcommand(TextNode * node);
+#endif 
+\end{chunk}
+
+\begin{chunk}{include/sman.h1}
+/* from bookvol8 chunk include/sman.h1 */
+extern int main(int argc , char * argv[] , char * envp[]);
+#ifdef _SMAN_C
+static void process_arguments(int argc , char * * argv);
+static int should_I_clef(void);
+static int in_X(void);
+static void set_up_defaults(void);
+static void process_options(int argc , char * * argv);
+static void death_handler(int sig);
+static void sman_catch_signals(void);
+static void fix_env(char * * envp , int spadnum);
+static void init_term_io(void);
+static char * strPrefix(char * prefix , char * s);
+static void check_spad_proc(char * file , char * prefix);
+static void clean_up_old_sockets(void);
+static SpadProcess * fork_you(int death_action);
+static void exec_command_env(char * command , char * * env);
+static SpadProcess * spawn_of_hell(char * command , int death_action);
+static void start_the_spadclient(void);
+static void start_the_local_spadclient(void);
+static void start_the_session_manager(void);
+static void start_the_hypertex(void);
+static void start_the_graphics(void);
+static void fork_Axiom(void);
+static void start_the_Axiom(char * * envp);
+static void clean_up_sockets(void);
+static void clean_hypertex_socket(void);
+static void read_from_spad_io(int ptcNum);
+static void read_from_manager(int ptcNum);
+static void manage_spad_io(int ptcNum);
+static void init_spad_process_list(void);
+static SpadProcess * find_child(int proc_id);
+static void kill_all_children(void);
+static void clean_up_terminal(void);
+static void monitor_children(void);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/sockio-c.h1}
+/* from bookvol8 chunk include/sockio-c.h1 */
+extern int get_int(Sock * );
+extern char * get_string(Sock * );
+extern double get_float(Sock * );
+extern Sock * connect_to_local_server(char *  , int  , int );
+extern int sread(Sock *  , char *  , int  , char * );
+extern double plus_infinity(void );
+extern double minus_infinity(void );
+extern double NANQ(void );
+extern void sigpipe_handler(int );
+extern int wait_for_client_read(Sock *  , char *  , int  , char * );
+extern int wait_for_client_write(Sock *  , char *  , int  , char * );
+extern int swrite(Sock *  , char *  , int  , char * );
+extern int sselect(int  , fd_set *  , fd_set *  , fd_set *  , void * );
+extern int fill_buf(Sock *  , char *  , int  , char * );
+extern int sock_get_int(int );
+extern int get_ints(Sock *  , int *  , int );
+extern int sock_get_ints(int  , int *  , int );
+extern int send_int(Sock *  , int );
+extern int sock_send_int(int  , int );
+extern int send_ints(Sock *  , int *  , int );
+extern int sock_send_ints(int  , int *  , int );
+extern int send_string(Sock *  , char * );
+extern int send_string_len(Sock *  , char *  , int );
+extern int sock_send_string(int  , char * );
+extern int sock_send_string_len(int  , char *  , int );
+extern int send_strings(Sock *  , char * *  , int );
+extern int sock_send_strings(int  , char * *  , int );
+extern char * sock_get_string(int );
+extern char * get_string_buf(Sock *  , char *  , int );
+extern char * sock_get_string_buf(int  , char *  , int );
+extern int get_strings(Sock *  , char * *  , int );
+extern int sock_get_strings(int  , char * *  , int );
+extern int send_float(Sock *  , double );
+extern int sock_send_float(int  , double );
+extern int send_sfloats(Sock *  , float *  , int );
+extern int sock_send_sfloats(int  , float *  , int );
+extern int send_floats(Sock *  , double *  , int );
+extern int sock_send_floats(int  , double *  , int );
+extern double sock_get_float(int );
+extern int get_sfloats(Sock *  , float *  , int );
+extern int sock_get_sfloats(int  , float *  , int );
+extern int get_floats(Sock *  , double *  , int );
+extern int sock_get_floats(int  , double *  , int );
+extern int wait_for_client_kill(Sock *  , int );
+extern int sock_get_remote_fd(int );
+extern int send_signal(Sock *  , int );
+extern int sock_send_signal(int  , int );
+extern int send_wakeup(Sock * );
+extern int sock_send_wakeup(int );
+extern Sock * connect_to_local_server_new(char *  , int  , int );
+extern void remote_stdio(Sock * );
+extern void init_purpose_table(void );
+extern int make_server_number(void );
+extern void close_socket(int  , char * );
+extern int make_server_name(char *  , char * );
+extern int open_server(char * );
+extern int accept_connection(Sock * );
+extern void get_socket_type(Sock * );
+extern int sock_accept_connection(int );
+extern void redirect_stdio(Sock * );
+extern void init_socks(void );
+extern int server_switch(void );
+extern void flush_stdout(void );
+extern void print_line(char * );
+\end{chunk}
+
+\begin{chunk}{include/spadbuf.h1}
+/* from bookvol8 chunk include/spadbuf.h1 */
+extern int main(int argc , char * * argv);
+#ifdef _SPADBUF_C
+static void spadbuf_inter_handler(int sig);
+static void spadbuf_function_chars(void);
+static void interp_io(void);
+static void init_parent(void);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/spadclient.h1}
+/* from bookvol8 chunk include/spadclient.h1 */
+extern int main(void);
+#ifdef _SPADCLIENT_C
+static void inter_handler(int sig);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/spadcolors.h1}
+/* from bookvol8 chunk include/spadcolors.h1 */
+extern RGB HSVtoRGB(HSV );
+extern RGB HLStoRGB(HLS );
+extern float value(float  , float  , float );
+extern int makeColors(Display *  , int  , Colormap *  , unsigned long * *  , int * );
+extern int makePermVector(Display *  , int  , unsigned long * * );
+extern int makeNewColorMap(Display *  , Colormap  , int );
+extern unsigned long XPixelColor(int );
+extern void FreePixels(Display *  , Colormap  , int );
+extern int AllocCells(Display *  , Colormap  , int );
+\end{chunk}
+
+\begin{chunk}{include/spadint.h1}
+/* from bookvol8 chunk include/spadint.h1 */
+extern HyperDocPage * issue_server_command(HyperLink * link);
+extern HyperDocPage * issue_unixlink(TextNode * node);
+extern char * print_to_string(TextNode * command);
+extern void issue_spadcommand(HyperDocPage * page , TextNode * command , 
+                              int immediate , int type);
+extern Sock * accept_menu_connection(Sock * server_sock);
+extern char * print_to_string1(TextNode * command , int * sizeBuf);
+extern int issue_serverpaste(TextNode * command);
+extern void issue_unixcommand(TextNode * node);
+extern int issue_unixpaste(TextNode * node);
+extern void service_session_socket(void);
+extern void send_lisp_command(char * command);
+extern void escape_string(char * s);
+extern void unescape_string(char * s);
+extern char * print_source_to_string1(TextNode * command , int * sizeBuf);
+extern char * print_source_to_string(TextNode * command);
+#ifdef _SPADINT_C
+static void start_user_buffer(HyperDocPage * page);
+static void clear_execution_marks(HashTable * depend_hash);
+static void issue_dependent_commands(HyperDocPage * page, TextNode * command, 
+                                     int type);
+static void send_pile(Sock * sock , char * str);
+static void mark_as_executed(HyperDocPage * page, TextNode * command, 
+                             int type);
+static void accept_menu_server_connection(HyperDocPage * page);
+static void switch_frames(void );
+static void close_client(int pid);
+#endif 
+\end{chunk}
+
+\begin{chunk}{include/titlebar.h1}
+/* from bookvol8 chunk include/titlebar.h1 */
+extern void getTitleBarMinimumSize(int * width , int * height);
+extern void linkTitleBarWindows(void);
+extern void makeTitleBarWindows(void);
+extern void showTitleBar(void);
+#ifdef _TITLEBAR_C
+static void readTitleBarImages(void);
+#endif
+\end{chunk}
+
+\begin{chunk}{include/util.h1}
+/* from bookvol8 chunk include/util.h1 */
+extern int checker(int  , int  , char * );
+extern char * getmemWithLine(int  , char *  , int );
+extern char * saymemWithLine(char *  , int  , int  , int );
+extern void myfree(void *  , int );
+extern XPoint getWindowPositionXY(Display *  , Window );
+extern XPoint getWindowSizeXY(Display *  , Window );
+\end{chunk}
+
+\begin{chunk}{include/wct.h1}
+/* from bookvol8 chunk include/wct.h1 */
+extern time_t ftime(char * );
+extern void fatal(char *  , char * );
+extern off_t fsize(char * );
+extern Wix * scanWct(Wct *  , char * );
+extern void reintern1Wct(Wct * );
+extern Wix * rescanWct(void);
+extern void skimWct(Wct * );
+extern void skim1Wct(Wct * );
+extern void printTime(long * );
+extern int skimString(char *  , int  , int  , int );
+extern int prChar(int );
+extern Wct * reread1Wct(Wct * );
+extern void sfatal(char * );
+extern Wct * read1Wct(char * );
+extern Wct * nconcWct(Wct *  , Wct * );
+extern void sortWct(Wct * );
+extern void sort1Wct(Wct * );
+extern int mystrcmp(const void  *  , const void * );
+extern void burstWct(Wct * );
+extern void burst1Wct(Wct * );
+extern Wct * intern1Wct(char * );
+extern void load_wct_file(char * );
+extern void  skim_wct(void);
+extern void  rescan_wct(void);
+extern void  find_wct(void);
+\end{chunk}
+
+\begin{chunk}{include/xdither.h1}
+/* from bookvol8 chunk include/xdither.h1 */
+extern int dither_char_bitmap(void);
+extern int XInitDither(Display *, int, GC, unsigned long, unsigned long);
+extern int XChangeDither(Display *  , GC  , int );
+extern void XDitherRectangle(Display *, Drawable, GC, int, int, unsigned int, 
+                             unsigned int );
+extern void XDitherRectangles(Display *, Drawable, GC, XRectangle *, int);
+extern void XDitherPolygon(Display *, Drawable, GC, XPoint *, int, int, int);
+extern void XDitherArc(Display *, Drawable, GC, int, int, unsigned int, 
+                       unsigned int, int, int );
+extern void XDitherArcs(Display *  , Drawable  , GC  , XArc *  , int );
+\end{chunk}
+
+\begin{chunk}{include/xpm.h}
+/* from bookvol8 chunk include/xpm.h */
+/*****************************************************************************\
+* xpm.h:                                                                      *
+*                                                                             *
+*  XPM library                                                                *
+*  Include file                                                               *
+*                                                                             *
+*  Developed by Arnaud Le Hors                                                *
+\*****************************************************************************/
+
+/*
+ * The code related to FOR_MSW has been added by
+ * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
+ */
+
+#ifndef XPM_h
+#define XPM_h
+
+/*
+ * first some identification numbers:
+ * the version and revision numbers are determined with the following rule:
+ * SO Major number = LIB minor version number.
+ * SO Minor number = LIB sub-minor version number.
+ * e.g: Xpm version 3.2f
+ *      we forget the 3 which is the format number, 2 gives 2, and f gives 6.
+ *      thus we have XpmVersion = 2 and XpmRevision = 6
+ *      which gives  SOXPMLIBREV = 2.6
+ *
+ * Then the XpmIncludeVersion number is built from these numbers.
+ */
+#define XpmFormat 3
+#define XpmVersion 4
+#define XpmRevision 9
+#define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
+
+#ifndef XPM_NUMBERS
+
+#ifdef FOR_MSW
+# define SYSV			/* uses memcpy string.h etc. */
+# include <malloc.h>
+# include "simx.h"		/* defines some X stuff using MSW types */
+#define NEED_STRCASECMP		/* at least for MSVC++ */
+#else /* FOR_MSW */
+# include <X11/Xlib.h>
+# include <X11/Xutil.h>
+#endif /* FOR_MSW */
+
+/* let's define Pixel if it is not done yet */
+#if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
+typedef unsigned long Pixel;	/* Index into colormap */
+# define PIXEL_ALREADY_TYPEDEFED
+#endif
+
+/* make sure we know whether function prototypes are needed or not */
+#ifndef NeedFunctionPrototypes
+# if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
+#  define NeedFunctionPrototypes 1
+# else
+#  define NeedFunctionPrototypes 0
+# endif
+#endif
+
+
+/* Return ErrorStatus codes:
+ * null     if full success
+ * positive if partial success
+ * negative if failure
+ */
+
+#define XpmColorError    1
+#define XpmSuccess       0
+#define XpmOpenFailed   -1
+#define XpmFileInvalid  -2
+#define XpmNoMemory     -3
+#define XpmColorFailed  -4
+
+typedef struct {
+    char *name;			/* Symbolic color name */
+    char *value;		/* Color value */
+    Pixel pixel;		/* Color pixel */
+}      XpmColorSymbol;
+
+typedef struct {
+    char *name;			/* name of the extension */
+    unsigned int nlines;	/* number of lines in this extension */
+    char **lines;		/* pointer to the extension array of strings */
+}      XpmExtension;
+
+typedef struct {
+    char *string;		/* characters string */
+    char *symbolic;		/* symbolic name */
+    char *m_color;		/* monochrom default */
+    char *g4_color;		/* 4 level grayscale default */
+    char *g_color;		/* other level grayscale default */
+    char *c_color;		/* color default */
+}      XpmColor;
+
+typedef struct {
+    unsigned int width;		/* image width */
+    unsigned int height;	/* image height */
+    unsigned int cpp;		/* number of characters per pixel */
+    unsigned int ncolors;	/* number of colors */
+    XpmColor *colorTable;	/* list of related colors */
+    unsigned int *data;		/* image data */
+}      XpmImage;
+
+typedef struct {
+    unsigned long valuemask;	/* Specifies which attributes are defined */
+    char *hints_cmt;		/* Comment of the hints section */
+    char *colors_cmt;		/* Comment of the colors section */
+    char *pixels_cmt;		/* Comment of the pixels section */
+    unsigned int x_hotspot;	/* Returns the x hotspot's coordinate */
+    unsigned int y_hotspot;	/* Returns the y hotspot's coordinate */
+    unsigned int nextensions;	/* number of extensions */
+    XpmExtension *extensions;	/* pointer to array of extensions */
+}      XpmInfo;
+
+typedef int (*XpmAllocColorFunc)(
+#if NeedFunctionPrototypes
+    Display*			/* display */,
+    Colormap			/* colormap */,
+    char*			/* colorname */,
+    XColor*			/* xcolor */,
+    void*			/* closure */
+#endif
+);
+
+typedef int (*XpmFreeColorsFunc)(
+#if NeedFunctionPrototypes
+    Display*			/* display */,
+    Colormap			/* colormap */,
+    Pixel*			/* pixels */,
+    int				/* npixels */,
+    void*			/* closure */
+#endif
+);
+
+typedef struct {
+    unsigned long valuemask;		/* Specifies which attributes are
+					   defined */
+
+    Visual *visual;			/* Specifies the visual to use */
+    Colormap colormap;			/* Specifies the colormap to use */
+    unsigned int depth;			/* Specifies the depth */
+    unsigned int width;			/* Returns the width of the created
+					   pixmap */
+    unsigned int height;		/* Returns the height of the created
+					   pixmap */
+    unsigned int x_hotspot;		/* Returns the x hotspot's
+					   coordinate */
+    unsigned int y_hotspot;		/* Returns the y hotspot's
+					   coordinate */
+    unsigned int cpp;			/* Specifies the number of char per
+					   pixel */
+    Pixel *pixels;			/* List of used color pixels */
+    unsigned int npixels;		/* Number of used pixels */
+    XpmColorSymbol *colorsymbols;	/* List of color symbols to override */
+    unsigned int numsymbols;		/* Number of symbols */
+    char *rgb_fname;			/* RGB text file name */
+    unsigned int nextensions;		/* Number of extensions */
+    XpmExtension *extensions;		/* List of extensions */
+
+    unsigned int ncolors;               /* Number of colors */
+    XpmColor *colorTable;               /* List of colors */
+/* 3.2 backward compatibility code */
+    char *hints_cmt;                    /* Comment of the hints section */
+    char *colors_cmt;                   /* Comment of the colors section */
+    char *pixels_cmt;                   /* Comment of the pixels section */
+/* end 3.2 bc */
+    unsigned int mask_pixel;            /* Color table index of transparent
+                                           color */
+
+    /* Color Allocation Directives */
+    Bool exactColors;			/* Only use exact colors for visual */
+    unsigned int closeness;		/* Allowable RGB deviation */
+    unsigned int red_closeness;		/* Allowable red deviation */
+    unsigned int green_closeness;	/* Allowable green deviation */
+    unsigned int blue_closeness;	/* Allowable blue deviation */
+    int color_key;			/* Use colors from this color set */
+
+    Pixel *alloc_pixels;		/* Returns the list of alloc'ed color
+					   pixels */
+    Bool nalloc_pixels;			/* Returns the number of alloc'ed
+					   color pixels */
+
+    Bool alloc_close_colors;    	/* Specify whether close colors should
+					   be allocated using XAllocColor
+					   or not */
+    int bitmap_format;			/* Specify the format of 1bit depth
+					   images: ZPixmap or XYBitmap */
+
+    /* Color functions */
+    XpmAllocColorFunc alloc_color;	/* Application color allocator */
+    XpmFreeColorsFunc free_colors;	/* Application color de-allocator */
+    void *color_closure;		/* Application private data to pass to
+					   alloc_color and free_colors */
+
+}      XpmAttributes;
+
+/* XpmAttributes value masks bits */
+#define XpmVisual	   (1L<<0)
+#define XpmColormap	   (1L<<1)
+#define XpmDepth	   (1L<<2)
+#define XpmSize		   (1L<<3)	/* width & height */
+#define XpmHotspot	   (1L<<4)	/* x_hotspot & y_hotspot */
+#define XpmCharsPerPixel   (1L<<5)
+#define XpmColorSymbols	   (1L<<6)
+#define XpmRgbFilename	   (1L<<7)
+/* 3.2 backward compatibility code */
+#define XpmInfos	   (1L<<8)
+#define XpmReturnInfos	   XpmInfos
+/* end 3.2 bc */
+#define XpmReturnPixels	   (1L<<9)
+#define XpmExtensions      (1L<<10)
+#define XpmReturnExtensions XpmExtensions
+
+#define XpmExactColors     (1L<<11)
+#define XpmCloseness	   (1L<<12)
+#define XpmRGBCloseness	   (1L<<13)
+#define XpmColorKey	   (1L<<14)
+
+#define XpmColorTable      (1L<<15)
+#define XpmReturnColorTable XpmColorTable
+
+#define XpmReturnAllocPixels (1L<<16)
+#define XpmAllocCloseColors (1L<<17)
+#define XpmBitmapFormat    (1L<<18)
+
+#define XpmAllocColor      (1L<<19)
+#define XpmFreeColors      (1L<<20)
+#define XpmColorClosure    (1L<<21)
+
+
+/* XpmInfo value masks bits */
+#define XpmComments        XpmInfos
+#define XpmReturnComments  XpmComments
+
+/* XpmAttributes mask_pixel value when there is no mask */
+#ifndef FOR_MSW
+#define XpmUndefPixel 0x80000000
+#else
+/* int is only 16 bit for MSW */
+#define XpmUndefPixel 0x8000
+#endif
+
+/*
+ * color keys for visual type, they must fit along with the number key of
+ * each related element in xpmColorKeys[] defined in XpmI.h
+ */
+#define XPM_MONO	2
+#define XPM_GREY4	3
+#define XPM_GRAY4	3
+#define XPM_GREY 	4
+#define XPM_GRAY 	4
+#define XPM_COLOR	5
+
+
+/* macros for forward declarations of functions with prototypes */
+#if NeedFunctionPrototypes
+#define FUNC(f, t, p) extern t f p
+#define LFUNC(f, t, p) static t f p
+#else
+#define FUNC(f, t, p) extern t f()
+#define LFUNC(f, t, p) static t f()
+#endif
+
+
+/*
+ * functions declarations
+ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
+
+#ifndef FOR_MSW
+    FUNC(XpmCreatePixmapFromData, int, (Display *display,
+					Drawable d,
+					char **data,
+					Pixmap *pixmap_return,
+					Pixmap *shapemask_return,
+					XpmAttributes *attributes));
+
+    FUNC(XpmCreateDataFromPixmap, int, (Display *display,
+					char ***data_return,
+					Pixmap pixmap,
+					Pixmap shapemask,
+					XpmAttributes *attributes));
+
+    FUNC(XpmReadFileToPixmap, int, (Display *display,
+				    Drawable d,
+				    char *filename,
+				    Pixmap *pixmap_return,
+				    Pixmap *shapemask_return,
+				    XpmAttributes *attributes));
+
+    FUNC(XpmWriteFileFromPixmap, int, (Display *display,
+				       char *filename,
+				       Pixmap pixmap,
+				       Pixmap shapemask,
+				       XpmAttributes *attributes));
+#endif  /* ndef FOR_MSW */
+
+    FUNC(XpmCreateImageFromData, int, (Display *display,
+				       char **data,
+				       XImage **image_return,
+				       XImage **shapemask_return,
+				       XpmAttributes *attributes));
+
+    FUNC(XpmCreateDataFromImage, int, (Display *display,
+				       char ***data_return,
+				       XImage *image,
+				       XImage *shapeimage,
+				       XpmAttributes *attributes));
+
+    FUNC(XpmReadFileToImage, int, (Display *display,
+				   char *filename,
+				   XImage **image_return,
+				   XImage **shapeimage_return,
+				   XpmAttributes *attributes));
+
+    FUNC(XpmWriteFileFromImage, int, (Display *display,
+				      char *filename,
+				      XImage *image,
+				      XImage *shapeimage,
+				      XpmAttributes *attributes));
+
+    FUNC(XpmCreateImageFromBuffer, int, (Display *display,
+					 char *buffer,
+					 XImage **image_return,
+					 XImage **shapemask_return,
+					 XpmAttributes *attributes));
+#ifndef FOR_MSW
+    FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
+					  Drawable d,
+					  char *buffer,
+					  Pixmap *pixmap_return,
+					  Pixmap *shapemask_return,
+					  XpmAttributes *attributes));
+
+    FUNC(XpmCreateBufferFromImage, int, (Display *display,
+					 char **buffer_return,
+					 XImage *image,
+					 XImage *shapeimage,
+					 XpmAttributes *attributes));
+
+    FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
+					  char **buffer_return,
+					  Pixmap pixmap,
+					  Pixmap shapemask,
+					  XpmAttributes *attributes));
+#endif  /* ndef FOR_MSW */
+    FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
+    FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
+
+    FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
+    FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
+
+    FUNC(XpmAttributesSize, int, ());
+    FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
+    FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
+				   int nextensions));
+
+    FUNC(XpmFreeXpmImage, void, (XpmImage *image));
+    FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
+    FUNC(XpmGetErrorString, char *, (int errcode));
+    FUNC(XpmLibraryVersion, int, ());
+
+    /* XpmImage functions */
+    FUNC(XpmReadFileToXpmImage, int, (char *filename,
+				      XpmImage *image,
+				      XpmInfo *info));
+
+    FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
+					 XpmImage *image,
+					 XpmInfo *info));
+#ifndef FOR_MSW
+    FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
+					    Drawable d,
+					    XpmImage *image,
+					    Pixmap *pixmap_return,
+					    Pixmap *shapemask_return,
+					    XpmAttributes *attributes));
+#endif
+    FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
+					   XpmImage *image,
+					   XImage **image_return,
+					   XImage **shapeimage_return,
+					   XpmAttributes *attributes));
+
+    FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
+					   XImage *image,
+					   XImage *shapeimage,
+					   XpmImage *xpmimage,
+					   XpmAttributes *attributes));
+#ifndef FOR_MSW
+    FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
+					    Pixmap pixmap,
+					    Pixmap shapemask,
+					    XpmImage *xpmimage,
+					    XpmAttributes *attributes));
+#endif
+    FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
+					  XpmImage *image,
+					  XpmInfo *info));
+
+    FUNC(XpmCreateXpmImageFromData, int, (char **data,
+					  XpmImage *image,
+					  XpmInfo *info));
+
+    FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
+					    XpmImage *image,
+					    XpmInfo *info));
+
+    FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
+					    XpmImage *image,
+					    XpmInfo *info));
+
+    FUNC(XpmFree, void, (void *ptr));
+
+#ifdef __cplusplus
+} /* for C++ V2.0 */
+#endif
+
+
+/* backward compatibility */
+
+/* for version 3.0c */
+#define XpmPixmapColorError  XpmColorError
+#define XpmPixmapSuccess     XpmSuccess
+#define XpmPixmapOpenFailed  XpmOpenFailed
+#define XpmPixmapFileInvalid XpmFileInvalid
+#define XpmPixmapNoMemory    XpmNoMemory
+#define XpmPixmapColorFailed XpmColorFailed
+
+#define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
+    XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
+#define XpmWritePixmapFile(dpy, file, pix, mask, att) \
+    XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
+
+/* for version 3.0b */
+#define PixmapColorError  XpmColorError
+#define PixmapSuccess     XpmSuccess
+#define PixmapOpenFailed  XpmOpenFailed
+#define PixmapFileInvalid XpmFileInvalid
+#define PixmapNoMemory    XpmNoMemory
+#define PixmapColorFailed XpmColorFailed
+
+#define ColorSymbol XpmColorSymbol
+
+#define XReadPixmapFile(dpy, d, file, pix, mask, att) \
+    XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
+#define XWritePixmapFile(dpy, file, pix, mask, att) \
+    XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
+#define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
+    XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
+#define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
+    XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
+
+#endif /* XPM_NUMBERS */
+#endif
+\end{chunk}
+
+\begin{chunk}{include/xshade.h1}
+/* from bookvol8 chunk include/xshade.h1 */
+extern int char_bitmap(void);
+extern int XInitShades(Display *  , int );
+extern int XChangeShade(Display *  , int );
+extern int XQueryShades(unsigned int * );
+extern void XShadeRectangle(Display *, Drawable, int, int, unsigned int, 
+                            unsigned int );
+extern void XShadeRectangles(Display *  , Drawable  , XRectangle *  , int );
+extern void XShadePolygon(Display *, Drawable, XPoint *, int, int, int );
+extern void XShadeArc(Display *, Drawable, int, int, unsigned int, 
+                      unsigned int, int, int );
+extern void XShadeArcs(Display *  , Drawable  , XArc *  , int );
+\end{chunk}
+
+\begin{chunk}{include/xspadfill.h1}
+/* from bookvol8 chunk include/xspadfill.h1 */
+extern int XInitSpadFill(Display *, int, Colormap *, int *, int *, 
+                         int *, int * );
+extern void XSpadFillSetArcMode(Display *, int );
+extern GC SpadFillGC(Display *, int, int, char * );
+extern unsigned long XSolidColor(int, int );
+extern void XSpadFillRectangle(Display *, Drawable, int, int, unsigned int, 
+                               unsigned int, int, int );
+extern void XSpadFillRectangles(Display *, Drawable, XRectangle *, int, 
+                                int, int );
+extern void XSpadFillPolygon(Display *, Drawable, XPoint *, int, int, 
+                             int, int, int );
+extern void XSpadFillArc(Display *, Drawable, int, int, unsigned int, 
+                         unsigned int, int, int, int, int );
+extern void XSpadFillArcs(Display *, Drawable, XArc *, int, int, int );
+\end{chunk}
+
 \chapter{viewman}
 \label{viewman}
 \index{viewman}
@@ -1756,11 +3633,11 @@ cflow --emacs -l -n -b -T --omit-arguments viewman.c
 \getchunk{include/view3d.h}
 \getchunk{include/viewcommand.h}
 
-#include "bsdsignal.h"
-#include "bsdsignal.h1"
-#include "com.h"
-#include "sockio-c.h1"
-#include "util.h1"
+\getchunk{include/bsdsignal.h}
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/com.h}
+\getchunk{include/sockio-c.h1}
+\getchunk{include/util.h1}
 
 \end{chunk}
 \subsection{extern references}
@@ -3027,7 +4904,7 @@ cflow --emacs -l -n -b -T --omit-arguments viewalone.c
 \getchunk{include/view2d.h}
 \getchunk{include/actions.h}
 \getchunk{include/viewcommand.h}
-#include "util.h1"
+\getchunk{include/util.h1}
 
 \end{chunk}
 \subsection{defines}
@@ -4128,14 +6005,13 @@ cflow --emacs -l -n -b -T --omit-arguments view2d.c
 \index{write.h}
 \index{xdefs.h}
 \begin{chunk}{view2d}
-#include "bsdsignal.h"
-#include "bsdsignal.h1"
-#include "hash.h"
-#include "hash.h1"
-#include "pixmap.h1"
-#include "util.h1"
-#include "xspadfill.h1"
-
+\getchunk{include/bsdsignal.h}
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/hash.h}
+\getchunk{include/hash.h1}
+\getchunk{include/pixmap.h1}
+\getchunk{include/util.h1}
+\getchunk{include/xspadfill.h1}
 \getchunk{include/actions.h}
 \getchunk{include/g.h}
 \getchunk{include/nox10.h}
@@ -8545,17 +10421,17 @@ cflow --emacs -l -n -b -T --omit-arguments view3d.c
 \index{write.h}
 \index{xdefs.h}
 \begin{chunk}{view3d}
-#include "bsdsignal.h"
-#include "bsdsignal.h1"
-#include "com.h"
-#include "hash.h"
-#include "hash.h1"
-#include "pixmap.h1"
+\getchunk{include/bsdsignal.h}
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/com.h}
+\getchunk{include/hash.h}
+\getchunk{include/hash.h1}
+\getchunk{include/pixmap.h1}
 \getchunk{include/view3d.h}
-#include "spadcolors.h1"
-#include "util.h1"
-#include "xshade.h1"
-#include "xspadfill.h1"
+\getchunk{include/spadcolors.h1}
+\getchunk{include/util.h1}
+\getchunk{include/xshade.h1}
+\getchunk{include/xspadfill.h1}
 
 \getchunk{include/actions.h}
 \getchunk{include/g.h}
@@ -21208,88 +23084,7086 @@ information macros or functions.
 \item (impl) XDeleteAssoc(Display * dsp,HashTable * table, Window w)
 \item XSelectInput(dsply, menu, KeyPressMask|ButtonPressMask|ExposureMask);
 \end{itemize}
-\chapter{Makefile}
-\begin{chunk}{*}
-BOOK=${SPD}/books/bookvol8.pamphlet
-WORK=${OBJ}/${SYS}/graph
-OUTLIB=	${MNT}/${SYS}/lib
-OUTBIN=	${MNT}/${SYS}/bin
-LIB=    ${OBJ}/${SYS}/lib
-TESTFILE=${MNT}/${SYS}/graph/parabola.view
-PS=	${MNT}/${SYS}/lib/graph
-LISP    =${OBJ}/${SYS}/bin/lisp
 
-PSFiles= ${PS}/colorpoly.ps ${PS}/colorwol.ps  ${PS}/draw.ps      \
-         ${PS}/drawIstr.ps  ${PS}/drawarc.ps   ${PS}/drawcolor.ps \
-         ${PS}/drawline.ps  ${PS}/drawlines.ps ${PS}/drawpoint.ps \
-         ${PS}/drawrect.ps  ${PS}/drawstr.ps   ${PS}/drwfilled.ps \
-         ${PS}/end.ps       ${PS}/fillarc.ps   ${PS}/fillpoly.ps  \
-         ${PS}/fillwol.ps   ${PS}/header.ps    ${PS}/setup.ps
+\chapter{libspad}
+These are library routines to support the graphics. Two of them,
+({\bf cfuns-c} and {\bf sockio-c}, get integrated into the lisp image.
+
+\section{bsdsignal.c}
+The system defines a set of signals that may be delivered to a
+process. Signal delivery resembles the occurrence of a hardware
+interrupt: the signal is normally blocked from further occurrence, the
+current process context is saved, and a new one is built. A process
+may specify a {\sl handler} to which a signal is delivered, or specify
+that a signal is to be {\sl ignored}. A process may also specify that
+a default action is to be taken by the system when a signal occurs. A
+signal may also be {\sl blocked}, in which case its delivery is
+postponed until it is {\sl unblocked}. The action to be taken on
+delivery is determined at the time of delivery. Normally, signal
+handlers execute on the current stack of the process. This may be
+changed, on a per-handler basis, so that signals are taken on a
+special {\sl signal stack}.
+
+Signal routines normally execute with the signal that caused their invocation 
+{\sl blocked}, but other signals may yet occur. A global {\sl signal mask} 
+defines the set of signals currently blocked from delivery to a process. 
+The signal mask for a process is initialized from that of its parent 
+(normally empty). It may be changed with a {\bf sigprocmask(2)} call, or 
+when a signal is delivered to the process.
+
+When a signal condition arises for a process, the signal is added to a
+set of signals pending for the process. If the signal is not currently
+{\sl blocked} by the process then it is delivered to the
+process. Signals may be delivered any time a process enters the
+operating system (e.g., during a system call, page fault or trap, or
+clock interrupt). If muliple signals are ready to be delivered at the
+same time, any signals that could be caused by traps are delivered
+first. Additional signals may be processed at the same time, with each
+appearing to interrupt the handlers for the previous signals before
+their first instructions. The set of pending signals is retuned by the
+{\bf sigpending(2)} system call. When a caught signal is delivered,
+the current state of the process is saved, a new signal mask is
+calculated (as described below), and the signal handler is
+invoked. The call to the handler is arranged so that if the signal
+handling routine returns normally the process will resume execution in
+the context from before the signal's delivery. If the process wishes
+to resume in a different context, then it must arrange to restore the
+previous context itself.
+
+When a signal is delivered to a proces a new signal mask is installed
+for the duration of the process's signal handler (or until a {\bf
+sigprocmask(2)} system call is made). This mask is formed by taking
+the union of the current signal mask set, the signal to be delivered,
+and the signal mask associated with the handler to be invoked.
+
+The {\bf sigaction()} system call assigns an action for a signal
+specified by {\sl sig}. If {\sl act} is non-zero, it specifies an
+action (SIG\_DFL, SIG\_IGN, or a handler routine) and mask to be used
+when delivering the specified signal.  If {\sl oact} is non-zero, the
+previous handling information for the signal is returned to the user.
+
+Once a signal handler is installed, it normally remains installed
+until another {\bf sigaction()} system call is made, or an {\sl
+execve(2)} is performed. A signal-specific default action may be reset
+by setting {\sl sa\_handler} to SIG\_DFL. The defaults are process
+termination, possibly with core dump; no action; stopping the process;
+or continuing the process. See the signal list below for each signal's
+default action. If {\sl sa\_handler} is SIG\_DFL, the default action
+for the signal is to discard the signal, and if a signal is pending,
+the pending signal is discarded even if the signal is masked. If {\sl
+sa\_handler} is set to SIG\_IGN current and pending instances of the
+signal are ignored and discarded.
+
+Options may be specified by setting {\sl sa\_flags}. 
+The meaning of the various bits is as follows:
 
-CFLAGS  = ${CCF} -I${SRC}/include
-LDFLAGS = ${LDF} -lX11 -lm
+\begin{itemize}
+\item {\bf SA\_NOCLDSTOP} If this bit is set when installing a catching 
+function for the SIGCHLD signal, the SIGCHLD signal will  be generated 
+only when a child process exits, not when a child process stops.
+\item {\bf SA\_NOCLDWAIT}
+If this bit is set when calling {\sl sigaction()} for the
+SIGCHLD signal, the system will not create zombie processes
+when children of the calling process exit. If the calling
+process subsequently issues a {\sl wait()} (or equivalent),
+it blocks until all of the calling process's child processes
+terminate, and then returns a value of -1 with errno set to
+ECHILD.
+\item {\bf SA\_ONSTACK} If this bit is set, the system will deliver the 
+signal to the process on a {\sl signal stack}, specified with
+{\bf sigaltstack(2)}.
+\item {\bf SA\_NODEFER} If this bit is set, further occurrences of the 
+delivered signal are not masked during the execution of the handler.
+\item {\bf SA\_RESETHAND} If this bit is set, the handler is reset 
+to SIG\_DFL at the moment the signal is delivered.
+\item {\bf SA\_RESTART} See the paragraph below
+\item {SA\_SIGINFO} If this bit is set, the handler function is assumed to 
+be pointed to by the sa\_sigaction member of struct sigaction
+and should match the prototype shown above or as below in
+EXAMPLES. This bit should not be set when assigning SIG\_DFL
+or SIG\_IGN
+\end{itemize}
+If a signal is caught during the system calls listed below, the call may be 
+forced to terminate with the error EINTR, the call may return with a data 
+transfer shorter than requested, or the call may be restarted. Restart of 
+pending calls is requested by setting the SA\_RESTART bit in {\sl sa\_flags}. 
+The affected system calls include {\bf open(2)}, {\bf read(2)}, {\bf write(2)}, 
+{\bf sendto(2)}, {\bf recvfrom(2)}, {\bf sendmsg(2)} and {\bf recvmsg(2)} 
+on a communications channel or a slow device (such as a terminal, but not a 
+regular file) and during a {\bf wait(2)} or {\bf ioctl(2)}. However, calls 
+that have already committed are not restarted, but instead return a partial 
+success (for example, a short read count).
+
+After a {\bf fork(2)} or {\bf vfork(2)} all signals, the signal mask, the 
+signal stack, and the restart/interrupt flags are inherited by the child.
+
+The {\bf execve(2)} system call reinstates the default action for all signals 
+which were caught and resets all signals to be caught on the user stack. 
+Ignored signals remain ignored; the signal mask remains the same; signals 
+that restart pending system calls continue to do so.
+
+The following is a list of all signals with names in the include file
+{\sl $<$signal.h$>$}:
+
+\begin{tabular}{lll}
+{\bf NAME} & {\bf Default Action} & Description\\
+SIGHUP     & terminate process    & terminal line hangup\\
+SIGINT     & terminate process    & interrupt program\\
+SIGQUIT    & create core image    & quit program\\
+SIGILL     & create core image    & illegal instruction\\
+SIGTRAP    & create core image    & trace trap\\
+SIGABRT    & create core image    & {\bf abort(3)} call (formerly SIGIOT)\\
+SIGEMT     & create core image    & emulate instruction executed\\
+SIGFPE     & create core image    & floating-point exception\\
+SIGKILL    & terminate process    & kill program\\
+SIGBUS     & create core image    & bus error\\
+SIGSEGV    & create core image    & segmentation violation\\
+SIGSYS     & create core image    & non-existent system call invoked\\
+SIGPIPE    & terminate process    & write on a pipe with no reader\\
+SIGALRM    & terminate process    & real-time timer expired\\
+SIGTERM    & terminate process    & software termination signal\\
+SIGURG     & discard signal       & urgent condition present on socket\\
+SIGSTOP    & stop process         & stop (cannot be caught or ignored)\\
+SIGSTP     & stop process         & keyboard generated stop signal\\
+SIGCONT    & discard signal       & continue after stop\\
+SIGCHLD    & discard signal       & child status has changed\\
+SIGTTIN    & stop process         & background read attempted from \\
+           &                      & control terminal\\
+SIGTTOU    & stop process         & background write attempted from\\
+           &                      & control terminal\\
+SIGIO      & discard signal       & I/O possible on descriptor fcntl(2)\\
+SIGXCPU    & terminate process    & cpu limit exceeded setrlimit(2)\\
+SIGXFSZ    & terminate process    & filesize exceeded setrlimit(2)\\
+SIGVTALRM  & terminate process    & virtual time alarm setitimer(2)\\
+SIGPROF    & terminate process    & profiling timer alarm setitimer(2)\\
+SIGWINCH   & discard signal       & Window size change\\
+SIGINFO    & discard signal       & status request from keyboard\\
+SIGUSR1    & terminate process    & User defined signal 1\\
+SIGUSR2    & terminate process    & User defined signal 2
+\end{tabular}
 
-VLIBS=${LIB}/sockio-c.o ${LIB}/util.o  ${LIB}/bsdsignal.o 
+The {\sl sigaction()} function returns the value 0 if successful; otherwise 
+the value -1 is returned and the global variable {\sl errno} is set to indicate 
+the error.
 
-LIBS= ${VLIBS}      ${LIB}/pixmap.o    ${LIB}/halloc.o  ${LIB}/spadcolors.o \
-      ${LIB}/hash.o ${LIB}/xspadfill.o ${LIB}/xdither.o ${LIB}/xshade.o   
+Signal handlers should have either the ANSI C prototype:
+\begin{verbatim}
+  void handler(int);
+\end{verbatim}
+or the POSIX SA\_SIGINFO prototype:
+\begin{verbatim}
+  void handler(int, siginfo_t *info, ucontext_t *uap);
+\end{verbatim}
 
-all: ${LIBS} dirs ${OUTLIB}/viewman ${OUTLIB}/view2d ${OUTLIB}/view3d \
-     ${OUTBIN}/viewalone ${TESTFILE}/data ${PSFiles}
-	@ echo 0 finished ${BOOK}
+The handler function should match the SA\_SIGINFO prototype 
+when the SA\_SIGINFO 
+bit is set in flags. It then should be pointed to by the sa\_sigaction member 
+of struct sigaction. Note that you should not assign SIG\_DFL or SIG\_IGN this way.
+
+If the SA\_SIGINFO flag is not set, the handler function should match either 
+the ANSI C or traditional BSD prototype and be pointed to by the sa\_handler 
+member of struct sigaction. In practice, FreeBSD always sends the three 
+arguments of the latter and since the ANSI C prototype is a subset, both 
+will work. The sa\_handler member declaration in FreeBSD include files is 
+that of ANSI C (as required by POSIX), so a function pointer of a BSD-style 
+function needs to be casted to compile without warning. The traditional BSD 
+style is not portable and since its capabilities are a full subset of a 
+SA\_SIGNFO handler its use is deprecated.
+
+The {\sl sig} argument is the signal number, one of the SIG\ldots values from 
+{\sl <signal.h>}.
+
+The {\sl code} argument of the BSD-style handler and the si\_code member of the
+info argument to a SA\_SIGINFO handler contain a numeric code explaining the
+cause of the signal, usually on of the SI\_\ldots values from {\sl <sys/signal.h>}
+or codes specific to a signal, i.e. one of the FPE\_\ldots values for SIGFPE.
+
+The {\sl uap} argument to a POSIX SA\_SIGINFO handler points to an instance of 
+ucontext\_t.
+
+The {\bf sigaction()} system call will fail and no new signal handler will be
+installed if one of the following occurs:
+\begin{itemize}
+\item {\bf [EFAULT]} Either {\sl act} or {\sl oact} points to memory that 
+is not a valid part of the process address space
+\item {\bf [EINVAL]} The {\sl sig} argument is not a valid signal number
+\item {\bf [EINVAL]} An attempt is made to ignore or supply a handler 
+for SIGKILL or SIGSTOP
+\end{itemize}
+
+\begin{chunk}{bsdsignal.c}
+
+\getchunk{include/bsdsignal.h}
+
+\end{chunk}
+
+The MACOSX platform is broken because no matter what you do it seems to
+include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
+systems these files include themselves which causes an infinite regression
+of includes that fails. GCC gracefully steps over that problem but the
+build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
+of files are badly broken with respect to the [[/usr/include]] versions.
+
+\begin{chunk}{bsdsignal.c}
+#if defined(MACOSXplatform)
+#include "/usr/include/signal.h"
+#else
+#include <signal.h> 
+#endif
+
+\getchunk{include/bsdsignal.h1}
+
+
+SignalHandlerFunc
+bsdSignal(int sig,SignalHandlerFunc action,int restartSystemCall)
+{
+#ifndef MSYSplatform
+
+  struct sigaction in,out;
+  in.sa_handler = action;
+  /* handler is reinstalled - calls are restarted if restartSystemCall */
+\end{chunk}
+
+We needed to change [[SIGCLD]] to [[SIGCHLD]] for the [[MAC OSX]] platform
+and we need to create a new platform variable. This change is made to 
+propogate that platform variable.
+
+\begin{chunk}{bsdsignal.c}
+#if defined(LINUXplatform)
+ if(restartSystemCall) in.sa_flags = SA_RESTART;
+  else in.sa_flags = 0;
+#elif defined (ALPHAplatform)
+ if(restartSystemCall) in.sa_flags = SA_RESTART;
+  else in.sa_flags = 0;
+#elif defined(RIOSplatform) 
+ if(restartSystemCall) in.sa_flags = SA_RESTART;
+  else in.sa_flags = 0;
+#elif defined(SUN4OS5platform) 
+ if(restartSystemCall) in.sa_flags = SA_RESTART;
+  else in.sa_flags = 0;
+#elif defined(SGIplatform) 
+ if(restartSystemCall) in.sa_flags = SA_RESTART;
+  else in.sa_flags = 0;
+#elif defined(HP10platform) 
+ if(restartSystemCall) in.sa_flags = SA_RESTART;
+  else in.sa_flags = 0;
+#elif defined(MACOSXplatform) 
+ if(restartSystemCall) in.sa_flags = SA_RESTART;
+  else in.sa_flags = 0;
+#elif defined(BSDplatform) 
+ if(restartSystemCall) in.sa_flags = SA_RESTART;
+  else in.sa_flags = 0;
+#elif defined(SUNplatform)
+  if (restartSystemCall) in.sa_flags = 0;
+  else in.sa_flags = SA_INTERRUPT;
+#elif defined(HP9platform)
+  in.sa_flags = 0; 
+#else
+  in.sa_flags = 0; 
+#endif
+  
+  return (sigaction(sig, &in, &out) ? (SignalHandlerFunc) -1 : 
+	  (SignalHandlerFunc) out.sa_handler);
+#else /* MSYSplatform */
+  return (SignalHandlerFunc) -1;
+#endif /* MSYSplatform */
+
+}
+
+\end{chunk}
+
+\section{cfuns-c.c}
+\begin{chunk}{cfuns-c.c}
+
+#include <stdio.h>
+\end{chunk}
+
+The MACOSX platform is broken because no matter what you do it seems to
+include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
+systems these files include themselves which causes an infinite regression
+of includes that fails. GCC gracefully steps over that problem but the
+build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
+of files are badly broken with respect to the [[/usr/include]] versions.
+
+\begin{chunk}{cfuns-c.c}
+
+#if defined(MACOSXplatform)
+#include "/usr/include/unistd.h"
+#else
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+#include <string.h>
+#if !defined(BSDplatform)
+#include <malloc.h>
+#endif
+#include <sys/types.h>
+#include <sys/stat.h>
+
+\getchunk{include/cfuns-c.h1}
+
+\end{chunk}
+The {\tt addtopath} function is used in {\tt interp/i-toplev.boot} 
+as part of the {\tt start} function.
+\begin{chunk}{cfuns-c.c}
+
+int addtopath(char *dir) {
+    char *path, *newpath;
+    path = getenv("PATH");
+    if (path == NULL)
+        return -1;
+    newpath = (char *) 
+       malloc(1 + strlen(path) + strlen(dir) + strlen("PATH=:"));
+    if (newpath == NULL)
+        return -1;
+    sprintf(newpath, "PATH=%s:%s", path, dir);
+    return putenv(newpath);
+}
+
+\end{chunk}
+
+Test whether the path is the name of a directory.  
+Returns 1 if so, 0 if not, -1 if it doesn't exist.
+
+\begin{chunk}{cfuns-c.c}
+int directoryp(char *path) {
+    struct stat buf;
+    int code = stat(path, &buf);
+    return(code == -1 ? -1 : S_ISDIR(buf.st_mode));
+}
+
+\end{chunk}
+
+This function is only used internal to this file.
+Axiom lisp code does not depend on it.
+
+\begin{chunk}{cfuns-c.c}
+int make_path_from_file(char *s, char *t) {
+    char *pos = "";
+    char *c;
+    /** simply copies the path name from t into s **/
+    for (c = t + strlen(t); c != s; c--)
+        if (*c == '/') {
+            pos = c;
+            break;
+        }
+    /** Check to see if the path was actually present **/
+    if (c == t) {               /** No Path, so return the pwd **/
+        return (-1);
+    }
+    /** now just do the copying **/
+    strncpy(s, t, pos - t);
+    return 1;
+}
+
+\end{chunk}
+
+This function is used in {\tt interp/fname.lisp} to support the
+{\tt myWriteable?} function, which is called by {\tt fnameWriteable?}.
+It supports a test called {\tt writeable?} in {\tt algebra/fname.spad}. 
+
+\begin{chunk}{cfuns-c.c}
+int writeablep(char *path) {
+    struct stat buf;
+    char newpath[100];
+    int code;
+    code = stat(path, &buf);
+    if (code == -1) {
+        /** The file does not exist, so check to see
+                 if the directory is writable                  *****/
+        if (make_path_from_file(newpath, path) == -1 ||
+            stat(newpath, &buf) == -1) {
+            return (-1);
+        }
+        else {
+            if (geteuid() == buf.st_uid) {
+                return (2 * ((buf.st_mode & S_IWUSR) != 0));
+            }
+            else if (getegid() == buf.st_gid) {
+                return (2 * ((buf.st_mode & S_IWGRP) != 0));
+            }
+            else {
+                return (2 * ((buf.st_mode & S_IWOTH) != 0));
+            }
+        }
+    }
+    else if (geteuid() == buf.st_uid) {
+        return ((buf.st_mode & S_IWUSR) != 0);
+    }
+    else if (getegid() == buf.st_gid) {
+        return ((buf.st_mode & S_IWGRP) != 0);
+    }
+    else {
+        return ((buf.st_mode & S_IWOTH) != 0);
+    }
+}
+
+\end{chunk}
+
+This function does not appear to be used anywhere
+\begin{verbatim}
+int CLgetpid(void) {
+     return getpid();
+}
+\end{verbatim}
+
+This function does not appear to be used in axiom. It has been
+replaced by native lisp code in {\tt fname.lisp} in the function
+{\tt file-readablep}.
+\begin{verbatim}
+int readablep(char *path) {
+    struct stat buf;
+    int code;
+    code = stat(path, &buf);
+    if (code == -1) {
+        return (-1);
+    }
+    else if (geteuid() == buf.st_uid) {
+        return ((buf.st_mode & S_IREAD) != 0);
+    }
+    else if (getegid() == buf.st_gid) {
+        return ((buf.st_mode & S_IRGRP) != 0);
+    }
+    else {
+        return ((buf.st_mode & S_IROTH) != 0);
+    }
+}
+\end{verbatim}
+
+This function does not appear to be used anywhere.
+\begin{verbatim}
+long findString(char *file, char *string) {
+    int nstring, charpos;
+    FILE *fn;
+    char buffer[1024];
+    if ((fn = fopen(file, "r")) == NULL)
+        return -1;
+    for (charpos = 0, nstring = strlen(string);
+         fgets(buffer, sizeof buffer, fn) != NULL;
+         charpos += strlen(buffer)
+        )
+        if (!strncmp(buffer, string, nstring))
+            return charpos;
+    return -1;
+}
+\end{verbatim}
+
+This function does not appear to be used anywhere.
+\begin{verbatim}
+int copyEnvValue(char *varName, char *buffer) {
+    char *s;
+    s = getenv(varName);
+    if (s == NULL)
+        return 0;
+    strcpy(buffer, s);
+    return strlen(s);
+}
+
+\end{verbatim}
+
+\section{cursor.c}
+\begin{chunk}{cursor.c}
+
+#include <stdlib.h>
+
+\getchunk{include/cursor.h1}
+
+/*
+ * This routine changes the shape of the cursor. it is a modified version of
+ * a program by SMWatt, called cursor.c. JMW 6/22/89
+ */
+
+/* this stuff can only be done on AIX <AND> the right terminal (aixterm,hft) */
+#if (defined(RIOSplatform) ||  defined(RTplatform)) && !defined(_AIX41)
+\getchunk{include/edible.h}
+/* the HFT stuff requires ioctl's and termio's */
+#include <termio.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/hft.h>
+
+int
+Cursor_shape(int shape)
+{
+    int hftfd;
+    char hftpath[16], s[100];
+    int chno;
+    int i;
+    struct termio oldterm, newterm;
+    struct hftgetid hftgid;
+    char *termVal;
+
+    termVal = (char *) getenv("TERM");
+    if (strcmp("hft", termVal) && strncmp("aixterm", termVal, 7))
+        return;
+
+
+
+    /* determine the desired shape */
+    if (shape < 0 || shape > 5) {
+        fprintf(stderr, "%d - Invalid cursor number\n");
+        return (-1);
+    }
+    /* change the shape */
+    s[0] = 033;                 /* hf_intro.hf_esc      */
+    s[1] = '[';                 /* hf_intro.hf_lbr      */
+    s[2] = 'x';                 /* hf_intro.hf_ex       */
+    s[3] = 0;                   /* hf_intro.hf_len[0]   */
+    s[4] = 0;                   /* hf_intro.hf_len[1]   */
+    s[5] = 0;                   /* hf_intro.hf_len[2]   */
+    s[6] = 10;                  /* hf_intro.hf_len[3]   */
+    s[7] = 2;                   /* hf_intro.hf_typehi   */
+    s[8] = 8;                   /* hf_intro.hf_typelo   */
+    s[9] = 2;                   /* hf_sublen            */
+    s[10] = 0;                  /* hf_subtype           */
+    s[11] = 0;                  /* hf_rsvd              */
+    s[12] = shape;              /* hf_shape     */
+
+    if (ioctl(0, HFTGETID, &hftgid) < 0) {
+        /* perror("ioctl: HFTGETID"); */
+        chno = -1;
+    }
+    else
+        chno = hftgid.hf_chan;
+    if (chno == -1) {
+        /** try being moronic and just writing what I want to
+                                     standard output             ****/
+
+        if (((ioctl(2, TCGETA, &oldterm)) == -1) ||
+            ((ioctl(2, TCGETA, &newterm)) == -1)) {
+            perror("Getting termio");
+            exit(0);
+        }
+        newterm.c_oflag = newterm.c_lflag = newterm.c_iflag = 0;
+        newterm.c_cc[0] = -1;
+        for (i = 1; i <= 5; i++)
+            newterm.c_cc[i] = 0;
+        if ((ioctl(2, TCSETAF, &newterm)) == -1) {
+            perror("Setting to raw mode");
+            exit(0);
+        }
+        write(2, s, 13);
+        read(0, s, 1024);
+        if ((ioctl(2, TCSETAF, &oldterm)) == -1) {
+            perror("Resetting terminal");
+            exit(0);
+        }
+    }
+    else {
+        /* open the currently active virtual terminal on the hft */
+        sprintf(hftpath, "/dev/hft/%d", chno);
+        if ((hftfd = open(hftpath, O_RDWR)) == -1) {
+            perror("Could not open hft channel\n");
+            exit(0);
+        }
+        write(hftfd, s, 13);
+    }
+}
+#else
+
+int
+Cursor_shape(int shape)
+{
+  return shape;
+}
+#endif
+
+\end{chunk}
+
+\section{edin.c}
+\begin{chunk}{edin.c}
+
+/* #define debug 1 */
+
+#include <stdlib.h>
+\end{chunk}
+
+The MACOSX platform is broken because no matter what you do it seems to
+include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
+systems these files include themselves which causes an infinite regression
+of includes that fails. GCC gracefully steps over that problem but the
+build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
+of files are badly broken with respect to the [[/usr/include]] versions.
+
+\begin{chunk}{edin.c}
+#if defined(MACOSXplatform)
+#include "/usr/include/unistd.h"
+#else
+#include <unistd.h>
+#endif
+#include <string.h>
+#include <stdio.h>
+#include <sys/types.h>
+
+\getchunk{include/edible.h}
+
+#define HFT 0
+#define SUN 1
+#define DEC 2
+#define control_to_alpha(x)   (x + ('A' - 0x01))
+#define alpha_to_control(x)   (x - ('A' - 0x01))
+
+int termId;
+QueStruct *ring = NULL;
+QueStruct *current = NULL;
+int ring_size = 0;
+int MAXRING = 64;
+int prev_check = 10;
+int curr_pntr;
+int num_pntr;
+int num_proc;
+int had_tab;
+int had_tab_last;
+extern char buff[1024];            /* Buffers for collecting input and  */
+extern int buff_flag[1024];  /* flags for whether buff chars
+				      are printing or non-printing  */
+int buff_pntr;                     /* present length of  buff */
+
+\getchunk{include/edin.h1}
+\getchunk{include/prt.h1}
+\getchunk{include/wct.h1}
+\getchunk{include/cursor.h1}
+\getchunk{include/fnct-key.h1}
+
+void
+init_reader(void)
+{
+  char *termVal;
+  
+  buff[50] = '\0';            /** initialize some stuff  ***/
+  init_flag(buff_flag, MAXLINE);
+  buff_pntr = curr_pntr = 0;
+  
+  had_tab = 0;
+  had_tab_last = 0;
+  termVal = (char *) getenv("TERM");
+  if (!strcmp("sun", termVal))
+    termId = SUN;
+  else if (!strcmp("xterm", termVal) || !strncmp("vt", termVal, 2))
+    termId = DEC;
+  else if (!strcmp("hft", termVal) || !strncmp("aixterm", termVal, 7))
+    termId = HFT;
+}
+
+
+void 
+do_reading(void)
+{
+  int ttt_read;
+  int done_completely;
+  
+  done_completely = 0;
+  num_proc = 0;
+  while (num_proc < num_read) {
+    if(in_buff[num_proc]== _ERASE) {
+      back_over_current_char();
+      num_proc++;
+    }
+    else {
+      switch (in_buff[num_proc]) {
+	/* lets start checking for different types of chars */
+      case _EOLN:
+      case _CR:
+	/* If I have read a complete line, so send it to the child */
+	send_line_to_child();
+	if (!PTY)
+	  myputchar('\n');
+	break;
+	
+	/*
+	 * Use 0x7f as delete
+	 */
+      case _DEL:
+	/* Had a delete key */
+	delete_current_char();
+	break;
+	
+      case _CNTRL_W:
+	move_back_word();
+	num_proc++;
+	break;
+      case _TAB:
+	had_tab = 1;
+	/* command completion stuff */
+	num_proc++;
+	if (had_tab_last)
+	  rescan_wct();
+	else
+	  find_wct();
+	break;
+      case _BELL:
+	insert_buff_nonprinting(1);
+	putchar(_BELL);
+	fflush(stdout);
+	break;
+      case _ESC:
+	
+	/*
+	 * get 2 characters more
+	 */
+	while (!(num_read - num_proc > 2)) {
+	  ttt_read = read(0, 
+			  in_buff + num_read, 
+			  2 - (num_read - num_proc) + 1);
+	  if (ttt_read > 0)
+	    num_read = num_read + ttt_read;
+	}
+	if ((in_buff[num_proc + 1] == _LBRACK)) {
+
+	  /* ESC [  */
+	  
+	  switch (in_buff[num_proc + 2]) {
+	    /*  look for arrows */
+	  case _A:
+	    /* up arrow */
+	    
+	    /*
+	     * The first thing I plan to do is get rid of the present
+	     * input **
+	     */
+	    prev_buff();
+	    curr_pntr = buff_pntr;
+	    num_proc = num_proc + 3;
+	    break;
+	  case _B:
+	    /* down arrow */
+	    next_buff();
+	    curr_pntr = buff_pntr;
+	    num_proc = num_proc + 3;
+	    break;
+	  case _C:
+	    /* right arrow */
+	    move_ahead();
+	    num_proc = num_proc + 3;
+	    break;
+	  case _D:
+	    /* left arrow */
+	    move_back();
+	    num_proc = num_proc + 3;
+	    break;
+	    
+	    /*
+	     * Use ^[[P as delete
+	     */
+	  case _P:
+	    /*** Had a delete key      ****/
+	    delete_current_char();
+	    break;
+	  case _H:
+	  case 0:
+	    move_home();
+	    num_proc += 3;
+	    break;
+	  case _M:
+	  case _Z:
+	    insert_buff_nonprinting(3);
+	    done_completely = 1;
+	    num_proc += 3;
+	    break;
+	  case _x:
+	    num_proc = num_read;
+	    break;
+	  case _1:
+	  case _2:
+	  case _0:
+	    
+	    /*
+	     * I have had a possible function key hit, look for the
+	     * ones I want. check for ESC ] x ~
+	     */
+	    while (!(num_read - num_proc > 3)) {
+	      ttt_read = read(0, 
+			      in_buff + num_read, 
+			      3 - (num_read - num_proc) + 1);
+	      if (ttt_read > 0)
+		num_read = num_read + ttt_read;
+	    }
+	    if (in_buff[num_proc + 3] == _twiddle) {
+	      
+	      /*
+	       * treat ESC ] x ~
+	       */
+	      switch (in_buff[num_proc + 2]) {
+	      case _2:
+		flip(INS_MODE);
+		if (INS_MODE)
+		  Cursor_shape(5);
+		else
+		  Cursor_shape(2);
+		reprint(curr_pntr);
+		num_proc += 4;
+		break;
+	      default:
+		insert_buff_nonprinting(1);
+		break;
+	      }
+	      break;
+	    }
+	    /* check for ESC ] x y ~ */
+	    while (!(num_read - num_proc > 4)) {
+	      ttt_read = read(0, 
+			      in_buff + num_read, 
+			      4 - (num_read - num_proc) + 1);
+	      if (ttt_read > 0)
+		num_read = num_read + ttt_read;
+	    }
+	    if (in_buff[num_proc + 4] == _twiddle) {
+	      
+	      /*
+	       * treat ESC ] x y ~
+	       */
+	      insert_buff_nonprinting(1);
+	      break;
+	    }
+	    
+	    /* check for ESC ] x y z [q|z] */
+	    
+	    while (!(num_read - num_proc > 5)) {
+	      ttt_read = read(0, 
+			      in_buff + num_read, 
+			      5 - (num_read - num_proc) + 1);
+	      if (ttt_read > 0)
+		num_read = num_read + ttt_read;
+	    }
+	    if (insert_toggle(&in_buff[num_proc + 3])) {
+	      flip(INS_MODE);
+	      if (INS_MODE)
+		Cursor_shape(5);
+	      else
+		Cursor_shape(2);
+	      reprint(curr_pntr);
+	      num_proc = num_proc + 6;
+	      break;
+	    }
+	    else if (cntrl_end(&in_buff[num_proc + 3])) {
+	      num_proc = num_proc + 6;
+	      delete_to_end_of_line();
+	      break;
+	    }
+	    else if (back_word(&in_buff[num_proc + 3])) {
+	      move_back_word();
+	      num_proc += 6;
+	      break;
+	    }
+	    else if (fore_word(&in_buff[num_proc + 3])) {
+	      move_fore_word();
+	      num_proc += 6;
+	      break;
+	    }
+	    else if (end_key(&in_buff[num_proc + 3])) {
+	      move_end();
+	      num_proc += 6;
+	      break;
+	    }
+	    switch (in_buff[num_proc + 5]) {
+	    case _q:
+	      
+	      /*
+	       * IBM function keys
+	       */
+	      {
+		char num[3];
+		int key;
+		
+		num[0] = in_buff[num_proc + 3];
+		num[1] = in_buff[num_proc + 4];
+		num[2] = '\0';
+		key = atoi(num);
+		if (key > 0 && key < 13) {
+		  if (function_key[key].str != NULL) {
+		    handle_function_key(key, contNum);
+		    done_completely = 1;
+		  }
+		  else {
+		    insert_buff_nonprinting(6);
+		    done_completely = 1;
+		  }
+		}
+		else {
+		  insert_buff_nonprinting(6);
+		  done_completely = 1;
+		}
+		break;
+	      }
+	    case _z:
+	      
+	      /*
+	       * Sun function keys
+	       */
+	      {
+		char num[3];
+		int key;
+		
+		num[0] = in_buff[num_proc + 3];
+		num[1] = in_buff[num_proc + 4];
+		num[2] = '\0';
+		key = atoi(num) - 23;
+		if (key > 0 && key < 13) {
+		  if (function_key[key].str != NULL) {
+		    handle_function_key(key, contNum);
+		    done_completely = 1;
+		  }
+		  else {
+		    insert_buff_nonprinting(6);
+		    done_completely = 1;
+		  }
+		}
+		else if (atoi(num) == 14) {
+		  move_home();
+		  num_proc += 6;
+		  done_completely = 1;
+		}
+		else if (atoi(num) == 20) {
+		  move_end();
+		  num_proc += 6;
+		  done_completely = 1;
+		}
+		else if (atoi(num) == 47) {
+		  flip(INS_MODE);
+		  if (INS_MODE)
+		    Cursor_shape(5);
+		  else
+		    Cursor_shape(2);
+		  reprint(curr_pntr);
+		  num_proc = num_proc + 6;
+		  done_completely = 1;
+		}
+		else {
+		  insert_buff_nonprinting(6);
+		  done_completely = 1;
+		}
+		
+		break;
+	      }
+	      
+	    default:
+	      insert_buff_nonprinting(1);
+	      break;
+	    }
+	  default:
+	    if (!done_completely)
+	      insert_buff_nonprinting(1);
+	    break;
+	  }
+	}                   /* if */
+	else {              /* ESC w/o [ */
+	  insert_buff_nonprinting(1);
+	}
+	break;
+	
+      case _BKSPC:
+	back_over_current_char();
+	num_proc++;
+	break;
+      default:
+	if (in_buff[num_proc] == _KILL) {
+	  delete_line();
+	  num_proc++;
+	}
+	else {
+	  if ((in_buff[num_proc] == _INTR) || (in_buff[num_proc] == _QUIT)) {
+	    write(contNum, &in_buff[num_proc], num_read - num_proc);
+	    if (!PTY)
+	      write(contNum, "\n", 1);
+	    num_proc++;
+	  }
+	  else {
+	    if (in_buff[num_proc] == _EOF) {
+	      insert_buff_nonprinting(1);
+	      if (!PTY)
+		write(contNum, "\n", 1);
+	      
+	      /*comment out this bit
+		if (!buff_pntr) {
+		write(contNum, &in_buff[num_proc], 1); 
+		if (!PTY)
+		write(contNum, "\n", 1);
+		}
+		else {
+		write(contNum, buff, buff_pntr);
+		}
+		*/
+	      num_proc++;
+	    }
+	    else {
+	      if (in_buff[num_proc] == _EOL) {
+		send_line_to_child();
+		if (!PTY)
+		  write(contNum, "\n", 1);
+	      }
+	      else {
+		if (in_buff[num_proc] == _ERASE) {
+		  back_over_current_char();
+		  num_proc++;
+		}
+		else {
+		  if (control_char(in_buff[num_proc]))
+		    insert_buff_nonprinting(1);
+		  else
+		    insert_buff_printing(1);
+		}
+	      }
+	    }
+	  }
+	}                   /* close the default case */
+	break;
+      }                       /* switch */
+    } /*else*/
+    if (had_tab) {
+      had_tab_last = 1;
+      had_tab = 0;
+    }
+    else
+      had_tab_last = 0;
+    
+  }                           /* while */
+}
+
+
+
+void 
+send_line_to_child(void )
+{
+  static char converted_buffer[MAXLINE];
+  int converted_num;
+  
+  /*  Takes care of sending a line to the child, and resetting the
+      buffer for new input                                  */
+  
+  back_it_up(curr_pntr);
+  
+  /* start by putting the line into the command line ring ***/
+  if (buff_pntr)
+    insert_queue();
+
+  /* finish the line and send it to the child **/
+  buff[buff_pntr] = in_buff[num_proc];
+  buff_flag[buff_pntr++] = 1;
+  buff[buff_pntr] = '\0';
+  buff_flag[buff_pntr] = -1;
+  
+  /*
+   * Instead of actually writing the Line, I have to  substitute in the
+   * actual characters recieved
+   */
+  converted_num =
+    convert_buffer(converted_buffer, buff, buff_flag, buff_pntr);
+  write(contNum, converted_buffer, converted_num);
+  
+  /** reinitialize the buffer  ***/
+  init_flag(buff_flag, buff_pntr);
+  init_buff(buff, buff_pntr);
+  /**  reinitialize my buffer pointers **/
+  buff_pntr = curr_pntr = 0;
+  
+  /** reset the ring pointer **/
+  current = NULL;
+  num_proc++;
+  return;
+}
+
+int
+convert_buffer(char *target, char *source,int * source_flag, int num)
+{
+  int i, j;
+  
+  /*
+   * Until I get something wierd, just keep copying
+   */
+  for (i = 0, j = 0; i < num; i++, j++) {
+    switch (source[i]) {
+    case _CARROT:
+      if (source_flag[i] == 1) {
+	target[j] = source[i];
+      }
+      else {
+	if (source[i + 1] == _LBRACK) {
+	  target[j] = _ESC;
+	  i++;
+	}
+	else if (source[i + 1] >= 'A' && source[i + 1] <= 'Z') {
+	  target[j] = alpha_to_control(source[i + 1]);
+	  i++;
+	}
+      }
+      break;
+    case '?':
+    default:
+      target[j] = source[i];
+    }
+  }
+  return j;
+}
+
+
+void
+insert_buff_printing(int amount)
+{
+  int count;
+  
+  /* This procedure takes the character at in_buff[num_proc] and adds
+     it to the buffer. It first checks to see if we should be inserting
+     or overwriting, and then does the appropriate thing     */
+  
+  if ((buff_pntr + amount) > 1023) {
+    putchar(_BELL);
+    fflush(stdout);
+    num_proc += amount;
+  }
+  else {
+    
+    if (INS_MODE) {
+      
+      forwardcopy(&buff[curr_pntr + amount],
+		  &buff[curr_pntr],
+		  buff_pntr - curr_pntr);
+      forwardflag_cpy(&buff_flag[curr_pntr + amount],
+		      &buff_flag[curr_pntr],
+		      buff_pntr - curr_pntr);
+      for (count = 0; count < amount; count++) {
+	buff[curr_pntr + count] = in_buff[num_proc + count];
+	buff_flag[curr_pntr + count] = 1;
+      }
+      ins_print(curr_pntr, amount);
+      buff_pntr = buff_pntr + amount;
+    }
+    else {
+      for (count = 0; count < amount; count++) {
+	if (buff_flag[curr_pntr + count] == 2) {
+	  myputchar(buff[curr_pntr + count]);
+	  curr_pntr += count + 1;
+	  delete_current_char();
+	  /** fix num_proc affected by delete **/
+	  num_proc -= 3;
+	  curr_pntr -= count + 1;
+	  myputchar(_BKSPC);
+	}
+	buff[curr_pntr + count] = in_buff[num_proc + count];
+	buff_flag[curr_pntr + count] = 1;
+      }
+      myputchar(in_buff[num_proc]);
+      if (curr_pntr == buff_pntr)
+	buff_pntr++;
+    }
+    num_proc = num_proc + amount;
+    curr_pntr = curr_pntr + amount;
+    fflush(stdout);
+  }
+  return;
+  
+}
+
+void 
+insert_buff_nonprinting(int amount)
+{
+  int count;
+  
+  /* This procedure takes the character at in_buff[num_proc] and adds
+     it to the buffer. It first checks to see if we should be inserting
+     or overwriting, and then does the appropriate thing */
+  
+  /* it takes care of the special case, when I have an esc character */
+  
+  if ((buff_pntr + amount) > 1023) {
+    myputchar(_BELL);
+    fflush(stdout);
+    num_proc += amount;
+  }
+  else {
+    if (INS_MODE) {
+      forwardcopy(&buff[curr_pntr + amount + 1],
+		  &buff[curr_pntr],
+		  buff_pntr - curr_pntr);
+      forwardflag_cpy(&buff_flag[curr_pntr + amount + 1],
+		      &buff_flag[curr_pntr],
+		      buff_pntr - curr_pntr);
+      /** now insert the special character **/
+      switch (in_buff[num_proc]) {
+      case _ESC:
+	/** in this case I insert a '^[' into the string ***/
+	buff[curr_pntr] = _CARROT;
+	buff_flag[curr_pntr] = 2;
+	buff[curr_pntr + 1] = _LBRACK;
+	buff_flag[curr_pntr + 1] = 0;
+	break;
+      default:
+	if (control_char(in_buff[num_proc])) {
+	  buff[curr_pntr] = _CARROT;
+	  buff_flag[curr_pntr] = 2;
+	  buff[curr_pntr + 1] = control_to_alpha(in_buff[num_proc]);
+	  buff_flag[curr_pntr + 1] = 0;
+	}
+	else {
+	  /** What do I have ? **/
+	  buff[curr_pntr] = '?';
+	  buff_flag[curr_pntr] = 2;
+	  buff[curr_pntr + 1] = in_buff[num_proc];
+	  buff_flag[curr_pntr] = 0;
+	  break;
+	}
+      }
+      /** Now add the normal characters **/
+      for (count = 1; count < amount; count++) {
+	buff[curr_pntr + count + 1] = in_buff[num_proc + count];
+	buff_flag[curr_pntr + count + 1] = 1;
+      }
+      ins_print(curr_pntr, amount + 1);
+      buff_pntr = buff_pntr + amount + 1;
+    }
+    else {
+      /** I am in the overstrike mode **/
+      switch (in_buff[num_proc]) {
+      case _ESC:
+	/** in this case I insert a '^[' into the string ***/
+	buff[curr_pntr] = _CARROT;
+	buff_flag[curr_pntr] = 2;
+	buff[curr_pntr + 1] = _LBRACK;
+	buff_flag[curr_pntr + 1] = 0;
+	break;
+      default:
+	if (control_char(in_buff[num_proc])) {
+	  buff[curr_pntr] = _CARROT;
+	  buff_flag[curr_pntr] = 2;
+	  buff[curr_pntr + 1] = control_to_alpha(in_buff[num_proc]);
+	  buff_flag[curr_pntr + 1] = 0;
+	}
+	else {
+	  /** What do I have ? **/
+	  buff[curr_pntr] = '?';
+	  buff_flag[curr_pntr] = 2;
+	  buff[curr_pntr + 1] = in_buff[num_proc];
+	  buff_flag[curr_pntr] = 0;
+	  break;
+	}
+      }
+      for (count = 1; count < amount; count++) {
+	if (buff_flag[curr_pntr + count] == 2) {
+	  curr_pntr += count + 1;
+	  delete_current_char();
+	  /** fix num. processed form delete **/
+	  num_proc -= 3;
+	  curr_pntr -= count + 1;
+	}
+	buff[curr_pntr + count + 1] = in_buff[num_proc + count];
+	buff_flag[curr_pntr + count + 1] = 1;
+      }
+      /** now print the characters I have put in **/
+      printbuff(curr_pntr, amount + 1);
+    }
+    num_proc = num_proc + amount;
+    curr_pntr = curr_pntr + amount + 1;
+    if (curr_pntr > buff_pntr)
+      buff_pntr = curr_pntr;
+  }
+  return;
+  
+}
+
+void
+prev_buff(void)
+{
+
+  /*
+   * If the current command ring is NULL, then I should NOT clear the
+   * current line. Thus my business is already done
+   */
+  if (ring == NULL)
+    return;
+  clear_buff();
+  init_buff(buff, buff_pntr);
+  init_flag(buff_flag, buff_pntr);
+  
+  if (current == NULL) {
+    if (ring == NULL)
+      return;
+    current = ring;
+  }
+  else
+    current = current->prev;
+  strcpy(buff, current->buff);
+  flagcpy(buff_flag, current->flags);
+
+  /* first  back up and blank the line */
+  fflush(stdout);
+  printbuff(0, strlen(buff));
+  curr_pntr = buff_pntr = strlen(buff);
+  fflush(stdout);
+  return ;
+}
+
+void
+next_buff(void)
+{
+  
+  /*
+   * If the current command ring is NULL, then I should NOT clear the
+   * current line. Thus my business is already done
+   */
+  if (ring == NULL)
+    return;
+  clear_buff();
+  init_buff(buff, buff_pntr);
+  init_flag(buff_flag, buff_pntr);
+  if (current == NULL) {
+    if (ring == NULL)
+      return;
+    current = ring->next;
+  }
+  else
+    current = current->next;
+  strcpy(buff, current->buff);
+  flagcpy(buff_flag, current->flags);
+  
+  /* first  back up and blank the line **/
+  fflush(stdout);
+  printbuff(0, strlen(buff));
+  curr_pntr = buff_pntr = strlen(buff);
+  fflush(stdout);
+  return ;
+}
+
+
+void 
+forwardcopy(char *buff1,char * buff2,int num)
+{
+  int count;
+  
+  for (count = num; count >= 0; count--)
+    buff1[count] = buff2[count];
+}
+
+
+void 
+forwardflag_cpy(int *buff1,int * buff2,int  num)
+{
+  int count;
+  
+  for (count = num; count >= 0; count--)
+    buff1[count] = buff2[count];
+}
+
+void 
+flagcpy(int *s,int *t)
+{
+  while (*t >= 0)
+    *s++ = *t++;
+  *s = *t;
+}
+
+void 
+flagncpy(int *s,int *t,int n)
+{
+  while (n-- > 0)
+    *s++ = *t++;
+}
+
+void 
+insert_queue(void)
+{
+  QueStruct *trace;
+  QueStruct *new;
+  int c;
+  
+  if (!ECHOIT)
+    return;
+  if (ring != NULL && !strcmp(buff, ring->buff))
+    return;
+  for (c = 0, trace = ring; trace != NULL && c < (prev_check - 1);
+       c++, trace = trace->prev) {
+    if (!strcmp(buff, trace->buff)) {
+      
+      /*
+       * throw this puppy at the end of the ring
+       */
+      trace->next->prev = trace->prev;
+      trace->prev->next = trace->next;
+      trace->prev = ring;
+      trace->next = ring->next;
+      ring->next = trace;
+      trace->next->prev = trace;
+      ring = trace;
+      return;
+    }
+  }
+  
+  /*
+   * simply places the buff command into the front of the queue
+   */
+  if (ring_size < MAXRING) {
+    new = (QueStruct *) malloc(sizeof(struct que_struct));
+    if (new == NULL) {
+      fprintf(stderr, "Malloc Error: Ran out of memory\n");
+      exit(-1);
+    }
+    if (ring_size == 0) {
+      ring = new;
+      ring->prev = ring->next = new;
+    }
+    else {
+      new->next = ring->next;
+      new->prev = ring;
+      ring->next = new;
+      new->next->prev = new;
+      ring = new;
+    }
+    ring_size++;
+  }
+  else
+    ring = ring->next;
+  
+  init_flag(ring->flags, MAXLINE);
+  init_buff(ring->buff, MAXLINE);
+  strcpy(ring->buff, buff);
+  flagncpy(ring->flags, buff_flag, buff_pntr);
+  (ring->buff)[buff_pntr] = '\0';
+  (ring->flags)[buff_pntr] = -1;
+}
+
+
+void
+init_flag(int *flags, int num)
+{
+  int i;
+  
+  for (i = 0; i < num; i++)
+    flags[i] = -1;
+}
+
+void 
+init_buff(char *flags, int num)
+{
+  int i;
+  
+  for (i = 0; i < num; i++)
+    flags[i] = '\0';
+}
+
+
+void
+send_function_to_child(void)
+{
+  /* Takes care of sending a line to the child, and resetting the
+     buffer for new input                                */
+  
+  back_it_up(curr_pntr);
+  /** start by putting the line into the command line ring ***/
+  if (buff_pntr)
+    insert_queue();
+  
+  /** finish the line and send it to the child **/
+  buff[buff_pntr] = _EOLN;
+  
+  buff_flag[buff_pntr++] = 1;
+  buff[buff_pntr] = '\0';
+  buff_flag[buff_pntr] = 0;
+  write(contNum, buff, buff_pntr);
+  
+  /** reinitialize the buffer  ***/
+  init_flag(buff_flag, buff_pntr);
+  init_buff(buff, buff_pntr);
+  /**  reinitialize my buffer pointers **/
+  buff_pntr = curr_pntr = 0;
+  
+  /** reset the ring pointer **/
+  current = NULL;
+  
+  num_proc++;
+  return;
+}
+
+void 
+send_buff_to_child(int chann)
+{
+  if (buff_pntr > 0)
+    write(chann, buff, buff_pntr);
+  num_proc += 6;
+  /** reinitialize the buffer  ***/
+  init_flag(buff_flag, buff_pntr);
+  init_buff(buff, buff_pntr);
+  /**  reinitialize my buffer pointers **/
+  buff_pntr = curr_pntr = 0;
+  /** reset the ring pointer **/
+  current = NULL;
+  return;
+}
+
+\end{chunk}
+
+\section{emupty.c}
+\begin{chunk}{emupty.c}
+
+/*
+  Here is some code taken from Nick Simicich. It takes an escape sequence
+  from the child, and if I am actually talking to an HFT device, it
+  translates that escape sequence into an ioctl call.
+  */
+
+
+#if 0
+
+\getchunk{include/edible.h}
+#include "sys/devinfo.h"
+#include <sys/ioctl.h>
+
+typedef union {
+   struct hfintro *hf;
+   struct hfctlreq *re;
+   char *c;
+} Argument;
+
+emuhft(Argument arg, int tty, int ptc, int len)
+{
+    /* What does it do? */
+    /* 1.  There are a number of ioctl's associated with the HFT terminal. */
+    /* 2.  When an HFT terminal is being emulated over a PTY, the */
+    /* IOCTL cannot be executed directly on the server end of the PTY. */
+    /* 3.  A system defined structure is set up such that the program */
+    /* at the end of the PTY can issue the ioctl as an escape */
+    /* sequence and get its response as an escape sequence. */
+    /* 4.  This is badly broken, even stupid.  If the protocol is */
+    /* defined, and everyone is supposed to use it, then the HFT */
+    /* should react directly to it.  But No.... */
+    /* 5.  Furthermore, our terminal itself might be a pty.  In that */
+    /* case, we have to transmit the data just as we got it to the */
+    /* other PTY, instead of executing the IOCTL. */
+
+    static union {
+        struct hfintro hfi;
+        struct hfctlack ackn;
+        char charvector[1024];  /* Spacer to make sure that response can be
+                                 * moved here */
+    }   aa;
+
+    extern int errno;
+
+#ifdef DEBUG
+    dstream(arg.c, stderr, NULL, "From emuhft (input)");
+#endif
+
+    if (len > 1000) {
+        fprintf(stderr, "Unreasonable value for len %d\n", len);
+        return -1;
+    }
+
+    if (ioctl(tty, IOCTYPE, 0) != (DD_PSEU << 8)) {     /* is it a pty ?      */
+        switch (arg.re->hf_request) {
+          case HFQUERY:{
+                struct hfquery hfqur;
+                int i;
+
+                hfqur.hf_resplen = iiret(arg.re->hf_rsp_len);
+                if (hfqur.hf_resplen > 0) {
+                    hfqur.hf_resp = aa.charvector + sizeof aa.ackn;
+                    if (hfqur.hf_resplen > (sizeof aa.charvector - sizeof
+                                            aa.ackn)) {
+                        errno = ENOMEM;
+                        perror("Can't store HFQUERY response");
+                        return -1;
+                    }
+                }
+                else
+                    hfqur.hf_resp = NULL;
+
+                hfqur.hf_cmd = arg.c + 3 + ciret(arg.hf->hf_len);
+                hfqur.hf_cmdlen = iiret(arg.re->hf_arg_len);
+                i = ioctl(tty, HFQUERY, &hfqur);        /* The meat of the
+                                                         * matter */
+                aa.hfi.hf_esc = HFINTROESC;
+                aa.hfi.hf_lbr = HFINTROLBR;
+                aa.hfi.hf_ex = HFINTROEX;
+                icmove(sizeof aa.ackn - 3, aa.hfi.hf_len);
+                aa.hfi.hf_typehi = HFCTLACKCH;
+                aa.hfi.hf_typelo = HFCTLACKCL;
+                if (i == -1)
+                    aa.ackn.hf_retcode = errno;
+                else
+                    aa.ackn.hf_retcode = 0;
+                aa.ackn.hf_sublen = arg.re->hf_sublen;
+                aa.ackn.hf_subtype = arg.re->hf_subtype;
+                aa.ackn.hf_request = iiret(arg.re->hf_request);
+                aa.ackn.hf_arg_len = hfqur.hf_resplen;
+                if (-1 == write(ptc, aa.charvector, (sizeof aa.ackn) +
+                                hfqur.hf_resplen)) {
+                    perror("write of HFQUERY acknowledgement failed");
+                    return (-1);
+                }
+#ifdef DEBUG
+                dstream(aa.charvector, stderr, NULL, "From emuhft (hfquery ack)");
+#endif
+                break;
+            }
+          case HFSKBD:{
+                struct hfbuf hfkey;
+                int i;
+
+                hfkey.hf_bufp = arg.c + 3 + ciret(arg.hf->hf_len);
+                hfkey.hf_buflen = iiret(arg.re->hf_arg_len);
+                i = ioctl(tty, HFSKBD, &hfkey); /* The meat of the matter */
+                aa.hfi.hf_esc = HFINTROESC;
+                aa.hfi.hf_lbr = HFINTROLBR;
+                aa.hfi.hf_ex = HFINTROEX;
+                icmove(sizeof aa.ackn - 3, aa.hfi.hf_len);
+                aa.hfi.hf_typehi = HFCTLACKCH;
+                aa.hfi.hf_typelo = HFCTLACKCL;
+                if (i == -1)
+                    aa.ackn.hf_retcode = errno;
+                else
+                    aa.ackn.hf_retcode = 0;
+                aa.ackn.hf_sublen = arg.re->hf_sublen;
+                aa.ackn.hf_subtype = arg.re->hf_subtype;
+                aa.ackn.hf_request = iiret(arg.re->hf_request);
+                aa.ackn.hf_arg_len = 0;
+                if (-1 == write(ptc, aa.charvector, sizeof aa.ackn)) {
+                    perror("write of HFSKEY acknowledgement failed");
+                    return (-1);
+                }
+#ifdef DEBUG
+                dstream(aa.charvector, stderr, NULL, "From emuhft (HFSKEY ack)");
+#endif
+                break;
+            }
+          default:{
+                aa.hfi.hf_esc = HFINTROESC;
+                aa.hfi.hf_lbr = HFINTROLBR;
+                aa.hfi.hf_ex = HFINTROEX;
+                icmove(sizeof aa.ackn - 3, aa.hfi.hf_len);
+                aa.hfi.hf_typehi = HFCTLACKCH;
+                aa.hfi.hf_typelo = HFCTLACKCL;
+                aa.ackn.hf_retcode = EINVAL;
+                aa.ackn.hf_sublen = arg.re->hf_sublen;
+                aa.ackn.hf_subtype = arg.re->hf_subtype;
+                aa.ackn.hf_request = iiret(arg.re->hf_request);
+                aa.ackn.hf_arg_len = 0;
+                if (-1 == write(ptc, aa.charvector, sizeof aa.ackn)) {
+                    perror("write of default acknowledgement failed");
+                    return (-1);
+                }
+#ifdef DEBUG
+                dstream(aa.charvector, stderr, NULL, "From emuhft (default ack)");
+#endif
+
+                break;
+            }
+        }
+    }
+    else {
+        /* Well, if we get here, we are a pseudo-device ourselves.  So */
+        /* we will just send on the request that we got.  we are in a */
+        /* unique situation.  We believe that both ptc and tty are as */
+        /* transparent as we can get them, so we don't have to worry. */
+        /* We will just write the request to the tty,  which we */
+        /* believe is a pty, and sooner or later, the ack will come */
+        /* back. */
+        if (-1 == write(tty, arg.c, len)) {
+            perror("write of control sequence to pty failed");
+            fprintf(stderr, "tty = %d, len = %d\n", tty, len);
+            return (-1);
+        }
+#ifdef DEBUG
+        dstream(arg.c, stderr, NULL, "From emuhft (on pty transfer)");
+        fprintf(stderr, "tty = %d, len = %d\r\n", tty, len);
+        fflush(stderr);
+#endif
+
+    }
+    return 0;
+}
+
+
+
+#endif
+
+static int _ThatsAll_(int x) 
+{
+return x;
+}
+\end{chunk}
+
+\section{fnct-key.c}
+
+On the MAC OSX the signal [[SIGCLD]] has been renamed to [[SIGCHLD]].
+In order to handle this change we need to ensure that the platform
+variable is set properly and that the platform variable is changed
+everywhere.
+\begin{chunk}{mac os signal rename}
+#if defined(MACOSXplatform) || defined(BSDplatform)
+        bsdSignal(SIGCHLD, null_fnct,RestartSystemCalls);
+#else
+        bsdSignal(SIGCLD, null_fnct,RestartSystemCalls);
+#endif
+\end{chunk}
+
+The MACOSX platform is broken because no matter what you do it seems to
+include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
+systems these files include themselves which causes an infinite regression
+of includes that fails. GCC gracefully steps over that problem but the
+build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
+of files are badly broken with respect to the [[/usr/include]] versions.
+
+\begin{chunk}{fnct-key.c}
+#if defined(MACOSXplatform)
+#include "/usr/include/unistd.h"
+#else
+#include <unistd.h>
+#endif
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <signal.h>
+
+
+\getchunk{include/edible.h}
+\getchunk{include/bsdsignal.h}
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/fnct-key.h1}
+\getchunk{include/prt.h1}
+\getchunk{include/edin.h1}
+
+
+/** Some constants for functio key defs ****/
+#define DELAYED 0
+#define IMMEDIATE 1
+#define SPECIAL   2
+
+
+/**   Here is the structure for storing bound  pf-keys             ***/
+fkey function_key[13];          /** Strings which replace function
+                                    keys when a key is hit          ***/
+
+static char *defaulteditor = "clefedit";
+char editorfilename[100];
+
+
+
+/*
+ * The following function environment variable clef editor. The command
+ * should be the one that the user wishes to have execed
+ */
+
+void 
+set_editor_key(void)
+{
+    int pid;
+
+    sprintf(editorfilename, "/tmp/clef%d", pid = getpid());
+
+    if (function_key[12].str == NULL) {
+        (function_key[12]).type = SPECIAL;
+        (function_key[12]).str = defaulteditor;
+    }
+}
+
+
+
+
+void
+define_function_keys(void)
+/***  This routine id used to find the users function key mappings. It
+    simply searches the users HOME directory for a file called ".clef".
+    If found it gets the key bindings from within
+    *****/
+{
+    char *HOME, path[1024], string[1024];
+    int key;
+    int fd;
+    char type;
+
+    /** lets initialize the key pointers **/
+    for (key = 0; key < 13; key++)
+        (function_key[key]).str = NULL;
+    /** see if the user has a .clef file       ***/
+    HOME = getenv("HOME");
+    sprintf(path, "%s/.clef", HOME);
+    if ((fd = open(path, O_RDONLY)) == -1) {
+        return;
+    }
+    else {
+        /*** If so, then get the key bindings **/
+        while ((key = get_key(fd, &type))) {
+            get_str(fd, string);
+            switch (type) {
+              case 'D':
+                if (key == 12) {
+                    fprintf(stderr,
+                       "Clef Error: PF12 can only be of type E in .clef\n");
+                    fprintf(stderr, "Line will be ignored\n");
+                    type = -1;
+                }
+                else {
+                    (function_key[key]).type = DELAYED;
+                }
+                break;
+              case 'F':
+                if (key == 12) {
+                    fprintf(stderr,
+                       "Clef Error: PF12 can only be of type E in .clef\n");
+                    fprintf(stderr, "Line will be ignored\n");
+                    type = -1;
+                }
+                else {
+                    (function_key[key]).type = IMMEDIATE;
+                }
+                break;
+              case 'E':
+                if (key != 12) {
+                    fprintf(stderr,
+                       "Clef Error: PF12 can only be of type E in .clef\n");
+                    fprintf(stderr, "Line will be ignored\n");
+                    type = -1;
+                }
+                else {
+                    (function_key[key]).type = SPECIAL;
+                }
+                break;
+            }
+            if (type != -1) {
+                (function_key[key]).str =
+                    (char *) malloc(strlen(string) + 1);
+                sprintf((function_key[key]).str, "%s", string);
+            }
+        }
+    }
+
+    /*
+     * Now set the editor function key
+     */
+    set_editor_key();
+}
+
+
+#define defof(c) ((c == 'F' || c == 'D' || c == 'E')?(1):(0))
+
+int
+get_key(int fd,char * ty)
+{
+
+    /*
+     * Determines the key number being mapped, and whether it is immediate or
+     * delay. It reurns the key value, and modifies the parameter type
+     */
+    char keynum[1024];
+    int nr;
+
+    nr = read(fd, keynum, 3);
+    if (nr != -1 && nr != 0) {
+        if (!defof(keynum[0])) {
+            return 0;
+        }
+        else {
+            *ty = keynum[0];
+            keynum[3] = '\0';
+            return (atoi(&keynum[1]));
+        }
+    }
+    else
+        return 0;
+}
+
+int
+get_str(int fd,char * string)
+{
+    /** Gets the key mapping being bound **/
+    char c;
+    int count = 0;
+    char *trace = string;
+
+    read(fd, &c, 1);
+    while (c == ' ')
+        read(fd, &c, 1);
+    while (c != '\n') {
+        count++;
+        *trace++ = c;
+        if (read(fd, &c, 1) == 0)
+            break;
+    }
+    *trace = '\0';
+    return count;
+}
+
+void 
+null_fnct(int sig)
+{
+    return;
+}
+
+void 
+handle_function_key(int key,int  chann)
+{
+    /** this procedure simply adds the string specified by the function key
+      to the buffer                                               ****/
+    int count, fd;
+    int amount = strlen(function_key[key].str);
+    int id;
+
+    /*** This procedure takes the character at in_buff[num_proc] and adds
+      it to the buffer. It first checks to see if we should be inserting
+      or overwriting, and then does the appropriate thing      *******/
+
+    switch ((function_key[key]).type) {
+      case IMMEDIATE:
+        if (INS_MODE) {
+            forwardcopy(&buff[curr_pntr + amount],
+                        &buff[curr_pntr],
+                        buff_pntr - curr_pntr);
+            forwardflag_cpy(&buff_flag[curr_pntr + amount],
+                            &buff_flag[curr_pntr],
+                            buff_pntr - curr_pntr);
+            for (count = 0; count < amount; count++) {
+                buff[curr_pntr + count] = (function_key[key].str)[count];
+                buff_flag[curr_pntr + count] = '1';
+            }
+            ins_print(curr_pntr, amount + 1);
+            buff_pntr = buff_pntr + amount;
+        }
+        else {
+            for (count = 0; count < amount; count++) {
+                buff[curr_pntr + count] = (function_key[key].str)[count];
+                buff_flag[curr_pntr + count] = '1';
+                myputchar((function_key[key].str)[count]);
+            }
+        }
+        num_proc = num_proc + 6;
+        curr_pntr = curr_pntr + amount;
+        buff_pntr = buff_pntr + amount;
+        send_function_to_child();
+        break;
+      case DELAYED:
+        if (INS_MODE) {
+            forwardcopy(&buff[curr_pntr + amount],
+                        &buff[curr_pntr],
+                        buff_pntr - curr_pntr);
+            forwardflag_cpy(&buff_flag[curr_pntr + amount],
+                            &buff_flag[curr_pntr],
+                            buff_pntr - curr_pntr);
+            for (count = 0; count < amount; count++) {
+                buff[curr_pntr + count] = (function_key[key].str)[count];
+                buff_flag[curr_pntr + count] = '1';
+            }
+            ins_print(curr_pntr, amount + 1);
+            buff_pntr = buff_pntr + amount;
+        }
+        else {
+            for (count = 0; count < amount; count++) {
+                buff[curr_pntr + count] = (function_key[key].str)[count];
+                buff_flag[curr_pntr + count] = '1';
+                myputchar((function_key[key].str)[count]);
+            }
+        }
+        num_proc = num_proc + 6;
+        curr_pntr = curr_pntr + amount;
+        buff_pntr = buff_pntr + amount;
+        fflush(stdout);
+        break;
+      case SPECIAL:
+        /* fprintf(stderr, "Here I am \n"); */
+        if (access(editorfilename, F_OK) < 0) {
+            fd = open(editorfilename, O_RDWR | O_CREAT, 0666);
+            write(fd, buff, buff_pntr);
+            back_up(buff_pntr);
+            close(fd);
+        }
+        else {
+            if (buff_pntr > 0) {
+                fd = open(editorfilename, O_RDWR | O_TRUNC);
+                write(fd, buff, buff_pntr);
+                back_up(buff_pntr);
+                close(fd);
+            }
+        }
+\getchunk{mac os signal rename}
+        switch (id = fork()) {
+          case -1:
+            perror("Special key");
+            break;
+          case 0:
+            execlp((function_key[12]).str,
+                   (function_key[12]).str,
+                   editorfilename, NULL);
+            perror("Returned from exec");
+            exit(0);
+
+        }
+        while (wait((int *) 0) < 0);
+        /** now I should read that file and send all it stuff thru the
+                  reader                                            *****/
+        fd = open(editorfilename, O_RDWR);
+        if (fd == -1) {
+            perror("Opening temp file");
+            exit(-1);
+        }
+        num_proc += 6;
+
+        /** reinitialize the buffer  ***/
+        init_flag(buff_flag, buff_pntr);
+        init_buff(buff, buff_pntr);
+        /**  reinitialize my buffer pointers **/
+        buff_pntr = curr_pntr = 0;
+        /** reset the ring pointer **/
+        current = NULL;
+        ECHOIT = 0;
+        while ((num_read = read(fd, in_buff, MAXLINE))) {
+            do_reading();
+        }
+        close(fd);
+        break;
+    }
+    return;
+
+}
+\end{chunk}
+
+\section{halloc.c}
+\begin{chunk}{halloc.c}
+
+/* memory allocation used by HyperDoc and addfile */
+
+#include <stdlib.h>
+#include <stdio.h>
+
+\getchunk{include/halloc.h1}
+
+
+/* allocate memory and bomb if none left (hyperTeX alloc) */
+char *
+halloc(int bytes,char * msg)
+{
+    static char buf[200];
+    char *result;
+
+    result = (char *) malloc(bytes);
+    if (result == NULL) {
+        sprintf(buf, "Ran out of memory allocating %s.\b", msg);
+        exit(-1);
+    }
+    return result;
+}
+\end{chunk}
+
+\section{hash.c}
+\begin{chunk}{hash.c}
+
+#define _HASH_C
+\getchunk{include/debug.h}
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+\getchunk{include/hash.h}
+\getchunk{include/hash.h1}
+\getchunk{include/halloc.h1}
+
+/* initialize a hash table */
+
+void
+hash_init(HashTable *table, int size, EqualFunction equal, 
+          HashcodeFunction hash_code)
+{
+    int i;
+
+    table->table =
+        (HashEntry **) halloc(size * sizeof(HashEntry *), "HashEntry");
+    for (i = 0; i < size; i++)
+        table->table[i] = NULL;
+    table->size = size;
+    table->equal = equal;
+    table->hash_code = hash_code;
+    table->num_entries = 0;
+}
+
+void
+free_hash(HashTable *table, FreeFunction free_fun)
+{
+  if (table) {
+    int i;
+
+    for (i = 0; i < table->size; i++) {
+      HashEntry *e, *next;
+
+      for (e = table->table[i]; e != NULL;) {
+        next = e->next;
+        (*free_fun) (e->data);
+	(*e).data=0;
+        free(e);
+        e = next;
+      }
+    }
+    free(table->table);
+  }
+}
+
+/* insert an entry into a hash table */
+
+void
+hash_insert(HashTable *table, char *data, char *key)
+{
+    HashEntry *entry = (HashEntry *) halloc(sizeof(HashEntry), "HashEntry");
+    int code;
+
+    entry->data = data;
+    entry->key = key;
+    code = (*table->hash_code) (key, table->size) % table->size;
+#ifdef DEBUG
+    fprintf(stderr, "Hash value = %d\n", code);
+#endif
+    entry->next = table->table[code];
+    table->table[code] = entry;
+    table->num_entries++;
+}
+
+char *
+hash_find(HashTable *table, char *key)
+{
+    HashEntry *entry;
+    int code = table->hash_code(key, table->size) % table->size;
+
+    for (entry = table->table[code]; entry != NULL; entry = entry->next)
+        if ((*table->equal) (entry->key, key))
+            return entry->data;
+    return NULL;
+}
+
+char *
+hash_replace(HashTable *table, char *data, char *key)
+{
+    HashEntry *entry;
+    int code = table->hash_code(key, table->size) % table->size;
+
+    for (entry = table->table[code]; entry != NULL; entry = entry->next)
+        if ((*table->equal) (entry->key, key)) {
+            entry->data = data;
+            return entry->data;
+        }
+    return NULL;
+}
+
+void
+hash_delete(HashTable *table, char *key)
+{
+    HashEntry **entry;
+    int code = table->hash_code(key, table->size) % table->size;
+
+    for (entry = &table->table[code]; *entry != NULL; entry = &((*entry)->next))
+        if ((*table->equal) ((*entry)->key, key)) {
+            *entry = (*entry)->next;
+            table->num_entries--;
+            return;
+        }
+}
+
+void
+hash_map(HashTable *table, MappableFunction func)
+{
+    int i;
+    HashEntry *e;
+
+    if (table == NULL)
+        return;
+    for (i = 0; i < table->size; i++)
+        for (e = table->table[i]; e != NULL; e = e->next)
+            (*func) (e->data);
+}
+
+HashEntry *
+hash_copy_entry(HashEntry *e)
+{
+    HashEntry *ne;
+
+    if (e == NULL)
+        return e;
+    ne = (HashEntry *) halloc(sizeof(HashEntry), "HashEntry");
+    ne->data = e->data;
+    ne->key = e->key;
+    ne->next = hash_copy_entry(e->next);
+    return ne;
+}
+
+/* copy a hash table */
+HashTable *
+hash_copy_table(HashTable *table)
+{
+    HashTable *nt = (HashTable *) halloc(sizeof(HashTable), "copy hash table");
+    int i;
+
+    nt->size = table->size;
+    nt->num_entries = table->num_entries;
+    nt->equal = table->equal;
+    nt->hash_code = table->hash_code;
+    nt->table = (HashEntry **) halloc(nt->size * sizeof(HashEntry *),
+                                      "copy table");
+    for (i = 0; i < table->size; i++)
+        nt->table[i] = hash_copy_entry(table->table[i]);
+    return nt;
+}
+
+/* hash code function for strings */
+int
+string_hash(char *s, int size)
+{
+    int c = 0;
+    char *p =s;
+
+
+    while (*p)
+        c += *p++;
+    return c % size;
+}
+
+/* test strings for equality */
+
+int
+string_equal(char *s1, char *s2)
+{
+    return (strcmp(s1, s2) == 0);
+}
+
+/* make a fresh copy of the given string */
+char *
+alloc_string(char *str)
+{
+    char * result;
+    result = halloc(strlen(str)+1,"String");
+    strcpy(result,str);
+    return (result);
+}
+\end{chunk}
+
+\section{openpty.c}
+
+The main function is {\tt ptyopen}. It simply opens up both sides of a
+pseudo-terminal. It uses and saves the pathnames for
+the devices which were actually opened.
+
+If it fails it simply exits the program.
+
+\begin{verbatim}
+ ptyopen(controller, server, controllerPath, serverPath) 
+ int *controller;     The file descriptor for controller side
+ int *server;         The file descriptor for the server side 
+ char *controllerPath;  actually , this is not used anywhere 
+                        on return and can be taken out of the 
+                        call sequence
+ char *serverPath;
+\end{verbatim}
+The path name  vars should be declared of size 11 or more
+
+The device {\tt /dev/ptmx} is the pseudo-terminal master device.
+The device {\tt /dev/pts} is the pseudo-terminal slave device.
+
+The file {\tt /dev/ptmx} is a character file with a major number of 5
+and a minor number of 2, usually of mode 0666 and owner.group of
+root.root. It is used to create a pseudo-terminal master and slave pair.
+
+When a process opens {\tt /dev/ptmx}, it gets a file descriptor for a
+pseudo-terminal master {\tt PTM}, and a pseudo-terminal slave {\tt PTS}
+device is created in the {\tt /dev/pts} directory. Each file descriptor
+obtained by opening {\tt /dev/ptmx} is an independent {\tt PTM} with its
+own associated {\tt PTS}, whose path can be found by passing the 
+descriptor to {\tt ptsname}.
+
+Before opening the pseudo-terminal slave, you must pass the master's
+file descriptor to {\tt grantpt} and {\tt unlockpt}.
+
+Once both the pseudo-terminal master and slave are open, the slave
+provides processes with an interface that is identical to that of a
+real terminal.
+
+Data written to the slave is presented on the master descriptor as input.
+Data written to the master is presented to the slave as input.
+
+In practice, pseudo-terminals are used for implementing terminal 
+emulators such as {\tt xterm}, in which data read from the 
+pseudo-terminal master is interpreted by the application in the same way
+a real terminal would interpret the data, and for implementing 
+remote login programs such as {\tt sshd}, in which data read from the
+pseudo-terminal master is sent across the network to a client program
+that is connected to a terminal or terminal emulator.
+
+Pseudo-terminals can also be used to send input to programs that normally
+refuse to read input from pipes (such as {\tt su}) and {\tt passwd}.
+
+The Linux support for the pseudo-terminals (known as Unix98 pty naming)
+is done using the {\tt devpts} filesystem, that should be mounted on
+{\tt /dev/pts}.
+
+Before this Unix98 scheme, master ptys were called {\tt /dev/ptyp0},
+$\ldots$, and slave ptys {\tt /dev/ttyp0}, $\ldots$ and one to 
+preallocate 
+a lot of device nodes./cite{1}
+
+\begin{chunk}{openpty.c}
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <string.h>
+
+#if defined(SUN4OS5platform) || defined(HP10platform)
+#include <stropts.h>
+#endif
+
+\getchunk{include/openpty.h1}
+
+\end{chunk}
+
+\begin{chunk}{openpty.c}
+
+int  
+ptyopen(int *controller,int * server, char *controllerPath,char * serverPath)
+{
+#if defined(SUNplatform) ||\
+ defined (HP9platform) ||\
+ defined(RTplatform) ||\
+ defined(AIX370platform) ||\
+ defined(BSDplatform)
+  int looking = 1, i;
+  int oflag = O_RDWR;                  /* flag for opening the pty */
+  
+  for (i = 0; looking && i < 1000; i++) {
+    makeNextPtyNames(controllerPath, serverPath);
+    if (access(controllerPath, 6) != 0) continue;
+    *controller = open(controllerPath, oflag, 0);
+    if (*controller >= 0) {
+      *server = open(serverPath, oflag, 0);
+      if (*server > 0)
+	looking = 0;
+      else
+	close(*controller);
+    }
+  }
+  if (looking) {
+    fprintf(stderr, "Couldn't find a free pty.\n");
+    exit(-1);
+  }
+  return (*controller);
+#endif
+#if defined RIOSplatform
+  int fdm,fds;
+  char *slavename;
+  /* open master */
+  if ((fdm=open("/dev/ptc",O_RDWR))<0)
+    perror("ptyopen failed to open /dev/ptc");
+  else {
+    /* get slave name */
+    if((slavename = ttyname(fdm))==0)
+      perror("ptyopen failed to get the slave device name");
+    /* open slave */
+    if ((fds = open(slavename, O_RDWR)) < 0 )
+      perror("ptyopen: Failed to open slave");
+    strcpy(serverPath,slavename);
+    *controller=fdm;
+    *server=fds;
+  }
+  return(fdm);
+#endif
+
+\end{chunk}
+
+Note that since we have no other information we are adding the
+MACOSXplatform variable to the list everywhere we find
+LINUXplatform. This may not be correct but we have no way to know
+yet. We have also added the BSDplatform variable.  MAC OSX is some
+variant of BSD. These should probably be merged but we cannot yet
+prove that.
+
+\begin{chunk}{openpty.c}
+#if defined(SUN4OS5platform) ||\
+ defined(ALPHAplatform) ||\
+ defined(HP10platform) ||\
+ defined(LINUXplatform) ||\
+ defined(MACOSXplatform) ||\
+ defined(BSDplatform)
+
+extern int grantpt(int);
+extern int unlockpt(int);
+extern char* ptsname(int);
+  int fdm,fds;
+  char *slavename;
+
+  /* open master */
+  if ((fdm = open("/dev/ptmx", O_RDWR)) < 0 )
+    perror("ptyopen: Failed to open /dev/ptmx");
+  else {
+    /* change permission ofslave */
+    if (grantpt(fdm) < 0)
+      perror("ptyopen: Failed to grant access to slave device");
+    /* unlock slave */
+    if (unlockpt(fdm) < 0)
+      perror("ptyopen: Failed to unlock master/slave pair");
+    /* get name of slave */
+    if ((slavename = ptsname(fdm)) == NULL)
+      perror("ptyopen: Failed to get name of slave device");
+    /* open slave */
+    if ((fds = open(slavename, O_RDWR)) < 0 )
+      perror("ptyopen: Failed to open slave");
+    else {
+#if defined(SUN4OS5platform) || defined(HP10platform)
+      /* push ptem */
+      if (ioctl(fds, I_PUSH, "ptem") < 0)
+        perror("ptyopen: Failed to push ptem");
+      /* push ldterm */
+      if (ioctl(fds, I_PUSH, "ldterm") < 0)
+        perror("ptyopen: Failed to push idterm");
+#endif
+      strcpy(serverPath,slavename);
+      *controller=fdm;
+      *server=fds;
+    }
+  }
+  return(fdm);
+#endif
+#if defined SGIplatform
+  char *fds;
+  fds = _getpty(controller, O_RDWR|O_NDELAY, 0600, 0);
+  strcpy(serverPath,fds);
+  if (0 == serverPath)
+    return(-1);
+  if (0 > (*server = open(serverPath,O_RDWR))) {
+    (void) close(*controller);
+    return(-1);
+  }
+  return (*controller);
+
+#endif
+}
+
+\end{chunk}
+
+Prior to using the Unix 98 pty naming scheme the naming scheme
+used 16 ptyp/ttyp names, ttyp0-ttypF (where F is a hex number).
+Later this was extended to ttyq0-ttyqF and so on, eventually
+wrapping around to ttya0-ttyaF. Linux also allows larger numbers
+such as ttypNNN.\cite{2}
+
+\begin{chunk}{openpty.c}
+
+void makeNextPtyNames(char *cont,char * serv)
+{
+#ifdef AIX370platform
+	static int channelNo = 0;
+	sprintf(cont, "/dev/ptyp%02x", channelNo);
+	sprintf(serv, "/dev/ttyp%02x", channelNo);
+	channelNo++;
+#endif
+\end{chunk}
+
+See the note above about the MACOS platform change.
+
+\begin{chunk}{openpty.c}
+#if defined(SUNplatform) ||\
+ defined(HP9platform) ||\
+ defined(LINUXplatform) ||\
+ defined(MACOSXplatform) ||\
+ defined(BSDplatform)
+	static int channelNo = 0;
+	static char group[] = "pqrstuvwxyzPQRST";
+	static int groupNo = 0;
+
+	sprintf(cont, "/dev/pty%c%x", group[groupNo], channelNo);
+	sprintf(serv, "/dev/tty%c%x", group[groupNo], channelNo);
+	channelNo++;                /* try next */
+	if (channelNo == 16) {      /* move to new group */
+		channelNo = 0;
+		groupNo++;
+		if (groupNo == 16) groupNo = 0;        /* recycle */
+		}
+#endif
+}
+
+\end{chunk}
+
+\section{pixmap.c}
+
+On the [[MAC OSX]] platform they defined [[zopen]]. Since the function
+is only used in this file we simply rename it to [[zzopen]].
+\begin{chunk}{mac zopen redefinition 1}
+FILE *
+zzopen(char *file,char * mode)
+\end{chunk}
+\begin{chunk}{mac zopen redefinition 2}
+    file = zzopen(filename, "r");
+\end{chunk}
+
+\begin{chunk}{pixmap.c}
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <netinet/in.h>
+
+#define yes 1
+#define no  0
+
+\getchunk{include/spadcolors.h}
+
+\getchunk{include/pixmap.h1}
+\getchunk{include/halloc.h1}
+\getchunk{include/spadcolors.h1}
+
+/* returns true if the file exists */
+
+int
+file_exists(char *file)
+{
+    FILE *f;
+
+    if ((f = fopen(file, "r")) != NULL) {
+        fclose(f);
+        return 1;
+    }
+    return 0;
+}
+
+\getchunk{mac zopen redefinition 1}
+{
+    char com[512], zfile[512];
+
+    if (file_exists(file))
+        return fopen(file, mode);
+    sprintf(zfile, "%s.Z", file);
+    if (file_exists(zfile)) {
+        sprintf(com, "gunzip -c %s.Z 2>/dev/null", file);
+        return popen(com, mode);
+    }
+    return NULL;
+}
+#ifdef OLD
+
+/*******************************************************************
+   KF 6/14/90
+   write_pixmap_file(display, filename, pm, width, height)
+        and
+   write_pixmap_file_xy(display, filename, pm, x, y, width, height)
+   has been merged into one function.
+
+   INPUT: display dsp, screen s, file name fn to write the file in,
+          window id wid where pixmap is,
+          upper left corner x, y of original pixmap,
+          width and height of pixmap
+   OUTPUT: binary file with data
+   PURPOSE: write_pixmap_file gets the image structure of the input
+          pixmap, convert the image data with the permutation color
+          vector, writes the image structure out to filename.
+
+   Note that writing out a Z pixmap is 8x faster than XY pixmap.
+   This is because XY writes out each pixel value per plane, thus
+   number of bits; Z writes out each pixel, or 8 bits at a time.
+
+   The XY format may have been chosen for a reason -- I don't know.
+
+********************************************************************/
+void
+write_pixmap_file(Display *dsp, int scr, char  *fn, 
+                  Window wid, int x, int y, int width,int height)
+{
+    XImage *xi;
+    FILE *file;
+    int *permVector;
+    int num;
+    int num_colors;
+
+    /* get color map and permutation vector */
+    if ((num_colors = makePermVector(dsp, scr,(unsigned long **)&permVector)) < 0) {
+        printf("num_colors < 0!!\n");
+        exit(-1);
+    }
+
+    /* reads image structure in ZPixmap format */
+    xi = XGetImage(dsp, wid, x, y, width, height, AllPlanes, ZPixmap);
+    file = fopen(fn, "wb");
+    if (file == NULL) {
+        perror("opening pixmap file for write");
+        exit(-1);
+    }
+
+#define PUTW(a,b) putw(htonl(a),b)
+
+
+    PUTW(xi->width, file);
+    PUTW(xi->height, file);
+    PUTW(xi->xoffset, file);
+    PUTW(xi->format, file);
+    PUTW(xi->byte_order, file);
+    PUTW(xi->bitmap_unit, file);
+    PUTW(xi->bitmap_bit_order, file);
+    PUTW(xi->bitmap_pad, file);
+    PUTW(xi->depth, file);
+    PUTW(xi->bytes_per_line, file);
+    PUTW(xi->bits_per_pixel, file);
+    PUTW(xi->red_mask, file);
+    PUTW(xi->green_mask, file);
+    PUTW(xi->blue_mask, file);
+
+    num = xi->bytes_per_line * height;  /* total number of pixels in pixmap */
+
+    /* store value from permutation */
+    {
+        int ii, jj;
+
+        for (ii = 0; ii < width; ii++)
+            for (jj = 0; jj < height; jj++) {
+                XPutPixel(xi, ii, jj, permVector[(int) XGetPixel(xi, ii, jj)]);
+            }
+    }
+    fwrite(xi->data, 1, num, file);
+    fclose(file);
+}
+
+/*******************************************************************
+   KF 6/14/90
+
+   INPUT: display, screen, filename to read the pixmap data from,
+   OUTPUT: ximage structure xi, width and height of pixmap
+   PURPOSE: read_pixmap_file reads an Ximage data structure from
+            the input file.
+            This routine can handle pixmaps of both XYPixmap and
+            ZPixmap.  If a pixmap has ZPixmap format, then the image
+            data, read in as spadColor index, is converted to the
+            pixel value using spadColor.
+
+   Note that reading in Z format takes less space and time too.
+
+********************************************************************/
+int
+read_pixmap_file(Display *display, int screen, char *filename,
+                 XImage **xi, int *width, int *height)
+{
+    FILE *file;
+    int wi, h, num, num_colors, read_this_time, offset;
+    Colormap cmap;
+    int ts;
+    unsigned long *spadColors;
+
+    /* colormap is necessary to call makeColors */
+    cmap = DefaultColormap(display, screen);
+    if ((num_colors = makeColors(display, screen, &cmap, &spadColors, &ts)) < 0) {
+        return(-1);
+    }
+\getchunk{mac zopen redefinition 2}
+    if (file == NULL) {
+        printf("couldn't open %s\n", filename);
+        return BitmapOpenFailed;
+    }
+#define GETW(f) ntohl(getw(f))
+    *width = wi = GETW(file);
+    *height = h = GETW(file);
+    (*xi) = XCreateImage(display, DefaultVisual(display, screen),
+                         DisplayPlanes(display, screen),
+                         ZPixmap, 0, NULL, wi, h, 16, 0);       /* handles both XY & Z */
+    if ((*xi) == NULL) {
+        fprintf(stderr, "Unable to create image\n");
+        return(-1);
+    }
+    (*xi)->width = wi;
+    (*xi)->height = h;
+    (*xi)->xoffset = GETW(file);
+    (*xi)->format = GETW(file);
+    (*xi)->byte_order = GETW(file);
+    (*xi)->bitmap_unit = GETW(file);
+    (*xi)->bitmap_bit_order = GETW(file);
+    (*xi)->bitmap_pad = GETW(file);
+    (*xi)->depth = GETW(file);
+    (*xi)->bytes_per_line = GETW(file);
+    (*xi)->bits_per_pixel = GETW(file);
+    (*xi)->red_mask = GETW(file);
+    (*xi)->green_mask = GETW(file);
+    (*xi)->blue_mask = GETW(file);
+
+    /* program will bomb if XYPixmap is not allocated enough space */
+    if ((*xi)->format == XYPixmap) {
+        /* printf("picture is in XYPixmap format.\n"); */
+        num = (*xi)->bytes_per_line * h * (*xi)->depth;
+    }
+    else                        /* ZPixmap */
+        num = (*xi)->bytes_per_line * h;
+    (*xi)->data = (void*)halloc(num, "Ximage data");
+
+    offset = 0;
+    while (offset < num) {
+        read_this_time = fread(((*xi)->data + offset), 1, num - offset, file);
+        offset = offset + read_this_time;
+    }
+    fclose(file);
+
+    /*
+     * pixmap data in ZPixmap format are spadColor indices; pixmap data in
+     * XYPixmap format are pixel values
+     */
+    if ((*xi)->format == ZPixmap) {
+
+        int ii, jj;
+
+        for (ii = 0; ii < wi; ii++)
+            for (jj = 0; jj < h; jj++) {
+                XPutPixel(*xi, ii, jj, spadColors[(int) XGetPixel(*xi, ii, jj)]);
+            }
+
+
+    }
+
+    return 0;
+}
+
+
+#else /*OLD*/
+
+\getchunk{include/xpm.h}
+
+int
+read_pixmap_file(Display *display, int screen, char *filename,
+                 XImage **xi, int *width, int *height)
+{
+  XpmAttributes attr;
+  XImage *xireturn;
+
+  attr.valuemask = 0;
+
+  attr.bitmap_format=ZPixmap;             /* instead of XYPixmap */
+  attr.valuemask |= XpmBitmapFormat;
+  attr.valuemask |= XpmSize;              /* we want feedback on width,height */
+  attr.valuemask |= XpmCharsPerPixel;     /* and cpp */
+  attr.valuemask |= XpmReturnPixels;      /* and pixels, npixels */
+  attr.valuemask |= XpmReturnAllocPixels; /* and alloc_pixels, nalloc_pixels */
+  attr.exactColors = False;
+  attr.valuemask |= XpmExactColors;       /* we don't want exact colors*/
+  attr.closeness = 30000;
+  attr.valuemask |= XpmCloseness;         /* we specify closeness*/
+  attr.alloc_close_colors = False;
+  attr.valuemask |= XpmAllocCloseColors;  /* we don't allocate close colors*/
+
+  
+  XpmReadFileToImage(display,filename,xi,&xireturn, &attr );
+  *width= (*xi)->width;
+  *height=(*xi)->height;
+#ifdef DEBUG
+  fprintf(stderr,"image file:%s\n",filename);
+  fprintf(stderr,"\twidth:%d\theight:%d\tcpp:%d\n",attr.width,attr.height,attr.cpp);
+  fprintf(stderr,"\tused/alloc'ed color pixels:%d/%d\n",attr.npixels,attr.nalloc_pixels);
+#endif
+  return 0;
+}
+
+
+void
+write_pixmap_file(Display *dsp, int scr, char  *fn, 
+                  Window wid, int x, int y, int width,int height)
+{
+  XImage *xi;
+  
+  /* reads image structure in ZPixmap format */
+  xi = XGetImage(dsp, wid, x, y, width, height, AllPlanes, ZPixmap);
+  if (xi==0) return ;
+  XpmWriteFileFromImage(dsp,fn,xi,0,0);
+  
+}
+
+
+#endif
+\end{chunk}
+
+\section{prt.c}
+\begin{chunk}{prt.c}
+
+#include <string.h>
+#include <stdio.h>
+#include <sys/types.h>
+
+\getchunk{include/edible.h}
+\getchunk{include/prt.h1}
+\getchunk{include/edin.h1}
+
+void
+myputchar(char c)
+{
+    if (ECHOIT)
+        putchar(c);
+    return;
+}
+
+void 
+clear_buff(void)
+{
+    int count;
+
+    /*** called when spadbuf gives me a line incase there is something already
+      on the line ****/
+    if (buff_pntr > 0) {
+        /*** backup to the beginning of the line ***/
+        for (count = curr_pntr; count > 0; count--)
+            myputchar(_BKSPC);
+        /** blank over the line      ***/
+        for (count = 0; count < buff_pntr; count++) {
+            myputchar(_BLANK);
+        }
+        /** back up again ***/
+        for (count = buff_pntr; count > 0; count--)
+            myputchar(_BKSPC);
+        init_buff(buff, buff_pntr);
+        init_flag(buff_flag, buff_pntr);
+        curr_pntr = buff_pntr = 0;
+    }
+}
+
+
+void 
+move_end(void)
+{
+
+    /** Moves cursor to the end of the line ***/
+    if (curr_pntr == buff_pntr) {
+        putchar(_BELL);
+    }
+    else {
+        for (; curr_pntr < buff_pntr;) {
+            myputchar(buff[curr_pntr++]);
+        }
+    }
+    fflush(stdout);
+}
+
+void 
+move_home(void)
+{
+
+    /*** Moves the cursor to the front of the line ***/
+    if (curr_pntr > 0) {
+        for (; curr_pntr > 0;) {
+            myputchar(_BKSPC);
+            curr_pntr--;
+        }
+    }
+    else {
+        putchar(_BELL);
+    }
+    fflush(stdout);
+
+}
+
+void 
+move_fore_word(void)
+{
+    /** move the cursor to the next blank space  **/
+    if (curr_pntr != buff_pntr) {
+        myputchar(buff[curr_pntr]);
+        curr_pntr++;
+        while (curr_pntr < buff_pntr && buff[curr_pntr] != ' ') {
+            myputchar(buff[curr_pntr]);
+            curr_pntr++;
+        }
+    }
+    else
+        putchar(_BELL);
+    fflush(stdout);
+    return;
+}
+
+void 
+move_back_word(void)
+{
+    /*** moves the cursor to the last blank space ***/
+    if (curr_pntr > 0) {
+        myputchar(_BKSPC);
+        curr_pntr--;
+        while (curr_pntr > 0 && buff[curr_pntr - 1] != ' ') {
+            myputchar(_BKSPC);
+            curr_pntr--;
+        }
+
+    }
+    else
+        putchar(_BELL);
+    fflush(stdout);
+    return;
+}
+
+void 
+delete_current_char(void)
+{
+    /**  deletes the char currently above the current_pntr, if it can be **/
+    if (curr_pntr != buff_pntr) {
+        if (buff_flag[curr_pntr] == 1 || buff_flag[curr_pntr] == 0) {
+            myputchar(_BLANK);
+            myputchar(_BKSPC);
+            strcpy(&buff[curr_pntr],
+                   &buff[curr_pntr + 1]);
+            flagcpy(&buff_flag[curr_pntr],
+                    &buff_flag[curr_pntr + 1]);
+            buff_pntr--;
+            del_print(curr_pntr, 1);
+        }
+        else {
+            /** lets delete two of the little buggers **/
+            myputchar(_BLANK);
+            myputchar(_BLANK);
+            myputchar(_BKSPC);
+            myputchar(_BKSPC);
+            strcpy(&buff[curr_pntr],
+                   &buff[curr_pntr + 2]);
+            flagcpy(&buff_flag[curr_pntr],
+                    &buff_flag[curr_pntr + 2]);
+            buff_pntr -= 2;
+            del_print(curr_pntr, 2);
+        }
+    }
+    else {
+        putchar(_BELL);
+        fflush(stdout);
+    }
+    num_proc = num_proc + 3;
+}
+
+void 
+delete_to_end_of_line(void)
+{
+    int count;
+
+    /*** deletes from the curr_pntr to the end of line ***/
+
+    if (curr_pntr == buff_pntr)
+        return;                 /** There is nothing to do **/
+
+    /** blank over the end of the line      ***/
+    for (count = curr_pntr; count < buff_pntr; count++) {
+        myputchar(_BLANK);
+    }
+    /** back up again ***/
+    for (count = buff_pntr; count > curr_pntr; count--)
+        myputchar(_BKSPC);
+
+    buff_pntr = curr_pntr;
+    fflush(stdout);
+    return;
+
+}
+
+void 
+delete_line(void)
+{
+    int count;
+
+    /*** deletes the entire line                                 *****/
+
+    if (buff_pntr == 0)
+        return;                 /** There is nothing to do **/
+
+    /** first I have to back up to the beginning of the line     ****/
+    for (count = curr_pntr; count > 0; count--)
+        myputchar(_BKSPC);
+
+    /** blank over the end of the line      ***/
+    for (count = 0; count < buff_pntr; count++) {
+        myputchar(_BLANK);
+    }
+    /** back up again ***/
+    for (count = buff_pntr; count > 0; count--)
+        myputchar(_BKSPC);
+
+    /* Also clear the buffer */
+    init_buff(buff, buff_pntr);
+    init_flag(buff_flag, buff_pntr);
+    buff_pntr = curr_pntr = 0;
+
+    fflush(stdout);
+    return;
+
+}
+
+void 
+printbuff(int start,int  num)
+{
+    int trace;
+
+    for (trace = start; trace < start + num; trace++)
+        if (buff[trace] != '\0')
+            myputchar(buff[trace]);
+    fflush(stdout);
+}
+
+void
+del_print(int start, int num)
+{
+    int count;
+
+    /*** move the rest of the string     ***/
+    for (count = start; count < buff_pntr; count++) {
+        myputchar(buff[count]);
+    }
+    /** now blank out the number of chars we are supposed to ***/
+    for (count = 0; count < num; count++)
+        myputchar(_BLANK);
+    /*** Now back up  ***/
+    for (count = buff_pntr + num; count > start; count--)
+        myputchar(_BKSPC);
+    fflush(stdout);
+}
+
+
+void 
+ins_print(int start,int  num)
+{
+    int count;
+
+    /** write the rest of the word ***/
+    for (count = start; count < buff_pntr + num; count++) {
+        myputchar(buff[count]);
+    }
+    /** now back up to where we should be ***/
+    for (count = buff_pntr; count > start; count--)
+        myputchar(_BKSPC);
+    fflush(stdout);
+}
+
+void 
+reprint(int start)
+{
+    /**  simply reprints a single character **/
+    if (buff[start] == '\0')
+        myputchar(_BLANK);
+    else
+        myputchar(buff[start]);
+    myputchar(_BKSPC);
+    fflush(stdout);
+    return;
+}
+
+void 
+back_up(int num_chars)
+{
+    int cnt;
+
+    for (cnt = 0; cnt < num_chars; cnt++)
+        myputchar(_BKSPC);
+    for (cnt = 0; cnt < num_chars; cnt++)
+        myputchar(_BLANK);
+    for (cnt = 0; cnt < num_chars; cnt++)
+        myputchar(_BKSPC);
+    fflush(stdout);
+
+}
+
+void 
+back_it_up(int num_chars)
+{
+    int cnt;
+
+    for (cnt = 0; cnt < num_chars; cnt++)
+        myputchar(_BKSPC);
+    fflush(stdout);
+}
+
+
+void 
+print_whole_buff(void)
+{
+    int trace;
+
+    for (trace = 0; trace < buff_pntr; trace++)
+        if (buff[trace] != '\0')
+            myputchar(buff[trace]);
+    fflush(stdout);
+}
+
+void
+move_ahead(void)
+{
+    /*** simply moves the pointer ahead a single word ***/
+    if (curr_pntr == buff_pntr) {
+        putchar(_BELL);
+    }
+    else {
+        if (buff_flag[curr_pntr] == 2) {
+            myputchar(buff[curr_pntr++]);
+        }
+        myputchar(buff[curr_pntr++]);
+    }
+    fflush(stdout);
+}
+
+void
+move_back(void)
+{
+    /** simply moves the cursor back one position **/
+    if (curr_pntr == 0) {
+        putchar(_BELL);
+    }
+    else {
+        if (!buff_flag[curr_pntr - 1]) {
+            myputchar(_BKSPC);
+            curr_pntr--;
+        }
+        myputchar(_BKSPC);
+        curr_pntr--;
+    }
+    fflush(stdout);
+}
+
+void
+back_over_current_char(void)
+{
+    /*** simply backs over the character behind the cursor ***/
+    if (curr_pntr == 0) {
+        putchar(_BELL);
+    }
+    else {
+        if (!buff_flag[curr_pntr - 1]) {
+            myputchar(_BKSPC);
+            myputchar(_BKSPC);
+            myputchar(_BLANK);
+            myputchar(_BLANK);
+            myputchar(_BKSPC);
+            myputchar(_BKSPC);
+            strcpy(&buff[curr_pntr - 2],
+                   &buff[curr_pntr]);
+            flagcpy(&buff_flag[curr_pntr - 2],
+                    &buff_flag[curr_pntr]);
+            buff_pntr -= 2;
+            curr_pntr -= 2;
+            del_print(curr_pntr, 2);
+        }
+        else {
+            myputchar(_BKSPC);
+            myputchar(_BLANK);
+            myputchar(_BKSPC);
+            strcpy(&buff[curr_pntr - 1],
+                   &buff[curr_pntr]);
+            flagcpy(&buff_flag[curr_pntr - 1],
+                    &buff_flag[curr_pntr]);
+            curr_pntr--;
+            buff_pntr--;
+            del_print(curr_pntr, 1);
+        }
+    }
+    fflush(stdout);
+    return;
+}
+
+\end{chunk}
+
+\section{sockio-c.c}
+\begin{chunk}{sockio-c.c}
+
+/* socket i/o primitives */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+\end{chunk}
+
+The MACOSX platform is broken because no matter what you do it seems to
+include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
+systems these files include themselves which causes an infinite regression
+of includes that fails. GCC gracefully steps over that problem but the
+build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
+of files are badly broken with respect to the [[/usr/include]] versions.
+
+\begin{chunk}{sockio-c.c}
+#if defined(MACOSXplatform)
+#include "/usr/include/unistd.h"
+#else
+#include <unistd.h>
+#endif
+#include <sys/time.h>
+#include <sys/stat.h>
+#include <errno.h>
+#include <string.h>
+#if defined(MACOSXplatform)
+#include "/usr/include/signal.h"
+#else
+#include <signal.h>
+#endif
+
+#if defined(SGIplatform)
+#include <bstring.h>
+#endif
+
+\getchunk{include/com.h}
+\getchunk{include/bsdsignal.h}
+
+#define TotalMaxPurposes 50
+#define MaxServerNumbers 100
+#define accept_if_needed(purpose) \
+  ( purpose_table[purpose] == NULL ? sock_accept_connection(purpose) : 1 )
+
+
+Sock clients[MaxClients];       /* socket description of spad clients */
+Sock server[2];                 /* AF_UNIX and AF_INET sockets for server */
+Sock *purpose_table[TotalMaxPurposes]; /* table of dedicated socket types */
+fd_set socket_mask;             /* bit mask of active sockets */
+fd_set server_mask;             /* bit mask of server sockets */
+int socket_closed;              /* used to identify closed socket on SIGPIPE */
+int spad_server_number = -1;    /* spad server number used in sman */
+int str_len = 0;
+int still_reading  = 0;
+
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/sockio-c.h1}
+
+void  
+sigpipe_handler(int sig)
+{
+  socket_closed = 1;
+}
+
+int 
+wait_for_client_read(Sock *sock,char *buf,int buf_size,char *msg)
+{
+  int ret_val;
+  switch(sock->purpose) {
+  case SessionManager:
+  case ViewportServer:
+    sock_accept_connection(sock->purpose);
+    ret_val = sread(purpose_table[sock->purpose], buf, buf_size, msg);
+    sock->socket = 0;
+    return ret_val;
+  default:
+    sock->socket = 0;
+    return -1;
+  }
+}
+
+int 
+wait_for_client_write(Sock *sock,char *buf,int buf_size,char *msg)
+{
+  int ret_val;
+  switch(sock->purpose) {
+  case SessionManager:
+  case ViewportServer:
+    sock_accept_connection(sock->purpose);
+    ret_val = swrite(purpose_table[sock->purpose], buf, buf_size, msg);
+    sock->socket = 0;
+    return ret_val;
+  default:
+    sock->socket = 0;
+    return -1;
+  }
+}
+
+int 
+sread(Sock *sock,char *buf,int buf_size,char *msg)
+{
+  int ret_val;
+  char err_msg[256];
+  errno = 0;
+  do {
+    ret_val = read(sock->socket, buf, buf_size);
+  } while (ret_val == -1 && errno == EINTR);
+  if (ret_val == 0) {
+    FD_CLR(sock->socket, &socket_mask);
+    purpose_table[sock->purpose] = NULL;
+    close(sock->socket);
+    return wait_for_client_read(sock, buf, buf_size, msg);
+  }
+  if (ret_val == -1) {
+    if (msg) {
+      sprintf(err_msg, "reading: %s", msg);
+      perror(err_msg);
+    }
+    return -1;
+  }
+  return ret_val;
+}
+
+int 
+swrite(Sock *sock,char *buf,int buf_size,char *msg)
+{
+  int ret_val;
+  char err_msg[256];
+  errno = 0;
+  socket_closed = 0;
+  ret_val = write(sock->socket, buf, buf_size);
+  if (ret_val == -1) {
+    if (socket_closed) {
+      FD_CLR(sock->socket, &socket_mask);
+      purpose_table[sock->purpose] = NULL;
+      /*      printf("   closing socket %d\n", sock->socket); */
+      close(sock->socket);
+      return wait_for_client_write(sock, buf, buf_size, msg);
+    } else {
+      if (msg) {
+        sprintf(err_msg, "writing: %s", msg);
+        perror(err_msg);
+      }
+      return -1;
+    }
+  }
+  return ret_val;
+}
+
+int 
+sselect(int n,fd_set  *rd, fd_set  *wr, fd_set *ex, void *timeout)
+{
+  int ret_val;
+  do {
+    ret_val = select(n, (void *)rd, (void *)wr, (void *)ex, (struct timeval *) timeout);
+  } while (ret_val == -1 && errno == EINTR);
+  return ret_val;
+}
+
+int 
+fill_buf(Sock *sock,char *buf, int len, char *msg)
+{
+  int bytes =  0, ret_val;
+  while(bytes < len) {
+    ret_val = sread(sock, buf + bytes, len - bytes, msg);
+    if (ret_val == -1) return -1;
+    bytes += ret_val;
+  }
+  return bytes;
+}
+
+int 
+get_int(Sock *sock)
+{
+  int val = -1, len;
+  len = fill_buf(sock, (char *)&val, sizeof(int), "integer");
+  if (len != sizeof(int)) {
+#ifdef DEBUG
+  fprintf(stderr,"get_int: caught error\n",val);
+#endif
+    return -1;
+  }
+#ifdef DEBUG
+  fprintf(stderr,"get_int: received %d\n",val);
+#endif
+  return val;
+}
+
+int 
+sock_get_int(int purpose)
+{
+  if (accept_if_needed(purpose) != -1)
+    return get_int(purpose_table[purpose]);
+  else return -1;
+}
+
+int 
+get_ints(Sock *sock, int *vals, int num)
+{
+  int i;
+  for(i=0; i<num; i++)
+    *vals++ = get_int(sock);
+  return 0;
+}
+
+int 
+sock_get_ints(int purpose, int *vals, int num)
+{
+  if (accept_if_needed(purpose) != -1)
+    return get_ints(purpose_table[purpose], vals, num);
+  return -1;
+}
+
+int 
+send_int(Sock *sock,int val)
+{
+  int ret_val;
+  ret_val = swrite(sock, (char *)&val, sizeof(int), NULL);
+  if (ret_val == -1) {
+    return -1;
+  }
+  return 0;
+}
+
+int 
+sock_send_int(int purpose,int  val)
+{
+  if (accept_if_needed(purpose) != -1)
+    return send_int(purpose_table[purpose], val);
+  return -1;
+}
+
+int 
+send_ints(Sock *sock, int *vals, int num)
+{
+  int i;
+  for(i=0; i<num; i++)
+    if (send_int(sock, *vals++) == -1)
+      return -1;
+  return 0;
+}
+
+int 
+sock_send_ints(int purpose, int *vals, int num)
+{
+  if (accept_if_needed(purpose) != -1)
+    return send_ints(purpose_table[purpose], vals, num);
+  return -1;
+}
+
+int 
+send_string_len(Sock *sock,char *str,int len)
+{
+  int val;
+  if (len > 1023) {
+    char *buf;
+    buf = malloc(len+1);
+    strncpy(buf,str,len);
+    buf[len]='\0';
+    send_int(sock,len+1);
+    val = swrite(sock, buf, len+1, NULL);
+    free(buf);
+  } else {
+    static char buf[1024];
+    strncpy(buf, str, len);
+    buf[len] = '\0';
+    send_int(sock, len+1);
+    val = swrite(sock, buf, len+1, NULL);
+  }
+  if (val == -1) {
+    return -1;
+  }
+  return 0;
+}
+
+int 
+send_string(Sock *sock, char *str)
+{
+  int val, len = strlen(str);
+  send_int(sock, len+1);
+  val = swrite(sock, str, len+1, NULL);
+  if (val == -1) {
+    return -1;
+  }
+  return 0;
+}
+
+
+int 
+sock_send_string(int purpose, char *str)
+{
+  if (accept_if_needed(purpose) != -1)
+    return send_string(purpose_table[purpose], str);
+  return -1;
+}
+
+int 
+sock_send_string_len(int purpose, char * str, int len)
+{
+  if (accept_if_needed(purpose) != -1)
+    return send_string_len(purpose_table[purpose], str, len);
+  return -1;
+}
+
+int 
+send_strings(Sock *sock, char ** vals, int num)
+{
+  int i;
+  for(i=0; i<num; i++)
+    if (send_string(sock, *vals++) == -1)
+      return -1;
+  return 0;
+}
+
+int 
+sock_send_strings(int purpose, char **vals, int num)
+{
+  if (accept_if_needed(purpose) != -1)
+    return send_strings(purpose_table[purpose], vals, num);
+  return -1;
+}
+
+char *
+get_string(Sock *sock)
+{
+  int val, len;
+  char *buf;
+  len = get_int(sock);
+  if (len <0) return NULL;
+  buf = malloc(len*sizeof(char));
+  val = fill_buf(sock, buf, len, "string");
+  if (val == -1){
+	free(buf);
+	return NULL;
+	}
+#ifdef DEBUG
+  fprintf(stderr,"get_string: received \"%s\" \n",buf);
+#endif
+  return buf;
+}
+
+char *
+sock_get_string(int purpose)
+{
+  if (accept_if_needed(purpose) != -1)
+    return get_string(purpose_table[purpose]);
+  else return NULL;
+}
+
+
+char *
+get_string_buf(Sock *sock, char *buf, int buf_len)
+{
+  int val;
+  if(!str_len) str_len = get_int(sock);
+    if (str_len > buf_len) {
+      val = fill_buf(sock, buf, buf_len, "buffered string");
+      str_len = str_len - buf_len;
+      if (val == -1)
+        return NULL;
+      return buf;
+    }
+    else {
+      val = fill_buf(sock, buf, str_len, "buffered string");
+      str_len = 0;
+      if (val == -1)
+        return NULL;
+      return NULL;
+    }
+}
+
+char *
+sock_get_string_buf(int purpose, char * buf, int buf_len)
+{
+  if (accept_if_needed(purpose) != -1)
+    return get_string_buf(purpose_table[purpose], buf, buf_len);
+  return NULL;
+}
+
+int 
+get_strings(Sock *sock,char **vals,int num)
+{
+  int i;
+  for(i=0; i<num; i++)
+    *vals++ = get_string(sock);
+  return 0;
+}
+
+int 
+sock_get_strings(int purpose, char ** vals, int num)
+{
+  if (accept_if_needed(purpose) != -1)
+    return get_strings(purpose_table[purpose], vals, num);
+  return -1;
+}
+
+int 
+send_float(Sock *sock, double num)
+{
+  int val;
+  val = swrite(sock, (char *)&num, sizeof(double), NULL);
+  if (val == -1) {
+    return -1;
+  }
+  return 0;
+}
+
+int 
+sock_send_float(int purpose, double num)
+{
+  if (accept_if_needed(purpose) != -1)
+    return send_float(purpose_table[purpose], num);
+  return -1;
+}
+
+int 
+send_sfloats(Sock *sock, float *vals,int  num)
+{
+  int i;
+  for(i=0; i<num; i++)
+    if (send_float(sock, (double) *vals++) == -1)
+      return -1;
+  return 0;
+}
+
+int 
+sock_send_sfloats(int purpose, float * vals, int num)
+{
+  if (accept_if_needed(purpose) != -1)
+    return send_sfloats(purpose_table[purpose], vals, num);
+  return -1;
+}
+
+int 
+send_floats(Sock *sock, double *vals, int num)
+{
+  int i;
+  for(i=0; i<num; i++)
+    if (send_float(sock, *vals++) == -1)
+      return -1;
+  return 0;
+}
+
+int 
+sock_send_floats(int purpose, double  *vals, int num)
+{
+  if (accept_if_needed(purpose) != -1)
+    return send_floats(purpose_table[purpose], vals, num);
+  return -1;
+}
+
+double 
+get_float(Sock *sock)
+{
+  double num = -1.0;
+  fill_buf(sock, (char *)&num, sizeof(double), "double");
+#ifdef DEBUG
+  fprintf(stderr,"get_float: received %f\n",num);
+#endif
+  return num;
+}
+
+double 
+sock_get_float(int purpose)
+{
+  if (accept_if_needed(purpose) != -1)
+    return get_float(purpose_table[purpose]);
+  else return 0.0;
+}
+
+int 
+get_sfloats(Sock *sock, float *vals, int num)
+{
+  int i;
+  for(i=0; i<num; i++)
+    *vals++ = (float) get_float(sock);
+  return 0;
+}
+
+
+int 
+sock_get_sfloats(int purpose,float * vals, int num)
+{
+  if (accept_if_needed(purpose) != -1)
+    return get_sfloats(purpose_table[purpose], vals, num);
+  return -1;
+}
+
+int 
+get_floats(Sock *sock,double *vals,int num)
+{
+  int i;
+  for(i=0; i<num; i++)
+    *vals++ = get_float(sock);
+  return 0;
+}
+
+
+int 
+sock_get_floats(int purpose, double *vals, int num)
+{
+  if (accept_if_needed(purpose) != -1)
+    return get_floats(purpose_table[purpose], vals, num);
+  return -1;
+}
+
+int 
+wait_for_client_kill(Sock *sock, int sig)
+{
+  int ret_val;
+  switch(sock->purpose) {
+  case SessionManager:
+  case ViewportServer:
+    sock_accept_connection(sock->purpose);
+    ret_val = send_signal(purpose_table[sock->purpose], sig);
+    sock->socket = 0;
+    return ret_val;
+  default:
+    sock->socket = 0;
+    return -1;
+  }
+}
+
+
+int 
+sock_get_remote_fd(int purpose)
+{
+  if (accept_if_needed(purpose) != -1)
+    return purpose_table[purpose]->remote_fd;
+  return -1;
+}
+
+int 
+send_signal(Sock *sock, int sig)
+{
+  int ret_val;
+  ret_val = kill(sock->pid, sig);
+  if (ret_val == -1 && errno == ESRCH) {
+    FD_CLR(sock->socket, &socket_mask);
+    purpose_table[sock->purpose] = NULL;
+/*    printf("   closing socket %d\n", sock->socket); */
+    close(sock->socket);
+    return wait_for_client_kill(sock, sig);
+  }
+  return ret_val;
+}
+
+int 
+sock_send_signal(int purpose,int  sig)
+{
+  if (accept_if_needed(purpose) != -1)
+    return send_signal(purpose_table[purpose], sig);
+  return -1;
+}
+
+int 
+send_wakeup(Sock *sock)
+{
+  return send_signal(sock, SIGUSR1);
+}
+
+int 
+sock_send_wakeup(int purpose)
+{
+  if (accept_if_needed(purpose) != -1)
+    return send_wakeup(purpose_table[purpose]);
+  return -1;
+}
+
+Sock *
+connect_to_local_server_new(char *server_name, int purpose, int time_out)
+{
+  int max_con=(time_out == 0 ? 1000000 : time_out), i, code=-1;
+  Sock *sock;
+  char name[256];
+
+  make_server_name(name, server_name);
+  sock = (Sock *) calloc(sizeof(Sock), 1);
+  if (sock == NULL) {
+    perror("allocating socket space");
+    return NULL;
+  }
+  sock->socket = socket(AF_UNIX, SOCK_STREAM, 0);
+  if (sock->socket < 0) {
+    perror("opening client socket");
+    return NULL;
+  }
+  memset(server[1].addr.u_addr.sa_data, 0,
+         sizeof(server[1].addr.u_addr.sa_data));
+  sock->addr.u_addr.sa_family = AF_UNIX;
+  strcpy(sock->addr.u_addr.sa_data, name);
+  for(i=0; i<max_con; i++) {
+    code = connect(sock->socket, &sock->addr.u_addr,
+                   sizeof(sock->addr.u_addr));
+    if (code == -1) {
+      if (errno != ENOENT && errno != ECONNREFUSED) {
+        perror("connecting server stream socket");
+        return NULL;
+      } else {
+        if (i != max_con - 1) sleep(1);
+        continue;
+      }
+    } else break;
+  }
+  if (code == -1) {
+    return NULL;
+  }
+  send_int(sock, getpid());
+  send_int(sock, purpose);
+  send_int(sock, sock->socket);
+  sock->pid = get_int(sock);
+  sock->remote_fd = get_int(sock);
+  return sock;
+}
+
+Sock *
+connect_to_local_server(char *server_name, int purpose, int time_out)
+{
+  int max_con=(time_out == 0 ? 1000000 : time_out), i, code=-1;
+  Sock *sock;
+  char name[256];
+
+  make_server_name(name, server_name);
+  sock = (Sock *) calloc(sizeof(Sock), 1);
+  if (sock == NULL) {
+    perror("allocating socket space");
+    return NULL;
+  }
+  sock->purpose = purpose;
+  /* create the socket */
+  sock->socket = socket(AF_UNIX, SOCK_STREAM, 0);
+  if (sock->socket < 0) {
+    perror("opening client socket");
+    return NULL;
+  }
+  /* connect socket using name specified in command line */
+  memset(server[1].addr.u_addr.sa_data, 0,
+         sizeof(server[1].addr.u_addr.sa_data));
+  sock->addr.u_addr.sa_family = AF_UNIX;
+  strcpy(sock->addr.u_addr.sa_data, name);
+  for(i=0; i<max_con; i++) {
+    code = connect(sock->socket, &sock->addr.u_addr,
+                   sizeof(sock->addr.u_addr));
+    if (code == -1) {
+      if (errno != ENOENT && errno != ECONNREFUSED) {
+        perror("connecting server stream socket");
+        return NULL;
+      } else {
+        if (i != max_con - 1) sleep(1);
+        continue;
+      }
+    } else break;
+  }
+  if (code == -1) {
+    return NULL;
+  }
+  send_int(sock, getpid());
+  send_int(sock, sock->purpose);
+  send_int(sock, sock->socket);
+  sock->pid = get_int(sock);
+/*  fprintf(stderr, "Got int form socket\n"); */
+  sock->remote_fd = get_int(sock);
+  return sock;
+}
+
+/* act as terminal session for sock connected to stdin and stdout of another
+   process */
+void 
+remote_stdio(Sock *sock)
+{
+  char buf[1024];
+  fd_set rd;
+  int len;
+  while (1) {
+    FD_ZERO(&rd);
+    FD_SET(sock->socket,&rd);
+    FD_SET(0, &rd);
+    len = sselect(FD_SETSIZE, (fd_set *)&rd, (fd_set *)0, (fd_set *)0, NULL);
+    if (len == -1) {
+      perror("stdio select");
+      return;
+    }
+    if (FD_ISSET(0, &rd)) {
+      fgets(buf,1024,stdin);
+      len = strlen(buf);
+      /*
+          gets(buf);
+          len = strlen(buf);
+          *(buf+len) = '\n';
+          *(buf+len+1) = '\0';
+      */
+      swrite(sock, buf, len, "writing to remote stdin");
+    }
+    if (FD_ISSET(sock->socket, &rd)) {
+      len = sread(sock, buf, 1024, "stdio");
+      if (len == -1)
+        return;
+      else {
+        *(buf + len) = '\0';
+        fputs(buf, stdout);
+        fflush(stdout);
+      }
+    }
+  }
+}
+
+/* initialize the table of dedicated sockets */
+void 
+init_purpose_table(void)
+{
+  int i;
+  for(i=0; i<TotalMaxPurposes; i++) {
+    purpose_table[i] = NULL;
+  }
+}
+
+
+int 
+make_server_number(void )
+{
+  spad_server_number = getpid();
+  return spad_server_number;
+}
+
+void 
+close_socket(int socket_num, char *name)
+{
+  close(socket_num);
+#ifndef RTplatform
+  unlink(name);
+#endif
+}
+
+int 
+make_server_name(char *name,char * base)
+{
+  char *num;
+  if (spad_server_number != -1) {
+    sprintf(name, "%s%d", base, spad_server_number);
+    return 0;
+  }
+  num = getenv("SPADNUM");
+  if (num == NULL) {
+/*    fprintf(stderr,
+      "\n(AXIOM Sockets) The AXIOM server number is undefined.\n");
+*/
+    return -1;
+  }
+  sprintf(name, "%s%s", base, num);
+  return 0;
+}
+
+/* client Spad server sockets.  Two sockets are created: server[0]
+   is the internet server socket, and server[1] is a UNIX domain socket. */
+int 
+open_server(char *server_name)
+{
+  char *s, name[256];
+
+  init_socks();
+  bsdSignal(SIGPIPE, sigpipe_handler,RestartSystemCalls);
+  if (make_server_name(name, server_name) == -1)
+    return -2;
+  /* create the socket internet socket */
+  server[0].socket = 0;
+/*  server[0].socket = socket(AF_INET, SOCK_STREAM, 0);
+  if (server[0].socket < 0) {
+    server[0].socket = 0;
+  } else {
+    server[0].addr.i_addr.sin_family = AF_INET;
+    server[0].addr.i_addr.sin_addr.s_addr = INADDR_ANY;
+    server[0].addr.i_addr.sin_port = 0;
+    if (bind(server[0].socket, &server[0].addr.i_addr,
+             sizeof(server[0].addr.i_addr))) {
+      perror("binding INET stream socket");
+      server[0].socket = 0;
+      return -1;
+    }
+    length = sizeof(server[0].addr.i_addr);
+    if (getsockname(server[0].socket, &server[0].addr.i_addr, &length)) {
+      perror("getting INET server socket name");
+      server[0].socket = 0;
+      return -1;
+    }
+    server_port = ntohs(server[0].addr.i_addr.sin_port);
+    FD_SET(server[0].socket, &socket_mask);
+    FD_SET(server[0].socket, &server_mask);
+    listen(server[0].socket,5);
+  } */
+  /* Next create the UNIX domain socket */
+  server[1].socket = socket(AF_UNIX, SOCK_STREAM, 0);
+  if (server[1].socket < 0) {
+    perror("opening UNIX server socket");
+    server[1].socket = 0;
+    return -2;
+  } else {
+    server[1].addr.u_addr.sa_family = AF_UNIX;
+    memset(server[1].addr.u_addr.sa_data, 0,
+           sizeof(server[1].addr.u_addr.sa_data));
+    strcpy(server[1].addr.u_addr.sa_data, name);
+    if (bind(server[1].socket, &server[1].addr.u_addr,
+             sizeof(server[1].addr.u_addr))) {
+      perror("binding UNIX server socket");
+      server[1].socket = 0;
+      return -2;
+    }
+    FD_SET(server[1].socket, &socket_mask);
+    FD_SET(server[1].socket, &server_mask);
+    listen(server[1].socket, 5);
+  }
+  s = getenv("SPADSERVER");
+  if (s == NULL) {
+/*    fprintf(stderr, "Not a spad server system\n"); */
+    return -1;
+  }
+  return 0;
+}
+
+int 
+accept_connection(Sock *sock)
+{
+  int client;
+  for(client=0; client<MaxClients && clients[client].socket != 0; client++);
+  if (client == MaxClients) {
+    printf("Ran out of client Sock structures\n");
+    return -1;
+  }
+  clients[client].socket = accept(sock->socket, 0, 0);
+  if (clients[client].socket == -1) {
+    perror("accept");
+    clients[client].socket = 0;
+    return -1;
+  }
+  FD_SET(clients[client].socket, &socket_mask);
+  get_socket_type(clients+client);
+  return clients[client].purpose;
+}
+
+/* reads a the socket purpose declaration for classification */
+void 
+get_socket_type(Sock *sock)
+{
+  sock->pid = get_int(sock);
+  sock->purpose = get_int(sock);
+  sock->remote_fd = get_int(sock);
+  send_int(sock, getpid());
+  send_int(sock, sock->socket);
+  purpose_table[sock->purpose] = sock;
+  switch (sock->purpose) {
+  case SessionManager:
+    break;
+  case ViewportServer:
+    break;
+  case MenuServer:
+    break;
+  case SessionIO:
+/*    redirect_stdio(sock); */
+    break;
+  }
+}
+
+int 
+sock_accept_connection(int purpose)
+{
+  fd_set rd;
+  int ret_val, i, p;
+  if (getenv("SPADNUM") == NULL) return -1;
+  while (1) {
+    rd = server_mask;
+    ret_val = sselect(FD_SETSIZE, (fd_set *)&rd, (fd_set *)0, (fd_set *)0, NULL);
+    if (ret_val == -1) {
+      /* perror ("Select"); */
+      return -1;
+    }
+    for(i=0; i<2; i++) {
+      if (server[i].socket > 0 && FD_ISSET(server[i].socket, &rd)) {
+        p = accept_connection(server+i);
+        if (p == purpose) return 1;
+      }
+    }
+  }
+}
+
+/* direct stdin and stdout from the given socket */
+void 
+redirect_stdio(Sock *sock)
+{
+  int fd;
+/*  setbuf(stdout, NULL);  */
+  fd = dup2(sock->socket, 1);
+  if (fd != 1) {
+    fprintf(stderr, "Error connecting stdout to socket\n");
+    return;
+  }
+  fd = dup2(sock->socket, 0);
+  if (fd != 0) {
+    fprintf(stderr, "Error connecting stdin to socket\n");
+    return;
+  }
+  fprintf(stderr, "Redirected standard IO\n");
+  FD_CLR(sock->socket, &socket_mask);
+}
+
+void
+init_socks(void)
+{
+  int i;
+  FD_ZERO(&socket_mask);
+  FD_ZERO(&server_mask);
+  init_purpose_table();
+  for(i=0; i<2; i++) server[i].socket = 0;
+  for(i=0; i<MaxClients; i++) clients[i].socket = 0;
+}
+
+/* Socket I/O selection called from the BOOT serverLoop function */
+
+int 
+server_switch(void)
+{
+  int ret_val, i, cmd = 0;
+  fd_set rd, wr, ex, fds_mask;
+  FD_ZERO(&rd);
+  FD_ZERO(&wr);
+  FD_ZERO(&ex);
+  fds_mask = server_mask;
+  cmd = 0;
+  if (purpose_table[SessionManager] != NULL) {
+    FD_SET(0, &fds_mask);
+    FD_SET(purpose_table[SessionManager]->socket, &fds_mask);
+  }
+  while (1) {
+    do {
+      if (purpose_table[MenuServer] != NULL) {
+        FD_SET(purpose_table[MenuServer]->socket, &fds_mask);
+      }
+      rd = fds_mask;
+      ret_val = select(FD_SETSIZE, (void *) &rd, (void *) 0, (void *) 0, (void *) 0);
+      if (ret_val == -1) {
+        /* perror ("Select in switch"); */
+        return -1;
+      }
+      for(i=0; i<2; i++) {
+        if (server[i].socket > 0 && (FD_ISSET(server[i].socket, &rd)))
+          accept_connection(server+i);
+      }
+    } while (purpose_table[SessionManager] == NULL);
+    FD_SET(purpose_table[SessionManager]->socket, &fds_mask);
+    if (FD_ISSET(purpose_table[SessionManager]->socket, &rd)) {
+      cmd = get_int(purpose_table[SessionManager]);
+      return cmd;
+    }
+    if (FD_ISSET(0, &rd)) {
+      return CallInterp;
+    }
+    if (purpose_table[MenuServer] != NULL &&
+        (FD_ISSET(purpose_table[MenuServer]->socket, &rd))) {
+      cmd = get_int(purpose_table[MenuServer]);
+      return cmd;
+    }
+  }
+}
+
+void 
+flush_stdout(void)
+{
+  static FILE *fp = NULL;
+  if (fp == NULL) {
+    fp = fdopen(purpose_table[SessionIO]->socket, "w");
+    if (fp == NULL) {
+      perror("fdopen");
+      return;
+    }
+  }
+  fflush(fp);
+}
+
+void 
+print_line(char *s)
+{
+  printf("%s\n", s);
+}
+
+
+typedef union {
+  double        f;
+  long          l[2];
+	} DoubleFloat;
+
+double 
+plus_infinity(void )
+{
+  static int init = 0;
+  static DoubleFloat pinf;
+  if (! init) {
+    pinf.l[0] = 0x7ff00000;
+    pinf.l[1] = 0;
+    init = 1;
+  }
+  return pinf.f;
+}
+
+double 
+minus_infinity(void)
+{
+  static int init = 0;
+  static DoubleFloat minf;
+  if (! init) {
+    minf.l[0] = 0xfff00000L;
+    minf.l[1] = 0;
+    init = 1;
+  }
+  return minf.f;
+}
+
+double 
+NANQ(void)
+{
+  static int init = 0;
+  static DoubleFloat nanq;
+  if (! init) {
+    nanq.l[0] = 0x7ff80000L;
+    nanq.l[1] = 0;
+    init = 1;
+  }
+  return nanq.f;
+}
+\end{chunk}
+
+\section{spadcolors.c}
+\begin{chunk}{spadcolors.c}
+
+#include <X11/Xlib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+\getchunk{include/spadcolors.h}
+\getchunk{include/spadcolors.h1}
+\getchunk{include/util.h1}
+
+#if 0 
+int colors[100];
+#endif
+
+static unsigned long    pixels[smoothConst+1];
+
+
+/*
+ * make sure you define a global variable like int *spadColors; in the main
+ * program
+ */
+
+/*
+ * code taken from Foley and Van Dam "Fundamentals of Interactive Computer
+ * Graphics"
+ */
+
+
+
+RGB
+HSVtoRGB(HSV hsv)
+{
+    RGB rgb;
+    float h, f, p, q, t;
+    int i;
+    
+    rgb.r = 0.0;
+    rgb.g = 0.0;
+    rgb.b = 0.0;
+    if (hsv.s == 0.0) {
+        rgb.r = rgb.g = rgb.b = hsv.v;
+        return (rgb);
+    }
+    else {
+        if (hsv.h == 360.0) {
+            hsv.h = 0.0;
+        }
+        h = hsv.h / 60;
+        i = floor(h);
+        f = h - i;
+        p = hsv.v * (1 - hsv.s);
+        q = hsv.v * (1 - (hsv.s * f));
+        t = hsv.v * (1 - (hsv.s * (1 - f)));
+        switch (i) {
+          case 0:
+            rgb.r = hsv.v;
+            rgb.g = t;
+            rgb.b = p;
+            break;
+          case 1:
+            rgb.r = q;
+            rgb.g = hsv.v;
+            rgb.b = p;
+            break;
+          case 2:
+            rgb.r = p;
+            rgb.g = hsv.v;
+            rgb.b = t;
+            break;
+          case 3:
+            rgb.r = p;
+            rgb.g = q;
+            rgb.b = hsv.v;
+            break;
+          case 4:
+            rgb.r = t;
+            rgb.g = p;
+            rgb.b = hsv.v;
+            break;
+          case 5:
+            rgb.r = hsv.v;
+            rgb.g = p;
+            rgb.b = q;
+            break;
+        }
+        return (rgb);
+    }
+}
+
+float
+value(float n1, float n2, float hue)
+{
+    float v;
+
+    if (hue > 360.0)
+        hue -= 360.0;
+    if (hue < 0.0)
+        hue += 360.0;
+    if (hue < 60.0) {
+        v = n1 + (n2 - n1) * hue / 60.0;
+    }
+    else {
+        if (hue < 180.0)
+            v = n2;
+        else {
+            if (hue < 240.0)
+                v = n1 + (n2 - n1) * (240.0 - hue) / 60.0;
+            else
+                v = n1;
+        }
+    }
+    return (v);
+}
+
+
+
+RGB
+HLStoRGB(HLS hls)
+{
+    RGB rgb;
+    float m1, m2;
+
+    if (hls.l <= 0.5) {
+        m2 = hls.l * (1.0 + hls.s);
+    }
+    else {
+        m2 = hls.l + hls.s - hls.l * hls.s;
+    }
+    m1 = 2.0 * hls.l - m2;
+    rgb.r = value(m1, m2, hls.h + 120.0);
+    rgb.g = value(m1, m2, hls.h);
+    rgb.b = value(m1, m2, hls.h - 120.0);
+
+    return (rgb);
+}
+
+
+/******************************************************
+ * int makeColors(dsply,scrn,colorMap,total_Shades)    *
+ *                                                    *
+ * This routine tries to allocate an adequate color   *
+ * map to be used by all the AXIOM applications       *
+ * that are to be run under X Windows that use        *
+ * colors that may be user-definable (e.g. viewports, *
+ * HyperTeX, etc). All these application should call  *
+ * this routine and then access the colors with the   *
+ * the returned color map.                            *
+ * For example, the following creates the map and     *
+ * then sets the foreground color for a GC:           *
+ *                                                    *
+ *   i = makeColors(d,s,&cmap,&spadColors,&ts);       *
+ *   XSetForegroundColor(d,gc,spadColors[3]);         *
+ *                                                    *
+ * where                                              *
+ * spadColors is of type (unsigned long *)            *
+ * i (the return value) is the total number of colors *
+ *   allocated.                                       *
+ * ts is the total number of shades for each hue      *
+ *                                                    *
+ * KF 6/14/90 (modification)                          *
+ * makeColors creates color table once only.          *
+ * hiya is of type static.                            *
+ ******************************************************/
+
+int
+makeColors(Display *dsply, int scrn, Colormap *colorMap, 
+           unsigned long **colorIndex, int *total_Shades)
+{
+
+    int h, s;
+    static unsigned long *hiya; /* keep colortable around for next time */
+    HSV hsv;
+    RGB rgb;
+    XColor color;
+    int okay = yes;             /* is true (1) so long as XAllocColor is
+                                 * working ok. if 0, then we ran out of room
+                                 * on the color table. */
+    int colorNum;
+
+    /* shade5 definition */
+
+    static float saturations[5] = {0.90, 0.80, 0.74, 0.50, 0.18};
+    static float values[5] = {0.38, 0.58, 0.75, 0.88, 0.94};
+
+    /* static float values[5]      = {0.34, 0.52, 0.80, 0.88, 0.94}; */
+
+    /*     fprintf(stderr,"makeColors called\n");*/
+
+    /* printf("making new colors....\n"); */
+    *total_Shades = totalShadesConst;
+
+    /* space for color table */
+    hiya = (unsigned long *) saymem("spadcolors30.c", 
+             totalHuesConst * (*total_Shades) + 2, sizeof(unsigned long));
+    *colorIndex = hiya;
+
+    for (h = 0, colorNum = 0; okay && h < 60; h += (hueStep - 6)) {
+        for (s = 0; okay && s < *total_Shades; s++) {
+            hsv.h = h;
+            hsv.s = saturations[s];
+            hsv.v = values[s];
+            rgb = HSVtoRGB(hsv);
+            color.red    = rgb.r *((1<<16)-1);
+            color.green  = rgb.g *((1<<16)-1);
+            color.blue   = rgb.b *((1<<16)-1);
+            color.flags = DoRed | DoGreen | DoBlue;
+            /*
+            fprintf(stderr,"%f\t%f\t%f\n",rgb.r,rgb.g,rgb.b);
+            fprintf(stderr,"%d\t%d\t%d\n",
+                    color.red,color.green,color.blue);
+              */
+            if ((okay = XAllocColor(dsply, *colorMap, &color)))
+                hiya[colorNum++] = color.pixel; /* hiya points to table */
+        }                       /* for s */
+    }                           /* for h */
+    for (h = 60; okay && h < 180; h += 20) {
+        for (s = 0; okay && s < *total_Shades; s++) {
+            hsv.h = h;
+            hsv.s = saturations[s];
+            hsv.v = values[s];
+            rgb = HSVtoRGB(hsv);
+
+            color.red    = rgb.r *((1<<16)-1);
+            color.green  = rgb.g *((1<<16)-1);
+            color.blue   = rgb.b *((1<<16)-1);
+            color.flags = DoRed | DoGreen | DoBlue;
+            /* 
+            fprintf(stderr,"%f\t%f\t%f\n",rgb.r,rgb.g,rgb.b);
+            fprintf(stderr,"%d\t%d\t%d\n",
+                    color.red,color.green,color.blue);
+            */
+
+            if ((okay = XAllocColor(dsply, *colorMap, &color)))
+                hiya[colorNum++] = color.pixel;
+        }
+    }
+
+    for (h = 180; okay && h <= 300; h += hueStep) {
+        for (s = 0; okay && s < *total_Shades; s++) {
+            hsv.h = h;
+            hsv.s = saturations[s];
+            hsv.v = values[s];
+            rgb = HSVtoRGB(hsv);
+
+            color.red    = rgb.r *((1<<16)-1);
+            color.green  = rgb.g *((1<<16)-1);
+            color.blue   = rgb.b *((1<<16)-1);
+            color.flags = DoRed | DoGreen | DoBlue;
+            /* 
+            fprintf(stderr,"%f\t%f\t%f\n",rgb.r,rgb.g,rgb.b);
+            fprintf(stderr,"%d\t%d\t%d\n",
+                    color.red,color.green,color.blue);
+               */
+            if ((okay = XAllocColor(dsply, *colorMap, &color)))
+                hiya[colorNum++] = color.pixel;
+        }
+    }
+
+    hiya[colorNum++] = BlackPixel(dsply, scrn);
+    hiya[colorNum++] = WhitePixel(dsply, scrn);
+
+    if (colorNum < (totalShadesConst * totalHuesConst + 2)) {
+        free(*colorIndex);
+        fprintf(stderr,
+           "    > Warning: cannot allocate all the necessary colors");
+        fprintf(stderr," - switching to monochrome mode\n");
+        *colorIndex = (unsigned long *) 
+           saymem("while allocating the colormap for AXIOM ", 
+                  2, sizeof(unsigned long));
+        (*colorIndex)[0] = BlackPixel(dsply, scrn);
+        (*colorIndex)[1] = WhitePixel(dsply, scrn);
+        return (-1);
+    }
+
+    return (colorNum);
+}
+
+#ifdef OLD
+/***********************************************************************
+  KF 6/14/90
+  INPUT: display dsply, screen scrn
+  OUTPUT: a pointer to the permutation color vector (permIndex)
+  PURPOSE: when called for the first time, this procedure creates a
+       permutation vector of the color table spadColor.  It
+       returns the pointer to this vector for subsequent calls.
+
+***********************************************************************/
+
+int
+makePermVector(Display *dsply, int scrn, unsigned long **permIndex)
+{
+    static int firstTime = yes;
+    unsigned long *spadColorsToo;
+    static unsigned long *pIndex;
+    Colormap cmap;
+    int num_colors;
+    int i, ts;
+
+    if (firstTime) {
+
+        /* initialization */
+
+        cmap = DefaultColormap(dsply, scrn);    /* what are other cmaps?? */
+        pIndex = (unsigned long *) 
+          saymem("makePermVector", Colorcells, sizeof(unsigned long));
+
+        /* get spadColors table */
+
+        if ((num_colors = 
+              makeColors(dsply, scrn, &cmap, &spadColorsToo, &ts)) < 0) {
+            printf("num_colors < 0!!\n");
+            exit(-1);
+        }
+
+        /* initialize unused slots in permutation vector */
+
+        for (i = 0; i < spadColorsToo[0]; i++)
+            pIndex[i] = 0;
+        for (i = num_colors; i < Colorcells; i++)
+            pIndex[i] = 0;
+
+        /* make permutation vector */
+
+        for (i = 0; i < num_colors; i++)
+            pIndex[spadColorsToo[i]] = i;
+
+        firstTime = no;
+    }
+
+    *permIndex = pIndex;
+    return (Colorcells);
+}
+
+#endif
+
+/******************************************************
+ * int makeNewColorMap(dsply,colorMap,smoothHue)      *
+ *                                                    *
+ * This routine tries to allocate an adequate color   *
+ * map to be used by the AXIOM smooth shading         *
+ * application that is to be run under X Windows.     *
+ * The colors are allocated from available space in   *
+ * the colorMap and returned in the array pixels.     *
+ * The size of the array is determined by smoothConst *
+ * which is the number of shades desired.  The colors *
+ * returned are variations in lightness of the hue    *
+ * smoothHue indicated on the control panel Colormap. *
+ *                                                    *
+ * If smoothConst colors can be allocated the value   *
+ * 1 is returned, otherwise returns 0                 *
+ *                                                    *
+ ******************************************************/
+
+
+int
+makeNewColorMap(Display *dsply, Colormap colorMap, int smoothHue)
+
+{
+
+    int count, i;
+    float lightness;
+    RGB rgb;
+    XColor xcolor;
+    HLS hls;
+
+    count = 0;
+    /* i = 0 .. smoothConst */
+    for (i = 0; i < (smoothConst + 1); i++) {
+        /* lightnes = 0.0 .. 1.0 */
+        lightness = (float) (i) / (float) (smoothConst);  
+        hls.h = (float) smoothHue;
+        hls.l = lightness;
+        hls.s = saturation;
+        rgb = HLStoRGB(hls);
+
+        xcolor.red    = rgb.r *((1<<16)-1);
+        xcolor.green  = rgb.g *((1<<16)-1);
+        xcolor.blue   = rgb.b *((1<<16)-1);
+        xcolor.flags = DoRed | DoGreen | DoBlue;
+        /* 
+        fprintf(stderr,"%f\t%f\t%f\n",rgb.r,rgb.g,rgb.b);
+        fprintf(stderr,"%d\t%d\t%d\n",
+                xcolor.red,xcolor.green,xcolor.blue);
+        */
+        if (XAllocColor(dsply, colorMap, &xcolor)) {
+            pixels[count] = xcolor.pixel;
+            count++;
+        }
+    }
+    /* count says how many succeeded */
+    if (count != (smoothConst+1) ) {
+
+      /* we have failed to get all of them - free the ones we got */
+
+      FreePixels(dsply,colorMap,count);
+      return (0);
+    }
+    return (1);
+}
+
+
+
+/******************************************************
+ * unsigned long XPixelColor(num)                     *
+ *                                                    *
+ * XPixelColor is a straight forward function that    *
+ * merely returns the XColor value desired within     *
+ * the pixels array.  For smooth shading, given an    *
+ * intensity from 0..1, scaling by the number of      *
+ * values in the array will return the location in    *
+ * pixels[] of the desired color for that intensity.  *
+ *                                                    *
+ ******************************************************/
+
+unsigned long
+XPixelColor(int num)
+
+{
+    if (num < 0)
+        num = 0;
+    return (pixels[num]);
+}
+
+
+/******************************************************
+ * FreePixels(dsply,colorMap,num)                 *
+ *                                                    *
+ * FreePixels is a call to XFreeColors which frees    *
+ * previously allocated colors for the indicated      *
+ * colorMap.  If it cannot free the number of colors  *
+ * given by num a BadAccess error will crash the      *
+ * viewport process.  This should ONLY be used if     *
+ * it can be guaranteed that there will be num colors *
+ * to free in colorMap. return 0 == success           *
+ *                                                    *
+ ******************************************************/
+
+
+void
+FreePixels(Display *dsply, Colormap colorMap, int num)
+{
+
+  XFreeColors(dsply, colorMap, pixels, num, 0);
+}
+
+
+
+/******************************************************
+ * int AllocCells(dsply,colorMap,smoothHue)           *
+ *                                                    *
+ * Use either makeNewColormap() OR AllocCells().      *
+ * This routine tries to allocate an adequate color   *
+ * map to be used by the AXIOM smooth shading         *
+ * application that is to be run under X Windows.     *
+ * The colors are allocated from available space in   *
+ * the colorMap and returned in the array pixels.     *
+ * The size of the array is determined by smoothConst *
+ * which is the number of shades desired.  The colors *
+ * returned are variations in lightness of the hue    *
+ * smoothHue indicated on the control panel Colormap. *
+ *                                                    *
+ * It is different from makeNewColormap() in that     *
+ * the cells are read/write, and if it cannot alloc   *
+ * all the colors desired it doesn't allocate any.    *
+ *                                                    *
+ ******************************************************/
+
+
+int
+AllocCells(Display *dsply, Colormap colorMap, int smoothHue)
+\end{chunk}
+
+This routine used to have the following code block. However this
+code block makes no sense. To see why you need to know that an
+XColor object looks like:
+
+\begin{verbatim}
+/*
+ * Data structure used by color operations
+ */
+typedef struct {
+        unsigned long pixel;
+        unsigned short red, green, blue;
+        char flags;  /* do_red, do_green, do_blue */
+        char pad;
+} XColor;
+\end{verbatim}
+This routine used to set the values of all of the elements of the XColor struct
+except [[pixel]]. This is usually done to specify a desired color in RGB
+values. To try to get a pixel value close to that color you call XAllocColor.
+This routine sets up the desired color values but it never asks for the pixel
+(which is really an index into the colormap of the nearest color) value that
+corresponds to the desired color. In fact it uses pixel without ever giving
+it a value. I've rewritten that code.
+\begin{verbatim}
+{
+    unsigned long plane_masks[1];
+    int i, count;
+    float lightness;
+    RGB rgb;
+    XColor xcolor;
+    HLS hls;
+
+    count = 0;
+    for (i = 0; i < (smoothConst + 1); i++) {
+        lightness = (float) (i) / (float) (smoothConst);
+        hls.h = (float) smoothHue;
+        hls.l = lightness;
+        hls.s = saturation;
+        rgb = HLStoRGB(hls);
+        xcolor.red    = rgb.r *((1@<<16)-1);
+        xcolor.green  = rgb.g *((1@<<16)-1);
+        xcolor.blue   = rgb.b *((1@<<16)-1);
+        xcolor.flags = DoRed | DoGreen | DoBlue;
+        /*
+        fprintf(stderr,"%f\t%f\t%f\n",rgb.r,rgb.g,rgb.b);
+        fprintf(stderr,"%d\t%d\t%d\n",
+                xcolor.red,xcolor.green,xcolor.blue);
+        */
+        pixels[i] = xcolor.pixel;
+        count++;
+    }
+    if (XAllocColorCells(dsply, colorMap, False, 
+                   plane_masks, 0, pixels, smoothConst + 1)) {
+        return (smoothConst + 1);
+    }
+    else {
+        return (0);
+    }
+}
+\end{verbatim}
+\begin{chunk}{spadcolors.c}
+{
+    unsigned long plane_masks[1];
+    int i, count;
+    float lightness;
+    RGB rgb;
+    XColor xcolor;
+    HLS hls;
+
+    count = 0;
+    for (i = 0; i < (smoothConst + 1); i++) {
+        lightness = (float) (i) / (float) (smoothConst);
+        hls.h = (float) smoothHue;
+        hls.l = lightness;
+        hls.s = saturation;
+        rgb = HLStoRGB(hls);
+        xcolor.red    = rgb.r *((1<<16)-1);
+        xcolor.green  = rgb.g *((1<<16)-1);
+        xcolor.blue   = rgb.b *((1<<16)-1);
+        xcolor.flags = DoRed | DoGreen | DoBlue;
+        /*
+        fprintf(stderr,"%f\t%f\t%f\n",rgb.r,rgb.g,rgb.b);
+        fprintf(stderr,"%d\t%d\t%d\n"
+                ,xcolor.red,xcolor.green,xcolor.blue);
+        */
+\end{chunk}
+
+Here I've modified the code to actually as for the pixel (colormap index) that
+most closely matches our requested RGB values.
+
+\begin{chunk}{spadcolors.c}
+        if (XAllocColor(dsply, colorMap, &xcolor)) { 
+            pixels[count] = xcolor.pixel;
+            count++;
+        }
+    }
+    /* count says how many succeeded */
+    if (count != (smoothConst+1) ) {
+      /* we have failed to get all of them - free the ones we got */
+      FreePixels(dsply,colorMap,count);
+      return (0);
+    }
+    if (XAllocColorCells(dsply, colorMap, False, 
+                plane_masks, 0, pixels, smoothConst + 1)) {
+        return (smoothConst + 1);
+    }
+    else {
+        return (0);
+    }
+}
+\end{chunk}
+
+\section{util.c}
+\begin{chunk}{util.c}
+
+#include <stdlib.h>
+\end{chunk}
+
+The MACOSX platform is broken because no matter what you do it seems to
+include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
+systems these files include themselves which causes an infinite regression
+of includes that fails. GCC gracefully steps over that problem but the
+build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
+of files are badly broken with respect to the [[/usr/include]] versions.
+
+\begin{chunk}{util.c}
+#if defined(MACOSXplatform)
+#include "/usr/include/unistd.h"
+#else
+#include <unistd.h>
+#endif
+#include <sys/types.h>
+#include <stdio.h>
+#include <errno.h>
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+\getchunk{include/view.h}
+
+\getchunk{include/util.h1}
+
+int
+checker(int code, int lineNumber, char *errorStr)
+{
+  if (code < 0) {
+    fprintf(stderr, "Error occured during %s\n", errorStr);
+    fprintf(stderr, "Error code of %d\n", errno);
+    fprintf(stderr, "Error in line number %d of process %d\n", 
+            lineNumber, getpid());
+    perror("");
+  }
+  return (code);
+}
+
+char *
+getmemWithLine(int nbytes, char *str, int lineNum)
+{
+  char *p;
+
+  p = (char *) malloc(nbytes);
+  if (!p) {
+    fprintf(stderr, 
+      "getmem: Could not get %d bytes for %s at line %d\n", 
+      nbytes, str, lineNum);
+    exit(99);
+  }
+  return p;
+}
+
+char *
+saymemWithLine(char *str, int num, int size, int lineNum)
+{
+  char *p;
+  p = getmemWithLine(num * size, str, lineNum);
+  return p;
+}
+
+void
+myfree(void *p, int size)
+{
+    free(p);
+}
+
+XPoint
+getWindowPositionXY(Display *display, Window w)
+{
+  XPoint position;
+  Window rootW, parentW, *childrenWs, tmpW;
+  unsigned int nChildren;
+  XWindowAttributes windowAttrib;
+  int screen, tmp = 1;
+
+  screen = DefaultScreen(display);
+  tmpW = w;
+  while (tmp) {
+    XQueryTree(display, tmpW, &rootW, &parentW, &childrenWs, &nChildren);
+    XFree((char *)childrenWs);
+    if (parentW == RootWindow(display, screen))
+      tmp = 0;
+    else
+      tmpW = parentW;
+  }
+  XGetWindowAttributes(display, tmpW, &windowAttrib);
+  position.x = (short) windowAttrib.x;
+  position.y = (short) windowAttrib.y;
+  return (position);
+}
+
+XPoint
+getWindowSizeXY(Display *display,Window w)
+{
+  XPoint size;
+  Window rootW, parentW, *childrenWs, tmpW;
+  unsigned int nChildren;
+  XWindowAttributes windowAttrib;
+  int screen, tmp = 1;
+
+  screen = DefaultScreen(display);
+  tmpW = w;
+  while (tmp) {
+    XQueryTree(display, tmpW, &rootW, &parentW, &childrenWs, &nChildren);
+    XFree((char *)childrenWs);
+    if (parentW == RootWindow(display, screen))
+      tmp = 0;
+    else
+      tmpW = parentW;
+  }
+  XGetWindowAttributes(display, tmpW, &windowAttrib);
+  size.x = (short) windowAttrib.width;
+  size.y = (short) windowAttrib.height;
+  return (size);
+}
+\end{chunk}
+
+\section{wct.c}
+\begin{chunk}{wct.c}
+
+/*
+ * Word completion.
+ *
+ *
+ * Word completion is driven from a list of completion tables. Each table
+ * contains a list of words.
+ *
+ */
+
+
+#include <stdio.h>
+#include <stdlib.h>
+\end{chunk}
+
+The MACOSX platform is broken because no matter what you do it seems to
+include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
+systems these files include themselves which causes an infinite regression
+of includes that fails. GCC gracefully steps over that problem but the
+build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
+of files are badly broken with respect to the [[/usr/include]] versions.
+
+\begin{chunk}{wct.c}
+#if defined(MACOSXplatform)
+#include "/usr/include/unistd.h"
+#else
+#include <unistd.h>
+#endif
+#include <string.h>
+#include <fcntl.h>
+#if defined(MACOSXplatform)
+#include "/usr/include/time.h"
+#else
+#include <time.h>
+#endif
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+/* #define PINFO *//* A flag to suppress printing of the file info */
+
+#define WCT                     /* A flag needed because ctype.h stole some
+                                 * of my constants */
+\getchunk{include/edible.h}
+
+#define MAX_PREFIX 1024
+#define strneql(a,b,n)  (*(a) == *(b) && !strncmp((a),(b),(n)))
+#define Delimiter(c) (! isalnum(c) && c != '%' && c != '!' && c != '?' && c != '_')
+
+
+\getchunk{include/wct.h1}
+\getchunk{include/prt.h1}
+\getchunk{include/edin.h1}
+
+
+
+static Wct *pwct = 0;
+static Wix *pwix;
+static Wix curr_wix;
+static char curr_prefix[MAX_PREFIX];
+static Wct *pHeadwct;
+
+time_t
+ftime(char *path)
+{
+    int rc;
+    struct stat stbuf;
+
+    rc = stat(path, &stbuf);
+    if (rc == -1)
+        fatal("Cannot deterimine status of %s.", path);
+
+    return stbuf.st_mtime;
+}
+
+off_t
+fsize(char *path)
+{
+    int rc;
+    struct stat stbuf;
+
+    rc = stat(path, &stbuf);
+    if (rc == -1)
+        fatal("Cannot deterimine status of %s.", path);
+
+    return stbuf.st_size;
+}
+
+
+/*
+ * Scan a word completion table for a particular word.
+ */
+
+
+Wix *
+scanWct(Wct *pwct, char *prefix)
+{
+    long fmod;
+    int preflen, i, wc;
+    char **wv;
+
+    preflen = strlen(prefix);
+    strncpy(curr_prefix, prefix, MAX_PREFIX);
+
+    pHeadwct = pwct;
+    curr_wix.pwct = 0;
+    curr_wix.word = 0;
+
+    for (; pwct; pwct = pwct->next) {
+        curr_wix.pwct = pwct;
+
+
+
+        fmod = ftime(pwct->fname);
+        if (fmod > pwct->ftime)
+            reintern1Wct(pwct);
+
+        wv = pwct->wordv;
+        wc = pwct->wordc;
+        for (i = 0; i < wc; i++) {
+            curr_wix.word = i;
+            if (strneql(wv[i], prefix, preflen))
+                return &curr_wix;
+        }
+    }
+    return 0;
+}
+
+Wix *
+rescanWct(void)
+{
+  Wct *pwct, *start_pwct;
+  int preflen, start_word, i, wc;
+  char **wv, *prefix;
+
+  start_pwct = curr_wix.pwct;
+  start_word = curr_wix.word;
+
+  if (!start_pwct) return(0);
+  prefix = curr_prefix;
+  preflen = strlen(prefix);
+
+  /*
+   * Finish the current structure.
+   */
+
+  pwct = start_pwct;
+
+  curr_wix.pwct = pwct;
+  wv = pwct->wordv;
+  wc = pwct->wordc;
+  for (i = start_word + 1; i < wc; i++) {
+    curr_wix.word = i;
+    if (strneql(wv[i], prefix, preflen))
+      return &curr_wix;
+  }
+
+  /*
+   * Finish to the end of the list, doing whole structures.
+   */
+  for (pwct = pwct->next; pwct; pwct = pwct->next) {
+    curr_wix.pwct = pwct;
+
+    wv = pwct->wordv;
+    wc = pwct->wordc;
+    for (i = 0; i < wc; i++) {
+      curr_wix.word = i;
+      if (strneql(wv[i], prefix, preflen))
+	return &curr_wix;
+    }
+  }
+
+  /*
+   * Restart at beginning, doing whole structures.
+   */
+  for (pwct = pHeadwct; pwct != start_pwct; pwct = pwct->next) {
+    curr_wix.pwct = pwct;
+
+    wv = pwct->wordv;
+    wc = pwct->wordc;
+    for (i = 0; i < wc; i++) {
+      curr_wix.word = i;
+      if (strneql(wv[i], prefix, preflen))
+	return &curr_wix;
+    }
+  }
+
+  /*
+   * Do beginning half of the start structure.
+   */
+  curr_wix.pwct = pwct;
+  wv = pwct->wordv;
+  wc = pwct->wordc;
+  for (i = 0; i <= start_word; i++) {
+    curr_wix.word = i;
+    if (strneql(wv[i], prefix, preflen))
+      return &curr_wix;
+  }
+
+  /* Not found? */
+  return 0;
+}
+
+/*
+ * Summarize a table.
+ */
+void
+skimWct(Wct *pwct)
+{
+  while (pwct) {
+#ifdef PINFO
+    skim1Wct(pwct);
+#endif
+    pwct = pwct->next;
+  }
+}
+
+void 
+skim1Wct(Wct *pwct)
+{
+#define NHEAD    13
+#define NTAIL    7
+
+  int cc;
+
+  printf("%-10s", pwct->fname);
+  printTime((long *)&(pwct->ftime));
+  cc = skimString(pwct->fimage, pwct->fsize, NHEAD, NTAIL);
+  printf("%s", "            " + (cc - (NHEAD + NTAIL)));
+  printf(" [%d w, %ld c]", pwct->wordc, (long)(pwct->fsize));
+  printf("\n");
+
+#ifdef SHOW_WORDS
+  {
+    int i;
+    char **wv;
+
+    for (i = 1, wv = pwct->wordv; *wv; i++, wv++) {
+      printf("%5d: %s\n", i, *wv);
+    }
+  }
+#endif
+}
+
+void
+printTime(long *clock)
+{
+    struct tm *tm;
+
+    tm = localtime((time_t *)clock);
+    printf("%.2d/%.2d/%.2d %.2d:%.2d:%.2d ",
+           tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
+           tm->tm_hour, tm->tm_min, tm->tm_sec);
+}
+
+int
+skimString(char *s, int slen,int  nhead,int  ntail)
+{
+    int spos, tlen, i, cc;
+
+    cc = printf("\"");
+    for (spos = 0; spos < slen && cc <= nhead; spos++)
+        cc += prChar(s[spos]);
+
+    /* Assume same tail has the same multi-character format ratio. */
+    tlen = ntail * ((1.0 * spos) / nhead);
+
+    if (spos + tlen >= slen)
+        for (; spos < slen; spos++)
+            cc += prChar(s[spos]);
+    else {
+        cc += printf("\"...\"");
+        for (i = slen - tlen; i < slen; i++)
+            cc += prChar(s[i]);
+    }
+    cc += printf("\"");
+    return cc;
+}
+
+int
+prChar(int c)
+{
+    if (c == '\n')
+        return printf("\\n");
+    if (c == '\t')
+        return printf("\\t");
+    if (c == '\b')
+        return printf("\\b");
+    if (c == '"')
+        return printf("\\\"");
+    if (iscntrl(c))
+        return printf("^%c", (c + 0100) % 0200);
+    if (isascii(c))
+        return printf("%c", c);
+
+    return printf("\\%d", c);
+}
+
+Wct *
+reread1Wct(Wct *pwct)
+{
+    int fd, rc;
+
+    /* Check information about the file. */
+    pwct->fsize = fsize(pwct->fname);
+    pwct->ftime = ftime(pwct->fname);
+
+    /* Allocate space for file image */
+    if (pwct->fimage)
+        free(pwct->fimage);
+    pwct->fimage = (char *) malloc(pwct->fsize + 1);
+    if (pwct->fimage == 0)
+        sfatal("Cannot allocate new table.");
+    pwct->fimage[pwct->fsize] = 0;
+
+    /* Read file into buffer. */
+    fd = open(pwct->fname, O_RDONLY);
+    if (fd == -1)
+        fatal("Cannot read file %s.", pwct->fname);
+    rc = read(fd, pwct->fimage, pwct->fsize);
+    if (rc != pwct->fsize)
+        fatal("Did not read all of file %s.", pwct->fname);
+
+    return pwct;
+}
+
+Wct *
+read1Wct(char *fname)
+{
+    Wct *pwct;
+
+    /* Allocate a new link for this file. */
+    pwct = (Wct *) malloc(sizeof(Wct));
+    if (pwct == 0)
+        sfatal("Cannot allocate new table.");
+
+    pwct->fname = fname;
+    pwct->wordc = 0;
+    pwct->wordv = 0;
+    pwct->fimage = 0;
+    pwct->next = 0;
+
+    return reread1Wct(pwct);
+}
+
+Wct *
+nconcWct(Wct *pwct,Wct * qwct)
+{
+    Wct *p0 = pwct;
+
+    if (!p0)
+        return qwct;
+
+    while (pwct->next)
+        pwct = pwct->next;
+    pwct->next = qwct;
+
+    return p0;
+}
+
+void
+sortWct(Wct *pwct)
+{
+    while (pwct) {
+        sort1Wct(pwct);
+        pwct = pwct->next;
+    }
+}
+
+void 
+sort1Wct(Wct *pwct)
+{
+    qsort((char *) pwct->wordv, pwct->wordc,
+          sizeof(*(pwct->wordv)), mystrcmp);
+}
+
+int
+mystrcmp(const void *s1,const void * s2)
+{
+    return strcmp(*(char **)s1, *(char **)s2);
+}
+
+/*
+ * Break wct struct into words.
+ */
+
+void 
+burstWct(Wct *pwct)
+{
+    while (pwct) {
+        burst1Wct(pwct);
+        pwct = pwct->next;
+    }
+}
+
+void 
+burst1Wct(Wct *pwct)
+{
+    char *s, **wv;
+    int i, j, inword = 0;
+
+
+    for (s = pwct->fimage, i = 0; i < pwct->fsize; s++, i++) {
+        if (isspace(*s) || iscntrl(*s)) {
+            *s = 0;
+            inword = 0;
+        }
+        else if (!inword) {
+            inword = 1;
+            pwct->wordc++;
+        }
+    }
+
+    if (pwct->wordv)
+        free(pwct->wordv);
+    pwct->wordv = (char **) calloc(pwct->wordc + 1, sizeof(char *));
+    if (!pwct->wordv)
+        fatal("Could not make word list for %s.", pwct->fname);
+
+    s = pwct->fimage;
+    i = 0;
+    for (wv = pwct->wordv, j = 0; j < pwct->wordc; wv++, j++) {
+        while (i < pwct->fsize && !s[i])
+            i++;
+        *wv = s + i;
+        while (i < pwct->fsize && s[i])
+            i++;
+    }
+    *wv = 0;
+}
+
+Wct *
+intern1Wct(char *fname)
+{
+    Wct *pwct;
+
+    pwct = read1Wct(fname);
+    burst1Wct(pwct);
+    return pwct;
+}
+
+void 
+reintern1Wct(Wct *pwct)
+{
+    reread1Wct(pwct);
+    burst1Wct(pwct);
+}
+
+void 
+sfatal(char *s)
+{
+    fatal("%s", s);
+}
+
+void 
+fatal(char *fmt,char * s)
+{
+    static char fbuf[256];
+
+    sprintf(fbuf, fmt, s);
+
+    perror(fbuf);
+    exit(1);
+}
+
+
+
+/* load up the wct database */
+void 
+load_wct_file(char *fname)
+{
+    pwct = nconcWct(intern1Wct(fname), pwct);
+}
+
+void
+skim_wct(void)
+{
+    skimWct(pwct);
+}
+
+/*
+ * This routine is called when a tab is hit. It simply takes the current
+ * buffer and tries to find a completion of the last word on the line in the
+ * data base.
+ */
+
+
+void 
+rescan_wct(void)
+{
+    int b = curr_pntr - 1;
+    int old_len;
+    int new_len;
+    int diff;
+    int i;
+    int ncs = 0;
+
+    /*
+     * first thing I should do is find my way back to the beginning of the
+     * word
+     */
+    while (b && !Delimiter(buff[b]))
+        b--;
+    if (Delimiter(buff[b]))
+        b++;
+
+    old_len = curr_pntr - b;
+
+    pwix = rescanWct();
+
+    if (!pwix) {
+        putchar(_BELL);
+        fflush(stdout);
+    }
+    else {
+        Wct *pwct = pwix->pwct;  /* start replacing it */
+
+        new_len = strlen(pwct->wordv[pwix->word]);
+        if (new_len > old_len) {
+
+            /*
+             * I have to just slide the characters forward a bit, stuff in
+             * the new characters, and then adjust curr_pntr
+             */
+            diff = new_len - old_len;
+            if (curr_pntr != buff_pntr) {
+                forwardcopy(&buff[curr_pntr + diff],
+                            &buff[curr_pntr],
+                            buff_pntr - curr_pntr);
+                forwardflag_cpy(&buff_flag[curr_pntr + diff],
+                                &buff_flag[curr_pntr],
+                                buff_pntr - curr_pntr);
+            }
+            buff_pntr += diff;
+            ncs = curr_pntr + diff;
+
+            /* Now insert the new word */
+            for (i = 0; i < new_len; i++)
+                buff[b + i] = (pwct->wordv[pwix->word])[i];
+
+            /* move cursor to the beginning of the word */
+            for (; curr_pntr != b; curr_pntr--)
+                putchar(_BKSPC);
+
+            /** now print the characters on the rest of the line **/
+            printbuff(curr_pntr, buff_pntr - curr_pntr);
+
+            /* now move bcak the number of characters I want to */
+            for (i = buff_pntr; i != ncs; i--)
+                putchar(_BKSPC);
+
+            fflush(stdout);
+
+            curr_pntr = ncs;
+        }
+        else if (new_len < old_len) {
+            /* this time I simply copy backwards and do the substituting */
+            diff = old_len - new_len;
+            strncpy(&buff[curr_pntr - diff],
+                    &buff[curr_pntr],
+                    buff_pntr - curr_pntr);
+            flagncpy(&buff_flag[curr_pntr - diff],
+                    &buff_flag[curr_pntr],
+                    buff_pntr - curr_pntr);
+            buff_pntr -= diff;
+            ncs = curr_pntr - diff;
+
+            /* Now insert the new word */
+            for (i = 0; i < new_len; i++)
+                buff[b + i] = (pwct->wordv[pwix->word])[i];
+
+            /* move cursor to the beginning of the word */
+            for (; curr_pntr != b; curr_pntr--)
+                putchar(_BKSPC);
+
+            /** now print the characters on the rest of the line **/
+            printbuff(b, buff_pntr - b);
+
+            /* now blank out the characters out on the end of this line */
+            for (i = 0; i < diff; i++)
+                myputchar(' ');
+
+            /* now move back the number of characters I want to */
+            for (i = buff_pntr + diff; i != ncs; i--)
+                putchar(_BKSPC);
+
+            fflush(stdout);
+
+            curr_pntr = ncs;
+        }
+        else {
+            diff = 0;
+            ncs = curr_pntr;
+            /* Now insert the new word */
+            for (i = 0; i < new_len; i++)
+                buff[b + i] = (pwct->wordv[pwix->word])[i];
+
+            /* move cursor to the beginning of the word */
+            for (; curr_pntr != b; curr_pntr--)
+                putchar(_BKSPC);
+
+            /** now print the characters on the rest of the line **/
+            printbuff(curr_pntr, buff_pntr - curr_pntr);
+
+            /* now move back the number of characters I want to */
+            for (i = buff_pntr; i != ncs; i--)
+                putchar(_BKSPC);
+
+            fflush(stdout);
+
+            curr_pntr = ncs;
+        }
+    }
+}
+
+void
+find_wct(void)
+{
+
+    char search_buff[100];
+    char *filler = search_buff;
+    int b = curr_pntr - 1;
+    int e = curr_pntr;
+    int ne = 0;
+    int st;
+    Wix *pwix;
+    int curr_len;
+    int new_len;
+    int diff;
+    int i;
+
+    /*
+     * First thing I do is try and construct the string to be searched for.
+     * Basically I just start from the curr_pntr and search backward until I
+     * find a blank. Once I find a blank I copy forward until I get back to
+     * curr_pntr;
+     */
+    if (!curr_pntr) {
+        putchar(_BELL);
+        return;
+    }
+    /* then get back to the first blank or back to the beginning */
+    while (b && !Delimiter(buff[b]))
+        b--;
+    if (Delimiter(buff[b]))
+        b++;
+
+    /* At the same time, let me find the end of the word */
+    while (e < buff_pntr && !Delimiter(buff[e])) {
+        e++;
+        ne++;
+    }
+
+    st = b;
+    curr_len = e - b;
+
+    /* now simply copy the text forward */
+    while (b < curr_pntr)
+        *filler++ = buff[b++];
+
+    *filler = '\0';
+
+    pwix = scanWct(pwct, search_buff);
+
+    /*
+     * else pwix = rescanWct();
+     */
+
+    if (!pwix) {
+        putchar(_BELL);
+        fflush(stdout);
+    }
+    else {
+        Wct *pwct = pwix->pwct;
+
+        /*
+         * printf("Found %s in file %s\n", pwct->wordv[pwix->word],
+         * pwct->fname);
+         */
+        /* copy them buffer into where it should be */
+        new_len = strlen(pwct->wordv[pwix->word]);
+        diff = new_len - curr_len;
+        if (curr_pntr != buff_pntr) {
+            forwardcopy(&buff[curr_pntr + diff],
+                        &buff[curr_pntr],
+                        buff_pntr - curr_pntr);
+            forwardflag_cpy(&buff_flag[curr_pntr + diff],
+                            &buff_flag[curr_pntr],
+                            buff_pntr - curr_pntr);
+        }
+        buff_pntr += diff;
+
+
+        /* Now insert the new characters */
+        for (i = new_len - diff; i < new_len; i++)
+            buff[st + i] = (pwct->wordv[pwix->word])[i];
+
+        /* Now move the cursor forward to the end of the word */
+        for (i = 0; i < diff; i++)
+            putchar(buff[curr_pntr++]);
+
+        /** now print the characters on the rest of the line **/
+        printbuff(curr_pntr, buff_pntr - curr_pntr);
+
+        /* now move bcak the number of characters I want to */
+        for (i = buff_pntr; i != e + diff; i--)
+            putchar(_BKSPC);
+
+        fflush(stdout);
+
+        curr_pntr = diff + e;
+
+    }
+
+
+}
+\end{chunk}
+
+\section{xdither.c}
+\begin{chunk}{xdither.c}
+
+#ifndef MSYSplatform
+
+#include <stdio.h>
+#include <stdlib.h>
+#if !defined(BSDplatform)
+#include <malloc.h>
+#endif
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/cursorfont.h>
+
+#define XDitherWidth 3
+#define XDitherMax  10
+
+char XDitherBits[] = {
+   0x00, 0x00, 0x00,
+   0x00, 0x02, 0x00,
+   0x00, 0x03, 0x00,
+   0x00, 0x03, 0x02,
+   0x00, 0x07, 0x02,
+   0x04, 0x07, 0x02,
+   0x04, 0x07, 0x03,
+   0x05, 0x07, 0x03,
+   0x05, 0x07, 0x07,
+   0x07, 0x07, 0x07 };
+
+\getchunk{include/xdither.h1}
+
+Pixmap XDither[XDitherMax];
+unsigned int DITHERINIT = 0;
+
+
+
+/*
+ * This routine has the function of returning the number of characters needed
+ * to store a bitmap. It first calculates the number of bits needed per line.
+ * Then it finds the closest multiple of 8 which is bigger than the number of
+ * bits. Once that is done, it multiplies this number by the number of bits
+ * high the bitmap is.
+ */
+int
+dither_char_bitmap(void)
+{
+    int bits_line;
+    int total_chars;
+
+    for (bits_line = 8, total_chars = 1; bits_line < XDitherWidth; total_chars++)
+        bits_line += 8;
+
+    total_chars = total_chars * XDitherWidth;
+
+    return total_chars;
+}
+
+int 
+XInitDither(Display *display, int screen, GC gc, unsigned long fg, 
+            unsigned long bg)
+{
+
+    char *bits;
+    int count;
+    int chars_bitmap = dither_char_bitmap();
+    int bit;
+    XGCValues xgcv;
+
+    DITHERINIT = 1;
+
+    /*
+     * First thing I should do is load in the Pixmaps
+     */
+    bits = (char *) malloc(chars_bitmap * sizeof(char));
+
+    for (count = 0; count < XDitherMax; count++) {
+
+        /*
+         * Load in the next bitmap
+         */
+        for (bit = 0; bit < chars_bitmap; bit++)
+            bits[bit] = XDitherBits[count * chars_bitmap + bit];
+
+        /*
+         * Create it and put it into the Pixmap array
+         */
+        XDither[count] = XCreatePixmapFromBitmapData(display,
+                                                RootWindow(display, screen),
+                                                     bits,
+                                                 XDitherWidth, XDitherWidth,
+                                                BlackPixel(display, screen),
+                                                WhitePixel(display, screen),
+                                                     1);
+    }
+
+    /*
+     * Now reset the gc values to be as I need them
+     */
+    xgcv.background = bg;
+    xgcv.foreground = fg;
+    xgcv.fill_style = FillOpaqueStippled;
+    xgcv.stipple = XDither[4];
+
+    XChangeGC(display, gc,
+              GCForeground | GCBackground | GCFillStyle | GCStipple, &xgcv);
+
+    return (XDitherMax);
+
+}
+
+
+int
+XChangeDither(Display *display, GC gc, int dither)
+{
+    if (!DITHERINIT) {
+        fprintf(stderr, "XChange Error: Init Not Called\n");
+        exit(-1);
+    }
+    if (dither >= XDitherMax || dither < 0) {
+        fprintf(stderr, "Dither %d, out of range\n",dither);
+        return (-1);
+    }
+    XSetStipple(display, gc, XDither[dither]);
+    return (1);
+}
+
+
+void
+XDitherRectangle(Display *display, Drawable drawable, GC gc, int x,
+                 int  y, unsigned int width, unsigned int height)
+{
+
+
+    if (!DITHERINIT) {
+        fprintf(stderr, "xdither Error: Tried to fill before INIT called\n");
+        exit(-1);
+    }
+    XFillRectangle(display, drawable, gc, x, y, width, height);
+
+}
+
+
+void
+XDitherRectangles(Display *display, Drawable drawable, GC gc, 
+                  XRectangle *rectangles, int nrectangles)
+{
+
+
+    if (!DITHERINIT) {
+        fprintf(stderr, "xdither Error: Tried to fill before INIT called\n");
+        exit(-1);
+    }
+    XFillRectangles(display, drawable, gc,
+                           rectangles, nrectangles);
+
+}
+
+
+void 
+XDitherPolygon(Display * display, Drawable drawable, GC gc, 
+               XPoint *points, int npoints, int shape, int mode)
+{
+    if (!DITHERINIT) {
+        fprintf(stderr, "xdither Error: Tried to fill before INIT called\n");
+        exit(-1);
+    }
+
+    XFillPolygon(display, drawable, gc,
+                        points, npoints, shape, mode);
+
+}
+
+void
+XDitherArc(Display *display, Drawable drawable, GC gc, int x,int  y, 
+           unsigned int width, unsigned int height, int angle1, int angle2)
+{
+
+    if (!DITHERINIT) {
+        fprintf(stderr, "xdither Error: Tried to fill before INIT called\n");
+        exit(-1);
+    }
+    XFillArc(display, drawable, gc, x, y, width,
+                    height, angle1, angle2);
+}
+
+
+void
+XDitherArcs(Display *display,Drawable  drawable, GC gc, XArc *arcs,int narcs)
+{
+
+    if (!DITHERINIT) {
+        fprintf(stderr, "xdither Error: Tried to fill before INIT called\n");
+        exit(-1);
+    }
+    XFillArcs(display, drawable, gc, arcs, narcs);
+}
+#endif /* MSYSplatform */
+\end{chunk}
+
+\section{xshade.c}
+\begin{chunk}{xshade.c}
+
+#ifndef MSYSplatform
+
+#include <stdio.h>
+#if !defined(BSDplatform)
+#include <malloc.h>
+#endif
+#include <stdlib.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+#include <X11/cursorfont.h>
+
+#define XShadeWidth 4
+#define XShadeMax  17
+
+char XShadeBits[] = {
+   0x00, 0x00, 0x00, 0x00,
+   0x01, 0x00, 0x00, 0x00,
+   0x01, 0x00, 0x04, 0x00,
+   0x05, 0x00, 0x04, 0x00,
+   0x05, 0x00, 0x05, 0x00,
+   0x05, 0x02, 0x05, 0x00,
+   0x05, 0x02, 0x05, 0x08,
+   0x05, 0x0a, 0x05, 0x08,
+   0x05, 0x0a, 0x05, 0x0a,
+   0x07, 0x0a, 0x05, 0x0a,
+   0x07, 0x0a, 0x0d, 0x0a,
+   0x0f, 0x0a, 0x0d, 0x0a,
+   0x0f, 0x0a, 0x0f, 0x0a,
+   0x0f, 0x0b, 0x0f, 0x0a,
+   0x0f, 0x0b, 0x0f, 0x0e,
+   0x0f, 0x0f, 0x0f, 0x0e,
+   0x0f, 0x0f, 0x0f, 0x0f};
+
+\getchunk{include/xshade.h1}
+
+Pixmap XShade[XShadeMax];
+GC  TileGC;
+unsigned int INIT = 1;
+
+/*
+ * This routine has the function of returning the number of characters needed
+ * to store a bitmap. It first calculates the number of bits needed per line.
+ * Then it finds the closest multiple of 8 which is bigger than the number of
+ * bits. Once that is done, it multiplies this number by the number of bits
+ * high the bitmap is.
+ */
+int
+char_bitmap(void)
+{
+    int bits_line;
+    int total_chars;
+
+    for (bits_line = 8, total_chars = 1; bits_line < XShadeWidth; total_chars++)
+        bits_line += 8;
+
+    total_chars = total_chars * XShadeWidth;
+
+    return total_chars;
+}
+
+int
+XInitShades(Display *display, int screen)
+{
+    char *bits;
+    int count;
+    int chars_bitmap = char_bitmap();
+    int bit;
+
+    bits = (char *) malloc(chars_bitmap * sizeof(char));
+
+    for (count = 0; count < XShadeMax; count++) {
+
+        /* Load in the next bitmap */
+
+        for (bit = 0; bit < chars_bitmap; bit++)
+            bits[bit] = XShadeBits[count * chars_bitmap + bit];
+
+        /* Create it and put it into the Pixmap array */
+
+        XShade[count] = XCreatePixmapFromBitmapData(display,
+                                                RootWindow(display, screen),
+                                                    bits,
+                                                    XShadeWidth, XShadeWidth,
+                                                BlackPixel(display, screen),
+                                                WhitePixel(display, screen),
+                                            DisplayPlanes(display, screen));
+    }
+    TileGC = XCreateGC(display, RootWindow(display, screen), 0, NULL);
+    XSetFillStyle(display, TileGC, FillTiled);
+    XSetTile(display, TileGC, XShade[XShadeMax / 2]);
+    return XShadeMax;
+}
+
+
+int
+XChangeShade(Display *display, int shade)
+{
+    if (shade >= XShadeMax || shade < 0) {
+        fprintf(stderr, "Shade %d, out of range\n",shade);
+        return (-1);
+    }
+    XSetTile(display, TileGC, XShade[shade]);
+    return (1);
+}
+
+int
+XQueryShades(unsigned int *shades)
+{
+    *shades = XShadeMax;
+    return 1;
+}
+
+
+void
+XShadeRectangle(Display *display, Drawable drawable, int x,int y,
+                unsigned int width, unsigned int height)
+{
+    if (!INIT) {
+        fprintf(stderr, "xshade Error: Tried to fill before INIT called\n");
+        exit(-1);
+    }
+    XFillRectangle(display, drawable, TileGC, x, y, width, height);
+}
+
+
+void
+XShadeRectangles(Display *display, Drawable drawable, 
+                 XRectangle *rectangles, int nrectangles)
+{
+    if (!INIT) {
+        fprintf(stderr, "xshade Error: Tried to fill before INIT called\n");
+        exit(-1);
+    }
+    XFillRectangles(display, drawable, TileGC,
+                           rectangles, nrectangles);
+}
+
+
+void
+XShadePolygon(Display *display, Drawable drawable, XPoint * points, 
+              int npoints, int  shape, int mode)
+{
+    if (!INIT) {
+        fprintf(stderr, "xshade Error: Tried to fill before INIT called\n");
+        exit(-1);
+    }
+
+    XFillPolygon(display, drawable, TileGC,
+                        points, npoints, shape, mode);
+}
+
+void
+XShadeArc(Display *display, Drawable drawable, int x, int y, 
+          unsigned int width, unsigned int height, int angle1, int angle2)
+{
+    if (!INIT) {
+        fprintf(stderr, "xshade Error: Tried to fill before INIT called\n");
+        exit(-1);
+    }
+    XFillArc(display, drawable, TileGC, x, y, width,
+                    height, angle1, angle2);
+}
+
+
+void
+XShadeArcs(Display *display, Drawable drawable, XArc *arcs, int narcs)
+{
+    if (!INIT) {
+        fprintf(stderr, "xshade Error: Tried to fill before INIT called\n");
+        exit(-1);
+    }
+    XFillArcs(display, drawable, TileGC, arcs, narcs);
+}
+
+#endif /* MSYSplatform */
+
+\end{chunk}
+
+\section{xspadfill.c}
+
+This file contains the routines needed to dither using the
+spadcolors. The routines will have names such as XSpadFill, $\ldots$
+The user simply gives the normal arguments as with the corresponding
+XFill routine, with two additional arguments which choose the shade
+and the hue.
+
+The file will maintain twoGC's: stippleGC - will be used when stippling the
+backgrounds. solidGC - will be used when the background should be solid
+
+The user should call XSpadInit to get everthing going. This routine has the
+job of Initializing the dithering routines, and getting the colors all
+into place.
+
+\begin{chunk}{xspadfill.c}
+
+#ifndef MSYSplatform
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <X11/Intrinsic.h>
+#include <X11/StringDefs.h>
+
+\getchunk{include/spadcolors.h}
+
+\getchunk{include/xspadfill.h1}
+\getchunk{include/xshade.h1}
+\getchunk{include/xdither.h1}
+\getchunk{include/spadcolors.h1}
+
+extern unsigned long *spadColors;
+static GC  stippleGC, solidGC;
+Colormap cmap;
+int SpadFillInit = 0;
+long white, black;
+int max_spad_shades;
+extern Display *dsply;
+
+extern int totalHues;
+extern int totalDithered;
+extern int totalSolid;
+extern int totalShades;
+extern int totalColors;
+extern int maxGreyShade;
+
+int
+XInitSpadFill(Display *dsply, int scr, Colormap * mapOfColors, int * hues, 
+              int *solid, int * dithered, int * shades)
+{
+    XColor BlackColor, WhiteColor;
+    XColor retColor;
+    int maxSolid;
+
+    SpadFillInit = 1;
+
+
+    /*
+     * First thing I should do is get the GC's
+     */
+    stippleGC = XCreateGC(dsply, RootWindow(dsply, scr), 0, NULL);
+    solidGC = XCreateGC(dsply, RootWindow(dsply, scr), 0, NULL);
+    XSetArcMode(dsply, solidGC, ArcPieSlice);
+    XSetArcMode(dsply, stippleGC, ArcPieSlice);
+
+
+    cmap = DefaultColormap(dsply, scr);
+    *mapOfColors = cmap;
+    XAllocNamedColor(dsply, cmap, "Black", &BlackColor, &retColor);
+    XAllocNamedColor(dsply, cmap, "White", &WhiteColor, &retColor);
+    black = BlackColor.pixel;
+    white = WhiteColor.pixel;
+
+    /*
+     * Now I check to see if I am on a monochrome display. If so then I
+     * simply set totalHues to be one, and total Shades to be 2. I also have
+     * to allocate balck and white colors. This I put into the first two
+     * memory locations of spadcolors.
+     *
+     * was      if(DisplayPlanes(dsply, scr) < 2)  changed temporarily to < 8
+     * because of problems with screens with 4 planes . Now if we don't have
+     * 8 planes to play with  we switch to monochrome
+     */
+
+    if (DisplayPlanes(dsply, scr) < 8) {
+        *dithered = totalDithered = maxGreyShade = XInitShades(dsply, scr);
+        spadColors = (unsigned long *) malloc(2 * sizeof(unsigned long));
+        spadColors[0] = BlackColor.pixel;
+        spadColors[1] = WhiteColor.pixel;
+        *hues = totalHues = 1;
+        *solid = totalSolid = 2;
+        *shades = totalColors = totalShades = totalDithered;
+        return (totalColors);
+    }
+
+    /*
+     * Now I have to get all the spad colors as every good spad program
+     * should Now I should initialize the dithering routines
+     */
+
+    *dithered = totalDithered =
+        XInitDither(dsply, scr, stippleGC, black, white);
+
+    if ((maxSolid=makeColors(dsply,scr,&cmap,&spadColors,&totalSolid)) > 0) {
+        *solid = totalSolid + 2;
+        *hues = totalHues = maxSolid / totalSolid;
+        *shades = totalShades = (totalSolid + 1) * (totalDithered - 1) + 1;
+        totalColors = totalHues * totalShades;
+        return (totalColors);
+    }
+    else {
+
+        /*
+         * makeColors managed to fail -- switch to mono
+         */
+        *dithered = totalDithered = maxGreyShade = XInitShades(dsply, scr);
+        spadColors = (unsigned long *) malloc(2 * sizeof(unsigned long));
+        spadColors[0] = BlackColor.pixel;
+        spadColors[1] = WhiteColor.pixel;
+        *hues = totalHues = 1;
+        *solid = totalSolid = 2;
+        *shades = totalColors = totalShades = totalDithered;
+        return (totalColors);
+    }
+}
+
+
+void 
+XSpadFillSetArcMode(Display *dsply, int mode)
+{
+    XSetArcMode(dsply, solidGC, mode);
+    XSetArcMode(dsply, stippleGC, mode);
+}
+
+GC
+SpadFillGC(Display *dsply,int  hue, int theshade,char * fill_routine)
+{
+    int dither;
+    int color;
+
+
+    if (!SpadFillInit) {
+        fprintf(stderr, 
+           "Tried to use SpadFillGC before calling XInitSpadFill\n");
+        exit(0);
+    }
+
+    if (theshade >= totalShades) {
+        fprintf(stderr, "Shade %d out of range\n",theshade);
+        exit(-1);
+    }
+    if (hue >= totalHues) {
+        fprintf(stderr, "Error Hue %d is out of range\n",hue);
+        exit(-1);
+    }
+    dither = ((theshade) % (totalDithered - 1));
+    if (dither != 0) {
+        XChangeDither(dsply, stippleGC, dither);
+        if (theshade < totalDithered) {    /* Dither to black */
+            color = totalSolid * hue;
+            XSetForeground(dsply, stippleGC, black);
+            XSetBackground(dsply, stippleGC, spadColors[color]);
+        }
+        else if (theshade > (totalShades - totalDithered)) {
+            /* Dither to white */
+            color = ((theshade) / (totalDithered - 1)) + totalSolid * hue - 1;
+            XSetForeground(dsply, stippleGC, spadColors[color]);
+            XSetBackground(dsply, stippleGC, white);
+        }
+        else {
+            color = ((theshade) / (totalDithered - 1)) + totalSolid * hue - 1;
+            XSetForeground(dsply, stippleGC, spadColors[color]);
+            XSetBackground(dsply, stippleGC, spadColors[color + 1]);
+        }
+        return (stippleGC);
+    }
+    else {
+        if (theshade == 0)
+            XSetForeground(dsply, solidGC, black);
+        else if (theshade == (totalShades - 1))
+            XSetForeground(dsply, solidGC, white);
+        else {
+            color = ((theshade) / (totalDithered - 1)) + totalSolid * hue - 1;
+            XSetForeground(dsply, solidGC, spadColors[color]);
+        }
+        return (solidGC);
+    }
+
+}
+
+unsigned long
+XSolidColor(int hue, int theshade)
+{
+    if (hue >= totalHues)
+        return -1;
+    if (theshade >= totalSolid)
+        return -1;
+    return (spadColors[hue * (totalSolid) + theshade]);
+}
+
+void 
+XSpadFillRectangle(Display *dsply, Drawable drawable, int x, int y,
+                   unsigned int width, unsigned int height,
+                   int hue, int theshade)
+{
+
+    XFillRectangle(dsply, drawable,
+                   SpadFillGC(dsply, hue, theshade, "XSpadFillRectangle"),
+                   x, y, width, height);
+
+}
+
+
+void
+XSpadFillRectangles(Display *dsply, Drawable drawable,
+                    XRectangle * rectangles, int nrectangles,
+                    int  hue, int theshade)
+{
+
+
+    XFillRectangles(dsply, drawable,
+                        SpadFillGC(dsply, hue, theshade, "XSpadFillRectangle"),
+                           rectangles, nrectangles);
+
+}
+
+
+void
+XSpadFillPolygon(Display *dsply, Drawable drawable, XPoint * points, 
+                 int npoints, int shape, int mode, int hue, int theshade)
+{
+    XFillPolygon(dsply, drawable,
+                        SpadFillGC(dsply, hue, theshade, "XSpadFillRectangle"),
+                        points, npoints, shape, mode);
+
+}
+
+void
+XSpadFillArc(Display *dsply, Drawable drawable, int x, int y, 
+             unsigned int width, unsigned int height,
+             int angle1, int angle2,int hue,int  theshade)
+{
+
+    XFillArc(dsply, drawable,
+                    SpadFillGC(dsply, hue, theshade, "XSpadFillRectangle"),
+                    x, y, width, height, angle1, angle2);
+}
+
+
+void
+XSpadFillArcs(Display *dsply, Drawable drawable, XArc * arcs, int narcs,
+              int hue, int theshade)
+{
+    XFillArcs(dsply, drawable,
+                     SpadFillGC(dsply, hue, theshade, "XSpadFillArcs"),
+                     arcs, narcs);
+}
+
+
+#endif /* MSYSplatform */
+
+\end{chunk}
+
+\section{edible.c}
+\subsection{edible Call Graph}
+This was generated by the GNU cflow program with the argument list.
+Note that the line:NNNN numbers refer to the line in the code after
+it has been tangled from this file.
+\begin{verbatim}
+cflow --emacs -l -n -b -T --omit-arguments edible.c
+\end{verbatim}
+\begin{verbatim}
+;; This file is generated by GNU cflow 1.3. -*- cflow -*-
+    2 {   0} +-main() <int main () line:122>
+    3 {   1}   +-ptyopen()
+    4 {   1}   +-perror()
+    5 {   1}   +-exit()
+    6 {   1}   +-catch_signals() <void catch_signals () line:482>
+    7 {   2}   | +-sprintf()
+    8 {   2}   | +-getpid()
+    9 {   2}   | +-open()
+   10 {   2}   | +-write()
+   11 {   2}   | +-strlen()
+   12 {   2}   | +-close()
+   13 {   2}   | +-bsdSignal()
+   14 {   2}   | +-hangup_handler() <void hangup_handler () line:374>
+   15 {   3}   |   +-open()
+   16 {   3}   |   +-write()
+   17 {   3}   |   +-strlen()
+   18 {   3}   |   +-close()
+   19 {   3}   |   +-kill()
+   20 {   3}   |   +-tcsetattr()
+   21 {   3}   |   +-perror()
+   22 {   3}   |   +-printf()
+   23 {   3}   |   +-unlink()
+   24 {   3}   |   \-exit()
+   25 {   2}   | +-child_handler() <void child_handler () line:430>
+   26 {   3}   |   +-open()
+   27 {   3}   |   +-write()
+   28 {   3}   |   +-strlen()
+   29 {   3}   |   +-close()
+   30 {   3}   |   +-Cursor_shape()
+   31 {   3}   |   +-kill()
+   32 {   3}   |   +-tcsetattr()
+   33 {   3}   |   +-perror()
+   34 {   3}   |   +-printf()
+   35 {   3}   |   +-unlink()
+   36 {   3}   |   \-exit()
+   37 {   2}   | +-terminate_handler() <void terminate_handler () line:396>
+   38 {   3}   |   +-open()
+   39 {   3}   |   +-write()
+   40 {   3}   |   +-strlen()
+   41 {   3}   |   +-close()
+   42 {   3}   |   +-sleep()
+   43 {   3}   |   +-kill()
+   44 {   3}   |   +-tcsetattr()
+   45 {   3}   |   +-perror()
+   46 {   3}   |   +-printf()
+   47 {   3}   |   +-Cursor_shape()
+   48 {   3}   |   +-fprintf()
+   49 {   3}   |   +-unlink()
+   50 {   3}   |   \-exit()
+   51 {   2}   | +-interrupt_handler() <void interrupt_handler () line:418>
+   52 {   3}   |   +-open()
+   53 {   3}   |   +-write()
+   54 {   3}   |   +-strlen()
+   55 {   3}   |   +-close()
+   56 {   3}   |   +-sleep()
+   57 {   3}   |   \-kill()
+   58 {   2}   | +-alarm_handler() <void alarm_handler () line:452>
+   59 {   3}   | | +-getppid()
+   60 {   3}   | | +-open()
+   61 {   3}   | | +-write()
+   62 {   3}   | | +-strlen()
+   63 {   3}   | | +-close()
+   64 {   3}   | | +-alarm()
+   65 {   3}   | | +-tcsetattr()
+   66 {   3}   | | +-perror()
+   67 {   3}   | | +-Cursor_shape()
+   68 {   3}   | | +-fprintf()
+   69 {   3}   | | +-unlink()
+   70 {   3}   | | \-exit()
+   71 {   2}   | \-alarm()
+   72 {   1}   +-strcmp()
+   73 {   1}   +-load_wct_file()
+   74 {   1}   +-fprintf()
+   75 {   1}   +-skim_wct()
+   76 {   1}   +-sprintf()
+   77 {   1}   +-getpid()
+   78 {   1}   +-open()
+   79 {   1}   +-tcgetattr()
+   80 {   1}   +-fork()
+   81 {   1}   +-setsid()
+   82 {   1}   +-dup2()
+   83 {   1}   +-close()
+   84 {   1}   +-tcsetattr()
+   85 {   1}   +-execvp()
+   86 {   1}   +-getenv()
+   87 {   1}   +-strdup()
+   88 {   1}   +-execlp()
+   89 {   1}   +-getppid()
+   90 {   1}   +-init_flag()
+   91 {   1}   +-define_function_keys()
+   92 {   1}   +-init_reader()
+   93 {   1}   +-init_parent() <void init_parent () line:328>
+   94 {   2}   | +-tcgetattr()
+   95 {   2}   | +-perror()
+   96 {   2}   | +-exit()
+   97 {   2}   | +-tcsetattr()
+   98 {   2}   | \-Cursor_shape()
+   99 {   1}   +-FD_ZERO()
+  100 {   1}   +-FD_SET()
+  101 {   1}   +-set_function_chars() <void set_function_chars () line:575>
+  102 {   1}   +-write()
+  103 {   1}   +-strlen()
+  104 {   1}   +-select()
+  105 {   1}   +-check_flip() <void check_flip () line:502>
+  106 {   2}   | +-tcgetattr()
+  107 {   2}   | +-perror()
+  108 {   2}   | +-flip_canonical() <void flip_canonical () line:547>
+  109 {   3}   |   +-tcsetattr()
+  110 {   3}   |   +-perror()
+  111 {   3}   |   +-exit()
+  112 {   3}   |   \-Cursor_shape()
+  113 {   2}   | \-flip_raw() <void flip_raw () line:533>
+  114 {   3}   |   +-send_buff_to_child()
+  115 {   3}   |   +-tcsetattr()
+  116 {   3}   |   +-perror()
+  117 {   3}   |   \-exit()
+  118 {   1}   +-FD_ISSET()
+  119 {   1}   +-read()
+  120 {   1}   +-back_up()
+  121 {   1}   +-print_whole_buff()
+  122 {   1}   \-do_reading()
+\end{verbatim}
+\begin{chunk}{edible.c}
+
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <string.h>
+#include <termios.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#include <errno.h>
+#include <signal.h>
+
+#if defined (SGIplatform)
+#include <bstring.h>
+#endif
+
+\getchunk{include/edible.h}
+\getchunk{include/com.h}
+\getchunk{include/bsdsignal.h}
+\getchunk{include/bsdsignal.h1}
+\getchunk{include/openpty.h1}
+\getchunk{include/prt.h1}
+\getchunk{include/edin.h1}
+\getchunk{include/wct.h1}
+\getchunk{include/edible.h1}
+\getchunk{include/fnct-key.h1}
+
+#ifdef AXIOM_UNLIKELY
+#define log 1
+#define logterm 1
+#define siglog 1
+#endif
+
+#define Cursor_shape(x) 
+
+#ifdef siglog
+int sigfile;
+char sigbuff[256];
+#endif
+
+/*   Here are the term structures I need for setting and resetting the
+     terminal characteristics. */
+
+struct termios childbuf;   /* the childs normal operating termio */
+struct termios oldbuf;     /* the initial settings */
+struct termios rawbuf;     /* the parents raw state, when it is doing nothing */
+struct termios canonbuf;   /* set it to be canonical */
+
+/*   the terminals mapping of the function keys */
+unsigned char  _INTR, _QUIT, _ERASE, _KILL, _EOF, _EOL, _RES1, _RES2;
+
+
+int ppid;        /* the parents's parent pid */
+int child_pid;   /* the childs process id */
+
+short INS_MODE ;    /* Flag for insert mode */
+short ECHOIT = 1;   /* Flag for echoing */
+short PTY;          /* Flag which tells me whether I should echo newlines */
+
+int MODE;    /* am I in cbreak, raw, or canonical */
+
+char in_buff[1024];   /* buffer for storing characters read until they are processed */
+char buff[MAXLINE];                 /**  Buffers for collecting input and  **/
+int  buff_flag[MAXLINE];      /**     flags for whether buff chars
+                                           are printing
+                                           or non-printing                **/
+
+
+char controllerPath[20];  /* path name for opening the controller side */
+char serverPath[20];      /* path name for opening the server side     */
+
+int contNum, serverNum;          /* file descriptors for pty's */
+int num_read;                    /* Number of chars read */
+
+#ifdef log 
+int logfd;
+char logpath[30];
+#endif
+
+int
+main(int argc, char *argv[])
+{
+  fd_set rfds;                  /* the structure for the select call */
+  int code;                    /* return code from system calls */
+  char out_buff[MAXLINE];       /* from child and stdin */
+  int out_flag[MAXLINE] ; /* initialize the output flags */
+  char *program;          /* a string to hold the child program invocation */ 
+  char **pargs = 0;             /* holds parts of the command line */
+  int not_command = 1;          /* a flag while parsing the command line */
+  
+  
+  
+  /* try to get a pseudoterminal to play with */
+  if (ptyopen(&contNum, &serverNum, controllerPath, serverPath) == -1) {
+    perror("ptyopen failed");
+    exit(-1);
+  }
+  
+  /* call the routine that handles signals */
+  catch_signals();
+  
+  /* parse the command line arguments - as with the aixterm  the command 
+     argument -e should be last on the line. */
+  
+  while(*++argv && not_command) {
+    if(!strcmp(*argv, "-f"))
+      load_wct_file(*++argv);
+    else if(!strcmp(*argv, "-e")) {
+      not_command = 0;
+      pargs = ++argv;
+    }
+    else {
+      fprintf(stderr, "usage: clef [-f fname] -e command\n");
+      exit(-1);
+    }
+  }
+  skim_wct(); 
+  
+#ifdef log 
+  sprintf(logpath, "/tmp/cleflog%d", getpid());
+  logfd = open(logpath, O_CREAT | O_RDWR, 0666);
+#endif
+  
+  /* get the original termio settings, so the child has them */
+  
+  if(tcgetattr(0,&childbuf) == -1) {
+    perror("clef trying to get the initial terminal settings");
+    exit(-1);
+  }
+  
+  /* start the child process */
+  
+  child_pid = fork();
+  switch(child_pid) {
+  case -1 :
+    perror("clef can't create a new process");
+    exit(-1);
+  case 0:
+    /* CHILD */
+    /* Dissasociate form my parents group so all my child processes
+       look at my terminal as the controlling terminal for the group */
+    setsid();
+
+    serverNum = open(serverPath,O_RDWR);
+    if (serverNum == -1) perror("open serverPath failed");
+
+    /* since I am the child, I can close ptc, and dup pts for all it
+       standard descriptors */
+    if (dup2(serverNum, 0) == -1) perror("dup2 0 failed");
+    if (dup2(serverNum, 1) == -1) perror("dup2 1 failed");
+    if (dup2(serverNum, 2) == -1) perror("dup2 2 failed");
+    if( (dup2(serverNum, 0) == -1)  ||
+	(dup2(serverNum, 1) == -1) ||
+	(dup2(serverNum, 2) == -1)  ) {
+      perror("clef trying to dup2");
+      exit(-1);
+    }
+    
+    /* since they have been duped, close them */
+    close(serverNum);
+    close(contNum); 
+    
+    
+    /* To make sure everything is nice, set off enhedit */
+    /*    childbuf.c_line = 0; */
+    
+    /* reconfigure the child's terminal get echoing */
+    if(tcsetattr(0, TCSAFLUSH, &childbuf) == -1) {
+      perror("clef child trying to set child's terminal");
+      exit(-1);
+    }
+    
+    /* fire up the child's process */
+    if(pargs){
+      execvp( pargs[0], pargs);
+      perror("clef trying to execvp its argument");
+      fprintf(stderr, "Process --> %s\n", pargs[0]);
+    }
+    else{
+      program = getenv("SHELL");
+      if (!program)
+	program = strdup("/bin/sh");  
+      else 
+	program = strdup (program);
+      execlp( program,program, 0);
+      perror("clef trying to execlp the default child");
+      fprintf(stderr, "Process --> %s\n", program);
+    }
+    exit(-1);
+    break;
+    /* end switch */
+  }
+  /* PARENT */
+  /* Since I am the parent, I should start to initialize some stuff.
+     I have to close the pts side for it to work properly */
+  
+  close(serverNum);  
+  ppid = getppid();
+  
+  /* Iinitialize some stuff for the reading and writing */
+  init_flag(out_flag, MAXLINE);
+  define_function_keys();
+  init_reader();
+  PTY = 1;
+  init_parent();
+  
+  /* Here is the main loop, it simply starts reading characters from
+     the std input, and from the child. */
+  
+  while(1)  {           /* loop forever */
+    
+    /* use select to see who has stuff waiting for me to handle */
+    /* set file descriptors for ptc and stdin */
+    FD_ZERO(&rfds);
+    FD_SET(contNum,&rfds);
+    FD_SET(0,&rfds);
+    set_function_chars();
+#ifdef log
+    {
+      char modepath[30];
+      sprintf(modepath, "\nMODE = %d\n", MODE);
+      write(logfd, modepath, strlen(modepath));
+    }
+#endif
+#ifdef logterm
+    {
+      struct termio ptermio;
+      char pbuff[1024];
+      tcgetattr(contNum, &ptermio);
+      sprintf(pbuff, "child's settings: Lflag = %d, Oflag = %d, Iflag = %d\n",
+	      ptermio.c_lflag, ptermio.c_oflag, ptermio.c_iflag);
+      write(logfd, pbuff, strlen(pbuff));
+    }
+#endif
+    
+    code = select(FD_SETSIZE,(void *) &rfds, NULL, NULL, NULL);
+    for(; code < 0 ;) {
+      if(errno == EINTR) {
+        check_flip();
+        code = select(FD_SETSIZE,(void *) &rfds, NULL, NULL, NULL);
+      }
+      else  {
+        perror("clef select failure");
+        exit(-1);
+      }
+    }
+    
+    /* reading from the child **/
+    if( FD_ISSET(contNum,&rfds)) {       
+      if( (num_read = read(contNum, out_buff, MAXLINE)) == -1) { 
+        num_read = 0;
+      }
+#ifdef log 
+      write(logfd, "OUT<<<<<", strlen("OUT<<<<<"));
+      write(logfd, out_buff, num_read);
+#endif
+      if(num_read > 0) {
+        /* now do the printing to the screen */
+        if(MODE!= CLEFRAW) {
+          back_up(buff_pntr);
+          write(1,out_buff, num_read);
+          print_whole_buff();    /* reprint the input buffer */
+        }
+        else write(1,out_buff, num_read);
+      }
+    } /* done the child stuff */
+    /* I should read from std input */
+    else  {
+      if(FD_ISSET(0,&rfds)) {          
+        num_read = read(0, in_buff, MAXLINE);
+#ifdef log 
+	write(logfd, "IN<<<<<", strlen("IN<<<<<"));
+	write(logfd, in_buff, num_read);
+#endif
+        check_flip();
+        if(MODE == CLEFRAW ) 
+          write(contNum, in_buff, num_read);
+        else 
+          do_reading();
+      }
+    }
+  }
+}
+
+
+void
+init_parent(void)
+{
+  
+  /* get the original termio settings, so I never have to check again */
+  if(tcgetattr(0, &oldbuf) == -1) {
+    perror("clef trying to get terminal initial settings");
+    exit(-1);
+  }
+  
+  /* get the settings for my different modes */  
+  if ((tcgetattr(0, &canonbuf) == -1) ||
+      (tcgetattr(0, &rawbuf) == -1) ) {
+    perror("clef trying to get terminal settings");
+    exit(-1);
+  }
+  
+     
+  canonbuf.c_lflag &= ~(ICANON | ECHO | ISIG); 
+  /* read before an eoln is typed */
+
+  canonbuf.c_lflag |= ISIG;
+ 
+  /*  canonbuf.c_line = 0;       turn off enhanced edit */
+
+  canonbuf.c_cc[VMIN] = 1;          /* we want every character  */
+  canonbuf.c_cc[VTIME] = 1;         /* these may require tweaking */
+
+  /* also set up the parents raw setting for when needed **/
+  rawbuf.c_oflag = rawbuf.c_iflag = rawbuf.c_lflag /* = rawbuf.c_line */ = 0;
+  rawbuf.c_cc[VMIN] = 1;
+  rawbuf.c_cc[VTIME] = 1;
+
+
+  if(tcsetattr(0, TCSAFLUSH, &canonbuf) == -1) {
+    perror("clef setting parent terminal to canonical processing");
+    exit(0);
+  }
+  
+  /* initialize some flags I will be using */
+  MODE = CLEFCANONICAL;
+  INS_MODE = 1;
+  Cursor_shape(2);
+}
+
+
+void 
+hangup_handler(int sig)
+{
+#ifdef siglog
+  sigfile = open(sigbuff, O_RDWR | O_APPEND);
+  write(sigfile, "Hangup Handler\n", strlen("Hangup Handler\n"));
+  close(sigfile);
+#endif
+  /* try to kill my child if it is around */
+  if(kill(child_pid, 0)) kill(child_pid, SIGTERM);
+  if(kill(ppid, 0) >= 0) {
+    /* fix the terminal and exit */
+    if(tcsetattr(0, TCSAFLUSH, &oldbuf) == -1) {
+      perror("clef restoring terminal in hangup handler");
+    }
+    printf("\n");
+  }
+  /* remove the temporary editor filename */
+  unlink(editorfilename);
+  exit(-1);
+}
+
+void 
+terminate_handler(int sig)
+{
+#ifdef siglog
+  sigfile = open(sigbuff, O_RDWR | O_APPEND);
+  write(sigfile, "Terminate Handler\n", strlen("Terminate Handler\n") + 1);
+  close(sigfile);
+  sleep(1);
+#endif
+  kill(child_pid, SIGTERM);
+  /* fix the terminal, and exit */
+  if(tcsetattr(0, TCSAFLUSH, &oldbuf) == -1) {
+    perror("clef restoring terminal in terminate handler");
+  }
+  printf("\n");
+  Cursor_shape(2);
+  fprintf(stderr, "\n");
+  /* remove the temporary editor filename */
+  unlink(editorfilename);
+  exit(0);
+}
+
+void 
+interrupt_handler(int sig)
+{
+#ifdef siglog
+  sigfile = open(sigbuff, O_RDWR | O_APPEND);
+  write(sigfile, "Interrupt Handler\n", strlen("Interrupt Handler\n") + 1);
+  close(sigfile);
+  sleep(1);
+#endif
+  kill(child_pid, SIGINT);
+}
+
+void 
+child_handler(int sig)
+{
+#ifdef siglog
+  sigfile = open(sigbuff, O_RDWR | O_APPEND );
+  write(sigfile, "Child Handler\n", strlen("Child Handler\n") + 1);
+  close(sigfile);
+#endif
+  Cursor_shape(2);
+  close(contNum);
+  if(kill(ppid, 0) >= 0) {
+   /* fix the terminal, and exit */
+    if(tcsetattr(0, TCSAFLUSH, &oldbuf) == -1) {
+      perror("clef restoring terminal in child handler");
+    }
+    printf("\n");
+  }
+  /* remove the temporary editor filename */
+  unlink(editorfilename);
+  exit(0);
+}
+
+void 
+alarm_handler(int sig)
+{
+  int newppid = getppid();
+#ifdef siglog
+  sigfile = open(sigbuff, O_RDWR | O_APPEND);
+  write(sigfile, "Alarm Handler\n", strlen("Alarm Handler\n")+ 1 );
+  close(sigfile);
+#endif
+  /* simply gets the parent process id, if different, it terminates ,
+    otherwise it resets the alarm */
+  
+  if(ppid == newppid) {
+    alarm(60);
+    return;
+  }
+  else {
+    /* once that is done fix the terminal, and exit */
+    if(tcsetattr(0, TCSAFLUSH, &oldbuf) == -1) {
+      perror("clef restoring terminal in alarm handler");
+    }
+    Cursor_shape(2);
+    fprintf(stderr, "\n");
+    /* remove the temporary editor filename */
+    unlink(editorfilename);
+    exit(0);
+  }
+}
+
+/* a procedure which tells my parent how to catch signals from its children */
+void
+catch_signals(void) 
+{
+#ifdef siglog
+  sprintf(sigbuff, "/tmp/csig%d", getpid());
+  sigfile = open(sigbuff, O_RDWR | O_TRUNC | O_CREAT);
+  write(sigfile, "Started \n", strlen("Started \n"));
+  close(sigfile);
+#endif
+  bsdSignal(SIGHUP, hangup_handler,RestartSystemCalls); 
+  bsdSignal(SIGCHLD,child_handler,RestartSystemCalls); 
+  bsdSignal(SIGTERM, terminate_handler,RestartSystemCalls);
+  bsdSignal(SIGINT, interrupt_handler,RestartSystemCalls); 
+  bsdSignal(SIGALRM, alarm_handler,RestartSystemCalls);
+  alarm(60);
+}
+
+/* Here is where I check the child's termio settings, and try to copy them.
+   I simply trace through the main modes (CLEFRAW,  CLEFCANONICAL) and
+   try to simulate them */
+void 
+check_flip(void)
+{
+  return;
+  
+#if 0
+  /*simply checks the termio structure of the child */
+  
+  if(tcgetattr(contNum, &childbuf) == -1) {
+    perror("clef parent getting child's terminal in check_termio");
+  }
+  if(childbuf.c_lflag & ICANON) {
+    if(MODE != CLEFCANONICAL) {
+      flip_canonical(contNum);
+      MODE = CLEFCANONICAL;
+    }
+  }
+  else {
+    if(MODE != CLEFRAW) {
+      flip_raw(contNum);
+      MODE = CLEFRAW;
+    }
+  }
+  /* While I am here, lets set the echo */
+  if(childbuf.c_lflag & ECHO) ECHOIT = 1;
+  else ECHOIT = 0;
+#endif
+}
+
+
+
+void
+flip_raw(int chann)
+{
+  
+  if(MODE == CLEFCANONICAL) 
+    send_buff_to_child(chann);
+  
+  if(tcsetattr(0, TCSAFLUSH, &rawbuf) == -1) {
+    perror("clef resetting parent to raw ");
+    exit(-1);
+  }
+}
+
+
+void
+flip_canonical(int chann)
+{
+  if(tcsetattr(0, TCSAFLUSH, &canonbuf) == -1) {
+    perror("clef resetting parent to canonical ");
+    exit(-1);
+  }
+  if(INS_MODE) 
+    Cursor_shape(5);
+  else 
+    Cursor_shape(2);
+}
+
+void
+etc_get_next_line(char * line,int * nr,int  fd)
+{
+  *nr = read(fd, line, 1024);
+  if(*nr == -1) {
+    perror("Reading /etc/master");
+  }
+  if(*nr == 0) {
+    fprintf(stderr, "Not found \n");
+  }
+}
+
+#define etc_whitespace(c) ((c == ' ' || c == '\t')?(1):(0))
+
+
+void
+set_function_chars(void)
+{
+  /* get the special characters */
+  _INTR = childbuf.c_cc[VINTR];
+  _QUIT = childbuf.c_cc[VQUIT];
+  _ERASE = childbuf.c_cc[VERASE];
+  _KILL = childbuf.c_cc[VKILL];
+  _EOF = childbuf.c_cc[VEOF];
+  _EOL = childbuf.c_cc[VEOL];
+  return;
+}
+\end{chunk}
+
+\chapter{Makefile}
+\begin{chunk}{Makefile}
+BOOK=${SPD}/books/bookvol8.pamphlet
+WORK=${OBJ}/${SYS}/graph
+OUTLIB=	${MNT}/${SYS}/lib
+OUTBIN=	${MNT}/${SYS}/bin
+LIB=    ${OBJ}/${SYS}/lib
+TESTFILE=${MNT}/${SYS}/graph/parabola.view
+PS=	${MNT}/${SYS}/lib/graph
+LISP    =${OBJ}/${SYS}/bin/lisp
+
+PSFiles= ${PS}/colorpoly.ps ${PS}/colorwol.ps  ${PS}/draw.ps      \
+         ${PS}/drawIstr.ps  ${PS}/drawarc.ps   ${PS}/drawcolor.ps \
+         ${PS}/drawline.ps  ${PS}/drawlines.ps ${PS}/drawpoint.ps \
+         ${PS}/drawrect.ps  ${PS}/drawstr.ps   ${PS}/drwfilled.ps \
+         ${PS}/end.ps       ${PS}/fillarc.ps   ${PS}/fillpoly.ps  \
+         ${PS}/fillwol.ps   ${PS}/header.ps    ${PS}/setup.ps
+
+CFLAGS  = ${CCF} -I${SRC}/include
+LDFLAGS = ${LDF} -lX11 -lm
+
+VLIBS=${LIB}/sockio-c.o ${LIB}/util.o  ${LIB}/bsdsignal.o 
+
+LIBS= ${VLIBS}      ${LIB}/pixmap.o    ${LIB}/halloc.o  ${LIB}/spadcolors.o \
+      ${LIB}/hash.o ${LIB}/xspadfill.o ${LIB}/xdither.o ${LIB}/xshade.o   
+
+CLEFOBJS= ${LIB}/edible.o ${LIB}/fnct-key.o ${LIB}/edin.o ${LIB}/bsdsignal.o \
+          ${LIB}/prt.o ${LIB}/wct.o ${LIB}/openpty.o ${LIB}/cursor.o
+
+all: announce ${OUTLIB}/viewman ${OUTLIB}/view2d \
+     ${OUTLIB}/view3d ${OUTBIN}/viewalone ${TESTFILE}/data ${PSFiles} \
+     ${OUTBIN}/clef finish
+	@ echo 0 finished ${BOOK}
+
+announce:
+	@ echo ================================
+	@ echo Making Graphics tools bookvol8
+	@ echo ================================
 
-dirs: 
-	@ echo 1 making target directories for bookvol8
-	@ mkdir -p ${WORK}
-	@ mkdir -p ${OUTBIN}
-	@ mkdir -p ${OUTLIB}
-	@ mkdir -p ${TESTFILE}
-	@ mkdir -p ${PS}
+finish:
+	@ echo ================================
+	@ echo Finish Graphics tools bookvol8
+	@ echo ================================
 
 ${OUTLIB}/viewman: ${BOOK}
 	@ echo 2 making ${OUTLIB}/viewman from ${BOOK}
 	@( cd ${WORK} ; \
-	 echo '(tangle "${BOOK}" "viewman" "viewman.c")' \
-           | ${LISP} 1>/dev/null 2>/dev/null ; \
+	   ${BOOKS}/tanglec ${BOOK} viewman >viewman.c ; \
 	   ${CC} ${CFLAGS} -c viewman.c ; \
 	   ${CC} ${VLIBS} viewman.o -o ${OUTLIB}/viewman ${LDFLAGS} )
 
 ${OUTLIB}/view2d: ${BOOK}
 	@ echo 3 making ${OUTLIB}/view2d from ${BOOK}
 	@( cd ${WORK} ; \
-	 echo '(tangle "${BOOK}" "view2d" "view2d.c")' \
-           | ${LISP} 1>/dev/null 2>/dev/null ; \
+	   ${BOOKS}/tanglec ${BOOK} view2d >view2d.c ; \
 	   ${CC} ${CFLAGS} -c view2d.c ; \
 	   ${CC} ${LIBS} view2d.o -o ${OUTLIB}/view2d ${LDFLAGS} )
 
 ${OUTLIB}/view3d: ${BOOK}
 	@ echo 4 making ${OUTLIB}/view3d from ${BOOK}
 	@( cd ${WORK} ; \
-	  echo '(tangle "${BOOK}" "view3d" "view3d.c")' \
-           | ${LISP} 1>/dev/null 2>/dev/null ; \
+	   ${BOOKS}/tanglec ${BOOK} view3d >view3d.c ; \
 	   ${CC} ${CFLAGS} -c view3d.c ; \
 	   ${CC} ${LIBS} view3d.o -o ${OUTLIB}/view3d ${LDFLAGS} )
 
 ${OUTBIN}/viewalone: ${BOOK}
 	@ echo 5 making ${OUTBIN}/viewalone from ${BOOK}
 	@( cd ${WORK} ; \
-	  echo '(tangle "${BOOK}" "viewalone" "viewalone.c")' \
-               | ${LISP} 1>/dev/null 2>/dev/null ; \
+	   ${BOOKS}/tanglec ${BOOK} viewalone >viewalone.c ; \
 	   ${CC} ${CFLAGS} -c viewalone.c ; \
 	   ${CC} ${VLIBS} viewalone.o -o ${OUTBIN}/viewalone ${LDFLAGS} )
 
 ${TESTFILE}/data: ${BOOK}
 	@ echo 6 making ${TESTFILE} from ${BOOK}
 	@ (cd ${TESTFILE} ; \
-	  echo '(tangle "${BOOK}" "parabola.view/data" "data")' \
-               | ${LISP} 1>/dev/null 2>/dev/null ; \
-	  echo '(tangle "${BOOK}" "parabola.view/graph0" "graph0")' \
-               | ${LISP} 1>/dev/null 2>/dev/null)
+	   ${BOOKS}/tanglec ${BOOK} "parabola.view/data" >data ; \
+	   ${BOOKS}/tanglec ${BOOK} "parabola.view/graph0" >graph0 )
 
 ${PS}/%.ps: ${BOOK} 
 	@ echo 7 ${PS}/$*.ps from ${BOOK} 
-	@ echo '(tangle "${BOOK}" "psfiles/$*" "${PS}/$*.ps")' \
-               | ${LISP} 1>/dev/null 2>/dev/null
+	@ ${BOOKS}/tanglec ${BOOK} "psfiles/$*" >"${PS}/$*.ps"
+
+${OUTBIN}/clef: ${BOOK}
+	@ echo 8 making ${OUTBIN}/clef from ${BOOK}
+	@( cd ${LIB} ; ${CC} ${CLEFOBJS} -o ${OUTBIN}/clef )
+
+libspad.a: ${BOOK}
+	@ echo ======================================
+	@ echo BUILDING LIB FILES
+	@ echo ======================================
+	@ ( cd ${LIB} ; \
+	 ${BOOKS}/tanglec ${BOOK} "bsdsignal.c"  >bsdsignal.c ; \
+	 ${CC} ${CCF} -c bsdsignal.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "cfuns-c.c"    >cfuns-c.c ; \
+	 ${CC} ${CCF} -c cfuns-c.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "cursor.c"     >cursor.c ; \
+	 ${CC} ${CCF} -c cursor.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "edin.c"       >edin.c ; \
+	 ${CC} ${CCF} -c edin.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "fnct-key.c"   >fnct-key.c ; \
+	 ${CC} ${CCF} -c fnct-key.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "halloc.c"     >halloc.c ; \
+	 ${CC} ${CCF} -c halloc.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "hash.c"       >hash.c ; \
+	 ${CC} ${CCF} -c hash.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "openpty.c"    >openpty.c ; \
+	 ${CC} ${CCF} -c openpty.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "pixmap.c"     >pixmap.c ; \
+	 ${CC} ${CCF} -c pixmap.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "prt.c"        >prt.c ; \
+	 ${CC} ${CCF} -c prt.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "sockio-c.c"   >sockio-c.c ; \
+	 ${CC} ${CCF} -c sockio-c.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "spadcolors.c" >spadcolors.c ; \
+	 ${CC} ${CCF} -c spadcolors.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "util.c"       >util.c ; \
+	 ${CC} ${CCF} -c util.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "wct.c"        >wct.c ; \
+	 ${CC} ${CCF} -c wct.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "xdither.c"    >xdither.c ; \
+	 ${CC} ${CCF} -c xdither.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "xshade.c"     >xshade.c ; \
+	 ${CC} ${CCF} -c xshade.c ; \
+	 ${BOOKS}/tanglec ${BOOK} "xspadfill.c"  >xspadfill.c ; \
+	 ${CC} ${CCF} -c xspadfill.c ; \
+	 ar ru libspad.a *.o ; \
+	 ${RANLIB} libspad.a )
+	@ ( cd ${LIB} ; \
+	 ${BOOKS}/tanglec ${BOOK} "edible.c"  >edible.c ; \
+	 ${CC} ${CCF} -c edible.c )
 
 \end{chunk}
 \begin{thebibliography}{99}
diff --git a/books/bookvolbib.pamphlet b/books/bookvolbib.pamphlet
index 5c53c87..905cf1b 100644
--- a/books/bookvolbib.pamphlet
+++ b/books/bookvolbib.pamphlet
@@ -3695,6 +3695,25 @@ Math. Tables Aids Comput. 10 91--96. (1956)
 ``On square-free decomposition algorithms''\\
 {\sl Proceedings of SYMSAC'76} pages 26-35, 1976
 
+\subsection{Z} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+
+\bibitem[Zhi 97]{Zhi97} Zhi, Lihong\\
+``Optimal Algorithm for Algebraic Factoring''\\
+\verb|www.mmrc.iss.ac.cn/~lzhi/Publications/zopfac.pdf|
+%\verb|axiom-developer.org/axiom-website/papers/Zhi97.pdf|
+
+\begin{adjustwidth}{2.5em}{0pt}
+This paper presents an optimized method for factoring multivariate
+polynomials over algebraic extension fields which defined by an
+irreducible ascending set. The basic idea is to convert multivariate
+polynomials to univariate polynomials and algebraic extensions fields
+to algebraic number fields by suitable integer substitutions, then
+factorize the univariate polynomials over the algebraic number fields.
+Finally, construct multivariate factors of the original polynomial by
+Hensel lemma and TRUEFACTOR test. Some examples with timing are
+included.
+\end{adjustwidth}
+
 \section{Special Topics} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
 \subsection{Solving Systems of Equations} %%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -4811,6 +4830,32 @@ implementations of simplification routines.
 
 \subsection{Integration} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
+\bibitem[Adamchik 97]{Adam97} Adamchik, Victor\\
+``A Class of Logarithmic Integrals''\\
+\verb|www.cs.cmu.edu/~adamchik/articles/issac/issac97.pdf|
+%\verb|axiom-developer.org/axiom-website/papers/Adam97.pdf|
+
+\begin{adjustwidth}{2.5em}{0pt}
+A class of definite integrals involving cyclotomic polynomials and
+nested logarithms is considered. The results are given in terms of
+derivatives of the Hurwitz Zeta function. Some special cases for which
+such derivatives can be expressed in closed form are also considered.
+\end{adjustwidth}
+
+\bibitem[Baddoura 89]{Bad89} Baddoura, Jamil\\
+``A Dilogarithmic Extension of Liouville's Theorem on Integration in Finite Terms''\\
+\verb|www.dtic.mil/dtic/tr/fulltext/u2/a206681.pdf|
+%\verb|axiom-developer.org/axiom-website/papers/Bad89.pdf|
+
+\begin{adjustwidth}{2.5em}{0pt}
+The result obtained generalizes Liouville's Theorem by allowing, in
+addition to the elementary functions, dilogarithms to appear in the
+integral of an elementary function. The basic conclusion is that an
+associated function to the dilogarihm, if dilogarithms appear in the
+integral, appears linearly, with logarithms appearing in a non-linear
+way.
+\end{adjustwidth}
+
 \bibitem[Baddoura 94]{Bad94} Baddoura, Mohamed Jamil\\
 ``Integration in Finite Terms with Elementary Functions and Dilogarithms''\\
 \verb|dspace.mit.edu/bitstream/handle/1721.1/26864/30757785.pdf|
@@ -4827,6 +4872,19 @@ functions by taking transcendental exponentials, dilogarithms, and
 logarithms.
 \end{adjustwidth}
 
+\bibitem[Bajpai 70]{Bajp70} Bajpai, S.D.\\
+``A contour integral involving legendre polynomial and Meijer's G-function''\\
+\verb|link.springer.com/article/10.1007/BF03049565|
+%\verb|axiom-developer.org/axiom-website/papers/Bajp70.pdf|
+
+\begin{adjustwidth}{2.5em}{0pt}
+In this paper a countour integral involving Legendre polynomial and
+Meijer's G-function is evaluated. the integral is of general character
+and it is a generalization of results recently given by Meijer,
+MacRobert and others.  An integral involving regular radial Coulomb
+wave function is also obtained as a particular case.
+\end{adjustwidth}
+
 \bibitem[Bronstein 97]{Bro97} Bronstein, M.\\ 
 ``Symbolic Integration I--Transcendental Functions.''\\
 Springer, Heidelberg, 1997 ISBN 3-540-21493-3
@@ -4868,11 +4926,51 @@ SIAM J. Comput. Vol 15 pp1-21 February 1986
 ``An Analysis of the Rational Exponential Integral''\\
 SIAM J. Computing Vol 18 pp 893-905 (1989)
 
+\bibitem[Churchill 06]{Chur06} Churchill, R.C.\\
+``Liouville's Theorem on Integration Terms of Elementary Functions''\\
+\verb|www.sci.ccny.cuny.edu/~ksda/PostedPapers/liouv06.pdf|
+%\verb|axiom-developer.org/axiom-website/papers/Chur06.pdf|
+
+\begin{adjustwidth}{2.5em}{0pt}
+This talk should be regarded as an elementary introduction to
+differential algebra. It culminates in a purely algebraic proof, due
+to M. Rosenlicht, of an 1835 theorem of Liouville on the existence of
+``elementary'' integrals of ``elementary'' functions. The precise
+meaning of elementary will be specified. As an application of that
+theorem we prove that the indefinite integral $\int{e^{x^2}}~dx$
+cannot be expressed in terms of elementary functions.
+\begin{itemize}
+\item Preliminaries on Meromorphic Functions
+\item Basic (Ordinary) Differential Algebra
+\item Differential Ring Extensions with No New Constants
+\item Extending Derivations
+\item Integration in Finite Terms
+\end{itemize}
+\end{adjustwidth}
+
 \bibitem[Davenport 79b]{Dav79b} Davenport, James Harold\\
 ``On the Integration of Algebraic Functions''\\
 Springer-Verlag Lecture Notes in Computer Science 102
 ISBN 0-387-10290-6
 
+\bibitem[Davenport 79c]{Dav79c} Davenport, J. H.\\
+``Algorithms for the Integration of Algebraic Functions''\\
+Lecture Notes in Computer Science V 72 pp415-425 (1979)
+%\verb|axiom-developer.org/axiom-website/papers/Dav79c.pdf|
+
+\begin{adjustwidth}{2.5em}{0pt}
+The problem of finding elementary integrals of algebraic functions has
+long been recognized as difficult, and has sometimes been thought
+insoluble. Risch stated a theorem characterising the integrands with
+elementary integrals, and we can use the language of algebraic
+geometry and the techniques of Davenport to yield an algorithm that will
+always produce the integral if it exists. We explain the difficulty in
+the way of extending this algorithm, and outline some ways of solving
+it. Using work of Manin we are able to solve the problem in all cases
+where the algebraic expressions depend on a parameter as well as on
+the variable of integration.
+\end{adjustwidth}
+
 \bibitem[Davenport 82]{Dav82} Davenport, J.H.\\
 ``On the Parallel Risch Algorithm (III): Use of Tangents''\\
 SIGSAM V16 no. 3 pp3-6 August 1982
@@ -4895,6 +4993,24 @@ Cambridge Unversity Press, Cambridge, 1916
 {\sl Nouvelles Annales de Math\'{e}matiques}
 ($2^{eme}$ s\'{e}rie), 11:145-148, 1872
 
+\bibitem[Horowitz 71]{Horo71} Horowitz, Ellis\\
+``Algorithms for Partial Fraction Decomposition and Rational Function Integration''
+%\verb|axiom-developer.org/axiom-website/papers/Horo71.pdf|
+
+\begin{adjustwidth}{2.5em}{0pt}
+Algorithms for symbolic partial fraction decomposition and indefinite
+integration of rational functions are described. Two types of
+partial fraction decomposition are investigated, square-free and
+complete square-free. A method is derived, based on the solution of
+a linear system, which produces the square-free decomposition of any
+rational function, say A/B. The computing time is show to be 
+$O(n^4(ln nf)^2)$ where ${\rm deg}(A) < {\rm\ deg}(B) = n$ and $f$
+is a number which is closely related to the size of the coefficients
+which occur in A and B. The complete square-free partical fraction
+decomposition can then be directly obtained and it is shown that the
+computing time for this process is also bounded by $O(n^4(ln nf)^2)$.
+\end{adjustwidth}
+
 \bibitem[Jeffrey 97]{Jeff97} Jeffrey, D.J.; Rich, A.D.\\
 ``Recursive integration of piecewise-continuous functions''\\
 \verb|www.cybertester.com/data/recint.pdf|
@@ -4942,6 +5058,19 @@ Journal of Symbolic Computation Vol 16 pp227-241 (1995)
 ``Algebra''\\
 Addison-Wesly, New York, 3rd edition 1993
 
+\bibitem[Leerawat 02]{Leer02} Leerawat, Utsanee; Laohakosol, Vichian\\
+``A Generalization of Liouville's Theorem on Integration in Finite Terms''\\
+\verb|www.mathnet.or.kr/mathnet/kms_tex/113666.pdf|
+%\verb|axiom-developer.org/axiom-website/papers/Leer02.pdf|
+
+\begin{adjustwidth}{2.5em}{0pt}
+A generalization of Liouville's theorem on integration in finite
+terms, by enlarging the class of fields to an extension called
+Ei-Gamma extension is established. This extension includes the
+$\mathcal{E}\mathcal{L}$-elementary extensions of Singer, Saunders and
+Caviness and contains the Gamma function.
+\end{adjustwidth}
+
 \bibitem[Liouville 1833a]{Lio1833a} Liouville, Joseph\\
 ``Premier m\'{e}moire sur la
 d\'{e}termination des int\'{e}grales dont la valeur est
@@ -5083,6 +5212,29 @@ involved.
 ``Integration in Finite Terms''\\
 Columbia University Press, New York 1948
 
+\bibitem[Rosenlicht 68]{Ro68} Rosenlicht, Maxwell\\
+``Liouville's Theorem on Functions with Elementary Integrals''\\
+Pacific Journal of Mathematics Vol 24 No 1 (1968)
+\verb|msp.org/pjm/1968/24-1/pjm-v24-n1-p16-p.pdf|
+\verb|axiom-developer.org/axiom-website/papers/Ro68.pdf|
+
+\begin{adjustwidth}{2.5em}{0pt}
+Defining a function with one variable to be elemetary if it has an
+explicit representation in terms of a finite number of algebraic
+operations, logarithms, and exponentials. Liouville's theorem in its
+simplest case says that if an algebraic function has an elementary
+integral then the latter is itself an algebraic function plus a sum of
+constant multiples of logarithms of algebraic functions. Ostrowski has
+generalized Liouville's results to wider classes of meromorphic
+functions on regions of the complex plane and J.F. Ritt has given the
+classical account of the entire subject in his Integraion in Finite
+Terms, Columbia University Press, 1948. In spite of the essentially
+algebraic nature of the problem, all proofs so far have been analytic.
+This paper gives a self contained purely algebraic exposition of the
+probelm, making a few new points in addition to the resulting
+simplicity and generalization.
+\end{adjustwidth}
+
 \bibitem[Rosenlicht 72]{Ro72} Rosenlicht, Maxwell\\
 ``Integration in finite terms''\\
 {\sl American Mathematical Monthly}, 79:963-972, 1972
@@ -5110,14 +5262,55 @@ Proc. Amer. Math. Soc. Vol 23 pp689-691 (1969)
 \bibitem[Singer 85]{Sing85} Singer, M.F.; Saunders, B.D.; Caviness, B.F.\\
 ``An extension of Liouville's theorem on integration in finite terms''\\
 SIAM J. of Comp. Vol 14 pp965-990 (1985)
+\verb|www4.ncsu.edu/~singer/papers/singer_saunders_caviness.pdf|
+%\verb|axiom-developer.org/axiom-website/papers/Sing85.pdf|
+
+\begin{adjustwidth}{2.5em}{0pt}
+In Part 1 of this paper, we give an extension of Liouville's Theorem
+and give a number of examples which show that integration with special
+functions involves some phenomena that do not occur in integration
+with the elementary functions alone. Our main result generalizes
+Liouville's Theorem by allowing, in addition to the elementary
+functions, special functions such as the error function, Fresnel
+integrals and the logarithmic integral (but not the dilogarithm or
+exponential integral) to appear in the integral of an elementary
+function. The basic conclusion is that these functions, if they
+appear, appear linearly. We give an algorithm which decides if an
+elementary function, built up using only exponential functions and
+rational operations has an integral which can be expressed in terms of
+elementary functions and error functions.
+\end{adjustwidth}
 
 \bibitem[Trager 76]{Tr76} Trager, Barry\\
 ``Algebraic factoring and rational function integration''\\
 In {Proceedings of SYMSAC'76} pages 219-226, 1976
+%\verb|axiom-developer.org/axiom-website/papers/Tr76.pdf|
+
+\begin{adjustwidth}{2.5em}{0pt}
+This paper presents a new, simple, and efficient algorithm for
+factoring polynomials in several variables over an algebraic number
+field. The algorithm is then used interatively to construct the
+splitting field of a polynomial over the integers. Finally the
+factorization and splitting field algorithms are applied to the
+problem of determining the transcendental part of the integral of a
+rational function. In particular, a constructive procedure is given
+for finding a least degree extension field in which the integral can
+be expressed.
+\end{adjustwidth}
 
 \bibitem[Trager 84]{Tr84} Trager, Barry\\
 ``On the integration of algebraic functions''\\
 PhD thesis, MIT, Computer Science, 1984
+\verb|www.dm.unipi.it/pages/gianni/public_html/Alg-Comp/thesis.pdf|
+%\verb|axiom-developer.org/axiom-website/papers/Tr84.pdf|
+
+\begin{adjustwidth}{2.5em}{0pt}
+We show how the ``rational'' approach for integrating algebraic
+functions can be extended to handle elementary functions. The
+resulting algorithm is a practical decision procedure for determining
+whether a given elementary function has an elementary antiderivative,
+and for computing it if it exists.
+\end{adjustwidth}
 
 \bibitem[W\"urfl 07]{Wurf07} W\"urfl, Andreas\\
 ``Basic Concepts of Differential Algebra''\\
diff --git a/books/tanglec.c b/books/tanglec.c
index 5eb6c11..ccd50be 100644
--- a/books/tanglec.c
+++ b/books/tanglec.c
@@ -31,9 +31,14 @@ int printline(int i, int length) {
 }
 
 /* handle begin{chunk}{chunkname}        */
-/* is this chunk name we are looking for? */
+/* is this chunk name we are looking for? &&
+   does the line start with \begin{chunk}? &&
+   is the next character a \{ &&
+   is the last character after the chunkname a \}
+*/
 int foundchunk(int i, char *chunkname) {
   if ((strncmp(&buffer[i+14],chunkname,strlen(chunkname)) == 0) &&
+      (strncmp(&buffer[i],"\\begin{chunk}",13) == 0) &&
       (buffer[i+13] == '{') &&
       (buffer[i+14+strlen(chunkname)] == '}')) {
     if (DEBUG==3) { printf("foundchunk(%s)\n",chunkname); }
diff --git a/changelog b/changelog
index b577274..9068c57 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,105 @@
+20140806 tpd src/axiom-website/patches.html 20140806.01.tpd.patch
+20140806 tpd Makefile merge include, lib, clef
+20140806 tpd books/Makefile merge include, lib, clef
+20140806 tpd books/bookvol10 merge include, lib, clef
+20140806 tpd books/bookvol11 merge include, lib, clef
+20140806 tpd books/bookvol3 merge include, lib, clef
+20140806 tpd books/bookvol4 merge include, lib, clef
+20140806 tpd books/bookvol6 merge include, lib, clef
+20140806 tpd books/bookvol7.1 merge include, lib, clef
+20140806 tpd books/bookvol7 merge include, lib, clef
+20140806 tpd books/bookvol8 merge include, lib, clef
+20140806 tpd books/bookvolbib merge include, lib, clef
+20140806 tpd books/tanglec.c fix criteria for finding chunkname
+20140806 tpd lsp/Makefile merge include, lib, clef
+20140806 tpd src/Makefile merge include, lib, clef
+20140806 tpd src/clef/Makefile remove include, lib, clef
+20140806 tpd src/clef/edible.c remove include, lib, clef
+20140806 tpd src/include/addfile.h1 remove include, lib, clef
+20140806 tpd src/include/all-hyper-proto.h1 remove include, lib, clef
+20140806 tpd src/include/bsdsignal.h remove include, lib, clef
+20140806 tpd src/include/bsdsignal.h1 remove include, lib, clef
+20140806 tpd src/include/cfuns-c.h1 remove include, lib, clef
+20140806 tpd src/include/com.h remove include, lib, clef
+20140806 tpd src/include/cond.h1 remove include, lib, clef
+20140806 tpd src/include/cursor.h1 remove include, lib, clef
+20140806 tpd src/include/debug.h remove include, lib, clef
+20140806 tpd src/include/dialog.h1 remove include, lib, clef
+20140806 tpd src/include/display.h1 remove include, lib, clef
+20140806 tpd src/include/edible.h remove include, lib, clef
+20140806 tpd src/include/edible.h1 remove include, lib, clef
+20140806 tpd src/include/edin.h1 remove include, lib, clef
+20140806 tpd src/include/event.h1 remove include, lib, clef
+20140806 tpd src/include/ex2ht.h1 remove include, lib, clef
+20140806 tpd src/include/extent1.h1 remove include, lib, clef
+20140806 tpd src/include/extent2.h1 remove include, lib, clef
+20140806 tpd src/include/fnct-key.h1 remove include, lib, clef
+20140806 tpd src/include/form-ext.h1 remove include, lib, clef
+20140806 tpd src/include/group.h1 remove include, lib, clef
+20140806 tpd src/include/halloc.h1 remove include, lib, clef
+20140806 tpd src/include/hash.h remove include, lib, clef
+20140806 tpd src/include/hash.h1 remove include, lib, clef
+20140806 tpd src/include/htadd.h1 remove include, lib, clef
+20140806 tpd src/include/hterror.h1 remove include, lib, clef
+20140806 tpd src/include/hthits.h1 remove include, lib, clef
+20140806 tpd src/include/htinp.h1 remove include, lib, clef
+20140806 tpd src/include/hyper.h1 remove include, lib, clef
+20140806 tpd src/include/initx.h1 remove include, lib, clef
+20140806 tpd src/include/input.h1 remove include, lib, clef
+20140806 tpd src/include/item.h1 remove include, lib, clef
+20140806 tpd src/include/keyin.h1 remove include, lib, clef
+20140806 tpd src/include/lex.h1 remove include, lib, clef
+20140806 tpd src/include/macro.h1 remove include, lib, clef
+20140806 tpd src/include/mem.h1 remove include, lib, clef
+20140806 tpd src/include/nagman.h1 remove include, lib, clef
+20140806 tpd src/include/openpty.h1 remove include, lib, clef
+20140806 tpd src/include/parse-aux.h1 remove include, lib, clef
+20140806 tpd src/include/parse-input.h1 remove include, lib, clef
+20140806 tpd src/include/parse-paste.h1 remove include, lib, clef
+20140806 tpd src/include/parse-types.h1 remove include, lib, clef
+20140806 tpd src/include/parse.h1 remove include, lib, clef
+20140806 tpd src/include/pixmap.h1 remove include, lib, clef
+20140806 tpd src/include/prt.h1 remove include, lib, clef
+20140806 tpd src/include/readbitmap.h1 remove include, lib, clef
+20140806 tpd src/include/rgb.h remove include, lib, clef
+20140806 tpd src/include/scrollbar.h1 remove include, lib, clef
+20140806 tpd src/include/session.h1 remove include, lib, clef
+20140806 tpd src/include/show-types.h1 remove include, lib, clef
+20140806 tpd src/include/sman.h1 remove include, lib, clef
+20140806 tpd src/include/sockio-c.h1 remove include, lib, clef
+20140806 tpd src/include/spadbuf.h1 remove include, lib, clef
+20140806 tpd src/include/spadclient.h1 remove include, lib, clef
+20140806 tpd src/include/spadcolors.h remove include, lib, clef
+20140806 tpd src/include/spadcolors.h1 remove include, lib, clef
+20140806 tpd src/include/spadint.h1 remove include, lib, clef
+20140806 tpd src/include/titlebar.h1 remove include, lib, clef
+20140806 tpd src/include/util.h1 remove include, lib, clef
+20140806 tpd src/include/view.h remove include, lib, clef
+20140806 tpd src/include/wct.h1 remove include, lib, clef
+20140806 tpd src/include/xdither.h1 remove include, lib, clef
+20140806 tpd src/include/xpm.h remove include, lib, clef
+20140806 tpd src/include/xshade.h1 remove include, lib, clef
+20140806 tpd src/include/xspadfill.h1 remove include, lib, clef
+20140806 tpd src/lib/Makefile remove include, lib, clef
+20140806 tpd src/lib/axiom.xpm remove include, lib, clef
+20140806 tpd src/lib/bsdsignal.c remove include, lib, clef
+20140806 tpd src/lib/cfuns-c.c remove include, lib, clef
+20140806 tpd src/lib/cursor.c remove include, lib, clef
+20140806 tpd src/lib/edin.c remove include, lib, clef
+20140806 tpd src/lib/emupty.c remove include, lib, clef
+20140806 tpd src/lib/fnct-key.c remove include, lib, clef
+20140806 tpd src/lib/halloc.c remove include, lib, clef
+20140806 tpd src/lib/hash.c remove include, lib, clef
+20140806 tpd src/lib/openpty.c remove include, lib, clef
+20140806 tpd src/lib/pixmap.c remove include, lib, clef
+20140806 tpd src/lib/prt.c remove include, lib, clef
+20140806 tpd src/lib/sockio-c.c remove include, lib, clef
+20140806 tpd src/lib/spadcolors.c remove include, lib, clef
+20140806 tpd src/lib/util.c remove include, lib, clef
+20140806 tpd src/lib/wct.c remove include, lib, clef
+20140806 tpd src/lib/xdither.c remove include, lib, clef
+20140806 tpd src/lib/xshade.c remove include, lib, clef
+20140806 tpd src/lib/xspadfill.c remove include, lib, clef
 20140802 tpd src/axiom-website/patches.html 20140802.02.tpd.patch
 20140802 tpd Makefile remove src/scripts directory
 20140802 tpd src/Makefile  remove src/scripts directory
diff --git a/lsp/Makefile.pamphlet b/lsp/Makefile.pamphlet
index 9b45cd1..6124bf8 100644
--- a/lsp/Makefile.pamphlet
+++ b/lsp/Makefile.pamphlet
@@ -763,8 +763,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -773,7 +771,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -816,8 +813,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -826,7 +821,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -869,8 +863,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -879,7 +871,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -927,8 +918,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -937,7 +926,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -977,8 +965,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -987,7 +973,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1020,8 +1005,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1030,7 +1013,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1074,8 +1056,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 113 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1084,7 +1064,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 115 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1117,8 +1096,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1127,7 +1104,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1158,8 +1134,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1168,7 +1142,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1200,8 +1173,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1210,7 +1181,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1241,8 +1211,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1251,7 +1219,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1282,8 +1249,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1292,7 +1257,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1324,8 +1288,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1334,7 +1296,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1366,8 +1327,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1376,7 +1335,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1408,8 +1366,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1418,7 +1374,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1524,8 +1479,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 10 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1534,7 +1487,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 12 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1626,8 +1578,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 21 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1636,7 +1586,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 23 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1664,8 +1613,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 22 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1674,7 +1621,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 24 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
@@ -1745,8 +1691,6 @@ gcldir:
 
 ccldir: ${LSP}/ccl/Makefile
 	@echo 14 building CCL
-	@mkdir -p ${INT}/ccl
-	@mkdir -p ${OBJ}/${SYS}/ccl
 	@( cd ccl ; ${ENV} ${MAKE} )
 
 ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
@@ -1755,7 +1699,6 @@ ${LSP}/ccl/Makefile: ${LSP}/ccl/Makefile.pamphlet
 
 document:
 	@echo 16 making docs in ${LSP}
-	@mkdir -p ${INT}/doc/lsp/ccl
 	@( cd ccl ; ${ENV} ${MAKE} document )
 
 clean:
diff --git a/patch b/patch
index e2cc112..b397b99 100644
--- a/patch
+++ b/patch
@@ -1,2 +1,4 @@
-Makefile, src/Makefile remove src/scripts directory
+merge and remove include, lib, and clef into books
 
+The include, lib, and clef subdirectories have been merged into 
+the related books. The directories were removed from the src tree.
diff --git a/src/Makefile.pamphlet b/src/Makefile.pamphlet
index fd4f454..5ab04d0 100644
--- a/src/Makefile.pamphlet
+++ b/src/Makefile.pamphlet
@@ -39,52 +39,18 @@ Since this varies from system to system it has been lifted
 up to the top level Makefile.pamphlet. If you add a new
 stanza to this Makefile you should check that list. 
 \begin{chunk}{environment}
-SETUP=libdir
 DIRS=${SRCDIRS}
-LTANGLE=${OBJ}/${SYS}/bin/lisp
 VOL11=${BOOKS}/bookvol11.pamphlet
 
 \end{chunk}
-\subsection{The clef directory}
-The {\bf clef} directory contains an Axiom command that works similar
-to GNU Readline.
-\begin{chunk}{clefdir}
-clefdir: ${SRC}/clef/Makefile
-	@echo 5 making ${SRC}/clef
-	@mkdir -p ${OBJ}/${SYS}/clef
-	@mkdir -p ${MNT}/${SYS}/doc/src/clef
-	@(cd clef ; ${ENV} ${MAKE} )
-
-${SRC}/clef/Makefile: ${SRC}/clef/Makefile.pamphlet
-	@echo 6 making ${SRC}/clef/Makefile from ${SRC}/clef/Makefile.pamphlet
-	@( cd clef ; \
-           ${EXTRACT} Makefile ; \
-           cp Makefile.pdf ${MNT}/${SYS}/doc/src/clef.Makefile.pdf )
-
-clefdocument: ${SRC}/clef/Makefile
-	@echo 7 documenting ${SRC}/clef
-	@mkdir -p ${INT}/doc/src/clef
-	@( cd clef ; ${ENV} ${MAKE} document )
-
-clefclean: ${SRC}/clef/Makefile
-	@echo 8 cleaning ${SRC}/clef
-	@( cd clef ; ${ENV} ${MAKE} clean )
-	@rm -f ${SRC}/clef/Makefile
-	@rm -f ${SRC}/clef/Makefile.dvi
-
-\end{chunk}
-\subsection{The clef directory}
+\subsection{The sman directory}
 Superman (sman) is the master process that runs all of the other
 processes including axiom, clef, nagman, graphics, and hyperdoc
 \begin{chunk}{smandir}
 smandir: ${SPD}/books/bookvol6.pamphlet
 	@echo 5 making ${SRC}/sman
-	@mkdir -p ${INT}/sman
-	@mkdir -p ${OBJ}/${SYS}/sman
-	@mkdir -p ${MNT}/${SYS}/doc/src/sman
 	@( cd sman ; \
-          echo '(tangle "${SPD}/books/bookvol6.pamphlet" "*" "Makefile")' \
-        | ${LTANGLE} ; \
+	   ${BOOKS}/tanglec ${BOOKS}/bookvol6.pamphlet >Makefile ; \
            ${ENV} ${MAKE} )
 
 \end{chunk}
@@ -95,7 +61,6 @@ system.
 \begin{chunk}{sharedir}
 sharedir: ${SRC}/share/Makefile
 	@echo 9 making ${SRC}/share
-	@mkdir -p ${MNT}/${SYS}/lib
 	@(cd share ; ${ENV} ${MAKE} )
 
 ${SRC}/share/Makefile: ${SRC}/share/Makefile.pamphlet
@@ -107,7 +72,6 @@ ${SRC}/share/Makefile: ${SRC}/share/Makefile.pamphlet
 
 sharedocument: ${SRC}/share/Makefile
 	@echo 11 documenting ${SRC}/share
-	@mkdir -p ${INT}/doc/src/share
 	@( cd share ; ${ENV} ${MAKE} document )
 
 shareclean: ${SRC}/share/Makefile
@@ -117,40 +81,6 @@ shareclean: ${SRC}/share/Makefile
 	@rm -f ${SRC}/share/Makefile.dvi
 
 \end{chunk}
-\subsection{The lib directory}
-The {\bf lib} directory is used to build {\bf libspad.a} which 
-contains C code for extending the underlying Common Lisp systems.
-It is built early in the process of system building because we
-need to make {\bf libspad.a} before we make the Common Lisps.
-
-\begin{chunk}{libdir}
-libdir: ${SRC}/lib/Makefile
-	@echo 17 making ${SRC}/lib
-	@mkdir -p ${INT}/lib
-	@mkdir -p ${OBJ}/${SYS}/lib
-	@mkdir -p ${INT}/doc/src/lib
-	@mkdir -p ${MNT}/${SYS}/doc/src/lib
-	@(cd lib ; ${ENV} ${MAKE} )
-
-${SRC}/lib/Makefile: ${SRC}/lib/Makefile.pamphlet
-	@echo 18 making ${SRC}/lib/Makefile from ${SRC}/lib/Makefile.pamphlet
-	@( cd lib ; \
-           ${EXTRACT} Makefile ; \
-           cp Makefile.pdf ${MNT}/${SYS}/doc/src/lib.Makefile.pdf )
-
-libdocument: ${SRC}/lib/Makefile
-	@echo 19 documenting ${SRC}/lib
-	@mkdir -p ${INT}/doc/src/lib
-	@( cd lib ; ${ENV} ${MAKE} document )
-
-libclean: ${SRC}/lib/Makefile
-	@echo 20 cleaning ${SRC}/lib
-	@( cd lib ; ${ENV} ${MAKE} clean )
-	@rm -rf ${OBJ}/${SYS}/lib
-	@rm -f ${SRC}/lib/Makefile
-	@rm -f ${SRC}/lib/Makefile.dvi
-
-\end{chunk}
 \subsection{The boot directory}
 Axiom is built in layers. The first layer is contructed into
 an image called {\bf bootsys}. The {\bf bootsys} image is used
@@ -163,9 +93,6 @@ common lisp form. This directory contains those files.
 \begin{chunk}{bootdir}
 bootdir: ${SRC}/boot/Makefile
 	@echo 21 making ${SRC}/boot
-	@mkdir -p ${INT}/boot
-	@mkdir -p ${OBJ}/${SYS}/boot
-	@mkdir -p ${MNT}/${SYS}/doc/src/boot
 	@(cd boot ; ${ENV} ${MAKE} )
 
 ${SRC}/boot/Makefile: ${SRC}/boot/Makefile.pamphlet
@@ -176,8 +103,6 @@ ${SRC}/boot/Makefile: ${SRC}/boot/Makefile.pamphlet
 
 bootdocument: ${SRC}/boot/Makefile
 	@echo 23 documenting ${SRC}/boot
-	@mkdir -p ${MNT}/${SYS}/doc/src/boot
-	@mkdir -p ${INT}/doc/src/boot
 	@( cd boot ; ${ENV} ${MAKE} document )
 
 bootclean: ${SRC}/boot/Makefile
@@ -206,19 +131,11 @@ function buildHtMacroTable (htcheck.boot)
 \begin{chunk}{interpdir}
 interpdir: ${SRC}/interp/Makefile
 	@echo 25 making ${SRC}/interp
-	@mkdir -p ${INT}/interp
-	@mkdir -p ${INT}/algebra
-	@mkdir -p ${OBJ}/${SYS}/interp
-	@mkdir -p ${MNT}/${SYS}/autoload
-	@mkdir -p ${MNT}/${SYS}/algebra
-	@mkdir -p ${MNT}/${SYS}/doc/msgs
-	@mkdir -p ${MNT}/${SYS}/doc/src/interp
 	@cp ${SPD}/books/bookvol5.pamphlet interp
 	@cp ${SPD}/books/bookvol9.pamphlet interp
 	@cp ${SPD}/books/bookvol10.5.pamphlet interp
 	@(cd ${MNT}/${SYS}/doc ; \
-      echo '(tangle "${SPD}/books/bookvol7.1.pamphlet" "util.ht" "util.ht")' \
-       | ${LTANGLE} )
+          ${BOOKS}/tanglec ${BOOKS}/bookvol7.1.pamphlet util.ht >util.ht )
 	@(cd interp ; ${ENV} ${MAKE} )
 
 ${SRC}/interp/Makefile: ${SRC}/interp/Makefile.pamphlet
@@ -230,8 +147,6 @@ ${SRC}/interp/Makefile: ${SRC}/interp/Makefile.pamphlet
 
 interpdocument: ${SRC}/interp/Makefile
 	@echo 27 documenting ${SRC}/interp
-	@mkdir -p ${MNT}/${SYS}/doc/src/interp
-	@mkdir -p ${INT}/doc/src/interp
 	@( cd interp ; ${ENV} ${MAKE} document )
 
 interpclean: ${SRC}/interp/Makefile
@@ -260,9 +175,6 @@ that nothing has been broken in the process of fixing bugs.
 \begin{chunk}{inputdir}
 inputdir: ${SRC}/input/Makefile
 	@echo 33 making ${SRC}/input
-	@mkdir -p ${INT}/input
-	@mkdir -p ${MNT}/${SYS}/input
-	@mkdir -p ${MNT}/${SYS}/doc/src/input
 	@(cd input ; ${ENV} ${MAKE} )
 #	@(cd input ; ${ENV} ${MAKE} -j 10)
 
@@ -275,7 +187,6 @@ ${SRC}/input/Makefile: ${SRC}/input/Makefile.pamphlet
 
 inputdocument: ${SRC}/input/Makefile
 	@echo 35 documenting ${SRC}/input
-	@mkdir -p ${INT}/doc/src/input
 	@( cd input ; ${ENV} ${MAKE} document )
 
 inputclean: ${SRC}/input/Makefile
@@ -295,9 +206,6 @@ categories from the shell without running Axiom.
 \begin{chunk}{etcdir}
 etcdir: ${SRC}/etc/Makefile
 	@echo 37 making ${SRC}/etc
-	@mkdir -p ${OBJ}/${SYS}/etc
-	@mkdir -p ${MNT}/${SYS}/bin
-	@mkdir -p ${MNT}/${SYS}/lib
 	@(cd etc ; ${ENV} ${MAKE} )
 
 ${SRC}/etc/Makefile: ${SRC}/etc/Makefile.pamphlet
@@ -308,7 +216,6 @@ ${SRC}/etc/Makefile: ${SRC}/etc/Makefile.pamphlet
 
 etcdocument: ${SRC}/etc/Makefile
 	@echo 39 documenting ${SRC}/etc
-	@mkdir -p ${INT}/doc/src/etc
 	@( cd etc ; ${ENV} ${MAKE} document )
 
 etcclean: ${SRC}/etc/Makefile
@@ -329,22 +236,15 @@ final doc directory.
 \begin{chunk}{docdir}
 docdir: 
 	@echo 41 making ${SRC}/doc
-	@mkdir -p ${INT}/doc
-	@mkdir -p ${MNT}/${SYS}/bin
-	@mkdir -p ${MNT}/${SYS}/doc/hypertex/bitmaps
 	@(cd ${MNT}/${SYS}/doc/hypertex ; \
-         echo '(tangle "${VOL11}" "axiom1.bitmap" "bitmaps/axiom1.bitmap")' \
-               | ${LTANGLE} ; \
-         echo '(tangle "${VOL11}" "rcm3720.input" "rcm3720.input")' \
-               | ${LTANGLE} ; \
-	 echo '(tangle "${VOL11}" "strang.input" "strang.input")' \
-               | ${LTANGLE} ; \
-	 echo '(tangle "${VOL11}" "signatures.txt" "signatures.txt")' \
-               | ${LTANGLE} )
-	@ cp ${BOOKS}/ps/doctitle.png ${AXIOM}/doc/hypertex/doctitle.png
-	@ cp ${BOOKS}/ps/lightbayou.png ${AXIOM}/doc/hypertex/lightbayou.png
+	 ${BOOKS}/tanglec axiom1.bitmap >bitmaps/axiom1.bitmap ; \
+	 ${BOOKS}/tanglec rcm3720.input >rcm3720.input ; \
+	 ${BOOKS}/tanglec strang.input >strang.input ; \
+	 ${BOOKS}/tanglec signatures.txt >signatures.txt ; \
+	 cp ${BOOKS}/ps/doctitle.png ${AXIOM}/doc/hypertex/doctitle.png ; \
+	 cp ${BOOKS}/ps/lightbayou.png ${AXIOM}/doc/hypertex/lightbayou.png ) 
 	@(cd ${MNT}/${SYS}/doc/hypertex ; \
-	  ${BOOKS}/tanglec ${SPD}/books/bookvol11.pamphlet >Makefile11 ; \
+	  ${BOOKS}/tanglec ${BOOKS}/bookvol11.pamphlet >Makefile11 ; \
 	  ${ENV} ${MAKE} -f Makefile11 ; \
 	  rm -f Makefile11 )
 
@@ -354,19 +254,12 @@ Hyperdoc is the Axiom document browser.
 \begin{chunk}{hyperdir}
 hyperdir: ${SPD}/books/bookvol7.pamphlet ${SPD}/books/bookvol7.1.pamphlet
 	@echo 7 making hyperdoc from bookvol7
-	@mkdir -p ${INT}/hyper
-	@mkdir -p ${OBJ}/${SYS}/hyper
-	@mkdir -p ${OBJ}/${SYS}/bin
-	@mkdir -p ${OBJ}/${SYS}/lib
-	@mkdir -p ${MNT}/${SYS}/doc/src/hyper
 	@(cd ${INT}/hyper ; \
-          echo '(tangle "${SPD}/books/bookvol7.pamphlet" "*" "Makefile")' \
-          | ${LTANGLE} ; \
+          ${BOOKS}/tanglec ${BOOKS}/bookvol7.pamphlet >Makefile ; \
 	  ${ENV} ${MAKE} )
 	@echo 7.1 making pages from bookvol7.1 ${ENV}
 	@(cd ${INT}/hyper ; \
-          echo '(tangle "${SPD}/books/bookvol7.1.pamphlet" "*" "Makefile")' \
-          | ${LTANGLE} ; \
+          ${BOOKS}/tanglec ${BOOKS}/bookvol7.1.pamphlet >Makefile ; \
 	  ${ENV} ${MAKE} )
 
 \end{chunk}
@@ -374,10 +267,8 @@ hyperdir: ${SPD}/books/bookvol7.pamphlet ${SPD}/books/bookvol7.1.pamphlet
 \begin{chunk}{graphdir}
 graphdir: ${SPD}/books/bookvol8.pamphlet
 	@echo 8 making graph from bookvol8
-	@mkdir -p ${OBJ}/${SYS}/graph
 	@(cd ${OBJ}/${SYS}/graph ; \
-	 echo '(tangle "${SPD}/books/bookvol8.pamphlet" "*" "Makefile")' \
-               | ${LTANGLE} ; \
+          ${BOOKS}/tanglec ${BOOKS}/bookvol8.pamphlet Makefile >Makefile ; \
 	  ${ENV} ${MAKE} )
 
 \end{chunk}
@@ -428,14 +319,6 @@ and bookvol10.3 (Packages) to the src/algebra subdirectory.
 algebradir: ${SRC}/algebra/Makefile ${SPD}/books/bookvol10.pamphlet \
             ${SPD}/books/bookvol7.1.pamphlet
 	@echo 29 making ${SRC}/algebra
-	@mkdir -p ${INT}/algebra
-	@mkdir -p ${INT}/input
-	@mkdir -p ${OBJ}/${SYS}/algebra
-	@mkdir -p ${MNT}/${SYS}/algebra
-	@mkdir -p ${MNT}/${SYS}/doc/src/algebra
-	@mkdir -p ${MNT}/${SYS}/doc/spadhelp
-	@mkdir -p ${MNT}/${SYS}/src/algebra
-	@mkdir -p ${INT}/input
 	@(cd algebra ; ${ENV} ${MAKE} )
 
 ${SRC}/algebra/Makefile: ${BOOKS}/bookvol10.pamphlet
@@ -473,7 +356,6 @@ post processing. Thus the "-j 10" argument to make. We use
 \begin{chunk}{browserdir}
 browserdir: ${SPD}/books/bookvol11.pamphlet
 	@echo 11 making browser from bookvol11
-#	@mkdir -p ${MNT}/${SYS}/doc/hypertex/bitmaps
 #	@(cd ${MNT}/${SYS}/doc/hypertex ; \
 #	  ${BOOKS}/tanglec ${SPD}/books/bookvol11.pamphlet >Makefile11 ; \
 #	  ${ENV} ${MAKE} -j 10 -f Makefile11 ; \
@@ -483,10 +365,6 @@ browserdir: ${SPD}/books/bookvol11.pamphlet
 
 \section{The Makefile}
 
-The {\bf libdir} stanza is executed
-to build {\bf libspad.a} which contains code needed by the underlying
-lisp.
-
 The second call will execute the {\bf all} stanza. This stanza walks 
 all of the lower level directories.
 \begin{chunk}{*}
@@ -507,7 +385,6 @@ setup: ${SETUP}
 \getchunk{smandir}
 \getchunk{sharedir}
 \getchunk{docdir}
-\getchunk{libdir}
 \getchunk{bootdir}
 \getchunk{interpdir}
 \getchunk{algebradir}
diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html
index 4ca6d8d..3bd3b93 100644
--- a/src/axiom-website/patches.html
+++ b/src/axiom-website/patches.html
@@ -4598,10 +4598,12 @@ src/lib/fnct-key.c remove 'save_echo', unused variable<br/>
 books/Makefile.pamphlet, bbold.sty add bbold.sty<br/>
 <a href="patches/20140801.02.tpd.patch">20140801.02.tpd.patch</a>
 books/bookvol5, SPADEDIT, move spadedit to bookvol5<br/>
-<a href="patches/20140808.01.tpd.patch">20140808.01.tpd.patch</a>
+<a href="patches/20140802.01.tpd.patch">20140802.01.tpd.patch</a>
 src/axiom-website/download.html add binary links<br/>
-<a href="patches/20140808.02.tpd.patch">20140808.02.tpd.patch</a>
+<a href="patches/20140802.02.tpd.patch">20140802.02.tpd.patch</a>
 Makefile, src/Makefile remove src/scripts directory<br/>
+<a href="patches/20140806.01.tpd.patch">20140806.01.tpd.patch</a>
+merge and remove include, lib, and clef into books<br/>
  </body>
 </html>
 
diff --git a/src/clef/Makefile.pamphlet b/src/clef/Makefile.pamphlet
deleted file mode 100644
index 4f8e457..0000000
--- a/src/clef/Makefile.pamphlet
+++ /dev/null
@@ -1,86 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/clef Makefile}
-\author{Timothy Daly}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{Environment variables}
-\begin{chunk}{environment}
-# this is where we are compiling from
-IN=     ${SRC}/clef
-
-# this is the intermediate place 
-MID=    ${OBJ}/${SYS}/clef
-
-# this is where to put the clef command
-OUT=	${MNT}/${SYS}/bin
-
-# this is where the include files live
-INC=    ${SRC}/include
-
-# this is where we hid the libspad library
-LIB=	${OBJ}/${SYS}/lib
-
-DOC=    ${MNT}/${SYS}/doc/src/clef
-
-# this is the set of files that comprise clef
-OBJS= ${MID}/edible.o
-
-CFLAGS=	${CCF} 
-LDFLAGS= -L${LIB} -lspad ${LDF}
-
-CLEFOBJS= ${MID}/edible.o ${LIB}/fnct-key.o ${LIB}/edin.o ${LIB}/bsdsignal.o \
-          ${LIB}/prt.o ${LIB}/wct.o ${LIB}/openpty.o ${LIB}/cursor.o
-
-DOCFILES=${DOC}/edible.c.dvi
-
-\end{chunk}
-\section{The clef sources, edible}
-\begin{chunk}{edible}
-${OUT}/clef:	${CLEFOBJS}
-	@ echo sc1 linking clef
-	@ ${CC} ${CLEFOBJS} -o ${OUT}/clef
-
-${MID}/edible.c: ${IN}/edible.c.pamphlet
-	@ echo sc2 making ${MID}/edible.c from ${IN}/edible.c.pamphlet
-	@ (cd ${MID} ; ${BOOKS}/tanglec ${IN}/edible.c.pamphlet >edible.c )
-
-${MID}/edible.o: ${MID}/edible.c ${INC}/edible.h
-	@ echo sc3 making ${MID}/edible.o from ${MID}/edible.c
-	@ ( cd ${MID} ; ${CC} -c ${CFLAGS} edible.c -I${INC} )
-
-${DOC}/edible.c.dvi: ${IN}/edible.c.pamphlet 
-	@ echo sc4 making ${DOC}/edible.c.dvi from ${IN}/edible.c.pamphlet
-	@ (cd ${DOC} ; \
-	cp ${IN}/edible.c.pamphlet ${DOC} ; \
-	${EXTRACT} edible.c.pamphlet >edible.c ; \
-	rm -f ${DOC}/edible.c.pamphlet ; \
-	rm -f ${DOC}/edible.c.tex ; \
-	rm -f ${DOC}/edible.c )
-
-\end{chunk}
-\begin{chunk}{*}
-\getchunk{environment}
-all:	announce ${OUT}/clef ${DOCFILES}
-	@ echo sc6 finished ${IN}
-
-announce:
-	@ echo ======================================
-	@ echo src/clef BUILDING CLEF
-	@ echo ======================================
-
-clean:
-	@echo sc7 cleaning ${SRC}/clef
-
-\getchunk{edible}
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/clef/edible.c.pamphlet b/src/clef/edible.c.pamphlet
deleted file mode 100644
index 1242a23..0000000
--- a/src/clef/edible.c.pamphlet
+++ /dev/null
@@ -1,732 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/clef edible.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\section{edible Call Graph}
-This was generated by the GNU cflow program with the argument list.
-Note that the line:NNNN numbers refer to the line in the code after
-it has been tangled from this file.
-\begin{verbatim}
-cflow --emacs -l -n -b -T --omit-arguments edible.c
-\end{verbatim}
-\begin{verbatim}
-;; This file is generated by GNU cflow 1.3. -*- cflow -*-
-    2 {   0} +-main() <int main () line:122>
-    3 {   1}   +-ptyopen()
-    4 {   1}   +-perror()
-    5 {   1}   +-exit()
-    6 {   1}   +-catch_signals() <void catch_signals () line:482>
-    7 {   2}   | +-sprintf()
-    8 {   2}   | +-getpid()
-    9 {   2}   | +-open()
-   10 {   2}   | +-write()
-   11 {   2}   | +-strlen()
-   12 {   2}   | +-close()
-   13 {   2}   | +-bsdSignal()
-   14 {   2}   | +-hangup_handler() <void hangup_handler () line:374>
-   15 {   3}   |   +-open()
-   16 {   3}   |   +-write()
-   17 {   3}   |   +-strlen()
-   18 {   3}   |   +-close()
-   19 {   3}   |   +-kill()
-   20 {   3}   |   +-tcsetattr()
-   21 {   3}   |   +-perror()
-   22 {   3}   |   +-printf()
-   23 {   3}   |   +-unlink()
-   24 {   3}   |   \-exit()
-   25 {   2}   | +-child_handler() <void child_handler () line:430>
-   26 {   3}   |   +-open()
-   27 {   3}   |   +-write()
-   28 {   3}   |   +-strlen()
-   29 {   3}   |   +-close()
-   30 {   3}   |   +-Cursor_shape()
-   31 {   3}   |   +-kill()
-   32 {   3}   |   +-tcsetattr()
-   33 {   3}   |   +-perror()
-   34 {   3}   |   +-printf()
-   35 {   3}   |   +-unlink()
-   36 {   3}   |   \-exit()
-   37 {   2}   | +-terminate_handler() <void terminate_handler () line:396>
-   38 {   3}   |   +-open()
-   39 {   3}   |   +-write()
-   40 {   3}   |   +-strlen()
-   41 {   3}   |   +-close()
-   42 {   3}   |   +-sleep()
-   43 {   3}   |   +-kill()
-   44 {   3}   |   +-tcsetattr()
-   45 {   3}   |   +-perror()
-   46 {   3}   |   +-printf()
-   47 {   3}   |   +-Cursor_shape()
-   48 {   3}   |   +-fprintf()
-   49 {   3}   |   +-unlink()
-   50 {   3}   |   \-exit()
-   51 {   2}   | +-interrupt_handler() <void interrupt_handler () line:418>
-   52 {   3}   |   +-open()
-   53 {   3}   |   +-write()
-   54 {   3}   |   +-strlen()
-   55 {   3}   |   +-close()
-   56 {   3}   |   +-sleep()
-   57 {   3}   |   \-kill()
-   58 {   2}   | +-alarm_handler() <void alarm_handler () line:452>
-   59 {   3}   | | +-getppid()
-   60 {   3}   | | +-open()
-   61 {   3}   | | +-write()
-   62 {   3}   | | +-strlen()
-   63 {   3}   | | +-close()
-   64 {   3}   | | +-alarm()
-   65 {   3}   | | +-tcsetattr()
-   66 {   3}   | | +-perror()
-   67 {   3}   | | +-Cursor_shape()
-   68 {   3}   | | +-fprintf()
-   69 {   3}   | | +-unlink()
-   70 {   3}   | | \-exit()
-   71 {   2}   | \-alarm()
-   72 {   1}   +-strcmp()
-   73 {   1}   +-load_wct_file()
-   74 {   1}   +-fprintf()
-   75 {   1}   +-skim_wct()
-   76 {   1}   +-sprintf()
-   77 {   1}   +-getpid()
-   78 {   1}   +-open()
-   79 {   1}   +-tcgetattr()
-   80 {   1}   +-fork()
-   81 {   1}   +-setsid()
-   82 {   1}   +-dup2()
-   83 {   1}   +-close()
-   84 {   1}   +-tcsetattr()
-   85 {   1}   +-execvp()
-   86 {   1}   +-getenv()
-   87 {   1}   +-strdup()
-   88 {   1}   +-execlp()
-   89 {   1}   +-getppid()
-   90 {   1}   +-init_flag()
-   91 {   1}   +-define_function_keys()
-   92 {   1}   +-init_reader()
-   93 {   1}   +-init_parent() <void init_parent () line:328>
-   94 {   2}   | +-tcgetattr()
-   95 {   2}   | +-perror()
-   96 {   2}   | +-exit()
-   97 {   2}   | +-tcsetattr()
-   98 {   2}   | \-Cursor_shape()
-   99 {   1}   +-FD_ZERO()
-  100 {   1}   +-FD_SET()
-  101 {   1}   +-set_function_chars() <void set_function_chars () line:575>
-  102 {   1}   +-write()
-  103 {   1}   +-strlen()
-  104 {   1}   +-select()
-  105 {   1}   +-check_flip() <void check_flip () line:502>
-  106 {   2}   | +-tcgetattr()
-  107 {   2}   | +-perror()
-  108 {   2}   | +-flip_canonical() <void flip_canonical () line:547>
-  109 {   3}   |   +-tcsetattr()
-  110 {   3}   |   +-perror()
-  111 {   3}   |   +-exit()
-  112 {   3}   |   \-Cursor_shape()
-  113 {   2}   | \-flip_raw() <void flip_raw () line:533>
-  114 {   3}   |   +-send_buff_to_child()
-  115 {   3}   |   +-tcsetattr()
-  116 {   3}   |   +-perror()
-  117 {   3}   |   \-exit()
-  118 {   1}   +-FD_ISSET()
-  119 {   1}   +-read()
-  120 {   1}   +-back_up()
-  121 {   1}   +-print_whole_buff()
-  122 {   1}   \-do_reading()
-\end{verbatim}
-\begin{chunk}{*}
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <string.h>
-#include <termios.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/time.h>
-#include <errno.h>
-#include <signal.h>
-
-
-#if defined (SGIplatform)
-#include <bstring.h>
-#endif
-
-
-#include "edible.h"
-#include "com.h"
-#include "bsdsignal.h"
-
-#include "bsdsignal.h1"
-#include "openpty.h1"
-#include "prt.h1"
-#include "edin.h1"
-#include "wct.h1"
-#include "edible.h1"
-#include "fnct-key.h1"
-
-#ifdef AXIOM_UNLIKELY
-#define log 1
-#define logterm 1
-#define siglog 1
-#endif
-
-
-#define Cursor_shape(x) 
-
-
-#ifdef siglog
-int sigfile;
-char sigbuff[256];
-#endif
-
-/*   Here are the term structures I need for setting and resetting the
-     terminal characteristics. */
-
-struct termios childbuf;   /* the childs normal operating termio */
-struct termios oldbuf;     /* the initial settings */
-struct termios rawbuf;     /* the parents raw state, when it is doing nothing */
-struct termios canonbuf;   /* set it to be canonical */
-
-/*   the terminals mapping of the function keys */
-unsigned char  _INTR, _QUIT, _ERASE, _KILL, _EOF, _EOL, _RES1, _RES2;
-
-
-int ppid;        /* the parents's parent pid */
-int child_pid;   /* the childs process id */
-
-short INS_MODE ;    /* Flag for insert mode */
-short ECHOIT = 1;   /* Flag for echoing */
-short PTY;          /* Flag which tells me whether I should echo newlines */
-
-int MODE;    /* am I in cbreak, raw, or canonical */
-
-char in_buff[1024];   /* buffer for storing characters read until they are processed */
-char buff[MAXLINE];                 /**  Buffers for collecting input and  **/
-int  buff_flag[MAXLINE];      /**     flags for whether buff chars
-                                           are printing
-                                           or non-printing                **/
-
-
-char controllerPath[20];  /* path name for opening the controller side */
-char serverPath[20];      /* path name for opening the server side     */
-
-int contNum, serverNum;          /* file descriptors for pty's */
-int num_read;                    /* Number of chars read */
-
-#ifdef log 
-int logfd;
-char logpath[30];
-#endif
-
-int
-main(int argc, char *argv[])
-{
-  fd_set rfds;                  /* the structure for the select call */
-  int code;                    /* return code from system calls */
-  char out_buff[MAXLINE];       /* from child and stdin */
-  int out_flag[MAXLINE] ; /* initialize the output flags */
-  char *program;          /* a string to hold the child program invocation */ 
-  char **pargs = 0;             /* holds parts of the command line */
-  int not_command = 1;          /* a flag while parsing the command line */
-  
-  
-  
-  /* try to get a pseudoterminal to play with */
-  if (ptyopen(&contNum, &serverNum, controllerPath, serverPath) == -1) {
-    perror("ptyopen failed");
-    exit(-1);
-  }
-  
-  /* call the routine that handles signals */
-  catch_signals();
-  
-  /* parse the command line arguments - as with the aixterm  the command 
-     argument -e should be last on the line. */
-  
-  while(*++argv && not_command) {
-    if(!strcmp(*argv, "-f"))
-      load_wct_file(*++argv);
-    else if(!strcmp(*argv, "-e")) {
-      not_command = 0;
-      pargs = ++argv;
-    }
-    else {
-      fprintf(stderr, "usage: clef [-f fname] -e command\n");
-      exit(-1);
-    }
-  }
-  skim_wct(); 
-  
-#ifdef log 
-  sprintf(logpath, "/tmp/cleflog%d", getpid());
-  logfd = open(logpath, O_CREAT | O_RDWR, 0666);
-#endif
-  
-  /* get the original termio settings, so the child has them */
-  
-  if(tcgetattr(0,&childbuf) == -1) {
-    perror("clef trying to get the initial terminal settings");
-    exit(-1);
-  }
-  
-  /* start the child process */
-  
-  child_pid = fork();
-  switch(child_pid) {
-  case -1 :
-    perror("clef can't create a new process");
-    exit(-1);
-  case 0:
-    /* CHILD */
-    /* Dissasociate form my parents group so all my child processes
-       look at my terminal as the controlling terminal for the group */
-    setsid();
-
-    serverNum = open(serverPath,O_RDWR);
-    if (serverNum == -1) perror("open serverPath failed");
-
-    /* since I am the child, I can close ptc, and dup pts for all it
-       standard descriptors */
-    if (dup2(serverNum, 0) == -1) perror("dup2 0 failed");
-    if (dup2(serverNum, 1) == -1) perror("dup2 1 failed");
-    if (dup2(serverNum, 2) == -1) perror("dup2 2 failed");
-    if( (dup2(serverNum, 0) == -1)  ||
-	(dup2(serverNum, 1) == -1) ||
-	(dup2(serverNum, 2) == -1)  ) {
-      perror("clef trying to dup2");
-      exit(-1);
-    }
-    
-    /* since they have been duped, close them */
-    close(serverNum);
-    close(contNum); 
-    
-    
-    /* To make sure everything is nice, set off enhedit */
-    /*    childbuf.c_line = 0; */
-    
-    /* reconfigure the child's terminal get echoing */
-    if(tcsetattr(0, TCSAFLUSH, &childbuf) == -1) {
-      perror("clef child trying to set child's terminal");
-      exit(-1);
-    }
-    
-    /* fire up the child's process */
-    if(pargs){
-      execvp( pargs[0], pargs);
-      perror("clef trying to execvp its argument");
-      fprintf(stderr, "Process --> %s\n", pargs[0]);
-    }
-    else{
-      program = getenv("SHELL");
-      if (!program)
-	program = strdup("/bin/sh");  
-      else 
-	program = strdup (program);
-      execlp( program,program, 0);
-      perror("clef trying to execlp the default child");
-      fprintf(stderr, "Process --> %s\n", program);
-    }
-    exit(-1);
-    break;
-    /* end switch */
-  }
-  /* PARENT */
-  /* Since I am the parent, I should start to initialize some stuff.
-     I have to close the pts side for it to work properly */
-  
-  close(serverNum);  
-  ppid = getppid();
-  
-  /* Iinitialize some stuff for the reading and writing */
-  init_flag(out_flag, MAXLINE);
-  define_function_keys();
-  init_reader();
-  PTY = 1;
-  init_parent();
-  
-  /* Here is the main loop, it simply starts reading characters from
-     the std input, and from the child. */
-  
-  while(1)  {           /* loop forever */
-    
-    /* use select to see who has stuff waiting for me to handle */
-    /* set file descriptors for ptc and stdin */
-    FD_ZERO(&rfds);
-    FD_SET(contNum,&rfds);
-    FD_SET(0,&rfds);
-    set_function_chars();
-#ifdef log
-    {
-      char modepath[30];
-      sprintf(modepath, "\nMODE = %d\n", MODE);
-      write(logfd, modepath, strlen(modepath));
-    }
-#endif
-#ifdef logterm
-    {
-      struct termio ptermio;
-      char pbuff[1024];
-      tcgetattr(contNum, &ptermio);
-      sprintf(pbuff, "child's settings: Lflag = %d, Oflag = %d, Iflag = %d\n",
-	      ptermio.c_lflag, ptermio.c_oflag, ptermio.c_iflag);
-      write(logfd, pbuff, strlen(pbuff));
-    }
-#endif
-    
-    code = select(FD_SETSIZE,(void *) &rfds, NULL, NULL, NULL);
-    for(; code < 0 ;) {
-      if(errno == EINTR) {
-        check_flip();
-        code = select(FD_SETSIZE,(void *) &rfds, NULL, NULL, NULL);
-      }
-      else  {
-        perror("clef select failure");
-        exit(-1);
-      }
-    }
-    
-    /* reading from the child **/
-    if( FD_ISSET(contNum,&rfds)) {       
-      if( (num_read = read(contNum, out_buff, MAXLINE)) == -1) { 
-        num_read = 0;
-      }
-#ifdef log 
-      write(logfd, "OUT<<<<<", strlen("OUT<<<<<"));
-      write(logfd, out_buff, num_read);
-#endif
-      if(num_read > 0) {
-        /* now do the printing to the screen */
-        if(MODE!= CLEFRAW) {
-          back_up(buff_pntr);
-          write(1,out_buff, num_read);
-          print_whole_buff();    /* reprint the input buffer */
-        }
-        else write(1,out_buff, num_read);
-      }
-    } /* done the child stuff */
-    /* I should read from std input */
-    else  {
-      if(FD_ISSET(0,&rfds)) {          
-        num_read = read(0, in_buff, MAXLINE);
-#ifdef log 
-	write(logfd, "IN<<<<<", strlen("IN<<<<<"));
-	write(logfd, in_buff, num_read);
-#endif
-        check_flip();
-        if(MODE == CLEFRAW ) 
-          write(contNum, in_buff, num_read);
-        else 
-          do_reading();
-      }
-    }
-  }
-}
-
-
-void
-init_parent(void)
-{
-  
-  /* get the original termio settings, so I never have to check again */
-  if(tcgetattr(0, &oldbuf) == -1) {
-    perror("clef trying to get terminal initial settings");
-    exit(-1);
-  }
-  
-  /* get the settings for my different modes */  
-  if ((tcgetattr(0, &canonbuf) == -1) ||
-      (tcgetattr(0, &rawbuf) == -1) ) {
-    perror("clef trying to get terminal settings");
-    exit(-1);
-  }
-  
-     
-  canonbuf.c_lflag &= ~(ICANON | ECHO | ISIG); 
-  /* read before an eoln is typed */
-
-  canonbuf.c_lflag |= ISIG;
- 
-  /*  canonbuf.c_line = 0;       turn off enhanced edit */
-
-  canonbuf.c_cc[VMIN] = 1;          /* we want every character  */
-  canonbuf.c_cc[VTIME] = 1;         /* these may require tweaking */
-
-  /* also set up the parents raw setting for when needed **/
-  rawbuf.c_oflag = rawbuf.c_iflag = rawbuf.c_lflag /* = rawbuf.c_line */ = 0;
-  rawbuf.c_cc[VMIN] = 1;
-  rawbuf.c_cc[VTIME] = 1;
-
-
-  if(tcsetattr(0, TCSAFLUSH, &canonbuf) == -1) {
-    perror("clef setting parent terminal to canonical processing");
-    exit(0);
-  }
-  
-  /* initialize some flags I will be using */
-  MODE = CLEFCANONICAL;
-  INS_MODE = 1;
-  Cursor_shape(2);
-}
-
-
-void 
-hangup_handler(int sig)
-{
-#ifdef siglog
-  sigfile = open(sigbuff, O_RDWR | O_APPEND);
-  write(sigfile, "Hangup Handler\n", strlen("Hangup Handler\n"));
-  close(sigfile);
-#endif
-  /* try to kill my child if it is around */
-  if(kill(child_pid, 0)) kill(child_pid, SIGTERM);
-  if(kill(ppid, 0) >= 0) {
-    /* fix the terminal and exit */
-    if(tcsetattr(0, TCSAFLUSH, &oldbuf) == -1) {
-      perror("clef restoring terminal in hangup handler");
-    }
-    printf("\n");
-  }
-  /* remove the temporary editor filename */
-  unlink(editorfilename);
-  exit(-1);
-}
-
-void 
-terminate_handler(int sig)
-{
-#ifdef siglog
-  sigfile = open(sigbuff, O_RDWR | O_APPEND);
-  write(sigfile, "Terminate Handler\n", strlen("Terminate Handler\n") + 1);
-  close(sigfile);
-  sleep(1);
-#endif
-  kill(child_pid, SIGTERM);
-  /* fix the terminal, and exit */
-  if(tcsetattr(0, TCSAFLUSH, &oldbuf) == -1) {
-    perror("clef restoring terminal in terminate handler");
-  }
-  printf("\n");
-  Cursor_shape(2);
-  fprintf(stderr, "\n");
-  /* remove the temporary editor filename */
-  unlink(editorfilename);
-  exit(0);
-}
-
-void 
-interrupt_handler(int sig)
-{
-#ifdef siglog
-  sigfile = open(sigbuff, O_RDWR | O_APPEND);
-  write(sigfile, "Interrupt Handler\n", strlen("Interrupt Handler\n") + 1);
-  close(sigfile);
-  sleep(1);
-#endif
-  kill(child_pid, SIGINT);
-}
-
-void 
-child_handler(int sig)
-{
-#ifdef siglog
-  sigfile = open(sigbuff, O_RDWR | O_APPEND );
-  write(sigfile, "Child Handler\n", strlen("Child Handler\n") + 1);
-  close(sigfile);
-#endif
-  Cursor_shape(2);
-  close(contNum);
-  if(kill(ppid, 0) >= 0) {
-   /* fix the terminal, and exit */
-    if(tcsetattr(0, TCSAFLUSH, &oldbuf) == -1) {
-      perror("clef restoring terminal in child handler");
-    }
-    printf("\n");
-  }
-  /* remove the temporary editor filename */
-  unlink(editorfilename);
-  exit(0);
-}
-
-void 
-alarm_handler(int sig)
-{
-  int newppid = getppid();
-#ifdef siglog
-  sigfile = open(sigbuff, O_RDWR | O_APPEND);
-  write(sigfile, "Alarm Handler\n", strlen("Alarm Handler\n")+ 1 );
-  close(sigfile);
-#endif
-  /* simply gets the parent process id, if different, it terminates ,
-    otherwise it resets the alarm */
-  
-  if(ppid == newppid) {
-    alarm(60);
-    return;
-  }
-  else {
-    /* once that is done fix the terminal, and exit */
-    if(tcsetattr(0, TCSAFLUSH, &oldbuf) == -1) {
-      perror("clef restoring terminal in alarm handler");
-    }
-    Cursor_shape(2);
-    fprintf(stderr, "\n");
-    /* remove the temporary editor filename */
-    unlink(editorfilename);
-    exit(0);
-  }
-}
-
-/* a procedure which tells my parent how to catch signals from its children */
-void
-catch_signals(void) 
-{
-#ifdef siglog
-  sprintf(sigbuff, "/tmp/csig%d", getpid());
-  sigfile = open(sigbuff, O_RDWR | O_TRUNC | O_CREAT);
-  write(sigfile, "Started \n", strlen("Started \n"));
-  close(sigfile);
-#endif
-  bsdSignal(SIGHUP, hangup_handler,RestartSystemCalls); 
-  bsdSignal(SIGCHLD,child_handler,RestartSystemCalls); 
-  bsdSignal(SIGTERM, terminate_handler,RestartSystemCalls);
-  bsdSignal(SIGINT, interrupt_handler,RestartSystemCalls); 
-  bsdSignal(SIGALRM, alarm_handler,RestartSystemCalls);
-  alarm(60);
-}
-
-/* Here is where I check the child's termio settings, and try to copy them.
-   I simply trace through the main modes (CLEFRAW,  CLEFCANONICAL) and
-   try to simulate them */
-void 
-check_flip(void)
-{
-  return;
-  
-#if 0
-  /*simply checks the termio structure of the child */
-  
-  if(tcgetattr(contNum, &childbuf) == -1) {
-    perror("clef parent getting child's terminal in check_termio");
-  }
-  if(childbuf.c_lflag & ICANON) {
-    if(MODE != CLEFCANONICAL) {
-      flip_canonical(contNum);
-      MODE = CLEFCANONICAL;
-    }
-  }
-  else {
-    if(MODE != CLEFRAW) {
-      flip_raw(contNum);
-      MODE = CLEFRAW;
-    }
-  }
-  /* While I am here, lets set the echo */
-  if(childbuf.c_lflag & ECHO) ECHOIT = 1;
-  else ECHOIT = 0;
-#endif
-}
-
-
-
-void
-flip_raw(int chann)
-{
-  
-  if(MODE == CLEFCANONICAL) 
-    send_buff_to_child(chann);
-  
-  if(tcsetattr(0, TCSAFLUSH, &rawbuf) == -1) {
-    perror("clef resetting parent to raw ");
-    exit(-1);
-  }
-}
-
-
-void
-flip_canonical(int chann)
-{
-  if(tcsetattr(0, TCSAFLUSH, &canonbuf) == -1) {
-    perror("clef resetting parent to canonical ");
-    exit(-1);
-  }
-  if(INS_MODE) 
-    Cursor_shape(5);
-  else 
-    Cursor_shape(2);
-}
-
-void
-etc_get_next_line(char * line,int * nr,int  fd)
-{
-  *nr = read(fd, line, 1024);
-  if(*nr == -1) {
-    perror("Reading /etc/master");
-  }
-  if(*nr == 0) {
-    fprintf(stderr, "Not found \n");
-  }
-}
-
-#define etc_whitespace(c) ((c == ' ' || c == '\t')?(1):(0))
-
-
-void
-set_function_chars(void)
-{
-  /* get the special characters */
-  _INTR = childbuf.c_cc[VINTR];
-  _QUIT = childbuf.c_cc[VQUIT];
-  _ERASE = childbuf.c_cc[VERASE];
-  _KILL = childbuf.c_cc[VKILL];
-  _EOF = childbuf.c_cc[VEOF];
-  _EOL = childbuf.c_cc[VEOL];
-  return;
-}
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/include/addfile.h1 b/src/include/addfile.h1
deleted file mode 100755
index 323a3c6..0000000
--- a/src/include/addfile.h1
+++ /dev/null
@@ -1,10 +0,0 @@
-extern FILE * db_file_open(char * db_file);
-extern void extend_ht(char * name);
-extern FILE * ht_file_open(char * fname , char * aname , char * name);
-extern FILE * temp_file_open(char * temp_db_file);
-#ifdef _ADDFILE_C
-static int build_ht_filename(char * fname , char * aname , char * name);
-static int pathname(char * name);
-static int strpostfix(char * s , char * t);
-#endif
-
diff --git a/src/include/all-hyper-proto.h1 b/src/include/all-hyper-proto.h1
deleted file mode 100755
index 4ddc6c3..0000000
--- a/src/include/all-hyper-proto.h1
+++ /dev/null
@@ -1,32 +0,0 @@
-#include "addfile.h1"
-#include "readbitmap.h1"
-#include "dialog.h1"
-#include "cond.h1"
-#include "display.h1"
-#include "event.h1"
-#include "ex2ht.h1"
-#include "form-ext.h1"
-#include "extent1.h1"
-#include "extent2.h1"
-#include "halloc.h1"
-#include "group.h1"
-#include "hterror.h1"
-#include "htinp.h1"
-#include "hyper.h1"
-#include "initx.h1"
-#include "input.h1"
-#include "keyin.h1"
-#include "item.h1"
-#include "lex.h1"
-#include "parse.h1"
-#include "macro.h1"
-#include "parse-paste.h1"
-#include "parse-aux.h1"
-#include "parse-input.h1"
-#include "show-types.h1"
-#include "parse-types.h1"
-#include "scrollbar.h1"
-#include "titlebar.h1"
-#include "spadint.h1"
-#include "hash.h1"
-#include "mem.h1"
diff --git a/src/include/bsdsignal.h b/src/include/bsdsignal.h
deleted file mode 100755
index e42e0fe..0000000
--- a/src/include/bsdsignal.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef _BSDSIGNAL_H_
-#define _BSDSIGNAL_H_
-
-
-#define RestartSystemCalls 1
-#define DontRestartSystemCalls 0
-
-
-typedef void (* SignalHandlerFunc)(int);
-
-#endif	    /* _BSDSIGNAL */
diff --git a/src/include/bsdsignal.h1 b/src/include/bsdsignal.h1
deleted file mode 100755
index 621b930..0000000
--- a/src/include/bsdsignal.h1
+++ /dev/null
@@ -1 +0,0 @@
-extern SignalHandlerFunc bsdSignal(int  , SignalHandlerFunc  , int );
diff --git a/src/include/cfuns-c.h1 b/src/include/cfuns-c.h1
deleted file mode 100755
index 66300e0..0000000
--- a/src/include/cfuns-c.h1
+++ /dev/null
@@ -1,9 +0,0 @@
-extern int addtopath(char * );
-extern int directoryp(char * );
-extern int make_path_from_file(char *  , char * );
-extern int writeablep(char * );
-/* unused? extern int CLgetpid(void); */
-/* unused? extern int readablep(char * );*/
-/* unused? extern long findString(char *  , char * );*/
-/* unused? extern int copyEnvValue(char *  , char * );*/
-
diff --git a/src/include/com.h b/src/include/com.h
deleted file mode 100755
index c974f07..0000000
--- a/src/include/com.h
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef _COM_H_
-#define _COM_H_
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#if defined(RIOSplatform)
-#include <sys/select.h>
-#endif
-
-
-typedef struct {
-  int socket;           /* socket number returned by "socket" call */
-  int type;             /* socket type (AF_UNIX or AF_INET) */
-  int purpose;          /* can be SessionManager, GraphicsServer, etc. */
-  int pid;              /* process ID of connected socket */
-  int frame;            /* spad interpreter frame (for interpreter windows) */
-  int remote_fd;        /* file descriptor of remote socket */
-  union {
-    struct sockaddr u_addr;
-    struct sockaddr_in i_addr;
-  } addr;
-  char *host_name;      /* name of foreign host if type == AF_INET */
-} Sock;
-
-
-#define MaxClients      150
-
-/* possible socket types (purpose) */
-
-#define SessionManager  1
-#define ViewportServer  2
-#define MenuServer      3
-#define SessionIO       4
-#define BaloonServer    5
-#define InterpWindow    6
-#define KillSpad        7
-#define DebugWindow     8  /* used for nagman */
-#define Forker          9
-#define AV              10 /*Simon's algebraic viewer */
-
-#define Acknowledge     255
-
-/* Timeout value for connection to remote socket */
-
-#define Forever 0
-
-/* Socket name for local AXIOM server and session manager */
-
-#define SpadServer              "/tmp/.d"
-#define SessionServer           "/tmp/.s"
-#define SessionIOName           "/tmp/.i"
-#define MenuServerName          "/tmp/.h"
-#define ForkServerName          "/tmp/.f"
-
-
-#define MASK_SIZE       (NBBY*sizeof(fd_set))
-
-
-/* table of dedicated socket types */
-
-extern Sock *purpose_table[];
-extern Sock server[];
-extern Sock clients[];
-extern fd_set socket_mask;
-extern fd_set server_mask;
-
-/* Commands sent over the AXIOM session manager or menu socket */
-
-#define CreateFrame             1
-#define SwitchFrames            2
-#define EndOfOutput             3
-#define CallInterp              4
-#define EndSession              5
-#define LispCommand             6
-#define SpadCommand             7
-#define SendXEventToHyperTeX    8
-#define QuietSpadCommand        9
-#define CloseClient             10
-#define QueryClients            11
-#define QuerySpad               12
-#define NonSmanSession          13
-#define KillLispSystem          14
-
-#define CreateFrameAnswer       50
-
-/* Commands from AXIOM menu server to interpreter windows */
-
-#define ReceiveInputLine        100
-#define TestLine                101
-
-#endif
-
-
-
-
-
-
-
diff --git a/src/include/cond.h1 b/src/include/cond.h1
deleted file mode 100755
index a2843d4..0000000
--- a/src/include/cond.h1
+++ /dev/null
@@ -1,6 +0,0 @@
-extern void change_cond(char * label , char * newcond);
-extern int check_condition(TextNode * node);
-extern void insert_cond(char * label , char * cond);
-#ifdef _COND_C
-static int check_memostack(TextNode * node);
-#endif
diff --git a/src/include/cursor.h1 b/src/include/cursor.h1
deleted file mode 100755
index 090e057..0000000
--- a/src/include/cursor.h1
+++ /dev/null
@@ -1 +0,0 @@
-extern int Cursor_shape(int );
diff --git a/src/include/debug.h b/src/include/debug.h
deleted file mode 100644
index c2dd986..0000000
--- a/src/include/debug.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/* redefine free */
-/* #define free hfree*/
-
diff --git a/src/include/dialog.h1 b/src/include/dialog.h1
deleted file mode 100755
index c95f9b6..0000000
--- a/src/include/dialog.h1
+++ /dev/null
@@ -1,34 +0,0 @@
-extern void add_buffer_to_sym(char * buffer , InputItem * sym);
-extern void dialog(XEvent * event , KeySym keysym , char * buffer);
-extern void draw_inputsymbol(InputItem * sym);
-extern void update_inputsymbol(InputItem * sym);
-#ifdef _DIALOG_C
-static void back_over_char(InputItem * sym);
-static void back_over_eoln(InputItem * sym);
-static void clear_cursor(InputItem * sym);
-static void clear_cursorline(InputItem * sym);
-static void dec_line_numbers(LineStruct * line);
-static void decrease_line_numbers(LineStruct * line , int am);
-static void delete_char(InputItem * sym);
-static void delete_eoln(InputItem * sym);
-static int delete_one_char(InputItem * sym);
-static void delete_rest_of_line(InputItem * sym);
-static void draw_cursor(InputItem * sym);
-static void enter_new_line(InputItem * sym);
-static void inc_line_numbers(LineStruct * line);
-static void insert_buffer(char * buffer , InputItem * sym);
-static int move_back_one_char(InputItem * sym);
-static void move_cursor_backward(InputItem * sym);
-static void move_cursor_down(InputItem * sym);
-static void move_cursor_end(InputItem * sym);
-static void move_cursor_forward(InputItem * sym);
-static void move_cursor_home(InputItem * sym);
-static void move_cursor_up(InputItem * sym);
-static char move_rest_back(LineStruct * line , int size);
-static int move_sym_forward(LineStruct * line, int num, int size, 
-                            InputItem * sym);
-static char * mystrncpy(char * buff1 , char * buff2 , int n);
-static void overwrite_buffer(char * buffer , InputItem * item);
-static void redraw_win(void);
-static void tough_enter(InputItem * sym);
-#endif 
diff --git a/src/include/display.h1 b/src/include/display.h1
deleted file mode 100755
index 8ccc2af..0000000
--- a/src/include/display.h1
+++ /dev/null
@@ -1,4 +0,0 @@
-extern void expose_page(HyperDocPage * page);
-extern void paste_page(TextNode * node);
-extern void scroll_page(HyperDocPage * page);
-extern void show_page(HyperDocPage * page);
diff --git a/src/include/edible.h b/src/include/edible.h
deleted file mode 100755
index 99340a5..0000000
--- a/src/include/edible.h
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-extern int contNum;
-extern struct termios childbuf;	  /** the childs normal operating termio   ***/
-
-/***   the terminals mapping of the function keys			 ***/
-extern unsigned char  _INTR, _QUIT, _ERASE, _KILL, _EOF, _EOL, _RES1, _RES2;
-extern short  INS_MODE ;     /** Flag for insert mode		     **/
-extern short ECHOIT;	     /** Flag for echoing **/
-extern short PTY;   /* A flag which lets me know whether or not I am 
-		       talking to a socket or a pty. If I am not 
-		       talking to a PTY then I have to do things like echo
-		      back newlines, and send interuppts with an eoln
-		      */
-/***************************************************************************
-    Here are the key mapping my routines need
-****************************************************************************/
-
-
-#define	      _ESC   0X1B    /**  A character sent before every arrow key ***/
-#define	      _LBRACK  0X5B    /**  [				      **/
-#define	      _EOLN    '\n'    /** eoln				      **/
-#define	      _CR      0X0D    /**  cr				      **/
-#define	      _BLANK   0X20    /**  blank			      **/
-#define	      _BKSPC   0X08    /**  backspace			      **/
-#define	      _DEL     0X7F    /**  delete			      **/
-#define	      _BELL    0X07    /***  ring the bell		      **/
-#define	      _INT     0X7F    /***  interrupt			      **/
-#define	      _SQUASH  0X03    /**   kill my process		      **/
-#define	      _CNTRL_W 0X17    /**   cntrl-w, to back up a word	      **/
-#define	      _CARROT  0X5E    /** circumflex			      **/
-#define	      _TAB     0X09    /** tab forward			      **/
-
-#ifndef WCT
-#define	      _A       0X41    /**  A				      **/
-#define	      _B       0X42    /**  B				      **/
-#define	      _C       0X43    /**  C				      **/
-#define	      _D       0X44    /**  D				      **/
-#define	      _Z       0X5A    /**  Z				      **/
-#define	      _H       0X48    /**  H				      **/
-#define	      _M       0X4D    /**  M				      **/
-#define	      _x       0X78    /**  x				      **/
-#define	      _z       0X7A    /*** z				      **/
-#define	      _twiddle 0X7E    /*** ~				      **/
-#define	      _P       0X50    /*** P				      **/
-#define	      _1       0X31    /*** 1				      **/
-#define	      _2       0X32    /*** 2				      **/
-#define	      _3       0X33    /*** 3				      **/
-#define	      _4       0X34    /*** 4				      **/
-#define	      _5       0X35    /*** 5				      **/
-#define	      _6       0X36    /*** 6				      **/
-#define	      _7       0X37    /*** 7				      **/
-#define	      _8       0X38    /*** 8				      **/
-#define	      _9       0X39    /*** 9				      **/
-#define	      _0       0X30    /*** 0				      **/
-#define	      _q       0X71    /*** q				      **/
-#endif
-
-
-
-#define MAXLINE		   1024	  /** maximum chars. on a line		  ***/
-#define MAXBUFF		    64	 /** maximum lines saved in the buffer
-				       queue				***/
-
-/***  Here are the constants for my three different modes. ******/
-#define CLEFRAW			     0
-#define CLEFCANONICAL		     1
-#define CLEFCBREAK		     2
-
-extern int mode;   /** One of the above # defines *****/
-
-/**   Here is the structure for storing bound  pf-keys		   ***/
-typedef struct Fkey
-{
-  char *str;
-  short type;
-} fkey;
-
-extern fkey function_key[13] ;	  /** strings which replace function
-					  keys when a key is hit	  ***/
-
-
-extern char editorfilename[];
-
-/****  Here are a bunch of constant, variable and function defs for edin.c */
-#define UP		     0	 /** Tells the replace buffer command	***/
-#define DOWN		     1	 /**   to look up or down		 **/
-
-#define inc(x)	((x+1)%MAXBUFF)	 /** returns the increment of the presented
-				       pointer				***/
-#define dec(x)	( ((x-1) < 0) ?(MAXBUFF - 1):(x-1))/** ibid for decrementing */
-
-#define flip(x)	  (x?(x=0):(x=1))      /*** flip the bit		  ***/
-
-/*
-    All the previous commands will now be stored in a double linked list.
-  This way when I type a command I just have to circle through this list
-*/
-typedef struct que_struct {
-   char buff[1024];
-   int flags[1024];
-   struct que_struct *prev, *next;
-   } QueStruct;
-
-typedef struct wct {
-    char *fname;
-    off_t fsize;
-    time_t ftime;
-    char *fimage;
-    int wordc;
-    char **wordv;
-
-    struct wct *next;
-} Wct;
-
-typedef struct wix {
-    Wct *pwct;
-    int word;
-} Wix;
-
-
-extern QueStruct *ring;
-extern QueStruct *current;
-extern int ring_size;
-extern int prev_check;
-extern int MAXRING;
-
-extern char buff[MAXLINE];		   /**	Buffers for collecting input and  **/
-extern int  buff_flag[MAXLINE];	   /**	   flags for whether buff chars
-					   are printing
-					   or non-printing		  **/
-
-extern char in_buff[1024];   /**     buffer for characters read until they are
-				      processed				  **/
-extern int num_read;
-extern int num_proc;	     /**   num chars processed after a read	  **/
-extern int buff_pntr;	     /**   present length of  buff		  **/
-extern int curr_pntr;	     /** the current position in buff		  **/
-
-/** Here are a bunch of macros for edin.c. They are mostly just charcter
-	comparison stuff						  ***/
-#define back_word(x) (((*(x) == _5) && (*(x+1) == _9) && \
-					(*(x+2) == _q))?(1):(0))
-
-#define fore_word(x) (((*(x) == _6) && (*(x+1) == _8) && \
-					(*(x+2) == _q))?(1):(0))
-
-#define alt_f1(x) (((*(x) == _3) && (*(x+1) == _7) && \
-					(*(x+2) == _q))?(1):(0))
-
-#define cntrl_end(x) (((*(x) == _4) && (*(x+1) == _8) && \
-					(*(x+2) == _q))?(1):(0))
-
-#define insert_toggle(x) (((*(x) == _3) && (*(x+1) == _9) && \
-					(*(x+2) == _q))?(1):(0))
-
-#define end_key(x) (((*(x) == _4) && (*(x+1) == _6) && \
-					(*(x+2) == _q))?(1):(0))
-
-#define control_char(x) \
-     (((x >= 0x01) && (x <= 0x1a))?(1):(0))
-
-
-
-/***
-   Some global defs needed for emulating a pty. This was taken from guru.h
-***/
-
-
-
-/* Return an integer that is represented by a character string */
-#define ciret(x) ((cintu.c4[0]=(x)[0]), (cintu.c4[1]=(x)[1]), \
-		  (cintu.c4[2]=(x)[2]), (cintu.c4[3]=(x)[3]), cintu.i4)
-
-/* move an integer (x) to a character string (y) */
-
-#define icmove(x, y) ((cintu.i4=(x)), ((y)[0]=cintu.c4[0]), \
-		      ((y)[1]=cintu.c4[1]), ((y)[2]=cintu.c4[2]), \
-			 ((y)[3]=cintu.c4[3]))
-
-/* Return an integer that may not be on an integer boundary */
-#define iiret(x) ciret(((char *)&(x)))
-
- /* Min of two expressions */
-#define min(x, y) ((x)<(y)?(x):(y))
-
- /* Max of two expressions */
-#define max(x, y) ((x)>(y)?(x):(y))
-
-
-
diff --git a/src/include/edible.h1 b/src/include/edible.h1
deleted file mode 100755
index d61da78..0000000
--- a/src/include/edible.h1
+++ /dev/null
@@ -1,13 +0,0 @@
-extern void check_flip(void);
-extern int main(int  , char * []);
-extern void catch_signals(void);
-extern void init_parent(void);
-extern void set_function_chars(void);
-extern void hangup_handler(int );
-extern void terminate_handler(int );
-extern void interrupt_handler(int );
-extern void child_handler(int );
-extern void alarm_handler(int );
-extern void flip_canonical(int );
-extern void flip_raw(int );
-extern void etc_get_next_line(char *  , int *  , int );
diff --git a/src/include/edin.h1 b/src/include/edin.h1
deleted file mode 100755
index 5e5cf56..0000000
--- a/src/include/edin.h1
+++ /dev/null
@@ -1,17 +0,0 @@
-extern void init_reader(void);
-extern void init_flag(int *  , int );
-extern void do_reading(void);
-extern void send_line_to_child(void);
-extern void insert_buff_nonprinting(int );
-extern void prev_buff(void);
-extern void next_buff(void);
-extern void insert_buff_printing(int );
-extern void insert_queue(void);
-extern int convert_buffer(char *  , char *  , int *  , int );
-extern void init_buff(char *  , int );
-extern void forwardcopy(char *  , char *  , int );
-extern void forwardflag_cpy(int *  ,int *  , int );
-extern void flagcpy(int *  , int * );
-extern void flagncpy(int *  , int *  , int );
-extern void send_function_to_child(void);
-extern void send_buff_to_child(int );
diff --git a/src/include/event.h1 b/src/include/event.h1
deleted file mode 100755
index f748adb..0000000
--- a/src/include/event.h1
+++ /dev/null
@@ -1,34 +0,0 @@
-extern void exitHyperDoc(void );
-extern void helpForHyperDoc(void );
-extern void mainEventLoop(void );
-extern void make_window_link(char * name);
-extern void quitHyperDoc(void );
-extern void get_new_window(void );
-#ifdef _EVENT_C
-static void set_cursor(HDWindow * window , Cursor state);
-static void change_cursor(Cursor state , HDWindow * window);
-static void create_window(void );
-static void downlink(void );
-static HyperDocPage * find_page(TextNode * node);
-static void handle_button(int button , XButtonEvent * event);
-static void handle_event(XEvent * event);
-static void handle_motion_event(XMotionEvent * event);
-static int HyperDocErrorHandler(Display * display , XErrorEvent * xe);
-static void init_cursor_states(void );
-static void killAxiomPage(HyperDocPage * page);
-static void make_busy_cursor(HDWindow * window);
-static void make_busy_cursors(void );
-static void memolink(void );
-static void set_error_handlers(void );
-static int set_window(Window window);
-static void clear_exposures(Window w);
-static void kill_page(HyperDocPage * page);
-static HyperDocPage * returnlink(void );
-static HyperDocPage * uplink(void );
-static void windowlink_handler(TextNode * node);
-static void lispwindowlink_handler(HyperLink * link);
-static HyperDocPage * paste_button(PasteNode * paste);
-static HyperLink * findButtonInList(HDWindow * window , int x , int y);
-static HyperLink * get_hyper_link(XButtonEvent * event);
-static void init_cursor_state(HDWindow * window);
-#endif
diff --git a/src/include/ex2ht.h1 b/src/include/ex2ht.h1
deleted file mode 100755
index 2dc0334..0000000
--- a/src/include/ex2ht.h1
+++ /dev/null
@@ -1,14 +0,0 @@
-extern int main(int argc , char * * argv);
-extern void openCoverPage(void);
-extern void exToHt(char * filename);
-extern void closeCoverPage(void);
-extern void addFile(char * filename);
-extern void closeCoverFile(void);
-extern char * allocString(char * s);
-extern char * strPrefix(char * prefix , char * s);
-extern char * getExTitle(FILE * inFile , char * line);
-extern void emitCoverLink(char * name , char * title);
-extern void emitHeader(FILE * outFile , char * pageName , char * pageTitle);
-extern void emitMenuEntry(char * line , FILE * outFile);
-extern void emitSpadCommand(char * line , char * prefix , FILE * outFile);
-extern void emitFooter(FILE * outFile);
diff --git a/src/include/extent1.h1 b/src/include/extent1.h1
deleted file mode 100755
index aae58d1..0000000
--- a/src/include/extent1.h1
+++ /dev/null
@@ -1,37 +0,0 @@
-extern void compute_header_extent(HyperDocPage * page);
-extern void compute_footer_extent(HyperDocPage * page);
-extern void compute_scrolling_extent(HyperDocPage * page);
-extern void compute_title_extent(HyperDocPage * page);
-extern void compute_text_extent(TextNode * node);
-#ifdef _EXTENT1_C
-static void compute_begin_items_extent(TextNode * node);
-static void compute_bf_extent(TextNode * node);
-static void compute_box_extent(TextNode * node);
-static void compute_button_extent(TextNode * node);
-static void compute_center_extent(TextNode * node);
-static void compute_dash_extent(TextNode * node);
-static void compute_em_extent(TextNode * node);
-static void compute_ifcond_extent(TextNode * node);
-static void compute_image_extent(TextNode * node);
-static void compute_input_extent(TextNode * node);
-static void compute_ir_extent(TextNode * node);
-static void compute_it_extent(TextNode * node);
-static void compute_item_extent(TextNode * node);
-static void compute_mbox_extent(TextNode * node);
-static void compute_mitem_extent(TextNode * node);
-static void compute_paste_extent(TextNode * node);
-static void compute_pastebutton_extent(TextNode * node);
-static void compute_punctuation_extent(TextNode * node);
-static void compute_rm_extent(TextNode * node);
-static void compute_spadcommand_extent(TextNode * node);
-static void compute_spadsrc_extent(TextNode * node);
-static void compute_spadsrctxt_extent(TextNode * node);
-static void compute_table_extent(TextNode * * node);
-static void compute_verbatim_extent(TextNode * node);
-static void compute_word_extent(TextNode * node);
-static void end_spadcommand_extent(TextNode * node);
-static void end_spadsrc_extent(TextNode * node);
-static void endbutton_extent(TextNode * node);
-static void endif_extent(TextNode * node);
-static void endpastebutton_extent(TextNode * node);
-#endif
diff --git a/src/include/extent2.h1 b/src/include/extent2.h1
deleted file mode 100755
index c8d20d1..0000000
--- a/src/include/extent2.h1
+++ /dev/null
@@ -1,23 +0,0 @@
-extern void init_extents(void );
-extern void init_text(void );
-extern void init_title_extents(HyperDocPage * page);
-extern void insert_bitmap_file(TextNode * node);
-extern void insert_pixmap_file(TextNode * node);
-extern int max_x(TextNode * node , int Ender);
-extern int plh(int height);
-extern void start_newline(int distance , TextNode * node);
-extern int text_height(TextNode * node , int Ender);
-extern int text_width(TextNode * node , int Ender);
-extern int total_width(TextNode * node , int Ender);
-extern int trailing_space(TextNode * node);
-#ifdef _EXTENT2_C
-static void center_nodes(TextNode * begin_node , TextNode * end_node);
-static int input_string_width(TextNode * node);
-static int punctuation_width(TextNode * node);
-static int text_height1(TextNode * node , int Ender);
-static int verbatim_width(TextNode * node);
-static int width_of_dash(TextNode * node);
-static int word_width(TextNode * node);
-static int x_value(TextNode * node);
-#endif
-
diff --git a/src/include/fnct-key.h1 b/src/include/fnct-key.h1
deleted file mode 100755
index f6e6233..0000000
--- a/src/include/fnct-key.h1
+++ /dev/null
@@ -1,7 +0,0 @@
-extern void set_editor_key(void);
-extern void define_function_keys(void);
-extern int get_key(int  , char * );
-extern int get_str(int  , char * );
-extern void null_fnct(int );
-extern void handle_function_key(int  , int );
-
diff --git a/src/include/form-ext.h1 b/src/include/form-ext.h1
deleted file mode 100755
index bd40993..0000000
--- a/src/include/form-ext.h1
+++ /dev/null
@@ -1,8 +0,0 @@
-extern void compute_form_page(HyperDocPage * page);
-extern int window_width(int cols);
-#ifdef _FORM_EXT_C
-static int window_height(HyperDocPage * page);
-static void form_header_extent(HyperDocPage * page);
-static void form_footer_extent(HyperDocPage * page);
-static void form_scrolling_extent(HyperDocPage * page);
-#endif 
diff --git a/src/include/group.h1 b/src/include/group.h1
deleted file mode 100755
index 99c15af..0000000
--- a/src/include/group.h1
+++ /dev/null
@@ -1,14 +0,0 @@
-extern void bf_top_group(void );
-extern GroupItem * copy_group_stack(void );
-extern void em_top_group(void );
-extern void free_group_stack(GroupItem * g);
-extern void init_group_stack(void );
-extern void init_top_group(void );
-extern void line_top_group(void );
-extern int pop_group_stack(void );
-extern void push_active_group(void );
-extern void push_group_stack(void );
-extern void push_spad_group(void );
-extern void rm_top_group(void );
-extern void tt_top_group(void );
-extern void center_top_group(void );
diff --git a/src/include/halloc.h1 b/src/include/halloc.h1
deleted file mode 100755
index 717a7d0..0000000
--- a/src/include/halloc.h1
+++ /dev/null
@@ -1 +0,0 @@
-extern char * halloc(int bytes , char * msg);
diff --git a/src/include/hash.h b/src/include/hash.h
deleted file mode 100755
index 87b3461..0000000
--- a/src/include/hash.h
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#ifndef _HASH_H_
-#define _HASH_H_ 1
-
-
-
-typedef struct hash_entry {
-  char *key;			/* pointer to key data */
-  char *data;			/* Pointer to entry */
-  struct hash_entry *next;	/* Link to next entry */
-} HashEntry;
-
-typedef int (*EqualFunction)(void *,void *);
-typedef int (*HashcodeFunction)(void *,int);
-typedef void (*MappableFunction) (void *);
-typedef void (*FreeFunction) (void *);
-typedef struct {
-  HashEntry **table;		/* the actual table */
-  int size;			/* size of table */
-  int num_entries;		/* number of elements in a hash table */
-  EqualFunction equal;		/* equality predicate for keys */
-  HashcodeFunction hash_code;	/* create hash code for a key */
-} HashTable;
-
-#endif
diff --git a/src/include/hash.h1 b/src/include/hash.h1
deleted file mode 100755
index 3630d00..0000000
--- a/src/include/hash.h1
+++ /dev/null
@@ -1,13 +0,0 @@
-extern char * alloc_string(char * str);
-extern HashEntry * hash_copy_entry(HashEntry * e);
-extern HashTable * hash_copy_table(HashTable * table);
-extern void hash_delete(HashTable * table , char * key);
-extern char * hash_find(HashTable * table , char * key);
-extern void hash_init(HashTable * table, int size, EqualFunction equal,
-                      HashcodeFunction hash_code);
-extern void free_hash(HashTable * table , FreeFunction free_fun);
-extern void hash_insert(HashTable * table , char * data , char * key);
-extern void hash_map(HashTable * table , MappableFunction func);
-extern char * hash_replace(HashTable * table , char * data , char * key);
-extern int string_equal(char * s1 , char * s2);
-extern int string_hash(char * s , int size);
diff --git a/src/include/htadd.h1 b/src/include/htadd.h1
deleted file mode 100755
index 42a4dc6..0000000
--- a/src/include/htadd.h1
+++ /dev/null
@@ -1,17 +0,0 @@
-extern int main(int argc , char * * argv);
-#ifdef _HTADD_C
-static void add_file(char * dbname , char * name , int fresh);
-static void add_new_pages(FILE * temp_db, FILE * new_file, 
-                          char * addname, char * fullname);
-static int build_db_filename(short flag , char * db_dir , char * dbfilename);
-static void copy_file(char * f1 , char * f2);
-static void delete_db(FILE * db , FILE * temp_db , char * name);
-static int delete_file(char * dbname , char * name);
-static void get_filename(void);
-static void parse_args(char * * argv, char * db_dir, 
-                       char * * filenames, short * fl);
-static void update_db(FILE * db, FILE * temp_db, FILE * new_file, 
-                      char * addname, char * fullname, int fresh);
-static int writable(struct stat buff);
-#endif
-
diff --git a/src/include/hterror.h1 b/src/include/hterror.h1
deleted file mode 100755
index 128f871..0000000
--- a/src/include/hterror.h1
+++ /dev/null
@@ -1,6 +0,0 @@
-extern void print_page_and_filename(void );
-extern void jump(void );
-extern void print_token(void );
-extern void token_name(int type);
-extern void print_next_ten_tokens(void );
-extern void htperror(char * msg , int errno);
diff --git a/src/include/hthits.h1 b/src/include/hthits.h1
deleted file mode 100755
index f210bb4..0000000
--- a/src/include/hthits.h1
+++ /dev/null
@@ -1,12 +0,0 @@
-extern void regerr(int code);
-extern int main(int argc , char * * argv);
-extern void cmdline(int argc , char * * argv);
-extern void handleHtdb(void);
-extern void badDB(void);
-extern void handleFile(FILE * htdbFile);
-extern void handleFilePages(char * fname , int pgc , PgInfo * pgv);
-extern void handlePage(FILE * infile , PgInfo * pg);
-extern void splitpage(char * buf , char * * ptitle , char * * pbody);
-extern void untexbuf(register char * s);
-extern void searchPage(char * pgname , char * pgtitle , char * pgbody);
-extern void squirt(char * s , int n);
diff --git a/src/include/htinp.h1 b/src/include/htinp.h1
deleted file mode 100755
index 0e767c5..0000000
--- a/src/include/htinp.h1
+++ /dev/null
@@ -1,21 +0,0 @@
-extern void ht2_input(void );
-extern void make_record(void );
-extern void verify_record(void );
-extern char * strCopy(char * s);
-extern void print_paste_line(FILE * pfile , char * str);
-extern void get_spad_output(FILE * pfile , char * command , int com_type);
-extern void get_graph_output(char * command , char * pagename , int com_type);
-#ifdef _HTINP_C
-static void make_input_file_list(void );
-static char * make_input_file_name(char * buf , char * filename);
-static char * make_paste_file_name(char * buf , char * filename);
-static void make_the_input_file(UnloadedPage * page);
-static void make_input_file_from_page(HyperDocPage * page);
-static int inListAndNewer(char * inputFile , char * htFile);
-static void print_paste(FILE * pfile, char * realcom, char * command, 
-                        char * pagename, int com_type);
-static void print_graph_paste(FILE * pfile, char * realcom, char * command, 
-                              char * pagename, int com_type);
-static void send_command(char * command , int com_type);
-#endif
-
diff --git a/src/include/hyper.h1 b/src/include/hyper.h1
deleted file mode 100755
index e0350f6..0000000
--- a/src/include/hyper.h1
+++ /dev/null
@@ -1,10 +0,0 @@
-extern void sigusr2_handler(int sig);
-extern void sigcld_handler(int sig);
-extern void clean_socket(void);
-extern int main(int argc , char * * argv);
-extern void init_page_structs(HDWindow * w);
-#ifdef _HYPER_C
-static void init_hash(void);
-static void make_server_connections(void);
-static void check_arguments(void);
-#endif
diff --git a/src/include/initx.h1 b/src/include/initx.h1
deleted file mode 100755
index 347d99f..0000000
--- a/src/include/initx.h1
+++ /dev/null
@@ -1,17 +0,0 @@
-extern void change_text(int color , XFontStruct * font);
-extern int init_form_window(char * name , int cols);
-extern int init_top_window(char * name);
-extern void initializeWindowSystem(void);
-extern int is_it_850(XFontStruct * fontarg);
-#ifdef _INITX_C
-static void get_GCs(HDWindow * window);
-static int get_border_properties(void);
-static int get_color(char * name , char * class , int def , Colormap * map);
-static void ingItColors_and_fonts(void);
-static void load_font(XFontStruct * * font_info , char * fontname);
-static void mergeDatabases(void);
-static void open_form_window(void);
-static void open_window(Window w);
-static void set_name_and_icon(void);
-static void set_size_hints(Window w);
-#endif
diff --git a/src/include/input.h1 b/src/include/input.h1
deleted file mode 100755
index 99f79a3..0000000
--- a/src/include/input.h1
+++ /dev/null
@@ -1,11 +0,0 @@
-extern InputItem * return_item(char * name);
-extern void fill_box(Window w , ImageStruct * image);
-extern void toggle_input_box(HyperLink * link);
-extern void toggle_radio_box(HyperLink * link);
-extern void change_input_focus(HyperLink * link);
-extern void next_input_focus(void);
-extern void prev_input_focus(void);
-extern int delete_item(char * name);
-#ifdef _INPUT_C
-static void clear_rbs(InputBox * list);
-#endif
diff --git a/src/include/item.h1 b/src/include/item.h1
deleted file mode 100755
index e462d98..0000000
--- a/src/include/item.h1
+++ /dev/null
@@ -1,5 +0,0 @@
-extern void push_item_stack(void);
-extern void clear_item_stack(void);
-extern void pop_item_stack(void);
-extern ItemStack * copy_item_stack(void);
-extern void free_item_stack(ItemStack * is);
diff --git a/src/include/keyin.h1 b/src/include/keyin.h1
deleted file mode 100755
index 0faab2f..0000000
--- a/src/include/keyin.h1
+++ /dev/null
@@ -1,2 +0,0 @@
-extern void handle_key(XEvent * event);
-extern void init_keyin(void);
diff --git a/src/include/lex.h1 b/src/include/lex.h1
deleted file mode 100755
index 7f04920..0000000
--- a/src/include/lex.h1
+++ /dev/null
@@ -1,23 +0,0 @@
-extern int connect_spad(void);
-extern void get_expected_token(int type);
-extern void parser_init(void);
-extern void init_scanner(void);
-extern void save_scanner_state(void);
-extern void restore_scanner_state(void);
-extern void unget_char(int c);
-extern int get_char(void);
-extern void unget_token(void);
-extern int get_token(void);
-extern void push_be_stack(int type , char * id);
-extern void check_and_pop_be_stack(int type , char * id);
-extern int clear_be_stack(void);
-extern int be_type(char * which);
-extern int begin_type(void);
-extern int end_type(void);
-extern void reset_connection(void);
-extern int spad_busy(void);
-#ifdef _LEX_C
-static int get_char1(void );
-static void spad_error_handler(void );
-static int keyword_type(void );
-#endif
diff --git a/src/include/macro.h1 b/src/include/macro.h1
deleted file mode 100755
index f7853c7..0000000
--- a/src/include/macro.h1
+++ /dev/null
@@ -1,11 +0,0 @@
-extern void scan_HyperDoc(void);
-extern int number(char * str);
-extern ParameterList init_parameter_elem(int number);
-extern int push_parameters(ParameterList new);
-extern int pop_parameters(void);
-extern int parse_macro(void);
-extern void parse_parameters(void);
-#ifdef _MACRO_C
-static char * load_macro(MacroStore * macro);
-static void get_parameter_strings(int number , char * macro_name);
-#endif
diff --git a/src/include/mem.h1 b/src/include/mem.h1
deleted file mode 100755
index a8e1a11..0000000
--- a/src/include/mem.h1
+++ /dev/null
@@ -1,32 +0,0 @@
-extern ButtonList * alloc_button_list(void);
-extern CondNode * alloc_condnode(void);
-extern HDWindow * alloc_hd_window(void);
-extern IfNode * alloc_ifnode(void);
-extern InputBox * alloc_inputbox(void);
-extern LineStruct * alloc_inputline(int size);
-extern TextNode * alloc_node(void);
-extern HyperDocPage * alloc_page(char * name);
-extern PasteNode * alloc_paste_node(char * name);
-extern RadioBoxes * alloc_rbs(void);
-extern void free_button_list(ButtonList * bl);
-extern void free_hd_window(HDWindow * w);
-extern void free_input_item(InputItem * sym , short des);
-extern void free_input_list(InputItem * il);
-extern void free_node(TextNode * node , short des);
-extern void free_page(HyperDocPage * page);
-extern void free_patch(PatchStore * p);
-extern void free_string(char * str);
-extern char * resizeBuffer(int size , char * oldBuf , int * oldSize);
-extern PatchStore * alloc_patchstore(void);
-#ifdef _MEM_C
-static void free_cond(CondNode * cond);
-static void free_depend(SpadcomDepend * sd);
-static void free_lines(LineStruct * lines);
-static void dont_free(void * link);
-static void free_if_non_NULL(void * p);
-static void free_input_box(InputBox * box);
-static void free_paste(PasteNode * paste , short des);
-static void free_pastearea(TextNode * node , short des);
-static void free_pastebutton(TextNode * node , short des);
-static void free_radio_boxes(RadioBoxes * radio);
-#endif
diff --git a/src/include/nagman.h1 b/src/include/nagman.h1
deleted file mode 100755
index 4a58ccd..0000000
--- a/src/include/nagman.h1
+++ /dev/null
@@ -1,7 +0,0 @@
-extern void main(int argc , char * * argv);
-#ifdef _NAGMAN_C
-static void term(int sig);
-static long size_of_file(char * filename);
-static void rpcloop(void);
-static void catchSignals(void);
-#endif
diff --git a/src/include/openpty.h1 b/src/include/openpty.h1
deleted file mode 100755
index dc46a19..0000000
--- a/src/include/openpty.h1
+++ /dev/null
@@ -1,2 +0,0 @@
-extern void makeNextPtyNames(char *  , char * );
-extern int ptyopen(int *  , int *  , char *  , char * );
diff --git a/src/include/parse-aux.h1 b/src/include/parse-aux.h1
deleted file mode 100755
index 4de9b24..0000000
--- a/src/include/parse-aux.h1
+++ /dev/null
@@ -1,18 +0,0 @@
-extern void add_dependencies(void );
-extern FILE * find_fp(FilePosition fp);
-extern char * get_input_string(void );
-extern HyperLink * make_link_window(TextNode * link_node , int type , int isSubWin);
-extern HyperLink * make_paste_window(PasteNode * paste);
-extern void make_special_pages(HashTable * pageHashTable);
-extern int window_code(Window * w , int size);
-extern int window_equal(Window * w1 , Window * w2);
-extern char * window_id(Window w);
-extern void read_ht_db(HashTable * page_hash , HashTable * macro_hash , HashTable * patch_hash);
-extern int get_filename(void);
-extern int is_number(char * str);
-extern void parser_error(char * str);
-extern int get_where(void);
-#ifdef _PARSE_AUX_C
-static void read_ht_file(HashTable * page_hash , HashTable * macro_hash , HashTable * patch_hash , FILE * db_fp , char * db_file);
-static HyperDocPage * make_special_page(int type , char * name);
-#endif
diff --git a/src/include/parse-input.h1 b/src/include/parse-input.h1
deleted file mode 100755
index b36d948..0000000
--- a/src/include/parse-input.h1
+++ /dev/null
@@ -1,16 +0,0 @@
-extern HyperLink * make_input_window(InputItem * item);
-extern HyperLink * make_box_window(InputBox * box , int type);
-extern void initialize_default(InputItem * item , char * buff);
-extern void parse_inputstring(void);
-extern void parse_simplebox(void);
-extern void parse_radiobox(void);
-extern void init_paste_item(InputItem * item);
-extern void repaste_item(void);
-extern InputItem * current_item(void);
-extern int already_there(char * name);
-extern void parse_radioboxes(void);
-#ifdef _PARSE_INPUT_C
-static void insert_item(InputItem * item);
-static void add_box_to_rb_list(char * name , InputBox * box);
-static int check_others(InputBox * list);
-#endif 
diff --git a/src/include/parse-paste.h1 b/src/include/parse-paste.h1
deleted file mode 100755
index b89badd..0000000
--- a/src/include/parse-paste.h1
+++ /dev/null
@@ -1,6 +0,0 @@
-extern void parse_paste(void);
-extern void parse_pastebutton(void);
-extern HyperDocPage * parse_patch(PasteNode * paste);
-#ifdef _PARSE_PASTE_C
-static void load_patch(PatchStore * patch);
-#endif 
diff --git a/src/include/parse-types.h1 b/src/include/parse-types.h1
deleted file mode 100755
index 664d0d2..0000000
--- a/src/include/parse-types.h1
+++ /dev/null
@@ -1,25 +0,0 @@
-extern void parse_begin_items(void );
-extern void parse_box(void );
-extern void parse_button(void );
-extern void parse_centerline(void );
-extern void parse_command(void );
-extern void parse_env(TextNode * node);
-extern void parse_free(void );
-extern void parse_help(void );
-extern void parse_ifcond(void );
-extern void parse_input_pix(void );
-extern void parse_item(void );
-extern void parse_mbox(void );
-extern void parse_mitem(void );
-extern void parse_newcond(void );
-extern void parse_setcond(void );
-extern void parse_spadcommand(TextNode * spad_node);
-extern void parse_spadsrc(TextNode * spad_node);
-extern void parse_table(void );
-extern void parse_value1(void );
-extern void parse_value2(void );
-extern void parse_verbatim(int type);
-#ifdef _PARSE_TYPES_C
-static void parse_condnode(void );
-static void parse_hasreturnto(void );
-#endif 
diff --git a/src/include/parse.h1 b/src/include/parse.h1
deleted file mode 100755
index fc2c346..0000000
--- a/src/include/parse.h1
+++ /dev/null
@@ -1,20 +0,0 @@
-extern void display_page(HyperDocPage * page);
-extern void init_parse_patch(HyperDocPage * page);
-extern void load_page(HyperDocPage * page);
-extern void parse_HyperDoc(void );
-extern void parse_from_string(char * str);
-extern HyperDocPage * parse_page_from_socket(void );
-extern HyperDocPage * parse_page_from_unixfd(void );
-#ifdef _PARSE_C
-static void end_a_page(void );
-static HyperDocPage * format_page(UnloadedPage * ulpage);
-static void parse_page(HyperDocPage * page);
-static void parse_replacepage(void );
-static void start_footer(void );
-static void start_scrolling(void );
-static void Push_MR(void );
-static void Pop_MR(void );
-static void parse_title(HyperDocPage * page);
-static void parse_header(HyperDocPage * page);
-static void init_parse_page(HyperDocPage * page);
-#endif
diff --git a/src/include/pixmap.h1 b/src/include/pixmap.h1
deleted file mode 100755
index 70aa314..0000000
--- a/src/include/pixmap.h1
+++ /dev/null
@@ -1,6 +0,0 @@
-extern int file_exists(char * );
-extern FILE * zzopen(char *  , char * );
-extern void write_pixmap_file(Display *, int, char *, Window, int, int, 
-                              int, int );
-extern int read_pixmap_file(Display *, int, char *, XImage * *, int *, int * );
-
diff --git a/src/include/prt.h1 b/src/include/prt.h1
deleted file mode 100755
index 5c76fd8..0000000
--- a/src/include/prt.h1
+++ /dev/null
@@ -1,19 +0,0 @@
-extern void myputchar(char );
-extern void clear_buff(void);
-extern void move_end(void);
-extern void move_home(void);
-extern void move_fore_word(void);
-extern void move_back_word(void);
-extern void delete_current_char(void);
-extern void del_print(int  , int );
-extern void delete_to_end_of_line(void);
-extern void delete_line(void);
-extern void printbuff(int  , int );
-extern void ins_print(int  , int );
-extern void reprint(int );
-extern void back_up(int );
-extern void back_it_up(int );
-extern void print_whole_buff(void);
-extern void move_ahead(void);
-extern void move_back(void);
-extern void back_over_current_char(void);
diff --git a/src/include/readbitmap.h1 b/src/include/readbitmap.h1
deleted file mode 100755
index bec15c9..0000000
--- a/src/include/readbitmap.h1
+++ /dev/null
@@ -1,9 +0,0 @@
-extern XImage * HTReadBitmapFile(Display * display, int screen, 
-                                 char * filename, int * width, int * height);
-extern ImageStruct * insert_image_struct(char * filename);
-#ifdef _READBITMAP_C
-static int read_hot(FILE * fd , char Line[] , int * x_hot , int * y_hot);
-static int read_w_and_h(FILE * fd, unsigned int * width, 
-                        unsigned int * height);
-#endif
-
diff --git a/src/include/rgb.h b/src/include/rgb.h
deleted file mode 100755
index cd3cd72..0000000
--- a/src/include/rgb.h
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-typedef struct _RGB {
-  float r,g,b;
-} RGB ;
-
-typedef struct _HSV {
-  float h,s,v;
-} HSV ;
-
-typedef struct _HLS {
-  float h,l,s;
-} HLS ;
-
-
-
-
-
-
-
diff --git a/src/include/scrollbar.h1 b/src/include/scrollbar.h1
deleted file mode 100755
index 5fcfcb3..0000000
--- a/src/include/scrollbar.h1
+++ /dev/null
@@ -1,21 +0,0 @@
-extern void calculateScrollBarMeasures(void );
-extern void drawScrollLines(void );
-extern void hideScrollBars(HDWindow * hdWindow);
-extern void getScrollBarMinimumSize(int * width , int * height);
-extern void linkScrollBars(void );
-extern void makeScrollBarWindows(void );
-extern void moveScroller(HDWindow * hdWindow);
-extern void scrollDown(void );
-extern void scrollDownPage(void );
-extern void scrollScroller(XButtonEvent * event);
-extern void scrollToFirstPage(void );
-extern void scrollUp(void );
-extern void scrollUpPage(void );
-extern void showScrollBars(HDWindow * hdWindow);
-#ifdef _SCROLLBAR_C
-static int ch(int height);
-static void changeWindowBackgroundPixmap(Window window , Pixmap pixmap);
-static void drawScroller3DEffects(HDWindow * hdWindow, int x1, int y1, 
-                                  int x2, int y2);
-
-#endif 
diff --git a/src/include/session.h1 b/src/include/session.h1
deleted file mode 100755
index 4eadaab..0000000
--- a/src/include/session.h1
+++ /dev/null
@@ -1,15 +0,0 @@
-extern int main(void);
-#ifdef _SESSION_C
-static void usr1_handler(int sig);
-static void usr2_handler(int sig);
-static void term_handler(int sig);
-static void close_client(int frame);
-static void read_SpadServer_command(void);
-static int test_sock_for_process(Sock * sock);
-static void read_menu_client_command(void);
-static void read_from_spad_io(void);
-static void kill_spad(void);
-static int accept_session_connection(Sock * server_sock);
-static void read_from_session(Sock * sock);
-static void manage_sessions(void);
-#endif
diff --git a/src/include/show-types.h1 b/src/include/show-types.h1
deleted file mode 100755
index a6fc5e3..0000000
--- a/src/include/show-types.h1
+++ /dev/null
@@ -1,10 +0,0 @@
-extern void show_text(TextNode * node , int Ender);
-#ifdef _SHOW_TYPES_C
-static void show_image(TextNode * node , GC gc);
-static void show_input(TextNode * node);
-static void show_link(TextNode * node);
-static void show_paste(TextNode * node);
-static void show_pastebutton(TextNode * node);
-static void show_simple_box(TextNode * node);
-static void show_spadcommand(TextNode * node);
-#endif 
diff --git a/src/include/sman.h1 b/src/include/sman.h1
deleted file mode 100755
index 9645289..0000000
--- a/src/include/sman.h1
+++ /dev/null
@@ -1,37 +0,0 @@
-extern int main(int argc , char * argv[] , char * envp[]);
-#ifdef _SMAN_C
-static void process_arguments(int argc , char * * argv);
-static int should_I_clef(void);
-static int in_X(void);
-static void set_up_defaults(void);
-static void process_options(int argc , char * * argv);
-static void death_handler(int sig);
-static void nagman_handler(int sig);
-static void sman_catch_signals(void);
-static void fix_env(char * * envp , int spadnum);
-static void init_term_io(void);
-static char * strPrefix(char * prefix , char * s);
-static void check_spad_proc(char * file , char * prefix);
-static void clean_up_old_sockets(void);
-static SpadProcess * fork_you(int death_action);
-static void exec_command_env(char * command , char * * env);
-static SpadProcess * spawn_of_hell(char * command , int death_action);
-static void start_the_spadclient(void);
-static void start_the_local_spadclient(void);
-static void start_the_nagman(void);
-static void start_the_session_manager(void);
-static void start_the_hypertex(void);
-static void start_the_graphics(void);
-static void fork_Axiom(void);
-static void start_the_Axiom(char * * envp);
-static void clean_up_sockets(void);
-static void clean_hypertex_socket(void);
-static void read_from_spad_io(int ptcNum);
-static void read_from_manager(int ptcNum);
-static void manage_spad_io(int ptcNum);
-static void init_spad_process_list(void);
-static SpadProcess * find_child(int proc_id);
-static void kill_all_children(void);
-static void clean_up_terminal(void);
-static void monitor_children(void);
-#endif
diff --git a/src/include/sockio-c.h1 b/src/include/sockio-c.h1
deleted file mode 100755
index 3798bc6..0000000
--- a/src/include/sockio-c.h1
+++ /dev/null
@@ -1,64 +0,0 @@
-extern int get_int(Sock * );
-extern char * get_string(Sock * );
-extern double get_float(Sock * );
-extern Sock * connect_to_local_server(char *  , int  , int );
-extern int sread(Sock *  , char *  , int  , char * );
-extern double plus_infinity(void );
-extern double minus_infinity(void );
-extern double NANQ(void );
-extern void sigpipe_handler(int );
-extern int wait_for_client_read(Sock *  , char *  , int  , char * );
-extern int wait_for_client_write(Sock *  , char *  , int  , char * );
-extern int swrite(Sock *  , char *  , int  , char * );
-extern int sselect(int  , fd_set *  , fd_set *  , fd_set *  , void * );
-extern int fill_buf(Sock *  , char *  , int  , char * );
-extern int sock_get_int(int );
-extern int get_ints(Sock *  , int *  , int );
-extern int sock_get_ints(int  , int *  , int );
-extern int send_int(Sock *  , int );
-extern int sock_send_int(int  , int );
-extern int send_ints(Sock *  , int *  , int );
-extern int sock_send_ints(int  , int *  , int );
-extern int send_string(Sock *  , char * );
-extern int send_string_len(Sock *  , char *  , int );
-extern int sock_send_string(int  , char * );
-extern int sock_send_string_len(int  , char *  , int );
-extern int send_strings(Sock *  , char * *  , int );
-extern int sock_send_strings(int  , char * *  , int );
-extern char * sock_get_string(int );
-extern char * get_string_buf(Sock *  , char *  , int );
-extern char * sock_get_string_buf(int  , char *  , int );
-extern int get_strings(Sock *  , char * *  , int );
-extern int sock_get_strings(int  , char * *  , int );
-extern int send_float(Sock *  , double );
-extern int sock_send_float(int  , double );
-extern int send_sfloats(Sock *  , float *  , int );
-extern int sock_send_sfloats(int  , float *  , int );
-extern int send_floats(Sock *  , double *  , int );
-extern int sock_send_floats(int  , double *  , int );
-extern double sock_get_float(int );
-extern int get_sfloats(Sock *  , float *  , int );
-extern int sock_get_sfloats(int  , float *  , int );
-extern int get_floats(Sock *  , double *  , int );
-extern int sock_get_floats(int  , double *  , int );
-extern int wait_for_client_kill(Sock *  , int );
-extern int sock_get_remote_fd(int );
-extern int send_signal(Sock *  , int );
-extern int sock_send_signal(int  , int );
-extern int send_wakeup(Sock * );
-extern int sock_send_wakeup(int );
-extern Sock * connect_to_local_server_new(char *  , int  , int );
-extern void remote_stdio(Sock * );
-extern void init_purpose_table(void );
-extern int make_server_number(void );
-extern void close_socket(int  , char * );
-extern int make_server_name(char *  , char * );
-extern int open_server(char * );
-extern int accept_connection(Sock * );
-extern void get_socket_type(Sock * );
-extern int sock_accept_connection(int );
-extern void redirect_stdio(Sock * );
-extern void init_socks(void );
-extern int server_switch(void );
-extern void flush_stdout(void );
-extern void print_line(char * );
diff --git a/src/include/spadbuf.h1 b/src/include/spadbuf.h1
deleted file mode 100755
index d5a0de9..0000000
--- a/src/include/spadbuf.h1
+++ /dev/null
@@ -1,7 +0,0 @@
-extern int main(int argc , char * * argv);
-#ifdef _SPADBUF_C
-static void spadbuf_inter_handler(int sig);
-static void spadbuf_function_chars(void);
-static void interp_io(void);
-static void init_parent(void);
-#endif
diff --git a/src/include/spadclient.h1 b/src/include/spadclient.h1
deleted file mode 100755
index 66cd152..0000000
--- a/src/include/spadclient.h1
+++ /dev/null
@@ -1,4 +0,0 @@
-extern int main(void);
-#ifdef _SPADCLIENT_C
-static void inter_handler(int sig);
-#endif
diff --git a/src/include/spadcolors.h b/src/include/spadcolors.h
deleted file mode 100755
index 4304724..0000000
--- a/src/include/spadcolors.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-#include <X11/X.h>
-#define numOfColors 240
-#define totalHuesConst   27 
-#define totalShadesConst 5 
-#define hueEnd  360
-#define hueStep 12    /* hueEnd/totalHuesConst */
-
-#define numPlanes 1
-#define numColors 10
-#define startColor 0
-#define endColor   startColor+numColors
-
-#define colorStep (maxColors+1)/numColors
-
-#define yes 1
-#define no 0
-
-#define smoothConst  50
-#define saymem(a,b,c) saymemWithLine(a,b,c,0)
-#define Colorcells 256   /* KF number of elements in permutation vector */
-#define shade 5
-#define saturation   0.8
-
-extern int       smoothHue;
-extern Colormap  colorMap;
-extern int       num;
-extern int       scrn;
-
-#define maxColors DisplayCells(dsply,scrn)-1
-
-#include "rgb.h"
diff --git a/src/include/spadcolors.h1 b/src/include/spadcolors.h1
deleted file mode 100755
index 39a2317..0000000
--- a/src/include/spadcolors.h1
+++ /dev/null
@@ -1,9 +0,0 @@
-extern RGB HSVtoRGB(HSV );
-extern RGB HLStoRGB(HLS );
-extern float value(float  , float  , float );
-extern int makeColors(Display *  , int  , Colormap *  , unsigned long * *  , int * );
-extern int makePermVector(Display *  , int  , unsigned long * * );
-extern int makeNewColorMap(Display *  , Colormap  , int );
-extern unsigned long XPixelColor(int );
-extern void FreePixels(Display *  , Colormap  , int );
-extern int AllocCells(Display *  , Colormap  , int );
diff --git a/src/include/spadint.h1 b/src/include/spadint.h1
deleted file mode 100755
index bb296a9..0000000
--- a/src/include/spadint.h1
+++ /dev/null
@@ -1,28 +0,0 @@
-extern HyperDocPage * issue_server_command(HyperLink * link);
-extern HyperDocPage * issue_unixlink(TextNode * node);
-extern char * print_to_string(TextNode * command);
-extern void issue_spadcommand(HyperDocPage * page , TextNode * command , 
-                              int immediate , int type);
-extern Sock * accept_menu_connection(Sock * server_sock);
-extern char * print_to_string1(TextNode * command , int * sizeBuf);
-extern int issue_serverpaste(TextNode * command);
-extern void issue_unixcommand(TextNode * node);
-extern int issue_unixpaste(TextNode * node);
-extern void service_session_socket(void);
-extern void send_lisp_command(char * command);
-extern void escape_string(char * s);
-extern void unescape_string(char * s);
-extern char * print_source_to_string1(TextNode * command , int * sizeBuf);
-extern char * print_source_to_string(TextNode * command);
-#ifdef _SPADINT_C
-static void start_user_buffer(HyperDocPage * page);
-static void clear_execution_marks(HashTable * depend_hash);
-static void issue_dependent_commands(HyperDocPage * page, TextNode * command, 
-                                     int type);
-static void send_pile(Sock * sock , char * str);
-static void mark_as_executed(HyperDocPage * page, TextNode * command, 
-                             int type);
-static void accept_menu_server_connection(HyperDocPage * page);
-static void switch_frames(void );
-static void close_client(int pid);
-#endif 
diff --git a/src/include/titlebar.h1 b/src/include/titlebar.h1
deleted file mode 100755
index b5d564c..0000000
--- a/src/include/titlebar.h1
+++ /dev/null
@@ -1,7 +0,0 @@
-extern void getTitleBarMinimumSize(int * width , int * height);
-extern void linkTitleBarWindows(void);
-extern void makeTitleBarWindows(void);
-extern void showTitleBar(void);
-#ifdef _TITLEBAR_C
-static void readTitleBarImages(void);
-#endif
diff --git a/src/include/util.h1 b/src/include/util.h1
deleted file mode 100755
index bed0da3..0000000
--- a/src/include/util.h1
+++ /dev/null
@@ -1,6 +0,0 @@
-extern int checker(int  , int  , char * );
-extern char * getmemWithLine(int  , char *  , int );
-extern char * saymemWithLine(char *  , int  , int  , int );
-extern void myfree(void *  , int );
-extern XPoint getWindowPositionXY(Display *  , Window );
-extern XPoint getWindowSizeXY(Display *  , Window );
diff --git a/src/include/view.h b/src/include/view.h
deleted file mode 100755
index 600047b..0000000
--- a/src/include/view.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-/* This file is to be included by all the viewport files */
-
-
-#define check(code) checker(code,__LINE__,errorStr)
-#define saymem(a,b,c) saymemWithLine(a,b,c,__LINE__)
-#define exitWithAck(ACK,ACKsize,i) check(write(Socket,&(ACK),sizeof(ACKsize)));  exit(i);
-#define NIL(type) ((type *)NULL)
-/* #define monoColor(x) (mono)?foregroundColor:spadColors[x] */
-
-#define oldNum 8  /* in the old system, we assumed an eight shade palette */
-#define oldOff 2
-
-#define monoColor(x) (mono)?foregroundColor:XSolidColor((int)x/oldNum,(int)(x%oldNum)/oldOff)
-#define monoDither(x,y) (mono)?foregroundColor:XSolidColor(x,y)
-#define notANumber (0.0/0.0)
-
-        /* error messages */
-#define fontErrMess "       Try getting the font or changing the .Xdefaults entry"
-
diff --git a/src/include/wct.h1 b/src/include/wct.h1
deleted file mode 100755
index b156c43..0000000
--- a/src/include/wct.h1
+++ /dev/null
@@ -1,26 +0,0 @@
-extern time_t ftime(char * );
-extern void fatal(char *  , char * );
-extern off_t fsize(char * );
-extern Wix * scanWct(Wct *  , char * );
-extern void reintern1Wct(Wct * );
-extern Wix * rescanWct(void);
-extern void skimWct(Wct * );
-extern void skim1Wct(Wct * );
-extern void printTime(long * );
-extern int skimString(char *  , int  , int  , int );
-extern int prChar(int );
-extern Wct * reread1Wct(Wct * );
-extern void sfatal(char * );
-extern Wct * read1Wct(char * );
-extern Wct * nconcWct(Wct *  , Wct * );
-extern void sortWct(Wct * );
-extern void sort1Wct(Wct * );
-extern int mystrcmp(const void  *  , const void * );
-extern void burstWct(Wct * );
-extern void burst1Wct(Wct * );
-extern Wct * intern1Wct(char * );
-extern void load_wct_file(char * );
-extern void  skim_wct(void);
-extern void  rescan_wct(void);
-extern void  find_wct(void);
-
diff --git a/src/include/xdither.h1 b/src/include/xdither.h1
deleted file mode 100755
index f9ac1a1..0000000
--- a/src/include/xdither.h1
+++ /dev/null
@@ -1,11 +0,0 @@
-extern int dither_char_bitmap(void);
-extern int XInitDither(Display *, int, GC, unsigned long, unsigned long);
-extern int XChangeDither(Display *  , GC  , int );
-extern void XDitherRectangle(Display *, Drawable, GC, int, int, unsigned int, 
-                             unsigned int );
-extern void XDitherRectangles(Display *, Drawable, GC, XRectangle *, int);
-extern void XDitherPolygon(Display *, Drawable, GC, XPoint *, int, int, int);
-extern void XDitherArc(Display *, Drawable, GC, int, int, unsigned int, 
-                       unsigned int, int, int );
-extern void XDitherArcs(Display *  , Drawable  , GC  , XArc *  , int );
-
diff --git a/src/include/xpm.h b/src/include/xpm.h
deleted file mode 100755
index 33da4b8..0000000
--- a/src/include/xpm.h
+++ /dev/null
@@ -1,487 +0,0 @@
-/*
- * Copyright (C) 1989-95 GROUPE BULL
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to
- * deal in the Software without restriction, including without limitation the
- * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
- * sell copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * GROUPE BULL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Except as contained in this notice, the name of GROUPE BULL shall not be
- * used in advertising or otherwise to promote the sale, use or other dealings
- * in this Software without prior written authorization from GROUPE BULL.
- */
-
-/*****************************************************************************\
-* xpm.h:                                                                      *
-*                                                                             *
-*  XPM library                                                                *
-*  Include file                                                               *
-*                                                                             *
-*  Developed by Arnaud Le Hors                                                *
-\*****************************************************************************/
-
-/*
- * The code related to FOR_MSW has been added by
- * HeDu (hedu@cul-ipn.uni-kiel.de) 4/94
- */
-
-#ifndef XPM_h
-#define XPM_h
-
-/*
- * first some identification numbers:
- * the version and revision numbers are determined with the following rule:
- * SO Major number = LIB minor version number.
- * SO Minor number = LIB sub-minor version number.
- * e.g: Xpm version 3.2f
- *      we forget the 3 which is the format number, 2 gives 2, and f gives 6.
- *      thus we have XpmVersion = 2 and XpmRevision = 6
- *      which gives  SOXPMLIBREV = 2.6
- *
- * Then the XpmIncludeVersion number is built from these numbers.
- */
-#define XpmFormat 3
-#define XpmVersion 4
-#define XpmRevision 9
-#define XpmIncludeVersion ((XpmFormat * 100 + XpmVersion) * 100 + XpmRevision)
-
-#ifndef XPM_NUMBERS
-
-#ifdef FOR_MSW
-# define SYSV			/* uses memcpy string.h etc. */
-# include <malloc.h>
-# include "simx.h"		/* defines some X stuff using MSW types */
-#define NEED_STRCASECMP		/* at least for MSVC++ */
-#else /* FOR_MSW */
-# include <X11/Xlib.h>
-# include <X11/Xutil.h>
-#endif /* FOR_MSW */
-
-/* let's define Pixel if it is not done yet */
-#if ! defined(_XtIntrinsic_h) && ! defined(PIXEL_ALREADY_TYPEDEFED)
-typedef unsigned long Pixel;	/* Index into colormap */
-# define PIXEL_ALREADY_TYPEDEFED
-#endif
-
-/* make sure we know whether function prototypes are needed or not */
-#ifndef NeedFunctionPrototypes
-# if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus)
-#  define NeedFunctionPrototypes 1
-# else
-#  define NeedFunctionPrototypes 0
-# endif
-#endif
-
-
-/* Return ErrorStatus codes:
- * null     if full success
- * positive if partial success
- * negative if failure
- */
-
-#define XpmColorError    1
-#define XpmSuccess       0
-#define XpmOpenFailed   -1
-#define XpmFileInvalid  -2
-#define XpmNoMemory     -3
-#define XpmColorFailed  -4
-
-typedef struct {
-    char *name;			/* Symbolic color name */
-    char *value;		/* Color value */
-    Pixel pixel;		/* Color pixel */
-}      XpmColorSymbol;
-
-typedef struct {
-    char *name;			/* name of the extension */
-    unsigned int nlines;	/* number of lines in this extension */
-    char **lines;		/* pointer to the extension array of strings */
-}      XpmExtension;
-
-typedef struct {
-    char *string;		/* characters string */
-    char *symbolic;		/* symbolic name */
-    char *m_color;		/* monochrom default */
-    char *g4_color;		/* 4 level grayscale default */
-    char *g_color;		/* other level grayscale default */
-    char *c_color;		/* color default */
-}      XpmColor;
-
-typedef struct {
-    unsigned int width;		/* image width */
-    unsigned int height;	/* image height */
-    unsigned int cpp;		/* number of characters per pixel */
-    unsigned int ncolors;	/* number of colors */
-    XpmColor *colorTable;	/* list of related colors */
-    unsigned int *data;		/* image data */
-}      XpmImage;
-
-typedef struct {
-    unsigned long valuemask;	/* Specifies which attributes are defined */
-    char *hints_cmt;		/* Comment of the hints section */
-    char *colors_cmt;		/* Comment of the colors section */
-    char *pixels_cmt;		/* Comment of the pixels section */
-    unsigned int x_hotspot;	/* Returns the x hotspot's coordinate */
-    unsigned int y_hotspot;	/* Returns the y hotspot's coordinate */
-    unsigned int nextensions;	/* number of extensions */
-    XpmExtension *extensions;	/* pointer to array of extensions */
-}      XpmInfo;
-
-typedef int (*XpmAllocColorFunc)(
-#if NeedFunctionPrototypes
-    Display*			/* display */,
-    Colormap			/* colormap */,
-    char*			/* colorname */,
-    XColor*			/* xcolor */,
-    void*			/* closure */
-#endif
-);
-
-typedef int (*XpmFreeColorsFunc)(
-#if NeedFunctionPrototypes
-    Display*			/* display */,
-    Colormap			/* colormap */,
-    Pixel*			/* pixels */,
-    int				/* npixels */,
-    void*			/* closure */
-#endif
-);
-
-typedef struct {
-    unsigned long valuemask;		/* Specifies which attributes are
-					   defined */
-
-    Visual *visual;			/* Specifies the visual to use */
-    Colormap colormap;			/* Specifies the colormap to use */
-    unsigned int depth;			/* Specifies the depth */
-    unsigned int width;			/* Returns the width of the created
-					   pixmap */
-    unsigned int height;		/* Returns the height of the created
-					   pixmap */
-    unsigned int x_hotspot;		/* Returns the x hotspot's
-					   coordinate */
-    unsigned int y_hotspot;		/* Returns the y hotspot's
-					   coordinate */
-    unsigned int cpp;			/* Specifies the number of char per
-					   pixel */
-    Pixel *pixels;			/* List of used color pixels */
-    unsigned int npixels;		/* Number of used pixels */
-    XpmColorSymbol *colorsymbols;	/* List of color symbols to override */
-    unsigned int numsymbols;		/* Number of symbols */
-    char *rgb_fname;			/* RGB text file name */
-    unsigned int nextensions;		/* Number of extensions */
-    XpmExtension *extensions;		/* List of extensions */
-
-    unsigned int ncolors;               /* Number of colors */
-    XpmColor *colorTable;               /* List of colors */
-/* 3.2 backward compatibility code */
-    char *hints_cmt;                    /* Comment of the hints section */
-    char *colors_cmt;                   /* Comment of the colors section */
-    char *pixels_cmt;                   /* Comment of the pixels section */
-/* end 3.2 bc */
-    unsigned int mask_pixel;            /* Color table index of transparent
-                                           color */
-
-    /* Color Allocation Directives */
-    Bool exactColors;			/* Only use exact colors for visual */
-    unsigned int closeness;		/* Allowable RGB deviation */
-    unsigned int red_closeness;		/* Allowable red deviation */
-    unsigned int green_closeness;	/* Allowable green deviation */
-    unsigned int blue_closeness;	/* Allowable blue deviation */
-    int color_key;			/* Use colors from this color set */
-
-    Pixel *alloc_pixels;		/* Returns the list of alloc'ed color
-					   pixels */
-    Bool nalloc_pixels;			/* Returns the number of alloc'ed
-					   color pixels */
-
-    Bool alloc_close_colors;    	/* Specify whether close colors should
-					   be allocated using XAllocColor
-					   or not */
-    int bitmap_format;			/* Specify the format of 1bit depth
-					   images: ZPixmap or XYBitmap */
-
-    /* Color functions */
-    XpmAllocColorFunc alloc_color;	/* Application color allocator */
-    XpmFreeColorsFunc free_colors;	/* Application color de-allocator */
-    void *color_closure;		/* Application private data to pass to
-					   alloc_color and free_colors */
-
-}      XpmAttributes;
-
-/* XpmAttributes value masks bits */
-#define XpmVisual	   (1L<<0)
-#define XpmColormap	   (1L<<1)
-#define XpmDepth	   (1L<<2)
-#define XpmSize		   (1L<<3)	/* width & height */
-#define XpmHotspot	   (1L<<4)	/* x_hotspot & y_hotspot */
-#define XpmCharsPerPixel   (1L<<5)
-#define XpmColorSymbols	   (1L<<6)
-#define XpmRgbFilename	   (1L<<7)
-/* 3.2 backward compatibility code */
-#define XpmInfos	   (1L<<8)
-#define XpmReturnInfos	   XpmInfos
-/* end 3.2 bc */
-#define XpmReturnPixels	   (1L<<9)
-#define XpmExtensions      (1L<<10)
-#define XpmReturnExtensions XpmExtensions
-
-#define XpmExactColors     (1L<<11)
-#define XpmCloseness	   (1L<<12)
-#define XpmRGBCloseness	   (1L<<13)
-#define XpmColorKey	   (1L<<14)
-
-#define XpmColorTable      (1L<<15)
-#define XpmReturnColorTable XpmColorTable
-
-#define XpmReturnAllocPixels (1L<<16)
-#define XpmAllocCloseColors (1L<<17)
-#define XpmBitmapFormat    (1L<<18)
-
-#define XpmAllocColor      (1L<<19)
-#define XpmFreeColors      (1L<<20)
-#define XpmColorClosure    (1L<<21)
-
-
-/* XpmInfo value masks bits */
-#define XpmComments        XpmInfos
-#define XpmReturnComments  XpmComments
-
-/* XpmAttributes mask_pixel value when there is no mask */
-#ifndef FOR_MSW
-#define XpmUndefPixel 0x80000000
-#else
-/* int is only 16 bit for MSW */
-#define XpmUndefPixel 0x8000
-#endif
-
-/*
- * color keys for visual type, they must fit along with the number key of
- * each related element in xpmColorKeys[] defined in XpmI.h
- */
-#define XPM_MONO	2
-#define XPM_GREY4	3
-#define XPM_GRAY4	3
-#define XPM_GREY 	4
-#define XPM_GRAY 	4
-#define XPM_COLOR	5
-
-
-/* macros for forward declarations of functions with prototypes */
-#if NeedFunctionPrototypes
-#define FUNC(f, t, p) extern t f p
-#define LFUNC(f, t, p) static t f p
-#else
-#define FUNC(f, t, p) extern t f()
-#define LFUNC(f, t, p) static t f()
-#endif
-
-
-/*
- * functions declarations
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* FOR_MSW, all ..Pixmap.. are excluded, only the ..XImage.. are used */
-
-#ifndef FOR_MSW
-    FUNC(XpmCreatePixmapFromData, int, (Display *display,
-					Drawable d,
-					char **data,
-					Pixmap *pixmap_return,
-					Pixmap *shapemask_return,
-					XpmAttributes *attributes));
-
-    FUNC(XpmCreateDataFromPixmap, int, (Display *display,
-					char ***data_return,
-					Pixmap pixmap,
-					Pixmap shapemask,
-					XpmAttributes *attributes));
-
-    FUNC(XpmReadFileToPixmap, int, (Display *display,
-				    Drawable d,
-				    char *filename,
-				    Pixmap *pixmap_return,
-				    Pixmap *shapemask_return,
-				    XpmAttributes *attributes));
-
-    FUNC(XpmWriteFileFromPixmap, int, (Display *display,
-				       char *filename,
-				       Pixmap pixmap,
-				       Pixmap shapemask,
-				       XpmAttributes *attributes));
-#endif  /* ndef FOR_MSW */
-
-    FUNC(XpmCreateImageFromData, int, (Display *display,
-				       char **data,
-				       XImage **image_return,
-				       XImage **shapemask_return,
-				       XpmAttributes *attributes));
-
-    FUNC(XpmCreateDataFromImage, int, (Display *display,
-				       char ***data_return,
-				       XImage *image,
-				       XImage *shapeimage,
-				       XpmAttributes *attributes));
-
-    FUNC(XpmReadFileToImage, int, (Display *display,
-				   char *filename,
-				   XImage **image_return,
-				   XImage **shapeimage_return,
-				   XpmAttributes *attributes));
-
-    FUNC(XpmWriteFileFromImage, int, (Display *display,
-				      char *filename,
-				      XImage *image,
-				      XImage *shapeimage,
-				      XpmAttributes *attributes));
-
-    FUNC(XpmCreateImageFromBuffer, int, (Display *display,
-					 char *buffer,
-					 XImage **image_return,
-					 XImage **shapemask_return,
-					 XpmAttributes *attributes));
-#ifndef FOR_MSW
-    FUNC(XpmCreatePixmapFromBuffer, int, (Display *display,
-					  Drawable d,
-					  char *buffer,
-					  Pixmap *pixmap_return,
-					  Pixmap *shapemask_return,
-					  XpmAttributes *attributes));
-
-    FUNC(XpmCreateBufferFromImage, int, (Display *display,
-					 char **buffer_return,
-					 XImage *image,
-					 XImage *shapeimage,
-					 XpmAttributes *attributes));
-
-    FUNC(XpmCreateBufferFromPixmap, int, (Display *display,
-					  char **buffer_return,
-					  Pixmap pixmap,
-					  Pixmap shapemask,
-					  XpmAttributes *attributes));
-#endif  /* ndef FOR_MSW */
-    FUNC(XpmReadFileToBuffer, int, (char *filename, char **buffer_return));
-    FUNC(XpmWriteFileFromBuffer, int, (char *filename, char *buffer));
-
-    FUNC(XpmReadFileToData, int, (char *filename, char ***data_return));
-    FUNC(XpmWriteFileFromData, int, (char *filename, char **data));
-
-    FUNC(XpmAttributesSize, int, ());
-    FUNC(XpmFreeAttributes, void, (XpmAttributes *attributes));
-    FUNC(XpmFreeExtensions, void, (XpmExtension *extensions,
-				   int nextensions));
-
-    FUNC(XpmFreeXpmImage, void, (XpmImage *image));
-    FUNC(XpmFreeXpmInfo, void, (XpmInfo *info));
-    FUNC(XpmGetErrorString, char *, (int errcode));
-    FUNC(XpmLibraryVersion, int, ());
-
-    /* XpmImage functions */
-    FUNC(XpmReadFileToXpmImage, int, (char *filename,
-				      XpmImage *image,
-				      XpmInfo *info));
-
-    FUNC(XpmWriteFileFromXpmImage, int, (char *filename,
-					 XpmImage *image,
-					 XpmInfo *info));
-#ifndef FOR_MSW
-    FUNC(XpmCreatePixmapFromXpmImage, int, (Display *display,
-					    Drawable d,
-					    XpmImage *image,
-					    Pixmap *pixmap_return,
-					    Pixmap *shapemask_return,
-					    XpmAttributes *attributes));
-#endif
-    FUNC(XpmCreateImageFromXpmImage, int, (Display *display,
-					   XpmImage *image,
-					   XImage **image_return,
-					   XImage **shapeimage_return,
-					   XpmAttributes *attributes));
-
-    FUNC(XpmCreateXpmImageFromImage, int, (Display *display,
-					   XImage *image,
-					   XImage *shapeimage,
-					   XpmImage *xpmimage,
-					   XpmAttributes *attributes));
-#ifndef FOR_MSW
-    FUNC(XpmCreateXpmImageFromPixmap, int, (Display *display,
-					    Pixmap pixmap,
-					    Pixmap shapemask,
-					    XpmImage *xpmimage,
-					    XpmAttributes *attributes));
-#endif
-    FUNC(XpmCreateDataFromXpmImage, int, (char ***data_return,
-					  XpmImage *image,
-					  XpmInfo *info));
-
-    FUNC(XpmCreateXpmImageFromData, int, (char **data,
-					  XpmImage *image,
-					  XpmInfo *info));
-
-    FUNC(XpmCreateXpmImageFromBuffer, int, (char *buffer,
-					    XpmImage *image,
-					    XpmInfo *info));
-
-    FUNC(XpmCreateBufferFromXpmImage, int, (char **buffer_return,
-					    XpmImage *image,
-					    XpmInfo *info));
-
-    FUNC(XpmFree, void, (void *ptr));
-
-#ifdef __cplusplus
-} /* for C++ V2.0 */
-#endif
-
-
-/* backward compatibility */
-
-/* for version 3.0c */
-#define XpmPixmapColorError  XpmColorError
-#define XpmPixmapSuccess     XpmSuccess
-#define XpmPixmapOpenFailed  XpmOpenFailed
-#define XpmPixmapFileInvalid XpmFileInvalid
-#define XpmPixmapNoMemory    XpmNoMemory
-#define XpmPixmapColorFailed XpmColorFailed
-
-#define XpmReadPixmapFile(dpy, d, file, pix, mask, att) \
-    XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
-#define XpmWritePixmapFile(dpy, file, pix, mask, att) \
-    XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
-
-/* for version 3.0b */
-#define PixmapColorError  XpmColorError
-#define PixmapSuccess     XpmSuccess
-#define PixmapOpenFailed  XpmOpenFailed
-#define PixmapFileInvalid XpmFileInvalid
-#define PixmapNoMemory    XpmNoMemory
-#define PixmapColorFailed XpmColorFailed
-
-#define ColorSymbol XpmColorSymbol
-
-#define XReadPixmapFile(dpy, d, file, pix, mask, att) \
-    XpmReadFileToPixmap(dpy, d, file, pix, mask, att)
-#define XWritePixmapFile(dpy, file, pix, mask, att) \
-    XpmWriteFileFromPixmap(dpy, file, pix, mask, att)
-#define XCreatePixmapFromData(dpy, d, data, pix, mask, att) \
-    XpmCreatePixmapFromData(dpy, d, data, pix, mask, att)
-#define XCreateDataFromPixmap(dpy, data, pix, mask, att) \
-    XpmCreateDataFromPixmap(dpy, data, pix, mask, att)
-
-#endif /* XPM_NUMBERS */
-#endif
diff --git a/src/include/xshade.h1 b/src/include/xshade.h1
deleted file mode 100755
index 820ea89..0000000
--- a/src/include/xshade.h1
+++ /dev/null
@@ -1,12 +0,0 @@
-extern int char_bitmap(void);
-extern int XInitShades(Display *  , int );
-extern int XChangeShade(Display *  , int );
-extern int XQueryShades(unsigned int * );
-extern void XShadeRectangle(Display *, Drawable, int, int, unsigned int, 
-                            unsigned int );
-extern void XShadeRectangles(Display *  , Drawable  , XRectangle *  , int );
-extern void XShadePolygon(Display *, Drawable, XPoint *, int, int, int );
-extern void XShadeArc(Display *, Drawable, int, int, unsigned int, 
-                      unsigned int, int, int );
-extern void XShadeArcs(Display *  , Drawable  , XArc *  , int );
-
diff --git a/src/include/xspadfill.h1 b/src/include/xspadfill.h1
deleted file mode 100755
index 849046d..0000000
--- a/src/include/xspadfill.h1
+++ /dev/null
@@ -1,14 +0,0 @@
-extern int XInitSpadFill(Display *, int, Colormap *, int *, int *, 
-                         int *, int * );
-extern void XSpadFillSetArcMode(Display *, int );
-extern GC SpadFillGC(Display *, int, int, char * );
-extern unsigned long XSolidColor(int, int );
-extern void XSpadFillRectangle(Display *, Drawable, int, int, unsigned int, 
-                               unsigned int, int, int );
-extern void XSpadFillRectangles(Display *, Drawable, XRectangle *, int, 
-                                int, int );
-extern void XSpadFillPolygon(Display *, Drawable, XPoint *, int, int, 
-                             int, int, int );
-extern void XSpadFillArc(Display *, Drawable, int, int, unsigned int, 
-                         unsigned int, int, int, int, int );
-extern void XSpadFillArcs(Display *, Drawable, XArc *, int, int, int );
diff --git a/src/lib/Makefile.pamphlet b/src/lib/Makefile.pamphlet
deleted file mode 100644
index c0b018d..0000000
--- a/src/lib/Makefile.pamphlet
+++ /dev/null
@@ -1,564 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib Makefile}
-\author{Timothy Daly}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{environment}
-\begin{chunk}{environment}
-IN=${SRC}/lib
-MID=${INT}/lib
-OUT=${OBJ}/${SYS}/lib
-DOCINT=${INT}/doc/src/lib
-DOCMNT=${MNT}/${SYS}/doc/src/lib
-INC= ${SRC}/include
-
-AR=	${OUT}/bsdsignal.o  ${OUT}/cursor.o ${OUT}/edin.o     \
-        ${OUT}/fnct-key.o   ${OUT}/halloc.o ${OUT}/openpty.o  \
-        ${OUT}/pixmap.o     ${OUT}/prt.o    ${OUT}/sockio-c.o \
-        ${OUT}/spadcolors.o ${OUT}/util.o   ${OUT}/wct.o      \
-        ${OUT}/xdither.o    ${OUT}/xshade.o ${OUT}/xspadfill.o 
-
-OTHER=	${OUT}/cfuns-c.o ${OUT}/hash.o
-
-DOCFILES=\
- ${DOCMNT}/bsdsignal.c.pdf  ${DOCMNT}/cfuns-c.c.pdf  ${DOCMNT}/cursor.c.pdf \
- ${DOCMNT}/edin.c.pdf       ${DOCMNT}/fnct-key.c.pdf ${DOCMNT}/halloc.c.pdf \
- ${DOCMNT}/hash.c.pdf       ${DOCMNT}/openpty.c.pdf  ${DOCMNT}/pixmap.c.pdf \
- ${DOCMNT}/prt.c.pdf        ${DOCMNT}/sockio-c.c.pdf ${DOCMNT}/Makefile.pdf \
- ${DOCMNT}/spadcolors.c.pdf ${DOCMNT}/util.c.pdf     ${DOCMNT}/wct.c.pdf    \
- ${DOCMNT}/xdither.c.pdf    ${DOCMNT}/xshade.c.pdf   ${DOCMNT}/xspadfill.c.pdf 
-
-\end{chunk}
-\section{Files}
-\subsection{bsdsignal.c \cite{1}}
-
-\begin{chunk}{bsdsignal}
-${MID}/bsdsignal.c: ${IN}/bsdsignal.c.pamphlet
-	@echo sl01 making ${MID}/bsdsignal.c from ${IN}/bsdsignal.c.pamphlet
-	@${BOOKS}/tanglec bsdsignal.c.pamphlet >${MID}/bsdsignal.c
-
-${OUT}/bsdsignal.o: ${MID}/bsdsignal.c
-	@echo sl02 making ${OUT}/bsdsignal.o from ${MID}/bsdsignal.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/bsdsignal.c )
-
-${DOCINT}/bsdsignal.c.pdf: ${IN}/bsdsignal.c.pamphlet 
-	@echo sl03 making ${DOCINT}/bsdsignal.c.pdf \
-                     from ${IN}/bsdsignal.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/bsdsignal.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} bsdsignal.c.pamphlet ; \
-	rm -f ${DOCINT}/bsdsignal.c.pamphlet ; \
-	rm -f ${DOCINT}/bsdsignal.c.tex ; \
-	rm -f ${DOCINT}/bsdsignal.c )
-
-${DOCMNT}/bsdsignal.c.pdf: ${DOCINT}/bsdsignal.c.pdf
-	@echo sl12 making ${DOCMNT}/bsdsignal.c.pdf from \
-                          ${DOCINT}/bsdsignal.c.pdf
-	@cp ${DOCINT}/bsdsignal.c.pdf ${DOCMNT}/bsdsignal.c.pdf 
-
-\end{chunk}
-
-\subsection{cfuns-c.c \cite{2}}
-The cfuns-c file contains socket primitives used by Axiom.
-They must be linked into and visible from the inferior lisp.
-In GCL this link happens thru setting a shell variable called
-{\bf EXTRAS} in the {\bf h/386-linux.defs} file. This file
-gets included as part of the final system build of GCL.
-
-\begin{chunk}{cfuns-c}
-${MID}/cfuns-c.c: ${IN}/cfuns-c.c.pamphlet
-	@echo sl05 making ${MID}/cfuns-c.c from ${IN}/cfuns-c.c.pamphlet
-	@${BOOKS}/tanglec cfuns-c.c.pamphlet >${MID}/cfuns-c.c
-
-${OUT}/cfuns-c.o: ${MID}/cfuns-c.c
-	@echo sl06 making ${OUT}/cfuns-c.o from ${MID}/cfuns-c.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/cfuns-c.c )
-
-${DOCINT}/cfuns-c.c.pdf: ${IN}/cfuns-c.c.pamphlet 
-	@echo sl07 making ${DOCINT}/cfuns-c.c.pdf from ${IN}/cfuns-c.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/cfuns-c.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} cfuns-c.c.pamphlet ; \
-	rm -f ${DOCINT}/cfuns-c.c.pamphlet ; \
-	rm -f ${DOCINT}/cfuns-c.c.tex ; \
-	rm -f ${DOCINT}/cfuns-c.c )
-
-${DOCMNT}/cfuns-c.c.pdf: ${DOCINT}/cfuns-c.c.pdf
-	@echo sl04 making ${DOCMNT}/cfuns-c.c.pdf from \
-                          ${IN}/cfuns-c.c.pamphlet
-	@cp ${DOCINT}/cfuns-c.c.pdf ${DOCMNT}/cfuns-c.c.pdf 
-
-\end{chunk}
-\subsection{cursor.c \cite{3}}
-\begin{chunk}{cursor}
-${MID}/cursor.c: ${IN}/cursor.c.pamphlet
-	@echo sl09 making ${MID}/cursor.c from ${IN}/cursor.c.pamphlet
-	@${BOOKS}/tanglec cursor.c.pamphlet >${MID}/cursor.c
-
-${OUT}/cursor.o: ${MID}/cursor.c
-	@echo sl10 making ${OUT}/cursor.o from ${MID}/cursor.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/cursor.c )
-
-${DOCINT}/cursor.c.pdf: ${IN}/cursor.c.pamphlet 
-	@echo sl11 making ${DOCINT}/cursor.c.pdf from ${IN}/cursor.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/cursor.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} cursor.c.pamphlet ; \
-	rm -f ${DOCINT}/cursor.c.pamphlet ; \
-	rm -f ${DOCINT}/cursor.c.tex ; \
-	rm -f ${DOCINT}/cursor.c )
-
-${DOCMNT}/cursor.c.pdf: ${DOCINT}/cursor.c.pdf
-	@echo sl12 making ${DOCMNT}/cursor.c.pdf from ${DOCINT}/cursor.c.pdf
-	@cp ${DOCINT}/cursor.c.pdf ${DOCMNT}/cursor.c.pdf 
-
-\end{chunk}
-\subsection{edin.c \cite{4}}
-\begin{chunk}{edin}
-${MID}/edin.c: ${IN}/edin.c.pamphlet
-	@echo sl13 making ${MID}/edin.c from ${IN}/edin.c.pamphlet
-	@${BOOKS}/tanglec edin.c.pamphlet >${MID}/edin.c
-
-${OUT}/edin.o: ${MID}/edin.c
-	@echo sl14 making ${OUT}/edin.o from ${MID}/edin.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/edin.c )
-
-${DOCINT}/edin.c.pdf: ${IN}/edin.c.pamphlet 
-	@echo sl15 making ${DOCINT}/edin.c.pdf from ${IN}/edin.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/edin.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} edin.c.pamphlet ; \
-	rm -f ${DOCINT}/edin.c.pamphlet ; \
-	rm -f ${DOCINT}/edin.c.tex ; \
-	rm -f ${DOCINT}/edin.c )
-
-${DOCMNT}/edin.c.pdf: ${DOCINT}/edin.c.pdf
-	@echo sl16 making ${DOCMNT}/edin.c.pdf from ${DOCINT}/edin.c.pdf
-	@cp ${DOCINT}/edin.c.pdf ${DOCMNT}/edin.c.pdf 
-
-\end{chunk}
-\subsection{fnct-key.c \cite{5}}
-\begin{chunk}{fnctkey}
-${MID}/fnct-key.c: ${IN}/fnct-key.c.pamphlet
-	@echo sl17 making ${MID}/fnct-key.c from ${IN}/fnct-key.c.pamphlet
-	@${BOOKS}/tanglec fnct-key.c.pamphlet >${MID}/fnct-key.c
-
-${OUT}/fnct-key.o: ${MID}/fnct-key.c
-	@echo sl18 making ${OUT}/fnct-key.o from ${MID}/fnct-key.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/fnct-key.c )
-
-${DOCINT}/fnct-key.c.pdf: ${IN}/fnct-key.c.pamphlet 
-	@echo sl19 making ${DOCINT}/fnct-key.c.pdf from ${IN}/fnct-key.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/fnct-key.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} fnct-key.c.pamphlet ; \
-	rm -f ${DOCINT}/fnct-key.c.pamphlet ; \
-	rm -f ${DOCINT}/fnct-key.c.tex ; \
-	rm -f ${DOCINT}/fnct-key.c )
-
-${DOCMNT}/fnct-key.c.pdf: ${DOCINT}/fnct-key.c.pdf
-	@echo sl20 making ${DOCMNT}/fnct-key.c.pdf from ${DOCINT}/fnct-key.c.pdf
-	@cp ${DOCINT}/fnct-key.c.pdf ${DOCMNT}/fnct-key.c.pdf 
-
-\end{chunk}
-\subsection{halloc.c \cite{6}}
-\begin{chunk}{halloc}
-${MID}/halloc.c: ${IN}/halloc.c.pamphlet
-	@echo sl21 making ${MID}/halloc.c from ${IN}/halloc.c.pamphlet
-	@${BOOKS}/tanglec halloc.c.pamphlet >${MID}/halloc.c
-
-${OUT}/halloc.o: ${MID}/halloc.c
-	@echo sl22 making ${OUT}/halloc.o from ${MID}/halloc.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/halloc.c )
-
-${DOCINT}/halloc.c.pdf: ${IN}/halloc.c.pamphlet 
-	@echo sl23 making ${DOCINT}/halloc.c.pdf from ${IN}/halloc.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/halloc.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} halloc.c.pamphlet ; \
-	rm -f ${DOCINT}/halloc.c.pamphlet ; \
-	rm -f ${DOCINT}/halloc.c.tex ; \
-	rm -f ${DOCINT}/halloc.c )
-
-${DOCMNT}/halloc.c.pdf: ${DOCINT}/halloc.c.pdf
-	@echo sl24 making ${DOCMNT}/halloc.c.pdf from ${DOCINT}/halloc.c.pdf
-	@cp ${DOCINT}/halloc.c.pdf ${DOCMNT}/halloc.c.pdf 
-
-\end{chunk}
-\subsection{hash.c \cite{6}}
-This a a string-based hash table that is used both in the graph
-and hyper functions. It is included here because we need it built
-earlier so the graph and hyper routines can refer to it.
-\begin{chunk}{hash}
-${MID}/hash.c: ${IN}/hash.c.pamphlet
-	@echo sl25 making ${MID}/hash.c from ${IN}/hash.c.pamphlet
-	@${BOOKS}/tanglec hash.c.pamphlet >${MID}/hash.c
-
-${OUT}/hash.o: ${MID}/hash.c
-	@echo sl26 making ${OUT}/hash.o from ${MID}/hash.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/hash.c )
-
-${DOCINT}/hash.c.pdf: ${IN}/hash.c.pamphlet 
-	@echo sl27 making ${DOCINT}/hash.c.pdf from ${IN}/hash.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/hash.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} hash.c.pamphlet ; \
-	rm -f ${DOCINT}/hash.c.pamphlet ; \
-	rm -f ${DOCINT}/hash.c.tex ; \
-	rm -f ${DOCINT}/hash.c )
-
-${DOCMNT}/hash.c.pdf: ${DOCINT}/hash.c.pdf
-	@echo sl28 making ${DOCMNT}/hash.c.pdf from ${DOCINT}/hash.c.pdf
-	@cp ${DOCINT}/hash.c.pdf ${DOCMNT}/hash.c.pdf 
-
-\end{chunk}
-\subsection{openpty.c \cite{7}}
-\begin{chunk}{openpty}
-${MID}/openpty.c: ${IN}/openpty.c.pamphlet
-	@echo sl29 making ${MID}/openpty.c from ${IN}/openpty.c.pamphlet
-	@${BOOKS}/tanglec openpty.c.pamphlet >${MID}/openpty.c
-
-${OUT}/openpty.o: ${MID}/openpty.c
-	@echo sl30 making ${OUT}/openpty.o from ${MID}/openpty.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/openpty.c )
-
-${DOCINT}/openpty.c.pdf: ${IN}/openpty.c.pamphlet 
-	@echo sl31 making ${DOCINT}/openpty.c.pdf from ${IN}/openpty.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/openpty.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} openpty.c.pamphlet ; \
-	rm -f ${DOCINT}/openpty.c.pamphlet ; \
-	rm -f ${DOCINT}/openpty.c.tex ; \
-	rm -f ${DOCINT}/openpty.c )
-
-${DOCMNT}/openpty.c.pdf: ${DOCINT}/openpty.c.pdf
-	@echo sl32 making ${DOCMNT}/openpty.c.pdf from ${DOCINT}/openpty.c.pdf
-	@cp ${DOCINT}/openpty.c.pdf ${DOCMNT}/openpty.c.pdf 
-
-\end{chunk}
-\subsection{pixmap.c \cite{8}}
-\begin{chunk}{pixmap}
-${MID}/pixmap.c: ${IN}/pixmap.c.pamphlet
-	@echo sl33 making ${MID}/pixmap.c from ${IN}/pixmap.c.pamphlet
-	@${BOOKS}/tanglec pixmap.c.pamphlet >${MID}/pixmap.c
-
-${OUT}/pixmap.o: ${MID}/pixmap.c
-	@echo sl34 making ${OUT}/pixmap.o from ${MID}/pixmap.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/pixmap.c )
-
-${DOCINT}/pixmap.c.pdf: ${IN}/pixmap.c.pamphlet 
-	@echo sl35 making ${DOCINT}/pixmap.c.pdf from ${IN}/pixmap.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/pixmap.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} pixmap.c.pamphlet ; \
-	rm -f ${DOCINT}/pixmap.c.pamphlet ; \
-	rm -f ${DOCINT}/pixmap.c.tex ; \
-	rm -f ${DOCINT}/pixmap.c )
-
-${DOCMNT}/pixmap.c.pdf: ${DOCINT}/pixmap.c.pdf
-	@echo sl36 making ${DOCMNT}/pixmap.c.pdf from ${DOCINT}/pixmap.c.pdf
-	@cp ${DOCINT}/pixmap.c.pdf ${DOCMNT}/pixmap.c.pdf 
-
-\end{chunk}
-\subsection{prt.c \cite{9}}
-\begin{chunk}{prt}
-${MID}/prt.c: ${IN}/prt.c.pamphlet
-	@echo sl37 making ${MID}/prt.c from ${IN}/prt.c.pamphlet
-	@${BOOKS}/tanglec prt.c.pamphlet >${MID}/prt.c
-
-${OUT}/prt.o: ${MID}/prt.c
-	@echo sl38 making ${OUT}/prt.o from ${MID}/prt.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/prt.c )
-
-${DOCINT}/prt.c.pdf: ${IN}/prt.c.pamphlet 
-	@echo sl39 making ${DOCINT}/prt.c.pdf from ${IN}/prt.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/prt.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} prt.c.pamphlet ; \
-	rm -f ${DOCINT}/prt.c.pamphlet ; \
-	rm -f ${DOCINT}/prt.c.tex ; \
-	rm -f ${DOCINT}/prt.c )
-
-${DOCMNT}/prt.c.pdf: ${DOCINT}/prt.c.pdf
-	@echo sl40 making ${DOCMNT}/prt.c.pdf from ${DOCINT}/prt.c.pdf
-	@cp ${DOCINT}/prt.c.pdf ${DOCMNT}/prt.c.pdf 
-
-\end{chunk}
-\subsection{sockio-c.c \cite{10}}
-The sockio-c file contains socket primitives used by Axiom.
-They must be linked into and visible from the inferior lisp.
-In GCL this link happens thru setting a shell variable called
-{\bf EXTRAS} in the {\bf h/386-linux.defs} file. This file
-gets included as part of the final system build of GCL.
-
-\begin{chunk}{sockio-c}
-${MID}/sockio-c.c: ${IN}/sockio-c.c.pamphlet
-	@echo sl41 making ${MID}/sockio-c.c from ${IN}/sockio-c.c.pamphlet
-	@${BOOKS}/tanglec sockio-c.c.pamphlet >${MID}/sockio-c.c
-
-${OUT}/sockio-c.o: ${MID}/sockio-c.c
-	@echo sl42 making ${OUT}/sockio-c.o from ${MID}/sockio-c.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/sockio-c.c )
-
-${DOCINT}/sockio-c.c.pdf: ${IN}/sockio-c.c.pamphlet 
-	@echo sl43 making ${DOCINT}/sockio-c.c.pdf from ${IN}/sockio-c.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/sockio-c.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} sockio-c.c.pamphlet ; \
-	rm -f ${DOCINT}/sockio-c.c.pamphlet ; \
-	rm -f ${DOCINT}/sockio-c.c.tex ; \
-	rm -f ${DOCINT}/sockio-c.c )
-
-${DOCMNT}/sockio-c.c.pdf: ${DOCINT}/sockio-c.c.pdf
-	@echo sl44 making ${DOCMNT}/sockio-c.c.pdf from ${DOCINT}/sockio-c.c.pdf
-	@cp ${DOCINT}/sockio-c.c.pdf ${DOCMNT}/sockio-c.c.pdf 
-
-\end{chunk}
-\subsection{spadcolors.c \cite{11}}
-\begin{chunk}{spadcolors}
-${MID}/spadcolors.c: ${IN}/spadcolors.c.pamphlet
-	@echo sl45 making ${MID}/spadcolors.c from ${IN}/spadcolors.c.pamphlet
-	@${BOOKS}/tanglec spadcolors.c.pamphlet >${MID}/spadcolors.c
-
-${OUT}/spadcolors.o: ${MID}/spadcolors.c
-	@echo sl46 making ${OUT}/spadcolors.o from ${MID}/spadcolors.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/spadcolors.c )
-
-${DOCINT}/spadcolors.c.pdf: ${IN}/spadcolors.c.pamphlet 
-	@echo sl47 making ${DOCINT}/spadcolors.c.pdf from \
-          ${IN}/spadcolors.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/spadcolors.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} spadcolors.c.pamphlet ; \
-	rm -f ${DOCINT}/spadcolors.c.pamphlet ; \
-	rm -f ${DOCINT}/spadcolors.c.tex ; \
-	rm -f ${DOCINT}/spadcolors.c )
-
-${DOCMNT}/spadcolors.c.pdf: ${DOCINT}/spadcolors.c.pdf
-	@echo sl48 making ${DOCMNT}/spadcolors.c.pdf from ${DOCINT}/spadcolors.c.pdf
-	@cp ${DOCINT}/spadcolors.c.pdf ${DOCMNT}/spadcolors.c.pdf
-
-\end{chunk}
-\subsection{util.c \cite{12}}
-\begin{chunk}{util}
-${MID}/util.c: ${IN}/util.c.pamphlet
-	@echo sl49 making ${MID}/util.c from ${IN}/util.c.pamphlet
-	@${BOOKS}/tanglec util.c.pamphlet >${MID}/util.c
-
-${OUT}/util.o: ${MID}/util.c
-	@echo sl50 making ${OUT}/util.o from ${MID}/util.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/util.c )
-
-${DOCINT}/util.c.pdf: ${IN}/util.c.pamphlet 
-	@echo sl51 making ${DOCINT}/util.c.pdf from ${IN}/util.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/util.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} util.c.pamphlet ; \
-	rm -f ${DOCINT}/util.c.pamphlet ; \
-	rm -f ${DOCINT}/util.c.tex ; \
-	rm -f ${DOCINT}/util.c )
-
-${DOCMNT}/util.c.pdf: ${DOCINT}/util.c.pdf
-	@echo sl52 making ${DOCMNT}/util.c.pdf from ${DOCINT}/util.c.pdf
-	@cp ${DOCINT}/util.c.pdf ${DOCMNT}/util.c.pdf
-
-\end{chunk}
-\subsection{wct.c \cite{13}}
-\begin{chunk}{wct}
-${MID}/wct.c: ${IN}/wct.c.pamphlet
-	@echo sl53 making ${MID}/wct.c from ${IN}/wct.c.pamphlet
-	@${BOOKS}/tanglec wct.c.pamphlet >${MID}/wct.c
-
-${OUT}/wct.o: ${MID}/wct.c
-	@echo sl54 making ${OUT}/wct.o from ${MID}/wct.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/wct.c )
-
-${DOCINT}/wct.c.pdf: ${IN}/wct.c.pamphlet 
-	@echo sl55 making ${DOCINT}/wct.c.pdf from ${IN}/wct.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/wct.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} wct.c.pamphlet ; \
-	rm -f ${DOCINT}/wct.c.pamphlet ; \
-	rm -f ${DOCINT}/wct.c.tex ; \
-	rm -f ${DOCINT}/wct.c )
-
-${DOCMNT}/wct.c.pdf: ${DOCINT}/wct.c.pdf
-	@echo sl56 making ${DOCMNT}/wct.c.pdf from ${DOCINT}/wct.c.pdf
-	@cp ${DOCINT}/wct.c.pdf ${DOCMNT}/wct.c.pdf
-
-\end{chunk}
-\subsection{xdither.c \cite{14}}
-\begin{chunk}{xdither}
-${MID}/xdither.c: ${IN}/xdither.c.pamphlet
-	@echo sl57 making ${MID}/xdither.c from ${IN}/xdither.c.pamphlet
-	@${BOOKS}/tanglec xdither.c.pamphlet >${MID}/xdither.c
-
-${OUT}/xdither.o: ${MID}/xdither.c
-	@echo sl58 making ${OUT}/xdither.o from ${MID}/xdither.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/xdither.c )
-
-${DOCINT}/xdither.c.pdf: ${IN}/xdither.c.pamphlet 
-	@echo sl59 making ${DOCINT}/xdither.c.pdf from ${IN}/xdither.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/xdither.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} xdither.c.pamphlet ; \
-	rm -f ${DOCINT}/xdither.c.pamphlet ; \
-	rm -f ${DOCINT}/xdither.c.tex ; \
-	rm -f ${DOCINT}/xdither.c )
-
-${DOCMNT}/xdither.c.pdf: ${DOCINT}/xdither.c.pdf
-	@echo sl60 making ${DOCMNT}/xdither.c.pdf from ${DOCINT}/xdither.c.pdf
-	@cp ${DOCINT}/xdither.c.pdf ${DOCMNT}/xdither.c.pdf
-
-\end{chunk}
-\subsection{xshade.c \cite{15}}
-\begin{chunk}{xshade}
-${MID}/xshade.c: ${IN}/xshade.c.pamphlet
-	@echo sl61 making ${MID}/xshade.c from ${IN}/xshade.c.pamphlet
-	@${BOOKS}/tanglec xshade.c.pamphlet >${MID}/xshade.c
-
-${OUT}/xshade.o: ${MID}/xshade.c
-	@echo sl62 making ${OUT}/xshade.o from ${MID}/xshade.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/xshade.c )
-
-${DOCINT}/xshade.c.pdf: ${IN}/xshade.c.pamphlet 
-	@echo sl63 making ${DOCINT}/xshade.c.pdf from ${IN}/xshade.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/xshade.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} xshade.c.pamphlet ; \
-	rm -f ${DOCINT}/xshade.c.pamphlet ; \
-	rm -f ${DOCINT}/xshade.c.tex ; \
-	rm -f ${DOCINT}/xshade.c )
-
-${DOCMNT}/xshade.c.pdf: ${DOCINT}/xshade.c.pdf
-	@echo sl64 making ${DOCMNT}/xshade.c.pdf from ${DOCINT}/xshade.c.pdf
-	@cp ${DOCINT}/xshade.c.pdf ${DOCMNT}/xshade.c.pdf
-
-\end{chunk}
-\subsection{xspadfill.c \cite{16}}
-\begin{chunk}{xspadfill}
-${MID}/xspadfill.c: ${IN}/xspadfill.c.pamphlet
-	@echo sl65 making ${MID}/xspadfill.c from ${IN}/xspadfill.c.pamphlet
-	@${BOOKS}/tanglec xspadfill.c.pamphlet >${MID}/xspadfill.c
-
-${OUT}/xspadfill.o: ${MID}/xspadfill.c
-	@echo sl66 making ${OUT}/xspadfill.o from ${MID}/xspadfill.c
-	@( cd ${OUT} ; \
-	${CC} ${CCF} -c -I${INC} ${MID}/xspadfill.c )
-
-${DOCINT}/xspadfill.c.pdf: ${IN}/xspadfill.c.pamphlet 
-	@echo sl67 making ${DOCINT}/xspadfill.c.pdf from ${IN}/xspadfill.c.pamphlet
-	@(cd ${DOCINT} ; \
-	cp ${IN}/xspadfill.c.pamphlet ${DOCINT} ; \
-	${EXTRACT} xspadfill.c.pamphlet ; \
-	rm -f ${DOCINT}/xspadfill.c.pamphlet ; \
-	rm -f ${DOCINT}/xspadfill.c.tex ; \
-	rm -f ${DOCINT}/xspadfill.c )
-
-${DOCMNT}/xspadfill.c.pdf: ${DOCINT}/xspadfill.c.pdf
-	@echo sl68 making ${DOCMNT}/xspadfill.c.pdf from ${DOCINT}/xspadfill.c.pdf
-	@cp ${DOCINT}/xspadfill.c.pdf ${DOCMNT}/xspadfill.c.pdf
-
-\end{chunk}
-\section{The document stanza}
-\begin{chunk}{document}
-document: ${DOCFILES}
-	@echo sl69 documenting ${IN}
-
-\end{chunk}
-\section{The clean stanza}
-\begin{chunk}{clean}
-clean:
-	@echo sl70 cleaning ${IN}
-	@rm -rf ${MID} ${OUT} ${DOCINT} ${DOCMNT}
-	@rm -f Makefile Makefile.pdf
-
-\end{chunk}
-\subsection{Makefile documentation}
-\begin{chunk}{Makefile.pdf}
-${DOCMNT}/Makefile.pdf: ${IN}/Makefile.pdf
-	@echo sl71 making ${DOCMNT}/Makefile.pdf from ${IN}/Makefile.pdf
-	@cp ${IN}/Makefile.pdf ${DOCMNT}/Makefile.pdf
-
-\end{chunk}
-\begin{chunk}{*}
-\getchunk{environment}
-
-all: announce ${OUT}/libspad.a ${OTHER} ${DOCFILES}
-	@echo sl72 finished making ${IN}
-
-announce:
-	@ echo ======================================
-	@ echo src/lib BUILDING LIB FILES
-	@ echo ======================================
-
-${OUT}/libspad.a: ${AR} 
-	@echo sl73 making ${OUT}/libspad.a
-	@(cd ${OUT} ; \
-	ar ru ${OUT}/libspad.a ${AR} ; \
-	${RANLIB} ${OBJ}/${SYS}/lib/libspad.a )
-
-\getchunk{Makefile.pdf}
-\getchunk{bsdsignal}
-\getchunk{cfuns-c}
-\getchunk{cursor}
-\getchunk{edin}
-\getchunk{fnctkey}
-\getchunk{halloc}
-\getchunk{hash}
-\getchunk{openpty}
-\getchunk{pixmap}
-\getchunk{prt}
-\getchunk{sockio-c}
-\getchunk{spadcolors}
-\getchunk{util}
-\getchunk{wct}
-\getchunk{xdither}
-\getchunk{xshade}
-\getchunk{xspadfill}
-\getchunk{document}
-\getchunk{clean}
-\end{chunk}
-
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} {\$SPAD/src/lib/bsdssignal.c.pamphlet}
-\bibitem{2} {\$SPAD/src/lib/cfuns-c.c.pamphlet}
-\bibitem{3} {\$SPAD/src/lib/cursor.c.pamphlet}
-\bibitem{4} {\$SPAD/src/lib/edin.c.pamphlet}
-\bibitem{5} {\$SPAD/src/lib/fnct-key.c.pamphlet}
-\bibitem{6} {\$SPAD/src/lib/halloc.c.pamphlet}
-\bibitem{7} {\$SPAD/src/lib/openpty.c.pamphlet}
-\bibitem{8} {\$SPAD/src/lib/pixmap.c.pamphlet}
-\bibitem{9} {\$SPAD/src/lib/prt.c.pamphlet}
-\bibitem{10} {\$SPAD/src/lib/sockio-c.c.pamphlet}
-\bibitem{11} {\$SPAD/src/lib/spadcolors.c.pamphlet}
-\bibitem{12} {\$SPAD/src/lib/util.c.pamphlet}
-\bibitem{13} {\$SPAD/src/lib/wct.c.pamphlet}
-\bibitem{14} {\$SPAD/src/lib/xdither.c.pamphlet}
-\bibitem{15} {\$SPAD/src/lib/xshade.c.pamphlet}
-\bibitem{16} {\$SPAD/src/lib/xspadfill.c.pamphlet}
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/axiom.xpm.pamphlet b/src/lib/axiom.xpm.pamphlet
deleted file mode 100644
index bb78e3a..0000000
--- a/src/lib/axiom.xpm.pamphlet
+++ /dev/null
@@ -1,163 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib axiom.xpm}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-<<*>>=
-/* XPM */
-static char ourcolormap[] = {
-/* width height ncolors chars_per_pixel */
-"137 1 137 2",
-/* colors */
-"`` c #000000",
-"`a c #6FE0E0",
-"`b c #086025",
-"`c c #E09C6F",
-"`d c #606008",
-"`e c #C4EFE1",
-"`f c #E0866F",
-"`g c #341C93",
-"`h c #604E08",
-"`i c #E07A6F",
-"`j c #604608",
-"`k c #BFBF30",
-"`l c #C96FE0",
-"`m c #603408",
-"`n c #6F9CE0",
-"`o c #602208",
-"`p c #601A08",
-"`q c #6F86E0",
-"`r c #3D0860",
-"`s c #600808",
-"`t c #93581C",
-"`u c #30BFBF",
-"`v c #934C1C",
-"`w c #7B1C93",
-"`x c #BF7730",
-"`y c #083D60",
-"`z c #4E0860",
-"a` c #93401C",
-"aa c #BF6930",
-"ab c #082B60",
-"ac c #93341C",
-"ad c #BF5B30",
-"ae c #93281C",
-"af c #BF4D30",
-"ag c #931C1C",
-"ah c #436008",
-"ai c #BF3F30",
-"aj c #3069BF",
-"ak c #30BF30",
-"al c #95E06F",
-"am c #304DBF",
-"an c #1C9344",
-"ao c #BAE06F",
-"ap c #44931C",
-"aq c #1C931C",
-"ar c #EFE6C4",
-"as c #EFE2C4",
-"at c #DEC4EF",
-"au c #EFDEC4",
-"av c #EFCCC4",
-"aw c #EFC8C4",
-"ax c #EFC4C4",
-"ay c #30BF8F",
-"az c #EFC4EF",
-"b` c #60BF30",
-"ba c #1A0860",
-"bb c #1C4C93",
-"bc c #2B0860",
-"bd c #C4E6EF",
-"be c #C4DEEF",
-"bf c #1C3493",
-"bg c #E0D56F",
-"bh c #C4CCEF",
-"bi c #1C1C93",
-"bj c #C4C4EF",
-"bk c #E0C96F",
-"bl c #086043",
-"bm c #E0B36F",
-"bn c #D5C4EF",
-"bo c #E0A76F",
-"bp c #E0916F",
-"bq c #605708",
-"br c #6FC9E0",
-"bs c #E6C4EF",
-"bt c #631C93",
-"bu c #6FB3E0",
-"bv c #E06F6F",
-"bw c #93931C",
-"bx c #603D08",
-"by c #866FE0",
-"bz c #6FE06F",
-"c` c #93871C",
-"ca c #BFB030",
-"cb c #602B08",
-"cc c #937B1C",
-"cd c #6B931C",
-"ce c #BFA230",
-"cf c #936F1C",
-"cg c #086060",
-"ch c #4D30BF",
-"ci c #BF9430",
-"cj c #601108",
-"ck c #93631C",
-"cl c #8630BF",
-"cm c #084E60",
-"cn c #BF30BF",
-"co c #BF8630",
-"cp c #4C1C93",
-"cq c #6F6FE0",
-"cr c #CCC4EF",
-"cs c #30A2BF",
-"ct c #081A60",
-"cu c #3086BF",
-"cv c #080860",
-"cw c #BF3030",
-"cx c #256008",
-"cy c #931C93",
-"cz c #E1EFC4",
-"d` c #6FE0BA",
-"da c #3030BF",
-"db c #B36FE0",
-"dc c #6930BF",
-"dd c #FFFFFF",
-"de c #A230BF",
-"df c #C4EFD2",
-"dg c #EFEFC4",
-"dh c #EFEBC4",
-"di c #600860",
-"dj c #1C9393",
-"dk c #6FE095",
-"dl c #9C6FE0",
-"dm c #EFD9C4",
-"dn c #EFD5C4",
-"do c #1C7B93",
-"dp c #EFD1C4",
-"dq c #1C936B",
-"dr c #1C6393",
-"ds c #086008",
-"dt c #8FBF30",
-"du c #C4EFC4",
-"dv c #C4EFEF",
-"dw c #E0E06F",
-"dx c #C4D5EF",
-"dy c #30BF60",
-"dz c #E0BE6F",
-"e` c #E06FE0",
-"ea c #D2EFC4",
-/* pixels */
-"`sagcwbvaxcjaeai`iaw`pacaf`fav`oa`adbpdpcb`vaa`cdn`m`t`xbodmbxckcobmau`jcfcidzas`hcccebkarbqc`cabgdh`dbw`kdwdgahcddtaoczcxapb`aleadsaqakbzdu`bandydkdfbldqayd``ecgdj`u`advcmdocsbrbd`ydrcububeabbbaj`ndxctbfam`qbhcvbidacqbjba`gchbycrbccpdcdlbn`rbtcldbat`z`wde`lbsdicycne`az``dd"
-};
-@
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/bsdsignal.c.pamphlet b/src/lib/bsdsignal.c.pamphlet
deleted file mode 100644
index 056cb47..0000000
--- a/src/lib/bsdsignal.c.pamphlet
+++ /dev/null
@@ -1,335 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib bsdsignal.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\newpage
-\section{Executive Overview}
-\section{Signals}
-
-The system defines a set of signals that may be delivered to a
-process. Signal delivery resembles the occurrence of a hardware
-interrupt: the signal is normally blocked from further occurrence, the
-current process context is saved, and a new one is built. A process
-may specify a {\sl handler} to which a signal is delivered, or specify
-that a signal is to be {\sl ignored}. A process may also specify that
-a default action is to be taken by the system when a signal occurs. A
-signal may also be {\sl blocked}, in which case its delivery is
-postponed until it is {\sl unblocked}. The action to be taken on
-delivery is determined at the time of delivery. Normally, signal
-handlers execute on the current stack of the process. This may be
-changed, on a per-handler basis, so that signals are taken on a
-special {\sl signal stack}.
-
-Signal routines normally execute with the signal that caused their invocation 
-{\sl blocked}, but other signals may yet occur. A global {\sl signal mask} 
-defines the set of signals currently blocked from delivery to a process. 
-The signal mask for a process is initialized from that of its parent 
-(normally empty). It may be changed with a {\bf sigprocmask(2)} call, or 
-when a signal is delivered to the process.
-
-When a signal condition arises for a process, the signal is added to a
-set of signals pending for the process. If the signal is not currently
-{\sl blocked} by the process then it is delivered to the
-process. Signals may be delivered any time a process enters the
-operating system (e.g., during a system call, page fault or trap, or
-clock interrupt). If muliple signals are ready to be delivered at the
-same time, any signals that could be caused by traps are delivered
-first. Additional signals may be processed at the same time, with each
-appearing to interrupt the handlers for the previous signals before
-their first instructions. The set of pending signals is retuned by the
-{\bf sigpending(2)} system call. When a caught signal is delivered,
-the current state of the process is saved, a new signal mask is
-calculated (as described below), and the signal handler is
-invoked. The call to the handler is arranged so that if the signal
-handling routine returns normally the process will resume execution in
-the context from before the signal's delivery. If the process wishes
-to resume in a different context, then it must arrange to restore the
-previous context itself.
-
-When a signal is delivered to a proces a new signal mask is installed
-for the duration of the process's signal handler (or until a {\bf
-sigprocmask(2)} system call is made). This mask is formed by taking
-the union of the current signal mask set, the signal to be delivered,
-and the signal mask associated with the handler to be invoked.
-
-The {\bf sigaction()} system call assigns an action for a signal
-specified by {\sl sig}. If {\sl act} is non-zero, it specifies an
-action (SIG\_DFL, SIG\_IGN, or a handler routine) and mask to be used
-when delivering the specified signal.  If {\sl oact} is non-zero, the
-previous handling information for the signal is returned to the user.
-
-Once a signal handler is installed, it normally remains installed
-until another {\bf sigaction()} system call is made, or an {\sl
-execve(2)} is performed. A signal-specific default action may be reset
-by setting {\sl sa\_handler} to SIG\_DFL. The defaults are process
-termination, possibly with core dump; no action; stopping the process;
-or continuing the process. See the signal list below for each signal's
-default action. If {\sl sa\_handler} is SIG\_DFL, the default action
-for the signal is to discard the signal, and if a signal is pending,
-the pending signal is discarded even if the signal is masked. If {\sl
-sa\_handler} is set to SIG\_IGN current and pending instances of the
-signal are ignored and discarded.
-
-Options may be specified by setting {\sl sa\_flags}. 
-The meaning of the various bits is as follows:
-
-\begin{itemize}
-\item {\bf SA\_NOCLDSTOP} If this bit is set when installing a catching 
-function for the SIGCHLD signal, the SIGCHLD signal will  be generated 
-only when a child process exits, not when a child process stops.
-\item {\bf SA\_NOCLDWAIT}
-If this bit is set when calling {\sl sigaction()} for the
-SIGCHLD signal, the system will not create zombie processes
-when children of the calling process exit. If the calling
-process subsequently issues a {\sl wait()} (or equivalent),
-it blocks until all of the calling process's child processes
-terminate, and then returns a value of -1 with errno set to
-ECHILD.
-\item {\bf SA\_ONSTACK} If this bit is set, the system will deliver the 
-signal to the process on a {\sl signal stack}, specified with
-{\bf sigaltstack(2)}.
-\item {\bf SA\_NODEFER} If this bit is set, further occurrences of the 
-delivered signal are not masked during the execution of the handler.
-\item {\bf SA\_RESETHAND} If this bit is set, the handler is reset 
-to SIG\_DFL at the moment the signal is delivered.
-\item {\bf SA\_RESTART} See the paragraph below
-\item {SA\_SIGINFO} If this bit is set, the handler function is assumed to 
-be pointed to by the sa\_sigaction member of struct sigaction
-and should match the prototype shown above or as below in
-EXAMPLES. This bit should not be set when assigning SIG\_DFL
-or SIG\_IGN
-\end{itemize}
-If a signal is caught during the system calls listed below, the call may be 
-forced to terminate with the error EINTR, the call may return with a data 
-transfer shorter than requested, or the call may be restarted. Restart of 
-pending calls is requested by setting the SA\_RESTART bit in {\sl sa\_flags}. 
-The affected system calls include {\bf open(2)}, {\bf read(2)}, {\bf write(2)}, 
-{\bf sendto(2)}, {\bf recvfrom(2)}, {\bf sendmsg(2)} and {\bf recvmsg(2)} 
-on a communications channel or a slow device (such as a terminal, but not a 
-regular file) and during a {\bf wait(2)} or {\bf ioctl(2)}. However, calls 
-that have already committed are not restarted, but instead return a partial 
-success (for example, a short read count).
-
-After a {\bf fork(2)} or {\bf vfork(2)} all signals, the signal mask, the 
-signal stack, and the restart/interrupt flags are inherited by the child.
-
-The {\bf execve(2)} system call reinstates the default action for all signals 
-which were caught and resets all signals to be caught on the user stack. 
-Ignored signals remain ignored; the signal mask remains the same; signals 
-that restart pending system calls continue to do so.
-
-The following is a list of all signals with names in the include file
-{\sl $<$signal.h$>$}:
-
-\begin{tabular}{lll}
-{\bf NAME} & {\bf Default Action} & Description\\
-SIGHUP     & terminate process    & terminal line hangup\\
-SIGINT     & terminate process    & interrupt program\\
-SIGQUIT    & create core image    & quit program\\
-SIGILL     & create core image    & illegal instruction\\
-SIGTRAP    & create core image    & trace trap\\
-SIGABRT    & create core image    & {\bf abort(3)} call (formerly SIGIOT)\\
-SIGEMT     & create core image    & emulate instruction executed\\
-SIGFPE     & create core image    & floating-point exception\\
-SIGKILL    & terminate process    & kill program\\
-SIGBUS     & create core image    & bus error\\
-SIGSEGV    & create core image    & segmentation violation\\
-SIGSYS     & create core image    & non-existent system call invoked\\
-SIGPIPE    & terminate process    & write on a pipe with no reader\\
-SIGALRM    & terminate process    & real-time timer expired\\
-SIGTERM    & terminate process    & software termination signal\\
-SIGURG     & discard signal       & urgent condition present on socket\\
-SIGSTOP    & stop process         & stop (cannot be caught or ignored)\\
-SIGSTP     & stop process         & keyboard generated stop signal\\
-SIGCONT    & discard signal       & continue after stop\\
-SIGCHLD    & discard signal       & child status has changed\\
-SIGTTIN    & stop process         & background read attempted from \\
-           &                      & control terminal\\
-SIGTTOU    & stop process         & background write attempted from\\
-           &                      & control terminal\\
-SIGIO      & discard signal       & I/O possible on descriptor fcntl(2)\\
-SIGXCPU    & terminate process    & cpu limit exceeded setrlimit(2)\\
-SIGXFSZ    & terminate process    & filesize exceeded setrlimit(2)\\
-SIGVTALRM  & terminate process    & virtual time alarm setitimer(2)\\
-SIGPROF    & terminate process    & profiling timer alarm setitimer(2)\\
-SIGWINCH   & discard signal       & Window size change\\
-SIGINFO    & discard signal       & status request from keyboard\\
-SIGUSR1    & terminate process    & User defined signal 1\\
-SIGUSR2    & terminate process    & User defined signal 2
-\end{tabular}
-
-The {\sl sigaction()} function returns the value 0 if successful; otherwise 
-the value -1 is returned and the global variable {\sl errno} is set to indicate 
-the error.
-
-Signal handlers should have either the ANSI C prototype:
-\begin{verbatim}
-  void handler(int);
-\end{verbatim}
-or the POSIX SA\_SIGINFO prototype:
-\begin{verbatim}
-  void handler(int, siginfo_t *info, ucontext_t *uap);
-\end{verbatim}
-
-The handler function should match the SA\_SIGINFO prototype 
-when the SA\_SIGINFO 
-bit is set in flags. It then should be pointed to by the sa\_sigaction member 
-of struct sigaction. Note that you should not assign SIG\_DFL or SIG\_IGN this way.
-
-If the SA\_SIGINFO flag is not set, the handler function should match either 
-the ANSI C or traditional BSD prototype and be pointed to by the sa\_handler 
-member of struct sigaction. In practice, FreeBSD always sends the three 
-arguments of the latter and since the ANSI C prototype is a subset, both 
-will work. The sa\_handler member declaration in FreeBSD include files is 
-that of ANSI C (as required by POSIX), so a function pointer of a BSD-style 
-function needs to be casted to compile without warning. The traditional BSD 
-style is not portable and since its capabilities are a full subset of a 
-SA\_SIGNFO handler its use is deprecated.
-
-The {\sl sig} argument is the signal number, one of the SIG\ldots values from 
-{\sl <signal.h>}.
-
-The {\sl code} argument of the BSD-style handler and the si\_code member of the
-info argument to a SA\_SIGINFO handler contain a numeric code explaining the
-cause of the signal, usually on of the SI\_\ldots values from {\sl <sys/signal.h>}
-or codes specific to a signal, i.e. one of the FPE\_\ldots values for SIGFPE.
-
-The {\sl uap} argument to a POSIX SA\_SIGINFO handler points to an instance of 
-ucontext\_t.
-
-The {\bf sigaction()} system call will fail and no new signal handler will be
-installed if one of the following occurs:
-\begin{itemize}
-\item {\bf [EFAULT]} Either {\sl act} or {\sl oact} points to memory that 
-is not a valid part of the process address space
-\item {\bf [EINVAL]} The {\sl sig} argument is not a valid signal number
-\item {\bf [EINVAL]} An attempt is made to ignore or supply a handler 
-for SIGKILL or SIGSTOP
-\end{itemize}
-\section{MAC OSX and BSD platform change}
-\begin{chunk}{*}
-
-#include "bsdsignal.h"
-
-\end{chunk}
-
-The MACOSX platform is broken because no matter what you do it seems to
-include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
-systems these files include themselves which causes an infinite regression
-of includes that fails. GCC gracefully steps over that problem but the
-build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
-of files are badly broken with respect to the [[/usr/include]] versions.
-
-\begin{chunk}{*}
-#if defined(MACOSXplatform)
-#include "/usr/include/signal.h"
-#else
-#include <signal.h> 
-#endif
-
-#include "bsdsignal.h1"
-
-
-SignalHandlerFunc
-bsdSignal(int sig,SignalHandlerFunc action,int restartSystemCall)
-{
-#ifndef MSYSplatform
-
-  struct sigaction in,out;
-  in.sa_handler = action;
-  /* handler is reinstalled - calls are restarted if restartSystemCall */
-\end{chunk}
-
-We needed to change [[SIGCLD]] to [[SIGCHLD]] for the [[MAC OSX]] platform
-and we need to create a new platform variable. This change is made to 
-propogate that platform variable.
-
-\begin{chunk}{*}
-#if defined(LINUXplatform)
- if(restartSystemCall) in.sa_flags = SA_RESTART;
-  else in.sa_flags = 0;
-#elif defined (ALPHAplatform)
- if(restartSystemCall) in.sa_flags = SA_RESTART;
-  else in.sa_flags = 0;
-#elif defined(RIOSplatform) 
- if(restartSystemCall) in.sa_flags = SA_RESTART;
-  else in.sa_flags = 0;
-#elif defined(SUN4OS5platform) 
- if(restartSystemCall) in.sa_flags = SA_RESTART;
-  else in.sa_flags = 0;
-#elif defined(SGIplatform) 
- if(restartSystemCall) in.sa_flags = SA_RESTART;
-  else in.sa_flags = 0;
-#elif defined(HP10platform) 
- if(restartSystemCall) in.sa_flags = SA_RESTART;
-  else in.sa_flags = 0;
-#elif defined(MACOSXplatform) 
- if(restartSystemCall) in.sa_flags = SA_RESTART;
-  else in.sa_flags = 0;
-#elif defined(BSDplatform) 
- if(restartSystemCall) in.sa_flags = SA_RESTART;
-  else in.sa_flags = 0;
-#elif defined(SUNplatform)
-  if (restartSystemCall) in.sa_flags = 0;
-  else in.sa_flags = SA_INTERRUPT;
-#elif defined(HP9platform)
-  in.sa_flags = 0; 
-#else
-  in.sa_flags = 0; 
-#endif
-  
-  return (sigaction(sig, &in, &out) ? (SignalHandlerFunc) -1 : 
-	  (SignalHandlerFunc) out.sa_handler);
-#else /* MSYSplatform */
-  return (SignalHandlerFunc) -1;
-#endif /* MSYSplatform */
-
-}
-
-\end{chunk}
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\newpage
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/cfuns-c.c.pamphlet b/src/lib/cfuns-c.c.pamphlet
deleted file mode 100644
index 486fe09..0000000
--- a/src/lib/cfuns-c.c.pamphlet
+++ /dev/null
@@ -1,238 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib cfuns-c.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\begin{chunk}{*}
-
-#include <stdio.h>
-\end{chunk}
-
-The MACOSX platform is broken because no matter what you do it seems to
-include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
-systems these files include themselves which causes an infinite regression
-of includes that fails. GCC gracefully steps over that problem but the
-build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
-of files are badly broken with respect to the [[/usr/include]] versions.
-
-\begin{chunk}{*}
-
-#if defined(MACOSXplatform)
-#include "/usr/include/unistd.h"
-#else
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-#include <string.h>
-#if !defined(BSDplatform)
-#include <malloc.h>
-#endif
-#include <sys/types.h>
-#include <sys/stat.h>
-
-#include "cfuns-c.h1"
-
-\end{chunk}
-The {\tt addtopath} function is used in {\tt interp/i-toplev.boot} 
-as part of the {\tt start} function.
-\begin{chunk}{*}
-
-int addtopath(char *dir) {
-    char *path, *newpath;
-    path = getenv("PATH");
-    if (path == NULL)
-        return -1;
-    newpath = (char *) 
-       malloc(1 + strlen(path) + strlen(dir) + strlen("PATH=:"));
-    if (newpath == NULL)
-        return -1;
-    sprintf(newpath, "PATH=%s:%s", path, dir);
-    return putenv(newpath);
-}
-
-\end{chunk}
-
-Test whether the path is the name of a directory.  
-Returns 1 if so, 0 if not, -1 if it doesn't exist.
-
-\begin{chunk}{*}
-int directoryp(char *path) {
-    struct stat buf;
-    int code = stat(path, &buf);
-    return(code == -1 ? -1 : S_ISDIR(buf.st_mode));
-}
-
-\end{chunk}
-
-This function is only used internal to this file.
-Axiom lisp code does not depend on it.
-
-\begin{chunk}{*}
-int make_path_from_file(char *s, char *t) {
-    char *pos = "";
-    char *c;
-    /** simply copies the path name from t into s **/
-    for (c = t + strlen(t); c != s; c--)
-        if (*c == '/') {
-            pos = c;
-            break;
-        }
-    /** Check to see if the path was actually present **/
-    if (c == t) {               /** No Path, so return the pwd **/
-        return (-1);
-    }
-    /** now just do the copying **/
-    strncpy(s, t, pos - t);
-    return 1;
-}
-
-\end{chunk}
-
-This function is used in {\tt interp/fname.lisp} to support the
-{\tt myWriteable?} function, which is called by {\tt fnameWriteable?}.
-It supports a test called {\tt writeable?} in {\tt algebra/fname.spad}. 
-
-\begin{chunk}{*}
-int writeablep(char *path) {
-    struct stat buf;
-    char newpath[100];
-    int code;
-    code = stat(path, &buf);
-    if (code == -1) {
-        /** The file does not exist, so check to see
-                 if the directory is writable                  *****/
-        if (make_path_from_file(newpath, path) == -1 ||
-            stat(newpath, &buf) == -1) {
-            return (-1);
-        }
-        else {
-            if (geteuid() == buf.st_uid) {
-                return (2 * ((buf.st_mode & S_IWUSR) != 0));
-            }
-            else if (getegid() == buf.st_gid) {
-                return (2 * ((buf.st_mode & S_IWGRP) != 0));
-            }
-            else {
-                return (2 * ((buf.st_mode & S_IWOTH) != 0));
-            }
-        }
-    }
-    else if (geteuid() == buf.st_uid) {
-        return ((buf.st_mode & S_IWUSR) != 0);
-    }
-    else if (getegid() == buf.st_gid) {
-        return ((buf.st_mode & S_IWGRP) != 0);
-    }
-    else {
-        return ((buf.st_mode & S_IWOTH) != 0);
-    }
-}
-
-\end{chunk}
-
-This function does not appear to be used anywhere
-\begin{verbatim}
-int CLgetpid(void) {
-     return getpid();
-}
-\end{verbatim}
-
-This function does not appear to be used in axiom. It has been
-replaced by native lisp code in {\tt fname.lisp} in the function
-{\tt file-readablep}.
-\begin{verbatim}
-int readablep(char *path) {
-    struct stat buf;
-    int code;
-    code = stat(path, &buf);
-    if (code == -1) {
-        return (-1);
-    }
-    else if (geteuid() == buf.st_uid) {
-        return ((buf.st_mode & S_IREAD) != 0);
-    }
-    else if (getegid() == buf.st_gid) {
-        return ((buf.st_mode & S_IRGRP) != 0);
-    }
-    else {
-        return ((buf.st_mode & S_IROTH) != 0);
-    }
-}
-\end{verbatim}
-
-This function does not appear to be used anywhere.
-\begin{verbatim}
-long findString(char *file, char *string) {
-    int nstring, charpos;
-    FILE *fn;
-    char buffer[1024];
-    if ((fn = fopen(file, "r")) == NULL)
-        return -1;
-    for (charpos = 0, nstring = strlen(string);
-         fgets(buffer, sizeof buffer, fn) != NULL;
-         charpos += strlen(buffer)
-        )
-        if (!strncmp(buffer, string, nstring))
-            return charpos;
-    return -1;
-}
-\end{verbatim}
-
-This function does not appear to be used anywhere.
-\begin{verbatim}
-int copyEnvValue(char *varName, char *buffer) {
-    char *s;
-    s = getenv(varName);
-    if (s == NULL)
-        return 0;
-    strcpy(buffer, s);
-    return strlen(s);
-}
-
-\end{verbatim}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/cursor.c.pamphlet b/src/lib/cursor.c.pamphlet
deleted file mode 100644
index 16d66ee..0000000
--- a/src/lib/cursor.c.pamphlet
+++ /dev/null
@@ -1,158 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib cursor.c}
-\author{Stephen Watt, James Wen}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\begin{chunk}{*}
-
-#include <stdlib.h>
-
-#include "cursor.h1"
-
-/*
- * This routine changes the shape of the cursor. it is a modified version of
- * a program by SMWatt, called cursor.c. JMW 6/22/89
- */
-
-/* this stuff can only be done on AIX <AND> the right terminal (aixterm,hft) */
-#if (defined(RIOSplatform) ||  defined(RTplatform)) && !defined(_AIX41)
-#include "edible.h"
-/* the HFT stuff requires ioctl's and termio's */
-#include <termio.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <sys/hft.h>
-
-int
-Cursor_shape(int shape)
-{
-    int hftfd;
-    char hftpath[16], s[100];
-    int chno;
-    int i;
-    struct termio oldterm, newterm;
-    struct hftgetid hftgid;
-    char *termVal;
-
-    termVal = (char *) getenv("TERM");
-    if (strcmp("hft", termVal) && strncmp("aixterm", termVal, 7))
-        return;
-
-
-
-    /* determine the desired shape */
-    if (shape < 0 || shape > 5) {
-        fprintf(stderr, "%d - Invalid cursor number\n");
-        return (-1);
-    }
-    /* change the shape */
-    s[0] = 033;                 /* hf_intro.hf_esc      */
-    s[1] = '[';                 /* hf_intro.hf_lbr      */
-    s[2] = 'x';                 /* hf_intro.hf_ex       */
-    s[3] = 0;                   /* hf_intro.hf_len[0]   */
-    s[4] = 0;                   /* hf_intro.hf_len[1]   */
-    s[5] = 0;                   /* hf_intro.hf_len[2]   */
-    s[6] = 10;                  /* hf_intro.hf_len[3]   */
-    s[7] = 2;                   /* hf_intro.hf_typehi   */
-    s[8] = 8;                   /* hf_intro.hf_typelo   */
-    s[9] = 2;                   /* hf_sublen            */
-    s[10] = 0;                  /* hf_subtype           */
-    s[11] = 0;                  /* hf_rsvd              */
-    s[12] = shape;              /* hf_shape     */
-
-    if (ioctl(0, HFTGETID, &hftgid) < 0) {
-        /* perror("ioctl: HFTGETID"); */
-        chno = -1;
-    }
-    else
-        chno = hftgid.hf_chan;
-    if (chno == -1) {
-        /** try being moronic and just writing what I want to
-                                     standard output             ****/
-
-        if (((ioctl(2, TCGETA, &oldterm)) == -1) ||
-            ((ioctl(2, TCGETA, &newterm)) == -1)) {
-            perror("Getting termio");
-            exit(0);
-        }
-        newterm.c_oflag = newterm.c_lflag = newterm.c_iflag = 0;
-        newterm.c_cc[0] = -1;
-        for (i = 1; i <= 5; i++)
-            newterm.c_cc[i] = 0;
-        if ((ioctl(2, TCSETAF, &newterm)) == -1) {
-            perror("Setting to raw mode");
-            exit(0);
-        }
-        write(2, s, 13);
-        read(0, s, 1024);
-        if ((ioctl(2, TCSETAF, &oldterm)) == -1) {
-            perror("Resetting terminal");
-            exit(0);
-        }
-    }
-    else {
-        /* open the currently active virtual terminal on the hft */
-        sprintf(hftpath, "/dev/hft/%d", chno);
-        if ((hftfd = open(hftpath, O_RDWR)) == -1) {
-            perror("Could not open hft channel\n");
-            exit(0);
-        }
-        write(hftfd, s, 13);
-    }
-}
-#else
-
-int
-Cursor_shape(int shape)
-{
-  return shape;
-}
-#endif
-
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/edin.c.pamphlet b/src/lib/edin.c.pamphlet
deleted file mode 100644
index 54db72d..0000000
--- a/src/lib/edin.c.pamphlet
+++ /dev/null
@@ -1,971 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib edin.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\begin{chunk}{*}
-
-/* #define debug 1 */
-
-#include <stdlib.h>
-\end{chunk}
-
-The MACOSX platform is broken because no matter what you do it seems to
-include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
-systems these files include themselves which causes an infinite regression
-of includes that fails. GCC gracefully steps over that problem but the
-build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
-of files are badly broken with respect to the [[/usr/include]] versions.
-
-\begin{chunk}{*}
-#if defined(MACOSXplatform)
-#include "/usr/include/unistd.h"
-#else
-#include <unistd.h>
-#endif
-#include <string.h>
-#include <stdio.h>
-#include <sys/types.h>
-
-#include "edible.h"
-
-#define HFT 0
-#define SUN 1
-#define DEC 2
-#define control_to_alpha(x)   (x + ('A' - 0x01))
-#define alpha_to_control(x)   (x - ('A' - 0x01))
-
-int termId;
-QueStruct *ring = NULL;
-QueStruct *current = NULL;
-int ring_size = 0;
-int MAXRING = 64;
-int prev_check = 10;
-int curr_pntr;
-int num_pntr;
-int num_proc;
-int had_tab;
-int had_tab_last;
-extern char buff[1024];            /* Buffers for collecting input and  */
-extern int buff_flag[1024];  /* flags for whether buff chars
-				      are printing or non-printing  */
-int buff_pntr;                     /* present length of  buff */
-
-
-#include "edin.h1"
-#include "prt.h1"
-#include "wct.h1"
-#include "cursor.h1"
-#include "fnct-key.h1"
-
-
-
-void
-init_reader(void)
-{
-  char *termVal;
-  
-  buff[50] = '\0';            /** initialize some stuff  ***/
-  init_flag(buff_flag, MAXLINE);
-  buff_pntr = curr_pntr = 0;
-  
-  had_tab = 0;
-  had_tab_last = 0;
-  termVal = (char *) getenv("TERM");
-  if (!strcmp("sun", termVal))
-    termId = SUN;
-  else if (!strcmp("xterm", termVal) || !strncmp("vt", termVal, 2))
-    termId = DEC;
-  else if (!strcmp("hft", termVal) || !strncmp("aixterm", termVal, 7))
-    termId = HFT;
-}
-
-
-void 
-do_reading(void)
-{
-  int ttt_read;
-  int done_completely;
-  
-  done_completely = 0;
-  num_proc = 0;
-  while (num_proc < num_read) {
-    if(in_buff[num_proc]== _ERASE) {
-      back_over_current_char();
-      num_proc++;
-    }
-    else {
-      switch (in_buff[num_proc]) {
-	/* lets start checking for different types of chars */
-      case _EOLN:
-      case _CR:
-	/* If I have read a complete line, so send it to the child */
-	send_line_to_child();
-	if (!PTY)
-	  myputchar('\n');
-	break;
-	
-	/*
-	 * Use 0x7f as delete
-	 */
-      case _DEL:
-	/* Had a delete key */
-	delete_current_char();
-	break;
-	
-      case _CNTRL_W:
-	move_back_word();
-	num_proc++;
-	break;
-      case _TAB:
-	had_tab = 1;
-	/* command completion stuff */
-	num_proc++;
-	if (had_tab_last)
-	  rescan_wct();
-	else
-	  find_wct();
-	break;
-      case _BELL:
-	insert_buff_nonprinting(1);
-	putchar(_BELL);
-	fflush(stdout);
-	break;
-      case _ESC:
-	
-	/*
-	 * get 2 characters more
-	 */
-	while (!(num_read - num_proc > 2)) {
-	  ttt_read = read(0, 
-			  in_buff + num_read, 
-			  2 - (num_read - num_proc) + 1);
-	  if (ttt_read > 0)
-	    num_read = num_read + ttt_read;
-	}
-	if ((in_buff[num_proc + 1] == _LBRACK)) {
-
-	  /* ESC [  */
-	  
-	  switch (in_buff[num_proc + 2]) {
-	    /*  look for arrows */
-	  case _A:
-	    /* up arrow */
-	    
-	    /*
-	     * The first thing I plan to do is get rid of the present
-	     * input **
-	     */
-	    prev_buff();
-	    curr_pntr = buff_pntr;
-	    num_proc = num_proc + 3;
-	    break;
-	  case _B:
-	    /* down arrow */
-	    next_buff();
-	    curr_pntr = buff_pntr;
-	    num_proc = num_proc + 3;
-	    break;
-	  case _C:
-	    /* right arrow */
-	    move_ahead();
-	    num_proc = num_proc + 3;
-	    break;
-	  case _D:
-	    /* left arrow */
-	    move_back();
-	    num_proc = num_proc + 3;
-	    break;
-	    
-	    /*
-	     * Use ^[[P as delete
-	     */
-	  case _P:
-	    /*** Had a delete key      ****/
-	    delete_current_char();
-	    break;
-	  case _H:
-	  case 0:
-	    move_home();
-	    num_proc += 3;
-	    break;
-	  case _M:
-	  case _Z:
-	    insert_buff_nonprinting(3);
-	    done_completely = 1;
-	    num_proc += 3;
-	    break;
-	  case _x:
-	    num_proc = num_read;
-	    break;
-	  case _1:
-	  case _2:
-	  case _0:
-	    
-	    /*
-	     * I have had a possible function key hit, look for the
-	     * ones I want. check for ESC ] x ~
-	     */
-	    while (!(num_read - num_proc > 3)) {
-	      ttt_read = read(0, 
-			      in_buff + num_read, 
-			      3 - (num_read - num_proc) + 1);
-	      if (ttt_read > 0)
-		num_read = num_read + ttt_read;
-	    }
-	    if (in_buff[num_proc + 3] == _twiddle) {
-	      
-	      /*
-	       * treat ESC ] x ~
-	       */
-	      switch (in_buff[num_proc + 2]) {
-	      case _2:
-		flip(INS_MODE);
-		if (INS_MODE)
-		  Cursor_shape(5);
-		else
-		  Cursor_shape(2);
-		reprint(curr_pntr);
-		num_proc += 4;
-		break;
-	      default:
-		insert_buff_nonprinting(1);
-		break;
-	      }
-	      break;
-	    }
-	    /* check for ESC ] x y ~ */
-	    while (!(num_read - num_proc > 4)) {
-	      ttt_read = read(0, 
-			      in_buff + num_read, 
-			      4 - (num_read - num_proc) + 1);
-	      if (ttt_read > 0)
-		num_read = num_read + ttt_read;
-	    }
-	    if (in_buff[num_proc + 4] == _twiddle) {
-	      
-	      /*
-	       * treat ESC ] x y ~
-	       */
-	      insert_buff_nonprinting(1);
-	      break;
-	    }
-	    
-	    /* check for ESC ] x y z [q|z] */
-	    
-	    while (!(num_read - num_proc > 5)) {
-	      ttt_read = read(0, 
-			      in_buff + num_read, 
-			      5 - (num_read - num_proc) + 1);
-	      if (ttt_read > 0)
-		num_read = num_read + ttt_read;
-	    }
-	    if (insert_toggle(&in_buff[num_proc + 3])) {
-	      flip(INS_MODE);
-	      if (INS_MODE)
-		Cursor_shape(5);
-	      else
-		Cursor_shape(2);
-	      reprint(curr_pntr);
-	      num_proc = num_proc + 6;
-	      break;
-	    }
-	    else if (cntrl_end(&in_buff[num_proc + 3])) {
-	      num_proc = num_proc + 6;
-	      delete_to_end_of_line();
-	      break;
-	    }
-	    else if (back_word(&in_buff[num_proc + 3])) {
-	      move_back_word();
-	      num_proc += 6;
-	      break;
-	    }
-	    else if (fore_word(&in_buff[num_proc + 3])) {
-	      move_fore_word();
-	      num_proc += 6;
-	      break;
-	    }
-	    else if (end_key(&in_buff[num_proc + 3])) {
-	      move_end();
-	      num_proc += 6;
-	      break;
-	    }
-	    switch (in_buff[num_proc + 5]) {
-	    case _q:
-	      
-	      /*
-	       * IBM function keys
-	       */
-	      {
-		char num[3];
-		int key;
-		
-		num[0] = in_buff[num_proc + 3];
-		num[1] = in_buff[num_proc + 4];
-		num[2] = '\0';
-		key = atoi(num);
-		if (key > 0 && key < 13) {
-		  if (function_key[key].str != NULL) {
-		    handle_function_key(key, contNum);
-		    done_completely = 1;
-		  }
-		  else {
-		    insert_buff_nonprinting(6);
-		    done_completely = 1;
-		  }
-		}
-		else {
-		  insert_buff_nonprinting(6);
-		  done_completely = 1;
-		}
-		break;
-	      }
-	    case _z:
-	      
-	      /*
-	       * Sun function keys
-	       */
-	      {
-		char num[3];
-		int key;
-		
-		num[0] = in_buff[num_proc + 3];
-		num[1] = in_buff[num_proc + 4];
-		num[2] = '\0';
-		key = atoi(num) - 23;
-		if (key > 0 && key < 13) {
-		  if (function_key[key].str != NULL) {
-		    handle_function_key(key, contNum);
-		    done_completely = 1;
-		  }
-		  else {
-		    insert_buff_nonprinting(6);
-		    done_completely = 1;
-		  }
-		}
-		else if (atoi(num) == 14) {
-		  move_home();
-		  num_proc += 6;
-		  done_completely = 1;
-		}
-		else if (atoi(num) == 20) {
-		  move_end();
-		  num_proc += 6;
-		  done_completely = 1;
-		}
-		else if (atoi(num) == 47) {
-		  flip(INS_MODE);
-		  if (INS_MODE)
-		    Cursor_shape(5);
-		  else
-		    Cursor_shape(2);
-		  reprint(curr_pntr);
-		  num_proc = num_proc + 6;
-		  done_completely = 1;
-		}
-		else {
-		  insert_buff_nonprinting(6);
-		  done_completely = 1;
-		}
-		
-		break;
-	      }
-	      
-	    default:
-	      insert_buff_nonprinting(1);
-	      break;
-	    }
-	  default:
-	    if (!done_completely)
-	      insert_buff_nonprinting(1);
-	    break;
-	  }
-	}                   /* if */
-	else {              /* ESC w/o [ */
-	  insert_buff_nonprinting(1);
-	}
-	break;
-	
-      case _BKSPC:
-	back_over_current_char();
-	num_proc++;
-	break;
-      default:
-	if (in_buff[num_proc] == _KILL) {
-	  delete_line();
-	  num_proc++;
-	}
-	else {
-	  if ((in_buff[num_proc] == _INTR) || (in_buff[num_proc] == _QUIT)) {
-	    write(contNum, &in_buff[num_proc], num_read - num_proc);
-	    if (!PTY)
-	      write(contNum, "\n", 1);
-	    num_proc++;
-	  }
-	  else {
-	    if (in_buff[num_proc] == _EOF) {
-	      insert_buff_nonprinting(1);
-	      if (!PTY)
-		write(contNum, "\n", 1);
-	      
-	      /*comment out this bit
-		if (!buff_pntr) {
-		write(contNum, &in_buff[num_proc], 1); 
-		if (!PTY)
-		write(contNum, "\n", 1);
-		}
-		else {
-		write(contNum, buff, buff_pntr);
-		}
-		*/
-	      num_proc++;
-	    }
-	    else {
-	      if (in_buff[num_proc] == _EOL) {
-		send_line_to_child();
-		if (!PTY)
-		  write(contNum, "\n", 1);
-	      }
-	      else {
-		if (in_buff[num_proc] == _ERASE) {
-		  back_over_current_char();
-		  num_proc++;
-		}
-		else {
-		  if (control_char(in_buff[num_proc]))
-		    insert_buff_nonprinting(1);
-		  else
-		    insert_buff_printing(1);
-		}
-	      }
-	    }
-	  }
-	}                   /* close the default case */
-	break;
-      }                       /* switch */
-    } /*else*/
-    if (had_tab) {
-      had_tab_last = 1;
-      had_tab = 0;
-    }
-    else
-      had_tab_last = 0;
-    
-  }                           /* while */
-}
-
-
-
-void 
-send_line_to_child(void )
-{
-  static char converted_buffer[MAXLINE];
-  int converted_num;
-  
-  /*  Takes care of sending a line to the child, and resetting the
-      buffer for new input                                  */
-  
-  back_it_up(curr_pntr);
-  
-  /* start by putting the line into the command line ring ***/
-  if (buff_pntr)
-    insert_queue();
-
-  /* finish the line and send it to the child **/
-  buff[buff_pntr] = in_buff[num_proc];
-  buff_flag[buff_pntr++] = 1;
-  buff[buff_pntr] = '\0';
-  buff_flag[buff_pntr] = -1;
-  
-  /*
-   * Instead of actually writing the Line, I have to  substitute in the
-   * actual characters recieved
-   */
-  converted_num =
-    convert_buffer(converted_buffer, buff, buff_flag, buff_pntr);
-  write(contNum, converted_buffer, converted_num);
-  
-  /** reinitialize the buffer  ***/
-  init_flag(buff_flag, buff_pntr);
-  init_buff(buff, buff_pntr);
-  /**  reinitialize my buffer pointers **/
-  buff_pntr = curr_pntr = 0;
-  
-  /** reset the ring pointer **/
-  current = NULL;
-  num_proc++;
-  return;
-}
-
-int
-convert_buffer(char *target, char *source,int * source_flag, int num)
-{
-  int i, j;
-  
-  /*
-   * Until I get something wierd, just keep copying
-   */
-  for (i = 0, j = 0; i < num; i++, j++) {
-    switch (source[i]) {
-    case _CARROT:
-      if (source_flag[i] == 1) {
-	target[j] = source[i];
-      }
-      else {
-	if (source[i + 1] == _LBRACK) {
-	  target[j] = _ESC;
-	  i++;
-	}
-	else if (source[i + 1] >= 'A' && source[i + 1] <= 'Z') {
-	  target[j] = alpha_to_control(source[i + 1]);
-	  i++;
-	}
-      }
-      break;
-    case '?':
-    default:
-      target[j] = source[i];
-    }
-  }
-  return j;
-}
-
-
-void
-insert_buff_printing(int amount)
-{
-  int count;
-  
-  /* This procedure takes the character at in_buff[num_proc] and adds
-     it to the buffer. It first checks to see if we should be inserting
-     or overwriting, and then does the appropriate thing     */
-  
-  if ((buff_pntr + amount) > 1023) {
-    putchar(_BELL);
-    fflush(stdout);
-    num_proc += amount;
-  }
-  else {
-    
-    if (INS_MODE) {
-      
-      forwardcopy(&buff[curr_pntr + amount],
-		  &buff[curr_pntr],
-		  buff_pntr - curr_pntr);
-      forwardflag_cpy(&buff_flag[curr_pntr + amount],
-		      &buff_flag[curr_pntr],
-		      buff_pntr - curr_pntr);
-      for (count = 0; count < amount; count++) {
-	buff[curr_pntr + count] = in_buff[num_proc + count];
-	buff_flag[curr_pntr + count] = 1;
-      }
-      ins_print(curr_pntr, amount);
-      buff_pntr = buff_pntr + amount;
-    }
-    else {
-      for (count = 0; count < amount; count++) {
-	if (buff_flag[curr_pntr + count] == 2) {
-	  myputchar(buff[curr_pntr + count]);
-	  curr_pntr += count + 1;
-	  delete_current_char();
-	  /** fix num_proc affected by delete **/
-	  num_proc -= 3;
-	  curr_pntr -= count + 1;
-	  myputchar(_BKSPC);
-	}
-	buff[curr_pntr + count] = in_buff[num_proc + count];
-	buff_flag[curr_pntr + count] = 1;
-      }
-      myputchar(in_buff[num_proc]);
-      if (curr_pntr == buff_pntr)
-	buff_pntr++;
-    }
-    num_proc = num_proc + amount;
-    curr_pntr = curr_pntr + amount;
-    fflush(stdout);
-  }
-  return;
-  
-}
-
-void 
-insert_buff_nonprinting(int amount)
-{
-  int count;
-  
-  /* This procedure takes the character at in_buff[num_proc] and adds
-     it to the buffer. It first checks to see if we should be inserting
-     or overwriting, and then does the appropriate thing */
-  
-  /* it takes care of the special case, when I have an esc character */
-  
-  if ((buff_pntr + amount) > 1023) {
-    myputchar(_BELL);
-    fflush(stdout);
-    num_proc += amount;
-  }
-  else {
-    if (INS_MODE) {
-      forwardcopy(&buff[curr_pntr + amount + 1],
-		  &buff[curr_pntr],
-		  buff_pntr - curr_pntr);
-      forwardflag_cpy(&buff_flag[curr_pntr + amount + 1],
-		      &buff_flag[curr_pntr],
-		      buff_pntr - curr_pntr);
-      /** now insert the special character **/
-      switch (in_buff[num_proc]) {
-      case _ESC:
-	/** in this case I insert a '^[' into the string ***/
-	buff[curr_pntr] = _CARROT;
-	buff_flag[curr_pntr] = 2;
-	buff[curr_pntr + 1] = _LBRACK;
-	buff_flag[curr_pntr + 1] = 0;
-	break;
-      default:
-	if (control_char(in_buff[num_proc])) {
-	  buff[curr_pntr] = _CARROT;
-	  buff_flag[curr_pntr] = 2;
-	  buff[curr_pntr + 1] = control_to_alpha(in_buff[num_proc]);
-	  buff_flag[curr_pntr + 1] = 0;
-	}
-	else {
-	  /** What do I have ? **/
-	  buff[curr_pntr] = '?';
-	  buff_flag[curr_pntr] = 2;
-	  buff[curr_pntr + 1] = in_buff[num_proc];
-	  buff_flag[curr_pntr] = 0;
-	  break;
-	}
-      }
-      /** Now add the normal characters **/
-      for (count = 1; count < amount; count++) {
-	buff[curr_pntr + count + 1] = in_buff[num_proc + count];
-	buff_flag[curr_pntr + count + 1] = 1;
-      }
-      ins_print(curr_pntr, amount + 1);
-      buff_pntr = buff_pntr + amount + 1;
-    }
-    else {
-      /** I am in the overstrike mode **/
-      switch (in_buff[num_proc]) {
-      case _ESC:
-	/** in this case I insert a '^[' into the string ***/
-	buff[curr_pntr] = _CARROT;
-	buff_flag[curr_pntr] = 2;
-	buff[curr_pntr + 1] = _LBRACK;
-	buff_flag[curr_pntr + 1] = 0;
-	break;
-      default:
-	if (control_char(in_buff[num_proc])) {
-	  buff[curr_pntr] = _CARROT;
-	  buff_flag[curr_pntr] = 2;
-	  buff[curr_pntr + 1] = control_to_alpha(in_buff[num_proc]);
-	  buff_flag[curr_pntr + 1] = 0;
-	}
-	else {
-	  /** What do I have ? **/
-	  buff[curr_pntr] = '?';
-	  buff_flag[curr_pntr] = 2;
-	  buff[curr_pntr + 1] = in_buff[num_proc];
-	  buff_flag[curr_pntr] = 0;
-	  break;
-	}
-      }
-      for (count = 1; count < amount; count++) {
-	if (buff_flag[curr_pntr + count] == 2) {
-	  curr_pntr += count + 1;
-	  delete_current_char();
-	  /** fix num. processed form delete **/
-	  num_proc -= 3;
-	  curr_pntr -= count + 1;
-	}
-	buff[curr_pntr + count + 1] = in_buff[num_proc + count];
-	buff_flag[curr_pntr + count + 1] = 1;
-      }
-      /** now print the characters I have put in **/
-      printbuff(curr_pntr, amount + 1);
-    }
-    num_proc = num_proc + amount;
-    curr_pntr = curr_pntr + amount + 1;
-    if (curr_pntr > buff_pntr)
-      buff_pntr = curr_pntr;
-  }
-  return;
-  
-}
-
-void
-prev_buff(void)
-{
-
-  /*
-   * If the current command ring is NULL, then I should NOT clear the
-   * current line. Thus my business is already done
-   */
-  if (ring == NULL)
-    return;
-  clear_buff();
-  init_buff(buff, buff_pntr);
-  init_flag(buff_flag, buff_pntr);
-  
-  if (current == NULL) {
-    if (ring == NULL)
-      return;
-    current = ring;
-  }
-  else
-    current = current->prev;
-  strcpy(buff, current->buff);
-  flagcpy(buff_flag, current->flags);
-
-  /* first  back up and blank the line */
-  fflush(stdout);
-  printbuff(0, strlen(buff));
-  curr_pntr = buff_pntr = strlen(buff);
-  fflush(stdout);
-  return ;
-}
-
-void
-next_buff(void)
-{
-  
-  /*
-   * If the current command ring is NULL, then I should NOT clear the
-   * current line. Thus my business is already done
-   */
-  if (ring == NULL)
-    return;
-  clear_buff();
-  init_buff(buff, buff_pntr);
-  init_flag(buff_flag, buff_pntr);
-  if (current == NULL) {
-    if (ring == NULL)
-      return;
-    current = ring->next;
-  }
-  else
-    current = current->next;
-  strcpy(buff, current->buff);
-  flagcpy(buff_flag, current->flags);
-  
-  /* first  back up and blank the line **/
-  fflush(stdout);
-  printbuff(0, strlen(buff));
-  curr_pntr = buff_pntr = strlen(buff);
-  fflush(stdout);
-  return ;
-}
-
-
-void 
-forwardcopy(char *buff1,char * buff2,int num)
-{
-  int count;
-  
-  for (count = num; count >= 0; count--)
-    buff1[count] = buff2[count];
-}
-
-
-void 
-forwardflag_cpy(int *buff1,int * buff2,int  num)
-{
-  int count;
-  
-  for (count = num; count >= 0; count--)
-    buff1[count] = buff2[count];
-}
-
-void 
-flagcpy(int *s,int *t)
-{
-  while (*t >= 0)
-    *s++ = *t++;
-  *s = *t;
-}
-
-void 
-flagncpy(int *s,int *t,int n)
-{
-  while (n-- > 0)
-    *s++ = *t++;
-}
-
-void 
-insert_queue(void)
-{
-  QueStruct *trace;
-  QueStruct *new;
-  int c;
-  
-  if (!ECHOIT)
-    return;
-  if (ring != NULL && !strcmp(buff, ring->buff))
-    return;
-  for (c = 0, trace = ring; trace != NULL && c < (prev_check - 1);
-       c++, trace = trace->prev) {
-    if (!strcmp(buff, trace->buff)) {
-      
-      /*
-       * throw this puppy at the end of the ring
-       */
-      trace->next->prev = trace->prev;
-      trace->prev->next = trace->next;
-      trace->prev = ring;
-      trace->next = ring->next;
-      ring->next = trace;
-      trace->next->prev = trace;
-      ring = trace;
-      return;
-    }
-  }
-  
-  /*
-   * simply places the buff command into the front of the queue
-   */
-  if (ring_size < MAXRING) {
-    new = (QueStruct *) malloc(sizeof(struct que_struct));
-    if (new == NULL) {
-      fprintf(stderr, "Malloc Error: Ran out of memory\n");
-      exit(-1);
-    }
-    if (ring_size == 0) {
-      ring = new;
-      ring->prev = ring->next = new;
-    }
-    else {
-      new->next = ring->next;
-      new->prev = ring;
-      ring->next = new;
-      new->next->prev = new;
-      ring = new;
-    }
-    ring_size++;
-  }
-  else
-    ring = ring->next;
-  
-  init_flag(ring->flags, MAXLINE);
-  init_buff(ring->buff, MAXLINE);
-  strcpy(ring->buff, buff);
-  flagncpy(ring->flags, buff_flag, buff_pntr);
-  (ring->buff)[buff_pntr] = '\0';
-  (ring->flags)[buff_pntr] = -1;
-}
-
-
-void
-init_flag(int *flags, int num)
-{
-  int i;
-  
-  for (i = 0; i < num; i++)
-    flags[i] = -1;
-}
-
-void 
-init_buff(char *flags, int num)
-{
-  int i;
-  
-  for (i = 0; i < num; i++)
-    flags[i] = '\0';
-}
-
-
-void
-send_function_to_child(void)
-{
-  /* Takes care of sending a line to the child, and resetting the
-     buffer for new input                                */
-  
-  back_it_up(curr_pntr);
-  /** start by putting the line into the command line ring ***/
-  if (buff_pntr)
-    insert_queue();
-  
-  /** finish the line and send it to the child **/
-  buff[buff_pntr] = _EOLN;
-  
-  buff_flag[buff_pntr++] = 1;
-  buff[buff_pntr] = '\0';
-  buff_flag[buff_pntr] = 0;
-  write(contNum, buff, buff_pntr);
-  
-  /** reinitialize the buffer  ***/
-  init_flag(buff_flag, buff_pntr);
-  init_buff(buff, buff_pntr);
-  /**  reinitialize my buffer pointers **/
-  buff_pntr = curr_pntr = 0;
-  
-  /** reset the ring pointer **/
-  current = NULL;
-  
-  num_proc++;
-  return;
-}
-
-void 
-send_buff_to_child(int chann)
-{
-  if (buff_pntr > 0)
-    write(chann, buff, buff_pntr);
-  num_proc += 6;
-  /** reinitialize the buffer  ***/
-  init_flag(buff_flag, buff_pntr);
-  init_buff(buff, buff_pntr);
-  /**  reinitialize my buffer pointers **/
-  buff_pntr = curr_pntr = 0;
-  /** reset the ring pointer **/
-  current = NULL;
-  return;
-}
-
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/emupty.c.pamphlet b/src/lib/emupty.c.pamphlet
deleted file mode 100644
index 1213222..0000000
--- a/src/lib/emupty.c.pamphlet
+++ /dev/null
@@ -1,239 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib emupty.c}
-\author{Nick Simicich}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\begin{chunk}{*}
-
-/*
-  Here is some code taken from Nick Simicich. It takes an escape sequence
-  from the child, and if I am actually talking to an HFT device, it
-  translates that escape sequence into an ioctl call.
-  */
-
-
-#if 0
-
-#include "edible.h"
-#include "sys/devinfo.h"
-#include <sys/ioctl.h>
-
-typedef union {
-   struct hfintro *hf;
-   struct hfctlreq *re;
-   char *c;
-} Argument;
-
-emuhft(Argument arg, int tty, int ptc, int len)
-{
-    /* What does it do? */
-    /* 1.  There are a number of ioctl's associated with the HFT terminal. */
-    /* 2.  When an HFT terminal is being emulated over a PTY, the */
-    /* IOCTL cannot be executed directly on the server end of the PTY. */
-    /* 3.  A system defined structure is set up such that the program */
-    /* at the end of the PTY can issue the ioctl as an escape */
-    /* sequence and get its response as an escape sequence. */
-    /* 4.  This is badly broken, even stupid.  If the protocol is */
-    /* defined, and everyone is supposed to use it, then the HFT */
-    /* should react directly to it.  But No.... */
-    /* 5.  Furthermore, our terminal itself might be a pty.  In that */
-    /* case, we have to transmit the data just as we got it to the */
-    /* other PTY, instead of executing the IOCTL. */
-
-    static union {
-        struct hfintro hfi;
-        struct hfctlack ackn;
-        char charvector[1024];  /* Spacer to make sure that response can be
-                                 * moved here */
-    }   aa;
-
-    extern int errno;
-
-#ifdef DEBUG
-    dstream(arg.c, stderr, NULL, "From emuhft (input)");
-#endif
-
-    if (len > 1000) {
-        fprintf(stderr, "Unreasonable value for len %d\n", len);
-        return -1;
-    }
-
-    if (ioctl(tty, IOCTYPE, 0) != (DD_PSEU << 8)) {     /* is it a pty ?      */
-        switch (arg.re->hf_request) {
-          case HFQUERY:{
-                struct hfquery hfqur;
-                int i;
-
-                hfqur.hf_resplen = iiret(arg.re->hf_rsp_len);
-                if (hfqur.hf_resplen > 0) {
-                    hfqur.hf_resp = aa.charvector + sizeof aa.ackn;
-                    if (hfqur.hf_resplen > (sizeof aa.charvector - sizeof
-                                            aa.ackn)) {
-                        errno = ENOMEM;
-                        perror("Can't store HFQUERY response");
-                        return -1;
-                    }
-                }
-                else
-                    hfqur.hf_resp = NULL;
-
-                hfqur.hf_cmd = arg.c + 3 + ciret(arg.hf->hf_len);
-                hfqur.hf_cmdlen = iiret(arg.re->hf_arg_len);
-                i = ioctl(tty, HFQUERY, &hfqur);        /* The meat of the
-                                                         * matter */
-                aa.hfi.hf_esc = HFINTROESC;
-                aa.hfi.hf_lbr = HFINTROLBR;
-                aa.hfi.hf_ex = HFINTROEX;
-                icmove(sizeof aa.ackn - 3, aa.hfi.hf_len);
-                aa.hfi.hf_typehi = HFCTLACKCH;
-                aa.hfi.hf_typelo = HFCTLACKCL;
-                if (i == -1)
-                    aa.ackn.hf_retcode = errno;
-                else
-                    aa.ackn.hf_retcode = 0;
-                aa.ackn.hf_sublen = arg.re->hf_sublen;
-                aa.ackn.hf_subtype = arg.re->hf_subtype;
-                aa.ackn.hf_request = iiret(arg.re->hf_request);
-                aa.ackn.hf_arg_len = hfqur.hf_resplen;
-                if (-1 == write(ptc, aa.charvector, (sizeof aa.ackn) +
-                                hfqur.hf_resplen)) {
-                    perror("write of HFQUERY acknowledgement failed");
-                    return (-1);
-                }
-#ifdef DEBUG
-                dstream(aa.charvector, stderr, NULL, "From emuhft (hfquery ack)");
-#endif
-                break;
-            }
-          case HFSKBD:{
-                struct hfbuf hfkey;
-                int i;
-
-                hfkey.hf_bufp = arg.c + 3 + ciret(arg.hf->hf_len);
-                hfkey.hf_buflen = iiret(arg.re->hf_arg_len);
-                i = ioctl(tty, HFSKBD, &hfkey); /* The meat of the matter */
-                aa.hfi.hf_esc = HFINTROESC;
-                aa.hfi.hf_lbr = HFINTROLBR;
-                aa.hfi.hf_ex = HFINTROEX;
-                icmove(sizeof aa.ackn - 3, aa.hfi.hf_len);
-                aa.hfi.hf_typehi = HFCTLACKCH;
-                aa.hfi.hf_typelo = HFCTLACKCL;
-                if (i == -1)
-                    aa.ackn.hf_retcode = errno;
-                else
-                    aa.ackn.hf_retcode = 0;
-                aa.ackn.hf_sublen = arg.re->hf_sublen;
-                aa.ackn.hf_subtype = arg.re->hf_subtype;
-                aa.ackn.hf_request = iiret(arg.re->hf_request);
-                aa.ackn.hf_arg_len = 0;
-                if (-1 == write(ptc, aa.charvector, sizeof aa.ackn)) {
-                    perror("write of HFSKEY acknowledgement failed");
-                    return (-1);
-                }
-#ifdef DEBUG
-                dstream(aa.charvector, stderr, NULL, "From emuhft (HFSKEY ack)");
-#endif
-                break;
-            }
-          default:{
-                aa.hfi.hf_esc = HFINTROESC;
-                aa.hfi.hf_lbr = HFINTROLBR;
-                aa.hfi.hf_ex = HFINTROEX;
-                icmove(sizeof aa.ackn - 3, aa.hfi.hf_len);
-                aa.hfi.hf_typehi = HFCTLACKCH;
-                aa.hfi.hf_typelo = HFCTLACKCL;
-                aa.ackn.hf_retcode = EINVAL;
-                aa.ackn.hf_sublen = arg.re->hf_sublen;
-                aa.ackn.hf_subtype = arg.re->hf_subtype;
-                aa.ackn.hf_request = iiret(arg.re->hf_request);
-                aa.ackn.hf_arg_len = 0;
-                if (-1 == write(ptc, aa.charvector, sizeof aa.ackn)) {
-                    perror("write of default acknowledgement failed");
-                    return (-1);
-                }
-#ifdef DEBUG
-                dstream(aa.charvector, stderr, NULL, "From emuhft (default ack)");
-#endif
-
-                break;
-            }
-        }
-    }
-    else {
-        /* Well, if we get here, we are a pseudo-device ourselves.  So */
-        /* we will just send on the request that we got.  we are in a */
-        /* unique situation.  We believe that both ptc and tty are as */
-        /* transparent as we can get them, so we don't have to worry. */
-        /* We will just write the request to the tty,  which we */
-        /* believe is a pty, and sooner or later, the ack will come */
-        /* back. */
-        if (-1 == write(tty, arg.c, len)) {
-            perror("write of control sequence to pty failed");
-            fprintf(stderr, "tty = %d, len = %d\n", tty, len);
-            return (-1);
-        }
-#ifdef DEBUG
-        dstream(arg.c, stderr, NULL, "From emuhft (on pty transfer)");
-        fprintf(stderr, "tty = %d, len = %d\r\n", tty, len);
-        fflush(stderr);
-#endif
-
-    }
-    return 0;
-}
-
-
-
-#endif
-
-static int _ThatsAll_(int x) 
-{
-return x;
-}
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/fnct-key.c.pamphlet b/src/lib/fnct-key.c.pamphlet
deleted file mode 100644
index fbeaf41..0000000
--- a/src/lib/fnct-key.c.pamphlet
+++ /dev/null
@@ -1,388 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib fnct\_key.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{MAC OSX and BSD port}
-On the MAC OSX the signal [[SIGCLD]] has been renamed to [[SIGCHLD]].
-In order to handle this change we need to ensure that the platform
-variable is set properly and that the platform variable is changed
-everywhere.
-\begin{chunk}{mac os signal rename}
-#if defined(MACOSXplatform) || defined(BSDplatform)
-        bsdSignal(SIGCHLD, null_fnct,RestartSystemCalls);
-#else
-        bsdSignal(SIGCLD, null_fnct,RestartSystemCalls);
-#endif
-\end{chunk}
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-
-The MACOSX platform is broken because no matter what you do it seems to
-include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
-systems these files include themselves which causes an infinite regression
-of includes that fails. GCC gracefully steps over that problem but the
-build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
-of files are badly broken with respect to the [[/usr/include]] versions.
-
-\begin{chunk}{*}
-#if defined(MACOSXplatform)
-#include "/usr/include/unistd.h"
-#else
-#include <unistd.h>
-#endif
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <signal.h>
-
-
-#include "edible.h"
-#include "bsdsignal.h"
-
-
-#include "bsdsignal.h1"
-#include "fnct-key.h1"
-#include "prt.h1"
-#include "edin.h1"
-
-
-/** Some constants for functio key defs ****/
-#define DELAYED 0
-#define IMMEDIATE 1
-#define SPECIAL   2
-
-
-/**   Here is the structure for storing bound  pf-keys             ***/
-fkey function_key[13];          /** Strings which replace function
-                                    keys when a key is hit          ***/
-
-static char *defaulteditor = "clefedit";
-char editorfilename[100];
-
-
-
-/*
- * The following function environment variable clef editor. The command
- * should be the one that the user wishes to have execed
- */
-
-void 
-set_editor_key(void)
-{
-    int pid;
-
-    sprintf(editorfilename, "/tmp/clef%d", pid = getpid());
-
-    if (function_key[12].str == NULL) {
-        (function_key[12]).type = SPECIAL;
-        (function_key[12]).str = defaulteditor;
-    }
-}
-
-
-
-
-void
-define_function_keys(void)
-/***  This routine id used to find the users function key mappings. It
-    simply searches the users HOME directory for a file called ".clef".
-    If found it gets the key bindings from within
-    *****/
-{
-    char *HOME, path[1024], string[1024];
-    int key;
-    int fd;
-    char type;
-
-    /** lets initialize the key pointers **/
-    for (key = 0; key < 13; key++)
-        (function_key[key]).str = NULL;
-    /** see if the user has a .clef file       ***/
-    HOME = getenv("HOME");
-    sprintf(path, "%s/.clef", HOME);
-    if ((fd = open(path, O_RDONLY)) == -1) {
-        return;
-    }
-    else {
-        /*** If so, then get the key bindings **/
-        while ((key = get_key(fd, &type))) {
-            get_str(fd, string);
-            switch (type) {
-              case 'D':
-                if (key == 12) {
-                    fprintf(stderr,
-                       "Clef Error: PF12 can only be of type E in .clef\n");
-                    fprintf(stderr, "Line will be ignored\n");
-                    type = -1;
-                }
-                else {
-                    (function_key[key]).type = DELAYED;
-                }
-                break;
-              case 'F':
-                if (key == 12) {
-                    fprintf(stderr,
-                       "Clef Error: PF12 can only be of type E in .clef\n");
-                    fprintf(stderr, "Line will be ignored\n");
-                    type = -1;
-                }
-                else {
-                    (function_key[key]).type = IMMEDIATE;
-                }
-                break;
-              case 'E':
-                if (key != 12) {
-                    fprintf(stderr,
-                       "Clef Error: PF12 can only be of type E in .clef\n");
-                    fprintf(stderr, "Line will be ignored\n");
-                    type = -1;
-                }
-                else {
-                    (function_key[key]).type = SPECIAL;
-                }
-                break;
-            }
-            if (type != -1) {
-                (function_key[key]).str =
-                    (char *) malloc(strlen(string) + 1);
-                sprintf((function_key[key]).str, "%s", string);
-            }
-        }
-    }
-
-    /*
-     * Now set the editor function key
-     */
-    set_editor_key();
-}
-
-
-#define defof(c) ((c == 'F' || c == 'D' || c == 'E')?(1):(0))
-
-int
-get_key(int fd,char * ty)
-{
-
-    /*
-     * Determines the key number being mapped, and whether it is immediate or
-     * delay. It reurns the key value, and modifies the parameter type
-     */
-    char keynum[1024];
-    int nr;
-
-    nr = read(fd, keynum, 3);
-    if (nr != -1 && nr != 0) {
-        if (!defof(keynum[0])) {
-            return 0;
-        }
-        else {
-            *ty = keynum[0];
-            keynum[3] = '\0';
-            return (atoi(&keynum[1]));
-        }
-    }
-    else
-        return 0;
-}
-
-int
-get_str(int fd,char * string)
-{
-    /** Gets the key mapping being bound **/
-    char c;
-    int count = 0;
-    char *trace = string;
-
-    read(fd, &c, 1);
-    while (c == ' ')
-        read(fd, &c, 1);
-    while (c != '\n') {
-        count++;
-        *trace++ = c;
-        if (read(fd, &c, 1) == 0)
-            break;
-    }
-    *trace = '\0';
-    return count;
-}
-
-void 
-null_fnct(int sig)
-{
-    return;
-}
-
-void 
-handle_function_key(int key,int  chann)
-{
-    /** this procedure simply adds the string specified by the function key
-      to the buffer                                               ****/
-    int count, fd;
-    int amount = strlen(function_key[key].str);
-    int id;
-
-    /*** This procedure takes the character at in_buff[num_proc] and adds
-      it to the buffer. It first checks to see if we should be inserting
-      or overwriting, and then does the appropriate thing      *******/
-
-    switch ((function_key[key]).type) {
-      case IMMEDIATE:
-        if (INS_MODE) {
-            forwardcopy(&buff[curr_pntr + amount],
-                        &buff[curr_pntr],
-                        buff_pntr - curr_pntr);
-            forwardflag_cpy(&buff_flag[curr_pntr + amount],
-                            &buff_flag[curr_pntr],
-                            buff_pntr - curr_pntr);
-            for (count = 0; count < amount; count++) {
-                buff[curr_pntr + count] = (function_key[key].str)[count];
-                buff_flag[curr_pntr + count] = '1';
-            }
-            ins_print(curr_pntr, amount + 1);
-            buff_pntr = buff_pntr + amount;
-        }
-        else {
-            for (count = 0; count < amount; count++) {
-                buff[curr_pntr + count] = (function_key[key].str)[count];
-                buff_flag[curr_pntr + count] = '1';
-                myputchar((function_key[key].str)[count]);
-            }
-        }
-        num_proc = num_proc + 6;
-        curr_pntr = curr_pntr + amount;
-        buff_pntr = buff_pntr + amount;
-        send_function_to_child();
-        break;
-      case DELAYED:
-        if (INS_MODE) {
-            forwardcopy(&buff[curr_pntr + amount],
-                        &buff[curr_pntr],
-                        buff_pntr - curr_pntr);
-            forwardflag_cpy(&buff_flag[curr_pntr + amount],
-                            &buff_flag[curr_pntr],
-                            buff_pntr - curr_pntr);
-            for (count = 0; count < amount; count++) {
-                buff[curr_pntr + count] = (function_key[key].str)[count];
-                buff_flag[curr_pntr + count] = '1';
-            }
-            ins_print(curr_pntr, amount + 1);
-            buff_pntr = buff_pntr + amount;
-        }
-        else {
-            for (count = 0; count < amount; count++) {
-                buff[curr_pntr + count] = (function_key[key].str)[count];
-                buff_flag[curr_pntr + count] = '1';
-                myputchar((function_key[key].str)[count]);
-            }
-        }
-        num_proc = num_proc + 6;
-        curr_pntr = curr_pntr + amount;
-        buff_pntr = buff_pntr + amount;
-        fflush(stdout);
-        break;
-      case SPECIAL:
-        /* fprintf(stderr, "Here I am \n"); */
-        if (access(editorfilename, F_OK) < 0) {
-            fd = open(editorfilename, O_RDWR | O_CREAT, 0666);
-            write(fd, buff, buff_pntr);
-            back_up(buff_pntr);
-            close(fd);
-        }
-        else {
-            if (buff_pntr > 0) {
-                fd = open(editorfilename, O_RDWR | O_TRUNC);
-                write(fd, buff, buff_pntr);
-                back_up(buff_pntr);
-                close(fd);
-            }
-        }
-\getchunk{mac os signal rename}
-        switch (id = fork()) {
-          case -1:
-            perror("Special key");
-            break;
-          case 0:
-            execlp((function_key[12]).str,
-                   (function_key[12]).str,
-                   editorfilename, NULL);
-            perror("Returned from exec");
-            exit(0);
-
-        }
-        while (wait((int *) 0) < 0);
-        /** now I should read that file and send all it stuff thru the
-                  reader                                            *****/
-        fd = open(editorfilename, O_RDWR);
-        if (fd == -1) {
-            perror("Opening temp file");
-            exit(-1);
-        }
-        num_proc += 6;
-
-        /** reinitialize the buffer  ***/
-        init_flag(buff_flag, buff_pntr);
-        init_buff(buff, buff_pntr);
-        /**  reinitialize my buffer pointers **/
-        buff_pntr = curr_pntr = 0;
-        /** reset the ring pointer **/
-        current = NULL;
-        ECHOIT = 0;
-        while ((num_read = read(fd, in_buff, MAXLINE))) {
-            do_reading();
-        }
-        close(fd);
-        break;
-    }
-    return;
-
-}
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/halloc.c.pamphlet b/src/lib/halloc.c.pamphlet
deleted file mode 100644
index 1f7c670..0000000
--- a/src/lib/halloc.c.pamphlet
+++ /dev/null
@@ -1,76 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib halloc.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\begin{chunk}{*}
-
-/* memory allocation used by HyperDoc and addfile */
-
-#include <stdlib.h>
-#include <stdio.h>
-
-#include "halloc.h1"
-
-
-/* allocate memory and bomb if none left (hyperTeX alloc) */
-char *
-halloc(int bytes,char * msg)
-{
-    static char buf[200];
-    char *result;
-
-    result = (char *) malloc(bytes);
-    if (result == NULL) {
-        sprintf(buf, "Ran out of memory allocating %s.\b", msg);
-        exit(-1);
-    }
-    return result;
-}
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/hash.c.pamphlet b/src/lib/hash.c.pamphlet
deleted file mode 100644
index baaad0e..0000000
--- a/src/lib/hash.c.pamphlet
+++ /dev/null
@@ -1,238 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{no title}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-      notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-\end{verbatim}
-\begin{chunk}{*}
-
-#define _HASH_C
-#include "debug.h"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include "hash.h"
-
-#include "hash.h1"
-#include "halloc.h1"
-
-/* initialize a hash table */
-
-void
-hash_init(HashTable *table, int size, EqualFunction equal, 
-          HashcodeFunction hash_code)
-{
-    int i;
-
-    table->table =
-        (HashEntry **) halloc(size * sizeof(HashEntry *), "HashEntry");
-    for (i = 0; i < size; i++)
-        table->table[i] = NULL;
-    table->size = size;
-    table->equal = equal;
-    table->hash_code = hash_code;
-    table->num_entries = 0;
-}
-
-void
-free_hash(HashTable *table, FreeFunction free_fun)
-{
-  if (table) {
-    int i;
-
-    for (i = 0; i < table->size; i++) {
-      HashEntry *e, *next;
-
-      for (e = table->table[i]; e != NULL;) {
-        next = e->next;
-        (*free_fun) (e->data);
-	(*e).data=0;
-        free(e);
-        e = next;
-      }
-    }
-    free(table->table);
-  }
-}
-
-/* insert an entry into a hash table */
-
-void
-hash_insert(HashTable *table, char *data, char *key)
-{
-    HashEntry *entry = (HashEntry *) halloc(sizeof(HashEntry), "HashEntry");
-    int code;
-
-    entry->data = data;
-    entry->key = key;
-    code = (*table->hash_code) (key, table->size) % table->size;
-#ifdef DEBUG
-    fprintf(stderr, "Hash value = %d\n", code);
-#endif
-    entry->next = table->table[code];
-    table->table[code] = entry;
-    table->num_entries++;
-}
-
-char *
-hash_find(HashTable *table, char *key)
-{
-    HashEntry *entry;
-    int code = table->hash_code(key, table->size) % table->size;
-
-    for (entry = table->table[code]; entry != NULL; entry = entry->next)
-        if ((*table->equal) (entry->key, key))
-            return entry->data;
-    return NULL;
-}
-
-char *
-hash_replace(HashTable *table, char *data, char *key)
-{
-    HashEntry *entry;
-    int code = table->hash_code(key, table->size) % table->size;
-
-    for (entry = table->table[code]; entry != NULL; entry = entry->next)
-        if ((*table->equal) (entry->key, key)) {
-            entry->data = data;
-            return entry->data;
-        }
-    return NULL;
-}
-
-void
-hash_delete(HashTable *table, char *key)
-{
-    HashEntry **entry;
-    int code = table->hash_code(key, table->size) % table->size;
-
-    for (entry = &table->table[code]; *entry != NULL; entry = &((*entry)->next))
-        if ((*table->equal) ((*entry)->key, key)) {
-            *entry = (*entry)->next;
-            table->num_entries--;
-            return;
-        }
-}
-
-void
-hash_map(HashTable *table, MappableFunction func)
-{
-    int i;
-    HashEntry *e;
-
-    if (table == NULL)
-        return;
-    for (i = 0; i < table->size; i++)
-        for (e = table->table[i]; e != NULL; e = e->next)
-            (*func) (e->data);
-}
-
-HashEntry *
-hash_copy_entry(HashEntry *e)
-{
-    HashEntry *ne;
-
-    if (e == NULL)
-        return e;
-    ne = (HashEntry *) halloc(sizeof(HashEntry), "HashEntry");
-    ne->data = e->data;
-    ne->key = e->key;
-    ne->next = hash_copy_entry(e->next);
-    return ne;
-}
-
-/* copy a hash table */
-HashTable *
-hash_copy_table(HashTable *table)
-{
-    HashTable *nt = (HashTable *) halloc(sizeof(HashTable), "copy hash table");
-    int i;
-
-    nt->size = table->size;
-    nt->num_entries = table->num_entries;
-    nt->equal = table->equal;
-    nt->hash_code = table->hash_code;
-    nt->table = (HashEntry **) halloc(nt->size * sizeof(HashEntry *),
-                                      "copy table");
-    for (i = 0; i < table->size; i++)
-        nt->table[i] = hash_copy_entry(table->table[i]);
-    return nt;
-}
-
-/* hash code function for strings */
-int
-string_hash(char *s, int size)
-{
-    int c = 0;
-    char *p =s;
-
-
-    while (*p)
-        c += *p++;
-    return c % size;
-}
-
-/* test strings for equality */
-
-int
-string_equal(char *s1, char *s2)
-{
-    return (strcmp(s1, s2) == 0);
-}
-
-/* make a fresh copy of the given string */
-char *
-alloc_string(char *str)
-{
-    char * result;
-    result = halloc(strlen(str)+1,"String");
-    strcpy(result,str);
-    return (result);
-}
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/openpty.c.pamphlet b/src/lib/openpty.c.pamphlet
deleted file mode 100644
index 61f46ce..0000000
--- a/src/lib/openpty.c.pamphlet
+++ /dev/null
@@ -1,302 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib openpty.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{Overview}
-The main function is {\tt ptyopen}. It simply opens up both sides of a
-pseudo-terminal. It uses and saves the pathnames for
-the devices which were actually opened.
-
-If it fails it simply exits the program.
-
-\begin{verbatim}
- ptyopen(controller, server, controllerPath, serverPath) 
- int *controller;     The file descriptor for controller side
- int *server;         The file descriptor for the server side 
- char *controllerPath;  actually , this is not used anywhere 
-                        on return and can be taken out of the 
-                        call sequence
- char *serverPath;
-\end{verbatim}
-The path name  vars should be declared of size 11 or more
-
-The device {\tt /dev/ptmx} is the pseudo-terminal master device.
-The device {\tt /dev/pts} is the pseudo-terminal slave device.
-
-The file {\tt /dev/ptmx} is a character file with a major number of 5
-and a minor number of 2, usually of mode 0666 and owner.group of
-root.root. It is used to create a pseudo-terminal master and slave pair.
-
-When a process opens {\tt /dev/ptmx}, it gets a file descriptor for a
-pseudo-terminal master {\tt PTM}, and a pseudo-terminal slave {\tt PTS}
-device is created in the {\tt /dev/pts} directory. Each file descriptor
-obtained by opening {\tt /dev/ptmx} is an independent {\tt PTM} with its
-own associated {\tt PTS}, whose path can be found by passing the 
-descriptor to {\tt ptsname}.
-
-Before opening the pseudo-terminal slave, you must pass the master's
-file descriptor to {\tt grantpt} and {\tt unlockpt}.
-
-Once both the pseudo-terminal master and slave are open, the slave
-provides processes with an interface that is identical to that of a
-real terminal.
-
-Data written to the slave is presented on the master descriptor as input.
-Data written to the master is presented to the slave as input.
-
-In practice, pseudo-terminals are used for implementing terminal 
-emulators such as {\tt xterm}, in which data read from the 
-pseudo-terminal master is interpreted by the application in the same way
-a real terminal would interpret the data, and for implementing 
-remote login programs such as {\tt sshd}, in which data read from the
-pseudo-terminal master is sent across the network to a client program
-that is connected to a terminal or terminal emulator.
-
-Pseudo-terminals can also be used to send input to programs that normally
-refuse to read input from pipes (such as {\tt su}) and {\tt passwd}.
-
-The Linux support for the pseudo-terminals (known as Unix98 pty naming)
-is done using the {\tt devpts} filesystem, that should be mounted on
-{\tt /dev/pts}.
-
-Before this Unix98 scheme, master ptys were called {\tt /dev/ptyp0},
-$\ldots$, and slave ptys {\tt /dev/ttyp0}, $\ldots$ and one to 
-preallocate 
-a lot of device nodes./cite{1}
-
-\section{include files}
-\begin{chunk}{*}
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <stdio.h>
-#include <fcntl.h>
-#include <string.h>
-
-#if defined(SUN4OS5platform) || defined(HP10platform)
-#include <stropts.h>
-#endif
-
-#include "openpty.h1"
-
-\end{chunk}
-\section{{\tt openpty}}
-\begin{chunk}{*}
-
-int  
-ptyopen(int *controller,int * server, char *controllerPath,char * serverPath)
-{
-#if defined(SUNplatform) ||\
- defined (HP9platform) ||\
- defined(RTplatform) ||\
- defined(AIX370platform) ||\
- defined(BSDplatform)
-  int looking = 1, i;
-  int oflag = O_RDWR;                  /* flag for opening the pty */
-  
-  for (i = 0; looking && i < 1000; i++) {
-    makeNextPtyNames(controllerPath, serverPath);
-    if (access(controllerPath, 6) != 0) continue;
-    *controller = open(controllerPath, oflag, 0);
-    if (*controller >= 0) {
-      *server = open(serverPath, oflag, 0);
-      if (*server > 0)
-	looking = 0;
-      else
-	close(*controller);
-    }
-  }
-  if (looking) {
-    fprintf(stderr, "Couldn't find a free pty.\n");
-    exit(-1);
-  }
-  return (*controller);
-#endif
-#if defined RIOSplatform
-  int fdm,fds;
-  char *slavename;
-  /* open master */
-  if ((fdm=open("/dev/ptc",O_RDWR))<0)
-    perror("ptyopen failed to open /dev/ptc");
-  else {
-    /* get slave name */
-    if((slavename = ttyname(fdm))==0)
-      perror("ptyopen failed to get the slave device name");
-    /* open slave */
-    if ((fds = open(slavename, O_RDWR)) < 0 )
-      perror("ptyopen: Failed to open slave");
-    strcpy(serverPath,slavename);
-    *controller=fdm;
-    *server=fds;
-  }
-  return(fdm);
-#endif
-
-\end{chunk}
-
-Note that since we have no other information we are adding the
-MACOSXplatform variable to the list everywhere we find
-LINUXplatform. This may not be correct but we have no way to know
-yet. We have also added the BSDplatform variable.  MAC OSX is some
-variant of BSD. These should probably be merged but we cannot yet
-prove that.
-
-\begin{chunk}{*}
-#if defined(SUN4OS5platform) ||\
- defined(ALPHAplatform) ||\
- defined(HP10platform) ||\
- defined(LINUXplatform) ||\
- defined(MACOSXplatform) ||\
- defined(BSDplatform)
-
-extern int grantpt(int);
-extern int unlockpt(int);
-extern char* ptsname(int);
-  int fdm,fds;
-  char *slavename;
-
-  /* open master */
-  if ((fdm = open("/dev/ptmx", O_RDWR)) < 0 )
-    perror("ptyopen: Failed to open /dev/ptmx");
-  else {
-    /* change permission ofslave */
-    if (grantpt(fdm) < 0)
-      perror("ptyopen: Failed to grant access to slave device");
-    /* unlock slave */
-    if (unlockpt(fdm) < 0)
-      perror("ptyopen: Failed to unlock master/slave pair");
-    /* get name of slave */
-    if ((slavename = ptsname(fdm)) == NULL)
-      perror("ptyopen: Failed to get name of slave device");
-    /* open slave */
-    if ((fds = open(slavename, O_RDWR)) < 0 )
-      perror("ptyopen: Failed to open slave");
-    else {
-#if defined(SUN4OS5platform) || defined(HP10platform)
-      /* push ptem */
-      if (ioctl(fds, I_PUSH, "ptem") < 0)
-        perror("ptyopen: Failed to push ptem");
-      /* push ldterm */
-      if (ioctl(fds, I_PUSH, "ldterm") < 0)
-        perror("ptyopen: Failed to push idterm");
-#endif
-      strcpy(serverPath,slavename);
-      *controller=fdm;
-      *server=fds;
-    }
-  }
-  return(fdm);
-#endif
-#if defined SGIplatform
-  char *fds;
-  fds = _getpty(controller, O_RDWR|O_NDELAY, 0600, 0);
-  strcpy(serverPath,fds);
-  if (0 == serverPath)
-    return(-1);
-  if (0 > (*server = open(serverPath,O_RDWR))) {
-    (void) close(*controller);
-    return(-1);
-  }
-  return (*controller);
-
-#endif
-}
-
-\end{chunk}
-
-Prior to using the Unix 98 pty naming scheme the naming scheme
-used 16 ptyp/ttyp names, ttyp0-ttypF (where F is a hex number).
-Later this was extended to ttyq0-ttyqF and so on, eventually
-wrapping around to ttya0-ttyaF. Linux also allows larger numbers
-such as ttypNNN.\cite{2}
-
-\section{{\tt makeNextPtyNames}}
-\begin{chunk}{*}
-
-void 
-makeNextPtyNames(char *cont,char * serv)
-{
-#ifdef AIX370platform
-	static int channelNo = 0;
-	sprintf(cont, "/dev/ptyp%02x", channelNo);
-	sprintf(serv, "/dev/ttyp%02x", channelNo);
-	channelNo++;
-#endif
-\end{chunk}
-
-See the note above about the MACOS platform change.
-
-\begin{chunk}{*}
-#if defined(SUNplatform) ||\
- defined(HP9platform) ||\
- defined(LINUXplatform) ||\
- defined(MACOSXplatform) ||\
- defined(BSDplatform)
-	static int channelNo = 0;
-	static char group[] = "pqrstuvwxyzPQRST";
-	static int groupNo = 0;
-
-	sprintf(cont, "/dev/pty%c%x", group[groupNo], channelNo);
-	sprintf(serv, "/dev/tty%c%x", group[groupNo], channelNo);
-	channelNo++;                /* try next */
-	if (channelNo == 16) {      /* move to new group */
-		channelNo = 0;
-		groupNo++;
-		if (groupNo == 16) groupNo = 0;        /* recycle */
-		}
-#endif
-}
-
-\end{chunk}
-
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} {\tt ptmx(4)} - Linux man page\\
-{\bf http://linux/die.net/man/4/ptmx}
-\bibitem{2} {\tt Text Termininal HOWTO}\\
-{\bf http://www.linux.org/docs/ldp/howto/\\
-{\hbox {\hskip 1.0cm}}Text-Terminal-HOWTO-7.html}
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/pixmap.c.pamphlet b/src/lib/pixmap.c.pamphlet
deleted file mode 100644
index 1e25071..0000000
--- a/src/lib/pixmap.c.pamphlet
+++ /dev/null
@@ -1,344 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib pixmap.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{MAC OSX zopen redefinition}
-On the [[MAC OSX]] platform they defined [[zopen]]. Since the function
-is only used in this file we simply rename it to [[zzopen]].
-\begin{chunk}{mac zopen redefinition 1}
-FILE *
-zzopen(char *file,char * mode)
-\end{chunk}
-\begin{chunk}{mac zopen redefinition 2}
-    file = zzopen(filename, "r");
-\end{chunk}
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\begin{chunk}{*}
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xos.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <netinet/in.h>
-
-#define yes 1
-#define no  0
-
-
-
-#include "spadcolors.h"
-
-#include "pixmap.h1"
-#include "halloc.h1"
-#include "spadcolors.h1"
-
-
-
-/* returns true if the file exists */
-
-int
-file_exists(char *file)
-{
-    FILE *f;
-
-    if ((f = fopen(file, "r")) != NULL) {
-        fclose(f);
-        return 1;
-    }
-    return 0;
-}
-
-\getchunk{mac zopen redefinition 1}
-{
-    char com[512], zfile[512];
-
-    if (file_exists(file))
-        return fopen(file, mode);
-    sprintf(zfile, "%s.Z", file);
-    if (file_exists(zfile)) {
-        sprintf(com, "gunzip -c %s.Z 2>/dev/null", file);
-        return popen(com, mode);
-    }
-    return NULL;
-}
-#ifdef OLD
-
-/*******************************************************************
-   KF 6/14/90
-   write_pixmap_file(display, filename, pm, width, height)
-        and
-   write_pixmap_file_xy(display, filename, pm, x, y, width, height)
-   has been merged into one function.
-
-   INPUT: display dsp, screen s, file name fn to write the file in,
-          window id wid where pixmap is,
-          upper left corner x, y of original pixmap,
-          width and height of pixmap
-   OUTPUT: binary file with data
-   PURPOSE: write_pixmap_file gets the image structure of the input
-          pixmap, convert the image data with the permutation color
-          vector, writes the image structure out to filename.
-
-   Note that writing out a Z pixmap is 8x faster than XY pixmap.
-   This is because XY writes out each pixel value per plane, thus
-   number of bits; Z writes out each pixel, or 8 bits at a time.
-
-   The XY format may have been chosen for a reason -- I don't know.
-
-********************************************************************/
-void
-write_pixmap_file(Display *dsp, int scr, char  *fn, 
-                  Window wid, int x, int y, int width,int height)
-{
-    XImage *xi;
-    FILE *file;
-    int *permVector;
-    int num;
-    int num_colors;
-
-    /* get color map and permutation vector */
-    if ((num_colors = makePermVector(dsp, scr,(unsigned long **)&permVector)) < 0) {
-        printf("num_colors < 0!!\n");
-        exit(-1);
-    }
-
-    /* reads image structure in ZPixmap format */
-    xi = XGetImage(dsp, wid, x, y, width, height, AllPlanes, ZPixmap);
-    file = fopen(fn, "wb");
-    if (file == NULL) {
-        perror("opening pixmap file for write");
-        exit(-1);
-    }
-
-#define PUTW(a,b) putw(htonl(a),b)
-
-
-    PUTW(xi->width, file);
-    PUTW(xi->height, file);
-    PUTW(xi->xoffset, file);
-    PUTW(xi->format, file);
-    PUTW(xi->byte_order, file);
-    PUTW(xi->bitmap_unit, file);
-    PUTW(xi->bitmap_bit_order, file);
-    PUTW(xi->bitmap_pad, file);
-    PUTW(xi->depth, file);
-    PUTW(xi->bytes_per_line, file);
-    PUTW(xi->bits_per_pixel, file);
-    PUTW(xi->red_mask, file);
-    PUTW(xi->green_mask, file);
-    PUTW(xi->blue_mask, file);
-
-    num = xi->bytes_per_line * height;  /* total number of pixels in pixmap */
-
-    /* store value from permutation */
-    {
-        int ii, jj;
-
-        for (ii = 0; ii < width; ii++)
-            for (jj = 0; jj < height; jj++) {
-                XPutPixel(xi, ii, jj, permVector[(int) XGetPixel(xi, ii, jj)]);
-            }
-    }
-    fwrite(xi->data, 1, num, file);
-    fclose(file);
-}
-
-/*******************************************************************
-   KF 6/14/90
-
-   INPUT: display, screen, filename to read the pixmap data from,
-   OUTPUT: ximage structure xi, width and height of pixmap
-   PURPOSE: read_pixmap_file reads an Ximage data structure from
-            the input file.
-            This routine can handle pixmaps of both XYPixmap and
-            ZPixmap.  If a pixmap has ZPixmap format, then the image
-            data, read in as spadColor index, is converted to the
-            pixel value using spadColor.
-
-   Note that reading in Z format takes less space and time too.
-
-********************************************************************/
-int
-read_pixmap_file(Display *display, int screen, char *filename,
-                 XImage **xi, int *width, int *height)
-{
-    FILE *file;
-    int wi, h, num, num_colors, read_this_time, offset;
-    Colormap cmap;
-    int ts;
-    unsigned long *spadColors;
-
-    /* colormap is necessary to call makeColors */
-    cmap = DefaultColormap(display, screen);
-    if ((num_colors = makeColors(display, screen, &cmap, &spadColors, &ts)) < 0) {
-        return(-1);
-    }
-\getchunk{mac zopen redefinition 2}
-    if (file == NULL) {
-        printf("couldn't open %s\n", filename);
-        return BitmapOpenFailed;
-    }
-#define GETW(f) ntohl(getw(f))
-    *width = wi = GETW(file);
-    *height = h = GETW(file);
-    (*xi) = XCreateImage(display, DefaultVisual(display, screen),
-                         DisplayPlanes(display, screen),
-                         ZPixmap, 0, NULL, wi, h, 16, 0);       /* handles both XY & Z */
-    if ((*xi) == NULL) {
-        fprintf(stderr, "Unable to create image\n");
-        return(-1);
-    }
-    (*xi)->width = wi;
-    (*xi)->height = h;
-    (*xi)->xoffset = GETW(file);
-    (*xi)->format = GETW(file);
-    (*xi)->byte_order = GETW(file);
-    (*xi)->bitmap_unit = GETW(file);
-    (*xi)->bitmap_bit_order = GETW(file);
-    (*xi)->bitmap_pad = GETW(file);
-    (*xi)->depth = GETW(file);
-    (*xi)->bytes_per_line = GETW(file);
-    (*xi)->bits_per_pixel = GETW(file);
-    (*xi)->red_mask = GETW(file);
-    (*xi)->green_mask = GETW(file);
-    (*xi)->blue_mask = GETW(file);
-
-    /* program will bomb if XYPixmap is not allocated enough space */
-    if ((*xi)->format == XYPixmap) {
-        /* printf("picture is in XYPixmap format.\n"); */
-        num = (*xi)->bytes_per_line * h * (*xi)->depth;
-    }
-    else                        /* ZPixmap */
-        num = (*xi)->bytes_per_line * h;
-    (*xi)->data = (void*)halloc(num, "Ximage data");
-
-    offset = 0;
-    while (offset < num) {
-        read_this_time = fread(((*xi)->data + offset), 1, num - offset, file);
-        offset = offset + read_this_time;
-    }
-    fclose(file);
-
-    /*
-     * pixmap data in ZPixmap format are spadColor indices; pixmap data in
-     * XYPixmap format are pixel values
-     */
-    if ((*xi)->format == ZPixmap) {
-
-        int ii, jj;
-
-        for (ii = 0; ii < wi; ii++)
-            for (jj = 0; jj < h; jj++) {
-                XPutPixel(*xi, ii, jj, spadColors[(int) XGetPixel(*xi, ii, jj)]);
-            }
-
-
-    }
-
-    return 0;
-}
-
-
-#else /*OLD*/
-
-
-#include "xpm.h"
-
-int
-read_pixmap_file(Display *display, int screen, char *filename,
-                 XImage **xi, int *width, int *height)
-{
-  XpmAttributes attr;
-  XImage *xireturn;
-
-  attr.valuemask = 0;
-
-  attr.bitmap_format=ZPixmap;             /* instead of XYPixmap */
-  attr.valuemask |= XpmBitmapFormat;
-  attr.valuemask |= XpmSize;              /* we want feedback on width,height */
-  attr.valuemask |= XpmCharsPerPixel;     /* and cpp */
-  attr.valuemask |= XpmReturnPixels;      /* and pixels, npixels */
-  attr.valuemask |= XpmReturnAllocPixels; /* and alloc_pixels, nalloc_pixels */
-  attr.exactColors = False;
-  attr.valuemask |= XpmExactColors;       /* we don't want exact colors*/
-  attr.closeness = 30000;
-  attr.valuemask |= XpmCloseness;         /* we specify closeness*/
-  attr.alloc_close_colors = False;
-  attr.valuemask |= XpmAllocCloseColors;  /* we don't allocate close colors*/
-
-  
-  XpmReadFileToImage(display,filename,xi,&xireturn, &attr );
-  *width= (*xi)->width;
-  *height=(*xi)->height;
-#ifdef DEBUG
-  fprintf(stderr,"image file:%s\n",filename);
-  fprintf(stderr,"\twidth:%d\theight:%d\tcpp:%d\n",attr.width,attr.height,attr.cpp);
-  fprintf(stderr,"\tused/alloc'ed color pixels:%d/%d\n",attr.npixels,attr.nalloc_pixels);
-#endif
-  return 0;
-}
-
-
-void
-write_pixmap_file(Display *dsp, int scr, char  *fn, 
-                  Window wid, int x, int y, int width,int height)
-{
-  XImage *xi;
-  
-  /* reads image structure in ZPixmap format */
-  xi = XGetImage(dsp, wid, x, y, width, height, AllPlanes, ZPixmap);
-  if (xi==0) return ;
-  XpmWriteFileFromImage(dsp,fn,xi,0,0);
-  
-}
-
-
-#endif
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/prt.c.pamphlet b/src/lib/prt.c.pamphlet
deleted file mode 100644
index 23faacf..0000000
--- a/src/lib/prt.c.pamphlet
+++ /dev/null
@@ -1,427 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib prt.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\begin{chunk}{*}
-
-#include <string.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include "edible.h"
-
-#include "prt.h1"
-#include "edin.h1"
-
-void
-myputchar(char c)
-{
-    if (ECHOIT)
-        putchar(c);
-    return;
-}
-
-void 
-clear_buff(void)
-{
-    int count;
-
-    /*** called when spadbuf gives me a line incase there is something already
-      on the line ****/
-    if (buff_pntr > 0) {
-        /*** backup to the beginning of the line ***/
-        for (count = curr_pntr; count > 0; count--)
-            myputchar(_BKSPC);
-        /** blank over the line      ***/
-        for (count = 0; count < buff_pntr; count++) {
-            myputchar(_BLANK);
-        }
-        /** back up again ***/
-        for (count = buff_pntr; count > 0; count--)
-            myputchar(_BKSPC);
-        init_buff(buff, buff_pntr);
-        init_flag(buff_flag, buff_pntr);
-        curr_pntr = buff_pntr = 0;
-    }
-}
-
-
-void 
-move_end(void)
-{
-
-    /** Moves cursor to the end of the line ***/
-    if (curr_pntr == buff_pntr) {
-        putchar(_BELL);
-    }
-    else {
-        for (; curr_pntr < buff_pntr;) {
-            myputchar(buff[curr_pntr++]);
-        }
-    }
-    fflush(stdout);
-}
-
-void 
-move_home(void)
-{
-
-    /*** Moves the cursor to the front of the line ***/
-    if (curr_pntr > 0) {
-        for (; curr_pntr > 0;) {
-            myputchar(_BKSPC);
-            curr_pntr--;
-        }
-    }
-    else {
-        putchar(_BELL);
-    }
-    fflush(stdout);
-
-}
-
-void 
-move_fore_word(void)
-{
-    /** move the cursor to the next blank space  **/
-    if (curr_pntr != buff_pntr) {
-        myputchar(buff[curr_pntr]);
-        curr_pntr++;
-        while (curr_pntr < buff_pntr && buff[curr_pntr] != ' ') {
-            myputchar(buff[curr_pntr]);
-            curr_pntr++;
-        }
-    }
-    else
-        putchar(_BELL);
-    fflush(stdout);
-    return;
-}
-
-void 
-move_back_word(void)
-{
-    /*** moves the cursor to the last blank space ***/
-    if (curr_pntr > 0) {
-        myputchar(_BKSPC);
-        curr_pntr--;
-        while (curr_pntr > 0 && buff[curr_pntr - 1] != ' ') {
-            myputchar(_BKSPC);
-            curr_pntr--;
-        }
-
-    }
-    else
-        putchar(_BELL);
-    fflush(stdout);
-    return;
-}
-
-void 
-delete_current_char(void)
-{
-    /**  deletes the char currently above the current_pntr, if it can be **/
-    if (curr_pntr != buff_pntr) {
-        if (buff_flag[curr_pntr] == 1 || buff_flag[curr_pntr] == 0) {
-            myputchar(_BLANK);
-            myputchar(_BKSPC);
-            strcpy(&buff[curr_pntr],
-                   &buff[curr_pntr + 1]);
-            flagcpy(&buff_flag[curr_pntr],
-                    &buff_flag[curr_pntr + 1]);
-            buff_pntr--;
-            del_print(curr_pntr, 1);
-        }
-        else {
-            /** lets delete two of the little buggers **/
-            myputchar(_BLANK);
-            myputchar(_BLANK);
-            myputchar(_BKSPC);
-            myputchar(_BKSPC);
-            strcpy(&buff[curr_pntr],
-                   &buff[curr_pntr + 2]);
-            flagcpy(&buff_flag[curr_pntr],
-                    &buff_flag[curr_pntr + 2]);
-            buff_pntr -= 2;
-            del_print(curr_pntr, 2);
-        }
-    }
-    else {
-        putchar(_BELL);
-        fflush(stdout);
-    }
-    num_proc = num_proc + 3;
-}
-
-void 
-delete_to_end_of_line(void)
-{
-    int count;
-
-    /*** deletes from the curr_pntr to the end of line ***/
-
-    if (curr_pntr == buff_pntr)
-        return;                 /** There is nothing to do **/
-
-    /** blank over the end of the line      ***/
-    for (count = curr_pntr; count < buff_pntr; count++) {
-        myputchar(_BLANK);
-    }
-    /** back up again ***/
-    for (count = buff_pntr; count > curr_pntr; count--)
-        myputchar(_BKSPC);
-
-    buff_pntr = curr_pntr;
-    fflush(stdout);
-    return;
-
-}
-
-void 
-delete_line(void)
-{
-    int count;
-
-    /*** deletes the entire line                                 *****/
-
-    if (buff_pntr == 0)
-        return;                 /** There is nothing to do **/
-
-    /** first I have to back up to the beginning of the line     ****/
-    for (count = curr_pntr; count > 0; count--)
-        myputchar(_BKSPC);
-
-    /** blank over the end of the line      ***/
-    for (count = 0; count < buff_pntr; count++) {
-        myputchar(_BLANK);
-    }
-    /** back up again ***/
-    for (count = buff_pntr; count > 0; count--)
-        myputchar(_BKSPC);
-
-    /* Also clear the buffer */
-    init_buff(buff, buff_pntr);
-    init_flag(buff_flag, buff_pntr);
-    buff_pntr = curr_pntr = 0;
-
-    fflush(stdout);
-    return;
-
-}
-
-void 
-printbuff(int start,int  num)
-{
-    int trace;
-
-    for (trace = start; trace < start + num; trace++)
-        if (buff[trace] != '\0')
-            myputchar(buff[trace]);
-    fflush(stdout);
-}
-
-void
-del_print(int start, int num)
-{
-    int count;
-
-    /*** move the rest of the string     ***/
-    for (count = start; count < buff_pntr; count++) {
-        myputchar(buff[count]);
-    }
-    /** now blank out the number of chars we are supposed to ***/
-    for (count = 0; count < num; count++)
-        myputchar(_BLANK);
-    /*** Now back up  ***/
-    for (count = buff_pntr + num; count > start; count--)
-        myputchar(_BKSPC);
-    fflush(stdout);
-}
-
-
-void 
-ins_print(int start,int  num)
-{
-    int count;
-
-    /** write the rest of the word ***/
-    for (count = start; count < buff_pntr + num; count++) {
-        myputchar(buff[count]);
-    }
-    /** now back up to where we should be ***/
-    for (count = buff_pntr; count > start; count--)
-        myputchar(_BKSPC);
-    fflush(stdout);
-}
-
-void 
-reprint(int start)
-{
-    /**  simply reprints a single character **/
-    if (buff[start] == '\0')
-        myputchar(_BLANK);
-    else
-        myputchar(buff[start]);
-    myputchar(_BKSPC);
-    fflush(stdout);
-    return;
-}
-
-void 
-back_up(int num_chars)
-{
-    int cnt;
-
-    for (cnt = 0; cnt < num_chars; cnt++)
-        myputchar(_BKSPC);
-    for (cnt = 0; cnt < num_chars; cnt++)
-        myputchar(_BLANK);
-    for (cnt = 0; cnt < num_chars; cnt++)
-        myputchar(_BKSPC);
-    fflush(stdout);
-
-}
-
-void 
-back_it_up(int num_chars)
-{
-    int cnt;
-
-    for (cnt = 0; cnt < num_chars; cnt++)
-        myputchar(_BKSPC);
-    fflush(stdout);
-}
-
-
-void 
-print_whole_buff(void)
-{
-    int trace;
-
-    for (trace = 0; trace < buff_pntr; trace++)
-        if (buff[trace] != '\0')
-            myputchar(buff[trace]);
-    fflush(stdout);
-}
-
-void
-move_ahead(void)
-{
-    /*** simply moves the pointer ahead a single word ***/
-    if (curr_pntr == buff_pntr) {
-        putchar(_BELL);
-    }
-    else {
-        if (buff_flag[curr_pntr] == 2) {
-            myputchar(buff[curr_pntr++]);
-        }
-        myputchar(buff[curr_pntr++]);
-    }
-    fflush(stdout);
-}
-
-void
-move_back(void)
-{
-    /** simply moves the cursor back one position **/
-    if (curr_pntr == 0) {
-        putchar(_BELL);
-    }
-    else {
-        if (!buff_flag[curr_pntr - 1]) {
-            myputchar(_BKSPC);
-            curr_pntr--;
-        }
-        myputchar(_BKSPC);
-        curr_pntr--;
-    }
-    fflush(stdout);
-}
-
-void
-back_over_current_char(void)
-{
-    /*** simply backs over the character behind the cursor ***/
-    if (curr_pntr == 0) {
-        putchar(_BELL);
-    }
-    else {
-        if (!buff_flag[curr_pntr - 1]) {
-            myputchar(_BKSPC);
-            myputchar(_BKSPC);
-            myputchar(_BLANK);
-            myputchar(_BLANK);
-            myputchar(_BKSPC);
-            myputchar(_BKSPC);
-            strcpy(&buff[curr_pntr - 2],
-                   &buff[curr_pntr]);
-            flagcpy(&buff_flag[curr_pntr - 2],
-                    &buff_flag[curr_pntr]);
-            buff_pntr -= 2;
-            curr_pntr -= 2;
-            del_print(curr_pntr, 2);
-        }
-        else {
-            myputchar(_BKSPC);
-            myputchar(_BLANK);
-            myputchar(_BKSPC);
-            strcpy(&buff[curr_pntr - 1],
-                   &buff[curr_pntr]);
-            flagcpy(&buff_flag[curr_pntr - 1],
-                    &buff_flag[curr_pntr]);
-            curr_pntr--;
-            buff_pntr--;
-            del_print(curr_pntr, 1);
-        }
-    }
-    fflush(stdout);
-    return;
-}
-
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/sockio-c.c.pamphlet b/src/lib/sockio-c.c.pamphlet
deleted file mode 100644
index 1eb44d3..0000000
--- a/src/lib/sockio-c.c.pamphlet
+++ /dev/null
@@ -1,1080 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib sockio-c.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\begin{chunk}{*}
-
-/* socket i/o primitives */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-\end{chunk}
-
-The MACOSX platform is broken because no matter what you do it seems to
-include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
-systems these files include themselves which causes an infinite regression
-of includes that fails. GCC gracefully steps over that problem but the
-build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
-of files are badly broken with respect to the [[/usr/include]] versions.
-
-\begin{chunk}{*}
-#if defined(MACOSXplatform)
-#include "/usr/include/unistd.h"
-#else
-#include <unistd.h>
-#endif
-#include <sys/time.h>
-#include <sys/stat.h>
-#include <errno.h>
-#include <string.h>
-#if defined(MACOSXplatform)
-#include "/usr/include/signal.h"
-#else
-#include <signal.h>
-#endif
-
-#if defined(SGIplatform)
-#include <bstring.h>
-#endif
-
-#include "com.h"
-#include "bsdsignal.h"
-
-#define TotalMaxPurposes 50
-#define MaxServerNumbers 100
-#define accept_if_needed(purpose) \
-  ( purpose_table[purpose] == NULL ? sock_accept_connection(purpose) : 1 )
-
-
-Sock clients[MaxClients];       /* socket description of spad clients */
-Sock server[2];                 /* AF_UNIX and AF_INET sockets for server */
-Sock *purpose_table[TotalMaxPurposes]; /* table of dedicated socket types */
-fd_set socket_mask;             /* bit mask of active sockets */
-fd_set server_mask;             /* bit mask of server sockets */
-int socket_closed;              /* used to identify closed socket on SIGPIPE */
-int spad_server_number = -1;    /* spad server number used in sman */
-int str_len = 0;
-int still_reading  = 0;
-
-
-
-#include "bsdsignal.h1"
-#include "sockio-c.h1"
-
-void  
-sigpipe_handler(int sig)
-{
-  socket_closed = 1;
-}
-
-int 
-wait_for_client_read(Sock *sock,char *buf,int buf_size,char *msg)
-{
-  int ret_val;
-  switch(sock->purpose) {
-  case SessionManager:
-  case ViewportServer:
-    sock_accept_connection(sock->purpose);
-    ret_val = sread(purpose_table[sock->purpose], buf, buf_size, msg);
-    sock->socket = 0;
-    return ret_val;
-  default:
-    sock->socket = 0;
-    return -1;
-  }
-}
-
-int 
-wait_for_client_write(Sock *sock,char *buf,int buf_size,char *msg)
-{
-  int ret_val;
-  switch(sock->purpose) {
-  case SessionManager:
-  case ViewportServer:
-    sock_accept_connection(sock->purpose);
-    ret_val = swrite(purpose_table[sock->purpose], buf, buf_size, msg);
-    sock->socket = 0;
-    return ret_val;
-  default:
-    sock->socket = 0;
-    return -1;
-  }
-}
-
-int 
-sread(Sock *sock,char *buf,int buf_size,char *msg)
-{
-  int ret_val;
-  char err_msg[256];
-  errno = 0;
-  do {
-    ret_val = read(sock->socket, buf, buf_size);
-  } while (ret_val == -1 && errno == EINTR);
-  if (ret_val == 0) {
-    FD_CLR(sock->socket, &socket_mask);
-    purpose_table[sock->purpose] = NULL;
-    close(sock->socket);
-    return wait_for_client_read(sock, buf, buf_size, msg);
-  }
-  if (ret_val == -1) {
-    if (msg) {
-      sprintf(err_msg, "reading: %s", msg);
-      perror(err_msg);
-    }
-    return -1;
-  }
-  return ret_val;
-}
-
-int 
-swrite(Sock *sock,char *buf,int buf_size,char *msg)
-{
-  int ret_val;
-  char err_msg[256];
-  errno = 0;
-  socket_closed = 0;
-  ret_val = write(sock->socket, buf, buf_size);
-  if (ret_val == -1) {
-    if (socket_closed) {
-      FD_CLR(sock->socket, &socket_mask);
-      purpose_table[sock->purpose] = NULL;
-      /*      printf("   closing socket %d\n", sock->socket); */
-      close(sock->socket);
-      return wait_for_client_write(sock, buf, buf_size, msg);
-    } else {
-      if (msg) {
-        sprintf(err_msg, "writing: %s", msg);
-        perror(err_msg);
-      }
-      return -1;
-    }
-  }
-  return ret_val;
-}
-
-int 
-sselect(int n,fd_set  *rd, fd_set  *wr, fd_set *ex, void *timeout)
-{
-  int ret_val;
-  do {
-    ret_val = select(n, (void *)rd, (void *)wr, (void *)ex, (struct timeval *) timeout);
-  } while (ret_val == -1 && errno == EINTR);
-  return ret_val;
-}
-
-int 
-fill_buf(Sock *sock,char *buf, int len, char *msg)
-{
-  int bytes =  0, ret_val;
-  while(bytes < len) {
-    ret_val = sread(sock, buf + bytes, len - bytes, msg);
-    if (ret_val == -1) return -1;
-    bytes += ret_val;
-  }
-  return bytes;
-}
-
-int 
-get_int(Sock *sock)
-{
-  int val = -1, len;
-  len = fill_buf(sock, (char *)&val, sizeof(int), "integer");
-  if (len != sizeof(int)) {
-#ifdef DEBUG
-  fprintf(stderr,"get_int: caught error\n",val);
-#endif
-    return -1;
-  }
-#ifdef DEBUG
-  fprintf(stderr,"get_int: received %d\n",val);
-#endif
-  return val;
-}
-
-int 
-sock_get_int(int purpose)
-{
-  if (accept_if_needed(purpose) != -1)
-    return get_int(purpose_table[purpose]);
-  else return -1;
-}
-
-int 
-get_ints(Sock *sock, int *vals, int num)
-{
-  int i;
-  for(i=0; i<num; i++)
-    *vals++ = get_int(sock);
-  return 0;
-}
-
-int 
-sock_get_ints(int purpose, int *vals, int num)
-{
-  if (accept_if_needed(purpose) != -1)
-    return get_ints(purpose_table[purpose], vals, num);
-  return -1;
-}
-
-int 
-send_int(Sock *sock,int val)
-{
-  int ret_val;
-  ret_val = swrite(sock, (char *)&val, sizeof(int), NULL);
-  if (ret_val == -1) {
-    return -1;
-  }
-  return 0;
-}
-
-int 
-sock_send_int(int purpose,int  val)
-{
-  if (accept_if_needed(purpose) != -1)
-    return send_int(purpose_table[purpose], val);
-  return -1;
-}
-
-int 
-send_ints(Sock *sock, int *vals, int num)
-{
-  int i;
-  for(i=0; i<num; i++)
-    if (send_int(sock, *vals++) == -1)
-      return -1;
-  return 0;
-}
-
-int 
-sock_send_ints(int purpose, int *vals, int num)
-{
-  if (accept_if_needed(purpose) != -1)
-    return send_ints(purpose_table[purpose], vals, num);
-  return -1;
-}
-
-int 
-send_string_len(Sock *sock,char *str,int len)
-{
-  int val;
-  if (len > 1023) {
-    char *buf;
-    buf = malloc(len+1);
-    strncpy(buf,str,len);
-    buf[len]='\0';
-    send_int(sock,len+1);
-    val = swrite(sock, buf, len+1, NULL);
-    free(buf);
-  } else {
-    static char buf[1024];
-    strncpy(buf, str, len);
-    buf[len] = '\0';
-    send_int(sock, len+1);
-    val = swrite(sock, buf, len+1, NULL);
-  }
-  if (val == -1) {
-    return -1;
-  }
-  return 0;
-}
-
-int 
-send_string(Sock *sock, char *str)
-{
-  int val, len = strlen(str);
-  send_int(sock, len+1);
-  val = swrite(sock, str, len+1, NULL);
-  if (val == -1) {
-    return -1;
-  }
-  return 0;
-}
-
-
-int 
-sock_send_string(int purpose, char *str)
-{
-  if (accept_if_needed(purpose) != -1)
-    return send_string(purpose_table[purpose], str);
-  return -1;
-}
-
-int 
-sock_send_string_len(int purpose, char * str, int len)
-{
-  if (accept_if_needed(purpose) != -1)
-    return send_string_len(purpose_table[purpose], str, len);
-  return -1;
-}
-
-int 
-send_strings(Sock *sock, char ** vals, int num)
-{
-  int i;
-  for(i=0; i<num; i++)
-    if (send_string(sock, *vals++) == -1)
-      return -1;
-  return 0;
-}
-
-int 
-sock_send_strings(int purpose, char **vals, int num)
-{
-  if (accept_if_needed(purpose) != -1)
-    return send_strings(purpose_table[purpose], vals, num);
-  return -1;
-}
-
-char *
-get_string(Sock *sock)
-{
-  int val, len;
-  char *buf;
-  len = get_int(sock);
-  if (len <0) return NULL;
-  buf = malloc(len*sizeof(char));
-  val = fill_buf(sock, buf, len, "string");
-  if (val == -1){
-	free(buf);
-	return NULL;
-	}
-#ifdef DEBUG
-  fprintf(stderr,"get_string: received \"%s\" \n",buf);
-#endif
-  return buf;
-}
-
-char *
-sock_get_string(int purpose)
-{
-  if (accept_if_needed(purpose) != -1)
-    return get_string(purpose_table[purpose]);
-  else return NULL;
-}
-
-
-char *
-get_string_buf(Sock *sock, char *buf, int buf_len)
-{
-  int val;
-  if(!str_len) str_len = get_int(sock);
-    if (str_len > buf_len) {
-      val = fill_buf(sock, buf, buf_len, "buffered string");
-      str_len = str_len - buf_len;
-      if (val == -1)
-        return NULL;
-      return buf;
-    }
-    else {
-      val = fill_buf(sock, buf, str_len, "buffered string");
-      str_len = 0;
-      if (val == -1)
-        return NULL;
-      return NULL;
-    }
-}
-
-char *
-sock_get_string_buf(int purpose, char * buf, int buf_len)
-{
-  if (accept_if_needed(purpose) != -1)
-    return get_string_buf(purpose_table[purpose], buf, buf_len);
-  return NULL;
-}
-
-int 
-get_strings(Sock *sock,char **vals,int num)
-{
-  int i;
-  for(i=0; i<num; i++)
-    *vals++ = get_string(sock);
-  return 0;
-}
-
-int 
-sock_get_strings(int purpose, char ** vals, int num)
-{
-  if (accept_if_needed(purpose) != -1)
-    return get_strings(purpose_table[purpose], vals, num);
-  return -1;
-}
-
-int 
-send_float(Sock *sock, double num)
-{
-  int val;
-  val = swrite(sock, (char *)&num, sizeof(double), NULL);
-  if (val == -1) {
-    return -1;
-  }
-  return 0;
-}
-
-int 
-sock_send_float(int purpose, double num)
-{
-  if (accept_if_needed(purpose) != -1)
-    return send_float(purpose_table[purpose], num);
-  return -1;
-}
-
-int 
-send_sfloats(Sock *sock, float *vals,int  num)
-{
-  int i;
-  for(i=0; i<num; i++)
-    if (send_float(sock, (double) *vals++) == -1)
-      return -1;
-  return 0;
-}
-
-int 
-sock_send_sfloats(int purpose, float * vals, int num)
-{
-  if (accept_if_needed(purpose) != -1)
-    return send_sfloats(purpose_table[purpose], vals, num);
-  return -1;
-}
-
-int 
-send_floats(Sock *sock, double *vals, int num)
-{
-  int i;
-  for(i=0; i<num; i++)
-    if (send_float(sock, *vals++) == -1)
-      return -1;
-  return 0;
-}
-
-int 
-sock_send_floats(int purpose, double  *vals, int num)
-{
-  if (accept_if_needed(purpose) != -1)
-    return send_floats(purpose_table[purpose], vals, num);
-  return -1;
-}
-
-double 
-get_float(Sock *sock)
-{
-  double num = -1.0;
-  fill_buf(sock, (char *)&num, sizeof(double), "double");
-#ifdef DEBUG
-  fprintf(stderr,"get_float: received %f\n",num);
-#endif
-  return num;
-}
-
-double 
-sock_get_float(int purpose)
-{
-  if (accept_if_needed(purpose) != -1)
-    return get_float(purpose_table[purpose]);
-  else return 0.0;
-}
-
-int 
-get_sfloats(Sock *sock, float *vals, int num)
-{
-  int i;
-  for(i=0; i<num; i++)
-    *vals++ = (float) get_float(sock);
-  return 0;
-}
-
-
-int 
-sock_get_sfloats(int purpose,float * vals, int num)
-{
-  if (accept_if_needed(purpose) != -1)
-    return get_sfloats(purpose_table[purpose], vals, num);
-  return -1;
-}
-
-int 
-get_floats(Sock *sock,double *vals,int num)
-{
-  int i;
-  for(i=0; i<num; i++)
-    *vals++ = get_float(sock);
-  return 0;
-}
-
-
-int 
-sock_get_floats(int purpose, double *vals, int num)
-{
-  if (accept_if_needed(purpose) != -1)
-    return get_floats(purpose_table[purpose], vals, num);
-  return -1;
-}
-
-int 
-wait_for_client_kill(Sock *sock, int sig)
-{
-  int ret_val;
-  switch(sock->purpose) {
-  case SessionManager:
-  case ViewportServer:
-    sock_accept_connection(sock->purpose);
-    ret_val = send_signal(purpose_table[sock->purpose], sig);
-    sock->socket = 0;
-    return ret_val;
-  default:
-    sock->socket = 0;
-    return -1;
-  }
-}
-
-
-int 
-sock_get_remote_fd(int purpose)
-{
-  if (accept_if_needed(purpose) != -1)
-    return purpose_table[purpose]->remote_fd;
-  return -1;
-}
-
-int 
-send_signal(Sock *sock, int sig)
-{
-  int ret_val;
-  ret_val = kill(sock->pid, sig);
-  if (ret_val == -1 && errno == ESRCH) {
-    FD_CLR(sock->socket, &socket_mask);
-    purpose_table[sock->purpose] = NULL;
-/*    printf("   closing socket %d\n", sock->socket); */
-    close(sock->socket);
-    return wait_for_client_kill(sock, sig);
-  }
-  return ret_val;
-}
-
-int 
-sock_send_signal(int purpose,int  sig)
-{
-  if (accept_if_needed(purpose) != -1)
-    return send_signal(purpose_table[purpose], sig);
-  return -1;
-}
-
-int 
-send_wakeup(Sock *sock)
-{
-  return send_signal(sock, SIGUSR1);
-}
-
-int 
-sock_send_wakeup(int purpose)
-{
-  if (accept_if_needed(purpose) != -1)
-    return send_wakeup(purpose_table[purpose]);
-  return -1;
-}
-
-Sock *
-connect_to_local_server_new(char *server_name, int purpose, int time_out)
-{
-  int max_con=(time_out == 0 ? 1000000 : time_out), i, code=-1;
-  Sock *sock;
-  char name[256];
-
-  make_server_name(name, server_name);
-  sock = (Sock *) calloc(sizeof(Sock), 1);
-  if (sock == NULL) {
-    perror("allocating socket space");
-    return NULL;
-  }
-  sock->socket = socket(AF_UNIX, SOCK_STREAM, 0);
-  if (sock->socket < 0) {
-    perror("opening client socket");
-    return NULL;
-  }
-  memset(server[1].addr.u_addr.sa_data, 0,
-         sizeof(server[1].addr.u_addr.sa_data));
-  sock->addr.u_addr.sa_family = AF_UNIX;
-  strcpy(sock->addr.u_addr.sa_data, name);
-  for(i=0; i<max_con; i++) {
-    code = connect(sock->socket, &sock->addr.u_addr,
-                   sizeof(sock->addr.u_addr));
-    if (code == -1) {
-      if (errno != ENOENT && errno != ECONNREFUSED) {
-        perror("connecting server stream socket");
-        return NULL;
-      } else {
-        if (i != max_con - 1) sleep(1);
-        continue;
-      }
-    } else break;
-  }
-  if (code == -1) {
-    return NULL;
-  }
-  send_int(sock, getpid());
-  send_int(sock, purpose);
-  send_int(sock, sock->socket);
-  sock->pid = get_int(sock);
-  sock->remote_fd = get_int(sock);
-  return sock;
-}
-
-Sock *
-connect_to_local_server(char *server_name, int purpose, int time_out)
-{
-  int max_con=(time_out == 0 ? 1000000 : time_out), i, code=-1;
-  Sock *sock;
-  char name[256];
-
-  make_server_name(name, server_name);
-  sock = (Sock *) calloc(sizeof(Sock), 1);
-  if (sock == NULL) {
-    perror("allocating socket space");
-    return NULL;
-  }
-  sock->purpose = purpose;
-  /* create the socket */
-  sock->socket = socket(AF_UNIX, SOCK_STREAM, 0);
-  if (sock->socket < 0) {
-    perror("opening client socket");
-    return NULL;
-  }
-  /* connect socket using name specified in command line */
-  memset(server[1].addr.u_addr.sa_data, 0,
-         sizeof(server[1].addr.u_addr.sa_data));
-  sock->addr.u_addr.sa_family = AF_UNIX;
-  strcpy(sock->addr.u_addr.sa_data, name);
-  for(i=0; i<max_con; i++) {
-    code = connect(sock->socket, &sock->addr.u_addr,
-                   sizeof(sock->addr.u_addr));
-    if (code == -1) {
-      if (errno != ENOENT && errno != ECONNREFUSED) {
-        perror("connecting server stream socket");
-        return NULL;
-      } else {
-        if (i != max_con - 1) sleep(1);
-        continue;
-      }
-    } else break;
-  }
-  if (code == -1) {
-    return NULL;
-  }
-  send_int(sock, getpid());
-  send_int(sock, sock->purpose);
-  send_int(sock, sock->socket);
-  sock->pid = get_int(sock);
-/*  fprintf(stderr, "Got int form socket\n"); */
-  sock->remote_fd = get_int(sock);
-  return sock;
-}
-
-/* act as terminal session for sock connected to stdin and stdout of another
-   process */
-void 
-remote_stdio(Sock *sock)
-{
-  char buf[1024];
-  fd_set rd;
-  int len;
-  while (1) {
-    FD_ZERO(&rd);
-    FD_SET(sock->socket,&rd);
-    FD_SET(0, &rd);
-    len = sselect(FD_SETSIZE, (fd_set *)&rd, (fd_set *)0, (fd_set *)0, NULL);
-    if (len == -1) {
-      perror("stdio select");
-      return;
-    }
-    if (FD_ISSET(0, &rd)) {
-      fgets(buf,1024,stdin);
-      len = strlen(buf);
-      /*
-          gets(buf);
-          len = strlen(buf);
-          *(buf+len) = '\n';
-          *(buf+len+1) = '\0';
-      */
-      swrite(sock, buf, len, "writing to remote stdin");
-    }
-    if (FD_ISSET(sock->socket, &rd)) {
-      len = sread(sock, buf, 1024, "stdio");
-      if (len == -1)
-        return;
-      else {
-        *(buf + len) = '\0';
-        fputs(buf, stdout);
-        fflush(stdout);
-      }
-    }
-  }
-}
-
-/* initialize the table of dedicated sockets */
-void 
-init_purpose_table(void)
-{
-  int i;
-  for(i=0; i<TotalMaxPurposes; i++) {
-    purpose_table[i] = NULL;
-  }
-}
-
-
-int 
-make_server_number(void )
-{
-  spad_server_number = getpid();
-  return spad_server_number;
-}
-
-void 
-close_socket(int socket_num, char *name)
-{
-  close(socket_num);
-#ifndef RTplatform
-  unlink(name);
-#endif
-}
-
-int 
-make_server_name(char *name,char * base)
-{
-  char *num;
-  if (spad_server_number != -1) {
-    sprintf(name, "%s%d", base, spad_server_number);
-    return 0;
-  }
-  num = getenv("SPADNUM");
-  if (num == NULL) {
-/*    fprintf(stderr,
-      "\n(AXIOM Sockets) The AXIOM server number is undefined.\n");
-*/
-    return -1;
-  }
-  sprintf(name, "%s%s", base, num);
-  return 0;
-}
-
-/* client Spad server sockets.  Two sockets are created: server[0]
-   is the internet server socket, and server[1] is a UNIX domain socket. */
-int 
-open_server(char *server_name)
-{
-  char *s, name[256];
-
-  init_socks();
-  bsdSignal(SIGPIPE, sigpipe_handler,RestartSystemCalls);
-  if (make_server_name(name, server_name) == -1)
-    return -2;
-  /* create the socket internet socket */
-  server[0].socket = 0;
-/*  server[0].socket = socket(AF_INET, SOCK_STREAM, 0);
-  if (server[0].socket < 0) {
-    server[0].socket = 0;
-  } else {
-    server[0].addr.i_addr.sin_family = AF_INET;
-    server[0].addr.i_addr.sin_addr.s_addr = INADDR_ANY;
-    server[0].addr.i_addr.sin_port = 0;
-    if (bind(server[0].socket, &server[0].addr.i_addr,
-             sizeof(server[0].addr.i_addr))) {
-      perror("binding INET stream socket");
-      server[0].socket = 0;
-      return -1;
-    }
-    length = sizeof(server[0].addr.i_addr);
-    if (getsockname(server[0].socket, &server[0].addr.i_addr, &length)) {
-      perror("getting INET server socket name");
-      server[0].socket = 0;
-      return -1;
-    }
-    server_port = ntohs(server[0].addr.i_addr.sin_port);
-    FD_SET(server[0].socket, &socket_mask);
-    FD_SET(server[0].socket, &server_mask);
-    listen(server[0].socket,5);
-  } */
-  /* Next create the UNIX domain socket */
-  server[1].socket = socket(AF_UNIX, SOCK_STREAM, 0);
-  if (server[1].socket < 0) {
-    perror("opening UNIX server socket");
-    server[1].socket = 0;
-    return -2;
-  } else {
-    server[1].addr.u_addr.sa_family = AF_UNIX;
-    memset(server[1].addr.u_addr.sa_data, 0,
-           sizeof(server[1].addr.u_addr.sa_data));
-    strcpy(server[1].addr.u_addr.sa_data, name);
-    if (bind(server[1].socket, &server[1].addr.u_addr,
-             sizeof(server[1].addr.u_addr))) {
-      perror("binding UNIX server socket");
-      server[1].socket = 0;
-      return -2;
-    }
-    FD_SET(server[1].socket, &socket_mask);
-    FD_SET(server[1].socket, &server_mask);
-    listen(server[1].socket, 5);
-  }
-  s = getenv("SPADSERVER");
-  if (s == NULL) {
-/*    fprintf(stderr, "Not a spad server system\n"); */
-    return -1;
-  }
-  return 0;
-}
-
-int 
-accept_connection(Sock *sock)
-{
-  int client;
-  for(client=0; client<MaxClients && clients[client].socket != 0; client++);
-  if (client == MaxClients) {
-    printf("Ran out of client Sock structures\n");
-    return -1;
-  }
-  clients[client].socket = accept(sock->socket, 0, 0);
-  if (clients[client].socket == -1) {
-    perror("accept");
-    clients[client].socket = 0;
-    return -1;
-  }
-  FD_SET(clients[client].socket, &socket_mask);
-  get_socket_type(clients+client);
-  return clients[client].purpose;
-}
-
-/* reads a the socket purpose declaration for classification */
-void 
-get_socket_type(Sock *sock)
-{
-  sock->pid = get_int(sock);
-  sock->purpose = get_int(sock);
-  sock->remote_fd = get_int(sock);
-  send_int(sock, getpid());
-  send_int(sock, sock->socket);
-  purpose_table[sock->purpose] = sock;
-  switch (sock->purpose) {
-  case SessionManager:
-    break;
-  case ViewportServer:
-    break;
-  case MenuServer:
-    break;
-  case SessionIO:
-/*    redirect_stdio(sock); */
-    break;
-  }
-}
-
-int 
-sock_accept_connection(int purpose)
-{
-  fd_set rd;
-  int ret_val, i, p;
-  if (getenv("SPADNUM") == NULL) return -1;
-  while (1) {
-    rd = server_mask;
-    ret_val = sselect(FD_SETSIZE, (fd_set *)&rd, (fd_set *)0, (fd_set *)0, NULL);
-    if (ret_val == -1) {
-      /* perror ("Select"); */
-      return -1;
-    }
-    for(i=0; i<2; i++) {
-      if (server[i].socket > 0 && FD_ISSET(server[i].socket, &rd)) {
-        p = accept_connection(server+i);
-        if (p == purpose) return 1;
-      }
-    }
-  }
-}
-
-/* direct stdin and stdout from the given socket */
-void 
-redirect_stdio(Sock *sock)
-{
-  int fd;
-/*  setbuf(stdout, NULL);  */
-  fd = dup2(sock->socket, 1);
-  if (fd != 1) {
-    fprintf(stderr, "Error connecting stdout to socket\n");
-    return;
-  }
-  fd = dup2(sock->socket, 0);
-  if (fd != 0) {
-    fprintf(stderr, "Error connecting stdin to socket\n");
-    return;
-  }
-  fprintf(stderr, "Redirected standard IO\n");
-  FD_CLR(sock->socket, &socket_mask);
-}
-
-void
-init_socks(void)
-{
-  int i;
-  FD_ZERO(&socket_mask);
-  FD_ZERO(&server_mask);
-  init_purpose_table();
-  for(i=0; i<2; i++) server[i].socket = 0;
-  for(i=0; i<MaxClients; i++) clients[i].socket = 0;
-}
-
-/* Socket I/O selection called from the BOOT serverLoop function */
-
-int 
-server_switch(void)
-{
-  int ret_val, i, cmd = 0;
-  fd_set rd, wr, ex, fds_mask;
-  FD_ZERO(&rd);
-  FD_ZERO(&wr);
-  FD_ZERO(&ex);
-  fds_mask = server_mask;
-  cmd = 0;
-  if (purpose_table[SessionManager] != NULL) {
-    FD_SET(0, &fds_mask);
-    FD_SET(purpose_table[SessionManager]->socket, &fds_mask);
-  }
-  while (1) {
-    do {
-      if (purpose_table[MenuServer] != NULL) {
-        FD_SET(purpose_table[MenuServer]->socket, &fds_mask);
-      }
-      rd = fds_mask;
-      ret_val = select(FD_SETSIZE, (void *) &rd, (void *) 0, (void *) 0, (void *) 0);
-      if (ret_val == -1) {
-        /* perror ("Select in switch"); */
-        return -1;
-      }
-      for(i=0; i<2; i++) {
-        if (server[i].socket > 0 && (FD_ISSET(server[i].socket, &rd)))
-          accept_connection(server+i);
-      }
-    } while (purpose_table[SessionManager] == NULL);
-    FD_SET(purpose_table[SessionManager]->socket, &fds_mask);
-    if (FD_ISSET(purpose_table[SessionManager]->socket, &rd)) {
-      cmd = get_int(purpose_table[SessionManager]);
-      return cmd;
-    }
-    if (FD_ISSET(0, &rd)) {
-      return CallInterp;
-    }
-    if (purpose_table[MenuServer] != NULL &&
-        (FD_ISSET(purpose_table[MenuServer]->socket, &rd))) {
-      cmd = get_int(purpose_table[MenuServer]);
-      return cmd;
-    }
-  }
-}
-
-void 
-flush_stdout(void)
-{
-  static FILE *fp = NULL;
-  if (fp == NULL) {
-    fp = fdopen(purpose_table[SessionIO]->socket, "w");
-    if (fp == NULL) {
-      perror("fdopen");
-      return;
-    }
-  }
-  fflush(fp);
-}
-
-void 
-print_line(char *s)
-{
-  printf("%s\n", s);
-}
-
-
-typedef union {
-  double        f;
-  long          l[2];
-	} DoubleFloat;
-
-double 
-plus_infinity(void )
-{
-  static int init = 0;
-  static DoubleFloat pinf;
-  if (! init) {
-    pinf.l[0] = 0x7ff00000;
-    pinf.l[1] = 0;
-    init = 1;
-  }
-  return pinf.f;
-}
-
-double 
-minus_infinity(void)
-{
-  static int init = 0;
-  static DoubleFloat minf;
-  if (! init) {
-    minf.l[0] = 0xfff00000L;
-    minf.l[1] = 0;
-    init = 1;
-  }
-  return minf.f;
-}
-
-double 
-NANQ(void)
-{
-  static int init = 0;
-  static DoubleFloat nanq;
-  if (! init) {
-    nanq.l[0] = 0x7ff80000L;
-    nanq.l[1] = 0;
-    init = 1;
-  }
-  return nanq.f;
-}
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/spadcolors.c.pamphlet b/src/lib/spadcolors.c.pamphlet
deleted file mode 100644
index 6e5e12c..0000000
--- a/src/lib/spadcolors.c.pamphlet
+++ /dev/null
@@ -1,635 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib spadcolors.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\begin{chunk}{*}
-
-#include "spadcolors.h"
-
-#include <X11/Xlib.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-
-#include "spadcolors.h1"
-#include "util.h1"
-
-#if 0 
-int colors[100];
-#endif
-
-static unsigned long    pixels[smoothConst+1];
-
-
-/*
- * make sure you define a global variable like int *spadColors; in the main
- * program
- */
-
-/*
- * code taken from Foley and Van Dam "Fundamentals of Interactive Computer
- * Graphics"
- */
-
-
-
-RGB
-HSVtoRGB(HSV hsv)
-{
-    RGB rgb;
-    float h, f, p, q, t;
-    int i;
-    
-    rgb.r = 0.0;
-    rgb.g = 0.0;
-    rgb.b = 0.0;
-    if (hsv.s == 0.0) {
-        rgb.r = rgb.g = rgb.b = hsv.v;
-        return (rgb);
-    }
-    else {
-        if (hsv.h == 360.0) {
-            hsv.h = 0.0;
-        }
-        h = hsv.h / 60;
-        i = floor(h);
-        f = h - i;
-        p = hsv.v * (1 - hsv.s);
-        q = hsv.v * (1 - (hsv.s * f));
-        t = hsv.v * (1 - (hsv.s * (1 - f)));
-        switch (i) {
-          case 0:
-            rgb.r = hsv.v;
-            rgb.g = t;
-            rgb.b = p;
-            break;
-          case 1:
-            rgb.r = q;
-            rgb.g = hsv.v;
-            rgb.b = p;
-            break;
-          case 2:
-            rgb.r = p;
-            rgb.g = hsv.v;
-            rgb.b = t;
-            break;
-          case 3:
-            rgb.r = p;
-            rgb.g = q;
-            rgb.b = hsv.v;
-            break;
-          case 4:
-            rgb.r = t;
-            rgb.g = p;
-            rgb.b = hsv.v;
-            break;
-          case 5:
-            rgb.r = hsv.v;
-            rgb.g = p;
-            rgb.b = q;
-            break;
-        }
-        return (rgb);
-    }
-}
-
-float
-value(float n1, float n2, float hue)
-{
-    float v;
-
-    if (hue > 360.0)
-        hue -= 360.0;
-    if (hue < 0.0)
-        hue += 360.0;
-    if (hue < 60.0) {
-        v = n1 + (n2 - n1) * hue / 60.0;
-    }
-    else {
-        if (hue < 180.0)
-            v = n2;
-        else {
-            if (hue < 240.0)
-                v = n1 + (n2 - n1) * (240.0 - hue) / 60.0;
-            else
-                v = n1;
-        }
-    }
-    return (v);
-}
-
-
-
-RGB
-HLStoRGB(HLS hls)
-{
-    RGB rgb;
-    float m1, m2;
-
-    if (hls.l <= 0.5) {
-        m2 = hls.l * (1.0 + hls.s);
-    }
-    else {
-        m2 = hls.l + hls.s - hls.l * hls.s;
-    }
-    m1 = 2.0 * hls.l - m2;
-    rgb.r = value(m1, m2, hls.h + 120.0);
-    rgb.g = value(m1, m2, hls.h);
-    rgb.b = value(m1, m2, hls.h - 120.0);
-
-    return (rgb);
-}
-
-
-/******************************************************
- * int makeColors(dsply,scrn,colorMap,total_Shades)    *
- *                                                    *
- * This routine tries to allocate an adequate color   *
- * map to be used by all the AXIOM applications       *
- * that are to be run under X Windows that use        *
- * colors that may be user-definable (e.g. viewports, *
- * HyperTeX, etc). All these application should call  *
- * this routine and then access the colors with the   *
- * the returned color map.                            *
- * For example, the following creates the map and     *
- * then sets the foreground color for a GC:           *
- *                                                    *
- *   i = makeColors(d,s,&cmap,&spadColors,&ts);       *
- *   XSetForegroundColor(d,gc,spadColors[3]);         *
- *                                                    *
- * where                                              *
- * spadColors is of type (unsigned long *)            *
- * i (the return value) is the total number of colors *
- *   allocated.                                       *
- * ts is the total number of shades for each hue      *
- *                                                    *
- * KF 6/14/90 (modification)                          *
- * makeColors creates color table once only.          *
- * hiya is of type static.                            *
- ******************************************************/
-
-int
-makeColors(Display *dsply, int scrn, Colormap *colorMap, 
-           unsigned long **colorIndex, int *total_Shades)
-{
-
-    int h, s;
-    static unsigned long *hiya; /* keep colortable around for next time */
-    HSV hsv;
-    RGB rgb;
-    XColor color;
-    int okay = yes;             /* is true (1) so long as XAllocColor is
-                                 * working ok. if 0, then we ran out of room
-                                 * on the color table. */
-    int colorNum;
-
-    /* shade5 definition */
-
-    static float saturations[5] = {0.90, 0.80, 0.74, 0.50, 0.18};
-    static float values[5] = {0.38, 0.58, 0.75, 0.88, 0.94};
-
-    /* static float values[5]      = {0.34, 0.52, 0.80, 0.88, 0.94}; */
-
-    /*     fprintf(stderr,"makeColors called\n");*/
-
-    /* printf("making new colors....\n"); */
-    *total_Shades = totalShadesConst;
-
-    /* space for color table */
-    hiya = (unsigned long *) saymem("spadcolors30.c", 
-             totalHuesConst * (*total_Shades) + 2, sizeof(unsigned long));
-    *colorIndex = hiya;
-
-    for (h = 0, colorNum = 0; okay && h < 60; h += (hueStep - 6)) {
-        for (s = 0; okay && s < *total_Shades; s++) {
-            hsv.h = h;
-            hsv.s = saturations[s];
-            hsv.v = values[s];
-            rgb = HSVtoRGB(hsv);
-            color.red    = rgb.r *((1<<16)-1);
-            color.green  = rgb.g *((1<<16)-1);
-            color.blue   = rgb.b *((1<<16)-1);
-            color.flags = DoRed | DoGreen | DoBlue;
-            /*
-            fprintf(stderr,"%f\t%f\t%f\n",rgb.r,rgb.g,rgb.b);
-            fprintf(stderr,"%d\t%d\t%d\n",
-                    color.red,color.green,color.blue);
-              */
-            if ((okay = XAllocColor(dsply, *colorMap, &color)))
-                hiya[colorNum++] = color.pixel; /* hiya points to table */
-        }                       /* for s */
-    }                           /* for h */
-    for (h = 60; okay && h < 180; h += 20) {
-        for (s = 0; okay && s < *total_Shades; s++) {
-            hsv.h = h;
-            hsv.s = saturations[s];
-            hsv.v = values[s];
-            rgb = HSVtoRGB(hsv);
-
-            color.red    = rgb.r *((1<<16)-1);
-            color.green  = rgb.g *((1<<16)-1);
-            color.blue   = rgb.b *((1<<16)-1);
-            color.flags = DoRed | DoGreen | DoBlue;
-            /* 
-            fprintf(stderr,"%f\t%f\t%f\n",rgb.r,rgb.g,rgb.b);
-            fprintf(stderr,"%d\t%d\t%d\n",
-                    color.red,color.green,color.blue);
-            */
-
-            if ((okay = XAllocColor(dsply, *colorMap, &color)))
-                hiya[colorNum++] = color.pixel;
-        }
-    }
-
-    for (h = 180; okay && h <= 300; h += hueStep) {
-        for (s = 0; okay && s < *total_Shades; s++) {
-            hsv.h = h;
-            hsv.s = saturations[s];
-            hsv.v = values[s];
-            rgb = HSVtoRGB(hsv);
-
-            color.red    = rgb.r *((1<<16)-1);
-            color.green  = rgb.g *((1<<16)-1);
-            color.blue   = rgb.b *((1<<16)-1);
-            color.flags = DoRed | DoGreen | DoBlue;
-            /* 
-            fprintf(stderr,"%f\t%f\t%f\n",rgb.r,rgb.g,rgb.b);
-            fprintf(stderr,"%d\t%d\t%d\n",
-                    color.red,color.green,color.blue);
-               */
-            if ((okay = XAllocColor(dsply, *colorMap, &color)))
-                hiya[colorNum++] = color.pixel;
-        }
-    }
-
-    hiya[colorNum++] = BlackPixel(dsply, scrn);
-    hiya[colorNum++] = WhitePixel(dsply, scrn);
-
-    if (colorNum < (totalShadesConst * totalHuesConst + 2)) {
-        free(*colorIndex);
-        fprintf(stderr,
-           "    > Warning: cannot allocate all the necessary colors");
-        fprintf(stderr," - switching to monochrome mode\n");
-        *colorIndex = (unsigned long *) 
-           saymem("while allocating the colormap for AXIOM ", 
-                  2, sizeof(unsigned long));
-        (*colorIndex)[0] = BlackPixel(dsply, scrn);
-        (*colorIndex)[1] = WhitePixel(dsply, scrn);
-        return (-1);
-    }
-
-    return (colorNum);
-}
-
-#ifdef OLD
-/***********************************************************************
-  KF 6/14/90
-  INPUT: display dsply, screen scrn
-  OUTPUT: a pointer to the permutation color vector (permIndex)
-  PURPOSE: when called for the first time, this procedure creates a
-       permutation vector of the color table spadColor.  It
-       returns the pointer to this vector for subsequent calls.
-
-***********************************************************************/
-
-int
-makePermVector(Display *dsply, int scrn, unsigned long **permIndex)
-{
-    static int firstTime = yes;
-    unsigned long *spadColorsToo;
-    static unsigned long *pIndex;
-    Colormap cmap;
-    int num_colors;
-    int i, ts;
-
-    if (firstTime) {
-
-        /* initialization */
-
-        cmap = DefaultColormap(dsply, scrn);    /* what are other cmaps?? */
-        pIndex = (unsigned long *) 
-          saymem("makePermVector", Colorcells, sizeof(unsigned long));
-
-        /* get spadColors table */
-
-        if ((num_colors = 
-              makeColors(dsply, scrn, &cmap, &spadColorsToo, &ts)) < 0) {
-            printf("num_colors < 0!!\n");
-            exit(-1);
-        }
-
-        /* initialize unused slots in permutation vector */
-
-        for (i = 0; i < spadColorsToo[0]; i++)
-            pIndex[i] = 0;
-        for (i = num_colors; i < Colorcells; i++)
-            pIndex[i] = 0;
-
-        /* make permutation vector */
-
-        for (i = 0; i < num_colors; i++)
-            pIndex[spadColorsToo[i]] = i;
-
-        firstTime = no;
-    }
-
-    *permIndex = pIndex;
-    return (Colorcells);
-}
-
-#endif
-
-/******************************************************
- * int makeNewColorMap(dsply,colorMap,smoothHue)      *
- *                                                    *
- * This routine tries to allocate an adequate color   *
- * map to be used by the AXIOM smooth shading         *
- * application that is to be run under X Windows.     *
- * The colors are allocated from available space in   *
- * the colorMap and returned in the array pixels.     *
- * The size of the array is determined by smoothConst *
- * which is the number of shades desired.  The colors *
- * returned are variations in lightness of the hue    *
- * smoothHue indicated on the control panel Colormap. *
- *                                                    *
- * If smoothConst colors can be allocated the value   *
- * 1 is returned, otherwise returns 0                 *
- *                                                    *
- ******************************************************/
-
-
-int
-makeNewColorMap(Display *dsply, Colormap colorMap, int smoothHue)
-
-{
-
-    int count, i;
-    float lightness;
-    RGB rgb;
-    XColor xcolor;
-    HLS hls;
-
-    count = 0;
-    /* i = 0 .. smoothConst */
-    for (i = 0; i < (smoothConst + 1); i++) {
-        /* lightnes = 0.0 .. 1.0 */
-        lightness = (float) (i) / (float) (smoothConst);  
-        hls.h = (float) smoothHue;
-        hls.l = lightness;
-        hls.s = saturation;
-        rgb = HLStoRGB(hls);
-
-        xcolor.red    = rgb.r *((1<<16)-1);
-        xcolor.green  = rgb.g *((1<<16)-1);
-        xcolor.blue   = rgb.b *((1<<16)-1);
-        xcolor.flags = DoRed | DoGreen | DoBlue;
-        /* 
-        fprintf(stderr,"%f\t%f\t%f\n",rgb.r,rgb.g,rgb.b);
-        fprintf(stderr,"%d\t%d\t%d\n",
-                xcolor.red,xcolor.green,xcolor.blue);
-        */
-        if (XAllocColor(dsply, colorMap, &xcolor)) {
-            pixels[count] = xcolor.pixel;
-            count++;
-        }
-    }
-    /* count says how many succeeded */
-    if (count != (smoothConst+1) ) {
-
-      /* we have failed to get all of them - free the ones we got */
-
-      FreePixels(dsply,colorMap,count);
-      return (0);
-    }
-    return (1);
-}
-
-
-
-/******************************************************
- * unsigned long XPixelColor(num)                     *
- *                                                    *
- * XPixelColor is a straight forward function that    *
- * merely returns the XColor value desired within     *
- * the pixels array.  For smooth shading, given an    *
- * intensity from 0..1, scaling by the number of      *
- * values in the array will return the location in    *
- * pixels[] of the desired color for that intensity.  *
- *                                                    *
- ******************************************************/
-
-unsigned long
-XPixelColor(int num)
-
-{
-    if (num < 0)
-        num = 0;
-    return (pixels[num]);
-}
-
-
-/******************************************************
- * FreePixels(dsply,colorMap,num)                 *
- *                                                    *
- * FreePixels is a call to XFreeColors which frees    *
- * previously allocated colors for the indicated      *
- * colorMap.  If it cannot free the number of colors  *
- * given by num a BadAccess error will crash the      *
- * viewport process.  This should ONLY be used if     *
- * it can be guaranteed that there will be num colors *
- * to free in colorMap. return 0 == success           *
- *                                                    *
- ******************************************************/
-
-
-void
-FreePixels(Display *dsply, Colormap colorMap, int num)
-{
-
-  XFreeColors(dsply, colorMap, pixels, num, 0);
-}
-
-
-
-/******************************************************
- * int AllocCells(dsply,colorMap,smoothHue)           *
- *                                                    *
- * Use either makeNewColormap() OR AllocCells().      *
- * This routine tries to allocate an adequate color   *
- * map to be used by the AXIOM smooth shading         *
- * application that is to be run under X Windows.     *
- * The colors are allocated from available space in   *
- * the colorMap and returned in the array pixels.     *
- * The size of the array is determined by smoothConst *
- * which is the number of shades desired.  The colors *
- * returned are variations in lightness of the hue    *
- * smoothHue indicated on the control panel Colormap. *
- *                                                    *
- * It is different from makeNewColormap() in that     *
- * the cells are read/write, and if it cannot alloc   *
- * all the colors desired it doesn't allocate any.    *
- *                                                    *
- ******************************************************/
-
-
-int
-AllocCells(Display *dsply, Colormap colorMap, int smoothHue)
-\end{chunk}
-
-This routine used to have the following code block. However this
-code block makes no sense. To see why you need to know that an
-XColor object looks like:
-
-\begin{verbatim}
-/*
- * Data structure used by color operations
- */
-typedef struct {
-        unsigned long pixel;
-        unsigned short red, green, blue;
-        char flags;  /* do_red, do_green, do_blue */
-        char pad;
-} XColor;
-\end{verbatim}
-This routine used to set the values of all of the elements of the XColor struct
-except [[pixel]]. This is usually done to specify a desired color in RGB
-values. To try to get a pixel value close to that color you call XAllocColor.
-This routine sets up the desired color values but it never asks for the pixel
-(which is really an index into the colormap of the nearest color) value that
-corresponds to the desired color. In fact it uses pixel without ever giving
-it a value. I've rewritten that code.
-\begin{verbatim}
-{
-    unsigned long plane_masks[1];
-    int i, count;
-    float lightness;
-    RGB rgb;
-    XColor xcolor;
-    HLS hls;
-
-    count = 0;
-    for (i = 0; i < (smoothConst + 1); i++) {
-        lightness = (float) (i) / (float) (smoothConst);
-        hls.h = (float) smoothHue;
-        hls.l = lightness;
-        hls.s = saturation;
-        rgb = HLStoRGB(hls);
-        xcolor.red    = rgb.r *((1@<<16)-1);
-        xcolor.green  = rgb.g *((1@<<16)-1);
-        xcolor.blue   = rgb.b *((1@<<16)-1);
-        xcolor.flags = DoRed | DoGreen | DoBlue;
-        /*
-        fprintf(stderr,"%f\t%f\t%f\n",rgb.r,rgb.g,rgb.b);
-        fprintf(stderr,"%d\t%d\t%d\n",
-                xcolor.red,xcolor.green,xcolor.blue);
-        */
-        pixels[i] = xcolor.pixel;
-        count++;
-    }
-    if (XAllocColorCells(dsply, colorMap, False, 
-                   plane_masks, 0, pixels, smoothConst + 1)) {
-        return (smoothConst + 1);
-    }
-    else {
-        return (0);
-    }
-}
-\end{verbatim}
-\begin{chunk}{*}
-{
-    unsigned long plane_masks[1];
-    int i, count;
-    float lightness;
-    RGB rgb;
-    XColor xcolor;
-    HLS hls;
-
-    count = 0;
-    for (i = 0; i < (smoothConst + 1); i++) {
-        lightness = (float) (i) / (float) (smoothConst);
-        hls.h = (float) smoothHue;
-        hls.l = lightness;
-        hls.s = saturation;
-        rgb = HLStoRGB(hls);
-        xcolor.red    = rgb.r *((1<<16)-1);
-        xcolor.green  = rgb.g *((1<<16)-1);
-        xcolor.blue   = rgb.b *((1<<16)-1);
-        xcolor.flags = DoRed | DoGreen | DoBlue;
-        /*
-        fprintf(stderr,"%f\t%f\t%f\n",rgb.r,rgb.g,rgb.b);
-        fprintf(stderr,"%d\t%d\t%d\n"
-                ,xcolor.red,xcolor.green,xcolor.blue);
-        */
-\end{chunk}
-
-Here I've modified the code to actually as for the pixel (colormap index) that
-most closely matches our requested RGB values.
-
-\begin{chunk}{*}
-        if (XAllocColor(dsply, colorMap, &xcolor)) { 
-            pixels[count] = xcolor.pixel;
-            count++;
-        }
-    }
-    /* count says how many succeeded */
-    if (count != (smoothConst+1) ) {
-      /* we have failed to get all of them - free the ones we got */
-      FreePixels(dsply,colorMap,count);
-      return (0);
-    }
-    if (XAllocColorCells(dsply, colorMap, False, 
-                plane_masks, 0, pixels, smoothConst + 1)) {
-        return (smoothConst + 1);
-    }
-    else {
-        return (0);
-    }
-}
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/util.c.pamphlet b/src/lib/util.c.pamphlet
deleted file mode 100644
index d6b6522..0000000
--- a/src/lib/util.c.pamphlet
+++ /dev/null
@@ -1,170 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib util.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\newpage
-\begin{chunk}{*}
-
-#include <stdlib.h>
-\end{chunk}
-
-The MACOSX platform is broken because no matter what you do it seems to
-include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
-systems these files include themselves which causes an infinite regression
-of includes that fails. GCC gracefully steps over that problem but the
-build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
-of files are badly broken with respect to the [[/usr/include]] versions.
-
-\begin{chunk}{*}
-#if defined(MACOSXplatform)
-#include "/usr/include/unistd.h"
-#else
-#include <unistd.h>
-#endif
-#include <sys/types.h>
-#include <stdio.h>
-#include <errno.h>
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include "view.h"
-
-#include "util.h1"
-
-int
-checker(int code, int lineNumber, char *errorStr)
-{
-  if (code < 0) {
-    fprintf(stderr, "Error occured during %s\n", errorStr);
-    fprintf(stderr, "Error code of %d\n", errno);
-    fprintf(stderr, "Error in line number %d of process %d\n", 
-            lineNumber, getpid());
-    perror("");
-  }
-  return (code);
-}
-
-char *
-getmemWithLine(int nbytes, char *str, int lineNum)
-{
-  char *p;
-
-  p = (char *) malloc(nbytes);
-  if (!p) {
-    fprintf(stderr, 
-      "getmem: Could not get %d bytes for %s at line %d\n", 
-      nbytes, str, lineNum);
-    exit(99);
-  }
-  return p;
-}
-
-char *
-saymemWithLine(char *str, int num, int size, int lineNum)
-{
-  char *p;
-  p = getmemWithLine(num * size, str, lineNum);
-  return p;
-}
-
-void
-myfree(void *p, int size)
-{
-    free(p);
-}
-
-XPoint
-getWindowPositionXY(Display *display, Window w)
-{
-  XPoint position;
-  Window rootW, parentW, *childrenWs, tmpW;
-  unsigned int nChildren;
-  XWindowAttributes windowAttrib;
-  int screen, tmp = 1;
-
-  screen = DefaultScreen(display);
-  tmpW = w;
-  while (tmp) {
-    XQueryTree(display, tmpW, &rootW, &parentW, &childrenWs, &nChildren);
-    XFree((char *)childrenWs);
-    if (parentW == RootWindow(display, screen))
-      tmp = 0;
-    else
-      tmpW = parentW;
-  }
-  XGetWindowAttributes(display, tmpW, &windowAttrib);
-  position.x = (short) windowAttrib.x;
-  position.y = (short) windowAttrib.y;
-  return (position);
-}
-
-XPoint
-getWindowSizeXY(Display *display,Window w)
-{
-  XPoint size;
-  Window rootW, parentW, *childrenWs, tmpW;
-  unsigned int nChildren;
-  XWindowAttributes windowAttrib;
-  int screen, tmp = 1;
-
-  screen = DefaultScreen(display);
-  tmpW = w;
-  while (tmp) {
-    XQueryTree(display, tmpW, &rootW, &parentW, &childrenWs, &nChildren);
-    XFree((char *)childrenWs);
-    if (parentW == RootWindow(display, screen))
-      tmp = 0;
-    else
-      tmpW = parentW;
-  }
-  XGetWindowAttributes(display, tmpW, &windowAttrib);
-  size.x = (short) windowAttrib.width;
-  size.y = (short) windowAttrib.height;
-  return (size);
-}
-\end{chunk}
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\newpage
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/wct.c.pamphlet b/src/lib/wct.c.pamphlet
deleted file mode 100644
index b88f880..0000000
--- a/src/lib/wct.c.pamphlet
+++ /dev/null
@@ -1,769 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib wct.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\newpage
-\begin{chunk}{*}
-
-/*
- * Word completion.
- *
- *
- * Word completion is driven from a list of completion tables. Each table
- * contains a list of words.
- *
- */
-
-
-#include <stdio.h>
-#include <stdlib.h>
-\end{chunk}
-
-The MACOSX platform is broken because no matter what you do it seems to
-include files from [[/usr/include/sys]] ahead of [[/usr/include]]. On linux
-systems these files include themselves which causes an infinite regression
-of includes that fails. GCC gracefully steps over that problem but the
-build fails anyway. On MACOSX the [[/usr/include/sys]] versions 
-of files are badly broken with respect to the [[/usr/include]] versions.
-
-\begin{chunk}{*}
-#if defined(MACOSXplatform)
-#include "/usr/include/unistd.h"
-#else
-#include <unistd.h>
-#endif
-#include <string.h>
-#include <fcntl.h>
-#if defined(MACOSXplatform)
-#include "/usr/include/time.h"
-#else
-#include <time.h>
-#endif
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-/* #define PINFO *//* A flag to suppress printing of the file info */
-
-#define WCT                     /* A flag needed because ctype.h stole some
-                                 * of my constants */
-#include "edible.h"
-
-#define MAX_PREFIX 1024
-#define strneql(a,b,n)  (*(a) == *(b) && !strncmp((a),(b),(n)))
-#define Delimiter(c) (! isalnum(c) && c != '%' && c != '!' && c != '?' && c != '_')
-
-
-#include "wct.h1"
-#include "prt.h1"
-#include "edin.h1"
-
-
-
-static Wct *pwct = 0;
-static Wix *pwix;
-static Wix curr_wix;
-static char curr_prefix[MAX_PREFIX];
-static Wct *pHeadwct;
-
-time_t
-ftime(char *path)
-{
-    int rc;
-    struct stat stbuf;
-
-    rc = stat(path, &stbuf);
-    if (rc == -1)
-        fatal("Cannot deterimine status of %s.", path);
-
-    return stbuf.st_mtime;
-}
-
-off_t
-fsize(char *path)
-{
-    int rc;
-    struct stat stbuf;
-
-    rc = stat(path, &stbuf);
-    if (rc == -1)
-        fatal("Cannot deterimine status of %s.", path);
-
-    return stbuf.st_size;
-}
-
-
-/*
- * Scan a word completion table for a particular word.
- */
-
-
-Wix *
-scanWct(Wct *pwct, char *prefix)
-{
-    long fmod;
-    int preflen, i, wc;
-    char **wv;
-
-    preflen = strlen(prefix);
-    strncpy(curr_prefix, prefix, MAX_PREFIX);
-
-    pHeadwct = pwct;
-    curr_wix.pwct = 0;
-    curr_wix.word = 0;
-
-    for (; pwct; pwct = pwct->next) {
-        curr_wix.pwct = pwct;
-
-
-
-        fmod = ftime(pwct->fname);
-        if (fmod > pwct->ftime)
-            reintern1Wct(pwct);
-
-        wv = pwct->wordv;
-        wc = pwct->wordc;
-        for (i = 0; i < wc; i++) {
-            curr_wix.word = i;
-            if (strneql(wv[i], prefix, preflen))
-                return &curr_wix;
-        }
-    }
-    return 0;
-}
-
-Wix *
-rescanWct(void)
-{
-  Wct *pwct, *start_pwct;
-  int preflen, start_word, i, wc;
-  char **wv, *prefix;
-
-  start_pwct = curr_wix.pwct;
-  start_word = curr_wix.word;
-
-  if (!start_pwct) return(0);
-  prefix = curr_prefix;
-  preflen = strlen(prefix);
-
-  /*
-   * Finish the current structure.
-   */
-
-  pwct = start_pwct;
-
-  curr_wix.pwct = pwct;
-  wv = pwct->wordv;
-  wc = pwct->wordc;
-  for (i = start_word + 1; i < wc; i++) {
-    curr_wix.word = i;
-    if (strneql(wv[i], prefix, preflen))
-      return &curr_wix;
-  }
-
-  /*
-   * Finish to the end of the list, doing whole structures.
-   */
-  for (pwct = pwct->next; pwct; pwct = pwct->next) {
-    curr_wix.pwct = pwct;
-
-    wv = pwct->wordv;
-    wc = pwct->wordc;
-    for (i = 0; i < wc; i++) {
-      curr_wix.word = i;
-      if (strneql(wv[i], prefix, preflen))
-	return &curr_wix;
-    }
-  }
-
-  /*
-   * Restart at beginning, doing whole structures.
-   */
-  for (pwct = pHeadwct; pwct != start_pwct; pwct = pwct->next) {
-    curr_wix.pwct = pwct;
-
-    wv = pwct->wordv;
-    wc = pwct->wordc;
-    for (i = 0; i < wc; i++) {
-      curr_wix.word = i;
-      if (strneql(wv[i], prefix, preflen))
-	return &curr_wix;
-    }
-  }
-
-  /*
-   * Do beginning half of the start structure.
-   */
-  curr_wix.pwct = pwct;
-  wv = pwct->wordv;
-  wc = pwct->wordc;
-  for (i = 0; i <= start_word; i++) {
-    curr_wix.word = i;
-    if (strneql(wv[i], prefix, preflen))
-      return &curr_wix;
-  }
-
-  /* Not found? */
-  return 0;
-}
-
-/*
- * Summarize a table.
- */
-void
-skimWct(Wct *pwct)
-{
-  while (pwct) {
-#ifdef PINFO
-    skim1Wct(pwct);
-#endif
-    pwct = pwct->next;
-  }
-}
-
-void 
-skim1Wct(Wct *pwct)
-{
-#define NHEAD    13
-#define NTAIL    7
-
-  int cc;
-
-  printf("%-10s", pwct->fname);
-  printTime((long *)&(pwct->ftime));
-  cc = skimString(pwct->fimage, pwct->fsize, NHEAD, NTAIL);
-  printf("%s", "            " + (cc - (NHEAD + NTAIL)));
-  printf(" [%d w, %ld c]", pwct->wordc, (long)(pwct->fsize));
-  printf("\n");
-
-#ifdef SHOW_WORDS
-  {
-    int i;
-    char **wv;
-
-    for (i = 1, wv = pwct->wordv; *wv; i++, wv++) {
-      printf("%5d: %s\n", i, *wv);
-    }
-  }
-#endif
-}
-
-void
-printTime(long *clock)
-{
-    struct tm *tm;
-
-    tm = localtime((time_t *)clock);
-    printf("%.2d/%.2d/%.2d %.2d:%.2d:%.2d ",
-           tm->tm_year, tm->tm_mon + 1, tm->tm_mday,
-           tm->tm_hour, tm->tm_min, tm->tm_sec);
-}
-
-int
-skimString(char *s, int slen,int  nhead,int  ntail)
-{
-    int spos, tlen, i, cc;
-
-    cc = printf("\"");
-    for (spos = 0; spos < slen && cc <= nhead; spos++)
-        cc += prChar(s[spos]);
-
-    /* Assume same tail has the same multi-character format ratio. */
-    tlen = ntail * ((1.0 * spos) / nhead);
-
-    if (spos + tlen >= slen)
-        for (; spos < slen; spos++)
-            cc += prChar(s[spos]);
-    else {
-        cc += printf("\"...\"");
-        for (i = slen - tlen; i < slen; i++)
-            cc += prChar(s[i]);
-    }
-    cc += printf("\"");
-    return cc;
-}
-
-int
-prChar(int c)
-{
-    if (c == '\n')
-        return printf("\\n");
-    if (c == '\t')
-        return printf("\\t");
-    if (c == '\b')
-        return printf("\\b");
-    if (c == '"')
-        return printf("\\\"");
-    if (iscntrl(c))
-        return printf("^%c", (c + 0100) % 0200);
-    if (isascii(c))
-        return printf("%c", c);
-
-    return printf("\\%d", c);
-}
-
-Wct *
-reread1Wct(Wct *pwct)
-{
-    int fd, rc;
-
-    /* Check information about the file. */
-    pwct->fsize = fsize(pwct->fname);
-    pwct->ftime = ftime(pwct->fname);
-
-    /* Allocate space for file image */
-    if (pwct->fimage)
-        free(pwct->fimage);
-    pwct->fimage = (char *) malloc(pwct->fsize + 1);
-    if (pwct->fimage == 0)
-        sfatal("Cannot allocate new table.");
-    pwct->fimage[pwct->fsize] = 0;
-
-    /* Read file into buffer. */
-    fd = open(pwct->fname, O_RDONLY);
-    if (fd == -1)
-        fatal("Cannot read file %s.", pwct->fname);
-    rc = read(fd, pwct->fimage, pwct->fsize);
-    if (rc != pwct->fsize)
-        fatal("Did not read all of file %s.", pwct->fname);
-
-    return pwct;
-}
-
-Wct *
-read1Wct(char *fname)
-{
-    Wct *pwct;
-
-    /* Allocate a new link for this file. */
-    pwct = (Wct *) malloc(sizeof(Wct));
-    if (pwct == 0)
-        sfatal("Cannot allocate new table.");
-
-    pwct->fname = fname;
-    pwct->wordc = 0;
-    pwct->wordv = 0;
-    pwct->fimage = 0;
-    pwct->next = 0;
-
-    return reread1Wct(pwct);
-}
-
-Wct *
-nconcWct(Wct *pwct,Wct * qwct)
-{
-    Wct *p0 = pwct;
-
-    if (!p0)
-        return qwct;
-
-    while (pwct->next)
-        pwct = pwct->next;
-    pwct->next = qwct;
-
-    return p0;
-}
-
-void
-sortWct(Wct *pwct)
-{
-    while (pwct) {
-        sort1Wct(pwct);
-        pwct = pwct->next;
-    }
-}
-
-void 
-sort1Wct(Wct *pwct)
-{
-    qsort((char *) pwct->wordv, pwct->wordc,
-          sizeof(*(pwct->wordv)), mystrcmp);
-}
-
-int
-mystrcmp(const void *s1,const void * s2)
-{
-    return strcmp(*(char **)s1, *(char **)s2);
-}
-
-/*
- * Break wct struct into words.
- */
-
-void 
-burstWct(Wct *pwct)
-{
-    while (pwct) {
-        burst1Wct(pwct);
-        pwct = pwct->next;
-    }
-}
-
-void 
-burst1Wct(Wct *pwct)
-{
-    char *s, **wv;
-    int i, j, inword = 0;
-
-
-    for (s = pwct->fimage, i = 0; i < pwct->fsize; s++, i++) {
-        if (isspace(*s) || iscntrl(*s)) {
-            *s = 0;
-            inword = 0;
-        }
-        else if (!inword) {
-            inword = 1;
-            pwct->wordc++;
-        }
-    }
-
-    if (pwct->wordv)
-        free(pwct->wordv);
-    pwct->wordv = (char **) calloc(pwct->wordc + 1, sizeof(char *));
-    if (!pwct->wordv)
-        fatal("Could not make word list for %s.", pwct->fname);
-
-    s = pwct->fimage;
-    i = 0;
-    for (wv = pwct->wordv, j = 0; j < pwct->wordc; wv++, j++) {
-        while (i < pwct->fsize && !s[i])
-            i++;
-        *wv = s + i;
-        while (i < pwct->fsize && s[i])
-            i++;
-    }
-    *wv = 0;
-}
-
-Wct *
-intern1Wct(char *fname)
-{
-    Wct *pwct;
-
-    pwct = read1Wct(fname);
-    burst1Wct(pwct);
-    return pwct;
-}
-
-void 
-reintern1Wct(Wct *pwct)
-{
-    reread1Wct(pwct);
-    burst1Wct(pwct);
-}
-
-void 
-sfatal(char *s)
-{
-    fatal("%s", s);
-}
-
-void 
-fatal(char *fmt,char * s)
-{
-    static char fbuf[256];
-
-    sprintf(fbuf, fmt, s);
-
-    perror(fbuf);
-    exit(1);
-}
-
-
-
-/* load up the wct database */
-void 
-load_wct_file(char *fname)
-{
-    pwct = nconcWct(intern1Wct(fname), pwct);
-}
-
-void
-skim_wct(void)
-{
-    skimWct(pwct);
-}
-
-/*
- * This routine is called when a tab is hit. It simply takes the current
- * buffer and tries to find a completion of the last word on the line in the
- * data base.
- */
-
-
-void 
-rescan_wct(void)
-{
-    int b = curr_pntr - 1;
-    int old_len;
-    int new_len;
-    int diff;
-    int i;
-    int ncs = 0;
-
-    /*
-     * first thing I should do is find my way back to the beginning of the
-     * word
-     */
-    while (b && !Delimiter(buff[b]))
-        b--;
-    if (Delimiter(buff[b]))
-        b++;
-
-    old_len = curr_pntr - b;
-
-    pwix = rescanWct();
-
-    if (!pwix) {
-        putchar(_BELL);
-        fflush(stdout);
-    }
-    else {
-        Wct *pwct = pwix->pwct;  /* start replacing it */
-
-        new_len = strlen(pwct->wordv[pwix->word]);
-        if (new_len > old_len) {
-
-            /*
-             * I have to just slide the characters forward a bit, stuff in
-             * the new characters, and then adjust curr_pntr
-             */
-            diff = new_len - old_len;
-            if (curr_pntr != buff_pntr) {
-                forwardcopy(&buff[curr_pntr + diff],
-                            &buff[curr_pntr],
-                            buff_pntr - curr_pntr);
-                forwardflag_cpy(&buff_flag[curr_pntr + diff],
-                                &buff_flag[curr_pntr],
-                                buff_pntr - curr_pntr);
-            }
-            buff_pntr += diff;
-            ncs = curr_pntr + diff;
-
-            /* Now insert the new word */
-            for (i = 0; i < new_len; i++)
-                buff[b + i] = (pwct->wordv[pwix->word])[i];
-
-            /* move cursor to the beginning of the word */
-            for (; curr_pntr != b; curr_pntr--)
-                putchar(_BKSPC);
-
-            /** now print the characters on the rest of the line **/
-            printbuff(curr_pntr, buff_pntr - curr_pntr);
-
-            /* now move bcak the number of characters I want to */
-            for (i = buff_pntr; i != ncs; i--)
-                putchar(_BKSPC);
-
-            fflush(stdout);
-
-            curr_pntr = ncs;
-        }
-        else if (new_len < old_len) {
-            /* this time I simply copy backwards and do the substituting */
-            diff = old_len - new_len;
-            strncpy(&buff[curr_pntr - diff],
-                    &buff[curr_pntr],
-                    buff_pntr - curr_pntr);
-            flagncpy(&buff_flag[curr_pntr - diff],
-                    &buff_flag[curr_pntr],
-                    buff_pntr - curr_pntr);
-            buff_pntr -= diff;
-            ncs = curr_pntr - diff;
-
-            /* Now insert the new word */
-            for (i = 0; i < new_len; i++)
-                buff[b + i] = (pwct->wordv[pwix->word])[i];
-
-            /* move cursor to the beginning of the word */
-            for (; curr_pntr != b; curr_pntr--)
-                putchar(_BKSPC);
-
-            /** now print the characters on the rest of the line **/
-            printbuff(b, buff_pntr - b);
-
-            /* now blank out the characters out on the end of this line */
-            for (i = 0; i < diff; i++)
-                myputchar(' ');
-
-            /* now move back the number of characters I want to */
-            for (i = buff_pntr + diff; i != ncs; i--)
-                putchar(_BKSPC);
-
-            fflush(stdout);
-
-            curr_pntr = ncs;
-        }
-        else {
-            diff = 0;
-            ncs = curr_pntr;
-            /* Now insert the new word */
-            for (i = 0; i < new_len; i++)
-                buff[b + i] = (pwct->wordv[pwix->word])[i];
-
-            /* move cursor to the beginning of the word */
-            for (; curr_pntr != b; curr_pntr--)
-                putchar(_BKSPC);
-
-            /** now print the characters on the rest of the line **/
-            printbuff(curr_pntr, buff_pntr - curr_pntr);
-
-            /* now move back the number of characters I want to */
-            for (i = buff_pntr; i != ncs; i--)
-                putchar(_BKSPC);
-
-            fflush(stdout);
-
-            curr_pntr = ncs;
-        }
-    }
-}
-
-void
-find_wct(void)
-{
-
-    char search_buff[100];
-    char *filler = search_buff;
-    int b = curr_pntr - 1;
-    int e = curr_pntr;
-    int ne = 0;
-    int st;
-    Wix *pwix;
-    int curr_len;
-    int new_len;
-    int diff;
-    int i;
-
-    /*
-     * First thing I do is try and construct the string to be searched for.
-     * Basically I just start from the curr_pntr and search backward until I
-     * find a blank. Once I find a blank I copy forward until I get back to
-     * curr_pntr;
-     */
-    if (!curr_pntr) {
-        putchar(_BELL);
-        return;
-    }
-    /* then get back to the first blank or back to the beginning */
-    while (b && !Delimiter(buff[b]))
-        b--;
-    if (Delimiter(buff[b]))
-        b++;
-
-    /* At the same time, let me find the end of the word */
-    while (e < buff_pntr && !Delimiter(buff[e])) {
-        e++;
-        ne++;
-    }
-
-    st = b;
-    curr_len = e - b;
-
-    /* now simply copy the text forward */
-    while (b < curr_pntr)
-        *filler++ = buff[b++];
-
-    *filler = '\0';
-
-    pwix = scanWct(pwct, search_buff);
-
-    /*
-     * else pwix = rescanWct();
-     */
-
-    if (!pwix) {
-        putchar(_BELL);
-        fflush(stdout);
-    }
-    else {
-        Wct *pwct = pwix->pwct;
-
-        /*
-         * printf("Found %s in file %s\n", pwct->wordv[pwix->word],
-         * pwct->fname);
-         */
-        /* copy them buffer into where it should be */
-        new_len = strlen(pwct->wordv[pwix->word]);
-        diff = new_len - curr_len;
-        if (curr_pntr != buff_pntr) {
-            forwardcopy(&buff[curr_pntr + diff],
-                        &buff[curr_pntr],
-                        buff_pntr - curr_pntr);
-            forwardflag_cpy(&buff_flag[curr_pntr + diff],
-                            &buff_flag[curr_pntr],
-                            buff_pntr - curr_pntr);
-        }
-        buff_pntr += diff;
-
-
-        /* Now insert the new characters */
-        for (i = new_len - diff; i < new_len; i++)
-            buff[st + i] = (pwct->wordv[pwix->word])[i];
-
-        /* Now move the cursor forward to the end of the word */
-        for (i = 0; i < diff; i++)
-            putchar(buff[curr_pntr++]);
-
-        /** now print the characters on the rest of the line **/
-        printbuff(curr_pntr, buff_pntr - curr_pntr);
-
-        /* now move bcak the number of characters I want to */
-        for (i = buff_pntr; i != e + diff; i--)
-            putchar(_BKSPC);
-
-        fflush(stdout);
-
-        curr_pntr = diff + e;
-
-    }
-
-
-}
-\end{chunk}
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\newpage
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/xdither.c.pamphlet b/src/lib/xdither.c.pamphlet
deleted file mode 100644
index d78cec0..0000000
--- a/src/lib/xdither.c.pamphlet
+++ /dev/null
@@ -1,252 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib xdither.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\begin{chunk}{*}
-
-#ifndef MSYSplatform
-
-#include <stdio.h>
-#include <stdlib.h>
-#if !defined(BSDplatform)
-#include <malloc.h>
-#endif
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xos.h>
-#include <X11/Intrinsic.h>
-#include <X11/StringDefs.h>
-#include <X11/cursorfont.h>
-
-#define XDitherWidth 3
-#define XDitherMax  10
-
-char XDitherBits[] = {
-   0x00, 0x00, 0x00,
-   0x00, 0x02, 0x00,
-   0x00, 0x03, 0x00,
-   0x00, 0x03, 0x02,
-   0x00, 0x07, 0x02,
-   0x04, 0x07, 0x02,
-   0x04, 0x07, 0x03,
-   0x05, 0x07, 0x03,
-   0x05, 0x07, 0x07,
-   0x07, 0x07, 0x07 };
-
-#include "xdither.h1"
-
-Pixmap XDither[XDitherMax];
-unsigned int DITHERINIT = 0;
-
-
-
-/*
- * This routine has the function of returning the number of characters needed
- * to store a bitmap. It first calculates the number of bits needed per line.
- * Then it finds the closest multiple of 8 which is bigger than the number of
- * bits. Once that is done, it multiplies this number by the number of bits
- * high the bitmap is.
- */
-int
-dither_char_bitmap(void)
-{
-    int bits_line;
-    int total_chars;
-
-    for (bits_line = 8, total_chars = 1; bits_line < XDitherWidth; total_chars++)
-        bits_line += 8;
-
-    total_chars = total_chars * XDitherWidth;
-
-    return total_chars;
-}
-
-int 
-XInitDither(Display *display, int screen, GC gc, unsigned long fg, 
-            unsigned long bg)
-{
-
-    char *bits;
-    int count;
-    int chars_bitmap = dither_char_bitmap();
-    int bit;
-    XGCValues xgcv;
-
-    DITHERINIT = 1;
-
-    /*
-     * First thing I should do is load in the Pixmaps
-     */
-    bits = (char *) malloc(chars_bitmap * sizeof(char));
-
-    for (count = 0; count < XDitherMax; count++) {
-
-        /*
-         * Load in the next bitmap
-         */
-        for (bit = 0; bit < chars_bitmap; bit++)
-            bits[bit] = XDitherBits[count * chars_bitmap + bit];
-
-        /*
-         * Create it and put it into the Pixmap array
-         */
-        XDither[count] = XCreatePixmapFromBitmapData(display,
-                                                RootWindow(display, screen),
-                                                     bits,
-                                                 XDitherWidth, XDitherWidth,
-                                                BlackPixel(display, screen),
-                                                WhitePixel(display, screen),
-                                                     1);
-    }
-
-    /*
-     * Now reset the gc values to be as I need them
-     */
-    xgcv.background = bg;
-    xgcv.foreground = fg;
-    xgcv.fill_style = FillOpaqueStippled;
-    xgcv.stipple = XDither[4];
-
-    XChangeGC(display, gc,
-              GCForeground | GCBackground | GCFillStyle | GCStipple, &xgcv);
-
-    return (XDitherMax);
-
-}
-
-
-int
-XChangeDither(Display *display, GC gc, int dither)
-{
-    if (!DITHERINIT) {
-        fprintf(stderr, "XChange Error: Init Not Called\n");
-        exit(-1);
-    }
-    if (dither >= XDitherMax || dither < 0) {
-        fprintf(stderr, "Dither %d, out of range\n",dither);
-        return (-1);
-    }
-    XSetStipple(display, gc, XDither[dither]);
-    return (1);
-}
-
-
-void
-XDitherRectangle(Display *display, Drawable drawable, GC gc, int x,
-                 int  y, unsigned int width, unsigned int height)
-{
-
-
-    if (!DITHERINIT) {
-        fprintf(stderr, "xdither Error: Tried to fill before INIT called\n");
-        exit(-1);
-    }
-    XFillRectangle(display, drawable, gc, x, y, width, height);
-
-}
-
-
-void
-XDitherRectangles(Display *display, Drawable drawable, GC gc, 
-                  XRectangle *rectangles, int nrectangles)
-{
-
-
-    if (!DITHERINIT) {
-        fprintf(stderr, "xdither Error: Tried to fill before INIT called\n");
-        exit(-1);
-    }
-    XFillRectangles(display, drawable, gc,
-                           rectangles, nrectangles);
-
-}
-
-
-void 
-XDitherPolygon(Display * display, Drawable drawable, GC gc, 
-               XPoint *points, int npoints, int shape, int mode)
-{
-    if (!DITHERINIT) {
-        fprintf(stderr, "xdither Error: Tried to fill before INIT called\n");
-        exit(-1);
-    }
-
-    XFillPolygon(display, drawable, gc,
-                        points, npoints, shape, mode);
-
-}
-
-void
-XDitherArc(Display *display, Drawable drawable, GC gc, int x,int  y, 
-           unsigned int width, unsigned int height, int angle1, int angle2)
-{
-
-    if (!DITHERINIT) {
-        fprintf(stderr, "xdither Error: Tried to fill before INIT called\n");
-        exit(-1);
-    }
-    XFillArc(display, drawable, gc, x, y, width,
-                    height, angle1, angle2);
-}
-
-
-void
-XDitherArcs(Display *display,Drawable  drawable, GC gc, XArc *arcs,int narcs)
-{
-
-    if (!DITHERINIT) {
-        fprintf(stderr, "xdither Error: Tried to fill before INIT called\n");
-        exit(-1);
-    }
-    XFillArcs(display, drawable, gc, arcs, narcs);
-}
-#endif /* MSYSplatform */
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/xshade.c.pamphlet b/src/lib/xshade.c.pamphlet
deleted file mode 100644
index bc77646..0000000
--- a/src/lib/xshade.c.pamphlet
+++ /dev/null
@@ -1,234 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib xshade.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\begin{chunk}{*}
-
-#ifndef MSYSplatform
-
-#include <stdio.h>
-#if !defined(BSDplatform)
-#include <malloc.h>
-#endif
-#include <stdlib.h>
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xos.h>
-#include <X11/Intrinsic.h>
-#include <X11/StringDefs.h>
-#include <X11/cursorfont.h>
-
-#define XShadeWidth 4
-#define XShadeMax  17
-
-char XShadeBits[] = {
-   0x00, 0x00, 0x00, 0x00,
-   0x01, 0x00, 0x00, 0x00,
-   0x01, 0x00, 0x04, 0x00,
-   0x05, 0x00, 0x04, 0x00,
-   0x05, 0x00, 0x05, 0x00,
-   0x05, 0x02, 0x05, 0x00,
-   0x05, 0x02, 0x05, 0x08,
-   0x05, 0x0a, 0x05, 0x08,
-   0x05, 0x0a, 0x05, 0x0a,
-   0x07, 0x0a, 0x05, 0x0a,
-   0x07, 0x0a, 0x0d, 0x0a,
-   0x0f, 0x0a, 0x0d, 0x0a,
-   0x0f, 0x0a, 0x0f, 0x0a,
-   0x0f, 0x0b, 0x0f, 0x0a,
-   0x0f, 0x0b, 0x0f, 0x0e,
-   0x0f, 0x0f, 0x0f, 0x0e,
-   0x0f, 0x0f, 0x0f, 0x0f};
-
-#include "xshade.h1"
-
-Pixmap XShade[XShadeMax];
-GC  TileGC;
-unsigned int INIT = 1;
-
-/*
- * This routine has the function of returning the number of characters needed
- * to store a bitmap. It first calculates the number of bits needed per line.
- * Then it finds the closest multiple of 8 which is bigger than the number of
- * bits. Once that is done, it multiplies this number by the number of bits
- * high the bitmap is.
- */
-int
-char_bitmap(void)
-{
-    int bits_line;
-    int total_chars;
-
-    for (bits_line = 8, total_chars = 1; bits_line < XShadeWidth; total_chars++)
-        bits_line += 8;
-
-    total_chars = total_chars * XShadeWidth;
-
-    return total_chars;
-}
-
-int
-XInitShades(Display *display, int screen)
-{
-    char *bits;
-    int count;
-    int chars_bitmap = char_bitmap();
-    int bit;
-
-    bits = (char *) malloc(chars_bitmap * sizeof(char));
-
-    for (count = 0; count < XShadeMax; count++) {
-
-        /* Load in the next bitmap */
-
-        for (bit = 0; bit < chars_bitmap; bit++)
-            bits[bit] = XShadeBits[count * chars_bitmap + bit];
-
-        /* Create it and put it into the Pixmap array */
-
-        XShade[count] = XCreatePixmapFromBitmapData(display,
-                                                RootWindow(display, screen),
-                                                    bits,
-                                                    XShadeWidth, XShadeWidth,
-                                                BlackPixel(display, screen),
-                                                WhitePixel(display, screen),
-                                            DisplayPlanes(display, screen));
-    }
-    TileGC = XCreateGC(display, RootWindow(display, screen), 0, NULL);
-    XSetFillStyle(display, TileGC, FillTiled);
-    XSetTile(display, TileGC, XShade[XShadeMax / 2]);
-    return XShadeMax;
-}
-
-
-int
-XChangeShade(Display *display, int shade)
-{
-    if (shade >= XShadeMax || shade < 0) {
-        fprintf(stderr, "Shade %d, out of range\n",shade);
-        return (-1);
-    }
-    XSetTile(display, TileGC, XShade[shade]);
-    return (1);
-}
-
-int
-XQueryShades(unsigned int *shades)
-{
-    *shades = XShadeMax;
-    return 1;
-}
-
-
-void
-XShadeRectangle(Display *display, Drawable drawable, int x,int y,
-                unsigned int width, unsigned int height)
-{
-    if (!INIT) {
-        fprintf(stderr, "xshade Error: Tried to fill before INIT called\n");
-        exit(-1);
-    }
-    XFillRectangle(display, drawable, TileGC, x, y, width, height);
-}
-
-
-void
-XShadeRectangles(Display *display, Drawable drawable, 
-                 XRectangle *rectangles, int nrectangles)
-{
-    if (!INIT) {
-        fprintf(stderr, "xshade Error: Tried to fill before INIT called\n");
-        exit(-1);
-    }
-    XFillRectangles(display, drawable, TileGC,
-                           rectangles, nrectangles);
-}
-
-
-void
-XShadePolygon(Display *display, Drawable drawable, XPoint * points, 
-              int npoints, int  shape, int mode)
-{
-    if (!INIT) {
-        fprintf(stderr, "xshade Error: Tried to fill before INIT called\n");
-        exit(-1);
-    }
-
-    XFillPolygon(display, drawable, TileGC,
-                        points, npoints, shape, mode);
-}
-
-void
-XShadeArc(Display *display, Drawable drawable, int x, int y, 
-          unsigned int width, unsigned int height, int angle1, int angle2)
-{
-    if (!INIT) {
-        fprintf(stderr, "xshade Error: Tried to fill before INIT called\n");
-        exit(-1);
-    }
-    XFillArc(display, drawable, TileGC, x, y, width,
-                    height, angle1, angle2);
-}
-
-
-void
-XShadeArcs(Display *display, Drawable drawable, XArc *arcs, int narcs)
-{
-    if (!INIT) {
-        fprintf(stderr, "xshade Error: Tried to fill before INIT called\n");
-        exit(-1);
-    }
-    XFillArcs(display, drawable, TileGC, arcs, narcs);
-}
-
-#endif /* MSYSplatform */
-
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
diff --git a/src/lib/xspadfill.c.pamphlet b/src/lib/xspadfill.c.pamphlet
deleted file mode 100644
index 26da157..0000000
--- a/src/lib/xspadfill.c.pamphlet
+++ /dev/null
@@ -1,316 +0,0 @@
-\documentclass{article}
-\usepackage{axiom}
-\begin{document}
-\title{\$SPAD/src/lib xspadfill.c}
-\author{The Axiom Team}
-\maketitle
-\begin{abstract}
-\end{abstract}
-\eject
-\tableofcontents
-\eject
-
-This file contains the routines needed to dither using the
-spadcolors. The routines will have names such as XSpadFill, $\ldots$
-The user simply gives the normal arguments as with the corresponding
-XFill routine, with two additional arguments which choose the shade
-and the hue.
-
-The file will maintain twoGC's: stippleGC - will be used when stippling the
-backgrounds. solidGC - will be used when the background should be solid
-
-The user should call XSpadInit to get everthing going. This routine has the
-job of Initializing the dithering routines, and getting the colors all
-into place.
-
-\section{License}
-\begin{verbatim}
-/*
-Copyright (c) 1991-2002, The Numerical ALgorithms Group Ltd.
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are
-met:
-
-    - Redistributions of source code must retain the above copyright
-      notice, this list of conditions and the following disclaimer.
-
-    - Redistributions in binary form must reproduce the above copyright
-     notice, this list of conditions and the following disclaimer in
-      the documentation and/or other materials provided with the
-      distribution.
-
-    - Neither the name of The Numerical ALgorithms Group Ltd. nor the
-      names of its contributors may be used to endorse or promote products
-      derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
-IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
-TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
-PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
-OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
-PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
-PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
-LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
-NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-\end{verbatim}
-\begin{chunk}{*}
-
-#ifndef MSYSplatform
-
-#include <stdio.h>
-#include <stdlib.h>
-
-#include <X11/Xlib.h>
-#include <X11/Xutil.h>
-#include <X11/Xos.h>
-#include <X11/Intrinsic.h>
-#include <X11/StringDefs.h>
-
-#include "spadcolors.h"
-
-#include "xspadfill.h1"
-#include "xshade.h1"
-#include "xdither.h1"
-#include "spadcolors.h1"
-
-extern unsigned long *spadColors;
-static GC  stippleGC, solidGC;
-Colormap cmap;
-int SpadFillInit = 0;
-long white, black;
-int max_spad_shades;
-extern Display *dsply;
-
-extern int totalHues;
-extern int totalDithered;
-extern int totalSolid;
-extern int totalShades;
-extern int totalColors;
-extern int maxGreyShade;
-
-int
-XInitSpadFill(Display *dsply, int scr, Colormap * mapOfColors, int * hues, 
-              int *solid, int * dithered, int * shades)
-{
-    XColor BlackColor, WhiteColor;
-    XColor retColor;
-    int maxSolid;
-
-    SpadFillInit = 1;
-
-
-    /*
-     * First thing I should do is get the GC's
-     */
-    stippleGC = XCreateGC(dsply, RootWindow(dsply, scr), 0, NULL);
-    solidGC = XCreateGC(dsply, RootWindow(dsply, scr), 0, NULL);
-    XSetArcMode(dsply, solidGC, ArcPieSlice);
-    XSetArcMode(dsply, stippleGC, ArcPieSlice);
-
-
-    cmap = DefaultColormap(dsply, scr);
-    *mapOfColors = cmap;
-    XAllocNamedColor(dsply, cmap, "Black", &BlackColor, &retColor);
-    XAllocNamedColor(dsply, cmap, "White", &WhiteColor, &retColor);
-    black = BlackColor.pixel;
-    white = WhiteColor.pixel;
-
-    /*
-     * Now I check to see if I am on a monochrome display. If so then I
-     * simply set totalHues to be one, and total Shades to be 2. I also have
-     * to allocate balck and white colors. This I put into the first two
-     * memory locations of spadcolors.
-     *
-     * was      if(DisplayPlanes(dsply, scr) < 2)  changed temporarily to < 8
-     * because of problems with screens with 4 planes . Now if we don't have
-     * 8 planes to play with  we switch to monochrome
-     */
-
-    if (DisplayPlanes(dsply, scr) < 8) {
-        *dithered = totalDithered = maxGreyShade = XInitShades(dsply, scr);
-        spadColors = (unsigned long *) malloc(2 * sizeof(unsigned long));
-        spadColors[0] = BlackColor.pixel;
-        spadColors[1] = WhiteColor.pixel;
-        *hues = totalHues = 1;
-        *solid = totalSolid = 2;
-        *shades = totalColors = totalShades = totalDithered;
-        return (totalColors);
-    }
-
-    /*
-     * Now I have to get all the spad colors as every good spad program
-     * should Now I should initialize the dithering routines
-     */
-
-    *dithered = totalDithered =
-        XInitDither(dsply, scr, stippleGC, black, white);
-
-    if ((maxSolid=makeColors(dsply,scr,&cmap,&spadColors,&totalSolid)) > 0) {
-        *solid = totalSolid + 2;
-        *hues = totalHues = maxSolid / totalSolid;
-        *shades = totalShades = (totalSolid + 1) * (totalDithered - 1) + 1;
-        totalColors = totalHues * totalShades;
-        return (totalColors);
-    }
-    else {
-
-        /*
-         * makeColors managed to fail -- switch to mono
-         */
-        *dithered = totalDithered = maxGreyShade = XInitShades(dsply, scr);
-        spadColors = (unsigned long *) malloc(2 * sizeof(unsigned long));
-        spadColors[0] = BlackColor.pixel;
-        spadColors[1] = WhiteColor.pixel;
-        *hues = totalHues = 1;
-        *solid = totalSolid = 2;
-        *shades = totalColors = totalShades = totalDithered;
-        return (totalColors);
-    }
-}
-
-
-void 
-XSpadFillSetArcMode(Display *dsply, int mode)
-{
-    XSetArcMode(dsply, solidGC, mode);
-    XSetArcMode(dsply, stippleGC, mode);
-}
-
-GC
-SpadFillGC(Display *dsply,int  hue, int theshade,char * fill_routine)
-{
-    int dither;
-    int color;
-
-
-    if (!SpadFillInit) {
-        fprintf(stderr, 
-           "Tried to use SpadFillGC before calling XInitSpadFill\n");
-        exit(0);
-    }
-
-    if (theshade >= totalShades) {
-        fprintf(stderr, "Shade %d out of range\n",theshade);
-        exit(-1);
-    }
-    if (hue >= totalHues) {
-        fprintf(stderr, "Error Hue %d is out of range\n",hue);
-        exit(-1);
-    }
-    dither = ((theshade) % (totalDithered - 1));
-    if (dither != 0) {
-        XChangeDither(dsply, stippleGC, dither);
-        if (theshade < totalDithered) {    /* Dither to black */
-            color = totalSolid * hue;
-            XSetForeground(dsply, stippleGC, black);
-            XSetBackground(dsply, stippleGC, spadColors[color]);
-        }
-        else if (theshade > (totalShades - totalDithered)) {
-            /* Dither to white */
-            color = ((theshade) / (totalDithered - 1)) + totalSolid * hue - 1;
-            XSetForeground(dsply, stippleGC, spadColors[color]);
-            XSetBackground(dsply, stippleGC, white);
-        }
-        else {
-            color = ((theshade) / (totalDithered - 1)) + totalSolid * hue - 1;
-            XSetForeground(dsply, stippleGC, spadColors[color]);
-            XSetBackground(dsply, stippleGC, spadColors[color + 1]);
-        }
-        return (stippleGC);
-    }
-    else {
-        if (theshade == 0)
-            XSetForeground(dsply, solidGC, black);
-        else if (theshade == (totalShades - 1))
-            XSetForeground(dsply, solidGC, white);
-        else {
-            color = ((theshade) / (totalDithered - 1)) + totalSolid * hue - 1;
-            XSetForeground(dsply, solidGC, spadColors[color]);
-        }
-        return (solidGC);
-    }
-
-}
-
-unsigned long
-XSolidColor(int hue, int theshade)
-{
-    if (hue >= totalHues)
-        return -1;
-    if (theshade >= totalSolid)
-        return -1;
-    return (spadColors[hue * (totalSolid) + theshade]);
-}
-
-void 
-XSpadFillRectangle(Display *dsply, Drawable drawable, int x, int y,
-                   unsigned int width, unsigned int height,
-                   int hue, int theshade)
-{
-
-    XFillRectangle(dsply, drawable,
-                   SpadFillGC(dsply, hue, theshade, "XSpadFillRectangle"),
-                   x, y, width, height);
-
-}
-
-
-void
-XSpadFillRectangles(Display *dsply, Drawable drawable,
-                    XRectangle * rectangles, int nrectangles,
-                    int  hue, int theshade)
-{
-
-
-    XFillRectangles(dsply, drawable,
-                        SpadFillGC(dsply, hue, theshade, "XSpadFillRectangle"),
-                           rectangles, nrectangles);
-
-}
-
-
-void
-XSpadFillPolygon(Display *dsply, Drawable drawable, XPoint * points, 
-                 int npoints, int shape, int mode, int hue, int theshade)
-{
-    XFillPolygon(dsply, drawable,
-                        SpadFillGC(dsply, hue, theshade, "XSpadFillRectangle"),
-                        points, npoints, shape, mode);
-
-}
-
-void
-XSpadFillArc(Display *dsply, Drawable drawable, int x, int y, 
-             unsigned int width, unsigned int height,
-             int angle1, int angle2,int hue,int  theshade)
-{
-
-    XFillArc(dsply, drawable,
-                    SpadFillGC(dsply, hue, theshade, "XSpadFillRectangle"),
-                    x, y, width, height, angle1, angle2);
-}
-
-
-void
-XSpadFillArcs(Display *dsply, Drawable drawable, XArc * arcs, int narcs,
-              int hue, int theshade)
-{
-    XFillArcs(dsply, drawable,
-                     SpadFillGC(dsply, hue, theshade, "XSpadFillArcs"),
-                     arcs, narcs);
-}
-
-
-#endif /* MSYSplatform */
-
-\end{chunk}
-\eject
-\begin{thebibliography}{99}
-\bibitem{1} nothing
-\end{thebibliography}
-\end{document}
