#!/bin/sh
#
# "$Id: pstopxl,v 1.1 2004/02/24 21:59:13 mike Exp $"
#
# CUPS PCL XL/PCL 6 filter script for Ghostscript.
#
# Copyright 2001-2003 by Easy Software Products.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#

# Installation directories...
prefix=/usr/local
exec_prefix=${prefix}
bindir=/usr/lib/cups/filter

# Set the library/font path...
GS_LIB="${CUPS_FONTPATH:=/usr/share/cups/fonts}"
export GS_LIB

# Determine the PCL XL/PCL 6 driver to use...
if test "x$PPD" != x; then
    colordevice=`grep '^*ColorDevice:' "$PPD" | awk -F: '{print $2}'`
    case "$colordevice" in
	*True* | *true*)
	    device="pxlcolor"
	    ;;
	*)
	    device="pxlmono"
	    ;;
    esac
else
    device="pxlmono"
fi

# Options we use with Ghostscript...
gsopts="-dQUIET -dDEBUG -dPARANOIDSAFER -dNOPAUSE -dBATCH"
gsopts="$gsopts -dNOMEDIAATTRS -sDEVICE=$device -sstdout=%stderr"

# See if we have a filename on the command-line...
if test -z "$6"; then
	ifile="-"
else
	ifile="$6"
fi

echo INFO: Starting ESP Ghostscript 7.07.1... 1>&2
echo DEBUG: Running $bindir/gsrip $gsopts -sOUTPUTFILE="%stdout" "$ifile" 1>&2

# Now run Ghostscript...
$bindir/gsrip $gsopts -sOUTPUTFILE="%stdout" "$ifile"

#
# End of "$Id: pstopxl,v 1.1 2004/02/24 21:59:13 mike Exp $".
#
