added SSL backend for IOMultiplexer
[TransparentIRC.git] / src / IOEngine.h
index dfcbe98bbb3fcb581e64cdafb004f5ac731dc8dd..8f4053b4823126e661c5b52d45eab8b4134a82aa 100644 (file)
 #include "overall.h"
 
 struct IODescriptor;
+enum IOType;
+enum IOStatus;
+enum IOEventType;
+
+#define timeval_is_bigger(x,y) ((x->tv_sec > y->tv_sec) || (x->tv_sec == y->tv_sec && x->tv_usec > y->tv_usec))
+#define timeval_is_smaler(x,y) ((x->tv_sec < y->tv_sec) || (x->tv_sec == y->tv_sec && x->tv_usec < y->tv_usec))
+
+enum IOLogType {
+    IOLOG_DEBUG,
+    IOLOG_WARNING,
+    IOLOG_ERROR,
+    IOLOG_FATAL
+};
 
 extern struct IODescriptor *first_descriptor;
+extern struct IODescriptor *timer_priority;
 
 struct IOEngine {
     const char *name;
@@ -32,8 +46,12 @@ struct IOEngine {
     void (*cleanup)(void);
 };
 
-#define iohandler_wants_writes(IOFD) (IOFD->writebuf.bufpos || IOFD->state == IO_CONNECTING
+#define iohandler_wants_writes(IOFD) ((IOFD->writebuf.bufpos && !IOFD->ssl_hs_read) || IOFD->state == IO_CONNECTING || IOFD->ssl_hs_write
 
+void iohandler_log(enum IOLogType type, char *text, ...);
 void iohandler_events(struct IODescriptor *iofd, int readable, int writeable);
+char *iohandler_iotype_name(enum IOType type);
+char *iohandler_iostatus_name(enum IOStatus status);
+char *iohandler_ioeventtype_name(enum IOEventType type);
 
 #endif