/usr/lib/cups/filter/gstopxl is in ghostscript-cups 9.05~dfsg-0ubuntu4.5.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | #!/bin/sh
#
# "$Id$"
#
# CUPS PCL XL/PCL 6 filter script for Ghostscript.
#
# Copyright 2001-2005 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
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
# 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
# Apply PPD settings.
ps_code=
ppd_opts=
resolution=
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|[[:space:]])Resolution=([0-9.]+(x[0-9.]+)?).*/resolution="${resolution:-\2}"/p')"
if test -e "$PPD"; then
eval "$(sed -nre 's/^\*DefaultResolution:[[:space:]]+([0-9.]+(x[0-9.]+)?).*/resolution="${resolution:-\1}"/p' "$PPD")"
fi
echo "DEBUG: Resolution: $resolution" >&2
if test -n "$resolution"; then
ppd_opts="${ppd_opts:+$ppd_opts }-r$resolution"
fi
pagesize=
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|[[:space:]])(media|PageSize)=([^[:space:]]+).*/pagesize="${pagesize:-\3}"/p')"
if test -e "$PPD"; then
eval "$(sed -nre 's/^\*DefaultPageSize:[[:space:]]+([^[:space:]]+).*/pagesize="${pagesize:-\1}"/p' "$PPD")"
fi
echo "DEBUG: Page size: $pagesize" >&2
width=
height=
if test -n "$pagesize" && test -e "$PPD"; then
eval "$(sed -nre 's|^\*PaperDimension[[:space:]]+'"$pagesize"'/[^:]+:[[:space:]]+"([^[:space:]]+)[[:space:]]+([^[:space:]]+)".*|width="\1"; height="\2"|p' "$PPD")"
fi
echo "DEBUG: Width: $width, height: $height" >&2
if test -n "$width"; then
ppd_opts="${ppd_opts:+$ppd_opts }-dDEVICEWIDTHPOINTS=$width"
fi
if test -n "$height"; then
ppd_opts="${ppd_opts:+$ppd_opts }-dDEVICEHEIGHTPOINTS=$height"
fi
bl_x=
bl_y=
tr_x=
tr_y=
if test -n "$pagesize" && test -e "$PPD"; then
eval "$(sed -nre 's|^\*ImageableArea[[:space:]]+'"$pagesize"'/[^:]+:[[:space:]]+"([^[:space:]]+)[[:space:]]+([^[:space:]]+)[[:space:]]+([^[:space:]]+)[[:space:]]+([^[:space:]]+)".*|bl_x="\1"; bl_y="\2"; tr_x="\3"; tr_y="\4"|p' "$PPD")"
fi
echo "DEBUG: Absolute margins: $bl_x, $bl_y, $tr_x, $tr_y" >&2
margin_l=
margin_b=
margin_r=
margin_t=
if test -n "$width" && test -n "$height" && \
test -n "$bl_x" && test -n "$bl_y" && \
test -n "$tr_x" && test -n "$tr_y"; then
margin_l="$bl_x"
margin_b="$bl_y"
margin_r="$(printf "scale=8; (%s)-(%s)\n" "$width" "$tr_x" | bc)"
margin_t="$(printf "scale=8; (%s)-(%s)\n" "$height" "$tr_y" | bc)"
fi
echo "DEBUG: Relative margins: $margin_l, $margin_b, $margin_r, $margin_t" >&2
if test -n "$margin_l" && test -n "$margin_b" && \
test -n "$margin_r" && test -n "$margin_t"; then
ps_code="${ps_code:+$ps_code }<</.HWMargins[$margin_l $margin_b $margin_r $margin_t] /Margins[0 0]>>setpagedevice"
fi
inputslot=
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|[[:space:]])(InputSlot)=([^[:space:]]+).*/inputslot="${inputslot:-\3}"/p')"
if test -e "$PPD"; then
eval "$(sed -nre 's/^\*DefaultInputSlot:[[:space:]]+([^[:space:]]+).*/inputslot="${inputslot:-\1}"/p' "$PPD")"
fi
echo "DEBUG: InputSlot: $inputslot" >&2
inputslot_val=
if test -n "$inputslot" && test -e "$PPD"; then
eval "$(sed -nre 's|^\*InputSlot[[:space:]]+'"$inputslot"'/[^:]+:[[:space:]]+"[[:space:]]*<[[:space:]]*<[[:space:]]*/MediaPosition[[:space:]]*([0-9]+)[[:space:]]*>[[:space:]]*>[[:space:]]*setpagedevice[[:space:]]*".*|inputslot_val="\1"|p' "$PPD")"
fi
echo "DEBUG: Value for MediaPosition: $inputslot_val" >&2
if test -n "$inputslot_val"; then
ppd_opts="${ppd_opts:+$ppd_opts }-dMediaPosition=$inputslot_val"
fi
colormodel=
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|[[:space:]])(ColorModel)=([^[:space:]]+).*/colormodel="${colormodel:-\3}"/p')"
if test -e "$PPD"; then
eval "$(sed -nre 's/^\*DefaultColorModel:[[:space:]]+([^[:space:]]+).*/colormodel="${colormodel:-\1}"/p' "$PPD")"
fi
echo "DEBUG: ColorModel: $colormodel" >&2
if test "$colormodel" = "Gray"; then
device=pxlmono
fi
colormodel_val=
if test -n "$colormodel" && test -e "$PPD"; then
eval "$(sed -nre 's|^\*ColorModel[[:space:]]+'"$colormodel"'/[^:]+:[[:space:]]+"[[:space:]]*<[[:space:]]*<[[:space:]]*/BitsPerPixel[[:space:]]*([0-9]*)[[:space:]]*>[[:space:]]*>[[:space:]]*setpagedevice[[:space:]]*".*|colormodel_val="\1"|p' "$PPD")"
fi
echo "DEBUG: Value for BitsPerPixel: $colormodel_val" >&2
if test -n "$colormodel_val"; then
ppd_opts="${ppd_opts:+$ppd_opts }-dBitsPerPixel=$colormodel_val"
fi
duplex=
eval "$(printf "%s" "$5" | sed -nre 's/.*(^|[[:space:]])(Duplex)=([^[:space:]]+).*/duplex="${duplex:-\3}"/p')"
if test -e "$PPD"; then
eval "$(sed -nre 's/^\*DefaultDuplex:[[:space:]]+([^[:space:]]+).*/duplex="${duplex:-\1}"/p' "$PPD")"
fi
echo "DEBUG: Duplex: $duplex" >&2
duplex_val=
tumble_val=
if test -n "$duplex" && test -e "$PPD"; then
eval "$(sed -nre 's|^\*Duplex[[:space:]]+'"$duplex"'/[^:]+:[[:space:]]+"[[:space:]]*<[[:space:]]*<[[:space:]]*/Duplex[[:space:]]*([^[:space:]]*)[[:space:]]*(/Tumble[[:space:]]*([^[:space:]]*)[[:space:]]*)?>[[:space:]]*>[[:space:]]*setpagedevice[[:space:]]*".*|duplex_val="\1"; tumble_val="\3"|p' "$PPD")"
fi
echo "DEBUG: Value for Duplex: $duplex_val; Value for Tumble: $tumble_val" >&2
if test -n "$duplex_val"; then
ppd_opts="${ppd_opts:+$ppd_opts }-dDuplex=$duplex_val"
fi
if test -n "$tumble_val"; then
ppd_opts="${ppd_opts:+$ppd_opts }-dTumble=$tumble_val"
fi
echo "DEBUG: PPD options: $ppd_opts" >&2
echo "DEBUG: PostScript code from options: $ps_code" >&2
# Options we use with Ghostscript...
gsopts="-dQUIET -dPARANOIDSAFER -dNOPAUSE -dBATCH -dNOINTERPOLATE"
gsopts="$gsopts -sDEVICE=$device -sstdout=%stderr"
# See if we have a filename on the command-line...
if [ -n "$6" ]; then
exec <"$6"
fi
# We read the data into a temporary file as Ghostscript needs this to be
# able to also work with PDF input
tempfiles=
trap 'rm -f $tempfiles' 0 1 2 13 15
ifile=$(mktemp -t gstopxl.XXXXXX)
tempfiles="$tempfiles $ifile"
cat >"$ifile"
echo INFO: Starting GPL Ghostscript `$bindir/gs --version`... 1>&2
echo DEBUG: Running $bindir/gs $gsopts $ppd_opts -sOUTPUTFILE="%stdout" -c "$ps_code" -f "$ifile" 1>&2
# Now run Ghostscript...
$bindir/gs $gsopts $ppd_opts -sOUTPUTFILE="%stdout" -c "$ps_code" -f "$ifile"
#
# End of "$Id$".
#
|