105 static struct termios Otty, Ntty;
112 Ntty.c_lflag &= ~ICANON;
113 Ntty.c_cc[VMIN] = CMIN;
114 Ntty.c_cc[VTIME] = CTIME;
116 if (0 == (error = tcsetattr(0, TCSANOW, &Ntty)))
119 error += ioctl(0, FIONREAD, &cnt);
120 error += tcsetattr(0, TCSANOW, &Otty);
123 select(1,
nullptr,
nullptr,
nullptr, &tv);
125 return (error == 0 ? cnt : -1 );
133 static struct termios Otty, Ntty;
141 Ntty.c_lflag &= ~ICANON;
142 Ntty.c_lflag &= ~ECHO;
143 Ntty.c_cc[VMIN] = CMIN;
144 Ntty.c_cc[VTIME] = CTIME;
150# define FLAG TCSAFLUSH
157 if (0 == (error = tcsetattr(0, FLAG, &Ntty)))
159 error = read(0, &ch, 1 );
160 error += tcsetattr(0, FLAG, &Otty);
162 return (error == 1 ? (
int) ch : -1 );
170 static struct termios Otty, Ntty;
178 Ntty.c_lflag &= ~ICANON;
179 Ntty.c_lflag |= ECHO;
180 Ntty.c_cc[VMIN] = CMIN;
181 Ntty.c_cc[VTIME] = CTIME;
187# define FLAG TCSAFLUSH
194 if (0 == (error = tcsetattr(0, FLAG, &Ntty))) {
195 error = read(0, &ch, 1 );
196 error += tcsetattr(0, FLAG, &Otty);
199 return (error == 1 ? (
int) ch : -1 );