1 /*****************************************************************************
2 * acl.c: Access list related functions
3 *****************************************************************************
4 * Copyright (C) 2007 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea at videolan tod org>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22 *****************************************************************************/
24 /*****************************************************************************
26 *****************************************************************************/
38 #include <lua.h> /* Low level lua C API */
39 #include <lauxlib.h> /* Higher level C API */
40 #include <lualib.h> /* Lua libs */
44 /*****************************************************************************
46 *****************************************************************************/
47 int vlclua_acl_create( lua_State *L )
49 vlc_object_t *p_this = vlclua_get_this( L );
50 vlc_bool_t b_allow = luaL_checkboolean( L, 1 ) ? VLC_TRUE : VLC_FALSE;
51 vlc_acl_t *p_acl = ACL_Create( p_this, b_allow );
53 return luaL_error( L, "ACL creation failed." );
54 lua_pushlightuserdata( L, p_acl ); /* FIXME */
58 int vlclua_acl_delete( lua_State *L )
60 vlc_acl_t *p_acl = (vlc_acl_t*)luaL_checklightuserdata( L, 1 );
65 int vlclua_acl_check( lua_State *L )
67 vlc_acl_t *p_acl = (vlc_acl_t*)luaL_checklightuserdata( L, 1 );
68 const char *psz_ip = luaL_checkstring( L, 2 );
69 lua_pushinteger( L, ACL_Check( p_acl, psz_ip ) );
73 int vlclua_acl_duplicate( lua_State *L )
75 vlc_object_t *p_this = vlclua_get_this( L );
76 vlc_acl_t *p_acl = (vlc_acl_t*)luaL_checklightuserdata( L, 1 );
77 vlc_acl_t *p_acl_new = ACL_Duplicate( p_this, p_acl );
78 lua_pushlightuserdata( L, p_acl_new );
82 int vlclua_acl_add_host( lua_State *L )
84 vlc_acl_t *p_acl = (vlc_acl_t*)luaL_checklightuserdata( L, 1 );
85 const char *psz_ip = luaL_checkstring( L, 2 );
86 vlc_bool_t b_allow = luaL_checkboolean( L, 3 ) ? VLC_TRUE : VLC_FALSE;
87 lua_pushinteger( L, ACL_AddHost( p_acl, psz_ip, b_allow ) );
91 int vlclua_acl_add_net( lua_State *L )
93 vlc_acl_t *p_acl = (vlc_acl_t*)luaL_checklightuserdata( L, 1 );
94 const char *psz_ip = luaL_checkstring( L, 2 );
95 int i_len = luaL_checkint( L, 3 );
96 vlc_bool_t b_allow = luaL_checkboolean( L, 4 ) ? VLC_TRUE : VLC_FALSE;
97 lua_pushinteger( L, ACL_AddNet( p_acl, psz_ip, i_len, b_allow ) );
101 int vlclua_acl_load_file( lua_State *L )
103 vlc_acl_t *p_acl = (vlc_acl_t*)luaL_checklightuserdata( L, 1 );
104 const char *psz_path = luaL_checkstring( L, 2 );
105 lua_pushinteger( L, ACL_LoadFile( p_acl, psz_path ) );