fres_container_get_block(struct fres_container *container,
enum fres_block_type type);
+/**
+ * Macro which defines type-safe container "accessor" functions for
+ * various blocks.
+ *
+ * This macro declares the following inline functions:
+ * - fres_container_add_<type>
+ * - fres_container_get_<type>
+ * - fres_container_del_<type>
+ *
+ * These functions are equivalent to fres_container_add_block(),
+ * fres_container_del_block() and fres_container_get_block() with
+ * appropriate parameters.
+ */
#define FRES_CONTAINER_ACCESSOR(TYPE, type) \
static inline int \
fres_container_add_##type(struct fres_container *container, \
void fres_contract_destroy(struct fres_contract *contract);
struct fres_contract *fres_contract_duplicate(struct fres_contract *src);
+/**
+ * Adds a block of the given type to the contract.
+ *
+ * This function uses fres_container_add_block() to do its job.
+ *
+ * @param contract Where to add the @a block.
+ * @param type Type of contract being added.
+ * @param block Pointer to the malloced block of given @a type.
+ *
+ * @return Zero on success, -1 on error and errno is set appropriately.
+ */
static inline int
fres_contract_add_block(struct fres_contract *contract,
enum fres_block_type type, void *block)
{
return fres_container_add_block(contract->container, type, block);
}
+/**
+ * Deletes a block from the contract and frees it from memory.
+ *
+ * This function uses fres_container_del_block() to do its job.
+ *
+ * @param contract Where to delete the block.
+ * @param type Type of contract to delete.
+ */
static inline void
fres_contract_del_block(struct fres_contract *contract,
enum fres_block_type type)
fres_container_del_block(contract->container, type);
}
+/**
+ * Returns pointer to a contract block of a particular @a type.
+ *
+ * This function uses fres_container_get_block() to do its job.
+ *
+ * @param contract
+ * @param type Type of the block to be returned.
+ *
+ * @return Pointer to the block or NULL if the block is not present or
+ * deserialized. The memory area pointed by this pointer is owned by
+ * the contract. If the user needs to store the block, it must be
+ * duplicated.
+ */
static inline void *
fres_contract_get_block(struct fres_contract *contract,
enum fres_block_type type)
void
fres_contract_print(char *prefix, const struct fres_contract *c);
+/**
+ * Macro which defines type-safe contract "accessor" functions for
+ * various blocks.
+ *
+ * This macro declares the following inline functions:
+ * - fres_contract_add_<type>
+ * - fres_contract_get_<type>
+ * - fres_contract_del_<type>
+ *
+ * The defined functions simply use the container "accessor" functions
+ * (usually defined) by #FRES_CONTAINER_ACCESSOR and are equivalent to
+ * fres_contract_add_block(), fres_contract_del_block() and
+ * fres_contract_get_block() with appropriate parameters.
+ */
#define FRES_CONTRACT_ACCESSOR(type) \
static inline int \
fres_contract_add_##type(struct fres_contract *contract, \