aboutsummaryrefslogtreecommitdiff
path: root/src/luasocket.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/luasocket.c')
-rw-r--r--src/luasocket.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/src/luasocket.c b/src/luasocket.c
index 53f8c21..5541d7f 100644
--- a/src/luasocket.c
+++ b/src/luasocket.c
@@ -24,12 +24,13 @@
24\*=========================================================================*/ 24\*=========================================================================*/
25#include "luasocket.h" 25#include "luasocket.h"
26 26
27#include "tm.h" 27#include "timeout.h"
28#include "buf.h" 28#include "buffer.h"
29#include "sock.h" 29#include "socket.h"
30#include "inet.h" 30#include "inet.h"
31#include "tcp.h" 31#include "tcp.h"
32#include "udp.h" 32#include "udp.h"
33#include "select.h"
33 34
34/*=========================================================================*\ 35/*=========================================================================*\
35* Exported functions 36* Exported functions
@@ -39,6 +40,7 @@
39\*-------------------------------------------------------------------------*/ 40\*-------------------------------------------------------------------------*/
40LUASOCKET_API int luaopen_socketlib(lua_State *L) 41LUASOCKET_API int luaopen_socketlib(lua_State *L)
41{ 42{
43 if (!sock_open()) return 0;
42 /* create namespace table */ 44 /* create namespace table */
43 lua_pushstring(L, LUASOCKET_LIBNAME); 45 lua_pushstring(L, LUASOCKET_LIBNAME);
44 lua_newtable(L); 46 lua_newtable(L);
@@ -53,13 +55,28 @@ LUASOCKET_API int luaopen_socketlib(lua_State *L)
53 lua_pushstring(L, LUASOCKET_LIBNAME); 55 lua_pushstring(L, LUASOCKET_LIBNAME);
54 lua_settable(L, LUA_GLOBALSINDEX); 56 lua_settable(L, LUA_GLOBALSINDEX);
55 /* initialize all modules */ 57 /* initialize all modules */
56 sock_open(L);
57 tm_open(L); 58 tm_open(L);
58 buf_open(L); 59 buf_open(L);
59 inet_open(L); 60 inet_open(L);
60 tcp_open(L); 61 tcp_open(L);
61 udp_open(L); 62 udp_open(L);
62 /* load all Lua code */ 63 select_open(L);
63 lua_dofile(L, "luasocket.lua"); 64#ifdef LUASOCKET_COMPILED
64 return 0; 65#include "auxiliar.lch"
66#include "concat.lch"
67#include "code.lch"
68#include "url.lch"
69#include "smtp.lch"
70#include "ftp.lch"
71#include "http.lch"
72#else
73 lua_dofile(L, "auxiliar.lua");
74 lua_dofile(L, "concat.lua");
75 lua_dofile(L, "code.lua");
76 lua_dofile(L, "url.lua");
77 lua_dofile(L, "smtp.lua");
78 lua_dofile(L, "ftp.lua");
79 lua_dofile(L, "http.lua");
80#endif
81 return 1;
65} 82}