Achieving CBREAK without Curses

"Gary S. Moss", VLD/VMB moss at BRL.MIL
Mon Jul 24 23:44:00 AEST 1989


Under System V, you should be using the termio structure rather than sgtty.
The way to simulate CBREAK mode would be to turn canonical input processing
OFF, and set up the VMIN and VTIME flags to 1 and zero respectively.  Below
is an excerpt from a library of mine which works on both BSD and SYSV, I
have stripped out the BSD stuff for this example, and it is incomplete, but
you should get the idea.  The library is part of BRL CAD (libtermio), but
if you don't have it and want just the library, send me a note, it is only
a few pages of sources.

	-moss

#include <termio.h>

struct termio tio;

/*	clrCbreak() -- turn CBREAK mode off */
clrCbreak()
	{
	tio.c_lflag |= ICANON;	/* Canonical input ON. */
	tio.c_cc[VEOF] = 4;	/* Defaults! Best we can do.... */
	tio.c_cc[VEOL] = 0;
	(void) ioctl( 0, TCSETA, &tio );
	}

/*	setCbreak() -- turn CBREAK mode on */
setCbreak()
	{
	tio.c_lflag &= ~ICANON;	/* Canonical input OFF. */
	tio.c_cc[VMIN] = 1;
	tio.c_cc[VTIME] = 0;
	(void) ioctl( 0, TCSETA, &tio );
	}



More information about the Comp.sys.sgi mailing list