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

Revision 14517, 23.2 KB checked in by mwhitson, 25 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r14516, 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 the status file,
36and file handle&nbsp;3 to an accounting file or program.
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 [argument | "argument" | 'argument' ]*
244:option=[flags]   /path [argument | "argument" | 'argument' ]*
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.
250Arguments in single or double quotes are passed as a single value,
251as for a shell.
252No escape (backslash) support is provided.
253<P>The sequence of operations to run a filter is as follows:
254<OL>
255<LI>The program must be specified with an absolute path name.</LI>
256<LI>By default, the program is run as the user if invoked from a client
257program such as <CODE>lpr</CODE>, <CODE>lpc</CODE>, etc.
258If invoked from <CODE>lpd</CODE>,  it is run as the
259<CODE>server_user</CODE>
260user
261(default <CODE>daemon</CODE>) configuration entry.</LI>
262<LI>The
263<EM>flags</EM> control how the program is to be run.
264The following flags are supported:
265<UL>
266<LI><B>ROOT</B>
267This opens a horrible security loophole,
268as it will run the program as ROOT.
269To enable this option,
270you must set various compilation flags,
271and perform other arcane operations.
272This is deliberately done to make administrators
273read the warnings and admonitions.
274<P>The alternative to ROOT is to have a setuid ROOT executable.
275Under NO circumstances should you run a shell script setuid ROOT,
276with general execute permissions on it.
277</LI>
278<LI><B>-$</B>
279This very odd looking flag is used to suppress the addition of
280additional command line arguments
281specified by the value of <CODE>filter_options</CODE>
282to the program command line.</LI>
283</UL>
284</LI>
285<LI>If the <B>-$</B> flag is not specified,
286the arguments determined by the value of the <CODE>bkf</CODE>
287(Berkeley LPD filter compatible flag) flag are added to the
288filter command line.
289If <CODE>bkf</CODE> is false the
290<CODE>filter_options</CODE> are added for OF filters and
291<CODE>of_filter_options</CODE>
292are added for non-OF filters;
293if it is true, then the
294<CODE>bk_filter_options</CODE> and <CODE>bk_of_filter_options</CODE> are added for
295OF and non-OF filters respectively.
296<P>
297<CENTER><TABLE BORDER><TR><TD>
298<BR>
299Option</TD><TD>DefaultValue</TD></TR><TR><TD>
300<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>
301<CODE>of_filter_options</CODE></TD><TD>(same as <CODE>filter_options</CODE>)</TD></TR><TR><TD>
302<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>
303<CODE>bk_of_filter_options</CODE></TD><TD>$w $l $x $y</TD></TR><TR><TD>
304
305</TD></TR></TABLE></CENTER>
306<P>
307</LI>
308<LI>By default,
309for programs that are not being invoked as print job file filters,
310the
311<CODE>filter_options</CODE>
312arguments are added.
313For print job filters, if the <CODE>bkf</CODE> flag is set,
314then the
315<CODE>bk_filter_options</CODE>
316and
317<CODE>bk_of_filter_options</CODE>
318entries are used.
319The default <CODE>bk</CODE> filter options are the same as originally used
320with the BSD LPR filters.
321For the <CODE>of</CODE> filter,
322either the <CODE>of_filter_options</CODE>
323or <CODE>bk_of_filter_options</CODE> arguments will be added.</LI>
324<LI>The program arguments will then be scanned and interpreted.
325Arguments of the form <CODE>$</CODE><EM>letter</EM> will be
326translated into values from the
327print job control file and/or printcap entry.
328The letters have the following meaning:
329<CENTER><TABLE BORDER><TR><TD>
330<BR>
331Letter</TD><TD>TranslatedValue</TD></TR><TR><TD>
332<CODE>a </CODE></TD><TD>printcap <CODE>af</CODE> (accounting file name)</TD></TR><TR><TD>
333<CODE>b </CODE></TD><TD>job size (in K bytes)</TD></TR><TR><TD>
334<CODE>c </CODE></TD><TD>binary file (<CODE>l</CODE> format for print file)</TD></TR><TR><TD>
335<CODE>d </CODE></TD><TD>printcap <CODE>cd</CODE> or <CODE>sd</CODE> entry</TD></TR><TR><TD>
336<CODE>e </CODE></TD><TD>print job data file name (currently being processed)</TD></TR><TR><TD>
337<CODE>f </CODE></TD><TD>print job original name when spooled for printing (N info from control file)</TD></TR><TR><TD>
338<CODE>h </CODE></TD><TD>print job originating host (H info from control file)</TD></TR><TR><TD>
339<CODE>i </CODE></TD><TD>indent request (I info from control file)</TD></TR><TR><TD>
340<CODE>j </CODE></TD><TD>job number in spool queue</TD></TR><TR><TD>
341<CODE>k </CODE></TD><TD>print job control file name</TD></TR><TR><TD>
342<CODE>l </CODE></TD><TD>printcap <CODE>pl</CODE> (page length)</TD></TR><TR><TD>
343<CODE>m </CODE></TD><TD>printcap <CODE>co</CODE></TD></TR><TR><TD>
344<CODE>n </CODE></TD><TD>user name (L info from control file)</TD></TR><TR><TD>
345<CODE>p </CODE></TD><TD>remote printer (when processing for bounce queue)</TD></TR><TR><TD>
346<CODE>r </CODE></TD><TD>remote host (when processing for bounce queue)</TD></TR><TR><TD>
347<CODE>s </CODE></TD><TD>printcap <CODE>sf</CODE> (status file)</TD></TR><TR><TD>
348<CODE>t </CODE></TD><TD>time in common UNIX format</TD></TR><TR><TD>
349<CODE>w </CODE></TD><TD>printcap <CODE>pw</CODE> (page width)</TD></TR><TR><TD>
350<CODE>x </CODE></TD><TD>printcap <CODE>px</CODE> (page x dimension)</TD></TR><TR><TD>
351<CODE>y </CODE></TD><TD>printcap <CODE>py</CODE> (page y dimension)</TD></TR><TR><TD>
352<CODE>F </CODE></TD><TD>print file format</TD></TR><TR><TD>
353<CODE>P </CODE></TD><TD>printer name</TD></TR><TR><TD>
354<CODE>S </CODE></TD><TD>printcap <CODE>cm</CODE> (comment field)</TD></TR><TR><TD>
355Capital letter</TD><TD>Corresponding line from control file</TD></TR><TR><TD>
356{key}</TD><TD>printcap value for <CODE>key</CODE></TD></TR><TR><TD>
357
358</TD></TR></TABLE></CENTER>
359</LI>
360<LI>If there is no value for the specified argument,
361then the argument is removed from the list.
362If there is a value, the actual form of the substitution is
363controlled by additional flags as follows.
364<CENTER><TABLE BORDER><TR><TD>
365<BR>
366Form</TD><TD>TranslatedValue</TD></TR><TR><TD>
367<CODE> $x </CODE></TD><TD><CODE>'-x<EM>value</EM>' </CODE></TD></TR><TR><TD>
368<CODE> $-x </CODE></TD><TD><CODE> '<EM>value</EM>' </CODE></TD></TR><TR><TD>
369<CODE> $0x </CODE></TD><TD><CODE> -x '<EM>value</EM>' </CODE></TD></TR><TR><TD>
370<CODE> $'x </CODE></TD><TD><CODE> -x <EM>value</EM> </CODE></TD></TR><TR><TD>
371
372</TD></TR></TABLE></CENTER>
373
374<P>Each entry in quotes is treated as a single value,
375as in /bin/sh.
376The <CODE>$'x</CODE> does not quote the value.
377Combinations of the various flags are allowed.  For example,
378<CODE>$-x</CODE> would simply substitute the value for <CODE>x</CODE>,
379and then pass the whitespace separated components as individual arguments.
380This last form is useful for adding in additional flags on the command line.
381</LI>
382<LI>The command line is parsed,
383metacharacters are ruthlessly stripped from all arguments and pathnames
384and replaced by <CODE>_</CODE> (underscores),
385and an argument list suitable for the <CODE>execve</CODE> system call
386is formed.</LI>
387<LI>A sanitized environment is set up for the program execution,
388with the following environment variables.
389<P>
390<CENTER><TABLE BORDER><TR><TD>
391<BR>
392<CODE> USER </CODE></TD><TD>User name (client only)</TD></TR><TR><TD>
393<CODE> LOGNAME </CODE></TD><TD>L control file info</TD></TR><TR><TD>
394<CODE> HOME </CODE></TD><TD>Home directory (client only)</TD></TR><TR><TD>
395<CODE> LOGDIR </CODE></TD><TD>Home directory (client only)</TD></TR><TR><TD>
396<CODE> PATH </CODE></TD><TD><CODE>filter_path</CODE> configuration information</TD></TR><TR><TD>
397<CODE> LD_LIBRARY_PATH </CODE></TD><TD><CODE> filter_ld_path </CODE> configuration information</TD></TR><TR><TD>
398<CODE> SHELL </CODE></TD><TD><CODE>/bin/sh</CODE></TD></TR><TR><TD>
399<CODE> IFS </CODE></TD><TD><CODE>" \t"</CODE></TD></TR><TR><TD>
400<CODE> TZ </CODE></TD><TD>Time zone</TD></TR><TR><TD>
401<CODE> SPOOL_DIR </CODE></TD><TD><CODE>sd</CODE> printcap info</TD></TR><TR><TD>
402<CODE> CONTROL_DIR </CODE></TD><TD><CODE>cd</CODE> printcap info</TD></TR><TR><TD>
403<CODE> PRINTCAP_ENTRY </CODE></TD><TD>printcap info</TD></TR><TR><TD>
404<CODE> CONTROL </CODE></TD><TD>control file</TD></TR><TR><TD>
405
406</TD></TR></TABLE></CENTER>
407<P>
408</LI>
409<LI>If the filter is to be run by a client program such as <CODE>lpr</CODE>,
410then the environment variables specified by the
411<CODE>pass_env</CODE> configuration or printcap option will be
412extracted from the environment,
413have any metacharacters removed,
414and then placed in the environment variable list.
415Commonly, the
416<CODE>PGPPASS</CODE>,
417<CODE>PGPPASSFD</CODE>,
418and <CODE>PGPPATH</CODE> are specified.</LI>
419<LI>The program is started,
420with STDIN, STDOUT, and STDERR attached to the appropriate files or
421file descriptors.
422If none is specified, then they are attached to
423<CODE>/dev/null</CODE>.</LI>
424</OL>
425<H2><A NAME="ss13.7">13.7 LPRng Supported Filters</A>
426</H2>
427
428<P>There already exists a large library of ready-to-use filters. Some of
429them have LPRng-specific versions, which can be found at the
430<A HREF="LPRng-HOWTO-1.html#secftp">LPRng ftp mirror sites</A>.
431<H3>Filter Distribution Conventions</H3>
432
433<P>By convention,
434most filters are either totally standalone (very rare),
435or require a set of support files.
436There are two types of support files: per print queue configuration information
437and global support information.
438<P>Since a print filter will execute with the current directory set to the
439spool queue directory,
440most filters expect that per print queue configuration information
441should be kept in the spool directory.
442Most <EM>vintage</EM> filters insist on having these files <EM>hidden</EM>
443with names such as <B><CODE>.setup</CODE></B>.
444This can make it difficult for administrators to determine where the
445configuration files are.
446<P>It is strongly recommended that filters and information
447be placed in commonly accessible directories such as
448<CODE><B>/usr/local/libexec/filters</B></CODE>,
449and the executables in subdirectories.
450This allows the LPRng administrator to set the privileges on these
451directories such that only the <CODE>lpd</CODE> process can
452access them.
453<P>Most of the LPRng supported filters can either be used as a
454<CODE>if</CODE> or <CODE>of</CODE> filter.
455The filter will examine the format type passed by the <CODE>-F<EM>X</EM></CODE>
456command line argument,
457and if it is <CODE>o</CODE> it will perform as an <CODE>of</CODE> filter.
458<P>Alternatively,
459the filter will check the filename in the pathname by which is was invoked.
460If the name has the substring <CODE>of</CODE> in the filename,
461then it assumes it is to act as an <CODE>of</CODE> filter.
462This allows symbolic links to be made to a common filter executable,
463each of which corresponds to the filter name by which it is to be invoked.
464<P>When a filter is invoked,
465it is passed a large number of options,
466many of which are totally ignored in filter operation.
467However,
468for many purposes it is necessary to provide options to the
469filters to tailor their operation to the particular spool queue needs.
470<P>By convention,
471all LPRng supported filters use the
472<BLOCKQUOTE><CODE>
473<PRE>
474-Tkey=value[,key=value]
475</PRE>
476</CODE></BLOCKQUOTE>
477<P>convention for specifying filter configuration option values.
478<H2><A NAME="lpf"></A> <A NAME="ss13.8">13.8 lpf</A>
479</H2>
480
481<P>Source code:
482<A HREF="LPRng-HOWTO-1.html#secftp">LPRng Distribution</A><P>This filter is distributed as part of the LPRng source code,
483and has a very limited functionality.
484By default,
485it only translates <CODE>\n</CODE> to <CODE>\r\n</CODE>
486sequences,
487and detects the OF Filter Stop sequence when invoked as an OF filter.
488<UL>
489<LI>Options:<BR>
490<CODE>-Tcrlf</CODE> - suppress <CODE>\n</CODE> to <CODE>\r\n</CODE> translation</LI>
491</UL>
492<H2><A NAME="ifhp"></A> <A NAME="ss13.9">13.9 IFHP Filter</A>
493</H2>
494
495<P>Source code:
496<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,
497or to be more specific,
498printers which support PostScript, PCL or PJL languages.
499<P>As explained in
500<A HREF="LPRng-HOWTO-3.html#installref">Setting Up Your Printer</A>,
501you can have a parallel (unidirectional),
502serial (bidirectional),
503or network (bidirectional) connection.
504When using a bidirectional connection,
505you can sometime obtain or gratuitously receive error and/or status
506information from the printer.
507<P>Some printers will spontaneously generate error messages when printing
508a job on a bidirectional interface.
509Usually, though,
510it it necessary to force the printer to provide status in a reasonable format.
511<P>Some printers have the capability of printing either PCL or PostScript;
512some require special setup commands and some will <EM>autosense</EM> which
513type of job is being printed.
514<P>If you are printing text,
515and not using a Page Description Language like PostScript or PCL,
516then you may want to download a font to the printer.
517This is especially the case when you are trying to print text files
518in a non-English font.
519<P>Some printers will provide a <EM>hardware</EM> page counter value when requested;
520however,
521the means of requesting differ from model to model.
522<P>Sometimes you want to generate a special banner for a particular printer,
523and need to put in some dynamic information.
524While this can be done by the <CODE>lpd</CODE> server using the
525<CODE>bp</CODE> program specification,
526it turns out that non-LPRng systems which want to use the <CODE>ifhp</CODE>
527want to have the same facilities.
528Thus,  you need to have some way to get the same effect as the <CODE>bp</CODE>
529option,  but at the filter level.
530<P>Having done <CODE>lpd</CODE> banner generation and printing,
531why not have the filter run an accounting script as well?
532<P>At this point,  I suspect that the reader is beginning to suspect that
533making a general purpose filter to support all of these possibilities is
534difficult.
535That is incorrect.  It is <B>extremely</B> difficult.
536<P>However,
537the <CODE>ifhp</CODE> filter greatly simplifies this,
538as it uses a simple database together with some printer configuration options.
539For details,
540see the <CODE>ifhp</CODE> documentation for details on using the filter.
541For the terminally impatient,
542the following is a quick cookbook:
543<BLOCKQUOTE><CODE>
544<PRE>
545# network connection to jet direct box,
546#   no banners, HP compatible
547lp
548  :lp=ipaddr%9100
549  :/usr/local/libexec/filters/ifhp
550  :sh:sf
551#
552# banner added
553#
554lp
555  :bp=/usr/local/libexec/filters/pclbanner
556  :of=/usr/local/libexec/filters/ifhp
557  :if=/usr/local/libexec/filters/ifhp
558  :sf
559#
560# for a parallel port printer or when you want VERY fast
561#  throughput, no pagecounts, error messages, etc.  The
562#
563lp
564  :ifhp=status@
565  :/usr/local/libexec/filters/ifhp
566  :sh:sf
567</PRE>
568</CODE></BLOCKQUOTE>
569<H2><A NAME="ss13.10">13.10 Using your own filters</A>
570</H2>
571
572<P>If you already have a working setup, with its own specific filter
573programs, you might want to keep them. Or, you might want to write a
574set of your own.
575<P>See the source code in the
576<A HREF="LPRng-HOWTO-1.html#secftp">LPRng Distribution, FILTERS_LPRng-&lt;version>.tgz</A> files for examples.
577<HR>
578<A HREF="LPRng-HOWTO-14.html">Next</A>
579<A HREF="LPRng-HOWTO-12.html">Previous</A>
580<A HREF="LPRng-HOWTO.html#toc13">Contents</A>
581</BODY>
582</HTML>
Note: See TracBrowser for help on using the repository browser.