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)(void *Data);
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 */
40 StrBuf *ErrMsg; /* if we fail to connect, or lookup, error goes here. */
42 /* read/send related... */
47 /* Citadel application callbacks... */
48 IO_CallBack ReadDone, /* Theres new data to read... */
49 SendDone, /* we may send more data */
50 Terminate, /* shutting down... */
51 Timeout, /* Timeout handler; may also be connection timeout */
52 ConnFail; /* What to do when one connection failed? */
54 IO_LineReaderCallback LineReader; /* if we have linereaders, maybe we want to read more lines before the real application logic is called? */
56 struct ares_options DNSOptions;
57 ares_channel DNSChannel;
58 ParseDNSAnswerCb DNS_CB;
61 void *VParsedDNSReply;
62 FreeDNSReply DNSReplyFree;
64 /* Custom data; its expected to contain AsyncIO so we can save malloc()s... */
65 DeleteHashDataFunc DeleteData; /* so if we have to destroy you, what to do... */
66 void *Data; /* application specific data */
69 typedef struct _IOAddHandler {
71 EventContextAttach EvAttch;
74 void FreeAsyncIOContents(AsyncIO *IO);
76 int QueueEventContext(void *Ctx, AsyncIO *IO, EventContextAttach CB);
77 int ShutDownEventQueue(void);
79 void InitEventIO(AsyncIO *IO,
83 IO_CallBack Terminate,
86 IO_LineReaderCallback LineReader,
89 int QueueQuery(ns_type Type, char *name, AsyncIO *IO, IO_CallBack PostDNS);