summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2002-06-09 03:44:51 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2002-06-09 03:44:51 +0000
commitabfac74328359cb29b52a4a8e83dbb8a623b9b52 (patch)
treec2f8230000ae8abb7024cf14ea9d316c2f186d67
parent717216267fdbefbdbd0658613316a28ba42261f8 (diff)
o Kill "garbage" global (unused)
o Kill "rank" global (doesn't need to be global) o Make inform() static (local to displayq.c) o Pass in rank to inform() based on index within sorted mtime array o Simplify compar()
-rw-r--r--usr.sbin/lpr/common_source/common.c17
-rw-r--r--usr.sbin/lpr/common_source/displayq.c22
-rw-r--r--usr.sbin/lpr/common_source/lp.h3
3 files changed, 19 insertions, 23 deletions
diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c
index d4d6647058f..90a393305f8 100644
--- a/usr.sbin/lpr/common_source/common.c
+++ b/usr.sbin/lpr/common_source/common.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: common.c,v 1.20 2002/06/08 18:19:34 millert Exp $ */
+/* $OpenBSD: common.c,v 1.21 2002/06/09 03:44:50 millert Exp $ */
/* $NetBSD: common.c,v 1.21 2000/08/09 14:28:50 itojun Exp $ */
/*
@@ -43,7 +43,7 @@
#if 0
static const char sccsid[] = "@(#)common.c 8.5 (Berkeley) 4/28/95";
#else
-static const char rcsid[] = "$OpenBSD: common.c,v 1.20 2002/06/08 18:19:34 millert Exp $";
+static const char rcsid[] = "$OpenBSD: common.c,v 1.21 2002/06/09 03:44:50 millert Exp $";
#endif
#endif /* not lint */
@@ -311,14 +311,13 @@ errdone:
* Compare modification times.
*/
static int
-compar(p1, p2)
- const void *p1, *p2;
+compar(v1, v2)
+ const void *v1, *v2;
{
- if ((*(struct queue **)p1)->q_time < (*(struct queue **)p2)->q_time)
- return(-1);
- if ((*(struct queue **)p1)->q_time > (*(struct queue **)p2)->q_time)
- return(1);
- return(0);
+ struct queue *p1 = *(struct queue **)v1;
+ struct queue *p2 = *(struct queue **)v2;
+
+ return(p1->q_time - p2->q_time);
}
/*
diff --git a/usr.sbin/lpr/common_source/displayq.c b/usr.sbin/lpr/common_source/displayq.c
index eea7ea09b26..1fa83e3293a 100644
--- a/usr.sbin/lpr/common_source/displayq.c
+++ b/usr.sbin/lpr/common_source/displayq.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: displayq.c,v 1.19 2002/06/08 23:23:24 millert Exp $ */
+/* $OpenBSD: displayq.c,v 1.20 2002/06/09 03:44:50 millert Exp $ */
/* $NetBSD: displayq.c,v 1.21 2001/08/30 00:51:50 itojun Exp $ */
/*
@@ -38,7 +38,7 @@
#if 0
static const char sccsid[] = "@(#)displayq.c 8.4 (Berkeley) 4/28/95";
#else
-static const char rcsid[] = "$OpenBSD: displayq.c,v 1.19 2002/06/08 23:23:24 millert Exp $";
+static const char rcsid[] = "$OpenBSD: displayq.c,v 1.20 2002/06/09 03:44:50 millert Exp $";
#endif
#endif /* not lint */
@@ -81,15 +81,14 @@ static int col; /* column on screen */
static char current[NAME_MAX]; /* current file being printed */
static char file[NAME_MAX]; /* print file name */
static int first; /* first file in ``files'' column? */
-static int garbage; /* # of garbage cf files */
static int lflag; /* long output option */
-static int rank; /* order to be printed (-1=none, 0=active) */
static off_t totsize; /* total print job size in bytes */
static const char *head0 = "Rank Owner Job Files";
static const char *head1 = "Total Size\n";
static void alarmer(int);
+static void inform(char *, int);
/*
* Display the current state of the queue. Format = 1 if long format.
@@ -116,7 +115,6 @@ displayq(int format)
lflag = format;
totsize = 0;
- rank = -1;
if ((i = cgetent(&bp, printcapdb, printer)) == -2)
fatal("can't open printer description file");
else if (i == -1)
@@ -233,7 +231,11 @@ displayq(int format)
header();
for (i = 0; i < nitems; i++) {
q = queue[i];
- inform(q->q_name);
+ /* active == 0, otherwise count starts at 1 */
+ if (strcmp(current, q->q_name) == 0)
+ inform(q->q_name, 0);
+ else
+ inform(q->q_name, i + 1);
free(q);
}
free(queue);
@@ -330,8 +332,8 @@ header(void)
printf(head1);
}
-void
-inform(char *cf)
+static void
+inform(char *cf, int rank)
{
int fd, j;
FILE *cfp = NULL;
@@ -349,10 +351,6 @@ inform(char *cf)
return;
}
- if (rank < 0)
- rank = 0;
- if (remote || garbage || strcmp(cf, current))
- rank++;
j = 0;
while (getline(cfp)) {
switch (line[0]) {
diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h
index 2734028e37d..2c910aeed4c 100644
--- a/usr.sbin/lpr/common_source/lp.h
+++ b/usr.sbin/lpr/common_source/lp.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lp.h,v 1.10 2002/06/08 01:53:43 millert Exp $ */
+/* $OpenBSD: lp.h,v 1.11 2002/06/09 03:44:50 millert Exp $ */
/* $NetBSD: lp.h,v 1.14 2000/04/16 14:43:58 mrg Exp $ */
/*
@@ -138,7 +138,6 @@ int getline(FILE *);
int getport(char *, int);
int getq(struct queue *(*[]));
void header(void);
-void inform(char *);
int inlist(char *, char *);
int iscf(struct dirent *);
int isowner(char *, char *);