From 9fd2e449defa49128b07270ed9397970e0ca12ca Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 21 Apr 2013 03:18:32 +0200 Subject: m_option: add function to check whether parameters are required To avoid that it will be duplicated with m_option.c and m_config.c. --- core/m_config.c | 5 +---- core/m_option.c | 8 ++++++++ core/m_option.h | 2 ++ 3 files changed, 11 insertions(+), 4 deletions(-) (limited to 'core') diff --git a/core/m_config.c b/core/m_config.c index 65d60bdab9..3781a92b90 100644 --- a/core/m_config.c +++ b/core/m_config.c @@ -585,10 +585,7 @@ int m_config_option_requires_param(struct m_config *config, bstr name) if (opt) { if (bstr_endswith0(name, "-clr")) return 0; - if (((opt->flags & M_OPT_OPTIONAL_PARAM) || - (opt->type->flags & M_OPT_TYPE_OPTIONAL_PARAM))) - return 0; - return 1; + return m_option_required_params(opt); } return M_OPT_UNKNOWN; } diff --git a/core/m_option.c b/core/m_option.c index 2feaa5a4b1..36baeb7444 100644 --- a/core/m_option.c +++ b/core/m_option.c @@ -59,6 +59,14 @@ char *m_option_strerror(int code) } } +int m_option_required_params(const m_option_t *opt) +{ + if (((opt->flags & M_OPT_OPTIONAL_PARAM) || + (opt->type->flags & M_OPT_TYPE_OPTIONAL_PARAM))) + return 0; + return 1; +} + static const struct m_option *m_option_list_findb(const struct m_option *list, struct bstr name) { diff --git a/core/m_option.h b/core/m_option.h index dd1dbd3d75..0026406569 100644 --- a/core/m_option.h +++ b/core/m_option.h @@ -464,6 +464,8 @@ static inline void m_option_free(const m_option_t *opt, void *dst) opt->type->free(dst); } +int m_option_required_params(const m_option_t *opt); + // Cause a compilation warning if typeof(expr) != type. // Should be used with pointer types only. #define MP_EXPECT_TYPE(type, expr) (0 ? (type)0 : (expr)) -- cgit v1.2.3