printf, data presentation

Knudsen knudsen at ihlpl.ATT.COM
Thu Jan 5 04:59:03 AEST 1989


Speaking of libraries and interactive screen programs,
it strikes me as criminal negligence that hardly any C standard
libs include the inkey() function, which means "check whether
a char has been typed on the keyboard; if so, return it;
else return \0 (or whatever).  DO NOT BLOCK."

Even a blocking version (that would return a char once typed,
without waiting for a newline) would be useful.

Most OSes make the inkey() function possible, but hardly easy.
I figured out how to do it in OS9, and someday I may borrow
a chapter 7 of the sys-adm's U**X manual long enuf to write
one for System V.  I know it takes a lot of ioctl() bashing.
I have also done the blocking version in U**X, using fcntl().

My point is that some guru should have figured out how to do
inkey() on the OS in question and put this in the library.
Then ordinary programmers wouldn't have to figure it out
for the zillionth time.
[Given that U**X was born on DEC machines with full-duplex
TTYs, I'm surprised that the C library didn't get inkey()
early on.  I guess VI and EMACS didn't come till much later.]

Anyway, it's the need for such functions that often keeps interactive
applications from using the buffered (f-names) I/O fcns.

Ironically, inkey() is built into every "toy" computer with
BASIC in ROM.  The joys of having no OS...
-- 
Mike Knudsen  Bell Labs(AT&T)   att!ihlpl!knudsen
"Lawyers are like nuclear bombs and PClones.  Nobody likes them,
but the other guy's got one, so I better get one too."



More information about the Comp.unix.wizards mailing list