#	@(#) pprx 22.2 90/04/24 
#
#
#	      UNIX is a registered trademark of AT&T
#		Portions Copyright 1976-1989 AT&T
#	Portions Copyright 1980-1989 Microsoft Corporation
#    Portions Copyright 1983-1989 The Santa Cruz Operation, Inc
#		      All Rights Reserved

#ident	"@(#)lp:model/pprx	1.3.1.2"
# lp interface for printronix line printer with	parallel interface
#
#	All output is passed through the /usr/lib/pprx filter
#  If this filter is not executable, then this interface will disable
#  the lp printer which	it was called to service.
#
x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

if [ -x "/usr/spool/lp/bin/drain.output" ]
then
	DRAIN="/usr/spool/lp/bin/drain.output 1"
else
	DRAIN=
fi

if [ ! -x /usr/lib/pprx	]
then
	disable	-r"can't execute /usr/lib/pprx filter" `basename $0`
	exit 1
fi
(
echo "\014\c"
echo "$x\n$x\n$x\n$x\n"
banner "$2"
echo "\n"
user=`grep "^$2:" /etc/passwd |	line | cut -d: -f5`
if [ -n	"$user"	]
then
	echo "User: $user\n"
else
	echo "\n"
fi
echo "Request id: $1	Printer: `basename $0`\n"
date
echo "\n"
if [ -n	"$3" ]
then
	banner $3
fi
copies=$4
echo "\014\c"
shift; shift; shift; shift; shift
files="$*"
i=1
while [	$i -le $copies ]
do
	for file in $files
	do
		cat "$file" 2>&1
		echo "\014\c"
	done
	i=`expr	$i + 1`
done
echo "$x\n$x\n$x\n$x\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n$x\n$x\n$x\n$x"
echo "$x\n$x\n$x\n$x\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
echo "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"
echo "$x\n$x\n$x\n$x\n$x\n$x\n$x\n$x\n"
) | /usr/lib/pprx
if [ $? != 0 ]
then
	disable -r"write error" `basename $0`
	exit 1
fi

#Draining characters might be necessary.
${DRAIN}

exit 0

