(strm, dictionary)
| 21950 | } |
| 21951 | |
| 21952 | function inflateSetDictionary(strm, dictionary) { |
| 21953 | var dictLength = dictionary.length; |
| 21954 | |
| 21955 | var state; |
| 21956 | var dictid; |
| 21957 | var ret; |
| 21958 | |
| 21959 | /* check state */ |
| 21960 | if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; } |
| 21961 | state = strm.state; |
| 21962 | |
| 21963 | if (state.wrap !== 0 && state.mode !== DICT) { |
| 21964 | return Z_STREAM_ERROR; |
| 21965 | } |
| 21966 | |
| 21967 | /* check for correct dictionary identifier */ |
| 21968 | if (state.mode === DICT) { |
| 21969 | dictid = 1; /* adler32(0, null, 0)*/ |
| 21970 | /* dictid = adler32(dictid, dictionary, dictLength); */ |
| 21971 | dictid = adler32(dictid, dictionary, dictLength, 0); |
| 21972 | if (dictid !== state.check) { |
| 21973 | return Z_DATA_ERROR; |
| 21974 | } |
| 21975 | } |
| 21976 | /* copy dictionary to window using updatewindow(), which will amend the |
| 21977 | existing dictionary if appropriate */ |
| 21978 | ret = updatewindow(strm, dictionary, dictLength, dictLength); |
| 21979 | if (ret) { |
| 21980 | state.mode = MEM; |
| 21981 | return Z_MEM_ERROR; |
| 21982 | } |
| 21983 | state.havedict = 1; |
| 21984 | // Tracev((stderr, "inflate: dictionary set\n")); |
| 21985 | return Z_OK; |
| 21986 | } |
| 21987 | |
| 21988 | exports.inflateReset = inflateReset; |
| 21989 | exports.inflateReset2 = inflateReset2; |
nothing calls this directly
no test coverage detected