1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Initialize the isupport functions on /upgrade aswell

git-svn-id: http://svn.irssi.org/repos/irssi/trunk@4096 dbcabf3a-b0e7-0310-adc4-f8d773084564
This commit is contained in:
Valentin Batz 2005-11-24 18:17:57 +00:00 committed by vb
parent fb6bdac677
commit 0bf5adcb93
3 changed files with 51 additions and 41 deletions

View File

@ -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);

View File

@ -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);

View File

@ -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);
}