diff options
author | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-02-04 14:29:11 +0000 |
---|---|---|
committer | Diego Nehab <diego@tecgraf.puc-rio.br> | 2004-02-04 14:29:11 +0000 |
commit | 0b2542d1a61fc5425ff65ab3dbf7ba7de174763f (patch) | |
tree | 8a6188e11db0c9ef6891c31e8a1bebca050b23b2 /src/luasocket.c | |
parent | f67864f86c7d703325e86b14d0ba33992c52891b (diff) | |
download | luasocket-0b2542d1a61fc5425ff65ab3dbf7ba7de174763f.tar.gz luasocket-0b2542d1a61fc5425ff65ab3dbf7ba7de174763f.tar.bz2 luasocket-0b2542d1a61fc5425ff65ab3dbf7ba7de174763f.zip |
Worked on the manual.
Implemented stuffing (needs test)
Added cddb and qp examples.
Diffstat (limited to 'src/luasocket.c')
-rw-r--r-- | src/luasocket.c | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/src/luasocket.c b/src/luasocket.c index bfe71c2..e99fcdf 100644 --- a/src/luasocket.c +++ b/src/luasocket.c | |||
@@ -33,12 +33,14 @@ | |||
33 | #include "tcp.h" | 33 | #include "tcp.h" |
34 | #include "udp.h" | 34 | #include "udp.h" |
35 | #include "select.h" | 35 | #include "select.h" |
36 | #include "smtp.h" | ||
36 | #include "mime.h" | 37 | #include "mime.h" |
37 | 38 | ||
38 | /*=========================================================================*\ | 39 | /*=========================================================================*\ |
39 | * Declarations | 40 | * Declarations |
40 | \*=========================================================================*/ | 41 | \*=========================================================================*/ |
41 | static int base_open(lua_State *L); | 42 | static int base_open(lua_State *L); |
43 | static int mod_open(lua_State *L, const luaL_reg *mod); | ||
42 | 44 | ||
43 | /*-------------------------------------------------------------------------*\ | 45 | /*-------------------------------------------------------------------------*\ |
44 | * Setup basic stuff. | 46 | * Setup basic stuff. |
@@ -66,22 +68,9 @@ static int base_open(lua_State *L) | |||
66 | return 0; | 68 | return 0; |
67 | } | 69 | } |
68 | 70 | ||
69 | /*-------------------------------------------------------------------------*\ | 71 | static int mod_open(lua_State *L, const luaL_reg *mod) |
70 | * Initializes all library modules. | ||
71 | \*-------------------------------------------------------------------------*/ | ||
72 | LUASOCKET_API int luaopen_socket(lua_State *L) | ||
73 | { | 72 | { |
74 | if (!sock_open()) return 0; | 73 | for (; mod->name; mod++) mod->func(L); |
75 | /* initialize all modules */ | ||
76 | base_open(L); | ||
77 | aux_open(L); | ||
78 | tm_open(L); | ||
79 | buf_open(L); | ||
80 | inet_open(L); | ||
81 | tcp_open(L); | ||
82 | udp_open(L); | ||
83 | select_open(L); | ||
84 | mime_open(L); | ||
85 | #ifdef LUASOCKET_COMPILED | 74 | #ifdef LUASOCKET_COMPILED |
86 | #include "auxiliar.lch" | 75 | #include "auxiliar.lch" |
87 | #include "concat.lch" | 76 | #include "concat.lch" |
@@ -101,5 +90,36 @@ LUASOCKET_API int luaopen_socket(lua_State *L) | |||
101 | lua_dofile(L, "ftp.lua"); | 90 | lua_dofile(L, "ftp.lua"); |
102 | lua_dofile(L, "http.lua"); | 91 | lua_dofile(L, "http.lua"); |
103 | #endif | 92 | #endif |
93 | return 0; | ||
94 | } | ||
95 | |||
96 | /*-------------------------------------------------------------------------*\ | ||
97 | * Modules | ||
98 | \*-------------------------------------------------------------------------*/ | ||
99 | static const luaL_reg mod[] = { | ||
100 | {"base", base_open}, | ||
101 | {"aux", aux_open}, | ||
102 | {"tm", tm_open}, | ||
103 | {"buf", buf_open}, | ||
104 | {"inet", inet_open}, | ||
105 | {"tcp", tcp_open}, | ||
106 | {"udp", udp_open}, | ||
107 | {"select", select_open}, | ||
108 | {"mime", mime_open}, | ||
109 | {"smtp", smtp_open}, | ||
110 | {NULL, NULL} | ||
111 | }; | ||
112 | |||
113 | /*-------------------------------------------------------------------------*\ | ||
114 | * Initializes all library modules. | ||
115 | \*-------------------------------------------------------------------------*/ | ||
116 | LUASOCKET_API int luaopen_socket(lua_State *L) | ||
117 | { | ||
118 | if (!sock_open()) { | ||
119 | lua_pushnil(L); | ||
120 | lua_pushstring(L, "unable to initialize library"); | ||
121 | return 2; | ||
122 | } | ||
123 | mod_open(L, mod); | ||
104 | return 1; | 124 | return 1; |
105 | } | 125 | } |