1 /* $OpenBSD: macros.h,v 1.6 2004/06/17 22:11:55 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 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 64 #define PPC_NULL ((const char **)NULL) 65 66 #ifndef MAXHOSTNAMELEN 67 #define MAXHOSTNAMELEN 64 68 #endif 69 70 #define Skip_Blanks(c, f) \ 71 while (c == '\t' || c == ' ') \ 72 c = get_char(f); 73 74 #define Skip_Nonblanks(c, f) \ 75 while (c!='\t' && c!=' ' && c!='\n' && c != EOF) \ 76 c = get_char(f); 77 78 #if DEBUGGING 79 # define Debug(mask, message) \ 80 if (DebugFlags & (mask)) \ 81 printf message; 82 #else /* !DEBUGGING */ 83 # define Debug(mask, message) \ 84 ; 85 #endif /* DEBUGGING */ 86 87 #define MkUpper(ch) (islower(ch) ? toupper(ch) : ch) 88 #define Set_LineNum(ln) {Debug(DPARS|DEXT,("linenum=%d\n",ln)); \ 89 LineNumber = ln; \ 90 } 91 92 /* Data values used on cron socket */ 93 #define RELOAD_CRON 0x2 94 #define RELOAD_AT 0x4 95 96 #ifdef HAVE_TM_GMTOFF 97 #define get_gmtoff(c, t) ((t)->tm_gmtoff) 98 #endif 99 100 #define SECONDS_PER_MINUTE 60 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