#!/bin/sh
# This script is created by the CONFIGURE shell script.
# You should call it from the $SHOME/cmd/sgml_help script
# or from the Unix prompt like this:  Splus PRINT <HTML file>
# If the -o option is supplied then the help information is put
# into a file instead of going to the printer.
# This script is used by the help() function if the arg offline=T.

usage (){
echo "Usage: $0 [-o out-file] help-file"
echo "  -o out-file  Instead of printing the help file, write it to <out-file>"
echo "  help-file    The HTML file to be printed"
exit 1
}

if [ $# = 0 ]; then usage; fi

while [ $# -ge 0 ]
do
	case $1 in
		-o)  outname=$2; print=no; shift; shift;;
		"-h" | "--help" | "-help") usage;;
		-*)  echo "Unknown option $1"; usage;;
		*)   helpfile=$1; break;;
	esac
done
if [ "X$helpfile" = "X" ]; then usage; fi
if [ ! -f "$helpfile" ]
then 
	echo "The help file \"$helpfile\" does not exist"
	exit 1
fi

if [ "X$outname" = "X" ] 
then
	outname="$S_TMPDIR/PRINT.$$.out"
        print=yes
fi
"$SHOME"/cmd/slynx -cfg="$SHOME/cmd/lynx.cfg" -dump -nolist "$helpfile" > "$outname" || exit 1
if [ $print = yes ]
then
	lp "$outname"
	echo "Sent $helpfile to the printer."
	rm "$outname"
fi

