diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-10-01 16:36:32 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-10-01 16:36:32 +0200 |
commit | 6bd0c63192e7acefbb7538a22aa061912cfc06f7 (patch) | |
tree | 2a8bc77faf556b5bda22e83409514fcdff3abd2f /src/plugins/relay | |
parent | 879a548beae9b02da65526c1016c903d69c0225c (diff) | |
download | weechat-6bd0c63192e7acefbb7538a22aa061912cfc06f7.zip |
core: make zstd dependency optional (closes #2024)
Diffstat (limited to 'src/plugins/relay')
-rw-r--r-- | src/plugins/relay/CMakeLists.txt | 6 | ||||
-rw-r--r-- | src/plugins/relay/weechat/relay-weechat-msg.c | 12 | ||||
-rw-r--r-- | src/plugins/relay/weechat/relay-weechat.c | 10 | ||||
-rw-r--r-- | src/plugins/relay/weechat/relay-weechat.h | 2 |
4 files changed, 26 insertions, 4 deletions
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, }; |