#!/bin/sh
# $Id: psfunix.LP,v 3.5 1992/06/02 08:16:01 ajf Exp ajf $
#  Postscript serial or parallel printer using psf filters
#
#	"make scripts" will use sed to replace "/usr/local/bin" with
#		the binary library directory name such as /local/bin.

# If page accounting is desired, modify the code at the end
# of this script.

# The following parameters are passed from "lp" at print time.

log=/usr/spool/lp/log
echo "start: $reqid  `date`"    >>$log
echo "\t$*" >> $log
exec 2>>$log        # catch error messages, since PS printer won't print them

printer=`basename $0`
request=$1
name=$2
title=$3
copies=$4
options=$5
shift; shift; shift; shift; shift

option_list=$options
options=
for i in ${option_list}
do
	case "${i}" in

	*@*)	rname="${i}"
		;;
# remove -oBSD*.  Input for BSD has options -oBSDJxxx -oBSDCxxx which
# confuses psffilter.
	-oBSD*)
		;;
	*)
		options="${options} ${i}"
		;;
	esac;
done

files="$*"
while	[ "$copies" -gt 0 ]
do
	for file in $files
	do
		( ( tr -d '\004'< "$file" | /usr/local/bin/nenscript $options -Z -p- ) ;
		 echo \\004\\c ) | /usr/local/bin/socket -q -W hplj4si 9100 
	done
	copies=`expr $copies - 1`
done
exit 0
