"SfR Fresh" - the SfR Freeware/Shareware Archive

Member "susefilter-1.5/handler/functions" of archive susefilter-1.5.tar.gz:


As a special service "SfR Fresh" has tried to format the requested source page into HTML format using source code syntax highlighting with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. That can be also achieved for any archive member file by clicking within an archive contents listing on the first character of the file(path) respectively on the according byte size field.
    1 #
    2 #  Module handler/functions for apsfilter
    3 #
    4 #  Copyright 1996 S.u.S.E. GmbH
    5 #  Author:   Werner Fink  <werner@suse.de>
    6 #
    7 
    8 #  NB:
    9 #     exit value 0 job did complete normally
   10 #     exit value 1 job did not complete normally and should be reprinted
   11 #     exit value 2 job did not complete normally and should be discarded 
   12 #  (Hope that all lpd's know that:)
   13 
   14 #  Error handling on detecting possible methods and existing programs
   15 #  or filters
   16 #
   17 fault_filetype()
   18 {
   19 	# make noise on system console
   20 	cat > /dev/console <<EOF
   21 apsfilter:
   22 
   23    Unsupported filetype - ${FILE_TYPE} - from $PERSON
   24    OR missing filter $1 !
   25 
   26 Or perhaps you have to type lpr -Pascii to print an ascii
   27 file containing control characters or lpr -Praw to print
   28 a file in your printers native language, when printing data
   29 files (pcl3, pcl5, ...) ?!
   30 EOF
   31 
   32 	# mail to printer admin and user
   33 	$MAILX -s "$FAULTMSG" $NOTIFY 2> /dev/null <<EOF
   34 apsfilter:
   35 
   36    Unsupported filetype - ${FILE_TYPE} - from $PERSON
   37    OR missing filter $1 !
   38 
   39 Or perhaps you have to type lpr -Pascii to print an ascii
   40 file containing control characters or lpr -Praw to print
   41 a file in your printers native language, when printing data
   42 files (pcl3, pcl5, ...) ?!
   43 EOF
   44 }
   45 declare -xf fault_filetype
   46 
   47 fault_method()
   48 {
   49 	echo "apsfilter: unknown print method $METHOD" > /dev/console
   50 	echo "apsfilter: unknown print method $METHOD" \
   51 	| $MAILX -s "$FAULTMSG" $NOTIFY 2> /dev/null
   52 }
   53 declare -xf fault_method
   54 
   55 fault_unpacker()
   56 {
   57 	echo "apsfilter: missing $UNPACKER utility to print file" > /dev/console
   58 	echo "apsfilter: missing $UNPACKER utility to print file" \
   59 	| $MAILX -s "$FAULTMSG" $NOTIFY 2> /dev/null
   60 }
   61 declare -xf fault_unpacker
   62 
   63 #
   64 #  Find a program for unpacking or a filter
   65 #
   66 findfilter()
   67 {
   68 	HAVE=`type -p $1`
   69 	[ -x "$HAVE" ] && eval "HAVE_$2=$HAVE" && return
   70 	fault_filetype $1
   71 	exit 2
   72 }
   73 declare -xf findfilter
   74 
   75 findunpack()
   76 {
   77 	HAVE=`type -p $1`
   78 	[ -x "$HAVE" ] && eval "HAVE_$2=$HAVE" && return
   79 	fault_unpacker
   80 	exit 2
   81 }
   82 declare -xf findunpack
   83 
   84 #
   85 # reads stdin which itself is stdout of gs (currently only)
   86 #
   87 acc_file()
   88 {
   89 	#
   90 	# key has format <int>:<int>:<int>
   91 	# we want the last <int> which is the page count
   92 	# ${ACCTFILE} should be the accounting file
   93 	#
   94 	local pages=0
   95 	while read line; do
   96 	    case $line in
   97 		$key:*)
   98 		    set -- $(echo $line| tr ':' ' ')
   99 		    pages=$3
  100 		    ;;
  101 		*)
  102 		    echo $line
  103 		    ;;
  104 	    esac
  105 	done
  106 	: ${PERSON=unknown}
  107 	: ${HOST=unknown}
  108 	: ${PRINTER=unknown}
  109 	: ${FILTER=f}
  110 	: ${DATE="$(date '+%a %b %d %T %Y')"}
  111 	echo "$PERSON $HOST $PRINTER $pages $FILTER $DATE" >> ${ACCTFILE}
  112 }
  113 declare -xf acc_file
  114 #
  115 # end
  116 #