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