Idea copied from the "ip" applet.
Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
//kbuild:lib-$(CONFIG_LZOPCAT) += bbunzip.o
//kbuild:lib-$(CONFIG_UNLZOP) += bbunzip.o
/* bzip2_main() too: */
-//kbuild:lib-$(CONFIG_BZIP2) += bbunzip.o
+//kbuild:lib-$(CONFIG_FEATURE_BZIP2_DECOMPRESS) += bbunzip.o
/* gzip_main() too: */
-//kbuild:lib-$(CONFIG_GZIP) += bbunzip.o
+//kbuild:lib-$(CONFIG_FEATURE_GZIP_DECOMPRESS) += bbunzip.o
/* Note: must be kept in sync with archival/lzop.c */
enum {
}
#if ENABLE_UNCOMPRESS \
- || ENABLE_BUNZIP2 || ENABLE_BZCAT \
+ || ENABLE_FEATURE_BZIP2_DECOMPRESS \
|| ENABLE_UNLZMA || ENABLE_LZCAT || ENABLE_LZMA \
|| ENABLE_UNXZ || ENABLE_XZCAT || ENABLE_XZ
static
//config:config GUNZIP
//config: bool "gunzip"
//config: default y
+//config: select FEATURE_GZIP_DECOMPRESS
//config: help
//config: gunzip is used to decompress archives created by gzip.
//config: You can use the `-t' option to test the integrity of
//config:config ZCAT
//config: bool "zcat"
//config: default y
+//config: select FEATURE_GZIP_DECOMPRESS
//config: help
//config: Alias to "gunzip -c".
//config:
//applet:IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP))
//applet:IF_ZCAT(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat))
-//kbuild:lib-$(CONFIG_GUNZIP) += bbunzip.o
-//kbuild:lib-$(CONFIG_ZCAT) += bbunzip.o
-#if ENABLE_GUNZIP || ENABLE_ZCAT
+#if ENABLE_FEATURE_GZIP_DECOMPRESS
static
char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM)
{
return bbunpack(argv, unpack_gz_stream, make_new_name_gunzip, /*unused:*/ NULL);
}
-#endif
+#endif /* FEATURE_GZIP_DECOMPRESS */
/*
//config:config BUNZIP2
//config: bool "bunzip2"
//config: default y
+//config: select FEATURE_BZIP2_DECOMPRESS
//config: help
//config: bunzip2 is a compression utility using the Burrows-Wheeler block
//config: sorting text compression algorithm, and Huffman coding. Compression
//config:config BZCAT
//config: bool "bzcat"
//config: default y
+//config: select FEATURE_BZIP2_DECOMPRESS
//config: help
//config: Alias to "bunzip2 -c".
//applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
//applet:IF_BZCAT(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat))
-//kbuild:lib-$(CONFIG_BUNZIP2) += bbunzip.o
-//kbuild:lib-$(CONFIG_BZCAT) += bbunzip.o
-#if ENABLE_BUNZIP2 || ENABLE_BZCAT
+#if ENABLE_FEATURE_BZIP2_DECOMPRESS
int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
int bunzip2_main(int argc UNUSED_PARAM, char **argv)
{
//config:
//config: Unless you have a specific application which requires bzip2, you
//config: should probably say N here.
+//config:
+//config:config FEATURE_BZIP2_DECOMPRESS
+//config: bool "Enable decompression"
+//config: default y
+//config: depends on BZIP2 || BUNZIP2 || BZCAT
+//config: help
+//config: Enable -d (--decompress) and -t (--test) options for bzip2.
+//config: This will be automatically selected if bunzip2 or bzcat is
+//config: enabled.
//applet:IF_BZIP2(APPLET(bzip2, BB_DIR_USR_BIN, BB_SUID_DROP))
//kbuild:lib-$(CONFIG_BZIP2) += bzip2.o
//usage:#define bzip2_full_usage "\n\n"
//usage: "Compress FILEs (or stdin) with bzip2 algorithm\n"
//usage: "\n -1..9 Compression level"
+//usage: IF_FEATURE_BZIP2_DECOMPRESS(
//usage: "\n -d Decompress"
+//usage: "\n -t Test file integrity"
+//usage: )
//usage: "\n -c Write to stdout"
//usage: "\n -f Force"
opt_complementary = "s2"; /* -s means -2 (compatibility) */
/* Must match bbunzip's constants OPT_STDOUT, OPT_FORCE! */
- opt = getopt32(argv, "cfv" IF_BUNZIP2("dt") "123456789qzs");
-#if ENABLE_BUNZIP2 /* bunzip2_main may not be visible... */
+ opt = getopt32(argv, "cfv" IF_FEATURE_BZIP2_DECOMPRESS("dt") "123456789qzs");
+#if ENABLE_FEATURE_BZIP2_DECOMPRESS /* bunzip2_main may not be visible... */
if (opt & 0x18) // -d and/or -t
return bunzip2_main(argc, argv);
opt >>= 5;
//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"
"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"
*/
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)
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] */