File: opendevice.htm

package info (click to toggle)
lprng 3.8.10-1.2
  • links: PTS
  • area: main
  • in suites: woody
  • size: 13,076 kB
  • ctags: 4,348
  • sloc: ansic: 35,394; sh: 10,756; perl: 2,210; makefile: 1,046
file content (446 lines) | stat: -rw-r--r-- 16,433 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta name="generator" content="HTML Tidy, see www.w3.org">
    <title>Opening the Output Device&#13;</title>
    <meta name="GENERATOR" content=
    "Modular DocBook HTML Stylesheet Version 1.71 ">
    <link rel="HOME" title=" LPRng-HOWTO" href="index.htm">
    <link rel="UP" title="Job Processing" href="jobsteps.htm">
    <link rel="PREVIOUS" title="Spool Queue Processing " href=
    "spoolq.htm">
    <link rel="NEXT" title="Printing Banners " href=
    "bannerprinting.htm">
  </head>

  <body class="SECT1" bgcolor="#FFFFFF" text="#000000" link=
  "#0000FF" vlink="#840084" alink="#0000FF">
    <div class="NAVHEADER">
      <table summary="Header navigation table" width="100%" border=
      "0" cellpadding="0" cellspacing="0">
        <tr>
          <th colspan="3" align="center">LPRng-HOWTO: 1 Apr 2002
          (For LPRng-3.8.10)</th>
        </tr>

        <tr>
          <td width="10%" align="left" valign="bottom"><a href=
          "spoolq.htm" accesskey="P">Prev</a></td>

          <td width="80%" align="center" valign="bottom">Chapter
          15. Job Processing</td>

          <td width="10%" align="right" valign="bottom"><a href=
          "bannerprinting.htm" accesskey="N">Next</a></td>
        </tr>
      </table>
      <hr align="LEFT" width="100%">
    </div>

    <div class="SECT1">
      <h1 class="SECT1"><a name="OPENDEVICE">15.4. Opening the
      Output Device</a></h1>

      <p>Options used:</p>

      <ul>
        <li>
          <p><tt class="LITERAL">achk</tt> FLAG <i class=
          "EMPHASIS">Accounting check at start</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">af=</tt><i class=
          "EMPHASIS">Accounting File</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">ar</tt> FLAG <i class=
          "EMPHASIS">Remote printer accounting enabled</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">as=</tt><i class=
          "EMPHASIS">Accounting at start</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">connect_grace=</tt><i class=
          "EMPHASIS">Time between jobs</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">connect_interval=</tt><i class=
          "EMPHASIS">Connection interval</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">connect_timeout=</tt><i class=
          "EMPHASIS">Connection timeout</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">control_filter=</tt><i class=
          "EMPHASIS">Control file filter</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">ff=</tt><i class="EMPHASIS">form
          feed</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">fo</tt> FLAG <i class=
          "EMPHASIS">form feed on open</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">la</tt> FLAG <i class=
          "EMPHASIS">Local printer accounting enabled</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">ld=</tt><i class="EMPHASIS">leader
          on open (initialization string)</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">lk</tt> FLAG <i class=
          "EMPHASIS">Lock IO device</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">lp=</tt><i class="EMPHASIS">IO
          device pathname</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">nb</tt> FLAG <i class=
          "EMPHASIS">Nonblocking device open</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">network_connect_grace=</tt><i
          class="EMPHASIS">Interval in secs between jobs</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">of=</tt><i class="EMPHASIS">of
          filter</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">retry_econnrefused</tt> FLAG <i
          class="EMPHASIS">Retry if open failed</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">retry_nolink</tt> FLAG <i class=
          "EMPHASIS">Retry if open failed</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">rm=</tt><i class="EMPHASIS">the
          remote machine to send the job to</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">rp=</tt><i class="EMPHASIS">the
          remote print queue to send the job to</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">rw</tt> FLAG <i class=
          "EMPHASIS">device opened RW flag</i></p>
        </li>

        <li>
          <p><tt class="LITERAL">server_tmp_dir=</tt><i class=
          "EMPHASIS">temporary directory</i></p>
        </li>
      </ul>
      Sequence of Operations: 

      <ol type="1">
        <li>
          <p>During the server operations, it will try to create
          temporary files in the print queue spool directory. If
          this is not desirable, it will create them in the <tt
          class="LITERAL">server_tmp_dir</tt> directory.</p>
        </li>

        <li>
          <p>If the accounting file specified by <tt class=
          "LITERAL">af</tt> exists, it is opened (af_fd) and the
          af_fd is passed as file descriptor 3 to all filters. If
          the <tt class="LITERAL">af</tt> value has the form <tt
          class="LITERAL">af=|/program</tt> then the program is
          started and the program <span class=
          "ACRONYM">STDIN</span> is used as af_fd. If the <tt
          class="LITERAL">af</tt> value has the form <tt class=
          "LITERAL">af=host%port</tt>, then a TCP/IP connection to
          the corresponding port on the remote host is made and the
          port used as af_fd. In the latter two cases, the filter
          <span class="ACRONYM">STDIN</span> (file descriptor 0) is
          actually opened read/write, and is used when information
          is needed from the accounting filter or remote server.
          See <a href=
          "accountingref.htm#ACCOUNTINGSERVER">Accounting Printcap
          Options</a> for more information on the <b class=
          "APPLICATION">LPRng</b> accounting support.</p>
        </li>

        <li>
          <p><a name="ACCOUNTSTART"></a> If <tt class=
          "LITERAL">la</tt> (local accounting) is true and we are
          printing a job or <tt class="LITERAL">ar</tt> (remote
          accounting) is true and we are transferring a job, the
          <tt class="LITERAL">as</tt> value is examined. If it is a
          filter (program) specification, then the program is
          started with its <span class="ACRONYM">STDIN</span>
          attached to <tt class="FILENAME">/dev/null</tt>, <span
          class="ACRONYM">STDOUT</span> will be read by the print
          spooler, <span class="ACRONYM">STDERR</span> output will
          be written to the error log, and file descriptor 3 output
          will be appended to the accounting file. The lpd program
          will wait until the accounting filter program terminates,
          and examine the error code for action, as for the filters
          (see <a href="printingjob.htm#ERRORCODES">errorcodes</a>
          below). If the exit status is 0, (JSUCC) then the
          printing process will continue, if JHOLD the job will be
          held, if JREMOVE the job will be removed, if JFAIL the
          job processing will terminate with a JFAIL indication,
          otherwise the job processing will terminate with a JABORT
          indication.</p>
        </li>

        <li>
          <p>If the accounting filter exited with a JSUCC (no error
          code) and the <tt class="LITERAL">achk</tt> (accounting
          check) flag is set, the line read from the accounting
          filter <span class="ACRONYM">STDOUT</span> will be
          examined. This line should be <tt class=
          "LITERAL">accept</tt>, <tt class="LITERAL">hold</tt>, <tt
          class="LITERAL">fail</tt>, <tt class=
          "LITERAL">remove</tt>, otherwise the job processing
          terminates with a JABORT indication. An <tt class=
          "LITERAL">accept</tt> will allow the job to be printed,
          <tt class="LITERAL">hold</tt> will hold the job, <tt
          class="LITERAL">fail</tt> will cause the job to fail, <tt
          class="LITERAL">remove</tt> will cause the job to be
          removed.</p>
        </li>

        <li>
          <p>If the <tt class="LITERAL">connect_grace</tt> value is
          non-zero and the server is opening a device or <tt class=
          "LITERAL">network_connect_grace</tt> is non-zero and a
          network connection is being made, the server will pause
          the specified time. This is to accommodate devices which
          need a recovery time between jobs.</p>
        </li>

        <li>
          <p>The <tt class="LITERAL">lp</tt> option is checked to
          determine the type of IO device.</p>

          <div class="INFORMALTABLE">
            <a name="AEN7025"></a>

            <table border="1" class="CALSTABLE">
              <thead>
                <tr>
                  <th align="LEFT" valign="TOP">Format</th>

                  <th align="LEFT" valign="TOP">Meaning</th>
                </tr>
              </thead>

              <tbody>
                <tr>
                  <td align="LEFT" valign="TOP"><tt class=
                  "FILENAME">/pathname</tt></td>

                  <td align="LEFT" valign="TOP">Absolute pathname
                  of IO device</td>
                </tr>

                <tr>
                  <td align="LEFT" valign="TOP"><tt class=
                  "LITERAL">pr@host</tt></td>

                  <td align="LEFT" valign="TOP">transfer to <tt
                  class="LITERAL">pr</tt> on remote <tt class=
                  "LITERAL">host</tt></td>
                </tr>

                <tr>
                  <td align="LEFT" valign="TOP"><tt class=
                  "LITERAL">host%port</tt></td>

                  <td align="LEFT" valign="TOP">open a TCP/IP
                  connection to port on host. host can be name or
                  IP address</td>
                </tr>

                <tr>
                  <td align="LEFT" valign="TOP"><tt class=
                  "LITERAL">|filter</tt></td>

                  <td align="LEFT" valign="TOP">run the filter
                  program; it <span class="ACRONYM">STDIN</span>
                  will be used as device</td>
                </tr>
              </tbody>
            </table>
          </div>
          <br>
          <br>
        </li>

        <li>
          <p>The IO device specified by <tt class="LITERAL">lp</tt>
          is opened write-only or read-write if the <tt class=
          "LITERAL">rw</tt> flag is true, and the resulting file
          descriptor is io_fd. If the <tt class="LITERAL">nb</tt>
          flag is set, a non-blocking open will be done as well. If
          the <tt class="LITERAL">lk</tt> (lock device) flag is
          true, the device will be locked against use by other <b
          class="APPLICATION">lpd</b> servers.</p>
        </li>

        <li>
          <p>If a <tt class="LITERAL">host%port</tt> combination, a
          TCP/IP connection will be opened to the remote port and
          the connection will be used as io_fd.</p>
        </li>

        <li>
          <p>If a filter program is specified, the filter program
          will be run and the <span class="ACRONYM">STDIN</span> of
          the filter will be used as the device file
          descriptor.</p>
        </li>

        <li>
          <p>If a <tt class="LITERAL">rp@rm</tt> combination, or
          none of the above combinations are true and the <tt
          class="LITERAL">rm</tt> and <tt class="LITERAL">rp</tt>
          values are non-zero, then the job will be transferred to
          a remote printer. The type of operation will be a job
          transfer, rather than printing operation.</p>
        </li>

        <li>
          <p>If the <tt class="LITERAL">connect_timeout</tt> value
          is non-zero, a timeout is setup for the device or socket
          open. If the device or connection open does not succeed
          within the timeout, then the open operation fails.</p>
        </li>

        <li>
          <p>If a connection is to a network address (i.e. - <tt
          class="FUNCTION">connect()</tt> system call) and the
          connection attempt fails with an <span class=
          "ACRONYM">ECONNREFUSED</span> error, if the <tt class=
          "LITERAL">retry_econnrefused</tt> flag is set then the
          connection attempt is retried, but this time using an
          alternative port number. See <a href=
          "rfc1179ref.htm">RFC1179</a> for details. This is
          repeated until all of the possible originating port
          numbers are exhausted.</p>
        </li>

        <li>
          <p>If the open or connect operation fails, and the <tt
          class="LITERAL">retry_nolink</tt> flag is set, then the
          server will pause for a minimum of <tt class=
          "LITERAL">connect_grace</tt> plus a multiple of <tt
          class="LITERAL">connect_interval</tt> seconds based on
          the number of attempts before retrying the open
          operation. Note that the interval may increase as the
          number of attempts increases.</p>
        </li>

        <li>
          <p>If printing a job and the <tt class="LITERAL">:of</tt>
          filter is specified, it is created with its <span class=
          "ACRONYM">STDOUT</span> (fd 1) attached to the io_fd. Its
          stdin (of_fd) will be used in the steps listed below. If
          there is no <tt class="LITERAL">:of</tt> filter, then the
          of_fd value will be the io_fd descriptor.</p>
        </li>

        <li>
          <p>If transferring a job and the <tt class=
          "LITERAL">control_filter</tt> option is specified, then
          the program specified by the <tt class=
          "LITERAL">control_filter</tt> value will be run. It will
          have its <span class="ACRONYM">STDIN</span> set to the
          control file, and its <span class="ACRONYM">STDOUT</span>
          output will be used as the new value of the control file
          to transfer to the remote host. See <a href=
          "filteroptions.htm">Filter Command Line Options and
          Environment Variables</a> for details of options passed
          to the control filter, and <a href=
          "printingjob.htm#ERRORCODES">errorcodes</a> for the exit
          codes of the filter.</p>
        </li>

        <li>
          <p>If the operation is a job transfer, the operation
          proceeds as outlined in <a href=
          "rfc1179ref.htm">RFC1179</a>, and then the <a href=
          "normalterm.htm">Normal Termination</a> operations are
          carried out.</p>
        </li>

        <li>
          <p>If the operation is a print operation and the <tt
          class="LITERAL">ld</tt> (leader on open) value is
          provided, the string is translated (escapes removed) and
          written to the of_fd file descriptor.</p>
        </li>

        <li>
          <p>If the <tt class="LITERAL">fo</tt> (form feed on open)
          flag is true, then the <tt class="LITERAL">ff</tt> (form
          feed) string is translated (escapes removed) and written
          to the of_fd file descriptor.</p>
        </li>
      </ol>
      <br>
      <br>
    </div>

    <div class="NAVFOOTER">
      <hr align="LEFT" width="100%">

      <table summary="Footer navigation table" width="100%" border=
      "0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="33%" align="left" valign="top"><a href=
          "spoolq.htm" accesskey="P">Prev</a></td>

          <td width="34%" align="center" valign="top"><a href=
          "index.htm" accesskey="H">Home</a></td>

          <td width="33%" align="right" valign="top"><a href=
          "bannerprinting.htm" accesskey="N">Next</a></td>
        </tr>

        <tr>
          <td width="33%" align="left" valign="top">Spool Queue
          Processing</td>

          <td width="34%" align="center" valign="top"><a href=
          "jobsteps.htm" accesskey="U">Up</a></td>

          <td width="33%" align="right" valign="top">Printing
          Banners</td>
        </tr>
      </table>
    </div>
  </body>
</html>