/usr/lib/printfilters/ps-to-printer.fpi is in printfilters-ppd 2.13-11.1.
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 192 193 194 195 196 197 198 199 200 201 | #!/bin/sh
#
# convert ps to the format required by the printer on this queue
#
# if the printer is a PostScript printer, just cat it through
# if the printer uses ghostscript, we'll run it now
# if the printer is neither, we die (with good message to someone)
#
#A. Mennucc: if gs is used to print PDF, it needs a file
INPUTFILE='-'
if [ "$1" = '--inputfile ' ] ; then
shift
INPUTFILE="$1"
shift
fi
if [ -f "${SPOOLDIR}/.debug" ];then
set -x
exec 2>${SPOOLDIR}/log.ps-to-printer.fpi
fi
# location of the ppaprint script
prefix=/usr
exec_prefix=${prefix}
libexecdir=${prefix}/lib/printfilters
bindir=${exec_prefix}/bin
FPIDIR=$libexecdir
# find the name of the queue from the spool dir
eval `pcap -S $SPOOLDIR`
# look up the printcap entry with sd=$SPOOLDIR and grab its ppdfile
# A. Mennucc: we may ditch this and use pcap
#PPDFILE=`$FPIDIR/grab-ppd.awk -v spool=${SPOOLDIR} /etc/printcap`
eval `pcap -P$queue:ppdfile` >> /dev/null
PPDFILE="$ppdfile"
# absolute path? if not, prepend $SPOOLDIR
echo $PPDFILE | grep '^/' > /dev/null 2>&1
if test $? -ne 0; then
PPDFILE=${SPOOLDIR}/${PPDFILE}
fi
#
# Load postscript configuration options
#
if [ -f "${SPOOLDIR}/postscript.cfg" ]; then
. ${SPOOLDIR}/postscript.cfg
else
eval `pcap -P$queue:GSDEVICE` >> /dev/null
eval `pcap -P$queue:RESOLUTION` >> /dev/null
eval `pcap -P$queue:COLOR` >> /dev/null
eval `pcap -P$queue:PAPERSIZE` >> /dev/null
eval `pcap -P$queue:EXTRA_GS_OPTIONS` >> /dev/null
eval `pcap -P$queue:PS_SEND_EOF` >> /dev/null
eval `pcap -P$queue:NUP` >> /dev/null
eval `pcap -P$queue:RTLFTMAR` >> /dev/null
eval `pcap -P$queue:TOPBOTMAR` >> /dev/null
fi
#
# see if we should reverse order
#
# support will be added for this in the future
# psorder needed and is part of netatalk, which we dont currently ship
#
if [ "$PAPERSIZE" = "letter" ]; then
mpage_paper="Letter"
elif [ "$PAPERSIZE" = "a4" ]; then
mpage_paper="A4"
elif [ "$PAPERSIZE" = "legal" ]; then
mpage_paper="Legal"
else
mpage_paper="Letter"
fi
#
# weird case - some PS doesnt get handled by mpage well
# so we allow nup=1 to just cat PS to printer w/o mpage interferring
#
# A.Mennucc: reason is:
# mpage fails if there is an eps in a ps, unless you add -k
if [ "$NUP" = "1" ]; then
border="-o"
mpage_cmd="cat $INPUTFILE"
else
border=""
mpage_cmd="mpage -k -b$mpage_paper $border -$NUP -m${RTLFTMAR}lr -m${TOPBOTMAR}tb $INPUTFILE"
fi
# processing based upon ppd using LPRng
if [ -n "$CONTROL" -a -f "$PPDFILE" ]; then
LPOPTS=`sed -n -e 's/^Z/ /' -e 's/,/ /' -e '/^ /p' -e 's/^ //' <<EOF
$CONTROL
EOF`
fi
# processing based upon ppd using modified lpr
if [ -n "$LPOPTS" -a -f "$PPDFILE" ]; then
# try to catch nasties
LPOPTS=`echo "$LPOPTS" | sed -e 's/.*[^-a-zA-Z_0-9,: ].*/__BAD__/' -e 's/,/ /g'`
#A. Mennucc: it is LPOPTS not LPOTPS
if [ "$LPOPTS" != "__BAD__" ]; then
#no shortcut ... 'ppdfilt -p ppd -' does not read from stdin
mpage_cmd="$mpage_cmd | ppdfilt -p $PPDFILE"
for i in $LPOPTS; do
mpage_cmd="$mpage_cmd -o '$i'"
done
fi
fi
# if the driver is
# "POSTSCRIPT" it means the printer handles Postscript natively,
# no need to run gs.
# "TEXT" it means the printer cannot handle PS input
# "uniprint" use the driver set by COLOR in postscript.cfg
# "ppa" use the driver and postprocessor returned by ppaprint
if [ "$GSDEVICE" = "POSTSCRIPT" ]; then
eval $mpage_cmd
elif [ "$GSDEVICE" = "TEXT" ]; then
echo "Error - ps-to-printer.fpi - this printer cannot print postscript" 1>&2
echo " and ghostscript does not have support" 1>&2
exit 1
#
# We're using ghostscript with "uniprint" command line style,
# $COLOR holds filename of driver parameters (filename.upp)
# Since real driver name is stored in *.upp files, this style can
# activate traditional drivers provided you create corresponding
# *.upp files, entry to printdb, and compile ghostscript with uniprint.
# ( Without compiling uniprint in ghostscript, this script will filter
# out all uniprint entries in printdb including fake ones for
# traditional drivers )
#
elif [ "$GSDEVICE" = "uniprint" ]; then
# Set default *.upp driver (your default printer upp driver here)
if [ "$COLOR" = "" ]; then
COLOR="stcany"
#A.Mennucc: this is annoying!
#echo "No filename for parameters given. Assume $COLOR." 1>&2
fi
#
# A.Mennucc: protect filename in gs with -f in case someone uses -c
# in GS_EXTRA_OPTIONS
eval "$mpage_cmd " | gs -q @$COLOR.upp \
-sPAPERSIZE=$PAPERSIZE \
-sOutputFile=- \
$EXTRA_GS_OPTIONS \
-f $INPUTFILE
# support for HP DeskJet PPA printers (710, 720, 820, 1000 series).
# assemble the PPA postprocessor command line using the ppaprint script.
# GSDEVICE is selected from among the pnm devices.
# $EXTRA_GS_OPTIONS is processed to remove PPA options.
# PPA configuration is encoded in $COLOR
elif [ "$GSDEVICE" = "ppa" ]; then
PPA=$FPIDIR/ppaprint
PPA_CMD=$(eval "$PPA $COLOR $PAPERSIZE $RESOLUTION $EXTRA_GS_OPTIONS ")
if ! echo $PPA_CMD | grep -e "Error" > /dev/null 2>&1 ; then
eval "$mpage_cmd " |\
sed "s/[(]%%.*%%[)].*flush//g" |\
gs -q \
-r$RESOLUTION \
-sPAPERSIZE=$PAPERSIZE \
-dNOPAUSE \
-dSAFER \
-sOutputFile=- \
$PPA_CMD -f $INPUTFILE
else
echo "Error - ps-to-printer.fpi - PPA postprocessor error:" 1>&2
echo $PPA_CMD 1>&2
exit 1
fi
else
# We're using ghostscript in traditional manner
eval "$mpage_cmd " | sed "s/[(]%%.*%%[)].*flush//g" | \
gs -q -sDEVICE=$GSDEVICE \
-r$RESOLUTION \
-sPAPERSIZE=$PAPERSIZE \
-dNOPAUSE \
-dSAFER \
-sOutputFile=- \
$COLOR \
$EXTRA_GS_OPTIONS \
-f $INPUTFILE
fi
#
#
# see if we need to send a form feed to eject the page from printer
#
if [ "$PS_SEND_EOF" = "YES" ]; then
printf "\004"
fi
exit 0
|