Use err(3). Add usage(). Various fixes in man pages.

This commit is contained in:
Philippe Charnier 1997-09-24 06:48:24 +00:00
parent efde591217
commit 9b3fe531b5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=29780
17 changed files with 128 additions and 103 deletions

View File

@ -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);

View File

@ -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>

View File

@ -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));
}

View File

@ -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.4 1997/02/22 16:06:13 peter Exp $
.\" $Id: lp.1,v 1.5 1997/09/18 06:52:35 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.

View File

@ -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.

View File

@ -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 <dirent.h>
#include <signal.h>
#include <setjmp.h>
#include <syslog.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <dirent.h>
#include <grp.h>
#include <setjmp.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <string.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++)

View File

@ -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

View File

@ -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 @@ chkhost(f)
/*NOTREACHED*/
}
void
static void
usage()
{
errx(EX_USAGE, "usage: lpd [-dl] [port#]");
fprintf(stderr, "usage: lpd [-dl] [port#]\n");
exit(EX_USAGE);
}

View File

@ -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);

View File

@ -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.

View File

@ -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);
}

View File

@ -30,7 +30,7 @@
.\" SUCH DAMAGE.
.\"
.\" From @(#)lpr.1 8.1 (Berkeley) 6/6/93
.\" $Id$
.\" $Id: lpr.1,v 1.7 1997/02/22 16:06:19 peter 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

View File

@ -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.19 1997/07/29 04:17:19 imp 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);
}

View File

@ -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 .

View File

@ -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");

View File

@ -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

View File

@ -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);