Support more versions of curl (patch included)

Discuss new features and functions
Posts: 44
Joined: 14 Aug 2022

daviank

This patch will permit to build freefilesync with any curl version >= 7.66.0 on the system.

Hopefully you can merge this into your source code.

Principle is always the same when you upgrade to a newer curl.
--- a/libcurl/curl_wrap.cpp
+++ b/libcurl/curl_wrap.cpp
@@ -336,7 +336,11 @@
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_OBSOLETE46);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_TOO_MANY_REDIRECTS);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_UNKNOWN_OPTION);
+#if LIBCURL_VERSION_NUM >= 0x074E00 // 7.78.0
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_SETOPT_OPTION_SYNTAX);
+#else
+            ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_TELNET_OPTION_SYNTAX);
+#endif
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_OBSOLETE50);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_OBSOLETE51);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_GOT_NOTHING);
@@ -349,7 +353,11 @@
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_SSL_CIPHER);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_PEER_FAILED_VERIFICATION);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_BAD_CONTENT_ENCODING);
+#if LIBCURL_VERSION_NUM >= 0x075200 // 7.82.0
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_OBSOLETE62);
+#else
+            ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_LDAP_INVALID_URL);
+#endif
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_FILESIZE_EXCEEDED);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_USE_SSL_FAILED);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_SEND_FAIL_REWIND);
@@ -362,8 +370,16 @@
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_TFTP_UNKNOWNID);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_REMOTE_FILE_EXISTS);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_TFTP_NOSUCHUSER);
+#if LIBCURL_VERSION_NUM >= 0x075500 // 7.85.0
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_OBSOLETE75);
+#else
+            ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_CONV_FAILED);
+#endif
+#if LIBCURL_VERSION_NUM >= 0x075200 // 7.82.0
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_OBSOLETE76);
+#else
+            ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_CONV_REQD);
+#endif
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_SSL_CACERT_BADFILE);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_REMOTE_FILE_NOT_FOUND);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_SSH);
@@ -381,15 +397,41 @@
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_SSL_INVALIDCERTSTATUS);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_HTTP2_STREAM);
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_RECURSIVE_API_CALL);
+#if LIBCURL_VERSION_NUM >= 0x074200 // 7.66.0
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_AUTH_ERROR);
+#endif
+#if LIBCURL_VERSION_NUM >= 0x074400 // 7.68.0
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_HTTP3);
+#endif
+#if LIBCURL_VERSION_NUM >= 0x074500 // 7.69.0
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_QUIC_CONNECT_ERROR);
+#endif
+#if LIBCURL_VERSION_NUM >= 0x074900 // 7.73.0
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_PROXY);
+#endif
+#if LIBCURL_VERSION_NUM >= 0x074D00 // 7.77.0
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_SSL_CLIENTCERT);
+#endif
+#if LIBCURL_VERSION_NUM >= 0x075400 // 7.84.0
             ZEN_CHECK_CASE_FOR_CONSTANT(CURLE_UNRECOVERABLE_POLL);
+#endif
             ZEN_CHECK_CASE_FOR_CONSTANT(CURL_LAST);
     }
+#if LIBCURL_VERSION_NUM >= 0x075400 // 7.84.0
     static_assert(CURL_LAST == CURLE_UNRECOVERABLE_POLL + 1);
+#elif LIBCURL_VERSION_NUM >= 0x074D00 // 7.77.0
+    static_assert(CURL_LAST == CURLE_SSL_CLIENTCERT + 1);
+#elif LIBCURL_VERSION_NUM >= 0x074900 // 7.73.0
+    static_assert(CURL_LAST == CURLE_PROXY + 1);
+#elif LIBCURL_VERSION_NUM >= 0x074500 // 7.69.0
+    static_assert(CURL_LAST == CURLE_QUIC_CONNECT_ERROR + 1);
+#elif LIBCURL_VERSION_NUM >= 0x074400 // 7.68.0
+    static_assert(CURL_LAST == CURLE_HTTP3 + 1);
+#elif LIBCURL_VERSION_NUM >= 0x074200 // 7.66.0
+    static_assert(CURL_LAST == CURLE_AUTH_ERROR + 1);
+#else
+    static_assert(CURL_LAST == CURLE_RECURSIVE_API_CALL + 1);
+#endif
 
     return replaceCpy<std::wstring>(L"Curl status %x", L"%x", numberTo<std::wstring>(static_cast<int>(sc)));
 }
[code]