a.out.h
/*
* Format of an a.out header
*/
struct exec { /* a.out header */
short a_magic; /* magic number */
#if vax
short a_stamp;
#endif
unsigned a_text; /* size of text segment */
unsigned a_data; /* size of initialized data */
unsigned a_bss; /* size of uninitialized data */
unsigned a_syms; /* size of symbol table */
unsigned a_entry; /* entry point */
#if vax
unsigned a_trsize; /* size of text relocation */
unsigned a_drsize; /* size of data relocation */
#endif
#if pdp11
unsigned a_stamp; /* system environment stamp */
unsigned a_flag; /* relocation info stripped */
#endif
};
#define A_MAGIC1 0407 /* normal */
#define A_MAGIC0 0401 /* lpd (UNIX/RT) */
#define A_MAGIC2 0410 /* read-only text */
#define A_MAGIC3 0411 /* separated I&D */
#define A_MAGIC4 0405 /* overlay */
#if vax
struct relocation_info {
long r_address; /* relative to current segment */
int r_symbolnum:24,
/* if extern then symbol table */
/* ordinal (0, 1, 2, ...) else */
/* segment number (same as symbol types) */
r_pcrel:1, /* if so, segment offset has already */
/* been subtracted */
r_length:2, /* 0=byte, 1=word, 2=long */
r_extern:1, /* does not include value */
/* of symbol referenced */
r_offset:1, /* already includes origin */
/* of this segment (?) */
r_pad:3; /* nothing, yet */
};
#endif
struct nlist { /* symbol table entry */
char n_name[8]; /* symbol name */
#if vax
char n_type; /* type flag */
char n_other;
short n_desc;
#endif
#if pdp11
int n_type; /* type flag */
#endif
unsigned n_value; /* value */
};
/* ***** in invocation of BADMAG macro, argument should not be a function.***/
#define BADMAG(X) (X.a_magic!=A_MAGIC1 && X.a_magic!=A_MAGIC2 && X.a_magic!=A_MAGIC3 && X.a_magic!=A_MAGIC4 && X.a_magic!=A_MAGIC0)
/* values for type flag */
#if vax
#define N_UNDF 0 /* undefined */
#define N_ABS 02 /* absolute */
#define N_TEXT 04 /* text */
#define N_DATA 06 /* data */
#define N_BSS 08
#define N_TYPE 037
#define N_FN 037 /* file name symbol */
#define N_GSYM 0040 /* global sym: name,,type,0 */
#define N_FNAME 0042 /* procedure name (f77 kludge): name,,,0 */
#define N_FUN 0044 /* procedure: name,,linenumber,address */
#define N_STSYM 0046 /* static symbol: name,,type,address */
#define N_LCSYM 0048 /* .lcomm symbol: name,,type,address */
#define N_BSTR 0060 /* begin structure: name,,, */
#define N_RSYM 0100 /* register sym: name,,register,offset */
#define N_SLINE 0104 /* src line: ,,linenumber,address */
#define N_ESTR 0120 /* end structure: name,,, */
#define N_SSYM 0140 /* structure elt: name,,type,struct_offset */
#define N_SO 0144 /* source file name: name,,,address */
#define N_BENUM 0160 /* begin enum: name,,, */
#define N_LSYM 0200 /* local sym: name,,type,offset */
#define N_SOL 0204 /* #line source filename: name,,,address */
#define N_ENUM 0220 /* enum element: name,,,value */
#define N_PSYM 0240 /* parameter: name,,type,offset */
#define N_ENTRY 0244 /* alternate entry: name,,linenumber,address */
#define N_EENUM 0260 /* end enum: name,,, */
#define N_LBRAC 0300 /* left bracket: ,,nesting level,address */
#define N_RBRAC 0340 /* right bracket: ,,nesting level,address */
#define N_BCOMM 0342 /* begin common: name,,, */
#define N_ECOMM 0344 /* end common: name,,, */
#define N_ECOML 0348 /* end common (local name): ,,,address */
#define N_STRU 0374 /* 2nd entry for structure: str tag,,,length */
#define N_LENG 0376 /* additional entry with length: ,,,length */
#define N_EXT 01 /* external bit, or'ed in */
#define FORMAT "%.8x"
#define STABTYPES 0340
#endif
#if pdp11
#define N_UNDF 0 /* undefined */
#define N_ABS 01 /* absolute */
#define N_TEXT 02 /* text symbol */
#define N_DATA 03 /* data symbol */
#define N_BSS 04 /* bss symbol */
#define N_TYPE 037
#define N_REG 024 /* register name */
#define N_FN 037 /* file name symbol */
#define N_EXT 040 /* external bit, or'ed in */
#define FORMAT "%.6o" /* to print a value */
#endif
ctype.h
#define _U 01
#define _L 02
#define _N 04
#define _S 010
#define _P 020
#define _C 040
#define _B 0100
#define _X 0200
extern char _ctype[];
#define isalpha(c) ((_ctype+1)[c]&(_U|_L))
#define isupper(c) ((_ctype+1)[c]&_U)
#define islower(c) ((_ctype+1)[c]&_L)
#define isdigit(c) ((_ctype+1)[c]&_N)
#define isxdigit(c) ((_ctype+1)[c]&_X)
#define isspace(c) ((_ctype+1)[c]&_S)
#define ispunct(c) ((_ctype+1)[c]&_P)
#define isalnum(c) ((_ctype+1)[c]&(_U|_L|_N))
#define isprint(c) ((_ctype+1)[c]&(_P|_U|_L|_N|_B))
#define isgraph(c) ((_ctype+1)[c]&(_P|_U|_L|_N))
#define iscntrl(c) ((_ctype+1)[c]&_C)
#define isascii(c) ((unsigned)(c)<=0177)
#define _toupper(c) ((c)-'a'+'A')
#define _tolower(c) ((c)-'A'+'a')
#define toascii(c) ((c)&0177)
errno.h
/*
* Error codes
*/
#define EPERM 1 /* Not super-user */
#define ENOENT 2 /* No such file or directory */
#define ESRCH 3 /* No such process */
#define EINTR 4 /* interrupted system call */
#define EIO 5 /* I/O error */
#define ENXIO 6 /* No such device or address */
#define E2BIG 7 /* Arg list too long */
#define ENOEXEC 8 /* Exec format error */
#define EBADF 9 /* Bad file number */
#define ECHILD 10 /* No children */
#define EAGAIN 11 /* No more processes */
#define ENOMEM 12 /* Not enough core */
#define EACCES 13 /* Permission denied */
#define EFAULT 14 /* Bad address */
#define ENOTBLK 15 /* Block device required */
#define EBUSY 16 /* Mount device busy */
#define EEXIST 17 /* File exists */
#define EXDEV 18 /* Cross-device link */
#define ENODEV 19 /* No such device */
#define ENOTDIR 20 /* Not a directory */
#define EISDIR 21 /* Is a directory */
#define EINVAL 22 /* Invalid argument */
#define ENFILE 23 /* File table overflow */
#define EMFILE 24 /* Too many open files */
#define ENOTTY 25 /* Not a typewriter */
#define ETXTBSY 26 /* Text file busy */
#define EFBIG 27 /* File too large */
#define ENOSPC 28 /* No space left on device */
#define ESPIPE 29 /* Illegal seek */
#define EROFS 30 /* Read only file system */
#define EMLINK 31 /* Too many links */
#define EPIPE 32 /* Broken pipe */
/* math software */
#define EDOM 33 /* Math arg out of domain of func */
#define ERANGE 34 /* Math result not representable */
execargs.h
#if vax
char **execargs = (char**)(0x7ffffffc);
#endif
#if pdp11
char **execargs = (char**)(-2);
#endif
sgtty.h
/*
* Structure for stty and gtty system calls.
*/
struct sgttyb {
char sg_ispeed; /* input speed */
char sg_ospeed; /* output speed */
char sg_erase; /* erase character */
char sg_kill; /* kill character */
int sg_flags; /* mode flags */
};
/*
* Modes
*/
#define HUPCL 01
#define XTABS 02
#define LCASE 04
#define ECHO 010
#define CRMOD 020
#define RAW 040
#define ODDP 0100
#define EVENP 0200
#define ANYP 0300
#define NLDELAY 001400
#define TBDELAY 002000
#define CRDELAY 030000
#define VTDELAY 040000
#define BSDELAY 0100000
#define ALLDELAY 0177400
/*
* Delay algorithms
*/
#define CR0 0
#define CR1 010000
#define CR2 020000
#define CR3 030000
#define NL0 0
#define NL1 000400
#define NL2 001000
#define NL3 001400
#define TAB0 0
#define TAB1 002000
#define NOAL 004000
#define FF0 0
#define FF1 040000
#define BS0 0
#define BS1 0100000
/*
* Speeds
*/
#define B0 0
#define B50 1
#define B75 2
#define B110 3
#define B134 4
#define B150 5
#define B200 6
#define B300 7
#define B600 8
#define B1200 9
#define B1800 10
#define B2400 11
#define B4800 12
#define B9600 13
#define EXTA 14
#define EXTB 15
/*
* ioctl arguments
*/
#define FIOCLEX (('f'<<8)|1)
#define FIONCLEX (('f'<<8)|2)
#define TIOCHPCL (('t'<<8)|2)
#define TIOCGETP (('t'<<8)|8)
#define TIOCSETP (('t'<<8)|9)
#define TIOCEXCL (('t'<<8)|13)
#define TIOCNXCL (('t'<<8)|14)
signal.h
#define SIGHUP 1 /* hangup */
#define SIGINT 2 /* interrupt (rubout) */
#define SIGQUIT 3 /* quit (ASCII FS) */
#define SIGILL 4 /* illegal instruction (not reset when caught)*/
#define SIGTRAP 5 /* trace trap (not reset when caught) */
#define SIGIOT 6 /* IOT instruction */
#define SIGEMT 7 /* EMT instruction */
#define SIGFPE 8 /* floating point exception */
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
#define SIGBUS 10 /* bus error */
#define SIGSEGV 11 /* segmentation violation */
#define SIGSYS 12 /* bad argument to system call */
#define SIGPIPE 13 /* write on a pipe with no one to read it */
#define SIGALRM 14 /* alarm clock */
#define SIGTERM 15 /* software termination signal from kill */
#define SIGUSR1 16 /* user defined signal 1 */
#define SIGUSR2 17 /* user defined signal 2 */
#define SIGCLD 18 /* death of a child */
#define SIGPWR 19 /* power-fail restart */
#if RT
#define SIGQIT 3 /* quit */
#define SIGTRC 5 /* trace trap (not reset when caught) */
#endif
#define NSIG 20
int (*signal())();
#define SIG_DFL (int (*)())0
#if lint
#define SIG_IGN (int (*)())0
#else
#define SIG_IGN (int (*)())1
#endif
sys/acct.h
/*
* Accounting structures
*/
typedef ushort comp_t; /* "floating point" */
/* 13-bit fraction, 3-bit exponent */
struct acct
{
char ac_flag; /* Accounting flag */
char ac_stat; /* Exit status */
ushort ac_uid; /* Accounting user ID */
ushort ac_gid; /* Accounting group ID */
dev_t ac_tty; /* control typewriter */
time_t ac_btime; /* Beginning time */
comp_t ac_utime; /* acctng user time in clock ticks */
comp_t ac_stime; /* acctng system time in clock ticks */
comp_t ac_etime; /* acctng elapsed time in clock ticks */
comp_t ac_mem; /* memory usage */
comp_t ac_io; /* chars transferred */
comp_t ac_rw; /* blocks read or written */
char ac_comm[8]; /* command name */
};
extern struct acct acctbuf;
extern struct inode *acctp; /* inode of accounting file */
#define AFORK 01 /* has executed fork, but no exec */
#define ASU 02 /* used super-user privileges */
#define ACCTF 0300 /* record type: 00 = acct */
sys/ioctl.h
#define IOCTYPE 0xff00
#define TIOC ('T'<<8)
#define TCGETA (TIOC|1)
#define TCSETA (TIOC|2)
#define TCSETAW (TIOC|3)
#define TCSETAF (TIOC|4)
#define TCSBRK (TIOC|5)
#define TCXONC (TIOC|6)
#define TCFLSH (TIOC|7)
#define TCDSET (TIOC|32)
#define LDIOC ('D'<<8)
#define LDOPEN (LDIOC|0)
#define LDCLOSE (LDIOC|1)
#define LDCHG (LDIOC|2)
#define tIOC ('t'<<8)
#define TIOCGETP (tIOC|8)
#define TIOCSETP (tIOC|9)
#define LIOC ('l'<<8)
#define LIOCGETP (LIOC|1)
#define LIOCSETP (LIOC|2)
#define LIOCGETS (LIOC|5)
#define LIOCSETS (LIOC|6)
#define DIOC ('d'<<8)
#define DIOCGETC (DIOC|1)
#define DIOCGETB (DIOC|2)
#define DIOCSETE (DIOC|3)
#define VPM ('V'<<8)
#define VPMCMD (VPM|8)
#define VPMERRS (VPM|9)
#define VPMRPT (VPM|10)
#define VPMTRCO (VPM|16)
sys/stat.h
/*
* Structure of the result of stat
*/
struct stat
{
dev_t st_dev;
ino_t st_ino;
ushort st_mode;
short st_nlink;
ushort st_uid;
ushort st_gid;
dev_t st_rdev;
off_t st_size;
time_t st_atime;
time_t st_mtime;
time_t st_ctime;
};
#define S_IFMT 0170000 /* type of file */
#define S_IFDIR 0040000 /* directory */
#define S_IFCHR 0020000 /* character special */
#define S_IFBLK 0060000 /* block special */
#define S_IFREG 0100000 /* regular */
#define S_IFIFO 0010000 /* fifo */
#define S_ISUID 04000 /* set user id on execution */
#define S_ISGID 02000 /* set group id on execution */
#define S_ISVTX 01000 /* save swapped text even after use */
#define S_IREAD 00400 /* read permission, owner */
#define S_IWRITE 00200 /* write permission, owner */
#define S_IEXEC 00100 /* execute/search permission, owner */
sys/tty.h
/*
* A clist structure is the head of a linked list queue of characters.
* The routines getc* and putc* manipulate these structures.
*/
struct clist {
int c_cc; /* character count */
struct cblock *c_cf; /* pointer to first */
struct cblock *c_cl; /* pointer to last */
};
/*
* A tty structure is needed for each UNIX character device that
* is used for normal terminal IO.
*/
#define NCC 8
struct tty {
struct clist t_rawq; /* raw input queue */
struct clist t_canq; /* canonical queue */
struct clist t_outq; /* output queue */
struct cblock *t_buf; /* buffer pointer */
int (* t_proc)(); /* routine for device functions */
ushort t_iflag; /* input modes */
ushort t_oflag; /* output modes */
ushort t_cflag; /* control modes */
ushort t_lflag; /* line discipline modes */
short t_state; /* internal state */
short t_pgrp; /* process group name */
char t_line; /* line discipline */
char t_delct; /* delimiter count */
char t_col; /* current column */
char t_row; /* current row */
unsigned char t_cc[NCC]; /* settable control chars */
};
/*
* The structure of a clist block
*/
#define CLSIZE 24
struct cblock {
struct cblock *c_next;
char c_first;
char c_last;
char c_data[CLSIZE];
};
extern struct cblock cfree[];
extern struct cblock * getcb();
extern struct cblock * getcf();
extern struct clist ttnulq;
struct chead {
struct cblock *c_next;
int c_size;
};
extern struct chead cfreelist;
struct inter {
int cnt;
};
/* control characters */
#define VINTR 0
#define VQUIT 1
#define VERASE 2
#define VKILL 3
#define VEOF 4
#define VEOL 5
#define VMIN 4
#define VTIME 5
/* default control chars */
#define CINTR 0177 /* DEL */
#define CQUIT 034 /* FS, cntl | */
#define CERASE '#'
#define CKILL '@'
#define CEOF 04 /* cntl d */
#define CSTART 021 /* cntl q */
#define CSTOP 023 /* cntl s */
#define TTIPRI 28
#define TTOPRI 29
/* limits */
extern int ttlowat[], tthiwat[];
#define TTYHOG 256
#define TTXOLO 60
#define TTXOHI 180
/* input modes */
#define IGNBRK 0000001
#define BRKINT 0000002
#define IGNPAR 0000004
#define PARMRK 0000010
#define INPCK 0000020
#define ISTRIP 0000040
#define INLCR 0000100
#define IGNCR 0000200
#define ICRNL 0000400
#define IUCLC 0001000
#define IXON 0002000
#define IXANY 0004000
#define IXOFF 0010000
/* output modes */
#define OPOST 0000001
#define OLCUC 0000002
#define ONLCR 0000004
#define OCRNL 0000010
#define ONOCR 0000020
#define ONLRET 0000040
#define OFILL 0000100
#define OFDEL 0000200
#define NLDLY 0000400
#define NL0 0
#define NL1 0000400
#define CRDLY 0003000
#define CR0 0
#define CR1 0001000
#define CR2 0002000
#define CR3 0003000
#define TABDLY 0014000
#define TAB0 0
#define TAB1 0004000
#define TAB2 0010000
#define TAB3 0014000
#define BSDLY 0020000
#define BS0 0
#define BS1 0020000
#define VTDLY 0040000
#define VT0 0
#define VT1 0040000
#define FFDLY 0100000
#define FF0 0
#define FF1 0100000
/* control modes */
#define CBAUD 0000017
#define B0 0
#define B50 0000001
#define B75 0000002
#define B110 0000003
#define B134 0000004
#define B150 0000005
#define B200 0000006
#define B300 0000007
#define B600 0000010
#define B1200 0000011
#define B1800 0000012
#define B2400 0000013
#define B4800 0000014
#define B9600 0000015
#define EXTA 0000016
#define EXTB 0000017
#define CSIZE 0000060
#define CS5 0
#define CS6 0000020
#define CS7 0000040
#define CS8 0000060
#define CSTOPB 0000100
#define CREAD 0000200
#define PARENB 0000400
#define PARODD 0001000
#define HUPCL 0002000
#define CLOCAL 0004000
/* line discipline 0 modes */
#define ISIG 0000001
#define ICANON 0000002
#define XCASE 0000004
#define ECHO 0000010
#define ECHOE 0000020
#define ECHOK 0000040
#define ECHONL 0000100
#define NOFLSH 0000200
#define SSPEED 7 /* default speed: 300 baud */
/* Hardware bits */
#define DONE 0200
#define IENABLE 0100
#define OVERRUN 040000
#define FRERROR 020000
#define PERROR 010000
/* Internal state */
#define TIMEOUT 01 /* Delay timeout in progress */
#define WOPEN 02 /* Waiting for open to complete */
#define ISOPEN 04 /* Device is open */
#define TBLOCK 010
#define CARR_ON 020 /* Software copy of carrier-present */
#define BUSY 040 /* Output in progress */
#define OASLP 0100 /* Wakeup when output done */
#define IASLP 0200 /* Wakeup when input done */
#define TTSTOP 0400 /* Output stopped by ctl-s */
#define EXTPROC 01000 /* External processing */
#define TACT 02000
#define ESC 04000 /* Last char escape */
#define RTO 010000
#define TTIOW 020000
#define TTXON 040000
#define TTXOFF 0100000
/* l_output status */
#define CPRES 1
/* device commands */
#define T_OUTPUT 0
#define T_TIME 1
#define T_SUSPEND 2
#define T_RESUME 3
#define T_BLOCK 4
#define T_UNBLOCK 5
#define T_RFLUSH 6
#define T_WFLUSH 7
#define T_BREAK 8
/*
* Ioctl control packet
*/
struct termio {
ushort c_iflag; /* input modes */
ushort c_oflag; /* output modes */
ushort c_cflag; /* control modes */
ushort c_lflag; /* line discipline modes */
char c_line; /* line discipline */
unsigned char c_cc[NCC]; /* control chars */
};