|
|
1.1 root 1: #
2: /*
3: * UNIX shell
4: */
5:
6:
7: #define BYTESPERWORD (sizeof(char *))
8:
9: TYPE char CHAR;
10: TYPE char BOOL;
11: TYPE int UFD;
12: TYPE int INT;
13: TYPE float REAL;
14: TYPE char *ADDRESS;
15: TYPE long int L_INT;
16: TYPE int VOID;
17: TYPE unsigned POS;
18: TYPE char *STRING;
19: TYPE char MSG[];
20: TYPE int PIPE[];
21: TYPE char *STKPTR;
22: TYPE char *BYTPTR;
23:
24: STRUCT stat STATBUF; /* defined in /usr/sys/stat.h */
25: STRUCT blk *BLKPTR;
26: STRUCT fileblk FILEBLK;
27: STRUCT filehdr FILEHDR;
28: STRUCT fileblk *FILE;
29: STRUCT trenod *TREPTR;
30: STRUCT forknod *FORKPTR;
31: STRUCT comnod *COMPTR;
32: STRUCT swnod *SWPTR;
33: STRUCT regnod *REGPTR;
34: STRUCT parnod *PARPTR;
35: STRUCT ifnod *IFPTR;
36: STRUCT whnod *WHPTR;
37: STRUCT fornod *FORPTR;
38: STRUCT lstnod *LSTPTR;
39: STRUCT argnod *ARGPTR;
40: STRUCT dolnod *DOLPTR;
41: STRUCT ionod *IOPTR;
42: STRUCT namnod NAMNOD;
43: STRUCT namnod *NAMPTR;
44: STRUCT sysnod SYSNOD;
45: STRUCT sysnod *SYSPTR;
46: STRUCT sysnod SYSTAB[];
47: #define NIL ((char*)0)
48:
49:
50: /* the following nonsense is required
51: * because casts turn an Lvalue
52: * into an Rvalue so two cheats
53: * are necessary, one for each context.
54: */
55: union { int _cheat;};
56: #define Lcheat(a) ((a)._cheat)
57: #define Rcheat(a) ((int)(a))
58:
59:
60: /* address puns for storage allocation */
61: UNION {
62: FORKPTR _forkptr;
63: COMPTR _comptr;
64: PARPTR _parptr;
65: IFPTR _ifptr;
66: WHPTR _whptr;
67: FORPTR _forptr;
68: LSTPTR _lstptr;
69: BLKPTR _blkptr;
70: NAMPTR _namptr;
71: BYTPTR _bytptr;
72: } address;
73:
74:
75: /* for functions that do not return values */
76: struct void {INT vvvvvvvv;};
77:
78:
79: /* heap storage */
80: struct blk {
81: BLKPTR word;
82: };
83:
84: #define BUFSIZ 64
85: struct fileblk {
86: UFD fdes;
87: POS flin;
88: BOOL feof;
89: CHAR fsiz;
90: STRING fnxt;
91: STRING fend;
92: STRING *feval;
93: FILE fstak;
94: CHAR fbuf[BUFSIZ];
95: };
96:
97: /* for files not used with file descriptors */
98: struct filehdr {
99: UFD fdes;
100: POS flin;
101: BOOL feof;
102: CHAR fsiz;
103: STRING fnxt;
104: STRING fend;
105: STRING *feval;
106: FILE fstak;
107: CHAR _fbuf[1];
108: };
109:
110: struct sysnod {
111: STRING sysnam;
112: INT sysval;
113: };
114:
115: /* this node is a proforma for those that follow */
116: struct trenod {
117: INT tretyp;
118: IOPTR treio;
119: };
120:
121: /* dummy for access only */
122: struct argnod {
123: ARGPTR argnxt;
124: CHAR argval[1];
125: };
126:
127: struct dolnod {
128: DOLPTR dolnxt;
129: INT doluse;
130: CHAR dolarg[1];
131: };
132:
133: struct forknod {
134: INT forktyp;
135: IOPTR forkio;
136: TREPTR forktre;
137: };
138:
139: struct comnod {
140: INT comtyp;
141: IOPTR comio;
142: ARGPTR comarg;
143: ARGPTR comset;
144: };
145:
146: struct ifnod {
147: INT iftyp;
148: TREPTR iftre;
149: TREPTR thtre;
150: TREPTR eltre;
151: };
152:
153: struct whnod {
154: INT whtyp;
155: TREPTR whtre;
156: TREPTR dotre;
157: };
158:
159: struct fornod {
160: INT fortyp;
161: TREPTR fortre;
162: STRING fornam;
163: COMPTR forlst;
164: };
165:
166: struct swnod {
167: INT swtyp;
168: STRING swarg;
169: REGPTR swlst;
170: };
171:
172: struct regnod {
173: ARGPTR regptr;
174: TREPTR regcom;
175: REGPTR regnxt;
176: };
177:
178: struct parnod {
179: INT partyp;
180: TREPTR partre;
181: };
182:
183: struct lstnod {
184: INT lsttyp;
185: TREPTR lstlef;
186: TREPTR lstrit;
187: };
188:
189: struct ionod {
190: INT iofile;
191: STRING ioname;
192: IOPTR ionxt;
193: IOPTR iolst;
194: };
195:
196: #define FORKTYPE (sizeof(struct forknod))
197: #define COMTYPE (sizeof(struct comnod))
198: #define IFTYPE (sizeof(struct ifnod))
199: #define WHTYPE (sizeof(struct whnod))
200: #define FORTYPE (sizeof(struct fornod))
201: #define SWTYPE (sizeof(struct swnod))
202: #define REGTYPE (sizeof(struct regnod))
203: #define PARTYPE (sizeof(struct parnod))
204: #define LSTTYPE (sizeof(struct lstnod))
205: #define IOTYPE (sizeof(struct ionod))
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.