Ilya (OgarkovIA) 6 месяцев назад
Родитель 2cc16d900d
Сommit 32078e2770

@ -2,24 +2,24 @@
<CodeBlocks_layout_file> <CodeBlocks_layout_file>
<FileVersion major="1" minor="0" /> <FileVersion major="1" minor="0" />
<ActiveTarget name="Debug" /> <ActiveTarget name="Debug" />
<File name="main.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <File name="text.cpp" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor> <Cursor>
<Cursor1 position="204" topLine="0" /> <Cursor1 position="0" topLine="0" />
</Cursor> </Cursor>
</File> </File>
<File name="histogram.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <File name="histogram.cpp" open="0" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0">
<Cursor> <Cursor>
<Cursor1 position="0" topLine="0" /> <Cursor1 position="0" topLine="20" />
</Cursor> </Cursor>
</File> </File>
<File name="text.cpp" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="0" zoom_2="0"> <File name="svg.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0">
<Cursor> <Cursor>
<Cursor1 position="0" topLine="0" /> <Cursor1 position="0" topLine="41" />
</Cursor> </Cursor>
</File> </File>
<File name="svg.cpp" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="-1" zoom_2="0"> <File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="-2" zoom_2="0">
<Cursor> <Cursor>
<Cursor1 position="0" topLine="0" /> <Cursor1 position="1933" topLine="47" />
</Cursor> </Cursor>
</File> </File>
</CodeBlocks_layout_file> </CodeBlocks_layout_file>

@ -51,35 +51,32 @@ size_t write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
return data_size; return data_size;
} }
Input download(const string& address) { Input download(const string& address) {
stringstream buffer; stringstream buffer;
CURL *curl = curl_easy_init();
curl_global_init(CURL_GLOBAL_ALL);
CURL* curl = curl_easy_init(); // CURL* - äåñêðèïòîð, ñëîæíûé îáúåêò, ïåðåäàâàòü èõ ôóíêöèÿì áèáëèîòåêè è ñðàâíèâàòü ìåæäó ñîáîé
if(curl) { if(curl) {
CURLcode res; CURLcode res;
double connect_time;
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_WRITEFUNCTION, write_data);
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer);
res = curl_easy_perform(curl); res = curl_easy_perform(curl);
if (!curl_easy_getinfo(curl, CURLINFO_CONNECT_TIME, &connect_time)) {
cerr << "Connect time: " << connect_time << " seconds." << endl;
} else {
cerr << "Failed to retrieve connect time." << endl;
}
if (res != CURLE_OK) { if (res != CURLE_OK) {
curl_easy_strerror(res); cerr << "CURL error: " << curl_easy_strerror(res) << endl;
curl_easy_cleanup(curl);
exit(1); exit(1);
} }
if(!res) {
long req;
res = curl_easy_getinfo(curl, CURLINFO_SIZE_DOWNLOAD_T, &req);
if(!res) {
cerr<<"Request size: "<<req<< " bytes\n";
}
}
curl_easy_cleanup(curl); curl_easy_cleanup(curl);
} }
return input_data(buffer, false); return input_data(buffer, false);

Загрузка…
Отмена
Сохранить