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