Doxyfile file description. Indentation. No change of code.
[yaz-moved-to-github.git] / src / eventl.h
1 /*
2  * Copyright (c) 1995-2004, Index Data
3  * See the file LICENSE for details.
4  *
5  * $Id: eventl.h,v 1.2 2004-10-15 00:19:00 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 } *IOCHAN;
43
44 #define iochan_destroy(i) (void)((i)->destroyed = 1)
45 #define iochan_getfd(i) ((i)->fd)
46 #define iochan_setfd(i, f) ((i)->fd = (f))
47 #define iochan_getdata(i) ((i)->data)
48 #define iochan_setdata(i, d) ((i)->data = d)
49 #define iochan_getflags(i) ((i)->flags)
50 #define iochan_setflags(i, d) ((i)->flags = d)
51 #define iochan_setflag(i, d) ((i)->flags |= d)
52 #define iochan_clearflag(i, d) ((i)->flags &= ~(d))
53 #define iochan_getflag(i, d) ((i)->flags & d ? 1 : 0)
54 #define iochan_getfun(i) ((i)->fun)
55 #define iochan_setfun(i, d) ((i)->fun = d)
56 #define iochan_setevent(i, e) ((i)->force_event = (e))
57 #define iochan_getnext(i) ((i)->next)
58 #define iochan_settimeout(i, t) ((i)->max_idle = (t), (i)->last_event = time(0))
59
60 IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags);
61 int event_loop(IOCHAN *iochans);
62 void statserv_remove (IOCHAN pIOChannel);
63 #endif