summaryrefslogtreecommitdiff
path: root/src/node_zlib.cc
diff options
context:
space:
mode:
authorBrian White <mscdex@mscdex.net>2013-07-01 05:44:17 -0400
committerBen Noordhuis <info@bnoordhuis.nl>2013-07-01 13:08:09 +0200
commit9b09c9eedd74589111b9893f7b4154c45e027fc7 (patch)
treec83a61749b47c5bfbaf96abb6f8a0f071b08f78e /src/node_zlib.cc
parent086d4ccace1d28e410f9982155d6762676d14483 (diff)
downloadnode-new-9b09c9eedd74589111b9893f7b4154c45e027fc7.tar.gz
zlib: allow changing of level and strategy
Diffstat (limited to 'src/node_zlib.cc')
-rw-r--r--src/node_zlib.cc30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/node_zlib.cc b/src/node_zlib.cc
index 229dacb69f..9bfc33e580 100644
--- a/src/node_zlib.cc
+++ b/src/node_zlib.cc
@@ -360,6 +360,18 @@ class ZCtx : public ObjectWrap {
return Undefined(node_isolate);
}
+ static Handle<Value> Params(const Arguments& args) {
+ HandleScope scope(node_isolate);
+
+ assert(args.Length() == 2 && "params(level, strategy)");
+
+ ZCtx* ctx = ObjectWrap::Unwrap<ZCtx>(args.This());
+
+ Params(ctx, args[0]->Int32Value(), args[1]->Int32Value());
+
+ return Undefined(node_isolate);
+ }
+
static Handle<Value> Reset(const Arguments &args) {
HandleScope scope(node_isolate);
@@ -455,6 +467,23 @@ class ZCtx : public ObjectWrap {
}
}
+ static void Params(ZCtx* ctx, int level, int strategy) {
+ ctx->err_ = Z_OK;
+
+ switch (ctx->mode_) {
+ case DEFLATE:
+ case DEFLATERAW:
+ ctx->err_ = deflateParams(&ctx->strm_, level, strategy);
+ break;
+ default:
+ break;
+ }
+
+ if (ctx->err_ != Z_OK && ctx->err_ != Z_BUF_ERROR) {
+ ZCtx::Error(ctx, "Failed to set parameters");
+ }
+ }
+
static void Reset(ZCtx* ctx) {
ctx->err_ = Z_OK;
@@ -514,6 +543,7 @@ void InitZlib(Handle<Object> target) {
NODE_SET_PROTOTYPE_METHOD(z, "write", ZCtx::Write);
NODE_SET_PROTOTYPE_METHOD(z, "init", ZCtx::Init);
NODE_SET_PROTOTYPE_METHOD(z, "close", ZCtx::Close);
+ NODE_SET_PROTOTYPE_METHOD(z, "params", ZCtx::Params);
NODE_SET_PROTOTYPE_METHOD(z, "reset", ZCtx::Reset);
z->SetClassName(String::NewSymbol("Zlib"));