uri revision 7c478bd95313f5f23a4c958a745db2134aa03244
935N/A# The contents of this file are subject to the terms of the 577N/A# Common Development and Distribution License, Version 1.0 only 577N/A# (the "License"). You may not use this file except in compliance 919N/A# See the License for the specific language governing permissions 919N/A# and limitations under the License. 919N/A# When distributing Covered Code, include this CDDL HEADER in each 919N/A# If applicable, add the following below this CDDL HEADER, with the 919N/A# fields enclosed by brackets "[]" replaced with your own identifying 919N/A# information: Portions Copyright [yyyy] [name of copyright owner] 919N/A# Copyright 2005 Sun Microsystems, Inc. All rights reserved. 577N/A# Use is subject to license terms. 577N/A# ident "%Z%%M% %I% %E% SMI" 577N/A# printer interface script for printers with a URI instead of 577N/A# The existence of a "PPD" environment variable in the calling environment 911N/A# indicates that Foomatic is to be used for filtering all job data as it is 911N/A# streamed to the output device (printer). 911N/A# The contents of a "DEVICE_URI" environment variable in the calling 577N/A# environment indicates the method and endpoint used in communicating with 606N/A# the output device (printer). If no DEVICE_URI is present or the value 829N/A# contains a missing or unknown scheme, the URI scheme is assumed to be 829N/A# "file" and output streaming will be handled accordingly. 577N/A# Re-arrange fds for later use 935N/A# HUP 1 - the output stream disconnected 810N/A# INT 2 - the output stream interupted us 577N/A# QUIT 3 - the output stream interupted us 577N/A# TERM 15 - we have been cancelled or shutdown echo "$(expr \"$1\" : \"^[^=]*=\(.*\)\")" # Generate an ASCII burst page and pass it to the printer # This may be much faster than the PostScript(TM) burst page # Generate a PostScript(TM) burst page (this assumes an 8.5x11 page size) /PrintLine { exch findfont exch scalefont setfont moveto show } def newpath 4 setlinewidth 1 setlinejoin 15 760 moveto 595 760 lineto 595 585 lineto 15 585 lineto closepath gsave .75 setgray fill grestore (${user}) 30 730 /Times-Bold 24 PrintLine (${request_id}) 415 730 /Times-Bold 24 PrintLine (${printer}) 30 600 /Times-Bold 16 PrintLine ($(date)) 350 600 /Times-Roman 16 PrintLine (${title}) 100 660 /Times-Bold 36 PrintLine (Copies: ${copies}) 30 25 /Times-Roman 16 PrintLine logger -p lpr.debug -t ${TAG} "$0 $*" # Detemine if we were called correctly fail ${EXIT_FATAL} "wrong number of arguments to interface script" burst_page="postscript_burst_page" burst_page="$(parse ${i})_burst_page" logger -p lpr.error -t ${TAG} \ "unrecognized \"-o ${i}\" option, ignored" 1>&2 # Procss the DEVICE_URI if we have one if [[ -n "${DEVICE_URI}" ]] ; then parse_uri ${DEVICE_URI} # split up the URI URI_SCHEME=${URI_SCHEME:-file} # if there is no scheme, assume "file" file|usb|ecpp|serial|parallel) IO_HANDLER_ARGS="${request_id} ${user} \"${title}\" 1 IO_HANDLER=${IO_HANDLER:-"lp.cat"} # if IO_HANDLER is still unset, use lp.cat # determine if the IO handler is available for us to use when communicating with # the output device (printer.) whence ${IO_HANDLER} >/dev/null "Interface script unable to locate IO handler: ${IO_HANDLER}" # There is a PPD file specified, so use foomatic if [[ -n "${PPD}" ]] ; then FILTER_CHAIN="| foomatic-rip" # Start processing the job here set | logger -p lpr.debug -t "${TAG}" if [[ -n "${burst_page}" ]] ; then eval "${burst_page} ${FILTER_CHAIN}" while [[ $copies -gt 0 ]] ; do for file in ${files} ; do if [[ -r "${file}" ]] ; then eval "cat ${file} ${FILTER_CHAIN}" ) | ${IO_HANDLER} ${IO_HANDLER_ARGS}