ew-engine/hq engine src/pk3.h
2006-10-08 00:00:00 +00:00

97 lines
3 KiB
C

#define ZIPIDHEADER ((4<<24)+(3<<16)+('K'<<8)+'P')
#define ZIPFILEIDHEADER ((2<<24)+(1<<16)+('K'<<8)+'P')
#define ZIPENDDIRHEADER ((6<<24)+(5<<16)+('K'<<8)+'P')
#define zipheadersize 30 //C will transform the size of the actual header to a power of 4 (32) which is incorrect.
typedef struct
{
int ident; //ZIPIDHEADER
short version;
short flags;
short compression;
short time;
short date;
byte crc32[4];
byte compressedsize[4];
byte uncompressedsize[4];
short filenamelen;
short extralen;
// char filename[1];//Variable sized
// char extra[1];//Variable sized
} zipheader_t;
typedef struct
{
int crc32;
int compressedsize;
int uncompressedsize;
} zipfooter_t;
#define zipfileheadersize 46 //C will transform the size of the actual header to a power of 4 (48) which is incorrect.
typedef struct
{
int ident; //ZIPFILEIDHEADER
byte version[2]; //Encoder version
byte minversion[2]; //Minimum version required
short flags;
byte compression[2];
byte time[2];
byte date[2];
byte crc32[4];
byte compressedsize[4];
byte uncompressedsize[4];
short filenamelen;
short extralen;
short commentlen;
short disknumberstart;
short internattribs;
byte externattribs[4];
byte offset[4];
// char filename[1] //Variable sized
// char extra[1] //Variable sized
// char comment[1] //Variable sized
} zipfileheader_t;
#define zipenddirheadersize 22 //C will transform the size of the actual header to a power of 4 (24) which is incorrect.
typedef struct
{
int ident; //ZIPFILEENDHEADER
short disknum;
short firstdirdisknum;
short disknumentries;
short totalnumentries;
int dirsize;
int diroffset;
short commentlength;
//char comment[1] //Variable sized.
} zipenddirheader_t;
#define ZIP_FLAG_ENCRYPTED 0
//For Method 6 - Imploding
#define ZIP_FLAG_8KSLIDING 1 //A 8k sliding dictionary was used instead of a 4k one.
#define ZIP_FLAG_3SFTREES 2 //3 Shannon-Fano trees were used instead of 2.
//For Method 8 - Deflating
#define ZIP_FLAG_COMPRESS1 1
#define ZIP_FLAG_COMPRESS2 2
#define ZIP_COMPRESS_NORMAL 0
#define ZIP_COMPRESS_MAXIMAL 1
#define ZIP_COMPRESS_FAST 2
#define ZIP_COMPRESS_SUPERFAST 3
#define ZIP_FLAG_FOOTER 3 //A zipfooter_t trails all total compression data.
#define ZIP_METHOD_STORE 0 //- The file is stored (no compression)
#define ZIP_METHOD_SHRINK 1 //- The file is Shrunk
#define ZIP_METHOD_REDUCE1 2 //- The file is Reduced with compression factor 1
#define ZIP_METHOD_REDUCE2 3 //- The file is Reduced with compression factor 2
#define ZIP_METHOD_REDUCE3 4 //- The file is Reduced with compression factor 3
#define ZIP_METHOD_REDUCE4 5 //- The file is Reduced with compression factor 4
#define ZIP_METHOD_IMPLODE 6 //- The file is Imploded
#define ZIP_METHOD_TOKENIZE 7 //- Reserved for Tokenizing compression algorithm
#define ZIP_METHOD_DEFLATE 8 //- The file is Deflated
#define ZIP_METHOD_DEFLATE2 9 //- Reserved for enhanced Deflating
#define ZIP_METHOD_IMPLODE2 10 //- PKWARE Date Compression Library Imploding
#define ZIP_ATTRIB_ASCII 0