source: trunk/third/lprng/doc/LPRng-HOWTO-13.html @ 13098

Revision 13098, 23.1 KB checked in by danw, 25 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r13097, which included commits to RCS files with non-trunk default branches.
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
2<HTML>
3<HEAD>
4 <META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
5 <TITLE> LPRng-HOWTO: Filters</TITLE>
6 <LINK HREF="LPRng-HOWTO-14.html" REL=next>
7 <LINK HREF="LPRng-HOWTO-12.html" REL=previous>
8 <LINK HREF="LPRng-HOWTO.html#toc13" REL=contents>
9</HEAD>
10<BODY>
11<A HREF="LPRng-HOWTO-14.html">Next</A>
12<A HREF="LPRng-HOWTO-12.html">Previous</A>
13<A HREF="LPRng-HOWTO.html#toc13">Contents</A>
14<HR>
15<H2><A NAME="secfilter"></A> <A NAME="s13">13. Filters</A></H2>
16
17<P>This section gives an overview of how LPRng uses filter programs,
18and gives a detailed discussion of how the printcap options and
19filters interact.
20<H2><A NAME="ss13.1">13.1 What are filters?</A>
21</H2>
22
23<P>Print filters are one of the most powerful tools in BSD-style printer
24systems.
25<P>In general UNIX terms, a <EM>filter</EM> is a program that takes its input
26file(s), does something with it, and sends the result to its standard
27output. Most UNIX utilities are designed as filters.
28(But since you are a system manager, you should already know that :))
29<P>In the context of a BSD-style print spooler (and also LPRng), the term
30<EM>filter</EM> refers to a program that processes file while it is
31being transferred to a printer.
32<P>The filter is executed with STDIN reading from the file to be
33printed
34STDOUT to the printer device or a temporary file.
35STDERR (file handle 2) is redirected to a log file,
36and file handle&nbsp;3 to an accounting file.
37<P>A filter can be as simple as a <CODE>LF</CODE> to <CODE>CR/LF</CODE>
38translator,
39or it can incorporate a complete
40accounting system, automatic file type translations,
41or even redirect the job to another printing system.
42<P>As part of the LPRng project,
43the following filters are supported.
44The are many others available for use,
45but are currently not supported.
46<UL>
47<LI> 
48<A HREF="#lpf">lpf</A>
49a very simple CR/LF or passthrough filter.</LI>
50<LI> 
51<A HREF="#ifhp">ifhp</A>
52HP PCL and PJL printer filters </LI>
53<LI></LI>
54</UL>
55
56The supported filters and other facilities are available from
57<A HREF="ftp://ftp.astart.com/pub/LPRng">ftp://ftp.astart.com/pub/LPRng</A><H2><A NAME="if"></A> <A NAME="ss13.2">13.2 What are print formats?</A>
58</H2>
59
60<P>Options used:
61<UL>
62<LI><CODE>if</CODE>,
63<CODE>cf</CODE>,
64<CODE>df</CODE>,
65<CODE>gf</CODE>,
66<CODE>nf</CODE>,
67<CODE>of</CODE>,
68<CODE>rf</CODE>,
69<CODE>tf</CODE>,
70<CODE>vf</CODE>,
71<EM>X</EM><CODE>f</CODE>,
72<EM>&nbsp;&nbsp;Filter programs </EM></LI>
73</UL>
74<P>LPRng has inherited a set of so-called `<B>print formats</B>' from its
75BSD ancestor.
76The format was used to specify the type of file that was being printed.
77The <CODE>lpd</CODE> server
78used the print format to select the filter for processing the file.
79The de<B>f</B>ault format is <CODE>f</CODE>.
80<P>The user can specify the format (i.e., the file type) by giving
81the appropriate option to <CODE>lpr</CODE>:
82<P>
83<UL>
84<LI><CODE>-b</CODE> or <CODE>-l</CODE>: Binary (literal) file. No processing should
85be done.
86The
87<CODE>l</CODE> format is recorded as the file format.</LI>
88<LI><CODE>-c</CODE>: cifplot(1) output.</LI>
89<LI><CODE>-d</CODE>: TeX DVI file.</LI>
90<LI><CODE>-g</CODE>: Output from the plot(3X) routines.</LI>
91<LI><CODE>-n</CODE> or <CODE>-t</CODE>: (di)troff output.</LI>
92<LI><CODE>-p</CODE>: Text file that should be pre-processed by the <CODE>pr</CODE>
93command, and then by the standard text filter.</LI>
94<LI><CODE>-v</CODE>: Benson Varian raster image.</LI>
95</UL>
96<P>Alternatively, one can also use
97<CODE>-Fx</CODE>, where <CODE>x</CODE> is the format specifier.
98(E.g., <CODE>-Fc</CODE>
99instead of <CODE>-c</CODE>.)
100This last form also allows you to use other
101(non-standard) format specifiers.
102<P>The filter for format
103<CODE>X</CODE>
104is the value for the
105<CODE>Xf</CODE> printcap
106option,
107with some minor exceptions.
108The following
109<CODE>Xf</CODE>
110options have a pre-defined meaning.
111<P>
112<UL>
113<LI><CODE>if</CODE>
114The <CODE>f</CODE>
115format filter,
116i.e. - for the default
117<CODE>f</CODE>
118format.
119All print jobs are passed
120through this one, unless another format is selected.</LI>
121<LI>
122<A NAME="cf"></A> 
123<CODE>cf</CODE> Cifplot data filter (for <CODE>-c</CODE> format).</LI>
124<LI>
125<A NAME="df"></A> 
126<CODE>df</CODE> Filter for DVI files (<CODE>-d</CODE>).</LI>
127<LI>
128<A NAME="gf"></A> 
129<CODE>gf</CODE> Graph data filter (<CODE>-g</CODE>).</LI>
130<LI>
131<A NAME="nf"></A> 
132<CODE>nf</CODE> Ditroff data filter (<CODE>-n</CODE>).</LI>
133<LI><CODE>of</CODE> This filter is used for processing the (optional)
134banner at the start and/or end of the print job,
135and also for the interjob separators.
136See
137<A HREF="#ofdetails">of</A> filter for details.</LI>
138<LI>
139<A NAME="rf"></A> 
140<CODE>rf</CODE> Filter for Fortran style files (<CODE>-r</CODE>).</LI>
141<LI>
142<A NAME="tf"></A> 
143<CODE>tf</CODE> Troff filter (<CODE>-t</CODE>).</LI>
144<LI>
145<A NAME="vf"></A> 
146<CODE>vf</CODE> (Versatek) raster image filter (<CODE>-v</CODE>).</LI>
147</UL>
148
149<A NAME="ofdetails"></A> <H2><A NAME="ss13.3">13.3 OF Filter</A>
150</H2>
151
152<P>The
153<CODE>of</CODE>
154filter is used to process banners and job separators.
155The
156<CODE>of</CODE> filter is responsible for performing appropriate
157processing of this information and sending to the printer
158for action.
159<P>While the various file filters are invoked on a once per print file basis,
160the
161<CODE>of</CODE>
162filter is invoked on a once per print job basis.
163<P>This filter is the first one to be started,
164and should perform whatever specialized device initialization
165is needed.
166It should also do whatever accounting procedure is desired
167for start of job accounting.
168<P>The
169<CODE>of</CODE>
170filter will be given any banner printing or job separation
171information for a job.
172As part of its operation,
173it can detect a specific string,
174corresponding to a banner print request,
175and generate a banner.
176(See the
177<A HREF="LPRng-HOWTO-12.html#jobsteps">Job Processing Steps and Printcap Options</A>
178for details.)
179<P>During operation,
180the
181<CODE>lpd</CODE> server will send the special
182<B>stop</B> sequence of <CODE>\031\001</CODE> to the
183<CODE>of</CODE> filter.
184The filter must then suspend itself using a
185<CODE>kill -STOP</CODE> operation.
186The <CODE>lpd</CODE> server will detect that the
187<CODE>of</CODE> filter has suspended itself and then
188will perform other printing operations.
189<P>After the other printing operations have been completed,
190the <CODE>of</CODE> will then be sent a
191<CODE>kill -CONT</CODE> signal.
192<P>This sequence will continue until all information has been printed,
193and then the <CODE>of</CODE> filter's STDIN will be closed.
194The filter will then perform whatever cleanup operations are needed,
195update accounting or other information,
196and exit.
197<H2><A NAME="pr"></A> <A NAME="ss13.4">13.4 LPR -p format</A>
198</H2>
199
200<P>Options used:
201<UL>
202<LI><CODE>pr=</CODE><EM>pr program for p format</EM></LI>
203</UL>
204<P>The <CODE>-p</CODE> format is requires filtering the
205the input files by the <CODE>pr</CODE> utility
206and then passing the result through the
207<CODE>if</CODE> filter.
208<P>This is widely regarded as a kludge and may not be supported
209on your print spooler.
210<H2><A NAME="ss13.5">13.5 LPR binary (-l) format</A>
211</H2>
212
213<P>The binary (or literal) format is <CODE>-l</CODE>.
214The <CODE>if</CODE> filter
215is used to process the file,
216and is invoked with the
217<CODE>-c</CODE>
218(<CODE>c</CODE>ancel processing?) flag.
219<P>The filter will not modify the file when sending it to the printer,
220but may apply various setups to the printer.
221<H2><A NAME="filtercmd"></A> <A NAME="py"></A> <A NAME="px"></A> <A NAME="pw"></A> <A NAME="pl"></A> <A NAME="passenv"></A> <A NAME="filterpath"></A> <A NAME="filterldpath"></A> <A NAME="offilteroptions"></A> <A NAME="filteroptions"></A> <A NAME="bkf"></A> <A NAME="bkoffilteroptions"></A> <A NAME="bkfilteroptions"></A> <A NAME="ss13.6">13.6 Filter Command Line Flags</A>
222</H2>
223
224<P>Options used:
225<UL>
226<LI> <CODE>bk_filter_options=</CODE><EM>Backwards Compatible Filter options</EM></LI>
227<LI> <CODE>bk_of_filter_options=</CODE><EM>Backwards Compatible OF Filter options</EM></LI>
228<LI> <CODE>bkf</CODE><EM>&nbsp;&nbsp;Backwards Compatible Filters</EM></LI>
229<LI> <CODE>filter_ld_path=</CODE><EM>Filter LD_LIBRARY_PATH environment</EM></LI>
230<LI> <CODE>filter_options=</CODE><EM>Filter options</EM></LI>
231<LI> <CODE>filter_path=</CODE><EM>Filter PATH environment</EM></LI>
232<LI> <CODE>of_filter_options=</CODE><EM>OF Filter options</EM></LI>
233<LI> <CODE>pass_env=</CODE><EM>Environment variables to copy to Filter environment</EM></LI>
234<LI> <CODE>pl#</CODE><EM>line count for page</EM></LI>
235<LI> <CODE>pw#</CODE><EM>column count for page</EM></LI>
236<LI> <CODE>px#</CODE><EM>pixel width for page</EM></LI>
237<LI> <CODE>py#</CODE><EM>pixel length for page</EM></LI>
238</UL>
239<P>A filter (or program) specification in the LPRng printcap database
240usually has the form:
241<BLOCKQUOTE><CODE>
242<PRE>
243:option=| [flags] /path [arguments]
244:option=[flags] /path [arguments]
245</PRE>
246</CODE></BLOCKQUOTE>
247<P>The first case is used where the option value can be a string or filter,
248and the second where a program is always expected.
249The following procedure is used to run a filter program.
250<P>The sequence of operations to run a filter is as follows:
251<OL>
252<LI>The program must be specified with an absolute path name.</LI>
253<LI>By default, the program is run as the user if invoked from a client
254program such as <CODE>lpr</CODE>, <CODE>lpc</CODE>, etc.
255If invoked from <CODE>lpd</CODE>,  it is run as the
256<CODE>server_user</CODE>
257user
258(default <CODE>daemon</CODE>) configuration entry.</LI>
259<LI>The
260<EM>flags</EM> control how the program is to be run.
261The following flags are supported:
262<UL>
263<LI><B>ROOT</B>
264This opens a horrible security loophole,
265as it will run the program as ROOT.
266To enable this option,
267you must set various compilation flags,
268and perform other arcane operations.
269This is deliberately done to make administrators
270read the warnings and admonitions.
271<P>The alternative to ROOT is to have a setuid ROOT executable.
272Under NO circumstances should you run a shell script setuid ROOT,
273with general execute permissions on it.
274</LI>
275<LI><B>-$</B>
276This very odd looking flag is used to suppress the addition of
277additional command line arguments
278specified by the value of <CODE>filter_options</CODE>
279to the program command line.</LI>
280</UL>
281</LI>
282<LI>If the <B>-$</B> flag is not specified,
283the arguments determined by the value of the <CODE>bkf</CODE>
284(Berkeley LPD filter compatible flag) flag are added to the
285filter command line.
286If <CODE>bkf</CODE> is false the
287<CODE>filter_options</CODE> are added for OF filters and
288<CODE>of_filter_options</CODE>
289are added for non-OF filters;
290if it is true, then the
291<CODE>bk_filter_options</CODE> and <CODE>bk_of_filter_options</CODE> are added for
292OF and non-OF filters respectively.
293<P>
294<CENTER><TABLE BORDER><TR><TD>
295<BR>
296Option</TD><TD>DefaultValue</TD></TR><TR><TD>
297<CODE>filter_options</CODE></TD><TD>$C $F $H $J $L $P $Q $R $Z $a $c $d $e $f $h $i $j $k $l $n $p$r $s $w $x $y $-a</TD></TR><TR><TD>
298<CODE>of_filter_options</CODE></TD><TD>(same as <CODE>filter_options</CODE>)</TD></TR><TR><TD>
299<CODE>bk_filter_options</CODE></TD><TD>$P $w $l $x $y $F $c $L $i $J $C $0n $0h $-a</TD></TR><TR><TD>
300<CODE>bk_of_filter_options</CODE></TD><TD>$w $l $x $y</TD></TR><TR><TD>
301
302</TD></TR></TABLE></CENTER>
303<P>
304</LI>
305<LI>By default,
306for programs that are not being invoked as print job file filters,
307the
308<CODE>filter_options</CODE>
309arguments are added.
310For print job filters, if the <CODE>bkf</CODE> flag is set,
311then the
312<CODE>bk_filter_options</CODE>
313and
314<CODE>bk_of_filter_options</CODE>
315entries are used.
316The default <CODE>bk</CODE> filter options are the same as originally used
317with the BSD LPR filters.
318For the <CODE>of</CODE> filter,
319either the <CODE>of_filter_options</CODE>
320or <CODE>bk_of_filter_options</CODE> arguments will be added.</LI>
321<LI>The program arguments will then be scanned and interpreted.
322Arguments of the form <CODE>$</CODE><EM>letter</EM> will be
323translated into values from the
324print job control file and/or printcap entry.
325The letters have the following meaning:
326<CENTER><TABLE BORDER><TR><TD>
327<BR>
328Letter</TD><TD>TranslatedValue</TD></TR><TR><TD>
329<CODE>a </CODE></TD><TD>printcap <CODE>af</CODE> (accounting file name)</TD></TR><TR><TD>
330<CODE>b </CODE></TD><TD>job size (in K bytes)</TD></TR><TR><TD>
331<CODE>c </CODE></TD><TD>binary file (<CODE>l</CODE> format for print file)</TD></TR><TR><TD>
332<CODE>d </CODE></TD><TD>printcap <CODE>cd</CODE> or <CODE>sd</CODE> entry</TD></TR><TR><TD>
333<CODE>e </CODE></TD><TD>print job data file name (currently being processed)</TD></TR><TR><TD>
334<CODE>f </CODE></TD><TD>print job original name when spooled for printing (N info from control file)</TD></TR><TR><TD>
335<CODE>h </CODE></TD><TD>print job originating host (H info from control file)</TD></TR><TR><TD>
336<CODE>i </CODE></TD><TD>indent request (I info from control file)</TD></TR><TR><TD>
337<CODE>j </CODE></TD><TD>job number in spool queue</TD></TR><TR><TD>
338<CODE>k </CODE></TD><TD>print job control file name</TD></TR><TR><TD>
339<CODE>l </CODE></TD><TD>printcap <CODE>pl</CODE> (page length)</TD></TR><TR><TD>
340<CODE>m </CODE></TD><TD>printcap <CODE>co</CODE></TD></TR><TR><TD>
341<CODE>n </CODE></TD><TD>user name (L info from control file)</TD></TR><TR><TD>
342<CODE>p </CODE></TD><TD>remote printer (when processing for bounce queue)</TD></TR><TR><TD>
343<CODE>r </CODE></TD><TD>remote host (when processing for bounce queue)</TD></TR><TR><TD>
344<CODE>s </CODE></TD><TD>printcap <CODE>sf</CODE> (status file)</TD></TR><TR><TD>
345<CODE>t </CODE></TD><TD>time in common UNIX format</TD></TR><TR><TD>
346<CODE>w </CODE></TD><TD>printcap <CODE>pw</CODE> (page width)</TD></TR><TR><TD>
347<CODE>x </CODE></TD><TD>printcap <CODE>px</CODE> (page x dimension)</TD></TR><TR><TD>
348<CODE>y </CODE></TD><TD>printcap <CODE>py</CODE> (page y dimension)</TD></TR><TR><TD>
349<CODE>F </CODE></TD><TD>print file format</TD></TR><TR><TD>
350<CODE>P </CODE></TD><TD>printer name</TD></TR><TR><TD>
351<CODE>S </CODE></TD><TD>printcap <CODE>cm</CODE> (comment field)</TD></TR><TR><TD>
352Capital letter</TD><TD>Corresponding line from control file</TD></TR><TR><TD>
353{key}</TD><TD>printcap value for <CODE>key</CODE></TD></TR><TR><TD>
354
355</TD></TR></TABLE></CENTER>
356</LI>
357<LI>If there is no value for the specified argument,
358then the argument is removed from the list.
359If there is a value, the actual form of the substitution is
360controlled by additional flags as follows.
361<CENTER><TABLE BORDER><TR><TD>
362<BR>
363Form</TD><TD>TranslatedValue</TD></TR><TR><TD>
364<CODE> $x </CODE></TD><TD><CODE>'-x<EM>value</EM>' </CODE></TD></TR><TR><TD>
365<CODE> $-x </CODE></TD><TD><CODE> '<EM>value</EM>' </CODE></TD></TR><TR><TD>
366<CODE> $0x </CODE></TD><TD><CODE> -x '<EM>value</EM>' </CODE></TD></TR><TR><TD>
367<CODE> $'x </CODE></TD><TD><CODE> -x <EM>value</EM> </CODE></TD></TR><TR><TD>
368
369</TD></TR></TABLE></CENTER>
370
371<P>Each entry in quotes is treated as a single value,
372as in /bin/sh.
373The <CODE>$'x</CODE> does not quote the value.
374Combinations of the various flags are allowed.  For example,
375<CODE>$-x</CODE> would simply substitute the value for <CODE>x</CODE>,
376and then pass the whitespace separated components as individual arguments.
377This last form is useful for adding in additional flags on the command line.
378</LI>
379<LI>The command line is parsed,
380metacharacters are ruthlessly stripped from all arguments and pathnames
381and replaced by <CODE>_</CODE> (underscores),
382and an argument list suitable for the <CODE>execve</CODE> system call
383is formed.</LI>
384<LI>A sanitized environment is set up for the program execution,
385with the following environment variables.
386<P>
387<CENTER><TABLE BORDER><TR><TD>
388<BR>
389<CODE> USER </CODE></TD><TD>User name (client only)</TD></TR><TR><TD>
390<CODE> LOGNAME </CODE></TD><TD>L control file info</TD></TR><TR><TD>
391<CODE> HOME </CODE></TD><TD>Home directory (client only)</TD></TR><TR><TD>
392<CODE> LOGDIR </CODE></TD><TD>Home directory (client only)</TD></TR><TR><TD>
393<CODE> PATH </CODE></TD><TD><CODE>filter_path</CODE> configuration information</TD></TR><TR><TD>
394<CODE> LD_LIBRARY_PATH </CODE></TD><TD><CODE> filter_ld_path </CODE> configuration information</TD></TR><TR><TD>
395<CODE> SHELL </CODE></TD><TD><CODE>/bin/sh</CODE></TD></TR><TR><TD>
396<CODE> IFS </CODE></TD><TD><CODE>" \t"</CODE></TD></TR><TR><TD>
397<CODE> TZ </CODE></TD><TD>Time zone</TD></TR><TR><TD>
398<CODE> SPOOL_DIR </CODE></TD><TD><CODE>sd</CODE> printcap info</TD></TR><TR><TD>
399<CODE> CONTROL_DIR </CODE></TD><TD><CODE>cd</CODE> printcap info</TD></TR><TR><TD>
400<CODE> PRINTCAP_ENTRY </CODE></TD><TD>printcap info</TD></TR><TR><TD>
401<CODE> CONTROL </CODE></TD><TD>control file</TD></TR><TR><TD>
402
403</TD></TR></TABLE></CENTER>
404<P>
405</LI>
406<LI>If the filter is to be run by a client program such as <CODE>lpr</CODE>,
407then the environment variables specified by the
408<CODE>pass_env</CODE> configuration or printcap option will be
409extracted from the environment,
410have any metacharacters removed,
411and then placed in the environment variable list.
412Commonly, the
413<CODE>PGPPASS</CODE>,
414<CODE>PGPPASSFD</CODE>,
415and <CODE>PGPPATH</CODE> are specified.</LI>
416<LI>The program is started,
417with STDIN, STDOUT, and STDERR attached to the appropriate files or
418file descriptors.
419If none is specified, then they are attached to
420<CODE>/dev/null</CODE>.</LI>
421</OL>
422<H2><A NAME="ss13.7">13.7 LPRng Supported Filters</A>
423</H2>
424
425<P>There already exists a large library of ready-to-use filters. Some of
426them have LPRng-specific versions, which can be found at the
427<A HREF="LPRng-HOWTO-1.html#secftp">LPRng ftp mirror sites</A>.
428<H3>Filter Distribution Conventions</H3>
429
430<P>By convention,
431most filters are either totally standalone (very rare),
432or require a set of support files.
433There are two types of support files: per print queue configuration information
434and global support information.
435<P>Since a print filter will execute with the current directory set to the
436spool queue directory,
437most filters expect that per print queue configuration information
438should be kept in the spool directory.
439Most <EM>vintage</EM> filters insist on having these files <EM>hidden</EM>
440with names such as <B><CODE>.setup</CODE></B>.
441This can make it difficult for administrators to determine where the
442configuration files are.
443<P>It is strongly recommended that filters and information
444be placed in commonly accessible directories such as
445<CODE><B>/usr/local/lib/filters</B></CODE>,
446and the executables in subdirectories.
447This allows the LPRng administrator to set the privileges on these
448directories such that only the <CODE>lpd</CODE> process can
449access them.
450<P>Most of the LPRng supported filters can either be used as a
451<CODE>if</CODE> or <CODE>of</CODE> filter.
452The filter will examine the format type passed by the <CODE>-F<EM>X</EM></CODE>
453command line argument,
454and if it is <CODE>o</CODE> it will perform as an <CODE>of</CODE> filter.
455<P>Alternatively,
456the filter will check the filename in the pathname by which is was invoked.
457If the name has the substring <CODE>of</CODE> in the filename,
458then it assumes it is to act as an <CODE>of</CODE> filter.
459This allows symbolic links to be made to a common filter executable,
460each of which corresponds to the filter name by which it is to be invoked.
461<P>When a filter is invoked,
462it is passed a large number of options,
463many of which are totally ignored in filter operation.
464However,
465for many purposes it is necessary to provide options to the
466filters to tailor their operation to the particular spool queue needs.
467<P>By convention,
468all LPRng supported filters use the
469<BLOCKQUOTE><CODE>
470<PRE>
471-Tkey=value[,key=value]
472</PRE>
473</CODE></BLOCKQUOTE>
474<P>convention for specifying filter configuration option values.
475<H2><A NAME="lpf"></A> <A NAME="ss13.8">13.8 lpf</A>
476</H2>
477
478<P>Source code:
479<A HREF="LPRng-HOWTO-1.html#secftp">LPRng Distribution</A><P>This filter is distributed as part of the LPRng source code,
480and has a very limited functionality.
481By default,
482it only translates <CODE>\n</CODE> to <CODE>\r\n</CODE>
483sequences,
484and detects the OF Filter Stop sequence when invoked as an OF filter.
485<UL>
486<LI>Options:<BR>
487<CODE>-Tcrlf</CODE> - suppress <CODE>\n</CODE> to <CODE>\r\n</CODE> translation</LI>
488</UL>
489<H2><A NAME="ifhp"></A> <A NAME="ss13.9">13.9 IFHP Filter</A>
490</H2>
491
492<P>Source code:
493<A HREF="LPRng-HOWTO-1.html#secftp">LPRng Distribution, ifhp-&lt;em>version&lt;/em>.tgz</A><P>This filter supports a wide variety of <I>smart</I> printers,
494or to be more specific,
495printers which support PostScript, PCL or PJL languages.
496<H3>Printer Capabilities</H3>
497
498<P>As explained in
499<A HREF="LPRng-HOWTO-3.html#installref">Setting Up Your Printer</A>,
500you can have a parallel (unidirectional),
501serial (bidirectional),
502or network (bidirectional) connection.
503When using a bidirectional connection,
504you can sometime obtain or gratuitously receive error and/or status
505information from the printer.
506<P>Some printers will spontaneously generate error messages when printing
507a job on a bidirectional interface.
508Usually, though,
509it it necessary to force the printer to provide status in a reasonable format.
510<P>Some printers have the capability of printing either PCL or PostScript;
511some require special setup commands and some will <EM>autosense</EM> which
512type of job is being printed.
513<P>If you are printing text,
514and not using a Page Description Language like PostScript or PCL,
515then you may want to download a font to the printer.
516This is especially the case when you are trying to print text files
517in a non-English font.
518<P>Some printers will provide a <EM>hardware</EM> page counter value when requested;
519however,
520the means of requesting differ from model to model.
521<P>Sometimes you want to generate a special banner for a particular printer,
522and need to put in some dynamic information.
523While this can be done by the <CODE>lpd</CODE> server using the
524<CODE>bp</CODE> program specification,
525it turns out that non-LPRng systems which want to use the <CODE>ifhp</CODE>
526want to have the same facilities.
527Thus,  you need to have some way to get the same effect as the <CODE>bp</CODE>
528option,  but at the filter level.
529<P>Having done <CODE>lpd</CODE> banner generation and printing,
530why not have the filter run an accounting script as well?
531<P>At this point,  I suspect that the reader is beginning to suspect that
532making a general purpose filter to support all of these possibilities is
533difficult.
534That is incorrect.  It is <B>extremely</B> difficult.
535<P>However,
536the <CODE>ifhp</CODE> filter greatly simplifies this,
537as it uses a simple database together with some printer configuration options.
538For details,
539see the <CODE>ifhp</CODE> documentation for details on using the filter.
540For the terminally impatient,
541the following is a quick cookbook:
542<BLOCKQUOTE><CODE>
543<PRE>
544# network connection to jet direct box,
545#   no banners, HP compatible
546lp
547  :lp=ipaddr%9100
548  :/usr/local/lib/filters/ifhp
549  :sh:sf
550#
551# banner added
552#
553lp
554  :bp=/usr/local/lib/filters/pclbanner
555  :of=/usr/local/lib/filters/ifhp
556  :if=/usr/local/lib/filters/ifhp
557  :sf:sb
558#
559# for a parallel port printer or when you want VERY fast
560#  throughput, no pagecounts, error messages, etc.  The
561#
562lp
563  :ifhp=status@
564  :/usr/local/lib/filters/ifhp -Tstatus@
565  :sh:sf
566</PRE>
567</CODE></BLOCKQUOTE>
568<H2><A NAME="ss13.10">13.10 Using your own filters</A>
569</H2>
570
571<P>If you already have a working setup, with its own specific filter
572programs, you might want to keep them. Or, you might want to write a
573set of your own.
574<P>See the source code in the
575<A HREF="LPRng-HOWTO-1.html#secftp">LPRng Distribution, FILTERS_LPRng-&lt;version>.tgz</A> files for examples.
576<HR>
577<A HREF="LPRng-HOWTO-14.html">Next</A>
578<A HREF="LPRng-HOWTO-12.html">Previous</A>
579<A HREF="LPRng-HOWTO.html#toc13">Contents</A>
580</BODY>
581</HTML>
Note: See TracBrowser for help on using the repository browser.