mirror of
https://github.com/sheumann/hush.git
synced 2024-08-21 11:28:57 +00:00
lpr: add more accurate comments
*: trailing whitespace removal
This commit is contained in:
parent
39c77c3738
commit
42cc304e90
@ -136,7 +136,7 @@ int patch_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
src_stream = NULL;
|
src_stream = NULL;
|
||||||
|
|
||||||
if (backup_filename && !stat(original_filename, &saved_stat)) {
|
if (backup_filename && !stat(original_filename, &saved_stat)) {
|
||||||
src_stream = xfopen((strcmp(original_filename, new_filename)) ?
|
src_stream = xfopen((strcmp(original_filename, new_filename)) ?
|
||||||
original_filename : backup_filename, "r");
|
original_filename : backup_filename, "r");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1718,7 +1718,7 @@ static int find_range(char ** start, char ** stop, char c)
|
|||||||
p = t;
|
p = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
// backward char movements don't include start position
|
// backward char movements don't include start position
|
||||||
if (q > p && strchr("^0bBh\b\177", c)) q--;
|
if (q > p && strchr("^0bBh\b\177", c)) q--;
|
||||||
|
|
||||||
multiline = 0;
|
multiline = 0;
|
||||||
|
@ -14,7 +14,7 @@ typedef struct file_header_t {
|
|||||||
char *name;
|
char *name;
|
||||||
char *link_target;
|
char *link_target;
|
||||||
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
#if ENABLE_FEATURE_TAR_UNAME_GNAME
|
||||||
char *uname;
|
char *uname;
|
||||||
char *gname;
|
char *gname;
|
||||||
#endif
|
#endif
|
||||||
off_t size;
|
off_t size;
|
||||||
|
@ -67,7 +67,7 @@ int chrt_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
fflush_stdout_and_exit(EXIT_SUCCESS);
|
fflush_stdout_and_exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
argv += optind;
|
argv += optind;
|
||||||
if (opt & OPT_p) {
|
if (opt & OPT_p) {
|
||||||
pid_str = *argv++;
|
pid_str = *argv++;
|
||||||
if (*argv) { /* "-p <priority> <pid> [...]" */
|
if (*argv) { /* "-p <priority> <pid> [...]" */
|
||||||
|
@ -537,7 +537,7 @@ int sendgetmail_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
// NOTE: we don't use xatou(buf) since buf is "nmsg nbytes"
|
// NOTE: we don't use xatou(buf) since buf is "nmsg nbytes"
|
||||||
// we only need nmsg and atoi is just exactly what we need
|
// we only need nmsg and atoi is just exactly what we need
|
||||||
// if atoi fails to convert buf into number it returns 0
|
// if atoi fails to convert buf into number it returns 0
|
||||||
// in this case the following loop simply will not be executed
|
// in this case the following loop simply will not be executed
|
||||||
nmsg = atoi(buf);
|
nmsg = atoi(buf);
|
||||||
if (ENABLE_FEATURE_CLEAN_UP)
|
if (ENABLE_FEATURE_CLEAN_UP)
|
||||||
free(buf-4); // buf is "+OK " away from malloc'ed string
|
free(buf-4); // buf is "+OK " away from malloc'ed string
|
||||||
|
@ -10,37 +10,40 @@
|
|||||||
/*
|
/*
|
||||||
* A typical usage of BB lpd looks as follows:
|
* A typical usage of BB lpd looks as follows:
|
||||||
* # tcpsvd -E 0 515 lpd SPOOLDIR [HELPER-PROG [ARGS...]]
|
* # tcpsvd -E 0 515 lpd SPOOLDIR [HELPER-PROG [ARGS...]]
|
||||||
*
|
*
|
||||||
* This means a network listener is started on port 515 (default for LP protocol).
|
* This means a network listener is started on port 515 (default for LP protocol).
|
||||||
* When a client connection is made (via lpr) lpd first change its working directory to SPOOLDIR.
|
* When a client connection is made (via lpr) lpd first change its working directory to SPOOLDIR.
|
||||||
*
|
*
|
||||||
* SPOOLDIR is the spool directory which contains printing queues
|
* SPOOLDIR is the spool directory which contains printing queues
|
||||||
* and should have the following structure:
|
* and should have the following structure:
|
||||||
*
|
*
|
||||||
* SPOOLDIR/
|
* SPOOLDIR/
|
||||||
* <queue1>
|
* <queue1>
|
||||||
* ...
|
* ...
|
||||||
* <queueN>
|
* <queueN>
|
||||||
*
|
*
|
||||||
* <queueX> can be of two types:
|
* <queueX> can be of two types:
|
||||||
* A. a printer character device or an ordinary file a link to such;
|
* A. a printer character device or an ordinary file a link to such;
|
||||||
* B. a directory.
|
* B. a directory.
|
||||||
*
|
*
|
||||||
* In case A lpd just dumps the data it receives from client (lpr) to the
|
* In case A lpd just dumps the data it receives from client (lpr) to the
|
||||||
* end of queue file/device. This is non-spooling mode.
|
* end of queue file/device. This is non-spooling mode.
|
||||||
*
|
*
|
||||||
* In case B lpd enters spooling mode. It reliably saves client data along with control info
|
* In case B lpd enters spooling mode. It reliably saves client data along with control info
|
||||||
* in two unique files under the queue directory. These files are named dfAXXXHHHH and cfAXXXHHHH,
|
* in two unique files under the queue directory. These files are named dfAXXXHHHH and cfAXXXHHHH,
|
||||||
* where XXX is the job number and HHHH is the client hostname. Unless a printing helper application
|
* where XXX is the job number and HHHH is the client hostname. Unless a printing helper application
|
||||||
* is specified lpd is done at this point.
|
* is specified lpd is done at this point.
|
||||||
*
|
*
|
||||||
|
* NB: file names are produced by peer! They actually may be anything at all!
|
||||||
|
* lpd only sanitizes them (by removing most non-alphanumerics).
|
||||||
|
*
|
||||||
* If HELPER-PROG (with optional arguments) is specified then lpd continues to process client data:
|
* If HELPER-PROG (with optional arguments) is specified then lpd continues to process client data:
|
||||||
* 1. it reads and parses control file (cfA...). The parse process results in setting environment
|
* 1. it reads and parses control file (cfA...). The parse process results in setting environment
|
||||||
* variables whose values were passed in control file; when parsing is complete, lpd deletes
|
* variables whose values were passed in control file; when parsing is complete, lpd deletes
|
||||||
* control file.
|
* control file.
|
||||||
* 2. it spawns specified helper application. It is then the helper application who is responsible
|
* 2. it spawns specified helper application. It is then the helper application who is responsible
|
||||||
* for both actual printing and deleting processed data file.
|
* for both actual printing and deleting processed data file.
|
||||||
*
|
*
|
||||||
* A good lpr passes control files which when parsed provide the following variables:
|
* A good lpr passes control files which when parsed provide the following variables:
|
||||||
* $H = host which issues the job
|
* $H = host which issues the job
|
||||||
* $P = user who prints
|
* $P = user who prints
|
||||||
@ -49,13 +52,17 @@
|
|||||||
* $L = print banner page
|
* $L = print banner page
|
||||||
* $M = the user to whom a mail should be sent if a problem occurs
|
* $M = the user to whom a mail should be sent if a problem occurs
|
||||||
* $l = name of datafile ("dfAxxx") - file whose content are to be printed
|
* $l = name of datafile ("dfAxxx") - file whose content are to be printed
|
||||||
*
|
*
|
||||||
|
* lpd also provides $DATAFILE environment variable - the ACTUAL name
|
||||||
|
* of the datafile under which it was saved.
|
||||||
|
* $l is not reliable (you are at mercy of remote peer), DON'T USE IT.
|
||||||
|
*
|
||||||
* Thus, a typical helper can be something like this:
|
* Thus, a typical helper can be something like this:
|
||||||
* #!/bin/sh
|
* #!/bin/sh
|
||||||
* cat "$l" >/dev/lp0
|
* cat "$l" >/dev/lp0
|
||||||
* mv -f "$l" save/
|
* mv -f "$l" save/
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "libbb.h"
|
#include "libbb.h"
|
||||||
|
|
||||||
// strip argument of bad chars
|
// strip argument of bad chars
|
||||||
|
@ -49,7 +49,7 @@ int lpqr_main(int argc ATTRIBUTE_UNUSED, char *argv[])
|
|||||||
OPT_U = 1 << 1, // -U username
|
OPT_U = 1 << 1, // -U username
|
||||||
|
|
||||||
LPR_V = 1 << 2, // -V: be verbose
|
LPR_V = 1 << 2, // -V: be verbose
|
||||||
LPR_h = 1 << 3, // -h: want banner printed
|
LPR_h = 1 << 3, // -h: want banner printed
|
||||||
LPR_C = 1 << 4, // -C class: job "class" (? supposedly printed on banner)
|
LPR_C = 1 << 4, // -C class: job "class" (? supposedly printed on banner)
|
||||||
LPR_J = 1 << 5, // -J title: the job title for the banner page
|
LPR_J = 1 << 5, // -J title: the job title for the banner page
|
||||||
LPR_m = 1 << 6, // -m: send mail back to user
|
LPR_m = 1 << 6, // -m: send mail back to user
|
||||||
|
@ -2740,7 +2740,7 @@ static int forkexec(struct op *t, int *pin, int *pout, int no_fork, char **wp)
|
|||||||
// longjmps away (at "Run builtin" below), leaving t->op_words clobbered!
|
// longjmps away (at "Run builtin" below), leaving t->op_words clobbered!
|
||||||
// See http://bugs.busybox.net/view.php?id=846.
|
// See http://bugs.busybox.net/view.php?id=846.
|
||||||
// Now we do not touch t->op_words, but separately pass wp as param list
|
// Now we do not touch t->op_words, but separately pass wp as param list
|
||||||
// to builtins
|
// to builtins
|
||||||
DBGPRINTF(("FORKEXEC: bltin %p, no_fork %d, owp %p\n", bltin,
|
DBGPRINTF(("FORKEXEC: bltin %p, no_fork %d, owp %p\n", bltin,
|
||||||
no_fork, owp));
|
no_fork, owp));
|
||||||
/* Don't fork if it is a lone builtin (not in pipe)
|
/* Don't fork if it is a lone builtin (not in pipe)
|
||||||
|
@ -168,7 +168,7 @@ int script_main(int argc ATTRIBUTE_UNUSED, char **argv)
|
|||||||
/* child: make pty slave to be input, output, error; run shell */
|
/* child: make pty slave to be input, output, error; run shell */
|
||||||
close(pty); /* close pty master */
|
close(pty); /* close pty master */
|
||||||
/* open pty slave to fd 0,1,2 */
|
/* open pty slave to fd 0,1,2 */
|
||||||
close(0);
|
close(0);
|
||||||
xopen(pty_line, O_RDWR); /* uses fd 0 */
|
xopen(pty_line, O_RDWR); /* uses fd 0 */
|
||||||
xdup2(0, 1);
|
xdup2(0, 1);
|
||||||
xdup2(0, 2);
|
xdup2(0, 2);
|
||||||
|
@ -71,7 +71,7 @@ static void
|
|||||||
uuidcache_addentry(char *device, /*int major, int minor,*/ char *label, char *uuid)
|
uuidcache_addentry(char *device, /*int major, int minor,*/ char *label, char *uuid)
|
||||||
{
|
{
|
||||||
struct uuidCache_s *last;
|
struct uuidCache_s *last;
|
||||||
|
|
||||||
if (!uuidCache) {
|
if (!uuidCache) {
|
||||||
last = uuidCache = xzalloc(sizeof(*uuidCache));
|
last = uuidCache = xzalloc(sizeof(*uuidCache));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user