Warp 6.0

Mark Plotnick mp at mit-eddie.UUCP
Thu Aug 25 00:00:38 AEST 1983


Here are some suggestions for two of the problems you'll have
making warp run on non-Berkeley UNIX.

Note that I'm talking about UNIX 3.0.1 here, which is probably the
same as System 3.  Perhaps you can do things in different ways
with System 5.

1) lack of FIONREAD.  While you can't get a count of characters waiting to
be read, you can set things up so that a read will slurp in all the
characters that have been typed ahead.  Warp's input_pending macro is used
in 3 different ways: once is to read all pending input (this can be replaced
by a single read() call), once is to sleep until any character is typed (I'm
not sure how to solve this one cleanly), and once to essentially flush all
typeahead (which you can do by simply reading until the count==0; perhaps
there's an ioctl call that'll do this for you).

2) lack of a simple bit to turn on RAW mode.  UNIX 3.0.1 had routines that
emulated stty and gtty, but if you use them you'll get bits such
as ECHOE turned off when you exit warp.

Here's some code I wrote that'll put your tty into RAW mode, with no echo,
and with non-blocking reads.

#include <termio.h>
#include <sys/types.h>
#include <fcntl.h>

	fd=open("/dev/tty",O_RDWR+O_NDELAY)

struct termio ttyjunk;
	
toraw()
{
	struct termio nttyjunk;

	ioctl(fd, TCGETA, &ttyjunk);
	nttyjunk=ttyjunk;
	nttyjunk.c_iflag = IGNBRK;	/* ignore break, no crnl
					   mapping, no ^S^Q */ 
	nttyjunk.c_oflag = 0;		/* no delays, no crlf mapping */
	nttyjunk.c_lflag &= ~(ISIG|ECHO|ICANON); /* no echo, signals,
					    or erase/kill processing */
	nttyjunk.c_cc[VMIN] =  1;	/* return after every character read */
	nttyjunk.c_cc[VTIME] = 1;

	ioctl(fd, TCSETAW, &nttyjunk);

unraw()
{
	ioctl(fd,TCSETAW, &ttyjunk);
}



More information about the Comp.sources.unix mailing list