1 ///////////////////////////////////////////////////////////////////////////////
3 /// \file filter_flags_decoder.c
4 /// \brief Decodes a Filter Flags field
6 // Copyright (C) 2007 Lasse Collin
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Lesser General Public
10 // License as published by the Free Software Foundation; either
11 // version 2.1 of the License, or (at your option) any later version.
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Lesser General Public License for more details.
18 ///////////////////////////////////////////////////////////////////////////////
20 #include "filter_decoder.h"
23 extern LZMA_API lzma_ret
24 lzma_filter_flags_decode(
25 lzma_filter *filter, lzma_allocator *allocator,
26 const uint8_t *in, size_t *in_pos, size_t in_size)
28 // Set the pointer to NULL so the caller can always safely free it.
29 filter->options = NULL;
32 return_if_error(lzma_vli_decode(&filter->id, NULL,
33 in, in_pos, in_size));
35 if (filter->id >= LZMA_FILTER_RESERVED_START)
36 return LZMA_DATA_ERROR;
40 return_if_error(lzma_vli_decode(&props_size, NULL,
41 in, in_pos, in_size));
44 if (in_size - *in_pos < props_size)
45 return LZMA_DATA_ERROR;
47 const lzma_ret ret = lzma_properties_decode(
48 filter, allocator, in + *in_pos, props_size);
50 *in_pos += props_size;