System.util.zlib.Deflate.deflateSetDictionary C# (CSharp) Méthode

deflateSetDictionary() private méthode

private deflateSetDictionary ( ZStream strm, byte dictionary, int dictLength ) : int
strm ZStream
dictionary byte
dictLength int
Résultat int
        internal int deflateSetDictionary (ZStream strm, byte[] dictionary, int dictLength){
            int length = dictLength;
            int index=0;

            if(dictionary == null || status != INIT_STATE)
                return Z_STREAM_ERROR;

            strm.adler=strm._adler.adler32(strm.adler, dictionary, 0, dictLength);

            if(length < MIN_MATCH) return Z_OK;
            if(length > w_size-MIN_LOOKAHEAD){
                length = w_size-MIN_LOOKAHEAD;
                index=dictLength-length; // use the tail of the dictionary
            }
            System.Array.Copy(dictionary, index, window, 0, length);
            strstart = length;
            block_start = length;

            // Insert all strings in the hash table (except for the last two bytes).
            // s->lookahead stays null, so s->ins_h will be recomputed at the next
            // call of fill_window.

            ins_h = window[0]&0xff;
            ins_h=(((ins_h)<<hash_shift)^(window[1]&0xff))&hash_mask;

            for(int n=0; n<=length-MIN_MATCH; n++){
                ins_h=(((ins_h)<<hash_shift)^(window[(n)+(MIN_MATCH-1)]&0xff))&hash_mask;
                prev[n&w_mask]=head[ins_h];
                head[ins_h]=(short)n;
            }
            return Z_OK;
        }