#ifndef _TERMINAL_H
#define _TERMINAL_H 1
#ifdef _hdr_termios
# include <termios.h>
# ifdef __sgi
# ifndef ECHOCTL
# define ECHOCTL ECHOE
# endif
# ifndef CNSUSP
# define CNSUSP CNSWTCH
# endif
# endif
#else
# ifdef _sys_termios
# include <sys/termios.h>
# define _hdr_termios
# endif
#endif
#if !defined(TCSETS) && !defined(TCSANOW)
#undef _hdr_termios
#undef _sys_termios
#endif
#ifdef _hdr_termios
# ifndef TCSANOW
# define TCSANOW TCSETS
# define TCSADRAIN TCSETSW
# define TCSAFLUSH TCSETSF
# define tcgetattr(fd,tty) ioctl(fd, TCGETS, tty)
# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
# endif
# if defined(TCSADFLUSH) && !defined(TCSAFLUSH)
# define TCSAFLUSH TCSADFLUSH
# endif
# undef TIOCGETC
# undef _hdr_termio
# undef _sys_termio
# undef _hdr_sgtty
# undef _sys_ioctl
# undef _sys_bsdtty
#else
# undef OLDTERMIO
#endif
#ifdef _hdr_termio
# include <termio.h>
#else
# ifdef _sys_termio
# include <sys/termio.h>
# define _hdr_termio 1
# endif
#endif
#if !defined(VEOL2) || !defined(TCGETA)
#undef _hdr_termio
#undef _sys_termio
#endif
#ifdef _hdr_termio
# define termios termio
# undef _hdr_sgtty
# undef TIOCGETC
# undef _sys_ioctl
# define tcgetattr(fd,tty) ioctl(fd, TCGETA, tty)
# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
#endif
#ifdef _sys_bsdtty
# include <sys/bsdtty.h>
#endif
#ifdef _hdr_sgtty
# include <sgtty.h>
# ifdef _sys_nttyio
# ifndef LPENDIN
# include <sys/nttyio.h>
# endif
# endif
# define termios sgttyb
# undef _sys_ioctl
# ifdef TIOCSETN
# undef TCSETAW
# endif
# ifdef _SELECT_
# ifndef included_sys_time
# ifdef _sys_time
# include <sys/time.h>
# endif
# define included_sys_time
# endif
extern const int tty_speeds[];
# endif
# ifdef TIOCGETP
# define tcgetattr(fd,tty) ioctl(fd, TIOCGETP, tty)
# define tcsetattr(fd,action,tty) ioctl(fd, action, tty)
# else
# define tcgetattr(fd,tty) gtty(fd, tty)
# define tcsetattr(fd,action,tty) stty(fd, tty)
# endif
#endif
#ifndef TCSANOW
# ifdef TCSETAW
# define TCSANOW TCSETA
# ifdef u370
# define TCSADRAIN TCSETA
# else
# define TCSADRAIN TCSETAW
# endif
# define TCSAFLUSH TCSETAF
# else
# ifdef TIOCSETN
# define TCSANOW TIOCSETN
# define TCSADRAIN TIOCSETN
# define TCSAFLUSH TIOCSETP
# endif
# endif
#endif
#endif
#ifndef _hdr_termios
# define cfgetospeed(tp) ((tp)->c_cflag & CBAUD)
#endif
#ifdef LCTLECH
# ifndef ECHOCTL
# define ECHOCTL LCTLECH
# endif
#endif
#ifdef LNEW_CTLECH
# ifndef ECHOCTL
# define ECHOCTL LNEW_CTLECH
# endif
#endif
#ifdef LNEW_PENDIN
# ifndef PENDIN
# define PENDIN LNEW_PENDIN
# endif
#endif
#ifndef ECHOCTL
# ifndef VEOL2
# define RAWONLY 1
# endif
#endif
#ifdef _sys_filio
# ifndef FIONREAD
# include <sys/filio.h>
# endif
#endif
#ifdef FIONREAD
# ifndef FIORDCHK
# define FIORDCHK FIONREAD
# endif
#endif
#ifdef PROTO
extern int tty_alt(int);
extern void tty_cooked(int);
extern int tty_get(int,struct termios*);
extern int tty_raw(int);
extern int tty_check(int);
#else
extern int tty_alt();
extern void tty_cooked();
extern int tty_get();
extern int tty_raw();
extern int tty_check();
#endif
extern int tty_set();