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