Path: utzoo!censor!geac!jtsv16!uunet!ginosko!ctrsol!uakari.primate.wisc.edu!csd4.milw.wisc.edu!marque!lakesys!davef
From: davef@lakesys.UUCP (Dave Fenske)
Newsgroups: comp.lang.c
Subject: Re: ReadKey like Function in C
Message-ID: <941@lakesys.UUCP>
Date: 10 Aug 89 03:21:27 GMT
References: <148@trigon.UUCP> <207600029@s.cs.uiuc.edu>
Reply-To: davef@lakesys.UUCP (Dave Fenske)
Organization: Lake Systems - Milwaukee, Wisconsin
Lines: 18

In article <207600029@s.cs.uiuc.edu> mccaugh@s.cs.uiuc.edu writes:
>
> Wait a minute -- am I missing something here? Isn't conventional (Kernighan-
> Ritchie) C supoosed to be capable of system-calls to the operating-system, 
> say, to switch I/O-mode from cooked to raw, thereby obviating the  on
> char-input, then switching back when done?

Absolutely!  You need only do the following:

1.  do an "ioctl (n, TCGETA, &term)
2.  modify some parameters, such as
    term.c_lflag &= ~(ICANON | ECHO)  or whatever else you need
3.  term.c_cc [VTIME] = some_value  <- for timeout, if desired
4.  term.c_cc [VMIN] = 1  <- satisfy read with 1 character
5.  ioctl (m, TCSETA, &term)  to reset the terminal
6.  you can now do a read (n, &work, 10)  

You might need/want to reset the terminal, but these are the basic steps.