5 V4.92a 29 Aug 2006 (c) 2000-2006 John Lim (jlim#natsoft.com.my). All rights reserved.
6 Contributed by Ross Smith (adodb@netebb.com).
7 Released under both BSD license and Lesser GPL library license.
8 Whenever there is any discrepancy between the two licenses,
9 the BSD license will take precedence.
10 Set tabs to 4 for best viewing.
14 if (!function_exists('gzcompress')) {
15 trigger_error('gzip functions are not available', E_USER_ERROR
);
21 class ADODB_Compress_Gzip
{
38 function setLevel($level) {
39 assert('$level >= 0');
40 assert('$level <= 9');
41 $this->_level
= (int) $level;
46 function getMinLength() {
47 return $this->_min_length
;
52 function setMinLength($min_length) {
53 assert('$min_length >= 0');
54 $this->_min_length
= (int) $min_length;
59 function ADODB_Compress_Gzip($level = null, $min_length = null) {
60 if (!is_null($level)) {
61 $this->setLevel($level);
64 if (!is_null($min_length)) {
65 $this->setMinLength($min_length);
71 function write($data, $key) {
72 if (strlen($data) < $this->_min_length
) {
76 if (!is_null($this->_level
)) {
77 return gzcompress($data, $this->_level
);
79 return gzcompress($data);
85 function read($data, $key) {
86 return $data ?
gzuncompress($data) : $data;