Commit 3b055b72 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Partially introduce vlc_config_set() to modify module_config_t through a less brittle API

BEWARE: If you have non-recompiled plugins, they WILL crash.
parent 28ff8dc8
......@@ -231,6 +231,22 @@ VLC_EXPORT( vlc_bool_t, __config_ExistIntf, ( vlc_object_t *, const char * ) );
#define config_RemoveIntf(a,b) __config_RemoveIntf(VLC_OBJECT(a),b)
#define config_ExistIntf(a,b) __config_ExistIntf(VLC_OBJECT(a),b)
typedef enum vlc_config_properties
{
/* DO NOT EVER REMOVE, INSERT OR REPLACE ANY ITEM! It would break the ABI!
* Append new items at the end ONLY. */
VLC_CONFIG_NAME, /* command line name (args=const char *, vlc_callback_t) */
VLC_CONFIG_DESC, /* description (args=const char *, const char *) */
VLC_CONFIG_VALUE, /* actual value (args=<type>) */
VLC_CONFIG_RANGE, /* minimum value (args=<type>, <type>) */
VLC_CONFIG_STEP, /* interval value (args=<type>) */
VLC_CONFIG_ADVANCED, /* enable advanced flag (args=none) */
VLC_CONFIG_VOLATILE, /* don't write variable to storage (args=none) */
VLC_CONFIG_PRIVATE, /* hide from user (args=none) */
} vlc_config_t;
VLC_EXPORT( int, vlc_config_set, (module_config_t *, vlc_config_t, ...) );
/*****************************************************************************
* Macros used to build the configuration structure.
......@@ -258,8 +274,8 @@ VLC_EXPORT( vlc_bool_t, __config_ExistIntf, ( vlc_object_t *, const char * ) );
#define add_typedesc_inner( type, text, longtext ) \
add_type_inner( type ); \
p_config[i_config].psz_text = text; \
p_config[i_config].psz_longtext = longtext
vlc_config_set (p_config + i_config, VLC_CONFIG_DESC, \
(const char *)(text), (const char *)(longtext))
#define add_typeadv_inner( type, text, longtext, advc ) \
add_typedesc_inner( type, text, longtext ); \
......@@ -267,8 +283,8 @@ VLC_EXPORT( vlc_bool_t, __config_ExistIntf, ( vlc_object_t *, const char * ) );
#define add_typename_inner( type, name, text, longtext, advc, cb ) \
add_typeadv_inner( type, text, longtext, advc ); \
p_config[i_config].psz_name = name; \
p_config[i_config].pf_callback = cb
vlc_config_set (p_config + i_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 ); \
......
......@@ -547,10 +547,10 @@ int config_Duplicate( module_t *p_module, const module_config_t *p_orig,
}
p_module->p_config[i].psz_type = strdupnull (p_orig[i].psz_type);
p_module->p_config[i].psz_name = strdupnull (p_orig[i].psz_name);
p_module->p_config[i].psz_name = p_orig[i].psz_name;
p_module->p_config[i].psz_current = strdupnull (p_orig[i].psz_current);
p_module->p_config[i].psz_text = _strdupnull (p_orig[i].psz_text);
p_module->p_config[i].psz_longtext = _strdupnull (p_orig[i].psz_longtext);
p_module->p_config[i].psz_text = p_orig[i].psz_text;
p_module->p_config[i].psz_longtext = p_orig[i].psz_longtext;
p_module->p_config[i].p_lock = &p_module->object_lock;
......
......@@ -20,10 +20,10 @@
#include <vlc/vlc.h>
#include <assert.h>
#include <stdarg.h>
#include "modules/modules.h"
#include "modules.h"
#include "libvlc.h"
#include "../libvlc.h"
static const char default_name[] = "unnamed";
......@@ -140,3 +140,48 @@ int vlc_module_set (module_t *module, int propid, void *value)
}
return 0;
}
int vlc_config_set (module_config_t *restrict item, vlc_config_t id, ...)
{
int ret = -1;
va_list ap;
assert (item != NULL);
va_start (ap, id);
switch (id)
{
case VLC_CONFIG_NAME:
{
const char *name = va_arg (ap, const char *);
vlc_callback_t cb = va_arg (ap, vlc_callback_t);
assert (name != NULL);
item->psz_name = strdup (name);
item->pf_callback = cb;
break;
}
case VLC_CONFIG_DESC:
{
const char *text = va_arg (ap, const char *);
const char *longtext = va_arg (ap, const char *);
item->psz_text = text ? strdup (gettext (text)) : NULL;
item->psz_longtext = longtext ? strdup (gettext (text)) : NULL;
ret = 0;
break;
}
case VLC_CONFIG_VALUE:
case VLC_CONFIG_RANGE:
case VLC_CONFIG_STEP:
case VLC_CONFIG_ADVANCED:
case VLC_CONFIG_VOLATILE:
case VLC_CONFIG_PRIVATE:
break;
}
va_end (ap);
return ret;
}
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