X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=archival%2Flzop.c;h=e0e90ac6cdcb8ca31d07d37f79a3c80812aa21d9;hb=179e88bec91cfe58096900dc5509a080ff37b083;hp=9b42e5fd3987b2e317ed6d16bbabab26bb7668e6;hpb=93b51819cf42728654769462130c4b7d50e9b67a;p=oweals%2Fbusybox.git diff --git a/archival/lzop.c b/archival/lzop.c index 9b42e5fd3..e0e90ac6c 100644 --- a/archival/lzop.c +++ b/archival/lzop.c @@ -25,6 +25,40 @@ "Minimalized" for busybox by Alain Knaff */ +//config:config LZOP +//config: bool "lzop" +//config: default y +//config: help +//config: Lzop compression/decompresion. +//config: +//config:config UNLZOP +//config: bool "unlzop" +//config: default y +//config: help +//config: Lzop decompresion. +//config: +//config:config LZOPCAT +//config: bool "lzopcat" +//config: default y +//config: help +//config: Alias to "unlzop -c". +//config: +//config:config LZOP_COMPR_HIGH +//config: bool "lzop compression levels 7,8,9 (not very useful)" +//config: default n +//config: depends on LZOP || UNLZOP || LZOPCAT +//config: help +//config: High levels (7,8,9) of lzop compression. These levels +//config: are actually slower than gzip at equivalent compression ratios +//config: and take up 3.2K of code. + +//applet:IF_LZOP(APPLET(lzop, BB_DIR_BIN, BB_SUID_DROP)) +//applet:IF_UNLZOP(APPLET_ODDNAME(unlzop, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, unlzop)) +//applet:IF_LZOPCAT(APPLET_ODDNAME(lzopcat, lzop, BB_DIR_USR_BIN, BB_SUID_DROP, lzopcat)) +//kbuild:lib-$(CONFIG_LZOP) += lzop.o +//kbuild:lib-$(CONFIG_UNLZOP) += lzop.o +//kbuild:lib-$(CONFIG_LZOPCAT) += lzop.o + //usage:#define lzop_trivial_usage //usage: "[-cfvd123456789CF] [FILE]..." //usage:#define lzop_full_usage "\n\n" @@ -37,20 +71,21 @@ //usage: "\n -C Also write checksum of compressed block" //usage: //usage:#define lzopcat_trivial_usage -//usage: "[-vCF] [FILE]..." +//usage: "[-vF] [FILE]..." //usage:#define lzopcat_full_usage "\n\n" //usage: " -v Verbose" -//usage: "\n -F Don't store or verify checksum" +//usage: "\n -F Don't verify checksum" //usage: //usage:#define unlzop_trivial_usage -//usage: "[-cfvCF] [FILE]..." +//usage: "[-cfvF] [FILE]..." //usage:#define unlzop_full_usage "\n\n" //usage: " -c Write to stdout" //usage: "\n -f Force" //usage: "\n -v Verbose" -//usage: "\n -F Don't store or verify checksum" +//usage: "\n -F Don't verify checksum" #include "libbb.h" +#include "common_bufsiz.h" #include "bb_archive.h" #include "liblzo_interface.h" @@ -423,8 +458,8 @@ struct globals { chksum_t chksum_in; chksum_t chksum_out; } FIX_ALIASING; -#define G (*(struct globals*)&bb_common_bufsiz1) -#define INIT_G() do { } while (0) +#define G (*(struct globals*)bb_common_bufsiz1) +#define INIT_G() do { setup_common_bufsiz(); } while (0) //#define G (*ptr_to_globals) //#define INIT_G() do { // SET_PTR_TO_GLOBALS(xzalloc(sizeof(G))); @@ -620,7 +655,7 @@ static int lzo_get_method(header_t *h) /**********************************************************************/ // compress a file /**********************************************************************/ -static NOINLINE smallint lzo_compress(const header_t *h) +static NOINLINE int lzo_compress(const header_t *h) { unsigned block_size = LZO_BLOCK_SIZE; int r = 0; /* LZO_E_OK */ @@ -630,7 +665,6 @@ static NOINLINE smallint lzo_compress(const header_t *h) uint32_t d_adler32 = ADLER32_INIT_VALUE; uint32_t d_crc32 = CRC32_INIT_VALUE; int l; - smallint ok = 1; uint8_t *wrk_mem = NULL; if (h->method == M_LZO1X_1) @@ -712,7 +746,7 @@ static NOINLINE smallint lzo_compress(const header_t *h) free(wrk_mem); free(b1); free(b2); - return ok; + return 1; } static FAST_FUNC void lzo_check( @@ -733,7 +767,7 @@ static FAST_FUNC void lzo_check( /**********************************************************************/ // decompress a file /**********************************************************************/ -static NOINLINE smallint lzo_decompress(const header_t *h) +static NOINLINE int lzo_decompress(const header_t *h) { unsigned block_size = LZO_BLOCK_SIZE; int r; @@ -741,7 +775,6 @@ static NOINLINE smallint lzo_decompress(const header_t *h) uint32_t c_adler32 = ADLER32_INIT_VALUE; uint32_t d_adler32 = ADLER32_INIT_VALUE; uint32_t c_crc32 = CRC32_INIT_VALUE, d_crc32 = CRC32_INIT_VALUE; - smallint ok = 1; uint8_t *b1; uint32_t mcs_block_size = MAX_COMPRESSED_SIZE(block_size); uint8_t *b2 = NULL; @@ -845,7 +878,7 @@ static NOINLINE smallint lzo_decompress(const header_t *h) } free(b2); - return ok; + return 1; } /**********************************************************************/ @@ -877,7 +910,7 @@ static NOINLINE smallint lzo_decompress(const header_t *h) * chksum_out * The rest is identical. */ -static const unsigned char lzop_magic[9] = { +static const unsigned char lzop_magic[9] ALIGN1 = { 0x89, 0x4c, 0x5a, 0x4f, 0x00, 0x0d, 0x0a, 0x1a, 0x0a }; @@ -1030,7 +1063,7 @@ static void lzo_set_method(header_t *h) h->level = level; } -static smallint do_lzo_compress(void) +static int do_lzo_compress(void) { header_t header; @@ -1058,7 +1091,7 @@ static smallint do_lzo_compress(void) /**********************************************************************/ // decompress /**********************************************************************/ -static smallint do_lzo_decompress(void) +static int do_lzo_decompress(void) { header_t header; @@ -1079,7 +1112,7 @@ static char* FAST_FUNC make_new_name_lzop(char *filename, const char *expected_e return xasprintf("%s.lzo", filename); } -static IF_DESKTOP(long long) int FAST_FUNC pack_lzop(transformer_aux_data_t *aux UNUSED_PARAM) +static IF_DESKTOP(long long) int FAST_FUNC pack_lzop(transformer_state_t *xstate UNUSED_PARAM) { if (option_mask32 & OPT_DECOMPRESS) return do_lzo_decompress(); @@ -1092,10 +1125,10 @@ int lzop_main(int argc UNUSED_PARAM, char **argv) getopt32(argv, OPTION_STRING); argv += optind; /* lzopcat? */ - if (applet_name[4] == 'c') + if (ENABLE_LZOPCAT && applet_name[4] == 'c') option_mask32 |= (OPT_STDOUT | OPT_DECOMPRESS); /* unlzop? */ - if (applet_name[4] == 'o') + if (ENABLE_UNLZOP && applet_name[4] == 'o') option_mask32 |= OPT_DECOMPRESS; global_crc32_table = crc32_filltable(NULL, 0);