1207753Smm/////////////////////////////////////////////////////////////////////////////// 2207753Smm// 3207753Smm/// \file simple_decoder.c 4207753Smm/// \brief Properties decoder for simple filters 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 "simple_decoder.h" 14207753Smm 15207753Smm 16207753Smmextern lzma_ret 17207753Smmlzma_simple_props_decode(void **options, lzma_allocator *allocator, 18207753Smm const uint8_t *props, size_t props_size) 19207753Smm{ 20207753Smm if (props_size == 0) 21207753Smm return LZMA_OK; 22207753Smm 23207753Smm if (props_size != 4) 24207753Smm return LZMA_OPTIONS_ERROR; 25207753Smm 26207753Smm lzma_options_bcj *opt = lzma_alloc( 27207753Smm sizeof(lzma_options_bcj), allocator); 28207753Smm if (opt == NULL) 29207753Smm return LZMA_MEM_ERROR; 30207753Smm 31207753Smm opt->start_offset = unaligned_read32le(props); 32207753Smm 33207753Smm // Don't leave an options structure allocated if start_offset is zero. 34207753Smm if (opt->start_offset == 0) 35207753Smm lzma_free(opt, allocator); 36207753Smm else 37207753Smm *options = opt; 38207753Smm 39207753Smm return LZMA_OK; 40207753Smm} 41