Rizin
unix-like reverse engineering framework and cli tools
filter_flags_encoder.c
Go to the documentation of this file.
1 //
5 //
6 // Author: Lasse Collin
7 //
8 // This file has been put into the public domain.
9 // You can do whatever you want with this file.
10 //
12 
13 #include "filter_encoder.h"
14 
15 
17 lzma_filter_flags_size(uint32_t *size, const lzma_filter *filter)
18 {
20  return LZMA_PROG_ERROR;
21 
22  return_if_error(lzma_properties_size(size, filter));
23 
24  *size += lzma_vli_size(filter->id) + lzma_vli_size(*size);
25 
26  return LZMA_OK;
27 }
28 
29 
30 extern LZMA_API(lzma_ret)
31 lzma_filter_flags_encode(const lzma_filter *filter,
32  uint8_t *out, size_t *out_pos, size_t out_size)
33 {
34  // Filter ID
36  return LZMA_PROG_ERROR;
37 
38  return_if_error(lzma_vli_encode(filter->id, NULL,
39  out, out_pos, out_size));
40 
41  // Size of Properties
42  uint32_t props_size;
43  return_if_error(lzma_properties_size(&props_size, filter));
44  return_if_error(lzma_vli_encode(props_size, NULL,
45  out, out_pos, out_size));
46 
47  // Filter Properties
48  if (out_size - *out_pos < props_size)
49  return LZMA_PROG_ERROR;
50 
51  return_if_error(lzma_properties_encode(filter, out + *out_pos));
52 
53  *out_pos += props_size;
54 
55  return LZMA_OK;
56 }
const lzma_allocator const uint8_t size_t uint8_t size_t * out_pos
Definition: block.h:528
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
#define NULL
Definition: cris-opc.c:27
LZMA_API(lzma_ret)
voidpf void uLong size
Definition: ioapi.h:138
unsigned int uint32_t
Definition: sftypes.h:29
unsigned char uint8_t
Definition: sftypes.h:31
Filter options.
Definition: filter.h:43
#define return_if_error(expr)
Return if expression doesn't evaluate to LZMA_OK.
Definition: common.h:278
#define LZMA_FILTER_RESERVED_START
Definition: common.h:67
lzma_ret
Return values used by several functions in liblzma.
Definition: base.h:57
@ LZMA_PROG_ERROR
Programming error.
Definition: base.h:218
@ LZMA_OK
Operation completed successfully.
Definition: base.h:58