home *** CD-ROM | disk | FTP | other *** search
- /* gstty.c -- get and set terminal parameters
-
- Author: Craig Bishop
- modified by David MacKenzie
- loosly based on original program by Michael Cooper. */
-
- #include <sys/ioctl.h>
-
- #ifdef SYSV
- #include <termio.h>
-
- static struct termio old_mode;
- static struct termio new_mode;
-
- /* Put terminal in raw mode. */
-
- void
- setterm ()
- {
- ioctl (0, TCGETA, &old_mode);
- new_mode = old_mode;
- new_mode.c_lflag &= ~ICANON;
- new_mode.c_lflag &= ~ECHO;
- new_mode.c_cc[VMIN] = 1;
- new_mode.c_cc[VTIME] = 0;
- ioctl (0, TCSETAF, &new_mode);
- }
-
- /* Put terminal back in previous mode. */
-
- void
- fixterm ()
- {
- ioctl (0, TCSETAF, &old_mode);
- }
-
- #else
- static struct sgttyb old_mode;
- static struct sgttyb new_mode;
-
- /* Put terminal in raw mode. */
-
- void
- setterm ()
- {
- ioctl (0, TIOCGETP, &old_mode);
- new_mode = old_mode;
- new_mode.sg_flags |= CBREAK;
- new_mode.sg_flags &= ~ECHO;
- ioctl (0, TIOCSETP, &new_mode);
- }
-
- /* Put terminal back in previous mode. */
-
- void
- fixterm ()
- {
- ioctl (0, TIOCSETP, &old_mode);
- }
-
- #endif /* SYSV */
-