PRINTCAP(5)

๐ŸŒธ PRINTCAP(5) โ€” printcap ๐Ÿ’–

okay bestie, so this is the manual page for printcap from the File Formats Manual, and it's literally the printer capability database. it's serving file-format realness, and i'm gonna walk you through every single crumb. ๐ŸŽ€


โœจ NAME โœจ

printcap โ€” printer capability database ๐Ÿ’…


โœจ SYNOPSIS โœจ

printcap

โœจ DESCRIPTION โœจ

so. the printcap file is a simplified lil sibling of the termcap(5) database, and its whole job is describing line printers. the spooling system reads the printcap file every single time it's used, which means you can dynamically add and delete printers โ€” iconic behavior, no restart needed, we love that for us. every entry in the database describes exactly one printer.

โš ๏ธ okay so this part matters: this database may not be substituted for, the way it's possible with termcap(5), because it may allow accounting to be bypassed. so don't try it. periodt.

the default printer is normally lp, though the environment variable PRINTER may be used to override this. and every spooling utility supports an option, -Pprinter, so you can explicitly name a destination printer. ๐Ÿซถ

if you want the complete discussion on how to set up the database for a given printer, go read the 4.3 BSD Line Printer Spooler Manual. it's giving required reading.


โœจ CAPABILITIES โœจ

for the file layout deets, refer to termcap(5). here's the whole roster of capabilities โ€” name, type, default, description, all of it, no crumbs left behind: ๐Ÿฆ‹

  • af โ€” str โ€” default NULL โ€” name of accounting file
  • br โ€” num โ€” default none โ€” if lp is a tty, set baud rate (ioctl(2) call)
  • cf โ€” str โ€” default NULL โ€” cifplot data filter
  • df โ€” str โ€” default NULL โ€” tex data filter (DVI format)
  • fc โ€” num โ€” default 0 โ€” if lp is a tty, clear flag bits (โŸจsgtty.hโŸฉ)
  • ff โ€” str โ€” default โ€˜\fโ€™ โ€” string to send for a form feed
  • fo โ€” bool โ€” default false โ€” print a form feed when device is opened
  • fs โ€” num โ€” default 0 โ€” if lp is a tty, set flag bits (โŸจsgtty.hโŸฉ)
  • gf โ€” str โ€” default NULL โ€” graph data filter (plot(3) format)
  • hl โ€” bool โ€” default false โ€” print the burst header page last
  • ic โ€” bool โ€” default false โ€” supports non-standard ioctl to indent printout
  • if โ€” str โ€” default NULL โ€” name of text filter which does accounting
  • lf โ€” str โ€” default /dev/console โ€” error logging file name
  • lo โ€” str โ€” default lock โ€” name of lock file
  • lp โ€” str โ€” default /dev/lp โ€” local printer device, or port@host for remote
  • ms โ€” str โ€” default NULL โ€” list of terminal modes to set or clear
  • mx โ€” num โ€” default 1000 โ€” max file size (in BUFSIZ blocks); 0=unlimited
  • nd โ€” str โ€” default NULL โ€” next directory for queues list (unimplemented)
  • nf โ€” str โ€” default NULL โ€” ditroff data filter (device independent troff)
  • of โ€” str โ€” default NULL โ€” name of output filtering program
  • pc โ€” num โ€” default 200 โ€” price per foot or page in hundredths of cents
  • pl โ€” num โ€” default 66 โ€” page length (in lines)
  • pw โ€” num โ€” default 132 โ€” page width (in characters)
  • px โ€” num โ€” default 0 โ€” page width in pixels (horizontal)
  • py โ€” num โ€” default 0 โ€” page length in pixels (vertical)
  • rf โ€” str โ€” default NULL โ€” filter for printing FORTRAN style text files
  • rg โ€” str โ€” default NULL โ€” restricted group-only group members can access
  • rm โ€” str โ€” default NULL โ€” machine name for remote printer
  • rp โ€” str โ€” default lp'' `` โ€” remote printer name argument
  • rs โ€” bool โ€” default false โ€” remote users must have a local account
  • rw โ€” bool โ€” default false โ€” open printer device for reading and writing
  • sb โ€” bool โ€” default false โ€” short banner (one line only)
  • sc โ€” bool โ€” default false โ€” suppress multiple copies
  • sd โ€” str โ€” default /var/spool/lpd โ€” spool directory
  • sf โ€” bool โ€” default false โ€” suppress form feeds
  • sh โ€” bool โ€” default false โ€” suppress printing of burst page header
  • st โ€” str โ€” default status โ€” status file name
  • tf โ€” str โ€” default NULL โ€” troff data filter (cat phototypesetter)
  • tr โ€” str โ€” default NULL โ€” trailer string to print when queue empties
  • vf โ€” str โ€” default NULL โ€” raster image filter
  • xc โ€” num โ€” default 0 โ€” if lp is a tty, clear local mode bits (tty(4))
  • xs โ€” num โ€” default 0 โ€” if lp is a tty, set local mode bits (tty(4))

and one more lil note for the girlies: if the local line printer driver supports indentation, the daemon must understand how to invoke it. no exceptions. ๐Ÿ‘‘


โœจ FILTERS โœจ

if a printer is specified via lp (either local or remote), the lpd(8) daemon creates a pipeline of โ€œfiltersโ€ to process files for various printer types. ๐Ÿ’ซ

๐Ÿšจ important caveat: the pipeline is not set up for remote printers specified via rm unless the local host is the same as the remote printer host given.

which filters get selected depends on the flags passed to lpr(1). here's the pipeline that gets set up:

p       pr | if regular text + pr(1)
none    if      regular text
c       cf      cifplot
d       df      DVI (tex)
g       gf      plot(3)
n       nf      ditroff
f       rf      Fortran
t       tf      troff
v       vf      raster image

๐ŸŽ€ the if filter

the if filter is invoked with these arguments:

if [-c] -wwidth -llength -iindent -n login -h host acct-file

okay let's break it down because this is giving detail-heavy and we love accuracy:

  • the -c flag is passed only if the -l flag (pass control characters literally) is specified to lpr(1).
  • width and length specify the page width and length (from pw and pl, respectively) in characters.
  • the -n and -h parameters specify the login name and host name of the owner of the job, respectively.
  • the acct-file function is passed from the af printcap entry.

๐ŸŽ€ no if? use of

if no if is specified, of is used instead โ€” with the distinction that of is opened only once, while if is opened for every individual job. so basically, if is better suited to performing accounting. ๐Ÿ’… the of is only given the width and length flags.

๐ŸŽ€ all the other filters

all other filters are called as:

filter -xwidth -ylength -n login -h host acct-file

where width and length are represented in pixels, specified by the px and py entries, respectively. and here's the vibe check on all filters: they take stdin as the file, stdout as the printer, may log either to stderr or using syslog(3), and must not ignore SIGINT. ๐Ÿ˜ค no cap.


โœจ LOGGING โœจ

error messages generated by the line printer programs themselves are logged by syslog(3) using the LPR facility. ๐Ÿชต

messages printed on stderr of one of the filters get sent to the corresponding lf file. and the filters may, of course, use syslog(3) themselves โ€” they're grown, they can log however they want. ๐Ÿ™ˆ

and one tiny lil detail: error messages sent to the console have a carriage return and a line feed appended to them, rather than just a line feed. yes bestie, \r\n, it's giving old school. ๐ŸŽ€


โœจ SEE ALSO โœจ

and also: the 4.3 BSD Line Printer Spooler Manual. ๐Ÿ“š


โœจ HISTORY โœจ

the printcap file format appeared in 4.2BSD. it's an OG, it's been here since forever, and honestly? iconic behavior. ๐Ÿ‘‘


so that's the whole entire page, every flag, every default, every filter, every lil caveat โ€” nothing skipped, nothing summarized, we ate and left no crumbs. ๐Ÿ’œ

๐Ÿฆ‹ mwah, this page lives on Debian, dated December 11, 1993, and it's filed under PRINTCAP(5) in the manual. slay, bye bestie!! ๐ŸŒˆโœจ๐Ÿ’–

๐Ÿ“ฆ where this page comes from