Ruby  2.5.0dev(2017-10-22revision60238)
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  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   "0.6.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_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 1425 of file zlib.c.

◆ ARG_LEVEL

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

Definition at line 1421 of file zlib.c.

◆ ARG_MEMLEVEL

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

Definition at line 1423 of file zlib.c.

◆ ARG_STRATEGY

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

Definition at line 1424 of file zlib.c.

◆ ARG_WBITS

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

Definition at line 1422 of file zlib.c.

◆ checksum_long

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

Definition at line 385 of file zlib.c.

◆ DEF_MEM_LEVEL

#define DEF_MEM_LEVEL   MAX_MEM_LEVEL

Definition at line 39 of file zlib.c.

◆ FIXNUMARG

#define FIXNUMARG (   val,
  ifnil 
)
Value:
(NIL_P((val)) ? (ifnil) \
: (FIX2INT((val))))
#define val
#define NIL_P(v)
Definition: ruby.h:451
#define FIX2INT(x)
Definition: ruby.h:686

Definition at line 1417 of file zlib.c.

◆ GZ_EXTRAFLAG_FAST

#define GZ_EXTRAFLAG_FAST   0x4

Definition at line 2145 of file zlib.c.

◆ GZ_EXTRAFLAG_SLOW

#define GZ_EXTRAFLAG_SLOW   0x2

Definition at line 2146 of file zlib.c.

◆ GZ_FLAG_COMMENT

#define GZ_FLAG_COMMENT   0x10

Definition at line 2141 of file zlib.c.

◆ GZ_FLAG_ENCRYPT

#define GZ_FLAG_ENCRYPT   0x20

Definition at line 2142 of file zlib.c.

◆ GZ_FLAG_EXTRA

#define GZ_FLAG_EXTRA   0x4

Definition at line 2139 of file zlib.c.

◆ GZ_FLAG_MULTIPART

#define GZ_FLAG_MULTIPART   0x2

Definition at line 2138 of file zlib.c.

◆ GZ_FLAG_ORIG_NAME

#define GZ_FLAG_ORIG_NAME   0x8

Definition at line 2140 of file zlib.c.

◆ GZ_FLAG_UNKNOWN_MASK

#define GZ_FLAG_UNKNOWN_MASK   0xc0

Definition at line 2143 of file zlib.c.

◆ GZ_MAGIC1

#define GZ_MAGIC1   0x1f

Definition at line 2135 of file zlib.c.

◆ GZ_MAGIC2

#define GZ_MAGIC2   0x8b

Definition at line 2136 of file zlib.c.

◆ GZ_METHOD_DEFLATE

#define GZ_METHOD_DEFLATE   8

Definition at line 2137 of file zlib.c.

◆ GZFILE_CBUF_CAPA

#define GZFILE_CBUF_CAPA   10

Definition at line 2197 of file zlib.c.

◆ GZFILE_FLAG_FOOTER_FINISHED

#define GZFILE_FLAG_FOOTER_FINISHED   (ZSTREAM_FLAG_UNUSED << 2)

Definition at line 2201 of file zlib.c.

◆ GZFILE_FLAG_HEADER_FINISHED

#define GZFILE_FLAG_HEADER_FINISHED   (ZSTREAM_FLAG_UNUSED << 1)

Definition at line 2200 of file zlib.c.

◆ GZFILE_FLAG_SYNC

#define GZFILE_FLAG_SYNC   ZSTREAM_FLAG_UNUSED

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

◆ GZFILE_READ_SIZE

#define GZFILE_READ_SIZE   2048

Definition at line 2206 of file zlib.c.

◆ gzfile_reader_new

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

Definition at line 2294 of file zlib.c.

◆ gzfile_writer_new

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

Definition at line 2293 of file zlib.c.

◆ GZIP_SUPPORT

#define GZIP_SUPPORT   1

Definition at line 31 of file zlib.c.

◆ MAX_UINT

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

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

◆ OS_AMIGA

#define OS_AMIGA   0x01

Definition at line 2150 of file zlib.c.

◆ OS_ATARI

#define OS_ATARI   0x05

Definition at line 2153 of file zlib.c.

◆ OS_CODE

#define OS_CODE   OS_UNIX

Definition at line 2167 of file zlib.c.

◆ OS_CPM

#define OS_CPM   0x09

Definition at line 2161 of file zlib.c.

◆ OS_MACOS

#define OS_MACOS   0x07

Definition at line 2155 of file zlib.c.

◆ OS_MSDOS

#define OS_MSDOS   0x00

Definition at line 2149 of file zlib.c.

◆ OS_OS2

#define OS_OS2   0x06

Definition at line 2154 of file zlib.c.

◆ OS_QDOS

#define OS_QDOS   0x0c

Definition at line 2162 of file zlib.c.

◆ OS_RISCOS

#define OS_RISCOS   0x0d

Definition at line 2163 of file zlib.c.

◆ OS_TOPS20

#define OS_TOPS20   0x0a

Definition at line 2156 of file zlib.c.

◆ OS_UNIX

#define OS_UNIX   0x03

Definition at line 2152 of file zlib.c.

◆ OS_UNKNOWN

#define OS_UNKNOWN   0xff

Definition at line 2164 of file zlib.c.

◆ OS_VMCMS

#define OS_VMCMS   0x04

Definition at line 2159 of file zlib.c.

◆ OS_VMS

#define OS_VMS   0x02

Definition at line 2151 of file zlib.c.

◆ OS_WIN32

#define OS_WIN32   0x0b

Definition at line 2157 of file zlib.c.

◆ OS_ZSYSTEM

#define OS_ZSYSTEM   0x08

Definition at line 2160 of file zlib.c.

◆ rb_gzwriter_addstr

#define rb_gzwriter_addstr   rb_io_addstr

Definition at line 3602 of file zlib.c.

◆ rb_gzwriter_print

#define rb_gzwriter_print   rb_io_print

Definition at line 3612 of file zlib.c.

◆ rb_gzwriter_printf

#define rb_gzwriter_printf   rb_io_printf

Definition at line 3607 of file zlib.c.

◆ rb_gzwriter_puts

#define rb_gzwriter_puts   rb_io_puts

Definition at line 3617 of file zlib.c.

◆ rb_zlib_adler32_combine

#define rb_zlib_adler32_combine   rb_f_notimplement

Definition at line 458 of file zlib.c.

◆ rb_zlib_crc32_combine

#define rb_zlib_crc32_combine   rb_f_notimplement

Definition at line 496 of file zlib.c.

◆ RUBY_ZLIB_VERSION

#define RUBY_ZLIB_VERSION   "0.6.0"

Definition at line 28 of file zlib.c.

◆ VALGRIND_MAKE_MEM_DEFINED

#define VALGRIND_MAKE_MEM_DEFINED (   p,
 
)    0

Definition at line 24 of file zlib.c.

◆ VALGRIND_MAKE_MEM_UNDEFINED

#define VALGRIND_MAKE_MEM_UNDEFINED (   p,
 
)    0

Definition at line 25 of file zlib.c.

◆ zstream_append_buffer2

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

Definition at line 735 of file zlib.c.

◆ zstream_append_input2

#define zstream_append_input2 (   z,
 
)
Value:
zstream_append_input((z), (Bytef*)RSTRING_PTR(v), RSTRING_LEN(v))
#define RB_GC_GUARD(v)
Definition: ruby.h:552
#define RSTRING_LEN(str)
Definition: ruby.h:971
#define RSTRING_PTR(str)
Definition: ruby.h:975

Definition at line 841 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 1155 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 543 of file zlib.c.

◆ ZSTREAM_FLAG_FINISHED

#define ZSTREAM_FLAG_FINISHED   0x4

Definition at line 542 of file zlib.c.

◆ ZSTREAM_FLAG_GZFILE

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

Definition at line 544 of file zlib.c.

◆ ZSTREAM_FLAG_IN_STREAM

#define ZSTREAM_FLAG_IN_STREAM   0x2

Definition at line 541 of file zlib.c.

◆ ZSTREAM_FLAG_READY

#define ZSTREAM_FLAG_READY   0x1

Definition at line 540 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 1156 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 4417 of file zlib.c.

References rb_define_module().

◆ NORETURN()

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