Overview
Access to the zlib library.
Class tree
(if you have GZIP_SUPPORT)
see also zlib.h
- CLASS Zlib::BufError
- CLASS Zlib::DataError
- CLASS Zlib::Deflate
- CLASS Zlib::Error
- CLASS Zlib::GzipFile
- CLASS Zlib::GzipReader
- CLASS Zlib::GzipWriter
- CLASS Zlib::Inflate
- CLASS Zlib::MemError
- CLASS Zlib::NeedDict
- CLASS Zlib::StreamEnd
- CLASS Zlib::StreamError
- CLASS Zlib::VersionError
- CLASS Zlib::ZStream
- A
- C
- D
- I
- Z
VERSION | = | rb_str_new2(RUBY_ZLIB_VERSION) |
The Ruby/zlib version string. |
||
ZLIB_VERSION | = | rb_str_new2(ZLIB_VERSION) |
The string which represents the version of zlib.h |
||
BINARY | = | INT2FIX(Z_BINARY) |
Integer representing date types which Zlib::ZStream#data_type method returns |
||
ASCII | = | INT2FIX(Z_ASCII) |
Integer representing date types which Zlib::ZStream#data_type method returns |
||
UNKNOWN | = | INT2FIX(Z_UNKNOWN) |
Integer representing date types which Zlib::ZStream#data_type method returns |
||
NO_COMPRESSION | = | INT2FIX(Z_NO_COMPRESSION) |
compression level 0 Which is an argument for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. |
||
BEST_SPEED | = | INT2FIX(Z_BEST_SPEED) |
compression level 1 Which is an argument for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. |
||
BEST_COMPRESSION | = | INT2FIX(Z_BEST_COMPRESSION) |
compression level 9 Which is an argument for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. |
||
DEFAULT_COMPRESSION | = | INT2FIX(Z_DEFAULT_COMPRESSION) |
compression level -1 Which is an argument for Zlib::Deflate.new, Zlib::Deflate#deflate, and so on. |
||
FILTERED | = | INT2FIX(Z_FILTERED) |
compression method 1 Which is an argument for Zlib::Deflate.new and Zlib::Deflate#params. |
||
HUFFMAN_ONLY | = | INT2FIX(Z_HUFFMAN_ONLY) |
compression method 2 Which is an argument for Zlib::Deflate.new and Zlib::Deflate#params. |
||
DEFAULT_STRATEGY | = | INT2FIX(Z_DEFAULT_STRATEGY) |
compression method 0 Which is an argument for Zlib::Deflate.new and Zlib::Deflate#params. |
||
MAX_WBITS | = | INT2FIX(MAX_WBITS) |
The default value of windowBits which is an argument for Zlib::Deflate.new and Zlib::Inflate.new. |
||
DEF_MEM_LEVEL | = | INT2FIX(DEF_MEM_LEVEL) |
Default value is 8 The integer representing memory levels. Which are an argument for Zlib::Deflate.new, Zlib::Deflate#params, and so on. |
||
MAX_MEM_LEVEL | = | INT2FIX(MAX_MEM_LEVEL) |
Maximum level is 9 The integers representing memory levels which are an argument for Zlib::Deflate.new, Zlib::Deflate#params, and so on. |
||
NO_FLUSH | = | INT2FIX(Z_NO_FLUSH) |
Output control - 0 The integers to control the output of the deflate stream, which are an argument for Zlib::Deflate#deflate and so on. |
||
SYNC_FLUSH | = | INT2FIX(Z_SYNC_FLUSH) |
Output control - 2 The integers to control the output of the deflate stream, which are an argument for Zlib::Deflate#deflate and so on. |
||
FULL_FLUSH | = | INT2FIX(Z_FULL_FLUSH) |
Output control - 3 The integers to control the output of the deflate stream, which are an argument for Zlib::Deflate#deflate and so on. |
||
FINISH | = | INT2FIX(Z_FINISH) |
Oputput control - 4 The integers to control the output of the deflate stream, which are an argument for Zlib::Deflate#deflate and so on. |
||
OS_CODE | = | INT2FIX(OS_CODE) |
From Zlib::GzipFile#os_code - code of current host |
||
OS_MSDOS | = | INT2FIX(OS_MSDOS) |
From Zlib::GzipFile#os_code - 0x00 |
||
OS_AMIGA | = | INT2FIX(OS_AMIGA) |
From Zlib::GzipFile#os_code - 0x01 |
||
OS_VMS | = | INT2FIX(OS_VMS) |
From Zlib::GzipFile#os_code - 0x02 |
||
OS_UNIX | = | INT2FIX(OS_UNIX) |
From Zlib::GzipFile#os_code - 0x03 |
||
OS_ATARI | = | INT2FIX(OS_ATARI) |
From Zlib::GzipFile#os_code - 0x05 |
||
OS_OS2 | = | INT2FIX(OS_OS2) |
From Zlib::GzipFile#os_code - 0x06 |
||
OS_MACOS | = | INT2FIX(OS_MACOS) |
From Zlib::GzipFile#os_code - 0x07 |
||
OS_TOPS20 | = | INT2FIX(OS_TOPS20) |
From Zlib::GzipFile#os_code - 0x0a |
||
OS_WIN32 | = | INT2FIX(OS_WIN32) |
From Zlib::GzipFile#os_code - 0x0b |
||
OS_VMCMS | = | INT2FIX(OS_VMCMS) |
From Zlib::GzipFile#os_code - 0x04 |
||
OS_ZSYSTEM | = | INT2FIX(OS_ZSYSTEM) |
From Zlib::GzipFile#os_code - 0x08 |
||
OS_CPM | = | INT2FIX(OS_CPM) |
From Zlib::GzipFile#os_code - 0x09 |
||
OS_QDOS | = | INT2FIX(OS_QDOS) |
From Zlib::GzipFile#os_code - 0x0c |
||
OS_RISCOS | = | INT2FIX(OS_RISCOS) |
From Zlib::GzipFile#os_code - 0x0d |
||
OS_UNKNOWN | = | INT2FIX(OS_UNKNOWN) |
From Zlib::GzipFile#os_code - 0xff |
Calculates Adler-32 checksum for string
, and returns updated
value of adler
. If string
is omitted, it returns
the Adler-32 initial value. If adler
is omitted, it assumes
that the initial value is given to adler
.
FIXME: expression.
Source: show
static VALUE rb_zlib_adler32(int argc, VALUE *argv, VALUE klass) { return do_checksum(argc, argv, adler32); }
Combine two Adler-32 check values in to one. alder1
is the
first Adler-32 value, adler2
is the second Adler-32 value.
len2
is the length of the string used to generate
adler2
.
Source: show
static VALUE rb_zlib_adler32_combine(VALUE klass, VALUE adler1, VALUE adler2, VALUE len2) { return ULONG2NUM( adler32_combine(NUM2ULONG(adler1), NUM2ULONG(adler2), NUM2LONG(len2))); }
Calculates CRC checksum for string
, and returns updated value
of crc
. If string
is omitted, it returns the CRC
initial value. If crc
is omitted, it assumes that the initial
value is given to crc
.
FIXME: expression.
Source: show
static VALUE rb_zlib_crc32(int argc, VALUE *argv, VALUE klass) { return do_checksum(argc, argv, crc32); }
Combine two CRC-32 check values in to one. crc1
is the first
CRC-32 value, crc2
is the second CRC-32 value.
len2
is the length of the string used to generate
crc2
.
Source: show
static VALUE rb_zlib_crc32_combine(VALUE klass, VALUE crc1, VALUE crc2, VALUE len2) { return ULONG2NUM( crc32_combine(NUM2ULONG(crc1), NUM2ULONG(crc2), NUM2LONG(len2))); }
Returns the table for calculating CRC checksum as an array.
Source: show
static VALUE rb_zlib_crc_table(VALUE obj) { #if !defined(HAVE_TYPE_Z_CRC_T) /* z_crc_t is defined since zlib-1.2.7. */ typedef unsigned long z_crc_t; #endif const z_crc_t *crctbl; VALUE dst; int i; crctbl = get_crc_table(); dst = rb_ary_new2(256); for (i = 0; i < 256; i++) { rb_ary_push(dst, rb_uint2inum(crctbl[i])); } return dst; }
Compresses the given string
. Valid values of level are
NO_COMPRESSION
, BEST_SPEED
,
BEST_COMPRESSION
, DEFAULT_COMPRESSION
, and an
integer from 0 to 9 (the default is 6).
This method is almost equivalent to the following code:
def deflate(string, level)
z = Zlib::Deflate.new(level)
dst = z.deflate(string, Zlib::NO_FLUSH)
z.close
dst
end
See also ::inflate
Source: show
static VALUE rb_deflate_s_deflate(int argc, VALUE *argv, VALUE klass) { struct zstream z; VALUE src, level, dst, args[2]; int err, lev; rb_scan_args(argc, argv, "11", &src, &level); lev = ARG_LEVEL(level); StringValue(src); zstream_init_deflate(&z); err = deflateInit(&z.stream, lev); if (err != Z_OK) { raise_zlib_error(err, z.stream.msg); } ZSTREAM_READY(&z); args[0] = (VALUE)&z; args[1] = src; dst = rb_ensure(deflate_run, (VALUE)args, zstream_end, (VALUE)&z); OBJ_INFECT(dst, src); return dst; }
Decompresses string
. Raises a Zlib::NeedDict exception if a preset
dictionary is needed for decompression.
This method is almost equivalent to the following code:
def inflate(string)
zstream = Zlib::Inflate.new
buf = zstream.inflate(string)
zstream.finish
zstream.close
buf
end
See also ::deflate
Source: show
static VALUE rb_inflate_s_inflate(VALUE obj, VALUE src) { struct zstream z; VALUE dst, args[2]; int err; StringValue(src); zstream_init_inflate(&z); err = inflateInit(&z.stream); if (err != Z_OK) { raise_zlib_error(err, z.stream.msg); } ZSTREAM_READY(&z); args[0] = (VALUE)&z; args[1] = src; dst = rb_ensure(inflate_run, (VALUE)args, zstream_end, (VALUE)&z); OBJ_INFECT(dst, src); return dst; }