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/lpr/pac | |
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/lpr/pac')
-rw-r--r-- | usr.sbin/lpr/pac/pac.8 | 4 | ||||
-rw-r--r-- | usr.sbin/lpr/pac/pac.c | 31 |
2 files changed, 22 insertions, 13 deletions
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); |