end
+local function save_TEXT(data,filename)
+ -- Open the output file
+ local outfile = io.open(filename, "w")
+ if outfile == nil then
+ return oops(string.format("Could not write to file %s",tostring(filename)))
+ end
+
+ outfile:write(data)
+ io.close(outfile)
+ return filename
+end
+
local function save_BIN(data, filename)
-- Open the output file
local function convert_ascii_dump_to_JS(infile)
local t = infile:read("*all")
-
+ local cleaned
local output = "[";
for line in string.gmatch(t, "[^\n]+") do
if string.byte(line,1) ~= string.byte("+",1) then
- output = output .. "'"..line.."',\n"
+ cleaned = (line or ''):gsub('%s+','')
+ output = output .. "'"..cleaned.."',\n"
end
end
output = output .. "]"
local function convert_ascii_dump_to_BIN(infile)
local t = infile:read("*all")
-
+ local cleaned
local output = {};
for line in string.gmatch(t, "[^\n]+") do
if string.byte(line) ~= string.byte("+") then
- for c in (line or ''):gmatch('..') do
+ cleaned = (line or ''):gsub('%s+','')
+ for c in cleaned:gmatch('..') do
output[#output+1] = string.char( tonumber(c,16) )
end
end
return {
convert_bin_to_html = convert_bin_to_html,
convert_eml_to_html = convert_eml_to_html,
- convert_eml_to_bin = convert_eml_to_bin,
+ convert_eml_to_bin = convert_eml_to_bin,
+ SaveAsBinary = save_BIN,
+ SaveAsText = save_TEXT,
+ SaveAsBinary = save_BIN,
+ SaveAsText = save_TEXT,
}