diff --git a/ProgUit Lab1/ProgUit Lab1.cpp b/ProgUit Lab1/ProgUit Lab1.cpp index af7eb22..54fb08c 100644 --- a/ProgUit Lab1/ProgUit Lab1.cpp +++ b/ProgUit Lab1/ProgUit Lab1.cpp @@ -60,6 +60,16 @@ input_data(istream& hin, bool promt = false) { 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(ctx); + buffer->write(reinterpret_cast(items), data_size); + + return data_size; +} + Input download(const string& address) { stringstream buffer; @@ -70,8 +80,14 @@ Input download(const string& address) { CURL* curl = curl_easy_init(); 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); + + res = curl_easy_perform(curl); curl_easy_cleanup(curl); @@ -92,6 +108,7 @@ Input download(const string& address) { int main(int argc, char* argv[]) { + curl_global_init(CURL_GLOBAL_ALL); Input in; if (argc > 1) { diff --git a/x64/Debug/ProgUit Lab1.pdb b/x64/Debug/ProgUit Lab1.pdb index 3b456fc..9b84be8 100644 Binary files a/x64/Debug/ProgUit Lab1.pdb and b/x64/Debug/ProgUit Lab1.pdb differ