The etcprintcap File BSD Printer Configuration and the Printer Capability Database

10.2.1.1 The etcprintcap File

The master printer configuration database is contained in the etcprintcap file. This file lists all devices serviced by the BSD printer spooling subsystem. A more precise description of the file would be printer capability database, which the name stands for. UNIX systems are usually shipped with a standard version of the etcprintcap file the template file, which describes most of the printers that could be used on the system. Each printer type is described by one printcap entry, which consists of a sufficient number of printcap fields describing different printer characteristics. Upon its installation, the entries can be commented−out; the system administrator should configure etcprintcap by activating the proper entries for the implemented printers. Sometimes minor modifications of entries are required, though in most cases the entries match existing printers. The etcprintcap file includes other printer configuration data necessary for successful printing, as well as data related to the printer characteristics, making it a true master printer configuration file. The lpd daemon reads the printer−related data from the etcprintcap file on an as−needed basis. This means any configuration change will be effective immediately, and there is no need to reinvoke the daemon itself as would be the case for the majority of daemons. Here is an example of a etcprintcap file: cat etcprintcap Printer Capability Data Base Modified on Feb. 2, 1998 by the System Administrator Entry for HP LaserJet IV printer 0\lp\lj4\hplj\ljiv\ascii\HP LaserJet 4: \ :mx0:\ :ms=−parity,−cstopb,−clocal,cread,ixon,ixoff,−opost:\ :lp=devttya:sd=usrspoollaserjet:br9600:\ :fc0777:fs06021:sb:sh:xc07737:x s040:\ :lf=usradmlpd−errs:of=usrlibhplaserjet: Entry for HP plotter for future use 5|HP|hp plotter|HP Plotter:\ :lp=devccplot:\ :of=usrspoolspff:\ :xn=146.95.1.3:\ :xp=6:\ :pl0:\ :lf=usradmerrorlog:\ :sh:\ :ff=[.Y:fo:tr=PG;: POSTSCRIPT laser printer pp|pp|PostScript|postscript:\ :lp=devppplot:\ :of=usrspoolspff:\ :xn=146.95.1.3:\ :xp=2:\ :lf=usradmerrorlog:\ :sh: Remote printers on the microVAX computer MVAXGR 10|prvax|vx|vax|sysprint|decwriter|line printer:\ :lp=:rm=mvaxgr:sd= usrspoollpdvax:lf=usr admlpd−errs:\ 227 11|lsvax|laser|syslspr|lsprinter|laser printer:\ :lp=:rm=mvaxgr:sd=usrspoollpdvax:lf=usr admlpd−errs:\ :rp=syslspr: ..... ..... Remote printers on RISC computers RS01CH and RS09CH 15|exrisc|rs09ch|ex|ex printer:\ :lp=:rm=rs09ch:sd=usrspoollpdrisc:lf=usradmlpd−errs:\ :rp=ex: 16|psrisc|rs01ch|ps|postscript|ps printer:\ :lp=:rm=rs01ch:sd=usrspoollpdrisc:lf=usradmlpd−errs:\ :rp=ps: ..... ..... Printer for SGI 20|lsv:\ :lp=:rm=mvaxgr:sd= usrspoollpdsgi:lf=usr admlpd−errs:\ :rp=syslspr: The etcprintcap is a simplified version of the termcap database discussed in Chapter 11, adapted to fully describe printers. The printer spooling subsystem accesses the printcap file every time it is used, allowing dynamic addition and deletion of a printers data. The basic rules for creating a printcap entry are: The lines beginning with a number sign are comments, and are not active lines. • Each entry can have an arbitrary number of items fields separated by colons :; an entry can continue from one line to another using the usual UNIX continuation backslash character \ at the end of a line. • Each printer is often identified by multiple names; the names are arbitrary and are the names available to that user on the system. The first name is, by convention, a number; the second given name is the most common abbreviation for the printer, and the last name should be the long name fully identifying the printer. The second name should contain no blanks; the last name may contain blanks for readability. A vertical line the pipe character | separates the printers names, and at least one of the names should be easy to use: short, logical, and easy to remember. • The default printer is identified by the generic name lp, appended to its other names; this will be explained in greater detail later. The BSD printing commands supports a −P printer option to explicitly determine the destination printer. • The remaining fields describe the printers capabilities characteristics, resources, and its use. • All capabilities in the printcap file are specified by two−character codes, and may be of three possible types: Boolean Capabilities, which, if they appear in a field, indicate that the printer has some particular feature. Boolean capabilities are simply written in an entrys fields between the : characters. In the capability table that follows, they are indicated by the word bool in the type column. Numeric Capabilities that supply information such as baud−rates, number of lines per page, etc. Numeric capabilities are specified by the word num in the type column of the capabilities table that follows. Numeric capabilities are identified by the 228 String Capabilities that specify a sequence that should be used to perform particular printer operations, for example, a cursor motion. String valued capabilities are specified by the word str in the type column of the capabilities table that follows. String valued capabilities are identified by the two−character capability code with the trailing = sign, followed by a string up to the next colon :. For example, : rp=spinwriter: is a sample entry stating that the remote printer is named spinwriter. The table of various capabilities in alphabetic order follows; the most common capabilities are presented in bold. Name Type Default Description af str NULL Name of accounting file br num none If lp is a tty, set the baud rate cf str NULL Cifplot data filter df str NULL TeX data filter DVI format du str User ID of user daemon fc num 0 If lp is a tty, clear flag bits ff str \f String to send for a form feed fo bool false Print a form feed when device is opened fs num 0 Like fc but set bits gf str NULL Graph data filter plot3X format hl bool false Print the burst header page last ic bool false Driver supports nonstandard ioctl to indent printout if str NULL Name of inputcommunication filter created per job lf str devconsole Error logging file name lo str lock Name of lock file lp str devlp Device name to open for output mc num 0 Maximum number of copies ms str NULL List of terminal modes to set or clear mx num 1000 Maximum file size in BUFSIZ blocks, zero = unlimited nd str NULL Next directory for list of queues unimplemented nf str NULL Ditroff data filter device independent troff of str NULL Name of outputbanner filter created once pc num 200 Price per foot or page in hundredths of cents pl num 66 Page length in lines pw num 132 Page width in characters px num 0 Page width in pixels horizontal py num 0 Page length in pixels vertical rf str NULL Filter for printing FORTRAN style text files rg str NULL Restricted group, only members of group allowed access rm str NULL Machine name for remote printer rp str lp Remote printer name argument 229 rw bool false Open printer device readwrite instead of write−only sb bool false Short banner one line only sc bool false Suppress multiple copies sd str varspoollpd Spool directory sf bool false Suppress form feeds sh bool false Suppress printing of burst page header st str status Status file name tc str NULL Name of similar printer; must be last tf str NULL Troff data filter CAT phototypesetter tr str NULL Trailer string to print when queue empties vf str NULL Raster image filter xc num 0 If lp is a tty, clear local mode bits xs num 0 Like xc but set bits 10.2.1.2 Setting the BSD Default Printer The system default printer is defined by the generic name lp within the etcprintcap file. The entry for the default printer should have attached lp to one, or more of its valid names, and only one entry can have such a name. Otherwise, the default printer will not be defined properly, and the first defined default entry within the file will be interpreted as the default destination. In the past, the local printer accessed via the special file devlp was usually assumed to be the default one; however, the default printer could be any local or remote printer lp could be assigned to any entry in the file. It is not mandatory to specify a default printer at all, in fact. Obviously, none of the existing printers can be regularly named lp; otherwise BSD printing subsystem will assume this printer for the default one. Such a restriction does not present a real problem in the implementation. Individual users can specify their own default printers with the PRINTER environment variable. The default printer is usually the most used printer, and the only benefit of using the default printer is the shorter printing commands since there is no need for the −P option. All other printing characteristics are defined in the printcap file in the same way as for other printers. 10.2.1.3 Spooling Directories The spooling directory holds files destined for a particular printer until the lpd daemon can process them for printing. Spooling directories are conventionally subdirectories located in usrspool or varspool. Each printer has to have a defined spooling directory; otherwise, the printing will be disabled. The spooling directory is defined within the printers printcap entry in the etcprintcap file. The field: sd=usrspooldir_name Defines the spooling directory for the corresponding printer All spooling directories must be owned by the user daemon, and the group daemon, with the access mode 755 drwxr−xr−x. Such a protection scheme gives the necessary write access to files that have been spooled, forcing users to use the printer spooling system and preventing anyone from deleting someone elses pending files, or otherwise abusing the system. 230 cd usrspool mkdir newprinter chown daemon.daemon newprinter original BSD syntax chmod 755 newprinter ls −ld drwxr−xr−x 2 daemon daemon 2048 May 12 11:15 newprinter The location of spooling directories varies among BSD UNIX flavors for example, the common location of the spooling directory on SunOS was varspool.

10.2.1.4 Filters