:
#
#	Your favorite way to print fax files
#
#	faxprint [options] [files]
#
#	NOTE: this script is automatically called from "faxrcv"
#	and may be passed the options -r1, -r2, -r3, or -r4.
#	Make sure that you handle these options if you change the
#	*logic* in this script.  "-r1" means print at the lowest
#	available resolution. "-r4" means print at the highest
#	available resolution. "-r2" and "-r3" are in between.
#	No "-r" option means choose a default resolution.
#
#	BEGIN CONFIGURATION SECTION (adjust these values as needed)
#
printer="lj"		# Default printer.  Possible values:
			# epson-fx	Epson MX/FX/JX/LX/CX printers
			# epson-lq	Epson LQ 800/1000 printers
			# lj		LaserJet+, LaserJet Series II, III
			# lj2p		LaserJet Series IIP
			# lj3		LaserJet Series III
			# lj4		LaserJet Series IV
			# bj10e		Canon Bubble Jet bj-10e, bj-200
			# ps		PostScript printers
res="2"			# Default printer resolution is medium-low
paper=""		# Force paper selection with legal, letter, or a4
options=""		# Any additonal default options
raw_lp_opt="-oraw -og"	# Option used by your lp interface to force
			# "raw" or 8-bit transparent output
			# -oraw is what our supplied "hplaser" lp model uses
			# -og is what SCO's "hpjet" lp model uses
			# we list them both to be safe
force_dest=""		# Name to force a particular printer destination
wantfooter=1		# Want filename for footer (0/1)
wantheader=1		# Want filename for header (0/1)
spooler="lp"		# Line printer spooler
#
#	END CONFIGURATION SECTION
#

#	Usage message
usage() {
	cat <<EOF
Usage: $0 [options] fax_files...

Convert and print FAX files.

	-T printer	Select printer type
	-r res		Select printing resolution (1, 2, 3, 4)
	-p range	Print only pages in range
EOF
}

#	Process options
set -- `getopt ?T:r:P:c:D:h:f:x:y:p:F $*`
if [ $? != 0 ]; then usage; exit 2; fi
for i in $*
do
	case $i in
	-T)		printer="$2"; shift; shift;;
	-r)		res="$2"; shift; shift;;
	-[pPcDhfxy])	options="$options $i$2"; shift; shift;;
	-F)		options="$options $i"; shift;;
	--)		shift; break;;
	-?)		usage; exit 0;;
	esac
done
files="$*"

prog=fax2pr

case "$printer" in
ibm-pro*)
		printer="ibm-pro"
		case "$res" in
		240|4)	res=240;;
		120|3)	res=120;;
		60|2|1)	res=60;;
		*)	res=240;;
		esac
		;;
epson-fx*)
		printer="epson-fx"
		case "$res" in
		240|4)	res=240;;
		120|3)	res=120;;
		60|2|1)	res=60;;
		*)	res=240;;
		esac
		;;
epson-lq*)
		printer="epson-lq"
		case "$res" in
		180|4)	res=180;;
		*)	res=180;;
		esac
		;;
bj*)		# Probably works for proprinter x24e, too
		printer="bj10e"
		case "$res" in
		360|4)	res=360;;
		*)	res=180;;
		esac
		;;
lj2p*)
		printer="lj2p"
		case "$res" in
		300|4)	res=300;;
		150|3)	res=150;;
		100|2)	res=100;;
		75|1)	res=75;;
		*)	res=100;;
		esac
		;;
lj3*|lj4*)
		printer="lj3"
		case "$res" in
		300|4)	res=300;;
		150|3)	res=150;;
		100|2)	res=100;;
		75|1)	res=75;;
		*)	res=100;;
		esac
		;;
lj*)
		printer="lj"
		case "$res" in
		300|4)	res=300;;
		150|3)	res=150;;
		100|2)	res=100;;
		75|1)	res=75;;
		*)	res=100;;
		esac
		;;
ps)
		prog=fax2ps	#Special program for Postscript
		printer=
		res=
		;;
esac

printer="-T${printer}-$res"
paper="${paper:+-P$paper}"
force_dest="${force_dest:+-d$force_dest}"

if [ "Q$files" = Q ]
then
	$prog $paper $options $printer 2>/dev/null |
		$spooler $raw_lp_opt $force_dest 2>/dev/null
else
	for i in $files
	do
		filename=`basename $i`
		if [ $wantfooter = 1 ]; then f="-f $filename"; else f=""; fi
		if [ $wantheader = 1 ]; then h="-h $filename"; else h=""; fi
		$prog $paper $f $h $options $printer $i 2>/dev/null |
			$spooler $raw_lp_opt -t$filename $force_dest 2>/dev/null
	done
fi
