diff options
Diffstat (limited to 'src/mime.lua')
-rw-r--r-- | src/mime.lua | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/mime.lua b/src/mime.lua index 37756c7..8f2cfff 100644 --- a/src/mime.lua +++ b/src/mime.lua | |||
@@ -1,6 +1,27 @@ | |||
1 | if not ltn12 then error('Requires LTN12 module') end | 1 | ----------------------------------------------------------------------------- |
2 | -- create mime namespace | 2 | -- MIME support for the Lua language. |
3 | mime = mime or {} | 3 | -- Author: Diego Nehab |
4 | -- Conforming to RFCs 2045-2049 | ||
5 | -- RCS ID: $Id$ | ||
6 | ----------------------------------------------------------------------------- | ||
7 | |||
8 | ----------------------------------------------------------------------------- | ||
9 | -- Load MIME from dynamic library | ||
10 | -- Comment these lines if you are loading static | ||
11 | ----------------------------------------------------------------------------- | ||
12 | open, err1, err2 = loadlib("mime", "luaopen_mime") | ||
13 | if not open then error(err1) end | ||
14 | open() | ||
15 | if not MIME_LIBNAME then error("MIME init failed") end | ||
16 | |||
17 | ----------------------------------------------------------------------------- | ||
18 | -- Namespace independence | ||
19 | ----------------------------------------------------------------------------- | ||
20 | local mime = _G[MIME_LIBNAME] | ||
21 | if not mime then error('MIME init FAILED') end | ||
22 | |||
23 | require("ltn12") | ||
24 | |||
4 | -- make all module globals fall into mime namespace | 25 | -- make all module globals fall into mime namespace |
5 | setmetatable(mime, { __index = _G }) | 26 | setmetatable(mime, { __index = _G }) |
6 | setfenv(1, mime) | 27 | setfenv(1, mime) |