From 63a65f9f7cf255934558902a57d969eba87b160b Mon Sep 17 00:00:00 2001
From: Přemysl Janouch
Date: Tue, 23 Jun 2015 21:04:38 +0200
Subject: degesch: stubplement casemapping changes
---
degesch.c | 51 +++++++++++++++++++++++++++++----------------------
1 file changed, 29 insertions(+), 22 deletions(-)
diff --git a/degesch.c b/degesch.c
index acd4856..f997471 100644
--- a/degesch.c
+++ b/degesch.c
@@ -2919,6 +2919,29 @@ irc_left_channel (struct channel *channel)
irc_channel_unlink_user (channel, iter);
}
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+static void
+irc_rehash_and_fix_conflicts (struct server *s)
+{
+ // TODO
+}
+
+static void
+irc_set_casemapping (struct server *s,
+ irc_tolower_fn tolower, irc_strxfrm_fn strxfrm)
+{
+ if (tolower == s->irc_tolower
+ && strxfrm == s->irc_strxfrm)
+ return;
+
+ s->irc_tolower = tolower;
+ s->irc_strxfrm = strxfrm;
+
+ // Ideally we would never have to do this but I can't think of a workaround
+ irc_rehash_and_fix_conflicts (s);
+}
+
// --- Core functionality ------------------------------------------------------
// Most of the core IRC code comes from ZyklonB which is mostly blocking.
@@ -3267,15 +3290,11 @@ on_irc_disconnected (struct server *s)
s->cap_echo_message = false;
- irc_tolower_fn old_tolower = s->irc_tolower;
- irc_strxfrm_fn old_strxfrm = s->irc_strxfrm;
+ // Need to call this before server_init_specifics()
+ irc_set_casemapping (s, irc_tolower, irc_strxfrm);
+
server_free_specifics (s);
server_init_specifics (s);
- // TODO: compare with the original functions and merge users and their
- // buffers as necessary; ideally we would never have to do this but
- // I can't think of any good workaround
- s->irc_tolower = old_tolower;
- s->irc_strxfrm = old_strxfrm;
// Take any relevant actions
if (s->ctx->quitting)
@@ -5203,25 +5222,13 @@ irc_handle_isupport_prefix (struct server *s, char *value)
static void
irc_handle_isupport_casemapping (struct server *s, char *value)
{
- // TODO: reinitialize hashtables with the new tolower() and strxfrm(),
- // note that collisions may arise on reconnecting
-
if (!strcmp (value, "ascii"))
- {
- s->irc_tolower = tolower_ascii;
- s->irc_strxfrm = tolower_ascii_strxfrm;
- }
+ irc_set_casemapping (s, tolower_ascii, tolower_ascii_strxfrm);
else if (!strcmp (value, "rfc1459"))
- {
- s->irc_tolower = irc_tolower;
- s->irc_strxfrm = irc_strxfrm;
- }
+ irc_set_casemapping (s, irc_tolower, irc_strxfrm);
else if (!strcmp (value, "rfc1459-strict"))
- {
// TODO: implement
- s->irc_tolower = irc_tolower;
- s->irc_strxfrm = irc_strxfrm;
- }
+ irc_set_casemapping (s, irc_tolower, irc_strxfrm);
}
static void
--
cgit v1.2.3-70-g09d2