From bae8d45c7f88bd182db15543520af30b13146bc5 Mon Sep 17 00:00:00 2001 From: Garance A Drosehn Date: Fri, 12 Jul 2002 01:22:57 +0000 Subject: [PATCH] Add two variables to struct jobqueue, and change the way that getq() calculates how much space to get for that struct, so it will get the right amount when new variables are added. MFC after: 3 days --- usr.sbin/lpr/common_source/common.c | 9 ++++++--- usr.sbin/lpr/common_source/lp.h | 4 ++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/usr.sbin/lpr/common_source/common.c b/usr.sbin/lpr/common_source/common.c index 257a74090eeb..e382e69be9a3 100644 --- a/usr.sbin/lpr/common_source/common.c +++ b/usr.sbin/lpr/common_source/common.c @@ -111,7 +111,7 @@ getq(const struct printer *pp, struct jobqueue *(*namelist[])) { register struct dirent *d; register struct jobqueue *q, **queue; - size_t arraysz, nitems; + size_t arraysz, entrysz, nitems; struct stat stbuf; DIR *dirp; int statres; @@ -143,10 +143,13 @@ getq(const struct printer *pp, struct jobqueue *(*namelist[])) seteuid(uid); if (statres < 0) continue; /* Doesn't exist */ - q = (struct jobqueue *)malloc(sizeof(time_t) + strlen(d->d_name) - + 1); + entrysz = sizeof(struct jobqueue) - sizeof(q->job_cfname) + + strlen(d->d_name) + 1; + q = (struct jobqueue *)malloc(entrysz); if (q == NULL) goto errdone; + q->job_matched = 0; + q->job_processed = 0; q->job_time = stbuf.st_mtime; strcpy(q->job_cfname, d->d_name); /* diff --git a/usr.sbin/lpr/common_source/lp.h b/usr.sbin/lpr/common_source/lp.h index 81ac7aee4afc..e155b4d616d9 100644 --- a/usr.sbin/lpr/common_source/lp.h +++ b/usr.sbin/lpr/common_source/lp.h @@ -183,9 +183,13 @@ extern u_char family; /* address family */ /* * Structure used for building a sorted list of control files. + * The job_processed value can be used by callers of getq(), to keep + * track of whatever processing they are doing. */ struct jobqueue { time_t job_time; /* last-mod time of cf-file */ + int job_matched; /* used by match_jobspec() */ + int job_processed; /* set to zero by getq() */ char job_cfname[MAXNAMLEN+1]; /* control file name */ };