aboutsummaryrefslogtreecommitdiff
path: root/src/select.c
diff options
context:
space:
mode:
authorDiego Nehab <diego@tecgraf.puc-rio.br>2002-12-02 23:34:41 +0000
committerDiego Nehab <diego@tecgraf.puc-rio.br>2002-12-02 23:34:41 +0000
commitd7e80592a69c076991ed4f4cc15d5390e14d1f0b (patch)
tree5fd9c99742b4a03e6a66f940a1f86f98d4db50c8 /src/select.c
parentb796207ce06a66b04cce6686b3fa664c06703995 (diff)
downloadluasocket-d7e80592a69c076991ed4f4cc15d5390e14d1f0b.tar.gz
luasocket-d7e80592a69c076991ed4f4cc15d5390e14d1f0b.tar.bz2
luasocket-d7e80592a69c076991ed4f4cc15d5390e14d1f0b.zip
Already compiling and running for Lua 5.0 (alpha)
Diffstat (limited to 'src/select.c')
-rw-r--r--src/select.c15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/select.c b/src/select.c
index 9a24dbb..1aaa7fe 100644
--- a/src/select.c
+++ b/src/select.c
@@ -31,9 +31,12 @@ void select_open(lua_State *L)
31{ 31{
32 /* push select auxiliar lua function and register 32 /* push select auxiliar lua function and register
33 * select_lua_select with it as an upvalue */ 33 * select_lua_select with it as an upvalue */
34#include "lsselect.loh" 34#ifdef LUASOCKET_DEBUG
35#endif
36 luaL_loadfile(L, "lsselect.lua");
37 lua_call(L, 0, 1);
35 lua_pushcclosure(L, select_lua_select, 1); 38 lua_pushcclosure(L, select_lua_select, 1);
36 lua_setglobal(L, "select"); 39 priv_newglobal(L, "select");
37 /* create luasocket(select) table */ 40 /* create luasocket(select) table */
38 lua_pushstring(L, "luasocket(select)"); 41 lua_pushstring(L, "luasocket(select)");
39 lua_newtable(L); 42 lua_newtable(L);
@@ -61,8 +64,8 @@ static int select_lua_select(lua_State *L)
61 /* make sure we have enough arguments (nil is the default) */ 64 /* make sure we have enough arguments (nil is the default) */
62 lua_settop(L, 4); 65 lua_settop(L, 4);
63 /* pass FD_SET and manipulation functions */ 66 /* pass FD_SET and manipulation functions */
64 lua_newuserdatabox(L, &read); 67 lua_boxpointer(L, &read);
65 lua_newuserdatabox(L, &write); 68 lua_boxpointer(L, &write);
66 lua_pushcfunction(L, local_FD_SET); 69 lua_pushcfunction(L, local_FD_SET);
67 lua_pushcfunction(L, local_FD_ISSET); 70 lua_pushcfunction(L, local_FD_ISSET);
68 /* pass getfd function with selectable table as upvalue */ 71 /* pass getfd function with selectable table as upvalue */
@@ -121,7 +124,7 @@ static int local_select(lua_State *L)
121static int local_FD_SET(lua_State *L) 124static int local_FD_SET(lua_State *L)
122{ 125{
123 COMPAT_FD fd = (COMPAT_FD) lua_tonumber(L, 1); 126 COMPAT_FD fd = (COMPAT_FD) lua_tonumber(L, 1);
124 fd_set *set = (fd_set *) lua_touserdata(L, 2); 127 fd_set *set = (fd_set *) lua_topointer(L, 2);
125 if (fd >= 0) FD_SET(fd, set); 128 if (fd >= 0) FD_SET(fd, set);
126 return 0; 129 return 0;
127} 130}
@@ -129,7 +132,7 @@ static int local_FD_SET(lua_State *L)
129static int local_FD_ISSET(lua_State *L) 132static int local_FD_ISSET(lua_State *L)
130{ 133{
131 COMPAT_FD fd = (COMPAT_FD) lua_tonumber(L, 1); 134 COMPAT_FD fd = (COMPAT_FD) lua_tonumber(L, 1);
132 fd_set *set = (fd_set *) lua_touserdata(L, 2); 135 fd_set *set = (fd_set *) lua_topointer(L, 2);
133 if (fd >= 0 && FD_ISSET(fd, set)) lua_pushnumber(L, 1); 136 if (fd >= 0 && FD_ISSET(fd, set)) lua_pushnumber(L, 1);
134 else lua_pushnil(L); 137 else lua_pushnil(L);
135 return 1; 138 return 1;