xref: /illumos-gate/usr/src/cmd/cron/cron.h (revision 7b07063d906859b2be1e88791f801b3c96e432f6)
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 #ifndef	_CRON_H
27 #define	_CRON_H
28 
29 #include <unistd.h>
30 
31 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
32 /*	  All Rights Reserved  	*/
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 #define	FALSE		0
39 #define	TRUE		1
40 #define	MINUTE		60L
41 #define	HOUR		60L*60L
42 #define	DAY		24L*60L*60L
43 #define	NQUEUE		26		/* number of queues available */
44 #define	ATEVENT		0
45 #define	BATCHEVENT	1
46 #define	CRONEVENT	2
47 
48 #define	ADD		'a'
49 #define	DELETE		'd'
50 #define	AT		'a'
51 #define	CRON		'c'
52 #define	REFRESH		'r'
53 
54 #define	QUE(x)		('a'+(x))
55 #define	RCODE(x)	(((x)>>8)&0377)
56 #define	TSTAT(x)	((x)&0377)
57 
58 /* This constant must be at least sysconf(_SC_LOGIN_NAME_MAX) in size */
59 #define	UNAMESIZE	32	/* max chars in a user name */
60 
61 #define	FLEN	UNAMESIZE
62 #define	LLEN	UNAMESIZE
63 
64 /*
65  * structure used for passing messages from the at and crontab commands to cron
66  */
67 struct	message {
68 	char	etype;
69 	char	action;
70 	char	fname[FLEN];
71 	char	logname[LLEN];
72 };
73 
74 #define	CRONDIR		"/var/spool/cron/crontabs"
75 #define	ATDIR		"/var/spool/cron/atjobs"
76 #define	ACCTFILE	"/var/cron/log"
77 #define	CRONALLOW	"/etc/cron.d/cron.allow"
78 #define	CRONDENY	"/etc/cron.d/cron.deny"
79 #define	ATALLOW		"/etc/cron.d/at.allow"
80 #define	ATDENY		"/etc/cron.d/at.deny"
81 #define	PROTO		"/etc/cron.d/.proto"
82 #define	QUEDEFS		"/etc/cron.d/queuedefs"
83 #define	FIFO		"/etc/cron.d/FIFO"
84 #define	DEFFILE		"/etc/default/cron"
85 
86 #define	SHELL		"/usr/bin/sh"	/* shell to execute */
87 
88 #define	ENV_SHELL	"SHELL="
89 #define	ENV_TZ		"TZ="
90 #define	ENV_HOME	"HOME="
91 
92 #define	CTLINESIZE	1000	/* max chars in a crontab line */
93 
94 extern int	allowed(char *, char *, char *);
95 extern int	days_in_mon(int, int);
96 extern char	*errmsg(int);
97 extern char	*getuser(uid_t);
98 extern void	cron_sendmsg(char, char *, char *, char);
99 extern time_t	 num(char **);
100 extern void	*xmalloc(size_t);
101 extern void	*xcalloc(size_t, size_t);
102 extern char	*xstrdup(const char *);
103 extern int	isvalid_shell(const char *shell);
104 extern int	isvalid_dir(const char *dir);
105 
106 extern int	cron_admin(const char *);
107 
108 #ifdef	__cplusplus
109 }
110 #endif
111 
112 #endif	/* _CRON_H */
113