From 77e876a354c62fac06c9486deb1cd56d6813006f Mon Sep 17 00:00:00 2001 From: KhokhlovKR Date: Tue, 6 Jun 2023 09:24:28 +0300 Subject: [PATCH] =?UTF-8?q?code:=D0=B8=D1=82=D0=BE=D0=B3=D0=BE=D0=B2=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82=20=D0=BF?= =?UTF-8?q?=D1=80=D0=BE=D0=B3=D1=80=D0=B0=D0=BC=D0=BC=D1=8B=20=D1=81=20?= =?UTF-8?q?=D1=81=D0=B5=D0=B4=D1=8C=D0=BC=D1=8B=D0=BC=20=D0=B2=D0=B0=D1=80?= =?UTF-8?q?=D0=B8=D0=B0=D0=BD=D1=82=D0=BE=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- laba1cb/lab1final/main.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/laba1cb/lab1final/main.cpp b/laba1cb/lab1final/main.cpp index dfe2eab..33a0001 100644 --- a/laba1cb/lab1final/main.cpp +++ b/laba1cb/lab1final/main.cpp @@ -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(ctx); buffer->write(reinterpret_cast(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)