JackUtils 0.5
Provides simplified Jack API for clients :)
|
Data Structures | |
struct | ju_buff_s |
FIFO Buffer internal structure. More... | |
Typedefs | |
typedef struct ju_buff_s | ju_buff_t |
typedef wrapper around buffer structure | |
Functions | |
JBU_API void() | ju_buff_init (ju_buff_t *b, size_t s) |
Initializes buffer structure. More... | |
JBU_API void() | ju_buff_uninit (ju_buff_t *b) |
Deinitializes buffer structure. More... | |
JBU_API void() | ju_buff_resize (ju_buff_t *b, size_t s) |
Resizes buffer structure. More... | |
JBU_API void() | ju_buff_check_size (ju_buff_t *b, size_t s) |
Check size of buffer with requested, and resizes if there is not enough spce. More... | |
JBU_API void | ju_buff_except (ju_buff_t *b, int(*cb)(ju_buff_t *, ju_ssize_t)) |
Underflow/owerflow exception handling. More... | |
JBU_API size_t() | ju_buff_size (ju_buff_t *b) |
Returns buffer summary size (used and unused). More... | |
JBU_API size_t() | ju_buff_used (ju_buff_t *b) |
Returns size of buffer busy part. More... | |
JBU_API size_t() | ju_buff_space (ju_buff_t *b) |
Returns size of buffer empity part. More... | |
JBU_API size_t() | ju_buff_append (ju_buff_t *b, const void *src, size_t size) |
Adds data from array to te end of the buffer. More... | |
JBU_API size_t() | ju_buff_fill (ju_buff_t *b, const void *src, size_t size, size_t n) |
Adds data from src array copied N times to the end of the buffer. More... | |
JBU_API size_t() | ju_buff_remove (ju_buff_t *, void *dst, size_t size) |
Removes data from start of buffer to the dst array. More... | |
JBU_API void() | ju_buff_move (ju_buff_t *, ju_ssize_t v) |
Moves buffer data forwards or backwards... More... | |
JBU_API size_t() | ju_buff_read (ju_buff_t *, int fd, size_t) |
Similar to ju_buff_append(), but reads values from the file by descriptor. | |
JBU_API size_t() | ju_buff_write (ju_buff_t *, int fd, size_t) |
Similar to ju_buff_remove(), but writes values to the the file by descriptor. | |
JBU_API void *() | ju_buff_data (ju_buff_t *b) |
Returns buffer data from the beginning. More... | |
JBU_API void() | ju_buff_lock (ju_buff_t *b) |
Locks buffer. More... | |
JBU_API void() | ju_buff_unlock (ju_buff_t *b) |
Unlocks buffer. More... | |
JBU_API size_t() ju_buff_append | ( | ju_buff_t * | b, |
const void * | src, | ||
size_t | size | ||
) |
Adds data from array to te end of the buffer.
b | buffer. |
src | source array of bytes. |
size | size of the source array. |
References ju_buff_space().
JBU_API void() ju_buff_check_size | ( | ju_buff_t * | b, |
size_t | s | ||
) |
Check size of buffer with requested, and resizes if there is not enough spce.
b | pointer on buffer structure. |
s | requested size of the buffer. |
JBU_API void *() ju_buff_data | ( | ju_buff_t * | b | ) |
Returns buffer data from the beginning.
b | buffer |
JBU_API void ju_buff_except | ( | ju_buff_t * | b, |
int(*)(ju_buff_t *, ju_ssize_t) | cb | ||
) |
Underflow/owerflow exception handling.
Sets cb callback to be runned when exeption happens with buffer underflow(-) or owerflow(+) value. Callback may MOVE buffer data backward to give space for new data in case of owerflow(default), or do nothing. In case of underflow, callback may add zeros to buffer, or do nothing(default).
Or even callback may print error message, and do some stuff of course :) Callback underflow/overflow value will NEVER BE MORE THAN SIZE OF BUFFER!
if you did something, it's a good sign to return 0, else return nonzero value from callback;
b | buffer |
cb | new exception handler callback |
JBU_API size_t() ju_buff_fill | ( | ju_buff_t * | b, |
const void * | src, | ||
size_t | size, | ||
size_t | n | ||
) |
Adds data from src array copied N times to the end of the buffer.
b | buffer. |
src | source array of bytes. |
size | size of the source array. |
n | how much array duplicates? |
References ju_buff_space().
JBU_API void() ju_buff_init | ( | ju_buff_t * | b, |
size_t | s | ||
) |
Initializes buffer structure.
b | pointer on buffer structure. |
s | size of the buffer. |
JBU_API void() ju_buff_lock | ( | ju_buff_t * | b | ) |
Locks buffer.
b | buffer |
If buffer is already locked, this function waits until it unlocks, lock it again and returns. This operation is atomary and threadsafe.
Don't forget to unlock buffer when you're done reading/writing and other buffer operations. Locking already locked buffer in the same thread causes to the DEADLOCK.
JBU_API void() ju_buff_move | ( | ju_buff_t * | b, |
ju_ssize_t | v | ||
) |
Moves buffer data forwards or backwards...
b | buffer. |
v | move steps with sign (+ forward) (-backward) |
JBU_API size_t() ju_buff_remove | ( | ju_buff_t * | b, |
void * | dst, | ||
size_t | size | ||
) |
Removes data from start of buffer to the dst array.
b | buffer. |
dst | destination array of bytes. |
size | how many elements to put into the array. |
References ju_buff_move().
JBU_API void() ju_buff_resize | ( | ju_buff_t * | b, |
size_t | s | ||
) |
Resizes buffer structure.
Buffer must be initialized before!
b | pointer on buffer structure. |
s | size of the buffer. |
JBU_API size_t() ju_buff_size | ( | ju_buff_t * | b | ) |
Returns buffer summary size (used and unused).
b | buffer |
JBU_API size_t() ju_buff_space | ( | ju_buff_t * | b | ) |
Returns size of buffer empity part.
b | buffer |
JBU_API void() ju_buff_uninit | ( | ju_buff_t * | b | ) |
Deinitializes buffer structure.
b | pointer on buffer structure. |
JBU_API void() ju_buff_unlock | ( | ju_buff_t * | b | ) |
Unlocks buffer.
b | buffer |
JBU_API size_t() ju_buff_used | ( | ju_buff_t * | b | ) |
Returns size of buffer busy part.
b | buffer |