vlc.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * vlc.h: VLC specific lua library functions.
00003  *****************************************************************************
00004  * Copyright (C) 2007-2008 the VideoLAN team
00005  * $Id$
00006  *
00007  * Authors: Antoine Cellerier <dionoea at videolan tod org>
00008  *          Pierre d'Herbemont <pdherbemont # videolan.org>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
00023  *****************************************************************************/
00024 
00025 #ifndef VLC_LUA_H
00026 #define VLC_LUA_H
00027 /*****************************************************************************
00028  * Preamble
00029  *****************************************************************************/
00030 
00031 #include <vlc_common.h>
00032 #include <vlc_input.h>
00033 #include <vlc_playlist.h>
00034 #include <vlc_meta.h>
00035 #include <vlc_url.h>
00036 #include <vlc_strings.h>
00037 #include <vlc_stream.h>
00038 #include <vlc_charset.h>
00039 
00040 #ifdef HAVE_SYS_STAT_H
00041 #   include <sys/stat.h>
00042 #endif
00043 
00044 #include <lua.h>        /* Low level lua C API */
00045 #include <lauxlib.h>    /* Higher level C API */
00046 #include <lualib.h>     /* Lua libs */
00047 
00048 /*****************************************************************************
00049  * Module entry points
00050  *****************************************************************************/
00051 int FindArt( vlc_object_t * );
00052 
00053 int Import_LuaPlaylist( vlc_object_t * );
00054 void Close_LuaPlaylist( vlc_object_t * );
00055 
00056 int Open_LuaIntf( vlc_object_t * );
00057 void Close_LuaIntf( vlc_object_t * );
00058 
00059 
00060 /*****************************************************************************
00061  * Lua debug
00062  *****************************************************************************/
00063 static inline void lua_Dbg( vlc_object_t * p_this, const char * ppz_fmt, ... )
00064 {
00065     va_list ap;
00066     va_start( ap, ppz_fmt );
00067     __msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_DBG, MODULE_STRING,
00068                       ppz_fmt, ap );
00069     va_end( ap );
00070 }
00071 
00072 /*****************************************************************************
00073  * Functions that should be in lua ... but aren't for some obscure reason
00074  *****************************************************************************/
00075 static inline int luaL_checkboolean( lua_State *L, int narg )
00076 {
00077     luaL_checktype( L, narg, LUA_TBOOLEAN ); /* can raise an error */
00078     return lua_toboolean( L, narg );
00079 }
00080 
00081 static inline int luaL_optboolean( lua_State *L, int narg, int def )
00082 {
00083     return luaL_opt( L, luaL_checkboolean, narg, def );
00084 }
00085 
00086 static inline const char *luaL_nilorcheckstring( lua_State *L, int narg )
00087 {
00088     if( lua_isnil( L, narg ) )
00089         return NULL;
00090     return luaL_checkstring( L, narg );
00091 }
00092 
00093 vlc_object_t * vlclua_get_this( lua_State * );
00094 
00095 /*****************************************************************************
00096  * Lua function bridge
00097  *****************************************************************************/
00098 #define vlclua_error( L ) luaL_error( L, "VLC lua error in file %s line %d (function %s)", __FILE__, __LINE__, __func__ )
00099 int vlclua_push_ret( lua_State *, int i_error );
00100 
00101 /*****************************************************************************
00102  * Will execute func on all scripts in luadirname, and stop if func returns
00103  * success.
00104  *****************************************************************************/
00105 int vlclua_scripts_batch_execute( vlc_object_t *p_this, const char * luadirname,
00106         int (*func)(vlc_object_t *, const char *, lua_State *, void *),
00107         lua_State * L, void * user_data );
00108 int vlclua_dir_list( const char *luadirname, char **ppsz_dir_list );
00109 void vlclua_dir_list_free( char **ppsz_dir_list );
00110 
00111 /*****************************************************************************
00112  * Playlist and meta data internal utilities.
00113  *****************************************************************************/
00114 void __vlclua_read_options( vlc_object_t *, lua_State *, int *, char *** );
00115 #define vlclua_read_options(a,b,c,d) __vlclua_read_options(VLC_OBJECT(a),b,c,d)
00116 void __vlclua_read_meta_data( vlc_object_t *, lua_State *, input_item_t * );
00117 #define vlclua_read_meta_data(a,b,c) __vlclua_read_meta_data(VLC_OBJECT(a),b,c)
00118 void __vlclua_read_custom_meta_data( vlc_object_t *, lua_State *,
00119                                      input_item_t *);
00120 #define vlclua_read_custom_meta_data(a,b,c) __vlclua_read_custom_meta_data(VLC_OBJECT(a),b,c)
00121 int __vlclua_playlist_add_internal( vlc_object_t *, lua_State *, playlist_t *,
00122                                     input_item_t *, bool );
00123 #define vlclua_playlist_add_internal(a,b,c,d,e) __vlclua_playlist_add_internal(VLC_OBJECT(a),b,c,d,e)
00124 
00125 
00126 #endif /* VLC_LUA_H */
00127 

Generated on Wed Aug 13 08:02:37 2008 for VLC by  doxygen 1.5.1