1207753Smm/////////////////////////////////////////////////////////////////////////////// 2207753Smm// 3207753Smm/// \file filter_flags_decoder.c 4207753Smm/// \brief Decodes a Filter Flags field 5207753Smm// 6207753Smm// Author: Lasse Collin 7207753Smm// 8207753Smm// This file has been put into the public domain. 9207753Smm// You can do whatever you want with this file. 10207753Smm// 11207753Smm/////////////////////////////////////////////////////////////////////////////// 12207753Smm 13207753Smm#include "filter_decoder.h" 14207753Smm 15207753Smm 16207753Smmextern LZMA_API(lzma_ret) 17207753Smmlzma_filter_flags_decode( 18292588Sdelphij lzma_filter *filter, const lzma_allocator *allocator, 19207753Smm const uint8_t *in, size_t *in_pos, size_t in_size) 20207753Smm{ 21207753Smm // Set the pointer to NULL so the caller can always safely free it. 22207753Smm filter->options = NULL; 23207753Smm 24207753Smm // Filter ID 25207753Smm return_if_error(lzma_vli_decode(&filter->id, NULL, 26207753Smm in, in_pos, in_size)); 27207753Smm 28207753Smm if (filter->id >= LZMA_FILTER_RESERVED_START) 29207753Smm return LZMA_DATA_ERROR; 30207753Smm 31207753Smm // Size of Properties 32207753Smm lzma_vli props_size; 33207753Smm return_if_error(lzma_vli_decode(&props_size, NULL, 34207753Smm in, in_pos, in_size)); 35207753Smm 36207753Smm // Filter Properties 37207753Smm if (in_size - *in_pos < props_size) 38207753Smm return LZMA_DATA_ERROR; 39207753Smm 40207753Smm const lzma_ret ret = lzma_properties_decode( 41207753Smm filter, allocator, in + *in_pos, props_size); 42207753Smm 43207753Smm *in_pos += props_size; 44207753Smm 45207753Smm return ret; 46207753Smm} 47