aboutsummaryrefslogtreecommitdiff
path: root/src/mime.lua
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2005-11-22 08:33:29 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2005-11-22 08:33:29 +0000
commitd55a5826e81136a9ecf65c4cd407152a56684dc2 (patch)
tree109ad44c75cee890ad5e98583e12b15b5e65a18e /src/mime.lua
parenta2b780bf7a78c66d54a248fa99b5fc862c12a127 (diff)
downloadluasocket-d55a5826e81136a9ecf65c4cd407152a56684dc2.tar.gz
luasocket-d55a5826e81136a9ecf65c4cd407152a56684dc2.tar.bz2
luasocket-d55a5826e81136a9ecf65c4cd407152a56684dc2.zip
Few tweaks in installation, some missing files, etc.
Diffstat (limited to 'src/mime.lua')
-rw-r--r--src/mime.lua14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/mime.lua b/src/mime.lua
index f6a9333..3182545 100644
--- a/src/mime.lua
+++ b/src/mime.lua
@@ -20,10 +20,10 @@ encodet = {}
20decodet = {} 20decodet = {}
21wrapt = {} 21wrapt = {}
22 22
23-- creates a function that chooses a filter by name from a given table 23-- creates a function that chooses a filter by name from a given table
24local function choose(table) 24local function choose(table)
25 return function(name, opt1, opt2) 25 return function(name, opt1, opt2)
26 if base.type(name) ~= "string" then 26 if base.type(name) ~= "string" then
27 name, opt1, opt2 = "default", name, opt1 27 name, opt1, opt2 = "default", name, opt1
28 end 28 end
29 local f = table[name or "nil"] 29 local f = table[name or "nil"]
@@ -38,7 +38,7 @@ encodet['base64'] = function()
38end 38end
39 39
40encodet['quoted-printable'] = function(mode) 40encodet['quoted-printable'] = function(mode)
41 return ltn12.filter.cycle(qp, "", 41 return ltn12.filter.cycle(qp, "",
42 (mode == "binary") and "=0D=0A" or "\r\n") 42 (mode == "binary") and "=0D=0A" or "\r\n")
43end 43end
44 44
@@ -56,22 +56,22 @@ local function format(chunk)
56 if chunk == "" then return "''" 56 if chunk == "" then return "''"
57 else return string.len(chunk) end 57 else return string.len(chunk) end
58 else return "nil" end 58 else return "nil" end
59end 59end
60 60
61-- define the line-wrap filters 61-- define the line-wrap filters
62wrapt['text'] = function(length) 62wrapt['text'] = function(length)
63 length = length or 76 63 length = length or 76
64 return ltn12.filter.cycle(wrp, length, length) 64 return ltn12.filter.cycle(wrp, length, length)
65end 65end
66wrapt['base64'] = wrapt['text'] 66wrapt['base64'] = wrapt['text']
67wrapt['default'] = wrapt['text'] 67wrapt['default'] = wrapt['text']
68 68
69wrapt['quoted-printable'] = function() 69wrapt['quoted-printable'] = function()
70 return ltn12.filter.cycle(qpwrp, 76, 76) 70 return ltn12.filter.cycle(qpwrp, 76, 76)
71end 71end
72 72
73-- function that choose the encoding, decoding or wrap algorithm 73-- function that choose the encoding, decoding or wrap algorithm
74encode = choose(encodet) 74encode = choose(encodet)
75decode = choose(decodet) 75decode = choose(decodet)
76wrap = choose(wrapt) 76wrap = choose(wrapt)
77 77