]> code.citadel.org Git - citadel.git/blobdiff - citadel/event_client.h
Libev migration:
[citadel.git] / citadel / event_client.h
index 0e6cae95323fec8a2918ce2db7901c7959cd2b1b..208a716616a7122ca8340490d2fa2511ffcc9d15 100644 (file)
@@ -2,6 +2,8 @@
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netdb.h>
+#include <arpa/nameser.h>
+#include <ares.h>
 
 typedef struct AsyncIO AsyncIO;
 
@@ -14,8 +16,10 @@ typedef enum _eNextState {
 }eNextState;
 
 typedef int (*EventContextAttach)(void *Data);
-typedef eNextState (*IO_CallBack)(void *Data);
+typedef eNextState (*IO_CallBack)(AsyncIO *IO);
 typedef eReadState (*IO_LineReaderCallback)(AsyncIO *IO);
+typedef void (*ParseDNSAnswerCb)(AsyncIO*, unsigned char*, int);
+typedef void (*FreeDNSReply)(void *DNSData);
 
 struct AsyncIO {
        StrBuf *Host;
@@ -26,9 +30,14 @@ struct AsyncIO {
        struct addrinfo *curr_ai;
 
        /* connection related */
+       int IP6;
+       struct hostent *HEnt;
        int sock;
-       int active_event;
+       unsigned short dport;
                eNextState NextState;
+
+       ev_timer conn_fail, 
+               rw_timeout;
        ev_io recv_event, 
                send_event, 
                conn_event;
@@ -44,11 +53,24 @@ struct AsyncIO {
                SendDone,     /* we may send more data */
                Terminate,    /* shutting down... */
                Timeout,      /* Timeout handler; may also be connection timeout */
-               ConnFail,     /* What to do when one connection failed? */
-               CustomDNS;    /* If the application wants to do custom dns functionality like cycle through different MX-Records */
+               ConnFail;     /* What to do when one connection failed? */
 
        IO_LineReaderCallback LineReader; /* if we have linereaders, maybe we want to read more lines before the real application logic is called? */
 
+
+       int active_dns_event;
+       ev_io dns_recv_event, 
+               dns_send_event;
+       struct ares_options DNSOptions;
+       ares_channel DNSChannel;
+
+       ParseDNSAnswerCb DNS_CB;
+       IO_CallBack PostDNS;
+
+       int DNSStatus;
+       void *VParsedDNSReply;
+       FreeDNSReply DNSReplyFree;
+
        /* Custom data; its expected to contain  AsyncIO so we can save malloc()s... */
        DeleteHashDataFunc DeleteData; /* so if we have to destroy you, what to do... */
        void *Data; /* application specific data */
@@ -71,6 +93,12 @@ void InitEventIO(AsyncIO *IO,
                 IO_CallBack Terminate, 
                 IO_CallBack Timeout, 
                 IO_CallBack ConnFail, 
-                IO_CallBack CustomDNS,
                 IO_LineReaderCallback LineReader,
+                double conn_timeout, double first_rw_timeout,
                 int ReadFirst);
+
+int QueueQuery(ns_type Type, char *name, AsyncIO *IO, IO_CallBack PostDNS);
+
+void StopClient(AsyncIO *IO);
+
+void SetNextTimeout(AsyncIO *IO, double timeout);