diff options
author | Namhyung Kim <namhyung@kernel.org> | 2014-10-22 11:15:45 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2014-10-29 08:32:47 -0400 |
commit | d152d1be5962ace0706066db71b4f05dff8764eb (patch) | |
tree | 3e8383632d183bcff2066436bfbb5db01e8f6324 /tools/perf/util/parse-options.c | |
parent | 29f9e5211132b0a0a4dfbbb403c136eebc334b73 (diff) |
perf tools: Add PARSE_OPT_DISABLED flag
In some cases, we need to reuse exising options with some of them
disabled. To do that, add PARSE_OPT_DISABLED flag and
set_option_flag() function.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Alexander Yarygin <yarygin@linux.vnet.ibm.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Hemant Kumar <hemant@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/1413990949-13953-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/parse-options.c')
-rw-r--r-- | tools/perf/util/parse-options.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tools/perf/util/parse-options.c b/tools/perf/util/parse-options.c index bf48092983c6..b6016101b40b 100644 --- a/tools/perf/util/parse-options.c +++ b/tools/perf/util/parse-options.c | |||
@@ -42,6 +42,8 @@ static int get_value(struct parse_opt_ctx_t *p, | |||
42 | return opterror(opt, "takes no value", flags); | 42 | return opterror(opt, "takes no value", flags); |
43 | if (unset && (opt->flags & PARSE_OPT_NONEG)) | 43 | if (unset && (opt->flags & PARSE_OPT_NONEG)) |
44 | return opterror(opt, "isn't available", flags); | 44 | return opterror(opt, "isn't available", flags); |
45 | if (opt->flags & PARSE_OPT_DISABLED) | ||
46 | return opterror(opt, "is not usable", flags); | ||
45 | 47 | ||
46 | if (!(flags & OPT_SHORT) && p->opt) { | 48 | if (!(flags & OPT_SHORT) && p->opt) { |
47 | switch (opt->type) { | 49 | switch (opt->type) { |
@@ -509,6 +511,8 @@ static void print_option_help(const struct option *opts, int full) | |||
509 | } | 511 | } |
510 | if (!full && (opts->flags & PARSE_OPT_HIDDEN)) | 512 | if (!full && (opts->flags & PARSE_OPT_HIDDEN)) |
511 | return; | 513 | return; |
514 | if (opts->flags & PARSE_OPT_DISABLED) | ||
515 | return; | ||
512 | 516 | ||
513 | pos = fprintf(stderr, " "); | 517 | pos = fprintf(stderr, " "); |
514 | if (opts->short_name) | 518 | if (opts->short_name) |
@@ -679,3 +683,16 @@ int parse_opt_verbosity_cb(const struct option *opt, | |||
679 | } | 683 | } |
680 | return 0; | 684 | return 0; |
681 | } | 685 | } |
686 | |||
687 | void set_option_flag(struct option *opts, int shortopt, const char *longopt, | ||
688 | int flag) | ||
689 | { | ||
690 | for (; opts->type != OPTION_END; opts++) { | ||
691 | if ((shortopt && opts->short_name == shortopt) || | ||
692 | (opts->long_name && longopt && | ||
693 | !strcmp(opts->long_name, longopt))) { | ||
694 | opts->flags |= flag; | ||
695 | break; | ||
696 | } | ||
697 | } | ||
698 | } | ||