NAME
buffer_patrim_put, buffer_patrim_putv, buffer_patrim_get - write/read data in PATRIM format
SYNOPSIS
#include <limb/buffer.h>
ssize_t buffer_patrim_put(buffer *buf, u64 id, u64 u, const char *data) ssize_t buffer_patrim_putv(buffer *buf, u64 id, const struct iovec v[], unsigned int n) int buffer_patrim_get(buffer *buf, u64 *id, u64 *u)
DESCRIPTION
The buffer_patrim_put
() function writes into the buffer buf
the data for the
given id
and its associated value or length, u
, encoded in patrim(5)
format.
So u
must be either the value for an integer, or the length of the byte array
pointed by data
for a blob.
The buffer_patrim_putv
() function is similar, but only works for id
representing a blob, whose data must be pointed by the array v
of length n
.
The buffer_patrim_get
() function reads patrim(5)-encoded data from the
buffer buf
, placing the ID in the value pointed by id
and its associated
value or length, depending whether the ID represents an integer or a blob, in
the value pointed by u
.
In case of a blob, the actual content is not read, it is up to the caller to
get as many bytes from buf
as the value placed into u
.
RETURN VALUE
The buffer_patrim_put
() and buffer_patrim_putv
() functions return the number
of bytes written on success. Otherwise they return -1 and set errno
to
indicate the error.
The buffer_patrim_get
() function returns 1 on success, 0 on failure.
ERRORS
The buffer_patrim_put
() and buffer_patrim_putv
() functions may fail and set
errno
for any of the errors specified for buffer_putv(3).
The buffer_patrim_get
() function may fail if :
EPIPE
Not enough data could be read from the buffer before reaching end-of-file.
It may also fail for any of the error specified for buffer_fill(3).