libsqsh v1.5.1
Loading...
Searching...
No Matches
sqsh_mapper.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_MAPPER_H
35#define SQSH_MAPPER_H
36
37#include <sqsh_common.h>
38#include <stddef.h>
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/***************************************
45 * mapper/mapper.c
46 */
47
48struct SqshMapper;
49
64#ifndef SQSH__NO_DEPRECATED_FIELD
65 __attribute__((deprecated("Since 1.5.0. Use init2() instead.")))
66#endif
67 int (*init)(struct SqshMapper *mapper, const void *input, size_t *size);
72#ifndef SQSH__NO_DEPRECATED_FIELD
73 __attribute__((deprecated("Since 1.5.0. Use init2() instead.")))
74#endif
75 int (*map)(
76 const struct SqshMapper *mapper, sqsh_index_t offset, size_t size,
77 uint8_t **data);
81 int (*unmap)(const struct SqshMapper *mapper, uint8_t *data, size_t size);
85 int (*cleanup)(struct SqshMapper *mapper);
91 int (*init2)(struct SqshMapper *mapper, const void *input, uint64_t *size);
95 int (*map2)(
96 const struct SqshMapper *mapper, uint64_t offset, size_t size,
97 uint8_t **data);
98};
99
107void sqsh_mapper_set_user_data(struct SqshMapper *mapper, void *user_data);
108
117void *sqsh_mapper_user_data(const struct SqshMapper *mapper);
118
129__attribute__((deprecated("Since 1.5.0. Use sqsh_mapper_size2() instead.")))
130size_t
131sqsh_mapper_size(const struct SqshMapper *mapper);
132
142uint64_t sqsh_mapper_size2(const struct SqshMapper *mapper);
143
153size_t sqsh_mapper_block_size(const struct SqshMapper *mapper);
154
155/***************************************
156 * mapper/curl_mapper.c
157 */
158
162extern const struct SqshMemoryMapperImpl *const sqsh_mapper_impl_curl;
163
164/***************************************
165 * mapper/mmap_mapper.c
166 */
167
171extern const struct SqshMemoryMapperImpl *const sqsh_mapper_impl_mmap;
172
173/***************************************
174 * mapper/static_mapper.c
175 */
176
180extern const struct SqshMemoryMapperImpl *const sqsh_mapper_impl_static;
181
182#ifdef __cplusplus
183}
184#endif
185#endif /* SQSH_MAPPER_H */
size_t sqsh_index_t
typedef used for indexing
Definition sqsh_common.h:69
const struct SqshMemoryMapperImpl *const sqsh_mapper_impl_mmap
a mapper that uses mmap to map the file into memory.
const struct SqshMemoryMapperImpl *const sqsh_mapper_impl_static
a mapper that uses a static buffer.
size_t sqsh_mapper_block_size(const struct SqshMapper *mapper)
size_t sqsh_mapper_size(const struct SqshMapper *mapper)
uint64_t sqsh_mapper_size2(const struct SqshMapper *mapper)
const struct SqshMemoryMapperImpl *const sqsh_mapper_impl_curl
a mapper that uses curl to download the file.
The mapper that is used to map chunks of the archive into memory.
void sqsh_mapper_set_user_data(struct SqshMapper *mapper, void *user_data)
Sets the user data for a mapper.
void * sqsh_mapper_user_data(const struct SqshMapper *mapper)
Retrieves the user data from a mapper.
The implementation of a memory mapper.
Definition sqsh_mapper.h:53
int(* init2)(struct SqshMapper *mapper, const void *input, uint64_t *size)
The initialization function for the mapper. Use sqsh_mapper_set_user_data() to set custom user data.
Definition sqsh_mapper.h:91
int(* map2)(const struct SqshMapper *mapper, uint64_t offset, size_t size, uint8_t **data)
The function that maps a block of data into memory.
Definition sqsh_mapper.h:95
int(* map)(const struct SqshMapper *mapper, sqsh_index_t offset, size_t size, uint8_t **data)
The function that maps a block of data into memory.
Definition sqsh_mapper.h:75
int(* unmap)(const struct SqshMapper *mapper, uint8_t *data, size_t size)
The function that unmaps a block of data from memory.
Definition sqsh_mapper.h:81
int(* init)(struct SqshMapper *mapper, const void *input, size_t *size)
The initialization function for the mapper. Use sqsh_mapper_set_user_data() to set custom user data.
Definition sqsh_mapper.h:67
int(* cleanup)(struct SqshMapper *mapper)
The cleanup function for the mapper.
Definition sqsh_mapper.h:85
size_t block_size_hint
A hint to libsqsh to use this block size if the user did not specify one.
Definition sqsh_mapper.h:58