mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-12 13:58:58 -04:00
provide an api for retrieving the supported event mechanisms
svn:r788
This commit is contained in:
parent
0a804f3c83
commit
3b2022ef3a
@ -91,7 +91,7 @@ Changes in current version:
|
|||||||
o support for virtual HTTP hosts.
|
o support for virtual HTTP hosts.
|
||||||
o turn event_initialized() into a function, and add function equivalents to EVENT_SIGNAL and EVENT_FD so that people don't need to include event_struct.h
|
o turn event_initialized() into a function, and add function equivalents to EVENT_SIGNAL and EVENT_FD so that people don't need to include event_struct.h
|
||||||
o Build test directory correctly with CPPFLAGS set.
|
o Build test directory correctly with CPPFLAGS set.
|
||||||
|
o Provide an API for retrieving the supported event mechanisms.
|
||||||
|
|
||||||
Changes in 1.4.0:
|
Changes in 1.4.0:
|
||||||
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
|
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
|
||||||
|
30
event.c
30
event.c
@ -318,6 +318,36 @@ event_reinit(struct event_base *base)
|
|||||||
return (res);
|
return (res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char **
|
||||||
|
event_supported_methods()
|
||||||
|
{
|
||||||
|
static const char **methods;
|
||||||
|
const struct eventop **method;
|
||||||
|
const char **tmp;
|
||||||
|
int i = 0, k;
|
||||||
|
|
||||||
|
if (methods != NULL)
|
||||||
|
return (methods);
|
||||||
|
|
||||||
|
/* count all methods */
|
||||||
|
for (method = &eventops[0]; *method != NULL; ++method)
|
||||||
|
++i;
|
||||||
|
|
||||||
|
/* allocate one more than we need for the NULL pointer */
|
||||||
|
tmp = mm_malloc((i + 1) * sizeof(char *));
|
||||||
|
if (tmp == NULL)
|
||||||
|
return (NULL);
|
||||||
|
|
||||||
|
/* populate the array with the supported methods */
|
||||||
|
for (k = 0; k < i; ++k)
|
||||||
|
tmp[k] = eventops[k]->name;
|
||||||
|
tmp[i] = NULL;
|
||||||
|
|
||||||
|
methods = tmp;
|
||||||
|
|
||||||
|
return (methods);
|
||||||
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
event_priority_init(int npriorities)
|
event_priority_init(int npriorities)
|
||||||
{
|
{
|
||||||
|
@ -97,6 +97,18 @@ int event_base_dispatch(struct event_base *);
|
|||||||
@return a string identifying the kernel event mechanism (kqueue, epoll, etc.)
|
@return a string identifying the kernel event mechanism (kqueue, epoll, etc.)
|
||||||
*/
|
*/
|
||||||
const char *event_base_get_method(struct event_base *);
|
const char *event_base_get_method(struct event_base *);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Gets all event notification mechanisms supported by libevent.
|
||||||
|
|
||||||
|
This functions returns the event mechanism in order preferred
|
||||||
|
by libevent.
|
||||||
|
|
||||||
|
@return an array with pointers to the names of support methods.
|
||||||
|
The end of the array is indicated by a NULL pointer. If an
|
||||||
|
error is encountered NULL is returned.
|
||||||
|
*/
|
||||||
|
const char **event_supported_methods(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2066,6 +2066,26 @@ test_evutil_strtoll(void)
|
|||||||
cleanup_test();
|
cleanup_test();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_methods(void)
|
||||||
|
{
|
||||||
|
const char **methods = event_supported_methods();
|
||||||
|
|
||||||
|
fprintf(stderr, "Testing supported methods: ");
|
||||||
|
|
||||||
|
if (methods == NULL) {
|
||||||
|
fprintf(stderr, "FAILED\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (*methods != NULL) {
|
||||||
|
fprintf(stderr, "%s ", *methods);
|
||||||
|
++methods;
|
||||||
|
}
|
||||||
|
|
||||||
|
fprintf(stderr, "OK\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
main (int argc, char **argv)
|
main (int argc, char **argv)
|
||||||
@ -2082,6 +2102,8 @@ main (int argc, char **argv)
|
|||||||
|
|
||||||
setvbuf(stdout, NULL, _IONBF, 0);
|
setvbuf(stdout, NULL, _IONBF, 0);
|
||||||
|
|
||||||
|
test_methods();
|
||||||
|
|
||||||
/* Initalize the event library */
|
/* Initalize the event library */
|
||||||
global_base = event_init();
|
global_base = event_init();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user