xref: /illumos-gate/usr/src/cmd/cron/cron.h (revision d8849d7dee03b84a3fa281ec65eb9e3d86d3756b)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*
27  * Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
28  */
29 
30 #ifndef	_CRON_H
31 #define	_CRON_H
32 
33 #include <unistd.h>
34 
35 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
36 /*	  All Rights Reserved	*/
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 #define	FALSE		0
43 #define	TRUE		1
44 #define	MINUTE		60L
45 #define	HOUR		60L*60L
46 #define	DAY		24L*60L*60L
47 #define	NQUEUE		26		/* number of queues available */
48 #define	ATEVENT		0
49 #define	BATCHEVENT	1
50 #define	CRONEVENT	2
51 
52 #define	ADD		'a'
53 #define	DELETE		'd'
54 #define	AT		'a'
55 #define	CRON		'c'
56 #define	REFRESH		'r'
57 
58 #define	QUE(x)		('a'+(x))
59 #define	RCODE(x)	(((x)>>8)&0377)
60 #define	TSTAT(x)	((x)&0377)
61 
62 /* This constant must be at least sysconf(_SC_LOGIN_NAME_MAX) in size */
63 #define	UNAMESIZE	32	/* max chars in a user name */
64 
65 #define	FLEN	UNAMESIZE
66 #define	LLEN	UNAMESIZE
67 
68 /*
69  * structure used for passing messages from the at and crontab commands to cron
70  */
71 struct	message {
72 	char	etype;
73 	char	action;
74 	char	fname[FLEN];
75 	char	logname[LLEN];
76 };
77 
78 /*
79  * Errors from the crontab field parser.
80  */
81 typedef enum {
82 	CFOK = 0,
83 	CFEOLN,
84 	CFUNEXPECT,
85 	CFOUTOFBOUND,
86 	CFEOVERFLOW,
87 	CFENOMEM
88 } cferror_t;
89 
90 #define	CRONDIR		"/var/spool/cron/crontabs"
91 #define	ATDIR		"/var/spool/cron/atjobs"
92 #define	ACCTFILE	"/var/cron/log"
93 #define	CRONALLOW	"/etc/cron.d/cron.allow"
94 #define	CRONDENY	"/etc/cron.d/cron.deny"
95 #define	ATALLOW		"/etc/cron.d/at.allow"
96 #define	ATDENY		"/etc/cron.d/at.deny"
97 #define	PROTO		"/etc/cron.d/.proto"
98 #define	QUEDEFS		"/etc/cron.d/queuedefs"
99 #define	FIFO		"/etc/cron.d/FIFO"
100 #define	DEFFILE		"/etc/default/cron"
101 
102 #define	SHELL		"/usr/bin/sh"	/* shell to execute */
103 
104 #define	ENV_SHELL	"SHELL="
105 #define	ENV_TZ		"TZ="
106 #define	ENV_HOME	"HOME="
107 
108 #define	CTLINESIZE	1000	/* max chars in a crontab line */
109 
110 extern int	allowed(char *, char *, char *);
111 extern int	days_in_mon(int, int);
112 extern char	*errmsg(int);
113 extern char	*getuser(uid_t);
114 extern void	cron_sendmsg(char, char *, char *, char);
115 extern time_t	 num(char **);
116 extern void	*xmalloc(size_t);
117 extern void	*xcalloc(size_t, size_t);
118 extern char	*xstrdup(const char *);
119 extern int	isvalid_shell(const char *shell);
120 extern int	isvalid_dir(const char *dir);
121 
122 extern int	cron_admin(const char *);
123 extern cferror_t next_field(uint_t, uint_t, char *, int *, char **);
124 
125 #ifdef	__cplusplus
126 }
127 #endif
128 
129 #endif	/* _CRON_H */
130