home *** CD-ROM | disk | FTP | other *** search
Text File | 1990-02-04 | 50.3 KB | 2,026 lines |
- *** /tmp/,RCSt1a02457 Tue Dec 19 11:34:42 1989
- --- utils.c Tue Dec 19 11:34:15 1989
- ***************
- *** 1,5
- /*
- ! * $Header: utils.c,v 2.3 89/07/19 20:31:40 billr Exp $
- */
- /*
- * utils.c
-
- --- 1,5 -----
- /*
- ! * $Header: utils.c,v 2.5 89/12/19 11:33:44 billr Exp $
- */
- /*
- * utils.c
- ***************
- *** 22,27
- * Permission is hereby granted to use and modify the modifications in source
- * or binary form as long as they are not sold for profit and this copyright
- * notice remains intact.
- */
- /********************************************
- * *
-
- --- 22,29 -----
- * Permission is hereby granted to use and modify the modifications in source
- * or binary form as long as they are not sold for profit and this copyright
- * notice remains intact.
- + * Modified parse_date to allow +nnn and -nnn syntax for dates relative to the
- + * current date. Peter Marshall <peter.marshall@uwo.ca>. 1989-09-19.
- */
- /********************************************
- * *
- ***************
- *** 33,38
-
- #include "ct.h"
- #include <stdio.h>
- #include <suntool/sunview.h>
- #include <suntool/canvas.h>
- #include <ctype.h>
-
- --- 35,41 -----
-
- #include "ct.h"
- #include <stdio.h>
- + #ifndef NOTOOL
- #include <suntool/sunview.h>
- #include <suntool/canvas.h>
- #endif /* NOTOOL */
- ***************
- *** 35,40
- #include <stdio.h>
- #include <suntool/sunview.h>
- #include <suntool/canvas.h>
- #include <ctype.h>
- #include <sys/types.h>
- #include <sys/file.h>
-
- --- 38,44 -----
- #ifndef NOTOOL
- #include <suntool/sunview.h>
- #include <suntool/canvas.h>
- + #endif /* NOTOOL */
- #include <ctype.h>
- #include <sys/types.h>
- #include <sys/time.h>
- ***************
- *** 37,42
- #include <suntool/canvas.h>
- #include <ctype.h>
- #include <sys/types.h>
- #include <sys/file.h>
- #include <sys/stat.h>
- #include <sys/errno.h>
-
- --- 41,47 -----
- #endif /* NOTOOL */
- #include <ctype.h>
- #include <sys/types.h>
- + #include <sys/time.h>
- #include <sys/file.h>
- #include <sys/stat.h>
- #include <sys/errno.h>
- ***************
- *** 54,60
- extern int one_based, version2, new_entry;
- extern int findex;
- extern struct appt_entry future[];
- - extern char todays_date[];
- extern char apts_dir[], lib_dir[];
- extern char printer[];
- extern int include_old, save_old;
-
- --- 59,64 -----
- extern int one_based, version2, new_entry;
- extern int findex;
- extern struct appt_entry future[];
- extern char apts_dir[], lib_dir[];
- extern int include_old, save_old, expire_days;
- #ifndef NOTOOL
- ***************
- *** 56,61
- extern struct appt_entry future[];
- extern char todays_date[];
- extern char apts_dir[], lib_dir[];
- extern char printer[];
- extern int include_old, save_old;
- extern Frame frame;
-
- --- 60,67 -----
- extern int findex;
- extern struct appt_entry future[];
- extern char apts_dir[], lib_dir[];
- + extern int include_old, save_old, expire_days;
- + #ifndef NOTOOL
- extern char printer[];
- extern Frame frame;
- extern Canvas canvas;
- ***************
- *** 57,63
- extern char todays_date[];
- extern char apts_dir[], lib_dir[];
- extern char printer[];
- - extern int include_old, save_old;
- extern Frame frame;
- extern Canvas canvas;
- extern Pixwin *main_pixwin;
-
- --- 63,68 -----
- extern int include_old, save_old, expire_days;
- #ifndef NOTOOL
- extern char printer[];
- extern Frame frame;
- extern Canvas canvas;
- extern Pixwin *main_pixwin;
- ***************
- *** 65,70
- extern Pixfont *font, *sfont;
- extern Frame prompt_frame;
- extern int update_interval;
- extern int errno;
-
- char inbuf[512], strbuf[256], errbuf[64];
-
- --- 70,77 -----
- extern Pixfont *font, *sfont;
- extern Frame prompt_frame;
- extern int update_interval;
- + extern int monday_first, hour24, day_first;
- + #endif /* NOTOOL */
- extern int errno;
-
- char inbuf[512], strbuf[256], errbuf[128];
- ***************
- *** 67,75
- extern int update_interval;
- extern int errno;
-
- ! char inbuf[512], strbuf[256], errbuf[64];
- ! char todays_date[32];
- ! static int including;
- static int log_to_console;
- char *daynames[] = {"Sunday","Monday","Tuesday","Wednesday",
- "Thursday","Friday","Saturday"};
-
- --- 74,82 -----
- #endif /* NOTOOL */
- extern int errno;
-
- ! char inbuf[512], strbuf[256], errbuf[128];
- ! char clockstr[32];
- ! static int include_level = 0;
- static int log_to_console;
- char *daynames[] = {"Sunday","Monday","Tuesday","Wednesday",
- "Thursday","Friday","Saturday"};
- ***************
- *** 76,81
- char *monthnames[] = {"January","February","March","April",
- "May","June","July","August",
- "September","October","November","December"};
- char *dayname[7] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
- char rasfile[] = "/usr/tmp/calentool.ras";
- char psfile[] = "/usr/tmp/calentool.ps";
-
- --- 83,91 -----
- char *monthnames[] = {"January","February","March","April",
- "May","June","July","August",
- "September","October","November","December"};
- + char *smonthnames[] = {"Jan","Feb","Mar","Apr",
- + "May","Jun","Jul","Aug",
- + "Sep","Oct","Nov","Dec"};
- char *dayname[7] = {"SU", "MO", "TU", "WE", "TH", "FR", "SA"};
- char rasfile[] = "/usr/tmp/calentool.ras";
- char psfile[] = "/usr/tmp/calentool.ps";
- ***************
- *** 91,96
- {
- struct tm *tm;
- struct timeval tv;
-
- gettimeofday(&tv, 0);
- tm = localtime(&tv.tv_sec);
-
- --- 101,107 -----
- {
- struct tm *tm;
- struct timeval tv;
- + char timstr[16];
-
- gettimeofday(&tv, 0);
- tm = localtime(&tv.tv_sec);
- ***************
- *** 97,103
-
- today = *tm;
-
- ! strcpy(todays_date, asctime(tm));
- if (update_interval >= 60)
- /* overwrite seconds field with year */
- sprintf(&todays_date[16], " %d", today.tm_year+1900);
-
- --- 108,120 -----
-
- today = *tm;
-
- ! #ifndef CALENCHECK
- ! if (day_first)
- ! sprintf(clockstr, "%3.3s %d %s %d, ", daynames[today.tm_wday],
- ! today.tm_mday, smonthnames[today.tm_mon], today.tm_year+1900);
- ! else
- ! sprintf(clockstr, "%3.3s %s %d %d, ", daynames[today.tm_wday],
- ! smonthnames[today.tm_mon], today.tm_mday, today.tm_year+1900);
- if (update_interval >= 60)
- sprintf(timstr, "%02d:%02d", today.tm_hour, today.tm_min);
- else
- ***************
- *** 99,106
-
- strcpy(todays_date, asctime(tm));
- if (update_interval >= 60)
- ! /* overwrite seconds field with year */
- ! sprintf(&todays_date[16], " %d", today.tm_year+1900);
- else
- /* just delete trailing \n */
- todays_date[strlen(todays_date)-1] = '\0';
-
- --- 116,122 -----
- sprintf(clockstr, "%3.3s %s %d %d, ", daynames[today.tm_wday],
- smonthnames[today.tm_mon], today.tm_mday, today.tm_year+1900);
- if (update_interval >= 60)
- ! sprintf(timstr, "%02d:%02d", today.tm_hour, today.tm_min);
- else
- sprintf(timstr, "%02d:%02d:%02d", today.tm_hour, today.tm_min, today.tm_sec);
- if (!hour24) {
- ***************
- *** 102,109
- /* overwrite seconds field with year */
- sprintf(&todays_date[16], " %d", today.tm_year+1900);
- else
- ! /* just delete trailing \n */
- ! todays_date[strlen(todays_date)-1] = '\0';
- }
-
- /*
-
- --- 118,140 -----
- if (update_interval >= 60)
- sprintf(timstr, "%02d:%02d", today.tm_hour, today.tm_min);
- else
- ! sprintf(timstr, "%02d:%02d:%02d", today.tm_hour, today.tm_min, today.tm_sec);
- ! if (!hour24) {
- ! /* display am/pm for 12-hour time */
- ! if (today.tm_hour > 12) {
- ! strcat(timstr, "pm");
- ! timstr[0] = ((today.tm_hour - 12) / 10) + '0';
- ! timstr[1] = ((today.tm_hour - 12) % 10) + '0';
- ! } else if (today.tm_hour == 12) {
- ! strcat(timstr, "pm");
- ! } else {
- ! strcat(timstr, "am");
- ! }
- ! if (timstr[0] == '0')
- ! timstr[0] = ' ';
- ! }
- ! strcat(clockstr, timstr);
- ! #endif /* CALENCHECK */
- }
-
- /*
- ***************
- *** 140,169
- current.tm_year++;
- }
- }
- ! current.tm_yday = current.tm_mday - 1;
- ! for (month = 0; month < current.tm_mon; month++) {
- ! current.tm_yday += monthlength(month);
- ! }
- ! if ((current.tm_year < today.tm_year)
- ! || ((current.tm_year == today.tm_year)
- ! && (current.tm_yday < today.tm_yday))) {
- ! from = current;
- ! to = today;
- ! } else {
- ! from = today;
- ! to = current;
- ! }
- ! if (from.tm_year != to.tm_year) {
- ! for (totdays = 0; from.tm_year < to.tm_year; from.tm_year++)
- ! totdays += dysize(from.tm_year + 1900);
- ! }
- ! totdays += to.tm_yday - from.tm_yday;
- ! if ((current.tm_year < today.tm_year)
- ! || ((current.tm_year == today.tm_year)
- ! && (current.tm_yday < today.tm_yday)))
- ! totdays = -totdays;
- ! current.tm_wday =
- ! ((totdays % 7) + 7 + today.tm_wday) % 7;
- }
-
- /*
-
- --- 171,178 -----
- current.tm_year++;
- }
- }
- ! current.tm_yday = day_of_year((double)current.tm_mday, current.tm_mon+1, current.tm_year+1900);
- ! current.tm_wday = get_day_of_week((double)current.tm_mday, current.tm_mon+1, current.tm_year+1900);
- }
-
- /*
- ***************
- *** 188,194
- {
- static int monthlengths[] = {31,28,31,30,31,30,31,31,30,31,30,31};
-
- ! if (month == FEB && (dysize(current.tm_year + 1900) == 366))
- return(29);
- else
- return(monthlengths[month]);
-
- --- 197,203 -----
- {
- static int monthlengths[] = {31,28,31,30,31,30,31,31,30,31,30,31};
-
- ! if (month == FEB && (length_of_year(current.tm_year + 1900) == 366))
- return(29);
- else
- return(monthlengths[month]);
- ***************
- *** 194,199
- return(monthlengths[month]);
- }
-
- /*
- *
- * Append data from active timeslots to end of "tmp.appointments"
-
- --- 203,209 -----
- return(monthlengths[month]);
- }
-
- + #ifndef CALENCHECK
- /*
- *
- * Append data from active timeslots to end of "tmp.appointments"
- ***************
- *** 256,261
- return(1);
- xrename(tmpapts_pathname, apts_pathname);
- }
-
- /*
- * get entry from appointments file
-
- --- 266,272 -----
- return(1);
- xrename(tmpapts_pathname, apts_pathname);
- }
- + #endif /* CALENCHECK */
-
- /*
- * get entry from appointments file
- ***************
- *** 260,266
- /*
- * get entry from appointments file
- */
- ! get_aentry(apts_file, appt)
- FILE *apts_file;
- struct appt_entry *appt;
- {
-
- --- 271,277 -----
- /*
- * get entry from appointments file
- */
- ! get_aentry(apts_file, appt, noInclude)
- FILE *apts_file;
- struct appt_entry *appt;
- int noInclude;
- ***************
- *** 263,268
- get_aentry(apts_file, appt)
- FILE *apts_file;
- struct appt_entry *appt;
- {
- char *ptr, *str;
- char *fgets(), *index();
-
- --- 274,280 -----
- get_aentry(apts_file, appt, noInclude)
- FILE *apts_file;
- struct appt_entry *appt;
- + int noInclude;
- {
- char *ptr, *str;
- char *fgets(), *index();
- ***************
- *** 267,273
- char *ptr, *str;
- char *fgets(), *index();
- char *incl_ptr, incl_buf[128], wday[3];
- ! int i, lib;
- struct stat sbuf;
- static FILE *include;
-
-
- --- 279,285 -----
- char *ptr, *str;
- char *fgets(), *index();
- char *incl_ptr, incl_buf[128], wday[3];
- ! int i, lib, parse_options, nodata = 1;
- struct stat sbuf;
- static FILE *include[MAX_INCLUDE_NESTING];
-
- ***************
- *** 269,275
- char *incl_ptr, incl_buf[128], wday[3];
- int i, lib;
- struct stat sbuf;
- ! static FILE *include;
-
- appt->flags = appt->repeat = appt->lookahead = 0;
- appt->sindex = 0;
-
- --- 281,287 -----
- char *incl_ptr, incl_buf[128], wday[3];
- int i, lib, parse_options, nodata = 1;
- struct stat sbuf;
- ! static FILE *include[MAX_INCLUDE_NESTING];
-
- appt->flags = appt->repeat = appt->lookahead = 0;
- appt->sindex = 0;
- ***************
- *** 273,278
-
- appt->flags = appt->repeat = appt->lookahead = 0;
- appt->sindex = 0;
- appt->next = NULL;
- if (including) {
- if (fgets(inbuf, 512, include) == NULL) {
-
- --- 285,291 -----
-
- appt->flags = appt->repeat = appt->lookahead = 0;
- appt->sindex = 0;
- + appt->runlength = 0;
- appt->next = NULL;
- /* If noInclude is set then don't follow include files, i.e.
- * treat #include directives as comments. This is useful for
- ***************
- *** 274,286
- appt->flags = appt->repeat = appt->lookahead = 0;
- appt->sindex = 0;
- appt->next = NULL;
- ! if (including) {
- ! if (fgets(inbuf, 512, include) == NULL) {
- ! /* end of include file - get next entry
- ! * from main file
- ! */
- ! including = 0;
- ! fclose(include);
- if (fgets(inbuf, 512, apts_file) == NULL)
- return(EOF);
- } else {
-
- --- 287,310 -----
- appt->sindex = 0;
- appt->runlength = 0;
- appt->next = NULL;
- ! /* If noInclude is set then don't follow include files, i.e.
- ! * treat #include directives as comments. This is useful for
- ! * copying the appts file.
- ! */
- ! while (nodata) {
- ! if (include_level) {
- ! if (fgets(inbuf, 512, include[include_level-1]) == NULL) {
- ! /* end of include file - get next entry
- ! * from previous level of nesting
- ! */
- ! fclose(include[include_level-1]);
- ! include_level--;
- ! } else {
- ! /* don't modify stuff from include files */
- ! appt->flags |= READONLY;
- ! nodata = 0; /* still data in file */
- ! }
- ! } else {
- if (fgets(inbuf, 512, apts_file) == NULL)
- return(EOF);
- else
- ***************
- *** 283,292
- fclose(include);
- if (fgets(inbuf, 512, apts_file) == NULL)
- return(EOF);
- ! } else {
- ! including = 2;
- ! /* don't modify stuff from include files */
- ! appt->flags |= READONLY;
- }
- } else
- if (fgets(inbuf, 512, apts_file) == NULL)
-
- --- 307,314 -----
- } else {
- if (fgets(inbuf, 512, apts_file) == NULL)
- return(EOF);
- ! else
- ! nodata = 0; /* still data in file */
- }
- }
- ptr = inbuf;
- ***************
- *** 288,296
- /* don't modify stuff from include files */
- appt->flags |= READONLY;
- }
- ! } else
- ! if (fgets(inbuf, 512, apts_file) == NULL)
- ! return(EOF);
- ptr = inbuf;
- if (*ptr == '#') {
- if (!strcmp(inbuf, HEADER) && !including) {
-
- --- 310,316 -----
- else
- nodata = 0; /* still data in file */
- }
- ! }
- ptr = inbuf;
- if (noInclude && *ptr == '#') {
- appt->flags |= A_COMMENT;
- ***************
- *** 292,297
- if (fgets(inbuf, 512, apts_file) == NULL)
- return(EOF);
- ptr = inbuf;
- if (*ptr == '#') {
- if (!strcmp(inbuf, HEADER) && !including) {
- /* first line in file read */
-
- --- 312,321 -----
- }
- }
- ptr = inbuf;
- + if (noInclude && *ptr == '#') {
- + appt->flags |= A_COMMENT;
- + return(0);
- + }
- if (*ptr == '#') {
- if (!strcmp(inbuf, HEADER) && !include_level) {
- /* first line in base file read */
- ***************
- *** 293,300
- return(EOF);
- ptr = inbuf;
- if (*ptr == '#') {
- ! if (!strcmp(inbuf, HEADER) && !including) {
- ! /* first line in file read */
- if (include_old && (First.tm_year < today.tm_year)) {
- /* read in old include file (if it exists) */
- /* prepend directory info */
-
- --- 317,324 -----
- return(0);
- }
- if (*ptr == '#') {
- ! if (!strcmp(inbuf, HEADER) && !include_level) {
- ! /* first line in base file read */
- if (include_old && (First.tm_year < today.tm_year)) {
- /* read in old include file (if it exists) */
- /* prepend directory info */
- ***************
- *** 301,310
- sprintf(incl_buf, "%s/.appointments.%02d",
- apts_dir, First.tm_year);
- if (!stat(incl_buf, &sbuf)) {
- ! if ((include = fopen(incl_buf, "r")) == NULL)
- ! err_rpt("can't open include file (ignored)", NON_FATAL);
- ! else
- ! including = 1;
- }
- }
- } else if (!strncmp(inbuf, "#include", 8)) {
-
- --- 325,337 -----
- sprintf(incl_buf, "%s/.appointments.%02d",
- apts_dir, First.tm_year);
- if (!stat(incl_buf, &sbuf)) {
- ! if ((include[include_level] = fopen(incl_buf, "r")) == NULL) {
- ! strcpy(errbuf, "can't open include file <");
- ! strcat(errbuf, incl_buf);
- ! strcat(errbuf, "> (ignored)");
- ! err_rpt(errbuf, NON_FATAL);
- ! } else
- ! include_level++;
- }
- }
- } else if (!strncmp(inbuf, "#include", 8)) {
- ***************
- *** 309,316
- }
- } else if (!strncmp(inbuf, "#include", 8)) {
- /* include file */
- ! if (including)
- ! err_rpt("include files may not be nested", FATAL);
- incl_ptr = strbuf;
- if ((ptr = index(inbuf, '"')) == NULL)
-
-
- --- 336,346 -----
- }
- } else if (!strncmp(inbuf, "#include", 8)) {
- /* include file */
- ! if (include_level > MAX_INCLUDE_NESTING) {
- ! err_rpt("include files nested too deep (ignored)", NON_FATAL);
- ! appt->flags |= A_COMMENT;
- ! return(0);
- ! }
- incl_ptr = strbuf;
- if ((ptr = index(inbuf, '"')) == NULL)
-
- ***************
- *** 316,321
-
- if ((ptr = index(inbuf, '<')) == NULL) {
- err_rpt("missing '\"' or '<' in include file spec", NON_FATAL);
- return(0);
- } else {
- lib = 1;
-
- --- 346,352 -----
-
- if ((ptr = index(inbuf, '<')) == NULL) {
- err_rpt("missing '\"' or '<' in include file spec", NON_FATAL);
- + appt->flags |= A_COMMENT;
- return(0);
- } else {
- lib = 1;
- ***************
- *** 327,332
- *incl_ptr++ = *ptr++;
- if (! *ptr) {
- err_rpt("missing '\"' or '>' in include file spec", NON_FATAL);
- return(0);
- }
- *incl_ptr = '\0';
-
- --- 358,364 -----
- *incl_ptr++ = *ptr++;
- if (! *ptr) {
- err_rpt("missing '\"' or '>' in include file spec", NON_FATAL);
- + appt->flags |= A_COMMENT;
- return(0);
- }
- *incl_ptr = '\0';
- ***************
- *** 339,348
- sprintf(incl_buf, "%s/%s", lib_dir, strbuf);
- else
- sprintf(incl_buf, "%s/%s", apts_dir, strbuf);
- ! if ((include = fopen(incl_buf, "r")) == NULL)
- ! err_rpt("can't open include file (ignored)", NON_FATAL);
- ! else
- ! including = 1;
- }
- appt->flags |= A_COMMENT;
- return(0);
-
- --- 371,383 -----
- sprintf(incl_buf, "%s/%s", lib_dir, strbuf);
- else
- sprintf(incl_buf, "%s/%s", apts_dir, strbuf);
- ! if ((include[include_level] = fopen(incl_buf, "r")) == NULL) {
- ! strcpy(errbuf, "can't open include file <");
- ! strcat(errbuf, incl_buf);
- ! strcat(errbuf, "> (ignored)");
- ! err_rpt(errbuf, NON_FATAL);
- ! } else
- ! include_level++;
- }
- appt->flags |= A_COMMENT;
- return(0);
- ***************
- *** 367,373
- }
- /* sanity check */
- if (appt->year < 0) {
- ! err_rpt("illegal year value (ignored)", NON_FATAL);
- return(1);
- }
- }
-
- --- 402,409 -----
- }
- /* sanity check */
- if (appt->year < 0) {
- ! sprintf(errbuf, "illegal year value [%d] (ignored)", appt->year);
- ! err_rpt(errbuf, NON_FATAL);
- return(1);
- }
- }
- ***************
- *** 383,389
- if (one_based) (appt->month)--;
- /* sanity check */
- if (appt->month < JAN || appt->month > DEC) {
- - /*
- sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
- err_rpt(errbuf, NON_FATAL);
- */
-
- --- 419,424 -----
- if (one_based) (appt->month)--;
- /* sanity check */
- if (appt->month < JAN || appt->month > DEC) {
- sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
- err_rpt(errbuf, NON_FATAL);
- return(1);
- ***************
- *** 386,393
- /*
- sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
- err_rpt(errbuf, NON_FATAL);
- - */
- - err_rpt("illegal month value (ignored)", NON_FATAL);
- return(1);
- }
- }
-
- --- 421,426 -----
- if (appt->month < JAN || appt->month > DEC) {
- sprintf(errbuf, "illegal month value [%d] (ignored)", appt->month);
- err_rpt(errbuf, NON_FATAL);
- return(1);
- }
- }
- ***************
- *** 405,411
- if (!one_based) (appt->day)++;
- /* sanity check */
- if (appt->day < 1 || appt->day > 31) {
- ! err_rpt("illegal day value (ignored)", NON_FATAL);
- return(1);
- }
- } else {
-
- --- 438,445 -----
- if (!one_based) (appt->day)++;
- /* sanity check */
- if (appt->day < 1 || appt->day > 31) {
- ! sprintf(errbuf, "illegal day value [%d] (ignored)", appt->day);
- ! err_rpt(errbuf, NON_FATAL);
- return(1);
- }
- } else {
- ***************
- *** 431,437
- appt->flags |= EVERY_SAT;
- else {
- /* sanity check */
- ! err_rpt("illegal day name (ignored)", NON_FATAL);
- return(1);
- }
- appt->day = 0;
-
- --- 465,472 -----
- appt->flags |= EVERY_SAT;
- else {
- /* sanity check */
- ! sprintf(errbuf, "illegal day name [%s] (ignored)", wday);
- ! err_rpt(errbuf, NON_FATAL);
- return(1);
- }
- appt->day = 0;
- ***************
- *** 445,451
- appt->hour += *++ptr - '0';
- /* sanity check */
- if (appt->hour < 0 || (appt->hour > 23 && appt->hour != 99)) {
- ! err_rpt("illegal hour value (ignored)", NON_FATAL);
- return(1);
- }
- if ((version2 && appt->hour == 99) || (!version2 && appt->hour == 0))
-
- --- 480,487 -----
- appt->hour += *++ptr - '0';
- /* sanity check */
- if (appt->hour < 0 || (appt->hour > 23 && appt->hour != 99)) {
- ! sprintf(errbuf, "illegal hour value [%d] (ignored)", appt->hour);
- ! err_rpt(errbuf, NON_FATAL);
- return(1);
- }
- if ((version2 && appt->hour == 99) || (!version2 && appt->hour == 0))
- ***************
- *** 460,466
- /* minutes currently can only be 00 or 30
- * unless it's a note.
- */
- ! err_rpt("illegal minute value (ignored)", NON_FATAL);
- return(1);
- }
- if ((appt->flags & A_NOTE) && version2 && appt->minute == 99)
-
- --- 496,503 -----
- /* minutes currently can only be 00 or 30
- * unless it's a note.
- */
- ! sprintf(errbuf, "illegal minute value [%d] (ignored)", appt->minute);
- ! err_rpt(errbuf, NON_FATAL);
- return(1);
- }
- if ((appt->flags & A_NOTE) && version2 && appt->minute == 99)
- ***************
- *** 472,478
- appt->arrows += *++ptr - '0';
- /* sanity check */
- if (appt->arrows < 0 || appt->arrows > N_TSLOTS) {
- ! err_rpt("illegal arrow value (ignored)", NON_FATAL);
- return(1);
- }
- ++ptr;
-
- --- 509,516 -----
- appt->arrows += *++ptr - '0';
- /* sanity check */
- if (appt->arrows < 0 || appt->arrows > N_TSLOTS) {
- ! sprintf(errbuf, "illegal arrow value [%d] (ignored)", appt->arrows);
- ! err_rpt(errbuf, NON_FATAL);
- return(1);
- }
- ++ptr;
- ***************
- *** 480,513
- ++ptr;
- /* lookahead and repeat entries are free format, i.e. they */
- /* can occur in either order */
- ! if (*ptr == '[') {
- ! appt->flags |= REPEAT;
- ! if (appt->flags & EVERY_SOMEDAY) {
- ! if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
- ! return(1);
- ! } else {
- ! if ((appt->repeat = do_repeat(&ptr)) < 0)
- ! return(1);
- ! }
- ! if (*ptr == '<') {
- ! appt->flags |= LOOKAHEAD;
- ! if ((appt->lookahead = do_lookahead(&ptr)) < 0)
- ! return(1);
- ! }
- ! if (*ptr == '#') {
- ! appt->flags |= DELETED;
- ! ++ptr;
- ! while (isspace(*ptr))
- ! ++ptr;
- ! }
- ! } else if (*ptr == '<') {
- ! appt->flags |= LOOKAHEAD;
- ! if ((appt->lookahead = do_lookahead(&ptr)) < 0)
- ! return(1);
- ! if (*ptr == '[') {
- ! appt->flags |= REPEAT;
- ! if (appt->flags & EVERY_SOMEDAY) {
- ! if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
- return(1);
- } else {
- if ((appt->repeat = do_repeat(&ptr)) < 0)
-
- --- 518,542 -----
- ++ptr;
- /* lookahead and repeat entries are free format, i.e. they */
- /* can occur in either order */
- ! parse_options = TRUE;
- ! while (parse_options) {
- ! switch (*ptr) {
- ! case '[':
- ! /* repeating appointment */
- ! appt->flags |= REPEAT;
- ! if (appt->flags & EVERY_SOMEDAY) {
- ! if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
- ! return(1);
- ! } else {
- ! if ((appt->repeat = do_repeat(&ptr)) < 0)
- ! return(1);
- ! }
- ! break;
- !
- ! case '<':
- ! /* remind us ahead of time */
- ! appt->flags |= LOOKAHEAD;
- ! if ((appt->lookahead = do_lookahead(&ptr)) < 0)
- return(1);
- break;
-
- ***************
- *** 509,516
- if (appt->flags & EVERY_SOMEDAY) {
- if ((appt->repeat = do_wk_repeat(&ptr)) < 0)
- return(1);
- ! } else {
- ! if ((appt->repeat = do_repeat(&ptr)) < 0)
- return(1);
- }
- }
-
- --- 538,551 -----
- appt->flags |= LOOKAHEAD;
- if ((appt->lookahead = do_lookahead(&ptr)) < 0)
- return(1);
- ! break;
- !
- ! case '+':
- ! /* this appointment lasts for n days */
- ! appt->flags |= RUN;
- ! while (isdigit(*++ptr))
- ! appt->runlength = appt->runlength * 10 + (int)(*ptr - '0');
- ! if (appt->runlength < 0)
- return(1);
- if (!(appt->flags & REPEAT)) {
- /* default to run of days */
- ***************
- *** 512,523
- } else {
- if ((appt->repeat = do_repeat(&ptr)) < 0)
- return(1);
- ! }
- ! }
- ! if (*ptr == '#') {
- ! appt->flags |= DELETED;
- ! ++ptr;
- ! while (isspace(*ptr))
- ++ptr;
- }
- } else if (*ptr == '#') {
-
- --- 547,562 -----
- appt->runlength = appt->runlength * 10 + (int)(*ptr - '0');
- if (appt->runlength < 0)
- return(1);
- ! if (!(appt->flags & REPEAT)) {
- ! /* default to run of days */
- ! appt->flags |= REPEAT;
- ! appt->repeat = 1;
- ! }
- ! break;
- !
- ! case '#':
- ! /* deleted appointment */
- ! appt->flags |= DELETED;
- ++ptr;
- break;
-
- ***************
- *** 519,524
- ++ptr;
- while (isspace(*ptr))
- ++ptr;
- }
- } else if (*ptr == '#') {
- appt->flags |= DELETED;
-
- --- 558,568 -----
- /* deleted appointment */
- appt->flags |= DELETED;
- ++ptr;
- + break;
- +
- + default:
- + parse_options = FALSE;
- + break;
- }
- while (isspace(*ptr))
- ++ptr;
- ***************
- *** 520,528
- while (isspace(*ptr))
- ++ptr;
- }
- - } else if (*ptr == '#') {
- - appt->flags |= DELETED;
- - ++ptr;
- while (isspace(*ptr))
- ++ptr;
- }
-
- --- 564,569 -----
- parse_options = FALSE;
- break;
- }
- while (isspace(*ptr))
- ++ptr;
- }
- ***************
- *** 553,560
- return(-1);
- }
- ++*ptr;
- - while (isspace(**ptr))
- - ++*ptr;
- return(repeat);
- }
-
-
- --- 594,599 -----
- return(-1);
- }
- ++*ptr;
- return(repeat);
- }
-
- ***************
- *** 584,592
- return(-1);
- }
- ++*ptr;
- - while (isspace(**ptr))
- - ++*ptr;
- -
- return(repeat);
- }
-
-
- --- 623,628 -----
- return(-1);
- }
- ++*ptr;
- return(repeat);
- }
-
- ***************
- *** 608,615
- return(-1);
- }
- ++*ptr;
- - while (isspace(**ptr))
- - ++*ptr;
- return(lookahead);
- }
-
-
- --- 644,649 -----
- return(-1);
- }
- ++*ptr;
- return(lookahead);
- }
-
- ***************
- *** 687,692
-
- if (appt->flags & LOOKAHEAD)
- fprintf(apts_file, "<%d> ", appt->lookahead);
- if (appt->flags & DELETED)
- fprintf(apts_file, "# %s\n", appt->str);
- else
-
- --- 721,728 -----
-
- if (appt->flags & LOOKAHEAD)
- fprintf(apts_file, "<%d> ", appt->lookahead);
- + if (appt->flags & RUN)
- + fprintf(apts_file, "+%d ", appt->runlength);
- if (appt->flags & DELETED)
- fprintf(apts_file, "# %s\n", appt->str);
- else
- ***************
- *** 726,731
- return (rptstr);
- }
-
- /*
- * Print today's appointments to stdout or mail (useful if we only have an ASCII
- * terminal connected to our Sun). Invoked by the "-p", "-P" or "-m" options.
-
- --- 762,768 -----
- return (rptstr);
- }
-
- + #ifndef CALENCHECK
- /*
- * Print today's appointments to stdout or mail (useful if we only have an ASCII
- * terminal connected to our Sun). Invoked by the "-p", "-P", "-m" or
- ***************
- *** 728,734
-
- /*
- * Print today's appointments to stdout or mail (useful if we only have an ASCII
- ! * terminal connected to our Sun). Invoked by the "-p", "-P" or "-m" options.
- * Month information is only printed as PostScript output.
- */
- print_apts(which, dest)
-
- --- 765,772 -----
- #ifndef CALENCHECK
- /*
- * Print today's appointments to stdout or mail (useful if we only have an ASCII
- ! * terminal connected to our Sun). Invoked by the "-p", "-P", "-m" or
- ! * "-M" options.
- * Month information is only printed as PostScript output.
- */
- print_apts(which, dest)
- ***************
- *** 734,740
- print_apts(which, dest)
- int which, dest;
- {
- ! int i;
- FILE *output, *pfp, *popen();
- char cmd[80], *name, *cuserid();
-
-
- --- 772,778 -----
- print_apts(which, dest)
- int which, dest;
- {
- ! int i, gd_rtn;
- FILE *output, *pfp, *popen();
- char cmd[80], *name, *cuserid();
-
- ***************
- *** 738,746
- FILE *output, *pfp, *popen();
- char cmd[80], *name, *cuserid();
-
- - if (dest == DST_MAIL)
- - /* only mail one day's appts */
- - which = PRI_DAY;
- fix_current_day();
- if ((which == PRI_DAY) && !get_day_appts())
- return; /* nothing to show */
-
- --- 776,781 -----
- FILE *output, *pfp, *popen();
- char cmd[80], *name, *cuserid();
-
- fix_current_day();
- gd_rtn = get_day_appts();
- if (which == PRI_DAY && !gd_rtn)
- ***************
- *** 742,748
- /* only mail one day's appts */
- which = PRI_DAY;
- fix_current_day();
- ! if ((which == PRI_DAY) && !get_day_appts())
- return; /* nothing to show */
- if (dest == DST_MAIL) {
- if (mailto != NULL) {
-
- --- 777,784 -----
- char cmd[80], *name, *cuserid();
-
- fix_current_day();
- ! gd_rtn = get_day_appts();
- ! if (which == PRI_DAY && !gd_rtn)
- return; /* nothing to show */
- if (which == PRI_DAY_XNOTES && gd_rtn == SOME_MKNOTES)
- /* all we have is marked notes */
- ***************
- *** 744,749
- fix_current_day();
- if ((which == PRI_DAY) && !get_day_appts())
- return; /* nothing to show */
- if (dest == DST_MAIL) {
- if (mailto != NULL) {
- name = mailto;
-
- --- 780,788 -----
- gd_rtn = get_day_appts();
- if (which == PRI_DAY && !gd_rtn)
- return; /* nothing to show */
- + if (which == PRI_DAY_XNOTES && gd_rtn == SOME_MKNOTES)
- + /* all we have is marked notes */
- + return; /* nothing to show */
- if (dest == DST_MAIL) {
- if (mailto != NULL) {
- name = mailto;
- ***************
- *** 750,756
- } else if ((name = cuserid(NULL)) == NULL) {
- err_rpt("nobody to mail to", FATAL);
- }
- ! sprintf(cmd, "mail -s \"Appointments for today\" %s", name);
- if ((output = popen(cmd, "w")) == NULL)
- err_rpt("Couldn't pipe to 'mail'", FATAL);
- } else {
-
- --- 789,795 -----
- } else if ((name = cuserid(NULL)) == NULL) {
- err_rpt("nobody to mail to", FATAL);
- }
- ! sprintf(cmd, "%s -s \"Appointments for today\" %s", MAILPROG, name);
- if ((output = popen(cmd, "w")) == NULL)
- err_rpt("Couldn't pipe to 'mail'", FATAL);
- } else {
- ***************
- *** 758,764
- }
-
- if (which == PRI_DAY || which == PRI_DAY_XNOTES) {
- ! print_one_day(which, output);
- } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
- current.tm_mday -= current.tm_wday; /* Sunday of this week */
- fix_current_day();
-
- --- 797,803 -----
- }
-
- if (which == PRI_DAY || which == PRI_DAY_XNOTES) {
- ! print_one_day(which, output, gd_rtn);
- } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
- current.tm_mday -= current.tm_wday; /* Sunday of this week */
- fix_current_day();
- ***************
- *** 762,768
- } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
- current.tm_mday -= current.tm_wday; /* Sunday of this week */
- fix_current_day();
- ! if (nr_weekdays < 7) {
- current.tm_mday++;
- fix_current_day();
- }
-
- --- 801,807 -----
- } else if (which == PRI_WEEK || which == PRI_WEEK_XNOTES) {
- current.tm_mday -= current.tm_wday; /* Sunday of this week */
- fix_current_day();
- ! if (nr_weekdays < 7 || monday_first) {
- current.tm_mday++;
- fix_current_day();
- }
- ***************
- *** 767,774
- fix_current_day();
- }
- for (i=0;i<nr_weekdays;i++) {
- ! if (get_day_appts())
- ! print_one_day(which, output);
- current.tm_mday++;
- fix_current_day();
- }
-
- --- 806,814 -----
- fix_current_day();
- }
- for (i=0;i<nr_weekdays;i++) {
- ! gd_rtn = get_day_appts();
- ! if ((gd_rtn && which == PRI_WEEK) || (gd_rtn & ~SOME_MKNOTES && which == PRI_WEEK_XNOTES))
- ! print_one_day(which, output, gd_rtn);
- current.tm_mday++;
- fix_current_day();
- }
- ***************
- *** 780,786
- pclose(output);
- }
-
- ! print_one_day(which, output)
- int which;
- FILE *output;
- {
-
- --- 820,826 -----
- pclose(output);
- }
-
- ! print_one_day(which, output, gdrtn)
- int which;
- FILE *output;
- int gdrtn;
- ***************
- *** 783,788
- print_one_day(which, output)
- int which;
- FILE *output;
- {
- int i;
- struct appt_entry tmp_apt;
-
- --- 823,829 -----
- print_one_day(which, output, gdrtn)
- int which;
- FILE *output;
- + int gdrtn;
- {
- int i;
- struct appt_entry tmp_apt;
- ***************
- *** 788,796
- struct appt_entry tmp_apt;
- char *format_appt();
-
- ! fprintf(output,"\n\t*** Appointments for %s %s %d, %d ***\n\n",
- ! daynames[current.tm_wday], monthnames[current.tm_mon],
- ! current.tm_mday, current.tm_year+1900);
-
- for (i=0; i<N_SLOTS; i++) {
- if (i == n_tslots)
-
- --- 829,842 -----
- struct appt_entry tmp_apt;
- char *format_appt();
-
- ! if (day_first)
- ! fprintf(output,"\n\t*** Appointments for %s %d %s %d ***\n\n",
- ! daynames[current.tm_wday], current.tm_mday,
- ! monthnames[current.tm_mon], current.tm_year+1900);
- ! else
- ! fprintf(output,"\n\t*** Appointments for %s %s %d, %d ***\n\n",
- ! daynames[current.tm_wday], monthnames[current.tm_mon],
- ! current.tm_mday, current.tm_year+1900);
-
- for (i=0; i<N_SLOTS; i++) {
- if (i == n_tslots)
- ***************
- *** 795,801
- for (i=0; i<N_SLOTS; i++) {
- if (i == n_tslots)
- /* start of notes section */
- ! fprintf(output,"\n\t\t ===== Notes =====\n");
- if (slots[i].first != NULL && slots[i].count > 0) {
- /* at least one appt here */
- slots[i].cur_appt = slots[i].first;
-
- --- 841,849 -----
- for (i=0; i<N_SLOTS; i++) {
- if (i == n_tslots)
- /* start of notes section */
- ! if ((gdrtn & SOME_NOTES) ||
- ! (!(which & PRI_XNOTES) && (gdrtn & SOME_MKNOTES)))
- ! fprintf(output,"\n\t\t ===== Notes =====\n");
- if (slots[i].first != NULL && slots[i].count > 0) {
- /* at least one appt here */
- slots[i].cur_appt = slots[i].first;
- ***************
- *** 841,847
- * also support a "lookahead" reminder service to remind one
- * in advance of a future appointment.
- * If "save_old" is set, then any appointments for years prior
- ! * to this one are save in a special file of the form
- * ".appointments.YY", where YY is the year.
- */
-
-
- --- 889,895 -----
- * also support a "lookahead" reminder service to remind one
- * in advance of a future appointment.
- * If "save_old" is set, then any appointments for years prior
- ! * to this one are saved in a special file of the form
- * ".appointments.YY", where YY is the year.
- */
-
- ***************
- *** 864,870
-
- /* copy existing entries to the new file */
- save_base = one_based;
- ! while ((err_flag = get_aentry(oappts, &appt)) != EOF) {
- if (err_flag)
- continue; /* ignore badly formatted input */
- if (appt.hour == 0)
-
- --- 912,918 -----
-
- /* copy existing entries to the new file */
- save_base = one_based;
- ! while ((err_flag = get_aentry(oappts, &appt, TRUE)) != EOF) {
- if (err_flag)
- continue; /* ignore badly formatted input */
- if (appt.hour == 0)
- ***************
- *** 891,898
- fclose(fp);
- }
- } else {
- ! if (put_aentry(nappts, &appt))
- ! err_rpt("write to new appt file failed, bailing out", FATAL);
- }
- one_based = save_base; /* (maybe) force old format input */
- }
-
- --- 939,949 -----
- fclose(fp);
- }
- } else {
- ! if (appt.flags & A_COMMENT)
- ! fputs(inbuf, nappts);
- ! else
- ! if (put_aentry(nappts, &appt))
- ! err_rpt("write to new appt file failed, bailing out", FATAL);
- }
- one_based = save_base; /* (maybe) force old format input */
- }
- ***************
- *** 904,971
- }
-
- /*
- - * Scan appointments file for outdated appointments and save them to a
- - * special file of the form ".appointments.YY", where YY is the year
- - * of that appointment.
- - */
- - create_old_files()
- - {
- - FILE *oappts, *nappts, *fp;
- - struct appt_entry appt;
- - int err_flag;
- - char save_file[128];
- - struct stat stbuf;
- -
- - if (read_only != 0) {
- - err_rpt("appts file is read-only, no conversion done", NON_FATAL);
- - return;
- - }
- -
- - /* open files, etc */
- - if ((oappts = fopen(apts_pathname, "r")) == NULL) {
- - err_rpt("can't open appts file for reading", FATAL);
- - /* NOT REACHED */
- - }
- - if ((nappts = fopen(tmpapts_pathname, "w")) == NULL) {
- - err_rpt("can't open temp file for writing", NON_FATAL);
- - return;
- - }
- -
- - /* copy existing entries to the tmp file, checking dates */
- - while ((err_flag = get_aentry(oappts, &appt)) != EOF) {
- - if (err_flag)
- - continue; /* ignore badly formatted input */
- - if (!(appt.flags & A_COMMENT)
- - && !(appt.flags & ALL_YEARS) && (appt.year < today.tm_year)
- - && !((appt.flags & REPEAT) && !(appt.flags & EVERY_SOMEDAY))) {
- - /* prepend directory info */
- - sprintf(save_file, "%s/.appointments.%02d",
- - apts_dir, appt.year);
- - if (stat(save_file, &stbuf) && errno == ENOENT) {
- - /* new file*/
- - if ((fp = fopen(save_file, "w")) == NULL)
- - err_rpt("can't open save file, bailing out", FATAL);
- - fputs(HEADER, fp);
- - fclose(fp);
- - }
- - if ((fp = fopen(save_file, "a+")) == NULL)
- - err_rpt("can't open save file, bailing out", FATAL);
- - else {
- - if (put_aentry(fp, &appt))
- - err_rpt("write to save appt file failed, bailing out", FATAL);
- - fclose(fp);
- - }
- - } else {
- - if (put_aentry(nappts, &appt))
- - err_rpt("write to new appt file failed, bailing out", FATAL);
- - }
- - }
- - fclose(oappts);
- - fclose(nappts);
- - xrename(tmpapts_pathname, apts_pathname);
- - }
- -
- - /*
- * convert appt entry to ASCII string for display with date, time and msg
- */
- char *
-
- --- 955,960 -----
- }
-
- /*
- * convert appt entry to ASCII string for display with date, time and msg
- */
- char *
- ***************
- *** 997,1005
- if (appt->flags & A_NOTE) {
- /* note */
- if (appt->flags & ALL_YEARS)
- ! sprintf(strbuf,"%3.3s %2d/%02d -- %s",
- ! daynames[current.tm_wday], appt->month+1,
- ! appt->day, appt->str);
- else if (appt->year > 99)
- sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- daynames[current.tm_wday], appt->month+1,
-
- --- 986,999 -----
- if (appt->flags & A_NOTE) {
- /* note */
- if (appt->flags & ALL_YEARS)
- ! if (day_first)
- ! sprintf(strbuf,"%3.3s %2d/%02d -- %s",
- ! daynames[current.tm_wday], appt->day,
- ! appt->month+1, appt->str);
- ! else
- ! sprintf(strbuf,"%3.3s %2d/%02d -- %s",
- ! daynames[current.tm_wday], appt->month+1,
- ! appt->day, appt->str);
- else if (appt->year > 99)
- if (day_first)
- sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- ***************
- *** 1001,1009
- daynames[current.tm_wday], appt->month+1,
- appt->day, appt->str);
- else if (appt->year > 99)
- ! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- ! daynames[current.tm_wday], appt->month+1,
- ! appt->day, appt->year-100, appt->str);
- else
- sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- daynames[current.tm_wday], appt->month+1,
-
- --- 995,1008 -----
- daynames[current.tm_wday], appt->month+1,
- appt->day, appt->str);
- else if (appt->year > 99)
- ! if (day_first)
- ! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- ! daynames[current.tm_wday], appt->day,
- ! appt->month+1, appt->year-100, appt->str);
- ! else
- ! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- ! daynames[current.tm_wday], appt->month+1,
- ! appt->day, appt->year-100, appt->str);
- else
- if (day_first)
- sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- ***************
- *** 1005,1014
- daynames[current.tm_wday], appt->month+1,
- appt->day, appt->year-100, appt->str);
- else
- ! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- ! daynames[current.tm_wday], appt->month+1,
- ! appt->day, appt->year, appt->str);
- ! } else
- /* standard appointment */
- sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d %s",
- daynames[current.tm_wday], appt->month+1,
-
- --- 1004,1018 -----
- daynames[current.tm_wday], appt->month+1,
- appt->day, appt->year-100, appt->str);
- else
- ! if (day_first)
- ! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- ! daynames[current.tm_wday], appt->day,
- ! appt->month+1, appt->year, appt->str);
- ! else
- ! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %s",
- ! daynames[current.tm_wday], appt->month+1,
- ! appt->day, appt->year, appt->str);
- ! } else {
- /* standard appointment */
- if (hour24)
- if (day_first)
- ***************
- *** 1010,1020
- appt->day, appt->year, appt->str);
- } else
- /* standard appointment */
- ! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d %s",
- ! daynames[current.tm_wday], appt->month+1,
- ! appt->day, appt->year, appt->hour, appt->minute,
- ! e_hour, e_minutes, appt->str);
- !
- current = Save;
- return(strbuf);
- }
-
- --- 1014,1048 -----
- appt->day, appt->year, appt->str);
- } else {
- /* standard appointment */
- ! if (hour24)
- ! if (day_first)
- ! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d %s",
- ! daynames[current.tm_wday], appt->day,
- ! appt->month+1, appt->year, appt->hour, appt->minute,
- ! e_hour, e_minutes, appt->str);
- ! else
- ! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d to %2d:%02d %s",
- ! daynames[current.tm_wday], appt->month+1,
- ! appt->day, appt->year, appt->hour, appt->minute,
- ! e_hour, e_minutes, appt->str);
- ! else
- ! if (day_first)
- ! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d%s to %2d:%02d%s %s",
- ! daynames[current.tm_wday], appt->day,
- ! appt->month+1, appt->year, (appt->hour < 13 ? appt->hour : appt->hour-12), appt->minute,
- ! (appt->hour < 12 ? "am" : "pm"),
- ! (e_hour < 13 ? e_hour : e_hour-12), e_minutes,
- ! (e_hour < 12 ? "am" : "pm"),
- ! appt->str);
- ! else
- ! sprintf(strbuf,"%3.3s %2d/%02d/%02d -- %2d:%02d%s to %2d:%02d%s %s",
- ! daynames[current.tm_wday], appt->month+1,
- ! appt->day, appt->year, (appt->hour < 13 ? appt->hour : appt->hour-12), appt->minute,
- ! (appt->hour < 12 ? "am" : "pm"),
- ! (e_hour < 13 ? e_hour : e_hour-12), e_minutes,
- ! (e_hour < 12 ? "am" : "pm"),
- ! appt->str);
- ! }
- current = Save;
- return(strbuf);
- }
- ***************
- *** 1046,1052
- }
-
- strbuf[0] = '\0';
- ! if (!(appt->flags & A_NOTE))
- /* standard appointment */
- sprintf(strbuf,"%2d:%02d to %2d:%02d ",
- appt->hour, appt->minute, e_hour, e_minutes);
-
- --- 1074,1080 -----
- }
-
- strbuf[0] = '\0';
- ! if (!(appt->flags & A_NOTE)) {
- /* standard appointment */
- if (hour24)
- sprintf(strbuf,"%2d:%02d to %2d:%02d ",
- ***************
- *** 1048,1055
- strbuf[0] = '\0';
- if (!(appt->flags & A_NOTE))
- /* standard appointment */
- ! sprintf(strbuf,"%2d:%02d to %2d:%02d ",
- ! appt->hour, appt->minute, e_hour, e_minutes);
- p = appt->str;
- q = strbuf + strlen(strbuf);
- while (*p) {
-
- --- 1076,1091 -----
- strbuf[0] = '\0';
- if (!(appt->flags & A_NOTE)) {
- /* standard appointment */
- ! if (hour24)
- ! sprintf(strbuf,"%2d:%02d to %2d:%02d ",
- ! appt->hour, appt->minute, e_hour, e_minutes);
- ! else
- ! sprintf(strbuf,"%2d:%02d%s to %2d:%02d%s ",
- ! (appt->hour < 13 ? appt->hour : appt->hour-12), appt->minute,
- ! (appt->hour < 12 ? "am" : "pm"),
- ! (e_hour < 13 ? e_hour : e_hour-12), e_minutes,
- ! (e_hour < 12 ? "am" : "pm"));
- ! }
- p = appt->str;
- q = strbuf + strlen(strbuf);
- while (*p) {
- ***************
- *** 1077,1083
- }
-
- /*
- ! * parse the date on the given tring and reset the "current"
- * date to reflect that date. The date may take the form of a
- * day name (e.g. Tu, Tue, Tuesday) or a date in m/d/y format
- * where the month and/or year may be missing (e.g. 27 = 27th
-
- --- 1113,1119 -----
- }
-
- /*
- ! * parse the date on the given string and reset the "current"
- * date to reflect that date. The date may take the form of a
- * day name (e.g. Tu, Tue, Tuesday) or a date in m/d/y format
- * where the month and/or year may be missing (e.g. 27 = 27th
- ***************
- *** 1084,1089
- * of this month, 8/27 = August 27 of this year, 8/27/89 =
- * August 27 of 1989. If 'cmdline' is true, then the string
- * came from the command line '-d' option.
- */
- int
- parse_date(str, cmdline)
-
- --- 1120,1128 -----
- * of this month, 8/27 = August 27 of this year, 8/27/89 =
- * August 27 of 1989. If 'cmdline' is true, then the string
- * came from the command line '-d' option.
- + * If the first character of the date is + or - scan the number and
- + * use it as an offset in days from the current date. Thus -1 becomes
- + * yesterday and +1 becomes tomorrow. pbm.
- */
- int
- parse_date(str, cmdline)
- ***************
- *** 1125,1134
- }
- if (y > 0)
- current.tm_year = y;
- ! if (m > 0)
- ! current.tm_mon = m - 1;
- ! if (d > 0)
- ! current.tm_mday = d;
- fix_current_day();
- } else {
- /* day of week */
-
- --- 1164,1182 -----
- }
- if (y > 0)
- current.tm_year = y;
- ! if (day_first) {
- ! if (m > 0) {
- ! current.tm_mon = d - 1;
- ! current.tm_mday = m;
- ! } else if (d > 0)
- ! current.tm_mday = d;
- ! } else {
- ! if (m > 0) {
- ! current.tm_mon = m - 1;
- ! current.tm_mday = d;
- ! } else if (d > 0)
- ! current.tm_mday = d;
- ! }
- fix_current_day();
- } else if (*str == '-' || *str == '+') {
- /*
- ***************
- *** 1130,1135
- if (d > 0)
- current.tm_mday = d;
- fix_current_day();
- } else {
- /* day of week */
- /* check for day names */
-
- --- 1178,1193 -----
- current.tm_mday = d;
- }
- fix_current_day();
- + } else if (*str == '-' || *str == '+') {
- + /*
- + * If the argument begins with a + or - assume that it is an
- + * offset in days from the current date. Use current date if the
- + * number doesn't scan after the - or +. pbm
- + */
- + if (sscanf(str, "%d", &i) == 1) {
- + current.tm_mday += i;
- + fix_current_day();
- + }
- } else {
- /* day of week */
- /* check for day names */
- ***************
- *** 1180,1186
-
- lock_cursors();
- working(TRUE);
- ! sprintf(buf, "Appointments file \"%s\" printed for %s on %s", apts_pathname, cuserid(NULL), todays_date);
- if (mainsw_state != DISPLAYING_MONTH) {
- if ((fp = fopen(rasfile, "w")) != NULL) {
- rect = (Rect *) window_get(canvas, WIN_RECT);
-
- --- 1238,1244 -----
-
- lock_cursors();
- working(TRUE);
- ! sprintf(buf, "Appointments file \"%s\" printed for %s on %s", apts_pathname, cuserid(NULL), clockstr);
- if (mainsw_state != DISPLAYING_MONTH) {
- if ((fp = fopen(rasfile, "w")) != NULL) {
- rect = (Rect *) window_get(canvas, WIN_RECT);
- ***************
- *** 1217,1223
- err_rpt("only PostScript output available for month printout", NON_FATAL);
- } else {
- if ((pfp = fopen(psfile, "w")) != NULL) {
- ! print_month(pfp, FALSE);
- fclose(pfp);
- sprintf(prntcmd, "%s %s", printer, psfile);
- system(prntcmd);
-
- --- 1275,1281 -----
- err_rpt("only PostScript output available for month printout", NON_FATAL);
- } else {
- if ((pfp = fopen(psfile, "w")) != NULL) {
- ! print_month(pfp, TRUE);
- fclose(pfp);
- sprintf(prntcmd, "%s %s", printer, psfile);
- system(prntcmd);
- ***************
- *** 1230,1235
- unlock_cursors();
- }
- #endif /* NO_PRINTER */
-
- /* set error logging flag */
- err2console(state)
-
- --- 1288,1294 -----
- unlock_cursors();
- }
- #endif /* NO_PRINTER */
- + #endif /* CALENCHECK */
-
- /* set error logging flag */
- err2console(state)
- ***************
- *** 1252,1257
- {
- FILE *f;
- int closed;
-
- closed = (int) window_get(frame, FRAME_CLOSED);
- if (frame && !log_to_console && !closed) {
-
- --- 1311,1317 -----
- {
- FILE *f;
- int closed;
- + char *getenv();
-
- #ifndef NOTOOL
- closed = (int) window_get(frame, FRAME_CLOSED);
- ***************
- *** 1253,1258
- FILE *f;
- int closed;
-
- closed = (int) window_get(frame, FRAME_CLOSED);
- if (frame && !log_to_console && !closed) {
- /* base frame exists */
-
- --- 1313,1319 -----
- int closed;
- char *getenv();
-
- + #ifndef NOTOOL
- closed = (int) window_get(frame, FRAME_CLOSED);
- if (frame && !log_to_console && !closed) {
- /* base frame exists */
- ***************
- *** 1260,1265
- (void) window_loop(prompt_frame);
- window_set(prompt_frame, WIN_SHOW, FALSE, 0);
- } else if ((f=fopen("/dev/console", "w")) != NULL) {
- fprintf(f, "%s: %s\n", progname, errstr);
- fclose(f);
- } else
-
- --- 1321,1329 -----
- (void) window_loop(prompt_frame);
- window_set(prompt_frame, WIN_SHOW, FALSE, 0);
- } else if ((f=fopen("/dev/console", "w")) != NULL) {
- + #else
- + if (getenv("WINDOW_PARENT") != NULL && (f=fopen("/dev/console", "w")) != NULL) {
- + #endif
- fprintf(f, "%s: %s\n", progname, errstr);
- fclose(f);
- } else
- ***************
- *** 1268,1273
- exit(1);
- }
-
- /* Clean-up */
- cleanup()
- {
-
- --- 1332,1338 -----
- exit(1);
- }
-
- + #ifndef CALENCHECK
- /* Clean-up */
- cleanup()
- {
- ***************
- *** 1275,1282
- close_day();
-
- /* create outdated include files (if necessary) */
- ! if (save_old)
- ! create_old_files();
-
- /* delete tmp file */
- if (access(tmpapts_pathname, R_OK) == 0 && unlink(tmpapts_pathname) < 0)
-
- --- 1340,1347 -----
- close_day();
-
- /* create outdated include files (if necessary) */
- ! if (save_old || expire_days)
- ! expire(expire_days);
-
- /* delete tmp file */
- if (access(tmpapts_pathname, R_OK) == 0 && unlink(tmpapts_pathname) < 0)
- ***************
- *** 1296,1298
- err_rpt("couldn't rename/copy tmp file", NON_FATAL);
- }
- }
-
- --- 1361,1364 -----
- err_rpt("couldn't rename/copy tmp file", NON_FATAL);
- }
- }
- + #endif /* CALENCHECK */
- *** /tmp/,RCSt1a16998 Fri Dec 15 17:24:01 1989
- --- version.c Fri Dec 15 17:18:34 1989
- ***************
- *** 1,5
- /*
- ! * $Header: version.c,v 2.5 89/09/19 06:09:07 billr Exp $
- */
- /*
- * version.c - current version of calentool program
-
- --- 1,5 -----
- /*
- ! * $Header: version.c,v 2.6 89/12/15 17:18:32 billr Exp $
- */
- /*
- * version.c - current version of calentool program
- ***************
- *** 24,27
- * notice remains intact.
- */
-
- ! char version[] = "Calendar Tool V2.1p4";
-
- --- 24,27 -----
- * notice remains intact.
- */
-
- ! char version[] = "Calendar Tool V2.1p5";
- *** /tmp/,RCSt1a17003 Fri Dec 15 17:24:04 1989
- --- wevent.c Fri Dec 15 17:18:37 1989
- ***************
- *** 1,5
- /*
- ! * $Header: wevent.c,v 2.1 89/05/09 14:19:57 billr Exp $
- */
- /*
- * wevent.c
-
- --- 1,5 -----
- /*
- ! * $Header: wevent.c,v 2.2 89/12/15 17:18:35 billr Exp $
- */
- /*
- * wevent.c
- ***************
- *** 36,41
- #include "event.h"
-
- extern Frame prompt_frame;
-
- week_inputevent(canvas, event)
- Canvas canvas;
-
- --- 36,42 -----
- #include "event.h"
-
- extern Frame prompt_frame;
- + extern int monday_first;
-
- week_inputevent(canvas, event)
- Canvas canvas;
- ***************
- *** 84,89
- return;
- }
- current.tm_mday -= current.tm_wday;
- current.tm_mday += day_chosen_from_week;
- fix_current_day();
- if (nr_weekdays == 5) {
-
- --- 85,96 -----
- return;
- }
- current.tm_mday -= current.tm_wday;
- + if (monday_first) {
- + if (current.tm_wday == SUN)
- + current.tm_mday -= 7;
- + if (nr_weekdays == 7)
- + current.tm_mday++;
- + }
- current.tm_mday += day_chosen_from_week;
- fix_current_day();
- if (nr_weekdays < 7) {
- ***************
- *** 86,92
- current.tm_mday -= current.tm_wday;
- current.tm_mday += day_chosen_from_week;
- fix_current_day();
- ! if (nr_weekdays == 5) {
- current.tm_mday++;
- fix_current_day();
- }
-
- --- 93,99 -----
- }
- current.tm_mday += day_chosen_from_week;
- fix_current_day();
- ! if (nr_weekdays < 7) {
- current.tm_mday++;
- fix_current_day();
- }
-