diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-11-22 08:33:29 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2005-11-22 08:33:29 +0000 |
| commit | d55a5826e81136a9ecf65c4cd407152a56684dc2 (patch) | |
| tree | 109ad44c75cee890ad5e98583e12b15b5e65a18e /src/mime.lua | |
| parent | a2b780bf7a78c66d54a248fa99b5fc862c12a127 (diff) | |
| download | luasocket-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.lua | 14 |
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 = {} | |||
| 20 | decodet = {} | 20 | decodet = {} |
| 21 | wrapt = {} | 21 | wrapt = {} |
| 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 |
| 24 | local function choose(table) | 24 | local 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() | |||
| 38 | end | 38 | end |
| 39 | 39 | ||
| 40 | encodet['quoted-printable'] = function(mode) | 40 | encodet['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") |
| 43 | end | 43 | end |
| 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 |
| 59 | end | 59 | end |
| 60 | 60 | ||
| 61 | -- define the line-wrap filters | 61 | -- define the line-wrap filters |
| 62 | wrapt['text'] = function(length) | 62 | wrapt['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) |
| 65 | end | 65 | end |
| 66 | wrapt['base64'] = wrapt['text'] | 66 | wrapt['base64'] = wrapt['text'] |
| 67 | wrapt['default'] = wrapt['text'] | 67 | wrapt['default'] = wrapt['text'] |
| 68 | 68 | ||
| 69 | wrapt['quoted-printable'] = function() | 69 | wrapt['quoted-printable'] = function() |
| 70 | return ltn12.filter.cycle(qpwrp, 76, 76) | 70 | return ltn12.filter.cycle(qpwrp, 76, 76) |
| 71 | end | 71 | end |
| 72 | 72 | ||
| 73 | -- function that choose the encoding, decoding or wrap algorithm | 73 | -- function that choose the encoding, decoding or wrap algorithm |
| 74 | encode = choose(encodet) | 74 | encode = choose(encodet) |
| 75 | decode = choose(decodet) | 75 | decode = choose(decodet) |
| 76 | wrap = choose(wrapt) | 76 | wrap = choose(wrapt) |
| 77 | 77 | ||
