aboutsummaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-03-22 04:15:03 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-03-22 04:15:03 +0000
commit1fa65d89ca5dc64756f7933d7cc3f524e4627dce (patch)
treedf614c8b86b0f7c2f45c2afcacc993ab3c0dcf11 /etc
parent4919a83d2271a9e43b83c7d488e3f94c850681e3 (diff)
downloadluasocket-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.lua15
-rw-r--r--etc/get.lua4
-rw-r--r--etc/qp.lua24
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 @@
1marker = {['-u'] = '\10', ['-d'] = '\13\10'} 1local marker = '\n'
2arg = arg or {'-u'} 2if arg and arg[1] == '-d' then marker = '\r\n' end
3marker = marker[arg[1]] or marker['-u'] 3local filter = mime.normalize(marker)
4local convert = socket.mime.normalize(marker) 4local source = ltn12.source.chain(ltn12.source.file(io.stdin), filter)
5while 1 do 5local sink = ltn12.sink.file(io.stdout)
6 local chunk = io.read(1) 6ltn12.pump(source, sink)
7 io.write(convert(chunk))
8 if not chunk then break end
9end
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
98end 98end
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
108end 108end
109 109
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
2arg = arg or {} 2arg = arg or {}
3local mode = arg and arg[1] or "-et" 3local mode = arg and arg[1] or "-et"
4if mode == "-et" then 4if 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)
9elseif mode == "-eb" then 9elseif 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)
13else convert = socket.mime.decode("quoted-printable") end 13else convert = mime.decode("quoted-printable") end
14while 1 do 14local source = ltn12.source.chain(ltn12.source.file(io.stdin), convert)
15 local chunk = io.read(4096) 15local sink = ltn12.sink.file(io.stdout)
16 io.write(convert(chunk)) 16ltn12.pump(source, sink)
17 if not chunk then break end
18end