CBREAK on Interactive Unix 2.2

bria!mike bria!mike
Wed Jan 23 12:21:53 AEST 1991


In an article, ncs.dnd.ca!marwood (Gordon Marwood) writes:
>I shall shortly be transferring from a MicroVAX Ultrix system to one
>using Interactive Unix 2.2.  In preparation for this I am transfering a
>number of programs over to the new system.  One of these uses CBREAK in
>a function which changes mode to allow "hot-key" interaction by the user.
>The Interactive C compiler cannot seem to find CBREAK, and generates an
>error.  Any assistance to solve this problem would be appreciated.

The only cbreak function that I'm aware of is in curses(3); if you need
the equivalent without using curses, here ya' go:

#include <termio.h>

int cbreak(mode)
int mode;
{
static struct termio old, new;
int oncethru = 0, israw = 0;

	if ( ! oncethru ) {
		ioctl(0,TCGETA,&old);
		ioctl(0,TCGETA,&new);
		oncethru = 1;
		}

	if ( mode && (! israw) ) {
		new.c_lflag &= ~ECHO;
		new.c_lflag &= ~ICANON;
		new.c_lflag &= ~ISIG;
		new.c_cc[VMIN] = 1;
		new.c_cc[VTIME] = 0;
		ioctl(0,TCSETA,&new);
		}
	else {
		ioctl(0,TCSETA,&old);
		israw = 0;
		}
}

Thus, using cbreak(1) would put the terminal into cbreak mode, which will
return one character at a time; using cbreak(0) would put the terminal
back into canonical mode.

-- 
Michael Stefanik, Systems Engineer (JOAT), Briareus Corporation
UUCP: ...!uunet!bria!mike
--
technoignorami (tek'no-ig'no-ram`i) a group of individuals that are constantly
found to be saying things like "Well, it works on my DOS machine ..."



More information about the Comp.unix.questions mailing list