summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/core/CMakeLists.txt4
-rw-r--r--src/core/wee-debug.c4
-rw-r--r--src/core/wee-dir.c13
-rw-r--r--src/gui/curses/CMakeLists.txt5
-rw-r--r--src/plugins/logger/logger-buffer.c8
-rw-r--r--src/plugins/logger/logger-config.c30
-rw-r--r--src/plugins/relay/CMakeLists.txt6
-rw-r--r--src/plugins/relay/weechat/relay-weechat-msg.c12
-rw-r--r--src/plugins/relay/weechat/relay-weechat.c10
-rw-r--r--src/plugins/relay/weechat/relay-weechat.h2
10 files changed, 86 insertions, 8 deletions
diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt
index 0769999a4..2f21d146a 100644
--- a/src/core/CMakeLists.txt
+++ b/src/core/CMakeLists.txt
@@ -91,7 +91,9 @@ include_directories(${GNUTLS_INCLUDE_PATH})
include_directories(${CURL_INCLUDE_DIRS})
-include_directories(${ZSTD_INCLUDE_DIRS})
+if(ENABLE_ZSTD)
+ include_directories(${ZSTD_INCLUDE_DIRS})
+endif()
include_directories("${CMAKE_BINARY_DIR}")
add_library(weechat_core STATIC ${LIB_CORE_SRC})
diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c
index b0bc8a4f1..ef93135db 100644
--- a/src/core/wee-debug.c
+++ b/src/core/wee-debug.c
@@ -33,7 +33,9 @@
#include <gcrypt.h>
#include <curl/curl.h>
#include <zlib.h>
+#ifdef HAVE_ZSTD
#include <zstd.h>
+#endif
#include <gnutls/gnutls.h>
@@ -683,11 +685,13 @@ debug_libs_cb (const void *pointer, void *data,
gui_chat_printf (NULL, " zlib: (?)");
#endif /* ZLIB_VERSION */
+#ifdef HAVE_ZSTD
/* display zstd version */
gui_chat_printf (NULL, " zstd: %d.%d.%d",
ZSTD_VERSION_MAJOR,
ZSTD_VERSION_MINOR,
ZSTD_VERSION_RELEASE);
+#endif /* HAVE_ZSTD */
return WEECHAT_RC_OK;
}
diff --git a/src/core/wee-dir.c b/src/core/wee-dir.c
index bd1252616..d05280861 100644
--- a/src/core/wee-dir.c
+++ b/src/core/wee-dir.c
@@ -45,7 +45,9 @@
#include <dirent.h>
#include <ftw.h>
#include <zlib.h>
+#ifdef HAVE_ZSTD
#include <zstd.h>
+#endif
#include "weechat.h"
#include "wee-config.h"
@@ -1135,6 +1137,7 @@ int
dir_file_compress_zstd (const char *from, const char *to,
int compression_level)
{
+#ifdef HAVE_ZSTD
FILE *source, *dest;
void *buffer_in, *buffer_out;
size_t buffer_in_size, buffer_out_size, num_read, remaining;
@@ -1297,6 +1300,14 @@ end:
fclose (dest);
return rc;
+#else
+ /* make C compiler happy */
+ (void) from;
+ (void) to;
+ (void) compression_level;
+
+ return 0;
+#endif /* HAVE_ZSTD */
}
/*
@@ -1306,7 +1317,7 @@ end:
*
* Supported values for parameter "compressor":
* - "gzip": gzip compression (via zlib)
- * - "zstd": zstandard compression
+ * - "zstd": zstandard compression (it must be enabled at build time)
*
* Parameter "compression_level" is the compression level as percentage:
* from 1 (fast, low compression) to 100 (slow, best compression).
diff --git a/src/gui/curses/CMakeLists.txt b/src/gui/curses/CMakeLists.txt
index 585c0d5a7..21e19aacb 100644
--- a/src/gui/curses/CMakeLists.txt
+++ b/src/gui/curses/CMakeLists.txt
@@ -48,7 +48,10 @@ list(APPEND EXTRA_LIBS "m")
list(APPEND EXTRA_LIBS ${CURL_LIBRARIES})
list(APPEND EXTRA_LIBS ${ZLIB_LIBRARY})
-list(APPEND EXTRA_LIBS ${LIBZSTD_LDFLAGS})
+
+if(ENABLE_ZSTD)
+ list(APPEND EXTRA_LIBS ${LIBZSTD_LDFLAGS})
+endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# link with resolv lib on macOS
diff --git a/src/plugins/logger/logger-buffer.c b/src/plugins/logger/logger-buffer.c
index 571cd5c87..dcbd8b7e3 100644
--- a/src/plugins/logger/logger-buffer.c
+++ b/src/plugins/logger/logger-buffer.c
@@ -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 */
diff --git a/src/plugins/logger/logger-config.c b/src/plugins/logger/logger-config.c
index 67ebb6020..287dffb10 100644
--- a/src/plugins/logger/logger-config.c
+++ b/src/plugins/logger/logger-config.c
@@ -94,6 +94,32 @@ logger_config_change_file_option_restart_log (const void *pointer, void *data,
}
/*
+ * 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",
diff --git a/src/plugins/relay/CMakeLists.txt b/src/plugins/relay/CMakeLists.txt
index dee24c307..953aa7227 100644
--- a/src/plugins/relay/CMakeLists.txt
+++ b/src/plugins/relay/CMakeLists.txt
@@ -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)
diff --git a/src/plugins/relay/weechat/relay-weechat-msg.c b/src/plugins/relay/weechat/relay-weechat-msg.c
index af2bd3d78..aab57d87e 100644
--- a/src/plugins/relay/weechat/relay-weechat-msg.c
+++ b/src/plugins/relay/weechat/relay-weechat-msg.c
@@ -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;
}
diff --git a/src/plugins/relay/weechat/relay-weechat.c b/src/plugins/relay/weechat/relay-weechat.c
index c61aacf3a..cfb39922b 100644
--- a/src/plugins/relay/weechat/relay-weechat.c
+++ b/src/plugins/relay/weechat/relay-weechat.c
@@ -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
+};
/*
diff --git a/src/plugins/relay/weechat/relay-weechat.h b/src/plugins/relay/weechat/relay-weechat.h
index 469536aac..b2b0438b7 100644
--- a/src/plugins/relay/weechat/relay-weechat.h
+++ b/src/plugins/relay/weechat/relay-weechat.h
@@ -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,
};