21mapper_init(
struct SqshMapper *mapper,
const void *input, uint64_t *size) {
27 file = fopen(input,
"r");
33 pos = fseek(file, 0, SEEK_END);
40 sqsh_mapper_set_user_data(mapper, file);
54 const struct SqshMapper *mapper, uint64_t offset,
size_t size,
57 FILE *file = sqsh_mapper_user_data(mapper);
59 *data = calloc(size,
sizeof(uint8_t));
64 rv = fseek(file, offset, SEEK_SET);
70 if (fread(*data,
sizeof(uint8_t), size, file) != size) {
86mapper_unmap(
const struct SqshMapper *mapper, uint8_t *data,
size_t size) {
97 FILE *file = sqsh_mapper_user_data(mapper);
107 .init2 = mapper_init,
109 .unmap = mapper_unmap,
110 .cleanup = mapper_cleanup,
116 fprintf(stderr,
"Usage: %s <file>\n", argv[0]);
124 assert(archive != NULL);
int main(int argc, char *argv[])
@ SQSH_ERROR_MALLOC_FAILED
SQSH_NO_UNUSED struct SqshArchive * sqsh_archive_open(const void *source, const struct SqshConfig *config, int *err)
initializes a archive context in heap.
int sqsh_archive_close(struct SqshArchive *archive)
Frees the resources used by a Sqsh instance.
The SqshConfig struct contains all the configuration options for a sqsh session.
const struct SqshMemoryMapperImpl * source_mapper
source_mapper is the memory mapper implementation that will be used to map the archive.
The mapper that is used to map chunks of the archive into memory.
The implementation of a memory mapper.
size_t block_size_hint
A hint to libsqsh to use this block size if the user did not specify one.