bday

view birthday.h @ 3:dc2f94280b01

new Makefile; removed MinWarn and MaxWarn; adjusted manpage
author meillo@marmaro.de
date Mon, 17 Dec 2007 11:28:40 +0100
parents 22b6e71de68e
children 5326c222cd4e
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)))
49 #define warnperiod(ev) ( (ev).warn )
51 /* -------- modifier flags */
53 #define F_MTYPE 0x07
54 #define F_TBIRTHDAY 1
55 #define F_TANNIVERSARY 2
56 #define F_TEVENT 3
57 #define F_TMESSAGE 4
59 /* flags processed immediately on encountering */
60 #define F_MIMMEDIATE 0x24
61 #define F_WTIME_P 0x08
62 #define F_FORDAYS 0x16
63 #define F_TODATE 0x24
65 struct _ftable {char *txt; unsigned flag;};
67 extern const struct _ftable FTABLE[];
69 struct date {
70 unsigned day;
71 unsigned month;
72 unsigned year;
73 };
75 struct event {
76 char *text;
77 struct date date;
78 struct date enddate;
79 int warn;
80 };
82 typedef int (*prnfunc)(const char *);
84 /* ========== */
86 struct event *readlist(char *fname);
87 void gettoday(void);
88 unsigned delta(struct date *);
89 unsigned ddiff(struct date *D1, struct date *D2);
90 void liststrings(struct event *evl, prnfunc outf);
91 char *tdelta(struct date *d);
92 char *ttime(int yr, int mn, int wk, int dy);
94 /* ========== Global Variables */
96 extern struct date today;
97 extern int iDWarn;