Remove Eval.CheckRepoAuthDeserialize
[hiphop-php.git] / hphp / runtime / ext / zlib / quicklz.h
blob69a190c54bdd36a911575ff949ffeb468ac73add
2 // Fast data compression library
3 // Copyright (C) 2006-2009 Lasse Mikkel Reinhold
4 // lar@quicklz.com
5 //
6 // QuickLZ can be used for free under the GPL-1 or GPL-2 license (where anything
7 // released into public must be open source) or under a commercial license if such
8 // has been acquired (see http://www.quicklz.com/order.html). The commercial license
9 // does not cover derived or ported versions created by third parties under GPL.
11 // You can edit following user settings. Data must be decompressed with the same
12 // setting of QLZ_COMPRESSION_LEVEL and QLZ_STREAMING_BUFFER as it was compressed
13 // (see manual). If QLZ_STREAMING_BUFFER > 0, scratch buffers must be initially
14 // zeroed out (see manual). First #ifndef makes it possible to define settings from
15 // the outside like the compiler command line.
17 // BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION
18 // BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION
19 // BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION
20 // BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION
21 // BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION BETA VERSION
23 // 1.5.0 BETA 2
25 #ifndef QLZ_COMPRESSION_LEVEL
26 #define QLZ_COMPRESSION_LEVEL 1
27 //#define QLZ_COMPRESSION_LEVEL 2
28 //#define QLZ_COMPRESSION_LEVEL 3
30 #define QLZ_STREAMING_BUFFER 0
31 //#define QLZ_STREAMING_BUFFER 100000
32 //#define QLZ_STREAMING_BUFFER 1000000
34 //#define QLZ_MEMORY_SAFE
35 #endif
37 #define QLZ_VERSION_MAJOR 1
38 #define QLZ_VERSION_MINOR 5
39 #define QLZ_VERSION_REVISION 0
41 // Verify compression level
42 #if QLZ_COMPRESSION_LEVEL != 1 && QLZ_COMPRESSION_LEVEL != 2 && QLZ_COMPRESSION_LEVEL != 3
43 #error QLZ_COMPRESSION_LEVEL must be 1, 2 or 3
44 #endif
46 typedef unsigned int ui32;
47 typedef unsigned short int ui16;
49 #ifdef QLZ_POINTERS
50 #undef QLZ_POINTERS
51 #undef QLZ_HASH_VALUES
52 #endif
54 // Decrease QLZ_POINTERS for level 3 to increase compression speed. Do not touch any other values!
55 #if QLZ_COMPRESSION_LEVEL == 1
56 #define QLZ_POINTERS 1
57 #define QLZ_HASH_VALUES 4096
58 #elif QLZ_COMPRESSION_LEVEL == 2
59 #define QLZ_POINTERS 4
60 #define QLZ_HASH_VALUES 2048
61 #elif QLZ_COMPRESSION_LEVEL == 3
62 #define QLZ_POINTERS 16
63 #define QLZ_HASH_VALUES 4096
64 #endif
66 // Detect if pointer size is 64-bit. It's not fatal if some 64-bit target is not detected because this is only for adding an optional 64-bit optimization.
67 #if defined _LP64 || defined __LP64__ || defined __64BIT__ || _ADDR64 || defined _WIN64 || defined __arch64__ || __WORDSIZE == 64 || (defined __sparc && defined __sparcv9) || defined __x86_64 || defined __amd64 || defined __x86_64__ || defined _M_X64 || defined _M_IA64 || defined __ia64 || defined __IA64__
68 #define QLZ_PTR_64
69 #endif
71 // hash entry
72 typedef struct
74 #if QLZ_COMPRESSION_LEVEL == 1
75 ui32 cache;
76 #if defined QLZ_PTR_64 && QLZ_STREAMING_BUFFER == 0
77 unsigned int offset;
78 #else
79 const unsigned char *offset;
80 #endif
81 #else
82 const unsigned char *offset[QLZ_POINTERS];
83 #endif
85 } qlz_hash_compress;
87 typedef struct
89 #if QLZ_COMPRESSION_LEVEL == 1
90 const unsigned char *offset;
91 #else
92 const unsigned char *offset[QLZ_POINTERS];
93 #endif
94 } qlz_hash_decompress;
97 // states
98 typedef struct
100 #if QLZ_STREAMING_BUFFER > 0
101 unsigned char stream_buffer[QLZ_STREAMING_BUFFER];
102 #endif
103 size_t stream_counter;
104 qlz_hash_compress hash[QLZ_HASH_VALUES];
105 unsigned char hash_counter[QLZ_HASH_VALUES];
106 } qlz_state_compress;
109 #if QLZ_COMPRESSION_LEVEL == 1 || QLZ_COMPRESSION_LEVEL == 2
110 typedef struct
112 #if QLZ_STREAMING_BUFFER > 0
113 unsigned char stream_buffer[QLZ_STREAMING_BUFFER];
114 #endif
115 qlz_hash_decompress hash[QLZ_HASH_VALUES];
116 unsigned char hash_counter[QLZ_HASH_VALUES];
117 size_t stream_counter;
118 } qlz_state_decompress;
119 #elif QLZ_COMPRESSION_LEVEL == 3
120 typedef struct
122 #if QLZ_STREAMING_BUFFER > 0
123 unsigned char stream_buffer[QLZ_STREAMING_BUFFER];
124 #endif
125 qlz_hash_decompress hash[QLZ_HASH_VALUES];
126 size_t stream_counter;
127 } qlz_state_decompress;
128 #endif
131 // Public functions of QuickLZ
132 size_t qlz_size_decompressed(const char *source);
133 size_t qlz_size_compressed(const char *source);
134 size_t qlz_compress(const void *source, char *destination, size_t size, qlz_state_compress *state);
135 size_t qlz_decompress(const char *source, void *destination, qlz_state_decompress *state);
136 int qlz_get_setting(int setting);