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