+/*
+ * 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.
*/
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:
* get the price.
*/
price = atof(cp);
+ pflag = 1;
continue;
case 's':
sort++;
continue;
+ case 'm':
+ /*
+ * disregard machine names for each user
+ */
+ mflag = 1;
+ continue;
+
case 'r':
/*
* Reverse sorting order.
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);
}
}
* 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)
;
ic = atoi(cp2);
*cp2 = '\0';
+ if (mflag && index(cp, ':'))
+ cp = index(cp, ':') + 1;
hp = lookup(cp);
if (hp == NIL) {
if (!allflag)
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);
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");