summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2026-01-03 23:28:26 +0100
committerCarl Hetherington <cth@carlh.net>2026-01-03 23:28:26 +0100
commit9aa3dad7959b8bdda55dbfb525337ae43948e326 (patch)
treef9e838ca9c74679e6d8c94481e51b8eeb3517f80 /src
parenta59aa65e54044368c59ebd022f23356ad532a7e6 (diff)
White space: internet.{cc,h}
Diffstat (limited to 'src')
-rw-r--r--src/lib/internet.cc86
-rw-r--r--src/lib/internet.h12
2 files changed, 49 insertions, 49 deletions
diff --git a/src/lib/internet.cc b/src/lib/internet.cc
index 92ab4c854..3fb45738c 100644
--- a/src/lib/internet.cc
+++ b/src/lib/internet.cc
@@ -42,7 +42,7 @@ using boost::optional;
static size_t
-ls_url_data (void* buffer, size_t size, size_t nmemb, void* output)
+ls_url_data(void* buffer, size_t size, size_t nmemb, void* output)
{
string* s = reinterpret_cast<string*>(output);
char* c = reinterpret_cast<char*>(buffer);
@@ -54,16 +54,16 @@ ls_url_data (void* buffer, size_t size, size_t nmemb, void* output)
list<string>
-ls_url (string url)
+ls_url(string url)
{
- auto curl = curl_easy_init ();
- curl_easy_setopt (curl, CURLOPT_URL, url.c_str());
- curl_easy_setopt (curl, CURLOPT_DIRLISTONLY, 1);
+ auto curl = curl_easy_init();
+ curl_easy_setopt(curl, CURLOPT_URL, url.c_str());
+ curl_easy_setopt(curl, CURLOPT_DIRLISTONLY, 1);
string ls;
- curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, ls_url_data);
- curl_easy_setopt (curl, CURLOPT_WRITEDATA, &ls);
- auto const cr = curl_easy_perform (curl);
+ curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, ls_url_data);
+ curl_easy_setopt(curl, CURLOPT_WRITEDATA, &ls);
+ auto const cr = curl_easy_perform(curl);
if (cr != CURLE_OK) {
return {};
@@ -79,46 +79,46 @@ ls_url (string url)
}
}
- result.pop_back ();
+ result.pop_back();
return result;
}
static size_t
-get_from_url_data (void* buffer, size_t size, size_t nmemb, void* stream)
+get_from_url_data(void* buffer, size_t size, size_t nmemb, void* stream)
{
- auto f = reinterpret_cast<FILE*> (stream);
- return fwrite (buffer, size, nmemb, f);
+ 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)
+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);
+ 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);
+ curl_easy_setopt(curl, CURLOPT_FTP_SKIP_PASV_IP, 1);
}
if (!pasv) {
- curl_easy_setopt (curl, CURLOPT_FTPPORT, "-");
+ curl_easy_setopt(curl, CURLOPT_FTPPORT, "-");
}
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
/* Maximum time is 20s */
- curl_easy_setopt (curl, CURLOPT_TIMEOUT, 20);
+ curl_easy_setopt(curl, CURLOPT_TIMEOUT, 20);
- auto const cr = curl_easy_perform (curl);
+ auto const cr = curl_easy_perform(curl);
f.close();
- curl_easy_cleanup (curl);
+ curl_easy_cleanup(curl);
if (cr != CURLE_OK) {
return fmt::format(_("Download failed ({} error {})"), url, (int) cr);
}
@@ -128,14 +128,14 @@ get_from_url (string url, bool pasv, bool skip_pasv_ip, ScopedTemporary& temp)
optional<string>
-get_from_url (string url, bool pasv, bool skip_pasv_ip, function<optional<string> (boost::filesystem::path, string)> load)
+get_from_url(string url, bool pasv, bool skip_pasv_ip, function<optional<string> (boost::filesystem::path, string)> load)
{
ScopedTemporary temp;
- auto e = get_from_url (url, pasv, skip_pasv_ip, temp);
+ auto e = get_from_url(url, pasv, skip_pasv_ip, temp);
if (e) {
return e;
}
- return load (temp.path(), url);
+ return load(temp.path(), url);
}
@@ -144,11 +144,11 @@ get_from_url (string url, bool pasv, bool skip_pasv_ip, function<optional<string
* @param load Function passed a (temporary) filesystem path of the unpacked file.
*/
optional<string>
-get_from_zip_url (string url, string file, bool pasv, bool skip_pasv_ip, function<optional<string> (boost::filesystem::path, string)> load)
+get_from_zip_url(string url, string file, bool pasv, bool skip_pasv_ip, function<optional<string> (boost::filesystem::path, string)> load)
{
/* Download the ZIP file to temp_zip */
ScopedTemporary temp_zip;
- auto e = get_from_url (url, pasv, skip_pasv_ip, temp_zip);
+ auto e = get_from_url(url, pasv, skip_pasv_ip, temp_zip);
if (e) {
return e;
}
@@ -166,40 +166,40 @@ get_from_zip_url (string url, string file, bool pasv, bool skip_pasv_ip, functio
return string(_("Could not open downloaded ZIP file"));
}
- auto zip_source = zip_source_filep_create (zip_file.take(), 0, -1, 0);
+ auto zip_source = zip_source_filep_create(zip_file.take(), 0, -1, 0);
if (!zip_source) {
return string(_("Could not open downloaded ZIP file"));
}
zip_error_t error;
- zip_error_init (&error);
- auto zip = zip_open_from_source (zip_source, ZIP_RDONLY, &error);
+ zip_error_init(&error);
+ auto zip = zip_open_from_source(zip_source, ZIP_RDONLY, &error);
if (!zip) {
return fmt::format(_("Could not open downloaded ZIP file ({}:{}: {})"), error.zip_err, error.sys_err, error.str ? error.str : "");
}
#else
- struct zip* zip = zip_open (temp_zip.c_str(), 0, 0);
+ struct zip* zip = zip_open(temp_zip.c_str(), 0, 0);
#endif
- struct zip_file* file_in_zip = zip_fopen (zip, file.c_str(), 0);
+ struct zip_file* file_in_zip = zip_fopen(zip, file.c_str(), 0);
if (!file_in_zip) {
return string(_("Unexpected ZIP file contents"));
}
ScopedTemporary temp_cert;
- auto& f = temp_cert.open ("wb");
+ auto& f = temp_cert.open("wb");
char buffer[4096];
while (true) {
- int const N = zip_fread (file_in_zip, buffer, sizeof (buffer));
+ int const N = zip_fread(file_in_zip, buffer, sizeof(buffer));
f.checked_write(buffer, N);
- if (N < int (sizeof (buffer))) {
+ if (N < int(sizeof(buffer))) {
break;
}
}
- zip_fclose (file_in_zip);
- zip_close (zip);
- f.close ();
+ zip_fclose(file_in_zip);
+ zip_close(zip);
+ f.close();
- return load (temp_cert.path(), url);
+ return load(temp_cert.path(), url);
}
diff --git a/src/lib/internet.h b/src/lib/internet.h
index 041bb1bb1..fc4024719 100644
--- a/src/lib/internet.h
+++ b/src/lib/internet.h
@@ -26,21 +26,21 @@
class ScopedTemporary;
-boost::optional<std::string> get_from_url (std::string url, bool pasv, bool skip_pasv_ip, ScopedTemporary& temp);
+boost::optional<std::string> get_from_url(std::string url, bool pasv, bool skip_pasv_ip, ScopedTemporary& temp);
-boost::optional<std::string> get_from_url (
+boost::optional<std::string> get_from_url(
std::string url,
bool pasv,
bool skip_pasv_ip,
- std::function<boost::optional<std::string> (boost::filesystem::path, std::string)> load
+ std::function<boost::optional<std::string>(boost::filesystem::path, std::string)> load
);
-boost::optional<std::string> get_from_zip_url (
+boost::optional<std::string> get_from_zip_url(
std::string url,
std::string file,
bool pasv,
bool skip_pasv_ip,
- std::function<boost::optional<std::string> (boost::filesystem::path, std::string)> load
+ std::function<boost::optional<std::string>(boost::filesystem::path, std::string)> load
);
-std::list<std::string> ls_url (std::string url);
+std::list<std::string> ls_url(std::string url);