diff options
| author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-21 06:07:58 +0000 |
|---|---|---|
| committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-06-21 06:07:58 +0000 |
| commit | bce1cb30d856d167e167c4c2997f9bebe03a612c (patch) | |
| tree | 8e684b912cdc9d27c5aebf593107487c94866438 /src/mime.lua | |
| parent | f7579db9e830ef41f422a280d26c9077f48728e5 (diff) | |
| download | luasocket-bce1cb30d856d167e167c4c2997f9bebe03a612c.tar.gz luasocket-bce1cb30d856d167e167c4c2997f9bebe03a612c.tar.bz2 luasocket-bce1cb30d856d167e167c4c2997f9bebe03a612c.zip | |
More adjustments/bugfixes.
Diffstat (limited to 'src/mime.lua')
| -rw-r--r-- | src/mime.lua | 32 |
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)) | |||
| 12 | local ltn12 = require("ltn12") | 12 | local ltn12 = require("ltn12") |
| 13 | 13 | ||
| 14 | -- encode, decode and wrap algorithm tables | 14 | -- encode, decode and wrap algorithm tables |
| 15 | encodet = {} | 15 | mime.encodet = {} |
| 16 | decodet = {} | 16 | mime.decodet = {} |
| 17 | wrapt = {} | 17 | mime.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 |
| 20 | local function choose(table) | 20 | local function choose(table) |
| @@ -29,47 +29,47 @@ local function choose(table) | |||
| 29 | end | 29 | end |
| 30 | 30 | ||
| 31 | -- define the encoding filters | 31 | -- define the encoding filters |
| 32 | encodet['base64'] = function() | 32 | mime.encodet['base64'] = function() |
| 33 | return ltn12.filter.cycle(b64, "") | 33 | return ltn12.filter.cycle(b64, "") |
| 34 | end | 34 | end |
| 35 | 35 | ||
| 36 | encodet['quoted-printable'] = function(mode) | 36 | mime.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") |
| 39 | end | 39 | end |
| 40 | 40 | ||
| 41 | -- define the decoding filters | 41 | -- define the decoding filters |
| 42 | decodet['base64'] = function() | 42 | mime.decodet['base64'] = function() |
| 43 | return ltn12.filter.cycle(unb64, "") | 43 | return ltn12.filter.cycle(unb64, "") |
| 44 | end | 44 | end |
| 45 | 45 | ||
| 46 | decodet['quoted-printable'] = function() | 46 | mime.decodet['quoted-printable'] = function() |
| 47 | return ltn12.filter.cycle(unqp, "") | 47 | return ltn12.filter.cycle(unqp, "") |
| 48 | end | 48 | end |
| 49 | 49 | ||
| 50 | -- define the line-wrap filters | 50 | -- define the line-wrap filters |
| 51 | wrapt['text'] = function(length) | 51 | mime.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) |
| 54 | end | 54 | end |
| 55 | wrapt['base64'] = wrapt['text'] | 55 | mime.wrapt['base64'] = wrapt['text'] |
| 56 | wrapt['default'] = wrapt['text'] | 56 | mime.wrapt['default'] = wrapt['text'] |
| 57 | 57 | ||
| 58 | wrapt['quoted-printable'] = function() | 58 | mime.wrapt['quoted-printable'] = function() |
| 59 | return ltn12.filter.cycle(qpwrp, 76, 76) | 59 | return ltn12.filter.cycle(qpwrp, 76, 76) |
| 60 | end | 60 | end |
| 61 | 61 | ||
| 62 | -- function that choose the encoding, decoding or wrap algorithm | 62 | -- function that choose the encoding, decoding or wrap algorithm |
| 63 | encode = choose(encodet) | 63 | mime.encode = choose(encodet) |
| 64 | decode = choose(decodet) | 64 | mime.decode = choose(decodet) |
| 65 | wrap = choose(wrapt) | 65 | mime.wrap = choose(wrapt) |
| 66 | 66 | ||
| 67 | -- define the end-of-line normalization filter | 67 | -- define the end-of-line normalization filter |
| 68 | function normalize(marker) | 68 | function mime.normalize(marker) |
| 69 | return ltn12.filter.cycle(eol, 0, marker) | 69 | return ltn12.filter.cycle(eol, 0, marker) |
| 70 | end | 70 | end |
| 71 | 71 | ||
| 72 | -- high level stuffing filter | 72 | -- high level stuffing filter |
| 73 | function stuff() | 73 | function mime.stuff() |
| 74 | return ltn12.filter.cycle(dot, 2) | 74 | return ltn12.filter.cycle(dot, 2) |
| 75 | end | 75 | end |
