NAME
allreadwrite, allreadwritev - perform specified I/O operation until fully completed
SYNOPSIS
#include <limb/allreadwrite.h>
ssize_t (*io_func) (int fd, char *data, size_t dlen) ssize_t (*iov_func) (int fd, const struct iovec *v, unsigned n) size_t allreadwrite(io_func op, int fd, char *data, size_t dlen) size_t allreadwritev(iov_func op, int fd, const struct iovec *v, unsigned n)
DESCRIPTION
The allreadwrite
() function will call op
with fd
, data
and dlen
as
arguments, expecting it to perform the requested I/O operation, returning the
amount of bytes read/written on success, or -1 on error (setting errno
to
indicate the error).
If less than dlen
bytes have been processed, it will call op
again (updating
its arguments data
and dlen
appropriately), until either dlen
bytes have
been processed in total, end-of-file has been reached, or an error occurred.
The allreadwritev
() function is similar, except that the arguments given to
op
are fd
and the pointer to an internal array of struct iovec and its
number of elements, originally similar to v
and n
but later adjusted as
needed. The original array v
remains unchanged.
RETURN VALUE
These functions return the number of bytes processed, which may be less than
dlen
(even 0).
To know whether an error occurred or not, you might want to set errno
to 0
prior to the call, and checking afterwards if it was set or not by the op
function.