summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPřemysl Janouch <p.janouch@gmail.com>2015-06-23 21:04:38 +0200
committerPřemysl Janouch <p.janouch@gmail.com>2015-06-23 21:04:38 +0200
commit63a65f9f7cf255934558902a57d969eba87b160b (patch)
tree10f3e1b20fa3895b097d6d2e513374a46a5cc323
parentc3439175d7ced235822bcecb37ff0fdebcdc9f1c (diff)
downloadxK-63a65f9f7cf255934558902a57d969eba87b160b.tar.gz
xK-63a65f9f7cf255934558902a57d969eba87b160b.tar.xz
xK-63a65f9f7cf255934558902a57d969eba87b160b.zip
degesch: stubplement casemapping changes
-rw-r--r--degesch.c51
1 files 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