summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2021-01-30 10:34:23 +0100
committerSébastien Helleu <flashcode@flashtux.org>2021-01-30 10:34:23 +0100
commit691c9a0a0fead81cf1b651c5d875b46e0af8e037 (patch)
tree6fce8fb9babbb624d73c28ec72e9c557c40ca9f0 /src
parent0c98b0cfa42e90574a858c4ff27f7f45f05b3748 (diff)
downloadweechat-691c9a0a0fead81cf1b651c5d875b46e0af8e037.zip
irc: add function irc_server_get_chantypes
Diffstat (limited to 'src')
-rw-r--r--src/plugins/irc/irc-channel.c14
-rw-r--r--src/plugins/irc/irc-nick.c11
-rw-r--r--src/plugins/irc/irc-server.c19
-rw-r--r--src/plugins/irc/irc-server.h1
4 files changed, 24 insertions, 21 deletions
diff --git a/src/plugins/irc/irc-channel.c b/src/plugins/irc/irc-channel.c
index cd5d034e7..b81f87f73 100644
--- a/src/plugins/irc/irc-channel.c
+++ b/src/plugins/irc/irc-channel.c
@@ -675,14 +675,8 @@ irc_channel_is_channel (struct t_irc_server *server, const char *string)
first_char[0] = string[0];
first_char[1] = '\0';
- /* default global chantypes if no server received */
- if (!server)
- return (strpbrk (first_char, irc_channel_default_chantypes)) ? 1 : 0;
-
- /* server chantypes, or option "default_chantypes" as fallback */
- ptr_chantypes = (server->chantypes) ?
- server->chantypes :
- IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_CHANTYPES);
+ ptr_chantypes = irc_server_get_chantypes (server);
+
return (strpbrk (first_char, ptr_chantypes)) ? 1 : 0;
}
@@ -707,9 +701,7 @@ irc_channel_get_auto_chantype (struct t_irc_server *server,
if (weechat_config_boolean (irc_config_look_join_auto_add_chantype)
&& !irc_channel_is_channel (server, channel_name))
{
- ptr_chantypes = (server->chantypes) ?
- server->chantypes :
- IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_CHANTYPES);
+ ptr_chantypes = irc_server_get_chantypes (server);
if (ptr_chantypes && ptr_chantypes[0])
{
/*
diff --git a/src/plugins/irc/irc-nick.c b/src/plugins/irc/irc-nick.c
index e09b41d44..67390354b 100644
--- a/src/plugins/irc/irc-nick.c
+++ b/src/plugins/irc/irc-nick.c
@@ -81,16 +81,7 @@ irc_nick_is_nick (struct t_irc_server *server, const char *string)
utf8mapping = (server) ? server->utf8mapping : IRC_SERVER_UTF8MAPPING_NONE;
ptr_prefix_chars = (server && server->prefix_chars) ?
server->prefix_chars : irc_server_prefix_chars_default;
- if (server)
- {
- ptr_chantypes = (server->chantypes) ?
- server->chantypes :
- IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_CHANTYPES);
- }
- else
- {
- ptr_chantypes = irc_channel_default_chantypes;
- }
+ ptr_chantypes = irc_server_get_chantypes (server);
/* check length of nick in bytes (if we have a limit in the server) */
if (server && (server->nick_max_length > 0)
diff --git a/src/plugins/irc/irc-server.c b/src/plugins/irc/irc-server.c
index 2695dbff1..f7b2138f2 100644
--- a/src/plugins/irc/irc-server.c
+++ b/src/plugins/irc/irc-server.c
@@ -1001,6 +1001,25 @@ irc_server_get_isupport_value (struct t_irc_server *server, const char *feature)
}
/*
+ * Gets "chantypes" for the server:
+ * - if server is NULL, returns pointer to irc_channel_default_chantypes
+ * - if server is not NULL, returns either chantypes in the server or
+ * server option "default_chantypes"
+ */
+
+const char *
+irc_server_get_chantypes (struct t_irc_server *server)
+{
+ if (!server)
+ return irc_channel_default_chantypes;
+
+ if (server->chantypes)
+ return server->chantypes;
+
+ return IRC_SERVER_OPTION_STRING(server, IRC_SERVER_OPTION_DEFAULT_CHANTYPES);
+}
+
+/*
* Sets "prefix_modes" and "prefix_chars" in server using value of PREFIX in IRC
* message 005.
*
diff --git a/src/plugins/irc/irc-server.h b/src/plugins/irc/irc-server.h
index f62f84a1e..11d8bf281 100644
--- a/src/plugins/irc/irc-server.h
+++ b/src/plugins/irc/irc-server.h
@@ -319,6 +319,7 @@ extern void irc_server_set_host (struct t_irc_server *server,
extern const char *irc_server_get_alternate_nick (struct t_irc_server *server);
extern const char *irc_server_get_isupport_value (struct t_irc_server *server,
const char *feature);
+extern const char *irc_server_get_chantypes (struct t_irc_server *server);
extern void irc_server_set_prefix_modes_chars (struct t_irc_server *server,
const char *prefix);
extern void irc_server_set_lag (struct t_irc_server *server);