From 115d4c9f689eea5f65f043d3a93b0f3d54153d76 Mon Sep 17 00:00:00 2001 From: plugd Date: Mon, 12 Aug 2024 15:58:27 +0200 Subject: [PATCH] REP side of nncp_handler drafted. --- qwikboard | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/qwikboard b/qwikboard index b4b0603..63dd32d 100755 --- a/qwikboard +++ b/qwikboard @@ -257,7 +257,18 @@ function qwk.write_message_text(mf, msg) 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" @@ -277,6 +288,8 @@ function qwk.process_replies(archive_dir, user_name) 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) @@ -403,7 +416,7 @@ function cmd.repin() 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 @@ -412,23 +425,7 @@ about this.]] 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() @@ -471,8 +468,17 @@ exec: { 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 -- 2.20.1