v02i028: Casio BOSS Digital Diary <-> Sparcstation, Part 02/06

Charles Mcgrew mcgrew at aramis.rutgers.edu
Wed Oct 24 08:13:24 AEST 1990


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

#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g..  If this archive is complete, you
# will see the following message at the end:
#		"End of archive 2 (of 6)."
# Contents:  boss.c boss_ui.h do_load.c do_store.c expand.c misc.c
#   record.c window_misc.c
# Wrapped by chuck at melmac on Tue Oct 16 08:53:03 1990
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'boss.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'boss.c'\"
else
echo shar: Extracting \"'boss.c'\" \(5480 characters\)
sed "s/^X//" >'boss.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/*	boss		main driver for Casio BOSS interface program	*/
X/*									*/
X/************************************************************************/
X
X#include	<stdio.h>
X#include	<ctype.h>
X#include	<sys/param.h>
X#include	<sys/types.h>
X#include	<xview/xview.h>
X#include	<xview/panel.h>
X#include	<xview/font.h>
X#include	"boss_ui.h"
X
X#include	"manifest.h"
X#include	"packet.h"
X#include	"object.h"
X#include	"globals.h"
X
XEXPORT	int	baud_rate = BAUD_9600;
XEXPORT	int	parity = NO_PARITY;
XEXPORT	int	port = PORT_TTYA;
XEXPORT	char	*port_file = "/dev/ttya";
XEXPORT	char	*casio_file = NULL;
XEXPORT	char	*appts_file = NULL;
X
XEXPORT	Attr_attribute	INSTANCE;
X
XEXPORT	boss_base_objects	*boss_base;
X
XPRIVATE	Attr_attribute	CENTER_POINT;
X
X/************************************************************************/
XEXPORT	update_object_count()
X
X{	int	i, j;
X	object	*obj;
X	char	buf[5];
X	Font_string_dims	dims;
X	static	Xv_Font	font;
X	static	Xv_opaque	count[MAX_OBJECT_KINDS] = {NULL, NULL, NULL, NULL, NULL};
X	static	int	amount[MAX_OBJECT_KINDS] = {0, 0, 0, 0, 0};
X
X	if (count[0] == NULL) {
X	   count[0] = boss_base->phone;
X	   count[1] = boss_base->schedule;
X	   count[2] = boss_base->memo;
X	   count[3] = boss_base->card;
X	   count[4] = boss_base->calendar;
X	   font = (Xv_Font) xv_get(boss_base->main_display, PANEL_BOLD_FONT);
X	   for (i = 0; i < MAX_OBJECT_KINDS; i++) {
X	      xv_get(font, FONT_STRING_DIMS, (char *) xv_get(count[i], PANEL_LABEL_STRING), &dims);
X	      xv_set(count[i], XV_KEY_DATA, CENTER_POINT, ((int) xv_get(count[i], XV_X)) + dims.width / 2, NULL);
X	      }
X	   }
X
X	for (i = 0; i < MAX_OBJECT_KINDS; i++) {
X	   for (j = 0, obj = data[i]; obj; obj = obj->next, j++)
X	      ;
X	   if (j != amount[i]) {
X	      sprintf(buf, " %d ", j);
X	      xv_get(font, FONT_STRING_DIMS, buf, &dims);
X	      xv_set(count[i], PANEL_LABEL_STRING, buf, PANEL_ITEM_X, ((int) xv_get(count[i], XV_KEY_DATA, CENTER_POINT)) - dims.width / 2, 0);
X	      XFlush(xv_get(boss_base->base, XV_DISPLAY));
X	      amount[i] = j;
X	      }
X	   }
X}
X
X/************************************************************************/
Xmain(argc, argv)
X
Xint		argc;
Xchar		**argv;
X
X{	char	c, *s, buf[512], getopt();
X	int	pid;
X
X	xv_init(XV_INIT_ARGC_PTR_ARGV, &argc, argv, 0);
X
X	while ((c = getopt(&argc, argv, "b:f:p:s:", &s)) != EOF)
X	   switch (c) {
X	      case 'b' : if (strcmp(s, "1200") == 0)
X	      		    baud_rate = BAUD_1200;
X	      		 else if (strcmp(s, "2400") == 0)
X	      		    baud_rate = BAUD_2400;
X	      		 else if (strcmp(s, "4800") == 0)
X	      		    baud_rate = BAUD_4800;
X	      		 else if (strcmp(s, "9600") == 0)
X	      		    baud_rate = BAUD_9600;
X	      		 else {
X	      		    fprintf(stderr, "%s: invalid baud rate: %s\n", argv[0], s);
X	      		    exit(1);
X	      		    }
X	      		 break;
X	      case 'f' : casio_file = strsave(s);
X	      		 break;
X	      case 'p' : lower(s);
X	      		 if (strcmp(s, "even") == 0)
X	      		    parity = EVEN_PARITY;
X	      		 else if (strcmp(s, "odd") == 0)
X	      		    parity = ODD_PARITY;
X	      		 else if (strcmp(s, "none") == 0)
X	      		    parity = NO_PARITY;
X	      		 else {
X	      		    fprintf(stderr, "%s: invalid parity: %s\n", argv[0], s);
X	      		    exit(1);
X	      		    }
X	      		 break;
X	      case 's' : lower(s);
X	      		 if (strcmp(s, "ttya") == 0)
X	      		    port = PORT_TTYA;
X	      		 else if (strcmp(s, "ttyb") == 0)
X	      		    port = PORT_TTYB;
X	      		 else {
X	      		    fprintf(stderr, "%s: invalid serial port: %s\n", argv[0], s);
X	      		    exit(1);
X	      		    }
X	      		 break;
X	      default  : fprintf(stderr, "usage: %s [-b <rate>] [-f <file>] [-p <parity>] [-s <port>]\n", argv[0]);
X	      		 exit(1);
X	      		 break;
X	      }
X	if (casio_file == NULL) {
X	   sprintf(buf, "%s/.casio", getenv("HOME"));
X	   casio_file = strsave(buf);
X	   }
X	sprintf(buf, "%s/.appointments", getenv("HOME"));
X	appts_file = strsave(buf);
X
X	pid = create_casio_handler();
X
X	INSTANCE = xv_unique_key();
X	CENTER_POINT = xv_unique_key();
X
X	boss_base = boss_base_objects_initialize(NULL, NULL);
X
X	update_object_count();
X	notify_set_wait3_func(boss_base->base, notify_default_wait3, pid);
X	window_main_loop(boss_base->base);
X	destroy_casio_handler();
X
X	exit(0);
X}
END_OF_FILE
if test 5480 -ne `wc -c <'boss.c'`; then
    echo shar: \"'boss.c'\" unpacked with wrong size!
fi
# end of 'boss.c'
fi
if test -f 'boss_ui.h' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'boss_ui.h'\"
else
echo shar: Extracting \"'boss_ui.h'\" \(5701 characters\)
sed "s/^X//" >'boss_ui.h' <<'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#ifndef	boss_HEADER
X#define	boss_HEADER
X
X/*
X * boss_ui.h - User interface object and function declarations.
X * This file was generated by `gxv' from `boss.G'.
X * DO NOT EDIT BY HAND.
X */
X
Xextern Attr_attribute	INSTANCE;
X
Xextern Xv_opaque	boss_file_menu_create();
Xextern Xv_opaque	boss_view_menu_create();
Xextern Xv_opaque	boss_edit_menu_create();
X
Xtypedef struct {
X	Xv_opaque	base;
X	Xv_opaque	main_control;
X	Xv_opaque	file_button;
X	Xv_opaque	view_button;
X	Xv_opaque	edit_button;
X	Xv_opaque	main_display;
X	Xv_opaque	message1;
X	Xv_opaque	message2;
X	Xv_opaque	message3;
X	Xv_opaque	message4;
X	Xv_opaque	message5;
X	Xv_opaque	phone;
X	Xv_opaque	schedule;
X	Xv_opaque	memo;
X	Xv_opaque	card;
X	Xv_opaque	calendar;
X} boss_base_objects;
X
Xextern boss_base_objects	*boss_base_objects_initialize();
X
Xextern Xv_opaque	boss_base_base_create();
Xextern Xv_opaque	boss_base_main_control_create();
Xextern Xv_opaque	boss_base_file_button_create();
Xextern Xv_opaque	boss_base_view_button_create();
Xextern Xv_opaque	boss_base_edit_button_create();
Xextern Xv_opaque	boss_base_main_display_create();
Xextern Xv_opaque	boss_base_message1_create();
Xextern Xv_opaque	boss_base_message2_create();
Xextern Xv_opaque	boss_base_message3_create();
Xextern Xv_opaque	boss_base_message4_create();
Xextern Xv_opaque	boss_base_message5_create();
Xextern Xv_opaque	boss_base_phone_create();
Xextern Xv_opaque	boss_base_schedule_create();
Xextern Xv_opaque	boss_base_memo_create();
Xextern Xv_opaque	boss_base_card_create();
Xextern Xv_opaque	boss_base_calendar_create();
X
Xtypedef struct {
X	Xv_opaque	load_dialog;
X	Xv_opaque	load_control;
X	Xv_opaque	source;
X	Xv_opaque	casio_source;
X	Xv_opaque	ascii_source;
X	Xv_opaque	load_accept;
X} boss_load_dialog_objects;
X
Xextern boss_load_dialog_objects	*boss_load_dialog_objects_initialize();
X
Xextern Xv_opaque	boss_load_dialog_load_dialog_create();
Xextern Xv_opaque	boss_load_dialog_load_control_create();
Xextern Xv_opaque	boss_load_dialog_source_create();
Xextern Xv_opaque	boss_load_dialog_casio_source_create();
Xextern Xv_opaque	boss_load_dialog_ascii_source_create();
Xextern Xv_opaque	boss_load_dialog_load_accept_create();
X
Xtypedef struct {
X	Xv_opaque	store_dialog;
X	Xv_opaque	store_control;
X	Xv_opaque	store_data;
X	Xv_opaque	dest;
X	Xv_opaque	casio_dest;
X	Xv_opaque	ascii_dest;
X	Xv_opaque	store_accept;
X} boss_store_dialog_objects;
X
Xextern boss_store_dialog_objects	*boss_store_dialog_objects_initialize();
X
Xextern Xv_opaque	boss_store_dialog_store_dialog_create();
Xextern Xv_opaque	boss_store_dialog_store_control_create();
Xextern Xv_opaque	boss_store_dialog_store_data_create();
Xextern Xv_opaque	boss_store_dialog_dest_create();
Xextern Xv_opaque	boss_store_dialog_casio_dest_create();
Xextern Xv_opaque	boss_store_dialog_ascii_dest_create();
Xextern Xv_opaque	boss_store_dialog_store_accept_create();
X
Xtypedef struct {
X	Xv_opaque	clear_dialog;
X	Xv_opaque	clear_control;
X	Xv_opaque	clear_data;
X	Xv_opaque	clear_accept;
X} boss_clear_dialog_objects;
X
Xextern boss_clear_dialog_objects	*boss_clear_dialog_objects_initialize();
X
Xextern Xv_opaque	boss_clear_dialog_clear_dialog_create();
Xextern Xv_opaque	boss_clear_dialog_clear_control_create();
Xextern Xv_opaque	boss_clear_dialog_clear_data_create();
Xextern Xv_opaque	boss_clear_dialog_clear_accept_create();
X
Xtypedef struct {
X	Xv_opaque	port_dialog;
X	Xv_opaque	port_control;
X	Xv_opaque	port_port;
X	Xv_opaque	port_baud;
X	Xv_opaque	port_parity;
X	Xv_opaque	port_accept;
X	Xv_opaque	port_reset;
X} boss_port_dialog_objects;
X
Xextern boss_port_dialog_objects	*boss_port_dialog_objects_initialize();
X
Xextern Xv_opaque	boss_port_dialog_port_dialog_create();
Xextern Xv_opaque	boss_port_dialog_port_control_create();
Xextern Xv_opaque	boss_port_dialog_port_port_create();
Xextern Xv_opaque	boss_port_dialog_port_baud_create();
Xextern Xv_opaque	boss_port_dialog_port_parity_create();
Xextern Xv_opaque	boss_port_dialog_port_accept_create();
Xextern Xv_opaque	boss_port_dialog_port_reset_create();
X
Xtypedef struct {
X	Xv_opaque	schedule_dialog;
X	Xv_opaque	schedule_control;
X	Xv_opaque	schedule_format;
X	Xv_opaque	appt_file;
X	Xv_opaque	schedule_accept;
X} boss_schedule_dialog_objects;
X
Xextern boss_schedule_dialog_objects	*boss_schedule_dialog_objects_initialize();
X
Xextern Xv_opaque	boss_schedule_dialog_schedule_dialog_create();
Xextern Xv_opaque	boss_schedule_dialog_schedule_control_create();
Xextern Xv_opaque	boss_schedule_dialog_schedule_format_create();
Xextern Xv_opaque	boss_schedule_dialog_appt_file_create();
Xextern Xv_opaque	boss_schedule_dialog_schedule_accept_create();
X#endif
END_OF_FILE
if test 5701 -ne `wc -c <'boss_ui.h'`; then
    echo shar: \"'boss_ui.h'\" unpacked with wrong size!
fi
# end of 'boss_ui.h'
fi
if test -f 'do_load.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'do_load.c'\"
else
echo shar: Extracting \"'do_load.c'\" \(5689 characters\)
sed "s/^X//" >'do_load.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_load		handle loading Casio data			*/
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#define		FROM_BOSS		0
X#define		FROM_CASIO_FILE		1
X#define		FROM_TEXT_FILE		2
X
XPUBLIC	boss_base_objects	*boss_base;
X
XPRIVATE	boss_load_dialog_objects	*dialog = NULL;
X
X/************************************************************************/
XEXPORT	Menu_item	load_dialog(item, op)
X
XMenu_item	item;
XMenu_generate	op;
X
X{
X	if (op == MENU_NOTIFY) {
X	   if (dialog == NULL) {
X	      dialog = boss_load_dialog_objects_initialize(NULL, boss_base->base);
X	      xv_set(dialog->casio_source,
X	                PANEL_VALUE, casio_file,
X	                PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
X	                PANEL_NOTIFY_STRING, "\n\r ",
X	                PANEL_INACTIVE, TRUE,
X	             NULL);
X	      xv_set(dialog->ascii_source,
X	                PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
X	                PANEL_NOTIFY_STRING, "\n\r ",
X	                PANEL_INACTIVE, TRUE,
X	             NULL);
X	      xv_set(dialog->source, PANEL_VALUE, 0, NULL);
X	      place_dialog(boss_base->base, dialog->load_dialog);
X	      }
X	   xv_set(dialog->load_dialog, XV_SHOW, TRUE, NULL);
X	   }
X	return item;
X}
X
X/************************************************************************/
XEXPORT	void	load_notify(item, value, event)
X
XPanel_item	item;
Xint		value;
XEvent		*event;
X
X{
X	if (value == 0) {
X	   xv_set(dialog->casio_source, PANEL_INACTIVE, TRUE, NULL);
X	   xv_set(dialog->ascii_source, PANEL_INACTIVE, TRUE, NULL);
X	   }
X	else if (value == 1) {
X	   xv_set(dialog->casio_source, PANEL_INACTIVE, FALSE, NULL);
X	   xv_set(dialog->ascii_source, PANEL_INACTIVE, TRUE, NULL);
X	   xv_set(dialog->load_control, PANEL_CARET_ITEM, dialog->casio_source, NULL);
X	   }
X	else {
X	   xv_set(dialog->casio_source, PANEL_INACTIVE, TRUE, NULL);
X	   xv_set(dialog->ascii_source, PANEL_INACTIVE, FALSE, NULL);
X	   xv_set(dialog->load_control, PANEL_CARET_ITEM, dialog->ascii_source, NULL);
X	   }
X}
X
X/************************************************************************/
XEXPORT	void	accept_load(item, event)
X
XPanel_item	item;
XEvent		*event;
X
X{	int	curr, len;
X	char	*p, buf[MAX_OBJECT_DATA], line[1024];
X	FILE	*f;
X	object	*o, *obj;
X
X	lets_get_busy(TRUE, NULL);
X	xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, 0);
X
X	if (((int) xv_get(dialog->source, PANEL_VALUE)) == FROM_BOSS) {
X	   if (open_casio(port_file, baud_rate, parity)) {
X	      while (obj = receive_object())
X	         add_to_list(obj);
X	      close_casio();
X	      xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, 0);
X	      }
X	   }
X	else if (((int) xv_get(dialog->source, PANEL_VALUE)) == FROM_CASIO_FILE) {
X	   p = (char *) xv_get(dialog->casio_source, PANEL_VALUE);
X	   if (*p == '\0')
X	      error("You must specify a Casio-format file to be read");
X	   else if (lex_init(p)) {
X	      parse_errors_occured = FALSE;
X	      yyparse();
X	      if (!parse_errors_occured) {
X	         for (obj = parsed_object_list; obj; ) {
X	            o = obj;
X	            obj = obj->next;
X	            add_to_list(o);
X	            }
X	         xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, 0);
X	         }
X	      }
X	   else
X	      error("Could not read from %s", p);
X	   }
X	else if (((int) xv_get(dialog->source, PANEL_VALUE)) == FROM_TEXT_FILE) {
X	   p = (char *) xv_get(dialog->ascii_source, PANEL_VALUE);
X	   if (*p == '\0')
X	      error("You must specify a ASCII-format file to be read");
X	   else if (f = fopen(p, "r")) {
X	      curr = 0;
X	      while (fgets(line, 512, f)) {
X	         if (curr + (len = strlen(line)) >= MAX_OBJECT_DATA) {
X	            add_to_list(text_to_object(buf));
X	            curr = 0;
X	            }
X	         while (len >= MAX_OBJECT_DATA) {
X	            strncpy(buf, line, MAX_OBJECT_DATA - 1);
X	            add_to_list(text_to_object(buf));
X	            strcpy(line, line + MAX_OBJECT_DATA - 1);
X	            len -= MAX_OBJECT_DATA - 1;
X	            }
X	         strcpy(buf + curr, line);
X	         curr += len;
X	         }
X	      if (curr > 0)
X	         add_to_list(text_to_object(buf));
X	      fclose(f);
X	      xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, 0);
X	      }
X	   else
X	      error("Could not read from %s", p);
X	   }
X	lets_get_busy(FALSE, NULL);
X}
END_OF_FILE
if test 5689 -ne `wc -c <'do_load.c'`; then
    echo shar: \"'do_load.c'\" unpacked with wrong size!
fi
# end of 'do_load.c'
fi
if test -f 'do_store.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'do_store.c'\"
else
echo shar: Extracting \"'do_store.c'\" \(5706 characters\)
sed "s/^X//" >'do_store.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_store	Handle storing Casio data			*/
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#define		TO_BOSS			0
X#define		TO_CASIO_FILE		1
X#define		TO_TEXT_FILE		2
X
XPUBLIC	boss_base_objects	*boss_base;
X
XPRIVATE	boss_store_dialog_objects	*dialog = NULL;
X
X/************************************************************************/
XEXPORT	Menu_item	store_dialog(item, op)
X
XMenu_item	item;
XMenu_generate	op;
X
X{
X	if (op == MENU_NOTIFY) {
X	   if (dialog == NULL) {
X	      dialog = boss_store_dialog_objects_initialize(NULL, boss_base->base);
X	      xv_set(dialog->casio_dest,
X	                PANEL_VALUE, casio_file,
X	                PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
X	                PANEL_NOTIFY_STRING, "\n\r ",
X	                PANEL_INACTIVE, TRUE,
X	             NULL);
X	      xv_set(dialog->ascii_dest,
X	                PANEL_NOTIFY_LEVEL, PANEL_SPECIFIED,
X	                PANEL_NOTIFY_STRING, "\n\r ",
X	                PANEL_INACTIVE, TRUE,
X	             NULL);
X	      xv_set(dialog->store_data, PANEL_VALUE, (1 << MAX_OBJECT_KINDS) - 1, NULL);
X	      xv_set(dialog->dest, PANEL_VALUE, 0, NULL);
X	      place_dialog(boss_base->base, dialog->store_dialog);
X	      }
X	   xv_set(dialog->store_dialog, XV_SHOW, TRUE, NULL);
X	   }
X	return item;
X}
X
X/************************************************************************/
XEXPORT	void	store_notify(item, value, event)
X
XPanel_item	item;
Xint		value;
XEvent		*event;
X
X{
X	if (value == 0) {
X	   xv_set(dialog->casio_dest, PANEL_INACTIVE, TRUE, NULL);
X	   xv_set(dialog->ascii_dest, PANEL_INACTIVE, TRUE, NULL);
X	   }
X	else if (value == 1) {
X	   xv_set(dialog->casio_dest, PANEL_INACTIVE, FALSE, NULL);
X	   xv_set(dialog->ascii_dest, PANEL_INACTIVE, TRUE, NULL);
X	   xv_set(dialog->store_control, PANEL_CARET_ITEM, dialog->casio_dest, NULL);
X	   }
X	else {
X	   xv_set(dialog->casio_dest, PANEL_INACTIVE, TRUE, NULL);
X	   xv_set(dialog->ascii_dest, PANEL_INACTIVE, FALSE, NULL);
X	   xv_set(dialog->store_control, PANEL_CARET_ITEM, dialog->ascii_dest, NULL);
X	   }
X}
X
X/************************************************************************/
XEXPORT	void	accept_store(item, event)
X
XPanel_item	item;
XEvent		*event;
X
X{	int	i, which;
X	FILE	*f;
X	object	*obj;
X	char	*path;
X
X	lets_get_busy(TRUE, NULL);
X	xv_set(item, PANEL_NOTIFY_STATUS, XV_ERROR, 0);
X
X	if ((which = (int) xv_get(dialog->store_data, PANEL_VALUE)) == 0)
X	   xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, 0);
X	else if (((int) xv_get(dialog->dest, PANEL_VALUE)) == TO_BOSS) {
X	   if (open_casio(port_file, baud_rate, parity)) {
X	      if (start_session()) {
X	         for (i = 0; i < MAX_OBJECT_KINDS; i++)
X	            if (which & (1 << i))
X	               for (obj = data[i]; obj; obj = obj->next)
X	                  if (!obj->from_casio)
X	                     if (!send_object(obj))
X	                        break;
X	         end_session();
X	         if (obj == NULL)
X	            xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, 0);
X	         }
X	      close_casio();
X	      }
X	   }
X	else if (((int) xv_get(dialog->dest, PANEL_VALUE)) == TO_CASIO_FILE) {
X	   path = (char *) xv_get(dialog->casio_dest, PANEL_VALUE);
X	   if (*path == '\0')
X	      error("You must specify a file to receive the Casio-format data");
X	   else if ((f = fopen(path, "w")) == NULL)
X	      error("cannot write to %s", path);
X	   else {
X	      for (i = 0; i < MAX_OBJECT_KINDS; i++)
X	         if (which & (1 << i))
X	            for (obj = data[i]; obj; obj = obj->next)
X	               print_object_internal(f, obj);
X	      fclose(f);
X	      xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, 0);
X	      }
X	   }
X	else if (((int) xv_get(dialog->dest, PANEL_VALUE)) == TO_TEXT_FILE) {
X	   path = (char *) xv_get(dialog->ascii_dest, PANEL_VALUE);
X	   if (*path == '\0')
X	      error("You must specify a file to receive the ASCII-format data");
X	   else if ((f = fopen(path, "w")) == NULL)
X	      error("cannot write to %s", path);
X	   else {
X	      for (i = 0; i < MAX_OBJECT_KINDS; i++)
X	         if (which & (1 << i))
X	            for (obj = data[i]; obj; obj = obj->next)
X	               print_object_ascii(f, obj);
X	      fclose(f);
X	      xv_set(item, PANEL_NOTIFY_STATUS, XV_OK, 0);
X	      }
X	   }
X	lets_get_busy(FALSE, NULL);
X}
END_OF_FILE
if test 5706 -ne `wc -c <'do_store.c'`; then
    echo shar: \"'do_store.c'\" unpacked with wrong size!
fi
# end of 'do_store.c'
fi
if test -f 'expand.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'expand.c'\"
else
echo shar: Extracting \"'expand.c'\" \(3210 characters\)
sed "s/^X//" >'expand.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#include	<sys/types.h>
X#include	<sys/dir.h>
X#include	<pwd.h>
X
X#include	"manifest.h"
X
XPUBLIC	char	*rindex(), *index();
X
X/************************************************************************/
XPRIVATE	char	*root_path(path)
X
Xchar	*path;
X
X{	char	*p;
X
X	if (p = rindex(path, '/'))
X	   if (p == path)
X	      p[1] = '\0';
X	   else
X	      *p = '\0';
X	else
X	   *path = '\0';
X	return(path);
X}
X
X/************************************************************************/
XPRIVATE	char	*last_node(path)
X
Xchar	*path;
X
X{	char	*p;
X
X	return((p = rindex(path, '/'))? p + 1 : path);
X}
X
X/************************************************************************/
XEXPORT	char	*expand_filename(path)
X
Xchar	*path;
X
X{	static	char	s[1024];
X	char	pattern[1024], candidate[1024], *p,*q;
X	DIR	*dir;
X	struct	direct *dp;
X	struct	passwd	*pw;
X
X	strcpy(s, path);
X	if (*path == '~')
X	   if (path[1] == '/' || path[1] == '\0') {
X	      strcpy(s, getenv("HOME"));
X	      strcat(s, path + 1);
X	      }
X	   else {
X	      if ((p = index(path, '/')) != NULL)
X	         *p = '\0';
X	      if ((pw = getpwnam(path + 1)) != NULL) {
X	         strcpy(s, pw->pw_dir);
X	         if (p != NULL) {
X	            strcat(s, "/");
X	            strcat(s, p + 1);
X	            }
X	         }
X	      else
X	         return(NULL);
X	      }
X	strcpy(pattern, last_node(s));
X	if (*pattern == '\0')
X	   return(s);
X	root_path(s);
X	candidate[0] = '\0';
X	if (*s == '\0')
X	   strcpy(s, ".");
X	if ((dir = opendir(s)) == NULL) {
X	   strcpy(s, path);
X	   return(s);
X	   }
X	while ((dp = readdir(dir)) != NULL)
X	   if (strncmp(dp->d_name, pattern, strlen(pattern)) == 0)
X	      if (*candidate == '\0')
X	         strcpy(candidate, dp->d_name);
X	      else {
X	         for (p = candidate, q = dp->d_name; *p == *q; p++, q++)
X	            ;
X	         *p = '\0';
X	         }
X	closedir(dir);
X	if (*candidate == '\0')
X	   return(NULL);
X	else {
X	   if (strcmp(s, ".") == 0)
X	      *s = '\0';
X	   else if (s[strlen(s) - 1] != '/')
X	      strcat(s, "/");
X	   strcat(s, candidate);
X	   }
X	return(s);
X}
END_OF_FILE
if test 3210 -ne `wc -c <'expand.c'`; then
    echo shar: \"'expand.c'\" unpacked with wrong size!
fi
# end of 'expand.c'
fi
if test -f 'misc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'misc.c'\"
else
echo shar: Extracting \"'misc.c'\" \(5180 characters\)
sed "s/^X//" >'misc.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/*	misc.c		miscellaneous support and conversion routines	*/
X/*									*/
X/************************************************************************/
X
X#include	<stdio.h>
X#include	<ctype.h>
X
X#include	<sys/termios.h>
X
X#include	"manifest.h"
X
X#define		value_of(p)		((*(p) - '0') * 10 + (*((p) + 1) - '0'))
X
X/************************************************************************/
XEXPORT	ascii_to_time(buf, start, stop)
X
Xbyte	*buf;
Xtime	*start;
Xtime	*stop;
X
X{
X	start->hour = value_of(buf);
X	start->minute = value_of(buf + 3);
X	if (stop)
X	   if (*(buf + 5) == '~') {
X	      stop->hour = value_of(buf + 6);
X	      stop->minute = value_of(buf + 9);
X	      }
X	   else
X	      stop->hour = stop->minute = INVALID_TIME;
X}
X
X/************************************************************************/
XEXPORT	time_to_ascii(start, stop, buf)
X
Xtime	*start;
Xtime	*stop;
Xbyte	*buf;
X
X{
X	sprintf(buf, "%02d:%02d", start->hour, start->minute);
X	if (stop && stop->hour != INVALID_TIME)
X	   sprintf(buf + 5, "~%02d:%02d", stop->hour, stop->minute);
X}
X
X/************************************************************************/
XEXPORT	ascii_to_date(buf, d)
X
Xbyte	*buf;
Xdate	*d;
X
X{
X	d->year = value_of(buf) * 100 + value_of(buf + 2);
X	d->month = value_of(buf + 5);
X	d->day = value_of(buf + 8);
X}
X
X/************************************************************************/
XEXPORT	date_to_ascii(d, buf)
X
Xdate	*d;
Xbyte	*buf;
X
X{
X	sprintf(buf, "%04d-%02d-%02d", d->year, d->month, d->day);
X}
X
X/************************************************************************/
XEXPORT	long	ascii_to_long(buf)
X
Xbyte	*buf;
X
X{
X	return(*((long *) buf));
X}
X
X/************************************************************************/
XEXPORT	long_to_ascii(val, buf)
X
Xlong	val;
Xbyte	*buf;
X
X{
X	*((long *) buf) = val;
X}
X
X#define		SIZE_INCREMENT		8
X
X/************************************************************************/
XEXPORT	char	**tokenize(line, argc)
X
Xchar	*line;
Xint	*argc;
X
X{	char	match, **argv, *buf, *p;
X	int	limit;
X
X	buf = (char *) malloc(strlen(line) + 1);
X	*argc = 0;
X	argv = (char **) malloc((limit = SIZE_INCREMENT) * sizeof(char *));
X	while (*line) {
X	   while (isspace(*line))
X	      line++;
X	   switch (*line) {
X	      case '"'  :
X	      case '\'' : match = *line++; /* remove the quote mark */
X	      		  for (p = buf; *line && (*line != match); ) {
X	      		     if (*line == '\\')
X	      		        line++;
X	      		     if (*line)
X	      		        *p++ = *line++;
X	      		     }
X	      		  if (*line)
X	      		     line++; /* wipe out quote mark */
X	      		  break;
X	      default   : for (p = buf; *line && !isspace(*line) && (*line != '"') && (*line != '\''); )
X	      		     *p++ = *line++;
X	      		  break;
X	      }
X	   *p = '\0';
X	   if (*buf) {
X	      argv[(*argc)++] = strsave(buf);
X	      if (*argc == limit)
X	         argv = (char **) realloc(argv, (limit += SIZE_INCREMENT) * sizeof(char *));
X	      }
X	   }
X	free(buf);
X	argv[*argc] = (char *) 0;
X	return(argv);
X}
X
X/************************************************************************/
XEXPORT	lower(p)
X
Xchar	*p;
X
X{
X	for ( ; *p; p++)
X	   if (isupper(*p))
X	      *p = tolower(*p);
X}
X
X/************************************************************************/
XPRIVATE	delarg(argc, argv)
X
Xint	*argc;
Xchar	**argv;
X
X{	char	*p;
X
X	while (*argv = *(argv+1))
X	   argv++;
X	(*argc)--;
X}
X
X/************************************************************************/
XEXPORT	char	getopt(argc, argv, opts, parm)
X
Xint	*argc;
Xchar	**argv;
Xchar	*opts;
Xchar	**parm;
X
X{	char	c, *p, *index();
X	int	killed;
X
X	*parm = NULL;
X	while (*argv && ((**argv != '-') || (*(*argv+1) == '\0')))
X	   argv++;
X	if (*argv == NULL)
X	   return(EOF);
X	c = *(*argv+1);
X	*++(*argv) = '-';
X	if (killed = (*(*argv+1) == '\0'))
X	   delarg(argc, argv);
X	if ((p = index(opts, c)) == NULL)
X	   c = '\0';
X	else if (*(p+1) == ':') {
X	   *parm = killed ? *argv : *argv+1;
X	   delarg(argc, argv);
X	   }
X	return(c);
X}
END_OF_FILE
if test 5180 -ne `wc -c <'misc.c'`; then
    echo shar: \"'misc.c'\" unpacked with wrong size!
fi
# end of 'misc.c'
fi
if test -f 'record.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'record.c'\"
else
echo shar: Extracting \"'record.c'\" \(4022 characters\)
sed "s/^X//" >'record.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/*	record.c	handles converting records to/from packets	*/
X/*									*/
X/************************************************************************/
X
X#include	"manifest.h"
X#include	"packet.h"
X#include	"record.h"
X
X/************************************************************************/
XEXPORT	record	*create_record()
X
X{	record	*rec;
X
X	rec = (record *) malloc(sizeof(record));
X	bzero(rec, sizeof(record));
X	return(rec);
X}
X
X/************************************************************************/
XEXPORT	free_record(rec)
X
Xrecord	*rec;
X
X{
X	free(rec);
X}
X
X/************************************************************************/
XEXPORT	record	*make_mode_record(mode)
X
Xword	mode;
X
X{	record	*rec;
X
X	rec = create_record();
X	rec->type = REC_MODE;
X	rec->address = 0;
X	rec->length = 2;
X	*((word *) rec->data) = mode;
X	return(rec);
X}
X
X/************************************************************************/
XEXPORT	record	*make_date_record(d)
X
Xdate	*d;
X
X{	record	*rec;
X
X	rec = create_record();
X	rec->type = REC_DATA;
X	rec->address = REC_DATA_DATE;
X	date_to_ascii(d, rec->data);
X	rec->length = strlen(rec->data);
X	return(rec);
X}
X
X/************************************************************************/
XEXPORT	record	*make_time_record(addr, start, stop)
X
Xword	addr;
Xtime	*start;
Xtime	*stop;
X
X{	record	*rec;
X
X	rec = create_record();
X	rec->type = REC_DATA;
X	rec->address = addr;
X	time_to_ascii(start, stop, rec->data);
X	rec->length = strlen(rec->data);
X	return(rec);
X}
X
X/************************************************************************/
XEXPORT	send_record(rec)
X
Xrecord	*rec;
X
X{
X	for ( ; rec; rec = rec->next)
X	   if (!send_packet(rec))
X	      return(FALSE);
X	return(TRUE);
X}
X
X/************************************************************************/
XEXPORT	record	*receive_record()
X
X{	record	*head, *rec;
X	static	word	last_mode = REC_MODE_INVALID;
X
X	head = rec = create_record();
X	if (!receive_packet(head))
X	   return(NULL);
X	if (head->type == REC_EXIT) {
X	   free_record(head);
X	   return(NULL);
X	   }
X	else if (head->type == REC_MODE)
X	   last_mode = *((word *) head->data);
X	else {
X	   if (last_mode != REC_MODE_INVALID) {
X	      rec = make_mode_record(last_mode);
X	      rec->next = head;
X	      head = rec;
X	      rec = head->next;
X	      }
X	   else
X	      error("no mode specified in receive_record");
X	   }
X	while (TRUE) {
X	   rec->next = create_record();
X	   rec = rec->next;
X	   if (!receive_packet(rec)) {
X	      error("premature end of packet sequence in receive_record");
X	      return(NULL);
X	      }
X	   else if (rec->type == REC_REGISTER)
X	      break;
X	   else if (rec->type != REC_DATA) {
X	      error("invalid record encountered (%02x) in receive_record", rec->type);
X	      return(NULL);
X	      }
X	   }
X	return(head);
X}
END_OF_FILE
if test 4022 -ne `wc -c <'record.c'`; then
    echo shar: \"'record.c'\" unpacked with wrong size!
fi
# end of 'record.c'
fi
if test -f 'window_misc.c' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'window_misc.c'\"
else
echo shar: Extracting \"'window_misc.c'\" \(5177 characters\)
sed "s/^X//" >'window_misc.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/*	window_misc.c	miscellaneous window management functions	*/
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	<xview/notice.h>
X
X#include	"boss_ui.h"
X
X#include	"manifest.h"
X
XPUBLIC	boss_base_objects	*boss_base;
X
X/************************************************************************/
XEXPORT	error(a, b, c, d, e, f)
X
Xchar	*a, *b, *c, *d, *e, *f;
X
X{	char	buf[512];
X
X	sprintf(buf, a, b, c, d, e, f);
X	notice_prompt(boss_base->base, NULL,
X		         NOTICE_MESSAGE_STRINGS, buf, 0,
X		         NOTICE_BUTTON_YES, "OK",
X		      0);
X}
X
X/************************************************************************/
XEXPORT	void	pinned_menu_notify(menu, item)
X
XMenu		menu;
XMenu_item	item;
X
X{	Xv_opaque	pin_window	 = (Xv_opaque) xv_get(menu, MENU_PIN_WINDOW);
X	void		(*menu_notify)() = (void (*)()) xv_get(menu, MENU_GEN_PROC);
X	void		(*item_notify)() = (void (*)()) xv_get(item, MENU_GEN_PROC);
X	
X	if (pin_window && xv_get(pin_window, XV_SHOW)) {
X	   if (menu_notify)
X	      (*menu_notify)(menu, MENU_NOTIFY);
X	   if (item_notify)
X	      (*item_notify)(item, MENU_NOTIFY);
X	   if (item_notify)
X	      (*item_notify)(item, MENU_NOTIFY_DONE);
X	   if (menu_notify)
X	      (*menu_notify)(menu, MENU_NOTIFY_DONE);
X	}
X}
X
X/************************************************************************/
XEXPORT	Panel_setting	filename_completion(item, event)
X
XPanel_item	item;
XEvent		*event;
X
X{	char	*p, *expand_filename();
X
X	switch (event_action(event)) {
X	   case '\n' :
X	   case '\r' :
X	   case ' '  : if ((p = expand_filename((char *) xv_get(item, PANEL_VALUE))) == NULL)
X	   		  window_bell(xv_get(item, XV_OWNER));
X	   	       else
X	   	          xv_set(item, PANEL_VALUE, p, 0);
X	   	       return(PANEL_NONE);
X	   case '\t' : return(event_shift_is_down(event)? PANEL_PREVIOUS : PANEL_NEXT);
X	   default   : return(panel_text_notify(item, event));
X	   }
X}
X
X/************************************************************************/
XEXPORT	void	place_dialog(base, dialog)
X
XXv_opaque	base;
XXv_opaque	dialog;
X
X{	Rect	br, dr, sr;
X
X	sr = *((Rect *) xv_get(base, WIN_SCREEN_RECT));
X	frame_get_rect(base, &br);
X	frame_get_rect(dialog, &dr);
X	if (rect_right(&br) + dr.r_width < sr.r_width) {
X	   dr.r_left = rect_right(&br);
X	   dr.r_top = br.r_top;
X	   }
X	else if (dr.r_width <= br.r_left) {
X	   dr.r_left = br.r_left - dr.r_width;
X	   dr.r_top = br.r_top;
X	   }
X	else {
X	   dr.r_left = br.r_left + 32;
X	   dr.r_top = br.r_top + 32;
X	   }
X	frame_set_rect(dialog, &dr);
X}
X
X/************************************************************************/
XEXPORT	int	list_count(item)
X
XPanel_item	item;
X
X{	int	i, count, rows;
X
X	rows = (int) xv_get(item, PANEL_LIST_NROWS);
X	for (i = count = 0; i < rows; i++)
X	   if (xv_get(item, PANEL_LIST_SELECTED, i))
X	      count++;
X	return(count);
X}
X
X/************************************************************************/
XEXPORT	empty_list(item)
X
XPanel_item	item;
X
X{	int	row;
X
X	row = (int) xv_get(item, PANEL_LIST_NROWS);
X	for ( ; row > 0; row--)
X	   xv_set(item, PANEL_LIST_DELETE, row - 1, NULL);
X}
X
X/************************************************************************/
XPRIVATE	set_busy(busy, skip)
X
Xint	busy;
XFrame	skip;
X
X{	Frame	subframe;
X	int	i;
X
X	for (i = 1; subframe = (Frame) xv_get(boss_base->base, FRAME_NTH_SUBFRAME, i); i++)
X	   if (subframe != skip)
X	      if (xv_get(subframe, XV_SHOW))
X	         xv_set(subframe, FRAME_BUSY, busy, NULL);
X	xv_set(boss_base->base, FRAME_BUSY, busy, NULL);
X}
X
X/************************************************************************/
XEXPORT	lets_get_busy(busy, skip)
X
Xint	busy;
XFrame	skip;
X
X{	static	int	depth = 0;
X
X	if (busy) {
X	   if (depth == 0)
X	      set_busy(TRUE, skip);
X	   depth++;
X	   }
X	else if (depth > 0)
X	   if (--depth == 0)
X	      set_busy(FALSE, NULL);
X}
END_OF_FILE
if test 5177 -ne `wc -c <'window_misc.c'`; then
    echo shar: \"'window_misc.c'\" unpacked with wrong size!
fi
# end of 'window_misc.c'
fi
echo shar: End of archive 2 \(of 6\).
cp /dev/null ark2isdone
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 at 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



More information about the Comp.sources.sun mailing list