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
+ result evbuffers can be used to pass data around without actually
incurring the overhead of copying the data.
A new evbuffer can be allocated with evbuffer_new(), and can be
/**
Returns the number of contiguous available bytes in the first buffer chain.
- This is useful when procesing data that might be split into multiple
+ This is useful when processing 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.
@param buf the event buffer in which to reserve space.
@param vec one or two extents returned by evbuffer_reserve_space.
- @paramm n_vecs the number of extents.
+ @param n_vecs the number of extents.
@return 0 on success, -1 on error
@see evbuffer_reserve_space
*/
@param outbuf the output buffer
@param data the memory to reference
@param datlen how memory to reference
- @param cleanupfn callback to be invokved when the memory is no longer
+ @param cleanupfn callback to be invoked when the memory is no longer
referenced
@param extra optional argument to the cleanup callback
@return 0 if successful, or -1 if an error occurred
enum evbuffer_ptr_how {
/** Sets the pointer to the position; can be called on with an
- uninitalized evbuffer_ptr. */
+ uninitialized evbuffer_ptr. */
EVBUFFER_PTR_SET,
/** Advances the pointer by adding to the current position. */
EVBUFFER_PTR_ADD
};
/**
- Sets the search pointer in the buffer to positiion.
+ Sets the search pointer in the buffer to position.
- If evbuffer_ptr is not initalized. This function can only be called
+ If evbuffer_ptr is not initialized. This function can only be called
with EVBUFFER_PTR_SET.
@param buffer the evbuffer to be search
removed from an evbuffer.
An evbuffer may have one or more callbacks set at a time. The order
- in which they are exectuded is undefined.
+ 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
@param cb the callback we want to suspend.
*/
void evbuffer_cb_suspend(struct evbuffer *buffer, struct evbuffer_cb_entry *cb);
-/** Stop postponing a callback that we posponed with evbuffer_cb_suspend.
+/** Stop postponing a callback that we postponed with evbuffer_cb_suspend.
If data was added to or removed from the buffer while the callback was
suspended, the callback will get called once now.
@param buf the evbuffer to make contiguous
@param size the number of bytes to make contiguous, or -1 to make the
entire buffer contiguous.
- @return a pointer to the contigous memory areay
+ @return a pointer to the contiguous memory array
*/
unsigned char *evbuffer_pullup(struct evbuffer *buf, ev_ssize_t size);
removed from an evbuffer.
An evbuffer may have one or more callbacks set at a time. The order
- in which they are exectuded is undefined.
+ 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
and one for writing, and callbacks that are invoked under certain
circumstances.
- libevent provides an abstraction on top of the regular event callbacks.
+ Libevent provides an abstraction on top of the regular event callbacks.
This abstraction is called a buffered event. A buffered event provides
input and output buffers that get filled and drained automatically. The
user of a buffered event no longer deals directly with the I/O, but
typedef void (*bufferevent_data_cb)(struct bufferevent *bev, void *ctx);
/**
- type defintion for the error callback of a bufferevent.
+ type definition for the error callback of a bufferevent.
The error callback is triggered if either an EOF condition or another
unrecoverable error was encountered.
The user MUST NOT set the callback on this buffer.
- @param bufev the buffervent from which to get the evbuffer
+ @param bufev the bufferevent from which to get the evbuffer
@return the evbuffer object for the input buffer
*/
struct evbuffer *bufferevent_get_input(struct bufferevent *bufev);
/**
- Returns the outut buffer.
+ Returns the output buffer.
The user MUST NOT set the callback on this buffer.
When filters are being used, the filters need to be manually
triggered if the output buffer was manipulated.
- @param bufev the buffervent from which to get the evbuffer
+ @param bufev the bufferevent from which to get the evbuffer
@return the evbuffer object for the output buffer
*/
On input, a bufferevent does not invoke the user read callback unless
there is at least low watermark data in the buffer. If the read buffer
- is beyond the high watermark, the buffevent stops reading from the network.
+ is beyond the high watermark, the bufferevent stops reading from the network.
On output, the user write callback is invoked whenever the buffered data
falls below the low watermark. Filters that write to this bufev will try
/** the filter needs to read more data before output */
BEV_NEED_MORE = 1,
- /** the filter enountered a critical error, no further data
+ /** the filter encountered a critical error, no further data
can be processed. */
BEV_ERROR = 2
};
@param state Whether we should write data as may be convenient
(BEV_NORMAL), or flush as much data as we can (BEV_FLUSH),
or flush as much as we can, possibly including an end-of-stream
- marker (BEF_FINISH).
+ marker (BEV_FINISH).
@param ctx A user-supplied pointer.
@return BEV_OK if we wrote some data; BEV_NEED_MORE if we can't
/**
Allocate a pair of linked bufferevents. The bufferevents behave as would
two bufferevent_sock instances connected to opposite ends of a
- socketpair(), except that no internel socketpair is allocated.
+ socketpair(), except that no internal socketpair is allocated.
@param base The event base to associate with the socketpair.
@param options A set of options for this bufferevent
/**
Create a new bufferevent for an fd.
- This function is deprecated. Use buffevent_socket_new and
+ This function is deprecated. Use bufferevent_socket_new and
bufferevent_set_callbacks instead.
libevent provides an abstraction on top of the regular event callbacks.
/** @file bufferevent_struct.h
Data structures for bufferevents. Using these structures may hurt forward
- compatibility with later versions of libevent: be careful!
+ compatibility with later versions of Libevent: be careful!
*/
* The original DNS code is due to Adam Langley with heavy
* modifications by Nick Mathewson. Adam put his DNS software in the
* public domain. You can find his original copyright below. Please,
- * aware that the code as part of libevent is governed by the 3-clause
+ * aware that the code as part of Libevent is governed by the 3-clause
* BSD license above.
*
* This software is Public Domain. To view a copy of the public domain dedication,
* (see http://www.imperialviolet.org/page25.html#e498). Otherwise,
* please continue.
*
- * This code is based on libevent and you must call event_init before
+ * This code is based on Libevent and you must call event_init before
* any of the APIs in this file. You must also seed the OpenSSL random
* source if you are using OpenSSL for ids (see below).
*
/** The name server refuses to reform the specified operation for policy
* reasons */
#define DNS_ERR_REFUSED 5
-/** The reply was truncated or ill-formated */
+/** The reply was truncated or ill-formatted */
#define DNS_ERR_TRUNCATED 65
/** An unknown error occurred */
#define DNS_ERR_UNKNOWN 66
/** Communication with the server timed out */
#define DNS_ERR_TIMEOUT 67
-/** The request was cancelled because the DNS subsystem was shut down. */
+/** The request was canceled because the DNS subsystem was shut down. */
#define DNS_ERR_SHUTDOWN 68
-/** The request was cancelled via a call to evdns_cancel_request */
+/** The request was canceled via a call to evdns_cancel_request */
#define DNS_ERR_CANCEL 69
#define DNS_IPv4_A 1
/**
A callback to implement a DNS server. The callback function receives a DNS
request. It should then optionally add a number of answers to the reply
- using the evdns_server_request_add_*_reply functinos, before calling either
+ using the evdns_server_request_add_*_reply functions, before calling either
evdns_server_request_respond to send the reply back, or
- evdns_server_request_drop to decling to answer the request.
+ evdns_server_request_drop to decline to answer the request.
@param req A newly received request
@param user_data A pointer that was passed to
/** @file dns_struct.h
Data structures for dns. Using these structures may hurt forward
- compatibility with later versions of libevent: be careful!
+ compatibility with later versions of Libevent: be careful!
*/
int event_base_dispatch(struct event_base *);
/**
- Get the kernel event notification mechanism used by libevent.
+ Get the kernel event notification mechanism used by Libevent.
@param eb the event_base structure returned by event_base_new()
@return a string identifying the kernel event mechanism (kqueue, epoll, etc.)
const char *event_base_get_method(struct event_base *);
/**
- Gets all event notification mechanisms supported by libevent.
+ Gets all event notification mechanisms supported by Libevent.
This functions returns the event mechanism in order preferred by
- libevent. Note that this list will include all backends that
+ Libevent. Note that this list will include all backends that
Libevent has compiled-in support for, and will not necessarily check
your OS to see whether it has the required resources.
This can be used to avoid event mechanisms that do not support certain
file descriptor types. An application can make use of multiple event
- bases to accomodate incompatible file descriptor types.
+ bases to accommodate incompatible file descriptor types.
@param cfg the event configuration object
@param method the event method to avoid
#define _EVENT_LOG_ERR 3
typedef void (*event_log_cb)(int severity, const char *msg);
/**
- Redirect libevent's log messages.
+ Redirect Libevent's log messages.
@param cb a function taking two arguments: an integer severity between
_EVENT_LOG_DEBUG and _EVENT_LOG_ERR, and a string. If cb is NULL,
Note that using event_assign() request that you have already allocated the
event struct. Doing so will often require your code to depend on the size
of the structure, and will create possible incompatibility with future
- versions of libevent. If this seems like a bad idea to you, use event_new()
+ versions of Libevent. If this seems like a bad idea to you, use event_new()
and event_free() instead.
@param ev an event struct to be modified
#endif
/**
- Get the libevent version.
+ Get the Libevent version.
Note that this will give you the version of the library that you're
currently linked against, not the version of the headers that you've
#ifndef _EVENT_DISABLE_MM_REPLACEMENT
/**
- Override the functions that libevent uses for memory management.
+ Override the functions that Libevent uses for memory management.
- Usually, libevent uses the standard libc functions malloc, realloc, and
+ Usually, Libevent uses the standard libc functions malloc, realloc, and
free to allocate memory. Passing replacements for those functions to
event_set_mem_functions() overrides this behavior. To restore the default
behavior, pass NULLs as the arguments to this function.
- Note that all memory returned from libevent will be allocated by the
+ Note that all memory returned from Libevent will be allocated by the
replacement functions rather than by malloc() and realloc(). Thus, if you
have replaced those functions, it may not be appropriate to free() memory
- that you get from libevent.
+ that you get from Libevent.
@param malloc_fn A replacement for malloc.
@param realloc_fn A replacement for realloc
used. Sets the current_base global representing the default base for
events that have no base associated with them.
- @deprecated This function is deprecated because it relaces the "current"
+ @deprecated This function is deprecated because it replaces the "current"
event_base, and is totally unsafe for multithreaded use. The replacement
is event_base_new().
/**
- Get the kernel event notification mechanism used by libevent.
+ Get the kernel event notification mechanism used by Libevent.
@return a string identifying the kernel event mechanism (kqueue, epoll, etc.)
/**
Set the number of different event priorities.
- By default libevent schedules all active events with the same priority.
+ By default Libevent schedules all active events with the same priority.
However, some time it is desirable to process some events with a higher
- priority than others. For that reason, libevent supports strict priority
+ priority than others. For that reason, Libevent supports strict priority
queues. Active events with a lower priority are always processed before
events with a higher priority.
The number of different priorities can be set initially with the
event_priority_init() function. This function should be called before the
first call to event_dispatch(). The event_priority_set() function can be
- used to assign a priority to an event. By default, libevent assigns the
+ used to assign a priority to an event. By default, Libevent assigns the
middle priority to all events unless their priority is explicitly set.
@deprecated This function is deprecated because it is easily confused by
/* EVLIST_X_ Private space: 0x1000-0xf000 */
#define EVLIST_ALL (0xf000 | 0x9f)
-/* Fix so that ppl dont have to run with <sys/queue.h> */
+/* Fix so that people don't have to run with <sys/queue.h> */
#ifndef TAILQ_ENTRY
#define _EVENT_DEFINED_TQENTRY
#define TAILQ_ENTRY(type) \
*
* Basic support for HTTP serving.
*
- * As libevent is a library for dealing with event notification and most
+ * As Libevent is a library for dealing with event notification and most
* interesting applications are networked today, I have often found the
* need to write HTTP code. The following prototypes and definitions provide
* an application with a minimal interface for making HTTP requests and for
void evhttp_connection_set_timeout(struct evhttp_connection *evcon,
int timeout_in_secs);
-/** Sets the retry limit for this connection - -1 repeats indefnitely */
+/** Sets the retry limit for this connection - -1 repeats indefinitely */
void evhttp_connection_set_retries(struct evhttp_connection *evcon,
int retry_max);
const char *key);
/**
- Removes a header from a list of exisiting headers.
+ Removes a header from a list of existing headers.
@param headers the evkeyvalq object from which to remove a header
@param key the name of the header to remove
int evhttp_remove_header(struct evkeyvalq *headers, const char *key);
/**
- Adds a header to a list of exisiting headers.
+ Adds a header to a list of existing headers.
@param headers the evkeyvalq object to which to add a header
@param key the name of the header
/** @file http_struct.h
Data structures for http. Using these structures may hurt forward
- compatibility with later versions of libevent: be careful!
+ compatibility with later versions of Libevent: be careful!
*/
* EVRPC_REGISTER(base, SendCommand, Request, Reply, FunctionCB, arg);
*
* when the server receives an appropriately formatted RPC, the user callback
- * is invokved. The callback needs to fill in the reply structure.
+ * is invoked. The callback needs to fill in the reply structure.
*
* void FunctionCB(EVRPC_STRUCT(SendCommand)* rpc, void *arg);
*
/** adds meta data to request
*
* evrpc_hook_add_meta() allows hooks to add meta data to a request. for
- * a client requet, the meta data can be inserted by an outgoing request hook
+ * a client request, the meta data can be inserted by an outgoing request hook
* and retrieved by the incoming request hook.
*
* @param ctx the context provided to the hook call
* @param ctx the context provided to the hook call
* @param key a NUL-terminated c-string
* @param data pointer to a data pointer that will contain the retrieved data
- * @param data_size pointer tothe size of the data
+ * @param data_size pointer to the size of the data
* @return 0 on success or -1 on failure
*/
int evrpc_hook_find_meta(void *ctx, const char *key,
/** @file thread.h
- Functions for multi-threaded applications using libevent.
+ Functions for multi-threaded applications using Libevent.
When using a multi-threaded application in which multiple threads
- add and delete events from a single event base, libevent needs to
+ add and delete events from a single event base, Libevent needs to
lock its data structures.
Like the memory-management function hooks, all of the threading functions
use them.
A multi-threaded application must provide locking functions to
- libevent via evthread_set_locking_callback(). Libevent will invoke
+ Libevent via evthread_set_locking_callback(). Libevent will invoke
this callback whenever a lock needs to be acquired or released.
- The total number of locks employed by libevent can be determined
+ The total number of locks employed by Libevent can be determined
via the evthread_num_locks() function. An application must provision
that many locks.
If the owner of an event base is waiting for events to happen,
- libevent may signal the thread via a special file descriptor to wake
+ Libevent may signal the thread via a special file descriptor to wake
up. To enable this feature, an application needs to provide a
thread identity function via evthread_set_id_callback().
#define EVTHREAD_READ 0x08
/**
- Sets the functions libevent should use for allocating and freeing
+ Sets the functions Libevent should use for allocating and freeing
locks. This needs to be called in addition to
- evthread_set_locking_callback() before using libevent in a
+ evthread_set_locking_callback() before using Libevent in a
multi-threaded application.
Locks must be recursive. That is, it must be safe for a thread to
void *(*alloc_fn)(void), void (*free_fn)(void *));
/**
- Sets the function libevent should use for locking.
+ Sets the function Libevent should use for locking.
- @param locking_fn the function that libevent should invoke to acquire
+ @param locking_fn the function that Libevent should invoke to acquire
or release a lock. mode has either EVTHREAD_LOCK or EVTHREAD_UNLOCK
- set, and in addition, either EVHTREAD_WRITE or EVTREAD_READ.
+ set, and in addition, either EVTHREAD_WRITE or EVTHREAD_READ.
*/
void evthread_set_locking_callback(
void (*locking_fn)(int mode, void *lock));
/**
- Sets the function for derminting the thread id.
+ Sets the function for determining the thread id.
@param base the event base for which to set the id function
- @param id_fn the identify function libevent should invoke to
+ @param id_fn the identify function Libevent should invoke to
determine the identity of a thread.
*/
void evthread_set_id_callback(
int evthread_make_base_notifiable(struct event_base *base);
#ifdef WIN32
-/** Sets up libevent for use with Windows builtin locking and thread ID
- functions. Unavailable if libevent is not built for Windows.
+/** Sets up Libevent for use with Windows builtin locking and thread ID
+ functions. Unavailable if Libevent is not built for Windows.
@return 0 on success, -1 on failure. */
int evthread_use_windows_threads(void);
#endif
#ifdef _EVENT_HAVE_PTHREADS
-/** Sets up libevent for use with Pthreadsn locking and thread ID functions.
- Unavailable if libevent is not build for use with pthreads. Requires
- libraries to link against libevent_pthreads as well as libevent.
+/** Sets up Libevent for use with Pthreads locking and thread ID functions.
+ Unavailable if Libevent is not build for use with pthreads. Requires
+ libraries to link against Libevent_pthreads as well as Libevent.
@return 0 on success, -1 on failure. */
int evthread_use_pthreads(void);
* C99-specified stdint.h. Shamefully, some platforms do not include
* stdint.h, so we need to replace it. (If you are on a platform like this,
* your C headers are now 10 years out of date. You should bug them to do
- * somthing about this.)
+ * something about this.)
*
* We define:
* ev_uint64_t, ev_uint32_t, ev_uint16_t, ev_uint8_t -- unsigned integer
another program will be able to bind this address right after we've
closed the listener
- @param sock The socket to make reuseabla
+ @param sock The socket to make reusable
@return 0 on success, -1 on failure
*/
int evutil_make_listen_socket_reuseable(evutil_socket_t);
* Elsewhere, a socket error is like any other error and is stored in errno.
* But winsock functions require you to retrieve the error with a special
* function, and don't let you use strerror for the error codes. And handling
- * EWOULD block is ... different. */
+ * EWOULDBLOCK is ... different. */
#ifdef WIN32
/** Return the most recent socket error. Not idempotent on all platforms. */
@param out A struct sockaddr to hold the result. This should probably be
a struct sockaddr_storage.
@param outlen A pointer to the number of bytes that that 'out' can safely
- hold. Set to the number of bytes used in 'out' on sucess.
+ hold. Set to the number of bytes used in 'out' on success.
@return -1 if the address is not well-formed, if the port is out of range,
or if out is not large enough to hold the result. Otherwise returns
0 on success.