[4057] added: Line of sight (vmaps) [part 2] (last part)
[mangos-git.git] / contrib / vmap_extractor_v2 / stormlib / pklib / pklib.h
blob5bb8ffceeddfa4565efe676650847d1f53e902d0
1 /*****************************************************************************/
2 /* pklib.h Copyright (c) Ladislav Zezula 2003 */
3 /*---------------------------------------------------------------------------*/
4 /* Header file for PKWARE Data Compression Library */
5 /*---------------------------------------------------------------------------*/
6 /* Date Ver Who Comment */
7 /* -------- ---- --- ------- */
8 /* 31.03.03 1.00 Lad The first version of pkware.h */
9 /*****************************************************************************/
11 #ifndef __PKLIB_H__
12 #define __PKLIB_H__
14 #include "../StormPort.h"
16 //-----------------------------------------------------------------------------
17 // Defines
19 #define CMP_BINARY 0 // Binary compression
20 #define CMP_ASCII 1 // Ascii compression
22 #define CMP_NO_ERROR 0
23 #define CMP_INVALID_DICTSIZE 1
24 #define CMP_INVALID_MODE 2
25 #define CMP_BAD_DATA 3
26 #define CMP_ABORT 4
28 //-----------------------------------------------------------------------------
29 // Define calling convention
31 #ifndef PKEXPORT
32 #define PKEXPORT //__cdecl // Use for normal __cdecl calling
33 #endif
34 //#define PKEXPORT __stdcall
35 //#define PKEXPORT __fastcall
37 //-----------------------------------------------------------------------------
38 // Internal structures
40 // Compression structure
41 typedef struct
43 unsigned int offs0000; // 0000 :
44 unsigned int out_bytes; // 0004 : # bytes available in out_buff
45 unsigned int out_bits; // 0008 : # of bits available in the last out byte
46 unsigned int dsize_bits; // 000C : Dict size : 4=0x400, 5=0x800, 6=0x1000
47 unsigned int dsize_mask; // 0010 : Dict size : 0x0F=0x400, 0x1F=0x800, 0x3F=0x1000
48 unsigned int ctype; // 0014 : Compression type (Ascii or binary)
49 unsigned int dsize_bytes; // 0018 : Dictionary size in bytes
50 unsigned char dist_bits[0x40]; // 001C : Distance bits
51 unsigned char dist_codes[0x40]; // 005C : Distance codes
52 unsigned char nChBits[0x306]; // 009C :
53 unsigned short nChCodes[0x306]; // 03A2 :
54 unsigned short offs09AE; // 09AE :
56 void * param; // 09B0 : User parameter
57 unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 9B4
58 void (*write_buf)(char *buf, unsigned int *size, void *param); // 9B8
60 unsigned short offs09BC[0x204]; // 09BC :
61 unsigned long offs0DC4; // 0DC4 :
62 unsigned short offs0DC8[0x900]; // 0DC8 :
63 unsigned short offs1FC8; // 1FC8 :
64 char out_buff[0x802]; // 1FCA : Output (compressed) data
65 unsigned char work_buff[0x2204]; // 27CC : Work buffer
66 // + DICT_OFFSET => Dictionary
67 // + UNCMP_OFFSET => Uncompressed data
68 unsigned short offs49D0[0x2000]; // 49D0 :
69 } TCmpStruct;
71 #define CMP_BUFFER_SIZE sizeof(TCmpStruct) // Size of compression buffer
74 // Decompression structure
75 typedef struct
77 unsigned long offs0000; // 0000
78 unsigned long ctype; // 0004 - Compression type (CMP_BINARY or CMP_ASCII)
79 unsigned long outputPos; // 0008 - Position in output buffer
80 unsigned long dsize_bits; // 000C - Dict size (4, 5, 6 for 0x400, 0x800, 0x1000)
81 unsigned long dsize_mask; // 0010 - Dict size bitmask (0x0F, 0x1F, 0x3F for 0x400, 0x800, 0x1000)
82 unsigned long bit_buff; // 0014 - 16-bit buffer for processing input data
83 unsigned long extra_bits; // 0018 - Number of extra (above 8) bits in bit buffer
84 unsigned int in_pos; // 001C - Position in in_buff
85 unsigned long in_bytes; // 0020 - Number of bytes in input buffer
86 void * param; // 0024 - Custom parameter
87 unsigned int (*read_buf)(char *buf, unsigned int *size, void *param); // 0028
88 void (*write_buf)(char *buf, unsigned int *size, void *param);// 002C
89 unsigned char out_buff[0x2000]; // 0030 - Output circle buffer. Starting position is 0x1000
90 unsigned char offs2030[0x204]; // 2030 - ???
91 unsigned char in_buff[0x800]; // 2234 - Buffer for data to be decompressed
92 unsigned char position1[0x100]; // 2A34 - Positions in buffers
93 unsigned char position2[0x100]; // 2B34 - Positions in buffers
94 unsigned char offs2C34[0x100]; // 2C34 - Buffer for
95 unsigned char offs2D34[0x100]; // 2D34 - Buffer for
96 unsigned char offs2E34[0x80]; // 2EB4 - Buffer for
97 unsigned char offs2EB4[0x100]; // 2EB4 - Buffer for
98 unsigned char ChBitsAsc[0x100]; // 2FB4 - Buffer for
99 unsigned char DistBits[0x40]; // 30B4 - Numbers of bytes to skip copied block length
100 unsigned char LenBits[0x10]; // 30F4 - Numbers of bits for skip copied block length
101 unsigned char ExLenBits[0x10]; // 3104 - Number of valid bits for copied block
102 unsigned short LenBase[0x10]; // 3114 - Buffer for
103 } TDcmpStruct;
105 #define EXP_BUFFER_SIZE sizeof(TDcmpStruct) // Size of decompress buffer
107 //-----------------------------------------------------------------------------
108 // Public functions
110 #ifdef __cplusplus
111 extern "C" {
112 #endif
114 unsigned int PKEXPORT implode(
115 unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
116 void (*write_buf)(char *buf, unsigned int *size, void *param),
117 char *work_buf,
118 void *param,
119 unsigned int *type,
120 unsigned int *dsize);
123 unsigned int PKEXPORT explode(
124 unsigned int (*read_buf)(char *buf, unsigned int *size, void *param),
125 void (*write_buf)(char *buf, unsigned int *size, void *param),
126 char *work_buf,
127 void *param);
129 // The original name "crc32" was changed to "crc32pk" due
130 // to compatibility with zlib
131 unsigned long PKEXPORT crc32pk(char *buffer, unsigned int *size, unsigned long *old_crc);
133 #ifdef __cplusplus
134 } // End of 'extern "C"' declaration
135 #endif
137 #endif // __PKLIB_H__