#!/usr/bin/sh
# @(#) $Revision: 72.1 $
# lp interface for hp2563a line printer
#
# Options recognized:
#	nb		| -nb		do not print the banner (save paper)
#

if tty -s <&1
then
	stty 9600 opost onlcr -parenb cs8 ixon -istrip clocal tab3 <&1
fi
# Print the standard header

banner="yes"

for i in $5
do
	case "$i" in

	-nb | nb) # Do not print banner page
		banner="";;
	esac
done

if [ -n "$banner" ]
then
	x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
	echo "\014\c"
	echo "$x\n$x\n$x\n$x\n"
	banner "$2"
	echo "\n"
	user=`pwget -n $2 | 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
fi
copies=$4
echo "\014\c"

# The remaining arguments are files

shift; shift; shift; shift; shift
files="$*"

# Print the spooled files

i=1
while [ $i -le $copies ]
do
	for file in $files
	do
		expand "$file" 2>&1
		echo "\014\c"
	done
	i=`expr $i + 1`
done

# Print the standard trailer

#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"

if tty -s <&1
then
	stty 9600 opost onlcr -parenb cs8 ixon -istrip clocal tab3 <&1
fi

exit 0
