Work on integrating libcurl <-> libev
[citadel.git] / citadel / modules / curl / serv_curl.h
1 #include <event_client.h>
2 #include <curl/curl.h>
3
4 typedef struct _evcurl_global_data {
5         int magic;
6         CURLM *mhnd;
7         ev_timer timeev;
8         int nrun;
9 } evcurl_global_data;
10
11 typedef struct _evcurl_request_data 
12 {
13         evcurl_global_data *global;
14         CURL *chnd;
15         char errdesc[CURL_ERROR_SIZE];
16         int attached;
17         char* PlainPostData;
18         long PlainPostDataLen;
19         StrBuf *PostData;
20         StrBuf *ReplyData;
21         ParsedURL *URL;
22         struct curl_slist * headers;
23 } evcurl_request_data;
24
25 typedef struct _sockwatcher_data 
26 {
27         evcurl_global_data *global;
28         ev_io ioev;
29 } sockwatcher_data;
30
31
32
33
34 #define OPT(s, v) \
35         do { \
36                 sta = curl_easy_setopt(chnd, (CURLOPT_##s), (v)); \
37                 if (sta)  {                                             \
38                         CtdlLogPrintf(CTDL_ERR, "error setting option " #s " on curl handle: %s", curl_easy_strerror(sta)); \
39         } } while (0)
40
41
42 int evcurl_init(evcurl_request_data *handle, 
43                 void *CustomData, 
44                 const char* Desc,
45                 int CallBack);
46
47 void evcurl_handle_start(evcurl_request_data *handle);