1 /* $OpenBSD: macros.h,v 1.2 2001/02/20 02:03:19 millert Exp $ */ 2 3 /* 4 * Copyright (c) 1997,2000 by Internet Software Consortium, Inc. 5 * 6 * Permission to use, copy, modify, and distribute this software for any 7 * purpose with or without fee is hereby granted, provided that the above 8 * copyright notice and this permission notice appear in all copies. 9 * 10 * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS 11 * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES 12 * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE 13 * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL 14 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR 15 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS 16 * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 17 * 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 STDIN 0 /* what is stdin's file descriptor? */ 41 #define STDOUT 1 /* stdout's? */ 42 #define STDERR 2 /* stderr's? */ 43 #define ERROR_EXIT 1 /* exit() with this will scare the shell */ 44 #define OK_EXIT 0 /* exit() with this is considered 'normal' */ 45 #define MAX_FNAME 100 /* max length of internally generated fn */ 46 #define MAX_COMMAND 1000 /* max length of internally generated cmd */ 47 #define MAX_ENVSTR 1000 /* max length of envvar=value\0 strings */ 48 #define MAX_TEMPSTR 100 /* obvious */ 49 #define MAX_UNAME (_PW_NAME_LEN+1) /* max length of username, should be overkill */ 50 #define ROOT_UID 0 /* don't change this, it really must be root */ 51 #define ROOT_USER "root" /* ditto */ 52 53 /* NOTE: these correspond to DebugFlagNames, 54 * defined below. 55 */ 56 #define DEXT 0x0001 /* extend flag for other debug masks */ 57 #define DSCH 0x0002 /* scheduling debug mask */ 58 #define DPROC 0x0004 /* process control debug mask */ 59 #define DPARS 0x0008 /* parsing debug mask */ 60 #define DLOAD 0x0010 /* database loading debug mask */ 61 #define DMISC 0x0020 /* misc debug mask */ 62 #define DTEST 0x0040 /* test mode: don't execute any commands */ 63 #define DBIT 0x0080 /* bit twiddling shown (long) */ 64 65 #define CRON_TAB(u) "%s/%s", SPOOL_DIR, u 66 #define PPC_NULL ((const char **)NULL) 67 68 #ifndef MAXHOSTNAMELEN 69 #define MAXHOSTNAMELEN 64 70 #endif 71 72 #define Skip_Blanks(c, f) \ 73 while (c == '\t' || c == ' ') \ 74 c = get_char(f); 75 76 #define Skip_Nonblanks(c, f) \ 77 while (c!='\t' && c!=' ' && c!='\n' && c != EOF) \ 78 c = get_char(f); 79 80 #define Skip_Line(c, f) \ 81 do {c = get_char(f);} while (c != '\n' && c != EOF); 82 83 #if DEBUGGING 84 # define Debug(mask, message) \ 85 if ( (DebugFlags & (mask) ) == (mask) ) \ 86 printf message; 87 #else /* !DEBUGGING */ 88 # define Debug(mask, message) \ 89 ; 90 #endif /* DEBUGGING */ 91 92 #define MkLower(ch) (isupper(ch) ? tolower(ch) : ch) 93 #define MkUpper(ch) (islower(ch) ? toupper(ch) : ch) 94 #define Set_LineNum(ln) {Debug(DPARS|DEXT,("linenum=%d\n",ln)); \ 95 LineNumber = ln; \ 96 } 97 98 #ifdef HAVE_TM_GMTOFF 99 #define get_gmtoff(c, t) (t->tm_gmtoff) 100 #endif 101 102 #define SECONDS_PER_MINUTE 60 103 104 #define FIRST_MINUTE 0 105 #define LAST_MINUTE 59 106 #define MINUTE_COUNT (LAST_MINUTE - FIRST_MINUTE + 1) 107 108 #define FIRST_HOUR 0 109 #define LAST_HOUR 23 110 #define HOUR_COUNT (LAST_HOUR - FIRST_HOUR + 1) 111 112 #define FIRST_DOM 1 113 #define LAST_DOM 31 114 #define DOM_COUNT (LAST_DOM - FIRST_DOM + 1) 115 116 #define FIRST_MONTH 1 117 #define LAST_MONTH 12 118 #define MONTH_COUNT (LAST_MONTH - FIRST_MONTH + 1) 119 120 /* note on DOW: 0 and 7 are both Sunday, for compatibility reasons. */ 121 #define FIRST_DOW 0 122 #define LAST_DOW 7 123 #define DOW_COUNT (LAST_DOW - FIRST_DOW + 1) 124 125 /* each user's crontab will be held as a list of 126 * the following structure. 127 * 128 * These are the cron commands. 129 */ 130