aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2010-05-27 02:22:54 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2010-05-27 02:22:54 +0200
commitccb88a689e0f603f8d94255a7d9cb8128b6e620d (patch)
treeebd35745219fbb246b605826a147e6ec031d891e
parentc5f30c0df8f0ce5e94ca22a5100496233067708a (diff)
downloadbusybox-w32-ccb88a689e0f603f8d94255a7d9cb8128b6e620d.tar.gz
busybox-w32-ccb88a689e0f603f8d94255a7d9cb8128b6e620d.tar.bz2
busybox-w32-ccb88a689e0f603f8d94255a7d9cb8128b6e620d.zip
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>
-rw-r--r--archival/Config.in8
-rw-r--r--archival/bbunzip.c27
-rw-r--r--archival/libunarchive/decompress_uncompress.c2
-rw-r--r--archival/lzop.c6
-rw-r--r--include/applets.h3
-rw-r--r--include/usage.h49
6 files changed, 59 insertions, 36 deletions
diff --git a/archival/Config.in b/archival/Config.in
index deacc2822..428398377 100644
--- a/archival/Config.in
+++ b/archival/Config.in
@@ -327,6 +327,14 @@ config FEATURE_LZMA_FAST
327 This option reduces decompression time by about 25% at the cost of 327 This option reduces decompression time by about 25% at the cost of
328 a 1K bigger binary. 328 a 1K bigger binary.
329 329
330config FEATURE_LZMA_ALIAS
331 bool "Provide lzma alias which supports only unpacking"
332 default n
333 depends on UNLZMA
334 help
335 Enable this option if you want commands like "lzma -d" to work.
336 IOW: you'll get lzma applet, but it will always require -d option.
337
330config UNZIP 338config UNZIP
331 bool "unzip" 339 bool "unzip"
332 default n 340 default n
diff --git a/archival/bbunzip.c b/archival/bbunzip.c
index df674bc6c..1e775f425 100644
--- a/archival/bbunzip.c
+++ b/archival/bbunzip.c
@@ -9,12 +9,12 @@
9#include "unarchive.h" 9#include "unarchive.h"
10 10
11enum { 11enum {
12 OPT_STDOUT = 0x1, 12 OPT_STDOUT = 1 << 0,
13 OPT_FORCE = 0x2, 13 OPT_FORCE = 1 << 1,
14/* gunzip and bunzip2 only: */ 14 /* only some decompressors: */
15 OPT_VERBOSE = 0x4, 15 OPT_VERBOSE = 1 << 2,
16 OPT_DECOMPRESS = 0x8, 16 OPT_DECOMPRESS = 1 << 3,
17 OPT_TEST = 0x10, 17 OPT_TEST = 1 << 4,
18}; 18};
19 19
20static 20static
@@ -333,12 +333,17 @@ IF_DESKTOP(long long) int unpack_unlzma(unpack_info_t *info UNUSED_PARAM)
333int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; 333int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
334int unlzma_main(int argc UNUSED_PARAM, char **argv) 334int unlzma_main(int argc UNUSED_PARAM, char **argv)
335{ 335{
336 getopt32(argv, "cf"); 336 int opts = getopt32(argv, "cfvdt");
337 argv += optind; 337# if ENABLE_FEATURE_LZMA_ALIAS
338 /* lzmacat? */ 338 /* lzma without -d or -t? */
339 if (applet_name[4] == 'c') 339 if (applet_name[2] == 'm' && !(opts & (OPT_DECOMPRESS|OPT_TEST)))
340 bb_show_usage();
341# endif
342 /* lzcat? */
343 if (applet_name[2] == 'c')
340 option_mask32 |= OPT_STDOUT; 344 option_mask32 |= OPT_STDOUT;
341 345
346 argv += optind;
342 return bbunpack(argv, make_new_name_unlzma, unpack_unlzma); 347 return bbunpack(argv, make_new_name_unlzma, unpack_unlzma);
343} 348}
344 349
@@ -346,7 +351,7 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv)
346 351
347 352
348/* 353/*
349 * Uncompress applet for busybox (c) 2002 Glenn McGrath 354 * Uncompress applet for busybox (c) 2002 Glenn McGrath
350 * 355 *
351 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. 356 * Licensed under GPLv2 or later, see file LICENSE in this tarball for details.
352 */ 357 */
diff --git a/archival/libunarchive/decompress_uncompress.c b/archival/libunarchive/decompress_uncompress.c
index 2877c8981..1ff89ce3c 100644
--- a/archival/libunarchive/decompress_uncompress.c
+++ b/archival/libunarchive/decompress_uncompress.c
@@ -229,7 +229,7 @@ unpack_Z_stream(int fd_in, int fd_out)
229 ("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)", 229 ("insize:%d posbits:%d inbuf:%02X %02X %02X %02X %02X (%d)",
230 insize, posbits, p[-1], p[0], p[1], p[2], p[3], 230 insize, posbits, p[-1], p[0], p[1], p[2], p[3],
231 (posbits & 07)); 231 (posbits & 07));
232 bb_error_msg("uncompress: corrupt input"); 232 bb_error_msg("corrupted data");
233 goto err; 233 goto err;
234 } 234 }
235 235
diff --git a/archival/lzop.c b/archival/lzop.c
index 0a15c51aa..d6cf6f4f5 100644
--- a/archival/lzop.c
+++ b/archival/lzop.c
@@ -738,12 +738,12 @@ static NOINLINE smallint lzo_decompress(const header_t *h)
738 bb_error_msg_and_die("this file is a split lzop file"); 738 bb_error_msg_and_die("this file is a split lzop file");
739 739
740 if (dst_len > MAX_BLOCK_SIZE) 740 if (dst_len > MAX_BLOCK_SIZE)
741 bb_error_msg_and_die("lzop file corrupted"); 741 bb_error_msg_and_die("corrupted data");
742 742
743 /* read compressed block size */ 743 /* read compressed block size */
744 src_len = read32(); 744 src_len = read32();
745 if (src_len <= 0 || src_len > dst_len) 745 if (src_len <= 0 || src_len > dst_len)
746 bb_error_msg_and_die("lzop file corrupted"); 746 bb_error_msg_and_die("corrupted data");
747 747
748 if (dst_len > block_size) { 748 if (dst_len > block_size) {
749 if (b2) { 749 if (b2) {
@@ -797,7 +797,7 @@ static NOINLINE smallint lzo_decompress(const header_t *h)
797 r = lzo1x_decompress_safe(b1, src_len, b2, &d, NULL); 797 r = lzo1x_decompress_safe(b1, src_len, b2, &d, NULL);
798 798
799 if (r != 0 /*LZO_E_OK*/ || dst_len != d) { 799 if (r != 0 /*LZO_E_OK*/ || dst_len != d) {
800 bb_error_msg_and_die("corrupted compressed data"); 800 bb_error_msg_and_die("corrupted data");
801 } 801 }
802 dst = b2; 802 dst = b2;
803 } else { 803 } else {
diff --git a/include/applets.h b/include/applets.h
index 33c3c2555..4d8ba0a6b 100644
--- a/include/applets.h
+++ b/include/applets.h
@@ -253,7 +253,8 @@ IF_LSMOD(APPLET(lsmod, _BB_DIR_SBIN, _BB_SUID_DROP))
253IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe)) 253IF_MODPROBE_SMALL(APPLET_ODDNAME(lsmod, modprobe, _BB_DIR_SBIN, _BB_SUID_DROP, modprobe))
254IF_LSPCI(APPLET(lspci, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 254IF_LSPCI(APPLET(lspci, _BB_DIR_USR_BIN, _BB_SUID_DROP))
255IF_LSUSB(APPLET(lsusb, _BB_DIR_USR_BIN, _BB_SUID_DROP)) 255IF_LSUSB(APPLET(lsusb, _BB_DIR_USR_BIN, _BB_SUID_DROP))
256IF_UNLZMA(APPLET_ODDNAME(lzmacat, unlzma, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzmacat)) 256IF_UNLZMA(APPLET_ODDNAME(lzcat, unlzma, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzcat))
257IF_FEATURE_LZMA_ALIAS(APPLET_ODDNAME(lzma, unlzma, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzma))
257IF_LZOP(APPLET(lzop, _BB_DIR_BIN, _BB_SUID_DROP)) 258IF_LZOP(APPLET(lzop, _BB_DIR_BIN, _BB_SUID_DROP))
258IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzopcat)) 259IF_LZOP(APPLET_ODDNAME(lzopcat, lzop, _BB_DIR_USR_BIN, _BB_SUID_DROP, lzopcat))
259IF_MAKEDEVS(APPLET(makedevs, _BB_DIR_SBIN, _BB_SUID_DROP)) 260IF_MAKEDEVS(APPLET(makedevs, _BB_DIR_SBIN, _BB_SUID_DROP))
diff --git a/include/usage.h b/include/usage.h
index 8b8bd2c78..3b03228ee 100644
--- a/include/usage.h
+++ b/include/usage.h
@@ -197,7 +197,7 @@
197#define bunzip2_trivial_usage \ 197#define bunzip2_trivial_usage \
198 "[OPTIONS] [FILE]..." 198 "[OPTIONS] [FILE]..."
199#define bunzip2_full_usage "\n\n" \ 199#define bunzip2_full_usage "\n\n" \
200 "Uncompress FILEs (or stdin)\n" \ 200 "Decompress FILEs (or stdin)\n" \
201 "\nOptions:" \ 201 "\nOptions:" \
202 "\n -c Write to stdout" \ 202 "\n -c Write to stdout" \
203 "\n -f Force" \ 203 "\n -f Force" \
@@ -207,10 +207,10 @@
207#define bzip2_full_usage "\n\n" \ 207#define bzip2_full_usage "\n\n" \
208 "Compress FILEs (or stdin) with bzip2 algorithm\n" \ 208 "Compress FILEs (or stdin) with bzip2 algorithm\n" \
209 "\nOptions:" \ 209 "\nOptions:" \
210 "\n -c Write to stdout" \ 210 "\n -1..9 Compression level" \
211 "\n -d Decompress" \ 211 "\n -d Decompress" \
212 "\n -c Write to stdout" \
212 "\n -f Force" \ 213 "\n -f Force" \
213 "\n -1..-9 Compression level" \
214 214
215#define busybox_notes_usage \ 215#define busybox_notes_usage \
216 "Hello world!\n" 216 "Hello world!\n"
@@ -218,13 +218,14 @@
218#define lzop_trivial_usage \ 218#define lzop_trivial_usage \
219 "[-cfvd123456789CF] [FILE]..." 219 "[-cfvd123456789CF] [FILE]..."
220#define lzop_full_usage "\n\n" \ 220#define lzop_full_usage "\n\n" \
221 " -c Write to stdout" \ 221 "Options:" \
222 "\n -1..9 Compression level" \
223 "\n -d Decompress" \
224 "\n -c Write to stdout" \
222 "\n -f Force" \ 225 "\n -f Force" \
223 "\n -v Verbose" \ 226 "\n -v Verbose" \
224 "\n -d Decompress" \
225 "\n -F Don't store or verify checksum" \ 227 "\n -F Don't store or verify checksum" \
226 "\n -C Also write checksum of compressed block" \ 228 "\n -C Also write checksum of compressed block" \
227 "\n -1..9 Compression level" \
228 229
229#define lzopcat_trivial_usage \ 230#define lzopcat_trivial_usage \
230 "[-vCF] [FILE]..." 231 "[-vCF] [FILE]..."
@@ -235,7 +236,8 @@
235#define unlzop_trivial_usage \ 236#define unlzop_trivial_usage \
236 "[-cfvCF] [FILE]..." 237 "[-cfvCF] [FILE]..."
237#define unlzop_full_usage "\n\n" \ 238#define unlzop_full_usage "\n\n" \
238 " -c Write to stdout" \ 239 "Options:" \
240 "\n -c Write to stdout" \
239 "\n -f Force" \ 241 "\n -f Force" \
240 "\n -v Verbose" \ 242 "\n -v Verbose" \
241 "\n -F Don't store or verify checksum" \ 243 "\n -F Don't store or verify checksum" \
@@ -243,20 +245,29 @@
243#define bzcat_trivial_usage \ 245#define bzcat_trivial_usage \
244 "FILE" 246 "FILE"
245#define bzcat_full_usage "\n\n" \ 247#define bzcat_full_usage "\n\n" \
246 "Uncompress to stdout" 248 "Decompress to stdout"
247 249
248#define unlzma_trivial_usage \ 250#define unlzma_trivial_usage \
249 "[OPTIONS] [FILE]..." 251 "[OPTIONS] [FILE]..."
250#define unlzma_full_usage "\n\n" \ 252#define unlzma_full_usage "\n\n" \
251 "Uncompress FILE (or stdin)\n" \ 253 "Decompress FILE (or stdin)\n" \
254 "\nOptions:" \
255 "\n -c Write to stdout" \
256 "\n -f Force" \
257
258#define lzma_trivial_usage \
259 "-d [OPTIONS] [FILE]..."
260#define lzma_full_usage "\n\n" \
261 "Decompress FILE (or stdin)\n" \
252 "\nOptions:" \ 262 "\nOptions:" \
263 "\n -d Decompress" \
253 "\n -c Write to stdout" \ 264 "\n -c Write to stdout" \
254 "\n -f Force" \ 265 "\n -f Force" \
255 266
256#define lzmacat_trivial_usage \ 267#define lzcat_trivial_usage \
257 "FILE" 268 "FILE"
258#define lzmacat_full_usage "\n\n" \ 269#define lzcat_full_usage "\n\n" \
259 "Uncompress to stdout" 270 "Decompress to stdout"
260 271
261#define cal_trivial_usage \ 272#define cal_trivial_usage \
262 "[-jy] [[MONTH] YEAR]" 273 "[-jy] [[MONTH] YEAR]"
@@ -267,11 +278,9 @@
267 "\n -y Display the entire year" \ 278 "\n -y Display the entire year" \
268 279
269#define cat_trivial_usage \ 280#define cat_trivial_usage \
270 "[-u] [FILE]..." 281 "[FILE]..."
271#define cat_full_usage "\n\n" \ 282#define cat_full_usage "\n\n" \
272 "Concatenate FILEs and print them to stdout\n" \ 283 "Concatenate FILEs and print them to stdout" \
273 "\nOptions:" \
274 "\n -u Use unbuffered i/o (ignored)" \
275 284
276#define cat_example_usage \ 285#define cat_example_usage \
277 "$ cat /proc/uptime\n" \ 286 "$ cat /proc/uptime\n" \
@@ -1610,7 +1619,7 @@
1610#define gunzip_trivial_usage \ 1619#define gunzip_trivial_usage \
1611 "[OPTIONS] [FILE]..." 1620 "[OPTIONS] [FILE]..."
1612#define gunzip_full_usage "\n\n" \ 1621#define gunzip_full_usage "\n\n" \
1613 "Uncompress FILEs (or stdin)\n" \ 1622 "Decompress FILEs (or stdin)\n" \
1614 "\nOptions:" \ 1623 "\nOptions:" \
1615 "\n -c Write to stdout" \ 1624 "\n -c Write to stdout" \
1616 "\n -f Force" \ 1625 "\n -f Force" \
@@ -1628,8 +1637,8 @@
1628#define gzip_full_usage "\n\n" \ 1637#define gzip_full_usage "\n\n" \
1629 "Compress FILEs (or stdin)\n" \ 1638 "Compress FILEs (or stdin)\n" \
1630 "\nOptions:" \ 1639 "\nOptions:" \
1631 "\n -c Write to stdout" \
1632 "\n -d Decompress" \ 1640 "\n -d Decompress" \
1641 "\n -c Write to stdout" \
1633 "\n -f Force" \ 1642 "\n -f Force" \
1634 1643
1635#define gzip_example_usage \ 1644#define gzip_example_usage \
@@ -4977,7 +4986,7 @@
4977#define uncompress_trivial_usage \ 4986#define uncompress_trivial_usage \
4978 "[-cf] [FILE]..." 4987 "[-cf] [FILE]..."
4979#define uncompress_full_usage "\n\n" \ 4988#define uncompress_full_usage "\n\n" \
4980 "Uncompress .Z file[s]\n" \ 4989 "Decompress .Z file[s]\n" \
4981 "\nOptions:" \ 4990 "\nOptions:" \
4982 "\n -c Extract to stdout" \ 4991 "\n -c Extract to stdout" \
4983 "\n -f Overwrite an existing file" \ 4992 "\n -f Overwrite an existing file" \
@@ -5224,7 +5233,7 @@
5224#define zcat_trivial_usage \ 5233#define zcat_trivial_usage \
5225 "FILE" 5234 "FILE"
5226#define zcat_full_usage "\n\n" \ 5235#define zcat_full_usage "\n\n" \
5227 "Uncompress to stdout" 5236 "Decompress to stdout"
5228 5237
5229#define zcip_trivial_usage \ 5238#define zcip_trivial_usage \
5230 "[OPTIONS] IFACE SCRIPT" 5239 "[OPTIONS] IFACE SCRIPT"