Skip to content

Latest commit

 

History

History
462 lines (438 loc) · 15.5 KB

sysop1.pas

File metadata and controls

462 lines (438 loc) · 15.5 KB
 
Nov 18, 2000
Nov 18, 2000
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
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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
(*****************************************************************************)
(*> <*)
(*> SYSOP1 .PAS - Written by Eric Oman <*)
(*> <*)
(*> SysOp functions: Protocol editor. <*)
(*> <*)
(*****************************************************************************)
{$A+,B+,D-,E+,F+,I+,L+,N-,O+,R-,S+,V-}
unit sysop1;
interface
procedure ee_help;
procedure exproedit;
implementation
uses
crt, dos,
{rcg11172000 no overlay under Linux.}
{overlay,}
common,
file1,
menus2;
var menuchanged:boolean;
x:integer;
procedure ee_help;
begin
sprint(' #:Modify item <CR>Redisplay screen');
lcmds(15,3,'[Back entry',']Forward entry');
lcmds(15,3,'Jump to entry','First entry in list');
lcmds(15,3,'Quit and save','Last entry in list');
end;
procedure exproedit;
var wrd:word;
i1,i2,ii,xloaded:integer;
c:char;
abort,next:boolean;
st:astr;
procedure xed(i:integer);
var x:integer;
begin
if (i>=0) and (i<=filesize(xf)-1) then begin
if (i>=0) and (i<filesize(xf)-1) then
for x:=i to filesize(xf)-2 do begin
seek(xf,x+1); read(xf,protocol);
seek(xf,x); write(xf,protocol);
end;
seek(xf,filesize(xf)-1); truncate(xf);
end;
end;
function newindexno:longint;
var xpr:protrec;
i,j:integer;
begin
reset(xf);
j:=-1;
for i:=1 to filesize(xf) do begin
read(xf,xpr);
if (xpr.permindx>j) then j:=xpr.permindx;
end;
inc(j);
newindexno:=j;
end;
procedure xei(i:integer);
var x:integer;
begin
if (i>=0) and (i<=filesize(xf)) and (filesize(xf)<maxprotocols) then begin
for x:=filesize(xf)-1 downto i do begin
seek(xf,x); read(xf,protocol);
write(xf,protocol); (* to next record *)
end;
with protocol do begin
xbstat:=[xbxferokcode];
ckeys:='!';
descr:=#3#4+'('+#3#3+'!'+#3#4+') New Protocol';
acs:='';
templog:='';
uloadlog:=''; dloadlog:='';
ulcmd:='QUIT'; dlcmd:='QUIT';
for x:=1 to 6 do begin ulcode[x]:=''; dlcode[x]:=''; end;
envcmd:='';
dlflist:='';
maxchrs:=128;
logpf:=0; logps:=0;
permindx:=newindexno;
for x:=1 to 11 do res[x]:=0;
end;
seek(xf,i); write(xf,protocol);
end;
end;
function udq:integer;
var c:char;
begin
prt('What type? (U)pload (D)ownload : ');
onek(c,'DU'); nl;
if (c='U') then udq:=1 else udq:=2;
end;
{rcg11172000 had to change this to get it compiling under Free Pascal...}
{function substone(src,old,new:astr):astr;}
function substone(src,old,_new:astr):astr;
var p:integer;
begin
p:=pos(old,src);
if (p>0) then begin
insert(_new,src,p+length(old));
delete(src,p,length(old));
end;
substone:=src;
end;
function showpmci(s:astr):astr;
begin
s:=substone(s,'%B',#3#3+'%B'+#3#1);
s:=substone(s,'%C',#3#3+'%C'+#3#1);
s:=substone(s,'%F',#3#3+'%F'+#3#1);
s:=substone(s,'%G',#3#3+'%G'+#3#1);
s:=substone(s,'%L',#3#3+'%L'+#3#1);
s:=substone(s,'%P',#3#3+'%P'+#3#1);
s:=substone(s,'%T',#3#3+'%T'+#3#1);
showpmci:=s;
end;
procedure xem;
var s:astr;
i,j,i1,i2,ii:integer;
c,c1:char;
bb:byte;
changed,b:boolean;
function cfip(pt:integer; s:astr):astr;
begin
if (pt<1) or (pt>5) then cfip:=s else cfip:='';
end;
function nnon(s:astr):astr;
begin
if (s<>'') then nnon:='"'+s+'"' else nnon:='*None*';
end;
procedure pprint(s:astr);
var i:integer;
begin
s:=showpmci(s);
cl(1);
for i:=1 to length(s) do
if ((s[i]=#3) and (i<>length(s))) then begin
cl(ord(s[i+1]));
inc(i);
end else
outkey(s[i]);
nl;
end;
begin
xloaded:=-1;
prt('Begin editing at which? (0-'+cstr(filesize(xf)-1)+') : '); inu(ii);
c:=' ';
if (ii>=0) and (ii<=filesize(xf)-1) then begin
while (c<>'Q') and (not hangup) do begin
if (xloaded<>ii) then begin
seek(xf,ii); read(xf,protocol);
xloaded:=ii; changed:=FALSE;
end;
with protocol do
repeat
if (c<>'?') then begin
cls;
abort:=FALSE; next:=FALSE; i:=1;
while ((i<=15) and (not abort)) do begin
case i of
1:print('Protocol #'+cstr(ii)+' of '+cstr(filesize(xf)-1));
2:print('!. Type/protocl:'+
aonoff(xbactive in xbstat,'Active','NOT ACTIVE')+' - '+
aonoff(xbisbatch in xbstat,'Batch protocol','Single protocol')+
aonoff(xbisresume in xbstat,' - RESUME protocol',''));
3:pprint('1. Keys/descrip:"'+ckeys+'" / "'+descr+'"');
4:print('2. ACS required: "'+acs+'"');
5:pprint('3. Temp. log : '+nnon(templog));
6:pprint('4. <U>L log : '+nnon(uloadlog));
7:pprint(' <D>L log : '+nnon(dloadlog));
8:pprint('5. <U>L command: '+nnon(ulcmd));
9:pprint(' <D>L command: '+nnon(dlcmd));
10:print('6. Codes mean :'+aonoff(xbxferokcode in xbstat,
'Transfer OK','Transfer bad'));
11:begin
s:='7. <U>L codes :';
for j:=1 to 6 do
s:=s+mln('('+cstr(j)+')"'+ulcode[j]+'" ',10);
print(copy(s,1,length(s)-1));
end;
12:begin
s:=' <D>L codes :';
for j:=1 to 6 do
s:=s+mln('('+cstr(j)+')"'+dlcode[j]+'" ',10);
print(copy(s,1,length(s)-1));
end;
13:pprint('E. Environ. cmd: '+nnon(envcmd));
14:pprint('I. DL File list: '+nnon(dlflist));
15:print('C. Max DOS chrs:'+cstr(maxchrs)+
' P. Log position: Filename: '+cstr(logpf)+
' - Status: '+cstr(logps));
end;
inc(i);
wkey(abort,next);
end;
end;
nl;
prt('Edit menu (?=help) : '); onek(c,'Q!1234567CEIP[]FJL?'^M);
nl;
case c of
'!':begin
repeat
print('1. Protocol active :'+syn(xbactive in xbstat));
print('2. Is batch protocol :'+syn(xbisbatch in xbstat));
print('3. Is resume protocol:'+syn(xbisresume in xbstat));
nl;
prt('Select (1-3,Q=Quit) : '); onek(c,'Q123'^M);
nl;
if (c in ['1'..'3']) then begin
changed:=TRUE;
case c of
'1':if (xbactive in xbstat) then
xbstat:=xbstat-[xbactive]
else xbstat:=xbstat+[xbactive];
'2':if (xbisbatch in xbstat) then
xbstat:=xbstat-[xbisbatch]
else xbstat:=xbstat+[xbisbatch];
'3':if (xbisresume in xbstat) then
xbstat:=xbstat-[xbisresume]
else xbstat:=xbstat+[xbisresume];
end;
end;
until ((not (c in ['1'..'3'])) or (hangup));
c:=#0;
end;
'1':begin
prt('New command keys: '); mpl(14); input(s,14);
if (s<>'') then begin
if (s<>ckeys) then changed:=TRUE;
ckeys:=s;
end;
nl;
print('New description:');
prt(':'); cl(1); inputwc(s,40);
if (s<>'') then begin
if (s<>descr) then changed:=TRUE;
descr:=s;
end;
end;
'2':begin
prt('New ACS: '); mpl(20);
inputwn(acs,20,changed);
end;
'3':begin
print('New temp. log:');
prt(':'); inputwn(templog,25,changed);
end;
'4':case udq of
1:begin
print('New permanent upload log:');
prt(':'); inputwn(uloadlog,25,changed);
end;
2:begin
print('New permanent download log:');
prt(':'); inputwn(dloadlog,25,changed);
end;
end;
'5':begin
s:=#0#0#0; j:=udq;
prt('Type: (A)scii (C)ommand (E)xternal (O)ff : ');
onek(c,^M'ACEO'); nl;
case c of
'A':s:='ASCII';
'C':begin
prt('(B)atch (N)ext (Q)uit : ');
onek(c,'BNQ'^M);
case c of
'B':s:='BATCH';
'N':s:='NEXT';
'Q':s:='QUIT';
end;
end;
'E':begin
if (j=1) then print('New upload commandline:')
else print('New download commandline:');
prt(':'); inputwn(s,78,changed);
end;
'O':if pynq('Set to NULL string? ') then s:='';
end;
if (s<>#0#0#0) then begin
changed:=TRUE;
case j of
1:ulcmd:=s;
2:dlcmd:=s;
end;
end;
c:=#0;
end;
'6':begin
if (xbxferokcode in xbstat) then
xbstat:=xbstat-[xbxferokcode]
else xbstat:=xbstat+[xbxferokcode];
changed:=TRUE;
end;
'7':begin
case udq of
1:begin
print('New upload codes:'); nl;
for i:=1 to 6 do begin
prt('Code #'+cstr(i)+' ["'+ulcode[i]+'"] : ');
inputwn(ulcode[i],6,changed);
end;
end;
2:begin
print('New download codes:'); nl;
for i:=1 to 6 do begin
prt('Code #'+cstr(i)+' ["'+dlcode[i]+'"] : ');
inputwn(dlcode[i],6,changed);
end;
end;
end;
end;
'C':begin
prt('New max DOS chrs in commandline: '); inu(i);
if (not badini) then begin
if (i<>maxchrs) then changed:=TRUE;
maxchrs:=i;
end;
end;
'E':begin
print('New environment setup commandline:');
prt(':'); inputwn(envcmd,60,changed);
end;
'I':begin
print('New batch file list:');
prt(':'); inputwn(dlflist,25,changed);
end;
'P':begin
prt('New "Filename" log position? ['+cstr(logpf)+'] : ');
inu(i);
if (not badini) then begin
if (i<>logpf) then changed:=TRUE;
logpf:=i;
end;
prt('New "Status" log position? ['+cstr(logps)+'] : ');
inu(i);
if (not badini) then begin
if (i<>logpf) then changed:=TRUE;
logps:=i;
end;
end;
'[':if (ii>0) then dec(ii) else c:=' ';
']':if (ii<filesize(xf)-1) then inc(ii) else c:=' ';
'F':if (ii<>0) then ii:=0 else c:=' ';
'J':begin
prt('Jump to entry: ');
input(s,3);
if ((value(s)>=0) and (value(s)<=filesize(xf)-1)) then
ii:=value(s) else c:=' ';
end;
'L':if (ii=filesize(xf)-1) then c:=' ' else ii:=filesize(xf)-1;
'?':ee_help;
end;
until (pos(c,'Q[]FJL')<>0) or (hangup);
if (changed) then begin
seek(xf,xloaded); write(xf,protocol);
changed:=FALSE;
end;
end;
end;
end;
procedure xep;
var i,j,k:integer;
begin
prt('Move which protocol? (0-'+cstr(filesize(xf)-1)+') : '); inu(i);
if ((not badini) and (i>=0) and (i<=filesize(xf)-1)) then begin
prt('Move before which protocol? (0-'+cstr(filesize(xf))+') : '); inu(j);
if ((not badini) and (j>=0) and (j<=filesize(xf)) and
(j<>i) and (j<>i+1)) then begin
xei(j);
if (j>i) then k:=i else k:=i+1;
seek(xf,k); read(xf,protocol);
seek(xf,j); write(xf,protocol);
if (j>i) then xed(i) else xed(i+1);
end;
end;
end;
function nar(c:char):char;
begin
if c='@' then nar:=' ' else nar:=c;
end;
begin
reset(xf); xloaded:=-1; c:=#0;
repeat
if (c<>'?') then
begin
cls; abort:=FALSE;
printacr(#3#3+' NNN'+sepr2+'ACS '+sepr2+'Description',abort,next);
printacr(#3#4+' ===:==========:=============================================================',abort,next);
ii:=0;
seek(xf,0);
while (ii<=filesize(xf)-1) and (not abort) do begin
read(xf,protocol);
with protocol do begin
printacr(aonoff((xbactive in xbstat),#3#5+'+',#3#1+'-')+
#3#0+mn(ii,3)+' '+#3#9+mln(acs,10)+' '+
#3#1+descr,abort,next);
inc(ii);
end;
end;
end;
nl;
prt('Protocol editor (?=help) : ');
onek(c,'QDIMP?'^M);
case c of
'?':begin
nl;
print('<CR>Redisplay screen');
lcmds(16,3,'Delete protocol','Insert protocol');
lcmds(16,3,'Modify protocol','Position protocol');
lcmds(16,3,'Quit','');
end;
'D':begin
prt('Protocol to delete? (0-'+cstr(filesize(xf)-1)+') : '); inu(ii);
if (ii>=0) and (ii<=filesize(xf)-1) then begin
seek(xf,ii); read(xf,protocol);
nl; sprint('Protocol: '+#3#4+protocol.descr);
if pynq('Delete this? ') then
begin
sysoplog('* Deleted protocol: '+protocol.descr); xed(ii);
end;
end;
end;
'I':begin
prt('Protocol to insert before? (0-'+cstr(filesize(xf))+') : '); inu(ii);
if (ii>=0) and (ii<=filesize(xf)) then
begin
xei(ii); sysoplog('* Inserted new protocol');
end;
end;
'M':xem;
'P':xep;
end;
until ((c='Q') or (hangup));
close(xf);
end;
end.