mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-09 20:41:27 -04:00
r15097@catbus: nickm | 2007-09-18 11:08:42 -0400
Wrap all newly-added Doxygen comments to fit in a consistent 80 columns, and remove all their trailing whitespace. svn:r437
This commit is contained in:
parent
7135ffb6fc
commit
d69a4c9ec4
54
evdns.h
54
evdns.h
@ -198,7 +198,7 @@ extern "C" {
|
|||||||
#define DNS_OPTION_MISC 4
|
#define DNS_OPTION_MISC 4
|
||||||
#define DNS_OPTIONS_ALL 7
|
#define DNS_OPTIONS_ALL 7
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The callback that contains the results from a lookup.
|
* The callback that contains the results from a lookup.
|
||||||
* - type is either DNS_IPv4_A or DNS_PTR or DNS_IPv6_AAAA
|
* - type is either DNS_IPv4_A or DNS_PTR or DNS_IPv6_AAAA
|
||||||
* - count contains the number of addresses of form type
|
* - count contains the number of addresses of form type
|
||||||
@ -210,8 +210,9 @@ typedef void (*evdns_callback_type) (int result, char type, int count, int ttl,
|
|||||||
/**
|
/**
|
||||||
Initialize the asynchronous DNS library.
|
Initialize the asynchronous DNS library.
|
||||||
|
|
||||||
This function initializes support for non-blocking name resolution by calling
|
This function initializes support for non-blocking name resolution by
|
||||||
evdns_resolv_conf_parse() on UNIX and evdns_config_windows_nameservers() on Windows.
|
calling evdns_resolv_conf_parse() on UNIX and
|
||||||
|
evdns_config_windows_nameservers() on Windows.
|
||||||
|
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@see evdns_shutdown()
|
@see evdns_shutdown()
|
||||||
@ -243,9 +244,9 @@ const char *evdns_err_to_string(int err);
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Add a nameserver.
|
Add a nameserver.
|
||||||
|
|
||||||
The address should be an IP address in network byte order.
|
The address should be an IP address in network byte order.
|
||||||
The type of address is chosen so that it matches in_addr.s_addr.
|
The type of address is chosen so that it matches in_addr.s_addr.
|
||||||
|
|
||||||
@param address an IP address in network byte order
|
@param address an IP address in network byte order
|
||||||
@ -263,7 +264,7 @@ int evdns_nameserver_add(unsigned long int address);
|
|||||||
whether our calls to the various nameserver configuration functions
|
whether our calls to the various nameserver configuration functions
|
||||||
have been successful.
|
have been successful.
|
||||||
|
|
||||||
@return the number of configured nameservers
|
@return the number of configured nameservers
|
||||||
@see evdns_nameserver_add()
|
@see evdns_nameserver_add()
|
||||||
*/
|
*/
|
||||||
int evdns_count_nameservers(void);
|
int evdns_count_nameservers(void);
|
||||||
@ -282,7 +283,7 @@ int evdns_clear_nameservers_and_suspend(void);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Resume normal operation and continue any suspended resolve requests.
|
Resume normal operation and continue any suspended resolve requests.
|
||||||
|
|
||||||
Re-attempt resolves left in limbo after an earlier call to
|
Re-attempt resolves left in limbo after an earlier call to
|
||||||
evdns_clear_nameservers_and_suspend().
|
evdns_clear_nameservers_and_suspend().
|
||||||
|
|
||||||
@ -313,7 +314,7 @@ int evdns_nameserver_ip_add(const char *ip_as_string);
|
|||||||
@param ptr an argument to pass to the callback function
|
@param ptr an argument to pass to the callback function
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@see evdns_resolve_ipv6(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6()
|
@see evdns_resolve_ipv6(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6()
|
||||||
*/
|
*/
|
||||||
int evdns_resolve_ipv4(const char *name, int flags, evdns_callback_type callback, void *ptr);
|
int evdns_resolve_ipv4(const char *name, int flags, evdns_callback_type callback, void *ptr);
|
||||||
|
|
||||||
|
|
||||||
@ -326,7 +327,7 @@ int evdns_resolve_ipv4(const char *name, int flags, evdns_callback_type callback
|
|||||||
@param ptr an argument to pass to the callback function
|
@param ptr an argument to pass to the callback function
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@see evdns_resolve_ipv4(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6()
|
@see evdns_resolve_ipv4(), evdns_resolve_reverse(), evdns_resolve_reverse_ipv6()
|
||||||
*/
|
*/
|
||||||
int evdns_resolve_ipv6(const char *name, int flags, evdns_callback_type callback, void *ptr);
|
int evdns_resolve_ipv6(const char *name, int flags, evdns_callback_type callback, void *ptr);
|
||||||
|
|
||||||
struct in_addr;
|
struct in_addr;
|
||||||
@ -341,7 +342,7 @@ struct in6_addr;
|
|||||||
@param ptr an argument to pass to the callback function
|
@param ptr an argument to pass to the callback function
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@see evdns_resolve_reverse_ipv6()
|
@see evdns_resolve_reverse_ipv6()
|
||||||
*/
|
*/
|
||||||
int evdns_resolve_reverse(struct in_addr *in, int flags, evdns_callback_type callback, void *ptr);
|
int evdns_resolve_reverse(struct in_addr *in, int flags, evdns_callback_type callback, void *ptr);
|
||||||
|
|
||||||
|
|
||||||
@ -361,10 +362,10 @@ int evdns_resolve_reverse_ipv6(struct in6_addr *in, int flags, evdns_callback_ty
|
|||||||
/**
|
/**
|
||||||
Set the value of a configuration option.
|
Set the value of a configuration option.
|
||||||
|
|
||||||
The currently available configuration options are:
|
The currently available configuration options are:
|
||||||
|
|
||||||
ndots, timeout, max-timeouts, max-inflight, and attempts
|
ndots, timeout, max-timeouts, max-inflight, and attempts
|
||||||
|
|
||||||
@param option the name of the configuration option to be modified
|
@param option the name of the configuration option to be modified
|
||||||
@param val the value to be set
|
@param val the value to be set
|
||||||
@param flags either 0 | DNS_OPTION_SEARCH | DNS_OPTION_MISC
|
@param flags either 0 | DNS_OPTION_SEARCH | DNS_OPTION_MISC
|
||||||
@ -376,17 +377,22 @@ int evdns_set_option(const char *option, const char *val, int flags);
|
|||||||
/**
|
/**
|
||||||
Parse a resolv.conf file.
|
Parse a resolv.conf file.
|
||||||
|
|
||||||
The 'flags' parameter determines what information is parsed from
|
The 'flags' parameter determines what information is parsed from the
|
||||||
the resolv.conf file. See the man page for resolv.conf for the format of this file.
|
resolv.conf file. See the man page for resolv.conf for the format of this
|
||||||
The following directives are not parsed from the file: sortlist, rotate, no-check-names, inet6, debug
|
file.
|
||||||
|
|
||||||
If this function encounters an error, the possible return values are:
|
The following directives are not parsed from the file: sortlist, rotate,
|
||||||
1 = failed to open file, 2 = failed to stat file, 3 = file too large,
|
no-check-names, inet6, debug.
|
||||||
4 = out of memory, 5 = short read from file, 6 = no nameservers listed in the file
|
|
||||||
|
|
||||||
@param flags any of DNS_OPTION_NAMESERVERS|DNS_OPTION_SEARCH|DNS_OPTION_MISC|DNS_OPTIONS_ALL
|
If this function encounters an error, the possible return values are: 1 =
|
||||||
|
failed to open file, 2 = failed to stat file, 3 = file too large, 4 = out of
|
||||||
|
memory, 5 = short read from file, 6 = no nameservers listed in the file
|
||||||
|
|
||||||
|
@param flags any of DNS_OPTION_NAMESERVERS|DNS_OPTION_SEARCH|DNS_OPTION_MISC|
|
||||||
|
DNS_OPTIONS_ALL
|
||||||
@param filename the path to the resolv.conf file
|
@param filename the path to the resolv.conf file
|
||||||
@return 0 if successful, or various positive error codes if an error occurred (see above)
|
@return 0 if successful, or various positive error codes if an error
|
||||||
|
occurred (see above)
|
||||||
@see resolv.conf(3), evdns_config_windows_nameservers()
|
@see resolv.conf(3), evdns_config_windows_nameservers()
|
||||||
*/
|
*/
|
||||||
int evdns_resolv_conf_parse(int flags, const char *filename);
|
int evdns_resolv_conf_parse(int flags, const char *filename);
|
||||||
@ -397,7 +403,7 @@ int evdns_resolv_conf_parse(int flags, const char *filename);
|
|||||||
|
|
||||||
Attempt to configure a set of nameservers based on platform settings on
|
Attempt to configure a set of nameservers based on platform settings on
|
||||||
a win32 host. Preferentially tries to use GetNetworkParams; if that fails,
|
a win32 host. Preferentially tries to use GetNetworkParams; if that fails,
|
||||||
looks in the registry.
|
looks in the registry.
|
||||||
|
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@see evdns_resolv_conf_parse()
|
@see evdns_resolv_conf_parse()
|
||||||
@ -414,7 +420,7 @@ void evdns_search_clear(void);
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Add a domain to the list of search domains
|
Add a domain to the list of search domains
|
||||||
|
|
||||||
@param domain the domain to be added to the search list
|
@param domain the domain to be added to the search list
|
||||||
*/
|
*/
|
||||||
@ -431,8 +437,8 @@ void evdns_search_add(const char *domain);
|
|||||||
*/
|
*/
|
||||||
void evdns_search_ndots_set(const int ndots);
|
void evdns_search_ndots_set(const int ndots);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
A callback that is invoked when a log message is generated
|
A callback that is invoked when a log message is generated
|
||||||
|
|
||||||
@param is_warning indicates if the log message is a 'warning'
|
@param is_warning indicates if the log message is a 'warning'
|
||||||
@param msg the content of the log message
|
@param msg the content of the log message
|
||||||
|
304
event.h
304
event.h
@ -28,76 +28,107 @@
|
|||||||
#define _EVENT_H_
|
#define _EVENT_H_
|
||||||
|
|
||||||
/** @mainpage
|
/** @mainpage
|
||||||
|
|
||||||
@section intro Introduction
|
@section intro Introduction
|
||||||
|
|
||||||
libevent is an event notification library for developing scalable
|
libevent is an event notification library for developing scalable network
|
||||||
network servers. The libevent API provides a mechanism to execute a callback function when a specific
|
servers. The libevent API provides a mechanism to execute a callback
|
||||||
event occurs on a file descriptor or after a timeout has been reached. Furthermore,
|
function when a specific event occurs on a file descriptor or after a
|
||||||
libevent also support callbacks due to signals or regular timeouts.
|
timeout has been reached. Furthermore, libevent also support callbacks due
|
||||||
|
to signals or regular timeouts.
|
||||||
libevent is meant to replace the event loop found in event driven network servers. An application just needs to call event_dispatch() and then add or remove events dynamically without having to change the event loop.
|
|
||||||
|
|
||||||
Currently, libevent supports /dev/poll, kqueue(2), select(2), poll(2) and epoll(4). It also has experimental support for real-time signals. The internal event mechanism is completely independent of the exposed event API, and a simple update of libevent can provide new functionality without having to redesign the applications. As a result, Libevent allows for portable application development and provides the most scalable event notification mechanism available on an operating system. Libevent can also be used for multi-threaded aplications; see Steven Grimm's explanation. Libevent should compile on Linux, *BSD, Mac OS X, Solaris and Windows.
|
libevent is meant to replace the event loop found in event driven network
|
||||||
|
servers. An application just needs to call event_dispatch() and then add or
|
||||||
|
remove events dynamically without having to change the event loop.
|
||||||
|
|
||||||
|
Currently, libevent supports /dev/poll, kqueue(2), select(2), poll(2) and
|
||||||
|
epoll(4). It also has experimental support for real-time signals. The
|
||||||
|
internal event mechanism is completely independent of the exposed event API,
|
||||||
|
and a simple update of libevent can provide new functionality without having
|
||||||
|
to redesign the applications. As a result, Libevent allows for portable
|
||||||
|
application development and provides the most scalable event notification
|
||||||
|
mechanism available on an operating system. Libevent can also be used for
|
||||||
|
multi-threaded aplications; see Steven Grimm's explanation. Libevent should
|
||||||
|
compile on Linux, *BSD, Mac OS X, Solaris and Windows.
|
||||||
|
|
||||||
@section usage Standard usage
|
@section usage Standard usage
|
||||||
|
|
||||||
Every program that uses libevent must include the <event.h> header, and pass the -levent flag to the linker.
|
Every program that uses libevent must include the <event.h> header, and pass
|
||||||
Before using any of the functions in the library, you must call event_init() to perform
|
the -levent flag to the linker. Before using any of the functions in the
|
||||||
one-time initialization of the libevent library.
|
library, you must call event_init() to perform one-time initialization of
|
||||||
|
the libevent library.
|
||||||
|
|
||||||
@section event Event notification
|
@section event Event notification
|
||||||
|
|
||||||
For each file descriptor that you wish to monitor, you must declare an event structure and call event_set() to initialize the members of the structure.
|
For each file descriptor that you wish to monitor, you must declare an event
|
||||||
To enable notification, you add the structure
|
structure and call event_set() to initialize the members of the structure.
|
||||||
to the list of monitored events by calling event_add(). The
|
To enable notification, you add the structure to the list of monitored
|
||||||
event structure must remain allocated as long as it is active, so it should be
|
events by calling event_add(). The event structure must remain allocated as
|
||||||
allocated on the heap. Finally, you call event_dispatch()
|
long as it is active, so it should be allocated on the heap. Finally, you
|
||||||
to loop and dispatch events.
|
call event_dispatch() to loop and dispatch events.
|
||||||
|
|
||||||
@section bufferevent I/O Buffers
|
@section bufferevent I/O Buffers
|
||||||
|
|
||||||
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 instead is reading from input and writing to output buffers.
|
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 instead is reading
|
||||||
|
from input and writing to output buffers.
|
||||||
|
|
||||||
Once initialized via bufferevent_new(), the bufferevent structure can be used repeatedly with bufferevent_enable() and bufferevent_disable(). Instead of reading and writing directly to a socket, you would call bufferevent_read() and bufferevent_write().
|
Once initialized via bufferevent_new(), the bufferevent structure can be
|
||||||
|
used repeatedly with bufferevent_enable() and bufferevent_disable().
|
||||||
|
Instead of reading and writing directly to a socket, you would call
|
||||||
|
bufferevent_read() and bufferevent_write().
|
||||||
|
|
||||||
When read enabled the bufferevent will try to read from the file descriptor and call the read callback. The write callback is executed whenever the output buffer is drained below the write low watermark, which is 0 by default.
|
When read enabled the bufferevent will try to read from the file descriptor
|
||||||
|
and call the read callback. The write callback is executed whenever the
|
||||||
|
output buffer is drained below the write low watermark, which is 0 by
|
||||||
|
default.
|
||||||
|
|
||||||
@section timers Timers
|
@section timers Timers
|
||||||
|
|
||||||
libevent can also be used to create timers that invoke a callback after a
|
libevent can also be used to create timers that invoke a callback after a
|
||||||
certain amount of time has expired. The evtimer_set() function prepares
|
certain amount of time has expired. The evtimer_set() function prepares an
|
||||||
an event struct to be used as a timer. To activate the timer, call evtimer_add(). Timers can be deactivated by calling evtimer_del().
|
event struct to be used as a timer. To activate the timer, call
|
||||||
|
evtimer_add(). Timers can be deactivated by calling evtimer_del().
|
||||||
|
|
||||||
@section timeouts Timeouts
|
@section timeouts Timeouts
|
||||||
|
|
||||||
In addition to simple timers, libevent can assign timeout events to file
|
In addition to simple timers, libevent can assign timeout events to file
|
||||||
descriptors that are triggered whenever a certain amount of time has passed
|
descriptors that are triggered whenever a certain amount of time has passed
|
||||||
with no activity on a file descriptor. The timeout_set() function initializes
|
with no activity on a file descriptor. The timeout_set() function
|
||||||
an event struct for use as a timeout. Once initialized, the event must be
|
initializes an event struct for use as a timeout. Once initialized, the
|
||||||
activated by using timeout_add(). To cancel the timeout, call timeout_del().
|
event must be activated by using timeout_add(). To cancel the timeout, call
|
||||||
|
timeout_del().
|
||||||
|
|
||||||
@section evdns Asynchronous DNS resolution
|
@section evdns Asynchronous DNS resolution
|
||||||
|
|
||||||
libevent provides an asynchronous DNS resolver that should be used instead of the
|
libevent provides an asynchronous DNS resolver that should be used instead
|
||||||
standard DNS resolver functions. These functions can be imported by including
|
of the standard DNS resolver functions. These functions can be imported by
|
||||||
the <evdns.h> header in your program. Before using any of the resolver functions, you must call evdns_init() to initialize the library. To convert a hostname to an IP address, you call
|
including the <evdns.h> header in your program. Before using any of the
|
||||||
the evdns_resolve_ipv4() function. To perform a reverse lookup, you would call the
|
resolver functions, you must call evdns_init() to initialize the library. To
|
||||||
evdns_resolve_reverse() function. All of these functions use callbacks to avoid
|
convert a hostname to an IP address, you call the evdns_resolve_ipv4()
|
||||||
blocking while the lookup is performed.
|
function. To perform a reverse lookup, you would call the
|
||||||
|
evdns_resolve_reverse() function. All of these functions use callbacks to
|
||||||
|
avoid blocking while the lookup is performed.
|
||||||
|
|
||||||
@section evhttp Event-driven HTTP servers
|
@section evhttp Event-driven HTTP servers
|
||||||
|
|
||||||
libevent provides a very simple event-driven HTTP server that can be embedded in your program
|
libevent provides a very simple event-driven HTTP server that can be
|
||||||
and used to service HTTP requests.
|
embedded in your program and used to service HTTP requests.
|
||||||
|
|
||||||
To use this capability, you need to include the <evhttp.h> header in your program.
|
To use this capability, you need to include the <evhttp.h> header in your
|
||||||
You create the server by calling evhttp_start() and providing the address and port to listen on. You then register one or more callbacks to handle incoming requests. Each URI can be assigned a callback via the evhttp_set_cb() function. A generic callback function can also be registered via evhttp_set_gencb(); this callback will be invoked if no other callbacks have been
|
program. You create the server by calling evhttp_start() and providing the
|
||||||
registered for a given URI.
|
address and port to listen on. You then register one or more callbacks to
|
||||||
|
handle incoming requests. Each URI can be assigned a callback via the
|
||||||
|
evhttp_set_cb() function. A generic callback function can also be
|
||||||
|
registered via evhttp_set_gencb(); this callback will be invoked if no other
|
||||||
|
callbacks have been registered for a given URI.
|
||||||
|
|
||||||
@section api API Reference
|
@section api API Reference
|
||||||
|
|
||||||
To browse the complete documentation of the libevent API, click on any of the following links.
|
To browse the complete documentation of the libevent API, click on any of
|
||||||
|
the following links.
|
||||||
|
|
||||||
event.h
|
event.h
|
||||||
The primary libevent header
|
The primary libevent header
|
||||||
@ -107,13 +138,13 @@ When read enabled the bufferevent will try to read from the file descriptor and
|
|||||||
|
|
||||||
evhttp.h
|
evhttp.h
|
||||||
An embedded libevent-based HTTP server
|
An embedded libevent-based HTTP server
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** @file event.h
|
/** @file event.h
|
||||||
|
|
||||||
A library for writing event-driven network servers
|
A library for writing event-driven network servers
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -232,7 +263,7 @@ struct eventop {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Initialize the event API.
|
Initialize the event API.
|
||||||
|
|
||||||
The event API needs to be initialized with event_init() before it can be
|
The event API needs to be initialized with event_init() before it can be
|
||||||
used.
|
used.
|
||||||
*/
|
*/
|
||||||
@ -241,11 +272,11 @@ void *event_init(void);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Loop to process events.
|
Loop to process events.
|
||||||
|
|
||||||
In order to process events, an application needs to call
|
In order to process events, an application needs to call
|
||||||
event_dispatch(). This function only returns on error, and should
|
event_dispatch(). This function only returns on error, and should
|
||||||
replace the event core of the application program.
|
replace the event core of the application program.
|
||||||
|
|
||||||
@see event_base_dispatch()
|
@see event_base_dispatch()
|
||||||
*/
|
*/
|
||||||
int event_dispatch(void);
|
int event_dispatch(void);
|
||||||
@ -253,7 +284,7 @@ int event_dispatch(void);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Threadsafe event dispatching loop.
|
Threadsafe event dispatching loop.
|
||||||
|
|
||||||
@param eb the event_base structure returned by event_init()
|
@param eb the event_base structure returned by event_init()
|
||||||
@see event_init(), event_dispatch()
|
@see event_init(), event_dispatch()
|
||||||
*/
|
*/
|
||||||
@ -262,7 +293,7 @@ int event_base_dispatch(struct event_base *);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Deallocate all memory associated with an event_base.
|
Deallocate all memory associated with an event_base.
|
||||||
|
|
||||||
@param eb an event_base to be freed
|
@param eb an event_base to be freed
|
||||||
*/
|
*/
|
||||||
void event_base_free(struct event_base *);
|
void event_base_free(struct event_base *);
|
||||||
@ -275,7 +306,7 @@ void event_base_free(struct event_base *);
|
|||||||
typedef void (*event_log_cb)(int severity, const char *msg);
|
typedef void (*event_log_cb)(int severity, const char *msg);
|
||||||
void event_set_log_callback(event_log_cb cb);
|
void event_set_log_callback(event_log_cb cb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Associate a different event base with an event.
|
Associate a different event base with an event.
|
||||||
|
|
||||||
@param eb the event base
|
@param eb the event base
|
||||||
@ -284,7 +315,7 @@ void event_set_log_callback(event_log_cb cb);
|
|||||||
int event_base_set(struct event_base *, struct event *);
|
int event_base_set(struct event_base *, struct event *);
|
||||||
|
|
||||||
/** A flag for event_loop() to indicate ... (FIXME) */
|
/** A flag for event_loop() to indicate ... (FIXME) */
|
||||||
#define EVLOOP_ONCE 0x01
|
#define EVLOOP_ONCE 0x01
|
||||||
|
|
||||||
/** A flag for event_loop() to indicate ... (FIXME) */
|
/** A flag for event_loop() to indicate ... (FIXME) */
|
||||||
#define EVLOOP_NONBLOCK 0x02
|
#define EVLOOP_NONBLOCK 0x02
|
||||||
@ -292,8 +323,8 @@ int event_base_set(struct event_base *, struct event *);
|
|||||||
/**
|
/**
|
||||||
Execute a single event.
|
Execute a single event.
|
||||||
|
|
||||||
The event_loop() function provides an interface for single pass execution of pending
|
The event_loop() function provides an interface for single pass execution of
|
||||||
events.
|
pending events.
|
||||||
|
|
||||||
@param flags any combination of EVLOOP_ONCE | EVLOOP_NONBLOCK
|
@param flags any combination of EVLOOP_ONCE | EVLOOP_NONBLOCK
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@ -304,8 +335,8 @@ int event_loop(int);
|
|||||||
/**
|
/**
|
||||||
Execute a single event (threadsafe variant).
|
Execute a single event (threadsafe variant).
|
||||||
|
|
||||||
The event_base_loop() function provides an interface for single pass execution of pending
|
The event_base_loop() function provides an interface for single pass
|
||||||
events.
|
execution of pending events.
|
||||||
|
|
||||||
@param eb the event_base structure returned by event_init()
|
@param eb the event_base structure returned by event_init()
|
||||||
@param flags any combination of EVLOOP_ONCE | EVLOOP_NONBLOCK
|
@param flags any combination of EVLOOP_ONCE | EVLOOP_NONBLOCK
|
||||||
@ -317,9 +348,9 @@ int event_base_loop(struct event_base *, int);
|
|||||||
/**
|
/**
|
||||||
Execute a single event, with a timeout.
|
Execute a single event, with a timeout.
|
||||||
|
|
||||||
The event_loopexit() function is similar to event_loop(),
|
The event_loopexit() function is similar to event_loop(), but allows the
|
||||||
but allows the loop to be terminated after some amount of time has passed.
|
loop to be terminated after some amount of time has passed.
|
||||||
|
|
||||||
@param tv the amount of time after which the loop should terminate.
|
@param tv the amount of time after which the loop should terminate.
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@see event_loop(), event_base_loop(), event_base_loopexit()
|
@see event_loop(), event_base_loop(), event_base_loopexit()
|
||||||
@ -327,20 +358,20 @@ int event_base_loop(struct event_base *, int);
|
|||||||
int event_loopexit(struct timeval *);
|
int event_loopexit(struct timeval *);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Execute a single event, with a timeout (threadsafe variant).
|
Execute a single event, with a timeout (threadsafe variant).
|
||||||
|
|
||||||
@param eb the event_base structure returned by event_init()
|
@param eb the event_base structure returned by event_init()
|
||||||
@param tv the amount of time after which the loop should terminate.
|
@param tv the amount of time after which the loop should terminate.
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@see event_loopexit()
|
@see event_loopexit()
|
||||||
*/
|
*/
|
||||||
int event_base_loopexit(struct event_base *, struct timeval *);
|
int event_base_loopexit(struct event_base *, struct timeval *);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Add a timer event.
|
Add a timer event.
|
||||||
|
|
||||||
@param ev the event struct
|
@param ev the event struct
|
||||||
@param tv timeval struct
|
@param tv timeval struct
|
||||||
*/
|
*/
|
||||||
@ -349,7 +380,7 @@ int event_base_loopexit(struct event_base *, struct timeval *);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Define a timer event.
|
Define a timer event.
|
||||||
|
|
||||||
@param ev event struct to be modified
|
@param ev event struct to be modified
|
||||||
@param cb callback function
|
@param cb callback function
|
||||||
@param arg argument that will be passed to the callback function
|
@param arg argument that will be passed to the callback function
|
||||||
@ -405,19 +436,20 @@ int event_base_loopexit(struct event_base *, struct timeval *);
|
|||||||
/**
|
/**
|
||||||
Prepare an event structure to be added.
|
Prepare an event structure to be added.
|
||||||
|
|
||||||
The function event_set() prepares the event structure ev to be used in future calls to
|
The function event_set() prepares the event structure ev to be used in
|
||||||
event_add() and event_del(). The event will be prepared to call the function specified
|
future calls to event_add() and event_del(). The event will be prepared to
|
||||||
by the fn argument with an int argument indicating the file descriptor, a short argument
|
call the function specified by the fn argument with an int argument
|
||||||
indicating the type of event, and a void * argument given in the arg argument. The fd
|
indicating the file descriptor, a short argument indicating the type of
|
||||||
indicates the file descriptor that should be monitored for events. The events can be
|
event, and a void * argument given in the arg argument. The fd indicates
|
||||||
either EV_READ, EV_WRITE, or both. Indicating that an application can read or write from
|
the file descriptor that should be monitored for events. The events can be
|
||||||
the file descriptor respectively without blocking.
|
either EV_READ, EV_WRITE, or both. Indicating that an application can read
|
||||||
|
or write from the file descriptor respectively without blocking.
|
||||||
|
|
||||||
|
The function fn will be called with the file descriptor that triggered the
|
||||||
|
event and the type of event which will be either EV_TIMEOUT, EV_SIGNAL,
|
||||||
|
EV_READ, or EV_WRITE. The additional flag EV_PERSIST makes an event_add()
|
||||||
|
persistent until event_del() has been called.
|
||||||
|
|
||||||
The function fn will be called with the file descriptor that triggered the event and the
|
|
||||||
type of event which will be either EV_TIMEOUT, EV_SIGNAL, EV_READ, or EV_WRITE. The
|
|
||||||
additional flag EV_PERSIST makes an event_add() persistent until event_del() has been
|
|
||||||
called.
|
|
||||||
|
|
||||||
@param ev an event struct to be modified
|
@param ev an event struct to be modified
|
||||||
@param fd the file descriptor to be monitored
|
@param fd the file descriptor to be monitored
|
||||||
@param event desired events to monitor; can be EV_READ and/or EV_WRITE
|
@param event desired events to monitor; can be EV_READ and/or EV_WRITE
|
||||||
@ -432,14 +464,17 @@ void event_set(struct event *, int, short, void (*)(int, short, void *), void *)
|
|||||||
/**
|
/**
|
||||||
Schedule a one-time event to occur.
|
Schedule a one-time event to occur.
|
||||||
|
|
||||||
The function event_once() is similar to event_set(). However, it schedules a callback to
|
The function event_once() is similar to event_set(). However, it schedules
|
||||||
be called exactly once and does not require the caller to prepare an event structure.
|
a callback to be called exactly once and does not require the caller to
|
||||||
|
prepare an event structure.
|
||||||
|
|
||||||
@param fd a file descriptor to monitor
|
@param fd a file descriptor to monitor
|
||||||
@param events event(s) to monitor; can be any of EV_TIMEOUT | EV_READ | EV_WRITE
|
@param events event(s) to monitor; can be any of EV_TIMEOUT | EV_READ |
|
||||||
|
EV_WRITE
|
||||||
@param callback callback function to be invoked when the event occurs
|
@param callback callback function to be invoked when the event occurs
|
||||||
@param arg an argument to be passed to the callback function
|
@param arg an argument to be passed to the callback function
|
||||||
@param timeout the maximum amount of time to wait for the event, or NULL to wait forever
|
@param timeout the maximum amount of time to wait for the event, or NULL
|
||||||
|
to wait forever
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@see event_set()
|
@see event_set()
|
||||||
|
|
||||||
@ -449,17 +484,19 @@ int event_once(int, short, void (*)(int, short, void *), void *, struct timeval
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Schedule a one-time event (threadsafe variant)
|
Schedule a one-time event (threadsafe variant)
|
||||||
|
|
||||||
The function event_base_once() is similar to event_set(). However, it schedules a
|
The function event_base_once() is similar to event_set(). However, it
|
||||||
callback to be called exactly once and does not require the caller to prepare an
|
schedules a callback to be called exactly once and does not require the
|
||||||
event structure.
|
caller to prepare an event structure.
|
||||||
|
|
||||||
@param base an event_base returned by event_init()
|
@param base an event_base returned by event_init()
|
||||||
@param fd a file descriptor to monitor
|
@param fd a file descriptor to monitor
|
||||||
@param events event(s) to monitor; can be any of EV_TIMEOUT | EV_READ | EV_WRITE
|
@param events event(s) to monitor; can be any of EV_TIMEOUT | EV_READ |
|
||||||
|
EV_WRITE
|
||||||
@param callback callback function to be invoked when the event occurs
|
@param callback callback function to be invoked when the event occurs
|
||||||
@param arg an argument to be passed to the callback function
|
@param arg an argument to be passed to the callback function
|
||||||
@param timeout the maximum amount of time to wait for the event, or NULL to wait forever
|
@param timeout the maximum amount of time to wait for the event, or NULL
|
||||||
|
to wait forever
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@see event_once()
|
@see event_once()
|
||||||
*/
|
*/
|
||||||
@ -469,16 +506,18 @@ int event_base_once(struct event_base *, int, short, void (*)(int, short, void *
|
|||||||
/**
|
/**
|
||||||
Add an event to the set of monitored events.
|
Add an event to the set of monitored events.
|
||||||
|
|
||||||
The function event_add() schedules the execution of the ev event when the event specified
|
The function event_add() schedules the execution of the ev event when the
|
||||||
in event_set() occurs or in at least the time specified in the tv. If tv is NULL, no
|
event specified in event_set() occurs or in at least the time specified in
|
||||||
timeout occurs and the function will only be called if a matching event occurs on the
|
the tv. If tv is NULL, no timeout occurs and the function will only be
|
||||||
file descriptor. The event in the ev argument must be already initialized by event_set()
|
called if a matching event occurs on the file descriptor. The event in the
|
||||||
and may not be used in calls to event_set() until it has timed out or been removed with
|
ev argument must be already initialized by event_set() and may not be used
|
||||||
event_del(). If the event in the ev argument already has a scheduled timeout, the old
|
in calls to event_set() until it has timed out or been removed with
|
||||||
timeout will be replaced by the new one.
|
event_del(). If the event in the ev argument already has a scheduled
|
||||||
|
timeout, the old timeout will be replaced by the new one.
|
||||||
|
|
||||||
@param ev an event struct initialized via event_set()
|
@param ev an event struct initialized via event_set()
|
||||||
@param timeout the maximum amount of time to wait for the event, or NULL to wait forever
|
@param timeout the maximum amount of time to wait for the event, or NULL
|
||||||
|
to wait forever
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@see event_del(), event_set()
|
@see event_del(), event_set()
|
||||||
*/
|
*/
|
||||||
@ -488,8 +527,9 @@ int event_add(struct event *, struct timeval *);
|
|||||||
/**
|
/**
|
||||||
Remove an event from the set of monitored events.
|
Remove an event from the set of monitored events.
|
||||||
|
|
||||||
The function event_del() will cancel the event in the argument ev. If the event has
|
The function event_del() will cancel the event in the argument ev. If the
|
||||||
already executed or has never been added the call will have no effect.
|
event has already executed or has never been added the call will have no
|
||||||
|
effect.
|
||||||
|
|
||||||
@param ev an event struct to be removed from the working set
|
@param ev an event struct to be removed from the working set
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@ -501,11 +541,11 @@ void event_active(struct event *, int, short);
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
||||||
Checks if a specific event is pending or scheduled.
|
Checks if a specific event is pending or scheduled.
|
||||||
|
|
||||||
@param ev an event struct previously passed to event_add()
|
@param ev an event struct previously passed to event_add()
|
||||||
@param event the requested event type; any of EV_TIMEOUT|EV_READ|EV_WRITE|EV_SIGNAL
|
@param event the requested event type; any of EV_TIMEOUT|EV_READ|
|
||||||
|
EV_WRITE|EV_SIGNAL
|
||||||
@param tv an alternate timeout (FIXME - is this true?)
|
@param tv an alternate timeout (FIXME - is this true?)
|
||||||
|
|
||||||
@return 1 if the event is pending, or 0 if the event has not occurred
|
@return 1 if the event is pending, or 0 if the event has not occurred
|
||||||
@ -517,10 +557,12 @@ int event_pending(struct event *, short, struct timeval *);
|
|||||||
/**
|
/**
|
||||||
Test if an event structure has been initialized.
|
Test if an event structure has been initialized.
|
||||||
|
|
||||||
The event_initialized() macro can be used to check if an event has been initialized.
|
The event_initialized() macro can be used to check if an event has been
|
||||||
|
initialized.
|
||||||
|
|
||||||
@param ev an event structure to be tested
|
@param ev an event structure to be tested
|
||||||
@return 1 if the structure has been initialized, or 0 if it has not been initialized
|
@return 1 if the structure has been initialized, or 0 if it has not been
|
||||||
|
initialized
|
||||||
*/
|
*/
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
#define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT && (ev)->ev_fd != (int)INVALID_HANDLE_VALUE)
|
#define event_initialized(ev) ((ev)->ev_flags & EVLIST_INIT && (ev)->ev_fd != (int)INVALID_HANDLE_VALUE)
|
||||||
@ -548,16 +590,17 @@ const char *event_get_method(void);
|
|||||||
/**
|
/**
|
||||||
Set the number of different event priorities.
|
Set the number of different event priorities.
|
||||||
|
|
||||||
By default libevent schedules all active events with the same priority. However, some
|
By default libevent schedules all active events with the same priority.
|
||||||
time it is desirable to process some events with a higher priority than others. For that
|
However, some time it is desirable to process some events with a higher
|
||||||
reason, libevent supports strict priority queues. Active events with a lower priority
|
priority than others. For that reason, libevent supports strict priority
|
||||||
are always processed before events with a higher 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()
|
The number of different priorities can be set initially with the
|
||||||
function. This function should be called before the first call to event_dispatch(). The
|
event_priority_init() function. This function should be called before the
|
||||||
event_priority_set() function can be used to assign a priority to an event. By default,
|
first call to event_dispatch(). The event_priority_set() function can be
|
||||||
libevent assigns the middle priority to all events unless their priority is explicitly
|
used to assign a priority to an event. By default, libevent assigns the
|
||||||
set.
|
middle priority to all events unless their priority is explicitly set.
|
||||||
|
|
||||||
@param npriorities the maximum number of priorities
|
@param npriorities the maximum number of priorities
|
||||||
@return 0 if successful, or -1 if an error occurred
|
@return 0 if successful, or -1 if an error occurred
|
||||||
@ -569,7 +612,7 @@ int event_priority_init(int);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Set the number of different event priorities (threadsafe variant).
|
Set the number of different event priorities (threadsafe variant).
|
||||||
|
|
||||||
See the description of event_priority_init() for more information.
|
See the description of event_priority_init() for more information.
|
||||||
|
|
||||||
@param eb the event_base structure returned by event_init()
|
@param eb the event_base structure returned by event_init()
|
||||||
@ -652,23 +695,29 @@ struct bufferevent {
|
|||||||
user of a buffered event no longer deals directly with the I/O, but
|
user of a buffered event no longer deals directly with the I/O, but
|
||||||
instead is reading from input and writing to output buffers.
|
instead is reading from input and writing to output buffers.
|
||||||
|
|
||||||
Once initialized, the bufferevent structure can be used repeatedly with
|
Once initialized, the bufferevent structure can be used repeatedly with
|
||||||
bufferevent_enable() and bufferevent_disable().
|
bufferevent_enable() and bufferevent_disable().
|
||||||
|
|
||||||
When read enabled the bufferevent will try to read from the file descriptor and
|
When read enabled the bufferevent will try to read from the file descriptor
|
||||||
call the read callback. The write callback is executed whenever the output buffer
|
and call the read callback. The write callback is executed whenever the
|
||||||
is drained below the write low watermark, which is 0 by default.
|
output buffer is drained below the write low watermark, which is 0 by
|
||||||
|
default.
|
||||||
|
|
||||||
If multiple bases are in use, bufferevent_base_set() must be called before enabling the
|
If multiple bases are in use, bufferevent_base_set() must be called before
|
||||||
bufferevent for the first time.
|
enabling the bufferevent for the first time.
|
||||||
|
|
||||||
@param fd the file descriptor from which data is read and written to.
|
@param fd the file descriptor from which data is read and written to.
|
||||||
This file descriptor is not allowed to be a pipe(2).
|
This file descriptor is not allowed to be a pipe(2).
|
||||||
@param readcb callback to invoke when there is data to be read, or NULL if no callback is desired
|
@param readcb callback to invoke when there is data to be read, or NULL if
|
||||||
@param writecb callback to invoke when the file descriptor is ready for writing, or NULL if no callback is desired
|
no callback is desired
|
||||||
@param errorcb callback to invoke when there is an error on the file descriptor
|
@param writecb callback to invoke when the file descriptor is ready for
|
||||||
@param cbarg an argument that will be supplied to each of the callbacks (readcb, writecb, and errorcb)
|
writing, or NULL if no callback is desired
|
||||||
@return a pointer to a newly allocated bufferevent struct, or NULL if an error occurred
|
@param errorcb callback to invoke when there is an error on the file
|
||||||
|
descriptor
|
||||||
|
@param cbarg an argument that will be supplied to each of the callbacks
|
||||||
|
(readcb, writecb, and errorcb)
|
||||||
|
@return a pointer to a newly allocated bufferevent struct, or NULL if an
|
||||||
|
error occurred
|
||||||
@see bufferevent_base_set(), bufferevent_free()
|
@see bufferevent_base_set(), bufferevent_free()
|
||||||
*/
|
*/
|
||||||
struct bufferevent *bufferevent_new(int fd,
|
struct bufferevent *bufferevent_new(int fd,
|
||||||
@ -707,10 +756,10 @@ void bufferevent_free(struct bufferevent *bufev);
|
|||||||
/**
|
/**
|
||||||
Write data to a bufferevent buffer.
|
Write data to a bufferevent buffer.
|
||||||
|
|
||||||
The bufferevent_write() function can be used to write data to the file descriptor. The
|
The bufferevent_write() function can be used to write data to the file
|
||||||
data is appended to the output buffer and written to the descriptor automatically as it
|
descriptor. The data is appended to the output buffer and written to the
|
||||||
becomes available for writing.
|
descriptor automatically as it becomes available for writing.
|
||||||
|
|
||||||
@param bufev the bufferevent to be written to
|
@param bufev the bufferevent to be written to
|
||||||
@param data a pointer to the data to be written
|
@param data a pointer to the data to be written
|
||||||
@param size the length of the data, in bytes
|
@param size the length of the data, in bytes
|
||||||
@ -785,7 +834,8 @@ void bufferevent_settimeout(struct bufferevent *bufev,
|
|||||||
/**
|
/**
|
||||||
Allocate storage for a new evbuffer.
|
Allocate storage for a new evbuffer.
|
||||||
|
|
||||||
@return a pointer to a newly allocated evbuffer struct, or NULL if an error occurred
|
@return a pointer to a newly allocated evbuffer struct, or NULL if an error
|
||||||
|
occurred
|
||||||
*/
|
*/
|
||||||
struct evbuffer *evbuffer_new(void);
|
struct evbuffer *evbuffer_new(void);
|
||||||
|
|
||||||
@ -801,7 +851,7 @@ void evbuffer_free(struct evbuffer *);
|
|||||||
/**
|
/**
|
||||||
Expands the available space in an event buffer.
|
Expands the available space in an event buffer.
|
||||||
|
|
||||||
Expands the available space in the event buffer to at least datlen
|
Expands the available space in the event buffer to at least datlen
|
||||||
|
|
||||||
@param buf the event buffer to be expanded
|
@param buf the event buffer to be expanded
|
||||||
@param datlen the new minimum length requirement
|
@param datlen the new minimum length requirement
|
||||||
@ -903,7 +953,7 @@ int evbuffer_write(struct evbuffer *, int);
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Read from a file descriptor and store the result in an evbuffer.
|
Read from a file descriptor and store the result in an evbuffer.
|
||||||
|
|
||||||
@param buf the evbuffer to store the result
|
@param buf the evbuffer to store the result
|
||||||
@param fd the file descriptor to read from
|
@param fd the file descriptor to read from
|
||||||
@ -933,7 +983,7 @@ u_char *evbuffer_find(struct evbuffer *, const u_char *, size_t);
|
|||||||
*/
|
*/
|
||||||
void evbuffer_setcb(struct evbuffer *, void (*)(struct evbuffer *, size_t, size_t, void *), void *);
|
void evbuffer_setcb(struct evbuffer *, void (*)(struct evbuffer *, size_t, size_t, void *), void *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Marshaling tagged data - We assume that all tags are inserted in their
|
* Marshaling tagged data - We assume that all tags are inserted in their
|
||||||
* numeric order - so that unknown tags will always be higher than the
|
* numeric order - so that unknown tags will always be higher than the
|
||||||
* known ones - and we can just ignore the end of an event buffer.
|
* known ones - and we can just ignore the end of an event buffer.
|
||||||
@ -946,7 +996,7 @@ void evtag_marshal(struct evbuffer *evbuf, uint8_t tag, const void *data,
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
Encode an integer and store it in an evbuffer.
|
Encode an integer and store it in an evbuffer.
|
||||||
|
|
||||||
We encode integer's by nibbles; the first nibble contains the number
|
We encode integer's by nibbles; the first nibble contains the number
|
||||||
of significant nibbles - 1; this allows us to encode up to 64-bit
|
of significant nibbles - 1; this allows us to encode up to 64-bit
|
||||||
integers. This function is byte-order independent.
|
integers. This function is byte-order independent.
|
||||||
|
25
evhttp.h
25
evhttp.h
@ -72,10 +72,10 @@ struct evkeyvalq;
|
|||||||
*/
|
*/
|
||||||
struct evhttp *evhttp_new(struct event_base *base);
|
struct evhttp *evhttp_new(struct event_base *base);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start an HTTP server on the specified address and port.
|
* Start an HTTP server on the specified address and port.
|
||||||
*
|
*
|
||||||
* Can be called multiple times to bind the same http server
|
* Can be called multiple times to bind the same http server
|
||||||
* to multiple different ports.
|
* to multiple different ports.
|
||||||
*
|
*
|
||||||
* @param address a string containing the IP address to listen(2) on
|
* @param address a string containing the IP address to listen(2) on
|
||||||
@ -86,7 +86,7 @@ struct evhttp *evhttp_new(struct event_base *base);
|
|||||||
int evhttp_bind_socket(struct evhttp *http, const char *address, u_short port);
|
int evhttp_bind_socket(struct evhttp *http, const char *address, u_short port);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Free the previously created HTTP server.
|
* Free the previously created HTTP server.
|
||||||
*
|
*
|
||||||
* Works only if no requests are currently being served.
|
* Works only if no requests are currently being served.
|
||||||
*
|
*
|
||||||
@ -102,11 +102,12 @@ void evhttp_set_cb(struct evhttp *, const char *,
|
|||||||
/** Removes the callback for a specified URI */
|
/** Removes the callback for a specified URI */
|
||||||
int evhttp_del_cb(struct evhttp *, const char *);
|
int evhttp_del_cb(struct evhttp *, const char *);
|
||||||
|
|
||||||
/** Set a callback for all requests that are not caught by specific callbacks */
|
/** Set a callback for all requests that are not caught by specific callbacks
|
||||||
|
*/
|
||||||
void evhttp_set_gencb(struct evhttp *,
|
void evhttp_set_gencb(struct evhttp *,
|
||||||
void (*)(struct evhttp_request *, void *), void *);
|
void (*)(struct evhttp_request *, void *), void *);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the timeout for an HTTP request.
|
* Set the timeout for an HTTP request.
|
||||||
*
|
*
|
||||||
* @param http an evhttp object
|
* @param http an evhttp object
|
||||||
@ -140,7 +141,7 @@ void evhttp_send_reply(struct evhttp_request *, int, const char *,
|
|||||||
void evhttp_send_reply_start(struct evhttp_request *, int, const char *);
|
void evhttp_send_reply_start(struct evhttp_request *, int, const char *);
|
||||||
void evhttp_send_reply_chunk(struct evhttp_request *, struct evbuffer *);
|
void evhttp_send_reply_chunk(struct evhttp_request *, struct evbuffer *);
|
||||||
void evhttp_send_reply_end(struct evhttp_request *);
|
void evhttp_send_reply_end(struct evhttp_request *);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Start an HTTP server on the specified address and port
|
* Start an HTTP server on the specified address and port
|
||||||
* DEPRECATED: it does not allow an event base to be specified
|
* DEPRECATED: it does not allow an event base to be specified
|
||||||
@ -165,9 +166,9 @@ struct evhttp_request {
|
|||||||
/* the connection object that this request belongs to */
|
/* the connection object that this request belongs to */
|
||||||
struct evhttp_connection *evcon;
|
struct evhttp_connection *evcon;
|
||||||
int flags;
|
int flags;
|
||||||
#define EVHTTP_REQ_OWN_CONNECTION 0x0001
|
#define EVHTTP_REQ_OWN_CONNECTION 0x0001
|
||||||
#define EVHTTP_PROXY_REQUEST 0x0002
|
#define EVHTTP_PROXY_REQUEST 0x0002
|
||||||
|
|
||||||
struct evkeyvalq *input_headers;
|
struct evkeyvalq *input_headers;
|
||||||
struct evkeyvalq *output_headers;
|
struct evkeyvalq *output_headers;
|
||||||
|
|
||||||
@ -182,7 +183,7 @@ struct evhttp_request {
|
|||||||
|
|
||||||
char major; /* HTTP Major number */
|
char major; /* HTTP Major number */
|
||||||
char minor; /* HTTP Minor number */
|
char minor; /* HTTP Minor number */
|
||||||
|
|
||||||
int got_firstline;
|
int got_firstline;
|
||||||
int response_code; /* HTTP Response code */
|
int response_code; /* HTTP Response code */
|
||||||
char *response_code_line; /* Readable response */
|
char *response_code_line; /* Readable response */
|
||||||
@ -197,7 +198,7 @@ struct evhttp_request {
|
|||||||
void (*cb)(struct evhttp_request *, void *);
|
void (*cb)(struct evhttp_request *, void *);
|
||||||
void *cb_arg;
|
void *cb_arg;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Chunked data callback - call for each completed chunk if
|
* Chunked data callback - call for each completed chunk if
|
||||||
* specified. If not specified, all the data is delivered via
|
* specified. If not specified, all the data is delivered via
|
||||||
* the regular callback.
|
* the regular callback.
|
||||||
@ -205,7 +206,7 @@ struct evhttp_request {
|
|||||||
void (*chunk_cb)(struct evhttp_request *, void *);
|
void (*chunk_cb)(struct evhttp_request *, void *);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new request object that needs to be filled in with the request
|
* Creates a new request object that needs to be filled in with the request
|
||||||
* parameters. The callback is executed when the request completed or an
|
* parameters. The callback is executed when the request completed or an
|
||||||
* error occurred.
|
* error occurred.
|
||||||
@ -297,7 +298,7 @@ char *evhttp_encode_uri(const char *uri);
|
|||||||
char *evhttp_decode_uri(const char *uri);
|
char *evhttp_decode_uri(const char *uri);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to parse out arguments in a query.
|
* Helper function to parse out arguments in a query.
|
||||||
* The arguments are separated by key and value.
|
* The arguments are separated by key and value.
|
||||||
* URI should already be decoded.
|
* URI should already be decoded.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user