]> git.sesse.net Git - vlc/blobdiff - src/config/core.c
Use 64-bits for integers in plugin descriptors
[vlc] / src / config / core.c
index 19cd370d0675a4c9ea1f56471f8c2a4cf9087dc9..75907dd20b526586d00086d3afabde63605c826c 100644 (file)
@@ -27,7 +27,6 @@
 
 #include <vlc_common.h>
 #include "vlc_keys.h"
-#include "vlc_charset.h"
 #include "vlc_configuration.h"
 
 #include <assert.h>
@@ -68,14 +67,14 @@ int IsConfigIntegerType (int type)
     return memchr (config_types, type, sizeof (config_types)) != NULL;
 }
 
-
+#undef config_GetType
 /*****************************************************************************
  * config_GetType: get the type of a variable (bool, int, float, string)
  *****************************************************************************
  * This function is used to get the type of a variable from its name.
  * Beware, this is quite slow.
  *****************************************************************************/
-int __config_GetType( vlc_object_t *p_this, const char *psz_name )
+int config_GetType( vlc_object_t *p_this, const char *psz_name )
 {
     module_config_t *p_config;
     int i_type;
@@ -134,6 +133,7 @@ int __config_GetType( vlc_object_t *p_this, const char *psz_name )
     return i_type;
 }
 
+#undef config_GetInt
 /*****************************************************************************
  * config_GetInt: get the value of an int variable
  *****************************************************************************
@@ -141,7 +141,7 @@ int __config_GetType( vlc_object_t *p_this, const char *psz_name )
  * represented by an integer (CONFIG_ITEM_INTEGER and
  * CONFIG_ITEM_BOOL).
  *****************************************************************************/
-int __config_GetInt( vlc_object_t *p_this, const char *psz_name )
+int64_t config_GetInt( vlc_object_t *p_this, const char *psz_name )
 {
     module_config_t *p_config;
 
@@ -160,7 +160,7 @@ int __config_GetInt( vlc_object_t *p_this, const char *psz_name )
         return -1;
     }
 
-    int val;
+    int64_t val;
 
     vlc_rwlock_rdlock (&config_lock);
     val = p_config->value.i;
@@ -168,13 +168,14 @@ int __config_GetInt( vlc_object_t *p_this, const char *psz_name )
     return val;
 }
 
+#undef config_GetFloat
 /*****************************************************************************
  * config_GetFloat: get the value of a float variable
  *****************************************************************************
  * This function is used to get the value of variables which are internally
  * represented by a float (CONFIG_ITEM_FLOAT).
  *****************************************************************************/
-float __config_GetFloat( vlc_object_t *p_this, const char *psz_name )
+float config_GetFloat( vlc_object_t *p_this, const char *psz_name )
 {
     module_config_t *p_config;
 
@@ -201,6 +202,7 @@ float __config_GetFloat( vlc_object_t *p_this, const char *psz_name )
     return val;
 }
 
+#undef config_GetPsz
 /*****************************************************************************
  * config_GetPsz: get the string value of a string variable
  *****************************************************************************
@@ -212,7 +214,7 @@ float __config_GetFloat( vlc_object_t *p_this, const char *psz_name )
  *   duplicate of the actual value. It isn't safe to return a pointer to the
  *   actual value as it can be modified at any time.
  *****************************************************************************/
-char * __config_GetPsz( vlc_object_t *p_this, const char *psz_name )
+char * config_GetPsz( vlc_object_t *p_this, const char *psz_name )
 {
     module_config_t *p_config;
 
@@ -239,6 +241,7 @@ char * __config_GetPsz( vlc_object_t *p_this, const char *psz_name )
     return psz_value;
 }
 
+#undef config_PutPsz
 /*****************************************************************************
  * config_PutPsz: set the string value of a string variable
  *****************************************************************************
@@ -246,11 +249,11 @@ char * __config_GetPsz( vlc_object_t *p_this, const char *psz_name )
  * represented by a string (CONFIG_ITEM_STRING, CONFIG_ITEM_FILE,
  * CONFIG_ITEM_DIRECTORY, CONFIG_ITEM_PASSWORD, and CONFIG_ITEM_MODULE).
  *****************************************************************************/
-void __config_PutPsz( vlc_object_t *p_this,
+void config_PutPsz( vlc_object_t *p_this,
                       const char *psz_name, const char *psz_value )
 {
     module_config_t *p_config;
-    vlc_value_t oldval, val;
+    vlc_value_t oldval;
 
     p_config = config_FindConfig( p_this, psz_name );
 
@@ -268,24 +271,25 @@ void __config_PutPsz( vlc_object_t *p_this,
         return;
     }
 
-    vlc_rwlock_wrlock (&config_lock);
+    char *str;
+    if ((psz_value != NULL) && *psz_value)
+        str = strdup (psz_value);
+    else
+        str = NULL;
 
+    vlc_rwlock_wrlock (&config_lock);
     /* backup old value */
     oldval.psz_string = (char *)p_config->value.psz;
 
-    if ((psz_value != NULL) && *psz_value)
-        p_config->value.psz = strdup (psz_value);
-    else
-        p_config->value.psz = NULL;
-
+    p_config->value.psz = str;
     p_config->b_dirty = true;
-
-    val.psz_string = (char *)p_config->value.psz;
-
     vlc_rwlock_unlock (&config_lock);
 
     if( p_config->pf_callback )
     {
+        vlc_value_t val;
+
+        val.psz_string = (char *)psz_value;
         p_config->pf_callback( p_this, psz_name, oldval, val,
                                p_config->p_callback_data );
     }
@@ -294,6 +298,7 @@ void __config_PutPsz( vlc_object_t *p_this,
     free( oldval.psz_string );
 }
 
+#undef config_PutInt
 /*****************************************************************************
  * config_PutInt: set the integer value of an int variable
  *****************************************************************************
@@ -301,7 +306,8 @@ void __config_PutPsz( vlc_object_t *p_this,
  * represented by an integer (CONFIG_ITEM_INTEGER and
  * CONFIG_ITEM_BOOL).
  *****************************************************************************/
-void __config_PutInt( vlc_object_t *p_this, const char *psz_name, int i_value )
+void config_PutInt( vlc_object_t *p_this, const char *psz_name,
+                    int64_t i_value )
 {
     module_config_t *p_config;
     vlc_value_t oldval;
@@ -321,12 +327,9 @@ void __config_PutInt( vlc_object_t *p_this, const char *psz_name, int i_value )
         return;
     }
 
-    /* if i_min == i_max == 0, then do not use them */
-    if ((p_config->min.i == 0) && (p_config->max.i == 0))
-        ;
-    else if (i_value < p_config->min.i)
+    if (i_value < p_config->min.i)
         i_value = p_config->min.i;
-    else if (i_value > p_config->max.i)
+    if (i_value > p_config->max.i)
         i_value = p_config->max.i;
 
     vlc_rwlock_wrlock (&config_lock);
@@ -347,14 +350,15 @@ void __config_PutInt( vlc_object_t *p_this, const char *psz_name, int i_value )
     }
 }
 
+#undef config_PutFloat
 /*****************************************************************************
  * config_PutFloat: set the value of a float variable
  *****************************************************************************
  * This function is used to set the value of variables which are internally
  * represented by a float (CONFIG_ITEM_FLOAT).
  *****************************************************************************/
-void __config_PutFloat( vlc_object_t *p_this,
-                        const char *psz_name, float f_value )
+void config_PutFloat( vlc_object_t *p_this,
+                      const char *psz_name, float f_value )
 {
     module_config_t *p_config;
     vlc_value_t oldval;
@@ -473,7 +477,7 @@ void config_UnsortConfig (void)
     config.list = NULL;
     config.count = 0;
 
-    free (config.list);
+    free (clist);
 }
 
 /*****************************************************************************
@@ -544,10 +548,11 @@ void config_Free( module_t *p_module )
     p_module->p_config = NULL;
 }
 
+#undef config_ResetAll
 /*****************************************************************************
  * config_ResetAll: reset the configuration data for all the modules.
  *****************************************************************************/
-void __config_ResetAll( vlc_object_t *p_this )
+void config_ResetAll( vlc_object_t *p_this )
 {
     VLC_UNUSED(p_this);
     module_t *p_module;