Skip to content

Latest commit

 

History

History
394 lines (368 loc) · 12.9 KB

doors.pas

File metadata and controls

394 lines (368 loc) · 12.9 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
(*****************************************************************************)
(*> <*)
(*> DOORS .PAS - Written by Eric Oman <*)
(*> <*)
(*> Online door procedures. <*)
(*> <*)
(*****************************************************************************)
{$A+,B+,D-,E+,F+,I+,L+,N-,O+,R-,S+,V-}
unit doors;
interface
uses
crt, dos,
{rcg11172000 no overlay under Linux.}
{overlay,}
execbat,
common;
function process_door(s:astr):astr;
procedure write_dorinfo1_def(rname:boolean); { RBBS-PC DORINFO1.DEF }
procedure write_door_sys(rname:boolean); { GAP DOOR.SYS }
procedure write_chain_txt; { WWIV CHAIN.TXT }
procedure write_callinfo_bbs(rname:boolean); { Wildcat! CALLINFO.BBS }
procedure write_sfdoors_dat(rname:boolean); { Spitfire SFDOORS.DAT }
procedure dodoorfunc(kind:char; cline:astr);
implementation
function timestr:astr;
var i:astr;
begin
{str(nsl/60,i);}
{i:=copy(i,2,length(i));}
{i:=copy(i,1,pos('.',i)-1);}
i:=cstrr(nsl/60,10);
timestr:=i;
end;
function process_door(s:astr):astr;
var i:integer;
sda,namm:astr;
sdoor:string[255];
begin
namm:=caps(thisuser.realname);
sdoor:='';
for i:=1 to length(s) do begin
if copy(s,i,1)='@' then begin
sda:='';
case upcase(s[i+1]) of
'B':if spd<>'KB' then sda:=spd else sda:='0';
'D':begin
loaduboard(fileboard);
sda:=memuboard.dlpath;
end;
'F':sda:=copy(namm,1,pos(' ',namm)-1);
'G':if okansi then sda:='1' else sda:='0';
'I':begin
loaduboard(fileboard);
sda:=systat.gfilepath;
if (copy(sda,length(sda),1)<>'\') then sda:=sda+'\';
sda:=sda+memuboard.filename+'.DIR';
end;
'L':begin
if (pos(' ',namm)=0) then sda:=namm else
sda:=copy(namm,pos(' ',namm)+1,length(namm));
end;
'N':sda:=caps(thisuser.name);
'T':sda:=timestr;
'R':sda:=(copy(nam,pos('#',nam)+1,length(nam)));
end;
sdoor:=sdoor+sda;
inc(i);
end
else sdoor:=sdoor+copy(s,i,1);
end;
process_door:=sdoor;
end;
procedure write_dorinfo1_def(rname:boolean); (* RBBS-PC's DORINFO1.DEF *)
var fp:text;
first,last:astr;
s:astr;
begin
assign(fp,'dorinfo1.def');
rewrite(fp);
writeln(fp,stripcolor(systat.bbsname));
first:=copy(systat.sysopname,1,pos(' ',systat.sysopname)-1);
last:=copy(systat.sysopname,length(first)+2,length(systat.sysopname));
writeln(fp,first);
writeln(fp,last);
if spd='KB' then writeln(fp,'COM0') else writeln(fp,'COM'+cstr(modemr.comport));
if spd='KB' then s:='0' else s:=spd;
writeln(fp,s+' BAUD,N,8,1');
writeln(fp,'0');
if (rname) then begin
if pos(' ',thisuser.realname)=0 then begin
first:=thisuser.realname;
last:='';
end else begin
first:=copy(thisuser.realname,1,pos(' ',thisuser.realname)-1);
last:=copy(thisuser.realname,length(first)+2,length(thisuser.realname));
end;
first:=allcaps(first);
last:=allcaps(last);
end else begin
if pos(' ',thisuser.name)=0 then begin
first:=thisuser.name;
last:='';
end else begin
first:=copy(thisuser.name,1,pos(' ',thisuser.name)-1);
last:=copy(thisuser.name,length(first)+2,length(thisuser.name));
end;
end;
writeln(fp,caps(first));
writeln(fp,caps(last));
writeln(fp,thisuser.citystate);
if (ansi in thisuser.ac) then writeln(fp,'1') else writeln(fp,'0');
writeln(fp,thisuser.sl);
s:=timestr;
if length(s)>3 then s:='999';
writeln(fp,s);
writeln(fp,'0');
close(fp);
end;
procedure write_door_sys(rname:boolean); (* GAP's DOOR.SYS *)
var fp:text;
i:integer;
s:astr;
begin
assign(fp,'door.sys');
rewrite(fp);
if spd<>'KB' then writeln(fp,'COM'+cstr(modemr.comport)+':') else writeln(fp,'COM0:');
if spd<>'KB' then writeln(fp,spd) else writeln(fp,cstr(modemr.waitbaud));
writeln(fp,' 8');
writeln(fp,' 1');
writeln(fp,' N');
if wantout then writeln(fp,' Y') else writeln(fp,' N');
writeln(fp,' Y');
if sysop then writeln(fp,' Y') else writeln(fp,' N');
if alert in thisuser.ac then writeln(fp,' Y') else writeln(fp,' N');
if (rname) then writeln(fp,thisuser.realname) else writeln(fp,thisuser.name);
writeln(fp,thisuser.citystate);
writeln(fp,copy(thisuser.ph,1,3)+' '+copy(thisuser.ph,5,8));
writeln(fp,copy(thisuser.ph,1,3)+' '+copy(thisuser.ph,5,8));
writeln(fp,thisuser.pw);
writeln(fp,cstr(thisuser.sl));
writeln(fp,cstr(thisuser.loggedon));
writeln(fp,thisuser.laston);
writeln(fp,cstrl(trunc(nsl)));
writeln(fp,cstr(trunc(nsl) div 60));
if okansi then writeln(fp,'GR') else writeln(fp,'NG');
writeln(fp,cstr(thisuser.pagelen));
if novice in thisuser.ac then writeln(fp,' N') else writeln(fp,' Y');
s:='';
for i:=1 to 7 do
if chr(i+64) in thisuser.ar then s:=s+cstr(i);
writeln(fp,s);
writeln(fp,'7');
writeln(fp,'12/31/99');
writeln(fp,' '+cstr(usernum));
writeln(fp,' X');
writeln(fp,' '+cstr(thisuser.uploads));
writeln(fp,' '+cstr(thisuser.downloads));
writeln(fp,' '+cstr(trunc(thisuser.dk)));
writeln(fp,' 999999');
close(fp);
end;
procedure write_chain_txt;
var fp:text;
ton,tused:real;
s:string[20];
function bo(b:boolean):astr;
begin
if b then bo:='1' else bo:='0';
end;
begin
assign(fp,'chain.txt');
rewrite(fp);
with thisuser do begin
writeln(fp,usernum); { user number }
writeln(fp,name); { user name }
writeln(fp,realname); { real name }
writeln(fp,''); { "call sign" ? }
writeln(fp,ageuser(bday)); { age }
writeln(fp,sex); { sex }
str(credit:7,s); writeln(fp,s+'.00'); { credit }
writeln(fp,laston); { laston date }
writeln(fp,linelen); { # screen columns }
writeln(fp,pagelen); { # screen rows }
writeln(fp,sl); { SL }
writeln(fp,bo(so)); { is he a SysOp? }
writeln(fp,bo(cso)); { is he a CoSysOp? }
writeln(fp,bo(okansi)); { is graphics on? }
writeln(fp,bo(incom)); { is remote? }
str(nsl:10:2,s); writeln(fp,s); { time left (sec) }
writeln(fp,systat.gfilepath); { gfiles path }
writeln(fp,systat.gfilepath); { data path }
writeln(fp,'SYSOP.LOG'); { SysOp log filespec }
s:=spd; if (s='KB') then s:='0'; { baud rate }
writeln(fp,s);
writeln(fp,modemr.comport); { COM port }
writeln(fp,stripcolor(systat.bbsname)); { system name }
writeln(fp,systat.sysopname); { SysOp's name }
with timeon do begin
ton:=hour*3600.0+min*60.0+sec;
tused:=timer-ton;
if (tused<0) then tused:=tused+3600.0*24.0;
end;
writeln(fp,trunc(ton)); { secs on f/midnight }
writeln(fp,trunc(tused)); { time used (sec) }
writeln(fp,uk); { upload K }
writeln(fp,uploads); { uploads }
writeln(fp,dk); { download K }
writeln(fp,downloads); { downloads }
writeln(fp,'8N1'); { COM parameters }
end;
close(fp);
end;
procedure write_callinfo_bbs(rname:boolean);
var fp:text;
s:astr;
function bo(b:boolean):astr;
begin
if b then bo:='1' else bo:='0';
end;
begin
assign(fp,'callinfo.bbs');
rewrite(fp);
with thisuser do begin
if (rname) then writeln(fp,allcaps(thisuser.realname)) else writeln(fp,allcaps(thisuser.name));
if spd='300' then s:='1' else
if spd='1200' then s:='2' else
if spd='2400' then s:='0' else
if spd='9600' then s:='3' else
if spd='KB' then s:='5' else
s:='4';
writeln(fp,s);
writeln(fp,allcaps(thisuser.citystate));
writeln(fp,cstr(thisuser.sl));
writeln(fp,timestr);
if okansi then writeln(fp,'COLOR') else writeln(fp,'MONO');
writeln(fp,thisuser.pw);
writeln(fp,cstr(usernum));
writeln(fp,'0');
writeln(fp,copy(time,1,5));
writeln(fp,copy(time,1,5)+' '+date);
writeln(fp,'A');
writeln(fp,'0');
writeln(fp,'999999');
writeln(fp,'0');
writeln(fp,'999999');
writeln(fp,thisuser.ph);
writeln(fp,thisuser.laston+' 00:00');
if (novice in thisuser.ac) then writeln(fp,'NOVICE') else writeln(fp,'EXPERT');
writeln(fp,'All');
writeln(fp,'01/01/80');
writeln(fp,cstr(thisuser.loggedon));
writeln(fp,cstr(thisuser.pagelen));
writeln(fp,'0');
writeln(fp,cstr(thisuser.uploads));
writeln(fp,cstr(thisuser.downloads));
writeln(fp,'8 { Databits }');
if ((incom) or (outcom)) then writeln(fp,'REMOTE') else writeln(fp,'LOCAL');
if ((incom) or (outcom)) then writeln(fp,'COM'+cstr(modemr.comport)) else writeln(fp,'COM0');
writeln(fp,thisuser.bday);
if spd='KB' then writeln(fp,cstr(modemr.waitbaud)) else writeln(fp,spd);
if ((incom) or (outcom)) then writeln(fp,'TRUE') else writeln(fp,'FALSE');
if (spdarq) then write(fp,'MNP/ARQ') else write(fp,'Normal');
writeln(fp,' Connection');
writeln(fp,'12/31/99 23:59');
writeln(fp,'1');
writeln(fp,'1');
end;
close(fp);
end;
procedure write_sfdoors_dat(rname:boolean); { Spitfire SFDOORS.DAT }
var fp:text;
s:astr;
begin
assign(fp,'SFDOORS.DAT');
rewrite(fp);
writeln(fp,cstr(usernum));
if (rname) then writeln(fp,allcaps(thisuser.realname)) else writeln(fp,allcaps(thisuser.name));
writeln(fp,thisuser.pw);
if (rname) then begin
if (pos(' ',thisuser.realname)=0) then s:=thisuser.realname
else s:=copy(thisuser.realname,1,pos(' ',thisuser.realname)-1);
end else begin
if (pos(' ',thisuser.name)=0) then s:=thisuser.name
else s:=copy(thisuser.name,1,pos(' ',thisuser.name)-1);
end;
writeln(fp,s);
if (spd='KB') then writeln(fp,'0') else writeln(fp,cstr(modemr.comport));
writeln(fp,timestr);
writeln(fp,'0'); { seconds since midnight }
writeln(fp,start_dir);
if okansi then writeln(fp,'TRUE') else writeln(fp,'FALSE');
writeln(fp,cstr(thisuser.sl));
writeln(fp,cstr(thisuser.uploads));
writeln(fp,cstr(thisuser.downloads));
writeln(fp,cstr(systat.timeallow[thisuser.sl]));
writeln(fp,'0'); { time on (seconds) }
writeln(fp,'0'); { extra time (seconds) }
writeln(fp,'FALSE');
writeln(fp,'FALSE');
writeln(fp,'FALSE');
if (spd='KB') then writeln(fp,'0') else writeln(fp,spd);
close(fp);
end;
procedure dodoorfunc(kind:char; cline:astr);
var doorstart,doorend,doortime:datetimerec;
s,cline2:astr;
retcode,savsl,savdsl:integer;
realname:boolean;
begin
realname:=FALSE;
if ((sqoutsp(cline)='') and (incom)) then begin
print('This command is inoperative!');
if (cso) then print('(An MString of "" will shell to DOS LOCALLY!)');
exit;
end;
if ((realsl<>-1) and (realdsl<>-1)) then begin
savsl:=thisuser.sl; savdsl:=thisuser.dsl;
thisuser.sl:=realsl; thisuser.dsl:=realdsl;
saveuf;
end;
(* sprint(#3#3+'[> '+#3#0+'Opening door on '+
#3#5+date+' '+time+#3#0+' ... Please wait.');*)
cline2:=cline;
if copy(allcaps(cline2),1,2)='R;' then begin
realname:=TRUE;
cline2:=copy(cline2,3,length(cline2)-2);
end;
s:=process_door(cline2);
case kind of
'C':begin
commandline('Outputting CHAIN.TXT (WWIV) ...');
write_chain_txt;
end;
'D':begin
commandline('Outputting DORINFO1.DEF (RBBS-PC) ...');
write_dorinfo1_def(realname);
end;
'G':begin
commandline('Outputting DOOR.SYS (GAP) ...');
write_door_sys(realname);
end;
'S':begin
commandline('Outputting SFDOORS.DAT (Spitfire) ...');
write_sfdoors_dat(realname);
end;
'W':begin
commandline('Outputting CALLINFO.BBS (Wildcat!) ...');
write_callinfo_bbs(realname);
end;
end;
commandline('Now running "'+s+'"');
sysoplog('>> '+date+' '+time+'- Door "'+s+'"');
close(sysopf);
getdatetime(doorstart);
shel1; shelldos(FALSE,s,retcode); shel2;
getdatetime(doorend);
timediff(doortime,doorstart,doorend);
chdir(start_dir);
append(sysopf);
if ((realsl<>-1) and (realdsl<>-1)) then begin
reset(uf); seek(uf,usernum); read(uf,thisuser); close(uf);
thisuser.sl:=savsl; thisuser.dsl:=savdsl;
end;
com_flush_rx;
getdatetime(tim);
sysoplog('>> '+date+' '+time+'- Returned (spent '+longtim(doortime)+')');
end;
end.