#! /bin/csh -f
# @(#)prevsec	1.4	12/1/92

# Command uses printer defined by environmental variable $PRINTER
# User .cshrc file must contain "setenv PRINTER whatever"

# The argument(s) are the files to be printed.
# An implicit header file, $PTOLEMY/doc/headers/shared, is prepended.

if ($#argv == 0) then
	echo "Usage: printsec [-options] files"
	exit 0
endif

# On interrupt, remove temporary files
onintr catch

if ( ! $?PTOLEMY ) setenv PTOLEMY ~ptolemy

# File structure information:
set dirheader = $PTOLEMY/doc/headers
set printcommand = ditroff
set printoptions = "-me -tbl -eqn -t"
set contentscmd = $PTOLEMY/doc/bin/contents
set files = ""

while ($#argv)
	switch ($argv[1])
		case -*:
			set printoptions = ($printoptions $argv[1])
			shift
			breaksw
		default:
			set files = ($files $argv[1])
			shift
			breaksw
	endsw
end

soelim $dirheader/shared $dirheader/domain $files | \
	$printcommand $printoptions -Ppsc | \
	xditview -
exit 0

catch:
        # prevent the "no match" error message if there are no temporary files
        set nonomatch
        /bin/rm /tmp/pt$$
        exit 1
