#!/bin/bash
#
# /usr/lib/lpdfilter/post/bin2cpva
#
# filter used by /usr/lib/lpdfilter/bin/if
#
# Copyright 2001 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
#
type -p ppmtomd &> /dev/null || fault_filetype ppmtomd

#
# Optional printer
#
model="${0#*bin2cpva}"
test -n "$model" || model='Printiva-600U'

#
# Citizen Printiva printers, reads ppm from gs
# 
exec -a ppmtomd ppmtomd -mode $model -halftone
