1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2007-2008 the VideoLAN team
7 * Authors: Antoine Cellerier <dionoea at videolan tod org>
8 * Pierre d'Herbemont <pdherbemont # videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
36 #include <vlc_common.h>
37 #include <vlc_plugin.h>
41 #include <lua.h> /* Low level lua C API */
42 #include <lauxlib.h> /* Higher level C API */
43 #include <lualib.h> /* Lua libs */
48 /*****************************************************************************
49 * Messaging facilities
50 *****************************************************************************/
51 static int vlclua_msg_dbg( lua_State *L )
53 int i_top = lua_gettop( L );
54 vlc_object_t *p_this = vlclua_get_this( L );
56 for( i = 1; i <= i_top; i++ )
57 msg_Dbg( p_this, "%s", luaL_checkstring( L, 1 ) );
61 static int vlclua_msg_warn( lua_State *L )
63 int i_top = lua_gettop( L );
64 vlc_object_t *p_this = vlclua_get_this( L );
66 for( i = 1; i <= i_top; i++ )
67 msg_Warn( p_this, "%s", luaL_checkstring( L, i ) );
71 static int vlclua_msg_err( lua_State *L )
73 int i_top = lua_gettop( L );
74 vlc_object_t *p_this = vlclua_get_this( L );
76 for( i = 1; i <= i_top; i++ )
77 msg_Err( p_this, "%s", luaL_checkstring( L, i ) );
81 static int vlclua_msg_info( lua_State *L )
83 int i_top = lua_gettop( L );
84 vlc_object_t *p_this = vlclua_get_this( L );
86 for( i = 1; i <= i_top; i++ )
87 msg_Info( p_this, "%s", luaL_checkstring( L, i ) );
91 /*****************************************************************************
93 *****************************************************************************/
94 static const luaL_Reg vlclua_msg_reg[] = {
95 { "dbg", vlclua_msg_dbg },
96 { "warn", vlclua_msg_warn },
97 { "err", vlclua_msg_err },
98 { "info", vlclua_msg_info },
102 void luaopen_msg( lua_State *L )
105 luaL_register( L, NULL, vlclua_msg_reg );
106 lua_setfield( L, -2, "msg" );