From 0bf5adcb932e2dfa7ca8caf2668b6eb9bc85ed0c Mon Sep 17 00:00:00 2001 From: Valentin Batz Date: Thu, 24 Nov 2005 18:17:57 +0000 Subject: Initialize the isupport functions on /upgrade aswell git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4096 dbcabf3a-b0e7-0310-adc4-f8d773084564 --- src/irc/core/irc-servers.c | 90 +++++++++++++++++++++++++--------------------- src/irc/core/irc-servers.h | 1 + src/irc/core/irc-session.c | 1 + 3 files changed, 51 insertions(+), 41 deletions(-) (limited to 'src/irc') diff --git a/src/irc/core/irc-servers.c b/src/irc/core/irc-servers.c index 269720f3..ff35b249 100644 --- a/src/irc/core/irc-servers.c +++ b/src/irc/core/irc-servers.c @@ -595,7 +595,7 @@ static void parse_chanmodes(IRC_SERVER_REC *server, const char *sptr) chanmodes = g_strsplit(sptr, ",", 5); /* ignore extras */ for (i = 0, item = chanmodes; *item != NULL && i < 4; item++, i++) { - unsigned char *p = *item; + unsigned char *p = (unsigned char*) *item; while (*p != '\0') { server->modes[(int)*p].func = modefuncs[i]; p++; @@ -626,6 +626,7 @@ static void parse_prefix(IRC_SERVER_REC *server, const char *sptr) } } + static void event_isupport(IRC_SERVER_REC *server, const char *data) { char **item, *sptr, *eptr; @@ -679,47 +680,8 @@ static void event_isupport(IRC_SERVER_REC *server, const char *data) g_free(value); } g_strfreev(isupport); + irc_server_init_isupport(server); - /* chanmodes/prefix will fully override defaults */ - memset(server->modes, 0, sizeof(server->modes)); - memset(server->prefix, 0, sizeof(server->prefix)); - - if ((sptr = g_hash_table_lookup(server->isupport, "CHANMODES"))) - parse_chanmodes(server, sptr); - - /* This is after chanmode because some servers define modes in both */ - if (g_hash_table_lookup_extended(server->isupport, "PREFIX", - &key, &value)) { - sptr = value; - if (*sptr != '(') { - /* server incompatible with isupport draft */ - g_hash_table_remove(server->isupport, key); - g_free(key); - g_free(value); - sptr = NULL; - } - } else { - sptr = NULL; - } - - if (sptr == NULL) { - sptr = g_strdup("(ohv)@%+"); - g_hash_table_insert(server->isupport, g_strdup("PREFIX"), sptr); - } - parse_prefix(server, sptr); - - if ((sptr = g_hash_table_lookup(server->isupport, "MODES"))) { - server->max_modes_in_cmd = atoi(sptr); - if (server->max_modes_in_cmd < 1) - server->max_modes_in_cmd = DEFAULT_MAX_MODES; - } - - if ((sptr = g_hash_table_lookup(server->isupport, "CASEMAPPING"))) { - if (strstr(sptr, "rfc1459") != NULL) - server->nick_comp_func = irc_nickcmp_rfc1459; - else - server->nick_comp_func = irc_nickcmp_ascii; - } } static void event_motd(IRC_SERVER_REC *server, const char *data, const char *from) @@ -787,6 +749,52 @@ static void event_empty(void) { } +void irc_server_init_isupport(IRC_SERVER_REC *server) +{ + char *sptr; + gpointer key, value; + /* chanmodes/prefix will fully override defaults */ + memset(server->modes, 0, sizeof(server->modes)); + memset(server->prefix, 0, sizeof(server->prefix)); + + if ((sptr = g_hash_table_lookup(server->isupport, "CHANMODES"))) + parse_chanmodes(server, sptr); + + /* This is after chanmode because some servers define modes in both */ + if (g_hash_table_lookup_extended(server->isupport, "PREFIX", + &key, &value)) { + sptr = value; + if (*sptr != '(') { + /* server incompatible with isupport draft */ + g_hash_table_remove(server->isupport, key); + g_free(key); + g_free(value); + sptr = NULL; + } + } else { + sptr = NULL; + } + + if (sptr == NULL) { + sptr = g_strdup("(ohv)@%+"); + g_hash_table_insert(server->isupport, g_strdup("PREFIX"), sptr); + } + parse_prefix(server, sptr); + + if ((sptr = g_hash_table_lookup(server->isupport, "MODES"))) { + server->max_modes_in_cmd = atoi(sptr); + if (server->max_modes_in_cmd < 1) + server->max_modes_in_cmd = DEFAULT_MAX_MODES; + } + + if ((sptr = g_hash_table_lookup(server->isupport, "CASEMAPPING"))) { + if (strstr(sptr, "rfc1459") != NULL) + server->nick_comp_func = irc_nickcmp_rfc1459; + else + server->nick_comp_func = irc_nickcmp_ascii; + } +} + void irc_servers_init(void) { settings_add_str("misc", "usermode", DEFAULT_USER_MODE); diff --git a/src/irc/core/irc-servers.h b/src/irc/core/irc-servers.h index c1d1d9f0..7352b876 100644 --- a/src/irc/core/irc-servers.h +++ b/src/irc/core/irc-servers.h @@ -118,6 +118,7 @@ char *irc_server_get_channels(IRC_SERVER_REC *server); /* INTERNAL: */ void irc_server_send_data(IRC_SERVER_REC *server, const char *data, int len); +void irc_server_init_isupport(IRC_SERVER_REC *server); void irc_servers_init(void); void irc_servers_deinit(void); diff --git a/src/irc/core/irc-session.c b/src/irc/core/irc-session.c index 5838e0d9..8eb6facf 100644 --- a/src/irc/core/irc-session.c +++ b/src/irc/core/irc-session.c @@ -106,6 +106,7 @@ static void sig_session_restore_server(IRC_SERVER_REC *server, g_hash_table_insert(server->isupport, g_strdup(node->key), g_strdup(node->value)); } + irc_server_init_isupport(server); } -- cgit v1.2.3