/*	@(#)termio.h	13.9 (RC International) 91/08/30	 */

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

#ifndef _TERMIO_H
#define _TERMIO_H

#include <sys/ioctl.h>

/*
 * The number of control characters in the termio.c_cc-table. 
 * Further characters (for termios.c_cc) are defined in termios.h.
 */
#define	NCC	13
/*
 * The names and indexes of the control characters in the termio.c_cc-table. 
 */
#define	VINTR	0
#define	VQUIT	1
#define	VERASE	2
#define	VKILL	3
#define	VEOF	4
#define	VNL	5
#define	VEOL	6
#define	VSUSP	7
#define	VBSLSH	8
#define	VCHOST	9
#define	VTIME	10
#define	VMIN	11
#define	VMAX	12

/*
 * The terminal control structure.
 */
struct termio {
    unsigned short	     c_iflag;	/* Input modes */
    unsigned short	     c_oflag;	/* Output modes */
    unsigned short	     c_cflag;	/* Control modes */
    unsigned short	     c_lflag;	/* Local modes */
    unsigned char	     c_cc[NCC];	/* Control characters */
};

/*
 * Input mode flags.
 */
#define	IGNBRK		0x00000001	/* Ignore break condition */
#define	BRKINT		0x00000002	/* Signal interrupt on break */
#define	IGNPAR		0x00000004	/* Ignore chars with parity errors */
#define	PARMRK		0x00000008	/* Mark parity errors */
#define	INPCK		0x00000010	/* Enable input parity check */
#define	ISTRIP		0x00000020	/* Strip characters to 7 bits */
#define	INLCR		0x00000040	/* Map NL to CR */
#define	IGNCR		0x00000080	/* Ignore CR */
#define	ICRNL		0x00000100	/* Map CR to NL */
#define	IUCLC		0x00000200	/* Map upper case to lower */
#define	IXON		0x00000400	/* Enable stop/start output control */
#define	IXANY		0x00000800	/* Enable any char to restart output */
#define	IXOFF		0x00001000	/* Enable stop/start input control */
#define	IMAXBEL		0x00002000	/* Ring bell on input queue full */

/*
 * Output mode flags.
 */
#define	OPOST		0x00000001	/* Enable post-processing of output */
#define	OLCUC		0x00000002	/* Map lower case to upper */
#define	ONLCR		0x00000004	/* Map NL to CR-NL */
#define	OCRNL		0x00000008	/* Map CR to NL */
#define	ONOCR		0x00000010	/* No CR output at column 0 */
#define	ONLRET		0x00000020	/* NL performs CR function */
#define	OFILL		0x00000040	/* Use fill character for delays */
#define	OFDEL		0x00000080	/* Fill is DEL, else NULL */
#define	NLDLY		0x00000100	/* Newline delay types */
#define		NL0	0x00000000	/* Not supported */
#define		NL1	0x00000100	/* Not supported */
#define	CRDLY		0x00000600	/* Carriage-return delay types */
#define		CR0	0x00000000	/* Not supported */
#define		CR1	0x00000200	/* Not supported */
#define		CR2	0x00000400	/* Not supported */
#define		CR3	0x00000600	/* Not supported */
#define	TABDLY		0x00001800	/* Horizontal tab delay types */
#define		TAB0	0x00000000	/* Not supported */
#define		TAB1	0x00000800	/* Not supported */
#define		TAB2	0x00001000	/* Not supported */
#define		TAB3	0x00001800	/* Expand tabs to spaces */
#define	OXTABS		TAB3
#define	BSDLY		0x00002000	/* Backspace delay types */
#define		BS0	0x00000000	/* Not supported */
#define		BS1	0x00002000	/* Not supported */
#define	VTDLY		0x00004000	/* Vertical tab delay types */
#define		VT0	0x00000000	/* Not supported */
#define		VT1	0x00004000	/* Not supported */
#define	FFDLY		0x00008000	/* Form feed delay types */
#define		FF0	0x00000000	/* Not supported */
#define		FF1	0x00008000	/* Not supported */
#define	ONOEOT		0x00010000	/* discard EOT's (^D) on output */

/*
 * Input/output speeds.
 */
#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

/*
 * Control mode flags.
 */
#define	CBAUD		0x0000000f	/* Output speed */
#define	CSIZE		0x00000030	/* Character size */
#define		CS5	0x00000000	/* Not supported */
#define		CS6	0x00000010	/* Not supported */
#define		CS7	0x00000020	/* 7 bits */
#define		CS8	0x00000030	/* 8 bits */
#define	CSTOPB		0x00000040	/* Send two stop bits, else one */
#define	CREAD		0x00000080	/* Enable receiver */
#define	PARENB		0x00000100	/* Parity enable */
#define	PARODD		0x00000200	/* Odd parity, else even */
#define	HUPCL		0x00000400	/* Hang up on last close */
#define	CLOCAL		0x00000800	/* Local line, else dial-up */
#define CIBAUD		0x000f0000	/* Input speed - not supported */
#define IBSHIFT		16		/* Shift width for CIBAUD */

/*
 * Local mode flags.
 */
#define	ISIG		0x00000001	/* Enable signals */
#define	ICANON		0x00000002	/* Enable canonical input processing */
#define	XCASE		0x00000004	/* Not supported */
#define	ECHO		0x00000008	/* Enable input echo */
#define	ECHOE		0x00000010	/* Not supported */
#define	ECHOK		0x00000020	/* Not supported */
#define	ECHONL		0x00000040	/* Not supported */
#define	NOFLSH		0x00000080	/* Disable flush on intr, quit, susp */
#define TOSTOP		0x00000100	/* Send SIGTTOU on background output */
#define	IEXTEN		0x00000200	/* Enable extended functions */
#define	EXTPROC		0x00000400	/* External processing - not supp. */
#define	ECHOKE		0x00000800	/* Visual erase for line kill */
#define	ECHOPRT		0x00001000	/* Visual erase mode for hardcopy */
#define	ECHOCTL	       	0x00002000	/* Echo control chars as ^(char) */	
#define IFIELD		0x00004000	/* Used by CSP (RcLan protocol) */
#define ICONV		0x00008000	/* Used by CSP (RcLan protocol) */
#define ALTWERASE	0x00010000	/* Use alternate WERASE algorithm */
#ifndef FLUSHO
#define FLUSHO		0x00800000	/* Output being flushed (state) */
#define PENDIN		0x20000000	/* Retype pending input (state) */
#endif

/*
 * The session specification structure is used to assign the terminal a new
 * session. 
 */
#define MAX_SESDESCR	((127-sizeof(short))/(sizeof(short)+12*sizeof(char)))

struct sesspec
{
    unsigned short	     no_sess;	/* No. of session descriptions */
    struct
    {
	char			 spu[12 + 1];	/* Host name */
	unsigned short		 prcindex;	/* Process description
						 * index */
    }			     ses_descr[MAX_SESDESCR];
};

#ifndef _POSIX_SOURCE
#include <sys/ttydefaults.h>
#endif

#endif /* _TERMIO_H */
