summaryrefslogtreecommitdiff
path: root/cmdutils.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-08-11 19:45:30 +0200
committerAnton Khirnov <anton@khirnov.net>2012-08-19 19:21:35 +0200
commit7c5012127fb7e18f0616011257bb4248f6a8b608 (patch)
treeb15931979cb46f5fc5f5d5b79680de8664f9a7d5 /cmdutils.c
parentdc4c24a3d35603957aecf2b075ac25902d18a190 (diff)
cmdutils: change semantics of show_help_options() and document it.
Currently it takes a mask and value, such that options for which (flags & mask) == value. Change it to take required flags and forbidden flags instead. This is shorter and simpler to understand.
Diffstat (limited to 'cmdutils.c')
-rw-r--r--cmdutils.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/cmdutils.c b/cmdutils.c
index 51077449b7..bc5cb8aae2 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -113,8 +113,8 @@ int64_t parse_time_or_die(const char *context, const char *timestr,
return us;
}
-void show_help_options(const OptionDef *options, const char *msg, int mask,
- int value)
+void show_help_options(const OptionDef *options, const char *msg, int req_flags,
+ int rej_flags)
{
const OptionDef *po;
int first;
@@ -122,18 +122,21 @@ void show_help_options(const OptionDef *options, const char *msg, int mask,
first = 1;
for (po = options; po->name != NULL; po++) {
char buf[64];
- if ((po->flags & mask) == value) {
- if (first) {
- printf("%s\n", msg);
- first = 0;
- }
- av_strlcpy(buf, po->name, sizeof(buf));
- if (po->flags & HAS_ARG) {
- av_strlcat(buf, " ", sizeof(buf));
- av_strlcat(buf, po->argname, sizeof(buf));
- }
- printf("-%-17s %s\n", buf, po->help);
+
+ if (((po->flags & req_flags) != req_flags) ||
+ (po->flags & rej_flags))
+ continue;
+
+ if (first) {
+ printf("%s\n", msg);
+ first = 0;
+ }
+ av_strlcpy(buf, po->name, sizeof(buf));
+ if (po->flags & HAS_ARG) {
+ av_strlcat(buf, " ", sizeof(buf));
+ av_strlcat(buf, po->argname, sizeof(buf));
}
+ printf("-%-17s %s\n", buf, po->help);
}
printf("\n");
}