-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypedefs.p
221 lines (192 loc) · 5.8 KB
/
typedefs.p
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
program typedefs(output);
const
isomax = 255; { ISO 4873 (646 is a subset) max value }
maxstr = 512; { maximum characters for chstring type }
ioerror = -1; { file descriptor not available indicator }
iomaxfd = 19; { maximum available stream number }
nul = 0; { ISO 4873 null character }
zmaxrow = 59; { allows a maximum of 60 rows }
zmaxcol = 131; { allows a maximum of 132 columns }
zfieldlimit = 239; { allows a maximum of 240 fields }
{ ******************************************************************* }
{ * * }
{ * Software Tools :: Type definitions exported to primitives * }
{ * * }
{ ******************************************************************* }
type
byte = 0..255;
coltype = 0..zmaxcol;
fdpointer = integer;
fieldindex = 0..zfieldlimit;
filedesc = ioerror..iomaxfd;
isochar = nul..isomax;
modeindex = 0..63;
rowtype = 0..zmaxrow;
smallint = 0..255;
chstring = packed array [1..maxstr] of isochar;
chtable = packed array [byte] of char;
imtype = array[rowtype,coltype] of isochar;
itable = packed array [byte] of byte;
modearray = packed array [modeindex] of smallint;
textlit = packed array [1..24] of char;
typelist = ( tchecker, tbyte, tcoltype, tfdpointer,
tfieldindex, tfiledesc, tisochar, tmodeindex,
trowtype, tsmallint, tchstring, tchtable,
timtype, titable, tmodearray, ttextlit );
over = record
case typelist of
tchecker : (checker : packed array[1..12] of char;);
tbyte : (vbyte : byte; );
tcoltype : (vcoltype : coltype; );
tfdpointer : (vfdpointer : fdpointer; );
tfieldindex : (vfieldindex : fieldindex; );
tfiledesc : (vfiledesc : filedesc; );
tisochar : (visochar : isochar; );
tmodeindex : (vmodeindex : modeindex; );
trowtype : (vrowtype : rowtype; );
tsmallint : (vsmallint : smallint; );
tchstring : (vchstring : chstring; );
tchtable : (vchtable : chtable; );
timtype : (vimtype : imtype; );
titable : (vitable : itable; );
tmodearray : (vmodearray : modearray; );
ttextlit : (vtextlit : textlit; );
end;
var
overrec : over;
procedure dotypedef ( s : integer );
begin
case s of
1 : write('char ');
2 : write('short ');
4 : write('long ');
end;
end;
procedure setup;
var i : integer;
begin
for i := 1 to 12 do
overrec.checker[i] := 'a';
end;
function sizof : integer;
var i : integer;
count : integer;
begin
count := 0;
for i := 1 to 12 do
begin
if overrec.checker[i] <> 'a'
then
count := count + 1;
end;
sizof := count;
end;
procedure typedefs;
var retval : integer;
begin
setup;
overrec.vbyte := 0;
retval := sizof;
write(' typedef unsigned ');
dotypedef(retval);
writeln('byte;');
setup;
overrec.vchstring[1] := 0;
retval := sizof;
write(' typedef unsigned ');
dotypedef(retval);
writeln('* chstring;');
setup;
overrec.vchtable[0] := '0';
retval := sizof;
write(' typedef ');
dotypedef(retval);
writeln('* chtable;');
setup;
overrec.vcoltype := 0;
retval := sizof;
write(' typedef unsigned ');
dotypedef(retval);
writeln('coltype;');
setup;
overrec.vfdpointer := 0;
retval := sizof;
write(' typedef ');
dotypedef(retval);
writeln('fdpointer;');
setup;
overrec.vfieldindex := 0;
retval := sizof;
write(' typedef unsigned ');
dotypedef(retval);
writeln('fieldindex;');
setup;
overrec.vfiledesc := 0;
retval := sizof;
write(' typedef ');
dotypedef(retval);
writeln('filedesc;');
setup;
overrec.vimtype[0,0] := 0;
retval := sizof;
write(' typedef unsigned ');
dotypedef(retval);
writeln('* imtype;');
setup;
overrec.vitable[0] := 0;
retval := sizof;
write(' typedef unsigned ');
dotypedef(retval);
writeln('* itable;');
setup;
overrec.visochar := 0;
retval := sizof;
write(' typedef unsigned ');
dotypedef(retval);
writeln('isochar;');
setup;
overrec.vmodearray[0] := 0;
retval := sizof;
write(' typedef unsigned ');
dotypedef(retval);
writeln('* modearray;');
setup;
overrec.vmodeindex := 0;
retval := sizof;
write(' typedef unsigned ');
dotypedef(retval);
writeln('modeindex;');
setup;
overrec.vrowtype := 0;
retval := sizof;
write(' typedef unsigned ');
dotypedef(retval);
writeln('rowtype;');
setup;
overrec.vsmallint := 0;
retval := sizof;
write(' typedef unsigned ');
dotypedef(retval);
writeln('smallint;');
setup;
overrec.vtextlit[1] := '0';
retval := sizof;
write(' typedef ');
dotypedef(retval);
writeln('* textlit;');
end;
begin
writeln('#define ZMAXROW ', zmaxrow);
writeln('#define ZMAXCOL ', zmaxcol);
writeln('#define MAXSTR ', maxstr);
writeln;
writeln('#ifndef HELPDIR');
writeln('#define HELPDIR "/usr/local/lib"');
writeln('#endif');
writeln;
writeln('#ifndef _NFILE');
writeln('#define _NFILE 32');
writeln('#endif');
writeln;
typedefs;
end.