Fix CRLF
[openemr.git] / library / adodb / session / adodb-compress-bzip2.php
blob1ec70ef2e8d34682f77e588f1de36e10ccef241b
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('bzcompress')) {
16 trigger_error('bzip2 functions are not available', E_USER_ERROR);
17 return 0;
22 class ADODB_Compress_Bzip2 {
23 /**
25 var $_block_size = null;
27 /**
29 var $_work_level = null;
31 /**
33 var $_min_length = 1;
35 /**
37 function getBlockSize() {
38 return $this->_block_size;
41 /**
43 function setBlockSize($block_size) {
44 assert('$block_size >= 1');
45 assert('$block_size <= 9');
46 $this->_block_size = (int) $block_size;
49 /**
51 function getWorkLevel() {
52 return $this->_work_level;
55 /**
57 function setWorkLevel($work_level) {
58 assert('$work_level >= 0');
59 assert('$work_level <= 250');
60 $this->_work_level = (int) $work_level;
63 /**
65 function getMinLength() {
66 return $this->_min_length;
69 /**
71 function setMinLength($min_length) {
72 assert('$min_length >= 0');
73 $this->_min_length = (int) $min_length;
76 /**
78 function ADODB_Compress_Bzip2($block_size = null, $work_level = null, $min_length = null) {
79 if (!is_null($block_size)) {
80 $this->setBlockSize($block_size);
83 if (!is_null($work_level)) {
84 $this->setWorkLevel($work_level);
87 if (!is_null($min_length)) {
88 $this->setMinLength($min_length);
92 /**
94 function write($data, $key) {
95 if (strlen($data) < $this->_min_length) {
96 return $data;
99 if (!is_null($this->_block_size)) {
100 if (!is_null($this->_work_level)) {
101 return bzcompress($data, $this->_block_size, $this->_work_level);
102 } else {
103 return bzcompress($data, $this->_block_size);
107 return bzcompress($data);
112 function read($data, $key) {
113 return $data ? bzdecompress($data) : $data;
118 return 1;