calendar.c:

- fixed a bug introduced in 1.1 where getting an error while
          reading the calandar file could cause an infinite loop
        - added "ChangeLog" comments for all versions
	- added stack checking
        - eliminated "pragma stacksize" from the source file; it was too
          small (was 512 bytes, currently using 862 bytes) and overriding
          the value given on the command line during the GNO base build
          process
README, calendar.info:
	- Moved the information in these files to the man page.
Makefile, calendar.rez:
	- initial checkin
calendar.1:
	- cleaned it up a bit and made it conform to the GNO base builds
	- added an example
This commit is contained in:
gdr-ftp 1998-07-07 02:14:30 +00:00
parent b40c451852
commit 3689484d24
6 changed files with 135 additions and 35 deletions

View File

@ -0,0 +1,9 @@
#
# $Id: Makefile,v 1.1 1998/07/07 02:14:29 gdr-ftp Exp $
#
PROG = calendar
BINDIR = /usr/games
STACK = 1024 # observed: 862
.INCLUDE: /src/gno/prog.mk

View File

@ -1,4 +0,0 @@
To install the calendar program, create a file called "Calendar" in your
home directory, and put a line:
:bin:calendar
in your "gshrc" file.

View File

@ -1,25 +1,61 @@
.TH CALENDAR 1 "June 30, 1998"
.SH NAME
.\"
.\" $Id: calendar.1,v 1.3 1998/07/07 02:14:29 gdr-ftp Exp $
.\"
.TH CALENDAR 1 "6 July 1998" GNO "Commands and Applications"
.SH NAME
.BR calendar
\- reminder service
.SH SYNOPSIS
.SH SYNOPSIS
calendar
.SH DESCRIPTION
.SH DESCRIPTION
.BR calendar
consults the file calendar in the current directory
consults the file
.B calendar
in the current directory
and prints out lines that contain today's or tomorrow's date
anywhere in the line. Most reasonable month-day dates such as
Aug. 24, august 24, 8/24, and so on, are recognized, but not
24 August or 24/8. On weekends ``tomorrow'' extends through
Monday.
.IR "Aug. 24" ,
.IR "august 24" ,
.IR "8/24",
and so on, are recognized, but not
.IR "24 August"
or
.IR "24/8" .
On weekends ``tomorrow'' extends through Monday.
.BR calendar
can be invoked regularly by using the
crontab(1) or at(1) commands.
.SH REFERENCES
at(1), cron(1M), crontab(1), date(1)
.SH NOTICES
.BR calendar's
extended idea of ``tomorrow'' does not account for
holidays.
.BR crontab (1)
or
.BR at (1)
commands.
.SH EXAMPLE
A common way to run
.BR calendar
is to have the following line in your
.B gshrc
file:
.nf
/usr/games/calendar
.fi
If the file $HOME/calendar contains entries like
.nf
Dec 25 No more shopping days until Christmas.
Jul 1 Dominion Day (Canada).
.fi
then the appropriate calendar entries will be printed every time you
login in.
.SH CAVEATS
.BR calendar 's
extended idea of ``tomorrow'' does not account for holidays.
.SH "SEE ALSO"
.BR at (1),
.BR cron (1),
.BR crontab (1),
.BR date (1)
.SH AUTHOR
Written for GNO by Christopher Neufeld.
Updated by Marlin Allred.

View File

@ -1,6 +1,32 @@
/* Calendar file v1.0. Copyright 1994 by Christopher Neufeld */
/* The executable for this file contains linked runtime libraries
copyrighted by The Byte Works. Used with permission. */
/*
* Calendar file v1.0. Copyright 1994-1998 by Christopher Neufeld
*
* The executable for this file contains linked runtime libraries
* copyrighted by The Byte Works. Used with permission.
*
* Change Log:
*
* 1.0 -- [Christopher Neufeld, 1994] Initial version.
*
* 1.1 -- [Marlin Allred, 1 Jul 1998]
* + the date can now appear anywhere on the line
* + on the weekend, Monday events are also listed
* + man page was converted from preformatted ASCII to nroff source
* + binary linked with the v2.0.6 libraries
*
* 1.2 -- [Devin Reade, 6 Jul 1998]
* + fixed a bug introduced in 1.1 where getting an error while
* reading the calandar file could cause an infinite loop
* + added the describe entry and resource fork
* + added these "ChangeLog" comments for all versions
* + added this program to the GNO base distribution
* + eliminated "pragma stacksize" from the source file; it was too
* small (was 512 bytes, currently using 862 bytes) and overriding
* the value given on the command line during the GNO base build
* process
*
* $Id: calendar.c,v 1.3 1998/07/07 02:14:30 gdr-ftp Exp $
*/
#include <stdio.h>
#include <stdlib.h>
@ -8,8 +34,10 @@
#include <time.h>
#include <ctype.h>
#include <string.h>
#pragma stacksize 512
#include <err.h>
#ifdef __GNO__
#include <gno/gno.h>
#endif
#define NMONTHS 12
#define NDAYS 31
@ -31,13 +59,17 @@ int main(void)
{
FILE *ifile;
time_t t1, t2;
struct tm st1, st2;
static struct tm st1, st2;
int monthnum, daynum, dayschk, i, j;
char *ptr1, *ptr2, holdmnth[4];
static char thislin[MAXLINELEN+1];
long deltat;
long ldayschk;
#ifdef __GNO__
__REPORT_STACK();
#endif
if ((ifile = fopen(CALFILE, "r")) == NULL) exit(0); /* Open calendar file
in CWD. If there is none, exit successfully */
t1 = time(NULL); /* Get the current time */
@ -50,12 +82,9 @@ int main(void)
tomorrow, unless tomorrow is on the weekend, in
which case we check up to and including Monday */
thislin[MAXLINELEN] = 0;
while (!feof(ifile)) {
if (fgets(thislin, MAXLINELEN, ifile) == NULL) { /* Get a line from the calendar file */
if (feof(ifile)) break; /* Didn't read a line, if we're done, quit */
fprintf(stderr, "Can't happen\n");
continue; /* Something funny happened on the read */
}
/* Get each line from the calendar file */
while (fgets(thislin, MAXLINELEN, ifile) != NULL) {
ptr1 = thislin;
while (isspace(*ptr1) && *ptr1 != 0) ptr1++; /* Flush initial whitespace */
if (*ptr1 == 0) continue; /* Blank line */
@ -104,6 +133,9 @@ int main(void)
if (deltat <= dayschk * SECSPERDAY) printf(thislin);
/* print the entire line if it is inside our acceptance window */
}
if (ferror(ifile)) {
err(1, "error while reading %s", CALFILE);
}
fclose(ifile);
exit(0);
}

View File

@ -1,2 +0,0 @@
Dec 25 No more shopping days until Christmas.
Jul 1 A Canadian holiday

View File

@ -0,0 +1,29 @@
/*
* $Id: calendar.rez,v 1.1 1998/07/07 02:14:30 gdr-ftp Exp $
*/
#define PROG "calendar"
#define DESC "Prints out upcoming events."
#include "Types.rez"
/*
* Version
*/
resource rVersion (1, purgeable3) {
{ 1, 2, 0, /* Version */
release, /* development|alpha|beta|final|release */
0 }, /* non-final release number */
verUS, /* Country */
PROG, /* Program name */
DESC " Released with GNO/ME."
};
/*
* Comment
*/
resource rComment (1, purgeable3) {
PROG " v1.2 (6 July 1998)\n"
"GNO utility: " DESC
};