最近做一个项目,里面要涉及到一个解压Gzip格式的压缩包,开发环境是VC2010,之前解压gz格式直接调用MFC库里的类就可以了,我在MFC查不到关于解压Gzip格式的类,请问各位长辈有没有解压Gzip的源代码,不要那种带LIB库的。

解决方案 »

  1.   

    把gzip的inflate.c改写一下就可以了,别的都不要。(gzip.h也不要)加入:
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>typedef unsigned char  uch;
    typedef unsigned short ush;
    typedef unsigned long  ulg;#define slide window
    #define WSIZE 0x8000 /* window size--must be a power of two */uch *inbuf;   // input  buffer
    uch *g_outbuf;// output buffer
    long bytes_out;            // number of output bytes 
    uch  window[2L*WSIZE];    // uch window[2*0x8000] 64kunsigned inptr;            // index of next byte to be processed in inbuf 
    unsigned outcnt;           // bytes in output buffer 
    //
    void flush_window();
    等等