#!/bin/ash

# lpr wrapper for lpr-local and lpr-remote
# by M.Andreoli (C) 1999


if [ -r /setup/cnf/printer.cnf ] ; then
        . /setup/cnf/printer.cnf
else
        PRINTER=ascii
fi

export PRINTER

# Syntax

case "$1" in
  -P)
    pr=$2;
    shift 2
    ;;
  -P*)
    pr=`echo -n "$1" | sed -e 's/^-P//'`
    shift
    ;;
esac

pr=${pr:-$PRINTER}
prog=`basename $0`

case $1 in
-h)
cat <<END
lpr, lpq, lprm -- muLinux offline printing 

Usage : 
	lpr [-h] [-f output] [-Phost:printer] [files]
	lpq [-P host:printer] -l
	lprm [-P host:printer] [-all | jobs]

Notes:
        This lpr support only ASCII and HP-PCL printers
        and work for fews file-type: TIFF-g3 (fax) and ascii but,
	using -P option, you can redirect your input to remote 
	UNIX printer (BSD-like).

END
exit 0
	;;
esac

# switch local<->remote

case "$pr" in
*:*)	/usr/lpr/rem/$prog -P$pr "$@"
	;;
*)
	echo -n "Send file to $pr ..."
	/usr/lpr/loc/$prog "$@"
	echo "done."
	;;
esac

