2007-03-08 03:32:23 +05:30
|
|
|
/* vi: set sw=4 ts=4: */
|
|
|
|
/*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Common code for gunzip-like applets
|
2007-03-08 03:32:23 +05:30
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2007-03-08 03:32:23 +05:30
|
|
|
*/
|
2017-07-04 01:01:16 +05:30
|
|
|
//kbuild:lib-$(CONFIG_ZCAT) += bbunzip.o
|
|
|
|
//kbuild:lib-$(CONFIG_GUNZIP) += bbunzip.o
|
|
|
|
//kbuild:lib-$(CONFIG_BZCAT) += bbunzip.o
|
|
|
|
//kbuild:lib-$(CONFIG_BUNZIP2) += bbunzip.o
|
|
|
|
|
2013-11-14 14:23:52 +05:30
|
|
|
/* lzop_main() uses bbunpack(), need this: */
|
|
|
|
//kbuild:lib-$(CONFIG_LZOP) += bbunzip.o
|
2016-12-23 07:12:26 +05:30
|
|
|
//kbuild:lib-$(CONFIG_LZOPCAT) += bbunzip.o
|
|
|
|
//kbuild:lib-$(CONFIG_UNLZOP) += bbunzip.o
|
2016-12-08 16:54:48 +05:30
|
|
|
/* bzip2_main() too: */
|
2017-07-04 01:01:16 +05:30
|
|
|
//kbuild:lib-$(CONFIG_BZIP2) += bbunzip.o
|
2016-12-23 07:12:26 +05:30
|
|
|
/* gzip_main() too: */
|
2017-07-04 01:01:16 +05:30
|
|
|
//kbuild:lib-$(CONFIG_GZIP) += bbunzip.o
|
2013-11-14 14:23:52 +05:30
|
|
|
|
2017-09-18 19:58:43 +05:30
|
|
|
#include "libbb.h"
|
|
|
|
#include "bb_archive.h"
|
|
|
|
|
2007-03-08 03:32:23 +05:30
|
|
|
static
|
|
|
|
int open_to_or_warn(int to_fd, const char *filename, int flags, int mode)
|
|
|
|
{
|
2007-04-12 04:50:53 +05:30
|
|
|
int fd = open3_or_warn(filename, flags, mode);
|
2007-03-08 03:32:23 +05:30
|
|
|
if (fd < 0) {
|
|
|
|
return 1;
|
|
|
|
}
|
2007-04-12 04:50:53 +05:30
|
|
|
xmove_fd(fd, to_fd);
|
2007-03-08 03:32:23 +05:30
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-05-31 17:48:57 +05:30
|
|
|
char* FAST_FUNC append_ext(char *filename, const char *expected_ext)
|
|
|
|
{
|
|
|
|
return xasprintf("%s.%s", filename, expected_ext);
|
|
|
|
}
|
|
|
|
|
2008-06-27 08:22:20 +05:30
|
|
|
int FAST_FUNC bbunpack(char **argv,
|
2014-12-07 05:12:49 +05:30
|
|
|
IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_state_t *xstate),
|
2010-05-31 17:48:57 +05:30
|
|
|
char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext),
|
|
|
|
const char *expected_ext
|
2007-03-08 03:32:23 +05:30
|
|
|
)
|
|
|
|
{
|
|
|
|
struct stat stat_buf;
|
2013-02-28 22:36:09 +05:30
|
|
|
IF_DESKTOP(long long) int status = 0;
|
2007-03-08 04:52:47 +05:30
|
|
|
char *filename, *new_name;
|
2007-03-08 03:32:23 +05:30
|
|
|
smallint exitcode = 0;
|
2014-12-07 05:12:49 +05:30
|
|
|
transformer_state_t xstate;
|
2007-03-08 03:32:23 +05:30
|
|
|
|
|
|
|
do {
|
2007-03-08 04:52:47 +05:30
|
|
|
/* NB: new_name is *maybe* malloc'ed! */
|
|
|
|
new_name = NULL;
|
2007-03-08 03:32:23 +05:30
|
|
|
filename = *argv; /* can be NULL - 'streaming' bunzip2 */
|
2007-03-08 04:52:47 +05:30
|
|
|
|
2007-03-08 03:32:23 +05:30
|
|
|
if (filename && LONE_DASH(filename))
|
|
|
|
filename = NULL;
|
|
|
|
|
|
|
|
/* Open src */
|
|
|
|
if (filename) {
|
2018-02-01 13:43:14 +05:30
|
|
|
if (!(option_mask32 & BBUNPK_SEAMLESS_MAGIC)) {
|
2013-02-28 22:36:09 +05:30
|
|
|
if (stat(filename, &stat_buf) != 0) {
|
|
|
|
err_name:
|
|
|
|
bb_simple_perror_msg(filename);
|
2007-03-08 03:32:23 +05:30
|
|
|
err:
|
2013-02-28 22:36:09 +05:30
|
|
|
exitcode = 1;
|
|
|
|
goto free_name;
|
|
|
|
}
|
|
|
|
if (open_to_or_warn(STDIN_FILENO, filename, O_RDONLY, 0))
|
|
|
|
goto err;
|
|
|
|
} else {
|
2013-02-28 23:07:04 +05:30
|
|
|
/* "clever zcat" with FILE */
|
2014-02-02 06:36:38 +05:30
|
|
|
/* fail_if_not_compressed because zcat refuses uncompressed input */
|
|
|
|
int fd = open_zipped(filename, /*fail_if_not_compressed:*/ 1);
|
2013-02-28 22:36:09 +05:30
|
|
|
if (fd < 0)
|
|
|
|
goto err_name;
|
|
|
|
xmove_fd(fd, STDIN_FILENO);
|
2007-03-08 03:32:23 +05:30
|
|
|
}
|
2013-02-28 23:07:04 +05:30
|
|
|
} else
|
2018-02-01 13:43:14 +05:30
|
|
|
if (option_mask32 & BBUNPK_SEAMLESS_MAGIC) {
|
2013-02-28 23:07:04 +05:30
|
|
|
/* "clever zcat" on stdin */
|
2014-02-02 06:36:38 +05:30
|
|
|
if (setup_unzip_on_fd(STDIN_FILENO, /*fail_if_not_compressed*/ 1))
|
2013-02-28 23:07:04 +05:30
|
|
|
goto err;
|
2007-03-08 03:32:23 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
/* Special cases: test, stdout */
|
2018-02-01 13:43:14 +05:30
|
|
|
if (option_mask32 & (BBUNPK_OPT_STDOUT|BBUNPK_OPT_TEST)) {
|
|
|
|
if (option_mask32 & BBUNPK_OPT_TEST)
|
2007-03-08 03:32:23 +05:30
|
|
|
if (open_to_or_warn(STDOUT_FILENO, bb_dev_null, O_WRONLY, 0))
|
2013-02-28 22:34:22 +05:30
|
|
|
xfunc_die();
|
2007-03-08 03:32:23 +05:30
|
|
|
filename = NULL;
|
|
|
|
}
|
|
|
|
|
2007-03-08 04:52:47 +05:30
|
|
|
/* Open dst if we are going to unpack to file */
|
2007-03-08 03:32:23 +05:30
|
|
|
if (filename) {
|
2010-05-31 17:48:57 +05:30
|
|
|
new_name = make_new_name(filename, expected_ext);
|
2007-03-08 03:32:23 +05:30
|
|
|
if (!new_name) {
|
|
|
|
bb_error_msg("%s: unknown suffix - ignored", filename);
|
|
|
|
goto err;
|
|
|
|
}
|
2008-06-26 02:24:45 +05:30
|
|
|
|
|
|
|
/* -f: overwrite existing output files */
|
2018-02-01 13:43:14 +05:30
|
|
|
if (option_mask32 & BBUNPK_OPT_FORCE) {
|
2008-06-26 02:24:45 +05:30
|
|
|
unlink(new_name);
|
|
|
|
}
|
|
|
|
|
2007-03-08 04:52:47 +05:30
|
|
|
/* O_EXCL: "real" bunzip2 doesn't overwrite files */
|
2007-10-05 20:56:08 +05:30
|
|
|
/* GNU gunzip does not bail out, but goes to next file */
|
2007-03-08 03:32:23 +05:30
|
|
|
if (open_to_or_warn(STDOUT_FILENO, new_name, O_WRONLY | O_CREAT | O_EXCL,
|
|
|
|
stat_buf.st_mode))
|
|
|
|
goto err;
|
|
|
|
}
|
|
|
|
|
2007-03-08 04:52:47 +05:30
|
|
|
/* Check that the input is sane */
|
2018-02-01 13:43:14 +05:30
|
|
|
if (!(option_mask32 & BBUNPK_OPT_FORCE) && isatty(STDIN_FILENO)) {
|
2007-03-08 03:32:23 +05:30
|
|
|
bb_error_msg_and_die("compressed data not read from terminal, "
|
|
|
|
"use -f to force it");
|
|
|
|
}
|
|
|
|
|
2018-02-01 13:43:14 +05:30
|
|
|
if (!(option_mask32 & BBUNPK_SEAMLESS_MAGIC)) {
|
2014-12-07 05:12:49 +05:30
|
|
|
init_transformer_state(&xstate);
|
2017-01-09 15:28:37 +05:30
|
|
|
/*xstate.signature_skipped = 0; - already is */
|
2014-12-07 05:14:00 +05:30
|
|
|
/*xstate.src_fd = STDIN_FILENO; - already is */
|
|
|
|
xstate.dst_fd = STDOUT_FILENO;
|
2014-12-07 05:12:49 +05:30
|
|
|
status = unpacker(&xstate);
|
2013-02-28 22:36:09 +05:30
|
|
|
if (status < 0)
|
|
|
|
exitcode = 1;
|
|
|
|
} else {
|
2013-02-28 23:07:04 +05:30
|
|
|
if (bb_copyfd_eof(STDIN_FILENO, STDOUT_FILENO) < 0)
|
2013-02-28 22:36:09 +05:30
|
|
|
/* Disk full, tty closed, etc. No point in continuing */
|
|
|
|
xfunc_die();
|
|
|
|
}
|
2011-10-31 05:35:16 +05:30
|
|
|
|
2018-02-01 13:43:14 +05:30
|
|
|
if (!(option_mask32 & BBUNPK_OPT_STDOUT))
|
2011-10-31 05:35:16 +05:30
|
|
|
xclose(STDOUT_FILENO); /* with error check! */
|
2007-03-08 03:32:23 +05:30
|
|
|
|
|
|
|
if (filename) {
|
|
|
|
char *del = new_name;
|
2013-07-30 09:11:11 +05:30
|
|
|
|
2007-03-08 03:32:23 +05:30
|
|
|
if (status >= 0) {
|
2013-07-30 09:11:11 +05:30
|
|
|
unsigned new_name_len;
|
|
|
|
|
2008-11-01 18:24:56 +05:30
|
|
|
/* TODO: restore other things? */
|
2014-12-07 05:12:49 +05:30
|
|
|
if (xstate.mtime != 0) {
|
2009-11-30 00:10:36 +05:30
|
|
|
struct timeval times[2];
|
2009-11-15 06:58:56 +05:30
|
|
|
|
2014-12-07 05:12:49 +05:30
|
|
|
times[1].tv_sec = times[0].tv_sec = xstate.mtime;
|
2009-11-30 00:10:36 +05:30
|
|
|
times[1].tv_usec = times[0].tv_usec = 0;
|
2009-10-05 06:33:07 +05:30
|
|
|
/* Note: we closed it first.
|
2009-11-15 06:58:56 +05:30
|
|
|
* On some systems calling utimes
|
2009-10-05 06:33:07 +05:30
|
|
|
* then closing resets the mtime
|
|
|
|
* back to current time. */
|
2009-11-30 00:10:36 +05:30
|
|
|
utimes(new_name, times); /* ignoring errors */
|
2008-11-01 18:24:56 +05:30
|
|
|
}
|
|
|
|
|
2013-07-30 09:11:11 +05:30
|
|
|
if (ENABLE_DESKTOP)
|
|
|
|
new_name_len = strlen(new_name);
|
|
|
|
/* Restore source filename (unless tgz -> tar case) */
|
|
|
|
if (new_name == filename) {
|
|
|
|
new_name_len = strlen(filename);
|
|
|
|
filename[new_name_len] = '.';
|
|
|
|
}
|
|
|
|
/* Extreme bloat for gunzip compat */
|
|
|
|
/* Some users do want this info... */
|
2018-02-01 13:43:14 +05:30
|
|
|
if (ENABLE_DESKTOP && (option_mask32 & BBUNPK_OPT_VERBOSE)) {
|
2013-07-30 09:11:11 +05:30
|
|
|
unsigned percent = status
|
|
|
|
? ((uoff_t)stat_buf.st_size * 100u / (unsigned long long)status)
|
|
|
|
: 0;
|
|
|
|
fprintf(stderr, "%s: %u%% - replaced with %.*s\n",
|
|
|
|
filename,
|
|
|
|
100u - percent,
|
|
|
|
new_name_len, new_name
|
|
|
|
);
|
|
|
|
}
|
|
|
|
/* Delete _source_ file */
|
2007-03-08 03:32:23 +05:30
|
|
|
del = filename;
|
2018-02-01 13:43:14 +05:30
|
|
|
if (option_mask32 & BBUNPK_OPT_KEEP) /* ... unless -k */
|
2017-06-15 21:37:04 +05:30
|
|
|
del = NULL;
|
2007-03-08 03:32:23 +05:30
|
|
|
}
|
2017-06-15 21:37:04 +05:30
|
|
|
if (del)
|
|
|
|
xunlink(del);
|
2007-03-08 03:32:23 +05:30
|
|
|
free_name:
|
|
|
|
if (new_name != filename)
|
|
|
|
free(new_name);
|
|
|
|
}
|
|
|
|
} while (*argv && *++argv);
|
|
|
|
|
2018-02-01 13:43:14 +05:30
|
|
|
if (option_mask32 & BBUNPK_OPT_STDOUT)
|
2011-10-31 05:35:16 +05:30
|
|
|
xclose(STDOUT_FILENO); /* with error check! */
|
|
|
|
|
2007-03-08 03:32:23 +05:30
|
|
|
return exitcode;
|
|
|
|
}
|
|
|
|
|
2016-12-08 16:54:48 +05:30
|
|
|
#if ENABLE_UNCOMPRESS \
|
2017-01-08 11:58:34 +05:30
|
|
|
|| ENABLE_FEATURE_BZIP2_DECOMPRESS \
|
2016-12-08 16:54:48 +05:30
|
|
|
|| ENABLE_UNLZMA || ENABLE_LZCAT || ENABLE_LZMA \
|
|
|
|
|| ENABLE_UNXZ || ENABLE_XZCAT || ENABLE_XZ
|
2007-03-08 03:32:23 +05:30
|
|
|
static
|
2010-05-31 17:48:57 +05:30
|
|
|
char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext)
|
2007-03-08 03:32:23 +05:30
|
|
|
{
|
|
|
|
char *extension = strrchr(filename, '.');
|
2007-03-10 02:19:55 +05:30
|
|
|
if (!extension || strcmp(extension + 1, expected_ext) != 0) {
|
2007-03-08 04:52:47 +05:30
|
|
|
/* Mimic GNU gunzip - "real" bunzip2 tries to */
|
|
|
|
/* unpack file anyway, to file.out */
|
2007-03-08 03:32:23 +05:30
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
*extension = '\0';
|
|
|
|
return filename;
|
|
|
|
}
|
2007-03-11 16:26:37 +05:30
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2010-05-30 07:16:54 +05:30
|
|
|
* Uncompress applet for busybox (c) 2002 Glenn McGrath
|
2007-03-11 16:26:37 +05:30
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2007-03-11 16:26:37 +05:30
|
|
|
*/
|
2011-03-28 02:10:30 +05:30
|
|
|
//usage:#define uncompress_trivial_usage
|
|
|
|
//usage: "[-cf] [FILE]..."
|
|
|
|
//usage:#define uncompress_full_usage "\n\n"
|
|
|
|
//usage: "Decompress .Z file[s]\n"
|
|
|
|
//usage: "\n -c Write to stdout"
|
|
|
|
//usage: "\n -f Overwrite"
|
|
|
|
|
2013-11-14 16:09:00 +05:30
|
|
|
//config:config UNCOMPRESS
|
2017-07-19 01:31:24 +05:30
|
|
|
//config: bool "uncompress (7.1 kb)"
|
2015-10-26 01:06:03 +05:30
|
|
|
//config: default n # ancient
|
2013-11-14 16:09:00 +05:30
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: uncompress is used to decompress archives created by compress.
|
|
|
|
//config: Not much used anymore, replaced by gzip/gunzip.
|
2013-11-14 16:09:00 +05:30
|
|
|
|
2013-11-14 14:24:24 +05:30
|
|
|
//applet:IF_UNCOMPRESS(APPLET(uncompress, BB_DIR_BIN, BB_SUID_DROP))
|
2013-11-14 14:23:52 +05:30
|
|
|
//kbuild:lib-$(CONFIG_UNCOMPRESS) += bbunzip.o
|
2010-05-30 07:16:54 +05:30
|
|
|
#if ENABLE_UNCOMPRESS
|
|
|
|
int uncompress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
|
|
|
int uncompress_main(int argc UNUSED_PARAM, char **argv)
|
2007-03-08 03:32:23 +05:30
|
|
|
{
|
2017-06-15 21:37:04 +05:30
|
|
|
// (N)compress 4.2.4.4:
|
|
|
|
// -d If given, decompression is done instead
|
|
|
|
// -c Write output on stdout, don't remove original
|
|
|
|
// -b Parameter limits the max number of bits/code
|
|
|
|
// -f Forces output file to be generated
|
|
|
|
// -v Write compression statistics
|
|
|
|
// -V Output vesion and compile options
|
|
|
|
// -r Recursive. If a filename is a directory, descend into it and compress everything
|
2010-05-30 07:16:54 +05:30
|
|
|
getopt32(argv, "cf");
|
2017-06-15 21:37:04 +05:30
|
|
|
|
2007-03-08 03:32:23 +05:30
|
|
|
argv += optind;
|
|
|
|
|
2014-12-07 05:14:00 +05:30
|
|
|
return bbunpack(argv, unpack_Z_stream, make_new_name_generic, "Z");
|
2007-03-08 03:32:23 +05:30
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Gzip implementation for busybox
|
|
|
|
*
|
|
|
|
* Based on GNU gzip v1.2.4 Copyright (C) 1992-1993 Jean-loup Gailly.
|
|
|
|
*
|
|
|
|
* Originally adjusted for busybox by Sven Rudolph <sr1@inf.tu-dresden.de>
|
|
|
|
* based on gzip sources
|
|
|
|
*
|
|
|
|
* Adjusted further by Erik Andersen <andersen@codepoet.org> to support files as
|
|
|
|
* well as stdin/stdout, and to generally behave itself wrt command line
|
|
|
|
* handling.
|
|
|
|
*
|
|
|
|
* General cleanup to better adhere to the style guide and make use of standard
|
2007-09-21 18:46:32 +05:30
|
|
|
* busybox functions by Glenn McGrath
|
2007-03-08 03:32:23 +05:30
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2007-03-08 03:32:23 +05:30
|
|
|
*
|
|
|
|
* gzip (GNU zip) -- compress files with zip algorithm and 'compress' interface
|
|
|
|
* Copyright (C) 1992-1993 Jean-loup Gailly
|
|
|
|
* The unzip code was written and put in the public domain by Mark Adler.
|
|
|
|
* Portions of the lzw code are derived from the public domain 'compress'
|
|
|
|
* written by Spencer Thomas, Joe Orost, James Woods, Jim McKie, Steve Davies,
|
|
|
|
* Ken Turkowski, Dave Mack and Peter Jannesen.
|
|
|
|
*/
|
2011-03-28 02:10:30 +05:30
|
|
|
//usage:#define gunzip_trivial_usage
|
2017-06-15 21:37:04 +05:30
|
|
|
//usage: "[-cfkt] [FILE]..."
|
2011-03-28 02:10:30 +05:30
|
|
|
//usage:#define gunzip_full_usage "\n\n"
|
|
|
|
//usage: "Decompress FILEs (or stdin)\n"
|
|
|
|
//usage: "\n -c Write to stdout"
|
|
|
|
//usage: "\n -f Force"
|
2017-06-15 21:37:04 +05:30
|
|
|
//usage: "\n -k Keep input files"
|
2011-03-28 02:10:30 +05:30
|
|
|
//usage: "\n -t Test file integrity"
|
|
|
|
//usage:
|
|
|
|
//usage:#define gunzip_example_usage
|
|
|
|
//usage: "$ ls -la /tmp/BusyBox*\n"
|
|
|
|
//usage: "-rw-rw-r-- 1 andersen andersen 557009 Apr 11 10:55 /tmp/BusyBox-0.43.tar.gz\n"
|
|
|
|
//usage: "$ gunzip /tmp/BusyBox-0.43.tar.gz\n"
|
|
|
|
//usage: "$ ls -la /tmp/BusyBox*\n"
|
|
|
|
//usage: "-rw-rw-r-- 1 andersen andersen 1761280 Apr 14 17:47 /tmp/BusyBox-0.43.tar\n"
|
|
|
|
//usage:
|
|
|
|
//usage:#define zcat_trivial_usage
|
2013-02-28 22:34:22 +05:30
|
|
|
//usage: "[FILE]..."
|
2011-03-28 02:10:30 +05:30
|
|
|
//usage:#define zcat_full_usage "\n\n"
|
|
|
|
//usage: "Decompress to stdout"
|
|
|
|
|
2013-11-14 16:09:00 +05:30
|
|
|
//config:config GUNZIP
|
2018-12-28 07:50:17 +05:30
|
|
|
//config: bool "gunzip (11 kb)"
|
2013-11-14 16:09:00 +05:30
|
|
|
//config: default y
|
2017-01-08 11:58:34 +05:30
|
|
|
//config: select FEATURE_GZIP_DECOMPRESS
|
2013-11-14 16:09:00 +05:30
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: gunzip is used to decompress archives created by gzip.
|
2017-08-02 17:42:48 +05:30
|
|
|
//config: You can use the '-t' option to test the integrity of
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: an archive, without decompressing it.
|
2015-10-27 03:12:32 +05:30
|
|
|
//config:
|
2016-11-16 20:15:05 +05:30
|
|
|
//config:config ZCAT
|
2018-12-28 07:50:17 +05:30
|
|
|
//config: bool "zcat (24 kb)"
|
2016-11-16 20:15:05 +05:30
|
|
|
//config: default y
|
2017-01-08 11:58:34 +05:30
|
|
|
//config: select FEATURE_GZIP_DECOMPRESS
|
2016-11-16 20:15:05 +05:30
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: Alias to "gunzip -c".
|
2016-11-16 20:15:05 +05:30
|
|
|
//config:
|
2015-10-27 03:12:32 +05:30
|
|
|
//config:config FEATURE_GUNZIP_LONG_OPTIONS
|
|
|
|
//config: bool "Enable long options"
|
|
|
|
//config: default y
|
2016-11-16 20:15:05 +05:30
|
|
|
//config: depends on (GUNZIP || ZCAT) && LONG_OPTS
|
2013-11-14 16:09:00 +05:30
|
|
|
|
2013-11-14 14:24:24 +05:30
|
|
|
//applet:IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP))
|
2017-01-29 19:27:33 +05:30
|
|
|
// APPLET_ODDNAME:name main location suid_type help
|
2016-11-16 20:15:05 +05:30
|
|
|
//applet:IF_ZCAT(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat))
|
2017-01-08 11:58:34 +05:30
|
|
|
#if ENABLE_FEATURE_GZIP_DECOMPRESS
|
2007-03-08 03:32:23 +05:30
|
|
|
static
|
2010-05-31 17:48:57 +05:30
|
|
|
char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM)
|
2007-03-08 03:32:23 +05:30
|
|
|
{
|
|
|
|
char *extension = strrchr(filename, '.');
|
|
|
|
|
|
|
|
if (!extension)
|
|
|
|
return NULL;
|
|
|
|
|
2007-03-10 02:19:55 +05:30
|
|
|
extension++;
|
|
|
|
if (strcmp(extension, "tgz" + 1) == 0
|
2008-08-05 18:40:34 +05:30
|
|
|
#if ENABLE_FEATURE_SEAMLESS_Z
|
|
|
|
|| (extension[0] == 'Z' && extension[1] == '\0')
|
2007-03-08 03:32:23 +05:30
|
|
|
#endif
|
|
|
|
) {
|
2007-03-10 02:19:55 +05:30
|
|
|
extension[-1] = '\0';
|
2007-04-12 06:02:05 +05:30
|
|
|
} else if (strcmp(extension, "tgz") == 0) {
|
2007-03-08 03:32:23 +05:30
|
|
|
filename = xstrdup(filename);
|
|
|
|
extension = strrchr(filename, '.');
|
|
|
|
extension[2] = 'a';
|
|
|
|
extension[3] = 'r';
|
|
|
|
} else {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return filename;
|
|
|
|
}
|
2015-10-27 03:12:32 +05:30
|
|
|
|
|
|
|
#if ENABLE_FEATURE_GUNZIP_LONG_OPTIONS
|
|
|
|
static const char gunzip_longopts[] ALIGN1 =
|
|
|
|
"stdout\0" No_argument "c"
|
|
|
|
"to-stdout\0" No_argument "c"
|
|
|
|
"force\0" No_argument "f"
|
|
|
|
"test\0" No_argument "t"
|
2015-10-27 03:12:33 +05:30
|
|
|
"no-name\0" No_argument "n"
|
2015-10-27 03:12:32 +05:30
|
|
|
;
|
|
|
|
#endif
|
|
|
|
|
2008-03-30 18:41:47 +05:30
|
|
|
/*
|
|
|
|
* Linux kernel build uses gzip -d -n. We accept and ignore it.
|
|
|
|
* Man page says:
|
|
|
|
* -n --no-name
|
|
|
|
* gzip: do not save the original file name and time stamp.
|
|
|
|
* (The original name is always saved if the name had to be truncated.)
|
|
|
|
* gunzip: do not restore the original file name/time even if present
|
|
|
|
* (remove only the gzip suffix from the compressed file name).
|
|
|
|
* This option is the default when decompressing.
|
|
|
|
* -N --name
|
|
|
|
* gzip: always save the original file name and time stamp (this is the default)
|
|
|
|
* gunzip: restore the original file name and time stamp if present.
|
|
|
|
*/
|
2007-10-11 15:35:36 +05:30
|
|
|
int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2008-07-05 14:48:54 +05:30
|
|
|
int gunzip_main(int argc UNUSED_PARAM, char **argv)
|
2007-03-08 03:32:23 +05:30
|
|
|
{
|
2015-10-27 03:12:32 +05:30
|
|
|
#if ENABLE_FEATURE_GUNZIP_LONG_OPTIONS
|
2018-02-01 13:43:14 +05:30
|
|
|
getopt32long(argv, BBUNPK_OPTSTR "dtn", gunzip_longopts);
|
getopt32: remove applet_long_options
FEATURE_GETOPT_LONG made dependent on LONG_OPTS.
The folloving options are removed, now LONG_OPTS enables long options
for affected applets:
FEATURE_ENV_LONG_OPTIONS FEATURE_EXPAND_LONG_OPTIONS
FEATURE_UNEXPAND_LONG_OPTIONS FEATURE_MKDIR_LONG_OPTIONS
FEATURE_MV_LONG_OPTIONS FEATURE_RMDIR_LONG_OPTIONS
FEATURE_ADDGROUP_LONG_OPTIONS FEATURE_ADDUSER_LONG_OPTIONS
FEATURE_HWCLOCK_LONG_OPTIONS FEATURE_NSENTER_LONG_OPTS
FEATURE_CHCON_LONG_OPTIONS FEATURE_RUNCON_LONG_OPTIONS
They either had a small number of long options, or their long options are
essential.
Example: upstream addgroup and adduser have ONLY longopts,
we should probably go further and get rid
of non-standard short options.
To this end, make addgroup and adduser "select LONG_OPTS".
We had this breakage caused by us even in our own package!
#if ENABLE_LONG_OPTS || !ENABLE_ADDGROUP
/* We try to use --gid, not -g, because "standard" addgroup
* has no short option -g, it has only long --gid.
*/
argv[1] = (char*)"--gid";
#else
/* Breaks if system in fact does NOT use busybox addgroup */
argv[1] = (char*)"-g";
#endif
xargs: its lone longopt no longer depends on DESKTOP, only on LONG_OPTS.
hwclock TODO: get rid of incompatible -t, -l aliases to --systz, --localtime
Shorten help texts by omitting long option when short opt alternative exists.
Reduction of size comes from the fact that store of an immediate
(an address of longopts) to a fixed address (global variable)
is a longer insn than pushing that immediate or passing it in a register.
This effect is CPU-agnostic.
function old new delta
getopt32 1350 22 -1328
vgetopt32 - 1318 +1318
getopt32long - 24 +24
tftpd_main 562 567 +5
scan_recursive 376 380 +4
collect_cpu 545 546 +1
date_main 1096 1095 -1
hostname_main 262 259 -3
uname_main 259 255 -4
setpriv_main 362 358 -4
rmdir_main 191 187 -4
mv_main 562 558 -4
ipcalc_main 548 544 -4
ifenslave_main 641 637 -4
gzip_main 192 188 -4
gunzip_main 77 73 -4
fsfreeze_main 81 77 -4
flock_main 318 314 -4
deluser_main 337 333 -4
cp_main 374 370 -4
chown_main 175 171 -4
applet_long_options 4 - -4
xargs_main 894 889 -5
wget_main 2540 2535 -5
udhcpc_main 2767 2762 -5
touch_main 436 431 -5
tar_main 1014 1009 -5
start_stop_daemon_main 1033 1028 -5
sed_main 682 677 -5
script_main 1082 1077 -5
run_parts_main 330 325 -5
rtcwake_main 459 454 -5
od_main 2169 2164 -5
nl_main 201 196 -5
modprobe_main 773 768 -5
mkdir_main 160 155 -5
ls_main 568 563 -5
install_main 773 768 -5
hwclock_main 411 406 -5
getopt_main 622 617 -5
fstrim_main 256 251 -5
env_main 198 193 -5
dumpleases_main 635 630 -5
dpkg_main 3991 3986 -5
diff_main 1355 1350 -5
cryptpw_main 233 228 -5
cpio_main 593 588 -5
conspy_main 1135 1130 -5
chpasswd_main 313 308 -5
adduser_main 887 882 -5
addgroup_main 416 411 -5
ftpgetput_main 351 345 -6
get_terminal_width_height 242 234 -8
expand_main 690 680 -10
static.expand_longopts 18 - -18
static.unexpand_longopts 27 - -27
mkdir_longopts 28 - -28
env_longopts 30 - -30
static.ifenslave_longopts 34 - -34
mv_longopts 46 - -46
static.rmdir_longopts 48 - -48
packed_usage 31739 31687 -52
------------------------------------------------------------------------------
(add/remove: 2/8 grow/shrink: 3/49 up/down: 1352/-1840) Total: -488 bytes
text data bss dec hex filename
915681 485 6880 923046 e15a6 busybox_old
915428 485 6876 922789 e14a5 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-08 20:08:18 +05:30
|
|
|
#else
|
2018-02-01 13:43:14 +05:30
|
|
|
getopt32(argv, BBUNPK_OPTSTR "dtn");
|
getopt32: remove applet_long_options
FEATURE_GETOPT_LONG made dependent on LONG_OPTS.
The folloving options are removed, now LONG_OPTS enables long options
for affected applets:
FEATURE_ENV_LONG_OPTIONS FEATURE_EXPAND_LONG_OPTIONS
FEATURE_UNEXPAND_LONG_OPTIONS FEATURE_MKDIR_LONG_OPTIONS
FEATURE_MV_LONG_OPTIONS FEATURE_RMDIR_LONG_OPTIONS
FEATURE_ADDGROUP_LONG_OPTIONS FEATURE_ADDUSER_LONG_OPTIONS
FEATURE_HWCLOCK_LONG_OPTIONS FEATURE_NSENTER_LONG_OPTS
FEATURE_CHCON_LONG_OPTIONS FEATURE_RUNCON_LONG_OPTIONS
They either had a small number of long options, or their long options are
essential.
Example: upstream addgroup and adduser have ONLY longopts,
we should probably go further and get rid
of non-standard short options.
To this end, make addgroup and adduser "select LONG_OPTS".
We had this breakage caused by us even in our own package!
#if ENABLE_LONG_OPTS || !ENABLE_ADDGROUP
/* We try to use --gid, not -g, because "standard" addgroup
* has no short option -g, it has only long --gid.
*/
argv[1] = (char*)"--gid";
#else
/* Breaks if system in fact does NOT use busybox addgroup */
argv[1] = (char*)"-g";
#endif
xargs: its lone longopt no longer depends on DESKTOP, only on LONG_OPTS.
hwclock TODO: get rid of incompatible -t, -l aliases to --systz, --localtime
Shorten help texts by omitting long option when short opt alternative exists.
Reduction of size comes from the fact that store of an immediate
(an address of longopts) to a fixed address (global variable)
is a longer insn than pushing that immediate or passing it in a register.
This effect is CPU-agnostic.
function old new delta
getopt32 1350 22 -1328
vgetopt32 - 1318 +1318
getopt32long - 24 +24
tftpd_main 562 567 +5
scan_recursive 376 380 +4
collect_cpu 545 546 +1
date_main 1096 1095 -1
hostname_main 262 259 -3
uname_main 259 255 -4
setpriv_main 362 358 -4
rmdir_main 191 187 -4
mv_main 562 558 -4
ipcalc_main 548 544 -4
ifenslave_main 641 637 -4
gzip_main 192 188 -4
gunzip_main 77 73 -4
fsfreeze_main 81 77 -4
flock_main 318 314 -4
deluser_main 337 333 -4
cp_main 374 370 -4
chown_main 175 171 -4
applet_long_options 4 - -4
xargs_main 894 889 -5
wget_main 2540 2535 -5
udhcpc_main 2767 2762 -5
touch_main 436 431 -5
tar_main 1014 1009 -5
start_stop_daemon_main 1033 1028 -5
sed_main 682 677 -5
script_main 1082 1077 -5
run_parts_main 330 325 -5
rtcwake_main 459 454 -5
od_main 2169 2164 -5
nl_main 201 196 -5
modprobe_main 773 768 -5
mkdir_main 160 155 -5
ls_main 568 563 -5
install_main 773 768 -5
hwclock_main 411 406 -5
getopt_main 622 617 -5
fstrim_main 256 251 -5
env_main 198 193 -5
dumpleases_main 635 630 -5
dpkg_main 3991 3986 -5
diff_main 1355 1350 -5
cryptpw_main 233 228 -5
cpio_main 593 588 -5
conspy_main 1135 1130 -5
chpasswd_main 313 308 -5
adduser_main 887 882 -5
addgroup_main 416 411 -5
ftpgetput_main 351 345 -6
get_terminal_width_height 242 234 -8
expand_main 690 680 -10
static.expand_longopts 18 - -18
static.unexpand_longopts 27 - -27
mkdir_longopts 28 - -28
env_longopts 30 - -30
static.ifenslave_longopts 34 - -34
mv_longopts 46 - -46
static.rmdir_longopts 48 - -48
packed_usage 31739 31687 -52
------------------------------------------------------------------------------
(add/remove: 2/8 grow/shrink: 3/49 up/down: 1352/-1840) Total: -488 bytes
text data bss dec hex filename
915681 485 6880 923046 e15a6 busybox_old
915428 485 6876 922789 e14a5 busybox_unstripped
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2017-08-08 20:08:18 +05:30
|
|
|
#endif
|
2007-03-08 03:32:23 +05:30
|
|
|
argv += optind;
|
2013-02-28 22:36:09 +05:30
|
|
|
|
|
|
|
/* If called as zcat...
|
|
|
|
* Normally, "zcat" is just "gunzip -c".
|
|
|
|
* But if seamless magic is enabled, then we are much more clever.
|
|
|
|
*/
|
2017-07-20 19:55:03 +05:30
|
|
|
if (ENABLE_ZCAT && (!ENABLE_GUNZIP || applet_name[1] == 'c'))
|
2018-02-01 13:43:14 +05:30
|
|
|
option_mask32 |= BBUNPK_OPT_STDOUT | BBUNPK_SEAMLESS_MAGIC;
|
2007-03-08 03:32:23 +05:30
|
|
|
|
2014-12-07 05:14:00 +05:30
|
|
|
return bbunpack(argv, unpack_gz_stream, make_new_name_gunzip, /*unused:*/ NULL);
|
2007-03-08 03:32:23 +05:30
|
|
|
}
|
2017-01-08 11:58:34 +05:30
|
|
|
#endif /* FEATURE_GZIP_DECOMPRESS */
|
2010-05-30 07:16:54 +05:30
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Modified for busybox by Glenn McGrath
|
|
|
|
* Added support output to stdout by Thomas Lundquist <thomasez@zelow.no>
|
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
2010-05-30 07:16:54 +05:30
|
|
|
*/
|
2010-06-06 05:23:38 +05:30
|
|
|
//usage:#define bunzip2_trivial_usage
|
2017-06-15 21:37:04 +05:30
|
|
|
//usage: "[-cfk] [FILE]..."
|
2010-06-06 05:23:38 +05:30
|
|
|
//usage:#define bunzip2_full_usage "\n\n"
|
|
|
|
//usage: "Decompress FILEs (or stdin)\n"
|
|
|
|
//usage: "\n -c Write to stdout"
|
|
|
|
//usage: "\n -f Force"
|
2017-06-15 21:37:04 +05:30
|
|
|
//usage: "\n -k Keep input files"
|
2010-06-06 05:23:38 +05:30
|
|
|
//usage:#define bzcat_trivial_usage
|
2013-02-28 22:34:22 +05:30
|
|
|
//usage: "[FILE]..."
|
2010-06-06 05:23:38 +05:30
|
|
|
//usage:#define bzcat_full_usage "\n\n"
|
|
|
|
//usage: "Decompress to stdout"
|
2013-11-14 14:23:52 +05:30
|
|
|
|
2013-11-14 16:09:00 +05:30
|
|
|
//config:config BUNZIP2
|
2018-12-28 07:50:17 +05:30
|
|
|
//config: bool "bunzip2 (8.7 kb)"
|
2013-11-14 16:09:00 +05:30
|
|
|
//config: default y
|
2017-01-08 11:58:34 +05:30
|
|
|
//config: select FEATURE_BZIP2_DECOMPRESS
|
2013-11-14 16:09:00 +05:30
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: bunzip2 is a compression utility using the Burrows-Wheeler block
|
|
|
|
//config: sorting text compression algorithm, and Huffman coding. Compression
|
|
|
|
//config: is generally considerably better than that achieved by more
|
|
|
|
//config: conventional LZ77/LZ78-based compressors, and approaches the
|
|
|
|
//config: performance of the PPM family of statistical compressors.
|
2013-11-14 16:09:00 +05:30
|
|
|
//config:
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: Unless you have a specific application which requires bunzip2, you
|
|
|
|
//config: should probably say N here.
|
2016-11-16 20:15:05 +05:30
|
|
|
//config:
|
|
|
|
//config:config BZCAT
|
2018-12-28 07:50:17 +05:30
|
|
|
//config: bool "bzcat (8.7 kb)"
|
2016-11-16 20:15:05 +05:30
|
|
|
//config: default y
|
2017-01-08 11:58:34 +05:30
|
|
|
//config: select FEATURE_BZIP2_DECOMPRESS
|
2016-11-16 20:15:05 +05:30
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: Alias to "bunzip2 -c".
|
2013-11-14 16:09:00 +05:30
|
|
|
|
2011-01-18 18:28:01 +05:30
|
|
|
//applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
|
2017-01-29 19:27:33 +05:30
|
|
|
// APPLET_ODDNAME:name main location suid_type help
|
2016-11-16 20:15:05 +05:30
|
|
|
//applet:IF_BZCAT(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat))
|
2017-07-04 19:53:36 +05:30
|
|
|
#if ENABLE_FEATURE_BZIP2_DECOMPRESS || ENABLE_BUNZIP2 || ENABLE_BZCAT
|
2010-05-30 07:16:54 +05:30
|
|
|
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
|
|
|
int bunzip2_main(int argc UNUSED_PARAM, char **argv)
|
|
|
|
{
|
2018-02-01 13:43:14 +05:30
|
|
|
getopt32(argv, BBUNPK_OPTSTR "dt");
|
2010-05-30 07:16:54 +05:30
|
|
|
argv += optind;
|
2017-07-20 19:55:03 +05:30
|
|
|
if (ENABLE_BZCAT && (!ENABLE_BUNZIP2 || applet_name[2] == 'c')) /* bzcat */
|
2018-02-01 13:43:14 +05:30
|
|
|
option_mask32 |= BBUNPK_OPT_STDOUT;
|
2007-03-08 03:32:23 +05:30
|
|
|
|
2014-12-07 05:14:00 +05:30
|
|
|
return bbunpack(argv, unpack_bz2_stream, make_new_name_generic, "bz2");
|
2010-05-30 07:16:54 +05:30
|
|
|
}
|
2007-03-08 03:32:23 +05:30
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Small lzma deflate implementation.
|
|
|
|
* Copyright (C) 2006 Aurelien Jacobs <aurel@gnuage.org>
|
|
|
|
*
|
|
|
|
* Based on bunzip.c from busybox
|
|
|
|
*
|
2010-08-16 23:44:46 +05:30
|
|
|
* Licensed under GPLv2, see file LICENSE in this source tree.
|
2007-03-08 03:32:23 +05:30
|
|
|
*/
|
2011-03-28 02:10:30 +05:30
|
|
|
//usage:#define unlzma_trivial_usage
|
2017-06-15 21:37:04 +05:30
|
|
|
//usage: "[-cfk] [FILE]..."
|
2011-03-28 02:10:30 +05:30
|
|
|
//usage:#define unlzma_full_usage "\n\n"
|
|
|
|
//usage: "Decompress FILE (or stdin)\n"
|
|
|
|
//usage: "\n -c Write to stdout"
|
|
|
|
//usage: "\n -f Force"
|
2017-06-15 21:37:04 +05:30
|
|
|
//usage: "\n -k Keep input files"
|
2011-03-28 02:10:30 +05:30
|
|
|
//usage:
|
|
|
|
//usage:#define lzma_trivial_usage
|
2017-06-15 21:37:04 +05:30
|
|
|
//usage: "-d [-cfk] [FILE]..."
|
2011-03-28 02:10:30 +05:30
|
|
|
//usage:#define lzma_full_usage "\n\n"
|
|
|
|
//usage: "Decompress FILE (or stdin)\n"
|
|
|
|
//usage: "\n -d Decompress"
|
|
|
|
//usage: "\n -c Write to stdout"
|
|
|
|
//usage: "\n -f Force"
|
2017-06-15 21:37:04 +05:30
|
|
|
//usage: "\n -k Keep input files"
|
2011-03-28 02:10:30 +05:30
|
|
|
//usage:
|
|
|
|
//usage:#define lzcat_trivial_usage
|
2013-02-28 22:34:22 +05:30
|
|
|
//usage: "[FILE]..."
|
2011-03-28 02:10:30 +05:30
|
|
|
//usage:#define lzcat_full_usage "\n\n"
|
|
|
|
//usage: "Decompress to stdout"
|
|
|
|
|
2013-11-14 16:09:00 +05:30
|
|
|
//config:config UNLZMA
|
2018-12-28 07:50:17 +05:30
|
|
|
//config: bool "unlzma (7.5 kb)"
|
2013-11-14 16:09:00 +05:30
|
|
|
//config: default y
|
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: unlzma is a compression utility using the Lempel-Ziv-Markov chain
|
|
|
|
//config: compression algorithm, and range coding. Compression
|
|
|
|
//config: is generally considerably better than that achieved by the bzip2
|
|
|
|
//config: compressors.
|
2013-11-14 16:09:00 +05:30
|
|
|
//config:
|
2016-11-16 20:15:05 +05:30
|
|
|
//config:config LZCAT
|
2018-12-28 07:50:17 +05:30
|
|
|
//config: bool "lzcat (7.5 kb)"
|
2016-11-16 20:15:05 +05:30
|
|
|
//config: default y
|
2013-11-14 16:09:00 +05:30
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: Alias to "unlzma -c".
|
2013-11-14 16:09:00 +05:30
|
|
|
//config:
|
|
|
|
//config:config LZMA
|
2016-11-16 20:15:05 +05:30
|
|
|
//config: bool "lzma -d"
|
2013-11-14 16:09:00 +05:30
|
|
|
//config: default y
|
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: Enable this option if you want commands like "lzma -d" to work.
|
|
|
|
//config: IOW: you'll get lzma applet, but it will always require -d option.
|
2013-11-14 16:09:00 +05:30
|
|
|
|
2013-11-14 14:24:24 +05:30
|
|
|
//applet:IF_UNLZMA(APPLET(unlzma, BB_DIR_USR_BIN, BB_SUID_DROP))
|
2017-01-29 19:27:33 +05:30
|
|
|
// APPLET_ODDNAME:name main location suid_type help
|
2016-11-16 20:15:05 +05:30
|
|
|
//applet:IF_LZCAT(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat))
|
2017-01-29 19:27:33 +05:30
|
|
|
//applet:IF_LZMA( APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma))
|
2013-11-14 14:23:52 +05:30
|
|
|
//kbuild:lib-$(CONFIG_UNLZMA) += bbunzip.o
|
2016-11-16 20:15:05 +05:30
|
|
|
//kbuild:lib-$(CONFIG_LZCAT) += bbunzip.o
|
|
|
|
//kbuild:lib-$(CONFIG_LZMA) += bbunzip.o
|
|
|
|
#if ENABLE_UNLZMA || ENABLE_LZCAT || ENABLE_LZMA
|
2007-10-11 15:35:36 +05:30
|
|
|
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
2008-07-05 14:48:54 +05:30
|
|
|
int unlzma_main(int argc UNUSED_PARAM, char **argv)
|
2007-03-08 03:32:23 +05:30
|
|
|
{
|
2018-02-01 13:43:14 +05:30
|
|
|
IF_LZMA(int opts =) getopt32(argv, BBUNPK_OPTSTR "dt");
|
2010-05-30 07:03:50 +05:30
|
|
|
# if ENABLE_LZMA
|
2010-05-27 05:52:54 +05:30
|
|
|
/* lzma without -d or -t? */
|
2018-02-01 13:43:14 +05:30
|
|
|
if (applet_name[2] == 'm' && !(opts & (BBUNPK_OPT_DECOMPRESS|BBUNPK_OPT_TEST)))
|
2010-05-27 05:52:54 +05:30
|
|
|
bb_show_usage();
|
|
|
|
# endif
|
|
|
|
/* lzcat? */
|
2016-11-16 20:15:05 +05:30
|
|
|
if (ENABLE_LZCAT && applet_name[2] == 'c')
|
2018-02-01 13:43:14 +05:30
|
|
|
option_mask32 |= BBUNPK_OPT_STDOUT;
|
2007-03-08 03:32:23 +05:30
|
|
|
|
2010-05-27 05:52:54 +05:30
|
|
|
argv += optind;
|
2014-12-07 05:14:00 +05:30
|
|
|
return bbunpack(argv, unpack_lzma_stream, make_new_name_generic, "lzma");
|
2007-03-08 03:32:23 +05:30
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2017-01-29 19:27:33 +05:30
|
|
|
//usage:#define unxz_trivial_usage
|
2017-06-15 21:37:04 +05:30
|
|
|
//usage: "[-cfk] [FILE]..."
|
2017-01-29 19:27:33 +05:30
|
|
|
//usage:#define unxz_full_usage "\n\n"
|
|
|
|
//usage: "Decompress FILE (or stdin)\n"
|
|
|
|
//usage: "\n -c Write to stdout"
|
|
|
|
//usage: "\n -f Force"
|
2017-06-15 21:37:04 +05:30
|
|
|
//usage: "\n -k Keep input files"
|
2017-01-29 19:27:33 +05:30
|
|
|
//usage:
|
|
|
|
//usage:#define xz_trivial_usage
|
2017-06-15 21:37:04 +05:30
|
|
|
//usage: "-d [-cfk] [FILE]..."
|
2017-01-29 19:27:33 +05:30
|
|
|
//usage:#define xz_full_usage "\n\n"
|
|
|
|
//usage: "Decompress FILE (or stdin)\n"
|
|
|
|
//usage: "\n -d Decompress"
|
|
|
|
//usage: "\n -c Write to stdout"
|
|
|
|
//usage: "\n -f Force"
|
2017-06-15 21:37:04 +05:30
|
|
|
//usage: "\n -k Keep input files"
|
2017-01-29 19:27:33 +05:30
|
|
|
//usage:
|
|
|
|
//usage:#define xzcat_trivial_usage
|
|
|
|
//usage: "[FILE]..."
|
|
|
|
//usage:#define xzcat_full_usage "\n\n"
|
|
|
|
//usage: "Decompress to stdout"
|
|
|
|
|
2013-11-14 16:09:00 +05:30
|
|
|
//config:config UNXZ
|
2017-07-19 01:31:24 +05:30
|
|
|
//config: bool "unxz (13 kb)"
|
2013-11-14 16:09:00 +05:30
|
|
|
//config: default y
|
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: unxz is a unlzma successor.
|
2013-11-14 16:09:00 +05:30
|
|
|
//config:
|
2016-11-16 20:15:05 +05:30
|
|
|
//config:config XZCAT
|
2017-07-19 01:31:24 +05:30
|
|
|
//config: bool "xzcat (13 kb)"
|
2016-11-16 20:15:05 +05:30
|
|
|
//config: default y
|
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: Alias to "unxz -c".
|
2016-11-16 20:15:05 +05:30
|
|
|
//config:
|
2013-11-14 16:09:00 +05:30
|
|
|
//config:config XZ
|
2016-11-16 20:15:05 +05:30
|
|
|
//config: bool "xz -d"
|
2013-11-14 16:09:00 +05:30
|
|
|
//config: default y
|
|
|
|
//config: help
|
2017-07-21 13:20:55 +05:30
|
|
|
//config: Enable this option if you want commands like "xz -d" to work.
|
|
|
|
//config: IOW: you'll get xz applet, but it will always require -d option.
|
2013-11-14 16:09:00 +05:30
|
|
|
|
2013-11-14 14:24:24 +05:30
|
|
|
//applet:IF_UNXZ(APPLET(unxz, BB_DIR_USR_BIN, BB_SUID_DROP))
|
2017-01-29 19:27:33 +05:30
|
|
|
// APPLET_ODDNAME:name main location suid_type help
|
2016-11-16 20:15:05 +05:30
|
|
|
//applet:IF_XZCAT(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat))
|
2017-01-29 19:27:33 +05:30
|
|
|
//applet:IF_XZ( APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz))
|
2013-11-14 14:23:52 +05:30
|
|
|
//kbuild:lib-$(CONFIG_UNXZ) += bbunzip.o
|
2016-11-16 20:15:05 +05:30
|
|
|
//kbuild:lib-$(CONFIG_XZCAT) += bbunzip.o
|
|
|
|
//kbuild:lib-$(CONFIG_XZ) += bbunzip.o
|
|
|
|
#if ENABLE_UNXZ || ENABLE_XZCAT || ENABLE_XZ
|
2010-05-30 07:05:18 +05:30
|
|
|
int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
|
|
|
|
int unxz_main(int argc UNUSED_PARAM, char **argv)
|
|
|
|
{
|
2018-02-01 13:43:14 +05:30
|
|
|
IF_XZ(int opts =) getopt32(argv, BBUNPK_OPTSTR "dt");
|
2010-05-30 07:05:18 +05:30
|
|
|
# if ENABLE_XZ
|
|
|
|
/* xz without -d or -t? */
|
2018-02-01 13:43:14 +05:30
|
|
|
if (applet_name[2] == '\0' && !(opts & (BBUNPK_OPT_DECOMPRESS|BBUNPK_OPT_TEST)))
|
2010-05-30 07:05:18 +05:30
|
|
|
bb_show_usage();
|
|
|
|
# endif
|
|
|
|
/* xzcat? */
|
2016-11-16 20:15:05 +05:30
|
|
|
if (ENABLE_XZCAT && applet_name[2] == 'c')
|
2018-02-01 13:43:14 +05:30
|
|
|
option_mask32 |= BBUNPK_OPT_STDOUT;
|
2010-05-30 07:05:18 +05:30
|
|
|
|
|
|
|
argv += optind;
|
2014-12-07 05:14:00 +05:30
|
|
|
return bbunpack(argv, unpack_xz_stream, make_new_name_generic, "xz");
|
2010-05-30 07:05:18 +05:30
|
|
|
}
|
|
|
|
#endif
|