From 2f707e5d52dd1dfa4be891bfbd2e7891d7ba0c41 Mon Sep 17 00:00:00 2001 From: Mark Probst Date: Tue, 2 Apr 2013 10:13:03 -0700 Subject: [sgen] Cmdline option to print all entries in sgen-grep-binprot. --- tools/sgen/sgen-grep-binprot.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'tools') 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); } -- cgit v1.2.3