diff options
Diffstat (limited to 'ot_event.h')
| -rw-r--r-- | ot_event.h | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/ot_event.h b/ot_event.h new file mode 100644 index 0000000..6023134 --- /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 | |||
| 17 | enum { EVENT_IN = 1, EVENT_OUT = 2 }; | ||
| 18 | |||
| 19 | typedef struct { | ||
| 20 | int fd; | ||
| 21 | uint32_t generation; | ||
| 22 | int what; | ||
| 23 | } ot_event; | ||
| 24 | |||
| 25 | int event_init(void); | ||
| 26 | void event_deinit(void); | ||
| 27 | |||
| 28 | int event_add(int fd, int what, uint32_t generation); | ||
| 29 | int event_modify(int fd, int what, uint32_t generation); | ||
| 30 | int 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. */ | ||
| 34 | int event_wait(ot_event *out, int max, int timeout_ms); | ||
| 35 | |||
| 36 | /* Which mechanism was compiled in, for the version string */ | ||
| 37 | const char *event_mechanism(void); | ||
| 38 | |||
| 39 | #endif | ||
