tty.h revision 1.1
1/*
2	tty.h -- centralized definitions for a variety of terminal interfaces
3
4	created by DPK, Oct. 1986
5
6	Rearranged to work with autoconf, added TTY_state, get_tty/set_tty
7						Michael Rendell, May '94
8
9	last edit:	30-Jul-1987	D A Gwyn
10*/
11/* $Id: tty.h,v 1.1 1996/09/21 23:35:17 jtc Exp $ */
12
13/* some useful #defines */
14#ifdef EXTERN
15# define I__(i) = i
16#else
17# define I__(i)
18# define EXTERN extern
19# define EXTERN_DEFINED
20#endif
21
22#ifdef	HAVE_TERMIOS_H
23# include <termios.h>
24typedef struct termios TTY_state;
25#else
26# ifdef HAVE_TERMIO_H
27#  include <termio.h>
28#  if _BSD_SYSV			/* BRL UNIX System V emulation */
29#   ifndef NTTYDISC
30#    define	TIOCGETD	_IOR( 't', 0, int )
31#    define	TIOCSETD	_IOW( 't', 1, int )
32#    define	NTTYDISC	2
33#   endif
34#   ifndef TIOCSTI
35#    define	TIOCSTI		_IOW( 't', 114, char )
36#   endif
37#   ifndef TIOCSPGRP
38#    define	TIOCSPGRP	_IOW( 't', 118, int )
39#   endif
40#  endif /* _BSD_SYSV */
41typedef struct termio TTY_state;
42# else /* HAVE_TERMIO_H */
43/* Assume BSD tty stuff.  Uses TIOCGETP, TIOCSETN; uses TIOCGATC/TIOCSATC if
44 * available, otherwise it uses TIOCGETC/TIOCSETC (also uses TIOCGLTC/TIOCSLTC
45 * if available)
46 */
47#  ifdef _MINIX
48#   include <sgtty.h>
49#   define TIOCSETN	TIOCSETP
50#  else
51#   include <sys/ioctl.h>
52#  endif
53typedef struct {
54	struct sgttyb	sgttyb;
55#  ifdef TIOCGATC
56	struct lchars	lchars;
57#  else /* TIOCGATC */
58	struct tchars	tchars;
59#   ifdef TIOCGLTC
60	struct ltchars	ltchars;
61#   endif /* TIOCGLTC */
62#  endif /* TIOCGATC */
63} TTY_state;
64# endif /* HAVE_TERMIO_H */
65#endif /* HAVE_TERMIOS_H */
66
67/* Flags for set_tty() */
68#define TF_NONE		0x00
69#define TF_WAIT		0x01	/* drain output, even it requires sleep() */
70#define TF_MIPSKLUDGE	0x02	/* kludge to unwedge RISC/os 5.0 tty driver */
71
72EXTERN int		tty_fd I__(-1);	/* dup'd tty file descriptor */
73EXTERN int		tty_devtty;	/* true if tty_fd is from /dev/tty */
74EXTERN TTY_state	tty_state;	/* saved tty state */
75
76extern int	get_tty ARGS((int fd, TTY_state *ts));
77extern int	set_tty ARGS((int fd, TTY_state *ts, int flags));
78extern void	tty_init ARGS((int init_ttystate));
79extern void	tty_close ARGS((void));
80
81/* be sure not to interfere with anyone else's idea about EXTERN */
82#ifdef EXTERN_DEFINED
83# undef EXTERN_DEFINED
84# undef EXTERN
85#endif
86#undef I__
87