# # Module handler/functions for apsfilter # # Copyright 1996 S.u.S.E. GmbH # Author: Werner Fink # # NB: # exit value 0 job did complete normally # exit value 1 job did not complete normally and should be reprinted # exit value 2 job did not complete normally and should be discarded # (Hope that all lpd's know that:) # Error handling on detecting possible methods and existing programs # or filters # fault_filetype() { # make noise on system console cat > /dev/console < /dev/null < /dev/console echo "apsfilter: unknown print method $METHOD" \ | $MAILX -s "$FAULTMSG" $NOTIFY 2> /dev/null } declare -xf fault_method fault_unpacker() { echo "apsfilter: missing $UNPACKER utility to print file" > /dev/console echo "apsfilter: missing $UNPACKER utility to print file" \ | $MAILX -s "$FAULTMSG" $NOTIFY 2> /dev/null } declare -xf fault_unpacker # # Find a program for unpacking or a filter # findfilter() { HAVE=`type -p $1` [ -x "$HAVE" ] && eval "HAVE_$2=$HAVE" && return fault_filetype $1 exit 2 } declare -xf findfilter findunpack() { HAVE=`type -p $1` [ -x "$HAVE" ] && eval "HAVE_$2=$HAVE" && return fault_unpacker exit 2 } declare -xf findunpack # # reads stdin which itself is stdout of gs (currently only) # acc_file() { # # key has format :: # we want the last which is the page count # ${ACCTFILE} should be the accounting file # local pages=0 while read line; do case $line in $key:*) set -- $(echo $line| tr ':' ' ') pages=$3 ;; *) echo $line ;; esac done : ${PERSON=unknown} : ${HOST=unknown} : ${PRINTER=unknown} : ${FILTER=f} : ${DATE="$(date '+%a %b %d %T %Y')"} echo "$PERSON $HOST $PRINTER $pages $FILTER $DATE" >> ${ACCTFILE} } declare -xf acc_file # # end #