xref: /openbsd-src/usr.sbin/cron/macros.h (revision 898184e3e61f9129feb5978fad5a8c6865f00b92)
1 /*	$OpenBSD: macros.h,v 1.7 2011/08/22 19:32:42 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 	/* these are really immutable, and are
21 	 *   defined for symbolic convenience only
22 	 * TRUE, FALSE, and ERR must be distinct
23 	 * ERR must be < OK.
24 	 */
25 #define TRUE		1
26 #define FALSE		0
27 	/* system calls return this on success */
28 #define OK		0
29 	/*   or this on error */
30 #define ERR		(-1)
31 
32 	/* turn this on to get '-x' code */
33 #ifndef DEBUGGING
34 #define DEBUGGING	FALSE
35 #endif
36 
37 #define	INIT_PID	1	/* parent of orphans */
38 #define READ_PIPE	0	/* which end of a pipe pair do you read? */
39 #define WRITE_PIPE	1	/*   or write to? */
40 #define	MAX_FNAME	100	/* max length of internally generated fn */
41 #define	MAX_COMMAND	1000	/* max length of internally generated cmd */
42 #define	MAX_ENVSTR	1000	/* max length of envvar=value\0 strings */
43 #define	MAX_TEMPSTR	100	/* obvious */
44 #define	MAX_UNAME	(_PW_NAME_LEN+1)	/* max length of username, should be overkill */
45 #define	ROOT_UID	0	/* don't change this, it really must be root */
46 #define	ROOT_USER	"root"	/* ditto */
47 
48 				/* NOTE: these correspond to DebugFlagNames,
49 				 *	defined below.
50 				 */
51 #define	DEXT		0x0001	/* extend flag for other debug masks */
52 #define	DSCH		0x0002	/* scheduling debug mask */
53 #define	DPROC		0x0004	/* process control debug mask */
54 #define	DPARS		0x0008	/* parsing debug mask */
55 #define	DLOAD		0x0010	/* database loading debug mask */
56 #define	DMISC		0x0020	/* misc debug mask */
57 #define	DTEST		0x0040	/* test mode: don't execute any commands */
58 
59 #define	PPC_NULL	((const char **)NULL)
60 
61 #ifndef MAXHOSTNAMELEN
62 #define MAXHOSTNAMELEN 64
63 #endif
64 
65 #define	Skip_Blanks(c, f) \
66 			while (c == '\t' || c == ' ') \
67 				c = get_char(f);
68 
69 #define	Skip_Nonblanks(c, f) \
70 			while (c!='\t' && c!=' ' && c!='\n' && c != EOF) \
71 				c = get_char(f);
72 
73 #if DEBUGGING
74 # define Debug(mask, message) \
75 			if (DebugFlags & (mask)) \
76 				printf message;
77 #else /* !DEBUGGING */
78 # define Debug(mask, message) \
79 			;
80 #endif /* DEBUGGING */
81 
82 #define	MkUpper(ch)	(islower(ch) ? toupper(ch) : ch)
83 #define	Set_LineNum(ln)	{Debug(DPARS|DEXT,("linenum=%d\n",ln)); \
84 			 LineNumber = ln; \
85 			}
86 
87 /* Data values used on cron socket */
88 #define	RELOAD_CRON	0x2
89 #define	RELOAD_AT	0x4
90 
91 #ifdef HAVE_TM_GMTOFF
92 #define	get_gmtoff(c, t)        ((t)->tm_gmtoff)
93 #endif
94 
95 #define	SECONDS_PER_MINUTE	60
96 
97 #define	FIRST_MINUTE	0
98 #define	LAST_MINUTE	59
99 #define	MINUTE_COUNT	(LAST_MINUTE - FIRST_MINUTE + 1)
100 
101 #define	FIRST_HOUR	0
102 #define	LAST_HOUR	23
103 #define	HOUR_COUNT	(LAST_HOUR - FIRST_HOUR + 1)
104 
105 #define	FIRST_DOM	1
106 #define	LAST_DOM	31
107 #define	DOM_COUNT	(LAST_DOM - FIRST_DOM + 1)
108 
109 #define	FIRST_MONTH	1
110 #define	LAST_MONTH	12
111 #define	MONTH_COUNT	(LAST_MONTH - FIRST_MONTH + 1)
112 
113 /* note on DOW: 0 and 7 are both Sunday, for compatibility reasons. */
114 #define	FIRST_DOW	0
115 #define	LAST_DOW	7
116 #define	DOW_COUNT	(LAST_DOW - FIRST_DOW + 1)
117