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 the status file, |
---|
36 | and file handle 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> |
---|
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 [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, |
---|
248 | and the second where a program is always expected. |
---|
249 | The following procedure is used to run a filter program. |
---|
250 | Arguments in single or double quotes are passed as a single value, |
---|
251 | as for a shell. |
---|
252 | No 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 |
---|
257 | program such as <CODE>lpr</CODE>, <CODE>lpc</CODE>, etc. |
---|
258 | If invoked from <CODE>lpd</CODE>, it is run as the |
---|
259 | <CODE>server_user</CODE> |
---|
260 | user |
---|
261 | (default <CODE>daemon</CODE>) configuration entry.</LI> |
---|
262 | <LI>The |
---|
263 | <EM>flags</EM> control how the program is to be run. |
---|
264 | The following flags are supported: |
---|
265 | <UL> |
---|
266 | <LI><B>ROOT</B> |
---|
267 | This opens a horrible security loophole, |
---|
268 | as it will run the program as ROOT. |
---|
269 | To enable this option, |
---|
270 | you must set various compilation flags, |
---|
271 | and perform other arcane operations. |
---|
272 | This is deliberately done to make administrators |
---|
273 | read the warnings and admonitions. |
---|
274 | <P>The alternative to ROOT is to have a setuid ROOT executable. |
---|
275 | Under NO circumstances should you run a shell script setuid ROOT, |
---|
276 | with general execute permissions on it. |
---|
277 | </LI> |
---|
278 | <LI><B>-$</B> |
---|
279 | This very odd looking flag is used to suppress the addition of |
---|
280 | additional command line arguments |
---|
281 | specified by the value of <CODE>filter_options</CODE> |
---|
282 | to the program command line.</LI> |
---|
283 | </UL> |
---|
284 | </LI> |
---|
285 | <LI>If the <B>-$</B> flag is not specified, |
---|
286 | the arguments determined by the value of the <CODE>bkf</CODE> |
---|
287 | (Berkeley LPD filter compatible flag) flag are added to the |
---|
288 | filter command line. |
---|
289 | If <CODE>bkf</CODE> is false the |
---|
290 | <CODE>filter_options</CODE> are added for OF filters and |
---|
291 | <CODE>of_filter_options</CODE> |
---|
292 | are added for non-OF filters; |
---|
293 | if it is true, then the |
---|
294 | <CODE>bk_filter_options</CODE> and <CODE>bk_of_filter_options</CODE> are added for |
---|
295 | OF and non-OF filters respectively. |
---|
296 | <P> |
---|
297 | <CENTER><TABLE BORDER><TR><TD> |
---|
298 | <BR> |
---|
299 | Option</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, |
---|
309 | for programs that are not being invoked as print job file filters, |
---|
310 | the |
---|
311 | <CODE>filter_options</CODE> |
---|
312 | arguments are added. |
---|
313 | For print job filters, if the <CODE>bkf</CODE> flag is set, |
---|
314 | then the |
---|
315 | <CODE>bk_filter_options</CODE> |
---|
316 | and |
---|
317 | <CODE>bk_of_filter_options</CODE> |
---|
318 | entries are used. |
---|
319 | The default <CODE>bk</CODE> filter options are the same as originally used |
---|
320 | with the BSD LPR filters. |
---|
321 | For the <CODE>of</CODE> filter, |
---|
322 | either the <CODE>of_filter_options</CODE> |
---|
323 | or <CODE>bk_of_filter_options</CODE> arguments will be added.</LI> |
---|
324 | <LI>The program arguments will then be scanned and interpreted. |
---|
325 | Arguments of the form <CODE>$</CODE><EM>letter</EM> will be |
---|
326 | translated into values from the |
---|
327 | print job control file and/or printcap entry. |
---|
328 | The letters have the following meaning: |
---|
329 | <CENTER><TABLE BORDER><TR><TD> |
---|
330 | <BR> |
---|
331 | Letter</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> |
---|
355 | Capital 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, |
---|
361 | then the argument is removed from the list. |
---|
362 | If there is a value, the actual form of the substitution is |
---|
363 | controlled by additional flags as follows. |
---|
364 | <CENTER><TABLE BORDER><TR><TD> |
---|
365 | <BR> |
---|
366 | Form</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, |
---|
375 | as in /bin/sh. |
---|
376 | The <CODE>$'x</CODE> does not quote the value. |
---|
377 | Combinations of the various flags are allowed. For example, |
---|
378 | <CODE>$-x</CODE> would simply substitute the value for <CODE>x</CODE>, |
---|
379 | and then pass the whitespace separated components as individual arguments. |
---|
380 | This last form is useful for adding in additional flags on the command line. |
---|
381 | </LI> |
---|
382 | <LI>The command line is parsed, |
---|
383 | metacharacters are ruthlessly stripped from all arguments and pathnames |
---|
384 | and replaced by <CODE>_</CODE> (underscores), |
---|
385 | and an argument list suitable for the <CODE>execve</CODE> system call |
---|
386 | is formed.</LI> |
---|
387 | <LI>A sanitized environment is set up for the program execution, |
---|
388 | with 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>, |
---|
410 | then the environment variables specified by the |
---|
411 | <CODE>pass_env</CODE> configuration or printcap option will be |
---|
412 | extracted from the environment, |
---|
413 | have any metacharacters removed, |
---|
414 | and then placed in the environment variable list. |
---|
415 | Commonly, the |
---|
416 | <CODE>PGPPASS</CODE>, |
---|
417 | <CODE>PGPPASSFD</CODE>, |
---|
418 | and <CODE>PGPPATH</CODE> are specified.</LI> |
---|
419 | <LI>The program is started, |
---|
420 | with STDIN, STDOUT, and STDERR attached to the appropriate files or |
---|
421 | file descriptors. |
---|
422 | If 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 |
---|
429 | them 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, |
---|
434 | most filters are either totally standalone (very rare), |
---|
435 | or require a set of support files. |
---|
436 | There are two types of support files: per print queue configuration information |
---|
437 | and global support information. |
---|
438 | <P>Since a print filter will execute with the current directory set to the |
---|
439 | spool queue directory, |
---|
440 | most filters expect that per print queue configuration information |
---|
441 | should be kept in the spool directory. |
---|
442 | Most <EM>vintage</EM> filters insist on having these files <EM>hidden</EM> |
---|
443 | with names such as <B><CODE>.setup</CODE></B>. |
---|
444 | This can make it difficult for administrators to determine where the |
---|
445 | configuration files are. |
---|
446 | <P>It is strongly recommended that filters and information |
---|
447 | be placed in commonly accessible directories such as |
---|
448 | <CODE><B>/usr/local/libexec/filters</B></CODE>, |
---|
449 | and the executables in subdirectories. |
---|
450 | This allows the LPRng administrator to set the privileges on these |
---|
451 | directories such that only the <CODE>lpd</CODE> process can |
---|
452 | access them. |
---|
453 | <P>Most of the LPRng supported filters can either be used as a |
---|
454 | <CODE>if</CODE> or <CODE>of</CODE> filter. |
---|
455 | The filter will examine the format type passed by the <CODE>-F<EM>X</EM></CODE> |
---|
456 | command line argument, |
---|
457 | and if it is <CODE>o</CODE> it will perform as an <CODE>of</CODE> filter. |
---|
458 | <P>Alternatively, |
---|
459 | the filter will check the filename in the pathname by which is was invoked. |
---|
460 | If the name has the substring <CODE>of</CODE> in the filename, |
---|
461 | then it assumes it is to act as an <CODE>of</CODE> filter. |
---|
462 | This allows symbolic links to be made to a common filter executable, |
---|
463 | each of which corresponds to the filter name by which it is to be invoked. |
---|
464 | <P>When a filter is invoked, |
---|
465 | it is passed a large number of options, |
---|
466 | many of which are totally ignored in filter operation. |
---|
467 | However, |
---|
468 | for many purposes it is necessary to provide options to the |
---|
469 | filters to tailor their operation to the particular spool queue needs. |
---|
470 | <P>By convention, |
---|
471 | all 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, |
---|
483 | and has a very limited functionality. |
---|
484 | By default, |
---|
485 | it only translates <CODE>\n</CODE> to <CODE>\r\n</CODE> |
---|
486 | sequences, |
---|
487 | and 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-<em>version</em>.tgz</A><P>This filter supports a wide variety of <I>smart</I> printers, |
---|
497 | or to be more specific, |
---|
498 | printers 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>, |
---|
501 | you can have a parallel (unidirectional), |
---|
502 | serial (bidirectional), |
---|
503 | or network (bidirectional) connection. |
---|
504 | When using a bidirectional connection, |
---|
505 | you can sometime obtain or gratuitously receive error and/or status |
---|
506 | information from the printer. |
---|
507 | <P>Some printers will spontaneously generate error messages when printing |
---|
508 | a job on a bidirectional interface. |
---|
509 | Usually, though, |
---|
510 | it 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; |
---|
512 | some require special setup commands and some will <EM>autosense</EM> which |
---|
513 | type of job is being printed. |
---|
514 | <P>If you are printing text, |
---|
515 | and not using a Page Description Language like PostScript or PCL, |
---|
516 | then you may want to download a font to the printer. |
---|
517 | This is especially the case when you are trying to print text files |
---|
518 | in a non-English font. |
---|
519 | <P>Some printers will provide a <EM>hardware</EM> page counter value when requested; |
---|
520 | however, |
---|
521 | the means of requesting differ from model to model. |
---|
522 | <P>Sometimes you want to generate a special banner for a particular printer, |
---|
523 | and need to put in some dynamic information. |
---|
524 | While this can be done by the <CODE>lpd</CODE> server using the |
---|
525 | <CODE>bp</CODE> program specification, |
---|
526 | it turns out that non-LPRng systems which want to use the <CODE>ifhp</CODE> |
---|
527 | want to have the same facilities. |
---|
528 | Thus, you need to have some way to get the same effect as the <CODE>bp</CODE> |
---|
529 | option, but at the filter level. |
---|
530 | <P>Having done <CODE>lpd</CODE> banner generation and printing, |
---|
531 | why 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 |
---|
533 | making a general purpose filter to support all of these possibilities is |
---|
534 | difficult. |
---|
535 | That is incorrect. It is <B>extremely</B> difficult. |
---|
536 | <P>However, |
---|
537 | the <CODE>ifhp</CODE> filter greatly simplifies this, |
---|
538 | as it uses a simple database together with some printer configuration options. |
---|
539 | For details, |
---|
540 | see the <CODE>ifhp</CODE> documentation for details on using the filter. |
---|
541 | For the terminally impatient, |
---|
542 | the following is a quick cookbook: |
---|
543 | <BLOCKQUOTE><CODE> |
---|
544 | <PRE> |
---|
545 | # network connection to jet direct box, |
---|
546 | # no banners, HP compatible |
---|
547 | lp |
---|
548 | :lp=ipaddr%9100 |
---|
549 | :/usr/local/libexec/filters/ifhp |
---|
550 | :sh:sf |
---|
551 | # |
---|
552 | # banner added |
---|
553 | # |
---|
554 | lp |
---|
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 | # |
---|
563 | lp |
---|
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 |
---|
573 | programs, you might want to keep them. Or, you might want to write a |
---|
574 | set of your own. |
---|
575 | <P>See the source code in the |
---|
576 | <A HREF="LPRng-HOWTO-1.html#secftp">LPRng Distribution, FILTERS_LPRng-<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> |
---|