diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2008-09-04 11:53:06 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2008-09-04 11:53:06 +0300 |
commit | da98df54400998be2a6c3876f9655a3c51b93c10 (patch) | |
tree | 3d3d2cd1f8e083dcf9680e3e775c31b17c13197c /src/lzma/process.c | |
parent | Don't allow LZMA_SYNC_FLUSH with decoders anymore. There's (diff) | |
download | xz-da98df54400998be2a6c3876f9655a3c51b93c10.tar.xz |
Added support for raw encoding and decoding to the command
line tool, and made various cleanups. --lzma was renamed to
--lzma1 to prevent people from accidentally using LZMA when
they want LZMA2.
Diffstat (limited to 'src/lzma/process.c')
-rw-r--r-- | src/lzma/process.c | 42 |
1 files changed, 34 insertions, 8 deletions
diff --git a/src/lzma/process.c b/src/lzma/process.c index 42c625e3..084b2c57 100644 --- a/src/lzma/process.c +++ b/src/lzma/process.c @@ -155,18 +155,44 @@ single_init(thread_data *t) lzma_ret ret; if (opt_mode == MODE_COMPRESS) { - if (opt_header == HEADER_ALONE) { - ret = lzma_alone_encoder(&t->strm, - opt_filters[0].options); - } else { + switch (opt_header) { + case HEADER_AUTO: + case HEADER_NATIVE: ret = lzma_stream_encoder(&t->strm, opt_filters, opt_check); + break; + + case HEADER_ALONE: + ret = lzma_alone_encoder(&t->strm, + opt_filters[0].options); + break; + + case HEADER_RAW: + ret = lzma_raw_encoder(&t->strm, opt_filters); + break; } } else { - // TODO Restrict file format if requested on the command line. - ret = lzma_auto_decoder(&t->strm, opt_memory, - LZMA_WARN_UNSUPPORTED_CHECK - | LZMA_CONCATENATED); + const uint32_t flags = LZMA_WARN_UNSUPPORTED_CHECK + | LZMA_CONCATENATED; + + switch (opt_header) { + case HEADER_AUTO: + ret = lzma_auto_decoder(&t->strm, opt_memory, flags); + break; + + case HEADER_NATIVE: + ret = lzma_stream_decoder(&t->strm, opt_memory, flags); + break; + + case HEADER_ALONE: + ret = lzma_alone_decoder(&t->strm, opt_memory); + break; + + case HEADER_RAW: + // Memory usage has already been checked in args.c. + ret = lzma_raw_decoder(&t->strm, opt_filters); + break; + } } if (ret != LZMA_OK) { |