auto_decoder.c | auto_decoder.c | |||
---|---|---|---|---|
skipping to change at line 31 | skipping to change at line 31 | |||
uint32_t flags; | uint32_t flags; | |||
enum { | enum { | |||
SEQ_INIT, | SEQ_INIT, | |||
SEQ_CODE, | SEQ_CODE, | |||
SEQ_FINISH, | SEQ_FINISH, | |||
} sequence; | } sequence; | |||
}; | }; | |||
static lzma_ret | static lzma_ret | |||
auto_decode(lzma_coder *coder, lzma_allocator *allocator, | auto_decode(lzma_coder *coder, const lzma_allocator *allocator, | |||
const uint8_t *restrict in, size_t *restrict in_pos, | const uint8_t *restrict in, size_t *restrict in_pos, | |||
size_t in_size, uint8_t *restrict out, | size_t in_size, uint8_t *restrict out, | |||
size_t *restrict out_pos, size_t out_size, lzma_action actio n) | size_t *restrict out_pos, size_t out_size, lzma_action actio n) | |||
{ | { | |||
switch (coder->sequence) { | switch (coder->sequence) { | |||
case SEQ_INIT: | case SEQ_INIT: | |||
if (*in_pos >= in_size) | if (*in_pos >= in_size) | |||
return LZMA_OK; | return LZMA_OK; | |||
// Update the sequence now, because we want to continue from | // Update the sequence now, because we want to continue from | |||
skipping to change at line 55 | skipping to change at line 55 | |||
// Detect the file format. For now this is simple, since if | // Detect the file format. For now this is simple, since if | |||
// it doesn't start with 0xFD (the first magic byte of the | // it doesn't start with 0xFD (the first magic byte of the | |||
// new format), it has to be LZMA_Alone, or something that | // new format), it has to be LZMA_Alone, or something that | |||
// we don't support at all. | // we don't support at all. | |||
if (in[*in_pos] == 0xFD) { | if (in[*in_pos] == 0xFD) { | |||
return_if_error(lzma_stream_decoder_init( | return_if_error(lzma_stream_decoder_init( | |||
&coder->next, allocator, | &coder->next, allocator, | |||
coder->memlimit, coder->flags)); | coder->memlimit, coder->flags)); | |||
} else { | } else { | |||
return_if_error(lzma_alone_decoder_init(&coder->next , | return_if_error(lzma_alone_decoder_init(&coder->next , | |||
allocator, coder->memlimit)); | allocator, coder->memlimit, true)); | |||
// If the application wants to know about missing | // If the application wants to know about missing | |||
// integrity check or about the check in general, we | // integrity check or about the check in general, we | |||
// need to handle it here, because LZMA_Alone decode r | // need to handle it here, because LZMA_Alone decode r | |||
// doesn't accept any flags. | // doesn't accept any flags. | |||
if (coder->flags & LZMA_TELL_NO_CHECK) | if (coder->flags & LZMA_TELL_NO_CHECK) | |||
return LZMA_NO_CHECK; | return LZMA_NO_CHECK; | |||
if (coder->flags & LZMA_TELL_ANY_CHECK) | if (coder->flags & LZMA_TELL_ANY_CHECK) | |||
return LZMA_GET_CHECK; | return LZMA_GET_CHECK; | |||
skipping to change at line 100 | skipping to change at line 100 | |||
return action == LZMA_FINISH ? LZMA_STREAM_END : LZMA_OK; | return action == LZMA_FINISH ? LZMA_STREAM_END : LZMA_OK; | |||
default: | default: | |||
assert(0); | assert(0); | |||
return LZMA_PROG_ERROR; | return LZMA_PROG_ERROR; | |||
} | } | |||
} | } | |||
static void | static void | |||
auto_decoder_end(lzma_coder *coder, lzma_allocator *allocator) | auto_decoder_end(lzma_coder *coder, const lzma_allocator *allocator) | |||
{ | { | |||
lzma_next_end(&coder->next, allocator); | lzma_next_end(&coder->next, allocator); | |||
lzma_free(coder, allocator); | lzma_free(coder, allocator); | |||
return; | return; | |||
} | } | |||
static lzma_check | static lzma_check | |||
auto_decoder_get_check(const lzma_coder *coder) | auto_decoder_get_check(const lzma_coder *coder) | |||
{ | { | |||
// It is LZMA_Alone if get_check is NULL. | // It is LZMA_Alone if get_check is NULL. | |||
skipping to change at line 140 | skipping to change at line 140 | |||
ret = LZMA_OK; | ret = LZMA_OK; | |||
} | } | |||
if (ret == LZMA_OK && new_memlimit != 0) | if (ret == LZMA_OK && new_memlimit != 0) | |||
coder->memlimit = new_memlimit; | coder->memlimit = new_memlimit; | |||
return ret; | return ret; | |||
} | } | |||
static lzma_ret | static lzma_ret | |||
auto_decoder_init(lzma_next_coder *next, lzma_allocator *allocator, | auto_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator, | |||
uint64_t memlimit, uint32_t flags) | uint64_t memlimit, uint32_t flags) | |||
{ | { | |||
lzma_next_coder_init(&auto_decoder_init, next, allocator); | lzma_next_coder_init(&auto_decoder_init, next, allocator); | |||
if (memlimit == 0) | if (memlimit == 0) | |||
return LZMA_PROG_ERROR; | return LZMA_PROG_ERROR; | |||
if (flags & ~LZMA_SUPPORTED_FLAGS) | if (flags & ~LZMA_SUPPORTED_FLAGS) | |||
return LZMA_OPTIONS_ERROR; | return LZMA_OPTIONS_ERROR; | |||
End of changes. 4 change blocks. | ||||
4 lines changed or deleted | 4 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |