size_t WriteCallback(void* contents, size_t size, size_t nmemb, void* userp)
{
size_t realsize = size * nmemb;
//stringLock.lock();
((string*)userp)->append((char*)contents, realsize);
//stringLock.unlock();
return realsize;
}
void getURL(string url, FetchResult* result)
{
CURL *curl;
CURLcode res;
string body;
curl = curl_easy_init();
if(curl)
{
curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &(result->value));
res = curl_easy_perform(curl);
/* always cleanup */
curl_easy_cleanup(curl);
}
}