Chapter 12. Printcap Database

Table of Contents
12.1. The Printcap Parsing Rules
12.2. Simple Client Printcap Entry
12.3. Simple Server Printcap Example
12.4. Using :oh To Select Printcap Information
12.5. Using the Wildcard Printcap Entry
12.6. Enterprise Strength Printcap Example
12.7. Remote Printer Using RFC1179
12.8. Remote Printer Using Socket API
12.9. Parallel Printer
12.10. Serial Printer
12.11. Bounce Queue
12.12. Job Format Translation
12.13. Dynamic Routing
12.14. Printer Load Balancing
12.15. Locations of Printcap Files
12.16. Single Printcap File for Large Installation
12.17. Management Strategies for Large Installations
12.18. Using Programs To Get Printcap Information
12.19. Lexmark Printers
12.20. Tektronix Phaser Printers
12.21. Duplex Printing
12.22. Solaris, Newsprint and FrameMaker

As described in the Print Spooling Overview, the heart of the LPRng system is information in the printcap file. The printcap information specifies:

  1. The print queues available to users.

  2. How client programs communicate with the lpc print server.

  3. The configuration, location, and other information for each print queue on the print server.

  4. How the lpd server processes jobs in each print queue.



In order to explain a complex subject, we will start with a set of simple printer configurations, and explain the purpose and effect of each entry in the printcap.

For details about individual printcap options, see the printcap(5) man page from the LPRng distribution, or use the Index To All The Configuration and Printcap Options to find a specific printcap option and its effects.

12.1. The Printcap Parsing Rules

Options used:



In this section, we will discuss the remaining tricky parts of the LPRng printcap database: combined client and server printcaps, host specific printcap entries, and the tc include facility.

The following is a complete description of how a printcap file is processed:

  1. When processing a printcap file, the LPRng software reads and parses each entry individually. Leading whitespace is removed. Lines starting with # and blank lines are ignored.

  2. Lines ending with \ will have the \ discarded, and all lines of a printcap entry are joined by removing the line separators (\n) and replacing them with a space.

  3. The printcap entry is parsed, and the printcap name, aliases, and options are determined. Colons : act as option separators, and leading and trailing whitespaces are removed.

  4. Options are sorted and except for the tc=... option only the last option setting is retained.

  5. If an option value requires a colon, then the \: or \072, the same escaped character value as used in the C, Perl, tcl, and other programming languages, can be used.

  6. Client programs will discard a printcap entry with a server option and server programs will discard a printcap entry with a client options.

  7. The oh (on this host) option specifies a list of IP addresses and mask pairs or glob strings which are used to determine if this printcap entry is valid for this host (see discussion below).

  8. After the above processing, if there is an existing termcap entry with the same name, the two sets of options are combined, with the last option setting retained except for the tc entries which are combined.

  9. When a printcap entry is actually used, the printcap entries listed by the tc include option are extracted and combined in order. This allows include entries to appear after the referring printcap entry. Then printcap options will be combined with the included ones. This has the effect that the options specified in the printcap entry will override the ones from the tc included entries.

  10. Finally, each string printcap option with a %X value has %X replaced by the following values. Unspecified values will not be modified.

    Key Value Purpose
    %P printcap entry primary name  
    %Q queue requested  
    %h short host name (host)  
    %H fully qualified host name (host.dns.whatever)  
    %R remote printer (rp value)  
    %M remote host (rm value)  
    %D date in YYYY-MM-DD format  


  11. When parsing multiple printcap files, these are processed in order, and all of their printcap entries are combined according to the above procedures. The tc resolution and %X expansion is done after all the files have been processed.



The following examples show how to use the above rules to your advantage. You can combine both client and server printcap information in a single file as well as dividing a printcap entry into several parts. Here is an example:

    # seen by both client and server
    lp1:lp=lp@pr1:mx=100
    lp1:sd=/usr/local/spool/lp1:mx=0
    # seen only by client
    lp2:lp=lp@pr2:client
    # seen only by server
    lp2:lp=/dev/lp:server
  1. Printcap entries with the same name are combined. The first printcap entry, lp1, the information is seen by both client and server. The next printcap entry, with the same name lp1, will be combined with the first one. The order of options is important - the entries are scanned in order and an option will have the last value set. Thus, after having read both the lp1 printcap entries, both client and server will have:

        lp1:lp=lp@pr1
          :mx=0
          :sd=/usr/local/spool/lp1
    


  2. The lp2 has a client and server version. This is recommended when complex printcaps on multiple hosts and servers are used. Thus, the LPRng clients will see:

        lp1
          :lp=lp@pr1
          :mx=0
          :sd=/usr/local/spool/lp1
        lp2
          :client
          :lp=lp@pr2
    
    and the server will see:
        lp1
          :lp=lp@pr1
          :mx=0
          :sd=/usr/local/spool/lp1
        lp2
          :lp=/dev/lp
          :server
    




If you have multiple printers of the same type whose configuration is almost identical, then you can define a set of tc only printcap entries containing common information and use the tc include facility.

Printcap entry names may start with period (.), question mark (?), or exclamation mark (!), followed by one or more alphanumeric , underscore (_) or hyphen (-) characters. Queue or printer names start with an alphanumeric character. Printcap entries whose names do not start with an alphanumeric character can only be used as targets of the tc include facility. For example:

    .hp:
      :sd=/usr/local/spool/%P
      :mx=0
    hp1:tc=.hp,.filter
      :lp=lp@10.0.0.1
    hp2:tc=.hp,.filter
      :lp=lp@10.0.0.2
    .filter
      :filter=/usr/local/libexec/filters/ifhp
  1. The .hp and .filter printcap entities are not spool queue definitions. After tc include processing is completed, the printcap information would resemble:

        hp1
          :lp=lp@10.0.0.1
          :filter=/usr/local/libexec/filters/ifhp
          :mx=0
          :sd=/usr/local/spool/%P
        hp2
          :lp=lp@10.0.0.2
          :filter=/usr/local/libexec/filters/ifhp
          :mx=0
          :sd=/usr/local/spool/%P
    


  2. The %X processing will replace %P with the printcap name, so we would have:

        hp1
          :lp=lp@10.0.0.1
          :filter=/usr/local/libexec/filters/ifhp
          :mx=0
          :sd=/usr/local/spool/hp1
        hp2
          :lp=lp@10.0.0.2
          :filter=/usr/local/libexec/filters/ifhp
          :mx=0
          :sd=/usr/local/spool/hp2