2 * Copyright (C) 1995-2007, Index Data ApS
3 * See the file LICENSE for details.
5 * $Id: zoom-socket.c,v 1.5 2007-11-09 16:46:43 adam Exp $
9 * \brief Implements ZOOM C socket interface.
18 #include <yaz/xmalloc.h>
21 #include <sys/types.h>
30 ZOOM_event_sys_yaz_poll(int no, ZOOM_connection *cs)
32 struct yaz_poll_fd *yp = xmalloc(sizeof(*yp) * no);
37 for (i = 0; i < no; i++)
39 ZOOM_connection c = cs[i];
44 fd = ZOOM_connection_get_socket(c);
45 mask = ZOOM_connection_get_mask(c);
46 timeout = ZOOM_connection_get_timeout(c);
52 enum yaz_poll_mask input_mask = 0;
54 if (mask & ZOOM_SELECT_READ)
55 input_mask += yaz_poll_read;
56 if (mask & ZOOM_SELECT_WRITE)
57 input_mask += yaz_poll_write;
58 if (mask & ZOOM_SELECT_EXCEPT)
59 input_mask += yaz_poll_except;
61 yp[nfds].input_mask = input_mask;
62 yp[nfds].client_data = c;
71 r = yaz_poll(yp, nfds, timeout);
74 for (i = 0; i < nfds; i++)
76 ZOOM_connection c = yp[i].client_data;
77 enum yaz_poll_mask output_mask = yp[i].output_mask;
78 if (output_mask & yaz_poll_timeout)
79 ZOOM_connection_fire_event_timeout(c);
83 if (output_mask & yaz_poll_read)
84 mask += ZOOM_SELECT_READ;
85 if (output_mask & yaz_poll_write)
86 mask += ZOOM_SELECT_WRITE;
87 if (output_mask & yaz_poll_except)
88 mask += ZOOM_SELECT_EXCEPT;
89 ZOOM_connection_fire_event_socket(c, mask);
98 ZOOM_event(int no, ZOOM_connection *cs)
102 r = ZOOM_event_nonblock(no, cs);
105 ZOOM_event_sys_yaz_poll(no, cs);
106 return ZOOM_event_nonblock(no, cs);
112 * indent-tabs-mode: nil
114 * vim: shiftwidth=4 tabstop=8 expandtab