mirror of https://github.com/GnoConsortium/gno.git
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:
parent
b40c451852
commit
3689484d24
|
@ -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
|
|
@ -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.
|
|
|
@ -1,25 +1,61 @@
|
||||||
|
.\"
|
||||||
.TH CALENDAR 1 "June 30, 1998"
|
.\" $Id: calendar.1,v 1.3 1998/07/07 02:14:29 gdr-ftp Exp $
|
||||||
|
.\"
|
||||||
.SH NAME
|
.TH CALENDAR 1 "6 July 1998" GNO "Commands and Applications"
|
||||||
|
.SH NAME
|
||||||
.BR calendar
|
.BR calendar
|
||||||
\- reminder service
|
\- reminder service
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
calendar
|
calendar
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.BR calendar
|
.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
|
and prints out lines that contain today's or tomorrow's date
|
||||||
anywhere in the line. Most reasonable month-day dates such as
|
anywhere in the line. Most reasonable month-day dates such as
|
||||||
Aug. 24, august 24, 8/24, and so on, are recognized, but not
|
.IR "Aug. 24" ,
|
||||||
24 August or 24/8. On weekends ``tomorrow'' extends through
|
.IR "august 24" ,
|
||||||
Monday.
|
.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
|
.BR calendar
|
||||||
can be invoked regularly by using the
|
can be invoked regularly by using the
|
||||||
crontab(1) or at(1) commands.
|
.BR crontab (1)
|
||||||
.SH REFERENCES
|
or
|
||||||
at(1), cron(1M), crontab(1), date(1)
|
.BR at (1)
|
||||||
.SH NOTICES
|
commands.
|
||||||
.BR calendar's
|
.SH EXAMPLE
|
||||||
extended idea of ``tomorrow'' does not account for
|
A common way to run
|
||||||
holidays.
|
.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.
|
||||||
|
|
|
@ -1,6 +1,32 @@
|
||||||
/* Calendar file v1.0. Copyright 1994 by Christopher Neufeld */
|
/*
|
||||||
/* The executable for this file contains linked runtime libraries
|
* Calendar file v1.0. Copyright 1994-1998 by Christopher Neufeld
|
||||||
copyrighted by The Byte Works. Used with permission. */
|
*
|
||||||
|
* 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 <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -8,8 +34,10 @@
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <err.h>
|
||||||
#pragma stacksize 512
|
#ifdef __GNO__
|
||||||
|
#include <gno/gno.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#define NMONTHS 12
|
#define NMONTHS 12
|
||||||
#define NDAYS 31
|
#define NDAYS 31
|
||||||
|
@ -31,13 +59,17 @@ int main(void)
|
||||||
{
|
{
|
||||||
FILE *ifile;
|
FILE *ifile;
|
||||||
time_t t1, t2;
|
time_t t1, t2;
|
||||||
struct tm st1, st2;
|
static struct tm st1, st2;
|
||||||
int monthnum, daynum, dayschk, i, j;
|
int monthnum, daynum, dayschk, i, j;
|
||||||
char *ptr1, *ptr2, holdmnth[4];
|
char *ptr1, *ptr2, holdmnth[4];
|
||||||
static char thislin[MAXLINELEN+1];
|
static char thislin[MAXLINELEN+1];
|
||||||
long deltat;
|
long deltat;
|
||||||
long ldayschk;
|
long ldayschk;
|
||||||
|
|
||||||
|
#ifdef __GNO__
|
||||||
|
__REPORT_STACK();
|
||||||
|
#endif
|
||||||
|
|
||||||
if ((ifile = fopen(CALFILE, "r")) == NULL) exit(0); /* Open calendar file
|
if ((ifile = fopen(CALFILE, "r")) == NULL) exit(0); /* Open calendar file
|
||||||
in CWD. If there is none, exit successfully */
|
in CWD. If there is none, exit successfully */
|
||||||
t1 = time(NULL); /* Get the current time */
|
t1 = time(NULL); /* Get the current time */
|
||||||
|
@ -50,12 +82,9 @@ int main(void)
|
||||||
tomorrow, unless tomorrow is on the weekend, in
|
tomorrow, unless tomorrow is on the weekend, in
|
||||||
which case we check up to and including Monday */
|
which case we check up to and including Monday */
|
||||||
thislin[MAXLINELEN] = 0;
|
thislin[MAXLINELEN] = 0;
|
||||||
while (!feof(ifile)) {
|
|
||||||
if (fgets(thislin, MAXLINELEN, ifile) == NULL) { /* Get a line from the calendar file */
|
/* Get each line from the calendar file */
|
||||||
if (feof(ifile)) break; /* Didn't read a line, if we're done, quit */
|
while (fgets(thislin, MAXLINELEN, ifile) != NULL) {
|
||||||
fprintf(stderr, "Can't happen\n");
|
|
||||||
continue; /* Something funny happened on the read */
|
|
||||||
}
|
|
||||||
ptr1 = thislin;
|
ptr1 = thislin;
|
||||||
while (isspace(*ptr1) && *ptr1 != 0) ptr1++; /* Flush initial whitespace */
|
while (isspace(*ptr1) && *ptr1 != 0) ptr1++; /* Flush initial whitespace */
|
||||||
if (*ptr1 == 0) continue; /* Blank line */
|
if (*ptr1 == 0) continue; /* Blank line */
|
||||||
|
@ -104,6 +133,9 @@ int main(void)
|
||||||
if (deltat <= dayschk * SECSPERDAY) printf(thislin);
|
if (deltat <= dayschk * SECSPERDAY) printf(thislin);
|
||||||
/* print the entire line if it is inside our acceptance window */
|
/* print the entire line if it is inside our acceptance window */
|
||||||
}
|
}
|
||||||
|
if (ferror(ifile)) {
|
||||||
|
err(1, "error while reading %s", CALFILE);
|
||||||
|
}
|
||||||
fclose(ifile);
|
fclose(ifile);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
Dec 25 No more shopping days until Christmas.
|
|
||||||
Jul 1 A Canadian holiday
|
|
|
@ -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
|
||||||
|
};
|
Loading…
Reference in New Issue