Fix URL of SRU diagnostics list.
[yaz-moved-to-github.git] / src / eventl.h
1 /*
2  * Copyright (C) 1995-2005, Index Data ApS
3  * See the file LICENSE for details.
4  *
5  * $Id: eventl.h,v 1.6 2005-06-25 15:46:04 adam Exp $
6  */
7
8 /**
9  * \file eventl.h
10  * \brief Definitions for event loop handling for GFS.
11  *
12  * This "private" header defines various functions for the
13  * main event loop in GFS.
14  */
15
16 #ifndef EVENTL_H
17 #define EVENTL_H
18
19 #include <time.h>
20
21 struct iochan;
22
23 typedef void (*IOC_CALLBACK)(struct iochan *i, int event);
24
25 typedef struct iochan
26 {
27     int fd;
28     int flags;
29 #define EVENT_INPUT     0x01
30 #define EVENT_OUTPUT    0x02
31 #define EVENT_EXCEPT    0x04
32 #define EVENT_TIMEOUT   0x08
33 #define EVENT_WORK      0x10
34 int force_event;
35     IOC_CALLBACK fun;
36     void *data;
37     int destroyed;
38     time_t last_event;
39     time_t max_idle;
40     
41     struct iochan *next;
42     int chan_id; /* listening port (0 if none ) */
43 } *IOCHAN;
44
45 #define iochan_destroy(i) (void)((i)->destroyed = 1)
46 #define iochan_getfd(i) ((i)->fd)
47 #define iochan_setfd(i, f) ((i)->fd = (f))
48 #define iochan_getdata(i) ((i)->data)
49 #define iochan_setdata(i, d) ((i)->data = d)
50 #define iochan_getflags(i) ((i)->flags)
51 #define iochan_setflags(i, d) ((i)->flags = d)
52 #define iochan_setflag(i, d) ((i)->flags |= d)
53 #define iochan_clearflag(i, d) ((i)->flags &= ~(d))
54 #define iochan_getflag(i, d) ((i)->flags & d ? 1 : 0)
55 #define iochan_getfun(i) ((i)->fun)
56 #define iochan_setfun(i, d) ((i)->fun = d)
57 #define iochan_setevent(i, e) ((i)->force_event = (e))
58 #define iochan_getnext(i) ((i)->next)
59 #define iochan_settimeout(i, t) ((i)->max_idle = (t), (i)->last_event = time(0))
60
61 IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags, int port);
62 int event_loop(IOCHAN *iochans);
63 void statserv_remove (IOCHAN pIOChannel);
64 #endif
65 /*
66  * Local variables:
67  * c-basic-offset: 4
68  * indent-tabs-mode: nil
69  * End:
70  * vim: shiftwidth=4 tabstop=8 expandtab
71  */
72