bday

view birthday.h @ 4:5326c222cd4e

removed MESSAGE; code beautifing workaround for MESSAGE: use an event with warn 0 (message=yyyy-mm-dd w 0)
author meillo@marmaro.de
date Mon, 17 Dec 2007 12:14:41 +0100
parents dc2f94280b01
children 5af6bf2cb271
line source
1 /*
2 birthday
4 Birthday/Anniversary display on login
6 (c) 1996 AS Mortimer
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License as
10 published by the Free Software Foundation; either version 2 of the
11 License, or (at your option) any later version. You may also
12 distribute it under the Artistic License, as comes with Perl.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 You should also have recieved a copy of the Artistic license with
23 this program.
25 $Id: birthday.h,v 1.6 1999/04/25 14:01:29 andy Exp $
26 */
28 /* ========== Configuration section */
30 #define DEFAULT_FILE ".birthdays"
32 /* standard time to warn in advance, when no explicit w flag is given. */
33 #define DEF_WARN 21
35 /* ========== Required includes */
37 #include <stdio.h>
39 /* ========== Global constants and data types */
42 /* month lengths etc */
44 #define isleapyear(y) ((y)%4==0 && ((y)%100 != 0 || (y)%400 == 0))
45 extern const unsigned MLENDAT[];
46 #define mlen(m,y) (MLENDAT[(m)-1] != -1 ? MLENDAT[(m)-1] : (isleapyear((y)) ? 29 : 28))
47 #define before(a,b) ((a).month < (b).month || ((a).month == (b).month && (a).day < (b).day))
48 #define ydelta(a,b) ((int) (b).year - (a).year + before((a),(b)))
50 /* -------- modifier flags */
52 #define F_MTYPE 0x07
53 #define F_TBIRTHDAY 1
54 #define F_TANNIVERSARY 2
55 #define F_TEVENT 3
57 /* flags processed immediately on encountering */
58 #define F_MIMMEDIATE 0x24
59 #define F_WTIME_P 0x08
60 #define F_FORDAYS 0x16
61 #define F_TODATE 0x24
63 struct _ftable {char *txt; unsigned flag;};
65 extern const struct _ftable FTABLE[];
67 struct date {
68 unsigned day;
69 unsigned month;
70 unsigned year;
71 };
73 struct event {
74 char *text;
75 struct date date;
76 struct date enddate;
77 int warn;
78 };
80 typedef int (*prnfunc)(const char *);
82 /* ========== */
84 struct event *readlist(char *fname);
85 void gettoday(void);
86 unsigned delta(struct date *);
87 unsigned ddiff(struct date *D1, struct date *D2);
88 void liststrings(struct event *evl, prnfunc outf);
89 char *tdelta(struct date *d);
90 char *ttime(int yr, int mn, int wk, int dy);
92 /* ========== Global Variables */
94 extern struct date today;
95 extern int iDWarn;