• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# zlib.ZStream类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.util.zlib.ZStream的典型用法代码示例。如果您正苦于以下问题:C# ZStream类的具体用法?C# ZStream怎么用?C# ZStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ZStream类属于System.util.zlib命名空间,在下文中一共展示了ZStream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: deflate

        internal int deflate(ZStream strm, int flush){
            int old_flush;

            if(flush>Z_FINISH || flush<0){
                return Z_STREAM_ERROR;
            }

            if(strm.next_out == null ||
                (strm.next_in == null && strm.avail_in != 0) ||
                (status == FINISH_STATE && flush != Z_FINISH)) {
                strm.msg=z_errmsg[Z_NEED_DICT-(Z_STREAM_ERROR)];
                return Z_STREAM_ERROR;
            }
            if(strm.avail_out == 0){
                strm.msg=z_errmsg[Z_NEED_DICT-(Z_BUF_ERROR)];
                return Z_BUF_ERROR;
            }

            this.strm = strm; // just in case
            old_flush = last_flush;
            last_flush = flush;

            // Write the zlib header
            if(status == INIT_STATE) {
                int header = (Z_DEFLATED+((w_bits-8)<<4))<<8;
                int level_flags=((level-1)&0xff)>>1;

                if(level_flags>3) level_flags=3;
                header |= (level_flags<<6);
                if(strstart!=0) header |= PRESET_DICT;
                header+=31-(header % 31);

                status=BUSY_STATE;
                putShortMSB(header);


                // Save the adler32 of the preset dictionary:
                if(strstart!=0){
                    putShortMSB((int)(strm.adler>>16));
                    putShortMSB((int)(strm.adler&0xffff));
                }
                strm.adler=strm._adler.adler32(0, null, 0, 0);
            }

            // Flush as much pending output as possible
            if(pending != 0) {
                strm.flush_pending();
                if(strm.avail_out == 0) {
                    //System.out.println("  avail_out==0");
                    // Since avail_out is 0, deflate will be called again with
                    // more output space, but possibly with both pending and
                    // avail_in equal to zero. There won't be anything to do,
                    // but this is not an error situation so make sure we
                    // return OK instead of BUF_ERROR at next call of deflate:
                    last_flush = -1;
                    return Z_OK;
                }

                // Make sure there is something to do and avoid duplicate consecutive
                // flushes. For repeated and useless calls with Z_FINISH, we keep
                // returning Z_STREAM_END instead of Z_BUFF_ERROR.
            }
            else if(strm.avail_in==0 && flush <= old_flush &&
                flush != Z_FINISH) {
                strm.msg=z_errmsg[Z_NEED_DICT-(Z_BUF_ERROR)];
                return Z_BUF_ERROR;
            }

            // User must not provide more input after the first FINISH:
            if(status == FINISH_STATE && strm.avail_in != 0) {
                strm.msg=z_errmsg[Z_NEED_DICT-(Z_BUF_ERROR)];
                return Z_BUF_ERROR;
            }

            // Start a new block or continue the current one.
            if(strm.avail_in!=0 || lookahead!=0 ||
                (flush != Z_NO_FLUSH && status != FINISH_STATE)) {
                int bstate=-1;
                switch(config_table[level].func){
                    case STORED: 
                        bstate = deflate_stored(flush);
                        break;
                    case FAST: 
                        bstate = deflate_fast(flush);
                        break;
                    case SLOW: 
                        bstate = deflate_slow(flush);
                        break;
                    default:
                        break;
                }

                if (bstate==FinishStarted || bstate==FinishDone) {
                    status = FINISH_STATE;
                }
                if (bstate==NeedMore || bstate==FinishStarted) {
                    if(strm.avail_out == 0) {
                        last_flush = -1; // avoid BUF_ERROR next call, see above
                    }
                    return Z_OK;
//.........这里部分代码省略.........
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:101,代码来源:Deflate.cs


示例2: init

 internal void init(int bl, int bd,
     int[] tl, int tl_index,
     int[] td, int td_index, ZStream z)
 {
     mode=START;
     lbits=(byte)bl;
     dbits=(byte)bd;
     ltree=tl;
     ltree_index=tl_index;
     dtree = td;
     dtree_index=td_index;
     tree=null;
 }
开发者ID:bmictech,项目名称:iTextSharp,代码行数:13,代码来源:InfCodes.cs


示例3: inflateSyncPoint

 // Returns true if inflate is currently at the end of a block generated
 // by Z_SYNC_FLUSH or Z_FULL_FLUSH. This function is used by one PPP
 // implementation to provide an additional safety check. PPP uses Z_SYNC_FLUSH
 // but removes the length bytes of the resulting empty stored block. When
 // decompressing, PPP checks that at the end of input packet, inflate is
 // waiting for these length bytes.
 internal int inflateSyncPoint(ZStream z){
     if(z == null || z.istate == null || z.istate.blocks == null)
         return Z_STREAM_ERROR;
     return z.istate.blocks.sync_point();
 }
开发者ID:pusp,项目名称:o2platform,代码行数:11,代码来源:Inflate.cs


示例4: free

 internal void free(ZStream z)
 {
     //  ZFREE(z, c);
 }
开发者ID:bmictech,项目名称:iTextSharp,代码行数:4,代码来源:InfCodes.cs


示例5: inflateInit

        internal int inflateInit(ZStream z, int w){
            z.msg = null;
            blocks = null;

            // handle undocumented nowrap option (no zlib header or check)
            nowrap = 0;
            if(w < 0){
                w = - w;
                nowrap = 1;
            }

            // set window size
            if(w<8 ||w>15){
                inflateEnd(z);
                return Z_STREAM_ERROR;
            }
            wbits=w;

            z.istate.blocks=new InfBlocks(z, 
                z.istate.nowrap!=0 ? null : this,
                1<<w);

            // reset state
            inflateReset(z);
            return Z_OK;
        }
开发者ID:pusp,项目名称:o2platform,代码行数:26,代码来源:Inflate.cs


示例6: inflateSetDictionary

        internal int inflateSetDictionary(ZStream z, byte[] dictionary, int dictLength){
            int index=0;
            int length = dictLength;
            if(z==null || z.istate == null|| z.istate.mode != DICT0)
                return Z_STREAM_ERROR;

            if(z._adler.adler32(1L, dictionary, 0, dictLength)!=z.adler){
                return Z_DATA_ERROR;
            }

            z.adler = z._adler.adler32(0, null, 0, 0);

            if(length >= (1<<z.istate.wbits)){
                length = (1<<z.istate.wbits)-1;
                index=dictLength - length;
            }
            z.istate.blocks.set_dictionary(dictionary, index, length);
            z.istate.mode = BLOCKS;
            return Z_OK;
        }
开发者ID:pusp,项目名称:o2platform,代码行数:20,代码来源:Inflate.cs


示例7: inflate_trees_dynamic

        internal int inflate_trees_dynamic(int nl,   // number of literal/length codes
            int nd,   // number of distance codes
            int[] c,  // that many (total) code lengths
            int[] bl, // literal desired/actual bit depth
            int[] bd, // distance desired/actual bit depth 
            int[] tl, // literal/length tree result
            int[] td, // distance tree result
            int[] hp, // space for trees
            ZStream z // for messages
            ){
            int result;

            // build literal/length tree
            initWorkArea(288);
            hn[0]=0;
            result = huft_build(c, 0, nl, 257, cplens, cplext, tl, bl, hp, hn, v);
            if (result != Z_OK || bl[0] == 0){
                if(result == Z_DATA_ERROR){
                    z.msg = "oversubscribed literal/length tree";
                }
                else if (result != Z_MEM_ERROR){
                    z.msg = "incomplete literal/length tree";
                    result = Z_DATA_ERROR;
                }
                return result;
            }

            // build distance tree
            initWorkArea(288);
            result = huft_build(c, nl, nd, 0, cpdist, cpdext, td, bd, hp, hn, v);

            if (result != Z_OK || (bd[0] == 0 && nl > 257)){
                if (result == Z_DATA_ERROR){
                    z.msg = "oversubscribed distance tree";
                }
                else if (result == Z_BUF_ERROR) {
                    z.msg = "incomplete distance tree";
                    result = Z_DATA_ERROR;
                }
                else if (result != Z_MEM_ERROR){
                    z.msg = "empty distance tree with lengths";
                    result = Z_DATA_ERROR;
                }
                return result;
            }

            return Z_OK;
        }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:48,代码来源:InfTree.cs


示例8: inflate_trees_fixed

 internal static int inflate_trees_fixed(int[] bl,  //literal desired/actual bit depth
     int[] bd,  //distance desired/actual bit depth
     int[][] tl,//literal/length tree result
     int[][] td,//distance tree result 
     ZStream z  //for memory allocation
     ){
     bl[0]=fixed_bl;
     bd[0]=fixed_bd;
     tl[0]=fixed_tl;
     td[0]=fixed_td;
     return Z_OK;
 }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:12,代码来源:InfTree.cs


示例9: inflate_trees_bits

        internal int inflate_trees_bits(int[] c,  // 19 code lengths
            int[] bb, // bits tree desired/actual depth
            int[] tb, // bits tree result
            int[] hp, // space for trees
            ZStream z // for messages
            ){
            int result;
            initWorkArea(19);
            hn[0]=0;
            result = huft_build(c, 0, 19, 19, null, null, tb, bb, hp, hn, v);

            if(result == Z_DATA_ERROR){
                z.msg = "oversubscribed dynamic bit lengths tree";
            }
            else if(result == Z_BUF_ERROR || bb[0] == 0){
                z.msg = "incomplete dynamic bit lengths tree";
                result = Z_DATA_ERROR;
            }
            return result;
        }
开发者ID:jagruti23,项目名称:itextsharp,代码行数:20,代码来源:InfTree.cs


示例10: deflateInit

 internal int deflateInit(ZStream strm, int level, int bits){
     return deflateInit2(strm, level, Z_DEFLATED, bits, DEF_MEM_LEVEL,
         Z_DEFAULT_STRATEGY);
 }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:4,代码来源:Deflate.cs


示例11: inflateEnd

 internal int inflateEnd(ZStream z){
     if(blocks != null)
         blocks.free(z);
     blocks=null;
     //    ZFREE(z, z->state);
     return Z_OK;
 }
开发者ID:pusp,项目名称:o2platform,代码行数:7,代码来源:Inflate.cs


示例12: inflate

        internal int inflate(ZStream z, int f){
            int r;
            int b;

            if(z == null || z.istate == null || z.next_in == null)
                return Z_STREAM_ERROR;
            f = f == Z_FINISH ? Z_BUF_ERROR : Z_OK;
            r = Z_BUF_ERROR;
            while (true){
                //System.out.println("mode: "+z.istate.mode);
                switch (z.istate.mode){
                    case METHOD:

                        if(z.avail_in==0)return r;r=f;

                        z.avail_in--; z.total_in++;
                        if(((z.istate.method = z.next_in[z.next_in_index++])&0xf)!=Z_DEFLATED){
                            z.istate.mode = BAD;
                            z.msg="unknown compression method";
                            z.istate.marker = 5;       // can't try inflateSync
                            break;
                        }
                        if((z.istate.method>>4)+8>z.istate.wbits){
                            z.istate.mode = BAD;
                            z.msg="invalid window size";
                            z.istate.marker = 5;       // can't try inflateSync
                            break;
                        }
                        z.istate.mode=FLAG;
                        goto case FLAG;
                    case FLAG:

                        if(z.avail_in==0)return r;r=f;

                        z.avail_in--; z.total_in++;
                        b = (z.next_in[z.next_in_index++])&0xff;

                        if((((z.istate.method << 8)+b) % 31)!=0){
                            z.istate.mode = BAD;
                            z.msg = "incorrect header check";
                            z.istate.marker = 5;       // can't try inflateSync
                            break;
                        }

                        if((b&PRESET_DICT)==0){
                            z.istate.mode = BLOCKS;
                            break;
                        }
                        z.istate.mode = DICT4;
                        goto case DICT4;
                    case DICT4:

                        if(z.avail_in==0)return r;r=f;

                        z.avail_in--; z.total_in++;
                        z.istate.need=((z.next_in[z.next_in_index++]&0xff)<<24)&0xff000000L;
                        z.istate.mode=DICT3;
                        goto case DICT3;
                    case DICT3:

                        if(z.avail_in==0)return r;r=f;

                        z.avail_in--; z.total_in++;
                        z.istate.need+=((z.next_in[z.next_in_index++]&0xff)<<16)&0xff0000L;
                        z.istate.mode=DICT2;
                        goto case DICT2;
                    case DICT2:

                        if(z.avail_in==0)return r;r=f;

                        z.avail_in--; z.total_in++;
                        z.istate.need+=((z.next_in[z.next_in_index++]&0xff)<<8)&0xff00L;
                        z.istate.mode=DICT1;
                        goto case DICT1;
                    case DICT1:

                        if(z.avail_in==0)return r;r=f;

                        z.avail_in--; z.total_in++;
                        z.istate.need += (z.next_in[z.next_in_index++]&0xffL);
                        z.adler = z.istate.need;
                        z.istate.mode = DICT0;
                        return Z_NEED_DICT;
                    case DICT0:
                        z.istate.mode = BAD;
                        z.msg = "need dictionary";
                        z.istate.marker = 0;       // can try inflateSync
                        return Z_STREAM_ERROR;
                    case BLOCKS:

                        r = z.istate.blocks.proc(z, r);
                        if(r == Z_DATA_ERROR){
                            z.istate.mode = BAD;
                            z.istate.marker = 0;     // can try inflateSync
                            break;
                        }
                        if(r == Z_OK){
                            r = f;
                        }
                        if(r != Z_STREAM_END){
//.........这里部分代码省略.........
开发者ID:pusp,项目名称:o2platform,代码行数:101,代码来源:Inflate.cs


示例13: deflateInit2

        internal int deflateInit2(ZStream strm, int level, int method,  int windowBits,
            int memLevel, int strategy){
            int noheader = 0;
            //    byte[] my_version=ZLIB_VERSION;

            //
            //  if (version == null || version[0] != my_version[0]
            //  || stream_size != sizeof(z_stream)) {
            //  return Z_VERSION_ERROR;
            //  }

            strm.msg = null;

            if (level == Z_DEFAULT_COMPRESSION) level = 6;

            if (windowBits < 0) { // undocumented feature: suppress zlib header
                noheader = 1;
                windowBits = -windowBits;
            }

            if (memLevel < 1 || memLevel > MAX_MEM_LEVEL || 
                method != Z_DEFLATED ||
                windowBits < 9 || windowBits > 15 || level < 0 || level > 9 ||
                strategy < 0 || strategy > Z_HUFFMAN_ONLY) {
                return Z_STREAM_ERROR;
            }

            strm.dstate = (Deflate)this;

            this.noheader = noheader;
            w_bits = windowBits;
            w_size = 1 << w_bits;
            w_mask = w_size - 1;

            hash_bits = memLevel + 7;
            hash_size = 1 << hash_bits;
            hash_mask = hash_size - 1;
            hash_shift = ((hash_bits+MIN_MATCH-1)/MIN_MATCH);

            window = new byte[w_size*2];
            prev = new short[w_size];
            head = new short[hash_size];

            lit_bufsize = 1 << (memLevel + 6); // 16K elements by default

            // We overlay pending_buf and d_buf+l_buf. This works since the average
            // output size for (length,distance) codes is <= 24 bits.
            pending_buf = new byte[lit_bufsize*4];
            pending_buf_size = lit_bufsize*4;

            d_buf = lit_bufsize/2;
            l_buf = (1+2)*lit_bufsize;

            this.level = level;

            //System.out.println("level="+level);

            this.strategy = strategy;
            this.method = (byte)method;

            return deflateReset(strm);
        }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:62,代码来源:Deflate.cs


示例14: inflateSync

        internal int inflateSync(ZStream z){
            int n;       // number of bytes to look at
            int p;       // pointer to bytes
            int m;       // number of marker bytes found in a row
            long r, w;   // temporaries to save total_in and total_out

            // set up
            if(z == null || z.istate == null)
                return Z_STREAM_ERROR;
            if(z.istate.mode != BAD){
                z.istate.mode = BAD;
                z.istate.marker = 0;
            }
            if((n=z.avail_in)==0)
                return Z_BUF_ERROR;
            p=z.next_in_index;
            m=z.istate.marker;

            // search
            while (n!=0 && m < 4){
                if(z.next_in[p] == mark[m]){
                    m++;
                }
                else if(z.next_in[p]!=0){
                    m = 0;
                }
                else{
                    m = 4 - m;
                }
                p++; n--;
            }

            // restore
            z.total_in += p-z.next_in_index;
            z.next_in_index = p;
            z.avail_in = n;
            z.istate.marker = m;

            // return no joy or set up to restart on a new block
            if(m != 4){
                return Z_DATA_ERROR;
            }
            r=z.total_in;  w=z.total_out;
            inflateReset(z);
            z.total_in=r;  z.total_out = w;
            z.istate.mode = BLOCKS;
            return Z_OK;
        }
开发者ID:pusp,项目名称:o2platform,代码行数:48,代码来源:Inflate.cs


示例15: deflateReset

        internal int deflateReset(ZStream strm){
            strm.total_in = strm.total_out = 0;
            strm.msg = null; //
            strm.data_type = Z_UNKNOWN;

            pending = 0;
            pending_out = 0;

            if(noheader < 0) {
                noheader = 0; // was set to -1 by deflate(..., Z_FINISH);
            }
            status = (noheader!=0) ? BUSY_STATE : INIT_STATE;
            strm.adler=strm._adler.adler32(0, null, 0, 0);

            last_flush = Z_NO_FLUSH;

            tr_init();
            lm_init();
            return Z_OK;
        }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:20,代码来源:Deflate.cs


示例16: inflateReset

        internal InfBlocks blocks;     // current inflate_blocks state

        internal int inflateReset(ZStream z){
            if(z == null || z.istate == null) return Z_STREAM_ERROR;
    
            z.total_in = z.total_out = 0;
            z.msg = null;
            z.istate.mode = z.istate.nowrap!=0 ? BLOCKS : METHOD;
            z.istate.blocks.reset(z, null);
            return Z_OK;
        }
开发者ID:pusp,项目名称:o2platform,代码行数:11,代码来源:Inflate.cs


示例17: deflateParams

        internal int deflateParams(ZStream strm, int _level, int _strategy){
            int err=Z_OK;

            if(_level == Z_DEFAULT_COMPRESSION){
                _level = 6;
            }
            if(_level < 0 || _level > 9 || 
                _strategy < 0 || _strategy > Z_HUFFMAN_ONLY) {
                return Z_STREAM_ERROR;
            }

            if(config_table[level].func!=config_table[_level].func &&
                strm.total_in != 0) {
                // Flush the last buffer:
                err = strm.deflate(Z_PARTIAL_FLUSH);
            }

            if(level != _level) {
                level = _level;
                max_lazy_match   = config_table[level].max_lazy;
                good_match       = config_table[level].good_length;
                nice_match       = config_table[level].nice_length;
                max_chain_length = config_table[level].max_chain;
            }
            strategy = _strategy;
            return err;
        }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:27,代码来源:Deflate.cs


示例18: inflate_fast

        // Called with number of bytes left to write in window at least 258
        // (the maximum string length) and number of input bytes available
        // at least ten.  The ten bytes are six bytes for the longest length/
        // distance pair plus four bytes for overloading the bit buffer.
        internal int inflate_fast(int bl, int bd, 
            int[] tl, int tl_index,
            int[] td, int td_index,
            InfBlocks s, ZStream z)
        {
            int t;                // temporary pointer
            int[] tp;             // temporary pointer
            int tp_index;         // temporary pointer
            int e;                // extra bits or operation
            int b;                // bit buffer
            int k;                // bits in bit buffer
            int p;                // input data pointer
            int n;                // bytes available there
            int q;                // output window write pointer
            int m;                // bytes to end of window or read pointer
            int ml;               // mask for literal/length tree
            int md;               // mask for distance tree
            int c;                // bytes to copy
            int d;                // distance back to copy from
            int r;                // copy source pointer

            int tp_index_t_3;     // (tp_index+t)*3

            // load input, output, bit values
            p=z.next_in_index;n=z.avail_in;b=s.bitb;k=s.bitk;
            q=s.write;m=q<s.read?s.read-q-1:s.end-q;

            // initialize masks
            ml = inflate_mask[bl];
            md = inflate_mask[bd];

            // do until not enough input or output space for fast loop
            do {                          // assume called with m >= 258 && n >= 10
                // get literal/length code
            while(k<(20)){              // max bits for literal/length code
                n--;
                b|=(z.next_in[p++]&0xff)<<k;k+=8;
            }

                t= b&ml;
                tp=tl;
                tp_index=tl_index;
                tp_index_t_3=(tp_index+t)*3;
                if ((e = tp[tp_index_t_3]) == 0){
                    b>>=(tp[tp_index_t_3+1]); k-=(tp[tp_index_t_3+1]);

                    s.window[q++] = (byte)tp[tp_index_t_3+2];
                    m--;
                    continue;
                }
                do {

                    b>>=(tp[tp_index_t_3+1]); k-=(tp[tp_index_t_3+1]);

                    if((e&16)!=0){
                        e &= 15;
                        c = tp[tp_index_t_3+2] + ((int)b & inflate_mask[e]);

                        b>>=e; k-=e;

                        // decode distance base of block to copy
                        while(k<(15)){           // max bits for distance code
                            n--;
                            b|=(z.next_in[p++]&0xff)<<k;k+=8;
                        }

                        t= b&md;
                        tp=td;
                        tp_index=td_index;
                        tp_index_t_3=(tp_index+t)*3;
                        e = tp[tp_index_t_3];

                        do {

                            b>>=(tp[tp_index_t_3+1]); k-=(tp[tp_index_t_3+1]);

                            if((e&16)!=0){
                                // get extra bits to add to distance base
                                e &= 15;
                                while(k<(e)){         // get extra bits (up to 13)
                                    n--;
                                    b|=(z.next_in[p++]&0xff)<<k;k+=8;
                                }

                                d = tp[tp_index_t_3+2] + (b&inflate_mask[e]);

                                b>>=(e); k-=(e);

                                // do the copy
                                m -= c;
                                if (q >= d){                // offset before dest
                                    //  just copy
                                    r=q-d;
                                    if(q-r>0 && 2>(q-r)){
                                        s.window[q++]=s.window[r++]; // minimum count is three,
                                        s.window[q++]=s.window[r++]; // so unroll loop a little
//.........这里部分代码省略.........
开发者ID:bmictech,项目名称:iTextSharp,代码行数:101,代码来源:InfCodes.cs


示例19: deflateSetDictionary

        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;
        }
开发者ID:nicecai,项目名称:iTextSharp-4.1.6,代码行数:32,代码来源:Deflate.cs


示例20: proc

        internal int proc(InfBlocks s, ZStream z, int r)
        {
            int j;              // temporary storage
            int tindex;         // temporary pointer
            int e;              // extra bits or operation
            int b=0;            // bit buffer
            int k=0;            // bits in bit buffer
            int p=0;            // input data pointer
            int n;              // bytes available there
            int q;              // output window write pointer
            int m;              // bytes to end of window or read pointer
            int f;              // pointer to copy strings from

            // copy input/output information to locals (UPDATE macro restores)
            p=z.next_in_index;n=z.avail_in;b=s.bitb;k=s.bitk;
            q=s.write;m=q<s.read?s.read-q-1:s.end-q;

            // process input and output based on current state
            while (true){
                switch (mode){
                        // waiting for "i:"=input, "o:"=output, "x:"=nothing
                    case START:         // x: set up for LEN
                        if (m >= 258 && n >= 10){

                            s.bitb=b;s.bitk=k;
                            z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
                            s.write=q;
                            r = inflate_fast(lbits, dbits,
                                ltree, ltree_index,
                                dtree, dtree_index,
                                s, z);

                            p=z.next_in_index;n=z.avail_in;b=s.bitb;k=s.bitk;
                            q=s.write;m=q<s.read?s.read-q-1:s.end-q;

                            if (r != Z_OK){
                                mode = r == Z_STREAM_END ? WASH : BADCODE;
                                break;
                            }
                        }
                        need = lbits;
                        tree = ltree;
                        tree_index=ltree_index;

                        mode = LEN;
                        goto case LEN;
                    case LEN:           // i: get length/literal/eob next
                        j = need;

                        while(k<(j)){
                            if(n!=0)r=Z_OK;
                            else{

                                s.bitb=b;s.bitk=k;
                                z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
                                s.write=q;
                                return s.inflate_flush(z,r);
                            }
                            n--;
                            b|=(z.next_in[p++]&0xff)<<k;
                            k+=8;
                        }

                        tindex=(tree_index+(b&inflate_mask[j]))*3;

                        b>>=(tree[tindex+1]);
                        k-=(tree[tindex+1]);

                        e=tree[tindex];

                        if(e == 0){               // literal
                            lit = tree[tindex+2];
                            mode = LIT;
                            break;
                        }
                        if((e & 16)!=0 ){          // length
                            get = e & 15;
                            len = tree[tindex+2];
                            mode = LENEXT;
                            break;
                        }
                        if ((e & 64) == 0){        // next table
                            need = e;
                            tree_index = tindex/3+tree[tindex+2];
                            break;
                        }
                        if ((e & 32)!=0){               // end of block
                            mode = WASH;
                            break;
                        }
                        mode = BADCODE;        // invalid code
                        z.msg = "invalid literal/length code";
                        r = Z_DATA_ERROR;

                        s.bitb=b;s.bitk=k;
                        z.avail_in=n;z.total_in+=p-z.next_in_index;z.next_in_index=p;
                        s.write=q;
                        return s.inflate_flush(z,r);

                    case LENEXT:        // i: getting length extra (have base)
//.........这里部分代码省略.........
开发者ID:bmictech,项目名称:iTextSharp,代码行数:101,代码来源:InfCodes.cs



注:本文中的System.util.zlib.ZStream类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# T4MVC.Dummy类代码示例发布时间:2022-05-26
下一篇:
C# zlib.ZDeflaterOutputStream类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap