|
10 | 10 | * http://themanaworld.org/ |
11 | 11 | * from the mapreader.cpp file |
12 | 12 | * |
| 13 | + * Some modifications were taken from: |
| 14 | + * https://www.codeandweb.com/texturepacker/contentprotection |
| 15 | + * |
13 | 16 | */ |
14 | | - |
| 17 | + |
15 | 18 | #ifndef __CC_ZIP_UTILS_H |
16 | 19 | #define __CC_ZIP_UTILS_H |
17 | 20 |
|
|
20 | 23 | #ifdef __cplusplus |
21 | 24 | extern "C" { |
22 | 25 | #endif |
23 | | - |
24 | | - /** |
25 | | - * Set the TexturePacker encryption key |
26 | | - * |
27 | | - * If your key used to encrypt the pvr.ccz file is |
28 | | - * aaaaaaaabbbbbbbbccccccccdddddddd |
29 | | - * you have to call this function 4 times: |
30 | | - * caw_setkey_part(0, 0xaaaaaaaa); |
31 | | - * caw_setkey_part(1, 0xbbbbbbbb); |
32 | | - * caw_setkey_part(2, 0xcccccccc); |
33 | | - * caw_setkey_part(3, 0xdddddddd); |
34 | | - * |
35 | | - * Distribute the call accross some files but make sure |
36 | | - * to call all of the parts *before* loading the first |
37 | | - * spritesheet. |
38 | | - * |
39 | | - * @param index part of the key [0..3] |
40 | | - * @param value value of the key part |
41 | | - */ |
42 | | - void caw_setkey_part(int index, uint32_t value); |
43 | 26 |
|
44 | | - /* XXX: pragma pack ??? */ |
45 | | - /** @struct CCZHeader |
46 | | - */ |
47 | | - struct CCZHeader { |
48 | | - uint8_t sig[4]; // signature. Should be 'CCZ!' 4 bytes |
49 | | - uint16_t compression_type; // should 0 |
50 | | - uint16_t version; // should be 2 (although version type==1 is also supported) |
51 | | - uint32_t reserved; // Reserverd for users. |
52 | | - uint32_t len; // size of the uncompressed file |
53 | | - }; |
| 27 | +/** |
| 28 | + * Set the TexturePacker encryption key |
| 29 | + * |
| 30 | + * If your key used to encrypt the pvr.ccz file is |
| 31 | + * aaaaaaaabbbbbbbbccccccccdddddddd |
| 32 | + * you have to call this function 4 times: |
| 33 | + * caw_setkey_part(0, 0xaaaaaaaa); |
| 34 | + * caw_setkey_part(1, 0xbbbbbbbb); |
| 35 | + * caw_setkey_part(2, 0xcccccccc); |
| 36 | + * caw_setkey_part(3, 0xdddddddd); |
| 37 | + * |
| 38 | + * Distribute the call accross some files but make sure |
| 39 | + * to call all of the parts *before* loading the first |
| 40 | + * spritesheet. |
| 41 | + * |
| 42 | + * @param index part of the key [0..3] |
| 43 | + * @param value value of the key part |
| 44 | + */ |
| 45 | +void caw_setkey_part(int index, uint32_t value); |
| 46 | + |
| 47 | +/* XXX: pragma pack ??? */ |
| 48 | +/** @struct CCZHeader |
| 49 | + */ |
| 50 | +struct CCZHeader { |
| 51 | + uint8_t sig[4]; // signature. Should be 'CCZ!' 4 bytes |
| 52 | + uint16_t compression_type; // should 0 |
| 53 | + uint16_t version; // should be 2 (although version type==1 is also supported) |
| 54 | + uint32_t reserved; // Reserverd for users. |
| 55 | + uint32_t len; // size of the uncompressed file |
| 56 | +}; |
54 | 57 |
|
55 | | - enum { |
56 | | - CCZ_COMPRESSION_ZLIB, // zlib format. |
57 | | - CCZ_COMPRESSION_BZIP2, // bzip2 format (not supported yet) |
58 | | - CCZ_COMPRESSION_GZIP, // gzip format (not supported yet) |
59 | | - CCZ_COMPRESSION_NONE, // plain (not supported yet) |
60 | | - }; |
| 58 | +enum { |
| 59 | + CCZ_COMPRESSION_ZLIB, // zlib format. |
| 60 | + CCZ_COMPRESSION_BZIP2, // bzip2 format (not supported yet) |
| 61 | + CCZ_COMPRESSION_GZIP, // gzip format (not supported yet) |
| 62 | + CCZ_COMPRESSION_NONE, // plain (not supported yet) |
| 63 | +}; |
61 | 64 |
|
62 | 65 | /** @file |
63 | 66 | * Zip helper functions |
64 | 67 | */ |
65 | | - |
| 68 | + |
66 | 69 | /** |
67 | 70 | * Inflates either zlib or gzip deflated memory. The inflated memory is |
68 | 71 | * expected to be freed by the caller. |
69 | 72 | * |
70 | 73 | * 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. |
71 | 74 | * @returns the length of the deflated buffer |
72 | 75 | * |
73 | | - @since v0.8.1 |
| 76 | + @since v0.8.1 |
74 | 77 | */ |
75 | 78 | int ccInflateMemory(unsigned char *in, unsigned int inLength, unsigned char **out); |
76 | 79 |
|
77 | 80 | /** |
78 | 81 | * Inflates either zlib or gzip deflated memory. The inflated memory is |
79 | 82 | * expected to be freed by the caller. |
80 | 83 | * |
81 | | - * outLenghtHint is assumed to be the needed room to allocate the inflated buffer. |
| 84 | + * outLengthHint is assumed to be the needed room to allocate the inflated buffer. |
82 | 85 | * |
83 | 86 | * @returns the length of the deflated buffer |
84 | 87 | * |
85 | | - @since v1.0.0 |
| 88 | + @since v1.0.0 |
86 | 89 | */ |
87 | 90 | int ccInflateMemoryWithHint(unsigned char *in, unsigned int inLength, unsigned char **out, unsigned int outLengthHint ); |
88 | 91 |
|
|
0 commit comments