Ruby 2.7.0p0(2019-12-25revision647ee6f091eafcce70ffb75ddf7e121e192ab217)

Data Structures | Macros | Functions
zlib.c File Reference
`#include <ruby.h>`
`#include <zlib.h>`
`#include <time.h>`
`#include <ruby/io.h>`
`#include <ruby/thread.h>`

Go to the source code of this file.

## Data Structures
struct | zstream
struct | zstream::zstream_funcs
struct | zstream_run_args
struct | gzfile
struct | read_raw_arg
struct | new_wrap_arg_t

## Macros
#define | VALGRIND_MAKE_MEM_DEFINED(p, n) 0
#define | VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
#define | RUBY_ZLIB_VERSION "1.1.0"
#define | GZIP_SUPPORT 1
#define | DEF_MEM_LEVEL MAX_MEM_LEVEL
#define | MAX_UINT(n) (uInt)(n)
#define | checksum_long(func, sum, ptr, len) (func)((sum), (ptr), (len))
#define | rb_zlib_adler32_combine rb_f_notimplement
#define | rb_zlib_crc32_combine rb_f_notimplement
#define | ZSTREAM_FLAG_READY 0x1
#define | ZSTREAM_FLAG_IN_STREAM 0x2
#define | ZSTREAM_FLAG_FINISHED 0x4
#define | ZSTREAM_FLAG_CLOSING 0x8
#define | ZSTREAM_FLAG_GZFILE
#define | ZSTREAM_FLAG_UNUSED 0x20
#define | ZSTREAM_READY(z) ((z)->flags |= ZSTREAM_FLAG_READY)
#define | ZSTREAM_IS_READY(z) ((z)->flags & ZSTREAM_FLAG_READY)
#define | ZSTREAM_IS_FINISHED(z) ((z)->flags & ZSTREAM_FLAG_FINISHED)
#define | ZSTREAM_IS_CLOSING(z) ((z)->flags & ZSTREAM_FLAG_CLOSING)
#define | ZSTREAM_IS_GZFILE(z) ((z)->flags & ZSTREAM_FLAG_GZFILE)
#define | ZSTREAM_BUF_FILLED(z) (NIL_P((z)->buf) ? 0 : RSTRING_LEN((z)->buf))
#define | ZSTREAM_EXPAND_BUFFER_OK 0
#define | ZSTREAM_INITIAL_BUFSIZE 1024
#define | ZSTREAM_AVAIL_OUT_STEP_MAX 16384
#define | ZSTREAM_AVAIL_OUT_STEP_MIN 2048
#define | zstream_init_deflate(z) zstream_init((z), &deflate_funcs)
#define | zstream_init_inflate(z) zstream_init((z), &inflate_funcs)
#define | zstream_append_buffer2(z, v) zstream_append_buffer((z),(Bytef*)RSTRING_PTR(v),RSTRING_LEN(v))
#define | zstream_append_input2(z, v)
#define | zstream_deflate_new(klass) zstream_new((klass), &deflate_funcs)
#define | zstream_inflate_new(klass) zstream_new((klass), &inflate_funcs)
#define | FIXNUMARG(val, ifnil)
#define | ARG_LEVEL(val) FIXNUMARG((val), Z_DEFAULT_COMPRESSION)
#define | ARG_WBITS(val) FIXNUMARG((val), MAX_WBITS)
#define | ARG_MEMLEVEL(val) FIXNUMARG((val), DEF_MEM_LEVEL)
#define | ARG_STRATEGY(val) FIXNUMARG((val), Z_DEFAULT_STRATEGY)
#define | ARG_FLUSH(val) FIXNUMARG((val), Z_NO_FLUSH)
#define | GZ_MAGIC1 0x1f
#define | GZ_MAGIC2 0x8b
#define | GZ_METHOD_DEFLATE 8
#define | GZ_FLAG_MULTIPART 0x2
#define | GZ_FLAG_EXTRA 0x4
#define | GZ_FLAG_ORIG_NAME 0x8
#define | GZ_FLAG_COMMENT 0x10
#define | GZ_FLAG_ENCRYPT 0x20
#define | GZ_FLAG_UNKNOWN_MASK 0xc0
#define | GZ_EXTRAFLAG_FAST 0x4
#define | GZ_EXTRAFLAG_SLOW 0x2
#define | OS_MSDOS 0x00
#define | OS_AMIGA 0x01
#define | OS_VMS 0x02
#define | OS_UNIX 0x03
#define | OS_ATARI 0x05
#define | OS_OS2 0x06
#define | OS_MACOS 0x07
#define | OS_TOPS20 0x0a
#define | OS_WIN32 0x0b
#define | OS_VMCMS 0x04
#define | OS_ZSYSTEM 0x08
#define | OS_CPM 0x09
#define | OS_QDOS 0x0c
#define | OS_RISCOS 0x0d
#define | OS_UNKNOWN 0xff
#define | OS_CODE OS_UNIX
#define | GZFILE_CBUF_CAPA 10
#define | GZFILE_FLAG_SYNC ZSTREAM_FLAG_UNUSED
#define | GZFILE_FLAG_HEADER_FINISHED (ZSTREAM_FLAG_UNUSED << 1)
#define | GZFILE_FLAG_FOOTER_FINISHED (ZSTREAM_FLAG_UNUSED << 2)
#define | GZFILE_FLAG_MTIME_IS_SET (ZSTREAM_FLAG_UNUSED << 3)
#define | GZFILE_IS_FINISHED(gz) (ZSTREAM_IS_FINISHED(&(gz)->z) && ZSTREAM_BUF_FILLED(&(gz)->z) == 0)
#define | GZFILE_READ_SIZE 2048
#define | gzfile_writer_new(gz) gzfile_new((gz),&deflate_funcs,gzfile_writer_end)
#define | gzfile_reader_new(gz) gzfile_new((gz),&inflate_funcs,gzfile_reader_end)
#define | rb_gzwriter_addstr rb_io_addstr
#define | rb_gzwriter_printf rb_io_printf
#define | rb_gzwriter_print rb_io_print
#define | rb_gzwriter_puts rb_io_puts
#define | OPTHASH_GIVEN_P(opts) (argc > 0 && !NIL_P((opts) = rb_check_hash_type(argv[argc-1])) && (--argc, 1))

## Functions
| NORETURN (static void gzfile_raise(struct gzfile *, VALUE, const char *))
void | Init_zlib (void)

## Macro Definition Documentation

## ◆ ARG_FLUSH

#define ARG_FLUSH | ( |  | val | ) | FIXNUMARG((val), Z_NO_FLUSH)

Definition at line 1467 of file zlib.c.

## ◆ ARG_LEVEL

#define ARG_LEVEL | ( |  | val | ) | FIXNUMARG((val), Z_DEFAULT_COMPRESSION)

Definition at line 1463 of file zlib.c.

## ◆ ARG_MEMLEVEL

#define ARG_MEMLEVEL | ( |  | val | ) | FIXNUMARG((val), DEF_MEM_LEVEL)

Definition at line 1465 of file zlib.c.

## ◆ ARG_STRATEGY

#define ARG_STRATEGY | ( |  | val | ) | FIXNUMARG((val), Z_DEFAULT_STRATEGY)

Definition at line 1466 of file zlib.c.

## ◆ ARG_WBITS

#define ARG_WBITS | ( |  | val | ) | FIXNUMARG((val), MAX_WBITS)

Definition at line 1464 of file zlib.c.

## ◆ checksum_long

#define checksum_long | ( |  | func,
|  |  | sum,
|  |  | ptr,
|  |  | len
| ) |  | (func)((sum), (ptr), (len))

Definition at line 386 of file zlib.c.

## ◆ DEF_MEM_LEVEL

#define DEF_MEM_LEVEL MAX_MEM_LEVEL

Definition at line 43 of file zlib.c.

## ◆ FIXNUMARG

#define FIXNUMARG | ( |  | val,
|  |  | ifnil
| ) |  |

Value:
(NIL_P((val)) ? (ifnil) \
: (FIX2INT((val))))

Definition at line 1459 of file zlib.c.

## ◆ GZ_EXTRAFLAG_FAST

#define GZ_EXTRAFLAG_FAST 0x4

Definition at line 2175 of file zlib.c.

## ◆ GZ_EXTRAFLAG_SLOW

#define GZ_EXTRAFLAG_SLOW 0x2

Definition at line 2176 of file zlib.c.

## ◆ GZ_FLAG_COMMENT

#define GZ_FLAG_COMMENT 0x10

Definition at line 2171 of file zlib.c.

## ◆ GZ_FLAG_ENCRYPT

#define GZ_FLAG_ENCRYPT 0x20

Definition at line 2172 of file zlib.c.

## ◆ GZ_FLAG_EXTRA

#define GZ_FLAG_EXTRA 0x4

Definition at line 2169 of file zlib.c.

## ◆ GZ_FLAG_MULTIPART

#define GZ_FLAG_MULTIPART 0x2

Definition at line 2168 of file zlib.c.

## ◆ GZ_FLAG_ORIG_NAME

#define GZ_FLAG_ORIG_NAME 0x8

Definition at line 2170 of file zlib.c.

## ◆ GZ_FLAG_UNKNOWN_MASK

#define GZ_FLAG_UNKNOWN_MASK 0xc0

Definition at line 2173 of file zlib.c.

## ◆ GZ_MAGIC1

#define GZ_MAGIC1 0x1f

Definition at line 2165 of file zlib.c.

## ◆ GZ_MAGIC2

#define GZ_MAGIC2 0x8b

Definition at line 2166 of file zlib.c.

## ◆ GZ_METHOD_DEFLATE

#define GZ_METHOD_DEFLATE 8

Definition at line 2167 of file zlib.c.

## ◆ GZFILE_CBUF_CAPA

#define GZFILE_CBUF_CAPA 10

Definition at line 2226 of file zlib.c.

## ◆ GZFILE_FLAG_FOOTER_FINISHED

#define GZFILE_FLAG_FOOTER_FINISHED (ZSTREAM_FLAG_UNUSED << 2)

Definition at line 2230 of file zlib.c.

## ◆ GZFILE_FLAG_HEADER_FINISHED

#define GZFILE_FLAG_HEADER_FINISHED (ZSTREAM_FLAG_UNUSED << 1)

Definition at line 2229 of file zlib.c.

## ◆ GZFILE_FLAG_MTIME_IS_SET

#define GZFILE_FLAG_MTIME_IS_SET (ZSTREAM_FLAG_UNUSED << 3)

Definition at line 2231 of file zlib.c.

## ◆ GZFILE_FLAG_SYNC

#define GZFILE_FLAG_SYNC ZSTREAM_FLAG_UNUSED

Definition at line 2228 of file zlib.c.

## ◆ GZFILE_IS_FINISHED

#define GZFILE_IS_FINISHED | ( |  | gz | ) | (ZSTREAM_IS_FINISHED(&(gz)->z) && ZSTREAM_BUF_FILLED(&(gz)->z) == 0)

Definition at line 2233 of file zlib.c.

## ◆ GZFILE_READ_SIZE

#define GZFILE_READ_SIZE 2048

Definition at line 2236 of file zlib.c.

## ◆ gzfile_reader_new

#define gzfile_reader_new | ( |  | gz | ) | gzfile_new((gz),&inflate_funcs,gzfile_reader_end)

Definition at line 2324 of file zlib.c.

## ◆ gzfile_writer_new

#define gzfile_writer_new | ( |  | gz | ) | gzfile_new((gz),&deflate_funcs,gzfile_writer_end)

Definition at line 2323 of file zlib.c.

## ◆ GZIP_SUPPORT

#define GZIP_SUPPORT 1

Definition at line 35 of file zlib.c.

## ◆ MAX_UINT

#define MAX_UINT | ( |  | n | ) | (uInt)(n)

Definition at line 56 of file zlib.c.

## ◆ OPTHASH_GIVEN_P

#define OPTHASH_GIVEN_P | ( |  | opts | ) | (argc > 0 && !NIL_P((opts) = rb_check_hash_type(argv[argc-1])) && (--argc, 1))

Definition at line 4301 of file zlib.c.

## ◆ OS_AMIGA

#define OS_AMIGA 0x01

Definition at line 2180 of file zlib.c.

## ◆ OS_ATARI

#define OS_ATARI 0x05

Definition at line 2183 of file zlib.c.

## ◆ OS_CODE

#define OS_CODE OS_UNIX

Definition at line 2197 of file zlib.c.

## ◆ OS_CPM

#define OS_CPM 0x09

Definition at line 2191 of file zlib.c.

## ◆ OS_MACOS

#define OS_MACOS 0x07

Definition at line 2185 of file zlib.c.

## ◆ OS_MSDOS

#define OS_MSDOS 0x00

Definition at line 2179 of file zlib.c.

## ◆ OS_OS2

#define OS_OS2 0x06

Definition at line 2184 of file zlib.c.

## ◆ OS_QDOS

#define OS_QDOS 0x0c

Definition at line 2192 of file zlib.c.

## ◆ OS_RISCOS

#define OS_RISCOS 0x0d

Definition at line 2193 of file zlib.c.

## ◆ OS_TOPS20

#define OS_TOPS20 0x0a

Definition at line 2186 of file zlib.c.

## ◆ OS_UNIX

#define OS_UNIX 0x03

Definition at line 2182 of file zlib.c.

## ◆ OS_UNKNOWN

#define OS_UNKNOWN 0xff

Definition at line 2194 of file zlib.c.

## ◆ OS_VMCMS

#define OS_VMCMS 0x04

Definition at line 2189 of file zlib.c.

## ◆ OS_VMS

#define OS_VMS 0x02

Definition at line 2181 of file zlib.c.

## ◆ OS_WIN32

#define OS_WIN32 0x0b

Definition at line 2187 of file zlib.c.

## ◆ OS_ZSYSTEM

#define OS_ZSYSTEM 0x08

Definition at line 2190 of file zlib.c.

## ◆ rb_gzwriter_addstr

#define rb_gzwriter_addstr rb_io_addstr

Definition at line 3632 of file zlib.c.

## ◆ rb_gzwriter_print

#define rb_gzwriter_print rb_io_print

Definition at line 3642 of file zlib.c.

## ◆ rb_gzwriter_printf

#define rb_gzwriter_printf rb_io_printf

Definition at line 3637 of file zlib.c.

## ◆ rb_gzwriter_puts

#define rb_gzwriter_puts rb_io_puts

Definition at line 3647 of file zlib.c.

## ◆ rb_zlib_adler32_combine

#define rb_zlib_adler32_combine rb_f_notimplement

Definition at line 459 of file zlib.c.

## ◆ rb_zlib_crc32_combine

#define rb_zlib_crc32_combine rb_f_notimplement

Definition at line 497 of file zlib.c.

## ◆ RUBY_ZLIB_VERSION

#define RUBY_ZLIB_VERSION "1.1.0"

Definition at line 28 of file zlib.c.

## ◆ VALGRIND_MAKE_MEM_DEFINED

#define VALGRIND_MAKE_MEM_DEFINED | ( |  | p,
|  |  | n
| ) |  | 0

Definition at line 24 of file zlib.c.

## ◆ VALGRIND_MAKE_MEM_UNDEFINED

#define VALGRIND_MAKE_MEM_UNDEFINED | ( |  | p,
|  |  | n
| ) |  | 0

Definition at line 25 of file zlib.c.

## ◆ zstream_append_buffer2

#define zstream_append_buffer2 | ( |  | z,
|  |  | v
| ) |  | zstream_append_buffer((z),(Bytef*)RSTRING_PTR(v),RSTRING_LEN(v))

Definition at line 733 of file zlib.c.

## ◆ zstream_append_input2

#define zstream_append_input2 | ( |  | z,
|  |  | v
| ) |  |

Value:
RB_GC_GUARD(v),\
zstream_append_input((z), (Bytef*)RSTRING_PTR(v), RSTRING_LEN(v))

Definition at line 837 of file zlib.c.

## ◆ ZSTREAM_AVAIL_OUT_STEP_MAX

#define ZSTREAM_AVAIL_OUT_STEP_MAX 16384

Definition at line 561 of file zlib.c.

## ◆ ZSTREAM_AVAIL_OUT_STEP_MIN

#define ZSTREAM_AVAIL_OUT_STEP_MIN 2048

Definition at line 562 of file zlib.c.

## ◆ ZSTREAM_BUF_FILLED

#define ZSTREAM_BUF_FILLED | ( |  | z | ) | (NIL_P((z)->buf) ? 0 : RSTRING_LEN((z)->buf))

Definition at line 553 of file zlib.c.

## ◆ zstream_deflate_new

#define zstream_deflate_new | ( |  | klass | ) | zstream_new((klass), &deflate_funcs)

Definition at line 1198 of file zlib.c.

## ◆ ZSTREAM_EXPAND_BUFFER_OK

#define ZSTREAM_EXPAND_BUFFER_OK 0

Definition at line 555 of file zlib.c.

## ◆ ZSTREAM_FLAG_CLOSING

#define ZSTREAM_FLAG_CLOSING 0x8

Definition at line 544 of file zlib.c.

## ◆ ZSTREAM_FLAG_FINISHED

#define ZSTREAM_FLAG_FINISHED 0x4

Definition at line 543 of file zlib.c.

## ◆ ZSTREAM_FLAG_GZFILE

#define ZSTREAM_FLAG_GZFILE

Value:
0x10 /* disallows yield from expand_buffer for
gzip*/

Definition at line 545 of file zlib.c.

## ◆ ZSTREAM_FLAG_IN_STREAM

#define ZSTREAM_FLAG_IN_STREAM 0x2

Definition at line 542 of file zlib.c.

## ◆ ZSTREAM_FLAG_READY

#define ZSTREAM_FLAG_READY 0x1

Definition at line 541 of file zlib.c.

## ◆ ZSTREAM_FLAG_UNUSED

#define ZSTREAM_FLAG_UNUSED 0x20

Definition at line 546 of file zlib.c.

## ◆ zstream_inflate_new

#define zstream_inflate_new | ( |  | klass | ) | zstream_new((klass), &inflate_funcs)

Definition at line 1199 of file zlib.c.

## ◆ zstream_init_deflate

#define zstream_init_deflate | ( |  | z | ) | zstream_init((z), &deflate_funcs)

Definition at line 615 of file zlib.c.

## ◆ zstream_init_inflate

#define zstream_init_inflate | ( |  | z | ) | zstream_init((z), &inflate_funcs)

Definition at line 616 of file zlib.c.

## ◆ ZSTREAM_INITIAL_BUFSIZE

#define ZSTREAM_INITIAL_BUFSIZE 1024

Definition at line 559 of file zlib.c.

## ◆ ZSTREAM_IS_CLOSING

#define ZSTREAM_IS_CLOSING | ( |  | z | ) | ((z)->flags & ZSTREAM_FLAG_CLOSING)

Definition at line 551 of file zlib.c.

## ◆ ZSTREAM_IS_FINISHED

#define ZSTREAM_IS_FINISHED | ( |  | z | ) | ((z)->flags & ZSTREAM_FLAG_FINISHED)

Definition at line 550 of file zlib.c.

## ◆ ZSTREAM_IS_GZFILE

#define ZSTREAM_IS_GZFILE | ( |  | z | ) | ((z)->flags & ZSTREAM_FLAG_GZFILE)

Definition at line 552 of file zlib.c.

## ◆ ZSTREAM_IS_READY

#define ZSTREAM_IS_READY | ( |  | z | ) | ((z)->flags & ZSTREAM_FLAG_READY)

Definition at line 549 of file zlib.c.

## ◆ ZSTREAM_READY

#define ZSTREAM_READY | ( |  | z | ) | ((z)->flags |= ZSTREAM_FLAG_READY)

Definition at line 548 of file zlib.c.

## Function Documentation

## ◆ Init_zlib()

void Init_zlib | ( | void |  | ) |

Definition at line 4453 of file zlib.c.

References rb_define_module().

## ◆ NORETURN()

NORETURN | ( | static void | gzfile_raisestruct gzfile *, VALUE, const char * | ) |

FIX2INT
#define FIX2INT(x)
Definition: ruby.h:717
RSTRING_PTR
#define RSTRING_PTR(str)
Definition: ruby.h:1009
v
int VALUE v
Definition: rb_mjit_min_header-2.7.0.h:12332
NIL_P
#define NIL_P(v)
Definition: ruby.h:482
RB_GC_GUARD
#define RB_GC_GUARD(v)
Definition: ruby.h:585
RSTRING_LEN
#define RSTRING_LEN(str)
Definition: ruby.h:1005