[comp.unix.wizards] Specifying tty delimiter characters

gnu@hoptoad.uucp (John Gilmore) (05/11/88)

wcs@skep2.ATT.COM (Bill.Stewart.<ho95c>) wrote:
> One feature I've wished was available in a TTY driver is the ability to
> specify a bunch of characters (e.g. control characters), and tell it
> to "read until N input characters or a special character".

The Data General AOS system implemented this uniformly across the file
system.  If you did "data sensitive" reads, it would read up to a delimiter
and just return you that much.  This was true of files as well as devices.
You could default the delimiter table (to CR, NL, FF, NUL, etc) or specify
it, as a 256-bit table.  The data-sensitive mode could be specified at
open time, or on individual reads.

On a Unix system, I suspect that the right place to make this pervasive
is in standard I/O.  On disk files, it would itself scan for the
delimiters; on ttys on old Unix systems, it would do raw mode reads; on
ttys on enhanced Unix systems, it could pass the delimiter table to the
kernel and let it terminate a longer, less resource-ful read.  You'd
need to define and implement a couple of new stdio functions for "read
up to delimiter", "set delimiter table", and "write up to delimiter".
Then wait til enough people use them so that the kernels can be
improved to deal.
-- 
John Gilmore  {sun,pacbell,uunet,pyramid,ihnp4}!hoptoad!gnu        gnu@toad.com
"Use the Source, Luke...."

rbj@icst-cmr.arpa (Root Boy Jim) (05/13/88)

   wcs@skep2.ATT.COM (Bill.Stewart.<ho95c>) wrote:
   > One feature I've wished was available in a TTY driver is the ability to
   > specify a bunch of characters (e.g. control characters), and tell it
   > to "read until N input characters or a special character".

Why don't you just write a wrapper function to do this?

	(Root Boy) Jim Cottrell	<rbj@icst-cmr.arpa>
	National Bureau of Standards
	Flamer's Hotline: (301) 975-5688
	The opinions expressed are solely my own
	and do not reflect NBS policy or agreement
I need to discuss BUY-BACK PROVISIONS with at least six studio SLEAZEBALLS!!

duncan@comp.vuw.ac.nz (Duncan McEwan) (05/18/88)

In article <14341@brl-adm.ARPA> rbj@icst-cmr.arpa (Root Boy Jim) writes:
>   wcs@skep2.ATT.COM (Bill.Stewart.<ho95c>) wrote:
>   > One feature I've wished was available in a TTY driver is the ability to
>   > specify a bunch of characters (e.g. control characters), and tell it
>   > to "read until N input characters or a special character".
>
>Why don't you just write a wrapper function to do this?

A wrapper function could certainly do the job, but one possible reason for
putting it in the kernel would be to allow for programs that need the
flexibility but don't want the overhead of running in raw or cbreak modes.  For
example command line editing shells only need to gain control when an editing
character is typed.  Most (?) of the time the user does not edit the command
line.

I don't know how hard this facility would be to add - I guess the `additional
break character' of the 4.[23]bsd tty driver could be made into a bitmap,
and an ioctl added to alter it.

Unfortunately, inadvertently leaving a tty with a break character mask that did
not correspond to current unix behaviour would probably break many programs
that expect to get a full line when they read from a tty.  With the increasing
use of personal workstations, is the saving of a little extra load on the cpu
due to shells wanting to run in cbreak or raw mode worth these problems?

Duncan

Domain: duncan@comp.vuw.ac.nz		Path: ...!uunet!vuwcomp!duncan