⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 unzip.h

📁 linux 上http email 协议分析程序 主要能够处理大数据量的主干网的应用
💻 H
字号:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


typedef unsigned char  uch;
typedef unsigned short ush;
typedef unsigned long  ulg;

#define INBUFSIZ  0x8000
#define WSIZE 0x8000
/* Return codes from gzip */
#define OK      0
#define ERROR   1
#define WARNING 2

/* Compression methods (see algorithm.doc) */
#define STORED      0
#define COMPRESSED  1
#define PACKED      2
#define LZHED       3
/* methods 4 to 7 reserved */
#define DEFLATED    8
#define MAX_METHODS 9

#define EXTHDR 16

#define RECORD_IO 0

#define PACK_MAGIC     "\037\036" /* Magic header for packed files */
#define GZIP_MAGIC     "\037\213" /* Magic header for gzip files, 1F 8B */
#define OLD_GZIP_MAGIC "\037\236" /* Magic header for gzip 0.5 = freeze 1.x */
#define LZH_MAGIC      "\037\240" /* Magic header for SCO LZH Compress files*/
#define PKZIP_MAGIC    "\120\113\003\004" /* Magic header for pkzip files */

/* gzip flag byte */
#define ASCII_FLAG   0x01 /* bit 0 set: file probably ascii text */
#define CONTINUATION 0x02 /* bit 1 set: continuation of multi-part gzip file */
#define EXTRA_FIELD  0x04 /* bit 2 set: extra field present */
#define ORIG_NAME    0x08 /* bit 3 set: original file name present */
#define COMMENT      0x10 /* bit 4 set: file comment present */
#define ENCRYPTED    0x20 /* bit 5 set: file is encrypted */
#define RESERVED     0xC0 /* bit 6,7:   reserved */
#define NEXTBYTE()  (uch)get_byte()
#define NEEDBITS(n) {while(k<(n)){b|=((ulg)NEXTBYTE())<<k;k+=8;}}
#define DUMPBITS(n) {b>>=(n);k-=(n);}
#define get_byte()  (m_iinptr < m_iinsize ? inbuf[m_iinptr++] : fill_inbuf())
#define flush_output(w) (wp=(w),flush_window())

#define get_char() get_byte()
#define BMAX 16         /* maximum bit length of any code (16 for explode) */
#define N_MAX 288       /* maximum number of codes in any set */
#define wp m_ioutcnt
#define slide windown

struct huft {
  uch e;                /* number of extra bits or operation */
  uch b;                /* number of bits in this code or subcode */
  union {
    ush n;              /* literal, length base, or distance base */
    struct huft *t;     /* pointer to next level of table */
  } v;
};



class Cunzip
{
public:
	Cunzip();
	~Cunzip();

	void clear_bufs();	
	int fill_inbuf();
	void flush_window();
	int get_method();
	int unzip(char *in, int &inlen, char *out);

	int inflate();
	int inflate_block(int *e);
	int inflate_stored();
	int inflate_fixed();
	int inflate_dynamic();

	int huft_build (unsigned *, unsigned, unsigned, ush *, ush *,
                   struct huft **, int *);
	int huft_free (struct huft *);
	int inflate_codes (struct huft *, struct huft *, int, int);	

private:

	ulg m_lbb;                         /* bit buffer */
	unsigned m_ibk;                    /* bits in bit buffer */
	
	unsigned m_iinptr;
	unsigned m_ioutcnt;           /* bytes in output buffer */

	
	//DECLARE(uch, window, 2L*WSIZE);
	char *m_szinput;
	int m_iinlen;
	char *m_szoutput;
	int m_ioutput;

	char *inbuf;
	char *outbuf;
	char *windown;

	unsigned m_iinsize; 
    unsigned m_ibytes_in;
	unsigned m_ibytes_out;

	unsigned m_ihufts;

	long m_ltime_stamp;
	int m_ino_time ;
	int m_imethod; //= DEFLATED;               /* unknown yet */
    int m_ipart_nb; //m_ipart_nb++;                   /* number of parts in gzip file */
    long m_lheader_bytes;// m_lheader_bytes = 0;
    int m_ilast_member; //= RECORD_IO;
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -