From 1fa65d89ca5dc64756f7933d7cc3f524e4627dce Mon Sep 17 00:00:00 2001 From: Diego Nehab Date: Mon, 22 Mar 2004 04:15:03 +0000 Subject: Adjusted some details, got rid of old files, added some new. --- etc/eol.lua | 15 ++++++--------- etc/get.lua | 4 ++-- etc/qp.lua | 24 +++++++++++------------- 3 files changed, 19 insertions(+), 24 deletions(-) (limited to 'etc') diff --git a/etc/eol.lua b/etc/eol.lua index 6b2a8a9..aa43596 100644 --- a/etc/eol.lua +++ b/etc/eol.lua @@ -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) diff --git a/etc/get.lua b/etc/get.lua index 0306b54..eafebda 100644 --- a/etc/get.lua +++ b/etc/get.lua @@ -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 diff --git a/etc/qp.lua b/etc/qp.lua index 1ca0ae2..08545db 100644 --- a/etc/qp.lua +++ b/etc/qp.lua @@ -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) -- cgit v1.2.3-55-g6feb