/* * sgen-grep-binprot-main.c: Binary protocol entries reader * * Copyright (C) 2016 Xamarin Inc * * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #include #include #include #include #include #include #include "sgen-entry-stream.h" #include "sgen-grep-binprot.h" /* FIXME Add grepers for specific endianness */ GrepEntriesFunction grepers [] = { sgen_binary_protocol_grep_entries32p, /* We have header, structures are packed, 32 bit word */ sgen_binary_protocol_grep_entries64p, /* We have header, structures are packed, 64 bit word */ sgen_binary_protocol_grep_entries /* No header, uses default word size and structure layout */ }; int main (int argc, char *argv[]) { int num_args = argc - 1; int num_nums = 0; int num_vtables = 0; int i; long nums [num_args]; long vtables [num_args]; gboolean dump_all = FALSE; gboolean color_output = FALSE; gboolean pause_times = FALSE; const char *input_path = NULL; int input_file; EntryStream stream; unsigned long long first_entry_to_consider = 0; for (i = 0; i < num_args; ++i) { char *arg = argv [i + 1]; char *next_arg = argv [i + 2]; if (!strcmp (arg, "--all")) { dump_all = TRUE; } else if (!strcmp (arg, "--pause-times")) { pause_times = TRUE; } else if (!strcmp (arg, "-v") || !strcmp (arg, "--vtable")) { vtables [num_vtables++] = strtoul (next_arg, NULL, 16); ++i; } else if (!strcmp (arg, "-s") || !strcmp (arg, "--start-at")) { first_entry_to_consider = strtoull (next_arg, NULL, 10); ++i; } else if (!strcmp (arg, "-c") || !strcmp (arg, "--color")) { color_output = TRUE; } else if (!strcmp (arg, "-i") || !strcmp (arg, "--input")) { input_path = next_arg; ++i; } else if (!strcmp (arg, "--help")) { printf ( "\n" "Usage:\n" "\n" "\tsgen-grep-binprot [options] [pointer...]\n" "\n" "Examples:\n" "\n" "\tsgen-grep-binprot --all