NAME
patrim_put, patrim_get, patrim_isblob, patrim_isint, patrim_isshldata - encode/decode data in PATRIM format
SYNOPSIS
#include <limb/patrim.h>
int patrim_put(char *dst, size_t dlen, size_t offset, u64 id, u64 u) int patrim_get(u64 *id, u64 *u, const char *data, size_t dlen, size_t offset) int patrim_isblob(u64 id) int patrim_isint(u64 id) int patrim_isshldata(u64 id)
DESCRIPTION
The patrim_put
() function will encode into the memory pointed by dst
of
length dlen
, starting at byte offset
, the data for the given id
and its
associated value or length, u
.
So u
must be either the value if id
represents an integer, or the length of
the blob if id
represents a blob. The actual data/blob content should
obviously be added afterwards.
The patrim_get
() function will read the memory pointed by data
, starting at
byte offset
and not going past dlen
bytes, decoding PATRIM-encoded data and
placing the ID in the memory pointed by id
and either the value of data
length, depending whether the ID of that of an integer or a blob respectively,
into the memory pointed by u
.
The patrim_isblob
() macro returns 1 if the id
if that of a blob, zero
otherwise.
The patrim_isint
() macro returns 1 if the id
if that of an integer, zero
otherwise.
The patrim_isshldata
() macro returns 1 if the id
is one that belongs to the
"shielded data" protocol - as described in shldata(5). Note that this only
applies when e.g. reading a shielded data file.
RETURN VALUE
On success the patrim_put
() and patrim_get
() functions return the number of
bytes written into dst
or read from data
, respectively. Otherwise - meaning
not enough bytes could be written or read - they return -1.
The patrim_isblob
() and patrim_isint
() macros return 1 id id
represents a
blob or an integer, respectively, otherwise they return 0.
The patrim_isshldata
() macro returns 1 if id
belongs to the shielded data
protocol, 0 otherwise. Note that this is only applicable when e.g. reading a
shielded data file.