summaryrefslogtreecommitdiff
path: root/fdtdump.c
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2013-04-15 22:13:12 -0400
committerDavid Gibson <david@gibson.dropbear.id.au>2013-05-24 18:20:53 +1000
commitbe8d1c82cb0a9caeb7e2f804f9a9f845063d7d53 (patch)
treec850c488754c0d3144eaf2a4c7861e5eea50e6fb /fdtdump.c
parent4e76ec796c90d44d417f82d9db2d67cfe575f8ed (diff)
downloaddtc-be8d1c82cb0a9caeb7e2f804f9a9f845063d7d53.tar.gz
fdtdump: make usage a bit more friendly
This starts a new usage framework and then cuts fdtdump over to it. Now we can do `fdtdump -h` and get something useful back. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'fdtdump.c')
-rw-r--r--fdtdump.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/fdtdump.c b/fdtdump.c
index 03ea429..a6e522c 100644
--- a/fdtdump.c
+++ b/fdtdump.c
@@ -117,21 +117,36 @@ static void dump_blob(void *blob)
}
}
+/* Usage related data. */
+static const char usage_synopsis[] = "fdtdump [options] <file>";
+static const char usage_short_opts[] = USAGE_COMMON_SHORT_OPTS;
+static struct option const usage_long_opts[] = {
+ USAGE_COMMON_LONG_OPTS
+};
+static const char * const usage_opts_help[] = {
+ USAGE_COMMON_OPTS_HELP
+};
int main(int argc, char *argv[])
{
+ int opt;
+ const char *file;
char *buf;
- if (argc < 2) {
- fprintf(stderr, "supply input filename\n");
- return 5;
+ while ((opt = util_getopt_long()) != EOF) {
+ switch (opt) {
+ case_USAGE_COMMON_FLAGS
+ }
}
+ if (optind != argc - 1)
+ long_usage("missing input filename");
+ file = argv[optind];
+
+ buf = utilfdt_read(file);
+ if (!buf)
+ die("could not read: %s\n", file);
- buf = utilfdt_read(argv[1]);
- if (buf)
- dump_blob(buf);
- else
- return 10;
+ dump_blob(buf);
return 0;
}