OpenBSD manual page server

Manual Page Search Parameters

EVBUFFER_NEW(3) Library Functions Manual EVBUFFER_NEW(3)

evbuffer_new, evbuffer_free, evbuffer_setcb, evbuffer_expand, evbuffer_add, evbuffer_add_buffer, evbuffer_add_printf, evbuffer_add_vprintf, evbuffer_drain, evbuffer_remove, evbuffer_write, evbuffer_read, evbuffer_find, evbuffer_readline, evbuffer_readln, EVBUFFER_LENGTH, EVBUFFER_DATAlibevent utility API for buffered input/output

#include <event.h>

struct evbuffer *
evbuffer_new(void);

void
evbuffer_free(struct evbuffer *buf);

void
evbuffer_setcb(struct evbuffer *buf, void (*cb)(struct evbuffer *, size_t, size_t, void *), void *cbarg);

int
evbuffer_expand(struct evbuffer *buf, size_t datlen);

int
evbuffer_add(struct evbuffer *buf, const void *data, size_t size);

int
evbuffer_add_buffer(struct evbuffer *dst, struct evbuffer *src);

int
evbuffer_add_printf(struct evbuffer *buf, const char *fmt, ...);

int
evbuffer_add_vprintf(struct evbuffer *buf, const char *fmt, va_list ap);

void
evbuffer_drain(struct evbuffer *buf, size_t size);

int
evbuffer_remove(struct evbuffer *buf, void *data, size_t datlen);

int
evbuffer_write(struct evbuffer *buf, int fd);

int
evbuffer_read(struct evbuffer *buf, int fd, int size);

u_char *
evbuffer_find(struct evbuffer *buf, const u_char *data, size_t size);

char *
evbuffer_readline(struct evbuffer *buf);

char *
evbuffer_readln(struct evbuffer *buf, size_t *read_out, enum evbuffer_eol_style eol_style);

size_t
EVBUFFER_LENGTH(const struct evbuffer *buf);

u_char *
EVBUFFER_DATA(const struct evbuffer *buf);

The evbuffer API provides an implementation of buffering for use with libevent.

() allocates and initialises a new evbuffer structure.

() deallocates the evbuffer structure buf and any referenced storage.

() sets the callback cb to be invoked with argument cbarg when the data in evbuffer buf is modified.

() expands the available space in buf to at least datlen bytes.

() appends a copy of size bytes from buffer data to the end of the evbuffer buf.

() moves the data off the src evbuffer and appends it to dst.

() appends a printf(3) style formatted string specified by fmt to the end of buf.

() appends a vprintf(3) style formatted string specified by fmt with a va_list ap to the end of buf.

() deletes size bytes from the beginning of the evbuffer buf.

() reads and drains up to datlen bytes from the beginning of the evbuffer buf into data.

() writes and drains the contents of evbuffer buf to the file descriptor fd.

() appends up to size bytes on to the end of the evbuffer buf by reading from the file descriptor fd.

() finds the size length string data in the evbuffer buf.

() reads and drains a single line from the evbuffer buf. A line is delimited by "\n", "\r", "\r\n", or "\n\r". It is the responsibility of the caller to free the returned line with free(3).

() reads and drains a single line from the evbuffer buf. The length of the line will be stored in read_out on success. It is the responsibility of the caller to free the returned line with free(3). The line delimiter is specified as one of the following:

Any sequence of newline or carriage return characters.
A new line optionally preceded by a carriage return.
A carriage return followed by a new line character.
A new line character.

() reports how many bytes are stored in the evbuffer buf.

evbuffer_new() returns a pointer to a newly allocated buffer on success, or NULL on failure and sets errno to indicate the failure.

evbuffer_expand(), evbuffer_add(), and evbuffer_add_buffer() return 0 on success, or -1 on failure and set errno to indicate the failure.

evbuffer_add_printf() and evbuffer_add_vprintf() return the number of bytes added on success, or -1 on failure.

evbuffer_remove() returns the number of bytes read.

evbuffer_write() returns the number of bytes written and drained on success, or -1 on failure and sets errno to indicate the failure.

evbuffer_read() returns the number of bytes appended to the evbuffer on success, 0 on an end of file condition, or -1 on failure and sets errno to indicate the failure.

evbuffer_find() returns a pointer to the start of the string within the evbuffer on success, or NULL on failure.

evbuffer_readline() and evbuffer_readln() return a pointer to the line on success, or NULL on failure.

EVBUFFER_LENGTH() returns the number of bytes available in the evbuffer.

EVBUFFER_DATA() returns a pointer to the evbuffer buf on success.

errno(2), event(3), free(3), printf(3)

The event library was written by Niels Provos.

July 26, 2018 OpenBSD-6.4