15 #ifdef HAVE_VALGRIND_MEMCHECK_H
16 # include <valgrind/memcheck.h>
17 # ifndef VALGRIND_MAKE_MEM_DEFINED
18 # define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE((p), (n))
20 # ifndef VALGRIND_MAKE_MEM_UNDEFINED
21 # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE((p), (n))
24 # define VALGRIND_MAKE_MEM_DEFINED(p, n) 0
25 # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) 0
28 #define RUBY_ZLIB_VERSION "0.6.0"
31 #define OBJ_IS_FREED(val) (RBASIC(val)->flags == 0)
34 #define GZIP_SUPPORT 1
39 #if MAX_MEM_LEVEL >= 8
40 #define DEF_MEM_LEVEL 8
42 #define DEF_MEM_LEVEL MAX_MEM_LEVEL
46 #if SIZEOF_LONG > SIZEOF_INT
50 if (n > UINT_MAX) n = UINT_MAX;
53 #define MAX_UINT(n) max_uint(n)
55 #define MAX_UINT(n) (uInt)(n)
58 #define sizeof(x) ((int)sizeof(x))
152 static unsigned long gzfile_get32(
const unsigned char*);
153 static void gzfile_set32(
unsigned long n,
unsigned char*);
330 case Z_VERSION_ERROR:
341 rb_sprintf(
"unknown zlib error %d: %s", err, msg));
353 fprintf(stderr,
"zlib(finalizer): %s\n", msg);
374 #if SIZEOF_LONG > SIZEOF_INT
376 checksum_long(uLong (*
func)(uLong,
const Bytef*, uInt), uLong sum,
const Bytef *ptr,
long len)
378 if (len > UINT_MAX) {
380 sum =
func(sum, ptr, UINT_MAX);
383 }
while (len >= UINT_MAX);
385 if (len > 0) sum =
func(sum, ptr, (uInt)len);
389 #define checksum_long(func, sum, ptr, len) (func)((sum), (ptr), (len))
396 uLong (*
func)(uLong,
const Bytef*, uInt);
406 else if (
NIL_P(str)) {
410 sum =
func(0, Z_NULL, 0);
414 sum =
func(sum, Z_NULL, 0);
440 #ifdef HAVE_ADLER32_COMBINE
458 #define rb_zlib_adler32_combine rb_f_notimplement
478 #ifdef HAVE_CRC32_COMBINE
496 #define rb_zlib_crc32_combine rb_f_notimplement
507 #if !defined(HAVE_TYPE_Z_CRC_T)
509 typedef unsigned long z_crc_t;
511 const z_crc_t *crctbl;
515 crctbl = get_crc_table();
518 for (i = 0; i < 256; i++) {
537 int (*
run)(z_streamp, int);
541 #define ZSTREAM_FLAG_READY 0x1
542 #define ZSTREAM_FLAG_IN_STREAM 0x2
543 #define ZSTREAM_FLAG_FINISHED 0x4
544 #define ZSTREAM_FLAG_CLOSING 0x8
545 #define ZSTREAM_FLAG_GZFILE 0x10
547 #define ZSTREAM_FLAG_UNUSED 0x20
549 #define ZSTREAM_READY(z) ((z)->flags |= ZSTREAM_FLAG_READY)
550 #define ZSTREAM_IS_READY(z) ((z)->flags & ZSTREAM_FLAG_READY)
551 #define ZSTREAM_IS_FINISHED(z) ((z)->flags & ZSTREAM_FLAG_FINISHED)
552 #define ZSTREAM_IS_CLOSING(z) ((z)->flags & ZSTREAM_FLAG_CLOSING)
553 #define ZSTREAM_IS_GZFILE(z) ((z)->flags & ZSTREAM_FLAG_GZFILE)
555 #define ZSTREAM_EXPAND_BUFFER_OK 0
559 #define ZSTREAM_INITIAL_BUFSIZE 1024
561 #define ZSTREAM_AVAIL_OUT_STEP_MAX 16384
562 #define ZSTREAM_AVAIL_OUT_STEP_MIN 2048
565 deflateReset, deflateEnd, deflate,
569 inflateReset, inflateEnd, inflate,
607 z->
stream.opaque = Z_NULL;
609 z->
stream.next_in = Z_NULL;
611 z->
stream.next_out = Z_NULL;
616 #define zstream_init_deflate(z) zstream_init((z), &deflate_funcs)
617 #define zstream_init_inflate(z) zstream_init((z), &inflate_funcs)
680 else if (z->
stream.avail_out != size) {
695 return (
void *)(
VALUE)state;
749 if (z->
stream.avail_out >= (uInt)len) {
750 z->
stream.avail_out -= (uInt)len;
761 #define zstream_append_buffer2(z,v) \
762 zstream_append_buffer((z),(Bytef*)RSTRING_PTR(v),RSTRING_LEN(v))
820 z->
stream.avail_out = (uInt)buflen;
835 if (z->
stream.avail_out > 0) {
836 if (len > z->
stream.avail_out) len = z->
stream.avail_out;
838 z->
stream.avail_out-=(uInt)len;
852 if (z->
stream.avail_out > 0) {
861 if (len <= 0)
return;
873 #define zstream_append_input2(z,v)\
875 zstream_append_input((z), (Bytef*)RSTRING_PTR(v), RSTRING_LEN(v))
945 rb_warning(
"attempt to close uninitialized zstream; ignored.");
949 rb_warning(
"attempt to close unfinished zstream; reset forced.");
976 if (err == Z_STREAM_END) {
982 if (err != Z_OK && err != Z_BUF_ERROR)
985 if (z->
stream.avail_out > 0) {
990 if (z->
stream.avail_in == 0 && z->
func == &inflate_funcs) {
1012 return (
void *)(
VALUE)err;
1040 z->
stream.next_in = (Bytef*)
"";
1053 if (z->
stream.avail_out == 0) {
1061 if (flush != Z_FINISH && err == Z_BUF_ERROR
1062 && z->
stream.avail_out > 0) {
1068 if (err != Z_OK && err != Z_STREAM_END) {
1069 if (z->
stream.avail_in > 0) {
1072 if (err == Z_NEED_DICT) {
1086 if (z->
stream.avail_in > 0) {
1104 err = inflateSync(&z->
stream);
1112 if (err != Z_DATA_ERROR) {
1118 if (len <= 0)
return Qfalse;
1122 err = inflateSync(&z->
stream);
1127 if (err != Z_DATA_ERROR) {
1145 if (err == Z_STREAM_ERROR)
1147 if (err == Z_DATA_ERROR)
1169 z->
stream.opaque = (voidpf)obj;
1173 #define zstream_deflate_new(klass) zstream_new((klass), &deflate_funcs)
1174 #define zstream_inflate_new(klass) zstream_new((klass), &inflate_funcs)
1183 rb_raise(cZError,
"stream is not ready");
1434 #define FIXNUMARG(val, ifnil) \
1435 (NIL_P((val)) ? (ifnil) \
1436 : ((void)Check_Type((val), T_FIXNUM), FIX2INT((val))))
1438 #define ARG_LEVEL(val) FIXNUMARG((val), Z_DEFAULT_COMPRESSION)
1439 #define ARG_WBITS(val) FIXNUMARG((val), MAX_WBITS)
1440 #define ARG_MEMLEVEL(val) FIXNUMARG((val), DEF_MEM_LEVEL)
1441 #define ARG_STRATEGY(val) FIXNUMARG((val), Z_DEFAULT_STRATEGY)
1442 #define ARG_FLUSH(val) FIXNUMARG((val), Z_NO_FLUSH)
1529 rb_scan_args(argc, argv,
"04", &level, &wbits, &memlevel, &strategy);
1557 if (z1 == z2)
return self;
1615 err = deflateInit(&z.
stream, lev);
1621 args[0] = (
VALUE)&z;
1637 if (flush != Z_NO_FLUSH ||
RSTRING_LEN(src) > 0) {
1721 flush =
FIXNUMARG(v_flush, Z_SYNC_FLUSH);
1722 if (flush != Z_NO_FLUSH) {
1745 int level, strategy;
1753 err = deflateParams(&z->
stream, level, strategy);
1755 while (err == Z_BUF_ERROR) {
1756 rb_warning(
"deflateParams() returned Z_BUF_ERROR");
1759 err = deflateParams(&z->
stream, level, strategy);
1792 err = deflateSetDictionary(&z->
stream,
1927 err = inflateInit(&z.
stream);
1933 args[0] = (
VALUE)&z;
2101 err = inflateSyncPoint(&z->
stream);
2127 err = inflateSetDictionary(&z->
stream,
2147 #define GZ_MAGIC1 0x1f
2148 #define GZ_MAGIC2 0x8b
2149 #define GZ_METHOD_DEFLATE 8
2150 #define GZ_FLAG_MULTIPART 0x2
2151 #define GZ_FLAG_EXTRA 0x4
2152 #define GZ_FLAG_ORIG_NAME 0x8
2153 #define GZ_FLAG_COMMENT 0x10
2154 #define GZ_FLAG_ENCRYPT 0x20
2155 #define GZ_FLAG_UNKNOWN_MASK 0xc0
2157 #define GZ_EXTRAFLAG_FAST 0x4
2158 #define GZ_EXTRAFLAG_SLOW 0x2
2161 #define OS_MSDOS 0x00
2162 #define OS_AMIGA 0x01
2164 #define OS_UNIX 0x03
2165 #define OS_ATARI 0x05
2167 #define OS_MACOS 0x07
2168 #define OS_TOPS20 0x0a
2169 #define OS_WIN32 0x0b
2171 #define OS_VMCMS 0x04
2172 #define OS_ZSYSTEM 0x08
2174 #define OS_QDOS 0x0c
2175 #define OS_RISCOS 0x0d
2176 #define OS_UNKNOWN 0xff
2179 #define OS_CODE OS_UNIX
2209 #define GZFILE_CBUF_CAPA 10
2211 #define GZFILE_FLAG_SYNC ZSTREAM_FLAG_UNUSED
2212 #define GZFILE_FLAG_HEADER_FINISHED (ZSTREAM_FLAG_UNUSED << 1)
2213 #define GZFILE_FLAG_FOOTER_FINISHED (ZSTREAM_FLAG_UNUSED << 2)
2215 #define GZFILE_IS_FINISHED(gz) \
2216 (ZSTREAM_IS_FINISHED(&(gz)->z) && (gz)->z.buf_filled == 0)
2218 #define GZFILE_READ_SIZE 2048
2238 if (z->
func == &deflate_funcs) {
2239 finalizer_warn(
"Zlib::GzipWriter object must be closed explicitly.");
2252 const struct zstream_funcs *funcs;
2253 void (*endfunc)(struct
gzfile *);
2267 gz->
crc = crc32(0, Z_NULL, 0);
2282 #define gzfile_writer_new(gz) gzfile_new((gz),&deflate_funcs,gzfile_writer_end)
2283 #define gzfile_reader_new(gz) gzfile_new((gz),&inflate_funcs,gzfile_reader_end)
2289 gz->
crc = crc32(0, Z_NULL, 0);
2368 if (
NIL_P(str))
return 0;
2386 rb_raise(cGzError,
"unexpected end of file");
2398 n = *(src++) & 0xff;
2399 n |= (*(src++) & 0xff) << 8;
2403 static unsigned long
2407 n = *(src++) & 0xff;
2408 n |= (*(src++) & 0xff) << 8;
2409 n |= (*(src++) & 0xff) << 16;
2410 n |= (*(src++) & 0xffU) << 24;
2417 *(dst++) = n & 0xff;
2418 *(dst++) = (n >> 8) & 0xff;
2419 *(dst++) = (n >> 16) & 0xff;
2420 *dst = (n >> 24) & 0xff;
2444 if (!
NIL_P(input)) {
2457 unsigned char flags = 0, extraflags = 0;
2465 if (gz->
mtime == 0) {
2466 gz->
mtime = time(0);
2469 if (gz->
level == Z_BEST_SPEED) {
2472 else if (gz->
level == Z_BEST_COMPRESSION) {
2481 buf[8] = extraflags;
2511 const unsigned char *
head;
2525 rb_raise(cGzError,
"unsupported compression method %d", head[2]);
2530 rb_raise(cGzError,
"multi-part gzip file is not supported");
2533 rb_raise(cGzError,
"encrypted gzip file is not supported");
2536 rb_raise(cGzError,
"unknown flags 0x%02x", flags);
2540 gz->
level = Z_BEST_SPEED;
2543 gz->
level = Z_BEST_COMPRESSION;
2546 gz->
level = Z_DEFAULT_COMPRESSION;
2555 rb_raise(cGzError,
"unexpected end of file");
2559 rb_raise(cGzError,
"unexpected end of file");
2565 rb_raise(cGzError,
"unexpected end of file");
2575 rb_raise(cGzError,
"unexpected end of file");
2592 unsigned long crc, length;
2606 if (gz->
crc != crc) {
2607 rb_raise(cCRCError,
"invalid compressed data -- crc error");
2610 rb_raise(cLengthError,
"invalid compressed data -- length error");
2624 ? Z_SYNC_FLUSH : Z_NO_FLUSH);
2638 rb_raise(cGzError,
"unexpected end of file");
2708 if (len < 0)
return Qnil;
2748 if (!
NIL_P(outbuf)) {
2773 if (
NIL_P(dst))
return dst;
2797 const unsigned char *ss, *sp, *se;
2798 unsigned char *ds, *
dp, *de;
2805 ds = dp = (
unsigned char *)gz->
cbuf;
2820 if (
NIL_P(dst))
return dst;
2924 rb_raise(cGzError,
"closed gzip stream");
3000 if (close_io_on_error) {
3190 rb_raise(cGzError,
"header is already written");
3216 rb_raise(cGzError,
"header is already written");
3240 rb_raise(cGzError,
"header is already written");
3476 if (!
NIL_P(opt)) argc--;
3479 rb_scan_args(argc, argv,
"12", &io, &level, &strategy);
3484 err = deflateInit2(&gz->
z.
stream, gz->
level, Z_DEFLATED,
3517 flush =
FIXNUMARG(v_flush, Z_SYNC_FLUSH);
3518 if (flush != Z_NO_FLUSH) {
3565 #define rb_gzwriter_addstr rb_io_addstr
3570 #define rb_gzwriter_printf rb_io_printf
3575 #define rb_gzwriter_print rb_io_print
3580 #define rb_gzwriter_puts rb_io_puts
3686 err = inflateInit2(&gz->
z.
stream, -MAX_WBITS);
3892 rb_warn(
"Zlib::GzipReader#bytes is deprecated; use #each_byte instead");
3946 while (n++, *(p++) ==
'\n') {
3999 long rslen, n, limit = -1;
4014 else if (!
NIL_P(rs)) {
4046 if (
NIL_P(dst))
return dst;
4085 if (!rspara)
rscheck(rsptr, rslen, rs);
4087 if (limit > 0 && filled >= limit) {
4090 res = memchr(p, rsptr[0], (filled - n + 1));
4093 if (limit > 0 && filled >= limit)
break;
4096 n += (long)(res - p);
4098 if (rslen == 1 ||
memcmp(p, rsptr, rslen) == 0)
break;
4108 if (
NIL_P(dst))
return dst;
4174 rb_warn(
"Zlib::GzipReader#lines is deprecated; use #each_line instead");
4201 VALUE mZlib, cZStream, cDeflate, cInflate;
4203 VALUE cGzipFile, cGzipWriter, cGzipReader;
4312 INT2FIX(Z_DEFAULT_COMPRESSION));
4383 id_readpartial =
rb_intern(
"readpartial");
#define RB_TYPE_P(obj, type)
static VALUE rb_gzreader_ungetbyte(VALUE, VALUE)
static VALUE rb_zstream_closed_p(VALUE)
#define ZSTREAM_IS_CLOSING(z)
static VALUE rb_zstream_avail_out(VALUE)
static VALUE rb_inflate_s_allocate(VALUE)
static VALUE rb_gzreader_unused(VALUE)
static VALUE rb_gzfile_os_code(VALUE)
static VALUE rb_gzfile_set_comment(VALUE, VALUE)
static void gzfile_set32(unsigned long n, unsigned char *)
static VALUE rb_deflate_params(VALUE, VALUE, VALUE)
static VALUE rb_gzfile_comment(VALUE)
static VALUE rb_gzfile_to_io(VALUE)
static VALUE new_wrap(VALUE tmp)
VALUE rb_str_resurrect(VALUE str)
static VALUE rb_gzfile_level(VALUE)
static void finalizer_warn(const char *)
#define MBCLEN_NEEDMORE_LEN(ret)
static void zstream_mark(struct zstream *)
static VALUE rb_zstream_set_avail_out(VALUE, VALUE)
VALUE rb_class_new_instance(int, VALUE *, VALUE)
void(* end)(struct gzfile *)
static VALUE rb_gzwriter_putc(VALUE, VALUE)
static VALUE rb_zstream_end(VALUE)
static void gzfile_check_footer(struct gzfile *)
#define ECONV_AFTER_OUTPUT
VALUE rb_big2ulong(VALUE x)
void rb_define_singleton_method(VALUE obj, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a singleton method for obj.
static VALUE rb_gzreader_readbyte(VALUE obj)
#define zstream_init_inflate(z)
#define ZSTREAM_AVAIL_OUT_STEP_MAX
static void zstream_expand_buffer_into(struct zstream *, unsigned long)
#define Data_Make_Struct(klass, type, mark, free, sval)
static VALUE rb_gzfile_mtime(VALUE)
#define rb_zlib_adler32_combine
static VALUE rb_gzfile_set_mtime(VALUE, VALUE)
static VALUE rb_gzwriter_initialize(int, VALUE *, VALUE)
static NORETURN(void raise_zlib_error(int, const char *))
RUBY_EXTERN void * memmove(void *, const void *, size_t)
static void zstream_unblock_func(void *ptr)
#define GZ_FLAG_ORIG_NAME
static void gzfile_read_header(struct gzfile *)
VALUE rb_str_subseq(VALUE, long, long)
static void zstream_buffer_ungetbyte(struct zstream *, int)
static void gzfile_ungets(struct gzfile *, const Bytef *, long)
static void do_inflate(struct zstream *, VALUE)
static void do_deflate(struct zstream *, VALUE, int)
static VALUE gzfile_reader_get_unused(struct gzfile *)
static void zstream_reset_input(struct zstream *)
static char * gzfile_read_raw_until_zero(struct gzfile *, long)
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
static VALUE rb_gzreader_getc(VALUE)
VALUE rb_ary_push(VALUE ary, VALUE item)
static VALUE rb_zstream_finished_p(VALUE)
void rb_lastline_set(VALUE)
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *state)
#define MBCLEN_NEEDMORE_P(ret)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
static VALUE rb_inflate_set_dictionary(VALUE, VALUE)
VALUE rb_define_class_under(VALUE outer, const char *name, VALUE super)
Defines a class under the namespace of outer.
static VALUE rb_deflate_s_allocate(VALUE)
void rb_raise(VALUE exc, const char *fmt,...)
static VALUE zstream_detach_input(struct zstream *)
static void zstream_append_input(struct zstream *, const Bytef *, long)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
static void gzfile_reader_end(struct gzfile *)
#define RETURN_ENUMERATOR(obj, argc, argv)
#define GZFILE_FLAG_FOOTER_FINISHED
#define rb_enc_left_char_head(s, p, e, enc)
static void * zstream_run_func(void *ptr)
static void zstream_discard_input(struct zstream *, long)
int rb_enc_mbclen(const char *p, const char *e, rb_encoding *enc)
void rb_include_module(VALUE klass, VALUE module)
#define GZFILE_IS_FINISHED(gz)
#define GZFILE_FLAG_HEADER_FINISHED
static VALUE rb_zlib_version(VALUE)
static VALUE rb_gzreader_each_char(VALUE obj)
#define ZSTREAM_IS_READY(z)
static VALUE gzfile_read_all(struct gzfile *)
static VALUE rb_inflate_s_inflate(VALUE, VALUE)
#define ZSTREAM_FLAG_FINISHED
static void gzreader_skip_linebreaks(struct gzfile *)
static VALUE rb_deflate_addstr(VALUE, VALUE)
#define ZSTREAM_FLAG_IN_STREAM
#define ZSTREAM_IS_GZFILE(z)
static VALUE gzfile_new(VALUE, const struct zstream_funcs *, void(*) _((struct gzfile *)))
static void zstream_init(struct zstream *, const struct zstream_funcs *)
#define ZSTREAM_FLAG_CLOSING
static void gzfile_mark(struct gzfile *)
static VALUE rb_gzwriter_flush(int, VALUE *, VALUE)
VALUE rb_str_append(VALUE, VALUE)
static VALUE rb_gzreader_rewind(VALUE)
VALUE rb_ivar_get(VALUE, ID)
static VALUE rb_gzreader_readchar(VALUE)
VALUE rb_str_to_str(VALUE)
static VALUE rb_gzfile_finish(VALUE)
static void zstream_buffer_ungets(struct zstream *, const Bytef *, unsigned long)
static void gzfile_writer_end(struct gzfile *)
#define rb_gzwriter_printf
static VALUE rb_zstream_total_in(VALUE)
#define ZSTREAM_FLAG_GZFILE
VALUE rb_enumeratorize(VALUE obj, VALUE meth, int argc, VALUE *argv)
int rb_econv_prepare_opts(VALUE opthash, VALUE *ecopts)
void rb_exc_raise(VALUE mesg)
static VALUE cLengthError
#define gzfile_writer_new(gz)
rb_encoding * rb_default_external_encoding(void)
static void gzfile_close(struct gzfile *, int)
static VALUE rb_gzfile_path(VALUE)
static long gzfile_fill(struct gzfile *gz, long len)
static unsigned long gzfile_get32(const unsigned char *)
static void gzfile_calc_crc(struct gzfile *, VALUE)
static VALUE rb_zstream_adler(VALUE)
static VALUE rb_deflate_s_deflate(int, VALUE *, VALUE)
int rb_block_given_p(void)
#define ZSTREAM_FLAG_READY
rb_econv_result_t rb_econv_convert(rb_econv_t *ec, const unsigned char **source_buffer_ptr, const unsigned char *source_buffer_end, unsigned char **destination_buffer_ptr, unsigned char *destination_buffer_end, int flags)
static VALUE cVersionError
static VALUE rb_gzwriter_s_allocate(VALUE)
static struct gzfile * get_gzfile(VALUE)
#define checksum_long(func, sum, ptr, len)
#define VALGRIND_MAKE_MEM_DEFINED(p, n)
const struct zstream::zstream_funcs * func
static VALUE rb_gzreader_gets(int, VALUE *, VALUE)
static void gzfile_free(struct gzfile *)
static VALUE gzfile_getc(struct gzfile *gz)
static void * zstream_expand_buffer_protect(void *ptr)
static VALUE rb_gzreader_read(int, VALUE *, VALUE)
static void gzfile_make_footer(struct gzfile *)
static int gzfile_read_raw_ensure(struct gzfile *, long)
static void zstream_passthrough_input(struct zstream *)
void rb_define_const(VALUE, const char *, VALUE)
VALUE rb_str_cat2(VALUE, const char *)
static void raise_zlib_error(int err, const char *msg)
static void zstream_expand_buffer(struct zstream *)
static VALUE rb_inflate_addstr(VALUE, VALUE)
#define GZ_EXTRAFLAG_FAST
#define zstream_deflate_new(klass)
static int rb_enc_dummy_p(rb_encoding *enc)
static VALUE gzfile_read_raw(struct gzfile *)
#define MBCLEN_CHARFOUND_P(ret)
static VALUE rb_gzfile_crc(VALUE)
static VALUE rb_gzreader_initialize(int, VALUE *, VALUE)
int(* run)(z_streamp, int)
static VALUE rb_zstream_reset(VALUE)
VALUE rb_call_super(int, const VALUE *)
static VALUE gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
static void gzfile_write_raw(struct gzfile *)
static VALUE rb_gzfile_lineno(VALUE)
static VALUE rb_zstream_flush_next_out(VALUE)
void * rb_thread_call_without_gvl(void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2)
static VALUE rb_zlib_crc_table(VALUE)
#define ZSTREAM_IS_FINISHED(z)
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
#define ARG_STRATEGY(val)
static VALUE rb_gzreader_bytes(VALUE obj)
VALUE rb_str_buf_cat(VALUE, const char *, long)
VALUE rb_obj_as_string(VALUE)
VALUE rb_hash_aset(VALUE, VALUE, VALUE)
#define rb_zlib_crc32_combine
static VALUE gzfile_writer_end_run(VALUE)
static VALUE gzfile_error_inspect(VALUE)
VALUE rb_str_resize(VALUE, long)
void rb_define_module_function(VALUE module, const char *name, VALUE(*func)(ANYARGS), int argc)
Defines a module function for module.
static VALUE rb_deflate_deflate(int, VALUE *, VALUE)
int rb_io_extract_encoding_option(VALUE opt, rb_encoding **enc_p, rb_encoding **enc2_p, int *fmode_p)
SSL_METHOD *(* func)(void)
VALUE rb_sprintf(const char *format,...)
static VALUE rb_gzfile_sync(VALUE)
void rb_econv_close(rb_econv_t *ec)
static VALUE rb_gzfile_closed_p(VALUE)
#define MBCLEN_CHARFOUND_LEN(ret)
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
static long gzreader_charboundary(struct gzfile *gz, long n)
static VALUE gzreader_gets(int, VALUE *, VALUE)
#define ZSTREAM_INITIAL_BUFSIZE
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
static VALUE gzfile_wrap(int argc, VALUE *argv, VALUE klass, int close_io_on_error)
static VALUE gzfile_newstr(struct gzfile *gz, VALUE str)
unsigned char buf[MIME_BUF_SIZE]
static VALUE rb_zstream_avail_in(VALUE)
static VALUE gzfile_read(struct gzfile *, long)
VALUE rb_exc_new2(VALUE etype, const char *s)
VALUE rb_str_inspect(VALUE)
static VALUE rb_gzfile_set_orig_name(VALUE, VALUE)
static void zlib_mem_free(voidpf, voidpf)
VALUE rb_file_open_str(VALUE, const char *)
#define zstream_append_input2(z, v)
static VALUE rb_gzreader_s_open(int, VALUE *, VALUE)
static VALUE zstream_new(VALUE, const struct zstream_funcs *)
VALUE rb_str_buf_new(long)
static struct zstream * get_zstream(VALUE)
void rb_undef_alloc_func(VALUE)
#define GZ_FLAG_MULTIPART
#define rb_gzwriter_print
static VALUE rb_gzfile_eof_p(VALUE)
static VALUE rb_gzreader_each_byte(VALUE)
VALUE rb_rescue2(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*r_proc)(ANYARGS), VALUE data2,...)
static VALUE zstream_shift_buffer(struct zstream *, long)
VALUE rb_attr_get(VALUE, ID)
#define RUBY_ZLIB_VERSION
rb_econv_t * rb_econv_open_opts(const char *source_encoding, const char *destination_encoding, int ecflags, VALUE ecopts)
VALUE rb_ensure(VALUE(*b_proc)(ANYARGS), VALUE data1, VALUE(*e_proc)(ANYARGS), VALUE data2)
int memcmp(const void *s1, const void *s2, size_t len)
static voidpf zlib_mem_alloc(voidpf, uInt, uInt)
static VALUE rb_gzreader_readlines(int, VALUE *, VALUE)
static VALUE rb_deflate_initialize(int, VALUE *, VALUE)
VALUE rb_time_new(time_t, long)
void rb_sys_fail(const char *mesg)
static VALUE zstream_end(struct zstream *)
RUBY_EXTERN VALUE rb_cString
void rb_jump_tag(int tag)
#define FIXNUMARG(val, ifnil)
static void gzfile_reset(struct gzfile *)
static VALUE rb_gzfile_total_in(VALUE)
static VALUE rb_deflate_flush(int, VALUE *, VALUE)
static VALUE rb_gzwriter_write(VALUE, VALUE)
static unsigned int gzfile_get16(const unsigned char *)
VALUE rb_ivar_set(VALUE, ID, VALUE)
void * ruby_xrealloc(void *ptr, size_t size)
static ID id_dictionaries
void rb_econv_check_error(rb_econv_t *ec)
static VALUE rb_zlib_crc32(int, VALUE *, VALUE)
rb_encoding * rb_enc_get(VALUE obj)
static VALUE inflate_run(VALUE)
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
static const struct zstream_funcs deflate_funcs
static VALUE rb_gzfile_total_out(VALUE)
static VALUE do_checksum(int, VALUE *, uLong(*)(uLong, const Bytef *, uInt))
static void gzfile_make_header(struct gzfile *)
static void gzfile_ungetbyte(struct gzfile *, int)
#define ZSTREAM_AVAIL_OUT_STEP_MIN
static const struct zstream_funcs inflate_funcs
static VALUE rb_inflate_initialize(int, VALUE *, VALUE)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
VALUE rb_exc_new3(VALUE etype, VALUE str)
static VALUE gzfile_ensure_close(VALUE)
void rb_define_attr(VALUE klass, const char *name, int read, int write)
Defines (a) public accessor method(s) for an attribute.
static VALUE rb_gzfile_set_lineno(VALUE, VALUE)
static VALUE rb_zstream_flush_next_in(VALUE)
static VALUE zstream_detach_buffer(struct zstream *)
static VALUE rb_gzreader_ungetc(VALUE, VALUE)
static VALUE cStreamError
static VALUE rb_inflate_sync_point_p(VALUE)
static void gzfile_raise(struct gzfile *gz, VALUE klass, const char *message)
void * rb_thread_call_with_gvl(void *(*func)(void *), void *data1)
#define ARG_MEMLEVEL(val)
#define ECONV_PARTIAL_INPUT
static VALUE zstream_sync(struct zstream *, Bytef *, long)
RUBY_EXTERN VALUE rb_cObject
static VALUE gzfile_read_raw_rescue(VALUE)
static void zstream_run(struct zstream *, Bytef *, long, int)
static VALUE rb_gzwriter_s_open(int, VALUE *, VALUE)
static void zstream_append_buffer(struct zstream *, const Bytef *, long)
#define gzfile_reader_new(gz)
static void zstream_free(struct zstream *)
VALUE rb_uint2inum(VALUE n)
static VALUE rb_gzfile_orig_name(VALUE)
#define Data_Get_Struct(obj, type, sval)
int rb_respond_to(VALUE, ID)
static void zstream_finalize(struct zstream *)
static VALUE rb_inflate_add_dictionary(VALUE obj, VALUE dictionary)
static VALUE rb_inflate_inflate(VALUE, VALUE)
static VALUE rb_gzreader_lines(int argc, VALUE *argv, VALUE obj)
static VALUE rb_gzreader_s_allocate(VALUE)
static VALUE rb_gzfile_set_sync(VALUE, VALUE)
#define RSTRING_LENINT(str)
VALUE rb_ary_new2(long capa)
#define rb_gzwriter_addstr
VALUE rb_str_new(const char *, long)
static VALUE rb_gzreader_readpartial(int argc, VALUE *argv, VALUE obj)
static VALUE rb_gzreader_readline(int, VALUE *, VALUE)
#define GZ_EXTRAFLAG_SLOW
static VALUE rb_gzfile_close(VALUE)
static VALUE gzfile_s_open(int, VALUE *, VALUE, const char *)
static VALUE rb_gzreader_each(int, VALUE *, VALUE)
static VALUE rb_zstream_data_type(VALUE)
static VALUE rb_deflate_init_copy(VALUE, VALUE)
VALUE rb_int2inum(SIGNED_VALUE n)
static void gzfile_write(struct gzfile *, Bytef *, long)
#define ZSTREAM_EXPAND_BUFFER_OK
static VALUE rb_zstream_total_out(VALUE)
VALUE rb_hash_aref(VALUE, VALUE)
rb_encoding * rb_ascii8bit_encoding(void)
RUBY_EXTERN VALUE rb_eEOFError
void rb_warning(const char *fmt,...)
#define GZ_METHOD_DEFLATE
#define zstream_init_deflate(z)
VALUE rb_define_module(const char *name)
static void zstream_reset(struct zstream *)
static long gzfile_read_more(struct gzfile *)
static VALUE rb_inflate_sync(VALUE, VALUE)
#define GZ_FLAG_UNKNOWN_MASK
static void rb_gzfile_ecopts(struct gzfile *gz, VALUE opts)
static int zstream_expand_buffer_without_gvl(struct zstream *z)
static void gzfile_reader_rewind(struct gzfile *)
static VALUE rb_zstream_finish(VALUE)
#define zstream_append_buffer2(z, v)
static void rscheck(const char *rsptr, long rslen, VALUE rs)
VALUE rb_check_string_type(VALUE)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
#define rb_enc_mbmaxlen(enc)
static VALUE gzfile_reader_end_run(VALUE)
static VALUE rb_gzfile_s_wrap(int, VALUE *, VALUE)
void rb_warn(const char *fmt,...)
static VALUE deflate_run(VALUE)
VALUE rb_econv_str_convert(rb_econv_t *ec, VALUE src, int flags)
static VALUE rb_deflate_set_dictionary(VALUE, VALUE)
VALUE rb_check_convert_type(VALUE, int, const char *, const char *)
#define zstream_inflate_new(klass)
static VALUE rb_gzreader_getbyte(VALUE obj)
static VALUE gzfile_read_raw_partial(VALUE)
static VALUE rb_zlib_adler32(int, VALUE *, VALUE)