diff options
author | dkf <donal.k.fellows@manchester.ac.uk> | 2012-04-17 07:42:58 (GMT) |
---|---|---|
committer | dkf <donal.k.fellows@manchester.ac.uk> | 2012-04-17 07:42:58 (GMT) |
commit | cabd03de9c061b66cb7735abc1dc4ccee55b84b2 (patch) | |
tree | a863b1269188f66d45b78acd78b7d82c4052d595 | |
parent | 6f233b426d4ed93956bdfb664f808bf6df832dbc (diff) | |
download | tcl-cabd03de9c061b66cb7735abc1dc4ccee55b84b2.zip tcl-cabd03de9c061b66cb7735abc1dc4ccee55b84b2.tar.gz tcl-cabd03de9c061b66cb7735abc1dc4ccee55b84b2.tar.bz2 |
Working towards the channel transform config options.
-rw-r--r-- | generic/tclZlib.c | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/generic/tclZlib.c b/generic/tclZlib.c index f88e0e1..0caa02b 100644 --- a/generic/tclZlib.c +++ b/generic/tclZlib.c @@ -2130,10 +2130,10 @@ ZlibPushSubcmd( Tcl_Channel chan; int chanMode, format, mode, level, i, option; static const char *const pushOptions[] = { - "-header", "-level", "-limit", NULL + "-dictionary", "-header", "-level", "-limit", NULL }; - enum pushOptions {poHeader, poLevel, poLimit}; - Tcl_Obj *headerObj = NULL; + enum pushOptions {poDictionary, poHeader, poLevel, poLimit}; + Tcl_Obj *headerObj = NULL, *compDictObj = NULL; int limit = 1, dummy; if (objc < 4) { @@ -2255,6 +2255,15 @@ ZlibPushSubcmd( limit = 1; } break; + case poDictionary: + if (++i > objc-1) { + Tcl_AppendResult(interp, + "value missing for -dictionary option", NULL); + Tcl_SetErrorCode(interp, "TCL", "ZIP", "NOVAL", NULL); + return TCL_ERROR; + } + compDictObj = objv[i]; + break; } } @@ -2262,6 +2271,10 @@ ZlibPushSubcmd( headerObj, NULL) == NULL) { return TCL_ERROR; } + if ((compDictObj != NULL) && (Tcl_SetChannelOption(interp, chan, + "-dictionary", TclGetString(compDictObj)) != TCL_OK)) { + return TCL_ERROR; + } Tcl_SetObjResult(interp, objv[3]); return TCL_OK; } @@ -2742,7 +2755,16 @@ ZlibTransformSetOption( /* not used */ int haveFlushOpt = (cd->mode == TCL_ZLIB_STREAM_DEFLATE); if (optionName && strcmp(optionName, "-dictionary") == 0) { - // TODO dictionary option + Tcl_Obj *compDictObj; + + TclNewStringObj(compDictObj, value, strlen(value)); + Tcl_IncrRefCount(compDictObj); + (void) Tcl_GetByteArrayFromObj(compDictObj, NULL); + if (cd->compDictObj) { + TclDecrRefCount(cd->compDictObj); + } + cd->compDictObj = compDictObj; + // TODO: consider whether to apply immediately } if (haveFlushOpt && optionName && strcmp(optionName, "-flush") == 0) { |