diff options
author | Anton Khirnov <anton@khirnov.net> | 2023-12-17 18:10:17 +0100 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2023-12-22 11:39:57 +0100 |
commit | 41716214c2912cf84946c939bea5400581384569 (patch) | |
tree | 9a9142b9482a5ae369ffc24db6382e468ac495d7 /fftools/cmdutils.h | |
parent | 148fac277a173473eed4ea6b03c7575e5696b3fa (diff) | |
download | ffmpeg-41716214c2912cf84946c939bea5400581384569.tar.gz |
fftools/ffmpeg: improve WARN_MULTIPLE_OPT_USAGE()
Currently it requires every single OPT_SPEC option to be accompanied by
an array of alternate names for this option. The vast majority of
options have no alternate names, resulting in a large numbers of
unnecessary single-element arrays that merely contain the option name.
Extend the option parsing API to allow marking options as having
alternate names, or as being the canonical name for some existing
alternatives. Use this new information to avoid the need for
abovementioned unnecessary single-element arrays.
Diffstat (limited to 'fftools/cmdutils.h')
-rw-r--r-- | fftools/cmdutils.h | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/fftools/cmdutils.h b/fftools/cmdutils.h index db91b788f8..53227abb47 100644 --- a/fftools/cmdutils.h +++ b/fftools/cmdutils.h @@ -118,6 +118,8 @@ typedef struct SpecifierOptList { SpecifierOpt *opt; int nb_opt; + /* Canonical option definition that was parsed into this list. */ + const struct OptionDef *opt_canon; enum OptionType type; } SpecifierOptList; @@ -160,6 +162,14 @@ typedef struct OptionDef { * output, or both. */ #define OPT_INPUT (1 << 10) #define OPT_OUTPUT (1 << 11) + +/* This option is a "canonical" form, to which one or more alternatives + * exist. These alternatives are listed in u1.names_alt. */ +#define OPT_HAS_ALT (1 << 12) +/* This option is an alternative form of some other option, whose + * name is stored in u1.name_canon */ +#define OPT_HAS_CANON (1 << 13) + union { void *dst_ptr; int (*func_arg)(void *, const char *, const char *); @@ -167,6 +177,15 @@ typedef struct OptionDef { } u; const char *help; const char *argname; + + union { + /* Name of the canonical form of this option. + * Is valid when OPT_HAS_CANON is set. */ + const char *name_canon; + /* A NULL-terminated list of alternate forms of this option. + * Is valid when OPT_HAS_ALT is set. */ + const char * const *names_alt; + } u1; } OptionDef; /** @@ -281,7 +300,7 @@ typedef struct OptionParseContext { * * @param optctx an app-specific options context. NULL for global options group */ -int parse_optgroup(void *optctx, OptionGroup *g); +int parse_optgroup(void *optctx, OptionGroup *g, const OptionDef *defs); /** * Split the commandline into an intermediate form convenient for further |