return io.open(filename, "r")
end
+function fs.dir(path)
+ return posix.dir(path)
+end
+
function fs.mkdir(dirname)
posix.mkdir(dirname)
end
local qwk = {}
-function qwk.write_control(cf, obbs, user_name)
+function qwk.write_control(target_dir, obbs, user_name)
+ local cf = assert(io.open(target_dir .. "/CONTROL.DAT", "w"))
+
cf:write(obbs.name .. "\r\n")
cf:write("\r\n") -- BBS location
cf:write("\r\n") -- BBS phone number
cf:write("HELLO\r\n")
cf:write("NEWS\r\n")
cf:write("GOODBYE\r\n")
+
+ cf:close()
end
-function qwk.write_message (mf, obbs)
+function qwk.write_message (target_dir, obbs)
+ local mf = assert(io.open(target_dir .. "/MESSAGES.DAT", "w"))
+
mf:write(space_pad("Produced by Qmail...Copyright (c) 1987 by Sparkware." ..
" All Rights Reserved", 128))
for cnum,cname in ipairs(obbs.conferences) do
- for mnum,msg_fname in ipairs(posix.dir(obbs.path .. "/conferences/" .. cname)) do
+ for mnum,msg_fname in ipairs(fs.dir(obbs.path .. "/conferences/" .. cname)) do
msg = io.open(obbs.path .. "/conferences/" .. cname .. "/" .. msg_fname, "r"):read("*all")
qwk.write_message_header_block(mf, obbs, cnum, mnum, msg)
qwk.write_message_blocks(mf, obbs, msg)
end
end
+
+ mf:close()
end
function qwk.write_message_header_block(mf, obbs, conf_num, msg)
+
+
end
function qwk.write_message_blocks(mf, obbs, msg)
local user_name = arg[1]
- local dir = fs.mktempdir()
+ local target_dir = fs.mktempdir()
-- CONTROL.DAT
-
- local cf = assert(io.open(dir .. "/CONTROL.DAT", "w"))
- qwk.write_control(cf, obbs, user_name)
- cf:close()
+ qwk.write_control(target_dir, obbs, user_name)
-- Copy BBS welcome, news and goodbye files
if obbs.hello and fs.exists(obbs.hello) then
- fs.copy(obbs.hello, dir .. "/HELLO")
+ fs.copy(obbs.hello, target_dir .. "/HELLO")
else
- fs.touch(dir .. "/HELLO")
+ fs.touch(target_dir .. "/HELLO")
end
if obbs.news and fs.exists(obbs.news) then
- fs.copy(obbs.news, dir .. "/NEWS")
+ fs.copy(obbs.news, target_dir .. "/NEWS")
else
- fs.touch(dir .. "/NEWS")
+ fs.touch(target_dir .. "/NEWS")
end
if obbs.news and fs.exists(obbs.goodbye) then
- fs.copy(obbs.goodbye, dir .. "/GOODBYE")
+ fs.copy(obbs.goodbye, target_dir .. "/GOODBYE")
else
- fs.touch(dir .. "/GOODBYE")
+ fs.touch(target_dir .. "/GOODBYE")
end
-- Pack messages
- local mf = assert(io.open(dir .. "/MESSAGES.DAT", "w"))
- qwk.write_message(mf, obbs)
- mf:close()
+ qwk.write_message(target_dir, obbs)
-- Create archive in outgoing
os.execute("zip -rj " .. obbs.path ..
"/outgoing/" .. obbs.bbsid ..
- ".qwk " .. dir)
+ ".qwk " .. target_dir)
- fs.rmdir(dir)
+ fs.rmdir(target_dir)
end
-- Main