diff --git a/CommonVar.cpp b/CommonVar.cpp index 92f1974..ba83a2a 100644 --- a/CommonVar.cpp +++ b/CommonVar.cpp @@ -9,6 +9,7 @@ using namespace std; + struct Input { vector Numbers; size_t BinCount{}; @@ -48,21 +49,29 @@ WriteData(void* items, size_t item_size, size_t item_count, void* ctx) { } Input -Download(const string& address) { +Download(const string& address, const string& option) { stringstream buffer; - + if ((option != "") && (address != "-verbose") && (option != "-verbose")) { + cout << "хуйню ты пишешь, пиши опцию -verbose, дааун" << endl; + exit(2); + } CURL* curl = curl_easy_init(); if (curl) { - CURLcode res; - curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); - curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteData); - curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); - res = curl_easy_perform(curl); - if (res != CURLE_OK) { - cout << curl_easy_strerror(res); - exit(1); - } - curl_easy_cleanup(curl); + + CURLcode res; + curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); + curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteData); + curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); + if (address == "-verbose" || option == "-verbose") { + curl_easy_setopt(curl, CURLOPT_VERBOSE, option == "-verbose" ? option.c_str() : address.c_str()); + } + res = curl_easy_perform(curl); + if (res != CURLE_OK) { + cout << curl_easy_strerror(res); + exit(1); + } + curl_easy_cleanup(curl); + } @@ -72,10 +81,11 @@ Download(const string& address) { int main(int argc, char* argv[]) { + setlocale(LC_ALL, "Russian"); double MaxCount = 0; Input in; if (argc > 1) { - in = Download(argv[1]); + in = Download(argv[1], argv[2]); } else { in = InputData(cin, true);