Этот коммит содержится в:
Alexey (MinovAS)
2023-06-10 10:52:56 +03:00
родитель a0b2bfa8bc
Коммит 6188e4961c
3 изменённых файлов: 19 добавлений и 2 удалений

Двоичный файл не отображается.

Просмотреть файл

@@ -50,6 +50,12 @@
ReferencedContainer = "container:lab_3.xcodeproj"> ReferencedContainer = "container:lab_3.xcodeproj">
</BuildableReference> </BuildableReference>
</BuildableProductRunnable> </BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "http://uit.mpei.ru/study/courses/cs/lab03/marks.txt"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
</LaunchAction> </LaunchAction>
<ProfileAction <ProfileAction
buildConfiguration = "Release" buildConfiguration = "Release"

Просмотреть файл

@@ -34,13 +34,22 @@ Input input_data(istream& in, bool prompt)
} }
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); {
size_t data_size = item_size * item_count; size_t data_size = item_size * item_count;
stringstream *buffer = reinterpret_cast<stringstream*>(ctx);
(*buffer).write(reinterpret_cast<const char*>(items), data_size); (*buffer).write(reinterpret_cast<const char*>(items), data_size);
return 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 Input
download(const string& adress){ download(const string& adress){
curl_global_init(CURL_GLOBAL_ALL); curl_global_init(CURL_GLOBAL_ALL);
@@ -52,6 +61,8 @@ download(const string& adress){
curl_easy_setopt(curl, CURLOPT_URL, adress.c_str()); curl_easy_setopt(curl, CURLOPT_URL, adress.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_HEADERFUNCTION, write_header);
curl_easy_setopt(curl, CURLOPT_HEADERDATA, NULL);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if (res != CURLE_OK) if (res != CURLE_OK)
{ {