bday

view 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
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
34 /* maximum time to warn in advance when no M flag is given */
35 #define MAX_WARN 500 /* ie, a year */
36 /* minimum time to warn in advance when no m flag */
37 #define MIN_WARN 0
39 /* ========== Required includes */
41 #include <stdio.h>
43 /* ========== Global constants and data types */
46 /* month lengths etc */
48 #define isleapyear(y) ((y)%4==0 && ((y)%100 != 0 || (y)%400 == 0))
49 extern const unsigned MLENDAT[];
50 #define mlen(m,y) (MLENDAT[(m)-1] != -1 ? MLENDAT[(m)-1] : (isleapyear((y)) ? 29 : 28))
51 #define before(a,b) ((a).month < (b).month || ((a).month == (b).month && (a).day < (b).day))
52 #define ydelta(a,b) ((int) (b).year - (a).year + before((a),(b)))
53 #define warnperiod(ev) ((ev).warn<iMinWarn?iMinWarn:((ev).warn>iMaxWarn?iMaxWarn:(ev).warn))
55 /* -------- modifier flags */
57 #define F_MTYPE 0x07
58 #define F_TBIRTHDAY 1
59 #define F_TANNIVERSARY 2
60 #define F_TEVENT 3
61 #define F_TMESSAGE 4
63 /* flags processed immediately on encountering */
64 #define F_MIMMEDIATE 0x24
65 #define F_WTIME_P 0x08
66 #define F_FORDAYS 0x16
67 #define F_TODATE 0x24
69 struct _ftable {char *txt; unsigned flag;};
71 extern const struct _ftable FTABLE[];
73 struct date {
74 unsigned day;
75 unsigned month;
76 unsigned year;
77 };
79 struct event {
80 char *text;
81 struct date date;
82 struct date enddate;
83 int warn;
84 };
86 typedef int (*prnfunc)(const char *);
88 /* ========== */
90 struct event *readlist(char *fname);
91 void gettoday(void);
92 unsigned delta(struct date *);
93 unsigned ddiff(struct date *D1, struct date *D2);
94 void liststrings(struct event *evl, prnfunc outf);
95 char *tdelta(struct date *d);
96 char *ttime(int yr, int mn, int wk, int dy);
98 /* ========== Global Variables */
100 extern struct date today;
101 extern int iDWarn;
102 extern int iMaxWarn;
103 extern int iMinWarn;