Added skeleton for query charset conversion. Bug #977.
[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.8 2007-01-03 08:42:15 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 int force_event;
34     IOC_CALLBACK fun;
35     void *data;
36     int destroyed;
37     time_t last_event;
38     time_t max_idle;
39     
40     struct iochan *next;
41     int chan_id; /* listening port (0 if none ) */
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, int port);
61 int iochan_is_alive(IOCHAN chan);
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