+#define EV_COMPAT3 0
#include <ev.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <arpa/nameser.h>
#include <ares.h>
+#include <curl/curl.h>
typedef struct AsyncIO AsyncIO;
void *Data;
} DNSQueryParts;
+typedef struct _evcurl_request_data
+{
+ CURL *chnd;
+ struct curl_slist *headers;
+ char errdesc[CURL_ERROR_SIZE];
+
+ int attached;
+
+ char *PlainPostData;
+ long PlainPostDataLen;
+ StrBuf *PostData;
+
+ StrBuf *ReplyData;
+ long httpcode;
+} evcurl_request_data;
struct AsyncIO {
eNextState NextState;
ev_cleanup abort_by_shutdown; /* server wants to go down... */
ev_timer conn_fail, /* connection establishing timed out */
rw_timeout; /* timeout while sending data */
- ev_idle unwind_stack; /* get c-ares out of the stack */
+ ev_idle unwind_stack, /* get c-ares out of the stack */
+ conn_fail_immediate; /* unwind stack, but fail immediately. */
ev_io recv_event, /* receive data from the client */
send_event, /* send more data to the client */
conn_event; /* Connection successfully established */
struct ares_options DNSOptions;
ares_channel DNSChannel;
DNSQueryParts *DNSQuery;
+
+ evcurl_request_data HttpReq;
+
+ /* Saving / loading a message async from / to disk */
+ struct CtdlMessage *AsyncMsg;
+ struct recptypes *AsyncRcp;
/* Custom data; its expected to contain AsyncIO so we can save malloc()s... */
void *Data; /* application specific data */
void *CitContext; /* Citadel Session context... */
void FreeAsyncIOContents(AsyncIO *IO);
+void NextDBOperation(AsyncIO *IO, IO_CallBack CB);
+int QueueDBOperation(AsyncIO *IO, IO_CallBack CB);
int QueueEventContext(AsyncIO *IO, IO_CallBack CB);
int ShutDownEventQueue(void);
void SetNextTimeout(AsyncIO *IO, double timeout);
void InitC_ares_dns(AsyncIO *IO);
+
+#include <curl/curl.h>
+
+#define OPT(s, v) \
+ do { \
+ sta = curl_easy_setopt(chnd, (CURLOPT_##s), (v)); \
+ if (sta) { \
+ CtdlLogPrintf(CTDL_ERR, "error setting option " #s " on curl handle: %s", curl_easy_strerror(sta)); \
+ } } while (0)
+
+
+int evcurl_init(AsyncIO *IO,
+ void *CustomData,
+ const char* Desc,
+ IO_CallBack CallBack,
+ IO_CallBack Terminate);
+
+void evcurl_handle_start(AsyncIO *IO);