diff options
author | wm4 <wm4@nowhere> | 2013-12-18 19:04:30 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2013-12-20 21:07:57 +0100 |
commit | 6a8fc3f5e38f93c36d18ad8407d4f3f345d893db (patch) | |
tree | ad2567044e98efaad555366b2b5a2bf010e815ee /options/m_option.c | |
parent | 5162c2709ee9bfce15750fa47744861c50351ae5 (diff) | |
download | mpv-6a8fc3f5e38f93c36d18ad8407d4f3f345d893db.tar.bz2 mpv-6a8fc3f5e38f93c36d18ad8407d4f3f345d893db.tar.xz |
msg: change --msglevel, reduce legacy glue
Basically, reimplement --msglevel. Instead of making the new msg code
use the legacy code, make the legacy code use the reimplemented
functionality.
The handling of the deprecated --identify switch changes. It temporarily
stops working; this will be fixed in later commits.
The actual sub-options syntax (like --msglevel-vo=...) goes away, but I
bet nobody knew about this or used this anyway.
Diffstat (limited to 'options/m_option.c')
-rw-r--r-- | options/m_option.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/options/m_option.c b/options/m_option.c index ba020f5375..32301b5ec3 100644 --- a/options/m_option.c +++ b/options/m_option.c @@ -1332,6 +1332,47 @@ const m_option_type_t m_option_type_subconfig_struct = { .parse = parse_subconf, }; +#undef VAL +#define VAL(x) (*(char **)(x)) + +static int parse_msglevels(const m_option_t *opt, struct bstr name, + struct bstr param, void *dst) +{ + if (param.start == NULL) + return M_OPT_MISSING_PARAM; + + bstr s = param; + while (1) { + int res = mp_msg_split_msglevel(&s, &(bstr){0}, &(int){0}); + if (res == 0) + break; + if (res < 0) { + mp_msg(MSGT_CFGPARSER, MSGL_ERR, + "Invalid syntax: %.*s\n", BSTR_P(s)); + return M_OPT_INVALID; + } + } + + if (dst) { + talloc_free(VAL(dst)); + VAL(dst) = bstrdup0(NULL, param); + } + + return 1; +} + +const m_option_type_t m_option_type_msglevels = { + .name = "Output verbosity levels", + .size = sizeof(char *), + .flags = M_OPT_TYPE_DYNAMIC, + .parse = parse_msglevels, + .print = print_str, + .copy = copy_str, + .free = free_str, +}; + +#undef VAL + static int parse_color(const m_option_t *opt, struct bstr name, struct bstr param, void *dst) { |