[net.sources] Warp 6.0

rb@houxn.UUCP (08/17/83)

Our warp failed the make...
Running BTL UNIX.....got undefined's on SIGTTOU and FIONREAD...
Any Fixes out there?????

	Rob Botwin
	...houxn!rb

wolenty@inuxa.UUCP (08/23/83)

Has anyone come up with fixes yet for the undefined SIGTTOU and
FIONREAD functions in the Warp 6.0 distribution for BTL Unix 5.0???
- Ron

thomas@utah-gr.UUCP (Spencer W. Thomas) (08/24/83)

Well, after seeing this go by for a week with no answer, I'll put in my
two cents.  I'm not familiar with Unix 3.0 or 5.0, but I can tell you this:
SIGTTOU does NOT exist on these systems.  Comment out (or #ifdef SIGTTOU) the
lines in which it appears.  FIONREAD is used to determine if the player
has typed any characters (which will be in the input queue - it returns the
number of chars which can be read, thus NREAD).  I assume that there must
be an equivalent on 3.0 and 5.0, probably involving non-blocking I/O.

=Spencer

mp@mit-eddie.UUCP (Mark Plotnick) (08/24/83)

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);
}