summaryrefslogtreecommitdiff
path: root/libstore
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-01-17 18:39:04 +0000
committerMiles Bader <miles@gnu.org>1996-01-17 18:39:04 +0000
commit004394d9095dab709a93b17639586cd040dcf6fe (patch)
treed3d64380e4790542775f8fabe946d64f907df91a /libstore
parenteeee6d3ad0590bccad3492dc38f7814409cd52f0 (diff)
Initial revision
Diffstat (limited to 'libstore')
-rw-r--r--libstore/storeread.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/libstore/storeread.c b/libstore/storeread.c
new file mode 100644
index 00000000..613425c8
--- /dev/null
+++ b/libstore/storeread.c
@@ -0,0 +1,51 @@
+#include <argp.h>
+
+#include "store.h"
+
+struct argp_options options[] = {
+ {0}
+};
+char *arg_doc = "FILE [OFFSET [LENGTH]]...";
+char *doc = "OFFSET defaults to 0, LENGTH to the remainder of FILE";
+
+int
+main (int argc, char **argv)
+{
+ error_t parse_opt (int key, char *arg, struct argp_state *state)
+ {
+ switch (key)
+ {
+ case ARGP_KEY_ARG:
+ if (! store)
+ {
+ file_t source = file_name_lookup (arg, O_READ, 0);
+ if (err)
+ error (err, 2, "%s", arg);
+ err = store_create (source, &store);
+ if (err)
+ error (err, 3, "%s", arg);
+ mach_port_deallocate (mach_task_self (), source);
+ }
+ else if (offset < 0)
+ offset = atoi (arg);
+ else
+ dump (store, offset,
+ {
+
+ }
+ break;
+ case ARGP_KEY_END:
+ if (offset < 0)
+ offset = 0;
+ if (length < 0)
+ dump (
+ case ARGP_KEY_NO_ARGS:
+ default:
+ return EINVAL;
+ }
+ return 0;
+ }
+ struct argp argp = {options, arg_doc, doc};
+ argp_parse (&argp, argc, argv, 0, 0);
+ exit (0);
+}