summaryrefslogtreecommitdiff
path: root/lib/version.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/version.c')
-rw-r--r--lib/version.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/lib/version.c b/lib/version.c
index 14e509606..91fb092ae 100644
--- a/lib/version.c
+++ b/lib/version.c
@@ -66,6 +66,10 @@
#include <brotli/decode.h>
#endif
+#ifdef HAVE_ZSTD
+#include <zstd.h>
+#endif
+
#ifdef HAVE_BROTLI
static size_t brotli_version(char *buf, size_t bufsz)
{
@@ -78,6 +82,20 @@ static size_t brotli_version(char *buf, size_t bufsz)
}
#endif
+#ifdef HAVE_ZSTD
+static size_t zstd_version(char *buf, size_t bufsz)
+{
+ unsigned long zstd_version = (unsigned long)ZSTD_versionNumber();
+ unsigned int major = (unsigned int)(zstd_version / (100 * 100));
+ unsigned int minor = (unsigned int)((zstd_version -
+ (major * 100 * 100)) / 100);
+ unsigned int patch = (unsigned int)(zstd_version -
+ (major * 100 * 100) - (minor * 100));
+
+ return msnprintf(buf, bufsz, "%u.%u.%u", major, minor, patch);
+}
+#endif
+
/*
* curl_version() returns a pointer to a static buffer.
*
@@ -103,6 +121,9 @@ char *curl_version(void)
#ifdef HAVE_BROTLI
char br_version[40] = "brotli/";
#endif
+#ifdef HAVE_ZSTD
+ char zst_version[40] = "zstd/";
+#endif
#ifdef USE_ARES
char cares_version[40];
#endif
@@ -153,6 +174,10 @@ char *curl_version(void)
brotli_version(&br_version[7], sizeof(br_version) - 7);
src[i++] = br_version;
#endif
+#ifdef HAVE_ZSTD
+ zstd_version(&zst_version[5], sizeof(zst_version) - 5);
+ src[i++] = zst_version;
+#endif
#ifdef USE_ARES
msnprintf(cares_version, sizeof(cares_version),
"c-ares/%s", ares_version(NULL));
@@ -389,6 +414,9 @@ static curl_version_info_data version_info = {
#if defined(HAVE_BROTLI)
| CURL_VERSION_BROTLI
#endif
+#if defined(HAVE_ZSTD)
+ | CURL_VERSION_ZSTD
+#endif
#if defined(USE_ALTSVC)
| CURL_VERSION_ALTSVC
#endif
@@ -413,10 +441,12 @@ static curl_version_info_data version_info = {
NULL,
#endif
#ifdef CURL_CA_PATH
- CURL_CA_PATH /* capath */
+ CURL_CA_PATH, /* capath */
#else
- NULL
+ NULL,
#endif
+ 0, /* zstd_ver_num */
+ NULL /* zstd version */
};
curl_version_info_data *curl_version_info(CURLversion stamp)
@@ -434,6 +464,10 @@ curl_version_info_data *curl_version_info(CURLversion stamp)
#ifdef HAVE_BROTLI
static char brotli_buffer[80];
#endif
+#ifdef HAVE_ZSTD
+ static char zstd_buffer[80];
+#endif
+
#ifdef USE_SSL
Curl_ssl_version(ssl_buffer, sizeof(ssl_buffer));
@@ -485,6 +519,12 @@ curl_version_info_data *curl_version_info(CURLversion stamp)
version_info.brotli_version = brotli_buffer;
#endif
+#ifdef HAVE_ZSTD
+ version_info.zstd_ver_num = (unsigned int)ZSTD_versionNumber();
+ zstd_version(zstd_buffer, sizeof(zstd_buffer));
+ version_info.zstd_version = zstd_buffer;
+#endif
+
#ifdef USE_NGHTTP2
{
nghttp2_info *h2 = nghttp2_version(0);