summaryrefslogtreecommitdiff
path: root/ot_event.h
diff options
context:
space:
mode:
Diffstat (limited to 'ot_event.h')
-rw-r--r--ot_event.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/ot_event.h b/ot_event.h
new file mode 100644
index 0000000..c1627ab
--- /dev/null
+++ b/ot_event.h
@@ -0,0 +1,39 @@
1/* This software was written by Dirk Engling <erdgeist@erdgeist.org>
2 It is considered beerware. Prost. Skol. Cheers or whatever.
3
4 $id$ */
5
6#ifndef OT_EVENT_H__
7#define OT_EVENT_H__
8
9#include <stdint.h>
10
11/* Which descriptors have become readable or writable, asked of whichever
12 mechanism the kernel offers. The generation a descriptor was registered
13 with is handed back with every event, so a caller can tell an event for
14 the connection it is holding from one for a connection that has since been
15 closed and had its number reused. */
16
17enum { EVENT_READ = 1, EVENT_WRITE = 2 };
18
19typedef struct {
20 int fd;
21 uint32_t generation;
22 int what;
23} ot_event;
24
25int event_init(void);
26void event_deinit(void);
27
28int event_add(int fd, int what, uint32_t generation);
29int event_modify(int fd, int what, uint32_t generation);
30int event_del(int fd);
31
32/* Waits at most timeout_ms, or indefinitely when that is negative, and fills
33 out with up to max ready descriptors. Returns how many, or -1. */
34int event_wait(ot_event *out, int max, int timeout_ms);
35
36/* Which mechanism was compiled in, for the version string */
37const char *event_mechanism(void);
38
39#endif