1.5: Fuckin' UE5... #38
1 changed files with 12 additions and 6 deletions
|
@ -37,6 +37,17 @@ UpdateChecker::~UpdateChecker() {
|
|||
curl_global_cleanup();
|
||||
}
|
||||
|
||||
inline
|
||||
std::size_t
|
||||
writeCallback(char* data, std::size_t size, std::size_t nmemb, void* user_data) {
|
||||
if(!data || !user_data) return std::size_t{};
|
||||
|
||||
auto* s = static_cast<Containers::String*>(user_data);
|
||||
(*s) = (*s) + Containers::StringView{data, size * nmemb};
|
||||
|
||||
return size * nmemb;
|
||||
}
|
||||
|
||||
UpdateChecker::Result
|
||||
UpdateChecker::check() {
|
||||
auto curl = curl_easy_init();
|
||||
|
@ -48,16 +59,11 @@ UpdateChecker::check() {
|
|||
|
||||
Containers::String response_body{Containers::AllocatedInit, ""};
|
||||
Containers::String error_buffer{ValueInit, CURL_ERROR_SIZE};
|
||||
static auto write_data = [](char* ptr, std::size_t size, std::size_t nmemb, Containers::String* buf){
|
||||
if(!ptr || !buf) return std::size_t{};
|
||||
(*buf) = Utility::format("{}{}", *buf, Containers::StringView{ptr, size * nmemb});
|
||||
return size * nmemb;
|
||||
};
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "https://williamjcm.ovh/mbst/version");
|
||||
curl_easy_setopt(curl, CURLOPT_HTTPGET, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 1L);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_data);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, writeCallback);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &response_body);
|
||||
curl_easy_setopt(curl, CURLOPT_ERRORBUFFER, error_buffer.data());
|
||||
curl_easy_setopt(curl, CURLOPT_TCP_KEEPALIVE, 0L);
|
||||
|
|
Loading…
Reference in a new issue