aboutsummaryrefslogtreecommitdiff
path: root/src/mime.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2004-06-21 06:07:58 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2004-06-21 06:07:58 +0000
commitbce1cb30d856d167e167c4c2997f9bebe03a612c (patch)
tree8e684b912cdc9d27c5aebf593107487c94866438 /src/mime.lua
parentf7579db9e830ef41f422a280d26c9077f48728e5 (diff)
downloadluasocket-bce1cb30d856d167e167c4c2997f9bebe03a612c.tar.gz
luasocket-bce1cb30d856d167e167c4c2997f9bebe03a612c.tar.bz2
luasocket-bce1cb30d856d167e167c4c2997f9bebe03a612c.zip
More adjustments/bugfixes.
Diffstat (limited to 'src/mime.lua')
-rw-r--r--src/mime.lua32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/mime.lua b/src/mime.lua
index 345bd25..fcdc358 100644
--- a/src/mime.lua
+++ b/src/mime.lua
@@ -12,9 +12,9 @@ local mime = requirelib("mime", "luaopen_mime", getfenv(1))
12local ltn12 = require("ltn12") 12local ltn12 = require("ltn12")
13 13
14-- encode, decode and wrap algorithm tables 14-- encode, decode and wrap algorithm tables
15encodet = {} 15mime.encodet = {}
16decodet = {} 16mime.decodet = {}
17wrapt = {} 17mime.wrapt = {}
18 18
19-- creates a function that chooses a filter by name from a given table 19-- creates a function that chooses a filter by name from a given table
20local function choose(table) 20local function choose(table)
@@ -29,47 +29,47 @@ local function choose(table)
29end 29end
30 30
31-- define the encoding filters 31-- define the encoding filters
32encodet['base64'] = function() 32mime.encodet['base64'] = function()
33 return ltn12.filter.cycle(b64, "") 33 return ltn12.filter.cycle(b64, "")
34end 34end
35 35
36encodet['quoted-printable'] = function(mode) 36mime.encodet['quoted-printable'] = function(mode)
37 return ltn12.filter.cycle(qp, "", 37 return ltn12.filter.cycle(qp, "",
38 (mode == "binary") and "=0D=0A" or "\r\n") 38 (mode == "binary") and "=0D=0A" or "\r\n")
39end 39end
40 40
41-- define the decoding filters 41-- define the decoding filters
42decodet['base64'] = function() 42mime.decodet['base64'] = function()
43 return ltn12.filter.cycle(unb64, "") 43 return ltn12.filter.cycle(unb64, "")
44end 44end
45 45
46decodet['quoted-printable'] = function() 46mime.decodet['quoted-printable'] = function()
47 return ltn12.filter.cycle(unqp, "") 47 return ltn12.filter.cycle(unqp, "")
48end 48end
49 49
50-- define the line-wrap filters 50-- define the line-wrap filters
51wrapt['text'] = function(length) 51mime.wrapt['text'] = function(length)
52 length = length or 76 52 length = length or 76
53 return ltn12.filter.cycle(wrp, length, length) 53 return ltn12.filter.cycle(wrp, length, length)
54end 54end
55wrapt['base64'] = wrapt['text'] 55mime.wrapt['base64'] = wrapt['text']
56wrapt['default'] = wrapt['text'] 56mime.wrapt['default'] = wrapt['text']
57 57
58wrapt['quoted-printable'] = function() 58mime.wrapt['quoted-printable'] = function()
59 return ltn12.filter.cycle(qpwrp, 76, 76) 59 return ltn12.filter.cycle(qpwrp, 76, 76)
60end 60end
61 61
62-- function that choose the encoding, decoding or wrap algorithm 62-- function that choose the encoding, decoding or wrap algorithm
63encode = choose(encodet) 63mime.encode = choose(encodet)
64decode = choose(decodet) 64mime.decode = choose(decodet)
65wrap = choose(wrapt) 65mime.wrap = choose(wrapt)
66 66
67-- define the end-of-line normalization filter 67-- define the end-of-line normalization filter
68function normalize(marker) 68function mime.normalize(marker)
69 return ltn12.filter.cycle(eol, 0, marker) 69 return ltn12.filter.cycle(eol, 0, marker)
70end 70end
71 71
72-- high level stuffing filter 72-- high level stuffing filter
73function stuff() 73function mime.stuff()
74 return ltn12.filter.cycle(dot, 2) 74 return ltn12.filter.cycle(dot, 2)
75end 75end