/*  THE SYSTEM HEADER
 *  copyright (c) 1978 by Whitesmiths, Ltd.
 */

/*  the system error codes
 */
#define EPERM   1
#define ENOENT  2
#define ESRCH   3
#define EINTR   4
#define EIO     5
#define ENXIO   6
#define E2BIG   7
#define ENOEXEC 8
#define EBADF   9
#define ECHILD  10
#define EAGAIN  11
#define ENOMEM  12
#define EACCES  13
#define EFAULT  14
#define ENOTBLK 15
#define EBUSY   16
#define EEXIST  17
#define EXDEV   18
#define ENODEV  19
#define ENOTDIR 20
#define EISDIR  21
#define EINVAL  22
#define ENFILE  23
#define EMFILE  24
#define ENOTTY  25
#define ETXTBSY 26
#define EFBIG   27
#define ENOSPC  28
#define ESPIPE  29
#define EROFS   30
#define EMLINK  31
#define EPIPE   32
#define EDOM    33
#define ERANGE  34

/*  the signals
 */
#define NOSIG   1
#define SIGHUP  1
#define SIGINT  2
#define SIGQUIT 3
#define SIGILIN 4
#define SIGTRC  5
#define SIGRNG  6
#define SIGDOM  7
#define SIGFPT  8
#define SIGKILL 9
#define SIGBUS  10
#define SIGSEG  11
#define SIGSYS  12
#define SIGPIPE 13
#define SIGALRM 14
#define SIGTERM 15
#define NSIG    16

/*  i/o parameters
 */
#define DIRSIZE 14
#define NAMSIZE 64

/*  macros
 */
#define isblk(mod)  (((mod) & 060000) == 060000)
#define ischr(mod)  (((mod) & 060000) == 020000)
#define isdir(mod)  (((mod) & 060000) == 040000)

/*  error returns
 */
typedef COUNT ERROR;

/*  directory structure
 */
typedef struct {
	UCOUNT d_ino;
	TEXT d_name[DIRSIZE];
	} DIR;

/*  stat and fstat structure
 */
typedef struct {
	UCOUNT s_dev;
	UCOUNT s_ino;
	BITS s_mode;
	UTINY s_link;
	UTINY s_uid, s_gid;
	UTINY s_size0;
	UCOUNT s_size1;
	UCOUNT s_addr[8];
	LONG s_actime, s_uptime;
	} STAT;

/*  stty and gtty structure
 */
#define TTY struct tty
struct tty {
	TEXT t_ispeed, t_ospeed;
	TEXT t_erase, t_kill;
	BITS t_mode;
	TEXT t_cgo, t_cstop;
	UTINY t_min, t_time;
	};

/*  codes for t_mode
 */
#define M_HUP   0x0001
#define M_XTABS 0x0002
#define M_LCASE 0x0004
#define M_ECHO  0x0008
#define M_CRTLF 0x0010
#define M_RAW   0x0020
#define M_ODD   0x0040
#define M_EVEN  0x0080
#define M_DECHO 0x0100
#define M_DCD   0x0200
#define M_CNTL  0x0400
#define M_SBRK  0x0800
#define M_RBRK  0x3000
#define M_2STOP 0x4000
#define M_ALL   0x8000

/*  define individual recieve break modes */
#define M_NBRK  0x0000
#define M_KBRK  0x1000
#define M_0BRK  0x2000
#define M_FBRK  0x3000

/*  special modes for raw only */
#define MR_PRI  0x0006  /* initial priority of RS-232 input */
#define MR_DTR  0x0008  /* use DTR in hardware handshake mode */
#define MR_XON  0x0010
#define MR_TERM 0x0100  /* enable terminator characters */
/*  initial raw mode input priority */
#define MR_PLOW 0x0000  /* start out at rock bottom */
#define MR_P0   0x0002  /* start out at zero priority */
#define MR_PHI  0x0004  /* start out with high priority */
