\doxysection{Osmocom ringbuffers for log strings}
\label{group__osmo__strrb}\index{Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}}
\doxysubsection*{Files}
\begin{DoxyCompactItemize}
\item 
file \textbf{ strrb.\+h}
\begin{DoxyCompactList}\small\item\em Osmocom string ringbuffer handling routines. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+strrb}
\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ RB\+\_\+\+MAX\+\_\+\+MESSAGE\+\_\+\+SIZE}~240
\begin{DoxyCompactList}\small\item\em A structure representing an osmocom string ringbuffer. \end{DoxyCompactList}\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ osmo\+\_\+strrb} $\ast$ \textbf{ osmo\+\_\+strrb\+\_\+create} (void $\ast$talloc\+\_\+ctx, size\+\_\+t rb\+\_\+size)
\begin{DoxyCompactList}\small\item\em Create an empty, initialized \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb}. \end{DoxyCompactList}\item 
bool \textbf{ osmo\+\_\+strrb\+\_\+is\+\_\+empty} (const struct \textbf{ osmo\+\_\+strrb} $\ast$rb)
\begin{DoxyCompactList}\small\item\em Check if an \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb} is empty. \end{DoxyCompactList}\item 
const char $\ast$ \textbf{ osmo\+\_\+strrb\+\_\+get\+\_\+nth} (const struct \textbf{ osmo\+\_\+strrb} $\ast$rb, unsigned int string\+\_\+index)
\begin{DoxyCompactList}\small\item\em Return a pointer to the Nth string in the \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb}. \end{DoxyCompactList}\item 
bool \textbf{ \+\_\+osmo\+\_\+strrb\+\_\+is\+\_\+bufindex\+\_\+valid} (const struct \textbf{ osmo\+\_\+strrb} $\ast$rb, unsigned int offset)
\item 
size\+\_\+t \textbf{ osmo\+\_\+strrb\+\_\+elements} (const struct \textbf{ osmo\+\_\+strrb} $\ast$rb)
\begin{DoxyCompactList}\small\item\em Count the number of log messages in an \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb}. \end{DoxyCompactList}\item 
int \textbf{ osmo\+\_\+strrb\+\_\+add} (struct \textbf{ osmo\+\_\+strrb} $\ast$rb, const char $\ast$\textbf{ data})
\begin{DoxyCompactList}\small\item\em Add a string to the \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb}. \end{DoxyCompactList}\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}


\doxysubsection{Macro Definition Documentation}
\mbox{\label{group__osmo__strrb_gae7ea3048b7595e37ccb8f1039d98c5b1}} 
\index{Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}!RB\_MAX\_MESSAGE\_SIZE@{RB\_MAX\_MESSAGE\_SIZE}}
\index{RB\_MAX\_MESSAGE\_SIZE@{RB\_MAX\_MESSAGE\_SIZE}!Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}}
\doxysubsubsection{RB\_MAX\_MESSAGE\_SIZE}
{\footnotesize\ttfamily \#define RB\+\_\+\+MAX\+\_\+\+MESSAGE\+\_\+\+SIZE~240}



A structure representing an osmocom string ringbuffer. 



\doxysubsection{Function Documentation}
\mbox{\label{group__osmo__strrb_gaa84efdd0a46d6212b416957432cf87a7}} 
\index{Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}!\_osmo\_strrb\_is\_bufindex\_valid@{\_osmo\_strrb\_is\_bufindex\_valid}}
\index{\_osmo\_strrb\_is\_bufindex\_valid@{\_osmo\_strrb\_is\_bufindex\_valid}!Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}}
\doxysubsubsection{\_osmo\_strrb\_is\_bufindex\_valid()}
{\footnotesize\ttfamily bool \+\_\+osmo\+\_\+strrb\+\_\+is\+\_\+bufindex\+\_\+valid (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+strrb} $\ast$}]{rb,  }\item[{unsigned int}]{offset }\end{DoxyParamCaption})}



References \textbf{ end}, \textbf{ osmo\+\_\+strrb\+\_\+is\+\_\+empty()}, \textbf{ size}, and \textbf{ start}.



Referenced by \textbf{ osmo\+\_\+strrb\+\_\+get\+\_\+nth()}.

\mbox{\label{group__osmo__strrb_ga3d8e138301a2fc21779b7259831a677c}} 
\index{Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}!osmo\_strrb\_add@{osmo\_strrb\_add}}
\index{osmo\_strrb\_add@{osmo\_strrb\_add}!Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}}
\doxysubsubsection{osmo\_strrb\_add()}
{\footnotesize\ttfamily int osmo\+\_\+strrb\+\_\+add (\begin{DoxyParamCaption}\item[{struct \textbf{ osmo\+\_\+strrb} $\ast$}]{rb,  }\item[{const char $\ast$}]{data }\end{DoxyParamCaption})}



Add a string to the \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em rb} & The \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb} to add to. \\
\hline
\mbox{\texttt{ in}}  & {\em data} & The string to add.\\
\hline
\end{DoxyParams}
Add a message to the \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb}. Older messages will be overwritten as necessary. \begin{DoxyReturn}{Returns}
0 normally, 1 as a warning (ie, if data was truncated). 
\end{DoxyReturn}


References \textbf{ buffer}, \textbf{ data}, \textbf{ end}, \textbf{ len()}, \textbf{ RB\+\_\+\+MAX\+\_\+\+MESSAGE\+\_\+\+SIZE}, \textbf{ size}, and \textbf{ start}.



Referenced by \textbf{ \+\_\+rb\+\_\+output()}.

\mbox{\label{group__osmo__strrb_gaaab7bfea64d0b1b7e86dbd717d253a30}} 
\index{Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}!osmo\_strrb\_create@{osmo\_strrb\_create}}
\index{osmo\_strrb\_create@{osmo\_strrb\_create}!Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}}
\doxysubsubsection{osmo\_strrb\_create()}
{\footnotesize\ttfamily struct \textbf{ osmo\+\_\+strrb} $\ast$ osmo\+\_\+strrb\+\_\+create (\begin{DoxyParamCaption}\item[{void $\ast$}]{talloc\+\_\+ctx,  }\item[{size\+\_\+t}]{rb\+\_\+size }\end{DoxyParamCaption})}



Create an empty, initialized \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em ctx} & The talloc memory context which should own this. \\
\hline
\mbox{\texttt{ in}}  & {\em rb\+\_\+size} & The number of message slots the \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb} can hold. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
A struct osmo\+\_\+strrb$\ast$ on success, NULL in case of error.
\end{DoxyReturn}
This function creates and initializes a ringbuffer. Note that the ringbuffer stores at most rb\+\_\+size -\/ 1 messages. 

References \textbf{ buffer}, \textbf{ RB\+\_\+\+MAX\+\_\+\+MESSAGE\+\_\+\+SIZE}, and \textbf{ size}.



Referenced by \textbf{ log\+\_\+target\+\_\+create\+\_\+rb()}.

\mbox{\label{group__osmo__strrb_gac730d01ff38c9eb9e9f10ce1f12cf3f0}} 
\index{Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}!osmo\_strrb\_elements@{osmo\_strrb\_elements}}
\index{osmo\_strrb\_elements@{osmo\_strrb\_elements}!Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}}
\doxysubsubsection{osmo\_strrb\_elements()}
{\footnotesize\ttfamily size\+\_\+t osmo\+\_\+strrb\+\_\+elements (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+strrb} $\ast$}]{rb }\end{DoxyParamCaption})}



Count the number of log messages in an \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em rb} & The \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb} to count the elements of.\\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The number of log messages in the \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb}. 
\end{DoxyReturn}


References \textbf{ end}, \textbf{ size}, and \textbf{ start}.



Referenced by \textbf{ log\+\_\+target\+\_\+rb\+\_\+used\+\_\+size()}.

\mbox{\label{group__osmo__strrb_ga284dcee685ff37d0138d1f739ff24d20}} 
\index{Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}!osmo\_strrb\_get\_nth@{osmo\_strrb\_get\_nth}}
\index{osmo\_strrb\_get\_nth@{osmo\_strrb\_get\_nth}!Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}}
\doxysubsubsection{osmo\_strrb\_get\_nth()}
{\footnotesize\ttfamily const char $\ast$ osmo\+\_\+strrb\+\_\+get\+\_\+nth (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+strrb} $\ast$}]{rb,  }\item[{unsigned int}]{string\+\_\+index }\end{DoxyParamCaption})}



Return a pointer to the Nth string in the \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb}. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em rb} & The \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb} to search. \\
\hline
\mbox{\texttt{ in}}  & {\em string\+\_\+index} & The index sought (N), zero-\/indexed.\\
\hline
\end{DoxyParams}
Return a pointer to the Nth string in the \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb}. Return NULL if there is no Nth string. Note that N is zero-\/indexed. \begin{DoxyReturn}{Returns}
A pointer to the target string on success, NULL in case of error. 
\end{DoxyReturn}


References \textbf{ \+\_\+osmo\+\_\+strrb\+\_\+is\+\_\+bufindex\+\_\+valid()}, \textbf{ buffer}, \textbf{ end}, \textbf{ size}, and \textbf{ start}.



Referenced by \textbf{ log\+\_\+target\+\_\+rb\+\_\+get()}.

\mbox{\label{group__osmo__strrb_gaa8d2f58d4f27e99836d85b5e5c568136}} 
\index{Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}!osmo\_strrb\_is\_empty@{osmo\_strrb\_is\_empty}}
\index{osmo\_strrb\_is\_empty@{osmo\_strrb\_is\_empty}!Osmocom ringbuffers for log strings@{Osmocom ringbuffers for log strings}}
\doxysubsubsection{osmo\_strrb\_is\_empty()}
{\footnotesize\ttfamily bool osmo\+\_\+strrb\+\_\+is\+\_\+empty (\begin{DoxyParamCaption}\item[{const struct \textbf{ osmo\+\_\+strrb} $\ast$}]{rb }\end{DoxyParamCaption})}



Check if an \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb} is empty. 


\begin{DoxyParams}[1]{Parameters}
\mbox{\texttt{ in}}  & {\em rb} & The \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb} to check. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
True if the \doxyref{osmo\+\_\+strrb}{p.}{structosmo__strrb} is empty, false otherwise. 
\end{DoxyReturn}


References \textbf{ end}, and \textbf{ start}.



Referenced by \textbf{ \+\_\+osmo\+\_\+strrb\+\_\+is\+\_\+bufindex\+\_\+valid()}.

