xref: /openbsd-src/usr.sbin/cron/structs.h (revision ae3cb403620ab940fbaabb3055fac045a63d56b7)
1 /*	$OpenBSD: structs.h,v 1.8 2016/01/11 14:23:50 millert Exp $	*/
2 
3 /*
4  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
5  * Copyright (c) 1997,2000 by Internet Software Consortium, Inc.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
17  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #include <sys/queue.h>
21 
22 struct passwd;
23 
24 typedef	struct _entry {
25 	SLIST_ENTRY(_entry) entries;
26 	struct passwd	*pwd;
27 	char		**envp;
28 	char		*cmd;
29 	bitstr_t	bit_decl(minute, MINUTE_COUNT);
30 	bitstr_t	bit_decl(hour,   HOUR_COUNT);
31 	bitstr_t	bit_decl(dom,    DOM_COUNT);
32 	bitstr_t	bit_decl(month,  MONTH_COUNT);
33 	bitstr_t	bit_decl(dow,    DOW_COUNT);
34 	int		flags;
35 #define	MIN_STAR	0x01
36 #define	HR_STAR		0x02
37 #define	DOM_STAR	0x04
38 #define	DOW_STAR	0x08
39 #define	WHEN_REBOOT	0x10
40 #define	DONT_LOG	0x20
41 } entry;
42 
43 			/* the crontab database will be a list of the
44 			 * following structure, one element per user
45 			 * plus one for the system.
46 			 *
47 			 * These are the crontabs.
48 			 */
49 
50 typedef	struct _user {
51 	TAILQ_ENTRY(_user) entries;	/* links */
52 	char		*name;
53 	struct timespec	mtime;		/* last modtime of crontab */
54 	SLIST_HEAD(crontab_list, _entry) crontab;	/* this person's crontab */
55 } user;
56 
57 typedef	struct _cron_db {
58 	TAILQ_HEAD(user_list, _user) users;
59 	struct timespec	mtime;		/* last modtime on spooldir */
60 } cron_db;
61 
62 typedef struct _atjob {
63 	TAILQ_ENTRY(_atjob) entries;	/* links */
64 	uid_t		uid;		/* uid of the job */
65 	gid_t		gid;		/* gid of the job */
66 	int		queue;		/* name of the at queue */
67 	time_t		run_time;	/* time to run at job */
68 } atjob;
69 
70 typedef struct _at_db {
71 	TAILQ_HEAD(atjob_list, _atjob) jobs;
72 	struct timespec	mtime;		/* last modtime on spooldir */
73 } at_db;
74