v02i004: calentool - patch level 5, Part 2/4
Charles Mcgrew
mcgrew at dartagnan.rutgers.edu
Wed Jan 10 12:35:46 AEST 1990
Submitted-by: Bill Randle <billr at saab.cna.tek.com>
Posting-number: Volume 2, Issue 4
Archive-name: calentool/patch5b
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of archive 2 (of 4)."
# Contents: calencheck.c patches05b
# Wrapped by billr at saab on Mon Dec 18 17:22:42 1989
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'calencheck.c' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'calencheck.c'\"
else
echo shar: Extracting \"'calencheck.c'\" \(9305 characters\)
sed "s/^X//" >'calencheck.c' <<'END_OF_FILE'
X/*
X * $Header: calencheck.c,v 2.1 89/12/15 17:04:41 billr Exp $
X *
X * calencheck.c - check for pending appts without the overhead
X * of the full blown calentool
X *
X * Copyright (C) 1989 Tektronix, Inc.
X * All Rights Reserved
X * Permission is hereby granted to use and modify this file in source
X * or binary form as long as it is not sold for profit and this copyright
X * notice remains intact.
X */
X
X#include <stdio.h>
X#include <sys/time.h>
X#include <sys/file.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <sunwindow/defaults.h>
X#include "ct.h"
X
Xint read_only = 1; /* no modifications allowed */
Xint n_tslots, otherfile = 0;
Xint day_is_open;
Xint include_old = 0, save_old = 0;
Xstruct tm current, today;
Xstruct tm First, Last;
Xchar *progname, *othername;
Xstruct dayslot slots[N_SLOTS];
Xint show_future = 1;
Xint one_based = 0, version2 = 0;
Xchar apts_pathname[160], tmpapts_pathname[2];
Xchar apts_dir[128], lib_dir[128];
Xchar *strcpy(), *strcat(), *rindex(), *getenv();
X
Xmain(argc,argv)
Xint argc;
Xchar *argv[];
X{
X int flag;
X extern char *optarg;
X
X if (progname = rindex(*argv, '/'))
X progname++;
X else
X progname = *argv;
X
X n_tslots = (N_TSLOTS > N_SLOTS ? N_SLOTS : N_TSLOTS);
X
X get_today(); /* initial day is today */
X current = today;
X
X while ((flag = getopt(argc, argv, "f:")) != EOF)
X switch (flag) {
X case 'f': /* use this file */
X otherfile = 1;
X othername = optarg;
X break;
X
X case '?':
X default:
X fprintf(stderr, "usage: %s [-f <appt_file>]\n", progname);
X exit(1);
X }
X
X err2console(TRUE);
X do_files();
X check_calendar();
X for (;;) {
X /* only check appointments every TIME_OUT minutes */
X sleep(TIME_OUT);
X check_calendar();
X }
X}
X
X/*
X * When timer has expired check to see if we are close to an
X * appointment. If so, print message on the console.
X */
Xcheck_calendar()
X{
X int appt_pending = 0; /* no appointments pending */
X int some_appts = 0; /* no appointments today */
X int slotno = 0; /* start with first timeslot */
X static int echoed_sno = -1;
X static int new_day = 0;
X static time_t lastmod = (time_t)0;
X struct stat stbuf;
X int sno;
X FILE *console;
X
X sno = echoed_sno; /* assume no console echo */
X get_today();
X stat(apts_pathname, &stbuf);
X /*
X * Check to see if we've run over into the next day or if
X * the appts file has been modified recently. If so,
X * we need to update our slot information.
X */
X if (ymd_compare(current, today) != 0) {
X current = today;
X lastmod = stbuf.st_mtime;
X (void)get_day_appts();
X if (!new_day) {
X new_day++;
X sno = echoed_sno = -1;
X }
X } else if (stbuf.st_mtime > lastmod) {
X lastmod = stbuf.st_mtime;
X (void)get_day_appts();
X sno = echoed_sno = -1;
X new_day = 0;
X } else
X new_day = 0;
X if (today.tm_hour >= START_HOUR) {
X slotno = (today.tm_hour - START_HOUR)*2 + today.tm_min/30;
X if (slotno < n_tslots) {
X if (slots[slotno].active != INACTIVE) {
X /* appointment is happening now */
X appt_pending++;
X if (slots[slotno].active == ACTIVE)
X sno = slotno;
X } else if (slotno+1 < n_tslots) {
X if (slots[slotno+1].active != INACTIVE)
X /* are we within 10 mins of an appointment? */
X if ((today.tm_min % 30) >= 20) {
X appt_pending++;
X if (slots[slotno+1].active == ACTIVE)
X sno = slotno+1;
X }
X }
X }
X }
X if (!appt_pending) {
X /*
X * Is there anything happening today (optionally
X * including memos)?
X * Don't care about things that happened before now
X * so start looking at <slotno>, which was set above to
X * reflect the current hour (or 0 if before START_HOUR).
X */
X /*
X * APPT_CHECK_LIMIT is typically either "n_tslots"
X * or "N_SLOTS" depending on whether we include the
X * notes section when indicating that we still have
X * appts today.
X */
X while (slotno < APPT_CHECK_LIMIT)
X if (slots[slotno++].active != INACTIVE) {
X some_appts++;
X break;
X }
X } else {
X /* notify the user via the console (once) ... */
X if (sno != echoed_sno) {
X echoed_sno = sno;
X if (getenv("WINDOW_PARENT") != NULL && (console = fopen("/dev/console", "w")) != NULL) {
X fprintf(console, "<< %s >> %s\n", progname, slots[sno].cur_appt->str);
X fclose(console);
X } else {
X fprintf(stderr, "\007\007<< %s >> %s\n", progname, slots[sno].cur_appt->str);
X }
X }
X }
X if (new_day) {
X new_day = 0;
X }
X}
X
X/* stripped down version of do_files() from init.c */
Xdo_files()
X{
X char *slash, *default_ptr, *envptr;
X char buff[80];
X int to_slash, getpid(), fd, errflag, numask;
X struct passwd *pw;
X struct stat statbuf;
X FILE *appts;
X
X if (otherfile) {
X strcpy(apts_pathname, othername);
X if ((slash = rindex(apts_pathname, '/')) != NULL) {
X to_slash = slash - apts_pathname;
X strncpy(apts_dir, apts_pathname, to_slash);
X apts_dir[to_slash] = '\0';
X } else {
X strcpy(apts_dir, ".");
X }
X } else {
X if ((default_ptr = defaults_get_string("/CalenTool/Appts", NULL, 0)) != NULL) {
X if ((slash = rindex(default_ptr, '/')) != NULL) {
X to_slash = slash - default_ptr;
X strncpy(apts_dir, default_ptr, to_slash);
X apts_dir[to_slash] = '\0';
X } else {
X strcpy(apts_dir, ".");
X }
X } else if ((envptr = getenv("CALENTOOL_DIR")) != NULL) {
X strcpy(apts_dir, envptr);
X } else if ((envptr = getenv("HOME")) != NULL) {
X strcpy(apts_dir, envptr);
X } else {
X apts_dir[0] = '\0';
X }
X if (*apts_dir) {
X /* prepend directory on pathnames */
X sprintf(apts_pathname, "%s/.appointments", apts_dir);
X } else {
X /* use current directory */
X strcpy(apts_pathname, ".appointments");
X }
X }
X
X /* directory for date/event data files */
X if ((default_ptr = defaults_get_string("/CalenTool/LibDir", NULL, 0)) != NULL)
X strcpy(lib_dir, default_ptr);
X else
X strcpy(lib_dir, DATELIB_DIR);
X
X errflag = 0;
X if (access(apts_pathname, R_OK) == -1) {
X fprintf(stderr, "Cannot access calendar file %s - create? ", apts_pathname);
X fgets(buff, 80, stdin);
X if (buff[0] == 'y' || buff[0] == 'Y') {
X if ((fd=open(apts_pathname, O_CREAT|O_RDWR, 0644)) <= 0) {
X perror(apts_pathname);
X return(1);
X } else {
X if (write(fd, HEADER, sizeof(HEADER)) != sizeof(HEADER)) {
X perror("writing header");
X close(fd);
X return(1);
X }
X close(fd);
X one_based = 1;
X }
X } else
X return(1);
X }
X
X /* check first line of appts file to see if it is the new style */
X if ((appts = fopen(apts_pathname, "r")) != NULL) {
X fgets(buff, 80, appts);
X fclose(appts);
X if (!strcmp(buff, HEADER)) {
X version2 = 1;
X one_based = 1;
X } else
X err_rpt("wrong version appointments file format", FATAL);
X }
X return;
X}
X
X/* stubs for needed routines where we don't want the whole
X * thing.
X */
Xdeactivate_slot(bi, dpyflag)
Xint bi;
Xint dpyflag;
X{
X slots[bi].active = INACTIVE;
X}
X
X/* returns pointer to slot containing arrow head */
Xint
Xdeactivate_lower_arrows(bi, dpyflag)
Xint bi, dpyflag;
X{
X while (bi < N_SLOTS-1) {
X bi++;
X if (slots[bi].active != ARROW_SHAFT &&
X slots[bi].active != ARROW_HEAD)
X return(bi-1);
X slots[bi].active = INACTIVE;
X }
X}
X
Xdraw_day_appts()
X{
X}
X
X/* activate a hidden appt and make it visible */
Xint
Xactivate_slot(bi, dpyflag)
Xint bi;
Xint dpyflag;
X{
X int n, e_slot;
X
X if (slots[bi].count <= 0)
X /* nothing to activate */
X return(0);
X if (slots[bi].cur_appt == NULL) {
X /* may be hidden arrows */
X /* find appt that they came from so we can see if
X * it should be arrow shaft or arrow head
X */
X n = bi;
X while (--n >= 0 && slots[n].active != ACTIVE)
X ;
X if (n >= 0) {
X e_slot = n + slots[n].cur_appt->arrows;
X if (e_slot < bi)
X /* no arrows here to show */
X return(0);
X while (++n < e_slot && slots[n].active != ACTIVE)
X slots[n].active = ARROW_SHAFT;
X if (slots[n].active != ACTIVE)
X slots[n].active = ARROW_HEAD;
X } else
X /* no active appt above */
X return(0);
X } else {
X /* there's a real appt hidden */
X slots[bi].active = ACTIVE;
X if (slots[bi].cur_appt->arrows > 0) {
X e_slot = bi + slots[bi].cur_appt->arrows;
X while (++bi < e_slot && slots[bi].active != ACTIVE)
X slots[bi].active = ARROW_SHAFT;
X if (slots[bi].active != ACTIVE)
X slots[bi].active = ARROW_HEAD;
X }
X }
X if (dpyflag)
X draw_day_appts(); /* redraw display */
X return(1);
X}
X
Xnext_appt(bi, dpyflag)
Xint bi;
Xint dpyflag;
X{
X if (slots[bi].active == ACTIVE) {
X deactivate_slot(bi, dpyflag);
X if (slots[bi].cur_appt->arrows > 0)
X (void)deactivate_lower_arrows(bi, dpyflag);
X } else
X /* must have arrows displayed */
X (void)deactivate_lower_arrows(bi, dpyflag);
X
X if (slots[bi].cur_appt == NULL)
X /* end of the chain */
X slots[bi].cur_appt = slots[bi].first;
X else
X /* activate next in chain */
X slots[bi].cur_appt = slots[bi].cur_appt->next;
X /* make sure it is not a deleted one */
X if (chk_deleted(bi))
X next_appt(bi, dpyflag); /* try next in chain */
X else if (!activate_slot(bi, dpyflag))
X next_appt(bi, dpyflag); /* try next in chain */
X}
X
X/* check to see if current is deleted */
Xint
Xchk_deleted(bi)
Xint bi;
X{
X int found = 0;
X struct appt_entry *aptr;
X
X if (slots[bi].cur_appt == NULL)
X return(0);
X if (slots[bi].cur_appt->flags & DELETED)
X return(1);
X /* run through the list to see if there are any deleted */
X for (aptr=slots[bi].first; aptr; aptr=aptr->next)
X if (aptr->flags & DELETED) {
X /* now see if the current one matches */
X if (!strcmp(aptr->str, slots[bi].cur_appt->str))
X return(1);
X }
X
X return(0);
X}
END_OF_FILE
if test 9305 -ne `wc -c <'calencheck.c'`; then
echo shar: \"'calencheck.c'\" unpacked with wrong size!
fi
# end of 'calencheck.c'
fi
if test -f 'patches05b' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'patches05b'\"
else
echo shar: Extracting \"'patches05b'\" \(46931 characters\)
sed "s/^X//" >'patches05b' <<'END_OF_FILE'
X*** /tmp/,RCSt1a16916 Fri Dec 15 17:22:32 1989
X--- ct.h Fri Dec 15 17:17:07 1989
X***************
X*** 1,5
X /*
X! * $Header: ct.h,v 2.2 89/07/19 20:26:27 billr Exp $
X */
X /*
X * ct.h - header file for calentool
X
X--- 1,5 -----
X /*
X! * $Header: ct.h,v 2.3 89/12/15 17:17:04 billr Exp $
X */
X /*
X * ct.h - header file for calentool
X***************
X*** 22,27
X * notice remains intact.
X */
X
X /* directory for date/event files */
X #ifndef DATELIB_DIR
X # define DATELIB_DIR "/usr/net/lib/calentool"
X
X--- 22,35 -----
X * notice remains intact.
X */
X
X+ /* ignore several things for calencheck program */
X+ #ifdef CALENCHECK
X+ # define NO_PRINTER
X+ # define NO_HOLIDAYS
X+ # define NO_SUN_MOON
X+ # define NOTOOL
X+ #endif
X+
X /* directory for date/event files */
X #ifndef DATELIB_DIR
X # define DATELIB_DIR "/usr/net/lib/calentool"
X***************
X*** 27,33
X # define DATELIB_DIR "/usr/net/lib/calentool"
X #endif
X
X! #ifndef NOPRINTER
X /* command string for sending a file to the Postscript printer */
X # ifndef PRINT_CMD
X # define PRINT_CMD "lpr -Plw"
X
X--- 35,41 -----
X # define DATELIB_DIR "/usr/net/lib/calentool"
X #endif
X
X! #ifndef NO_PRINTER
X /* command string for sending a file to the Postscript printer */
X # ifndef PRINT_CMD
X # define PRINT_CMD "lpr -Plw"
X***************
X*** 39,44
X #endif
X #endif
X
X /* define NR_WEEKDAYS for desired week display */
X /* NR_WEEKDAYS display */
X /* 5 Mon-Fri */
X
X--- 47,57 -----
X #endif
X #endif
X
X+ #ifndef MAILPROG
X+ # define MAILPROG "/usr/ucb/mail"
X+ /* assumes -s option is available */
X+ #endif
X+
X /* define NR_WEEKDAYS for desired week display */
X /* NR_WEEKDAYS display */
X /* 5 Mon-Fri */
X***************
X*** 43,49
X /* NR_WEEKDAYS display */
X /* 5 Mon-Fri */
X /* 6 Mon-Sat */
X! /* 7 Sun-Sat */
X /**/
X #ifndef NR_WEEKDAYS
X # define NR_WEEKDAYS 5
X
X--- 56,62 -----
X /* NR_WEEKDAYS display */
X /* 5 Mon-Fri */
X /* 6 Mon-Sat */
X! /* 7 Sun-Sat or Mon-Sun */
X /**/
X #ifndef NR_WEEKDAYS
X # define NR_WEEKDAYS 5
X***************
X*** 48,53
X #ifndef NR_WEEKDAYS
X # define NR_WEEKDAYS 5
X #endif
X
X #ifndef START_HOUR
X # define START_HOUR 8 /* 8am */
X
X--- 61,69 -----
X #ifndef NR_WEEKDAYS
X # define NR_WEEKDAYS 5
X #endif
X+ #ifndef MON_FIRST
X+ # define MON_FIRST 0 /* 0=Sun-Sat, 1=Mon-Sun */
X+ #endif
X
X #ifndef START_HOUR
X # define START_HOUR 8 /* 8am */
X***************
X*** 55,60
X #ifndef END_HOUR
X # define END_HOUR 18 /* 6pm */
X #endif
X
X #ifndef START_YEAR
X # define START_YEAR 89
X
X--- 71,82 -----
X #ifndef END_HOUR
X # define END_HOUR 18 /* 6pm */
X #endif
X+ #ifndef HOUR_24
X+ # define HOUR_24 0 /* 0=12hr time, 1=24hr time */
X+ #endif
X+ #ifndef DAY_FIRST
X+ # define DAY_FIRST 0 /* 0=M/D/Y, 1=D/M/Y */
X+ #endif
X
X #ifndef START_YEAR
X # define START_YEAR 89
X***************
X*** 66,72
X #ifndef UPDATE_RATE
X # define UPDATE_RATE "second" /* update time */
X #endif /* options are "second" & "minute" */
X! #define TIME_OUT 5 /* check appts every 5 minutes */
X
X /*
X * If calentool is too big and you want a stripped-down version
X
X--- 88,94 -----
X #ifndef UPDATE_RATE
X # define UPDATE_RATE "second" /* update time */
X #endif /* options are "second" & "minute" */
X! #define TIME_OUT 2 /* check appts every 5 minutes */
X
X /*
X * APPT_CHECK_LIMIT is typically either "n_tslots"
X***************
X*** 69,74
X #define TIME_OUT 5 /* check appts every 5 minutes */
X
X /*
X * If calentool is too big and you want a stripped-down version
X * define some or all of these here or in the Makefile. Combined,
X * they save ~100K bytes.
X
X--- 91,106 -----
X #define TIME_OUT 2 /* check appts every 5 minutes */
X
X /*
X+ * APPT_CHECK_LIMIT is typically either "n_tslots"
X+ * or "N_SLOTS" depending on whether we include the
X+ * notes section when indicating that we still have
X+ * appts today.
X+ */
X+ #ifndef APPT_CHECK_LIMIT
X+ # define APPT_CHECK_LIMIT n_tslots
X+ #endif
X+
X+ /*
X * If calentool is too big and you want a stripped-down version
X * define some or all of these here or in the Makefile. Combined,
X * they save ~100K bytes.
X***************
X*** 94,109
X #define N_SLOTS (N_TSLOTS+10) /* Total number of slots on a day page. */
X #define MAX_FUTURE_ENTRIES 32 /* number of appts displayed in popup window */
X
X- /*
X- * APPT_CHECK_LIMIT is typically either "n_tslots"
X- * or "N_SLOTS" depending on whether we include the
X- * notes section when indicating that we still have
X- * appts today.
X- */
X- #ifndef APPT_CHECK_LIMIT
X- # define APPT_CHECK_LIMIT n_tslots
X- #endif
X-
X /* Dimensions of 30-minute week slot.
X * Message size determines width - everything else keyed
X * off font size and message size
X
X--- 126,131 -----
X #define N_SLOTS (N_TSLOTS+10) /* Total number of slots on a day page. */
X #define MAX_FUTURE_ENTRIES 32 /* number of appts displayed in popup window */
X
X /* Dimensions of 30-minute week slot.
X * Message size determines width - everything else keyed
X * off font size and message size
X***************
X*** 110,115
X */
X #define WEEK_MESSAGE_SIZE 12
X
X #define DISPLAYING_DAY 1 /* Defs for state of main */
X #define DISPLAYING_WEEK 2 /* subwindow (mainsw_state) */
X #define DISPLAYING_MONTH 3
X
X--- 132,139 -----
X */
X #define WEEK_MESSAGE_SIZE 12
X
X+ #define MAX_INCLUDE_NESTING 4 /* number of allowed include files */
X+
X #define DISPLAYING_DAY 1 /* Defs for state of main */
X #define DISPLAYING_WEEK 2 /* subwindow (mainsw_state) */
X #define DISPLAYING_MONTH 3
X***************
X*** 185,190
X #define MARKED 0x800 /* don't show in month/year display */
X #define MARKED_NOTE 0xc00
X #define DELETED 0x1000 /* don't show the appt that matches this */
X
X /* format of repeat field for every_someday type appts */
X #define WEEK1 0x1
X
X--- 209,215 -----
X #define MARKED 0x800 /* don't show in month/year display */
X #define MARKED_NOTE 0xc00
X #define DELETED 0x1000 /* don't show the appt that matches this */
X+ #define RUN 0x2000
X
X /* format of repeat field for every_someday type appts */
X #define WEEK1 0x1
X***************
X*** 216,221
X #define DST_STDOUT 1
X #define DST_MAIL 2
X
X /* header line in appts file implies one-based entries and 99 memo flag */
X #define HEADER "# CalenTool V2 - DO NOT REMOVE THIS LINE\n"
X
X
X--- 241,253 -----
X #define DST_STDOUT 1
X #define DST_MAIL 2
X
X+ /* return codes from get_day_appts() */
X+ #define NO_ENTRIES 0
X+ #define SOME_APPTS 1
X+ #define SOME_NOTES 2
X+ #define SOME_MKNOTES 4
X+ #define SOME_FUTURES 8
X+
X /* header line in appts file implies one-based entries and 99 memo flag */
X #define HEADER "# CalenTool V2 - DO NOT REMOVE THIS LINE\n"
X
X***************
X*** 224,229
X /* describes an entry in the appointments file */
X int year, month, day, hour, minute, arrows;
X int repeat, lookahead, flags, sindex;
X char str[MAX_STRLEN];
X struct appt_entry *next; /* ptr to next appt in list */
X }; /* NULL if last entry */
X
X--- 256,262 -----
X /* describes an entry in the appointments file */
X int year, month, day, hour, minute, arrows;
X int repeat, lookahead, flags, sindex;
X+ int runlength;
X char str[MAX_STRLEN];
X struct appt_entry *next; /* ptr to next appt in list */
X }; /* NULL if last entry */
X*** /tmp/,RCSt1a16921 Fri Dec 15 17:22:36 1989
X--- datelib.c Fri Dec 15 17:17:17 1989
X***************
X*** 1,5
X /*
X! * $Header: datelib.c,v 2.2 89/07/19 20:34:23 billr Exp $
X *
X * datelib.c - Calendar (date) computation library
X *
X
X--- 1,5 -----
X /*
X! * $Header: datelib.c,v 2.3 89/12/15 17:17:08 billr Exp $
X *
X * datelib.c - Calendar (date) computation library
X *
X***************
X*** 89,94
X "Sunday", "Monday", "Tuesday", "Wednesday",
X "Thursday", "Friday", "Saturday" };
X static char timebuf[16];
X
X /*
X * date_string:
X
X--- 89,96 -----
X "Sunday", "Monday", "Tuesday", "Wednesday",
X "Thursday", "Friday", "Saturday" };
X static char timebuf[16];
X+ static double passoverJD, easterJD;
X+ static int passoverJY;
X
X /*
X * date_string:
X***************
X*** 254,259
X }
X
X /*
X * julian_day:
X * Compute Julian day (>=1)
X * given day (1-31), month (1-12), year (1901-2009)
X
X--- 256,289 -----
X }
X
X /*
X+ * nth_mday_of_month:
X+ * Compute nth m-day of the month (1-31)
X+ * given n (1-5), day of week (0-6, 0 for Sunday), month (1-12),
X+ * year (1583-9999)
X+ */
X+ double
X+ nth_mday_of_month(n, day_of_week, month, year)
X+ int day_of_week, month, n, year;
X+ {
X+ int atmp, btmp, ctmp, dtmp, etmp, tmonth, tyear;
X+
X+ if (month > 2) {
X+ tmonth = month + 1;
X+ tyear = year;
X+ }
X+ else {
X+ tmonth = month + 13;
X+ tyear = year - 1;
X+ }
X+ atmp = 2.6 * tmonth;
X+ btmp = 1.25 * tyear;
X+ ctmp = (tyear / 100) - 7;
X+ dtmp = 0.75 * ctmp;
X+ etmp = (day_of_week - atmp - btmp + dtmp) % 7;
X+ return (double) (etmp + (n * 7));
X+ }
X+
X+ /*
X * julian_day:
X * Compute Julian day (>=1)
X * given day (1-31), month (1-12), year (1901-2009)
X***************
X*** 270,277
X double day;
X int month, year;
X {
X! int atmp, btmp, monthp, yearp;
X! double ctmp;
X
X if (month > 2) {
X monthp = month + 1;
X
X--- 300,307 -----
X double day;
X int month, year;
X {
X! int atmp, monthp, yearp;
X! double ctmp = 1720994.5 + day;
X
X if (month > 2) {
X monthp = month + 1;
X***************
X*** 282,288
X yearp = year - 1;
X }
X if ((year > 1582) || (year == 1582 && month >= 10)
X! || (year == 1582 && month ==10 && day >= 15)) {
X atmp = year / 100;
X btmp = 2 - atmp + (atmp / 4);
X }
X
X--- 312,318 -----
X yearp = year - 1;
X }
X if ((year > 1582) || (year == 1582 && month >= 10)
X! || (year == 1582 && month == 10 && day >= 15)) {
X atmp = year / 100;
X ctmp += 2 - atmp + (int)(atmp / 4);
X }
X***************
X*** 284,290
X if ((year > 1582) || (year == 1582 && month >= 10)
X || (year == 1582 && month ==10 && day >= 15)) {
X atmp = year / 100;
X! btmp = 2 - atmp + (atmp / 4);
X }
X else
X btmp = 0;
X
X--- 314,320 -----
X if ((year > 1582) || (year == 1582 && month >= 10)
X || (year == 1582 && month == 10 && day >= 15)) {
X atmp = year / 100;
X! ctmp += 2 - atmp + (int)(atmp / 4);
X }
X ctmp += (int)(365.25 * yearp) + (int)(30.6001 * monthp);
X return ctmp;
X***************
X*** 286,298
X atmp = year / 100;
X btmp = 2 - atmp + (atmp / 4);
X }
X! else
X! btmp = 0;
X! atmp = 365.25 * yearp;
X! ctmp = atmp;
X! atmp = 30.6001 * monthp;
X! ctmp = ctmp + atmp;
X! return ctmp + day + 1720994.5 + btmp;
X }
X
X #ifndef NO_HOLIDAYS
X
X--- 316,323 -----
X atmp = year / 100;
X ctmp += 2 - atmp + (int)(atmp / 4);
X }
X! ctmp += (int)(365.25 * yearp) + (int)(30.6001 * monthp);
X! return ctmp;
X }
X
X #ifndef NO_HOLIDAYS
X***************
X*** 297,302
X
X #ifndef NO_HOLIDAYS
X /*
X * corrected_julian_day:
X * Correct Julian day (>=1) for conversion from JULIAN CALENDAR
X * to GREGORIAN CALENDAR.
X
X--- 322,341 -----
X
X #ifndef NO_HOLIDAYS
X /*
X+ * datelib_int:
X+ * Calculate often used quantities (e.g. Easter, Passover) as an
X+ * optimization.
X+ */
X+ datelib_init(year)
X+ int year;
X+ {
X+ void passover_init(), easter_init();
X+
X+ easter_init(year);
X+ passover_init(year);
X+ }
X+
X+ /*
X * corrected_julian_day:
X * Correct Julian day (>=1) for conversion from JULIAN CALENDAR
X * to GREGORIAN CALENDAR.
X***************
X*** 374,411
X }
X
X /*
X- * nth_mday_of_month:
X- * Compute nth m-day of the month (1-31)
X- * given n (1-5), day of week (0-6, 0 for Sunday), month (1-12),
X- * year (1583-9999)
X- */
X- double
X- nth_mday_of_month(n, day_of_week, month, year)
X- int day_of_week, month, n, year;
X- {
X- int atmp, btmp, ctmp, dtmp, etmp, ftmp, tmonth, tyear;
X-
X- if (month > 2) {
X- tmonth = month + 1;
X- tyear = year;
X- }
X- else {
X- tmonth = month + 13;
X- tyear = year - 1;
X- }
X- atmp = 2.6 * tmonth;
X- btmp = 1.25 * tyear;
X- ctmp = (tyear / 100) - 7;
X- dtmp = 0.75 * ctmp;
X- etmp = (day_of_week - atmp - btmp + dtmp) % 7;
X- if (etmp == 0)
X- ftmp = 7;
X- else
X- ftmp = etmp;
X- return (double) (ftmp + (n * 7));
X- }
X-
X- /*
X * years_date_is_mday:
X * Compute year(s) for which a given date is an m-day
X * given starting year, ending year,
X
X--- 413,418 -----
X }
X
X /*
X * years_date_is_mday:
X * Compute year(s) for which a given date is an m-day
X * given starting year, ending year,
X***************
X*** 698,705
X * Method valid for all dates in the Gregorian calendar
X * (from 15 October 1583 on)
X */
X! double
X! easter(year)
X int year;
X {
X double day;
X
X--- 705,712 -----
X * Method valid for all dates in the Gregorian calendar
X * (from 15 October 1583 on)
X */
X! void
X! easter_init(year)
X int year;
X {
X double day;
X***************
X*** 721,727
X mtmp = (atmp + (11 * htmp) + (22 * ltmp)) / 451;
X month = (htmp + ltmp - (7 * mtmp) + 114) / 31;
X day = ((htmp + ltmp - (7 * mtmp) + 114) % 31) + 1;
X! return julian_day(day, month, year);
X }
X
X /*
X
X--- 728,734 -----
X mtmp = (atmp + (11 * htmp) + (22 * ltmp)) / 451;
X month = (htmp + ltmp - (7 * mtmp) + 114) / 31;
X day = ((htmp + ltmp - (7 * mtmp) + 114) % 31) + 1;
X! easterJD = julian_day(day, month, year);
X }
X
X double
X***************
X*** 724,729
X return julian_day(day, month, year);
X }
X
X /*
X * first_sunday_advent:
X * Christian holidays: compute Julian day for First Sunday in Advent
X
X--- 731,743 -----
X easterJD = julian_day(day, month, year);
X }
X
X+ double
X+ easter(year)
X+ int year;
X+ {
X+ return easterJD;
X+ }
X+
X /*
X * first_sunday_advent:
X * Christian holidays: compute Julian day for First Sunday in Advent
X***************
X*** 755,763
X double offset;
X int year;
X {
X! double easter();
X!
X! return easter(year) + offset;
X }
X
X /*
X
X--- 769,775 -----
X double offset;
X int year;
X {
X! return easterJD + offset;
X }
X
X /*
X***************
X*** 1030,1038
X * Floating point implementation by R.P.C. Rodgers; integer implementation
X * (for faster calculation) by Amos Shapir (amos at nsc.com).
X */
X! double
X! passover(year, jyear)
X! int *jyear, year;
X {
X int etmp, p_day;
X int atmp, btmp, ctmp, day_of_week, dtmp, ftmp, gtmp;
X
X--- 1042,1050 -----
X * Floating point implementation by R.P.C. Rodgers; integer implementation
X * (for faster calculation) by Amos Shapir (amos at nsc.com).
X */
X! void
X! passover_init(year)
X! int year;
X {
X int etmp, p_day;
X int atmp, btmp, ctmp, day_of_week, dtmp, ftmp, gtmp;
X***************
X*** 1039,1045
X int p_month;
X
X atmp = year + 3760;
X! *jyear = atmp;
X btmp = (12 * atmp + 17) % 19;
X ctmp = atmp % 4;
X etmp = (765433 * btmp) - (1565 * atmp)
X
X--- 1051,1057 -----
X int p_month;
X
X atmp = year + 3760;
X! passoverJY = atmp;
X btmp = (12 * atmp + 17) % 19;
X ctmp = atmp % 4;
X etmp = (765433 * btmp) - (1565 * atmp)
X***************
X*** 1049,1055
X /* day_of_week is not to be confused with the
X value returned by the day_of_week routine; here, Sunday = 1 */
X day_of_week = ((3 * atmp) + (5 * ctmp) + dtmp + 5) % 7;
X! if (day_of_week == 0 && btmp > 11 && etmp >= 311676)
X p_day = dtmp + 1;
X else if (day_of_week == 1 && btmp > 6 && etmp >= 311676)
X p_day = dtmp + 2;
X
X--- 1061,1067 -----
X /* day_of_week is not to be confused with the
X value returned by the day_of_week routine; here, Sunday = 1 */
X day_of_week = ((3 * atmp) + (5 * ctmp) + dtmp + 5) % 7;
X! if (day_of_week == 0 && btmp > 11 && etmp >= 442111)
X p_day = dtmp + 1;
X else if (day_of_week == 1 && btmp > 6 && etmp >= 311676)
X p_day = dtmp + 2;
X***************
X*** 1067,1073
X }
X else
X p_month = 3;
X! return julian_day(p_day, p_month, year);
X }
X
X /*
X
X--- 1079,1085 -----
X }
X else
X p_month = 3;
X! passoverJD = julian_day((double)p_day, p_month, year);
X }
X
X double
X***************
X*** 1070,1075
X return julian_day(p_day, p_month, year);
X }
X
X /*
X * passover_offset:
X * Jewish holidays: compute Julian day as offset from Passover
X
X--- 1082,1095 -----
X passoverJD = julian_day((double)p_day, p_month, year);
X }
X
X+ double
X+ passover(year, jyear)
X+ int year, *jyear;
X+ {
X+ *jyear = passoverJY;
X+ return passoverJD;
X+ }
X+
X /*
X * passover_offset:
X * Jewish holidays: compute Julian day as offset from Passover
X***************
X*** 1080,1088
X double offset;
X int *jyear, year;
X {
X! double passover();
X!
X! return passover(year, jyear) + offset;
X }
X
X /*
X
X--- 1100,1107 -----
X double offset;
X int *jyear, year;
X {
X! *jyear = passoverJY;
X! return passoverJD + offset;
X }
X
X /*
X***************
X*** 1178,1185
X chanukah(year, jyear)
X int *jyear, year;
X {
X! double atmp;
X! int btmp, dummy;
X
X atmp = passover(year, jyear);
X btmp = passover((year + 1), &dummy) - atmp;
X
X--- 1197,1204 -----
X chanukah(year, jyear)
X int *jyear, year;
X {
X! double atmp, ptmp;
X! int btmp, ytmp;
X
X atmp = passover(year, jyear);
X /* we need top compute passover for next year, so
X***************
X*** 1182,1188
X int btmp, dummy;
X
X atmp = passover(year, jyear);
X! btmp = passover((year + 1), &dummy) - atmp;
X (*jyear)++;
X if (btmp == 355 || btmp == 385)
X return atmp + 247.0;
X
X--- 1201,1215 -----
X int btmp, ytmp;
X
X atmp = passover(year, jyear);
X! /* we need top compute passover for next year, so
X! * save current info and restore when done
X! */
X! ptmp = passoverJD;
X! ytmp = passoverJY;
X! passover_init(year + 1);
X! btmp = passoverJD - atmp;
X! passoverJD = ptmp;
X! passoverJY = ytmp;
X (*jyear)++;
X if (btmp == 355 || btmp == 385)
X return atmp + 247.0;
X*** /tmp/,RCSt1a16926 Fri Dec 15 17:22:44 1989
X--- devent.c Fri Dec 15 17:17:23 1989
X***************
X*** 1,5
X /*
X! * $Header: devent.c,v 2.5 89/09/19 05:58:58 billr Exp $
X */
X /*
X * devent.c
X
X--- 1,5 -----
X /*
X! * $Header: devent.c,v 2.6 89/12/15 17:17:18 billr Exp $
X */
X /*
X * devent.c
X***************
X*** 43,48
X extern Panel_item everyx_pi, repeat_pi, remind_pi;
X extern Panel_item whichwk_pi, marked_pi;
X extern Panel_item del_choice_pi;
X extern Frame del_frame;
X extern Panel del_panel;
X extern Pixrect tri_right_pr, tri_up_pr;
X
X--- 43,49 -----
X extern Panel_item everyx_pi, repeat_pi, remind_pi;
X extern Panel_item whichwk_pi, marked_pi;
X extern Panel_item del_choice_pi;
X+ extern Panel_item runl_pi;
X extern Frame del_frame;
X extern Panel del_panel;
X extern Pixrect tri_right_pr, tri_up_pr;
X***************
X*** 463,469
X
X /* clears a day slot */
X deactivate_slot(bi, dpyflag)
X! int bi;
X {
X slots[bi].active = INACTIVE;
X if (!dpyflag)
X
X--- 464,470 -----
X
X /* clears a day slot */
X deactivate_slot(bi, dpyflag)
X! int bi, dpyflag;
X {
X slots[bi].active = INACTIVE;
X if (!dpyflag)
X***************
X*** 485,491
X /* returns pointer to slot containing arrow head */
X int
X deactivate_lower_arrows(bi, dpyflag)
X! int bi;
X {
X while (bi < N_SLOTS-1) {
X bi++;
X
X--- 486,492 -----
X /* returns pointer to slot containing arrow head */
X int
X deactivate_lower_arrows(bi, dpyflag)
X! int bi, dpyflag;
X {
X while (bi < N_SLOTS-1) {
X bi++;
X***************
X*** 517,522
X slots[bi].cur_appt->arrows = 0;
X slots[bi].cur_appt->flags = slots[bi].cur_appt->repeat = 0;
X slots[bi].cur_appt->lookahead = slots[bi].cur_appt->sindex = 0;
X if (bi >= n_tslots) {
X /* notes section */
X slots[bi].cur_appt->hour = 99;
X
X--- 518,524 -----
X slots[bi].cur_appt->arrows = 0;
X slots[bi].cur_appt->flags = slots[bi].cur_appt->repeat = 0;
X slots[bi].cur_appt->lookahead = slots[bi].cur_appt->sindex = 0;
X+ slots[bi].cur_appt->runlength = 0;
X if (bi >= n_tslots) {
X /* notes section */
X slots[bi].cur_appt->hour = 99;
X***************
X*** 756,761
X
X panel_set_value(repeat_pi, ""); /* set default */
X panel_set_value(remind_pi, ""); /* set default */
X if (apt->flags & ALL_DAYS)
X everyx_val |= 0x1;
X if (apt->flags & ALL_MONTHS)
X
X--- 758,764 -----
X
X panel_set_value(repeat_pi, ""); /* set default */
X panel_set_value(remind_pi, ""); /* set default */
X+ panel_set_value(runl_pi, ""); /* set default */
X if (apt->flags & ALL_DAYS)
X everyx_val |= 0x1;
X if (apt->flags & ALL_MONTHS)
X***************
X*** 780,785
X if (apt->flags & LOOKAHEAD) {
X sprintf(str, "%d", apt->lookahead);
X panel_set_value(remind_pi, str);
X }
X panel_set_value(marked_pi, (apt->flags & MARKED ? 1 : 0));
X if (apt->flags & A_NOTE)
X
X--- 783,792 -----
X if (apt->flags & LOOKAHEAD) {
X sprintf(str, "%d", apt->lookahead);
X panel_set_value(remind_pi, str);
X+ }
X+ if (apt->flags & RUN) {
X+ sprintf(str, "%d", apt->runlength);
X+ panel_set_value(runl_pi, str);
X }
X panel_set_value(marked_pi, (apt->flags & MARKED ? 1 : 0));
X if (apt->flags & A_NOTE)
X*** /tmp/,RCSt1a16931 Fri Dec 15 17:22:51 1989
X--- dpaint.c Fri Dec 15 17:17:29 1989
X***************
X*** 1,5
X /*
X! * $Header: dpaint.c,v 2.3 89/07/19 20:27:45 billr Exp $
X */
X /*
X * dpaint.c
X
X--- 1,5 -----
X /*
X! * $Header: dpaint.c,v 2.4 89/12/15 17:17:25 billr Exp $
X */
X /*
X * dpaint.c
X***************
X*** 28,35
X * *
X ***************************************************/
X
X- #include <suntool/sunview.h>
X- #include <suntool/canvas.h>
X #include <ctype.h>
X #include <sys/time.h>
X #include <stdio.h>
X
X--- 28,33 -----
X * *
X ***************************************************/
X
X #include <ctype.h>
X #include <sys/time.h>
X #include <stdio.h>
X***************
X*** 33,38
X #include <ctype.h>
X #include <sys/time.h>
X #include <stdio.h>
X #include "ct.h"
X #include "paint.h"
X #include "riseset.h"
X
X--- 31,40 -----
X #include <ctype.h>
X #include <sys/time.h>
X #include <stdio.h>
X+ #ifndef NOTOOL
X+ #include <suntool/sunview.h>
X+ #include <suntool/canvas.h>
X+ #endif
X #include "ct.h"
X #include "paint.h"
X #ifndef NOTOOL
X***************
X*** 35,40
X #include <stdio.h>
X #include "ct.h"
X #include "paint.h"
X #include "riseset.h"
X #define J1970 2440587.5 /* VAX clock Epoch 1970 Jan 1 (0h UT) */
X
X
X--- 37,43 -----
X #endif
X #include "ct.h"
X #include "paint.h"
X+ #ifndef NOTOOL
X #include "riseset.h"
X #define J1970 2440587.5 /* VAX clock Epoch 1970 Jan 1 (0h UT) */
X
X***************
X*** 42,48
X extern Frame mframe, sframe;
X extern Canvas mcanvas, scanvas;
X extern Panel_item mdate_pi, sdate_pi;
X! #endif
X extern Pixrect *leftarrow, *rightarrow;
X extern Pixrect *arrowshaft_pr, *arrowhead_pr;
X extern int day_message_size;
X
X--- 45,51 -----
X extern Frame mframe, sframe;
X extern Canvas mcanvas, scanvas;
X extern Panel_item mdate_pi, sdate_pi;
X! #endif /* NO_SUN_MOON */
X extern Pixrect *leftarrow, *rightarrow;
X extern Pixrect *arrowshaft_pr, *arrowhead_pr;
X extern char riseset_buf[][64];
X***************
X*** 45,51
X #endif
X extern Pixrect *leftarrow, *rightarrow;
X extern Pixrect *arrowshaft_pr, *arrowhead_pr;
X- extern int day_message_size;
X extern char riseset_buf[][64];
X extern int old_slot;
X extern int show_future;
X
X--- 48,53 -----
X #endif /* NO_SUN_MOON */
X extern Pixrect *leftarrow, *rightarrow;
X extern Pixrect *arrowshaft_pr, *arrowhead_pr;
X extern char riseset_buf[][64];
X extern int old_slot;
X #endif /* NOTOOL */
X***************
X*** 48,53
X extern int day_message_size;
X extern char riseset_buf[][64];
X extern int old_slot;
X extern int show_future;
X extern char *index();
X
X
X--- 50,57 -----
X extern Pixrect *arrowshaft_pr, *arrowhead_pr;
X extern char riseset_buf[][64];
X extern int old_slot;
X+ #endif /* NOTOOL */
X+ extern int day_message_size;
X extern int show_future;
X extern char *index();
X
X***************
X*** 55,60
X struct appt_entry future[MAX_FUTURE_ENTRIES];
X int findex = 0; /* index into struct future array */
X
X /*
X * This one draws the current selected day in the
X * main subwindow.
X
X--- 59,65 -----
X struct appt_entry future[MAX_FUTURE_ENTRIES];
X int findex = 0; /* index into struct future array */
X
X+ #ifndef NOTOOL
X /*
X * This one draws the current selected day in the
X * main subwindow.
X***************
X*** 116,125
X starty = y = (rect->r_height - (N_SLOTS * dayslot_height)) / 2;
X
X /* Format daystring to say, for example, */
X! /* Tuesday, March 12, 1985 */
X! sprintf(daystring, "%s %s %d, %d",
X! daynames[current.tm_wday], monthnames[current.tm_mon],
X! current.tm_mday, 1900 + current.tm_year);
X pw_text(main_pixwin, (rect->r_width - bigfont->pf_defaultsize.x*strlen(daystring))/2, starty/2 + 7,
X PIX_SRC, bigfont, daystring);
X
X
X--- 121,136 -----
X starty = y = (rect->r_height - (N_SLOTS * dayslot_height)) / 2;
X
X /* Format daystring to say, for example, */
X! if (day_first)
X! /* Tuesday, 13 March 1990 */
X! sprintf(daystring, "%s %d %s %d",
X! daynames[current.tm_wday], current.tm_mday,
X! monthnames[current.tm_mon], 1900 + current.tm_year);
X! else
X! /* Tuesday, March 13, 1990 */
X! sprintf(daystring, "%s %s %d, %d",
X! daynames[current.tm_wday], monthnames[current.tm_mon],
X! current.tm_mday, 1900 + current.tm_year);
X pw_text(main_pixwin, (rect->r_width - bigfont->pf_defaultsize.x*strlen(daystring))/2, starty/2 + 7,
X PIX_SRC, bigfont, daystring);
X
X***************
X*** 146,154
X pw_write(main_pixwin,x,y,dayslot_width,dayslot_height,PIX_SRC,timeslot_pr,0,0);
X if (i < n_tslots) {
X /* display time */
X! sprintf(timestring, "%2d:%s",
X! (START_HOUR+(i/2))%12 == 0 ? 12 : (START_HOUR+(i/2))%12,
X! i%2 == 0 ? "00" : "30");
X } else if (i == n_tslots) {
X sprintf(timestring, "Notes");
X } else {
X
X--- 157,170 -----
X pw_write(main_pixwin,x,y,dayslot_width,dayslot_height,PIX_SRC,timeslot_pr,0,0);
X if (i < n_tslots) {
X /* display time */
X! if (hour24)
X! sprintf(timestring, "%2d:%s",
X! START_HOUR+(i/2),
X! i%2 == 0 ? "00" : "30");
X! else
X! sprintf(timestring, "%2d:%s%s",
X! (START_HOUR+(i/2))%12 == 0 ? 12 : (START_HOUR+(i/2))%12,
X! i%2 == 0 ? "00" : "30", (START_HOUR+(i/2) < 12 ? "am" : "pm"));
X } else if (i == n_tslots) {
X sprintf(timestring, "Notes");
X } else {
X***************
X*** 154,160
X } else {
X sprintf(timestring, " ");
X }
X! pw_text(main_pixwin,x-8*font->pf_defaultsize.x,y+font->pf_defaultsize.y,PIX_SRC,font,timestring);
X y += dayslot_height - 1;
X }
X
X
X--- 170,176 -----
X } else {
X sprintf(timestring, " ");
X }
X! pw_text(main_pixwin,x-9*font->pf_defaultsize.x,y+font->pf_defaultsize.y,PIX_SRC,font,timestring);
X y += dayslot_height - 1;
X }
X
X***************
X*** 168,173
X sun_moon_buttons(TRUE);
X print_button(TRUE);
X }
X
X
X /*
X
X--- 184,190 -----
X sun_moon_buttons(TRUE);
X print_button(TRUE);
X }
X+ #endif /* NOTOOL */
X
X /*
X * Fills in appointments for the day.
X***************
X*** 169,175
X print_button(TRUE);
X }
X
X-
X /*
X * Fills in appointments for the day.
X * The ".tmp.aptsXXXXX" file is filled out
X
X--- 186,191 -----
X }
X #endif /* NOTOOL */
X
X /*
X * Fills in appointments for the day.
X * The ".tmp.aptsXXXXX" file is filled out
X***************
X*** 182,187
X FILE *apts, *temp_apts;
X int slotno, n_arrows, i;
X int read_stat, some_appt = 0;
X struct appt_entry appt;
X struct appt_entry *nappt, *aptr;
X char buf[MAX_STRLEN], *sptr;
X
X--- 198,204 -----
X FILE *apts, *temp_apts;
X int slotno, n_arrows, i;
X int read_stat, some_appt = 0;
X+ int runl;
X struct appt_entry appt;
X struct appt_entry *nappt, *aptr;
X char buf[MAX_STRLEN], *sptr;
X***************
X*** 235,241
X /*
X * now go thru the appointments file
X */
X! while ((read_stat=get_aentry(apts, &appt)) != EOF) {
X if (read_stat)
X continue; /* read error (ignore) */
X if (appt.flags & A_COMMENT) {
X
X--- 252,258 -----
X /*
X * now go thru the appointments file
X */
X! while ((read_stat=get_aentry(apts, &appt, FALSE)) != EOF) {
X if (read_stat)
X continue; /* read error (ignore) */
X if (appt.flags & A_COMMENT) {
X***************
X*** 256,263
X current.tm_mday = First.tm_mday;
X else if (appt.flags & EVERY_SOMEDAY) {
X if (Pickday(appt.flags) == First.tm_wday) {
X! if (chk_week(appt.repeat, First.tm_mday))
X! current.tm_mday = First.tm_mday;
X }
X } else if (appt.flags & REPEAT) {
X while (ymd_compare(current, First) < 0) {
X
X--- 273,284 -----
X current.tm_mday = First.tm_mday;
X else if (appt.flags & EVERY_SOMEDAY) {
X if (Pickday(appt.flags) == First.tm_wday) {
X! if (chk_week(appt.repeat, First.tm_mday)) {
X! if (appt.flags & RUN)
X! find_date(&appt);
X! else
X! current.tm_mday = First.tm_mday;
X! }
X }
X } else if (appt.flags & REPEAT) {
X if (appt.flags & RUN)
X***************
X*** 260,268
X current.tm_mday = First.tm_mday;
X }
X } else if (appt.flags & REPEAT) {
X! while (ymd_compare(current, First) < 0) {
X! current.tm_mday += appt.repeat;
X! fix_current_day();
X }
X }
X if (ymd_compare(current, First) == 0) {
X
X--- 281,297 -----
X }
X }
X } else if (appt.flags & REPEAT) {
X! if (appt.flags & RUN)
X! runl = appt.runlength;
X! else
X! runl = 1;
X! while (ymd_compare(current, First) < 0 && runl) {
X! if (appt.flags & RUN)
X! --runl;
X! if (runl) {
X! current.tm_mday += appt.repeat;
X! fix_current_day();
X! }
X }
X }
X if (ymd_compare(current, First) == 0) {
X***************
X*** 267,273
X }
X if (ymd_compare(current, First) == 0) {
X /* if it's for this day, fill in slot info */
X! if (appt.flags & A_NOTE)
X /* notes section */
X add_note(&appt);
X else {
X
X--- 296,302 -----
X }
X if (ymd_compare(current, First) == 0) {
X /* if it's for this day, fill in slot info */
X! if (appt.flags & A_NOTE) {
X /* notes section */
X add_note(&appt);
X if (appt.flags & MARKED)
X***************
X*** 270,276
X if (appt.flags & A_NOTE)
X /* notes section */
X add_note(&appt);
X! else {
X /* regular appointment */
X slotno = (appt.hour-START_HOUR) * 2 + appt.minute / 30;
X if (slotno < 0)
X
X--- 299,311 -----
X if (appt.flags & A_NOTE) {
X /* notes section */
X add_note(&appt);
X! if (appt.flags & MARKED)
X! /* marked note */
X! some_appt |= SOME_MKNOTES;
X! else
X! /* regular note */
X! some_appt |= SOME_NOTES;
X! } else {
X /* regular appointment */
X slotno = (appt.hour-START_HOUR) * 2 + appt.minute / 30;
X if (slotno < 0)
X***************
X*** 280,285
X /* add this appt to the list of appts for the slot */
X /* and update all the reference counts */
X add_to_slot(slotno, &appt, FALSE);
X }
X } else if (appt.flags & LOOKAHEAD) {
X /* This lookahead appt was not for today, so
X
X--- 315,321 -----
X /* add this appt to the list of appts for the slot */
X /* and update all the reference counts */
X add_to_slot(slotno, &appt, FALSE);
X+ some_appt |= SOME_APPTS;
X }
X } else if (appt.flags & LOOKAHEAD) {
X /* This lookahead appt was not for today, so
X***************
X*** 316,321
X future[findex].month = save_day.tm_mon;
X future[findex].day = save_day.tm_mday;
X ++findex;
X }
X }
X } else { /* line is not for today */
X
X--- 352,358 -----
X future[findex].month = save_day.tm_mon;
X future[findex].day = save_day.tm_mday;
X ++findex;
X+ some_appt |= SOME_FUTURES;
X }
X }
X } else { /* line is not for today */
X***************
X*** 334,350
X fclose(apts);
X current = First;
X fix_current_day();
X! /* now check to see if there is anything happening this day */
X! if (findex)
X! some_appt = 1;
X! else {
X! for (i=0; i<N_SLOTS; i++) {
X! if (slots[i].count > 0) {
X! some_appt = 1;
X! break;
X! }
X! }
X! }
X return(some_appt);
X }
X
X
X--- 371,377 -----
X fclose(apts);
X current = First;
X fix_current_day();
X!
X return(some_appt);
X }
X
X***************
X*** 380,385
X struct appt_entry *appt;
X {
X struct tm save;
X
X save = current;
X /* set current to match dow of repeated appt */
X
X--- 407,413 -----
X struct appt_entry *appt;
X {
X struct tm save;
X+ int runl;
X
X save = current;
X /* set current to match dow of repeated appt */
X***************
X*** 390,395
X current.tm_mday += 7;
X fix_current_day();
X }
X /* search for first matching week */
X while (!chk_week(appt->repeat, current.tm_mday)) {
X current.tm_mday += 7;
X
X--- 418,427 -----
X current.tm_mday += 7;
X fix_current_day();
X }
X+ if (appt->flags & RUN)
X+ runl = appt->runlength;
X+ else
X+ runl = 1;
X /* search for first matching week */
X while (!chk_week(appt->repeat, current.tm_mday) && runl) {
X current.tm_mday += 7;
X***************
X*** 391,397
X fix_current_day();
X }
X /* search for first matching week */
X! while (!chk_week(appt->repeat, current.tm_mday)) {
X current.tm_mday += 7;
X fix_current_day();
X }
X
X--- 423,429 -----
X else
X runl = 1;
X /* search for first matching week */
X! while (!chk_week(appt->repeat, current.tm_mday) && runl) {
X current.tm_mday += 7;
X fix_current_day();
X if (appt->flags & RUN)
X***************
X*** 394,399
X while (!chk_week(appt->repeat, current.tm_mday)) {
X current.tm_mday += 7;
X fix_current_day();
X }
X /* now check to make sure this is legal, i.e. there
X * were no month or year restrictions
X
X--- 426,433 -----
X while (!chk_week(appt->repeat, current.tm_mday) && runl) {
X current.tm_mday += 7;
X fix_current_day();
X+ if (appt->flags & RUN)
X+ --runl;
X }
X /* now check to make sure this is legal, i.e. there
X * were no month or year restrictions and runlength
X***************
X*** 396,402
X fix_current_day();
X }
X /* now check to make sure this is legal, i.e. there
X! * were no month or year restrictions
X */
X if ((!(appt->flags & ALL_YEARS) && current.tm_year != save.tm_year)
X || (!(appt->flags & ALL_MONTHS) && current.tm_mon != save.tm_mon))
X
X--- 430,437 -----
X --runl;
X }
X /* now check to make sure this is legal, i.e. there
X! * were no month or year restrictions and runlength
X! * wasn't exceeded
X */
X if (!runl || (!(appt->flags & ALL_YEARS) && current.tm_year != save.tm_year)
X || (!(appt->flags & ALL_MONTHS) && current.tm_mon != save.tm_mon))
X***************
X*** 398,404
X /* now check to make sure this is legal, i.e. there
X * were no month or year restrictions
X */
X! if ((!(appt->flags & ALL_YEARS) && current.tm_year != save.tm_year)
X || (!(appt->flags & ALL_MONTHS) && current.tm_mon != save.tm_mon))
X /* invalid date, due to month or year wrap */
X current = save;
X
X--- 433,439 -----
X * were no month or year restrictions and runlength
X * wasn't exceeded
X */
X! if (!runl || (!(appt->flags & ALL_YEARS) && current.tm_year != save.tm_year)
X || (!(appt->flags & ALL_MONTHS) && current.tm_mon != save.tm_mon))
X /* invalid date, due to month or year wrap */
X current = save;
X***************
X*** 409,415
X add_note(appt)
X struct appt_entry *appt;
X {
X! int slotno;
X
X /* auto-hunt for free note slot */
X for (slotno=n_tslots; slotno<N_SLOTS; slotno++)
X
X--- 444,451 -----
X add_note(appt)
X struct appt_entry *appt;
X {
X! int slotno, found = 0;
X! struct appt_entry *optr;
X
X /* This used to just find a free slot and add the note
X * to it. However, with deleted notes we need to find
X***************
X*** 411,420
X {
X int slotno;
X
X! /* auto-hunt for free note slot */
X! for (slotno=n_tslots; slotno<N_SLOTS; slotno++)
X! if (slots[slotno].active == INACTIVE)
X! break;
X if (slotno == N_SLOTS) {
X /* overflow of notes field, so
X * add to last note field list
X
X--- 447,484 -----
X int slotno, found = 0;
X struct appt_entry *optr;
X
X! /* This used to just find a free slot and add the note
X! * to it. However, with deleted notes we need to find
X! * the matching slotno (if it exists) to make sure that
X! * the deleted and non-deleted notes end up in the same
X! * slot number (so they won't be displayed).
X! */
X! if (appt->flags & DELETED) {
X! /* look for matching non-deleted note */
X! for (slotno=n_tslots; slotno<N_SLOTS && !found; slotno++) {
X! if (slots[slotno].active == INACTIVE)
X! break; /* no more notes */
X! for (optr=slots[slotno].first;optr;optr=optr->next) {
X! if (!strcmp(appt->str, optr->str) && !(optr->flags & DELETED)) {
X! found = 1;
X! break;
X! }
X! }
X! }
X! } else {
X! /* look for matching deleted note */
X! for (slotno=n_tslots; slotno<N_SLOTS && !found; slotno++) {
X! if (slots[slotno].active == INACTIVE)
X! break; /* no more notes */
X! for (optr=slots[slotno].first;optr;optr=optr->next)
X! if (!strcmp(appt->str, optr->str) && (optr->flags & DELETED)) {
X! found = 1;
X! break;
X! }
X! }
X! }
X! if (found)
X! --slotno; /* for loop incremented slotno */
X if (slotno == N_SLOTS) {
X /* overflow of notes field, so
X * add to last note field list
X***************
X*** 424,429
X add_to_slot(slotno, appt, FALSE);
X }
X
X /* draw in todays appointments */
X draw_day_appts()
X {
X
X--- 488,494 -----
X add_to_slot(slotno, appt, FALSE);
X }
X
X+ #ifndef NOTOOL
X /* draw in todays appointments */
X draw_day_appts()
X {
X***************
X*** 555,560
X }
X }
X }
X
X /*
X * Add an appointment entry pointed to by aptr to the day slot
X
X--- 620,626 -----
X }
X }
X }
X+ #endif /* NOTOOL */
X
X /*
X * Add an appointment entry pointed to by aptr to the day slot
X***************
X*** 600,606
X n_arrows = nappt->arrows;
X if (nappt->flags & DELETED) {
X /* look for matching non-deleted appt in list */
X! for (optr=slots[slotno].first;optr;optr=optr->next)
X if (!strcmp(nappt->str, optr->str) && !(optr->flags & DELETED)) {
X found = 1;
X break;
X
X--- 666,672 -----
X n_arrows = nappt->arrows;
X if (nappt->flags & DELETED) {
X /* look for matching non-deleted appt in list */
X! for (optr=slots[slotno].first;optr && !found;optr=optr->next)
X if (!strcmp(nappt->str, optr->str) && !(optr->flags & DELETED)) {
X found = 1;
X break;
X***************
X*** 645,651
X }
X } else {
X /* look for matching deleted appt in list */
X! for (optr=slots[slotno].first;optr;optr=optr->next)
X if (!strcmp(nappt->str, optr->str) && optr->flags & DELETED) {
X found = 1;
X break;
X
X--- 711,717 -----
X }
X } else {
X /* look for matching deleted appt in list */
X! for (optr=slots[slotno].first;optr && !found;optr=optr->next)
X if (!strcmp(nappt->str, optr->str) && optr->flags & DELETED) {
X found = 1;
X break;
X*** /tmp/,RCSt1a16937 Fri Dec 15 17:22:58 1989
X--- event.c Fri Dec 15 17:17:33 1989
X***************
X*** 1,5
X /*
X! * $Header: event.c,v 2.1 89/05/09 14:23:23 billr Exp $
X */
X /*
X * event.c
X
X--- 1,5 -----
X /*
X! * $Header: event.c,v 2.2 89/12/15 17:17:30 billr Exp $
X */
X /*
X * event.c
X***************
X*** 40,46
X extern Frame fframe, sframe, mframe;
X extern struct tm olddate;
X extern int update_interval, show_time;
X! extern char timestr[], todays_date[];
X extern Icon icon;
X Notify_value myframe_interposer();
X
X
X--- 40,46 -----
X extern Frame fframe, sframe, mframe;
X extern struct tm olddate;
X extern int update_interval, show_time;
X! extern char timestr[];
X extern Icon icon;
X extern int monday_first, hour24;
X extern Pixfont *sfont;
X***************
X*** 42,47
X extern int update_interval, show_time;
X extern char timestr[], todays_date[];
X extern Icon icon;
X Notify_value myframe_interposer();
X
X void
X
X--- 42,49 -----
X extern int update_interval, show_time;
X extern char timestr[];
X extern Icon icon;
X+ extern int monday_first, hour24;
X+ extern Pixfont *sfont;
X Notify_value myframe_interposer();
X
X void
X***************
X*** 120,125
X (y <= week_arrows[i].bottom)) {
X week_index = i;
X current.tm_mday = -current.tm_wday + 1 + (7 * week_index);
X selected_type = WEEK;
X pw_write(main_pixwin,week_arrows[week_index].left,
X week_arrows[week_index].top,smallarrow_pr->pr_size.x,
X
X--- 122,129 -----
X (y <= week_arrows[i].bottom)) {
X week_index = i;
X current.tm_mday = -current.tm_wday + 1 + (7 * week_index);
X+ if (monday_first)
X+ current.tm_mday++;
X selected_type = WEEK;
X pw_write(main_pixwin,week_arrows[week_index].left,
X week_arrows[week_index].top,smallarrow_pr->pr_size.x,
X***************
X*** 211,217
X sframe_done(0);
X #endif
X check_calendar(); /* update icon */
X! if (show_time) {
X /* update time label */
X strcpy(timestr, todays_date+10);
X if (update_interval == 60)
X
X--- 215,221 -----
X sframe_done(0);
X #endif
X check_calendar(); /* update icon */
X! if (show_time)
X /* update time label */
X update_icon_time();
X }
X***************
X*** 213,227
X check_calendar(); /* update icon */
X if (show_time) {
X /* update time label */
X! strcpy(timestr, todays_date+10);
X! if (update_interval == 60)
X! /* display hh:mm */
X! timestr[6] = '\0';
X! else
X! /* display hh:mm:ss */
X! timestr[9] = '\0';
X! cur_icon = (Icon) window_get(frame, FRAME_ICON);
X! icon_set(cur_icon, ICON_LABEL, timestr, 0);
X! window_set(frame, FRAME_ICON, cur_icon, 0);
X }
X }
X
X--- 217,256 -----
X check_calendar(); /* update icon */
X if (show_time)
X /* update time label */
X! update_icon_time();
X! }
X!
X! /* update the time field of the current icon */
X! update_icon_time()
X! {
X! Icon cur_icon;
X!
X! format_icon_time();
X! cur_icon = (Icon) window_get(frame, FRAME_ICON);
X! icon_set(cur_icon, ICON_LABEL, timestr, 0);
X! window_set(frame, FRAME_ICON, cur_icon, 0);
X! }
X!
X! format_icon_time()
X! {
X! if (update_interval >= 60)
X! /* display hh:mm */
X! sprintf(timestr, " %2d:%02d", today.tm_hour, today.tm_min);
X! else
X! /* display hh:mm:ss */
X! sprintf(timestr, " %2d:%02d:%02d", today.tm_hour, today.tm_min, today.tm_sec);
X! if (!hour24) {
X! /* display am/pm for 12-hour time */
X! if (today.tm_hour > 12) {
X! strcat(timestr, "pm");
X! timestr[1] = ((today.tm_hour - 12) / 10) + '0';
X! timestr[2] = ((today.tm_hour - 12) % 10) + '0';
X! } else if (today.tm_hour == 12) {
X! strcat(timestr, "pm");
X! } else {
X! strcat(timestr, "am");
X! }
X! if (timestr[1] == '0')
X! timestr[1] = ' ';
X }
X }
X*** /tmp/,RCSt1a24048 Mon Dec 18 17:14:37 1989
X--- dates/space Mon Dec 18 17:13:53 1989
X***************
X*** 1,5
X # CalenTool V2 - DO NOT REMOVE THIS LINE
X! # $Header: space,v 1.2 89/08/25 11:18:46 billr Exp $
X # Special days file for calentool (rel 2.1)
X # Submitted by Steve Gilbreath <steve at prism.gatech.edu>
X # Space events of note
X
X--- 1,5 -----
X # CalenTool V2 - DO NOT REMOVE THIS LINE
X! # $Header: space,v 2.1 89/12/18 17:13:32 billr Exp $
X # Special days file for calentool (rel 2.1)
X # Submitted by Steve Gilbreath <steve at prism.gatech.edu>
X # Space events of note
X***************
X*** 111,117
X ** 04 20 99 99 00 Soyuz T-8 launched; mission aborted when capsule failed to dock with Salyut station. (1983)
X ** 04 23 99 99 00 Advisory council for Aeronautics became National Advisory Council on Aeronautics (NACA). (1915)
X ** 04 23 99 99 00 Launch of 1st Soviet communications satelite. (1965)
X! ** 04 23 99 99 00 USSR Soyus 1 launched with Vladimir Komarov becoming the 1st cosomonaut to make 2 flights. He also became 1st man to die in space after his parachute line tangled on re-entry. Soyus 1. All Soviet manned flights ceased for 18 months.
(1967)
X ** 04 24 99 99 00 China becomes 5th nation to launch artificial satellite. (1970)
X ** 04 25 99 99 00 Mercury/Atlas rocket lifted off with an electronic mannequin; when inertial guidance system failed 40 seconds after launch the rocket was destroyed by range safety officer. (1961)
X ** 04 26 99 99 00 US/UK launched Ariel; 1st International payload. (1962)
X
X--- 111,117 -----
X ** 04 20 99 99 00 Soyuz T-8 launched; mission aborted when capsule failed to dock with Salyut station. (1983)
X ** 04 23 99 99 00 Advisory council for Aeronautics became National Advisory Council on Aeronautics (NACA). (1915)
X ** 04 23 99 99 00 Launch of 1st Soviet communications satelite. (1965)
X! ** 04 23 99 99 00 USSR Soyus 1 launched with Vladimir Komarov becoming the 1st cosomonaut to make 2 flights. Also became 1st man to die in space after his parachute line tangled on re-entry. All Soviet manned flights ceased for 18 months. (1967)
X ** 04 24 99 99 00 China becomes 5th nation to launch artificial satellite. (1970)
X ** 04 25 99 99 00 Mercury/Atlas rocket lifted off with an electronic mannequin; when inertial guidance system failed 40 seconds after launch the rocket was destroyed by range safety officer. (1961)
X ** 04 26 99 99 00 US/UK launched Ariel; 1st International payload. (1962)
X*** /tmp/,RCSt1a24057 Mon Dec 18 17:15:10 1989
X--- dates/world Mon Dec 18 17:14:16 1989
X***************
X*** 1,5
X # CalenTool V2 - DO NOT REMOVE THIS LINE
X! # $Header: world,v 2.2 89/05/16 10:46:16 billr Exp $
X # Special days file for calentool (rel 2.1); modified from network posting by
X # RPC Rodgers, UCSF, Nov. 1988
X # Various holidays commemorated around the world (non-US and Canadian)
X
X--- 1,5 -----
X # CalenTool V2 - DO NOT REMOVE THIS LINE
X! # $Header: world,v 2.3 89/12/18 17:14:00 billr Exp $
X # Special days file for calentool (rel 2.1); modified from network posting by
X # RPC Rodgers, UCSF, Nov. 1988
X # Various holidays commemorated around the world (non-US and Canadian)
X***************
X*** 41,47
X ** 01 23 99 99 00 Feast of St. Ildefonsus
X ** 01 24 99 99 00 Economic Liberation Day (Togo)
X ** 01 26 99 99 00 Republic Day (India)
X! ** 01 30 99 99 00 Australia Day (Australia)
X ** 02 01 99 99 00 Chinese New Year Holiday (3 days) (Taiwan)
X ** 02 03 99 99 00 Setsubun, Change of Season or "Bean Throwing Night" (Japan)
X ** 02 04 99 99 00 Independence Commemoration Day (Sri Lanka)
X
X--- 41,47 -----
X ** 01 23 99 99 00 Feast of St. Ildefonsus
X ** 01 24 99 99 00 Economic Liberation Day (Togo)
X ** 01 26 99 99 00 Republic Day (India)
X! ** 01 26 99 99 00 Australia Day (Australia)
X ** 02 01 99 99 00 Chinese New Year Holiday (3 days) (Taiwan)
X ** 02 03 99 99 00 Setsubun, Change of Season or "Bean Throwing Night" (Japan)
X ** 02 04 99 99 00 Independence Commemoration Day (Sri Lanka)
X***************
X*** 366,372
X ** 09 30 99 99 00 Botswanna Day (Botswanna)
X ** 10 01 99 99 00 Armed Forces Day (South Korea)
X ** 10 01 99 99 00 Independence Day (Nigeria)
X! ** 10 01 99 99 00 Labor Day (Australia)
X ** 10 01 99 99 00 National Liberation Day (2 days) (China)
X ** 10 01 99 99 00 Public Holiday (Botswanna)
X ** 10 02 99 99 00 Anniversary of Guinean Independence (Guinea)
X
X--- 366,372 -----
X ** 09 30 99 99 00 Botswanna Day (Botswanna)
X ** 10 01 99 99 00 Armed Forces Day (South Korea)
X ** 10 01 99 99 00 Independence Day (Nigeria)
X! #** 10 01 99 99 00 Labor Day (Australia) [really 1st Monday in October]
X ** 10 01 99 99 00 National Liberation Day (2 days) (China)
X ** 10 01 99 99 00 Public Holiday (Botswanna)
X ** 10 02 99 99 00 Anniversary of Guinean Independence (Guinea)
END_OF_FILE
if test 46931 -ne `wc -c <'patches05b'`; then
echo shar: \"'patches05b'\" unpacked with wrong size!
fi
# end of 'patches05b'
fi
echo shar: End of archive 2 \(of 4\).
cp /dev/null ark2isdone
MISSING=""
for I in 1 2 3 4 ; do
if test ! -f ark${I}isdone ; then
MISSING="${MISSING} ${I}"
fi
done
if test "${MISSING}" = "" ; then
echo You have unpacked all 4 archives.
rm -f ark[1-9]isdone
else
echo You still need to unpack the following archives:
echo " " ${MISSING}
fi
## End of shell archive.
exit 0
More information about the Comp.sources.sun
mailing list