Adds the per-user High-Water Mark API to TMessageBase:
function SupportsHWM: boolean;
function GetHWM(const UserName: AnsiString): longint;
procedure SetHWM(const UserName: AnsiString; MsgNum: longint);
procedure MapUser(const UserName: AnsiString; UserId: longint);
property ActiveUser: AnsiString;
GetHWM returns -1 when the format has no HWM mechanism, the user
isn't registered (number-keyed formats), or no HWM has been set
for that user yet.
Two-flavour native dispatch:
- Name-keyed backends (JAM, later Squish/Wildcat) override
DoGetHWMByName / DoSetHWMByName.
- Number-keyed backends (later Hudson/GoldBase/EzyCom) override
DoGetHWMById / DoSetHWMById; caller must register name->id via
MapUser first.
Auto-bump: when ActiveUser is non-empty, ReadMessage compares the
just-read msg.num to GetHWM(ActiveUser); if higher, calls SetHWM.
Never decrements -- reading a lower-numbered message is a no-op.
Default off (ActiveUser = '').
JAM implementation:
- Adds .JLR (lastread) handling to TJamBase: lazy open via
EnsureLrStream, GetLastRead/GetHighRead/SetLastRead methods,
proper Close cleanup.
- TJamMessageBase wires DoGetHWMByName / DoSetHWMByName to
CalcUserCRC + GetLastRead / SetLastRead. SetHWM also keeps
HighReadMsg monotonic.
Coverage map (this milestone):
- JAM: native ✓
- Squish, Hudson, GoldBase, EzyCom, Wildcat: -1 (planned 0.3.1/2)
- PCBoard, MSG, PKT: -1 (no HWM in spec)
Tests: tests/test_hwm.pas covers SupportsHWM, set/get round-trip,
persistence across Open/Close, auto-bump via ActiveUser (advances),
auto-bump never decrements, MSG/PKT correctly return -1, Hudson
returns -1 even after MapUser (until 0.3.1 lands the impl). 7/7
new tests pass; full suite 38/38 across 9 programs.
Recommended caller pattern:
base.ActiveUser := 'NetReader';
for i := 0 to base.MessageCount - 1 do begin
base.ReadMessage(i, msg);
{ process msg ... HWM auto-tracks the high-water for NetReader }
end;
fpc-msgbase
A unified Free Pascal library for reading and writing classic BBS message bases.
Implements every supported format from the FTSC specifications and the original
format authors' published documentation, behind one polymorphic API
(TMessageBase). BBS software, mail tossers, message editors, and utilities
can target a single interface regardless of the underlying format on disk.
Supported formats
| Format | Files | Backend unit |
|---|---|---|
| Hudson | MSGINFO/IDX/HDR/TXT/TOIDX.BBS | ma.fmt.hudson.pas |
| JAM | *.JHR *.JDT *.JDX *.JLR |
ma.fmt.jam.pas |
| Squish | *.SQD *.SQI *.SQL |
ma.fmt.squish.pas |
| FTS-1 MSG | numbered *.MSG per directory |
ma.fmt.msg.pas |
| FTN PKT | *.pkt (Type-2 / 2+ / 2.2) |
ma.fmt.pkt.pas |
| PCBoard | *.MSG + *.IDX |
ma.fmt.pcboard.pas |
| EzyCom | MH#####.BBS / MT#####.BBS |
ma.fmt.ezycom.pas |
| GoldBase | MSGINFO/IDX/HDR/TXT/TOIDX.DAT | ma.fmt.goldbase.pas |
| Wildcat 4 | WC SDK databases | ma.fmt.wildcat.pas |
Features
- One
TMessageBaseabstract class — read, write, pack, reindex through the same methods regardless of format. - Lossless two-area message model.
TUniMessage=Body(just the message text) +Attributes(key/value bag holding from/to/subject/dates/ addresses/MSGID/SEEN-BY/PATH and per-format extras). Same shape as RFC 822 email. Round-trip preservation enforced by the test suite. - Capabilities API —
base.SupportsAttribute('attr.returnreceipt')lets UIs hide controls the underlying backend has no slot for. Each backend publishes its key list viaClassSupportedAttributes. Full per-format matrix indocs/attributes-registry.md. - Layered locking: in-process
TRTLCriticalSection+ cross-process advisory lock (fpflockon Unix,LockFileExon Windows,.LCKsentinel fallback)- the existing
fmShareDenyWrite/fmShareDenyNoneshare modes.
- the existing
- Event hooks for logging, progress, and status reporting.
TPacketBatchworker pool for tossers that need to process many.pktfiles concurrently while serialising writes per destination base.- Path / filename auto-derivation per format from a base directory plus optional area tag.
Building
Native Linux:
fpc -Fusrc -Fusrc/formats examples/example_read.pas
Lazarus package:
lazbuild fpc-msgbase.lpk
The repo includes a fpc.cfg template covering the multi-target build
(i386-go32v2, i386-win32, i386-linux, i386-os2).
Layout
src/ ma.api, ma.types, ma.events, ma.lock, ma.paths, ma.batch
src/formats/ ma.fmt.<format>.pas — one per supported format
docs/ architecture, locking semantics, format notes
tests/ FPCUnit tests, sample data
examples/ small CLI programs that double as smoke tests
Unit-name convention follows the Fimail style: ma.<category>.<name>.pas
(ma. is the library's namespace prefix; the project was originally named
message_api, hence ma). All units use {$mode objfpc}{$H+}.
Documentation
docs/API.md— full API reference with examplesdocs/architecture.md— layered design + Body/Attributes contractdocs/attributes-registry.md— canonical attribute keys + per-format support matrixdocs/ftsc-compliance.md— spec notesdocs/format-notes/— per-format quirks
Status
Early development. APIs may move until 1.0.
0.2 is a breaking change vs 0.1. TUniMessage lost its 13 named
fields (WhoFrom/WhoTo/Subject/MsgNum/Attr/etc.) in favour of a strict
Body + Attributes two-area model. Migration:
{ before } { after }
msg.WhoFrom msg.Attributes.Get('from')
msg.Subject := 'foo'; msg.Attributes.SetValue('subject', 'foo');
msg.Attr := MSG_ATTR_LOCAL; msg.Attributes.SetBool('attr.local', true);
msg.OrigAddr msg.Attributes.GetAddr('addr.orig')
msg.DateWritten msg.Attributes.GetDate('date.written')
This change makes the unified API lossless — kludges (MSGID, SEEN-BY,
PATH, etc.) round-trip cleanly, where 0.1 silently dropped them. See
docs/attributes-registry.md for the
full key catalog.
Format backends are spec-driven implementations validated against real-world sample bases.