libosmocore 1.10.0.57-8972
Osmocom core library
|
Files | |
file | strrb.h |
Osmocom string ringbuffer handling routines. | |
Data Structures | |
struct | osmo_strrb |
Macros | |
#define | RB_MAX_MESSAGE_SIZE 240 |
A structure representing an osmocom string ringbuffer. More... | |
Functions | |
struct osmo_strrb * | osmo_strrb_create (void *talloc_ctx, size_t rb_size) |
Create an empty, initialized osmo_strrb. More... | |
bool | osmo_strrb_is_empty (const struct osmo_strrb *rb) |
Check if an osmo_strrb is empty. More... | |
const char * | osmo_strrb_get_nth (const struct osmo_strrb *rb, unsigned int string_index) |
Return a pointer to the Nth string in the osmo_strrb. More... | |
bool | _osmo_strrb_is_bufindex_valid (const struct osmo_strrb *rb, unsigned int offset) |
size_t | osmo_strrb_elements (const struct osmo_strrb *rb) |
Count the number of log messages in an osmo_strrb. More... | |
int | osmo_strrb_add (struct osmo_strrb *rb, const char *data) |
Add a string to the osmo_strrb. More... | |
#define RB_MAX_MESSAGE_SIZE 240 |
A structure representing an osmocom string ringbuffer.
bool _osmo_strrb_is_bufindex_valid | ( | const struct osmo_strrb * | rb, |
unsigned int | offset | ||
) |
References end, osmo_strrb_is_empty(), size, and start.
Referenced by osmo_strrb_get_nth().
int osmo_strrb_add | ( | struct osmo_strrb * | rb, |
const char * | data | ||
) |
Add a string to the osmo_strrb.
[in] | rb | The osmo_strrb to add to. |
[in] | data | The string to add. |
Add a message to the osmo_strrb. Older messages will be overwritten as necessary.
References buffer, data, end, len(), RB_MAX_MESSAGE_SIZE, size, and start.
Referenced by _rb_output().
struct osmo_strrb * osmo_strrb_create | ( | void * | talloc_ctx, |
size_t | rb_size | ||
) |
Create an empty, initialized osmo_strrb.
[in] | ctx | The talloc memory context which should own this. |
[in] | rb_size | The number of message slots the osmo_strrb can hold. |
This function creates and initializes a ringbuffer. Note that the ringbuffer stores at most rb_size - 1 messages.
References buffer, RB_MAX_MESSAGE_SIZE, and size.
Referenced by log_target_create_rb().
size_t osmo_strrb_elements | ( | const struct osmo_strrb * | rb | ) |
Count the number of log messages in an osmo_strrb.
[in] | rb | The osmo_strrb to count the elements of. |
References end, size, and start.
Referenced by log_target_rb_used_size().
const char * osmo_strrb_get_nth | ( | const struct osmo_strrb * | rb, |
unsigned int | string_index | ||
) |
Return a pointer to the Nth string in the osmo_strrb.
[in] | rb | The osmo_strrb to search. |
[in] | string_index | The index sought (N), zero-indexed. |
Return a pointer to the Nth string in the osmo_strrb. Return NULL if there is no Nth string. Note that N is zero-indexed.
References _osmo_strrb_is_bufindex_valid(), buffer, end, size, and start.
Referenced by log_target_rb_get().
bool osmo_strrb_is_empty | ( | const struct osmo_strrb * | rb | ) |
Check if an osmo_strrb is empty.
[in] | rb | The osmo_strrb to check. |
Referenced by _osmo_strrb_is_bufindex_valid().