|
|
|
@ -98,7 +98,7 @@ size_t write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
|
|
|
|
|
|
|
|
|
|
size_t write_header(char* buffer, size_t size, size_t nitems, void* userdata)
|
|
|
|
|
{
|
|
|
|
|
cerr << "Headers: " << buffer << endl;
|
|
|
|
|
//cerr << "Headers: " << buffer << endl;
|
|
|
|
|
return size * nitems;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -108,8 +108,10 @@ static size_t progress_callback(void* clientp,
|
|
|
|
|
double ultotal,
|
|
|
|
|
double ulnow)
|
|
|
|
|
{
|
|
|
|
|
struct progress* memory = (progress*)clientp;
|
|
|
|
|
cerr << "Progress: " << (dlnow / dltotal) * 100 << "%\n";
|
|
|
|
|
//struct progress* memory = (progress*)clientp;
|
|
|
|
|
if (!isnan((dlnow / dltotal) * 100.0)) {
|
|
|
|
|
cerr << "Progress: " << (double)(dlnow / dltotal) * 100.0 << "%\n";
|
|
|
|
|
}
|
|
|
|
|
//cerr << "Progress: " << memory->privat << "\n";
|
|
|
|
|
return 0; /* all is good */
|
|
|
|
|
}
|
|
|
|
@ -122,13 +124,13 @@ Input download(const string& address) {
|
|
|
|
|
if (curl) {
|
|
|
|
|
CURLcode res;
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &data);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, write_header);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_HEADERDATA, NULL);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
|
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
if (res != CURLE_OK) {
|
|
|
|
|