From 7c5012127fb7e18f0616011257bb4248f6a8b608 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Sat, 11 Aug 2012 19:45:30 +0200 Subject: 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. --- cmdutils.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'cmdutils.c') 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"); } -- cgit v1.2.3