diff --git a/http/http_event.c b/http/http_event.c
index 96f9bb2..02e4346 100644
--- a/http/http_event.c
+++ b/http/http_event.c
@@ -10,8 +10,7 @@
* AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
* THIS SOFTWARE.
*/
-#include <sys/time.h>
-#include <event.h>
+#include <event2/event.h>
#include <libkc3/kc3.h>
#include "http_event.h"
@@ -71,21 +70,24 @@ void http_event_callback (int fd, short events, void *tag_tuple)
tag_clean(&tmp);
}
-s32 http_event_dispatch (void)
+s32 http_event_base_dispatch (struct event_base *eb)
{
- return event_dispatch();
+ return event_base_dispatch(eb);
}
-struct event * http_event_new (s32 fd, const s_list * const *events,
+void * http_event_init (void)
+{
+ return event_base_new();
+}
+
+struct event * http_event_new (struct event_base *event_base, s32 fd,
+ const s_list * const *events,
const s_fn *callback, s_tag *arg)
{
const s_list *e;
struct event *ev;
s16 events_s16;
s_tag *tag;
- ev = alloc(sizeof(*ev));
- if (! ev)
- return NULL;
events_s16 = 0;
e = *events;
while (e) {
@@ -103,9 +105,9 @@ struct event * http_event_new (s32 fd, const s_list * const *events,
}
tag = tag_new_tuple(3);
tag_init_fn_copy(tag->data.tuple.tag, callback);
- tag_init_ptr(tag->data.tuple.tag + 1, ev);
tag_init_copy(tag->data.tuple.tag + 2, arg);
- event_set(ev, fd, events_s16, http_event_callback, tag);
+ ev = event_new(event_base, fd, events_s16, http_event_callback, tag);
+ tag_init_ptr(tag->data.tuple.tag + 1, ev);
return ev;
invalid_event_list:
err_write_1("http_event_new: invalid event list: ");
@@ -155,3 +157,8 @@ struct event * http_event_new (s32 fd, const s_list *events,
return ev;
}
*/
+
+s_str * http_event_version (s_str *dest)
+{
+ return str_init_1(dest, NULL, event_get_version());
+}
diff --git a/http/http_event.h b/http/http_event.h
index 26ed7b9..9848c0d 100644
--- a/http/http_event.h
+++ b/http/http_event.h
@@ -15,10 +15,13 @@
#include "types.h"
-/* Heap-allocation functions, call http_event_delete after use. */
-void http_event_delete (struct event *ev);
-struct event * http_event_new (s32 fd, const s_list * const *events,
- const s_fn *fn, s_tag *arg);
+/* Heap-allocation functions, call *_delete after use. */
+struct event_base * http_event_base_new (void);
+void http_event_delete (struct event *ev);
+struct event * http_event_new (struct event_base *event_base,
+ s32 fd,
+ const s_list * const *events,
+ const s_fn *callback, s_tag *arg);
/* Operators. */
s32 http_event_add (struct event *ev, s_time *time);
diff --git a/lib/kc3/0.1/http/event.kc3 b/lib/kc3/0.1/http/event.kc3
index e49f101..77fe018 100644
--- a/lib/kc3/0.1/http/event.kc3
+++ b/lib/kc3/0.1/http/event.kc3
@@ -9,10 +9,13 @@ defmodule HTTP.Event do
def del = cfn S32 "event_del" (Ptr)
- def dispatch = cfn S32 "event_dispatch" ()
+ def dispatch = cfn S32 "event_base_dispatch" (Ptr)
- def init = cfn Ptr "event_init" ()
+ # init() returns a (struct event_base *)
+ def init = cfn Ptr "http_event_init" ()
- def new = cfn Ptr "http_event_new" (S32, List, Fn, Tag)
+ def new = cfn Ptr "http_event_new" (Ptr, S32, List, Fn, Tag)
+
+ def version = cfn Str "http_event_version" (Result)
end
diff --git a/libkc3/time.c b/libkc3/time.c
index 8e4585a..d910fa1 100644
--- a/libkc3/time.c
+++ b/libkc3/time.c
@@ -42,7 +42,7 @@ s_time * time_init (s_time *time)
s_time * time_init_add (s_time *time, const s_time *a, const s_time *b)
{
- s_time tmp = {0}
+ s_time tmp = {0};
assert(time);
assert(a);
assert(b);