Adjusted some details, got rid of old files, added some new.

This commit is contained in:
Diego Nehab 2004-03-22 04:15:03 +00:00
parent 4919a83d22
commit 1fa65d89ca
12 changed files with 132 additions and 97 deletions

View file

@ -1,9 +1,6 @@
marker = {['-u'] = '\10', ['-d'] = '\13\10'}
arg = arg or {'-u'}
marker = marker[arg[1]] or marker['-u']
local convert = socket.mime.normalize(marker)
while 1 do
local chunk = io.read(1)
io.write(convert(chunk))
if not chunk then break end
end
local marker = '\n'
if arg and arg[1] == '-d' then marker = '\r\n' end
local filter = mime.normalize(marker)
local source = ltn12.source.chain(ltn12.source.file(io.stdin), filter)
local sink = ltn12.sink.file(io.stdout)
ltn12.pump(source, sink)

View file

@ -93,7 +93,7 @@ function getbyhttp(url, file)
local save = ltn12.sink.file(file or io.stdout)
-- only print feedback if output is not stdout
if file then save = ltn12.sink.chain(stats(gethttpsize(url)), save) end
local respt = socket.http.request_cb({url = url, sink = save})
local respt = socket.http.request {url = url, sink = save }
if respt.code ~= 200 then print(respt.status or respt.error) end
end
@ -103,7 +103,7 @@ function getbyftp(url, file)
-- only print feedback if output is not stdout
-- and we don't know how big the file is
if file then save = ltn12.sink.chain(stats(), save) end
local ret, err = socket.ftp.get_cb {url = url, sink = save, type = "i"}
local ret, err = socket.ftp.get {url = url, sink = save, type = "i"}
if err then print(err) end
end

View file

@ -2,17 +2,15 @@ local convert
arg = arg or {}
local mode = arg and arg[1] or "-et"
if mode == "-et" then
local normalize = socket.mime.normalize()
local qp = socket.mime.encode("quoted-printable")
local wrap = socket.mime.wrap("quoted-printable")
convert = socket.mime.chain(normalize, qp, wrap)
local normalize = mime.normalize()
local qp = mime.encode("quoted-printable")
local wrap = mime.wrap("quoted-printable")
convert = ltn12.filter.chain(normalize, qp, wrap)
elseif mode == "-eb" then
local qp = socket.mime.encode("quoted-printable", "binary")
local wrap = socket.mime.wrap("quoted-printable")
convert = socket.mime.chain(qp, wrap)
else convert = socket.mime.decode("quoted-printable") end
while 1 do
local chunk = io.read(4096)
io.write(convert(chunk))
if not chunk then break end
end
local qp = mime.encode("quoted-printable", "binary")
local wrap = mime.wrap("quoted-printable")
convert = ltn12.filter.chain(qp, wrap)
else convert = mime.decode("quoted-printable") end
local source = ltn12.source.chain(ltn12.source.file(io.stdin), convert)
local sink = ltn12.sink.file(io.stdout)
ltn12.pump(source, sink)