🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.micro.hp
Article #172

Re: Re: Response to <547@batcompu>

#172
From: ken
Date: Tue, 15 Jul 1986 01:00
137 lines
3086 bytes
/*
 * Minimal Terminal Emulator for the IPC
 *
 * This code is NOT a supported HP program.
 * We make no warranty of any kind with regard to this material.
 */
#include	<stdio.h>
#include	<fcntl.h>
#include	<termio.h>
#include	<signal.h>
#include	<extty.h>

#define		ENQ	'\005'
#define		ACK	"\006"

/*******************************************************************

	Quick terminal program

*******************************************************************/

int	done();

char	conbuf[100], fdbuf[100];
int	fd, tty, i, j, sig_rec, child;
struct	ocio	o;
struct	termio	t, con, old_con;


h_break()
{
	signal(SIGINT, SIG_IGN);

	sig_rec = 1;
}


send_break()
{

	ioctl(fd, TCSBRK, 0);
	for(i = 0; i < 25000; i++)
		;
	while( signal(SIGINT, h_break) < 0)
		;
	return;
}


main(argc, argv)

int	argc;
char	*argv[];

{
	if(argc == 1)
		fd = open("/dev/cul00", O_RDWR | O_NDELAY);
	else
		fd = open(argv[1], O_RDWR | O_NDELAY);
	
	if(fd < 0) {
		puts("Unable to open device, bye...");
		exit(1);
	}

	ioctl(fd, TCGETA, &t);
	t.c_lflag &= ~ICANON;
	t.c_cc[VMIN] = 1;
	t.c_cc[VTIME] = 0;
	t.c_iflag = IXON | IXOFF | ISTRIP;
	t.c_oflag = OPOST | ONLCR;
	t.c_cflag = B9600 | CS8 | CREAD | CLOCAL;
	ioctl(fd, TCSETA, &t);
	/*
	 * hey this looks like real UN*X to me!
	 */

	ioctl(fd, GETCTLBITS, &o);
	o.cntl_bits |= ENQACKON;
	ioctl(fd, SETCTLBITS, &o);

	fcntl(fd, F_SETFL, O_RDWR);

	tty = open("/dev/tty", O_RDWR);
	ioctl(tty, TCGETA, &con);
	old_con = con;
	con.c_iflag |= INLCR;
	con.c_iflag &= ~ICRNL;
	con.c_lflag &= ~ICANON & ~ECHO;
	con.c_cc[VMIN] = 1;
	con.c_cc[VTIME] = 0;
	ioctl(tty, TCSETA, &con);


	puts("Ready...");

	if(child = fork()) {    /* read console and write to serial */
		signal(SIGINT, h_break);
		signal(SIGQUIT, done);
		while(1) {
			i = read(tty, conbuf, 100);
			if(sig_rec) {
				sig_rec = 0;

				ioctl(tty, TCGETA, &con);
				con.c_cc[VMIN] = 0;
				con.c_cc[VTIME] = 0;
				ioctl(tty, TCSETA, &con);

				send_break();
				ioctl(tty, TCGETA, &con);
				con.c_cc[VMIN] = 1;
				con.c_cc[VTIME] = 0;
				ioctl(tty, TCSETA, &con);

				continue;
			}
			write(fd, conbuf, i);
		}
	} else {        /* read serial and write to console */
		signal(SIGINT, SIG_IGN);
		while(1) {
			i = read(fd, fdbuf, 100);
			write(tty, fdbuf, i);
		}
	}
}

done()
{

	ioctl(tty, TCSETA, &old_con);
	kill(child, 9);
	write(tty, "\nBye...\n", 8);
	exit(0);
}
Technical Details
Message-ID: <15100009@hpcvlo.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utcs!mnetor!seismo!nbires!hao!hplabs!hp-pcd!ken
References: <581@batcompu.UUCP>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!utcs!mnetor!seismo!nbires!hao!hplabs!hp-pcd!ken
From: ken@hp-pcd.UUCP
Newsgroups: net.micro.hp
Subject: Re: Re: Response to <547@batcompu>
Message-ID: <15100009@hpcvlo.UUCP>
Date: Mon, 14-Jul-86 21:00:00 EDT
Article-I.D.: hpcvlo.15100009
Posted: Mon Jul 14 21:00:00 1986
Date-Received: Fri, 18-Jul-86 05:49:52 EDT
References: <581@batcompu.UUCP>
Organization: Hewlett-Packard - Corvallis, OR
Lines: 137
Nf-ID: #R:batcompu:-58100:hpcvlo:15100009:000:2368
Nf-From: hpcvlo!ken    Jul 14 17:00:00 1986