1 /* $OpenBSD: calendar.h,v 1.11 2004/12/10 20:47:30 mickey Exp $ */ 2 3 /* 4 * Copyright (c) 1989, 1993, 1994 5 * The Regents of the University of California. All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 1. Redistributions of source code must retain the above copyright 11 * notice, this list of conditions and the following disclaimer. 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 3. Neither the name of the University nor the names of its contributors 16 * may be used to endorse or promote products derived from this software 17 * without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29 * SUCH DAMAGE. 30 */ 31 32 33 extern struct passwd *pw; 34 extern int doall; 35 extern int bodun_always; 36 extern time_t f_time; 37 extern struct iovec header[]; 38 extern struct tm *tp; 39 extern char *calendarFile; 40 extern char *calendarHome; 41 extern char *optarg; 42 43 struct fixs { 44 char *name; 45 int len; 46 }; 47 48 struct event { 49 time_t when; 50 char print_date[31]; 51 char **desc; 52 char *ldesc; 53 struct event *next; 54 }; 55 56 struct match { 57 time_t when; 58 char print_date[30]; 59 int bodun; 60 int var; 61 struct match *next; 62 }; 63 64 struct specialev { 65 char *name; 66 int nlen; 67 char *uname; 68 int ulen; 69 int (*getev)(int); 70 }; 71 72 void cal(void); 73 void closecal(FILE *); 74 int getday(char *); 75 int getdayvar(char *); 76 int getfield(char *, char **, int *); 77 int getmonth(char *); 78 int pesach(int); 79 int easter(int); 80 int paskha(int); 81 void insert(struct event **, struct event *); 82 struct match *isnow(char *, int); 83 FILE *opencal(void); 84 void settime(time_t *); 85 time_t Mktime(char *); 86 void usage(void); 87 int foy(int); 88 void variable_weekday(int *, int, int); 89 void setnnames(void); 90 91 /* some flags */ 92 #define F_ISMONTH 0x01 /* month (Januar ...) */ 93 #define F_ISDAY 0x02 /* day of week (Sun, Mon, ...) */ 94 /*#define F_ISDAYVAR 0x04 variables day of week, like SundayLast */ 95 #define F_SPECIAL 0x08 /* Events that occur once a year but don't track 96 * calendar time--e.g. Easter or easter depending 97 * days */ 98 99 extern int f_dayAfter; /* days after current date */ 100 extern int f_dayBefore; /* days before current date */ 101 102 /* Special events; see also setnnames() in day.c */ 103 /* '=' is not a valid character in a special event name */ 104 #define PESACH "pesach" 105 #define PESACHLEN (sizeof(PESACH) - 1) 106 #define EASTER "easter" 107 #define EASTERNAMELEN (sizeof(EASTER) - 1) 108 #define PASKHA "paskha" 109 #define PASKHALEN (sizeof(PASKHA) - 1) 110 111 /* calendars */ 112 extern enum calendars { GREGORIAN = 0, JULIAN, LUNAR } calendar; 113 extern u_long julian; 114 115 #define NUMEV 3 /* Total number of such special events */ 116 extern struct specialev spev[NUMEV]; 117 118 /* For calendar -a, specify a maximum time (in seconds) to spend parsing 119 * each user's calendar files. This prevents them from hanging calendar 120 * (e.g. by using named pipes) 121 */ 122 #define USERTIMEOUT 20 123