/*
* call-seq: inflate(string)
*
* Inputs +string+ into the inflate stream and returns the output from the
* stream. Calling this method, both the input and the output buffer of the
* stream are flushed. If string is +nil+, this method finishes the stream,
* just like Zlib::ZStream#finish.
*
* Raises a Zlib::NeedDict exception if a preset dictionary is needed to
* decompress. Set the dictionary by Zlib::Inflate#set_dictionary and then
* call this method again with an empty string. (<i>???</i>)
*
* TODO: document better!
*/
static VALUE
rb_inflate_inflate(obj, src)
VALUE obj, src;
{
struct zstream *z = get_zstream(obj);
VALUE dst;
OBJ_INFECT(obj, src);
if (ZSTREAM_IS_FINISHED(z)) {
if (NIL_P(src)) {
dst = zstream_detach_buffer(z);
}
else {
StringValue(src);
zstream_append_buffer2(z, src);
dst = rb_str_new(0, 0);
}
}
else {
do_inflate(z, src);
dst = zstream_detach_buffer(z);
if (ZSTREAM_IS_FINISHED(z)) {
zstream_passthrough_input(z);
}
}
OBJ_INFECT(dst, obj);
return dst;
}