[vlc-commits] config_GetPszChoices(): add support for module config items
Rémi Denis-Courmont
git at videolan.org
Fri Oct 12 18:29:12 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Oct 12 19:28:24 2012 +0300| [2ef7e0e7e71b26b197cd69e1440e3026735cab2f] | committer: Rémi Denis-Courmont
config_GetPszChoices(): add support for module config items
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=2ef7e0e7e71b26b197cd69e1440e3026735cab2f
---
src/config/core.c | 46 +++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 45 insertions(+), 1 deletion(-)
diff --git a/src/config/core.c b/src/config/core.c
index 02fd0ce..9882c52 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -379,6 +379,38 @@ ssize_t config_GetIntChoices (vlc_object_t *obj, const char *name,
}
+static ssize_t config_ListModules (const char *cap, char ***restrict values,
+ char ***restrict texts)
+{
+ module_t **list;
+ ssize_t n = module_list_cap (&list, cap);
+ if (n <= 0)
+ {
+ *values = *texts = NULL;
+ return n;
+ }
+
+ char **vals = xmalloc ((n + 2) * sizeof (*vals));
+ char **txts = xmalloc ((n + 2) * sizeof (*txts));
+
+ vals[0] = xstrdup ("any");
+ txts[0] = xstrdup (_("Automatic"));
+
+ for (ssize_t i = 0; i < n; i++)
+ {
+ vals[i + 1] = xstrdup (module_get_object (list[i]));
+ txts[i + 1] = xstrdup (module_gettext (list[i],
+ module_get_name (list[i], true)));
+ }
+
+ vals[n + 1] = xstrdup ("none");
+ txts[n + 1] = xstrdup (_("Disable"));
+
+ *values = vals;
+ *texts = txts;
+ return n + 2;
+}
+
/**
* Determines a list of suggested values for a string configuration item.
* \param values pointer to a table of value strings [OUT]
@@ -396,11 +428,23 @@ ssize_t config_GetPszChoices (vlc_object_t *obj, const char *name,
module_config_t *cfg = config_FindConfig (obj, name);
if (cfg == NULL)
{
- msg_Warn (obj, "option %s does not exist", name);
errno = ENOENT;
return -1;
}
+ switch (cfg->i_type)
+ {
+ case CONFIG_ITEM_MODULE:
+ return config_ListModules (cfg->psz_type, values, texts);
+ default:
+ if (!IsConfigStringType (cfg->i_type))
+ {
+ errno = EINVAL;
+ return -1;
+ }
+ break;
+ }
+
size_t count = cfg->list_count;
if (count == 0)
{
More information about the vlc-commits
mailing list