Add odr_prepend()
[yaz-moved-to-github.git] / src / eventl.h
1 /*
2  * Copyright (c) 1995-2003, Index Data
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Id: eventl.h,v 1.1 2003-10-27 12:21:30 adam Exp $
7  */
8
9 #ifndef EVENTL_H
10 #define EVENTL_H
11
12 #include <time.h>
13
14 struct iochan;
15
16 typedef void (*IOC_CALLBACK)(struct iochan *i, int event);
17
18 typedef struct iochan
19 {
20     int fd;
21     int flags;
22 #define EVENT_INPUT     0x01
23 #define EVENT_OUTPUT    0x02
24 #define EVENT_EXCEPT    0x04
25 #define EVENT_TIMEOUT   0x08
26 #define EVENT_WORK      0x10
27 int force_event;
28     IOC_CALLBACK fun;
29     void *data;
30     int destroyed;
31     time_t last_event;
32     time_t max_idle;
33     
34     struct iochan *next;
35 } *IOCHAN;
36
37 #define iochan_destroy(i) (void)((i)->destroyed = 1)
38 #define iochan_getfd(i) ((i)->fd)
39 #define iochan_setfd(i, f) ((i)->fd = (f))
40 #define iochan_getdata(i) ((i)->data)
41 #define iochan_setdata(i, d) ((i)->data = d)
42 #define iochan_getflags(i) ((i)->flags)
43 #define iochan_setflags(i, d) ((i)->flags = d)
44 #define iochan_setflag(i, d) ((i)->flags |= d)
45 #define iochan_clearflag(i, d) ((i)->flags &= ~(d))
46 #define iochan_getflag(i, d) ((i)->flags & d ? 1 : 0)
47 #define iochan_getfun(i) ((i)->fun)
48 #define iochan_setfun(i, d) ((i)->fun = d)
49 #define iochan_setevent(i, e) ((i)->force_event = (e))
50 #define iochan_getnext(i) ((i)->next)
51 #define iochan_settimeout(i, t) ((i)->max_idle = (t), (i)->last_event = time(0))
52
53 IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags);
54 int event_loop(IOCHAN *iochans);
55 void statserv_remove (IOCHAN pIOChannel);
56 #endif