#!/bin/sh
GS_EXECUTABLE=gs
PBMPLUSPATH=/usr/local/bin
PSFILTERPATH=/usr/local/lib/ghostscript
LOCALPATH=/usr/local/bin
X11HOME=/usr/X11R6
PATH=/bin:/usr/bin:/usr/ucb:/usr/etc
PATH=${PATH}\:${LOCALPATH}\:${PBMPLUSPATH}\:${PSFILTERPATH}
LD_LIBRARY_PATH=${X11HOME}/lib
export PATH LD_LIBRARY_PATH acctfile host user
user= host= acctfile=/dev/null
exec 3>&1 1>&2
while [ $# != 0 ]
do case "$1" in
-n) user=$2 ; shift ;;
-h) host=$2 ; shift ;;
-*) ;;
*) acctfile=$1 ;;
esac
shift
done
filter=`basename $0`
device=`dirname $0`
type=`dirname ${device}`
device=`basename ${device}`
fdevname=$device
type=`basename ${type}`
colorspec="`echo ${device} | sed 's/.*\.[0-9][0-9]*\.\([0-9][0-9]*\)$/\1/'`"
if test "$colorspec" = "${device}"
then
colorspec=""
else
device=`basename ${device} .$colorspec`
colorspec="-dColors=$colorspec"
fi
bpp="`echo ${device} | sed 's/.*\.\([0-9][0-9]*\)$/\1/'`"
if test "$bpp" = "${device}"
then
bpp=1
else
device=`basename ${device} .$bpp`
fi
lock=`dirname ${acctfile}`/lock
cf=`sed -n '$p' ${lock}`
job=`sed -n 's/^J//p' ${cf}`
echo "gsbanner: ${host}:${user} Job: ${job} Date: `date`"
echo "gsif: ${host}:${user} ${fdevname} start - `date`"
case "${type}" in
direct)
gsoutput="cat 1>&3" ;;
indirect)
gsoutput="lpr -P${device}.raw" ;;
esac
(
case "${filter}" in
gsif) cat ;;
gsnf) psdit ;;
gstf) pscat ;;
gsgf) psplot ;;
gsvf) rasttopnm | pnmtops ;;
gsdf) dvi2ps -sqlw ;;
gscf|gsrf) echo "${filter}: filter not available" 1>&2 ; exit 0 ;;
esac
echo "\
(acctfile) getenv
{ currentdevice /PageCount gsgetdeviceprop dup cvi 0 gt
{ exch (a) file /acctfile exch def
/string 20 string def
string cvs dup length dup
4 lt
{ 4 exch sub
{ acctfile ( ) writestring } repeat
} { pop } ifelse
acctfile exch writestring
acctfile (.00 ) writestring
acctfile (host) getenv
{ string cvs } { (NOHOST) } ifelse writestring
acctfile (:) writestring
acctfile (user) getenv
{ string cvs } { (NOUSER) } ifelse writestring
acctfile (\n) writestring
acctfile closefile
} { pop } ifelse
} if
quit"
) | $GS_EXECUTABLE -q -P- -dSAFER -dNOPAUSE -sDEVICE=${device} \
-dBitsPerPixel=${bpp} $colorspec \
-sOutputFile=\|"${gsoutput}" -
rm -f ${gspipe}
echo "gsif: end - `date`"