1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 2 3<html> 4 <head> 5 <meta name="generator" content="HTML Tidy, see www.w3.org"> 6 <title>Printcap Database</title> 7 <meta name="GENERATOR" content= 8 "Modular DocBook HTML Stylesheet Version 1.7"> 9 <link rel="HOME" title=" LPRng Reference Manual" href= 10 "index.htm"> 11 <link rel="PREVIOUS" title="Serial Printers " href= 12 "secserial.htm"> 13 <link rel="NEXT" title="Simple Client Printcap Entry " href= 14 "simple.htm"> 15 </head> 16 17 <body class="CHAPTER" bgcolor="#FFFFFF" text="#000000" link= 18 "#0000FF" vlink="#840084" alink="#0000FF"> 19 <div class="NAVHEADER"> 20 <table summary="Header navigation table" width="100%" border= 21 "0" cellpadding="0" cellspacing="0"> 22 <tr> 23 <th colspan="3" align="center">LPRng Reference Manual: 5 24 Sep 2003 (For LPRng-3.8.22)</th> 25 </tr> 26 27 <tr> 28 <td width="10%" align="left" valign="bottom"><a href= 29 "secserial.htm" accesskey="P">Prev</a></td> 30 31 <td width="80%" align="center" valign="bottom"> 32 </td> 33 34 <td width="10%" align="right" valign="bottom"><a href= 35 "simple.htm" accesskey="N">Next</a></td> 36 </tr> 37 </table> 38 <hr align="LEFT" width="100%"> 39 </div> 40 41 <div class="CHAPTER"> 42 <h1><a name="PRINTCAPREF"></a>Chapter 12. Printcap 43 Database</h1> 44 45 <div class="TOC"> 46 <dl> 47 <dt><b>Table of Contents</b></dt> 48 49 <dt>12.1. <a href="printcapref.htm#PRINTCAPPARSE">The 50 Printcap Parsing Rules</a></dt> 51 52 <dt>12.2. <a href="simple.htm">Simple Client Printcap 53 Entry</a></dt> 54 55 <dt>12.3. <a href="cm.htm">Simple Server Printcap 56 Example</a></dt> 57 58 <dt>12.4. <a href="x5732.htm">Using :oh To Select 59 Printcap Information</a></dt> 60 61 <dt>12.5. <a href="x5758.htm">Using the Wildcard Printcap 62 Entry</a></dt> 63 64 <dt>12.6. <a href="x5770.htm">Enterprise Strength 65 Printcap Example</a></dt> 66 67 <dt>12.7. <a href="x5787.htm">Remote Printer Using 68 RFC1179</a></dt> 69 70 <dt>12.8. <a href="x5821.htm">Remote Printer Using Socket 71 API</a></dt> 72 73 <dt>12.9. <a href="x5848.htm">Parallel Printer</a></dt> 74 75 <dt>12.10. <a href="serial.htm">Serial Printer</a></dt> 76 77 <dt>12.11. <a href="lpdbounce.htm">Bounce Queue</a></dt> 78 79 <dt>12.12. <a href="translateformat.htm">Job Format 80 Translation</a></dt> 81 82 <dt>12.13. <a href="destinations.htm">Dynamic 83 Routing</a></dt> 84 85 <dt>12.14. <a href="loadbalance.htm">Printer Load 86 Balancing</a></dt> 87 88 <dt>12.15. <a href="printcappath.htm">Locations of 89 Printcap Files</a></dt> 90 91 <dt>12.16. <a href="secoh.htm">Single Printcap File for 92 Large Installation</a></dt> 93 94 <dt>12.17. <a href="x6118.htm">Management Strategies for 95 Large Installations</a></dt> 96 97 <dt>12.18. <a href="secnis.htm">Using Programs To Get 98 Printcap Information</a></dt> 99 100 <dt>12.19. <a href="x6228.htm">Lexmark Printers</a></dt> 101 102 <dt>12.20. <a href="p450.htm">Tektronix Phaser 103 Printers</a></dt> 104 105 <dt>12.21. <a href="x6242.htm">Duplex Printing</a></dt> 106 107 <dt>12.22. <a href="x6263.htm">Solaris, Newsprint and 108 FrameMaker</a></dt> 109 </dl> 110 </div> 111 112 <p>As described in the <a href="tutorial.htm#OVERVIEW">Print 113 Spooling Overview</a>, the heart of the <b class= 114 "APPLICATION">LPRng</b> system is information in the <tt 115 class="FILENAME">printcap</tt> file. The printcap information 116 specifies:</p> 117 118 <ol type="1"> 119 <li> 120 <p>The print queues available to users.</p> 121 </li> 122 123 <li> 124 <p>How client programs communicate with the <b class= 125 "APPLICATION">lpc</b> print server.</p> 126 </li> 127 128 <li> 129 <p>The configuration, location, and other information for 130 each print queue on the print server.</p> 131 </li> 132 133 <li> 134 <p>How the <b class="APPLICATION">lpd</b> server 135 processes jobs in each print queue.</p> 136 </li> 137 </ol> 138 <br> 139 <br> 140 141 <p>In order to explain a complex subject, we will start with 142 a set of simple printer configurations, and explain the 143 purpose and effect of each entry in the printcap.</p> 144 145 <p>For details about individual printcap options, see the 146 <span class="CITEREFENTRY"><span class= 147 "REFENTRYTITLE">printcap</span>(5)</span> man page from the 148 <b class="APPLICATION">LPRng</b> distribution, or use the <a 149 href="optionindex.htm">Index To All The Configuration and 150 Printcap Options</a> to find a specific printcap option and 151 its effects.</p> 152 153 <div class="SECT1"> 154 <h1 class="SECT1"><a name="PRINTCAPPARSE">12.1. The 155 Printcap Parsing Rules</a></h1> 156 157 <p>Options used:</p> 158 159 <ul> 160 <li> 161 <p><var class="LITERAL">client</var> FLAG <span class= 162 "emphasis"><i class="EMPHASIS">printcap entry valid 163 only for client programs</i></span></p> 164 </li> 165 166 <li> 167 <p><var class="LITERAL">oh=</var><span class= 168 "emphasis"><i class="EMPHASIS">hosts where printcap 169 entry valid</i></span></p> 170 </li> 171 172 <li> 173 <p><var class="LITERAL">server</var><span class= 174 "emphasis"><i class="EMPHASIS">printcap entry valid 175 only for lpd server</i></span></p> 176 </li> 177 178 <li> 179 <p><var class="LITERAL">tc</var><span class= 180 "emphasis"><i class="EMPHASIS">add named printcap entry 181 contents</i></span></p> 182 </li> 183 </ul> 184 <br> 185 <br> 186 187 <p>In this section, we will discuss the remaining tricky 188 parts of the <b class="APPLICATION">LPRng</b> printcap 189 database: combined client and server printcaps, host 190 specific printcap entries, and the <var class= 191 "LITERAL">tc</var> <span class="emphasis"><i class= 192 "EMPHASIS">include</i></span> facility.</p> 193 194 <p>The following is a complete description of how a 195 printcap file is processed:</p> 196 197 <ol type="1"> 198 <li> 199 <p>When processing a printcap file, the <b class= 200 "APPLICATION">LPRng</b> software reads and parses each 201 entry individually. Leading whitespace is removed. 202 Lines starting with <var class="LITERAL">#</var> and 203 blank lines are ignored.</p> 204 </li> 205 206 <li> 207 <p>Lines ending with <var class="LITERAL">\</var> will 208 have the <var class="LITERAL">\</var> discarded, and 209 all lines of a printcap entry are joined by removing 210 the line separators (<var class="LITERAL">\n</var>) and 211 replacing them with a space.</p> 212 </li> 213 214 <li> 215 <p>The printcap entry is parsed, and the printcap name, 216 aliases, and options are determined. Colons <var class= 217 "LITERAL">:</var> act as option separators, and leading 218 and trailing whitespaces are removed.</p> 219 </li> 220 221 <li> 222 <p>Options are sorted and except for the <var class= 223 "LITERAL">tc=...</var> option only the last option 224 setting is retained.</p> 225 </li> 226 227 <li> 228 <p>If an option value requires a colon, then the <var 229 class="LITERAL">\:</var> or <var class= 230 "LITERAL">\072</var>, the same escaped character value 231 as used in the C, Perl, tcl, and other programming 232 languages, can be used.</p> 233 </li> 234 235 <li> 236 <p>Client programs will discard a printcap entry with a 237 <var class="LITERAL">server</var> option and server 238 programs will discard a printcap entry with a <var 239 class="LITERAL">client</var> options.</p> 240 </li> 241 242 <li> 243 <p>The <var class="LITERAL">oh</var> (<span class= 244 "emphasis"><i class="EMPHASIS">o</i></span>n this <span 245 class="emphasis"><i class="EMPHASIS">h</i></span>ost) 246 option specifies a list of IP addresses and mask pairs 247 or glob strings which are used to determine if this 248 printcap entry is valid for this host (see discussion 249 below).</p> 250 </li> 251 252 <li> 253 <p>After the above processing, if there is an existing 254 termcap entry with the same name, the two sets of 255 options are combined, with the last option setting 256 retained except for the <var class="LITERAL">tc</var> 257 entries which are combined.</p> 258 </li> 259 260 <li> 261 <p>When a printcap entry is actually used, the printcap 262 entries listed by the <var class="LITERAL">tc</var> 263 include option are extracted and combined in order. 264 This allows include entries to appear after the 265 referring printcap entry. Then printcap options will be 266 combined with the included ones. This has the effect 267 that the options specified in the printcap entry will 268 override the ones from the <var class= 269 "LITERAL">tc</var> included entries.</p> 270 </li> 271 272 <li> 273 <p>Finally, each string printcap option with a <span 274 class="emphasis"><i class="EMPHASIS">%X</i></span> 275 value has <span class="emphasis"><i class= 276 "EMPHASIS">%X</i></span> replaced by the following 277 values. Unspecified values will not be modified.</p> 278 279 <div class="INFORMALTABLE"> 280 <a name="AEN5414"></a> 281 282 <table border="1" frame="border" rules="all" class= 283 "CALSTABLE"> 284 <col> 285 <col> 286 <col> 287 288 <thead> 289 <tr> 290 <th>Key</th> 291 292 <th>Value</th> 293 294 <th>Purpose</th> 295 </tr> 296 </thead> 297 298 <tbody> 299 <tr> 300 <td><var class="LITERAL">%P</var></td> 301 302 <td>printcap entry primary name</td> 303 304 <td> </td> 305 </tr> 306 307 <tr> 308 <td><var class="LITERAL">%Q</var></td> 309 310 <td>queue requested</td> 311 312 <td> </td> 313 </tr> 314 315 <tr> 316 <td><var class="LITERAL">%h</var></td> 317 318 <td>short host name (host)</td> 319 320 <td> </td> 321 </tr> 322 323 <tr> 324 <td><var class="LITERAL">%H</var></td> 325 326 <td>fully qualified host name 327 (host.dns.whatever)</td> 328 329 <td> </td> 330 </tr> 331 332 <tr> 333 <td><var class="LITERAL">%R</var></td> 334 335 <td>remote printer (rp value)</td> 336 337 <td> </td> 338 </tr> 339 340 <tr> 341 <td><var class="LITERAL">%M</var></td> 342 343 <td>remote host (rm value)</td> 344 345 <td> </td> 346 </tr> 347 348 <tr> 349 <td><var class="LITERAL">%D</var></td> 350 351 <td>date in YYYY-MM-DD format</td> 352 353 <td> </td> 354 </tr> 355 </tbody> 356 </table> 357 </div> 358 <br> 359 <br> 360 </li> 361 362 <li> 363 <p>When parsing multiple printcap files, these are 364 processed in order, and all of their printcap entries 365 are combined according to the above procedures. The 366 <var class="LITERAL">tc</var> resolution and <span 367 class="emphasis"><i class="EMPHASIS">%X</i></span> 368 expansion is done after all the files have been 369 processed.</p> 370 </li> 371 </ol> 372 <br> 373 <br> 374 375 <p>The following examples show how to use the above rules 376 to your advantage. You can combine both client and server 377 printcap information in a single file as well as dividing a 378 printcap entry into several parts. Here is an example:</p> 379 380 <div class="INFORMALEXAMPLE"> 381 <a name="AEN5455"></a> 382<pre class="SCREEN"> 383 # seen by both client and server 384 lp1:lp=lp@pr1:mx=100 385 lp1:sd=/usr/local/spool/lp1:mx=0 386 # seen only by client 387 lp2:lp=lp@pr2:client 388 # seen only by server 389 lp2:lp=/dev/lp:server 390</pre> 391 </div> 392 393 <ol type="1"> 394 <li> 395 <p>Printcap entries with the same name are combined. 396 The first printcap entry, <var class= 397 "LITERAL">lp1</var>, the information is seen by both 398 client and server. The next printcap entry, with the 399 same name <var class="LITERAL">lp1</var>, will be 400 combined with the first one. The order of options is 401 important - the entries are scanned in order and an 402 option will have the last value set. Thus, after having 403 read both the <var class="LITERAL">lp1</var> printcap 404 entries, both client and server will have:</p> 405 406 <div class="INFORMALEXAMPLE"> 407 <a name="AEN5463"></a> 408<pre class="SCREEN"> 409 lp1:lp=lp@pr1 410 :mx=0 411 :sd=/usr/local/spool/lp1 412</pre> 413 </div> 414 <br> 415 <br> 416 </li> 417 418 <li> 419 <p>The <var class="LITERAL">lp2</var> has a client and 420 server version. This is recommended when complex 421 printcaps on multiple hosts and servers are used. Thus, 422 the <b class="APPLICATION">LPRng</b> clients will 423 see:</p> 424 425 <div class="INFORMALEXAMPLE"> 426 <a name="AEN5469"></a> 427<pre class="SCREEN"> 428 lp1 429 :lp=lp@pr1 430 :mx=0 431 :sd=/usr/local/spool/lp1 432 lp2 433 :client 434 :lp=lp@pr2 435</pre> 436 </div> 437 and the server will see: 438 439 <div class="INFORMALEXAMPLE"> 440 <a name="AEN5471"></a> 441<pre class="SCREEN"> 442 lp1 443 :lp=lp@pr1 444 :mx=0 445 :sd=/usr/local/spool/lp1 446 lp2 447 :lp=/dev/lp 448 :server 449</pre> 450 </div> 451 <br> 452 <br> 453 </li> 454 </ol> 455 <br> 456 <br> 457 458 <p>If you have multiple printers of the same type whose 459 configuration is almost identical, then you can define a 460 set of <span class="emphasis"><i class= 461 "EMPHASIS">tc</i></span> only printcap entries containing 462 common information and use the <var class= 463 "LITERAL">tc</var> include facility.</p> 464 465 <p>Printcap entry names may start with period (<var class= 466 "LITERAL">.</var>), question mark (<var class= 467 "LITERAL">?</var>), or exclamation mark (<var class= 468 "LITERAL">!</var>), followed by one or more alphanumeric , 469 underscore (<var class="LITERAL">_</var>) or hyphen (<var 470 class="LITERAL">-</var>) characters. Queue or printer names 471 start with an alphanumeric character. Printcap entries 472 whose names do not start with an alphanumeric character can 473 only be used as targets of the <var class= 474 "LITERAL">tc</var> include facility. For example:</p> 475 476 <div class="INFORMALEXAMPLE"> 477 <a name="AEN5483"></a> 478<pre class="SCREEN"> 479 .hp: 480 :sd=/usr/local/spool/%P 481 :mx=0 482 hp1:tc=.hp,.filter 483 :lp=lp@10.0.0.1 484 hp2:tc=.hp,.filter 485 :lp=lp@10.0.0.2 486 .filter 487 :filter=/usr/local/libexec/filters/ifhp 488</pre> 489 </div> 490 491 <ol type="1"> 492 <li> 493 <p>The <tt class="FILENAME">.hp</tt> and <tt class= 494 "FILENAME">.filter</tt> printcap entities are not spool 495 queue definitions. After <var class="LITERAL">tc</var> 496 include processing is completed, the printcap 497 information would resemble:</p> 498 499 <div class="INFORMALEXAMPLE"> 500 <a name="AEN5491"></a> 501<pre class="SCREEN"> 502 hp1 503 :lp=lp@10.0.0.1 504 :filter=/usr/local/libexec/filters/ifhp 505 :mx=0 506 :sd=/usr/local/spool/%P 507 hp2 508 :lp=lp@10.0.0.2 509 :filter=/usr/local/libexec/filters/ifhp 510 :mx=0 511 :sd=/usr/local/spool/%P 512</pre> 513 </div> 514 <br> 515 <br> 516 </li> 517 518 <li> 519 <p>The <var class="LITERAL">%X</var> processing will 520 replace <var class="LITERAL">%P</var> with the printcap 521 name, so we would have:</p> 522 523 <div class="INFORMALEXAMPLE"> 524 <a name="AEN5497"></a> 525<pre class="SCREEN"> 526 hp1 527 :lp=lp@10.0.0.1 528 :filter=/usr/local/libexec/filters/ifhp 529 :mx=0 530 :sd=/usr/local/spool/hp1 531 hp2 532 :lp=lp@10.0.0.2 533 :filter=/usr/local/libexec/filters/ifhp 534 :mx=0 535 :sd=/usr/local/spool/hp2 536</pre> 537 </div> 538 <br> 539 <br> 540 </li> 541 </ol> 542 <br> 543 <br> 544 </div> 545 </div> 546 547 <div class="NAVFOOTER"> 548 <hr align="LEFT" width="100%"> 549 550 <table summary="Footer navigation table" width="100%" border= 551 "0" cellpadding="0" cellspacing="0"> 552 <tr> 553 <td width="33%" align="left" valign="top"><a href= 554 "secserial.htm" accesskey="P">Prev</a></td> 555 556 <td width="34%" align="center" valign="top"><a href= 557 "index.htm" accesskey="H">Home</a></td> 558 559 <td width="33%" align="right" valign="top"><a href= 560 "simple.htm" accesskey="N">Next</a></td> 561 </tr> 562 563 <tr> 564 <td width="33%" align="left" valign="top">Serial 565 Printers</td> 566 567 <td width="34%" align="center" valign="top"> </td> 568 569 <td width="33%" align="right" valign="top">Simple Client 570 Printcap Entry</td> 571 </tr> 572 </table> 573 </div> 574 </body> 575</html> 576 577