1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-03 08:13:14 +02:00

core: make zstd dependency optional (closes #2024)

This commit is contained in:
Sébastien Helleu
2023-10-01 16:36:32 +02:00
parent 879a548bea
commit 6bd0c63192
39 changed files with 697 additions and 213 deletions
+8
View File
@@ -375,6 +375,7 @@ logger_buffer_compress_file (struct t_logger_buffer *logger_buffer)
unlink (filename);
}
break;
#ifdef HAVE_ZSTD
case LOGGER_BUFFER_COMPRESSION_ZSTD:
if (weechat_file_compress (filename, new_filename,
"zstd", compression_level))
@@ -382,6 +383,7 @@ logger_buffer_compress_file (struct t_logger_buffer *logger_buffer)
unlink (filename);
}
break;
#endif
default:
break;
}
@@ -477,6 +479,12 @@ logger_buffer_rotate (struct t_logger_buffer *logger_buffer)
compression_type = weechat_config_enum (
logger_config_file_rotation_compression_type);
#ifndef HAVE_ZSTD
if (compression_type == LOGGER_BUFFER_COMPRESSION_ZSTD)
compression_type = LOGGER_BUFFER_COMPRESSION_NONE;
#endif
ptr_extension = logger_buffer_compression_extension[compression_type];
/* find the highest existing extension index */
+29 -1
View File
@@ -93,6 +93,32 @@ logger_config_change_file_option_restart_log (const void *pointer, void *data,
logger_buffer_adjust_log_filenames ();
}
/*
* Callback for changes on compression type option.
*/
void
logger_config_change_file_rotation_comp_type (const void *pointer,
void *data,
struct t_config_option *option)
{
/* make C compiler happy */
(void) pointer;
(void) data;
(void) option;
#ifndef HAVE_ZSTD
if (weechat_config_enum (option) == LOGGER_BUFFER_COMPRESSION_ZSTD)
{
weechat_printf (NULL,
_("%s%s: zstd compression is not available, "
"logger files will not be compressed"),
weechat_prefix ("error"),
LOGGER_PLUGIN_NAME);
}
#endif
}
/*
* Callback for changes on option "logger.file.color_lines".
*/
@@ -666,7 +692,9 @@ logger_config_init ()
"new type (or decompress files), then change the option in "
"logger.conf, then load the logger plugin"),
"none|gzip|zstd", 0, 0, "none", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
NULL, NULL, NULL,
&logger_config_change_file_rotation_comp_type, NULL, NULL,
NULL, NULL, NULL);
logger_config_file_rotation_size_max = weechat_config_new_option (
logger_config_file, logger_config_section_file,
"rotation_size_max", "string",
+4 -2
View File
@@ -50,8 +50,10 @@ list(APPEND LINK_LIBS ${GCRYPT_LDFLAGS})
list(APPEND LINK_LIBS ${ZLIB_LIBRARY})
include_directories(${ZSTD_INCLUDE_DIRS})
list(APPEND LINK_LIBS ${LIBZSTD_LDFLAGS})
if(ENABLE_ZSTD)
include_directories(${ZSTD_INCLUDE_DIRS})
list(APPEND LINK_LIBS ${LIBZSTD_LDFLAGS})
endif()
target_link_libraries(relay ${LINK_LIBS} coverage_config)
@@ -29,7 +29,9 @@
#include <errno.h>
#include <arpa/inet.h>
#include <zlib.h>
#ifdef HAVE_ZSTD
#include <zstd.h>
#endif
#include "../../weechat-plugin.h"
#include "../relay.h"
@@ -1111,6 +1113,7 @@ int
relay_weechat_msg_compress_zstd (struct t_relay_client *client,
struct t_relay_weechat_msg *msg)
{
#ifdef HAVE_ZSTD
char raw_message[1024];
uint32_t size32;
Bytef *dest;
@@ -1169,6 +1172,13 @@ error:
free (dest);
return rc;
#else
/* make C compiler happy */
(void) client;
(void) msg;
return 0;
#endif /* HAVE_ZSTD */
}
/*
@@ -1190,10 +1200,12 @@ relay_weechat_msg_send (struct t_relay_client *client,
if (relay_weechat_msg_compress_zlib (client, msg))
return;
break;
#ifdef HAVE_ZSTD
case RELAY_WEECHAT_COMPRESSION_ZSTD:
if (relay_weechat_msg_compress_zstd (client, msg))
return;
break;
#endif
default:
break;
}
+8 -2
View File
@@ -40,8 +40,14 @@
#include "../relay-raw.h"
char *relay_weechat_compression_string[] = /* strings for compression */
{ "off", "zlib", "zstd" };
/* strings for compression */
char *relay_weechat_compression_string[RELAY_WEECHAT_NUM_COMPRESSIONS] = {
"off",
"zlib",
#ifdef HAVE_ZSTD
"zstd",
#endif
};
/*
@@ -34,7 +34,9 @@ enum t_relay_weechat_compression
{
RELAY_WEECHAT_COMPRESSION_OFF = 0, /* no compression of binary objects */
RELAY_WEECHAT_COMPRESSION_ZLIB, /* zlib compression */
#ifdef HAVE_ZSTD
RELAY_WEECHAT_COMPRESSION_ZSTD, /* Zstandard compression */
#endif
/* number of compressions */
RELAY_WEECHAT_NUM_COMPRESSIONS,
};