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