Fix CRLF
[openemr.git] / library / adodb / session / adodb-compress-gzip.php
blob304bca0df88f9b36bf384d009aa10dcd885abec9
1 <?php
3 // $CVSHeader$
5 /*
6 V4.01 23 Oct 2003 (c) 2000-2004 John Lim (jlim@natsoft.com.my). All rights reserved.
7 Contributed by Ross Smith (adodb@netebb.com).
8 Released under both BSD license and Lesser GPL library license.
9 Whenever there is any discrepancy between the two licenses,
10 the BSD license will take precedence.
11 Set tabs to 4 for best viewing.
15 if (!function_exists('gzcompress')) {
16 trigger_error('gzip functions are not available', E_USER_ERROR);
17 return 0;
22 class ADODB_Compress_Gzip {
23 /**
25 var $_level = null;
27 /**
29 var $_min_length = 1;
31 /**
33 function getLevel() {
34 return $this->_level;
37 /**
39 function setLevel($level) {
40 assert('$level >= 0');
41 assert('$level <= 9');
42 $this->_level = (int) $level;
45 /**
47 function getMinLength() {
48 return $this->_min_length;
51 /**
53 function setMinLength($min_length) {
54 assert('$min_length >= 0');
55 $this->_min_length = (int) $min_length;
58 /**
60 function ADODB_Compress_Gzip($level = null, $min_length = null) {
61 if (!is_null($level)) {
62 $this->setLevel($level);
65 if (!is_null($min_length)) {
66 $this->setMinLength($min_length);
70 /**
72 function write($data, $key) {
73 if (strlen($data) < $this->_min_length) {
74 return $data;
77 if (!is_null($this->_level)) {
78 return gzcompress($data, $this->_level);
79 } else {
80 return gzcompress($data);
84 /**
86 function read($data, $key) {
87 return $data ? gzuncompress($data) : $data;
92 return 1;