File notification.diff of Package hylafax+

diff -rauiEZbB a/util/common-functions.sh.in b/util/common-functions.sh.in
--- a/util/common-functions.sh.in	2017-02-18 02:03:07.000000000 +0100
+++ b/util/common-functions.sh.in	2017-12-23 19:42:34.733559532 +0100
@@ -1,4 +1,4 @@
-#! @SCRIPT_SH@
+#! /bin/bash
 #    $Id: common-functions.sh.in 1159 2013-05-11 21:05:30Z faxguy $
 
 #
@@ -11,20 +11,25 @@
 #
 encode()
 {
-    if [ ! -f "$1" ]; then
+	if [ ! -f "$1" ]
+	then
 	return	# encode what?
     fi
-    if [ -x "$MIMENCODE" ]; then
+	if [ -x "$MIMENCODE" ]
+	then
 	$MIMENCODE < $1 2>$ERRORSTO
-    elif [ -x "$UUENCODE" ]; then
-	if [ "$ENCODING" = "base64" ]; then
+	elif [ -x "$UUENCODE" ]
+	then
+		if [ "$ENCODING" = "base64" ]
+		then
 	    $UUENCODE -m $1 ==== | $GREP -v "====$" 2>$ERRORSTO
 	else
 	    $UUENCODE $1 $1 2>$ERRORSTO
 	fi
     else
 	# Do not use "-x" for backward compatibility; even if it fails
-	# this is last chance to encode data, so there's nothing to lose.
+		# this is last chance to encode data, so there's nothing to
+		# lose.
 	$MIMENCODE < $1 2>$ERRORSTO
     fi
 }
@@ -35,13 +40,17 @@
 #
 setInfoSize()
 {
-    INFOSIZE=`$INFO -n $1 | $SED 's/:.*//g' | $SED q | $AWK 'BEGIN {L=0} length>L {L=length} END {print L}'`
+	INFOSIZE=`$INFO -n $1 | $SED 's/:.*//g' | $SED q |
+	$AWK 'BEGIN {L=0} length>L {L=length} END {print L}'`
     for ITEM in DICTSENDER DICTPAGES DICTQUALITY DICTSIZE DICTRECEIVED \
 		DICTTIMETORECV DICTSIGNALRATE DICTDATAFORMAT DICTERRCORRECT \
 		DICTCALLID1 DICTCALLID2 DICTCALLID3 DICTCALLID4 DICTCALLID \
-		DICTCALLID6 DICTCALLID7 DICTRECEIVEDON DICTCOMMID; do
+		DICTCALLID6 DICTCALLID7 DICTRECEIVEDON DICTCOMMID
+	do
 	THISLEN="`eval echo \\\""$"$ITEM\\\" | $AWK 'BEGIN {L=0} length>L {L=length} END {print L}' | $SED 's/ //g'`"
-	if [ $THISLEN -gt $INFOSIZE ]; then INFOSIZE=$THISLEN; fi
+		if [ $THISLEN -gt $INFOSIZE ]
+		then INFOSIZE=$THISLEN
+		fi
     done
 }
 
@@ -51,14 +60,18 @@
 setItemSize()
 {
     ITEMSIZE=0
-    for ITEM in DICTDESTINATION DICTJOBID DICTGROUPID DICTSENDER DICTMAILADDR \
-		DICTCOMMID DICTMODEM DICTSUBMITTEDFROM DICTPAGEWIDTH \
-		DICTPAGELENGTH DICTRES DICTSTATUS DICTDIALOGS DICTDIALS \
-		DICTCALLS DICTPAGES DICTATTEMPTS DICTDIRNUM DICTRECEIVER DICTQUALITY \
-		DICTPAGEWIDTH DICTPAGELENGTH DICTDATAFORMAT DICTREMOTEEQUIPMENT \
-		DICTREMOTESTATION DICTSIGNALRATE; do
+	for ITEM in DICTDESTINATION DICTJOBID DICTGROUPID DICTSENDER \
+		DICTMAILADDR DICTCOMMID DICTMODEM DICTSUBMITTEDFROM \
+		DICTPAGEWIDTH DICTPAGELENGTH DICTRES DICTSTATUS DICTDIALOGS \
+		DICTDIALS DICTCALLS DICTPAGES DICTATTEMPTS DICTDIRNUM \
+		DICTRECEIVER DICTQUALITY DICTPAGEWIDTH DICTPAGELENGTH \
+		DICTDATAFORMAT DICTREMOTEEQUIPMENT DICTREMOTESTATION \
+		DICTSIGNALRATE
+	do
 	THISLEN="`eval echo \\\""$"$ITEM\\\" | $AWK 'BEGIN {L=0} length>L {L=length} END {print L}' | $SED 's/ //g'`"
-	if [ $THISLEN -gt $ITEMSIZE ]; then ITEMSIZE=$THISLEN; fi
+		if [ $THISLEN -gt $ITEMSIZE ]
+		then ITEMSIZE=$THISLEN
+		fi
     done
 }
 
@@ -112,12 +125,14 @@
     # print out variable name and value so we can eval it in the shell
     #
     VAR_PREFIX="$1"
-    if [ -n "$2" ] ; then
-        FILENAME=$2;
+	if [ -n "$2" ]
+	then
+		FILENAME=$2
     else
-        FILENAME=$QFILE;
+		FILENAME=$QFILE
     fi
-    if [ ! -f "$FILENAME" ] ; then
+	if [ ! -f "$FILENAME" ]
+	then
         return # cannot do much more without a file
     fi
     $AWK -F: '
@@ -185,41 +200,45 @@
 	2432x*|3648x*|4864x*)
 	    paper=a3;;
 	*)
-	    echo "$0: Unsupported page size: $pagewidth x $pagelength";
+			echo "$0: Unsupported page size: $pagewidth x $pagelength"
 	    exit 254;;			# causes document to be rejected
     esac
     #
     # The image must end up with a pixel width according to T.32 Table 21.
-    # Ghostscript contains code to fixate a4 and letter to 1728 pixels
-    # when using 196-204 dpi and tiffg3/4.  It supposedly does the same for
-    # B4 but not for A3, thus the floats are needed (for A3's benefit).
+	# Ghostscript contains code to fixate a4 and letter to 1728 pixels when
+	# using 196-204 dpi and tiffg3/4.  It supposedly does the same for B4
+	# but not for A3, thus the floats are needed (for A3's benefit).
     # However, this behavior does nothing for US legal as well as the myriad
     # other page sizes (other than A4, US Letter, and B4) that we sometimes
-    # see.  So we have to carefully ensure that our formatting will be right.
+	# see.  So we have to carefully ensure that our formatting will be
+	# right.
     #
-    # Depending on which Ghostcript version is being used our default approach
-    # in getting all pages sized properly varies by default.  We either use a 
-    # combination of -dEPSFitPage and -dPDFFitPage, or for newer Ghostscript 
-    # versions we use -dAdjustWidth, instead.  These make it so that the image 
-    # is resized to fit the page media and prevents page sizing within the 
-    # documents from altering the command-line page-size specification.  (In 
-    # the past -dFIXEDMEDIA was used for this purpose, but -dFIXEDMEDIA doesn't 
-    # resize documents, it just cuts them.)  The benefit to -dAdjustWidth is 
-    # that it permits TIFFs to be made with pages of varied length (such as 
-    # mixed letter and legal) whereas -dEPSFitPage and -dPDFFitPage will create 
-    # pages of all the same length.
-    #
-    # We use -dUseCropBox to prevent utilization of the full MediaBox (as they
-    # can differ).  Remove this if there is regularly desireable content 
-    # outside the CropBox.
+	# Depending on which Ghostcript version is being used our default
+	# approach in getting all pages sized properly varies by default.  We
+	# either use a combination of -dEPSFitPage and -dPDFFitPage, or for
+	# newer Ghostscript versions we use -dAdjustWidth, instead.  These make
+	# it so that the image is resized to fit the page media and prevents
+	# page sizing within the documents from altering the command-line
+	# page-size specification.  (In the past -dFIXEDMEDIA was used for this
+	# purpose, but -dFIXEDMEDIA doesn't resize documents, it just cuts
+	# them.)  The benefit to -dAdjustWidth is that it permits TIFFs to be
+	# made with pages of varied length (such as mixed letter and legal)
+	# whereas -dEPSFitPage and -dPDFFitPage will create pages of all the
+	# same length.
+	#
+	# We use -dUseCropBox to prevent utilization of the full MediaBox (as
+	# they can differ).  Remove this if there is regularly desireable
+	# content outside the CropBox.
     #
-    if [ "$GSMAJVER" -eq 8 ] && [ "$GSMINVER" -eq 70 ]; then
+	if [ "$GSMAJVER" -eq 8 ] && [ "$GSMINVER" -eq 70 ]
+	then
 	# There's a bug with -dUseCropBox on 8.70 when it finds no MediaBox/CropBox.
 	FIXEDWIDTH=""
     else
 	FIXEDWIDTH="-dUseCropBox"
     fi
-    if [ "$GSMAJVER" -gt 9 ] || [ "$GSMAJVER" -eq 9 ] && [ "$GSMINVER" -ge 4 ]; then
+	if [ "$GSMAJVER" -gt 9 ] || [ "$GSMAJVER" -eq 9 ] && [ "$GSMINVER" -ge 4 ]
+	then
 	FIXEDWIDTH="$FIXEDWIDTH -dAdjustWidth=$pagewidth"
     else
 	FIXEDWIDTH="$FIXEDWIDTH -dEPSFitPage -dPDFFitPage"
@@ -278,7 +297,8 @@
     # This feature can be disabled with AUTOROTATE="" in etc/FaxModify and
     # only works for Ghostscript 8 and later.
     #
-    if [ "$GSMAJVER" -gt 7 ]; then
+	if [ "$GSMAJVER" -gt 7 ]
+	then
 	AUTOROTATE="bin/auto-rotate.ps"
     else
 	AUTOROTATE=""
@@ -302,11 +322,13 @@
     #
     # Apply customizations such as watermarking.
     #
-    if [ -f etc/FaxModify ]; then
+	if [ -f etc/FaxModify ]
+	then
 	. etc/FaxModify
     fi
 
-    if [ "$color" = "yes" ]; then
+	if [ "$color" = "yes" ]
+	then
 	# We should prepare a color image - possibly in addition to monochrome.
 	# Square resolutions are mandatory per ITU T.30 Table 2 Notes 25 and 34,
 	# so we use hres for vertical resolution as well.
@@ -317,20 +339,23 @@
 	    *)  chres=203.29;;		# 1728 pixels
 	esac
 	outfile=$out
-	if [ "$device" != "tiff24nc" ]; then
+		if [ "$device" != "tiff24nc" ]
+		then
 	    # Indicates color-only
 	    outfile="$out.color"
 	fi
 	$PS -q -sDEVICE=tiff24nc -dNOPAUSE -dSAFER=true -sPAPERSIZE=$paper \
 	    -dBATCH -r$chres\x$chres "-sOutputFile=$outfile" $STRIPSIZE $FIXEDWIDTH $AUTOROTATE $files
-	if [ "$device" = "tiff24nc" ]; then
+		if [ "$device" = "tiff24nc" ]
+		then
 	    $RM -f "$out.color"
 	    return
 	fi
     else
 	$RM -f "$out.color"
     fi
-    if [ "$DITHERING" = "gs-stocht" ]; then
+	if [ "$DITHERING" = "gs-stocht" ]
+	then
 	$CAT $files | $PS -q \
 	    -sDEVICE=$device \
 	    -dNOPAUSE \
@@ -347,14 +372,16 @@
     fi
     if [ "$DITHERING" = "libtiff-fs" ] && ($PS -h | $GREP tiff24nc >/dev/null 2>&1) && \
        [ -x $TIFFBIN/tiff2bw ] && [ -x $TIFFBIN/tiffdither ] && [ -x $TIFFBIN/tiff2ps ] && \
-       [ -x $TIFFBIN/tiffsplit ] && [ -x $TIFFBIN/tiffcp ]; then
+		[ -x $TIFFBIN/tiffsplit ] && [ -x $TIFFBIN/tiffcp ]
+	then
 	$PS -q -sDEVICE=tiff24nc -dNOPAUSE -dSAFER=true -sPAPERSIZE=$paper \
 	    -dBATCH -r$hres\x$vres "-sOutputFile=$out.1" $STRIPSIZE $FIXEDWIDTH $AUTOROTATE $files
 	# Both tiff2bw and tiffdither only operate on single pages, so...
 	mkdir tmpdir.$$
 	cd tmpdir.$$
 	$TIFFBIN/tiffsplit ../$out.1
-	for i in *; do
+		for i in *
+		do
 	    $TIFFBIN/tiff2bw $i $i.2
 	    $TIFFBIN/tiffdither $i.2 $i.3
 	    $RM -f $i $i.2
@@ -386,7 +413,8 @@
 	$AUTOROTATE \
 	$files
 
-    if [ "$DITHERING" = "libtiff-fs" ]; then
+	if [ "$DITHERING" = "libtiff-fs" ]
+	then
 	$RM -f $out.1 $out.2 $out.3
     fi
     #
@@ -408,7 +436,8 @@
 tiffCheck()
 {
     CLEARTMP=no
-    if [ "$fil" = "$out" ]; then
+	if [ "$fil" = "$out" ]
+	then
 	CLEARTMP=yes
 	fil="$fil.$$.tmp"
 	$MV $out $fil
@@ -453,25 +482,35 @@
 	# The -p is needed or ownership and permissions can be lost.
 	#
 	$CP -p -f $fil $out
-	if [ "$CLEARTMP" = "yes" ]; then $RM -f $fil; fi
+			if [ "$CLEARTMP" = "yes" ]
+			then $RM -f $fil
+			fi
 	exit 0			# successful conversion
 	;;
     *REJECT*)			# document rejected out of hand
 	echo "$RESULT" | $SED 1d
-	if [ "$CLEARTMP" = "yes" ]; then $RM -f $fil; fi
+			if [ "$CLEARTMP" = "yes" ]
+			then $RM -f $fil
+			fi
 	exit 254			# reject document
 	;;
     REFORMAT)			# only need format conversion (e.g. g4->g3)
 	rowsperstrip="-r 9999 "
-	if [ -n "`$TIFFINFO $fil | $GREP 'Compression Scheme: ISO JBIG'`" ]; then
+			if [ -n "`$TIFFINFO $fil | $GREP 'Compression Scheme: ISO JBIG'`" ]
+			then
 	    rowsperstrip=""
 	fi
 	$TIFFCP -i -c $df -f lsb2msb $rowsperstrip$fil $out
 
 	# libtiff 3.5.7 gives exit status 9 when there are unknown tags...
 	exitcode=$?
-	if [ "$CLEARTMP" = "yes" ]; then $RM -f $fil; fi
-	if [ $exitcode != 0 ] && [ $exitcode != 9 ]; then {
+			if [ "$CLEARTMP" = "yes" ]
+			then
+				$RM -f $fil
+			fi
+			if [ $exitcode != 0 ] && [ $exitcode != 9 ]
+			then
+				{
 	    $CAT<<EOF
 Unexpected failure converting TIFF document; the command
 
@@ -480,7 +519,8 @@
 failed with exit status $?.  This conversion was done because:
 
 EOF
-	    echo "$RESULT" | $SED 1d; exit 254
+					echo "$RESULT" | $SED 1d
+					exit 254
 	}
 	fi
 	exit 0
@@ -491,24 +531,33 @@
     # *REIMAGE			maybe should reject (XXX)
     #
     *REVRES|*RESIZE|*REIMAGE)
-	if [ -z "$PS2FAX" ]; then
+			if [ -z "$PS2FAX" ]
+			then
 	    echo "Unable to format with converters."
 	    echo "Preventing recursion."
-	    if [ "$CLEARTMP" = "yes" ]; then $RM -f $fil; fi
+				if [ "$CLEARTMP" = "yes" ]
+				then $RM -f $fil
+				fi
 	    exit 254
 	fi
-	#
-	# Previously we used tiff2ps here instead of tiff2pdf, however, this was problematic
-	# with conversion of TIFFs which were not the same size as the target page.  To fix 
-	# this it would have required pushing image dimensions to Ghostscript for it to use
-	# the -g option, and that would require a lot of converter-script modifications.  It 
-	# is easier to simply use tiff2pdf because the PDF output includes the image 
-	# dimensions which are then fed to Ghostscript.  (Which would have also been 
-	# accomplished with the tiff2ps -2 or -3 options, however, in those cases tiff2ps 
-	# resizes the image to fit on the page, and other options, -h and -w, which may not 
-	# be available to all tiff2ps versions would have needed to be used.)
-	#
-	($TIFF2PDF -o $out.$$.pdf $fil; $PDF2FAX -o $out -i "$jobid" $opt $out.$$.pdf && $RM -f $out.$$.pdf) || {
+			# Previously we used tiff2ps here instead of tiff2pdf, however, this
+			# was problematic with conversion of TIFFs which were not the same
+			# size as the target page.  To fix this it would have required
+			# pushing image dimensions to Ghostscript for it to use the -g
+			# option, and that would require a lot of converter-script
+			# modifications.  It is easier to simply use tiff2pdf because the PDF
+			# output includes the image dimensions which are then fed to
+			# Ghostscript.  (Which would have also been accomplished with the
+			# tiff2ps -2 or -3 options, however, in those cases tiff2ps resizes
+			# the image to fit on the page, and other options, -h and -w, which
+			# may not be available to all tiff2ps versions would have needed to
+			# be used.)
+			(
+				$TIFF2PDF -o $out.$$.pdf $fil
+				$PDF2FAX -o $out -i "$jobid" $opt $out.$$.pdf &&
+				$RM -f $out.$$.pdf
+			) ||
+			{
 	    $CAT<<EOF
 Unexpected failure converting TIFF document; the command
 
@@ -517,9 +566,13 @@
 failed with exit status $?.  This conversion was done because
 
 EOF
-	    echo "$RESULT" | $SED 1d; exit 254
+				echo "$RESULT" | $SED 1d
+				exit 254
 	}
-	if [ "$CLEARTMP" = "yes" ]; then $RM -f $fil; fi
+			if [ "$CLEARTMP" = "yes" ]
+			then
+				$RM -f $fil
+			fi
 	exit 0
 	;;
     *)				# something went wrong
@@ -528,7 +581,10 @@
 	echo ""
 	echo "$RESULT"
 	echo ""
-	if [ "$CLEARTMP" = "yes" ]; then $RM -f $fil; fi
+			if [ "$CLEARTMP" = "yes" ]
+			then
+				$RM -f $fil
+			fi
 	exit 254			# no formatter
 	;;
     esac
@@ -536,16 +592,19 @@
 
 SetupPrivateTmp()
 {
-    if [ -d "$HYLAFAX_TMPDIR" ]; then
+	if [ -d "$HYLAFAX_TMPDIR" ]
+	then
         # Private temp area already created.
         return
     fi
 
     # Would have liked to use -t, but older mktemp don't support it.
-    if [ -z "$TMPDIR" ] || [ ! -w "$TMPDIR" ]; then
+	if [ -z "$TMPDIR" ] || [ ! -w "$TMPDIR" ]
+	then
         TMPDIR="/tmp"
     fi
-    HYLAFAX_TMPDIR=`mktemp -d $TMPDIR/hylafaxtmp-XXXXXXXX 2>/dev/null` || {
+	HYLAFAX_TMPDIR=`mktemp -d $TMPDIR/hylafaxtmp-XXXXXXXX 2>/dev/null` ||
+	{
         HYLAFAX_TMPDIR="$TMPDIR/hylafaxtmp-$RANDOM-$RANDOM-$RANDOM-$$"
         mkdir -m 0700 "$HYLAFAX_TMPDIR"
     }
@@ -581,3 +640,187 @@
     cleanupExit
     exit $1
 }
+
+assign_cmd_subst()
+{
+	# Parameters:
+	# variablename 'commandline ...' [ positional parameters ...]
+	#
+	# 'eval' the commandline and assign its standard output data to the
+	# given variable (like command substitution), preserving trailing
+	# newlines (unlike command substitution).
+	#
+	# The positional parameters ("$@") are set to the given positional
+	# parameters and then the commandline is evaluated in a subshell
+	# execution environment.  Its standard output data is assigned to the
+	# given variable.
+	#
+	# Return the exit code of the commandline.
+
+	set false "$@"
+	# "$1", if executed, signals an error if and only if it returns with
+	# exit code 0.
+
+	if ${2+false} :
+	then
+		# No parameters have been given:
+		printf '%s: %s\n' assign_cmd_subst \
+			'Missing variable name.' >&2
+		# Signal an error:
+		shift; set : "$@"
+	elif ! LC_ALL=C expr " $2" : \
+		' [[:alpha:]_][[:alnum:]_]*$' > /dev/null
+	then
+		printf '%s: %s: is not a variable name.\n' \
+			assign_cmd_subst "$2" >&2
+		# Signal an error:
+		shift; set : "$@"
+	fi
+	if ${3+false} :
+	then
+		printf '%s: %s\n' assign_cmd_subst \
+			'Missing commandline.' >&2
+		# Signal an error:
+		shift; set : "$@"
+	fi
+	if "$1"
+	then
+		# An error occurred.  Fail.
+		return 125
+	else
+		shift
+		# "$1" looks like a variable name.
+		eval "$1"'="$( ( shift 2; '"$2"' ); ec="$?";' \
+			'printf %s .; exit "$ec" )"'
+		set "$?" "$1"
+		eval "$2"'="${'"$2"'%.}"'
+		return "$1"
+	fi
+}
+
+set_exit_code()
+{
+	return ${1+"$1"}
+}
+
+rfc2047-encode()
+{
+	# RFC2047-encode a part of a header field value.
+	#
+	# required parameters:
+	#
+	# * number of already used columns in the current line,
+	#
+	# * charset name,
+	#
+	# * header field value to be encoded,
+	#
+	# optional parameters:
+	#
+	# * name of a variable to store the number of already used columns in
+	#   the last line.
+	#
+	# The encoded text is sent to standard output.
+
+	eval "$( rfc2047-encode-2 "$@" )"
+} 3>&1
+
+rfc2047-encode-2()
+{
+	# Caller environment:
+	#
+	# File descriptor #3: receives the encoded text.
+	#
+	# File descriptor #1: receives shell commands for the caller
+	# environment to be "eval"ed.
+	#
+	# required parameters:
+	#
+	# * number of already used columns in the current line,
+	#
+	# * charset_name,
+	#
+	# * header field value to be encoded,
+	#
+	# optional parameters:
+	#
+	# * name of a variable to store the number of already used columns in
+	#   the last line.
+
+	set -u &&
+	columns_in_use="${1:?missing number of already used columns}" &&
+	charset="${2:?missing non-empty charset name}" &&
+	value="${3?missing header field value}" &&
+	column_variable="${4-}" &&
+	prefix=' =?'"$charset"'?Q?' &&
+	suffix='?=' &&
+	: $(( columns_in_use += ${#prefix} + ${#suffix} )) &&
+	printf '%s' "${prefix}" >&3 &&
+	while
+		character="${value%"${value#?}"}" &&
+		# "$character" is the first (maybe multi-byte) character of
+		# "$value".
+		${character:+:} false &&
+		value="${value#"$character"}"
+	do
+		(
+			# In order to process the individual octets of a single
+			# (maybe multi-byte) character, change the locale to
+			# the POSIX locale:
+			export LC_ALL && LC_ALL=C &&
+			encoded_character= && length_of_encoded_character=0 &&
+			while
+				octet="${character%"${character#?}"}" &&
+				${octet:+:} false &&
+				character="${character#"$octet"}"
+			do
+				case "$octet" in
+					[[:alnum:]])
+						;;
+					*)
+						octet="$( printf '=%.2X' \
+							\'"$octet" )"
+						;;
+				esac
+				encoded_character="${encoded_character}${octet}"
+			done &&
+			printf '%s\n' "$encoded_character"
+		)
+	done 3>&- |
+	{
+		{
+			while read -r encoded_character
+			do
+				length_of_encoded_character="${#encoded_character}" &&
+				if test $(( columns_in_use += \
+					length_of_encoded_character )) -gt 75
+				then
+					# Appending the encoded character would
+					# make the current line too long.
+					#
+					# Finish the current encoded word
+					# without appending the encoded
+					# character, then start in a
+					# continuation line a new encoded
+					# word beginning with the encoded
+					# character.
+					columns_in_use=$(( ${#prefix} + \
+						length_of_encoded_character + \
+						${#suffix} ))
+					printf '%s\n%s' "$suffix" "$prefix"
+				fi &&
+				printf '%s' "$encoded_character"
+			done &&
+			printf '%s' "$suffix"
+		} >&3
+		{
+			ec="$?"
+			if ${column_variable:+:} false
+			then
+				printf '%s=%s\n' "$column_variable" \
+					"$columns_in_use"
+			fi
+			printf 'set_exit_code %s\n' "$ec"
+		} 3>&-
+	}
+}
diff -rauiEZbB a/util/dictionary.sh.in b/util/dictionary.sh.in
--- a/util/dictionary.sh.in	2017-02-18 02:03:08.000000000 +0100
+++ b/util/dictionary.sh.in	2017-12-23 19:42:34.733559532 +0100
@@ -1,9 +1,7 @@
-#! @SCRIPT_SH@
+#! /bin/bash
 #    $Id: dictionary.sh.in 1073 2011-12-13 23:37:07Z faxguy $
 
-LANG=`echo $LANG | sed 's/^cn_/zh_/'`	# fix wrong Chinese locale
-
-case "$LANG" in
+case "${NOTIFICATIONLANGUAGE:-${LC_ALL:-${LC_MESSAGES:-${LANG:-}}}}" in
     nl_BE*)
 	. bin/dict/nl_BE
 	;;
@@ -37,7 +35,7 @@
     tr_*)
 	. bin/dict/tr
 	;;
-    zh_*)
+	zh_*|cn_*)
 	. bin/dict/zh
 	;;
     sr_*)
@@ -54,8 +52,135 @@
 	;;
 esac
 
-#
-# Modify LANG according to CHARSET
-#
-LANG="`echo $LANG | $SED 's/\..*//'`.$CHARSET"
-export LANG
+for variable in \
+	DICTRECEIVEAGENT \
+	DICTRECEIVEDFROM \
+	DICTRETRIEVEDFROM \
+	DICTMSGINTRO \
+	DICTLOGFOLLOWS \
+	DICTLOGFOLLOWS2 \
+	DICTNOLOGAVAIL \
+	DICTDISPATCHEDTO \
+	DICTPOLLDISPATCHTO \
+	DICTNOTRECEIVED \
+	DICTATTEMPTEDFAXFAILED \
+	DICTATTEMPTEDPOLLFAILED \
+	DICTFAILEDBECAUSE \
+	DICTUNKNOWNDOCTYPE \
+	DICTNOFILEEXISTS \
+	DICTDESTINATION \
+	DICTJOBID \
+	DICTGROUPID \
+	DICTSENDER \
+	DICTMAILADDR \
+	DICTMODEM \
+	DICTCOMMID \
+	DICTSUBMITTEDFROM \
+	DICTPAGEWIDTH \
+	DICTPAGELENGTH \
+	DICTRES \
+	DICTNOTHINGAVAIL \
+	DICTSTATUS \
+	DICTREMOTEEXCHANGES \
+	DICTDIALOGS \
+	DICTFAILEDCALLS \
+	DICTDIALS \
+	DICTTOTALCALLS \
+	DICTCALLS \
+	DICTPAGESTRANSMITTED \
+	DICTPAGES \
+	DICTTOTALPAGES \
+	DICTTOTPAGES \
+	DICTATTEMPTSPAGE \
+	DICTATTEMPTS \
+	DICTDIRNEXTPAGE \
+	DICTDIRNUM \
+	DICTDOCSSUBMITTED \
+	DICTDOCSTEXT1 \
+	DICTDOCSTEXT2 \
+	DICTDOCSTEXT3 \
+	DICTDOCSTEXT4 \
+	DICTFILENAME \
+	DICTSIZE \
+	DICTTYPE \
+	DICTUNSENTPAGES \
+	DICTUNSENTJOBSTATUS \
+	DICTPIN \
+	DICTMESSAGETEXT \
+	DICTNOREASON \
+	DICTYOURJOBTO \
+	DICTfacsimile \
+	DICTpager \
+	DICTJOB \
+	DICTAT \
+	DICTTO \
+	DICTCOMPLETED \
+	DICTCOMPLETEDSUCCESSFULLY \
+	DICTRECEIVER \
+	DICTQUALITY \
+	DICTFINE \
+	DICTNORMAL \
+	DICTSIGNALRATE \
+	DICTDATAFORMAT \
+	DICTREMOTEEQUIPMENT \
+	DICTREMOTESTATION \
+	DICTPROCESSINGTIME \
+	DICTADDITIONALINFO \
+	DICTFAILED \
+	DICTREJECTEDBECAUSE \
+	DICTBLOCKED \
+	DICTDELAYEDBECAUSE \
+	DICTASSOONASPOSSIBLE \
+	DICTREQUEUED \
+	DICTWASNOTSENT \
+	DICTWILLBERETRIED \
+	DICTREMOVEDFROMQUEUE \
+	DICTWASDELETED \
+	DICTTIMEDOUT \
+	DICTCONVERSION1 \
+	DICTCONVERSION2 \
+	DICTCONVERSION3 \
+	DICTNOFORMATTER1 \
+	DICTNOFORMATTER2 \
+	DICTNOTICEABOUT \
+	DICTPOLLINGFAILED \
+	DICTREMOTEREJECTED \
+	DICTNODOCTOPOLL \
+	DICTUNSPECIFIEDPROBLEM \
+	DICTUNKNOWNREASON1 \
+	DICTUNKNOWNREASON2 \
+	DICTUNKNOWNREASON3 \
+	DICTUNKNOWNREASON4 \
+	DICTRECEIVEDON \
+	DICTPOLLFAILED \
+	DICTYES \
+	DICTNO \
+	DICTRECEIVED \
+	DICTTIMETORECV \
+	DICTERRCORRECT \
+	DICTCALLID1 \
+	DICTCALLID2 \
+	DICTCALLID3 \
+	DICTCALLID4 \
+	DICTCALLID5 \
+	DICTCALLID6 \
+	DICTCALLID7
+do
+	# Recode the variable's value to the character map as defined by the
+	# current locale:
+	if eval '${'"$variable"'+:} false'
+	then
+		# "$variable" denotes an existing variable.
+		# Recode it from the character set "$CHARSET" to the
+		# character set according to the current locale settings:
+		assign_cmd_subst "$variable" \
+			'LC_ALL=C printf %s "${'"$variable"'}" | "$@"' \
+			iconv -c -f "$CHARSET"
+	fi
+done
+# Let "$CHARSET" reflect the current locale's charset:
+CHARSET="$(locale -- charmap)"
+if LC_ALL=C expr " $CHARSET" : ' ANSI_X3\.4\>' > /dev/null
+then
+	CHARSET=US-ASCII
+fi
diff -rauiEZbB a/util/notify.sh.in b/util/notify.sh.in
--- a/util/notify.sh.in	2017-02-18 02:03:08.000000000 +0100
+++ b/util/notify.sh.in	2017-12-23 19:42:34.733559532 +0100
@@ -1,4 +1,4 @@
-#! @SCRIPT_SH@
+#! /bin/bash
 #    $Id: notify.sh.in 984 2010-02-12 04:45:15Z faxguy $
 #
 # ============================================
@@ -46,6 +46,11 @@
 # The notify shell now behaves in a manner like faxrcvd.  
 # It is now written in shell with a little embedded awk as needed.
 
+
+#set -x
+#exec > /tmp/hylafax-notify.$$ 2>&1
+
+
 . bin/common-functions
 
 #
@@ -53,7 +58,8 @@
 #
 # Return mail to the submitter of a job when notification is needed.
 #
-if [ $# != 3 ] && [ $# != 4 ]; then
+if [ $# != 3 ] && [ $# != 4 ]
+then
     echo "Usage: $0 qfile why jobtime [nextTry]"
     hfExit 1
 fi
@@ -67,14 +73,20 @@
 {
     MAILSUBJECT="$1"
     MAILTO="$2"
-
-   (echo "MIME-Version: 1.0"
+	(
+		echo "MIME-Version: 1.0"
     echo "Content-Type: Multipart/Mixed; Boundary=\"$MIMEBOUNDARY\""
     echo "Content-Transfer-Encoding: 7bit"
     echo "To: $MAILTO"
     echo "From: $FROMADDR"
-    printf "Subject: "
-    ( echo "$MAILSUBJECT" ) | LANG=C $AWK -f bin/rfc2047-encode.awk -v charset="$CHARSET"; echo
+		(
+			header_field='Subject:' &&
+			printf '%s' "$header_field" &&
+			columns_used="${#header_field}" &&
+			rfc2047-encode "$columns_used" "$CHARSET" \
+				"$MAILSUBJECT" columns_used
+		)
+		echo
     echo ""
     echo "This is a multi-part message in MIME format."
     echo ""
@@ -84,12 +96,14 @@
     echo "Content-Transfer-Encoding: quoted-printable"
     echo ""
     (
-    if [ -z "$THISJOBTYPE" ]; then
+			if [ -z "$THISJOBTYPE" ]
+			then
 	printf "$jobtag $DICTTO $number"
     else
 	eval printf \"$DICTYOURJOBTO\"
     fi
-    if [ "$WHY" = "done" ]; then
+			if [ "$WHY" = "done" ]
+			then
 	echo "$DICTCOMPLETEDSUCCESSFULLY"
 	echo ""
     else
@@ -126,11 +140,14 @@
 		echo "$DICTNOFORMATTER2";;
 	    poll_*)
 		printf "$DICTPOLLINGFAILED"
-		if [ "$WHY" = "poll_rejected" ] ; then
+						if [ "$WHY" = "poll_rejected" ]
+						then
 		    echo "$DICTREMOTEREJECTED"
-		elif [ "$WHY" = "poll_no_document" ] ; then
+						elif [ "$WHY" = "poll_no_document" ]
+						then
 		    echo "$DICTNODOCTOPOLL"
-		elif [ "$WHY" = "poll_failed" ] ; then
+						elif [ "$WHY" = "poll_failed" ]
+						then
 		    echo "$DICTUNSPECIFIEDPROBLEM"
 		fi;;
 	    *)
@@ -151,17 +168,23 @@
     echo "$DICTDESTINATION| $number" | printFormatted $ITEMSIZE
     echo "$DICTSENDER| $sender" | printFormatted $ITEMSIZE
     echo "$DICTMAILADDR| $mailaddr" | printFormatted $ITEMSIZE
-    if [ "$jobtype" = "facsimile" ] ; then
-	if [ "$npages" -gt 0 ]; then
+			if [ "$jobtype" = "facsimile" ]
+			then
+				if [ "$npages" -gt 0 ]
+				then
 	    echo "$DICTPAGES| $npages" | printFormatted $ITEMSIZE
 	fi
-	if [ -n "$faxstatus" ] && [ -n "$dirnum" ]; then
-	    echo  "$DICTDIRNUM| $dirnum ($DICTDIRNEXTPAGE)" | printFormatted $ITEMSIZE
+				if [ -n "$faxstatus" ] && [ -n "$dirnum" ]
+				then
+					echo  "$DICTDIRNUM| $dirnum ($DICTDIRNEXTPAGE)" |
+					printFormatted $ITEMSIZE
 	fi
-	if [ -n "$csi" ]; then
+				if [ -n "$csi" ]
+				then
 	    echo "$DICTRECEIVER| $csi" | printFormatted $ITEMSIZE
 	fi
-        if [ "$RETURNTECHINFO" = "yes" ] && [ "$totdials" -gt 0 ]; then
+				if [ "$RETURNTECHINFO" = "yes" ] && [ "$totdials" -gt 0 ]
+				then
 	    case "$resolution" in
 		196) echo "$DICTQUALITY| $DICTFINE" | printFormatted $ITEMSIZE;;
 		98) echo "$DICTQUALITY| $DICTNORMAL" | printFormatted $ITEMSIZE;;
@@ -171,40 +194,54 @@
             echo "$DICTPAGELENGTH| $pagelength (mm)" | printFormatted $ITEMSIZE
             echo "$DICTSIGNALRATE| $signalrate" | printFormatted $ITEMSIZE
             echo "$DICTDATAFORMAT| $dataformat" | printFormatted $ITEMSIZE
-	    if [ -n "$equipment" ]; then
+					if [ -n "$equipment" ]
+					then
 		echo "$DICTREMOTEEQUIPMENT| $equipment" | printFormatted $ITEMSIZE
 	    fi
-	    if [ -n "$station" ]; then
+					if [ -n "$station" ]
+					then
 		echo "$DICTREMOTESTATION| $station" | printFormatted $ITEMSIZE
 	    fi
         fi
     fi
-    if [ "$RETURNTECHINFO" = "yes" ] ; then
-        if [ "$tottries" != "1" ] ; then 
-            echo "$DICTDIALOGS| $tottries ($DICTREMOTEEXCHANGES)" | printFormatted $ITEMSIZE
-        fi
-        if [ "$totdials" != "1" ] ; then 
-            echo "$DICTCALLS| $totdials ($DICTTOTALCALLS)" | printFormatted $ITEMSIZE
-        fi
-	if [ "$ndials" != "0" ]; then
-	    echo "$DICTDIALS| $ndials ($DICTFAILEDCALLS)" | printFormatted $ITEMSIZE
+			if [ "$RETURNTECHINFO" = "yes" ]
+			then
+				if [ "$tottries" != "1" ]
+				then
+					echo "$DICTDIALOGS| $tottries ($DICTREMOTEEXCHANGES)" |
+					printFormatted $ITEMSIZE
+				fi
+				if [ "$totdials" != "1" ]
+				then
+					echo "$DICTCALLS| $totdials ($DICTTOTALCALLS)" |
+					printFormatted $ITEMSIZE
+				fi
+				if [ "$ndials" != "0" ]
+				then
+					echo "$DICTDIALS| $ndials ($DICTFAILEDCALLS)" |
+					printFormatted $ITEMSIZE
 	fi
 	echo "$DICTMODEM| $modemused" | printFormatted $ITEMSIZE
-	if [ -n "$faxstatus" ]; then
+				if [ -n "$faxstatus" ]
+				then
 	    echo "$DICTSTATUS| $FAXSTATUSMSG" | printFormatted $ITEMSIZE
 	fi
         echo "$DICTSUBMITTEDFROM| $client" | printFormatted $ITEMSIZE
         echo "$DICTJOBID| $jobid" | printFormatted $ITEMSIZE
         echo "$DICTGROUPID| $groupid" | printFormatted $ITEMSIZE
-	if [ -n "$commid" ]; then
+				if [ -n "$commid" ]
+				then
             echo "$DICTCOMMID| c$commid" | printFormatted $ITEMSIZE
 	fi
-	if [ -n "$JTIME" ]; then
+				if [ -n "$JTIME" ]
+				then
 	    printf "\n$DICTPROCESSINGTIME %s.\n" "$JTIME"
 	fi
     fi
-    if [ "$jobtype" = "facsimile" ]; then
-	if [ $nfiles -gt 0 ] && [ "$RETURNTECHINFO" = "yes" ] ; then
+			if [ "$jobtype" = "facsimile" ]
+			then
+				if [ $nfiles -gt 0 ] && [ "$RETURNTECHINFO" = "yes" ]
+				then
 	    echo ""
 	    echo "    ---- $DICTDOCSSUBMITTED ----"
 	    echo ""
@@ -214,10 +251,12 @@
             eval echo "$DICTDOCSTEXT4"
             echo ""
             printf "%-20s %8s %s\n" "$DICTFILENAME" "$DICTSIZE" "$DICTTYPE"
-            for i in `local_seq 1 $nfiles`; do
+					for i in `local_seq 1 $nfiles`
+					do
                 name="files_$i"
                 eval filename=`echo "$"$name`
-                if [ -f $filename ] ; then
+						if [ -f $filename ]
+						then
                         set - `wc -c "$filename"`
                     FILESIZE=$1
                     type="filetype_$i"
@@ -227,8 +266,10 @@
                     # and because HylaFAX has historically handled PDF named as
                     # "postscript" we have to double-check the PostScript filetype.
                     #
-                    if [ "$filetype" = "PostScript" ]; then
-                        if [ "`fileType $filename`" != "PostScript" ]; then
+							if [ "$filetype" = "PostScript" ]
+							then
+								if [ "`fileType $filename`" != "PostScript" ]
+								then
                             filetype=PDF
                         fi
                     fi
@@ -236,26 +277,31 @@
                 fi
             done
         fi
-    elif [ "$jobtype" = "pager" ] && [ "$WHY" != "done" ]; then
-        if [ $npins -ne 0 ] ; then
+			elif [ "$jobtype" = "pager" ] && [ "$WHY" != "done" ]
+			then
+				if [ $npins -ne 0 ]
+				then
 	    echo ""
 	    echo "    ---- $DICTUNSENTPAGES ----"
 	    echo ""
-            for i in `local_seq 1 $npins`; do
+					for i in `local_seq 1 $npins`
+					do
                 name="files_$i"
                 eval pin=`echo "$"$name`
                 printf "%15s\n" "$DICTPIN" $pin
             done
         fi
-        if [ $nfiles -ne 0 ] && [ -s $files_0 ] ; then
+				if [ $nfiles -ne 0 ] && [ -s $files_0 ]
+				then
 	    echo ""
 	    echo "    ---- $DICTMESSAGETEXT ----"
 	    echo ""
             cat $files_0
         fi
     fi
-    ) | LANG=C $AWK -f bin/qp-encode.awk
-    if [ -n "$faxstatus" ] && [ "$RETURNTRANSCRIPT" = "yes" ] ; then
+		) | LC_ALL=C $AWK -f bin/qp-encode.awk
+		if [ -n "$faxstatus" ] && [ "$RETURNTRANSCRIPT" = "yes" ]
+		then
 	(
 	 # use -e in echo to interpret escape characters in faxstatus
 	 echo ""
@@ -266,9 +312,10 @@
 	 echo ""
 	 echo "    ---- $DICTLOGFOLLOWS2 ----"
 	 echo ""
-	) | LANG=C $AWK -f bin/qp-encode.awk
+			) | LC_ALL=C $AWK -f bin/qp-encode.awk
         COMFILE="log/c$commid"
-        if [ -f "$COMFILE" ] ; then
+			if [ -f "$COMFILE" ]
+			then
 	    echo ""
 	    echo "--$MIMEBOUNDARY"
 	    echo "Content-Type: text/plain; charset=US-ASCII; name=c$commid"
@@ -277,24 +324,29 @@
 	    echo "Content-Disposition: inline"
 	    echo ""
             # dump the comfile to output except for '-- data' lines
-            cat $COMFILE | $SED -e '/-- data/d' \
-		-e '/start.*timer/d' -e '/stop.*timer/d'
+				cat $COMFILE |
+				$SED -e '/-- data/d' -e '/start.*timer/d' -e '/stop.*timer/d'
         else 
 	    (
              printf "$DICTNOLOGAVAIL"
-             if [ -n "$commid" ] ; then  # non 0 len commid value
+					if [ -n "$commid" ]
+					then  # non 0 len commid value
                     printf "($DICTCOMMID c$commid)"
              fi
              echo "."
-	    ) | LANG=C $AWK -f bin/qp-encode.awk
+				) | LC_ALL=C $AWK -f bin/qp-encode.awk
         fi
     fi
-    for type in $RETURNFILETYPE; do 
-	if [ $nfiles -gt 0 ] ; then
-	    for i in `local_seq 1 $nfiles`; do 
+		for type in $RETURNFILETYPE
+		do
+			if [ $nfiles -gt 0 ]
+			then
+				for i in `local_seq 1 $nfiles`
+				do
 		name="files_$i"
 		eval filename=`echo "$"$name`
-		if [ -s $filename ] ; then # file is > 0 size
+					if [ -s $filename ]
+					then # file is > 0 size
 		    ftype="filetype_$i"
 		    eval FROMFMT=`echo "$"$ftype`
 		    #
@@ -302,13 +354,16 @@
 		    # and because HylaFAX has historically handled PDF named as
 		    # "postscript" we have to double-check the PostScript filetype.
 		    #
-		    if [ "$FROMFMT" = "PostScript" ]; then
-			if [ "`fileType $filename`" != "PostScript" ]; then
+						if [ "$FROMFMT" = "PostScript" ]
+						then
+							if [ "`fileType $filename`" != "PostScript" ]
+							then
 			    FROMFMT=PDF
 			fi
 		    fi
 		    FILEEXTEN="$type"
-		    if [ "$FILEEXTEN" = "original" ]; then
+						if [ "$FILEEXTEN" = "original" ]
+						then
 			case "$FROMFMT" in
 			    "TIFF") FILEEXTEN=tif;;
 			    "PostScript") FILEEXTEN=ps;;
@@ -343,15 +398,15 @@
     echo "--$MIMEBOUNDARY--"
    ) 2>$ERRORSTO | $SENDMAIL -f$FROMADDR -oi -t
 }
-
-test -f etc/setup.cache || {
+test -f etc/setup.cache ||
+{
     SPOOL=`pwd`
     cat<<EOF
 
 FATAL ERROR: $SPOOL/etc/setup.cache is missing!
 
 The file $SPOOL/etc/setup.cache is not present.  This
-probably means the machine has not been setup using the faxsetup(@MANNUM1_8@)
+probably means the machine has not been setup using the faxsetup(8C)
 command.  Read the documentation on setting up HylaFAX before you
 startup a server system.
 
@@ -377,8 +432,10 @@
 
 . etc/setup.cache
 
-local_seq() {
-	if [ $1 -gt $2 ]; then
+local_seq()
+{
+	if [ $1 -gt $2 ]
+	then
 		return
 	fi
 	COUNT=$1
@@ -416,7 +473,8 @@
 # dev-nulling them or allowing them to creep into
 # the mail.
 #
-if $TTYCMD >/dev/null 2>&1; then
+if $TTYCMD >/dev/null 2>&1
+then
     ERRORSTO=`$TTYCMD`
 else
     ERRORSTO=/dev/null
@@ -424,19 +482,19 @@
 
 adjustNotifyFaxMaster()
 {
-#  Determine what NOTIFY_FAXMASTER should be set to based
-#  on the current value of NOTIFY_FAXMASTER and on other
-#  attributes set about this notification.
-#  NOTIFY_FAXMASTER can be set to
-#    yes - send everything
-#    no - send nothing
-#    errors - send only failed type faxes that are not from busy, no answer or no carrier
-#    always - send everything
-#    never - send nothing
-#
-# known $WHY values we can test to set NOTIFY_FAXMASTER are
-# "done" "failed" "rejected" "blocked" "requeued" "removed" "killed" "timedout"
-# "format_failed" "no_formatter" "poll_rejected" "poll_no_document" "poll_failed"
+	#  Determine what NOTIFY_FAXMASTER should be set to based
+	#  on the current value of NOTIFY_FAXMASTER and on other
+	#  attributes set about this notification.
+	#  NOTIFY_FAXMASTER can be set to
+	#    yes - send everything
+	#    no - send nothing
+	#    errors - send only failed type faxes that are not from busy, no answer or no carrier
+	#    always - send everything
+	#    never - send nothing
+	#
+	# known $WHY values we can test to set NOTIFY_FAXMASTER are
+	# "done" "failed" "rejected" "blocked" "requeued" "removed" "killed" "timedout"
+	# "format_failed" "no_formatter" "poll_rejected" "poll_no_document" "poll_failed"
     case $NOTIFY_FAXMASTER in
         never|no) NOTIFY_FAXMASTER=no;;
         always|yes) NOTIFY_FAXMASTER=yes;;
@@ -447,7 +505,10 @@
 		"done"|blocked|removed|killed)
 		    NOTIFY_FAXMASTER=no;;
                 *)
-                    if (match "$faxstatus" "Busy signal") || (match "$faxstatus" "No answer") || (match "$faxstatus" "No carrier"); then
+					if (match "$faxstatus" "Busy signal") ||
+						(match "$faxstatus" "No answer") ||
+						(match "$faxstatus" "No carrier")
+					then
                         NOTIFY_FAXMASTER=no
                     else 
                         NOTIFY_FAXMASTER=yes
@@ -463,7 +524,8 @@
     # Apply customizations.  All customizable variables should
     # be set to their non-customized defaults prior to this.
     #
-    if [ -f etc/FaxNotify ]; then
+	if [ -f etc/FaxNotify ]
+	then
         # source notify preferences
         . etc/FaxNotify
     fi
@@ -472,16 +534,19 @@
     # Language settings...
     #
     . bin/dictionary
-    if [ -f etc/FaxDictionary ]; then
+	if [ -f etc/FaxDictionary ]
+	then
 	. etc/FaxDictionary
     fi
 
     #
     #  Customize error message.
     #
-    if [ -n "$errorcode" ]; then
+	if [ -n "$errorcode" ]
+	then
 	eval ERRMSG="$"`echo $errorcode`
-	if [ -z "$ERRMSG" ]; then
+		if [ -z "$ERRMSG" ]
+		then
 	    ERRMSG="$faxstatus"
 	fi
     else
@@ -496,13 +561,17 @@
 # with the '-i' option (mime type output)
 {
     FILENAME=$1
-    if [ -f "$FILENAME" ] ; then
+	if [ -f "$FILENAME" ]
+	then
 	FILETYPE=`file $FILENAME`
-        if (match "$FILETYPE" "postscript") ; then 
+		if (match "$FILETYPE" "postscript")
+		then
             echo "PostScript"
-        elif (match "$FILETYPE" "tiff") ; then 
+		elif (match "$FILETYPE" "tiff")
+		then
             echo "TIFF"
-        elif (match "$FILETYPE" "pdf") ; then 
+		elif (match "$FILETYPE" "pdf")
+		then
             echo "PDF"
         else
             echo "$DICTUNKNOWNDOCTYPE"
@@ -518,13 +587,16 @@
 {
     SOURCEFILE=$1
     CONVERTFROM=$2
-    OUTFILE="tmp/conv2pdf$$.out" ;
-    if [ "$CONVERTFROM" = "PDF" ] ; then
+	OUTFILE="tmp/conv2pdf$$.out"
+	if [ "$CONVERTFROM" = "PDF" ]
+	then
         encode "$SOURCEFILE"
         return # all done here
-    elif [ "$CONVERTFROM" = "TIFF" ] ; then
+	elif [ "$CONVERTFROM" = "TIFF" ]
+	then
         CONVERTCMD="$TIFF2PDF -o $OUTFILE $SOURCEFILE" 
-    elif [ "$CONVERTFROM" = "PostScript" ] ; then
+	elif [ "$CONVERTFROM" = "PostScript" ]
+	then
         CONVERTCMD="$PS2PDF $SOURCEFILE $OUTFILE" 
     else
         return # unknow convert from format
@@ -540,14 +612,17 @@
 {
     SOURCEFILE=$1
     CONVERTFROM=$2
-    OUTFILE="tmp/conv2ps$$.out" ;
-    if [ "$CONVERTFROM" = "PostScript" ] ; then
+	OUTFILE="tmp/conv2ps$$.out"
+	if [ "$CONVERTFROM" = "PostScript" ]
+	then
         encode "$SOURCEFILE"
         return # all done here
-    elif [ "$CONVERTFROM" = "TIFF" ] ; then
+	elif [ "$CONVERTFROM" = "TIFF" ]
+	then
         #  tiff2ps -a for all pages, 
         CONVERTCMD="$TIFF2PS -a  $SOURCEFILE > $OUTFILE" 
-    elif [ "$CONVERTFROM" = "PDF" ] ; then
+	elif [ "$CONVERTFROM" = "PDF" ]
+	then
         CONVERTCMD="$PDF2PS $SOURCEFILE $OUTFILE" 
     else
         return # unknow convert from format
@@ -563,13 +638,16 @@
 {
     SOURCEFILE=$1
     CONVERTFROM=$2
-    OUTFILE="tmp/conv2tif$$.out" ;
-    if [ $CONVERTFROM = "TIFF" ] ; then 
+	OUTFILE="tmp/conv2tif$$.out"
+	if [ $CONVERTFROM = "TIFF" ]
+	then
         encode "$SOURCEFILE"
         return # all done here
-    elif [ $CONVERTFROM = "PDF" ] ; then 
+	elif [ $CONVERTFROM = "PDF" ]
+	then
         CONVERTCMD="$PDF2FAX -r $resolution -o $OUTFILE $SOURCEFILE" 
-    elif [ $CONVERTFROM = "PostScript" ] ; then 
+	elif [ $CONVERTFROM = "PostScript" ]
+	then
         CONVERTCMD="$PS2FAX -r $resolution -o $OUTFILE $SOURCEFILE" 
     else
         return # unknow convert from format
@@ -580,13 +658,15 @@
 }
 
 match()
-#  look for substring in fullsting.  substring can be a regular expression or plain string
-#  if the substring is found anywhere in the full string, true(0) is returned.
+#  Look for substring in fullsting.  substring can be a regular expression
+#  or plain string.  If the substring is found anywhere in the full string,
+#  true(0) is returned.
 {
     FULLSTR="$1"
     SUBSTR="$2"
     echo "$FULLSTR" | $GREP -i "$SUBSTR" > /dev/null 2>&1
-    if [ $? -eq 0 ] ; then
+	if [ $? -eq 0 ]
+	then
         return 0
     else
         return 1
@@ -619,27 +699,33 @@
 adjustNotifyFaxMaster 
 
 THISJOBTYPE=""
-if [ -z "$jobtag" ] ; then
+if [ -z "$jobtag" ]
+then
     THISJOBTYPE=`eval echo "$"DICT$jobtype`
     jobtag="`eval echo $DICTJOB`"
 fi
-if [ "$doneop" = "default" ] ; then
+if [ "$doneop" = "default" ]
+then
     doneop="remove"
 fi
-if [ "$jobtype" = "pager" ] ; then
+if [ "$jobtype" = "pager" ]
+then
     number=$pagernum
 fi
 DESTINATION="$receiver"
-if [ -n "$receiver" ] && [ -n "$company" ]; then
+if [ -n "$receiver" ] && [ -n "$company" ]
+then
     DESTINATION="$receiver $DICTAT "
 fi
 DESTINATION="$DESTINATION$company"
-if [ -n "$DESTINATION" ]; then
+if [ -n "$DESTINATION" ]
+then
     DESTINATION="$DESTINATION ($number)"
 else
     DESTINATION="$number"
 fi
-if [ -z "$faxstatus" ] ; then # 0 string len
+if [ -z "$faxstatus" ]
+then # 0 string len
     FAXSTATUSMSG="<$DICTNOREASON>"
 else
     # we need to change the '\n' in the strings to real newlines
@@ -657,7 +743,8 @@
     requeued)
 	notify_mail "$jobtag $DICTTO $DESTINATION $DICTREQUEUED" "$mailaddr";;
     removed|killed)
-	notify_mail "$jobtag $DICTTO $DESTINATION $DICTREMOVEDFROMQUEUE" "$mailaddr";;
+		notify_mail "$jobtag $DICTTO $DESTINATION $DICTREMOVEDFROMQUEUE" \
+			"$mailaddr";;
     timedout)
 	notify_mail "$jobtag $DICTTO $DESTINATION $DICTFAILED" "$mailaddr";;
     format_failed)
@@ -669,16 +756,18 @@
     *)
 	notify_mail "$DICTNOTICEABOUT $jobtag" "$mailaddr";;
 esac
-if [ "$NOTIFY_FAXMASTER" = "yes" ]; then
-    # make sure that FAXMASTER gets all information in email by forcing some RETURN values
-    # and then reset them later
+if [ "$NOTIFY_FAXMASTER" = "yes" ]
+then
+	# make sure that FAXMASTER gets all information in email by forcing some
+	# RETURN values and then reset them later
     origRETURNTRANSCRIPT=$RETURNTRANSCRIPT
     origRETURNTECHINFO=$RETURNTECHINFO
     origRETURNFILETYPE=$RETURNFILETYPE
     RETURNTRANSCRIPT="yes"
     RETURNTECHINFO="yes"
     RETURNFILETYPE=""
-    if [ -z "$jobtag" ] ; then
+	if [ -z "$jobtag" ]
+	then
 	jobtag="$jobtype job $jobid"
     fi
     notify_mail "$jobtag to $number $WHY" "$TOADDR"
Nur in a/util: rfc2047-encode.awk.in.
openSUSE Build Service is sponsored by