summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilippe Charnier <charnier@FreeBSD.org>1997-09-25 06:33:17 +0000
committerPhilippe Charnier <charnier@FreeBSD.org>1997-09-25 06:33:17 +0000
commitdffc6f5a6ca463fb057e48f6b92a35a3d26f7746 (patch)
tree8c8c8eb319cd05b7236dd939a91d13309cf69e95
parenta888b1470bdc94d5d792b903adb8f5827d2270da (diff)
Notes
-rw-r--r--usr.sbin/lpr/common_source/rmjob.c4
-rw-r--r--usr.sbin/lpr/common_source/startdaemon.c23
-rw-r--r--usr.sbin/lpr/lp/lp.127
-rw-r--r--usr.sbin/lpr/lpc/lpc.86
-rw-r--r--usr.sbin/lpr/lpc/lpc.c27
-rw-r--r--usr.sbin/lpr/lpd/lpd.84
-rw-r--r--usr.sbin/lpr/lpd/lpd.c11
-rw-r--r--usr.sbin/lpr/lpd/recvjob.c12
-rw-r--r--usr.sbin/lpr/lpq/lpq.16
-rw-r--r--usr.sbin/lpr/lpq/lpq.c13
-rw-r--r--usr.sbin/lpr/lpr/lpr.18
-rw-r--r--usr.sbin/lpr/lpr/lpr.c15
-rw-r--r--usr.sbin/lpr/lprm/lprm.114
-rw-r--r--usr.sbin/lpr/lprm/lprm.c10
-rw-r--r--usr.sbin/lpr/pac/pac.84
-rw-r--r--usr.sbin/lpr/pac/pac.c31
16 files changed, 118 insertions, 97 deletions
diff --git a/usr.sbin/lpr/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c
index c44f1726c361..32e13d4add2d 100644
--- a/usr.sbin/lpr/common_source/rmjob.c
+++ b/usr.sbin/lpr/common_source/rmjob.c
@@ -32,7 +32,11 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)rmjob.c 8.2 (Berkeley) 4/28/95";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
diff --git a/usr.sbin/lpr/common_source/startdaemon.c b/usr.sbin/lpr/common_source/startdaemon.c
index ca24c82e35c6..7f990b4d4760 100644
--- a/usr.sbin/lpr/common_source/startdaemon.c
+++ b/usr.sbin/lpr/common_source/startdaemon.c
@@ -32,7 +32,11 @@
*/
#ifndef lint
+#if 0
static char sccsid[] = "@(#)startdaemon.c 8.2 (Berkeley) 4/17/94";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
@@ -41,17 +45,15 @@ static char sccsid[] = "@(#)startdaemon.c 8.2 (Berkeley) 4/17/94";
#include <sys/un.h>
#include <dirent.h>
-#include <errno.h>
+#include <err.h>
#include <stdio.h>
-#include <unistd.h>
#include <string.h>
+#include <unistd.h>
#include "lp.h"
#include "pathnames.h"
extern uid_t uid, euid;
-static void perr __P((char *));
-
/*
* Tell the printer daemon that there are new files in the spool directory.
*/
@@ -66,7 +68,7 @@ startdaemon(printer)
s = socket(AF_UNIX, SOCK_STREAM, 0);
if (s < 0) {
- perr("socket");
+ warn("socket");
return(0);
}
memset(&un, 0, sizeof(un));
@@ -78,7 +80,7 @@ startdaemon(printer)
seteuid(euid);
if (connect(s, (struct sockaddr *)&un, SUN_LEN(&un)) < 0) {
seteuid(uid);
- perr("connect");
+ warn("connect");
(void) close(s);
return(0);
}
@@ -89,7 +91,7 @@ startdaemon(printer)
}
n = strlen(buf);
if (write(s, buf, n) != n) {
- perr("write");
+ warn("write");
(void) close(s);
return(0);
}
@@ -105,10 +107,3 @@ startdaemon(printer)
(void) close(s);
return(0);
}
-
-static void
-perr(msg)
- char *msg;
-{
- (void)printf("%s: %s: %s\n", name, msg, strerror(errno));
-}
diff --git a/usr.sbin/lpr/lp/lp.1 b/usr.sbin/lpr/lp/lp.1
index e3adae6c10f5..54e3c3a59f3c 100644
--- a/usr.sbin/lpr/lp/lp.1
+++ b/usr.sbin/lpr/lp/lp.1
@@ -31,7 +31,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $Id: lp.1,v 1.2 1996/05/11 18:56:09 joerg Exp $
+.\" $Id: lp.1,v 1.2.2.1 1997/09/19 06:18:19 charnier Exp $
.\"
.Dd January 22, 1995
.Dt LP 1
@@ -42,7 +42,7 @@
.Sh SYNOPSIS
.Nm lp
.Op Fl c
-.Op Fl d printer
+.Op Fl d Ar printer
.Op Fl n Ar num
.Op Ar name ...
.Sh DESCRIPTION
@@ -55,17 +55,16 @@ with the proper set of arguments.
It generally prints the named files on the destination printer.
.Pp
-Option
-.Fl c
-makes the
+The following options are available:
+.Bl -tag -width indent
+.It Fl c
+Make the
.Nm
command exit only after further access to any of the input files is no
longer required. The application can then safely delete or modify the
files without affecting the output operation.
-
-To specify a particular printer, option
-.Fl d Ar dest
-can be used. If no
+.It Fl d Ar dest
+Specify a particular printer. If no
.Fl d
is provided on the command line, the contents of the environment
variables
@@ -74,13 +73,11 @@ or
.Ev PRINTER
.Pq with this precedence
are taken as the destination printer.
-
-Option
-.Fl n Ar num
-can be used to specify that
+.It Fl n Ar num
+Specify that
.Ar num
copies of each of the named files shall be printed.
-
+.El
.Sh ENVIRONMENT
As described above, the variables
.Ev LPDEST
@@ -92,7 +89,7 @@ are examined to select the destination printer.
.Xr lpr 1
.Sh STANDARDS
The
-.Nm lp
+.Nm
command is expected to comply with the
.St -p1003.2
specification.
diff --git a/usr.sbin/lpr/lpc/lpc.8 b/usr.sbin/lpr/lpc/lpc.8
index ce0f451fee2e..b3a0c52ee051 100644
--- a/usr.sbin/lpr/lpc/lpc.8
+++ b/usr.sbin/lpr/lpc/lpc.8
@@ -64,14 +64,14 @@ spooling queues and printer daemons.
.El
.Pp
Without any arguments,
-.Nm lpc
+.Nm
will prompt for commands from the standard input.
If arguments are supplied,
-.Nm lpc
+.Nm
interprets the first argument as a command and the remaining
arguments as parameters to the command. The standard input
may be redirected causing
-.Nm lpc
+.Nm
to read commands from file.
Commands may be abbreviated;
the following is the list of recognized commands.
diff --git a/usr.sbin/lpr/lpc/lpc.c b/usr.sbin/lpr/lpc/lpc.c
index 353d7cb88c22..bb07d46ecf33 100644
--- a/usr.sbin/lpr/lpc/lpc.c
+++ b/usr.sbin/lpr/lpc/lpc.c
@@ -33,27 +33,31 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)lpc.c 8.3 (Berkeley) 4/28/95";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
#include <sys/param.h>
+#include <ctype.h>
#include <dirent.h>
-#include <signal.h>
+#include <grp.h>
#include <setjmp.h>
-#include <syslog.h>
-#include <unistd.h>
-#include <stdlib.h>
+#include <signal.h>
#include <stdio.h>
-#include <ctype.h>
+#include <stdlib.h>
+#include <syslog.h>
#include <string.h>
-#include <grp.h>
+#include <unistd.h>
#include <sys/param.h>
#include "lp.h"
#include "lpc.h"
@@ -304,14 +308,11 @@ ingroup(grname)
if (gptr == NULL) {
if ((gptr = getgrnam(grname)) == NULL) {
- fprintf(stderr, "Warning: unknown group '%s'\n",
- grname);
+ warnx("warning: unknown group '%s'", grname);
return(0);
}
- if (getgroups(NGROUPS, groups) < 0) {
- perror("getgroups");
- exit(1);
- }
+ if (getgroups(NGROUPS, groups) < 0)
+ err(1, "getgroups");
}
gid = gptr->gr_gid;
for (i = 0; i < NGROUPS; i++)
diff --git a/usr.sbin/lpr/lpd/lpd.8 b/usr.sbin/lpr/lpd/lpd.8
index 3b6d768796c1..2323f40eccb1 100644
--- a/usr.sbin/lpr/lpd/lpd.8
+++ b/usr.sbin/lpr/lpd/lpd.8
@@ -69,7 +69,7 @@ on the Internet listening socket (see
The
.Fl l
flag causes
-.Nm lpd
+.Nm
to log valid requests received from the network. This can be useful
for debugging purposes.
.It Ar "port#"
@@ -214,7 +214,7 @@ and contains two lines.
The first is the process id of the daemon and the second is the control
file name of the current job being printed. The second line is updated to
reflect the current status of
-.Nm lpd
+.Nm
for the programs
.Xr lpq 1
and
diff --git a/usr.sbin/lpr/lpd/lpd.c b/usr.sbin/lpr/lpd/lpd.c
index 7fc8a8f4e5eb..e62e6bf7d48a 100644
--- a/usr.sbin/lpr/lpd/lpd.c
+++ b/usr.sbin/lpr/lpd/lpd.c
@@ -33,13 +33,17 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1993, 1994\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)lpd.c 8.7 (Berkeley) 5/10/95";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
/*
@@ -603,8 +607,9 @@ again:
/*NOTREACHED*/
}
-void
+static void
usage()
{
- errx(EX_USAGE, "usage: lpd [-dl] [port#]");
+ fprintf(stderr, "usage: lpd [-dl] [port#]\n");
+ exit(EX_USAGE);
}
diff --git a/usr.sbin/lpr/lpd/recvjob.c b/usr.sbin/lpr/lpd/recvjob.c
index 6ed50c3a7637..192d993bff3f 100644
--- a/usr.sbin/lpr/lpd/recvjob.c
+++ b/usr.sbin/lpr/lpd/recvjob.c
@@ -33,13 +33,17 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)recvjob.c 8.2 (Berkeley) 4/27/95";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
/*
@@ -146,7 +150,7 @@ readjob()
do {
if ((size = read(1, cp, 1)) != 1) {
if (size < 0)
- frecverr("%s: Lost connection",
+ frecverr("%s: lost connection",
printer);
return(nfiles);
}
@@ -243,7 +247,7 @@ readfile(file, size)
do {
j = read(1, cp, amt);
if (j <= 0)
- frecverr("Lost connection");
+ frecverr("lost connection");
amt -= j;
cp += j;
} while (amt > 0);
@@ -272,7 +276,7 @@ noresponse()
char resp;
if (read(1, &resp, 1) != 1)
- frecverr("Lost connection");
+ frecverr("lost connection");
if (resp == '\0')
return(0);
return(1);
diff --git a/usr.sbin/lpr/lpq/lpq.1 b/usr.sbin/lpr/lpq/lpq.1
index 200f60d7fe1f..04ecdadab6e6 100644
--- a/usr.sbin/lpr/lpq/lpq.1
+++ b/usr.sbin/lpr/lpq/lpq.1
@@ -75,7 +75,7 @@ rather than just the specified printer.
.Pp
For each job submitted (i.e. invocation of
.Xr lpr 1 )
-.Nm lpq
+.Nm
reports the user's name, current rank in the queue, the
names of files comprising the job, the job identifier (a number which
may be supplied to
@@ -93,7 +93,7 @@ is used as a sink in a pipeline) in which case the file
is indicated as ``(standard input)''.
.Pp
If
-.Nm lpq
+.Nm
warns that there is no daemon present (i.e. due to some malfunction),
the
.Xr lpc 8
@@ -127,7 +127,7 @@ appeared in
.Bx 3 .
.Sh BUGS
Due to the dynamic nature of the information in the spooling directory
-.Nm lpq
+.Nm
may report unreliably.
Output formatting is sensitive to the line length of the terminal;
this can results in widely spaced columns.
diff --git a/usr.sbin/lpr/lpq/lpq.c b/usr.sbin/lpr/lpq/lpq.c
index c680f9222cfd..4034ecbdf692 100644
--- a/usr.sbin/lpr/lpq/lpq.c
+++ b/usr.sbin/lpr/lpq/lpq.c
@@ -72,7 +72,7 @@ int users; /* # of users in user array */
uid_t uid, euid;
static int ckqueue __P((char *));
-void usage __P((void));
+static void usage __P((void));
int
main(argc, argv)
@@ -88,10 +88,8 @@ main(argc, argv)
uid = getuid();
seteuid(uid);
name = *argv;
- if (gethostname(host, sizeof(host))) {
- perror("lpq: gethostname");
- exit(1);
- }
+ if (gethostname(host, sizeof(host)))
+ err(1, "gethostname");
openlog("lpd", 0, LOG_LPR);
aflag = lflag = 0;
@@ -170,9 +168,10 @@ ckqueue(cap)
return (0);
}
-void
+static void
usage()
{
- puts("usage: lpq [-a] [-l] [-Pprinter] [user ...] [job ...]");
+ fprintf(stderr,
+ "usage: lpq [-a] [-l] [-Pprinter] [user ...] [job ...]\n");
exit(1);
}
diff --git a/usr.sbin/lpr/lpr/lpr.1 b/usr.sbin/lpr/lpr/lpr.1
index a1d34e56d0d0..554a4dac1a9e 100644
--- a/usr.sbin/lpr/lpr/lpr.1
+++ b/usr.sbin/lpr/lpr/lpr.1
@@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" From @(#)lpr.1 8.1 (Berkeley) 6/6/93
-.\" $Id$
+.\" $Id: lpr.1,v 1.5 1996/05/11 19:00:54 joerg Exp $
.\" "
.Dd June 6, 1993
.Dt LPR 1
@@ -226,7 +226,7 @@ Temporary copies of "cf" files.
.Xr lpd 8
.Sh HISTORY
The
-.Nm lpr
+.Nm
command appeared in
.Bx 3 .
.Sh DIAGNOSTICS
@@ -234,12 +234,12 @@ If you try to spool too large a file, it will be truncated.
.Nm Lpr
will object to printing binary files.
If a user other than root prints a file and spooling is disabled,
-.Nm lpr
+.Nm
will print a message saying so and will not put jobs in the queue.
If a connection to
.Xr lpd 8
on the local machine cannot be made,
-.Nm lpr
+.Nm
will say that the daemon cannot be started.
Diagnostics may be printed in the daemon's log file
regarding missing spool files by
diff --git a/usr.sbin/lpr/lpr/lpr.c b/usr.sbin/lpr/lpr/lpr.c
index 26140fe40fb2..db695e334e50 100644
--- a/usr.sbin/lpr/lpr/lpr.c
+++ b/usr.sbin/lpr/lpr/lpr.c
@@ -38,14 +38,17 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1989, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
-static char sccsid[] = "From: @(#)lpr.c 8.4 (Berkeley) 4/28/95"
- "\n$Id: lpr.c,v 1.10.2.3 1997/07/08 21:07:21 dima Exp $\n";
+#if 0
+static char sccsid[] = "@(#)from: lpr.c 8.4 (Berkeley) 4/28/95";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
/*
@@ -695,9 +698,9 @@ chkprinter(s)
static void
usage()
{
- fprintf(stderr,
-"usage: lpr [-Pprinter] [-#num] [-C class] [-J job] [-T title] [-U user]\n"
-"[-i[numcols]] [-1234 font] [-wnum] [-cdfghlnmprstv] [name ...]\n");
+ fprintf(stderr, "%s\n%s\n",
+"usage: lpr [-Pprinter] [-#num] [-C class] [-J job] [-T title] [-U user]",
+"[-i[numcols]] [-1234 font] [-wnum] [-cdfghlnmprstv] [name ...]");
exit(1);
}
diff --git a/usr.sbin/lpr/lprm/lprm.1 b/usr.sbin/lpr/lprm/lprm.1
index a4c46594fc1e..02da03461b72 100644
--- a/usr.sbin/lpr/lprm/lprm.1
+++ b/usr.sbin/lpr/lprm/lprm.1
@@ -47,7 +47,7 @@
.Nm Lprm
will remove a job, or jobs, from a printer's spool queue.
Since the spooling directory is protected from users, using
-.Nm lprm
+.Nm
is normally the only method by which a user may remove a job.
The owner of a job is determined by the user's login name
and host name on the machine where the
@@ -64,16 +64,16 @@ Specify the queue associated with a specific
If a single
.Sq Fl
is given,
-.Nm lprm
+.Nm
will remove all jobs which a user
owns. If the super-user employs this flag, the spool queue will
be emptied entirely.
.It Ar user
-Causes
-.Nm lprm
+Cause
+.Nm
to attempt to remove any jobs queued belonging to that user
(or users). This form of invoking
-.Nm lprm
+.Nm
is useful only to the super-user.
.It Ar job\ \&#
A user may dequeue an individual job by specifying its job number.
@@ -91,7 +91,7 @@ program, e.g.
.El
.Pp
If neither arguments or options are given,
-.Nm Lprm
+.Nm
will delete the currently active job if it is
owned by the user who invoked
.Nm lprm .
@@ -140,6 +140,6 @@ Since there are race conditions possible in the update of the lock file,
the currently active job may be incorrectly identified.
.Sh HISTORY
The
-.Nm lprm
+.Nm
command appeared in
.Bx 3.0 .
diff --git a/usr.sbin/lpr/lprm/lprm.c b/usr.sbin/lpr/lprm/lprm.c
index df3a6cb3b042..e124744a7ce7 100644
--- a/usr.sbin/lpr/lprm/lprm.c
+++ b/usr.sbin/lpr/lprm/lprm.c
@@ -33,13 +33,17 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)lprm.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
/*
@@ -78,7 +82,7 @@ uid_t uid, euid; /* real and effective user id's */
static char luser[16]; /* buffer for person */
-void usage __P((void));
+static void usage __P((void));
int
main(argc, argv)
@@ -140,7 +144,7 @@ main(argc, argv)
exit(0);
}
-void
+static void
usage()
{
fprintf(stderr, "usage: lprm [-] [-Pprinter] [[job #] [user] ...]\n");
diff --git a/usr.sbin/lpr/pac/pac.8 b/usr.sbin/lpr/pac/pac.8
index 6e7ffc0b765d..433cfe45d8d0 100644
--- a/usr.sbin/lpr/pac/pac.8
+++ b/usr.sbin/lpr/pac/pac.8
@@ -62,10 +62,10 @@ the value of the environment variable
.Ev PRINTER
is used.
.It Fl c
-flag causes the output to be sorted by cost; usually the
+Cause the output to be sorted by cost; usually the
output is sorted alphabetically by name.
.It Fl m
-flag causes the host name to be ignored in the accounting file. This
+Cause the host name to be ignored in the accounting file. This
allows for a user on multiple machines to have all of his printing
charges grouped together.
.It Fl p Ns Ar price
diff --git a/usr.sbin/lpr/pac/pac.c b/usr.sbin/lpr/pac/pac.c
index 980696552864..c89a52696d95 100644
--- a/usr.sbin/lpr/pac/pac.c
+++ b/usr.sbin/lpr/pac/pac.c
@@ -33,13 +33,17 @@
*/
#ifndef lint
-static char copyright[] =
+static const char copyright[] =
"@(#) Copyright (c) 1983, 1993\n\
The Regents of the University of California. All rights reserved.\n";
#endif /* not lint */
#ifndef lint
+#if 0
static char sccsid[] = "@(#)pac.c 8.1 (Berkeley) 6/6/93";
+#endif
+static const char rcsid[] =
+ "$Id$";
#endif /* not lint */
/*
@@ -99,6 +103,7 @@ static struct hent *enter __P((char []));
static struct hent *lookup __P((char []));
static int qucmp __P((const void *, const void *));
static void rewrite __P((void));
+static void usage __P((void));
int
main(argc, argv)
@@ -158,9 +163,7 @@ main(argc, argv)
continue;
default:
-fprintf(stderr,
- "usage: pac [-Pprinter] [-pprice] [-s] [-c] [-r] [-m] [user ...]\n");
- exit(1);
+ usage();
}
}
(void) enter(--cp);
@@ -190,6 +193,14 @@ fprintf(stderr,
exit(errs);
}
+static void
+usage()
+{
+ fprintf(stderr,
+ "usage: pac [-Pprinter] [-pprice] [-s] [-c] [-r] [-m] [user ...]\n");
+ exit(1);
+}
+
/*
* Read the entire accounting file, accumulating statistics
* for the users that we have in the hash table. If allflag
@@ -287,7 +298,7 @@ rewrite()
register FILE *acctf;
if ((acctf = fopen(sumfile, "w")) == NULL) {
- perror(sumfile);
+ warn("%s", sumfile);
errs++;
return;
}
@@ -301,12 +312,12 @@ rewrite()
}
fflush(acctf);
if (ferror(acctf)) {
- perror(sumfile);
+ warn("%s", sumfile);
errs++;
}
fclose(acctf);
if ((acctf = fopen(acctfile, "w")) == NULL)
- perror(acctfile);
+ warn("%s", acctfile);
else
fclose(acctf);
}
@@ -438,10 +449,8 @@ chkprinter(s)
if (!pflag && (cgetnum(bp, "pc", &price100) == 0))
price = price100/10000.0;
sumfile = (char *) calloc(sizeof(char), strlen(acctfile)+5);
- if (sumfile == NULL) {
- perror("pac");
- exit(1);
- }
+ if (sumfile == NULL)
+ errx(1, "calloc failed");
strcpy(sumfile, acctfile);
strcat(sumfile, "_sum");
return(1);