bday

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/birthday.h	Sun Dec 16 22:26:48 2007 +0100
     1.3 @@ -0,0 +1,104 @@
     1.4 +/*
     1.5 +   birthday
     1.6 +
     1.7 +   Birthday/Anniversary display on login
     1.8 +
     1.9 +   (c) 1996 AS Mortimer
    1.10 +
    1.11 +    This program is free software; you can redistribute it and/or
    1.12 +    modify it under the terms of the GNU General Public License as
    1.13 +    published by the Free Software Foundation; either version 2 of the
    1.14 +    License, or (at your option) any later version.  You may also
    1.15 +    distribute it under the Artistic License, as comes with Perl.
    1.16 +
    1.17 +    This program is distributed in the hope that it will be useful,
    1.18 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.19 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    1.20 +
    1.21 +    You should have received a copy of the GNU General Public License
    1.22 +    along with this program; if not, write to the Free Software
    1.23 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    1.24 +
    1.25 +    You should also have recieved a copy of the Artistic license with
    1.26 +    this program.
    1.27 +
    1.28 +   $Id: birthday.h,v 1.6 1999/04/25 14:01:29 andy Exp $
    1.29 +*/
    1.30 +
    1.31 +/* ========== Configuration section */
    1.32 +
    1.33 +#define DEFAULT_FILE ".birthdays"
    1.34 +
    1.35 +/* standard time to warn in advance, when no explicit w flag is given. */
    1.36 +#define DEF_WARN 21
    1.37 +/* maximum time to warn in advance when no M flag is given */
    1.38 +#define MAX_WARN 500 /* ie, a year */
    1.39 +/* minimum time to warn in advance when no m flag */
    1.40 +#define MIN_WARN 0
    1.41 +
    1.42 +/* ========== Required includes */
    1.43 +
    1.44 +#include <stdio.h>
    1.45 +
    1.46 +/* ========== Global constants and data types */
    1.47 +
    1.48 +
    1.49 +/* month lengths etc */
    1.50 +
    1.51 +#define isleapyear(y) ((y)%4==0 && ((y)%100 != 0 || (y)%400 == 0))
    1.52 +extern const unsigned MLENDAT[];
    1.53 +#define mlen(m,y) (MLENDAT[(m)-1] != -1 ? MLENDAT[(m)-1] : (isleapyear((y)) ? 29 : 28))
    1.54 +#define before(a,b) ((a).month < (b).month || ((a).month == (b).month && (a).day < (b).day))
    1.55 +#define ydelta(a,b) ((int) (b).year - (a).year + before((a),(b)))
    1.56 +#define warnperiod(ev) ((ev).warn<iMinWarn?iMinWarn:((ev).warn>iMaxWarn?iMaxWarn:(ev).warn))
    1.57 +
    1.58 +/* -------- modifier flags */
    1.59 +
    1.60 +#define F_MTYPE 0x07
    1.61 +#define F_TBIRTHDAY 1
    1.62 +#define F_TANNIVERSARY 2
    1.63 +#define F_TEVENT 3
    1.64 +#define F_TMESSAGE 4
    1.65 +
    1.66 +/* flags processed immediately on encountering */
    1.67 +#define F_MIMMEDIATE 0x24
    1.68 +#define F_WTIME_P 0x08
    1.69 +#define F_FORDAYS 0x16
    1.70 +#define F_TODATE 0x24
    1.71 +
    1.72 +struct _ftable {char *txt; unsigned flag;};
    1.73 +
    1.74 +extern const struct _ftable FTABLE[];
    1.75 +
    1.76 +struct date {
    1.77 +  unsigned day;
    1.78 +  unsigned month;
    1.79 +  unsigned year;
    1.80 +};
    1.81 +
    1.82 +struct event {
    1.83 +  char *text;
    1.84 +  struct date date;
    1.85 +  struct date enddate;
    1.86 +  int warn;
    1.87 +};
    1.88 +
    1.89 +typedef int (*prnfunc)(const char *);
    1.90 +
    1.91 +/* ========== */
    1.92 +
    1.93 +struct event *readlist(char *fname);
    1.94 +void gettoday(void);
    1.95 +unsigned delta(struct date *);
    1.96 +unsigned ddiff(struct date *D1, struct date *D2);
    1.97 +void liststrings(struct event *evl, prnfunc outf);
    1.98 +char *tdelta(struct date *d);
    1.99 +char *ttime(int yr, int mn, int wk, int dy);
   1.100 +
   1.101 +/* ========== Global Variables */
   1.102 +
   1.103 +extern struct date today;
   1.104 +extern int iDWarn;
   1.105 +extern int iMaxWarn;
   1.106 +extern int iMinWarn;
   1.107 +