#! /bin/bash
#
# This file is considered part of the software distribution,
# and any changes made to it may get overwritten in a
# subsequent upgrade or reinstallation.  Instead of making
# changes here, directly, consider copying the entire
# default MIMEConverters directory to a custom location, i.e.
# /usr/local/sbin/faxmail.custom, set MIMEConverters in 
# hyla.conf to point there, and make changes there instead.
#

DISCARDMSG="DISCARDED application/octet-stream goes here"
FILECMD=file

. /var/spool/fax/etc/setup.cache

if [ ! -x $FILECMD ]; then
    echo "$DISCARDMSG" | $LIBEXEC/textfmt -B
    exit
fi

MIMETYPE="`$FILECMD -bi "$1"`"
case "$MIMETYPE" in
    "application/postscript") cat "$1";;
    "application/pdf")	$LIBDATA/faxmail/application/pdf "$1";;
    "image/tiff")	$LIBDATA/faxmail/image/tiff "$1";;
    "message/rfc822")	cat "$1" | $LIBEXEC/textfmt -B;;
    text/*) cat "$1" | $LIBEXEC/textfmt -B;;
    *) echo "$DISCARDMSG" | $LIBEXEC/textfmt -B;;
esac

exit
