Added body-of-text to BIB-1 ANY and the WAIS profile
[yaz-moved-to-github.git] / server / eventl.h
1 /*
2  * Copyright (c) 1995, Index Data I/S 
3  * See the file LICENSE for details.
4  * Sebastian Hammer, Adam Dickmeiss
5  *
6  * $Log: eventl.h,v $
7  * Revision 1.8  1995-06-19 12:39:09  quinn
8  * Fixed bug in timeout code. Added BER dumper.
9  *
10  * Revision 1.7  1995/06/16  10:31:34  quinn
11  * Added session timeout.
12  *
13  * Revision 1.6  1995/05/16  08:51:02  quinn
14  * License, documentation, and memory fixes
15  *
16  * Revision 1.5  1995/05/15  11:56:37  quinn
17  * Asynchronous facilities. Restructuring of seshigh code.
18  *
19  * Revision 1.4  1995/03/27  08:34:23  quinn
20  * Added dynamic server functionality.
21  * Released bindings to session.c (is now redundant)
22  *
23  * Revision 1.3  1995/03/15  08:37:42  quinn
24  * Now we're pretty much set for nonblocking I/O.
25  *
26  * Revision 1.2  1995/03/14  10:28:00  quinn
27  * More work on demo server.
28  *
29  * Revision 1.1  1995/03/10  18:22:45  quinn
30  * The rudiments of an asynchronous server.
31  *
32  */
33
34 #ifndef EVENTL_H
35 #define EVENTL_H
36
37 struct iochan;
38
39 typedef void (*IOC_CALLBACK)(struct iochan *i, int event);
40
41 typedef struct iochan
42 {
43     int fd;
44     int flags;
45 #define EVENT_INPUT     0x01
46 #define EVENT_OUTPUT    0x02
47 #define EVENT_EXCEPT    0x04
48 #define EVENT_TIMEOUT   0x08
49 #define EVENT_WORK      0x10
50 int force_event;
51     IOC_CALLBACK fun;
52     void *data;
53     int destroyed;
54     time_t last_event;
55     time_t max_idle;
56     
57     struct iochan *next;
58 } *IOCHAN;
59
60 #define iochan_destroy(i) (void)((i)->destroyed = 1)
61 #define iochan_getfd(i) ((i)->fd)
62 #define iochan_setfd(i, f) ((i)->fd = (f))
63 #define iochan_getdata(i) ((i)->data)
64 #define iochan_setdata(i, d) ((i)->data = d)
65 #define iochan_getflags(i) ((i)->flags)
66 #define iochan_setflags(i, d) ((i)->flags = d)
67 #define iochan_setflag(i, d) ((i)->flags |= d)
68 #define iochan_clearflag(i, d) ((i)->flags &= ~(d))
69 #define iochan_getflag(i, d) ((i)->flags & d ? 1 : 0)
70 #define iochan_getfun(i) ((i)->fun)
71 #define iochan_setfun(i, d) ((i)->fun = d)
72 #define iochan_setevent(i, e) ((i)->force_event = (e))
73 #define iochan_getnext(i) ((i)->next)
74 #define iochan_settimeout(i, t) ((i)->max_idle = (t), (i)->last_event = time(0))
75
76 IOCHAN iochan_getchan(void);
77 IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags);
78 int event_loop();
79
80 #endif