From pa.dec.com!decwrl!sdd.hp.com!mips!samsung!uunet!sparky!kent Sun Aug 11 15:30:39 PDT 1991
Article: 2568 of comp.sources.misc
Path: pa.dec.com!decwrl!sdd.hp.com!mips!samsung!uunet!sparky!kent
From: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
Newsgroups: comp.sources.misc
Subject: v21i056:  ecu - ECU async comm package rev 3.10, Part04/37
Message-ID: <1991Aug3.033624.28160@sparky.IMD.Sterling.COM>
Date: 3 Aug 91 03:36:24 GMT
References: <csm-v21i053=ecu.215539@sparky.imd.sterling.com>
Sender: kent@sparky.IMD.Sterling.COM (Kent Landfield)
Organization: Sterling Software, IMD
Lines: 1973
Approved: kent@sparky.imd.sterling.com
X-Md4-Signature: 1985c82b7509986bb2b5ab5ce1a53f5e

Submitted-by: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
Posting-number: Volume 21, Issue 56
Archive-name: ecu/part04
Supersedes: ecu3: Volume 16, Issue 25-59
Environment: SCO, XENIX, ISC

---- Cut Here and feed the following to sh ----
#!/bin/sh
# this is ecu310.04 (part 4 of ecu310)
# do not concatenate these parts, unpack them in order with /bin/sh
# file ecuDCE.c continued
#
if touch 2>&1 | fgrep 'amc' > /dev/null
 then TOUCH=touch
 else TOUCH=true
fi
if test ! -r _shar_seq_.tmp; then
	echo 'Please unpack part 1 first!'
	exit 1
fi
(read Scheck
 if test "$Scheck" != 4; then
	echo Please unpack part "$Scheck" next!
	exit 1
 else
	exit 0
 fi
) < _shar_seq_.tmp || exit 1
if test ! -f _shar_wnt_.tmp; then
	echo 'x - still skipping ecuDCE.c'
else
echo 'x - continuing file ecuDCE.c'
sed 's/^X//' << 'SHAR_EOF' >> 'ecuDCE.c' &&
X
X/*+-------------------------------------------------------------------------
X	DCE_set_sreg(regnum,value)
X assumes rcvr process has been killed
X returns 0 if no error (reads back value set),
X else -1 and error message has been printed
X--------------------------------------------------------------------------*/
Xint
XDCE_set_sreg(regnum,value)
Xint regnum;
Xint value;
X{
Xchar s128[128];
Xint value2;
XLRWT	lr;
X
X	sprintf(s128,"ATS%d=%d",regnum,value);
X	DCE_send_cmd(s128);
X	lflush(0);
X	lr.to1 = 2000L;
X	lr.to2 = 140L;
X	lr.raw_flag = 0;
X	lr.buffer = s128;
X	lr.bufsize = sizeof(s128);
X	lr.delim = (char *)0;
X	lr.echo = 0;
X	lgets_timeout(&lr);
X	value2 = DCE_get_sreg_value(regnum);
X	if(value2 < 0)
X		pprintf("PROBLEM setting modem S%d=%d; cannot talk to modem\n",
X				regnum,value);
X	else if(value != value2)
X		pprintf("PROBLEM setting modem S%d=%d; got %d back\n",
X				regnum,value,value2);
X	return((value != value2) ? -1 : 0);
X
X}	/* end of DCE_set_sreg */
X
X/*+-------------------------------------------------------------------------
X	DCE_autoanswer()
X--------------------------------------------------------------------------*/
Xvoid
XDCE_autoanswer()
X{
X	if(!Lmodem_autoans[0])
X		return;
X	(void)nap(200L);
X	lputs_paced(20,"AT\r");
X	(void)nap(100L);
X	lputs_paced(20,Lmodem_autoans); /* quiet modem */
X	lputs_paced(20,"\r");
X	(void)nap(200L);
X	lputs_paced(20,Lmodem_autoans); /* quiet modem */
X	lputs_paced(20,"\r");
X	(void)nap(200L);
X	lflush(0);
X}	/* end of DCE_autoanswer */
X
X/* end of ecuDCE.c */
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
echo 'File ecuDCE.c is complete' &&
$TOUCH -am 0725125591 'ecuDCE.c' &&
chmod 0644 ecuDCE.c ||
echo 'restore of ecuDCE.c failed'
Wc_c="`wc -c < 'ecuDCE.c'`"
test 22762 -eq "$Wc_c" ||
	echo 'ecuDCE.c: original size 22762, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= ecuLCK.c ==============
if test -f 'ecuLCK.c' -a X"$1" != X"-c"; then
	echo 'x - skipping ecuLCK.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting ecuLCK.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'ecuLCK.c' &&
X#define HONEYDANBER /* means use ASCII pids in lock files */
X#if defined(SHARE_DEBUG)
X#define LOG_LOCKS
X#endif
X/*+-----------------------------------------------------------------------
X	ecuLCK.c -- ECU lock file management
X	wht@n4hgf.Mt-Park.GA.US
X
X  Defined functions:
X	is_active_lock(name)
X	line_locked(ttyname)
X	make_lock_name(ttyname,lock_file_name)
X
XLock files under XENIX are supposed to use the direct line name
X(lower-case last letter); we create only the lower-case case, but
Xcheck for both.
X------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
X/*:11-19-1990-01:05-wht@n4hgf-remove lock in is_active_lock if we locked */
X/*:10-16-1990-20:43-wht@n4hgf-add SHARE_DEBUG */
X/*:09-19-1990-19:36-wht@n4hgf-ecu_log_event now gets pid for log from caller */
X/*:08-14-1990-20:39-wht@n4hgf-ecu3.00-flush old edit history */
X
X#include "ecu.h"
X#include "utmpstatus.h"
X
Xextern int errno;
Xextern char ungetty_ttyname[];
X
X/*+-------------------------------------------------------------------------
X	make_lock_name(ttyname,lock_file_name)
X--------------------------------------------------------------------------*/
Xmake_lock_name(ttyname,lock_file_name)
Xchar *ttyname;
Xchar *lock_file_name;
X{
X
X	if((ulindex(ttyname,"/dev/tty")) != 0)
X		return(LOPEN_INVALID);
X
X	strcpy(lock_file_name,"/usr/spool/uucp/LCK..");
X	strcat(lock_file_name,ttyname + 5);
X	return(0);
X
X}	/* end of make_lock_name */
X
X/*+-------------------------------------------------------------------------
X	is_active_lock(name) - check to see if lock still active
X
Xif not unlink any old lock name
X--------------------------------------------------------------------------*/
Xis_active_lock(name)
Xregister char *name;
X{
Xregister itmp;
Xint lockpid;
Xint fd;
Xint status = 0;
Xchar pidstr[12];
X
X	errno = 0;
X	if((fd = open(name,O_RDONLY,0)) < 0)
X	{
X		if(errno != ENOENT)
X			status = LOPEN_LCKERR;
X		goto RETURN_STATUS;
X	}
X
X#if defined(HONEYDANBER)
X	itmp = read(fd,(char *)pidstr,11);
X	pidstr[11] = 0;
X	close(fd);
X	if(itmp != 11)
X		goto UNLINK_OLD_LOCK;
X	lockpid = atoi(pidstr);
X#else
X	itmp = read(fd,(char *)&lockpid,sizeof(int));
X	close(fd);
X	if(itmp != sizeof(int))
X		goto UNLINK_OLD_LOCK;
X#endif
X
X/*
X * during certain error recovery conditions,
X * we could get hurt by our own lock file
X */
X	if(lockpid == getpid())		/* if we are the locker, kill it */
X		goto UNLINK_OLD_LOCK;
X
X	if((!(itmp = kill(lockpid,0))) || (errno != ESRCH))
X	{
X		errno = EACCES;		/* for termecu() */
X		status = lockpid;
X		goto RETURN_STATUS;
X	}
X
XUNLINK_OLD_LOCK:
X	if(unlink(name))
X		status = LOPEN_LCKERR;
X
XRETURN_STATUS:
X
X#if defined(LOG_LOCKS)
X{ char s128[128];
X  extern char *errno_text();
X	sprintf(s128,"ISLOCK %s status=%d errno=%s",
X		name,status,errno_text(errno));
X	ecu_log_event(getpid(),s128);
X}
X#endif
X
X	return(status);
X}	/* end of is_active_lock */
X
X/*+-----------------------------------------------------------------------
X	line_locked(ttyname) - boolean test for locked line
X
X  ttyname must be of style "/dev/ttyxx"
X  Returns locking pid if locked else LOPEN lock error code (< 0) else 0
X  Either modem or direct name might be locked, so check both
X------------------------------------------------------------------------*/
Xint
Xline_locked(ttyname)
Xchar *ttyname;
X{
Xregister itmp;
Xchar lock_file_name[64];
X	
X	make_lock_name(ttyname,lock_file_name);
X	if(itmp = is_active_lock(lock_file_name))
X		return(itmp);
X
X#if defined(M_XENIX) || defined(M_UNIX)
X	if(isalpha(lock_file_name[itmp = strlen(lock_file_name) - 1]))
X	{
X		lock_file_name[itmp] ^= 0x20;	/* lower->upper, upper->lower */
X		if(itmp = is_active_lock(lock_file_name))
X			return(itmp);
X	}
X#endif
X	return(0);
X
X}	/* end of line_locked */
X
X/* end of ecuLCK.c */
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0725125591 'ecuLCK.c' &&
chmod 0644 ecuLCK.c ||
echo 'restore of ecuLCK.c failed'
Wc_c="`wc -c < 'ecuLCK.c'`"
test 3778 -eq "$Wc_c" ||
	echo 'ecuLCK.c: original size 3778, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= ecuchdir.c ==============
if test -f 'ecuchdir.c' -a X"$1" != X"-c"; then
	echo 'x - skipping ecuchdir.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting ecuchdir.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'ecuchdir.c' &&
X/*+-------------------------------------------------------------------------
X	ecuchdir.c - ECU change directory command/history
X	wht@n4hgf.Mt-Park.GA.US
X
X  Defined functions:
X	cd_array_delete(arg,narg)
X	cd_array_delete_usage()
X	cd_array_init()
X	cd_array_read()
X	cd_array_save()
X	change_directory(dirname,arg_present_flag)
X	expand_dirname(dirname,maxlen)
X	pop_directory(arg,arg_present,pcmd)
X	push_directory(dirname,arg_present,pcmd)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
X/*:07-14-1991-18:18-wht@n4hgf-new ttygets functions */
X/*:05-21-1991-18:53-wht@n4hgf-add push_directory and pop_directory */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#include "ecu.h"
X#include "ecukey.h"
X#include "ecutty.h"
X
Xint push_directory();
X
X#define CD_PATHLEN	256
X
X#define CD_QUAN		44
Xchar *cd_array[CD_QUAN];
Xuint cd_in_use = 0;
X
X#define DIR_PUSH_MAX	10
Xchar *dir_push_stack[DIR_PUSH_MAX];
Xuint dir_push_level = 0;
X
Xextern char curr_dir[CURR_DIRSIZ];		/* current working directory */
Xextern int proctrace;
Xextern char errmsg[];
Xextern int errno;
X
X/*+-------------------------------------------------------------------------
X	cd_array_read() - read ~/.ecu/dir
X--------------------------------------------------------------------------*/
Xvoid
Xcd_array_read()
X{
Xchar dirpath[CD_PATHLEN];
XFILE *fpcd;
XFILE *fopen();
Xregister char *cptr;
Xchar *skip_ld_break();
X
X	get_home_dir(dirpath);
X	strcat(dirpath,"/.ecu/dir");
X	if((fpcd = fopen(dirpath,"r")) == (FILE *)0)
X		return;		/* none found */
X
X	for(cd_in_use = 0; cd_in_use < CD_QUAN; cd_in_use++)
X	{
X		if(fgets(dirpath,sizeof(dirpath),fpcd) == (char *)0)
X			break;
X		dirpath[strlen(dirpath) - 1] = 0;
X		cptr = skip_ld_break(dirpath);
X		if(strlen(cptr) == 0)
X		{
X			--cd_in_use;
X			continue;
X		}
X		strcpy(cd_array[cd_in_use],cptr);
X	}
X	fclose(fpcd);
X}	/* end of cd_array_read */
X
X/*+-------------------------------------------------------------------------
X	cd_array_save() - save ~/.ecu/dir
X--------------------------------------------------------------------------*/
Xvoid
Xcd_array_save()
X{
Xregister icd;
Xchar savepath[256];
XFILE *fpcd;
XFILE *fopen();
X
X	get_home_dir(savepath);
X	strcat(savepath,"/.ecu/dir");
X
X	if(cd_in_use == 0)
X	{
X		ff(se,"No directory list to save in %s\r\n",savepath);
X		return;
X	}
X	if((fpcd = fopen(savepath,"w")) == (FILE *)0)
X	{
X		ff(se,"%s could not be opened\r\n",savepath);
X		return;
X	}
X
X	for(icd = 0; icd < cd_in_use; icd++)
X		fprintf(fpcd,"%s\n",cd_array[icd]);
X	fclose(fpcd);
X	ff(se,"%d entries saved in %s\r\n",cd_in_use,savepath);
X
X}	/* end of cd_array_save */
X
X/*+-------------------------------------------------------------------------
X	cd_array_delete_usage()
X--------------------------------------------------------------------------*/
Xvoid
Xcd_array_delete_usage()
X{
X	ff(se,"usage: d[elete] <1st> [<last>]\r\n");
X}	/* end of cd_array_delete_usage */
X
X/*+-------------------------------------------------------------------------
X	cd_array_delete(arg,narg)
X--------------------------------------------------------------------------*/
Xcd_array_delete(arg,narg)
Xchar **arg;
Xint narg;
X{
Xuint first;		/* 1st to delete */
Xuint last;		/* last to delete */
X
X	if((narg < 2) || (narg > 3))
X	{
X		cd_array_delete_usage();
X		return(-1);
X	}
X
X	first = atoi(arg[1]) - 1;
X	if(narg == 2)
X		last = first;
X	else
X		last = atoi(arg[2]) - 1;
X
X	if((first > (cd_in_use - 1)) || (last > (cd_in_use - 1)) || (last < first))
X	{
X		cd_array_delete_usage();
X		return(-1);
X	}
X
X	if(last == (cd_in_use - 1))
X	{
X		cd_in_use = first;
X	}
X	else
X	{
X	int count_less = last - first + 1;
X		last++;
X		while(last != cd_in_use)
X			strcpy(cd_array[first++],cd_array[last++]);
X		cd_in_use -= count_less;
X	}
X	return(0);
X}	/* end of cd_array_delete */
X
X/*+-------------------------------------------------------------------------
X	cd_array_init()
X--------------------------------------------------------------------------*/
Xvoid
Xcd_array_init()
X{
Xregister itmp;
X
X/*allocate change_directory stack */
X	for(itmp = 0; itmp < CD_QUAN; itmp++)
X	{
X		if(!(cd_array[itmp] = malloc(CD_PATHLEN + 1)))
X		{
X			ff(se,"Not enough memory for cd stack\r\n");
X			exit(1);
X		}
X		*cd_array[itmp] = 0;
X	}
X	(void)cd_array_read();
X}	/* end of cd_array_init */
X
X/*+-------------------------------------------------------------------------
X	expand_dirname(dirname,maxlen) - convert dirnames with shell chars
X--------------------------------------------------------------------------*/
Xexpand_dirname(dirname,maxlen)
Xchar *dirname;
Xint maxlen;
X{
Xchar s256[256];
Xchar *expcmd;
X
X	if(!find_shell_chars(dirname))
X		return(0);
X
X	sprintf(s256,"`ls -d %s`",dirname);
X	if(expand_wildcard_list(s256,&expcmd))
X	{
X		strcpy(errmsg,"No files match");
X		return(-1);
X	}
X	strncpy(dirname,expcmd,maxlen);
X	dirname[maxlen - 1] = 0;
X	free(expcmd);
X	if(strchr(dirname,' '))
X	{
X		strcpy(errmsg,"Too many files");
X		return(-1);
X	}
X	return(0);
X
X}	/* end of expand_dirname */
X
X/*+-------------------------------------------------------------------------
X	change_directory(dirname,arg_present_flag) - 'cd' interactive cmd hdlr
X
X  Change directory to 'dirname' if arg_present_flag is true,
X  else if flag 0, ask for new directory name and change to it
X  This procedure maintains the global variable 'curr_dir' that
X  reflects the ecu transmitter process current working directory.
X--------------------------------------------------------------------------*/
Xint
Xchange_directory(dirname,arg_present_flag)
Xchar *dirname;
Xint arg_present_flag;
X{
Xregister icd;
Xregister itmp;
Xchar s256[256];
Xuchar delim;
X#define BLD_ARG_MAX	5
Xchar *arg[BLD_ARG_MAX];
Xint narg;
Xint longest;
Xint pushing = 0;
X
X	if(cd_in_use == 0)
X		cd_array_read();
X
X	fputs("  ",se);
X
X	if(arg_present_flag)		/* if there is an argument ... */
X	{
X		if(isdigit(*dirname))		/* ... and first char is digit */
X		{
X			icd = atoi(dirname) - 1;
X			if((icd < 0) || (icd >= cd_in_use))
X				goto DISPLAY_CD_ARRAY;
X			strncpy(s256,cd_array[icd],sizeof(s256) - 1);
X		}
X		else
X			strncpy(s256,dirname,sizeof(s256) - 1);	/* literal dir spec */
X
X		s256[sizeof(s256) - 1] = 0;
X	}
X	else		/* no arg to cd command */
X	{
XDISPLAY_CD_ARRAY:
X		fputs("\r\n",se);
X		longest = 0;
X		for(icd = 0; icd < CD_QUAN/2; icd++)
X		{
X			if(icd >= cd_in_use)
X				break;
X			if(longest < (itmp = strlen(cd_array[icd])))
X				longest = itmp;
X		}
X		longest += 4;
X		if(longest < 36)
X			longest += 4;
X		for(icd = 0; icd < CD_QUAN/2; icd++)
X		{
X			if(icd >= cd_in_use)
X				break;
X			sprintf(s256,"%2d %s ",icd + 1,cd_array[icd]);
X			fputs(s256,se);
X			if(icd + CD_QUAN/2 >= cd_in_use)
X				fputs("\r\n",se);
X			else
X			{
X				itmp = longest - strlen(s256);
X				while(itmp-- > 0)
X					fputc(' ',se);
X				sprintf(s256,"%2d %s\r\n",
X					icd + 1 + CD_QUAN/2,cd_array[icd + CD_QUAN/2]);
X				fputs(s256,se);
X			
X			}
X		}
X		fputs("current dir: ",se);
X		tcap_stand_out();
X		ff(se," %s ",curr_dir);
X		tcap_stand_end();
X		tcap_eeol();
X		fputs("\r\n",se);
X
XGET_NEW_DIR:
X		fputs("New dir, <#>, %save, %read, %del, %xmitcd, %pushd, <enter>:  ",
X			se);
X		ttygets(s256,sizeof(s256),TG_CRLF,&delim,(int *)0);
X
XTRY_AGAIN:
X		if((delim == ESC) || !strlen(s256))
X		{
X			ff(se,"no directory change\r\n");
X			return(0);
X		}
X		else if(s256[0] == '%')
X		{
X			if(pushing)
X			{
X				ff(se,"syntax error\n");
X				return(-1);
X			}
X			build_str_array(s256,arg,BLD_ARG_MAX,&narg);
X
X			if(minunique("save",&s256[1],1))
X			{
X				cd_array_save();
X				goto GET_NEW_DIR;
X			}
X			else if(minunique("read",&s256[1],1))
X			{
X				cd_array_read();
X				goto DISPLAY_CD_ARRAY;
X			}
X			else if(minunique("delete",&s256[1],1))
X			{
X				if(cd_array_delete(arg,narg))
X					goto GET_NEW_DIR;
X				else
X					goto DISPLAY_CD_ARRAY;
X			}
X			else if(minunique("xmitcd",&s256[1],1))
X			{
X				lputs("cd ");
X				lputs(curr_dir);
X				lputc('\r');
X				return(0);
X			}
X			else if(minunique("pushd",&s256[1],1))
X			{
X				strcpy(s256,arg[1]);
X				pushing = 1;
X				goto TRY_AGAIN;
X			}
X			else
X			{
X				ff(se,"Invalid cd subcommand\r\n");
X				goto GET_NEW_DIR;
X			}
X		}
X		else if(icd = atoi(s256))
X		{
X			icd--;
X			if(icd >= cd_in_use)
X				goto GET_NEW_DIR;
X			strncpy(s256,cd_array[icd],sizeof(s256) - 1);
X			s256[sizeof(s256) - 1] = 0;
X		}
X	}
X	if(pushing)
X	{
X		if(push_directory(s256,1,1))
X			return(-1);
X	}
X	else
X	{
X		if(expand_dirname(s256,sizeof(s256)))
X		{
X			ff(se,"%s\r\n",errmsg);
X			return(-1);
X		}
X		if(chdir(s256) < 0)		/* now change to the new directory */
X		{
X			perror(s256);		/* print error if we get one */
X			ff(se,"\r\n");
X			return(-1);
X		}
X		get_curr_dir(curr_dir,sizeof(curr_dir));
X		fputs("confirmed: ",se);
X		tcap_stand_out();
X		ff(se," %s ",curr_dir);
X		tcap_stand_end();
X		fputs("\r\n",se);
X	}
X
X	for(icd = 0; icd < cd_in_use; icd++)
X	{
X		if(strcmp(curr_dir,cd_array[icd]) == 0)
X			return(0);
X	}
X	if(cd_in_use == CD_QUAN)
X	{
X		for(icd = 1; icd < CD_QUAN; icd++)
X		{
X			strcpy(cd_array[icd - 1],cd_array[icd]);
X		}
X		strcpy(cd_array[CD_QUAN - 1],curr_dir);
X	}
X	else
X		strcpy(cd_array[cd_in_use++],curr_dir);
X
X	return(0);
X
X}	/* end of change_directory */
X
X/*+-------------------------------------------------------------------------
X	push_directory(dirname,arg_present,pcmd) - 'pushd' function
X
XThis function performs 'pushd' actions for both the interactive
Xand procedure 'pushd' commands
X
Xdirname is new directory name if arg_present true
Xpcmd true if procedure command or cd %p interactive, else interactive command
X
Xreturns -1 if error, else 0
X--------------------------------------------------------------------------*/
Xint
Xpush_directory(dirname,arg_present,pcmd)
Xchar *dirname;
Xint arg_present;
Xint pcmd;
X{
Xregister itmp;
Xchar s256[256];
X
X	if(!pcmd)
X		ff(se,"\r\n");
X
X	if(!arg_present)
X	{
X		if(!dir_push_level)
X		{
X			if(!pcmd || proctrace)
X				pprintf("---: no directories pushed\n");
X		}
X		else
X		{
X			for(itmp = 0; itmp < dir_push_level; itmp++)
X				pprintf("%3d: %s\n",itmp,dir_push_stack[itmp]);
X		}
X		pprintf("cwd: %s\n",curr_dir);
X		return(0);
X	}
X
X	if(dir_push_level == DIR_PUSH_MAX)
X	{
X		pputs("too many pushds\n");
X		return(-1);
X	}
X
X	if(!dir_push_stack[dir_push_level])
X	{
X		if(!(dir_push_stack[dir_push_level] = malloc(CD_PATHLEN)))
X		{
X			pputs("no memory for pushd\n");
X			return(-1);
X		}
X	}
X
X	get_curr_dir(dir_push_stack[dir_push_level],CD_PATHLEN);
X
X	strncpy(s256,dirname,sizeof(s256) - 1);
X	s256[sizeof(s256) - 1] = 0;
X	if(expand_dirname(s256,sizeof(s256)))
X	{
X		pprintf("'%s': %s\n",s256,errmsg);
X		return(-1);
X	}
X	if(chdir(s256) < 0)		/* now change to the new directory */
X	{
X		pperror(s256);		/* print error if we get one */
X		return(-1);
X	}
X	get_curr_dir(curr_dir,sizeof(curr_dir));
X
X	if(pcmd && proctrace)
X		pprintf("pushed to directory %s\n",curr_dir);
X	else
X	{
X		fputs("confirmed: ",se);
X		tcap_stand_out();
X		ff(se," %s ",curr_dir);
X		tcap_stand_end();
X		ff(se," (level %d)\r\n",dir_push_level);
X	}
X
X	dir_push_level++;
X	return(0);
X
X}	/* end of push_directory */
X
X/*+-------------------------------------------------------------------------
X	pop_directory(arg,arg_present,pcmd) - 'popd' function
X
XThis function performs 'popd' actions for both the interactive
Xand procedure 'popd' commands
X
Xarg is empty if arg_present false
Xif not empty, it is == 'all' or a numeric level to pop to
Xpcmd true if procedure command, else interactive command
X
Xreturns -1 if error, else 0
X--------------------------------------------------------------------------*/
Xint
Xpop_directory(arg,arg_present,pcmd)
Xchar *arg;
Xint arg_present;
Xint pcmd;
X{
Xint new_level = -1;
X
X	if(!pcmd)
X		pputs("\n");
X
X	if(!dir_push_level)
X	{
X		if(!pcmd || proctrace)
X		{
X			pprintf("---: no directories pushed\n");
X			pprintf("cwd: %s\n",curr_dir);
X		}
X		return(-1);
X	}
X
X	if(!arg_present)
X		new_level = dir_push_level - 1;
X	if(arg_present && minunique("all",arg,1))
X		new_level = 0;
X	else if(isdigit(arg[0]))
X		new_level = atoi(arg);
X
X	if((new_level < 0) || (new_level > (dir_push_level - 1)))
X	{
X		pprintf("invalid popd argument (or not pushed to level): '%s'\n",arg);
X		return(-1);
X	}
X
X	dir_push_level = new_level;
X	if(chdir(dir_push_stack[dir_push_level]) < 0)
X	{
X		pperror(dir_push_stack[dir_push_level]);
X		return(-1);
X	}
X	get_curr_dir(curr_dir,sizeof(curr_dir));
X
X	if(pcmd && proctrace)
X		pprintf("popped to directory %s (level %d)\n",curr_dir,dir_push_level);
X	else
X	{
X		fputs("confirmed: ",se);
X		tcap_stand_out();
X		ff(se," %s ",curr_dir);
X		tcap_stand_end();
X		ff(se," (level %d)\r\n",dir_push_level);
X	}
X
X	return(0);
X
X}	/* end of pop_directory */
X
X/* end of ecuchdir.c */
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0725125591 'ecuchdir.c' &&
chmod 0644 ecuchdir.c ||
echo 'restore of ecuchdir.c failed'
Wc_c="`wc -c < 'ecuchdir.c'`"
test 12465 -eq "$Wc_c" ||
	echo 'ecuchdir.c: original size 12465, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= ecucmd.h ==============
if test -f 'ecucmd.h' -a X"$1" != X"-c"; then
	echo 'x - skipping ecucmd.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting ecucmd.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'ecucmd.h' &&
X/*+-------------------------------------------------------------------------
X	ecucmd.h -- command definitions
X	wht@n4hgf.Mt-Park.GA.US
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
X/*:07-04-1991-20:07-wht@n4hgf-add procedure rlog cmd */
X/*:05-21-1991-18:07-wht@n4hgf-add pushd/popd commands */
X/*:03-20-1991-05:25-root@n4hgf-experimental eto command */
X/*:03-16-1991-15:24-wht@n4hgf-add nice */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X/* interactive command tokens */
X
X#define CTax             1
X#define CTbaud           2
X#define CTbn             3
X#define CTbreak          4
X#define CTcd             5
X#define CTclrx           6
X#define CTda             7
X#define CTdial           8
X#define CTdo             9
X#define CTduplex        10
X#define CTexit          11
X#define CTfi            12
X#define CTfkey          13
X#define CTgetf          14
X#define CThangup        15
X#define CThelp          16
X#define CTllp           17
X#define CTloff          18
X#define CTlog           19
X#define CTnl            21
X#define CTnlin          22
X#define CTnlout         23
X#define CToa            24
X#define CTparity        25
X#define CTpcmd          26
X#define CTpid           27
X#define CTplog          28
X#define CTptrace        29
X#define CTputf          30
X#define CTpwd           31
X#define CTredial        32
X#define CTrev           33
X#define CTrk            34
X#define CTrs            35
X#define CTrtscts        36
X#define CTrx            37
X#define CTry            38
X#define CTrz            39
X#define CTsdname        40
X#define CTsgr           41
X#define CTsk            43
X#define CTss            44
X#define CTstat          45
X#define CTsx            46
X#define CTsy            47
X#define CTsz            48
X#define CTtime          50
X#define CTts            51
X#define CTtty           52
X#define CTxa            53
X#define CTxlog          54
X#define CTxon           55
X#if	defined(FASI)
X#define CTfasi          56
X#endif
X#define CTnice          57
X#define CTeto           58
X#define CTpushd         59
X#define CTpopd          60
X
X#define CTdummy1       120
X#define CTdummy2       121
X#define CTdummy3       122
X#define CTdummy4       123
X
X#define TOKEN_QUAN	128		/* for help package */
X
Xtypedef int(*PFI)();
X
X#if defined(HELPGEN)
X#define Z {;}
X#else
X#define Z ;
X#endif
X
Xint pcmd_baud() Z
Xint pcmd_break() Z
Xint pcmd_cd() Z
Xint pcmd_clrx() Z
Xint pcmd_cls() Z
Xint pcmd_color() Z
Xint pcmd_continue() Z
Xint pcmd_cursor() Z
Xint pcmd_delline() Z
Xint pcmd_dial() Z
Xint pcmd_do() Z
Xint pcmd_duplex() Z
Xint pcmd_echo() Z
Xint pcmd_eeol() Z
Xint pcmd_else() Z
Xint pcmd_exit() Z
Xint pcmd_expresp() Z
Xint pcmd_getf() Z
X#if	defined(FASI)
Xint pcmd_fasi() Z
X#endif
Xint pcmd_fchmod() Z
Xint pcmd_fclose() Z
Xint pcmd_fgetc() Z
Xint pcmd_fgets() Z
Xint pcmd_fkey() Z
Xint pcmd_flush() Z
Xint pcmd_fopen() Z
Xint pcmd_fputc() Z
Xint pcmd_fputs() Z
Xint pcmd_fread() Z
Xint pcmd_fseek() Z
Xint pcmd_fdel() Z
Xint pcmd_fwrite() Z
Xint pcmd_gosub() Z
Xint pcmd_gosubb() Z
Xint pcmd_goto() Z
Xint pcmd_gotob() Z
Xint pcmd_hangup() Z
Xint pcmd_hexdump() Z
Xint pcmd_home() Z
Xint pcmd_icolor() Z
Xint pcmd_insline() Z
Xint pcmd_ifge() Z
Xint pcmd_ifgt() Z
Xint pcmd_ifi() Z
Xint pcmd_ifle() Z
Xint pcmd_iflt() Z
Xint pcmd_ifnz() Z
Xint pcmd_ifs() Z
Xint pcmd_ifz() Z
Xint pcmd_lbreak() Z
Xint pcmd_lgets() Z
Xint pcmd_logevent() Z
Xint pcmd_lookfor() Z
X/* int pcmd_mkdir() Z */
Xint pcmd_mkvar() Z
Xint pcmd_nap() Z
Xint pcmd_nice() Z
Xint pcmd_parity() Z
Xint pcmd_pclose() Z
Xint pcmd_plog() Z
Xint pcmd_popd() Z
Xint pcmd_popen() Z
Xint pcmd_prompt() Z
Xint pcmd_ptrace() Z
Xint pcmd_pushd() Z
Xint pcmd_putf() Z
Xint pcmd_return() Z
Xint pcmd_rk() Z
Xint pcmd_rlog() Z
Xint pcmd_rname() Z
Xint pcmd_rs() Z
Xint pcmd_rtscts() Z
Xint pcmd_rx() Z
Xint pcmd_ry() Z
Xint pcmd_rz() Z
Xint pcmd_scrdump() Z
Xint pcmd_send() Z
Xint pcmd_set() Z
Xint pcmd_sk() Z
Xint pcmd_ss() Z
Xint pcmd_sx() Z
Xint pcmd_sy() Z
Xint pcmd_system() Z
Xint pcmd_sz() Z
Xint pcmd_vidcolor() Z
Xint pcmd_vidnorm() Z
Xint pcmd_vidrev() Z
Xint pcmd_whilei() Z
Xint pcmd_whiles() Z
Xint pcmd_xon() Z
X
X/* command classification */
X#define ccG  1	/* general command */
X#define ccC  2	/* comm command */
X#define ccT  3	/* transfer command */
X#define ccP  4	/* procedure-related command */
X
Xtypedef struct p_cmd
X{ 
X	char *cmd;		/* command string */
X	short mincnt;	/* min chars for match (0 if not interactive) */
X	short token;	/* command number (if interactive) */
X	char *descr;	/* command description (if interactive) */
X	PFI proc;		/* procedure cmd handler (or 0) */
X	short cmdclass;	/* cc{C,G,P,X} or 0 (for help processor) */
X}	P_CMD;
X
X#if !defined(DECLARE_P_CMD)
X#if defined(NEED_P_CMD)
Xextern P_CMD icmd_cmds[];
X#endif
X#else
XP_CMD icmd_cmds[] =
X{
X	{ "ax",		2,CTax,		"ascii char to hex/oct/dec",	0,			ccG},
X	{ "baud",	2,CTbaud,	"set/display line baud rate",	pcmd_baud,	ccC},
X	{ "bn",		2,CTbn,		"all console event alarm",		0,			ccG},
X	{ "break",	2,CTbreak,	"send break to remote",			pcmd_break,	ccC},
X	{ "cd",		2,CTcd,		"change current directory",		pcmd_cd,	ccG},
X	{ "clrx",	2,CTclrx,	"simulate XON from remote",		pcmd_clrx,	ccC},
X	{ "cls",	0,0,		"",								pcmd_cls,	0  },
X	{ "color",	0,0,		"",								pcmd_color,	0  },
X	{ "continue",0,0,		"",								pcmd_continue,0},
X	{ "cursor",	0,0,		"",								pcmd_cursor,0  },
X	{ "da",		2,CTda,		"decimal to ascii char",		0,         ccG},
X	{ "dial",	1,CTdial,	"dial remote destination",		pcmd_dial, ccC},
X	{ "delline",0,0,		"",								pcmd_delline,0 },
X	{ "do",		2,CTdo,		"perform procedure",			pcmd_do,   ccP},
X	{ "duplex",	2,CTduplex,	"set/display duplex",			pcmd_duplex,ccC},
X	{ "echo",	0,0,		"",								pcmd_echo,  0  },
X	{ "eeol",	0,0,		"",								pcmd_eeol,  0  },
X	{ "else",	0,0,		"",								pcmd_else,  0  },
X	{ "eto",	3,CTeto,	"ESC/fkey timeout",				0,         ccG},
X	{ "exit",	2,CTexit,	"hang up, exit program",		pcmd_exit, ccG},
X	{ "expresp",0,0,		"",								pcmd_expresp,0 },
X#if	defined(FASI)
X	{ "fasi",	2,CTfasi,	"FAS/i driver control",			pcmd_fasi,	ccC},
X#endif
X	{ "fchmod",	0,0,		"",								pcmd_fchmod,0  },
X	{ "fclose",	0,0,		"",								pcmd_fclose,0  },
X	{ "fdel",	0,0,		"",								pcmd_fdel,  0  },
X	{ "fgetc",	0,0,		"",								pcmd_fgetc, 0  },
X	{ "fgets",	0,0,		"",								pcmd_fgets, 0  },
X	{ "fi",		2,CTfi,		"send text file to line",		0,         ccG },
X	{ "fkey",	2,CTfkey,	"function key definition",		pcmd_fkey, ccG },
X	{ "flush",	0,0,		"",								pcmd_flush, 0  },
X	{ "fopen",	0,0,		"",								pcmd_fopen, 0  },
X	{ "fputc",	0,0,		"",								pcmd_fputc, 0  },
X	{ "fputs",	0,0,		"",								pcmd_fputs, 0  },
X	{ "fread",	0,0,		"",								pcmd_fread, 0  },
X	{ "fseek",	0,0,		"",								pcmd_fseek, 0  },
X	{ "fwrite",	0,0,		"",								pcmd_fwrite,0  },
X	{ "getf",	0,0,		"",								pcmd_getf,  0  },
X	{ "gosub",	0,0,		"",								pcmd_gosub, 0  },
X	{ "gosubb",	0,0,		"",								pcmd_gosubb,0  },
X	{ "goto",	0,0,		"",								pcmd_goto,  0  },
X	{ "gotob",	0,0,		"",								pcmd_gotob, 0  },
X	{ "hangup",	2,CThangup,	"hang up modem",				pcmd_hangup,ccC},
X	{ "help",	2,CThelp,	"invoke help",					0,         ccG },
X	{ "hexdump",0,0,		"",								pcmd_hexdump,0 },
X	{ "home",	0,0,		"",								pcmd_home,  0  },
X	{ "icolor",	0,0,		"",								pcmd_icolor,0  },
X	{ "ifge",	0,0,		"",								pcmd_ifge,  0  },
X	{ "ifgt",	0,0,		"",								pcmd_ifgt,  0  },
X	{ "ifi",	0,0,		"",								pcmd_ifi,   0  },
X	{ "ifle",	0,0,		"",								pcmd_ifle,  0  },
X	{ "iflt",	0,0,		"",								pcmd_iflt,  0  },
X	{ "ifnz",	0,0,		"",								pcmd_ifnz,  0  },
X	{ "ifs",	0,0,		"",								pcmd_ifs,   0  },
X	{ "ifz",	0,0,		"",								pcmd_ifz,   0  },
X	{ "insline",0,0,		"",								pcmd_insline,0 },
X	{ "lbreak",	0,0,		"",								pcmd_lbreak,0  },
X	{ "llp",	2,CTllp,	"set session log to /dev/lp",	0,         ccG },
X	{ "lgets",	0,0,		"",								pcmd_lgets, 0  },
X	{ "loff",	3,CTloff,	"turn off session logging",		0,         ccG },
X	{ "log",	3,CTlog,	"session logging control",		0,         ccG },
X	{ "logevent",0,0,		"",								pcmd_logevent,0},
X	{ "lookfor",0,0,		"",								pcmd_lookfor,0 },
X/*	{ "mkdir",	3,CTmkdir,	"mkdir <dirname>",				pcmd_mkdir, ccG}, */
X	{ "mkvar",	0,0,		"",								pcmd_mkvar, 0  },
X	{ "nap",	0,0,		"",								pcmd_nap,   0  },
X	{ "nice",	2,CTnice,	"change process nice (0-39)",	pcmd_nice,  0  },
X	{ "nl",		2,CTnl,		"display CR/LF mapping",		0,         ccC },
X	{ "nlin",	3,CTnlin,	"set receive CR/LF mapping",	0,         ccC },
X	{ "nlout",	3,CTnlout,	"set transmit CR/LF mapping",	0,         ccC },
X	{ "oa",		2,CToa,		"octal to ascii char",			0,         ccG },
X	{ "parity",	3,CTparity,	"set/display line parity",		pcmd_parity,ccC},
X	{ "pclose",	0,0,		"",								pcmd_pclose,0  },
X	{ "pcmd",	2,CTpcmd,	"execute a procedure command",	0,         ccP },
X	{ "pid",	2,CTpid,	"display process ids",			0,         ccG },
X	{ "plog",	2,CTplog,	"control procedure logging",	pcmd_plog, ccP },
X	{ "popd",	2,CTpopd,	"pop to previous directory",	pcmd_popd, ccG },
X	{ "popen",	0,0,		"",								pcmd_popen, 0  },
X	{ "prompt",	0,0,		"",								pcmd_prompt,0  },
X	{ "ptrace",	2,CTptrace,	"control procedure trace",		pcmd_ptrace,ccP},
X	{ "pushd",	2,CTpushd,	"push to new directory",		pcmd_pushd, ccG},
X	{ "putf",	0,0,		"",								pcmd_putf,  0  },
X	{ "pwd",	2,CTpwd,	"print working directory",		0,         ccG },
X	{ "redial",	3,CTredial,	"redial last number",			0,         ccC },
X	{ "return",	0,0,		"",								pcmd_return,0  },
X	{ "rev",	3,CTrev,	"ecu revision/make date",		0,         ccG },
X	{ "rk",		2,CTrk,		"receive via C-Kermit",			pcmd_rk,   ccT },
X	{ "rlog",	0,0,		"",								pcmd_rlog,  0  },
X	{ "rname",	0,0,		"",								pcmd_rname, 0  },
X	{ "rs",		2,CTrs,		"receive via SEAlink",			pcmd_rs,   ccT },
X	{ "rtscts",	3,CTrtscts,	"control RTS/CTS flow control",	pcmd_rtscts,ccC},
X	{ "rx",		2,CTrx,		"receive via XMODEM/CRC",		pcmd_rx,   ccT },
X	{ "ry",		2,CTry,		"receive via YMODEM Batch",		pcmd_ry,   ccT },
X	{ "rz",		2,CTrz,		"receive via ZMODEM/CRC32",		pcmd_rz,   ccT },
X	{ "scrdump",0,0,		"",								pcmd_scrdump,0 },
X	{ "sdname",	3,CTsdname,	"select screen dump name",		0,         ccC },
X	{ "send",	0,0,		"",								pcmd_send,  0  },
X	{ "set",	0,0,		"",								pcmd_set,   0  },
X	{ "sgr",	2,CTsgr,	"send command/get response",	0,         ccC },
X	{ "sk",		2,CTsk,		"send via C-Kermit",			pcmd_sk,   ccT },
X	{ "ss",		2,CTss,		"send via SEAlink",				pcmd_ss,   ccT },
X	{ "stat",	2,CTstat,	"general status",				0,         ccG },
X	{ "sx",		2,CTsx,		"send via XMODEM/CRC",			pcmd_sx,   ccT },
X	{ "sy",		2,CTsy,		"send via YMODEM Batch",		pcmd_sy,   ccT },
X	{ "system",	0,CTsy,		"",								pcmd_system,0  },
X	{ "sz",		2,CTsz,		"send via ZMODEM/CRC32",		pcmd_sz,   ccT },
X	{ "time",	2,CTtime,	"time of day",					0,         ccG },
X	{ "ts",		2,CTts,		"termio display",				0,         ccC },
X	{ "tty",	2,CTtty,	"console tty name",				0,         ccG },
X	{ "vidcolor",0,0,		"",								pcmd_vidcolor,0},
X	{ "vidnorm",0,0,		"",								pcmd_vidnorm,0 },
X	{ "vidrev",	0,0,		"",								pcmd_vidrev,0  },
X	{ "whilei",	0,0,		"",								pcmd_whilei,0  },
X	{ "whiles",	0,0,		"",								pcmd_whiles,0  },
X	{ "xa",		2,CTxa,		"hex to ascii char",			0,         ccG },
X	{ "xlog",	2,CTxlog,	"protocol packet logging",		0,         ccT },
X	{ "xon",	2,CTxon,	"control xon/xoff flow control",pcmd_xon,  ccC },
X/* these cmds are interecepted by special code in ecucmd.h and appear
X * here only so they will be picked up by the help system.
X */
X	{ "!",		1,CTdummy1,	"execute shell (tty)",			0,         ccG },
X	{ "$",		1,CTdummy2,	"execute shell (comm line)",	0,         ccG },
X	{ "-",		1,CTdummy3,	"execute program",				0,         ccG },
X	{ "?",		1,CTdummy4,	"get help",						0,         ccG },
X	{ "",		0,-1,"",0,0 }	/* list ends with token value of -1 */
X};
X#endif
X
X/* end of ecucmd.h */
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0725125591 'ecucmd.h' &&
chmod 0644 ecucmd.h ||
echo 'restore of ecucmd.h failed'
Wc_c="`wc -c < 'ecucmd.h'`"
test 11733 -eq "$Wc_c" ||
	echo 'ecucmd.h: original size 11733, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= ecucurses.h ==============
if test -f 'ecucurses.h' -a X"$1" != X"-c"; then
	echo 'x - skipping ecucurses.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting ecucurses.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'ecucurses.h' &&
X/*+-------------------------------------------------------------------------
X	ecucurses.h - bypass SCO <curses.h> problems
X	wht@n4hgf.Mt-Park.GA.US
X
XIt is impossible to avoid warnings with various SCO curses installation
Xoptions, so we do it here
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
X/*:05-02-1991-02:35-wht@n4hgf-creation */
X
X#if defined(M_TERMINFO)
X#undef M_TERMINFO
X#endif /* M_TERMINFO */
X
X#if defined(M_TERMCAP)
X#undef M_TERMCAP
X#endif /* M_TERMCAP */
X
X#define M_TERMCAP	/* this, alas is required at this time */
X
X#if defined(M_SYSV)		/* any SCO */
X#if defined(M_TERMCAP)
X# include <tcap.h>
X#else /* !M_TERMCAP */
X# include <tinfo.h>
X#endif /* M_TERMCAP */
X#else /* !M_SYSV */
X# include <curses.h>
X#endif /* M_SYSV */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of ecucurses.h */
SHAR_EOF
$TOUCH -am 0725125591 'ecucurses.h' &&
chmod 0644 ecucurses.h ||
echo 'restore of ecucurses.h failed'
Wc_c="`wc -c < 'ecucurses.h'`"
test 890 -eq "$Wc_c" ||
	echo 'ecucurses.h: original size 890, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= ecudump.c ==============
if test -f 'ecudump.c' -a X"$1" != X"-c"; then
	echo 'x - skipping ecudump.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting ecudump.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'ecudump.c' &&
X/*+-----------------------------------------------------------------------
X	ecudump.c  -- very generic hex/graphics dump development aid
X	wht@n4hgf.Mt-Park.GA.US
X
X  Defined functions:
X	dump_putc(ch)
X	dump_puts(str)
X	hex_dump(str,len,title,terse_flag)
X	hex_dump_fp(fp,str,len,title,terse_flag)
X	hex_dump16(int16)
X	hex_dump32(int32)
X	hex_dump4(int4)
X	hex_dump8(int8)
X
X------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#include "ecu.h"
X
XFILE *dumpfp;
X
X/*+-------------------------------------------------------------------------
X	dump_putc(ch)
X--------------------------------------------------------------------------*/
Xvoid
Xdump_putc(ch)
Xchar ch;
X{
X	if(dumpfp == se)
X		pputc(ch);
X	else
X		fputc(ch,dumpfp);
X}	/* end of dump_putc */
X
X
X/*+-------------------------------------------------------------------------
X	dump_puts(str)
X--------------------------------------------------------------------------*/
Xvoid
Xdump_puts(str)
Xchar *str;
X{
X	if(dumpfp == se)
X		pputs(str);
X	else
X		fputs(str,dumpfp);
X}	/* end of dump_puts */
X
X
X/*+-----------------------------------------------------------------------
X	hex_dump#... subservient routines
X------------------------------------------------------------------------*/
Xvoid hex_dump4(int4)
Xuchar int4;
X{
X	int4 &= 15;
X	dump_putc((int4 >= 10) ? (int4 + 'A' - 10) : (int4 + '0'));
X}
X
Xvoid hex_dump8(int8)
Xuchar int8;
X{
X	hex_dump4(int8 >> 4);
X	hex_dump4(int8);
X}
X
Xvoid hex_dump16(int16)
Xushort int16;
X{
X	hex_dump8(int16 >> 8);
X	hex_dump8(int16);
X}
X
Xvoid hex_dump32(int32)
Xulong int32;
X{
X	hex_dump16(int32 >> 16);
X	hex_dump16(int32);
X}
X
X
X/*+-----------------------------------------------------------------
X	hex_dump_fp(fp,str,len,title,terse_flag)
X
X  if 'title' not NULL, title is printed... 'terse_flag'
X  controls whether or not the title is "conspicuous" with
X  hyphens before and after it making title line >70 chars long
X------------------------------------------------------------------*/
Xvoid
Xhex_dump_fp(fp,str,len,title,terse_flag)
XFILE *fp;
Xchar *str;
Xint len;
Xchar *title;
Xint terse_flag;
X{
Xint istr;
Xregister ipos = 0;
Xregister itmp;
X
X	dumpfp = fp;
X
X	if(title && (istr = strlen(title)))
X	{
X		if(!terse_flag)
X		{
X			ipos = (73 - istr) / 2;
X			itmp = ipos;
X			while(itmp--)
X				dump_putc('-');
X			dump_putc(' ');
X			if(istr & 1)
X				ipos--;
X		}
X		dump_puts(title);
X		if(!terse_flag)
X		{
X			dump_putc(' ');
X			while(ipos--)
X				dump_putc('-');
X		}
X		if(dumpfp == se)
X			dump_puts("\r\n");
X		else
X			dump_puts("\n");
X
X	}
X
X	istr = 0;
X	while(istr < len)
X	{
X		hex_dump16(istr);
X		dump_putc(' ');
X		for(itmp = 0; itmp < 16; ++itmp)
X		{
X			ipos = istr + itmp;
X			if(ipos >= len)
X			{
X				if(!terse_flag)
X					dump_puts("   ");
X				continue;
X			}
X			dump_putc(' ');
X			hex_dump8(str[ipos]);
X		}
X		dump_puts(" | ");
X		for(itmp = 0; itmp < 16; ++itmp)
X		{
X			ipos = istr + itmp;
X			if( (ipos) >= len)
X			{
X				if(!terse_flag)
X					dump_putc(' ');
X			}
X			else
X			{
X				dump_putc((str[ipos] >= ' ' && str[ipos] < 0x7f)
X		 			? str[ipos] : '.' );
X			}
X		}
X		if(dumpfp == se)
X			dump_puts(" |\r\n");
X		else
X			dump_puts(" |\n");
X		istr += 16;
X	}   /* end of while(istr < len) */
X
X}	/* end of hex_dump_fp */
X
X/*+-------------------------------------------------------------------------
X	hex_dump(str,len,title,terse_flag)
X--------------------------------------------------------------------------*/
Xvoid
Xhex_dump(str,len,title,terse_flag)
Xchar *str;
Xint len;
Xchar *title;
Xint terse_flag;
X{
X	hex_dump_fp(se,str,len,title,terse_flag);
X}	/* end of hex_dump_fp */
X/* end of ecudump.c */
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
$TOUCH -am 0725125591 'ecudump.c' &&
chmod 0644 ecudump.c ||
echo 'restore of ecudump.c failed'
Wc_c="`wc -c < 'ecudump.c'`"
test 3703 -eq "$Wc_c" ||
	echo 'ecudump.c: original size 3703, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= ecuerror.h ==============
if test -f 'ecuerror.h' -a X"$1" != X"-c"; then
	echo 'x - skipping ecuerror.h (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting ecuerror.h (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'ecuerror.h' &&
X/*+-------------------------------------------------------------------------
X	ecuerror.h
X	wht@n4hgf.Mt-Park.GA.US
X
Xe_... values must not be changed without careful looking through code
Xerror numbers should be <= 0x7FFF to avoid problems with M_I286 versions
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#define e_USER				0x1000	/* user error differentiation */
X
X/* warning errors - do not stop proc execution */
X#define e_WARNING			0x3000
X#define eProcEmpty			0x3001  /* empty procedure */
X#define eWARNING_ALREADY	0x3002  /* warning already printed */
X#define eConnectFailed		0x3003	/* failed to connect */
X#define eNoSwitches			0x3004	/* no switch(es) to command */
X
X/* fatal errors - stop proc execution */
X#define e_FATAL				0x4000
X#define eIllegalCommand		0x4003  /* invalid command */
X#define eNoMemory			0x4004  /* no more memory available */
X#define eSyntaxError		0x4005  /* syntax error */
X#define eIllegalVarNumber	0x4006  /* number is invalid or out of range */
X#define eIllegalVarType		0x4007  /* unrecognized variable type */
X#define eNotInteger			0x4008  /* integer expected and not found */
X#define eFATAL_ALREADY		0x4011  /* fatal to proc, info already printed */
X#define eCONINT				0x4012  /* abort due to interrupt */
X#define eInvalidFunction	0x4013  /* invalid function name */
X#define eMissingLeftParen	0x4014  /* did not find expected left paren */
X#define eMissingRightParen	0x4015  /* did not find expected right paren */
X#define eCommaExpected		0x4016  /* expected comma not found */
X#define eProcStackTooDeep	0x4017  /* procedure stack depth exceeded */
X#define eInvalidRelOp		0x4018  /* invalid relational operator */
X#define eInvalidIntOp		0x4019  /* invalid integer operator */
X#define eInvalidStrOp		0x4020  /* invalid string operator */
X#define eNotExecutingProc	0x4022  /* not executing DO at this time */
X#define eInvalidLabel		0x4023  /* invalid label */
X#define eInternalLogicError	0x4025  /* internal logic error ... whoops */
X#define eEOF				0x4026  /* end of file or read error */
X#define eBufferTooSmall		0x4027  /* string too long */
X#define eNoParameter		0x4028  /* expected parameter not found */
X#define eBadParameter		0x4029  /* bad parameter */
X#define eInvalidHexNumber	0x402A	/* invalid hexadecimal digit */
X#define eInvalidDecNumber	0x402B	/* invalid decimal digit */
X#define eInvalidOctNumber	0x402C	/* invalid octal digit */
X#define eInteractiveCmd		0x402E	/* interactive command */
X#define eNoLineAttached		0x402F	/* no line (modem) attached */
X#define eBadFileNumber		0x4030	/* file number out of range */
X#define eNotImplemented		0x4031	/* not implemented */
X#define eDuplicateMatch		0x4032	/* more than one condition matches */
X#define eColonExpected		0x4033  /* expected colon not found */
X#define eLabelInvalidHere	0x4034  /* label not allowed on this statement */
X#define eNoCloseFrame		0x4035  /* missing '}' for '{' */
X#define eNoFrame			0x4036  /* missing command or command group after 'while' or 'if' */
X#define eMissingCommand		0x4037  /* expected command not found */
X#define eBreakCommand		0x4038  /* 'break' outside 'while' */
X#define eContinueCommand	0x4039  /* 'continue' outside 'while' */
X#define eElseCommand		0x403A  /* 'else' without matching 'if' */
X#define eInvalidVarName		0x403B  /* invalid variable name */
X#define eNoSuchVariable		0x403C  /* variable by this name not defined */
X#define eInvalidLogicOp		0x403D  /* invalid logical operator */
X#define eExpectRespondFail	0x403E  /* expect-respond failed */
X
X/* DO attention getter */
X#define e_ProcAttn			0x7000
X#define eProcAttn_GOTO		0x7000  /* GOTO detected */
X#define eProcAttn_GOTOB		0x7001  /* GOTOB detected */
X#define eProcAttn_RETURN	0x7002  /* RETURN detected */
X#define eProcAttn_ESCAPE	0x7003  /* ESCAPE detected */
X#define eProcAttn_Interrupt	0x7004  /* procedure interrupted */
X
SHAR_EOF
$TOUCH -am 0725125591 'ecuerror.h' &&
chmod 0644 ecuerror.h ||
echo 'restore of ecuerror.h failed'
Wc_c="`wc -c < 'ecuerror.h'`"
test 3980 -eq "$Wc_c" ||
	echo 'ecuerror.h: original size 3980, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= ecufinsert.c ==============
if test -f 'ecufinsert.c' -a X"$1" != X"-c"; then
	echo 'x - skipping ecufinsert.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting ecufinsert.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'ecufinsert.c' &&
X#define USE_XON_XOFF
X/*+-------------------------------------------------------------------------
X	ecufinsert.c -- insert file onto comm line
X	wht@n4hgf.Mt-Park.GA.US
X
X  Defined functions:
X	expand_filename(fname,maxlen)
X	file_insert_clear_xoff()
X	file_insert_to_line(narg,arg)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
X/*:07-17-1991-07:04-wht@n4hgf-avoid SCO UNIX nap bug */
X/*:07-14-1991-18:18-wht@n4hgf-new ttygets functions */
X/*:04-27-1991-01:24-wht@n4hgf-expand_filename was NFG */
X/*:03-30-1991-12:40-wht@n4hgf-redi!donovan found q does not restart receiver */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#include "ecu.h"
X#include "ecukey.h"
X#include "ecutty.h"
X
Xextern int sigint;
Xextern char kbdintr;		/* current input INTR */
Xextern ulong colors_current;
Xextern ulong colors_alert;
Xextern ulong colors_errors;
X
X/*+-------------------------------------------------------------------------
X	expand_filename(fname) - convert fnames with shell chars
X
Xreturn 0 if no shell characters found
X       -1 if shell expansion match found
X       1 if shell expansion found
X--------------------------------------------------------------------------*/
Xint
Xexpand_filename(fname,maxlen)
Xchar *fname;
Xint maxlen;
X{
Xchar *expcmd;
X
X	if(!find_shell_chars(fname))
X		return(0);
X
X	if(expand_wildcard_list(fname,&expcmd))
X	{
X		fputs("\r\n",se);
X		fputs(expcmd,se);
X		fputs("\r\n",se);
X		return(-1);
X	}
X	strncpy(fname,expcmd,maxlen);
X	fname[maxlen - 1] = 0;
X	if(strchr(expcmd,' '))
X	{
X		fputs("\r\nToo many files:\r\n",se);
X		fputs(expcmd,se);
X		fputs("\r\n",se);
X		free(expcmd);
X		return(-1);
X	}
X	strncpy(fname,expcmd,maxlen - 1);
X	*(fname + maxlen - 1) = 0;
X	free(expcmd);
X	return(0);
X
X}	/* end of expand_filename */
X
X/*+-------------------------------------------------------------------------
X	file_insert_clear_xoff()
X--------------------------------------------------------------------------*/
Xvoid
Xfile_insert_clear_xoff()
X{
X#ifdef USE_XON_XOFF
X#ifdef SAY_CLEARED_XOFF
Xulong colors_at_entry = colors_current;
X
X	setcolor(colors_alert);
X	fputs("--> local XOFF cleared\r",se);
X	setcolor(colors_at_entry);
X#endif
X	lclear_xmtr_xoff();
X#endif
X}	/* end of file_insert_clear_xoff */
X
X/*+-------------------------------------------------------------------------
X	file_insert_to_line(narg,arg)
X--------------------------------------------------------------------------*/
Xfile_insert_to_line(narg,arg)
Xint narg;
Xchar **arg;
X{
Xint itmp;
Xregister rchar;
Xint old_ttymode = get_ttymode();
Xlong total_chars = 0L;
Xlong total_lines = 0L;
Xulong colors_at_entry = colors_current;
Xlong timeout_msecs;
XFILE *fp;
Xchar file_string[256];
Xchar s256[256];
Xchar xmit_mode;
Xuchar delim;
X#ifdef USE_XON_XOFF
Xint ixon;
Xint ixoff;
X#endif
Xchar *make_char_graphic();
X
X	if(narg > 1)
X	{
X		strncpy(s256,arg[1],sizeof(s256));	
X		s256[sizeof(s256) - 1] = 0;
X	}
X	else
X	{
X		ff(se,"\r\n--> File to insert on comm line: ");
X		ttygets(s256,sizeof(s256),TG_CRLF,&delim,(int *)0);
X		if((delim == ESC) || !strlen(s256)) 
X		{
X			ff(se," --> transmission aborted\r\n");
X			return(0);
X		}
X	}
X	if((itmp = expand_filename(s256,sizeof(s256))) < 0)
X		return(-1);
X	else if(itmp)
X		ff(se,"\r\n--> wild card match: %s",s256);
X
X	if((fp = fopen(s256,"r")) == (FILE *)0)
X	{
X		ff(se,"\r\n--> ");
X		pperror(s256);			/* print error if we get one */
X		return(-1);
X	}
X
X	if(narg > 1)
X		ff(se,"\r\n");
X
X	if(narg > 2)
X		xmit_mode = *arg[2];
X	else
X	{
XASK_OPTION:
X		ff(se,"(S)ingle line at a time\r\n");
X		ff(se,"(E)cho pacing\r\n");
X		ff(se,"(F)ull speed transmission\r\n");
X		ff(se,"(P)aced transmission (20 msec/char)\r\n");
X		ff(se,"(Q)uit (or ESC)          press a key");
X		xmit_mode = ttygetc(0) & 0x7F;
X		if(xmit_mode > 0x20)
X			fputs(make_char_graphic(xmit_mode,0),se);
X		fputs("\r\n",se);
X	}
X
X	kill_rcvr_process(SIGUSR1);
X
X	switch(xmit_mode = to_lower(xmit_mode))
X	{
X		case 's':
X			setcolor(colors_alert);
X			fputs("--> press SPACE to continue or ESC/'s' to stop\r\n",se);
X			setcolor(colors_at_entry);
X			break;
X
X		case 'e':
X			/* fall through */
X
X		case 'f':
X		case 'p':
X			setcolor(colors_alert);
X			ff(se,"--> press %s to abort\r\n",make_char_graphic(kbdintr,0));
X			setcolor(colors_at_entry);
X			ttymode(2);
X			break;
X
X		case 'q':
X		case ESC:
X			goto INSERT_DONE2;
X
X		default:
X			ring_bell();
X			fputs("\r\n",se);
X			goto ASK_OPTION;
X	}
X
X#ifdef USE_XON_XOFF
X	lget_xon_xoff(&ixon,&ixoff);		/* get current line xon/xoff status */
X	lxon_xoff(IXON);					/* set it for us */
X#endif
X
X	sigint = 0;	/* reset SIGINT flag */
X	while(fgets(file_string,sizeof(file_string),fp))
X	{
X	int xmit_len = strlen(file_string);
X	int xmit_cr = xmit_len && (file_string[xmit_len - 1] == NL);
X
X		if(xmit_cr)
X		{
X			xmit_len--;
X			file_string[xmit_len] = 0;
X		}
X		total_chars += xmit_len;
X		total_lines++;
X
X/* some destinations, like BBS msg entry, take a blank line to mean
Xend of message, so do not send completely blank lines */
X		if(!xmit_len && xmit_cr)
X		{
X			lputc(' ');
X			xmit_len = 1;
X		}
X		else if(xmit_mode == 'p')
X		{
X		register char *cptr = file_string;
X			while(*cptr)
X			{
X				lputc(*cptr++);
X				nap(20L);
X				while(rdchk(shm->Liofd))
X				{
X					rchar = lgetc_xmtr();
X					process_xmtr_rcvd_char((char)rchar,1);
X				}
X			}
X		}
X		else
X			lputs(file_string);
X		if(xmit_cr)
X		{
X			if(xmit_mode == 'p')
X				nap(20L);
X			lputc('\r');
X			xmit_len++;
X		}
X
X		if(sigint)
X			break;
X
X		switch(xmit_mode)
X		{
X			case 's':
X				while(1)
X				{
X					if(rdchk(0))
X						break;
X					rchar = lgetc_timeout(5 * 1000L);
X					if(rchar < 0)
X						file_insert_clear_xoff();
X					else
X						process_xmtr_rcvd_char((char)rchar,1);
X					if(rchar == 0x0A)
X						break;
X				}
X				rchar = to_lower(ttygetc(1));
X				if((rchar == 's') || (rchar == ESC))
X					goto INSERT_DONE;
X				break;
X
X			case 'e':
X				timeout_msecs = 5 * 1000L;
X				while(1)
X				{
X					if(sigint)
X						break;
X					rchar = lgetc_timeout(timeout_msecs);
X					if(rchar < 0)
X					{
X						if(!xmit_len)
X							break;
X						file_insert_clear_xoff();
X						timeout_msecs = 1 * 1000L;
X					}
X					else
X					{
X						process_xmtr_rcvd_char((char)rchar,1);
X						timeout_msecs = 100L;
X						if(xmit_len)
X							xmit_len--;
X					}
X					if(rchar == 0x0A)
X						break;
X				}
X				break;
X
X			case 'f':
X			case 'p':
X				while(rdchk(shm->Liofd))
X				{
X					rchar = lgetc_xmtr();
X					process_xmtr_rcvd_char((char)rchar,1);
X				}
X				break;
X		}
X		if(sigint)
X			break;
X	}
X
XINSERT_DONE:
X
X	if(sigint)
X	{
X		setcolor(colors_error);
X		ff(se,"--> Interrupted\r\n");
X		setcolor(colors_at_entry);
X	}
X
XINSERT_DONE2:
X
X	fclose(fp);
X
X	ttymode(old_ttymode);		/* restore old console mode */
X	sigint = 0;				/* reset SIGINT flag */
X
X	while(((rchar = lgetc_timeout(200L)) > 0) && !sigint)
X		process_xmtr_rcvd_char((char)rchar,1);
X
X	setcolor(colors_success);
X	ff(se,"\r\n-->  done ... sent %ld lines, %ld characters\r\n",
X				total_lines,total_chars);
X	setcolor(colors_at_entry);
X	lclear_xmtr_xoff();
X#ifdef USE_XON_XOFF
X	lxon_xoff(ixon | ixoff);	/* restore old line xon/xoff status */
X#endif
X	start_rcvr_process(1);
X	return(0);
X
X}	/* end of file_insert_to_line */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of ecufinsert.c */
SHAR_EOF
$TOUCH -am 0725125591 'ecufinsert.c' &&
chmod 0644 ecufinsert.c ||
echo 'restore of ecufinsert.c failed'
Wc_c="`wc -c < 'ecufinsert.c'`"
test 7178 -eq "$Wc_c" ||
	echo 'ecufinsert.c: original size 7178, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= ecufkey.c ==============
if test -f 'ecufkey.c' -a X"$1" != X"-c"; then
	echo 'x - skipping ecufkey.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting ecufkey.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'ecufkey.c' &&
X/*+-----------------------------------------------------------------
X	ecufkey.c -- function key definition
X	wht@n4hgf.Mt-Park.GA.US
X
X  Defined functions:
X	ffso(str)
X	kde_fgets(buf,bufsize,fp)
X	keyset_define_key(bufptr)
X	keyset_display()
X	keyset_idnum(keystr)
X	keyset_idstr(KDEt)
X	keyset_init()
X	keyset_read(name)
X	xf_to_KDEt(xf)
X
XI had a problem with gcc 1.39 when I added -fcall-used-...  in
Xthat the assembler code generated for keyset_display() had a
Xsyntax error When it blows up, I did:
X
X  make
X    ecufkey.c:
X    aline: syntax error in line blah
X  make -n ecufkey.o > tmp
X  edit tmp to add -S after -c
X  source tmp  -or-  . tmp
X  as ecufkey.s
X    aline: syntax error in line blah
X  edit ecufkey.s, find line blah,
X    change movl operand from '.Lxxx' to '$.Lxxx'
X  as ecufkey.s
X  make --- resume normal making
X
Xso it must be a little boog. There's a workaround in place ( using
Xa function in ecuutil.c, a separate compilation unit).
X
XGCC 1.40 fixed the bug, so #ifdef GCC140, don't use the kludge.
X------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:55-wht@n4hgf-ECU release 3.10 */
X/*:07-12-1991-13:57-wht@n4hgf-GCC140 fix update */
X/*:05-21-1991-00:45-wht@n4hgf-added -3 error code to keyset_read */
X/*:05-21-1991-00:37-wht@n4hgf-improve fkey load error detection */
X/*:05-16-1991-15:05-wht@n4hgf-gcc binary exploded in keyset_display */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#include "ecu.h"
X#include "ecukey.h"
X#include "ecufkey.h"
X#include "ecuxkey.h"
X#include "ecufork.h"
X
Xextern char kbdintr;	/* current input INTR */
SHAR_EOF
true || echo 'restore of ecufkey.c failed'
fi
echo 'End of ecu310 part 4'
echo 'File ecufkey.c is continued in part 5'
echo 5 > _shar_seq_.tmp
exit 0
--------------------------------------------------------------------
Warren Tucker, TuckerWare emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
Hacker Extraordinaire  d' async PADs,  pods,  proteins and protocols

exit 0 # Just in case...
-- 
Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
Sterling Software, IMD           UUCP:     uunet!sparky!kent
Phone:    (402) 291-8300         FAX:      (402) 291-4362
Please send comp.sources.misc-related mail to kent@uunet.uu.net.


