:
#	@(#) lzr1260 1.0 90/04/15 
#
#	Copyright (C), Altos Computer Systems, 1990
#	This Module contains Proprietary Information of
#	Altos Computer Systems, and should be treated as Confidential.
#
#	Postscript printer requiring <nl> mapped to <cr><lf>
#
#	Printer : Dataproducts LZR-1260
#
#	This implementation depends on the availability of a 
#	program "pscat", to convert a plain ascii file to a Postscript
#	program.
#	"pscat" will recognize a Postscript program and forward it
#	directly to the printer without conversion.
#

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

# The following variable will not being used..for now.
CONF_FILE="/usr/spool/lp/admins/lp/printers/$printer/configuration"

DEF_STTY_VAL="9600 -parity -tabs -opost ixon ixoff" 
PS_CAT="/usr/altos/bin/pscat"			

shift; shift; shift; shift; shift


stty $DEF_STTY_VAL 0<&1

# If it is necessary to change the baud rate or other stty settings for
# your serial printer you may add the appropriate options here:
#stty 9600 ixon ixoff cread tab3 onlcr 0<&1

# border around the banner
x="XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

# the fifth field of the /etc/passwd file is assigned to the variable user
user=`sed -n "s/^$name:.*:.*:.*:\(.*\):.*:.*$/\1/p" /etc/passwd`

# nhead gets the value of BANNERS or 1 by default
nhead=`sed -n 's/^BANNERS=//p' /etc/default/lpd`
[ "$nhead" -ge 0 -a "$nhead" -le 5 ] || nhead=1

# Build $nhead banners to /tmp/$$b.out
{
while	[ "$nhead" -gt 0 ]
do
	echo "$x\n" >> /tmp/$$b.out
	banner "$name" >> /tmp/$$b.out
	echo "$x\n" >> /tmp/$$b.out
	[ "$user" ] && echo "User: $user\n" >> /tmp/$$b.out
	echo "Request id: $request\n" >> /tmp/$$b.out
	echo "Printer: $printer\n" >> /tmp/$$b.out
	date >> /tmp/$$b.out
	echo >> /tmp/$$b.out
	[ "$title" ] && banner $title >> /tmp/$$b.out
# 	echo "\f\c" >> /tmp/$$b.out
 	nhead=`expr $nhead - 1`
done

# Print the banner and remove the temporary file afterwards
$PS_CAT /tmp/$$b.out
/bin/rm /tmp/$$b.out

# send the file(s) to be printed to the standard out $copies times
# (Use pscat -l72 "$file" for European A4 format paper)
# (and/or pscat -C "$file" for non-recognized postscript formats)
# (This ought to be doable passing parameters with -o to lp!!!!)
while	[ "$copies" -gt 0 ]
do
	for file
	do
	egrep '(cleartomark|PS-Adobe)' "$file"  > /dev/null 2>&1
	if [ $? = 0 ]
	then
	        $PS_CAT -C "$file" 2>&1 
	else
 		$PS_CAT "$file" 2>&1
	fi
	done
	copies=`expr $copies - 1`
done
} 
exit 0
