]> git.ipfire.org Git - thirdparty/HylaFAX.git/commitdiff
Bug 574: add support for base64-encode
authorLee Howard <faxguy@howardsilvan.com>
Tue, 28 Dec 2004 04:45:03 +0000 (04:45 +0000)
committerLee Howard <faxguy@howardsilvan.com>
Tue, 28 Dec 2004 04:45:03 +0000 (04:45 +0000)
         add uuencode support in pollrcvd
         make faxsetup double-check and repair attachment encoding setup

CHANGES
configure
etc/faxsetup.sh.in
util/faxrcvd.sh.in
util/notify.sh.in
util/pollrcvd.sh.in

diff --git a/CHANGES b/CHANGES
index da32a4d82400180d251575ff5707a8f47aa618a6..498c598a721d1e6c043395c95f3e9a88bdbf614a 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -2,9 +2,13 @@
 
 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)
index b580a21ca437d0d07d9a0e7fe13084d6b324661e..acc5c2888ce3a8b425702b2632f2a6bdd709464a 100755 (executable)
--- a/configure
+++ b/configure
@@ -3482,6 +3482,7 @@ test "$GREP"      || GREP=`findAppDef grep $PATH grep`
 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`
index 177fc9315bce55cb8c4ccdab66be1c7a6dd08efb..1ec1088debd54cc88e9c6cb9b318f3dd13a62df3 100644 (file)
@@ -175,6 +175,24 @@ dumpvals()
        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.
@@ -749,6 +767,39 @@ if onServer; then
     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
 
 #
index fad1efed9401e2d08828d0300975431f1afa4845..6f43c97d04357ee3c8e827ddfc437fd0132f625b 100644 (file)
@@ -122,7 +122,7 @@ fi
 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
@@ -132,7 +132,7 @@ encode()
     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
 }
 
index 755e64ceac5db726750ab1bfcd2b94231e36728c..904c9fa0ba8a24ee6e0303852cc31a41c5509f43 100644 (file)
@@ -449,7 +449,7 @@ mimeEncode()
         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 \
@@ -462,7 +462,7 @@ mimeEncode()
     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
 }
 
index 278f12676e5d0a365ae4c7acca7a491ce243688d..c7815333c8896eb03d15ca59d22431b21504e027 100644 (file)
@@ -62,8 +62,6 @@ TTYCMD=tty
 
 INFO=$SBIN/faxinfo
 FAX2PS=$TIFFBIN/fax2ps
-MIMENCODE=mimencode
-ENCODING=base64
 TIFF2PS=tiff2ps
 PS2PDF=ps2pdf
 TOADDR=FaxMaster
@@ -94,6 +92,26 @@ MSG="$5"
 
 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
@@ -179,7 +197,7 @@ if [ -f $FILE ]; then
            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"
@@ -196,7 +214,7 @@ if [ -f $FILE ]; then
                $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\""