module BBS::Xmodem

XMODEM downloads: the sending side of Ward Christensen’s protocol and its CRC and 1K variants, the transfer the terminals of a Commodore 64 (CCGMS, Novaterm, UltimateTerm and the like) know besides SyncTERM, Qodem and lrzsz’s rx.

BBS::Xmodem.send_file(session, bytes)
BBS::Xmodem.send_file(session, bytes, one_k: true)
# => :ok, :cancelled, :timeout or :hangup

XMODEM carries no file name: the caller names the file in the terminal before the transfer starts. The last block is padded with SUB (0x1a) up to its size, so the received file may be longer than the original.

The bytes go out as they are, past the PETSCII encoder, with 0xFF as a doubled telnet IAC (telnet: false for a plain byte pipe), and the line is asked into telnet BINARY mode for the transfer.