/**
 * Document-method: MessagePack::Unpacker#fill
 *
 * call-seq:
 *   unpacker.fill -> length of read data
 *
 * Fills the internal buffer using the input stream.
 *
 * If the input stream is not specified, it returns nil.
 * You can set it on *initialize* or *stream=* methods.
 *
 * This methods raises exceptions that _stream.sysread_ or
 * _stream.readpartial_ method raises.
 */
static VALUE MessagePack_Unpacker_fill(VALUE self)
{
        UNPACKER(self, mp);

        if(mp->user.stream == Qnil) {
                return Qnil;
        }

        rb_funcall(mp->user.stream, mp->user.stream_append_method, 2,
                        LONG2FIX(MSGPACK_UNPACKER_BUFFER_RESERVE_SIZE),
                        mp->user.streambuf);

        size_t len = RSTRING_LEN(mp->user.streambuf);
        feed_buffer(mp, RSTRING_PTR(mp->user.streambuf), len);

        return LONG2FIX(len);
}