static int writer void data size_t size size_t nmemb TStringStream buf

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
static int writer(void *data, size_t size, size_t nmemb, TStringStream *buffer) {
int result = 0;
if (buffer != NULL) {
buffer->Write(data, size * nmemb);
result = size * nmemb;
}
return result;
}
void DSend(String s) {
CURL *curl;
CURLcode res;
curl = curl_easy_init();
TStringStream *buffer = new TStringStream("", 65001);
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL, "http://");
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writer);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, buffer);
}
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
delete buffer;
}