Removes all PKT code from fpc-msgbase. The wire format and its
container concerns now live in the sibling fpc-ftn-transport
library (units tt.pkt.format, tt.pkt.reader, tt.pkt.writer,
tt.pkt.batch). Pair this commit with fpc-ftn-transport's
0.2.0 (commit 6bb71a6).
Why: the previous "reader here, writer there" split (briefly
landed in 0.3.5) baked in a coupling that didn't survive a
fresh look. The writer reached into fpc-msgbase for types,
the wire format lived in the wrong house, and consumers reading
fpc-msgbase saw "PKT support" that was actually only half-
support. Cleanest split: PKT is a wire format, both directions
belong with the wire-format-aware library; fpc-msgbase becomes
purely real message bases (Hudson / JAM / Squish / MSG /
PCBoard / EzyCom / GoldBase / Wildcat).
Also a cleaner separation-of-concerns story: a BBS that just
reads JAM/Squish never needs fpc-ftn-transport. A pure store-
and-forward node doing only ArcMail unbundle never depends on
storage formats. Each library = one concern.
Removed:
src/formats/ma.fmt.pkt.pas -> tt.pkt.format
src/formats/ma.fmt.pkt.uni.pas -> tt.pkt.reader
(TPktMessageBase -> TPktReader)
src/ma.batch.pas -> tt.pkt.batch
(TPacketBatch class name unchanged)
tests/test_batch.pas -> tests/test_pkt_writer.pas
(consolidated PKT tests)
examples/example_tosser.pas -> moves with the batch helper
Reduced in src/ma.types.pas:
- PacketRecord
- FlavourType / FlavourTypeSet / DateTimeArray
- FlagsToFido / FidoToFlags
- VersionNum (PKT-product-code stamping)
All moved to tt.pkt.format.
Kept in src/ma.types.pas:
- mbfPkt enum value (so tt.pkt.reader can register the backend
with the unified-API factory; consumers still use the
standard MessageBaseOpen(mbfPkt, ...) shape)
Migration for vendoring consumers:
before: after:
uses ma.fmt.pkt; uses tt.pkt.format;
uses ma.fmt.pkt.uni; uses tt.pkt.reader;
uses ma.batch; uses tt.pkt.batch;
(no writer surface) uses tt.pkt.writer;
TPktMessageBase TPktReader
TPktFile, TPktMessage, (unchanged class names)
TPktHeaderInfo, etc.
TPacketBatch (unchanged)
Docs sweep:
- README: PKT row called out as "moved to fpc-ftn-transport";
TPacketBatch removed from features.
- docs/architecture.md: layer diagram drops PKT + ma.batch;
new sibling-library box added for fpc-ftn-transport.
- docs/attributes-registry.md: PKT column dropped from per-
format support matrix; pointer to fpc-ftn-transport.
- docs/API.md: PKT cheat-sheet entry redirects to
fpc-ftn-transport; TPacketBatch section reduced to a
"moved" pointer with the new uses-clause shape.
- docs/ftsc-compliance.md: Type-2 / 2+ / 2.2 / AuxNet rows
annotated as living in tt.pkt.format.
Suite: 47/47 across 9 programs (was 9 with test_batch; now 9
with the PKT bits dropped from test_consumer_round1 and
test_hwm). All other tests untouched.
105 lines
2.7 KiB
ObjectPascal
105 lines
2.7 KiB
ObjectPascal
{
|
|
example_write.pas - post one test message to any supported base
|
|
via the unified API.
|
|
|
|
usage: example_write <format> <path> <from> <to> <subject> <body>
|
|
|
|
Example:
|
|
example_write jam /tmp/testarea Sysop All Hello 'Hello, world'
|
|
|
|
For Hudson/GoldBase/MSG the path is a directory; for JAM/Squish
|
|
it is <dir>/<areaname> (no extension); for PKT it is the full
|
|
*.pkt filename; for EzyCom it is the base directory and board 1
|
|
is used by default.
|
|
}
|
|
|
|
program example_write;
|
|
|
|
{$mode objfpc}{$H+}
|
|
|
|
uses
|
|
SysUtils,
|
|
ma.types, ma.events, ma.api,
|
|
ma.fmt.hudson, ma.fmt.hudson.uni,
|
|
ma.fmt.jam, ma.fmt.jam.uni,
|
|
ma.fmt.squish, ma.fmt.squish.uni,
|
|
ma.fmt.msg, ma.fmt.msg.uni,
|
|
ma.fmt.pcboard, ma.fmt.pcboard.uni,
|
|
ma.fmt.ezycom, ma.fmt.ezycom.uni,
|
|
ma.fmt.goldbase, ma.fmt.goldbase.uni;
|
|
|
|
function ParseFormat(const S: string; out AFormat: TMsgBaseFormat): boolean;
|
|
begin
|
|
Result := True;
|
|
case LowerCase(S) of
|
|
'hudson': AFormat := mbfHudson;
|
|
'jam': AFormat := mbfJam;
|
|
'squish': AFormat := mbfSquish;
|
|
'msg': AFormat := mbfMsg;
|
|
'pcboard': AFormat := mbfPCBoard;
|
|
'ezycom': AFormat := mbfEzyCom;
|
|
'goldbase': AFormat := mbfGoldBase;
|
|
else
|
|
Result := False;
|
|
end;
|
|
end;
|
|
|
|
procedure Usage;
|
|
begin
|
|
WriteLn('Usage: example_write <format> <path> <from> <to> <subject> <body>');
|
|
WriteLn(' formats: hudson jam squish msg pcboard ezycom goldbase');
|
|
Halt(2);
|
|
end;
|
|
|
|
var
|
|
fmtName, path, whoFrom, whoTo, subject, body: string;
|
|
fmt: TMsgBaseFormat;
|
|
base: TMessageBase;
|
|
msg: TUniMessage;
|
|
begin
|
|
if ParamCount < 6 then Usage;
|
|
fmtName := ParamStr(1);
|
|
path := ParamStr(2);
|
|
whoFrom := ParamStr(3);
|
|
whoTo := ParamStr(4);
|
|
subject := ParamStr(5);
|
|
body := ParamStr(6);
|
|
|
|
if not ParseFormat(fmtName, fmt) then Usage;
|
|
|
|
try
|
|
base := MessageBaseOpen(fmt, path, momReadWrite);
|
|
except
|
|
on E: Exception do begin
|
|
WriteLn('error: ', E.Message);
|
|
Halt(1);
|
|
end;
|
|
end;
|
|
|
|
if not base.Open then begin
|
|
WriteLn('error: Open returned False (missing files? lock busy?)');
|
|
base.Free;
|
|
Halt(1);
|
|
end;
|
|
|
|
msg.Attributes.Clear;
|
|
msg.Attributes.SetValue('from', whoFrom);
|
|
msg.Attributes.SetValue('to', whoTo);
|
|
msg.Attributes.SetValue('subject', subject);
|
|
msg.Attributes.SetDate('date.written', Now);
|
|
msg.Attributes.SetBool('attr.local', true);
|
|
msg.Attributes.SetAddr('addr.orig', MakeFTNAddress(1, 1, 1, 0));
|
|
msg.Attributes.SetAddr('addr.dest', MakeFTNAddress(1, 1, 2, 0));
|
|
msg.Body := body + #13;
|
|
|
|
try
|
|
if base.WriteMessage(msg) then
|
|
WriteLn('wrote message #', msg.Attributes.GetInt('msg.num'))
|
|
else
|
|
WriteLn('error: WriteMessage returned False');
|
|
finally
|
|
base.Close;
|
|
base.Free;
|
|
end;
|
|
end.
|