#include <assert.h>
#include <stdarg.h>
-#include "modules.h"
+#include "modules/modules.h"
+#include "config/config.h"
#include "libvlc.h"
static const char default_name[] = "unnamed";
case VLC_MODULE_PROGRAM:
msg_Warn (module, "deprecated module property %d", propid);
- return 0;
+ break;
default:
msg_Err (module, "unknown module property %d", propid);
return 0;
}
-int vlc_config_set (module_config_t *restrict item, vlc_config_t id, ...)
+module_config_t *vlc_config_create (module_t *module, int type)
+{
+ unsigned confsize = module->confsize;
+ module_config_t *tab = module->p_config;
+
+ if ((confsize & 0xf) == 0)
+ {
+ tab = realloc (tab, (confsize + 17) * sizeof (*tab));
+ if (tab == NULL)
+ return NULL;
+
+ module->p_config = tab;
+ }
+ module->confsize++;
+
+ memset (tab + confsize, 0, sizeof (tab[confsize]));
+ tab[confsize].i_type = type;
+ tab[confsize].p_lock = &module->object_lock;
+
+ return tab + confsize;
+}
+
+int vlc_config_set (module_config_t *restrict item, int id, ...)
{
int ret = -1;
va_list ap;
assert (name != NULL);
item->psz_name = strdup (name);
item->pf_callback = cb;
+ ret = 0;
break;
}
}
case VLC_CONFIG_VALUE:
+ {
+ if (IsConfigIntegerType (item->i_type))
+ {
+ item->orig.i = item->saved.i =
+ item->value.i = va_arg (ap, int);
+ ret = 0;
+ }
+ else
+ if (IsConfigFloatType (item->i_type))
+ {
+ item->orig.f = item->saved.f =
+ item->value.f = va_arg (ap, double);
+ ret = 0;
+ }
+ else
+ if (IsConfigStringType (item->i_type))
+ {
+ const char *value = va_arg (ap, const char *);
+ item->value.psz = value ? strdup (value) : NULL;
+ item->orig.psz = value ? strdup (value) : NULL;
+ item->saved.psz = value ? strdup (value) : NULL;
+ ret = 0;
+ }
+ break;
+ }
+
case VLC_CONFIG_RANGE:
- case VLC_CONFIG_STEP:
+ {
+ if (IsConfigIntegerType (item->i_type))
+ {
+ item->min.i = va_arg (ap, int);
+ item->max.i = va_arg (ap, int);
+ ret = 0;
+ }
+ else
+ if (IsConfigFloatType (item->i_type))
+ {
+ item->min.f = va_arg (ap, double);
+ item->max.f = va_arg (ap, double);
+ ret = 0;
+ }
+ break;
+ }
+
case VLC_CONFIG_ADVANCED:
+ item->b_advanced = VLC_TRUE;
+ ret = 0;
+ break;
+
case VLC_CONFIG_VOLATILE:
+ item->b_unsaveable = VLC_TRUE;
+ ret = 0;
+ break;
+
+ case VLC_CONFIG_PERSISTENT:
+ item->b_autosave = VLC_TRUE;
+ ret = 0;
+ break;
+
+ case VLC_CONFIG_RESTART:
+ item->b_restart = VLC_TRUE;
+ ret = 0;
+ break;
+
case VLC_CONFIG_PRIVATE:
+ item->b_internal = VLC_TRUE;
+ ret = 0;
+ break;
+
+ case VLC_CONFIG_REMOVED:
+ item->psz_current = "SUPPRESSED";
+ ret = 0;
+ break;
+
+ case VLC_CONFIG_CAPABILITY:
+ {
+ const char *cap = va_arg (ap, const char *);
+ item->psz_type = cap ? strdup (cap) : NULL;
+ ret = 0;
+ break;
+ }
+
+ case VLC_CONFIG_SHORTCUT:
+ item->i_short = va_arg (ap, int);
+ ret = 0;
+ break;
+
+ case VLC_CONFIG_LIST:
+ {
+ size_t len = va_arg (ap, size_t);
+ char **dtext = malloc (sizeof (char *) * (len + 1));
+
+ if (dtext == NULL)
+ break;
+
+ /* Copy values */
+ if (IsConfigIntegerType (item->i_type))
+ {
+ const int *src = va_arg (ap, const int *);
+ int *dst = malloc (sizeof (int) * (len + 1));
+
+ if (dst != NULL)
+ {
+ memcpy (dst, src, sizeof (int) * len);
+ dst[len] = 0;
+ }
+ item->pi_list = dst;
+ }
+ else
+#if 0
+ if (IsConfigFloatType (item->i_type))
+ {
+ const float *src = va_arg (ap, const float *);
+ float *dst = malloc (sizeof (float) * (len + 1));
+
+ if (dst != NULL)
+ {
+ memcpy (dst, src, sizeof (float) * len);
+ dst[len] = 0.;
+ }
+ item->pf_list = dst;
+ }
+ else
+#endif
+ if (IsConfigStringType (item->i_type))
+ {
+ const char *const *src = va_arg (ap, const char *const *);
+ char **dst = malloc (sizeof (char *) * (len + 1));
+
+ if (dst != NULL)
+ {
+ for (size_t i = 0; i < len; i++)
+ dst[i] = src[i] ? strdup (src[i]) : NULL;
+ dst[len] = NULL;
+ }
+ item->ppsz_list = dst;
+ }
+ else
+ break;
+
+ /* Copy textual descriptions */
+ const char *const *text = va_arg (ap, const char *const *);
+ if (text != NULL)
+ {
+ for (size_t i = 0; i < len; i++)
+ dtext[i] = text[i] ? strdup (gettext (text[i])) : NULL;
+
+ dtext[len] = NULL;
+ item->ppsz_list_text = dtext;
+ }
+ else
+ item->ppsz_list_text = NULL;
+
+ item->i_list = len;
+ ret = 0;
break;
+ }
}
va_end (ap);