Commit a71b1c8c authored by Gildas Bazin's avatar Gildas Bazin

* ALL: added a new vlc_list_t common type. vlc_list_find() and vlc_list_release() have been modified
to use this new type.
parent 270c4994
......@@ -2,7 +2,7 @@
* variables.h: variables handling
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: variables.h,v 1.9 2002/12/07 15:25:26 gbazin Exp $
* $Id: variables.h,v 1.10 2002/12/13 01:56:29 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -87,7 +87,9 @@ struct variable_t
#define VLC_VAR_HASMAX 0x0400
#define VLC_VAR_HASSTEP 0x0800
#define VLC_VAR_ISCOMMAND 0x1000
#define VLC_VAR_ISLIST 0x1000
#define VLC_VAR_ISCOMMAND 0x2000
#define VLC_VAR_ISCONFIG 0x2000
/*****************************************************************************
* Variable actions
......
......@@ -2,7 +2,7 @@
* vlc.h: global header for vlc
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc.h,v 1.18 2002/12/03 16:29:04 gitan Exp $
* $Id: vlc.h,v 1.19 2002/12/13 01:56:29 gbazin Exp $
*
* 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
......@@ -30,6 +30,8 @@ extern "C" {
* Our custom types
*****************************************************************************/
typedef int vlc_bool_t;
typedef struct vlc_list_t vlc_list_t;
typedef struct vlc_object_t vlc_object_t;
typedef union
{
......@@ -38,12 +40,20 @@ typedef union
float f_float;
char * psz_string;
void * p_address;
vlc_object_t * p_object;
/* Make sure the structure is at least 64bits */
struct { char a, b, c, d, e, f, g, h; } padding;
} vlc_value_t;
struct vlc_list_t
{
int i_count;
vlc_value_t * p_values;
};
/*****************************************************************************
* Error values
*****************************************************************************/
......
......@@ -3,7 +3,7 @@
* Collection of useful common types and macros definitions
*****************************************************************************
* Copyright (C) 1998, 1999, 2000 VideoLAN
* $Id: vlc_common.h,v 1.42 2002/11/28 23:24:14 massiot Exp $
* $Id: vlc_common.h,v 1.43 2002/12/13 01:56:29 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@via.ecp.fr>
* Vincent Seguin <seguin@via.ecp.fr>
......@@ -178,8 +178,6 @@ typedef uint32_t vlc_fourcc_t;
/* Internal types */
typedef struct libvlc_t libvlc_t;
typedef struct vlc_t vlc_t;
typedef struct vlc_list_t vlc_list_t;
typedef struct vlc_object_t vlc_object_t;
typedef struct variable_t variable_t;
/* Messages */
......
......@@ -2,7 +2,7 @@
* vlc_objects.h: vlc_object_t definition.
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: vlc_objects.h,v 1.13 2002/10/14 16:46:55 sam Exp $
* $Id: vlc_objects.h,v 1.14 2002/12/13 01:56:29 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -50,19 +50,6 @@ struct vlc_object_t
VLC_COMMON_MEMBERS
};
/*****************************************************************************
* The vlc_list_t object list type
*****************************************************************************/
struct vlc_list_t
{
int i_count;
vlc_object_t ** pp_objects;
/* Private */
int _i_extra;
vlc_object_t * _p_first;
};
/*****************************************************************************
* Prototypes
*****************************************************************************/
......@@ -74,7 +61,7 @@ VLC_EXPORT( void *, __vlc_object_get, ( vlc_object_t *, int ) );
VLC_EXPORT( void *, __vlc_object_find, ( vlc_object_t *, int, int ) );
VLC_EXPORT( void, __vlc_object_yield, ( vlc_object_t * ) );
VLC_EXPORT( void, __vlc_object_release, ( vlc_object_t * ) );
VLC_EXPORT( vlc_list_t *, __vlc_list_find, ( vlc_object_t *, int, int ) );
VLC_EXPORT( vlc_list_t, __vlc_list_find, ( vlc_object_t *, int, int ) );
VLC_EXPORT( void, vlc_list_release, ( vlc_list_t * ) );
#define vlc_object_create(a,b) \
......
......@@ -2,7 +2,7 @@
* familiar.c : familiar plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: familiar.c,v 1.12 2002/12/12 12:24:23 sam Exp $
* $Id: familiar.c,v 1.13 2002/12/13 01:56:29 gbazin Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -198,36 +198,37 @@ static void Run( intf_thread_t *p_intf )
void GtkAutoPlayFile( vlc_object_t *p_this )
{
GtkWidget *cbautoplay;
intf_thread_t **pp_intf;
vlc_list_t *p_list = vlc_list_find( p_this, VLC_OBJECT_INTF,
intf_thread_t *p_intf;
int i_index;
vlc_list_t list = vlc_list_find( p_this, VLC_OBJECT_INTF,
FIND_ANYWHERE );
for( pp_intf = (intf_thread_t **)p_list->pp_objects ;
*pp_intf ;
pp_intf++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
if( strcmp( MODULE_STRING, (*pp_intf)->p_module->psz_object_name ) )
p_intf = (intf_thread_t *)list.p_values[i_index].p_object ;
if( strcmp( MODULE_STRING, p_intf->p_module->psz_object_name ) )
{
continue;
}
cbautoplay = GTK_WIDGET( gtk_object_get_data(
GTK_OBJECT( (*pp_intf)->p_sys->p_window ),
GTK_OBJECT( p_intf->p_sys->p_window ),
"cbautoplay" ) );
if( !config_GetInt( p_this, "familiar-autoplayfile" ) )
{
(*pp_intf)->p_sys->b_autoplayfile = VLC_FALSE;
p_intf->p_sys->b_autoplayfile = VLC_FALSE;
}
else
{
(*pp_intf)->p_sys->b_autoplayfile = VLC_TRUE;
p_intf->p_sys->b_autoplayfile = VLC_TRUE;
}
gtk_toggle_button_set_active( GTK_TOGGLE_BUTTON( cbautoplay ),
(*pp_intf)->p_sys->b_autoplayfile );
p_intf->p_sys->b_autoplayfile );
}
vlc_list_release( p_list );
vlc_list_release( &list );
}
......@@ -2,7 +2,7 @@
* display.c: Gtk+ tools for main interface
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: display.c,v 1.4 2002/09/30 11:05:38 sam Exp $
* $Id: display.c,v 1.5 2002/12/13 01:56:29 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Stphane Borel <stef@via.ecp.fr>
......@@ -237,32 +237,33 @@ gint E_(GtkModeManage)( intf_thread_t * p_intf )
*****************************************************************************/
void E_(GtkHideTooltips)( vlc_object_t *p_this )
{
intf_thread_t **pp_intf;
vlc_list_t *p_list = vlc_list_find( p_this, VLC_OBJECT_INTF,
intf_thread_t *p_intf;
int i_index;
vlc_list_t list = vlc_list_find( p_this, VLC_OBJECT_INTF,
FIND_ANYWHERE );
vlc_bool_t b_enable = config_GetInt( p_this, "gnome-tooltips" );
for( pp_intf = (intf_thread_t **)p_list->pp_objects ;
*pp_intf ;
pp_intf++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
if( strcmp( MODULE_STRING, (*pp_intf)->p_module->psz_object_name ) )
p_intf = (intf_thread_t *)list.p_values[i_index].p_object ;
if( strcmp( MODULE_STRING, p_intf->p_module->psz_object_name ) )
{
continue;
}
if( b_enable )
{
gtk_tooltips_enable( (*pp_intf)->p_sys->p_tooltips );
gtk_tooltips_enable( p_intf->p_sys->p_tooltips );
}
else
{
gtk_tooltips_disable( (*pp_intf)->p_sys->p_tooltips );
gtk_tooltips_disable( p_intf->p_sys->p_tooltips );
}
}
vlc_list_release( p_list );
vlc_list_release( &list );
}
#ifdef MODULE_NAME_IS_gnome
......@@ -276,28 +277,29 @@ void GtkHideToolbarText( vlc_object_t *p_this )
{
GtkToolbarStyle style;
GtkToolbar * p_toolbar;
intf_thread_t **pp_intf;
vlc_list_t *p_list = vlc_list_find( p_this, VLC_OBJECT_INTF,
intf_thread_t *p_intf;
int i_index;
vlc_list_t list = vlc_list_find( p_this, VLC_OBJECT_INTF,
FIND_ANYWHERE );
style = config_GetInt( p_this, "gnome-toolbartext" )
? GTK_TOOLBAR_BOTH
: GTK_TOOLBAR_ICONS;
for( pp_intf = (intf_thread_t **)p_list->pp_objects ;
*pp_intf ;
pp_intf++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
if( strcmp( MODULE_STRING, (*pp_intf)->p_module->psz_object_name ) )
p_intf = (module_t *)list.p_values[i_index].p_object ;
if( strcmp( MODULE_STRING, p_intf->p_module->psz_object_name ) )
{
continue;
}
p_toolbar = GTK_TOOLBAR(lookup_widget( (*pp_intf)->p_sys->p_window,
p_toolbar = GTK_TOOLBAR(lookup_widget( p_intf->p_sys->p_window,
"toolbar" ));
gtk_toolbar_set_style( p_toolbar, style );
}
vlc_list_release( p_list );
vlc_list_release( &list );
}
#endif
......@@ -2,7 +2,7 @@
* gtk_preferences.c: functions to handle the preferences dialog box.
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: preferences.c,v 1.5 2002/12/06 16:34:07 sam Exp $
* $Id: preferences.c,v 1.6 2002/12/13 01:56:29 gbazin Exp $
*
* Authors: Gildas Bazin <gbazin@netcourrier.com>
* Loc Minier <lool@via.ecp.fr>
......@@ -118,9 +118,10 @@ void GtkPreferencesShow( GtkMenuItem * menuitem, gpointer user_data )
static void GtkCreateConfigDialog( char *psz_module_name,
intf_thread_t *p_intf )
{
module_t **pp_parser;
vlc_list_t *p_list;
module_t *p_parser = NULL;
vlc_list_t list;
module_config_t *p_item;
int i_index;
guint rows = 0;
......@@ -174,23 +175,22 @@ static void GtkCreateConfigDialog( char *psz_module_name,
/* Look for the selected module */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( psz_module_name
&& !strcmp( psz_module_name, (*pp_parser)->psz_object_name ) )
&& !strcmp( psz_module_name, p_parser->psz_object_name ) )
{
break;
}
}
if( !(*pp_parser) )
if( !p_parser || i_index == list.i_count )
{
vlc_list_release( p_list );
vlc_list_release( &list );
return;
}
......@@ -198,12 +198,12 @@ static void GtkCreateConfigDialog( char *psz_module_name,
/* Create the configuration dialog box */
#ifdef MODULE_NAME_IS_gnome
config_dialog = gnome_dialog_new( (*pp_parser)->psz_longname, NULL );
config_dialog = gnome_dialog_new( p_parser->psz_longname, NULL );
config_dialog_vbox = GNOME_DIALOG(config_dialog)->vbox;
#else
config_dialog = gtk_dialog_new();
gtk_window_set_title( GTK_WINDOW(config_dialog),
(*pp_parser)->psz_longname );
p_parser->psz_longname );
config_dialog_vbox = GTK_DIALOG(config_dialog)->vbox;
#endif
......@@ -225,7 +225,7 @@ static void GtkCreateConfigDialog( char *psz_module_name,
gtk_container_add( GTK_CONTAINER(config_dialog_vbox), config_notebook );
/* Enumerate config options and add corresponding config boxes */
p_item = (*pp_parser)->p_config;
p_item = p_parser->p_config;
if( p_item ) do
{
......@@ -329,15 +329,16 @@ static void GtkCreateConfigDialog( char *psz_module_name,
/* build a list of available modules */
{
gchar * entry[2];
pp_parser = (module_t **)p_list->pp_objects;
for( ; *pp_parser ; pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
if( !strcmp( (*pp_parser)->psz_capability,
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( !strcmp( p_parser->psz_capability,
p_item->psz_type ) )
{
entry[0] = (*pp_parser)->psz_object_name;
entry[1] = (*pp_parser)->psz_longname;
entry[0] = p_parser->psz_object_name;
entry[1] = p_parser->psz_longname;
gtk_clist_append( GTK_CLIST(module_clist), entry );
}
}
......@@ -515,7 +516,7 @@ static void GtkCreateConfigDialog( char *psz_module_name,
}
while( p_item->i_type != CONFIG_HINT_END && p_item++ );
vlc_list_release( p_list );
vlc_list_release( &list );
#ifndef MODULE_NAME_IS_gnome
/* Now let's add the action buttons at the bottom of the page */
......@@ -658,9 +659,10 @@ static void GtkModuleHighlighted( GtkCList *module_clist, int row, int column,
{
intf_thread_t *p_intf;
GtkWidget *config_button;
module_t **pp_parser;
vlc_list_t *p_list;
module_t *p_parser;
vlc_list_t list;
char *psz_name;
int i_index;
p_intf = (intf_thread_t *)gtk_object_get_data( GTK_OBJECT(module_clist),
"p_intf" );
......@@ -671,19 +673,19 @@ static void GtkModuleHighlighted( GtkCList *module_clist, int row, int column,
}
/* look for module 'psz_name' */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
if( !strcmp( (*pp_parser)->psz_object_name, psz_name ) )
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( !strcmp( p_parser->psz_object_name, psz_name ) )
{
gtk_object_set_data( GTK_OBJECT(module_clist),
"module_highlighted", (*pp_parser) );
"module_highlighted", p_parser );
config_button = gtk_object_get_data( GTK_OBJECT(module_clist),
"config_button" );
if( (*pp_parser)->i_config_items )
if( p_parser->i_config_items )
gtk_widget_set_sensitive( config_button, TRUE );
else
gtk_widget_set_sensitive( config_button, FALSE );
......@@ -692,7 +694,7 @@ static void GtkModuleHighlighted( GtkCList *module_clist, int row, int column,
}
}
vlc_list_release( p_list );
vlc_list_release( &list );
}
/****************************************************************************
......
......@@ -2,7 +2,7 @@
* preferences.cpp: preferences window for the kde gui
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: preferences.cpp,v 1.8 2002/10/16 23:34:27 sigmunau Exp $
* $Id: preferences.cpp,v 1.9 2002/12/13 01:56:29 gbazin Exp $
*
* Authors: Sigmund Augdal <sigmunau@idi.ntnu.no> Mon Aug 12 2002
*
......@@ -52,37 +52,37 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name,
KDialogBase ( Tabbed, caption, Ok| Apply|Cancel|User1, Ok, parent,
"vlc preferences", true, false, "Save")
{
module_t **pp_parser;
vlc_list_t *p_list;
module_t *p_parser;
vlc_list_t list;
module_config_t *p_item;
int i_index;
QVBox *category_table = NULL;
QString *category_label;
this->p_intf = p_intf;
/* List all modules */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
/* Look for the selected module */
for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( psz_module_name
&& !strcmp( psz_module_name, (*pp_parser)->psz_object_name ) )
&& !strcmp( psz_module_name, p_parser->psz_object_name ) )
{
break;
}
}
if( !(*pp_parser) )
if( !p_parser || i_index == list.i_count )
{
vlc_list_release( p_list );
vlc_list_release( list );
return;
}
p_item = (*pp_parser)->p_config;
p_item = p_parser->p_config;
if( p_item ) do
{
switch( p_item->i_type )
......@@ -131,16 +131,16 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name,
/* build a list of available plugins */
for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
if( !strcmp( (*pp_parser)->psz_capability,
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( !strcmp( p_parser->psz_capability,
p_item->psz_type ) )
{
new QListViewItem(item_frame->getListView(),
(*pp_parser)->psz_object_name,
(*pp_parser)->psz_longname);
p_parser->psz_object_name,
p_parser->psz_longname);
}
}
......@@ -256,7 +256,7 @@ KPreferences::KPreferences(intf_thread_t *p_intf, const char *psz_module_name,
}
while( p_item->i_type != CONFIG_HINT_END );
vlc_list_release( p_list );
vlc_list_release( &list );
exec();
}
......@@ -273,24 +273,25 @@ KPreferences::~KPreferences()
*/
bool KPreferences::isConfigureable(QString module)
{
module_t **pp_parser;
vlc_list_t *p_list;
module_t *p_parser;
vlc_list_t list;
int i_index;
p_list = vlc_list_find( this->p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
list = vlc_list_find( this->p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
if( !module.compare( (*pp_parser)->psz_object_name ) )
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( !module.compare( p_parser->psz_object_name ) )
{
bool ret = (*pp_parser)->i_config_items != 0;
vlc_list_release( p_list );
bool ret = p_parser->i_config_items != 0;
vlc_list_release( &list );
return ret;
}
}
vlc_list_release( p_list );
vlc_list_release( &list );
return false;
}
......
......@@ -2,7 +2,7 @@
* prefs.m: MacOS X plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: prefs.m,v 1.1 2002/11/05 03:57:16 jlj Exp $
* $Id: prefs.m,v 1.2 2002/12/13 01:56:30 gbazin Exp $
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
*
......@@ -100,28 +100,29 @@
- (BOOL)hasPrefs:(NSString *)o_module_name
{
module_t **pp_parser;
vlc_list_t *p_list;
module_t *p_parser;
vlc_list_t list;
char *psz_module_name;
int i_index;
psz_module_name = (char *)[o_module_name lossyCString];
/* look for module */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
if( !strcmp( (*pp_parser)->psz_object_name, psz_module_name ) )
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( !strcmp( p_parser->psz_object_name, psz_module_name ) )
{
BOOL b_has_prefs = (*pp_parser)->i_config_items != 0;
vlc_list_release( p_list );
BOOL b_has_prefs = p_parser->i_config_items != 0;
vlc_list_release( &list );
return( b_has_prefs );
}
}
vlc_list_release( p_list );
vlc_list_release( &list );
return( NO );
}
......@@ -131,10 +132,11 @@
int i_pos;
int i_module_tag;
module_t **pp_parser;
vlc_list_t *p_list;
module_t *p_parser;
vlc_list_t list;
module_config_t *p_item;
char *psz_module_name;
int i_index;
NSPanel *o_panel; /* panel */
NSRect s_panel_rc; /* panel rect */
......@@ -163,22 +165,22 @@
psz_module_name = (char *)[o_module_name lossyCString];
/* Look for the selected module */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( psz_module_name
&& !strcmp( psz_module_name, (*pp_parser)->psz_object_name ) )
&& !strcmp( psz_module_name, p_parser->psz_object_name ) )
{
break;
}
}
if( !(*pp_parser) )
if( !p_parser || i_index == list.i_count )
{
vlc_list_release( p_list );
vlc_list_release( &list );
return;
}
......@@ -211,7 +213,7 @@
forKey: o_module_name];
/* Enumerate config options and add corresponding config boxes */
p_item = (*pp_parser)->p_config;
p_item = p_parser->p_config;
i_pos = 0;
o_view = nil;
......@@ -381,15 +383,15 @@
/* build a list of available modules */
{
pp_parser = (module_t **)p_list->pp_objects;
for( ; *pp_parser ; pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
if( !strcmp( (*pp_parser)->psz_capability,
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( !strcmp( p_parser->psz_capability,
p_item->psz_type ) )
{
NSString *o_object_name = [NSString
stringWithCString: (*pp_parser)->psz_object_name];
stringWithCString: p_parser->psz_object_name];
[o_modules addItemWithTitle: o_object_name];
}
}
......@@ -517,7 +519,7 @@
}
while( p_item->i_type != CONFIG_HINT_END && p_item++ );
vlc_list_release( p_list );
vlc_list_release( &list );
[o_toolbars setObject: o_tb_items forKey: o_module_name];
[o_toolbar setDelegate: self];
......
......@@ -248,8 +248,9 @@ __fastcall TPanelPlugin::TPanelPlugin( TComponent* Owner,
//---------------------------------------------------------------------------
void __fastcall TPanelPlugin::CheckListBoxClick( TObject *Sender )
{
module_t **pp_parser;
vlc_list_t *p_list;
module_t *p_parser;
vlc_list_t list;
int i_index;
/* check that the click is valid (we are on an item, and the click
* started on an item */
......@@ -262,17 +263,17 @@ void __fastcall TPanelPlugin::CheckListBoxClick( TObject *Sender )
return;
/* look for module 'Name' */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
if( strcmp( (*pp_parser)->psz_object_name, Name.c_str() ) == 0 )
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( strcmp( p_parser->psz_object_name, Name.c_str() ) == 0 )
{
ModuleSelected = (*pp_parser);
ModuleSelected = p_parser;
ButtonConfig->Enabled =
(*pp_parser)->i_config_items ? true : false;
p_parser->i_config_items ? true : false;
break;
}
......@@ -523,8 +524,9 @@ void __fastcall TPreferencesDlg::FormClose( TObject *Sender,
void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
{
module_t **pp_parser;
vlc_list_t *p_list;
module_t *p_parser;
vlc_list_t list;
int i_index;
module_config_t *p_item;
int i_pages, i_ctrl;
......@@ -539,21 +541,21 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
TPanelBool *PanelBool;
/* Look for the selected module */
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( psz_module_name
&& !strcmp( psz_module_name, (*pp_parser)->psz_object_name ) )
&& !strcmp( psz_module_name, p_parser->psz_object_name ) )
{
break;
}
}
if( !(*pp_parser) )
if( !p_parser || i_index == list.i_count )
{
vlc_list_release( p_list );
vlc_list_release( &list );
return;
}
......@@ -562,7 +564,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
*/
/* Enumerate config options and add corresponding config boxes */
p_item = (*pp_parser)->p_config;
p_item = p_parser->p_config;
if( p_item ) do
{
switch( p_item->i_type )
......@@ -595,29 +597,29 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
PanelPlugin->Parent = ScrollBox;
/* Look for valid modules */
pp_parser = (module_t **)p_list->pp_objects;
for( ; *pp_parser ; pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
if( !strcmp( (*pp_parser)->psz_capability, p_item->psz_type ) )
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( !strcmp( p_parser->psz_capability, p_item->psz_type ) )
{
AnsiString ModuleDesc;
if ( (*pp_parser)->psz_longname != NULL ) {
ModuleDesc = AnsiString((*pp_parser)->psz_longname) +
" (" + AnsiString((*pp_parser)->psz_object_name) +
if ( p_parser->psz_longname != NULL ) {
ModuleDesc = AnsiString(p_parser->psz_longname) +
" (" + AnsiString(p_parser->psz_object_name) +
")";
}
else
ModuleDesc = AnsiString((*pp_parser)->psz_object_name);
ModuleDesc = AnsiString(p_parser->psz_object_name);
int item = PanelPlugin->CleanCheckListBox->Items->AddObject(
ModuleDesc.c_str(),
new TObjectString((*pp_parser)->psz_object_name) );
new TObjectString(p_parser->psz_object_name) );
/* check the box if it's the default module */
AnsiString Name = p_item->psz_value ?
p_item->psz_value : "";
if( !strcmp( (*pp_parser)->psz_object_name, Name.c_str()) )
if( !strcmp( p_parser->psz_object_name, Name.c_str()) )
{
PanelPlugin->CleanCheckListBox->Checked[item] = true;
}
......@@ -683,7 +685,7 @@ void __fastcall TPreferencesDlg::CreateConfigDialog( char *psz_module_name )
}
}
vlc_list_release( p_list );
vlc_list_release( &list );
/* set active tabsheet
* FIXME: i don't know why, but both lines are necessary */
......
......@@ -2,7 +2,7 @@
* libvlc.c: main libvlc source
*****************************************************************************
* Copyright (C) 1998-2002 VideoLAN
* $Id: libvlc.c,v 1.50 2002/12/08 00:41:06 massiot Exp $
* $Id: libvlc.c,v 1.51 2002/12/13 01:56:30 gbazin Exp $
*
* Authors: Vincent Seguin <seguin@via.ecp.fr>
* Samuel Hocevar <sam@zoy.org>
......@@ -1005,11 +1005,12 @@ static void Usage( vlc_t *p_this, char const *psz_module_name )
*/
#define LINE_START 8
#define PADDING_SPACES 25
vlc_list_t *p_list;
module_t **pp_parser;
vlc_list_t list;
module_t *p_parser;
module_config_t *p_item;
char psz_spaces[PADDING_SPACES+LINE_START+1];
char psz_format[sizeof(FORMAT_STRING)];
int i_index;
memset( psz_spaces, ' ', PADDING_SPACES+LINE_START );
psz_spaces[PADDING_SPACES+LINE_START] = '\0';
......@@ -1021,31 +1022,31 @@ static void Usage( vlc_t *p_this, char const *psz_module_name )
#endif
/* List all modules */
p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
/* Enumerate the config for each module */
for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
vlc_bool_t b_help_module;
p_parser = (module_t *)list.p_values[i_index].p_object ;
if( psz_module_name && strcmp( psz_module_name,
(*pp_parser)->psz_object_name ) )
p_parser->psz_object_name ) )
{
continue;
}
/* Ignore modules without config options */
if( !(*pp_parser)->i_config_items )
if( !p_parser->i_config_items )
{
continue;
}
b_help_module = !strcmp( "help", (*pp_parser)->psz_object_name );
b_help_module = !strcmp( "help", p_parser->psz_object_name );
/* Print module options */
for( p_item = (*pp_parser)->p_config;
for( p_item = p_parser->p_config;
p_item->i_type != CONFIG_HINT_END;
p_item++ )
{
......@@ -1180,7 +1181,7 @@ static void Usage( vlc_t *p_this, char const *psz_module_name )
}
/* Release the module list */
vlc_list_release( p_list );
vlc_list_release( &list );
#ifdef WIN32 /* Pause the console because it's destroyed when we exit */
fprintf( stdout, _("\nPress the RETURN key to continue...\n") );
......@@ -1196,9 +1197,10 @@ static void Usage( vlc_t *p_this, char const *psz_module_name )
*****************************************************************************/
static void ListModules( vlc_t *p_this )
{
vlc_list_t *p_list;
module_t **pp_parser;
vlc_list_t list;
module_t *p_parser;
char psz_spaces[22];
int i_index;
memset( psz_spaces, ' ', 22 );
......@@ -1213,28 +1215,28 @@ static void ListModules( vlc_t *p_this )
fprintf( stdout, _("[module] [description]\n") );
/* List all modules */
p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
/* Enumerate each module */
for( pp_parser = (module_t **)p_list->pp_objects ;
*pp_parser ;
pp_parser++ )
for( i_index = 0; i_index < list.i_count; i_index++ )
{
int i;
p_parser = (module_t *)list.p_values[i_index].p_object ;
/* Nasty hack, but right now I'm too tired to think about a nice
* solution */
i = 22 - strlen( (*pp_parser)->psz_object_name ) - 1;
i = 22 - strlen( p_parser->psz_object_name ) - 1;
if( i < 0 ) i = 0;
psz_spaces[i] = 0;
fprintf( stdout, " %s%s %s\n", (*pp_parser)->psz_object_name,
psz_spaces, (*pp_parser)->psz_longname );
fprintf( stdout, " %s%s %s\n", p_parser->psz_object_name,
psz_spaces, p_parser->psz_longname );
psz_spaces[i] = ' ';
}
vlc_list_release( p_list );
vlc_list_release( &list );
#ifdef WIN32 /* Pause the console because it's destroyed when we exit */
fprintf( stdout, _("\nPress the RETURN key to continue...\n") );
......@@ -1283,4 +1285,3 @@ static void ShowConsole( void )
return;
}
#endif
This diff is collapsed.
......@@ -2,7 +2,7 @@
* modules.c : Builtin and plugin modules management functions
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: modules.c,v 1.107 2002/11/19 17:38:07 sam Exp $
* $Id: modules.c,v 1.108 2002/12/13 01:56:30 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Ethan C. Baldridge <BaldridgeE@cadmus.com>
......@@ -250,13 +250,12 @@ module_t * __module_Need( vlc_object_t *p_this, const char *psz_capability,
};
module_list_t *p_list, *p_first, *p_tmp;
vlc_list_t *p_all;
vlc_list_t all;
int i_index = 0;
int i_which_module, i_index = 0;
vlc_bool_t b_intf = VLC_FALSE;
module_t *p_module;
module_t **pp_parser;
int i_shortcuts = 0;
char *psz_shortcuts = NULL, *psz_var = NULL;
......@@ -296,17 +295,17 @@ module_t * __module_Need( vlc_object_t *p_this, const char *psz_capability,
}
/* Sort the modules and test them */
p_all = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
p_list = malloc( p_all->i_count * sizeof( module_list_t ) );
all = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
p_list = malloc( all.i_count * sizeof( module_list_t ) );
p_first = NULL;
/* Parse the module list for capabilities and probe each of them */
for( pp_parser = (module_t**)p_all->pp_objects ; *pp_parser ; pp_parser++ )
for( i_which_module = 0; i_which_module < all.i_count; i_which_module++ )
{
module_t * p_submodule = NULL;
int i_shortcut_bonus = 0, i_submodule;
p_module = *pp_parser;
p_module = (module_t *)all.p_values[i_which_module].p_object;
/* Test that this module can do what we need */
if( strcmp( p_module->psz_capability, psz_capability ) )
......@@ -449,7 +448,7 @@ module_t * __module_Need( vlc_object_t *p_this, const char *psz_capability,
}
/* We can release the list, interesting modules were yielded */
vlc_list_release( p_all );
vlc_list_release( &all );
/* Parse the linked list and use the first successful module */
p_tmp = p_first;
......@@ -977,4 +976,3 @@ static int CallEntry( module_t * p_module )
return 0;
}
#endif /* HAVE_DYNAMIC_PLUGINS */
......@@ -2,7 +2,7 @@
* objects.c: vlc_object_t handling
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: objects.c,v 1.31 2002/12/07 15:25:27 gbazin Exp $
* $Id: objects.c,v 1.32 2002/12/13 01:56:30 gbazin Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -57,8 +57,9 @@ static void DumpStructure ( vlc_object_t *, int, char * );
static int FindIndex ( vlc_object_t *, vlc_object_t **, int );
static void SetAttachment ( vlc_object_t *, vlc_bool_t );
static vlc_list_t * NewList ( void );
static vlc_list_t * ListAppend ( vlc_list_t *, vlc_object_t * );
static vlc_list_t NewList ( int );
static void ListReplace ( vlc_list_t *, vlc_object_t *, int );
static void ListAppend ( vlc_list_t *, vlc_object_t * );
/*****************************************************************************
* Local structure lock
......@@ -486,9 +487,9 @@ void __vlc_object_detach( vlc_object_t *p_this )
* This function recursively looks for a given object type. i_mode can be one
* of FIND_PARENT, FIND_CHILD or FIND_ANYWHERE.
*****************************************************************************/
vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
vlc_list_t __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
{
vlc_list_t *p_list = NewList();
vlc_list_t list;
vlc_mutex_lock( &structure_lock );
......@@ -496,6 +497,7 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
if( (i_mode & 0x000f) == FIND_ANYWHERE )
{
vlc_object_t **pp_current, **pp_end;
int i_count = 0, i_index = 0;
pp_current = p_this->p_libvlc->pp_objects;
pp_end = pp_current + p_this->p_libvlc->i_objects;
......@@ -505,18 +507,32 @@ vlc_list_t * __vlc_list_find( vlc_object_t *p_this, int i_type, int i_mode )
if( (*pp_current)->b_attached
&& (*pp_current)->i_object_type == i_type )
{
p_list = ListAppend( p_list, *pp_current );
i_count++;
}
}
list = NewList( i_count );
pp_current = p_this->p_libvlc->pp_objects;
for( ; pp_current < pp_end ; pp_current++ )
{
if( (*pp_current)->b_attached
&& (*pp_current)->i_object_type == i_type )
{
ListReplace( &list, *pp_current, i_index );
if( i_index < i_count ) i_index++;
}
}
}
else
{
msg_Err( p_this, "unimplemented!" );
list = NewList( 0 );
}
vlc_mutex_unlock( &structure_lock );
return p_list;
return list;
}
/*****************************************************************************
......@@ -592,22 +608,18 @@ static int DumpCommand( vlc_object_t *p_this, char const *psz_cmd,
*****************************************************************************/
void vlc_list_release( vlc_list_t *p_list )
{
if( p_list->i_count )
{
vlc_object_t ** pp_current = p_list->pp_objects;
int i_index;
for( i_index = 0; i_index < p_list->i_count; i_index++ )
{
vlc_mutex_lock( &structure_lock );
while( pp_current[0] )
{
pp_current[0]->i_refcount--;
pp_current++;
}
p_list->p_values[i_index].p_object->i_refcount--;
vlc_mutex_unlock( &structure_lock );
}
free( p_list );
free( p_list->p_values );
}
/* Following functions are local */
......@@ -844,57 +856,62 @@ static void DumpStructure( vlc_object_t *p_this, int i_level, char *psz_foo )
}
}
static vlc_list_t * NewList( void )
static vlc_list_t NewList( int i_count )
{
vlc_list_t *p_list = malloc( sizeof( vlc_list_t )
+ 3 * sizeof( vlc_object_t * ) );
vlc_list_t list;
if( p_list == NULL )
list.i_count = i_count;
if( i_count == 0 )
{
return NULL;
list.p_values = NULL;
return list;
}
p_list->i_count = 0;
p_list->pp_objects = &p_list->_p_first;
/* We allocated space for NULL and for three extra objects */
p_list->_i_extra = 3;
p_list->_p_first = NULL;
list.p_values = malloc( i_count * sizeof( vlc_value_t ) );
if( list.p_values == NULL )
{
list.i_count = 0;
return list;
}
return p_list;
return list;
}
static vlc_list_t * ListAppend( vlc_list_t *p_list, vlc_object_t *p_object )
static void ListReplace( vlc_list_t *p_list, vlc_object_t *p_object,
int i_index )
{
if( p_list == NULL )
if( p_list == NULL || i_index >= p_list->i_count )
{
return NULL;
return;
}
if( p_list->_i_extra == 0 )
{
/* If we had X objects it means the array has a size of X+1, we
* make it size 2X+2, so we alloc 2X+1 because there is already
* one allocated in the real structure */
p_list = realloc( p_list, sizeof( vlc_list_t )
+ (p_list->i_count * 2 + 1)
* sizeof( vlc_object_t * ) );
p_object->i_refcount++;
p_list->p_values[i_index].p_object = p_object;
return;
}
static void ListAppend( vlc_list_t *p_list, vlc_object_t *p_object )
{
if( p_list == NULL )
{
return NULL;
return;
}
/* We have X+1 extra slots */
p_list->_i_extra = p_list->i_count + 1;
p_list->pp_objects = &p_list->_p_first;
p_list->p_values = realloc( p_list->p_values, (p_list->i_count + 1)
* sizeof( vlc_value_t ) );
if( p_list->p_values == NULL )
{
p_list->i_count = 0;
return;
}
p_object->i_refcount++;
p_list->pp_objects[p_list->i_count] = p_object;
p_list->p_values[p_list->i_count].p_object = p_object;
p_list->i_count++;
p_list->pp_objects[p_list->i_count] = NULL;
p_list->_i_extra--;
return p_list;
return;
}
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