|
|
|
@ -84,6 +84,19 @@ Input input_data(istream& instr, bool promt) {
|
|
|
|
|
return in;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
(*buffer).write(reinterpret_cast<const char*>(items), data_size);
|
|
|
|
|
return data_size;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
size_t write_header(char* buffer, size_t size, size_t nitems, void* userdata)
|
|
|
|
|
{
|
|
|
|
|
cerr << "Headers: " << buffer << endl;
|
|
|
|
|
return size * nitems;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Input download(const string& address) {
|
|
|
|
|
stringstream buffer;
|
|
|
|
|
|
|
|
|
@ -91,6 +104,10 @@ Input download(const string& address) {
|
|
|
|
|
if (curl) {
|
|
|
|
|
CURLcode res;
|
|
|
|
|
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_HEADERFUNCTION, write_header);
|
|
|
|
|
curl_easy_setopt(curl, CURLOPT_HEADERDATA, NULL);
|
|
|
|
|
res = curl_easy_perform(curl);
|
|
|
|
|
curl_easy_cleanup(curl);
|
|
|
|
|
if (res != CURLE_OK) {
|
|
|
|
|