aboutsummaryrefslogtreecommitdiff
path: root/printutils
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-03-24 02:05:58 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-03-24 02:05:58 +0000
commit42cc304e9084843ad6b153afaf4b3f6c6528c364 (patch)
tree51d7cc0dfcd554658d980b9628180e39512f9b1b /printutils
parent39c77c37384f87075ad578855f0a11ecbf0681f3 (diff)
downloadbusybox-w32-42cc304e9084843ad6b153afaf4b3f6c6528c364.tar.gz
busybox-w32-42cc304e9084843ad6b153afaf4b3f6c6528c364.tar.bz2
busybox-w32-42cc304e9084843ad6b153afaf4b3f6c6528c364.zip
lpr: add more accurate comments
*: trailing whitespace removal
Diffstat (limited to 'printutils')
-rw-r--r--printutils/lpd.c45
-rw-r--r--printutils/lpr.c2
2 files changed, 27 insertions, 20 deletions
diff --git a/printutils/lpd.c b/printutils/lpd.c
index cac881383..bc0348eba 100644
--- a/printutils/lpd.c
+++ b/printutils/lpd.c
@@ -10,37 +10,40 @@
10/* 10/*
11 * A typical usage of BB lpd looks as follows: 11 * A typical usage of BB lpd looks as follows:
12 * # tcpsvd -E 0 515 lpd SPOOLDIR [HELPER-PROG [ARGS...]] 12 * # tcpsvd -E 0 515 lpd SPOOLDIR [HELPER-PROG [ARGS...]]
13 * 13 *
14 * This means a network listener is started on port 515 (default for LP protocol). 14 * This means a network listener is started on port 515 (default for LP protocol).
15 * When a client connection is made (via lpr) lpd first change its working directory to SPOOLDIR. 15 * When a client connection is made (via lpr) lpd first change its working directory to SPOOLDIR.
16 * 16 *
17 * SPOOLDIR is the spool directory which contains printing queues 17 * SPOOLDIR is the spool directory which contains printing queues
18 * and should have the following structure: 18 * and should have the following structure:
19 * 19 *
20 * SPOOLDIR/ 20 * SPOOLDIR/
21 * <queue1> 21 * <queue1>
22 * ... 22 * ...
23 * <queueN> 23 * <queueN>
24 * 24 *
25 * <queueX> can be of two types: 25 * <queueX> can be of two types:
26 * A. a printer character device or an ordinary file a link to such; 26 * A. a printer character device or an ordinary file a link to such;
27 * B. a directory. 27 * B. a directory.
28 * 28 *
29 * In case A lpd just dumps the data it receives from client (lpr) to the 29 * In case A lpd just dumps the data it receives from client (lpr) to the
30 * end of queue file/device. This is non-spooling mode. 30 * end of queue file/device. This is non-spooling mode.
31 * 31 *
32 * In case B lpd enters spooling mode. It reliably saves client data along with control info 32 * In case B lpd enters spooling mode. It reliably saves client data along with control info
33 * in two unique files under the queue directory. These files are named dfAXXXHHHH and cfAXXXHHHH, 33 * in two unique files under the queue directory. These files are named dfAXXXHHHH and cfAXXXHHHH,
34 * where XXX is the job number and HHHH is the client hostname. Unless a printing helper application 34 * where XXX is the job number and HHHH is the client hostname. Unless a printing helper application
35 * is specified lpd is done at this point. 35 * is specified lpd is done at this point.
36 * 36 *
37 * NB: file names are produced by peer! They actually may be anything at all!
38 * lpd only sanitizes them (by removing most non-alphanumerics).
39 *
37 * If HELPER-PROG (with optional arguments) is specified then lpd continues to process client data: 40 * If HELPER-PROG (with optional arguments) is specified then lpd continues to process client data:
38 * 1. it reads and parses control file (cfA...). The parse process results in setting environment 41 * 1. it reads and parses control file (cfA...). The parse process results in setting environment
39 * variables whose values were passed in control file; when parsing is complete, lpd deletes 42 * variables whose values were passed in control file; when parsing is complete, lpd deletes
40 * control file. 43 * control file.
41 * 2. it spawns specified helper application. It is then the helper application who is responsible 44 * 2. it spawns specified helper application. It is then the helper application who is responsible
42 * for both actual printing and deleting processed data file. 45 * for both actual printing and deleting processed data file.
43 * 46 *
44 * A good lpr passes control files which when parsed provide the following variables: 47 * A good lpr passes control files which when parsed provide the following variables:
45 * $H = host which issues the job 48 * $H = host which issues the job
46 * $P = user who prints 49 * $P = user who prints
@@ -49,13 +52,17 @@
49 * $L = print banner page 52 * $L = print banner page
50 * $M = the user to whom a mail should be sent if a problem occurs 53 * $M = the user to whom a mail should be sent if a problem occurs
51 * $l = name of datafile ("dfAxxx") - file whose content are to be printed 54 * $l = name of datafile ("dfAxxx") - file whose content are to be printed
52 * 55 *
56 * lpd also provides $DATAFILE environment variable - the ACTUAL name
57 * of the datafile under which it was saved.
58 * $l is not reliable (you are at mercy of remote peer), DON'T USE IT.
59 *
53 * Thus, a typical helper can be something like this: 60 * Thus, a typical helper can be something like this:
54 * #!/bin/sh 61 * #!/bin/sh
55 * cat "$l" >/dev/lp0 62 * cat "$l" >/dev/lp0
56 * mv -f "$l" save/ 63 * mv -f "$l" save/
57 *
58 */ 64 */
65
59#include "libbb.h" 66#include "libbb.h"
60 67
61// strip argument of bad chars 68// strip argument of bad chars
diff --git a/printutils/lpr.c b/printutils/lpr.c
index 5313d5a20..d0bf5873e 100644
--- a/printutils/lpr.c
+++ b/printutils/lpr.c
@@ -49,7 +49,7 @@ int lpqr_main(int argc ATTRIBUTE_UNUSED, char *argv[])
49 OPT_U = 1 << 1, // -U username 49 OPT_U = 1 << 1, // -U username
50 50
51 LPR_V = 1 << 2, // -V: be verbose 51 LPR_V = 1 << 2, // -V: be verbose
52 LPR_h = 1 << 3, // -h: want banner printed 52 LPR_h = 1 << 3, // -h: want banner printed
53 LPR_C = 1 << 4, // -C class: job "class" (? supposedly printed on banner) 53 LPR_C = 1 << 4, // -C class: job "class" (? supposedly printed on banner)
54 LPR_J = 1 << 5, // -J title: the job title for the banner page 54 LPR_J = 1 << 5, // -J title: the job title for the banner page
55 LPR_m = 1 << 6, // -m: send mail back to user 55 LPR_m = 1 << 6, // -m: send mail back to user