#!/bin/csh -f

# Usage: xdviprogc fileroot
# xdviprog is any program for viewing a .dvi file, e.g., xd or texx.
# You just need to make sure there is a link from xdviprog to this file.
# Fileroot is the part of the file name preceding ".dvi".  If you give
# a filename containing ".", the part from the last "." on is replaced
# with ".dvi" to find the .dvi file.  So you get the same behavior from
# "xdc foo" or "xdc foo.dvi" or even "xdc foo.zqfmgb".

umask 66

set fullprogname = $0
set fullprogname = `echo $fullprogname | sed 's+^\([^/]\)+./\1+'`
set progdir = $fullprogname:h
set progname = $fullprogname:t

set progbase = `echo $progname | sed 's+\(.*\)c+\1+'`

set inputbase = $1:r
set tempbase = \#temp.$$

echo "Enter key:"
set key = $<

crypt $key <$inputbase.dvi >$tempbase.dvi
$progbase $tempbase.dvi
echo "Print? (y/n) [n]"
set answer = $<
if ("$answer" == "y") lprd $tempbase.dvi
rm -f $tempbase.dvi
