limb 0.2.0

2024-01-09

buffer_init(3)
limb manual
buffer_init(3)

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.

limb 0.1.0
2023-07-24
buffer_init(3)