1303 files changed, 32187 insertions, 57138 deletions
diff --git a/archival/bbunzip.c b/archival/bbunzip.c index fce5ab9..60a837e 100644 --- a/archival/bbunzip.c +++ b/archival/bbunzip.c @@ -9,6 +9,12 @@ /* lzop_main() uses bbunpack(), need this: */ //kbuild:lib-$(CONFIG_LZOP) += bbunzip.o +//kbuild:lib-$(CONFIG_LZOPCAT) += bbunzip.o +//kbuild:lib-$(CONFIG_UNLZOP) += bbunzip.o +/* bzip2_main() too: */ +//kbuild:lib-$(CONFIG_BZIP2) += bbunzip.o +/* gzip_main() too: */ +//kbuild:lib-$(CONFIG_GZIP) += bbunzip.o /* Note: must be kept in sync with archival/lzop.c */ enum { @@ -39,7 +45,7 @@ char* FAST_FUNC append_ext(char *filename, const char *expected_ext) } int FAST_FUNC bbunpack(char **argv, - IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_aux_data_t *aux), + IF_DESKTOP(long long) int FAST_FUNC (*unpacker)(transformer_state_t *xstate), char* FAST_FUNC (*make_new_name)(char *filename, const char *expected_ext), const char *expected_ext ) @@ -48,7 +54,7 @@ int FAST_FUNC bbunpack(char **argv, IF_DESKTOP(long long) int status = 0; char *filename, *new_name; smallint exitcode = 0; - transformer_aux_data_t aux; + transformer_state_t xstate; do { /* NB: new_name is *maybe* malloc'ed! */ @@ -120,9 +126,11 @@ int FAST_FUNC bbunpack(char **argv, } if (!(option_mask32 & SEAMLESS_MAGIC)) { - init_transformer_aux_data(&aux); - aux.check_signature = 1; - status = unpacker(&aux); + init_transformer_state(&xstate); + xstate.signature_skipped = 0; + /*xstate.src_fd = STDIN_FILENO; - already is */ + xstate.dst_fd = STDOUT_FILENO; + status = unpacker(&xstate); if (status < 0) exitcode = 1; } else { @@ -141,10 +149,10 @@ int FAST_FUNC bbunpack(char **argv, unsigned new_name_len; /* TODO: restore other things? */ - if (aux.mtime != 0) { + if (xstate.mtime != 0) { struct timeval times[2]; - times[1].tv_sec = times[0].tv_sec = aux.mtime; + times[1].tv_sec = times[0].tv_sec = xstate.mtime; times[1].tv_usec = times[0].tv_usec = 0; /* Note: we closed it first. * On some systems calling utimes @@ -188,7 +196,10 @@ int FAST_FUNC bbunpack(char **argv, return exitcode; } -#if ENABLE_UNCOMPRESS || ENABLE_BUNZIP2 || ENABLE_UNLZMA || ENABLE_UNXZ +#if ENABLE_UNCOMPRESS \ + || ENABLE_BUNZIP2 || ENABLE_BZCAT \ + || ENABLE_UNLZMA || ENABLE_LZCAT || ENABLE_LZMA \ + || ENABLE_UNXZ || ENABLE_XZCAT || ENABLE_XZ static char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext) { @@ -218,7 +229,7 @@ char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext) //config:config UNCOMPRESS //config: bool "uncompress" -//config: default n +//config: default n # ancient //config: help //config: uncompress is used to decompress archives created by compress. //config: Not much used anymore, replaced by gzip/gunzip. @@ -226,18 +237,13 @@ char* FAST_FUNC make_new_name_generic(char *filename, const char *expected_ext) //applet:IF_UNCOMPRESS(APPLET(uncompress, BB_DIR_BIN, BB_SUID_DROP)) //kbuild:lib-$(CONFIG_UNCOMPRESS) += bbunzip.o #if ENABLE_UNCOMPRESS -static -IF_DESKTOP(long long) int FAST_FUNC unpack_uncompress(transformer_aux_data_t *aux) -{ - return unpack_Z_stream(aux, STDIN_FILENO, STDOUT_FILENO); -} int uncompress_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int uncompress_main(int argc UNUSED_PARAM, char **argv) { getopt32(argv, "cf"); argv += optind; - return bbunpack(argv, unpack_uncompress, make_new_name_generic, "Z"); + return bbunpack(argv, unpack_Z_stream, make_new_name_generic, "Z"); } #endif @@ -293,12 +299,25 @@ int uncompress_main(int argc UNUSED_PARAM, char **argv) //config: gunzip is used to decompress archives created by gzip. //config: You can use the `-t' option to test the integrity of //config: an archive, without decompressing it. +//config: +//config:config ZCAT +//config: bool "zcat" +//config: default y +//config: help +//config: Alias to "gunzip -c". +//config: +//config:config FEATURE_GUNZIP_LONG_OPTIONS +//config: bool "Enable long options" +//config: default y +//config: depends on (GUNZIP || ZCAT) && LONG_OPTS +//config: help +//config: Enable use of long options. //applet:IF_GUNZIP(APPLET(gunzip, BB_DIR_BIN, BB_SUID_DROP)) -//applet:IF_GUNZIP(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat)) -//kbuild:lib-$(CONFIG_GZIP) += bbunzip.o +//applet:IF_ZCAT(APPLET_ODDNAME(zcat, gunzip, BB_DIR_BIN, BB_SUID_DROP, zcat)) //kbuild:lib-$(CONFIG_GUNZIP) += bbunzip.o -#if ENABLE_GUNZIP +//kbuild:lib-$(CONFIG_ZCAT) += bbunzip.o +#if ENABLE_GUNZIP || ENABLE_ZCAT static char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UNUSED_PARAM) { @@ -324,11 +343,17 @@ char* FAST_FUNC make_new_name_gunzip(char *filename, const char *expected_ext UN } return filename; } -static -IF_DESKTOP(long long) int FAST_FUNC unpack_gunzip(transformer_aux_data_t *aux) -{ - return unpack_gz_stream(aux, STDIN_FILENO, STDOUT_FILENO); -} + +#if ENABLE_FEATURE_GUNZIP_LONG_OPTIONS +static const char gunzip_longopts[] ALIGN1 = + "stdout\0" No_argument "c" + "to-stdout\0" No_argument "c" + "force\0" No_argument "f" + "test\0" No_argument "t" + "no-name\0" No_argument "n" + ; +#endif + /* * Linux kernel build uses gzip -d -n. We accept and ignore it. * Man page says: @@ -345,6 +370,9 @@ IF_DESKTOP(long long) int FAST_FUNC unpack_gunzip(transformer_aux_data_t *aux) int gunzip_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int gunzip_main(int argc UNUSED_PARAM, char **argv) { +#if ENABLE_FEATURE_GUNZIP_LONG_OPTIONS + applet_long_options = gunzip_longopts; +#endif getopt32(argv, "cfvqdtn"); argv += optind; @@ -352,10 +380,10 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv) * Normally, "zcat" is just "gunzip -c". * But if seamless magic is enabled, then we are much more clever. */ - if (applet_name[1] == 'c') + if (ENABLE_ZCAT && applet_name[1] == 'c') option_mask32 |= OPT_STDOUT | SEAMLESS_MAGIC; - return bbunpack(argv, unpack_gunzip, make_new_name_gunzip, /*unused:*/ NULL); + return bbunpack(argv, unpack_gz_stream, make_new_name_gunzip, /*unused:*/ NULL); } #endif @@ -389,26 +417,27 @@ int gunzip_main(int argc UNUSED_PARAM, char **argv) //config: //config: Unless you have a specific application which requires bunzip2, you //config: should probably say N here. +//config: +//config:config BZCAT +//config: bool "bzcat" +//config: default y +//config: help +//config: Alias to "bunzip2 -c". //applet:IF_BUNZIP2(APPLET(bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP)) -//applet:IF_BUNZIP2(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat)) -//kbuild:lib-$(CONFIG_BZIP2) += bbunzip.o +//applet:IF_BZCAT(APPLET_ODDNAME(bzcat, bunzip2, BB_DIR_USR_BIN, BB_SUID_DROP, bzcat)) //kbuild:lib-$(CONFIG_BUNZIP2) += bbunzip.o -#if ENABLE_BUNZIP2 -static -IF_DESKTOP(long long) int FAST_FUNC unpack_bunzip2(transformer_aux_data_t *aux) -{ - return unpack_bz2_stream(aux, STDIN_FILENO, STDOUT_FILENO); -} +//kbuild:lib-$(CONFIG_BZCAT) += bbunzip.o +#if ENABLE_BUNZIP2 || ENABLE_BZCAT int bunzip2_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int bunzip2_main(int argc UNUSED_PARAM, char **argv) { getopt32(argv, "cfvqdt"); argv += optind; - if (applet_name[2] == 'c') /* bzcat */ + if (ENABLE_BZCAT && applet_name[2] == 'c') /* bzcat */ option_mask32 |= OPT_STDOUT; - return bbunpack(argv, unpack_bunzip2, make_new_name_generic, "bz2"); + return bbunpack(argv, unpack_bz2_stream, make_new_name_generic, "bz2"); } #endif @@ -473,32 +502,40 @@ int bunzip2_main(int argc UNUSED_PARAM, char **argv) //config: The BusyBox unlzma applet is limited to decompression only. //config: On an x86 system, this applet adds about 4K. //config: -//config:config FEATURE_LZMA_FAST -//config: bool "Optimize unlzma for speed" -//config: default n -//config: depends on UNLZMA +//config:config LZCAT +//config: bool "lzcat" +//config: default y //config: help -//config: This option reduces decompression time by about 25% at the cost of -//config: a 1K bigger binary. +//config: unlzma is a compression utility using the Lempel-Ziv-Markov chain +//config: compression algorithm, and range coding. Compression +//config: is generally considerably better than that achieved by the bzip2 +//config: compressors. +//config: +//config: The BusyBox unlzma applet is limited to decompression only. +//config: On an x86 system, this applet adds about 4K. //config: //config:config LZMA -//config: bool "Provide lzma alias which supports only unpacking" +//config: bool "lzma -d" //config: default y -//config: depends on UNLZMA //config: help //config: Enable this option if you want commands like "lzma -d" to work. //config: IOW: you'll get lzma applet, but it will always require -d option. +//config: +//config:config FEATURE_LZMA_FAST +//config: bool "Optimize unlzma for speed" +//config: default n +//config: depends on UNLZMA || LZCAT || LZMA +//config: help +//config: This option reduces decompression time by about 25% at the cost of +//config: a 1K bigger binary. //applet:IF_UNLZMA(APPLET(unlzma, BB_DIR_USR_BIN, BB_SUID_DROP)) -//applet:IF_UNLZMA(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat)) +//applet:IF_LZCAT(APPLET_ODDNAME(lzcat, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzcat)) //applet:IF_LZMA(APPLET_ODDNAME(lzma, unlzma, BB_DIR_USR_BIN, BB_SUID_DROP, lzma)) //kbuild:lib-$(CONFIG_UNLZMA) += bbunzip.o -#if ENABLE_UNLZMA -static -IF_DESKTOP(long long) int FAST_FUNC unpack_unlzma(transformer_aux_data_t *aux) -{ - return unpack_lzma_stream(aux, STDIN_FILENO, STDOUT_FILENO); -} +//kbuild:lib-$(CONFIG_LZCAT) += bbunzip.o +//kbuild:lib-$(CONFIG_LZMA) += bbunzip.o +#if ENABLE_UNLZMA || ENABLE_LZCAT || ENABLE_LZMA int unlzma_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int unlzma_main(int argc UNUSED_PARAM, char **argv) { @@ -509,11 +546,11 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv) bb_show_usage(); # endif /* lzcat? */ - if (applet_name[2] == 'c') + if (ENABLE_LZCAT && applet_name[2] == 'c') option_mask32 |= OPT_STDOUT; argv += optind; - return bbunpack(argv, unpack_unlzma, make_new_name_generic, "lzma"); + return bbunpack(argv, unpack_lzma_stream, make_new_name_generic, "lzma"); } #endif @@ -524,24 +561,26 @@ int unlzma_main(int argc UNUSED_PARAM, char **argv) //config: help //config: unxz is a unlzma successor. //config: +//config:config XZCAT +//config: bool "xzcat" +//config: default y +//config: help +//config: Alias to "unxz -c". +//config: //config:config XZ -//config: bool "Provide xz alias which supports only unpacking" +//config: bool "xz -d" //config: default y -//config: depends on UNXZ //config: help //config: Enable this option if you want commands like "xz -d" to work. //config: IOW: you'll get xz applet, but it will always require -d option. //applet:IF_UNXZ(APPLET(unxz, BB_DIR_USR_BIN, BB_SUID_DROP)) -//applet:IF_UNXZ(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat)) +//applet:IF_XZCAT(APPLET_ODDNAME(xzcat, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xzcat)) //applet:IF_XZ(APPLET_ODDNAME(xz, unxz, BB_DIR_USR_BIN, BB_SUID_DROP, xz)) //kbuild:lib-$(CONFIG_UNXZ) += bbunzip.o -#if ENABLE_UNXZ -static -IF_DESKTOP(long long) int FAST_FUNC unpack_unxz(transformer_aux_data_t *aux) -{ - return unpack_xz_stream(aux, STDIN_FILENO, STDOUT_FILENO); -} +//kbuild:lib-$(CONFIG_XZCAT) += bbunzip.o +//kbuild:lib-$(CONFIG_XZ) += bbunzip.o +#if ENABLE_UNXZ || ENABLE_XZCAT || ENABLE_XZ int unxz_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; int unxz_main(int argc UNUSED_PARAM, char **argv) { @@ -552,10 +591,10 @@ int unxz_main(int argc UNUSED_PARAM, char **argv) bb_show_usage(); # endif /* xzcat? */ - if (applet_name[2] == 'c') + if (ENABLE_XZCAT && applet_name[2] == 'c') option_mask32 |= OPT_STDOUT; argv += optind; - return bbunpack(argv, unpack_unxz, make_new_name_generic, "xz"); + return bbunpack(argv, unpack_xz_stream, make_new_name_generic, "xz"); } #endif |