]> git.sesse.net Git - vlc/blobdiff - modules/misc/lua/vlclua.c
Removes trailing spaces. Removes tabs.
[vlc] / modules / misc / lua / vlclua.c
index f8a0a0b669a18d5224171df5b5827835c1fad8e8..fabbdd9b79e428a9423f8c828e9444d73d25c906 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************
- * luameta.c: Get meta/artwork using lua scripts
+ * vlclua.c: Generic lua inteface functions
  *****************************************************************************
- * Copyright (C) 2006 the VideoLAN team
- * $Id: luameta.c 21327 2007-08-20 19:23:10Z courmisch $
+ * Copyright (C) 2007 the VideoLAN team
+ * $Id$
  *
  * Authors: Antoine Cellerier <dionoea at videolan tod org>
  *          Pierre d'Herbemont <pdherbemont # videolan.org>
  *****************************************************************************/
 
 vlc_module_begin();
-    add_shortcut( "lua" );
+    add_shortcut( "luameta" );
+    set_shortname( N_( "Lua Meta" ) );
+    set_description( _("Fetch metadata using lua scripts") );
+    set_capability( "meta fetcher", 10 );
+    set_callbacks( E_(FindMeta), NULL );
     add_submodule();
-        add_shortcut( "luameta" );
-        set_shortname( N_( "Lua Meta" ) );
-        set_description( _("Fetch Artwork using lua scripts") );
-        set_capability( "meta fetcher", 10 );
-        set_callbacks( E_(FindMeta), NULL );
-        add_submodule();
-            set_capability( "art finder", 10 );
-            set_callbacks( E_(FindArt), NULL );
+        set_shortname( N_( "Lua Art" ) );
+        set_description( _("Fetch artwork using lua scripts") );
+        set_capability( "art finder", 10 );
+        set_callbacks( E_(FindArt), NULL );
     add_submodule();
         add_shortcut( "luaplaylist" );
         set_category( CAT_INPUT );
         set_subcategory( SUBCAT_INPUT_DEMUX );
-
         set_shortname( _("Lua Playlist") );
         set_description( _("Lua Playlist Parser Interface") );
         set_capability( "demux2", 9 );
@@ -245,8 +244,8 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
     char  *ppsz_dir_list[] = { NULL, NULL, NULL, NULL };
     char **ppsz_dir;
 
-    if( asprintf( &ppsz_dir_list[0], "%s" DIR_SEP CONFIG_DIR DIR_SEP "%s", p_this->p_libvlc->psz_homedir,
-            luadirname ) < 0 )
+    if( asprintf( &ppsz_dir_list[0], "%s" DIR_SEP "%s",
+                   p_this->p_libvlc->psz_datadir, luadirname ) < 0 )
         return VLC_ENOMEM;
 
 #   if defined(__APPLE__) || defined(SYS_BEOS) || defined(WIN32)
@@ -259,24 +258,23 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
             return VLC_ENOMEM;
     }
 #   else
-    {
+    if( asprintf( &ppsz_dir_list[1],
+                  "share" DIR_SEP "%s", luadirname ) < 0 )
+        return VLC_ENOMEM;
+
 #   ifdef HAVE_SYS_STAT_H
+    {
         struct stat stat_info;
-        if( ( utf8_stat( "share/luaplaylist", &stat_info ) == -1 )
+        if( ( utf8_stat( ppsz_dir_list[1], &stat_info ) == -1 )
             || !S_ISDIR( stat_info.st_mode ) )
         {
-            if( asprintf( &ppsz_dir_list[1], 
+            free(ppsz_dir_list[1]);
+            if( asprintf( &ppsz_dir_list[1],
                           DATA_PATH DIR_SEP "%s", luadirname ) < 0 )
                 return VLC_ENOMEM;
         }
-        else
-#   endif
-        {
-            if( asprintf( &ppsz_dir_list[1], 
-                          "share" DIR_SEP "%s", luadirname ) < 0 )
-                return VLC_ENOMEM;
-        }
     }
+#   endif
 #   endif
 
     for( ppsz_dir = ppsz_dir_list; *ppsz_dir; ppsz_dir++ )
@@ -308,11 +306,13 @@ int vlclua_scripts_batch_execute( vlc_object_t *p_this,
         for( ppsz_file = ppsz_filelist; ppsz_file < ppsz_fileend; ppsz_file++ )
         {
             char  *psz_filename;
-            asprintf( &psz_filename, "%s" DIR_SEP "%s", *ppsz_dir, *ppsz_file );
+            if( asprintf( &psz_filename,
+                          "%s" DIR_SEP "%s", *ppsz_dir, *ppsz_file ) < 0)
+                return VLC_ENOMEM;
             msg_Dbg( p_this, "Trying Lua playlist script %s", psz_filename );
-            
             i_ret = func( p_this, psz_filename, p_state, user_data );
-            
             free( psz_filename );
 
             if( i_ret == VLC_SUCCESS ) break;