code:итоговый вариант программы с седьмым вариантом

master
KhokhlovKR 2 лет назад
Родитель 3de94b2167
Сommit 77e876a354

@ -16,10 +16,21 @@ struct Input {
size_t bin_count{};
};
int progress_callback(void *clientp, double dltotal, double dlnow, double ultotal, double ulnow)
{
if(dltotal > 0) {
double progress = ((dlnow * 100) / dltotal);
cerr << "Progress: " << progress << "%" << endl;
}
return 0;
}
size_t
write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
size_t data_size = item_size * item_count;
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
buffer->write(reinterpret_cast<const char*>(items), data_size);
@ -62,6 +73,8 @@ download(const string& address) {
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
res = curl_easy_perform(curl);
if (res != 0)

Загрузка…
Отмена
Сохранить