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 Build test directory correctly with CPPFLAGS set.
-
+ o Provide an API for retrieving the supported event mechanisms.
Changes in 1.4.0:
o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
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
event_priority_init(int npriorities)
{
@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.
+
+ 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);
/**
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
main (int argc, char **argv)
setvbuf(stdout, NULL, _IONBF, 0);
+ test_methods();
+
/* Initalize the event library */
global_base = event_init();