[sgen] Cmdline option to print all entries in sgen-grep-binprot.
authorMark Probst <mark.probst@gmail.com>
Tue, 2 Apr 2013 17:13:03 +0000 (10:13 -0700)
committerMark Probst <mark.probst@gmail.com>
Tue, 2 Apr 2013 17:39:36 +0000 (10:39 -0700)
tools/sgen/sgen-grep-binprot.c

index 9978815b73a20b43dcc83e723788c8c1cd22d091..3dfda20fa21b18e249a2f34a8b6ef0de1515d47a 100644 (file)
@@ -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);
        }