diff --git a/lab_01.cbp b/lab_01.cbp
index acf2a33..5ae7400 100644
--- a/lab_01.cbp
+++ b/lab_01.cbp
@@ -13,11 +13,10 @@
-
+
-
-
+
diff --git a/lab_01.depend b/lab_01.depend
index 2efbd31..1de7263 100644
--- a/lab_01.depend
+++ b/lab_01.depend
@@ -10,7 +10,7 @@
1682341619 c:\users\gmack\onedrive\ \lab01\lab_01\histogram.h
-1684761978 source:c:\users\gmack\onedrive\ \lab01\lab_01\main.cpp
+1685882470 source:c:\users\gmack\onedrive\ \lab01\lab_01\main.cpp
@@ -20,6 +20,8 @@
"svg.h"
"histogram_internal.h"
+
+
1681931523 c:\users\gmack\onedrive\ \lab01\lab_01\text.h
diff --git a/lab_01.layout b/lab_01.layout
index 91dafb6..98a9c1f 100644
--- a/lab_01.layout
+++ b/lab_01.layout
@@ -2,24 +2,24 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
@@ -27,19 +27,19 @@
-
+
-
+
-
+
-
+
-
+
-
+
diff --git a/main.cpp b/main.cpp
index 01fc645..a3c9587 100644
--- a/main.cpp
+++ b/main.cpp
@@ -39,39 +39,31 @@ input_data(istream &tin, bool prompt){
size_t
write_data(void* items, size_t item_size, size_t item_count, void* ctx) {
- CURL* curl = curl_easy_init();
- if(curl) {
- CURLcode res;
- curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
- 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;
+ 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;
- CURL* curl = curl_easy_init();
- if(curl) {
- CURLcode res;
- curl_easy_setopt(curl, CURLOPT_URL, "https://example.com");
- 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_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
- curl_easy_cleanup(curl);
+ 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);
+ if (res != CURLE_OK)
+ {
+ fprintf(stderr, "curl_easy_perform() failed: %s\n",curl_easy_strerror(res));
+ exit(1);
}
+ curl_easy_cleanup(curl);
+ }
return input_data(buffer, false);
}