aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_zlib.c
diff options
context:
space:
mode:
authorSverker Eriksson <[email protected]>2013-10-14 17:46:28 +0200
committerSverker Eriksson <[email protected]>2013-11-18 20:19:51 +0100
commitf10ea68ce28e9b93ce614b5f829b1ca7f4cc753f (patch)
treeeb3d72afb2d16189db998397a1ffdbb7649e67e2 /erts/emulator/beam/erl_zlib.c
parent38f1140d197e14f6cb4d0040859b0b19876d2a14 (diff)
downloadotp-f10ea68ce28e9b93ce614b5f829b1ca7f4cc753f.tar.gz
otp-f10ea68ce28e9b93ce614b5f829b1ca7f4cc753f.tar.bz2
otp-f10ea68ce28e9b93ce614b5f829b1ca7f4cc753f.zip
trapping uncompress
Diffstat (limited to 'erts/emulator/beam/erl_zlib.c')
-rw-r--r--erts/emulator/beam/erl_zlib.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/erts/emulator/beam/erl_zlib.c b/erts/emulator/beam/erl_zlib.c
index 47fd92988e..8e33144f96 100644
--- a/erts/emulator/beam/erl_zlib.c
+++ b/erts/emulator/beam/erl_zlib.c
@@ -87,6 +87,46 @@ int ZEXPORT erl_zlib_deflate_finish(z_stream *streamp)
return deflateEnd(streamp);
}
+int ZEXPORT erl_zlib_inflate_start(z_stream *streamp, const Bytef* source,
+ uLong sourceLen)
+{
+ streamp->next_in = (Bytef*)source;
+ streamp->avail_in = (uInt)sourceLen;
+ streamp->total_out = streamp->avail_out = 0;
+ streamp->next_out = NULL;
+ erl_zlib_alloc_init(streamp);
+ return inflateInit(streamp);
+}
+/*
+ * Inflate a chunk, The destination length is the limit.
+ * Returns Z_OK if more to process, Z_STREAM_END if we are done.
+ */
+int ZEXPORT erl_zlib_inflate_chunk(z_stream *streamp, Bytef* dest, uLongf* destLen)
+{
+ int err;
+ uLongf last_tot = streamp->total_out;
+
+ streamp->next_out = dest;
+ streamp->avail_out = (uInt)*destLen;
+
+ if ((uLong)streamp->avail_out != *destLen) return Z_BUF_ERROR;
+
+ err = inflate(streamp, Z_NO_FLUSH);
+ ASSERT(err != Z_STREAM_ERROR);
+ *destLen = streamp->total_out - last_tot;
+ return err;
+}
+
+/*
+ * When we are done, free up the inflate structure
+ * Retyurns Z_OK or Error
+ */
+int ZEXPORT erl_zlib_inflate_finish(z_stream *streamp)
+{
+ return inflateEnd(streamp);
+}
+
+
int ZEXPORT erl_zlib_compress2 (Bytef* dest, uLongf* destLen,
const Bytef* source, uLong sourceLen,
int level)