# HG changeset patch # User meillo@marmaro.de # Date 1197887320 -3600 # Node ID dc2f94280b01c977e3beadcf06884e7ab00bb010 # Parent 9ec037775c3808fa1e3cfca79de2ba41b2f54982 new Makefile; removed MinWarn and MaxWarn; adjusted manpage diff -r 9ec037775c38 -r dc2f94280b01 Makefile --- a/Makefile Mon Dec 17 08:02:15 2007 +0100 +++ b/Makefile Mon Dec 17 11:28:40 2007 +0100 @@ -1,34 +1,80 @@ -###################################################################### -# birthday. Reminder of birthdays and other events in the near future. -# $Id: Makefile.in,v 1.3 2000/01/02 19:17:33 andy Exp $ +# bday by meillo@marmaro.de +NAME=bday +VERSION = 0.1 +NV=${NAME}-${VERSION} + +DOCS=COPYRIGHT ChangeLog TODO + +# paths +PREFIX = /usr +BINDIR = ${PREFIX}/bin +MANDIR = ${PREFIX}/share/man + +SRC=birthday.c bdengine.c +OBJ=$(SRC:.c=.o) + CFLAGS=-O2 -Wall -Wstrict-prototypes +all: + @echo usage: make [un]install -SRC=birthday.c bdengine.c -OBJ=$(SRC:.c=.o) -EXE=bday +build: ${NAME} -all: ${EXE} - -${EXE}: $(OBJ) +${NAME}: $(OBJ) $(CC) $(LDFLAGS) $(OBJ) -o $@ +dist: build changelog + @mkdir -p ${NV} + @cp -f ${NAME} ${NAME}.1 Makefile ${DOCS} ${NV} + @tar -czhof ${NV}.tar.gz ${NV} + @rm -rf ${NV} -install: all - @echo "installing program in $(DESTDIR)/usr/bin" - mkdir -p $(DESTDIR)/usr/bin - cp ${EXE} $(DESTDIR)/usr/bin/${EXE} - chmod 0755 $(DESTDIR)/usr/bin/${EXE} - @echo "installing manpage in $(DESTDIR)/usr/share/man/man1" - mkdir -p $(DESTDIR)/usr/share/man/man1 - cp ${EXE}.1 $(DESTDIR)/usr/share/man/man1/${EXE}.1 - chmod 0644 $(DESTDIR)/usr/share/man/man1/${EXE}.1 +deb: dist + @mkdir -p Packages + @cp ${NV}.tar.gz Packages/ + @( \ + cd Packages/ ;\ + tar -xzf ${NV}.tar.gz ;\ + mv ${NV}.tar.gz ${NAME}_${VERSION}.orig.tar.gz ;\ + cd ${NV}/ ;\ + cp -r ../../debian/ . ;\ + debuild ;\ + ) + +changelog: + @echo generating changelog from mercurial log + @hg log -v --style changelog > ChangeLog + +install: + @echo installing executable file to ${DESTDIR}${BINDIR} + @mkdir -p ${DESTDIR}${BINDIR} + @cp ${NAME} ${DESTDIR}${BINDIR} + @chmod 755 ${DESTDIR}${BINDIR}/${NAME} + @echo installing manual page to ${DESTDIR}${MANDIR}/man1 + @mkdir -p ${DESTDIR}${MANDIR}/man1 + @sed 's/VERSION/${VERSION}/g' < ${NAME}.1 > ${DESTDIR}${MANDIR}/man1/${NAME}.1 + @chmod 644 ${DESTDIR}${MANDIR}/man1/${NAME}.1 + +uninstall: + @echo removing executable file from ${DESTDIR}${BINDIR} + @rm -f ${DESTDIR}${BINDIR}/${NAME} + @echo removing manual page from ${DESTDIR}${MANDIR}/man1 + @rm -f ${DESTDIR}${MANDIR}/man1/${NAME}.1 clean: rm -f *.o realclean: clean - rm -f ${EXE} + rm -f ${NAME} + +distclean: realclean + @rm -f ${NAME}-*.tar.gz ChangeLog + +debclean: distclean + @cd Packages/${NV}/ ; debuild clean ; + + +.PHONY: all dist deb changelog clean distclean debclean build install uninstall diff -r 9ec037775c38 -r dc2f94280b01 bday.1 --- a/bday.1 Mon Dec 17 08:02:15 2007 +0100 +++ b/bday.1 Mon Dec 17 11:28:40 2007 +0100 @@ -6,10 +6,6 @@ .IR file ] .RB [ -W .IR defwarn ] -.RB [ -M -.IR maxwarn ] -.RB [ -m -.IR minwarn ] .SH DESCRIPTION The @@ -33,8 +29,6 @@ is a single hyphen, read the events from the standard input (usually the terminal). -.SS List Options - .TP .BI -W\ warn Warn @@ -44,32 +38,13 @@ flag (see .BR FILE\ FORMAT ). If this switch is not specified, it defaults to 21 days. -.TP -.BI -M\ max -Warn at most -.I max -days in advance. This overrides any flag given in the file. -.TP -.BI -m\ min -Warn at least -.I min -days in advance. This overrides any flag given in the file. .SH FILE FORMAT Each line beginning with a hash sign, .RB ` # ', -is a comment and will be ignored. Lines beginning with an ampersand, -.RB ` & ', -are directives. Currently there is only one such directive, -.B &include -.IR file , -which reads in a seperate file from your -.I .birthdays -file. -.I file -should be given with an absolute path, which should not use the tilde notation to specify your home directory. +is a comment and will be ignored. Any other line specifies the name of a person or event, followed by an equals sign and a date and finally some extra options. The date has to be in ISO 8601 date format (YYYY-MM-DD). diff -r 9ec037775c38 -r dc2f94280b01 bdengine.c --- a/bdengine.c Mon Dec 17 08:02:15 2007 +0100 +++ b/bdengine.c Mon Dec 17 11:28:40 2007 +0100 @@ -82,8 +82,8 @@ $Id: xmalloc.c,v 1.2 1999/01/16 17:08:59 andy Exp $ */ -void *xmalloc (size_t size) { - register void *value = malloc (size); +void* xmalloc (size_t size) { + register void* value = malloc (size); if (value == 0) { fprintf(stderr, "virtual memory exhausted\n"); exit(1); @@ -92,8 +92,8 @@ } -void *xrealloc (void *ptr, size_t size) { - register void *value = realloc (ptr, size); +void* xrealloc (void* ptr, size_t size) { + register void* value = realloc (ptr, size); if (value == 0) { fprintf(stderr, "virtual memory exhausted\n"); exit(1); @@ -112,14 +112,11 @@ int evcmp(const void *e1, const void *e2); char *deffname(void); -/*struct event *dir_include(char *dir, char *parm);*/ /* ========== Global variables */ struct date today; int iDWarn = DEF_WARN; -int iMaxWarn = MAX_WARN; -int iMinWarn = MIN_WARN; const unsigned MLENDAT[]={31,-1,31,30,31,30,31,31,30,31,30,31}; @@ -290,7 +287,7 @@ if (evl[i].warn == -1 && delta(&(evl[i].date))==0) { append(buf, evl[i].text); } else if (evl[i].enddate.day == 0) { - if (delta(&(evl[i].date)) <= warnperiod(evl[i])) { + if (delta(&(evl[i].date)) <= evl[i].warn) { append(buf, evl[i].text); append(buf, " "); tmp = tdelta(&(evl[i].date)); @@ -298,7 +295,7 @@ free(tmp); } } else { - if (delta(&(evl[i].date)) <= warnperiod(evl[i])) { + if (delta(&(evl[i].date)) <= evl[i].warn) { append(buf, evl[i].text); append(buf, " for "); /* +1 because, if the difference between two dates is one day, @@ -310,7 +307,7 @@ append(buf, " "); tmp = tdelta(&(evl[i].date)); append(buf, tmp); - } else if (delta(&(evl[i].enddate)) <= warnperiod(evl[i])) { + } else if (delta(&(evl[i].enddate)) <= evl[i].warn) { append(buf, evl[i].text); append(buf, " "); j = delta(&(evl[i].enddate)); diff -r 9ec037775c38 -r dc2f94280b01 birthday.c --- a/birthday.c Mon Dec 17 08:02:15 2007 +0100 +++ b/birthday.c Mon Dec 17 11:28:40 2007 +0100 @@ -36,7 +36,6 @@ { char* fname = NULL; struct event *evl; /* evl => event list */ - char* opt = NULL; while (--argc > 0 && (*++argv)[0] == '-') { if (strcmp(argv[0], "-f") == 0) { @@ -45,14 +44,8 @@ } else if (strcmp(argv[0], "-W") == 0) { iDWarn = atoi((++argv)[0]); argc--; - } else if (strcmp(argv[0], "-M") == 0) { - iMaxWarn = atoi((++argv)[0]); - argc--; - } else if (strcmp(argv[0], "-m") == 0) { - iMinWarn = atoi((++argv)[0]); - argc--; } else { - fprintf(stderr, "unknown option %s\n", opt); + fprintf(stderr, "unknown option %s\n", argv[0]); exit(1); } } diff -r 9ec037775c38 -r dc2f94280b01 birthday.h --- a/birthday.h Mon Dec 17 08:02:15 2007 +0100 +++ b/birthday.h Mon Dec 17 11:28:40 2007 +0100 @@ -31,10 +31,6 @@ /* standard time to warn in advance, when no explicit w flag is given. */ #define DEF_WARN 21 -/* maximum time to warn in advance when no M flag is given */ -#define MAX_WARN 500 /* ie, a year */ -/* minimum time to warn in advance when no m flag */ -#define MIN_WARN 0 /* ========== Required includes */ @@ -50,7 +46,7 @@ #define mlen(m,y) (MLENDAT[(m)-1] != -1 ? MLENDAT[(m)-1] : (isleapyear((y)) ? 29 : 28)) #define before(a,b) ((a).month < (b).month || ((a).month == (b).month && (a).day < (b).day)) #define ydelta(a,b) ((int) (b).year - (a).year + before((a),(b))) -#define warnperiod(ev) ((ev).warniMaxWarn?iMaxWarn:(ev).warn)) +#define warnperiod(ev) ( (ev).warn ) /* -------- modifier flags */ @@ -99,6 +95,4 @@ extern struct date today; extern int iDWarn; -extern int iMaxWarn; -extern int iMinWarn;