Skip to content

Commit e15ec92

Browse files
authored
Merge pull request #38 from cracksalad/master
Add support for Frame format
2 parents f3faf6e + 5c8607f commit e15ec92

7 files changed

Lines changed: 447 additions & 6 deletions

File tree

README.md

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ RPM packages of this extension are available in [» Remi's RPM repository](https
3333

3434
DEB packages of this extension are available in [» Ondřej Surý's DEB repository](https://deb.sury.org/) and are named **php-lz4**.
3535

36+
## Installation via PIE
37+
38+
```bash
39+
pie install kjdev/lz4
40+
```
41+
3642

3743
## Configuration
3844

@@ -42,8 +48,10 @@ php.ini:
4248

4349
## Function
4450

45-
* lz4\_compress — LZ4 compression
46-
* lz4\_uncompress — LZ4 decompression
51+
* lz4\_compress — LZ4 compression (block format)
52+
* lz4\_uncompress — LZ4 decompression (block format)
53+
* lz4\_compress\_frame — LZ4 compression (frame format)
54+
* lz4\_uncompress\_frame — LZ4 decompression (frame format)
4755

4856
### lz4\_compress — LZ4 compression
4957

@@ -53,7 +61,7 @@ string **lz4\_compress** ( string _$data_ [ , int _$level_ = 0 , string _$extra_
5361

5462
LZ4 compression.
5563

56-
#### Pameters
64+
#### Parameters
5765

5866
* _data_
5967

@@ -81,7 +89,7 @@ string **lz4\_uncompress** ( string _$data_ [ , long _$maxsize_ = -1 , long _$of
8189

8290
LZ4 decompression.
8391

84-
#### Pameters
92+
#### Parameters
8593

8694
* _data_
8795

@@ -99,6 +107,70 @@ LZ4 decompression.
99107

100108
Returns the decompressed data or FALSE if an error occurred.
101109

110+
111+
### lz4\_compress\_frame — LZ4 compression (frame format)
112+
113+
#### Description
114+
115+
string **lz4\_compress\_frame** ( string _$data_ [ , int _$level_ = 0 , int _$max_block_size_ = 0 , int _$checksums_ = 0 ] )
116+
117+
LZ4 compression to frame.
118+
119+
#### Parameters
120+
121+
* _data_
122+
123+
The string to compress.
124+
125+
* _level_
126+
127+
The level of compression (1-12, Recommended values are between 4 and 9).
128+
(Default to 0, Not High Compression Mode.)
129+
130+
* _max\_block\_size_
131+
132+
Maximum uncompressed size of each block.
133+
Pass any of the following values:
134+
135+
* _LZ4\_BLOCK\_SIZE\_64KB_
136+
* _LZ4\_BLOCK\_SIZE\_256KB_
137+
* _LZ4\_BLOCK\_SIZE\_1MB_
138+
* _LZ4\_BLOCK\_SIZE\_4MB_
139+
140+
Any other value will be treated as _LZ4\_BLOCK\_SIZE\_64KB_.
141+
142+
* _checksums_
143+
144+
Enable/disable frame-level and block-level checksums.
145+
Pass a bitwise combination of the following constants:
146+
147+
* _LZ4\_CHECKSUM\_FRAME_: frame-level checksum
148+
* _LZ4\_CHECKSUM\_BLOCK_: block-level checksum
149+
150+
#### Return Values
151+
152+
Returns the compressed data or FALSE if an error occurred.
153+
154+
155+
### lz4\_uncompress\_frame — LZ4 decompression (frame format)
156+
157+
#### Description
158+
159+
string **lz4\_uncompress\_frame** ( string _$data_ )
160+
161+
LZ4 decompression from frame.
162+
163+
#### Parameters
164+
165+
* _data_
166+
167+
The compressed string.
168+
169+
#### Return Values
170+
171+
Returns the decompressed data or FALSE if an error occurred.
172+
173+
102174
## Examples
103175

104176
$data = lz4_compress('test');

config.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ if test "$PHP_LZ4" != "no"; then
5959
else
6060
AC_MSG_RESULT(use bundled version)
6161

62-
PHP_NEW_EXTENSION(lz4, lz4.c lz4/lib/lz4.c lz4/lib/lz4hc.c lz4/lib/xxhash.c, $ext_shared)
62+
PHP_NEW_EXTENSION(lz4, lz4.c lz4/lib/lz4.c lz4/lib/lz4hc.c lz4/lib/lz4frame.c lz4/lib/xxhash.c, $ext_shared)
6363

6464
PHP_ADD_BUILD_DIR($ext_builddir/lz4/lib, 1)
6565
PHP_ADD_INCLUDE([$ext_srcdir/lz4/lib])

config.w32

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ if (PHP_LZ4 != "no") {
66
EXTENSION("lz4", "lz4.c", PHP_LZ4_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
77
} else {
88
EXTENSION("lz4", "lz4.c", PHP_LZ4_SHARED, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
9-
ADD_SOURCES("lz4/lib", "lz4.c lz4hc.c xxhash.c", "lz4", "lz4\\lib");
9+
ADD_SOURCES("lz4/lib", "lz4.c lz4frame.c lz4hc.c xxhash.c", "lz4", "lz4\\lib");
1010
ADD_FLAG("CFLAGS_LZ4", " /I" + configure_module_dirname + " /I" + configure_module_dirname + "/lz4/lib");
1111
}
1212
PHP_INSTALL_HEADERS("ext/lz4/", "php_lz4.h");

0 commit comments

Comments
 (0)