comparison etc/qp.lua @ 0:4b915342e2a8

LuaSocket 2.0.2 + CMake build description.
author Eric Wing <ewing . public |-at-| gmail . com>
date Tue, 26 Aug 2008 18:40:01 -0700
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4b915342e2a8
1 -----------------------------------------------------------------------------
2 -- Little program to convert to and from Quoted-Printable
3 -- LuaSocket sample files
4 -- Author: Diego Nehab
5 -- RCS ID: $Id: qp.lua,v 1.5 2004/06/17 21:46:22 diego Exp $
6 -----------------------------------------------------------------------------
7 local ltn12 = require("ltn12")
8 local mime = require("mime")
9 local convert
10 arg = arg or {}
11 local mode = arg and arg[1] or "-et"
12 if mode == "-et" then
13 local normalize = mime.normalize()
14 local qp = mime.encode("quoted-printable")
15 local wrap = mime.wrap("quoted-printable")
16 convert = ltn12.filter.chain(normalize, qp, wrap)
17 elseif mode == "-eb" then
18 local qp = mime.encode("quoted-printable", "binary")
19 local wrap = mime.wrap("quoted-printable")
20 convert = ltn12.filter.chain(qp, wrap)
21 else convert = mime.decode("quoted-printable") end
22 local source = ltn12.source.chain(ltn12.source.file(io.stdin), convert)
23 local sink = ltn12.sink.file(io.stdout)
24 ltn12.pump.all(source, sink)