Module: Zlib

Defined in:
lib/pr/zlib.rb

Defined Under Namespace

Classes: BufError, DataError, Deflate, Error, GzipFile, GzipReader, GzipWriter, Inflate, MemError, NeedDict, StreamEnd, StreamError, VersionError, ZStream, ZStreamFuncs

Constant Summary collapse

RUBY_ZLIB_VERSION =
'0.6.0'
PR_ZLIB_VERSION =
'1.0.0'
VERSION =
RUBY_ZLIB_VERSION
ZLIB_VERSION =
ZLIB_VERSION
BINARY =
Z_BINARY
ASCII =
Z_ASCII
UNKNOWN =
Z_UNKNOWN
NO_COMPRESSION =
Z_NO_COMPRESSION
BEST_SPEED =
Z_BEST_SPEED
BEST_COMPRESSION =
Z_BEST_COMPRESSION
DEFAULT_COMPRESSION =
Z_DEFAULT_COMPRESSION
FILTERED =
Z_FILTERED
HUFFMAN_ONLY =
Z_HUFFMAN_ONLY
DEFAULT_STRATEGY =
Z_DEFAULT_STRATEGY
MAX_WBITS =
MAX_WBITS
DEF_MEM_LEVEL =
DEF_MEM_LEVEL
MAX_MEM_LEVEL =
MAX_MEM_LEVEL
NO_FLUSH =
Z_NO_FLUSH
SYNC_FLUSH =
Z_SYNC_FLUSH
FULL_FLUSH =
Z_FULL_FLUSH
FINISH =
Z_FINISH
OS_CODE =
OS_CODE
OS_MSDOS =
0x00
OS_AMIGA =
0x01
OS_VMS =
0x02
OS_UNIX =
0x03
OS_ATARI =
0x05
OS_OS2 =
0x06
OS_MACOS =
0x07
OS_TOPS20 =
0x0a
OS_WIN32 =
0x0b
ZSTREAM_FLAG_READY =
0x1
ZSTREAM_FLAG_IN_STREAM =
0x2
ZSTREAM_FLAG_FINISHED =
0x4
ZSTREAM_FLAG_CLOSING =
0x8
ZSTREAM_FLAG_UNUSED =
0x10
ZSTREAM_INITIAL_BUFSIZE =
1024
ZSTREAM_AVAIL_OUT_STEP_MAX =
16384
ZSTREAM_AVAIL_OUT_STEP_MIN =
2048
DeflateFuncs =
ZStreamFuncs.new(:deflateReset, :deflateEnd, :deflate)
InflateFuncs =
ZStreamFuncs.new(:inflateReset, :inflateEnd, :inflate)

Class Method Summary collapse

Class Method Details

.adler32(string = nil, adler = nil) ⇒ Object



1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
# File 'lib/pr/zlib.rb', line 1510

def adler32(string=nil, adler=nil)
  if adler
    [adler].pack('L')  # check range
    sum = adler
  elsif string.nil?
    sum = 0
  else
    sum = Rbzlib.adler32(0,nil)
  end

  if string.nil?
    sum = Rbzlib.adler32(sum,nil)
  else
    sum = Rbzlib.adler32(sum,string,string.length)
  end
  sum
end

.crc32(string = nil, adler = nil) ⇒ Object



1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
# File 'lib/pr/zlib.rb', line 1528

def crc32(string=nil, adler=nil)
  if adler
    [adler].pack('L') # check range
    sum = adler
  elsif string.nil?
    sum = 0
  else
    sum = Rbzlib.crc32(0,nil)
  end

  if string.nil?
    sum = Rbzlib.crc32(sum,nil)
  else
    sum = Rbzlib.crc32(sum,string,string.length)
  end
  sum
end

.crc_tableObject



1546
1547
1548
# File 'lib/pr/zlib.rb', line 1546

def crc_table
  get_crc_table
end

.zlib_versionObject



1506
1507
1508
# File 'lib/pr/zlib.rb', line 1506

def zlib_version
  zlibVersion()
end