return module;
}
+/**
+ * Destroys a plug-in.
+ * @warning If the plug-in is loaded in memory, the handle will be leaked.
+ */
void vlc_module_destroy (module_t *module)
{
+ assert (!module->b_loaded || !module->b_unloadable);
+
for (module_t *m = module->submodule, *next; m != NULL; m = next)
{
next = m->next;
}
-int vlc_plugin_set (module_t *module, module_config_t *item, int propid, ...)
+/**
+ * Callback for the plugin descriptor functions.
+ */
+static int vlc_plugin_setter (void *plugin, void *tgt, int propid, ...)
{
+ module_t **pprimary = plugin;
+ module_t *module = tgt;
+ module_config_t *item = tgt;
va_list ap;
int ret = 0;
{
case VLC_MODULE_CREATE:
{
- module_t **pp = va_arg (ap, module_t **);
+ module = *pprimary;
module_t *submodule = vlc_module_create (module);
-
if (unlikely(submodule == NULL))
{
ret = -1;
break;
}
- *pp = submodule;
- if (module == NULL)
+ *(va_arg (ap, module_t **)) = submodule;
+ if (*pprimary == NULL)
+ {
+ *pprimary = submodule;
break;
+ }
/* Inheritance. Ugly!! */
submodule->pp_shortcuts = xmalloc (sizeof (char **));
submodule->pp_shortcuts[0] = strdup_null (module->pp_shortcuts[0]);
{
int type = va_arg (ap, int);
module_config_t **pp = va_arg (ap, module_config_t **);
- *pp = vlc_config_create (module, type);
- if (*pp == NULL)
+
+ item = vlc_config_create (*pprimary, type);
+ if (unlikely(item == NULL))
+ {
ret = -1;
+ break;
+ }
+ *pp = item;
break;
}
case VLC_CONFIG_RANGE:
{
- if (IsConfigIntegerType (item->i_type)
- || !CONFIG_ITEM(item->i_type))
- {
- item->min.i = va_arg (ap, int64_t);
- item->max.i = va_arg (ap, int64_t);
- }
- else
if (IsConfigFloatType (item->i_type))
{
item->min.f = va_arg (ap, double);
item->max.f = va_arg (ap, double);
}
+ else
+ {
+ item->min.i = va_arg (ap, int64_t);
+ item->max.i = va_arg (ap, int64_t);
+ }
break;
}
item->i_short = va_arg (ap, int);
break;
- case VLC_CONFIG_OLDNAME:
- {
- const char *oldname = va_arg (ap, const char *);
- assert (item->psz_oldname == NULL);
- item->psz_oldname = oldname ? strdup (oldname) : NULL;
- break;
- }
-
case VLC_CONFIG_SAFE:
item->b_safe = true;
break;
va_end (ap);
return ret;
}
+
+/**
+ * Runs a plug-in descriptor. This loads the plug-in meta-data in memory.
+ */
+module_t *vlc_plugin_describe (vlc_plugin_cb entry)
+{
+ module_t *module = NULL;
+
+ if (entry (vlc_plugin_setter, &module) != 0)
+ {
+ if (module != NULL) /* partially initialized plug-in... */
+ vlc_module_destroy (module);
+ module = NULL;
+ }
+ return module;
+}