This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Unbuffered line input and the GNU library


>>>>> "Ish" == Ish Rattan <ishwar@pali.cps.cmich.edu> writes:

    Ish> On Mon, 19 Aug 2002, Steve Dondley wrote:
    >> function.  However, I did a grep on every *.h file on my
    >> computer and wasn't
    Ish> It is a macro defined in /usr/include/stdio.h

I can't find it there (glibc 2.2.5 Debian GNU/Linux). What's the
version of your C library that you're using?

Usually, in order to get unbuffered line input you need to switch the
terminal to unbufferd input mode (and properly restore it when done -
I guess this wouldn't work with a simple macro; I'd really like to see
the macro if it really is there).

Here's some code I used for this purpose:

,----
|   struct termios tio_orig;
|   struct termios tio_new;
| 
|   tcgetattr(0, &tio_orig);
| 
|   tio_new = tio_orig;
|   tio_new.c_lflag &= ~(ICANON|ECHO); /* Clear ICANON and ECHO. */
|   tcsetattr(0,TCSANOW,&tio_new);
|   
|   /* ... */
| 
|   tcsetattr(0,TCSANOW,&tio_orig);
`----

Cheers.

-- 
Claudio Bley                                                        _ 
                                             ASCII ribbon campaign ( )
ICQ# 83197241                                 - against HTML email  X 
http://www.cs.uni-magdeburg.de/~bley/                     & vCards / \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]