root/modules/misc/lua/vlc.h
| Revision 588723d7c65ccdb0fa5cc39b3cae132176637300, 5.1 kB (checked in by Rémi Duraffort <ivoire@videolan.org>, 4 months ago) | |
|---|---|
| |
| Line | |
|---|---|
| 1 | /***************************************************************************** |
| 2 | * vlc.h: VLC specific lua library functions. |
| 3 | ***************************************************************************** |
| 4 | * Copyright (C) 2007-2008 the VideoLAN team |
| 5 | * $Id$ |
| 6 | * |
| 7 | * Authors: Antoine Cellerier <dionoea at videolan tod org> |
| 8 | * Pierre d'Herbemont <pdherbemont # videolan.org> |
| 9 | * |
| 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. |
| 14 | * |
| 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. |
| 19 | * |
| 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 | *****************************************************************************/ |
| 24 | |
| 25 | #ifndef VLC_LUA_H |
| 26 | #define VLC_LUA_H |
| 27 | /***************************************************************************** |
| 28 | * Preamble |
| 29 | *****************************************************************************/ |
| 30 | |
| 31 | #include <vlc_common.h> |
| 32 | #include <vlc_input.h> |
| 33 | #include <vlc_playlist.h> |
| 34 | #include <vlc_meta.h> |
| 35 | #include <vlc_url.h> |
| 36 | #include <vlc_strings.h> |
| 37 | #include <vlc_stream.h> |
| 38 | #include <vlc_charset.h> |
| 39 | |
| 40 | #ifdef HAVE_SYS_STAT_H |
| 41 | # include <sys/stat.h> |
| 42 | #endif |
| 43 | |
| 44 | #include <lua.h> /* Low level lua C API */ |
| 45 | #include <lauxlib.h> /* Higher level C API */ |
| 46 | #include <lualib.h> /* Lua libs */ |
| 47 | |
| 48 | /***************************************************************************** |
| 49 | * Module entry points |
| 50 | *****************************************************************************/ |
| 51 | int FindArt( vlc_object_t * ); |
| 52 | |
| 53 | int Import_LuaPlaylist( vlc_object_t * ); |
| 54 | void Close_LuaPlaylist( vlc_object_t * ); |
| 55 | |
| 56 | int Open_LuaIntf( vlc_object_t * ); |
| 57 | void Close_LuaIntf( vlc_object_t * ); |
| 58 | |
| 59 | |
| 60 | /***************************************************************************** |
| 61 | * Lua debug |
| 62 | *****************************************************************************/ |
| 63 | static inline void lua_Dbg( vlc_object_t * p_this, const char * ppz_fmt, ... ) |
| 64 | { |
| 65 | va_list ap; |
| 66 | va_start( ap, ppz_fmt ); |
| 67 | __msg_GenericVa( ( vlc_object_t *)p_this, VLC_MSG_DBG, MODULE_STRING, |
| 68 | ppz_fmt, ap ); |
| 69 | va_end( ap ); |
| 70 | } |
| 71 | |
| 72 | /***************************************************************************** |
| 73 | * Functions that should be in lua ... but aren't for some obscure reason |
| 74 | *****************************************************************************/ |
| 75 | static inline int luaL_checkboolean( lua_State *L, int narg ) |
| 76 | { |
| 77 | luaL_checktype( L, narg, LUA_TBOOLEAN ); /* can raise an error */ |
| 78 | return lua_toboolean( L, narg ); |
| 79 | } |
| 80 | |
| 81 | static inline int luaL_optboolean( lua_State *L, int narg, int def ) |
| 82 | { |
| 83 | return luaL_opt( L, luaL_checkboolean, narg, def ); |
| 84 | } |
| 85 | |
| 86 | static inline const char *luaL_nilorcheckstring( lua_State *L, int narg ) |
| 87 | { |
| 88 | if( lua_isnil( L, narg ) ) |
| 89 | return NULL; |
| 90 | return luaL_checkstring( L, narg ); |
| 91 | } |
| 92 | |
| 93 | vlc_object_t * vlclua_get_this( lua_State * ); |
| 94 | |
| 95 | /***************************************************************************** |
| 96 | * Lua function bridge |
| 97 | *****************************************************************************/ |
| 98 | #define vlclua_error( L ) luaL_error( L, "VLC lua error in file %s line %d (function %s)", __FILE__, __LINE__, __func__ ) |
| 99 | int vlclua_push_ret( lua_State *, int i_error ); |
| 100 | |
| 101 | /***************************************************************************** |
| 102 | * Will execute func on all scripts in luadirname, and stop if func returns |
| 103 | * success. |
| 104 | *****************************************************************************/ |
| 105 | int vlclua_scripts_batch_execute( vlc_object_t *p_this, const char * luadirname, |
| 106 | int (*func)(vlc_object_t *, const char *, lua_State *, void *), |
| 107 | lua_State * L, void * user_data ); |
| 108 | int vlclua_dir_list( const char *luadirname, char **ppsz_dir_list ); |
| 109 | void vlclua_dir_list_free( char **ppsz_dir_list ); |
| 110 | |
| 111 | /***************************************************************************** |
| 112 | * Playlist and meta data internal utilities. |
| 113 | *****************************************************************************/ |
| 114 | void __vlclua_read_options( vlc_object_t *, lua_State *, int *, char *** ); |
| 115 | #define vlclua_read_options(a,b,c,d) __vlclua_read_options(VLC_OBJECT(a),b,c,d) |
| 116 | void __vlclua_read_meta_data( vlc_object_t *, lua_State *, input_item_t * ); |
| 117 | #define vlclua_read_meta_data(a,b,c) __vlclua_read_meta_data(VLC_OBJECT(a),b,c) |
| 118 | void __vlclua_read_custom_meta_data( vlc_object_t *, lua_State *, |
| 119 | input_item_t *); |
| 120 | #define vlclua_read_custom_meta_data(a,b,c) __vlclua_read_custom_meta_data(VLC_OBJECT(a),b,c) |
| 121 | int __vlclua_playlist_add_internal( vlc_object_t *, lua_State *, playlist_t *, |
| 122 | input_item_t *, bool ); |
| 123 | #define vlclua_playlist_add_internal(a,b,c,d,e) __vlclua_playlist_add_internal(VLC_OBJECT(a),b,c,d,e) |
| 124 | |
| 125 | |
| 126 | #endif /* VLC_LUA_H */ |
| 127 |
Note: See TracBrowser for help on using the browser.
