:
#	@(#) dqp10 23.2 91/08/29 
#
#	Copyright (C) 1988-1991 The Santa Cruz Operation, Inc.
#		All Rights Reserved.
#	The information in this file is provided for the exclusive use of
#	the licensees of The Santa Cruz Operation, Inc.  Such users have the
#	right to use, modify, and incorporate this code into other products
#	for purposes authorized by the license agreement provided they include
#	this notice and the associated copyright notice with any such product.
#	The information in this file is provided "AS IS" without warranty.
#
#ident	"@(#)lp:model/dqp10	1.3.1.2"

# lp interface for DQP-10 Matrix Printer
#

x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

#Set up some global variables.
: ${SPOOLDIR:=/usr/spool/lp}
: ${LOCALPATH:=${SPOOLDIR}/bin}

#Set up the default filter.
if [  -x "${LOCALPATH}/lp.cat" ]
then
	LPCAT="${LOCALPATH}/lp.cat 0"
else
	LPCAT="cat"
fi

#If we are not using a filter, use the default one.
if [ -z "${FILTER}" ]
then
	FILTER="${LPCAT}"
fi

if [ -x "${LOCALPATH}/drain.output" ]
then
	DRAIN="${LOCALPATH}/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 "\033N"
echo "\033]"
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
		0<${file} eval ${FILTER} 2>&1
		stty opost -ocrnl onlcr -onlret tab3 0<&1
		echo "\033N"
		echo "\033]"
		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
