mf:write(string.rep("\0",padding))
end
-function qwk.process_replies(archive_dir, user_name)
+function qwk.import_rep(user_name, rep_filename)
+
+ if not fs.exists(rep_filename) then
+ print("Error: reply packet file '" .. rep_filename .. "' does not exist.")
+ return false
+ end
+
+ local archive_dir = fs.mktempdir()
+
+ fs.copy(rep_filename, archive_dir .. "/repfile.rep")
+ os.execute(qb.unzip .. " " .. archive_dir .. "/repfile.rep -d " .. archive_dir)
+
local msg_filename = archive_dir .. "/" .. qb.bbsid .. ".MSG"
while mf:read(0) do
qwk.process_reply(mf, qb, user_name)
end
+
+ fs.rmdir(archive_dir, true)
end
function qwk.process_reply(mf, user_name)
load_config()
if not arg[2] then
- print [[Usage: qwikboard DIR repin INFILE USER
+ print [[Usage: qwikboard DIR repin USER INFILE
Here INFILE is the name of the REP file to import new messages
from. This is traditionally named BBSID.rep, where BBSID is
return
end
- local rep_filename = arg[1]
- local user_name = arg[2]
-
- if not fs.exists(rep_filename) then
- print("Error: reply packet file '" .. rep_filename .. "' does not exist.")
- return
- end
-
- local work_dir = fs.mktempdir()
-
- fs.copy(rep_filename, work_dir .. "/repfile.rep")
- os.execute(qb.unzip .. " " .. work_dir .. "/repfile.rep -d " .. work_dir)
-
- qwk.process_replies(work_dir, qb, user_name)
-
- fs.rmdir(work_dir, true)
-
+ qwk.import_rep(arg[1], arg[2])
end
function cmd.nncp_handler()
print("Accepting REP packet from user '" .. user_name .. "'")
-- Accept REP packet
- -- TODO
+ local rep_file_name = os.tmpname()
+ fs.rmfile(rep_file_name)
+ local rep_file_name = rep_file_name .. ".rep"
+
+ local rf = assert(io.open(rep_file_name, "w"))
+ rf:write(input_string)
+ rf:close()
+
+ qwk.import_rep(user_name, rep_file_name)
+ fs.rmfile(rep_file_name)
end
end