|
|
1.1 ! root 1: #include <termio.h> ! 2: static struct termio save_tio; ! 3: ! 4: setraw(on) ! 5: int on; ! 6: { ! 7: struct termio tio; ! 8: ! 9: ioctl(0, TCGETA, (char *)&tio); ! 10: if (on) { ! 11: tio.c_lflag &= ~ICANON; ! 12: tio.c_iflag &= ~ICRNL; ! 13: tio.c_cc[VMIN] = 1; ! 14: tio.c_lflag &= ~ECHO; ! 15: tio.c_cc[VINTR] = -1; ! 16: } else { ! 17: tio.c_lflag |= ICANON; ! 18: tio.c_iflag |= ICRNL; ! 19: tio.c_cc[VMIN] = 1; ! 20: tio.c_lflag |= ECHO; ! 21: tio.c_cc[VINTR] = -1; ! 22: } ! 23: ioctl(0, TCSETA, (char *)&tio); ! 24: } ! 25: ! 26: ! 27: setecho(on) ! 28: int on; ! 29: { ! 30: struct termio tio; ! 31: ! 32: ioctl(0, TCGETA, (char *)&tio); ! 33: if (on) { ! 34: tio.c_lflag |= ECHO; ! 35: } else { ! 36: tio.c_lflag &= ~ECHO; ! 37: } ! 38: ioctl(0, TCSETA, (char *)&tio); ! 39: } ! 40: ! 41: savetty() ! 42: { ! 43: ioctl(0, TCGETA, (char *)&save_tio); ! 44: } ! 45: ! 46: restoretty() ! 47: { ! 48: ioctl(0, TCSETA, (char *)&save_tio); ! 49: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.