diff options
Diffstat (limited to 'etc/b64.lua')
-rw-r--r-- | etc/b64.lua | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/etc/b64.lua b/etc/b64.lua index de83578..ea157c4 100644 --- a/etc/b64.lua +++ b/etc/b64.lua | |||
@@ -1,13 +1,12 @@ | |||
1 | local source = ltn12.source.file(io.stdin) | ||
2 | local sink = ltn12.sink.file(io.stdout) | ||
1 | local convert | 3 | local convert |
2 | if arg and arg[1] == '-d' then | 4 | if arg and arg[1] == '-d' then |
3 | convert = socket.mime.decode("base64") | 5 | convert = mime.decode("base64") |
4 | else | 6 | else |
5 | local base64 = socket.mime.encode("base64") | 7 | local base64 = mime.encode("base64") |
6 | local wrap = socket.mime.wrap() | 8 | local wrap = mime.wrap() |
7 | convert = socket.mime.chain(base64, wrap) | 9 | convert = ltn12.filter.chain(base64, wrap) |
8 | end | ||
9 | while 1 do | ||
10 | local chunk = io.read(4096) | ||
11 | io.write(convert(chunk)) | ||
12 | if not chunk then break end | ||
13 | end | 10 | end |
11 | source = ltn12.source.chain(source, convert) | ||
12 | ltn12.pump(source, sink) | ||