diff options
author | charnier <charnier@FreeBSD.org> | 1997-09-24 06:48:24 +0000 |
---|---|---|
committer | charnier <charnier@FreeBSD.org> | 1997-09-24 06:48:24 +0000 |
commit | 49a43f1c40cff330447553c74983f50c305a90bd (patch) | |
tree | 2461a8278a1795e3f8aa616ff0029567b021f873 /usr.sbin | |
parent | 8acbd05f99be0b83f71366e26584715af13f0872 (diff) | |
download | FreeBSD-src-49a43f1c40cff330447553c74983f50c305a90bd.zip FreeBSD-src-49a43f1c40cff330447553c74983f50c305a90bd.tar.gz |
Use err(3). Add usage(). Various fixes in man pages.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/lpr/common_source/recvjob.c | 12 | ||||
-rw-r--r-- | usr.sbin/lpr/common_source/rmjob.c | 4 | ||||
-rw-r--r-- | usr.sbin/lpr/common_source/startdaemon.c | 23 | ||||
-rw-r--r-- | usr.sbin/lpr/lp/lp.1 | 27 | ||||
-rw-r--r-- | usr.sbin/lpr/lpc/lpc.8 | 6 | ||||
-rw-r--r-- | usr.sbin/lpr/lpc/lpc.c | 27 | ||||
-rw-r--r-- | usr.sbin/lpr/lpd/lpd.8 | 4 | ||||
-rw-r--r-- | usr.sbin/lpr/lpd/lpd.c | 11 | ||||
-rw-r--r-- | usr.sbin/lpr/lpd/recvjob.c | 12 | ||||
-rw-r--r-- | usr.sbin/lpr/lpq/lpq.1 | 6 | ||||
-rw-r--r-- | usr.sbin/lpr/lpq/lpq.c | 13 | ||||
-rw-r--r-- | usr.sbin/lpr/lpr/lpr.1 | 8 | ||||
-rw-r--r-- | usr.sbin/lpr/lpr/lpr.c | 15 | ||||
-rw-r--r-- | usr.sbin/lpr/lprm/lprm.1 | 14 | ||||
-rw-r--r-- | usr.sbin/lpr/lprm/lprm.c | 10 | ||||
-rw-r--r-- | usr.sbin/lpr/pac/pac.8 | 4 | ||||
-rw-r--r-- | usr.sbin/lpr/pac/pac.c | 31 |
17 files changed, 126 insertions, 101 deletions
diff --git a/usr.sbin/lpr/common_source/recvjob.c b/usr.sbin/lpr/common_source/recvjob.c index 6ed50c3..192d993 100644 --- a/usr.sbin/lpr/common_source/recvjob.c +++ b/usr.sbin/lpr/common_source/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/common_source/rmjob.c b/usr.sbin/lpr/common_source/rmjob.c index c44f172..32e13d4 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 ca24c82..7f990b4 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 58d469c..1faeba9 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.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. diff --git a/usr.sbin/lpr/lpc/lpc.8 b/usr.sbin/lpr/lpc/lpc.8 index ce0f451..b3a0c52 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 353d7cb..bb07d46 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 3b6d768..2323f40 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 7fc8a8f..e62e6bf 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 6ed50c3..192d993 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 200f60d..04ecdad 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 56705bc..9dc9c8a 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 a1d34e5..672edad 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.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 diff --git a/usr.sbin/lpr/lpr/lpr.c b/usr.sbin/lpr/lpr/lpr.c index a4f81d9..a22ccc3 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.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); } diff --git a/usr.sbin/lpr/lprm/lprm.1 b/usr.sbin/lpr/lprm/lprm.1 index a4c4659..02da034 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 df3a6cb..e124744 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 6e7ffc0..433cfe4 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 9806965..c89a526 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); |