aboutsummaryrefslogtreecommitdiff
path: root/core/compress.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/compress.c')
-rw-r--r--core/compress.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/core/compress.c b/core/compress.c
new file mode 100644
index 0000000..df61123
--- /dev/null
+++ b/core/compress.c
@@ -0,0 +1,56 @@
+void salis_deflate(z_stream *strm, size_t size, Bytef *in, Bytef *out) {
+ assert(strm);
+ assert(size);
+ assert(in);
+ assert(out);
+
+ strm->zalloc = NULL;
+ strm->zfree = NULL;
+ strm->opaque = NULL;
+
+ deflateInit(strm, Z_DEFAULT_COMPRESSION);
+
+ strm->avail_in = size;
+ strm->avail_out = size;
+ strm->next_in = in;
+ strm->next_out = out;
+
+ deflate(strm, Z_FINISH);
+}
+
+void salis_deflate_end(z_stream *strm) {
+ assert(strm);
+
+ deflateEnd(strm);
+}
+
+void salis_inflate(z_stream *strm, size_t avail_in, size_t size, Bytef *in, Bytef *out) {
+ assert(strm);
+ assert(avail_in);
+ assert(size);
+ assert(in);
+ assert(out);
+
+ strm->next_in = in;
+ strm->avail_in = avail_in;
+ strm->zalloc = NULL;
+ strm->zfree = NULL;
+ strm->opaque = NULL;
+
+ inflateInit(strm);
+
+ strm->avail_out = size;
+ strm->next_out = out;
+
+#if defined(NDEBUG)
+ inflate(strm, Z_FINISH);
+#else
+ assert(inflate(strm, Z_FINISH));
+#endif
+}
+
+void salis_inflate_end(z_stream *strm) {
+ assert(strm);
+
+ inflateEnd(strm);
+}