15810Sjoerg#!/bin/sh
25810Sjoerg#
35810Sjoerg#
45810Sjoerg# Copyright (c) 1995 Joerg Wunsch
55810Sjoerg#
65810Sjoerg# All rights reserved.
75810Sjoerg#
85810Sjoerg# This program is free software.
95810Sjoerg#
105810Sjoerg# Redistribution and use in source and binary forms, with or without
115810Sjoerg# modification, are permitted provided that the following conditions
125810Sjoerg# are met:
135810Sjoerg# 1. Redistributions of source code must retain the above copyright
145810Sjoerg#    notice, this list of conditions and the following disclaimer.
155810Sjoerg# 2. Redistributions in binary form must reproduce the above copyright
165810Sjoerg#    notice, this list of conditions and the following disclaimer in the
175810Sjoerg#    documentation and/or other materials provided with the distribution.
185810Sjoerg# 3. All advertising materials mentioning features or use of this software
195810Sjoerg#    must display the following acknowledgement:
205810Sjoerg#	This product includes software developed by Joerg Wunsch
215810Sjoerg# 4. The name of the developer may not be used to endorse or promote
225810Sjoerg#    products derived from this software without specific prior written
235810Sjoerg#    permission.
245810Sjoerg#
255810Sjoerg# THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
265810Sjoerg# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
275810Sjoerg# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
285810Sjoerg# IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
295810Sjoerg# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
305810Sjoerg# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
315810Sjoerg# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
325810Sjoerg# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
335810Sjoerg# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
345810Sjoerg# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
355810Sjoerg#
365810Sjoerg#
375810Sjoerg# Posix 1003.2 compliant print spooler interface.
385810Sjoerg#
3950479Speter# $FreeBSD$
405810Sjoerg#
415810Sjoerg
425810Sjoergncopies=""
435810Sjoergsymlink="-s"
44194171Sbrianmailafter=""
45194171Sbriantitle=""
465810Sjoerg
475810Sjoerg# Posix says LPDEST gets precedence over PRINTER
485810Sjoergdest=${LPDEST:-${PRINTER:-lp}}
495810Sjoerg
505810Sjoerg#
515810Sjoerg# XXX We include the -o flag as a dummy.  Posix 1003.2 does not require
525810Sjoerg# it, but the rationale mentions it as a possible future extension.
5357816Ssheldonh# XXX We include the -s flag as a dummy.  SUSv2 requires it,
5457816Ssheldonh# although we do not yet emit the affected messages.
555810Sjoerg#
56194171Sbrianwhile getopts "cd:mn:o:st:" option
575810Sjoergdo
585810Sjoerg	case $option in
595810Sjoerg
605810Sjoerg	c)			# copy files before printing
615810Sjoerg		symlink="";;
625810Sjoerg	d)			# destination
635810Sjoerg		dest="${OPTARG}";;
64194171Sbrian	m)			# mail after job
65194171Sbrian		mailafter="-m";;
665810Sjoerg	n)			# number of copies
675810Sjoerg		ncopies="-#${OPTARG}";;
685810Sjoerg	o)			# (printer option)
695810Sjoerg		: ;;
7057816Ssheldonh	s)			# (silent option)
7157816Ssheldonh		: ;;
72194171Sbrian	t)			# title for banner page
73197625Sjilles		title="${OPTARG}";;
745810Sjoerg	*)			# (error msg printed by getopts)
755810Sjoerg		exit 2;;
765810Sjoerg	esac
775810Sjoergdone
785810Sjoerg
795810Sjoergshift $(($OPTIND - 1))
805810Sjoerg
81197625Sjillesexec /usr/bin/lpr "-P${dest}" ${symlink} ${ncopies} ${mailafter} ${title:+-J"${title}"} "$@"
82