aboutsummaryrefslogtreecommitdiff
path: root/archival/lzop.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2017-06-15 18:07:04 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2017-06-15 18:07:04 +0200
commit1c013fae2845a6062fb4ad9e7720b5e5d1117cac (patch)
tree5952578df3283e80c986f3235565e2ccd413bc35 /archival/lzop.c
parent5d72ae53c972bd55864f47523e3923b1c683c185 (diff)
downloadbusybox-w32-1c013fae2845a6062fb4ad9e7720b5e5d1117cac.tar.gz
busybox-w32-1c013fae2845a6062fb4ad9e7720b5e5d1117cac.tar.bz2
busybox-w32-1c013fae2845a6062fb4ad9e7720b5e5d1117cac.zip
archival: add option -k "keep" to gzip/bzip2/lzop, add -U "nokeep" to lzop
function old new delta bbunpack 745 779 +34 lzop_main 93 121 +28 do_lzo_compress 320 328 +8 packed_usage 31685 31653 -32 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/1 up/down: 70/-32) Total: 38 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/lzop.c')
-rw-r--r--archival/lzop.c53
1 files changed, 35 insertions, 18 deletions
diff --git a/archival/lzop.c b/archival/lzop.c
index ca61add3c..6ef82b749 100644
--- a/archival/lzop.c
+++ b/archival/lzop.c
@@ -33,13 +33,13 @@
33//config: 33//config:
34//config:config UNLZOP 34//config:config UNLZOP
35//config: bool "unlzop" 35//config: bool "unlzop"
36//config: default y 36//config: default n # INCOMPAT: upstream lzop does not provide such tool
37//config: help 37//config: help
38//config: Lzop decompresion. 38//config: Lzop decompresion.
39//config: 39//config:
40//config:config LZOPCAT 40//config:config LZOPCAT
41//config: bool "lzopcat" 41//config: bool "lzopcat"
42//config: default y 42//config: default n # INCOMPAT: upstream lzop does not provide such tool
43//config: help 43//config: help
44//config: Alias to "unlzop -c". 44//config: Alias to "unlzop -c".
45//config: 45//config:
@@ -61,12 +61,14 @@
61//kbuild:lib-$(CONFIG_LZOPCAT) += lzop.o 61//kbuild:lib-$(CONFIG_LZOPCAT) += lzop.o
62 62
63//usage:#define lzop_trivial_usage 63//usage:#define lzop_trivial_usage
64//usage: "[-cfvd123456789CF] [FILE]..." 64//usage: "[-cfUvd123456789CF] [FILE]..."
65//usage:#define lzop_full_usage "\n\n" 65//usage:#define lzop_full_usage "\n\n"
66//usage: " -1..9 Compression level" 66//usage: " -1..9 Compression level"
67//usage: "\n -d Decompress" 67//usage: "\n -d Decompress"
68//usage: "\n -c Write to stdout" 68//usage: "\n -c Write to stdout"
69//usage: "\n -f Force" 69//usage: "\n -f Force"
70//usage: "\n -U Delete input files"
71///////: "\n -k Keep input files" (default, so why bother documenting?)
70//usage: "\n -v Verbose" 72//usage: "\n -v Verbose"
71//usage: "\n -F Don't store or verify checksum" 73//usage: "\n -F Don't store or verify checksum"
72//usage: "\n -C Also write checksum of compressed block" 74//usage: "\n -C Also write checksum of compressed block"
@@ -78,10 +80,12 @@
78//usage: "\n -F Don't verify checksum" 80//usage: "\n -F Don't verify checksum"
79//usage: 81//usage:
80//usage:#define unlzop_trivial_usage 82//usage:#define unlzop_trivial_usage
81//usage: "[-cfvF] [FILE]..." 83//usage: "[-cfkvF] [FILE]..."
82//usage:#define unlzop_full_usage "\n\n" 84//usage:#define unlzop_full_usage "\n\n"
83//usage: " -c Write to stdout" 85//usage: " -c Write to stdout"
84//usage: "\n -f Force" 86//usage: "\n -f Force"
87//usage: "\n -U Delete input files"
88///////: "\n -k Keep input files" (default, so why bother documenting?)
85//usage: "\n -v Verbose" 89//usage: "\n -v Verbose"
86//usage: "\n -F Don't verify checksum" 90//usage: "\n -F Don't verify checksum"
87 91
@@ -472,27 +476,33 @@ struct globals {
472//#define LZOP_VERSION_STRING "1.01" 476//#define LZOP_VERSION_STRING "1.01"
473//#define LZOP_VERSION_DATE "Apr 27th 2003" 477//#define LZOP_VERSION_DATE "Apr 27th 2003"
474 478
475#define OPTION_STRING "cfvqdt123456789CF" 479// lzop wants to be weird:
480// unlike all other compressosrs, its -k "keep" option is the default,
481// and -U is used to delete the source. We will invert the bit after getopt().
482#define OPTION_STRING "cfUvqdt123456789CFk"
476 483
477/* Note: must be kept in sync with archival/bbunzip.c */ 484/* Note: must be kept in sync with archival/bbunzip.c */
478enum { 485enum {
479 OPT_STDOUT = (1 << 0), 486 OPT_STDOUT = (1 << 0),
480 OPT_FORCE = (1 << 1), 487 OPT_FORCE = (1 << 1),
481 OPT_VERBOSE = (1 << 2), 488 OPT_KEEP = (1 << 2),
482 OPT_QUIET = (1 << 3), 489 OPT_VERBOSE = (1 << 3),
483 OPT_DECOMPRESS = (1 << 4), 490 OPT_QUIET = (1 << 4),
484 OPT_TEST = (1 << 5), 491 OPT_DECOMPRESS = (1 << 5),
485 OPT_1 = (1 << 6), 492 OPT_TEST = (1 << 6),
486 OPT_2 = (1 << 7), 493 OPT_1 = (1 << 7),
487 OPT_3 = (1 << 8), 494 OPT_2 = (1 << 8),
488 OPT_4 = (1 << 9), 495 OPT_3 = (1 << 9),
489 OPT_5 = (1 << 10), 496 OPT_4 = (1 << 10),
490 OPT_6 = (1 << 11), 497 OPT_5 = (1 << 11),
491 OPT_789 = (7 << 12), 498 OPT_6 = (1 << 12),
492 OPT_7 = (1 << 13), 499 OPT_7 = (1 << 13),
493 OPT_8 = (1 << 14), 500 OPT_8 = (1 << 14),
494 OPT_C = (1 << 15), 501 OPT_9 = (1 << 15),
495 OPT_F = (1 << 16), 502 OPT_C = (1 << 16),
503 OPT_F = (1 << 17),
504 OPT_k = (1 << 18),
505 OPT_789 = OPT_7 | OPT_8 | OPT_9
496}; 506};
497 507
498/**********************************************************************/ 508/**********************************************************************/
@@ -1125,6 +1135,13 @@ int lzop_main(int argc UNUSED_PARAM, char **argv)
1125{ 1135{
1126 getopt32(argv, OPTION_STRING); 1136 getopt32(argv, OPTION_STRING);
1127 argv += optind; 1137 argv += optind;
1138 /* -U is "anti -k", invert bit for bbunpack(): */
1139 option_mask32 ^= OPT_KEEP;
1140 /* -k disables -U (if any): */
1141 /* opt_complementary = "k-U"; - nope, only handles -Uk, not -kU */
1142 if (option_mask32 & OPT_k)
1143 option_mask32 |= OPT_KEEP;
1144
1128 /* lzopcat? */ 1145 /* lzopcat? */
1129 if (ENABLE_LZOPCAT && applet_name[4] == 'c') 1146 if (ENABLE_LZOPCAT && applet_name[4] == 'c')
1130 option_mask32 |= (OPT_STDOUT | OPT_DECOMPRESS); 1147 option_mask32 |= (OPT_STDOUT | OPT_DECOMPRESS);