diff options
author | Sébastien Helleu <flashcode@flashtux.org> | 2023-05-14 09:16:40 +0200 |
---|---|---|
committer | Sébastien Helleu <flashcode@flashtux.org> | 2023-05-14 15:32:39 +0200 |
commit | 128fbe0d5beb6050bbf775e81a4b693ef8d40d42 (patch) | |
tree | e299732a8822ff3cc8272fc3e44235edb46ac799 /src/plugins/irc | |
parent | 1116474c45ebb00011ec8c1694dda230251f17b3 (diff) | |
download | weechat-128fbe0d5beb6050bbf775e81a4b693ef8d40d42.zip |
irc: add support of "LINELEN" in message 005 (max message length in bytes) (closes #1927)
Diffstat (limited to 'src/plugins/irc')
-rw-r--r-- | src/plugins/irc/irc-message.c | 6 | ||||
-rw-r--r-- | src/plugins/irc/irc-protocol.c | 8 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.c | 7 | ||||
-rw-r--r-- | src/plugins/irc/irc-server.h | 1 | ||||
-rw-r--r-- | src/plugins/irc/irc-upgrade.c | 1 |
5 files changed, 20 insertions, 3 deletions
diff --git a/src/plugins/irc/irc-message.c b/src/plugins/irc/irc-message.c index bc5023727..0be7cb1d6 100644 --- a/src/plugins/irc/irc-message.c +++ b/src/plugins/irc/irc-message.c @@ -1518,8 +1518,10 @@ irc_message_split (struct t_irc_server *server, const char *message) if (server) { - split_msg_max_length = IRC_SERVER_OPTION_INTEGER( - server, IRC_SERVER_OPTION_SPLIT_MSG_MAX_LENGTH); + split_msg_max_length = (server->msg_max_length > 0) ? + server->msg_max_length : + IRC_SERVER_OPTION_INTEGER( + server, IRC_SERVER_OPTION_SPLIT_MSG_MAX_LENGTH); /* if split disabled, use a high max_length to prevent any split */ if (split_msg_max_length == 0) split_msg_max_length = INT_MAX - 16; diff --git a/src/plugins/irc/irc-protocol.c b/src/plugins/irc/irc-protocol.c index d5c59b909..a5e9878a7 100644 --- a/src/plugins/irc/irc-protocol.c +++ b/src/plugins/irc/irc-protocol.c @@ -3886,6 +3886,14 @@ IRC_PROTOCOL_CALLBACK(005) /* save prefix */ irc_server_set_prefix_modes_chars (server, params[i] + 7); } + else if (strncmp (params[i], "LINELEN=", 8) == 0) + { + /* save max message length */ + error = NULL; + value = strtol (params[i] + 8, &error, 10); + if (error && !error[0] && (value > 0)) + server->msg_max_length = (int)value; + } else if (strncmp (params[i], "NICKLEN=", 8) == 0) { /* save max nick length */ diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c index 8d334e8dc..c1b752e3c 100644 --- a/src/plugins/irc/irc-server.c +++ b/src/plugins/irc/irc-server.c @@ -1686,6 +1686,7 @@ irc_server_alloc (const char *name) new_server->isupport = NULL; new_server->prefix_modes = NULL; new_server->prefix_chars = NULL; + new_server->msg_max_length = 0; new_server->nick_max_length = 0; new_server->user_max_length = 0; new_server->host_max_length = 0; @@ -5666,6 +5667,7 @@ irc_server_disconnect (struct t_irc_server *server, int switch_address, free (server->prefix_chars); server->prefix_chars = NULL; } + server->msg_max_length = 0; server->nick_max_length = 0; server->user_max_length = 0; server->host_max_length = 0; @@ -6364,7 +6366,7 @@ irc_server_hdata_server_cb (const void *pointer, void *data, WEECHAT_HDATA_VAR(struct t_irc_server, isupport, STRING, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, prefix_modes, STRING, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, prefix_chars, STRING, 0, NULL, NULL); - WEECHAT_HDATA_VAR(struct t_irc_server, nick_max_length, INTEGER, 0, NULL, NULL); + WEECHAT_HDATA_VAR(struct t_irc_server, msg_max_length, INTEGER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, user_max_length, INTEGER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, host_max_length, INTEGER, 0, NULL, NULL); WEECHAT_HDATA_VAR(struct t_irc_server, casemapping, INTEGER, 0, NULL, NULL); @@ -6735,6 +6737,8 @@ irc_server_add_to_infolist (struct t_infolist *infolist, return 0; if (!weechat_infolist_new_var_string (ptr_item, "prefix_chars", server->prefix_chars)) return 0; + if (!weechat_infolist_new_var_integer (ptr_item, "msg_max_length", server->msg_max_length)) + return 0; if (!weechat_infolist_new_var_integer (ptr_item, "nick_max_length", server->nick_max_length)) return 0; if (!weechat_infolist_new_var_integer (ptr_item, "user_max_length", server->user_max_length)) @@ -7132,6 +7136,7 @@ irc_server_print_log () weechat_log_printf (" isupport. . . . . . . . . : '%s'", ptr_server->isupport); weechat_log_printf (" prefix_modes. . . . . . . : '%s'", ptr_server->prefix_modes); weechat_log_printf (" prefix_chars. . . . . . . : '%s'", ptr_server->prefix_chars); + weechat_log_printf (" msg_max_length. . . . . . : %d", ptr_server->msg_max_length); weechat_log_printf (" nick_max_length . . . . . : %d", ptr_server->nick_max_length); weechat_log_printf (" user_max_length . . . . . : %d", ptr_server->user_max_length); weechat_log_printf (" host_max_length . . . . . : %d", ptr_server->host_max_length); diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h index 2bee2b6d3..979160b9b 100644 --- a/src/plugins/irc/irc-server.h +++ b/src/plugins/irc/irc-server.h @@ -242,6 +242,7 @@ struct t_irc_server char *isupport; /* copy of message 005 (ISUPPORT) */ char *prefix_modes; /* prefix modes from msg 005 (eg "ohv") */ char *prefix_chars; /* prefix chars from msg 005 (eg "@%+") */ + int msg_max_length; /* max length of msg (from msg 005) */ int nick_max_length; /* max length of nick (from msg 005) */ int user_max_length; /* max length of user (from msg 005) */ int host_max_length; /* max length of host (from msg 005) */ diff --git a/src/plugins/irc/irc-upgrade.c b/src/plugins/irc/irc-upgrade.c index ec34b9a85..231eb8805 100644 --- a/src/plugins/irc/irc-upgrade.c +++ b/src/plugins/irc/irc-upgrade.c @@ -501,6 +501,7 @@ irc_upgrade_read_cb (const void *pointer, void *data, free (irc_upgrade_current_server->prefix_chars); irc_upgrade_current_server->prefix_chars = strdup (str); } + irc_upgrade_current_server->msg_max_length = weechat_infolist_integer (infolist, "msg_max_length"); irc_upgrade_current_server->nick_max_length = weechat_infolist_integer (infolist, "nick_max_length"); /* "user_max_length" is new in WeeChat 2.6 */ if (weechat_infolist_search_var (infolist, "user_max_length")) |