libsqsh
v1.5.1
Loading...
Searching...
No Matches
libsqsh
include
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
43
extern
"C"
{
44
#endif
45
46
struct
SqshArchive
;
47
struct
SqshMapReader
;
48
49
/***************************************
50
* extract/extractor2.c
51
*/
52
57
typedef
uint8_t
sqsh__extractor_context_t
[256];
58
64
extern
const
struct
SqshExtractorImpl
*
const
volatile
sqsh__impl_lzo
;
65
71
struct
SqshExtractorImpl
{
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
91
struct
SqshExtractor
{
95
struct
CxBuffer *buffer;
96
const
struct
SqshExtractorImpl
*impl;
97
sqsh__extractor_context_t
context;
98
uint8_t *target;
99
size_t
block_size;
100
};
101
112
SQSH_NO_EXPORT
const
struct
SqshExtractorImpl
*
113
sqsh__extractor_impl_from_id
(
enum
SqshSuperblockCompressionId
id
);
114
127
SQSH_NO_EXPORT
SQSH_NO_UNUSED
int
sqsh__extractor_init
(
128
struct
SqshExtractor
*extractor,
struct
CxBuffer *buffer,
129
const
struct
SqshExtractorImpl
*impl,
size_t
block_size);
130
142
SQSH_NO_EXPORT
SQSH_NO_UNUSED
int
sqsh__extractor_write
(
143
struct
SqshExtractor
*extractor,
const
uint8_t *compressed,
144
const
size_t
compressed_size);
145
155
SQSH_NO_EXPORT
int
sqsh__extractor_finish
(
struct
SqshExtractor
*extractor);
156
166
SQSH_NO_EXPORT
int
sqsh__extractor_cleanup
(
struct
SqshExtractor
*extractor);
167
168
/***************************************
169
* extract/extract_manager.c
170
*/
171
175
struct
SqshExtractManager
{
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
199
SQSH_NO_EXPORT
SQSH_NO_UNUSED
int
sqsh__extract_manager_init
(
200
struct
SqshExtractManager
*manager,
struct
SqshArchive
*archive,
201
uint32_t block_size,
size_t
lru_size);
202
214
SQSH_NO_EXPORT
int
sqsh__extract_manager_uncompress
(
215
struct
SqshExtractManager
*manager,
const
struct
SqshMapReader
*reader,
216
const
struct
CxBuffer **target);
217
228
SQSH_NO_EXPORT
int
sqsh__extract_manager_release
(
229
struct
SqshExtractManager
*manager, uint64_t address);
230
240
SQSH_NO_EXPORT
int
241
sqsh__extract_manager_cleanup
(
struct
SqshExtractManager
*manager);
242
243
/***************************************
244
* extract/extract_view.c
245
*/
246
250
struct
SqshExtractView
{
254
struct
SqshExtractManager
*manager;
255
const
struct
CxBuffer *buffer;
256
uint64_t address;
257
size_t
size;
258
};
259
271
SQSH_NO_EXPORT
SQSH_NO_UNUSED
int
sqsh__extract_view_init
(
272
struct
SqshExtractView
*view,
struct
SqshExtractManager
*manager,
273
const
struct
SqshMapReader
*reader);
274
284
SQSH_NO_EXPORT
const
uint8_t *
285
sqsh__extract_view_data
(
const
struct
SqshExtractView
*view);
286
296
SQSH_NO_EXPORT
size_t
297
sqsh__extract_view_size
(
const
struct
SqshExtractView
*view);
298
308
SQSH_NO_EXPORT
int
sqsh__extract_view_cleanup
(
struct
SqshExtractView
*view);
309
310
/***************************************
311
* extract/lz4.c
312
*/
313
317
SQSH_NO_EXPORT
extern
const
struct
SqshExtractorImpl
*
const
sqsh__impl_lz4
;
318
/***************************************
319
* extract/lzma.c
320
*/
321
325
SQSH_NO_EXPORT
extern
const
struct
SqshExtractorImpl
*
const
sqsh__impl_lzma
;
329
SQSH_NO_EXPORT
extern
const
struct
SqshExtractorImpl
*
const
sqsh__impl_xz
;
330
331
/***************************************
332
* extract/zlib.c
333
*/
334
338
SQSH_NO_EXPORT
extern
const
struct
SqshExtractorImpl
*
const
sqsh__impl_zlib
;
339
340
/***************************************
341
* extract/zstd.c
342
*/
343
347
SQSH_NO_EXPORT
extern
const
struct
SqshExtractorImpl
*
const
sqsh__impl_zstd
;
348
349
#ifdef __cplusplus
350
}
351
#endif
352
#endif
/* SQSH_EXTRACT_PRIVATE_H */
SQSH_NO_EXPORT
#define SQSH_NO_EXPORT
Do not export symbol.
Definition
sqsh_common.h:64
SQSH_NO_UNUSED
#define SQSH_NO_UNUSED
Warn if return value is unused.
Definition
sqsh_common.h:59
sqsh_data.h
SqshSuperblockCompressionId
SqshSuperblockCompressionId
The compression used in the archive.
Definition
sqsh_data.h:50
sqsh__extractor_cleanup
SQSH_NO_EXPORT int sqsh__extractor_cleanup(struct SqshExtractor *extractor)
sqsh__extract_manager_release
SQSH_NO_EXPORT int sqsh__extract_manager_release(struct SqshExtractManager *manager, uint64_t address)
sqsh__impl_xz
SQSH_NO_EXPORT const struct SqshExtractorImpl *const sqsh__impl_xz
The implementation of the xz extractor.
sqsh__impl_zlib
SQSH_NO_EXPORT const struct SqshExtractorImpl *const sqsh__impl_zlib
The implementation of the zlib extractor.
sqsh__impl_zstd
SQSH_NO_EXPORT const struct SqshExtractorImpl *const sqsh__impl_zstd
The implementation of the zstd extractor.
sqsh__impl_lz4
SQSH_NO_EXPORT const struct SqshExtractorImpl *const sqsh__impl_lz4
The implementation of the lz4 extractor.
sqsh__extract_view_data
SQSH_NO_EXPORT const uint8_t * sqsh__extract_view_data(const struct SqshExtractView *view)
sqsh__extract_view_size
SQSH_NO_EXPORT size_t sqsh__extract_view_size(const struct SqshExtractView *view)
sqsh__extractor_context_t
uint8_t sqsh__extractor_context_t[256]
Definition
sqsh_extract_private.h:57
sqsh__impl_lzma
SQSH_NO_EXPORT const struct SqshExtractorImpl *const sqsh__impl_lzma
The implementation of the lzma extractor.
sqsh__extractor_init
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__extract_view_cleanup
SQSH_NO_EXPORT int sqsh__extract_view_cleanup(struct SqshExtractView *view)
sqsh__extract_manager_init
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__extractor_finish
SQSH_NO_EXPORT int sqsh__extractor_finish(struct SqshExtractor *extractor)
sqsh__extract_view_init
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__extract_view_init(struct SqshExtractView *view, struct SqshExtractManager *manager, const struct SqshMapReader *reader)
sqsh__impl_lzo
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__extractor_write
SQSH_NO_EXPORT SQSH_NO_UNUSED int sqsh__extractor_write(struct SqshExtractor *extractor, const uint8_t *compressed, const size_t compressed_size)
sqsh__extract_manager_cleanup
SQSH_NO_EXPORT int sqsh__extract_manager_cleanup(struct SqshExtractManager *manager)
sqsh__extract_manager_uncompress
SQSH_NO_EXPORT int sqsh__extract_manager_uncompress(struct SqshExtractManager *manager, const struct SqshMapReader *reader, const struct CxBuffer **target)
sqsh__extractor_impl_from_id
SQSH_NO_EXPORT const struct SqshExtractorImpl * sqsh__extractor_impl_from_id(enum SqshSuperblockCompressionId id)
SqshArchive
Definition
sqsh_archive_private.h:226
SqshExtractManager
Manages chunks of compressed areas from an archive.
Definition
sqsh_extract_private.h:175
SqshExtractView
A fiew into compressed memory managed by a SqshExtractManager.
Definition
sqsh_extract_private.h:250
SqshExtractorImpl
Definition
sqsh_extract_private.h:71
SqshExtractorImpl::init
int(* init)(void *context, uint8_t *target, size_t target_size)
Function that is called to initialize the extractor context.
Definition
sqsh_extract_private.h:75
SqshExtractorImpl::write
int(* write)(void *context, const uint8_t *compressed, const size_t compressed_size)
Function that is called when new data is available.
Definition
sqsh_extract_private.h:79
SqshExtractorImpl::finish
int(* finish)(void *context, uint8_t *target, size_t *target_size)
Function that is called to finish the extraction.
Definition
sqsh_extract_private.h:85
SqshExtractor
The SqshExtractor struct is used to decompress data.
Definition
sqsh_extract_private.h:91
SqshMapManager
The map manager.
Definition
sqsh_mapper_private.h:168
SqshMapReader
A reader over a mapping of data.
Definition
sqsh_mapper_private.h:372
Generated by
1.11.0