Mercurial > bday
view birthday.h @ 5:5af6bf2cb271
reads only stdin now, no files anymore; removed -f option aswell; code beatifing
author | meillo@marmaro.de |
---|---|
date | Mon, 17 Dec 2007 15:09:03 +0100 |
parents | 5326c222cd4e |
children | fc6e40f7bd5a |
line wrap: on
line source
/* birthday Birthday/Anniversary display on login (c) 1996 AS Mortimer This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. You may also distribute it under the Artistic License, as comes with Perl. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA You should also have recieved a copy of the Artistic license with this program. $Id: birthday.h,v 1.6 1999/04/25 14:01:29 andy Exp $ */ #include <stdio.h> /* ========== Configuration section */ /* standard time to warn in advance, when no explicit w flag is given. */ #define DEF_WARN 14 /* ========== Global constants and data types */ /* month lengths etc */ #define isleapyear(y) ((y)%4==0 && ((y)%100 != 0 || (y)%400 == 0)) extern const unsigned MLENDAT[]; #define mlen(m,y) (MLENDAT[(m)-1] != -1 ? MLENDAT[(m)-1] : (isleapyear((y)) ? 29 : 28)) #define before(a,b) ((a).month < (b).month || ((a).month == (b).month && (a).day < (b).day)) #define ydelta(a,b) ((int) (b).year - (a).year + before((a),(b))) /* -------- modifier flags */ #define F_MTYPE 0x07 #define F_TBIRTHDAY 1 #define F_TANNIVERSARY 2 #define F_TEVENT 3 /* flags processed immediately on encountering */ #define F_MIMMEDIATE 0x24 #define F_WTIME_P 0x08 #define F_FORDAYS 0x16 #define F_TODATE 0x24 struct _ftable {char *txt; unsigned flag;}; extern const struct _ftable FTABLE[]; struct date { unsigned day; unsigned month; unsigned year; }; struct event { char *text; struct date date; struct date enddate; int warn; }; typedef int (*prnfunc)(const char *); /* ========== */ struct event* readlist(void); void gettoday(void); unsigned delta(struct date *); unsigned ddiff(struct date *D1, struct date *D2); void liststrings(struct event *evl, prnfunc outf); char *tdelta(struct date *d); char *ttime(int yr, int mn, int wk, int dy); /* ========== Global Variables */ extern struct date today; extern int iDWarn;