]> git.sesse.net Git - vlc/blobdiff - src/libvlc-common.c
Specifying --fake-file-reload 5 reloads the image file every 5 seconds. This will...
[vlc] / src / libvlc-common.c
index 68c8954e7a4f1df4315f27a024ab864073a4e726..5e02e795c9696961dc3fd58d5267babf2df37489 100644 (file)
@@ -36,8 +36,8 @@
 #include "control/libvlc_internal.h"
 #include <vlc_input.h>
 
-#include "misc/modules.h"
-#include "misc/configuration.h"
+#include "modules/modules.h"
+#include "modules/configuration.h"
 
 #include <errno.h>                                                 /* ENOMEM */
 #include <stdio.h>                                              /* sprintf() */
@@ -108,7 +108,7 @@ static inline int LoadMessages (void);
 static int  GetFilenames  ( libvlc_int_t *, int, char *[] );
 static void Help          ( libvlc_int_t *, char const *psz_help_name );
 static void Usage         ( libvlc_int_t *, char const *psz_module_name );
-static void ListModules   ( libvlc_int_t * );
+static void ListModules   ( libvlc_int_t *, vlc_bool_t );
 static void Version       ( void );
 
 #ifdef WIN32
@@ -287,7 +287,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
     module_InitBank( p_libvlc );
 
     /* Hack: insert the help module here */
-    p_help_module = vlc_object_create( p_libvlc, VLC_OBJECT_MODULE );
+    p_help_module = vlc_module_create( VLC_OBJECT(p_libvlc) );
     if( p_help_module == NULL )
     {
         module_EndBank( p_libvlc );
@@ -499,7 +499,13 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
     /* Check for module list option */
     else if( config_GetInt( p_libvlc, "list" ) )
     {
-        ListModules( p_libvlc );
+        ListModules( p_libvlc, VLC_FALSE );
+        b_exit = VLC_TRUE;
+        i_ret = VLC_EEXITSUCCESS;
+    }
+    else if( config_GetInt( p_libvlc, "list-verbose" ) )
+    {
+        ListModules( p_libvlc, VLC_TRUE );
         b_exit = VLC_TRUE;
         i_ret = VLC_EEXITSUCCESS;
     }
@@ -697,7 +703,7 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int i_argc, char *ppsz_argv[] )
             }
         }
         /* we unreference the connection when we've finished with it */
-       if( p_conn ) dbus_connection_unref( p_conn );
+        if( p_conn ) dbus_connection_unref( p_conn );
     }
 #endif
 
@@ -1335,6 +1341,11 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
     /* List all modules */
     p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
 
+    /* Ugly hack to make sure that the help options always come first
+     * (part 1) */
+    if( !psz_module_name )
+        Usage( p_this, "help" );
+
     /* Enumerate the config for each module */
     for( i_index = 0; i_index < p_list->i_count; i_index++ )
     {
@@ -1363,6 +1374,12 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
             continue;
         }
 
+        b_help_module = !strcmp( "help", p_parser->psz_object_name );
+        /* Ugly hack to make sure that the help options always come first
+         * (part 2) */
+        if( !psz_module_name && b_help_module )
+            continue;
+
         /* Ignore modules with only advanced config options if requested */
         if( !b_advanced )
         {
@@ -1384,8 +1401,13 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
             else
                 utf8_fprintf( stdout, "\n %s\n", p_parser->psz_longname );
         }
-
-        b_help_module = !strcmp( "help", p_parser->psz_object_name );
+        if( p_parser->psz_help )
+        {
+            if( b_color )
+                utf8_fprintf( stdout, CYAN" %s\n"GRAY, p_parser->psz_help );
+            else
+                utf8_fprintf( stdout, " %s\n", p_parser->psz_help );
+        }
 
         /* Print module options */
         for( p_item = p_parser->p_config;
@@ -1685,13 +1707,15 @@ static void Usage( libvlc_int_t *p_this, char const *psz_module_name )
  * Print a list of all available modules (builtins and plugins) and a short
  * description for each one.
  *****************************************************************************/
-static void ListModules( libvlc_int_t *p_this )
+static void ListModules( libvlc_int_t *p_this, vlc_bool_t b_verbose )
 {
     vlc_list_t *p_list = NULL;
     module_t *p_parser = NULL;
     char psz_spaces[22];
     int i_index;
 
+    vlc_bool_t b_color = config_GetInt( p_this, "color" );
+
     memset( psz_spaces, ' ', 22 );
 
 #ifdef WIN32
@@ -1714,8 +1738,52 @@ static void ListModules( libvlc_int_t *p_this )
         if( i < 0 ) i = 0;
         psz_spaces[i] = 0;
 
-        utf8_fprintf( stdout, "  %s%s %s\n", p_parser->psz_object_name,
-                         psz_spaces, p_parser->psz_longname );
+        if( b_color )
+            utf8_fprintf( stdout, GREEN"  %s%s "WHITE"%s\n"GRAY,
+                          p_parser->psz_object_name,
+                          psz_spaces,
+                          p_parser->psz_longname );
+        else
+            utf8_fprintf( stdout, "  %s%s %s\n",
+                          p_parser->psz_object_name,
+                          psz_spaces, p_parser->psz_longname );
+
+        if( b_verbose )
+        {
+            const char **pp_shortcut = p_parser->pp_shortcuts;
+            while( pp_shortcut && *pp_shortcut )
+            {
+                if( strcmp( *pp_shortcut, p_parser->psz_object_name ) )
+                {
+                    if( b_color )
+                        utf8_fprintf( stdout, CYAN"   s %s\n"GRAY,
+                                      *pp_shortcut );
+                    else
+                        utf8_fprintf( stdout, "   s %s\n",
+                                      *pp_shortcut );
+                }
+                pp_shortcut++;
+            }
+            if( p_parser->psz_capability )
+            {
+                if( b_color )
+                    utf8_fprintf( stdout, MAGENTA"   c %s (%d)\n"GRAY,
+                                  p_parser->psz_capability,
+                                  p_parser->i_score );
+                else
+                    utf8_fprintf( stdout, "   c %s (%d)\n",
+                                  p_parser->psz_capability,
+                                  p_parser->i_score );
+            }
+            if( p_parser->psz_program )
+            {
+                if( b_color )
+                    utf8_fprintf( stdout, YELLOW "   p %s\n"GRAY,
+                                  p_parser->psz_program );
+                else
+                    utf8_fprintf( stdout, "   p %s\n", p_parser->psz_program );
+            }
+        }
 
         psz_spaces[i] = ' ';
     }
@@ -1873,33 +1941,27 @@ static void InitDeviceValues( libvlc_int_t *p_vlc )
     char **devices = NULL;
     char *block_dev = NULL;
     dbus_bool_t b_dvd;
+
 #ifdef HAVE_HAL_1
     DBusConnection *p_connection = NULL;
     DBusError       error;
-#endif
 
-#ifdef HAVE_HAL_1
     ctx = libhal_ctx_new();
     if( !ctx ) return;
     dbus_error_init( &error );
     p_connection = dbus_bus_get ( DBUS_BUS_SYSTEM, &error );
     if( dbus_error_is_set( &error ) || !p_connection )
     {
-        libhal_ctx_shutdown( ctx, NULL );
         dbus_error_free( &error );
         return;
     }
-#else
-    ctx = hal_initialize( NULL, FALSE );
-    if( !ctx ) return;
-#endif
-
-#ifdef HAVE_HAL_1
     libhal_ctx_set_dbus_connection( ctx, p_connection );
     if( libhal_ctx_init( ctx, &error ) )
 #else
-    if( ( ctx = hal_initialize( NULL, FALSE ) ) )
+    ctx = hal_initialize( NULL, FALSE );
+    if( ctx )
 #endif
+
     {
 #ifdef HAVE_HAL_1
         if( ( devices = libhal_get_all_devices( ctx, &i_devices, NULL ) ) )