1 /*****************************************************************************
2 * vlc.h: VLC specific lua library functions.
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 *****************************************************************************/
27 /*****************************************************************************
29 *****************************************************************************/
31 #include <vlc_common.h>
32 #include <vlc_input.h>
33 #include <vlc_playlist.h>
36 #include <vlc_strings.h>
37 #include <vlc_stream.h>
38 #include <vlc_charset.h>
40 #include <lua.h> /* Low level lua C API */
41 #include <lauxlib.h> /* Higher level C API */
42 #include <lualib.h> /* Lua libs */
44 /*****************************************************************************
46 *****************************************************************************/
47 int ReadMeta( vlc_object_t * );
48 int FetchMeta( vlc_object_t * );
49 int FindArt( vlc_object_t * );
51 int Import_LuaPlaylist( vlc_object_t * );
52 void Close_LuaPlaylist( vlc_object_t * );
54 int Open_LuaIntf( vlc_object_t * );
55 void Close_LuaIntf( vlc_object_t * );
57 int Open_Extension( vlc_object_t * );
58 void Close_Extension( vlc_object_t * );
60 int Open_LuaSD( vlc_object_t * );
61 void Close_LuaSD( vlc_object_t * );
63 /*****************************************************************************
65 *****************************************************************************/
66 static inline void lua_Dbg( vlc_object_t * p_this, const char * ppz_fmt, ... )
69 va_start( ap, ppz_fmt );
70 msg_GenericVa( p_this, VLC_MSG_DBG, MODULE_STRING, ppz_fmt, ap );
74 /*****************************************************************************
75 * Functions that should be in lua ... but aren't for some obscure reason
76 *****************************************************************************/
77 static inline int luaL_checkboolean( lua_State *L, int narg )
79 luaL_checktype( L, narg, LUA_TBOOLEAN ); /* can raise an error */
80 return lua_toboolean( L, narg );
83 static inline int luaL_optboolean( lua_State *L, int narg, int def )
85 return luaL_opt( L, luaL_checkboolean, narg, def );
88 static inline const char *luaL_nilorcheckstring( lua_State *L, int narg )
90 if( lua_isnil( L, narg ) )
92 return luaL_checkstring( L, narg );
95 vlc_object_t * vlclua_get_this( lua_State * );
97 /*****************************************************************************
99 *****************************************************************************/
100 #define vlclua_error( L ) luaL_error( L, "VLC lua error in file %s line %d (function %s)", __FILE__, __LINE__, __func__ )
101 int vlclua_push_ret( lua_State *, int i_error );
103 /*****************************************************************************
104 * Will execute func on all scripts in luadirname, and stop if func returns
106 *****************************************************************************/
107 int vlclua_scripts_batch_execute( vlc_object_t *p_this, const char * luadirname,
108 int (*func)(vlc_object_t *, const char *, lua_State *, void *),
109 lua_State * L, void * user_data );
110 int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname, char **ppsz_dir_list );
111 void vlclua_dir_list_free( char **ppsz_dir_list );
112 char *vlclua_find_file( vlc_object_t *p_this, const char *psz_luadirname, const char *psz_name );
114 /*****************************************************************************
115 * Playlist and meta data internal utilities.
116 *****************************************************************************/
117 void __vlclua_read_options( vlc_object_t *, lua_State *, int *, char *** );
118 #define vlclua_read_options(a,b,c,d) __vlclua_read_options(VLC_OBJECT(a),b,c,d)
119 void __vlclua_read_meta_data( vlc_object_t *, lua_State *, input_item_t * );
120 #define vlclua_read_meta_data(a,b,c) __vlclua_read_meta_data(VLC_OBJECT(a),b,c)
121 void __vlclua_read_custom_meta_data( vlc_object_t *, lua_State *,
123 #define vlclua_read_custom_meta_data(a,b,c) __vlclua_read_custom_meta_data(VLC_OBJECT(a),b,c)
124 int __vlclua_playlist_add_internal( vlc_object_t *, lua_State *, playlist_t *,
125 input_item_t *, bool );
126 #define vlclua_playlist_add_internal(a,b,c,d,e) __vlclua_playlist_add_internal(VLC_OBJECT(a),b,c,d,e)
129 * Per-interface private state
142 #endif /* VLC_LUA_H */