about summary refs log tree commit diff
path: root/cli/btinfo.c
diff options
context:
space:
mode:
authorRichard Nyberg <rnyberg@murmeldjur.se>2005-06-24 09:51:38 +0000
committerRichard Nyberg <rnyberg@murmeldjur.se>2005-06-24 09:51:38 +0000
commitdd0d462afae75ff243f8cd1528963f9ad489706d (patch)
tree2ef874a1fe5212245814d16f4c9b389524aed9d1 /cli/btinfo.c
downloadbtpd-dd0d462afae75ff243f8cd1528963f9ad489706d.tar.gz
btpd-dd0d462afae75ff243f8cd1528963f9ad489706d.zip
Import btpd-0.1.
git-svn-id: file:///home/rnyberg/svngit/btpd/releases/0.1@1 76a1f634-46fa-0310-9943-bd1476092a85
Diffstat (limited to 'cli/btinfo.c')
-rw-r--r--cli/btinfo.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/cli/btinfo.c b/cli/btinfo.c
new file mode 100644
index 0000000..bd4a33b
--- /dev/null
+++ b/cli/btinfo.c
@@ -0,0 +1,53 @@
+#include <sys/types.h>
+
+#include <err.h>
+#include <errno.h>
+#include <getopt.h>
+#include <inttypes.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "metainfo.h"
+
+static void
+usage()
+{
+    fprintf(stderr, "Usage: btinfo file ...\n\n");
+    exit(1);
+}
+
+static struct option longopts[] = {
+    { "help", no_argument, NULL, 1 },
+    { NULL, 0, NULL, 0 }
+};
+
+int
+main(int argc, char **argv)
+{
+    int ch;
+
+    while ((ch = getopt_long(argc, argv, "", longopts, NULL)) != -1)
+	usage();
+
+    argc -= optind;
+    argv += optind;
+
+    if (argc < 1)
+	usage();
+
+    while (argc > 0) {
+	struct metainfo *mi;
+
+	if ((errno = load_metainfo(*argv, -1, 1, &mi)) != 0)
+	    err(1, "load_metainfo: %s", *argv);
+
+	print_metainfo(mi);
+	clear_metainfo(mi);
+	free(mi);
+
+	argc--;
+	argv++;
+    }
+
+    return 0;
+}