Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-5]: src/usr.sbin/lpr/pac Pullup 1.15 by patch [jdolecek]:
details: https://anonhg.NetBSD.org/src/rev/dbd9b9d8574c
branches: netbsd-1-5
changeset: 489930:dbd9b9d8574c
user: tv <tv%NetBSD.org@localhost>
date: Thu Oct 19 14:09:52 2000 +0000
description:
Pullup 1.15 by patch [jdolecek]:
account(): fix so that number of copies is optional and whitespace
between it and hostname:username is optional as well (some software relies
in this); while here, covert to use sscanf() instead of explicit parse code,
sprinkle some comments
Portion of 1.15 dealing with changing the printing of totals is not pulled up.
diffstat:
usr.sbin/lpr/pac/pac.c | 55 ++++++++++++++++++-------------------------------
1 files changed, 20 insertions(+), 35 deletions(-)
diffs (102 lines):
diff -r ac43fe258976 -r dbd9b9d8574c usr.sbin/lpr/pac/pac.c
--- a/usr.sbin/lpr/pac/pac.c Thu Oct 19 14:05:25 2000 +0000
+++ b/usr.sbin/lpr/pac/pac.c Thu Oct 19 14:09:52 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pac.c,v 1.14 2000/04/27 13:40:18 msaitoh Exp $ */
+/* $NetBSD: pac.c,v 1.14.4.1 2000/10/19 14:09:52 tv Exp $ */
/*
* Copyright (c) 1983, 1993
@@ -41,7 +41,7 @@
#if 0
static char sccsid[] = "@(#)pac.c 8.1 (Berkeley) 6/6/93";
#else
-__RCSID("$NetBSD: pac.c,v 1.14 2000/04/27 13:40:18 msaitoh Exp $");
+__RCSID("$NetBSD: pac.c,v 1.14.4.1 2000/10/19 14:09:52 tv Exp $");
#endif
#endif /* not lint */
@@ -95,7 +95,6 @@
static struct hent *hashtab[HSHSIZE]; /* Hash table proper */
static void account __P((FILE *));
-static int any __P((int, const char *));
static int chkprinter __P((const char *));
static void dumpit __P((void));
static int hash __P((const char *));
@@ -205,33 +204,36 @@
* is set, then just gather the facts on everyone.
* Note that we must accomodate both the active and summary file
* formats here.
+ * Format of accounting file is
+ * feet_per_page [runs_count] [hostname:]username
+ * Some software relies on whitespace between runs_count and hostname:username
+ * being optional (such as Ghostscript's unix-lpr.sh).
+ *
* Host names are ignored if the -m flag is present.
*/
static void
account(acct)
FILE *acct;
{
+ char who[BUFSIZ];
char linebuf[BUFSIZ];
- double t;
+ float t;
char *cp, *cp2;
struct hent *hp;
int ic;
while (fgets(linebuf, BUFSIZ, acct) != NULL) {
- cp = linebuf;
- while (any(*cp, " \t"))
- cp++;
- t = atof(cp);
- while (any(*cp, ".0123456789"))
- cp++;
- while (any(*cp, " \t"))
- cp++;
- for (cp2 = cp; !any(*cp2, " \t\n"); cp2++)
- ;
- ic = atoi(cp2);
- *cp2 = '\0';
- if (mflag && strchr(cp, ':'))
- cp = strchr(cp, ':') + 1;
+ if (sscanf(linebuf, "%f %d%s", &t, &ic, who) == 0) {
+ sscanf(linebuf, "%f %s", &t, who);
+ ic = 1;
+ }
+
+ /* if -m was specified, don't use the hostname part */
+ if (mflag && (cp2 = strchr(who, ':')))
+ cp = cp2 + 1;
+ else
+ cp = who;
+
hp = lookup(cp);
if (hp == NULL) {
if (!allflag)
@@ -392,23 +394,6 @@
}
/*
- * Other stuff
- */
-static int
-any(ch, str)
- int ch;
- const char *str;
-{
- int c = ch;
- const char *cp = str;
-
- while (*cp)
- if (*cp++ == c)
- return(1);
- return(0);
-}
-
-/*
* The qsort comparison routine.
* The comparison is ascii collating order
* or by feet of typesetter film, according to sort.
Home |
Main Index |
Thread Index |
Old Index