Append data to the end of an evbuffer.
Parameters:
buf the evbuffer to be appended to
data pointer to the beginning of the data buffer
datlen the number of bytes to be copied from the data buffer
Returns:
0 on success, -1 on failure.
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.
Parameters:
outbuf the output buffer
inbuf the input buffer
Returns:
0 if successful, or -1 if an error occurred
See also:
evbuffer_remove_buffer()
Copy data from one evbuffer into another evbuffer. This is a non-destructive
  add. The data from one buffer is copied into the other buffer. However, no
  unnecessary memory copies occur.
Note that buffers already containing buffer references can't be
    added to other buffers.
Parameters:
outbuf the output buffer
inbuf the input buffer
Returns:
0 if successful, or -1 if an error occurred
Add a new callback to an evbuffer. Subsequent calls to evbuffer_add_cb()
  add new callbacks. To remove this callback, call evbuffer_remove_cb or
  evbuffer_remove_cb_entry.
Parameters:
buffer the evbuffer to be monitored
cb the callback function to invoke when the evbuffer is modified, or NULL
  to remove all callbacks.
cbarg an argument to be provided to the callback function
Returns:
a handle to the callback on success, or NULL on
  failure.
Copy data from a file into the evbuffer for writing to a socket. This function
  avoids unnecessary data copies between userland and kernel. If sendfile is
  available and the EVBUFFER_FLAG_DRAINS_TO_FD flag is set, it uses those
  functions. Otherwise, it tries to use mmap (or CreateFileMapping on Windows).
The function owns the resulting file descriptor and will close it
    when finished transferring data.
The results of using evbuffer_remove() or
    evbuffer_pullup() on evbuffers whose data was added using this
    function are undefined.
For more fine-grained control, use evbuffer_add_file_segment.
Parameters:
outbuf the output buffer
fd the file descriptor
offset the offset from which to read data
length how much data to read, or -1 to read as much as possible. (-1
  requires that 'fd' support fstat.)
Returns:
0 if successful, or -1 if an error occurred
Insert some or all of an evbuffer_file_segment at the end of an evbuffer. Note
  that the offset and length parameters of this function have a different
  meaning from those provided to evbuffer_file_segment_new: When you create the
  segment, the offset is the offset within the file, and the length is
  the length of the segment, whereas when you add a segment to an
  evbuffer, the offset is within the segment and the length is the length
  of the _part of the segment you want to use.
In other words, if you have a 10 KiB file, and you create an
    evbuffer_file_segment for it with offset 20 and length 1000, it will refer
    to bytes 20..1019 inclusive. If you then pass this segment to
    evbuffer_add_file_segment and specify an offset of 20 and a length of 50,
    you will be adding bytes 40..99 inclusive.
Parameters:
buf the evbuffer to append to
seg the segment to add
offset the offset within the segment to start from
length the amount of data to add, or -1 to add it all.
Returns:
0 on success, -1 on failure.
Append data from 1 or more iovec's to an evbuffer. Calculates the number of
  bytes needed for an iovec structure and guarantees all data will fit into a
  single chain. Can be used in lieu of functionality which calls
  evbuffer_add() constantly before being used to increase performance.
Parameters:
buffer the destination buffer
vec the source iovec
n_vec the number of iovec structures.
Returns:
the number of bytes successfully written to the output
  buffer.
Append a formatted string to the end of an evbuffer. The string is formated as
  printf.
Parameters:
buf the evbuffer that will be appended to
fmt a format string
... arguments that will be passed to printf(3)
Returns:
The number of bytes added if successful, or -1 if an
  error occurred.
See also:
evutil_printf(), evbuffer_add_vprintf()
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.
Parameters:
outbuf the output buffer
data the memory to reference
datlen how memory to reference
cleanupfn callback to be invoked when the memory is no longer referenced
  by this evbuffer.
cleanupfn_arg optional argument to the cleanup callback
Returns:
0 if successful, or -1 if an error occurred
Append a va_list formatted string to the end of an evbuffer.
Parameters:
buf the evbuffer that will be appended to
fmt a format string
ap a varargs va_list argument array that will be passed to
  vprintf(3)
Returns:
The number of bytes added if successful, or -1 if an
  error occurred.
Change the flags that are set for a callback on a buffer by removing some.
Parameters:
buffer the evbuffer that the callback is watching.
cb the callback whose status we want to change.
flags EVBUFFER_CB_ENABLED to disable the callback.
Returns:
0 on success, -1 on failure.
Change the flags that are set for a callback on a buffer by adding more.
Parameters:
buffer the evbuffer that the callback is watching.
cb the callback whose status we want to change.
flags EVBUFFER_CB_ENABLED to re-enable the callback.
Returns:
0 on success, -1 on failure.
Change the flags that are set for an evbuffer by removing some.
Parameters:
buffer the evbuffer that the callback is watching.
cb the callback whose status we want to change.
flags One or more EVBUFFER_FLAG_* options
Returns:
0 on success, -1 on failure.
Commits previously reserved space. Commits some of the space previously reserved
  with 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!
Parameters:
buf the evbuffer in which to reserve space.
vec one or two extents returned by evbuffer_reserve_space.
n_vecs the number of extents.
Returns:
0 on success, -1 on error
See also:
evbuffer_reserve_space()
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.
Parameters:
buf the evbuffer to be read from
data_out the destination buffer to store the result
datlen the maximum size of the destination buffer
Returns:
the number of bytes read, or -1 if we can't drain the
  buffer.
Read data from the middle of 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.
Parameters:
buf the evbuffer to be read from
pos the position to start reading from
data_out the destination buffer to store the result
datlen the maximum size of the destination buffer
Returns:
the number of bytes read, or -1 if we can't drain the
  buffer.
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.
Remove a specified number of bytes data from the beginning of an evbuffer.
Parameters:
buf the evbuffer to be drained
len the number of bytes to drain from the beginning of the buffer
Returns:
0 on success, -1 on failure.
Enable locking on an evbuffer so that it can safely be used by multiple threads
  at the same time. NOTE: 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!
Parameters:
buf An evbuffer to make lockable.
lock A lock object, or NULL if we should allocate our own.
Returns:
0 on success, -1 on failure.
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.
Parameters:
buf the evbuffer to be expanded
datlen the new minimum length requirement
Returns:
0 if successful, or -1 if an error occurred
Add cleanup callback and argument for the callback to an evbuffer_file_segment.
  The cleanup callback will be invoked when no more references to the
  evbuffer_file_segment exist.
Free an evbuffer_file_segment. It is safe to call this function even if the
  segment has been added to one or more evbuffers. The evbuffer_file_segment
  will not be freed until no more references to it exist.
Create and return a new evbuffer_file_segment for reading data from a file and
  sending it out via an evbuffer. This function avoids unnecessary data copies
  between userland and kernel. Where available, it uses sendfile or splice.
The file descriptor must not be closed so long as any evbuffer is
    using this segment.
The results of using evbuffer_remove() or
    evbuffer_pullup() or any other function that reads bytes from an
    evbuffer on any evbuffer containing the newly returned segment are
    undefined, unless you pass the EVBUF_FS_DISABLE_SENDFILE flag to this
    function.
Parameters:
fd an open file to read from.
offset an index within the file at which to start reading
length how much data to read, or -1 to read as much as possible. (-1
  requires that 'fd' support fstat.)
flags any number of the EVBUF_FS_* flags
Returns:
a new evbuffer_file_segment, or NULL on failure.
Deallocate storage for an evbuffer.
Parameters:
buf pointer to the evbuffer to be freed
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.
Parameters:
buf The buffer to freeze
at_front If true, we freeze the front of the buffer. If false, we freeze
  the back.
Returns:
0 on success, -1 on failure.
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 evbuffer_pullup() that
  cause reallocation and copying of data can thus be avoided.
Parameters:
buf pointer to the evbuffer
Returns:
0 if no data is available, otherwise the number of
  available bytes in the first buffer chain.
Returns the total number of bytes stored in the evbuffer.
Parameters:
buf pointer to the evbuffer
Returns:
the number of bytes stored in the evbuffer
Acquire the lock on an evbuffer. Has no effect if locking was not enabled with
  evbuffer_enable_locking.
Allocate storage for a new evbuffer.
Returns:
a pointer to a newly allocated evbuffer struct, or NULL
  if an error occurred
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).
Parameters:
buffer the evbuffer to peek into,
len the number of bytes to try to peek. If len is negative, we will try
  to fill as much of vec_out as we can. If len is negative and vec_out is not
  provided, we return the number of evbuffer_iovecs that would be needed to get
  all the data in the buffer.
start_at an evbuffer_ptr indicating the point at which we should
  start looking for data. NULL means, 'At the start of the
 buffer.'
vec_out an array of evbuffer_iovec
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.
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.
Prepends data to the beginning of the evbuffer.
Parameters:
buf the evbuffer to which to prepend data
data a pointer to the memory to prepend
size the number of bytes to prepend
Returns:
0 if successful, or -1 otherwise
Prepends all data from the src evbuffer to the beginning of the dst evbuffer.
Parameters:
dst the evbuffer to which to prepend data
src the evbuffer to prepend; it will be emptied as a result
Returns:
0 if successful, or -1 otherwise
Sets the search pointer in the buffer to position. There are two ways to use
  this function: you can call evbuffer_ptr_set(buf, &pos, N,
  EVBUFFER_PTR_SET) to move 'pos' to a position 'N' bytes after the start of the
  buffer, or evbuffer_ptr_set(buf, &pos, N, EVBUFFER_PTR_ADD) to move 'pos'
  forward by 'N' bytes.
If evbuffer_ptr is not initialized, this function can only
    be called with EVBUFFER_PTR_SET.
An evbuffer_ptr can represent any position from the start
    of the buffer to a position immediately after the end of the buffer.
Parameters:
buffer the evbuffer to be search
ptr a pointer to a struct evbuffer_ptr
position the position at which to start the next search
how determines how the pointer should be manipulated.
Returns:
0 on success or -1 otherwise
Makes the data at the beginning of an evbuffer contiguous.
Parameters:
buf the evbuffer to make contiguous
size the number of bytes to make contiguous, or -1 to make the entire
  buffer contiguous.
Returns:
a pointer to the contiguous memory array, or NULL if
  param size requested more data than is present in the buffer.
Read from a file descriptor and store the result in an evbuffer.
Parameters:
buffer the evbuffer to store the result
fd the file descriptor to read from
howmuch the number of bytes to be read
Returns:
the number of bytes read, or -1 if an error
  occurred
See also:
evbuffer_write()
Read a single line from an evbuffer. Reads a line terminated by an EOL as
  determined by the evbuffer_eol_style argument. Returns a newly allocated
  nul-terminated string; the caller must free the returned value. The EOL is not
  included in the returned string.
Parameters:
buffer the evbuffer to read from
n_read_out if non-NULL, 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
  NUL characters.
eol_style the style of line-ending to use.
Returns:
pointer to a single line, or NULL if an error
  occurred
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.
Parameters:
buf the evbuffer to be read from
data the destination buffer to store the result
datlen the maximum size of the destination buffer
Returns:
the number of bytes read, or -1 if we can't drain the
  buffer.
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.
Parameters:
src the evbuffer to be read from
dst the destination evbuffer to store the result into
datlen the maximum numbers of bytes to transfer
Returns:
the number of bytes read
Remove a callback from an evbuffer, given the function and argument used to add
  it.
Returns:
0 if a callback was removed, or -1 if no matching
  callback was found.
Remove a callback from an evbuffer, given a handle returned from
  evbuffer_add_cb. Calling this function invalidates the handle.
Returns:
0 if a callback was removed, or -1 if no matching
  callback was found.
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 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 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.
NOTE: The code currently does not ever use more than two extents.
    This may change in future versions.
Parameters:
buf the evbuffer in which to reserve space.
size how much space to make available, at minimum. The total length of
  the extents may be greater than the requested length.
vec an array of one or more evbuffer_iovec structures to hold
  pointers to the reserved extents of memory.
n_vec The length of the vec array. Must be at least 1; 2 is more
  efficient.
Returns:
the number of provided extents, or -1 on error.
See also:
evbuffer_commit_space()
Search for a string within an evbuffer.
Parameters:
buffer the evbuffer to be searched
what the string to be searched for
len the length of the search string
start NULL or a pointer to a valid struct evbuffer_ptr.
Returns:
a struct 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.
Search for an end-of-line string within an evbuffer.
Parameters:
buffer the evbuffer to be searched
start NULL or a pointer to a valid struct evbuffer_ptr to start
  searching at.
eol_len_out If non-NULL, the pointed-to value will be set to the length
  of the end-of-line string.
eol_style The kind of EOL to look for; see evbuffer_readln() for
  more information
Returns:
a struct evbuffer_ptr whose 'pos' field has the
  offset of the first occurrence EOL in the buffer after 'start'. The 'pos'
  field of the result is -1 if the string was not found.
Search for a string within part of an evbuffer.
Parameters:
buffer the evbuffer to be searched
what the string to be searched for
len the length of the search string
start NULL or a pointer to a valid struct evbuffer_ptr that
  indicates where we should start searching.
end NULL or a pointer to a valid struct evbuffer_ptr that
  indicates where we should stop searching.
Returns:
a struct 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.
Change the flags that are set for an evbuffer by adding more.
Parameters:
buffer the evbuffer that the callback is watching.
cb the callback whose status we want to change.
flags One or more EVBUFFER_FLAG_* options
Returns:
0 on success, -1 on failure.
Re-enable calls that modify an evbuffer.
Parameters:
buf The buffer to un-freeze
at_front If true, we unfreeze the front of the buffer. If false, we
  unfreeze the back.
Returns:
0 on success, -1 on failure.
Release the lock on an evbuffer. Has no effect if locking was not enabled with
  evbuffer_enable_locking.
Write the contents of an evbuffer to a file descriptor. The evbuffer will be
  drained after the bytes have been successfully written.
Parameters:
buffer the evbuffer to be written and drained
fd the file descriptor to be written to
Returns:
the number of bytes written, or -1 if an error
  occurred
See also:
evbuffer_read()
Write some of the contents of an evbuffer to a file descriptor. The evbuffer
  will be drained after the bytes have been successfully written.
Parameters:
buffer the evbuffer to be written and drained
fd the file descriptor to be written to
howmuch the largest allowable number of bytes to write, or -1 to write as
  many bytes as we can.
Returns:
the number of bytes written, or -1 if an error
  occurred
See also:
evbuffer_read()