[comp.sources.unix] v10i088: Magtape handling package, Part01/02

rs@uunet.UU.NET (Rich Salz) (08/04/87)

Submitted-by: Dick Grune <dick@cs.vu.nl>
Posting-number: Volume 10, Issue 88
Archive-name: magtapetools/Part01

	David Hayes' posting of his ansitape program reminded me of my
more general (but less specialized) magtape handling package, which has
been in use for quite some years and which I have, in the course of
time, sent out to some number of people.  I also sent it, some years ago,
to net.sources.  It does not show up in your last listing of mod.sources.
Anyway, it has been updated and adjusted, e.g., for machines with funny
byte order.

	This letter begins with a very short comparison of his program
to my package, followed by part 1 of 2 of the sources (sharchive).

					Dick Grune
					Vrije Universiteit
					de Boelelaan 1081
					1081 HV  Amsterdam
					the Netherlands
					dick@cs.vu.nl
					...!mcvax!vu44!dick

----------------------------------------------------------------
A few points of comparison between the program ANSITAPE by
 	David S. Hayes, The Merlin of Avalon
	PhoneNet:	(202) 694-6900
	ARPA:		merlin%hqda-ai.uucp@brl-smoke
	UUCP:		...!seismo!sundc!hqda-ai!merlin
and the MAGTAPE package by
	Dick Grune
	Vrije Universiteit
	Amsterdam, Holland
	dick@cs.vu.nl
	...!mcvax!vu44!dick

ANSITAPE
	uses BSD 4.2 system calls
	writes variable format only
	can extract files using wildcard characters
	can add to tapes
	can write EBCDIC

MAGTAPE
	can do many other things besides handling ANSI tapes (see READ_ME)
	runs on BSD 4.1, V7, SYS V and probably others
	supports tape images on disk
	writes fixed format only

----------------------------------------------------------------
: This is a shar archive.  Extract with sh, not csh.
: This archive ends with exit, so do not worry about trailing junk.
: --------------------------- cut here --------------------------
PATH=/bin:/usr/bin
echo Extracting \R\E\A\D\_\M\E
sed 's/^X//' > \R\E\A\D\_\M\E << '+ END-OF-FILE '\R\E\A\D\_\M\E
X#       This file is part of the magtape handling package MAG.
X#       Written by Dick Grune, Vrije Universiteit, Amsterdam.
X#
X
XSALES TALK
X        If you have one or more magtape units and want to do more with
Xthem than just run  `tar', this is for you.
X
X        On the shell level this package offers programs for
X  - getting a quick look at a tape,
X  - making exact copies of tapes even if you've got only one magtape unit,
X  - extracting arbitrary portions from tapes and
X  - the reading and writing of ANSI standard labelled tapes.
XAll these programs work equally well on real tapes and on tape images
Xon disk.
X
X        On the C-level it supplies routines for handling real tapes and
Xtape images on disk as a unified concept (`generalized magtape').
X
X
XINSTALLATION
X-       Take a look at the file  `tploc.h'  which requires you to define:
X
X        SYSCODE                         the name of your installation
X        DEV_LOW, DEV_NORMAL, DEV_HIGH   the name(s) of the magtape unit(s)
X
X        You may also #define one of the following flags to describe
X        the reading and writing of the tape:
X        NORMAL (default)                anything goes (VAX, etc)
X        EVEN                            only even blocksize allowed (PDP11)
X        SWAB                            bytes must be swapped (M68000)
X
X        If you are not on a UNIX(like) system, you may look at `sys.c',
X        which contains the (non-magtape) interface to the OS.
X
X-       Call  `make all'  and the shell commands as described in mag(1)
X        will appear.
X
X-       To install the shell commands, change the macro USR (and possibly
X        BIN, LIB, and INC) in the  `makefile'  and do  `make install'. To
X        install the C-routine library  `libt.a', do  `make libt'.
X
X-       Now do
X
X                ansir -fp test.image
X
X        to get a feel for what it does. (Then do it a second time!).
X
XCYBER
X        If you happen to have a Control Data Cyber around, running
XSCOPE or NOS/BE, call  `make NOS'  to get  `NOSsplit', a program for
Xreading Cyber SI-format tapes, and  `NOStr'  which converts from various
XCyber character codes.
X
X                                        Dick Grune
X                                        Vrije Universiteit
X                                        de Boelelaan 1081
X                                        1081 HV  Amsterdam
X                                        the Netherlands
X
X                                        dick@cs.vu.nl
X                                        ..!mcvax!vu44!dick
X
+ END-OF-FILE READ_ME
chmod 'u=rw,g=r,o=r' \R\E\A\D\_\M\E
set `sum \R\E\A\D\_\M\E`
sum=$1
case $sum in
55393)	:;;
*)	echo 'Bad sum in '\R\E\A\D\_\M\E >&2
esac
echo Extracting \M\a\k\e\f\i\l\e
sed 's/^X//' > \M\a\k\e\f\i\l\e << '+ END-OF-FILE '\M\a\k\e\f\i\l\e
X#	This file is part of the magtape handling package MAG.
X#	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X#
X
X#	A system for handling magtapes, real or in tape image form.
X#
X#	make all:	make all the shell commands and run a superficial test
X#	make install:	install all the shell commands
X#	make libt:	install C-routine library
X#	make NOS:	install NOSsplit et al. for reading Cyber tapes
X#	make man:	install the manuals
X#	make lint:	`lint' everything
X#	make clean:	clean up the generated files
X#
X
X#	P A R A M E T E R S
XUSR =		/user1/dick
X
XBIN =		$(USR)/bin#		# where to store the binaries
XLIB =		$(USR)/lib#		# where to store libt.a
XINC =		$(USR)/src#		# where to store tp.h for public use
XMAN1 =		$(USR)/man#		# where to store manual pages(1)
XMAN3 =		$(USR)/man#		# where to store manual pages(3)
X
XCC =		cc#			# the C compiler to be used
XCFLAGS =	-O -s#			# its flags
XLINT =		lint#			# lint to be used, including flags
X
X#	P U B L I C   E N T R I E S
XPRG =		survey rawtp cptp ansir ansiw
XNOS =		NOSsplit NOStr
X
Xall:		$(PRG) $(NOS) test.image
X	./ansir -f test.image
X	cmp READ_ME READ_ME.TEST
X	rm READ_ME.TEST
X
Xinstall:	$(PRG)
X	for F in $(PRG); do cp $$F $(BIN)/$$F; done
X
Xlibt:		tp.h libt.a
X	cp tp.h $(INC)/tp.h
X	cp libt.a $(LIB)/libt.a
X
XNOS:		$(NOS)
X	for F in $(NOS); do cp $$F $(BIN)/$$F; done
X
X#	M A N U A L S
XMAN1_SRC =	ansir.1 ansiw.1 cptp.1 rawtp.1 survey.1 mag.1 \
X		NOSsplit.1 NOStr.1
XMAN3_SRC =	mag.3
XMAN_SRC =	$(MAN1_SRC) $(MAN3_SRC)
X
Xman:
X	for F in $(MAN1_SRC); do cp $$F $(MAN1)/$$F; done
X	for F in $(MAN3_SRC); do cp $$F $(MAN3)/$$F; done
X
X#	L I B R A R Y
XLIB_OBJ =	tpread.o tpwrite.o tpopen.o tpclose.o tpname.o tperr.o \
X		tploc.o tprdloc.o tpwloc.o tpwtmloc.o sys.o
XLIB_SRC =	tpread.c tpwrite.c tpopen.c tpclose.c tpname.c tperr.c \
X		tploc.c tprdloc.c tpwloc.c tpwtmloc.c sys.c
XLIB_HDR =	aux.h tp.h tploc.h tpsys.h sys.h
XLIB_AUX =	tpdummy.c llib-lmag.c
X
Xlibt.a:		$(LIB_OBJ)
X	ar cr libt.a $(LIB_OBJ)
X	if /bin/test -f /usr/bin/ranlib ; then ranlib libt.a ; fi
X
X
X#	P R O G R A M S
XPRG_SRC =	ansi.c etoa.c ansir.c ansiw.c cptp.c rawtp.c survey.c \
X		NOSsplit.c NOStr.c
XPRG_HDR =	ansi.h etoa.h options.h
X
Xansir:		ansir.o ansi.o etoa.o libt.a
X	$(CC) $(CFLAGS) ansir.o ansi.o etoa.o libt.a -o ansir
X
Xansiw:		ansiw.o ansi.o libt.a
X	$(CC) $(CFLAGS) ansiw.o ansi.o libt.a -o ansiw
X
Xcptp:		cptp.o libt.a
X	$(CC) $(CFLAGS) cptp.o libt.a -o cptp
X
Xrawtp:		rawtp.o libt.a
X	$(CC) $(CFLAGS) rawtp.o libt.a -o rawtp
X
Xsurvey:		survey.o etoa.o libt.a
X	$(CC) $(CFLAGS) survey.o etoa.o libt.a -o survey
X
XNOSsplit:	NOSsplit.o libt.a
X	$(CC) $(CFLAGS) NOSsplit.o libt.a -o NOSsplit
X
XNOStr:		NOStr.o
X	$(CC) $(CFLAGS) NOStr.o -o NOStr
X
X#	S E R V I C E   E N T R I E S
Xlint:
X	$(LINT) $(LIB_SRC) tpdummy.c
X	$(LINT) tpdummy.c llib-lmag.c
X	$(LINT) rawtp.c llib-lmag.c
X	$(LINT) cptp.c llib-lmag.c
X	$(LINT) ansir.c ansi.c llib-lmag.c
X	$(LINT) ansiw.c ansi.c llib-lmag.c
X	$(LINT) NOSsplit.c llib-lmag.c
X	$(LINT) NOStr.c
X
XFiles:		Makefile
X	ls Makefile READ_ME $(MAN_SRC) $(LIB_HDR) $(LIB_SRC) $(LIB_AUX) \
X		$(PRG_HDR) $(PRG_SRC) >Files
X
Xshar:		shar1 shar2
XSHAR1 =		READ_ME Makefile $(MAN_SRC) $(LIB_HDR) $(LIB_SRC) $(LIB_AUX)
XSHAR2 =		$(PRG_HDR) $(PRG_SRC)
X
Xshar1:		Makefile $(SHAR1)
X	shar $(SHAR1) >shar1
X
Xshar2:		Makefile $(SHAR2)
X	shar $(SHAR2) >shar2
X
Xtags:		$(LIB_SRC) $(PRG_SRC)
X	ctags $(LIB_SRC) $(PRG_SRC) >tags
X
Xtest.image:	ansiw READ_ME
X	cp READ_ME READ_ME.TEST
X	./ansiw -f test.image READ_ME.TEST
X	rm READ_ME.TEST
X
Xclean:
X	rm -f *.o libt.a $(PRG) $(NOS) \
X		test.image shar1 shar2 tags
X
X
X#----------------------------------------------------------------
XNOSsplit.o: aux.h options.h tp.h
XNOStr.o: aux.h
Xansi.o: ansi.h aux.h tp.h
Xansir.o: ansi.h aux.h etoa.h options.h tp.h
Xansiw.o: ansi.h aux.h options.h sys.h tp.h tploc.h
Xcptp.o: aux.h options.h tp.h
Xrawtp.o: aux.h options.h tp.h
Xsurvey.o: aux.h etoa.h options.h tp.h
Xsys.o: aux.h
Xtpclose.o: aux.h tp.h tpsys.h
Xtpdummy.o: options.h sys.h tp.h
Xtperr.o: aux.h tp.h tpsys.h
Xtploc.o: tploc.h
Xtpname.o: aux.h tp.h tpsys.h
Xtpopen.o: tp.h tpsys.h
Xtprdloc.o: tp.h tploc.h tpsys.h
Xtpread.o: tp.h tpsys.h
Xtpwloc.o: tp.h tploc.h tpsys.h
Xtpwrite.o: tp.h tpsys.h
Xtpwtmloc.o: aux.h tp.h tpsys.h
+ END-OF-FILE Makefile
chmod 'u=rw,g=r,o=r' \M\a\k\e\f\i\l\e
set `sum \M\a\k\e\f\i\l\e`
sum=$1
case $sum in
27318)	:;;
*)	echo 'Bad sum in '\M\a\k\e\f\i\l\e >&2
esac
echo Extracting \a\n\s\i\r\.\1
sed 's/^X//' > \a\n\s\i\r\.\1 << '+ END-OF-FILE '\a\n\s\i\r\.\1
X.\"	This file is part of the magtape handling package MAG.
X.\"	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X.\"
X.TH ANSIR 1 82/04/16
X.SH NAME
Xansir \- read ANSI standard labelled tape
X.SH SYNOPSIS
X.B ansir
X[
X.B \-ijnpg
X] [ name ... ]
X.SH DESCRIPTION
X.I Ansir
Xreads a single volume multi-file ANSI Standard
XLabelled Tape or anything that looks remotely like it.
XIt can handle F, U, D, S and V formats (V is for IBM tapes).
XLabels can be in ASCII or in EBCDIC;
X.I ansir
Xassumes the files to be in the same character code as the labels, except
Xfor U format files which are supposed to be in BINARY (i.e. untranslated).
XThe record separator for ASCII or EBCDIC is the newline; the record
Xseparator for BINARY is determined interactively. All these rules can
Xbe overridden through the
X.B \-i
Xand
X.B \-j
Xparameters.
X.PP
XBad characters, i.e., those not in the ASCII95 set, are reported and
Xshow up in the format \e[777]. This may necessitate some postprocessing
Xbut too much light is better than being left in the dark.
X.PP
X.I Ansir
Xmay consult the user on missing information; when a question is answered
Xwith a single question mark,
X.I ansir
Xsupplies more information.
X.PP
XThe program accepts the usual
X.B \-cfhlm
Xparameters to describe the tape (see
X.IR mag (I)).
X.PP
XThere are a number of additional options:
X.TP
X.B \-i
Xthe UNIX file name and character code are determined interactively. A
Xminus
X.B \-
Xfor a file name will result in skipping the corresponding tape file.
X.TP
X.B \-j
Xas \fBi\fP-option, but including record format, block length,
Xrecord length and buffer offset.
X.TP
X.B \-n
Xno execution: the files will not be extracted.
X.TP
X.B \-p
Xinformation from the labels is printed.
X.TP
X.B \-g
Xif a
X.B \-p
Xis given, the information about generation number and
Xversion number is also printed.
X.PP
XIf
X.I name
Xparameters are
Xgiven, only the named files are treated.
X.SH SEE ALSO
Xmag(I)
X.SH BUGS
XThe S format has never been tried.
X.PP
XThe
X.B \-p
Xoption causes too much output.
X.SH AUTHOR
XDick Grune.
+ END-OF-FILE ansir.1
chmod 'u=rw,g=r,o=r' \a\n\s\i\r\.\1
set `sum \a\n\s\i\r\.\1`
sum=$1
case $sum in
12139)	:;;
*)	echo 'Bad sum in '\a\n\s\i\r\.\1 >&2
esac
echo Extracting \a\n\s\i\w\.\1
sed 's/^X//' > \a\n\s\i\w\.\1 << '+ END-OF-FILE '\a\n\s\i\w\.\1
X.\"	This file is part of the magtape handling package MAG.
X.\"	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X.\"
X.TH ANSIW 1 82/04/13
X.SH NAME
Xansiw \- write ANSI standard labelled tape
X.SH SYNOPSIS
X.B ansiw
X[
X.B \-ignpv
X] [ file ... ]
X.SH DESCRIPTION
X.I Ansiw
Xwrites a single volume multi-file ANSI Standard Labelled Tape
Xin F- or U-format.
X.PP
XIf no option is given the tape has the following properties:
X.br
X	the volume serial number is 222222,
X.br
X	the owner is the user id,
X.br
X	the file identifier is the UNIX filename,
X.br
X	the expiration date is the current date,
X.br
X	the accessibility symbol is a space character.
X.PP
XThe preferred record format is F with block length 1920 and record length 80.
XEach
X.I file
Xis scanned before it is written to tape. If it is found to be incompatible
Xwith the preferred record format,
X.I ansiw
Xtries to find a better one. If it fails the user is consulted.
X.PP
XThe program accepts the usual
X.B \-cfhlm
Xparameters to describe the tape (see
X.IR mag (I)).
X.PP
XThere are a number of additional options.
X.TP
X.B \-i
Xthe user is consulted about the tape properties.
X.TP
X.B \-g
Xif a
X.B \-i
Xis given the user is also consulted about the generation number
Xand the version number.
X.TP
X.B \-n
Xno execution: the tape-file is not created.
X.TP
X.B \-p
Xa short report is printed for each file.
X.TP
X.B \-v
Xthe user is only consulted about the Volume Label.
X.PP
XThe D and S formats are not implemented since their portability
Xvalue is considered low.
X.SH SEE ALSO
Xmag(I)
X.SH AUTHOR
XDick Grune.
+ END-OF-FILE ansiw.1
chmod 'u=rw,g=r,o=r' \a\n\s\i\w\.\1
set `sum \a\n\s\i\w\.\1`
sum=$1
case $sum in
01038)	:;;
*)	echo 'Bad sum in '\a\n\s\i\w\.\1 >&2
esac
echo Extracting \c\p\t\p\.\1
sed 's/^X//' > \c\p\t\p\.\1 << '+ END-OF-FILE '\c\p\t\p\.\1
X.\"	This file is part of the magtape handling package MAG.
X.\"	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X.\"
X.TH CPTP 1 82/04/16
X.SH NAME
Xcptp \- copy from tape to tape
X.SH SYNOPSIS
X.B cptp
X[
X.B \-x
X] [
X.BR of= file
X|
X.BR if= file
X]
X.SH DESCRIPTION
X.I Cptp
Xconverts between real tapes and tape images on disk.
XThe
X.B of=
Xparameter causes
X.I cptp
Xto read the real magtape and produce a tape image on the indicated file.
XA call with an
X.B if=
Xparameter will write back the tape image from the indicated file to the
Xreal magtape.
X.PP
XThe program accepts the usual
X.B \-cfhlm
Xparameters to describe the tape (see
X.IR mag (I)).
XIf the
X.BI \-x -option
Xis given,
Xcopying will continue regardless of read-errors or consecutive tape marks
X(default is stopping after 4 consecutive TMs).
X.SH "SEE ALSO"
Xmag(I),
Xrawtp(I),
Xsurvey(I)
X.SH AUTHOR
XDick Grune.
+ END-OF-FILE cptp.1
chmod 'u=rw,g=r,o=r' \c\p\t\p\.\1
set `sum \c\p\t\p\.\1`
sum=$1
case $sum in
50689)	:;;
*)	echo 'Bad sum in '\c\p\t\p\.\1 >&2
esac
echo Extracting \r\a\w\t\p\.\1
sed 's/^X//' > \r\a\w\t\p\.\1 << '+ END-OF-FILE '\r\a\w\t\p\.\1
X.\"	This file is part of the magtape handling package MAG.
X.\"	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X.\"
X.TH RAWTP 1 82/04/16
X.SH NAME
Xrawtp \- read raw tape
X.SH SYNOPSIS
X.B rawtp
Xname [
X.B \-x
X] [ param ... ]
X.SH DESCRIPTION
X.I Rawtp
Xextracts arbitrary portions from a magtape.
X.PP
XThe program accepts the usual
X.B \-cfhlm
Xparameters to describe the tape (see
X.IR mag (I)).
XThe additional
X.BR \-x -option
Xwill cause
X.I rawtp
Xto continue reading regardless of read-errors or consecutive tape marks
X(normally
X.I rawtp
Xstops after 4 consecutive tape marks).
X.PP
XThe tape is considered as a series of files, each terminated by a
Xtape mark (TM); a file is considered as a series of blocks, each
Xterminated by an InterRecord Gap (IRG); a block consists of characters.
X.PP
XAn instruction
X.I +t.i.c
Xor
X.I \-t.i.c
Xmoves the tape over
X.I t
XTM's,
X.I i
XIRG's (but not over a TM) and
X.I c
Xcharacters (but not over an IRG). If the instruction begins with a
X.I +
Xthe contents are copied to a file, a
X.I \-
Xjust skips the contents.
X.PP
XInstructions may be concatenated into an instruction series. If an
Xinstruction sequence is followed by
X.BI x n
Xthe effect is repeated
X.I n
Xtimes. If
X.I n
Xis absent or 0, the instruction series is repeated until it becomes
Xineffective. E.g.,
X.I +.1\-1x
Xwill give you the first block of each file on tape.
XDefault parameter is
X.I +1x
Xwhich splits the tape into its separate files.
X.PP
XThe produced files are named
X.I namepprrrii
Xwhere
X.I name
Xis the first argument,
X.I pp
Xis the two-digit parameter number,
X.I rrr
Xis a three-letter counter counting the number of repetitions of the
Xparameter, and
X.I ii
Xis the two-digit instruction number within the parameter.
X.PP
XExample:
X
X.br
X	rawtp  tp  \-10  +..80\-3x
X
Xwill skip 10 files, and then give the first 80 characters of the first
Xblock of every third file on the files
X.IR tp02aaa01 ,
X.IR tp02aab01 ,
Xetc, (if present.)
X.SH "SEE ALSO"
Xmag(I),
Xcptp(I),
Xsurvey(I)
X.SH AUTHOR
XDick Grune.
+ END-OF-FILE rawtp.1
chmod 'u=rw,g=r,o=r' \r\a\w\t\p\.\1
set `sum \r\a\w\t\p\.\1`
sum=$1
case $sum in
08829)	:;;
*)	echo 'Bad sum in '\r\a\w\t\p\.\1 >&2
esac
echo Extracting \s\u\r\v\e\y\.\1
sed 's/^X//' > \s\u\r\v\e\y\.\1 << '+ END-OF-FILE '\s\u\r\v\e\y\.\1
X.\"	This file is part of the magtape handling package MAG.
X.\"	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X.\"
X.TH SURVEY 1 82/04/16
X.SH NAME
Xsurvey \- survey contents of a magtape
X.SH SYNOPSIS
X.B survey
X[
X.B \-px
X]
X.SH DESCRIPTION
X.I Survey
Xlists the lengths of the blocks on a magtape. If the
X.B \-p
Xoption is given, the first characters of each block are displayed
Xin ASCII, EBCDIC and hexadecimal.
X.PP
XThe program accepts the usual
X.B \-cfhlm
Xparameters to describe the tape (see
X.IR mag (I)).
XThe additional
X.BR \-x -option
Xwill cause
X.I rawtp
Xto continue reading regardless of read-errors or consecutive tape marks
X(normally
X.I rawtp
Xstops after 4 consecutive tape marks).
X.SH SEE ALSO
Xmag(I)
X.SH AUTHOR
XDick Grune.
+ END-OF-FILE survey.1
chmod 'u=rw,g=r,o=r' \s\u\r\v\e\y\.\1
set `sum \s\u\r\v\e\y\.\1`
sum=$1
case $sum in
38018)	:;;
*)	echo 'Bad sum in '\s\u\r\v\e\y\.\1 >&2
esac
echo Extracting \m\a\g\.\1
sed 's/^X//' > \m\a\g\.\1 << '+ END-OF-FILE '\m\a\g\.\1
X.\"	This file is part of the magtape handling package MAG.
X.\"	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X.\"
X.TH MAG 1 83/06/23
X.SH NAME
Xmag \- generalized magnetic tape
X.SH SYNOPSIS
X.PP
X.B cptp
X[
X.B -x
X] [
X.BR of= file
X|
X.BR if= file
X]
X.PP
X.B rawtp
Xname [
X.B \-x
X] [ param ... ]
X.PP
X.B survey
X[
X.B \-px
X]
X.PP
X.B ansir
X[
X.B \-ijnpg
X] [ name ... ]
X.PP
X.B ansiw
X[
X.B \-ignpv
X] [ file ... ]
X.PP
X.B NOSsplit
X[
X.B \-s
XN ] [ name ]
X.SH DESCRIPTION
XThese programs have in common that they use a 'generalized magtape'.
XSuch a generalized magtape may correspond to a real magtape or to a tape image
Xi.e., a normal
Xfile with a specific structure which contains all information present on
Xa tape, including block sizes and tape marks. Conversion between real tapes
Xand tape images is done by
X.IR cptp (I).
X.PP
XThe generalized magtape is described by the following parameters which
Xapply to all of the above programs.
X.TP
X.BI \-m " N"
Xthe magtape is real and on unit
X.IR N .
X.TP
X.B \-h
Xthe magtape is real and in high density.
X.TP
X.B \-l
Xthe magtape is real and in low density.
X.TP
X.BI \-f " name"
Xthe magtape is a tape image on file
X.IR name .
X.TP
X.BI \-c " name"
Xthe magtape is the character-device
X.IR name .
X.PP
XThe options may appear separately or in groups.
X.SH AUTHOR
XDick Grune.
X.SH BUGS
XConflicts between options are not detected.
+ END-OF-FILE mag.1
chmod 'u=rw,g=r,o=r' \m\a\g\.\1
set `sum \m\a\g\.\1`
sum=$1
case $sum in
54257)	:;;
*)	echo 'Bad sum in '\m\a\g\.\1 >&2
esac
echo Extracting \N\O\S\s\p\l\i\t\.\1
sed 's/^X//' > \N\O\S\s\p\l\i\t\.\1 << '+ END-OF-FILE '\N\O\S\s\p\l\i\t\.\1
X.\"	This file is part of the magtape handling package MAG.
X.\"	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X.\"
X.TH NOSSPLIT 1 83/02/08
X.SH NAME
XNOSsplit \- split Cyber system tape
X.SH SYNOPSIS
X.B NOSsplit
X[
X.B \-s
XN ] [ name ]
X.SH DESCRIPTION
X.I NOSsplit
Xreads a Control Data Cyber system tape (SI-format) as written under NOS/BE or
XSCOPE by COPY, COPYBF or COPYBR. Each Cyber record is written to a separate
Xfile. The EOR-levels appear on standard output.
X.PP
XA Cyber record consists of an integral number of Cyber words of 60 bits each,
Xwhereas a UNIX file consists of an integral number of bytes of 8 bits each;
Xso, if the Cyber record has an odd number of words, a bit-to-bit mapping
Xwon't work. Therefore, a mapping is used in which
Xeach Cyber machine-word (60 bits) maps onto 10 characters, each containing
X6 bits (again 60 bits).
XSuch a 6-bit file can be processed by
X.RI NOStr (I),
Xwhich can do translation from DISPLAY code and Z-type record recognition.
X.PP
XThe file names are
X.IR name 00000,
X.IR name 00001,
Xetc. The default
X.I name
Xis
X.BR x .
X.PP
XThe program accepts the usual
X.B \-cfhlm
Xparameters to describe the tape (see
X.IR mag (I)).
X.PP
XWhen the
X.B \-s
Xoption is given, the first
X.I N
Xrecords are skipped.
X.SH SEE ALSO
Xmag(I),
XNOStr(I)
X.SH BUGS
XThere is no
X.I NOScombine
Xto put Humpty Dumpty together again.
X.SH AUTHOR
XDick Grune.
+ END-OF-FILE NOSsplit.1
chmod 'u=rw,g=r,o=r' \N\O\S\s\p\l\i\t\.\1
set `sum \N\O\S\s\p\l\i\t\.\1`
sum=$1
case $sum in
45288)	:;;
*)	echo 'Bad sum in '\N\O\S\s\p\l\i\t\.\1 >&2
esac
echo Extracting \N\O\S\t\r\.\1
sed 's/^X//' > \N\O\S\t\r\.\1 << '+ END-OF-FILE '\N\O\S\t\r\.\1
X.\"	This file is part of the magtape handling package MAG.
X.\"	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X.\"
X.TH NOSTR 1 82/04/16
X.SH NAME
XNOStr \- translate Cyber 6-bits files
X.SH SYNOPSIS
X.BR "NOStr -" C
X[ file ]
X.SH DESCRIPTION
X.I NOStr
Xaccepts as input a 6-bits Cyber file, as created, e.g., by
X.IR NOSsplit (I).
XSuch a file contains a mapping of an integral number of 60-bits Cyber words;
Xeach Cyber word is mapped onto 10 UNIX characters, each containing 6 bits in
Xthe right-most 6 positions. Depending on the interpretation that should be
Xgiven to the original Cyber words
X.I NOStr
Xperforms the appropriate conversion indicated by
X.IR C .
X.PP
XThree conversions have been implemented:
X.TP
X.B d
Xthe input is interpreted as originating from Z-type
Xrecords in DISPLAY code (6 bits to a character, EOR marked by two or more 00
Xcharacters in the lower end of a word)
X.TP
X.B a
XZ-type records in ASCII95 (8-bit characters right aligned in
X12 bits, EOR marked by one or more NULL characters in the lower end)
X.TP
X.B b
X`binary', i.e., ASCII256 (8-bit characters right aligned in
X12 bits, no further processing); since this code is not well standardized,
Xparity checking, CR-removal and further preening are left to the user.
X.SH SEE ALSO
XNOSsplit (I)
X.SH BUGS
XAs with
X.I NOSsplit
Xthe inverse does not exist.
X.SH AUTHOR
XDick Grune.
+ END-OF-FILE NOStr.1
chmod 'u=rw,g=r,o=r' \N\O\S\t\r\.\1
set `sum \N\O\S\t\r\.\1`
sum=$1
case $sum in
56699)	:;;
*)	echo 'Bad sum in '\N\O\S\t\r\.\1 >&2
esac
echo Extracting \m\a\g\.\3
sed 's/^X//' > \m\a\g\.\3 << '+ END-OF-FILE '\m\a\g\.\3
X.\"	This file is part of the magtape handling package MAG.
X.\"	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X.\"
X.TH MAG 3 83/06/23
X.SH NAME
Xmag \- implement generalized magtape
X.SH SYNOPSIS
X.PP
X.B "#include <tp.h>"
X.PP
X.B "TPFILE *tpopen(unit, nmdns, rwx) char *nmdns, *rwx;"
X.PP
X.B "tpclose(tf) TPFILE *tf;"
X.PP
X.B "int tpread(tf, buf, size) TPFILE *tf; char *buf;"
X.PP
X.B "tpwrite(tf, buf, size) TPFILE *tf; char *buf;"
X.PP
X.B "tperrout(stream) FILE *stream;"
X.SH DESCRIPTION
XThese routines implement the generalized magtape described in
X.IR mag (I).
XSuch a generalized magtape is viewed as a sequence of blocks each of which
Xis written and read in one piece. A tape mark is represented as a block of
Xlength 0. The blocks correspond to physical blocks on tape (as separated
Xby Interrecord Gaps). On a tape image each block is preceded by its length
Xin format "%08d".
X.PP
XA generalized magtape is handled by these routines as a pointer to a
XTPFILE. Such a pointer is obtained from
X.IR tpopen .
XThe
X.I unit
Xand the
X.I nmdns
Xdescribe the generalized magtape; these are the possibilities:
X.PP
Xa real magtape:
X.I unit
Xis a small non-negative integer (the unit number);
X.I nmdns
Xis TP_DENL, TP_DENN or TP_DENH (for low, normal or high density).
X.PP
Xa tape image:
X.I unit
Xis TP_IMAG;
X.I nmdns
Xis the file name.
X.PP
Xa character device:
X.I unit
Xis TP_CDEV;
X.I nmdns
Xis the device name.
X.PP
XThe third parameter
X.I rwx
Xis either "r" or "rx" for reading or "w" for writing; "rx" suppresses
Xthe recognition of end-of-file in real magtapes (see
X.IR tpread ).
X.PP
X.I Tpclose
Xcloses a generalized magtape; this causes a rewind and makes room for
Xother such files, since only a limited number (specified in _TP_MOPEN)
Xcan be open at the same time.
X.PP
X.I Tpread
Xreads one block into
X.I buf
Xto a maximum of
X.I size
Xcharacters. The rest of the block, if present, is skipped.
XIt returns the number of
Xcharacters read, or 0 for a tape mark, or -1 for an end-of-file.
XOn a tape image file the end-of-file coincides with the actual end-of-file.
XOn a real magtape or on a character device three conditions can cause
Xan end-of-file:
X.IP
X4 consecutive tape marks,
X.br
X2 consecutive read errors, or
X.br
X1 read error preceded by a tape mark,
X.PP
Xunless "rx" was specified in the call of
X.IR tpopen ,
Xin which case only 100 consecutive read errors will cause an end-of-file
X(to prevent the program from looping on end-of-reel).
X.PP
X.I Tpwrite
Xwrites one block from
X.I buf
Xif
X.I size
X> 0, or a tape mark if
X.I size
X= 0.
X.SH DIAGNOSTICS
XIf an error condition (other than end-of-file) is found, a message is
Xprinted on
X.I stderr
Xand the program exits. This default can be changed by calling
X.I tperrout.
X.SH AUTHOR
XDick Grune.
+ END-OF-FILE mag.3
chmod 'u=rw,g=r,o=r' \m\a\g\.\3
set `sum \m\a\g\.\3`
sum=$1
case $sum in
40145)	:;;
*)	echo 'Bad sum in '\m\a\g\.\3 >&2
esac
echo Extracting \a\u\x\.\h
sed 's/^X//' > \a\u\x\.\h << '+ END-OF-FILE '\a\u\x\.\h
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#define	char2int(c)	((c)&0377)
X#define	is_ascii95(c)	(040 <= (c) && (c) <= 0176)
X#define	is_digit(c)	('0' <= (c) && (c) <= '9')
X#define	n_items(a)	(sizeof (a)/sizeof (a)[0])
X
X/* a define that generates 2 parameters */
X#define	english(i)	(i), (i) == 1 ? "" : "s"	/* word with plural */
X
X#ifdef	lint
X/* this #define has the same syntactic properties as the original */
X#define	VOID(x)	if ((int)(x)) printf("")
X#else	lint
X#define	VOID(x)	(x)
X#endif	lint
+ END-OF-FILE aux.h
chmod 'u=rw,g=r,o=r' \a\u\x\.\h
set `sum \a\u\x\.\h`
sum=$1
case $sum in
47132)	:;;
*)	echo 'Bad sum in '\a\u\x\.\h >&2
esac
echo Extracting \t\p\.\h
sed 's/^X//' > \t\p\.\h << '+ END-OF-FILE '\t\p\.\h
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#define	TP_MAXB	32766	/* largest size parameter to `read' & `write' */
X
X#define	TP_CDEV	(-1)
X#define	TP_IMAG	(-2)
X
X#define	TP_DENL	_tp_dnl
X#define	TP_DENN	_tp_dnn
X#define	TP_DENH	_tp_dnh
X
Xextern char _tp_dnl[], _tp_dnn[], _tp_dnh[];
X
Xstruct tpdes	{
X	int _tp_unit;		/* unit number or TP_IMAG  or TP_CDEV  */
X	char *_tp_nmdns;	/* density     or filename or filename */
X	char _tp_rw;		/* 'r' for reading, 'w' for writing */
X	char _tp_x;		/* 'x' for persistent, ' ' for normal */
X	char _tp_fildes;	/* file descriptor after `open' */
X
X	long _tp_blkc;		/* block counter */
X	int _tp_mkc;		/* accumulative TM counter */
X	int _tp_mc;		/* consecutive TM counter */
X	char _tp_eof;		/* EOF-flag */
X};
X#define	TPFILE	struct tpdes
X
Xextern TPFILE *tpopen();
X
+ END-OF-FILE tp.h
chmod 'u=rw,g=r,o=r' \t\p\.\h
set `sum \t\p\.\h`
sum=$1
case $sum in
45874)	:;;
*)	echo 'Bad sum in '\t\p\.\h >&2
esac
echo Extracting \t\p\l\o\c\.\h
sed 's/^X//' > \t\p\l\o\c\.\h << '+ END-OF-FILE '\t\p\l\o\c\.\h
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X/*	#define's which may require local modification */
X
X
X/*	1.	System code */
X/*	This string of at most 13 characters will be written in the
X	HDR1-label, to identify the system (organization) of origin.
X	DO USE YOURS!
X*/
X/* Ruler for length:	"1234567890123"	*/
X#define	SYSCODE		"VU, Amsterdam"
X
X
X/*	2.	Names of tape devices */
X/*	The macros DEV_* define the names of the low-density,
X	normal-density and high-density tape devices, as double-strings.
X	The first string indicates the read name, the second the write
X	name; the unit number will be inserted at %d (using sprintf).
X*/
X#define	DEV_LOW		"/dev/rmt%d\0/dev/nrmt%d"
X#define	DEV_NORMAL	"/dev/rmt8\0/dev/nrmt8"
X#define	DEV_HIGH	"/dev/rmt%d\0/dev/nrmt%d"
X
X
X/*	3.	Special reading and writing */
X/*	The intricacies of reading and writing a block on tape are
X	somewhat system-dependent.  #define exactly one of the following.
X	
X	If your system is not described by this (which will be rare),
X	see  tprdloc.c, tpwloc.c and tpwtmloc.c  to see how to roll your own.
X*/
X#define	NORMAL	1		/* anything goes: VAX */
X#undef	EVEN	1		/* only even blocksize allowed: PDP11 */
X#undef	SWAB	1		/* bytes must be swapped: M 68000 */
X
+ END-OF-FILE tploc.h
chmod 'u=rw,g=r,o=r' \t\p\l\o\c\.\h
set `sum \t\p\l\o\c\.\h`
sum=$1
case $sum in
58969)	:;;
*)	echo 'Bad sum in '\t\p\l\o\c\.\h >&2
esac
echo Extracting \t\p\s\y\s\.\h
sed 's/^X//' > \t\p\s\y\s\.\h << '+ END-OF-FILE '\t\p\s\y\s\.\h
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#define	_TP_PREF	8	/* size of length prefix in disk images */
X#define	_TP_MOPEN	2	/* max # of simultaneously open tape-files */
X
Xextern char *_tpname();
+ END-OF-FILE tpsys.h
chmod 'u=rw,g=r,o=r' \t\p\s\y\s\.\h
set `sum \t\p\s\y\s\.\h`
sum=$1
case $sum in
47628)	:;;
*)	echo 'Bad sum in '\t\p\s\y\s\.\h >&2
esac
echo Extracting \s\y\s\.\h
sed 's/^X//' > \s\y\s\.\h << '+ END-OF-FILE '\s\y\s\.\h
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
Xextern char *sysdate();			/* today's date as YYDDD */
Xextern char *username();		/* a name for the user */
X
+ END-OF-FILE sys.h
chmod 'u=rw,g=r,o=r' \s\y\s\.\h
set `sum \s\y\s\.\h`
sum=$1
case $sum in
59579)	:;;
*)	echo 'Bad sum in '\s\y\s\.\h >&2
esac
echo Extracting \t\p\r\e\a\d\.\c
sed 's/^X//' > \t\p\r\e\a\d\.\c << '+ END-OF-FILE '\t\p\r\e\a\d\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#include	"tp.h"
X#include	"tpsys.h"
X
Xint
Xtpread(tf, buf, size)
X	TPFILE *tf;
X	char *buf;
X{
X	int res;
X
X	if (tf->_tp_eof)
X		return -1;
X
X	if (tf->_tp_unit != TP_IMAG && tf->_tp_x == ' ' && tf->_tp_mc >= 4)
X		res = -1;
X	else
X		res = _tp_rd(tf, buf, size);
X
X	if (res > 0)	{
X		tf->_tp_blkc++;
X		tf->_tp_mc = 0;
X	}
X	else
X	if (res == 0)	{
X		tf->_tp_mkc++;
X		tf->_tp_mc++;
X		tf->_tp_blkc = 0;
X	}
X	else
X	if (res < 0)	{
X		tf->_tp_mc = 0;
X	}
X
X	return size < res ? size : res;
X}
X
Xint
X_tp_rd(tf, buf, size)
X	TPFILE *tf;
X	char *buf;
X{
X	int sz;
X
X	if (size <= 0)	{
X		static char ch;		/* substitute buffer */
X
X		buf = &ch;
X		size = 1;
X	}
X
X	if (tf->_tp_unit == TP_IMAG)	{
X		char pref[_TP_PREF];
X		int n;
X		char ch;
X
X		n = read(tf->_tp_fildes, pref, _TP_PREF);
X		if (n == 0)
X			return -1;
X		if (n != _TP_PREF)
X			goto Lformerr;
X		sz = 0;
X		for (n = 0; n < _TP_PREF; n++)	{
X			int dig = pref[n] - '0';
X			if (dig < 0 || dig > 9)
X				goto Lformerr;
X			sz = sz*10 + dig;
X		}
X		n = sz < size ? sz : size;
X		if (n > 0)
X			if (read(tf->_tp_fildes, buf, n) != n)
X				goto Lformerr;
X		while (sz-- > size)
X			if (read(tf->_tp_fildes, &ch, 1) != 1)
X				goto Lformerr;
X		return n;
X
X	Lformerr:
X		_tprwerr("tape image error", tf);
X		exit(1);
X	}
X	else	{
X		int erc = 0;
X
X		while ((sz = _tprdloc(tf, buf, size)) < 0)	{
X			_tprwerr("garbage", tf);
X			erc++;
X			if (tf->_tp_x == ' ' && (tf->_tp_mc > 0 || erc >= 2))
X				return -1;
X			if (tf->_tp_x == 'x' && (erc >= 100))
X				return -1;
X		}
X		return sz;
X	}
X	/*NOTREACHED*/
X}
+ END-OF-FILE tpread.c
chmod 'u=rw,g=r,o=r' \t\p\r\e\a\d\.\c
set `sum \t\p\r\e\a\d\.\c`
sum=$1
case $sum in
55300)	:;;
*)	echo 'Bad sum in '\t\p\r\e\a\d\.\c >&2
esac
echo Extracting \t\p\w\r\i\t\e\.\c
sed 's/^X//' > \t\p\w\r\i\t\e\.\c << '+ END-OF-FILE '\t\p\w\r\i\t\e\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#include	"tp.h"
X#include	"tpsys.h"
X
Xtpwrite(tf, buf, size)
X	TPFILE *tf;
X	char *buf;
X{
X	if (tf->_tp_unit == TP_IMAG)	{
X		int i, n = size;
X		char pref[_TP_PREF];
X		for (i = _TP_PREF; i--; )	{
X			pref[i] = n % 10 + '0';
X			n = n / 10;
X		}
X		if (write(tf->_tp_fildes, pref, _TP_PREF) != _TP_PREF)
X			goto Lerr;
X		if (size > 0)
X			if (write(tf->_tp_fildes, buf, size) != size)
X				goto Lerr;
X	}
X	else	{
X		if (size == 0)
X			_tpwtmloc(tf);
X		else
X		if (_tpwloc(tf, buf, size) != size)
X			goto Lerr;
X	}
X
X	if (size == 0)	{
X		tf->_tp_mkc++;
X		tf->_tp_blkc = 0;
X	}
X	else	{
X		tf->_tp_blkc++;
X	}
X
X	return;
X
XLerr:
X	_tprwerr("write error", tf);
X	exit(1);
X}
+ END-OF-FILE tpwrite.c
chmod 'u=rw,g=r,o=r' \t\p\w\r\i\t\e\.\c
set `sum \t\p\w\r\i\t\e\.\c`
sum=$1
case $sum in
16659)	:;;
*)	echo 'Bad sum in '\t\p\w\r\i\t\e\.\c >&2
esac
echo Extracting \t\p\o\p\e\n\.\c
sed 's/^X//' > \t\p\o\p\e\n\.\c << '+ END-OF-FILE '\t\p\o\p\e\n\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#include	"tp.h"
X#include	"tpsys.h"
X
XTPFILE *
Xtpopen(unit, nmdns, rwx)
X	char *nmdns, *rwx;
X{
X	char *name = (char *)0;
X	static TPFILE tflist[_TP_MOPEN];
X	TPFILE *tf;
X
X	for (tf = &tflist[0]; tf->_tp_fildes != 0; tf++)
X		if (tf == &tflist[_TP_MOPEN-1])	{
X			_tpopenerr(name, "too many tapes");
X		}
X
X	tf->_tp_unit = unit;
X	tf->_tp_nmdns = nmdns;
X	tf->_tp_rw = 'r';
X	tf->_tp_x = ' ';
X	while (*rwx)
X	switch (*rwx++)	{
X	case 'r':
X		tf->_tp_rw = 'r';
X		break;
X	case 'w':
X		tf->_tp_rw = 'w';
X		break;
X	case 'x':
X		tf->_tp_x = 'x';
X		break;
X	default:
X		_tpopenerr(name, "Bad option in tpopen");
X		break;
X	}
X	tf->_tp_blkc = tf->_tp_mkc = tf->_tp_mc = tf->_tp_eof = 0;
X
X	name = _tpname(tf);
X
X	if (tf->_tp_rw == 'w')	{
X		if ((tf->_tp_fildes = creat(name, 0666)) < 0)	{
X			_tpopenerr(name, "cannot create");
X		}
X	}
X       	else	{
X	       	if ((tf->_tp_fildes = open(name, 0)) < 0)	{
X	       		_tpopenerr(name, "cannot open");
X		}
X	}
X
X	return tf;
X}
+ END-OF-FILE tpopen.c
chmod 'u=rw,g=r,o=r' \t\p\o\p\e\n\.\c
set `sum \t\p\o\p\e\n\.\c`
sum=$1
case $sum in
33170)	:;;
*)	echo 'Bad sum in '\t\p\o\p\e\n\.\c >&2
esac
echo Extracting \t\p\c\l\o\s\e\.\c
sed 's/^X//' > \t\p\c\l\o\s\e\.\c << '+ END-OF-FILE '\t\p\c\l\o\s\e\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#include	"aux.h"
X#include	"tp.h"
X#include	"tpsys.h"
X
Xtpclose(tf)
X	TPFILE *tf;
X{
X	VOID(close(tf->_tp_fildes));
X	if (tf->_tp_rw == 'w')	{
X		tf->_tp_rw = 'r';
X		VOID(close(open(_tpname(tf), 0)));
X	}
X	tf->_tp_fildes = 0;
X}
+ END-OF-FILE tpclose.c
chmod 'u=rw,g=r,o=r' \t\p\c\l\o\s\e\.\c
set `sum \t\p\c\l\o\s\e\.\c`
sum=$1
case $sum in
11552)	:;;
*)	echo 'Bad sum in '\t\p\c\l\o\s\e\.\c >&2
esac
echo Extracting \t\p\n\a\m\e\.\c
sed 's/^X//' > \t\p\n\a\m\e\.\c << '+ END-OF-FILE '\t\p\n\a\m\e\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#include	"aux.h"
X#include	"tp.h"
X#include	"tpsys.h"
X
Xextern char *sprintf();
X
Xchar * /* transient */
X_tpname(tf)
X	TPFILE *tf;
X{
X	static char name[20];
X	int unit = tf->_tp_unit;
X	char *nmdns = tf->_tp_nmdns;
X
X	if (unit == TP_IMAG || unit == TP_CDEV)
X		return nmdns;
X	
X	/* a real magtape */
X	if (tf->_tp_rw == 'w')	{
X		/* find the second name */
X		while (*nmdns++)	{
X		}
X	}
X	VOID(sprintf(name, nmdns, unit));
X
X	return name;
X}
+ END-OF-FILE tpname.c
chmod 'u=rw,g=r,o=r' \t\p\n\a\m\e\.\c
set `sum \t\p\n\a\m\e\.\c`
sum=$1
case $sum in
04109)	:;;
*)	echo 'Bad sum in '\t\p\n\a\m\e\.\c >&2
esac
echo Extracting \t\p\e\r\r\.\c
sed 's/^X//' > \t\p\e\r\r\.\c << '+ END-OF-FILE '\t\p\e\r\r\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#include	<stdio.h>
X#include	"aux.h"
X#include	"tp.h"
X#include	"tpsys.h"
X
XFILE *tperr = stderr;
X
Xtperrout(stream)
X	FILE *stream;
X{
X	tperr = stream;
X	setbuf(tperr, (char *)NULL);
X}
X
X_tpopenerr(name, msg)
X	char *name, *msg;
X{
X	if (name != NULL)
X		fprintf(tperr, "%s: ", name);
X	fprintf(tperr, "%s\n", msg);
X	exit(1);
X}
X
X_tprwerr(msg, tf)
X	char *msg;
X	TPFILE *tf;
X{
X	fprintf(tperr,
X		"After %d tape mark%s, after %ld block%s: %s on %s\n",
X		english(tf->_tp_mkc), english(tf->_tp_blkc), msg, _tpname(tf));
X}
+ END-OF-FILE tperr.c
chmod 'u=rw,g=r,o=r' \t\p\e\r\r\.\c
set `sum \t\p\e\r\r\.\c`
sum=$1
case $sum in
24399)	:;;
*)	echo 'Bad sum in '\t\p\e\r\r\.\c >&2
esac
echo Extracting \t\p\l\o\c\.\c
sed 's/^X//' > \t\p\l\o\c\.\c << '+ END-OF-FILE '\t\p\l\o\c\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#include	"tploc.h"
X
X/* The tape device names */
Xchar _tp_dnl[] = DEV_LOW;
Xchar _tp_dnn[] = DEV_NORMAL;
Xchar _tp_dnh[] = DEV_HIGH;
+ END-OF-FILE tploc.c
chmod 'u=rw,g=r,o=r' \t\p\l\o\c\.\c
set `sum \t\p\l\o\c\.\c`
sum=$1
case $sum in
02816)	:;;
*)	echo 'Bad sum in '\t\p\l\o\c\.\c >&2
esac
echo Extracting \t\p\r\d\l\o\c\.\c
sed 's/^X//' > \t\p\r\d\l\o\c\.\c << '+ END-OF-FILE '\t\p\r\d\l\o\c\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#include	"tp.h"
X#include	"tploc.h"
X#include	"tpsys.h"
X
X/*
X * _tprdloc reads one block from a character device.
X * It must take care of local restrictions.
X */
X
Xint
X_tprdloc(tf, buf, size)
X	TPFILE *tf;
X	char *buf;
X{
X	int sz;
X	
X#ifdef	NORMAL
X	/* This is the VAX version, anything goes. */
X	sz = read(tf->_tp_fildes, buf, size);
X#endif	NORMAL
X
X#ifdef	EVEN
X	/* This is the PDP version, even block size required. */
X	{
X		/* if odd, read one char more */
X		char ch = buf[size];		/* save the original */
X		sz = read(tf->_tp_fildes, buf, size % 2 ? size + 1 : size);
X		sz = (sz > size ? size : sz);
X		buf[size] = ch;			/* restore the original */
X	}
X#endif	EVEN
X
X#ifdef	SWAB
X	/* Modified 12/30/84 gertjan */
X	/* This is the Motorola version (bytes are swabbed). */
X	{
X		static char swab_buf[TP_MAXB];	/* too big for the stack */
X		sz = read(tf->_tp_fildes, swab_buf, size);
X		swab(swab_buf, buf, size);
X	}
X#endif	SWAB
X
X	return sz;
X}
+ END-OF-FILE tprdloc.c
chmod 'u=rw,g=r,o=r' \t\p\r\d\l\o\c\.\c
set `sum \t\p\r\d\l\o\c\.\c`
sum=$1
case $sum in
11454)	:;;
*)	echo 'Bad sum in '\t\p\r\d\l\o\c\.\c >&2
esac
echo Extracting \t\p\w\l\o\c\.\c
sed 's/^X//' > \t\p\w\l\o\c\.\c << '+ END-OF-FILE '\t\p\w\l\o\c\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#include	"tp.h"
X#include	"tploc.h"
X#include	"tpsys.h"
X
X/*
X * _tpwloc writes one block of non-zero length to a character device.
X * It must take care of local restrictions.
X */
X
Xint
X_tpwloc(tf, buf, size)
X	TPFILE *tf;
X	char *buf;
X{
X	register int sz;
X	
X#ifdef	NORMAL
X	/* This is the VAX version (anything goes). */
X	sz = write(tf->_tp_fildes, buf, size);
X#endif	NORMAL
X
X#ifdef	EVEN
X	/* This is the PDP11/45 version (even block size). */
X	/* if odd, write one char more */
X	sz = write(tf->_tp_fildes, buf, size % 2 ? size + 1 : size);
X	sz = (sz > size ? size : sz);
X#endif	EVEN
X
X#ifdef	SWAB
X	/* Modified 12/30/84 gertjan */
X	/* This is the Motorola version (bytes are swabbed). */
X	{
X		static char swab_buf[TP_MAXB];	/* too big for the stack */
X		swab(buf, swab_buf, size);
X		sz = write(tf->_tp_fildes, swab_buf, size);
X	}
X#endif	SWAB
X	
X	return sz;
X}
+ END-OF-FILE tpwloc.c
chmod 'u=rw,g=r,o=r' \t\p\w\l\o\c\.\c
set `sum \t\p\w\l\o\c\.\c`
sum=$1
case $sum in
63369)	:;;
*)	echo 'Bad sum in '\t\p\w\l\o\c\.\c >&2
esac
echo Extracting \t\p\w\t\m\l\o\c\.\c
sed 's/^X//' > \t\p\w\t\m\l\o\c\.\c << '+ END-OF-FILE '\t\p\w\t\m\l\o\c\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#include	"aux.h"
X#include	"tp.h"
X#include	"tpsys.h"
X
X/*
X * _tpwtmloc writes a tape mark to a character device.
X * It must take care of the local restrictions.
X */
X
X_tpwtmloc(tf)
X	TPFILE *tf;
X{
X	VOID(close(tf->_tp_fildes));
X	tf->_tp_fildes = open(_tpname(tf), 1);
X}
+ END-OF-FILE tpwtmloc.c
chmod 'u=rw,g=r,o=r' \t\p\w\t\m\l\o\c\.\c
set `sum \t\p\w\t\m\l\o\c\.\c`
sum=$1
case $sum in
18915)	:;;
*)	echo 'Bad sum in '\t\p\w\t\m\l\o\c\.\c >&2
esac
echo Extracting \s\y\s\.\c
sed 's/^X//' > \s\y\s\.\c << '+ END-OF-FILE '\s\y\s\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X/*	This file declares the routines that interface to the operating
X	system beside those that do tape I/O.
X	
X	sysdate()	returns a transient pointer to today's date in the
X			format YYDDD, e.g. 86365 for the last day of 1986.
X	username()	returns a transient pointer to a readable form of
X			the name of the user/owner. At most 14 chars will
X			be used.
X*/
X
X#include	"aux.h"
X
X#include	<sys/types.h>
X#include	<pwd.h>
X#include	<time.h>
X
Xextern time_t time();
Xextern struct tm *localtime();
Xextern struct passwd *getpwuid();
Xextern char *sprintf();
X
Xchar * /* transient */
Xsysdate()	{			/* today's date as YYDDD */
X	time_t tnow = time((time_t*)0);
X	struct tm *timeptr = localtime(&tnow);
X	static char today[6];
X	
X	VOID(sprintf(today, "%02d%03d",
X				timeptr->tm_year, timeptr->tm_yday+1));
X	return today;
X}
X
Xchar * /* transient */
Xusername()	{		/* user name, if available, else NULL */
X	struct passwd *pwd = getpwuid(getuid()); /* is transient already */
X	
X	return pwd == ((struct passwd *)0) ? ((char *)0) : pwd->pw_name;
X}
X
+ END-OF-FILE sys.c
chmod 'u=rw,g=r,o=r' \s\y\s\.\c
set `sum \s\y\s\.\c`
sum=$1
case $sum in
16535)	:;;
*)	echo 'Bad sum in '\s\y\s\.\c >&2
esac
echo Extracting \t\p\d\u\m\m\y\.\c
sed 's/^X//' > \t\p\d\u\m\m\y\.\c << '+ END-OF-FILE '\t\p\d\u\m\m\y\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X#include	<stdio.h>
X#include	"aux.h"
X#include	"tp.h"
X#include	"sys.h"
X
Xint unit = 0;
Xchar *nmdns = TP_DENN;
Xchar *rx = "r";
XTPFILE *from, *to;
Xchar *filename;
Xint size;
Xchar buff[TP_MAXB];
X
Xmain(argc, argv)
X	char *argv[];
X{
X	argc--, argv++;
X	while (argc > 0 && argv[0][0] == '-')	{
X		char *pp = argv[0];
X		
X		while (*++pp)	{
X			switch (*pp)	{
X			/* insert cases to handle the standard options */
X#include	"options.h"
X			/* special options */
X			}
X		}
X		argc--, argv++;
X	}
X	
X	printf("%s, %s\n", sysdate(), username());
X	tperrout(stdout);
X	from = tpopen(unit, nmdns, rx);
X	to = tpopen(TP_IMAG, filename, "w");
X
X	while ((size = tpread(from, buff, TP_MAXB)) >= 0)	{
X		tpwrite(to, buff, size);
X	}
X	tpclose(from);
X	tpclose(to);
X	exit(0);
X
XLbad:
X	exit(1);
X}
+ END-OF-FILE tpdummy.c
chmod 'u=rw,g=r,o=r' \t\p\d\u\m\m\y\.\c
set `sum \t\p\d\u\m\m\y\.\c`
sum=$1
case $sum in
38785)	:;;
*)	echo 'Bad sum in '\t\p\d\u\m\m\y\.\c >&2
esac
echo Extracting \l\l\i\b\-\l\m\a\g\.\c
sed 's/^X//' > \l\l\i\b\-\l\m\a\g\.\c << '+ END-OF-FILE '\l\l\i\b\-\l\m\a\g\.\c
X/*	This file is part of the magtape handling package MAG.
X	Written by Dick Grune, Vrije Universiteit, Amsterdam.
X*/
X
X/*LINTLIBRARY*/
X#include	<stdio.h>
X#include	"tp.h"
X
XTPFILE *tpopen(unit, nmdns, rwx) char *nmdns, *rwx;
X{return tpopen(unit, nmdns, rwx);}
X
Xtpclose(tf) TPFILE *tf;
X{tpclose(tf); return;}
X
Xint tpread(tf, buf, size) TPFILE *tf; char *buf;
X{return tpread(tf, buf, size);}
X
Xtpwrite(tf, buf, size) TPFILE *tf; char *buf;
X{tpwrite(tf, buf, size); return;}
X
Xtperrout(stream) FILE *stream;
X{tperrout(stream); return;}
X
Xchar *sysdate()
X{return sysdate();}
X
Xchar *username()
X{return username();}
X
Xchar TP_DENL[];
Xchar TP_DENN[];
Xchar TP_DENH[];
X
Xchar _etoa[];
+ END-OF-FILE llib-lmag.c
chmod 'u=rw,g=r,o=r' \l\l\i\b\-\l\m\a\g\.\c
set `sum \l\l\i\b\-\l\m\a\g\.\c`
sum=$1
case $sum in
13145)	:;;
*)	echo 'Bad sum in '\l\l\i\b\-\l\m\a\g\.\c >&2
esac
exit 0

-- 

Rich $alz			"Anger is an energy"
Cronus Project, BBN Labs	rsalz@bbn.com
Moderator, comp.sources.unix	sources@uunet.uu.n <D