1 /*****************************************************************************
2 * vlc.c: Generic lua interface 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 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
38 #include <vlc_common.h>
39 #include <vlc_plugin.h>
41 #include <vlc_charset.h>
44 #include <vlc_services_discovery.h>
47 #include <lua.h> /* Low level lua C API */
48 #include <lauxlib.h> /* Higher level C API */
49 #include <lualib.h> /* Lua libs */
53 /*****************************************************************************
55 *****************************************************************************/
56 #define INTF_TEXT N_("Lua interface")
57 #define INTF_LONGTEXT N_("Lua interface module to load")
59 #define CONFIG_TEXT N_("Lua interface configuration")
60 #define CONFIG_LONGTEXT N_("Lua interface configuration string. Format is: '[\"<interface module name>\"] = { <option> = <value>, ...}, ...'.")
61 #define HOST_TEXT N_( "Host address" )
62 #define HOST_LONGTEXT N_( \
63 "Address and port the HTTP interface will listen on. It defaults to " \
64 "all network interfaces (0.0.0.0)." \
65 " If you want the HTTP interface to be available only on the local " \
66 "machine, enter 127.0.0.1" )
67 #define SRC_TEXT N_( "Source directory" )
68 #define SRC_LONGTEXT N_( "Source directory" )
69 #define INDEX_TEXT N_( "Directory index" )
70 #define INDEX_LONGTEXT N_( "Allow to build directory index" )
72 #define TELNETHOST_TEXT N_( "Host" )
73 #define TELNETHOST_LONGTEXT N_( "This is the host on which the " \
74 "interface will listen. It defaults to all network interfaces (0.0.0.0)." \
75 " If you want this interface to be available only on the local " \
76 "machine, enter \"127.0.0.1\"." )
77 #define TELNETPORT_TEXT N_( "Port" )
78 #define TELNETPORT_LONGTEXT N_( "This is the TCP port on which this " \
79 "interface will listen. It defaults to 4212." )
80 #define TELNETPORT_DEFAULT 4212
81 #define TELNETPWD_TEXT N_( "Password" )
82 #define TELNETPWD_LONGTEXT N_( "A single administration password is used " \
83 "to protect this interface. The default value is \"admin\"." )
84 #define TELNETPWD_DEFAULT "admin"
85 #define RCHOST_TEXT N_("TCP command input")
86 #define RCHOST_LONGTEXT N_("Accept commands over a socket rather than stdin. " \
87 "You can set the address and port the interface will bind to." )
89 static int vlc_sd_probe_Open( vlc_object_t * );
92 set_shortname( N_("Lua Interface Module") )
93 set_description( N_("Interfaces implemented using lua scripts") )
94 add_shortcut( "luaintf" )
95 add_shortcut( "luahttp" )
96 /* add_shortcut( "http" ) */
97 add_shortcut( "luatelnet" )
98 add_shortcut( "telnet" )
99 add_shortcut( "luahotkeys" )
100 /* add_shortcut( "hotkeys" ) */
101 set_capability( "interface", 0 )
102 set_category( CAT_INTERFACE )
103 set_subcategory( SUBCAT_INTERFACE_CONTROL )
104 add_string( "lua-intf", "dummy",
105 INTF_TEXT, INTF_LONGTEXT, false )
106 add_string( "lua-config", "",
107 CONFIG_TEXT, CONFIG_LONGTEXT, false )
108 set_section( N_("Lua HTTP"), 0 )
109 add_string ( "http-host", NULL, HOST_TEXT, HOST_LONGTEXT, true )
110 add_string ( "http-src", NULL, SRC_TEXT, SRC_LONGTEXT, true )
111 add_bool ( "http-index", false, INDEX_TEXT, INDEX_LONGTEXT, true )
112 set_section( N_("Lua RC"), 0 )
113 add_string( "rc-host", NULL, RCHOST_TEXT, RCHOST_LONGTEXT, true )
114 set_section( N_("Lua Telnet"), 0 )
115 add_string( "telnet-host", "localhost", TELNETHOST_TEXT,
116 TELNETHOST_LONGTEXT, true )
117 add_integer( "telnet-port", TELNETPORT_DEFAULT, TELNETPORT_TEXT,
118 TELNETPORT_LONGTEXT, true )
119 add_password( "telnet-password", TELNETPWD_DEFAULT, TELNETPWD_TEXT,
120 TELNETPWD_LONGTEXT, true )
122 set_callbacks( Open_LuaIntf, Close_LuaIntf )
125 set_shortname( N_( "Lua Meta Fetcher" ) )
126 set_description( N_("Fetch meta data using lua scripts") )
127 set_capability( "meta fetcher", 10 )
128 set_callbacks( FetchMeta, NULL )
131 set_shortname( N_( "Lua Meta Reader" ) )
132 set_description( N_("Read meta data using lua scripts") )
133 set_capability( "meta reader", 10 )
134 set_callbacks( ReadMeta, NULL )
137 add_shortcut( "luaplaylist" )
138 set_shortname( N_("Lua Playlist") )
139 set_description( N_("Lua Playlist Parser Interface") )
140 set_capability( "demux", 2 )
141 set_callbacks( Import_LuaPlaylist, Close_LuaPlaylist )
144 set_description( N_("Lua Interface Module (shortcuts)") )
145 add_shortcut( "luarc" )
147 set_capability( "interface", 25 )
148 set_callbacks( Open_LuaIntf, Close_LuaIntf )
151 set_shortname( N_( "Lua Art" ) )
152 set_description( N_("Fetch artwork using lua scripts") )
153 set_capability( "art finder", 10 )
154 set_callbacks( FindArt, NULL )
157 set_shortname( N_("Lua Extension") )
158 add_shortcut( "luaextension" )
159 set_capability( "extension", 1 )
160 set_callbacks( Open_Extension, Close_Extension )
163 set_description( N_("Lua SD Module") )
164 add_shortcut( "luasd" )
165 set_capability( "services_discovery", 0 )
166 add_string( "lua-sd", "", NULL, NULL, false )
168 add_string( "lua-longname", "", NULL, NULL, false )
170 set_callbacks( Open_LuaSD, Close_LuaSD )
173 set_description( N_("Freebox TV") )
174 add_shortcut( "freebox" )
175 set_capability( "services_discovery", 0 )
176 set_callbacks( Open_LuaSD, Close_LuaSD )
179 set_description( N_("French TV") )
180 add_shortcut( "frenchtv" )
181 set_capability( "services_discovery", 0 )
182 set_callbacks( Open_LuaSD, Close_LuaSD )
184 VLC_SD_PROBE_SUBMODULE
188 /*****************************************************************************
190 *****************************************************************************/
191 static const char *ppsz_lua_exts[] = { ".luac", ".lua", NULL };
192 static int file_select( const char *file )
194 int i = strlen( file );
196 for( j = 0; ppsz_lua_exts[j]; j++ )
198 int l = strlen( ppsz_lua_exts[j] );
199 if( i >= l && !strcmp( file+i-l, ppsz_lua_exts[j] ) )
205 static int file_compare( const char **a, const char **b )
207 return strcmp( *a, *b );
210 int vlclua_dir_list( vlc_object_t *p_this, const char *luadirname,
211 char ***pppsz_dir_list )
213 #define MAX_DIR_LIST_SIZE 5
214 *pppsz_dir_list = malloc(MAX_DIR_LIST_SIZE*sizeof(char *));
215 if (!*pppsz_dir_list)
217 char **ppsz_dir_list = *pppsz_dir_list;
220 char *datadir = config_GetUserDir( VLC_DATA_DIR );
222 if( likely(datadir != NULL)
223 && likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s",
224 datadir, luadirname ) != -1) )
228 #if !(defined(__APPLE__) || defined(WIN32))
229 if( likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s",
230 config_GetLibDir(), luadirname ) != -1) )
234 char *psz_datapath = config_GetDataDir( p_this );
235 if( likely(psz_datapath != NULL) )
237 if( likely(asprintf( &ppsz_dir_list[i], "%s"DIR_SEP"lua"DIR_SEP"%s",
238 psz_datapath, luadirname ) != -1) )
241 #if defined(__APPLE__)
242 if( likely(asprintf( &ppsz_dir_list[i],
243 "%s"DIR_SEP"share"DIR_SEP"lua"DIR_SEP"%s",
244 psz_datapath, luadirname ) != -1) )
247 free( psz_datapath );
250 ppsz_dir_list[i] = NULL;
252 assert( i < MAX_DIR_LIST_SIZE);
257 void vlclua_dir_list_free( char **ppsz_dir_list )
259 for( char **ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
261 free( ppsz_dir_list );
264 /*****************************************************************************
265 * Will execute func on all scripts in luadirname, and stop if func returns
267 *****************************************************************************/
268 int vlclua_scripts_batch_execute( vlc_object_t *p_this,
269 const char * luadirname,
270 int (*func)(vlc_object_t *, const char *, void *),
273 char **ppsz_dir_list = NULL;
276 if((i_ret = vlclua_dir_list( p_this, luadirname, &ppsz_dir_list ) != VLC_SUCCESS))
279 i_ret = VLC_EGENERIC;
280 for( char **ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
282 char **ppsz_filelist;
284 msg_Dbg( p_this, "Trying Lua scripts in %s", *ppsz_dir );
285 int i_files = vlc_scandir( *ppsz_dir, &ppsz_filelist, file_select,
290 char **ppsz_file = ppsz_filelist;
291 char **ppsz_fileend = ppsz_filelist + i_files;
293 while( ppsz_file < ppsz_fileend )
297 if( asprintf( &psz_filename,
298 "%s" DIR_SEP "%s", *ppsz_dir, *ppsz_file ) == -1 )
300 free( *(ppsz_file++) );
302 if( likely(psz_filename != NULL) )
304 msg_Dbg( p_this, "Trying Lua playlist script %s",
306 i_ret = func( p_this, psz_filename, user_data );
307 free( psz_filename );
308 if( i_ret == VLC_SUCCESS )
313 while( ppsz_file < ppsz_fileend )
314 free( *(ppsz_file++) );
315 free( ppsz_filelist );
317 if( i_ret == VLC_SUCCESS )
320 vlclua_dir_list_free( ppsz_dir_list );
324 char *vlclua_find_file( vlc_object_t *p_this, const char *psz_luadirname, const char *psz_name )
326 char **ppsz_dir_list = NULL;
327 vlclua_dir_list( p_this, psz_luadirname, &ppsz_dir_list );
329 for( char **ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
331 for( const char **ppsz_ext = ppsz_lua_exts; *ppsz_ext; ppsz_ext++ )
336 if( asprintf( &psz_filename, "%s"DIR_SEP"%s%s", *ppsz_dir,
337 psz_name, *ppsz_ext ) < 0 )
339 vlclua_dir_list_free( ppsz_dir_list );
343 if( vlc_stat( psz_filename, &st ) == 0
344 && S_ISREG( st.st_mode ) )
346 vlclua_dir_list_free( ppsz_dir_list );
349 free( psz_filename );
352 vlclua_dir_list_free( ppsz_dir_list );
356 /*****************************************************************************
357 * Meta data setters utility.
358 * Playlist item table should be on top of the stack when these are called
359 *****************************************************************************/
360 void __vlclua_read_meta_data( vlc_object_t *p_this, lua_State *L,
361 input_item_t *p_input )
363 #define TRY_META( a, b ) \
364 lua_getfield( L, -1, a ); \
365 if( lua_isstring( L, -1 ) && \
366 strcmp( lua_tostring( L, -1 ), "" ) ) \
368 char *psz_value = strdup( lua_tostring( L, -1 ) ); \
369 EnsureUTF8( psz_value ); \
370 msg_Dbg( p_this, #b ": %s", psz_value ); \
371 input_item_Set ## b ( p_input, psz_value ); \
374 lua_pop( L, 1 ); /* pop a */
375 TRY_META( "title", Title );
376 TRY_META( "artist", Artist );
377 TRY_META( "genre", Genre );
378 TRY_META( "copyright", Copyright );
379 TRY_META( "album", Album );
380 TRY_META( "tracknum", TrackNum );
381 TRY_META( "description", Description );
382 TRY_META( "rating", Rating );
383 TRY_META( "date", Date );
384 TRY_META( "setting", Setting );
385 TRY_META( "url", URL );
386 TRY_META( "language", Language );
387 TRY_META( "nowplaying", NowPlaying );
388 TRY_META( "publisher", Publisher );
389 TRY_META( "encodedby", EncodedBy );
390 TRY_META( "arturl", ArtURL );
391 TRY_META( "trackid", TrackID );
394 void __vlclua_read_custom_meta_data( vlc_object_t *p_this, lua_State *L,
395 input_item_t *p_input )
398 lua_getfield( L, -1, "meta" );
400 if( lua_istable( L, -1 ) )
403 /* ... item meta nil */
404 while( lua_next( L, -2 ) )
406 /* ... item meta key value */
407 if( !lua_isstring( L, -2 ) )
409 msg_Warn( p_this, "Custom meta data category name must be "
412 else if( !lua_istable( L, -1 ) )
414 msg_Warn( p_this, "Custom meta data category contents "
419 const char *psz_meta_category = lua_tostring( L, -2 );
420 msg_Dbg( p_this, "Found custom meta data category: %s",
423 /* ... item meta key value nil */
424 while( lua_next( L, -2 ) )
426 /* ... item meta key value key2 value2 */
427 if( !lua_isstring( L, -2 ) )
429 msg_Warn( p_this, "Custom meta category item name "
430 "must be a string." );
432 else if( !lua_isstring( L, -1 ) )
434 msg_Warn( p_this, "Custom meta category item value "
435 "must be a string." );
439 const char *psz_meta_name =
440 lua_tostring( L, -2 );
441 const char *psz_meta_value =
442 lua_tostring( L, -1 );
443 msg_Dbg( p_this, "Custom meta %s, %s: %s",
444 psz_meta_category, psz_meta_name,
446 input_item_AddInfo( p_input, psz_meta_category,
447 psz_meta_name, "%s", psz_meta_value );
449 lua_pop( L, 1 ); /* pop item */
450 /* ... item meta key value key2 */
452 /* ... item meta key value */
454 lua_pop( L, 1 ); /* pop category */
455 /* ... item meta key */
459 lua_pop( L, 1 ); /* pop "meta" */
460 /* ... item -> back to original stack */
463 /*****************************************************************************
465 ****************************************************************************/
467 * Playlist item table should be on top of the stack when this is called
469 void __vlclua_read_options( vlc_object_t *p_this, lua_State *L,
470 int *pi_options, char ***pppsz_options )
472 lua_getfield( L, -1, "options" );
473 if( lua_istable( L, -1 ) )
476 while( lua_next( L, -2 ) )
478 if( lua_isstring( L, -1 ) )
480 char *psz_option = strdup( lua_tostring( L, -1 ) );
481 msg_Dbg( p_this, "Option: %s", psz_option );
482 INSERT_ELEM( *pppsz_options, *pi_options, *pi_options,
487 msg_Warn( p_this, "Option should be a string" );
489 lua_pop( L, 1 ); /* pop option */
492 lua_pop( L, 1 ); /* pop "options" */
495 int __vlclua_playlist_add_internal( vlc_object_t *p_this, lua_State *L,
496 playlist_t *p_playlist,
497 input_item_t *p_parent, bool b_play )
500 input_item_node_t *p_parent_node = NULL;
502 assert( p_parent || p_playlist );
505 if( lua_istable( L, -1 ) )
507 if( p_parent ) p_parent_node = input_item_node_Create( p_parent );
510 while( lua_next( L, -2 ) )
512 /* playlist key item */
513 /* <Parse playlist item> */
514 if( lua_istable( L, -1 ) )
516 lua_getfield( L, -1, "path" );
517 /* playlist key item path */
518 if( lua_isstring( L, -1 ) )
520 const char *psz_path = NULL;
521 const char *psz_name = NULL;
522 char **ppsz_options = NULL;
524 mtime_t i_duration = -1;
525 input_item_t *p_input;
527 /* Read path and name */
528 psz_path = lua_tostring( L, -1 );
529 msg_Dbg( p_this, "Path: %s", psz_path );
530 lua_getfield( L, -2, "name" );
531 /* playlist key item path name */
532 if( lua_isstring( L, -1 ) )
534 psz_name = lua_tostring( L, -1 );
535 msg_Dbg( p_this, "Name: %s", psz_name );
539 if( !lua_isnil( L, -1 ) )
540 msg_Warn( p_this, "Playlist item name should be a string." );
545 lua_getfield( L, -3, "duration" );
546 /* playlist key item path name duration */
547 if( lua_isnumber( L, -1 ) )
549 i_duration = (mtime_t)(lua_tonumber( L, -1 )*1e6);
551 else if( !lua_isnil( L, -1 ) )
553 msg_Warn( p_this, "Playlist item duration should be a number (in seconds)." );
555 lua_pop( L, 1 ); /* pop "duration" */
557 /* playlist key item path name */
559 /* Read options: item must be on top of stack */
560 lua_pushvalue( L, -3 );
561 /* playlist key item path name item */
562 vlclua_read_options( p_this, L, &i_options, &ppsz_options );
564 /* Create input item */
565 p_input = input_item_NewExt( p_playlist, psz_path,
567 (const char **)ppsz_options,
568 VLC_INPUT_OPTION_TRUSTED,
570 lua_pop( L, 3 ); /* pop "path name item" */
571 /* playlist key item */
573 /* Read meta data: item must be on top of stack */
574 vlclua_read_meta_data( p_this, L, p_input );
576 /* Read custom meta data: item must be on top of stack*/
577 vlclua_read_custom_meta_data( p_this, L, p_input );
579 /* Append item to playlist */
580 if( p_parent ) /* Add to node */
582 input_item_CopyOptions( p_parent, p_input );
583 input_item_node_AppendItem( p_parent_node, p_input );
585 else /* Play or Enqueue (preparse) */
586 /* FIXME: playlist_AddInput() can fail */
587 playlist_AddInput( p_playlist, p_input,
589 ( b_play ? PLAYLIST_GO : PLAYLIST_PREPARSE ),
590 PLAYLIST_END, true, false );
591 i_count ++; /* increment counter */
592 vlc_gc_decref( p_input );
593 while( i_options > 0 )
594 free( ppsz_options[--i_options] );
595 free( ppsz_options );
599 lua_pop( L, 1 ); /* pop "path" */
601 "Playlist item's path should be a string" );
603 /* playlist key item */
607 msg_Warn( p_this, "Playlist item should be a table" );
609 /* <Parse playlist item> */
610 lua_pop( L, 1 ); /* pop the value, keep the key for
611 * the next lua_next() call */
617 if( i_count ) input_item_node_PostAndDelete( p_parent_node );
618 else input_item_node_Delete( p_parent_node );
623 msg_Warn( p_this, "Playlist should be a table." );
628 static int vlc_sd_probe_Open( vlc_object_t *obj )
630 vlc_probe_t *probe = (vlc_probe_t *)obj;
631 char **ppsz_filelist = NULL;
632 char **ppsz_fileend = NULL;
635 char **ppsz_dir_list = NULL;
638 vlclua_dir_list( obj, "sd", &ppsz_dir_list );
639 for( ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
644 for( ppsz_file = ppsz_filelist; ppsz_file < ppsz_fileend;
647 free( ppsz_filelist );
648 ppsz_filelist = NULL;
650 i_files = vlc_scandir( *ppsz_dir, &ppsz_filelist, file_select,
652 if( i_files < 1 ) continue;
653 ppsz_fileend = ppsz_filelist + i_files;
654 for( ppsz_file = ppsz_filelist; ppsz_file < ppsz_fileend; ppsz_file++ )
657 if( asprintf( &psz_filename,
658 "%s" DIR_SEP "%s", *ppsz_dir, *ppsz_file ) < 0 )
665 msg_Err( probe, "Could not create new Lua State" );
666 free( psz_filename );
670 if( vlclua_add_modules_path( probe, L, psz_filename ) )
672 msg_Err( probe, "Error while setting the module search path for %s",
674 free( psz_filename );
677 if( luaL_dofile( L, psz_filename ) )
680 msg_Err( probe, "Error loading script %s: %s", psz_filename,
681 lua_tostring( L, lua_gettop( L ) ) );
683 free( psz_filename );
688 char *temp = strchr( *ppsz_file, '.' );
691 lua_getglobal( L, "descriptor" );
692 if( !lua_isfunction( L, lua_gettop( L ) ) || lua_pcall( L, 0, 1, 0 ) )
694 msg_Warn( probe, "No 'descriptor' function in '%s'", psz_filename );
696 if( !( psz_longname = strdup( *ppsz_file ) ) )
698 free( psz_filename );
704 lua_getfield( L, -1, "title" );
705 if( !lua_isstring( L, -1 ) ||
706 !( psz_longname = strdup( lua_tostring( L, -1 ) ) ) )
708 free( psz_filename );
713 char *psz_file_esc = config_StringEscape( *ppsz_file );
714 char *psz_longname_esc = config_StringEscape( psz_longname );
715 if( asprintf( &psz_name, "lua{sd='%s',longname='%s'}",
716 psz_file_esc, psz_longname_esc ) < 0 )
718 free( psz_file_esc );
719 free( psz_longname_esc );
720 free( psz_filename );
721 free( psz_longname );
724 free( psz_file_esc );
725 free( psz_longname_esc );
726 vlc_sd_probe_Add( probe, psz_name, psz_longname, SD_CAT_INTERNET );
728 free( psz_longname );
729 free( psz_filename );
735 for( ppsz_file = ppsz_filelist; ppsz_file < ppsz_fileend;
738 free( ppsz_filelist );
740 vlclua_dir_list_free( ppsz_dir_list );
741 return VLC_PROBE_CONTINUE;
745 for( ppsz_file = ppsz_filelist; ppsz_file < ppsz_fileend;
748 free( ppsz_filelist );
752 vlclua_dir_list_free( ppsz_dir_list );
756 static int vlclua_add_modules_path_inner( lua_State *L, const char *psz_path )
759 for( const char **ppsz_ext = ppsz_lua_exts; *ppsz_ext; ppsz_ext++ )
761 lua_pushfstring( L, "%s"DIR_SEP"modules"DIR_SEP"?%s;",
762 psz_path, *ppsz_ext );
769 int __vlclua_add_modules_path( vlc_object_t *obj, lua_State *L, const char *psz_filename )
771 /* Setup the module search path:
772 * * "The script's directory"/modules
773 * * "The script's parent directory"/modules
774 * * and so on for all the next directories in the directory list
776 char *psz_path = strdup( psz_filename );
780 char *psz_char = strrchr( psz_path, DIR_SEP_CHAR );
788 /* psz_path now holds the file's directory */
789 psz_char = strrchr( psz_path, DIR_SEP_CHAR );
797 /* Push package on stack */
799 lua_getglobal( L, "package" );
801 /* psz_path now holds the file's parent directory */
802 count += vlclua_add_modules_path_inner( L, psz_path );
803 *psz_char = DIR_SEP_CHAR;
805 /* psz_path now holds the file's directory */
806 count += vlclua_add_modules_path_inner( L, psz_path );
808 char **ppsz_dir_list = NULL;
809 vlclua_dir_list( obj, psz_char+1/* gruik? */, &ppsz_dir_list );
810 char **ppsz_dir = ppsz_dir_list;
812 for( ; *ppsz_dir && strcmp( *ppsz_dir, psz_path ); ppsz_dir++ );
815 for( ; *ppsz_dir; ppsz_dir++ )
817 psz_path = *ppsz_dir;
818 /* FIXME: doesn't work well with meta/... modules due to the double
820 psz_char = strrchr( psz_path, DIR_SEP_CHAR );
823 vlclua_dir_list_free( ppsz_dir_list );
828 count += vlclua_add_modules_path_inner( L, psz_path );
829 *psz_char = DIR_SEP_CHAR;
830 count += vlclua_add_modules_path_inner( L, psz_path );
833 lua_getfield( L, -(count+1), "path" ); /* Get package.path */
834 lua_concat( L, count+1 ); /* Concat vlc module paths and package.path */
835 lua_setfield( L, -2, "path"); /* Set package.path */
836 lua_pop( L, 1 ); /* Pop the package module */
838 vlclua_dir_list_free( ppsz_dir_list );