summaryrefslogtreecommitdiff
path: root/lib/io/internal.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-06-26 22:51:27 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-07-08 19:17:35 +0200
commit359d71e90050a8b83f7bc7d2ecd4ff29c477cc22 (patch)
treedf2b7a585b78e6776446d4ca9be62a22db27f0a7 /lib/io/internal.h
parent2087cc237cd0fe1ed29ebf891648bacb46f4833b (diff)
Cleanup: rename libfstream to libio, split headers
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/io/internal.h')
-rw-r--r--lib/io/internal.h81
1 files changed, 81 insertions, 0 deletions
diff --git a/lib/io/internal.h b/lib/io/internal.h
new file mode 100644
index 0000000..4ac38f5
--- /dev/null
+++ b/lib/io/internal.h
@@ -0,0 +1,81 @@
+/* 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 "io/istream.h"
+#include "io/ostream.h"
+#include "io/file.h"
+#include "io/xfrm.h"
+#include "io/std.h"
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <ctype.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 */