OLD | NEW |
1 /////////////////////////////////////////////////////////////////////////////// | 1 /////////////////////////////////////////////////////////////////////////////// |
2 // | 2 // |
3 /// \file auto_decoder.c | 3 /// \file auto_decoder.c |
4 /// \brief Autodetect between .xz Stream and .lzma (LZMA_Alone) formats | 4 /// \brief Autodetect between .xz Stream and .lzma (LZMA_Alone) formats |
5 // | 5 // |
6 // Author: Lasse Collin | 6 // Author: Lasse Collin |
7 // | 7 // |
8 // This file has been put into the public domain. | 8 // This file has been put into the public domain. |
9 // You can do whatever you want with this file. | 9 // You can do whatever you want with this file. |
10 // | 10 // |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 // Detect the file format. For now this is simple, since if | 47 // Detect the file format. For now this is simple, since if |
48 // it doesn't start with 0xFD (the first magic byte of the | 48 // it doesn't start with 0xFD (the first magic byte of the |
49 // new format), it has to be LZMA_Alone, or something that | 49 // new format), it has to be LZMA_Alone, or something that |
50 // we don't support at all. | 50 // we don't support at all. |
51 if (in[*in_pos] == 0xFD) { | 51 if (in[*in_pos] == 0xFD) { |
52 return_if_error(lzma_stream_decoder_init( | 52 return_if_error(lzma_stream_decoder_init( |
53 &coder->next, allocator, | 53 &coder->next, allocator, |
54 coder->memlimit, coder->flags)); | 54 coder->memlimit, coder->flags)); |
55 } else { | 55 } else { |
56 return_if_error(lzma_alone_decoder_init(&coder->next, | 56 return_if_error(lzma_alone_decoder_init(&coder->next, |
57 » » » » » allocator, coder->memlimit)); | 57 » » » » » allocator, coder->memlimit, true)); |
58 | 58 |
59 // If the application wants to know about missing | 59 // If the application wants to know about missing |
60 // integrity check or about the check in general, we | 60 // integrity check or about the check in general, we |
61 // need to handle it here, because LZMA_Alone decoder | 61 // need to handle it here, because LZMA_Alone decoder |
62 // doesn't accept any flags. | 62 // doesn't accept any flags. |
63 if (coder->flags & LZMA_TELL_NO_CHECK) | 63 if (coder->flags & LZMA_TELL_NO_CHECK) |
64 return LZMA_NO_CHECK; | 64 return LZMA_NO_CHECK; |
65 | 65 |
66 if (coder->flags & LZMA_TELL_ANY_CHECK) | 66 if (coder->flags & LZMA_TELL_ANY_CHECK) |
67 return LZMA_GET_CHECK; | 67 return LZMA_GET_CHECK; |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 extern LZMA_API(lzma_ret) | 177 extern LZMA_API(lzma_ret) |
178 lzma_auto_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags) | 178 lzma_auto_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags) |
179 { | 179 { |
180 lzma_next_strm_init(auto_decoder_init, strm, memlimit, flags); | 180 lzma_next_strm_init(auto_decoder_init, strm, memlimit, flags); |
181 | 181 |
182 strm->internal->supported_actions[LZMA_RUN] = true; | 182 strm->internal->supported_actions[LZMA_RUN] = true; |
183 strm->internal->supported_actions[LZMA_FINISH] = true; | 183 strm->internal->supported_actions[LZMA_FINISH] = true; |
184 | 184 |
185 return LZMA_OK; | 185 return LZMA_OK; |
186 } | 186 } |
OLD | NEW |