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