Skip to content

Latest commit

 

History

History
474 lines (436 loc) · 15.5 KB

mail4.pas

File metadata and controls

474 lines (436 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
463
464
465
466
467
468
469
470
471
472
473
474
{$A+,B+,D-,E+,F+,I+,L+,N-,O+,R-,S+,V-}
unit mail4;
interface
uses
crt, dos,
{rcg11172000 no overlay under Linux.}
{overlay,}
common, timejunk,
sysop3,
misc3, miscx,
mail0, mail1, mail2, mail3;
procedure autoreply;
procedure readmail;
implementation
function extractusernum(s:string):integer;
var i:integer;
begin
i:=length(s);
while ((s[i]<>'#') and (i>1)) do dec(i);
i:=value(copy(s,i+1,5));
extractusernum:=i;
end;
procedure autoreply;
var i:integer; c:char;
t:text;
mheader:mheaderrec;
s:string;
brdsig,dfdt1,dfdt2,newmsgptr,totload:longint;
begin
if (lastname='') then
print('hmmm.. I am unable to auto-reply now.')
else begin
i:=extractusernum(lastname);
if (i=0) then print('It seems I can''t do that now.') else imail(i);
end;
end;
procedure readmail;
const hellfreezesover=FALSE;
var t:text;
u:userrec;
mheader:mheaderrec;
mixr:msgindexrec;
pdt:packdatetime;
dt:ldatetimerec;
cmds,s,s1:string;
brdsig,totload:longint;
crec,i,j,k,mnum,mw,snum:integer;
c:char;
bb:byte;
abort,b,bakw,done,done1,dotitles,errs,found,hasshown1,holdit,
justdel,next,noreshow,seeanon:boolean;
procedure findit;
var orec:integer;
abort:boolean;
begin
orec:=crec; done1:=TRUE; found:=FALSE;
if (bakw) then begin
repeat
dec(crec); abort:=(crec<0);
if (not abort) then begin
ensureloaded(crec);
mixr:=mintab[getmixnum(crec)];
end;
until ((abort) or
((mixr.messagenum=usernum) and (miexist in mixr.msgindexstat)));
found:=not abort; if (abort) then crec:=orec;
if (crec<>orec) then dec(mnum);
exit;
end;
repeat
inc(crec); abort:=(crec>himsg);
if (not abort) then begin
ensureloaded(crec);
mixr:=mintab[getmixnum(crec)];
end;
until ((abort) or
((mixr.messagenum=usernum) and (miexist in mixr.msgindexstat)));
found:=not abort; if (abort) then crec:=orec;
if (crec<>orec) then inc(mnum);
if ((justdel) and (not found)) then begin done1:=FALSE; bakw:=TRUE; end;
exit;
end;
function tch(c:char; i:integer):string;
var s:string;
begin
s:=cstr(i); if (i<10) then s:=c+s;
tch:=s;
end;
procedure getout;
begin
closebrd;
thisuser.waiting:=mw;
readingmail:=FALSE;
end;
begin
readingmail:=TRUE;
abort:=FALSE; next:=FALSE;
dotitles:=TRUE;
mailread:=TRUE;
repeat
if (dotitles) then begin
abort:=FALSE; next:=FALSE;
nl;
hasshown1:=FALSE;
if (thisuser.waiting=0) then
sprint(#3#5+'Sorry, but you have no mail waiting.')
else begin
if (thisuser.clsmsg=1) then cls;
sprompt(#3#5+'You have '+#3#3+cstr(thisuser.waiting)+#3#5+' piece');
if (thisuser.waiting<>1) then sprompt('s');
sprint(' of mail waiting:');
nl;
end;
initbrd(-1);
i:=0; mw:=0;
while (i<=himsg) do begin
ensureloaded(i);
if ((mintab[getmixnum(i)].messagenum=usernum) and
(miexist in mintab[getmixnum(i)].msgindexstat)) then begin
inc(mw);
if (not abort) then begin
loadmhead(i,mheader); ensureloaded(i);
for j:=1 to 6 do pdt[j]:=mintab[getmixnum(i)].msgdate[j];
pdt2dt(pdt,dt);
with dt do begin
j:=hour;
if (j>12) then dec(j,12);
if (j=0) then j:=12;
s:=tch(' ',j)+':'+tch('0',min)+aonoff((hour>=12),'p','a');
s:=#3#3+copy('JanFebMarAprMayJunJulAugSepOctNovDec',(month-1)*3+1,3)+
' '+tch('0',day)+' '+cstr(year)+' - '+s;
end;
s1:=what00(mheader.fromi.anon,mheader.fromi.as);
if (mheader.fromi.anon in [1,2]) then begin
case mheader.fromi.anon of
1:seeanon:=aacs(systat.anonprivread);
2:seeanon:=aacs(systat.csop);
end;
if (seeanon) then
s1:=s1+' ('+caps(mheader.fromi.alias)+' #'+
cstr(mheader.fromi.usernum)+')'
else
s:=' ';
end;
if ((not hasshown1) and (thisuser.waiting=0)) then begin
nl; sprint(#3#5+'Correction! You do have mail waiting:'); nl;
end;
sprint(#3#0+tch(' ',mw)+#3#1+' - '+s+#3#1+' - '+#3#3+s1);
hasshown1:=TRUE;
end;
end;
inc(i);
wkey(abort,next);
end;
if (mw<>0) then nl;
if (thisuser.waiting<>mw) then begin
if (mw=0) then
sprint(#3#3+'You actually have no mail waiting!');
sprint(#3#5+'Note: Discrepancy has been repaired.');
sysoplog('Fixed discrepancy in number of private messages waiting.');
end;
thisuser.waiting:=mw;
if (mw=0) then begin getout; exit; end;
abort:=FALSE; done:=FALSE; next:=FALSE;
repeat
sprompt(#3#5+'Start out with (1-'+cstr(mw)+') or (Q)uit : '+#3#9);
input(s,4); snum:=0; i:=value(s);
if ((s='ZZZZ') and (thisuser.sl=255)) then begin
nl;
sprint(#3#3+'Super Mass Delete function selected!');
nl;
if (checkpw) then begin
prompt('Enter user PW: ');
echo:=FALSE; input(s1,20); echo:=TRUE;
if (s1=thisuser.pw) then begin
nl; nl;
if pynq('Are you absolutely totally incredibly surely sure???!!? ') then begin
nl;
print('You have selected a very powerful command.');
print('Pause a few moments and reflect upon exactly what you are doing.');
nl;
delay(2000);
nl;
if pynq('Now, then... do you REALLY want to do this? ') then begin
nl;
print('OK! Don''t tell me I didn''t warn you!');
nl;
prompt('Deleting all your e-mail.... ');
i:=0; j:=0;
while (i<=himsg) do begin
ensureloaded(i);
if ((mintab[getmixnum(i)].messagenum=usernum) and
(miexist in mintab[getmixnum(i)].msgindexstat)) then begin
inc(j);
s1:=cstr(j)+' of '+cstr(mw);
prompt(s1); for k:=1 to length(s1) do prompt(^H);
delmail(i);
end;
inc(i);
end;
nl; nl; print('Done!');
thisuser.waiting:=0;
getout; exit;
end;
end;
end;
end;
end;
if ((i>=1) and (i<=mw)) then snum:=i;
if ((s='') or (i=0)) then snum:=1;
if (copy(s,1,1)='Q') then abort:=TRUE;
done:=((abort) or (snum<>0));
until ((done) or (hangup));
if (abort) then begin getout; exit; end;
end;
bakw:=FALSE; done:=FALSE; dotitles:=FALSE;
holdit:=FALSE; justdel:=FALSE; noreshow:=FALSE;
crec:=-1; mnum:=0;
repeat
if (not holdit) then
repeat
findit;
if (crec=-1) then begin done1:=TRUE; dotitles:=TRUE; end;
until (done1);
justdel:=FALSE;
if (mnum=snum) then snum:=0;
if ((snum=0) and (crec>=0)) then begin
next:=FALSE;
if (not noreshow) then begin
if (thisuser.clsmsg=1) then cls;
readmsg(2,crec,mnum,mw,abort,next);
end else
noreshow:=FALSE;
if (not next) then begin
prt('Read mail : ');
cmds:='Q?-ADFGIRSTN'^N;
if (cso) then cmds:=cmds+'EUVX';
if (mso) then cmds:=cmds+'Z';
onek(c,cmds);
end else
c:='I';
abort:=FALSE; bakw:=FALSE; holdit:=TRUE; next:=FALSE;
case c of
'-':begin bakw:=TRUE; holdit:=FALSE; end;
'E':if (cso) then begin
thisuser.waiting:=mw;
if (lastname<>'') then uedit(extractusernum(lastname));
holdit:=FALSE; i:=mnum; crec:=-1; mnum:=0; snum:=i;
mw:=thisuser.waiting;
end;
'F':begin
nl;
prt('Forward letter to which user? '); finduserws(i);
if (i<1) then print('Unknown user.')
else
if (i<>usernum) then begin
reset(uf); seek(uf,i); read(uf,u);
j:=0; b:=TRUE;
while ((j<4) and (b)) do begin
inc(j); b:=moremail(u,i,j);
if (not b) then
case j of
1:print('Mailbox is full.');
2:print('Mailbox is closed.');
3:if (mso) then print('That user is deleted.')
else print('Can''t send mail to that user.');
4:print('Can''t send mail to yourself!');
end;
end;
close(uf);
if (b) then begin
mixr:=mintab[getmixnum(crec)]; mixr.messagenum:=i;
savemix(mixr,crec);
dec(thisuser.waiting);
reset(uf);
seek(uf,i); read(uf,u); inc(u.waiting);
seek(uf,i); write(uf,u);
close(uf);
sysoplog('Forwarded letter to '+caps(u.name)+' #'+cstr(i));
dec(mw); crec:=-1;
snum:=mnum; mnum:=0; if (snum>mw) then dec(snum);
holdit:=FALSE;
end;
end;
end;
'G':begin
prt('Goto message? (1-'+cstr(mw)+') : '); inu(i);
if ((not badini) and (i>=1) and (i<=mw)) then
begin holdit:=FALSE; crec:=-1; mnum:=0; snum:=i; end;
end;
'I','N',^N:holdit:=FALSE;
'Q':begin getout; exit; end;
'R':;
'T':dotitles:=TRUE;
'U':if (cso) then
if (lastname<>'') then begin
noreshow:=TRUE;
nl;
i:=extractusernum(lastname);
if (i<>0) then begin
reset(uf);
errs:=((i<1) or (i>filesize(uf)-1));
if (not errs) then begin
{$I-} seek(uf,i); read(uf,u); {$I+}
errs:=(ioresult<>0);
end;
if (errs) then
sprint(#3#7+'Unable to find "'+lastname+'" !')
else
showuserinfo(1,i,u);
nl;
close(uf);
end;
end;
'V':if (cso) then
if (lastname<>'') then begin
noreshow:=TRUE;
nl;
i:=extractusernum(lastname);
if (i<>0) then begin
reset(uf);
errs:=((i<1) or (i>filesize(uf)-1));
if (not errs) then begin
{$I-} seek(uf,i); read(uf,u); {$I+}
errs:=(ioresult<>0);
end;
close(uf);
if (errs) then
sprint(#3#7+'Unable to find "'+lastname+'" !')
else begin
autoval(u,i);
reset(uf);
{$I-} seek(uf,i); write(uf,u); {$I+}
close(uf);
sysoplog('Validated '+caps(u.name)+' #'+cstr(i));
ssm(abs(mheader.fromi.usernum),^G+'You were validated on '+date+' '+time+'.'^G);
nl;
end;
end;
end;
'X':if (mso) then begin
nl;
prt('Extract filename? (default="EXT.TXT") : ');
input(s,40);
if (s='') then s:='EXT.TXT';
if pynq('Are you sure? ') then begin
b:=pynq('Strip color codes from output? ');
loadmhead(crec,mheader);
assign(t,s);
{$I-} append(t); {$I+}
if (ioresult<>0) then rewrite(t);
totload:=0;
repeat
blockreadstr2(brdf,s);
inc(totload,length(s)+2);
if ((b) and (pos(#3,s)<>0)) then s:=stripcolor(s);
writeln(t,s);
until (totload>=mheader.msglength);
close(t);
nl;
print('Done!');
end;
end;
'A','S',
'D','Z':begin
b:=TRUE;
if (c in ['A','S']) then begin
reset(uf);
loadmhead(crec,mheader);
i:=mheader.fromi.usernum;
if ((i>=1) and (i<=filesize(uf)-1)) then begin
seek(uf,i); read(uf,u);
end;
j:=0; b:=TRUE;
while ((j<4) and (b)) do begin
inc(j); b:=moremail(u,i,j);
if (not b) then
case j of
1:print('That user''s mailbox is full.');
2:print('That user''s mailbox is closed.');
3:if (mso) then print('That user is deleted.')
else print('Can''t send mail to that user.');
4:print('Can''t send mail to yourself!');
end;
end;
close(uf);
end;
if (b) then begin
if ((c='Z') and (not mso)) then c:='D';
case c of
'D':ssm(abs(mheader.fromi.usernum),
nam+' read your letter on '+date+' '+time+'.');
'A','S':ssm(abs(mheader.fromi.usernum),
nam+' replied to your letter on '+date+' '+time+'.');
end;
if (c<>'S') then begin
s:=rmail(crec);
dec(mw); crec:=-1;
snum:=mnum; mnum:=0; if (snum>mw) then dec(snum);
holdit:=FALSE;
end;
end;
end;
'?':begin
nl;
lcmds(19,3,'Title listing','');
lcmds(19,3,'Ignore letter','-Previous letter');
lcmds(19,3,'Goto letter','Forward letter to other user');
lcmds(19,3,'Delete letter','Auto-reply to author');
lcmds(19,3,'Re-read letter','Store and reply (save original)');
if (cso) then
lcmds(19,5,'User info/author','Edit author''s account');
if (cso) then
lcmds(19,5,'Validate author','Zap (delete w/o receipt)')
else
if (mso) then
lcmds(19,5,'Zap letter','');
if (mso) then
lcmds(50,5,'Xtract msg to file','');
lcmds(19,9,'Quit Mail','');
nl;
noreshow:=TRUE;
end;
end;
if (c in ['A','S']) then begin
i:=thisuser.waiting;
autoreply; inc(mw,thisuser.waiting-i);
end;
end;
if ((mw=0) or ((crec=-1) and (snum=0))) then done:=TRUE;
until ((done) or (dotitles) or (hangup));
if (done) then begin getout; exit; end;
until (hellfreezesover);
getout; { just in case hell freezes over! <grin> }
end;
end.