#	@(#) lqp40 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/lqp40	1.3.1.2"

# lp interface for LQP-40 Letter Quality Printer
#

x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

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

stty -parenb -parodd 9600 cs8 cread clocal ixon 0<&1
stty -ignbrk -brkint -ignpar -parmrk -inpck -istrip 0<&1
stty -inlcr -igncr -iuclc -ixany 0<&1
stty opost -ocrnl onlcr -onlret tab3 0<&1
echo "\033P"
id=$1
name=$2
title=$3
copies=$4
shift; shift; shift; shift; shift
files="$*"
echo "\014\c"
echo "\n\n\n\n\n\n\n\n\n\n"
echo "$x\n$x\n$x\n$x\n\n\n\n\n"
banner "$name"
echo "\n"
echo "Request id: $id"  
date
echo "\n"
if [ -n "$title" ]
then
	banner $title
fi
echo "\n\n\n\n\n"
echo "$x\n$x\n$x\n$x\n\n\n\n\n"
echo "\014\c"
i=1
while [ $i -le $copies ]
do
	for file in $files
	do
		case $file
		in
			*.g|*.n|*.mm)
			stty -opost 0<&1
			;;
		esac
		cat "$file" 2>&1
		stty opost -ocrnl onlcr -onlret tab3 0<&1
		echo "\033P"
		echo "\014\c"
	done
	i=`expr $i + 1`
done
echo "\n\n\n\n\n\n\n\n\n\n"
echo "$x\n$x\n$x\n$x\n\n\n\n\n"
banner "END"
echo "$x\n$x\n$x\n$x\n\n\n\n\n"
echo "\014\c"

#Draining characters might be necessary.
${DRAIN}

exit 0
