From e873d703e956d3e2e68b9e18562983b029b5c7a8 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Thu, 28 Jul 2011 11:07:47 +0300 Subject: options: change option parsing to use bstr Using bstr allows simpler parsing code, especially because it avoids the need to modify or copy strings just to terminate extracted substrings. --- m_config.h | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'm_config.h') diff --git a/m_config.h b/m_config.h index d2c3b9ee4e..75dd85ac14 100644 --- a/m_config.h +++ b/m_config.h @@ -21,6 +21,7 @@ #include +#include "bstr.h" // m_config provides an API to manipulate the config variables in MPlayer. // It makes use of the Options API to provide a context stack that @@ -129,28 +130,42 @@ int m_config_register_options(struct m_config *config, /* Set an option. * \param config The config object. - * \param arg The option's name. + * \param name The option's name. * \param param The value of the option, can be NULL. * \param ambiguous_param: old style cmdline option, "param" may be a parameter to this option or something entirely unrelated * \return See \ref OptionParserReturn. */ -int m_config_set_option(struct m_config *config, char *arg, - char *param, bool ambiguous_param); +int m_config_set_option(struct m_config *config, struct bstr name, + struct bstr param, bool ambiguous_param); + +static inline int m_config_set_option0(struct m_config *config, + const char *name, const char *param, + bool ambiguous) +{ + return m_config_set_option(config, bstr(name), bstr(param), ambiguous); +} /* Check if an option setting is valid. * Same as above m_config_set_option() but doesn't actually set anything. */ -int m_config_check_option(const struct m_config *config, char *arg, - char *param, bool ambiguous_param); +int m_config_check_option(const struct m_config *config, struct bstr name, + struct bstr param, bool ambiguous_param); + +static inline int m_config_check_option0(struct m_config *config, + const char *name, const char *param, + bool ambiguous) +{ + return m_config_check_option(config, bstr(name), bstr(param), ambiguous); +} /* Get the option matching the given name. * \param config The config object. - * \param arg The option's name. + * \param name The option's name. */ const struct m_option *m_config_get_option(const struct m_config *config, - char *arg); + struct bstr name); /* Print a list of all registered options. * \param config The config object. -- cgit v1.2.3