// // G A M E.O.N.E - LOW LEVEL LIB V1.0 // Copyright (C) 2001 LEVEL ONE ENTERTAINMENT, // Licensed under the terms of LGPL. //:--------------------------------------------------------------------------- //:Description // // LOW LEVEL ZIP MODULE INCLUDE FILE // //:--------------------------------------------------------------------------- #ifndef _MODZIP_H #define _MODZIP_H #include "lib_base.h" #include "llstream.h" typedef TxU16 ush; typedef TxU8 uch; typedef TxU32 ulg; typedef enum { NOT_INITIALIZED, // do nothing COPY, // copy stored data INIT_BLOCK, // initialize next block to inflate INFLATE_CODES, // decompress current block INFLATE_STORED, // decompress current stored block INFLATE_END // all finished, do the cleanup } eInflateStatus; 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; }; typedef struct directory { char *filename; long crc; long filepos; long uncompressed_size; long compressed_size; short method; int offset; // offset zu daten wenn method=STORED. offset=grösse vom zipheader struct directory *next; } directory; class CModZipfile : public CStreamModule { //------------------------------------------------------------------------------------------------- // construction / destruction //------------------------------------------------------------------------------------------------- public: CModZipfile(); virtual ~CModZipfile(); //------------------------------------------------------------------------------------------------- // public member functions //------------------------------------------------------------------------------------------------- public: virtual int read(void *ioBuf, int iNum); virtual int write(void *ioBuf, int iNum); virtual int ioCtl( char *iCmd, void *ioOption );// send a command down the stream CStreamModule *Clone(); //------------------------------------------------------------------------------------------------- // instance variables //------------------------------------------------------------------------------------------------- private: directory *mDirectoryList; directory *mSelectedFile; //------------------------------------------------------------------------------------------------- // helper functions //------------------------------------------------------------------------------------------------- private: void Reset(void); int InitUnzip(void); int BuildDirectory(void); void DumpDir(void); int SelectZipfile( char* iFilename ); int RetrieveBuffer(void *ioBuf, int iNum); void CleanUp(void); void ResetBufs(void); void flush_window(void); TxU8 fillinbuf(int eof_ok); int huft_build (TxU32 *, TxU32, TxU32, ush *, ush *, struct huft **, int *); void huft_free (struct huft *); int inflate_codes (void); //struct huft *, struct huft *, int, int); int inflate_stored (void); int inflate_fixed (void); int inflate_dynamic (void); int inflate_block (void); int inflate (void); TxU8 fill_inbuf(int eof_ok); //------------------------------------------------------------------------------------------------- // buffer related variables //------------------------------------------------------------------------------------------------- private: TxU8 *mOutbuf; // Outputbuffer int mOutcnt; // num of bytes ready to flush int mReadcnt; // num of bytes removed from Outputbuffer int mBytes_out; // total number of decompressed bytes read int mBytes_in; // total number of compressed bytes read TxU8 *mInbuf; // Inputbuffer int mInptr; // Read Index of Inputbuffer int mInsize; // number of bytes in Inputbuffer TxU16 *mDistbuf; // Distance buffer TxU8 *mWindow; // buffer to uncompressed file TxU16 *mTabprefix; // ? TxU32 mCrc; // crc shift register //------------------------------------------------------------------------------------------------- // inflate related variables //------------------------------------------------------------------------------------------------- eInflateStatus mInflateStatus; // controls reentrant inflate routines int mLastBlock; // last block flag int mHufts; // maximum struct huft's (h) malloc'ed TxU32 mOrigCrc; // crc reported from zipfile int mOrigLen; // length reported from zipfile int mCompLen; // length of compressed file TxU32 mBitBuffer; // bit buffer TxU32 mBits; // bits in bit buffer int mBlocksize; // number of bytes in block struct huft *mTl; // literal/length tables struct huft *mTd; // distance decoder tables int mBl; // number of bits decoded by mTl[] int mBd; // number of bits decoded by mTd[] //------------------------------------------------------------------------------------------------- // inflate codes related variables //------------------------------------------------------------------------------------------------- TxU32 e; /* table entry flag/number of extra bits */ TxU32 n, d; /* length and index for copy */ struct huft *t; /* pointer to table entry */ TxU32 ml, md; /* masks for bl and bd bits */ TxU32 hsrcl[288]; /* length list for huft_build */ TxU32 hsrcd[288]; /* distance list for huft_build */ }; #endif // _MOD_ZIP_H