bday

view birthday.h @ 6:fc6e40f7bd5a

minor stuff
author meillo@marmaro.de
date Mon, 17 Dec 2007 16:31:40 +0100
parents 5af6bf2cb271
children
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 #include <stdio.h>
30 /* ========== Configuration section */
32 /* standard time to warn in advance, when no explicit w flag is given. */
33 #define DEF_WARN 14
35 /* ========== Global constants and data types */
38 /* month lengths etc */
40 #define isleapyear(y) ((y)%4==0 && ((y)%100 != 0 || (y)%400 == 0))
41 extern const unsigned MLENDAT[];
42 #define mlen(m,y) (MLENDAT[(m)-1] != -1 ? MLENDAT[(m)-1] : (isleapyear((y)) ? 29 : 28))
43 #define before(a,b) ((a).month < (b).month || ((a).month == (b).month && (a).day < (b).day))
44 #define ydelta(a,b) ((int) (b).year - (a).year + before((a),(b)))
46 /* -------- modifier flags */
48 #define F_MTYPE 0x07
49 #define F_TBIRTHDAY 1
50 #define F_TANNIVERSARY 2
51 #define F_TEVENT 3
53 /* flags processed immediately on encountering */
54 #define F_MIMMEDIATE 0x24
55 #define F_WTIME_P 0x08
56 #define F_FORDAYS 0x16
57 #define F_TODATE 0x24
59 struct _ftable {char *txt; unsigned flag;};
61 extern const struct _ftable FTABLE[];
63 struct date {
64 unsigned day;
65 unsigned month;
66 unsigned year;
67 };
69 struct event {
70 char *text;
71 struct date date;
72 struct date enddate;
73 int warn;
74 };
76 typedef int (*prnfunc)(const char *);
78 /* ========== */
80 struct event* readlist(void);
81 void gettoday(void);
82 unsigned delta(struct date *);
83 unsigned ddiff(struct date *D1, struct date *D2);
84 void liststrings(struct event* evl, prnfunc outf);
85 char *tdelta(struct date *d);
86 char *ttime(int yr, int mn, int wk, int dy);
88 /* ========== Global Variables */
90 extern struct date today;
91 extern int iDWarn;