]> git.sesse.net Git - vlc/blobdiff - modules/misc/lua/libs/misc.c
Experimental lua gettext support.
[vlc] / modules / misc / lua / libs / misc.c
index e080d2776cf6dc4bd36637c7366acd7e97590d4f..09a8e272701b7f9e91fb68c141b15f6c8b938347 100644 (file)
@@ -39,6 +39,7 @@
 #include <vlc_charset.h>
 #include <vlc_aout.h>
 #include <vlc_interface.h>
+#include <vlc_keys.h>
 
 #include <lua.h>        /* Low level lua C API */
 #include <lauxlib.h>    /* Higher level C API */
@@ -114,13 +115,17 @@ static int vlclua_quit( lua_State *L )
  *****************************************************************************/
 static int vlclua_datadir( lua_State *L )
 {
-    lua_pushstring( L, config_GetDataDir() );
+    char *psz_data = config_GetDataDir( vlclua_get_this( L ) );
+    lua_pushstring( L, psz_data );
+    free( psz_data );
     return 1;
 }
 
 static int vlclua_userdatadir( lua_State *L )
 {
-    lua_pushstring( L, config_GetUserDataDir() );
+    char *dir = config_GetUserDir( VLC_DATA_DIR );
+    lua_pushstring( L, dir );
+    free( dir );
     return 1;
 }
 
@@ -142,7 +147,7 @@ static int vlclua_configdir( lua_State *L )
 
 static int vlclua_cachedir( lua_State *L )
 {
-    char *dir = config_GetCacheDir();
+    char *dir = config_GetUserDir( VLC_CACHE_DIR );
     lua_pushstring( L, dir );
     free( dir );
     return 1;
@@ -155,7 +160,8 @@ static int vlclua_datadir_list( lua_State *L )
     char **ppsz_dir = ppsz_dir_list;
     int i = 1;
 
-    if( vlclua_dir_list( psz_dirname, ppsz_dir_list ) != VLC_SUCCESS )
+    if( vlclua_dir_list( vlclua_get_this( L ), psz_dirname, ppsz_dir_list )
+        != VLC_SUCCESS )
         return 0;
     lua_newtable( L );
     for( ; *ppsz_dir; ppsz_dir++ )
@@ -176,9 +182,10 @@ static int vlclua_lock_and_wait( lua_State *L )
     intf_sys_t *p_sys = p_intf->p_sys;
 
     vlc_mutex_lock( &p_sys->lock );
+    mutex_cleanup_push( &p_sys->lock );
     while( !p_sys->exiting )
         vlc_cond_wait( &p_sys->wait, &p_sys->lock );
-    vlc_mutex_unlock( &p_sys->lock );
+    vlc_cleanup_pop();
     lua_pushboolean( L, 1 );
     return 1;
 }
@@ -203,6 +210,15 @@ static int vlclua_intf_should_die( lua_State *L )
     return 1;
 }
 
+static int vlclua_action_id( lua_State *L )
+{
+    vlc_key_t i_key = vlc_GetActionId( luaL_checkstring( L, 1 ) );
+    if (i_key == 0)
+        return 0;
+    lua_pushnumber( L, i_key );
+    return 1;
+}
+
 /*****************************************************************************
  *
  *****************************************************************************/
@@ -218,6 +234,8 @@ static const luaL_Reg vlclua_misc_reg[] = {
     { "cachedir", vlclua_cachedir },
     { "datadir_list", vlclua_datadir_list },
 
+    { "action_id", vlclua_action_id },
+
     { "mdate", vlclua_mdate },
     { "mwait", vlclua_mwait },