- /* In lua, setting a variable's value to nil is equivalent to deleting it */
- lua_pushnil( L );
- lua_pushnil( L );
- lua_setglobal( L, "probe" );
- lua_setglobal( L, "parse" );
+ /* Initialise Lua state structure */
+ lua_State *L = luaL_newstate();
+ if( !L )
+ {
+ msg_Err( p_demux, "Could not create new Lua State" );
+ goto error;
+ }
+ p_demux->p_sys->L = L;
+
+ /* Load Lua libraries */
+ luaL_openlibs( L ); /* FIXME: Don't open all the libs? */
+
+ luaL_register( L, "vlc", p_reg );
+ luaopen_msg( L );
+ luaopen_strings( L );
+ lua_pushlightuserdata( L, p_demux );
+ lua_setfield( L, -2, "private" );
+ lua_pushstring( L, p_demux->psz_path );
+ lua_setfield( L, -2, "path" );
+ lua_pushstring( L, p_demux->psz_access );
+ lua_setfield( L, -2, "access" );
+
+ lua_pop( L, 1 );