]> code.citadel.org Git - citadel.git/blobdiff - citadel/event_client.h
finish rewriting of http client code
[citadel.git] / citadel / event_client.h
index 52e3de5ac9f132ddc01d24f78a8c2199cbd31298..49d1159783ba1a50380e9485a932d27adb012dea 100644 (file)
@@ -4,6 +4,7 @@
 #include <netdb.h>
 #include <arpa/nameser.h>
 #include <ares.h>
+#include <curl/curl.h>
 
 typedef struct AsyncIO AsyncIO;
 
@@ -33,6 +34,21 @@ typedef struct _DNSQueryParts {
        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;
@@ -72,6 +88,8 @@ struct AsyncIO {
        struct ares_options DNSOptions;
        ares_channel DNSChannel;
        DNSQueryParts *DNSQuery;
+       
+       evcurl_request_data HttpReq;
 
        /* Custom data; its expected to contain  AsyncIO so we can save malloc()s... */
        void *Data;        /* application specific data */
@@ -107,3 +125,20 @@ void StopClientWatchers(AsyncIO *IO);
 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);
+
+void evcurl_handle_start(AsyncIO *IO);