|
|
|
@ -13,6 +13,15 @@ struct Input {
|
|
|
|
size_t bin_count;
|
|
|
|
size_t bin_count;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static int progress_callback(void* clientp, double dltotal, double dlnow, double ultotal, double ulnow) {
|
|
|
|
|
|
|
|
if (dltotal <= 0) return 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int progress = static_cast<int>((dlnow / dltotal) * 100);
|
|
|
|
|
|
|
|
cerr << "Progress: " << progress << "%\r";
|
|
|
|
|
|
|
|
cerr.flush();
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Input input_data(istream& in, bool prompt) {
|
|
|
|
Input input_data(istream& in, bool prompt) {
|
|
|
|
Input inp;
|
|
|
|
Input inp;
|
|
|
|
size_t number_count;
|
|
|
|
size_t number_count;
|
|
|
|
@ -35,34 +44,36 @@ Input input_data(istream& in, bool prompt) {
|
|
|
|
return inp;
|
|
|
|
return inp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
size_t
|
|
|
|
size_t write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
|
|
|
|
write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
|
|
|
|
|
|
|
|
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
|
|
|
|
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
|
|
|
|
size_t data_size = item_size * item_count;
|
|
|
|
size_t data_size = item_size * item_count;
|
|
|
|
(*buffer).write(reinterpret_cast<const char*>(items), data_size);
|
|
|
|
(*buffer).write(reinterpret_cast<const char*>(items), data_size);
|
|
|
|
return data_size;
|
|
|
|
return data_size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Input
|
|
|
|
Input download(const string& address){
|
|
|
|
download(const string& adress){
|
|
|
|
|
|
|
|
stringstream buffer;
|
|
|
|
stringstream buffer;
|
|
|
|
CURL* curl = curl_easy_init();
|
|
|
|
CURL* curl = curl_easy_init();
|
|
|
|
if(curl) {
|
|
|
|
if(curl) {
|
|
|
|
|
|
|
|
|
|
|
|
CURLcode res;
|
|
|
|
CURLcode res;
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, adress.c_str());
|
|
|
|
curl_easy_setopt(curl, CURLOPT_URL, address.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);
|
|
|
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0L);
|
|
|
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_PROGRESSFUNCTION, progress_callback);
|
|
|
|
|
|
|
|
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
if (res != CURLE_OK){
|
|
|
|
if (res != CURLE_OK){
|
|
|
|
cerr << curl_easy_strerror(res);
|
|
|
|
cerr << curl_easy_strerror(res);
|
|
|
|
exit(1);
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
|
|
|
cerr << endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return input_data(buffer, false);
|
|
|
|
return input_data(buffer, false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
int main(int argc, char* argv[]) {
|
|
|
|
Input input;
|
|
|
|
Input input;
|
|
|
|
if (argc > 1) {
|
|
|
|
if (argc > 1) {
|
|
|
|
|