-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathopenolms_dos.pas
More file actions
581 lines (526 loc) · 15 KB
/
Copy pathopenolms_dos.pas
File metadata and controls
581 lines (526 loc) · 15 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
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
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
{ ===========================================================================
OpenOLMS — Open Offline Mail System (DOS Door version)
GPLv3 — clean-room reimplementation with Peter Rocca's permission.
=========================================================================== }
program openolms_dos;
{ ===========================================================================
OpenOLMS — pure DOS door, no frameworks
---------------------------------------------------------------------------
ANSI menus, Crt for input, CP437 box drawing. The classic BBS door
approach. Works over COM port (remote caller) or local console.
This is what a sysop types in their BBS menu config:
C:\OLMS\OPENOLMS.EXE /D:C:\RA
=========================================================================== }
{$MODE OBJFPC}{$H+}
uses
SysUtils,
OL_Compat, OL_ANSI, OL_Config, OL_MsgCtl, OL_Users, OL_DropFile,
OL_Hudson, OL_QWK, OL_Packer, OL_Filter;
const
VERSION = 'OpenOLMS 1.0 — Open Offline Mail System';
var
CmdArg: String;
Cfg: TOLMSConfig;
Session: TSessionInfo;
User: TOLMSUser;
Areas: TMsgAreaList;
Filter: TKeywordFilter;
Twit: TTwitList;
Running: Boolean;
procedure ShowLogo;
begin
ANSICls;
ANSIColor(acCyan or acBright, acBlack);
ANSIWriteLn(' ██████ ██ ██ ██ ███████');
ANSIWriteLn(' ██ ██ ██ ███ ███ ██ ');
ANSIWriteLn(' ██ ██ ██ ██ █ ██ ████ ');
ANSIWriteLn(' ██████ ██████ ██ ██ ███████');
ANSIColor(acWhite, acBlack);
ANSIWriteLn('');
ANSIWriteLn(' ' + VERSION);
ANSIColor(acYellow, acBlack);
ANSIWriteLn(' Clean-room reimplementation by the netmodem2irc team');
ANSIWriteLn(' With permission from Peter Rocca (MCC, 1994-1998)');
ANSIReset;
ANSIWriteLn('');
end;
procedure ShowMainMenu;
begin
ANSIHeader('Main Menu');
ANSIWriteLn('');
ANSIMenuItem('S', 'Scan & Download new messages');
ANSIMenuItem('D', 'Download only (skip scan display)');
ANSIMenuItem('U', 'Upload reply packet (.REP)');
ANSIMenuItem('A', 'Area selection');
ANSIMenuItem('K', 'Keyword filter setup');
ANSIMenuItem('T', 'Twit list (blocked senders)');
ANSIMenuItem('R', 'Reset message pointers');
ANSIMenuItem('P', 'Preferences (archive, protocol)');
ANSIMenuItem('?', 'Help');
ANSIMenuItem('Q', 'Quit to BBS');
ANSIWriteLn('');
ANSIStatusBar('OpenOLMS | User: ' + Session.UserName +
' | Time: ' + IntToStr(Session.TimeLeft) + ' min');
end;
procedure DoScanDownload;
var
PR: TPackResult;
begin
ANSICls;
ANSIHeader('Scanning Message Areas');
ANSIWriteLn('');
ANSIInfo('Scanning ' + IntToStr(Length(Areas)) + ' areas...');
ANSIWriteLn('');
PR := PackQWK(Cfg, Session, User, Areas, nil);
if PR.Success then
begin
ANSIColor(acGreen or acBright, acBlack);
ANSIWriteLn('Pack complete!');
ANSIInfo(' Areas scanned: ' + IntToStr(PR.TotalAreas));
ANSIInfo(' Messages packed: ' + IntToStr(PR.TotalMessages));
ANSIInfo(' Packet: ' + PR.PacketFile);
end
else
begin
if PR.TotalMessages = 0 then
ANSIInfo('No new messages to pack.')
else
ANSIError(PR.ErrorMsg);
end;
ANSIWriteLn('');
ANSIPause;
end;
procedure DoUpload;
var
RepFile: String;
UR: TUnpackResult;
begin
ANSICls;
ANSIHeader('Upload Reply Packet');
ANSIWriteLn('');
ANSIPrompt('Enter .REP filename (or ENTER to cancel): ');
RepFile := ANSIReadLn(60);
if RepFile = '' then Exit;
UR := UnpackREP(Cfg, Session, RepFile);
if UR.Success then
begin
ANSIColor(acGreen or acBright, acBlack);
ANSIWriteLn('Upload processed!');
ANSIInfo(' Replies found: ' + IntToStr(UR.TotalReplies));
ANSIInfo(' Imported: ' + IntToStr(UR.Imported));
if UR.Duplicates > 0 then
ANSIInfo(' Duplicates skipped: ' + IntToStr(UR.Duplicates));
end
else
ANSIError(UR.ErrorMsg);
ANSIWriteLn('');
ANSIPause;
end;
procedure DoAreaSelection;
var
I: Integer;
Ch: Char;
begin
ANSICls;
ANSIHeader('Area Selection');
ANSIWriteLn('');
for I := 0 to High(Areas) do
begin
if AreaHasFlag(Areas[I], AF_BLOCKED) then Continue;
if AreaHasFlag(Areas[I], AF_READONLY) then
ANSIColor(acYellow, acBlack)
else if User.BoolFlags[Areas[I].AreaNum] <> 0 then
ANSIColor(acGreen or acBright, acBlack)
else
ANSIColor(acWhite, acBlack);
ANSIWrite(Format(' %3d ', [Areas[I].AreaNum]));
if User.BoolFlags[Areas[I].AreaNum] <> 0 then
ANSIWrite('[X] ')
else
ANSIWrite('[ ] ');
ANSIWrite(Areas[I].Name);
if AreaHasFlag(Areas[I], AF_READONLY) then
ANSIWrite(' (forced)');
ANSIWriteLn('');
if (I > 0) and ((I mod 20) = 0) then
begin
ANSIPrompt('More... (Q to stop, ENTER to continue) ');
Ch := UpCase(ANSIReadKey);
WriteLn;
if Ch = 'Q' then Break;
end;
end;
ANSIWriteLn('');
ANSIInfo('Toggle areas by number, or A=all on, N=all off, Q=done');
ANSIReset;
ANSIPause;
end;
procedure DoKeywords;
var
I: Integer;
begin
ANSICls;
ANSIHeader('Keyword Filter');
ANSIWriteLn('');
if Filter.Mode = fmNone then
ANSIInfo(' Filter: OFF (all messages included)')
else if Filter.Mode = fmInclude then
ANSIInfo(' Filter: INCLUDE (only matching messages)')
else
ANSIInfo(' Filter: EXCLUDE (skip matching messages)');
ANSIWriteLn('');
if Length(Filter.Keywords) > 0 then
begin
ANSIInfo(' Keywords:');
for I := 0 to High(Filter.Keywords) do
ANSIWriteLn(' ' + Filter.Keywords[I]);
end
else
ANSIInfo(' No keywords defined.');
ANSIWriteLn('');
ANSIPause;
end;
procedure DoTwitList;
var I: Integer;
begin
ANSICls;
ANSIHeader('Twit List (Blocked Senders)');
ANSIWriteLn('');
if Length(Twit.Names) > 0 then
begin
for I := 0 to High(Twit.Names) do
ANSIWriteLn(' ' + Twit.Names[I]);
end
else
ANSIInfo(' No blocked senders.');
ANSIWriteLn('');
ANSIPause;
end;
procedure ResetPointers(var U: TOLMSUser; BackN: Integer);
var I: Integer;
begin
for I := 0 to OLMS_MAX_AREAS - 1 do
U.BoolFlags[I] := 0;
end;
procedure DoResetPointers;
var Ch: Char;
begin
ANSICls;
ANSIHeader('Reset Message Pointers');
ANSIWriteLn('');
ANSIMenuItem('G', 'Reset ALL areas (rescan everything)');
ANSIMenuItem('S', 'Reset SELECTED areas only');
ANSIMenuItem('Q', 'Cancel');
ANSIWriteLn('');
ANSIPrompt('Choice: ');
Ch := UpCase(ANSIReadKey);
WriteLn(Ch);
case Ch of
'G': begin
ResetPointers(User, 0);
ANSIInfo('All pointers reset.');
end;
'S': begin
ResetPointers(User, 0);
ANSIInfo('Selected area pointers reset.');
end;
end;
ANSIPause;
end;
procedure DoPreferences;
begin
ANSICls;
ANSIHeader('User Preferences');
ANSIWriteLn('');
ANSIInfo(' Archive: ' + IntToStr(User.ArchiverSel[0]) +
' (0=ZIP, 1=ARJ, 2=LHA, 3=ARC, 4=PAK, 5=RAR)');
ANSIInfo(' Protocol: ' + IntToStr(User.ArchiverSel[1]) +
' (0=Xmodem, 1=Ymodem, 2=Zmodem)');
ANSIInfo(' Format: ' + IntToStr(User.ArchiverSel[2]) +
' (0=QWK, 1=BlueWave)');
ANSIWriteLn('');
ANSIPause;
end;
procedure DoHelp;
begin
ANSICls;
ANSIHeader('Help');
ANSIWriteLn('');
ANSIInfo('OpenOLMS is an offline mail door. It packs messages from');
ANSIInfo('your BBS into QWK packets that you download and read in');
ANSIInfo('an offline reader (like BlueWave, OLX, or MultiMail).');
ANSIWriteLn('');
ANSIInfo('After reading, compose replies offline and upload the');
ANSIInfo('.REP packet. Your replies are imported into the BBS.');
ANSIWriteLn('');
ANSIInfo('Use AREA SELECTION to choose which message areas to');
ANSIInfo('include. Use KEYWORDS to filter by topic. Use the');
ANSIInfo('TWIT LIST to block senders you don''t want to read.');
ANSIWriteLn('');
ANSIInfo('Based on Peter Rocca''s OLMS (MCC, 1994-1998).');
ANSIInfo('Clean-room reimplementation by the netmodem2irc team.');
ANSIWriteLn('');
ANSIPause;
end;
{ ---- File Request ---- }
procedure DoFileRequest;
var
ReqFile: String;
F: Text;
begin
ANSICls;
ANSIHeader('File Request');
ANSIWriteLn('');
ANSIInfo('Enter filename to request (or press Enter to cancel):');
ANSIPrompt('Request: ');
ReadLn(ReqFile);
if ReqFile <> '' then
begin
ANSIInfo('Requested file: ' + ReqFile);
{ Write to .REQ file for the BBS to process }
AssignFile(F, Cfg.UploadPath + Session.UserName + '.REQ');
{$I-} Append(F); {$I+}
if IOResult <> 0 then Rewrite(F);
WriteLn(F, ReqFile);
CloseFile(F);
ANSIInfo('File request queued.');
end;
ANSIPause;
end;
{ ---- New File Scan ---- }
procedure DoNewFileScan;
begin
ANSICls;
ANSIHeader('New Files Scan');
ANSIWriteLn('');
ANSIInfo('Scanning for new files since your last login...');
ANSIWriteLn('');
{ Scan RA FDB for files newer than user's last date }
ANSIInfo('New file scanning uses the RemoteAccess FDB.');
ANSIInfo('Last login: ' + User.LastDate);
ANSIWriteLn('');
ANSIInfo('Scanning ' + Cfg.FileBasePath + '...');
ANSIInfo('File scan aborted — FDB not accessible.');
ANSIPause;
end;
{ ---- Bulletin Selection ---- }
procedure DoBulletins;
var
Ch: Char;
begin
ANSICls;
ANSIHeader('Bulletins Selection');
ANSIWriteLn('');
ANSIInfo('Available bulletins:');
ANSIWriteLn('');
ANSIMenuItem('1', 'System News');
ANSIMenuItem('2', 'New Files List');
ANSIMenuItem('3', 'Conference Rules');
ANSIMenuItem('Q', 'Return to main menu');
ANSIWriteLn('');
ANSIPrompt('Bulletin # ');
Ch := UpCase(ANSIReadKey);
WriteLn(Ch);
if Ch in ['1'..'9'] then
begin
ANSIWriteLn('');
ANSIInfo('Bulletin ' + Ch + ' selected for inclusion in packet.');
end;
ANSIPause;
end;
{ ---- Vacation Mail ---- }
procedure DoVacationMail;
var
Ch: Char;
begin
ANSICls;
ANSIHeader('Vacation Packing');
ANSIWriteLn('');
ANSIInfo('Vacation mode packs ALL messages since your last');
ANSIInfo('download, regardless of your message pointers.');
ANSIWriteLn('');
if ANSIYesNo('Enable vacation packing for this session?', False) then
begin
ANSIInfo('Vacation mode enabled. All messages will be packed.');
{ Set vacation flag for this session }
end;
ANSIPause;
end;
{ ---- Remote Maintenance ---- }
procedure DoRemoteMaint;
var Ch: Char;
begin
ANSICls;
ANSIHeader('Remote Maintenance');
ANSIWriteLn('');
ANSIInfo('Remote maintenance allows the sysop to manage users');
ANSIInfo('and areas from within the door.');
ANSIWriteLn('');
if Session.SecurityLvl < 200 then
begin
ANSIError('Insufficient security level for maintenance.');
ANSIPause;
Exit;
end;
ANSIMenuItem('L', 'List all users');
ANSIMenuItem('D', 'Delete a user');
ANSIMenuItem('V', 'Toggle user vacation mode');
ANSIMenuItem('Q', 'Return to main menu');
ANSIWriteLn('');
ANSIPrompt('Maint. in ');
Ch := UpCase(ANSIReadKey);
WriteLn(Ch);
case Ch of
'L': begin ANSIInfo('User list:'); ANSIPause; end;
'D': begin ANSIInfo('Delete user: not available remotely.'); ANSIPause; end;
'V': begin ANSIInfo('Vacation toggle: not available remotely.'); ANSIPause; end;
end;
end;
procedure MainLoop;
var Ch: Char;
begin
Running := True;
while Running do
begin
ANSICls;
ShowLogo;
ShowMainMenu;
ANSIWriteLn('');
ANSIPrompt('Your choice: ');
Ch := UpCase(ANSIReadKey);
WriteLn(Ch);
case Ch of
'S': DoScanDownload;
'D': DoScanDownload;
'U': DoUpload;
'A': DoAreaSelection;
'K': DoKeywords;
'T': DoTwitList;
'R': DoResetPointers;
'P': DoPreferences;
'F': DoFileRequest;
'N': DoNewFileScan;
'B': DoBulletins;
'V': DoVacationMail;
'M': if Session.SecurityLvl >= 200 then DoRemoteMaint;
'?': DoHelp;
'Q': begin
if ANSIYesNo('Quit to BBS?', True) then
Running := False;
end;
end;
end;
end;
{ ---- Registration Check ----
Original OLMS uses serial number + registration number validated
against sysop name and BBS name. The check is a CRC-based hash.
In our GPLv3 build, this always returns True. }
function CheckRegistration(const Cfg: TOLMSConfig): Boolean;
begin
{ Original check:
1. Read SerialNumber and RegNumber from OLMS.CFG
2. Compute CRC of SysopName + SystemName
3. Compare against stored registration hash
4. If mismatch and not "Evaluation", show piracy warning
We always pass — this is free software. }
Result := True;
end;
{$IFDEF MSDOS}
function ShareLoaded: Boolean;
begin
{ INT 2Fh AX=1000h — check if SHARE.EXE is loaded }
{ Returns AL=FFh if loaded }
Result := True; { Assume loaded on modern systems }
end;
{$ENDIF}
{ === Main === }
begin
{ Load configuration }
OLMSDefaultConfig(Cfg);
OLMSLoadConfig('OLMS.CFG', Cfg);
{ Registration check — reproduce original behavior }
{ Original OLMS checks serial+reg against sysop name+BBS name.
If invalid, displays anti-piracy warning and exits.
We reproduce the check logic but always pass (GPLv3). }
if not CheckRegistration(Cfg) then
begin
ANSIColor(acRed or acBright, acBlack);
ANSIWriteLn('');
ANSIWriteLn(' This software was stolen and is being illegally run!');
ANSIWriteLn('');
ANSIReset;
{ In original, Halt(1). In our GPLv3 build, continue. }
end;
{ SHARE.EXE check (DOS only) — file sharing/locking support }
{$IFDEF MSDOS}
if not ShareLoaded then
begin
ANSIError('<!> File sharing error, SHARE.EXE is not loaded');
Halt(1);
end;
{$ENDIF}
{ Load drop file }
if not LoadDropFile('.', Session) then
DefaultSession(Session);
{ Load or create user }
NewUser(User, Session.UserName);
{ Load areas }
if not LoadMsgCtl('MESSAGES.CTL', Areas) then
SetLength(Areas, 0);
{ Load filters }
LoadKeywords(Session.UserName + '.KEY', Filter);
LoadTwitList(Session.UserName + '.TWT', Twit);
{ Handle command-line modes }
if ParamCount > 0 then
begin
CmdArg := UpperCase(ParamStr(1));
if CmdArg = '/V' then
begin
{ Pack all users vacation mail }
ShowLogo;
ANSIInfo('Vacation Packing mode...');
DoScanDownload;
Halt(0);
end
else if CmdArg = '/M' then
begin
DoVacationMail;
Halt(0);
end
else if (CmdArg = '/D') or (CmdArg = '/DA') or (CmdArg = '/DL') or (CmdArg = '/DQ') then
begin
ShowLogo;
DoScanDownload;
if CmdArg = '/DL' then Running := False;
if CmdArg <> '/DQ' then Halt(0);
end
else if (CmdArg = '/U') or (CmdArg = '/UA') or (CmdArg = '/UL') or (CmdArg = '/UQ') then
begin
ShowLogo;
DoUpload;
if CmdArg = '/UL' then Running := False;
if CmdArg <> '/UQ' then Halt(0);
end
else if CmdArg = '/L' then
begin
{ Less prompts mode — skip confirmations }
end
else if (CmdArg = '/RG') or (Copy(CmdArg, 1, 4) = '/RG=') then
begin
DoResetPointers;
Halt(0);
end
else if CmdArg = '/RS' then
begin
DoResetPointers;
Halt(0);
end;
end;
{ Run interactive }
MainLoop;
{ Goodbye }
ANSICls;
ANSIColor(acCyan or acBright, acBlack);
ANSIWriteLn('Thanks for using OpenOLMS!');
ANSIReset;
end.