summaryrefslogtreecommitdiffstats
path: root/options/m_option.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-06-23 20:51:12 +0200
committerwm4 <wm4@nowhere>2017-06-23 20:51:12 +0200
commit0729bee415880fd076d68f2eae9bd646dd28f474 (patch)
treed040f13872e2d7f66160567e76aec49ed467a8e0 /options/m_option.c
parent633152e55a6f851c58267793081dea3162acfb48 (diff)
downloadmpv-0729bee415880fd076d68f2eae9bd646dd28f474.tar.bz2
mpv-0729bee415880fd076d68f2eae9bd646dd28f474.tar.xz
options: simplify and rename m_option_type_store
This was an annoying option type. And still is. But at least it's on the same level as m_option_type_print_fn now, and can probably cleaned up further like it. Both types are for options that are only on the command line, always have special handling (i.e. do something with them in parse_commandline.c before passing them to the generic m_config.c/m_option.c layers), and are m_options only for --list-options and (oddly) the split_opt_silent() function.
Diffstat (limited to 'options/m_option.c')
-rw-r--r--options/m_option.c56
1 files changed, 18 insertions, 38 deletions
diff --git a/options/m_option.c b/options/m_option.c
index 7e35153c84..c141850e75 100644
--- a/options/m_option.c
+++ b/options/m_option.c
@@ -202,42 +202,6 @@ const m_option_type_t m_option_type_flag = {
.get = flag_get,
};
-// Single-value, write-only flag
-
-static int parse_store(struct mp_log *log, const m_option_t *opt,
- struct bstr name, struct bstr param, void *dst)
-{
- if (param.len == 0) {
- if (dst)
- VAL(dst) = opt->max;
- return 0;
- } else {
- mp_err(log, "Invalid parameter for %.*s flag: %.*s\n",
- BSTR_P(name), BSTR_P(param));
- return M_OPT_DISALLOW_PARAM;
- }
-}
-
-static int store_set(const m_option_t *opt, void *dst, struct mpv_node *src)
-{
- if (src->format != MPV_FORMAT_FLAG)
- return M_OPT_UNKNOWN;
- if (!src->u.flag)
- return M_OPT_INVALID;
- VAL(dst) = opt->max;
- return 1;
-}
-
-const m_option_type_t m_option_type_store = {
- // can only be activated
- .name = "Flag",
- .size = sizeof(int),
- .flags = M_OPT_TYPE_OPTIONAL_PARAM,
- .parse = parse_store,
- .copy = copy_opt,
- .set = store_set,
-};
-
// Integer
#undef VAL
@@ -1654,8 +1618,6 @@ const m_option_type_t m_option_type_msglevels = {
.set = set_msglevels,
};
-/////////////////// Print
-
static int parse_print(struct mp_log *log, const m_option_t *opt,
struct bstr name, struct bstr param, void *dst)
{
@@ -1669,6 +1631,24 @@ const m_option_type_t m_option_type_print_fn = {
.parse = parse_print,
};
+static int parse_dummy_flag(struct mp_log *log, const m_option_t *opt,
+ struct bstr name, struct bstr param, void *dst)
+{
+ if (param.len) {
+ mp_err(log, "Invalid parameter for %.*s flag: %.*s\n",
+ BSTR_P(name), BSTR_P(param));
+ return M_OPT_DISALLOW_PARAM;
+ }
+ return 0;
+}
+
+const m_option_type_t m_option_type_dummy_flag = {
+ // can only be activated
+ .name = "Flag",
+ .flags = M_OPT_TYPE_OPTIONAL_PARAM,
+ .parse = parse_dummy_flag,
+};
+
#undef VAL
// Read s sub-option name, or a positional sub-opt value.