итоговый вариант 2

master
Tanya 11 месяцев назад
Родитель 95f84eb8fa
Сommit 308ebfa503

@ -51,16 +51,27 @@ write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
} }
Input Input
download(const string& address) { download(const string& address, const string& option) {
cerr << "zalupa ebanaya" << endl;
stringstream buffer; stringstream buffer;
CURL* curl = curl_easy_init(); CURL* curl = curl_easy_init();
if ((option != "") && (address != "-verbose") && (option != "-verbose")) {
cout << "Invalid argument, please use -verbose" << endl;
exit(2);
}
if (curl) { if (curl) {
CURLcode res; CURLcode res;
curl_easy_setopt(curl, CURLOPT_URL, address.c_str()); if (option == "" || option == "-verbose") {
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
}
else if (address == "-verbose") {
curl_easy_setopt(curl, CURLOPT_URL, option.c_str());
}
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); 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); res = curl_easy_perform(curl);
if (res != CURLE_OK) { if (res != CURLE_OK) {
cout << curl_easy_strerror(res); cout << curl_easy_strerror(res);
@ -68,19 +79,15 @@ download(const string& address) {
} }
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
} }
cerr << "polnaya pizda" << endl;
cerr << buffer.str();
return input_data(buffer, false); return input_data(buffer, false);
} }
int main(int argc, char* argv[]) { int main(int argc, char* argv[]) {
Input in; Input in;
if (argc > 1) { if (argc > 1) {
cerr << "ebal rot"<< endl; in = download(argv[1], argv[2]);
in = download(argv[1]);
} }
else { else {
cerr << "kak je zaebalo"<<endl;
in = input_data(cin, true); in = input_data(cin, true);
} }
auto bins = make_histogram(in.numbers, in.bin_count); auto bins = make_histogram(in.numbers, in.bin_count);

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