Libevent integration
[citadel.git] / citadel / event_client.h
1 #include <event.h>
2
3 typedef struct AsyncIO AsyncIO;
4
5 typedef enum _eNextState {
6         eSendReply, 
7         eSendMore,
8         eReadMessage, 
9         eAbort
10 }eNextState;
11
12 typedef int (*EventContextAttach)(void *Data);
13 typedef eNextState (*IO_CallBack)(void *Data);
14 typedef eReadState (*IO_LineReaderCallback)(AsyncIO *IO);
15
16 struct AsyncIO {
17         int sock;
18         struct event recv_event, send_event;
19         IOBuffer SendBuf, RecvBuf;
20         IO_LineReaderCallback LineReader;
21         IO_CallBack ReadDone, SendDone;
22         StrBuf *IOBuf;
23         void *Data;
24         eNextState NextState;
25 };
26
27
28 int QueueEventContext(void *Ctx, EventContextAttach CB);
29
30 void InitEventIO(AsyncIO *IO, 
31                  void *pData, 
32                  IO_CallBack ReadDone, 
33                  IO_CallBack SendDone, 
34                  IO_LineReaderCallback LineReader,
35                  int ReadFirst);