Happy new year
[pazpar2-moved-to-github.git] / src / eventl.h
index 169044c..515b7f2 100644 (file)
@@ -1,65 +1,21 @@
-/*
- * Copyright (c) 1995-1999, Index Data
- * See the file LICENSE for details.
- * Sebastian Hammer, Adam Dickmeiss
- *
- * $Log: eventl.h,v $
- * Revision 1.3  2007-04-08 23:04:20  adam
- * Moved HTTP channel address from struct iochan to struct http_channel.
- * This fixes compilation on FreeBSD and reverts eventl.{c,h} to original
- * paraz state. This change, simple as it is, is untested.
- *
- * Revision 1.1  2006/12/20 20:47:16  quinn
- * Reorganized source tree
- *
- * Revision 1.3  2006/12/12 02:36:24  quinn
- * Implemented session timeout; ping command
- *
- * Revision 1.2  2006/11/18 05:00:38  quinn
- * Added record retrieval, etc.
- *
- * Revision 1.1.1.1  2006/11/14 20:44:38  quinn
- * PazPar2
- *
- * Revision 1.1.1.1  2000/02/23 14:40:18  heikki
- * Original import to cvs
- *
- * Revision 1.11  1999/04/20 09:56:48  adam
- * Added 'name' paramter to encoder/decoder routines (typedef Odr_fun).
- * Modified all encoders/decoders to reflect this change.
- *
- * Revision 1.10  1998/01/29 13:30:23  adam
- * Better event handle system for NT/Unix.
- *
- * Revision 1.9  1997/09/01 09:31:48  adam
- * Removed definition statserv_remove from statserv.h to eventl.h.
- *
- * Revision 1.8  1995/06/19 12:39:09  quinn
- * Fixed bug in timeout code. Added BER dumper.
- *
- * Revision 1.7  1995/06/16  10:31:34  quinn
- * Added session timeout.
- *
- * Revision 1.6  1995/05/16  08:51:02  quinn
- * License, documentation, and memory fixes
- *
- * Revision 1.5  1995/05/15  11:56:37  quinn
- * Asynchronous facilities. Restructuring of seshigh code.
- *
- * Revision 1.4  1995/03/27  08:34:23  quinn
- * Added dynamic server functionality.
- * Released bindings to session.c (is now redundant)
- *
- * Revision 1.3  1995/03/15  08:37:42  quinn
- * Now we're pretty much set for nonblocking I/O.
- *
- * Revision 1.2  1995/03/14  10:28:00  quinn
- * More work on demo server.
- *
- * Revision 1.1  1995/03/10  18:22:45  quinn
- * The rudiments of an asynchronous server.
- *
- */
+/* This file is part of Pazpar2.
+   Copyright (C) Index Data
+
+Pazpar2 is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
+
+Pazpar2 is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+*/
 
 #ifndef EVENTL_H
 #define EVENTL_H
@@ -70,6 +26,8 @@ struct iochan;
 
 typedef void (*IOC_CALLBACK)(struct iochan *i, int event);
 
+typedef struct iochan_man_s *iochan_man_t;
+
 typedef struct iochan
 {
     int fd;
@@ -78,35 +36,47 @@ typedef struct iochan
 #define EVENT_OUTPUT    0x02
 #define EVENT_EXCEPT    0x04
 #define EVENT_TIMEOUT   0x08
-#define EVENT_WORK      0x10
-    int force_event;
     IOC_CALLBACK fun;
     void *data;
     int destroyed;
     time_t last_event;
     time_t max_idle;
-    
+    int this_event;
+    int thread_users;
+
+    iochan_man_t man;
+    char *name;
     struct iochan *next;
+    int poll_offset;
 } *IOCHAN;
 
-#define iochan_destroy(i) (void)((i)->destroyed = 1)
+
+iochan_man_t iochan_man_create(int no_threads, int max_sockets);
+int iochan_add(iochan_man_t man, IOCHAN chan, int slack);
+void iochan_man_events(iochan_man_t man);
+void iochan_man_destroy(iochan_man_t *mp);
+void iochan_destroy(IOCHAN chan);
+
 #define iochan_getfd(i) ((i)->fd)
-#define iochan_setfd(i, f) ((i)->fd = (f))
+#define iochan_setfd(i, d) ((i)->fd = d)
 #define iochan_getdata(i) ((i)->data)
 #define iochan_setdata(i, d) ((i)->data = d)
-#define iochan_getflags(i) ((i)->flags)
 #define iochan_setflags(i, d) ((i)->flags = d)
 #define iochan_setflag(i, d) ((i)->flags |= d)
 #define iochan_clearflag(i, d) ((i)->flags &= ~(d))
 #define iochan_getflag(i, d) ((i)->flags & d ? 1 : 0)
-#define iochan_getfun(i) ((i)->fun)
-#define iochan_setfun(i, d) ((i)->fun = d)
-#define iochan_setevent(i, e) ((i)->force_event = (e))
-#define iochan_getnext(i) ((i)->next)
 #define iochan_settimeout(i, t) ((i)->max_idle = (t), (i)->last_event = time(0))
 #define iochan_activity(i) ((i)->last_event = time(0))
 
-IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags);
-int event_loop(IOCHAN *iochans);
+IOCHAN iochan_create(int fd, IOC_CALLBACK cb, int flags, const char *name);
 
 #endif
+/*
+ * Local variables:
+ * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * vim: shiftwidth=4 tabstop=8 expandtab
+ */
+