Keyword definitions and examples

You can use keywords to define options in a filter definition.

The following keywords are available for defining options in a filter definition:

Characteristic keyword Possible patterns Example
Content type (input) INPUT content-type troff
Content type (output) OUTPUT content-type postscript
Printer type TERM printer-type att495
Printer name PRINTER printer-name lp1
Character pitch CPI scaled-decimal 10
Line pitch LPI scaled-decimal 6
Page length LENGTH scaled-decimal 66
Page width WIDTH scaled-decimal 80
Pages to print PAGES page-list 1-5,13-20
Character set CHARSET character-set finnish
Form name FORM form-name invoice2
Number of copies COPIES integer 3
Special modes MODES mode landscape

To find out which values to supply for each type of template (that is, for the pattern and replacement arguments for each keyword), consider the following:

  • The values for the INPUT and OUTPUT templates come from the file type that needs to be converted by the filter and the output type that has to be produced by the filter, respectively. They will each be a type registered with the filter.
  • The value for the TERM template is the printer type.
  • The value for the PRINTER template is the name of the printer that will print the final output.
  • The values for the CPI, LPI, LENGTH, and WIDTH templates come from the user request, the form being used, or the default values for the printer.
  • The value for the PAGES template is a list of pages to be printed. Typically, it is a comma-separated list of page ranges, each of which consists of a dash-separated pair of numbers or a single number (such as 1-6,8,10 for pages 1 through 6, 8, and 10). However, whatever value was given in the -P option to a print request is passed unchanged.
  • The value for the CHARSET template is the name of the character set to be used.
  • The value for the FORM template is the name of the form requested by the -f option of the lp command.
  • The value of the COPIES template determines the number of copies made of the file. If the filter uses this template, the print service will reduce to 1 the number of copies of the filtered file it will have printed, because this single copy will really be the multiple copies produced by the filter.
  • The value of the MODES template comes from the -y option of the lp command (the command used to submit a print request). Because a user can specify several -y options, there may be several values for the MODES template. The values will be applied in the left-to-right order given by the user.

The replacement part of a template shows how the value of a template is given to the filter program. It is typically a literal option, sometimes with the place-holder * (asterisk) included to show where the value goes. The pattern and replacement can also use the regular expression syntax of the ed command for more complex conversion of user input options into filter options. All of the regular expression syntax of the ed command is supported, including the \( . . . \) and \n constructions, which can be used to extract portions of the pattern for copying into the replacement, and the &, which can be used to copy the entire pattern into the replacement.

Note: If a comma or an equal sign (=) is included in a pattern or a replacement, escape its special meaning by preceding it with a backslash (\). Note that some regular expressions include commas that will have to be escaped this way. A backslash in front of any of these characters is removed when the pattern or replacement is used.