[comp.sources.sun] v02i029: Casio BOSS Digital Diary <-> Sparcstation, Part03/06

mcgrew@aramis.rutgers.edu (Charles Mcgrew) (10/24/90)

Submitted-by: chuck@trantor.harris-atd.com (Chuck Musciano)
Posting-number: Volume 2, Issue 29
Archive-name: boss-sparc/part03

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 3 (of 6)."
# Contents:  boss.man calentool.c casio_master.c do_schedule.c lex.c
#   packet.c
# Wrapped by chuck@melmac on Tue Oct 16 08:53:04 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'boss.man' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'boss.man'\"
else
echo shar: Extracting \"'boss.man'\" \(7221 characters\)
sed "s/^X//" >'boss.man' <<'END_OF_FILE'
X.TH BOSS 1 "15 October 1990"
X.SH NAME
Xboss \- interface with a Casio BOSS
X.SH SYNOPSIS
Xboss [\fB\(hyb\fP \fIbaud\fP] [\fB\(hyf\fP \fIfile\fP] [\fB\(hyp\fP \fIparity\fP] [\fB\(hys\fP \fIport\fP] 
X.SH DESCRIPTION
X.LP
X\f2Boss\fP allows workstation users to load and store data to and from a
XCasio BOSS Digital Diary.  Casio BOSS models SF-7000, SF-7500, SF-8000,
XSF-9000, and SF-9500 are equipped with a serial port, which can be connected
Xto a variety of computing devices.
X.LP
XIn order to connect the BOSS to your machine, you will need a special 
Xconversion cable.  This cable must convert the TTL voltage-level waveforms
Xproduced by the BOSS into RS-232 voltage-level waveforms.  Real men will
Xbuild their own cable; lesser users will shell out for the Casio PC-LINK
Xcable, available from Casio dealers.  Although sold as a PC-compatible 
Xcable, the PC-LINK is known to work with a number of workstations,
Xincluding Sun machines.
X.LP
X\f2Boss\fP can read BOSS data from a number of sources, including the BOSS,
Xconventional text files, and special \f2boss\fP-format files.  Items read
Xby \f2boss\fP can then be stored in either a file or back into the BOSS.
X\f2Boss\fP can also convert BOSS schedule items to a format compatible
Xwith \f2calentool\fP(1).
X.LP
X\f2Boss\fP is most often used to periodically back up BOSS data, and to
Xconvert BOSS items, particularly memo and schedule entries, to formats
Xcompatible wih other tools.
X.SH OPTIONS
X.IP "\fB\\(hyb\fP \fIbaud\fP"
Xspecifies the default baud rate to use for the serial port to which the BOSS
Xis attached.  \fIBaud\fP must be either \*(lq1200\*(rq, \*(lq2400\*(rq, \*(lq4800\*(rq, or \*(lq9600\*(rq, 
Xand should correspond to the baud rate set in the communications parameters
Xof your BOSS.  You can also modify the baud rate in the port properties
Xdialog, described below.
X.IP "\fB\\(hyf\fP \fIfile\fP"
Xspecifies the default file into which BOSS data is saved.  If not specified,
X~/.casio is used.  This file is typically used to back up your BOSS data
Xperiodically.
X.IP "\fB\\(hyp\fP \fIparity\fP"
Xspecifies the default parity to use for the serial port to which the BOSS
Xis attached.  \fIParity\fP must be either \*(lqnone\*(rq, \*(lqodd\*(rq, or \*(lqeven\*(rq,
Xand should correspond to the parity set in the communications parameters
Xof your BOSS.  You can also modify the parity in the port properties
Xdialog, described below.
X.IP "\fB\\(hys\fP \fIport\fP"
Xspecifies the serial port to which the BOSS is attached.
X\fIPort\fP must be either \*(lqttya\*(rq or \*(lqttyb\*(rq.
XYou can modify the port setting in the port properties
Xdialog, described below.
X.SH USER INTERFACE
X.LP
X\f2Boss\fP presents the user with a control panel containing three
Xbuttons and a display window.  The count of the number of objects
Xcurrently stored by \f2boss\fP is shown in the display window.
X\f2Boss\fP's behavior is managed with the \fBFile\fP,
X\fBView\fP, and \fBEdit\fP buttons.  The menus associated with these
Xbuttons are:
X.IP "\fBFile: Load Data...\fP"
Xbrings up the \fBLoad Data\fP dialog box.  This dialog contains
Xan exclusive setting, which lets you choose the source of the data
Xto be loaded.  If \*(lqCasio BOSS\*(rq is selected, data will be read from the
Xserial port.  If \*(lqCasio-format file\*(rq is selected, data is read
Xfrom the specified file, which must have been previously created by saving
Xdata from \f2boss\fP into a Casio-format file.  If \*(lqASCII text file\*(rq
Xis selected, \f2boss\fP will read ASCII text from a file and convert it 
Xinto a sequence of BOSS memo items, placing as much text as possible into
Xeach memo item.
X.IP ""
XWhen loading data from the BOSS, click the \*(lqLoad\*(rq button in this
Xdialog \fIbefore\fP pressing the \*(lqSet\*(rq button on your BOSS to
Xstart the data transfer.
X.IP ""
XThe text fields associated with \*(lqCasio-format file\*(rq and \*(lqASCII text file\*(rq
Xprovide file name completion, like \f2csh\fP(1), by typing
Xa space or carriage return.
X.IP "\fBFile: Save Data...\fP"
Xbrings up the \fBSave Data\fP dialog box.  This dialog contains a non-exclusive
Xsetting labeled \*(lqStore items\*(rq that lets you choose which items are to
Xbe stored.  Only those items selected in this setting will be written to the
Xdestination selected.
X.IP ""
XBelow the \*(lqStore items\*(rq selection is
Xan exclusive setting which lets you choose the destination of the data
Xto be saved.  If \*(lqCasio BOSS\*(rq is selected, data will be written to the
Xserial port.  If \*(lqCasio-format file\*(rq is selected, data is written to
Xthe specified file in an internal format which retains all BOSS object
Xattributes.  This format is recommdended for backing up your BOSS data
Xfor later reloading.  If \*(lqASCII text file\*(rq
Xis selected, \f2boss\fP will convert the selected BOSS objects to ASCII text and write
Xthem to a file.  These objects, if later read by \f2boss\fP, \fIcannot\fP be
Xconverted into their original form; they will be read in as memo items.
X.IP ""
XWhen storing data to the BOSS, make sure you place the BOSS in receive mode \fIbefore\fP
Xyou start the transfer by clicking the \*(lqStore\*(rq button.
X.IP ""
XThe text fields associated with \*(lqCasio-format file\*(rq and \*(lqASCII text file\*(rq
Xprovide file name completion, like \f2csh\fP(1), by typing
Xa space or carriage return.
X.IP "\fBFile: Schedule Appointments...\fP"
Xbrings up the \fBSchedule Appointments\fP dialog box.  This dialog lets you convert
XBOSS schedule items into a format compatible with other schedule management tools.
X.IP ""
XAn exclusive setting lets you choose the destination conversion format, either
X\fIcalentool\fP(1) or Calendar Manager (see \fIcm\fP(1)).  If \f2calentool\fP
Xformat is chosen, a text field is provided to let you specify the file containing
Xyour \f2calentool\fP appointments.  By default, this is ~/.appointments.
X.IP ""
XNote that \f2boss\fP will convert appointments as closely as possible, but may
Xhave to round off certain times to retain compatibility with the destination
Xtool.  In addition, alarm times may also be lost during conversion.
X.IP "\fBView: Clear Data...\fP"
Xbrings up the \*(lqClear Data\*(rq dialog box.  This dialog contains a non-exclusive
Xsetting which lets you select those objects that will be cleared from \f2boss\fP's
Xmemory.  This is often useful when reading in new data, since existing items
Xare not removed from memory before new objects are read in.
X.IP "\fBEdit: Port Properties...\fP"
Xbrings up the \*(lqPort Properties\*(rq dialog box.  This dialog provides
Xexclusive settings which let you change the serial port, baud rate, and parity used
Xto communicate with the BOSS.  The values selected in this dialog must correspond to
Xthose set in the BOSS communications settings.  The default values use port
X/dev/ttya at 9600 baud with no parity.  The defaults can be changed with command line
Xoptions, discussed above.
X.SH FILES
X.ta 2i
X~/.casio	default BOSS data file
X.SH SEE ALSO
Xcalentool(1), cm(1)
X.SH AUTHOR
X.LP
XChuck Musciano
X.br
XAdvanced Technology Department
X.br
XHarris Corporation
X.br
XPO Box 37, MS 3A/1912
X.br
XMelbourne, FL 32902
X.br
X(407) 727-6131
X.br
XARPA: chuck@trantor.harris-atd.com
X.SH BUGS
X.LP
XIt would be nice to be able to view and edit individual BOSS objects.
END_OF_FILE
if test 7221 -ne `wc -c <'boss.man'`; then
    echo shar: \"'boss.man'\" unpacked with wrong size!
fi
# end of 'boss.man'
fi
if test -f 'calentool.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'calentool.c'\"
else
echo shar: Extracting \"'calentool.c'\" \(7196 characters\)
sed "s/^X//" >'calentool.c' <<'END_OF_FILE'
X/************************************************************************/
X/*	Copyright 1990 by Chuck Musciano and Harris Corporation		*/
X/*									*/
X/*	Permission to use, copy, modify, and distribute this software	*/
X/*	and its documentation for any purpose and without fee is	*/
X/*	hereby granted, provided that the above copyright notice	*/
X/*	appear in all copies and that both that copyright notice and	*/
X/*	this permission notice appear in supporting documentation, and	*/
X/*	that the name of Chuck Musciano and Harris Corporation not be	*/
X/*	used in advertising or publicity pertaining to distribution	*/
X/*	of the software without specific, written prior permission.	*/
X/*	Chuck Musciano and Harris Corporation make no representations	*/
X/*	about the suitability of this software for any purpose.  It is	*/
X/*	provided "as is" without express or implied warranty.		*/
X/*									*/
X/*	This code contains data and information that is proprietary	*/
X/*	to Casio Corporation.  You may be subject to legal action if	*/
X/*	this information is released without explicit permission from	*/
X/*	Casio.								*/
X/************************************************************************/
X
X/************************************************************************/
X/*									*/
X/*	calentool.c	read and write calentool appointment files	*/
X/*									*/
X/************************************************************************/
X
X#include	<stdio.h>
X#include	<ctype.h>
X
X#include	"manifest.h"
X#include	"calentool.h"
X
XPRIVATE	char	*days[] = {"Su", "Mo", "Tu", "We", "Th", "Fr", "Sa", "**"};
X
X/************************************************************************/
XPRIVATE	int	scan_value(p, val)
X
Xchar	**p;
Xint	*val;
X
X{	int	i;
X
X	if (*(*p + 2) != ' ')
X	   return(FALSE);
X	else if (isdigit(**p) && isdigit(*(*p + 1))) {
X	   *val = (**p - '0') * 10 + (*(*p + 1)) - '0';
X	   *p += 3;
X	   return(TRUE);
X	   }
X	else {
X	   for (i = 0; i < 8; i++)
X	      if (strncmp(*p, days[i], 2) == 0) {
X	         *val = -(i + 1);
X	         *p += 3;
X	         return(TRUE);
X	         }
X	   return(FALSE);
X	   }
X}
X
X/************************************************************************/
XPRIVATE	print_value(f, val)
X
XFILE	*f;
Xint	val;
X
X{
X	if (val < 0)
X	   fprintf(f, "%s ", days[-val - 1]);
X	else
X	   fprintf(f, "%02d ", val);
X}
X
X/************************************************************************/
XPRIVATE	free_calentool(cal)
X
Xcalen	*cal;
X
X{	calen	*old;
X
X	while (cal) {
X	   old = cal;
X	   cal = cal->next;
X	   if (old->message)
X	      free(old->message);
X	   if (old->warning)
X	      free(old->warning);
X	   if (old->interval)
X	      free(old->interval);
X	   if (old->repeat)
X	      free(old->repeat);
X	   free(old);
X	   }
X}
X
X/************************************************************************/
XEXPORT	calen	*load_calentool(path)
X
Xchar	*path;
X
X{	calen	*head = NULL, *cal;
X	FILE	*f;
X	char	*p, *q, buf[1024], *index();
X
X	if ((f = fopen(path, "r")) != NULL) {
X	   while (fgets(buf, 1024, f)) {
X	      if (head == NULL)
X	         head = cal = (calen *) malloc(sizeof(calen));
X	      else {
X	         cal->next = (calen *) malloc(sizeof(calen));
X	         cal = cal->next;
X	         }
X	      bzero(cal, sizeof(calen));
X	      buf[strlen(buf) - 1] = '\0';
X	      for (p = buf; isspace(*p); p++)
X	         ;
X	      if (*p == '\0' || *p == '\n' || *p == '\r') {
X	         cal->kind = LINE_BLANK;
X	         }
X	      else if (buf[0] == '#') {
X	         cal->kind = LINE_COMMENT;
X	         cal->message = strsave(buf + 1);
X	         }
X	      else {
X	         cal->kind = LINE_APPOINTMENT;
X	         p = buf;
X	         if (!scan_value(&p, &(cal->year))) {
X	            error("Invalid year in appointment file");
X	            free_calentool(head);
X	            return(NULL);
X	            }
X	         if (!scan_value(&p, &(cal->month))) {
X	            error("Invalid month in appointment file");
X	            free_calentool(head);
X	            return(NULL);
X	            }
X	         if (!scan_value(&p, &(cal->day))) {
X	            error("Invalid day in appointment file");
X	            free_calentool(head);
X	            return(NULL);
X	            }
X	         if (!scan_value(&p, &(cal->hour))) {
X	            error("Invalid hour in appointment file");
X	            free_calentool(head);
X	            return(NULL);
X	            }
X	         if (!scan_value(&p, &(cal->minute))) {
X	            error("Invalid minute in appointment file");
X	            free_calentool(head);
X	            return(NULL);
X	            }
X	         if (!scan_value(&p, &(cal->length))) {
X	            error("Invalid length in appointment file");
X	            free_calentool(head);
X	            return(NULL);
X	            }
X	         while (*p && isspace(*p))
X	            p++;
X	         if (*p == '[') {
X	            if ((q = index(p, ']')) == NULL) {
X	               error("Invalid interval in appointment file");
X	               free_calentool(head);
X	               return(NULL);
X	               }
X	            cal->interval = (char *) malloc(q - p + 2);
X	            strncpy(cal->interval, p, q - p + 1);
X	            *(cal->interval + (q - p) + 1) = '\0';
X	            p = q + 1;
X	            }
X	         while (*p && isspace(*p))
X	            p++;
X	         if (*p == '<') {
X	            if ((q = index(p, '>')) == NULL) {
X	               error("Invalid warning in appointment file");
X	               free_calentool(head);
X	               return(NULL);
X	               }
X	            cal->warning = (char *) malloc(q - p + 2);
X	            strncpy(cal->warning, p, q - p + 1);
X	            *(cal->warning + (q - p) + 1) = '\0';
X	            p = q + 1;
X	            }
X	         while (*p && isspace(*p))
X	            p++;
X	         if (*p == '+') {
X	            for (p++, cal->repeat = 0; isdigit(*p); p++)
X	               cal->repeat = cal->repeat * 10 + *p - '0';
X	            }
X	         else
X	            cal->repeat = -1;
X	         while (*p && isspace(*p))
X	            p++;
X	         if (*p != '\0')
X	            cal->message = strsave(p);
X	         }
X	      }
X	   fclose(f);
X	   return(head);
X	   }
X	else {
X	   error("Cannot read ", path);
X	   return(NULL);
X	   }
X}
X
X/************************************************************************/
XEXPORT	store_calentool(path, list)
X
Xchar	*path;
Xcalen	*list;
X
X{	FILE	*f;
X	calen	*cal;
X
X	if ((f = fopen(path, "w")) != NULL) {
X	   for (cal = list; cal; cal = cal->next)
X	      if (cal->kind == LINE_BLANK)
X	         fprintf(f, "\n");
X	      else if (cal->kind == LINE_COMMENT)
X	         fprintf(f, "#%s\n", cal->message);
X	      else {
X	         print_value(f, cal->year);
X	         print_value(f, cal->month);
X	         print_value(f, cal->day);
X	         print_value(f, cal->hour);
X	         print_value(f, cal->minute);
X	         print_value(f, cal->length);
X	         if (cal->interval)
X	            fprintf(f, "%s ", cal->interval);
X	         if (cal->warning)
X	            fprintf(f, "%s ", cal->warning);
X	         if (cal->repeat != -1)
X	            fprintf(f, "+%d ", cal->repeat);
X	         if (cal->message)
X	            fprintf(f, cal->message);
X	         fprintf(f, "\n");
X	         }
X	   fclose(f);
X	   }
X	else
X	   error("Cannot write to ", path);
X	free_calentool(list);
X}
END_OF_FILE
if test 7196 -ne `wc -c <'calentool.c'`; then
    echo shar: \"'calentool.c'\" unpacked with wrong size!
fi
# end of 'calentool.c'
fi
if test -f 'casio_master.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'casio_master.c'\"
else
echo shar: Extracting \"'casio_master.c'\" \(6003 characters\)
sed "s/^X//" >'casio_master.c' <<'END_OF_FILE'
X/************************************************************************/
X/*	Copyright 1990 by Chuck Musciano and Harris Corporation		*/
X/*									*/
X/*	Permission to use, copy, modify, and distribute this software	*/
X/*	and its documentation for any purpose and without fee is	*/
X/*	hereby granted, provided that the above copyright notice	*/
X/*	appear in all copies and that both that copyright notice and	*/
X/*	this permission notice appear in supporting documentation, and	*/
X/*	that the name of Chuck Musciano and Harris Corporation not be	*/
X/*	used in advertising or publicity pertaining to distribution	*/
X/*	of the software without specific, written prior permission.	*/
X/*	Chuck Musciano and Harris Corporation make no representations	*/
X/*	about the suitability of this software for any purpose.  It is	*/
X/*	provided "as is" without express or implied warranty.		*/
X/*									*/
X/*	This code contains data and information that is proprietary	*/
X/*	to Casio Corporation.  You may be subject to legal action if	*/
X/*	this information is released without explicit permission from	*/
X/*	Casio.								*/
X/************************************************************************/
X
X/************************************************************************/
X/*									*/
X/*	casio_master.c	send i/o requests to Casio slave		*/
X/*									*/
X/************************************************************************/
X
X#include	<stdio.h>
X#include	<sys/types.h>
X#include	<sys/termios.h>
X#include	<sys/file.h>
X
X#include	"manifest.h"
X#include	"protocol.h"
X
XPUBLIC	int	errno;
XPUBLIC	char	*sys_errlist[];
X
XPRIVATE	FILE	*commands_out;
XPRIVATE	FILE	*results_in;
XPRIVATE	char	buf[512];
X
X/************************************************************************/
XPRIVATE	int	do_write(buf, len)
X
Xchar	*buf;
Xint	len;
X
X{
X	if (fwrite(buf, 1, len, commands_out) == len)
X	   if (fflush(commands_out) == 0)
X	      return(TRUE);
X	   else
X	      error("Could not flush command pipe to Casio slave");
X	else
X	   error("Error writing to Casio slave command pipe: %s", sys_errlist[errno]);
X	return(FALSE);
X}
X
X/************************************************************************/
XPRIVATE	int	read_reply()
X
X{	char	result;
X
X	if (fread(&result, 1, 1, results_in) == 1)
X	   if (result == 0)
X	      return(TRUE);
X	   else if (fread(buf, 1, result, results_in) == result)
X	      error(buf);
X	   else
X	      error("Could not read error message from Casio slave");
X	else
X	   error("Could not read reply from Casio slave");
X	return(FALSE);
X}
X
X/************************************************************************/
XEXPORT	int	create_casio_handler()
X
X{	int	pid, commands[2], results[2];
X
X	if (pipe(commands) == -1) {
X	   fprintf(stderr, "cannot create a pipe: %s\n", sys_errlist[errno]);
X	   exit(1);
X	   }
X	if (pipe(results) == -1) {
X	   fprintf(stderr, "cannot create a pipe: %s\n", sys_errlist[errno]);
X	   exit(1);
X	   }
X	if ((pid = fork()) == -1) {
X	   fprintf(stderr, "cannot fork Casio handler: %s\n", sys_errlist[errno]);
X	   exit(1);
X	   }
X	else if (pid == 0) {
X	   close(commands[1]);
X	   close(results[0]);
X	   start_slave_handler(commands[0], results[1]);
X	   exit(0);
X	   }
X	else {
X	   close(commands[0]);
X	   close(results[1]);
X	   commands_out = fdopen(commands[1], "w");
X	   results_in = fdopen(results[0], "r");
X	   return(pid);
X	   }
X}
X
X/************************************************************************/
XEXPORT	destroy_casio_handler()
X
X{
X	close(commands_out);
X	close(results_in);
X}
X
X/************************************************************************/
XEXPORT	int	open_casio(port, baud, par)
X
Xchar	*port;
Xint	baud;
Xint	par;
X
X{
X	buf[0] = OPEN_CASIO;
X	buf[1] = baud;
X	buf[2] = par;
X	buf[3] = strlen(port);
X	strcpy(buf + 4, port);
X	if (do_write(buf, buf[3] + 4))
X	   return(read_reply());
X	else
X	   return(FALSE);
X}
X
X/************************************************************************/
XEXPORT	close_casio()
X
X{
X	buf[0] = CLOSE_CASIO;
X	if (do_write(buf, 1))
X	   read_reply();
X}
X
X/************************************************************************/
XEXPORT	int	read_casio(buffer, len, max_time)
X
Xbyte	*buffer;
Xint	len;
Xint	max_time;
X
X{	int	amount;
X
X	buf[0] = READ_CASIO;
X	bcopy(&len, buf + 1, sizeof(int));
X	bcopy(&max_time, buf + 5, sizeof(int));
X	if (do_write(buf, 9))
X	   if (read_reply())
X	      if (fread(&amount, 1, sizeof(int), results_in) == sizeof(int))
X	         if (fread(buffer, 1, amount, results_in) == amount)
X	            return(amount);
X	         else
X	            error("Error reading %d bytes from Casio slave: %s", amount, sys_errlist[errno]);
X	      else
X	         error("Error reading block size from Casio slave: %s", sys_errlist[errno]);
X	return(-1);
X}
X
X/************************************************************************/
XEXPORT	int	write_casio(buffer, len)
X
Xbyte	*buffer;
Xint	len;
X
X{	int	result;
X
X	buf[0] = WRITE_CASIO;
X	bcopy(&len, buf + 1, sizeof(int));
X	if (do_write(buf, 5))
X	   if (do_write(buffer, len))
X	      if (read_reply())
X	         if (fread(&result, 1, sizeof(int), results_in) == sizeof(int))
X	            return(result);
X	         else
X	            error("Could not read write reply from Casio slave: %s", sys_errlist[errno]);
X	return(-1);
X}
X
X/************************************************************************/
XEXPORT	enable_flow_control()
X
X{
X	buf[0] = ENABLE_FLOW_CONTROL;
X	if (do_write(buf, 1))
X	   return(read_reply());
X	return(FALSE);
X}
X
X/************************************************************************/
XEXPORT	disable_flow_control()
X
X{
X	buf[0] = DISABLE_FLOW_CONTROL;
X	if (do_write(buf, 1))
X	   return(read_reply());
X	return(FALSE);
X}
X
X/************************************************************************/
XEXPORT	int	flush_casio()
X
X{
X	buf[0] = FLUSH_CASIO;
X	if (do_write(buf, 1))
X	   return(read_reply());
X	return(FALSE);
X}
X
X/************************************************************************/
XEXPORT	unget_byte(b)
X
Xbyte	b;
X
X{
X	buf[0] = FLUSH_CASIO;
X	buf[1] = b;
X	if (do_write(buf, 2))
X	   read_reply();
X}
END_OF_FILE
if test 6003 -ne `wc -c <'casio_master.c'`; then
    echo shar: \"'casio_master.c'\" unpacked with wrong size!
fi
# end of 'casio_master.c'
fi
if test -f 'do_schedule.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'do_schedule.c'\"
else
echo shar: Extracting \"'do_schedule.c'\" \(7308 characters\)
sed "s/^X//" >'do_schedule.c' <<'END_OF_FILE'
X/************************************************************************/
X/*	Copyright 1990 by Chuck Musciano and Harris Corporation		*/
X/*									*/
X/*	Permission to use, copy, modify, and distribute this software	*/
X/*	and its documentation for any purpose and without fee is	*/
X/*	hereby granted, provided that the above copyright notice	*/
X/*	appear in all copies and that both that copyright notice and	*/
X/*	this permission notice appear in supporting documentation, and	*/
X/*	that the name of Chuck Musciano and Harris Corporation not be	*/
X/*	used in advertising or publicity pertaining to distribution	*/
X/*	of the software without specific, written prior permission.	*/
X/*	Chuck Musciano and Harris Corporation make no representations	*/
X/*	about the suitability of this software for any purpose.  It is	*/
X/*	provided "as is" without express or implied warranty.		*/
X/*									*/
X/*	This code contains data and information that is proprietary	*/
X/*	to Casio Corporation.  You may be subject to legal action if	*/
X/*	this information is released without explicit permission from	*/
X/*	Casio.								*/
X/************************************************************************/
X
X/************************************************************************/
X/*									*/
X/*	do_schedule	add Casio appointments to calentool file	*/
X/*									*/
X/************************************************************************/
X
X#include	<stdio.h>
X#include	<sys/param.h>
X#include	<sys/types.h>
X#include	<xview/xview.h>
X#include	<xview/panel.h>
X#include	"boss_ui.h"
X
X#include	"manifest.h"
X#include	"object.h"
X#include	"globals.h"
X
X#include	"calentool.h"
X
X#define		round_minute(x)		(((x) < 30)? 0 : 30)
X#define		wc(x, y)		(((x) == WILDCARD) || ((x) == (y)))
X
X#define		CALENTOOL		0
X#define		CALENDAR_MANAGER	1
X
X#define		CALENTOOL_START		(8 * 2) /* 8 AM in half hours */
X#define		CALENTOOL_END		(17 * 2 + 1) /* 5:30 PM */
X
XPUBLIC	boss_base_objects	*boss_base;
X
XPRIVATE	boss_schedule_dialog_objects	*dialog = NULL;
X
X/************************************************************************/
XPRIVATE	reconcile_schedule_range(hour, minute, len, msg)
X
Xint	*hour;
Xint	*minute;
Xint	*len;
Xchar	**msg;
X
X{	char	*p;
X	int	start, end, oh, om, new_start = FALSE, new_end = FALSE;
X
X	start = *hour * 2 + *minute / 30;
X	end = start + *len;
X	if (start < CALENTOOL_START) {
X	   start = CALENTOOL_START;
X	   new_start = TRUE;
X	   }
X	if (start > CALENTOOL_END) {
X	   start = CALENTOOL_END;
X	   new_start = TRUE;
X	   }
X	if (end < CALENTOOL_START) {
X	   end = CALENTOOL_START;
X	   new_end = TRUE;
X	   }
X	if (end > CALENTOOL_END) {
X	   end = CALENTOOL_END;
X	   new_end = TRUE;
X	   }
X	if (new_start || new_end) {
X	   p = (char *) malloc(strlen(*msg) + 20);
X	   oh = *hour + *len / 2;
X	   om = *minute + (*len % 2 + 1) * 30;
X	   if (om >= 60) {
X	      oh++;
X	      om -= 60;
X	      }
X	   if (oh > 12)
X	      oh -= 12;
X	   if (new_start && !new_end)
X	      sprintf(p, "%s (%d:%02d)", *msg, (*hour > 12)? *hour - 12 : *hour, *minute);
X	   else if (new_start && new_end)
X	      sprintf(p, "%s (%d:%02d to %d:%02d)", *msg, (*hour > 12)? *hour - 12 : *hour, *minute, oh, om);
X	   else if (!new_start && new_end)
X	      sprintf(p, "%s (to %d:%02d)", *msg, oh, om);
X	   free(*msg);
X	   *msg = p;
X	   *hour = start / 2;
X	   *minute = (start % 2) * 30;
X	   *len = end - start;
X	   }
X}
X
X/************************************************************************/
XPRIVATE	int	convert_to_calentool()
X
X{	calen	*cal, *app, *new;
X	char	*path, *p, *msg;
X	object	*obj;
X	int	year, hour, minute, len;
X
X	path = (char *) xv_get(dialog->appt_file, PANEL_VALUE);
X	if (cal = load_calentool(path)) {
X	   for (obj = data[OBJ_SCHEDULE]; obj; obj = obj->next) {
X	      msg = strsave(obj->sch_memo);
X	      for (p = msg; *p; p++)
X	         if (*p == '\r')
X	            *p = ' ';
X	      year = obj->sch_date.year % 100;
X	      if (obj->sch_start_time.hour == INVALID_TIME) {
X	         hour = 99;
X	         minute = 99;
X	         }
X	      else {
X	         hour = obj->sch_start_time.hour;
X	         minute = round_minute(obj->sch_start_time.minute);
X	         }
X	      if (obj->sch_stop_time.hour == INVALID_TIME)
X	         len = 0;
X	      else
X	         len = ((obj->sch_stop_time.hour * 60 + round_minute(obj->sch_stop_time.minute)) - (hour * 60 + minute)) / 30 - 1;
X	      if (hour != 99)
X	         reconcile_schedule_range(&hour, &minute, &len, &msg);
X	      for (app = cal; app; app = app->next) {
X	         if (wc(app->year, year) && wc(app->month, obj->sch_date.month) && wc(app->day, obj->sch_date.day)) {
X	            if (hour == 99) {
X	               if (app->hour == 99 && strcmp(app->message, msg) == 0)
X	                  break;
X	               }
X	            else if (hour == app->hour && minute == app->minute && len == app->length && strcmp(app->message, msg) == 0)
X	               break;
X	            }
X	         }
X	      if (app == NULL) {
X	         new = (calen *) malloc(sizeof(calen));
X	         bzero(new, sizeof(calen));
X	         new->kind = LINE_APPOINTMENT;
X	         new->year = year;
X	         new->month = obj->sch_date.month;
X	         new->day = obj->sch_date.day;
X	         new->hour = hour;
X	         new->minute = (hour == 99)? 0 : minute;
X	         new->length = len;
X	         new->repeat = -1;
X	         new->message = msg;
X	         for (app = cal; app->next; app = app->next)
X	            ;
X	         app->next = new;
X	         }
X	      else
X	         free(msg);
X	      }
X	   store_calentool(path, cal);
X	   return(XV_OK);
X	   }
X	return(XV_ERROR);
X}
X
X/************************************************************************/
XPRIVATE	int	convert_to_calendar_manager()
X
X{
X	error("Calendar Manager conversion is not yet available");
X	return(XV_ERROR);
X}
X
X/************************************************************************/
XEXPORT	Menu_item	schedule_dialog(item, op)
X
XMenu_item	item;
XMenu_generate	op;
X
X{
X	if (op == MENU_NOTIFY) {
X	   if (dialog == NULL) {
X	      dialog = boss_schedule_dialog_objects_initialize(NULL, boss_base->base);
X	      xv_set(dialog->appt_file,
X	                PANEL_VALUE, appts_file,
X	                PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
X	                PANEL_NOTIFY_STRING, "\n\r ",
X	                PANEL_INACTIVE, FALSE,
X	             NULL);
X	      xv_set(dialog->schedule_format, PANEL_VALUE, 0, NULL);
X	      place_dialog(boss_base->base, dialog->schedule_dialog);
X	      }
X	   xv_set(dialog->schedule_dialog, XV_SHOW, TRUE, NULL);
X	   }
X	return item;
X}
X
X/************************************************************************/
XEXPORT	void	schedule_notify(item, value, event)
X
XPanel_item	item;
Xint		value;
XEvent		*event;
X
X{
X	if (value == CALENTOOL)
X	   xv_set(dialog->appt_file, PANEL_INACTIVE, FALSE, NULL);
X	else if (value == CALENDAR_MANAGER)
X	   xv_set(dialog->appt_file, PANEL_INACTIVE, TRUE, NULL);
X}
X
X/************************************************************************/
XEXPORT	void	accept_schedule(item, event)
X
XPanel_item	item;
XEvent		*event;
X
X{	int	result, format;
X
X	lets_get_busy(TRUE, NULL);
X	if ((format = (int) xv_get(dialog->schedule_format, PANEL_VALUE)) == CALENTOOL)
X	   result = convert_to_calentool();
X	else if (format == CALENDAR_MANAGER)
X	   result = convert_to_calendar_manager();
X	xv_set(item, PANEL_NOTIFY_STATUS, result, NULL);
X	lets_get_busy(FALSE, NULL);
X}
END_OF_FILE
if test 7308 -ne `wc -c <'do_schedule.c'`; then
    echo shar: \"'do_schedule.c'\" unpacked with wrong size!
fi
# end of 'do_schedule.c'
fi
if test -f 'lex.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'lex.c'\"
else
echo shar: Extracting \"'lex.c'\" \(7219 characters\)
sed "s/^X//" >'lex.c' <<'END_OF_FILE'
X/************************************************************************/
X/*	Copyright 1990 by Chuck Musciano and Harris Corporation		*/
X/*									*/
X/*	Permission to use, copy, modify, and distribute this software	*/
X/*	and its documentation for any purpose and without fee is	*/
X/*	hereby granted, provided that the above copyright notice	*/
X/*	appear in all copies and that both that copyright notice and	*/
X/*	this permission notice appear in supporting documentation, and	*/
X/*	that the name of Chuck Musciano and Harris Corporation not be	*/
X/*	used in advertising or publicity pertaining to distribution	*/
X/*	of the software without specific, written prior permission.	*/
X/*	Chuck Musciano and Harris Corporation make no representations	*/
X/*	about the suitability of this software for any purpose.  It is	*/
X/*	provided "as is" without express or implied warranty.		*/
X/*									*/
X/*	This code contains data and information that is proprietary	*/
X/*	to Casio Corporation.  You may be subject to legal action if	*/
X/*	this information is released without explicit permission from	*/
X/*	Casio.								*/
X/************************************************************************/
X
X#define		RETURN(x)		return(last_token = (x))
X
X#define		FIRST_KEYWORD		ADDRESS
X#define		LAST_KEYWORD		TELEX
X#define		NUM_KEYWORDS		(LAST_KEYWORD - FIRST_KEYWORD + 1)
X
XPRIVATE	FILE	*f = NULL;
XPRIVATE	int	last_token = -1;
XPRIVATE	char	buf[1024];
X
XPRIVATE	struct	{char	*name;
X		 int	value;
X		} token[] = {{"address",    ADDRESS},
X			     {"alarm",      ALARM},
X			     {"calendar",   CALENDAR},
X			     {"card",       CARD},
X			     {"date",       DATE},
X			     {"department", DEPARTMENT},
X			     {"employer",   EMPLOYER},
X			     {"extra_1",    EXTRA_1},
X			     {"extra_2",    EXTRA_2},
X			     {"extra_3",    EXTRA_3},
X			     {"extra_4",    EXTRA_4},
X			     {"extra_5",    EXTRA_5},
X			     {"extra_6",    EXTRA_6},
X			     {"fax",        FAX},
X			     {"highlight",  HIGHLIGHT},
X			     {"marked",     MARKED},
X			     {"memo",       MEMO},
X			     {"name",       NAME},
X			     {"number",     NUMBER},
X			     {"pobox",      POBOX},
X			     {"position",   POSITION},
X			     {"schedule",   SCHEDULE},
X			     {"start",      START},
X			     {"stop",       STOP},
X			     {"telephone",  TELEPHONE},
X			     {"telex",      TELEX}};
X
XPRIVATE	struct	{char	first;
X		 char	next;
X		 int	name;
X		} punc[] = {{':',  '\0', COLON},
X			    {'{',  '\0', LBRACE},
X			    {'}',  '\0', RBRACE},
X			    {'/',  '\0', SLASH},
X			    {'\0', '\0', -1}};
X
X/************************************************************************/
XEXPORT	int	lex_init(path)
X
Xchar	*path;
X
X{
X	if (f)
X	   fclose(f);
X	if (f = fopen(path, "r")) {
X	   curr_file = strsave(path);
X	   line_count = 1;
X	   ungetc = -1;
X	   return(TRUE);
X	   }
X	else
X	   return(FALSE);
X}
X
X/************************************************************************/
XPRIVATE	char	getch()
X
X{	register	char	c;
X	static		int	first = TRUE;
X
X	if (ungetc != -1)
X	   c = ungetc, ungetc = -1;
X	else {
X	   c = getc(f);
X	   if (c == '\n')
X	      line_count++;
X	   }
X	return(c);
X}
X
X/************************************************************************/
XPRIVATE	fix_escapes(buf)
X
Xchar	*buf;
X
X{	char	*q;
X	int	i;
X
X	for (q = buf; *buf; buf++, q++)
X	   if (*buf == '\\')
X	      switch (*++buf) {
X	         case 'b' : *q = '\010'; /* ^h */
X	            	    break;
X	         case 'e' : *q = '\033'; /* esc */
X	          	    break;
X	         case 'f' : *q = '\014'; /* ^l */
X	            	    break;
X	         case 'n' : *q = '\012'; /* ^j */
X	            	    break;
X	         case 'r' : *q = '\015'; /* ^m */
X	            	    break;
X	         case 't' : *q = '\011'; /* ^i */
X	            	    break;
X	         case '0' : 
X	         case '1' : 
X	         case '2' : 
X	         case '3' : 
X	         case '4' : 
X	         case '5' : 
X	         case '6' : 
X	         case '7' : *q = *buf++ - '0';
X	            	    for (i = 0; i < 2 && *buf >= '0' && *buf <= '7'; i++)
X	            	       *q = (*q << 3) + *buf++ - '0';
X	            	    buf--;
X	            	    break;
X	         default  : *q = *buf;
X	            	    break;
X	         }
X	   else if (*buf == '^' && *(buf + 1) >= '@' && *(buf + 1) <= '_')
X	      *q = *++buf & 0x1f;
X	   else
X	      *q = *buf;
X	*q = '\0';
X}
X
X/************************************************************************/
XPRIVATE	int	is_keyword(s)
X
Xchar	*s;
X
X{	register	int	cmp, high, low, pos;
X
X	for (low = 0, high = NUM_KEYWORDS - 1; low <= high; )
X	   if ((cmp = strcmp(s, token[pos = (high - low) / 2 + low].name)) == 0)
X	      return(token[pos].value);
X	   else if (cmp < 0)
X	      high = pos - 1;
X	   else
X	      low = pos + 1;
X	return(NULL);
X}
X
X/************************************************************************/
XPRIVATE	int	yylex()
X
X{	register	char	c, c1, *p;
X	register	int	i, j, val;
X	char			*index();
X	double			atof();
X
X	c = getch();
X	while (isspace(c))
X	   c = getch();
X	if (isalpha(c)) {
X	   p = buf;
X	   *p++ = c;
X	   while (isalnum(c = getch()) || c == '_')
X	      *p++ = c;
X	   ungetc = c;
X	   *p = '\0';
X	   for (p = buf; *p; p++)
X	      if (isupper(*p))
X	         *p = tolower(*p);
X	   if (i = is_keyword(buf))
X	      RETURN(i);
X	   else {
X	      yyerror("unexpected keyword: %s", buf);
X	      RETURN(yylex());
X	      }
X	   }
X	else if (c == '"') {
X	   for (p = buf; TRUE; p++)
X	      if ((*p = getch()) == '"')
X	         break;
X	      else if (*p == '\\')
X	         *++p = getch();
X	      else if (*p == '\n' || *p == '\r') {
X	         yyerror("Newline in string not allowed");
X	         break;
X	         }
X	   *p = '\0';
X	   fix_escapes(buf);
X	   yylval.cpval = strsave(buf);
X	   RETURN(STRING);
X	   }
X	else if (isdigit(c)) {
X	   p = buf;
X	   *p++ = c;
X	   while (isdigit(c = getch()))
X	      *p++ = c;
X	   *p = '\0';
X	   ungetc = c;
X	   yylval.ival = atoi(buf);
X	   RETURN(INTEGER);
X	   }
X	else if (c == EOF) {
X	   fclose(f);
X	   f = NULL;
X	   RETURN(EOF);
X	   }
X	else {
X	   for (i = 0; punc[i].first; i++)
X	      if (c == punc[i].first) {
X	         for (c1 = getch(), j = 1; punc[i + j].first == c; j++)
X	            if (c1 == punc[i + j].next)
X	               RETURN(punc[i + j].name);
X	         ungetc = c1;
X	         RETURN(punc[i].name);
X	         }
X	   yyerror("Invalid character in source file: %c (0x%02x)", c, c);
X	   }
X	RETURN(yylex());
X}
X
X/************************************************************************/
XPRIVATE	char	*get_last_token()
X
X{	int	i;
X	static	char	msg[512];
X
X	if (last_token == INTEGER || last_token == STRING)
X	   sprintf(msg, "\"%s\"", buf);
X	else if (last_token >= COLON && last_token <= SLASH) {
X	   for (i = 0; punc[i].first; i++)
X	      if (punc[i].name == last_token) {
X	         sprintf(msg, "\"%c\"", punc[i].first);
X	         if (punc[i].next)
X	            sprintf(msg + 2, "%c\"", punc[i].next);
X	         break;
X	         }
X	   if (punc[i].first == '\0')
X	      sprintf(msg, "!!Geez!  Some punctuation, I don't know!!");
X	   }
X	else if (last_token >= FIRST_KEYWORD && last_token <= LAST_KEYWORD)
X	   sprintf(msg, "\"%s\"", token[last_token - FIRST_KEYWORD].name);
X	else if (last_token == EOF)
X	   sprintf(msg, "End Of File");
X	else
X	   sprintf(msg, "!!Geez!  Some keyword, I don't know!!");
X	return(msg);
X}
END_OF_FILE
if test 7219 -ne `wc -c <'lex.c'`; then
    echo shar: \"'lex.c'\" unpacked with wrong size!
fi
# end of 'lex.c'
fi
if test -f 'packet.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'packet.c'\"
else
echo shar: Extracting \"'packet.c'\" \(6443 characters\)
sed "s/^X//" >'packet.c' <<'END_OF_FILE'
X/************************************************************************/
X/*	Copyright 1990 by Chuck Musciano and Harris Corporation		*/
X/*									*/
X/*	Permission to use, copy, modify, and distribute this software	*/
X/*	and its documentation for any purpose and without fee is	*/
X/*	hereby granted, provided that the above copyright notice	*/
X/*	appear in all copies and that both that copyright notice and	*/
X/*	this permission notice appear in supporting documentation, and	*/
X/*	that the name of Chuck Musciano and Harris Corporation not be	*/
X/*	used in advertising or publicity pertaining to distribution	*/
X/*	of the software without specific, written prior permission.	*/
X/*	Chuck Musciano and Harris Corporation make no representations	*/
X/*	about the suitability of this software for any purpose.  It is	*/
X/*	provided "as is" without express or implied warranty.		*/
X/*									*/
X/*	This code contains data and information that is proprietary	*/
X/*	to Casio Corporation.  You may be subject to legal action if	*/
X/*	this information is released without explicit permission from	*/
X/*	Casio.								*/
X/************************************************************************/
X
X/************************************************************************/
X/*									*/
X/*	packet.c	handle sending and receiving raw packets	*/
X/*									*/
X/************************************************************************/
X
X#include	"manifest.h"
X#include	"casio.h"
X
XPRIVATE	int	session_open = FALSE;
XPRIVATE	char	hex[] = "0123456789ABCDEF";
X
X/************************************************************************/
XPRIVATE	int	read_byte(b, len)
X
Xbyte	*b;
Xint	len;
X
X{	char	buf[1024], *v1, *v2, *p, *index();
X
X	if (read_casio(buf, 2 * len, 1000) == 2 * len) {
X	   for (p = buf; len > 0; len--, p += 2, b++)
X	      if ((v1 = index(hex, *p)) && (v2 = index(hex, *(p + 1))))
X	         *b = ((v1 - hex) << 4) + (v2 - hex);
X	      else {
X	         error("Invalid Hex-ASCII byte from BOSS: %c%c (%02x%02x)", *p, *(p + 1), *p, *(p + 1));
X	         return(FALSE);
X	         }
X	   return(TRUE);
X	   }
X	else
X	   error("error reading %d byte%s from BOSS", len, (len == 1)? "" : "s");
X	return(FALSE);
X}
X
X/************************************************************************/
XEXPORT	int	start_session()
X
X{	byte	b;
X	int	i;
X
X	if (session_open)
X	   return(TRUE);
X	if (!flush_casio())
X	   return(FALSE);
X	if (!disable_flow_control())
X	   return(FALSE);
X	for (i = 0; i < 16; i++) {
X	   b = '\r';
X	   if (write_casio(&b, 1) == 1) {
X	      usleep(5000);
X	      b = '\n';
X	      if (write_casio(&b, 1) == 1)
X	         if (read_casio(&b, 1, 1000) == 1)
X	            if (b == '\021')
X	               if (enable_flow_control()) {
X	                  session_open = TRUE;
X	                  return(TRUE);
X	                  }
X	      }
X	   usleep(100000);
X	   }
X	error("BOSS session not started");
X	return(FALSE);
X}
X
X/************************************************************************/
XEXPORT	end_session()
X
X{	byte	buf[8];
X
X	if (session_open) {
X	   buf[0] = 0; /* length of 0 */
X	   buf[1] = 0; /* address of 0 */
X	   buf[2] = 0;
X	   buf[3] = 0xff; /* type REC_EXIT */
X	   send_packet(buf);
X	   buf[0] = XMIT_TERMINATE;
X	   write_casio(buf, 1);
X	   session_open = FALSE;
X	   }
X}
X
X/************************************************************************/
XEXPORT	send_packet(buf)
X
Xbyte	*buf;
X
X{	int	len, i;
X	byte	b, checksum;
X	char	real[1024];
X
X	if (session_open) {
X	   real[0] = PACKET_START;
X	   for (len = buf[0] + 4, i = checksum = 0; i < len; i++) {
X	      checksum += buf[i];
X	      real[2 * i + 1] = hex[buf[i] >> 4];
X	      real[2 * i + 2] = hex[buf[i] & 0x0f];
X	      }
X	   checksum = 256 - checksum;
X	   real[2 * i + 1] = hex[checksum >> 4];
X	   real[2 * i + 2] = hex[checksum & 0x0f];
X	   while (TRUE) {
X	      if (write_casio(real, 2 * len + 3) != 2 * len + 3) {
X	         error("unable to write packet to BOSS");
X	         return(FALSE);
X	         }
X	      if ((i = read_casio(&b, 1, 50)) == 0)
X	         return(TRUE); /* no complaints from BOSS */
X	      else if (i == -1) {
X	         error("error awaiting packet ACK from BOSS");
X	         return(FALSE);
X	         }
X	      else if (b == '?') {
X	         disable_flow_control();
X	         usleep(20000);
X	         i = read_casio(&b, 1, 1000);
X	         enable_flow_control();
X	         if (i != 1 || b != '\021') {
X	            error("protocol error during packet retry prologue");
X	            return(FALSE);
X	            }
X	         }
X	      else {
X	         unget_byte(b);
X	         return(TRUE);
X	         }
X	      }
X	   }
X	else {
X	   error("attempted to send a packet without opening a session");
X	   return(FALSE);
X	   }
X}
X
X/************************************************************************/
XEXPORT	int	receive_packet(packet)
X
Xbyte	*packet;
X
X{	byte	checksum;
X	int	i;
X
X	while (TRUE) {
X	   if (read_casio(packet, 1, 60000) != 1) {
X	      error("no transmission received from BOSS");
X	      return(FALSE);
X	      }
X	   if (packet[0] == '\n' || packet[0] == '\r') {
X	      packet[0] = '\021';
X	      if (write_casio(packet, 1) != 1) {
X	         error("could not reply to BOSS polling");
X	         return(FALSE);
X	         }
X	      }
X	   else if (packet[0] == PACKET_START)
X	      break;
X	   else if (packet[0] == XMIT_TERMINATE)
X	      return(FALSE);
X	   else {
X	      error("unexpected data from the BOSS: %c (%02x)", packet[0], packet[0]);
X	      return(FALSE);
X	      }
X	   }
X	if (!read_byte(packet, 4))
X	   return(FALSE);
X	if (!read_byte(packet + 4, packet[0] + 1))
X	   return(FALSE);
X	for (i = checksum = 0; i < packet[0] + 5; i++)
X	   checksum += packet[i];
X	if (checksum != 0) {
X	   error("parity error, retrying receive");
X	   packet[0] = RCV_ERROR;
X	   write_casio(packet, 1);
X	   usleep(20000);
X	   packet[0] = '\021';
X	   write_casio(packet, 1);
X	   return(receive_packet(packet));
X	   }
X	else
X	   return(TRUE);
X}
X
X/************************************************************************/
XEXPORT	acknowledge_object()
X
X{	byte	b;
X
X	b = PACKET_ACK;
X	if (!write_casio(&b, 1))
X	   error("error acknowledging packet");
X}
X
X/************************************************************************/
XEXPORT	int	wait_for_acknowledgement()
X
X{	byte	b;
X
X	if (read_casio(&b, 1, 60000) == 1)
X	   if (b == PACKET_ACK)
X	      return(TRUE);
X	   else
X	      error("invalid object acknowledgement: %c (%02x)", b, b);
X	else
X	   error("no acknowledgement received from BOSS");
X	return(FALSE);
X}
END_OF_FILE
if test 6443 -ne `wc -c <'packet.c'`; then
    echo shar: \"'packet.c'\" unpacked with wrong size!
fi
# end of 'packet.c'
fi
echo shar: End of archive 3 \(of 6\).
cp /dev/null ark3isdone
MISSING=""
for I in 1 2 3 4 5 6 ; do
    if test ! -f ark${I}isdone ; then
	MISSING="${MISSING} ${I}"
    fi
done
if test "${MISSING}" = "" ; then
    echo You have unpacked all 6 archives.
    rm -f ark[1-9]isdone
else
    echo You still need to unpack the following archives:
    echo "        " ${MISSING}
fi
##  End of shell archive.
exit 0

Chuck Musciano				ARPA  : chuck@trantor.harris-atd.com
Harris Corporation 			Usenet: ...!uunet!x102a!trantor!chuck
PO Box 37, MS 3A/1912			AT&T  : (407) 727-6131
Melbourne, FL 32902			FAX   : (407) 729-2537

A good newspaper is never good enough,
	but a lousy newspaper is a joy forever.		-- Garrison Keillor