diff options
author | Mark Probst <mark.probst@gmail.com> | 2013-04-02 21:13:03 +0400 |
---|---|---|
committer | Mark Probst <mark.probst@gmail.com> | 2013-04-02 21:39:36 +0400 |
commit | 2f707e5d52dd1dfa4be891bfbd2e7891d7ba0c41 (patch) | |
tree | f4de254500e13ee365b7a69137e13caf5ffb532c /tools/sgen/sgen-grep-binprot.c | |
parent | 359f977e79ed0d5b32e9e8d386949c25828d8dd0 (diff) |
[sgen] Cmdline option to print all entries in sgen-grep-binprot.
Diffstat (limited to 'tools/sgen/sgen-grep-binprot.c')
-rw-r--r-- | tools/sgen/sgen-grep-binprot.c | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/tools/sgen/sgen-grep-binprot.c b/tools/sgen/sgen-grep-binprot.c index 9978815b73a..3dfda20fa21 100644 --- a/tools/sgen/sgen-grep-binprot.c +++ b/tools/sgen/sgen-grep-binprot.c @@ -285,17 +285,26 @@ is_match (gpointer ptr, int type, void *data) } } +static gboolean dump_all = FALSE; + int main (int argc, char *argv[]) { int type; void *data; - int num_nums = argc - 1; + int num_args = argc - 1; + int num_nums = 0; int i; - long nums [num_nums]; + long nums [num_args]; - for (i = 0; i < num_nums; ++i) - nums [i] = strtoul (argv [i + 1], NULL, 16); + for (i = 0; i < num_args; ++i) { + char *arg = argv [i + 1]; + if (!strcmp (arg, "--all")) { + dump_all = TRUE; + } else { + nums [num_nums++] = strtoul (arg, NULL, 16); + } + } while ((type = read_entry (stdin, &data)) != SGEN_PROTOCOL_EOF) { gboolean match = FALSE; @@ -305,7 +314,9 @@ main (int argc, char *argv[]) break; } } - if (match) + if (dump_all) + printf (match ? "* " : " "); + if (match || dump_all) print_entry (type, data); free (data); } |