|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
ioctl() and termios for "canonical" read
Well, this app is giving me quite a headache
![]() I need to have a program read a char at a time and then process it, using read(). Therefore, I'll have to set the terminal to canonical mode (correct?), using ioctl() along with termios' flags. What I just can't get is what flag to use and wich values to set (I've already read ALL the man page...). My best bet is using the c_lflag and manipulating it's ICANON value. Can somebody point out a good solution for this problem? Some sample code would be usefull, I'm not very skilled... Thanx in advance! PS: I can't use getchar ![]() |
|
#2
|
|||
|
|||
|
Here's how to, if anyone ever needs it
main(){
struct termios oldT, newT; char c; ioctl(0,TCGETS,&oldT); /*get current mode newT=oldT; newT.c_lflag &= ~ECHO; /* echo off */ newT.c_lflag &= ~ICANON; /*one char @ a time*/ ioctl(0,TCSETS,&newT); /* set new terminal mode */ read(0,&c,1); /*read 1 char @ a time from stdin*/ ioctl(0,TCSETS,&oldT); /* restore previous terminal mode */ } Detailed info on: http://www.unidata.ucar.edu/cgi-bin/man-cgi?termio+7 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages > C Programming > ioctl() and termios for "canonical" read |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|