% limb manual
% allreadwrite(3)
% limb 0.1.0
% 2023-07-24
# NAME
allreadwrite, allreadwritev - perform specified I/O operation until fully
completed
# SYNOPSIS
#include <limb/allreadwrite.h>
```pre hl
ssize_t (*io_func) (int <em>fd</em>, char *<em>data</em>, size_t <em>dlen</em>)
ssize_t (*iov_func) (int <em>fd</em>, const struct iovec *<em>v</em>, unsigned <em>n</em>)
size_t allreadwrite(io_func <em>op</em>, int <em>fd</em>, char *<em>data</em>, size_t <em>dlen</em>)
size_t allreadwritev(iov_func <em>op</em>, int <em>fd</em>, const struct iovec *<em>v</em>, unsigned <em>n</em>)
```
# 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).
! HINT:
! 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.