summary refs log tree commit diff stats
path: root/libs/cocos2d/Support/ZipUtils.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/cocos2d/Support/ZipUtils.h')
-rwxr-xr-xlibs/cocos2d/Support/ZipUtils.h91
1 files changed, 91 insertions, 0 deletions
diff --git a/libs/cocos2d/Support/ZipUtils.h b/libs/cocos2d/Support/ZipUtils.h new file mode 100755 index 0000000..363f911 --- /dev/null +++ b/libs/cocos2d/Support/ZipUtils.h
@@ -0,0 +1,91 @@
1/* cocos2d for iPhone
2 *
3 * http://www.cocos2d-iphone.org
4 *
5 *
6 * inflateMemory_ based on zlib example code
7 * http://www.zlib.net
8 *
9 * Some ideas were taken from:
10 * http://themanaworld.org/
11 * from the mapreader.cpp file
12 *
13 */
14
15#ifndef __CC_ZIP_UTILS_H
16#define __CC_ZIP_UTILS_H
17
18#import <stdint.h>
19
20#ifdef __cplusplus
21extern "C" {
22#endif
23
24 /* XXX: pragma pack ??? */
25 /** @struct CCZHeader
26 */
27 struct CCZHeader {
28 uint8_t sig[4]; // signature. Should be 'CCZ!' 4 bytes
29 uint16_t compression_type; // should 0
30 uint16_t version; // should be 2 (although version type==1 is also supported)
31 uint32_t reserved; // Reserverd for users.
32 uint32_t len; // size of the uncompressed file
33 };
34
35 enum {
36 CCZ_COMPRESSION_ZLIB, // zlib format.
37 CCZ_COMPRESSION_BZIP2, // bzip2 format (not supported yet)
38 CCZ_COMPRESSION_GZIP, // gzip format (not supported yet)
39 CCZ_COMPRESSION_NONE, // plain (not supported yet)
40 };
41
42/** @file
43 * Zip helper functions
44 */
45
46/**
47 * Inflates either zlib or gzip deflated memory. The inflated memory is
48 * expected to be freed by the caller.
49 *
50 * It will allocate 256k for the destination buffer. If it is not enought it will multiply the previous buffer size per 2, until there is enough memory.
51 * @returns the length of the deflated buffer
52 *
53 @since v0.8.1
54 */
55int ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out);
56
57/**
58 * Inflates either zlib or gzip deflated memory. The inflated memory is
59 * expected to be freed by the caller.
60 *
61 * outLenghtHint is assumed to be the needed room to allocate the inflated buffer.
62 *
63 * @returns the length of the deflated buffer
64 *
65 @since v1.0.0
66 */
67int ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLenghtHint );
68
69
70/** inflates a GZip file into memory
71 *
72 * @returns the length of the deflated buffer
73 *
74 * @since v0.99.5
75 */
76int ccInflateGZipFile(const char *filename, unsigned char **out);
77
78/** inflates a CCZ file into memory
79 *
80 * @returns the length of the deflated buffer
81 *
82 * @since v0.99.5
83 */
84int ccInflateCCZFile(const char *filename, unsigned char **out);
85
86
87#ifdef __cplusplus
88}
89#endif
90
91#endif // __CC_ZIP_UTILS_H