unlzma: add "lzma -d" alias, add -t support, rename lzmacat->lzcat

Also coalesce some common strings

   text    data     bss     dec     hex filename
 844110     453    6812  851375   cfdaf busybox_old
 844061     453    6812  851326   cfd7e busybox_unstripped

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko
2010-05-27 02:22:54 +02:00
parent c5f30c0df8
commit ccb88a689e
6 changed files with 59 additions and 36 deletions

View File

@@ -327,6 +327,14 @@ config FEATURE_LZMA_FAST
This option reduces decompression time by about 25% at the cost of
a 1K bigger binary.
config FEATURE_LZMA_ALIAS
bool "Provide lzma alias which supports only unpacking"
default n
depends on UNLZMA
help
Enable this option if you want commands like "lzma -d" to work.
IOW: you'll get lzma applet, but it will always require -d option.
config UNZIP
bool "unzip"
default n

View File

@@ -9,12 +9,12 @@
#include "unarchive.h"
enum {
OPT_STDOUT = 0x1,
OPT_FORCE = 0x2,
/* gunzip and bunzip2 only: */
OPT_VERBOSE = 0x4,
OPT_DECOMPRESS = 0x8,
OPT_TEST = 0x10,
OPT_STDOUT = 1 << 0,
OPT_FORCE = 1 << 1,
/* only some decompressors: */
OPT_VERBOSE = 1 << 2,
OPT_DECOMPRESS = 1 << 3,
OPT_TEST = 1 << 4,
};
static
@@ -333,12 +333,17 @@ IF_DESKTOP(long long) int unpack_unlzma(unpack_info_t *info UNUSED_PARAM)
int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int unlzma_main(int argc UNUSED_PARAM, char **argv)
{
getopt32(argv, "cf");
argv += optind;
/* lzmacat? */
if (applet_name[4] == 'c')
int opts = getopt32(argv, "cfvdt");
# if ENABLE_FEATURE_LZMA_ALIAS
/* lzma without -d or -t? */
if (applet_name[2] == 'm' && !(opts & (OPT_DECOMPRESS|OPT_TEST)))
bb_show_usage();
# endif
/* lzcat? */
if (applet_name[2] == 'c')
option_mask32 |= OPT_STDOUT;
argv += optind;
return bbunpack(argv, make_new_name_unlzma, unpack_unlzma);
}
@@ -346,7 +351,7 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv)
/*
* Uncompress applet for busybox (c) 2002 Glenn McGrath
* Uncompress applet for busybox (c) 2002 Glenn McGrath
*
* Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
*/

View File

@@ -229,7 +229,7 @@ unpack_Z_stream(int fd_in, int fd_out)
("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)",
insize, posbits, p[-1], p[0], p[1], p[2], p[3],
(posbits & 07));
bb_error_msg("uncompress: corrupt input");
bb_error_msg("corrupted data");
goto err;
}

View File

@@ -738,12 +738,12 @@ static NOINLINE smallint lzo_decompress(const header_t *h)
bb_error_msg_and_die("this file is a split lzop file");
if (dst_len > MAX_BLOCK_SIZE)
bb_error_msg_and_die("lzop file corrupted");
bb_error_msg_and_die("corrupted data");
/* read compressed block size */
src_len = read32();
if (src_len <= 0 || src_len > dst_len)
bb_error_msg_and_die("lzop file corrupted");
bb_error_msg_and_die("corrupted data");
if (dst_len > block_size) {
if (b2) {
@@ -797,7 +797,7 @@ static NOINLINE smallint lzo_decompress(const header_t *h)
r = lzo1x_decompress_safe(b1, src_len, b2, &d, NULL);
if (r != 0 /*LZO_E_OK*/ || dst_len != d) {
bb_error_msg_and_die("corrupted compressed data");
bb_error_msg_and_die("corrupted data");
}
dst = b2;
} else {