In the previous sections we discussed how a print filter was executed and how it could be used. Now we will look at how the lpd spooler chooses a print filter program. Let us re-examine our example print job control file:
Hh4.private Ppapowell J/tmp/hi CA Lpapowell Apapowell@h4+105 D2000-04-12-15:27:26.662 Qlp N/tmp/hi fdfA105h4.private UdfA105h4.private
Each data file for a print job has a name with the format dfXnnnh4.private. The df is used to indicate that the file is a data file, and the remainder is a unique name for the file in the job. The X part of the name must be an upper or lower case letter, setting a limit of 52 different files in a single print job.
The fdfA105h4.private line in the control file specifies that we are to print the job using the filter for the f format; the file printing information consists of the format assigned to the file and the name of the file. In the legacy BSD print spoolers, this format was used to select the print filter to be used. LPRng has expanded this by providing a default filter specification.
Table 4-2. Job Formats and Filter Selection
lpr command line option | Control File Line | Printcap Option For Filter | Filter Command Line |
---|---|---|---|
(default) | fdfAnnn | :if=/path | /path -Ff ... |
-b or -l | ldfAnnn | :if=/path | /path ... -Ff -c |
-p | pdfAnnn | :if=/path | pr | format f filter |
-c, -d, -n, -r, -t, -v, -FX | XdfAnnn | :Xf=/path ... | /path -FX |
any format | XdfAnnn | :filter=/path ... | /path -FX |
Table 4-2 shows the rather baroque relationship between the format options specified by the lpr command and the way that lpd uses them. The reason for this complexity lies in the various implementations and variations that occurred during the development and deployment of the original BSD print spooling software.
Here is the complete, arcane, and baroque set of rules that are used to select and print filters. The default format used by lpr is f; unless some other format is specified this is used. The lpr -b and lpr -l (binary and literal literals) are a request to lpd to do as little processing as possible of this file before printing it. Lpd use the :if filter for formats f and l; the l literal causes the the -c filter command line flag to be used as well. The lpr -c, -d, -n, -r, -t, and -v options cause the corresponding format to be used, and for lpd to use the filter specified by the printcap option :Xf, where X is the specified format.
The lpr -p (pretty-print literal) selects p format, and lpd is supposed to use the program specified by the :pr printcap option to format the file and then process the output of this program according to format f. Unpredictable results may occur using this facility.
the lpr -FX allows you to explicitly specify format X where X is a lower case letter, and lpd will use the filter specified by printcap option :Xf, where X is the specified format. If there is no :Xf printcap literal value then the printcap :filter literal value will be used as the filter, and if this is undefined then the file will be passed without processing through to the printing device.
If a filter is not specified for the format then the default filter specified by :filter=/path filter is used, and if there is no default, then the output is sent directly to the output device.
If the :fx=formats is present in a printcap entry, it specifies the formats that are allowed. For example, :fx=lfv would allow only formats l, f, and v to be used on a particular spool queue.
Some Xf options have pre-assigned meanings and cannot be used for filter selection.
Printcap Option | Purpose |
---|---|
Printcap Option | Purpose |
:af=/path | Accounting File |
:ff=formfeed | Form Feed String |
:if=/path | filter (l,b,p,f formats) |
:filter=/path | Default filter |
:lf=/path | Log file |
:of=/path | OF filter |
:sf | suppress form feed between job files |
The :of filter is a special case and is used for banner printing and accounting purposes. See OF Filter for details.