MCPcopy Create free account
hub / github.com/hoothin/UserScripts / inflateSetDictionary

Function inflateSetDictionary

Picviewer CE+/dist.user.js:9917–9951  ·  view source on GitHub ↗
(strm, dictionary)

Source from the content-addressed store, hash-verified

9915}
9916
9917function inflateSetDictionary(strm, dictionary) {
9918 var dictLength = dictionary.length;
9919
9920 var state;
9921 var dictid;
9922 var ret;
9923
9924 /* check state */
9925 if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }
9926 state = strm.state;
9927
9928 if (state.wrap !== 0 && state.mode !== DICT) {
9929 return Z_STREAM_ERROR;
9930 }
9931
9932 /* check for correct dictionary identifier */
9933 if (state.mode === DICT) {
9934 dictid = 1; /* adler32(0, null, 0)*/
9935 /* dictid = adler32(dictid, dictionary, dictLength); */
9936 dictid = adler32(dictid, dictionary, dictLength, 0);
9937 if (dictid !== state.check) {
9938 return Z_DATA_ERROR;
9939 }
9940 }
9941 /* copy dictionary to window using updatewindow(), which will amend the
9942 existing dictionary if appropriate */
9943 ret = updatewindow(strm, dictionary, dictLength, dictLength);
9944 if (ret) {
9945 state.mode = MEM;
9946 return Z_MEM_ERROR;
9947 }
9948 state.havedict = 1;
9949 // Tracev((stderr, "inflate: dictionary set\n"));
9950 return Z_OK;
9951}
9952
9953exports.inflateReset = inflateReset;
9954exports.inflateReset2 = inflateReset2;

Callers

nothing calls this directly

Calls 2

adler32Function · 0.70
updatewindowFunction · 0.70

Tested by

no test coverage detected