X-Git-Url: https://git.subgeniuskitty.com/unix-history/.git/blobdiff_plain/0f4556f12c8f75078501c9d1338ae7648a97f975..95f51977ddc18faa2e212f30c00a39540b39f325:/usr/src/usr.lib/lpr/pac.c diff --git a/usr/src/usr.lib/lpr/pac.c b/usr/src/usr.lib/lpr/pac.c index 2dc1c37544..f544480543 100644 --- a/usr/src/usr.lib/lpr/pac.c +++ b/usr/src/usr.lib/lpr/pac.c @@ -1,11 +1,23 @@ +/* + * Copyright (c) 1983 Regents of the University of California. + * All rights reserved. The Berkeley software License Agreement + * specifies the terms and conditions for redistribution. + */ + +#ifndef lint +char copyright[] = +"@(#) Copyright (c) 1983 Regents of the University of California.\n\ + All rights reserved.\n"; +#endif not lint + #ifndef lint -static char sccsid[] = "@(#)pac.c 4.2 (Berkeley) 7/17/83"; -#endif +static char sccsid[] = "@(#)pac.c 5.2 (Berkeley) 10/30/85"; +#endif not lint /* * Do Printer accounting summary. * Currently, usage is - * pac [-Pprinter] [-pprice] [-s] [-r] [-c] [user ...] + * pac [-Pprinter] [-pprice] [-s] [-r] [-c] [-m] [user ...] * to print the usage information for the named people. */ @@ -22,6 +34,11 @@ int summarize; /* Compress accounting file */ int reverse; /* Reverse sort order */ int hcount; /* Count of hash entries */ int errs; +int mflag = 0; /* disregard machine names */ +int pflag = 0; /* 1 if -p on cmd line */ +int price100; /* per-page cost in 100th of a cent */ +char *index(); +int pgetnum(); /* * Grossness follows: @@ -70,6 +87,7 @@ main(argc, argv) * get the price. */ price = atof(cp); + pflag = 1; continue; case 's': @@ -86,6 +104,13 @@ main(argc, argv) sort++; continue; + case 'm': + /* + * disregard machine names for each user + */ + mflag = 1; + continue; + case 'r': /* * Reverse sorting order. @@ -94,7 +119,8 @@ main(argc, argv) continue; default: -fprintf(stderr, "usage: pac [-Pprinter] [-pprice] [-s] [-c] [-r] [user ...]\n"); +fprintf(stderr, + "usage: pac [-Pprinter] [-pprice] [-s] [-c] [-r] [-m] [user ...]\n"); exit(1); } } @@ -131,6 +157,7 @@ fprintf(stderr, "usage: pac [-Pprinter] [-pprice] [-s] [-c] [-r] [user ...]\n"); * is set, then just gather the facts on everyone. * Note that we must accomodate both the active and summary file * formats here. + * Host names are ignored if the -m flag is present. */ account(acct) @@ -155,6 +182,8 @@ account(acct) ; ic = atoi(cp2); *cp2 = '\0'; + if (mflag && index(cp, ':')) + cp = index(cp, ':') + 1; hp = lookup(cp); if (hp == NIL) { if (!allflag) @@ -339,7 +368,8 @@ qucmp(left, right) h1 = *left; h2 = *right; if (sort) - r = h1->h_feetpages < h2->h_feetpages ? -1 : h1->h_feetpages > h2->h_feetpages; + r = h1->h_feetpages < h2->h_feetpages ? -1 : h1->h_feetpages > +h2->h_feetpages; else r = strcmp(h1->h_name, h2->h_name); return(reverse ? -r : r); @@ -365,6 +395,8 @@ chkprinter(s) printf("accounting not enabled for printer %s\n", printer); exit(2); } + if (!pflag && (price100 = pgetnum("pc")) > 0) + price = price100/10000.0; sumfile = (char *) calloc(sizeof(char), strlen(acctfile)+5); if (sumfile == NULL) { perror("pac");