#include <ares.h>
#include <curl/curl.h>
+#ifndef __ASYNCIO__
+#define __ASYNCIO__
typedef struct AsyncIO AsyncIO;
+#endif
+#ifndef __CIT_CONTEXT__
+#define __CIT_CONTEXT__
+typedef struct CitContext CitContext;
+#endif
+
+typedef enum __eIOState {
+ eDBQ,
+ eQDBNext,
+ eDBAttach,
+ eDBNext,
+ eDBStop,
+ eDBX,
+ eDBTerm,
+ eIOQ,
+ eIOAttach,
+ eIOConnectSock,
+ eIOAbort,
+ eIOTimeout,
+ eIOConnfail,
+ eIOConnfailNow,
+ eIOConnNow,
+ eIOConnWait,
+ eCurlQ,
+ eCurlStart,
+ eCurlShutdown,
+ eCurlNewIO,
+ eCurlGotIO,
+ eCurlGotData,
+ eCurlGotStatus,
+ eCaresStart,
+ eCaresDoneIO,
+ eCaresFinished,
+ eCaresX,
+ eKill,
+ eExit
+}eIOState;
typedef enum _eNextState {
eSendDNSQuery,
eAbort
}eNextState;
+void SetEVState(AsyncIO *IO, eIOState State);
+
typedef eNextState (*IO_CallBack)(AsyncIO *IO);
typedef eReadState (*IO_LineReaderCallback)(AsyncIO *IO);
typedef void (*ParseDNSAnswerCb)(AsyncIO*, unsigned char*, int);
ParseDNSAnswerCb DNS_CB;
IO_CallBack PostDNS;
+ const char *QueryTYPE;
+ const char *QStr;
int DNSStatus;
void *VParsedDNSReply;
FreeDNSReply DNSReplyFree;
CURL *chnd;
struct curl_slist *headers;
char errdesc[CURL_ERROR_SIZE];
+ const char *CurlError;
int attached;
/* Saving / loading a message async from / to disk */
ReadAsyncMsg *ReadMsg;
struct CtdlMessage *AsyncMsg;
- struct recptypes *AsyncRcp;
+ recptypes *AsyncRcp;
/* Context specific data; Hint: put AsyncIO in there */
void *Data; /* application specific data */
- void *CitContext; /* Citadel Session context... */
+ CitContext *CitContext; /* Citadel Session context... */
};
typedef struct _IOAddHandler {
#define EDBGLOG(LEVEL) if ((LEVEL != LOG_DEBUG) || (DebugEventLoop != 0))
-#define CCID ((CitContext*)IO->CitContext)->cs_pid
+#define CCID ((CitContext*)IO->CitContext)?((CitContext*)IO->CitContext)->cs_pid:-1
#define EVQ_syslog(LEVEL, FORMAT, ...) \
EDBGLOG (LEVEL) syslog(LEVEL, "IOQ " FORMAT, __VA_ARGS__)
eNextState NextDBOperation(AsyncIO *IO, IO_CallBack CB);
eNextState QueueDBOperation(AsyncIO *IO, IO_CallBack CB);
+eNextState EventQueueDBOperation(AsyncIO *IO, IO_CallBack CB);
void StopDBWatchers(AsyncIO *IO);
eNextState QueueEventContext(AsyncIO *IO, IO_CallBack CB);
eNextState QueueCurlContext(AsyncIO *IO);
+eNextState DBQueueEventContext(AsyncIO *IO, IO_CallBack CB);
eNextState EvConnectSock(AsyncIO *IO,
double conn_timeout,
IO_CallBack Terminate,
IO_CallBack DBTerminate,
IO_CallBack ShutdownAbort);
-
+void KillAsyncIOContext(AsyncIO *IO);
void StopCurlWatchers(AsyncIO *IO);
+eNextState CurlQueueDBOperation(AsyncIO *IO, IO_CallBack CB);
eNextState ReAttachIO(AsyncIO *IO,
void *pData,