26 #ifndef _EVENT2_BUFFER_H_ 27 #define _EVENT2_BUFFER_H_ 79 #include <event2/event-config.h> 81 #ifdef _EVENT_HAVE_SYS_TYPES_H 82 #include <sys/types.h> 84 #ifdef _EVENT_HAVE_SYS_UIO_H 96 #ifdef _EVENT_IN_DOXYGEN
124 #ifdef _EVENT_HAVE_SYS_UIO_H 125 #define evbuffer_iovec iovec 127 #define _EVBUFFER_IOVEC_IS_NATIVE 193 #define EVBUFFER_FLAG_DRAINS_TO_FD 1 420 size_t datalen,
void *extra);
438 const void *data,
size_t datlen,
479 __attribute__((format(printf, 2, 3)))
493 __attribute__((format(printf, 2, 0)))
689 struct evbuffer_cb_entry;
712 struct evbuffer_cb_entry *ent);
727 #define EVBUFFER_CB_ENABLED 1 737 struct evbuffer_cb_entry *cb, ev_uint32_t flags);
747 struct evbuffer_cb_entry *cb, ev_uint32_t flags);
759 void evbuffer_cb_suspend(
struct evbuffer *buffer,
struct evbuffer_cb_entry *cb);
768 void evbuffer_cb_unsuspend(
struct evbuffer *buffer,
struct evbuffer_cb_entry *cb);
struct evbuffer * evbuffer_new(void)
Allocate storage for a new evbuffer.
ev_ssize_t evbuffer_copyout(struct evbuffer *buf, void *data_out, size_t datlen)
Read data from an evbuffer, and leave the buffer unchanged.
int evbuffer_set_flags(struct evbuffer *buf, ev_uint64_t flags)
Change the flags that are set for an evbuffer by adding more.
int evbuffer_read(struct evbuffer *buffer, evutil_socket_t fd, int howmuch)
Read from a file descriptor and store the result in an evbuffer.
size_t iov_len
The length of the extent of memory.
Definition: buffer.h:133
int evbuffer_remove_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg)
Remove a callback from an evbuffer, given the function and argument used to add it.
int evbuffer_cb_clear_flags(struct evbuffer *buffer, struct evbuffer_cb_entry *cb, ev_uint32_t flags)
Change the flags that are set for a callback on a buffer by removing some.
An EOL is an LF, optionally preceded by a CR.
Definition: buffer.h:375
int evbuffer_prepend_buffer(struct evbuffer *dst, struct evbuffer *src)
Prepends all data from the src evbuffer to the beginning of the dst evbuffer.
Pointer to a position within an evbuffer.
Definition: buffer.h:109
int evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap)
Append a va_list formatted string to the end of an evbuffer.
int evbuffer_add_reference(struct evbuffer *outbuf, const void *data, size_t datlen, evbuffer_ref_cleanup_cb cleanupfn, void *cleanupfn_arg)
Reference memory into an evbuffer without copying.
int evbuffer_defer_callbacks(struct evbuffer *buffer, struct event_base *base)
Force all the callbacks on an evbuffer to be run, not immediately after the evbuffer is altered...
Sets the pointer to the position; can be called on with an uninitialized evbuffer_ptr.
Definition: buffer.h:582
size_t n_added
The number of bytes added since callbacks were last invoked.
Definition: buffer.h:663
void(* evbuffer_cb_func)(struct evbuffer *buffer, const struct evbuffer_cb_info *info, void *arg)
Type definition for a callback that is invoked whenever data is added or removed from an evbuffer...
Definition: buffer.h:687
struct evbuffer_ptr evbuffer_search_range(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start, const struct evbuffer_ptr *end)
Search for a string within part of an evbuffer.
void * iov_base
The start of the extent of memory.
Definition: buffer.h:131
void evbuffer_free(struct evbuffer *buf)
Deallocate storage for an evbuffer.
size_t evbuffer_get_length(const struct evbuffer *buf)
Returns the total number of bytes stored in the evbuffer.
int evbuffer_peek(struct evbuffer *buffer, ev_ssize_t len, struct evbuffer_ptr *start_at, struct evbuffer_iovec *vec_out, int n_vec)
Function to peek at data inside an evbuffer without removing it or copying it out.
int evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf)
Move all data from one evbuffer into another evbuffer.
int evbuffer_commit_space(struct evbuffer *buf, struct evbuffer_iovec *vec, int n_vecs)
Commits previously reserved space.
Advances the pointer by adding to the current position.
Definition: buffer.h:584
int evbuffer_reserve_space(struct evbuffer *buf, ev_ssize_t size, struct evbuffer_iovec *vec, int n_vec)
Reserves space in the last chain or chains of an evbuffer.
evbuffer_ptr_how
Defines how to adjust an evbuffer_ptr by evbuffer_ptr_set()
Definition: buffer.h:579
Structure passed to an evbuffer_cb_func evbuffer callback.
Definition: buffer.h:658
#define evutil_socket_t
A type wide enough to hold the output of "socket()" or "accept()".
Definition: util.h:274
int evbuffer_remove_buffer(struct evbuffer *src, struct evbuffer *dst, size_t datlen)
Read data from an evbuffer into another evbuffer, draining the bytes from the source buffer...
size_t n_deleted
The number of bytes removed since callbacks were last invoked.
Definition: buffer.h:665
Any sequence of CR and LF characters is acceptable as an EOL.
Definition: buffer.h:372
int evbuffer_cb_set_flags(struct evbuffer *buffer, struct evbuffer_cb_entry *cb, ev_uint32_t flags)
Change the flags that are set for a callback on a buffer by adding more.
struct evbuffer_cb_entry * evbuffer_add_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg)
Add a new callback to an evbuffer.
An evbuffer is an opaque data type for efficiently buffering data to be sent or received on the netwo...
Definition: buffer.h:95
void evbuffer_lock(struct evbuffer *buf)
Acquire the lock on an evbuffer.
int evbuffer_clear_flags(struct evbuffer *buf, ev_uint64_t flags)
Change the flags that are set for an evbuffer by removing some.
int evbuffer_add_file(struct evbuffer *outbuf, int fd, ev_off_t offset, ev_off_t length)
Copy data from a file into the evbuffer for writing to a socket.
evbuffer_eol_style
Used to tell evbuffer_readln what kind of line-ending to look for.
Definition: buffer.h:362
void(* evbuffer_ref_cleanup_cb)(const void *data, size_t datalen, void *extra)
A cleanup function for a piece of memory added to an evbuffer by reference.
Definition: buffer.h:419
Common convenience functions for cross-platform portability and related socket manipulations.
An EOL is a LF.
Definition: buffer.h:379
int evbuffer_freeze(struct evbuffer *buf, int at_front)
Prevent calls that modify an evbuffer from succeeding.
struct evbuffer_ptr evbuffer_search_eol(struct evbuffer *buffer, struct evbuffer_ptr *start, size_t *eol_len_out, enum evbuffer_eol_style eol_style)
Search for an end-of-line string within an evbuffer.
size_t evbuffer_get_contiguous_space(const struct evbuffer *buf)
Returns the number of contiguous available bytes in the first buffer chain.
int evbuffer_drain(struct evbuffer *buf, size_t len)
Remove a specified number of bytes data from the beginning of an evbuffer.
int evbuffer_add_printf(struct evbuffer *buf, const char *fmt,...)
Append a formatted string to the end of an evbuffer.
int evbuffer_prepend(struct evbuffer *buf, const void *data, size_t size)
Prepends data to the beginning of the evbuffer.
int evbuffer_ptr_set(struct evbuffer *buffer, struct evbuffer_ptr *ptr, size_t position, enum evbuffer_ptr_how how)
Sets the search pointer in the buffer to position.
char * evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out, enum evbuffer_eol_style eol_style)
Read a single line from an evbuffer.
int evbuffer_remove_cb_entry(struct evbuffer *buffer, struct evbuffer_cb_entry *ent)
Remove a callback from an evbuffer, given a handle returned from evbuffer_add_cb. ...
int evbuffer_add(struct evbuffer *buf, const void *data, size_t datlen)
Append data to the end of an evbuffer.
An EOL is a CR followed by an LF.
Definition: buffer.h:377
int evbuffer_unfreeze(struct evbuffer *buf, int at_front)
Re-enable calls that modify an evbuffer.
size_t orig_size
The number of bytes in this evbuffer when callbacks were last invoked.
Definition: buffer.h:661
int evbuffer_write_atmost(struct evbuffer *buffer, evutil_socket_t fd, ev_ssize_t howmuch)
Write some of the contents of an evbuffer to a file descriptor.
int evbuffer_write(struct evbuffer *buffer, evutil_socket_t fd)
Write the contents of an evbuffer to a file descriptor.
unsigned char * evbuffer_pullup(struct evbuffer *buf, ev_ssize_t size)
Makes the data at the beginning of an evbuffer contiguous.
Describes a single extent of memory inside an evbuffer.
Definition: buffer.h:129
int evbuffer_enable_locking(struct evbuffer *buf, void *lock)
Enable locking on an evbuffer so that it can safely be used by multiple threads at the same time...
int evbuffer_remove(struct evbuffer *buf, void *data, size_t datlen)
Read data from an evbuffer and drain the bytes read.
Structure to hold information and state for a Libevent dispatch loop.
Definition: event.h:213
struct evbuffer_ptr evbuffer_search(struct evbuffer *buffer, const char *what, size_t len, const struct evbuffer_ptr *start)
Search for a string within an evbuffer.
int evbuffer_expand(struct evbuffer *buf, size_t datlen)
Expands the available space in an evbuffer.
void evbuffer_unlock(struct evbuffer *buf)
Release the lock on an evbuffer.