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

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

---- Cut Here and unpack ----
#!/bin/sh
# this is part 8 of a multipart archive
# do not concatenate these parts, unpack them in order with /bin/sh
# file ecurcvr.c continued
#
CurArch=8
if test ! -r s2_seq_.tmp
then echo "Please unpack part 1 first!"
     exit 1; fi
( read Scheck
  if test "$Scheck" != $CurArch
  then echo "Please unpack part $Scheck next!"
       exit 1;
  else exit 0; fi
) < s2_seq_.tmp || exit 1
echo "x - Continuing file ecurcvr.c"
sed 's/^X//' << 'SHAR_EOF' >> ecurcvr.c
X	ansi_CUD()
X--------------------------------------------------------------------------*/
Xvoid
Xansi_CUD()
X{
Xregister count;
X	if(ansilen == 2)		/* no param */
X		count = 1;
X	else
X		count = atoi(ansi + 1);
X
X	ansi_y += count;
X	if(ansi_y > tcap_LINES)
X		ansi_y = tcap_LINES;
X#if defined(ANSI_DEBUG_2)
X	if(dbg)
X		fprintf(dbg,"CUD count %d cur %d,%d\n",count,ansi_y,ansi_x);
X#endif
X}	/* end of ansi_CUD */
X
X/*+-------------------------------------------------------------------------
X	ansi_CUF() -- cursor forward
X--------------------------------------------------------------------------*/
Xvoid
Xansi_CUF()
X{
Xregister count;
X	if(ansilen == 2)		/* no param */
X		count = 1;
X	else
X		count = atoi(ansi + 1);
X
X	ansi_x += count;
X	if(ansi_x > tcap_COLS)
X		ansi_x = tcap_COLS;
X
X#if defined(ANSI_DEBUG_2)
X	if(dbg)
X		fprintf(dbg,"CUF count %d cur %d,%d\n",count,ansi_y,ansi_x);
X#endif
X}	/* end of ansi_CUF */
X
X/*+-------------------------------------------------------------------------
X	ansi_CUB()
X--------------------------------------------------------------------------*/
Xvoid
Xansi_CUB()
X{
Xregister count;
X	if(ansilen == 2)		/* no param */
X		count = 1;
X	else
X		count = atoi(ansi + 1);
X
X	ansi_x -= count;
X	if(ansi_x < 1)
X		ansi_x = 1;
X
X#if defined(ANSI_DEBUG_2)
X	if(dbg)
X		fprintf(dbg,"CUB count %d cur %d,%d\n",count,ansi_y,ansi_x);
X#endif
X}	/* end of ansi_CUB */
X
X/*+-------------------------------------------------------------------------
X	ansi_DSR() -- device status report
X--------------------------------------------------------------------------*/
Xvoid
Xansi_DSR()
X{
Xchar response[MAX_ANSI_LEN];
X	sprintf(response,"\033[%d;%dR",ansi_y,ansi_x);
X	write(Liofd,response,strlen(response));
X}	/* end of ansi_DSR */
X
X/*+-------------------------------------------------------------------------
X	ansi_ED() -- erase in display
Xhave to check this one since a parameter of 2 homes cursor as well
Xas clearing entire screen (MSDOS tech ref doesn't mention any param
Xvalue other than 2 but just in case)
X--------------------------------------------------------------------------*/
Xvoid
Xansi_ED()
X{
Xregister param;
X	if(ansilen == 2)		/* no param */
X		param = 0;
X	else
X		param = atoi(ansi + 1);
X
X#if defined(ANSI_DEBUG_2)
X	if(dbg)
X		fprintf(dbg,"ED param %d old cur %d,%d\n",param,ansi_y,ansi_x);
X#endif
X
X	if(param == 2)
X	{
X		ansi_y = 1;
X		ansi_x = 1;
X	}
X
X#if defined(ANSI_DEBUG_2)
X	if(dbg)
X		fprintf(dbg,"           new cur %d,%d\n",ansi_y,ansi_x);
X#endif
X}	/* end of ansi_ED */
X
X/*+-------------------------------------------------------------------------
X	ibm_crock_save_cursor() -- 
Xpart 1 of why this crap is necessary
X--------------------------------------------------------------------------*/
Xvoid
Xibm_crock_save_cursor()
X{
X	ibm_crock_y = ansi_y;
X	ibm_crock_x = ansi_x;
X#if defined(ANSI_DEBUG_2)
X	if(dbg)
X		fprintf(dbg,"save cur %d,%d\n",ansi_y,ansi_x);
X#endif
X}	/* end of ibm_crock_save_cursor */
X
X/*+-------------------------------------------------------------------------
X	ibm_crock_restore_cursor()
Xpart 2 of why this crap is necessary
X--------------------------------------------------------------------------*/
Xvoid
Xibm_crock_restore_cursor()
X{
Xchar crock[MAX_ANSI_LEN];
X	ansi_y = ibm_crock_y;
X	ansi_x = ibm_crock_x;
X#if defined(ANSI_DEBUG_2)
X	if(dbg)
X		fprintf(dbg,"restore cur %d,%d\n",ansi_y,ansi_x);
X#endif
X	sprintf(crock,"\033[%d;%dH",ansi_y,ansi_x);
X	write(TTYERR,crock,strlen(crock));
X}	/* end of ibm_crock_restore_cursor */
X
X/*+-------------------------------------------------------------------------
X	rcvr_saw_escape()
Xrcvr read an ESC character : read the rest of an ansi sequence
Xand process it; if not ansi sequence, spit ESC + string read by
Xlget_ansi to screen
X--------------------------------------------------------------------------*/
Xvoid
Xrcvr_saw_escape()
X{
Xregister itmp;
Xregister char *cptr;
X
X	ansi = ansibuf;
X	ansilen = lget_ansi();
X	if(!ansilen)		/* XENIX ansi driver can't handle ESC ... */
X		return;			/* ... followed by real ansi sequence */
X	else if(ansilen < 0)
X	{					/* if escape and non-ansi, garbage ... print ... */
X		ansilen = -ansilen;		/* ... but do not include the escape */
X		write(TTYERR,ansi,ansilen);
X		return;
X	}
X	else if(!ansi_filter)		/* if not filtering, pass raw to driver */
X	{	
X		write(TTYERR,&esc,1);
X		write(TTYERR,ansi,ansilen);
X		return;
X	}
X
X/* we are going to filter amongst the flavors of "ANSI" (IBM sucks floppies) */
X
X	itmp = 1;		/* assume write needed */
X	switch(ansi[ansilen - 1])
X	{
X		case 'm': ansi_SGR(); itmp = 0; break;
X		case 'f':
X		case 'H': ansi_CUP(); break;
X		case 'A': ansi_CUU(); break;
X		case 'B': ansi_CUD(); break;
X		case 'C': ansi_CUF(); break;
X		case 'D': ansi_CUB(); break;
X		case 's': ibm_crock_save_cursor(); itmp = 0; break;
X		case 'u': ibm_crock_restore_cursor(); itmp = 0; break;
X		case 'n': ansi_DSR(); itmp = 0; break;
X		case 'J': ansi_ED(); break;
X		default:
X#if defined(ANSI_DEBUG)
X			if(dbg)
X				ansi_log_unknown(ansi,ansilen);
X		case '@':
X		case 'K':
X		case 'L':
X		case 'M':
X		case 'P':
X		case 'S':
X#if defined(ANSI_DEBUG_2)
X			if(dbg)
X				hex_dump_fp(dbg,ansi,ansilen,"fallthru",1);
X#endif
X#endif
X			break;
X	}
X
X	if(itmp)
X	{
X		write(TTYERR,&esc,1);
X		write(TTYERR,ansi,ansilen);
X	}
X
X}	/* end of rcvr_saw_escape */
X
X/*+-------------------------------------------------------------------------
X	rcvr_log_open()
X--------------------------------------------------------------------------*/
Xvoid
Xrcvr_log_open()
X{
X
X	if(rcvr_log)		/* if xmtr set us up for logging */
X	{
X		rcvr_log_fp = fopen(rcvr_log_file,rcvr_log_append ? "a" : "w");
X		rcvr_log_append = 1;	/* until next %log -s */
X		if(!rcvr_log_fp)
X		{
X			ff(se,"ecu RCVR: Could not open log file: %s\r\n",rcvr_log_file);
X			ff(se,"recording aborted.\r\n");
X		}
X		else if(!rcvr_log_raw)
X		{
X		char tstr[80];
X			get_tod(2,tstr);
X			fprintf(rcvr_log_fp,"\n====> %s (phone %s) %s\n\n",
X				Ldescr,(Ltelno[0]) ? Ltelno : "NONE",tstr);
X		}
X	}
X}	/* end of rcvr_log_open */
X
X/*+-----------------------------------------------------------------------
X	rcvr() -- copy characters from remote line to so (fd == 1)
X------------------------------------------------------------------------*/
Xvoid
Xrcvr()
X{
Xlong lseek();
Xregister unsigned char reg_char;
Xregister parity = Lparity;
Xunsigned char nlchar = NL;
Xstatic char static_rcvr_char;
X
X#if defined(ANSI_DEBUG)
X	if(!dbg && (ansi_filter == 2))
X	{
X		dbg = fopen("/tmp/ansi.log","a");
X		setbuf(dbg,NULL);
X	}
X#endif
X
X	xenix_lgetc_count = 0;
X
X	rcvr_signals();
X	rcvr_log_open();
X
X	if(ansi_filter)
X		ansi_filter_control(ansi_filter);
X
X	while(1)		/* receive loop -- keep tight as possible! */
X	{
X
X		reg_char = lgetc_rcvr();
X		if(parity)
X			reg_char &= 0x7F;
X
X
X		if(want_bell_notify == 2)
X		{
X			shmr_set_xmtr_bn_1();
X			want_bell_notify = 1;
X			xenix_bell_notify(XBELL_3T);
X		}
X		else if(reg_char == 7)
X			xenix_bell_notify(XBELL_ATTENTION);
X		else if(reg_char == ESC)
X		{
X			rcvr_saw_escape();
X			continue;
X		}
X		else if(ansi_filter)
X		{
X#if defined(ANSI_DEBUG_3)
X		int dbg_y = ansi_y,dbg_x = ansi_x;
X#endif
X			if(reg_char < SPACE)
X			{
X				switch(reg_char)
X				{
X					case BS:
X						if(ansi_x != 1) ansi_x--; break;
X					case NL:
X						if(ansi_y != tcap_LINES) ansi_y++; break;
X					case CR:
X						ansi_x = 1; break;
X					/* case TAB: don't want to think about it! */
X				}
X			}
X			else
X			{
X				if(++ansi_x > tcap_COLS)
X				{
X					ansi_x = 1;
X					if(ansi_y != tcap_LINES)
X						ansi_y++;
X				}
X			}
X#if defined(ANSI_DEBUG_3)
X			if(dbg)
X				fprintf(dbg,"char: %x o%d,%dn%d,%d\n",
X					reg_char,dbg_y,dbg_x,ansi_y,ansi_x);
X#endif
X		}
X
X		static_rcvr_char = reg_char;
X		write(TTYERR,&static_rcvr_char,1);
X		if(Ladd_nl_incoming && (reg_char == CR))
X			write(TTYERR,&nlchar,1);
X
X		if(rcvr_log)
X		{
X			if(rcvr_log_raw || 
X			((reg_char >= SPACE) && (reg_char <= '~')) ||
X			(reg_char == NL) || (reg_char == TAB))
X				putc(reg_char,rcvr_log_fp);
X			if(rcvr_log_flusheach)
X				fflush(rcvr_log_fp);
X		}
X	}
X}	/* end of rcvr */
X
X/* end of ecurcvr.c */
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
echo "File ecurcvr.c is complete"
chmod 0644 ecurcvr.c || echo "restore of ecurcvr.c fails"
echo "x - extracting ecuscrdump.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ecuscrdump.c &&
X/* CHK=0x2501 */
X/*+-------------------------------------------------------------------------
X	ecuscrdump.c
X	Copyright 1986,1989 Warren H. Tucker, III. All Rights Reserved
X
X  Defined functions:
X	screen_dump()
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-03-1989-22:57-wht------------- ecu 2.00 ---------------- */
X/*:06-24-1989-16:53-wht-flush edits --- ecu 1.95 */
X
X#include "ecu.h"
X#include "pc_scr.h"
X
Xextern char curr_dir[];		/* current working directory */
Xextern int rcvr_pid;
X
Xchar screen_dump_file_name[256];
X
X/*+-------------------------------------------------------------------------
X	screen_dump(scrfile)
X
Xif scrfile == NULL, default to ~/.ecu/screen.dump
X--------------------------------------------------------------------------*/
Xvoid
Xscreen_dump(scrfile)
Xchar *scrfile;
X{
Xchar s133[133];
Xunsigned char schar;
Xregister char *cptr = s133;
XFILE *fp;
Xstruct termio dump_tty_termio_at_entry;
Xstruct termio dump_tty_termio_current;
Xint rcvr_alive = (rcvr_pid > 0);
Xextern struct termio tty_termio_at_entry;
X
X	if(rcvr_alive)
X		kill_rcvr_process(SIGUSR1);
X
X/* save keyboard termio at entry */
X	ioctl(TTYIN,TCGETA,(char *)&dump_tty_termio_at_entry);
X
X/* set keyboard to termio status at staart of execution of program 
X   plus a few mods */
X
X	dump_tty_termio_current = tty_termio_at_entry;
X	dump_tty_termio_current.c_cflag &= ~(PARENB | PARODD);
X	dump_tty_termio_current.c_cflag |= CS8;
X	dump_tty_termio_current.c_iflag &= ~(ISTRIP);
X	dump_tty_termio_current.c_lflag &= ~(ICANON | ISIG | ECHO);
X	ioctl(TTYIN,TCSETAW,(char *) &dump_tty_termio_current);
X	ttyflush(2);
X
X	if(scrfile)
X		fp = fopen(scrfile,"a");
X	else
X	{
X		get_home_dir(s133);
X		strcat(s133,"/.ecu/screen.dump");
X		fp = fopen(s133,"a");
X	}
X	if(!fp)
X	{
X		xbell(XBELL_3T,1);
X		return;
X	}
X	get_tod(2,s133);
X	fprintf(fp,"====> %s (phone %s) %s\n",
X		Ldescr,(Ltelno[0]) ? Ltelno : "NONE",s133);
X
X	write(1,"\033[2i",4);	/* spill your guts, screen */
X
X	while(1)
X	{
X		if(!rdchk(0))
X		{
X			nap(40L);
X			if(!rdchk(0))
X				break;
X		}
X
X		read(0,&schar,1);
X		if((schar > 0x7E) || (schar < 0x20))
X		{
X			switch(schar)
X			{
X			case 0x0A:
X				while((cptr > s133) && (*(cptr - 1) == ' '))
X					cptr--;
X				*cptr++ = 0x0A;
X				*cptr = 0;
X				fputs(s133,fp);
X				cptr = s133;
X				*cptr = 0;
X				continue;
X			case sTL:		
X			case sTR:
X				schar = '.';
X				break;
X			case sBL:		
X				schar = '`';
X				break;
X			case sBR:		
X				schar = '\'';
X				break;
X			case sLT:			/* left hand T */
X			case sRT:			/* right hand T */
X				schar = '+';
X				break;
X			case sVR:			/* vertical rule */
X				schar = '|';
X				break;
X			case sHR:			/* horizontal rule */
X				schar = '-';
X				break;
X			default:
X				schar = ' ';
X			}
X		}
X		*cptr++ = schar;
X	}
X
X/* restore keyboard termio at entry */
X	ioctl(TTYIN,TCSETAW,(char *)&dump_tty_termio_at_entry);
X	ttyflush(2);
X
X	nap(40L);
X	if(rcvr_alive)
X		start_rcvr_process(0);
X
X/* bug in sco video driver leaves "ESC,[,2", so use "l" to unlock tty, a noop */
X	fputs("l",stdout);
X	fflush(stdout);
X	xbell(XBELL_DEEDLE,1);
X	fclose(fp);
X}	/* end of screen_dump */
SHAR_EOF
chmod 0644 ecuscrdump.c || echo "restore of ecuscrdump.c fails"
echo "x - extracting ecusetup.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ecusetup.c &&
X/* CHK=0x5ED7 */
X/*+-------------------------------------------------------------------------
X	ecusetup.c -- ecu visual "argv"
X	Copyright 1986,1989 Warren H. Tucker, III. All Rights Reserved
X
X  0000000000111111111122222222223333333333444444444455555555556666
X  0123456789012345678901234567890123456789012345678901234567890123
X00.--[ ecu rev ]-------------------------------------------------.
X01|                                                              |
X02|  Name/phone number to call: ...................              |
X03|  ...................        ................................ |
X04|                                                              |
X05|  tty: /dev/tty.....   (opened)                               | 
X06|                                                              |
X07|  duplex: .  baud: .....  parity: . (data bits .)             |
X08|  Add NL to transmitted CR: .                                 |
X09|  Add NL to received CR:    .                                 |
X10|                                                              |
X11|                                                              |
X12|   TAB:next ^B:prev END:proceed ^D:phone dir  ESC:quit ecu    |
X13`--------------------------------------------------------------'
X
X  Defined functions:
X	setup_display_baud()
X	setup_display_name()
X	setup_display_screen(write_lits)
X	setup_display_single_char()
X	setup_display_tty()
X	setup_line_open()
X	setup_open_status()
X	setup_screen(argv_logical)
X	setw_bot_msg(msg)
X	setw_get_single(nondelim_list)
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:07-03-1989-22:57-wht------------- ecu 2.00 ---------------- */
X/*:06-24-1989-16:53-wht-flush edits --- ecu 1.95 */
X
X#include <curses.h>
X
X#define STDIO_H_INCLUDED
X#define OMIT_TERMIO_REFERENCES
X#include "ecu.h"
X#include "ecukey.h"
X#include "ecuxkey.h"
X#include "pc_scr.h"
X
X#define END		XFend
X
X#define SETW_LINES	14
X#define SETW_COLS	64
X#define SETW_TLY	1
X#define SETW_TLX	((80 - SETW_COLS) / 2)
X
X#define NAME_Y		2
X#define NAME_X		30
X#define NAME_LEN	19
X#define NAME_LX		3
X
X#define TELNO_Y		3
X#define TELNO_X		3
X#define TELNO_LEN	19
X
X#define DESCR_Y		3
X#define DESCR_X		30
X#define DESCR_LEN	32
X
X#define TTY_Y		5
X#define TTY_X		16
X#define TTY_LEN		5
X#define TTY_LX		3
X
X#define TTYOPN_LY	5
X#define TTYOPN_LX	24
X
X#define DPX_Y		7
X#define DPX_X		11
X#define DPX_LX		3
X
X#define BAUD_Y		7
X#define BAUD_X		20
X#define BAUD_LEN	5
X#define BAUD_LX		14
X
X#define PAR_Y		7
X#define PAR_X		34
X#define PAR_LX		27
X
X#define DB_Y		7
X#define DB_X		48
X#define DB_LX		37
X#define DB_LX2		49
X
X#define XADDNL_Y	8
X#define XADDNL_X	29
X#define XADDNL_LX	3
X
X#define RADDNL_Y	9
X#define RADDNL_X	29
X#define RADDNL_LX	3
X
Xextern char *numeric_revision;
Xextern char *select_rev_modifier;
Xextern int rcvr_pid;
Xextern char errmsg[];
X
XWINDOW *setw;
X
X#define SETW_MSG_LEFTX 2
X#define SETW_MSG_MAXLEN	(SETW_COLS - SETW_MSG_LEFTX - 8)
X#define SETW_MSG_BOT_Y  (SETW_LINES - 1)
X#define SETW_MSG_ERR_Y  (SETW_LINES - 3)
X
X/*+-------------------------------------------------------------------------
X	setw_msg(msg,y,fillch)
X--------------------------------------------------------------------------*/
Xvoid
Xsetw_msg(msg,y,fillch,last_msglen)
Xchar *msg;
Xint y;
Xchar fillch;
Xint *last_msglen;
X{
Xregister itmp;
Xregister itmp2;
Xchar msg2[80];
X
X	if(!*last_msglen && !strlen(msg))
X		return;
X
X	wmove(setw,y,SETW_MSG_LEFTX);
X
X	if((itmp = strlen(msg)) == 0)
X	{
X		itmp2 = *last_msglen + 2;
X		for(itmp = 0; itmp < itmp2; itmp++)
X			waddch(setw,fillch);
X		*last_msglen = 0;
X	}
X	else
X	{
X		waddch(setw,' ');
X		if(itmp > SETW_MSG_MAXLEN)
X		{
X			strncpy(msg2,msg,SETW_MSG_MAXLEN);
X			msg2[SETW_MSG_MAXLEN + 1] = 0;
X			waddstr(setw,msg2);
X			itmp = strlen(msg2);
X		}
X		else
X		{
X			waddstr(setw,msg);
X			itmp = strlen(msg);
X		}
X		waddch(setw,' ');
X		if((itmp2 = *last_msglen - itmp) > 0)
X		{
X			while(itmp2--)
X				waddch(setw,fillch);
X		}
X		*last_msglen = itmp;		/* remember last message length */
X	}
X	wrefresh(setw);
X}	/* end of setw_msg */
X
X/*+-------------------------------------------------------------------------
X	setw_bot_msg(msg)
X--------------------------------------------------------------------------*/
Xvoid
Xsetw_bot_msg(msg)
Xchar *msg;
X{
Xstatic int last_msglen = 0;
X
X	setw_msg(msg,SETW_MSG_BOT_Y,sHR,&last_msglen);
X}	/* end of setw_bot_msg */
X
X/*+-------------------------------------------------------------------------
X	setw_err_msg(msg)
X--------------------------------------------------------------------------*/
Xvoid
Xsetw_err_msg(msg)
Xchar *msg;
X{
Xstatic int last_msglen = 0;
X
X	setw_msg(msg,SETW_MSG_ERR_Y,' ',&last_msglen);
X}	/* end of setw_err_msg */
X
X/*+-------------------------------------------------------------------------
X	setup_display_name()
X--------------------------------------------------------------------------*/
Xvoid
Xsetup_display_name()
X{
X	clear_area(setw,NAME_Y,NAME_X,NAME_LEN);
X	waddstr(setw,Llogical);
X
X	clear_area(setw,TELNO_Y,TELNO_X,TELNO_LEN);
X	clear_area(setw,DESCR_Y,DESCR_X,DESCR_LEN);
X	if(strcmp(Llogical,Ldescr))
X	{
X		waddstr(setw,Ldescr);
X		wmove(setw,TELNO_Y,TELNO_X);
X		waddstr(setw,Ltelno);
X	}
X
X}	/* end of setup_display_name */
X
X/*+-------------------------------------------------------------------------
X	setup_display_tty()
X000000000011111
X012345678901234
X/dev/ttyxxxxxx
X--------------------------------------------------------------------------*/
Xvoid
Xsetup_display_tty()
X{
X	clear_area(setw,TTY_Y,TTY_X,TTY_LEN);
X	waddstr(setw,&Lline[8]);
X}	/* end of setup_display_tty */
X
X/*+-------------------------------------------------------------------------
X	setup_display_single_char()
X--------------------------------------------------------------------------*/
Xvoid
Xsetup_display_single_char()
X{
X	wmove(setw,DPX_Y,DPX_X);
X	waddch(setw,(Lfull_duplex) ? 'F' : 'E');
X	wmove(setw,PAR_Y,PAR_X);
X	waddch(setw,(Lparity) ? to_upper(Lparity) : 'N');
X	wmove(setw,DB_Y,DB_X);
X	waddch(setw,(Lparity) ? '7' : '8');
X	wmove(setw,XADDNL_Y,XADDNL_X);
X	waddch(setw,(Ladd_nl_outgoing) ? 'Y' : 'N');
X	wmove(setw,RADDNL_Y,RADDNL_X);
X	waddch(setw,(Ladd_nl_incoming) ? 'Y' : 'N');
X
X }	/* end of setup_display_single_char */
X
X/*+-------------------------------------------------------------------------
X	setup_display_baud()
X--------------------------------------------------------------------------*/
Xvoid
Xsetup_display_baud()
X{
Xchar s8[8];
X	clear_area(setw,BAUD_Y,BAUD_X,BAUD_LEN);
X	sprintf(s8,"%u",Lbaud);
X	waddstr(setw,s8);
X
X}	/* end of setup_display_baud */
X
X/*+-------------------------------------------------------------------------
X	setup_display_screen(write_lits)
X--------------------------------------------------------------------------*/
Xvoid
Xsetup_display_screen(write_lits)
Xint write_lits;
X{
X	if(write_lits)
X	{
X		wmove(setw,NAME_Y,NAME_LX);
X		waddstr(setw,"Name/phone number to call:");
X		wmove(setw,TTY_Y,TTY_LX);
X		waddstr(setw,"tty: /dev/tty");
X		wmove(setw,DPX_Y,DPX_LX);
X		waddstr(setw,"duplex:");
X		wmove(setw,BAUD_Y,BAUD_LX);
X		waddstr(setw,"baud:");
X		wmove(setw,PAR_Y,PAR_LX);
X		waddstr(setw,"parity:");
X		wmove(setw,DB_Y,DB_LX);
X		waddstr(setw,"(data bits");
X		wmove(setw,DB_Y,DB_LX2);
X		waddch(setw,')');
X		wmove(setw,XADDNL_Y,XADDNL_LX);
X		waddstr(setw,"Add NL to transmitted CR:");
X		wmove(setw,RADDNL_Y,RADDNL_LX);
X		waddstr(setw,"Add NL to received CR:");
X		wmove(setw,SETW_LINES - 2,1);
X		wstandout(setw);
X		waddstr(setw,		/* kludge -- must change if setw width does */
X			"   TAB:next ^B:prev END:proceed ^D:phone dir  ESC:quit ecu    ");
X		wstandend(setw);
X	}
X	setup_display_name();
X	setup_display_tty();
X	setup_display_single_char();
X	setup_display_baud();
X	wrefresh(setw);
X}	/* end of setup_display_screen */
X
X/*+-------------------------------------------------------------------------
X	setup_open_status()
X--------------------------------------------------------------------------*/
Xvoid
Xsetup_open_status()
X{
X	wmove(setw,TTYOPN_LY,TTYOPN_LX);
X	if(Liofd >= 0)
X		waddstr(setw,"(opened)");
X	else
X		waddstr(setw,"        ");
X	wrefresh(setw);
X}	/* end of setup_open_status */
X
X/*+-------------------------------------------------------------------------
X	setup_line_open()
X--------------------------------------------------------------------------*/
Xsetup_line_open()
X{
Xregister itmp;
Xchar s64[64];
Xchar *lopen_err_text();
X
X	if(itmp = lopen())
X	{
X		setw_err_msg(lopen_err_text(itmp));
X		ring_bell();
X	}
X	setup_open_status();
X	return(itmp);
X
X}	/* end of setup_line_open */
X
X/*+-------------------------------------------------------------------------
X	setw_get_single(nondelim_list)
Xassumes cursor is already positioned
X--------------------------------------------------------------------------*/
Xint
Xsetw_get_single(nondelim_list)
Xregister char *nondelim_list;
X{
Xregister uint itmp;
Xstatic char setw_nondelim_list[] =
X{
X	CR,NL,CTL_B,CTL_D,TAB,ESC,CTL_L,CTL_R,END
X};
X
X	itmp = winget_single(setw,nondelim_list,setw_nondelim_list);
X	if( (itmp & 0xFF) == CR)
X		itmp = NL | 0x1000;
X	return(itmp);
X}	/* end of setw_get_single */
X
X/*+-------------------------------------------------------------------------
X	setup_screen(argv_logical)
X--------------------------------------------------------------------------*/
Xvoid
Xsetup_screen(argv_logical)
Xchar *argv_logical;
X{
Xregister itmp;
Xregister input_state = 0;
Xchar s64[64];
Xint done = 0;
Xuint baud;
Xuchar delim;	/* important to be unsigned to avoid sign extension */
XWINDOW *window_create();
Xstatic char use_input_delim[] = {TAB,NL,END,CTL_D};
X
X	windows_start();
X	sprintf(s64,"ecu %s%s",numeric_revision,select_rev_modifier);
X	setw = window_create(s64,3,SETW_TLY,SETW_TLX,SETW_LINES,SETW_COLS);
X	setup_display_screen(1);
X
XREENTER_INPUT_LOOP:
X	while(!done)
X	{
X		wrefresh(setw);
X		switch(input_state)
X		{
X			case 0:
XCASE_0:
X				if(argv_logical)
X				{
X					itmp = 0;	/* 'ecu -' means dont dial */
X					if(strcmp(argv_logical,"-"))	/* if not "-" */
X					{
X						strncpy(s64,argv_logical,NAME_LEN + 1);
X						s64[NAME_LEN + 1] = 0;
X						itmp = strlen(s64);
X					}
X					delim = END;
X				}
X				else
X				{
X					setw_bot_msg(
X						"logical phone directory entry, phone number or empty");
X 					itmp = wingets(setw,NAME_Y,NAME_X,s64,NAME_LEN + 1,&delim,
X						(Llogical[0] != 0));
X					setw_err_msg("");
X				}
X				if(strchr(use_input_delim,delim) && strlen(s64))
X				{
X					strcpy(Llogical,s64);
X					if(Llogical[0] && (lookup_logical_telno() == 0))
X					{
X						setw_err_msg(errmsg);
X						setup_display_screen(0);
X						ring_bell();
X						argv_logical = (char *)0;
X						goto CASE_0;
X					}
X					setup_display_screen(0);
X					break;
X				}
X				setup_display_name();
X				break;
X
X			case 1:
X				setw_bot_msg("comm line: i.e., 1a, 2a, 4a, 4b, 4c, 4d");
X				setup_display_tty();
X 				itmp = wingets(setw,TTY_Y,TTY_X,s64,TTY_LEN + 1,&delim,1);
X				setw_err_msg("");
X				if(strchr(use_input_delim,delim) && strlen(s64))
X					strcpy(&Lline[8],s64);
X				setup_display_tty();
X				break;
X
X			case 2:
X				setw_bot_msg("duplex F:full H:half");
X				wmove(setw,DPX_Y,DPX_X);
X				wrefresh(setw);
X				delim = NL;
X				switch(itmp = setw_get_single("fh"))
X				{
X					case 0:
X					case 1:
X						Lfull_duplex = itmp;
X						break;
X					default:
X						delim = itmp & 0xFF;
X						break;
X				}
X				break;
X
X			case 3:		/* baud */
X				setw_bot_msg(
X				"rates: 110,300,600,1200,2400,4800,9600,19200,38400");
XCASE_3:
X 				itmp = wingets(setw,BAUD_Y,BAUD_X,s64,BAUD_LEN + 1,&delim,1);
X				if(strchr(use_input_delim,delim) && strlen(s64))
X				{
X					if(valid_baud_rate(baud = atoi(s64)) < 0)
X					{
X						setup_display_baud();
X						ring_bell();
X						goto CASE_3;
X					}
X					Lbaud = baud;
X				}
X				setup_display_baud();
X				break;
X
X			case 4:
X				setw_bot_msg("parity: N:none E:even O:odd");
X				wmove(setw,PAR_Y,PAR_X);
X				wrefresh(setw);
X				delim = NL;
X				switch(itmp = setw_get_single("neo"))
X				{
X					case 0:	Lparity = 0;   break;
X					case 1: Lparity = 'e'; break;
X					case 2: Lparity = 'o'; break;
X					default:
X						delim = itmp & 0xFF;
X						break;
X				}
X				wmove(setw,DB_Y,DB_X);
X				waddch(setw,(Lparity) ? '7' : '8');
X				break;
X
X			case 5:
X				setw_bot_msg("");
X				wmove(setw,XADDNL_Y,XADDNL_X);
X				wrefresh(setw);
X				delim = NL;
X				switch(itmp = setw_get_single("ny"))
X				{
X					case 0:
X					case 1: Ladd_nl_outgoing = itmp; break;
X					default: delim = itmp & 0xFF;
X				}
X				break;
X
X			case 6:
X				setw_bot_msg("");
X				wmove(setw,RADDNL_Y,RADDNL_X);
X				wrefresh(setw);
X				delim = NL;
X				switch(itmp = setw_get_single("ny"))
X				{
X					case 0:
X					case 1: Ladd_nl_incoming = itmp; break;
X					default: delim = itmp & 0xFF; break;
X				}
X				break;
X		}
X
X		if(argv_logical)
X			break;
X
X		switch(delim)
X		{
X			case CTL_B:
X				if(input_state)
X					input_state--;
X				else
X					input_state = 6;
X				break;
X
X			case TAB:
X			case NL:
X				input_state++;
X				input_state %= 7;
X				break;
X
X			case ESC:
X				if(Liofd >= 0)
X					lclose();
X				setw_bot_msg("");
X				setup_open_status();
X				hangup(0);
X				break;
X
X			case CTL_L:
X			case CTL_R:
X				clear_screen();
X				touchwin(stdscr);
X				wrefresh(stdscr);
X				setup_display_screen(1);
X				touchwin(setw);
X				wrefresh(setw);
X				break;
X
X			case END:
X			case CTL_D:
X				done = 1;
X				break;
X		}
X	}
X
X	if(Liofd < 0)
X	{
X		wmove(setw,TTY_Y,TTY_X);
X		wrefresh(setw);
X		if(setup_line_open())
X		{
X			done = 0;
X			input_state = 1;
X			argv_logical = (char *)0;
X			goto REENTER_INPUT_LOOP;
X		}
X	}
X
X	wmove(setw,SETW_LINES - 2,1);
X	wstandout(setw);
X	waddstr(setw,		/* kludge -- must change if setw width does */
X		"------- Press HOME then 'help' for further assistance --------");
X	wstandend(setw);
X	setw_bot_msg("");
X	windows_end(setw);
X	curmove(SETW_LINES + SETW_TLY + 1,0);
X	if(delim == CTL_D)
X	{
X		rcvr_pid = -2;
X		pde_list_manager();
X	}
X	else if(Llogical[0])
X	{
X#ifdef AUTO_DIAL_PROC
X		if(find_procedure(Llogical))
X		{
X		char *pargv[2];
X			pargv[0] = Llogical;
X			pargv[1] = "!INITIAL";
X			rcvr_pid = 0;
X			do_proc(2,pargv);
X			start_rcvr_process(1);
X		}
X		else
X		{
X			rcvr_pid = -2;
X			hayes_dial();
X		}
X#else
X	rcvr_pid = -2;
X	hayes_dial();
X#endif
X	}
X	else
X		start_rcvr_process(1);
X
X}	/* end of setup_screen */
X
X/* vi: set tabstop=4 shiftwidth=4: */
SHAR_EOF
chmod 0644 ecusetup.c || echo "restore of ecusetup.c fails"
echo "x - extracting ecushm.c (Text)"
sed 's/^X//' << 'SHAR_EOF' > ecushm.c &&
X/* CHK=0x4F89 */
X/*+-------------------------------------------------------------------------
X	ecushm.c - XENIX shared data area handler for ecu xmtr/rcvr comm
X	Copyright 1986,1989 Warren H. Tucker, III. All Rights Reserved
X
X  Defined functions:
X	shm_done()
X	shm_init()
X	shmr_process_rcvr_SIGUSR2()
X	shmr_rcvd_chars(count)
X	shmr_set_xmtr_bn_1()
X	shmx_connect()
X	shmx_make_rcvr_sleep(seconds)
X	shmx_process_xmtr_SIGUSR2()
X	shmx_rc_report(prcvd_chars,prcvd_chars_this_connect)
X	shmx_set_rcvr_ansi(mode)
X	shmx_set_rcvr_bn(bn_value)
X	shmx_set_rcvr_log(logfilename,append_flag,raw_flag)
X	shmx_set_rcvr_nl_control()
X
X--------------------------------------------------------------------------*/
X/*+:EDITS:*/
X/*:08-06-1989-13:56-wht-if raw logging, do not append newline on close */
X/*:07-03-1989-22:57-wht------------- ecu 2.00 ---------------- */
X/*:06-24-1989-16:53-wht-flush edits --- ecu 1.95 */
X
X
X#if defined(M_I386)
X#define FAR
X#else
X#define FAR far
X#endif
X
X#include "ecu.h"
X#include "ecushm.h"
X#include <sys/ipc.h>
X#include <sys/shm.h>
X
X/* xmtr to rcvr cmds */
X#define SHMX_MAKE_RCVR_SLEEP	1	/* sleep xi1=#seconds */
X#define	SHMX_SET_RCVR_BN		2	/* set want_bell_notify xi1=value */
X#define SHMX_SET_RCVR_LOG		3	/* log file manipulations
X									 * xi1=append, xi2=raw, xs1=name */
X#define SHMX_SET_RCVR_ANSI		4	/* ansi filter; xi1=setting */
X#define SHMX_SET_RCVR_NL_CTRL	5	/* update nlin/nlout parameters
X									 * xi1=nlin, xi2=nlout */
X
X/* rcvr to xmtr cmds */
X#define SHMR_SET_XMTR_BN1		1	/* set want_bell_notify to 1 */
X
Xextern int want_bell_notify;
Xextern int rcvr_pid;
Xextern int xmtr_pid;
Xextern char rcvr_log_file[];	/* if rcvr_log!= 0,log filename */
Xextern int rcvr_log;			/* rcvr log active if != 0 */
Xextern FILE *rcvr_log_fp;		/* rcvr log file */
Xextern int rcvr_log_raw;		/* if true, log all, else filter ctl chrs */
Xextern int rcvr_log_flusheach;
Xextern int rcvr_log_append;	/* if true, append, else scratch */
Xextern int ansi_filter;
X
XECU_SDS FAR *shm;				/* shared segment pointer */
Xchar shm_name[130] = "";		/* filename from which to derive key */
Xkey_t	shm_key;
Xint shm_shmid;
X
X/*+-------------------------------------------------------------------------
X	shm_init()
X  Called by parent process (xmtr) to initialize environment
X--------------------------------------------------------------------------*/
Xshm_init()
X{
Xuint old_umask = umask(0);
Xint fd;
X
X	sprintf(shm_name,"/tmp/ecu%05d.shm",getpid());
X	if((fd = open(shm_name,O_CREAT | O_RDWR,0600)) < 0)
X	{
X		fputs("creation of ",se);
SHAR_EOF
echo "End of part 8"
echo "File ecushm.c is continued in part 9"
echo "9" > s2_seq_.tmp
exit 0
-- 
-------------------------------------------------------------------
Warren Tucker, Tridom Corporation       ...!gatech!emory!tridom!wht 
Ker-au'-lo-phon.  An 8-foot partial flue-stop, having metal pipes
surmounted by adjustable rings, and with a hole bored near the top
of each pipe, producing a soft and "reedy" tone.