Commit 0170377d authored by Gildas Bazin's avatar Gildas Bazin

* changed ADD_BOOL and ADD_BOOL_WITH_SHORT config macros to accept a
default value as an argument.
* modified the command line parsing to accept --foo and --no-foo when a
"foo" boolean config option is defined.
* modified the help menu to indicate if the option is enabled or
disabled by default.
parent 9df1a97b
......@@ -4,7 +4,7 @@
* It includes functions allowing to declare, get or set configuration options.
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: configuration.h,v 1.10 2002/05/03 20:49:30 sam Exp $
* $Id: configuration.h,v 1.11 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -141,27 +141,25 @@ void config_UnsetCallbacks( module_config_t * );
#define ADD_FLOAT( name, f_value, p_callback, text, longtext ) \
{ MODULE_CONFIG_ITEM_FLOAT, name, '\0', text, longtext, NULL, 0, f_value, \
p_callback, NULL, 0 },
#define ADD_BOOL( name, p_callback, text, longtext ) \
{ MODULE_CONFIG_ITEM_BOOL, name, '\0', text, longtext, NULL, 0, 0, \
#define ADD_BOOL( name, b_value, p_callback, text, longtext ) \
{ MODULE_CONFIG_ITEM_BOOL, name, '\0', text, longtext, NULL, b_value, 0, \
p_callback, NULL, 0 },
#define ADD_STRING_WITH_SHORT( name, ch, value, p_callback, text, longtext ) \
{ MODULE_CONFIG_ITEM_STRING, name, ch, text, longtext, value, 0, 0, \
#define ADD_STRING_WITH_SHORT( name, ch, psz_value, p_callback, text, ltext ) \
{ MODULE_CONFIG_ITEM_STRING, name, ch, text, ltext, psz_value, 0, 0, \
p_callback, NULL, 0 },
#define ADD_FILE_WITH_SHORT( name, ch, psz_value, p_callback, text, longtext ) \
{ MODULE_CONFIG_ITEM_FILE, name, ch, text, longtext, psz_value, 0, 0, \
#define ADD_FILE_WITH_SHORT( name, ch, psz_value, p_callback, text, ltext ) \
{ MODULE_CONFIG_ITEM_FILE, name, ch, text, ltext, psz_value, 0, 0, \
p_callback, NULL, 0 },
#define ADD_MODULE_WITH_SHORT( name, ch, i_capability, psz_value, p_callback, \
text, longtext) \
{ MODULE_CONFIG_ITEM_MODULE, name, ch, text, longtext, psz_value, \
text, ltext) \
{ MODULE_CONFIG_ITEM_MODULE, name, ch, text, ltext, psz_value, \
i_capability, 0, p_callback, NULL, 0 },
#define ADD_INTEGER_WITH_SHORT( name, ch, i_value, p_callback, text, \
longtext ) \
{ MODULE_CONFIG_ITEM_INTEGER, name, ch, text, longtext, NULL, i_value, 0, \
#define ADD_INTEGER_WITH_SHORT( name, ch, i_value, p_callback, text, ltext ) \
{ MODULE_CONFIG_ITEM_INTEGER, name, ch, text, ltext, NULL, i_value, 0, \
p_callback, NULL, 0 },
#define ADD_FLOAT_WITH_SHORT( name, f_value, p_callback, text, longtext ) \
{ MODULE_CONFIG_ITEM_FLOAT, name, ch, text, longtext, NULL, 0, f_value, \
#define ADD_FLOAT_WITH_SHORT( name, ch, f_value, p_callback, text, ltext ) \
{ MODULE_CONFIG_ITEM_FLOAT, name, ch, text, ltext, NULL, 0, f_value, \
p_callback, NULL, 0 },
#define ADD_BOOL_WITH_SHORT( name, ch, p_callback, text, longtext ) \
{ MODULE_CONFIG_ITEM_BOOL, name, ch, text, longtext, NULL, 0, 0, \
#define ADD_BOOL_WITH_SHORT( name, ch, b_value, p_callback, text, ltext ) \
{ MODULE_CONFIG_ITEM_BOOL, name, ch, text, ltext, NULL, b_value, 0, \
p_callback, NULL, 0 },
......@@ -2,7 +2,7 @@
* modules.h : Module management functions.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules.h,v 1.50 2002/05/18 17:47:46 sam Exp $
* $Id: modules.h,v 1.51 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -132,6 +132,7 @@ typedef struct module_s
struct module_config_s *p_config; /* Module configuration structure */
vlc_mutex_t config_lock; /* lock used to modify the config */
unsigned int i_config_items; /* number of configuration items */
unsigned int i_bool_items; /* number of bool config items */
/*
* Variables used internally by the module manager
......
......@@ -2,7 +2,7 @@
* modules_inner.h : Macros used from within a module.
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules_inner.h,v 1.21 2002/05/22 17:17:45 sam Exp $
* $Id: modules_inner.h,v 1.22 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -93,13 +93,15 @@
#define MODULE_INIT_STOP \
} while( 0 ); \
p_module->pp_shortcuts[ i_shortcut ] = NULL; \
p_module->i_config_items = 0; \
p_module->i_config_items = p_module->i_bool_items = 0; \
for( p_item = p_config; \
p_item->i_type != MODULE_CONFIG_HINT_END; \
p_item++ ) \
{ \
if( p_item->i_type & MODULE_CONFIG_ITEM ) \
p_module->i_config_items++; \
if( p_item->i_type == MODULE_CONFIG_ITEM_BOOL ) \
p_module->i_bool_items++; \
} \
vlc_mutex_init( &p_module->config_lock ); \
p_module->p_config = config_Duplicate( p_config ); \
......
......@@ -4,7 +4,7 @@
* (http://liba52.sf.net/).
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: a52.c,v 1.13 2002/05/27 16:01:42 fenrir Exp $
* $Id: a52.c,v 1.14 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -72,7 +72,7 @@ void _M( adec_getfunctions )( function_list_t * p_function_list )
/*****************************************************************************
* Build configuration structure.
*****************************************************************************/
#define DYNRNG_TEXT N_("disable A/52 dynamic range compression")
#define DYNRNG_TEXT N_("A/52 dynamic range compression")
#define DYNRNG_LONGTEXT N_( \
"Dynamic range compression makes the loud sounds softer, and the soft " \
"sounds louder, so you can more easily listen to the stream in a noisy " \
......@@ -82,7 +82,7 @@ void _M( adec_getfunctions )( function_list_t * p_function_list )
MODULE_CONFIG_START
ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
ADD_BOOL ( "a52-no-dynrng", NULL, DYNRNG_TEXT, DYNRNG_LONGTEXT )
ADD_BOOL ( "a52-dynrng", 1, NULL, DYNRNG_TEXT, DYNRNG_LONGTEXT )
MODULE_CONFIG_STOP
MODULE_INIT_START
......@@ -209,7 +209,7 @@ static int InitThread( a52_adec_thread_t * p_a52_adec )
return -1;
}
p_a52_adec->b_dynrng = !config_GetIntVariable( "a52-no-dynrng" );
p_a52_adec->b_dynrng = config_GetIntVariable( "a52-dynrng" );
/* Init the BitStream */
InitBitstream( &p_a52_adec->bit_stream,
......
......@@ -2,7 +2,7 @@
* vout_beos.cpp: beos video output display method
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: vout_beos.cpp,v 1.57 2002/05/22 12:23:41 tcastley Exp $
* $Id: vout_beos.cpp,v 1.58 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Jean-Marc Dressler <polux@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -279,7 +279,7 @@ int VideoWindow::SelectDrawingMode(int width, int height)
{
int drawingMode = BITMAP;
int noOverlay = config_GetIntVariable( "nooverlay" );
int noOverlay = !config_GetIntVariable( "overlay" );
for (int i = 0; i < COLOR_COUNT; i++)
{
if (noOverlay) break;
......
......@@ -2,7 +2,7 @@
* directx.c : Windows DirectX plugin for vlc
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: directx.c,v 1.9 2002/05/22 19:31:33 gbazin Exp $
* $Id: directx.c,v 1.10 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -43,11 +43,11 @@ void _M( vout_getfunctions )( function_list_t * p_function_list );
/*****************************************************************************
* Building configuration tree
*****************************************************************************/
#define HW_YUV_TEXT N_("Disable hardware YUV->RGB conversions")
#define HW_YUV_TEXT N_("use hardware YUV->RGB conversions")
#define HW_YUV_LONGTEXT N_( \
"Don't try to use hardware acceleration for YUV->RGB conversions. This " \
"option doesn't have any effect when using overlays." )
#define SYSMEM_TEXT N_("Use video buffers in system memory")
"Try to use hardware acceleration for YUV->RGB conversions. " \
"This option doesn't have any effect when using overlays." )
#define SYSMEM_TEXT N_("use video buffers in system memory")
#define SYSMEM_LONGTEXT N_( \
"Create video buffers in system memory instead of video memory. This " \
"isn't recommended as usually using video memory allows to benefit from " \
......@@ -56,9 +56,8 @@ void _M( vout_getfunctions )( function_list_t * p_function_list );
MODULE_CONFIG_START
ADD_CATEGORY_HINT( N_("Video"), NULL )
ADD_BOOL ( "no-directx-hw-yuv", NULL, HW_YUV_TEXT, HW_YUV_LONGTEXT )
ADD_BOOL ( "directx-use-sysmem", NULL, SYSMEM_TEXT, SYSMEM_LONGTEXT )
ADD_CATEGORY_HINT( N_("Audio"), NULL )
ADD_BOOL ( "directx-hw-yuv", 1, NULL, HW_YUV_TEXT, HW_YUV_LONGTEXT )
ADD_BOOL ( "directx-use-sysmem", 0, NULL, SYSMEM_TEXT, SYSMEM_LONGTEXT )
MODULE_CONFIG_STOP
MODULE_INIT_START
......
......@@ -2,7 +2,7 @@
* vout_directx.c: Windows DirectX video output display method
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: vout_directx.c,v 1.35 2002/05/18 22:41:43 gbazin Exp $
* $Id: vout_directx.c,v 1.36 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -128,9 +128,9 @@ static int vout_Create( vout_thread_t *p_vout )
p_vout->p_sys->b_event_thread_die = 0;
p_vout->p_sys->b_caps_overlay_clipping = 0;
SetRectEmpty( &p_vout->p_sys->rect_display );
p_vout->p_sys->b_using_overlay = !config_GetIntVariable( "nooverlay" );
p_vout->p_sys->b_using_overlay = config_GetIntVariable( "overlay" );
p_vout->p_sys->b_use_sysmem = config_GetIntVariable( "directx-use-sysmem");
p_vout->p_sys->b_hw_yuv = !config_GetIntVariable( "no-directx-hw-yuv" );
p_vout->p_sys->b_hw_yuv = config_GetIntVariable( "directx-hw-yuv" );
p_vout->p_sys->b_cursor_hidden = 0;
p_vout->p_sys->i_lastmoved = mdate();
......
......@@ -2,7 +2,7 @@
* wall.c : Wall video plugin for vlc
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: wall.c,v 1.19 2002/05/28 22:49:25 sam Exp $
* $Id: wall.c,v 1.20 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -153,7 +153,6 @@ static int vout_Create( vout_thread_t *p_vout )
if( p_vout->p_sys->pp_vout == NULL )
{
intf_ErrMsg("error: %s", strerror(ENOMEM) );
free( psz_method_tmp );
free( p_vout->p_sys );
return( 1 );
}
......
......@@ -2,7 +2,7 @@
* gnome.c : Gnome plugin for vlc
*****************************************************************************
* Copyright (C) 2000 VideoLAN
* $Id: gnome.c,v 1.21 2002/05/22 14:20:41 gbazin Exp $
* $Id: gnome.c,v 1.22 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -61,10 +61,11 @@ static gint GnomeManage ( gpointer p_data );
/*****************************************************************************
* Building configuration tree
*****************************************************************************/
#define TOOLTIPS_TEXT N_("hide tooltips")
#define TOOLTIPS_LONGTEXT N_("Do not show tooltips for configuration options.")
#define TOOLBAR_TEXT N_("hide text on toolbar buttons")
#define TOOLBAR_LONGTEXT N_("Do not show the text below icons on the toolbar.")
#define TOOLTIPS_TEXT N_("show tooltips")
#define TOOLTIPS_LONGTEXT N_("Show tooltips for configuration options.")
#define TOOLBAR_TEXT N_("show text on toolbar buttons")
#define TOOLBAR_LONGTEXT N_("Show the text below icons on the toolbar.")
#define PREFS_MAXH_TEXT N_("maximum height for the configuration windows")
#define PREFS_MAXH_LONGTEXT N_( \
......@@ -72,12 +73,12 @@ static gint GnomeManage ( gpointer p_data );
"preferences menu will occupy.")
MODULE_CONFIG_START
ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
ADD_BOOL ( "gnome-notooltips", GtkHideTooltips, TOOLTIPS_TEXT,
ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
ADD_BOOL ( "gnome-tooltips", 1, GtkHideTooltips, TOOLTIPS_TEXT,
TOOLTIPS_LONGTEXT )
ADD_BOOL ( "gnome-notoolbartext", GtkHideToolbarText, TOOLBAR_TEXT,
ADD_BOOL ( "gnome-toolbartext", GtkHideToolbarText, TOOLBAR_TEXT,
TOOLBAR_LONGTEXT )
ADD_INTEGER ( "gnome-prefs-maxh", 480, NULL, PREFS_MAXH_TEXT,
ADD_INTEGER( "gnome-prefs-maxh", 480, NULL, PREFS_MAXH_TEXT,
PREFS_MAXH_LONGTEXT )
MODULE_CONFIG_STOP
......@@ -272,11 +273,11 @@ static void intf_Run( intf_thread_t *p_intf )
p_intf->p_sys->p_tooltips = gtk_tooltips_new();
/* Hide tooltips if the option is set */
if( config_GetIntVariable( "gnome-notooltips" ) )
if( !config_GetIntVariable( "gnome-tooltips" ) )
gtk_tooltips_disable( p_intf->p_sys->p_tooltips );
/* Hide toolbar text of the option is set */
if ( config_GetIntVariable( "gnome-notoolbartext" ) )
if( !config_GetIntVariable( "gnome-toolbartext" ) )
gtk_toolbar_set_style(
GTK_TOOLBAR(lookup_widget( p_intf->p_sys->p_window, "toolbar" )),
GTK_TOOLBAR_ICONS );
......
......@@ -2,7 +2,7 @@
* gtk.c : Gtk+ plugin for vlc
*****************************************************************************
* Copyright (C) 2000-2001 VideoLAN
* $Id: gtk.c,v 1.22 2002/05/20 22:39:36 sam Exp $
* $Id: gtk.c,v 1.23 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -62,8 +62,8 @@ static gint GtkManage ( gpointer p_data );
/*****************************************************************************
* Building configuration tree
*****************************************************************************/
#define TOOLTIPS_TEXT N_("hide tooltips")
#define TOOLTIPS_LONGTEXT N_("Do not show tooltips for configuration options.")
#define TOOLTIPS_TEXT N_("show tooltips")
#define TOOLTIPS_LONGTEXT N_("Show tooltips for configuration options.")
#define PREFS_MAXH_TEXT N_("maximum height for the configuration windows")
#define PREFS_MAXH_LONGTEXT N_( \
......@@ -71,11 +71,9 @@ static gint GtkManage ( gpointer p_data );
"preferences menu will occupy.")
MODULE_CONFIG_START
ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
ADD_BOOL ( "gtk-notooltips", GtkHideTooltips, TOOLTIPS_TEXT,
TOOLTIPS_LONGTEXT )
ADD_INTEGER ( "gtk-prefs-maxh", 480, NULL, PREFS_MAXH_TEXT,
PREFS_MAXH_LONGTEXT )
ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
ADD_BOOL( "gtk-tooltips", 1, GtkHideTooltips, TOOLTIPS_TEXT, TOOLTIPS_LONGTEXT)
ADD_INTEGER( "gtk-prefs-maxh", 480, NULL, PREFS_MAXH_TEXT, PREFS_MAXH_LONGTEXT)
MODULE_CONFIG_STOP
MODULE_INIT_START
......@@ -271,7 +269,7 @@ static void intf_Run( intf_thread_t *p_intf )
p_intf->p_sys->p_jump = NULL;
/* Hide tooltips if the option is set */
if( config_GetIntVariable( "gtk-notooltips" ) )
if( !config_GetIntVariable( "gtk-tooltips" ) )
gtk_tooltips_disable( p_intf->p_sys->p_tooltips );
/* Store p_intf to keep an eye on it */
......
......@@ -2,7 +2,7 @@
* gtk_display.c: Gtk+ tools for main interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: gtk_display.c,v 1.21 2002/05/04 02:05:03 lool Exp $
* $Id: gtk_display.c,v 1.22 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Stphane Borel <stef@via.ecp.fr>
......@@ -244,13 +244,13 @@ gint GtkModeManage( intf_thread_t * p_intf )
/*****************************************************************************
* GtkHideTooltips: show or hide the tooltips depending on the configuration
* option gnome-notooltips
* option gnome-tooltips
*****************************************************************************
* FIXME: we should get the intf as parameter
*****************************************************************************/
void GtkHideTooltips( void )
{
if( config_GetIntVariable( "gnome-notooltips" ) )
if( !config_GetIntVariable( "gnome-tooltips" ) )
gtk_tooltips_disable( p_main->p_intf->p_sys->p_tooltips );
else gtk_tooltips_enable( p_main->p_intf->p_sys->p_tooltips );
}
......@@ -258,7 +258,7 @@ void GtkHideTooltips( void )
#ifdef MODULE_NAME_IS_gnome
/*****************************************************************************
* GtkHideToolbartext: show or hide the tooltips depending on the
* configuration option gnome-notoolbartext
* configuration option gnome-toolbartext
*****************************************************************************
* FIXME: we should get the intf as parameter
* FIXME: GNOME only because of missing icons in gtk interface
......@@ -268,9 +268,9 @@ void GtkHideToolbarText( void )
GtkToolbarStyle style;
GtkToolbar * p_toolbar;
style = config_GetIntVariable( "gnome-notoolbartext" )
? GTK_TOOLBAR_ICONS
: GTK_TOOLBAR_BOTH;
style = config_GetIntVariable( "gnome-toolbartext" )
? GTK_TOOLBAR_BOTH
: GTK_TOOLBAR_ICONS;
p_toolbar = GTK_TOOLBAR(lookup_widget( p_main->p_intf->p_sys->p_window,
"toolbar" ));
......
......@@ -2,7 +2,7 @@
* xmga.c : X11 MGA plugin for vlc
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: xmga.c,v 1.14 2002/05/18 17:47:47 sam Exp $
* $Id: xmga.c,v 1.15 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -110,7 +110,7 @@ static void ToggleCursor ( vout_thread_t * );
MODULE_CONFIG_START
ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
ADD_STRING ( "xmga_display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT )
ADD_BOOL ( "xmga_altfullscreen", NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT )
ADD_BOOL ( "xmga_altfullscreen", 0, NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT )
MODULE_CONFIG_STOP
MODULE_INIT_START
......
......@@ -172,8 +172,8 @@ static int vout_Create( vout_thread_t *p_vout )
p_vout->b_fullscreen =
config_GetIntVariable( "fullscreen" );
p_vout->p_sys->i_mode =
config_GetIntVariable( "nooverlay" ) ?
MODE_NORMAL_MEM : MODE_VIDEO_OVERLAY;
config_GetIntVariable( "overlay" ) ?
MODE_NORMAL_OVERLAY : MODE_VIDEO_MEM;
p_vout->p_sys->dim.w = p_vout->i_window_width;
p_vout->p_sys->dim.h = p_vout->i_window_height;
......
......@@ -68,7 +68,7 @@ MODULE_CONFIG_START
ADD_INTEGER ( "polarization", 0, NULL, POL_TEXT, POL_LONGTEXT )
ADD_INTEGER ( "fec", 3, NULL, FEC_TEXT, FEC_LONGTEXT )
ADD_INTEGER ( "symbol-rate", 27500, NULL, SRATE_TEXT, SRATE_LONGTEXT )
ADD_BOOL ( "diseqc", 0, DISEQC_TEXT, DISEQC_LONGTEXT )
ADD_BOOL ( "diseqc", 0, NULL, DISEQC_TEXT, DISEQC_LONGTEXT )
ADD_INTEGER ( "lnb-lof1", 10000, NULL, LNB_LOF1_TEXT, LNB_LOF1_LONGTEXT )
ADD_INTEGER ( "lnb-lof2", 10000, NULL, LNB_LOF2_TEXT, LNB_LOF2_LONGTEXT )
ADD_INTEGER ( "lnb-slof", 11700, NULL, LNB_SLOF_TEXT, LNB_SLOF_LONGTEXT )
......
......@@ -2,7 +2,7 @@
* x11.c : X11 plugin for vlc
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: x11.c,v 1.16 2002/04/23 14:16:20 sam Exp $
* $Id: x11.c,v 1.17 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -54,7 +54,7 @@
MODULE_CONFIG_START
ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
ADD_STRING ( "x11-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT )
ADD_BOOL ( "x11-altfullscreen", NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT )
ADD_BOOL ( "x11-altfullscreen", 0, NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT )
MODULE_CONFIG_STOP
MODULE_INIT_START
......
......@@ -2,7 +2,7 @@
* xvideo.c : Xvideo plugin for vlc
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: xvideo.c,v 1.12 2002/05/13 17:58:08 sam Exp $
* $Id: xvideo.c,v 1.13 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Shane Harper <shanegh@optusnet.com.au>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -65,7 +65,7 @@ MODULE_CONFIG_START
ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
ADD_STRING ( "xvideo-display", NULL, NULL, DISPLAY_TEXT, DISPLAY_LONGTEXT )
ADD_INTEGER ( "xvideo-adaptor", -1, NULL, ADAPTOR_TEXT, ADAPTOR_LONGTEXT )
ADD_BOOL ( "xvideo-altfullscreen", NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT )
ADD_BOOL ( "xvideo-altfullscreen", 0, NULL, ALT_FS_TEXT, ALT_FS_LONGTEXT )
ADD_STRING ( "xvideo-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT )
MODULE_CONFIG_STOP
......
......@@ -4,7 +4,7 @@
* and spawn threads.
*****************************************************************************
* Copyright (C) 1998-2001 VideoLAN
* $Id: main.c,v 1.194 2002/05/20 22:39:36 sam Exp $
* $Id: main.c,v 1.195 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -119,13 +119,13 @@
"vlc.\nNote that the default behavior is to automatically select the " \
"best method available.")
#define NOAUDIO_TEXT N_("disable audio")
#define NOAUDIO_LONGTEXT N_( \
"This will completely disable the audio output. The audio decoding " \
"stage shouldn't even be done, so it can allow you to save some " \
#define AUDIO_TEXT N_("enable audio")
#define AUDIO_LONGTEXT N_( \
"You can completely disable the audio output. In this case the audio " \
"decoding stage won't be done, and it will also save some " \
"processing power.")
#define MONO_TEXT N_("mono audio")
#define MONO_TEXT N_("force mono audio")
#define MONO_LONGTEXT N_("This will force a mono audio output")
#define VOLUME_TEXT N_("audio output volume")
......@@ -162,10 +162,10 @@
"Note that the default behavior is to automatically select the best " \
"method available.")
#define NOVIDEO_TEXT N_("disable video")
#define NOVIDEO_LONGTEXT N_( \
"This will completely disable the video output. The video decoding " \
"stage shouldn't even be done, so it can allow you to save some " \
#define VIDEO_TEXT N_("enable video")
#define VIDEO_LONGTEXT N_( \
"You can completely disable the video output. In this case the video " \
"decoding stage won't be done, and it will also save some " \
"processing power.")
#define DISPLAY_TEXT N_("display identifier")
......@@ -189,17 +189,17 @@
#define GRAYSCALE_TEXT N_("grayscale video output")
#define GRAYSCALE_LONGTEXT N_( \
"Using this option, vlc will not decode the color information from the " \
"video (this can also allow you to save some processing power).")
"When enabled, the color information from the video won't be decoded " \
"(this can also allow you to save some processing power).")
#define FULLSCREEN_TEXT N_("fullscreen video output")
#define FULLSCREEN_LONGTEXT N_( \
"If this option is enabled, vlc will always start a video in fullscreen " \
"mode.")
#define NOOVERLAY_TEXT N_("disable hardware acceleration for the video output")
#define NOOVERLAY_LONGTEXT N_( \
"By default vlc will try to take advantage of the overlay capabilities " \
#define OVERLAY_TEXT N_("overlay video output")
#define OVERLAY_LONGTEXT N_( \
"If enabled, vlc will try to take advantage of the overlay capabilities " \
"of you graphics card.")
#define SPUMARGIN_TEXT N_("force SPU position")
......@@ -249,7 +249,7 @@
#define INPUT_SUBT_TEXT N_("choose subtitles")
#define INPUT_SUBT_LONGTEXT N_( \
"Give the stream number of the subtitle channel you want to use in a DVD " \
"Give the stream number of the subtitle channel you want to use in a DVD "\
"(from 1 to n).")
#define DVD_DEV_TEXT N_("DVD device")
......@@ -280,42 +280,42 @@
"This allows you to select the AC3/A52 audio decoder you want to use. " \
"Common choices are builtin and a52.")
#define NOMMX_TEXT N_("disable CPU's MMX support")
#define NOMMX_LONGTEXT N_( \
"If your processor supports the MMX instructions set but you don't want " \
"vlc to use them, you can use this option.")
#define NO3DN_TEXT N_("disable CPU's 3D Now! support")
#define NO3DN_LONGTEXT N_( \
"If your processor supports the 3D Now! instructions set but you don't " \
"want vlc to use them, you can use this option.")
#define NOMMXEXT_TEXT N_("disable CPU's MMX EXT support")
#define NOMMXEXT_LONGTEXT N_( \
"If your processor supports the MMX EXT instructions set but you don't " \
"want vlc to use them, you can use this option.")
#define NOSSE_TEXT N_("disable CPU's SSE support")
#define NOSSE_LONGTEXT N_( \
"If your processor supports the SSE instructions set but you don't want " \
"vlc to use them, you can use this option.")
#define NOALTIVEC_TEXT N_("disable CPU's AltiVec support")
#define NOALTIVEC_LONGTEXT N_( \
"If your processor supports the AltiVec instructions set but you don't " \
"want vlc to use them, you can use this option.")
#define PLAYLIST_LAUNCH_TEXT N_("launch playlist on startup")
#define PLAYLIST_LAUNCH_LONGTEXT N_( \
#define MMX_TEXT N_("enable CPU MMX support")
#define MMX_LONGTEXT N_( \
"If your processor supports the MMX instructions set, vlc can take " \
"advantage of them.")
#define THREE_DN_TEXT N_("enable CPU 3D Now! support")
#define THREE_DN_LONGTEXT N_( \
"If your processor supports the 3D Now! instructions set, vlc can take "\
"advantage of them.")
#define MMXEXT_TEXT N_("enable CPU MMX EXT support")
#define MMXEXT_LONGTEXT N_( \
"If your processor supports the MMX EXT instructions set, vlc can take "\
"advantage of them.")
#define SSE_TEXT N_("enable CPU SSE support")
#define SSE_LONGTEXT N_( \
"If your processor supports the SSE instructions set, vlc can take " \
"can take advantage of them.")
#define ALTIVEC_TEXT N_("enable CPU AltiVec support")
#define ALTIVEC_LONGTEXT N_( \
"If your processor supports the AltiVec instructions set, vlc can take "\
"advantage of them.")
#define PL_LAUNCH_TEXT N_("launch playlist on startup")
#define PL_LAUNCH_LONGTEXT N_( \
"If you want vlc to start playing on startup, then enable this option.")
#define PLAYLIST_ENQUEUE_TEXT N_("enqueue playlist as default")
#define PLAYLIST_ENQUEUE_LONGTEXT N_( \
#define PL_ENQUEUE_TEXT N_("enqueue items in playlist")
#define PL_ENQUEUE_LONGTEXT N_( \
"If you want vlc to add items to the playlist as you open them, then " \
"enable this option.")
#define PLAYLIST_LOOP_TEXT N_("loop playlist on end")
#define PLAYLIST_LOOP_LONGTEXT N_( \
#define PL_LOOP_TEXT N_("loop playlist on end")
#define PL_LOOP_LONGTEXT N_( \
"If you want vlc to keep playing the playlist indefinitely then enable " \
"this option.")
......@@ -324,6 +324,14 @@
"You can select wich memory copy module you want to use. By default vlc " \
"will select the fastest one supported by your hardware.")
#define ACCESS_TEXT N_("access module")
#define ACCESS_LONGTEXT N_( \
"This is a legacy entry to let you configure access modules")
#define DEMUX_TEXT N_("demux module")
#define DEMUX_LONGTEXT N_( \
"This is a legacy entry to let you configure demux modules")
#define FAST_PTHREAD_TEXT N_("fast pthread on NT/2K/XP (developpers only)")
#define FAST_PTHREAD_LONGTEXT N_( \
"On Windows NT/2K/XP we use a slow but correct pthread implementation, " \
......@@ -342,7 +350,7 @@
* ADD_MODULE( option_name, psz_value, i_capability, p_callback,
* N_(text), N_(longtext) )
* ADD_INTEGER( option_name, i_value, p_callback, N_(text), N_(longtext) )
* ADD_BOOL( option_name, p_callback, N_(text), N_(longtext) )
* ADD_BOOL( option_name, b_value, p_callback, N_(text), N_(longtext) )
*/
MODULE_CONFIG_START
......@@ -351,37 +359,36 @@ MODULE_CONFIG_START
ADD_CATEGORY_HINT( N_("Interface"), NULL)
ADD_MODULE_WITH_SHORT ( "intf", 'I', 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_BOOL ( "stats", 0, NULL, STATS_TEXT, STATS_LONGTEXT )
ADD_STRING ( "search-path", NULL, NULL, INTF_PATH_TEXT, INTF_PATH_LONGTEXT )
/* Audio options */
ADD_CATEGORY_HINT( N_("Audio"), NULL)
ADD_MODULE_WITH_SHORT ( "aout", 'A', 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_BOOL ( "audio", 1, NULL, AUDIO_TEXT, AUDIO_LONGTEXT )
ADD_BOOL ( "mono", 0, 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 ( "audio-format", 0, NULL, FORMAT_TEXT,
FORMAT_LONGTEXT )
ADD_INTEGER ( "audio-format", 0, NULL, FORMAT_TEXT, FORMAT_LONGTEXT )
/* Video options */
ADD_CATEGORY_HINT( N_("Video"), NULL )
ADD_MODULE_WITH_SHORT ( "vout", 'V', MODULE_CAPABILITY_VOUT, NULL, NULL, VOUT_TEXT, VOUT_LONGTEXT )
ADD_BOOL ( "novideo", NULL, NOVIDEO_TEXT, NOVIDEO_LONGTEXT )
ADD_BOOL ( "video", 1, NULL, VIDEO_TEXT, VIDEO_LONGTEXT )
ADD_INTEGER ( "width", -1, NULL, WIDTH_TEXT, WIDTH_LONGTEXT )
ADD_INTEGER ( "height", -1, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT )
ADD_FLOAT ( "zoom", 1, NULL, ZOOM_TEXT, ZOOM_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_BOOL ( "grayscale", 0, NULL, GRAYSCALE_TEXT, GRAYSCALE_LONGTEXT )
ADD_BOOL ( "fullscreen", 0, NULL, FULLSCREEN_TEXT, FULLSCREEN_LONGTEXT )
ADD_BOOL ( "overlay", 1, NULL, OVERLAY_TEXT, OVERLAY_LONGTEXT )
ADD_INTEGER ( "spumargin", -1, NULL, SPUMARGIN_TEXT, SPUMARGIN_LONGTEXT )
ADD_MODULE ( "filter", MODULE_CAPABILITY_VOUT, NULL, NULL, FILTER_TEXT, FILTER_LONGTEXT )
/* Input options */
ADD_CATEGORY_HINT( N_("Input"), NULL )
ADD_INTEGER ( "server-port", 1234, NULL, SERVER_PORT_TEXT, SERVER_PORT_LONGTEXT )
ADD_BOOL ( "network-channel", NULL, NETCHANNEL_TEXT, NETCHANNEL_LONGTEXT )
ADD_BOOL ( "network-channel", 0, 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 )
......@@ -394,8 +401,8 @@ ADD_INTEGER ( "spu-channel", -1, NULL, INPUT_SUBT_TEXT, INPUT_SUBT_LONGTEXT )
ADD_STRING ( "dvd", DVD_DEVICE, NULL, DVD_DEV_TEXT, DVD_DEV_LONGTEXT )
ADD_STRING ( "vcd", VCD_DEVICE, NULL, VCD_DEV_TEXT, VCD_DEV_LONGTEXT )
ADD_BOOL_WITH_SHORT ( "ipv6", '6', NULL, IPV6_TEXT, IPV6_LONGTEXT )
ADD_BOOL_WITH_SHORT ( "ipv4", '4', NULL, IPV4_TEXT, IPV4_LONGTEXT )
ADD_BOOL_WITH_SHORT ( "ipv6", '6', 0, NULL, IPV6_TEXT, IPV6_LONGTEXT )
ADD_BOOL_WITH_SHORT ( "ipv4", '4', 0, NULL, IPV4_TEXT, IPV4_LONGTEXT )
/* Decoder options */
ADD_CATEGORY_HINT( N_("Decoders"), NULL )
......@@ -404,26 +411,26 @@ ADD_MODULE ( "ac3-adec", MODULE_CAPABILITY_DECODER, NULL, NULL, ADEC_AC3_TEXT,
/* CPU options */
ADD_CATEGORY_HINT( N_("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 )
ADD_BOOL ( "mmx", 1, NULL, MMX_TEXT, MMX_LONGTEXT )
ADD_BOOL ( "3dn", 1, NULL, THREE_DN_TEXT, THREE_DN_LONGTEXT )
ADD_BOOL ( "mmxext", 1, NULL, MMXEXT_TEXT, MMXEXT_LONGTEXT )
ADD_BOOL ( "sse", 1, NULL, SSE_TEXT, SSE_LONGTEXT )
ADD_BOOL ( "altivec", 1, NULL, ALTIVEC_TEXT, ALTIVEC_LONGTEXT )
/* Playlist options */
ADD_CATEGORY_HINT( N_("Playlist"), NULL )
ADD_BOOL ( "launch-playlist", NULL, PLAYLIST_LAUNCH_TEXT, PLAYLIST_LAUNCH_LONGTEXT )
ADD_BOOL ( "enqueue-playlist", NULL, PLAYLIST_ENQUEUE_TEXT, PLAYLIST_ENQUEUE_LONGTEXT )
ADD_BOOL ( "loop-playlist", NULL, PLAYLIST_LOOP_TEXT, PLAYLIST_LOOP_LONGTEXT )
ADD_BOOL ( "launch-playlist", 0, NULL, PL_LAUNCH_TEXT, PL_LAUNCH_LONGTEXT )
ADD_BOOL ( "enqueue-playlist", 0, NULL, PL_ENQUEUE_TEXT, PL_ENQUEUE_LONGTEXT )
ADD_BOOL ( "loop-playlist", 0, NULL, PL_LOOP_TEXT, PL_LOOP_LONGTEXT )
/* Misc options */
ADD_CATEGORY_HINT( N_("Miscellaneous"), NULL )
ADD_MODULE ( "memcpy", MODULE_CAPABILITY_MEMCPY, NULL, NULL, MEMCPY_TEXT, MEMCPY_LONGTEXT )
ADD_MODULE ( "access", MODULE_CAPABILITY_ACCESS, NULL, NULL, "access module", "This is a legacy entry to let you configure access modules" )
ADD_MODULE ( "demux", MODULE_CAPABILITY_DEMUX, NULL, NULL, "demux module", "This is a legacy entry to let you configure demux modules" )
ADD_MODULE ( "access", MODULE_CAPABILITY_ACCESS, NULL, NULL, ACCESS_TEXT, ACCESS_LONGTEXT )
ADD_MODULE ( "demux", MODULE_CAPABILITY_DEMUX, NULL, NULL, DEMUX_TEXT, DEMUX_LONGTEXT )
#if defined(WIN32)
ADD_BOOL ( "fast_pthread", NULL, FAST_PTHREAD_TEXT, FAST_PTHREAD_LONGTEXT )
ADD_BOOL ( "fast_pthread", 0, NULL, FAST_PTHREAD_TEXT, FAST_PTHREAD_LONGTEXT )
#endif
MODULE_CONFIG_STOP
......@@ -449,13 +456,19 @@ static module_config_t p_help_config[] =
NULL, NULL, 0, 0, NULL, NULL, 0 },
{ MODULE_CONFIG_ITEM_BOOL, "list", 'l', N_("print a list of available "
"modules"), NULL, NULL, 0, 0, NULL, NULL, 0 },
{ MODULE_CONFIG_ITEM_STRING, "module", 'p', N_("print help on module "
"<string>"), NULL, NULL, 0, 0, NULL, &help_module.config_lock, 0 },
{ MODULE_CONFIG_ITEM_STRING, "module", 'p', N_("print help on module"),
NULL, NULL, 0, 0, NULL, &help_module.config_lock, 0 },
{ MODULE_CONFIG_ITEM_BOOL, "version", '\0',
N_("print version information"), NULL, NULL, 0, 0, NULL, NULL, 0 },
{ MODULE_CONFIG_HINT_END, NULL, '\0', NULL, NULL, NULL, 0, 0,
NULL, NULL, 0 }
};
static module_t help_module = { "help", "help module", NULL, {NULL}, 0, {0}, 0,
NULL, p_help_config, {0},
sizeof(p_help_config)/sizeof(module_config_t),
sizeof(p_help_config)/sizeof(module_config_t)
};
/*****************************************************************************
* End configuration.
......@@ -511,7 +524,6 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
vout_bank_t vout_bank;
char *psz_module;
char *p_tmp;
struct module_config_s *p_item;
p_main = &main_data; /* set up the global variables */
p_module_bank = &module_bank;
......@@ -599,18 +611,7 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
module_LoadMain();
/* Hack: insert the help module here */
help_module.psz_name = "help";
help_module.psz_longname = _( "help module" );
help_module.i_config_items =
sizeof(p_help_config) / sizeof(module_config_t) - 1;
vlc_mutex_init( &help_module.config_lock );
help_module.p_config = config_Duplicate( p_help_config );
for( p_item = help_module.p_config;
p_item->i_type != MODULE_CONFIG_HINT_END;
p_item++ )
{
p_item->p_lock = &help_module.config_lock;
}
help_module.next = p_module_bank->first;
p_module_bank->first = &help_module;
/* end hack */
......@@ -719,18 +720,18 @@ int main( int i_argc, char *ppsz_argv[], char *ppsz_env[] )
p_main->i_warning_level = config_GetIntVariable( "warning" );
p_main->i_desync = config_GetIntVariable( "desync" ) * (mtime_t)1000;
p_main->b_stats = config_GetIntVariable( "stats" );
p_main->b_audio = !config_GetIntVariable( "noaudio" );
p_main->b_audio = config_GetIntVariable( "audio" );
p_main->b_stereo= !config_GetIntVariable( "mono" );
p_main->b_video = !config_GetIntVariable( "novideo" );
if( config_GetIntVariable( "nommx" ) )
p_main->b_video = config_GetIntVariable( "video" );
if( !config_GetIntVariable( "mmx" ) )
p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_MMX;
if( config_GetIntVariable( "no3dn" ) )
if( !config_GetIntVariable( "3dn" ) )
p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_3DNOW;
if( config_GetIntVariable( "nommxext" ) )
if( !config_GetIntVariable( "mmxext" ) )
p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_MMXEXT;
if( config_GetIntVariable( "nosse" ) )
if( !config_GetIntVariable( "sse" ) )
p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_SSE;
if( config_GetIntVariable( "noaltivec" ) )
if( !config_GetIntVariable( "altivec" ) )
p_main->i_cpu_capabilities &= ~CPU_CAPABILITY_ALTIVEC;
......@@ -923,13 +924,15 @@ static int GetFilenames( int i_argc, char *ppsz_argv[] )
*****************************************************************************/
static void Usage( const char *psz_module_name )
{
#define FORMAT_STRING " --%s%s%s%s%s %s"
/* option name ---------------' | | | | |
* <bra ------------------------' | | | |
* option type or "" -------------' | | |
* ket> ----------------------------' | |
* padding spaces --------------------' |
* comment ------------------------------'
#define FORMAT_STRING " --%s%s%s%s%s%s %s%s"
/* option name prefix ------' | | | | | | |
* option name ---------------' | | | | | |
* <bra ------------------------' | | | | |
* option type or "" -------------' | | | |
* ket> ----------------------------' | | |
* padding spaces --------------------' | |
* comment ------------------------------' |
* comment suffix -------------------------'
*
* The purpose of having bra and ket is that we might i18n them as well.
*/
......@@ -949,11 +952,13 @@ static void Usage( const char *psz_module_name )
ShowConsole();
#endif
/* Enumerate the config of each module */
/* Enumerate the config for each module */
for( p_module = p_module_bank->first ;
p_module != NULL ;
p_module = p_module->next )
{
boolean_t b_help_module = !strcmp( "help", p_module->psz_name );
if( psz_module_name && strcmp( psz_module_name, p_module->psz_name ) )
continue;
......@@ -968,21 +973,9 @@ static void Usage( const char *psz_module_name )
p_item++ )
{
char *psz_bra = NULL, *psz_type = NULL, *psz_ket = NULL;
char *psz_suf = "";
int i;
if( p_item->i_short )
{
psz_format[2] = '-';
psz_format[3] = p_item->i_short;
psz_format[4] = ',';
}
else
{
psz_format[2] = ' ';
psz_format[3] = ' ';
psz_format[4] = ' ';
}
switch( p_item->i_type )
{
case MODULE_CONFIG_HINT_CATEGORY:
......@@ -1002,14 +995,34 @@ static void Usage( const char *psz_module_name )
break;
case MODULE_CONFIG_ITEM_BOOL:
psz_bra = ""; psz_type = ""; psz_ket = "";
if( !b_help_module )
psz_suf = p_item->i_value ? _(" (default: enabled)") :
_(" (default: disabled)");
break;
}
/* Add short option */
if( p_item->i_short )
{
psz_format[2] = '-';
psz_format[3] = p_item->i_short;
psz_format[4] = ',';
}
else
{
psz_format[2] = ' ';
psz_format[3] = ' ';
psz_format[4] = ' ';
}
if( psz_type )
{
i = PADDING_SPACES - strlen( p_item->psz_name )
- strlen( psz_bra ) - strlen( psz_type )
- strlen( psz_ket ) - 1;
if( p_item->i_type == MODULE_CONFIG_ITEM_BOOL &&
!b_help_module ) i -= 5;
if( i < 0 )
{
i = 0;
......@@ -1020,8 +1033,11 @@ static void Usage( const char *psz_module_name )
psz_spaces[i] = '\0';
}
intf_Msg( psz_format, p_item->psz_name, psz_bra, psz_type,
psz_ket, psz_spaces, p_item->psz_text );
intf_Msg( psz_format,
( p_item->i_type == MODULE_CONFIG_ITEM_BOOL &&
!b_help_module ) ? "(no-)" : "",
p_item->psz_name, psz_bra, psz_type, psz_ket,
psz_spaces, p_item->psz_text, psz_suf );
psz_spaces[i] = ' ';
}
}
......
......@@ -2,7 +2,7 @@
* configuration.c management of the modules configuration
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: configuration.c,v 1.25 2002/05/18 17:53:11 massiot Exp $
* $Id: configuration.c,v 1.26 2002/05/30 08:17:04 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
*
......@@ -775,7 +775,7 @@ int config_SaveConfigFile( const char *psz_module_name )
int config_LoadCmdLine( int *pi_argc, char *ppsz_argv[],
boolean_t b_ignore_errors )
{
int i_cmd, i_index, i_opts, i_shortopts;
int i_cmd, i_index, i_opts, i_shortopts, flag;
module_t *p_module;
module_config_t *p_item;
struct option *p_longopts;
......@@ -823,8 +823,9 @@ int config_LoadCmdLine( int *pi_argc, char *ppsz_argv[],
p_module = p_module->next )
{
/* count the number of exported configuration options (to allocate
* longopts). */
i_opts += p_module->i_config_items;
* longopts). We also need to allocate space for too options when
* dealing with boolean to allow for --foo and --no-foo */
i_opts += (p_module->i_config_items + p_module->i_bool_items);
}
p_longopts = malloc( sizeof(struct option) * (i_opts + 1) );
......@@ -880,14 +881,31 @@ int config_LoadCmdLine( int *pi_argc, char *ppsz_argv[],
continue;
/* Add item to long options */
p_longopts[i_index].name = p_item->psz_name;
p_longopts[i_index].name = strdup( p_item->psz_name );
if( p_longopts[i_index].name == NULL ) continue;
p_longopts[i_index].has_arg =
(p_item->i_type == MODULE_CONFIG_ITEM_BOOL)?
no_argument : required_argument;
p_longopts[i_index].flag = 0;
p_longopts[i_index].flag = &flag;
p_longopts[i_index].val = 0;
i_index++;
/* When dealing with bools we also need to add the --no-foo
* option */
if( p_item->i_type == MODULE_CONFIG_ITEM_BOOL )
{
char *psz_name = malloc( strlen(p_item->psz_name) + 4 );
if( psz_name == NULL ) continue;
strcpy( psz_name, "no-" );
strcat( psz_name, p_item->psz_name );
p_longopts[i_index].name = psz_name;
p_longopts[i_index].has_arg = no_argument;
p_longopts[i_index].flag = &flag;
p_longopts[i_index].val = 1;
i_index++;
}
/* If item also has a short option, add it */
if( p_item->i_short )
{
......@@ -919,26 +937,29 @@ int config_LoadCmdLine( int *pi_argc, char *ppsz_argv[],
if( i_cmd == 0 )
{
module_config_t *p_conf;
char *psz_name = (char *)p_longopts[i_index].name;
/* Check if we deal with a --no-foo long option */
if( flag ) psz_name += 3;
/* Store the configuration option */
p_conf = config_FindConfig( p_longopts[i_index].name );
p_conf = config_FindConfig( psz_name );
switch( p_conf->i_type )
if( p_conf ) switch( p_conf->i_type )
{
case MODULE_CONFIG_ITEM_STRING:
case MODULE_CONFIG_ITEM_FILE:
case MODULE_CONFIG_ITEM_MODULE:
config_PutPszVariable( p_longopts[i_index].name, optarg );
config_PutPszVariable( psz_name, optarg );
break;
case MODULE_CONFIG_ITEM_INTEGER:
config_PutIntVariable( p_longopts[i_index].name, atoi(optarg));
config_PutIntVariable( psz_name, atoi(optarg));
break;
case MODULE_CONFIG_ITEM_FLOAT:
config_PutFloatVariable( p_longopts[i_index].name,
(float)atof(optarg) );
config_PutFloatVariable( psz_name, (float)atof(optarg) );
break;
case MODULE_CONFIG_ITEM_BOOL:
config_PutIntVariable( p_longopts[i_index].name, 1 );
config_PutIntVariable( psz_name, !flag );
break;
}
......@@ -989,6 +1010,9 @@ int config_LoadCmdLine( int *pi_argc, char *ppsz_argv[],
}
}
/* Free allocated resources */
for( i_index = 0; p_longopts[i_index].name; i_index++ )
free( (char *)p_longopts[i_index].name );
free( p_longopts );
free( psz_shortopts );
if( b_ignore_errors ) free( ppsz_argv );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment