code: код выполнен до индивидуальных заданий
Этот коммит содержится в:
@@ -13,11 +13,10 @@
|
|||||||
<Option compiler="gcc" />
|
<Option compiler="gcc" />
|
||||||
<Compiler>
|
<Compiler>
|
||||||
<Add option="-g" />
|
<Add option="-g" />
|
||||||
<Add directory="curl/include" />
|
<Add directory="C:/Users/gmack/OneDrive/Рабочий стол/lab01/lab_01/curl/include" />
|
||||||
</Compiler>
|
</Compiler>
|
||||||
<Linker>
|
<Linker>
|
||||||
<Add library="libcurl.dll.a" />
|
<Add library="curl/lib/libcurl.dll.a" />
|
||||||
<Add directory="curl/lib" />
|
|
||||||
</Linker>
|
</Linker>
|
||||||
</Target>
|
</Target>
|
||||||
<Target title="Release">
|
<Target title="Release">
|
||||||
|
|||||||
@@ -10,7 +10,7 @@
|
|||||||
1682341619 c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\histogram.h
|
1682341619 c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\histogram.h
|
||||||
<vector>
|
<vector>
|
||||||
|
|
||||||
1684761978 source:c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\main.cpp
|
1685882470 source:c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\main.cpp
|
||||||
<math.h>
|
<math.h>
|
||||||
<iostream>
|
<iostream>
|
||||||
<conio.h>
|
<conio.h>
|
||||||
@@ -20,6 +20,8 @@
|
|||||||
"svg.h"
|
"svg.h"
|
||||||
"histogram_internal.h"
|
"histogram_internal.h"
|
||||||
<curl/curl.h>
|
<curl/curl.h>
|
||||||
|
<sstream>
|
||||||
|
<string>
|
||||||
|
|
||||||
1681931523 c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\text.h
|
1681931523 c:\users\gmack\onedrive\đŕáî÷čé ńňîë\lab01\lab_01\text.h
|
||||||
<vector>
|
<vector>
|
||||||
|
|||||||
@@ -2,29 +2,9 @@
|
|||||||
<CodeBlocks_layout_file>
|
<CodeBlocks_layout_file>
|
||||||
<FileVersion major="1" minor="0" />
|
<FileVersion major="1" minor="0" />
|
||||||
<ActiveTarget name="Debug" />
|
<ActiveTarget name="Debug" />
|
||||||
<File name="text.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="histogram.h" open="1" top="0" tabpos="6" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="73" topLine="0" />
|
<Cursor1 position="167" topLine="0" />
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="text.cpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="211" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="svg.h" open="1" top="0" tabpos="8" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="106" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="svg.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="980" topLine="0" />
|
|
||||||
</Cursor>
|
|
||||||
</File>
|
|
||||||
<File name="histogram.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
|
||||||
<Cursor>
|
|
||||||
<Cursor1 position="1502" topLine="23" />
|
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="histogram_internal.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="histogram_internal.h" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
@@ -32,14 +12,34 @@
|
|||||||
<Cursor1 position="173" topLine="0" />
|
<Cursor1 position="173" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="histogram.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="svg.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="167" topLine="0" />
|
<Cursor1 position="980" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="text.h" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="73" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="histogram.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="1502" topLine="23" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
<File name="main.cpp" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
<File name="main.cpp" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
<Cursor>
|
<Cursor>
|
||||||
<Cursor1 position="811" topLine="0" />
|
<Cursor1 position="725" topLine="7" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="svg.h" open="1" top="0" tabpos="7" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="106" topLine="0" />
|
||||||
|
</Cursor>
|
||||||
|
</File>
|
||||||
|
<File name="text.cpp" open="1" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
|
||||||
|
<Cursor>
|
||||||
|
<Cursor1 position="211" topLine="0" />
|
||||||
</Cursor>
|
</Cursor>
|
||||||
</File>
|
</File>
|
||||||
</CodeBlocks_layout_file>
|
</CodeBlocks_layout_file>
|
||||||
|
|||||||
44
main.cpp
44
main.cpp
@@ -39,39 +39,31 @@ input_data(istream &tin, 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) {
|
||||||
CURL* curl = curl_easy_init();
|
size_t data_size = item_size * item_count;
|
||||||
if(curl) {
|
stringstream* buffer = reinterpret_cast<stringstream*>(ctx);
|
||||||
CURLcode res;
|
buffer->write(reinterpret_cast<const char*>(items), data_size);
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
return data_size;
|
||||||
res = curl_easy_perform(curl);
|
|
||||||
if(res != CURLE_OK){
|
|
||||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
|
||||||
curl_easy_strerror(res));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
curl_easy_cleanup(curl);
|
|
||||||
}
|
|
||||||
size_t data_size = item_size * item_count;
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Input
|
Input
|
||||||
download(const string& address) {
|
download(const string& address) {
|
||||||
stringstream buffer;
|
stringstream buffer;
|
||||||
CURL* curl = curl_easy_init();
|
CURL *curl = curl_easy_init();
|
||||||
if(curl) {
|
if(curl)
|
||||||
CURLcode res;
|
{
|
||||||
curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
|
CURLcode res;
|
||||||
res = curl_easy_perform(curl);
|
curl_easy_setopt(curl, CURLOPT_URL, address.c_str());
|
||||||
if(res != CURLE_OK){
|
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
|
||||||
curl_easy_strerror(res));
|
res = curl_easy_perform(curl);
|
||||||
exit(1);
|
if (res != CURLE_OK)
|
||||||
}
|
{
|
||||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(res));
|
||||||
curl_easy_cleanup(curl);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
curl_easy_cleanup(curl);
|
||||||
|
|
||||||
|
}
|
||||||
return input_data(buffer, false);
|
return input_data(buffer, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user