/** * call-seq: * Rev::Buffer#read_from(io) -> Integer * * Perform a nonblocking read of the the given IO object and fill * the buffer with any data received. The call will read as much * data as it can until the read would block. */ static VALUE Rev_Buffer_read_from(VALUE self, VALUE io) { struct buffer *buf; #if HAVE_RB_IO_T rb_io_t *fptr; #else OpenFile *fptr; #endif Data_Get_Struct(self, struct buffer, buf); GetOpenFile(rb_convert_type(io, T_FILE, "IO", "to_io"), fptr); rb_io_set_nonblock(fptr); return INT2NUM(buffer_read_from(buf, FPTR_TO_FD(fptr))); }
/* read from handler->fd, fill rbuf with contents */ int handle_read_to_rbuf(struct ludis_handle *h) { return buffer_read_from(h->rb, h->fd); }