libosmocore  1.10.0.2-2e788.202408152026
Osmocom core library
strrb.h
Go to the documentation of this file.
1 
3 /*
4  * (C) 2012-2013 by Katerina Barone-Adesi <kat.obsc@gmail.com>
5  * All Rights Reserved
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  */
18 
19 #pragma once
20 
25 #include <unistd.h>
26 #include <stdbool.h>
27 #include <stdint.h>
28 
31 #define RB_MAX_MESSAGE_SIZE 240
32 struct osmo_strrb {
33  uint16_t start;
34  uint16_t end;
35  uint16_t size;
36  char **buffer;
37 };
38 
39 struct osmo_strrb *osmo_strrb_create(void *talloc_ctx, size_t rb_size);
40 bool osmo_strrb_is_empty(const struct osmo_strrb *rb);
41 const char *osmo_strrb_get_nth(const struct osmo_strrb *rb,
42  unsigned int string_index);
43 bool _osmo_strrb_is_bufindex_valid(const struct osmo_strrb *rb,
44  unsigned int offset);
45 size_t osmo_strrb_elements(const struct osmo_strrb *rb);
46 int osmo_strrb_add(struct osmo_strrb *rb, const char *data);
47 
uint8_t data[0]
int osmo_strrb_add(struct osmo_strrb *rb, const char *data)
Add a string to the osmo_strrb.
Definition: strrb.c:148
bool _osmo_strrb_is_bufindex_valid(const struct osmo_strrb *rb, unsigned int offset)
Definition: strrb.c:115
bool osmo_strrb_is_empty(const struct osmo_strrb *rb)
Check if an osmo_strrb is empty.
Definition: strrb.c:88
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.
Definition: strrb.c:102
size_t osmo_strrb_elements(const struct osmo_strrb *rb)
Count the number of log messages in an osmo_strrb.
Definition: strrb.c:132
struct osmo_strrb * osmo_strrb_create(void *talloc_ctx, size_t rb_size)
Create an empty, initialized osmo_strrb.
Definition: strrb.c:55
Definition: strrb.h:32
uint16_t size
max number of messages to store
Definition: strrb.h:35
uint16_t end
index of the last slot
Definition: strrb.h:34
char ** buffer
storage for messages
Definition: strrb.h:36
uint16_t start
index of the first slot
Definition: strrb.h:33