#!/bin/bash
#
# /usr/lib/lpdfilter/filter/html2ps
#
# filter used by /usr/lib/lpdfilter/bin/if
#
# Copyright 2000 SuSE GmbH, Nuernberg Germany
#
# Author: Werner Fink <feedback@suse.de>
#

#
# Activate debugging if requested.
#
if test "$DEBUG" = "medium" -o "$DEBUG" = "high" ; then
    # bash should be verbose
    set -x
    # Redirect stderr to a file
    exec 2> $(mktemp /tmp/lpdfilter.${0##*/}-$$.XXXXXX) || exit 2
fi

#
# Get our environment
#
. /usr/lib/lpdfilter/global/signals
. /usr/lib/lpdfilter/global/functions
type -p readpc   &> /dev/null || export PATH=/usr/lib/lpdfilter/bin:${PATH}
type -p xpmtoppm &> /dev/null || export PATH=${PATH}:/usr/X11R6/bin

#
# Check for our filter program (same name as we!)
#
test -x /usr/bin/html2ps &> /dev/null || fault_filetype /usr/bin/html2ps

#
# html2ps options give as $html2ps if any
#
: ${html2ps="-e ISO-8859-1 -u -H"}

#
# Color?
#
if test "$color" = "yes" ; then
    color=""
else
    color="-g"
fi

#
# run the command on stdin
#   $encoding instead of the hardcoded ISO-8859-1 is not used
#   here because html2ps does not support other ISOs and produces
#   bad PostScript for them.
#
exec -a html2ps html2ps ${html2ps:+"$html2ps"} ${color:+"$color"}
