1 /*****************************************************************************
2 * configuration.c: Generic lua<->vlc config inteface
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 *****************************************************************************/
37 #include <lua.h> /* Low level lua C API */
38 #include <lauxlib.h> /* Higher level C API */
39 #include <lualib.h> /* Lua libs */
43 /*****************************************************************************
45 *****************************************************************************/
46 int vlclua_config_get( lua_State *L )
48 vlc_object_t * p_this = vlclua_get_this( L );
50 psz_name = luaL_checkstring( L, 1 );
51 switch( config_GetType( p_this, psz_name ) )
56 case VLC_VAR_DIRECTORY:
57 lua_pushstring( L, config_GetPsz( p_this, psz_name ) );
61 lua_pushinteger( L, config_GetInt( p_this, psz_name ) );
65 lua_pushboolean( L, config_GetInt( p_this, psz_name ) );
69 lua_pushnumber( L, config_GetFloat( p_this, psz_name ) );
73 return vlclua_error( L );
79 int vlclua_config_set( lua_State *L )
81 vlc_object_t *p_this = vlclua_get_this( L );
83 psz_name = luaL_checkstring( L, 1 );
84 switch( config_GetType( p_this, psz_name ) )
89 case VLC_VAR_DIRECTORY:
90 config_PutPsz( p_this, psz_name, luaL_checkstring( L, 2 ) );
94 config_PutInt( p_this, psz_name, luaL_checkint( L, 2 ) );
98 config_PutInt( p_this, psz_name, luaL_checkboolean( L, 2 ) );
102 config_PutFloat( p_this, psz_name,
103 luaL_checknumber( L, 2 ) );
107 return vlclua_error( L );