1
0
mirror of https://github.com/rkd77/elinks.git synced 2024-06-24 00:56:14 +00:00

[version] Show runtime version of decompression libraries

This commit is contained in:
Witold Filipczyk 2021-12-27 17:02:58 +01:00
parent d3f9bd5a4b
commit 571d275759
11 changed files with 78 additions and 5 deletions

View File

@ -175,6 +175,23 @@ brotli_close(struct stream_encoded *stream)
}
}
const char *
get_brotli_version(void)
{
static char version[16];
if (!version[0]) {
int v = BrotliDecoderVersion();
int major = v >> 24;
int minor = (v >> 12) & 0xFFF;
int patch = v & 0xFFF;
snprintf(version, 15, "%d.%d.%d", major, minor, patch);
}
return version;
}
static const char *const brotli_extensions[] = { ".br", NULL };
const struct decoding_backend brotli_decoding_backend = {

View File

@ -9,6 +9,8 @@ extern "C" {
#ifdef CONFIG_BROTLI
extern const struct decoding_backend brotli_decoding_backend;
const char *get_brotli_version(void);
#else
#define brotli_decoding_backend dummy_decoding_backend
#endif

View File

@ -212,6 +212,22 @@ bzip2_close(struct stream_encoded *stream)
}
}
const char *
get_bzip2_version(void)
{
static char version[16];
if (!version[0]) {
strncpy(version, BZ2_bzlibVersion(), 15);
size_t ok = strspn(version, "0123456789.");
version[ok] = '\0';
}
return version;
}
static const char *const bzip2_extensions[] = { ".bz2", ".tbz", NULL };
const struct decoding_backend bzip2_decoding_backend = {

View File

@ -9,6 +9,7 @@ extern "C" {
#ifdef CONFIG_BZIP2
extern const struct decoding_backend bzip2_decoding_backend;
const char *get_bzip2_version(void);
#else
#define bzip2_decoding_backend dummy_decoding_backend
#endif

View File

@ -250,6 +250,12 @@ deflate_close(struct stream_encoded *stream)
}
}
const char *
get_gzip_version(void)
{
return zlibVersion();
}
static const char *const gzip_extensions[] = { ".gz", ".tgz", NULL };
const struct decoding_backend gzip_decoding_backend = {

View File

@ -9,6 +9,7 @@ extern "C" {
#ifdef CONFIG_GZIP
extern const struct decoding_backend gzip_decoding_backend;
const char *get_gzip_version(void);
#else
#define gzip_decoding_backend dummy_decoding_backend
#endif

View File

@ -176,6 +176,12 @@ lzma_close(struct stream_encoded *stream)
}
}
const char *
get_lzma_version(void)
{
return lzma_version_string();
}
static const char *const lzma_extensions[] = { ".lzma", ".xz", NULL };
const struct decoding_backend lzma_decoding_backend = {

View File

@ -9,6 +9,7 @@ extern "C" {
#ifdef CONFIG_LZMA
extern const struct decoding_backend lzma_decoding_backend;
const char *get_lzma_version(void);
#else
#define lzma_decoding_backend dummy_decoding_backend
#endif

View File

@ -170,6 +170,12 @@ zstd_close(struct stream_encoded *stream)
}
}
const char *
get_zstd_version(void)
{
return ZSTD_versionString();
}
static const char *const zstd_extensions[] = { ".zst", NULL };
const struct decoding_backend zstd_decoding_backend = {

View File

@ -9,6 +9,7 @@ extern "C" {
#ifdef CONFIG_ZSTD
extern const struct decoding_backend zstd_decoding_backend;
const char *get_zstd_version(void);
#else
#define zstd_decoding_backend dummy_decoding_backend
#endif

View File

@ -13,6 +13,22 @@
#include "elinks.h"
#ifdef CONFIG_BROTLI
#include "encoding/brotli.h"
#endif
#ifdef CONFIG_GZIP
#include "encoding/gzip.h"
#endif
#ifdef CONFIG_BZIP2
#include "encoding/bzip2.h"
#endif
#ifdef CONFIG_LZMA
#include "encoding/lzma.h"
#endif
#ifdef CONFIG_ZSTD
#include "encoding/zstd.h"
#endif
#include "intl/libintl.h"
#include "main/module.h"
#include "main/version.h"
@ -132,19 +148,19 @@ get_dyn_full_version(struct terminal *term, int more)
comma, "IPv6",
#endif
#ifdef CONFIG_BROTLI
comma, "brotli",
comma, "brotli(", get_brotli_version(),")",
#endif
#ifdef CONFIG_GZIP
comma, "gzip",
comma, "gzip(", get_gzip_version(),")",
#endif
#ifdef CONFIG_BZIP2
comma, "bzip2",
comma, "bzip2(", get_bzip2_version(), ")",
#endif
#ifdef CONFIG_LZMA
comma, "lzma",
comma, "lzma(", get_lzma_version(), ")",
#endif
#ifdef CONFIG_ZSTD
comma, "zstd",
comma, "zstd(", get_zstd_version(), ")",
#endif
#ifndef CONFIG_MOUSE
comma, _("No mouse", term),