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 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" 43*a0b956f5SMartin Matuska "\tzstream decompress [-v] [OBJECT,OFFSET[,TYPE]] ...\n" 44*a0b956f5SMartin Matuska "\n" 45eda14cbcSMatt Macy "\tzstream token resume_token\n" 46eda14cbcSMatt Macy "\n" 47eda14cbcSMatt Macy "\tzstream redup [-v] FILE | ...\n"); 48eda14cbcSMatt Macy exit(1); 49eda14cbcSMatt Macy } 50eda14cbcSMatt Macy 51eda14cbcSMatt Macy int 52eda14cbcSMatt Macy main(int argc, char *argv[]) 53eda14cbcSMatt Macy { 5416038816SMartin Matuska char *basename = strrchr(argv[0], '/'); 5516038816SMartin Matuska basename = basename ? (basename + 1) : argv[0]; 5616038816SMartin Matuska if (argc >= 1 && strcmp(basename, "zstreamdump") == 0) 5716038816SMartin Matuska return (zstream_do_dump(argc, argv)); 5816038816SMartin Matuska 59eda14cbcSMatt Macy if (argc < 2) 60eda14cbcSMatt Macy zstream_usage(); 61eda14cbcSMatt Macy 62eda14cbcSMatt Macy char *subcommand = argv[1]; 63eda14cbcSMatt Macy 64eda14cbcSMatt Macy if (strcmp(subcommand, "dump") == 0) { 65eda14cbcSMatt Macy return (zstream_do_dump(argc - 1, argv + 1)); 66*a0b956f5SMartin Matuska } else if (strcmp(subcommand, "decompress") == 0) { 67*a0b956f5SMartin Matuska return (zstream_do_decompress(argc - 1, argv + 1)); 68eda14cbcSMatt Macy } else if (strcmp(subcommand, "token") == 0) { 69eda14cbcSMatt Macy return (zstream_do_token(argc - 1, argv + 1)); 70eda14cbcSMatt Macy } else if (strcmp(subcommand, "redup") == 0) { 71eda14cbcSMatt Macy return (zstream_do_redup(argc - 1, argv + 1)); 72eda14cbcSMatt Macy } else { 73eda14cbcSMatt Macy zstream_usage(); 74eda14cbcSMatt Macy } 75eda14cbcSMatt Macy } 76