diff options
Diffstat (limited to 'src/mime.lua')
| -rw-r--r-- | src/mime.lua | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/src/mime.lua b/src/mime.lua index ecf310d..000404f 100644 --- a/src/mime.lua +++ b/src/mime.lua | |||
| @@ -6,23 +6,15 @@ | |||
| 6 | ----------------------------------------------------------------------------- | 6 | ----------------------------------------------------------------------------- |
| 7 | 7 | ||
| 8 | ----------------------------------------------------------------------------- | 8 | ----------------------------------------------------------------------------- |
| 9 | -- Load MIME from dynamic library | ||
| 10 | -- Comment these lines if you are loading static | ||
| 11 | ----------------------------------------------------------------------------- | ||
| 12 | local open = assert(loadlib("mime", "luaopen_mime")) | ||
| 13 | local mime = assert(open()) | ||
| 14 | |||
| 15 | ----------------------------------------------------------------------------- | ||
| 16 | -- Load other required modules | 9 | -- Load other required modules |
| 17 | ----------------------------------------------------------------------------- | 10 | ----------------------------------------------------------------------------- |
| 11 | local mime = requirelib("mime", "luaopen_mime", getfenv(1)) | ||
| 18 | local ltn12 = require("ltn12") | 12 | local ltn12 = require("ltn12") |
| 19 | 13 | ||
| 20 | ----------------------------------------------------------------------------- | 14 | ----------------------------------------------------------------------------- |
| 21 | -- Setup namespace | 15 | -- Setup namespace |
| 22 | ----------------------------------------------------------------------------- | 16 | ----------------------------------------------------------------------------- |
| 23 | -- make all module globals fall into mime namespace | 17 | _LOADED["mime"] = mime |
| 24 | setmetatable(mime, { __index = _G }) | ||
| 25 | setfenv(1, mime) | ||
| 26 | 18 | ||
| 27 | -- encode, decode and wrap algorithm tables | 19 | -- encode, decode and wrap algorithm tables |
| 28 | encodet = {} | 20 | encodet = {} |
| @@ -48,7 +40,7 @@ end | |||
| 48 | 40 | ||
| 49 | encodet['quoted-printable'] = function(mode) | 41 | encodet['quoted-printable'] = function(mode) |
| 50 | return ltn12.filter.cycle(qp, "", | 42 | return ltn12.filter.cycle(qp, "", |
| 51 | (mode == "binary") and "=0D=0A" or "\13\10") | 43 | (mode == "binary") and "=0D=0A" or "\r\n") |
| 52 | end | 44 | end |
| 53 | 45 | ||
| 54 | -- define the decoding filters | 46 | -- define the decoding filters |
