<>++fab > desole pour de contre temps, j'ai du me construire un linux vite fait.
Ci -dessous une fonction qui passe la ligne en mode "raw" . juste pour
ne pas rester bloque en attente apres avoir recu 1 caractere. VTIME et
VMIN sont expliques dans le man de termios. Dans mon code on
attend VMIN = 1 caractere et l'on retourne immediatement. il n'y
a pas de timeout VTIME.
**************************************************************************/
#include <stdio.h>
>
#include <termios.h>
struct termios Line_New_Setting,
Line_Old_Setting;
/***************** un exemple d'utilisation de la fonction ********/
int main(){
int c;
setRawAttr(fileno(stdin));
while(1)
c = fgetc(stdin);
}
/*****************************************************/
int setRawAttr(int fd){
extern struct termios Line_New_Setting,
Line_Old_Setting;
if(tcgetattr(fd,&Line_Old_Setting) < 0) {
perror("Ioctl Get error");
return -1;
}
Line_New_Setting = Line_Old_Setting;
Line_New_Setting.c_lflag &= ~ICANON; /* non canonical mode */
Line_New_Setting.c_lflag &= ~ISIG; /* ignore ^C*/
Line_New_Setting.c_cc[VMIN] = 1; /* return after 1 char has been read */
Line_New_Setting.c_cc[VTIME] = 0; /* in .1 seconds */
Line_New_Setting.c_cc[VQUIT] = 0;
Line_New_Setting.c_lflag &= ~ECHO; /* disable echo */
Line_New_Setting.c_oflag |= (OPOST | ONLCR); /* enable Opost and nl to cr nl conversion */
/* set the new terminal attributes */
if(tcsetattr(fd,TCSAFLUSH,&Line_New_Setting) < 0){
perror("Ioctl Set error");
return -1;
}
return (0);
}
Yves