New filter scheme.

ltn12 and mime updated.
smtp/ftp broken.
This commit is contained in:
Diego Nehab 2004-03-16 06:42:53 +00:00
parent b6edaac284
commit bcc0c2a9f0
17 changed files with 568 additions and 530 deletions

View file

@ -1,13 +1,12 @@
local source = ltn12.source.file(io.stdin)
local sink = ltn12.sink.file(io.stdout)
local convert
if arg and arg[1] == '-d' then
convert = socket.mime.decode("base64")
convert = mime.decode("base64")
else
local base64 = socket.mime.encode("base64")
local wrap = socket.mime.wrap()
convert = socket.mime.chain(base64, wrap)
end
while 1 do
local chunk = io.read(4096)
io.write(convert(chunk))
if not chunk then break end
local base64 = mime.encode("base64")
local wrap = mime.wrap()
convert = ltn12.filter.chain(base64, wrap)
end
source = ltn12.source.chain(source, convert)
ltn12.pump(source, sink)