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 GZIP_SUPPORT 1 36 #if MAX_MEM_LEVEL >= 8 37 #define DEF_MEM_LEVEL 8 39 #define DEF_MEM_LEVEL MAX_MEM_LEVEL 43 #if SIZEOF_LONG > SIZEOF_INT 47 if (n > UINT_MAX) n = UINT_MAX;
50 #define MAX_UINT(n) max_uint(n) 52 #define MAX_UINT(n) (uInt)(n) 148 static unsigned long gzfile_get32(
const unsigned char*);
149 static void gzfile_set32(
unsigned long n,
unsigned char*);
326 case Z_VERSION_ERROR:
337 rb_sprintf(
"unknown zlib error %d: %s", err, msg));
349 fprintf(stderr,
"zlib(finalizer): %s\n", msg);
370 #if SIZEOF_LONG > SIZEOF_INT 374 if (len > UINT_MAX) {
376 sum =
func(sum, ptr, UINT_MAX);
379 }
while (len >= UINT_MAX);
381 if (len > 0) sum =
func(sum, ptr, (uInt)len);
385 #define checksum_long(func, sum, ptr, len) (func)((sum), (ptr), (len)) 399 else if (
NIL_P(str)) {
403 sum =
func(0, Z_NULL, 0);
407 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++) {
536 int (*
run)(z_streamp, int);
540 #define ZSTREAM_FLAG_READY 0x1 541 #define ZSTREAM_FLAG_IN_STREAM 0x2 542 #define ZSTREAM_FLAG_FINISHED 0x4 543 #define ZSTREAM_FLAG_CLOSING 0x8 544 #define ZSTREAM_FLAG_GZFILE 0x10 546 #define ZSTREAM_FLAG_UNUSED 0x20 548 #define ZSTREAM_READY(z) ((z)->flags |= ZSTREAM_FLAG_READY) 549 #define ZSTREAM_IS_READY(z) ((z)->flags & ZSTREAM_FLAG_READY) 550 #define ZSTREAM_IS_FINISHED(z) ((z)->flags & ZSTREAM_FLAG_FINISHED) 551 #define ZSTREAM_IS_CLOSING(z) ((z)->flags & ZSTREAM_FLAG_CLOSING) 552 #define ZSTREAM_IS_GZFILE(z) ((z)->flags & ZSTREAM_FLAG_GZFILE) 553 #define ZSTREAM_BUF_FILLED(z) (NIL_P((z)->buf) ? 0 : RSTRING_LEN((z)->buf)) 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,
606 z->
stream.opaque = Z_NULL;
608 z->
stream.next_in = Z_NULL;
610 z->
stream.next_out = Z_NULL;
615 #define zstream_init_deflate(z) zstream_init((z), &deflate_funcs) 616 #define zstream_init_inflate(z) zstream_init((z), &inflate_funcs) 666 else if (z->
stream.avail_out != size) {
681 return (
void *)(
VALUE)state;
724 if (z->
stream.avail_out >= (uInt)len) {
725 z->
stream.avail_out -= (uInt)len;
735 #define zstream_append_buffer2(z,v) \ 736 zstream_append_buffer((z),(Bytef*)RSTRING_PTR(v),RSTRING_LEN(v)) 786 memmove(bufptr, bufptr + len, buflen);
793 z->
stream.avail_out = (uInt)buflen;
809 memmove(bufptr + len, bufptr, filled);
812 if (z->
stream.avail_out > 0) {
813 if (len > z->
stream.avail_out) len = z->
stream.avail_out;
815 z->
stream.avail_out-=(uInt)len;
829 if (len <= 0)
return;
841 #define zstream_append_input2(z,v)\ 843 zstream_append_input((z), (Bytef*)RSTRING_PTR(v), RSTRING_LEN(v)) 911 rb_warning(
"attempt to close uninitialized zstream; ignored.");
915 rb_warning(
"attempt to close unfinished zstream; reset forced.");
942 if (err == Z_STREAM_END) {
948 if (err != Z_OK && err != Z_BUF_ERROR)
951 if (z->
stream.avail_out > 0) {
956 if (z->
stream.avail_in == 0 && z->
func == &inflate_funcs) {
979 return (
void *)(
VALUE)err;
1007 z->
stream.next_in = (Bytef*)
"";
1020 if (z->
stream.avail_out == 0) {
1028 if (flush != Z_FINISH && err == Z_BUF_ERROR
1029 && z->
stream.avail_out > 0) {
1035 if (err != Z_OK && err != Z_STREAM_END) {
1036 if (z->
stream.avail_in > 0) {
1039 if (err == Z_NEED_DICT) {
1053 if (z->
stream.avail_in > 0) {
1058 if (args.jump_state)
1071 err = inflateSync(&z->
stream);
1079 if (err != Z_DATA_ERROR) {
1085 if (len <= 0)
return Qfalse;
1089 err = inflateSync(&z->
stream);
1094 if (err != Z_DATA_ERROR) {
1113 if (err == Z_STREAM_ERROR)
1115 if (err == Z_DATA_ERROR)
1134 return sizeof(
struct zstream);
1151 z->
stream.opaque = (voidpf)obj;
1155 #define zstream_deflate_new(klass) zstream_new((klass), &deflate_funcs) 1156 #define zstream_inflate_new(klass) zstream_new((klass), &inflate_funcs) 1165 rb_raise(cZError,
"stream is not ready");
1417 #define FIXNUMARG(val, ifnil) \ 1418 (NIL_P((val)) ? (ifnil) \ 1421 #define ARG_LEVEL(val) FIXNUMARG((val), Z_DEFAULT_COMPRESSION) 1422 #define ARG_WBITS(val) FIXNUMARG((val), MAX_WBITS) 1423 #define ARG_MEMLEVEL(val) FIXNUMARG((val), DEF_MEM_LEVEL) 1424 #define ARG_STRATEGY(val) FIXNUMARG((val), Z_DEFAULT_STRATEGY) 1425 #define ARG_FLUSH(val) FIXNUMARG((val), Z_NO_FLUSH) 1514 rb_scan_args(argc, argv,
"04", &level, &wbits, &memlevel, &strategy);
1542 if (z1 == z2)
return self;
1599 err = deflateInit(&z.
stream, lev);
1605 args[0] = (
VALUE)&z;
1621 if (flush != Z_NO_FLUSH ||
RSTRING_LEN(src) > 0) {
1705 flush =
FIXNUMARG(v_flush, Z_SYNC_FLUSH);
1706 if (flush != Z_NO_FLUSH) {
1729 int level, strategy;
1738 err = deflateParams(&z->
stream, level, strategy);
1739 filled = n - z->
stream.avail_out;
1740 while (err == Z_BUF_ERROR) {
1741 rb_warning(
"deflateParams() returned Z_BUF_ERROR");
1745 err = deflateParams(&z->
stream, level, strategy);
1746 filled = n - z->
stream.avail_out;
1779 err = deflateSetDictionary(&z->
stream,
1914 err = inflateInit(&z.
stream);
1920 args[0] = (
VALUE)&z;
2089 err = inflateSyncPoint(&z->
stream);
2115 err = inflateSetDictionary(&z->
stream,
2135 #define GZ_MAGIC1 0x1f 2136 #define GZ_MAGIC2 0x8b 2137 #define GZ_METHOD_DEFLATE 8 2138 #define GZ_FLAG_MULTIPART 0x2 2139 #define GZ_FLAG_EXTRA 0x4 2140 #define GZ_FLAG_ORIG_NAME 0x8 2141 #define GZ_FLAG_COMMENT 0x10 2142 #define GZ_FLAG_ENCRYPT 0x20 2143 #define GZ_FLAG_UNKNOWN_MASK 0xc0 2145 #define GZ_EXTRAFLAG_FAST 0x4 2146 #define GZ_EXTRAFLAG_SLOW 0x2 2149 #define OS_MSDOS 0x00 2150 #define OS_AMIGA 0x01 2152 #define OS_UNIX 0x03 2153 #define OS_ATARI 0x05 2155 #define OS_MACOS 0x07 2156 #define OS_TOPS20 0x0a 2157 #define OS_WIN32 0x0b 2159 #define OS_VMCMS 0x04 2160 #define OS_ZSYSTEM 0x08 2162 #define OS_QDOS 0x0c 2163 #define OS_RISCOS 0x0d 2164 #define OS_UNKNOWN 0xff 2167 #define OS_CODE OS_UNIX 2197 #define GZFILE_CBUF_CAPA 10 2199 #define GZFILE_FLAG_SYNC ZSTREAM_FLAG_UNUSED 2200 #define GZFILE_FLAG_HEADER_FINISHED (ZSTREAM_FLAG_UNUSED << 1) 2201 #define GZFILE_FLAG_FOOTER_FINISHED (ZSTREAM_FLAG_UNUSED << 2) 2203 #define GZFILE_IS_FINISHED(gz) \ 2204 (ZSTREAM_IS_FINISHED(&(gz)->z) && ZSTREAM_BUF_FILLED(&(gz)->z) == 0) 2206 #define GZFILE_READ_SIZE 2048 2229 if (z->
func == &deflate_funcs) {
2230 finalizer_warn(
"Zlib::GzipWriter object must be closed explicitly.");
2243 const struct gzfile *gz = p;
2255 0, 0, RUBY_TYPED_FREE_IMMEDIATELY
2269 gz->
crc = crc32(0, Z_NULL, 0);
2293 #define gzfile_writer_new(gz) gzfile_new((gz),&deflate_funcs,gzfile_writer_end) 2294 #define gzfile_reader_new(gz) gzfile_new((gz),&inflate_funcs,gzfile_reader_end) 2301 gz->
crc = crc32(0, Z_NULL, 0);
2380 rb_raise(cGzError,
"unexpected end of string");
2384 if (
NIL_P(str))
return 0;
2402 rb_raise(cGzError,
"unexpected end of file");
2414 n = *(src++) & 0xff;
2415 n |= (*(src++) & 0xff) << 8;
2419 static unsigned long 2423 n = *(src++) & 0xff;
2424 n |= (*(src++) & 0xff) << 8;
2425 n |= (*(src++) & 0xff) << 16;
2426 n |= (*(src++) & 0xffU) << 24;
2433 *(dst++) = n & 0xff;
2434 *(dst++) = (n >> 8) & 0xff;
2435 *(dst++) = (n >> 16) & 0xff;
2436 *dst = (n >> 24) & 0xff;
2460 if (!
NIL_P(input)) {
2473 unsigned char flags = 0, extraflags = 0;
2481 if (gz->
mtime == 0) {
2482 gz->
mtime = time(0);
2485 if (gz->
level == Z_BEST_SPEED) {
2488 else if (gz->
level == Z_BEST_COMPRESSION) {
2497 buf[8] = extraflags;
2527 const unsigned char *head;
2541 rb_raise(cGzError,
"unsupported compression method %d", head[2]);
2546 rb_raise(cGzError,
"multi-part gzip file is not supported");
2549 rb_raise(cGzError,
"encrypted gzip file is not supported");
2552 rb_raise(cGzError,
"unknown flags 0x%02x", flags);
2556 gz->
level = Z_BEST_SPEED;
2559 gz->
level = Z_BEST_COMPRESSION;
2562 gz->
level = Z_DEFAULT_COMPRESSION;
2571 rb_raise(cGzError,
"unexpected end of file");
2575 rb_raise(cGzError,
"unexpected end of file");
2581 rb_raise(cGzError,
"unexpected end of file");
2591 rb_raise(cGzError,
"unexpected end of file");
2608 unsigned long crc, length;
2622 if (gz->
crc != crc) {
2623 rb_raise(cCRCError,
"invalid compressed data -- crc error");
2626 rb_raise(cLengthError,
"invalid compressed data -- length error");
2640 ? Z_SYNC_FLUSH : Z_NO_FLUSH);
2654 rb_raise(cGzError,
"unexpected end of file");
2725 if (len < 0)
return Qnil;
2765 if (!
NIL_P(outbuf)) {
2791 if (
NIL_P(dst))
return dst;
2815 const unsigned char *ss, *sp, *se;
2816 unsigned char *ds, *
dp, *de;
2823 ds = dp = (
unsigned char *)gz->
cbuf;
2838 if (
NIL_P(dst))
return dst;
2942 rb_raise(cGzError,
"closed gzip stream");
3018 if (close_io_on_error) {
3219 rb_raise(cGzError,
"header is already written");
3241 rb_raise(cGzError,
"header is already written");
3265 rb_raise(cGzError,
"header is already written");
3396 uLong total_out = gz->
z.
stream.total_out;
3399 if (total_out >= (uLong)buf_filled) {
3402 return LONG2FIX(-(buf_filled - (
long)total_out));
3512 if (!
NIL_P(opt)) argc--;
3515 rb_scan_args(argc, argv,
"12", &io, &level, &strategy);
3520 err = deflateInit2(&gz->
z.
stream, gz->
level, Z_DEFLATED,
3553 flush =
FIXNUMARG(v_flush, Z_SYNC_FLUSH);
3554 if (flush != Z_NO_FLUSH) {
3602 #define rb_gzwriter_addstr rb_io_addstr 3607 #define rb_gzwriter_printf rb_io_printf 3612 #define rb_gzwriter_print rb_io_print 3617 #define rb_gzwriter_puts rb_io_puts 3723 err = inflateInit2(&gz->
z.
stream, -MAX_WBITS);
3929 rb_warn(
"Zlib::GzipReader#bytes is deprecated; use #each_byte instead");
3984 while (n++, *(p++) ==
'\n') {
4037 long rslen, n, limit = -1;
4052 else if (!
NIL_P(rs)) {
4084 if (
NIL_P(dst))
return dst;
4124 if (!rspara)
rscheck(rsptr, rslen, rs);
4126 if (limit > 0 && filled >= limit) {
4129 res = memchr(p, rsptr[0], (filled - n + 1));
4132 if (limit > 0 && filled >= limit)
break;
4136 n += (long)(res - p);
4138 if (rslen == 1 ||
memcmp(p, rsptr, rslen) == 0)
break;
4148 if (
NIL_P(dst))
return dst;
4215 rb_warn(
"Zlib::GzipReader#lines is deprecated; use #each_line instead");
4257 #define OPTHASH_GIVEN_P(opts) \ 4258 (argc > 0 && !NIL_P((opts) = rb_check_hash_type(argv[argc-1])) && (--argc, 1)) 4287 struct gzfile *gz = &gz0;
4298 if (kwargs[0] !=
Qundef) {
4301 if (kwargs[1] !=
Qundef) {
4302 strategy = kwargs[1];
4309 err = deflateInit2(&gz->
z.
stream, gz->
level, Z_DEFLATED,
4356 struct gzfile *gz = &gz0;
4363 err = inflateInit2(&gz->
z.
stream, -MAX_WBITS);
4374 rb_raise(cGzError,
"unexpected end of file");
4377 rb_raise(cNoFooter,
"footer is not found");
4387 VALUE mZlib, cZStream, cDeflate, cInflate;
4389 VALUE cGzipFile, cGzipWriter, cGzipReader;
4498 INT2FIX(Z_DEFAULT_COMPRESSION));
4569 id_readpartial =
rb_intern(
"readpartial");
RUBY_EXTERN VALUE rb_cString
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)
#define MBCLEN_CHARFOUND_P(ret)
static VALUE rb_gzfile_comment(VALUE)
static VALUE rb_gzfile_to_io(VALUE)
static VALUE new_wrap(VALUE tmp)
#define MBCLEN_CHARFOUND_LEN(ret)
#define RUBY_TYPED_FREE_IMMEDIATELY
static VALUE rb_gzreader_external_encoding(VALUE self)
static VALUE rb_gzfile_level(VALUE)
static void finalizer_warn(const char *)
static VALUE zlib_gunzip(VALUE klass, VALUE src)
static VALUE rb_zstream_set_avail_out(VALUE, VALUE)
static VALUE rb_gzwriter_putc(VALUE, VALUE)
static VALUE rb_zstream_end(VALUE)
static void gzfile_check_footer(struct gzfile *)
void rb_undef_alloc_func(VALUE)
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)
static VALUE rb_gzfile_mtime(VALUE)
VALUE rb_str_cat(VALUE, const char *, long)
int rb_get_kwargs(VALUE keyword_hash, const ID *table, int required, int optional, VALUE *values)
#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 *))
static void zstream_unblock_func(void *ptr)
#define TypedData_Get_Struct(obj, type, data_type, sval)
#define GZ_FLAG_ORIG_NAME
static void gzfile_read_header(struct gzfile *)
static void zstream_buffer_ungetbyte(struct zstream *, int)
static void gzfile_ungets(struct gzfile *, const Bytef *, long)
static void do_inflate(struct zstream *, VALUE)
VALUE rb_exc_new_str(VALUE etype, VALUE str)
static void do_deflate(struct zstream *, VALUE, int)
static VALUE gzfile_reader_get_unused(struct gzfile *)
int rb_enc_dummy_p(rb_encoding *enc)
void(* end)(struct gzfile *)
int rb_econv_prepare_opts(VALUE opthash, VALUE *ecopts)
void rb_econv_close(rb_econv_t *ec)
static void zstream_reset_input(struct zstream *)
VALUE rb_enc_from_encoding(rb_encoding *encoding)
static char * gzfile_read_raw_until_zero(struct gzfile *, long)
static VALUE rb_gzreader_getc(VALUE)
VALUE rb_ary_push(VALUE ary, VALUE item)
SSL_METHOD *(* func)(void)
if(len<=MAX_WORD_LENGTH &&len >=MIN_WORD_LENGTH)
static VALUE rb_zstream_finished_p(VALUE)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
void rb_str_set_len(VALUE, long)
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *state)
static void zstream_free(void *)
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 *)
VALUE rb_ivar_get(VALUE, ID)
static void zstream_append_input(struct zstream *, const Bytef *, long)
#define RSTRING_GETMEM(str, ptrvar, lenvar)
VALUE rb_enc_associate(VALUE obj, rb_encoding *enc)
static void gzfile_reader_end(struct gzfile *)
#define GZFILE_FLAG_FOOTER_FINISHED
void rb_define_alloc_func(VALUE, rb_alloc_func_t)
VALUE rb_obj_is_kind_of(VALUE, VALUE)
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)
void rb_gc_mark(VALUE ptr)
#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 *)
VALUE rb_file_open_str(VALUE, const char *)
static VALUE rb_inflate_s_inflate(VALUE, VALUE)
#define ZSTREAM_FLAG_FINISHED
#define rb_enc_mbmaxlen(enc)
static void gzreader_skip_linebreaks(struct gzfile *)
static VALUE rb_deflate_addstr(VALUE, VALUE)
static void zstream_mark(void *)
static size_t gzfile_memsize(const void *p)
#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 VALUE rb_gzwriter_flush(int, VALUE *, VALUE)
#define OPTHASH_GIVEN_P(opts)
static VALUE rb_gzreader_rewind(VALUE)
VALUE rb_str_conv_enc_opts(VALUE str, rb_encoding *from, rb_encoding *to, int ecflags, VALUE ecopts)
static VALUE rb_gzreader_readchar(VALUE)
static VALUE rb_gzfile_finish(VALUE)
static void zstream_buffer_ungets(struct zstream *, const Bytef *, unsigned long)
RUBY_EXTERN void * memmove(void *, const void *, size_t)
static void gzfile_writer_end(struct gzfile *)
#define rb_gzwriter_printf
static VALUE rb_zstream_total_in(VALUE)
VALUE rb_str_buf_cat(VALUE, const char *, long)
#define ZSTREAM_FLAG_GZFILE
void * xmalloc2(size_t, size_t) RUBY_ATTR_ALLOC_SIZE((1
void rb_exc_raise(VALUE mesg)
#define RB_TYPE_P(obj, type)
static VALUE cLengthError
#define gzfile_writer_new(gz)
void rb_econv_check_error(rb_econv_t *ec)
rb_encoding * rb_default_external_encoding(void)
static void gzfile_close(struct gzfile *, int)
static void gzfile_free(void *)
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
VALUE rb_hash_aset(VALUE hash, VALUE key, VALUE val)
static VALUE cVersionError
VALUE rb_str_substr(VALUE, long, long)
RUBY_EXTERN VALUE rb_cObject
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
#define MBCLEN_NEEDMORE_P(ret)
static VALUE rb_gzreader_gets(int, VALUE *, VALUE)
static VALUE gzfile_getc(struct gzfile *gz)
static void * zstream_expand_buffer_protect(void *ptr)
VALUE rb_str_cat2(VALUE, const char *)
VALUE rb_obj_as_string(VALUE)
static VALUE rb_gzreader_read(int, VALUE *, VALUE)
static void gzfile_make_footer(struct gzfile *)
rb_econv_t * rb_econv_open_opts(const char *source_encoding, const char *destination_encoding, int ecflags, VALUE ecopts)
#define ECONV_PARTIAL_INPUT
static int gzfile_read_raw_ensure(struct gzfile *, long)
#define ECONV_AFTER_OUTPUT
static void zstream_passthrough_input(struct zstream *)
static void raise_zlib_error(int err, const char *msg)
static void zstream_expand_buffer(struct zstream *)
static VALUE rb_inflate_addstr(VALUE, VALUE)
static const rb_data_type_t gzfile_data_type
void rb_define_const(VALUE, const char *, VALUE)
#define GZ_EXTRAFLAG_FAST
#define zstream_deflate_new(klass)
void rb_lastline_set(VALUE)
static VALUE gzfile_read_raw(struct gzfile *)
#define MBCLEN_NEEDMORE_LEN(ret)
static VALUE rb_gzfile_crc(VALUE)
static VALUE rb_gzreader_initialize(int, VALUE *, VALUE)
VALUE rb_str_conv_enc(VALUE str, rb_encoding *from, rb_encoding *to)
static VALUE rb_zstream_reset(VALUE)
static VALUE gzfile_readpartial(struct gzfile *gz, long len, VALUE outbuf)
int(* run)(z_streamp, int)
static void gzfile_write_raw(struct gzfile *)
VALUE rb_obj_reveal(VALUE obj, VALUE klass)
static VALUE rb_gzfile_lineno(VALUE)
static VALUE rb_zstream_flush_next_out(VALUE)
VALUE rb_class_new_instance(int, const VALUE *, VALUE)
void * rb_thread_call_without_gvl(void *(*func)(void *), void *data1, rb_unblock_function_t *ubf, void *data2)
VALUE rb_time_new(time_t, long)
static VALUE rb_zlib_crc_table(VALUE)
#define ZSTREAM_IS_FINISHED(z)
#define ARG_STRATEGY(val)
VALUE rb_str_resurrect(VALUE str)
static VALUE rb_gzreader_bytes(VALUE obj)
VALUE rb_str_resize(VALUE, long)
#define rb_zlib_crc32_combine
static VALUE gzfile_writer_end_run(VALUE)
static VALUE gzfile_error_inspect(VALUE)
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)
VALUE rb_sprintf(const char *format,...)
static VALUE rb_gzfile_sync(VALUE)
static VALUE rb_gzfile_closed_p(VALUE)
int rb_enc_precise_mbclen(const char *p, const char *e, rb_encoding *enc)
static long gzreader_charboundary(struct gzfile *gz, long n)
static void gzfile_init(struct gzfile *gz, const struct zstream_funcs *funcs, void(*endfunc)(struct gzfile *))
static VALUE gzreader_gets(int, VALUE *, VALUE)
#define ZSTREAM_INITIAL_BUFSIZE
int rb_scan_args(int argc, const VALUE *argv, const char *fmt,...)
void rb_str_modify_expand(VALUE, long)
static VALUE gzfile_wrap(int argc, VALUE *argv, VALUE klass, int close_io_on_error)
VALUE rb_ivar_set(VALUE, ID, VALUE)
static VALUE gzfile_newstr(struct gzfile *gz, VALUE str)
static VALUE rb_zstream_avail_in(VALUE)
static VALUE gzfile_read(struct gzfile *, long)
static VALUE rb_gzfile_set_orig_name(VALUE, VALUE)
static void zlib_mem_free(voidpf, voidpf)
#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_obj_hide(VALUE obj)
static struct zstream * get_zstream(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_call_super(int, const VALUE *)
#define RUBY_ZLIB_VERSION
static void gzfile_mark(void *)
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)
static void zlib_gunzip_end(struct gzfile *gz)
void rb_sys_fail(const char *mesg)
static VALUE zstream_end(struct zstream *)
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)
int rb_respond_to(VALUE, ID)
register unsigned int len
static VALUE rb_gzwriter_write(VALUE, VALUE)
static unsigned int gzfile_get16(const unsigned char *)
static ID id_dictionaries
static VALUE rb_zlib_crc32(int, VALUE *, VALUE)
rb_encoding * rb_enc_get(VALUE obj)
static VALUE inflate_run(VALUE)
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))
#define UNLIMITED_ARGUMENTS
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)
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)
VALUE rb_check_convert_type(VALUE, int, const char *, const char *)
static VALUE zlib_s_gzip(int argc, VALUE *argv, VALUE klass)
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 void zlib_gzip_end(struct gzfile *gz)
static VALUE zstream_detach_buffer(struct zstream *)
static VALUE rb_gzreader_ungetc(VALUE, VALUE)
RUBY_SYMBOL_EXPORT_BEGIN void * rb_thread_call_with_gvl(void *(*func)(void *), void *data1)
static VALUE cStreamError
VALUE rb_hash_aref(VALUE hash, VALUE key)
static VALUE rb_inflate_sync_point_p(VALUE)
static void gzfile_raise(struct gzfile *gz, VALUE klass, const char *message)
VALUE rb_enumeratorize(VALUE obj, VALUE meth, int argc, const VALUE *argv)
#define ARG_MEMLEVEL(val)
VALUE rb_check_string_type(VALUE)
static VALUE zstream_sync(struct zstream *, Bytef *, long)
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)
#define ZSTREAM_BUF_FILLED(z)
static size_t zstream_memsize(const void *p)
VALUE rb_uint2inum(VALUE n)
size_t rb_str_capacity(VALUE str)
static VALUE rb_gzfile_orig_name(VALUE)
static void zstream_finalize(struct zstream *)
static VALUE rb_inflate_add_dictionary(VALUE obj, VALUE dictionary)
#define TypedData_Make_Struct(klass, type, data_type, sval)
#define rb_enc_left_char_head(s, p, e, enc)
static VALUE rb_inflate_inflate(VALUE, VALUE)
VALUE rb_str_inspect(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 RETURN_ENUMERATOR(obj, argc, argv)
#define rb_gzwriter_addstr
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)
rb_encoding * rb_ascii8bit_encoding(void)
void rb_warning(const char *fmt,...)
#define GZ_METHOD_DEFLATE
#define RSTRING_LENINT(str)
RUBY_EXTERN VALUE rb_eEOFError
#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 int zstream_expand_buffer_non_stream(struct zstream *z)
static void rb_gzfile_ecopts(struct gzfile *gz, VALUE opts)
VALUE rb_str_buf_new(long)
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)
void rb_define_method(VALUE klass, const char *name, VALUE(*func)(ANYARGS), int argc)
VALUE rb_str_append(VALUE, VALUE)
static VALUE gzfile_reader_end_run(VALUE)
static VALUE rb_gzfile_s_wrap(int, VALUE *, VALUE)
void rb_warn(const char *fmt,...)
VALUE rb_str_to_str(VALUE)
static VALUE deflate_run(VALUE)
static VALUE rb_deflate_set_dictionary(VALUE, VALUE)
static const rb_data_type_t zstream_data_type
#define zstream_inflate_new(klass)
VALUE rb_attr_get(VALUE, ID)
static VALUE rb_gzreader_getbyte(VALUE obj)
static VALUE gzfile_read_raw_partial(VALUE)
VALUE rb_econv_str_convert(rb_econv_t *ec, VALUE src, int flags)
static VALUE rb_zlib_adler32(int, VALUE *, VALUE)
VALUE rb_str_new(const char *, long)