Changelog for HylaFAX 4.2.1
+* cause faxsetup to double-check and fix attachment encoding
+ setup (27 Dec 2004)
+* add uuencode support in pollrcvd (27 Dec 2004)
+* add support for base64-encode (27 Dec 2004)
* check strftime with arguments, gcc-3.3 fix (23 Dec 2004)
* initialize some variables in some scripts that may not
- be initialzed in setup.cache (23 Dec 2004)
+ be initialzed in setup.cache (23, 27 Dec 2004)
* remove need to have separate "fax" user (22 Dec 2004)
* fix parsing of AT+FCLASS=? response within faxaddmodem
and probemodem (21 Dec 2004)
test "$LN" || LN=`findAppDef ln $PATH ln`
test "$MAN" || MAN=`findAppDef man $PATH man`
test "$MIMENCODE" || MIMENCODE=`findAppDef mimencode $PATH mimencode`
+test "$MIMENCODE" || MIMENCODE=`findAppDef base64-encode $PATH base64-encode`
test "$MKDIR" || MKDIR=`findAppDef mkdir $PATH mkdir`
test "$MV" || MV=`findAppDef mv $PATH mv`
test "$PWDCMD" || PWDCMD=`findAppDef pwd $PATH pwd`
while read a b; do eval c=\$${b:-$a}; echo "$a='$c'"; done
}
+#
+# Find the full pathname of an executable;
+# supply a default if nothing is found.
+#
+findAppDef()
+{
+ app=$1; path=$2; def=$3
+ case $app in
+ /*) test -x $app && { echo $app; return; };;
+ esac
+ IFS=:
+ for i in $path; do
+ test -x $i/$app && { echo $i/$app; return; }
+ done
+ echo $def
+}
+
+
#
# Error diagnostics that should go to the terminal are
# done with this interface or cat.
fi
fi
+#
+# Double-check these settings...
+#
+test -x "$MIMENCODE" || {
+ MIMENCODE=`findAppDef mimencode $PATH mimencode`
+ test -x $MIMENCODE || {
+ MIMENCODE=`findAppDef base64-encode $PATH base64-encode`
+ }
+ Note "Found encoder: $MIMENCODE"
+}
+test -x "$UUENCODE" || {
+ UUENCODE=`findAppDef uuencode $PATH uuencode`
+ Note "Found encoder: $UUENCODE"
+}
+if [ -x "$MIMENCODE" ]; then
+ if [ "$ENCODING" != "base64" ]; then
+ ENCODING=base64
+ Note "Looks like $MIMENCODE supports base64 encoding."
+ fi
+elif [ -x "$UUENCODE" ]; then
+ if capture "$UUENCODE -m $PASSWD foo"; then
+ if [ "$ENCODING" != "base64" ]; then
+ ENCODING=base64
+ Note "Looks like $UUENCODE supports base64 encoding."
+ fi
+ else
+ if [ "$ENCODING" != "x-uuencode" ]; then
+ ENCODING=x-uuencode
+ Note "Looks like $UUENCODE does not support base64 encoding."
+ fi
+ fi
+fi
+
RM="$RMCMD -f" # remove file for use below
#
encode()
{
if [ -x "$MIMENCODE" ]; then
- $MIMENCODE $1 2>$ERRORSTO
+ $MIMENCODE < $1 2>$ERRORSTO
elif [ -x "$UUENCODE" ]; then
if [ "$ENCODING" = "base64" ]; then
$UUENCODE -m $1 $1 | grep -E -v "^begin|^====$" 2>$ERRORSTO
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.
- $MIMENCODE $1 2>$ERRORSTO
+ $MIMENCODE < $1 2>$ERRORSTO
fi
}
return # cannot do much more without a file
fi
if [ -x "$MIMENCODE" ]; then
- $MIMENCODE $FILENAME 2>$ERRORSTO
+ $MIMENCODE < $FILENAME 2>$ERRORSTO
elif [ -x "$UUENCODE" ]; then
if [ "$ENCODING" = "base64" ]; then
$UUENCODE -m $FILENAME $FILENAME \
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.
- $MIMENCODE $FILENAME 2>$ERRORSTO
+ $MIMENCODE < $FILENAME 2>$ERRORSTO
fi
}
INFO=$SBIN/faxinfo
FAX2PS=$TIFFBIN/fax2ps
-MIMENCODE=mimencode
-ENCODING=base64
TIFF2PS=tiff2ps
PS2PDF=ps2pdf
TOADDR=FaxMaster
FILENAME=`echo $FILE | $SED -e 's/\.tif//' -e 's/recvq\///'`
+#
+# Produce mailable encoding for binary files.
+#
+encode()
+{
+ if [ -x "$MIMENCODE" ]; then
+ $MIMENCODE < $1 2>$ERRORSTO
+ elif [ -x "$UUENCODE" ]; then
+ if [ "$ENCODING" = "base64" ]; then
+ $UUENCODE -m $1 $1 | grep -E -v "^begin|^====$" 2>$ERRORSTO
+ else
+ $UUENCODE $1 $1 | grep -E -v "^begin|^====$" 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.
+ $MIMENCODE < $1 2>$ERRORSTO
+ fi
+}
+
if [ -f $FILE ]; then
#
# Check the sender's TSI and setup to dispatch
echo "Content-Transfer-Encoding: $ENCODING"
echo "Content-Disposition: attachment; filename=\"$FILENAME.tif\""
echo ""
- $MIMENCODE $FILE 2>/dev/null
+ encode $FILE
elif [ "$FILETYPE" = "pdf" ]; then
echo "Content-Type: application/pdf; name=\"c$COMMID.pdf\""
echo "Content-Description: FAX document"
$SED 's/.*Resolution: [0-9]*, \([0-9]*\).*/\1/g' | sort -n | $SED -n '$p'`
$TIFF2PS -a -O $FILE.ps $FILE 2>/dev/null # fax2ps looks bad
$PS2PDF -g$GW\x$GL -r$RW\x$RL $FILE.ps $FILE.pdf 2>/dev/null
- $MIMENCODE $FILE.pdf 2>/dev/null
+ encode $FILE.pdf
$RM -f $FILE.ps $FILE.pdf 2>/dev/null
elif [ "$FILETYPE" = "ps" ]; then
echo "Content-Type: application/postscript; name=\"$FILENAME.ps\""