NetBSD/usr.sbin/cron/job.c
christos 9ac7be0692 Warnsify:
- add __RCSID
	- remove nested comments
	- remove register and auto keywords
	- change into posix signals
	- fix prototypes
1998-01-31 14:40:13 +00:00

82 lines
1.7 KiB
C

/* $NetBSD: job.c,v 1.3 1998/01/31 14:40:35 christos Exp $ */
/* Copyright 1988,1990,1993,1994 by Paul Vixie
* All rights reserved
*
* Distribute freely, except: don't remove my name from the source or
* documentation (don't take credit for my work), mark your changes (don't
* get me blamed for your possible bugs), don't alter or remove this
* notice. May be sold if buildable source is provided to buyer. No
* warrantee of any kind, express or implied, is included with this
* software; use at your own risk, responsibility for damages (if any) to
* anyone resulting from the use of this software rests entirely with the
* user.
*
* Send bug reports, bug fixes, enhancements, requests, flames, etc., and
* I'll try to keep a version up to date. I can be reached as follows:
* Paul Vixie <paul@vix.com> uunet!decwrl!vixie!paul
*/
#include <sys/cdefs.h>
#if !defined(lint) && !defined(LINT)
#if 0
static char rcsid[] = "Id: job.c,v 1.6 1994/01/15 20:43:43 vixie Exp";
#else
__RCSID("$NetBSD: job.c,v 1.3 1998/01/31 14:40:35 christos Exp $");
#endif
#endif
#include "cron.h"
typedef struct _job {
struct _job *next;
entry *e;
user *u;
} job;
static job *jhead = NULL, *jtail = NULL;
void
job_add(e, u)
entry *e;
user *u;
{
job *j;
/* if already on queue, keep going */
for (j=jhead; j; j=j->next)
if (j->e == e && j->u == u) { return; }
/* build a job queue element */
j = (job*)malloc(sizeof(job));
j->next = (job*) NULL;
j->e = e;
j->u = u;
/* add it to the tail */
if (!jhead) { jhead=j; }
else { jtail->next=j; }
jtail = j;
}
int
job_runqueue()
{
job *j, *jn;
int run = 0;
for (j=jhead; j; j=jn) {
do_command(j->e, j->u);
jn = j->next;
free(j);
run++;
}
jhead = jtail = NULL;
return run;
}