#include "configuration.h"
#include "modules/modules.h"
-vlc_rwlock_t config_lock;
+vlc_rwlock_t config_lock = VLC_STATIC_RWLOCK;
static inline char *strdupnull (const char *src)
{
return src ? strdup (src) : NULL;
}
-/* Item types that use a string value (i.e. serialized in the module cache) */
-int IsConfigStringType (int type)
-{
- static const unsigned char config_types[] =
- {
- CONFIG_ITEM_STRING, CONFIG_ITEM_MODULE, CONFIG_ITEM_DIRECTORY,
- CONFIG_ITEM_KEY, CONFIG_ITEM_MODULE_CAT, CONFIG_ITEM_PASSWORD,
- CONFIG_ITEM_MODULE_LIST, CONFIG_ITEM_MODULE_LIST_CAT,
- CONFIG_ITEM_FONT, CONFIG_ITEM_LOADFILE, CONFIG_ITEM_SAVEFILE,
- };
-
- /* NOTE: this needs to be changed if we ever get more than 255 types */
- return memchr (config_types, type, sizeof (config_types)) != NULL;
-}
-
-
-int IsConfigIntegerType (int type)
-{
- static const unsigned char config_types[] =
- {
- CONFIG_ITEM_INTEGER, CONFIG_ITEM_BOOL,
- CONFIG_CATEGORY, CONFIG_SUBCATEGORY
- };
-
- return memchr (config_types, type, sizeof (config_types)) != NULL;
-}
-
#undef config_GetType
/*****************************************************************************
* config_GetType: get the type of a variable (bool, int, float, string)
return 0;
}
- switch( p_config->i_type )
+ switch( CONFIG_CLASS(p_config->i_type) )
{
- case CONFIG_ITEM_BOOL:
- i_type = VLC_VAR_BOOL;
+ case CONFIG_ITEM_FLOAT:
+ i_type = VLC_VAR_FLOAT;
break;
case CONFIG_ITEM_INTEGER:
i_type = VLC_VAR_INTEGER;
break;
- case CONFIG_ITEM_FLOAT:
- i_type = VLC_VAR_FLOAT;
+ case CONFIG_ITEM_BOOL:
+ i_type = VLC_VAR_BOOL;
break;
- case CONFIG_ITEM_MODULE:
- case CONFIG_ITEM_MODULE_CAT:
- case CONFIG_ITEM_MODULE_LIST:
- case CONFIG_ITEM_MODULE_LIST_CAT:
case CONFIG_ITEM_STRING:
- case CONFIG_ITEM_PASSWORD:
- case CONFIG_ITEM_LOADFILE:
- case CONFIG_ITEM_SAVEFILE:
- case CONFIG_ITEM_DIRECTORY:
- case CONFIG_ITEM_KEY:
i_type = VLC_VAR_STRING;
break;
return i_type;
}
+bool config_IsSafe( const char *name )
+{
+ module_config_t *p_config = config_FindConfig( NULL, name );
+ return p_config != NULL && p_config->b_safe;
+}
+
#undef config_GetInt
/*****************************************************************************
* config_GetInt: get the value of an int variable
item < end;
item++)
{
- if (item->i_type & CONFIG_HINT)
+ if (!CONFIG_ITEM(item->i_type))
continue; /* ignore hints */
clist[nconf++] = item;
}
return p ? *p : NULL;
}
-/*****************************************************************************
- * config_Free: frees a duplicated module's configuration data.
- *****************************************************************************
- * This function frees all the data duplicated by config_Duplicate.
- *****************************************************************************/
-void config_Free( module_t *p_module )
+/**
+ * Destroys an array of configuration items.
+ * \param config start of array of items
+ * \param confsize number of items in the array
+ */
+void config_Free (module_config_t *config, size_t confsize)
{
- int i;
-
- for (size_t j = 0; j < p_module->confsize; j++)
+ for (size_t j = 0; j < confsize; j++)
{
- module_config_t *p_item = p_module->p_config + j;
+ module_config_t *p_item = config + j;
free( p_item->psz_type );
free( p_item->psz_name );
free( p_item->psz_text );
free( p_item->psz_longtext );
- free( p_item->psz_oldname );
if (IsConfigStringType (p_item->i_type))
{
}
if( p_item->ppsz_list )
- for( i = 0; i < p_item->i_list; i++ )
+ for (int i = 0; i < p_item->i_list; i++)
free( p_item->ppsz_list[i] );
if( p_item->ppsz_list_text )
- for( i = 0; i < p_item->i_list; i++ )
+ for (int i = 0; i < p_item->i_list; i++)
free( p_item->ppsz_list_text[i] );
free( p_item->ppsz_list );
free( p_item->ppsz_list_text );
if( p_item->i_action )
{
- for( i = 0; i < p_item->i_action; i++ )
- {
+ for (int i = 0; i < p_item->i_action; i++)
free( p_item->ppsz_action_text[i] );
- }
free( p_item->ppf_action );
free( p_item->ppsz_action_text );
}
}
- free (p_module->p_config);
- p_module->p_config = NULL;
+ free (config);
}
#undef config_ResetAll