]> git.sesse.net Git - vlc/blobdiff - src/interface/main.c
* Fixed a bug that made vlc segfault when choosing a program, change to
[vlc] / src / interface / main.c
index 6a8faf8c38b362504c3c34b2e3751ccfc7aa807e..39756fd168317da2f520a2e6738226587bde572b 100644 (file)
@@ -4,10 +4,11 @@
  * and spawn threads.
  *****************************************************************************
  * Copyright (C) 1998-2001 VideoLAN
- * $Id: main.c,v 1.145 2002/01/17 23:02:45 gbazin Exp $
+ * $Id: main.c,v 1.168 2002/03/25 02:06:24 jobi Exp $
  *
  * Authors: Vincent Seguin <seguin@via.ecp.fr>
  *          Samuel Hocevar <sam@zoy.org>
+ *          Gildas Bazin <gbazin@netcourrier.com>
  *
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
 #include "debug.h"
 
 /*****************************************************************************
- * Command line options constants. If something is changed here, be sure that
- * GetConfiguration and Usage are also changed.
+ * Configuration options for the main program. Each plugin will also separatly
+ * define its own configuration options.
+ * Look into configuration.h if you need to know more about the following
+ * macros.
+ * 
  *****************************************************************************/
+#define BUILTIN
+#define MODULE_NAME main
+#include "modules_inner.h"                        /* for configuration stuff */
+
+
+#define INTF_TEXT "interface method"
+#define INTF_LONGTEXT "This option allows you to select the interface used by"\
+                      " vlc.\nNote that the default behaviour is to" \
+                      " automatically select the best method available"
+
+#define WARNING_TEXT "warning level (or use -v, -vv, etc...)"
+#define WARNING_LONGTEXT "Increasing the warning level will allow you to see" \
+                         " more debug messages and can sometimes help you to" \
+                         " troubleshoot a problem"
+
+#define STATS_TEXT "output statistics"
+#define STATS_LONGTEXT "Enabling the stats mode will flood your log console" \
+                       " with various statistics messages"
+
+#define INTF_PATH_TEXT "interface default search path"
+#define INTF_PATH_LONGTEXT "This option allows you to set the default path" \
+                           "that the interface will open when looking for a" \
+                           " file"
+
+#define AOUT_TEXT "audio output method"
+#define AOUT_LONGTEXT "This option allows you to select the audio" \
+                      " audio output method used by vlc.\nNote that the" \
+                      " default behaviour is to automatically select the best"\
+                      " method available"
 
-/* Long options return values - note that values corresponding to short options
- * chars, and in general any regular char, should be avoided */
-#define OPT_NOAUDIO             150
-#define OPT_STEREO              151
-#define OPT_MONO                152
-#define OPT_SPDIF               153
-#define OPT_VOLUME              154
-#define OPT_DESYNC              155
-
-#define OPT_NOVIDEO             160
-#define OPT_DISPLAY             161
-#define OPT_WIDTH               162
-#define OPT_HEIGHT              163
-#define OPT_COLOR               164
-#define OPT_FULLSCREEN          165
-#define OPT_NOOVERLAY           166
-#define OPT_XVADAPTOR           167
-#define OPT_SMP                 168
-#define OPT_FILTER              169
-
-#define OPT_CHANNELS            170
-#define OPT_SERVER              171
-#define OPT_PORT                172
-#define OPT_BROADCAST           173
-#define OPT_CHANNELSERVER       174
-
-#define OPT_INPUT               180
-#define OPT_MOTION              181
-#define OPT_IDCT                182
-#define OPT_YUV                 183
-#define OPT_DOWNMIX             184
-#define OPT_IMDCT               185
-#define OPT_MEMCPY              186
-#define OPT_DVDCSS_METHOD       187
-#define OPT_DVDCSS_VERBOSE      188
-
-#define OPT_SYNCHRO             190
-#define OPT_WARNING             191
-#define OPT_VERSION             192
-#define OPT_STDOUT              193
-#define OPT_STATS               194
-
-#define OPT_MPEG_ADEC           200
-
-#define OPT_NOMMX               201
-#define OPT_NO3DNOW             202
-#define OPT_NOMMXEXT            203
-#define OPT_NOSSE               204
-#define OPT_NOALTIVEC           205
-
-/* Usage fashion */
-#define USAGE                     0
-#define SHORT_HELP                1
-#define LONG_HELP                 2
-
-/* Long options */
-static const struct option longopts[] =
-{
-    /*  name,               has_arg,    flag,   val */
-
-    /* General/common options */
-    {   "help",             0,          0,      'h' },
-    {   "longhelp",         0,          0,      'H' },
-    {   "version",          0,          0,      OPT_VERSION },
-
-    /* Interface options */
-    {   "intf",             1,          0,      'I' },
-    {   "warning",          1,          0,      OPT_WARNING },
-    {   "stdout",           1,          0,      OPT_STDOUT },
-    {   "stats",            0,          0,      OPT_STATS },
-
-    /* Audio options */
-    {   "noaudio",          0,          0,      OPT_NOAUDIO },
-    {   "aout",             1,          0,      'A' },
-    {   "stereo",           0,          0,      OPT_STEREO },
-    {   "mono",             0,          0,      OPT_MONO },
-    {   "spdif",            0,          0,      OPT_SPDIF },
-    {   "downmix",          1,          0,      OPT_DOWNMIX },
-    {   "imdct",            1,          0,      OPT_IMDCT },
-    {   "volume",           1,          0,      OPT_VOLUME },
-    {   "desync",           1,          0,      OPT_DESYNC },
-
-    /* Video options */
-    {   "novideo",          0,          0,      OPT_NOVIDEO },
-    {   "vout",             1,          0,      'V' },
-    {   "display",          1,          0,      OPT_DISPLAY },
-    {   "width",            1,          0,      OPT_WIDTH },
-    {   "height",           1,          0,      OPT_HEIGHT },
-    {   "grayscale",        0,          0,      'g' },
-    {   "color",            0,          0,      OPT_COLOR },
-    {   "motion",           1,          0,      OPT_MOTION },
-    {   "idct",             1,          0,      OPT_IDCT },
-    {   "yuv",              1,          0,      OPT_YUV },
-    {   "fullscreen",       0,          0,      OPT_FULLSCREEN },
-    {   "nooverlay",        0,          0,      OPT_NOOVERLAY },
-    {   "xvadaptor",        1,          0,      OPT_XVADAPTOR },
-    {   "smp",              1,          0,      OPT_SMP },
-    {   "filter",           1,          0,      OPT_FILTER },
-
-    /* DVD options */
-    {   "dvdtitle",         1,          0,      't' },
-    {   "dvdchapter",       1,          0,      'T' },
-    {   "dvdangle",         1,          0,      'u' },
-    {   "dvdaudio",         1,          0,      'a' },
-    {   "dvdchannel",       1,          0,      'c' },
-    {   "dvdsubtitle",      1,          0,      's' },
-    {   "dvdcss-method",    1,          0,      OPT_DVDCSS_METHOD },
-    {   "dvdcss-verbose",   1,          0,      OPT_DVDCSS_VERBOSE },
-
-    /* Input options */
-    {   "input",            1,          0,      OPT_INPUT },
-    {   "channels",         0,          0,      OPT_CHANNELS },
-    {   "channelserver",    1,          0,      OPT_CHANNELSERVER },
-
-    /* Misc options */
-    {   "synchro",          1,          0,      OPT_SYNCHRO },
-    {   "memcpy",           1,          0,      OPT_MEMCPY },
-
-    /* Decoder options */
-    {   "mpeg_adec",        1,          0,      OPT_MPEG_ADEC },
-
-    /* CPU options */
-    {   "nommx",            0,          0,      OPT_NOMMX },
-    {   "no3dnow",          0,          0,      OPT_NO3DNOW },
-    {   "nommxext",         0,          0,      OPT_NOMMXEXT },
-    {   "nosse",            0,          0,      OPT_NOSSE },
-    {   "noaltivec",        0,          0,      OPT_NOALTIVEC },
-
-    {   0,                  0,          0,      0 }
-};
-
-/* Short options */
-static const char *psz_shortopts = "hHvgt:T:u:a:s:c:I:A:V:";
+#define NOAUDIO_TEXT "disable audio"
+#define NOAUDIO_LONGTEXT "This will completely disable the audio output. The" \
+                         " audio decoding stage shouldn't even be done, so it"\
+                         " can allow you to save some processing power"
+
+#define MONO_TEXT "mono audio"
+#define MONO_LONGTEXT "This will force a mono audio output"
+
+#define VOLUME_TEXT "audio output volume"
+#define VOLUME_LONGTEXT "You can set the default audio output volume here," \
+                        " in a range from 0 to 1024"
+
+#define FORMAT_TEXT "audio output format"
+#define FORMAT_LONGTEXT "You can force the audio output format here.\n" \
+                        "0 -> 16 bits signed native endian (default)\n" \
+                        "1 ->  8 bits unsigned\n"                       \
+                        "2 -> 16 bits signed little endian\n"           \
+                        "3 -> 16 bits signed big endian\n"              \
+                        "4 ->  8 bits signed\n"                         \
+                        "5 -> 16 bits unsigned little endian\n"         \
+                        "6 -> 16 bits unsigned big endian\n"            \
+                        "7 -> mpeg2 audio (unsupported)\n"              \
+                        "8 -> ac3 pass-through"
+                         
+#define RATE_TEXT "audio output frequency (Hz)"
+#define RATE_LONGTEXT "You can force the audio output frequency here.\n"    \
+                      "Common values are 48000, 44100, 32000, 22050,"       \
+                      " 16000, 11025, 8000"
+
+#define DESYNC_TEXT "Compensate desynchronization of audio (in ms)"
+#define DESYNC_LONGTEXT "This option allows you to delay the audio output." \
+                        "This can be handy if you notice a lag between the" \
+                        " video and the audio"
+
+#define VOUT_TEXT "video output method"
+#define VOUT_LONGTEXT "This option allows you to select the video output" \
+                      "method used by vlc.\nNote that the default behaviour" \
+                      "is to automatically select the best method available"
+
+#define NOVIDEO_TEXT "disable video"
+#define NOVIDEO_LONGTEXT "This will completely disable the video output. The" \
+                         "video decoding stage shouldn't even be done, so it" \
+                         "can allow you to save some processing power"
+
+#define DISPLAY_TEXT "display identifier"
+#define DISPLAY_LONGTEXT NULL
+
+#define WIDTH_TEXT "video width"
+#define WIDTH_LONGTEXT "You can enforce the video width here.\nNote" \
+                       "that by default vlc will adapt to the video properties"
+
+#define HEIGHT_TEXT "video height"
+#define HEIGHT_LONGTEXT NULL
+
+#define GRAYSCALE_TEXT "grayscale video output"
+#define GRAYSCALE_LONGTEXT NULL
+
+#define FULLSCREEN_TEXT "fullscreen video output"
+#define FULLSCREEN_LONGTEXT NULL
+
+#define NOOVERLAY_TEXT "disable accelerated display"
+#define NOOVERLAY_LONGTEXT NULL
+
+#define SPUMARGIN_TEXT "force SPU position"
+#define SPUMARGIN_LONGTEXT NULL
+
+#define FILTER_TEXT "video filter module"
+#define FILTER_LONGTEXT NULL
+
+#define INPUT_TEXT "input method"
+#define INPUT_LONGTEXT NULL
+
+#define SERVER_PORT_TEXT "server port"
+#define SERVER_PORT_LONGTEXT NULL
+
+#define NETCHANNEL_TEXT "enable network channel mode"
+#define NETCHANNEL_LONGTEXT NULL
+
+#define CHAN_SERV_TEXT "channel server address"
+#define CHAN_SERV_LONGTEXT NULL
+
+#define CHAN_PORT_TEXT "channel server port"
+#define CHAN_PORT_LONGTEXT NULL
+
+#define IFACE_TEXT "network interface"
+#define IFACE_LONGTEXT NULL
+
+#define INPUT_AUDIO_TEXT "choose audio"
+#define INPUT_AUDIO_LONGTEXT NULL
+
+#define INPUT_CHAN_TEXT "choose channel"
+#define INPUT_CHAN_LONGTEXT NULL
+
+#define INPUT_SUBT_TEXT "choose subtitles"
+#define INPUT_SUBT_LONGTEXT NULL
+
+#define DVD_DEV_TEXT "DVD device"
+#define DVD_DEV_LONGTEXT NULL
+
+#define VCD_DEV_TEXT "VCD device"
+#define VCD_DEV_LONGTEXT NULL
+
+#define SAT_FREQ_TEXT "Satellite transponder frequency"
+#define SAT_FREQ_LONGTEXT NULL
+
+#define SAT_POL_TEXT "Satellite transponder polarization"
+#define SAT_POL_LONGTEXT NULL
+
+#define SAT_SRATE_TEXT "Satellite transponder symbol rate"
+#define SAT_SRATE_LONGTEXT NULL
+                       
+#define IPV6_TEXT "force IPv6"
+#define IPV6_LONGTEXT NULL
+
+#define IPV4_TEXT "force IPv4"
+#define IPV4_LONGTEXT NULL
+
+#define ADEC_MPEG_TEXT "choose MPEG audio decoder"
+#define ADEC_MPEG_LONGTEXT NULL
+
+#define ADEC_AC3_TEXT "choose AC3 audio decoder"
+#define ADEC_AC3_LONGTEXT NULL
+
+#define VDEC_SMP_TEXT "use additional processors"
+#define VDEC_SMP_LONGTEXT NULL
+
+#define VPAR_SYNCHRO_TEXT "force synchro algorithm {I|I+|IP|IP+|IPB}"
+#define VPAR_SYNCHRO_LONGTEXT NULL
+
+#define NOMMX_TEXT "disable CPU's MMX support"
+#define NOMMX_LONGTEXT NULL
+
+#define NO3DN_TEXT "disable CPU's 3D Now! support"
+#define NO3DN_LONGTEXT NULL
+
+#define NOMMXEXT_TEXT "disable CPU's MMX EXT support"
+#define NOMMXEXT_LONGTEXT NULL
+
+#define NOSSE_TEXT "disable CPU's SSE support"
+#define NOSSE_LONGTEXT NULL
+
+#define NOALTIVEC_TEXT "disable CPU's AltiVec support"
+#define NOALTIVEC_LONGTEXT NULL
+
+#define PLAYLIST_LAUNCH_TEXT "launch playlist on startup"
+#define PLAYLIST_LAUNCH_LONGTEXT NULL
+
+#define PLAYLIST_ENQUEUE_TEXT "enqeue playlist as default"
+#define PLAYLIST_ENQUEUE_LONGTEXT NULL
+
+#define PLAYLIST_LOOP_TEXT "loop playlist on end"
+#define PLAYLIST_LOOP_LONGTEXT NULL
+
+#define MEMCPY_TEXT "memory copy method"
+#define MEMCPY_LONGTEXT NULL
+
+/* Quick usage guide
+MODULE_CONFIG_START
+MODULE_CONFIG_STOP
+ADD_CATEGORY_HINT( text, longtext )
+ADD_SUBCATEGORY_HINT( text, longtext )
+ADD_STRING( option_name, value, p_callback, text, longtext )
+ADD_FILE( option_name, psz_value, p_callback, text, longtext )
+ADD_PLUGIN( option_name, psz_value, i_capability, p_callback, text, longtext )
+ADD_INTEGER( option_name, i_value, p_callback, text, longtext )
+ADD_BOOL( option_name, p_callback, text, longtext )
+*/
+
+MODULE_CONFIG_START
+
+/* Interface options */
+ADD_CATEGORY_HINT( "Interface", NULL)
+ADD_PLUGIN  ( "intf", MODULE_CAPABILITY_INTF, NULL, NULL, INTF_TEXT, INTF_LONGTEXT )
+ADD_INTEGER ( "warning", 0, NULL, WARNING_TEXT, WARNING_LONGTEXT )
+ADD_BOOL    ( "stats", NULL, STATS_TEXT, STATS_LONGTEXT )
+ADD_STRING  ( "search_path", NULL, NULL, INTF_PATH_TEXT, INTF_PATH_LONGTEXT )
+
+/* Audio options */
+ADD_CATEGORY_HINT( "Audio", NULL)
+ADD_PLUGIN  ( "aout", MODULE_CAPABILITY_AOUT, NULL, NULL, AOUT_TEXT, AOUT_LONGTEXT )
+ADD_BOOL    ( "noaudio", NULL, NOAUDIO_TEXT, NOAUDIO_LONGTEXT )
+ADD_BOOL    ( "mono", NULL, MONO_TEXT, MONO_LONGTEXT )
+ADD_INTEGER ( "volume", VOLUME_DEFAULT, NULL, VOLUME_TEXT, VOLUME_LONGTEXT )
+ADD_INTEGER ( "rate", 44100, NULL, RATE_TEXT, RATE_LONGTEXT )
+ADD_INTEGER ( "desync", 0, NULL, DESYNC_TEXT, DESYNC_LONGTEXT )
+ADD_INTEGER ( "aout_format", 0, NULL, FORMAT_TEXT,
+              FORMAT_LONGTEXT )
+
+/* Video options */
+ADD_CATEGORY_HINT( "Video", NULL )
+ADD_PLUGIN  ( "vout", MODULE_CAPABILITY_VOUT, NULL, NULL, VOUT_TEXT, VOUT_LONGTEXT )
+ADD_BOOL    ( "novideo", NULL, NOVIDEO_TEXT, NOVIDEO_LONGTEXT )
+ADD_STRING  ( "display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT )
+ADD_INTEGER ( "width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT )
+ADD_INTEGER ( "height", -1, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT )
+ADD_BOOL    ( "grayscale", NULL, GRAYSCALE_TEXT, GRAYSCALE_LONGTEXT )
+ADD_BOOL    ( "fullscreen", NULL, FULLSCREEN_TEXT, FULLSCREEN_LONGTEXT )
+ADD_BOOL    ( "nooverlay", NULL, NOOVERLAY_TEXT, NOOVERLAY_LONGTEXT )
+ADD_INTEGER ( "spumargin", -1, NULL, SPUMARGIN_TEXT, SPUMARGIN_LONGTEXT )
+ADD_PLUGIN  ( "filter", MODULE_CAPABILITY_VOUT, NULL, NULL, FILTER_TEXT, FILTER_LONGTEXT )
+
+/* Input options */
+ADD_CATEGORY_HINT( "Input", NULL )
+ADD_STRING  ( "input", NULL, NULL, INPUT_TEXT, INPUT_LONGTEXT )
+ADD_INTEGER ( "server_port", 1234, NULL, SERVER_PORT_TEXT, SERVER_PORT_LONGTEXT )
+ADD_BOOL    ( "network_channel", NULL, NETCHANNEL_TEXT, NETCHANNEL_LONGTEXT )
+ADD_STRING  ( "channel_server", "localhost", NULL, CHAN_SERV_TEXT, CHAN_SERV_LONGTEXT )
+ADD_INTEGER ( "channel_port", 6010, NULL, CHAN_PORT_TEXT, CHAN_PORT_LONGTEXT )
+ADD_STRING  ( "iface", "eth0", NULL, IFACE_TEXT, IFACE_LONGTEXT )
+
+ADD_INTEGER ( "input_audio", -1, NULL, INPUT_AUDIO_TEXT, INPUT_AUDIO_LONGTEXT )
+ADD_INTEGER ( "input_channel", -1, NULL, INPUT_CHAN_TEXT, INPUT_CHAN_LONGTEXT )
+ADD_INTEGER ( "input_subtitle", -1, NULL, INPUT_SUBT_TEXT, INPUT_SUBT_LONGTEXT )
+
+ADD_STRING  ( "dvd_device", "/dev/dvd", NULL, DVD_DEV_TEXT, DVD_DEV_LONGTEXT )
+ADD_STRING  ( "vcd_device", "/dev/cdrom", NULL, VCD_DEV_TEXT, VCD_DEV_LONGTEXT )
+#ifdef HAVE_SATELLITE
+ADD_INTEGER ( "sat_frequency", 12553, NULL, SAT_FREQ_TEXT, SAT_FREQ_LONGTEXT )
+ADD_INTEGER ( "sat_polarization", 0, NULL, SAT_POL_TEXT, SAT_POL_LONGTEXT )
+ADD_INTEGER ( "sat_symbol_rate", 27500, NULL, SAT_SRATE_TEXT, 
+            SAT_SRATE_LONGTEXT )
+#endif
+
+ADD_BOOL    ( "ipv6", NULL, IPV6_TEXT, IPV6_LONGTEXT )
+ADD_BOOL    ( "ipv4", NULL, IPV4_TEXT, IPV4_LONGTEXT )
+
+/* Decoder options */
+ADD_CATEGORY_HINT( "Decoders", NULL )
+ADD_PLUGIN  ( "mpeg_adec", MODULE_CAPABILITY_DECODER, NULL, NULL, ADEC_MPEG_TEXT, ADEC_MPEG_LONGTEXT )
+ADD_PLUGIN  ( "ac3_adec", MODULE_CAPABILITY_DECODER, NULL, NULL, ADEC_AC3_TEXT, ADEC_AC3_LONGTEXT )
+ADD_INTEGER ( "vdec_smp", 0, NULL, VDEC_SMP_TEXT, VDEC_SMP_LONGTEXT )
+ADD_STRING  ( "vpar_synchro", NULL, NULL, VPAR_SYNCHRO_TEXT, VPAR_SYNCHRO_LONGTEXT )
+
+/* CPU options */
+ADD_CATEGORY_HINT( "CPU", NULL )
+ADD_BOOL    ( "nommx", NULL, NOMMX_TEXT, NOMMX_LONGTEXT )
+ADD_BOOL    ( "no3dn", NULL, NO3DN_TEXT, NO3DN_LONGTEXT )
+ADD_BOOL    ( "nommxext", NULL, NOMMXEXT_TEXT, NOMMXEXT_LONGTEXT )
+ADD_BOOL    ( "nosse", NULL, NOSSE_TEXT, NOSSE_LONGTEXT )
+ADD_BOOL    ( "noaltivec", NULL, NOALTIVEC_TEXT, NOALTIVEC_LONGTEXT )
+
+/* Playlist options */
+ADD_CATEGORY_HINT( "Playlist", NULL )
+ADD_BOOL    ( "playlist_launch", NULL, PLAYLIST_LAUNCH_TEXT, PLAYLIST_LAUNCH_LONGTEXT )
+ADD_BOOL    ( "playlist_enqueue", NULL, PLAYLIST_ENQUEUE_TEXT, PLAYLIST_ENQUEUE_LONGTEXT )
+ADD_BOOL    ( "playlist_loop", NULL, PLAYLIST_LOOP_TEXT, PLAYLIST_LOOP_LONGTEXT )
+
+/* Misc options */
+ADD_CATEGORY_HINT( "Miscellaneous", NULL )
+ADD_PLUGIN  ( "memcpy", MODULE_CAPABILITY_MEMCPY, NULL, NULL, MEMCPY_TEXT, MEMCPY_LONGTEXT )
+
+MODULE_CONFIG_STOP
+
+MODULE_INIT_START
+    SET_DESCRIPTION( "Main program" )
+    ADD_CAPABILITY( MAIN, 100/*whatever*/ )
+MODULE_INIT_STOP
+
+MODULE_ACTIVATE_START
+MODULE_ACTIVATE_STOP
+
+MODULE_DEACTIVATE_START
+MODULE_DEACTIVATE_STOP
+
+/* Hack for help options */
+static module_t help_module;
+static module_config_t p_help_config[] = {
+    { MODULE_CONFIG_ITEM_BOOL, "help", "print help (or use -h)",
+      NULL, NULL, 0, NULL, NULL, 0 },
+    { MODULE_CONFIG_ITEM_BOOL, "longhelp", "print detailed help (or use -H)",
+      NULL, NULL, 0, NULL, NULL, 0 },
+    { MODULE_CONFIG_ITEM_BOOL, "list", "print a list of available plugins "
+      "(or use -l)", NULL, NULL, 0, NULL, NULL, 0 },
+    { MODULE_CONFIG_ITEM_STRING, "plugin", "print help on plugin (or use -p)",
+      NULL, NULL, 0, NULL, &help_module.config_lock, 0 },
+    { MODULE_CONFIG_ITEM_BOOL, "version", "print version information",
+      NULL, NULL, 0, NULL, NULL, 0 },
+    { MODULE_CONFIG_HINT_END, NULL, NULL, NULL, NULL, 0, NULL, NULL, 0 } };
+
+
+/*****************************************************************************
+ * End configuration.
+ *****************************************************************************/
 
 /*****************************************************************************
  * Global variables - these are the only ones, see main.h and modules.h
@@ -234,20 +417,20 @@ vout_bank_t   *p_vout_bank;
 /*****************************************************************************
  * Local prototypes
  *****************************************************************************/
-static int  GetConfiguration        ( int *pi_argc, char *ppsz_argv[],
-                                      char *ppsz_env[] );
-static int  GetFilenames            ( int i_argc, char *ppsz_argv[] );
-static void Usage                   ( int i_fashion );
-static void Version                 ( void );
-
-static void InitSignalHandler       ( void );
-static void SimpleSignalHandler     ( int i_signal );
-static void FatalSignalHandler      ( int i_signal );
-static void IllegalSignalHandler    ( int i_signal );
-static u32  CPUCapabilities         ( void );
-
-static int  RedirectSTDOUT          ( void );
-static void ShowConsole             ( void );
+static int  GetFilenames                ( int i_argc, char *ppsz_argv[] );
+static void Usage                       ( const char *psz_module_name );
+static void ListModules                 ( void );
+static void Version                     ( void );
+
+static void InitSignalHandler           ( void );
+static void SimpleSignalHandler         ( int i_signal );
+static void FatalSignalHandler          ( int i_signal );
+static void IllegalSignalHandler        ( int i_signal );
+static u32  CPUCapabilities             ( void );
+
+#ifdef WIN32
+static void ShowConsole                 ( void );
+#endif
 
 static jmp_buf env;
 static int     i_illegal;
@@ -270,6 +453,8 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
     input_bank_t  input_bank;
     aout_bank_t   aout_bank;
     vout_bank_t   vout_bank;
+    char *psz_plugin;
+    char *p_tmp;
 
     p_main        = &main_data;               /* set up the global variables */
     p_module_bank = &module_bank;
@@ -277,7 +462,9 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
     p_aout_bank   = &aout_bank;
     p_vout_bank   = &vout_bank;
 
-#ifdef ENABLE_NLS
+    p_main->i_warning_level = 0;
+
+#if defined( ENABLE_NLS ) && defined ( HAVE_GETTEXT )
     /*
      * Support for getext
      */
@@ -300,7 +487,7 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
     /*
      * Initialize threads system
      */
-    vlc_threads_init( );
+    vlc_threads_init();
 
     /*
      * Test if our code is likely to run on this CPU
@@ -316,37 +503,159 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
 #elif defined( SYS_LINUX )
 #   ifdef DEBUG
     /* Activate malloc checking routines to detect heap corruptions. */
-    main_PutIntVariable( "MALLOC_CHECK_", 2 );
+    putenv( "MALLOC_CHECK_=2" );
+    putenv( "GNOME_DISABLE_CRASH_DIALOG=1" );
 #   endif
 #endif
 
     /*
      * Initialize messages interface
      */
-    p_main->p_msg = intf_MsgCreate();
-    if( !p_main->p_msg )                         /* start messages interface */
+    intf_MsgCreate();
+
+    intf_Msg( COPYRIGHT_MESSAGE "\n" );
+
+
+    /* Get the executable name (similar to the basename command) */
+    p_main->psz_arg0 = p_tmp = ppsz_argv[ 0 ];
+    while( *p_tmp )
     {
-        fprintf( stderr, "error: can't initialize messages interface (%s)\n",
-                 strerror(errno) );
-        return( errno );
+        if( *p_tmp == '/' ) p_main->psz_arg0 = ++p_tmp;
+        else ++p_tmp;
     }
 
-    intf_MsgImm( COPYRIGHT_MESSAGE "\n" );
-
     /*
-     * Read configuration
+     * Initialize the module bank and and load the configuration of the main
+     * module. We need to do this at this stage to be able to display a short
+     * help if required by the user. (short help == main module options)
      */
-    if( GetConfiguration( &i_argc, ppsz_argv, ppsz_env ) ) /* parse cmd line */
+    module_InitBank();
+    module_LoadMain();
+
+    /* Hack: insert the help module here */
+    help_module.psz_name = "help";
+    help_module.i_config_lines = sizeof(p_help_config) /
+                                     sizeof(module_config_t);
+    help_module.i_config_items = help_module.i_config_lines - 1;
+    vlc_mutex_init( &help_module.config_lock );
+    help_module.p_config = p_help_config;
+    help_module.next = p_module_bank->first;
+    p_module_bank->first = &help_module;
+    /* end hack */
+
+    if( config_LoadCmdLine( &i_argc, ppsz_argv, 1 ) )
     {
         intf_MsgDestroy();
         return( errno );
     }
 
+    /* Check for short help option */
+    if( config_GetIntVariable( "help" ) )
+    {
+        intf_Msg( "Usage: %s [options] [parameters] [file]...\n",
+                  p_main->psz_arg0 );
+
+        Usage( "help" );
+        Usage( "main" );
+        return( -1 );
+    }
+
+    /* Check for version option */
+    if( config_GetIntVariable( "version" ) )
+    {
+        Version();
+        return( -1 );
+    }
+
+    /* Hack: remove the help module here */
+    p_module_bank->first = help_module.next;
+    /* end hack */
+
+    /*
+     * Load the builtins and plugins into the module_bank.
+     * We have to do it before config_Load*() because this also gets the
+     * list of configuration options exported by each plugin and loads their
+     * default values.
+     */
+    module_LoadBuiltins();
+    module_LoadPlugins();
+    intf_WarnMsg( 2, "module: module bank initialized, found %i modules",
+                  p_module_bank->i_count );
+
+    /* Hack: insert the help module here */
+    help_module.next = p_module_bank->first;
+    p_module_bank->first = &help_module;
+    /* end hack */
+
+    /* Check for help on plugins */
+    if( (p_tmp = config_GetPszVariable( "plugin" )) )
+    {
+        Usage( p_tmp );
+        free( p_tmp );
+        return( -1 );
+    }
+
+    /* Check for long help option */
+    if( config_GetIntVariable( "longhelp" ) )
+    {
+        Usage( NULL );
+        return( -1 );
+    }
+
+    /* Check for plugin list option */
+    if( config_GetIntVariable( "list" ) )
+    {
+        ListModules();
+        return( -1 );
+    }
+
+    /* Hack: remove the help module here */
+    p_module_bank->first = help_module.next;
+    /* end hack */
+
+
     /*
-     * Redirect the standard output if required by the user, and on Win32 we
-     * also open a console to display the debug messages.
+     * Override default configuration with config file settings
      */
-    RedirectSTDOUT();
+    vlc_mutex_init( &p_main->config_lock );
+    p_main->psz_homedir = config_GetHomeDir();
+    config_LoadConfigFile( NULL );
+
+    /*
+     * Override configuration with command line settings
+     */
+    if( config_LoadCmdLine( &i_argc, ppsz_argv, 0 ) )
+    {
+#ifdef WIN32
+        ShowConsole();
+        /* Pause the console because it's destroyed when we exit */
+        intf_Msg( "The command line options couldn't be loaded, check that "
+                  "they are valid.\nPress the RETURN key to continue..." );
+        getchar();
+#endif
+        intf_MsgDestroy();
+        return( errno );
+    }
+
+
+    /* p_main inititalization. FIXME ? */
+    p_main->i_desync = (mtime_t)config_GetIntVariable( "desync" )
+      * (mtime_t)1000;
+    p_main->b_stats = config_GetIntVariable( "stats" );
+    p_main->b_audio = !config_GetIntVariable( "noaudio" );
+    p_main->b_stereo= !config_GetIntVariable( "mono" );
+    p_main->b_video = !config_GetIntVariable( "novideo" );
+    if( config_GetIntVariable( "nommx" ) )
+        p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_MMX;
+    if( config_GetIntVariable( "no3dn" ) )
+        p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_3DNOW;
+    if( config_GetIntVariable( "nommxext" ) )
+        p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_MMXEXT;
+    if( config_GetIntVariable( "nosse" ) )
+        p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_SSE;
+    if( config_GetIntVariable( "noaltivec" ) )
+        p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_ALTIVEC;
+
 
     if( p_main->b_stats )
     {
@@ -391,9 +700,8 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
     GetFilenames( i_argc, ppsz_argv );
 
     /*
-     * Initialize module, input, aout and vout banks
+     * Initialize input, aout and vout banks
      */
-    module_InitBank();
     input_InitBank();
     aout_InitBank();
     vout_InitBank();
@@ -401,24 +709,32 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
     /*
      * Choose the best memcpy module
      */
-    if( module_NeedMemcpy( &p_main->memcpy ) )
+    psz_plugin = config_GetPszVariable( "memcpy" );
+    p_main->p_memcpy_module = module_Need( MODULE_CAPABILITY_MEMCPY, NULL,
+                                           psz_plugin );
+    if( psz_plugin ) free( psz_plugin );
+    if( p_main->p_memcpy_module == NULL )
     {
         intf_ErrMsg( "intf error: no suitable memcpy module, "
                      "using libc default" );
-        p_main->memcpy.pf_memcpy = memcpy;
+        p_main->pf_memcpy = memcpy;
+    }
+    else
+    {
+        p_main->pf_memcpy = p_main->p_memcpy_module->p_functions
+                                  ->memcpy.functions.memcpy.pf_memcpy;
     }
 
     /*
      * Initialize shared resources and libraries
      */
-    if( main_GetIntVariable( INPUT_NETWORK_CHANNEL_VAR,
-                             INPUT_NETWORK_CHANNEL_DEFAULT ) &&
+    if( config_GetIntVariable( "network_channel" ) &&
         network_ChannelCreate() )
     {
         /* On error during Channels initialization, switch off channels */
-        intf_Msg( "Channels initialization failed : "
-                  "Channel management is deactivated" );
-        main_PutIntVariable( INPUT_NETWORK_CHANNEL_VAR, 0 );
+        intf_ErrMsg( "intf error: channels initialization failed, " 
+                                 "deactivating channels" );
+        config_PutIntVariable( "network_channel", 0 );
     }
 
     /*
@@ -449,8 +765,7 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
         /*
          * Go back into channel 0 which is the network
          */
-        if( main_GetIntVariable( INPUT_NETWORK_CHANNEL_VAR,
-                                 INPUT_NETWORK_CHANNEL_DEFAULT ) )
+        if( config_GetIntVariable( "network_channel" ) )
         {
             network_ChannelJoin( COMMON_CHANNEL );
         }
@@ -471,9 +786,9 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
     /*
      * Free memcpy module if it was allocated
      */
-    if( p_main->memcpy.p_module != NULL )
+    if( p_main->p_memcpy_module != NULL )
     {
-        module_UnneedMemcpy( &p_main->memcpy );
+        module_Unneed( p_main->p_memcpy_module );
     }
 
     /*
@@ -503,572 +818,186 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
     return 0;
 }
 
-/*****************************************************************************
- * main_GetIntVariable: get the int value of an environment variable
- *****************************************************************************
- * This function is used to read some default parameters in modules.
- *****************************************************************************/
-int main_GetIntVariable( char *psz_name, int i_default )
-{
-    char *      psz_env;                                /* environment value */
-    char *      psz_end;                             /* end of parsing index */
-    long int    i_value;                                            /* value */
 
-    psz_env = getenv( psz_name );
-    if( psz_env )
-    {
-        i_value = strtol( psz_env, &psz_end, 0 );
-        if( (*psz_env != '\0') && (*psz_end == '\0') )
-        {
-            return( i_value );
-        }
-    }
-    return( i_default );
-}
+/* following functions are local */
 
 /*****************************************************************************
- * main_GetPszVariable: get the string value of an environment variable
+ * GetFilenames: parse command line options which are not flags
  *****************************************************************************
- * This function is used to read some default parameters in modules.
+ * Parse command line for input files.
  *****************************************************************************/
-char * main_GetPszVariable( char *psz_name, char *psz_default )
+static int GetFilenames( int i_argc, char *ppsz_argv[] )
 {
-    char *psz_env;
+    int i_opt;
 
-    psz_env = getenv( psz_name );
-    if( psz_env )
+    /* We assume that the remaining parameters are filenames */
+    for( i_opt = optind; i_opt < i_argc; i_opt++ )
     {
-        return( psz_env );
+        intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END,
+                          ppsz_argv[ i_opt ] );
     }
-    return( psz_default );
-}
-
-/*****************************************************************************
- * main_PutPszVariable: set the string value of an environment variable
- *****************************************************************************
- * This function is used to set some default parameters in modules. The use of
- * this function will cause some memory leak: since some systems use the pointer
- * passed to putenv to store the environment string, it can't be freed.
- *****************************************************************************/
-void main_PutPszVariable( char *psz_name, char *psz_value )
-{
-    char *psz_env;
 
-    psz_env = malloc( strlen(psz_name) + strlen(psz_value) + 2 );
-    if( psz_env == NULL )
-    {
-        intf_ErrMsg( "intf error: cannot create psz_env (%s)",
-                     strerror(ENOMEM) );
-    }
-    else
-    {
-        sprintf( psz_env, "%s=%s", psz_name, psz_value );
-        if( putenv( psz_env ) )
-        {
-            intf_ErrMsg( "intf error: cannot putenv (%s)", strerror(errno) );
-        }
-    }
+    return( 0 );
 }
 
 /*****************************************************************************
- * main_PutIntVariable: set the integer value of an environment variable
+ * Usage: print program usage
  *****************************************************************************
- * This function is used to set some default parameters in modules. The use of
- * this function will cause some memory leak: since some systems use the pointer
- * passed to putenv to store the environment string, it can't be freed.
+ * Print a short inline help. Message interface is initialized at this stage.
  *****************************************************************************/
-void main_PutIntVariable( char *psz_name, int i_value )
+static void Usage( const char *psz_module_name )
 {
-    char psz_value[ 256 ];                               /* buffer for value */
+    int i;
+    module_t *p_module;
+    char psz_spaces[30];
 
-    sprintf( psz_value, "%d", i_value );
-    main_PutPszVariable( psz_name, psz_value );
-}
-
-/* following functions are local */
+    memset( psz_spaces, 32, 30 );
 
-/*****************************************************************************
- * GetConfiguration: parse command line
- *****************************************************************************
- * Parse command line and configuration file for configuration. If the inline
- * help is requested, the function Usage() is called and the function returns
- * -1 (causing main() to exit). The messages interface is initialized at this
- * stage, but most structures are not allocated, so only environment should
- * be used.
- *****************************************************************************/
-static int GetConfiguration( int *pi_argc, char *ppsz_argv[], char *ppsz_env[] )
-{
-    int   i_cmd;
-    char *p_tmp;
+#ifdef WIN32
+    ShowConsole();
+#endif
 
-    /* Set default configuration and copy arguments */
-    p_main->i_argc    = *pi_argc;
-    p_main->ppsz_argv = ppsz_argv;
-    p_main->ppsz_env  = ppsz_env;
+    /* Enumerate the config of each module */
+    for( p_module = p_module_bank->first ;
+         p_module != NULL ;
+         p_module = p_module->next )
+    {
 
-    p_main->b_audio     = 1;
-    p_main->b_video     = 1;
+        if( psz_module_name && strcmp( psz_module_name, p_module->psz_name ) )
+            continue;
 
-    p_main->i_warning_level = 0;
-    p_main->b_stats = 0;
-    p_main->i_desync = 0; /* No desynchronization by default */
+        /* ignore plugins without config options */
+        if( !p_module->i_config_items ) continue;
 
-    p_main->p_channel = NULL;
+        /* print module name */
+        intf_Msg( "%s options:\n", p_module->psz_name );
 
-    /* Get the executable name (similar to the basename command) */
-    p_main->psz_arg0 = p_tmp = ppsz_argv[ 0 ];
-    while( *p_tmp )
-    {
-        if( *p_tmp == '/' )
-        {
-            p_main->psz_arg0 = ++p_tmp;
-        }
-        else
+        for( i = 0; i < p_module->i_config_lines; i++ )
         {
-            ++p_tmp;
-        }
-    }
-
-#ifdef SYS_DARWIN
-    /* When vlc.app is run by double clicking in Mac OS X, the 2nd arg
-     * is the PSN - process serial number (a unique PID-ish thingie)
-     * still ok for real Darwin & when run from command line */
-    if ( (*pi_argc > 1) && (strncmp( ppsz_argv[ 1 ] , "-psn" , 4 ) == 0) )
-                                        /* for example -psn_0_9306113 */
-    {
-        /* GDMF!... I can't do this or else the MacOSX window server will
-         * not pick up the PSN and not register the app and we crash...
-         * hence the following kludge otherwise we'll get confused w/ argv[1]
-         * being an input file name */
-#if 0
-        ppsz_argv[ 1 ] = NULL;
-#endif
-        *pi_argc = *pi_argc - 1;
-        pi_argc--;
-        return( 0 );
-    }
-#endif
+            int j;
 
-    /* Parse command line options */
-    opterr = 0;
-    while( ( i_cmd = getopt_long( *pi_argc, ppsz_argv,
-                                   psz_shortopts, longopts, 0 ) ) != EOF )
-    {
-        switch( i_cmd )
-        {
-        /* General/common options */
-        case 'h':                                              /* -h, --help */
-            ShowConsole();
-            RedirectSTDOUT();
-            Usage( SHORT_HELP );
-#ifdef WIN32        /* Pause the console because it's destroyed when we exit */
-            if( strcmp( "", main_GetPszVariable( INTF_STDOUT_VAR,
-                                                 INTF_STDOUT_DEFAULT ) ) == 0 )
-            {
-                /* No stdout redirection has been asked for */
-                intf_MsgImm( "\nPress the RETURN key to continue..." );
-                getchar();
-            }
-#endif
-            return( -1 );
-            break;
-        case 'H':                                          /* -H, --longhelp */
-            ShowConsole();
-            RedirectSTDOUT();
-            Usage( LONG_HELP );
-#ifdef WIN32        /* Pause the console because it's destroyed when we exit */
-            if( strcmp( "", main_GetPszVariable( INTF_STDOUT_VAR,
-                                                 INTF_STDOUT_DEFAULT ) ) == 0 )
-            {
-                /* No stdout redirection has been asked for */
-                intf_MsgImm( "\nPress the RETURN key to continue..." );
-                getchar();
-            }
-#endif
-            return( -1 );
-            break;
-        case OPT_VERSION:                                       /* --version */
-            ShowConsole();
-            RedirectSTDOUT();
-            Version();
-#ifdef WIN32        /* Pause the console because it's destroyed when we exit */
-            if( strcmp( "", main_GetPszVariable( INTF_STDOUT_VAR,
-                                                 INTF_STDOUT_DEFAULT ) ) == 0 )
-            {
-                /* No stdout redirection has been asked for */
-                intf_MsgImm( "\nPress the RETURN key to continue..." );
-                getchar();
-            }
-#endif
-            return( -1 );
-            break;
-        case 'v':                                           /* -v, --verbose */
-            p_main->i_warning_level++;
-            break;
-
-        /* Interface warning messages level */
-        case 'I':                                              /* -I, --intf */
-            main_PutPszVariable( INTF_METHOD_VAR, optarg );
-            break;
-        case OPT_WARNING:                                       /* --warning */
-            intf_ErrMsg( "intf error: `--warning' is deprecated, use `-v'" );
-            p_main->i_warning_level = atoi(optarg);
-            break;
-
-        case OPT_STDOUT:                                         /* --stdout */
-            main_PutPszVariable( INTF_STDOUT_VAR, optarg );
-            break;
-
-        case OPT_STATS:
-            p_main->b_stats = 1;
-            break;
-
-        /* Audio options */
-        case OPT_NOAUDIO:                                       /* --noaudio */
-            p_main->b_audio = 0;
-            break;
-        case 'A':                                              /* -A, --aout */
-            main_PutPszVariable( AOUT_METHOD_VAR, optarg );
-            break;
-        case OPT_STEREO:                                         /* --stereo */
-            main_PutIntVariable( AOUT_STEREO_VAR, 1 );
-            break;
-        case OPT_MONO:                                             /* --mono */
-            main_PutIntVariable( AOUT_STEREO_VAR, 0 );
-            break;
-        case OPT_SPDIF:                                           /* --spdif */
-            main_PutIntVariable( AOUT_SPDIF_VAR, 1 );
-            break;
-        case OPT_DOWNMIX:                                       /* --downmix */
-            main_PutPszVariable( DOWNMIX_METHOD_VAR, optarg );
-            break;
-        case OPT_IMDCT:                                           /* --imdct */
-            main_PutPszVariable( IMDCT_METHOD_VAR, optarg );
-            break;
-        case OPT_VOLUME:                                         /* --volume */
-            main_PutIntVariable( AOUT_VOLUME_VAR, atoi(optarg) );
-            break;
-        case OPT_DESYNC:                                         /* --desync */
-            p_main->i_desync = atoi(optarg);
-            break;
-
-        /* Video options */
-        case OPT_NOVIDEO:                                       /* --novideo */
-            p_main->b_video = 0;
-            break;
-        case 'V':                                              /* -V, --vout */
-            main_PutPszVariable( VOUT_METHOD_VAR, optarg );
-            break;
-        case OPT_DISPLAY:                                       /* --display */
-            main_PutPszVariable( VOUT_DISPLAY_VAR, optarg );
-            break;
-        case OPT_WIDTH:                                           /* --width */
-            main_PutPszVariable( VOUT_WIDTH_VAR, optarg );
-            break;
-        case OPT_HEIGHT:                                         /* --height */
-            main_PutPszVariable( VOUT_HEIGHT_VAR, optarg );
-            break;
-        case 'g':                                         /* -g, --grayscale */
-            main_PutIntVariable( VOUT_GRAYSCALE_VAR, 1 );
-            break;
-        case OPT_COLOR:                                           /* --color */
-            main_PutIntVariable( VOUT_GRAYSCALE_VAR, 0 );
-            break;
-        case OPT_FULLSCREEN:                                 /* --fullscreen */
-            main_PutIntVariable( VOUT_FULLSCREEN_VAR, 1 );
-            break;
-        case OPT_NOOVERLAY:                                   /* --nooverlay */
-            main_PutIntVariable( VOUT_NOOVERLAY_VAR, 1 );
-            break;
-        case OPT_XVADAPTOR:                                   /* --xvadaptor */
-            main_PutIntVariable( VOUT_XVADAPTOR_VAR, atoi(optarg) );
-            break;
-        case OPT_MOTION:                                         /* --motion */
-            main_PutPszVariable( MOTION_METHOD_VAR, optarg );
-            break;
-        case OPT_IDCT:                                             /* --idct */
-            main_PutPszVariable( IDCT_METHOD_VAR, optarg );
-            break;
-        case OPT_YUV:                                               /* --yuv */
-            main_PutPszVariable( YUV_METHOD_VAR, optarg );
-            break;
-        case OPT_SMP:                                               /* --smp */
-            main_PutIntVariable( VDEC_SMP_VAR, atoi(optarg) );
-            break;
-        case OPT_FILTER:                                         /* --filter */
-            main_PutPszVariable( VOUT_FILTER_VAR, optarg );
-            break;
-
-        /* DVD options */
-        case 't':                                              /* --dvdtitle */
-            main_PutIntVariable( INPUT_TITLE_VAR, atoi(optarg) );
-            break;
-        case 'T':                                            /* --dvdchapter */
-            main_PutIntVariable( INPUT_CHAPTER_VAR, atoi(optarg) );
-            break;
-        case 'u':                                              /* --dvdangle */
-            main_PutIntVariable( INPUT_ANGLE_VAR, atoi(optarg) );
-            break;
-        case 'a':                                              /* --dvdaudio */
-            if ( ! strcmp(optarg, "ac3") )
-                main_PutIntVariable( INPUT_AUDIO_VAR, REQUESTED_AC3 );
-            else if ( ! strcmp(optarg, "lpcm") )
-                main_PutIntVariable( INPUT_AUDIO_VAR, REQUESTED_LPCM );
-            else if ( ! strcmp(optarg, "mpeg") )
-                main_PutIntVariable( INPUT_AUDIO_VAR, REQUESTED_MPEG );
-            else
-                main_PutIntVariable( INPUT_AUDIO_VAR, REQUESTED_NOAUDIO );
-            break;
-        case 'c':                                            /* --dvdchannel */
-            main_PutIntVariable( INPUT_CHANNEL_VAR, atoi(optarg) );
-            break;
-        case 's':                                           /* --dvdsubtitle */
-            main_PutIntVariable( INPUT_SUBTITLE_VAR, atoi(optarg) );
-            break;
-        case OPT_DVDCSS_METHOD:                           /* --dvdcss-method */
-            main_PutPszVariable( "DVDCSS_METHOD", optarg );
-            break;
-        case OPT_DVDCSS_VERBOSE:                         /* --dvdcss-verbose */
-            main_PutPszVariable( "DVDCSS_VERBOSE", optarg );
-            break;
-
-        /* Input options */
-        case OPT_INPUT:                                           /* --input */
-            main_PutPszVariable( INPUT_METHOD_VAR, optarg );
-            break;
-        case OPT_CHANNELS:                                     /* --channels */
-            main_PutIntVariable( INPUT_NETWORK_CHANNEL_VAR, 1 );
-            break;
-        case OPT_CHANNELSERVER:                           /* --channelserver */
-            main_PutPszVariable( INPUT_CHANNEL_SERVER_VAR, optarg );
-            break;
-
-        /* Misc options */
-        case OPT_SYNCHRO:
-            main_PutPszVariable( VPAR_SYNCHRO_VAR, optarg );
-            break;
-        case OPT_MEMCPY:
-            main_PutPszVariable( MEMCPY_METHOD_VAR, optarg );
-            break;
-
-        /* Decoder options */
-        case OPT_MPEG_ADEC:
-            main_PutPszVariable( ADEC_MPEG_VAR, optarg );
-            break;
-
-        /* CPU options */
-        case OPT_NOMMX:
-            p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_MMX;
-            break;
-
-        case OPT_NO3DNOW:
-            p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_3DNOW;
-            break;
-
-        case OPT_NOMMXEXT:
-            p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_MMXEXT;
-            break;
-
-        case OPT_NOSSE:
-            p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_SSE;
-            break;
-
-        case OPT_NOALTIVEC:
-            p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_ALTIVEC;
-            break;
-
-        /* Internal error: unknown option */
-        case '?':
-        default:
-            ShowConsole();
-            RedirectSTDOUT();
-            intf_ErrMsg( "intf error: unknown option `%s'",
-                         ppsz_argv[optind] );
-            Usage( USAGE );
-#ifdef WIN32        /* Pause the console because it's destroyed when we exit */
-            if( strcmp( "", main_GetPszVariable( INTF_STDOUT_VAR,
-                                                 INTF_STDOUT_DEFAULT ) ) == 0 )
+            switch( p_module->p_config[i].i_type )
             {
-                /* No stdout redirection has been asked for */
-                intf_MsgImm( "\nPress the RETURN key to continue..." );
-                getchar();
+            case MODULE_CONFIG_HINT_CATEGORY:
+                intf_Msg( " %s", p_module->p_config[i].psz_text );
+                break;
+
+            case MODULE_CONFIG_ITEM_STRING:
+            case MODULE_CONFIG_ITEM_FILE:
+            case MODULE_CONFIG_ITEM_PLUGIN:
+                /* Nasty hack, but right now I'm too tired to think about
+                 * a nice solution */
+                j = 25 - strlen( p_module->p_config[i].psz_name )
+                    - strlen(" <string>") - 1;
+                if( j < 0 ) j = 0; psz_spaces[j] = 0;
+
+                intf_Msg( "  --%s <string>%s %s",
+                          p_module->p_config[i].psz_name, psz_spaces,
+                          p_module->p_config[i].psz_text );
+                psz_spaces[j] = 32;
+                break;
+            case MODULE_CONFIG_ITEM_INTEGER:
+                /* Nasty hack, but right now I'm too tired to think about
+                 * a nice solution */
+                j = 25 - strlen( p_module->p_config[i].psz_name )
+                    - strlen(" <integer>") - 1;
+                if( j < 0 ) j = 0; psz_spaces[j] = 0;
+
+                intf_Msg( "  --%s <integer>%s %s",
+                          p_module->p_config[i].psz_name, psz_spaces,
+                          p_module->p_config[i].psz_text );
+                psz_spaces[j] = 32;
+                break;
+            case MODULE_CONFIG_ITEM_BOOL:
+                /* Nasty hack, but right now I'm too tired to think about
+                 * a nice solution */
+                j = 25 - strlen( p_module->p_config[i].psz_name ) - 1;
+                if( j < 0 ) j = 0; psz_spaces[j] = 0;
+
+                intf_Msg( "  --%s%s %s",
+                          p_module->p_config[i].psz_name, psz_spaces,
+                          p_module->p_config[i].psz_text );
+                psz_spaces[j] = 32;
+                break;
             }
-#endif
-            return( EINVAL );
-            break;
         }
-    }
 
-    if( p_main->i_warning_level < 0 )
-    {
-        p_main->i_warning_level = 0;
+        /* Yet another nasty hack.
+         * Maybe we could use MODULE_CONFIG_ITEM_END to display tail messages
+         * for each module?? */
+        if( !strcmp( "main", p_module->psz_name ) )
+            intf_Msg( "\nPlaylist items:"
+                "\n  *.mpg, *.vob                   \tPlain MPEG-1/2 files"
+                "\n  [dvd:][device][@raw_device][@[title][,[chapter][,angle]]]"
+                "\n                                 \tDVD device"
+                "\n  [vcd:][device][@[title][,[chapter]]"
+                "\n                                 \tVCD device"
+                "\n  udpstream:[<server>[:<server port>]][@[<bind address>]"
+                      "[:<bind port>]]"
+                "\n                                 \tUDP stream sent by VLS"
+                "\n  vlc:loop                       \tLoop execution of the "
+                      "playlist"
+                "\n  vlc:pause                      \tPause execution of "
+                      "playlist items"
+                "\n  vlc:quit                       \tQuit VLC" );
+
+        intf_Msg( "" );
+
     }
 
-    return( 0 );
+#ifdef WIN32        /* Pause the console because it's destroyed when we exit */
+        intf_Msg( "\nPress the RETURN key to continue..." );
+        getchar();
+#endif
 }
 
 /*****************************************************************************
- * GetFilenames: parse command line options which are not flags
+ * ListModules: list the available modules with their description
  *****************************************************************************
- * Parse command line for input files.
+ * Print a list of all available modules (builtins and plugins) and a short
+ * description for each one.
  *****************************************************************************/
-static int GetFilenames( int i_argc, char *ppsz_argv[] )
+static void ListModules( void )
 {
-    int i_opt;
+    module_t *p_module;
+    char psz_spaces[20];
 
-    /* We assume that the remaining parameters are filenames */
-    for( i_opt = optind; i_opt < i_argc; i_opt++ )
-    {
-        intf_PlaylistAdd( p_main->p_playlist, PLAYLIST_END,
-                          ppsz_argv[ i_opt ] );
-    }
+    memset( psz_spaces, 32, 20 );
 
-    return( 0 );
-}
+#ifdef WIN32
+    ShowConsole();
+#endif
 
-/*****************************************************************************
- * Usage: print program usage
- *****************************************************************************
- * Print a short inline help. Message interface is initialized at this stage.
- *****************************************************************************/
-static void Usage( int i_fashion )
-{
     /* Usage */
-    intf_MsgImm( "Usage: %s [options] [parameters] [file]...",
-                 p_main->psz_arg0 );
+    intf_Msg( "Usage: %s [options] [parameters] [file]...\n",
+              p_main->psz_arg0 );
 
-    if( i_fashion == USAGE )
+    intf_Msg( "[plugin]              [description]" );
+
+    /* Enumerate each module */
+    for( p_module = p_module_bank->first ;
+         p_module != NULL ;
+         p_module = p_module->next )
     {
-        intf_MsgImm( "Try `%s --help' for more information.",
-                     p_main->psz_arg0 );
-        return;
+        int i;
+
+        /* Nasty hack, but right now I'm too tired to think about a nice
+         * solution */
+        i = 20 - strlen( p_module->psz_name ) - 1;
+        if( i < 0 ) i = 0;
+        psz_spaces[i] = 0;
+
+        intf_Msg( "  %s%s %s", p_module->psz_name, psz_spaces,
+                  p_module->psz_longname );
+
+        psz_spaces[i] = 32;
+
     }
 
-    /* Options */
-    intf_MsgImm( "\nOptions:"
-          "\n  -I, --intf <module>            \tinterface method"
-          "\n  -v, --verbose                  \tverbose mode (cumulative)"
-          "\n      --stdout <filename>        \tredirect console stdout"
-          "\n      --memcpy <module>          \tmemcpy method"
-          "\n"
-          "\n      --noaudio                  \tdisable audio"
-          "\n  -A, --aout <module>            \taudio output method"
-          "\n      --stereo, --mono           \tstereo/mono audio"
-          "\n      --spdif                    \tAC3 pass-through mode"
-          "\n      --downmix <module>         \tAC3 downmix method"
-          "\n      --imdct <module>           \tAC3 IMDCT method"
-          "\n      --volume [0..1024]         \tVLC output volume"
-          "\n      --desync <time in ms>      \tCompensate desynchronization of the audio"
-          "\n"
-          "\n      --novideo                  \tdisable video"
-          "\n  -V, --vout <module>            \tvideo output method"
-          "\n      --display <display>        \tdisplay string"
-          "\n      --width <w>, --height <h>  \tdisplay dimensions"
-          "\n  -g, --grayscale                \tgrayscale output"
-          "\n      --fullscreen               \tfullscreen output"
-          "\n      --nooverlay                \tdisable accelerated display"
-          "\n      --xvadaptor <adaptor>      \tXVideo adaptor"
-          "\n      --color                    \tcolor output"
-          "\n      --motion <module>          \tmotion compensation method"
-          "\n      --idct <module>            \tIDCT method"
-          "\n      --yuv <module>             \tYUV method"
-          "\n      --synchro <type>           \tforce synchro algorithm"
-          "\n      --smp <number of threads>  \tuse several processors"
-          "\n      --filter <module>          \tvideo filter module"
-          "\n"
-          "\n  -t, --dvdtitle <num>           \tchoose DVD title"
-          "\n  -T, --dvdchapter <num>         \tchoose DVD chapter"
-          "\n  -u, --dvdangle <num>           \tchoose DVD angle"
-          "\n  -a, --dvdaudio <type>          \tchoose DVD audio type"
-          "\n  -c, --dvdchannel <channel>     \tchoose DVD audio channel"
-          "\n  -s, --dvdsubtitle <channel>    \tchoose DVD subtitle channel"
-          "\n      --dvdcss-method <method>   \tselect dvdcss decryption method"
-          "\n      --dvdcss-verbose <level>   \tselect dvdcss verbose level"
-          "\n"
-          "\n      --input                    \tinput method"
-          "\n      --channels                 \tenable channels"
-          "\n      --channelserver <host>     \tchannel server address"
-          "\n"
-          "\n      --mpeg_adec <builtin|mad>  \tchoose audio decoder"
-          "\n"
-          "\n      --nommx                    \tdisable CPU's MMX support"
-          "\n      --no3dnow                  \tdisable CPU's 3D Now! support"
-          "\n      --nommxext                 \tdisable CPU's MMX EXT support"
-          "\n      --nosse                    \tdisable CPU's SSE support"
-          "\n      --noaltivec                \tdisable CPU's AltiVec support"
-          "\n"
-          "\n  -h, --help                     \tprint help and exit"
-          "\n  -H, --longhelp                 \tprint long help and exit"
-          "\n      --version                  \toutput version information and exit"
-          "\n\nPlaylist items:"
-          "\n  *.mpg, *.vob                   \tPlain MPEG-1/2 files"
-          "\n  dvd:<device>[@<raw device>]    \tDVD device"
-          "\n  vcd:<device>                   \tVCD device"
-          "\n  udpstream:[<server>[:<server port>]][@[<bind address>][:<bind port>]]"
-          "\n                                 \tUDP stream sent by VLS"
-          "\n  vlc:loop                       \tLoop execution of the playlist"
-          "\n  vlc:pause                      \tPause execution of playlist items"
-          "\n  vlc:quit                       \tQuit VLC");
-
-    if( i_fashion == SHORT_HELP )
-        return;
-
-    /* Interface parameters */
-    intf_MsgImm( "\nInterface parameters:"
-        "\n  " INTF_METHOD_VAR "=<method name>        \tinterface method"
-        "\n  " INTF_INIT_SCRIPT_VAR "=<filename>              \tinitialization script"
-        "\n  " INTF_CHANNELS_VAR "=<filename>         \tchannels list"
-        "\n  " INTF_STDOUT_VAR "=<filename>           \tredirect console stdout"
-        "\n  " MEMCPY_METHOD_VAR "=<method name>      \tmemcpy method" );
-
-    /* Audio parameters */
-    intf_MsgImm( "\nAudio parameters:"
-        "\n  " AOUT_METHOD_VAR "=<method name>        \taudio method"
-        "\n  " AOUT_DSP_VAR "=<filename>              \tdsp device path"
-        "\n  " AOUT_STEREO_VAR "={1|0}                \tstereo or mono output"
-        "\n  " AOUT_SPDIF_VAR "={1|0}                 \tAC3 pass-through mode"
-        "\n  " DOWNMIX_METHOD_VAR "=<method name>     \tAC3 downmix method"
-        "\n  " IMDCT_METHOD_VAR "=<method name>       \tAC3 IMDCT method"
-        "\n  " AOUT_VOLUME_VAR "=[0..1024]            \tVLC output volume"
-        "\n  " AOUT_RATE_VAR "=<rate>                 \toutput rate" );
-
-    /* Video parameters */
-    intf_MsgImm( "\nVideo parameters:"
-        "\n  " VOUT_METHOD_VAR "=<method name>        \tdisplay method"
-        "\n  " VOUT_DISPLAY_VAR "=<display name>      \tdisplay used"
-        "\n  " VOUT_WIDTH_VAR "=<width>               \tdisplay width"
-        "\n  " VOUT_HEIGHT_VAR "=<height>             \tdislay height"
-        "\n  " VOUT_FB_DEV_VAR "=<filename>           \tframebuffer device path"
-        "\n  " VOUT_GRAYSCALE_VAR "={1|0}             \tgrayscale or color output"
-        "\n  " VOUT_FULLSCREEN_VAR "={1|0}            \tfullscreen"
-        "\n  " VOUT_NOOVERLAY_VAR "={1|0}             \tnooverlay"
-        "\n  " VOUT_XVADAPTOR_VAR "=<adaptor>         \tXVideo adaptor"
-        "\n  " MOTION_METHOD_VAR "=<method name>      \tmotion compensation method"
-        "\n  " IDCT_METHOD_VAR "=<method name>        \tIDCT method"
-        "\n  " YUV_METHOD_VAR "=<method name>         \tYUV method"
-        "\n  " VPAR_SYNCHRO_VAR "={I|I+|IP|IP+|IPB}   \tsynchro algorithm"
-        "\n  " VDEC_SMP_VAR "=<number of threads>     \tuse several processors"
-        "\n  " VOUT_FILTER_VAR "=<method name>        \tvideo filter method" );
-
-    /* DVD parameters */
-    intf_MsgImm( "\nDVD parameters:"
-        "\n  " INPUT_DVD_DEVICE_VAR "=<device>        \tDVD device"
-        "\n  " INPUT_TITLE_VAR "=<title>              \ttitle number"
-        "\n  " INPUT_CHAPTER_VAR "=<chapter>          \tchapter number"
-        "\n  " INPUT_ANGLE_VAR "=<angle>              \tangle number"
-        "\n  " INPUT_AUDIO_VAR "={ac3|lpcm|mpeg|off}  \taudio type"
-        "\n  " INPUT_CHANNEL_VAR "=[0-15]             \taudio channel"
-        "\n  " INPUT_SUBTITLE_VAR "=[0-31]            \tsubtitle channel" );
-
-    /* Input parameters */
-    intf_MsgImm( "\nInput parameters:"
-        "\n  " INPUT_IFACE_VAR "=<interface>          \tnetwork interface"
-        "\n  " INPUT_CHANNEL_SERVER_VAR "=<hostname>  \tchannel server"
-        "\n  " INPUT_CHANNEL_PORT_VAR "=<port>        \tchannel server port" );
-
-    /* Decoder parameters */
-    intf_MsgImm( "\nDecoder parameters:"
-        "\n  " ADEC_MPEG_VAR "=<builtin|mad>          \taudio decoder" );
+#ifdef WIN32        /* Pause the console because it's destroyed when we exit */
+        intf_Msg( "\nPress the RETURN key to continue..." );
+        getchar();
+#endif
 }
 
 /*****************************************************************************
@@ -1078,11 +1007,20 @@ static void Usage( int i_fashion )
  *****************************************************************************/
 static void Version( void )
 {
-    intf_MsgImm( VERSION_MESSAGE
-        "This program comes with NO WARRANTY, to the extent permitted by law.\n"
-        "You may redistribute it under the terms of the GNU General Public License;\n"
-        "see the file named COPYING for details.\n"
+#ifdef WIN32
+    ShowConsole();
+#endif
+
+    intf_Msg( VERSION_MESSAGE
+        "This program comes with NO WARRANTY, to the extent permitted by "
+        "law.\nYou may redistribute it under the terms of the GNU General "
+        "Public License;\nsee the file named COPYING for details.\n"
         "Written by the VideoLAN team at Ecole Centrale, Paris." );
+
+#ifdef WIN32        /* Pause the console because it's destroyed when we exit */
+        intf_Msg( "\nPress the RETURN key to continue..." );
+        getchar();
+#endif
 }
 
 /*****************************************************************************
@@ -1135,7 +1073,7 @@ static void FatalSignalHandler( int i_signal )
 #endif
 
     /* Acknowledge the signal received */
-    intf_ErrMsgImm( "intf error: signal %d received, exiting", i_signal );
+    intf_ErrMsg( "intf error: signal %d received, exiting", i_signal );
 
     /* Try to terminate everything - this is done by requesting the end of the
      * interface thread */
@@ -1145,7 +1083,7 @@ static void FatalSignalHandler( int i_signal )
 /*****************************************************************************
  * IllegalSignalHandler: system signal handler
  *****************************************************************************
- * This function is called when a illegal instruction signal is received by
+ * This function is called when an illegal instruction signal is received by
  * the program. We use this function to test OS and CPU capabilities
  *****************************************************************************/
 static void IllegalSignalHandler( int i_signal )
@@ -1387,61 +1325,18 @@ static u32 CPUCapabilities( void )
 #endif
 }
 
-/*****************************************************************************
- * RedirectSTDOUT: redirect stdout and stderr to a file
- *****************************************************************************
- * This function will redirect stdout and stderr to a file if the user has
- * specified so.
- *****************************************************************************/
-static int RedirectSTDOUT( void )
-{
-    int  i_fd;
-    char *psz_filename;
-
-    psz_filename = main_GetPszVariable( INTF_STDOUT_VAR, INTF_STDOUT_DEFAULT );
-
-    if( *psz_filename )
-    {
-        ShowConsole();
-        i_fd = open( psz_filename, O_CREAT | O_TRUNC | O_RDWR,
-                                   S_IREAD | S_IWRITE );
-        if( dup2( i_fd, fileno(stdout) ) == -1 )
-        {
-            intf_ErrMsg( "warning: unable to redirect stdout" );
-        }
-
-        if( dup2( i_fd, fileno(stderr) ) == -1 )
-        {
-            intf_ErrMsg( "warning: unable to redirect stderr" );
-        }
-
-        close( i_fd );
-    }
-    else
-    {
-        /* No stdout redirection has been asked so open a console */
-        if( p_main->i_warning_level )
-        {
-            ShowConsole();
-        }
-
-    }
-
-    return 0;
-}
-
 /*****************************************************************************
  * ShowConsole: On Win32, create an output console for debug messages
  *****************************************************************************
  * This function is usefull only on Win32.
  *****************************************************************************/
+#ifdef WIN32 /*  */
 static void ShowConsole( void )
 {
-#ifdef WIN32 /*  */
     AllocConsole();
     freopen( "CONOUT$", "w", stdout );
     freopen( "CONOUT$", "w", stderr );
     freopen( "CONIN$", "r", stdin );
-#endif
     return;
 }
+#endif