Loading...
Searching...
No Matches
Osmocom ringbuffers for log strings

## 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.

## Functions

struct osmo_strrb * | osmo_strrb_create (TALLOC_CTX *ctx, size_t rb_size)
| Create an empty, initialized osmo_strrb.
bool | osmo_strrb_is_empty (const struct osmo_strrb *rb)
| Check if an osmo_strrb is empty.
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.
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.
int | osmo_strrb_add (struct osmo_strrb *rb, const char *data)
| Add a string to the osmo_strrb.

## Detailed Description

## Macro Definition Documentation

## RB_MAX_MESSAGE_SIZE

#define RB_MAX_MESSAGE_SIZE 240

A structure representing an osmocom string ringbuffer.

## Function Documentation

## _osmo_strrb_is_bufindex_valid()

bool _osmo_strrb_is_bufindex_valid | ( | const struct osmo_strrb * | rb,
|  | unsigned int | offset
| ) |  |

References end, osmo_strrb_is_empty(), size, start, and subsys.

Referenced by osmo_strrb_get_nth().

## osmo_strrb_add()

int osmo_strrb_add | ( | struct osmo_strrb * | rb,
|  | const char * | data
| ) |  |

Add a string to the osmo_strrb.

Parameters

  [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.

Returns
  0 normally, 1 as a warning (ie, if data was truncated).

References buffer, data, end, len, RB_MAX_MESSAGE_SIZE, size, start, and subsys.

Referenced by _rb_output().

## osmo_strrb_create()

struct osmo_strrb * osmo_strrb_create | ( | TALLOC_CTX * | ctx,
|  | size_t | rb_size
| ) |  |

Create an empty, initialized osmo_strrb.

Parameters

  [in] | ctx | The talloc memory context which should own this.
  [in] | rb_size | The number of message slots the osmo_strrb can hold.

Returns
  A struct osmo_strrb* on success, NULL in case of error.

This function creates and initializes a ringbuffer. Note that the ringbuffer stores at most rb_size - 1 messages.

References buffer, RB_MAX_MESSAGE_SIZE, size, and subsys.

Referenced by log_target_create_rb().

## osmo_strrb_elements()

size_t osmo_strrb_elements | ( | const struct osmo_strrb * | rb | ) |

Count the number of log messages in an osmo_strrb.

Parameters

  [in] | rb | The osmo_strrb to count the elements of.

Returns
  The number of log messages in the osmo_strrb.

References end, size, and start.

Referenced by log_target_rb_used_size().

## osmo_strrb_get_nth()

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.

Parameters

  [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.

Returns
  A pointer to the target string on success, NULL in case of error.

References _osmo_strrb_is_bufindex_valid(), buffer, end, size, start, and subsys.

Referenced by log_target_rb_get().

## osmo_strrb_is_empty()

bool osmo_strrb_is_empty | ( | const struct osmo_strrb * | rb | ) |

Check if an osmo_strrb is empty.

Parameters

  [in] | rb | The osmo_strrb to check.

Returns
  True if the osmo_strrb is empty, false otherwise.

References end, and start.

Referenced by _osmo_strrb_is_bufindex_valid().