- string* s = reinterpret_cast<string *> (data);
- uint8_t* b = reinterpret_cast<uint8_t *> (buffer);
- for (size_t i = 0; i < (size * nmemb); ++i) {
- *s += b[i];
+ auto f = reinterpret_cast<FILE*> (stream);
+ return fwrite (buffer, size, nmemb, f);
+}
+
+
+optional<string>
+get_from_url (string url, bool pasv, bool skip_pasv_ip, ScopedTemporary& temp)
+{
+ auto curl = curl_easy_init ();
+ curl_easy_setopt (curl, CURLOPT_URL, url.c_str());
+
+ auto& f = temp.open ("wb");
+ curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, get_from_url_data);
+ curl_easy_setopt (curl, CURLOPT_WRITEDATA, f.get());
+ curl_easy_setopt (curl, CURLOPT_FTP_USE_EPSV, 0);
+ curl_easy_setopt (curl, CURLOPT_FTP_USE_EPRT, 0);
+ if (skip_pasv_ip) {
+ curl_easy_setopt (curl, CURLOPT_FTP_SKIP_PASV_IP, 1);