xref: /netbsd-src/external/bsd/cron/dist/macros.h (revision 032a439890ddfa3f6f4a2803c19869bfa3a6ad0e)
1 /*	$NetBSD: macros.h,v 1.2 2010/05/06 18:53:17 christos Exp $	*/
2 
3 /*
4  * Id: macros.h,v 1.9 2004/01/23 18:56:43 vixie Exp
5  */
6 
7 /*
8  * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
9  * Copyright (c) 1997,2000 by Internet Software Consortium, Inc.
10  *
11  * Permission to use, copy, modify, and distribute this software for any
12  * purpose with or without fee is hereby granted, provided that the above
13  * copyright notice and this permission notice appear in all copies.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
16  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
17  * MERCHANTABILITY AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR
18  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
20  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
21  * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
22  */
23 
24 	/* these are really immutable, and are
25 	 *   defined for symbolic convenience only
26 	 * TRUE, FALSE, and ERR must be distinct
27 	 * ERR must be < OK.
28 	 */
29 #define TRUE		1
30 #define FALSE		0
31 	/* system calls return this on success */
32 #define OK		0
33 	/*   or this on error */
34 #define ERR		(-1)
35 
36 	/* turn this on to get '-x' code */
37 #ifndef DEBUGGING
38 #define DEBUGGING	FALSE
39 #endif
40 
41 #define	INIT_PID	1	/* parent of orphans */
42 #define READ_PIPE	0	/* which end of a pipe pair do you read? */
43 #define WRITE_PIPE	1	/*   or write to? */
44 #define STDIN		0	/* what is stdin's file descriptor? */
45 #define STDOUT		1	/*   stdout's? */
46 #define STDERR		2	/*   stderr's? */
47 #define ERROR_EXIT	1	/* exit() with this will scare the shell */
48 #define	OK_EXIT		0	/* exit() with this is considered 'normal' */
49 #define	MAX_FNAME	100	/* max length of internally generated fn */
50 #define	MAX_COMMAND	1000	/* max length of internally generated cmd */
51 #define	MAX_ENVSTR	1000	/* max length of envvar=value\0 strings */
52 #define	MAX_TEMPSTR	100	/* obvious */
53 #define	MAX_UNAME	33	/* max length of username, should be overkill */
54 #define	ROOT_UID	0	/* don't change this, it really must be root */
55 #define	ROOT_USER	"root"	/* ditto */
56 
57 				/* NOTE: these correspond to DebugFlagNames,
58 				 *	defined below.
59 				 */
60 #define	DEXT		0x0001	/* extend flag for other debug masks */
61 #define	DSCH		0x0002	/* scheduling debug mask */
62 #define	DPROC		0x0004	/* process control debug mask */
63 #define	DPARS		0x0008	/* parsing debug mask */
64 #define	DLOAD		0x0010	/* database loading debug mask */
65 #define	DMISC		0x0020	/* misc debug mask */
66 #define	DTEST		0x0040	/* test mode: don't execute any commands */
67 
68 #define	PPC_NULL	((const char **)NULL)
69 
70 #ifndef MAXHOSTNAMELEN
71 #define MAXHOSTNAMELEN 64
72 #endif
73 
74 #define	Skip_Blanks(c, f) \
75 			while (c == '\t' || c == ' ') \
76 				c = get_char(f)
77 
78 #define	Skip_Nonblanks(c, f) \
79 			while (c!='\t' && c!=' ' && c!='\n' && c != EOF) \
80 				c = get_char(f)
81 
82 #if DEBUGGING
83 # define Debug(mask, message) \
84 			if ((DebugFlags & (mask)) != 0) \
85 				printf message
86 #else /* !DEBUGGING */
87 # define Debug(mask, message) do {} while (/*CONSTCOND*/0)
88 #endif /* DEBUGGING */
89 
90 #define	Set_LineNum(ln)	do { \
91 	Debug(DPARS|DEXT,("linenum=%d\n", ln)); \
92 	LineNumber = ln; \
93 } while (/*CONSTCOND*/0)
94 
95 #ifdef HAVE_TM_GMTOFF
96 #define	get_gmtoff(c, t)	((t)->tm_gmtoff)
97 #endif
98 
99 #define	SECONDS_PER_MINUTE	60
100 #define	SECONDS_PER_HOUR	3600
101 
102 #define	FIRST_MINUTE	0
103 #define	LAST_MINUTE	59
104 #define	MINUTE_COUNT	(LAST_MINUTE - FIRST_MINUTE + 1)
105 
106 #define	FIRST_HOUR	0
107 #define	LAST_HOUR	23
108 #define	HOUR_COUNT	(LAST_HOUR - FIRST_HOUR + 1)
109 
110 #define	FIRST_DOM	1
111 #define	LAST_DOM	31
112 #define	DOM_COUNT	(LAST_DOM - FIRST_DOM + 1)
113 
114 #define	FIRST_MONTH	1
115 #define	LAST_MONTH	12
116 #define	MONTH_COUNT	(LAST_MONTH - FIRST_MONTH + 1)
117 
118 /* note on DOW: 0 and 7 are both Sunday, for compatibility reasons. */
119 #define	FIRST_DOW	0
120 #define	LAST_DOW	7
121 #define	DOW_COUNT	(LAST_DOW - FIRST_DOW + 1)
122 
123 /*
124  * Because crontab/at files may be owned by their respective users we
125  * take extreme care in opening them.  If the OS lacks the O_NOFOLLOW
126  * we will just have to live without it.  In order for this to be an
127  * issue an attacker would have to subvert group CRON_GROUP.
128  */
129 #ifndef O_NOFOLLOW
130 #define O_NOFOLLOW	0
131 #endif
132