From pa.dec.com!decwrl!olivea!uunet!sparky!kent Sun Aug 11 15:42:42 PDT 1991
Article: 2579 of comp.sources.misc
Path: pa.dec.com!decwrl!olivea!uunet!sparky!kent
From: wht@n4hgf.Mt-Park.GA.US (Warren Tucker)
Newsgroups: comp.sources.misc
Subject: v21i069:  ecu - ECU async comm package rev 3.10, Part17/37
Message-ID: <1991Aug4.015850.9156@sparky.IMD.Sterling.COM>
Date: 4 Aug 91 01:58:50 GMT
References: <csm-v21i053=ecu.215539@sparky.imd.sterling.com>
Sender: kent@sparky.IMD.Sterling.COM (Kent Landfield)
Organization: Sterling Software, IMD
Lines: 2356
Approved: kent@sparky.imd.sterling.com
X-Md4-Signature: 1e29e3d2feb4db23702e8e7d68082877

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

---- Cut Here and feed the following to sh ----
#!/bin/sh
# this is ecu310.17 (part 17 of ecu310)
# do not concatenate these parts, unpack them in order with /bin/sh
# file pcmdif.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" != 17; 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 pcmdif.c'
else
echo 'x - continuing file pcmdif.c'
sed 's/^X//' << 'SHAR_EOF' >> 'pcmdif.c' &&
X	erc = eInvalidLogicOp;
X	if(!strncmp(cptr,"&&",2))
X	{
X		*op_returned = OP_AND;
X		erc = 0;
X	}
X	else if(!strncmp(cptr,"||",2))
X	{
X		*op_returned = OP_OR;
X		erc = 0;
X	}
X	if(!erc)
X		param->index += 2;
X	return(erc);
X
X}	/* end of get_logicop */
X
X/*+-------------------------------------------------------------------------
X	test_truth_int(int1,relop,int2)
X--------------------------------------------------------------------------*/
Xint
Xtest_truth_int(int1,relop,int2)
Xlong int1;
Xint relop;
Xlong int2;
X{
Xregister truth = 0;
X
X	switch(relop)
X	{
X	case OP_EQ:
X		truth = (int1 == int2);
X		break;
X	case OP_NE:
X		truth = (int1 != int2);
X		break;
X	case OP_GT:
X		truth = (int1 > int2);
X		break;
X	case OP_LT:
X		truth = (int1 < int2);
X		break;
X	case OP_GE:
X		truth = (int1 >= int2);
X		break;
X	case OP_LE:
X		truth = (int1 <= int2);
X		break;
X	}
X	return(truth);
X
X}	/* end of test_truth_int */
X
X/*+-------------------------------------------------------------------------
X	get_truth_int(param,truth)
X--------------------------------------------------------------------------*/
Xint
Xget_truth_int(param,truth)
XESD *param;
Xint *truth;
X{
Xregister erc;
Xlong int1;
Xlong int2;
Xint operator;
Xint truth2;
X
X	if(erc = gint(param,&int1))
X		return(erc);
X	if(erc = get_relop(param,&operator))
X		return(erc);
X	if(erc = gint(param,&int2))
X		return(erc);
X	*truth = test_truth_int(int1,operator,int2);
X
X	while(!get_logicop(param,&operator))
X	{
X		if(erc = get_truth_int(param,&truth2))
X			return(erc);
X		switch(operator)
X		{
X			case OP_AND:
X				*truth &= truth2;
X				break;
X
X			case OP_OR:
X				*truth |= truth2;
X				break;
X		}
X	}
X	return(0);
X
X}	/* end of get_truth_int */
X
X/*+-------------------------------------------------------------------------
X    get_truth_str(param,truth)
X--------------------------------------------------------------------------*/
Xint
Xget_truth_str(param,truth)
XESD *param;
Xint *truth;
X{
Xregister erc;
XESD *tesd1 = (ESD *)0;
XESD *tesd2 = (ESD *)0;
Xint operator;
Xint strcmp_result;
Xint truth2;
X
X	if(!(tesd1 = esdalloc(256)) || !(tesd2 = esdalloc(256)))
X	{
X		erc = eNoMemory;
X		goto RETURN;
X	}	
X
X	if(erc = gstr(param,tesd1,1))
X		goto RETURN;
X	if(erc = get_relop(param,&operator))
X		goto RETURN;
X	if(erc = gstr(param,tesd2,1))
X		goto RETURN;
X
X	strcmp_result = strcmp(tesd1->pb,tesd2->pb);
X
X	switch(operator)
X	{
X		case OP_EQ:
X			*truth = (strcmp_result == 0);
X			break;
X		case OP_NE:
X			*truth = (strcmp_result != 0);
X			break;
X		case OP_GT:
X			*truth = (strcmp_result > 0);
X			break;
X		case OP_LT:
X			*truth = (strcmp_result < 0);
X			break;
X		case OP_GE:
X			*truth = (strcmp_result >= 0);
X			break;
X		case OP_LE:
X			*truth = (strcmp_result <= 0);
X			break;
X		default:
X			return(eInvalidStrOp);
X	}
X
X	while(!get_logicop(param,&operator))
X	{
X		if(erc = get_truth_str(param,&truth2))
X			return(erc);
X		switch(operator)
X		{
X			case OP_AND:
X				*truth &= truth2;
X				break;
X
X			case OP_OR:
X				*truth |= truth2;
X				break;
X		}
X	}
X
X	erc = 0;
X
XRETURN:
X	if(tesd1)
X		esdfree(tesd1);
X	if(tesd2)
X		esdfree(tesd2);
X	return(erc);
X
X}   /* end of get_truth_str */
X
X/*+-------------------------------------------------------------------------
X	_if_common(param,truth)
X--------------------------------------------------------------------------*/
Xint
X_if_common(param,truth)
XESD *param;
Xint truth;
X{
Xregister erc = 0;
Xchar s80[80];
XPCB *pcb;
XESD *else_line;
Xint label_on_else_line;
Xint truth2;
Xint save_index;
Xlong int1;
X
X	if(proctrace > 1)
X	{
X		pprintf("if condition %s",(truth) ? "TRUE: " : "FALSE\n");
X		if(truth)
X		{
X			skip_cmd_break(param);
X			pputs(param->pb + param->index);
X			pputc('\n');
X		}
X	}
X
X	truth_already[if_level] = truth;
X
X/* if end of command, execute frame else conditionally execute rest of esd */
X	s80[0] = 0;
X	if(end_of_cmd(param))
X		erc = execute_frame(truth);
X	else if(truth)
X		erc = execute_esd(param);
X	else
X		param->index = param->cb;
X
X	if(erc)
X		return(erc);
X
X/* check for else statement */
X	pcb = pcb_stack[proc_level - 1];
X	if(!pcb->current->next)		/* if no next line, no "else" */
X		return(0);
X
X	else_line = pcb->current->next->text;
X	else_line->index = else_line->old_index = 0;
X	if(label_on_else_line = (*else_line->pb != 0x20))
X	{	/* strip label */
X		if(get_alphanum_zstr(else_line,s80,sizeof(s80)))
X			return(eInvalidLabel);
X	}
X	if(get_alphanum_zstr(else_line,s80,sizeof(s80)))
X		return(0);		/* not "else" */
X	if(strcmp(s80,"else"))
X		return(0);		/* not "else" */
X	if(label_on_else_line)
X	{
X		else_line->old_index = 0;
X		pputs("label not allowed on else statement\n");
X		return(eFATAL_ALREADY);
X	}
X
X/* we have an "else" condition */
X	truth = !truth;
X	pcb->current = pcb->current->next;
X
X	trace_proc_cmd(pcb);
X
X	if(end_of_cmd(else_line))
X		erc = execute_frame(truth);
X	else
X	{
X		save_index = else_line->old_index = else_line->index;
X		s80[0] = 0;
X		if((*(else_line->pb + else_line->index) != '$') &&
X			get_alpha_zstr(else_line,s80,sizeof(s80)))
X		{
X			pputs("illegal command after 'else'\n");
X			return(eFATAL_ALREADY);
X		}
X		if(!strcmp(s80,"ifi"))
X		{
X			if(erc = get_truth_int(else_line,&truth2))
X				return(erc);
X			erc = _if_common(else_line,!truth_already[if_level] & truth2);
X			truth_already[if_level] |= truth2;
X		}
X		else if(!strcmp(s80,"ifs"))
X		{
X			if(erc = get_truth_str(else_line,&truth2))
X				return(erc);
X			erc = _if_common(else_line,!truth_already[if_level] & truth2);
X			truth_already[if_level] |= truth2;
X		}
X		else if(!strcmp(s80,"ifz"))
X		{
X			if(erc = gint(else_line,&int1))
X				return(erc);
X			truth2 = test_truth_int(int1,OP_EQ,0L);
X			erc = _if_common(else_line,!truth_already[if_level] & truth2);
X			truth_already[if_level] |= truth2;
X		}
X		else if(!strcmp(s80,"ifnz"))
X		{
X			if(erc = gint(else_line,&int1))
X				return(erc);
X			truth2 = test_truth_int(int1,OP_NE,0L);
X			erc = _if_common(else_line,!truth_already[if_level] & truth2);
X			truth_already[if_level] |= truth2;
X		}
X		else if(!strcmp(s80,"iflt"))
X		{
X			if(erc = gint(else_line,&int1))
X				return(erc);
X			truth2 = test_truth_int(int1,OP_LT,0L);
X			erc = _if_common(else_line,!truth_already[if_level] & truth2);
X			truth_already[if_level] |= truth2;
X		}
X		else if(!strcmp(s80,"ifle"))
X		{
X			if(erc = gint(else_line,&int1))
X				return(erc);
X			truth2 = test_truth_int(int1,OP_LE,0L);
X			erc = _if_common(else_line,!truth_already[if_level] & truth2);
X			truth_already[if_level] |= truth2;
X		}
X		else if(!strcmp(s80,"ifgt"))
X		{
X			if(erc = gint(else_line,&int1))
X				return(erc);
X			truth2 = test_truth_int(int1,OP_GT,0L);
X			erc = _if_common(else_line,!truth_already[if_level] & truth2);
X			truth_already[if_level] |= truth2;
X		}
X		else if(!strcmp(s80,"ifge"))
X		{
X			if(erc = gint(else_line,&int1))
X				return(erc);
X			truth2 = test_truth_int(int1,OP_GE,0L);
X			erc = _if_common(else_line,!truth_already[if_level] & truth2);
X			truth_already[if_level] |= truth2;
X		}
X		else if(!strncmp(s80,"while",5))
X		{
X			pputs("'while' command not allowed as 'else' conditional\n");
X			return(eFATAL_ALREADY);
X		}
X		else
X		{
X			else_line->index = save_index;
X			if(truth)
X				erc = execute_esd(else_line);
X		}
X	}
X
X	return(erc);
X}	/* end of _if_common */
X
X/*+-------------------------------------------------------------------------
X    pcmd_ifi(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_ifi(param)
XESD *param;
X{
Xregister erc;
Xint truth;
X
X	if(!proc_level)
X		return(eNotExecutingProc);
X
X	if(if_level == MAX_IF)
X	{
X		pputs("if statements nested too deeply\n");
X		return(eFATAL_ALREADY);
X	}
X	if_level++;
X	truth_already[if_level] = 0;
X
X	if(!(erc = get_truth_int(param,&truth)))
X		erc = _if_common(param,truth);
X	if_level--;
X	return(erc);
X
X}   /* end of pcmd_ifi */
X
X/*+-------------------------------------------------------------------------
X	_cmd_ifrel_common(param,relop)
X--------------------------------------------------------------------------*/
Xint
X_cmd_ifrel_common(param,relop)
XESD *param;
Xint relop;
X{
Xregister erc;
Xint truth;
Xlong int1;
X
X	if(!proc_level)
X		return(eNotExecutingProc);
X
X	if(if_level == MAX_IF)
X	{
X		pputs("if statements nested too deeply\n");
X		return(eFATAL_ALREADY);
X	}
X	if_level++;
X	truth_already[if_level] = 0;
X
X	if(erc = gint(param,&int1))
X		return(erc);
X	truth = test_truth_int(int1,relop,0L);
X	erc = _if_common(param,truth);
X	if_level--;
X	return(erc);
X
X}	/* end of _cmd_ifrel_common */
X
X/*+-------------------------------------------------------------------------
X	pcmd_ifz(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_ifz(param)
XESD *param;
X{
X	return(_cmd_ifrel_common(param,OP_EQ));
X}	/* end of pcmd_ifz */
X
X/*+-------------------------------------------------------------------------
X	pcmd_ifnz(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_ifnz(param)
XESD *param;
X{
X	return(_cmd_ifrel_common(param,OP_NE));
X}	/* end of pcmd_ifnz */
X
X/*+-------------------------------------------------------------------------
X	pcmd_ifle(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_ifle(param)
XESD *param;
X{
X	return(_cmd_ifrel_common(param,OP_LE));
X}	/* end of pcmd_ifle */
X
X/*+-------------------------------------------------------------------------
X	pcmd_ifge(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_ifge(param)
XESD *param;
X{
X	return(_cmd_ifrel_common(param,OP_GE));
X}	/* end of pcmd_ifge */
X
X/*+-------------------------------------------------------------------------
X	pcmd_iflt(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_iflt(param)
XESD *param;
X{
X	return(_cmd_ifrel_common(param,OP_LT));
X}	/* end of pcmd_iflt */
X
X/*+-------------------------------------------------------------------------
X	pcmd_ifgt(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_ifgt(param)
XESD *param;
X{
X	return(_cmd_ifrel_common(param,OP_GT));
X}	/* end of pcmd_ifgt */
X
X/*+-------------------------------------------------------------------------
X    pcmd_ifs(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_ifs(param)
XESD *param;
X{
Xregister erc;
Xint truth;
X
X	if(!proc_level)
X		return(eNotExecutingProc);
X
X	if(if_level == MAX_IF)
X	{
X		pputs("if statements nested too deeply\n");
X		return(eFATAL_ALREADY);
X	}
X	if_level++;
X	truth_already[if_level] = 0;
X
X	if(!(erc = get_truth_str(param,&truth)))
X		erc = _if_common(param,truth);
X	if_level--;
X	return(erc);
X
X}   /* end of pcmd_ifs */
X
X/*+-------------------------------------------------------------------------
X	pcmd_else(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_else(param)
XESD *param;
X{
X	return(eElseCommand);
X}	/* end of pcmd_else */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of pcmdif.c */
SHAR_EOF
echo 'File pcmdif.c is complete' &&
$TOUCH -am 0725125991 'pcmdif.c' &&
chmod 0644 pcmdif.c ||
echo 'restore of pcmdif.c failed'
Wc_c="`wc -c < 'pcmdif.c'`"
test 13866 -eq "$Wc_c" ||
	echo 'pcmdif.c: original size 13866, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= pcmdtty.c ==============
if test -f 'pcmdtty.c' -a X"$1" != X"-c"; then
	echo 'x - skipping pcmdtty.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting pcmdtty.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'pcmdtty.c' &&
X/*+-------------------------------------------------------------------------
X	pcmdtty.c - tty (console) related procedure commands
X	wht@n4hgf.Mt-Park.GA.US
X
X  Defined functions:
X	pcmd_cls(param)
X	pcmd_color(param)
X	pcmd_cursor(param)
X	pcmd_delline(param)
X	pcmd_eeol(param)
X	pcmd_fkey(param)
X	pcmd_home(param)
X	pcmd_icolor(param)
X	pcmd_insline(param)
X	pcmd_scrdump(param)
X	pcmd_vidcolor(param)
X	pcmd_vidnorm(param)
X	pcmd_vidrev(param)
X	ifunc_colors(pvalue)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
X/*:05-21-1991-00:45-wht@n4hgf-added -3 error code to keyset_read */
X/*:01-23-1991-01:58-wht@n4hgf-illegal color name make hi_white on hi_white */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#include "ecu.h"
X#include "ecuerror.h"
X#include "esd.h"
X#include "ecutty.h"
X
Xextern int proctrace;
Xextern ulong colors_current;
X
X/*+-------------------------------------------------------------------------
X	pcmd_color(param)
X
XUsage:   color [-r] [argument] [argument]
XOptions:
X   color color      Set foreground and background normal video colors
X   -r color color   Set foreground & background reverse video colors
X
XColor names
X   blue      magenta      brown      black
X   lt_blue   lt_magenta   yellow     gray
X   cyan      white        green      red
X   lt_cyan   hi_white     lt_green   lt_red
X
X--------------------------------------------------------------------------*/
Xpcmd_color(param)
XESD *param;
X{
Xregister erc;
Xchar switches[8];
Xint normal;
Xchar s32[32];
Xulong foreground;
Xulong background;
X
X	get_switches(param,switches,sizeof(switches));
X	if(!strlen(switches))
X		normal = 1;
X	else if(switches[1] == 'r')
X		normal = 0;		/* reverse */
X	else
X	{
X		pputs("unrecognized switch\n");
X		return(eFATAL_ALREADY);
X	}
X
X	if((erc = get_alpha_zstr(param,s32,sizeof(s32))) ||
X			((int)(foreground = color_name_to_num(s32)) < 0))
X		goto ERROR;
X
X	if(erc = get_alpha_zstr(param,s32,sizeof(s32)))
X	{
X		if(!end_of_cmd(param))
X			goto ERROR;
X		background = 0;
X	}
X	else if((int)(background = color_name_to_num(s32)) < 0)
X		goto ERROR;
X
X	if(normal)
X	{
X		colors_current &= 0xFFFF0000;
X		colors_current |= (foreground << 8) | background;
X		if(proctrace > 1)
X		{
X			pprintf("normal %ld,%ld current=0x%08lx\n",
X				foreground,background,colors_current);
X		}
X	}
X	else
X	{
X		colors_current &= 0x0000FFFF;
X		colors_current |= (foreground << 24) | (background << 16);
X		if(proctrace > 1)
X		{
X			pprintf("reverse %ld,%ld current=0x%08lx\n",
X				foreground,background,colors_current);
X		}
X	}
X
X	setcolor(colors_current);
X	return(0);
X
XERROR:
X	if(erc)
X		return(erc);
X	pputs("invalid color\n");
X	return(eFATAL_ALREADY);
X
X}	/* end of pcmd_color */
X
X/*+-------------------------------------------------------------------------
X	ifunc_colors(pvalue)
X--------------------------------------------------------------------------*/
Xint
Xifunc_colors(pvalue)
Xulong *pvalue;
X{
X	*pvalue = colors_current;
X	return(0);
X}	/* end of ifunc_colors */
X
X/*+-------------------------------------------------------------------------
X	pcmd_icolor(param)
X--------------------------------------------------------------------------*/
Xpcmd_icolor(param)
XESD *param;
X{
Xint erc;
Xulong new_colors;
X
X	if(erc = gint(param,&new_colors))
X		return(erc);
X
X	setcolor(new_colors);
X	return(0);
X}	/* end of pcmd_icolor */
X
X/*+-------------------------------------------------------------------------
X	pcmd_cls(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_cls(param)
XESD *param;
X{
X	tcap_clear_screen();
X	return(0);
X}	/* end of pcmd_cls */
X
X/*+-------------------------------------------------------------------------
X	pcmd_cursor(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_cursor(param)
XESD *param;
X{
Xint erc;
Xlong row;
Xlong col = 0;
X
X	if(erc = gint(param,&row))
X		return(erc);
X	if(gint(param,&col))
X	{
X		/* if something there non-integer */
X		if(!end_of_cmd(param))
X			return(eSyntaxError);
X	}
X	tcap_cursor((int)row,(int)col);
X	return(0);
X}	/* end of pcmd_cursor */
X
X/*+-------------------------------------------------------------------------
X	pcmd_scrdump(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_scrdump(param)
XESD *param;
X{
Xint erc;
XESD *fname;
XFILE *fp;
X
X	if((fname = esdalloc(256)) == (ESD *)0)
X		return(eNoMemory);
X
X	if(erc = gstr(param,fname,1))
X	{
X		if(!end_of_cmd(param))
X		{
X			erc = eSyntaxError;
X			goto RETURN;
X		}
X	}
X
X	if(fname->cb)
X	{
X		if((fp = fopen(fname->pb,"a")) == NULL)
X		{
X			pperror(fname->pb);
X			erc = eFATAL_ALREADY;
X			goto RETURN;
X		}
X		fclose(fp);
X	}
X
X	screen_dump((fname->cb) ? fname->pb : (char *)0);
X
XRETURN:
X	esdfree(fname);
X	return(erc);
X}	/* end of pcmd_scrdump */
X
X/*+-------------------------------------------------------------------------
X	pcmd_vidnorm(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_vidnorm(param)
XESD *param;
X{
X	tcap_stand_end();
X	return(0);
X}	/* end of pcmd_vidnorm */
X
X/*+-------------------------------------------------------------------------
X	pcmd_vidrev(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_vidrev(param)
XESD *param;
X{
X	tcap_stand_out();
X	return(0);
X}	/* end of pcmd_vidrev */
X
X/*+-------------------------------------------------------------------------
X	pcmd_fkey(param)
X--------------------------------------------------------------------------*/
Xpcmd_fkey(param)
XESD *param;
X{
Xint erc;
XESD *tesd;
X
X	if((tesd = esdalloc(64)) == (ESD *)0)
X		return(eNoMemory);
X
X	if(erc = gstr(param,tesd,0))
X		goto RETURN;
X
X	switch(keyset_read(tesd->pb))
X	{
X		case  0:
X			if(proctrace)
X				keyset_display();
X			break;
X		case -1:
X			pprintf("cannot find ~/.ecu/keys\n");
X			erc = eFATAL_ALREADY;
X			break;
X		case -2:
X			pprintf("'%s' not found in ~/.ecu/keys\n",tesd->pb);
X			erc = eFATAL_ALREADY;
X			break;
X		case -3:
X			pprintf("'%s' has a syntax error\n",tesd->pb);
X			erc = eFATAL_ALREADY;
X			break;
X	}
X
XRETURN:
X	esdfree(tesd);
X	return(erc);
X}	/* end of pcmd_fkey */
X
X/*+-------------------------------------------------------------------------
X	pcmd_vidcolor(param)
X
Xvidcolor normal|reverse|notify|success|alert|error fcolor [bcolor]
X--------------------------------------------------------------------------*/
Xint
Xpcmd_vidcolor(param)
XESD *param;
X{
Xint erc;
Xint ntokens = 0;
Xchar *tokens[3];
Xint param_index[3];
Xchar tokenbuf[64];
X
X	tokens[0] = tokenbuf;
X	tokens[1] = tokenbuf + 20;
X	tokens[2] = tokenbuf + 40;
X
X	while(ntokens < 3)
X	{
X		skip_cmd_break(param);
X		param_index[ntokens] = param->index;
X		if(erc = get_word_zstr(param,tokens[ntokens],20))
X			break;
X		ntokens++;
X	}
X
X	if(erc && ((erc != eNoParameter) || (ntokens < 2)))
X		return(erc);
X
X	switch(erc = setcolor_internal(ntokens,tokens))
X	{
X		case 0:
X			break;
X		default:
X			param->old_index = param->index = param_index[erc - 1];
X			erc = eBadParameter;
X	}
X	return(erc);
X}	/* end of pcmd_vidcolor */
X
X/*+-------------------------------------------------------------------------
X	pcmd_home(param) - home the cursor
X--------------------------------------------------------------------------*/
Xint
Xpcmd_home(param)
XESD *param;
X{
X	tcap_cursor(0,0);
X	return(0);
X}	/* end of pcmd_home */
X
X/*+-------------------------------------------------------------------------
X	pcmd_eeol(param) - erase to end of line
X--------------------------------------------------------------------------*/
Xint
Xpcmd_eeol(param)
XESD *param;
X{
X	tcap_eeol();
X	return(0);
X}	/* end of pcmd_eeol */
X
X/*+-------------------------------------------------------------------------
X	pcmd_insline(param) - insert line in display
X--------------------------------------------------------------------------*/
Xint
Xpcmd_insline(param)
XESD *param;
X{
X	tcap_insert_lines(1);
X	return(0);
X}	/* end of pcmd_insline */
X
X/*+-------------------------------------------------------------------------
X	pcmd_delline(param) - delete line from display
X--------------------------------------------------------------------------*/
Xint
Xpcmd_delline(param)
XESD *param;
X{
X	tcap_delete_lines(1);
X	return(0);
X}	/* end of pcmd_delline */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of pcmdtty.c */
SHAR_EOF
$TOUCH -am 0725125991 'pcmdtty.c' &&
chmod 0644 pcmdtty.c ||
echo 'restore of pcmdtty.c failed'
Wc_c="`wc -c < 'pcmdtty.c'`"
test 8241 -eq "$Wc_c" ||
	echo 'pcmdtty.c: original size 8241, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= pcmdwhile.c ==============
if test -f 'pcmdwhile.c' -a X"$1" != X"-c"; then
	echo 'x - skipping pcmdwhile.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting pcmdwhile.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'pcmdwhile.c' &&
X/*+-------------------------------------------------------------------------
X	pcmdwhile.c - ecu while procedure commands
X	wht@n4hgf.Mt-Park.GA.US
X
X    WHILEI $i0 rel-op $i1 cmd
X    WHILES $s0 rel-op $s1 cmd
X
X    where rel-op is "=", "==", "!=", "<>", ">", "<", ">=", "=<"
X
X  Defined functions:
X	pcmd_whilei(param)
X	pcmd_whiles(param)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X#include <ctype.h>
X#include "ecu.h"
X#include "ecuerror.h"
X#include "esd.h"
X#include "var.h"
X#include "proc.h"
X#include "relop.h"
X
Xextern PCB *pcb_stack[];
Xextern int proc_level;
X
X/*+-------------------------------------------------------------------------
X    pcmd_whilei(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_whilei(param)
XESD *param;
X{
Xregister erc;
Xint truth;
XPCB *pcb;
XLCB *condition_lcb;
Xint condition_index = param->index;
X
X	if(!proc_level)
X		return(eNotExecutingProc);
X
X	pcb = pcb_stack[proc_level - 1];
X	condition_lcb = pcb->current;
X
XREPEAT_WHILE:
X
X	if(erc = get_truth_int(param,&truth))
X		return(erc);
X
X/* if end of command, execute frame */
X	if(end_of_cmd(param))
X	{
X		if(erc = execute_frame(truth))
X		{
X			if(erc == eContinueCommand)
X				goto CONTINUE;
X			if(erc == eBreakCommand)
X				erc = 0;
X			return(erc);
X		}
X	}
X	else if(truth)
X	{
X		if(erc = execute_esd(param))
X			return(erc);
X	}
X
X/* repeat if indicated */
XCONTINUE:
X	if(truth)
X	{
X		pcb->current = condition_lcb;
X		param->index = param->old_index = condition_index;
X		goto REPEAT_WHILE;
X	}
X
X	return(0);
X}   /* end of pcmd_whilei */
X
X/*+-------------------------------------------------------------------------
X    pcmd_whiles(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_whiles(param)
XESD *param;
X{
Xregister erc;
Xint truth;
XPCB *pcb;
XLCB *condition_lcb;
Xint condition_index = param->index;
X
X	if(!proc_level)
X		return(eNotExecutingProc);
X
X	pcb = pcb_stack[proc_level - 1];
X	condition_lcb = pcb->current;
X
XREPEAT_WHILE:
X
X	if(erc = get_truth_str(param,&truth))
X		return(erc);
X
X/* if end of command, execute frame */
X	if(end_of_cmd(param))
X	{
X		if(erc = execute_frame(truth))
X		{
X			if(erc == eContinueCommand)
X				goto CONTINUE;
X			if(erc == eBreakCommand)
X				erc = 0;
X			return(erc);
X		}
X	}
X	else if(truth)
X	{
X		if(erc = execute_esd(param))
X			return(erc);
X	}
X
X/* repeat if indicated */
XCONTINUE:
X	if(truth)
X	{
X		pcb->current = condition_lcb;
X		param->index = param->old_index = condition_index;
X		goto REPEAT_WHILE;
X	}
X
X	return(0);
X}   /* end of pcmd_whiles */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of pcmdwhile.c */
SHAR_EOF
$TOUCH -am 0725125991 'pcmdwhile.c' &&
chmod 0644 pcmdwhile.c ||
echo 'restore of pcmdwhile.c failed'
Wc_c="`wc -c < 'pcmdwhile.c'`"
test 2736 -eq "$Wc_c" ||
	echo 'pcmdwhile.c: original size 2736, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= pcmdxfer.c ==============
if test -f 'pcmdxfer.c' -a X"$1" != X"-c"; then
	echo 'x - skipping pcmdxfer.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting pcmdxfer.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'pcmdxfer.c' &&
X/*+-------------------------------------------------------------------------
X	pcmdxfer.c - ecu file transfer related procedure commands
X	wht@n4hgf.Mt-Park.GA.US
X
X  Defined functions:
X	_adjust_erc_and_iv0(adj_erc)
X	_make_bottom_label(param,default_flag,sending_flag)
X	_pcmd_report_send_status()
X	_smart_sender_common(cmd)
X	pcmd_rk(param)
X	pcmd_rs(param)
X	pcmd_rx(param)
X	pcmd_ry(param)
X	pcmd_rz(param)
X	pcmd_sk(param)
X	pcmd_ss(param)
X	pcmd_sx(param)
X	pcmd_sy(param)
X	pcmd_sz(param)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
X/*:04-23-1991-23:44-wht@n4hgf-big time overhaul - better but flames expected */
X/*:04-23-1991-05:10-wht@n4hgf-new cmd build mechanism for long file lists */
X/*:01-17-1991-17:01-wht@n4hgf-skipped files in sz aborted proc */
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 "ecuerror.h"
X#include "esd.h"
X#include "var.h"
X#include "proc.h"
X
X/*
X * file transmission command and pathname list ESD initial size
X * (lengths can grow to ESD_MAXSIZE)
X */
X#define CMDESD_INITIAL_SIZE  384 /* executable command initial size */
X#define PATHESD_INITIAL_SIZE 256 /* pathname list initial size */
X#define CMDSTR_SIZE          384 /* receive command string size */
X
Xextern int proctrace;
Xextern int last_child_wait_status;
Xextern char curr_dir[CURR_DIRSIZ];
X
Xstatic char bottom_label[80];
X
X/*+-------------------------------------------------------------------------
X	_make_bottom_label(param,default_flag)
X--------------------------------------------------------------------------*/
Xint
X_make_bottom_label(param,default_flag,sending_flag)
XESD *param;
Xint default_flag;
Xint sending_flag;
X{
Xregister erc;
XESD *label = (ESD *)0;
X
X	if(default_flag)
X	{
X		sprintf(bottom_label,
X			(sending_flag) ? "-C \"'Connected to %s'\" "
X			               : "-C 'Connected to %s' ",
X			(shm->Lrname[0]) ? shm->Lrname : "?");
X		return(0);
X	}
X	if((label = esdalloc(64)) == (ESD *)0)
X		return(eNoMemory);
X	if(erc = gstr(param,label,0))
X	{
X		esdfree(label);
X		return(erc);
X	}
X	strcpy(bottom_label,(sending_flag) ? "-C \"'" : "-C '");
X	strcat(bottom_label,label->pb);
X	strcat(bottom_label,(sending_flag) ? "'\"" : "'");
X	esdfree(label);
X	return(0);
X
X}	/* end of _make_bottom_label */
X
X/*+-------------------------------------------------------------------------
X	_adjust_erc_and_iv0(adj_erc)
X--------------------------------------------------------------------------*/
Xint
X_adjust_erc_and_iv0(adj_erc)
Xint adj_erc;
X{
X
X	if(adj_erc)
X		return(adj_erc);
X
X	iv[0] = (last_child_wait_status & 0xFF)
X			? 0x100L : (long)((last_child_wait_status >> 8) & 0xFFFF);
X
X	if(proctrace)
X		pprintf("$i00 = %ld (transfer %s)\n",iv[0],
X			(iv[0] == 0x100L) ? "interrupted" : "program exit status");
X
X	return(0);
X
X}	/* end of _adjust_erc_and_iv0 */
X
X/*+-------------------------------------------------------------------------
X	_pcmd_report_send_status() - report file transmission result
X
Xfor "ecu knowledgeable" protocols only
Xreturns proc-type erc
X--------------------------------------------------------------------------*/
Xint
X_pcmd_report_send_status()
X{
Xregister ushort ustmp;
Xint erc = eFATAL_ALREADY;
Xint iv0_set = 0;
Xchar *signal_name_text();
X
X	ustmp = last_child_wait_status;
X	if((ustmp & 0xFF) == 0)	/* exit() called */
X	{
X		ustmp >>= 8;
X		if(!ustmp)
X		{
X			if(proctrace)
X				pputs("transfer successful\n");
X			erc = 0;
X		}
X		else if(ustmp == 255)
X			pputs("ecu error: transfer program usage error\n");
X		else if(ustmp == 254)
X		{
X			pputs(
X			"protocol failure: bad line conditions or remote not ready\n");
X		}
X		else if(ustmp == 253)
X			pputs("no requested files exist\n");
X		else if(ustmp < 128)
X		{
X			if(proctrace)
X			{
X				if(ustmp == 127)
X					pputs("127 or more files skipped\n");
X				else
X					pprintf("%u files rejected\n",ustmp);
X			}
X			iv[0] = (long)ustmp;
X			iv0_set = 1;
X			last_child_wait_status = 0;
X			erc = 0;
X		}
X		else
X		{
X			pprintf("transfer aborted by %s\n",signal_name_text(ustmp & 0x7F));
X			erc = eProcAttn_Interrupt;
X		}
X	}
X	else
X	{
X		pprintf("transfer killed by %s\n",signal_name_text(ustmp & 0x7F));
X		erc = eProcAttn_Interrupt;
X	}
X
X	if(!iv0_set)
X	{
X		iv[0] = (last_child_wait_status & 0xFF)
X			? 0x100L : (long)((last_child_wait_status >> 8) & 0xFFFF);
X	}
X
X	if(proctrace)
X		pprintf("$i00 = %ld (transfer %s)\n",iv[0],
X			(iv[0] == 0x100L) ? "interrupted" : "program exit status");
X
X	return(erc);
X
X}	/* end of _pcmd_report_send_status */
X
X/*+-------------------------------------------------------------------------
X	_smart_sender_common(cmd) - common exec and bottom processing
X
Xfor "ecu knowledgeable" protocols only
Xreturns proc-type erc
X--------------------------------------------------------------------------*/
Xint
X_smart_sender_common(cmd)
Xchar *cmd;
X{
Xint erc = 0;
X
X	last_child_wait_status = 0;
X	file_xfer_start();
X
X	if(find_shell_chars(cmd))
X	{
X	char *expcmd;
X
X		if(expand_wildcard_list(cmd,&expcmd))
X		{
X			pputs("No files match wildcard list\n");
X			iv[0] = -1;
X			return(0);
X		}
X		else
X		{
X			exec_cmd(expcmd);
X			erc = _pcmd_report_send_status();
X			free(expcmd);
X		}
X	}
X	else
X	{
X		exec_cmd(cmd);
X		erc = _pcmd_report_send_status();
X	}
X
X	lreset_ksr();
X	file_xfer_done_bell();
X
X	return(erc);
X
X}	/* end of _smart_sender_common */
X
X/*+-------------------------------------------------------------------------
X	pcmd_sx(param)
X
Xsx [-ak[l]] [<label-str>] <filelist-str>
X--------------------------------------------------------------------------*/
Xint
Xpcmd_sx(param)
XESD *param;
X{
Xint erc;
Xchar switches[8];
XESD *pathesd = (ESD *)0;
XESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
X
X	get_switches(param,switches,sizeof(switches));
X
X	if(erc = _make_bottom_label(param,!strchr(switches,'l'),1))
X		return(erc);
X
X	/*
X	 * build command at beginning of 'cmdesd' ESD
X	 */
X	sprintf(cmdesd->pb,"ecusz -X -. %d ",shm->Liofd);
X	strcat(cmdesd->pb,bottom_label);
X
X#if defined(WHT)	/* for testing */
X	if(strchr(switches,'p'))
X		strcat(cmdesd->pb,"-, ");
X#endif
X
X	if(strchr(switches,'a'))
X		strcat(cmdesd->pb,"-a ");
X
X	if(strchr(switches,'k'))
X		strcat(cmdesd->pb,"-k");
X
X	/*
X	 * update cmdesd esd
X	 */
X	cmdesd->cb = strlen(cmdesd->pb);
X
X	if(!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
X	{
X		erc = eNoMemory;
X		goto FREE_MEM_AND_EXIT;
X	}
X
X	/*
X	 * get list of pathnames to send
X	 */
X	if(erc = gstr(param,pathesd,1))
X		goto FREE_MEM_AND_EXIT;
X
X	/*
X	 * append filelist to command
X	 */
X	if(erc = esdcat(cmdesd,pathesd,1))
X		goto FREE_MEM_AND_EXIT;
X
X	/*
X	 * perform the operation
X	 */
X	erc = _smart_sender_common(cmdesd->pb);
X
XFREE_MEM_AND_EXIT:
X	if(pathesd)
X		esdfree(pathesd);
X	if(cmdesd)
X		esdfree(cmdesd);
X	return(erc);
X
X}	/* end of pcmd_sx */
X
X/*+-------------------------------------------------------------------------
X	pcmd_sy(param)
X
Xsy [-a[l]] [<label-str>] <filelist-str>
X--------------------------------------------------------------------------*/
Xint
Xpcmd_sy(param)
XESD *param;
X{
Xint erc;
Xchar switches[8];
XESD *pathesd = (ESD *)0;
XESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
X
X	get_switches(param,switches,sizeof(switches));
X
X	if(erc = _make_bottom_label(param,!strchr(switches,'l'),1))
X		return(erc);
X
X	/*
X	 * build command at beginning of 'cmdesd' ESD
X	 */
X	sprintf(cmdesd->pb,"ecusz -Y -. %d -k ",shm->Liofd);
X	strcat(cmdesd->pb,bottom_label);
X	if(strchr(switches,'a'))
X		strcat(cmdesd->pb,"-a ");
X	else
X		strcat(cmdesd->pb,"-b ");
X
X	/*
X	 * update cmdesd esd
X	 */
X	cmdesd->cb = strlen(cmdesd->pb);
X
X	if(!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
X	{
X		erc = eNoMemory;
X		goto FREE_MEM_AND_EXIT;
X	}
X
X	/*
X	 * get list of pathnames to send
X	 */
X	if(erc = gstr(param,pathesd,1))
X		goto FREE_MEM_AND_EXIT;
X
X	/*
X	 * append filelist to command
X	 */
X	if(erc = esdcat(cmdesd,pathesd,1))
X		goto FREE_MEM_AND_EXIT;
X
X	/*
X	 * perform the operation
X	 */
X	erc = _smart_sender_common(cmdesd->pb);
X
XFREE_MEM_AND_EXIT:
X	if(pathesd)
X		esdfree(pathesd);
X	if(cmdesd)
X		esdfree(cmdesd);
X	return(erc);
X
X}	/* end of pcmd_sy */
X
X/*+-------------------------------------------------------------------------
X	pcmd_sz(param)
X
Xsz [-anf[l]] [<label-str>] <filelist-str>
X-a ascii, else binary
X-n send only newer, else all files
X-f full, else simple pathnames
X-l non-default bottom line label on transfer string
X$i0 set to:
X	0: file transfer completely successful
X	-1 program did not run
X--------------------------------------------------------------------------*/
Xint
Xpcmd_sz(param)
XESD *param;
X{
Xint erc;
Xchar switches[8];
XESD *pathesd = (ESD *)0;
XESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
X
X	if(!cmdesd)
X		return(eNoMemory);
X
X	get_switches(param,switches,sizeof(switches));
X
X	if(erc = _make_bottom_label(param,!strchr(switches,'l'),1))
X		return(erc);
X
X	/*
X	 * build command at beginning of 'cmdesd' ESD
X	 */
X	sprintf(cmdesd->pb,"ecusz -Z -. %d -y ",shm->Liofd);
X	strcat(cmdesd->pb,bottom_label);
X
X	if(strchr(switches,'N'))		/* force "no curses" */
X		strcat(cmdesd->pb,"-@ ");
X
X	if(strchr(switches,'a'))
X		strcat(cmdesd->pb,"-a ");
X
X	if(strchr(switches,'n'))
X		strcat(cmdesd->pb,"-n ");	/* overrides -y choice earlier */
X
X	if(strchr(switches,'f'))
X		strcat(cmdesd->pb,"-f ");
X
X#if defined(WHT)	/* for testing */
X	if(strchr(switches,'p'))
X		strcat(cmdesd->pb,"-, ");
X#endif
X
X	/*
X	 * update cmdesd esd
X	 */
X	cmdesd->cb = strlen(cmdesd->pb);
X
X	if(!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
X	{
X		erc = eNoMemory;
X		goto FREE_MEM_AND_EXIT;
X	}
X
X	/*
X	 * get list of pathnames to send
X	 */
X	if(erc = gstr(param,pathesd,1))
X		goto FREE_MEM_AND_EXIT;
X
X	/*
X	 * append filelist to command
X	 */
X	if(erc = esdcat(cmdesd,pathesd,1))
X		goto FREE_MEM_AND_EXIT;
X
X	/*
X	 * perform the operation
X	 */
X	erc = _smart_sender_common(cmdesd->pb);
X
XFREE_MEM_AND_EXIT:
X	if(pathesd)
X		esdfree(pathesd);
X	if(cmdesd)
X		esdfree(cmdesd);
X	return(erc);
X
X}	/* end of pcmd_sz */
X
X/*+-------------------------------------------------------------------------
X	pcmd_sk(param)
X
Xsk [-a] <str>
X--------------------------------------------------------------------------*/
Xint
Xpcmd_sk(param)
XESD *param;
X{
Xint erc;
Xchar switches[8];
XESD *pathesd = (ESD *)0;
XESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
X
X	if(!cmdesd)
X		return(eNoMemory);
X
X	get_switches(param,switches,sizeof(switches));
X
X	/*
X	 * build command at beginning of 'cmdesd' ESD
X	 */
X	sprintf(cmdesd->pb,"ckermit -l %d -b %u -p %c%s%s -s ",
X		shm->Liofd,shm->Lbaud,
X		(shm->Lparity) ? shm->Lparity : 'n',
X		(strchr(switches,'a')) ? "" : " -i",
X		(1 /* overwrite*/ ) ? "" : " -w");
X
X	if(strchr(switches,'b'))
X		strcat(cmdesd->pb,"-a ");
X	else
X		strcat(cmdesd->pb,"-b ");
X
X	if(strchr(switches,'n'))
X		strcat(cmdesd->pb,"-n ");	/* overrides -y choice earlier */
X	if(strchr(switches,'f'))
X		strcat(cmdesd->pb,"-f ");
X
X	/*
X	 * update cmdesd esd
X	 */
X	cmdesd->cb = strlen(cmdesd->pb);
X
X	if(!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
X	{
X		erc = eNoMemory;
X		goto FREE_MEM_AND_EXIT;
X	}
X
X	/*
X	 * get list of pathnames to send
X	 */
X	if(erc = gstr(param,pathesd,1))
X		goto FREE_MEM_AND_EXIT;
X
X	/*
X	 * append filelist to command
X	 */
X	if(erc = esdcat(cmdesd,pathesd,1))
X		goto FREE_MEM_AND_EXIT;
X
X	/*
X	 * perform the operation
X	 */
X	last_child_wait_status = 0;
X	if(exec_cmd(cmdesd->pb))
X		erc = eFATAL_ALREADY;
X
XFREE_MEM_AND_EXIT:
X	if(pathesd)
X		esdfree(pathesd);
X	if(cmdesd)
X		esdfree(cmdesd);
X
X	file_xfer_done_bell();
X	lreset_ksr();
X
X	return(_adjust_erc_and_iv0(erc));
X
X}	/* end of pcmd_sk */
X
X/*+-------------------------------------------------------------------------
X	pcmd_ss(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_ss(param)
XESD *param;
X{
Xint erc;
XESD *pathesd = (ESD *)0;
XESD *cmdesd = esdalloc(CMDESD_INITIAL_SIZE);
X
X	if(!cmdesd)
X		return(eNoMemory);
X
X	/*
X	 * build command at beginning of 'cmdesd' ESD
X	 */
X	sprintf(cmdesd->pb,"ecusea -. %d -/ %s -s ",shm->Liofd,curr_dir);
X
X	/*
X	 * update cmdesd esd
X	 */
X	cmdesd->cb = strlen(cmdesd->pb);
X
X	if(!(pathesd = esdalloc(PATHESD_INITIAL_SIZE)))
X	{
X		erc = eNoMemory;
X		goto FREE_MEM_AND_EXIT;
X	}
X
X	/*
X	 * get list of pathnames to send
X	 */
X	if(erc = gstr(param,pathesd,1))
X		goto FREE_MEM_AND_EXIT;
X
X	/*
X	 * append filelist to command
X	 */
X	if(erc = esdcat(cmdesd,pathesd,1))
X		goto FREE_MEM_AND_EXIT;
X
X	/*
X	 * perform the operation
X	 */
X	last_child_wait_status = 0;
X	if(exec_cmd(cmdesd->pb))
X		erc = eFATAL_ALREADY;
X
XFREE_MEM_AND_EXIT:
X	if(pathesd)
X		esdfree(pathesd);
X	if(cmdesd)
X		esdfree(cmdesd);
X
X	file_xfer_done_bell();
X	lreset_ksr();
X
X	return(_adjust_erc_and_iv0(erc));
X
X}	/* end of pcmd_ss */
X
X/*+-------------------------------------------------------------------------
X	pcmd_rx(param)
X
Xrx [-b] <str>
X--------------------------------------------------------------------------*/
Xint
Xpcmd_rx(param)
XESD *param;
X{
Xint erc = 0;
Xchar cmdstr[CMDSTR_SIZE];
Xchar switches[8];
XESD *pathesd = esdalloc(PATHESD_INITIAL_SIZE);
X
X	if(!pathesd)
X		return(eNoMemory);
X
X	get_switches(param,switches,sizeof(switches));
X
X	if(erc = gstr(param,pathesd,1))
X	{
X		esdfree(pathesd);
X		return(erc);
X	}
X
X	if(erc = _make_bottom_label(param,!strchr(switches,'l'),0))
X		return(erc);
X
X	/*
X	 * build command in 'cmdstr' string
X	 */
X	sprintf(cmdstr,"ecurz -X -. %d -c ",shm->Liofd);
X	strcat(cmdstr,bottom_label);
X	if(!strchr(switches,'b'))
X		strcat(cmdstr,"-b ");
X	else
X		strcat(cmdstr,"-a ");
X	strcat(cmdstr,pathesd->pb);
X	esdfree(pathesd);
X	file_xfer_start();
X
X	last_child_wait_status = 0;
X
X	if(exec_cmd(cmdstr))
X		erc = eFATAL_ALREADY;
X	else
X		erc = _adjust_erc_and_iv0(erc);
X
X	file_xfer_done_bell();
X	lreset_ksr();
X	return(erc);
X
X}	/* end of pcmd_rx */
X
X/*+-------------------------------------------------------------------------
X	pcmd_ry(param)
X
Xry
X--------------------------------------------------------------------------*/
Xint
Xpcmd_ry(param)
XESD *param;
X{
Xint erc = 0;
Xchar cmdstr[CMDSTR_SIZE];
Xchar switches[8];
X
X	get_switches(param,switches,sizeof(switches));
X
X	last_child_wait_status = 0;
X
X	if(erc = _make_bottom_label(param,!strchr(switches,'l'),0))
X		return(erc);
X
X	/*
X	 * build command in 'cmdstr' string
X	 */
X	sprintf(cmdstr,"ecurz -Y -. %d -y ",shm->Liofd);
X	strcat(cmdstr,bottom_label);
X	file_xfer_start();
X	if(exec_cmd(cmdstr))
X		erc = eFATAL_ALREADY;
X	else
X		erc = _adjust_erc_and_iv0(erc);
X
X	file_xfer_done_bell();
X	lreset_ksr();
X
X	return(erc);
X}	/* end of pcmd_ry */
X
X/*+-------------------------------------------------------------------------
X	pcmd_rz(param)
X--------------------------------------------------------------------------*/
Xint
Xpcmd_rz(param)
XESD *param;
X{
Xint erc = 0;
Xchar cmdstr[CMDSTR_SIZE];
Xchar switches[8];
X
X	get_switches(param,switches,sizeof(switches));
X
X	last_child_wait_status = 0;
X
X	if(erc = _make_bottom_label(param,!strchr(switches,'l'),0))
X		return(erc);
X
X	/*
X	 * build command in 'cmdstr' string
X	 */
X	sprintf(cmdstr,"ecurz -Z -. %d ",shm->Liofd);
X	strcat(cmdstr,bottom_label);
X
X	if(strchr(switches,'N'))		/* force "no curses" */
X		strcat(cmdstr,"-@ ");
X#if defined(WHT)	/* for testing */
X	if(strchr(switches,'c'))
X		strcat(cmdstr,"-: ");
X	if(strchr(switches,'p'))
X		strcat(cmdstr,"-, ");
X#endif
X	file_xfer_start();
X	if(exec_cmd(cmdstr))
X		erc = eFATAL_ALREADY;
X	else
X		erc = _adjust_erc_and_iv0(erc);
X
X	file_xfer_done_bell();
X	lreset_ksr();
X
X	return(erc);
X}	/* end of pcmd_rz */
X
X/*+-------------------------------------------------------------------------
X	pcmd_rk(param)
X
Xrk [-a]
X--------------------------------------------------------------------------*/
Xint
Xpcmd_rk(param)
XESD *param;
X{
Xint erc = 0;
Xchar cmdstr[CMDSTR_SIZE];
Xchar switches[8];
X
X	get_switches(param,switches,sizeof(switches));
X
X	last_child_wait_status = 0;
X	sprintf(cmdstr,"ckermit -r -e 512 -l %d -b %d -p %c",
X		shm->Liofd,shm->Lbaud,(shm->Lparity) ? shm->Lparity : 'n');
X	if(strchr(switches,'a'))
X		strcat(cmdstr,"-i ");
X	file_xfer_start();
X
X	if(exec_cmd(cmdstr))
X		erc = eFATAL_ALREADY;
X	else
X		erc = _adjust_erc_and_iv0(erc);
X
X	file_xfer_done_bell();
X	lreset_ksr();
X
X	return(erc);
X}	/* end of pcmd_rk */
X
X/*+-------------------------------------------------------------------------
X	pcmd_rs(param)
X
Xrs
X--------------------------------------------------------------------------*/
Xint
Xpcmd_rs(param)
XESD *param;
X{
Xint erc = 0;
Xchar cmdstr[CMDSTR_SIZE];
X
X	file_xfer_start();
X	sprintf(cmdstr,"ecusea -r -. %d -/ %s",shm->Liofd,curr_dir);
X
X	if(exec_cmd(cmdstr))
X		erc = eFATAL_ALREADY;
X	else
X		erc = _adjust_erc_and_iv0(erc);
X
X	file_xfer_done_bell();
X	lreset_ksr();
X
X	return(erc);
X}	/* end of pcmd_rs */
X
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of pcmdxfer.c */
SHAR_EOF
$TOUCH -am 0725125991 'pcmdxfer.c' &&
chmod 0644 pcmdxfer.c ||
echo 'restore of pcmdxfer.c failed'
Wc_c="`wc -c < 'pcmdxfer.c'`"
test 16424 -eq "$Wc_c" ||
	echo 'pcmdxfer.c: original size 16424, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= poutput.c ==============
if test -f 'poutput.c' -a X"$1" != X"-c"; then
	echo 'x - skipping poutput.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting poutput.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'poutput.c' &&
X/*+-------------------------------------------------------------------------
X	poutput.c - ecu procedure output routines
X	wht@n4hgf.Mt-Park.GA.US
X
X  Defined functions:
X	pcmd_plog(param)
X	pperror(str)
X	pputc(ch)
X	pputs(str)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:59-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#include "ecukey.h"
X#include "ecuerror.h"
X#include "esd.h"
X
Xextern int proctrace;
Xextern FILE *rcvr_log_fp;
X
XFILE *plog_fp = (FILE *)0;
XESD *plog_name = (ESD *)0;
X
X/*+-------------------------------------------------------------------------
X	plogs(str)
X--------------------------------------------------------------------------*/
Xvoid
Xplogs(str)
Xchar *str;
X{
X	if(plog_fp)
X		fputs(str,plog_fp);
X}	/* end of plogs */
X
X/*+-------------------------------------------------------------------------
X	plogc(ch)
X--------------------------------------------------------------------------*/
Xvoid
Xplogc(ch)
Xchar ch;
X{
X	if(plog_fp)
X		fputc(ch,plog_fp);
X}	/* end of plogc */
X
X/*+-------------------------------------------------------------------------
X	pputc(ch) - put procedure output character to stderr and log
X--------------------------------------------------------------------------*/
Xvoid
Xpputc(ch)
Xchar ch;
X{
X	if(ch == NL)
X		fputc(CRET,se);
X	fputc(ch,se);
X	if(plog_fp && (ch != CRET))
X		fputc(ch,plog_fp);
X	if(rcvr_log_fp && (ch != CRET))
X		fputc(ch,rcvr_log_fp);
X}	/* end of pputc */
X
X/*+-------------------------------------------------------------------------
X	pputs(str) - put procedure output string to stderr and log
X--------------------------------------------------------------------------*/
Xvoid
Xpputs(str)
Xregister char *str;
X{
X	while(*str)
X	{
X		if(*str == NL)
X			fputc(CRET,se);
X		fputc(*str,se);
X		if(plog_fp && (*str != CRET))
X			fputc(*str,plog_fp);
X		if(rcvr_log_fp && (*str != CRET))
X			fputc(*str,rcvr_log_fp);
X		str++;
X	}
X}	/* end of pputs */
X
X/*+-------------------------------------------------------------------------
X	pflush()
X--------------------------------------------------------------------------*/
Xvoid
Xpflush()
X{
X	if(plog_fp)
X		fflush(plog_fp);
X}	/* end of pflush */
X
X/*+-------------------------------------------------------------------------
X	pperror(str)
X--------------------------------------------------------------------------*/
Xvoid
Xpperror(str)
Xchar *str;
X{
Xextern char *sys_errlist[];
Xextern int sys_nerr;
Xextern int errno;
Xint save_errno = errno;
X
X	if(str && *str)
X	{
X		pputs(str);
X		pputs(": ");
X	}
X	if(save_errno <= sys_nerr)
X		pputs(sys_errlist[save_errno]);
X	else
X		pprintf("error %d",save_errno);
X	pputs("\n");
X}	/* end of pperror */
X
X/*+-------------------------------------------------------------------------
X	plog_control(fname)
X fname == 0, close
X fname == 1, plog_name already plugged
X--------------------------------------------------------------------------*/
Xint
Xplog_control(fname)
Xchar *fname;
X{
X	if(!fname)	/* close */
X	{
X		if(plog_fp)
X			fclose(plog_fp);
X		plog_fp = (FILE *)0;
X		return(0);
X	}
X
X	if(plog_fp)
X		plog_control((char *)0);
X
X	if(fname != (char *)1)
X	{
X		strcpy(plog_name->pb,fname);
X		plog_name->cb = strlen(fname);
X	}
X
X	if((plog_fp = fopen(plog_name->pb,"a")) == NULL)
X	{
X		pperror(plog_name->pb);
X		return(eFATAL_ALREADY);
X	}
X	return(0);
X}	/* end of plog_control */
X
X/*+-------------------------------------------------------------------------
X	pcmd_plog(param)
X
Xplog $s0     log to file
Xplog off     stop logging
Xplog         show status
X--------------------------------------------------------------------------*/
Xint
Xpcmd_plog(param)
XESD *param;
X{
Xint erc = eSyntaxError;
Xchar off_str[8];
X
X	if(!skip_cmd_break(param))	/* if arguments */
X	{
X		if(!get_alpha_zstr(param,off_str,sizeof(off_str)))
X		{
X			if(strcmp(off_str,"off"))
X				return(eBadParameter);
X			erc = plog_control((char *)0);
X		}
X		else
X		{
X			if(erc = gstr(param,plog_name,1))
X				return(erc);
X			erc = plog_control((char *)1);
X		}
X	}
X	return(erc);
X
X}	/* end of pcmd_plog */
X
X/*+-------------------------------------------------------------------------
X	poutput_init()
X--------------------------------------------------------------------------*/
Xvoid
Xpoutput_init()
X{
X	if((plog_name = esdalloc(256)) == (ESD *)0)
X	{
X		ff(se,"Out of memory\r\n");
X		termecu(1);
X	}
X}	/* end of poutput_init */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of poutput.c */
SHAR_EOF
$TOUCH -am 0725125991 'poutput.c' &&
chmod 0644 poutput.c ||
echo 'restore of poutput.c failed'
Wc_c="`wc -c < 'poutput.c'`"
test 4430 -eq "$Wc_c" ||
	echo 'poutput.c: original size 4430, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= pprintf.c ==============
if test -f 'pprintf.c' -a X"$1" != X"-c"; then
	echo 'x - skipping pprintf.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting pprintf.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'pprintf.c' &&
X/*+-------------------------------------------------------------------------
X	pprintf.c - procedure printf
X
X  This module has been hacked a bit to work for ECU applications
X  as of its writing.  If you use this with SCO MSC, the ifdefs
X  will work in any environment.  Using it without any SCO
X  predefines will cause %p to print as a 32-bit linear pointer.
X  M_I286 assumes %p is a segmented pointer unless M_SDATA is
X  supplied too, in which case %p prints as a 16-bit segment offset.
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
X/*:01-09-1991-22:31-wht@n4hgf-ISC port */
X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
X
X/* based on Portable vsprintf  by Robert A. Larson <blarson@skat.usc.edu> */
X
X/* Copyright 1989 Robert A. Larson.
X * Distribution in any form is allowed as long as the author
X * retains credit, changes are noted by their author and the
X * copyright message remains intact.  This program comes as-is
X * with no warentee of fitness for any purpouse.
X *
X * Thanks to Doug Gwen, Chris Torek, and others who helped clarify
X * the ansi printf specs.
X *
X * Please send any bug fixes and improvments to blarson@skat.usc.edu .
X * The use of goto is NOT a bug.
X */
X
X#if !defined(BUILDING_PROTOTYPES)
X
X#include <stdio.h>
X#include <varargs.h>
X
X#if defined(M_I386) || defined(i386)
X#define LONGINT
X#endif
X
X/* This must be a typedef not a #define! */
X#define NOVOID
X#if defined(NOVOID)
Xtypedef char *pointer;
X#else
Xtypedef void *pointer;
X#endif
X
Xtypedef int *intp;
X
X/*+-------------------------------------------------------------------------
X	pprintf(format,va_alist)
X--------------------------------------------------------------------------*/
Xvoid
Xpprintf(format,va_alist)
Xregister char *format;
Xva_dcl
X{
Xva_list args;
Xregister char c;
Xregister char *tp;
Xchar tempfmt[64];
X#if !defined(LONGINT)
Xint longflag;
X#endif
Xchar accum_string[256];
Xregister char *dp = accum_string;
X
X	va_start(args);
X
X	tempfmt[0] = '%';
X	while(c = *format++)
X	{
X		if(c=='%')
X		{
X			tp = &tempfmt[1];
X#if !defined(LONGINT)
X			longflag = 0;
X#endif
Xcontinue_format:
X			switch(c = *format++)
X			{
X			case 's':
X				*tp++ = c;
X				*tp = '\0';
X				dp += sprintf(dp,tempfmt,va_arg(args,char *));
X				break;
X			case 'u':
X			case 'x':
X			case 'o':
X			case 'X':
X#if defined(UNSIGNEDSPECIAL)
X				*tp++ = c;
X				*tp = '\0';
X#if !defined(LONGINT)
X				if(longflag)
X					dp += sprintf(dp,tempfmt,va_arg(args,unsigned long));
X				else
X#endif
X					dp += sprintf(dp,tempfmt,va_arg(args,unsigned));
X				break;
X#endif
X			case 'd':
X			case 'c':
X			case 'i':
X				*tp++ = c;
X				*tp = '\0';
X#if !defined(LONGINT)
X				if(longflag)
X					dp += sprintf(dp,tempfmt,va_arg(args,long));
X				else
X#endif
X					dp += sprintf(dp,tempfmt,va_arg(args,int));
X				break;
X			case 'f':
X			case 'e':
X			case 'E':
X			case 'g':
X			case 'G':
X				*tp++ = c;
X				*tp = '\0';
X				dp += sprintf(dp,tempfmt,va_arg(args,double));
X				break;
X			case 'p':
X#if defined(M_I286)
X				tp = va_arg(args,pointer);
X#if defined(M_SDATA)
X				dp += sprintf(dp,"0x%04x",tp);
X#else
X				dp += sprintf(dp,"%04x:%04x",(int)tp,(int)((long)tp >> 16));
X#endif /* M_SDATA */
X#else
X				dp += sprintf(dp,"0x%08lx",va_arg(args,pointer));
X#endif /* M_I286 */
X				break;
X			case '-':
X			case '+':
X			case '0':
X			case '1':
X			case '2':
X			case '3':
X			case '4':
X			case '5':
X			case '6':
X			case '7':
X			case '8':
X			case '9':
X			case '.':
X			case ' ':
X			case '#':
X			case 'h':
X				*tp++ = c;
X				goto continue_format;
X			case 'l':
X#if !defined(LONGINT)
X				longflag = 1;
X				*tp++ = c;
X#endif
X				goto continue_format;
X			case '*':
X				tp += sprintf(tp,"%d",va_arg(args,int));
X				goto continue_format;
X			case '%':
X			default:
X				*dp++ = c;
X				break;
X			}
X		}
X		else *dp++ = c;
X	}
X	*dp = '\0';
X	va_end(args);
X	pputs(accum_string);
X}	/* end of pprintf */
X#endif /* !defined(BUILDING_PROTOTYPES) */
X
X/* vi: set tabstop=4 shiftwidth=4: */
X/* end of pprintf.c */
SHAR_EOF
$TOUCH -am 0725125991 'pprintf.c' &&
chmod 0644 pprintf.c ||
echo 'restore of pprintf.c failed'
Wc_c="`wc -c < 'pprintf.c'`"
test 3984 -eq "$Wc_c" ||
	echo 'pprintf.c: original size 3984, current size' "$Wc_c"
rm -f _shar_wnt_.tmp
fi
# ============= proc.c ==============
if test -f 'proc.c' -a X"$1" != X"-c"; then
	echo 'x - skipping proc.c (File already exists)'
	rm -f _shar_wnt_.tmp
else
> _shar_wnt_.tmp
echo 'x - extracting proc.c (Text)'
sed 's/^X//' << 'SHAR_EOF' > 'proc.c' &&
X/*+-------------------------------------------------------------------------
X	proc.c - procedure command and control
X	wht@n4hgf.Mt-Park.GA.US
X
X  Defined functions:
X	_cmd_gosub_common(param,type)
X	_get_goto_label(param)
X	pcmd_do(param)
X	pcmd_gosub(param)
X	pcmd_gosubb(param)
X	pcmd_goto(param)
X	pcmd_gotob(param)
X	pcmd_return(param)
X	do_proc(argc,argv)
X	dump_proc(pcb)
X	execute_esd(tesd)
X	execute_goto(pcb,goto_type)
X	execute_labelled_esd(tesd)
X	execute_proc(pcb,use_goto_label)
X	find_labelled_lcb(label,first,last)
X	find_proc_cmd(cmd_list,cmd)
X	find_procedure(name)
X	free_lcb_chain(lcb)
X	show_error_position(pcb)
X	trace_proc_cmd(pcb)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
X/*:07-01-1991-01:53-wht@n4hgf-fix return with value */
X/*:05-01-1991-04:18-wht@n4hgf-new find_procedure failed on home subdir match */
SHAR_EOF
true || echo 'restore of proc.c failed'
fi
echo 'End of ecu310 part 17'
echo 'File proc.c is continued in part 18'
echo 18 > _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.


