/
file0.pas
390 lines (349 loc) · 9.27 KB
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
{$A+,B+,D-,E+,F+,I+,L+,N-,O+,R-,S+,V-}
unit file0;
interface
uses
crt,dos,
{rcg11172000 no overlay under Linux.}
{overlay,}
myio,
common;
const
ulffopen1:boolean=TRUE; { whether ulff has been opened before }
var
dirinfo:searchrec;
found:boolean;
function align(fn:astr):astr;
function baddlpath:boolean;
function badulpath:boolean;
function bslash(b:boolean; s:astr):astr;
function existdir(s:astr):boolean;
procedure ffile(fn:astr);
procedure fileinfo(f:ulfrec; editing:boolean; var abort,next:boolean);
procedure fiscan(var pl:integer);
function fit(f1,f2:astr):boolean;
procedure gfn(var fn:astr);
function isgifdesc(d:astr):boolean;
function isgifext(fn:astr):boolean;
function isul(s:astr):boolean;
function iswildcard(s:astr):boolean;
procedure nfile;
procedure nrecno(fn:astr; var pl,rn:integer);
procedure recno(fn:astr; var pl,rn:integer);
function rte:real;
procedure star(s:astr);
function stripname(i:astr):astr;
function tcheck(s:real; i:integer):boolean;
function tchk(s:real; i:real):boolean;
procedure verbfileinfo(pt:integer; editing,abort,next:boolean);
implementation
function align(fn:astr):astr;
var f,e,t:astr; c,c1:integer;
begin
c:=pos('.',fn);
if (c=0) then begin
f:=fn; e:=' ';
end else begin
f:=copy(fn,1,c-1); e:=copy(fn,c+1,3);
end;
f:=mln(f,8);
e:=mln(e,3);
c:=pos('*',f); if (c<>0) then for c1:=c to 8 do f[c1]:='?';
c:=pos('*',e); if (c<>0) then for c1:=c to 3 do e[c1]:='?';
c:=pos(' ',f); if (c<>0) then for c1:=c to 8 do f[c1]:=' ';
c:=pos(' ',e); if (c<>0) then for c1:=c to 3 do e[c1]:=' ';
align:=f+'.'+e;
end;
function baddlpath:boolean;
var s:string;
begin
if (badfpath) then begin
nl;
sprint(#3#7+'File base #'+cstr(fileboard)+': Unable to perform command.');
sprint(#3#5+'Bad DL file path: "'+memuboard.dlpath+'".');
sprint(#3#5+'Please inform the SysOp.');
sysoplog('Invalid DL path (file base #'+cstr(fileboard)+'): "'+
memuboard.dlpath+'"');
end;
baddlpath:=badfpath;
end;
function badulpath:boolean;
var s:string;
begin
if (badufpath) then begin
nl;
sprint(#3#7+'File base #'+cstr(fileboard)+': Unable to perform command.');
sprint(#3#5+'Bad UL file path: "'+memuboard.ulpath+'".');
sprint(#3#5+'Please inform the SysOp.');
sysoplog('Invalid UL path (file base #'+cstr(fileboard)+'): "'+
memuboard.ulpath+'"');
end;
badulpath:=badufpath;
end;
function bslash(b:boolean; s:astr):astr;
begin
if (b) then begin
while (copy(s,length(s)-1,2)='\\') do s:=copy(s,1,length(s)-2);
if (copy(s,length(s),1)<>'\') then s:=s+'\';
end else
while (copy(s,length(s),1)='\') do s:=copy(s,1,length(s)-1);
bslash:=s;
end;
function existdir(s:astr):boolean;
var savedir:astr;
okd:boolean;
begin
okd:=TRUE;
s:=bslash(FALSE,fexpand(s));
if ((length(s)=2) and (copy(s,2,1)=':')) then begin
getdir(0,savedir);
{$I-} chdir(s); {$I+}
if (ioresult<>0) then okd:=FALSE;
chdir(savedir);
exit;
end;
okd:=(exist(s));
if (okd) then begin
findfirst(s,anyfile,dirinfo);
if (dirinfo.attr and directory<>directory) or
(doserror<>0) then okd:=FALSE;
end;
existdir:=okd;
end;
procedure fiscan(var pl:integer); { loads in memuboard ... }
var f:ulfrec;
dirinfo:searchrec;
s:astr;
begin
s:=memuboard.dlpath; s:=copy(s,1,length(s)-1);
if ((length(s)=2) and (s[2]=':')) then badfpath:=FALSE
else begin
findfirst(s,dos.directory,dirinfo);
badfpath:=(doserror<>0);
end;
s:=memuboard.ulpath; s:=copy(s,1,length(s)-1);
if ((length(s)=2) and (s[2]=':')) then badufpath:=FALSE
else begin
findfirst(s,dos.directory,dirinfo);
badufpath:=(doserror<>0);
end;
if (not ulffopen1) then
if (filerec(ulff).mode<>fmclosed) then close(ulff)
else
begin
end
else
ulffopen1:=FALSE;
loaduboard(fileboard);
158
{rcg11182000 lowercased these ".DIR" strings...}
159
if (fbdirdlpath in memuboard.fbstat) then
160
assign(ulff,memuboard.dlpath+memuboard.filename+'.dir')
161
else
162
assign(ulff,systat.gfilepath+memuboard.filename+'.dir');
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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
{$I-} reset(ulff); {$I+}
if (ioresult<>0) then begin
rewrite(ulff);
f.blocks:=0;
write(ulff,f);
end;
seek(ulff,0); read(ulff,f);
pl:=f.blocks;
bnp:=FALSE;
end;
procedure ffile(fn:astr);
begin
findfirst(fn,anyfile,dirinfo);
found:=(doserror=0);
end;
procedure fileinfo(f:ulfrec; editing:boolean; var abort,next:boolean);
var dt:datetimerec;
s:astr;
r:real;
x:longint;
i,j:integer;
u:userrec;
begin
j:=0;
with f do
for i:=1 to 8 do begin
if (i=4) and (editing) then inc(i);
inc(j);
if (editing) then s:=#3#3+cstr(j)+'. ' else s:=#3#1;
case i of
1:s:=s+'Filename : '+#3#3+'"'+filename+'"';
2:s:=s+'Description: '+#3#3+description;
3:begin
x:=blocks; x:=x*128;
s:=s+'File size : '+#3#5+cstrl(x)+' bytes ('+cstr((blocks+7) div 8)+'K) / '+cstr(blocks)+' blocks';
end;
4:begin
r:=rte*blocks; r2dt(r,dt);
s:=s+'Aprox. time: '+#3#5+longtim(dt);
end;
5:if (editing) or (aacs(memuboard.nameacs)) then
s:=s+'UL''d by : '+#3#9+caps(stowner)+' #'+cstr(owner);
6:s:=s+'UL''d on : '+#3#9+date;
7:s:=s+'Times DL''d : '+#3#9+cstr(nacc);
8:begin
s:=s+'File points: '+#3#4+cstr(filepoints);
if (notval in filestat) then s:=s+' '+#3#8+'<NV>';
if (isrequest in filestat) then s:=s+' '+#3#9+'Ask (Request File)';
if (resumelater in filestat) then s:=s+' '+#3#7+'Resume later';
end;
end;
if (s<>#3#1) then printacr(s,abort,next);
end;
if (f.vpointer<>-1) then verbfileinfo(f.vpointer,editing,abort,next);
end;
function fit(f1,f2:astr):boolean;
var tf:boolean; c:integer;
begin
tf:=TRUE;
for c:=1 to 12 do
if (f1[c]<>f2[c]) and (f1[c]<>'?') then tf:=FALSE;
fit:=tf;
end;
procedure gfn(var fn:astr);
begin
sprint(fstring.gfnline1);
prt(fstring.gfnline2); input(fn,12);
if (pos('.',fn)=0) then fn:=fn+'*.*';
fn:=align(fn);
end;
function isgifdesc(d:astr):boolean;
begin
isgifdesc:=((copy(d,1,1)='(') and (pos('x',d) in [1..7]) and
(pos('c)',d)<>0));
end;
function isgifext(fn:astr):boolean;
begin
fn:=align(stripname(sqoutsp(fn)));
fn:=allcaps(copy(fn,length(fn)-2,3));
isgifext:=((fn='GIF') or (fn='GYF'));
end;
function isul(s:astr):boolean;
begin
isul:=((pos('\',s)<>0) or (pos(':',s)<>0) or (pos('|',s)<>0));
end;
function iswildcard(s:astr):boolean;
begin
iswildcard:=((pos('*',s)<>0) or (pos('?',s)<>0));
end;
procedure nfile;
begin
findnext(dirinfo);
found:=(doserror=0);
end;
procedure nrecno(fn:astr; var pl,rn:integer);
var c:integer;
f:ulfrec;
begin
rn:=0;
if (lrn<pl) and (lrn>=0) then begin
c:=lrn+1;
while (c<=pl) and (rn=0) do begin
seek(ulff,c); read(ulff,f);
if pos('.',f.filename)<>9 then begin
f.filename:=align(f.filename);
seek(ulff,c); write(ulff,f);
end;
if fit(lfn,f.filename) then rn:=c;
inc(c);
end;
lrn:=rn;
end;
end;
procedure recno(fn:astr; var pl,rn:integer);
var f:ulfrec;
c:integer;
begin
fn:=align(fn);
fiscan(pl);
rn:=0; c:=1;
while (c<=pl) and (rn=0) do begin
seek(ulff,c); read(ulff,f);
if pos('.',f.filename)<>9 then begin
f.filename:=align(f.filename);
seek(ulff,c); write(ulff,f);
end;
if fit(fn,f.filename) then rn:=c;
inc(c);
end;
lrn:=rn;
lfn:=fn;
end;
function rte:real;
var i:integer;
begin
i:=value(spd); if (i=0) then i:=modemr.waitbaud;
rte:=1400.0/i;
end;
procedure star(s:astr);
begin
cl(4); if (okansi) then prompt('þ ') else prompt('* ');
cl(3); if (s<>#1) then sprint(s);
end;
function stripname(i:astr):astr;
var i1:astr;
n:integer;
function nextn:integer;
var n:integer;
begin
n:=pos(':',i1);
if (n=0) then n:=pos('\',i1);
if (n=0) then n:=pos('/',i1);
nextn:=n;
end;
begin
i1:=i;
while (nextn<>0) do i1:=copy(i1,nextn+1,80);
stripname:=i1;
end;
function tcheck(s:real; i:integer):boolean;
var r:real;
begin
r:=timer-s;
if r<0.0 then r:=r+86400.0;
if (r<0.0) or (r>32760.0) then r:=32766.0;
if trunc(r)>i then tcheck:=FALSE else tcheck:=TRUE;
end;
function tchk(s:real; i:real):boolean;
var r:real;
begin
r:=timer;
if r<s then r:=r+86400.0;
if (r-s)>i then tchk:=FALSE else tchk:=TRUE;
end;
procedure verbfileinfo(pt:integer; editing,abort,next:boolean);
var v:verbrec;
i:integer;
s:astr;
vfo:boolean;
begin
v.descr[1]:='';
if pt<>-1 then begin
vfo:=(filerec(verbf).mode<>fmclosed);
{$I-} if not vfo then reset(verbf); {$I+}
if ioresult=0 then begin
{$I-} seek(verbf,pt); read(verbf,v); {$I+}
if ioresult=0 then
with v do
for i:=1 to 4 do
if descr[i]='' then i:=4
else begin
s:=#3#5;
if (editing) then s:=s+' ';
if (i=1) then s:=s+'Verbose : ' else s:=s+' : ';
s:=s+#3#4+descr[i];
if (editing) and (i=1) then s:=s+#3#2+' ('+cstr(pt)+')';
printacr(s,abort,next);
end;
if (not vfo) then close(verbf);
end;
end;
if (editing) then
if (pt=-1) then printacr(#3#5' No Verbose',abort,next)
else
if (v.descr[1]='') then
printacr(#3#7' No Verbose YET'+#3#2+' ('+cstr(pt)+')',abort,next);
end;
end.