Rizin
unix-like reverse engineering framework and cli tools
index.h
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 #ifndef LZMA_INDEX_H
14 #define LZMA_INDEX_H
15 
16 #include "common.h"
17 
18 
20 #define UNPADDED_SIZE_MIN LZMA_VLI_C(5)
21 
23 #define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))
24 
25 
29 
30 
34 extern void lzma_index_prealloc(lzma_index *i, lzma_vli records);
35 
36 
38 static inline lzma_vli
40 {
41  assert(vli <= LZMA_VLI_MAX);
42  return (vli + 3) & ~LZMA_VLI_C(3);
43 }
44 
45 
47 static inline lzma_vli
49 {
50  // Index Indicator + Number of Records + List of Records + CRC32
51  return 1 + lzma_vli_size(count) + index_list_size + 4;
52 }
53 
54 
56 static inline lzma_vli
57 index_size(lzma_vli count, lzma_vli index_list_size)
58 {
59  return vli_ceil4(index_size_unpadded(count, index_list_size));
60 }
61 
62 
64 static inline lzma_vli
66  lzma_vli count, lzma_vli index_list_size)
67 {
68  return LZMA_STREAM_HEADER_SIZE + blocks_size
69  + index_size(count, index_list_size)
71 }
72 
73 #endif
lzma_index ** i
Definition: index.h:629
void lzma_index_prealloc(lzma_index *i, lzma_vli records)
Definition: index.c:431
static lzma_vli index_stream_size(lzma_vli blocks_size, lzma_vli count, lzma_vli index_list_size)
Calculate the total size of the Stream.
Definition: index.h:65
static lzma_vli vli_ceil4(lzma_vli vli)
Round the variable-length integer to the next multiple of four.
Definition: index.h:39
static lzma_vli index_size(lzma_vli count, lzma_vli index_list_size)
Calculate the size of the Index field including Index Padding.
Definition: index.h:57
static lzma_vli index_size_unpadded(lzma_vli count, lzma_vli index_list_size)
Calculate the size of the Index field excluding Index Padding.
Definition: index.h:48
uint32_t lzma_index_padding_size(const lzma_index *i)
Definition: index.c:593
static static sync static getppid static getegid const char static filename char static len const char char static bufsiz static mask static vfork const void static prot static getpgrp const char static swapflags static arg static fd static protocol static who struct sockaddr static addrlen static backlog struct timeval struct timezone static tz const struct iovec static count static mode const void const struct sockaddr static tolen const char static pathname void count
Definition: sflib.h:98
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
Definitions common to the whole liblzma library.
uint64_t lzma_vli
Variable-length integer type.
Definition: vli.h:63
#define LZMA_VLI_C(n)
VLI constant suffix.
Definition: vli.h:49
#define LZMA_VLI_MAX
Maximum supported value of a variable-length integer.
Definition: vli.h:34