meillo@0: /* meillo@0: birthday meillo@0: meillo@0: Birthday/Anniversary display on login meillo@0: meillo@0: (c) 1996 AS Mortimer meillo@0: meillo@0: This program is free software; you can redistribute it and/or meillo@0: modify it under the terms of the GNU General Public License as meillo@0: published by the Free Software Foundation; either version 2 of the meillo@0: License, or (at your option) any later version. You may also meillo@0: distribute it under the Artistic License, as comes with Perl. meillo@0: meillo@0: This program is distributed in the hope that it will be useful, meillo@0: but WITHOUT ANY WARRANTY; without even the implied warranty of meillo@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. meillo@0: meillo@0: You should have received a copy of the GNU General Public License meillo@0: along with this program; if not, write to the Free Software meillo@0: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA meillo@0: meillo@0: You should also have recieved a copy of the Artistic license with meillo@0: this program. meillo@0: meillo@0: $Id: birthday.h,v 1.6 1999/04/25 14:01:29 andy Exp $ meillo@0: */ meillo@0: meillo@0: /* ========== Configuration section */ meillo@0: meillo@0: #define DEFAULT_FILE ".birthdays" meillo@0: meillo@0: /* standard time to warn in advance, when no explicit w flag is given. */ meillo@0: #define DEF_WARN 21 meillo@0: /* maximum time to warn in advance when no M flag is given */ meillo@0: #define MAX_WARN 500 /* ie, a year */ meillo@0: /* minimum time to warn in advance when no m flag */ meillo@0: #define MIN_WARN 0 meillo@0: meillo@0: /* ========== Required includes */ meillo@0: meillo@0: #include meillo@0: meillo@0: /* ========== Global constants and data types */ meillo@0: meillo@0: meillo@0: /* month lengths etc */ meillo@0: meillo@0: #define isleapyear(y) ((y)%4==0 && ((y)%100 != 0 || (y)%400 == 0)) meillo@0: extern const unsigned MLENDAT[]; meillo@0: #define mlen(m,y) (MLENDAT[(m)-1] != -1 ? MLENDAT[(m)-1] : (isleapyear((y)) ? 29 : 28)) meillo@0: #define before(a,b) ((a).month < (b).month || ((a).month == (b).month && (a).day < (b).day)) meillo@0: #define ydelta(a,b) ((int) (b).year - (a).year + before((a),(b))) meillo@0: #define warnperiod(ev) ((ev).warniMaxWarn?iMaxWarn:(ev).warn)) meillo@0: meillo@0: /* -------- modifier flags */ meillo@0: meillo@0: #define F_MTYPE 0x07 meillo@0: #define F_TBIRTHDAY 1 meillo@0: #define F_TANNIVERSARY 2 meillo@0: #define F_TEVENT 3 meillo@0: #define F_TMESSAGE 4 meillo@0: meillo@0: /* flags processed immediately on encountering */ meillo@0: #define F_MIMMEDIATE 0x24 meillo@0: #define F_WTIME_P 0x08 meillo@0: #define F_FORDAYS 0x16 meillo@0: #define F_TODATE 0x24 meillo@0: meillo@0: struct _ftable {char *txt; unsigned flag;}; meillo@0: meillo@0: extern const struct _ftable FTABLE[]; meillo@0: meillo@0: struct date { meillo@0: unsigned day; meillo@0: unsigned month; meillo@0: unsigned year; meillo@0: }; meillo@0: meillo@0: struct event { meillo@0: char *text; meillo@0: struct date date; meillo@0: struct date enddate; meillo@0: int warn; meillo@0: }; meillo@0: meillo@0: typedef int (*prnfunc)(const char *); meillo@0: meillo@0: /* ========== */ meillo@0: meillo@0: struct event *readlist(char *fname); meillo@0: void gettoday(void); meillo@0: unsigned delta(struct date *); meillo@0: unsigned ddiff(struct date *D1, struct date *D2); meillo@0: void liststrings(struct event *evl, prnfunc outf); meillo@0: char *tdelta(struct date *d); meillo@0: char *ttime(int yr, int mn, int wk, int dy); meillo@0: meillo@0: /* ========== Global Variables */ meillo@0: meillo@0: extern struct date today; meillo@0: extern int iDWarn; meillo@0: extern int iMaxWarn; meillo@0: extern int iMinWarn; meillo@0: