3 #include <sys/socket.h>
5 #include <arpa/nameser.h>
8 typedef struct AsyncIO AsyncIO;
10 typedef enum _eNextState {
18 typedef int (*EventContextAttach)(void *Data);
19 typedef eNextState (*IO_CallBack)(AsyncIO *IO);
20 typedef eReadState (*IO_LineReaderCallback)(AsyncIO *IO);
21 typedef void (*ParseDNSAnswerCb)(AsyncIO*, unsigned char*, int);
22 typedef void (*FreeDNSReply)(void *DNSData);
28 /* To cycle through several possible services... */
30 struct addrinfo *curr_ai;
32 /* connection related */
44 StrBuf *ErrMsg; /* if we fail to connect, or lookup, error goes here. */
46 /* read/send related... */
51 /* Citadel application callbacks... */
52 IO_CallBack ReadDone, /* Theres new data to read... */
53 SendDone, /* we may send more data */
54 Terminate, /* shutting down... */
55 Timeout, /* Timeout handler; may also be connection timeout */
56 ConnFail; /* What to do when one connection failed? */
58 IO_LineReaderCallback LineReader; /* if we have linereaders, maybe we want to read more lines before the real application logic is called? */
64 struct ares_options DNSOptions;
65 ares_channel DNSChannel;
67 ParseDNSAnswerCb DNS_CB;
71 void *VParsedDNSReply;
72 FreeDNSReply DNSReplyFree;
74 /* Custom data; its expected to contain AsyncIO so we can save malloc()s... */
75 DeleteHashDataFunc DeleteData; /* so if we have to destroy you, what to do... */
76 void *Data; /* application specific data */
79 typedef struct _IOAddHandler {
81 EventContextAttach EvAttch;
84 void FreeAsyncIOContents(AsyncIO *IO);
86 int QueueEventContext(void *Ctx, AsyncIO *IO, EventContextAttach CB);
87 int ShutDownEventQueue(void);
89 void InitEventIO(AsyncIO *IO,
93 IO_CallBack Terminate,
96 IO_LineReaderCallback LineReader,
97 double conn_timeout, double first_rw_timeout,
100 int QueueQuery(ns_type Type, char *name, AsyncIO *IO, IO_CallBack PostDNS);
102 void StopClient(AsyncIO *IO);
104 void SetNextTimeout(AsyncIO *IO, double timeout);