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