diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-03-22 04:15:03 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-03-22 04:15:03 +0000 |
| commit | 1fa65d89ca5dc64756f7933d7cc3f524e4627dce (patch) | |
| tree | df614c8b86b0f7c2f45c2afcacc993ab3c0dcf11 /etc | |
| parent | 4919a83d2271a9e43b83c7d488e3f94c850681e3 (diff) | |
| download | luasocket-1fa65d89ca5dc64756f7933d7cc3f524e4627dce.tar.gz luasocket-1fa65d89ca5dc64756f7933d7cc3f524e4627dce.tar.bz2 luasocket-1fa65d89ca5dc64756f7933d7cc3f524e4627dce.zip | |
Adjusted some details, got rid of old files, added some new.
Diffstat (limited to 'etc')
| -rw-r--r-- | etc/eol.lua | 15 | ||||
| -rw-r--r-- | etc/get.lua | 4 | ||||
| -rw-r--r-- | etc/qp.lua | 24 |
3 files changed, 19 insertions, 24 deletions
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 @@ | |||
| 1 | marker = {['-u'] = '\10', ['-d'] = '\13\10'} | 1 | local marker = '\n' |
| 2 | arg = arg or {'-u'} | 2 | if arg and arg[1] == '-d' then marker = '\r\n' end |
| 3 | marker = marker[arg[1]] or marker['-u'] | 3 | local filter = mime.normalize(marker) |
| 4 | local convert = socket.mime.normalize(marker) | 4 | local source = ltn12.source.chain(ltn12.source.file(io.stdin), filter) |
| 5 | while 1 do | 5 | local sink = ltn12.sink.file(io.stdout) |
| 6 | local chunk = io.read(1) | 6 | ltn12.pump(source, sink) |
| 7 | io.write(convert(chunk)) | ||
| 8 | if not chunk then break end | ||
| 9 | end | ||
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) | |||
| 93 | local save = ltn12.sink.file(file or io.stdout) | 93 | local save = ltn12.sink.file(file or io.stdout) |
| 94 | -- only print feedback if output is not stdout | 94 | -- only print feedback if output is not stdout |
| 95 | if file then save = ltn12.sink.chain(stats(gethttpsize(url)), save) end | 95 | if file then save = ltn12.sink.chain(stats(gethttpsize(url)), save) end |
| 96 | local respt = socket.http.request_cb({url = url, sink = save}) | 96 | local respt = socket.http.request {url = url, sink = save } |
| 97 | if respt.code ~= 200 then print(respt.status or respt.error) end | 97 | if respt.code ~= 200 then print(respt.status or respt.error) end |
| 98 | end | 98 | end |
| 99 | 99 | ||
| @@ -103,7 +103,7 @@ function getbyftp(url, file) | |||
| 103 | -- only print feedback if output is not stdout | 103 | -- only print feedback if output is not stdout |
| 104 | -- and we don't know how big the file is | 104 | -- and we don't know how big the file is |
| 105 | if file then save = ltn12.sink.chain(stats(), save) end | 105 | if file then save = ltn12.sink.chain(stats(), save) end |
| 106 | local ret, err = socket.ftp.get_cb {url = url, sink = save, type = "i"} | 106 | local ret, err = socket.ftp.get {url = url, sink = save, type = "i"} |
| 107 | if err then print(err) end | 107 | if err then print(err) end |
| 108 | end | 108 | end |
| 109 | 109 | ||
| @@ -2,17 +2,15 @@ local convert | |||
| 2 | arg = arg or {} | 2 | arg = arg or {} |
| 3 | local mode = arg and arg[1] or "-et" | 3 | local mode = arg and arg[1] or "-et" |
| 4 | if mode == "-et" then | 4 | if mode == "-et" then |
| 5 | local normalize = socket.mime.normalize() | 5 | local normalize = mime.normalize() |
| 6 | local qp = socket.mime.encode("quoted-printable") | 6 | local qp = mime.encode("quoted-printable") |
| 7 | local wrap = socket.mime.wrap("quoted-printable") | 7 | local wrap = mime.wrap("quoted-printable") |
| 8 | convert = socket.mime.chain(normalize, qp, wrap) | 8 | convert = ltn12.filter.chain(normalize, qp, wrap) |
| 9 | elseif mode == "-eb" then | 9 | elseif mode == "-eb" then |
| 10 | local qp = socket.mime.encode("quoted-printable", "binary") | 10 | local qp = mime.encode("quoted-printable", "binary") |
| 11 | local wrap = socket.mime.wrap("quoted-printable") | 11 | local wrap = mime.wrap("quoted-printable") |
| 12 | convert = socket.mime.chain(qp, wrap) | 12 | convert = ltn12.filter.chain(qp, wrap) |
| 13 | else convert = socket.mime.decode("quoted-printable") end | 13 | else convert = mime.decode("quoted-printable") end |
| 14 | while 1 do | 14 | local source = ltn12.source.chain(ltn12.source.file(io.stdin), convert) |
| 15 | local chunk = io.read(4096) | 15 | local sink = ltn12.sink.file(io.stdout) |
| 16 | io.write(convert(chunk)) | 16 | ltn12.pump(source, sink) |
| 17 | if not chunk then break end | ||
| 18 | end | ||
