xref: /openbsd/usr.sbin/cron/structs.h (revision 2e6cac80)
1 /*	$OpenBSD: structs.h,v 1.10 2020/04/16 17:51:56 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 #define	MAIL_WHEN_ERR	0x40
42 #define	SINGLE_JOB	0x80
43 } entry;
44 
45 			/* the crontab database will be a list of the
46 			 * following structure, one element per user
47 			 * plus one for the system.
48 			 *
49 			 * These are the crontabs.
50 			 */
51 
52 typedef	struct _user {
53 	TAILQ_ENTRY(_user) entries;	/* links */
54 	char		*name;
55 	struct timespec	mtime;		/* last modtime of crontab */
56 	SLIST_HEAD(crontab_list, _entry) crontab;	/* this person's crontab */
57 } user;
58 
59 typedef	struct _cron_db {
60 	TAILQ_HEAD(user_list, _user) users;
61 	struct timespec	mtime;		/* last modtime on spooldir */
62 } cron_db;
63 
64 typedef struct _atjob {
65 	TAILQ_ENTRY(_atjob) entries;	/* links */
66 	uid_t		uid;		/* uid of the job */
67 	gid_t		gid;		/* gid of the job */
68 	int		queue;		/* name of the at queue */
69 	time_t		run_time;	/* time to run at job */
70 } atjob;
71 
72 typedef struct _at_db {
73 	TAILQ_HEAD(atjob_list, _atjob) jobs;
74 	struct timespec	mtime;		/* last modtime on spooldir */
75 } at_db;
76