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