One of the more nifty things that the APSFILTER does is to allow you
to have a set of queues with names like:
  lp                 - normal
  lp_landscape       - landscape mode
  lp_legal           - legal paper
  lp_landscape_legal - landscape and legal

The problem here is that you need a LOT of queues OR a LOT of
aliases:


lp|lp_landscape|lp_legal|lp_landscape_legal|....
  :lp=lp@server
lp|lp_landscape|lp_legal|lp_landscape_legal|....
  :server
  :lp=realprinter@server
  :control_filter=/.../update_z

realprinter:server
  :[EMAIL PROTECTED]
  :ifhp=model=whatevermodelyouhave
  :filter=/usr/local/libexec/filters/ifhp


You use the control filter to set the various Z option values
as necessary.  Here is a typical control filter to do this:

#!/usr/bin/perl
# update_z script:
# Determine the options according to the format of the queue name
#  Inspired by the psfilter code of Andreas Klemm
#  and Thomas Bueschgens 
# First, get command line arguments
#
use Getopt::Std;
my(%args,$Q,$Zopts,@file);
getopts(
"A:B:C:D:E:F:G:H:I:J:K:L:M:N:O:P:Q:R:S:T:U:V:W:X:Y:Z:" .
"a:b:cd:e:f:g:h:i:j:k:l:m:n:o:p:q:r:s:t:u:v:w:x:y:z:",
\%args );
# read stdin
@file = <>;
$Zopts = "";
# first use command line Queue name
$Q = $args{"Q"};
if( not $Q and (($Q) = grep(/^Q/,@file)) ){
   # next use control file Queue name
        chomp $Q if $Q;
}
# now we split up the name and use as parameters for Z options
while( $Q =~ /_([^_]+)/g ){
        # you can add them or test and then add them
        if( $1 eq "landscape"
                or $1 eq "legal"
                or $1 eq "ledger" ){
                $Zopts .= ",$1"
        }
}
if( $Zopts ){
        # remove leading comma
        $Zopts = substr( $Zopts, 1 );
        #replace or prefix Z options
        if( not (grep { s/$/,$Zopts/ if /^Z/; } @file) ){
                print "Z" . $Zopts . "\n";
        }
}
print @file if( @file );
exit 0



Now, this is messy and requires you to add aliases each time.

So,  just to make life easier for this type of thing,  I have
provided two more capabilities:

 a) The queue name can be a glob pattern
    When searching for a printer, the exact printer
    name is searched for first,  then the first printer
    that matches a glob.  There is no defined order to these
    so you should have unique prefixes for your printers.

  b) incoming_control_filter=/filter
    Applied to the incoming control file

We combine these as follows:

lp|lp_*:lp=%P@server
q2|q2_*:lp=%P@server

OR even more brually:

*:lp=%P@server


lp|lp_*:server:tc=.common_multi
  :[EMAIL PROTECTED]

q2|q2_*:server:tc=.common_multi
  :[EMAIL PROTECTED]

.common_multi
  :incoming_control_filter=/.../update_z
  :ifhp=model=whatevermodelyouhave
  :filter=/usr/local/libexec/filters/ifhp
  :sd=/var/spool/lpd/%P

Note that the incoming_control_filter is applied to the incoming
job's control file,  and has all of the information about files,
etc.,  available in the DATA_FILES environment variable so it
can peek at the contents of the data files to determine what
other options it may want to add.  This is to handle the
problems with systems that put job options in the comments in
PostScript files.

Patrick Powell                 Astart Technologies,
[EMAIL PROTECTED]            9475 Chesapeake Drive, Suite D,
Network and System             San Diego, CA 92123
  Consulting                   858-874-6543 FAX 858-279-8424 
LPRng - Print Spooler (http://www.astart.com)

-----------------------------------------------------------------------------
If you need help, send email to [EMAIL PROTECTED] (or lprng-requests
or lprng-digest-requests) with the word 'help' in the body.  For the impatient,
to subscribe to a list with name LIST,  send mail to [EMAIL PROTECTED]
with:                           | example:
subscribe LIST <mailaddr>       |  subscribe lprng-digest [EMAIL PROTECTED]
unsubscribe LIST <mailaddr>     |  unsubscribe lprng [EMAIL PROTECTED]

If you have major problems,  send email to [EMAIL PROTECTED] with the word
LPRNGLIST in the SUBJECT line.
-----------------------------------------------------------------------------

Reply via email to