]> git.sesse.net Git - vlc/commitdiff
Use vlc_config_create()
authorRémi Denis-Courmont <rem@videolan.org>
Mon, 17 Dec 2007 20:53:25 +0000 (20:53 +0000)
committerRémi Denis-Courmont <rem@videolan.org>
Mon, 17 Dec 2007 20:53:25 +0000 (20:53 +0000)
include/vlc_configuration.h
include/vlc_modules_macros.h
src/config/config.h
src/config/core.c
src/libvlc.sym
src/modules/entry.c

index 0611e5549e2101278f03f9e42588424c1b8aa861..b41373f6aefc5e354417639f1b5479e774a2f11f 100644 (file)
@@ -211,8 +211,6 @@ VLC_EXPORT( void,   __config_ResetAll, ( vlc_object_t * ) );
 
 VLC_EXPORT( module_config_t *, config_FindConfig,( vlc_object_t *, const char * ) );
 
-VLC_EXPORT( int, config_Duplicate,( module_t *, const module_config_t *, size_t ));
-
 VLC_EXPORT(const char *, config_GetDataDir, ( void ));
 
 VLC_EXPORT( void,       __config_AddIntf,    ( vlc_object_t *, const char * ) );
@@ -300,47 +298,39 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) );
  *   allow for a more user friendly interface.
  *****************************************************************************/
 
-#define add_config_inner( ) \
-    i_config++; \
-    if( (i_config % 10) == 0 ) \
-        p_config = (module_config_t *) \
-             realloc(p_config, (i_config+11) * sizeof(module_config_t)); \
-    memset( p_config + i_config, 0, sizeof( *p_config ) )
-
 #define add_type_inner( type ) \
-    add_config_inner( ); \
-    p_config[i_config].i_type = type
+    p_config = vlc_config_create (p_module, type)
 
 #define add_typedesc_inner( type, text, longtext ) \
     add_type_inner( type ); \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_DESC, \
+    vlc_config_set (p_config, VLC_CONFIG_DESC, \
                     (const char *)(text), (const char *)(longtext))
 
 #define add_typeadv_inner( type, text, longtext, advc ) \
     add_typedesc_inner( type, text, longtext ); \
-    if (advc) vlc_config_set (p_config + i_config, VLC_CONFIG_ADVANCED)
+    if (advc) vlc_config_set (p_config, VLC_CONFIG_ADVANCED)
 
 #define add_typename_inner( type, name, text, longtext, advc, cb ) \
     add_typeadv_inner( type, text, longtext, advc ); \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_NAME, \
+    vlc_config_set (p_config, VLC_CONFIG_NAME, \
                     (const char *)(name), (vlc_callback_t)(cb))
 
 #define add_string_inner( type, name, text, longtext, advc, cb, v ) \
     add_typename_inner( type, name, text, longtext, advc, cb ); \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (const char *)(v))
+    vlc_config_set (p_config, VLC_CONFIG_VALUE, (const char *)(v))
 
 #define add_int_inner( type, name, text, longtext, advc, cb, v ) \
     add_typename_inner( type, name, text, longtext, advc, cb ); \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (int)(v))
+    vlc_config_set (p_config, VLC_CONFIG_VALUE, (int)(v))
 
 
 #define set_category( i_id ) \
     add_type_inner( CONFIG_CATEGORY ); \
-    p_config[i_config].value.i = i_id
+    p_config->value.i = i_id
 
 #define set_subcategory( i_id ) \
     add_type_inner( CONFIG_SUBCATEGORY ); \
-    p_config[i_config].value.i = i_id
+    p_config->value.i = i_id
 
 #define set_section( text, longtext ) \
     add_typedesc_inner( CONFIG_SECTION, text, longtext )
@@ -371,22 +361,20 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) );
 
 #define add_module( name, psz_caps, value, p_callback, text, longtext, advc ) \
     add_string_inner( CONFIG_ITEM_MODULE, name, text, longtext, advc, p_callback, value ); \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_CAPABILITY, \
-                    (const char *)(psz_caps))
+    vlc_config_set (p_config, VLC_CONFIG_CAPABILITY, (const char *)(psz_caps))
 
 #define add_module_list( name, psz_caps, value, p_callback, text, longtext, advc ) \
     add_string_inner( CONFIG_ITEM_MODULE_LIST, name, text, longtext, advc, p_callback, value ); \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_CAPABILITY, \
-                    (const char *)(psz_caps))
+    vlc_config_set (p_config, VLC_CONFIG_CAPABILITY, (const char *)(psz_caps))
 
 #ifndef __PLUGIN__
 #define add_module_cat( name, i_subcategory, value, p_callback, text, longtext, advc ) \
     add_string_inner( CONFIG_ITEM_MODULE_CAT, name, text, longtext, advc, p_callback, value ); \
-    p_config[i_config].min.i = i_subcategory /* gruik */
+    p_config->min.i = i_subcategory /* gruik */
 
 #define add_module_list_cat( name, i_subcategory, value, p_callback, text, longtext, advc ) \
     add_string_inner( CONFIG_ITEM_MODULE_LIST_CAT, name, text, longtext, advc, p_callback, value ); \
-    p_config[i_config].min.i = i_subcategory /* gruik */
+    p_config->min.i = i_subcategory /* gruik */
 #endif
 
 #define add_integer( name, value, p_callback, text, longtext, advc ) \
@@ -401,7 +389,7 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) );
 
 #define add_float( name, v, p_callback, text, longtext, advc ) \
     add_typename_inner( CONFIG_ITEM_FLOAT, name, text, longtext, advc, p_callback ); \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (double)(v))
+    vlc_config_set (p_config, VLC_CONFIG_VALUE, (double)(v))
 
 #define add_float_with_range( name, value, f_min, f_max, p_callback, text, longtext, advc ) \
     add_float( name, value, p_callback, text, longtext, advc ); \
@@ -409,14 +397,14 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) );
 
 #define add_bool( name, v, p_callback, text, longtext, advc ) \
     add_typename_inner( CONFIG_ITEM_BOOL, name, text, longtext, advc, p_callback ); \
-    if (v) vlc_config_set (p_config + i_config, VLC_CONFIG_VALUE, (int)VLC_TRUE)
+    if (v) vlc_config_set (p_config, VLC_CONFIG_VALUE, (int)VLC_TRUE)
 
 /* For removed option */
 #define add_obsolete_inner( name, type ) \
     add_type_inner( type ); \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_NAME, \
+    vlc_config_set (p_config, VLC_CONFIG_NAME, \
                     (const char *)(name), (vlc_callback_t)NULL); \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_REMOVED)
+    vlc_config_set (p_config, VLC_CONFIG_REMOVED)
 
 #define add_obsolete_bool( name ) \
         add_obsolete_inner( name, CONFIG_ITEM_BOOL )
@@ -433,53 +421,51 @@ VLC_EXPORT( int, vlc_config_set, (module_config_t *, int, ...) );
 /* Modifier macros for the config options (used for fine tuning) */
 
 #define add_deprecated_alias( name ) \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_OLDNAME, \
-                    (const char *)(name))
+    vlc_config_set (p_config, VLC_CONFIG_OLDNAME, (const char *)(name))
 
 #define change_short( ch ) \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_SHORTCUT, (int)(ch))
+    vlc_config_set (p_config, VLC_CONFIG_SHORTCUT, (int)(ch))
 
 #define change_string_list( list, list_text, list_update_func ) \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_LIST, \
+    vlc_config_set (p_config, VLC_CONFIG_LIST, \
                     (size_t)(sizeof (list) / sizeof (char *)), \
                     (const char *const *)(list), \
                     (const char *const *)(list_text))
 
 #define change_integer_list( list, list_text, list_update_func ) \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_LIST, \
+    vlc_config_set (p_config, VLC_CONFIG_LIST, \
                     (size_t)(sizeof (list) / sizeof (int)), \
                     (const int *)(list), \
                     (const char *const *)(list_text))
 
 #define change_float_list( list, list_text, list_update_func ) \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_LIST, \
+    vlc_config_set (p_config, VLC_CONFIG_LIST, \
                     (size_t)(sizeof (list) / sizeof (float)), \
                     (const float *)(list), \
                     (const char *const *)(list_text))
 
 #define change_integer_range( minv, maxv ) \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_RANGE, \
-                    (int)(minv), (int)(maxv))
+    vlc_config_set (p_config, VLC_CONFIG_RANGE, (int)(minv), (int)(maxv))
 
 #define change_float_range( minv, maxv ) \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_RANGE, \
+    vlc_config_set (p_config, VLC_CONFIG_RANGE, \
                     (double)(minv), (double)(maxv))
 
 #define change_action_add( pf_action, text ) \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_ADD_ACTION, \
+    vlc_config_set (p_config, VLC_CONFIG_ADD_ACTION, \
                     (vlc_callback_t)(pf_action), (const char *)(text))
 
 #define change_internal() \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_PRIVATE)
+    vlc_config_set (p_config, VLC_CONFIG_PRIVATE)
 
 #define change_need_restart() \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_RESTART)
+    vlc_config_set (p_config, VLC_CONFIG_RESTART)
 
 #define change_autosave() \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_PERSISTENT)
+    vlc_config_set (p_config, VLC_CONFIG_PERSISTENT)
 
 #define change_unsaveable() \
-    vlc_config_set (p_config + i_config, VLC_CONFIG_VOLATILE)
+    vlc_config_set (p_config, VLC_CONFIG_VOLATILE)
 
 /****************************************************************************
  * config_chain_t:
index 96a2aeccd2dd51f0c20d8b868ee457321ab226b3..fccda313e5adb49355cc30f8a7d967b550527174 100644 (file)
@@ -111,7 +111,6 @@ E_(vlc_entry) ( module_t *p_module );
     __VLC_SYMBOL(vlc_entry) ( module_t *p_module )                            \
     {                                                                         \
         int res;                                                              \
-        size_t i_config = (size_t)(-1);                                       \
         module_config_t *p_config = NULL;                                     \
         if (vlc_module_set (p_module, VLC_MODULE_NAME,                        \
                             (void *)(MODULE_STRING)))                         \
@@ -121,10 +120,10 @@ E_(vlc_entry) ( module_t *p_module );
 
 #define vlc_module_end( )                                                     \
         }                                                                     \
-        return config_Duplicate( p_module, p_config, ++i_config );            \
+        return VLC_SUCCESS;                                                   \
                                                                               \
     error:                                                                    \
-        /* FIXME: config_Free( p_config ); */                                 \
+        /* FIXME: config_Free( p_module ); */                                 \
         /* FIXME: cleanup submodules objects ??? */                           \
         return VLC_EGENERIC;                                                  \
     }                                                                         \
index 9e5b6d5e03ff1112b59e30e556824a5305af4ef4..53890cd2c9ed84885e45a2586e13819ad1014bf4 100644 (file)
@@ -34,6 +34,9 @@ extern "C" {
 int  config_CreateDir( vlc_object_t *, const char * );
 int  config_AutoSaveConfigFile( vlc_object_t * );
 
+/* TODO: remove this, only used for helper module */
+int config_Duplicate( module_t *, module_config_t *, size_t );
+
 void config_Free( module_t * );
 
 void config_SetCallbacks( module_config_t *, module_config_t *, size_t );
index 0caaa6fae10ca45b49c9e08f253b114113eb48f8..f300ce0124f0ff3bb633a64d4aa1bff77274e0f3 100644 (file)
@@ -486,7 +486,7 @@ module_config_t *config_FindConfig( vlc_object_t *p_this, const char *psz_name )
  * this module might be unloaded from memory at any time (remember HideModule).
  * This is why we need to create an exact copy of the config data.
  *****************************************************************************/
-int config_Duplicate( module_t *p_module, const module_config_t *p_orig,
+int config_Duplicate( module_t *p_module, module_config_t *p_orig,
                       size_t n )
 {
     const module_config_t *p_item, *p_end = p_orig + n;
index c0d7d8016bf7ef8349f80bc0270db34f130b48d7..a36597437e488e5d9e5d858c883d6d49a5966146 100644 (file)
@@ -46,7 +46,6 @@ block_Realloc
 config_ChainCreate
 config_ChainDestroy
 __config_ChainParse
-config_Duplicate
 config_FindConfig
 config_GetDataDir
 __config_GetFloat
index 94667fc6f7d69fad57c9acce7342e10a030f61e1..7cb0ebf11626cce9a92350e2a39f315f34367833 100644 (file)
@@ -157,7 +157,6 @@ module_config_t *vlc_config_create (module_t *module, int type)
 
         module->p_config = tab;
     }
-    module->confsize++;
 
     memset (tab + confsize, 0, sizeof (tab[confsize]));
     tab[confsize].i_type = type;
@@ -170,6 +169,7 @@ module_config_t *vlc_config_create (module_t *module, int type)
             module->i_bool_items++;
     }
 
+    module->confsize++;
     return tab + confsize;
 }