Ruby: ext/zlib/zlib.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

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

## Macros
#define | VALGRIND_MAKE_MEM_DEFINED(p, n) 0
#define | VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
#define | RUBY_ZLIB_VERSION "2.0.0"
#define | GZIP_SUPPORT 1
#define | DEF_MEM_LEVEL MAX_MEM_LEVEL
#define | MAX_UINT(n) (uInt)(n)
#define | OPTHASH_GIVEN_P(opts) (argc > 0 && !NIL_P((opts) = rb_check_hash_type(argv[argc-1])) && (--argc, 1))
#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 (1 << 0)
#define | ZSTREAM_FLAG_IN_STREAM (1 << 1)
#define | ZSTREAM_FLAG_FINISHED (1 << 2)
#define | ZSTREAM_FLAG_CLOSING (1 << 3)
#define | ZSTREAM_FLAG_GZFILE
#define | ZSTREAM_REUSE_BUFFER (1 << 5)
#define | ZSTREAM_IN_PROGRESS (1 << 6)
#define | ZSTREAM_FLAG_UNUSED (1 << 7)
#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_REUSE_BUFFER_P(z) ((z)->flags & ZSTREAM_REUSE_BUFFER)
#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)

## Functions
void | Init_zlib (void)

## Macro Definition Documentation

## ◆ ARG_FLUSH

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

Definition at line 1554 of file zlib.c.

## ◆ ARG_LEVEL

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

Definition at line 1550 of file zlib.c.

## ◆ ARG_MEMLEVEL

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

Definition at line 1552 of file zlib.c.

## ◆ ARG_STRATEGY

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

Definition at line 1553 of file zlib.c.

## ◆ ARG_WBITS

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

Definition at line 1551 of file zlib.c.

## ◆ checksum_long

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

Definition at line 390 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))))
FIX2INT
#define FIX2INT
Definition: int.h:41
NIL_P
#define NIL_P
Definition: special_consts.h:46

Definition at line 1546 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 59 of file zlib.c.

## ◆ rb_zlib_adler32_combine

#define rb_zlib_adler32_combine rb_f_notimplement

Definition at line 474 of file zlib.c.

## ◆ rb_zlib_crc32_combine

#define rb_zlib_crc32_combine rb_f_notimplement

Definition at line 514 of file zlib.c.

## ◆ RUBY_ZLIB_VERSION

#define RUBY_ZLIB_VERSION "2.0.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 768 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))
RSTRING_LEN
#define RSTRING_LEN(string)
Definition: fbuffer.h:22
RSTRING_PTR
#define RSTRING_PTR(string)
Definition: fbuffer.h:19
RB_GC_GUARD
#define RB_GC_GUARD(v)
Definition: memory.h:91
Bytef
Byte FAR Bytef
Definition: zconf.h:406

Definition at line 874 of file zlib.c.

## ◆ ZSTREAM_AVAIL_OUT_STEP_MAX

#define ZSTREAM_AVAIL_OUT_STEP_MAX 16384

Definition at line 583 of file zlib.c.

## ◆ ZSTREAM_AVAIL_OUT_STEP_MIN

#define ZSTREAM_AVAIL_OUT_STEP_MIN 2048

Definition at line 584 of file zlib.c.

## ◆ ZSTREAM_BUF_FILLED

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

Definition at line 573 of file zlib.c.

## ◆ zstream_deflate_new

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

Definition at line 1285 of file zlib.c.

## ◆ ZSTREAM_EXPAND_BUFFER_OK

#define ZSTREAM_EXPAND_BUFFER_OK 0

Definition at line 577 of file zlib.c.

## ◆ ZSTREAM_FLAG_CLOSING

#define ZSTREAM_FLAG_CLOSING (1 << 3)

Definition at line 562 of file zlib.c.

## ◆ ZSTREAM_FLAG_FINISHED

#define ZSTREAM_FLAG_FINISHED (1 << 2)

Definition at line 561 of file zlib.c.

## ◆ ZSTREAM_FLAG_GZFILE

#define ZSTREAM_FLAG_GZFILE

Value:
(1 << 4) /* disallows yield from expand_buffer for
gzip*/

Definition at line 563 of file zlib.c.

## ◆ ZSTREAM_FLAG_IN_STREAM

#define ZSTREAM_FLAG_IN_STREAM (1 << 1)

Definition at line 560 of file zlib.c.

## ◆ ZSTREAM_FLAG_READY

#define ZSTREAM_FLAG_READY (1 << 0)

Definition at line 559 of file zlib.c.

## ◆ ZSTREAM_FLAG_UNUSED

#define ZSTREAM_FLAG_UNUSED (1 << 7)

Definition at line 566 of file zlib.c.

## ◆ ZSTREAM_IN_PROGRESS

#define ZSTREAM_IN_PROGRESS (1 << 6)

Definition at line 565 of file zlib.c.

## ◆ zstream_inflate_new

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

Definition at line 1286 of file zlib.c.

## ◆ zstream_init_deflate

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

Definition at line 640 of file zlib.c.

## ◆ zstream_init_inflate

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

Definition at line 641 of file zlib.c.

## ◆ ZSTREAM_INITIAL_BUFSIZE

#define ZSTREAM_INITIAL_BUFSIZE 1024

Definition at line 581 of file zlib.c.

## ◆ ZSTREAM_IS_CLOSING

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

Definition at line 571 of file zlib.c.

## ◆ ZSTREAM_IS_FINISHED

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

Definition at line 570 of file zlib.c.

## ◆ ZSTREAM_IS_GZFILE

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

Definition at line 572 of file zlib.c.

## ◆ ZSTREAM_IS_READY

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

Definition at line 569 of file zlib.c.

## ◆ ZSTREAM_READY

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

Definition at line 568 of file zlib.c.

## ◆ ZSTREAM_REUSE_BUFFER

#define ZSTREAM_REUSE_BUFFER (1 << 5)

Definition at line 564 of file zlib.c.

## ◆ ZSTREAM_REUSE_BUFFER_P

#define ZSTREAM_REUSE_BUFFER_P | ( |  | z | ) | ((z)->flags & ZSTREAM_REUSE_BUFFER)

Definition at line 575 of file zlib.c.

## Function Documentation

## ◆ Init_zlib()

void Init_zlib | ( | void |  | ) |

Definition at line 4616 of file zlib.c.

References DEF_MEM_LEVEL, INT2FIX, MAX_MEM_LEVEL, MAX_WBITS, OS_CODE, rb_cObject, rb_define_alloc_func(), rb_define_attr(), rb_define_class_under(), rb_define_const(), rb_define_method, rb_define_module(), rb_define_module_function, rb_define_singleton_method, rb_eStandardError, rb_ext_ractor_safe(), rb_include_module(), rb_intern(), rb_mEnumerable, rb_str_new2, rb_undef_alloc_func(), rb_zlib_adler32_combine, rb_zlib_crc32_combine, RUBY_ZLIB_VERSION, Z_ASCII, Z_BEST_COMPRESSION, Z_BEST_SPEED, Z_BINARY, Z_DEFAULT_COMPRESSION, Z_DEFAULT_STRATEGY, Z_FILTERED, Z_FINISH, Z_FIXED, Z_FULL_FLUSH, Z_HUFFMAN_ONLY, Z_NO_COMPRESSION, Z_NO_FLUSH, Z_RLE, Z_SYNC_FLUSH, Z_TEXT, Z_UNKNOWN, and ZLIB_VERSION.