aboutsummaryrefslogtreecommitdiff
path: root/archival/gzip.c
diff options
context:
space:
mode:
authorGravatar Kang-Che Sung <explorer09@gmail.com>2017-01-08 14:28:34 +0800
committerGravatar Denys Vlasenko <vda.linux@googlemail.com>2017-01-09 09:03:31 +0100
commitb130f9f758b6404c6d0911a1c120937ae6ab47f8 (patch)
treece1502cfcfc67e7e9fb40b85d13488273aa82689 /archival/gzip.c
parentfb87d93d1e0a6760049fa88aadd1232b7e1545e7 (diff)
downloadbusybox-b130f9f758b6404c6d0911a1c120937ae6ab47f8.tar.gz
busybox-b130f9f758b6404c6d0911a1c120937ae6ab47f8.tar.bz2
Allow 'gzip -d' and 'bzip2 -d' without gunzip or bunzip2
Idea copied from the "ip" applet. Signed-off-by: Kang-Che Sung <explorer09@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'archival/gzip.c')
-rw-r--r--archival/gzip.c24
1 files changed, 17 insertions, 7 deletions
diff --git a/archival/gzip.c b/archival/gzip.c
index 9e0bee815..63bf76053 100644
--- a/archival/gzip.c
+++ b/archival/gzip.c
@@ -72,19 +72,29 @@ aa: 85.1% -- replaced with aa.gz
//config: is 6. If levels 1-3 are specified, 4 is used.
//config: If this option is not selected, -N options are ignored and -9
//config: is used.
+//config:
+//config:config FEATURE_GZIP_DECOMPRESS
+//config: bool "Enable decompression"
+//config: default y
+//config: depends on GZIP || GUNZIP || ZCAT
+//config: help
+//config: Enable -d (--decompress) and -t (--test) options for gzip.
+//config: This will be automatically selected if gunzip or zcat is
+//config: enabled.
//applet:IF_GZIP(APPLET(gzip, BB_DIR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_GZIP) += gzip.o
//usage:#define gzip_trivial_usage
-//usage: "[-cf" IF_GUNZIP("d") IF_FEATURE_GZIP_LEVELS("123456789") "] [FILE]..."
+//usage: "[-cf" IF_FEATURE_GZIP_DECOMPRESS("dt") IF_FEATURE_GZIP_LEVELS("123456789") "] [FILE]..."
//usage:#define gzip_full_usage "\n\n"
//usage: "Compress FILEs (or stdin)\n"
//usage: IF_FEATURE_GZIP_LEVELS(
//usage: "\n -1..9 Compression level"
//usage: )
-//usage: IF_GUNZIP(
+//usage: IF_FEATURE_GZIP_DECOMPRESS(
//usage: "\n -d Decompress"
+//usage: "\n -t Test file integrity"
//usage: )
//usage: "\n -c Write to stdout"
//usage: "\n -f Force"
@@ -2154,7 +2164,7 @@ static const char gzip_longopts[] ALIGN1 =
"to-stdout\0" No_argument "c"
"force\0" No_argument "f"
"verbose\0" No_argument "v"
-#if ENABLE_GUNZIP
+#if ENABLE_FEATURE_GZIP_DECOMPRESS
"decompress\0" No_argument "d"
"uncompress\0" No_argument "d"
"test\0" No_argument "t"
@@ -2181,7 +2191,7 @@ static const char gzip_longopts[] ALIGN1 =
*/
int gzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
-#if ENABLE_GUNZIP
+#if ENABLE_FEATURE_GZIP_DECOMPRESS
int gzip_main(int argc, char **argv)
#else
int gzip_main(int argc UNUSED_PARAM, char **argv)
@@ -2211,13 +2221,13 @@ int gzip_main(int argc UNUSED_PARAM, char **argv)
applet_long_options = gzip_longopts;
#endif
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
- opt = getopt32(argv, "cfv" IF_GUNZIP("dt") "qn123456789");
-#if ENABLE_GUNZIP /* gunzip_main may not be visible... */
+ opt = getopt32(argv, "cfv" IF_FEATURE_GZIP_DECOMPRESS("dt") "qn123456789");
+#if ENABLE_FEATURE_GZIP_DECOMPRESS /* gunzip_main may not be visible... */
if (opt & 0x18) // -d and/or -t
return gunzip_main(argc, argv);
#endif
#ifdef ENABLE_FEATURE_GZIP_LEVELS
- opt >>= ENABLE_GUNZIP ? 7 : 5; /* drop cfv[dt]qn bits */
+ opt >>= ENABLE_FEATURE_GZIP_DECOMPRESS ? 7 : 5; /* drop cfv[dt]qn bits */
if (opt == 0)
opt = 1 << 6; /* default: 6 */
opt = ffs(opt >> 4); /* Maps -1..-4 to [0], -5 to [1] ... -9 to [5] */