Path: utzoo!yunexus!james From: james@yunexus.UUCP (James Pierre Lewis) Newsgroups: alt.sources Subject: Vcalendar (part 3 of 3) is available upon request. Keywords: Vcal Message-ID: <959@yunexus.UUCP> Date: 1 Feb 89 02:58:22 GMT Article-I.D.: yunexus.959 Organization: York U. Computing Services Lines: 1487 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@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: # vcal-purge.c # vcal-remind.c # vcal-sum.c # vcal-util.c # vcal.c # vcal.h # vcalendar.cld # vcalendar.rnh # This archive created: Tue Jan 31 21:50:25 1989 export PATH; PATH=/bin:$PATH echo shar: extracting "'vcal-purge.c'" '(3855 characters)' if test -f 'vcal-purge.c' then echo shar: will not over-write existing file "'vcal-purge.c'" else sed 's/^ X//' << \SHAR_EOF > 'vcal-purge.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 X#include X#include X#include "vcal.h" X Xchar msgdata[MAX_ENT][MAX_BUF]; /* message pointers */ X Xint daydata[MAX_ENT], /* day data */ X monthdata[MAX_ENT], /* month data */ X tmonth, /* current month */ X tday, /* current day */ X tyear, /* current year */ X yeardata[MAX_ENT]; /* year data */ X Xmain() X{ X timeset(); X loaddata(); X updatedata(); 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 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 CHK_STAT("", __, OWN_MSG, VCAL_ACCESS); 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 break; X } X X fclose(fptr); 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 *fptr; X X c = mktemp("SYS$LOGIN:TMPXXXXXX"); X sprintf(tmpnam, "%s.DAT", c); X fptr = 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 X if ((daydata[i] != NULL) && X ((monthdata[i] >= tmonth) && (yeardata[i] >= tyear))) 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(fptr, "%s\n", tmp2); X } X } X X fclose(fptr); 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} SHAR_EOF if test 3855 -ne "`wc -c < 'vcal-purge.c'`" then echo shar: error transmitting "'vcal-purge.c'" '(should have been 3855 characters)' fi fi # end of overwriting check echo shar: extracting "'vcal-remind.c'" '(2154 characters)' if test -f 'vcal-remind.c' then echo shar: will not over-write existing file "'vcal-remind.c'" else sed 's/^ X//' << \SHAR_EOF > 'vcal-remind.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 X#include X#include X#include X#include "vcal.h" X Xmain() X{ X char min[MAX_BUF], X prc_nam[MAX_BUF], X tmp[MAX_BUF]; X int flag = 0x00000001, /* no wait */ X stat; X $DESCRIPTOR(image, REMIND_IMAGE); X $DESCRIPTOR(log_nam, VCAL_MIN); X $DESCRIPTOR(tab_nam, "LNM$JOB"); X ITEM_LST item_lst[] = X { X { 2, LNM$_STRING, min, 0 }, X { 0, 0, 0, 0 } X }; X X cuserid(tmp); X sprintf(prc_nam, "REM_%s", tmp); X prc_nam[15] = NULL; X get_data(min); X X stat = sys$crelnm(__, &tab_nam, &log_nam, __, &item_lst); X CHK_STAT("", __, SYS_MSG, stat); X X stat = lib$spawn(&image, __, __, &flag, mkdesc(prc_nam), __, __, __, X __, __, __, __); X CHK_STAT("", __, SYS_MSG, stat); X} X X/*----------------------------------------------------------------------------*/ X Xget_data(min) X Xchar *min; X{ X char min_tmp[MAX_BUF]; X short len = NULL; X int i, X stat; X $DESCRIPTOR(min_inp, min_tmp); X $DESCRIPTOR(min_lbl, MIN); X X if ((stat = cli$present(&min_lbl)) == CLI$_PRESENT) X { X stat = cli$get_value(&min_lbl, &min_inp, &len); X min_tmp[len] = NULL; X X if ((i = atoi(min_tmp)) < 5 || i > 20) X { X CHK_STAT("", __, OWN_MSG, VCAL_INVMIN); X } X X sprintf(min, "%-2.2s", min_tmp); X } X else sprintf(min, "%-2.2s", DEF_MIN); X} SHAR_EOF if test 2154 -ne "`wc -c < 'vcal-remind.c'`" then echo shar: error transmitting "'vcal-remind.c'" '(should have been 2154 characters)' fi fi # end of overwriting check echo shar: extracting "'vcal-sum.c'" '(7808 characters)' if test -f 'vcal-sum.c' then echo shar: will not over-write existing file "'vcal-sum.c'" else sed 's/^ X//' << \SHAR_EOF > 'vcal-sum.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 X#include X#include X#include X#include "vcal.h" X Xchar msgdata[MAX_ENT][MAX_BUF]; /* message pointers */ X Xint cday, /* current day */ X cmonth, /* current month */ X cyear, /* current year */ X daydata[MAX_ENT], /* day data */ X dayindex[MAX_MSG], /* day index to day, month, year */ X monthdata[MAX_ENT], /* month data */ X yeardata[MAX_ENT]; /* year data */ X Xmain() X{ X char file_nam[FILE_LEN]; X int month, X year; X X timeset(); X year = cyear; X month = cmonth; X get_data(&month, &year, file_nam); X X if (*file_nam) X stdout = freopen(file_nam, "w", stdout, "shr = nil"); X X if (stdout == NULL) X { X CHK_STAT("", __, OWN_MSG, VCAL_INVFILE); X } X X loaddata(); X fprintf(stdout, X " A P P O I N T M E N T S L I S T\n"); X repeat('-', 78); X table(month, year); X repeat('-', 78); X} X X/*----------------------------------------------------------------------------*/ X Xget_data(month, year, file_nam) X Xchar *file_nam; Xint *month, X *year; X{ X char month_tmp[MAX_BUF], X year_tmp[MAX_BUF]; X short len = NULL; X int stat; X struct { X int : 32; X struct { X char *month_nam; X int : 32; X } month_tbl[12]; X } key_tbl = X { X 24, X { X { "7JANUARY", 1 }, X { "8FEBRUARY", 2 }, X { "5MARCH", 3 }, X { "5APRIL", 4 }, X { "3MAY", 5 }, X { "3JUN", 6 }, X { "4JULY", 7 }, X { "6AUGUST", 8 }, X { "9SEPTEMBER", 9 }, X { "8OCTOBER", 10 }, X { "8NOVEMBER", 11 }, X { "8DECEMBER", 12 } X } X }; X $PTR_DESCRIPTOR(FILE_LEN, file_inp, file_nam); X $DESCRIPTOR(file_lbl, OUT_FILE); X $DESCRIPTOR(month_inp, month_tmp); X $DESCRIPTOR(month_lbl, MONTH); X $DESCRIPTOR(year_inp, year_tmp); X $DESCRIPTOR(year_lbl, YEAR); X X if ((stat = cli$present(&month_lbl)) == CLI$_PRESENT) X { X stat = cli$get_value(&month_lbl, &month_inp, &len); X month_tmp[len] = NULL; X stat = lib$lookup_key(mkdesc(month_tmp), &key_tbl, month, X __, __); X CHK_STAT("", stat, SS$_NORMAL, VCAL_INVMONTH); X } X X if ((stat = cli$present(&year_lbl)) == CLI$_PRESENT) X { X stat = cli$get_value(&year_lbl, &year_inp, &len); X year_tmp[len] = NULL; X *year = atoi(year_tmp); X X if (*year == NULL || *year > UYEAR || *year < LYEAR) X { X CHK_STAT("", __, OWN_MSG, VCAL_INVYEAR); X } X } X X if ((stat = cli$present(&file_lbl)) == CLI$_PRESENT) X { X stat = cli$get_value(&file_lbl, &file_inp, &len); X file_nam[len] = NULL; X } X} X X/*----------------------------------------------------------------------------*/ X Xrepeat(c, num) X Xchar c; Xint num; X{ X char tmp[MAX_BUF]; X int i; X X for (i = NULL; i < num; tmp[i] = c, i++); X X tmp[0] = tmp[num - 1] = '+'; X tmp[i] = NULL; X fprintf(stdout, "%s\n", tmp); X} X X/*----------------------------------------------------------------------------*/ X Xtable(month, year) X Xint month, X year; X{ X char *dayw[] = X { X "Sat ", "Sun ", "Mon ", "Tue ", X "Wed ", "Thu ", "Fri " X }; X char *smon[] = X { X "JANUARY ", "FEBRUARY ", "MARCH ", "APRIL ", X "MAY ", "JUNE ", "JULY ", "AUGUST ", X "SEPTEMBER ", "OCTOBER ", "NOVEMBER ", "DECEMBER " X }; X int dow, X first, X i, X j, X monthday = NULL; X X fprintf(stdout, X "| %-10.10s %4.4u \ X |\n", smon[month-1], year); X X while (++monthday <= 31) X { X first = TRUE; X X for (i = j = NULL; i <= MAX_ENT; i++) X { X if ((yeardata[i] == year) && (monthdata[i] == month) && X (daydata[i] == monthday)) 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; i < j; i++) X { X if (first == TRUE) X { X dow = getdow(monthday, month, year); X first = FALSE; X fprintf(stdout, X "| \ X |\n"); X fprintf(stdout, X "| %-7.7s%2d %-64.64s|\n", dayw[dow], X monthday, msgdata[dayindex[i]]); X } X else fprintf(stdout, X "| %-64.64s|\n", X msgdata[dayindex[i]]); X } X } X} X X/*----------------------------------------------------------------------------*/ X Xgetdow(tday, tmonth, tyear) X Xint tday, X tmonth, X tyear; X{ X X static int mdays[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; X int day = 1, X days, X mcnt, X month = 1, X year = 79; X X X if ((tmonth == month) && (tyear == year)) X days = abs(day - tday); X else X { X days = mdays[month] - day; X X if (tyear == year) X { X while (++month < tmonth) X { X days += mdays[month]; X days = ((month == 2) && ((year % 4) == 0)) ? X days + 1 : days; X } X } X else X { X while (++month < 13) X { X days += mdays[month]; X days = ((month == 2) && ((year % 4) == 0)) ? X days + 1 : days; X } X X while (++year < tyear) X { X days += 365; X days = ((year % 4) == 0) ? days + 1 : days; X } X X for (mcnt = 1; mcnt < tmonth; mcnt++) X { X days += mdays[mcnt]; X days = ((mcnt == 2) && ((tyear % 4) == 0)) ? X days + 1 : days; X } X } X X days += tday; X } X X return (days % 7); 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 CHK_STAT("", __, OWN_MSG, VCAL_ACCESS); 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 break; X } X X fclose(fptr); 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 cyear = tp->tm_year; X cmonth = tp->tm_mon + 1; X cday = tp->tm_mday; X cyear += LYEAR; 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 7808 -ne "`wc -c < 'vcal-sum.c'`" then echo shar: error transmitting "'vcal-sum.c'" '(should have been 7808 characters)' fi fi # end of overwriting check echo shar: extracting "'vcal-util.c'" '(7891 characters)' if test -f 'vcal-util.c' then echo shar: will not over-write existing file "'vcal-util.c'" else sed 's/^ X//' << \SHAR_EOF > 'vcal-util.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 X#include X#include X#include X#include X#include X#include X#include X#include "smgtrmptr.h" X#include "vcal.h" X Xsetup_tty() X{ X int i, X stat; X ITEM_LST item_lst[] = X { X { 4, DVI$_DEVCLASS, &tty_class, 0 }, X { 4, DVI$_DEVTYPE, &tty_type, 0 }, X { 4, DVI$_DEVDEPEND, &tty_depend, 0 }, X { 0, 0, 0, 0 } X }; X $DESCRIPTOR(tty, "TT"); X X stat = sys$getdvi(__, __, &tty, &item_lst, __, __, __, __); X CHK_STAT("", tty_class, DC$_TERM, VCAL_NOT_TRM); X X stat = sys$assign(&tty, &tty_chan, __, __); X CHK_STAT("", __, SYS_MSG, stat); X X stat = sys$qiow(__, tty_chan, IO$_SENSEMODE, __, __, __, tty_oldchar, X 12, __, __, __, __); X X for (i = NULL; i < 3; i++) X tty_newchar[i] = tty_oldchar[i]; /* new tty mode */ X X tty_newchar[1] &= ~TT$M_MECHTAB; /* no tabbing is allowed */ X tty_newchar[1] &= ~TT$M_WRAP; /* no wrapping is allowed */ X X stat = sys$qiow(__, tty_chan, IO$_SETMODE, __, __, __, tty_newchar, X 12, __, __, __, __); X} X X/*----------------------------------------------------------------------------*/ X Xfresh_tty() X{ X char tty_clear[ESC_LEN], X tty_nowrap[ESC_LEN], X tty_setorigin[ESC_LEN], X tty_setscroll[ESC_LEN]; X int esc_len, X stat; X ESC_ARG std_region = { 2, 1, 24}; /* Normal scrolling */ X X if (tty_depend & TT$M_SCOPE) X { X stat = smg$init_term_table_by_type(&tty_type, &tty_entry, __); X CHK_STAT("", __, SYS_MSG, stat); X X stat = smg$get_term_data(&tty_entry, &SMG$K_ERASE_WHOLE_DISPLAY, X &ESC_LEN, &esc_len, tty_clear, __); X tty_clear[esc_len] = 0; X X stat = smg$get_term_data(&tty_entry, &SMG$K_SET_SCROLL_REGION, X &ESC_LEN, &esc_len, tty_setscroll, &std_region); X tty_setscroll[esc_len] = 0; X X stat = smg$get_term_data(&tty_entry, &SMG$K_SET_ORIGIN_ABSOLUTE, X &ESC_LEN, &esc_len, tty_setorigin, __); X tty_setorigin[esc_len] = 0; X X stat = smg$get_term_data(&tty_entry, &SMG$K_END_AUTOWRAP_MODE, X &ESC_LEN, &esc_len, tty_nowrap, __); X tty_nowrap[esc_len] = 0; X X if (*tty_clear && *tty_setscroll && X *tty_setorigin && *tty_nowrap) X { X printf("%s%s%s%s", tty_clear, tty_setscroll, X tty_setorigin, tty_nowrap); X } X else X { X CHK_STAT("", __, OWN_MSG, VCAL_NOT_COMP); X } X } X else X { X CHK_STAT("", __, OWN_MSG, VCAL_NOT_COMP); X } X} X X/*----------------------------------------------------------------------------*/ X Xcreat_window() X{ X int stat; X X stat = smg$create_pasteboard(&pstbrd_id, __, &BRD_LEN, &BRD_WID, __); X stat = smg$create_virtual_display(&VCAL_LEN, &VCAL_WID, &vcal_id, X __, __, __); X stat = smg$paste_virtual_display(&vcal_id, &pstbrd_id, X &TOP_ROW, &TOP_COL); X stat = smg$create_virtual_display(&VCAL_LEN, &VCAL_WID, &hlp_id, X &SMG$M_BORDER, __, __); X stat = smg$create_virtual_keyboard(&keybrd_id, __, __, __); X} X X/*----------------------------------------------------------------------------*/ X Xctrl_trap() X{ X extern int trap_ast(); X int stat; X X stat = smg$set_out_of_band_asts(&pstbrd_id, &CTRL_MASK, &trap_ast, __); X} X X/*----------------------------------------------------------------------------*/ X Xtrap_ast() X{ X int stat; X X stat = smg$cancel_input(&keybrd_id); /* cancel pending I/O */ X stat = sys$canexh(__); /* cancel exit handler */ X stat = smg$delete_pasteboard(&pstbrd_id, __); /* clear it */ X stat = smg$delete_virtual_keyboard(&keybrd_id); /* reset keyboard */ X stat = sys$qiow(__, tty_chan, IO$_SETMODE, __, __, __, tty_oldchar, X 12, __, __, __, __); /* reset tty mode */ X stat = sys$cancel(tty_chan); /* Cancel pending I/O. */ X stat = sys$dassgn(tty_chan); /* Cancel a channel for I/O. */ X stat = sys$exit(SS$_NORMAL); /* exit normally */ X} X X/*----------------------------------------------------------------------------*/ X Xchar X*mkstr(len) X Xint len; X{ X char *s; X int i; X X s = malloc(len + 1); X X for (i = NULL; i < len; s[i] = ' ', i++); X X s[len] = NULL; X X return s; X} X X/*----------------------------------------------------------------------------*/ X Xstruct dsc$descriptor X*mkdesc(str) X Xchar *str; X{ X struct dsc$descriptor *p; X X p = (struct dsc$descriptor *) malloc(sizeof(struct dsc$descriptor)); X X p->dsc$w_length = strlen(str); X p->dsc$b_dtype = DSC$K_DTYPE_T; X p->dsc$b_class = DSC$K_CLASS_S; X p->dsc$a_pointer = str; X X return p; X} X X/*----------------------------------------------------------------------------*/ X Xget_key(id) X Xint id; X{ X int func = IO$M_NOECHO | IO$M_ESCAPE | IO$M_NOFILTR, X len = 0, X stat, X trm_cd = 0; X struct dsc$descriptor *tmp; X X tmp = mkdesc(mkstr(ESC_LEN)); X stat = smg$read_string(&keybrd_id, tmp, __, &KEY_LEN, &func, __, X __, &len, &trm_cd, &id, __, __, __); X X switch(trm_cd) { X X case SMG$K_TRM_UP: X case SMG$K_TRM_DOWN: X case SMG$K_TRM_LEFT: X case SMG$K_TRM_RIGHT: X case SMG$K_TRM_CR: X case SMG$K_TRM_SPACE: X case SMG$K_TRM_DELETE: X case SMG$K_TRM_CTRLA: X case SMG$K_TRM_CTRLU: X case SMG$K_TRM_CTRLW: X case SMG$K_TRM_CTRLZ: X return trm_cd; X break; X X default: X if (!len) X return NULL; X else return (*tmp->dsc$a_pointer & CHAR_MASK); X break; X } X} X X/*----------------------------------------------------------------------------*/ X Xexit_handler(handler_rtn, arg) X Xint (*handler_rtn)(), X *arg[]; X{ X int stat; X EXIT_BLK *exit_blk; X X exit_blk = (EXIT_BLK *) malloc(sizeof(EXIT_BLK)); X X exit_blk->nxt = 0; X exit_blk->exit_rtn = handler_rtn; X exit_blk->num_arg = 2; X exit_blk->final_stat = malloc(sizeof(int)); X exit_blk->arg = (int *) arg; X X stat = sys$dclexh(exit_blk); X} X X/*----------------------------------------------------------------------------*/ X Xreset_tty(final_stat) X Xint *final_stat; X{ X int stat; X X stat = smg$delete_pasteboard(&pstbrd_id, &CLEAR); /* clear it */ X stat = smg$delete_virtual_keyboard(&keybrd_id); /* reset keyboard */ X stat = sys$qiow(__, tty_chan, IO$_SETMODE, __, __, __, tty_oldchar, X 12, __, __, __, __); /* reset tty mode */ X stat = sys$cancel(tty_chan); /* Cancel pending I/O. */ X stat = sys$dassgn(tty_chan); /* Cancel a channel for I/O. */ X} X X/*----------------------------------------------------------------------------*/ X Xcrypt_it(x, key) X Xchar *x, X *key; X{ X char c; X int i, X j, X k; X X for (i = k = NULL, j = strlen(key); *x; x++, i = ++k % j) X { X c = *x; X *x = (*x & ~key[i]) | (~*x & key[i]); X *x = (*x == NULL || X *x == CR || X *x == LF || X *x == FF ) ? c : *x; X } X} X X/*----------------------------------------------------------------------------*/ X Xfill_fld(src, dest, len) X Xchar *src, X *dest; Xint len; X{ X int i; X X /* X * Copy a src to dest field. The field is padded with blanks. X * Therefore, pointer must be correct at the boundary. X */ X X for (i = 1; i <= len && *src; *dest = *src, i++, dest++, src++); X X for (; i <= len; *dest = ' ', i++, dest++); X X dest[len] = NULL; X} SHAR_EOF if test 7891 -ne "`wc -c < 'vcal-util.c'`" then echo shar: error transmitting "'vcal-util.c'" '(should have been 7891 characters)' fi fi # end of overwriting check echo shar: extracting "'vcal.c'" '(993 characters)' if test -f 'vcal.c' then echo shar: will not over-write existing file "'vcal.c'" else sed 's/^ X//' << \SHAR_EOF > 'vcal.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 "vcal.h" X Xmain() X{ X setup_tty(); X fresh_tty(); X creat_window(); X ctrl_trap(); X do_appts(); X} SHAR_EOF if test 993 -ne "`wc -c < 'vcal.c'`" then echo shar: error transmitting "'vcal.c'" '(should have been 993 characters)' fi fi # end of overwriting check echo shar: extracting "'vcal.h'" '(3554 characters)' if test -f 'vcal.h' then echo shar: will not over-write existing file "'vcal.h'" else sed 's/^ X//' << \SHAR_EOF > 'vcal.h' X#include X#include X X/* Volatile definitions that can be customized to your needs */ X/* */ X/* LYEAR should be changed when the year 2000 comes. That's */ X/* a long way to go. */ X/* MAX_ENT shoud not be changed to a value less than MAX_MSG */ X/* */ X X#define APPTS_FILE "SYS$LOGIN:APPOINTMENTS.DAT" X#define LYEAR 1900 X#define MAX_ENT 1000 /* Maximum entries in the file */ X#define REMIND_IMAGE "RUN CS:DO-CALLS.EXE" X X/* Static definitions that should not be changed carelessly */ X X#define __ 0 X#define CHAR_MASK 0xffffffff X#define CLEAR 1 X#define CR '\015' X#define CTRL_MASK 0x02000008 X#define BEL '\007' X#define BRD_LEN 24 X#define BRD_WID 80 X#define DEF_MIN "5" X#define ESC_LEN 20 X#define EXIT_MSG "Press to complete and exit" X#define FF '\014' X#define FILE_LEN 256 X#define KEY_LEN 1 X#define LF '\012' X#define LIB$M_CLI_CTRLY 0x02000000 X#define MAX_BUF 80 X#define MAX_MSG 17 X#define MAX_TXT 61 X#define MIN "MIN" X#define MONTH "MONTH" X#define MSG_BUF 256 X#define OUT_FILE "FILE" X#define OWN_MSG -1 X#define QST_MARK '\037' X#define WAIT_MSG "Press to continue ..." X#define R_MAR 38 X#define SYS_MSG 0 X#define TOP_ROW 1 X#define TOP_COL 1 X#define TXT_COL 42 X#define TXT_LEN 39 X#define TXT_ROW 8 X#define UYEAR 9999 X#define VCAL_LEN 24 X#define VCAL_MIN "VCAL_MIN" X#define VCAL_TITLE "V I S U A L C A L E N D A R" X#define VCAL_WID 80 X#define WRAP 1 X#define YEAR "YEAR" X X#define CHK_STAT(msg, lft_val, rht_val, stat) { \ X switch(rht_val) {\ X case OWN_MSG: \ X lib$signal(stat); \ X if (*msg) \ X fprintf(stderr, " \\%s\\\r\n", msg); \ X sys$exit(SS$_NORMAL); \ X break; \ X case SYS_MSG: \ X if (!((stat & STS$M_SUCCESS) >> STS$V_SUCCESS)) \ X { \ X lib$signal(stat); \ X if (*msg) \ X fprintf(stderr, " \\%s\\\r\n", msg); \ X sys$exit(SS$_NORMAL); \ X } \ X break; \ X default: \ X if (lft_val != rht_val) \ X { \ X lib$signal(stat); \ X if (*msg) \ X fprintf(stderr, " \\%s\\\r\n", msg); \ X sys$exit(SS$_NORMAL); \ X } \ X break; \ X } \ X} X X#define $PTR_DESCRIPTOR(len, name, str) struct dsc$descriptor_s name = \ X { len, DSC$K_DTYPE_T, DSC$K_CLASS_S, str } X Xtypedef struct X { X short : 16; /* buffer length */ X short : 16; /* item code */ X int *buf_addr; X int *len_addr; X } ITEM_LST; X Xtypedef struct X { X int : 32; /* number of arguments */ X int : 32; /* first argument */ X int : 32; /* second argument */ X } ESC_ARG; X Xtypedef struct X { X int nxt; /* forward link */ X int (*exit_rtn)(); /* handler address */ X int num_arg; /* number of arguments */ X int *final_stat; /* final status */ X int arg; /* /* optional argument */ X } EXIT_BLK; X Xextern short tty_chan; /* tty channel */ X Xextern int hlp_id, /* help display */ X keybrd_id, /* keyboard id */ X pstbrd_id, /* pasteboard id */ X tty_class, /* terminal class */ X tty_depend, /* terminal dependency */ X tty_entry, /* terminal entry */ X tty_newchar[3], /* new characteristics */ X tty_oldchar[3], /* old characteristics */ X tty_type, /* terminal type */ X vcal_id; /* calendar display */ X Xglobalvalue X int VCAL_ACCESS, /* no access to appointments file */ X VCAL_FILE, /* file creation */ X VCAL_INVFILE, /* file creation problem */ X VCAL_INVMIN, /* invalid min */ X VCAL_INVMONTH, /* invalid month */ X VCAL_INVYEAR, /* invalid year */ X VCAL_NOT_COMP, /* terminal not compatible */ X VCAL_NOT_TRM, /* not a terminal */ X VCAL_PURGE; /* old entries should be purged */ SHAR_EOF if test 3554 -ne "`wc -c < 'vcal.h'`" then echo shar: error transmitting "'vcal.h'" '(should have been 3554 characters)' fi fi # end of overwriting check echo shar: extracting "'vcalendar.cld'" '(836 characters)' if test -f 'vcalendar.cld' then echo shar: will not over-write existing file "'vcalendar.cld'" else sed 's/^ X//' << \SHAR_EOF > 'vcalendar.cld' Xdefine verb vcalendar X image CS:vcal.exe X noparameters X qualifier purge, X label=purge, X nonnegatable, X syntax=purge X qualifier remind, X label=remind, X nonnegatable, X syntax=remind X qualifier summary X label=summary X nonnegatable, X syntax=summary X disallow any2(purge, remind, summary) Xdefine syntax purge X image CS:vcal-purge.exe X noparameters X noqualifiers Xdefine syntax remind X image CS:vcal-remind.exe X noparameters X qualifier min, X label=min, X nonnegatable, X value(type=$number, required) Xdefine syntax summary X image CS:vcal-sum.exe X noparameters X qualifier month, X label=month, X nonnegatable, X value(type=$quoted_string, required) X qualifier year, X label=year, X nonnegatable, X value(type=$number, required) X qualifier out, X label=file, X nonnegatable, X value(type=$file, required) SHAR_EOF if test 836 -ne "`wc -c < 'vcalendar.cld'`" then echo shar: error transmitting "'vcalendar.cld'" '(should have been 836 characters)' fi fi # end of overwriting check echo shar: extracting "'vcalendar.rnh'" '(5905 characters)' if test -f 'vcalendar.rnh' then echo shar: will not over-write existing file "'vcalendar.rnh'" else sed 's/^ X//' << \SHAR_EOF > 'vcalendar.rnh' X1 VCALENDAR X.lm+2 .s1 XThe command $ VCALENDAR invokes the calendar utility. This utility Xhelps you to keep track of your appointments. X.s1 .lit XFormat: X X $ VCALENDAR [/qualifiers] X.end lit X.lm-2 X2 Acknowledgements X.lm+2 .s1 XThanks to Mike Essex at Berkeley who, together with many others, wrote VCAL. XMike's version has been reported to work on XUNIX XVersion 7, BSD 4.3, and ULTRIX. The software was written in C using C curses Xand Termcap. XIt 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.lm-2 X2 Features X.lm+2 .s1 X VCAL 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.s1 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. You Xcould set the reminding service to remind you from 5 to 20 minutes before Xschedule events. X.s1 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.s1 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.lm-2 X2 Limitations X.lm+2 .s1 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.s1 XIf you have several appointments scheduled for the same hour, you may be Xreminded for the first one only. X.lm-2 X2 Commands X.lm+2 .s1 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. Default = 5 min. */ 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. (You could set the Xreminding service to remind you from 5 to 20 minutes before schedule events). XThe sub-process then terminates. In terms of system resources, it doesn't bog Xdown any thing because when the process hibernates, it is swapped out of Xmemory. When you log out, the sub-process is automatically terminated also. If Xyou want to terminate this sub-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.lm-2 X2 Qualifiers X.lm+2 .s1 XIf there is no qualifier specified, VCAL will display a calendar of each month. XFrom this calendar, you can pick any day to make appointments. X.lm-2 X/SUMMARY X.lit X /SUMMARY X.end lit X.lm+2 .s1 XDisplays the appointments summary for the current month if no /MON and /YEAR Xare specified. X.lm-2 X/MIN X.lit X /MIN=[min] /* 5 <= min <= 20. Default = 5 min. */ X.end lit X.lm+2 .s1 XIf you want the reminding sub-process wakes up earlier than 5 minutes before Xscheduled events, use this qualifier together with /REMIND. X.lm-2 X/OUT X.lit X /OUT=[file] X.end lit X.lm+2 .s1 XIf you want to re-direct the output of appointments summary to a file, then Xuse this qualifier. X.lm-2 X/REMIND X.lit X /REMIND X.end lit X.lm+2 .s1 XCall for the reminding service. A sub-process is created under the name X"REM__username", i.e., REM__CS100002. It hibernates until approximately 5 Xminutes before each appointment for that day, wakes up reminding you the Xscheduled event, then goes back into hibernation until no more appointments. X(You could set the reminding service to remind you from 5 to 20 minutes before Xschedule events). The sub-process then terminates. In terms of system resources, Xit doesn't bog down any thing because when the process hibernates, it is Xswapped out of memory. When you log out, the sub-process is automatically Xterminated also. If you want to terminate this sub-process instead, just type: X$ STOP REM__username. X.lm-2 X/PURGE X.lit X /PURGE X.end lit X.lm+2 .s1 XWhen your APPOINTMENTS.DAT in the main directory grows bigger to a threshold Xsize, you will be notified to purge old appointments leaving behind those of Xcurrent and future months. SHAR_EOF if test 5905 -ne "`wc -c < 'vcalendar.rnh'`" then echo shar: error transmitting "'vcalendar.rnh'" '(should have been 5905 characters)' fi fi # end of overwriting check # End of shell archive exit 0