\doxysection{src/vty/buffer.c File Reference}
\label{buffer_8c}\index{src/vty/buffer.c@{src/vty/buffer.c}}


Buffering of output and input.  


{\ttfamily \#include $<$stdio.\+h$>$}\newline
{\ttfamily \#include $<$stdlib.\+h$>$}\newline
{\ttfamily \#include $<$unistd.\+h$>$}\newline
{\ttfamily \#include $<$string.\+h$>$}\newline
{\ttfamily \#include $<$errno.\+h$>$}\newline
{\ttfamily \#include $<$stddef.\+h$>$}\newline
{\ttfamily \#include $<$sys/uio.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/core/talloc.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/vty/buffer.\+h$>$}\newline
{\ttfamily \#include $<$osmocom/vty/vty.\+h$>$}\newline
\doxysubsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ buffer}
\item 
struct \textbf{ buffer\+\_\+data}
\end{DoxyCompactItemize}
\doxysubsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \textbf{ BUFFER\+\_\+\+SIZE\+\_\+\+DEFAULT}~4096
\item 
\#define \textbf{ BUFFER\+\_\+\+DATA\+\_\+\+FREE}(D)~talloc\+\_\+free((D))
\item 
\#define \textbf{ MAX\+\_\+\+CHUNKS}~16
\item 
\#define \textbf{ MAX\+\_\+\+FLUSH}~131072
\end{DoxyCompactItemize}
\doxysubsection*{Functions}
\begin{DoxyCompactItemize}
\item 
struct \textbf{ buffer} $\ast$ \textbf{ buffer\+\_\+new} (void $\ast$ctx, size\+\_\+t size)
\item 
void \textbf{ buffer\+\_\+free} (struct \textbf{ buffer} $\ast$b)
\item 
char $\ast$ \textbf{ buffer\+\_\+getstr} (struct \textbf{ buffer} $\ast$b)
\item 
int \textbf{ buffer\+\_\+empty} (struct \textbf{ buffer} $\ast$b)
\item 
void \textbf{ buffer\+\_\+reset} (struct \textbf{ buffer} $\ast$b)
\item 
static struct \textbf{ buffer\+\_\+data} $\ast$ \textbf{ buffer\+\_\+add} (struct \textbf{ buffer} $\ast$b)
\item 
void \textbf{ buffer\+\_\+put} (struct \textbf{ buffer} $\ast$b, const void $\ast$p, size\+\_\+t size)
\item 
void \textbf{ buffer\+\_\+putc} (struct \textbf{ buffer} $\ast$b, unsigned char \textbf{ c})
\item 
void \textbf{ buffer\+\_\+putstr} (struct \textbf{ buffer} $\ast$b, const char $\ast$\textbf{ c})
\item 
\textbf{ buffer\+\_\+status\+\_\+t} \textbf{ buffer\+\_\+flush\+\_\+all} (struct \textbf{ buffer} $\ast$b, int \textbf{ fd})
\item 
\textbf{ buffer\+\_\+status\+\_\+t} \textbf{ buffer\+\_\+flush\+\_\+available} (struct \textbf{ buffer} $\ast$b, int \textbf{ fd})
\item 
\textbf{ buffer\+\_\+status\+\_\+t} \textbf{ buffer\+\_\+write} (struct \textbf{ buffer} $\ast$b, int \textbf{ fd}, const void $\ast$p, size\+\_\+t size)
\end{DoxyCompactItemize}


\doxysubsection{Detailed Description}
Buffering of output and input. 



\doxysubsection{Macro Definition Documentation}
\mbox{\label{buffer_8c_a1a2b87a6bddffd1ff50c2e32cc432dcc}} 
\index{buffer.c@{buffer.c}!BUFFER\_DATA\_FREE@{BUFFER\_DATA\_FREE}}
\index{BUFFER\_DATA\_FREE@{BUFFER\_DATA\_FREE}!buffer.c@{buffer.c}}
\doxysubsubsection{BUFFER\_DATA\_FREE}
{\footnotesize\ttfamily \#define BUFFER\+\_\+\+DATA\+\_\+\+FREE(\begin{DoxyParamCaption}\item[{}]{D }\end{DoxyParamCaption})~talloc\+\_\+free((D))}

\mbox{\label{buffer_8c_aba02eec807073b2458c435aa56d7f939}} 
\index{buffer.c@{buffer.c}!BUFFER\_SIZE\_DEFAULT@{BUFFER\_SIZE\_DEFAULT}}
\index{BUFFER\_SIZE\_DEFAULT@{BUFFER\_SIZE\_DEFAULT}!buffer.c@{buffer.c}}
\doxysubsubsection{BUFFER\_SIZE\_DEFAULT}
{\footnotesize\ttfamily \#define BUFFER\+\_\+\+SIZE\+\_\+\+DEFAULT~4096}

\mbox{\label{buffer_8c_a9e879c11aa15653382faa681060e6179}} 
\index{buffer.c@{buffer.c}!MAX\_CHUNKS@{MAX\_CHUNKS}}
\index{MAX\_CHUNKS@{MAX\_CHUNKS}!buffer.c@{buffer.c}}
\doxysubsubsection{MAX\_CHUNKS}
{\footnotesize\ttfamily \#define MAX\+\_\+\+CHUNKS~16}

\mbox{\label{buffer_8c_aaa4f5f66c653ca3963cdda9359d8bdde}} 
\index{buffer.c@{buffer.c}!MAX\_FLUSH@{MAX\_FLUSH}}
\index{MAX\_FLUSH@{MAX\_FLUSH}!buffer.c@{buffer.c}}
\doxysubsubsection{MAX\_FLUSH}
{\footnotesize\ttfamily \#define MAX\+\_\+\+FLUSH~131072}



\doxysubsection{Function Documentation}
\mbox{\label{buffer_8c_a5a33738cadc18e781925f00a76eac240}} 
\index{buffer.c@{buffer.c}!buffer\_add@{buffer\_add}}
\index{buffer\_add@{buffer\_add}!buffer.c@{buffer.c}}
\doxysubsubsection{buffer\_add()}
{\footnotesize\ttfamily static struct \textbf{ buffer\+\_\+data} $\ast$ buffer\+\_\+add (\begin{DoxyParamCaption}\item[{struct \textbf{ buffer} $\ast$}]{b }\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [static]}}



References \textbf{ buffer\+\_\+data\+::cp}, \textbf{ data}, \textbf{ buffer\+::head}, \textbf{ buffer\+\_\+data\+::next}, \textbf{ buffer\+::size}, \textbf{ buffer\+\_\+data\+::sp}, and \textbf{ buffer\+::tail}.



Referenced by \textbf{ buffer\+\_\+put()}.

\mbox{\label{buffer_8c_a5f2ba1147c2f9b7fee1a90ac2e76d0b7}} 
\index{buffer.c@{buffer.c}!buffer\_empty@{buffer\_empty}}
\index{buffer\_empty@{buffer\_empty}!buffer.c@{buffer.c}}
\doxysubsubsection{buffer\_empty()}
{\footnotesize\ttfamily int buffer\+\_\+empty (\begin{DoxyParamCaption}\item[{struct \textbf{ buffer} $\ast$}]{b }\end{DoxyParamCaption})}



References \textbf{ buffer\+::head}.

\mbox{\label{buffer_8c_a191ab7385104a44e13f385e0e6ca1b5d}} 
\index{buffer.c@{buffer.c}!buffer\_flush\_all@{buffer\_flush\_all}}
\index{buffer\_flush\_all@{buffer\_flush\_all}!buffer.c@{buffer.c}}
\doxysubsubsection{buffer\_flush\_all()}
{\footnotesize\ttfamily \textbf{ buffer\+\_\+status\+\_\+t} buffer\+\_\+flush\+\_\+all (\begin{DoxyParamCaption}\item[{struct \textbf{ buffer} $\ast$}]{b,  }\item[{int}]{fd }\end{DoxyParamCaption})}



References \textbf{ BUFFER\+\_\+\+EMPTY}, \textbf{ buffer\+\_\+flush\+\_\+available()}, \textbf{ BUFFER\+\_\+\+PENDING}, \textbf{ fd}, \textbf{ buffer\+::head}, and \textbf{ buffer\+\_\+data\+::sp}.



Referenced by \textbf{ client\+\_\+data()}, \textbf{ vty\+\_\+close()}, and \textbf{ vty\+\_\+flush()}.

\mbox{\label{buffer_8c_a3df3e577fcbeec460e3ddab6bc6f59ec}} 
\index{buffer.c@{buffer.c}!buffer\_flush\_available@{buffer\_flush\_available}}
\index{buffer\_flush\_available@{buffer\_flush\_available}!buffer.c@{buffer.c}}
\doxysubsubsection{buffer\_flush\_available()}
{\footnotesize\ttfamily \textbf{ buffer\+\_\+status\+\_\+t} buffer\+\_\+flush\+\_\+available (\begin{DoxyParamCaption}\item[{struct \textbf{ buffer} $\ast$}]{b,  }\item[{int}]{fd }\end{DoxyParamCaption})}



References \textbf{ BUFFER\+\_\+\+DATA\+\_\+\+FREE}, \textbf{ BUFFER\+\_\+\+EMPTY}, \textbf{ BUFFER\+\_\+\+ERROR}, \textbf{ BUFFER\+\_\+\+PENDING}, \textbf{ buffer\+\_\+data\+::cp}, \textbf{ buffer\+\_\+data\+::data}, \textbf{ ERRNO\+\_\+\+IO\+\_\+\+RETRY}, \textbf{ fd}, \textbf{ buffer\+::head}, \textbf{ MAX\+\_\+\+CHUNKS}, \textbf{ MAX\+\_\+\+FLUSH}, \textbf{ buffer\+\_\+data\+::next}, \textbf{ buffer\+\_\+data\+::sp}, and \textbf{ buffer\+::tail}.



Referenced by \textbf{ buffer\+\_\+flush\+\_\+all()}, and \textbf{ buffer\+\_\+write()}.

\mbox{\label{buffer_8c_a33630b21db5f9cda080c24c3175bde5a}} 
\index{buffer.c@{buffer.c}!buffer\_free@{buffer\_free}}
\index{buffer\_free@{buffer\_free}!buffer.c@{buffer.c}}
\doxysubsubsection{buffer\_free()}
{\footnotesize\ttfamily void buffer\+\_\+free (\begin{DoxyParamCaption}\item[{struct \textbf{ buffer} $\ast$}]{b }\end{DoxyParamCaption})}



References \textbf{ buffer\+\_\+reset()}.



Referenced by \textbf{ vty\+\_\+close()}, and \textbf{ vty\+\_\+new()}.

\mbox{\label{buffer_8c_a432bb12021ea78fb50af8b0298ecdfb0}} 
\index{buffer.c@{buffer.c}!buffer\_getstr@{buffer\_getstr}}
\index{buffer\_getstr@{buffer\_getstr}!buffer.c@{buffer.c}}
\doxysubsubsection{buffer\_getstr()}
{\footnotesize\ttfamily char $\ast$ buffer\+\_\+getstr (\begin{DoxyParamCaption}\item[{struct \textbf{ buffer} $\ast$}]{b }\end{DoxyParamCaption})}



References \textbf{ data}, \textbf{ buffer\+::head}, and \textbf{ tall\+\_\+vty\+\_\+ctx}.

\mbox{\label{buffer_8c_afa3fd5e9fc60dcd1e4cc36ac9cb19722}} 
\index{buffer.c@{buffer.c}!buffer\_new@{buffer\_new}}
\index{buffer\_new@{buffer\_new}!buffer.c@{buffer.c}}
\doxysubsubsection{buffer\_new()}
{\footnotesize\ttfamily struct \textbf{ buffer} $\ast$ buffer\+\_\+new (\begin{DoxyParamCaption}\item[{void $\ast$}]{ctx,  }\item[{size\+\_\+t}]{size }\end{DoxyParamCaption})}



References \textbf{ BUFFER\+\_\+\+SIZE\+\_\+\+DEFAULT}, and \textbf{ buffer\+::size}.



Referenced by \textbf{ vty\+\_\+new()}.

\mbox{\label{buffer_8c_a6150096c2eaae19e636d2742c3df5b75}} 
\index{buffer.c@{buffer.c}!buffer\_put@{buffer\_put}}
\index{buffer\_put@{buffer\_put}!buffer.c@{buffer.c}}
\doxysubsubsection{buffer\_put()}
{\footnotesize\ttfamily void buffer\+\_\+put (\begin{DoxyParamCaption}\item[{struct \textbf{ buffer} $\ast$}]{b,  }\item[{const void $\ast$}]{p,  }\item[{size\+\_\+t}]{size }\end{DoxyParamCaption})}



References \textbf{ buffer\+\_\+add()}, \textbf{ data}, \textbf{ buffer\+::size}, and \textbf{ buffer\+::tail}.



Referenced by \textbf{ buffer\+\_\+putc()}, \textbf{ buffer\+\_\+putstr()}, \textbf{ buffer\+\_\+write()}, \textbf{ vty\+\_\+out\+\_\+newline()}, \textbf{ vty\+\_\+out\+\_\+va()}, and \textbf{ vty\+\_\+write()}.

\mbox{\label{buffer_8c_a36699f394f36624f8c1739ef0758db9f}} 
\index{buffer.c@{buffer.c}!buffer\_putc@{buffer\_putc}}
\index{buffer\_putc@{buffer\_putc}!buffer.c@{buffer.c}}
\doxysubsubsection{buffer\_putc()}
{\footnotesize\ttfamily void buffer\+\_\+putc (\begin{DoxyParamCaption}\item[{struct \textbf{ buffer} $\ast$}]{b,  }\item[{unsigned char}]{c }\end{DoxyParamCaption})}



References \textbf{ buffer\+\_\+put()}, and \textbf{ c}.

\mbox{\label{buffer_8c_a23f67bdda323e69158b6e4587ad19649}} 
\index{buffer.c@{buffer.c}!buffer\_putstr@{buffer\_putstr}}
\index{buffer\_putstr@{buffer\_putstr}!buffer.c@{buffer.c}}
\doxysubsubsection{buffer\_putstr()}
{\footnotesize\ttfamily void buffer\+\_\+putstr (\begin{DoxyParamCaption}\item[{struct \textbf{ buffer} $\ast$}]{b,  }\item[{const char $\ast$}]{c }\end{DoxyParamCaption})}



References \textbf{ buffer\+\_\+put()}, and \textbf{ c}.

\mbox{\label{buffer_8c_a91ad0ff694ccef1876a3e8d8a3b05ffa}} 
\index{buffer.c@{buffer.c}!buffer\_reset@{buffer\_reset}}
\index{buffer\_reset@{buffer\_reset}!buffer.c@{buffer.c}}
\doxysubsubsection{buffer\_reset()}
{\footnotesize\ttfamily void buffer\+\_\+reset (\begin{DoxyParamCaption}\item[{struct \textbf{ buffer} $\ast$}]{b }\end{DoxyParamCaption})}



References \textbf{ BUFFER\+\_\+\+DATA\+\_\+\+FREE}, \textbf{ data}, \textbf{ buffer\+::head}, \textbf{ buffer\+\_\+data\+::next}, and \textbf{ buffer\+::tail}.



Referenced by \textbf{ buffer\+\_\+free()}, \textbf{ vty\+\_\+buffer\+\_\+reset()}, \textbf{ vty\+\_\+read()}, and \textbf{ vty\+\_\+reset()}.

\mbox{\label{buffer_8c_a426b697edda52bb07fdf222e8b982e9d}} 
\index{buffer.c@{buffer.c}!buffer\_write@{buffer\_write}}
\index{buffer\_write@{buffer\_write}!buffer.c@{buffer.c}}
\doxysubsubsection{buffer\_write()}
{\footnotesize\ttfamily \textbf{ buffer\+\_\+status\+\_\+t} buffer\+\_\+write (\begin{DoxyParamCaption}\item[{struct \textbf{ buffer} $\ast$}]{b,  }\item[{int}]{fd,  }\item[{const void $\ast$}]{p,  }\item[{size\+\_\+t}]{size }\end{DoxyParamCaption})}



References \textbf{ BUFFER\+\_\+\+EMPTY}, \textbf{ BUFFER\+\_\+\+ERROR}, \textbf{ buffer\+\_\+flush\+\_\+available()}, \textbf{ BUFFER\+\_\+\+PENDING}, \textbf{ buffer\+\_\+put()}, \textbf{ ERRNO\+\_\+\+IO\+\_\+\+RETRY}, \textbf{ fd}, and \textbf{ buffer\+::head}.

