From c56626411597b5cf9f57d46768fcd5472855677a Mon Sep 17 00:00:00 2001 From: "(KasimovAM)" Date: Tue, 6 Jun 2023 23:02:23 +0300 Subject: [PATCH] =?UTF-8?q?code:=20=D0=B2=D0=B0=D1=80=D0=B8=D0=B0=D0=BD?= =?UTF-8?q?=D1=82=209?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.cpp | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/main.cpp b/main.cpp index ef2ee2a..aa195d1 100644 --- a/main.cpp +++ b/main.cpp @@ -46,12 +46,15 @@ size_t write_data(void* items, size_t item_size, size_t item_count, void* ctx) } Input -download(const string& address) { -stringstream buffer; +download(const string& address) +{ + stringstream buffer; CURL *curl = curl_easy_init(); if(curl) { CURLcode res; + curl_version_info_data *ver = curl_version_info(CURLVERSION_NOW); + curl_version_info_data *version = curl_version_info(CURLVERSION_NOW); curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); @@ -61,9 +64,16 @@ stringstream buffer; fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(res)); exit(1); } - curl_easy_cleanup(curl); - + else + { + fprintf(stderr,"libcurl version %u.%u.%u\n", + (ver->version_num >> 16) & 0xff, + (ver->version_num >> 8) & 0xff, + ver->version_num & 0xff); + cerr << "OpenSSL version " << version->ssl_version << endl; + } } + curl_easy_cleanup(curl); return input_data(buffer, false); } @@ -71,14 +81,18 @@ stringstream buffer; int -main(int argc, char* argv[]) { +main(int argc, char* argv[]) +{ Input input; - if (argc > 1) { + if (argc > 1) + { input = download(argv[1]); - } else { + } + else + { input = input_data(cin, true); } - const auto bins = make_histogram(input.numbers, input.bin_count); + const auto bins = make_histogram(input.numbers, input.bin_count); show_histogram_svg(bins); }