ecu - SCO XENIX V/{2,3}86 Extended CU part 12/47

Warren Tucker wht at tridom.uucp
Mon Oct 9 07:52:11 AEST 1989


---- Cut Here and unpack ----
#!/bin/sh
# this is part 12 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file ecuxenix.c continued
#
CurArch=12
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 ecuxenix.c"
sed 's/^X//' << 'SHAR_EOF' >> ecuxenix.c
Xvoid
Xsend_bell_fd(fd,count,nap_msec)
Xregister fd;
Xregister count;
Xregister nap_msec;
X{
Xstatic char bellch = 0x07;
X
X	if(count)
X		while(count--)
X		{
X			write(fd,&bellch,1);	
X			nap((long)nap_msec);
X		}
X}	/* end of send_bell_fd */
X
X/*+-------------------------------------------------------------------------
X	xbell_fd(fd,type,count)
X--------------------------------------------------------------------------*/
Xvoid
Xxbell_fd(fd,type,count)
Xregister fd;
Xregister type;
Xregister count;
X{
Xregister itmp;
X
X	if(count)
X		while(count--)
X		{
X			switch(type)
X			{
X				case XBELL_DEEDLE:		/* octaves */
X					set_bell_fd(fd,1000,1);
X					send_bell_fd(fd,1,100);
X					set_bell_fd(fd,2000,1);
X					send_bell_fd(fd,1,100);
X					set_bell_fd(fd,4000,1);
X					send_bell_fd(fd,1,100);
X					break;
X				case XBELL_ATTENTION:		/* morse .-.-.- ATTENTION */
X					for(itmp = 0; itmp < 3; itmp++)
X					{
X						set_bell_fd(fd,2000,1);
X						send_bell_fd(fd,1,140);
X						set_bell_fd(fd,2000,3);
X						send_bell_fd(fd,1,340);
X					}
X					break;
X				case XBELL_C:		/* morse -.-. C */
X					for(itmp = 0; itmp < 2; itmp++)
X					{
X						set_bell_fd(fd,2000,3);
X						send_bell_fd(fd,1,320);
X						set_bell_fd(fd,2000,1);
X						send_bell_fd(fd,1,120);
X					}
X					break;
X				case XBELL_3T:		/* 3 morse T's */
X					set_bell_fd(fd,2000,3);
X					send_bell_fd(fd,3,460);
X					break;
X				default:
X					set_bell_fd(fd,2000,4);
X					send_bell_fd(fd,1,100);
X					break;
X			}
X		}
X				
X	set_bell_fd(fd,4000,1);
X	
X}	/* end of xbell_fd */
X
X/*+-------------------------------------------------------------------------
X	morse_bell(xbell_type,count)
X--------------------------------------------------------------------------*/
X#if defined(MORSE)
Xmorse_bell(xbell_type,count)
Xint xbell_type;
Xint count;
X{
Xregister morse_fd;
Xint morse_ticks = 2;
Xchar s64[64];
Xextern int errno;
X
X	if((morse_fd = open("/dev/morse",O_WRONLY,0)) < 0)
X		return(-1);
X
X	ioctl(morse_fd,MORSE_SET_SPEED,&morse_ticks);
X	switch(xbell_type)
X	{
X		case XBELL_DEEDLE: s64[0] = 'd'; break;
X		case XBELL_ATTENTION: s64[0] = '.'; break;
X		case XBELL_C: s64[0] = 'c'; break;
X		case XBELL_3T: s64[0] = 'o'; break;
X		default: s64[0] = BT; break;
X	}
X	while(count--)
X		write(morse_fd,s64,1);
X	close(morse_fd);
X	return(0);
X}	/* end of morse_bell */
X#endif
X
X/*+-------------------------------------------------------------------------
X	xbell(type,count)
X--------------------------------------------------------------------------*/
Xvoid
Xxbell(type,count)
Xint type;
Xint count;
X{
X#if defined(MORSE)
X	if(morse_bell(type,count))
X#endif
X		xbell_fd(1,type,count);
X}	/* end of xbell */
X
X/*+-------------------------------------------------------------------------
X	xenix_bell_alarm(xbell_type)
X  Under XENIX 2.2.1, ring bell on multiscreens;
X  if morse driver included, use it
X--------------------------------------------------------------------------*/
Xint
Xxenix_bell_alarm(xbell_type)
Xint xbell_type;
X{
Xregister notify_fd;
Xregister fork_pid;
Xstatic long notify_time = 0L;
Xchar *ttname;
Xchar devname[64];
Xint devnum;
Xint ttnum;
Xlong time(long *);
X
X/* if ECU from modem port or console in single-user mode, dont do it */
X/* 0123456789 */
X/* /dev/tty10  */
X/* /dev/tty1a  */
X	ttname = get_ttyname();
X	if(!isdigit(ttname[strlen(ttname) - 1]))
X		return(0);
X	ttnum = atoi(ttname + 8);
X
X/* if happened less than 15 secs ago, forget it */
X	if((time((long *)0) - notify_time) < 15L)
X		return(0);
X
X	notify_time = time((long *)0);
X
X#if defined(MORSE)
X	if(morse_bell(xbell_type,1))
X	{
X#endif
X		if((fork_pid = smart_fork()) != 0)
X		{
X#if defined(FORK_DEBUG)
X			sprintf(devname,"DEBUG bell notify pid %d",fork_pid);
X			ecu_log_event(devname);	/* bell notify */
X#endif
X			return(fork_pid > 0);
X		}
X
X		for(devnum = 1; devnum < 13; devnum++)
X		{
X			if(devnum == ttnum)		/* don't bell notify ecu's tty */
X				continue;
X			sprintf(devname,"/dev/tty%02d",devnum);
X			if((notify_fd = open(devname,O_WRONLY,0)) >= 0)
X			{
X				xbell_fd(notify_fd,xbell_type,1);
X				close(notify_fd);
X			}
X		}
X
X		_exit(0);		/* end of child tine (of the fork, naturally) */
X#if defined(MORSE)
X	}
X#endif
X}	/* end of xenix_bell_alarm */
X
X/*+-------------------------------------------------------------------------
X	xenix_bell_notify(xbell_type)
X--------------------------------------------------------------------------*/
Xvoid
Xxenix_bell_notify(xbell_type)
Xint xbell_type;
X{
X
X	if(want_bell_notify)
X		xenix_bell_alarm(xbell_type);
X
X}	/* end of xenix_bell_notify */
X
X/*+-------------------------------------------------------------------------
X	xenix_signal_str(sig)
X--------------------------------------------------------------------------*/
Xchar *
Xxenix_signal_str(sig)
Xint sig;
X{
Xregister char *cptr;
Xstatic char sigunknown[20];
X
X	switch(sig)
X	{
X		case SIGHUP:	cptr = "SIGHUP"; break;
X		case SIGINT:	cptr = "SIGINT"; break;
X		case SIGQUIT:	cptr = "SIGQUIT"; break;
X		case SIGILL:	cptr = "SIGILL"; break;
X		case SIGTRAP:	cptr = "SIGTRAP"; break;
X		case SIGIOT:	cptr = "SIGIOT"; break;
X		case SIGEMT:	cptr = "SIGEMT"; break;
X		case SIGFPE:	cptr = "SIGFPE"; break;
X		case SIGKILL:	cptr = "SIGKILL"; break;
X		case SIGBUS:	cptr = "SIGBUS"; break;
X		case SIGSEGV:	cptr = "SIGSEGV"; break;
X		case SIGSYS:	cptr = "SIGSYS"; break;
X		case SIGPIPE:	cptr = "SIGPIPE"; break;
X		case SIGALRM:	cptr = "SIGALRM"; break;
X		case SIGTERM:	cptr = "SIGTERM"; break;
X		case SIGUSR1:	cptr = "SIGUSR1"; break;
X		case SIGUSR2:	cptr = "SIGUSR2"; break;
X		case SIGCLD:	cptr = "SIGCLD"; break;
X		case SIGPWR:	cptr = "SIGPWR"; break;
X		default:
X			sprintf(sigunknown,"SIG?? (%u)",sig);
X			return(sigunknown);
X	}
X	return(cptr);
X
X}	/* end of xenix_signal_str */
X
X/*+-------------------------------------------------------------------------
X	rename(from,to)
X--------------------------------------------------------------------------*/
Xrename(from,to)
Xchar *from;
Xchar *to;
X{
Xstruct stat ss;
Xextern int errno;
X
X	if(stat(to,&ss) == 0)	/* if to exists, flunk */
X	{
X		errno = EEXIST;	/* fake "file exists" error */
X		return(-1);
X	}
X	if(link(from,to))	/* if cannot link, flunk */
X		return(-1);
X	if(unlink(from))	/* if cannot unlink, flunk */
X		return(-1);
X	return(0);
X}	/* end of rename */
X
X/*+-------------------------------------------------------------------------
X	send_get_response(token,narg,arg)
X--------------------------------------------------------------------------*/
Xsend_get_response(token,narg,arg)
Xint token;
Xint narg;
Xchar **arg;
X{
Xregister itmp;
Xregister char *cptr;
Xint iarg;
Xint mode = atoi(arg[1]);
XLRWT lr;
Xchar buf[1024];
XFILE *fplog;
Xchar *fname = "ecu.sgr.log";
Xextern int rcvr_pid;
Xextern int interrupt;
Xint rcvr_alive = (rcvr_pid > 0);
X
X	if(narg < 3)
X	{
X		fputs("   usage: sgr mode cmd\r\n",se);
X		return;
X	}
X	if((fplog = fopen(fname,"a")) == NULL)
X	{
X		fputs("\r\n",se);
X		perror(fname);
X		fputs("\r\n",se);
X		return;
X	}
X
X	mode &= 0x0F;
X	if(rcvr_alive)
X		kill_rcvr_process(SIGUSR1);
X
X	lr.to1 = 10 * 1000L;
X	lr.to2 = 2 * 1000L;
X	lr.raw_flag = 0x80 + mode; /* allow interrupts */
X	lr.buffer = buf;
X	lr.bufsize = sizeof(buf);
X	lr.delim = (char *)0;
X	lr.echo = 0;
X	interrupt = 0;
X
X	fputs("\r\n",se);
X
X	fprintf(fplog,"\nMode: %d ",mode);
X	fputs("Stimulus: ",fplog);
X	for(iarg = 2; iarg < narg; iarg++)
X	{
X		fputs(arg[iarg],fplog);
X		lputs_paced(20,arg[iarg]);
X		if(iarg != (narg - 1))
X		{
X			fputc(' ',fplog);
X			lputc_paced(20,' ');
X		}
X	}
X	fputs("\nResponse: \n",fplog);
X	lputc_paced(20,'\r');
X
X	lgets_timeout(&lr);
X	itmp = lr.count;
X	cptr = strchr(buf,'\n') + 1;
X	itmp -= (int)(cptr - buf);
X	hex_dump_fp(fplog,cptr,itmp,(char *)0,1);
X
X	itmp = lr.count;
X	cptr = buf;
X	while(itmp--)
X	{
X		if(*cptr == '\n')
X			fputc('\r',se);
X		fputc(*cptr++,se);
X	}
X		
X	fclose(fplog);
X	if(rcvr_alive)
X		start_rcvr_process(0);
X}	/* end of send_get_response */
X
X/* end of ecuxenix.c */
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
echo "File ecuxenix.c is complete"
chmod 0644 ecuxenix.c || echo "restore of ecuxenix.c fails"
echo "x - extracting ecuxfer.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ecuxfer.c &&
X/* CHK=0x6734 */
X/*+-------------------------------------------------------------------------
X	ecuxfer.c
X	Copyright 1986,1989 Warren H. Tucker, III. All Rights Reserved
X
X   000000000011111111112222222222333333333344444444445555555555666666666actually
X   012345678901234567890123456789012345678901234567890123456789012345678wider
X00:.--[ Send ZMODEM/CRC32 ]--------------------------------------------.
X01:|                                                                   |
X02:|  File? to send:                                                   |
X03:|  ................................................................ |
X04:|                                                                   |
X05:|  Binary: Y (no CR/LF translation)                                 |
X06:|  Overwrite destination files: Y                                   |
X07:|  Send full pathnames: N                                           |
X08:|  Transfer only newer files: N (if receiver supports)              |
X09:|                                                                   |
X-1:| TAB:next  ^B:prev  END:perform transfer  ESC:abort                |
X-0:`-------------------------------------------------------------------'
X
X  Defined functions:
X	file_xfer_done_bell()
X	file_xfer_start()
X	receive_files_from_remote(argc,argv)
X	report_send_status()
X	send_files_to_remote(argc,argv)
X	xfer_title_fragment()
X	xfrw_bot_msg(msg)
X	xfrw_display_cmd_line()
X	xfrw_get_single(nondelim_list)
X	xfrws_display_allvars()
X	xfrws_display_binary()
X	xfrws_display_literals()
X	xfrws_display_name()
X	xfrws_display_xfernew()
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-03-1989-22:57-wht------------- ecu 2.00 ---------------- */
X/*:06-27-1989-22:42-wht-brackets around standout status report */
X/*:06-24-1989-16:53-wht-flush edits --- ecu 1.95 */
X
X#include <curses.h>
X
X#define STDIO_H_INCLUDED
X#define OMIT_TERMIO_REFERENCES
X#include "ecu.h"
X#include "ecukey.h"
X#include "ecuxkey.h"
X#include "ecuerror.h"
X#include "pc_scr.h"
X
X#define END		XFend
X
X/* -- protocol xfer types -- */
X#define ECUSZ_X			1
X#define ECUSZ_Y			2
X#define ECUSZ_Z			3
X#define ECUSEA			4
X#define CKERMIT			5
X#define ECURZ_X			7
X#define ECURZ_Y			8
X#define ECURZ_Z			9
X
X/* --------------------- send window ----------------------------------- */
X/*      SNDW_LINES			calculated (xfrw_lines) */
X#define SNDW_COLS			79
X#define SNDW_TLY			2
X/*      SNDW_TLX			calculated (xfrw_tlx) */
X
X#define SNDW_FILE_LY		2
X#define SNDW_FILE_LX		3
X#define SNDW_FILE_Y			3
X#define SNDW_FILE_X			3
X#define SNDW_FILE_LEN		(SNDW_COLS - SNDW_FILE_X - 2)
X
X#define SNDW_BIN_Y			5
X#define SNDW_BIN_LX			3
X#define SNDW_BIN_X			11
X#define SNDW_BIN_LX2		13
X
X#define SNDW_OVERW_Y		6
X#define SNDW_OVERW_LX		3
X#define SNDW_OVERW_X		32
X
X#define SNDW_SNDFUL_Y		7
X#define SNDW_SNDFUL_LX		3
X#define SNDW_SNDFUL_X		24
X
X#define SNDW_XFRNEW_Y		8
X#define SNDW_XFRNEW_LX		3
X#define SNDW_XFRNEW_X		30
X
Xextern char curr_dir[];		/* current working directory */
Xextern int protocol_log_packets;
Xextern int last_child_wait_status;
X
Xlong file_xfer_start_time;	/* time() value at beginning of file xfer */
Xchar xfertype = -1;		/* file xfer type */
XWINDOW *xfrw;
Xchar xfrw_cols;
Xchar xfrw_lines;
Xchar xfrw_tlx;
X
Xchar p_binary;		/* xfer options -- not all apply to all protocols */
Xchar p_sendfull;
Xchar p_overwrite;
Xchar p_xfernew;
Xchar p_filelist[80];
X
X/*+-------------------------------------------------------------------------
X	file_xfer_start()
X--------------------------------------------------------------------------*/
Xvoid
Xfile_xfer_start()
X{
Xlong time();
X	file_xfer_start_time = time((long *)0);
X}	/* end of file_xfer_start */
X
X/*+-------------------------------------------------------------------------
X	file_xfer_done_bell()
X--------------------------------------------------------------------------*/
Xvoid
Xfile_xfer_done_bell()
X{
Xlong time();
Xlong xfer_time = time((long *)0) - file_xfer_start_time;
Xint xbell_count = 0;
Xextern int want_bell_notify;
X
X	sleep(1);
X	xbell_count = 1;
X	if(xfer_time >= 3600L)			/* >= one hour */
X		xbell_count = 3;
X	else if(xfer_time >= 1800L)		/* >= 1/2 hour */
X		xbell_count = 2;
X
X	if(want_bell_notify)
X		xenix_bell_notify(XBELL_ATTENTION);
X
X	xbell(XBELL_DEEDLE,xbell_count);
X}	/* end of file_xfer_done_bell */
X
X/*+-------------------------------------------------------------------------
X	xfrw_bot_msg(msg)
X--------------------------------------------------------------------------*/
Xvoid
Xxfrw_bot_msg(msg)
Xchar *msg;
X{
Xregister itmp;
Xregister itmp2;
Xstatic last_msglen = 0;
Xchar msg2[80];
X
X	wmove(xfrw,xfrw_lines - 1,3);
X
X	if((itmp = strlen(msg)) == 0)
X	{
X		itmp2 = last_msglen + 2;
X		for(itmp = 0; itmp < itmp2; itmp++)
X			waddch(xfrw,sHR);
X		last_msglen = 0;
X	}
X	else
X	{
X		waddch(xfrw,' ');
X		if(itmp > xfrw_cols - 3 - 2)
X		{
X			strncpy(msg2,msg,xfrw_cols - 3 - 2);
X			msg2[xfrw_cols - 3 - 2 + 1] = 0;
X			waddstr(xfrw,msg2);
X			itmp = strlen(msg2);
X		}
X		else
X		{
X			waddstr(xfrw,msg);
X			itmp = strlen(msg);
X		}
X		waddch(xfrw,' ');
X		if((itmp2 = last_msglen - itmp) > 0)
X		{
X			while(itmp2--)
X				waddch(xfrw,sHR);
X		}
X		last_msglen = itmp;		/* remember last message length */
X	}
X	wrefresh(xfrw);
X}	/* end of xfrw_bot_msg */
X
X/*+-------------------------------------------------------------------------
X	xfrw_get_single(nondelim_list)
Xassumes cursor is already positioned
X--------------------------------------------------------------------------*/
Xint
Xxfrw_get_single(nondelim_list)
Xregister char *nondelim_list;
X{
Xregister uint itmp;
Xstatic char xfrw_nondelim_list[] =
X{
X	CR,NL,CTL_B,TAB,ESC,CTL_L,CTL_R,END
X};
X
X	itmp = winget_single(xfrw,nondelim_list,xfrw_nondelim_list);
X	if( (itmp & 0xFF) == 0x0D)
X		itmp = NL | 0x1000;
X	return(itmp);
X}	/* end of xfrw_get_single */
X
X/*+-------------------------------------------------------------------------
X	xfer_title_fragment(xfertype)
X--------------------------------------------------------------------------*/
Xchar *
Xxfer_title_fragment()
X{
Xregister char *cptr = "UNKNOWN";
X
X	switch(xfertype)
X	{
X		case ECURZ_X:
X		case ECUSZ_X: cptr = "XMODEM/CRC"; break;
X		case ECURZ_Y:
X		case ECUSZ_Y: cptr = "YMODEM/CRC"; break;
X		case ECURZ_Z:
X		case ECUSZ_Z: cptr = "ZMODEM/CRC32"; break;
X		case ECUSEA:  cptr = "SEAlink"; break;
X		case CKERMIT: cptr = "KERMIT/CRC" ;break;
X	}
X	return(cptr);
X}	/* end of xfer_title_fragment */
X
X/*+-------------------------------------------------------------------------
X	xfrw_display_cmd_line()
X--------------------------------------------------------------------------*/
Xvoid
Xxfrw_display_cmd_line()
X{
Xregister itmp;
Xchar *cmd_string = "TAB:next  ^B:prev  END:perform transfer  ESC:abort"; 
Xregister left_spaces = ((xfrw_cols - 2) - strlen(cmd_string)) / 2;
Xint x;
Xint y;
X
X	wmove(xfrw,xfrw_lines - 2,1);
X	wstandout(xfrw);
X	for(itmp = 0; itmp < left_spaces; itmp++)
X		waddch(xfrw,' ');
X	waddstr(xfrw,cmd_string);
X	getyx(xfrw,y,x);
X	while(++x < xfrw_cols)
X		waddch(xfrw,' '); 
X	wstandend(xfrw);
X
X}	/* end of xfrw_display_cmd_line */
X
X/*+-------------------------------------------------------------------------
X	xfrws_display_literals()
X--------------------------------------------------------------------------*/
Xvoid
Xxfrws_display_literals()
X{
X	wmove(xfrw,SNDW_FILE_LY,SNDW_FILE_LX);
X	if(xfertype == ECUSZ_X)
X		waddstr(xfrw,"File");
X	else
X		waddstr(xfrw,"File(s)");
X	waddstr(xfrw," to send:");
X
X	switch(xfertype)
X	{
X		case ECUSZ_Z:
X			wmove(xfrw,SNDW_XFRNEW_Y,SNDW_XFRNEW_LX);
X			waddstr(xfrw,"Transfer only newer files:");
X			wmove(xfrw,SNDW_SNDFUL_Y,SNDW_SNDFUL_LX);
X			waddstr(xfrw,"Send full pathames:");
X		case CKERMIT:
X			wmove(xfrw,SNDW_OVERW_Y,SNDW_OVERW_LX);
X			waddstr(xfrw,"Overwrite destination files:");
X		case ECUSZ_Y:
X		case ECUSZ_X:
X			wmove(xfrw,SNDW_BIN_Y,SNDW_BIN_LX);
X			waddstr(xfrw,"Binary:");
X	}
X}	/* end of xfrws_display_literals */
X
X/*+-------------------------------------------------------------------------
X	xfrws_display_name()
X--------------------------------------------------------------------------*/
Xvoid
Xxfrws_display_name()
X{
X	clear_area(xfrw,SNDW_FILE_Y,SNDW_FILE_X,SNDW_FILE_LEN);
X	waddstr(xfrw,p_filelist);
X
X}	/* end of xfrws_display_name */
X
X/*+-------------------------------------------------------------------------
X	xfrws_display_binary()
X--------------------------------------------------------------------------*/
Xvoid
Xxfrws_display_binary()
X{
X	wmove(xfrw,SNDW_BIN_Y,SNDW_BIN_X);
X	waddch(xfrw,(p_binary) ? 'Y' : 'N');
X	if(p_binary)
X		waddstr(xfrw," (no NL-CR/LF translation)     ");
X	else
X		waddstr(xfrw," (NL-CR/LF translation enabled)");
X
X}	/* end of xfrws_display_binary */
X
X/*+-------------------------------------------------------------------------
X	xfrws_display_xfernew()
X--------------------------------------------------------------------------*/
Xxfrws_display_xfernew()
X{
X	wmove(xfrw,SNDW_XFRNEW_Y,SNDW_XFRNEW_X);
X	waddch(xfrw,(p_xfernew) ? 'Y' : 'N');
X	if(p_xfernew)
X		waddstr(xfrw," (if receiver supports)");
X	else
X		waddstr(xfrw,"                       ");
X}	/* end of xfrws_display_xfernew */
X
X/*+-------------------------------------------------------------------------
X	xfrws_display_allvars()
X--------------------------------------------------------------------------*/
Xvoid
Xxfrws_display_allvars()
X{
X	xfrws_display_name();
X	switch(xfertype)
X	{
X		case ECUSZ_Z:
X			xfrws_display_xfernew();
X			wmove(xfrw,SNDW_SNDFUL_Y,SNDW_SNDFUL_X);
X			waddch(xfrw,(p_sendfull) ? 'Y' : 'N');
X		case CKERMIT:
X			wmove(xfrw,SNDW_OVERW_Y,SNDW_OVERW_X);
X			waddch(xfrw,(p_overwrite) ? 'Y' : 'N');
X		case ECUSZ_Y:
X		case ECUSZ_X:
X			xfrws_display_binary();
X	}
X}	/* end of xfrws_display_allvars */
X
X/*+-------------------------------------------------------------------------
X	report_send_status() - report file transmission result
Xreturns proc-type erc
Xfor "ecu knowledgeable" protocols only
X--------------------------------------------------------------------------*/
Xreport_send_status()
X{
Xint erc = 0;
Xunsigned int utmp;
X
X	utmp = last_child_wait_status;
X	if((utmp & 0xFF) == 0)	/* exit() called */
X	{
X		utmp >>= 8;
X		if(utmp == 0)
X		{
X			stand_out();
X			pputs(" [transfer successful] ");
X			stand_end();
X			pputs("\n");
X			erc = 0;
X		}
X		else if(utmp == 255)
X		{
X			stand_out();
X			pputs(" [ecu error: transfer program usage error] ");
X			stand_end();
X			pputs("\n");
X			erc = eFATAL_ALREADY;
X		}
X		else if(utmp == 254)
X		{
X			stand_out();
X			pputs(
X			" [protocol failure: bad line conditions or remote not ready] ");
X			stand_end();
X			pputs("\n");
X			erc = eFATAL_ALREADY;
X		}
X		else if(utmp == 253)
X		{
X			stand_out();
X			pputs(" [no requested files exist] ");
X			stand_end();
X			pputs("\n");
X			erc = eFATAL_ALREADY;
X		}
X		else if(utmp < 128)
X		{
X			stand_out();
X			if(utmp == 127)
X				pputs(" [127 or more files skipped] ");
X			else
X				pprintf(" [%u files rejected] ",utmp);
X			stand_end();
X			pputs("\n");
X			erc = 0;
X		}
X		else
X		{
X			stand_out();
X			pprintf(" [transfer aborted by %s] ",
X				xenix_signal_str(utmp - 128));
X			stand_end();
X			pputs("\n");
X			erc = eProcAttn_Interrupt;
X		}
X	}
X	else
X	{
X		stand_out();
X		pprintf(" [transfer killed by %s] ",
X			xenix_signal_str(utmp - 128));
X		stand_end();
X		pputs("\n");
X		erc = eProcAttn_Interrupt;
X	}
X
X	return(erc);
X
X}	/* end of report_send_status */
X
X/*+-----------------------------------------------------------------------
X	send_files_to_remote(argc,argv)
X------------------------------------------------------------------------*/
Xvoid
Xsend_files_to_remote(argc,argv)
Xint argc;
Xchar **argv;
X{
Xregister itmp;
Xregister input_state = 0;
Xregister input_state_mod;
Xunsigned int utmp;
Xint input_done;
Xint used_argv = 0;
Xchar execcmd[256];
Xchar s80[80];
Xuchar delim;	/* important to be unsigned to avoid sign extension */
XWINDOW *window_create();
Xchar bottom_label[64];
X
X	p_binary = 1;		/* assume p_binary xfer */
X	p_sendfull = 0;		/* assume no full pathnames */
X	p_overwrite = 1;	/* assume overwrite */
X	p_xfernew = 0;		/* assume send only newer */
X	p_filelist[0] = 0;	/* no filenames yet */
X
X	switch(to_lower(*(argv[0] + 1)))
X	{
X		case 'x': xfertype = ECUSZ_X; break;
X		case 'y': xfertype = ECUSZ_Y; break;
X		case 'z': xfertype = ECUSZ_Z; break;
X		case 'k': xfertype = CKERMIT; break;
X		case 's': xfertype = ECUSEA; break;
X		default: ff(se,"send command invalid\n");
X			return;
X	}
X
X	kill_rcvr_process(SIGUSR1);	/* SIGUSR1 gives chance to close log file */
X
X/* define and open window */
X	input_state_mod = 0;
X	xfrw_tlx = (COLS - SNDW_COLS) / 2;
X	xfrw_cols = SNDW_COLS;
X	switch(xfertype)
X	{
X		case ECUSEA:
X			input_state_mod = 1;
X			xfrw_lines = 7;
X			break;
X		case ECUSZ_X:
X			input_state_mod = 2;
X			xfrw_lines = 9;
X			break;
X		case ECUSZ_Z:
X			input_state_mod = 5;
X		case CKERMIT:
X			if(!input_state_mod)
X				input_state_mod = 3;
X		case ECUSZ_Y:
X			if(!input_state_mod)
X				input_state_mod = 2;
X			xfrw_lines = input_state_mod + 7;
X			break;
X		default:
X			hangup(9999);
X	}
X
X	windows_start();
X	sprintf(execcmd,"Send %s",xfer_title_fragment());
X	xfrw = window_create(execcmd,3,SNDW_TLY,(int)xfrw_tlx,
X			(int)xfrw_lines,(int)xfrw_cols);
X	xfrw_display_cmd_line();
X	xfrws_display_literals();
X	xfrws_display_allvars();
X	wmove(xfrw,0,27);
X	waddstr(xfrw," dir: ");
X	if(strlen(curr_dir) > (xfrw_cols - 32))
X	{
X	char s80[80];
X		strncpy(s80,curr_dir,xfrw_cols - 32);
X		s80[xfrw_cols - 32] = 0;
X		waddstr(xfrw,s80);
X	}
X	else
X		waddstr(xfrw,curr_dir);
X	waddch(xfrw,' ');
X
XREENTER_INPUT_LOOP:
X	input_done = 0;
X	while(!input_done)
X	{
X		switch(input_state)
X		{
X			case 0:		/* filename(s) */
X				xfrw_bot_msg("enter file(s) to send");
XCASE_0_AGAIN:
X				if(used_argv || (argc == 1))
X				{
X					itmp = wingets(xfrw,SNDW_FILE_Y,SNDW_FILE_X,s80,
X						SNDW_FILE_LEN + 1,&delim,(p_filelist[0] != 0));
X				}
X				else
X				{
X					used_argv = 1;
X					s80[0] = 0;
X					utmp = 0;
X					for(itmp = 1; itmp < argc; itmp++)
X					{
X						if((strlen(s80) + strlen(argv[itmp]) + 1) > sizeof(s80))
X						{
X							xfrw_bot_msg("arguments too long ... reenter list");
X							ring_bell();
X							goto CASE_0_AGAIN;
X						}
X						strcat(s80,argv[itmp]);
X						if(itmp != (argc - 1))
X							strcat(s80," ");
X					}
X					delim = CR;
X				}
X				if(delim == ESC)
X					break;
X				if(strlen(s80))
X				{
X					strcpy(p_filelist,s80);
X					xfrws_display_name();
X					if(find_shell_chars(p_filelist))
X					{
X					char *expcmd;
X
X						if(expand_cmd_with_wildlist(p_filelist,&expcmd))
X						{
X							xfrw_bot_msg(expcmd);
X							ring_bell();
X							goto CASE_0_AGAIN;
X						}
X						expcmd[SNDW_FILE_LEN - 1] = 0;
X						clear_area(xfrw,SNDW_FILE_Y,SNDW_FILE_X,SNDW_FILE_LEN);
X						waddstr(xfrw,expcmd);
X						free(expcmd);
X					}
X				}
X				break;
X			case 1:		/* binary */
X				xfrw_bot_msg("Y: no conversion, N: NLs converted to CR/LF");
X				wmove(xfrw,SNDW_BIN_Y,SNDW_BIN_X);
X				wrefresh(xfrw);
X				delim = NL;
X				switch(itmp = xfrw_get_single("ny"))
X				{
X					case 0:
X					case 1:
X						p_binary = itmp;
X						xfrws_display_binary();
X						break;
X					default:
X						delim = itmp & 0xFF;
X						break;
X				}
X				break;
X
X			case 2:		/* overwrite */
X				xfrw_bot_msg("Y: overwrite, N: protect destination files");
X				wmove(xfrw,SNDW_OVERW_Y,SNDW_OVERW_X);
X				wrefresh(xfrw);
X				delim = NL;
X				switch(itmp = xfrw_get_single("ny"))
X				{
X					case 0:
X					case 1:
X						p_overwrite = itmp;
X						break;
X					default:
X						delim = itmp & 0xFF;
X						break;
X				}
X				break;
X
X			case 3:		/* send full pathnames */
X				xfrw_bot_msg(
X					"Y: full pathnames, N: strip directory portion from names");
X				wmove(xfrw,SNDW_SNDFUL_Y,SNDW_SNDFUL_X);
X				wrefresh(xfrw);
X				delim = NL;
X				switch(itmp = xfrw_get_single("ny"))
X				{
X					case 0:
X					case 1:
X						p_sendfull = itmp;
X						break;
X					default:
X						delim = itmp & 0xFF;
X						break;
X				}
X				break;
X
X			case 4:		/* resume interrupted transfer */
X
X				xfrw_bot_msg(
X				"Y: send only if source newer than destination, N send all");
X				wmove(xfrw,SNDW_XFRNEW_Y,SNDW_XFRNEW_X);
X				wrefresh(xfrw);
X				delim = NL;
X				switch(itmp = xfrw_get_single("ny"))
X				{
X					case 0:
X					case 1:
X						p_xfernew = itmp;
X						xfrws_display_xfernew();
X						break;
X					default:
X						delim = itmp & 0xFF;
X						break;
X				}
X				break;
X
X		}
X
X		switch(delim)
X		{
X			case CTL_B:
X				input_state = (input_state) ? input_state - 1 
X				                            : input_state_mod - 1;
X				break;
X
X			case TAB:
X			case NL:
X				input_state++;
X				input_state %= input_state_mod;
X				break;
X
X			case CTL_L:
X			case CTL_R:
X				clear_screen();
X				touchwin(stdscr);
X				wrefresh(stdscr);
X				touchwin(xfrw);
X				wrefresh(xfrw);
X				break;
X
X			case ESC:
X				xfrw_bot_msg("transfer abandoned");
X				input_done = 1;
X				break;
X
X			case END:
X				input_done = 1;
X				break;
X		}
X	}
X
X	if(delim == END)
X	{
X		if(!p_filelist[0])
X		{
X			ring_bell();
X			xfrw_bot_msg("No filenames entered!  Press <ENTER>");
X			(void)ttygetc(1);
X			input_state = 0;
X			goto REENTER_INPUT_LOOP;
X		}
X		xfrw_bot_msg("starting file transfer");
X	}
X
X	windows_end(xfrw);
X	curmove(SNDW_TLY + xfrw_lines + 1,0);
X
X	if(delim == ESC)
X	{
X		start_rcvr_process(1);
X		return;
X	}
X
X	sprintf(bottom_label,"-C \"'Connected to %s'\" ",
X		(Llogical[0]) ? Llogical : "?");
X
X/* we are going to do a transfer! */
X	switch(xfertype)
X	{
X		case ECUSZ_X:
X			sprintf(execcmd,"ecusz -X -. %d ",Liofd);
X			strcat(execcmd,bottom_label);
X			if(protocol_log_packets)
X				strcpy(&execcmd[strlen(execcmd) ],"-, ");
X			if(p_binary)
X				strcat(execcmd,"-b ");
X			else
X				strcat(execcmd,"-a ");
X			strcat(execcmd,p_filelist);
X			break;
X		case ECUSZ_Y:
X			sprintf(execcmd,"ecusz -Y -. %d -k ",Liofd);
X			strcat(execcmd,bottom_label);
X			if(protocol_log_packets)
X				strcpy(&execcmd[strlen(execcmd) ],"-, ");
X			if(p_binary)
X				strcat(execcmd,"-b ");
X			else
X				strcat(execcmd,"-a ");
X			strcat(execcmd,p_filelist);
X			break;
X
X		case ECUSZ_Z:
X			sprintf(execcmd,"ecusz -Z -. %d ",Liofd);
X			strcat(execcmd,bottom_label);
X			if(protocol_log_packets)
X				strcat(execcmd,"-, ");
X			if(p_overwrite)
X				strcat(execcmd,"-y ");
X			else
X				strcat(execcmd,"-p ");
X			if(p_binary)
X				strcat(execcmd,"-b ");
X			else
X				strcat(execcmd,"-a ");
X			if(p_xfernew)
X				strcat(execcmd,"-n ");	/* overrides -y/-p choice earlier */
X			if(p_sendfull)
X				strcat(execcmd,"-f ");
X			strcat(execcmd,p_filelist);
X			break;
X
X		case ECUSEA:
X			sprintf(execcmd,"ecusea -. %d -/ %s -s ",Liofd,curr_dir);
X			if(protocol_log_packets)
X				strcat(execcmd,"-, ");
X			strcat(execcmd,p_filelist);
X			break;
X
X		case CKERMIT:
X			sprintf(execcmd,"ckermit -l %d -b %u -p %c%s%s -s %s",
X					Liofd,
X					Lbaud,
X					(Lparity) ? Lparity : 'n',
X					(p_binary) ? " -i" : "",
X					(p_overwrite) ? "" : " -w",
X					p_filelist);
X			break;
X
X	}
X
X	file_xfer_start();
X
X	if(find_shell_chars(execcmd))
X	{
X	char *expcmd;
X
X		if(expand_cmd_with_wildlist(execcmd,&expcmd))
X		{
X			ff(se,"No files match\r\n");
X			return;
X		}
X		if(exec_cmd(expcmd))
X		{
X			ff(se,"Could not execute command\r\n");
X			start_rcvr_process(1);
X			free(expcmd);
X			return;
X		}
X		free(expcmd);
X	}
X	else
X	{
X		if(exec_cmd(execcmd))
X		{
X			ff(se,"Could not execute command\r\n");
X			start_rcvr_process(1);
X			return;
X		}
X	}
X
X	lreset_ksr();
X
X	switch(xfertype)
X	{
X		case ECUSEA:
X		case ECUSZ_X:
X		case ECUSZ_Y:
X		case ECUSZ_Z:
X			xfertype = 1;		/* was ecusz */
X			break;
X		default:
X			xfertype = 0;
X			break;
X	}
X
X	if(xfertype)	/* ecu knowledgable */
X		report_send_status();
X	else
X	{
X		stand_out();
X		ff(se," transfer status %04x ",last_child_wait_status);
SHAR_EOF
echo "End of part 12"
echo "File ecuxfer.c is continued in part 13"
echo "13" > 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.



More information about the Alt.sources mailing list