X-Git-Url: https://code.citadel.org/?a=blobdiff_plain;f=citadel%2Fevent_client.h;h=0e6cae95323fec8a2918ce2db7901c7959cd2b1b;hb=a706083cbf719d326b15edd89ca01fc134492169;hp=34023a3c0967211ab80618cbf0fd729c1e50f5f3;hpb=03ca46c6f61467f62cb600d345383d70ca4fc953;p=citadel.git diff --git a/citadel/event_client.h b/citadel/event_client.h index 34023a3c0..0e6cae953 100644 --- a/citadel/event_client.h +++ b/citadel/event_client.h @@ -1,4 +1,7 @@ -#include +#include +#include +#include +#include typedef struct AsyncIO AsyncIO; @@ -15,16 +18,40 @@ typedef eNextState (*IO_CallBack)(void *Data); typedef eReadState (*IO_LineReaderCallback)(AsyncIO *IO); struct AsyncIO { + StrBuf *Host; + char service[32]; + + /* To cycle through several possible services... */ + struct addrinfo *res; + struct addrinfo *curr_ai; + + /* connection related */ int sock; int active_event; - struct event recv_event, send_event; - IOBuffer SendBuf, RecvBuf; - IO_LineReaderCallback LineReader; - IO_CallBack ReadDone, SendDone, Terminate; - StrBuf *IOBuf; - void *Data; - DeleteHashDataFunc DeleteData; /* data is expected to contain AsyncIO... */ eNextState NextState; + ev_io recv_event, + send_event, + conn_event; + StrBuf *ErrMsg; /* if we fail to connect, or lookup, error goes here. */ + + /* read/send related... */ + StrBuf *IOBuf; + IOBuffer SendBuf, + RecvBuf; + + /* Citadel application callbacks... */ + IO_CallBack ReadDone, /* Theres new data to read... */ + SendDone, /* we may send more data */ + Terminate, /* shutting down... */ + Timeout, /* Timeout handler; may also be connection timeout */ + ConnFail, /* What to do when one connection failed? */ + CustomDNS; /* If the application wants to do custom dns functionality like cycle through different MX-Records */ + + IO_LineReaderCallback LineReader; /* if we have linereaders, maybe we want to read more lines before the real application logic is called? */ + + /* Custom data; its expected to contain AsyncIO so we can save malloc()s... */ + DeleteHashDataFunc DeleteData; /* so if we have to destroy you, what to do... */ + void *Data; /* application specific data */ }; typedef struct _IOAddHandler { @@ -42,5 +69,8 @@ void InitEventIO(AsyncIO *IO, IO_CallBack ReadDone, IO_CallBack SendDone, IO_CallBack Terminate, + IO_CallBack Timeout, + IO_CallBack ConnFail, + IO_CallBack CustomDNS, IO_LineReaderCallback LineReader, int ReadFirst);