|
|
|
@ -15,6 +15,11 @@ struct Input {
|
|
|
|
|
size_t bin_count{};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct progress {
|
|
|
|
|
char *pr;
|
|
|
|
|
size_t size;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Input input_data(istream& in1, bool prompt) {
|
|
|
|
|
size_t number_count;
|
|
|
|
|
if (prompt) {
|
|
|
|
@ -38,6 +43,25 @@ Input input_data(istream& in1, bool prompt) {
|
|
|
|
|
return in;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
static int progress_callback(void *clientp,
|
|
|
|
|
double dltotal,
|
|
|
|
|
double dlnow,
|
|
|
|
|
double ultotal,
|
|
|
|
|
double ulnow)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int progress = (dlnow / dltotal) * 100;
|
|
|
|
|
cerr << "Ïðîãðåññ çàãðóçêè: "<< progress << "%\r";
|
|
|
|
|
//cerr << dlnow << "\n" << dltotal << "\n";
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
size_t write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
|
|
|
|
|
size_t data_size = item_size * item_count;
|
|
|
|
|
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
|
|
|
|
@ -48,6 +72,7 @@ size_t write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
|
|
|
|
|
|
|
|
|
|
Input download(const string& address) {
|
|
|
|
|
stringstream buffer;
|
|
|
|
|
progress data;
|
|
|
|
|
CURL* curl = curl_easy_init();
|
|
|
|
|
if(curl)
|
|
|
|
|
{
|
|
|
|
@ -55,6 +80,11 @@ Input download(const string& address) {
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
|
|
|
|
//
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROGRESSDATA, &data);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
|
|
|
|
|
//
|
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
if(res != 0)
|
|
|
|
@ -87,4 +117,3 @@ int main(int argc, char* argv[])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//show_histogram_text(bins, in.bin_count);
|
|
|
|
|