diff options
author | Uoti Urpala <uau@mplayer2.org> | 2011-07-27 20:59:44 +0300 |
---|---|---|
committer | Uoti Urpala <uau@mplayer2.org> | 2011-07-29 05:02:05 +0300 |
commit | 507fa7e2c23623dcbecf20a392ee025002c83866 (patch) | |
tree | 8bb5f2331af88dca98cfc799ac6ca45b09d775fe /m_option.h | |
parent | 0958620591375b41a8d21dd2a3501e1c9e5e9cba (diff) | |
download | mpv-507fa7e2c23623dcbecf20a392ee025002c83866.tar.bz2 mpv-507fa7e2c23623dcbecf20a392ee025002c83866.tar.xz |
options: indicate ambiguous option parameters explicitly
Command line options like "-foo xyz" are ambiguous: "xyz" may be a
parameter to the option "foo" or an unrelated argument. Instead of
relying on the struct m_config mode field (commandline/file) pass
parameters to specify ambiguous mode explicitly. Meant for "--foo"
options which are never ambiguous on command line either.
Diffstat (limited to 'm_option.h')
-rw-r--r-- | m_option.h | 27 |
1 files changed, 10 insertions, 17 deletions
diff --git a/m_option.h b/m_option.h index 5fa503f0c7..76d3366d18 100644 --- a/m_option.h +++ b/m_option.h @@ -21,6 +21,7 @@ #include <string.h> #include <stddef.h> +#include <stdbool.h> #include "config.h" @@ -209,13 +210,15 @@ struct m_option_type { * \param opt The option that is parsed. * \param name The full option name. * \param param The parameter to parse. + * \param ambiguous_param: "param" old cmdline style, "param" may or + * may not be an argument meant for this option * \param dst Pointer to the memory where the data should be written. * If NULL the parameter validity should still be checked. - * \param src Source of the option, see \ref OptionParserModes. - * \return On error a negative value is returned, on success the number of arguments - * consumed. For details see \ref OptionParserReturn. + * \return On error a negative value is returned, on success the number + * of arguments consumed. For details see \ref OptionParserReturn. */ - int (*parse)(const m_option_t *opt, const char *name, const char *param, void *dst, int src); + int (*parse)(const m_option_t *opt, const char *name, const char *param, + bool ambiguous_param, void *dst); // Print back a value in string form. /** \param opt The option to print. @@ -383,17 +386,6 @@ struct m_option { ///////////////////////////// Parser flags ///////////////////////////////// -// Some parsers behave differently depending on the mode passed in the src -// parameter of m_option_type::parse. For example the flag type doesn't take -// an argument when parsing from the command line. - -// Set when parsing from a config file. -#define M_CONFIG_FILE 0 -// Set when parsing command line arguments. -#define M_COMMAND_LINE 1 -// Set when pre-parsing the command line -#define M_COMMAND_LINE_PRE_PARSE 2 - // On success parsers return the number of arguments consumed: 0 or 1. // // To indicate that MPlayer should exit without playing anything, @@ -449,9 +441,10 @@ static inline void *m_option_get_ptr(const struct m_option *opt, // Helper to parse options, see \ref m_option_type::parse. static inline int m_option_parse(const m_option_t *opt, const char *name, - const char *param, void *dst, int src) + const char *param, bool ambiguous_param, + void *dst) { - return opt->type->parse(opt, name, param, dst, src); + return opt->type->parse(opt, name, param, ambiguous_param, dst); } // Helper to print options, see \ref m_option_type::print. |