[alt.sources] ecu - SCO XENIX V/{2,3}86 Extended CU part 31/47

wht@tridom.uucp (Warren Tucker) (10/12/89)

---- Cut Here and unpack ----
#!/bin/sh
# this is part 31 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file sea/ecusea.c continued
#
CurArch=31
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file sea/ecusea.c"
sed 's/^X//' << 'SHAR_EOF' >> sea/ecusea.c
X	{				/* if we really got anything */
X		fclose(fp);
X		unlink(outname);		/* rename temp to proper name */
X		for(onp = outname;cnvrt && *onp;onp++)
X			/* find out if there's lower- */
X			if(islower(*onp))	/* case letters filename */
X				cnvrt = 0;	/*  there are, don't convert */
X		if(cnvrt)			/* if there aren't, make all */
X			for(onp = outname;*onp;onp++)	/* into uppercase */
X				*onp = tolower(*onp);
X		if(link(tmpname,outname) == 0)
X			unlink(tmpname);
X		if(blk0.secs_since_1980)		/* set stamp, if known */
X			set_utime_1980(outname,blk0.secs_since_1980);
X		return(outname);
X	}
X	else 
X	{				/* else no real file */
X		fclose(fp);
X		unlink(tmpname);		/* discard empty file */
X		report_str("end of transfer",0);
X		rf_done = 1;
X		return(NULL);
X	}
X
XCANCEL_TRANSFER:
X	fclose(fp);
X	xmit_cancel();
X	rf_done = 2;
X	return(NULL);
X}	/* end of receive_file */
X
X/*+-------------------------------------------------------------------------
X	cancel_transaction(sig)
X--------------------------------------------------------------------------*/
Xcancel_transaction(sig)
Xint sig;
X{
X	xmit_cancel();
X	sprintf(s128,"signal %d ... exiting",sig);
X	report_str(s128,1);
X/*
X	report_rx_ind(0);
X	report_tx_ind(0);
X*/
X	report_uninit();
X	if(sig == SIGQUIT)
X		abort();
X	exit(128+sig);
X}	/* end of cancel_transaction */
X
X/*+-------------------------------------------------------------------------
X	main(argc,argv,envp)
X--------------------------------------------------------------------------*/
Xmain(argc,argv,envp)
Xint argc;
Xchar **argv;
Xchar **envp;
X{
Xint ipaths;
Xint ok;
X#define MAX_PATHS 512
Xchar *paths[MAX_PATHS];
Xchar **ppaths = paths;
Xchar *cptr;
Xchar **gargv = argv;
Xint gargc = argc;
X
X	while(--argc)
X	{
X		cptr = *++argv;
X		if(*cptr == '-')
X		{
X			cptr++;
X			switch(*cptr++)
X			{
X			case ',':
X				log_packets = 1;
X				break;
X			case '/':
X				if(--argc < 1)
X					exit(255);
X				strcpy(curr_dir,*++argv);
X				break;
X			case '.':
X				if(--argc < 1)
X					exit(255);
X				iofd = atoi(*++argv);
X				break;
X			case 'r':
X				sending_flag = 0;
X				break;
X			case 's':
X				sending_flag = 1;
X			}
X		}
X		else if(argc > 0)
X		{
X			if(npaths < MAX_PATHS)
X			{
X				*ppaths++ = cptr;
X				npaths++;
X			}
X			else
X			{
X				printf("too many filenames to send\n");
X				exit(255);
X			}
X		}
X	}
X
X	if(sending_flag == -1)
X	{
X		printf("no -r or -s\n");
X		exit(255);
X	}
X
X	if((npaths < 1) && sending_flag)
X		exit(253);
X
X	if(npaths && !sending_flag)
X		exit(255);
X
X	if(log_packets)
X	{
X	char log_packets_name[64];
X	FILE *ftmp;
X	int iargv;
X		sprintf(log_packets_name,"/tmp/sea%05d.plog",getpid());
X		unlink(log_packets_name);
X		ftmp = fopen(log_packets_name,"w");
X		fclose(ftmp);
X		log_packets = open(log_packets_name,O_WRONLY,0644);
X		if(log_packets < 0)
X			log_packets = 0;
X		else
X		{
X			write(log_packets,"exec: ",6);
X			for(iargv = 0; iargv < gargc; iargv++)
X			{
X				write(log_packets,gargv[iargv],strlen(gargv[iargv]));
X				write(log_packets," ",1);
X			}
X			write(log_packets,"\n",1);
X		}
X	}
X
X	sprintf(s128,"ecusea %s",revision);
X	report_init(s128);
X	signal(SIGHUP,cancel_transaction);
X	signal(SIGQUIT,cancel_transaction);
X	signal(SIGINT,cancel_transaction);
X	signal(SIGTERM,cancel_transaction);
X
X	ioctl(iofd,TCGETA,&tio);
X
X	tio.c_oflag = 0;
X	tio.c_cflag &= ~PARENB;
X	tio.c_cflag &= ~CSIZE;
X	tio.c_cflag |= CS8;
X
X	ioctl(iofd,TCSETA,&tio);
X
X	switch(sending_flag)
X	{
X		case 0:				/* receive files */
X			while(receive_file() != NULL)
X				nap(1000L);
X			ok = (rf_done == 1);
X			break;
X
X		case 1:				/* send files */
X			ipaths = 0;
X			while(ipaths < npaths)
X			{
X				if(!(ok = send_file(paths[ipaths])))
X					break;
X				nap(1000L);
X				ipaths++;
X			}
X			if(ok)		/* no errors, send end marker */
X				send_file("");
X			break;
X	}
X
X	report_uninit();
X	exit(ok ? 0 : 254);	/* and return error status */
X
X}	/* end of main */
X
SHAR_EOF
echo "File sea/ecusea.c is complete"
chmod 0644 sea/ecusea.c || echo "restore of sea/ecusea.c fails"
echo "x - extracting sea/scurses.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > sea/scurses.c &&
X/* CHK=0x804E */
X/*+-------------------------------------------------------------------------
X	scurses.c -- ecu file transfer program curses interface
X
X  000000000011111111112222222222333333333344444444445555555550
X  012345678901234567890123456789012345678901234567890123456789
X00.----------------------------------------------------------.
X01|  SEAlink_6____  _39____________________________________  |
X02|  File ### of ###: _38__________________________________  |
X03|  File position:  _8______ length: _8______               |
X04|  _55____________________________________________________ | transaction
X05|  _55____________________________________________________ | last rx/tx hdr
X06|  Comm I/O: rx _8______  tx _8______ bytes                |
X07|  Baud rate: _5___ BINARY blklen: _____ comm mode: CBREAK |
X08|  Time started: session: HH:MM:SS  this file: HH:MM:SS    |
X09|                elpased: HH:MM:SS       time: HH:MM:SS    |
X10|  Error counts: this file:  _4__  total: _6____           |
X11|  _55____________________________________________________ |  err str
X12|  _55____________________________________________________ |  comment str
X13|  _55____________________________________________________ |  remote info
X14`----------------------------------------------------------'
X
X  Defined functions:
X	clear_area(win,row,col,len)
X	clear_area_char(win,row,col,len,fillchar)
X	get_elapsed_time(elapsed_seconds)
X	get_tod(type,tod)
X	report_comm_baud_rate(baud_rate)
X	report_error_count()
X	report_file_byte_io(count)
X	report_file_close()
X	report_file_open_length(length)
X	report_file_open_mode(file_mode)
X	report_file_open_tod()
X	report_file_rcv_started(filename,length,last_mod_time,file_mode)
X	report_file_send_open(filename,filestat)
X	report_init(title)
X	report_last_rxhdr(rptstr,error_flag)
X	report_last_txhdr(rptstr,error_flag)
X	report_mode(mode)
X	report_protocol_crc_type(str)
X	report_protocol_type(str)
X	report_rx_ind(status)
X	report_rx_tx_count()
X	report_rxblklen(blklen)
X	report_rxpos(rxpos)
X	report_str(rptstr,error_flag)
X	report_top_line(topstr)
X	report_transaction(str)
X	report_tx_ind(status)
X	report_txblklen(blklen)
X	report_txpos(txpos)
X	report_uninit(sig)
X	report_xfer_mode(str)
X
X------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-03-1989-22:58-wht------------- ecu 2.00 ---------------- */
X/*:03-03-1987-19:47-wht-adapt zcurses.c */
X
X#include <curses.h>
X#include <sys/types.h>
X#include <sys/stat.h>
X#include <ctype.h>
X#include <signal.h>
X#include <time.h>
X#include <sys/timeb.h>
X
X#include "../pc_scr.h"
X#include "lint_args.h"
X
Xlong time();
Xextern char *tzname[];
Xstruct tm *localtime();
X
X
X#define WIN_LINES	15
X#define WIN_COLS	60
X#define WIN_TOPY	2
X#define WIN_LEFTX	8
X
Xextern char curr_dir[];
Xextern char s128[];
Xextern int Filcnt;
Xextern int Restricted;
Xextern int sending_flag;	/* send == 1, receive == 0 */
Xextern int npaths;
Xextern long rxpos;
Xextern int log_packets;
X
XWINDOW	*win;
Xint (*original_sigint_handler)();
Xint (*original_sigquit_handler)();
Xint (*original_sigterm_handler)();
Xint curses_installed = 0;		/* curses not yet active */
Xint this_file_errors;
Xint total_errors;
Xlong current_seconds;
Xlong start_seconds;
Xlong elapsed_seconds;
Xunsigned long total_data_chars_xfered = 0L;
X
Xchar *win_template[] =
X{
X/*00000000001111111111222222222233333333334444444444555555555 */
X/*01234567890123456789012345678901234567890123456789012345678 */
X/*.----------------------------------------------------------. */
X  "  SEAlink                                                 ",	/* 1 */
X  "  File ### of ###: _____________________________________  ",	/* 2 */
X  "  File position:  ________ length: ________               ",	/* 3 */
X  "                                                          ",	/* 4 */
X  "  tx: ______________________  rx: ______________________  ",	/* 5 */
X  "  Comm I/O: rx ________  tx ________ bytes                ",	/* 6 */
X  "  Baud rate: _____ BINARY blklen: 128   comm mode: ______ ",	/* 7 */
X  "  Time started: session: --:--:--  this file: --:--:--    ",	/* 8 */
X  "                elapsed: --:--:--    current: --:--:--    ",	/* 9 */
X  "  Error counts: this file:  ____  total: ______           ",	/* 10 */
X  "                                                          ",	/* 11 */
X  "                                                          ",	/* 12 */
X  "                                                          ",	/* 13 */
X/*`----------------------------------------------------------' */
X(char *)0
X};
X
X/*+-----------------------------------------------------------------------
X	char *get_elapsed_time(elapsed_seconds)
X	hh:mm:ss returned
X  static string address is returned
X------------------------------------------------------------------------*/
Xchar *get_elapsed_time(elapsed_seconds)
Xlong elapsed_seconds;
X{
X	static char elapsed_time_str[10];
X	long hh,mm,ss;
X
X	hh = elapsed_seconds / 3600;
X	elapsed_seconds -= hh * 3600;
X	mm = elapsed_seconds / 60L;
X	elapsed_seconds -= mm * 60L;
X	ss = elapsed_seconds;
X
X	sprintf(elapsed_time_str,"%02ld:%02ld:%02ld",hh,mm,ss);
X	return(elapsed_time_str);
X}	/* end of get_elapsed_time */
X
X/*+-----------------------------------------------------------------------
X	char *get_tod(type,tod)
X
X  time of day types:
X	0		hh:mm
X	1		hh:mm:ss
X	2		mm-dd-yyyy hh:mm
X
X  static string address is returned
X  if tod != (char *)0, time is returned there too
X------------------------------------------------------------------------*/
Xchar *
Xget_tod(type,tod)
Xint type;
Xchar *tod;
X{
X	long cur_time = 0;
X	struct tm *lt;			/* local time */
X	static char tod_str[32];
X	struct timeb tp;
X
X	cur_time = time((long *)0);
X	lt = localtime(&cur_time);
X#if defined(M_XENIX) && defined(MESSED_UP_DST)
X	ftime(&tp);				/* localtime() does not know about DST */
X	if(tp.dstflag)			/* so we adjust with ftime, which does know */
X	{
X		cur_time += 3600L;	/* problem in BSD too, but no ftime there */
X		lt = localtime(&cur_time);
X		cur_time -= 3600L;
X	}
X#endif
X
X	switch(type)
X	{
X	case 0:
X		sprintf(tod_str,"%02d:%02d",lt->tm_hour,lt->tm_min);
X		break;
X
X	default:
X	case 1:
X		sprintf(tod_str,"%02d:%02d:%02d",lt->tm_hour,lt->tm_min,lt->tm_sec);
X		break;
X
X	case 2:
X		sprintf(tod_str,"%02d-%02d-%04d %02d:%02d",
X		    lt->tm_mon + 1,lt->tm_mday,lt->tm_year + 1900,
X		    lt->tm_hour,lt->tm_min);
X		break;
X	}
X
X	if(tod != (char *)0)
X		strcpy(tod,tod_str);
X
X	return(tod_str);
X}	/* end of get_tod */
X
X/*+-------------------------------------------------------------------------
X	clear_area(win,row,col,len)
X--------------------------------------------------------------------------*/
Xclear_area(win,row,col,len)
XWINDOW	*win;
Xint row;
Xint col;
Xint len;
X{
X	wmove(win,row,col);
X	while(len-- > 0)
X		waddch(win,' ');
X	wmove(win,row,col);
X
X}	/* end of clear_area */
X
X/*+-------------------------------------------------------------------------
X	clear_area_char(win,row,col,len,fillchar)
X--------------------------------------------------------------------------*/
Xclear_area_char(win,row,col,len,fillchar)
XWINDOW	*win;
Xint row;
Xint col;
Xint len;
Xchar fillchar;
X{
X	wmove(win,row,col);
X	while(len-- > 0)
X		waddch(win,fillchar);
X	wmove(win,row,col);
X
X}	/* end of clear_area_char */
X
X/*+-------------------------------------------------------------------------
X	report_top_line(topstr)
X   top line: row 1 col 18 length 39
X--------------------------------------------------------------------------*/
Xvoid
Xreport_top_line(topstr)
Xchar *topstr;
X{
Xchar s42[42];
X	clear_area(win,1,18,39);
X	if(strlen(topstr) < 39)
X		waddstr(win,topstr);
X	else
X	{
X		strncpy(s42,topstr,39);
X		s42[39] = 0;
X		waddstr(win,s42);
X	}
X}	/* end of report_top_line */
X
X/*+-------------------------------------------------------------------------
X	report_protocol_crc_type(str)
X
X  protocol crc type:  row 1 col 10 length 6
X--------------------------------------------------------------------------*/
Xreport_protocol_crc_type(str)
Xregister char *str;
X{
Xchar s8[8];
X
X	if(strlen(str) > 6)
X	{
X		strncpy(s8,str,6);
X		s8[6] = 0;
X		str = s8;
X	}
X	clear_area(win,1,10,6);
X	waddstr(win,str);
X	wrefresh(win);
X	if(log_packets)
X	{
X		write(log_packets,"chk:  ",6);
X		write(log_packets,str,strlen(str));
X		write(log_packets,"\n",1);
X	}
X
X}	/* end of report_protocol_crc_type */
X
X/*+-------------------------------------------------------------------------
X	report_uninit()
X--------------------------------------------------------------------------*/
Xvoid
Xreport_uninit()
X{
Xfloat total = (float)total_data_chars_xfered;
X
X	if(curses_installed)
X	{
X		if((total_data_chars_xfered != 0L) && (elapsed_seconds != 0L))
X		{
X			sprintf(s128,"Data xfer rate ~= %6.0f chars/sec",
X			    total / (float)elapsed_seconds);
X			if(log_packets)
X			{
X				write(log_packets,"info: ",6);
X				write(log_packets,s128,strlen(s128));
X				write(log_packets,"\n",1);
X			}
X			report_top_line(s128);
X		}
X		report_file_byte_io(0L);
X		report_rx_tx_count();
X		wmove(win,WIN_LINES - 1,WIN_COLS - 1);
X		wrefresh(win);
X		endwin();
X		fprintf(stderr,"\r\n\r\n\r\n");
X		fflush(stderr);
X		curses_installed = 0;
X	}
X
X}	/* end of report_uninit */
X
X/*+-------------------------------------------------------------------------
X	report_init(title)
X--------------------------------------------------------------------------*/
Xvoid
Xreport_init(title)
Xchar *title;
X{
Xregister int itmp;
Xregister char *cptr;
Xchar buf[48];
X
X	if(curses_installed)
X		return;
X
X	initscr();
X	crmode();
X	noecho();
X	nonl();
X	clear();
X	curses_installed = 1;
X	win = newwin(WIN_LINES,WIN_COLS,WIN_TOPY,WIN_LEFTX);
X	box(win,sVR,sHR);
X	wmove(win,0,0); waddch(win,sTL);
X	wmove(win,win->_maxy - 1,0); waddch(win,sBL);
X	wmove(win,win->_maxy - 1,win->_maxx - 1); waddch(win,sBR);
X	wmove(win,0,win->_maxx - 1); waddch(win,sTR);
X	wmove(win,0,3);
X	waddch(win,' ');
X	waddstr(win,title);
X	waddch(win,' ');
X	waddch(win,sHR);
X	waddch(win,sHR);
X	waddstr(win," dir: ");
X	waddstr(win,curr_dir);
X	waddch(win,' ');
X
X	itmp = 0;
X	while(1)
X	{
X		if(win_template[itmp] == (char *)0)
X			break;
X		wmove(win,itmp + 1,1);
X		waddstr(win,win_template[itmp++]);
X	}
X	if(sending_flag)
X	{
X		clear_area(win,2,15,3);
X		sprintf(s128,"%3d",npaths);
X		waddstr(win,s128);
X#if defined(FORK_DEBUG)
X		sprintf(s128,"ecusz pid %d",getpid());
X#endif
X	}
X	else	/* ecurz */
X	{
X		clear_area(win,2,11,8);	/* clear "of ###" */
X		waddstr(win,":");
X#if defined(FORK_DEBUG)
X		sprintf(s128,"ecurz pid %d",getpid());
X#endif
X	}
X
X#if defined(FORK_DEBUG)
X	ecu_log_event(s128);
X#endif
X
X	clear_area(win,1,11,47);
X	report_error_count();
X	clear_area(win,8,26,8);		/* starting time */
X	waddstr(win,get_tod(1,(char *)0));
X	start_seconds = time((long *)0);
X	current_seconds = start_seconds;
X
X	wrefresh(win);
X
X}	/* end of report_init */
X
X/*+-------------------------------------------------------------------------
X	report_rx_ind(status)
X--------------------------------------------------------------------------*/
Xvoid
Xreport_rx_ind(status)
Xint status;
X{
X	wmove(win,1,54);
X	waddch(win,(status) ? 'R' : ' ');
X	wmove(win,1,54);
X	wrefresh(win);
X}	/* end of report_rx_ind */
X
X/*+-------------------------------------------------------------------------
X	report_tx_ind(status)
X--------------------------------------------------------------------------*/
Xvoid
Xreport_tx_ind(status)
Xint status;
X{
X	wmove(win,1,56);
X	waddch(win,(status) ? 'T' : ' ');
X	wmove(win,1,56);
X	wrefresh(win);
X}	/* end of report_tx_ind */
X
X/*+-------------------------------------------------------------------------
X	report_rx_tx_count()
X
X  rx char count: row 6 col 16 length 8 unsigned long
X  tx char count: row 6 col 29 length 8 unsigned long
X  now time of day: row 1 col 50 length 8 hh:mm:ss
X  This procedure may be counted upon to perform wrefresh(win)
X
Xelapsed time row 9 col 26 length 8
Xcurrent tod row 9 col 47 length 8
X--------------------------------------------------------------------------*/
Xreport_rx_tx_count()
X{
X	extern unsigned long rx_char_count;
X	extern unsigned long tx_char_count;
X
X	register char *cptr;
X
X	sprintf(s128,"%8ld",rx_char_count);
X	wmove(win,6,16);
X	waddstr(win,s128);
X	sprintf(s128,"%8ld",tx_char_count);
X	wmove(win,6,29);
X	waddstr(win,s128);
X
X	/* now time of day */
X	clear_area(win,9,47,8);
X	cptr = get_tod(1,(char *)0);
X	waddstr(win,cptr);
X	current_seconds = time((long *)0);
X	elapsed_seconds = current_seconds - start_seconds;
X	cptr = get_elapsed_time(elapsed_seconds);
X	clear_area(win,9,26,8);
X	waddstr(win,cptr);
X	wrefresh(win);		/* calling procs expect this to occur always */
X
X}	/* end of report_rx_tx_count */
X
X/*+-------------------------------------------------------------------------
X	report_mode(mode)
X
X comm mode row 7 col 52 length 5
X--------------------------------------------------------------------------*/
Xvoid
Xreport_mode(mode)
Xint mode;
X{
X	char tmp[8];
X
X	clear_area(win,7,52,6);
X	switch(mode)
X	{
X	case 0:
X		waddstr(win,"NORMAL");
X		break;
X	case 1:
X		waddstr(win,"RAW");
X		break;
X	case 2:
X		waddstr(win,"CBREAK");
X		break;
X	default:
X		sprintf(tmp,"%5u",mode);
X		waddstr(win,tmp);
X	}
X	wrefresh(win);
X
X}	/* end of report_mode */
X
X/*+-------------------------------------------------------------------------
X	report_rxpos(rxpos) row 3 col 19 len 8
X--------------------------------------------------------------------------*/
Xvoid
Xreport_rxpos(rxpos)
Xlong rxpos;
X{
Xchar tmp[16];
Xchar refr;
X
X	if(rdchk(0))
X	{
X		read(0,&refr,1);
X		if(refr == 0x0C || refr == 0x012)	/* ^L or ^R */
X		{
X			write(2,"\033[2J",4);
X			nap((long)60);
X			touchwin(stdscr);
X			wrefresh(stdscr);
X			touchwin(win);
X			wrefresh(win);
X		}
X	}
X
X	if((rxpos > 99999999L) || (rxpos < 0L))
X		return;
X
X	sprintf(tmp,"%8lu",rxpos);
X	wmove(win,3,19);
X	waddstr(win,tmp);
X	wrefresh(win);
X	report_rx_tx_count();	/* which will do a refresh */
X}	/* end of report_rxpos */
X
X/*+-------------------------------------------------------------------------
X	report_txpos(txpos)
X--------------------------------------------------------------------------*/
Xvoid
Xreport_txpos(txpos)
Xlong txpos;
X{
X	report_rxpos(txpos);
X}	/* end of report_txpos */
X
X/*+-------------------------------------------------------------------------
X	report_error_count()
X	DOES NOT PERFORM A REFRESH CYCLE
X  this file: row 10 col 29 len 4
X  total:     row 10 col 42 len 6
X--------------------------------------------------------------------------*/
Xreport_error_count()
X{
X	char tmp[16];
X
X	clear_area(win,10,29,4);
X	sprintf(tmp,"%4d",this_file_errors);
X	waddstr(win,tmp);
X
X	clear_area(win,10,42,6);
X	sprintf(tmp,"%6d",total_errors);
X	waddstr(win,tmp);
X	wrefresh(win);
X
X}	/* end of report_error_count */
X
X/*+-------------------------------------------------------------------------
X	report_last_txhdr(rptstr,error_flag)
X	5,7,22
X--------------------------------------------------------------------------*/
Xvoid
Xreport_last_txhdr(rptstr,error_flag)
Xregister char *rptstr;
Xint error_flag;
X{
Xchar s24[24];
X
X	if(log_packets)
X	{
X		write(log_packets,"tx:   ",6);
X		write(log_packets,rptstr,strlen(rptstr));
X		write(log_packets,"\n",1);
X	}
X
X	if(strlen(rptstr) > 22)
X	{
X		strncpy(s24,rptstr,22);
X		s24[23] = 0;
X		rptstr = s24;
X	}
X	clear_area(win,5,7,22);
X	waddstr(win,rptstr);
X	wrefresh(win);
X
X	if(error_flag)
X	{
X		++this_file_errors;
X		++total_errors;
X		report_error_count();
X	}
X}	/* end of report_last_txhdr */
X
X/*+-------------------------------------------------------------------------
X	report_last_rxhdr(rptstr,error_flag)
X	5,35,22
X--------------------------------------------------------------------------*/
Xvoid
Xreport_last_rxhdr(rptstr,error_flag)
Xregister char *rptstr;
Xint error_flag;
X{
Xchar s24[24];
Xextern int log_packets;
X
X	if(log_packets)
X	{
X		write(log_packets,"rx:   ",6);
X		write(log_packets,rptstr,strlen(rptstr));
X		write(log_packets,"\n",1);
X	}
X
X	if(strlen(rptstr) > 22)
X	{
X		strncpy(s24,rptstr,22);
X		s24[23] = 0;
X		rptstr = s24;
X	}
X	clear_area(win,5,35,22);
X	waddstr(win,rptstr);
X	wrefresh(win);
X
X	if(error_flag)
X	{
X		++this_file_errors;
X		++total_errors;
X		report_error_count();
X	}
X
X}	/* end of report_last_rxhdr */
X
X/*+-------------------------------------------------------------------------
X	report_str(rptstr,error_flag) row 11/12 col 3 len 55
X
X  error_flag == 0 for status/progress message
X             == 1 for bump error count, unless rptstr is null
X                  in which case, merely clear error string area
X             == 2 write string on bottom line (not an error)
X             == 3 write string on transaction line (not an error)
X             == -1 use error line but do not bump error count
X--------------------------------------------------------------------------*/
Xvoid
Xreport_str(rptstr,error_flag)
Xregister char *rptstr;
Xint error_flag;
X{
Xchar s60[60];
Xextern int log_packets;
X
X	if(strlen(rptstr) > 55)
X	{
X		strncpy(s60,rptstr,55);
X		s60[56] = 0;
X		rptstr = s60;
X	}
X
X	switch(error_flag)
X	{
X		case 0:
X			clear_area(win,12,3,55);
X			break;
X		case 1:
X			++this_file_errors;
X			++total_errors;
X			report_error_count();
X		case -1:
X			clear_area(win,11,3,55);
X			break;
X		case 2:
X			clear_area(win,13,3,55);
X			break;
X		case 3:
X			clear_area(win,4,3,55);
X			break;
X	}
X
X	waddstr(win,rptstr);
X	wrefresh(win);
X
X	if(log_packets)
X	{
X		write(log_packets,"info: ",6);
X		write(log_packets,rptstr,strlen(rptstr));
X		write(log_packets,"\n",1);
X	}
X
X}	/* end of report_str */
X
X/*+-------------------------------------------------------------------------
X	report_transaction()
X--------------------------------------------------------------------------*/
Xvoid
Xreport_transaction(str)
Xchar *str;
X{
X	report_str(str,3);
X}	/* end of report_transaction */
X
X/*+-------------------------------------------------------------------------
X	report_file_open_tod() -- time of start of this file
X
X  this file open time: row 8 col 47 length 8
X--------------------------------------------------------------------------*/
Xvoid
Xreport_file_open_tod()
X{
X	clear_area(win,8,47,8);
X	waddstr(win,get_tod(1,(char *)0));
X	wrefresh(win);
X}	/* end of report_file_open_tod */
X
X/*+-------------------------------------------------------------------------
X	report_file_open_length(long_length)
X  length:   row 3 col 36 len  8
X--------------------------------------------------------------------------*/
Xreport_file_open_length(length)
Xlong length;
X{
X	clear_area(win,3,36,8);
X	if(length <= 0)
X		waddstr(win,"unknown");
X	else
X	{
X		sprintf(s128,"%8lu",length);
X		waddstr(win,s128);
X	}
X	wrefresh(win);
X}	/* end of report_file_open_length */
X
X/*+-------------------------------------------------------------------------
X	report_file_send_open(filename,filestat)
X
X  filename: row 2 col 20 len 38
X  number:   row 2 col 8 len 3
X  length:   row 3 col 36 len  8
X  mode:     row 3 col 46 len 10
X  time of start of this file: row 4 col 47 length 8 hh:mm:ss
X--------------------------------------------------------------------------*/
Xvoid
Xreport_file_send_open(filename,filestat)
Xchar *filename;
Xstruct stat *filestat;
X{
Xchar s50[50];
Xregister char *cptr = filename;
Xchar s256[256];
X
X	if(log_packets)
X	{
X		write(log_packets,"file: ",6);
X		write(log_packets,filename,strlen(filename));
X		write(log_packets,"\n",1);
X	}
X
X	/* number */
X	clear_area(win,2,8,3);
X	sprintf(s50,"%3d",Filcnt);
X	waddstr(win,s50);
X
X	/* filename */
X	if(strlen(filename) > 38)
X	{
X		strncpy(s50,filename,38);
X		s50[39] = 0;
X		cptr = s50;
X	}
X	clear_area(win,2,20,38);
X	waddstr(win,cptr);
X
X#if defined(LOG_XFER)
X	sprintf(s256,"sending %s",filename);
X	ecu_log_event(s256);
X#endif
X
X	/* length */
X	report_file_open_length(filestat->st_size);
X
X	/* time of start of this file */
X	report_file_open_tod();
X
X	this_file_errors = 0;
X	report_error_count();
X}	/* end of report_file_send_open */
X
X/*+-------------------------------------------------------------------------
X	report_file_rcv_started(filename,length,last_mod_time)
X
X  filename: row 2 col 7 len 50
X  length:   row 3 col 36 len  8 if not xmodem
X  time of start of this file: row 4 col 47 length 8 hh:mm:ss
X--------------------------------------------------------------------------*/
Xreport_file_rcv_started(filename,length,last_mod_time)
Xchar *filename;
Xlong length;					/* if < 0, "UNKNOWN" */
Xlong last_mod_time;			/* not currently displayed */
X{
Xregister char *cptr;
Xchar s50[50];
Xchar s256[256];
X
X	if(log_packets)
X	{
X		write(log_packets,"file: ",6);
X		write(log_packets,filename,strlen(filename));
X		write(log_packets,"\n",1);
X	}
X
X	/* filename */
X	if(strlen(filename) > 38)
X	{
X		strncpy(s50,filename,38);
X		s50[39] = 0;
X		cptr = s50;
X	}
X	else
X		cptr = filename;
X
X#if defined(LOG_XFER)
X	sprintf(s256,"receiving %s",filename);
X	ecu_log_event(s256);
X#endif
X
X	clear_area(win,2,20,38);
X	waddstr(win,cptr);
X
X	/* file number */
X	clear_area(win,2,8,3);
X	sprintf(s50,"%3d",Filcnt);	/* rz uses as file number 1-n */
X	waddstr(win,s50);
X
X/* if remote sender provides a file count, display it */
X	if(npaths)
X	{
X		clear_area(win,2,12,7);	/* clear "of ###" */
X		sprintf(s50,"of %3d:",npaths);
X		waddstr(win,s50);
X	}
X
X	/* length */
X	report_file_open_length(length);
X
X	/* time of start of this file */
X	report_file_open_tod();
X
X	this_file_errors = 0;
X	report_error_count();
X}	/* end of report_file_rcv_started */
X
X/*+-------------------------------------------------------------------------
X	report_file_close()
X--------------------------------------------------------------------------*/
Xvoid report_file_close()
X{
X	report_str("End of file",0);
X	wrefresh(win);
X
X}	/* end of report_file_close */
X
X/*+-------------------------------------------------------------------------
X	report_comm_baud_rate(baud_rate)
X
X baud rate: row 7 col 14 length 5
X--------------------------------------------------------------------------*/
Xreport_comm_baud_rate(baud_rate)
Xunsigned int baud_rate;
X{
X	char tstr8[8];
X
X	clear_area(win,7,14,5);
X	if(baud_rate == 0)
X		waddstr(win,"?");
X	else
X
X	{
X		sprintf(tstr8,"%5u",baud_rate);
X		waddstr(win,tstr8);
X	}
X	wrefresh(win);
X
X}	/* end of report_comm_baud_rate */
X
X/*+-------------------------------------------------------------------------
X	report_file_byte_io(count)
X--------------------------------------------------------------------------*/
Xreport_file_byte_io(count)
Xlong count;
X{
X
X	total_data_chars_xfered += (long)count;
X	if(total_data_chars_xfered)
X	{
X		sprintf(s128,"Total file bytes transferred: %lu",
X			total_data_chars_xfered);
X		report_str(s128,-1);
X	}
X
X}	/* end of report_file_byte_io */
X
X/* end of scurses.c */
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
chmod 0644 sea/scurses.c || echo "restore of sea/scurses.c fails"
echo "x - extracting sea/sealink.doc (Text)"
sed 's/^X//' << 'SHAR_EOF' > sea/sealink.doc &&
X                                     SEALINK
X
X                             File Transfer Protocol
X
X                                 9 February 1987
X
X
X
X          (C) COPYRIGHT 1986,87 by System Enhancement Associates, Inc.
X
X
X
X     This document describes briefly the  SEAlink  file  transfer  protocol
X     developers' package.  SEAlink is a sliding  window  protocol  that  is
X     fully  backwards compatible with XMODEM in all tested implementations.
X
X     The intent of SEAlink is to provide a file transfer protocol that does
X     not  suffer  from  propagation  delays,  such  as  are  introduced  by
X     satellite relays or packet switched  networks.  Actual  tests  of  the
X     enclosed  routines  has  shown  that  SEAlink  is capable of virtually
X     eliminating propagation delays and turnaround delays.  File  transfers
X     between New Jersey and Hawaii,  which normally suffer a degradation of
X     50% or more  due  to  satellite  relays,  proceed  as  fast  as  local
X     transfers.  Even transfers within the local exchange are speeded up by
X     up to 20% at 2400 baud by the elimination of turnaround delays.  Large
X     volume  tests  show  that SEAlink is capable of coming to within 2% of
X     the theoretical minimum time for data transfer.
X
X
X
X     The developers' package contains the following files:
X
X         SEALINK.DOC    This document.
X         SEALINK.C      A set of C routines for implementing SEAlink.
X         CLINK.EXE      A sample TTY program that implements SEAlink.
X
X
X
X     You are granted a license to use this code in your  programs,  and  to
X     adapt  it to your particular situation and needs,  subject only to the
X     following conditions:
X
X     1) You must refer to it as the SEAlink protocol,  and  you  must  give
X        credit to System Enhancement Associates.
SHAR_EOF
echo "End of part 31"
echo "File sea/sealink.doc is continued in part 32"
echo "32" > s2_seq_.tmp
exit 0
-- 
-------------------------------------------------------------------
Warren Tucker, Tridom Corporation       ...!gatech!emory!tridom!wht 
Ker-au'-lo-phon.  An 8-foot partial flue-stop, having metal pipes
surmounted by adjustable rings, and with a hole bored near the top
of each pipe, producing a soft and "reedy" tone.