\hypertarget{buffer_8h}{\section{opal/mca/event/libevent2013/libevent/include/event2/buffer.h File Reference}
\label{buffer_8h}\index{opal/mca/event/libevent2013/libevent/include/event2/buffer.\+h@{opal/mca/event/libevent2013/libevent/include/event2/buffer.\+h}}
}


Functions for buffering data for network sending or receiving.  


{\ttfamily \#include $<$event2/event-\/config.\+h$>$}\\*
{\ttfamily \#include $<$stdarg.\+h$>$}\\*
{\ttfamily \#include $<$event2/util.\+h$>$}\\*
\subsection*{Data Structures}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr}
\begin{DoxyCompactList}\small\item\em Pointer to a position within an evbuffer. \end{DoxyCompactList}\item 
struct \hyperlink{structevbuffer__iovec}{evbuffer\+\_\+iovec}
\begin{DoxyCompactList}\small\item\em Describes a single extent of memory inside an evbuffer. \end{DoxyCompactList}\item 
struct \hyperlink{structevbuffer__cb__info}{evbuffer\+\_\+cb\+\_\+info}
\begin{DoxyCompactList}\small\item\em Structure passed to an evbuffer\+\_\+cb\+\_\+func evbuffer callback. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Macros}
\begin{DoxyCompactItemize}
\item 
\#define \hyperlink{buffer_8h_aeb635643a72f8e57d50d7dee37308148}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+C\+B\+\_\+\+E\+N\+A\+B\+L\+E\+D}~1
\begin{DoxyCompactList}\small\item\em If this flag is not set, then a callback is temporarily disabled, and should not be invoked. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Typedefs}
\begin{DoxyCompactItemize}
\item 
typedef void($\ast$ \hyperlink{buffer_8h_acc4dead0032a38143cb2c902417f9177}{evbuffer\+\_\+ref\+\_\+cleanup\+\_\+cb} )(const void $\ast$data, size\+\_\+t datalen, void $\ast$extra)
\begin{DoxyCompactList}\small\item\em A cleanup function for a piece of memory added to an evbuffer by reference. \end{DoxyCompactList}\item 
typedef void($\ast$ \hyperlink{buffer_8h_af40adaa98b02da7fca55da29270266d9}{evbuffer\+\_\+cb\+\_\+func} )(struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, const struct \hyperlink{structevbuffer__cb__info}{evbuffer\+\_\+cb\+\_\+info} $\ast$info, void $\ast$arg)
\begin{DoxyCompactList}\small\item\em Type definition for a callback that is invoked whenever data is added or removed from an evbuffer. \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Enumerations}
\begin{DoxyCompactItemize}
\item 
enum \hyperlink{buffer_8h_ad8daf54669a1d2094ce4251dbb502178}{evbuffer\+\_\+eol\+\_\+style} \{ \hyperlink{buffer_8h_ad8daf54669a1d2094ce4251dbb502178ab7c6da1408b1b2ec3a6657e5a71a50c3}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+A\+N\+Y}, 
\hyperlink{buffer_8h_ad8daf54669a1d2094ce4251dbb502178a4aec5353e85fbb57ce3b1ee68f36f641}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F}, 
\hyperlink{buffer_8h_ad8daf54669a1d2094ce4251dbb502178a814775b4a9773d34421e7e88ca8c58de}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F\+\_\+\+S\+T\+R\+I\+C\+T}, 
\hyperlink{buffer_8h_ad8daf54669a1d2094ce4251dbb502178ac572ea90e5a96a7ceb878f2a8ef48993}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+L\+F}
 \}
\begin{DoxyCompactList}\small\item\em Used to tell evbuffer\+\_\+readln what kind of line-\/ending to look for. \end{DoxyCompactList}\item 
enum \hyperlink{buffer_8h_a13a9ee759900ce2964d16acd5f309014}{evbuffer\+\_\+ptr\+\_\+how} \{ \hyperlink{buffer_8h_a13a9ee759900ce2964d16acd5f309014a78a0ff3721ff5f1647f743dcfb2f13ee}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+S\+E\+T}, 
\hyperlink{buffer_8h_a13a9ee759900ce2964d16acd5f309014a0bce00d78b5fbc55c478ff362269f428}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+A\+D\+D}
 \}
\begin{DoxyCompactList}\small\item\em Defines how to adjust an \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} by \hyperlink{buffer_8h_a83ea16ab8facba6c68d2e6931d13fbf4}{evbuffer\+\_\+ptr\+\_\+set()} \end{DoxyCompactList}\end{DoxyCompactItemize}
\subsection*{Functions}
\begin{DoxyCompactItemize}
\item 
struct \hyperlink{structevbuffer}{evbuffer} $\ast$ \hyperlink{buffer_8h_a8ebe44bfccd1d245cae17b1b7586092a}{evbuffer\+\_\+new} (void)
\begin{DoxyCompactList}\small\item\em Allocate storage for a new evbuffer. \end{DoxyCompactList}\item 
void \hyperlink{buffer_8h_a0a87b43a5ae8c5589e77cde486b8a155}{evbuffer\+\_\+free} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf)
\begin{DoxyCompactList}\small\item\em Deallocate storage for an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a1bf21d715f288541eb670c5f159f2264}{evbuffer\+\_\+enable\+\_\+locking} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, void $\ast$lock)
\begin{DoxyCompactList}\small\item\em Enable locking on an evbuffer so that it can safely be used by multiple threads at the same time. \end{DoxyCompactList}\item 
void \hyperlink{buffer_8h_af9542ca1ac381708c9b1450d91d168ec}{evbuffer\+\_\+lock} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf)
\begin{DoxyCompactList}\small\item\em Acquire the lock on an evbuffer. \end{DoxyCompactList}\item 
void \hyperlink{buffer_8h_a538b62549df58369e10fd5703cafe92b}{evbuffer\+\_\+unlock} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf)
\begin{DoxyCompactList}\small\item\em Release the lock on an evbuffer. \end{DoxyCompactList}\item 
size\+\_\+t \hyperlink{buffer_8h_af1b44374d37735f3a90ae402eaeddf44}{evbuffer\+\_\+get\+\_\+length} (const struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf)
\begin{DoxyCompactList}\small\item\em Returns the total number of bytes stored in the evbuffer. \end{DoxyCompactList}\item 
size\+\_\+t \hyperlink{buffer_8h_acd3d8507991609637a501e835e450331}{evbuffer\+\_\+get\+\_\+contiguous\+\_\+space} (const struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf)
\begin{DoxyCompactList}\small\item\em Returns the number of contiguous available bytes in the first buffer chain. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a305caf7b9bfb8713e6ef383d61791f95}{evbuffer\+\_\+expand} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, size\+\_\+t datlen)
\begin{DoxyCompactList}\small\item\em Expands the available space in an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_ada49b2dc41bb09bb011765c1fc826a5d}{evbuffer\+\_\+reserve\+\_\+space} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, ev\+\_\+ssize\+\_\+t size, struct \hyperlink{structevbuffer__iovec}{evbuffer\+\_\+iovec} $\ast$vec, int n\+\_\+vec)
\begin{DoxyCompactList}\small\item\em Reserves space in the last chain or chains of an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a7a13a10fd1eb75cccf0ca29a05c5ba8a}{evbuffer\+\_\+commit\+\_\+space} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, struct \hyperlink{structevbuffer__iovec}{evbuffer\+\_\+iovec} $\ast$vec, int n\+\_\+vecs)
\begin{DoxyCompactList}\small\item\em Commits previously reserved space. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a69c3b8893a49bdd919642c6920c1fcb4}{evbuffer\+\_\+add} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, const void $\ast$data, size\+\_\+t datlen)
\begin{DoxyCompactList}\small\item\em Append data to the end of an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a0455fc72c74c758ed8dc9a0902af451a}{evbuffer\+\_\+remove} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, void $\ast$data, size\+\_\+t datlen)
\begin{DoxyCompactList}\small\item\em Read data from an evbuffer and drain the bytes read. \end{DoxyCompactList}\item 
ev\+\_\+ssize\+\_\+t \hyperlink{buffer_8h_a8fa753475570f6529691ef8484cacc1b}{evbuffer\+\_\+copyout} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, void $\ast$data\+\_\+out, size\+\_\+t datlen)
\begin{DoxyCompactList}\small\item\em Read data from an evbuffer, and leave the buffer unchanged. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a0bdef97f6a142425b271b329a90de869}{evbuffer\+\_\+remove\+\_\+buffer} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$src, struct \hyperlink{structevbuffer}{evbuffer} $\ast$dst, size\+\_\+t datlen)
\begin{DoxyCompactList}\small\item\em Read data from an evbuffer into another evbuffer, draining the bytes from the source buffer. \end{DoxyCompactList}\item 
char $\ast$ \hyperlink{buffer_8h_ae2460b5060948d3233342c4c81888650}{evbuffer\+\_\+readln} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, size\+\_\+t $\ast$n\+\_\+read\+\_\+out, enum \hyperlink{buffer_8h_ad8daf54669a1d2094ce4251dbb502178}{evbuffer\+\_\+eol\+\_\+style} eol\+\_\+style)
\begin{DoxyCompactList}\small\item\em Read a single line from an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a9d2edd536246d70c50678a3865305414}{evbuffer\+\_\+add\+\_\+buffer} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$outbuf, struct \hyperlink{structevbuffer}{evbuffer} $\ast$inbuf)
\begin{DoxyCompactList}\small\item\em Move all data from one evbuffer into another evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a8a61b06a97974a86853becb9110b2ffd}{evbuffer\+\_\+add\+\_\+reference} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$outbuf, const void $\ast$data, size\+\_\+t datlen, \hyperlink{buffer_8h_acc4dead0032a38143cb2c902417f9177}{evbuffer\+\_\+ref\+\_\+cleanup\+\_\+cb} cleanupfn, void $\ast$cleanupfn\+\_\+arg)
\begin{DoxyCompactList}\small\item\em Reference memory into an evbuffer without copying. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a5db7e9063755accc56fdad87d662743e}{evbuffer\+\_\+add\+\_\+file} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$outbuf, int fd, ev\+\_\+off\+\_\+t offset, ev\+\_\+off\+\_\+t length)
\begin{DoxyCompactList}\small\item\em Copy data from a file into the evbuffer for writing to a socket. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_adeb9457f344ddaf459726dbe348ac3db}{evbuffer\+\_\+add\+\_\+printf} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, const char $\ast$fmt,...)
\begin{DoxyCompactList}\small\item\em Append a formatted string to the end of an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_acc385568d5129d4af10486b641b98f81}{evbuffer\+\_\+add\+\_\+vprintf} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, const char $\ast$fmt, va\+\_\+list ap)
\begin{DoxyCompactList}\small\item\em Append a va\+\_\+list formatted string to the end of an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a5c24f3bfbc941d693bf59b5d77d2c37f}{evbuffer\+\_\+drain} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, size\+\_\+t len)
\begin{DoxyCompactList}\small\item\em Remove a specified number of bytes data from the beginning of an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a1207167bb14d5333326225f41477e910}{evbuffer\+\_\+write} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, \hyperlink{opal_2mca_2event_2libevent2013_2libevent_2include_2event2_2util_8h_a7ef0023565082a65020f6e56be59fd0b}{evutil\+\_\+socket\+\_\+t} fd)
\begin{DoxyCompactList}\small\item\em Write the contents of an evbuffer to a file descriptor. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_aa0bea512e82177762be7cf0a28a9b03b}{evbuffer\+\_\+write\+\_\+atmost} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, \hyperlink{opal_2mca_2event_2libevent2013_2libevent_2include_2event2_2util_8h_a7ef0023565082a65020f6e56be59fd0b}{evutil\+\_\+socket\+\_\+t} fd, ev\+\_\+ssize\+\_\+t howmuch)
\begin{DoxyCompactList}\small\item\em Write some of the contents of an evbuffer to a file descriptor. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a464aff577b05417171192fc68539b77e}{evbuffer\+\_\+read} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, \hyperlink{opal_2mca_2event_2libevent2013_2libevent_2include_2event2_2util_8h_a7ef0023565082a65020f6e56be59fd0b}{evutil\+\_\+socket\+\_\+t} fd, int howmuch)
\begin{DoxyCompactList}\small\item\em Read from a file descriptor and store the result in an evbuffer. \end{DoxyCompactList}\item 
struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} \hyperlink{buffer_8h_a61e15e2a355409587464c476d2481105}{evbuffer\+\_\+search} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, const char $\ast$what, size\+\_\+t len, const struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} $\ast$start)
\begin{DoxyCompactList}\small\item\em Search for a string within an evbuffer. \end{DoxyCompactList}\item 
struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} \hyperlink{buffer_8h_a532ded8162d838b306e18839e9ab04af}{evbuffer\+\_\+search\+\_\+range} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, const char $\ast$what, size\+\_\+t len, const struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} $\ast$start, const struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} $\ast$end)
\begin{DoxyCompactList}\small\item\em Search for a string within part of an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a83ea16ab8facba6c68d2e6931d13fbf4}{evbuffer\+\_\+ptr\+\_\+set} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} $\ast$ptr, size\+\_\+t position, enum \hyperlink{buffer_8h_a13a9ee759900ce2964d16acd5f309014}{evbuffer\+\_\+ptr\+\_\+how} how)
\begin{DoxyCompactList}\small\item\em Sets the search pointer in the buffer to position. \end{DoxyCompactList}\item 
struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} \hyperlink{buffer_8h_aa54aca588fa272157513191a9628d457}{evbuffer\+\_\+search\+\_\+eol} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} $\ast$start, size\+\_\+t $\ast$eol\+\_\+len\+\_\+out, enum \hyperlink{buffer_8h_ad8daf54669a1d2094ce4251dbb502178}{evbuffer\+\_\+eol\+\_\+style} eol\+\_\+style)
\begin{DoxyCompactList}\small\item\em Search for an end-\/of-\/line string within an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_adf4b59974a0cb989b7091f0b8677d511}{evbuffer\+\_\+peek} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, ev\+\_\+ssize\+\_\+t len, struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} $\ast$start\+\_\+at, struct \hyperlink{structevbuffer__iovec}{evbuffer\+\_\+iovec} $\ast$vec\+\_\+out, int n\+\_\+vec)
\begin{DoxyCompactList}\small\item\em \hyperlink{structFunction}{Function} to peek at data inside an evbuffer without removing it or copying it out. \end{DoxyCompactList}\item 
struct \hyperlink{structevbuffer__cb__entry}{evbuffer\+\_\+cb\+\_\+entry} $\ast$ \hyperlink{buffer_8h_aa2a1509845c3d71f0adac4198aab0bf7}{evbuffer\+\_\+add\+\_\+cb} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, \hyperlink{buffer_8h_af40adaa98b02da7fca55da29270266d9}{evbuffer\+\_\+cb\+\_\+func} cb, void $\ast$cbarg)
\begin{DoxyCompactList}\small\item\em Add a new callback to an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_afd1e51be92170b17178949a639dfa8ab}{evbuffer\+\_\+remove\+\_\+cb\+\_\+entry} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, struct \hyperlink{structevbuffer__cb__entry}{evbuffer\+\_\+cb\+\_\+entry} $\ast$ent)
\begin{DoxyCompactList}\small\item\em Remove a callback from an evbuffer, given a handle returned from evbuffer\+\_\+add\+\_\+cb. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a4d7c75045267863306d37043d3f0809a}{evbuffer\+\_\+remove\+\_\+cb} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, \hyperlink{buffer_8h_af40adaa98b02da7fca55da29270266d9}{evbuffer\+\_\+cb\+\_\+func} cb, void $\ast$cbarg)
\begin{DoxyCompactList}\small\item\em Remove a callback from an evbuffer, given the function and argument used to add it. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a4ba44d01484f19fbfe7c18d2a175dc3b}{evbuffer\+\_\+cb\+\_\+set\+\_\+flags} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, struct \hyperlink{structevbuffer__cb__entry}{evbuffer\+\_\+cb\+\_\+entry} $\ast$cb, ev\+\_\+uint32\+\_\+t flags)
\begin{DoxyCompactList}\small\item\em Change the flags that are set for a callback on a buffer by adding more. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_acda56baecd4b512f4e9f54a21e39177f}{evbuffer\+\_\+cb\+\_\+clear\+\_\+flags} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, struct \hyperlink{structevbuffer__cb__entry}{evbuffer\+\_\+cb\+\_\+entry} $\ast$cb, ev\+\_\+uint32\+\_\+t flags)
\begin{DoxyCompactList}\small\item\em Change the flags that are set for a callback on a buffer by removing some. \end{DoxyCompactList}\item 
unsigned char $\ast$ \hyperlink{buffer_8h_a07df786553218ae3a7b0ebd2c9471a96}{evbuffer\+\_\+pullup} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, ev\+\_\+ssize\+\_\+t size)
\begin{DoxyCompactList}\small\item\em Makes the data at the begging of an evbuffer contiguous. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a0daf99dbc837953427b60c462e5eba97}{evbuffer\+\_\+prepend} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, const void $\ast$data, size\+\_\+t size)
\begin{DoxyCompactList}\small\item\em Prepends data to the beginning of the evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a80ea4326ada348edc0e4fb53ad1df80c}{evbuffer\+\_\+prepend\+\_\+buffer} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$dst, struct \hyperlink{structevbuffer}{evbuffer} $\ast$src)
\begin{DoxyCompactList}\small\item\em Prepends all data from the src evbuffer to the beginning of the dst evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a8611ca97c720d4dd605e272cc4136684}{evbuffer\+\_\+freeze} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, int at\+\_\+front)
\begin{DoxyCompactList}\small\item\em Prevent calls that modify an evbuffer from succeeding. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a0aceee5e8d8443df6d1b5daeb4daacfd}{evbuffer\+\_\+unfreeze} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buf, int at\+\_\+front)
\begin{DoxyCompactList}\small\item\em Re-\/enable calls that modify an evbuffer. \end{DoxyCompactList}\item 
int \hyperlink{buffer_8h_a1c99c484430a81e641a783a273435074}{evbuffer\+\_\+defer\+\_\+callbacks} (struct \hyperlink{structevbuffer}{evbuffer} $\ast$buffer, struct \hyperlink{structevent__base}{event\+\_\+base} $\ast$base)
\begin{DoxyCompactList}\small\item\em Force all the callbacks on an evbuffer to be run, not immediately after the evbuffer is altered, but instead from inside the event loop. \end{DoxyCompactList}\end{DoxyCompactItemize}


\subsection{Detailed Description}
Functions for buffering data for network sending or receiving. 

An evbuffer can be used for preparing data before sending it to the network or conversely for reading data from the network. Evbuffers try to avoid memory copies as much as possible. As a result, evbuffers can be used to pass data around without actually incurring the overhead of copying the data.

A new evbuffer can be allocated with \hyperlink{buffer_8h_a8ebe44bfccd1d245cae17b1b7586092a}{evbuffer\+\_\+new()}, and can be freed with \hyperlink{buffer_8h_a0a87b43a5ae8c5589e77cde486b8a155}{evbuffer\+\_\+free()}. Most users will be using evbuffers via the bufferevent interface. To access a bufferevent's evbuffers, use \hyperlink{bufferevent_8h_a7bc716ede3a5fc1e9107ae522e545e0c}{bufferevent\+\_\+get\+\_\+input()} and \hyperlink{bufferevent_8h_af3dea057c5a276461dd94a1601682be1}{bufferevent\+\_\+get\+\_\+output()}.

There are several guidelines for using evbuffers.


\begin{DoxyItemize}
\item if you already know how much data you are going to add as a result of calling \hyperlink{buffer_8h_a69c3b8893a49bdd919642c6920c1fcb4}{evbuffer\+\_\+add()} multiple times, it makes sense to use \hyperlink{buffer_8h_a305caf7b9bfb8713e6ef383d61791f95}{evbuffer\+\_\+expand()} first to make sure that enough memory is allocated before hand.
\item \hyperlink{buffer_8h_a9d2edd536246d70c50678a3865305414}{evbuffer\+\_\+add\+\_\+buffer()} adds the contents of one buffer to the other without incurring any unnecessary memory copies.
\item \hyperlink{buffer_8h_a69c3b8893a49bdd919642c6920c1fcb4}{evbuffer\+\_\+add()} and \hyperlink{buffer_8h_a9d2edd536246d70c50678a3865305414}{evbuffer\+\_\+add\+\_\+buffer()} do not mix very well\+: if you use them, you will wind up with fragmented memory in your buffer.
\item For high-\/performance code, you may want to avoid copying data into and out of buffers. You can skip the copy step by using \hyperlink{buffer_8h_ada49b2dc41bb09bb011765c1fc826a5d}{evbuffer\+\_\+reserve\+\_\+space()}/evbuffer\+\_\+commit\+\_\+space() when writing into a buffer, and \hyperlink{buffer_8h_adf4b59974a0cb989b7091f0b8677d511}{evbuffer\+\_\+peek()} when reading.
\end{DoxyItemize}

In Libevent 2.\+0 and later, evbuffers are represented using a linked list of memory chunks, with pointers to the first and last chunk in the chain.

As the contents of an evbuffer can be stored in multiple different memory blocks, it cannot be accessed directly. Instead, \hyperlink{buffer_8h_a07df786553218ae3a7b0ebd2c9471a96}{evbuffer\+\_\+pullup()} can be used to force a specified number of bytes to be contiguous. This will cause memory reallocation and memory copies if the data is split across multiple blocks. It is more efficient, however, to use \hyperlink{buffer_8h_adf4b59974a0cb989b7091f0b8677d511}{evbuffer\+\_\+peek()} if you don't require that the memory to be contiguous. 

\subsection{Macro Definition Documentation}
\hypertarget{buffer_8h_aeb635643a72f8e57d50d7dee37308148}{\index{buffer.\+h@{buffer.\+h}!E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+C\+B\+\_\+\+E\+N\+A\+B\+L\+E\+D@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+C\+B\+\_\+\+E\+N\+A\+B\+L\+E\+D}}
\index{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+C\+B\+\_\+\+E\+N\+A\+B\+L\+E\+D@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+C\+B\+\_\+\+E\+N\+A\+B\+L\+E\+D}!buffer.\+h@{buffer.\+h}}
\subsubsection[{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+C\+B\+\_\+\+E\+N\+A\+B\+L\+E\+D}]{\setlength{\rightskip}{0pt plus 5cm}\#define E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+C\+B\+\_\+\+E\+N\+A\+B\+L\+E\+D~1}}\label{buffer_8h_aeb635643a72f8e57d50d7dee37308148}


If this flag is not set, then a callback is temporarily disabled, and should not be invoked. 

\begin{DoxySeeAlso}{See also}
\hyperlink{buffer_8h_a4ba44d01484f19fbfe7c18d2a175dc3b}{evbuffer\+\_\+cb\+\_\+set\+\_\+flags()}, \hyperlink{buffer_8h_acda56baecd4b512f4e9f54a21e39177f}{evbuffer\+\_\+cb\+\_\+clear\+\_\+flags()} 
\end{DoxySeeAlso}


Referenced by bufferevent\+\_\+setwatermark(), and evbuffer\+\_\+add\+\_\+cb().



\subsection{Typedef Documentation}
\hypertarget{buffer_8h_af40adaa98b02da7fca55da29270266d9}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+cb\+\_\+func@{evbuffer\+\_\+cb\+\_\+func}}
\index{evbuffer\+\_\+cb\+\_\+func@{evbuffer\+\_\+cb\+\_\+func}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+cb\+\_\+func}]{\setlength{\rightskip}{0pt plus 5cm}typedef void($\ast$ evbuffer\+\_\+cb\+\_\+func)(struct {\bf evbuffer} $\ast$buffer, const struct {\bf evbuffer\+\_\+cb\+\_\+info} $\ast$info, void $\ast$arg)}}\label{buffer_8h_af40adaa98b02da7fca55da29270266d9}


Type definition for a callback that is invoked whenever data is added or removed from an evbuffer. 

An evbuffer may have one or more callbacks set at a time. The order in which they are executed is undefined.

A callback function may add more callbacks, or remove itself from the list of callbacks, or add or remove data from the buffer. It may not remove another callback from the list.

If a callback adds or removes data from the buffer or from another buffer, this can cause a recursive invocation of your callback or other callbacks. If you ask for an infinite loop, you might just get one\+: watch out!


\begin{DoxyParams}{Parameters}
{\em buffer} & the buffer whose size has changed \\
\hline
{\em info} & a structure describing how the buffer changed. \\
\hline
{\em arg} & a pointer to user data \\
\hline
\end{DoxyParams}
\hypertarget{buffer_8h_acc4dead0032a38143cb2c902417f9177}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+ref\+\_\+cleanup\+\_\+cb@{evbuffer\+\_\+ref\+\_\+cleanup\+\_\+cb}}
\index{evbuffer\+\_\+ref\+\_\+cleanup\+\_\+cb@{evbuffer\+\_\+ref\+\_\+cleanup\+\_\+cb}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+ref\+\_\+cleanup\+\_\+cb}]{\setlength{\rightskip}{0pt plus 5cm}typedef void($\ast$ evbuffer\+\_\+ref\+\_\+cleanup\+\_\+cb)(const void $\ast$data, size\+\_\+t datalen, void $\ast$extra)}}\label{buffer_8h_acc4dead0032a38143cb2c902417f9177}


A cleanup function for a piece of memory added to an evbuffer by reference. 

\begin{DoxySeeAlso}{See also}
\hyperlink{buffer_8h_a8a61b06a97974a86853becb9110b2ffd}{evbuffer\+\_\+add\+\_\+reference()} 
\end{DoxySeeAlso}


\subsection{Enumeration Type Documentation}
\hypertarget{buffer_8h_ad8daf54669a1d2094ce4251dbb502178}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+eol\+\_\+style@{evbuffer\+\_\+eol\+\_\+style}}
\index{evbuffer\+\_\+eol\+\_\+style@{evbuffer\+\_\+eol\+\_\+style}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+eol\+\_\+style}]{\setlength{\rightskip}{0pt plus 5cm}enum {\bf evbuffer\+\_\+eol\+\_\+style}}}\label{buffer_8h_ad8daf54669a1d2094ce4251dbb502178}


Used to tell evbuffer\+\_\+readln what kind of line-\/ending to look for. 

\begin{Desc}
\item[Enumerator]\par
\begin{description}
\index{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+A\+N\+Y@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+A\+N\+Y}!buffer.\+h@{buffer.\+h}}\index{buffer.\+h@{buffer.\+h}!E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+A\+N\+Y@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+A\+N\+Y}}\item[{\em 
\hypertarget{buffer_8h_ad8daf54669a1d2094ce4251dbb502178ab7c6da1408b1b2ec3a6657e5a71a50c3}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+A\+N\+Y}\label{buffer_8h_ad8daf54669a1d2094ce4251dbb502178ab7c6da1408b1b2ec3a6657e5a71a50c3}
}]Any sequence of C\+R and L\+F characters is acceptable as an E\+O\+L. Note that this style can produce ambiguous results\+: the sequence \char`\"{}\+C\+R\+L\+F\char`\"{} will be treated as a single E\+O\+L if it is all in the buffer at once, but if you first read a C\+R from the network and later read an L\+F from the network, it will be treated as two E\+O\+Ls. \index{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F}!buffer.\+h@{buffer.\+h}}\index{buffer.\+h@{buffer.\+h}!E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F}}\item[{\em 
\hypertarget{buffer_8h_ad8daf54669a1d2094ce4251dbb502178a4aec5353e85fbb57ce3b1ee68f36f641}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F}\label{buffer_8h_ad8daf54669a1d2094ce4251dbb502178a4aec5353e85fbb57ce3b1ee68f36f641}
}]An E\+O\+L is an L\+F, optionally preceded by a C\+R. This style is most useful for implementing text-\/based internet protocols. \index{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F\+\_\+\+S\+T\+R\+I\+C\+T@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F\+\_\+\+S\+T\+R\+I\+C\+T}!buffer.\+h@{buffer.\+h}}\index{buffer.\+h@{buffer.\+h}!E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F\+\_\+\+S\+T\+R\+I\+C\+T@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F\+\_\+\+S\+T\+R\+I\+C\+T}}\item[{\em 
\hypertarget{buffer_8h_ad8daf54669a1d2094ce4251dbb502178a814775b4a9773d34421e7e88ca8c58de}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F\+\_\+\+S\+T\+R\+I\+C\+T}\label{buffer_8h_ad8daf54669a1d2094ce4251dbb502178a814775b4a9773d34421e7e88ca8c58de}
}]An E\+O\+L is a C\+R followed by an L\+F. \index{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+L\+F@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+L\+F}!buffer.\+h@{buffer.\+h}}\index{buffer.\+h@{buffer.\+h}!E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+L\+F@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+L\+F}}\item[{\em 
\hypertarget{buffer_8h_ad8daf54669a1d2094ce4251dbb502178ac572ea90e5a96a7ceb878f2a8ef48993}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+L\+F}\label{buffer_8h_ad8daf54669a1d2094ce4251dbb502178ac572ea90e5a96a7ceb878f2a8ef48993}
}]An E\+O\+L is a L\+F. \end{description}
\end{Desc}
\hypertarget{buffer_8h_a13a9ee759900ce2964d16acd5f309014}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+ptr\+\_\+how@{evbuffer\+\_\+ptr\+\_\+how}}
\index{evbuffer\+\_\+ptr\+\_\+how@{evbuffer\+\_\+ptr\+\_\+how}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+ptr\+\_\+how}]{\setlength{\rightskip}{0pt plus 5cm}enum {\bf evbuffer\+\_\+ptr\+\_\+how}}}\label{buffer_8h_a13a9ee759900ce2964d16acd5f309014}


Defines how to adjust an \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} by \hyperlink{buffer_8h_a83ea16ab8facba6c68d2e6931d13fbf4}{evbuffer\+\_\+ptr\+\_\+set()} 

\begin{DoxySeeAlso}{See also}
\hyperlink{buffer_8h_a83ea16ab8facba6c68d2e6931d13fbf4}{evbuffer\+\_\+ptr\+\_\+set()} 
\end{DoxySeeAlso}
\begin{Desc}
\item[Enumerator]\par
\begin{description}
\index{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+S\+E\+T@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+S\+E\+T}!buffer.\+h@{buffer.\+h}}\index{buffer.\+h@{buffer.\+h}!E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+S\+E\+T@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+S\+E\+T}}\item[{\em 
\hypertarget{buffer_8h_a13a9ee759900ce2964d16acd5f309014a78a0ff3721ff5f1647f743dcfb2f13ee}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+S\+E\+T}\label{buffer_8h_a13a9ee759900ce2964d16acd5f309014a78a0ff3721ff5f1647f743dcfb2f13ee}
}]Sets the pointer to the position; can be called on with an uninitialized \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr}. \index{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+A\+D\+D@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+A\+D\+D}!buffer.\+h@{buffer.\+h}}\index{buffer.\+h@{buffer.\+h}!E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+A\+D\+D@{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+A\+D\+D}}\item[{\em 
\hypertarget{buffer_8h_a13a9ee759900ce2964d16acd5f309014a0bce00d78b5fbc55c478ff362269f428}{E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+A\+D\+D}\label{buffer_8h_a13a9ee759900ce2964d16acd5f309014a0bce00d78b5fbc55c478ff362269f428}
}]Advances the pointer by adding to the current position. \end{description}
\end{Desc}


\subsection{Function Documentation}
\hypertarget{buffer_8h_a69c3b8893a49bdd919642c6920c1fcb4}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+add@{evbuffer\+\_\+add}}
\index{evbuffer\+\_\+add@{evbuffer\+\_\+add}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+add}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+add (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{const void $\ast$}]{data, }
\item[{size\+\_\+t}]{datlen}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a69c3b8893a49bdd919642c6920c1fcb4}


Append data to the end of an evbuffer. 


\begin{DoxyParams}{Parameters}
{\em buf} & the evbuffer to be appended to \\
\hline
{\em data} & pointer to the beginning of the data buffer \\
\hline
{\em datlen} & the number of bytes to be copied from the data buffer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, -\/1 on failure. 
\end{DoxyReturn}


References evbuffer\+\_\+chain\+::buffer, evbuffer\+\_\+chain\+::buffer\+\_\+len, evbuffer\+\_\+chain\+::flags, evbuffer\+::freeze\+\_\+end, evbuffer\+::last, evbuffer\+\_\+chain\+::misalign, evbuffer\+::n\+\_\+add\+\_\+for\+\_\+cb, evbuffer\+\_\+chain\+::off, and evbuffer\+::total\+\_\+len.



Referenced by bufferevent\+\_\+write(), evbuffer\+\_\+remove\+\_\+buffer(), evhttp\+\_\+send\+\_\+reply\+\_\+chunk(), evhttp\+\_\+send\+\_\+reply\+\_\+end(), evhttp\+\_\+uri\+\_\+join(), evhttp\+\_\+uriencode(), and evtag\+\_\+encode\+\_\+int().

\hypertarget{buffer_8h_a9d2edd536246d70c50678a3865305414}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+add\+\_\+buffer@{evbuffer\+\_\+add\+\_\+buffer}}
\index{evbuffer\+\_\+add\+\_\+buffer@{evbuffer\+\_\+add\+\_\+buffer}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+add\+\_\+buffer}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+add\+\_\+buffer (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{outbuf, }
\item[{struct {\bf evbuffer} $\ast$}]{inbuf}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a9d2edd536246d70c50678a3865305414}


Move all data from one evbuffer into another evbuffer. 

This is a destructive add. The data from one buffer moves into the other buffer. However, no unnecessary memory copies occur.


\begin{DoxyParams}{Parameters}
{\em outbuf} & the output buffer \\
\hline
{\em inbuf} & the input buffer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, or -\/1 if an error occurred
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{buffer_8h_a0bdef97f6a142425b271b329a90de869}{evbuffer\+\_\+remove\+\_\+buffer()} 
\end{DoxySeeAlso}


References evbuffer\+::first, evbuffer\+::freeze\+\_\+end, evbuffer\+::freeze\+\_\+start, evbuffer\+::n\+\_\+add\+\_\+for\+\_\+cb, evbuffer\+::n\+\_\+del\+\_\+for\+\_\+cb, and evbuffer\+::total\+\_\+len.



Referenced by bufferevent\+\_\+read\+\_\+buffer(), bufferevent\+\_\+write\+\_\+buffer(), evbuffer\+\_\+add\+\_\+file(), evbuffer\+\_\+remove\+\_\+buffer(), and evhttp\+\_\+send\+\_\+reply\+\_\+chunk().

\hypertarget{buffer_8h_aa2a1509845c3d71f0adac4198aab0bf7}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+add\+\_\+cb@{evbuffer\+\_\+add\+\_\+cb}}
\index{evbuffer\+\_\+add\+\_\+cb@{evbuffer\+\_\+add\+\_\+cb}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+add\+\_\+cb}]{\setlength{\rightskip}{0pt plus 5cm}struct {\bf evbuffer\+\_\+cb\+\_\+entry}$\ast$ evbuffer\+\_\+add\+\_\+cb (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{{\bf evbuffer\+\_\+cb\+\_\+func}}]{cb, }
\item[{void $\ast$}]{cbarg}
\end{DoxyParamCaption}
)}}\label{buffer_8h_aa2a1509845c3d71f0adac4198aab0bf7}


Add a new callback to an evbuffer. 

Subsequent calls to \hyperlink{buffer_8h_aa2a1509845c3d71f0adac4198aab0bf7}{evbuffer\+\_\+add\+\_\+cb()} add new callbacks. To remove this callback, call evbuffer\+\_\+remove\+\_\+cb or evbuffer\+\_\+remove\+\_\+cb\+\_\+entry.


\begin{DoxyParams}{Parameters}
{\em buffer} & the evbuffer to be monitored \\
\hline
{\em cb} & the callback function to invoke when the evbuffer is modified, or N\+U\+L\+L to remove all callbacks. \\
\hline
{\em cbarg} & an argument to be provided to the callback function \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a handle to the callback on success, or N\+U\+L\+L on failure. 
\end{DoxyReturn}


References evbuffer\+\_\+cb\+\_\+entry\+::cb, evbuffer\+\_\+cb\+\_\+entry\+::cbarg, E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+C\+B\+\_\+\+E\+N\+A\+B\+L\+E\+D, and evbuffer\+\_\+cb\+\_\+entry\+::flags.



Referenced by bufferevent\+\_\+filter\+\_\+new(), bufferevent\+\_\+setwatermark(), bufferevent\+\_\+socket\+\_\+new(), and evbuffer\+\_\+setcb().

\hypertarget{buffer_8h_a5db7e9063755accc56fdad87d662743e}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+add\+\_\+file@{evbuffer\+\_\+add\+\_\+file}}
\index{evbuffer\+\_\+add\+\_\+file@{evbuffer\+\_\+add\+\_\+file}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+add\+\_\+file}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+add\+\_\+file (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{outbuf, }
\item[{int}]{fd, }
\item[{ev\+\_\+off\+\_\+t}]{offset, }
\item[{ev\+\_\+off\+\_\+t}]{length}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a5db7e9063755accc56fdad87d662743e}


Copy data from a file into the evbuffer for writing to a socket. 

This function avoids unnecessary data copies between userland and kernel. Where available, it uses sendfile or splice; failing those, it tries to use mmap.

The function owns the resulting file descriptor and will close it when finished transferring data.

The results of using \hyperlink{buffer_8h_a0455fc72c74c758ed8dc9a0902af451a}{evbuffer\+\_\+remove()} or \hyperlink{buffer_8h_a07df786553218ae3a7b0ebd2c9471a96}{evbuffer\+\_\+pullup()} on evbuffers whose data was added using this function are undefined.


\begin{DoxyParams}{Parameters}
{\em outbuf} & the output buffer \\
\hline
{\em fd} & the file descriptor \\
\hline
{\em offset} & the offset from which to read data \\
\hline
{\em length} & how much data to read \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, or -\/1 if an error occurred 
\end{DoxyReturn}


References evbuffer\+\_\+chain\+::buffer, evbuffer\+\_\+chain\+::buffer\+\_\+len, evbuffer\+\_\+add\+\_\+buffer(), evbuffer\+\_\+drain(), evbuffer\+\_\+free(), evbuffer\+\_\+new(), evbuffer\+\_\+chain\+\_\+fd\+::fd, evbuffer\+\_\+chain\+::flags, evbuffer\+::freeze\+\_\+end, evbuffer\+\_\+chain\+::misalign, evbuffer\+::n\+\_\+add\+\_\+for\+\_\+cb, and evbuffer\+\_\+chain\+::off.

\hypertarget{buffer_8h_adeb9457f344ddaf459726dbe348ac3db}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+add\+\_\+printf@{evbuffer\+\_\+add\+\_\+printf}}
\index{evbuffer\+\_\+add\+\_\+printf@{evbuffer\+\_\+add\+\_\+printf}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+add\+\_\+printf}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+add\+\_\+printf (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{const char $\ast$}]{fmt, }
\item[{}]{...}
\end{DoxyParamCaption}
)}}\label{buffer_8h_adeb9457f344ddaf459726dbe348ac3db}


Append a formatted string to the end of an evbuffer. 

The string is formated as printf.


\begin{DoxyParams}{Parameters}
{\em buf} & the evbuffer that will be appended to \\
\hline
{\em fmt} & a format string \\
\hline
{\em ...} & arguments that will be passed to printf(3) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The number of bytes added if successful, or -\/1 if an error occurred.
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
evutil\+\_\+printf(), \hyperlink{buffer_8h_acc385568d5129d4af10486b641b98f81}{evbuffer\+\_\+add\+\_\+vprintf()} 
\end{DoxySeeAlso}


References evbuffer\+\_\+add\+\_\+vprintf().



Referenced by evhttp\+\_\+send\+\_\+error(), evhttp\+\_\+send\+\_\+reply\+\_\+chunk(), evhttp\+\_\+uri\+\_\+join(), and evhttp\+\_\+uriencode().

\hypertarget{buffer_8h_a8a61b06a97974a86853becb9110b2ffd}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+add\+\_\+reference@{evbuffer\+\_\+add\+\_\+reference}}
\index{evbuffer\+\_\+add\+\_\+reference@{evbuffer\+\_\+add\+\_\+reference}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+add\+\_\+reference}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+add\+\_\+reference (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{outbuf, }
\item[{const void $\ast$}]{data, }
\item[{size\+\_\+t}]{datlen, }
\item[{{\bf evbuffer\+\_\+ref\+\_\+cleanup\+\_\+cb}}]{cleanupfn, }
\item[{void $\ast$}]{cleanupfn\+\_\+arg}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a8a61b06a97974a86853becb9110b2ffd}


Reference memory into an evbuffer without copying. 

The memory needs to remain valid until all the added data has been read. This function keeps just a reference to the memory without actually incurring the overhead of a copy.


\begin{DoxyParams}{Parameters}
{\em outbuf} & the output buffer \\
\hline
{\em data} & the memory to reference \\
\hline
{\em datlen} & how memory to reference \\
\hline
{\em cleanupfn} & callback to be invoked when the memory is no longer referenced by this evbuffer. \\
\hline
{\em cleanupfn\+\_\+arg} & optional argument to the cleanup callback \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, or -\/1 if an error occurred 
\end{DoxyReturn}


References evbuffer\+\_\+chain\+::buffer, evbuffer\+\_\+chain\+::buffer\+\_\+len, evbuffer\+\_\+chain\+::flags, evbuffer\+::freeze\+\_\+end, evbuffer\+::n\+\_\+add\+\_\+for\+\_\+cb, and evbuffer\+\_\+chain\+::off.

\hypertarget{buffer_8h_acc385568d5129d4af10486b641b98f81}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+add\+\_\+vprintf@{evbuffer\+\_\+add\+\_\+vprintf}}
\index{evbuffer\+\_\+add\+\_\+vprintf@{evbuffer\+\_\+add\+\_\+vprintf}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+add\+\_\+vprintf}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+add\+\_\+vprintf (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{const char $\ast$}]{fmt, }
\item[{va\+\_\+list}]{ap}
\end{DoxyParamCaption}
)}}\label{buffer_8h_acc385568d5129d4af10486b641b98f81}


Append a va\+\_\+list formatted string to the end of an evbuffer. 


\begin{DoxyParams}{Parameters}
{\em buf} & the evbuffer that will be appended to \\
\hline
{\em fmt} & a format string \\
\hline
{\em ap} & a varargs va\+\_\+list argument array that will be passed to vprintf(3) \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The number of bytes added if successful, or -\/1 if an error occurred. 
\end{DoxyReturn}


References evbuffer\+\_\+chain\+::buffer, evbuffer\+\_\+chain\+::buffer\+\_\+len, evutil\+\_\+vsnprintf(), evbuffer\+::freeze\+\_\+end, evbuffer\+\_\+chain\+::misalign, evbuffer\+::n\+\_\+add\+\_\+for\+\_\+cb, evbuffer\+\_\+chain\+::off, and evbuffer\+::total\+\_\+len.



Referenced by evbuffer\+\_\+add\+\_\+printf().

\hypertarget{buffer_8h_acda56baecd4b512f4e9f54a21e39177f}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+cb\+\_\+clear\+\_\+flags@{evbuffer\+\_\+cb\+\_\+clear\+\_\+flags}}
\index{evbuffer\+\_\+cb\+\_\+clear\+\_\+flags@{evbuffer\+\_\+cb\+\_\+clear\+\_\+flags}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+cb\+\_\+clear\+\_\+flags}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+cb\+\_\+clear\+\_\+flags (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{struct {\bf evbuffer\+\_\+cb\+\_\+entry} $\ast$}]{cb, }
\item[{ev\+\_\+uint32\+\_\+t}]{flags}
\end{DoxyParamCaption}
)}}\label{buffer_8h_acda56baecd4b512f4e9f54a21e39177f}


Change the flags that are set for a callback on a buffer by removing some. 


\begin{DoxyParams}{Parameters}
{\em buffer} & the evbuffer that the callback is watching. \\
\hline
{\em cb} & the callback whose status we want to change. \\
\hline
{\em flags} & E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+C\+B\+\_\+\+E\+N\+A\+B\+L\+E\+D to disable the callback. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, -\/1 on failure. 
\end{DoxyReturn}


References evbuffer\+\_\+cb\+\_\+entry\+::flags.



Referenced by bufferevent\+\_\+setwatermark().

\hypertarget{buffer_8h_a4ba44d01484f19fbfe7c18d2a175dc3b}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+cb\+\_\+set\+\_\+flags@{evbuffer\+\_\+cb\+\_\+set\+\_\+flags}}
\index{evbuffer\+\_\+cb\+\_\+set\+\_\+flags@{evbuffer\+\_\+cb\+\_\+set\+\_\+flags}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+cb\+\_\+set\+\_\+flags}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+cb\+\_\+set\+\_\+flags (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{struct {\bf evbuffer\+\_\+cb\+\_\+entry} $\ast$}]{cb, }
\item[{ev\+\_\+uint32\+\_\+t}]{flags}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a4ba44d01484f19fbfe7c18d2a175dc3b}


Change the flags that are set for a callback on a buffer by adding more. 


\begin{DoxyParams}{Parameters}
{\em buffer} & the evbuffer that the callback is watching. \\
\hline
{\em cb} & the callback whose status we want to change. \\
\hline
{\em flags} & E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+C\+B\+\_\+\+E\+N\+A\+B\+L\+E\+D to re-\/enable the callback. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, -\/1 on failure. 
\end{DoxyReturn}


References evbuffer\+\_\+cb\+\_\+entry\+::flags.



Referenced by bufferevent\+\_\+setwatermark().

\hypertarget{buffer_8h_a7a13a10fd1eb75cccf0ca29a05c5ba8a}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+commit\+\_\+space@{evbuffer\+\_\+commit\+\_\+space}}
\index{evbuffer\+\_\+commit\+\_\+space@{evbuffer\+\_\+commit\+\_\+space}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+commit\+\_\+space}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+commit\+\_\+space (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{struct {\bf evbuffer\+\_\+iovec} $\ast$}]{vec, }
\item[{int}]{n\+\_\+vecs}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a7a13a10fd1eb75cccf0ca29a05c5ba8a}


Commits previously reserved space. 

Commits some of the space previously reserved with \hyperlink{buffer_8h_ada49b2dc41bb09bb011765c1fc826a5d}{evbuffer\+\_\+reserve\+\_\+space()}. It then becomes available for reading.

This function may return an error if the pointer in the extents do not match those returned from evbuffer\+\_\+reserve\+\_\+space, or if data has been added to the buffer since the space was reserved.

If you want to commit less data than you got reserved space for, modify the iov\+\_\+len pointer of the appropriate extent to a smaller value. Note that you may have received more space than you requested if it was available!


\begin{DoxyParams}{Parameters}
{\em buf} & the evbuffer in which to reserve space. \\
\hline
{\em vec} & one or two extents returned by evbuffer\+\_\+reserve\+\_\+space. \\
\hline
{\em n\+\_\+vecs} & the number of extents. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, -\/1 on error 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{buffer_8h_ada49b2dc41bb09bb011765c1fc826a5d}{evbuffer\+\_\+reserve\+\_\+space()} 
\end{DoxySeeAlso}


References evbuffer\+::freeze\+\_\+end, evbuffer\+\_\+iovec\+::iov\+\_\+base, evbuffer\+\_\+iovec\+::iov\+\_\+len, evbuffer\+::last, evbuffer\+::last\+\_\+with\+\_\+datap, evbuffer\+::n\+\_\+add\+\_\+for\+\_\+cb, evbuffer\+\_\+chain\+::next, evbuffer\+\_\+chain\+::off, and evbuffer\+::total\+\_\+len.

\hypertarget{buffer_8h_a8fa753475570f6529691ef8484cacc1b}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+copyout@{evbuffer\+\_\+copyout}}
\index{evbuffer\+\_\+copyout@{evbuffer\+\_\+copyout}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+copyout}]{\setlength{\rightskip}{0pt plus 5cm}ev\+\_\+ssize\+\_\+t evbuffer\+\_\+copyout (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{void $\ast$}]{data\+\_\+out, }
\item[{size\+\_\+t}]{datlen}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a8fa753475570f6529691ef8484cacc1b}


Read data from an evbuffer, and leave the buffer unchanged. 

If more bytes are requested than are available in the evbuffer, we only extract as many bytes as were available.


\begin{DoxyParams}{Parameters}
{\em buf} & the evbuffer to be read from \\
\hline
{\em data\+\_\+out} & the destination buffer to store the result \\
\hline
{\em datlen} & the maximum size of the destination buffer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes read, or -\/1 if we can't drain the buffer. 
\end{DoxyReturn}


References evbuffer\+\_\+chain\+::buffer, evbuffer\+::first, evbuffer\+::freeze\+\_\+start, evbuffer\+\_\+chain\+::misalign, evbuffer\+\_\+chain\+::next, evbuffer\+\_\+chain\+::off, and evbuffer\+::total\+\_\+len.



Referenced by evbuffer\+\_\+remove().

\hypertarget{buffer_8h_a1c99c484430a81e641a783a273435074}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+defer\+\_\+callbacks@{evbuffer\+\_\+defer\+\_\+callbacks}}
\index{evbuffer\+\_\+defer\+\_\+callbacks@{evbuffer\+\_\+defer\+\_\+callbacks}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+defer\+\_\+callbacks}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+defer\+\_\+callbacks (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{struct {\bf event\+\_\+base} $\ast$}]{base}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a1c99c484430a81e641a783a273435074}


Force all the callbacks on an evbuffer to be run, not immediately after the evbuffer is altered, but instead from inside the event loop. 

This can be used to serialize all the callbacks to a single thread of execution. 

References evbuffer\+::cb\+\_\+queue, evbuffer\+::deferred, and evbuffer\+::deferred\+\_\+cbs.

\hypertarget{buffer_8h_a5c24f3bfbc941d693bf59b5d77d2c37f}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+drain@{evbuffer\+\_\+drain}}
\index{evbuffer\+\_\+drain@{evbuffer\+\_\+drain}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+drain}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+drain (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{size\+\_\+t}]{len}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a5c24f3bfbc941d693bf59b5d77d2c37f}


Remove a specified number of bytes data from the beginning of an evbuffer. 


\begin{DoxyParams}{Parameters}
{\em buf} & the evbuffer to be drained \\
\hline
{\em len} & the number of bytes to drain from the beginning of the buffer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, -\/1 on failure. 
\end{DoxyReturn}


References evbuffer\+::first, evbuffer\+::freeze\+\_\+start, evbuffer\+::last\+\_\+with\+\_\+datap, evbuffer\+\_\+chain\+::misalign, evbuffer\+::n\+\_\+del\+\_\+for\+\_\+cb, evbuffer\+\_\+chain\+::next, evbuffer\+\_\+chain\+::off, and evbuffer\+::total\+\_\+len.



Referenced by evbuffer\+\_\+add\+\_\+file(), evbuffer\+\_\+readln(), evbuffer\+\_\+remove(), and evbuffer\+\_\+write\+\_\+atmost().

\hypertarget{buffer_8h_a1bf21d715f288541eb670c5f159f2264}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+enable\+\_\+locking@{evbuffer\+\_\+enable\+\_\+locking}}
\index{evbuffer\+\_\+enable\+\_\+locking@{evbuffer\+\_\+enable\+\_\+locking}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+enable\+\_\+locking}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+enable\+\_\+locking (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{void $\ast$}]{lock}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a1bf21d715f288541eb670c5f159f2264}


Enable locking on an evbuffer so that it can safely be used by multiple threads at the same time. 

N\+O\+T\+E\+: when locking is enabled, the lock will be held when callbacks are invoked. This could result in deadlock if you aren't careful. Plan accordingly!


\begin{DoxyParams}{Parameters}
{\em buf} & An evbuffer to make lockable. \\
\hline
{\em lock} & A lock object, or N\+U\+L\+L if we should allocate our own. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, -\/1 on failure. 
\end{DoxyReturn}


References E\+V\+T\+H\+R\+E\+A\+D\+\_\+\+L\+O\+C\+K\+T\+Y\+P\+E\+\_\+\+R\+E\+C\+U\+R\+S\+I\+V\+E, evbuffer\+::lock, and evbuffer\+::own\+\_\+lock.

\hypertarget{buffer_8h_a305caf7b9bfb8713e6ef383d61791f95}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+expand@{evbuffer\+\_\+expand}}
\index{evbuffer\+\_\+expand@{evbuffer\+\_\+expand}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+expand}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+expand (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{size\+\_\+t}]{datlen}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a305caf7b9bfb8713e6ef383d61791f95}


Expands the available space in an evbuffer. 

Expands the available space in the evbuffer to at least datlen, so that appending datlen additional bytes will not require any new allocations.


\begin{DoxyParams}{Parameters}
{\em buf} & the evbuffer to be expanded \\
\hline
{\em datlen} & the new minimum length requirement \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, or -\/1 if an error occurred 
\end{DoxyReturn}
\hypertarget{buffer_8h_a0a87b43a5ae8c5589e77cde486b8a155}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+free@{evbuffer\+\_\+free}}
\index{evbuffer\+\_\+free@{evbuffer\+\_\+free}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+free}]{\setlength{\rightskip}{0pt plus 5cm}void evbuffer\+\_\+free (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a0a87b43a5ae8c5589e77cde486b8a155}


Deallocate storage for an evbuffer. 


\begin{DoxyParams}{Parameters}
{\em buf} & pointer to the evbuffer to be freed \\
\hline
\end{DoxyParams}


Referenced by evbuffer\+\_\+add\+\_\+file(), evbuffer\+\_\+launch\+\_\+read(), evbuffer\+\_\+launch\+\_\+write(), evhttp\+\_\+request\+\_\+free(), evhttp\+\_\+send\+\_\+error(), evhttp\+\_\+uri\+\_\+join(), and evhttp\+\_\+uriencode().

\hypertarget{buffer_8h_a8611ca97c720d4dd605e272cc4136684}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+freeze@{evbuffer\+\_\+freeze}}
\index{evbuffer\+\_\+freeze@{evbuffer\+\_\+freeze}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+freeze}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+freeze (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{int}]{at\+\_\+front}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a8611ca97c720d4dd605e272cc4136684}


Prevent calls that modify an evbuffer from succeeding. 

A buffer may frozen at the front, at the back, or at both the front and the back.

If the front of a buffer is frozen, operations that drain data from the front of the buffer, or that prepend data to the buffer, will fail until it is unfrozen. If the back a buffer is frozen, operations that append data from the buffer will fail until it is unfrozen.


\begin{DoxyParams}{Parameters}
{\em buf} & The buffer to freeze \\
\hline
{\em at\+\_\+front} & If true, we freeze the front of the buffer. If false, we freeze the back. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, -\/1 on failure. 
\end{DoxyReturn}


References evbuffer\+::freeze\+\_\+end, and evbuffer\+::freeze\+\_\+start.



Referenced by bufferevent\+\_\+pair\+\_\+new(), bufferevent\+\_\+socket\+\_\+new(), evbuffer\+\_\+launch\+\_\+read(), and evbuffer\+\_\+launch\+\_\+write().

\hypertarget{buffer_8h_acd3d8507991609637a501e835e450331}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+get\+\_\+contiguous\+\_\+space@{evbuffer\+\_\+get\+\_\+contiguous\+\_\+space}}
\index{evbuffer\+\_\+get\+\_\+contiguous\+\_\+space@{evbuffer\+\_\+get\+\_\+contiguous\+\_\+space}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+get\+\_\+contiguous\+\_\+space}]{\setlength{\rightskip}{0pt plus 5cm}size\+\_\+t evbuffer\+\_\+get\+\_\+contiguous\+\_\+space (
\begin{DoxyParamCaption}
\item[{const struct {\bf evbuffer} $\ast$}]{buf}
\end{DoxyParamCaption}
)}}\label{buffer_8h_acd3d8507991609637a501e835e450331}


Returns the number of contiguous available bytes in the first buffer chain. 

This is useful when processing data that might be split into multiple chains, or that might all be in the first chain. Calls to \hyperlink{buffer_8h_a07df786553218ae3a7b0ebd2c9471a96}{evbuffer\+\_\+pullup()} that cause reallocation and copying of data can thus be avoided.


\begin{DoxyParams}{Parameters}
{\em buf} & pointer to the evbuffer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if no data is available, otherwise the number of available bytes in the first buffer chain. 
\end{DoxyReturn}


References evbuffer\+::first, and evbuffer\+\_\+chain\+::off.

\hypertarget{buffer_8h_af1b44374d37735f3a90ae402eaeddf44}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+get\+\_\+length@{evbuffer\+\_\+get\+\_\+length}}
\index{evbuffer\+\_\+get\+\_\+length@{evbuffer\+\_\+get\+\_\+length}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+get\+\_\+length}]{\setlength{\rightskip}{0pt plus 5cm}size\+\_\+t evbuffer\+\_\+get\+\_\+length (
\begin{DoxyParamCaption}
\item[{const struct {\bf evbuffer} $\ast$}]{buf}
\end{DoxyParamCaption}
)}}\label{buffer_8h_af1b44374d37735f3a90ae402eaeddf44}


Returns the total number of bytes stored in the evbuffer. 


\begin{DoxyParams}{Parameters}
{\em buf} & pointer to the evbuffer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes stored in the evbuffer 
\end{DoxyReturn}


References evbuffer\+::total\+\_\+len.



Referenced by bufferevent\+\_\+setwatermark(), evhttp\+\_\+send\+\_\+reply\+\_\+chunk(), evhttp\+\_\+send\+\_\+reply\+\_\+end(), evhttp\+\_\+uri\+\_\+join(), evhttp\+\_\+uriencode(), and evtag\+\_\+unmarshal\+\_\+header().

\hypertarget{buffer_8h_af9542ca1ac381708c9b1450d91d168ec}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+lock@{evbuffer\+\_\+lock}}
\index{evbuffer\+\_\+lock@{evbuffer\+\_\+lock}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+lock}]{\setlength{\rightskip}{0pt plus 5cm}void evbuffer\+\_\+lock (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf}
\end{DoxyParamCaption}
)}}\label{buffer_8h_af9542ca1ac381708c9b1450d91d168ec}


Acquire the lock on an evbuffer. 

Has no effect if locking was not enabled with evbuffer\+\_\+enable\+\_\+locking. \hypertarget{buffer_8h_a8ebe44bfccd1d245cae17b1b7586092a}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+new@{evbuffer\+\_\+new}}
\index{evbuffer\+\_\+new@{evbuffer\+\_\+new}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+new}]{\setlength{\rightskip}{0pt plus 5cm}struct {\bf evbuffer}$\ast$ evbuffer\+\_\+new (
\begin{DoxyParamCaption}
\item[{void}]{}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a8ebe44bfccd1d245cae17b1b7586092a}


Allocate storage for a new evbuffer. 

\begin{DoxyReturn}{Returns}
a pointer to a newly allocated evbuffer struct, or N\+U\+L\+L if an error occurred 
\end{DoxyReturn}


References evbuffer\+::first, evbuffer\+::last\+\_\+with\+\_\+datap, and evbuffer\+::refcnt.



Referenced by evbuffer\+\_\+add\+\_\+file(), evhttp\+\_\+request\+\_\+new(), evhttp\+\_\+send\+\_\+error(), evhttp\+\_\+uri\+\_\+join(), evhttp\+\_\+uriencode(), and evrpc\+\_\+request\+\_\+done().

\hypertarget{buffer_8h_adf4b59974a0cb989b7091f0b8677d511}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+peek@{evbuffer\+\_\+peek}}
\index{evbuffer\+\_\+peek@{evbuffer\+\_\+peek}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+peek}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+peek (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{ev\+\_\+ssize\+\_\+t}]{len, }
\item[{struct {\bf evbuffer\+\_\+ptr} $\ast$}]{start\+\_\+at, }
\item[{struct {\bf evbuffer\+\_\+iovec} $\ast$}]{vec\+\_\+out, }
\item[{int}]{n\+\_\+vec}
\end{DoxyParamCaption}
)}}\label{buffer_8h_adf4b59974a0cb989b7091f0b8677d511}


\hyperlink{structFunction}{Function} to peek at data inside an evbuffer without removing it or copying it out. 

Pointers to the data are returned by filling the 'vec\+\_\+out' array with pointers to one or more extents of data inside the buffer.

The total data in the extents that you get back may be more than you requested (if there is more data last extent than you asked for), or less (if you do not provide enough evbuffer\+\_\+iovecs, or if the buffer does not have as much data as you asked to see).


\begin{DoxyParams}{Parameters}
{\em buffer} & the evbuffer to peek into, \\
\hline
{\em len} & the number of bytes to try to peek. If negative, we will try to fill as much of vec\+\_\+out as we can. \\
\hline
{\em start\+\_\+at} & an \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} indicating the point at which we should start looking for data. N\+U\+L\+L means, \char`\"{}\+At the start of the
   buffer.\char`\"{} \\
\hline
{\em vec\+\_\+out} & an array of \hyperlink{structevbuffer__iovec}{evbuffer\+\_\+iovec} \\
\hline
{\em n\+\_\+vec} & the length of vec\+\_\+out. If 0, we only count how many extents would be necessary to point to the requested amount of data. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
The number of extents needed. This may be less than n\+\_\+vec if we didn't need all the evbuffer\+\_\+iovecs we were given, or more than n\+\_\+vec if we would need more to return all the data that was requested. 
\end{DoxyReturn}


References evbuffer\+\_\+chain\+::buffer, evbuffer\+::first, evbuffer\+\_\+iovec\+::iov\+\_\+base, evbuffer\+\_\+iovec\+::iov\+\_\+len, evbuffer\+\_\+chain\+::misalign, evbuffer\+\_\+chain\+::next, and evbuffer\+\_\+chain\+::off.

\hypertarget{buffer_8h_a0daf99dbc837953427b60c462e5eba97}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+prepend@{evbuffer\+\_\+prepend}}
\index{evbuffer\+\_\+prepend@{evbuffer\+\_\+prepend}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+prepend}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+prepend (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{const void $\ast$}]{data, }
\item[{size\+\_\+t}]{size}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a0daf99dbc837953427b60c462e5eba97}


Prepends data to the beginning of the evbuffer. 


\begin{DoxyParams}{Parameters}
{\em buf} & the evbuffer to which to prepend data \\
\hline
{\em data} & a pointer to the memory to prepend \\
\hline
{\em size} & the number of bytes to prepend \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, or -\/1 otherwise 
\end{DoxyReturn}


References evbuffer\+\_\+chain\+::buffer, evbuffer\+\_\+chain\+::buffer\+\_\+len, evbuffer\+::first, evbuffer\+\_\+chain\+::flags, evbuffer\+::freeze\+\_\+start, evbuffer\+::last\+\_\+with\+\_\+datap, evbuffer\+\_\+chain\+::misalign, evbuffer\+::n\+\_\+add\+\_\+for\+\_\+cb, evbuffer\+\_\+chain\+::next, evbuffer\+\_\+chain\+::off, and evbuffer\+::total\+\_\+len.

\hypertarget{buffer_8h_a80ea4326ada348edc0e4fb53ad1df80c}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+prepend\+\_\+buffer@{evbuffer\+\_\+prepend\+\_\+buffer}}
\index{evbuffer\+\_\+prepend\+\_\+buffer@{evbuffer\+\_\+prepend\+\_\+buffer}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+prepend\+\_\+buffer}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+prepend\+\_\+buffer (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{dst, }
\item[{struct {\bf evbuffer} $\ast$}]{src}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a80ea4326ada348edc0e4fb53ad1df80c}


Prepends all data from the src evbuffer to the beginning of the dst evbuffer. 


\begin{DoxyParams}{Parameters}
{\em dst} & the evbuffer to which to prepend data \\
\hline
{\em src} & the evbuffer to prepend; it will be emptied as a result \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 if successful, or -\/1 otherwise 
\end{DoxyReturn}


References evbuffer\+::first, evbuffer\+::freeze\+\_\+start, evbuffer\+::n\+\_\+add\+\_\+for\+\_\+cb, evbuffer\+::n\+\_\+del\+\_\+for\+\_\+cb, and evbuffer\+::total\+\_\+len.

\hypertarget{buffer_8h_a83ea16ab8facba6c68d2e6931d13fbf4}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+ptr\+\_\+set@{evbuffer\+\_\+ptr\+\_\+set}}
\index{evbuffer\+\_\+ptr\+\_\+set@{evbuffer\+\_\+ptr\+\_\+set}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+ptr\+\_\+set}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+ptr\+\_\+set (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{struct {\bf evbuffer\+\_\+ptr} $\ast$}]{ptr, }
\item[{size\+\_\+t}]{position, }
\item[{enum {\bf evbuffer\+\_\+ptr\+\_\+how}}]{how}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a83ea16ab8facba6c68d2e6931d13fbf4}


Sets the search pointer in the buffer to position. 

If \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} is not initialized. This function can only be called with E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+S\+E\+T.


\begin{DoxyParams}{Parameters}
{\em buffer} & the evbuffer to be search \\
\hline
{\em ptr} & a pointer to a struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} \\
\hline
{\em position} & the position at which to start the next search \\
\hline
{\em how} & determines how the pointer should be manipulated. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success or -\/1 otherwise 
\end{DoxyReturn}


References E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+A\+D\+D, E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+S\+E\+T, evbuffer\+::first, evbuffer\+\_\+chain\+::next, and evbuffer\+\_\+chain\+::off.



Referenced by evbuffer\+\_\+search\+\_\+eol().

\hypertarget{buffer_8h_a07df786553218ae3a7b0ebd2c9471a96}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+pullup@{evbuffer\+\_\+pullup}}
\index{evbuffer\+\_\+pullup@{evbuffer\+\_\+pullup}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+pullup}]{\setlength{\rightskip}{0pt plus 5cm}unsigned char$\ast$ evbuffer\+\_\+pullup (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{ev\+\_\+ssize\+\_\+t}]{size}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a07df786553218ae3a7b0ebd2c9471a96}


Makes the data at the begging of an evbuffer contiguous. 


\begin{DoxyParams}{Parameters}
{\em buf} & the evbuffer to make contiguous \\
\hline
{\em size} & the number of bytes to make contiguous, or -\/1 to make the entire buffer contiguous. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a pointer to the contiguous memory array 
\end{DoxyReturn}


References evbuffer\+\_\+chain\+::buffer, evbuffer\+\_\+chain\+::buffer\+\_\+len, evbuffer\+::first, evbuffer\+::last, evbuffer\+::last\+\_\+with\+\_\+datap, evbuffer\+\_\+chain\+::misalign, evbuffer\+\_\+chain\+::next, evbuffer\+\_\+chain\+::off, and evbuffer\+::total\+\_\+len.



Referenced by evbuffer\+\_\+find(), and evbuffer\+\_\+write\+\_\+atmost().

\hypertarget{buffer_8h_a464aff577b05417171192fc68539b77e}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+read@{evbuffer\+\_\+read}}
\index{evbuffer\+\_\+read@{evbuffer\+\_\+read}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+read}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+read (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{{\bf evutil\+\_\+socket\+\_\+t}}]{fd, }
\item[{int}]{howmuch}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a464aff577b05417171192fc68539b77e}


Read from a file descriptor and store the result in an evbuffer. 


\begin{DoxyParams}{Parameters}
{\em buffer} & the evbuffer to store the result \\
\hline
{\em fd} & the file descriptor to read from \\
\hline
{\em howmuch} & the number of bytes to be read \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes read, or -\/1 if an error occurred 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{buffer_8h_a1207167bb14d5333326225f41477e910}{evbuffer\+\_\+write()} 
\end{DoxySeeAlso}
U\+S\+E\+\_\+\+I\+O\+V\+E\+C\+\_\+\+I\+M\+P\+L 

References evbuffer\+\_\+chain\+::buffer, evbuffer\+::freeze\+\_\+end, evbuffer\+::last\+\_\+with\+\_\+datap, evbuffer\+\_\+chain\+::misalign, evbuffer\+::n\+\_\+add\+\_\+for\+\_\+cb, evbuffer\+\_\+chain\+::next, evbuffer\+\_\+chain\+::off, and evbuffer\+::total\+\_\+len.

\hypertarget{buffer_8h_ae2460b5060948d3233342c4c81888650}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+readln@{evbuffer\+\_\+readln}}
\index{evbuffer\+\_\+readln@{evbuffer\+\_\+readln}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+readln}]{\setlength{\rightskip}{0pt plus 5cm}char$\ast$ evbuffer\+\_\+readln (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{size\+\_\+t $\ast$}]{n\+\_\+read\+\_\+out, }
\item[{enum {\bf evbuffer\+\_\+eol\+\_\+style}}]{eol\+\_\+style}
\end{DoxyParamCaption}
)}}\label{buffer_8h_ae2460b5060948d3233342c4c81888650}


Read a single line from an evbuffer. 

Reads a line terminated by an E\+O\+L as determined by the evbuffer\+\_\+eol\+\_\+style argument. Returns a newly allocated nul-\/terminated string; the caller must free the returned value. The E\+O\+L is not included in the returned string.


\begin{DoxyParams}{Parameters}
{\em buffer} & the evbuffer to read from \\
\hline
{\em n\+\_\+read\+\_\+out} & if non-\/\+N\+U\+L\+L, points to a size\+\_\+t that is set to the number of characters in the returned string. This is useful for strings that can contain N\+U\+L characters. \\
\hline
{\em eol\+\_\+style} & the style of line-\/ending to use. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
pointer to a single line, or N\+U\+L\+L if an error occurred 
\end{DoxyReturn}


References evbuffer\+\_\+drain(), evbuffer\+\_\+remove(), evbuffer\+\_\+search\+\_\+eol(), and evbuffer\+::freeze\+\_\+start.



Referenced by evbuffer\+\_\+readline().

\hypertarget{buffer_8h_a0455fc72c74c758ed8dc9a0902af451a}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+remove@{evbuffer\+\_\+remove}}
\index{evbuffer\+\_\+remove@{evbuffer\+\_\+remove}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+remove}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+remove (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{void $\ast$}]{data, }
\item[{size\+\_\+t}]{datlen}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a0455fc72c74c758ed8dc9a0902af451a}


Read data from an evbuffer and drain the bytes read. 

If more bytes are requested than are available in the evbuffer, we only extract as many bytes as were available.


\begin{DoxyParams}{Parameters}
{\em buf} & the evbuffer to be read from \\
\hline
{\em data} & the destination buffer to store the result \\
\hline
{\em datlen} & the maximum size of the destination buffer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes read, or -\/1 if we can't drain the buffer. 
\end{DoxyReturn}


References evbuffer\+\_\+copyout(), and evbuffer\+\_\+drain().



Referenced by bufferevent\+\_\+read(), evbuffer\+\_\+readln(), evhttp\+\_\+uri\+\_\+join(), and evhttp\+\_\+uriencode().

\hypertarget{buffer_8h_a0bdef97f6a142425b271b329a90de869}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+remove\+\_\+buffer@{evbuffer\+\_\+remove\+\_\+buffer}}
\index{evbuffer\+\_\+remove\+\_\+buffer@{evbuffer\+\_\+remove\+\_\+buffer}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+remove\+\_\+buffer}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+remove\+\_\+buffer (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{src, }
\item[{struct {\bf evbuffer} $\ast$}]{dst, }
\item[{size\+\_\+t}]{datlen}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a0bdef97f6a142425b271b329a90de869}


Read data from an evbuffer into another evbuffer, draining the bytes from the source buffer. 

This function avoids copy operations to the extent possible.

If more bytes are requested than are available in src, the src buffer is drained completely.


\begin{DoxyParams}{Parameters}
{\em src} & the evbuffer to be read from \\
\hline
{\em dst} & the destination evbuffer to store the result into \\
\hline
{\em datlen} & the maximum numbers of bytes to transfer \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes read 
\end{DoxyReturn}


References evbuffer\+\_\+chain\+::buffer, evbuffer\+\_\+add(), evbuffer\+\_\+add\+\_\+buffer(), evbuffer\+::first, evbuffer\+::freeze\+\_\+end, evbuffer\+::freeze\+\_\+start, evbuffer\+::last, evbuffer\+::last\+\_\+with\+\_\+datap, evbuffer\+\_\+chain\+::misalign, evbuffer\+::n\+\_\+add\+\_\+for\+\_\+cb, evbuffer\+::n\+\_\+del\+\_\+for\+\_\+cb, evbuffer\+\_\+chain\+::next, evbuffer\+\_\+chain\+::off, and evbuffer\+::total\+\_\+len.

\hypertarget{buffer_8h_a4d7c75045267863306d37043d3f0809a}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+remove\+\_\+cb@{evbuffer\+\_\+remove\+\_\+cb}}
\index{evbuffer\+\_\+remove\+\_\+cb@{evbuffer\+\_\+remove\+\_\+cb}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+remove\+\_\+cb}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+remove\+\_\+cb (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{{\bf evbuffer\+\_\+cb\+\_\+func}}]{cb, }
\item[{void $\ast$}]{cbarg}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a4d7c75045267863306d37043d3f0809a}


Remove a callback from an evbuffer, given the function and argument used to add it. 

\begin{DoxyReturn}{Returns}
0 if a callback was removed, or -\/1 if no matching callback was found. 
\end{DoxyReturn}


References evbuffer\+\_\+cb\+\_\+entry\+::cb, evbuffer\+\_\+cb\+\_\+entry\+::cbarg, and evbuffer\+\_\+remove\+\_\+cb\+\_\+entry().

\hypertarget{buffer_8h_afd1e51be92170b17178949a639dfa8ab}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+remove\+\_\+cb\+\_\+entry@{evbuffer\+\_\+remove\+\_\+cb\+\_\+entry}}
\index{evbuffer\+\_\+remove\+\_\+cb\+\_\+entry@{evbuffer\+\_\+remove\+\_\+cb\+\_\+entry}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+remove\+\_\+cb\+\_\+entry}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+remove\+\_\+cb\+\_\+entry (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{struct {\bf evbuffer\+\_\+cb\+\_\+entry} $\ast$}]{ent}
\end{DoxyParamCaption}
)}}\label{buffer_8h_afd1e51be92170b17178949a639dfa8ab}


Remove a callback from an evbuffer, given a handle returned from evbuffer\+\_\+add\+\_\+cb. 

Calling this function invalidates the handle.

\begin{DoxyReturn}{Returns}
0 if a callback was removed, or -\/1 if no matching callback was found. 
\end{DoxyReturn}


Referenced by evbuffer\+\_\+remove\+\_\+cb().

\hypertarget{buffer_8h_ada49b2dc41bb09bb011765c1fc826a5d}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+reserve\+\_\+space@{evbuffer\+\_\+reserve\+\_\+space}}
\index{evbuffer\+\_\+reserve\+\_\+space@{evbuffer\+\_\+reserve\+\_\+space}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+reserve\+\_\+space}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+reserve\+\_\+space (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{ev\+\_\+ssize\+\_\+t}]{size, }
\item[{struct {\bf evbuffer\+\_\+iovec} $\ast$}]{vec, }
\item[{int}]{n\+\_\+vec}
\end{DoxyParamCaption}
)}}\label{buffer_8h_ada49b2dc41bb09bb011765c1fc826a5d}


Reserves space in the last chain or chains of an evbuffer. 

Makes space available in the last chain or chains of an evbuffer that can be arbitrarily written to by a user. The space does not become available for reading until it has been committed with \hyperlink{buffer_8h_a7a13a10fd1eb75cccf0ca29a05c5ba8a}{evbuffer\+\_\+commit\+\_\+space()}.

The space is made available as one or more extents, represented by an initial pointer and a length. You can force the memory to be available as only one extent. Allowing more extents, however, makes the function more efficient.

Multiple subsequent calls to this function will make the same space available until \hyperlink{buffer_8h_a7a13a10fd1eb75cccf0ca29a05c5ba8a}{evbuffer\+\_\+commit\+\_\+space()} has been called.

It is an error to do anything that moves around the buffer's internal memory structures before committing the space.

N\+O\+T\+E\+: The code currently does not ever use more than two extents. This may change in future versions.


\begin{DoxyParams}{Parameters}
{\em buf} & the evbuffer in which to reserve space. \\
\hline
{\em size} & how much space to make available, at minimum. The total length of the extents may be greater than the requested length. \\
\hline
{\em vec} & an array of one or more \hyperlink{structevbuffer__iovec}{evbuffer\+\_\+iovec} structures to hold pointers to the reserved extents of memory. \\
\hline
{\em n\+\_\+vec} & The length of the vec array. Must be at least 1; 2 is more efficient. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of provided extents, or -\/1 on error. 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{buffer_8h_a7a13a10fd1eb75cccf0ca29a05c5ba8a}{evbuffer\+\_\+commit\+\_\+space()} 
\end{DoxySeeAlso}


References evbuffer\+::freeze\+\_\+end, evbuffer\+\_\+iovec\+::iov\+\_\+base, and evbuffer\+\_\+iovec\+::iov\+\_\+len.

\hypertarget{buffer_8h_a61e15e2a355409587464c476d2481105}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+search@{evbuffer\+\_\+search}}
\index{evbuffer\+\_\+search@{evbuffer\+\_\+search}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+search}]{\setlength{\rightskip}{0pt plus 5cm}struct {\bf evbuffer\+\_\+ptr} evbuffer\+\_\+search (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{const char $\ast$}]{what, }
\item[{size\+\_\+t}]{len, }
\item[{const struct {\bf evbuffer\+\_\+ptr} $\ast$}]{start}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a61e15e2a355409587464c476d2481105}


Search for a string within an evbuffer. 


\begin{DoxyParams}{Parameters}
{\em buffer} & the evbuffer to be searched \\
\hline
{\em what} & the string to be searched for \\
\hline
{\em len} & the length of the search string \\
\hline
{\em start} & N\+U\+L\+L or a pointer to a valid struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr}. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} whose 'pos' field has the offset of the first occurrence of the string in the buffer after 'start'. The 'pos' field of the result is -\/1 if the string was not found. 
\end{DoxyReturn}


References evbuffer\+\_\+search\+\_\+range().



Referenced by evbuffer\+\_\+find(), and evbuffer\+\_\+search\+\_\+eol().

\hypertarget{buffer_8h_aa54aca588fa272157513191a9628d457}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+search\+\_\+eol@{evbuffer\+\_\+search\+\_\+eol}}
\index{evbuffer\+\_\+search\+\_\+eol@{evbuffer\+\_\+search\+\_\+eol}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+search\+\_\+eol}]{\setlength{\rightskip}{0pt plus 5cm}struct {\bf evbuffer\+\_\+ptr} evbuffer\+\_\+search\+\_\+eol (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{struct {\bf evbuffer\+\_\+ptr} $\ast$}]{start, }
\item[{size\+\_\+t $\ast$}]{eol\+\_\+len\+\_\+out, }
\item[{enum {\bf evbuffer\+\_\+eol\+\_\+style}}]{eol\+\_\+style}
\end{DoxyParamCaption}
)}}\label{buffer_8h_aa54aca588fa272157513191a9628d457}


Search for an end-\/of-\/line string within an evbuffer. 


\begin{DoxyParams}{Parameters}
{\em buffer} & the evbuffer to be searched \\
\hline
{\em start} & N\+U\+L\+L or a pointer to a valid struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} to start searching at. \\
\hline
{\em eol\+\_\+len\+\_\+out} & If non-\/\+N\+U\+L\+L, the pointed-\/to value will be set to the length of the end-\/of-\/line string. \\
\hline
{\em eol\+\_\+style} & The kind of E\+O\+L to look for; see \hyperlink{buffer_8h_ae2460b5060948d3233342c4c81888650}{evbuffer\+\_\+readln()} for more information \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} whose 'pos' field has the offset of the first occurrence E\+O\+L in the buffer after 'start'. The 'pos' field of the result is -\/1 if the string was not found. 
\end{DoxyReturn}


References E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+A\+N\+Y, E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F, E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+C\+R\+L\+F\+\_\+\+S\+T\+R\+I\+C\+T, E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+E\+O\+L\+\_\+\+L\+F, E\+V\+B\+U\+F\+F\+E\+R\+\_\+\+P\+T\+R\+\_\+\+A\+D\+D, evbuffer\+\_\+ptr\+\_\+set(), and evbuffer\+\_\+search().



Referenced by evbuffer\+\_\+readln().

\hypertarget{buffer_8h_a532ded8162d838b306e18839e9ab04af}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+search\+\_\+range@{evbuffer\+\_\+search\+\_\+range}}
\index{evbuffer\+\_\+search\+\_\+range@{evbuffer\+\_\+search\+\_\+range}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+search\+\_\+range}]{\setlength{\rightskip}{0pt plus 5cm}struct {\bf evbuffer\+\_\+ptr} evbuffer\+\_\+search\+\_\+range (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{const char $\ast$}]{what, }
\item[{size\+\_\+t}]{len, }
\item[{const struct {\bf evbuffer\+\_\+ptr} $\ast$}]{start, }
\item[{const struct {\bf evbuffer\+\_\+ptr} $\ast$}]{end}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a532ded8162d838b306e18839e9ab04af}


Search for a string within part of an evbuffer. 


\begin{DoxyParams}{Parameters}
{\em buffer} & the evbuffer to be searched \\
\hline
{\em what} & the string to be searched for \\
\hline
{\em len} & the length of the search string \\
\hline
{\em start} & N\+U\+L\+L or a pointer to a valid struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} that indicates where we should start searching. \\
\hline
{\em end} & N\+U\+L\+L or a pointer to a valid struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} that indicates where we should stop searching. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
a struct \hyperlink{structevbuffer__ptr}{evbuffer\+\_\+ptr} whose 'pos' field has the offset of the first occurrence of the string in the buffer after 'start'. The 'pos' field of the result is -\/1 if the string was not found. 
\end{DoxyReturn}


References evbuffer\+\_\+chain\+::buffer, evbuffer\+\_\+chain\+::misalign, evbuffer\+\_\+chain\+::next, and evbuffer\+\_\+chain\+::off.



Referenced by evbuffer\+\_\+search().

\hypertarget{buffer_8h_a0aceee5e8d8443df6d1b5daeb4daacfd}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+unfreeze@{evbuffer\+\_\+unfreeze}}
\index{evbuffer\+\_\+unfreeze@{evbuffer\+\_\+unfreeze}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+unfreeze}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+unfreeze (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf, }
\item[{int}]{at\+\_\+front}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a0aceee5e8d8443df6d1b5daeb4daacfd}


Re-\/enable calls that modify an evbuffer. 


\begin{DoxyParams}{Parameters}
{\em buf} & The buffer to un-\/freeze \\
\hline
{\em at\+\_\+front} & If true, we unfreeze the front of the buffer. If false, we unfreeze the back. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
0 on success, -\/1 on failure. 
\end{DoxyReturn}


References evbuffer\+::freeze\+\_\+end, and evbuffer\+::freeze\+\_\+start.



Referenced by evbuffer\+\_\+commit\+\_\+read(), evbuffer\+\_\+launch\+\_\+read(), and evbuffer\+\_\+launch\+\_\+write().

\hypertarget{buffer_8h_a538b62549df58369e10fd5703cafe92b}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+unlock@{evbuffer\+\_\+unlock}}
\index{evbuffer\+\_\+unlock@{evbuffer\+\_\+unlock}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+unlock}]{\setlength{\rightskip}{0pt plus 5cm}void evbuffer\+\_\+unlock (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buf}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a538b62549df58369e10fd5703cafe92b}


Release the lock on an evbuffer. 

Has no effect if locking was not enabled with evbuffer\+\_\+enable\+\_\+locking. \hypertarget{buffer_8h_a1207167bb14d5333326225f41477e910}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+write@{evbuffer\+\_\+write}}
\index{evbuffer\+\_\+write@{evbuffer\+\_\+write}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+write}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+write (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{{\bf evutil\+\_\+socket\+\_\+t}}]{fd}
\end{DoxyParamCaption}
)}}\label{buffer_8h_a1207167bb14d5333326225f41477e910}


Write the contents of an evbuffer to a file descriptor. 

The evbuffer will be drained after the bytes have been successfully written.


\begin{DoxyParams}{Parameters}
{\em buffer} & the evbuffer to be written and drained \\
\hline
{\em fd} & the file descriptor to be written to \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes written, or -\/1 if an error occurred 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{buffer_8h_a464aff577b05417171192fc68539b77e}{evbuffer\+\_\+read()} 
\end{DoxySeeAlso}


References evbuffer\+\_\+write\+\_\+atmost().

\hypertarget{buffer_8h_aa0bea512e82177762be7cf0a28a9b03b}{\index{buffer.\+h@{buffer.\+h}!evbuffer\+\_\+write\+\_\+atmost@{evbuffer\+\_\+write\+\_\+atmost}}
\index{evbuffer\+\_\+write\+\_\+atmost@{evbuffer\+\_\+write\+\_\+atmost}!buffer.\+h@{buffer.\+h}}
\subsubsection[{evbuffer\+\_\+write\+\_\+atmost}]{\setlength{\rightskip}{0pt plus 5cm}int evbuffer\+\_\+write\+\_\+atmost (
\begin{DoxyParamCaption}
\item[{struct {\bf evbuffer} $\ast$}]{buffer, }
\item[{{\bf evutil\+\_\+socket\+\_\+t}}]{fd, }
\item[{ev\+\_\+ssize\+\_\+t}]{howmuch}
\end{DoxyParamCaption}
)}}\label{buffer_8h_aa0bea512e82177762be7cf0a28a9b03b}


Write some of the contents of an evbuffer to a file descriptor. 

The evbuffer will be drained after the bytes have been successfully written.


\begin{DoxyParams}{Parameters}
{\em buffer} & the evbuffer to be written and drained \\
\hline
{\em fd} & the file descriptor to be written to \\
\hline
{\em howmuch} & the largest allowable number of bytes to write, or -\/1 to write as many bytes as we can. \\
\hline
\end{DoxyParams}
\begin{DoxyReturn}{Returns}
the number of bytes written, or -\/1 if an error occurred 
\end{DoxyReturn}
\begin{DoxySeeAlso}{See also}
\hyperlink{buffer_8h_a464aff577b05417171192fc68539b77e}{evbuffer\+\_\+read()} 
\end{DoxySeeAlso}


References evbuffer\+\_\+drain(), evbuffer\+\_\+pullup(), evbuffer\+::first, evbuffer\+\_\+chain\+::flags, evbuffer\+::freeze\+\_\+start, and evbuffer\+::total\+\_\+len.



Referenced by evbuffer\+\_\+write().

