diff options
Diffstat (limited to 'core/m_config.h')
-rw-r--r-- | core/m_config.h | 56 |
1 files changed, 26 insertions, 30 deletions
diff --git a/core/m_config.h b/core/m_config.h index 8b9b0dc7f7..57170cf48a 100644 --- a/core/m_config.h +++ b/core/m_config.h @@ -64,13 +64,6 @@ struct m_profile { char **opts; }; -enum option_source { - // Set when parsing command line arguments. - M_COMMAND_LINE, - // Set when parsing from a config file. - M_CONFIG_FILE, -}; - // Config object /** \ingroup Config */ typedef struct m_config { @@ -78,7 +71,6 @@ typedef struct m_config { /** This contains all options and suboptions. */ struct m_config_option *opts; - enum option_source mode; // When options are set (via m_config_set_option or m_config_set_profile), // back up the old value (unless it's already backed up). Used for restoring // global options when per-file options are set. @@ -114,7 +106,19 @@ void m_config_leave_file_local(struct m_config *config); int m_config_register_options(struct m_config *config, const struct m_option *args); -/* Set an option. +enum { + M_SETOPT_PRE_PARSE_ONLY = 1, // Silently ignore non-M_OPT_PRE_PARSE opt. + M_SETOPT_CHECK_ONLY = 2, // Don't set, just check name/value + M_SETOPT_FROM_CONFIG_FILE = 4, // Reject M_OPT_NOCFG opt. (print error) +}; + +// Set the named option to the given string. +// flags: combination of M_SETOPT_* flags (0 for normal operation) +// Returns >= 0 on success, otherwise see OptionParserReturn. +int m_config_set_option_ext(struct m_config *config, struct bstr name, + struct bstr param, int flags); + +/* Set an option. (Like: m_config_set_option_ext(config, name, param, 0)) * \param config The config object. * \param name The option's name. * \param param The value of the option, can be NULL. @@ -129,18 +133,6 @@ static inline int m_config_set_option0(struct m_config *config, return m_config_set_option(config, bstr0(name), bstr0(param)); } -/* 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(struct m_config *config, struct bstr name, - struct bstr param); - -static inline int m_config_check_option0(struct m_config *config, - const char *name, const char *param) -{ - return m_config_check_option(config, bstr0(name), bstr0(param)); -} - int m_config_parse_suboptions(struct m_config *config, char *name, char *subopts); @@ -156,15 +148,19 @@ struct m_config_option *m_config_get_co(const struct m_config *config, struct bstr name); /* Map options like "no-opt=" to "opt=no". - * config The config object. - * \param name The option's name. May be set to a new name. - * \param param The option value. May be set to a new value. - * \return The following error codes: - * M_OPT_UNKNOWN: option not found - * M_OPT_INVALID: parameter non-empty in map case, prevents the mapping - * 0: success, *name and *param have been changed (or not) + * config: config object. + * name: option's name. May be set to a new name. + * value: option value. May be set to a new value. + * ambiguous: if true, "value" may be either an option value, or a separate, + * unrelated option following the current option. + * returns the following error codes: + * < 0: one of the M_OPT_ error codes + * 0: the option is valid, *value is set implicitly + * ("--foo bar" maps to "--foo=yes" + "bar", *value == "yes") + * 1: the option is valid, *value is a proper parameter */ -int m_config_map_option(struct m_config *config, bstr *name, bstr *param); +int m_config_map_option(struct m_config *config, bstr *name, bstr *value, + bool ambiguous); /* Print a list of all registered options. * \param config The config object. @@ -204,7 +200,7 @@ void m_profile_set_desc(struct m_profile *p, char *desc); * \param val The option's value. */ int m_config_set_profile_option(struct m_config *config, struct m_profile *p, - char *name, char *val); + bstr name, bstr val); /* Enables profile usage * Used by the config file parser when loading a profile. |