Added --with-yc option to configure. For the data1_node in data1.h:
[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.10  1998-01-29 13:30:23  adam
8  * Better event handle system for NT/Unix.
9  *
10  * Revision 1.9  1997/09/01 09:31:48  adam
11  * Removed definition statserv_remove from statserv.h to eventl.h.
12  *
13  * Revision 1.8  1995/06/19 12:39:09  quinn
14  * Fixed bug in timeout code. Added BER dumper.
15  *
16  * Revision 1.7  1995/06/16  10:31:34  quinn
17  * Added session timeout.
18  *
19  * Revision 1.6  1995/05/16  08:51:02  quinn
20  * License, documentation, and memory fixes
21  *
22  * Revision 1.5  1995/05/15  11:56:37  quinn
23  * Asynchronous facilities. Restructuring of seshigh code.
24  *
25  * Revision 1.4  1995/03/27  08:34:23  quinn
26  * Added dynamic server functionality.
27  * Released bindings to session.c (is now redundant)
28  *
29  * Revision 1.3  1995/03/15  08:37:42  quinn
30  * Now we're pretty much set for nonblocking I/O.
31  *
32  * Revision 1.2  1995/03/14  10:28:00  quinn
33  * More work on demo server.
34  *
35  * Revision 1.1  1995/03/10  18:22:45  quinn
36  * The rudiments of an asynchronous server.
37  *
38  */
39
40 #ifndef EVENTL_H
41 #define EVENTL_H
42
43 #include <time.h>
44
45 struct iochan;
46
47 typedef void (*IOC_CALLBACK)(struct iochan *i, int event);
48
49 typedef struct iochan
50 {
51     int fd;
52     int flags;
53 #define EVENT_INPUT     0x01
54 #define EVENT_OUTPUT    0x02
55 #define EVENT_EXCEPT    0x04
56 #define EVENT_TIMEOUT   0x08
57 #define EVENT_WORK      0x10
58 int force_event;
59     IOC_CALLBACK fun;
60     void *data;
61     int destroyed;
62     time_t last_event;
63     time_t max_idle;
64     
65     struct iochan *next;
66 } *IOCHAN;
67
68 #define iochan_destroy(i) (void)((i)->destroyed = 1)
69 #define iochan_getfd(i) ((i)->fd)
70 #define iochan_setfd(i, f) ((i)->fd = (f))
71 #define iochan_getdata(i) ((i)->data)
72 #define iochan_setdata(i, d) ((i)->data = d)
73 #define iochan_getflags(i) ((i)->flags)
74 #define iochan_setflags(i, d) ((i)->flags = d)
75 #define iochan_setflag(i, d) ((i)->flags |= d)
76 #define iochan_clearflag(i, d) ((i)->flags &= ~(d))
77 #define iochan_getflag(i, d) ((i)->flags & d ? 1 : 0)
78 #define iochan_getfun(i) ((i)->fun)
79 #define iochan_setfun(i, d) ((i)->fun = d)
80 #define iochan_setevent(i, e) ((i)->force_event = (e))
81 #define iochan_getnext(i) ((i)->next)
82 #define iochan_settimeout(i, t) ((i)->max_idle = (t), (i)->last_event = time(0))
83
84 IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags);
85 int event_loop(IOCHAN *iochans);
86 void statserv_remove (IOCHAN pIOChannel);
87 #endif