local pkt_msg_num = 0
- mf:write(space_pad("Produced by Qmail...Copyright (c) 1987 by Sparkware." ..
- " All Rights Reserved", 128))
+ mf:write(space_pad("Produced by OBBS.", 128))
for cnum,cname in ipairs(obbs.conferences) do
msgs = {}
for i,msg in ipairs(msgs) do
pkt_msg_num = pkt_msg_num + 1
qwk.write_message_header_block(mf, obbs, cnum, pkt_msg_num, msg)
- qwk.write_message_blocks(mf, obbs, msg)
+ qwk.write_message_text(mf, obbs, msg)
end
end
mf:write(" ") -- No network tag-line present
end
-function qwk.write_message_blocks(mf, obbs, msg)
+function qwk.write_message_text(mf, obbs, msg)
mf:write((string.gsub(msg.text, "\n", "\xe3")))
local padding = (128 - (string.len(msg.text) % 128)) % 128
function qwk.read_message(archive_dir, obbs, user_name)
- local msg_filename = work_dir .. "/" .. obbs.bbsid .. ".MSG"
+ local msg_filename = archive_dir .. "/" .. obbs.bbsid .. ".MSG"
if not fs.exists(msg_filename) then
print("Error: MSG file not found.")
- return
+ return false
+ end
+
+ local mf = assert(io.open(msg_filename, "r"))
+ local block = mf:read(128)
+
+ if not string.find(block, obbs.bbsid .. " *") then
+ print("Error: Failed to match BBSID in first block.")
+ return false
+ end
+
+ while mf:read(0) do
+ qwk.read_message_header(mf, obbs)
end
+end
- local mf = asert(io.open(msg_filename, "r"))
+function qwk.read_message_header(mf, obbs)
+ local msg = {}
+
+ mf:read(1) -- Message status (ignore for now)
+ local conf_num = tonumber(mf:read(7))
+ msg.date = mf:read(8)
+ msg.time = mf:read(5)
+ msg.to = mf:read(25)
+ msg.from = mf:read(25)
+ msg.subject = mf:read(25)
+ mf:read(12) -- Password (unused)
+ msg.replyto = tonumber(mf:read(8))
+
+ local nblocks = tonumber(mf:read(6))
+
+ mf:read(1) -- flag (ignore for now)
+ mf:read(2) -- conference number (already have this)
+ mf:read(2) -- message number in packet (unused)
+ mf:read(1) -- network tag flag (ignore)
+
+ msg.text = ""
+ for b=2,nblocks do
+ msg.text = msg.text .. mf:read(128)
+ end
+ msg.text = string.gsub(msg.text, "\xe3", "\n")
+ print("Message{")
+ for k,v in pairs(msg) do
+ print("\t" .. k .. "=\'" .. v .. "',")
+ end
+ print("}")
end
+function qwk.read_message_text(mf, obbs, msg)
+end
--- Commands ---