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, |
---|
18 | and gives a detailed discussion of how the printcap options and |
---|
19 | filters 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 |
---|
24 | systems. |
---|
25 | <P>In general UNIX terms, a <EM>filter</EM> is a program that takes its input |
---|
26 | file(s), does something with it, and sends the result to its standard |
---|
27 | output. 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 |
---|
31 | being transferred to a printer. |
---|
32 | <P>The filter is executed with STDIN reading from the file to be |
---|
33 | printed |
---|
34 | STDOUT to the printer device or a temporary file. |
---|
35 | STDERR (file handle 2) is redirected to a log file, |
---|
36 | and file handle 3 to an accounting file. |
---|
37 | <P>A filter can be as simple as a <CODE>LF</CODE> to <CODE>CR/LF</CODE> |
---|
38 | translator, |
---|
39 | or it can incorporate a complete |
---|
40 | accounting system, automatic file type translations, |
---|
41 | or even redirect the job to another printing system. |
---|
42 | <P>As part of the LPRng project, |
---|
43 | the following filters are supported. |
---|
44 | The are many others available for use, |
---|
45 | but are currently not supported. |
---|
46 | <UL> |
---|
47 | <LI> |
---|
48 | <A HREF="#lpf">lpf</A> |
---|
49 | a very simple CR/LF or passthrough filter.</LI> |
---|
50 | <LI> |
---|
51 | <A HREF="#ifhp">ifhp</A> |
---|
52 | HP PCL and PJL printer filters </LI> |
---|
53 | <LI></LI> |
---|
54 | </UL> |
---|
55 | |
---|
56 | The 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> Filter programs </EM></LI> |
---|
73 | </UL> |
---|
74 | <P>LPRng has inherited a set of so-called `<B>print formats</B>' from its |
---|
75 | BSD ancestor. |
---|
76 | The format was used to specify the type of file that was being printed. |
---|
77 | The <CODE>lpd</CODE> server |
---|
78 | used the print format to select the filter for processing the file. |
---|
79 | The 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 |
---|
81 | the 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 |
---|
85 | be done. |
---|
86 | The |
---|
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> |
---|
93 | command, 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> |
---|
99 | instead of <CODE>-c</CODE>.) |
---|
100 | This last form also allows you to use other |
---|
101 | (non-standard) format specifiers. |
---|
102 | <P>The filter for format |
---|
103 | <CODE>X</CODE> |
---|
104 | is the value for the |
---|
105 | <CODE>Xf</CODE> printcap |
---|
106 | option, |
---|
107 | with some minor exceptions. |
---|
108 | The following |
---|
109 | <CODE>Xf</CODE> |
---|
110 | options have a pre-defined meaning. |
---|
111 | <P> |
---|
112 | <UL> |
---|
113 | <LI><CODE>if</CODE> |
---|
114 | The <CODE>f</CODE> |
---|
115 | format filter, |
---|
116 | i.e. - for the default |
---|
117 | <CODE>f</CODE> |
---|
118 | format. |
---|
119 | All print jobs are passed |
---|
120 | through 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) |
---|
134 | banner at the start and/or end of the print job, |
---|
135 | and also for the interjob separators. |
---|
136 | See |
---|
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> |
---|
154 | filter is used to process banners and job separators. |
---|
155 | The |
---|
156 | <CODE>of</CODE> filter is responsible for performing appropriate |
---|
157 | processing of this information and sending to the printer |
---|
158 | for action. |
---|
159 | <P>While the various file filters are invoked on a once per print file basis, |
---|
160 | the |
---|
161 | <CODE>of</CODE> |
---|
162 | filter is invoked on a once per print job basis. |
---|
163 | <P>This filter is the first one to be started, |
---|
164 | and should perform whatever specialized device initialization |
---|
165 | is needed. |
---|
166 | It should also do whatever accounting procedure is desired |
---|
167 | for start of job accounting. |
---|
168 | <P>The |
---|
169 | <CODE>of</CODE> |
---|
170 | filter will be given any banner printing or job separation |
---|
171 | information for a job. |
---|
172 | As part of its operation, |
---|
173 | it can detect a specific string, |
---|
174 | corresponding to a banner print request, |
---|
175 | and generate a banner. |
---|
176 | (See the |
---|
177 | <A HREF="LPRng-HOWTO-12.html#jobsteps">Job Processing Steps and Printcap Options</A> |
---|
178 | for details.) |
---|
179 | <P>During operation, |
---|
180 | the |
---|
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. |
---|
184 | The filter must then suspend itself using a |
---|
185 | <CODE>kill -STOP</CODE> operation. |
---|
186 | The <CODE>lpd</CODE> server will detect that the |
---|
187 | <CODE>of</CODE> filter has suspended itself and then |
---|
188 | will perform other printing operations. |
---|
189 | <P>After the other printing operations have been completed, |
---|
190 | the <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, |
---|
193 | and then the <CODE>of</CODE> filter's STDIN will be closed. |
---|
194 | The filter will then perform whatever cleanup operations are needed, |
---|
195 | update accounting or other information, |
---|
196 | and 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 |
---|
205 | the input files by the <CODE>pr</CODE> utility |
---|
206 | and 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 |
---|
209 | on 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>. |
---|
214 | The <CODE>if</CODE> filter |
---|
215 | is used to process the file, |
---|
216 | and 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, |
---|
220 | but 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> 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 |
---|
240 | usually 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, |
---|
248 | and the second where a program is always expected. |
---|
249 | The 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 |
---|
254 | program such as <CODE>lpr</CODE>, <CODE>lpc</CODE>, etc. |
---|
255 | If invoked from <CODE>lpd</CODE>, it is run as the |
---|
256 | <CODE>server_user</CODE> |
---|
257 | user |
---|
258 | (default <CODE>daemon</CODE>) configuration entry.</LI> |
---|
259 | <LI>The |
---|
260 | <EM>flags</EM> control how the program is to be run. |
---|
261 | The following flags are supported: |
---|
262 | <UL> |
---|
263 | <LI><B>ROOT</B> |
---|
264 | This opens a horrible security loophole, |
---|
265 | as it will run the program as ROOT. |
---|
266 | To enable this option, |
---|
267 | you must set various compilation flags, |
---|
268 | and perform other arcane operations. |
---|
269 | This is deliberately done to make administrators |
---|
270 | read the warnings and admonitions. |
---|
271 | <P>The alternative to ROOT is to have a setuid ROOT executable. |
---|
272 | Under NO circumstances should you run a shell script setuid ROOT, |
---|
273 | with general execute permissions on it. |
---|
274 | </LI> |
---|
275 | <LI><B>-$</B> |
---|
276 | This very odd looking flag is used to suppress the addition of |
---|
277 | additional command line arguments |
---|
278 | specified by the value of <CODE>filter_options</CODE> |
---|
279 | to the program command line.</LI> |
---|
280 | </UL> |
---|
281 | </LI> |
---|
282 | <LI>If the <B>-$</B> flag is not specified, |
---|
283 | the arguments determined by the value of the <CODE>bkf</CODE> |
---|
284 | (Berkeley LPD filter compatible flag) flag are added to the |
---|
285 | filter command line. |
---|
286 | If <CODE>bkf</CODE> is false the |
---|
287 | <CODE>filter_options</CODE> are added for OF filters and |
---|
288 | <CODE>of_filter_options</CODE> |
---|
289 | are added for non-OF filters; |
---|
290 | if it is true, then the |
---|
291 | <CODE>bk_filter_options</CODE> and <CODE>bk_of_filter_options</CODE> are added for |
---|
292 | OF and non-OF filters respectively. |
---|
293 | <P> |
---|
294 | <CENTER><TABLE BORDER><TR><TD> |
---|
295 | <BR> |
---|
296 | Option</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, |
---|
306 | for programs that are not being invoked as print job file filters, |
---|
307 | the |
---|
308 | <CODE>filter_options</CODE> |
---|
309 | arguments are added. |
---|
310 | For print job filters, if the <CODE>bkf</CODE> flag is set, |
---|
311 | then the |
---|
312 | <CODE>bk_filter_options</CODE> |
---|
313 | and |
---|
314 | <CODE>bk_of_filter_options</CODE> |
---|
315 | entries are used. |
---|
316 | The default <CODE>bk</CODE> filter options are the same as originally used |
---|
317 | with the BSD LPR filters. |
---|
318 | For the <CODE>of</CODE> filter, |
---|
319 | either the <CODE>of_filter_options</CODE> |
---|
320 | or <CODE>bk_of_filter_options</CODE> arguments will be added.</LI> |
---|
321 | <LI>The program arguments will then be scanned and interpreted. |
---|
322 | Arguments of the form <CODE>$</CODE><EM>letter</EM> will be |
---|
323 | translated into values from the |
---|
324 | print job control file and/or printcap entry. |
---|
325 | The letters have the following meaning: |
---|
326 | <CENTER><TABLE BORDER><TR><TD> |
---|
327 | <BR> |
---|
328 | Letter</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> |
---|
352 | Capital 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, |
---|
358 | then the argument is removed from the list. |
---|
359 | If there is a value, the actual form of the substitution is |
---|
360 | controlled by additional flags as follows. |
---|
361 | <CENTER><TABLE BORDER><TR><TD> |
---|
362 | <BR> |
---|
363 | Form</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, |
---|
372 | as in /bin/sh. |
---|
373 | The <CODE>$'x</CODE> does not quote the value. |
---|
374 | Combinations of the various flags are allowed. For example, |
---|
375 | <CODE>$-x</CODE> would simply substitute the value for <CODE>x</CODE>, |
---|
376 | and then pass the whitespace separated components as individual arguments. |
---|
377 | This last form is useful for adding in additional flags on the command line. |
---|
378 | </LI> |
---|
379 | <LI>The command line is parsed, |
---|
380 | metacharacters are ruthlessly stripped from all arguments and pathnames |
---|
381 | and replaced by <CODE>_</CODE> (underscores), |
---|
382 | and an argument list suitable for the <CODE>execve</CODE> system call |
---|
383 | is formed.</LI> |
---|
384 | <LI>A sanitized environment is set up for the program execution, |
---|
385 | with 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>, |
---|
407 | then the environment variables specified by the |
---|
408 | <CODE>pass_env</CODE> configuration or printcap option will be |
---|
409 | extracted from the environment, |
---|
410 | have any metacharacters removed, |
---|
411 | and then placed in the environment variable list. |
---|
412 | Commonly, the |
---|
413 | <CODE>PGPPASS</CODE>, |
---|
414 | <CODE>PGPPASSFD</CODE>, |
---|
415 | and <CODE>PGPPATH</CODE> are specified.</LI> |
---|
416 | <LI>The program is started, |
---|
417 | with STDIN, STDOUT, and STDERR attached to the appropriate files or |
---|
418 | file descriptors. |
---|
419 | If 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 |
---|
426 | them 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, |
---|
431 | most filters are either totally standalone (very rare), |
---|
432 | or require a set of support files. |
---|
433 | There are two types of support files: per print queue configuration information |
---|
434 | and global support information. |
---|
435 | <P>Since a print filter will execute with the current directory set to the |
---|
436 | spool queue directory, |
---|
437 | most filters expect that per print queue configuration information |
---|
438 | should be kept in the spool directory. |
---|
439 | Most <EM>vintage</EM> filters insist on having these files <EM>hidden</EM> |
---|
440 | with names such as <B><CODE>.setup</CODE></B>. |
---|
441 | This can make it difficult for administrators to determine where the |
---|
442 | configuration files are. |
---|
443 | <P>It is strongly recommended that filters and information |
---|
444 | be placed in commonly accessible directories such as |
---|
445 | <CODE><B>/usr/local/lib/filters</B></CODE>, |
---|
446 | and the executables in subdirectories. |
---|
447 | This allows the LPRng administrator to set the privileges on these |
---|
448 | directories such that only the <CODE>lpd</CODE> process can |
---|
449 | access them. |
---|
450 | <P>Most of the LPRng supported filters can either be used as a |
---|
451 | <CODE>if</CODE> or <CODE>of</CODE> filter. |
---|
452 | The filter will examine the format type passed by the <CODE>-F<EM>X</EM></CODE> |
---|
453 | command line argument, |
---|
454 | and if it is <CODE>o</CODE> it will perform as an <CODE>of</CODE> filter. |
---|
455 | <P>Alternatively, |
---|
456 | the filter will check the filename in the pathname by which is was invoked. |
---|
457 | If the name has the substring <CODE>of</CODE> in the filename, |
---|
458 | then it assumes it is to act as an <CODE>of</CODE> filter. |
---|
459 | This allows symbolic links to be made to a common filter executable, |
---|
460 | each of which corresponds to the filter name by which it is to be invoked. |
---|
461 | <P>When a filter is invoked, |
---|
462 | it is passed a large number of options, |
---|
463 | many of which are totally ignored in filter operation. |
---|
464 | However, |
---|
465 | for many purposes it is necessary to provide options to the |
---|
466 | filters to tailor their operation to the particular spool queue needs. |
---|
467 | <P>By convention, |
---|
468 | all 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, |
---|
480 | and has a very limited functionality. |
---|
481 | By default, |
---|
482 | it only translates <CODE>\n</CODE> to <CODE>\r\n</CODE> |
---|
483 | sequences, |
---|
484 | and 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-<em>version</em>.tgz</A><P>This filter supports a wide variety of <I>smart</I> printers, |
---|
494 | or to be more specific, |
---|
495 | printers 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>, |
---|
500 | you can have a parallel (unidirectional), |
---|
501 | serial (bidirectional), |
---|
502 | or network (bidirectional) connection. |
---|
503 | When using a bidirectional connection, |
---|
504 | you can sometime obtain or gratuitously receive error and/or status |
---|
505 | information from the printer. |
---|
506 | <P>Some printers will spontaneously generate error messages when printing |
---|
507 | a job on a bidirectional interface. |
---|
508 | Usually, though, |
---|
509 | it 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; |
---|
511 | some require special setup commands and some will <EM>autosense</EM> which |
---|
512 | type of job is being printed. |
---|
513 | <P>If you are printing text, |
---|
514 | and not using a Page Description Language like PostScript or PCL, |
---|
515 | then you may want to download a font to the printer. |
---|
516 | This is especially the case when you are trying to print text files |
---|
517 | in a non-English font. |
---|
518 | <P>Some printers will provide a <EM>hardware</EM> page counter value when requested; |
---|
519 | however, |
---|
520 | the means of requesting differ from model to model. |
---|
521 | <P>Sometimes you want to generate a special banner for a particular printer, |
---|
522 | and need to put in some dynamic information. |
---|
523 | While this can be done by the <CODE>lpd</CODE> server using the |
---|
524 | <CODE>bp</CODE> program specification, |
---|
525 | it turns out that non-LPRng systems which want to use the <CODE>ifhp</CODE> |
---|
526 | want to have the same facilities. |
---|
527 | Thus, you need to have some way to get the same effect as the <CODE>bp</CODE> |
---|
528 | option, but at the filter level. |
---|
529 | <P>Having done <CODE>lpd</CODE> banner generation and printing, |
---|
530 | why 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 |
---|
532 | making a general purpose filter to support all of these possibilities is |
---|
533 | difficult. |
---|
534 | That is incorrect. It is <B>extremely</B> difficult. |
---|
535 | <P>However, |
---|
536 | the <CODE>ifhp</CODE> filter greatly simplifies this, |
---|
537 | as it uses a simple database together with some printer configuration options. |
---|
538 | For details, |
---|
539 | see the <CODE>ifhp</CODE> documentation for details on using the filter. |
---|
540 | For the terminally impatient, |
---|
541 | the following is a quick cookbook: |
---|
542 | <BLOCKQUOTE><CODE> |
---|
543 | <PRE> |
---|
544 | # network connection to jet direct box, |
---|
545 | # no banners, HP compatible |
---|
546 | lp |
---|
547 | :lp=ipaddr%9100 |
---|
548 | :/usr/local/lib/filters/ifhp |
---|
549 | :sh:sf |
---|
550 | # |
---|
551 | # banner added |
---|
552 | # |
---|
553 | lp |
---|
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 | # |
---|
562 | lp |
---|
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 |
---|
572 | programs, you might want to keep them. Or, you might want to write a |
---|
573 | set of your own. |
---|
574 | <P>See the source code in the |
---|
575 | <A HREF="LPRng-HOWTO-1.html#secftp">LPRng Distribution, FILTERS_LPRng-<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> |
---|