THE LAST WORD (HOPEFULLY) ON THE GREAT IOCTL DEBATE

MS W420 chen at MITRE-GATEWAY.ARPA
Wed Aug 14 04:05:50 AEST 1985


Hmmmm.  Reminds me of something I did a while back.  I was working on
a multi-window vi that was to run under curses.  Needless to say,
I quickly discovered that curses really sucks if you want to do any
non-trivial tty-driver handling.

I ended up writing a set of library routines to handle tty drivers
in a portable way.  My goal was to enable application programs
to handle tty driver settings as states or objects.

Instead of calling a routine to immediately change the state of the
driver, you pass a structure representing some tty state to a routine
and tell it what operation you want performed on that state.  The routine
gives you back a structure and sets an error field in that structure if
the current tty driver can't accomodate your request.  After you've
monkeyed around with a tty structure to your heart's content, you can
then call a routine with a tty structure as a parameter which will
set the state of the real tty to correspond to the state of the tty
structure.  There's also a routine which returns a structure that
reflects the current state of the real tty.

This enables an application program to find out about the capabilities
of its tty driver, get the current settings, keep many different
terminal settings around, and switch among them at will.

The applications programs see only a defined structure
and a set of routines.  The definition of the structure
changes from system to system but the user does nothing
with the structure other than store them, pass them to the
library routines, and check the error field (which exists in
all incarnations).

When I stopped working on it, the library could handle everything
vi needed to do.  Set/reset special characters, cbreak, echo, tabs,
etc.  Although I've only been able to test it under 4.2,
it should (or will) run under 4.x, 2.x, v7, v8, and System V.

I don't have the code lying around at the moment, but if
anybody's interested in it, drop me a line.  Or you could
always redo it yourself if you're feeling particularly
masochistic.  It wasn't hard, just tedious.

	Ray Chen
	chen at mitre-gw



More information about the Comp.unix.wizards mailing list