annotate birthday.h @ 0:22b6e71de68e

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