NAME
buffer_init, buffer_read, buffer_write - initialize an I/O buffer
SYNOPSIS
#include <limb/buffer.h>
int buffer_init(buffer *buf, iov_func *opfn, int fd, char *mem, size_t len) ssize_t buffer_read(int fd, struct iovec *v, unsigned int n) ssize_t buffer_write(int fd, struct iovec *v, unsigned int n)
DESCRIPTION
The buffer_init
() function initializes the buffer pointed by buf
, to use the
function opfn
as its operational function with the file descriptor fd
. It
will use the memory pointed by mem
of length len
as its internal buffer.
The buffer_read
() macro is a function that can be used to initialize a reading
buffer, that is a buffer used to read from its associated file descriptor.
The buffer_write
() macro is a function that can be used to initialize a
writing buffer, that is a buffer used to write to its associated file
descriptor.
RETURN VALUE
The buffer_init
() function returns 1 on success. Otherwise it returns 0 and
set errno
to indicate the error.
The buffer_read
() and buffer_write
() functions return the amount of data
read or written, respectively, from the file descriptor fd
, using the memory
as described by the vectors v
of length n
, on success. Otherwise they return
-1 and set errno
to indicate the error.
ERRORS
The buffer_init
() function may fail if :
EINVAL
The length of memory len
is too small.
The buffer_read
() and buffer_write
() function may fail for any of the errors
described for fd_readv(3) and fd_writev(3) respectively.