Libtrap: Internal development docs
0.11.7
|
Macros | |
#define | TB_FILL_START(rdb, bl, res) |
#define | TB_FILL_END(rdb, bl, s) |
Functions | |
int | tb_getmess (trap_buffer_t *tb, const void **data, uint16_t *size) |
void | tb_first_rd_block (trap_buffer_t *tb) |
void | tb_next_rd_block (trap_buffer_t *tb) |
A set of functions used for input IFC (module receives messages).
#define TB_FILL_END | ( | rdb, | |
bl, | |||
s | |||
) |
Unlock the current free block after writing its content.
It MUST NOT be called when TB_FILL_START() returned TB_FULL.
[in] | rdb | Pointer to the buffer. |
[in] | bl | Pointer to block (tb_block_t *bl). |
[in] | s | Size of data written into the block. This will be set into header. |
Definition at line 386 of file trap_buffer.h.
#define TB_FILL_START | ( | rdb, | |
bl, | |||
res | |||
) |
Lock the current free block for writing its content.
After this code, it is possible to write size and data into bl. See TB_FILL_END() for unlocking the block.
Pseudocode: trap_buffer_t *b = tb_init(10, 100000); tb_block_t *bl; TB_FILL_START(b, &bl, res); if (res == TB_SUCCESS) { s = recv(...); TB_FILL_END(b, bl, s); }
[in] | rdb | Pointer to the buffer. |
[out] | bl | Pointer to block (tb_block_t **bl). |
[out] | res | Result of TB_FILL_START(), it is set to TB_SUCCESS or TB_FULL. |
Definition at line 362 of file trap_buffer.h.
void tb_first_rd_block | ( | trap_buffer_t * | tb | ) |
Move to the first block for reading.
This function moves cur_block pointer to the first block.
[in] | tb | Pointer to the buffer. |
Definition at line 123 of file trap_buffer.c.
int tb_getmess | ( | trap_buffer_t * | tb, |
const void ** | data, | ||
uint16_t * | size | ||
) |
Get message from buffer.
[in] | tb | Pointer to the buffer. |
[out] | data | Pointer to read message. |
[out] | size | Size of read message. |
Definition at line 323 of file trap_buffer.c.
void tb_next_rd_block | ( | trap_buffer_t * | tb | ) |
Move to the next block for reading.
This function moves cur_block pointer to the next block (it overflows after nblocks).
[in] | tb | Pointer to the buffer. |
Definition at line 113 of file trap_buffer.c.