[comp.unix.xenix] CBREAK on SCO XENIX

tb@pemstgt.gtc.de (Tillmann Basien) (07/06/90)

Hy,
I have a source code of a keyboard-programm under SCO XENIX 2.3.2 and I
want to compile it under SCI UNIX 3.2.

SCO UNIX 3.2 does not know CBREAK and I don't find anything in the doc.

Here the source:

	static int set_tty()
	{
	   struct sgttyb _t;
	   if ((KB_LINE=open("/dev/tty", O_RDWR))<0) return -1;
	   gtty (KB_LINE,&_t);
	   old_flags = _t.sg_flags;
	   /* don't echo chars, don't expand tabs, no RAW-mode */
	   _t.sg_flags &= ~(ECHO | CRMOD | RAW | XTABS) ;
	   /* but CBREAK */
	   _t.sg_flags |= CBREAK;
	   stty (KB_LINE,&_t);
	return 0;

	}  /*  set_tty  */

What kind of flag is CBREAK, what does it mean?
What ist the UNIX equivilant for it?

Thanks to all of you

Tillmann
-- 
Dipl.Ing. Tillmann Basien			   tb@pemstgt.gtc.de
Programmentwicklung fuer Microcomputer		   unido!gtc!pemstgt!tb	UUCP
Vaihinger Str.49, PostBox 810165		      +49-711-713047	FAX
7000 Stuttgart 80- West Germany                       +49-711-713045	PHONE

hb@vpnet.chi.il.us (hank barta) (07/14/90)

> 
> What kind of flag is CBREAK, what does it mean?
> What ist the UNIX equivilant for it?

The header <sys/ttold.h> has a define O_CBREAK 02. Could this be what you are
looking for? (There are also flags for O_ECHO, O_CRMOD, O_RAW usw.)

hank

wht@n4hgf.Mt-Park.GA.US (Warren Tucker) (07/24/90)

> What kind of flag is CBREAK, what does it mean?
> What ist the UNIX equivilant for it?

CBREAK may be found but it is also unsupported :-).
It is a "half-cooked" mode found in BSD.  CBREAK made it into
XENIX sgtty.h, but I have never been able to get it to work.

From a BSD man page:

 CBREAK    This mode eliminates the character, word, and line
           editing input facilities, making the input charac-
           ter available to the user program as it is typed.
           Flow control, literal-next and interrupt process-
           ing are still done in this mode.  Output
           processing is done.


 
----------------------------------------------------------------------
Warren Tucker, TuckerWare   emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
"It was electrons that brought down the Berlin Wall." -- Timothy Leary

iverson@xstor.UUCP (Tim Iverson) (07/25/90)

In article <173@n4hgf.Mt-Park.GA.US> wht@n4hgf.UUCP (Warren Tucker) writes:
>> [paraphrased] What's CBREAK?  What's the UNIX equivilant for it?
>
>CBREAK may be found but it is also unsupported :-).
>It is a "half-cooked" mode found in BSD.  CBREAK made it into
>XENIX sgtty.h, but I have never been able to get it to work.

It's used mostly to unbuffer tty input so that programs can get a key as it
is typed (e.g. rn, emacs, vi, jove, etc. all use cbreak mode or its
equivilent).  Under Xenix, support for this is provided via the termio 
library calls as follows (see the termio manual entry for details):

{
	struct termio	t;
	int		gotkey;
	char		key;

	/* NB - on a real implementation, you should also
	 *	save the current setting to restore before you leave.
	 */
	ioctl(0, TCGETA, &t);		/* get current settings */
	t.c_iflag &= ~ICANON;		/* turn off editing & line buffering */
	t.c_cc[VMIN] = 1;		/* return at least 1 char, */
	t.c_cc[VTIME] = 0;		/*   but don't wait for more chars */
	ioctl(0, TCSETA, &t);

	gotkey = read(0, key, 1) == 1;	/* get just one key */
}

>Warren Tucker, TuckerWare   emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
>"It was electrons that brought down the Berlin Wall." -- Timothy Leary

- Tim Iverson
  uunet!xstor!iverson

wht@n4hgf.Mt-Park.GA.US (Warren Tucker) (07/25/90)

In article <192@xstor.UUCP> iverson@xstor.UUCP (Tim Iverson) writes:
>In article <173@n4hgf.Mt-Park.GA.US> wht@n4hgf.UUCP (Warren Tucker) writes:
>>> [paraphrased] What's CBREAK?  What's the UNIX equivilant for it?
>>
>>CBREAK may be found but it is also unsupported :-).
>It's used mostly to unbuffer tty input so that programs can get a key as it
>is typed (e.g. rn, emacs, vi, jove, etc. all use cbreak mode or its
>equivilent).  Under Xenix, support for this is provided via the termio 
>library calls as follows (see the termio manual entry for details):

Or by comm programs :-)

CBREAK, however, doesn't work.  I must prefer termio to the cluster
of structures you need for BSD tty support, but if CBREAK worked, I
wouldn't have to 'modernize' progras I port, then keeping ifdefs
around to keep the BSD stuff working.

 
--------------------------------------------------------------------
Warren Tucker, TuckerWare emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
E = I * R, if you're lucky, and only then on alternate Tuesdays.