14 #ifdef HAVE_VALGRIND_MEMCHECK_H
15 # include <valgrind/memcheck.h>
16 # ifndef VALGRIND_MAKE_MEM_DEFINED
17 # define VALGRIND_MAKE_MEM_DEFINED(p, n) VALGRIND_MAKE_READABLE((p), (n))
19 # ifndef VALGRIND_MAKE_MEM_UNDEFINED
20 # define VALGRIND_MAKE_MEM_UNDEFINED(p, n) VALGRIND_MAKE_WRITABLE((p), (n))
23 # define VALGRIND_MAKE_MEM_DEFINED(p, n)
24 # define VALGRIND_MAKE_MEM_UNDEFINED(p, n)
27 #define RUBY_ZLIB_VERSION "0.6.0"
30 #define OBJ_IS_FREED(val) (RBASIC(val)->flags == 0)
33 #define GZIP_SUPPORT 1
38 #if MAX_MEM_LEVEL >= 8
39 #define DEF_MEM_LEVEL 8
41 #define DEF_MEM_LEVEL MAX_MEM_LEVEL
45 #if SIZEOF_LONG > SIZEOF_INT
49 if (n > UINT_MAX) n = UINT_MAX;
52 #define MAX_UINT(n) max_uint(n)
54 #define MAX_UINT(n) (uInt)(n)
57 #define sizeof(x) ((int)sizeof(x))
148 static unsigned long gzfile_get32(
const unsigned char*);
149 static void gzfile_set32(
unsigned long n,
unsigned char*);
287 case Z_VERSION_ERROR:
299 snprintf(buf, BUFSIZ,
"unknown zlib error %d: %s", err, msg);
313 fprintf(stderr,
"zlib(finalizer): %s\n", msg);
334 #if SIZEOF_LONG > SIZEOF_INT
338 if (len > UINT_MAX) {
340 sum =
func(sum, ptr, UINT_MAX);
343 }
while (len >= UINT_MAX);
345 if (len > 0) sum =
func(sum, ptr, (uInt)len);
349 #define checksum_long(func, sum, ptr, len) (func)((sum), (ptr), (len))
356 uLong (*
func)(uLong,
const Bytef*, uInt);
366 else if (
NIL_P(str)) {
370 sum =
func(0, Z_NULL, 0);
374 sum =
func(sum, Z_NULL, 0);
400 #ifdef HAVE_ADLER32_COMBINE
418 #define rb_zlib_adler32_combine rb_f_notimplement
438 #ifdef HAVE_CRC32_COMBINE
456 #define rb_zlib_crc32_combine rb_f_notimplement
467 #if !defined(HAVE_TYPE_Z_CRC_T)
469 typedef unsigned long z_crc_t;
471 const z_crc_t *crctbl;
475 crctbl = get_crc_table();
478 for (i = 0; i < 256; i++) {
497 int (*
run)(z_streamp, int);
501 #define ZSTREAM_FLAG_READY 0x1
502 #define ZSTREAM_FLAG_IN_STREAM 0x2
503 #define ZSTREAM_FLAG_FINISHED 0x4
504 #define ZSTREAM_FLAG_CLOSING 0x8
505 #define ZSTREAM_FLAG_UNUSED 0x10
507 #define ZSTREAM_READY(z) ((z)->flags |= ZSTREAM_FLAG_READY)
508 #define ZSTREAM_IS_READY(z) ((z)->flags & ZSTREAM_FLAG_READY)
509 #define ZSTREAM_IS_FINISHED(z) ((z)->flags & ZSTREAM_FLAG_FINISHED)
510 #define ZSTREAM_IS_CLOSING(z) ((z)->flags & ZSTREAM_FLAG_CLOSING)
514 #define ZSTREAM_INITIAL_BUFSIZE 1024
515 #define ZSTREAM_AVAIL_OUT_STEP_MAX 16384
516 #define ZSTREAM_AVAIL_OUT_STEP_MIN 2048
519 deflateReset, deflateEnd, deflate,
523 inflateReset, inflateEnd, inflate,
554 z->
stream.opaque = Z_NULL;
556 z->
stream.next_in = Z_NULL;
558 z->
stream.next_out = Z_NULL;
563 #define zstream_init_deflate(z) zstream_init((z), &deflate_funcs)
564 #define zstream_init_inflate(z) zstream_init((z), &inflate_funcs)
610 else if (z->
stream.avail_out != size) {
635 if (z->
stream.avail_out >= (uInt)len) {
636 z->
stream.avail_out -= (uInt)len;
647 #define zstream_append_buffer2(z,v) \
648 zstream_append_buffer((z),(Bytef*)RSTRING_PTR(v),RSTRING_LEN(v))
691 z->
stream.avail_out = (uInt)buflen;
706 if (z->
stream.avail_out > 0) {
707 if (len > z->
stream.avail_out) len = z->
stream.avail_out;
709 z->
stream.avail_out-=(uInt)len;
723 if (z->
stream.avail_out > 0) {
732 if (len <= 0)
return;
744 #define zstream_append_input2(z,v)\
746 zstream_append_input((z), (Bytef*)RSTRING_PTR(v), RSTRING_LEN(v))
816 rb_warning(
"attempt to close uninitialized zstream; ignored.");
820 rb_warning(
"attempt to close unfinished zstream; reset forced.");
841 z->
stream.next_in = (Bytef*)
"";
854 if (z->
stream.avail_out == 0) {
867 if (err == Z_STREAM_END) {
873 if (flush != Z_FINISH && err == Z_BUF_ERROR
874 && z->
stream.avail_out > 0) {
879 if (z->
stream.avail_in > 0) {
884 if (z->
stream.avail_out > 0) {
892 if (z->
stream.avail_in > 0) {
907 err = inflateSync(&z->
stream);
915 if (err != Z_DATA_ERROR) {
921 if (len <= 0)
return Qfalse;
925 err = inflateSync(&z->
stream);
930 if (err != Z_DATA_ERROR) {
948 if (err == Z_STREAM_ERROR)
950 if (err == Z_DATA_ERROR)
975 #define zstream_deflate_new(klass) zstream_new((klass), &deflate_funcs)
976 #define zstream_inflate_new(klass) zstream_new((klass), &inflate_funcs)
985 rb_raise(cZError,
"stream is not ready");
1230 #define FIXNUMARG(val, ifnil) \
1231 (NIL_P((val)) ? (ifnil) \
1232 : ((void)Check_Type((val), T_FIXNUM), FIX2INT((val))))
1234 #define ARG_LEVEL(val) FIXNUMARG((val), Z_DEFAULT_COMPRESSION)
1235 #define ARG_WBITS(val) FIXNUMARG((val), MAX_WBITS)
1236 #define ARG_MEMLEVEL(val) FIXNUMARG((val), DEF_MEM_LEVEL)
1237 #define ARG_STRATEGY(val) FIXNUMARG((val), Z_DEFAULT_STRATEGY)
1238 #define ARG_FLUSH(val) FIXNUMARG((val), Z_NO_FLUSH)
1309 VALUE level, wbits, memlevel, strategy;
1312 rb_scan_args(argc, argv,
"04", &level, &wbits, &memlevel, &strategy);
1397 err = deflateInit(&z.
stream, lev);
1403 args[0] = (
VALUE)&z;
1419 if (flush != Z_NO_FLUSH ||
RSTRING_LEN(src) > 0) {
1461 VALUE src, flush, dst;
1509 flush =
FIXNUMARG(v_flush, Z_SYNC_FLUSH);
1510 if (flush != Z_NO_FLUSH) {
1542 int level, strategy;
1550 err = deflateParams(&z->
stream, level, strategy);
1552 while (err == Z_BUF_ERROR) {
1553 rb_warning(
"deflateParams() returned Z_BUF_ERROR");
1556 err = deflateParams(&z->
stream, level, strategy);
1589 err = deflateSetDictionary(&z->
stream,
1717 err = inflateInit(&z.
stream);
1723 args[0] = (
VALUE)&z;
1867 err = inflateSyncPoint(&z->
stream);
1893 err = inflateSetDictionary(&z->
stream,
1913 #define GZ_MAGIC1 0x1f
1914 #define GZ_MAGIC2 0x8b
1915 #define GZ_METHOD_DEFLATE 8
1916 #define GZ_FLAG_MULTIPART 0x2
1917 #define GZ_FLAG_EXTRA 0x4
1918 #define GZ_FLAG_ORIG_NAME 0x8
1919 #define GZ_FLAG_COMMENT 0x10
1920 #define GZ_FLAG_ENCRYPT 0x20
1921 #define GZ_FLAG_UNKNOWN_MASK 0xc0
1923 #define GZ_EXTRAFLAG_FAST 0x4
1924 #define GZ_EXTRAFLAG_SLOW 0x2
1927 #define OS_MSDOS 0x00
1928 #define OS_AMIGA 0x01
1930 #define OS_UNIX 0x03
1931 #define OS_ATARI 0x05
1933 #define OS_MACOS 0x07
1934 #define OS_TOPS20 0x0a
1935 #define OS_WIN32 0x0b
1937 #define OS_VMCMS 0x04
1938 #define OS_ZSYSTEM 0x08
1940 #define OS_QDOS 0x0c
1941 #define OS_RISCOS 0x0d
1942 #define OS_UNKNOWN 0xff
1945 #define OS_CODE OS_UNIX
1975 #define GZFILE_CBUF_CAPA 10
1977 #define GZFILE_FLAG_SYNC ZSTREAM_FLAG_UNUSED
1978 #define GZFILE_FLAG_HEADER_FINISHED (ZSTREAM_FLAG_UNUSED << 1)
1979 #define GZFILE_FLAG_FOOTER_FINISHED (ZSTREAM_FLAG_UNUSED << 2)
1981 #define GZFILE_IS_FINISHED(gz) \
1982 (ZSTREAM_IS_FINISHED(&(gz)->z) && (gz)->z.buf_filled == 0)
1984 #define GZFILE_READ_SIZE 2048
2004 if (z->
func == &deflate_funcs) {
2005 finalizer_warn(
"Zlib::GzipWriter object must be closed explicitly.");
2018 const struct zstream_funcs *funcs;
2019 void (*endfunc)(struct
gzfile *);
2032 gz->
crc = crc32(0, Z_NULL, 0);
2047 #define gzfile_writer_new(gz) gzfile_new((gz),&deflate_funcs,gzfile_writer_end)
2048 #define gzfile_reader_new(gz) gzfile_new((gz),&inflate_funcs,gzfile_reader_end)
2054 gz->
crc = crc32(0, Z_NULL, 0);
2133 if (
NIL_P(str))
return 0;
2151 rb_raise(cGzError,
"unexpected end of file");
2163 n = *(src++) & 0xff;
2164 n |= (*(src++) & 0xff) << 8;
2168 static unsigned long
2172 n = *(src++) & 0xff;
2173 n |= (*(src++) & 0xff) << 8;
2174 n |= (*(src++) & 0xff) << 16;
2175 n |= (*(src++) & 0xffU) << 24;
2182 *(dst++) = n & 0xff;
2183 *(dst++) = (n >> 8) & 0xff;
2184 *(dst++) = (n >> 16) & 0xff;
2185 *dst = (n >> 24) & 0xff;
2209 if (!
NIL_P(input)) {
2222 unsigned char flags = 0, extraflags = 0;
2230 if (gz->
mtime == 0) {
2231 gz->
mtime = time(0);
2234 if (gz->
level == Z_BEST_SPEED) {
2237 else if (gz->
level == Z_BEST_COMPRESSION) {
2246 buf[8] = extraflags;
2276 const unsigned char *head;
2290 rb_raise(cGzError,
"unsupported compression method %d", head[2]);
2295 rb_raise(cGzError,
"multi-part gzip file is not supported");
2298 rb_raise(cGzError,
"encrypted gzip file is not supported");
2301 rb_raise(cGzError,
"unknown flags 0x%02x", flags);
2305 gz->
level = Z_BEST_SPEED;
2308 gz->
level = Z_BEST_COMPRESSION;
2311 gz->
level = Z_DEFAULT_COMPRESSION;
2320 rb_raise(cGzError,
"unexpected end of file");
2324 rb_raise(cGzError,
"unexpected end of file");
2330 rb_raise(cGzError,
"unexpected end of file");
2340 rb_raise(cGzError,
"unexpected end of file");
2357 unsigned long crc, length;
2371 if (gz->
crc != crc) {
2372 rb_raise(cCRCError,
"invalid compressed data -- crc error");
2375 rb_raise(cLengthError,
"invalid compressed data -- length error");
2389 ? Z_SYNC_FLUSH : Z_NO_FLUSH);
2403 rb_raise(cGzError,
"unexpected end of file");
2473 if (len < 0)
return Qnil;
2513 if (!
NIL_P(outbuf)) {
2561 const unsigned char *ss, *sp, *se;
2562 unsigned char *ds, *
dp, *de;
2570 ds = dp = (
unsigned char *)gz->
cbuf;
2688 rb_raise(cGzError,
"closed gzip stream");
2764 if (close_io_on_error) {
2951 rb_raise(cGzError,
"header is already written");
2977 rb_raise(cGzError,
"header is already written");
3001 rb_raise(cGzError,
"header is already written");
3232 if (!
NIL_P(opt)) argc--;
3235 rb_scan_args(argc, argv,
"12", &io, &level, &strategy);
3240 err = deflateInit2(&gz->
z.
stream, gz->
level, Z_DEFLATED,
3273 flush =
FIXNUMARG(v_flush, Z_SYNC_FLUSH);
3274 if (flush != Z_NO_FLUSH) {
3321 #define rb_gzwriter_addstr rb_io_addstr
3326 #define rb_gzwriter_printf rb_io_printf
3331 #define rb_gzwriter_print rb_io_print
3336 #define rb_gzwriter_puts rb_io_puts
3437 err = inflateInit2(&gz->
z.
stream, -MAX_WBITS);
3683 while (n++, *(p++) ==
'\n') {
3736 long rslen, n, limit = -1;
3751 else if (!
NIL_P(rs)) {
3821 if (!rspara)
rscheck(rsptr, rslen, rs);
3823 if (limit > 0 && filled >= limit) {
3826 res = memchr(p, rsptr[0], (filled - n + 1));
3829 if (limit > 0 && filled >= limit)
break;
3832 n += (
long)(res - p);
3834 if (rslen == 1 ||
memcmp(p, rsptr, rslen) == 0)
break;
4005 VALUE mZlib, cZStream, cDeflate, cInflate;
4007 VALUE cGzipFile, cGzipWriter, cGzipReader;
4102 INT2FIX(Z_DEFAULT_COMPRESSION));
4156 id_readpartial =
rb_intern(
"readpartial");
RUBY_EXTERN VALUE rb_cString
static VALUE rb_gzreader_ungetbyte(VALUE, VALUE)
#define RSTRING_LEN(string)
static long NUM2LONG(VALUE x)
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)
void rb_thread_schedule(void)
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)
static VALUE rb_gzfile_level(VALUE)
static void finalizer_warn(const char *)
static void zstream_mark(struct zstream *)
static VALUE rb_zstream_set_avail_out(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 *)
VALUE rb_big2ulong(VALUE x)
void rb_undef_alloc_func(VALUE)
#define Data_Get_Struct(obj, type, sval)
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)
#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 *))
#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)
static void do_deflate(struct zstream *, VALUE, int)
static VALUE gzfile_reader_get_unused(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 *)
static char * gzfile_read_raw_until_zero(struct gzfile *, long)
static VALUE rb_gzreader_getc(VALUE)
VALUE rb_ary_push(VALUE ary, VALUE item)
static VALUE rb_zstream_finished_p(VALUE)
static VALUE INT2NUM(int v)
VALUE rb_funcall(VALUE, ID, int,...)
Calls a method.
VALUE rb_protect(VALUE(*proc)(VALUE), VALUE data, int *state)
#define RSTRING_PTR(string)
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 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_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)
#define ZSTREAM_FLAG_IN_STREAM
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)
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)
void rb_exc_raise(VALUE mesg)
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 VALUE rb_gzfile_path(VALUE)
static long gzfile_fill(struct gzfile *gz, long len)
VALUE rb_class_new_instance(int, VALUE *, VALUE)
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
static VALUE cVersionError
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 void gzfile_free(struct gzfile *)
static VALUE gzfile_getc(struct gzfile *gz)
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)
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)
int(* run)(z_streamp, int)
static VALUE rb_zstream_reset(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)
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)
VALUE rb_str_resize(VALUE, long)
#define rb_zlib_crc32_combine
VALUE rb_str_subseq(VALUE, long, long)
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)
SSL_METHOD *(* func)(void)
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)
#define RB_GC_GUARD(object)
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)
VALUE rb_ivar_set(VALUE, ID, VALUE)
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)
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 *)
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 int rb_enc_dummy_p(rb_encoding *enc)
register unsigned int len
static VALUE zstream_shift_buffer(struct zstream *, long)
VALUE rb_call_super(int, const VALUE *)
#define RUBY_ZLIB_VERSION
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)
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)
#define Data_Make_Struct(klass, type, mark, free, sval)
int rb_respond_to(VALUE, ID)
static VALUE rb_gzwriter_write(VALUE, VALUE)
static unsigned int gzfile_get16(const unsigned char *)
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))
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 ULONG2NUM(unsigned long v)
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)
#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)
static void zstream_free(struct zstream *)
VALUE rb_uint2inum(VALUE n)
static VALUE rb_gzfile_orig_name(VALUE)
static void zstream_finalize(struct zstream *)
#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_s_allocate(VALUE)
static VALUE rb_gzfile_set_sync(VALUE, VALUE)
#define RETURN_ENUMERATOR(obj, argc, argv)
VALUE rb_ary_new2(long capa)
#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 char NUM2CHR(VALUE x)
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)
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 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)
VALUE rb_str_new2(const char *)
static VALUE rb_gzfile_s_wrap(int, VALUE *, VALUE)
VALUE rb_str_to_str(VALUE)
static VALUE deflate_run(VALUE)
static VALUE rb_deflate_set_dictionary(VALUE, VALUE)
#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)