aboutsummaryrefslogtreecommitdiff
path: root/lib/fstream/internal.h
blob: 2dc81e442e82fa73c3a86a88353711a305505cc2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/* SPDX-License-Identifier: GPL-3.0-or-later */
/*
 * internal.h
 *
 * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
 */
#ifndef INTERNAL_H
#define INTERNAL_H

#include "config.h"
#include "compat.h"
#include "fstream.h"

#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <stdio.h>

#define BUFSZ (262144)

typedef struct ostream_comp_t {
	ostream_t base;

	ostream_t *wrapped;

	size_t inbuf_used;

	sqfs_u8 inbuf[BUFSZ];
	sqfs_u8 outbuf[BUFSZ];

	int (*flush_inbuf)(struct ostream_comp_t *ostrm, bool finish);

	void (*cleanup)(struct ostream_comp_t *ostrm);
} ostream_comp_t;

typedef struct istream_comp_t {
	istream_t base;

	istream_t *wrapped;

	sqfs_u8 uncompressed[BUFSZ];

	bool eof;

	void (*cleanup)(struct istream_comp_t *strm);
} istream_comp_t;

#ifdef __cplusplus
extern "C" {
#endif

SQFS_INTERNAL ostream_comp_t *ostream_gzip_create(const char *filename);

SQFS_INTERNAL ostream_comp_t *ostream_xz_create(const char *filename);

SQFS_INTERNAL ostream_comp_t *ostream_zstd_create(const char *filename);

SQFS_INTERNAL ostream_comp_t *ostream_bzip2_create(const char *filename);

SQFS_INTERNAL istream_comp_t *istream_gzip_create(const char *filename);

SQFS_INTERNAL istream_comp_t *istream_xz_create(const char *filename);

SQFS_INTERNAL istream_comp_t *istream_zstd_create(const char *filename);

SQFS_INTERNAL istream_comp_t *istream_bzip2_create(const char *filename);

#ifdef __cplusplus
}
#endif

#endif /* INTERNAL_H */