Rizin
unix-like reverse engineering framework and cli tools
stream_flags_encoder.c File Reference

Encodes Stream Header and Stream Footer for .xz files. More...

Go to the source code of this file.

Functions

static bool stream_flags_encode (const lzma_stream_flags *options, uint8_t *out)
 
 LZMA_API (lzma_ret)
 

Detailed Description

Encodes Stream Header and Stream Footer for .xz files.

Definition in file stream_flags_encoder.c.

Function Documentation

◆ LZMA_API()

LZMA_API ( lzma_ret  )

Definition at line 29 of file stream_flags_encoder.c.

31 {
34 
35  if (options->version != 0)
36  return LZMA_OPTIONS_ERROR;
37 
38  // Magic
40 
41  // Stream Flags
43  return LZMA_PROG_ERROR;
44 
45  // CRC32 of the Stream Header
46  const uint32_t crc = lzma_crc32(out + sizeof(lzma_header_magic),
48 
50  crc);
51 
52  return LZMA_OK;
53 }
const lzma_allocator const uint8_t size_t uint8_t * out
Definition: block.h:528
memcpy(mem, inblock.get(), min(CONTAINING_RECORD(inblock.get(), MEMBLOCK, data) ->size, size))
static const char struct stat static buf struct stat static buf static vhangup int options
Definition: sflib.h:145
assert(limit<=UINT32_MAX/2)
unsigned int uint32_t
Definition: sftypes.h:29
#define LZMA_STREAM_HEADER_SIZE
Size of Stream Header and Stream Footer.
Definition: stream_flags.h:27
const uint8_t lzma_header_magic[6]
#define LZMA_STREAM_FLAGS_SIZE
Size of the Stream Flags field.
static bool stream_flags_encode(const lzma_stream_flags *options, uint8_t *out)
#define write32le(buf, num)
@ LZMA_PROG_ERROR
Programming error.
Definition: base.h:218
@ LZMA_OPTIONS_ERROR
Invalid or unsupported options.
Definition: base.h:160
@ LZMA_OK
Operation completed successfully.
Definition: base.h:58

References assert(), lzma_header_magic, LZMA_OK, LZMA_OPTIONS_ERROR, LZMA_PROG_ERROR, LZMA_STREAM_FLAGS_SIZE, LZMA_STREAM_HEADER_SIZE, memcpy(), options, out, stream_flags_encode(), and write32le.

◆ stream_flags_encode()

static bool stream_flags_encode ( const lzma_stream_flags options,
uint8_t out 
)
static

Definition at line 17 of file stream_flags_encoder.c.

18 {
19  if ((unsigned int)(options->check) > LZMA_CHECK_ID_MAX)
20  return true;
21 
22  out[0] = 0x00;
23  out[1] = options->check;
24 
25  return false;
26 }
#define LZMA_CHECK_ID_MAX
Maximum valid Check ID.
Definition: check.h:68

References LZMA_CHECK_ID_MAX, options, and out.

Referenced by LZMA_API().