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