summaryrefslogtreecommitdiff
path: root/xs_curl.h
diff options
context:
space:
mode:
Diffstat (limited to 'xs_curl.h')
-rw-r--r--xs_curl.h18
1 files changed, 9 insertions, 9 deletions
diff --git a/xs_curl.h b/xs_curl.h
index 2301661..feb23e0 100644
--- a/xs_curl.h
+++ b/xs_curl.h
@@ -54,10 +54,10 @@ struct _payload_data {
54 int offset; 54 int offset;
55}; 55};
56 56
57static int _data_callback(void *buffer, size_t size, 57static size_t _data_callback(void *buffer, size_t size,
58 size_t nitems, struct _payload_data *pd) 58 size_t nitems, struct _payload_data *pd)
59{ 59{
60 int sz = size * nitems; 60 size_t sz = size * nitems;
61 61
62 /* open space */ 62 /* open space */
63 pd->size += sz; 63 pd->size += sz;
@@ -71,14 +71,14 @@ static int _data_callback(void *buffer, size_t size,
71} 71}
72 72
73 73
74static int _post_callback(char *buffer, size_t size, 74static size_t _post_callback(char *buffer, size_t size,
75 size_t nitems, struct _payload_data *pd) 75 size_t nitems, struct _payload_data *pd)
76{ 76{
77 /* size of data left */ 77 /* size of data left */
78 int sz = pd->size - pd->offset; 78 size_t sz = pd->size - pd->offset;
79 79
80 /* if it's still bigger than the provided space, trim */ 80 /* if it's still bigger than the provided space, trim */
81 if (sz > (int) (size * nitems)) 81 if (sz > (size_t) (size * nitems))
82 sz = size * nitems; 82 sz = size * nitems;
83 83
84 memcpy(buffer, pd->data + pd->offset, sz); 84 memcpy(buffer, pd->data + pd->offset, sz);
@@ -125,11 +125,11 @@ xs_dict *xs_http_request(const char *method, const char *url,
125 125
126 /* store response headers here */ 126 /* store response headers here */
127 curl_easy_setopt(curl, CURLOPT_HEADERDATA, &response); 127 curl_easy_setopt(curl, CURLOPT_HEADERDATA, &response);
128 curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, _header_callback); 128 curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, (curl_read_callback) _header_callback);
129 129
130 struct _payload_data ipd = { NULL, 0, 0 }; 130 struct _payload_data ipd = { NULL, 0, 0 };
131 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ipd); 131 curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ipd);
132 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, _data_callback); 132 curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, (curl_read_callback) _data_callback);
133 133
134 if (strcmp(method, "POST") == 0 || strcmp(method, "PUT") == 0) { 134 if (strcmp(method, "POST") == 0 || strcmp(method, "PUT") == 0) {
135 CURLoption curl_method = method[1] == 'O' ? CURLOPT_POST : CURLOPT_UPLOAD; 135 CURLoption curl_method = method[1] == 'O' ? CURLOPT_POST : CURLOPT_UPLOAD;
@@ -147,7 +147,7 @@ xs_dict *xs_http_request(const char *method, const char *url,
147 pd.offset = 0; 147 pd.offset = 0;
148 148
149 curl_easy_setopt(curl, CURLOPT_READDATA, &pd); 149 curl_easy_setopt(curl, CURLOPT_READDATA, &pd);
150 curl_easy_setopt(curl, CURLOPT_READFUNCTION, _post_callback); 150 curl_easy_setopt(curl, CURLOPT_READFUNCTION, (curl_read_callback) _post_callback);
151 } 151 }
152 } 152 }
153 153
@@ -232,7 +232,7 @@ int xs_smtp_request(const char *url, const char *user, const char *pass,
232 curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, rcpt); 232 curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, rcpt);
233 233
234 curl_easy_setopt(curl, CURLOPT_READDATA, &pd); 234 curl_easy_setopt(curl, CURLOPT_READDATA, &pd);
235 curl_easy_setopt(curl, CURLOPT_READFUNCTION, _post_callback); 235 curl_easy_setopt(curl, CURLOPT_READFUNCTION, (curl_read_callback) _post_callback);
236 curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L); 236 curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
237 237
238 res = curl_easy_perform(curl); 238 res = curl_easy_perform(curl);