1 #ifdef TERMIOS
2 # include <termios.h>
3 #else
4 # ifdef TERMIO
5 #  include <termio.h>
6 # else
7 #  include <sgtty.h>
8 #  ifndef TIOCFLUSH
9 #   include <sys/ioctl.h>
10 #  endif
11 #  ifndef FREAD
12 #   include <sys/file.h>
13 #  endif
14 # endif
15 #endif
16 
17 #ifdef PTEM
18 # include <sys/stream.h>
19 # include <sys/ptem.h>
20 #endif
21 
22 #ifndef TIOCGWINSZ
23 # include <sys/ioctl.h>
24 #endif
25 
26 #ifndef TERMIOS
27 # ifdef TERMIO
28 #  define termios termio
29 #  define tcgetattr(fd, tty_p)		ioctl((fd), TCGETA, (tty_p))
30 #  define tcsetattr(fd, opt, tty_p)	ioctl((fd), (opt), (tty_p))
31 #  define  TCSANOW	TCSETA
32 #  define  TCSADRAIN	TCSETAW
33 #  define  TCSAFLUSH	TCSETAF
34 #  define tcflush(fd, mode)		ioctl((fd), TCFLSH, (mode))
35 #  define  TCIFLUSH	0
36 #  define  TCOFLUSH	1
37 #  define  TCIOFLUSH	2
38 # else
39 #  define termios sgttyb
40 #  define tcgetattr(fd, tty_p)		ioctl((fd), TIOCGETP, (tty_p))
41 #  define tcsetattr(fd, opt, tty_p)	ioctl((fd), (opt), (tty_p))
42 #  define  TCSANOW	TIOCSETN
43 #  define  TCSADRAIN	TIOCSETN
44 #  define  TCSAFLUSH	TIOCSETP
45 #  define ttflush(fd, mode)		ioctl((fd), TIOCFLUSH, (mode))
46 #  define  TCIFLUSH	FREAD
47 #  define  TCOFLUSH	FWRITE
48 #  define  TCIOFLUSH	(FREAD|FWRITE)
49 # endif /*TERMIO*/
50 #endif /*TERMIOS*/
51 
52