module_list_get(): gets the list of modules
module_list_free(): releases the list
VLC_EXPORT( module_config_t *, module_GetConfig, ( const module_t *, unsigned * ) );
VLC_EXPORT( void, module_PutConfig, ( module_config_t * ) );
VLC_EXPORT( module_config_t *, module_GetConfig, ( const module_t *, unsigned * ) );
VLC_EXPORT( void, module_PutConfig, ( module_config_t * ) );
+VLC_EXPORT( void, module_list_free, (module_t **) );
+VLC_EXPORT( module_t **, module_list_get, (size_t *n) );
+
/* Return a NULL terminated array with the names of the modules that have a
* certain capability.
* Free after uses both the string and the table. */
/* Return a NULL terminated array with the names of the modules that have a
* certain capability.
* Free after uses both the string and the table. */
{
int i_cmd, i_index, i_opts, i_shortopts, flag, i_verbose = 0;
module_t *p_parser;
{
int i_cmd, i_index, i_opts, i_shortopts, flag, i_verbose = 0;
module_t *p_parser;
struct option *p_longopts;
int i_modules_index;
const char **argv_copy = NULL;
struct option *p_longopts;
int i_modules_index;
const char **argv_copy = NULL;
#endif
/* List all modules */
#endif
/* List all modules */
- p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
+ module_t **list = module_list_get (NULL);
/*
* Generate the longopts and shortopts structures used by getopt_long
*/
i_opts = 0;
/*
* Generate the longopts and shortopts structures used by getopt_long
*/
i_opts = 0;
- for( i_modules_index = 0; i_modules_index < p_list->i_count;
- i_modules_index++ )
- {
- p_parser = (module_t *)p_list->p_values[i_modules_index].p_object ;
-
+ for (size_t i = 0; (p_parser = list[i]) != NULL; i++)
/* count the number of exported configuration options (to allocate
* longopts). We also need to allocate space for two options when
* dealing with boolean to allow for --foo and --no-foo */
/* count the number of exported configuration options (to allocate
* longopts). We also need to allocate space for two options when
* dealing with boolean to allow for --foo and --no-foo */
- i_opts += p_parser->i_config_items
- + 2 * p_parser->i_bool_items;
- }
+ i_opts += p_parser->i_config_items + 2 * p_parser->i_bool_items;
p_longopts = malloc( sizeof(struct option) * (i_opts + 1) );
if( p_longopts == NULL )
{
p_longopts = malloc( sizeof(struct option) * (i_opts + 1) );
if( p_longopts == NULL )
{
- vlc_list_release( p_list );
+ module_list_free (list);
if( psz_shortopts == NULL )
{
free( p_longopts );
if( psz_shortopts == NULL )
{
free( p_longopts );
- vlc_list_release( p_list );
+ module_list_free (list);
{
free( psz_shortopts );
free( p_longopts );
{
free( psz_shortopts );
free( p_longopts );
- vlc_list_release( p_list );
+ module_list_free (list);
return -1;
}
memcpy( argv_copy, ppsz_argv, *pi_argc * sizeof(char *) );
return -1;
}
memcpy( argv_copy, ppsz_argv, *pi_argc * sizeof(char *) );
/* Fill the p_longopts and psz_shortopts structures */
i_index = 0;
/* Fill the p_longopts and psz_shortopts structures */
i_index = 0;
- for( i_modules_index = 0; i_modules_index < p_list->i_count;
- i_modules_index++ )
+ for (size_t i = 0; (p_parser = list[i]) != NULL; i++)
{
module_config_t *p_item, *p_end;
{
module_config_t *p_item, *p_end;
- p_parser = (module_t *)p_list->p_values[i_modules_index].p_object ;
if( !p_parser->i_config_items )
continue;
if( !p_parser->i_config_items )
continue;
}
/* We don't need the module list anymore */
}
/* We don't need the module list anymore */
- vlc_list_release( p_list );
+ module_list_free( list );
/* Close the longopts and shortopts structures */
memset( &p_longopts[i_index], 0, sizeof(struct option) );
/* Close the longopts and shortopts structures */
memset( &p_longopts[i_index], 0, sizeof(struct option) );
*****************************************************************************/
module_config_t *config_FindConfig( vlc_object_t *p_this, const char *psz_name )
{
*****************************************************************************/
module_config_t *config_FindConfig( vlc_object_t *p_this, const char *psz_name )
{
- vlc_list_t *p_list;
- int i_index;
if( !psz_name ) return NULL;
if( !psz_name ) return NULL;
- p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
+ module_t **list = module_list_get (NULL);
+ if (list == NULL)
+ return NULL;
- for( i_index = 0; i_index < p_list->i_count; i_index++ )
+ for (size_t i = 0; (p_parser = list[i]) != NULL; i++)
{
module_config_t *p_item, *p_end;
{
module_config_t *p_item, *p_end;
- module_t *p_parser = (module_t *)p_list->p_values[i_index].p_object;
if( !p_parser->i_config_items )
continue;
if( !p_parser->i_config_items )
continue;
|| ( p_item->psz_oldname
&& !strcmp( psz_name, p_item->psz_oldname ) ) )
{
|| ( p_item->psz_oldname
&& !strcmp( psz_name, p_item->psz_oldname ) ) )
{
- vlc_list_release( p_list );
+ module_list_free (list);
- vlc_list_release( p_list );
-
+ module_list_free (list);
{
libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
int i_index;
{
libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
int i_index;
+ module_t **list = module_list_get (NULL);
/* Acquire config file lock */
vlc_mutex_lock( &priv->config_lock );
/* Acquire config file lock */
vlc_mutex_lock( &priv->config_lock );
- p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
- for( i_index = 0; i_index < p_list->i_count; i_index++ )
+ for (size_t j = 0; (p_module = list[j]) != NULL; j++)
- p_module = (module_t *)p_list->p_values[i_index].p_object ;
if( p_module->b_submodule ) continue;
for (size_t i = 0; i < p_module->confsize; i++ )
if( p_module->b_submodule ) continue;
for (size_t i = 0; i < p_module->confsize; i++ )
- vlc_list_release( p_list );
+ module_list_free (list);
vlc_mutex_unlock( &priv->config_lock );
}
vlc_mutex_unlock( &priv->config_lock );
}
int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
{
libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
int __config_LoadConfigFile( vlc_object_t *p_this, const char *psz_module_name )
{
libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
FILE *file;
file = config_OpenConfigFile (p_this, "rt");
FILE *file;
file = config_OpenConfigFile (p_this, "rt");
vlc_mutex_lock( &priv->config_lock );
/* Look for the selected module, if NULL then save everything */
vlc_mutex_lock( &priv->config_lock );
/* Look for the selected module, if NULL then save everything */
- p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
+ module_t **list = module_list_get (NULL);
/* Look for UTF-8 Byte Order Mark */
char * (*convert) (const char *) = strdupnull;
/* Look for UTF-8 Byte Order Mark */
char * (*convert) (const char *) = strdupnull;
if ((psz_module_name == NULL)
|| (strcmp (psz_module_name, section) == 0))
{
if ((psz_module_name == NULL)
|| (strcmp (psz_module_name, section) == 0))
{
- for (int i = 0; i < p_list->i_count; i++)
+ for (int i = 0; list[i]; i++)
- module_t *m = (module_t *)p_list->p_values[i].p_object;
if ((strcmp (section, m->psz_object_name) == 0)
&& (m->i_config_items > 0)) /* ignore config-less modules */
if ((strcmp (section, m->psz_object_name) == 0)
&& (m->i_config_items > 0)) /* ignore config-less modules */
- vlc_list_release( p_list );
+ module_list_free (list);
if (loc != (locale_t)0)
{
uselocale (baseloc);
if (loc != (locale_t)0)
{
uselocale (baseloc);
{
libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
module_t *p_parser;
{
libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
module_t *p_parser;
FILE *file;
char p_line[1024], *p_index2;
int i_sizebuf = 0;
FILE *file;
char p_line[1024], *p_index2;
int i_sizebuf = 0;
p_bigbuffer[0] = 0;
/* List all available modules */
p_bigbuffer[0] = 0;
/* List all available modules */
- p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
+ module_t **list = module_list_get (NULL);
/* backup file into memory, we only need to backup the sections we won't
* save later on */
/* backup file into memory, we only need to backup the sections we won't
* save later on */
{
/* we found a section, check if we need to do a backup */
{
/* we found a section, check if we need to do a backup */
- for( i_index = 0; i_index < p_list->i_count; i_index++ )
+ for( i_index = 0; (p_parser = list[i_index]) != NULL; i_index++ )
- p_parser = (module_t *)p_list->p_values[i_index].p_object ;
-
if( ((p_index2 - &p_line[1])
== (int)strlen(p_parser->psz_object_name) )
&& !memcmp( &p_line[1], p_parser->psz_object_name,
if( ((p_index2 - &p_line[1])
== (int)strlen(p_parser->psz_object_name) )
&& !memcmp( &p_line[1], p_parser->psz_object_name,
- if( i_index == p_list->i_count )
+ if( list[i_index] == NULL )
{
/* we don't have this section in our list so we need to back
* it up */
{
/* we don't have this section in our list so we need to back
* it up */
file = config_OpenConfigFile (p_this, "wt");
if( !file )
{
file = config_OpenConfigFile (p_this, "wt");
if( !file )
{
- vlc_list_release( p_list );
+ module_list_free (list);
free( p_bigbuffer );
vlc_mutex_unlock( &priv->config_lock );
return -1;
free( p_bigbuffer );
vlc_mutex_unlock( &priv->config_lock );
return -1;
locale_t baseloc = uselocale (loc);
/* Look for the selected module, if NULL then save everything */
locale_t baseloc = uselocale (loc);
/* Look for the selected module, if NULL then save everything */
- for( i_index = 0; i_index < p_list->i_count; i_index++ )
+ for( i_index = 0; (p_parser = list[i_index]) != NULL; i_index++ )
{
module_config_t *p_item, *p_end;
{
module_config_t *p_item, *p_end;
- p_parser = (module_t *)p_list->p_values[i_index].p_object ;
if( psz_module_name && strcmp( psz_module_name,
p_parser->psz_object_name ) )
if( psz_module_name && strcmp( psz_module_name,
p_parser->psz_object_name ) )
- vlc_list_release( p_list );
+ module_list_free (list);
if (loc != (locale_t)0)
{
uselocale (baseloc);
if (loc != (locale_t)0)
{
uselocale (baseloc);
int config_AutoSaveConfigFile( vlc_object_t *p_this )
{
libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
int config_AutoSaveConfigFile( vlc_object_t *p_this )
{
libvlc_priv_t *priv = libvlc_priv (p_this->p_libvlc);
- vlc_list_t *p_list;
- int i_index, i_count;
+ size_t i_index;
+ bool done;
assert( p_this );
/* Check if there's anything to save */
vlc_mutex_lock( &priv->config_lock );
assert( p_this );
/* Check if there's anything to save */
vlc_mutex_lock( &priv->config_lock );
- p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
- i_count = p_list->i_count;
- for( i_index = 0; i_index < i_count; i_index++ )
+ module_t **list = module_list_get (NULL);
+ for( i_index = 0; list[i_index]; i_index++ )
- module_t *p_parser = (module_t *)p_list->p_values[i_index].p_object ;
+ module_t *p_parser = list[i_index];
module_config_t *p_item, *p_end;
if( !p_parser->i_config_items ) continue;
module_config_t *p_item, *p_end;
if( !p_parser->i_config_items ) continue;
}
if( p_item < p_end ) break;
}
}
if( p_item < p_end ) break;
}
- vlc_list_release( p_list );
+ done = list[i_index] == NULL;
+ module_list_free (list);
vlc_mutex_unlock( &priv->config_lock );
vlc_mutex_unlock( &priv->config_lock );
- if( i_index == i_count ) return VLC_SUCCESS;
- return SaveConfigFile( p_this, NULL, true );
+ return done ? VLC_SUCCESS : SaveConfigFile( p_this, NULL, true );
}
int __config_SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name )
}
int __config_SaveConfigFile( vlc_object_t *p_this, const char *psz_module_name )
#else
# define OPTION_VALUE_SEP " "
#endif
#else
# define OPTION_VALUE_SEP " "
#endif
- vlc_list_t *p_list = NULL;
char psz_spaces_text[PADDING_SPACES+LINE_START+1];
char psz_spaces_longtext[LINE_START+3];
char psz_format[sizeof(COLOR_FORMAT_STRING)];
char psz_format_bool[sizeof(COLOR_FORMAT_STRING_BOOL)];
char psz_buffer[10000];
char psz_short[4];
char psz_spaces_text[PADDING_SPACES+LINE_START+1];
char psz_spaces_longtext[LINE_START+3];
char psz_format[sizeof(COLOR_FORMAT_STRING)];
char psz_format_bool[sizeof(COLOR_FORMAT_STRING_BOOL)];
char psz_buffer[10000];
char psz_short[4];
int i_width = ConsoleWidth() - (PADDING_SPACES+LINE_START+1);
int i_width_description = i_width + PADDING_SPACES - 1;
bool b_advanced = config_GetInt( p_this, "advanced" ) > 0;
int i_width = ConsoleWidth() - (PADDING_SPACES+LINE_START+1);
int i_width_description = i_width + PADDING_SPACES - 1;
bool b_advanced = config_GetInt( p_this, "advanced" ) > 0;
- p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
+ module_t **list = module_list_get (NULL);
+ if (!list)
+ return;
/* Ugly hack to make sure that the help options always come first
* (part 1) */
/* Ugly hack to make sure that the help options always come first
* (part 1) */
Usage( p_this, "help" );
/* Enumerate the config for each module */
Usage( p_this, "help" );
/* Enumerate the config for each module */
- for( i_index = 0; i_index < p_list->i_count; i_index++ )
+ for (size_t i = 0; list[i]; i++)
- module_t *p_parser = (module_t *)p_list->p_values[i_index].p_object;
+ module_t *p_parser = list[i];
module_config_t *p_item = NULL;
module_config_t *p_section = NULL;
module_config_t *p_end = p_parser->p_config + p_parser->confsize;
module_config_t *p_item = NULL;
module_config_t *p_section = NULL;
module_config_t *p_end = p_parser->p_config + p_parser->confsize;
}
/* Release the module list */
}
/* Release the module list */
- vlc_list_release( p_list );
+ module_list_free (list);
}
/*****************************************************************************
}
/*****************************************************************************
*****************************************************************************/
static void ListModules( libvlc_int_t *p_this, bool b_verbose )
{
*****************************************************************************/
static void ListModules( libvlc_int_t *p_this, bool b_verbose )
{
- vlc_list_t *p_list = NULL;
- module_t *p_parser = NULL;
bool b_color = config_GetInt( p_this, "color" ) > 0;
bool b_color = config_GetInt( p_this, "color" ) > 0;
#endif
/* List all modules */
#endif
/* List all modules */
- p_list = vlc_list_find( p_this, VLC_OBJECT_MODULE, FIND_ANYWHERE );
+ module_t **list = module_list_get (NULL);
/* Enumerate each module */
/* Enumerate each module */
- for( i_index = 0; i_index < p_list->i_count; i_index++ )
+ for (size_t j = 0; (p_parser = list[j]) != NULL; j++)
- p_parser = (module_t *)p_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( p_parser->psz_object_name ) - 1;
/* Nasty hack, but right now I'm too tired to think about a nice
* solution */
i = 22 - strlen( p_parser->psz_object_name ) - 1;
-
- vlc_list_release( p_list );
+ module_list_free (list);
#ifdef WIN32 /* Pause the console because it's destroyed when we exit */
PauseConsole();
#ifdef WIN32 /* Pause the console because it's destroyed when we exit */
PauseConsole();
module_GetName
module_GetObjName
module_IsCapable
module_GetName
module_GetObjName
module_IsCapable
+module_list_free
+module_list_get
__module_Need
module_Put
module_PutConfig
__module_Need
module_Put
module_PutConfig