|
|
1.1 ! root 1: /* ! 2: * File: tty_mode.c ! 3: * ! 4: * Purpose: transfer modes between tty devices ! 5: * ! 6: * $Log: tty_mode.c,v $ ! 7: * Revision 1.2 92/06/15 10:04:58 bin ! 8: * *** empty log message *** ! 9: * ! 10: */ ! 11: ! 12: /* ! 13: * Includes. ! 14: */ ! 15: #include <sgtty.h> ! 16: ! 17: /* ! 18: * Definitions. ! 19: * Constants. ! 20: * Macros with argument lists. ! 21: * Typedefs. ! 22: * Enums. ! 23: */ ! 24: typedef unsigned char uchar; ! 25: typedef unsigned int uint; ! 26: typedef unsigned long ulong; ! 27: ! 28: /* ! 29: * Functions. ! 30: * Import Functions. ! 31: * Export Functions. ! 32: * Local Functions. ! 33: */ ! 34: int tty_getmode(); ! 35: int tty_setmode(); ! 36: ! 37: /* ! 38: * Global Data. ! 39: * Import Variables. ! 40: * Export Variables. ! 41: * Local Variables. ! 42: */ ! 43: static struct sgttyb tty_sgttyb; ! 44: static struct tchars tty_tchars; ! 45: ! 46: /* ! 47: * tty_getmode() ! 48: * ! 49: * Save modes for the given file descriptor. ! 50: */ ! 51: int ! 52: tty_getmode(fd) ! 53: int fd; ! 54: { ! 55: if (ioctl(fd, TIOCGETP, &tty_sgttyb) < 0) ! 56: return -1; ! 57: if (ioctl(fd, TIOCGETC, &tty_tchars) < 0) ! 58: return -1; ! 59: return 0; ! 60: } ! 61: ! 62: /* ! 63: * tty_setmode() ! 64: * ! 65: * Restore modes to the given file descriptor. ! 66: */ ! 67: int ! 68: tty_setmode(fd) ! 69: int fd; ! 70: { ! 71: if (ioctl(fd, TIOCSETP, &tty_sgttyb) < 0) ! 72: return -1; ! 73: if (ioctl(fd, TIOCSETC, &tty_tchars) < 0) ! 74: return -1; ! 75: return 0; ! 76: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.