From 448fb40b4a86c3cb0ee3848e197667956cc69bea Mon Sep 17 00:00:00 2001 From: Alex Date: Mon, 3 Jun 2024 00:32:49 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B3=D0=BE=D1=82=D0=BE=D0=B2=D1=8B=D0=B9=20?= =?UTF-8?q?=D1=81=D0=BE=D0=B1=D1=81=D1=82=D0=B2=D0=B5=D0=BD=D0=BD=D1=8B?= =?UTF-8?q?=D0=B9=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/main.cpp b/main.cpp index 95fa242..1ad4ce6 100644 --- a/main.cpp +++ b/main.cpp @@ -60,21 +60,26 @@ Input download(const string& address) if(curl) { CURLcode res; + double start; + curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); res = curl_easy_perform(curl); curl_easy_cleanup(curl); - if (res != 0) + if (res == CURLE_OK) { - cerr << curl_easy_strerror(res) << endl; - exit(1); + res = curl_easy_getinfo(curl, CURLINFO_STARTTRANSFER_TIME, &start); + if (CURLE_OK == res) + { + cerr<<"Time: " << start; + } } - } - curl_easy_cleanup(curl); + curl_easy_cleanup(curl); - return input_data(buffer, false); + return input_data(buffer, false); + } } @@ -111,11 +116,15 @@ Input download(const string& address) return 0; } */ -int main(int argc, char* argv[]) { +int main(int argc, char* argv[]) +{ Input input; - if (argc > 1) { + if (argc > 1) + { input = download(argv[1]); - } else { + } + else + { input = input_data(cin, true); }