libevent  2.2.1
Event notification library
Macros | Typedefs | Functions
buffer_compat.h File Reference

Obsolete and deprecated versions of the functions in buffer.h: provided only for backward compatibility. More...

#include <event2/visibility.h>

Go to the source code of this file.

Macros

#define EVBUFFER_DATA(x)   evbuffer_pullup((x), -1)
 deprecated in favor of calling the functions directly
 
#define EVBUFFER_LENGTH(x)   evbuffer_get_length(x)
 deprecated in favor of calling the functions directly
 

Typedefs

typedef void(* evbuffer_cb) (struct evbuffer *buffer, size_t old_len, size_t new_len, void *arg)
 Type definition for a callback that is invoked whenever data is added or removed from an evbuffer. More...
 

Functions

EVENT2_EXPORT_SYMBOL unsigned char * evbuffer_find (struct evbuffer *buffer, const unsigned char *what, size_t len)
 Find a string within an evbuffer. More...
 
EVENT2_EXPORT_SYMBOL char * evbuffer_readline (struct evbuffer *buffer)
 Obsolete alias for evbuffer_readln(buffer, NULL, EVBUFFER_EOL_ANY). More...
 
EVENT2_EXPORT_SYMBOL int evbuffer_setcb (struct evbuffer *buffer, evbuffer_cb cb, void *cbarg)
 Replace all callbacks on an evbuffer with a single new callback, or remove them. More...
 

Detailed Description

Obsolete and deprecated versions of the functions in buffer.h: provided only for backward compatibility.

Typedef Documentation

◆ evbuffer_cb

typedef void(* evbuffer_cb) (struct evbuffer *buffer, size_t old_len, size_t new_len, void *arg)

Type definition for a callback that is invoked whenever data is added or removed from an evbuffer.

An evbuffer may have one or more callbacks set at a time. The order in which they are executed is undefined.

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.

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!

Parameters
bufferthe buffer whose size has changed
old_lenthe previous length of the buffer
new_lenthe current length of the buffer
arga pointer to user data

Function Documentation

◆ evbuffer_find()

EVENT2_EXPORT_SYMBOL unsigned char* evbuffer_find ( struct evbuffer buffer,
const unsigned char *  what,
size_t  len 
)

Find a string within an evbuffer.

Parameters
bufferthe evbuffer to be searched
whatthe string to be searched for
lenthe length of the search string
Returns
a pointer to the beginning of the search string, or NULL if the search failed.

◆ evbuffer_readline()

EVENT2_EXPORT_SYMBOL char* evbuffer_readline ( struct evbuffer buffer)

Obsolete alias for evbuffer_readln(buffer, NULL, EVBUFFER_EOL_ANY).

Deprecated:
This function is deprecated because its behavior is not correct for almost any protocol, and also because it's wholly subsumed by evbuffer_readln().
Parameters
bufferthe evbuffer to read from
Returns
pointer to a single line, or NULL if an error occurred

◆ evbuffer_setcb()

EVENT2_EXPORT_SYMBOL int evbuffer_setcb ( struct evbuffer buffer,
evbuffer_cb  cb,
void *  cbarg 
)

Replace all callbacks on an evbuffer with a single new callback, or remove them.

Subsequent calls to evbuffer_setcb() replace callbacks set by previous calls. Setting the callback to NULL removes any previously set callback.

Deprecated:
This function is deprecated because it clears all previous callbacks set on the evbuffer, which can cause confusing behavior if multiple parts of the code all want to add their own callbacks on a buffer. Instead, use evbuffer_add(), evbuffer_del(), and evbuffer_setflags() to manage your own evbuffer callbacks without interfering with callbacks set by others.
Parameters
bufferthe evbuffer to be monitored
cbthe callback function to invoke when the evbuffer is modified, or NULL to remove all callbacks.
cbargan argument to be provided to the callback function
Returns
0 if successful, or -1 on error