# Example attachment decoder script. The attachment comes from stdin, and
# the script is expected to output UTF-8 data to stdout. (If the output isn't
# UTF-8, everything except valid UTF-8 sequences are dropped from it.)
# The attachment decoding is enabled by setting:
#
# plugin {
# fts_decoder = decode2text
# }
# service decode2text {
# executable = script /usr/local/libexec/dovecot/decode2text.sh
# user = dovecot
# unix_listener decode2text {
# mode = 0666
# }
# }
libexec_dir=`dirname $0`
content_type=$1
# The second parameter is the format's filename extension, which is used when
# found from a filename of application/octet-stream. You can also add more
# extensions by giving more parameters.
formats='application/pdf pdf
application/x-pdf pdf
application/msword doc
application/ms-excel xls
application/x-msexcel xls
'
if [ "$content_type" = "" ]; then
echo "$formats"
exit 0
fi
if [ "$fmt" = "" ]; then
echo "Content-Type: $content_type not supported" >&2
exit 1
fi
# most decoders can't handle stdin directly, so write the attachment
# to a temp file
name=$1
exit 1
fi
cd $tempdir || exit 1
}
childpid=$!
wait $childpid
}
export LANG
if [ $fmt = "pdf" ]; then
elif [ $fmt = "doc" ]; then
elif [ $fmt = "ppt" ]; then
elif [ $fmt = "xls" ]; then
elif [ $fmt = "docx" ]; then
elif [ $fmt = "xlsx" ]; then
elif [ $fmt = "pptx" ]; then
xmlunzip "slide*.xml"
else
echo "Buggy decoder script: $fmt not handled" >&2
exit 1
fi
exit 0