Vcalendar (part 1 of 3) is available upon request.
James Pierre Lewis
james at yunexus.UUCP
Wed Feb 1 12:56:13 AEST 1989
Vcalendar is a calendar/schedule keeping program that allows one to
keep track of appointments, classes, meetings, and dates, etc. It is
posted upon request from panetta at duphy4.drexel.edu. Vcalendar is
written in C running on VAX/VMS 4.xx or higher. It is free.
If you are interested, please cut the three parts - VCAL1.SHAR,
VCAL2.SHAR and VCAL3.SHAR; follow the instructions in 0REAME.1ST and
have fun.
-----CUT-----CUT-----CUT-----CUT-----CUT-----CUT-----CUT-----CUT-----CUT-----
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
# 0readme.1st
# build.com
# bulletin.mem
# bulletin.rno
# decode.c
# do-appts.c
# do-calls.c
# This archive created: Tue Jan 31 21:48:00 1989
export PATH; PATH=/bin:$PATH
echo shar: extracting "'0readme.1st'" '(427 characters)'
if test -f '0readme.1st'
then
echo shar: will not over-write existing file "'0readme.1st'"
else
sed 's/^ X//' << \SHAR_EOF > '0readme.1st'
XATTENTION:
X
XPlease do the following steps to build VCAL:
X
X1) @BUILD.COM
X
X2) Replace the default directory (CS) in the following line in VCAL.H:
X
X #define REMIND_IMAGE "RUN CS:DO_CALLS.EXE"
X --
X
X with your system's default directory where VCAL resides.
X
X3) Replace the default directory (CS:) in VCALENDAR.CLD.
X
X...Have fun...Please send suggestions, complaints to ...yunexus!james.
X
X
SHAR_EOF
if test 427 -ne "`wc -c < '0readme.1st'`"
then
echo shar: error transmitting "'0readme.1st'" '(should have been 427 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'build.com'" '(574 characters)'
if test -f 'build.com'
then
echo shar: will not over-write existing file "'build.com'"
else
sed 's/^ X//' << \SHAR_EOF > 'build.com'
X$!
X$! Building VCAL Software Package - March 7, 1987
X$!
X$ Variable:
X$!
X$ link_it = "link/notra/nodeb"
X$!
X$ Compile:
X$!
X$ cc vcal, vcal-util, do-appts, do-calls, vcal-sum, -
X vcal-remind, vcal-purge
X$ message vcal-msg.msg
X$!
X$ Link:
X$!
X$ define lnk$library sys$library:vaxcrtl
X$ 'link_it' vcal, do-appts, vcal-util, vcal-msg
X$ 'link_it' vcal-remind, vcal-util, vcal-msg
X$ 'link_it' vcal-purge, vcal-util, vcal-msg
X$ 'link_it' vcal-sum, vcal-util, vcal-msg
X$ 'link_it' do-calls, vcal-util, vcal-msg
X$!
X$ Command:
X$!
X$ set command vcalendar.cld
X$!
X$ Finish:
X$!
X$ exit
SHAR_EOF
if test 574 -ne "`wc -c < 'build.com'`"
then
echo shar: error transmitting "'build.com'" '(should have been 574 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bulletin.mem'" '(5784 characters)'
if test -f 'bulletin.mem'
then
echo shar: will not over-write existing file "'bulletin.mem'"
else
sed 's/^ X//' << \SHAR_EOF > 'bulletin.mem'
X
X
X
X Abstract
X
X If you forget your dates or are late on your appointments most of the
X times, VCAL may be the right tool for you.
X
X History
X
X There have been many versions of VCAL. One of those written by Mike
X Essex at Berkeley. His version, which has been reported to work on
X UNIX Version 7, BSD 4.3, and ULTRIX, was written in C using C curses
X and Termcap. It could, perhaps, be ported to VAX/VMS without making
X changes. However, excellent VAX/VMS screen management features are
X not fully utilized; therefore, VCAL was then C-modified using SMG.
X There are differences and similarities between UNIX C and VAX C; and C
X curses and SMG. However, they are not discussed here.
X
X VAX/VMS VCAL Features
X
X VCAL provides you a calendar of each month. From this calendar, you
X can pick any day to record appointments (Day Picking Phase). When a
X day is picked, you enter the second phase (Appointments Making Phase).
X You can switch back and forth between these two phases. You can
X record 17 appointments for a day. The length of each appointments is
X 60 characters. Just think that you are using a calendar pad. The
X design was based on this philosophy. It sounds complicated, but don't
X worry! The software is a menu-driven one, so it will help you when
X you go along. You just have to pay attention to the small help window
X in the lower left-hand corner.
X
X That's not all. VCAL does also provides you the reminding service for
X today if you want. Before the appointment time approximately 5
X minutes, it will beep at your terminal, displaying the scheduled
X activity you had recorded before.
X
X That's still not all. VCAL, furthermore, provides you the
X appointments summary for any month between the year 1900 and 9999 if
X you want.
X
X Finally, when your appointments file grows bigger until it reaches the
X threshold size, you will be notified to purge all old appointments
X leaving only appointments for the current month and the future ones.
X
X What does it cost you? Nothing! If you are interested, then continue
X reading.
X
X VAX/VMS VCAL Commands
X
X 1) To record appointments, please type:
X
X $ VCAL
X
X Then follow the instructions provided in the small lower left-hand
X window. When you complete and exit, the file APPOINTMENTS.DAT is
X created in your main directory. DONOT delete this file. It is where
X all appointments are kept. If you frequently purge all old
X appointments, the size of this file will be at maximum 1 block.
X
X 2) To ask for reminding service for today:
X
X $ VCAL/REMIND/MIN=[min] /* 5 <= min <= 20 */
X
X A sub-process is created. It hibernates until approximately 5 minutes
X before each appointment for that day, wakes up reminding you the
X scheduled event, then goes back into hibernation until no more
X appointments. The sub-process then terminates. In terms of system
X resources, it doesn't bog down any thing because when the process
X hibernates, it is swapped out of memory. When you log out, the
X sub-process is automatically terminated also. If you want to
X terminate this sub-process instead, just type:
X
X $ STOP REM_username /* For example, $ STOP REM_CS100002 */
X
X 3) To ask for an appointments summary for a month, please type:
X
X $ VCAL/SUMMARY
X
X The summary for this month's appointments will be displayed on screen.
X You can re-direct the output to a file by typing:
X
X $ VCAL/SUMMARY/OUT=[file]
X
X You can also add the qualifiers /MON=[month], and /YEAR=[year] to the
X command. Month is any month. i.e., JANUARY, FEBRUARY, etc. Year is
X any year from 1900 to 9999.
X
X 4) To purge all old appointments leaving only current month's
X appointments and future ones, please type:
X
X $ VCAL/PURGE
X
X 5) To get help such as this one, just type:
X
X $ HELP VCAL
X
X Limitation
X
X VCAL expects you to enter the hour in the format "hhhh". If the hour
X is not understood, say 2500, then it is set to 0000.
X
X If you have several appointments scheduled for the same hour, you will
X be reminded for the first one only.
X
X User's Comments
X
X To help us doing a good job at releasing future softwares, please
X spend a few minutes of your times answering the following
X questionaires and mail them to JAMES before March 30, 1987.
X
X 1) Do you gain any benefit from using this software? Please clarify.
X
X 2) Do you find that the software is easy to use? Please clarify.
X
X 3) In the next release of this software, what features do you want
X this software to have?
X
X 4) What area of Computer Science are you interested in the most?
X
X Acknowledgements
X
X I would like to thank Mike Essex and those who did wrote VCAL. Only
X they can tell the differences and enhancements. Special thanks are
X pre-said to those who will response to the above questionaires.
X
X ----------
X
X UNIX is a trademark of Bell Laboratories.
X VAX/VMS is a trademark of Digital Equipment Corporation.
SHAR_EOF
if test 5784 -ne "`wc -c < 'bulletin.mem'`"
then
echo shar: error transmitting "'bulletin.mem'" '(should have been 5784 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'bulletin.rno'" '(5025 characters)'
if test -f 'bulletin.rno'
then
echo shar: will not over-write existing file "'bulletin.rno'"
else
sed 's/^ X//' << \SHAR_EOF > 'bulletin.rno'
X.page size 1000, 80
X.left margin 5
X.right margin 75
X.autoparagraph
X.c;Abstract
X.skip
XIf you forget your dates or are late on your appointments most of the
Xtimes, VCAL may be the right tool for you.
X.skip
X.c;History
X.skip
XThere have been many versions of VCAL. One of those written by Mike
XEssex at Berkeley. His version, which has been reported to work on UNIX
XVersion 7, BSD 4.3, and ULTRIX, was written in C using C curses and Termcap. It
Xcould, perhaps, be ported to VAX/VMS without making changes. However, excellent
XVAX/VMS screen management features are not fully utilized; therefore, VCAL was
Xthen C-modified using SMG. There are differences and similarities between UNIX
XC and VAX C; and C curses and SMG. However, they are not discussed here.
X.skip
X.c;VAX/VMS VCAL Features
X.skip
XVCAL provides you a calendar of each month. From this
Xcalendar, you can pick any day to record appointments (Day Picking Phase). When
Xa day is picked, you enter the second phase (Appointments Making Phase). You
Xcan switch back and forth between these two phases. You can record 17
Xappointments for a day. The length of each appointments is 60 characters. Just
Xthink that you are using a calendar pad. The design was based on this
Xphilosophy. It sounds complicated, but don't worry! The software is a
Xmenu-driven one, so it will help you when you go along. You just have to pay
Xattention to the small help window in the lower left-hand corner.
X.skip
XThat's not all. VCAL does also provides you the reminding service for today if
Xyou want. Before the appointment time approximately 5 minutes, it will beep at
Xyour terminal, displaying the scheduled activity you had recorded before.
X.skip
XThat's still not all. VCAL, furthermore, provides you the appointments summary
Xfor any month between the year 1900 and 9999 if you want.
X.skip
XFinally, when your appointments file grows bigger until it reaches the threshold
Xsize, you will be notified to purge all old appointments leaving only
Xappointments for the current month and the future ones.
X.skip
XWhat does it cost you? Nothing! If you are interested, then continue reading.
X.skip
X.c;VAX/VMS VCAL Commands
X.skip
X1) To record appointments, please type:
X.skip
X$ VCAL
X.skip
XThen follow the instructions provided in the small lower left-hand window. When
Xyou complete and exit, the file APPOINTMENTS.DAT is created in your main
Xdirectory. DONOT delete this file. It is where all appointments are kept. If
Xyou frequently purge all old appointments, the size of this file will be at
Xmaximum 1 block.
X.skip
X2) To ask for reminding service for today:
X.skip
X$ VCAL/REMIND/MIN=[min]#####/* 5 <= min <= 20 */
X.SKIP
XA sub-process is created. It hibernates until approximately 5 minutes before
Xeach appointment for that day, wakes up reminding you the scheduled event, then
Xgoes back into hibernation until no more appointments. The sub-process then
Xterminates. In terms of system resources, it doesn't bog down any thing because
Xwhen the process hibernates, it is swapped out of memory. When you log out, the
Xsub-process is automatically terminated also. If you want to terminate this
Xsub-process instead, just type:
X.skip
X$ STOP REM__username#####/* For example, $ STOP REM__CS100002 */
X.skip
X3) To ask for an appointments summary for a month, please type:
X.skip
X$ VCAL/SUMMARY
X.SKIP
XThe summary for this month's appointments will be displayed on screen. You can
Xre-direct the output to a file by typing:
X.skip
X$ VCAL/SUMMARY/OUT=[file]
X.skip
XYou can also add the qualifiers /MON=[month], and /YEAR=[year] to the command.
XMonth is any month. i.e., JANUARY, FEBRUARY, etc. Year is any year from 1900 to
X9999.
X.skip
X4) To purge all old appointments leaving only current month's appointments and
Xfuture ones, please type:
X.skip
X$ VCAL/PURGE
X.SKIP
X5) To get help such as this one, just type:
X.skip
X$ HELP VCAL
X.SKIP
X.c;Limitation
X.skip
XVCAL expects you to enter the hour in the format "hhhh". If the hour is not
Xunderstood, say 2500, then it is set to 0000.
X.skip
XIf you have several appointments scheduled for the same hour, you will be
Xreminded for the first one only.
X.skip
X.c;User's Comments
X.skip
XTo help us doing a good job at releasing future softwares, please spend a few
Xminutes of your times answering the following questionaires and mail them to
XJAMES before March 30, 1987.
X.skip
X1) Do you gain any benefit from using this software? Please clarify.
X.skip
X2) Do you find that the software is easy to use? Please clarify.
X.skip
X3) In the next release of this software, what features do you want this
Xsoftware to have?
X.skip
X4) What area of Computer Science are you interested in the most?
X.skip
X.c;Acknowledgements
X.skip
XI would like to thank Mike Essex and those who did wrote VCAL. Only they can
Xtell the differences and enhancements. Special thanks are pre-said to those who
Xwill response to the above questionaires.
X.skip
X.repeat 10 '-'
X.skip
XUNIX is a trademark of Bell Laboratories.
X.break
XVAX/VMS is a trademark of Digital Equipment Corporation.
SHAR_EOF
if test 5025 -ne "`wc -c < 'bulletin.rno'`"
then
echo shar: error transmitting "'bulletin.rno'" '(should have been 5025 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'decode.c'" '(501 characters)'
if test -f 'decode.c'
then
echo shar: will not over-write existing file "'decode.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'decode.c'
X#include <ctype.h>
X#include <stdio.h>
X#include "vcal.h"
X
Xmain()
X{
X char basedata[MAX_BUF],
X *c,
X file_nam[FILE_LEN],
X key[MAX_BUF];
X FILE *fptr;
X
X printf("Enter the file to decode: ");
X gets(file_nam);
X printf("Enter the username: ");
X gets(key);
X
X for (c = key; *c; *c = _toupper(*c), c++);
X
X strcat(key, "-VCAL");
X fptr = fopen(file_nam, "r");
X
X while(fgets(basedata, MAX_BUF, fptr) != NULL)
X {
X basedata[strlen(basedata) - 1] = NULL;
X crypt_it(basedata, key);
X printf("%s\n", basedata);
X }
X}
SHAR_EOF
if test 501 -ne "`wc -c < 'decode.c'`"
then
echo shar: error transmitting "'decode.c'" '(should have been 501 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'do-appts.c'" '(25439 characters)'
if test -f 'do-appts.c'
then
echo shar: will not over-write existing file "'do-appts.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'do-appts.c'
X/*
X * -------------------------------------------------------
X * Neither York University, Department of Computer
X * Science nor the author assume any responsibility
X * for the use or reliability of this software.
X *
X * Copyright (C) 1987, York University
X * Department of Computer Science
X *
X * General permission to copy or modify, but not for
X * profit, is hereby granted, provided that the above
X * copyright notice is included and reference made to
X * the fact that reproduction privileges were granted
X * by the York University, Department of Computer Science.
X * -------------------------------------------------------
X *
X * Written by: James Pierre Lewis
X * Department of Computer Science
X * York University
X * 1987 - Version V1.0
X */
X
X#include <ctype.h>
X#include <descrip.h>
X#include <smgdef.h>
X#include <stdio.h>
X#include <time.h>
X#include "vcal.h"
X
Xchar msgdata[MAX_ENT][MAX_BUF]; /* message pointers */
X
Xchar dayw[] =
X {
X " S M T W T F S "
X };
X
Xchar *smon[] =
X {
X "JANUARY ", "FEBRUARY ", "MARCH ", "APRIL ",
X "MAY ", "JUNE ", "JULY ", "AUGUST ",
X "SEPTEMBER ", "OCTOBER ", "NOVEMBER ", "DECEMBER "
X };
X
Xint active[33], /* active day */
X daydata[MAX_ENT], /* day data */
X dayindex[MAX_MSG], /* day index to day, month, year */
X monthdata[MAX_ENT], /* month data */
X msgcnt = NULL, /* entries count */
X notclear = FALSE, /* clear flag */
X tmonth, /* current month */
X tday, /* current day */
X tyear, /* current year */
X xposition[32], /* x coordinate */
X yposition[32], /* y coordinate */
X yeardata[MAX_ENT]; /* year data */
X
Xint mon[] =
X {
X 0,
X 31, 29, 31, 30,
X 31, 30, 31, 31,
X 30, 31, 30, 31
X };
X
Xdo_appts()
X{
X extern int reset_tty(),
X updatedata();
X int day,
X i,
X j,
X key,
X month,
X stat,
X year;
X
X timeset();
X month = tmonth;
X day = tday;
X year = tyear;
X
X loaddata();
X exit_handler(updatedata, __);
X exit_handler(reset_tty, __);
X cal(day, month, year);
X help_one();
X movcur(day);
X
X while ((key = get_key(vcal_id)) != SMG$K_TRM_CTRLZ)
X {
X switch(key) {
X
X case 'P' & CHAR_MASK: /* previous month */
X case 'p' & CHAR_MASK:
X if (--month < 1)
X {
X month = 12;
X year--;
X }
X
X if (notclear)
X clearmsgs();
X clearcar();
X
X if ((month == tmonth) && (year == tyear))
X day = tday;
X else day = 1;
X
X cal(day, month, year);
X break;
X
X case 'N' & CHAR_MASK: /* next month */
X case 'n' & CHAR_MASK:
X if (++month == 13)
X {
X month = 1;
X year++;
X }
X
X if (notclear)
X clearmsgs();
X clearcar();
X
X if ((month == tmonth) && (year == tyear))
X day = tday;
X else day = 1;
X
X cal(day, month, year);
X break;
X
X case 'D' & CHAR_MASK: /* display notes */
X case 'd' & CHAR_MASK:
X notes(day, month, year);
X break;
X
X case 'E' & CHAR_MASK: /* erase a day's notes */
X case 'e' & CHAR_MASK:
X clearday(day, month, year);
X
X if (notclear)
X clearmsgs();
X break;
X
X case 'M' & CHAR_MASK: /* make appointments */
X case 'm' & CHAR_MASK:
X help_two();
X notes(day, month, year);
X modnotes(day, month, year);
X help_one();
X break;
X
X case SMG$K_TRM_UP: /* up a day */
X if ((day -= 7) <= NULL)
X {
X day += 35;
X day = (day > mon[month]) ? day - 7 : day;
X }
X
X if (notclear)
X clearmsgs();
X break;
X
X case SMG$K_TRM_DOWN: /* down a day */
X if ((day += 7) > mon[month])
X {
X day %= 7;
X day = (day == NULL) ? 7 : day;
X }
X
X if (notclear)
X clearmsgs();
X break;
X
X case SMG$K_TRM_LEFT: /* left a day */
X day = (--day <= NULL) ? mon[month] : day;
X
X if (notclear)
X clearmsgs();
X break;
X
X case SMG$K_TRM_RIGHT: /* right a day */
X day = (++day > mon[month]) ? 1 : day;
X
X if (notclear)
X clearmsgs();
X break;
X
X case SMG$K_TRM_CTRLW: /* refresh screen */
X stat = smg$repaint_screen(&pstbrd_id);
X break;
X }
X
X movcur(day); /* day right now */
X }
X}
X
X/*----------------------------------------------------------------------------*/
X
Xloaddata()
X{
X char basedata[MAX_BUF],
X key[MAX_BUF],
X tmp[MAX_BUF];
X int field,
X i,
X j,
X k,
X l;
X FILE *fptr;
X
X for (i = NULL; i < MAX_ENT; i++)
X {
X daydata[i] = monthdata[i] = yeardata[i] = *msgdata[i] = NULL;
X }
X
X if (access(APPTS_FILE, __) == -1)
X {
X warng(VCAL_FILE, 1, 1);
X }
X
X fptr = fopen(APPTS_FILE, "r");
X i = NULL;
X cuserid(key);
X strcat(key, "-VCAL");
X
X while(fgets(basedata, MAX_BUF, fptr) != NULL)
X {
X basedata[strlen(basedata) - 1] = NULL;
X crypt_it(basedata, key);
X j = k = field = NULL;
X
X while(basedata[j] != NULL )
X {
X if (basedata[j] != ',')
X tmp[k++] = basedata[j];
X else
X {
X switch(field) {
X
X case 0 :
X tmp[k] = NULL;
X monthdata[i] = atoi(tmp);
X k = NULL;
X break;
X
X case 1 :
X tmp[k] = NULL;
X daydata[i] = atoi(tmp);
X k = NULL;
X break;
X
X case 2 :
X tmp[k] = NULL;
X yeardata[i] = atoi(tmp);
X k = NULL;
X break;
X
X case 3 :
X tmp[k++] = ' ';
X tmp[k++] = ' ';
X break;
X }
X field++;
X }
X j++;
X }
X
X tmp[k] = NULL;
X strncpy(msgdata[i], tmp, MAX_BUF);
X msgdata[i][MAX_BUF - 1] = NULL;
X
X if (++i >= MAX_ENT)
X {
X CHK_STAT("", __, OWN_MSG, VCAL_PURGE);
X break;
X }
X }
X
X fclose(fptr);
X}
X
X/*----------------------------------------------------------------------------*/
X
Xwarng(msg_id, xpos, ypos)
X
Xint msg_id,
X xpos,
X ypos;
X{
X char tmp[MSG_BUF];
X short msg_len = NULL;
X int stat;
X $DESCRIPTOR(msg_buf, tmp);
X $DESCRIPTOR(wait_buf, WAIT_MSG);
X
X stat = sys$getmsg(msg_id, &msg_len, &msg_buf, __, __);
X tmp[msg_len] = NULL; msg_buf.dsc$w_length = msg_len;
X stat = smg$put_line(&vcal_id, &msg_buf, __, __, __, &WRAP, __, __);
X stat = smg$put_chars(&vcal_id, &wait_buf, __, __, __,__, __, __);
X
X if (get_key(vcal_id) == SMG$K_TRM_CTRLZ)
X sys$exit(SS$_NORMAL);
X else stat = smg$erase_display(&vcal_id, __, __, __, __);
X}
X
X/*----------------------------------------------------------------------------*/
X
Xcal(day, month, year)
X
Xint day,
X month,
X year;
X{
X char tmp[MAX_BUF];
X int d,
X i,
X j,
X k,
X stat;
X $DESCRIPTOR(blank, " ");
X
X stat = smg$put_chars(&vcal_id, mkdesc(VCAL_TITLE), &1, &1, __,
X &(SMG$M_REVERSE|SMG$M_BOLD), __, __);
X stat = smg$put_chars(&vcal_id, mkdesc(EXIT_MSG), &1, &46, __,
X &SMG$M_BOLD, __, __);
X stat = smg$draw_line(&vcal_id, &2, &1, &2, &VCAL_WID);
X sprintf(tmp, "\t\t\t\t%s%u", smon[month-1], year);
X stat = smg$put_chars(&vcal_id, mkdesc(tmp), &3, &1, __,
X &SMG$M_REVERSE, __, __);
X stat = smg$draw_line(&vcal_id, &4, &1, &4, &VCAL_WID);
X stat = smg$put_chars(&vcal_id, mkdesc(dayw), &6, &1, __, __, __, __);
X stat = smg$set_cursor_abs(&vcal_id, &TXT_ROW, &1);
X
X d = jan1(year);
X mon[2] = 29;
X mon[9] = 30;
X
X for (i = 1; i <= 32; active[i] = FALSE, i++);
X
X for (i = NULL; i < MAX_ENT; i++)
X {
X if ((yeardata[i] == year) && (monthdata[i] == month))
X active[daydata[i]] = TRUE;
X }
X
X switch((jan1(year + 1) + 7 - d) % 7) {
X
X case 1: /* non-leap year */
X mon[2] = 28;
X break;
X
X default: /* 1752 */
X mon[9] = 19;
X break;
X
X case 2: /* leap year */
X ;
X }
X
X for (i = 1; i < month; d += mon[i], i++); /* day begin of year */
X
X for (i = NULL, d %= 7; i < (5 * d); i++) /* first day of week */
X {
X stat = smg$set_cursor_rel(&vcal_id, __, &1);
X }
X
X for (j = 1, k = NULL, i = d; j <= 31; j++)
X {
X xposition[j] = (i*5) + 2;
X yposition[j] = (k*2) + 7;
X
X if (++i == 7)
X {
X i = NULL;
X k++;
X }
X }
X
X for (i = 1; i <= mon[month]; i++)
X {
X if (i == 3 && mon[month] == 19)
X {
X i += 11;
X mon[month] += 11;
X }
X
X if (active[i] == TRUE)
X {
X if (i > 9)
X {
X stat = smg$set_cursor_rel(&vcal_id, __, &1);
X sprintf(tmp, "%d", i / 10);
X stat = smg$put_chars(&vcal_id, mkdesc(tmp), __,
X __, __, &SMG$M_REVERSE, __, __);
X }
X else
X {
X stat = smg$set_cursor_rel(&vcal_id, __, &1);
X stat = smg$put_chars(&vcal_id, &blank, __,
X __, __, &SMG$M_REVERSE, __, __);
X }
X
X sprintf(tmp, "%d", i % 10);
X stat = smg$put_chars(&vcal_id, mkdesc(tmp), __,
X __, __, &SMG$M_REVERSE, __, __);
X stat = smg$set_cursor_rel(&vcal_id, __, &2);
X }
X else
X {
X if (i > 9)
X {
X sprintf(tmp, " %d", i / 10);
X stat = smg$put_chars(&vcal_id, mkdesc(tmp), __,
X __, __, __, __, __);
X }
X else stat = smg$set_cursor_rel(&vcal_id, __, &2);
X
X sprintf(tmp, "%d ", i % 10);
X stat = smg$put_chars(&vcal_id, mkdesc(tmp), __,
X __, __, __, __, __);
X
X }
X
X if (++d == 7)
X {
X d = NULL;
X stat = smg$put_line(&vcal_id, &blank, &2, __,
X __, __, __, __);
X
X }
X }
X}
X
X/*----------------------------------------------------------------------------*/
X
Xjan1(year)
X
Xint year;
X{
X register int y,
X d;
X
X y = year;
X d = 4 + y + (y + 3) / 4;
X
X if (y > 1800)
X {
X d -= (y - 1701) / 100;
X d += (y - 1601) / 400;
X }
X
X d = (y > 1752) ? d + 3 : d;
X
X return (d % 7);
X}
X
X/*----------------------------------------------------------------------------*/
X
Xhelp_one()
X{
X char *txt[4] = {
X { "Cursors : Up, Down, Left, Right" },
X { "P/p, N/n : Previous, Next month" },
X { "D/d, E/e : Display, Erase appointments" },
X { "M/m : Make appointments" }
X };
X int i,
X stat;
X
X stat = smg$unpaste_virtual_display(&hlp_id, &pstbrd_id);
X stat = smg$erase_display(&hlp_id, __, __, __, __);
X stat = smg$change_virtual_display(&hlp_id, &4, &38, __, __, __);
X
X for (i = NULL; i < 4; i++)
X {
X stat = smg$put_line(&hlp_id, mkdesc(txt[i]), &1, __,
X __, __, __, __);
X }
X
X stat = smg$paste_virtual_display(&hlp_id, &pstbrd_id, &20, &2);
X}
X
X/*----------------------------------------------------------------------------*/
X
Xhelp_two()
X{
X char *txt[4] = {
X { "Cursors : Up, Down" },
X { "I/i : Input an appointment" },
X { "E/e : Erase an appointment" },
X { "P/p : Pick another day" }
X };
X int i,
X stat;
X
X stat = smg$unpaste_virtual_display(&hlp_id, &pstbrd_id);
X stat = smg$erase_display(&hlp_id, __, __, __, __);
X stat = smg$change_virtual_display(&hlp_id, &4, &30, __, __, __);
X
X for (i = NULL; i < 4; i++)
X {
X stat = smg$put_line(&hlp_id, mkdesc(txt[i]), &1, __,
X __, __, __, __);
X }
X
X stat = smg$paste_virtual_display(&hlp_id, &pstbrd_id, &20, &2);
X}
X
X/*----------------------------------------------------------------------------*/
X
Xhelp_three()
X{
X char *txt[4] = {
X { "Cursors : Left, Right" },
X { "<CR> : End inputing an appointment" },
X { "<CTRL-A> : Toggle overtrike/insert" },
X { "<CTRL-U> : Start inputing again" }
X };
X int i,
X stat;
X
X stat = smg$unpaste_virtual_display(&hlp_id, &pstbrd_id);
X stat = smg$erase_display(&hlp_id, __, __, __, __);
X stat = smg$change_virtual_display(&hlp_id, &4, &38, __, __, __);
X
X for (i = NULL; i < 4; i++)
X {
X stat = smg$put_line(&hlp_id, mkdesc(txt[i]), &1, __,
X __, __, __, __);
X }
X
X stat = smg$paste_virtual_display(&hlp_id, &pstbrd_id, &20, &2);
X}
X
X/*----------------------------------------------------------------------------*/
X
Xhelp_four()
X{
X char *txt[4] = {
X { " A T T E N T I O N " },
X { "* Appointments file is now full *" },
X { "* Please purge old appointments *" }
X };
X int i,
X stat;
X $DESCRIPTOR(wait_buf, WAIT_MSG);
X
X stat = smg$unpaste_virtual_display(&hlp_id, &pstbrd_id);
X stat = smg$erase_display(&hlp_id, __, __, __, __);
X stat = smg$change_virtual_display(&hlp_id, &4, &33, __, __, __);
X
X for (i = NULL; i < 3; i++)
X {
X stat = smg$put_line(&hlp_id, mkdesc(txt[i]), &1, __,
X __, __, __, __);
X }
X
X stat = smg$paste_virtual_display(&hlp_id, &pstbrd_id, &20, &2);
X stat = smg$put_chars(&hlp_id, &wait_buf, &4, &1, __,
X &SMG$M_BOLD, __, __);
X
X if (get_key(hlp_id) == SMG$K_TRM_CTRLZ)
X sys$exit(SS$_NORMAL);
X}
X
X/*----------------------------------------------------------------------------*/
X
Xtimeset()
X{
X int tloc;
X struct tm *localtime(),
X *tp;
X
X time(&tloc);
X tp = localtime(&tloc);
X
X tyear = tp->tm_year;
X tmonth = tp->tm_mon + 1;
X tday = tp->tm_mday;
X tyear += LYEAR;
X}
X
X/*----------------------------------------------------------------------------*/
X
Xmovcur(day)
X
Xint day;
X{
X int col = xposition[day] + 1,
X row = yposition[day] + 1,
X stat;
X
X stat = smg$set_cursor_abs(&vcal_id, &row, &col);
X}
X
X/*----------------------------------------------------------------------------*/
X
Xclearmsgs()
X{
X int i,
X stat;
X
X notclear = FALSE;
X
X for (i = 5; i < 25; i++)
X {
X stat = smg$erase_chars(&vcal_id, &TXT_LEN, &i, &TXT_COL);
X }
X}
X
X/*----------------------------------------------------------------------------*/
X
Xclearcar()
X{
X int i,
X j = TXT_COL - 1,
X stat;
X
X stat = smg$erase_line(&vcal_id, &3, &1);
X
X for (i = TXT_ROW; i < 19; i++)
X {
X stat = smg$erase_chars(&vcal_id, &j, &i, &1);
X }
X}
X
X/*----------------------------------------------------------------------------*/
X
Xnotes(day, month, year)
X
Xint day,
X month,
X year;
X{
X char tmp[MAX_BUF];
X int i,
X j,
X k,
X stat;
X $DESCRIPTOR(blank, " ");
X
X notclear = TRUE;
X
X for (i = NULL; i <= MAX_MSG; dayindex[i] = -1, i++);
X
X sprintf(tmp, "%s", "Time Message");
X stat = smg$put_chars(&vcal_id, mkdesc(tmp), &5, &TXT_COL,
X __, __, __, __);
X sprintf(tmp, "%-3.3s %2.2d, %2.2d", smon[month - 1], day, year);
X stat = smg$put_chars(&vcal_id, mkdesc(tmp), &5, &69, __, __, __, __);
X sprintf(tmp, "%s", "hhhh <------------------------------->");
X stat = smg$put_chars(&vcal_id, mkdesc(tmp), &6, &TXT_COL,
X __, __, __, __);
X
X for (i = j = NULL; i < MAX_ENT; i++)
X {
X if ((yeardata[i] == year) &&
X (monthdata[i] == month) && (daydata[i] == day))
X {
X dayindex[j++] = i;
X }
X
X if (j > MAX_MSG)
X break;
X }
X
X sort(j - 1);
X
X for (i = NULL, k = TXT_ROW; i < j; i++, k++)
X {
X sprintf(tmp, "%-*.*s", MAX_TXT, MAX_TXT, msgdata[dayindex[i]]);
X stat = smg$put_chars(&vcal_id, mkdesc(tmp), &k,
X &TXT_COL, __, __, __, __);
X }
X
X for (msgcnt = i = NULL; i < MAX_ENT; i++)
X {
X if (daydata[i] == NULL)
X {
X dayindex[j++] = i;
X
X if (j > MAX_MSG)
X break;
X }
X else msgcnt++;
X }
X}
X
X/*----------------------------------------------------------------------------*/
X
Xclearday(day, month, year)
X
Xint day,
X month,
X year;
X{
X int i,
X stat;
X
X for (i = NULL; i < MAX_ENT; i++)
X {
X if ((yeardata[i] == year) &&
X (monthdata[i] == month) && (daydata[i] == day))
X {
X msgcnt--;
X active[day] = FALSE;
X daydata[i] = monthdata[i] = yeardata[i] = NULL;
X
X if (*msgdata[i])
X {
X *msgdata[i] = NULL;
X }
X }
X }
X
X i = yposition[day] + 1;
X stat = smg$change_rendition(&vcal_id, &i, &xposition[day], &1, &2,
X &SMG$M_REVERSE, &SMG$M_REVERSE);
X
X}
X
X/*----------------------------------------------------------------------------*/
X
Xupdatedata(final_stat)
X
Xint *final_stat;
X{
X char *c,
X key[MAX_BUF],
X tmp1[MAX_BUF],
X tmp2[MAX_BUF],
X tmpnam[MAX_BUF];
X int i,
X stat;
X FILE *tptr;
X
X c = mktemp("SYS$LOGIN:TMPXXXXXX");
X sprintf(tmpnam, "%s.DAT", c);
X
X tptr = fopen(tmpnam, "w", "fop = cif", "mrs = 80", "rat = cr",
X "rfm = var, stm");
X cuserid(key);
X strcat(key, "-VCAL");
X
X stat = lib$disable_ctrl(&LIB$M_CLI_CTRLY, __);
X
X for (i = NULL; i < MAX_ENT; i++)
X {
X if (daydata[i] != NULL)
X {
X strcpy(tmp1, msgdata[i]);
X tmp1[4] = NULL;
X sprintf(tmp2, "%d,%d,%d,%4.4s,%s",
X monthdata[i], daydata[i], yeardata[i],
X tmp1, &tmp1[6]);
X crypt_it(tmp2, key);
X fprintf(tptr, "%s\n", tmp2);
X }
X }
X
X fclose(tptr);
X delete(APPTS_FILE);
X stat = lib$rename_file(mkdesc(tmpnam), mkdesc(APPTS_FILE), __,
X __, __, __, __, __, __, __, __, __);
X
X stat = lib$enable_ctrl(&LIB$M_CLI_CTRLY, __);
X stat = sys$exit(*final_stat); /* exit normally */
X}
X
X/*----------------------------------------------------------------------------*/
X
Xmodnotes(day, month, year)
X
Xint day,
X month,
X year;
X{
X int i,
X key = NULL,
X stat,
X upbound,
X xcoord = TXT_COL,
X ycoord = TXT_ROW;
X
X stat = smg$set_cursor_abs(&vcal_id, &ycoord, &xcoord);
X
X for (i = NULL; i < MAX_MSG && dayindex[i] != -1; i++);
X
X if (i == MAX_MSG)
X upbound = VCAL_LEN - TXT_ROW;
X else upbound = i - 1;
X
X i = NULL;
X
X while ((key != 'P' & CHAR_MASK) && (key != 'p' & CHAR_MASK))
X {
X switch(key = get_key(vcal_id)) {
X
X case SMG$K_TRM_DOWN: /* down a line */
X i++;
X
X if (++ycoord > (upbound + TXT_ROW))
X {
X ycoord = TXT_ROW;
X i = NULL;
X }
X break;
X
X case SMG$K_TRM_UP: /* up a line */
X i--;
X
X if (--ycoord < TXT_ROW)
X {
X ycoord = upbound + TXT_ROW;
X i = upbound;
X }
X break;
X
X case SMG$K_TRM_CTRLW: /* refresh screen */
X stat = smg$repaint_screen(&pstbrd_id);
X break;
X
X case SMG$K_TRM_CTRLZ: /* ctrl-z to exit */
X stat = sys$exit(SS$_NORMAL);
X break;
X
X case 'I' & CHAR_MASK: /* input a line */
X case 'i' & CHAR_MASK:
X if (msgcnt < MAX_ENT)
X {
X help_three();
X get_txt(xcoord, ycoord, i, day, month, year);
X
X help_two();
X }
X else
X {
X help_four();
X help_two();
X }
X break;
X
X case 'E' & CHAR_MASK: /* erase a line */
X case 'e' & CHAR_MASK:
X daydata[dayindex[i]] = NULL;
X monthdata[dayindex[i]] = NULL;
X yeardata[dayindex[i]] = NULL;
X
X if (*msgdata[dayindex[i]])
X {
X msgcnt--;
X *msgdata[dayindex[i]] = NULL;
X }
X
X stat = smg$erase_chars(&vcal_id, &TXT_LEN,
X &ycoord, &TXT_COL);
X break;
X
X case 'P' & CHAR_MASK: /* pick another day */
X case 'p' & CHAR_MASK:
X if (notclear)
X clearmsgs();
X break;
X }
X
X stat = smg$set_cursor_abs(&vcal_id, &ycoord, &xcoord);
X }
X
X active[day] = FALSE;
X
X for (i = NULL; i < MAX_ENT; i++)
X {
X if ((yeardata[i] == year) && (monthdata[i] == month))
X active[daydata[i]] = TRUE;
X }
X
X i = yposition[day] + 1;
X
X if (active[day] == NULL)
X {
X stat = smg$change_rendition(&vcal_id, &i, &xposition[day],
X &1, &2, &SMG$M_REVERSE, &SMG$M_REVERSE);
X }
X else
X {
X stat = smg$change_rendition(&vcal_id, &i, &xposition[day],
X &1, &2, &SMG$M_REVERSE, __);
X }
X}
X
X/*----------------------------------------------------------------------------*/
X
Xget_txt(xcoord, ycoord, i, day, month, year)
X
Xint day,
X i,
X month,
X xcoord,
X ycoord,
X year;
X{
X static char *c,
X *d,
X hnum[3],
X mnum[3],
X num[5],
X tmp[MAX_BUF];
X char s[2];
X static int cnt,
X k,
X ovr_stk = TRUE;
X int j,
X l,
X m,
X key,
X stat;
X $DESCRIPTOR(blank, " ");
X
X if (*msgdata[dayindex[i]])
X fill_fld(msgdata[dayindex[i]], tmp, MAX_TXT + 1);
X else fill_fld("", tmp, MAX_TXT + 1);
X
X cnt = k = NULL;
X stat = smg$change_rendition(&vcal_id, &ycoord, &xcoord,
X &1, &TXT_LEN, &SMG$M_REVERSE, __);
X
X while ((key = get_key(vcal_id)) != SMG$K_TRM_CR)
X {
X switch(key) {
X
X case SMG$K_TRM_LEFT: /* move left */
X if (cnt <= R_MAR)
X {
X if (cnt > NULL)
X {
X if (--cnt == 5)
X {
X cnt = 3;
X stat = smg$set_cursor_rel(
X &vcal_id, __, &-3);
X }
X else
X {
X stat = smg$set_cursor_rel(
X &vcal_id, __, &-1);
X }
X }
X }
X else
X {
X stat = smg$return_cursor_pos(&vcal_id, &l, &m);
X
X if (--cnt == R_MAR)
X {
X k = NULL;
X stat = smg$put_chars(&vcal_id,
X mkdesc(tmp), __, &TXT_COL,
X __, &SMG$M_REVERSE, __, __);
X m = TXT_COL + cnt;
X }
X else
X {
X k--;
X m--;
X }
X
X stat = smg$set_cursor_abs(&vcal_id, &l, &m);
X }
X break;
X
X case SMG$K_TRM_RIGHT: /* move right */
X if (cnt < R_MAR)
X {
X if (++cnt == 4)
X {
X cnt = 6;
X stat = smg$set_cursor_rel(&vcal_id, __,
X &3);
X }
X else stat = smg$set_cursor_rel(&vcal_id, __,
X &1);
X }
X else if (cnt < MAX_TXT)
X {
X stat = smg$return_cursor_pos(&vcal_id, &l, &m);
X cnt++;
X k++;
X
X if (m == TXT_COL + R_MAR)
X {
X d = tmp + k;
X stat = smg$put_chars(&vcal_id,
X mkdesc(d), __, &TXT_COL,
X __, &SMG$M_REVERSE, __, __);
X }
X else
X {
X m++;
X stat = smg$set_cursor_abs(&vcal_id,
X &l, &m);
X }
X }
X break;
X
X case SMG$K_TRM_CTRLA: /* insert, overstrike */
X ovr_stk = ovr_stk ? FALSE : TRUE;
X break;
X
X case SMG$K_TRM_CTRLU: /* input again */
X cnt = NULL;
X fill_fld("", tmp, MAX_TXT + 1);
X stat = smg$erase_chars(&vcal_id, &TXT_LEN,
X &ycoord, &TXT_COL);
X stat = smg$change_rendition(&vcal_id, &ycoord, &xcoord,
X &1, &TXT_LEN, &SMG$M_REVERSE, __);
X stat = smg$set_cursor_abs(&vcal_id, &ycoord,
X &TXT_COL);
X break;
X
X case SMG$K_TRM_CTRLW: /* refresh screen */
X stat = smg$repaint_screen(&pstbrd_id);
X break;
X
X case SMG$K_TRM_DELETE: /* delete a char */
X del_char(tmp, &cnt, &k);
X break;
X
X case NULL: /* nothing return */
X break;
X
X default: /* input text in */
X if ((*s = (char *) key) > QST_MARK)
X {
X s[1] = NULL;
X ins_char(s, tmp, &cnt, &k, ovr_stk);
X }
X break;
X }
X }
X
X for (c = tmp + MAX_TXT - 1; *c == ' '; c--);
X
X *++c = NULL;
X
X for (c = tmp; *c == ' '; c++);
X
X if (*c)
X {
X if (*msgdata[dayindex[i]] == NULL)
X {
X msgcnt++;
X }
X
X for (j = NULL; j < 4 && isdigit(c[j]); num[j] = c[j], j++);
X
X if (j != 4)
X {
X for (j = NULL; j < 4; c[j++] = '0');
X }
X else
X {
X num[4] = NULL;
X hnum[0] = num[0]; hnum[1] = num[1]; hnum[2] = NULL;
X mnum[0] = num[2]; mnum[1] = num[3]; mnum[2] = NULL;
X
X if ((j = atoi(hnum)) < NULL || j > 24)
X {
X for (j = NULL; j < 2; c[j++] = '0');
X }
X
X if ((j = atoi(mnum)) < NULL || j > 60)
X {
X for (j = 2; j < 4; c[j++] = '0');
X }
X }
X
X strcpy(msgdata[dayindex[i]], c);
X daydata[dayindex[i]] = day;
X monthdata[dayindex[i]] = month;
X yeardata[dayindex[i]] = year;
X }
X else
X {
X daydata[dayindex[i]] = NULL;
X monthdata[dayindex[i]] = NULL;
X yeardata[dayindex[i]] = NULL;
X
X if (*msgdata[dayindex[i]])
X {
X msgcnt--;
X *msgdata[dayindex[i]] = NULL;
X }
X }
X
X stat = smg$erase_chars(&vcal_id, &TXT_LEN, &ycoord, &TXT_COL);
X stat = smg$put_chars(&vcal_id, mkdesc(tmp), &ycoord, &xcoord,
X __, __, __, __);
X
X if (c[0] == '0' && c[1] == '0' && c[2] == '0' && c[3] == '0')
X {
X stat = smg$ring_bell(&vcal_id, __);
X }
X}
X
X/*----------------------------------------------------------------------------*/
X
Xdel_char(tmp, cnt, l_mar)
X
Xchar *tmp;
Xint *cnt,
X *l_mar;
X{
X char *c,
X s[2];
X int i,
X j,
X k,
X stat;
X $DESCRIPTOR(blank, " ");
X
X if ((*cnt <= R_MAR) && (*cnt > NULL))
X {
X switch(--(*cnt)) {
X
X case 0:
X case 1:
X case 2:
X case 3:
X stat = smg$set_cursor_rel(&vcal_id, __, &-1);
X
X for (i = *cnt; i <= 3; i++)
X {
X tmp[i] = tmp[i + 1];
X s[0] = tmp[i]; s[1] = NULL;
X stat = smg$put_chars(&vcal_id, mkdesc(s),
X __, __, __, &SMG$M_REVERSE, __, __);
X }
X
X i = TXT_COL + *cnt;
X stat = smg$set_cursor_abs(&vcal_id, __, &i);
X break;
X
X case 5:
X *cnt = 3;
X stat = smg$set_cursor_rel(&vcal_id, __, &-3);
X stat = smg$put_chars(&vcal_id, &blank,
X __, __, __, &SMG$M_REVERSE, __, __);
X stat = smg$set_cursor_rel(&vcal_id, __, &-1);
X tmp[*cnt] = ' ';
X break;
X
X default:
X for (i = *cnt; i < MAX_TXT; tmp[i] = tmp[i + 1], i++);
X
X stat = smg$return_cursor_pos(&vcal_id, &j, &k);
X stat = smg$put_chars(&vcal_id, mkdesc(tmp),
X __, &TXT_COL, __, &SMG$M_REVERSE, __, __);
X k--;
X stat = smg$set_cursor_abs(&vcal_id, &j, &k);
X break;
X }
X }
X else if (*cnt > R_MAR)
X {
X for (--(*cnt), i = *cnt; i < MAX_TXT; tmp[i] = tmp[i + 1], i++);
X
X if (*cnt == R_MAR)
X *l_mar = NULL;
X else --(*l_mar);
X
X c = tmp + (*cnt - R_MAR);
X stat = smg$put_chars(&vcal_id, mkdesc(c), __,
X &TXT_COL, __, &SMG$M_REVERSE, __, __);
X }
X}
X
X/*----------------------------------------------------------------------------*/
X
Xins_char(s, tmp, cnt, l_mar, ovr_stk)
X
Xchar *s,
X *tmp;
Xint *cnt,
X *l_mar,
X ovr_stk;
X{
X char *c;
X int i,
X j,
X k,
X stat;
X
X if (ovr_stk)
X {
X if (*cnt < R_MAR)
X {
X tmp[*cnt] = s[0];
X stat = smg$put_chars(&vcal_id, mkdesc(s), __,
X __, __, &SMG$M_REVERSE, __, __);
X
X if (++(*cnt) == 4)
X {
X *cnt = 6;
X stat = smg$set_cursor_rel(&vcal_id, __, &2);
X tmp[4] = tmp[5] = ' ';
X }
X }
X else if (*cnt < MAX_TXT)
X {
X tmp[*cnt] = s[0];
X stat = smg$return_cursor_pos(&vcal_id, &j, &k);
X
X (*cnt)++;
X (*l_mar)++;
X
X if (k == TXT_COL + R_MAR)
X {
X c = tmp + *l_mar;
X stat = smg$put_chars(&vcal_id, mkdesc(c), __,
X &TXT_COL, __, &SMG$M_REVERSE, __, __);
X }
X else
X {
X stat = smg$put_chars(&vcal_id, mkdesc(s), __,
X &k, __, &SMG$M_REVERSE, __, __);
X }
X }
X }
X else
X {
X if (*cnt < R_MAR)
X {
X if (*cnt <= 3)
X {
X for (i = 3; i > *cnt; tmp[i] = tmp[i - 1], --i);
X }
X else
X {
X for (i = MAX_TXT - 1; i > *cnt; --i)
X tmp[i] = tmp[i - 1];
X }
X
X tmp[*cnt] = s[0];
X stat = smg$return_cursor_pos(&vcal_id, &j, &k);
X stat = smg$put_chars(&vcal_id, mkdesc(tmp),
X __, &TXT_COL, __, &SMG$M_REVERSE, __, __);
X k++;
X stat = smg$set_cursor_abs(&vcal_id, &j, &k);
X
X if (++(*cnt) == 4)
X {
X *cnt = 6;
X stat = smg$set_cursor_rel(&vcal_id, __, &2);
X tmp[4] = tmp[5] = ' ';
X }
X }
X else if (*cnt < MAX_TXT)
X {
X for (i = MAX_TXT - 1; i > *cnt; --i)
X tmp[i] = tmp[i - 1];
X
X tmp[*cnt] = s[0];
X stat = smg$return_cursor_pos(&vcal_id, &j, &k);
X
X (*cnt)++;
X (*l_mar)++;
X
X if (k == TXT_COL + R_MAR)
X {
X c = tmp + *l_mar;
X stat = smg$put_chars(&vcal_id, mkdesc(c), __,
X &TXT_COL, __, &SMG$M_REVERSE, __, __);
X }
X else
X {
X stat = smg$put_chars(&vcal_id, mkdesc(s), __,
X &k, __, &SMG$M_REVERSE, __, __);
X }
X }
X }
X}
X
X/*----------------------------------------------------------------------------*/
X
Xsort(upbound)
X
Xint upbound;
X{
X int i,
X j,
X k;
X
X for (i = upbound; i > NULL; i--)
X {
X for (j = NULL; j < i; j++)
X {
X if (strncmp(msgdata[dayindex[j]],
X msgdata[dayindex[j + 1]], 4) > NULL)
X {
X k = dayindex[j];
X dayindex[j] = dayindex[j + 1];
X dayindex[j + 1] = k;
X }
X }
X }
X}
SHAR_EOF
if test 25439 -ne "`wc -c < 'do-appts.c'`"
then
echo shar: error transmitting "'do-appts.c'" '(should have been 25439 characters)'
fi
fi # end of overwriting check
echo shar: extracting "'do-calls.c'" '(6041 characters)'
if test -f 'do-calls.c'
then
echo shar: will not over-write existing file "'do-calls.c'"
else
sed 's/^ X//' << \SHAR_EOF > 'do-calls.c'
X/*
X * -------------------------------------------------------
X * Neither York University, Department of Computer
X * Science nor the author assume any responsibility
X * for the use or reliability of this software.
X *
X * Copyright (C) 1987, York University
X * Department of Computer Science
X *
X * General permission to copy or modify, but not for
X * profit, is hereby granted, provided that the above
X * copyright notice is included and reference made to
X * the fact that reproduction privileges were granted
X * by the York University, Department of Computer Science.
X * -------------------------------------------------------
X *
X * Written by: James Pierre Lewis
X * Department of Computer Science
X * York University
X * 1987 - Version V1.0
X */
X
X#include <descrip.h>
X#include <lnmdef.h>
X#include <iodef.h>
X#include <stdio.h>
X#include <time.h>
X#include "vcal.h"
X
Xchar msgdata[MAX_ENT][MAX_BUF];/* message pointers */
Xint ampm, /* am or pm */
X day, /* day */
X daydata[MAX_ENT], /* day data */
X dayindex[MAX_MSG], /* day index to day, month, year */
X dow, /* dow */
X hour, /* hour */
X mhour, /* mhour */
X min, /* minute */
X month, /* month */
X monthdata[MAX_ENT], /* month data */
X year, /* year */
X yeardata[MAX_ENT], /* year data */
X sec, /* second */
X timedata[MAX_ENT]; /* time data */
X
Xmain()
X{
X int cnt,
X i,
X j,
X nowtime,
X timeout,
X tmin,
X stat;
X $DESCRIPTOR(tty, "TT");
X
X stat = sys$assign(&tty, &tty_chan, __, __);
X
X if (!((stat & STS$M_SUCCESS) >> STS$V_SUCCESS))
X warng(stat);
X
X get_data(&tmin);
X tmin = tmin * 60;
X loaddata();
X timeset();
X
X for (i = j = NULL; i < MAX_ENT; i++)
X {
X if ((yeardata[i] == year) &&
X (monthdata[i] == month) && (daydata[i] == day))
X {
X dayindex[j++] = i;
X }
X
X if (j > MAX_MSG)
X break;
X }
X
X sort(j - 1);
X timeset();
X
X for (i = NULL; i < j; i++)
X {
X nowtime = (mhour * 60) + min;
X
X if (timedata[dayindex[i]] > nowtime)
X {
X timeout = (timedata[dayindex[i]] - nowtime) * 60;
X timeout = timeout > tmin ? timeout - tmin : NULL;
X ringer(timeout, msgdata[dayindex[i]],
X timedata[dayindex[i]]);
X }
X }
X}
X
X/*----------------------------------------------------------------------------*/
X
Xget_data(tmin)
X
Xint *tmin;
X{
X char eqv_str[MAX_BUF];
X int stat;
X $DESCRIPTOR(log_nam, VCAL_MIN);
X $DESCRIPTOR(tab_nam, "LNM$JOB");
X ITEM_LST item_lst[] =
X {
X { 2, LNM$_STRING, eqv_str, 0 },
X { 0, 0, 0, 0 }
X };
X
X stat = sys$trnlnm(__, &tab_nam, &log_nam, __, &item_lst);
X
X *tmin = atoi(eqv_str);
X *tmin = (*tmin < 5 || *tmin > 20) ? 5 : *tmin;
X}
X
X/*----------------------------------------------------------------------------*/
X
Xloaddata()
X{
X char basedata[MAX_BUF],
X key[MAX_BUF],
X tmp[MAX_BUF];
X int field,
X i,
X j,
X k,
X l,
X msgtime;
X FILE *fptr;
X
X for (i = NULL; i < MAX_ENT; i++)
X {
X daydata[i] = monthdata[i] = yeardata[i] = *msgdata[i] = NULL;
X }
X
X if (access(APPTS_FILE, __) == -1)
X warng(VCAL_ACCESS);
X
X fptr = fopen(APPTS_FILE, "r");
X i = NULL;
X cuserid(key);
X strcat(key, "-VCAL");
X
X while(fgets(basedata, MAX_BUF, fptr) != NULL)
X {
X basedata[strlen(basedata) - 1] = NULL;
X crypt_it(basedata, key);
X j = k = field = NULL;
X
X while(basedata[j] != NULL )
X {
X if (basedata[j] != ',')
X tmp[k++] = basedata[j];
X else
X {
X switch(field) {
X
X case 0 :
X tmp[k] = NULL;
X monthdata[i] = atoi(tmp);
X k = NULL;
X break;
X
X case 1 :
X tmp[k] = NULL;
X daydata[i] = atoi(tmp);
X k = NULL;
X break;
X
X case 2 :
X tmp[k] = NULL;
X yeardata[i] = atoi(tmp);
X k = NULL;
X break;
X
X case 3 :
X tmp[k] = NULL;
X msgtime = atoi(tmp);
X timedata[i] = ((msgtime / 100) * 60) +
X (msgtime % 100);
X k = NULL;
X break;
X }
X field++;
X }
X j++;
X }
X
X tmp[k] = NULL;
X strncpy(msgdata[i], tmp, MAX_BUF);
X msgdata[i][MAX_BUF - 1] = NULL;
X
X if (++i >= MAX_ENT)
X break;
X }
X
X fclose(fptr);
X}
X
X/*----------------------------------------------------------------------------*/
X
Xwarng(msg_id)
X
Xint msg_id;
X{
X char tmp[MSG_BUF];
X short msg_len;
X int car_ret = 0x00000020, /* ret, <message>, ret */
X func = IO$_WRITEVBLK | IO$M_BREAKTHRU |
X IO$M_REFRESH | IO$M_CANCTRLO,
X stat;
X $DESCRIPTOR(msg_buf, tmp);
X
X stat = sys$getmsg(msg_id, &msg_len, &msg_buf, __, __);
X tmp[msg_len] = NULL;
X stat = sys$qiow(__, tty_chan, func, __, __, __, tmp, strlen(tmp),
X __, car_ret, __, __);
X stat = sys$exit(SS$_NORMAL);
X}
X
X/*----------------------------------------------------------------------------*/
X
Xtimeset()
X{
X struct tm *localtime();
X
X struct tm *tp;
X int tloc;
X
X time(&tloc);
X tp = localtime(&tloc);
X dow = tp->tm_wday;
X year = tp->tm_year;
X month = tp->tm_mon + 1;
X day = tp->tm_mday;
X hour = tp->tm_hour;
X mhour = tp->tm_hour;
X min = tp->tm_min;
X sec = tp->tm_sec;
X year += LYEAR;
X
X if (sec >= 30)
X {
X if (++min == 60)
X {
X ++mhour;
X ++hour;
X min = 0;
X }
X }
X
X hour = hour > 12 ? hour - 12 : hour;
X ampm = mhour >= 12 ? TRUE : FALSE;
X}
X
X/*----------------------------------------------------------------------------*/
X
Xringer(delay, message, at)
X
Xchar *message;
Xint at,
X delay;
X{
X char tmp[MAX_BUF];
X int car_ret = 0x00000020, /* ret, <message>, ret */
X func = IO$_WRITEVBLK | IO$M_BREAKTHRU |
X IO$M_REFRESH | IO$M_CANCTRLO,
X stat;
X
X sleep(delay);
X timeset();
X sprintf(tmp, "%c%s - Time %d:%02d %2s - %s",
X BEL, "*VCAL*", at / 60, at % 60, (ampm) ? "PM" : "AM", message);
X stat = sys$qiow(__, tty_chan, func, __, __, __, tmp, strlen(tmp),
X __, car_ret, __, __);
X}
X
X/*----------------------------------------------------------------------------*/
X
Xsort(upbound)
X
Xint upbound;
X{
X int i,
X j,
X k;
X
X for (i = upbound; i > NULL; i--)
X {
X for (j = NULL; j < i; j++)
X {
X if (timedata[dayindex[j]] > timedata[dayindex[j + 1]])
X {
X k = dayindex[j];
X dayindex[j] = dayindex[j + 1];
X dayindex[j + 1] = k;
X }
X }
X }
X}
SHAR_EOF
if test 6041 -ne "`wc -c < 'do-calls.c'`"
then
echo shar: error transmitting "'do-calls.c'" '(should have been 6041 characters)'
fi
fi # end of overwriting check
# End of shell archive
exit 0
More information about the Alt.sources
mailing list