libevent
2.2.1
Event notification library
|
Go to the documentation of this file.
26 #ifndef EVENT2_BUFFER_H_INCLUDED_
27 #define EVENT2_BUFFER_H_INCLUDED_
75 #include <event2/visibility.h>
81 #include <event2/event-config.h>
83 #ifdef EVENT__HAVE_SYS_TYPES_H
84 #include <sys/types.h>
86 #ifdef EVENT__HAVE_SYS_UIO_H
98 #ifdef EVENT_IN_DOXYGEN_
132 #ifdef EVENT__HAVE_SYS_UIO_H
133 #define evbuffer_iovec iovec
135 #define EVBUFFER_IOVEC_IS_NATIVE_
230 #define EVBUFFER_FLAG_DRAINS_TO_FD 1
506 size_t datalen,
void *extra);
525 const void *data,
size_t datlen,
548 void *cleanupfn_arg);
585 struct evbuffer_file_segment;
592 #define EVBUF_FS_CLOSE_ON_FREE 0x01
597 #define EVBUF_FS_DISABLE_MMAP 0x02
607 #define EVBUF_FS_DISABLE_SENDFILE 0x04
614 #define EVBUF_FS_DISABLE_LOCKING 0x08
621 struct evbuffer_file_segment const* seg,
int flags,
void* arg);
647 int fd, ev_off_t offset, ev_off_t length,
unsigned flags);
694 struct evbuffer_file_segment *seg, ev_off_t offset, ev_off_t length);
711 __attribute__((format(printf, 2, 3)))
726 __attribute__((format(printf, 2, 0)))
941 struct evbuffer_cb_entry;
966 struct evbuffer_cb_entry *ent);
982 #define EVBUFFER_CB_ENABLED 1
993 struct evbuffer_cb_entry *cb, ev_uint32_t flags);
1002 EVENT2_EXPORT_SYMBOL
1004 struct evbuffer_cb_entry *cb, ev_uint32_t flags);
1016 EVENT2_EXPORT_SYMBOL
1017 void evbuffer_cb_suspend(
struct evbuffer *buffer,
struct evbuffer_cb_entry *cb);
1026 EVENT2_EXPORT_SYMBOL
1027 void evbuffer_cb_unsuspend(
struct evbuffer *buffer,
struct evbuffer_cb_entry *cb);
1040 EVENT2_EXPORT_SYMBOL
1052 EVENT2_EXPORT_SYMBOL
1063 EVENT2_EXPORT_SYMBOL
1080 EVENT2_EXPORT_SYMBOL
1090 EVENT2_EXPORT_SYMBOL
1101 EVENT2_EXPORT_SYMBOL
1117 EVENT2_EXPORT_SYMBOL
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL size_t evbuffer_get_length(const struct evbuffer *buf)
Returns the total number of bytes stored in the evbuffer.
@ EVBUFFER_PTR_ADD
Advances the pointer by adding to the current position.
Definition: buffer.h:824
EVENT2_EXPORT_SYMBOL int evbuffer_remove(struct evbuffer *buf, void *data, size_t datlen)
Read data from an evbuffer and drain the bytes read.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL int evbuffer_add_reference_with_offset(struct evbuffer *outbuf, const void *data, size_t offset, size_t datlen, evbuffer_ref_cleanup_cb cleanupfn, void *cleanupfn_arg)
Reference memory into an evbuffer without copying.
EVENT2_EXPORT_SYMBOL size_t evbuffer_get_contiguous_space(const struct evbuffer *buf)
Returns the number of contiguous available bytes in the first buffer chain.
Structure passed to an evbuffer_cb_func evbuffer callback.
Definition: buffer.h:910
EVENT2_EXPORT_SYMBOL int evbuffer_add(struct evbuffer *buf, const void *data, size_t datlen)
Append data to the end of an evbuffer.
@ EVBUFFER_EOL_CRLF
An EOL is an LF, optionally preceded by a CR.
Definition: buffer.h:436
void * iov_base
The start of the extent of memory.
Definition: buffer.h:139
EVENT2_EXPORT_SYMBOL size_t evbuffer_add_iovec(struct evbuffer *buffer, struct evbuffer_iovec *vec, int n_vec)
Append data from 1 or more iovec's to an evbuffer.
EVENT2_EXPORT_SYMBOL int evbuffer_unfreeze(struct evbuffer *buf, int at_front)
Re-enable calls that modify an evbuffer.
EVENT2_EXPORT_SYMBOL int evbuffer_set_flags(struct evbuffer *buf, ev_uint64_t flags)
Change the flags that are set for an evbuffer by adding more.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL int evbuffer_set_max_read(struct evbuffer *buf, size_t max)
Set maximum read buffer size.
evbuffer_eol_style
Used to tell evbuffer_readln what kind of line-ending to look for.
Definition: buffer.h:423
@ EVBUFFER_EOL_NUL
An EOL is a NUL character (that is, a single byte with value 0)
Definition: buffer.h:442
Structure to hold information and state for a Libevent dispatch loop.
Definition: event.h:219
EVENT2_EXPORT_SYMBOL void evbuffer_lock(struct evbuffer *buf)
Acquire the lock on an evbuffer.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL unsigned char * evbuffer_pullup(struct evbuffer *buf, ev_ssize_t size)
Makes the data at the beginning of an evbuffer contiguous.
@ EVBUFFER_EOL_CRLF_STRICT
An EOL is a CR followed by an LF.
Definition: buffer.h:438
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL 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,...
EVENT2_EXPORT_SYMBOL int evbuffer_prepend(struct evbuffer *buf, const void *data, size_t size)
Prepends data to the beginning of the evbuffer.
EVENT2_EXPORT_SYMBOL int evbuffer_read(struct evbuffer *buffer, evutil_socket_t fd, int howmuch)
Read from a file descriptor and store the result in an evbuffer.
EVENT2_EXPORT_SYMBOL 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.
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:505
EVENT2_EXPORT_SYMBOL ev_ssize_t evbuffer_copyout_from(struct evbuffer *buf, const struct evbuffer_ptr *pos, void *data_out, size_t datlen)
Read data from the middle of an evbuffer, and leave the buffer unchanged.
Describes a single extent of memory inside an evbuffer.
Definition: buffer.h:137
EVENT2_EXPORT_SYMBOL int evbuffer_drain(struct evbuffer *buf, size_t len)
Remove a specified number of bytes data from the beginning of an evbuffer.
Pointer to a position within an evbuffer.
Definition: buffer.h:116
EVENT2_EXPORT_SYMBOL int evbuffer_prepend_buffer(struct evbuffer *dst, struct evbuffer *src)
Prepends all data from the src evbuffer to the beginning of the dst evbuffer.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL 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.
An evbuffer is an opaque data type for efficiently buffering data to be sent or received on the netwo...
Definition: buffer.h:97
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:939
EVENT2_EXPORT_SYMBOL int evbuffer_freeze(struct evbuffer *buf, int at_front)
Prevent calls that modify an evbuffer from succeeding.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL struct evbuffer_cb_entry * evbuffer_add_cb(struct evbuffer *buffer, evbuffer_cb_func cb, void *cbarg)
Add a new callback to an evbuffer.
EVENT2_EXPORT_SYMBOL struct evbuffer_file_segment * evbuffer_file_segment_new(int fd, ev_off_t offset, ev_off_t length, unsigned flags)
Create and return a new evbuffer_file_segment for reading data from a file and sending it out via an ...
EVENT2_EXPORT_SYMBOL char * evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out, enum evbuffer_eol_style eol_style)
Read a single line from an evbuffer.
EVENT2_EXPORT_SYMBOL void evbuffer_unlock(struct evbuffer *buf)
Release the lock on an evbuffer.
EVENT2_EXPORT_SYMBOL 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.
size_t n_deleted
The number of bytes removed since callbacks were last invoked.
Definition: buffer.h:917
EVENT2_EXPORT_SYMBOL int evbuffer_clear_flags(struct evbuffer *buf, ev_uint64_t flags)
Change the flags that are set for an evbuffer by removing some.
evbuffer_ptr_how
Defines how to adjust an evbuffer_ptr by evbuffer_ptr_set()
Definition: buffer.h:819
size_t n_added
The number of bytes added since callbacks were last invoked.
Definition: buffer.h:915
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL int evbuffer_add_buffer(struct evbuffer *outbuf, struct evbuffer *inbuf)
Move all data from one evbuffer into another evbuffer.
EVENT2_EXPORT_SYMBOL int evbuffer_add_file_segment(struct evbuffer *buf, struct evbuffer_file_segment *seg, ev_off_t offset, ev_off_t length)
Insert some or all of an evbuffer_file_segment at the end of an evbuffer.
EVENT2_EXPORT_SYMBOL int evbuffer_add_printf(struct evbuffer *buf, const char *fmt,...)
Append a formatted string to the end of an evbuffer.
@ EVBUFFER_EOL_LF
An EOL is a LF.
Definition: buffer.h:440
EVENT2_EXPORT_SYMBOL int evbuffer_commit_space(struct evbuffer *buf, struct evbuffer_iovec *vec, int n_vecs)
Commits previously reserved space.
EVENT2_EXPORT_SYMBOL int evbuffer_write(struct evbuffer *buffer, evutil_socket_t fd)
Write the contents of an evbuffer to a file descriptor.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL void evbuffer_free(struct evbuffer *buf)
Deallocate storage for an evbuffer.
void(* evbuffer_file_segment_cleanup_cb)(struct evbuffer_file_segment const *seg, int flags, void *arg)
A cleanup function for a evbuffer_file_segment added to an evbuffer for reference.
Definition: buffer.h:620
@ EVBUFFER_EOL_ANY
Any sequence of CR and LF characters is acceptable as an EOL.
Definition: buffer.h:433
size_t orig_size
The number of bytes in this evbuffer when callbacks were last invoked.
Definition: buffer.h:913
EVENT2_EXPORT_SYMBOL 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_SET
Sets the pointer to the position; can be called on with an uninitialized evbuffer_ptr.
Definition: buffer.h:822
size_t iov_len
The length of the extent of memory.
Definition: buffer.h:141
EVENT2_EXPORT_SYMBOL int evbuffer_add_buffer_reference(struct evbuffer *outbuf, struct evbuffer *inbuf)
Copy data from one evbuffer into another evbuffer.
EVENT2_EXPORT_SYMBOL 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.
EVENT2_EXPORT_SYMBOL struct evbuffer * evbuffer_new(void)
Allocate storage for a new evbuffer.
EVENT2_EXPORT_SYMBOL size_t evbuffer_get_max_read(struct evbuffer *buf)
Get maximum read buffer size.
EVENT2_EXPORT_SYMBOL void evbuffer_file_segment_free(struct evbuffer_file_segment *seg)
Free an evbuffer_file_segment.
Common convenience functions for cross-platform portability and related socket manipulations.
EVENT2_EXPORT_SYMBOL ev_ssize_t evbuffer_copyout(struct evbuffer *buf, void *data_out, size_t datlen)
Read data from an evbuffer, and leave the buffer unchanged.
EVENT2_EXPORT_SYMBOL void evbuffer_file_segment_add_cleanup_cb(struct evbuffer_file_segment *seg, evbuffer_file_segment_cleanup_cb cb, void *arg)
Add cleanup callback and argument for the callback to an evbuffer_file_segment.
EVENT2_EXPORT_SYMBOL int evbuffer_expand(struct evbuffer *buf, size_t datlen)
Expands the available space in an evbuffer.
EVENT2_EXPORT_SYMBOL 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.
#define evutil_socket_t
A type wide enough to hold the output of "socket()" or "accept()".
Definition: util.h:325