|
|
|
@ -1,6 +1,8 @@
|
|
|
|
|
#include <iostream>
|
|
|
|
|
#include <vector>
|
|
|
|
|
#include <curl/curl.h>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
#include <string>
|
|
|
|
|
#include "histogram.h"
|
|
|
|
|
#include "text.h"
|
|
|
|
|
#include "svg.h"
|
|
|
|
@ -30,27 +32,34 @@ Input input_data(istream& in, bool prompt = true)
|
|
|
|
|
in >> input.bin_count;
|
|
|
|
|
return input;
|
|
|
|
|
}
|
|
|
|
|
Input
|
|
|
|
|
download(const string& address) {
|
|
|
|
|
stringstream buffer;
|
|
|
|
|
CURL *curl = curl_easy_init();
|
|
|
|
|
if(curl) {
|
|
|
|
|
CURLcode res;
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
if (res!=CURLE_OK){
|
|
|
|
|
cerr << curl_easy_strerror(res);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
}
|
|
|
|
|
return input_data(buffer, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[])
|
|
|
|
|
{
|
|
|
|
|
Input input;
|
|
|
|
|
if (argc > 1) {
|
|
|
|
|
CURL *curl = curl_easy_init();
|
|
|
|
|
if(curl) {
|
|
|
|
|
CURLcode res;
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, argv[1]);
|
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
if (res!=CURLE_OK){
|
|
|
|
|
cerr << curl_easy_strerror(res);
|
|
|
|
|
exit(1);
|
|
|
|
|
}
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
input = download(argv[1]);
|
|
|
|
|
} else {
|
|
|
|
|
input = input_data(cin, true);
|
|
|
|
|
}
|
|
|
|
|
bool show_prompts;
|
|
|
|
|
cout << "Show prompts? (1 for yes, 0 for no): ";
|
|
|
|
|
cin >> show_prompts;
|
|
|
|
|
Input in = input_data(cin, show_prompts);
|
|
|
|
|
vector<size_t> bins = make_histogram(in.numbers, in.bin_count);
|
|
|
|
|
const auto bins = make_histogram(input.numbers, input.bin_count);
|
|
|
|
|
show_histogram_svg(bins);
|
|
|
|
|
}
|
|
|
|
|