code: сокращение ссылки в writedata
Этот коммит содержится в:
@@ -60,6 +60,16 @@ input_data(istream& hin, bool promt = false) {
|
|||||||
return in;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Input download(const string& address) {
|
Input download(const string& address) {
|
||||||
stringstream buffer;
|
stringstream buffer;
|
||||||
@@ -70,8 +80,14 @@ Input download(const string& address) {
|
|||||||
|
|
||||||
CURL* curl = curl_easy_init();
|
CURL* curl = curl_easy_init();
|
||||||
if (curl) {
|
if (curl) {
|
||||||
|
|
||||||
|
|
||||||
CURLcode res;
|
CURLcode res;
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||||
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
||||||
|
|
||||||
|
|
||||||
res = curl_easy_perform(curl);
|
res = curl_easy_perform(curl);
|
||||||
curl_easy_cleanup(curl);
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
@@ -92,6 +108,7 @@ Input download(const string& address) {
|
|||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
|
curl_global_init(CURL_GLOBAL_ALL);
|
||||||
|
|
||||||
Input in;
|
Input in;
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
|
|||||||
Двоичные данные
x64/Debug/ProgUit Lab1.pdb
Двоичные данные
x64/Debug/ProgUit Lab1.pdb
Двоичный файл не отображается.
Ссылка в новой задаче
Block a user