2008-02-28 02:47:43 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2007 Niels Provos <provos@citi.umich.edu>
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. The name of the author may not be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
|
|
|
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
|
|
|
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
|
|
|
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
#ifndef _EVENT2_BUFFER_H_
|
|
|
|
#define _EVENT2_BUFFER_H_
|
|
|
|
|
|
|
|
/** @file buffer.h
|
|
|
|
|
|
|
|
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 witout actually
|
|
|
|
incurring the overhead of copying the data.
|
|
|
|
|
|
|
|
A new evbuffer can be allocated with evbuffer_new(), and can be
|
|
|
|
freed with evbuffer_free().
|
|
|
|
|
|
|
|
There are several guide lines for using evbuffers.
|
|
|
|
|
|
|
|
- if you already know how much data you are going to add as a result
|
|
|
|
of calling evbuffer_add() multiple times, it makes sense to use
|
|
|
|
evbuffer_expand() first to make sure that enough memory is allocated
|
|
|
|
before hand.
|
|
|
|
|
|
|
|
- evbuffer_add_buffer() adds the contents of one buffer to the other
|
2009-01-12 20:42:06 +00:00
|
|
|
without incurring any unnecessary memory copies.
|
2008-02-28 02:47:43 +00:00
|
|
|
|
2009-01-12 20:42:06 +00:00
|
|
|
- evbuffer_add() and evbuffer_add_buffer() do not mix very well:
|
|
|
|
if you use them, you will wind up with fragmented memory in your
|
|
|
|
buffer.
|
2008-02-28 02:47:43 +00:00
|
|
|
|
|
|
|
As the contents of an evbuffer can be stored into multiple different
|
|
|
|
memory blocks, it cannot be accessed directly. Instead, evbuffer_pullup()
|
|
|
|
can be used to force a specified number of bytes to be continuous. This
|
|
|
|
will cause memory reallocation and memory copies if the data is split
|
|
|
|
across multiple blocks.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <event-config.h>
|
2008-04-17 19:16:30 +00:00
|
|
|
#include <stdarg.h>
|
2008-02-28 02:47:43 +00:00
|
|
|
|
|
|
|
struct evbuffer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Allocate storage for a new evbuffer.
|
|
|
|
|
|
|
|
@return a pointer to a newly allocated evbuffer struct, or NULL if an error
|
|
|
|
occurred
|
|
|
|
*/
|
|
|
|
struct evbuffer *evbuffer_new(void);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Deallocate storage for an evbuffer.
|
|
|
|
|
|
|
|
@param buf pointer to the evbuffer to be freed
|
|
|
|
*/
|
|
|
|
void evbuffer_free(struct evbuffer *buf);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the total number of bytes stored in the event buffer
|
|
|
|
|
|
|
|
@param buf pointer to the evbuffer
|
|
|
|
@return the number of bytes stored in the event buffer
|
|
|
|
*/
|
2009-01-14 22:17:31 +00:00
|
|
|
size_t evbuffer_get_length(const struct evbuffer *buf);
|
2008-02-28 02:47:43 +00:00
|
|
|
|
2008-05-03 02:37:18 +00:00
|
|
|
/**
|
2009-01-12 20:42:06 +00:00
|
|
|
Returns the number of contiguous available bytes in the first buffer chain.
|
2008-05-03 02:37:18 +00:00
|
|
|
|
2009-01-12 20:42:06 +00:00
|
|
|
This is useful when procesing 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.
|
2008-05-03 02:37:18 +00:00
|
|
|
|
|
|
|
@param buf pointer to the evbuffer
|
|
|
|
@return 0 if no data is available, otherwise the number of available bytes
|
|
|
|
in the first buffer chain.
|
|
|
|
*/
|
2009-01-14 22:17:31 +00:00
|
|
|
size_t evbuffer_get_contiguous_space(const struct evbuffer *buf);
|
2008-05-03 02:37:18 +00:00
|
|
|
|
2008-02-28 02:47:43 +00:00
|
|
|
/**
|
|
|
|
Expands the available space in an event buffer.
|
|
|
|
|
2008-02-28 18:36:03 +00:00
|
|
|
Expands the available space in the event buffer to at least datlen, so that
|
|
|
|
appending datlen additional bytes will not require any new allocations.
|
2008-02-28 02:47:43 +00:00
|
|
|
|
|
|
|
@param buf the event buffer to be expanded
|
|
|
|
@param datlen the new minimum length requirement
|
|
|
|
@return 0 if successful, or -1 if an error occurred
|
|
|
|
*/
|
|
|
|
int evbuffer_expand(struct evbuffer *buf, size_t datlen);
|
|
|
|
|
2008-05-03 03:05:28 +00:00
|
|
|
/**
|
|
|
|
Reserves space in the last chain of an event buffer.
|
|
|
|
|
|
|
|
Makes space available in the last chain of an event buffer that can
|
|
|
|
be arbitrarily written to by a user. The space does not become
|
2009-01-12 20:42:06 +00:00
|
|
|
available for reading until it has been committed with
|
|
|
|
evbuffer_commit_space().
|
2008-05-03 03:05:28 +00:00
|
|
|
|
|
|
|
Multiple subsequent calls to this function will make the same space
|
|
|
|
available until evbuffer_commit_space() has been called.
|
|
|
|
|
|
|
|
@param buf the event buffer in which to reserve space.
|
|
|
|
@param size how much space to make available.
|
|
|
|
@return the pointer to the available space or NULL on error.
|
|
|
|
@see evbuffer_commit_space
|
|
|
|
*/
|
|
|
|
|
2008-05-12 00:40:04 +00:00
|
|
|
unsigned char *evbuffer_reserve_space(struct evbuffer *buf, size_t size);
|
2008-05-03 03:05:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Commits previously reserved space.
|
|
|
|
|
2009-01-12 20:42:06 +00:00
|
|
|
Commits some of the space previously reserved with
|
|
|
|
evbuffer_reserve_space(). It then becomes available for reading.
|
2008-05-03 03:05:28 +00:00
|
|
|
|
|
|
|
@param buf the event buffer in which to reserve space.
|
|
|
|
@param size how much space to commit.
|
|
|
|
@return 0 on success, -1 on error
|
|
|
|
@see evbuffer_reserve_space
|
|
|
|
*/
|
|
|
|
|
|
|
|
int evbuffer_commit_space(struct evbuffer *buf, size_t size);
|
|
|
|
|
2008-02-28 02:47:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Append data to the end of an evbuffer.
|
|
|
|
|
|
|
|
@param buf the event buffer to be appended to
|
|
|
|
@param data pointer to the beginning of the data buffer
|
|
|
|
@param datlen the number of bytes to be copied from the data buffer
|
|
|
|
*/
|
|
|
|
int evbuffer_add(struct evbuffer *buf, const void *data, size_t datlen);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Read data from an event buffer and drain the bytes read.
|
|
|
|
|
|
|
|
@param buf the event buffer to be read from
|
|
|
|
@param data the destination buffer to store the result
|
|
|
|
@param datlen the maximum size of the destination buffer
|
|
|
|
@return the number of bytes read
|
|
|
|
*/
|
|
|
|
int evbuffer_remove(struct evbuffer *buf, void *data, size_t datlen);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Read data from an event buffer into another event buffer draining
|
|
|
|
the bytes from the src buffer read. This function avoids memcpy
|
|
|
|
as possible.
|
|
|
|
|
|
|
|
@param src the event buffer to be read from
|
|
|
|
@param dst the destination event buffer to store the result into
|
|
|
|
@param datlen the maximum numbers of bytes to transfer
|
|
|
|
@return the number of bytes read
|
|
|
|
*/
|
|
|
|
int evbuffer_remove_buffer(struct evbuffer *src, struct evbuffer *dst,
|
|
|
|
size_t datlen);
|
|
|
|
|
|
|
|
/** Used to tell evbuffer_readln what kind of line-ending to look for.
|
|
|
|
*/
|
|
|
|
enum evbuffer_eol_style {
|
|
|
|
/** Any sequence of CR and LF characters is acceptable as an EOL. */
|
|
|
|
EVBUFFER_EOL_ANY,
|
|
|
|
/** An EOL is an LF, optionally preceded by a CR. This style is
|
|
|
|
* most useful for implementing text-based internet protocols. */
|
|
|
|
EVBUFFER_EOL_CRLF,
|
|
|
|
/** An EOL is a CR followed by an LF. */
|
|
|
|
EVBUFFER_EOL_CRLF_STRICT,
|
|
|
|
/** An EOL is a LF. */
|
|
|
|
EVBUFFER_EOL_LF
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Read a single line from an event buffer.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* @param buffer the evbuffer to read from
|
|
|
|
* @param 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.
|
|
|
|
* @param eol_style the style of line-ending to use.
|
|
|
|
* @return pointer to a single line, or NULL if an error occurred
|
|
|
|
*/
|
|
|
|
char *evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out,
|
|
|
|
enum evbuffer_eol_style eol_style);
|
|
|
|
|
|
|
|
/**
|
|
|
|
Move data from one evbuffer into another evbuffer.
|
|
|
|
|
|
|
|
This is a destructive add. The data from one buffer moves into
|
2009-01-12 20:42:06 +00:00
|
|
|
the other buffer. However, no unnecessary memory copies occur.
|
2008-02-28 02:47:43 +00:00
|
|
|
|
|
|
|
@param outbuf the output buffer
|
|
|
|
@param inbuf the input buffer
|
|
|
|
@return 0 if successful, or -1 if an error occurred
|
|
|
|
*/
|
|
|
|
int evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Append a formatted string to the end of an evbuffer.
|
|
|
|
|
|
|
|
@param buf the evbuffer that will be appended to
|
|
|
|
@param fmt a format string
|
|
|
|
@param ... arguments that will be passed to printf(3)
|
2008-04-10 19:25:11 +00:00
|
|
|
@return The number of bytes added if successful, or -1 if an error occurred.
|
|
|
|
|
2008-02-28 02:47:43 +00:00
|
|
|
*/
|
|
|
|
int evbuffer_add_printf(struct evbuffer *buf, const char *fmt, ...)
|
|
|
|
#ifdef __GNUC__
|
|
|
|
__attribute__((format(printf, 2, 3)))
|
|
|
|
#endif
|
|
|
|
;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Append a va_list formatted string to the end of an evbuffer.
|
|
|
|
|
|
|
|
@param buf the evbuffer that will be appended to
|
|
|
|
@param fmt a format string
|
|
|
|
@param ap a varargs va_list argument array that will be passed to vprintf(3)
|
2008-04-10 19:25:11 +00:00
|
|
|
@return The number of bytes added if successful, or -1 if an error occurred.
|
2008-02-28 02:47:43 +00:00
|
|
|
*/
|
|
|
|
int evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Remove a specified number of bytes data from the beginning of an evbuffer.
|
|
|
|
|
|
|
|
@param buf the evbuffer to be drained
|
|
|
|
@param len the number of bytes to drain from the beginning of the buffer
|
|
|
|
@return 0 if successful, or -1 if an error occurred
|
|
|
|
*/
|
|
|
|
void evbuffer_drain(struct evbuffer *buf, size_t len);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Write the contents of an evbuffer to a file descriptor.
|
|
|
|
|
|
|
|
The evbuffer will be drained after the bytes have been successfully written.
|
|
|
|
|
|
|
|
@param buffer the evbuffer to be written and drained
|
|
|
|
@param fd the file descriptor to be written to
|
|
|
|
@return the number of bytes written, or -1 if an error occurred
|
|
|
|
@see evbuffer_read()
|
|
|
|
*/
|
|
|
|
int evbuffer_write(struct evbuffer *buffer, evutil_socket_t fd);
|
|
|
|
|
2009-01-12 20:42:19 +00:00
|
|
|
/**
|
|
|
|
Write some of the contents of an evbuffer to a file descriptor.
|
|
|
|
|
|
|
|
The evbuffer will be drained after the bytes have been successfully written.
|
|
|
|
|
|
|
|
@param buffer the evbuffer to be written and drained
|
|
|
|
@param fd the file descriptor to be written to
|
|
|
|
@param howmuch the largest allowable number of bytes to write, or -1
|
|
|
|
to write as many bytes as we can.
|
|
|
|
@return the number of bytes written, or -1 if an error occurred
|
|
|
|
@see evbuffer_read()
|
|
|
|
*/
|
|
|
|
int evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd,
|
|
|
|
ssize_t howmuch);
|
|
|
|
|
2008-02-28 02:47:43 +00:00
|
|
|
/**
|
|
|
|
Read from a file descriptor and store the result in an evbuffer.
|
|
|
|
|
|
|
|
@param buf the evbuffer to store the result
|
|
|
|
@param fd the file descriptor to read from
|
|
|
|
@param howmuch the number of bytes to be read
|
|
|
|
@return the number of bytes read, or -1 if an error occurred
|
|
|
|
@see evbuffer_write()
|
|
|
|
*/
|
|
|
|
int evbuffer_read(struct evbuffer *buffer, evutil_socket_t fd, int howmuch);
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Find a string within an evbuffer.
|
|
|
|
|
|
|
|
@param buffer the evbuffer to be searched
|
|
|
|
@param what the string to be searched for
|
|
|
|
@param len the length of the search string
|
|
|
|
@return a pointer to the beginning of the search string, or NULL if the search failed.
|
|
|
|
*/
|
2008-05-12 00:40:04 +00:00
|
|
|
unsigned char *evbuffer_find(struct evbuffer *buffer, const unsigned char *what, size_t len);
|
2008-02-28 02:47:43 +00:00
|
|
|
|
|
|
|
|
2009-01-23 18:03:45 +00:00
|
|
|
/** Type definition for a callback that is invoked whenever data is added or
|
|
|
|
removed from an evbuffer.
|
2009-01-23 01:11:13 +00:00
|
|
|
|
2009-01-23 18:03:45 +00:00
|
|
|
An evbuffer may have one or more callbacks set at a time. The order
|
|
|
|
in which they are exectuded is undefined.
|
2009-01-23 01:11:13 +00:00
|
|
|
|
2009-01-23 18:03:45 +00:00
|
|
|
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.
|
2009-01-23 01:11:13 +00:00
|
|
|
|
2009-01-23 18:03:45 +00:00
|
|
|
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!
|
2009-01-23 01:11:13 +00:00
|
|
|
|
2009-01-23 18:03:45 +00:00
|
|
|
@param buffer the buffer whose size has changed
|
|
|
|
@param old_len the previous length of the buffer
|
|
|
|
@param new_len thee current length of the buffer
|
|
|
|
@param arg a pointer to user data
|
2009-01-23 01:11:13 +00:00
|
|
|
*/
|
|
|
|
typedef void (*evbuffer_cb)(struct evbuffer *buffer, size_t old_len, size_t new_len, void *arg);
|
|
|
|
|
|
|
|
struct evbuffer_cb_entry;
|
|
|
|
/** Add a new callback to an evbuffer.
|
2009-01-12 20:42:06 +00:00
|
|
|
|
2009-01-23 01:11:13 +00:00
|
|
|
Subsequent calls to evbuffer_add_cb() add new callbacks. To remove this
|
|
|
|
callback, call evbuffer_remove_cb or evbuffer_remove_cb_entry.
|
2009-01-12 20:42:06 +00:00
|
|
|
|
2008-02-28 02:47:43 +00:00
|
|
|
@param buffer the evbuffer to be monitored
|
2009-01-23 01:11:13 +00:00
|
|
|
@param cb the callback function to invoke when the evbuffer is modified,
|
|
|
|
or NULL to remove all callbacks.
|
2008-02-28 02:47:43 +00:00
|
|
|
@param cbarg an argument to be provided to the callback function
|
2009-01-23 01:11:13 +00:00
|
|
|
@return a handle to the callback on success, or NULL on failure.
|
|
|
|
*/
|
|
|
|
struct evbuffer_cb_entry *evbuffer_add_cb(struct evbuffer *buffer, evbuffer_cb cb, void *cbarg);
|
|
|
|
|
|
|
|
/** Remove a callback from an evbuffer, given a handle returned from
|
2009-01-23 18:03:45 +00:00
|
|
|
evbuffer_add_cb.
|
2009-01-23 01:11:13 +00:00
|
|
|
|
2009-01-23 18:03:45 +00:00
|
|
|
Calling this function invalidates the handle.
|
2009-01-23 01:11:13 +00:00
|
|
|
|
2009-01-23 18:03:45 +00:00
|
|
|
@return 0 if a callback was removed, or -1 if no matching callback was
|
|
|
|
found.
|
2009-01-23 01:11:13 +00:00
|
|
|
*/
|
|
|
|
int evbuffer_remove_cb_entry(struct evbuffer *buffer,
|
2009-01-23 18:03:45 +00:00
|
|
|
struct evbuffer_cb_entry *ent);
|
2009-01-23 01:11:13 +00:00
|
|
|
|
|
|
|
/** Remove a callback from an evbuffer, given the function and argument
|
2009-01-23 18:03:45 +00:00
|
|
|
used to add it.
|
2009-01-23 01:11:13 +00:00
|
|
|
|
2009-01-23 18:03:45 +00:00
|
|
|
@return 0 if a callback was removed, or -1 if no matching callback was
|
|
|
|
found.
|
2008-02-28 02:47:43 +00:00
|
|
|
*/
|
2009-01-23 01:11:13 +00:00
|
|
|
int evbuffer_remove_cb(struct evbuffer *buffer, evbuffer_cb cb, void *cbarg);
|
2008-02-28 02:47:43 +00:00
|
|
|
|
2009-01-23 18:04:34 +00:00
|
|
|
#define EVBUFFER_CB_ENABLED 1
|
|
|
|
/** Change whether a given callback is enabled on a buffer or not. A
|
|
|
|
disabled callback is not invoked even when the buffer size changes.
|
|
|
|
|
|
|
|
@param buffer the evbuffer that the callback is watching.
|
|
|
|
@param cb the callback whose status we want to change.
|
|
|
|
@param flags EVBUFFER_CB_ENABLED to enable the callback, or 0 to
|
|
|
|
disable it.
|
|
|
|
@return 0 on success, -1 on failure.
|
|
|
|
*/
|
|
|
|
int evbuffer_cb_set_flags(struct evbuffer *buffer,
|
|
|
|
struct evbuffer_cb_entry *cb, unsigned flags);
|
|
|
|
|
2008-02-28 02:47:43 +00:00
|
|
|
/**
|
2009-01-12 20:42:06 +00:00
|
|
|
Makes the data at the begging of an evbuffer contiguous.
|
2008-02-28 02:47:43 +00:00
|
|
|
|
|
|
|
@param buf the evbuffer to make contiguous
|
2008-02-28 18:36:03 +00:00
|
|
|
@param size the number of bytes to make contiguous, or -1 to make the
|
|
|
|
entire buffer contiguous.
|
2008-02-28 02:47:43 +00:00
|
|
|
@return a pointer to the contigous memory areay
|
|
|
|
*/
|
|
|
|
|
2008-05-12 00:40:04 +00:00
|
|
|
unsigned char *evbuffer_pullup(struct evbuffer *buf, int size);
|
2008-02-28 02:47:43 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Prepends data to the beginning of the evbuffer
|
|
|
|
|
|
|
|
@param buf the evbuffer to which to prepend data
|
|
|
|
@param data a pointer to the memory to prepend
|
|
|
|
@param size the number of bytes to prepend
|
|
|
|
@return 0 if successful, or -1 otherwise
|
|
|
|
*/
|
|
|
|
|
|
|
|
int evbuffer_prepend(struct evbuffer *buf, const void *data, size_t size);
|
|
|
|
|
|
|
|
/**
|
2009-01-12 20:42:06 +00:00
|
|
|
Prepends all data from the src evbuffer to the beginning of the dst
|
|
|
|
evbuffer.
|
2008-02-28 02:47:43 +00:00
|
|
|
|
|
|
|
@param dst the evbuffer to which to prepend data
|
|
|
|
@param src the evbuffer to prepend; it will be emptied as a result
|
|
|
|
*/
|
|
|
|
|
|
|
|
void evbuffer_prepend_buffer(struct evbuffer *dst, struct evbuffer* src);
|
|
|
|
|
2008-02-28 18:36:03 +00:00
|
|
|
/* XXX missing APIs:
|
|
|
|
|
|
|
|
A better find-string that returns a smart offset structure rather than a
|
|
|
|
pointer. It should also be able to start searching _at_ an offset.
|
|
|
|
|
2009-01-23 18:03:45 +00:00
|
|
|
A check-representation functions for testing, so we can assert() that
|
|
|
|
nothing has gone screwy inside an evbuffer.
|
2008-02-28 18:36:03 +00:00
|
|
|
*/
|
|
|
|
|
2008-02-28 02:47:43 +00:00
|
|
|
/** deprecated in favor of calling the functions directly */
|
2008-05-08 22:51:39 +00:00
|
|
|
#define EVBUFFER_LENGTH(x) evbuffer_get_length(x)
|
2008-02-28 02:47:43 +00:00
|
|
|
#define EVBUFFER_DATA(x) evbuffer_pullup(x, -1)
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif /* _EVENT2_BUFFER_H_ */
|