]> git.sesse.net Git - vlc/commitdiff
Remove vlc.net.select() and fd_set.
authorAntoine Cellerier <dionoea@videolan.org>
Sat, 9 Jan 2010 10:51:06 +0000 (11:51 +0100)
committerAntoine Cellerier <dionoea@videolan.org>
Sat, 9 Jan 2010 10:51:06 +0000 (11:51 +0100)
modules/misc/lua/libs/net.c
share/lua/README.txt

index f577211e988be32810b592bf63558c697f215321..ebe5b7852553c992d25de5be2bb069d82573c470 100644 (file)
@@ -216,98 +216,6 @@ static int vlclua_net_poll( lua_State *L )
     return 1;
 }
 
-static int vlclua_net_select( lua_State *L )
-{
-    int i_ret;
-    size_t i_nfds = luaL_checkint( L, 1 );
-    fd_set *fds_read = (fd_set*)luaL_checkudata( L, 2, "fd_set" );
-    fd_set *fds_write = (fd_set*)luaL_checkudata( L, 3, "fd_set" );
-    double f_timeout = luaL_checknumber( L, 4 );
-    struct timeval timeout;
-
-#ifndef WIN32
-    if( i_nfds > FD_SETSIZE )
-        i_nfds = FD_SETSIZE;
-#endif
-    if( f_timeout >= 0. )
-    {
-        timeout.tv_sec = (int)f_timeout;
-        timeout.tv_usec = (int)(1e6*(f_timeout-(double)((int)f_timeout)));
-    }
-    i_ret = select( i_nfds, fds_read, fds_write, 0, f_timeout >= 0. ? &timeout : NULL );
-    lua_pushinteger( L, i_ret );
-    return 1;
-}
-
-/*****************************************************************************
- *
- *****************************************************************************/
-static int vlclua_fd_clr( lua_State * );
-static int vlclua_fd_isset( lua_State * );
-static int vlclua_fd_set( lua_State * );
-static int vlclua_fd_zero( lua_State * );
-
-static const luaL_Reg vlclua_fd_set_reg[] = {
-    { "clr", vlclua_fd_clr },
-    { "isset", vlclua_fd_isset },
-    { "set", vlclua_fd_set },
-    { "zero", vlclua_fd_zero },
-    { NULL, NULL }
-};
-
-static int vlclua_fd_set_new( lua_State *L )
-{
-    fd_set *fds = (fd_set*)lua_newuserdata( L, sizeof( fd_set ) );
-    FD_ZERO( fds );
-
-    if( luaL_newmetatable( L, "fd_set" ) )
-    {
-        lua_newtable( L );
-        luaL_register( L, NULL, vlclua_fd_set_reg );
-        lua_setfield( L, -2, "__index" );
-    }
-
-    lua_setmetatable( L, -2 );
-    return 1;
-}
-
-static int vlclua_fd_clr( lua_State *L )
-{
-    fd_set *fds = (fd_set*)luaL_checkudata( L, 1, "fd_set" );
-    int i_fd = luaL_checkint( L, 2 );
-    FD_CLR( i_fd, fds );
-    return 0;
-}
-
-static int vlclua_fd_isset( lua_State *L )
-{
-    fd_set *fds = (fd_set*)luaL_checkudata( L, 1, "fd_set" );
-    int i_fd = luaL_checkint( L, 2 );
-    lua_pushboolean( L, FD_ISSET( i_fd, fds ) );
-    return 1;
-}
-
-static int vlclua_fd_set( lua_State *L )
-{
-    fd_set *fds = (fd_set*)luaL_checkudata( L, 1, "fd_set" );
-    size_t i_fd = luaL_checkint( L, 2 );
-    /* FIXME: we should really use poll() instead here, but that breaks the
-     * VLC/LUA API. On Windows, overflow protection is built-in FD_SET, not
-     * on POSIX. In both cases, run-time behavior will however be wrong. */
-#ifndef WIN32
-    if( i_fd < FD_SETSIZE )
-#endif
-        FD_SET( i_fd, fds );
-    return 0;
-}
-
-static int vlclua_fd_zero( lua_State *L )
-{
-    fd_set *fds = (fd_set*)luaL_checkudata( L, 1, "fd_set" );
-    FD_ZERO( fds );
-    return 0;
-}
-
 /*****************************************************************************
  *
  *****************************************************************************/
@@ -432,8 +340,6 @@ static const luaL_Reg vlclua_net_reg[] = {
     { "send", vlclua_net_send },
     { "recv", vlclua_net_recv },
     { "poll", vlclua_net_poll },
-    { "select", vlclua_net_select },
-    { "fd_set_new", vlclua_fd_set_new },
     { "read", vlclua_fd_read },
     { "write", vlclua_fd_write },
     { "stat", vlclua_stat }, /* Not really "net" */
index 1257d4eb030ea00a049e2e4916d0b6471f7d353f..960ebab3d124556415202ba7bf267a5b0b9a2c05 100644 (file)
@@ -114,7 +114,7 @@ net.url_parse( url, [option delimiter] ): Parse URL. Returns a table with
 net.listen_tcp( host, port ): Listen to TCP connections. This returns an
   object with an accept and an fds method. accept is blocking (Poll on the
   fds with the net.POLLIN flag if you want to be non blockin).
-  The fds method returns a list of fds you can call select on before using
+  The fds method returns a list of fds you can call poll on before using
   the accept method. For example:
 local l = vlc.net.listen_tcp( "localhost", 1234 )
 while true do
@@ -131,14 +131,6 @@ net.poll( { fd = events }, [timeout in seconds] ): Implement poll function.
   Retruns the numbers of file descriptors with a non 0 revent. The function
   modifies the input table to { fd = revents }. See "man poll".
 net.POLLIN/POLLPRI/POLLOUT/POLLRDHUP/POLLERR/POLLHUP/POLLNVAL: poll event flags
-net.select( nfds, fds_read, fds_write, timeout ): Monitor a bunch of file
-  descriptors. Returns number of fds to handle. See "man select".
-net.fd_set_new(): Create a new fd_set.
-local fds = vlc.net.fd_set_new()
-fds:clr( fd ) -- remove fd from set
-fds:isset( fd ) -- check if fd is set
-fds:set( fd ) -- add fd to set
-fds:zero() -- clear the set
 net.fd_read( fd, [max length] ): Read data from fd.
 net.fd_write( fd, string, [length] ): Write data to fd.
 net.stat( path ): Stat a file. Returns a table with the following fields: