libsqsh v1.5.1
Loading...
Searching...
No Matches
sqsh_extract_private.h
Go to the documentation of this file.
1/******************************************************************************
2 * *
3 * Copyright (c) 2023-2024, Enno Boland <g@s01.de> *
4 * *
5 * Redistribution and use in source and binary forms, with or without *
6 * modification, are permitted provided that the following conditions are *
7 * met: *
8 * *
9 * * Redistributions of source code must retain the above copyright notice, *
10 * this list of conditions and the following disclaimer. *
11 * * Redistributions in binary form must reproduce the above copyright *
12 * notice, this list of conditions and the following disclaimer in the *
13 * documentation and/or other materials provided with the distribution. *
14 * *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS *
16 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, *
17 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR *
18 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR *
19 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
20 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
21 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
22 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
23 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
24 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
26 * *
27 ******************************************************************************/
28
34#ifndef SQSH_EXTRACT_PRIVATE_H
35#define SQSH_EXTRACT_PRIVATE_H
36
37#include <cextras/collection.h>
38
39#include <sqsh_data.h>
40#include <sqsh_utils_private.h>
41
42#ifdef __cplusplus
43extern "C" {
44#endif
45
46struct SqshArchive;
47struct SqshMapReader;
48
49/***************************************
50 * extract/extractor2.c
51 */
52
57typedef uint8_t sqsh__extractor_context_t[256];
58
64extern const struct SqshExtractorImpl *const volatile sqsh__impl_lzo;
65
75 int (*init)(void *context, uint8_t *target, size_t target_size);
79 int (*write)(
80 void *context, const uint8_t *compressed,
81 const size_t compressed_size);
85 int (*finish)(void *context, uint8_t *target, size_t *target_size);
86};
87
95 struct CxBuffer *buffer;
96 const struct SqshExtractorImpl *impl;
98 uint8_t *target;
99 size_t block_size;
100};
101
114
128 struct SqshExtractor *extractor, struct CxBuffer *buffer,
129 const struct SqshExtractorImpl *impl, size_t block_size);
130
143 struct SqshExtractor *extractor, const uint8_t *compressed,
144 const size_t compressed_size);
145
156
167
168/***************************************
169 * extract/extract_manager.c
170 */
171
179 struct CxRcRadixTree cache;
180 const struct SqshExtractorImpl *extractor_impl;
181 uint32_t block_size;
182 struct SqshMapManager *map_manager;
183 struct CxLru lru;
184 sqsh__mutex_t lock;
185};
186
200 struct SqshExtractManager *manager, struct SqshArchive *archive,
201 uint32_t block_size, size_t lru_size);
202
215 struct SqshExtractManager *manager, const struct SqshMapReader *reader,
216 const struct CxBuffer **target);
217
229 struct SqshExtractManager *manager, uint64_t address);
230
242
243/***************************************
244 * extract/extract_view.c
245 */
246
254 struct SqshExtractManager *manager;
255 const struct CxBuffer *buffer;
256 uint64_t address;
257 size_t size;
258};
259
272 struct SqshExtractView *view, struct SqshExtractManager *manager,
273 const struct SqshMapReader *reader);
274
284SQSH_NO_EXPORT const uint8_t *
286
296SQSH_NO_EXPORT size_t
298
309
310/***************************************
311 * extract/lz4.c
312 */
313
317SQSH_NO_EXPORT extern const struct SqshExtractorImpl *const sqsh__impl_lz4;
318/***************************************
319 * extract/lzma.c
320 */
321
325SQSH_NO_EXPORT extern const struct SqshExtractorImpl *const sqsh__impl_lzma;
329SQSH_NO_EXPORT extern const struct SqshExtractorImpl *const sqsh__impl_xz;
330
331/***************************************
332 * extract/zlib.c
333 */
334
338SQSH_NO_EXPORT extern const struct SqshExtractorImpl *const sqsh__impl_zlib;
339
340/***************************************
341 * extract/zstd.c
342 */
343
347SQSH_NO_EXPORT extern const struct SqshExtractorImpl *const sqsh__impl_zstd;
348
349#ifdef __cplusplus
350}
351#endif
352#endif /* SQSH_EXTRACT_PRIVATE_H */
#define SQSH_NO_EXPORT
Do not export symbol.
Definition sqsh_common.h:64
#define SQSH_NO_UNUSED
Warn if return value is unused.
Definition sqsh_common.h:59
SqshSuperblockCompressionId
The compression used in the archive.
Definition sqsh_data.h:50
SQSH_NO_EXPORT int sqsh__extractor_cleanup(struct SqshExtractor *extractor)
SQSH_NO_EXPORT int sqsh__extract_manager_release(struct SqshExtractManager *manager, uint64_t address)
SQSH_NO_EXPORT const struct SqshExtractorImpl *const sqsh__impl_xz
The implementation of the xz extractor.
SQSH_NO_EXPORT const struct SqshExtractorImpl *const sqsh__impl_zlib
The implementation of the zlib extractor.
SQSH_NO_EXPORT const struct SqshExtractorImpl *const sqsh__impl_zstd
The implementation of the zstd extractor.
SQSH_NO_EXPORT const struct SqshExtractorImpl *const sqsh__impl_lz4
The implementation of the lz4 extractor.
SQSH_NO_EXPORT const uint8_t * sqsh__extract_view_data(const struct SqshExtractView *view)
SQSH_NO_EXPORT size_t sqsh__extract_view_size(const struct SqshExtractView *view)
uint8_t sqsh__extractor_context_t[256]
SQSH_NO_EXPORT const struct SqshExtractorImpl *const sqsh__impl_lzma
The implementation of the lzma extractor.
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__extractor_init(struct SqshExtractor *extractor, struct CxBuffer *buffer, const struct SqshExtractorImpl *impl, size_t block_size)
SQSH_NO_EXPORT int sqsh__extract_view_cleanup(struct SqshExtractView *view)
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__extract_manager_init(struct SqshExtractManager *manager, struct SqshArchive *archive, uint32_t block_size, size_t lru_size)
SQSH_NO_EXPORT int sqsh__extractor_finish(struct SqshExtractor *extractor)
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__extract_view_init(struct SqshExtractView *view, struct SqshExtractManager *manager, const struct SqshMapReader *reader)
const struct SqshExtractorImpl *const volatile sqsh__impl_lzo
The implementation of the lzo extractor. This is NULL by default. If you want to use this,...
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__extractor_write(struct SqshExtractor *extractor, const uint8_t *compressed, const size_t compressed_size)
SQSH_NO_EXPORT int sqsh__extract_manager_cleanup(struct SqshExtractManager *manager)
SQSH_NO_EXPORT int sqsh__extract_manager_uncompress(struct SqshExtractManager *manager, const struct SqshMapReader *reader, const struct CxBuffer **target)
SQSH_NO_EXPORT const struct SqshExtractorImpl * sqsh__extractor_impl_from_id(enum SqshSuperblockCompressionId id)
Manages chunks of compressed areas from an archive.
A fiew into compressed memory managed by a SqshExtractManager.
int(* init)(void *context, uint8_t *target, size_t target_size)
Function that is called to initialize the extractor context.
int(* write)(void *context, const uint8_t *compressed, const size_t compressed_size)
Function that is called when new data is available.
int(* finish)(void *context, uint8_t *target, size_t *target_size)
Function that is called to finish the extraction.
The SqshExtractor struct is used to decompress data.
The map manager.
A reader over a mapping of data.