/*	@(#)sgtty.h	13.3 (RC International) 91/08/30	 */

/*
 * This file contains definitions for the tty(4) interface (BSD) to terminals. 
 */

#ifndef __SGTTY
#define __SGTTY

#include <sys/ioctl.h>

/*
 * Structure for TIOCGETP/TIOCSETP ioctls.
 */
struct sgttyb {
    char		     sg_ispeed;	/* Input speed */
    char		     sg_ospeed;	/* Output speed */
    char		     sg_erase;	/* Erase character */
    char		     sg_kill;	/* Kill character */
    short		     sg_flags;	/* Local mode flags */
};

/*
 * Structure for TIOCGETC/TIOCSETC ioctls.
 */
struct tchars {
    char		     t_intrc;	/* Interrupt */
    char		     t_quitc;	/* Quit */
    char		     t_startc;	/* Start output */
    char		     t_stopc;	/* Stop output */
    char		     t_eofc;	/* End-of-file */
    char		     t_brkc;	/* Input delimiter (like nl) */
};

/*
 * Structure for TIOCGLTC/TIOCSLTC ioctls.
 */
struct ltchars {
    char		     t_suspc;	/* Stop process signal */
    char		     t_dsuspc;	/* Delayed stop process signal - n.s.*/
    char		     t_rprntc;	/* Reprint line - not supported */
    char		     t_flushc;	/* Flush output (toggles) - n.s. */
    char		     t_werasc;	/* Word erase */
    char		     t_lnextc;	/* Literal next character - n.s. */
};

/*
 * Certain ioctl's are kept here together with the
 * structures they manipulate.
 */
#define	TIOCGETP	_IOR('t', 8, struct sgttyb) /* get sgttyb structure */
#define	TIOCSETP	_IOW('t', 9, struct sgttyb) /* set sgttyb structure */
#define	TIOCSETN	_IOW('t', 10, struct sgttyb)
#define	TIOCSETC	_IOW('t', 17, struct tchars) /* get tchars structure */
#define	TIOCGETC	_IOR('t', 18, struct tchars) /* set tchars structure */
#define	TIOCLGET	_IOR('t', 124, int) /* get local mode word */
#define	TIOCLSET	_IOW('t', 125, int) /* set local mode word */
#define	TIOCLBIC	_IOW('t', 126, int) /* clear bit in local mode word */
#define	TIOCLBIS	_IOW('t', 127, int) /* set bit in local mode word */
#define	TIOCGLTC	_IOR('t', 116, struct ltchars) /* get ltchars struct */
#define	TIOCSLTC	_IOW('t', 117, struct ltchars) /* set ltchars struct */

/*
 * The input/output speeds in sgttyb.
 */
#define	CBAUD		0x0000000f	/* baud rates */
#define		B0	0x00000000	/* hang up */
#define		B50	0x00000001	/* n.s. */
#define		B75	0x00000002	/* n.s. */
#define		B110	0x00000003	/* n.s. */
#define		B134	0x00000004	/* n.s. */
#define		B150	0x00000005	/* n.s. */
#define		B200	0x00000006	/* n.s. */
#define		B300	0x00000007	/* 300 baud */
#define		B600	0x00000008	/* 600 baud */
#define		B1200	0x00000009	/* 1200 baud */
#define		B1800	0x0000000a	/* n.s. */
#define		B2400	0x0000000b	/* 2400 baud */
#define		B4800	0x0000000c	/* 4800 baud */
#define		B9600	0x0000000d	/* 9600 baud */
#define		B19200	0x0000000e	/* 19200 baud */
#define		B38400	0x0000000f	/* n.s. */
#define		EXTA	B19200
#define		EXTB	B38400

/*
 * The mode flags in sgttyb.
 */
#define	  TANDEM	0x00000001	/* Send stopc on out q full */
#define	  CBREAK	0x00000002	/* Half-cooked mode */
#define	  LCASE		0x00000004	/* Simulate lower case - n.s. */
#define	  ECHO		0x00000008	/* Echo input */
#define	  CRMOD		0x00000010	/* Map \r to \r\n on output */
#define	  RAW		0x00000020	/* No i/o processing */
#define	  ODDP		0x00000040	/* Get/send odd parity */
#define	  EVENP		0x00000080	/* Get/send even parity */
#define	  ANYP		0x000000c0	/* Get any parity/send none - n.s. */
#define	  NLDELAY	0x00000300	/* \n delay - n.s. */
#define		NL0	0x00000000	/* n.s. */
#define		NL1	0x00000100	/* tty 37 - n.s. */
#define		NL2	0x00000200	/* vt05 - n.s. */
#define		NL3	0x00000300	/* n.s. */
#define	  TBDELAY	0x00000c00	/* Horizontal tab delay - n.s. */
#define		TAB0	0x00000000	/* n.s. */
#define		TAB1	0x00000400	/* tty 37 - n.s. */
#define		TAB2	0x00000800	/* n.s. */
#define	  XTABS		0x00000c00	/* Expand tabs on output */
#define	  CRDELAY	0x00003000	/* \r delay - n.s. */
#define		CR0	0x00000000	/* n.s. */
#define		CR1	0x00001000	/* tn 300 - n.s. */
#define		CR2	0x00002000	/* tty 37 - n.s. */
#define		CR3	0x00003000	/* concept 100 - n.s. */
#define	  VTDELAY	0x00004000	/* Vertical tab delay - n.s. */
#define		FF0	0x00000000	/* n.s. */
#define		FF1	0x00004000	/* tty 37 - n.s. */
#define	  BSDELAY	0x00008000	/* \b delay - n.s. */
#define		BS0	0x00000000	/* n.s. */
#define		BS1	0x00008000	/* n.s. */
#define	  ALLDELAY	(NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY)

/*
 * The local mode flags for TIOCLGET/TIOCLSET/TIOCLBIS/TIOCLBIC ioctls.
 */
#define	LCRTBS		0x00000001 	/* do backspacing for crt - n.s. */
#define	LPRTERA		0x00000002 	/* \ ... / erase - n.s. */
#define	LCRTERA		0x00000004 	/* " \b " to wipe out char - n.s. */
#define	LTILDE		0x00000008 	/* hazeltine tilde kludge - n.s. */
#define	LMDMBUF		0x00000010 	/* stp/strt output as carrier drops-ns*/
#define	LLITOUT		0x00000020	/* literal output */
#define	LTOSTOP		0x00000040	/* SIGSTOP on background output */
#define	LFLUSHO		0x00000080	/* flush output to terminal - n.s. */
#define	LNOHANG		0x00000100	/* no SIGHUP on carrier drop */
#define	LCRTKIL		0x00000400	/* kill line with " \b " - n.s. */
#define	LPASS8		0x00000800	/* 8-bit characters */
#define	LCTLECH		0x00001000	/* echo control chars as ^X - n.s. */
#define	LPENDIN		0x00002000	/* tp->t_rawq needs reread - n.s. */
#define	LDECCTQ		0x00004000	/* only ^Q starts after ^S */
#define	LNOFLSH		0x00008000	/* no output flush on signal */


/* To get control character defaults */
#include <sys/ttydefaults.h>

#endif __SGTTY
