итоговый вариант 2
Этот коммит содержится в:
21
main.cpp
21
main.cpp
@@ -51,16 +51,27 @@ write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
|
||||
}
|
||||
|
||||
Input
|
||||
download(const string& address) {
|
||||
cerr << "zalupa ebanaya" << endl;
|
||||
download(const string& address, const string& option) {
|
||||
stringstream buffer;
|
||||
|
||||
CURL* curl = curl_easy_init();
|
||||
if ((option != "") && (address != "-verbose") && (option != "-verbose")) {
|
||||
cout << "Invalid argument, please use -verbose" << endl;
|
||||
exit(2);
|
||||
}
|
||||
if (curl) {
|
||||
CURLcode res;
|
||||
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_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);
|
||||
@@ -68,19 +79,15 @@ download(const string& address) {
|
||||
}
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
cerr << "polnaya pizda" << endl;
|
||||
cerr << buffer.str();
|
||||
return input_data(buffer, false);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
Input in;
|
||||
if (argc > 1) {
|
||||
cerr << "ebal rot"<< endl;
|
||||
in = download(argv[1]);
|
||||
in = download(argv[1], argv[2]);
|
||||
}
|
||||
else {
|
||||
cerr << "kak je zaebalo"<<endl;
|
||||
in = input_data(cin, true);
|
||||
}
|
||||
auto bins = make_histogram(in.numbers, in.bin_count);
|
||||
|
||||
Ссылка в новой задаче
Block a user