1eda14cbcSMatt Macy /*
2eda14cbcSMatt Macy * CDDL HEADER START
3eda14cbcSMatt Macy *
4eda14cbcSMatt Macy * This file and its contents are supplied under the terms of the
5eda14cbcSMatt Macy * Common Development and Distribution License ("CDDL"), version 1.0.
6eda14cbcSMatt Macy * You may only use this file in accordance with the terms of version
7eda14cbcSMatt Macy * 1.0 of the CDDL.
8eda14cbcSMatt Macy *
9eda14cbcSMatt Macy * A full copy of the text of the CDDL should have accompanied this
10eda14cbcSMatt Macy * source. A copy of the CDDL is also available via the Internet at
11eda14cbcSMatt Macy * http://www.illumos.org/license/CDDL.
12eda14cbcSMatt Macy *
13eda14cbcSMatt Macy * CDDL HEADER END
14eda14cbcSMatt Macy */
15eda14cbcSMatt Macy
16eda14cbcSMatt Macy /*
17eda14cbcSMatt Macy * Copyright (c) 2020 by Delphix. All rights reserved.
18eda14cbcSMatt Macy * Copyright (c) 2020 by Datto Inc. All rights reserved.
19eda14cbcSMatt Macy */
20eda14cbcSMatt Macy #include <sys/types.h>
21eda14cbcSMatt Macy #include <sys/stat.h>
22eda14cbcSMatt Macy #include <fcntl.h>
23eda14cbcSMatt Macy #include <ctype.h>
24eda14cbcSMatt Macy #include <stdio.h>
25eda14cbcSMatt Macy #include <stdlib.h>
26da5137abSMartin Matuska #include <string.h>
27eda14cbcSMatt Macy #include <unistd.h>
28eda14cbcSMatt Macy #include <libintl.h>
29eda14cbcSMatt Macy #include <stddef.h>
30eda14cbcSMatt Macy #include <libzfs.h>
31eda14cbcSMatt Macy #include "zstream.h"
32eda14cbcSMatt Macy
33eda14cbcSMatt Macy void
zstream_usage(void)34eda14cbcSMatt Macy zstream_usage(void)
35eda14cbcSMatt Macy {
36eda14cbcSMatt Macy (void) fprintf(stderr,
37eda14cbcSMatt Macy "usage: zstream command args ...\n"
38eda14cbcSMatt Macy "Available commands are:\n"
39eda14cbcSMatt Macy "\n"
40eda14cbcSMatt Macy "\tzstream dump [-vCd] FILE\n"
41eda14cbcSMatt Macy "\t... | zstream dump [-vCd]\n"
42eda14cbcSMatt Macy "\n"
43a0b956f5SMartin Matuska "\tzstream decompress [-v] [OBJECT,OFFSET[,TYPE]] ...\n"
44a0b956f5SMartin Matuska "\n"
45*dbd5678dSMartin Matuska "\tzstream recompress [ -l level] TYPE\n"
46*dbd5678dSMartin Matuska "\n"
47eda14cbcSMatt Macy "\tzstream token resume_token\n"
48eda14cbcSMatt Macy "\n"
49eda14cbcSMatt Macy "\tzstream redup [-v] FILE | ...\n");
50eda14cbcSMatt Macy exit(1);
51eda14cbcSMatt Macy }
52eda14cbcSMatt Macy
53eda14cbcSMatt Macy int
main(int argc,char * argv[])54eda14cbcSMatt Macy main(int argc, char *argv[])
55eda14cbcSMatt Macy {
5616038816SMartin Matuska char *basename = strrchr(argv[0], '/');
5716038816SMartin Matuska basename = basename ? (basename + 1) : argv[0];
5816038816SMartin Matuska if (argc >= 1 && strcmp(basename, "zstreamdump") == 0)
5916038816SMartin Matuska return (zstream_do_dump(argc, argv));
6016038816SMartin Matuska
61eda14cbcSMatt Macy if (argc < 2)
62eda14cbcSMatt Macy zstream_usage();
63eda14cbcSMatt Macy
64eda14cbcSMatt Macy char *subcommand = argv[1];
65eda14cbcSMatt Macy
66eda14cbcSMatt Macy if (strcmp(subcommand, "dump") == 0) {
67eda14cbcSMatt Macy return (zstream_do_dump(argc - 1, argv + 1));
68a0b956f5SMartin Matuska } else if (strcmp(subcommand, "decompress") == 0) {
69a0b956f5SMartin Matuska return (zstream_do_decompress(argc - 1, argv + 1));
70*dbd5678dSMartin Matuska } else if (strcmp(subcommand, "recompress") == 0) {
71*dbd5678dSMartin Matuska return (zstream_do_recompress(argc - 1, argv + 1));
72eda14cbcSMatt Macy } else if (strcmp(subcommand, "token") == 0) {
73eda14cbcSMatt Macy return (zstream_do_token(argc - 1, argv + 1));
74eda14cbcSMatt Macy } else if (strcmp(subcommand, "redup") == 0) {
75eda14cbcSMatt Macy return (zstream_do_redup(argc - 1, argv + 1));
76eda14cbcSMatt Macy } else {
77eda14cbcSMatt Macy zstream_usage();
78eda14cbcSMatt Macy }
79eda14cbcSMatt Macy }
80