diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-05-28 06:16:43 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-05-28 06:16:43 +0000 |
commit | 694edcc3c1ac3041ff8cdd753a2f7894e8783e6c (patch) | |
tree | f8797b4c7671fbf9042fc011277d69d4c3549045 /src/luasocket.c | |
parent | bf738a03368b8de9c574d9631f131c5a520acf7b (diff) | |
download | luasocket-694edcc3c1ac3041ff8cdd753a2f7894e8783e6c.tar.gz luasocket-694edcc3c1ac3041ff8cdd753a2f7894e8783e6c.tar.bz2 luasocket-694edcc3c1ac3041ff8cdd753a2f7894e8783e6c.zip |
Committing with require.
Diffstat (limited to 'src/luasocket.c')
-rw-r--r-- | src/luasocket.c | 37 |
1 files changed, 3 insertions, 34 deletions
diff --git a/src/luasocket.c b/src/luasocket.c index fe4c96c..8d49be5 100644 --- a/src/luasocket.c +++ b/src/luasocket.c | |||
@@ -35,38 +35,6 @@ | |||
35 | #include "udp.h" | 35 | #include "udp.h" |
36 | #include "select.h" | 36 | #include "select.h" |
37 | #include "smtp.h" | 37 | #include "smtp.h" |
38 | #include "mime.h" | ||
39 | |||
40 | /*=========================================================================*\ | ||
41 | * Declarations | ||
42 | \*=========================================================================*/ | ||
43 | static int mod_open(lua_State *L, const luaL_reg *mod); | ||
44 | |||
45 | |||
46 | static int mod_open(lua_State *L, const luaL_reg *mod) | ||
47 | { | ||
48 | for (; mod->name; mod++) mod->func(L); | ||
49 | #ifdef LUASOCKET_COMPILED | ||
50 | #include "ltn12.lch" | ||
51 | #include "auxiliar.lch" | ||
52 | #include "url.lch" | ||
53 | #include "mime.lch" | ||
54 | #include "tp.lch" | ||
55 | #include "smtp.lch" | ||
56 | #include "http.lch" | ||
57 | #include "ftp.lch" | ||
58 | #else | ||
59 | lua_dofile(L, "ltn12.lua"); | ||
60 | lua_dofile(L, "auxiliar.lua"); | ||
61 | lua_dofile(L, "url.lua"); | ||
62 | lua_dofile(L, "mime.lua"); | ||
63 | lua_dofile(L, "tp.lua"); | ||
64 | lua_dofile(L, "smtp.lua"); | ||
65 | lua_dofile(L, "http.lua"); | ||
66 | lua_dofile(L, "ftp.lua"); | ||
67 | #endif | ||
68 | return 0; | ||
69 | } | ||
70 | 38 | ||
71 | /*-------------------------------------------------------------------------*\ | 39 | /*-------------------------------------------------------------------------*\ |
72 | * Modules | 40 | * Modules |
@@ -80,7 +48,6 @@ static const luaL_reg mod[] = { | |||
80 | {"tcp", tcp_open}, | 48 | {"tcp", tcp_open}, |
81 | {"udp", udp_open}, | 49 | {"udp", udp_open}, |
82 | {"select", select_open}, | 50 | {"select", select_open}, |
83 | {"mime", mime_open}, | ||
84 | {"smtp", smtp_open}, | 51 | {"smtp", smtp_open}, |
85 | {NULL, NULL} | 52 | {NULL, NULL} |
86 | }; | 53 | }; |
@@ -90,11 +57,13 @@ static const luaL_reg mod[] = { | |||
90 | \*-------------------------------------------------------------------------*/ | 57 | \*-------------------------------------------------------------------------*/ |
91 | LUASOCKET_API int luaopen_socket(lua_State *L) | 58 | LUASOCKET_API int luaopen_socket(lua_State *L) |
92 | { | 59 | { |
60 | int i; | ||
93 | if (!sock_open()) { | 61 | if (!sock_open()) { |
94 | lua_pushnil(L); | 62 | lua_pushnil(L); |
95 | lua_pushstring(L, "unable to initialize library"); | 63 | lua_pushstring(L, "unable to initialize library"); |
96 | return 2; | 64 | return 2; |
97 | } | 65 | } |
98 | mod_open(L, mod); | 66 | for (i = 0; mod[i].name; i++) |
67 | mod[i].func(L); | ||
99 | return 1; | 68 | return 1; |
100 | } | 69 | } |