Fix compilation for curl 7.68.0

This commit is contained in:
blankie 2023-11-25 15:50:49 +11:00
parent 0dd921cd5d
commit 5d74e1124d
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
4 changed files with 28 additions and 5 deletions

View File

@ -43,9 +43,15 @@ MastodonClient::MastodonClient() {
try {
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_DNS);
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_SSL_SESSION);
#if CURL_AT_LEAST_VERSION(7, 57, 0)
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_CONNECT);
#endif
#if CURL_AT_LEAST_VERSION(7, 61, 0)
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_PSL);
#endif
#if CURL_AT_LEAST_VERSION(7, 88, 0)
setopt(this->_share, CURLSHOPT_SHARE, CURL_LOCK_DATA_HSTS);
#endif
setopt(this->_share, CURLSHOPT_LOCKFUNC, share_lock);
setopt(this->_share, CURLSHOPT_UNLOCKFUNC, share_unlock);
@ -206,7 +212,11 @@ CURL* MastodonClient::_get_easy() {
try {
setopt(curl, CURLOPT_TIMEOUT_MS, 10000L);
#if CURL_AT_LEAST_VERSION(7, 85, 0)
setopt(curl, CURLOPT_PROTOCOLS_STR, "https");
#else
setopt(curl, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS);
#endif
setopt(curl, CURLOPT_USERAGENT, "Coyote (https://gitlab.com/blankX/coyote; blankie@nixnetmail.com)");
setopt(curl, CURLOPT_SHARE, this->_share);
} catch (const std::exception& e) {
@ -266,7 +276,7 @@ long MastodonClient::_response_status_code() {
static void lowercase(std::string& str) {
for (size_t i = 0; i < str.size(); i++) {
if (str[i] >= 'A' && str[i] <= 'Z') {
str[i] = str[i] - static_cast<char>('A' + 'a');
str[i] = static_cast<char>(str[i] - 'A' + 'a');
}
}
}

View File

@ -89,6 +89,6 @@ private:
lxb_html_document_t* _document;
};
}; // namespace HTML
} // namespace HTML
}; // namespace LXB
} // namespace LXB

View File

@ -41,7 +41,7 @@ struct Account {
std::vector<Emoji> emojis;
std::vector<AccountField> fields;
constexpr std::string acct(bool always_show_domain = true) const {
inline std::string acct(bool always_show_domain = true) const {
std::string res = this->username;
if (always_show_domain || !this->same_server) {
res += '@';

View File

@ -29,13 +29,26 @@ static inline Element serialize_poll(const httplib::Request& req, const Poll& po
class CurlUrlException : public std::exception {
public:
CurlUrlException(CURLUcode code_) : code(code_) {}
CurlUrlException(CURLUcode code_) : code(code_) {
#if !CURL_AT_LEAST_VERSION(7, 80, 0)
snprintf(this->_id_buf, 64, "curl url error %d", this->code);
#endif
}
const char* what() const noexcept {
#if CURL_AT_LEAST_VERSION(7, 80, 0)
return curl_url_strerror(this->code);
#else
return this->_id_buf;
#endif
}
CURLUcode code;
private:
#if !CURL_AT_LEAST_VERSION(7, 80, 0)
char _id_buf[64];
#endif
};