]> git.sesse.net Git - vlc/blob - modules/misc/lua/vlc.h
update module LIST file.
[vlc] / modules / misc / lua / vlc.h
1 /*****************************************************************************
2  * luameta.c: Get meta/artwork using lua scripts
3  *****************************************************************************
4  * Copyright (C) 2007 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/vlc.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 E_(FindArt)( vlc_object_t * );
52 int E_(FindMeta)( vlc_object_t * );
53
54 int E_(Import_LuaPlaylist)( vlc_object_t * );
55 void E_(Close_LuaPlaylist)( vlc_object_t * );
56
57 int E_(Open_LuaIntf)( vlc_object_t * );
58 void E_(Close_LuaIntf)( vlc_object_t * );
59
60
61 /*****************************************************************************
62  * Lua debug
63  *****************************************************************************/
64 static inline void lua_Dbg( vlc_object_t * p_this, const char * ppz_fmt, ... )
65 {
66     if( p_this->p_libvlc->i_verbose < 3 )
67         return;
68
69     va_list ap;
70     va_start( ap, ppz_fmt );
71     __msg_GenericVa( ( vlc_object_t *)p_this, MSG_QUEUE_NORMAL,
72                       VLC_MSG_DBG, MODULE_STRING,
73                       ppz_fmt, ap );
74     va_end( ap );
75 }
76
77 /*****************************************************************************
78  * Functions that should be in lua ... but aren't for some obscure reason
79  *****************************************************************************/
80 static inline int luaL_checkboolean( lua_State *L, int narg )
81 {
82     luaL_checktype( L, narg, LUA_TBOOLEAN ); /* can raise an error */
83     return lua_toboolean( L, narg );
84 }
85
86 static inline int luaL_optboolean( lua_State *L, int narg, int def )
87 {
88     return luaL_opt( L, luaL_checkboolean, narg, def );
89 }
90
91 static inline const void *luaL_checklightuserdata( lua_State *L, int narg )
92 {
93     luaL_checktype( L, narg, LUA_TLIGHTUSERDATA ); /* can raise an error */
94     return lua_topointer( L, narg );
95 }
96
97 static inline const void *luaL_checkuserdata( lua_State *L, int narg, size_t size )
98 {
99     luaL_checktype( L, narg, LUA_TUSERDATA ); /* can raise an error */
100     if( size && size != lua_objlen( L, narg ) ) /* this isn't worth much ... but it might still prevent a few errors */
101         luaL_error( L, "user data size doesn't match" );
102     return lua_topointer( L, narg );
103 }
104
105 static inline const char *luaL_nilorcheckstring( lua_State *L, int narg )
106 {
107     if( lua_isnil( L, narg ) )
108         return NULL;
109     return luaL_checkstring( L, narg );
110 }
111
112 /*****************************************************************************
113  * Lua vlc_object_t wrapper
114  *****************************************************************************/
115 int __vlclua_push_vlc_object( lua_State *L, vlc_object_t *p_obj,
116                               lua_CFunction pf_gc );
117 #define vlclua_push_vlc_object( a, b, c ) \
118         __vlclua_push_vlc_object( a, VLC_OBJECT( b ), c )
119 vlc_object_t *vlclua_checkobject( lua_State *L, int narg, int i_type );
120 int vlclua_gc_release( lua_State *L );
121 int vlclua_object_find( lua_State *L );
122 int vlclua_object_find_name( lua_State *L );
123
124 vlc_object_t * vlclua_get_this( lua_State * );
125 playlist_t *vlclua_get_playlist_internal( lua_State * );
126
127 int vlclua_add_callback( lua_State * );
128 int vlclua_del_callback( lua_State * );
129
130 int vlclua_url_parse( lua_State * );
131 int vlclua_net_listen_tcp( lua_State * );
132 int vlclua_net_listen_close( lua_State * );
133 int vlclua_net_accept( lua_State * );
134 int vlclua_net_close( lua_State * );
135 int vlclua_net_send( lua_State * );
136 int vlclua_net_recv( lua_State * );
137 int vlclua_net_select( lua_State * );
138
139 int vlclua_fd_set_new( lua_State * );
140 int vlclua_fd_clr( lua_State * );
141 int vlclua_fd_isset( lua_State * );
142 int vlclua_fd_set( lua_State * );
143 int vlclua_fd_zero( lua_State * );
144 int vlclua_fd_read( lua_State * );
145 int vlclua_fd_write( lua_State * );
146
147 int vlclua_stat( lua_State * );
148 int vlclua_opendir( lua_State * );
149
150 int vlclua_vlm_new( lua_State * );
151 int vlclua_vlm_delete( lua_State * );
152 int vlclua_vlm_execute_command( lua_State * );
153
154 int vlclua_httpd_tls_host_new( lua_State *L );
155 int vlclua_httpd_host_delete( lua_State *L );
156 int vlclua_httpd_handler_new( lua_State * L );
157 int vlclua_httpd_handler_delete( lua_State *L );
158 int vlclua_httpd_file_new( lua_State *L );
159 int vlclua_httpd_file_delete( lua_State *L );
160 int vlclua_httpd_redirect_new( lua_State *L );
161 int vlclua_httpd_redirect_delete( lua_State *L );
162
163 int vlclua_acl_create( lua_State * );
164 int vlclua_acl_delete( lua_State * );
165 int vlclua_acl_check( lua_State * );
166 int vlclua_acl_duplicate( lua_State * );
167 int vlclua_acl_add_host( lua_State * );
168 int vlclua_acl_add_net( lua_State * );
169 int vlclua_acl_load_file( lua_State * );
170
171 int vlclua_sd_get_services_names( lua_State * );
172 int vlclua_sd_add( lua_State * );
173 int vlclua_sd_remove( lua_State * );
174 int vlclua_sd_is_loaded( lua_State * );
175
176
177 /*****************************************************************************
178  * Lua function bridge
179  *****************************************************************************/
180 #define vlclua_error( L ) luaL_error( L, "VLC lua error in file %s line %d (function %s)", __FILE__, __LINE__, __func__ )
181 int vlclua_push_ret( lua_State *, int i_error );
182
183 int vlclua_version( lua_State * );
184 int vlclua_license( lua_State * );
185 int vlclua_copyright( lua_State * );
186 int vlclua_quit( lua_State * );
187
188 int vlclua_datadir( lua_State * );
189 int vlclua_homedir( lua_State * );
190 int vlclua_configdir( lua_State * );
191 int vlclua_cachedir( lua_State * );
192 int vlclua_datadir_list( lua_State * );
193
194 int vlclua_pushvalue( lua_State *L, int i_type, vlc_value_t val ); /* internal use only */
195 int vlclua_var_get( lua_State * );
196 int vlclua_var_get_list( lua_State * );
197 int vlclua_var_set( lua_State * );
198 int vlclua_module_command( lua_State * );
199 int vlclua_libvlc_command( lua_State * );
200
201 int vlclua_config_get( lua_State * );
202 int vlclua_config_set( lua_State * );
203
204 int vlclua_volume_set( lua_State * );
205 int vlclua_volume_get( lua_State * );
206 int vlclua_volume_up( lua_State * );
207 int vlclua_volume_down( lua_State * );
208
209 int vlclua_stream_new( lua_State * );
210 int vlclua_stream_read( lua_State * );
211 int vlclua_stream_readline( lua_State * );
212 int vlclua_stream_delete( lua_State * );
213
214 int vlclua_decode_uri( lua_State * );
215 int vlclua_resolve_xml_special_chars( lua_State * );
216 int vlclua_convert_xml_special_chars( lua_State * );
217
218 int vlclua_msg_dbg( lua_State * );
219 int vlclua_msg_warn( lua_State * );
220 int vlclua_msg_err( lua_State * );
221 int vlclua_msg_info( lua_State * );
222
223 /*****************************************************************************
224  * Will execute func on all scripts in luadirname, and stop if func returns
225  * success.
226  *****************************************************************************/
227 int vlclua_scripts_batch_execute( vlc_object_t *p_this, const char * luadirname,
228         int (*func)(vlc_object_t *, const char *, lua_State *, void *),
229         lua_State * L, void * user_data );
230 int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname, char **ppsz_dir_list );
231
232 /*****************************************************************************
233  * Playlist and meta data internal utilities.
234  *****************************************************************************/
235 void __vlclua_read_options( vlc_object_t *, lua_State *, int *, char *** );
236 #define vlclua_read_options(a,b,c,d) __vlclua_read_options(VLC_OBJECT(a),b,c,d)
237 void __vlclua_read_meta_data( vlc_object_t *, lua_State *, input_item_t * );
238 #define vlclua_read_meta_data(a,b,c) __vlclua_read_meta_data(VLC_OBJECT(a),b,c)
239 void __vlclua_read_custom_meta_data( vlc_object_t *, lua_State *,
240                                      input_item_t *);
241 #define vlclua_read_custom_meta_data(a,b,c) __vlclua_read_custom_meta_data(VLC_OBJECT(a),b,c)
242 int __vlclua_playlist_add_internal( vlc_object_t *, lua_State *, playlist_t *,
243                                     input_item_t *, vlc_bool_t );
244 #define vlclua_playlist_add_internal(a,b,c,d,e) __vlclua_playlist_add_internal(VLC_OBJECT(a),b,c,d,e)
245
246
247 #endif /* VLC_LUA_H */
248