mirror of
https://github.com/weechat/weechat.git
synced 2026-06-29 14:26:39 +02:00
relay: rename compression "gzip" to "zlib" (compression is zlib, not gzip) (thanks to Dominik Honnef)
This commit is contained in:
@@ -999,52 +999,58 @@ relay_weechat_msg_send (struct t_relay_client *client,
|
||||
struct timeval tv1, tv2;
|
||||
long time_diff;
|
||||
|
||||
if (RELAY_WEECHAT_DATA(client, compression)
|
||||
&& (weechat_config_integer (relay_config_network_compression_level) > 0))
|
||||
if (weechat_config_integer (relay_config_network_compression_level) > 0)
|
||||
{
|
||||
dest_size = compressBound (msg->data_size - 5);
|
||||
dest = malloc (dest_size + 5);
|
||||
if (dest)
|
||||
switch (RELAY_WEECHAT_DATA(client, compression))
|
||||
{
|
||||
gettimeofday (&tv1, NULL);
|
||||
rc = compress2 (dest + 5, &dest_size,
|
||||
(Bytef *)(msg->data + 5), msg->data_size - 5,
|
||||
weechat_config_integer (relay_config_network_compression_level));
|
||||
gettimeofday (&tv2, NULL);
|
||||
time_diff = weechat_util_timeval_diff (&tv1, &tv2);
|
||||
if ((rc == Z_OK) && ((int)dest_size + 5 < msg->data_size))
|
||||
{
|
||||
/* set size and compression flag */
|
||||
size32 = htonl ((uint32_t)(dest_size + 5));
|
||||
memcpy (dest, &size32, 4);
|
||||
dest[4] = 1;
|
||||
case RELAY_WEECHAT_COMPRESSION_ZLIB:
|
||||
dest_size = compressBound (msg->data_size - 5);
|
||||
dest = malloc (dest_size + 5);
|
||||
if (dest)
|
||||
{
|
||||
gettimeofday (&tv1, NULL);
|
||||
rc = compress2 (dest + 5, &dest_size,
|
||||
(Bytef *)(msg->data + 5), msg->data_size - 5,
|
||||
weechat_config_integer (relay_config_network_compression_level));
|
||||
gettimeofday (&tv2, NULL);
|
||||
time_diff = weechat_util_timeval_diff (&tv1, &tv2);
|
||||
if ((rc == Z_OK) && ((int)dest_size + 5 < msg->data_size))
|
||||
{
|
||||
/* set size and compression flag */
|
||||
size32 = htonl ((uint32_t)(dest_size + 5));
|
||||
memcpy (dest, &size32, 4);
|
||||
dest[4] = RELAY_WEECHAT_COMPRESSION_ZLIB;
|
||||
|
||||
/* display message in raw buffer */
|
||||
snprintf (raw_message, sizeof (raw_message),
|
||||
"obj: %d/%d bytes (%d%%, %ldms), id: %s",
|
||||
(int)dest_size + 5,
|
||||
msg->data_size,
|
||||
100 - ((((int)dest_size + 5) * 100) / msg->data_size),
|
||||
time_diff,
|
||||
msg->id);
|
||||
/* display message in raw buffer */
|
||||
snprintf (raw_message, sizeof (raw_message),
|
||||
"obj: %d/%d bytes (%d%%, %ldms), id: %s",
|
||||
(int)dest_size + 5,
|
||||
msg->data_size,
|
||||
100 - ((((int)dest_size + 5) * 100) / msg->data_size),
|
||||
time_diff,
|
||||
msg->id);
|
||||
|
||||
/* send compressed data */
|
||||
relay_client_send (client, (const char *)dest, dest_size + 5,
|
||||
raw_message);
|
||||
/* send compressed data */
|
||||
relay_client_send (client, (const char *)dest, dest_size + 5,
|
||||
raw_message);
|
||||
|
||||
free (dest);
|
||||
return;
|
||||
}
|
||||
free (dest);
|
||||
free (dest);
|
||||
return;
|
||||
}
|
||||
free (dest);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* compression with zlib failed (or not asked), send uncompressed message */
|
||||
/* compression failed (or not asked), send uncompressed message */
|
||||
|
||||
/* set size and compression flag */
|
||||
size32 = htonl ((uint32_t)msg->data_size);
|
||||
relay_weechat_msg_set_bytes (msg, 0, &size32, 4);
|
||||
compression = 0;
|
||||
compression = RELAY_WEECHAT_COMPRESSION_OFF;
|
||||
relay_weechat_msg_set_bytes (msg, 4, &compression, 1);
|
||||
|
||||
/* send uncompressed data */
|
||||
|
||||
@@ -159,7 +159,7 @@ relay_weechat_protocol_is_sync (struct t_relay_client *ptr_client,
|
||||
*
|
||||
* Message looks like:
|
||||
* init password=mypass
|
||||
* init password=mypass,compression=gzip
|
||||
* init password=mypass,compression=zlib
|
||||
* init password=mypass,compression=off
|
||||
*/
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
|
||||
|
||||
char *relay_weechat_compression_string[] = /* strings for compressions */
|
||||
{ "off", "gzip" };
|
||||
{ "off", "zlib" };
|
||||
|
||||
|
||||
/*
|
||||
@@ -175,7 +175,7 @@ relay_weechat_alloc (struct t_relay_client *client)
|
||||
if (client->protocol_data)
|
||||
{
|
||||
RELAY_WEECHAT_DATA(client, password_ok) = (password && password[0]) ? 0 : 1;
|
||||
RELAY_WEECHAT_DATA(client, compression) = 1;
|
||||
RELAY_WEECHAT_DATA(client, compression) = RELAY_WEECHAT_COMPRESSION_ZLIB;
|
||||
RELAY_WEECHAT_DATA(client, nicklist_diff) = 0;
|
||||
RELAY_WEECHAT_DATA(client, buffers_sync) =
|
||||
weechat_hashtable_new (32,
|
||||
|
||||
@@ -28,7 +28,7 @@ struct t_relay_client;
|
||||
enum t_relay_weechat_compression
|
||||
{
|
||||
RELAY_WEECHAT_COMPRESSION_OFF = 0, /* no compression of binary objects */
|
||||
RELAY_WEECHAT_COMPRESSION_GZIP, /* gzip compression */
|
||||
RELAY_WEECHAT_COMPRESSION_ZLIB, /* zlib compression */
|
||||
/* number of compressions */
|
||||
RELAY_WEECHAT_NUM_COMPRESSIONS,
|
||||
};
|
||||
@@ -36,7 +36,7 @@ enum t_relay_weechat_compression
|
||||
struct t_relay_weechat_data
|
||||
{
|
||||
int password_ok; /* password received and OK? */
|
||||
int compression; /* compression type */
|
||||
enum t_relay_weechat_compression compression; /* compression type */
|
||||
int nicklist_diff; /* (TEMPORARY) nicklist diff enabled?*/
|
||||
|
||||
/* sync of buffers */
|
||||
|
||||
Reference in New Issue
Block a user