Subject: [alpine-devel] Mailing List Archives back online

From: Nathan Angelacos <[email-masked]>
Date: Fri, 12 Feb 2010 12:12:27 -0800

Due to a malformed email, the alpine-devel mailing list archives hadn't 
been updated since 22 Dec 2009

The hypermail script is now updated to handle the condition, and the 
archives are now up-to-date again.

Sorry for the outage.

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---

---

From: Michael Mason <[email-masked]>
Date: Fri, 12 Feb 2010 20:20:24 +0000

On Feb 12, 2010, at 8:12 PM, Nathan Angelacos wrote:

> Due to a malformed email, the alpine-devel mailing list archives  
> hadn't been updated since 22 Dec 2009
>
Nangel: is the is mdir2mbox.lua script that has been included in the  
hypermail package for alpine? If it is, please send me the update and  
I will include it in the package.

Thanks

---

---

From: Nathan Angelacos <[email-masked]>
Date: Fri, 12 Feb 2010 12:48:35 -0800

Michael Mason wrote:
> hypermail package for alpine? If it is, please send me the update and I 
> will include it in the package.
> 
one line patch:

--- /usr/bin/mdir2mbox.lua
+++ mdir2mbox.lua
@@ -70,7 +70,7 @@

  	local date = string.match("\n" .. headers, "\nDate: ([^\n]*)")
  	if date == nil then
-		date = os.date ("%c", posix.stat(path, "mtime"))
+		date = os.date ("%a, %d %b %Y %X +%z", posix.stat(path, "mtime"))
  	end
  	local weekday,day,month,year,time,offset = string.match(date, 
"([^,]*), +(%d+) (%a+) (%d+) ([%d:]*) ([%d]*)")

New file is attached

#!/usr/bin/lua
-- This script takes a mlmmj archive "maildir format" directory and
-- writes out an mbox formatted file to stdout
-- Copyright (c) 2009 N. Angelacos under the  GPL 2 License

require "posix"

-- command line parser, or exit 
check_command_line = function () 
	local source_dir = arg[1]
	local source_time = arg[2]
	
	if (source_dir == nil ) then
		io.stderr:write("mdir2mbox  source_dir [hours]\n" ..
			"Writes an mbox formatted file to stdout from the files in source_dir\n" ..
			"If [hours] is given, then only files newer then [hours] are processed\n")
		os.exit(-1)
	end

	if (posix.stat(source_dir, "type") ~= "directory") then
		io.stderr:write(source_dir .. " is not a directory\n")
		os.exit(-1)
	end

	return source_dir, source_time
end

-- Get candidates 
get_candidates = function (source, hours)
	local all = posix.dir(source)
	local candidates = {}
	local timestamp = 0

	if (hours) then
		timestamp = os.time() - hours * 3600
	end

	for k,v in ipairs(all) do
		local st = posix.stat(source .. "/" .. v)
		if (st) and (st.type == "regular") and (st.mtime > timestamp) then
			table.insert(candidates,source .. "/" .. v)
		end
	end
	
	return candidates
end

file_to_mbox = function (path)
	local fh = io.open(path)
	if (fh == nil) then 
		return 
	end
	local headers = ""
	local l = ""
	-- get headers
	repeat
		headers = headers .. l
		l = (fh:read("*l") or "" ) .. "\n"
	until (#l == 1)

	local from = string.match("\n" .. headers, "\nFrom: ([^\n]*)")
	if from == nil then
		from = string.match("\n" .. headers, "\nReply-To: ([^\n]*)")
	end
	if from == nil then
		from = "<[email-masked]>"
	end
	from = string.match(from, "<([^>]*)>") or string.match(from, "([^ ]*)")

	local date = string.match("\n" .. headers, "\nDate: ([^\n]*)")
	if date == nil then
		date = os.date ("%a, %d %b %Y %X +%z", posix.stat(path, "mtime"))
	end
	local weekday,day,month,year,time,offset = string.match(date, "([^,]*), +(%d+) (%a+) (%d+) ([%d:]*) ([%d]*)")

	print ("From " .. from .. " " .. string.format("%s %s %s %s %s", weekday, month, day, time, year, offset ))
	print (headers)
	
	-- get rest of message
	repeat
		local foo  = fh:read("*l")
		if foo then 
			print(foo)
		end
	until (foo == nil)
	
fh:close()
end

candidates =  get_candidates(check_command_line ())

for k,v in ipairs(candidates) do
	file_to_mbox(v)
end
print ("")